From a650754f4e6737cde0bb765b6e593220eb19849e Mon Sep 17 00:00:00 2001 From: sober-wang Date: Sun, 15 Jul 2018 13:06:43 +0800 Subject: [PATCH 001/455] =?UTF-8?q?2018=E5=B9=B47=E6=9C=8815=E6=97=A5?= =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...6 Linux Virtual Machines vs Linux Live Images.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md index 9b927bb348..ced49524bd 100644 --- a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md +++ b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md @@ -12,16 +12,23 @@ I'll be the first to admit(认可) that I tend(照顾) to try out new [L When I test out a brand new Linux distro for the first time, the method I use depends heavily(沉重的) on the resources(资源) of the PC I'm currently(目前的) on. If I have access to my desktop PC, I'm going to run the distro to be tested in a virtual machine. The reason(理由) for this approach(靠近) is that I can download and test the distro in not only a live environment(环境), but also(也) as an installed product with persistent(稳定的) storage abilities(能力). -为了第一时间去做 Linux 发型版本的依赖测试,我把它们运行在我目前所拥有的所有类型的 PC 上。如果我用我的台式机,我将运行一个 Linux 虚拟机做测试。 +为了第一时间去做 Linux 发型版本的依赖测试,我把它们运行在我目前所拥有的所有类型的 PC 上。如果我用我的台式机,我将运行一个 Linux 虚拟机做测试。使用这种方法的原因是,不仅仅是生活环境下我可以下载测并测试发行版,但也会用稳定的生产环境安装。 -On the other hand, if I am working with much less robust hardware on a PC, then testing out a distro with a virtual machine installation of Linux is counter-productive. I'd be pushing that PC to its limits and honestly would be better off using a live Linux image instead running from a flash drive. +On the other hand, if I am working with much less robust(强力的) hardware on a PC, then testing out a distro with a virtual machine installation of Linux is counter-productive. I'd be pushing that PC to its limits(范围) and honestly(真诚的) would be better off(富裕的) using a live Linux image instead running from a flash drive. + +在另一方面,如果我在工作中我的PC不具备强力的硬件条件的,在一个虚拟机上测试 Linux 发型版本的时候将会产生相反的效果。老实的讲,我会将电脑性能压榨到极限,如果在经济条件服务的情况下我会使用实体机运行 Linux 镜像替代虚拟机 ### Touring software on a new Linux distro +### 在一个新的 Linux 发行版本上运行旅游软件 -If you're interested in checking out a distro's desktop environment or the available software, you can't go wrong with a live image of the distro. A live environment provides you with a birds eye view of what to expect in terms of overall layout, applications provided and how the user experience flows overall. +If you're interested in checking out a distro's desktop environment(环境) or the available software(购买软件), you can't go wrong with a live image of the distro. A live environment provides(提供) you with a birds eye view of what to expect(期望) in terms of overall layout(总体布局), applications provided and how the user experience(体验) flows overall. + +如果你有兴趣查看发行版本的桌面环境或购买软件,你不能因为发行版本的一个实时图片而诽谤它。一个生活环境提供给你希望的鸟瞰全局的视角,如何使用户体验更好是由应用程序提供的。 To be fair, you could do the same thing with a virtual machine installation, but it may be a bit overkill if you would rather avoid filling up hard drive space with yet more data. After all, this is a simple tour of the distro. Remember what I said in the first section – I like to run Linux in a virtual machine to test it. This means I'm going to see how it installs, what the partition options look like and other elements you wouldn't see from using a live image of any given distro. +公平的说,一个虚拟化安装你也可以做同样的事,但是 + Touring usually indicates that you're only looking to take a quick look at a distro, so in this case the method that can be done with the least amount of resistance and time investment is a good course of action. ### Taking a Linux distro with you From bb916f8477c9a5555283f36e4ea8f5d02db6db25 Mon Sep 17 00:00:00 2001 From: sober-wang Date: Wed, 1 Aug 2018 23:07:16 +0800 Subject: [PATCH 002/455] =?UTF-8?q?=E6=AF=94=E8=BE=83=E8=99=9A=E6=8B=9F?= =?UTF-8?q?=E6=9C=BA=E4=B8=8E=E9=95=9C=E5=83=8F=E7=9A=84=E4=BE=BF=E6=90=BA?= =?UTF-8?q?=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...6 Linux Virtual Machines vs Linux Live Images.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md index ced49524bd..872eb35a7a 100644 --- a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md +++ b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md @@ -25,15 +25,20 @@ If you're interested in checking out a distro's desktop environment(环境) 如果你有兴趣查看发行版本的桌面环境或购买软件,你不能因为发行版本的一个实时图片而诽谤它。一个生活环境提供给你希望的鸟瞰全局的视角,如何使用户体验更好是由应用程序提供的。 -To be fair, you could do the same thing with a virtual machine installation, but it may be a bit overkill if you would rather avoid filling up hard drive space with yet more data. After all, this is a simple tour of the distro. Remember what I said in the first section – I like to run Linux in a virtual machine to test it. This means I'm going to see how it installs, what the partition options look like and other elements you wouldn't see from using a live image of any given distro. +To be fair, you could do the same thing with a virtual machine installation, but it may be a bit overkill if you would rather(宁可) avoid(消除) filling(填充) up hard drive space with yet more data. After all(毕竟), this is a simple tour of the distro. Remember what I said in the first section – I like to run Linux in a virtual machine to test it. This means I'm going to see how it installs, what the partition(区分) options look like and other elements(原理) you wouldn't see from using a live image of any given distro. -公平的说,一个虚拟化安装你也可以做同样的事,但是 +公平的说,一个虚拟化安装你也可以做同样的事,但是它有点不好,如果这么做你将要消除硬件上的许多数据。毕竟这是一个简单的发行版。记得我说过在第一部分-我做测试喜欢在虚拟机上运行 Linux 。这个方式我就能看见如何去安装它,使用镜像安装时你讲看不见有区别的操作和其他工作原理。 -Touring usually indicates that you're only looking to take a quick look at a distro, so in this case the method that can be done with the least amount of resistance and time investment is a good course of action. +Touring usually indicates(表明) that you're only looking to take a quick look at a distro, so in this case(情况) the method(方法) that can be done with the least amount(最少的数量) of resistance(阻力) and time investment(时间的投入) is a good course(过程) of action. + +通常你仅能看见一个关于发行版本的简短介绍,关于功能用最少的阻力和时间投入,是解决这个问题的好办法。 ### Taking a Linux distro with you +### 随身携带一个发行版本 -While it's not as common as it was a few years ago, the ability to take a Linux distro with you may be a consideration for some users. Obviously, virtual machine installations don't necessarily lend themselves favorably to portability. However a live image of a Linux distro is actually quite portable. A live image can be written to a DVD or copied onto a flash drive for easy traveling. +While it's not as common(共同的) as it was a few(很少数) years ago, the ability(有……能力) to take a Linux distro with you may be a consideration(担心) for some users. Obviously, virtual machine installations don't necessarily(必要的) lend(提供) themselves favorably(适合他们自己的) to portability(可携带). However a live image of a Linux distro is actually quite portable. A live image can be written to a DVD or copied onto a flash drive for easy traveling. + +这个话题虽然不像几年前那样普遍,使用 Linux 发行版的能力可能是许多用户所顾虑的。明显,适合他们自己携带的系统,虚拟机是无法提供的。无论如何,一个 Linux 发行版本的镜像都十分轻便。一个镜像能够轻松的写入到 DVD 或者 Flash 存储设备中。 Expanding on this concept of Linux portability, it's also beneficial to have a live image on a flash drive when showing off how Linux works on a friend's computer. This empowers you to demonstrate how Linux can enrich their life while not relying on running a virtual machine on their PC. It's a bit of a win-win in favor of using a live image. From f3971e0c3cf4147ec50fdf147251fe7ba4dcc0c9 Mon Sep 17 00:00:00 2001 From: sober-wang Date: Sun, 5 Aug 2018 00:26:42 +0800 Subject: [PATCH 003/455] =?UTF-8?q?=E7=BC=98=E6=96=AD=E6=83=85=E6=B8=85?= =?UTF-8?q?=E3=80=82Linux=20=E5=B0=86=E6=98=AF=E6=9C=80=E5=A5=BD=E7=9A=84?= =?UTF-8?q?=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...226 Linux Virtual Machines vs Linux Live Images.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md index 872eb35a7a..90f0c31c06 100644 --- a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md +++ b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md @@ -38,13 +38,18 @@ Touring usually indicates(表明) that you're only looking to take a quick l While it's not as common(共同的) as it was a few(很少数) years ago, the ability(有……能力) to take a Linux distro with you may be a consideration(担心) for some users. Obviously, virtual machine installations don't necessarily(必要的) lend(提供) themselves favorably(适合他们自己的) to portability(可携带). However a live image of a Linux distro is actually quite portable. A live image can be written to a DVD or copied onto a flash drive for easy traveling. -这个话题虽然不像几年前那样普遍,使用 Linux 发行版的能力可能是许多用户所顾虑的。明显,适合他们自己携带的系统,虚拟机是无法提供的。无论如何,一个 Linux 发行版本的镜像都十分轻便。一个镜像能够轻松的写入到 DVD 或者 Flash 存储设备中。 +这个话题虽然不像几年前那样普遍,使用 Linux 发行版的能力可能是许多用户所顾虑的。明显,适合他们自己携带的系统,虚拟机是无法提供的。无论如何,一个 Linux 发行版本的镜像是具有可移植性的。一个镜像能够轻松的写入到 DVD 或者 Flash 存储设备中。 -Expanding on this concept of Linux portability, it's also beneficial to have a live image on a flash drive when showing off how Linux works on a friend's computer. This empowers you to demonstrate how Linux can enrich their life while not relying on running a virtual machine on their PC. It's a bit of a win-win in favor of using a live image. +Expanding(花费) on this concept(概念) of Linux portability(轻便/便携), it's also beneficial(有益处) to have a live image on a flash drive when showing off how Linux works on a friend's computer. This empowers(授权) you to demonstrate(证明) how Linux can enrich(充实/使丰富) their life while not relying on running a virtual machine on their PC. It's a bit of a win-win in favor(喜爱) of using a live image. + +在 Linux 可移植性的概念上花费时间,这有益于在一个朋友的电脑上使用 Flash 存储设备安装镜像版 Linux 。这个授权使你能证明 Linux 能充实他们的生活,虽然在他们的 PC 上运行一个虚拟机是不可靠的。在喜爱使用镜像的用户哪里,它是双赢的。 ### Alternative to dual-booting Linux +### 选择做双系统 Linux -This next item is a huge one. Consider this – perhaps you're a Windows user. You like playing with Linux, but would rather not take the plunge. Dual-booting is out of the question in case something goes wrong or perhaps you're not comfortable identifying individual partitions. Whatever the case may be, both using Linux in a virtual machine or from a live image might be a great option for you. +This next item is a huge one. Consider this – perhaps you're a Windows user. You like playing with Linux, but would rather not take the plunge. Dual-booting is out of the question in case(情况) something goes wrong or perhaps you're not comfortable identifying individual partitions. Whatever the case may be, both using Linux in a virtual machine or from a live image might be a great option for you. + +这是一个巨大的项目。考虑一些事,例如你在使用 Windows .你喜欢玩 Linux ,但是宁可不获取插件。在一些出状况或考虑你不是拥有单独分区,双系统将是一个问题。不管什么样的情况,同时使用 Linux 虚拟机和镜像系统都对于你是一个很好的选择。 Now I'm going to take a rather odd stance on something. I think you'll get far more value in the long term running Linux on a flash drive using a live image than with a virtual machine. There are two reasons for this. First of all, you'll get used to truly running Linux vs running it inside of a virtual machine on top of Windows. Second, you can setup your flash drive to contain user data with persistent storage. From 1518a277539d50fedd1226efbc2c3d663c850af2 Mon Sep 17 00:00:00 2001 From: shangmo Date: Sun, 12 Aug 2018 23:35:59 +0800 Subject: [PATCH 004/455] =?UTF-8?q?=E9=80=89=E6=8B=A9=E5=9C=A8=E8=99=9A?= =?UTF-8?q?=E6=8B=9F=E6=9C=BA=E4=B8=AD=E5=AE=89=E8=A3=85=20linux=20?= =?UTF-8?q?=E8=BF=98=E6=98=AF=E5=9C=A8=20Flash=20=E4=B8=AD=E5=AE=89?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0180226 Linux Virtual Machines vs Linux Live Images.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md index 90f0c31c06..01d6bf48a0 100644 --- a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md +++ b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md @@ -51,7 +51,13 @@ This next item is a huge one. Consider this – perhaps you're a Windows user. Y 这是一个巨大的项目。考虑一些事,例如你在使用 Windows .你喜欢玩 Linux ,但是宁可不获取插件。在一些出状况或考虑你不是拥有单独分区,双系统将是一个问题。不管什么样的情况,同时使用 Linux 虚拟机和镜像系统都对于你是一个很好的选择。 -Now I'm going to take a rather odd stance on something. I think you'll get far more value in the long term running Linux on a flash drive using a live image than with a virtual machine. There are two reasons for this. First of all, you'll get used to truly running Linux vs running it inside of a virtual machine on top of Windows. Second, you can setup your flash drive to contain user data with persistent storage. +Now I'm going to take a rather odd(奇怪的) stance(立场) on something. I think you'll get far(能走多远) more value in the long term running Linux on a flash drive using a live image than with a virtual machine. There are two reasons(原因) for this. First of all, you'll get used to truly (真正的)running Linux vs running it inside of a virtual machine on top of Windows. Second, you can setup your flash drive to contain(包含) user data with persistent storage. + + + +现在,我在一些事物上采取奇怪的立场。长期运行 Linux 镜像在 Flash 存储或虚拟机,我知道你将为了更多的价值走更远。对于这个说法有两个原因。第一个,在 Windows 中安装一个虚拟机 VS 真正的运行的 Linux 。第二,用一个持续的存储设备你的 Flash 存储,安装 Linux 和你的数据。 + + I'll grant you the same could be said with a virtual machine running Linux, however you will never have an update break anything using the live image approach. Why? Because you're not updating a host OS or the guest OS. Remember there are entire distros that are designed to be nothing more than persistent storage Linux distros. Puppy Linux is one great example. Not only can it run on PCs that would otherwise be recycled or thrown away, it allows you to never be bothered again with tedious system updates thanks to the way the distro handles security. It's not a normal Linux distro and it's walled off in such a way that the persistent live image is free from anything scary. From 4750088a091cdcef86983fb8543b1b82824ad3fb Mon Sep 17 00:00:00 2001 From: imquanquan Date: Tue, 21 Aug 2018 12:10:33 +0800 Subject: [PATCH 005/455] translated half --- ...ges of Go that you dont hear much about.md | 95 +++++++++---------- 1 file changed, 47 insertions(+), 48 deletions(-) rename {sources => translated}/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md (61%) diff --git a/sources/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md b/translated/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md similarity index 61% rename from sources/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md rename to translated/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md index efa3c4e653..2c5c6b3177 100644 --- a/sources/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md +++ b/translated/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md @@ -1,89 +1,88 @@ -Translatin by imquanquan - -Here are some amazing advantages of Go that you don’t hear much about +你没听说过的 Go 语言惊人优点 ============================================================ ![](https://cdn-images-1.medium.com/max/2000/1*NDXd5I87VZG0Z74N7dog0g.png) -Artwork from [https://github.com/ashleymcnamara/gophers][1] +来自 [https://github.com/ashleymcnamara/gophers][1] 的图稿 -In this article, I discuss why you should give Go a chance and where to start. - -Golang is a programming language you might have heard about a lot during the last couple years. Even though it was created back in 2009, it has started to gain popularity only in recent years. +在这篇文章中,我将讨论为什么你需要尝试一下 Go,以及应该从哪里学起。 +Golang 是可能是最近几年里你经常听人说起的编程语言。尽管它在 2009 年已经发布,但它最近才开始流行起来。 ![](https://cdn-images-1.medium.com/max/2000/1*cQ8QzhCPiFXqk_oQdUk_zw.png) -Golang popularity according to Google Trends -This article is not about the main selling points of Go that you usually see. +根据 Google 趋势,Golang 语言非常流行。 -Instead, I would like to present to you some rather small but still significant features that you only get to know after you’ve decided to give Go a try. +这篇文章不会讨论一些你经常看到的 Golang 的主要特性。 -These are amazing features that are not laid out on the surface, but they can save you weeks or months of work. They can also make software development more enjoyable. +相反,我想向您介绍一些相当小众但仍然很重要的功能。在您决定尝试Go后,您才会知道这些功能。 -Don’t worry if Go is something new for you. This article does not require any prior experience with the language. I have included a few extra links at the bottom, in case you would like to learn a bit more. +这些都是表面上没有体现出来的惊人特性,但它们可以为您节省数周或数月的工作量。而且这些特性还可以使软件开发更加愉快。 -We will go through such topics as: +阅读本文不需要任何语言经验,所以不比担心 Golang 对你来说是新的事物。如果你想了解更多,可以看看我在底部列出的一些额外的链接,。 + +我们将讨论以下主题: * GoDoc -* Static code analysis +* 静态代码分析 -* Built-in testing and profiling framework +* 内置的测试和分析框架 -* Race condition detection +* 竞争条件检测 -* Learning curve +* 学习曲线 -* Reflection +* 反射(Reflection) -* Opinionatedness +* 专制独裁的 Go -* Culture +* 文化 Please, note that the list doesn’t follow any particular order. It is also opinionated as hell. +请注意,这个列表不遵循任何特定顺序来讨论。 ### GoDoc -Documentation in code is taken very seriously in Go. So is simplicity. +Golang 非常重视代码中的文档,简洁也是如此。 -[GoDoc][4] is a static code analyzing tool that creates beautiful documentation pages straight out of your code. A remarkable thing about GoDoc is that it doesn’t use any extra languages, like JavaDoc, PHPDoc, or JSDoc to annotate constructions in your code. Just English. +[GoDoc][4] 是一个静态代码分析工具,可以直接从代码中创建漂亮的文档页面。GoDoc 的一个显着特点是它不使用任何其他的语言,如 JavaDoc,PHPDoc 或 JSDoc 来注释代码中的结构,只需要用英语。 -It uses as much information as it can get from the code to outline, structure, and format the documentation. And it has all the bells and whistles, such as cross-references, code samples, and direct links to your version control system repository. +它使用从代码中获取的尽可能多的信息来概述、构造和格式化文档。它有多而全的功能,比如:交叉引用,代码示例以及一个指向版本控制系统仓库的链接。 -All you can do is to add a good old `// MyFunc transforms Foo into Bar` kind of comment which would be reflected in the documentation, too. You can even add [code examples][5] which are actually runnable via the web interface or locally. +而你需要做的只有添加一些好的,像 `// MyFunc transforms Foo into Bar` 这样子的注释,而这些注释也会反映在的文档中。你甚至可以添加一些通过网络接口或者在本地可以实际运行的 [代码示例][5]。 -GoDoc is the only documentation engine for Go that is used by the whole community. This means that every library or application written in Go has the same format of documentation. In the long run, it saves you tons of time while browsing those docs. +GoDoc 是 Go 的唯一文档引擎,供整个社区使用。这意味着用 Go 编写的每个库或应用程序都具有相同的文档格式。从长远来看,它可以帮你在浏览这些文档时节省大量时间。 -Here, for example, is the GoDoc page for my recent pet project: [pullkee — GoDoc][6]. +例如,这是我最近一个小项目的 GoDoc 页面:[pullkee — GoDoc][6]。 -### Static code analysis +### 静态代码分析 -Go heavily relies on static code analysis. Examples include [godoc][7] for documentation, [gofmt][8] for code formatting, [golint][9] for code style linting, and many others. +Go 严重依赖于静态代码分析。例子包括 godoc 文档,gofmt 代码格式化,golint 代码风格统一,等等。 -There are so many of them that there’s even an everything-included-kind-of project called [gometalinter][10] to compose them all into a single utility. +There are so many of them that there’s even an everything-included-kind-of project called [gometalinter][10] to compose them all into a single utility. -Those tools are commonly implemented as stand-alone command line applications and integrate easily with any coding environment. +这些工具通常作为独立的命令行应用程序实现,并可轻松与任何编码环境集成。 -Static code analysis isn’t actually something new to modern programming, but Go sort of brings it to the absolute. I can’t overestimate how much time it saved me. Also, it gives you a feeling of safety, as though someone is covering your back. +静态代码分析实际上并不是现代编程的新概念,但是 Go 将其带入了绝对的范畴。我无法估量它为我节省了多少时间。此外,它给你一种安全感,就像有人在你背后支持你一样。 -It’s very easy to create your own analyzers, as Go has dedicated built-in packages for parsing and working with Go sources. +创建自己的分析器非常简单,因为 Go 有专门的内置包来解析和加工 Go 源码。 -You can learn more from this talk: [GothamGo Kickoff Meetup: Go Static Analysis Tools by Alan Donovan][11]. +你可以从这个链接中了解到更多相关内容: [GothamGo Kickoff Meetup: Go Static Analysis Tools by Alan Donovan][11]. -### Built-in testing and profiling framework +### 内置的测试和分析框架 -Have you ever tried to pick a testing framework for a Javascript project you are starting from scratch? If so, you might understand that struggle of going through such an analysis paralysis. You might have also realized that you were not using like 80% of the framework you have chosen. +您是否曾尝试为一个从头开始的 Javascript 项目选择测试框架?如果是这样,你可能会明白经历这种分析瘫痪的斗争。您可能也意识到您没有使用其中 80% 的框架。 -The issue repeats over again once you need to do some reliable profiling. +一旦您需要进行一些可靠的分析,问题就会重复出现。 -Go comes with a built-in testing tool designed for simplicity and efficiency. It provides you the simplest API possible, and makes minimum assumptions. You can use it for different kinds of testing, profiling, and even to provide executable code examples. +Go 附带内置测试工具,旨在简化和提高效率。它为您提供了最简单的 API,并做出最小的假设。您可以将它用于不同类型的测试,分析,甚至可以提供可执行代码示例。 -It produces CI-friendly output out-of-box, and the usage is usually as easy as running `go test`. Of course, it also supports advanced features like running tests in parallel, marking them skipped, and many more. +它可以开箱即用地生成持续集成友好的输出,而且它的用法很简单,只需运行 `go test`。当然,它还支持高级功能,如并行运行测试,跳过标记代码,以及其他更多功能。 ### Race condition detection -You might already know about Goroutines, which are used in Go to achieve concurrent code execution. If you don’t, [here’s][12] a really brief explanation. +You might already know about Goroutines, which are used in Go to achieve concurrent code execution. If you don’t, [here’s][12] a really brief explanation. Concurrent programming in complex applications is never easy regardless of the specific technique, partly due to the possibility of race conditions. @@ -91,13 +90,13 @@ Simply put, race conditions happen when several concurrent operations finish in All that said, concurrent programming is taken very seriously in Go and, luckily, we have quite a powerful tool to hunt those race conditions down. It is fully integrated into Go’s toolchain. -You can read more about it and learn how to use it here: [Introducing the Go Race Detector — The Go Blog][13]. +You can read more about it and learn how to use it here: [Introducing the Go Race Detector — The Go Blog][13]. ### Learning curve You can learn ALL Go’s language features in one evening. I mean it. Of course, there are also the standard library, and the best practices in different, more specific areas. But two hours would totally be enough time to get you confidently writing a simple HTTP server, or a command-line app. -The project has [marvelous documentation][14], and most of the advanced topics have already been covered on their blog: [The Go Programming Language Blog][15]. +The project has [marvelous documentation][14], and most of the advanced topics have already been covered on their blog: [The Go Programming Language Blog][15]. Go is much easier to bring to your team than Java (and the family), Javascript, Ruby, Python, or even PHP. The environment is easy to setup, and the investment your team needs to make is much smaller before they can complete your first production code. @@ -107,19 +106,19 @@ Code reflection is essentially an ability to sneak under the hood and access dif Given that Go is a statically typed language, it’s exposed to a number of various limitations when it comes to more loosely typed abstract programming. Especially compared to languages like Javascript or Python. -Moreover, Go [doesn’t implement a concept called Generics][16] which makes it even more challenging to work with multiple types in an abstract way. Nevertheless, many people think it’s actually beneficial for the language because of the amount of complexity Generics bring along. And I totally agree. +Moreover, Go [doesn’t implement a concept called Generics][16] which makes it even more challenging to work with multiple types in an abstract way. Nevertheless, many people think it’s actually beneficial for the language because of the amount of complexity Generics bring along. And I totally agree. According to Go’s philosophy (which is a separate topic itself), you should try hard to not over-engineer your solutions. And this also applies to dynamically-typed programming. Stick to static types as much as possible, and use interfaces when you know exactly what sort of types you’re dealing with. Interfaces are very powerful and ubiquitous in Go. However, there are still cases in which you can’t possibly know what sort of data you are facing. A great example is JSON. You convert all the kinds of data back and forth in your applications. Strings, buffers, all sorts of numbers, nested structs and more. -In order to pull that off, you need a tool to examine all the data in runtime that acts differently depending on its type and structure. Reflection to rescue! Go has a first-class [reflect][17] package to enable your code to be as dynamic as it would be in a language like Javascript. +In order to pull that off, you need a tool to examine all the data in runtime that acts differently depending on its type and structure. Reflection to rescue! Go has a first-class [reflect][17] package to enable your code to be as dynamic as it would be in a language like Javascript. An important caveat is to know what price you pay for using it — and only use it when there is no simpler way. -You can read more about it here: [The Laws of Reflection — The Go Blog][18]. +You can read more about it here: [The Laws of Reflection — The Go Blog][18]. -You can also read some real code from the JSON package sources here: [src/encoding/json/encode.go — Source Code][19] +You can also read some real code from the JSON package sources here: [src/encoding/json/encode.go — Source Code][19] ### Opinionatedness @@ -161,9 +160,9 @@ Always use the best tool for the job! You might have heard of Go before. Or maybe it’s something that has been staying out of your radar for a while. Either way, chances are, Go can be a very decent choice for you or your team when starting a new project or improving the existing one. -This is not a complete list of all the amazing things about Go. Just the undervalued ones. +This is not a complete list of all the amazing things about Go. Just the undervalued ones. -Please, give Go a try with [A Tour of Go][20] which is an incredible place to start. +Please, give Go a try with [A Tour of Go][20] which is an incredible place to start. If you wish to learn more about Go’s benefits, you can check out these links: @@ -181,7 +180,7 @@ Always be looking for the best tools for your craft! If you like this article, please consider following me for more, and clicking on those funny green little hands right below this text for sharing. 👏👏👏 -Check out my [Github][21] and follow me on [Twitter][22]! +Check out my [Github][21] and follow me on [Twitter][22]! -------------------------------------------------------------------------------- From 1255e2b34d78792245f48c2cf680b0eae9cf361a Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 23 Aug 2018 11:22:23 +0800 Subject: [PATCH 006/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Quickl?= =?UTF-8?q?y=20Serve=20Files=20And=20Folders=20Over=20HTTP=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ve Files And Folders Over HTTP In Linux.md | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 sources/tech/20180810 How To Quickly Serve Files And Folders Over HTTP In Linux.md diff --git a/sources/tech/20180810 How To Quickly Serve Files And Folders Over HTTP In Linux.md b/sources/tech/20180810 How To Quickly Serve Files And Folders Over HTTP In Linux.md new file mode 100644 index 0000000000..c4adc3ac07 --- /dev/null +++ b/sources/tech/20180810 How To Quickly Serve Files And Folders Over HTTP In Linux.md @@ -0,0 +1,168 @@ +How To Quickly Serve Files And Folders Over HTTP In Linux +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/08/http-720x340.png) + +Today, I came across a whole bunch of methods to serve a single file or entire directory with other systems in your local area network via a web browser. I tested all of them in my Ubuntu test machine, and everything worked just fine as described below. If you ever wondered how to easily and quickly serve files and folders over HTTP in Unix-like operating systems, one of the following methods will definitely help. + +### Serve Files And Folders Over HTTP In Linux + +**Disclaimer:** All the methods given here are meant to be used within a secure local area network. Since these methods doesn’t have any security mechanism, it is **not recommended to use them in production**. You have been warned! + +#### Method 1 – Using simpleHTTPserver (Python) + +We already have written a brief guide to setup a simple http server to share files and directories instantly in the following link. If you have a system with Python installed, this method is quite handy. + +#### Method 2 – Using Quickserve (Python) + +This method is specifically for Arch Linux and its variants. Check the following link for more details. + +#### Method 3 – Using Ruby** + +In this method, we use Ruby to serve files and folders over HTTP in Unix-like systems. Install Ruby and Rails as described in the following link. + +Once Ruby installed, go to the directory, for example ostechnix, that you want to share over the network: +``` +$ cd ostechnix + +``` + +And, run the following command: +``` +$ ruby -run -ehttpd . -p8000 +[2018-08-10 16:02:55] INFO WEBrick 1.4.2 +[2018-08-10 16:02:55] INFO ruby 2.5.1 (2018-03-29) [x86_64-linux] +[2018-08-10 16:02:55] INFO WEBrick::HTTPServer#start: pid=5859 port=8000 + +``` + +Make sure the port 8000 is opened in your router or firewall . If the port has already been used by some other services use different port. + +You can now access the contents of this folder from any remote system using URL – **http:// :8000/**. + +![](https://www.ostechnix.com/wp-content/uploads/2018/08/ruby-http-server.png) + +To stop sharing press **CTRL+C**. + +#### Method 4 – Using Http-server (NodeJS) + +[**Http-server**][1] is a simple, production ready command line http-server written in NodeJS. It requires zero configuration and can be used to instantly share files and directories via web browser. + +Install NodeJS as described below. + +Once NodeJS installed, run the following command to install http-server. +``` +$ npm install -g http-server + +``` + +Now, go to any directory and share its contents over HTTP as shown below. +``` +$ cd ostechnix + +$ http-server -p 8000 +Starting up http-server, serving ./ +Available on: + http://127.0.0.1:8000 + http://192.168.225.24:8000 + http://192.168.225.20:8000 +Hit CTRL-C to stop the server + +``` + +Now, you can access the contents of this directory from local or remote systems in the network using URL – **http:// :8000**. + +![](http://www.ostechnix.com/wp-content/uploads/2018/08/nodejs-http-server.png) + +To stop sharing, press **CTRL+C**. + +#### Method 5 – Using Miniserve (Rust) + +[**Miniserve**][2] is yet another command line utility that allows you to quickly serve files over HTTP. It is very fast, easy-to-use, and cross-platform utility written in **Rust** programming language. Unlike the above utilities/methods, it provides authentication support, so you can setup username and password to the shares. + +Install Rust in your Linux system as described in the following link. + +After installing Rust, run the following command to install miniserve: +``` +$ cargo install miniserve + +``` + +Alternatively, you can download the binaries from [**the releases page**][3] and make it executable. +``` +$ chmod +x miniserve-linux + +``` + +And, then you can run it using command (assuming miniserve binary file is downloaded in the current working directory): +``` +$ ./miniserve-linux + +``` + +**Usage** + +To serve a directory: +``` +$ miniserve + +``` + +**Example:** +``` +$ miniserve /home/sk/ostechnix/ +miniserve v0.2.0 +Serving path /home/sk/ostechnix at http://[::]:8080, http://localhost:8080 +Quit by pressing CTRL-C + +``` + +Now, you can access the share from local system itself using URL – **** and/or from remote system with URL – **http:// :8080**. + +To serve a single file: +``` +$ miniserve + +``` + +**Example:** +``` +$ miniserve ostechnix/file.txt + +``` + +Serve file/folder with username and password: +``` +$ miniserve --auth joe:123 + +``` + +Bind to multiple interfaces: +``` +$ miniserve -i 192.168.225.1 -i 10.10.0.1 -i ::1 -- + +``` + +As you can see, I have given only 5 methods. But, there are few more methods given in the link attached at the end of this guide. Go and test them as well. Also, bookmark and revisit it from time to time to check if there are any new additions to the list in future. + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-quickly-serve-files-and-folders-over-http-in-linux/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://www.npmjs.com/package/http-server +[2]:https://github.com/svenstaro/miniserve +[3]:https://github.com/svenstaro/miniserve/releases From a8d322de3bb34e8c038b02c9cd53d6ee33335827 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 28 Aug 2018 12:54:15 +0800 Subject: [PATCH 007/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Joplin:=20Encrypt?= =?UTF-8?q?ed=20Open=20Source=20Note=20Taking=20And=20To-Do=20Application?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ource Note Taking And To-Do Application.md | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 sources/tech/20180824 Joplin- Encrypted Open Source Note Taking And To-Do Application.md diff --git a/sources/tech/20180824 Joplin- Encrypted Open Source Note Taking And To-Do Application.md b/sources/tech/20180824 Joplin- Encrypted Open Source Note Taking And To-Do Application.md new file mode 100644 index 0000000000..5c520c8021 --- /dev/null +++ b/sources/tech/20180824 Joplin- Encrypted Open Source Note Taking And To-Do Application.md @@ -0,0 +1,78 @@ +Joplin: Encrypted Open Source Note Taking And To-Do Application +====== +**[Joplin][1] is a free and open source note taking and to-do application available for Linux, Windows, macOS, Android and iOS. Its key features include end-to-end encryption, Markdown support, and synchronization via third-party services like NextCloud, Dropbox, OneDrive or WebDAV.** + +![](https://1.bp.blogspot.com/-vLLYx1Pfmb0/W3_wq_B0avI/AAAAAAAABb8/B9pe5NXVzg83A6Lm6_0ORMe9aWqtfTn4gCLcBGAs/s640/joplin-notes.png) + +With Joplin you can write your notes in the **Markdown format** (with support for math notations and checkboxes) and the desktop app comes with 3 views: Markdown code, Markdown preview, or both side by side. **You can add attachments to your notes (with image previews) or edit them in an external Markdown editor** and have them automatically updated in Joplin each time you save the file. + +The application should handle a large number of notes pretty well by allowing you to **organizing notes into notebooks, add tags, and search in notes**. You can also sort notes by updated date, creation date or title. **Each notebook can contain notes, to-do items, or both** , and you can easily add links to other notes (in the desktop app right click on a note and select `Copy Markdown link` , then paste the link in a note). + +**Do-do items in Joplin support alarms** , but this feature didn't work for me on Ubuntu 18.04. + +**Other Joplin features include:** + + * **Optional Web Clipper extension** for Firefox and Chrome (in the Joplin desktop application go to `Tools > Web clipper options` to enable the clipper service and find download links for the Chrome / Firefox extension) which can clip simplified or complete pages, clip a selection or screenshot. + + * **Optional command line client**. + + * **Import Enex files (Evernote export format) and Markdown files**. + + * **Export JEX files (Joplin Export format), PDF and raw files**. + + * **Offline first, so the entire data is always available on the device even without an internet connection**. + + * **Geolocation support**. + + + +[![Joplin notes checkboxes link to other note][2]][3] +Joplin with hidden sidebar showing checkboxes and a link to another note + +While it doesn't offer as many features as Evernote, Joplin is a robust open source Evernote alternative. Joplin includes all the basic features, and on top of that it's open source software, it includes encryption support, and you also get to choose the service you want to use for synchronization. + +The application was actually designed as an Evernote alternative so it can import complete Evernote notebooks, notes, tags, attachments, and note metadata like the author, creation and updated time, or geolocation. + +Another aspect on which the Joplin development was focused was to avoid being tied to a particular company or service. This is why the application offers multiple synchronization solutions, like NextCloud, Dropbox, oneDrive and WebDav, while also making it easy to support new services. It's also easy to switch from one service to another if you change your mind. + +**I should note that Joplin doesn't use encryption by default and you must enable this from its settings. Go to** `Tools > Encryption options` and enable the Joplin end-to-end encryption from there. + +### Download Joplin + +[Download Joplin][7] + +**Joplin is available for Linux, Windows, macOS, Android and iOS. On Linux, there's an AppImage as well as an Aur package available.** + +To run the Joplin AppImage on Linux, double click it and select `Make executable and run` if your file manager supports this. If not, you'll need to make it executable either using your file manager (should be something like: `right click > Properties > Permissions > Allow executing file as program` , but this may vary depending on the file manager you use), or from the command line: +``` +chmod +x /path/to/Joplin-*-x86_64.AppImage + +``` + +Replacing `/path/to/` with the path to where you downloaded Joplin. Now you can double click the Joplin Appimage file to launch it. + +**TIP:** If you integrate Joplin to your menu and `~/.local/share/applications/appimagekit-joplin.desktop`) and adding `StartupWMClass=Joplin` at the end of the file on a new line, without modifying anything else. + +Joplin has a **command line client** that can be [installed using npm][5] (for Debian, Ubuntu or Linux Mint, see [how to install and configure Node.js and npm][6] ). + + +-------------------------------------------------------------------------------- + +via: https://www.linuxuprising.com/2018/08/joplin-encrypted-open-source-note.html + +作者:[Logix][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/118280394805678839070 +[1]:https://joplin.cozic.net/ +[2]:https://3.bp.blogspot.com/-y9JKL1F89Vo/W3_0dkZjzQI/AAAAAAAABcI/hQI7GAx6i_sMcel4mF0x4uxBrMO88O59wCLcBGAs/s640/joplin-notes-markdown.png (Joplin notes checkboxes link to other note) +[3]:https://3.bp.blogspot.com/-y9JKL1F89Vo/W3_0dkZjzQI/AAAAAAAABcI/hQI7GAx6i_sMcel4mF0x4uxBrMO88O59wCLcBGAs/s1600/joplin-notes-markdown.png +[4]:https://github.com/laurent22/joplin/issues/338 +[5]:https://joplin.cozic.net/terminal/ +[6]:https://www.linuxuprising.com/2018/04/how-to-install-and-configure-nodejs-and.html + +[7]: https://joplin.cozic.net/#installation From a9ca62c371f752312cf9b41c289f0755cca4d30c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 31 Aug 2018 22:36:27 +0800 Subject: [PATCH 008/455] PRF:20180806 A gawk script to convert smart quotes.md @lujun9972 --- ...6 A gawk script to convert smart quotes.md | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/translated/tech/20180806 A gawk script to convert smart quotes.md b/translated/tech/20180806 A gawk script to convert smart quotes.md index 911d9cc542..52c94c39cb 100644 --- a/translated/tech/20180806 A gawk script to convert smart quotes.md +++ b/translated/tech/20180806 A gawk script to convert smart quotes.md @@ -1,19 +1,22 @@ 一个转换花引号的 gawk 脚本 ====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_520x292_opensourceprescription.png?itok=gFrc_GTH) +> 下载我的 awk 秘籍。 -我管理着一个个人网站,同时手工编辑网站上的网页。由于网站上的页面并不多,这种方法对我很适合,可以让我对网站代码的细节一清二楚。 +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_520x292_opensourceprescription.png?itok=gFrc_GTH) -最近我升级了网站的设计样式,我决定把所有的普通引号都转换成 "花引号",即在打印材料中使用的那种引号:用 “” 来代替 ""。 +我管理着一个个人网站,用手工编辑网站上的网页。由于网站上的页面并不多,这种方法对我很适合,可以让我对网站代码的细节一清二楚。 -手工修改所有的引号太耗时了,因此我决定将转换所有 HTML 文件中引号的过程自动化。不过通过程序或脚本来实现该功能需要费点劲。这个脚本需要知道何时将普通引号转换成花引号,并决定使用哪种引号(译注:左引号还是右引号,单引号还是双引号)。 +最近我升级了网站的设计样式,我决定把所有的普通引号都转换成“花引号”,即在打印材料中使用的那种引号:用 “” 来代替 ""。 -有多种方法可以转换引号。Greg Pittman 写过一个 [Python 脚本 ][1] 来修正文本中的花引号。而我自己使用 GNU [awk][2] (gawk) 来实现。 +手工修改所有的引号太耗时了,因此我决定将这个转换所有 HTML 文件中引号的过程自动化。不过通过程序或脚本来实现该功能需要费点劲。这个脚本需要知道何时将普通引号转换成花引号,并决定使用哪种引号(LCTT 译注:左引号还是右引号,单引号还是双引号)。 -> 下载我的 awk 备忘录。[免费下载 ][3]。 +有多种方法可以转换引号。Greg Pittman 写过一个 [Python 脚本][1] 来修正文本中的花引号。而我自己使用 GNU [awk][2] (gawk) 来实现。 + +> 下载我的 awk 秘籍。[免费下载][3]。 + +开始之前,我写了一个简单的 gawk 函数来评估单个字符。若该字符是一个引号,这该函数判断是输出普通引号还是花引号。函数查看前一个字符;若前一个字符是空格,则函数输出左花引号。否则函数输出右花引号。脚本对单引号的处理方式也一样。 -开始之前,我写了一个简单的 gawk 函数来评估单个字符。若该字符是一个引号,这该函数判断是输出普通引号还是花引号。函数查看前一个字符; 若前一个字符是空格,则函数输出左花引号。否则函数输出右花引号。脚本对单引号的处理方式也一样。 ``` function smartquote (char, prevchar) {         # print smart quotes depending on the previous character @@ -46,7 +49,8 @@ function smartquote (char, prevchar) { } ``` -这个 gawk 脚本的主体部分通过该函数处理 HTML 输入文件的一个个字符。该脚本在 HTML 标签内部逐字原样输出所有内容(比如,``)。在 HTML 标签外,脚本使用 `smartquote()` 函数来输出文本。`smartquote()` 函数来评估是输出普通引号还是花引号。 +这个 gawk 脚本的主体部分通过该函数处理 HTML 输入文件的一个个字符。该脚本在 HTML 标签内部逐字原样输出所有内容(比如,``)。在 HTML 标签外,脚本使用 `smartquote()` 函数来输出文本。`smartquote()` 函数来评估是输出普通引号还是花引号。 + ``` function smartquote (char, prevchar) {         ... @@ -87,11 +91,13 @@ BEGIN {htmltag = 0} ``` 下面是一个例子: + ``` gawk -f quotes.awk test.html > test2.html ``` 其输入为: + ``` @@ -107,10 +113,10 @@ gawk -f quotes.awk test.html > test2.html  

It's and its.

- ``` 其输出为: + ``` @@ -135,7 +141,7 @@ via: https://opensource.com/article/18/8/gawk-script-convert-smart-quotes 作者:[Jim Hall][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[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 248cd6e3bd8cd972340ca72d621a3ca7c970684c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 31 Aug 2018 22:37:12 +0800 Subject: [PATCH 009/455] PUB:20180806 A gawk script to convert smart quotes.md @lujun9972 https://linux.cn/article-9969-1.html --- .../20180806 A gawk script to convert smart quotes.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180806 A gawk script to convert smart quotes.md (100%) diff --git a/translated/tech/20180806 A gawk script to convert smart quotes.md b/published/20180806 A gawk script to convert smart quotes.md similarity index 100% rename from translated/tech/20180806 A gawk script to convert smart quotes.md rename to published/20180806 A gawk script to convert smart quotes.md From 042b27fa1fea735971fe07a0ff0a6a277654fde1 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 31 Aug 2018 23:55:12 +0800 Subject: [PATCH 010/455] PRF:20180706 Anatomy of a Linux DNS Lookup - Part III.md @pinewall --- ...natomy of a Linux DNS Lookup - Part III.md | 31 ++++++------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/translated/tech/20180706 Anatomy of a Linux DNS Lookup - Part III.md b/translated/tech/20180706 Anatomy of a Linux DNS Lookup - Part III.md index 4e5b8628d4..7df06726df 100644 --- a/translated/tech/20180706 Anatomy of a Linux DNS Lookup - Part III.md +++ b/translated/tech/20180706 Anatomy of a Linux DNS Lookup - Part III.md @@ -8,7 +8,7 @@ Linux DNS 查询剖析(第三部分) * `/etc/resolv.conf` * `ping` 与 `host` 查询方式的对比 -and in [Linux DNS 查询剖析(第二部分)][2],我们介绍了: +而在 [Linux DNS 查询剖析(第二部分)][2],我们介绍了: * `systemd` 和对应的 `networking` 服务 * `ifup` 和 `ifdown` @@ -17,21 +17,17 @@ and in [Linux DNS 查询剖析(第二部分)][2],我们介绍了: 剖析进展如下: -* * * - ![linux-dns-2 (2)][4] _(大致)准确的关系图_ 很可惜,故事还没有结束,还有不少东西也会影响 DNS 查询。在第三部分中,我将介绍 `NetworkManager` 和 `dnsmasq`,简要说明它们如何影响 DNS 查询。 -* * * - ### 1) NetworkManager 在第二部分已经提到,我们现在介绍的内容已经偏离 POSIX 标准,涉及的 DNS 解析管理部分在各个发行版上形式并不统一。 -在我使用的发行版 (Ubuntu)中,有一个名为 [NetworkManager][3] 的服务,它通常作为一些其它软件包的依赖被安装而且处于激活available状态。它实际上是 RedHat 在 2004 年开发的一个服务,用于帮助你管理网络接口。 +在我使用的发行版 (Ubuntu)中,有一个名为 [NetworkManager][3] 的可用available服务,它通常作为一些其它软件包的依赖被安装。它实际上是 RedHat 在 2004 年开发的一个服务,用于帮助你管理网络接口。 它与 DNS 查询有什么关系呢?让我们安装这个服务并找出答案: @@ -53,8 +49,6 @@ managed=false 看到 `dns=dnsmasq` 了吧?这意味着 `NetworkManager` 将使用 `dnsmasq` 管理主机上的 DNS。 -* * * - ### 2) dnsmasq `dnsmasq` 程序是我们很熟悉的程序:只是 `/etc/resolv.conf` 之上的又一个间接层。 @@ -89,13 +83,13 @@ search home 可见,并没有被 `NetworkManager` 修改。 -如果安装 `dnsmasq`: +如果安装 `dnsmasq`: ``` $ apt-get install -y dnsmasq ``` -这时,`dnsmasq` 已经启动运行: +然后启动运行 `dnsmasq`: ``` $ ps -ef | grep dnsmasq @@ -130,14 +124,11 @@ udp        0      0 0.0.0.0:68        0.0.0.0:*               udp        0      0 0.0.0.0:68        0.0.0.0:*               10185/dhclient ``` -* * * - ### 3) 分析 dnsmasq 在目前的情况下,所有的 DNS 查询都会使用 `127.0.0.1:53` 这个 DNS 服务器,下一步会发生什么呢? -我再次查看 `/var/run` 目录,可以发现一个线索: -`resolvconf` 目录下 `resolv.conf` 文件中的配置也相应变更,变更为 `dnsmasq` 对应的 DNS 服务器: +我再次查看 `/var/run` 目录,可以发现一个线索:`resolvconf` 目录下 `resolv.conf` 文件中的配置也相应变更,变更为 `dnsmasq` 对应的 DNS 服务器: ``` $ cat /var/run/resolvconf/resolv.conf @@ -160,8 +151,6 @@ nameserver 10.0.2.2 虽然可以推导出这个结论,但如何查看具体的调用逻辑呢? -* * * - ### 4) 调试 dnsmasq 我经常思考 `dnsmasq` (在整个过程中)的功能定位。幸运的是,如果你将 `/etc/dnsmasq.conf` 中的一行做如下调整,你可以获取大量 `dnsmasq` 状态的信息: @@ -200,7 +189,7 @@ Jul  3 19:56:07 ubuntu-xenial dnsmasq[15372]: query[A] bbc.co.uk from 127.0.0.1 可以清晰看出 `dnsmasq` 收到的查询、查询被转发到了哪里以及收到的回复。 -如果查询被缓存命中(或者说,本地的查询结果还在存活时间time-to-live内,并未过期),日志显示如下: +如果查询被缓存命中(或者说,本地的查询结果还在存活时间time-to-live TTL 内,并未过期),日志显示如下: ``` [...] query[A] bbc.co.uk from 127.0.0.1 @@ -219,7 +208,7 @@ $ kill -SIGUSR1 $(cat /run/dnsmasq/dnsmasq.pid) (LCTT 译注:原文中命令执行报错,已变更成最接近且符合作者意图的命令) -导记录对应如下输出: +导出记录对应如下输出: ``` Jul  3 15:08:08 ubuntu-xenial dnsmasq[15697]: time 1530630488 @@ -245,7 +234,7 @@ Jul  3 15:08:08 ubuntu-xenial dnsmasq[15697]: time 1530630488 [...] ip6-allrouters   ff02::2        6FRI   H ``` -在上面的输出中,我猜测(并不确认,`?` 代表我比较疯狂的猜测)如下: +在上面的输出中,我猜测(并不确认,`?` 代表我比较无根据的猜测)如下: * `4` 代表 IPv4 * `6` 代表 IPv6 @@ -263,8 +252,6 @@ Jul  3 15:08:08 ubuntu-xenial dnsmasq[15697]: time 1530630488 `NetworkManager` 配置中的 `dns` 字段并不是只能使用 `dnsmasq`,可选项包括 `none`,`default`,`unbound` 和 `dnssec-triggered` 等。使用 `none` 时,`NetworkManager` 不会改动 `/etc/resolv.conf`;使用 `default` 时,`NetworkManager` 会根据当前的活跃连接active connections更新 `resolv.conf`;使用 `unbound` 时,`NetworkManager` 会与 `unbound` 服务通信;`dnssec-triggered` 与 DNS 安全相关,不在本文讨论范围。 -* * * - ### 第三部分总结 第三部分到此结束,其中我们介绍了 `NetworkManager` 服务及其 `dns=dnsmasq` 的配置。 @@ -288,7 +275,7 @@ via: https://zwischenzugs.com/2018/07/06/anatomy-of-a-linux-dns-lookup-part-iii/ 作者:[ZWISCHENZUGS][a] 译者:[pinewall](https://github.com/pinewall) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 7701445a85aee3217e7eaa7c74cfaf76276e5956 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 1 Sep 2018 00:15:28 +0800 Subject: [PATCH 011/455] PRF:20180626 How to build a professional network when you work in a bazaar.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @ZenMoore 翻译的很好。 --- ...ional network when you work in a bazaar.md | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/translated/talk/20180626 How to build a professional network when you work in a bazaar.md b/translated/talk/20180626 How to build a professional network when you work in a bazaar.md index 5a94dd8c2f..0434331c6b 100644 --- a/translated/talk/20180626 How to build a professional network when you work in a bazaar.md +++ b/translated/talk/20180626 How to build a professional network when you work in a bazaar.md @@ -1,25 +1,27 @@ -在市场工作时如何建立一个职业网络 +在开源“集市”工作时如何建立一个职业网络 ====== + +> 在组织内建立联系遇到问题了吗?你或许是采用了错误的策略。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/connection_people_team_collaboration.png?itok=0_vQT8xV) -职业社交网络——在同事或专业人员之间建立人际联系——可以采用多种形式、在产业内跨组织进行。建立职业网络需要花费时间和精力,并且当某位成员加入或离开一个组织时,此人的网络通常需要被在一个新的工作环境中重建。 +职业社交网络 —— 在同事或专业人员之间建立人际联系 —— 可以采用多种形式、在产业内跨组织进行。建立职业网络需要花费时间和精力,并且当某位成员加入或离开一个组织时,此人的网络通常需要被在一个新的工作环境中重建。 -职业社交网络在不同组织中起相似作用——信息共享,导师制,机会,工作利益和其他作用——然而传统组织与开放组织在组织内构建特定联系的方法和原因可能不尽相同。这些差异有其影响:同事联系方式、如何建立信任、组织内多元化的程度和种类以及建立合作的能力,所有这些因素都是相互关联的,而且他们参与并塑造了人们所建立的社交网络。 +职业社交网络在不同组织中起相似作用 —— 信息共享、导师制、机会、工作利益和其他作用 —— 然而传统组织与开放组织在组织内构建特定联系的*方法*和*原因*可能不尽相同。这些差异有其影响:同事联系方式、如何建立信任、组织内多元化的程度和种类以及建立合作的能力,所有这些因素都是相互关联的,而且它们参与并塑造了人们所建立的社交网络。 -一个开放的组织对包容性的强调可以使社交网络在解决商业问题上比传统等级制组织更加高效。这种观念在开源的思考中有很久的历史。例如,在[《教堂与市场》][1]The Cathedral and the Bazaar中,埃里克·雷蒙德写道:“许多年前社会学家发现, 相比一个随机选择的观察者的观点,许多同等专业的(或是同等无知的)观察家的普遍观点是可靠得多的预言。”所以让我们了解社交网络的结构和目的如何影响各类组织的价值观。 +一个开放的组织对包容性的强调可以使社交网络在解决商业问题上比传统等级制组织更加高效。这种观念在开源的思考中有很久的历史。例如,在[《教堂与集市》][1]The Cathedral and the Bazaar中,埃里克·雷蒙德写道:“许多年前社会学家发现,相比一个随机选择的观察者的观点,许多同等专业的(或是同等无知的)观察家的普遍观点是可靠得多的预言。”所以让我们了解社交网络的结构和目的如何影响各类组织的价值观。 ### 传统组织中的社交网络 -当我在传统组织工作并要描述我为工作做了什么时,人们问我的第一件事就是我与其他人如何关联,通常是主任级的领导。“你在希拉手下吗?”他们会这么问。“你为马尔科姆工作吗?”这意味着以一种上下级的视角看待传统组织的作用;当试图安排工作或雇员时,人们想要从上下级的角度理解网络结构。 +当我在传统组织工作并要描述我为工作做了什么时,人们问我的第一件事就是我与其他人(通常是总监级的领导)的关系。“你在希拉手下吗?”他们会这么问。“你为马尔科姆工作吗?”这意味着以一种上下级的视角看待传统组织的作用;当试图安排工作或雇员时,人们想要从上下级的角度理解网络结构。 -换言之,在传统组织中社交网络依赖于等级制结构,因此他们彼此追寻。事实上,甚至弄清一个雇员在关系网中处于怎样的位置也算得上是一种“上下级组织”式的担忧。 +换言之,在传统组织中社交网络依赖于等级制结构,因此他们彼此跟随。事实上,甚至弄清一个雇员在关系网中处于怎样的位置也算得上是一种“上下级组织”式的担忧。 然而并非所有潜在等级制都是如此。它还视相关人员而定。对于上下级网络的关注会决定雇员在网络中的“价值”,因为网络本身是一个持续的权力关系的系统,它会根据人不同水平的价值给予他们不同的定位。它淡化了个人的能力和技能的重要性。因此,一个人在传统组织的联系促使其能力具有前瞻性,为人所知,有影响力并在其事业中起到支持作用。 相比传统等级制组织,一个开放的组织对包容性的强调能使网络解决商业问题更加高效。 -传统组织的正式结构以特定方式决定着雇员的社交网络——有些可能是优点,有些可能是缺点,这取决于具体环境——例如: +传统组织的正式结构以特定方式决定着雇员的社交网络 —— 有些可能是优点,有些可能是缺点,这取决于具体环境——例如: * 要更快速地了解“谁是谁”并看到人们如何关联是较为便捷的(通常这在特定层级内建立信任网络)。 * 通常,这种对关系的进一步的理解意味着会有更少的过剩工作(在一个特定网络中项目有清晰的相应的归属者)和过多交流(人们知道谁对交流什么负责)。 @@ -28,12 +30,10 @@ * 权力转让缓慢;一个人的参与能力更多地决定于等级结构所创造的网络的结盟而非其他因素(比如个人能力),减少了被看做社区和成员利益的东西。 * 竞争似乎更加清晰;理解“谁在竞争什么”通常发生在一个公认的、被限定了的等级结构中(权力网络中职位的缺乏增进了竞争因此竞争会更激烈)。 * 当更严格的网络决定了灵活性的限度时,适应能力会受损。网络的“夙愿”和合作的限度也会以同样的方式受影响。 - * 在严格的网络中,方向明确,并且领导人通常靠过度指导经营,在这里,破坏更容易发生。 - * 当社交网络不那么灵活时,风险下降;人们知道什么需要发生,怎样发生,何时发生(但是考虑到在一个组织中工作的广度,这不见得总是“坏事”;一些工作的职能需要较小的风险,例如:人力资源管理H R),企业并购和法律工作等。 + * 在严格的网络中,方向明确,并且领导人通常靠过度指导来进行管理,在这里,破坏更容易发生。 + * 当社交网络不那么灵活时,风险下降;人们知道什么需要发生,怎样发生,何时发生(但是考虑到在一个组织中工作的广度,这不见得总是“坏事”;一些工作的职能需要较小的风险,例如:人力资源管理 HR),企业并购和法律工作等。 * 在网络中的信任是更大的,尤其当受雇者是正式网络的一部分的时候(当某人不是网络的一份子时,被排斥的人可能特别难管理或改正)。 - - ### 开放组织中的社交网络 尽管开放组织必定会有等级结构,但他们并不根据那个网络运作。他们的职业网络结构更加灵活(或者说是“随时随地”)。 @@ -53,22 +53,21 @@ * 灵活的社交网络同样会增加变革和风险;创意会流通得更快而且更神奇,并且执行会更加自信。 * 信任建立在同事合作之上(它本该如此!),而不是在对架构的尊重之上。 - - ### 让它有效 如果你正在考虑从一种组织架构转变为另一种,当你在构建并维持你的职业社交网络时思考一下如下所述内容。 #### 来自传统组织的小建议 - * 对决策的架构和管控不是坏事; 运作中的框架需要明晰透明,而且决策者需要考虑他们的决定。 + * 对决策的架构和管控不是坏事;运作中的框架需要明晰透明,而且决策者需要考虑他们的决定。 * 在执行上突出需要经理提供关注,还需要有在滤出任何让人分心或混乱的事务的同时仍能提供足够的来龙去脉的能力。 * 已经确立的网络帮助了一大批人同步工作并且能管控风险。 -#### 来自开放组织的小建议 - * 能力强的领导人是那些可以根据多样的风格和对同事、团队的不同偏好提供不同层次的透明度和指导,同时又不会构建出不灵活的网络的人。。 +#### 来自开放组织的小建议 + + * 能力强的领导人是那些可以根据多样的风格和对同事、团队的不同偏好提供不同层次的透明度和指导,同时又不会构建出不灵活的网络的人。 * 伟大的想法比已建立的组织会赢得更多。 - * 人们对他们得名声会更加负责任。 + * 人们对他们的名声会更加负责任。 * 创意和信息的流转是变革的关键。松散组织中的关系网络可以使这两种元素生发的频度更高、幅度更广。 @@ -79,7 +78,7 @@ via: https://opensource.com/open-organization/18/6/building-professional-social- 作者:[Heidi Hess;von Ludewig][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[ZenMoore](https://github.com/ZenMoore) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 72e65bd0919517c3bb835f3562d222448e7dfd29 Mon Sep 17 00:00:00 2001 From: ypingcn <1344632698@qq.com> Date: Sat, 1 Sep 2018 13:08:09 +0800 Subject: [PATCH 012/455] Claim: 20180826 How to capture and analyze packets with tcpdump command on Linux.md --- ...capture and analyze packets with tcpdump command on Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md b/sources/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md index 0098323fcd..4ab2b8d72b 100644 --- a/sources/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md +++ b/sources/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md @@ -1,3 +1,5 @@ +translating by ypingcn + How to capture and analyze packets with tcpdump command on Linux ====== tcpdump is a well known command line **packet analyzer** tool. Using tcpdump command we can capture the live TCP/IP packets and these packets can also be saved to a file. Later on these captured packets can be analyzed via tcpdump command. tcpdump command becomes very handy when it comes to troubleshooting on network level. From 9cd6fb822eed450b010f6d3664732d2480250e1d Mon Sep 17 00:00:00 2001 From: Auk7F7 <34982730+Auk7F7@users.noreply.github.com> Date: Sat, 1 Sep 2018 13:15:55 +0800 Subject: [PATCH 013/455] Delete 20180316 How to Encrypt Files From Within a File Manager.md --- ...ncrypt Files From Within a File Manager.md | 179 ------------------ 1 file changed, 179 deletions(-) delete mode 100644 sources/tech/20180316 How to Encrypt Files From Within a File Manager.md diff --git a/sources/tech/20180316 How to Encrypt Files From Within a File Manager.md b/sources/tech/20180316 How to Encrypt Files From Within a File Manager.md deleted file mode 100644 index 491c18eb04..0000000000 --- a/sources/tech/20180316 How to Encrypt Files From Within a File Manager.md +++ /dev/null @@ -1,179 +0,0 @@ -How to Encrypt Files From Within a File Manager -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/encryption.jpg?itok=Pk3_x5hz) -The Linux desktop and server enjoys a remarkable level of security. That doesn’t mean, however, you should simply rest easy. You should always consider that your data is always a quick hack away from being compromised. That being said, you might want to employ various tools for encryption, such as GnuPG, which lets you encrypt and decrypt files and much more. One problem with GnuPG is that some users don’t want to mess with the command line. If that’s the case, you can turn to a desktop file manager. Many Linux desktops include the ability to easily encrypt or decrypt files, and if that capability is not built in, it’s easy to add. - -I will walk you through the process of encrypting and decrypting a file from within three popular Linux file managers: - - * Nautilus (aka GNOME Files) - - * Dolphin - - * Thunar - - - - -### Installing GnuPG - -Before we get into the how to of this, we have to ensure your system includes the necessary base component… [GnuPG][1]. Most distributions ship with GnuPG included. On the off chance you use a distribution that doesn’t ship with GnuPG, here’s how to install it: - - * Ubuntu-based distribution: sudo apt install gnupg - - * Fedora-based distribution: sudo yum install gnupg - - * openSUSE: sudo zypper in gnupg - - * Arch-based distribution: sudo pacman -S gnupg - - - - -Whether you’ve just now installed GnuPG or it was installed by default, you will have to create a GPG key for this to work. Each desktop uses a different GUI tool for this (or may not even include a GUI tool for the task), so let’s create that key from the command line. Open up your terminal window and issue the following command: -``` -gpg --gen-key - -``` - -You will then be asked to answer the following questions. Unless you have good reason, you can accept the defaults: - - * What kind of key do you want? - - * What key size do you want? - - * Key is valid for? - - - - -Once you’ve answered these questions, type y to indicate the answers are correct. Next you’ll need to supply the following information: - - * Real name. - - * Email address. - - * Comment. - - - - -Complete the above and then, when prompted, type O (for Okay). You will then be required to type a passphrase for the new key. Once the system has collected enough entropy (you’ll need to do some work on the desktop so this can happen), your key will have been created and you’re ready to go. - -Let’s see how to encrypt/decrypt files from within the file managers. - -### Nautilus - -We start with the default GNOME file manager because it is the easiest. Nautilus requires no extra installation or extra work to encrypt/decrypt files from within it’s well-designed interface. Once you have your gpg key created, you can open up the file manager, navigate to the directory housing the file to be encrypted, right-click the file in question, and select Encrypt from the menu (Figure 1). - - -![nautilus][3] - -Figure 1: Encrypting a file from within Nautilus. - -[Used with permission][4] - -You will be asked to select a recipient (or list of recipients — Figure 2). NOTE: Recipients will be those users whose public keys you have imported. Select the necessary keys and then select your key (email address) from the Sign message as drop-down. - -![nautilus][6] - -Figure 2: Selecting recipients and a signer. - -[Used with permission][4] - -Notice you can also opt to encrypt the file with only a passphrase. This is important if the file will remain on your local machine (more on this later). Once you’ve set up the encryption, click OK and (when prompted) type the passphrase for your key. The file will be encrypted (now ending in .gpg) and saved in the working directory. You can now send that encrypted file to the recipients you selected during the encryption process. - -Say someone (who has your public key) has sent you an encrypted file. Save that file, open the file manager, navigate to the directory housing that file, right-click the encrypted file, select Open With Decrypt File, give the file a new name (without the .gpg extension), and click Save. When prompted, type your gpg key passphrase and the file will be decrypted and ready to use. - -### Dolphin - -On the KDE front, there’s a package that must be installed in order to encrypt/decrypt from with the Dolphin file manager. Log into your KDE desktop, open the terminal window, and issue the following command (I’m demonstrating with Neon. If your distribution isn’t Ubuntu-based, you’ll have to alter the command accordingly): -``` -sudo apt install kgpg - -``` - -Once that installs, logout and log back into the KDE desktop. You can open up Dolphin and right-click a file to be encrypted. Since this is the first time you’ve used kgpg, you’ll have to walk through a quick setup wizard (which self-explanatory). When you’ve completed the wizard, you can go back to that file, right-click it (Figure 3), and select Encrypt File. - - -![Dolphin][8] - -Figure 3: Encrypting a file within Dolphin. - -[Used with permission][4] - -You’ll be prompted to select the key to use for encryption (Figure 4). Make your selection and click OK. The file will encrypt and you’re ready to send it to the recipient. - -Note: With KDE’s Dolphin file manager, you cannot encrypt with a passphrase only. - - -![Dolphin][10] - -Figure 4: Selecting your recipients for encryption. - -[Used with permission][4] - -If you receive an encrypted file from a user who has your public key (or you have a file you’ve encrypted yourself), open up Dolphin, navigate to the file in question, double-click the file, give the file a new name, type the encryption passphrase, and click OK. You can now read your newly decrypted file. If you’ve encrypted the file with your own key, you won’t be prompted to type the passphrase (as it has already been stored). - -### Thunar - -The Thunar file manager is a bit trickier. There aren’t any extra packages to install; instead, you need to create new custom action for Encrypt. Once you’ve done this, you’ll have the ability to do this from within the file manager. - -To create the custom actions, open up the Thunar file manager and click Edit > Configure Custom Actions. In the resulting window, click the + button (Figure 5) and enter the following for an Encrypt action: - -Name: Encrypt - -Description: File Encryption - -Command: gnome-terminal -x gpg --encrypt --recipient %f - -Click OK to save this action. - - -![Thunar][12] - -Figure 5: Creating an custom action within Thunar. - -[Used with permission][4] - -NOTE: If gnome-terminal isn’t your default terminal, substitute the command to open your default terminal in. - -You can also create an action that encrypts with a passphrase only (not a key). To do this, the details for the action would be: - -Name: Encrypt Passphrase - -Description: Encrypt with Passphrase only - -Command: gnome-terminal -x gpg -c %f - -You don’t need to create a custom action for the decryption process, as Thunar already knows what to do with an encrypted file. To decrypt a file, simply right-click it (within Thunar), select Open With Decrypt File, give the decrypted file a name, and (when/if prompted) type the encryption passphrase. Viola, your encrypted file has been decrypted and is ready to use. - -### One caveat - -Do note: If you encrypt your own files, using your own keys, you won’t need to enter an encryption passphrase to decrypt them (because your public keys are stored). If, however, you receive files from others (who have your public key) you will be required to enter your passphrase. If you’re wanting to store your own encrypted files, instead of encrypting them with a key, encrypt them with a passphrase only. This is possible with Nautilus and Thunar (but not KDE). By opting for passphrase encryption (over key encryption), when you go to decrypt the file, it will always prompt you for the passphrase. - -### Other file managers - -There are plenty of other file managers out there, some of them can work with encryption, some cannot. Chances are, you’re using one of these three tools, so the ability to add encryption/decryption to the contextual menu is not only possible, it’s pretty easy. Give this a try and see if it doesn’t make the process of encryption and decryption much easier. - -Learn more about Linux through the free ["Introduction to Linux" ][13] course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/3/how-encrypt-files-within-file-manager - -作者:[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.gnupg.org/ -[3]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/nautilus.jpg?itok=ae7Gtj60 (nautilus) -[4]:https://www.linux.com/licenses/category/used-permission -[6]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/nautilus_2.jpg?itok=3ht7j63n (nautilus) -[8]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kde_0.jpg?itok=KSTctVw0 (Dolphin) -[10]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kde_2.jpg?itok=CeqWikNl (Dolphin) -[12]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/thunar.jpg?itok=fXcHk08B (Thunar) -[13]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From d595e6d5ebbf80217a52f993335af65316fee29f Mon Sep 17 00:00:00 2001 From: Auk7F7 <34982730+Auk7F7@users.noreply.github.com> Date: Sat, 1 Sep 2018 13:19:59 +0800 Subject: [PATCH 014/455] Create 20180316 How to Encrypt Files From Within a File Manager.md --- ...ncrypt Files From Within a File Manager.md | 179 ++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 translated/tech/20180316 How to Encrypt Files From Within a File Manager.md diff --git a/translated/tech/20180316 How to Encrypt Files From Within a File Manager.md b/translated/tech/20180316 How to Encrypt Files From Within a File Manager.md new file mode 100644 index 0000000000..d74fc29022 --- /dev/null +++ b/translated/tech/20180316 How to Encrypt Files From Within a File Manager.md @@ -0,0 +1,179 @@ +如何从文件管理器中加密文件 +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/encryption.jpg?itok=Pk3_x5hz) +Linux 桌面版和服务器版具有卓越的安全性。然而这并不意味着你可以放松警惕。你应该一直认为你的数据总是很快就会被破坏。也就是说,你可能需要使用各种加密工具。比如 GnuPG,它可以让你加密和解密文件等更多功能。GnuPG 的一个问题是一些用户不想扰乱命令行。如果是这样的话,你可以转向桌面文件管理器。许多 Linux 桌面版包含了简易的加密和解密文件的功能,如果这种功能没有内置,那么也是很容易添加的。 + +我将引导你完成从三个流行的 Linux 文件管理器中对文件进行加密和解密过程: + + * Nautilus (aka GNOME Files) + + * Dolphin + + * Thunar + + + + +### 安装 GnuPG + +在我们讨论如何处理这个问题之前,我们必须确保你的系统包含了必要的基本组件... [GnuPG][1]。大多数发行版本都包含 GnuPG。 在某些偶然情况下,你使用的是没有自带 GnuPG 的发行版本,以下是安装方法: + + * 基于 Ubuntu 的发行版: sudo apt install gnupg + + * 基于 Fedora 的发行版: sudo yum install gnupg + + * openSUSE: sudo zypper in gnupg + + * 基于 Arch 的发行版:sudo pacman -S gnupg + + + + +无论你是刚刚安装了 GnuPG,还是默认安装的,你都必须创建一个 GPG 密钥才能使用。每个桌面版都使用了不同的 GUI 工具(或者甚至不包含一个 GUI 工具来完成这个任务),所以让我们从命令行中创建这个密钥。打开终端窗口并输入以下指令: +``` +gpg --gen-key + +``` + +然后,你将被要求回答以下问题。除非你有充分的理由,否则你可以接受默认值: + + * 你想要哪种密钥? + + * 你想要多大的密钥? + + * 密钥是否有效? + + + + +一旦你回答了这些问题,输入 y 来表示答案是正确的。接下来你需要提供以下信息: + + * 真实姓名。 + + * Email 地址。 + + * 评论。 + + + + +完成上述操作后,然后在提示的时候输入 o (为了 ok )。然后,你将被要求为新密钥输入一个密码。一旦系统收集到了足够的熵(你需要在桌面上做一些工作才能做到这一点),你的密钥就会被创建,然后你就可以开始工作了。 + +让我们看看如何从文件管理器中加密/解密文件: + +### Nautilus + +让我们从默认的 GNOME 文件管理器开始,因为它是最简单的。Nautilus 不需要额外的安装或额外的工作就可以从精心设计的接口内加密/解密文件。一旦你创建完 gpg 密钥后,就可以打开文件管理器,导航到包含要加密的文件的目录,右键单击要加密的文件,然后从菜单中选择 Encrypt (图1)。 + + +![nautilus][3] + +图1:从 Nautilus 中加密文件。 + +[Used with permission][4] + +你将被要求选择一个收件人(或者收件人列表—图2)。注意:收件人将是那些你已经导入了公钥的用户。选择所需的密钥,然后从签名信息下拉列表中选择你的密钥(电子邮件地址)。 + +![nautilus][6] + +图2:选择收件人和签名者。 + +[Used with permission][4] + +注意:你还可以选择仅使用密码来加密文件。如果文件将保留在你的本地机器上,这一点非常重要(稍后将详细介绍)。一旦你设置好加密后,单击 OK 并(在提示时)输入 gpg 密钥的密码。文件将被加密(现在以 .gpg 结尾)并保存在工作目录中。现在你可以将加密后的文件发送给在加密过程中已选择的收件人。 + +说某人(谁拥有你的公钥)已经给你发送了一个加密文件。保存该文件,打开文件管理器,导航到该文件所在的目录,右击加密文件,选择 Open With Decrypt File,给文件一个新名称(不带 .gpg 的扩展名),然后单击“保存”。当提示时,输入你的 gpg 密钥的密码,该文件将被解密并准备使用。 + +### Dolphin + +在KDE前端,必须安装一个软件包才能使用 Dolphin 文件管理器进行加密/解密。 登录到你的KDE桌面,打开终端窗口,然后输入以下命令(我正在使用 Neon 进行演示。如果你的发行版不是基于Ubuntu 的,则必须相应地更改命令): +``` +sudo apt install kgpg + +``` + +安装完毕后,注销并重新登录KDE桌面。 你可以打开 Dolphin 并右键单击要加密的文件。 由于这是你第一次使用 kgpg,因此你必须完成快速设置向导(不言自明)。 当完成向导后,你可以返回该文件,右键单击它(图3),然后选择 Encrypt File。 + + +![Dolphin][8] + +图3:在 Dolphin 中加密文件。 + +[Used with permission][4] + +系统将提示你选择用于加密的密钥(图4)。 进行选择并单击 OK。 该文件将被加密,而且你已准备好将其发送给收件人。 + +注意:使用 KDE 的 Dolphin 文件管理器市,你无法仅使用密码加密。 + + +![Dolphin][10] + +图4:选择要加密的收件人。 + +[Used with permission][4] + +如果你收到来自拥有公钥的用户的加密文件(或者你有自己加密的文件),请打开 Dolphin,导航到相关文件,双击该文件,为该文件指定一个新名称 ,键入加密密码并单击 OK。 你现在可以读取到新解密的文件。 如果你使用自己的密钥加密了该文件,则不会提示你键入密码(因为它已经被存储了)。 + +### Thunar + +Thunar文件管理器有点棘手。 没有任何额外的软件包可供安装; 相反,你需要为了加密创建新的自定义操作。完成此操作后,你将能够在文件管理器中执行此操作。 + +要创建自定义操作,请打开 Thunar 文件管理器,然后单击 Edit > Configure Custom Actions。 在所得到的窗口中,单击 + 按钮(图5)并为加密操作输入以下内容: + +名称:加密 + +描述:文件加密 + +命令:gnome-terminal -x gpg --encrypt --recipient%f + +单击 OK 以保存此操作。 + + +![Thunar][12] + +图5:在Thunar中创建自定义操作。 + +[Used with permission][4] + +注意:如果 gnome-terminal 不是你的默认终端,请替换该命令以打开你的默认终端。 + +你还可以创建仅使用密码加密(不是密钥)的操作。 为此,该操作的详细动作将会是以下内容: + +名称:加密密码 + +说明:仅使用密码加密 + +命令:gnome-terminal -x gpg -c%f + +你不需要为解密过程创建一个自定义操作,因为 Thunar 已经知道如何处理一个加密文件。 要解密文件,只需右键单击它(在 Thunar 中),选择 Open With Decrypt File,为解密文件命名,然后(在提示时)键入加密密码。 Viola,你的加密文件已被解密并可以使用。 + +### 一个警告 + +请注意:如果你使用自己的密钥加密自己的文件,则无需输入加密密码来解密它们(因为你的公钥已存储)。 但是,如果你收到其他人(谁拥有你的公钥)的文件,则需要输入你的密码。 如果你想要存储自己的加密文件,而不是使用密钥来加密它们,请使用仅使用密码加密。 Nautilus 和Thunar(但不是KDE)可以做到这一点。 通过选择密码加密(通过密钥加密),当你解密文件时,它将始终提示你输入密码。 + +### 其他文件管理器 + +还有很多其他的文件管理器,他们中的一些可以使用加密,有些则不能。 你很有可能正在使用这三种工具中的一种,因此不仅可以将加密 / 解密添加到上下文菜单,而且是非常容易。 尝试一下,看看它是否会使加密和解密的过程变得更容易。 + +从 Linux 基金会和 edX 免费提供的["Linux 介绍" ][13]课程了解更多关于 Linux 的信息。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/3/how-encrypt-files-within-file-manager + +作者:[JACK WALLEN][a] +译者:[Auk7f7](https://github.com/Auk7f7) +校对:[校对者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.gnupg.org/ +[3]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/nautilus.jpg?itok=ae7Gtj60 "nautilus" +[4]:https://www.linux.com/licenses/category/used-permission +[6]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/nautilus_2.jpg?itok=3ht7j63n "nautilus" +[8]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kde_0.jpg?itok=KSTctVw0 "Dolphin" +[10]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kde_2.jpg?itok=CeqWikNl "Dolphin" +[12]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/thunar.jpg?itok=fXcHk08B "Thunar" +[13]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From ed9e79996a6ba939f02f6118771f6d5bf4aca9f3 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 1 Sep 2018 21:22:49 +0800 Subject: [PATCH 015/455] PUB:20180626 How to build a professional network when you work in a bazaar.md @ZenMoore https://linux.cn/article-9971-1.html --- ...to build a professional network when you work in a bazaar.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {translated/talk => published}/20180626 How to build a professional network when you work in a bazaar.md (98%) diff --git a/translated/talk/20180626 How to build a professional network when you work in a bazaar.md b/published/20180626 How to build a professional network when you work in a bazaar.md similarity index 98% rename from translated/talk/20180626 How to build a professional network when you work in a bazaar.md rename to published/20180626 How to build a professional network when you work in a bazaar.md index 0434331c6b..fc9452edbc 100644 --- a/translated/talk/20180626 How to build a professional network when you work in a bazaar.md +++ b/published/20180626 How to build a professional network when you work in a bazaar.md @@ -75,7 +75,7 @@ via: https://opensource.com/open-organization/18/6/building-professional-social-networks-openly -作者:[Heidi Hess;von Ludewig][a] +作者:[Heidi Hess von Ludewig][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[ZenMoore](https://github.com/ZenMoore) 校对:[wxy](https://github.com/wxy) From 5c227ae8cb71706c86f830ebfeb056811828731c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 1 Sep 2018 21:24:33 +0800 Subject: [PATCH 016/455] =?UTF-8?q?=E5=BD=92=E6=A1=A3=20201808?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => 201808}/20160325 Network automation with Ansible.md | 0 ...llection Of Useful BASH Scripts For Heavy Commandline Users.md | 0 ...70721 Arch Linux Applications Automatic Installation Script.md | 0 ... (Flexible I-O Tester) to Measure Disk Performance in Linux.md | 0 .../{ => 201808}/20171009 Considering Pythons Target Audience.md | 0 ...1 Linux command line tools for working with non-Linux users.md | 0 .../{ => 201808}/20171102 Using User Namespaces on Docker.md | 0 ...ches TensorFlow-based vision recognition kit for RPi Zero W.md | 0 .../20180107 7 leadership rules for the DevOps age.md | 0 ...w to Play Sound Through Two or More Output Devices in Linux.md | 0 .../20180306 How To Check All Running Services In Linux.md | 0 ...Machine Learning to IoT using Android Things and TensorFlow.md | 0 .../20180306 Try, learn, modify- The new IT leader-s code.md | 0 ...tem Hardware Manufacturer, Model And Serial Number In Linux.md | 0 ...429 Asynchronous Processing with Go using Kafka and MongoDB.md | 0 ...0508 Everything old is new again- Microservices - DXC Blogs.md | 0 .../20180508 UKTools - Easy Way To Install Latest Linux Kernel.md | 0 ...180510 Splicing the Cloud Native Stack, One Floor at a Time.md | 0 .../{ => 201808}/20180516 How to Read Outlook Emails by Python.md | 0 ...80523 A Set Of Useful Utilities For Debian And Ubuntu Users.md | 0 .../20180524 How CERN Is Using Linux and Open Source.md | 0 ... Find If A Package Is Available For Your Linux Distribution.md | 0 ...7 Using MQTT to send and receive data for your next project.md | 0 .../20180609 Anatomy of a Linux DNS Lookup - Part I.md | 0 .../20180615 5 Commands for Checking Memory Usage in Linux.md | 0 .../20180618 Anatomy of a Linux DNS Lookup - Part II.md | 0 ... How to reset, revert, and return to previous states in Git.md | 0 .../{ => 201808}/20180621 Bitcoin is a Cult - Adam Caudill.md | 0 ...0622 How to Check Disk Space on Linux from the Command line.md | 0 ...nstall Yaourt- Use These Alternatives for AUR in Arch Linux.md | 0 ...and Emulating Linux System Calls with Ptrace - null program.md | 0 .../20180627 CIP- Keeping the Lights On with Linux.md | 0 ...702 How to edit Adobe InDesign files with Scribus and Gedit.md | 0 ...ke a career move from proprietary to open source technology.md | 0 ...y is Arch Linux So Challenging and What are Its Pros - Cons.md | 0 published/{ => 201808}/20180705 Testing Node.js in 2018.md | 0 ...visiting wallabag, an open source alternative to Instapaper.md | 0 .../20180709 A sysadmin-s guide to network management.md | 0 ...710 4 Essential and Practical Usage of Cut Command in Linux.md | 0 .../20180710 How I Fully Quit Google And You Can Too.md | 0 ...cript Framework Comparison with Examples React Vue Hyperapp.md | 0 published/{ => 201808}/20180711 netdev-day-1--ipsec.md | 0 ...ysadmin-s guide to SELinux- 42 answers to the big questions.md | 0 published/{ => 201808}/20180712 Slices from the ground up.md | 0 ...y 2 moving away from as fast as possible in networking code.md | 0 .../20180716 3 cool productivity apps for Fedora 28.md | 0 .../20180719 Incomplete Path Expansion (Completion) For Bash.md | 0 .../20180720 3 Methods to List All The Users in Linux System.md | 0 .../20180720 4 cool new projects to try in COPR for July 2018.md | 0 published/{ => 201808}/20180720 Convert video using Handbrake.md | 0 ... 4 open source media conversion tools for the Linux desktop.md | 0 .../20180724 Textricator- Data extraction made simple.md | 0 published/{ => 201808}/20180726 4 cool apps for your terminal.md | 0 .../{ => 201808}/20180726 The evolution of package managers.md | 0 .../20180727 Three Graphical Clients for Git on Linux.md | 0 ...e Networking Jobs- A Hotbed of Innovation and Opportunities.md | 0 published/{ => 201808}/20180731 A sysadmin-s guide to Bash.md | 0 .../20180731 How To Use Pbcopy And Pbpaste Commands On Linux.md | 0 published/{ => 201808}/20180801 Cross-Site Request Forgery.md | 0 ...Easy Ways to Check User Name And Other Information in Linux.md | 0 ...0802 Getting started with Mu, a Python editor for beginners.md | 0 published/{ => 201808}/20180803 UNIX curiosities.md | 0 .../{ => 201808}/20180803 What data is too risky for the cloud.md | 0 ...803 Why I still love Alpine for email at the Linux terminal.md | 0 .../20180806 A gawk script to convert smart quotes.md | 0 ...180806 Learn Python programming the easy way with EduBlocks.md | 0 published/{ => 201808}/20180806 What is CI-CD.md | 0 ...80809 How To Switch Between Multiple PHP Versions In Ubuntu.md | 0 .../20180810 Image creation applications for Fedora.md | 0 published/{ => 201808}/20180812 Ubuntu 18.04 Vs. Fedora 28.md | 0 .../20180813 Convert file systems with Fstransform.md | 0 ...w To Switch Between Different Versions Of Commands In Linux.md | 0 ...180813 How to display data in a human-friendly way on Linux.md | 0 .../20180813 Tips for using the top command in Linux.md | 0 ... How To Record Terminal Sessions As SVG Animations In Linux.md | 0 ...w the L1 Terminal Fault vulnerability affects Linux systems.md | 0 ...80819 How to define and use functions in Linux Shell Script.md | 0 .../20180821 A Collection Of More Useful Unix Utilities.md | 0 78 files changed, 0 insertions(+), 0 deletions(-) rename published/{ => 201808}/20160325 Network automation with Ansible.md (100%) rename published/{ => 201808}/20170713 A Collection Of Useful BASH Scripts For Heavy Commandline Users.md (100%) rename published/{ => 201808}/20170721 Arch Linux Applications Automatic Installation Script.md (100%) rename published/{ => 201808}/20170805 How to use Fio (Flexible I-O Tester) to Measure Disk Performance in Linux.md (100%) rename published/{ => 201808}/20171009 Considering Pythons Target Audience.md (100%) rename published/{ => 201808}/20171101 Linux command line tools for working with non-Linux users.md (100%) rename published/{ => 201808}/20171102 Using User Namespaces on Docker.md (100%) rename published/{ => 201808}/20171130 Google launches TensorFlow-based vision recognition kit for RPi Zero W.md (100%) rename published/{ => 201808}/20180107 7 leadership rules for the DevOps age.md (100%) rename published/{ => 201808}/20180118 How to Play Sound Through Two or More Output Devices in Linux.md (100%) rename published/{ => 201808}/20180306 How To Check All Running Services In Linux.md (100%) rename published/{ => 201808}/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md (100%) rename published/{ => 201808}/20180306 Try, learn, modify- The new IT leader-s code.md (100%) rename published/{ => 201808}/20180426 How To Check System Hardware Manufacturer, Model And Serial Number In Linux.md (100%) rename published/{ => 201808}/20180429 Asynchronous Processing with Go using Kafka and MongoDB.md (100%) rename published/{ => 201808}/20180508 Everything old is new again- Microservices - DXC Blogs.md (100%) rename published/{ => 201808}/20180508 UKTools - Easy Way To Install Latest Linux Kernel.md (100%) rename published/{ => 201808}/20180510 Splicing the Cloud Native Stack, One Floor at a Time.md (100%) rename published/{ => 201808}/20180516 How to Read Outlook Emails by Python.md (100%) rename published/{ => 201808}/20180523 A Set Of Useful Utilities For Debian And Ubuntu Users.md (100%) rename published/{ => 201808}/20180524 How CERN Is Using Linux and Open Source.md (100%) rename published/{ => 201808}/20180607 Find If A Package Is Available For Your Linux Distribution.md (100%) rename published/{ => 201808}/20180607 Using MQTT to send and receive data for your next project.md (100%) rename published/{ => 201808}/20180609 Anatomy of a Linux DNS Lookup - Part I.md (100%) rename published/{ => 201808}/20180615 5 Commands for Checking Memory Usage in Linux.md (100%) rename published/{ => 201808}/20180618 Anatomy of a Linux DNS Lookup - Part II.md (100%) rename published/{ => 201808}/20180619 How to reset, revert, and return to previous states in Git.md (100%) rename published/{ => 201808}/20180621 Bitcoin is a Cult - Adam Caudill.md (100%) rename published/{ => 201808}/20180622 How to Check Disk Space on Linux from the Command line.md (100%) rename published/{ => 201808}/20180623 Don-t Install Yaourt- Use These Alternatives for AUR in Arch Linux.md (100%) rename published/{ => 201808}/20180623 Intercepting and Emulating Linux System Calls with Ptrace - null program.md (100%) rename published/{ => 201808}/20180627 CIP- Keeping the Lights On with Linux.md (100%) rename published/{ => 201808}/20180702 How to edit Adobe InDesign files with Scribus and Gedit.md (100%) rename published/{ => 201808}/20180703 How to make a career move from proprietary to open source technology.md (100%) rename published/{ => 201808}/20180703 Why is Arch Linux So Challenging and What are Its Pros - Cons.md (100%) rename published/{ => 201808}/20180705 Testing Node.js in 2018.md (100%) rename published/{ => 201808}/20180706 Revisiting wallabag, an open source alternative to Instapaper.md (100%) rename published/{ => 201808}/20180709 A sysadmin-s guide to network management.md (100%) rename published/{ => 201808}/20180710 4 Essential and Practical Usage of Cut Command in Linux.md (100%) rename published/{ => 201808}/20180710 How I Fully Quit Google And You Can Too.md (100%) rename published/{ => 201808}/20180711 Javascript Framework Comparison with Examples React Vue Hyperapp.md (100%) rename published/{ => 201808}/20180711 netdev-day-1--ipsec.md (100%) rename published/{ => 201808}/20180712 A sysadmin-s guide to SELinux- 42 answers to the big questions.md (100%) rename published/{ => 201808}/20180712 Slices from the ground up.md (100%) rename published/{ => 201808}/20180712 netdev day 2 moving away from as fast as possible in networking code.md (100%) rename published/{ => 201808}/20180716 3 cool productivity apps for Fedora 28.md (100%) rename published/{ => 201808}/20180719 Incomplete Path Expansion (Completion) For Bash.md (100%) rename published/{ => 201808}/20180720 3 Methods to List All The Users in Linux System.md (100%) rename published/{ => 201808}/20180720 4 cool new projects to try in COPR for July 2018.md (100%) rename published/{ => 201808}/20180720 Convert video using Handbrake.md (100%) rename published/{ => 201808}/20180723 4 open source media conversion tools for the Linux desktop.md (100%) rename published/{ => 201808}/20180724 Textricator- Data extraction made simple.md (100%) rename published/{ => 201808}/20180726 4 cool apps for your terminal.md (100%) rename published/{ => 201808}/20180726 The evolution of package managers.md (100%) rename published/{ => 201808}/20180727 Three Graphical Clients for Git on Linux.md (100%) rename published/{ => 201808}/20180730 Open Source Networking Jobs- A Hotbed of Innovation and Opportunities.md (100%) rename published/{ => 201808}/20180731 A sysadmin-s guide to Bash.md (100%) rename published/{ => 201808}/20180731 How To Use Pbcopy And Pbpaste Commands On Linux.md (100%) rename published/{ => 201808}/20180801 Cross-Site Request Forgery.md (100%) rename published/{ => 201808}/20180802 6 Easy Ways to Check User Name And Other Information in Linux.md (100%) rename published/{ => 201808}/20180802 Getting started with Mu, a Python editor for beginners.md (100%) rename published/{ => 201808}/20180803 UNIX curiosities.md (100%) rename published/{ => 201808}/20180803 What data is too risky for the cloud.md (100%) rename published/{ => 201808}/20180803 Why I still love Alpine for email at the Linux terminal.md (100%) rename published/{ => 201808}/20180806 A gawk script to convert smart quotes.md (100%) rename published/{ => 201808}/20180806 Learn Python programming the easy way with EduBlocks.md (100%) rename published/{ => 201808}/20180806 What is CI-CD.md (100%) rename published/{ => 201808}/20180809 How To Switch Between Multiple PHP Versions In Ubuntu.md (100%) rename published/{ => 201808}/20180810 Image creation applications for Fedora.md (100%) rename published/{ => 201808}/20180812 Ubuntu 18.04 Vs. Fedora 28.md (100%) rename published/{ => 201808}/20180813 Convert file systems with Fstransform.md (100%) rename published/{ => 201808}/20180813 How To Switch Between Different Versions Of Commands In Linux.md (100%) rename published/{ => 201808}/20180813 How to display data in a human-friendly way on Linux.md (100%) rename published/{ => 201808}/20180813 Tips for using the top command in Linux.md (100%) rename published/{ => 201808}/20180814 How To Record Terminal Sessions As SVG Animations In Linux.md (100%) rename published/{ => 201808}/20180815 How the L1 Terminal Fault vulnerability affects Linux systems.md (100%) rename published/{ => 201808}/20180819 How to define and use functions in Linux Shell Script.md (100%) rename published/{ => 201808}/20180821 A Collection Of More Useful Unix Utilities.md (100%) diff --git a/published/20160325 Network automation with Ansible.md b/published/201808/20160325 Network automation with Ansible.md similarity index 100% rename from published/20160325 Network automation with Ansible.md rename to published/201808/20160325 Network automation with Ansible.md diff --git a/published/20170713 A Collection Of Useful BASH Scripts For Heavy Commandline Users.md b/published/201808/20170713 A Collection Of Useful BASH Scripts For Heavy Commandline Users.md similarity index 100% rename from published/20170713 A Collection Of Useful BASH Scripts For Heavy Commandline Users.md rename to published/201808/20170713 A Collection Of Useful BASH Scripts For Heavy Commandline Users.md diff --git a/published/20170721 Arch Linux Applications Automatic Installation Script.md b/published/201808/20170721 Arch Linux Applications Automatic Installation Script.md similarity index 100% rename from published/20170721 Arch Linux Applications Automatic Installation Script.md rename to published/201808/20170721 Arch Linux Applications Automatic Installation Script.md diff --git a/published/20170805 How to use Fio (Flexible I-O Tester) to Measure Disk Performance in Linux.md b/published/201808/20170805 How to use Fio (Flexible I-O Tester) to Measure Disk Performance in Linux.md similarity index 100% rename from published/20170805 How to use Fio (Flexible I-O Tester) to Measure Disk Performance in Linux.md rename to published/201808/20170805 How to use Fio (Flexible I-O Tester) to Measure Disk Performance in Linux.md diff --git a/published/20171009 Considering Pythons Target Audience.md b/published/201808/20171009 Considering Pythons Target Audience.md similarity index 100% rename from published/20171009 Considering Pythons Target Audience.md rename to published/201808/20171009 Considering Pythons Target Audience.md diff --git a/published/20171101 Linux command line tools for working with non-Linux users.md b/published/201808/20171101 Linux command line tools for working with non-Linux users.md similarity index 100% rename from published/20171101 Linux command line tools for working with non-Linux users.md rename to published/201808/20171101 Linux command line tools for working with non-Linux users.md diff --git a/published/20171102 Using User Namespaces on Docker.md b/published/201808/20171102 Using User Namespaces on Docker.md similarity index 100% rename from published/20171102 Using User Namespaces on Docker.md rename to published/201808/20171102 Using User Namespaces on Docker.md diff --git a/published/20171130 Google launches TensorFlow-based vision recognition kit for RPi Zero W.md b/published/201808/20171130 Google launches TensorFlow-based vision recognition kit for RPi Zero W.md similarity index 100% rename from published/20171130 Google launches TensorFlow-based vision recognition kit for RPi Zero W.md rename to published/201808/20171130 Google launches TensorFlow-based vision recognition kit for RPi Zero W.md diff --git a/published/20180107 7 leadership rules for the DevOps age.md b/published/201808/20180107 7 leadership rules for the DevOps age.md similarity index 100% rename from published/20180107 7 leadership rules for the DevOps age.md rename to published/201808/20180107 7 leadership rules for the DevOps age.md diff --git a/published/20180118 How to Play Sound Through Two or More Output Devices in Linux.md b/published/201808/20180118 How to Play Sound Through Two or More Output Devices in Linux.md similarity index 100% rename from published/20180118 How to Play Sound Through Two or More Output Devices in Linux.md rename to published/201808/20180118 How to Play Sound Through Two or More Output Devices in Linux.md diff --git a/published/20180306 How To Check All Running Services In Linux.md b/published/201808/20180306 How To Check All Running Services In Linux.md similarity index 100% rename from published/20180306 How To Check All Running Services In Linux.md rename to published/201808/20180306 How To Check All Running Services In Linux.md diff --git a/published/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md b/published/201808/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md similarity index 100% rename from published/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md rename to published/201808/20180306 How to apply Machine Learning to IoT using Android Things and TensorFlow.md diff --git a/published/20180306 Try, learn, modify- The new IT leader-s code.md b/published/201808/20180306 Try, learn, modify- The new IT leader-s code.md similarity index 100% rename from published/20180306 Try, learn, modify- The new IT leader-s code.md rename to published/201808/20180306 Try, learn, modify- The new IT leader-s code.md diff --git a/published/20180426 How To Check System Hardware Manufacturer, Model And Serial Number In Linux.md b/published/201808/20180426 How To Check System Hardware Manufacturer, Model And Serial Number In Linux.md similarity index 100% rename from published/20180426 How To Check System Hardware Manufacturer, Model And Serial Number In Linux.md rename to published/201808/20180426 How To Check System Hardware Manufacturer, Model And Serial Number In Linux.md diff --git a/published/20180429 Asynchronous Processing with Go using Kafka and MongoDB.md b/published/201808/20180429 Asynchronous Processing with Go using Kafka and MongoDB.md similarity index 100% rename from published/20180429 Asynchronous Processing with Go using Kafka and MongoDB.md rename to published/201808/20180429 Asynchronous Processing with Go using Kafka and MongoDB.md diff --git a/published/20180508 Everything old is new again- Microservices - DXC Blogs.md b/published/201808/20180508 Everything old is new again- Microservices - DXC Blogs.md similarity index 100% rename from published/20180508 Everything old is new again- Microservices - DXC Blogs.md rename to published/201808/20180508 Everything old is new again- Microservices - DXC Blogs.md diff --git a/published/20180508 UKTools - Easy Way To Install Latest Linux Kernel.md b/published/201808/20180508 UKTools - Easy Way To Install Latest Linux Kernel.md similarity index 100% rename from published/20180508 UKTools - Easy Way To Install Latest Linux Kernel.md rename to published/201808/20180508 UKTools - Easy Way To Install Latest Linux Kernel.md diff --git a/published/20180510 Splicing the Cloud Native Stack, One Floor at a Time.md b/published/201808/20180510 Splicing the Cloud Native Stack, One Floor at a Time.md similarity index 100% rename from published/20180510 Splicing the Cloud Native Stack, One Floor at a Time.md rename to published/201808/20180510 Splicing the Cloud Native Stack, One Floor at a Time.md diff --git a/published/20180516 How to Read Outlook Emails by Python.md b/published/201808/20180516 How to Read Outlook Emails by Python.md similarity index 100% rename from published/20180516 How to Read Outlook Emails by Python.md rename to published/201808/20180516 How to Read Outlook Emails by Python.md diff --git a/published/20180523 A Set Of Useful Utilities For Debian And Ubuntu Users.md b/published/201808/20180523 A Set Of Useful Utilities For Debian And Ubuntu Users.md similarity index 100% rename from published/20180523 A Set Of Useful Utilities For Debian And Ubuntu Users.md rename to published/201808/20180523 A Set Of Useful Utilities For Debian And Ubuntu Users.md diff --git a/published/20180524 How CERN Is Using Linux and Open Source.md b/published/201808/20180524 How CERN Is Using Linux and Open Source.md similarity index 100% rename from published/20180524 How CERN Is Using Linux and Open Source.md rename to published/201808/20180524 How CERN Is Using Linux and Open Source.md diff --git a/published/20180607 Find If A Package Is Available For Your Linux Distribution.md b/published/201808/20180607 Find If A Package Is Available For Your Linux Distribution.md similarity index 100% rename from published/20180607 Find If A Package Is Available For Your Linux Distribution.md rename to published/201808/20180607 Find If A Package Is Available For Your Linux Distribution.md diff --git a/published/20180607 Using MQTT to send and receive data for your next project.md b/published/201808/20180607 Using MQTT to send and receive data for your next project.md similarity index 100% rename from published/20180607 Using MQTT to send and receive data for your next project.md rename to published/201808/20180607 Using MQTT to send and receive data for your next project.md diff --git a/published/20180609 Anatomy of a Linux DNS Lookup - Part I.md b/published/201808/20180609 Anatomy of a Linux DNS Lookup - Part I.md similarity index 100% rename from published/20180609 Anatomy of a Linux DNS Lookup - Part I.md rename to published/201808/20180609 Anatomy of a Linux DNS Lookup - Part I.md diff --git a/published/20180615 5 Commands for Checking Memory Usage in Linux.md b/published/201808/20180615 5 Commands for Checking Memory Usage in Linux.md similarity index 100% rename from published/20180615 5 Commands for Checking Memory Usage in Linux.md rename to published/201808/20180615 5 Commands for Checking Memory Usage in Linux.md diff --git a/published/20180618 Anatomy of a Linux DNS Lookup - Part II.md b/published/201808/20180618 Anatomy of a Linux DNS Lookup - Part II.md similarity index 100% rename from published/20180618 Anatomy of a Linux DNS Lookup - Part II.md rename to published/201808/20180618 Anatomy of a Linux DNS Lookup - Part II.md diff --git a/published/20180619 How to reset, revert, and return to previous states in Git.md b/published/201808/20180619 How to reset, revert, and return to previous states in Git.md similarity index 100% rename from published/20180619 How to reset, revert, and return to previous states in Git.md rename to published/201808/20180619 How to reset, revert, and return to previous states in Git.md diff --git a/published/20180621 Bitcoin is a Cult - Adam Caudill.md b/published/201808/20180621 Bitcoin is a Cult - Adam Caudill.md similarity index 100% rename from published/20180621 Bitcoin is a Cult - Adam Caudill.md rename to published/201808/20180621 Bitcoin is a Cult - Adam Caudill.md diff --git a/published/20180622 How to Check Disk Space on Linux from the Command line.md b/published/201808/20180622 How to Check Disk Space on Linux from the Command line.md similarity index 100% rename from published/20180622 How to Check Disk Space on Linux from the Command line.md rename to published/201808/20180622 How to Check Disk Space on Linux from the Command line.md diff --git a/published/20180623 Don-t Install Yaourt- Use These Alternatives for AUR in Arch Linux.md b/published/201808/20180623 Don-t Install Yaourt- Use These Alternatives for AUR in Arch Linux.md similarity index 100% rename from published/20180623 Don-t Install Yaourt- Use These Alternatives for AUR in Arch Linux.md rename to published/201808/20180623 Don-t Install Yaourt- Use These Alternatives for AUR in Arch Linux.md diff --git a/published/20180623 Intercepting and Emulating Linux System Calls with Ptrace - null program.md b/published/201808/20180623 Intercepting and Emulating Linux System Calls with Ptrace - null program.md similarity index 100% rename from published/20180623 Intercepting and Emulating Linux System Calls with Ptrace - null program.md rename to published/201808/20180623 Intercepting and Emulating Linux System Calls with Ptrace - null program.md diff --git a/published/20180627 CIP- Keeping the Lights On with Linux.md b/published/201808/20180627 CIP- Keeping the Lights On with Linux.md similarity index 100% rename from published/20180627 CIP- Keeping the Lights On with Linux.md rename to published/201808/20180627 CIP- Keeping the Lights On with Linux.md diff --git a/published/20180702 How to edit Adobe InDesign files with Scribus and Gedit.md b/published/201808/20180702 How to edit Adobe InDesign files with Scribus and Gedit.md similarity index 100% rename from published/20180702 How to edit Adobe InDesign files with Scribus and Gedit.md rename to published/201808/20180702 How to edit Adobe InDesign files with Scribus and Gedit.md diff --git a/published/20180703 How to make a career move from proprietary to open source technology.md b/published/201808/20180703 How to make a career move from proprietary to open source technology.md similarity index 100% rename from published/20180703 How to make a career move from proprietary to open source technology.md rename to published/201808/20180703 How to make a career move from proprietary to open source technology.md diff --git a/published/20180703 Why is Arch Linux So Challenging and What are Its Pros - Cons.md b/published/201808/20180703 Why is Arch Linux So Challenging and What are Its Pros - Cons.md similarity index 100% rename from published/20180703 Why is Arch Linux So Challenging and What are Its Pros - Cons.md rename to published/201808/20180703 Why is Arch Linux So Challenging and What are Its Pros - Cons.md diff --git a/published/20180705 Testing Node.js in 2018.md b/published/201808/20180705 Testing Node.js in 2018.md similarity index 100% rename from published/20180705 Testing Node.js in 2018.md rename to published/201808/20180705 Testing Node.js in 2018.md diff --git a/published/20180706 Revisiting wallabag, an open source alternative to Instapaper.md b/published/201808/20180706 Revisiting wallabag, an open source alternative to Instapaper.md similarity index 100% rename from published/20180706 Revisiting wallabag, an open source alternative to Instapaper.md rename to published/201808/20180706 Revisiting wallabag, an open source alternative to Instapaper.md diff --git a/published/20180709 A sysadmin-s guide to network management.md b/published/201808/20180709 A sysadmin-s guide to network management.md similarity index 100% rename from published/20180709 A sysadmin-s guide to network management.md rename to published/201808/20180709 A sysadmin-s guide to network management.md diff --git a/published/20180710 4 Essential and Practical Usage of Cut Command in Linux.md b/published/201808/20180710 4 Essential and Practical Usage of Cut Command in Linux.md similarity index 100% rename from published/20180710 4 Essential and Practical Usage of Cut Command in Linux.md rename to published/201808/20180710 4 Essential and Practical Usage of Cut Command in Linux.md diff --git a/published/20180710 How I Fully Quit Google And You Can Too.md b/published/201808/20180710 How I Fully Quit Google And You Can Too.md similarity index 100% rename from published/20180710 How I Fully Quit Google And You Can Too.md rename to published/201808/20180710 How I Fully Quit Google And You Can Too.md diff --git a/published/20180711 Javascript Framework Comparison with Examples React Vue Hyperapp.md b/published/201808/20180711 Javascript Framework Comparison with Examples React Vue Hyperapp.md similarity index 100% rename from published/20180711 Javascript Framework Comparison with Examples React Vue Hyperapp.md rename to published/201808/20180711 Javascript Framework Comparison with Examples React Vue Hyperapp.md diff --git a/published/20180711 netdev-day-1--ipsec.md b/published/201808/20180711 netdev-day-1--ipsec.md similarity index 100% rename from published/20180711 netdev-day-1--ipsec.md rename to published/201808/20180711 netdev-day-1--ipsec.md diff --git a/published/20180712 A sysadmin-s guide to SELinux- 42 answers to the big questions.md b/published/201808/20180712 A sysadmin-s guide to SELinux- 42 answers to the big questions.md similarity index 100% rename from published/20180712 A sysadmin-s guide to SELinux- 42 answers to the big questions.md rename to published/201808/20180712 A sysadmin-s guide to SELinux- 42 answers to the big questions.md diff --git a/published/20180712 Slices from the ground up.md b/published/201808/20180712 Slices from the ground up.md similarity index 100% rename from published/20180712 Slices from the ground up.md rename to published/201808/20180712 Slices from the ground up.md diff --git a/published/20180712 netdev day 2 moving away from as fast as possible in networking code.md b/published/201808/20180712 netdev day 2 moving away from as fast as possible in networking code.md similarity index 100% rename from published/20180712 netdev day 2 moving away from as fast as possible in networking code.md rename to published/201808/20180712 netdev day 2 moving away from as fast as possible in networking code.md diff --git a/published/20180716 3 cool productivity apps for Fedora 28.md b/published/201808/20180716 3 cool productivity apps for Fedora 28.md similarity index 100% rename from published/20180716 3 cool productivity apps for Fedora 28.md rename to published/201808/20180716 3 cool productivity apps for Fedora 28.md diff --git a/published/20180719 Incomplete Path Expansion (Completion) For Bash.md b/published/201808/20180719 Incomplete Path Expansion (Completion) For Bash.md similarity index 100% rename from published/20180719 Incomplete Path Expansion (Completion) For Bash.md rename to published/201808/20180719 Incomplete Path Expansion (Completion) For Bash.md diff --git a/published/20180720 3 Methods to List All The Users in Linux System.md b/published/201808/20180720 3 Methods to List All The Users in Linux System.md similarity index 100% rename from published/20180720 3 Methods to List All The Users in Linux System.md rename to published/201808/20180720 3 Methods to List All The Users in Linux System.md diff --git a/published/20180720 4 cool new projects to try in COPR for July 2018.md b/published/201808/20180720 4 cool new projects to try in COPR for July 2018.md similarity index 100% rename from published/20180720 4 cool new projects to try in COPR for July 2018.md rename to published/201808/20180720 4 cool new projects to try in COPR for July 2018.md diff --git a/published/20180720 Convert video using Handbrake.md b/published/201808/20180720 Convert video using Handbrake.md similarity index 100% rename from published/20180720 Convert video using Handbrake.md rename to published/201808/20180720 Convert video using Handbrake.md diff --git a/published/20180723 4 open source media conversion tools for the Linux desktop.md b/published/201808/20180723 4 open source media conversion tools for the Linux desktop.md similarity index 100% rename from published/20180723 4 open source media conversion tools for the Linux desktop.md rename to published/201808/20180723 4 open source media conversion tools for the Linux desktop.md diff --git a/published/20180724 Textricator- Data extraction made simple.md b/published/201808/20180724 Textricator- Data extraction made simple.md similarity index 100% rename from published/20180724 Textricator- Data extraction made simple.md rename to published/201808/20180724 Textricator- Data extraction made simple.md diff --git a/published/20180726 4 cool apps for your terminal.md b/published/201808/20180726 4 cool apps for your terminal.md similarity index 100% rename from published/20180726 4 cool apps for your terminal.md rename to published/201808/20180726 4 cool apps for your terminal.md diff --git a/published/20180726 The evolution of package managers.md b/published/201808/20180726 The evolution of package managers.md similarity index 100% rename from published/20180726 The evolution of package managers.md rename to published/201808/20180726 The evolution of package managers.md diff --git a/published/20180727 Three Graphical Clients for Git on Linux.md b/published/201808/20180727 Three Graphical Clients for Git on Linux.md similarity index 100% rename from published/20180727 Three Graphical Clients for Git on Linux.md rename to published/201808/20180727 Three Graphical Clients for Git on Linux.md diff --git a/published/20180730 Open Source Networking Jobs- A Hotbed of Innovation and Opportunities.md b/published/201808/20180730 Open Source Networking Jobs- A Hotbed of Innovation and Opportunities.md similarity index 100% rename from published/20180730 Open Source Networking Jobs- A Hotbed of Innovation and Opportunities.md rename to published/201808/20180730 Open Source Networking Jobs- A Hotbed of Innovation and Opportunities.md diff --git a/published/20180731 A sysadmin-s guide to Bash.md b/published/201808/20180731 A sysadmin-s guide to Bash.md similarity index 100% rename from published/20180731 A sysadmin-s guide to Bash.md rename to published/201808/20180731 A sysadmin-s guide to Bash.md diff --git a/published/20180731 How To Use Pbcopy And Pbpaste Commands On Linux.md b/published/201808/20180731 How To Use Pbcopy And Pbpaste Commands On Linux.md similarity index 100% rename from published/20180731 How To Use Pbcopy And Pbpaste Commands On Linux.md rename to published/201808/20180731 How To Use Pbcopy And Pbpaste Commands On Linux.md diff --git a/published/20180801 Cross-Site Request Forgery.md b/published/201808/20180801 Cross-Site Request Forgery.md similarity index 100% rename from published/20180801 Cross-Site Request Forgery.md rename to published/201808/20180801 Cross-Site Request Forgery.md diff --git a/published/20180802 6 Easy Ways to Check User Name And Other Information in Linux.md b/published/201808/20180802 6 Easy Ways to Check User Name And Other Information in Linux.md similarity index 100% rename from published/20180802 6 Easy Ways to Check User Name And Other Information in Linux.md rename to published/201808/20180802 6 Easy Ways to Check User Name And Other Information in Linux.md diff --git a/published/20180802 Getting started with Mu, a Python editor for beginners.md b/published/201808/20180802 Getting started with Mu, a Python editor for beginners.md similarity index 100% rename from published/20180802 Getting started with Mu, a Python editor for beginners.md rename to published/201808/20180802 Getting started with Mu, a Python editor for beginners.md diff --git a/published/20180803 UNIX curiosities.md b/published/201808/20180803 UNIX curiosities.md similarity index 100% rename from published/20180803 UNIX curiosities.md rename to published/201808/20180803 UNIX curiosities.md diff --git a/published/20180803 What data is too risky for the cloud.md b/published/201808/20180803 What data is too risky for the cloud.md similarity index 100% rename from published/20180803 What data is too risky for the cloud.md rename to published/201808/20180803 What data is too risky for the cloud.md diff --git a/published/20180803 Why I still love Alpine for email at the Linux terminal.md b/published/201808/20180803 Why I still love Alpine for email at the Linux terminal.md similarity index 100% rename from published/20180803 Why I still love Alpine for email at the Linux terminal.md rename to published/201808/20180803 Why I still love Alpine for email at the Linux terminal.md diff --git a/published/20180806 A gawk script to convert smart quotes.md b/published/201808/20180806 A gawk script to convert smart quotes.md similarity index 100% rename from published/20180806 A gawk script to convert smart quotes.md rename to published/201808/20180806 A gawk script to convert smart quotes.md diff --git a/published/20180806 Learn Python programming the easy way with EduBlocks.md b/published/201808/20180806 Learn Python programming the easy way with EduBlocks.md similarity index 100% rename from published/20180806 Learn Python programming the easy way with EduBlocks.md rename to published/201808/20180806 Learn Python programming the easy way with EduBlocks.md diff --git a/published/20180806 What is CI-CD.md b/published/201808/20180806 What is CI-CD.md similarity index 100% rename from published/20180806 What is CI-CD.md rename to published/201808/20180806 What is CI-CD.md diff --git a/published/20180809 How To Switch Between Multiple PHP Versions In Ubuntu.md b/published/201808/20180809 How To Switch Between Multiple PHP Versions In Ubuntu.md similarity index 100% rename from published/20180809 How To Switch Between Multiple PHP Versions In Ubuntu.md rename to published/201808/20180809 How To Switch Between Multiple PHP Versions In Ubuntu.md diff --git a/published/20180810 Image creation applications for Fedora.md b/published/201808/20180810 Image creation applications for Fedora.md similarity index 100% rename from published/20180810 Image creation applications for Fedora.md rename to published/201808/20180810 Image creation applications for Fedora.md diff --git a/published/20180812 Ubuntu 18.04 Vs. Fedora 28.md b/published/201808/20180812 Ubuntu 18.04 Vs. Fedora 28.md similarity index 100% rename from published/20180812 Ubuntu 18.04 Vs. Fedora 28.md rename to published/201808/20180812 Ubuntu 18.04 Vs. Fedora 28.md diff --git a/published/20180813 Convert file systems with Fstransform.md b/published/201808/20180813 Convert file systems with Fstransform.md similarity index 100% rename from published/20180813 Convert file systems with Fstransform.md rename to published/201808/20180813 Convert file systems with Fstransform.md diff --git a/published/20180813 How To Switch Between Different Versions Of Commands In Linux.md b/published/201808/20180813 How To Switch Between Different Versions Of Commands In Linux.md similarity index 100% rename from published/20180813 How To Switch Between Different Versions Of Commands In Linux.md rename to published/201808/20180813 How To Switch Between Different Versions Of Commands In Linux.md diff --git a/published/20180813 How to display data in a human-friendly way on Linux.md b/published/201808/20180813 How to display data in a human-friendly way on Linux.md similarity index 100% rename from published/20180813 How to display data in a human-friendly way on Linux.md rename to published/201808/20180813 How to display data in a human-friendly way on Linux.md diff --git a/published/20180813 Tips for using the top command in Linux.md b/published/201808/20180813 Tips for using the top command in Linux.md similarity index 100% rename from published/20180813 Tips for using the top command in Linux.md rename to published/201808/20180813 Tips for using the top command in Linux.md diff --git a/published/20180814 How To Record Terminal Sessions As SVG Animations In Linux.md b/published/201808/20180814 How To Record Terminal Sessions As SVG Animations In Linux.md similarity index 100% rename from published/20180814 How To Record Terminal Sessions As SVG Animations In Linux.md rename to published/201808/20180814 How To Record Terminal Sessions As SVG Animations In Linux.md diff --git a/published/20180815 How the L1 Terminal Fault vulnerability affects Linux systems.md b/published/201808/20180815 How the L1 Terminal Fault vulnerability affects Linux systems.md similarity index 100% rename from published/20180815 How the L1 Terminal Fault vulnerability affects Linux systems.md rename to published/201808/20180815 How the L1 Terminal Fault vulnerability affects Linux systems.md diff --git a/published/20180819 How to define and use functions in Linux Shell Script.md b/published/201808/20180819 How to define and use functions in Linux Shell Script.md similarity index 100% rename from published/20180819 How to define and use functions in Linux Shell Script.md rename to published/201808/20180819 How to define and use functions in Linux Shell Script.md diff --git a/published/20180821 A Collection Of More Useful Unix Utilities.md b/published/201808/20180821 A Collection Of More Useful Unix Utilities.md similarity index 100% rename from published/20180821 A Collection Of More Useful Unix Utilities.md rename to published/201808/20180821 A Collection Of More Useful Unix Utilities.md From bcdcb7f655f8105dd3ff947766002aff7c44437d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 1 Sep 2018 21:32:21 +0800 Subject: [PATCH 017/455] PUB:20180706 Anatomy of a Linux DNS Lookup - Part III.md @pinewall https://linux.cn/article-9972-1.html --- .../20180706 Anatomy of a Linux DNS Lookup - Part III.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180706 Anatomy of a Linux DNS Lookup - Part III.md (100%) diff --git a/translated/tech/20180706 Anatomy of a Linux DNS Lookup - Part III.md b/published/20180706 Anatomy of a Linux DNS Lookup - Part III.md similarity index 100% rename from translated/tech/20180706 Anatomy of a Linux DNS Lookup - Part III.md rename to published/20180706 Anatomy of a Linux DNS Lookup - Part III.md From 3490325c52506165646fbefa0d479ba500ecb048 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 1 Sep 2018 22:03:08 +0800 Subject: [PATCH 018/455] PRF:20180427 An Official Introduction to the Go Compiler.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @stephenxs @pityonline 我斟酌再三,觉得应该将“pass”翻译出来,权衡之后选择了“环节”的译法。请两位考虑和讨论。 --- ...fficial Introduction to the Go Compiler.md | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/translated/tech/20180427 An Official Introduction to the Go Compiler.md b/translated/tech/20180427 An Official Introduction to the Go Compiler.md index 0110b78be1..aeb419daa2 100644 --- a/translated/tech/20180427 An Official Introduction to the Go Compiler.md +++ b/translated/tech/20180427 An Official Introduction to the Go Compiler.md @@ -1,63 +1,59 @@ Go 编译器介绍 ====== -> Copyright 2018 The Go Authors. All rights reserved. -> Use of this source code is governed by a BSD-style -> license that can be found in the LICENSE file. - `cmd/compile` 包含构成 Go 编译器主要的包。编译器在逻辑上可以被分为四个阶段,我们将简要介绍这几个阶段以及包含相应代码的包的列表。 在谈到编译器时,有时可能会听到前端front-end后端back-end这两个术语。粗略地说,这些对应于我们将在此列出的前两个和后两个阶段。第三个术语中间端middle-end通常指的是第二阶段执行的大部分工作。 请注意,`go/parser` 和 `go/types` 等 `go/*` 系列的包与编译器无关。由于编译器最初是用 C 编写的,所以这些 `go/*` 包被开发出来以便于能够写出和 `Go` 代码一起工作的工具,例如 `gofmt` 和 `vet`。 -需要澄清的是,名称 “gc” 代表 “Go 编译器”,与大写 GC 无关,后者代表垃圾收集garbage collection。 +需要澄清的是,名称 “gc” 代表 “Go 编译器Go compiler”,与大写 GC 无关,后者代表垃圾收集garbage collection。 -### 1. 解析 +### 1、 解析 * `cmd/compile/internal/syntax`(词法分析器lexer解析器parser语法树syntax tree) -在编译的第一阶段,源代码被标记化(词法分析),解析(语法分析),并为每个源文件构造语法树(译注:这里标记指 token,它是一组预定义的、能够识别的字符串,通常由名字和值构成,其中名字一般是词法的类别,如标识符、关键字、分隔符、操作符、文字和注释等;语法树,以及下文提到的抽象语法树Abstract Syntax Tree(AST),是指用树来表达程序设计语言的语法结构,通常叶子节点是操作数,其它节点是操作码)。 +在编译的第一阶段,源代码被标记化(词法分析)、解析(语法分析),并为每个源文件构造语法树(LCTT 译注:这里标记指 token,它是一组预定义的、能够识别的字符串,通常由名字和值构成,其中名字一般是词法的类别,如标识符、关键字、分隔符、操作符、文字和注释等;语法树,以及下文提到的抽象语法树Abstract Syntax Tree(AST),是指用树来表达程序设计语言的语法结构,通常叶子节点是操作数,其它节点是操作码)。 每个语法树都是相应源文件的确切表示,其中节点对应于源文件的各种元素,例如表达式、声明和语句。语法树还包括位置信息,用于错误报告和创建调试信息。 -### 2. 类型检查和 AST 变形 +### 2、 类型检查和 AST 变换 -* `cmd/compile/internal/gc`(创建编译器 AST,类型检查type-checkingAST 变形AST transformation) +* `cmd/compile/internal/gc`(创建编译器 AST,类型检查type-checkingAST 变换AST transformation) gc 包中包含一个继承自(早期)C 语言实现的版本的 AST 定义。所有代码都是基于它编写的,所以 gc 包必须做的第一件事就是将 syntax 包(定义)的语法树转换为编译器的 AST 表示法。这个额外步骤可能会在将来重构。 然后对 AST 进行类型检查。第一步是名字解析和类型推断,它们确定哪个对象属于哪个标识符,以及每个表达式具有的类型。类型检查包括特定的额外检查,例如“声明但未使用”以及确定函数是否会终止。 -特定转换也基于 AST 完成。一些节点被基于类型信息而细化,例如把字符串加法从算术加法的节点类型中拆分出来。其它一些例子是死代码消除dead code elimination函数调用内联function call inlining逃逸分析escape analysis(译注:逃逸分析是一种分析指针有效范围的方法)。 +特定变换也基于 AST 完成。一些节点被基于类型信息而细化,例如把字符串加法从算术加法的节点类型中拆分出来。其它一些例子是死代码消除dead code elimination函数调用内联function call inlining逃逸分析escape analysis(LCTT 译注:逃逸分析是一种分析指针有效范围的方法)。 -### 3. 通用 SSA +### 3、 通用 SSA * `cmd/compile/internal/gc`(转换成 SSA) -* `cmd/compile/internal/ssa`(SSA 相关的 pass 和规则) +* `cmd/compile/internal/ssa`(SSA 相关的环节pass和规则) -(译注:许多常见高级语言的编译器无法通过一次扫描源代码或 AST 就完成所有编译工作,取而代之的做法是多次扫描,每次完成一部分工作,并将输出结果作为下次扫描的输入,直到最终产生目标代码。这里每次扫描称作一遍 pass;最后一遍 pass 之前所有的 pass 得到的结果都可称作中间表示法,本文中 AST、SSA 等都属于中间表示法。SSA,静态单赋值形式,是中间表示法的一种性质,它要求每个变量只被赋值一次且在使用前被定义)。 +(LCTT 译注:许多常见高级语言的编译器无法通过一次扫描源代码或 AST 就完成所有编译工作,取而代之的做法是多次扫描,每次完成一部分工作,并将输出结果作为下次扫描的输入,直到最终产生目标代码。这里每次扫描称作一个环节pass;最后一个环节之前所有的环节得到的结果都可称作中间表示法,本文中 AST、SSA 等都属于中间表示法。SSA,静态单赋值形式,是中间表示法的一种性质,它要求每个变量只被赋值一次且在使用前被定义)。 在此阶段,AST 将被转换为静态单赋值Static Single Assignment(SSA)形式,这是一种具有特定属性的低级中间表示法intermediate representation,可以更轻松地实现优化并最终从它生成机器码。 -在这个转换过程中,将完成内置函数function intrinsics的处理。这些是特殊的函数,编译器被告知逐个分析这些函数并决定是否用深度优化的代码替换它们(译注:内置函数指由语言本身定义的函数,通常编译器的处理方式是使用相应实现函数的指令序列代替对函数的调用指令,有点类似内联函数)。 +在这个转换过程中,将完成内置函数function intrinsics的处理。这些是特殊的函数,编译器被告知逐个分析这些函数并决定是否用深度优化的代码替换它们(LCTT 译注:内置函数指由语言本身定义的函数,通常编译器的处理方式是使用相应实现函数的指令序列代替对函数的调用指令,有点类似内联函数)。 -在 AST 转化成 SSA 的过程中,特定节点也被低级化为更简单的组件,以便于剩余的编译阶段可以基于它们工作。例如,内建的拷贝被替换为内存移动,range 循环被改写为 for 循环。由于历史原因,目前这里面有些在转化到 SSA 之前发生,但长期计划则是把它们都移到这里(转化 SSA)。 +在 AST 转化成 SSA 的过程中,特定节点也被低级化为更简单的组件,以便于剩余的编译阶段可以基于它们工作。例如,内建的拷贝被替换为内存移动,`range` 循环被改写为 `for` 循环。由于历史原因,目前这里面有些在转化到 SSA 之前发生,但长期计划则是把它们都移到这里(转化 SSA)。 -然后,一系列机器无关的规则和 pass 会被执行。这些并不考虑特定计算机体系结构,因此对所有 `GOARCH` 变量的值都会运行。 +然后,一系列机器无关的规则和编译环节会被执行。这些并不考虑特定计算机体系结构,因此对所有 `GOARCH` 变量的值都会运行。 -这类通用 pass 的一些例子包括,死代码消除,移除不必要的空值检查,以及移除无用的分支等。通用改写规则主要考虑表达式,例如将一些表达式替换为常量,优化乘法和浮点操作。 +这类通用的编译环节的一些例子包括,死代码消除、移除不必要的空值检查,以及移除无用的分支等。通用改写规则主要考虑表达式,例如将一些表达式替换为常量,优化乘法和浮点操作。 -### 4. 生成机器码 +### 4、 生成机器码 * `cmd/compile/internal/ssa`(SSA 低级化和架构特定的 pass) * `cmd/internal/obj`(机器码生成) -编译器中机器相关的阶段开始于“低级”的 pass,该阶段将通用变量改写为它们的特定的机器码形式。例如,在 amd64 架构中操作数可以在内存中操作,这样许多加载-存储load-store操作就可以被合并。 +编译器中机器相关的阶段开始于“低级”的编译环节,该阶段将通用变量改写为它们的特定的机器码形式。例如,在 amd64 架构中操作数可以在内存中操作,这样许多加载-存储load-store操作就可以被合并。 -注意低级的 pass 运行所有机器特定的重写规则,因此当前它也应用了大量优化。 +注意低级的编译环节运行所有机器特定的重写规则,因此当前它也应用了大量优化。 -一旦 SSA 被“低级化”并且更具体地针对目标体系结构,就要运行最终代码优化的 pass 了。这包含了另外一个死代码消除的 pass,它将变量移动到更靠近它们使用的地方,移除从来没有被读过的局部变量,以及寄存器register分配。 +一旦 SSA 被“低级化”并且更具体地针对目标体系结构,就要运行最终代码优化的编译环节了。这包含了另外一个死代码消除的环节,它将变量移动到更靠近它们使用的地方,移除从来没有被读过的局部变量,以及寄存器register分配。 本步骤中完成的其它重要工作包括堆栈布局stack frame layout,它将堆栈偏移位置分配给局部变量,以及指针活性分析pointer liveness analysis,后者计算每个垃圾收集安全点上的哪些堆栈上的指针仍然是活动的。 @@ -71,9 +67,9 @@ gc 包中包含一个继承自(早期)C 语言实现的版本的 AST 定义 via: https://github.com/golang/go/blob/master/src/cmd/compile/README.md -作者:[mvdan][a] +作者:[mvdan][a] 译者:[stephenxs](https://github.com/stephenxs) -校对:[pityonline](https://github.com/pityonline) +校对:[pityonline](https://github.com/pityonline), [wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 119ea765c25cca48aa9460f0beea1bdde4dc111c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 1 Sep 2018 23:00:32 +0800 Subject: [PATCH 019/455] =?UTF-8?q?PRF:20170709=20The=20Extensive=20Guide?= =?UTF-8?q?=20to=20Creating=20Streams=20in=C2=A0RxJS.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @BriFuture 翻译的很好。有部分地方我将英文翻译为中文了,对于这种前沿领域变化很快的部分,翻译跟不上技术变化。 --- ...nsive Guide to Creating Streams in RxJS.md | 284 +++++------------- 1 file changed, 72 insertions(+), 212 deletions(-) diff --git a/translated/tech/20170709 The Extensive Guide to Creating Streams in RxJS.md b/translated/tech/20170709 The Extensive Guide to Creating Streams in RxJS.md index 66b0e920e9..8dbb42e640 100644 --- a/translated/tech/20170709 The Extensive Guide to Creating Streams in RxJS.md +++ b/translated/tech/20170709 The Extensive Guide to Creating Streams in RxJS.md @@ -1,22 +1,19 @@ -在 RxJS 中创建流的延伸教程 -============================================================ +全面教程:在 RxJS 中创建流 +================================ ![](https://cdn-images-1.medium.com/max/900/1*hj8mGnl5tM_lAlx5_vqS-Q.jpeg) -对大多数开发者来说,RxJS 是以库的形式与之接触,就像 Angular。一些函数会返回流,要使用它们就得把注意力放在操作符上。 +对大多数开发者来说,与 RxJS 的初次接触是通过库的形式,就像 Angular。一些函数会返回stream,要使用它们就得把注意力放在操作符上。 有些时候,混用响应式和非响应式代码似乎很有用。然后大家就开始热衷流的创造。不论是在编写异步代码或者是数据处理时,流都是一个不错的方案。 RxJS 提供很多方式来创建流。不管你遇到的是什么情况,都会有一个完美的创建流的方式。你可能根本用不上它们,但了解它们可以节省你的时间,让你少码一些代码。 -我把所有可能的方法,按它们的主要目的,分放在四个目录中: +我把所有可能的方法,按它们的主要目的,放在四个分类当中: * 流式化现有数据 - * 生成数据 - -* 使用现有 APIs 进行交互 - +* 使用现有 API 进行交互 * 选择现有的流,并结合起来 注意:示例用的是 RxJS 6,可能会以前的版本有所不同。已知的区别是你导入函数的方式不同了。 @@ -25,9 +22,7 @@ RxJS 6 ``` import {of, from} from 'rxjs'; -``` -``` of(...); from(...); ``` @@ -38,36 +33,24 @@ RxJS < 6 import { Observable } from 'rxjs/Observable'; import 'rxjs/add/observable/of'; import 'rxjs/add/observable/from'; -``` -``` Observable.of(...); Observable.from(...); -``` -``` -//or -``` +//或 -``` import { of } from 'rxjs/observable/of'; import { from } from 'rxjs/observable/from'; -``` -``` of(...); from(...); ``` 流的图示中的标记: -* | 表示流结束了 - -* X 表示流出现错误并被终结 - -* … 表示流的走向不定 - -* * * +* `|` 表示流结束了 +* `X` 表示流出现错误并被终结 +* `...` 表示流的走向不定 ### 流式化已有数据 @@ -75,7 +58,7 @@ from(...); #### of -如果只有一个或者一些不同的元素,使用 _of_ : +如果只有一个或者一些不同的元素,使用 `of`: ``` of(1,2,3) @@ -89,13 +72,11 @@ of(1,2,3) #### from -如果有一个数组或者 _可迭代的_ 对象,而且你想要其中的所有元素发送到流中,使用 _from_。你也可以用它来把一个 promise 对象变成可观测的。 +如果有一个数组或者 _可迭代的对象_ ,而且你想要其中的所有元素发送到流中,使用 `from`。你也可以用它来把一个 promise 对象变成可观测的。 ``` const foo = [1,2,3]; -``` -``` from(foo) .subscribe(); ``` @@ -111,9 +92,7 @@ from(foo) ``` const foo = { a: 1, b: 2}; -``` -``` pairs(foo) .subscribe(); ``` @@ -125,19 +104,16 @@ pairs(foo) #### 那么其他的数据结构呢? -也许你的数据存储在自定义的结构中,而它又没有实现 _Iterable_ 接口,又或者说你的结构是递归的,树状的。也许下面某种选择适合这些情况: +也许你的数据存储在自定义的结构中,而它又没有实现 _可迭代的对象_ 接口,又或者说你的结构是递归的、树状的。也许下面某种选择适合这些情况: -* 先将数据提取到数组里 +1. 先将数据提取到数组里 +2. 使用下一节将会讲到的 `generate` 函数,遍历所有数据 +3. 创建一个自定义流(见下一节) +4. 创建一个迭代器 -* 使用下一节将会讲到的 _generate_ 函数,遍历所有数据 +稍后会讲到选项 2 和 3 ,因此这里的重点是创建一个迭代器。我们可以对一个 _可迭代的对象_ 调用 `from` 创建一个流。 _可迭代的对象_ 是一个对象,可以产生一个迭代器(如果你对细节感兴趣,参考 [这篇 mdn 文章][6])。 -* 创建一个自定义流(见下一节) - -* 创建一个迭代器 - -稍后会讲到选项 2 和 3 ,因此这里的重点是创建一个迭代器。我们可以对一个 _iterable_ 对象调用 _from_ 创建一个流。 _iterable_ 是一个对象,可以产生一个迭代器(如果你对细节感兴趣,参考 [这篇 mdn 文章][6])。 - -创建一个迭代器的简单方式是 [generator function][7]。当你调用一个生成函数(generator function)时,它返回一个对象,该对象同时遵循 _iterable_ 接口和 _iterator_ 接口。 +创建一个迭代器的简单方式是 [生成函数][7]generator function。当你调用一个生成函数时,它返回一个对象,该对象同时遵循 _可迭代的对象_ 接口和 _迭代器_ 接口。 ``` // 自定义的数据结构 @@ -147,23 +123,17 @@ class List { get size() ... ... } -``` -``` function* listIterator(list) { for (let i = 0; i console.log("foo"); // 5 秒后打印 foo @@ -229,7 +195,7 @@ interval(10000).pipe( 这段代码每 10 秒获取一次数据,更新屏幕。 -#### generate +#### 生成(`generate `) 这是个更加复杂的函数,允许你发送一系列任意类型的对象。它有一些重载,这里你看到的是最有意思的部分: @@ -246,15 +212,13 @@ generate( // 1 2 4 8 | ``` -你也可以用它来迭代值,如果一个结构没有实现 _Iterable_ 接口。我们用前面的 list 例子来进行演示: +你也可以用它来迭代值,如果一个结构没有实现 _可迭代的对象_ 接口。我们用前面的列表例子来进行演示: ``` const myList = new List(); myList.add(1); myList.add(3); -``` -``` generate( 0, // 从这个值开始 i => i < list.size, // 条件:发送数据,直到遍历完整个列表 @@ -268,15 +232,13 @@ generate( // 1 3 | ``` -如你所见,我添加了另一个参数:选择器(selector)。它和 _map_ 操作符作用类似,将生成的值转换为更有用的东西。 - -* * * +如你所见,我添加了另一个参数:选择器。它和 `map` 操作符作用类似,将生成的值转换为更有用的东西。 ### 空的流 -有时候你要传递或返回一个不用发送任何数据的流。有三个函数分别用于不同的情况。你可以给这三个函数传递调度器。_empty_ 和 _throwError_ 接收一个调度器参数。 +有时候你要传递或返回一个不用发送任何数据的流。有三个函数分别用于不同的情况。你可以给这三个函数传递调度器。`empty` 和 `throwError` 接收一个调度器参数。 -#### empty +#### `empty` 创建一个空的流,一个值也不发送。 @@ -290,7 +252,7 @@ empty() // | ``` -#### never +#### `never` 创建一个永远不会结束的流,仍然不发送值。 @@ -304,7 +266,7 @@ never() // ... ``` -#### throwError +#### `throwError` 创建一个流,流出现错误,不发送数据。 @@ -318,15 +280,13 @@ throwError('error') // X ``` -* * * - ### 挂钩已有的 API 不是所有的库和所有你之前写的代码使用或者支持流。幸运的是 RxJS 提供函数用来桥接非响应式和响应式代码。这一节仅仅讨论 RxJS 为桥接代码提供的模版。 -你可能还对这篇出自 [Ben Lesh][9] 的 [延伸阅读][8] 感兴趣,这篇文章讲了几乎所有能与 promises 交互操作的方式。 +你可能还对这篇出自 [Ben Lesh][9] 的 [全面的文章][8] 感兴趣,这篇文章讲了几乎所有能与 promises 交互操作的方式。 -#### from +#### `from` 我们已经用过它,把它列在这里是因为,它可以封装一个含有 observable 对象的 promise 对象。 @@ -346,9 +306,7 @@ fromEvent 为 DOM 元素添加一个事件监听器,我确定你知道这个 ``` const element = $('#fooButton'); // 从 DOM 元素中创建一个 jQuery 对象 -``` -``` from(element, 'click') .subscribe(); ``` @@ -367,31 +325,25 @@ from(document, 'click') .subscribe(); ``` -这告诉 RxJS 我们想要监听 document 中的点击事件。在提交过程中,RxJS 发现 document 是一个 _EventTarget_ 类型,因此它可以调用它的 _addEventListener_ 方法。如果我们传入的是一个 jQuery 对象而非 document,那么 RxJs 知道它得调用 _on_ 方法。 +这告诉 RxJS 我们想要监听 document 中的点击事件。在提交过程中,RxJS 发现 document 是一个 _EventTarget_ 类型,因此它可以调用它的 `addEventListener` 方法。如果我们传入的是一个 jQuery 对象而非 document,那么 RxJs 知道它得调用 _on_ 方法。 -这个例子用的是 _fromEventPattern_,和 _fromEvent_ 的工作基本上一样: +这个例子用的是 _fromEventPattern_ ,和 _fromEvent_ 的工作基本上一样: ``` function addClickHandler(handler) { document.addEventListener('click', handler); } -``` -``` function removeClickHandler(handler) { document.removeEventListener('click', handler); } -``` -``` fromEventPattern( addClickHandler, removeClickHandler, ) .subscribe(console.log); -``` -``` // 等效于 fromEvent(document, 'click') ``` @@ -402,49 +354,37 @@ RxJS 自动创建实际的监听器( _handler_ )你的工作是添加或者 ``` const listeners = []; -``` -``` class Foo { registerListener(listener) { listeners.push(listener); } -``` -``` emit(value) { listeners.forEach(listener => listener(value)); } } -``` -``` const foo = new Foo(); -``` -``` fromEventPattern(listener => foo.registerListener(listener)) .subscribe(); -``` -``` foo.emit(1); ``` ``` -// Produces +// 结果 // 1 ... ``` -当我们调用 foo.emit(1) 时,RxJS 中的监听器将被调用,然后它就能把值发送到流中。 +当我们调用 `foo.emit(1)` 时,RxJS 中的监听器将被调用,然后它就能把值发送到流中。 你也可以用它来监听多个事件类型,或者结合所有可以通过回调进行通讯的 API,例如,WebWorker API: ``` const myWorker = new Worker('worker.js'); -``` -``` fromEventPattern( handler => { myWorker.onmessage = handler }, handler => { myWorker.onmessage = undefined } @@ -465,20 +405,14 @@ fromEventPattern( function foo(value, callback) { callback(value); } -``` -``` // 没有流 foo(1, console.log); //prints 1 in the console -``` -``` // 有流 const reactiveFoo = bindCallback(foo); // 当我们调用 reactiveFoo 时,它返回一个 observable 对象 -``` -``` reactiveFoo(1) .subscribe(console.log); // 在控制台打印 1 ``` @@ -494,51 +428,39 @@ reactiveFoo(1) ``` import { webSocket } from 'rxjs/webSocket'; -``` -``` let socket$ = webSocket('ws://localhost:8081'); -``` -``` // 接收消息 socket$.subscribe( (msg) => console.log('message received: ' + msg), (err) => console.log(err), () => console.log('complete') * ); -``` -``` // 发送消息 socket$.next(JSON.stringify({ op: 'hello' })); ``` -把 websocket 功能添加到你的应用中真的很简单。_websocket_ 创建一个 subject。这意味着你可以订阅它,通过调用 _next_ 来获得消息和发送消息。 +把 websocket 功能添加到你的应用中真的很简单。_websocket_ 创建一个 subject。这意味着你可以订阅它,通过调用 `next` 来获得消息和发送消息。 #### ajax -如你所知:类似于 websocket,提供 AJAX 查询的功能。你可能用了一个带有 AJAX 功能的库或者框架。或者你没有用,那么我建议使用 fetch(或者必要的话用 polyfill),把返回的 promise 封装到一个 observable 对象中(参考稍后会讲到的 _defer_ 函数)。 +如你所知:类似于 websocket,提供 AJAX 查询的功能。你可能用了一个带有 AJAX 功能的库或者框架。或者你没有用,那么我建议使用 fetch(或者必要的话用 polyfill),把返回的 promise 封装到一个 observable 对象中(参考稍后会讲到的 `defer` 函数)。 -* * * - -### Custom Streams +### 定制流 有时候已有的函数用起来并不是足够灵活。或者你需要对订阅有更强的控制。 -#### Subject +#### 主题(`Subject`) -subject 是一个特殊的对象,它使得你的能够把数据发送到流中,并且能够控制数据。subject 本身就是一个 observable 对象,但如果你想要把流暴露给其它代码,建议你使用 _asObservable_ 方法。这样你就不能意外调用原始方法。 +`Subject` 是一个特殊的对象,它使得你的能够把数据发送到流中,并且能够控制数据。`Subject` 本身就是一个可观察对象,但如果你想要把流暴露给其它代码,建议你使用 `asObservable` 方法。这样你就不能意外调用原始方法。 ``` const subject = new Subject(); const observable = subject.asObservable(); -``` -``` observable.subscribe(); -``` -``` subject.next(1); subject.next(2); subject.complete(); @@ -554,17 +476,11 @@ subject.complete(); ``` const subject = new Subject(); const observable = subject.asObservable(); -``` -``` subject.next(1); -``` -``` observable.subscribe(console.log); -``` -``` subject.next(2); subject.complete(); ``` @@ -574,20 +490,16 @@ subject.complete(); // 2 ``` -除了常规的 subject,RxJS 还提供了三种特殊的版本。 +除了常规的 `Subject`,RxJS 还提供了三种特殊的版本。 -_AsyncSubject_ 在结束后只发送最后的一个值。 +`AsyncSubject` 在结束后只发送最后的一个值。 ``` const subject = new AsyncSubject(); const observable = subject.asObservable(); -``` -``` observable.subscribe(console.log); -``` -``` subject.next(1); subject.next(2); subject.complete(); @@ -598,18 +510,14 @@ subject.complete(); // 2 ``` -_BehaviorSubject_ 使得你能够提供一个(默认的)值,如果当前没有其它值发送的话,这个值会被发送给每个订阅者。否则订阅者收到最后一个发送的值。 +`BehaviorSubject` 使得你能够提供一个(默认的)值,如果当前没有其它值发送的话,这个值会被发送给每个订阅者。否则订阅者收到最后一个发送的值。 ``` const subject = new BehaviorSubject(1); const observable = subject.asObservable(); -``` -``` const subscription1 = observable.subscribe(console.log); -``` -``` subject.next(2); subscription1.unsubscribe(); ``` @@ -622,29 +530,21 @@ subscription1.unsubscribe(); ``` const subscription2 = observable.subscribe(console.log); -``` -``` // 输出 // 2 ``` -The _ReplaySubject_ 存储一定数量、或一定时间或所有的发送过的值。所有新的订阅者将会获得所有存储了的值。 +`ReplaySubject` 存储一定数量、或一定时间或所有的发送过的值。所有新的订阅者将会获得所有存储了的值。 ``` const subject = new ReplaySubject(); const observable = subject.asObservable(); -``` -``` subject.next(1); -``` -``` observable.subscribe(console.log); -``` -``` subject.next(2); subject.complete(); ``` @@ -655,11 +555,11 @@ subject.complete(); // 2 ``` -你可以在 [ReactiveX documentation][10](它提供了一些其它的连接) 里面找到更多关于 subjects 的信息。[Ben Lesh][11] 在 [On The Subject Of Subjects][12] 上面提供了一些关于 subjects 的理解,[Nicholas Jamieson][13] 在 [in RxJS: Understanding Subjects][14] 上也提供了一些理解。 +你可以在 [ReactiveX 文档][10](它提供了一些其它的连接) 里面找到更多关于 `Subject` 的信息。[Ben Lesh][11] 在 [On The Subject Of Subjects][12] 上面提供了一些关于 `Subject` 的理解,[Nicholas Jamieson][13] 在 [in RxJS: Understanding Subjects][14] 上也提供了一些理解。 -#### Observable +#### 可观察对象 -你可以简单地用 new 操作符创建一个 observable 对象。通过你传入的函数,你可以控制流,只要有人订阅了或者它接收到一个可以当成 subject 使用的 observer,这个函数就会被调用,比如,调用 next,complet 和 error。 +你可以简单地用 new 操作符创建一个可观察对象。通过你传入的函数,你可以控制流,只要有人订阅了或者它接收到一个可以当成 `Subject` 使用的观察者,这个函数就会被调用,比如,调用 `next`、`complet` 和 `error`。 让我们回顾一下列表示例: @@ -667,16 +567,12 @@ subject.complete(); const myList = new List(); myList.add(1); myList.add(3); -``` -``` new Observable(observer => { for (let i = 0; i { // 1 3 | ``` -这个函数可以返回一个 unsubcribe 函数,当有订阅者取消订阅时这个函数就会被调用。你可以用它来清楚或者执行一些收尾操作。 +这个函数可以返回一个 `unsubcribe` 函数,当有订阅者取消订阅时这个函数就会被调用。你可以用它来清楚或者执行一些收尾操作。 ``` new Observable(observer => { // 流式化 -``` -``` return () => { //clean up }; @@ -702,20 +596,18 @@ new Observable(observer => { .subscribe(); ``` -#### 继承 Observable +#### 继承可观察对象 -在有可用的操作符前,这是一种实现自定义操作符的方式。RxJS 在内部扩展了 _Observable_。_Subject_ 就是一个例子,另一个是 _publisher_ 操作符。它返回一个 _ConnectableObservable_ 对象,该对象提供额外的方法 _connect_。 +在有可用的操作符前,这是一种实现自定义操作符的方式。RxJS 在内部扩展了 _可观察对象_ 。`Subject` 就是一个例子,另一个是 `publisher` 操作符。它返回一个 `ConnectableObservable` 对象,该对象提供额外的方法 `connect`。 -#### 实现 Subscribable 接口 +#### 实现 `Subscribable` 接口 -有时候你已经用一个对象来保存状态,并且能够发送值。如果你实现了 Subscribable 接口,你可以把它转换成一个 observable 对象。Subscribable 接口中只有一个 subscribe 方法。 +有时候你已经用一个对象来保存状态,并且能够发送值。如果你实现了 `Subscribable` 接口,你可以把它转换成一个可观察对象。`Subscribable` 接口中只有一个 `subscribe` 方法。 ``` interface Subscribable { subscribe(observerOrNext?: PartialObserver | ((value: T) => void), error?: (error: any) => void, complete?: () => void): Unsubscribable} ``` -* * * - ### 结合和选择现有的流 知道怎么创建一个独立的流还不够。有时候你有好几个流但其实只需要一个。有些函数也可作为操作符,所以我不打算在这里深入展开。推荐看看 [Max NgWizard K][16] 所写的一篇 [文章][15],它还包含一些有趣的动画。 @@ -724,41 +616,34 @@ interface Subscribable { subscribe(observerOrNext?: PartialObserver | ((v #### ObservableInput 类型 -期望接收流的操作符和函数通常不单独和 observables 一起工作。相反,他们实际上期望的参数类型是 ObservableInput,定义如下: +期望接收流的操作符和函数通常不单独和可观察对象一起工作。相反,它们实际上期望的参数类型是 ObservableInput,定义如下: ``` type ObservableInput = SubscribableOrPromise | ArrayLike | Iterable; ``` -这意味着你可以传递一个 promises 或者数组却不需要事先把他们转换成 observables。 +这意味着你可以传递一个 promises 或者数组却不需要事先把他们转换成可观察对象。 #### defer -主要的目的是把一个 observable 对象的创建延迟(defer)到有人想要订阅的时间。在以下情况,这很有用: - -* 创建 observable 对象的开销较大 - -* 你想要给每个订阅者新的 observable 对象 - -* 你想要在订阅时候选择不同的 observable 对象 +主要的目的是把一个 observable 对象的创建延迟(`defer`)到有人想要订阅的时间。在以下情况,这很有用: +* 创建可观察对象的开销较大 +* 你想要给每个订阅者新的可观察对象 +* 你想要在订阅时候选择不同的可观察对象 * 有些代码必须在订阅之后执行 -最后一点包含了一个并不起眼的用例:Promises(defer 也可以返回一个 promise 对象)。看看这个用到了 fetch API 的例子: +最后一点包含了一个并不起眼的用例:Promises(`defer` 也可以返回一个 promise 对象)。看看这个用到了 fetch API 的例子: ``` function getUser(id) { console.log("fetching data"); return fetch(`https://server/user/${id}`); } -``` -``` const userPromise = getUser(1); console.log("I don't want that request now"); -``` -``` // 其它地方 userPromise.then(response => console.log("done"); ``` @@ -770,17 +655,13 @@ userPromise.then(response => console.log("done"); // done ``` -只要流在你订阅的时候执行了,promise 就会立即执行。我们调用 getUser 的瞬间,就发送了一个请求,哪怕我们这个时候不想发送请求。当然,我们可以使用 from 来把一个 promise 对象转换成 observable 对象,但我们传递的 promise 对象已经创建或执行了。defer 让我们能够等到订阅才发送这个请求: +只要流在你订阅的时候执行了,promise 就会立即执行。我们调用 `getUser` 的瞬间,就发送了一个请求,哪怕我们这个时候不想发送请求。当然,我们可以使用 `from` 来把一个 promise 对象转换成可观察对象,但我们传递的 promise 对象已经创建或执行了。`defer` 让我们能够等到订阅才发送这个请求: ``` const user$ = defer(() => getUser(1)); -``` -``` console.log("I don't want that request now"); -``` -``` // 其它地方 user$.subscribe(response => console.log("done"); ``` @@ -794,7 +675,7 @@ user$.subscribe(response => console.log("done"); #### iif - _iif 包含了一个关于 _defer_ 的特殊用例:在订阅时选择两个流中的一个: + `iif` 包含了一个关于 `defer` 的特殊用例:在订阅时选择两个流中的一个: ``` iif( @@ -810,9 +691,9 @@ iif( // AM before noon, PM afterwards ``` -引用了文档: +引用该文档: -> 实际上 `[iif][3]` 能够轻松地用 `[defer][4]` 实现,它仅仅是出于方便和可读性的目的。 +> 实际上 [iif][3] 能够轻松地用 [defer][4] 实现,它仅仅是出于方便和可读性的目的。 #### onErrorResumeNext @@ -822,13 +703,9 @@ iif( const stream1$ = of(1, 2).pipe( tap(i => { if(i>1) throw 'error'}) //fail after first element ); -``` -``` const stream2$ = of(3,4); -``` -``` onErrorResumeNext(stream1$, stream2$) .subscribe(console.log); ``` @@ -848,9 +725,7 @@ onErrorResumeNext(stream1$, stream2$) function handleResponses([user, account]) { // 执行某些任务 } -``` -``` forkJoin( fetch("https://server/user/1"), fetch("https://server/account/1") @@ -860,9 +735,9 @@ forkJoin( #### merge / concat -发送每一个从源 observables 对象中发出的值。 +发送每一个从可观察对象源中发出的值。 - _merge_  接收一个参数,让你定义有多少流能被同时订阅。默认是无限制的。设为 1 就意味着监听一个源流,在它结束的时候订阅下一个。由于这是一个常见的场景,RxJS 为你提供了一个显示的函数:_concat_。 +`merge` 接收一个参数,让你定义有多少流能被同时订阅。默认是无限制的。设为 1 就意味着监听一个源流,在它结束的时候订阅下一个。由于这是一个常见的场景,RxJS 为你提供了一个显示的函数:`concat`。 ``` merge( @@ -872,31 +747,20 @@ merge( 2 //two concurrent streams ) .subscribe(); -``` -``` // 只订阅流 1 和流 2 -``` -``` // 输出 // Stream 1 -> after 1000ms // Stream 2 -> after 1200ms // Stream 1 -> after 2000ms -``` -``` // 流 1 结束后,开始订阅流 3 -``` -``` // 输出 // Stream 3 -> after 0 ms // Stream 2 -> after 400 ms (2400ms from beginning) // Stream 3 -> after 1000ms -``` - -``` merge( interval(1000).pipe(mapTo("Stream 1"), take(2)), @@ -908,9 +772,7 @@ concat( interval(1000).pipe(mapTo("Stream 1"), take(2)), interval(1200).pipe(mapTo("Stream 2"), take(2)) ) -``` -``` // 输出 // Stream 1 -> after 1000ms // Stream 1 -> after 2000ms @@ -920,7 +782,7 @@ concat( #### zip / combineLatest - _merge_ 和 _concat_ 一个接一个的发送所有从源流中读到的值,而 zip 和 combineLatest 是把每个流中的一个值结合起来一起发送。_zip_ 结合所有源流中发送的第一个值。如果流的内容相关联,那么这就很有用。 +`merge` 和 `concat` 一个接一个的发送所有从源流中读到的值,而 `zip` 和 `combineLatest` 是把每个流中的一个值结合起来一起发送。`zip` 结合所有源流中发送的第一个值。如果流的内容相关联,那么这就很有用。 ``` zip( @@ -935,7 +797,7 @@ zip( // [0, 0] [1, 1] [2, 2] ... ``` -_combineLatest_ 与之类似,但结合的是源流中发送的最后一个值。直到所有源流至少发送一个值之后才会触发事件。这之后每次源流发送一个值,它都会把这个值与其他流发送的最后一个值结合起来。 +`combineLatest` 与之类似,但结合的是源流中发送的最后一个值。直到所有源流至少发送一个值之后才会触发事件。这之后每次源流发送一个值,它都会把这个值与其他流发送的最后一个值结合起来。 ``` combineLatest( @@ -983,15 +845,13 @@ race( // foo | ``` -由于 _of_ 立即产生一个值,因此它是最快的流,然而这个流就被选中了。 - -* * * +由于 `of` 立即产生一个值,因此它是最快的流,然而这个流就被选中了。 ### 总结 -已经有很多创建 observables 对象的方式了。如果你想要创造响应式的 APIs 或者想用响应式的 API 结合传统 APIs,那么了解这些方法很重要。 +已经有很多创建可观察对象的方式了。如果你想要创造响应式的 API 或者想用响应式的 API 结合传统 API,那么了解这些方法很重要。 -我已经向你展示了所有可用的方法,但它们其实还有很多内容可以讲。如果你想更加深入地了解,我极力推荐你查阅 [documentation][20] 或者阅读相关文章。 +我已经向你展示了所有可用的方法,但它们其实还有很多内容可以讲。如果你想更加深入地了解,我极力推荐你查阅 [文档][20] 或者阅读相关文章。 [RxViz][21] 是另一种值得了解的有意思的方式。你编写 RxJS 代码,产生的流可以用图形或动画进行显示。 @@ -1001,7 +861,7 @@ via: https://blog.angularindepth.com/the-extensive-guide-to-creating-streams-in- 作者:[Oliver Flaggl][a] 译者:[BriFuture](https://github.com/BriFuture) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2c5a3ca34586e7d1e250b65cf5dc0d97d4d9fc30 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 1 Sep 2018 23:01:00 +0800 Subject: [PATCH 020/455] =?UTF-8?q?PUB:20170709=20The=20Extensive=20Guide?= =?UTF-8?q?=20to=20Creating=20Streams=20in=C2=A0RxJS.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @BriFuture https://linux.cn/article-9973-1.html --- .../20170709 The Extensive Guide to Creating Streams in RxJS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170709 The Extensive Guide to Creating Streams in RxJS.md (100%) diff --git a/translated/tech/20170709 The Extensive Guide to Creating Streams in RxJS.md b/published/20170709 The Extensive Guide to Creating Streams in RxJS.md similarity index 100% rename from translated/tech/20170709 The Extensive Guide to Creating Streams in RxJS.md rename to published/20170709 The Extensive Guide to Creating Streams in RxJS.md From 20ed76193260c4a4f822e727f4a199a5690e1010 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 2 Sep 2018 21:59:00 +0800 Subject: [PATCH 021/455] =?UTF-8?q?PRF:20180703=20Understanding=20Python?= =?UTF-8?q?=20Dataclasses=E2=80=8A=E2=80=94=E2=80=8APart=201.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @MjSeven --- ...derstanding Python Dataclasses — Part 1.md | 53 ++++++++----------- 1 file changed, 23 insertions(+), 30 deletions(-) diff --git a/translated/tech/20180703 Understanding Python Dataclasses — Part 1.md b/translated/tech/20180703 Understanding Python Dataclasses — Part 1.md index d038a4d5bf..3b0d370546 100644 --- a/translated/tech/20180703 Understanding Python Dataclasses — Part 1.md +++ b/translated/tech/20180703 Understanding Python Dataclasses — Part 1.md @@ -1,28 +1,29 @@ -理解 Python 的 Dataclasses -- 第一部分 +理解 Python 的 Dataclasses(一) ====== ![](https://cdn-images-1.medium.com/max/900/1*7pr8EL8EDsP296pxL7Wz_g.png) -如果你正在阅读本文,那么你已经意识到了 Python 3.7 以及它所包含的新特性。就我个人而言,我对 `Dataclasses` 感到非常兴奋,因为我有一段时间在等待它了。 +如果你正在阅读本文,那么你已经意识到了 Python 3.7 以及它所包含的新特性。就我个人而言,我对 `Dataclasses` 感到非常兴奋,因为我等了它一段时间了。 本系列包含两部分: -1\. Dataclass 特点概述 -2\. 在下一篇文章概述 Dataclass 的 `fields` + +1. Dataclass 特点概述 +2. 在下一篇文章概述 Dataclass 的 `fields` ### 介绍 -`Dataclasses` 是 Python 的类(译注:更准确的说,它是一个模块),适用于存储数据对象。你可能会问什么是数据对象?下面是定义数据对象的一个不太详细的特性列表: +`Dataclasses` 是 Python 的类(LCTT 译注:更准确的说,它是一个模块),适用于存储数据对象。你可能会问什么是数据对象?下面是定义数据对象的一个不太详细的特性列表: - * 它们存储数据并代表某种数据类型。例如:一个数字。对于熟悉 ORM 的人来说,模型实例是一个数据对象。它代表一种特定的实体。它包含那些定义或表示实体的属性。 - - * 它们可以与同一类型的其他对象进行比较。例如:一个数字可以是 `greater than(大于)`, `less than(小于)` 或 `equal(等于)` 另一个数字。 +* 它们存储数据并代表某种数据类型。例如:一个数字。对于熟悉 ORM 的人来说,模型实例就是一个数据对象。它代表一种特定的实体。它包含那些定义或表示实体的属性。 +* 它们可以与同一类型的其他对象进行比较。例如:一个数字可以是 `greater than`(大于)、`less than`(小于) 或 `equal`(等于) 另一个数字。 当然还有更多的特性,但是这个列表足以帮助你理解问题的关键。 为了理解 `Dataclasses`,我们将实现一个包含数字的简单类,并允许我们执行上面提到的操作。 + 首先,我们将使用普通类,然后我们再使用 `Dataclasses` 来实现相同的结果。 -但在我们开始之前,先来谈谈 `dataclasses` 的用法。 +但在我们开始之前,先来谈谈 `Dataclasses` 的用法。 Python 3.7 提供了一个装饰器 [dataclass][2],用于将类转换为 `dataclass`。 @@ -33,7 +34,7 @@ from dataclasses import dataclass @dataclass class A: - … + ... ``` 现在,让我们深入了解一下 `dataclass` 带给我们的变化和用途。 @@ -65,10 +66,10 @@ class Number: >>> 1 ``` -以下是 dataclass 装饰器带来的变化: +以下是 `dataclass` 装饰器带来的变化: -1\. 无需定义 `__init__`,然后将值赋给 `self.d` 负责处理它(to 校正:这里真不知道 d 在哪里) -2\. 我们以更加易读的方式预先定义了成员属性,以及[类型提示][3]。我们现在立即能知道 `val` 是 `int` 类型。这无疑比一般定义类成员的方式更具可读性。 +1. 无需定义 `__init__`,然后将值赋给 `self`,`dataclass` 负责处理它(LCTT 译注:此处原文可能有误,提及一个不存在的 `d`) +2. 我们以更加易读的方式预先定义了成员属性,以及[类型提示][3]。我们现在立即能知道 `val` 是 `int` 类型。这无疑比一般定义类成员的方式更具可读性。 > Python 之禅: 可读性很重要 @@ -133,15 +134,11 @@ class Number: 两个对象 `a` 和 `b` 之间的比较通常包括以下操作: -* a < b - -* a > b - -* a == b - -* a >= b - -* a <= b +* `a < b` +* `a > b` +* `a == b` +* `a >= b` +* `a <= b` 在 Python 中,能够在可以执行上述操作的类中定义[方法][4]。为了简单起见,不让这篇文章过于冗长,我将只展示 `==` 和 `<` 的实现。 @@ -200,7 +197,7 @@ def __eq__(self, other): return (self.name, self.age) == ( other.name, other.age) ``` -请注意属性的顺序。它们总是按照你在 dataclass 类中定义的顺序生成。 +请注意属性的顺序。它们总是按照你在 `dataclass` 类中定义的顺序生成。 同样,等效的 `__le__` 函数类似于: @@ -234,7 +231,7 @@ def __le__(self, other): ### `dataclass` 作为一个可调用的装饰器 -定义所有的 `dunder`(译注:这是指双下划线方法,即魔法方法)方法并不总是值得的。你的用例可能只包括存储值和检查相等性。因此,你只需定义 `__init__` 和 `__eq__` 方法。如果我们可以告诉装饰器不生成其他方法,那么它会减少一些开销,并且我们将在数据对象上有正确的操作。 +定义所有的 `dunder`(LCTT 译注:这是指双下划线方法,即魔法方法)方法并不总是值得的。你的用例可能只包括存储值和检查相等性。因此,你只需定义 `__init__` 和 `__eq__` 方法。如果我们可以告诉装饰器不生成其他方法,那么它会减少一些开销,并且我们将在数据对象上有正确的操作。 幸运的是,这可以通过将 `dataclass` 装饰器作为可调用对象来实现。 @@ -247,11 +244,8 @@ class C: ``` 1. `init`:默认将生成 `__init__` 方法。如果传入 `False`,那么该类将不会有 `__init__` 方法。 - 2. `repr`:`__repr__` 方法默认生成。如果传入 `False`,那么该类将不会有 `__repr__` 方法。 - 3. `eq`:默认将生成 `__eq__` 方法。如果传入 `False`,那么 `__eq__` 方法将不会被 `dataclass` 添加,但默认为 `object.__eq__`。 - 4. `order`:默认将生成 `__gt__`、`__ge__`、`__lt__`、`__le__` 方法。如果传入 `False`,则省略它们。 我们在接下来会讨论 `frozen`。由于 `unsafe_hash` 参数复杂的用例,它值得单独发布一篇文章。 @@ -332,7 +326,6 @@ dataclasses.FrozenInstanceError: cannot assign to field ‘val’ 因此,一个 `frozen` 实例是一种很好方式来存储: * 常数 - * 设置 这些通常不会在应用程序的生命周期内发生变化,任何企图修改它们的行为都应该被禁止。 @@ -476,7 +469,7 @@ class B(A): ### 结论 -因此,以上是 dataclasses 使 Python 开发人员变得更轻松的几种方法。 +因此,以上是 `dataclass` 使 Python 开发人员变得更轻松的几种方法。 我试着彻底覆盖大部分的用例,但是,没有人是完美的。如果你发现了错误,或者想让我注意相关的用例,请联系我。 @@ -493,7 +486,7 @@ via: https://medium.com/mindorks/understanding-python-dataclasses-part-1-c3ccd43 作者:[Shikhar Chauhan][a] 译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From f2ebc2bf82884fd6294192255eb2fdbdb6ce0e74 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 2 Sep 2018 21:59:31 +0800 Subject: [PATCH 022/455] =?UTF-8?q?PUB:20180703=20Understanding=20Python?= =?UTF-8?q?=20Dataclasses=E2=80=8A=E2=80=94=E2=80=8APart=201.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @MjSeven https://linux.cn/article-9974-1.html --- .../20180703 Understanding Python Dataclasses — Part 1.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180703 Understanding Python Dataclasses — Part 1.md (100%) diff --git a/translated/tech/20180703 Understanding Python Dataclasses — Part 1.md b/published/20180703 Understanding Python Dataclasses — Part 1.md similarity index 100% rename from translated/tech/20180703 Understanding Python Dataclasses — Part 1.md rename to published/20180703 Understanding Python Dataclasses — Part 1.md From b46ea8cbdd1f4bb14daffe0c79415e516af8bcca Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 2 Sep 2018 22:20:38 +0800 Subject: [PATCH 023/455] PRF:20180810 6 Reasons Why Linux Users Switch to BSD.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @LuuMing 翻译的不错 --- ...6 Reasons Why Linux Users Switch to BSD.md | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/translated/tech/20180810 6 Reasons Why Linux Users Switch to BSD.md b/translated/tech/20180810 6 Reasons Why Linux Users Switch to BSD.md index a5755a68ee..2807f83920 100644 --- a/translated/tech/20180810 6 Reasons Why Linux Users Switch to BSD.md +++ b/translated/tech/20180810 6 Reasons Why Linux Users Switch to BSD.md @@ -1,54 +1,56 @@ -Linux 用户选择 BSD 的 6 个理由 +Linux 用户应该换到 BSD 的 6 个理由 ====== -迄今我因 BSD 是 FOSSFree and Open Source Software 已经写了数篇关于它的文章。但总有人会问:"为什么要纠结于 BSD?"。我认为最好的办法是写一篇关于这个话题的文章。 +迄今我因 BSD 是 自由及开源软件Free and Open Source Software(FOSS) 已经写了数篇关于它的文章。但总有人会问:“为什么要纠结于 BSD?”。我认为最好的办法是写一篇关于这个话题的文章。 -### 为什么在 Linux 上使用 BSD? +### 为什么用 BSD 取代 Linux? + +为了准备这篇文章,我与几位 BSD 的用户聊了聊,其中有人使用了多年 Linux 而后转入 BSD。因而这篇文章的观点都来源于真实的 BSD 用户。本文希望提出一个不同的观点。 -为了准备这篇文章,我与几位使用了多年 Linux 而后转入 BSD 的用户聊了聊。因而这篇文章的观点都来源于真实的 BSD 用户。本文希望提出一个不同的观点。 ![why use bsd over linux][2] -#### 1\. BSD 不仅仅是一个内核 +#### 1、BSD 不仅仅是一个内核 -几个人都指出 BSD 提供的操作系统对于终端用户来说就是一个巨大的内建的软件包。他们指出 "Linux" 仅仅说的是内核。一个 Linux 发行版由上述的内核与许多由发行者所选取的不同的应用与软件包组成。有时候安装新的软件包所导致的不兼容会使系统产生崩溃。 +几个人都指出 BSD 提供的操作系统对于终端用户来说就是一个巨大而统一的软件包。他们指出所谓 “Linux” 仅仅说的是内核。一个 Linux 发行版由上述的内核与许多由发行者所选取的不同的应用与软件包组成。有时候安装新的软件包所导致的不兼容会使系统产生崩溃。 -一个典型的 BSD 由内核和许多必要的软件包组成。这些包里的大多数是通过活跃的项目所开发。因此其具备高集成度与高响应度的特点。 +一个典型的 BSD 由内核和许多必要的软件包组成。这些包里的大多数是通过活跃的项目所开发,因此其具备高集成度与高响应度的特点。 -#### 2\. 软件包更值得信赖 +#### 2、软件包更值得信赖 -说起软件包,BSD 用户提出的另一点是软件包的可信度。在 Linux 上,软件包可以从一堆不同源上获得,一些是发行版的开发者,另一些是第三方。[Ubuntu][3] 和[其他发行版][4]就遇到了在第三方应用里隐藏了恶意软件的问题。 +说起软件包,BSD 用户提出的另一点是软件包的可信度。在 Linux 上,软件包可以从一堆不同的源上获得,一些是发行版的开发者提供的,另一些是第三方。[Ubuntu][3] 和[其他发行版][4]就遇到了在第三方应用里隐藏了恶意软件的问题。 -在 BSD 上,所有的软件包由“每个软件包都作为单个仓库的一部分并且每一步都设有安全系统的集中式软件包/端口系统”所提供。这就确保了黑客不能将恶意软件潜入看似稳定的应用程序中,保障了 BSD 的长期稳定性。 +在 BSD 上,所有的软件包由“集中式软件包/ ports 系统”所提供,“每个软件包都是单一仓库的一部分,并且每一步都设有安全系统”。这就确保了黑客不能将恶意软件潜入到看似稳定的应用程序中,保障了 BSD 的长期稳定性。 -#### 3\. 更新缓慢 = 更好的长期稳定性 +#### 3、更新缓慢 = 更好的长期稳定性 -如果更新是一场竞赛,那么 Linux 就是兔子, BSD 就是乌龟。甚至最慢的 Linux 发行版每年至少发布一个新版本(当然,除了 Debian)。在 BSD 的世界里,主要版本的发布需要更长时间。这就意味着可以更加集中于将事情做完善之后再将它推送给用户。 +如果更新是一场竞赛,那么 Linux 就是兔子,BSD 就是乌龟。甚至最慢的 Linux 发行版每年至少发布一个新版本(当然,除了 Debian)。在 BSD 的世界里,重大版本的发布需要更长时间。这就意味着可以更关注于将事情做完善之后再将它推送给用户。 -这也意味着操作系统的变化会随着时间的推移而发生。Linux 世界经历了数次快速而重大的变化,我们至今仍感觉如此(咳咳, [systemD][5],咳咳)。就像 Debian 那样,长时间的开发周期帮助 BSD 去测试新的想法,保证在它永久化之前正常工作。它也有助于生产出不太可能出现问题的代码。 +这也意味着操作系统的变化会随着时间的推移而发生。Linux 世界经历了数次快速而重大的变化,我们至今仍感觉如此(咳咳, [systemD][5],咳咳)。就像 Debian 那样,长时间的开发周期可以帮助 BSD 去测试新的想法,保证在它在永久改变之前正常工作。它也有助于生产出不太可能出现问题的代码。 -#### 4\. Linux 太乱了 +#### 4、Linux 太乱了 没有一个 BSD 用户直截了当地指出这一点,但这是他们许多经验所显示出的情况。很多用户从一个 Linux 发行版跳到另一个发行版去寻找适合他的版本。很多情况下,他们无法使所有的软件或硬件正常工作。这时,他们决定尝试使用 BSD,接着,所有的东西都正常工作了。 -当考虑到如何选择 BSD 时,一切就变得相当简单。目前只有一半的 BSD 在积极开发。这些 BSD中的每一个都有特定的用途。“[OpenBSD][6] 更安全,[FreeBSD][7] 适用于桌面或服务器, [NetBSD][8] 无所不包,[DragonFlyBSD][9] 精简高效“。与此同时,Linux 世界充满的许多版本仅仅是在现有的发行版上增加了主题或者图标。BSD 项目数量之少意味着它重复性低并且更加专注。 +当考虑到如何选择 BSD 时,一切就变得相当简单。目前只有六个 BSD 发行版在积极开发。这些 BSD 中的每一个都有特定的用途。“[OpenBSD][6] 更安全,[FreeBSD][7] 适用于桌面或服务器,[NetBSD][8] 无所不包,[DragonFlyBSD][9] 精简高效”。与此同时,充斥着 Linux 世界的许多发行版仅仅是在现有的发行版上增加了主题或者图标而已。BSD 项目数量之少意味着它重复性低并且更加专注。 -#### 5\. ZFS 支持 +#### 5、ZFS 支持 一个 BSD 用户说到他选择 BSD 最主要的原因是 [ZFS][10]。事实上,几乎所有我谈过的人都提到 BSD 支持 ZFS 是他们没有返回 Linux 的原因。 -这一点是 Linux 从一开始就处于下风的地方。虽然在一些 Linux 发行版上可以使用 [OpenZFS][11],但是 ZFS 已经内置在了 BSD 的内核中。这意味着 ZFS 在 BSD 上将会有更好地性能。尽管数次尝试将 ZFS 加入到 Linux 内核中,但协议问题依旧无法解决。 +这一点是 Linux 从一开始就处于下风的地方。虽然在一些 Linux 发行版上可以使用 [OpenZFS][11],但是 ZFS 已经内置在了 BSD 的内核中。这意味着 ZFS 在 BSD 上将会有更好地性能。尽管有过将 ZFS 加入到 Linux 内核中的数次尝试,但许可证问题依旧无法解决。 -#### 6\. 协议 +#### 6、许可证 -就协议而言也有不同的看法。大多数人所持有的想法是, GPL 不是真正的自由,因为它限制了如何使用软件。一些人也认为 GPL 太庞大而复杂以至于无法作出解释,会在开发过程中不仔细遵守协议而导致法律问题。 +就许可证而言也有不同的看法。大多数人所持有的想法是,GPL 不是真正的自由,因为它限制了如何使用软件。一些人也认为 GPL “太庞大而复杂而难于理解,如果在开发过程中不仔细检查许可证会导致法律问题。” -另一方面,BSD 协议只有 3 条,并且允许任何人“使用软件、进行修改、做任何事,并且对开发者提供保护”。 +另一方面,BSD 协议只有 3 条,并且允许任何人“使用软件、进行修改、做任何事,并且对开发者提供了保护”。 -#### 总结 +### 总结 这些仅仅只是一小部分人们使用 BSD 而不使用 Linux 的原因。如果你感兴趣,你可以[在这][12]阅读其他人的评论。如果你是 BSD 用户并且觉得我错过什么重要的地方,请在评论里说出你的想法。 如果你觉得这篇文章有意思,请在社交媒体上、技术资讯或者 [Reddit][13] 上分享它。 + -------------------------------------------------------------------------------- via: https://itsfoss.com/why-use-bsd/ @@ -56,7 +58,7 @@ via: https://itsfoss.com/why-use-bsd/ 作者:[John Paul][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[LuuMing](https://github.com/LuuMing) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8271015ad2cb42ba0bf9fed7f41d078f7791f293 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 2 Sep 2018 22:21:00 +0800 Subject: [PATCH 024/455] PUB:20180810 6 Reasons Why Linux Users Switch to BSD.md @LuuMing https://linux.cn/article-9975-1.html --- .../20180810 6 Reasons Why Linux Users Switch to BSD.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180810 6 Reasons Why Linux Users Switch to BSD.md (100%) diff --git a/translated/tech/20180810 6 Reasons Why Linux Users Switch to BSD.md b/published/20180810 6 Reasons Why Linux Users Switch to BSD.md similarity index 100% rename from translated/tech/20180810 6 Reasons Why Linux Users Switch to BSD.md rename to published/20180810 6 Reasons Why Linux Users Switch to BSD.md From 62eb896f9c4e4888736dc1538a4e5c3d44bf6143 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 2 Sep 2018 22:34:57 +0800 Subject: [PATCH 025/455] PRF:20180810 Automatically Switch To Light - Dark Gtk Themes Based On Sunrise And Sunset Times With AutomaThemely.md @geekpi --- ...ise And Sunset Times With AutomaThemely.md | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/translated/tech/20180810 Automatically Switch To Light - Dark Gtk Themes Based On Sunrise And Sunset Times With AutomaThemely.md b/translated/tech/20180810 Automatically Switch To Light - Dark Gtk Themes Based On Sunrise And Sunset Times With AutomaThemely.md index 2e23f6b528..407155c167 100644 --- a/translated/tech/20180810 Automatically Switch To Light - Dark Gtk Themes Based On Sunrise And Sunset Times With AutomaThemely.md +++ b/translated/tech/20180810 Automatically Switch To Light - Dark Gtk Themes Based On Sunrise And Sunset Times With AutomaThemely.md @@ -1,17 +1,19 @@ -使用 AutomaThemely 基于日出和日落时间自动切换到明/暗 Gtk 主题 +基于日出和日落时间自动切换到明/暗 Gtk 主题 ====== + 如果你在寻找一种基于日出和日落时间自动更改 Gtk 主题的简单方法,请尝试一下 [AutomaThemely][3]。 ![](https://4.bp.blogspot.com/-LS0XNNflbp0/W2q8zAwhUdI/AAAAAAAABUY/l8fVbjt-tHExYxPHsyVv74iUhV4O9UXLwCLcBGAs/s640/automathemely-settings.png) -**AutomaThemely 是一个 Python 程序,它可以根据光亮和黑暗时间自动更改 Gnome 主题,如果你想在夜间使用黑暗的 Gtk 主题并在白天使用明亮的 Gtk 主题,那么它非常有用。** +AutomaThemely 是一个 Python 程序,它可以根据光亮和黑暗时间自动更改 Gnome 主题,如果你想在夜间使用黑暗的 Gtk 主题并在白天使用明亮的 Gtk 主题,那么它非常有用。 -**虽然该程序是为 Gnome 桌面制作的,但它也适用于 Unity**。AutomaThemely 不支持不使用 “org.gnome.desktop.interface Gsettings” 的桌面环境,如 Cinnamon,的 Gtk 主题,或者更改图标主题,至少现在还不行。它也不支持设置 Gnome Shell 主题。 +**虽然该程序是为 Gnome 桌面制作的,但它也适用于 Unity**。AutomaThemely 不支持不使用 `org.gnome.desktop.interface Gsettings` 的桌面环境,如 Cinnamon,的 Gtk 主题,或者更改图标主题,至少现在还不行。它也不支持设置 Gnome Shell 主题。 除了自动更改 Gtk3 主题外,**AutomaThemely 还可以自动切换 Atom 编辑器和 VSCode 的明暗主题,以及 Atom 编辑器的明暗语法高亮。**这显然也是基于一天中的时间完成的。 [![AutomaThemely Atom VSCode][1]][2] -AutomaThemely Atom 和 VSCode 主题/语法设置 + +*AutomaThemely Atom 和 VSCode 主题/语法设置* 程序使用你的 IP 地址来确定你的位置,以便检索日出和日落时间,并且需要有可用的 Internet 连接。但是,你可以从程序用户界面禁用自动定位,并手动输入你的位置。 @@ -19,24 +21,25 @@ AutomaThemely Atom 和 VSCode 主题/语法设置 ### 下载/安装 AutomaThemely -**Ubuntu 18.04**:使用上面的链接,下载包含依赖项的 Python 3.6 DEB(python3.6-automathemely_1.2_all.deb)。 +- [下载 AutomaThemely][4] -**Ubuntu 16.04**:你需要下载并安装 AutomaThemely Python 3.5 DEB,它不包含依赖项(python3.5-no_deps-automathemely_1.2_all.deb),并使用 PIP3 分别安装依赖项(`requests`、`astral `、`pytz`、`tzlocal` 和 `schedule`): +**Ubuntu 18.04**:使用上面的链接,下载包含依赖项的 Python 3.6 DEB(`python3.6-automathemely_1.2_all.deb`)。 + +**Ubuntu 16.04**:你需要下载并安装 AutomaThemely Python 3.5 DEB,它不包含依赖项(`python3.5-no_deps-automathemely_1.2_all.deb`),并使用 PIP3 分别安装依赖项(`requests`、`astral `、`pytz`、`tzlocal` 和 `schedule`): ``` sudo apt install python3-pip python3 -m pip install --user requests astral pytz tzlocal schedule - ``` -AutomaThemely 下载页面还包含 Python 3.5 或 3.6 的 RPM 包,有包含和不包含依赖项。安装适合你的 Python 版本的软件包。如果你下载了包含依赖项的包但无法在你的系统上使用,请下载 “no_deps” 包并如上所述使用 PIP3 安装 Python3 依赖项。 +AutomaThemely 下载页面还包含 Python 3.5 或 3.6 的 RPM 包,有包含和不包含依赖项两种。安装适合你的 Python 版本的软件包。如果你下载了包含依赖项的包但无法在你的系统上使用,请下载 “no_deps” 包并如上所述使用 PIP3 安装 Python3 依赖项。 ### 使用 AutomaThemely 根据太阳时间更改明亮/黑暗 Gtk 主题 安装完成后,运行 AutomaThemely 一次以生成配置文件。单击 AutomaThemely 菜单条目或在终端中运行: + ``` automathemely - ``` 这不会运行任何 GUI,它只生成配置文件。 @@ -46,16 +49,16 @@ automathemely ![](https://2.bp.blogspot.com/-7YWj07q0-M0/W2rACrCyO_I/AAAAAAAABUs/iaN_LEyRSG8YGM0NB6Aw9PLKmRU4NxzMACLcBGAs/s320/automathemely-jumplists.png) 你还可以使用以下命令从命令行启动 AutomaThemely GUI: + ``` automathemely --manage - ``` -**配置要使用的主题后,你需要更新太阳的时间并重新启动 AutomaThemely 调度器**。你可以通过右键单击 AutomaThemely 图标(应该在 Unity/Gnome 中可用)并选择 `Update sun times`,然后选择 `Restart the scheduler` 来完成此操作。你也可以使用以下命令从终端执行此操作: +**配置要使用的主题后,你需要更新太阳的时间并重新启动 AutomaThemely 调度器**。你可以通过右键单击 AutomaThemely 图标(应该在 Unity/Gnome 中可用)并选择 “Update sun times” 来更新太阳时间,然后选择 “Restart the scheduler” 来重启调度器完成此操作。你也可以使用以下命令从终端执行此操作: + ``` automathemely --update automathemely --restart - ``` @@ -66,7 +69,7 @@ via: https://www.linuxuprising.com/2018/08/automatically-switch-to-light-dark-gt 作者:[Logix][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -74,3 +77,4 @@ via: https://www.linuxuprising.com/2018/08/automatically-switch-to-light-dark-gt [1]:https://4.bp.blogspot.com/-K2-1K_MIWv0/W2q9GEWYA6I/AAAAAAAABUg/-z_gTMSHlxgN-ZXDvUGIeTQ8I72WrRq0ACLcBGAs/s640/automathemely-settings_2.png (AutomaThemely Atom VSCode) [2]:https://4.bp.blogspot.com/-K2-1K_MIWv0/W2q9GEWYA6I/AAAAAAAABUg/-z_gTMSHlxgN-ZXDvUGIeTQ8I72WrRq0ACLcBGAs/s1600/automathemely-settings_2.png [3]:https://github.com/C2N14/AutomaThemely +[4]:https://github.com/C2N14/AutomaThemely/releases From 1a652d0cce8c78d738de26c5f7151e1ab6807a43 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 2 Sep 2018 22:35:32 +0800 Subject: [PATCH 026/455] PUB:20180810 Automatically Switch To Light - Dark Gtk Themes Based On Sunrise And Sunset Times With AutomaThemely.md @geekpi https://linux.cn/article-9976-1.html --- ...Themes Based On Sunrise And Sunset Times With AutomaThemely.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180810 Automatically Switch To Light - Dark Gtk Themes Based On Sunrise And Sunset Times With AutomaThemely.md (100%) diff --git a/translated/tech/20180810 Automatically Switch To Light - Dark Gtk Themes Based On Sunrise And Sunset Times With AutomaThemely.md b/published/20180810 Automatically Switch To Light - Dark Gtk Themes Based On Sunrise And Sunset Times With AutomaThemely.md similarity index 100% rename from translated/tech/20180810 Automatically Switch To Light - Dark Gtk Themes Based On Sunrise And Sunset Times With AutomaThemely.md rename to published/20180810 Automatically Switch To Light - Dark Gtk Themes Based On Sunrise And Sunset Times With AutomaThemely.md From f7182c5d33a18ab8da1cde775d293781fd333b01 Mon Sep 17 00:00:00 2001 From: shangmo Date: Sun, 2 Sep 2018 23:12:19 +0800 Subject: [PATCH 027/455] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E7=BB=93=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...x Virtual Machines vs Linux Live Images.md | 46 +++++++++++++++++-- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md index 01d6bf48a0..fc1bf69de0 100644 --- a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md +++ b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md @@ -59,21 +59,57 @@ Now I'm going to take a rather odd(奇怪的) stance(立场) on somethin -I'll grant you the same could be said with a virtual machine running Linux, however you will never have an update break anything using the live image approach. Why? Because you're not updating a host OS or the guest OS. Remember there are entire distros that are designed to be nothing more than persistent storage Linux distros. Puppy Linux is one great example. Not only can it run on PCs that would otherwise be recycled or thrown away, it allows you to never be bothered again with tedious system updates thanks to the way the distro handles security. It's not a normal Linux distro and it's walled off in such a way that the persistent live image is free from anything scary. +I'll grant you the same(如此) could be said(说) with a virtual machine running Linux, however you will never have an update break(打破) anything using the live image approach. Why? Because you're not updating a host OS or the guest OS. Remember(还记得) there are entire(整个) distros(发行版) that are designed to be nothing more than persistent storage Linux distros. Puppy Linux is one great example. Not only can it run on PCs that would otherwise(否则) be recycled(循环) or thrown away, it allows you to never be bothered(困扰) again with tedious(单调的) system updates thanks to the way the distro handles(处理) security. It's not a normal(正常的) Linux distro and it's walled off in such a way that the persistent(持续) live image is free from anything scary. + + + +我知道你会说用一个虚拟机运行 Linux 也是如此,无论如何你都无法升级到用镜像安装的地步。为什么?你不会更新你的宿主系统或者客户系统。记住,有一些发行 Linux 发行版本被设定为只能在持久存储中运行。Puppy Linux 就是一个非常好的例子。它仅能运行在个人 PC 上,否则它将进入死循环或被丢弃,它允许你永远不被单调的系统省级困扰,由于发行版会安全的处理这些更新。它不是一个正常的 Linux 发行版,有一个持久的免费镜像这样的方式用一堵墙个离开,多么可怕。 ### When a Linux virtual machine is absolutely the best option +### Linux 虚拟机是一个绝好的选择 + As I bring this article to a close, let me leave you with this. There is one instance where using a virtual machine such as Virtual Box is absolutely better than using a live image – recording the desktop environment of any Linux distro. -For example, I make videos that provide a tour and review of a variety of Linux distros. Doing this with live images would require me to capture the screen with a hardware device or install a software capture device from the live image's repositories. Clearly, a virtual machine is better suited for this job than a live image of a Linux distro. -Once you toss audio capture into the mix, there is no question that if you're going to use software to capture your review, you really want to have a host OS that has all the basic needs covered for a reasonably decent capture environment. Again, you could do all of this with a hardware device...but that might be cost prohibitive if you're only do video/audio capturing as a part time endeavor. + +我就讲到这里,这篇文章是时候结束了。Virtual Box 绝对是一个非常不错的运行 Linux 虚拟机的虚拟化产品。 + + + +For example, I make videos that provide a tour and review of a variety of Linux distros. Doing this with live images would require(需要) me to capture(捕获) the screen(屏幕) with a hardware device or install a software capture device from the live image's repositories(存储苦). Clearly(很明显), a virtual machine is better suited for this job than a live image of a Linux distro. + + + +例如,我制作了一个录像,里面介绍和评论了许多 Linux 发行版。硬件安装或者虚拟机安装一个从 Linux 发行版镜像库获得的镜像,一个实时的操作我们需要通过屏幕去捕获它。很明显,虚拟机运行 Linux 和 镜像安装更适合。 + + + +Once you toss audio capture into the mix, there is no question that if you're going to use software to capture your review, you really want to have a host OS that has all the basic needs covered(覆盖) for a reasonably(合理的) decent capture environment(环境). Again, you could do all of this with a hardware device...but that might(可能) be cost prohibitive if you're only do video/audio capturing as a part(部分) time endeavor. + + + +一旦你需要在音频资料中采集到混音,这没有问题,那如果你用软件去采集你的信息,为了一个合理的采集环境,你将需要一个本地安装的系统,这里面包含了所有的基本要求。在一次,用一个硬件安装方式,但是这开销可能很大,如果你仅仅是用与视频和音频操作,这需要花费一部分时间。 + + ### A Linux virtual machine vs a Linux live image -What is your preferred method of trying out new distros? Perhaps you're someone who is fine with formatting their hard drive and throwing caution to the wind, thus, making the idea of any of this unneeded? +### Linux 虚拟机 VS Linux 镜像 -Most people I've interacted with online tend to follow much of the methodology I've touched on above, but I'd love to hear what approach works best for you. Hit the comments, let me know which method you prefer when checking out the greatest and latest from the Linux distro world. +What is your preferred method of trying out new distros? Perhaps(也许) you're someone who is fine with formatting(格式化) their hard drive and throwing caution to the wind, thus, making the idea of any of this unneeded? + + + +你最喜欢尝试新发行版的方式是那些?也许,你会格式化磁盘,然后豁出去了,因此,不需要任何理由 + + + +Most people I've interacted(互动) with online tend to follow much of the methodology I've touched on above, but I'd love to hear what approach works best for you. Hit the comments, let me know which method you prefer when checking out the greatest and latest from the Linux distro world. + + + +大多数人告诉我他们喜欢上面的方法,但是我很像知道哪种方式更加适合你。点击评论,让我知道在 Linux 发行世界最伟大和最新的版本时,您更喜欢哪种方法。 -------------------------------------------------------------------------------- From d5d6855a5ea7a9757436319d7965b98c6c00c212 Mon Sep 17 00:00:00 2001 From: pityonline Date: Sun, 2 Sep 2018 23:12:03 +0800 Subject: [PATCH 028/455] =?UTF-8?q?PRF:=20#10034=20=E5=BE=AE=E8=B0=83?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E4=B8=8E=20pass=20=E7=9A=84=E7=BF=BB?= =?UTF-8?q?=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... An Official Introduction to the Go Compiler.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/translated/tech/20180427 An Official Introduction to the Go Compiler.md b/translated/tech/20180427 An Official Introduction to the Go Compiler.md index aeb419daa2..622bf49c6d 100644 --- a/translated/tech/20180427 An Official Introduction to the Go Compiler.md +++ b/translated/tech/20180427 An Official Introduction to the Go Compiler.md @@ -9,7 +9,7 @@ Go 编译器介绍 需要澄清的是,名称 “gc” 代表 “Go 编译器Go compiler”,与大写 GC 无关,后者代表垃圾收集garbage collection。 -### 1、 解析 +### 1、解析 * `cmd/compile/internal/syntax`(词法分析器lexer解析器parser语法树syntax tree) @@ -17,7 +17,7 @@ Go 编译器介绍 每个语法树都是相应源文件的确切表示,其中节点对应于源文件的各种元素,例如表达式、声明和语句。语法树还包括位置信息,用于错误报告和创建调试信息。 -### 2、 类型检查和 AST 变换 +### 2、类型检查和 AST 变换 * `cmd/compile/internal/gc`(创建编译器 AST,类型检查type-checkingAST 变换AST transformation) @@ -27,7 +27,7 @@ gc 包中包含一个继承自(早期)C 语言实现的版本的 AST 定义 特定变换也基于 AST 完成。一些节点被基于类型信息而细化,例如把字符串加法从算术加法的节点类型中拆分出来。其它一些例子是死代码消除dead code elimination函数调用内联function call inlining逃逸分析escape analysis(LCTT 译注:逃逸分析是一种分析指针有效范围的方法)。 -### 3、 通用 SSA +### 3、通用 SSA * `cmd/compile/internal/gc`(转换成 SSA) * `cmd/compile/internal/ssa`(SSA 相关的环节pass和规则) @@ -44,9 +44,9 @@ gc 包中包含一个继承自(早期)C 语言实现的版本的 AST 定义 这类通用的编译环节的一些例子包括,死代码消除、移除不必要的空值检查,以及移除无用的分支等。通用改写规则主要考虑表达式,例如将一些表达式替换为常量,优化乘法和浮点操作。 -### 4、 生成机器码 +### 4、生成机器码 -* `cmd/compile/internal/ssa`(SSA 低级化和架构特定的 pass) +* `cmd/compile/internal/ssa`(SSA 低级化和架构特定的环节) * `cmd/internal/obj`(机器码生成) 编译器中机器相关的阶段开始于“低级”的编译环节,该阶段将通用变量改写为它们的特定的机器码形式。例如,在 amd64 架构中操作数可以在内存中操作,这样许多加载-存储load-store操作就可以被合并。 @@ -61,13 +61,13 @@ gc 包中包含一个继承自(早期)C 语言实现的版本的 AST 定义 ### 扩展阅读 -要深入了解 SSA 包的工作方式,包括它的 pass 和规则,请转到 [cmd/compile/internal/ssa/README.md][1]。 +要深入了解 SSA 包的工作方式,包括它的环节和规则,请转到 [cmd/compile/internal/ssa/README.md][1]。 -------------------------------------------------------------------------------- via: https://github.com/golang/go/blob/master/src/cmd/compile/README.md -作者:[mvdan][a] +作者:[mvdan][a] 译者:[stephenxs](https://github.com/stephenxs) 校对:[pityonline](https://github.com/pityonline), [wxy](https://github.com/wxy) From 6fa77f4d8a2e6cbe66dcaa494657302447fd8d04 Mon Sep 17 00:00:00 2001 From: shangmo Date: Sun, 2 Sep 2018 23:20:08 +0800 Subject: [PATCH 029/455] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=8E=9F=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...x Virtual Machines vs Linux Live Images.md | 59 ------------------- 1 file changed, 59 deletions(-) delete mode 100644 sources/tech/20180226 Linux Virtual Machines vs Linux Live Images.md diff --git a/sources/tech/20180226 Linux Virtual Machines vs Linux Live Images.md b/sources/tech/20180226 Linux Virtual Machines vs Linux Live Images.md deleted file mode 100644 index 5367ccf9db..0000000000 --- a/sources/tech/20180226 Linux Virtual Machines vs Linux Live Images.md +++ /dev/null @@ -1,59 +0,0 @@ -## sober-wang 翻译中 -Linux Virtual Machines vs Linux Live Images -====== -I'll be the first to admit that I tend to try out new [Linux distros][1] on a far too frequent basis. Yet the method I use to test them, does vary depending on my goals for each instance. In this article, we're going to look at both running Linux virtual machines and running Linux live images. There are advantages to each method, but there are some hurdles with each method as well. - -### Testing out a new Linux distro for the first time - -When I test out a brand new Linux distro for the first time, the method I use depends heavily on the resources of the PC I'm currently on. If I have access to my desktop PC, I'm going to run the distro to be tested in a virtual machine. The reason for this approach is that I can download and test the distro in not only a live environment, but also as an installed product with persistent storage abilities. - -On the other hand, if I am working with much less robust hardware on a PC, then testing out a distro with a virtual machine installation of Linux is counter-productive. I'd be pushing that PC to its limits and honestly would be better off using a live Linux image instead running from a flash drive. - -### Touring software on a new Linux distro - -If you're interested in checking out a distro's desktop environment or the available software, you can't go wrong with a live image of the distro. A live environment provides you with a birds eye view of what to expect in terms of overall layout, applications provided and how the user experience flows overall. - -To be fair, you could do the same thing with a virtual machine installation, but it may be a bit overkill if you would rather avoid filling up hard drive space with yet more data. After all, this is a simple tour of the distro. Remember what I said in the first section – I like to run Linux in a virtual machine to test it. This means I'm going to see how it installs, what the partition options look like and other elements you wouldn't see from using a live image of any given distro. - -Touring usually indicates that you're only looking to take a quick look at a distro, so in this case the method that can be done with the least amount of resistance and time investment is a good course of action. - -### Taking a Linux distro with you - -While it's not as common as it was a few years ago, the ability to take a Linux distro with you may be a consideration for some users. Obviously, virtual machine installations don't necessarily lend themselves favorably to portability. However a live image of a Linux distro is actually quite portable. A live image can be written to a DVD or copied onto a flash drive for easy traveling. - -Expanding on this concept of Linux portability, it's also beneficial to have a live image on a flash drive when showing off how Linux works on a friend's computer. This empowers you to demonstrate how Linux can enrich their life while not relying on running a virtual machine on their PC. It's a bit of a win-win in favor of using a live image. - -### Alternative to dual-booting Linux - -This next item is a huge one. Consider this – perhaps you're a Windows user. You like playing with Linux, but would rather not take the plunge. Dual-booting is out of the question in case something goes wrong or perhaps you're not comfortable identifying individual partitions. Whatever the case may be, both using Linux in a virtual machine or from a live image might be a great option for you. - -Now I'm going to take a rather odd stance on something. I think you'll get far more value in the long term running Linux on a flash drive using a live image than with a virtual machine. There are two reasons for this. First of all, you'll get used to truly running Linux vs running it inside of a virtual machine on top of Windows. Second, you can setup your flash drive to contain user data with persistent storage. - -I'll grant you the same could be said with a virtual machine running Linux, however you will never have an update break anything using the live image approach. Why? Because you're not updating a host OS or the guest OS. Remember there are entire distros that are designed to be nothing more than persistent storage Linux distros. Puppy Linux is one great example. Not only can it run on PCs that would otherwise be recycled or thrown away, it allows you to never be bothered again with tedious system updates thanks to the way the distro handles security. It's not a normal Linux distro and it's walled off in such a way that the persistent live image is free from anything scary. - -### When a Linux virtual machine is absolutely the best option - -As I bring this article to a close, let me leave you with this. There is one instance where using a virtual machine such as Virtual Box is absolutely better than using a live image – recording the desktop environment of any Linux distro. - -For example, I make videos that provide a tour and review of a variety of Linux distros. Doing this with live images would require me to capture the screen with a hardware device or install a software capture device from the live image's repositories. Clearly, a virtual machine is better suited for this job than a live image of a Linux distro. - -Once you toss audio capture into the mix, there is no question that if you're going to use software to capture your review, you really want to have a host OS that has all the basic needs covered for a reasonably decent capture environment. Again, you could do all of this with a hardware device...but that might be cost prohibitive if you're only do video/audio capturing as a part time endeavor. - -### A Linux virtual machine vs a Linux live image - -What is your preferred method of trying out new distros? Perhaps you're someone who is fine with formatting their hard drive and throwing caution to the wind, thus, making the idea of any of this unneeded? - -Most people I've interacted with online tend to follow much of the methodology I've touched on above, but I'd love to hear what approach works best for you. Hit the comments, let me know which method you prefer when checking out the greatest and latest from the Linux distro world. - --------------------------------------------------------------------------------- - -via: https://www.datamation.com/open-source/linux-virtual-machines-vs-linux-live-images.html - -作者:[Matt Hartley][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.datamation.com/author/Matt-Hartley-3080.html -[1]:https://www.datamation.com/open-source/best-linux-distro.html From 105c9b237eec00c0bf129654816486a203b9b030 Mon Sep 17 00:00:00 2001 From: shangmo Date: Sun, 2 Sep 2018 23:37:01 +0800 Subject: [PATCH 030/455] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E5=8E=9F=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...x Virtual Machines vs Linux Live Images.md | 71 +------------------ 1 file changed, 2 insertions(+), 69 deletions(-) diff --git a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md index fc1bf69de0..9e73c63ede 100644 --- a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md +++ b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md @@ -1,114 +1,47 @@ -## sober-wang 翻译中 - -Linux Virtual Machines vs Linux Live Images Linxu 虚拟机 vs Linux 实体机 ====== -I'll be the first to admit(认可) that I tend(照顾) to try out new [Linux distros(发行版本)][1] on a far(远) too frequent(频繁) basis. Yet the method(方法) I use to test them, does vary depending(依赖) on my goals(目标) for each instance(每一个). In this article(文章), we're going to look at both(两个) running Linux virtual machines and running Linux live images. There are advantages(优势/促进/有利于) to each method(方法), but there are some hurdles(障碍) with each method(方法/函数) as well(同样的). - 首先我得承认,我非常倾向于频繁尝试新的[ linux 发行版本 ][1],我的目标是为了解决每一个 Linux 发行版的依赖,所以我用一些方法来测试它们。在一些文章中,我们将会看到两种运行 Linux 的模式,虚拟机或实体机。每一种方式都存在优势,但是有一些障碍会伴随着这两种方式。 -### Testing out a new Linux distro for the first time ### 第一时间测试一个新的 Linux 发行版 -When I test out a brand new Linux distro for the first time, the method I use depends heavily(沉重的) on the resources(资源) of the PC I'm currently(目前的) on. If I have access to my desktop PC, I'm going to run the distro to be tested in a virtual machine. The reason(理由) for this approach(靠近) is that I can download and test the distro in not only a live environment(环境), but also(也) as an installed product with persistent(稳定的) storage abilities(能力). - 为了第一时间去做 Linux 发型版本的依赖测试,我把它们运行在我目前所拥有的所有类型的 PC 上。如果我用我的台式机,我将运行一个 Linux 虚拟机做测试。使用这种方法的原因是,不仅仅是生活环境下我可以下载测并测试发行版,但也会用稳定的生产环境安装。 -On the other hand, if I am working with much less robust(强力的) hardware on a PC, then testing out a distro with a virtual machine installation of Linux is counter-productive. I'd be pushing that PC to its limits(范围) and honestly(真诚的) would be better off(富裕的) using a live Linux image instead running from a flash drive. - 在另一方面,如果我在工作中我的PC不具备强力的硬件条件的,在一个虚拟机上测试 Linux 发型版本的时候将会产生相反的效果。老实的讲,我会将电脑性能压榨到极限,如果在经济条件服务的情况下我会使用实体机运行 Linux 镜像替代虚拟机 -### Touring software on a new Linux distro ### 在一个新的 Linux 发行版本上运行旅游软件 -If you're interested in checking out a distro's desktop environment(环境) or the available software(购买软件), you can't go wrong with a live image of the distro. A live environment provides(提供) you with a birds eye view of what to expect(期望) in terms of overall layout(总体布局), applications provided and how the user experience(体验) flows overall. - 如果你有兴趣查看发行版本的桌面环境或购买软件,你不能因为发行版本的一个实时图片而诽谤它。一个生活环境提供给你希望的鸟瞰全局的视角,如何使用户体验更好是由应用程序提供的。 -To be fair, you could do the same thing with a virtual machine installation, but it may be a bit overkill if you would rather(宁可) avoid(消除) filling(填充) up hard drive space with yet more data. After all(毕竟), this is a simple tour of the distro. Remember what I said in the first section – I like to run Linux in a virtual machine to test it. This means I'm going to see how it installs, what the partition(区分) options look like and other elements(原理) you wouldn't see from using a live image of any given distro. - 公平的说,一个虚拟化安装你也可以做同样的事,但是它有点不好,如果这么做你将要消除硬件上的许多数据。毕竟这是一个简单的发行版。记得我说过在第一部分-我做测试喜欢在虚拟机上运行 Linux 。这个方式我就能看见如何去安装它,使用镜像安装时你讲看不见有区别的操作和其他工作原理。 -Touring usually indicates(表明) that you're only looking to take a quick look at a distro, so in this case(情况) the method(方法) that can be done with the least amount(最少的数量) of resistance(阻力) and time investment(时间的投入) is a good course(过程) of action. - 通常你仅能看见一个关于发行版本的简短介绍,关于功能用最少的阻力和时间投入,是解决这个问题的好办法。 -### Taking a Linux distro with you -### 随身携带一个发行版本 - -While it's not as common(共同的) as it was a few(很少数) years ago, the ability(有……能力) to take a Linux distro with you may be a consideration(担心) for some users. Obviously, virtual machine installations don't necessarily(必要的) lend(提供) themselves favorably(适合他们自己的) to portability(可携带). However a live image of a Linux distro is actually quite portable. A live image can be written to a DVD or copied onto a flash drive for easy traveling. +### 随身携带一个 这个话题虽然不像几年前那样普遍,使用 Linux 发行版的能力可能是许多用户所顾虑的。明显,适合他们自己携带的系统,虚拟机是无法提供的。无论如何,一个 Linux 发行版本的镜像是具有可移植性的。一个镜像能够轻松的写入到 DVD 或者 Flash 存储设备中。 -Expanding(花费) on this concept(概念) of Linux portability(轻便/便携), it's also beneficial(有益处) to have a live image on a flash drive when showing off how Linux works on a friend's computer. This empowers(授权) you to demonstrate(证明) how Linux can enrich(充实/使丰富) their life while not relying on running a virtual machine on their PC. It's a bit of a win-win in favor(喜爱) of using a live image. - 在 Linux 可移植性的概念上花费时间,这有益于在一个朋友的电脑上使用 Flash 存储设备安装镜像版 Linux 。这个授权使你能证明 Linux 能充实他们的生活,虽然在他们的 PC 上运行一个虚拟机是不可靠的。在喜爱使用镜像的用户哪里,它是双赢的。 -### Alternative to dual-booting Linux ### 选择做双系统 Linux -This next item is a huge one. Consider this – perhaps you're a Windows user. You like playing with Linux, but would rather not take the plunge. Dual-booting is out of the question in case(情况) something goes wrong or perhaps you're not comfortable identifying individual partitions. Whatever the case may be, both using Linux in a virtual machine or from a live image might be a great option for you. - 这是一个巨大的项目。考虑一些事,例如你在使用 Windows .你喜欢玩 Linux ,但是宁可不获取插件。在一些出状况或考虑你不是拥有单独分区,双系统将是一个问题。不管什么样的情况,同时使用 Linux 虚拟机和镜像系统都对于你是一个很好的选择。 -Now I'm going to take a rather odd(奇怪的) stance(立场) on something. I think you'll get far(能走多远) more value in the long term running Linux on a flash drive using a live image than with a virtual machine. There are two reasons(原因) for this. First of all, you'll get used to truly (真正的)running Linux vs running it inside of a virtual machine on top of Windows. Second, you can setup your flash drive to contain(包含) user data with persistent storage. - - - 现在,我在一些事物上采取奇怪的立场。长期运行 Linux 镜像在 Flash 存储或虚拟机,我知道你将为了更多的价值走更远。对于这个说法有两个原因。第一个,在 Windows 中安装一个虚拟机 VS 真正的运行的 Linux 。第二,用一个持续的存储设备你的 Flash 存储,安装 Linux 和你的数据。 - - -I'll grant you the same(如此) could be said(说) with a virtual machine running Linux, however you will never have an update break(打破) anything using the live image approach. Why? Because you're not updating a host OS or the guest OS. Remember(还记得) there are entire(整个) distros(发行版) that are designed to be nothing more than persistent storage Linux distros. Puppy Linux is one great example. Not only can it run on PCs that would otherwise(否则) be recycled(循环) or thrown away, it allows you to never be bothered(困扰) again with tedious(单调的) system updates thanks to the way the distro handles(处理) security. It's not a normal(正常的) Linux distro and it's walled off in such a way that the persistent(持续) live image is free from anything scary. - - - 我知道你会说用一个虚拟机运行 Linux 也是如此,无论如何你都无法升级到用镜像安装的地步。为什么?你不会更新你的宿主系统或者客户系统。记住,有一些发行 Linux 发行版本被设定为只能在持久存储中运行。Puppy Linux 就是一个非常好的例子。它仅能运行在个人 PC 上,否则它将进入死循环或被丢弃,它允许你永远不被单调的系统省级困扰,由于发行版会安全的处理这些更新。它不是一个正常的 Linux 发行版,有一个持久的免费镜像这样的方式用一堵墙个离开,多么可怕。 -### When a Linux virtual machine is absolutely the best option - ### Linux 虚拟机是一个绝好的选择 -As I bring this article to a close, let me leave you with this. There is one instance where using a virtual machine such as Virtual Box is absolutely better than using a live image – recording the desktop environment of any Linux distro. - - - 我就讲到这里,这篇文章是时候结束了。Virtual Box 绝对是一个非常不错的运行 Linux 虚拟机的虚拟化产品。 - - -For example, I make videos that provide a tour and review of a variety of Linux distros. Doing this with live images would require(需要) me to capture(捕获) the screen(屏幕) with a hardware device or install a software capture device from the live image's repositories(存储苦). Clearly(很明显), a virtual machine is better suited for this job than a live image of a Linux distro. - - - 例如,我制作了一个录像,里面介绍和评论了许多 Linux 发行版。硬件安装或者虚拟机安装一个从 Linux 发行版镜像库获得的镜像,一个实时的操作我们需要通过屏幕去捕获它。很明显,虚拟机运行 Linux 和 镜像安装更适合。 - - -Once you toss audio capture into the mix, there is no question that if you're going to use software to capture your review, you really want to have a host OS that has all the basic needs covered(覆盖) for a reasonably(合理的) decent capture environment(环境). Again, you could do all of this with a hardware device...but that might(可能) be cost prohibitive if you're only do video/audio capturing as a part(部分) time endeavor. - - - 一旦你需要在音频资料中采集到混音,这没有问题,那如果你用软件去采集你的信息,为了一个合理的采集环境,你将需要一个本地安装的系统,这里面包含了所有的基本要求。在一次,用一个硬件安装方式,但是这开销可能很大,如果你仅仅是用与视频和音频操作,这需要花费一部分时间。 - - -### A Linux virtual machine vs a Linux live image - ### Linux 虚拟机 VS Linux 镜像 -What is your preferred method of trying out new distros? Perhaps(也许) you're someone who is fine with formatting(格式化) their hard drive and throwing caution to the wind, thus, making the idea of any of this unneeded? - - - 你最喜欢尝试新发行版的方式是那些?也许,你会格式化磁盘,然后豁出去了,因此,不需要任何理由 - - -Most people I've interacted(互动) with online tend to follow much of the methodology I've touched on above, but I'd love to hear what approach works best for you. Hit the comments, let me know which method you prefer when checking out the greatest and latest from the Linux distro world. - - - 大多数人告诉我他们喜欢上面的方法,但是我很像知道哪种方式更加适合你。点击评论,让我知道在 Linux 发行世界最伟大和最新的版本时,您更喜欢哪种方法。 -------------------------------------------------------------------------------- @@ -116,7 +49,7 @@ Most people I've interacted(互动) with online tend to follow much of the m via: https://www.datamation.com/open-source/linux-virtual-machines-vs-linux-live-images.html 作者:[Matt Hartley][a] -译者:[译者ID](https://github.com/译者ID) +译者:[sober-wang](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 5f43861d5e511a62b520eb9c42842bd5a5a01ebe Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 3 Sep 2018 06:03:36 +0800 Subject: [PATCH 031/455] translated --- ...ction to pipes and named pipes in Linux.md | 60 ------------------- ...ction to pipes and named pipes in Linux.md | 60 +++++++++++++++++++ 2 files changed, 60 insertions(+), 60 deletions(-) delete mode 100644 sources/tech/20180823 An introduction to pipes and named pipes in Linux.md create mode 100644 translated/tech/20180823 An introduction to pipes and named pipes in Linux.md diff --git a/sources/tech/20180823 An introduction to pipes and named pipes in Linux.md b/sources/tech/20180823 An introduction to pipes and named pipes in Linux.md deleted file mode 100644 index ab6a8cf932..0000000000 --- a/sources/tech/20180823 An introduction to pipes and named pipes in Linux.md +++ /dev/null @@ -1,60 +0,0 @@ -translating---geekpi - -An introduction to pipes and named pipes in Linux -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW-Internet_construction_9401467_520x292_0512_dc.png?itok=RPkPPtDe) - -In Linux, the `pipe` command lets you sends the output of one command to another. Piping, as the term suggests, can redirect the standard output, input, or error of one process to another for further processing. - -The syntax for the `pipe` or `unnamed pipe` command is the `|` character between any two commands: - -`Command-1 | Command-2 | …| Command-N` - -Here, the pipe cannot be accessed via another session; it is created temporarily to accommodate the execution of `Command-1` and redirect the standard output. It is deleted after successful execution. - -![](https://opensource.com/sites/default/files/uploads/pipe.png) - -In the example above, contents.txt contains a list of all files in a particular directory—specifically, the output of the ls -al command. We first grep the filenames with the "file" keyword from contents.txt by piping (as shown), so the output of the cat command is provided as the input for the grep command. Next, we add piping to execute the awk command, which displays the 9th column from the filtered output from the grep command. We can also count the number of rows in contents.txt using the wc -l command. - -A named pipe can last until as long as the system is up and running or until it is deleted. It is a special file that follows the [FIFO][1] (first in, first out) mechanism. It can be used just like a normal file; i.e., you can write to it, read from it, and open or close it. To create a named pipe, the command is: -``` -mkfifo - -``` - -This creates a named pipe file that can be used even over multiple shell sessions. - -Another way to create a FIFO named pipe is to use this command: -``` -mknod p - -``` - -To redirect a standard output of any command to another process, use the `>` symbol. To redirect a standard input of any command, use the `<` symbol. - -![](https://opensource.com/sites/default/files/uploads/redirection.png) - -As shown above, the output of the `ls -al` command is redirected to `contents.txt` and inserted in the file. Similarly, the input for the `tail` command is provided as `contents.txt` via the `<` symbol. - -![](https://opensource.com/sites/default/files/uploads/create-named-pipe.png) - -![](https://opensource.com/sites/default/files/uploads/verify-output.png) - -Here, we have created a named pipe, `my-named-pipe`, and redirected the output of the `ls -al` command into the named pipe. We can the open a new shell session and `cat` the contents of the named pipe, which shows the output of the `ls -al` command, as previously supplied. Notice the size of the named pipe is zero and it has a designation of "p". - -So, next time you're working with commands at the Linux terminal and find yourself moving data between commands, hopefully a pipe will make the process quick and easy. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/introduction-pipes-linux - -作者:[Archit Modi][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/architmodi -[1]:https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics) diff --git a/translated/tech/20180823 An introduction to pipes and named pipes in Linux.md b/translated/tech/20180823 An introduction to pipes and named pipes in Linux.md new file mode 100644 index 0000000000..f50af52225 --- /dev/null +++ b/translated/tech/20180823 An introduction to pipes and named pipes in Linux.md @@ -0,0 +1,60 @@ +介绍 Linux 中的管道和命名管道 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW-Internet_construction_9401467_520x292_0512_dc.png?itok=RPkPPtDe) + +在 Linux 中,`pipe` 能让你将一个命令的输出发送给另一个命令。管道,如它的名称那样,能重定向一个进程的标准输出、输入、和错误到另一个进程,以便于进一步处理。 + +`pipe` 或者 `unnamed pipe` 命令的语法是在两个命令之间加上 `|` 字符: + + +`Command-1 | Command-2 | …| Command-N` + +这里,管道不能通过另一个会话访问;它被临时创建用于接收 `Command-1` 的执行并重定向标准输出。它在成功执行之后删除。 + +![](https://opensource.com/sites/default/files/uploads/pipe.png) + +在上面的示例中,contents.txt 包含特定目录中所有文件的列表 - 具体来说,就 是ls -al 命令的输出。我们首先通过管道(如图所示)使用 contents.txt 中的 “file” 关键字 grep 文件名,因此 cat 命令的输出作为 grep 命令的输入提供。接下来,我们添加管道来执行 awk 命令,该命令显示 grep 命令的过滤输出中的第 9 列。我们还可以使用 wc -l 命令计算 contents.txt 中的行数。 + +只要系统启动并运行或直到它被删除,命名管道就可以持续使用。它是一个遵循 [FIFO][1](先进先出)机制的特殊文件。它可以像普通文件一样使用。也就是,你可以写入,从中读取,然后打开或关闭它。要创建命名管道,命令为: + +``` +mkfifo + +``` + +这将创建一个命名管道文件,它甚至可以在多个 shell 会话中使用。 + +创建 FIFO 命名管道的另一种方法是使用此命令: +``` +mknod p + +``` + + `>` 符号。要重定向任何命令的标准输入,请使用 `<` 符号。 + +![](https://opensource.com/sites/default/files/uploads/redirection.png) + +如上所示,`ls -al` 命令的输出被重定向到 `contents.txt` 并插入到文件中。类似地,`tail` 命令的输入通过 `<` 符号从 `contents.txt` 读取。 + +![](https://opensource.com/sites/default/files/uploads/create-named-pipe.png) + +![](https://opensource.com/sites/default/files/uploads/verify-output.png) + +这里,我们创建了一个命名管道 `my-named-pipe`,并将 `ls -al` 命令的输出重定向到命名管道。我们可以打开一个新的 shell 会话并 `cat` 命名管道的内容,如前所述,它显示了 `ls -al`命令的输出。请注意,命名管道的大小为零,并有一副标志 “p”。 + +因此,下次你在 Linux 终端上使用命令并在命令之间移动数据时,希望管道使过程快速简便。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/introduction-pipes-linux + +作者:[Archit Modi][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/architmodi +[1]:https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics) From 935a6d6a4fabb91fe4176c9ad7962c27cd924b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=B3=A5?= <24203166+fuzheng1998@users.noreply.github.com> Date: Mon, 3 Sep 2018 07:25:36 +0800 Subject: [PATCH 032/455] apply for translation --- ...ud Commander - A Web File Manager With Console And Editor.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md b/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md index 0aae74d680..0b842e32b1 100644 --- a/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md +++ b/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md @@ -1,3 +1,5 @@ +fuzheng1998 translating +====== Cloud Commander – A Web File Manager With Console And Editor ====== From e94f93ac2ff9db001293d10516b6128caa28c926 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 3 Sep 2018 09:43:57 +0800 Subject: [PATCH 033/455] translating --- ...80824 How to install software from the Linux command line.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180824 How to install software from the Linux command line.md b/sources/tech/20180824 How to install software from the Linux command line.md index 012ed3fece..eccf8c5e17 100644 --- a/sources/tech/20180824 How to install software from the Linux command line.md +++ b/sources/tech/20180824 How to install software from the Linux command line.md @@ -1,3 +1,5 @@ +translating----geekpi + How to install software from the Linux command line ====== From 3f83b35898934352443c08f80fbbad3f050bacde Mon Sep 17 00:00:00 2001 From: ypingcn <1344632698@qq.com> Date: Mon, 3 Sep 2018 11:23:44 +0800 Subject: [PATCH 034/455] Delete 20180826 How to capture and analyze packets with tcpdump command on Linux.md --- ...e packets with tcpdump command on Linux.md | 419 ------------------ 1 file changed, 419 deletions(-) delete mode 100644 sources/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md diff --git a/sources/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md b/sources/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md deleted file mode 100644 index 4ab2b8d72b..0000000000 --- a/sources/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md +++ /dev/null @@ -1,419 +0,0 @@ -translating by ypingcn - -How to capture and analyze packets with tcpdump command on Linux -====== -tcpdump is a well known command line **packet analyzer** tool. Using tcpdump command we can capture the live TCP/IP packets and these packets can also be saved to a file. Later on these captured packets can be analyzed via tcpdump command. tcpdump command becomes very handy when it comes to troubleshooting on network level. - -![](https://www.linuxtechi.com/wp-content/uploads/2018/08/tcpdump-command-examples-linux.jpg) - -tcpdump is available in most of the Linux distributions, for Debian based Linux, it be can be installed using apt command, -``` -# apt install tcpdump -y - -``` - -On RPM based Linux OS, tcpdump can be installed using below yum command -``` -# yum install tcpdump -y - -``` - -When we run the tcpdump command without any options then it will capture packets of all the interfaces. So to stop or cancel the tcpdump command, type “ **ctrl+c** ” . In this tutorial we will discuss how to capture and analyze packets using different practical examples, - -### Example:1) Capturing packets from a specific interface - -When we run the tcpdump command without any options, it will capture packets on the all interfaces, so to capture the packets from a specific interface use the option ‘ **-i** ‘ followed by the interface name. - -Syntax : - -``` -# tcpdump -i {interface-name} -``` - -Let’s assume, i want to capture packets from interface “enp0s3” - -Output would be something like below, -``` -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes -06:43:22.905890 IP compute-0-1.example.com.ssh > 169.144.0.1.39374: Flags [P.], seq 21952160:21952540, ack 13537, win 291, options [nop,nop,TS val 26164373 ecr 6580205], length 380 -06:43:22.906045 IP compute-0-1.example.com.ssh > 169.144.0.1.39374: Flags [P.], seq 21952540:21952760, ack 13537, win 291, options [nop,nop,TS val 26164373 ecr 6580205], length 220 -06:43:22.906150 IP compute-0-1.example.com.ssh > 169.144.0.1.39374: Flags [P.], seq 21952760:21952980, ack 13537, win 291, options [nop,nop,TS val 26164373 ecr 6580205], length 220 -06:43:22.906291 IP 169.144.0.1.39374 > compute-0-1.example.com.ssh: Flags [.], ack 21952980, win 13094, options [nop,nop,TS val 6580205 ecr 26164373], length 0 -06:43:22.906303 IP 169.144.0.1.39374 > compute-0-1.example.com.ssh: Flags [P.], seq 13537:13609, ack 21952980, win 13094, options [nop,nop,TS val 6580205 ecr 26164373], length 72 -06:43:22.906322 IP compute-0-1.example.com.ssh > 169.144.0.1.39374: Flags [P.], seq 21952980:21953200, ack 13537, win 291, options [nop,nop,TS val 26164373 ecr 6580205], length 220 -^C -109930 packets captured -110065 packets received by filter -133 packets dropped by kernel -[[email protected] ~]# - -``` - -### Example:2) Capturing specific number number of packet from a specific interface - -Let’s assume we want to capture 12 packets from the specific interface like “enp0s3”, this can be easily achieved using the options “ **-c {number} -i {interface-name}** ” -``` -root@compute-0-1 ~]# tcpdump -c 12 -i enp0s3 - -``` - -Above command will generate the output something like below - -[![N-Number-Packsets-tcpdump-interface][1]][2] - -### Example:3) Display all the available Interfaces for tcpdump - -Use ‘ **-D** ‘ option to display all the available interfaces for tcpdump command, -``` -[root@compute-0-1 ~]# tcpdump -D -1.enp0s3 -2.enp0s8 -3.ovs-system -4.br-int -5.br-tun -6.nflog (Linux netfilter log (NFLOG) interface) -7.nfqueue (Linux netfilter queue (NFQUEUE) interface) -8.usbmon1 (USB bus number 1) -9.usbmon2 (USB bus number 2) -10.qbra692e993-28 -11.qvoa692e993-28 -12.qvba692e993-28 -13.tapa692e993-28 -14.vxlan_sys_4789 -15.any (Pseudo-device that captures on all interfaces) -16.lo [Loopback] -[[email protected] ~]# - -``` - -I am running the tcpdump command on one of my openstack compute node, that’s why in the output you have seen number interfaces, tab interface, bridges and vxlan interface. - -### Example:4) Capturing packets with human readable timestamp (-tttt option) - -By default in tcpdump command output, there is no proper human readable timestamp, if you want to associate human readable timestamp to each captured packet then use ‘ **-tttt** ‘ option, example is shown below, -``` -[[email protected] ~]# tcpdump -c 8 -tttt -i enp0s3 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes -2018-08-25 23:23:36.954883 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 1449206247:1449206435, ack 3062020950, win 291, options [nop,nop,TS val 86178422 ecr 21583714], length 188 -2018-08-25 23:23:36.955046 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 188, win 13585, options [nop,nop,TS val 21583717 ecr 86178422], length 0 -2018-08-25 23:23:37.140097 IP controller0.example.com.amqp > compute-0-1.example.com.57818: Flags [P.], seq 814607956:814607964, ack 2387094506, win 252, options [nop,nop,TS val 86172228 ecr 86176695], length 8 -2018-08-25 23:23:37.140175 IP compute-0-1.example.com.57818 > controller0.example.com.amqp: Flags [.], ack 8, win 237, options [nop,nop,TS val 86178607 ecr 86172228], length 0 -2018-08-25 23:23:37.355238 IP compute-0-1.example.com.57836 > controller0.example.com.amqp: Flags [P.], seq 1080415080:1080417400, ack 1690909362, win 237, options [nop,nop,TS val 86178822 ecr 86163054], length 2320 -2018-08-25 23:23:37.357119 IP controller0.example.com.amqp > compute-0-1.example.com.57836: Flags [.], ack 2320, win 1432, options [nop,nop,TS val 86172448 ecr 86178822], length 0 -2018-08-25 23:23:37.357545 IP controller0.example.com.amqp > compute-0-1.example.com.57836: Flags [P.], seq 1:22, ack 2320, win 1432, options [nop,nop,TS val 86172449 ecr 86178822], length 21 -2018-08-25 23:23:37.357572 IP compute-0-1.example.com.57836 > controller0.example.com.amqp: Flags [.], ack 22, win 237, options [nop,nop,TS val 86178825 ecr 86172449], length 0 -8 packets captured -134 packets received by filter -69 packets dropped by kernel -[[email protected] ~]# - -``` - -### Example:5) Capturing and saving packets to a file (-w option) - -Use “ **-w** ” option in tcpdump command to save the capture TCP/IP packet to a file, so that we can analyze those packets in the future for further analysis. - -Syntax : - -``` -# tcpdump -w file_name.pcap -i {interface-name} -``` - -Note: Extension of file must be **.pcap** - -Let’s assume i want to save the captured packets of interface “ **enp0s3** ” to a file name **enp0s3-26082018.pcap** - -``` -[root@compute-0-1 ~]# tcpdump -w enp0s3-26082018.pcap -i enp0s3 -``` - -Above command will generate the output something like below, -``` -[root@compute-0-1 ~]# tcpdump -w enp0s3-26082018.pcap -i enp0s3 -tcpdump: listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes -^C841 packets captured -845 packets received by filter -0 packets dropped by kernel -[root@compute-0-1 ~]# ls -anaconda-ks.cfg enp0s3-26082018.pcap -[root@compute-0-1 ~]# - -``` - -Capturing and Saving the packets whose size **greater** than **N bytes** -``` -[root@compute-0-1 ~]# tcpdump -w enp0s3-26082018-2.pcap greater 1024 - -``` - -Capturing and Saving the packets whose size **less** than **N bytes** -``` -[root@compute-0-1 ~]# tcpdump -w enp0s3-26082018-3.pcap less 1024 - -``` - -### Example:6) Reading packets from the saved file ( -r option) - -In the above example we have saved the captured packets to a file, we can read those packets from the file using the option ‘ **-r** ‘, example is shown below, - -``` -[root@compute-0-1 ~]# tcpdump -r enp0s3-26082018.pcap -``` - -Reading the packets with human readable timestamp, -``` -[root@compute-0-1 ~]# tcpdump -tttt -r enp0s3-26082018.pcap -reading from file enp0s3-26082018.pcap, link-type EN10MB (Ethernet) -2018-08-25 22:03:17.249648 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 1426167803:1426167927, ack 3061962134, win 291, options -[nop,nop,TS val 81358717 ecr 20378789], length 124 -2018-08-25 22:03:17.249840 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 124, win 564, options [nop,nop,TS val 20378791 ecr 81358 -717], length 0 -2018-08-25 22:03:17.454559 IP controller0.example.com.amqp > compute-0-1.example.com.57836: Flags [.], ack 1079416895, win 1432, options [nop,nop,TS v -al 81352560 ecr 81353913], length 0 -2018-08-25 22:03:17.454642 IP compute-0-1.example.com.57836 > controller0.example.com.amqp: Flags [.], ack 1, win 237, options [nop,nop,TS val 8135892 -2 ecr 81317504], length 0 -2018-08-25 22:03:17.646945 IP compute-0-1.example.com.57788 > controller0.example.com.amqp: Flags [.], seq 106760587:106762035, ack 688390730, win 237 -, options [nop,nop,TS val 81359114 ecr 81350901], length 1448 -2018-08-25 22:03:17.647043 IP compute-0-1.example.com.57788 > controller0.example.com.amqp: Flags [P.], seq 1448:1956, ack 1, win 237, options [nop,no -p,TS val 81359114 ecr 81350901], length 508 -2018-08-25 22:03:17.647502 IP controller0.example.com.amqp > compute-0-1.example.com.57788: Flags [.], ack 1956, win 1432, options [nop,nop,TS val 813 -52753 ecr 81359114], length 0 -......................................................................................................................... - -``` - -### Example:7) Capturing only IP address packets on a specific Interface (-n option) - -Using -n option in tcpdum command we can capture only IP address packets on specific interface, example is shown below, - -``` -[root@compute-0-1 ~]# tcpdump -n -i enp0s3 -``` - -Output of above command would be something like below, -``` -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes -22:22:28.537904 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1433301395:1433301583, ack 3061976250, win 291, options [nop,nop,TS val 82510005 ecr 20666610], length 188 -22:22:28.538173 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 188, win 9086, options [nop,nop,TS val 20666613 ecr 82510005], length 0 -22:22:28.538573 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 188:552, ack 1, win 291, options [nop,nop,TS val 82510006 ecr 20666613], length 364 -22:22:28.538736 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 552, win 9086, options [nop,nop,TS val 20666613 ecr 82510006], length 0 -22:22:28.538874 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 552:892, ack 1, win 291, options [nop,nop,TS val 82510006 ecr 20666613], length 340 -22:22:28.539042 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 892, win 9086, options [nop,nop,TS val 20666613 ecr 82510006], length 0 -22:22:28.539178 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 892:1232, ack 1, win 291, options [nop,nop,TS val 82510006 ecr 20666613], length 340 -22:22:28.539282 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 1232, win 9086, options [nop,nop,TS val 20666614 ecr 82510006], length 0 -22:22:28.539479 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1232:1572, ack 1, win 291, options [nop,nop,TS val 82510006 ecr 20666614], length 340 -22:22:28.539595 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 1572, win 9086, options [nop,nop,TS val 20666614 ecr 82510006], length 0 -22:22:28.539760 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1572:1912, ack 1, win 291, options [nop,nop,TS val 82510007 ecr 20666614], length 340 -......................................................................... - -``` - -You can also capture N number of IP address packets using -c and -n option in tcpdump command, -``` -[root@compute-0-1 ~]# tcpdump -c 25 -n -i enp0s3 - -``` - -### Example:8) Capturing only TCP packets on a specific interface - -In tcpdump command we can capture only tcp packets using the ‘ **tcp** ‘ option, -``` -[root@compute-0-1 ~]# tcpdump -i enp0s3 tcp -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes -22:36:54.521053 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1433336467:1433336655, ack 3061986618, win 291, options [nop,nop,TS val 83375988 ecr 20883106], length 188 -22:36:54.521474 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 188, win 9086, options [nop,nop,TS val 20883109 ecr 83375988], length 0 -22:36:54.522214 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 188:552, ack 1, win 291, options [nop,nop,TS val 83375989 ecr 20883109], length 364 -22:36:54.522508 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 552, win 9086, options [nop,nop,TS val 20883109 ecr 83375989], length 0 -22:36:54.522867 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 552:892, ack 1, win 291, options [nop,nop,TS val 83375990 ecr 20883109], length 340 -22:36:54.523006 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 892, win 9086, options [nop,nop,TS val 20883109 ecr 83375990], length 0 -22:36:54.523304 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 892:1232, ack 1, win 291, options [nop,nop,TS val 83375990 ecr 20883109], length 340 -22:36:54.523461 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 1232, win 9086, options [nop,nop,TS val 20883110 ecr 83375990], length 0 -22:36:54.523604 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1232:1572, ack 1, win 291, options [nop,nop,TS val 83375991 ecr 20883110], length 340 -................................................................................................................................................... - -``` - -### Example:9) Capturing packets from a specific port on a specific interface - -Using tcpdump command we can capture packet from a specific port (e.g 22) on a specific interface enp0s3 - -Syntax : - -``` -# tcpdump -i {interface-name} port {Port_Number} -``` -``` -[root@compute-0-1 ~]# tcpdump -i enp0s3 port 22 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes -22:54:45.032412 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 1435010787:1435010975, ack 3061993834, win 291, options [nop,nop,TS val 84446499 ecr 21150734], length 188 -22:54:45.032631 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 188, win 9131, options [nop,nop,TS val 21150737 ecr 84446499], length 0 -22:54:55.037926 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 188:576, ack 1, win 291, options [nop,nop,TS val 84456505 ecr 21150737], length 388 -22:54:55.038106 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 576, win 9154, options [nop,nop,TS val 21153238 ecr 84456505], length 0 -22:54:55.038286 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 576:940, ack 1, win 291, options [nop,nop,TS val 84456505 ecr 21153238], length 364 -22:54:55.038564 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 940, win 9177, options [nop,nop,TS val 21153238 ecr 84456505], length 0 -22:54:55.038708 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 940:1304, ack 1, win 291, options [nop,nop,TS val 84456506 ecr 21153238], length 364 -............................................................................................................................ -[root@compute-0-1 ~]# - -``` - -### Example:10) Capturing the packets from a Specific Source IP on a Specific Interface - -Using “ **src** ” keyword followed by “ **ip address** ” in tcpdump command we can capture the packets from a specific Source IP, - -syntax : - -``` -# tcpdump -n -i {interface-name} src {ip-address} -``` - -Example is shown below, -``` -[root@compute-0-1 ~]# tcpdump -n -i enp0s3 src 169.144.0.10 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes -23:03:45.912733 IP 169.144.0.10.amqp > 169.144.0.20.57800: Flags [.], ack 526623844, win 243, options [nop,nop,TS val 84981008 ecr 84982372], length 0 -23:03:46.136757 IP 169.144.0.10.amqp > 169.144.0.20.57796: Flags [.], ack 2535995970, win 252, options [nop,nop,TS val 84981232 ecr 84982596], length 0 -23:03:46.153398 IP 169.144.0.10.amqp > 169.144.0.20.57798: Flags [.], ack 3623063621, win 243, options [nop,nop,TS val 84981248 ecr 84982612], length 0 -23:03:46.361160 IP 169.144.0.10.amqp > 169.144.0.20.57802: Flags [.], ack 2140263945, win 252, options [nop,nop,TS val 84981456 ecr 84982821], length 0 -23:03:46.376926 IP 169.144.0.10.amqp > 169.144.0.20.57808: Flags [.], ack 175946224, win 252, options [nop,nop,TS val 84981472 ecr 84982836], length 0 -23:03:46.505242 IP 169.144.0.10.amqp > 169.144.0.20.57810: Flags [.], ack 1016089556, win 252, options [nop,nop,TS val 84981600 ecr 84982965], length 0 -23:03:46.616994 IP 169.144.0.10.amqp > 169.144.0.20.57812: Flags [.], ack 832263835, win 252, options [nop,nop,TS val 84981712 ecr 84983076], length 0 -23:03:46.809344 IP 169.144.0.10.amqp > 169.144.0.20.57814: Flags [.], ack 2781799939, win 252, options [nop,nop,TS val 84981904 ecr 84983268], length 0 -23:03:46.809485 IP 169.144.0.10.amqp > 169.144.0.20.57816: Flags [.], ack 1662816815, win 252, options [nop,nop,TS val 84981904 ecr 84983268], length 0 -23:03:47.033301 IP 169.144.0.10.amqp > 169.144.0.20.57818: Flags [.], ack 2387094362, win 252, options [nop,nop,TS val 84982128 ecr 84983492], length 0 -^C -10 packets captured -12 packets received by filter -0 packets dropped by kernel -[root@compute-0-1 ~]# - -``` - -### Example:11) Capturing packets from a specific destination IP on a specific Interface - -Syntax : - -``` -# tcpdump -n -i {interface-name} dst {IP-address} -``` -``` -[root@compute-0-1 ~]# tcpdump -n -i enp0s3 dst 169.144.0.1 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes -23:10:43.520967 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1439564171:1439564359, ack 3062005550, win 291, options [nop,nop,TS val 85404988 ecr 21390356], length 188 -23:10:43.521441 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 188:408, ack 1, win 291, options [nop,nop,TS val 85404988 ecr 21390359], length 220 -23:10:43.521719 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 408:604, ack 1, win 291, options [nop,nop,TS val 85404989 ecr 21390359], length 196 -23:10:43.521993 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 604:800, ack 1, win 291, options [nop,nop,TS val 85404989 ecr 21390359], length 196 -23:10:43.522157 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 800:996, ack 1, win 291, options [nop,nop,TS val 85404989 ecr 21390359], length 196 -23:10:43.522346 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 996:1192, ack 1, win 291, options [nop,nop,TS val 85404989 ecr 21390359], length 196 -......................................................................................... - -``` - -### Example:12) Capturing TCP packet communication between two Hosts - -Let’s assume i want to capture tcp packets between two hosts 169.144.0.1 & 169.144.0.20, example is shown below, -``` -[root@compute-0-1 ~]# tcpdump -w two-host-tcp-comm.pcap -i enp0s3 tcp and \(host 169.144.0.1 or host 169.144.0.20\) - -``` - -Capturing only SSH packet flow between two hosts using tcpdump command, -``` -[root@compute-0-1 ~]# tcpdump -w ssh-comm-two-hosts.pcap -i enp0s3 src 169.144.0.1 and port 22 and dst 169.144.0.20 and port 22 - -``` - -### Example:13) Capturing the udp network packets (to & fro) between two hosts - -Syntax : - -``` -# tcpdump -w -s -i udp and \(host and host \) -``` -``` -[root@compute-0-1 ~]# tcpdump -w two-host-comm.pcap -s 1000 -i enp0s3 udp and \(host 169.144.0.10 and host 169.144.0.20\) - -``` - -### Example:14) Capturing packets in HEX and ASCII Format - -Using tcpdump command, we can capture tcp/ip packet in ASCII and HEX format, - -To capture the packets in ASCII format use **-A** option, example is shown below, -``` -[root@compute-0-1 ~]# tcpdump -c 10 -A -i enp0s3 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes -00:37:10.520060 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 1452637331:1452637519, ack 3062125586, win 333, options [nop,nop,TS val 90591987 ecr 22687106], length 188 -E...[root@compute-0-1 @...............V.|...T....MT...... -.fR..Z-....b.:..Z5...{.'p....]."}...Z..9.?......."root@compute-0-1 <.....V..C.....{,...OKP.2.*...`..-sS..1S...........:.O[.....{G..%ze.Pn.T..N.... ....qB..5...n.....`...:=...[..0....k.....S.:..5!.9..G....!-..'.. -00:37:10.520319 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 188, win 13930, options [nop,nop,TS val 22687109 ecr 90591987], length 0 -root@compute-0-1 @.|+..............T.V.}O..6j.d..... -.Z-..fR. -00:37:11.687543 IP controller0.example.com.amqp > compute-0-1.example.com.57800: Flags [.], ack 526624548, win 243, options [nop,nop,TS val 90586768 ecr 90588146], length 0 -root@compute-0-1 @.!L... -.....(..g....c.$........... -.f>..fC. -00:37:11.687612 IP compute-0-1.example.com.57800 > controller0.example.com.amqp: Flags [.], ack 1, win 237, options [nop,nop,TS val 90593155 ecr 90551716], length 0 -root@compute-0-1 @.......... -...(.c.$g.......Se..... -.fW..e.. -.................................................................................................................................................. - -``` - -To Capture the packets both in HEX and ASCII format use **-XX** option -``` -[root@compute-0-1 ~]# tcpdump -c 10 -XX -i enp0s3 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes -00:39:15.124363 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 1452640859:1452641047, ack 3062126346, win 333, options [nop,nop,TS val 90716591 ecr 22718257], length 188 -0x0000: 0a00 2700 0000 0800 27f4 f935 0800 4510 ..'.....'..5..E. -0x0010: 00f0 5bc6 4000 4006 8afc a990 0014 a990 ..[root@compute-0-1 @......... -0x0020: 0001 0016 99ee 5695 8a5b b684 570a 8018 ......V..[..W... -0x0030: 014d 5418 0000 0101 080a 0568 39af 015a .MT........h9..Z -0x0040: a731 adb7 58b6 1a0f 2006 df67 c9b6 4479 .1..X......g..Dy -0x0050: 19fd 2c3d 2042 3313 35b9 a160 fa87 d42c ..,=.B3.5..`..., -0x0060: 89a9 3d7d dfbf 980d 2596 4f2a 99ba c92a ..=}....%.O*...* -0x0070: 3e1e 7bf7 3af2 a5cc ee4f 10bc 7dfc 630d >.{.:....O..}.c. -0x0080: 898a 0e16 6825 56c7 b683 1de4 3526 ff04 ....h%V.....5&.. -0x0090: 68d1 4f7d babd 27ba 84ae c5d3 750b 01bd h.O}..'.....u... -0x00a0: 9c43 e10a 33a6 8df2 a9f0 c052 c7ed 2ff5 .C..3......R../. -0x00b0: bfb1 ce84 edfc c141 6dad fa19 0702 62a7 .......Am.....b. -0x00c0: 306c db6b 2eea 824e eea5 acd7 f92e 6de3 0l.k...N......m. -0x00d0: 85d0 222d f8bf 9051 2c37 93c8 506d 5cb5 .."-...Q,7..Pm\. -0x00e0: 3b4a 2a80 d027 49f2 c996 d2d9 a9eb c1c4 ;J*..'I......... -0x00f0: 7719 c615 8486 d84c e42d 0ba3 698c w......L.-..i. -00:39:15.124648 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 188, win 13971, options [nop,nop,TS val 22718260 ecr 90716591], length 0 -0x0000: 0800 27f4 f935 0a00 2700 0000 0800 4510 ..'..5..'.....E. -0x0010: 0034 6b70 4000 4006 7c0e a990 0001 a990 root@compute-0-1 @.|....... -0x0020: 0014 99ee 0016 b684 570a 5695 8b17 8010 ........W.V..... -0x0030: 3693 7c0e 0000 0101 080a 015a a734 0568 6.|........Z.4.h -0x0040: 39af -....................................................................... - -``` - -That’s all from this article, i hope you got an idea how to capture and analyze tcp/ip packets using tcpdump command. Please do share your feedback and comments. - --------------------------------------------------------------------------------- - -via: https://www.linuxtechi.com/capture-analyze-packets-tcpdump-command-linux/ - -作者:[Pradeep Kumar][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://www.linuxtechi.com/author/pradeep/ -[1]:https://www.linuxtechi.com/wp-content/uploads/2018/08/N-Number-Packsets-tcpdump-interface-1024x422.jpg -[2]:https://www.linuxtechi.com/wp-content/uploads/2018/08/N-Number-Packsets-tcpdump-interface.jpg From 43c45b022777592adfba073cb66b61f726633ba6 Mon Sep 17 00:00:00 2001 From: ypingcn <1344632698@qq.com> Date: Mon, 3 Sep 2018 11:26:17 +0800 Subject: [PATCH 035/455] Create 20180826 How to capture and analyze packets with tcpdump command on Linux.md --- ...e packets with tcpdump command on Linux.md | 427 ++++++++++++++++++ 1 file changed, 427 insertions(+) create mode 100644 translated/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md diff --git a/translated/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md b/translated/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md new file mode 100644 index 0000000000..307aeeb0ec --- /dev/null +++ b/translated/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md @@ -0,0 +1,427 @@ +如何在 Linux 上使用 tcpdump 命令捕获和分析数据包 +====== +tcpdump 是一个有名的命令行**数据包分析**工具。我们可以使用 tcpdump 命令捕获实时 TCP/IP 数据包,这些数据包也可以保存到文件中。之后这些捕获的数据包可以通过 tcpdump 命令进行分析。tcpdump 命令在网络级故障排除时变得非常方便。 + +![](https://www.linuxtechi.com/wp-content/uploads/2018/08/tcpdump-command-examples-linux.jpg) + +tcpdump 在大多数 Linux 发行版中都能用,对于基于 Debian 的Linux,可以使用 apt 命令安装它 + +``` +# apt install tcpdump -y +``` + +在基于 RPM 的 Linux 操作系统上,可以使用下面的 yum 命令安装 tcpdump + +``` +# yum install tcpdump -y +``` + +当我们在没用任何选项的情况下运行 tcpdump 命令时,它将捕获所有接口的数据包。因此,要停止或取消 tcpdump 命令,请输入 '**ctrl+c**'。在本教程中,我们将使用不同的实例来讨论如何捕获和分析数据包, + +### 示例: 1) 从特定接口捕获数据包 + +当我们在没用任何选项的情况下运行 tcpdump 命令时,它将捕获所有接口上的数据包,因此,要从特定接口捕获数据包,请使用选项 '**-i**',后跟接口名称。 + +语法: + +``` +# tcpdump -i {接口名} +``` + +假设我想从接口“enp0s3”捕获数据包 + +输出将如下所示, + +``` +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes +06:43:22.905890 IP compute-0-1.example.com.ssh > 169.144.0.1.39374: Flags [P.], seq 21952160:21952540, ack 13537, win 291, options [nop,nop,TS val 26164373 ecr 6580205], length 380 +06:43:22.906045 IP compute-0-1.example.com.ssh > 169.144.0.1.39374: Flags [P.], seq 21952540:21952760, ack 13537, win 291, options [nop,nop,TS val 26164373 ecr 6580205], length 220 +06:43:22.906150 IP compute-0-1.example.com.ssh > 169.144.0.1.39374: Flags [P.], seq 21952760:21952980, ack 13537, win 291, options [nop,nop,TS val 26164373 ecr 6580205], length 220 +06:43:22.906291 IP 169.144.0.1.39374 > compute-0-1.example.com.ssh: Flags [.], ack 21952980, win 13094, options [nop,nop,TS val 6580205 ecr 26164373], length 0 +06:43:22.906303 IP 169.144.0.1.39374 > compute-0-1.example.com.ssh: Flags [P.], seq 13537:13609, ack 21952980, win 13094, options [nop,nop,TS val 6580205 ecr 26164373], length 72 +06:43:22.906322 IP compute-0-1.example.com.ssh > 169.144.0.1.39374: Flags [P.], seq 21952980:21953200, ack 13537, win 291, options [nop,nop,TS val 26164373 ecr 6580205], length 220 +^C +109930 packets captured +110065 packets received by filter +133 packets dropped by kernel +[[email protected] ~]# + +``` + +### 示例: 2) 从特定接口捕获特定数量数据包 + +假设我们想从特定接口(如“enp0s3”)捕获12个数据包,这可以使用选项 '**-c {数量} -I {接口名称}**' 轻松实现 + +``` +root@compute-0-1 ~]# tcpdump -c 12 -i enp0s3 +``` + +上面的命令将生成如下所示的输出 + +[![N-Number-Packsets-tcpdump-interface][1]][2] + +### 示例: 3) 显示 tcpdump 的所有可用接口 + +使用 '**-D**' 选项显示 tcpdump 命令的所有可用接口, + +``` +[root@compute-0-1 ~]# tcpdump -D +1.enp0s3 +2.enp0s8 +3.ovs-system +4.br-int +5.br-tun +6.nflog (Linux netfilter log (NFLOG) interface) +7.nfqueue (Linux netfilter queue (NFQUEUE) interface) +8.usbmon1 (USB bus number 1) +9.usbmon2 (USB bus number 2) +10.qbra692e993-28 +11.qvoa692e993-28 +12.qvba692e993-28 +13.tapa692e993-28 +14.vxlan_sys_4789 +15.any (Pseudo-device that captures on all interfaces) +16.lo [Loopback] +[[email protected] ~]# +``` + +我正在我的一个openstack计算节点上运行tcpdump命令,这就是为什么在输出中你会看到数字接口、标签接口、网桥和vxlan接口 + +### 示例: 4) 捕获带有可读时间戳(-tttt 选项)的数据包 + +默认情况下,在tcpdump命令输出中,没有显示可读性好的时间戳,如果您想将可读性好的时间戳与每个捕获的数据包相关联,那么使用 '**-tttt**'选项,示例如下所示, + +``` +[[email protected] ~]# tcpdump -c 8 -tttt -i enp0s3 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes +2018-08-25 23:23:36.954883 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 1449206247:1449206435, ack 3062020950, win 291, options [nop,nop,TS val 86178422 ecr 21583714], length 188 +2018-08-25 23:23:36.955046 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 188, win 13585, options [nop,nop,TS val 21583717 ecr 86178422], length 0 +2018-08-25 23:23:37.140097 IP controller0.example.com.amqp > compute-0-1.example.com.57818: Flags [P.], seq 814607956:814607964, ack 2387094506, win 252, options [nop,nop,TS val 86172228 ecr 86176695], length 8 +2018-08-25 23:23:37.140175 IP compute-0-1.example.com.57818 > controller0.example.com.amqp: Flags [.], ack 8, win 237, options [nop,nop,TS val 86178607 ecr 86172228], length 0 +2018-08-25 23:23:37.355238 IP compute-0-1.example.com.57836 > controller0.example.com.amqp: Flags [P.], seq 1080415080:1080417400, ack 1690909362, win 237, options [nop,nop,TS val 86178822 ecr 86163054], length 2320 +2018-08-25 23:23:37.357119 IP controller0.example.com.amqp > compute-0-1.example.com.57836: Flags [.], ack 2320, win 1432, options [nop,nop,TS val 86172448 ecr 86178822], length 0 +2018-08-25 23:23:37.357545 IP controller0.example.com.amqp > compute-0-1.example.com.57836: Flags [P.], seq 1:22, ack 2320, win 1432, options [nop,nop,TS val 86172449 ecr 86178822], length 21 +2018-08-25 23:23:37.357572 IP compute-0-1.example.com.57836 > controller0.example.com.amqp: Flags [.], ack 22, win 237, options [nop,nop,TS val 86178825 ecr 86172449], length 0 +8 packets captured +134 packets received by filter +69 packets dropped by kernel +[[email protected] ~]# + +``` + +### 示例: 5) 捕获数据包并将其保存到文件( -w 选项) + +使用 tcpdump 命令中的 '**-w**' 选项将捕获的 TCP/IP 数据包保存到一个文件中,以便我们可以在将来分析这些数据包以供进一步分析。 + +语法: + +``` +# tcpdump -w 文件名.pcap -i {接口名} +``` + +注意:文件扩展名必须为 **.pcap** + +假设我要把 '**enp0s3**' 接口捕获到的包保存到文件名为 **enp0s3-26082018.pcap** + +``` +[root@compute-0-1 ~]# tcpdump -w enp0s3-26082018.pcap -i enp0s3 +``` + +上述命令将生成如下所示的输出, + +``` +[root@compute-0-1 ~]# tcpdump -w enp0s3-26082018.pcap -i enp0s3 +tcpdump: listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes +^C841 packets captured +845 packets received by filter +0 packets dropped by kernel +[root@compute-0-1 ~]# ls +anaconda-ks.cfg enp0s3-26082018.pcap +[root@compute-0-1 ~]# + +``` + +捕获并保存大小**大于 N 字节**的数据包 + +``` +[root@compute-0-1 ~]# tcpdump -w enp0s3-26082018-2.pcap greater 1024 +``` + +捕获并保存大小**小于 N 字节**的数据包 + +``` +[root@compute-0-1 ~]# tcpdump -w enp0s3-26082018-3.pcap less 1024 +``` + +### 示例: 6) 从保存的文件中读取数据包( -r 选项) + +在上面的例子中,我们已经将捕获的数据包保存到文件中,我们可以使用选项 '**-r**' 从文件中读取这些数据包,例子如下所示, + +``` +[root@compute-0-1 ~]# tcpdump -r enp0s3-26082018.pcap +``` + +用可读性高的时间戳读取包内容, + +``` +[root@compute-0-1 ~]# tcpdump -tttt -r enp0s3-26082018.pcap +reading from file enp0s3-26082018.pcap, link-type EN10MB (Ethernet) +2018-08-25 22:03:17.249648 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 1426167803:1426167927, ack 3061962134, win 291, options +[nop,nop,TS val 81358717 ecr 20378789], length 124 +2018-08-25 22:03:17.249840 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 124, win 564, options [nop,nop,TS val 20378791 ecr 81358 +717], length 0 +2018-08-25 22:03:17.454559 IP controller0.example.com.amqp > compute-0-1.example.com.57836: Flags [.], ack 1079416895, win 1432, options [nop,nop,TS v +al 81352560 ecr 81353913], length 0 +2018-08-25 22:03:17.454642 IP compute-0-1.example.com.57836 > controller0.example.com.amqp: Flags [.], ack 1, win 237, options [nop,nop,TS val 8135892 +2 ecr 81317504], length 0 +2018-08-25 22:03:17.646945 IP compute-0-1.example.com.57788 > controller0.example.com.amqp: Flags [.], seq 106760587:106762035, ack 688390730, win 237 +, options [nop,nop,TS val 81359114 ecr 81350901], length 1448 +2018-08-25 22:03:17.647043 IP compute-0-1.example.com.57788 > controller0.example.com.amqp: Flags [P.], seq 1448:1956, ack 1, win 237, options [nop,no +p,TS val 81359114 ecr 81350901], length 508 +2018-08-25 22:03:17.647502 IP controller0.example.com.amqp > compute-0-1.example.com.57788: Flags [.], ack 1956, win 1432, options [nop,nop,TS val 813 +52753 ecr 81359114], length 0 +......................................................................................................................... + +``` + +### 示例: 7) 仅捕获特定接口上的 IP 地址数据包( -n 选项) + +使用 tcpdump 命令中的 -n 选项,我们能只捕获特定接口上的 IP 地址数据包,示例如下所示, + +``` +[root@compute-0-1 ~]# tcpdump -n -i enp0s3 +``` + +上述命令输出如下, + +``` +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes +22:22:28.537904 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1433301395:1433301583, ack 3061976250, win 291, options [nop,nop,TS val 82510005 ecr 20666610], length 188 +22:22:28.538173 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 188, win 9086, options [nop,nop,TS val 20666613 ecr 82510005], length 0 +22:22:28.538573 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 188:552, ack 1, win 291, options [nop,nop,TS val 82510006 ecr 20666613], length 364 +22:22:28.538736 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 552, win 9086, options [nop,nop,TS val 20666613 ecr 82510006], length 0 +22:22:28.538874 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 552:892, ack 1, win 291, options [nop,nop,TS val 82510006 ecr 20666613], length 340 +22:22:28.539042 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 892, win 9086, options [nop,nop,TS val 20666613 ecr 82510006], length 0 +22:22:28.539178 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 892:1232, ack 1, win 291, options [nop,nop,TS val 82510006 ecr 20666613], length 340 +22:22:28.539282 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 1232, win 9086, options [nop,nop,TS val 20666614 ecr 82510006], length 0 +22:22:28.539479 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1232:1572, ack 1, win 291, options [nop,nop,TS val 82510006 ecr 20666614], length 340 +22:22:28.539595 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 1572, win 9086, options [nop,nop,TS val 20666614 ecr 82510006], length 0 +22:22:28.539760 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1572:1912, ack 1, win 291, options [nop,nop,TS val 82510007 ecr 20666614], length 340 +......................................................................... + +``` + +您还可以使用 tcpdump 命令中的 -c 和 -N 选项捕获 N 个 IP 地址包, + +``` +[root@compute-0-1 ~]# tcpdump -c 25 -n -i enp0s3 +``` + + +### 示例: 8) 仅捕获特定接口上的TCP数据包 + +在 tcpdump 命令中,我们能使用 '**tcp**' 选项来只捕获TCP数据包, + +``` +[root@compute-0-1 ~]# tcpdump -i enp0s3 tcp +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes +22:36:54.521053 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1433336467:1433336655, ack 3061986618, win 291, options [nop,nop,TS val 83375988 ecr 20883106], length 188 +22:36:54.521474 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 188, win 9086, options [nop,nop,TS val 20883109 ecr 83375988], length 0 +22:36:54.522214 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 188:552, ack 1, win 291, options [nop,nop,TS val 83375989 ecr 20883109], length 364 +22:36:54.522508 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 552, win 9086, options [nop,nop,TS val 20883109 ecr 83375989], length 0 +22:36:54.522867 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 552:892, ack 1, win 291, options [nop,nop,TS val 83375990 ecr 20883109], length 340 +22:36:54.523006 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 892, win 9086, options [nop,nop,TS val 20883109 ecr 83375990], length 0 +22:36:54.523304 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 892:1232, ack 1, win 291, options [nop,nop,TS val 83375990 ecr 20883109], length 340 +22:36:54.523461 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 1232, win 9086, options [nop,nop,TS val 20883110 ecr 83375990], length 0 +22:36:54.523604 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1232:1572, ack 1, win 291, options [nop,nop,TS val 83375991 ecr 20883110], length 340 +................................................................................................................................................... +``` + +### 示例: 9) 从特定接口上的特定端口捕获数据包 + +使用 tcpdump 命令,我们可以从特定接口 enp0s3 上的特定端口(例如 22 )捕获数据包 + +语法: + +``` +# tcpdump -i {interface-name} port {Port_Number} +``` +``` +[root@compute-0-1 ~]# tcpdump -i enp0s3 port 22 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes +22:54:45.032412 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 1435010787:1435010975, ack 3061993834, win 291, options [nop,nop,TS val 84446499 ecr 21150734], length 188 +22:54:45.032631 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 188, win 9131, options [nop,nop,TS val 21150737 ecr 84446499], length 0 +22:54:55.037926 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 188:576, ack 1, win 291, options [nop,nop,TS val 84456505 ecr 21150737], length 388 +22:54:55.038106 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 576, win 9154, options [nop,nop,TS val 21153238 ecr 84456505], length 0 +22:54:55.038286 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 576:940, ack 1, win 291, options [nop,nop,TS val 84456505 ecr 21153238], length 364 +22:54:55.038564 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 940, win 9177, options [nop,nop,TS val 21153238 ecr 84456505], length 0 +22:54:55.038708 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 940:1304, ack 1, win 291, options [nop,nop,TS val 84456506 ecr 21153238], length 364 +............................................................................................................................ +[root@compute-0-1 ~]# +``` + + +### 示例: 10) 在特定接口上捕获来自特定来源 IP 的数据包 + +在tcpdump命令中,使用 '**src**' 关键字后跟 '**IP 地址**',我们可以捕获来自特定来源 IP 的数据包, + +语法: + +``` +# tcpdump -n -i {接口名} src {IP 地址} +``` + +例子如下, + +``` +[root@compute-0-1 ~]# tcpdump -n -i enp0s3 src 169.144.0.10 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes +23:03:45.912733 IP 169.144.0.10.amqp > 169.144.0.20.57800: Flags [.], ack 526623844, win 243, options [nop,nop,TS val 84981008 ecr 84982372], length 0 +23:03:46.136757 IP 169.144.0.10.amqp > 169.144.0.20.57796: Flags [.], ack 2535995970, win 252, options [nop,nop,TS val 84981232 ecr 84982596], length 0 +23:03:46.153398 IP 169.144.0.10.amqp > 169.144.0.20.57798: Flags [.], ack 3623063621, win 243, options [nop,nop,TS val 84981248 ecr 84982612], length 0 +23:03:46.361160 IP 169.144.0.10.amqp > 169.144.0.20.57802: Flags [.], ack 2140263945, win 252, options [nop,nop,TS val 84981456 ecr 84982821], length 0 +23:03:46.376926 IP 169.144.0.10.amqp > 169.144.0.20.57808: Flags [.], ack 175946224, win 252, options [nop,nop,TS val 84981472 ecr 84982836], length 0 +23:03:46.505242 IP 169.144.0.10.amqp > 169.144.0.20.57810: Flags [.], ack 1016089556, win 252, options [nop,nop,TS val 84981600 ecr 84982965], length 0 +23:03:46.616994 IP 169.144.0.10.amqp > 169.144.0.20.57812: Flags [.], ack 832263835, win 252, options [nop,nop,TS val 84981712 ecr 84983076], length 0 +23:03:46.809344 IP 169.144.0.10.amqp > 169.144.0.20.57814: Flags [.], ack 2781799939, win 252, options [nop,nop,TS val 84981904 ecr 84983268], length 0 +23:03:46.809485 IP 169.144.0.10.amqp > 169.144.0.20.57816: Flags [.], ack 1662816815, win 252, options [nop,nop,TS val 84981904 ecr 84983268], length 0 +23:03:47.033301 IP 169.144.0.10.amqp > 169.144.0.20.57818: Flags [.], ack 2387094362, win 252, options [nop,nop,TS val 84982128 ecr 84983492], length 0 +^C +10 packets captured +12 packets received by filter +0 packets dropped by kernel +[root@compute-0-1 ~]# + +``` + +### 示例: 11) 在特定接口上捕获来自特定目的IP的数据包 + +语法: + +``` +# tcpdump -n -i {接口名} dst {IP 地址} +``` +``` +[root@compute-0-1 ~]# tcpdump -n -i enp0s3 dst 169.144.0.1 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes +23:10:43.520967 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1439564171:1439564359, ack 3062005550, win 291, options [nop,nop,TS val 85404988 ecr 21390356], length 188 +23:10:43.521441 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 188:408, ack 1, win 291, options [nop,nop,TS val 85404988 ecr 21390359], length 220 +23:10:43.521719 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 408:604, ack 1, win 291, options [nop,nop,TS val 85404989 ecr 21390359], length 196 +23:10:43.521993 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 604:800, ack 1, win 291, options [nop,nop,TS val 85404989 ecr 21390359], length 196 +23:10:43.522157 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 800:996, ack 1, win 291, options [nop,nop,TS val 85404989 ecr 21390359], length 196 +23:10:43.522346 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 996:1192, ack 1, win 291, options [nop,nop,TS val 85404989 ecr 21390359], length 196 +......................................................................................... + +``` + +### 示例: 12) 捕获两台主机之间的 TCP 数据包通信 + +假设我想捕获两台主机 169.144.0.1 和 169.144.0.20 之间的 TCP 数据包,示例如下所示, + +``` +[root@compute-0-1 ~]# tcpdump -w two-host-tcp-comm.pcap -i enp0s3 tcp and \(host 169.144.0.1 or host 169.144.0.20\) + +``` + +使用 tcpdump 命令只捕获两台主机之间的 SSH 数据包流, + +``` +[root@compute-0-1 ~]# tcpdump -w ssh-comm-two-hosts.pcap -i enp0s3 src 169.144.0.1 and port 22 and dst 169.144.0.20 and port 22 + +``` + +示例: 13) 捕获两台主机之间的 UDP 网络数据包(来回) + +语法: + +``` +# tcpdump -w -s -i udp and \(host and host \) +``` +``` +[root@compute-0-1 ~]# tcpdump -w two-host-comm.pcap -s 1000 -i enp0s3 udp and \(host 169.144.0.10 and host 169.144.0.20\) + +``` + +### 示例: 14) 捕获十六进制和ASCII格式的数据包 + +使用 tcpdump 命令,我们可以以 ASCII 和十六进制格式捕获 TCP/IP 数据包, + +要使用** -A **选项捕获ASCII格式的数据包,示例如下所示: + +``` +[root@compute-0-1 ~]# tcpdump -c 10 -A -i enp0s3 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes +00:37:10.520060 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 1452637331:1452637519, ack 3062125586, win 333, options [nop,nop,TS val 90591987 ecr 22687106], length 188 +E...[root@compute-0-1 @...............V.|...T....MT...... +.fR..Z-....b.:..Z5...{.'p....]."}...Z..9.?......."root@compute-0-1 <.....V..C.....{,...OKP.2.*...`..-sS..1S...........:.O[.....{G..%ze.Pn.T..N.... ....qB..5...n.....`...:=...[..0....k.....S.:..5!.9..G....!-..'.. +00:37:10.520319 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 188, win 13930, options [nop,nop,TS val 22687109 ecr 90591987], length 0 +root@compute-0-1 @.|+..............T.V.}O..6j.d..... +.Z-..fR. +00:37:11.687543 IP controller0.example.com.amqp > compute-0-1.example.com.57800: Flags [.], ack 526624548, win 243, options [nop,nop,TS val 90586768 ecr 90588146], length 0 +root@compute-0-1 @.!L... +.....(..g....c.$........... +.f>..fC. +00:37:11.687612 IP compute-0-1.example.com.57800 > controller0.example.com.amqp: Flags [.], ack 1, win 237, options [nop,nop,TS val 90593155 ecr 90551716], length 0 +root@compute-0-1 @.......... +...(.c.$g.......Se..... +.fW..e.. +.................................................................................................................................................. +``` + +要同时以十六进制和 ASCII 格式捕获数据包,请使用** -XX **选项 + +``` +[root@compute-0-1 ~]# tcpdump -c 10 -XX -i enp0s3 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes +00:39:15.124363 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 1452640859:1452641047, ack 3062126346, win 333, options [nop,nop,TS val 90716591 ecr 22718257], length 188 +0x0000: 0a00 2700 0000 0800 27f4 f935 0800 4510 ..'.....'..5..E. +0x0010: 00f0 5bc6 4000 4006 8afc a990 0014 a990 ..[root@compute-0-1 @......... +0x0020: 0001 0016 99ee 5695 8a5b b684 570a 8018 ......V..[..W... +0x0030: 014d 5418 0000 0101 080a 0568 39af 015a .MT........h9..Z +0x0040: a731 adb7 58b6 1a0f 2006 df67 c9b6 4479 .1..X......g..Dy +0x0050: 19fd 2c3d 2042 3313 35b9 a160 fa87 d42c ..,=.B3.5..`..., +0x0060: 89a9 3d7d dfbf 980d 2596 4f2a 99ba c92a ..=}....%.O*...* +0x0070: 3e1e 7bf7 3af2 a5cc ee4f 10bc 7dfc 630d >.{.:....O..}.c. +0x0080: 898a 0e16 6825 56c7 b683 1de4 3526 ff04 ....h%V.....5&.. +0x0090: 68d1 4f7d babd 27ba 84ae c5d3 750b 01bd h.O}..'.....u... +0x00a0: 9c43 e10a 33a6 8df2 a9f0 c052 c7ed 2ff5 .C..3......R../. +0x00b0: bfb1 ce84 edfc c141 6dad fa19 0702 62a7 .......Am.....b. +0x00c0: 306c db6b 2eea 824e eea5 acd7 f92e 6de3 0l.k...N......m. +0x00d0: 85d0 222d f8bf 9051 2c37 93c8 506d 5cb5 .."-...Q,7..Pm\. +0x00e0: 3b4a 2a80 d027 49f2 c996 d2d9 a9eb c1c4 ;J*..'I......... +0x00f0: 7719 c615 8486 d84c e42d 0ba3 698c w......L.-..i. +00:39:15.124648 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 188, win 13971, options [nop,nop,TS val 22718260 ecr 90716591], length 0 +0x0000: 0800 27f4 f935 0a00 2700 0000 0800 4510 ..'..5..'.....E. +0x0010: 0034 6b70 4000 4006 7c0e a990 0001 a990 root@compute-0-1 @.|....... +0x0020: 0014 99ee 0016 b684 570a 5695 8b17 8010 ........W.V..... +0x0030: 3693 7c0e 0000 0101 080a 015a a734 0568 6.|........Z.4.h +0x0040: 39af +....................................................................... + +``` + +这就是本文的全部内容,我希望您能了解如何使用 tcpdump 命令捕获和分析 TCP/IP 数据包。请分享你的反馈和评论。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/capture-analyze-packets-tcpdump-command-linux/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[ypingcn](https://github.com/ypingcn) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.linuxtechi.com/author/pradeep/ +[1]: https://www.linuxtechi.com/wp-content/uploads/2018/08/N-Number-Packsets-tcpdump-interface-1024x422.jpg +[2]: https://www.linuxtechi.com/wp-content/uploads/2018/08/N-Number-Packsets-tcpdump-interface.jpg From 7b0766710b6edb15e228fae2204b781d266e33b1 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Mon, 3 Sep 2018 12:07:34 +0800 Subject: [PATCH 036/455] tranlated --- ...ges of Go that you dont hear much about.md | 100 +++++++++--------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/translated/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md b/translated/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md index 2c5c6b3177..24a6190f00 100644 --- a/translated/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md +++ b/translated/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md @@ -35,7 +35,7 @@ Golang 是可能是最近几年里你经常听人说起的编程语言。尽管 * 反射(Reflection) -* 专制独裁的 Go +* Opinionatedness(专制独裁的 Go) * 文化 @@ -60,7 +60,7 @@ GoDoc 是 Go 的唯一文档引擎,供整个社区使用。这意味着用 Go Go 严重依赖于静态代码分析。例子包括 godoc 文档,gofmt 代码格式化,golint 代码风格统一,等等。 -There are so many of them that there’s even an everything-included-kind-of project called [gometalinter][10] to compose them all into a single utility. +其中有很多甚至全部包含在类似 [gometalinter][10] 的项目中,这些将它们全部组合成一个实用程序。 这些工具通常作为独立的命令行应用程序实现,并可轻松与任何编码环境集成。 @@ -80,101 +80,101 @@ Go 附带内置测试工具,旨在简化和提高效率。它为您提供了 它可以开箱即用地生成持续集成友好的输出,而且它的用法很简单,只需运行 `go test`。当然,它还支持高级功能,如并行运行测试,跳过标记代码,以及其他更多功能。 -### Race condition detection +### 竞争条件检测 -You might already know about Goroutines, which are used in Go to achieve concurrent code execution. If you don’t, [here’s][12] a really brief explanation. +您可能已经了解了 Goroutines,它们在 Go 中用于实现并发代码执行。如果你未曾了解过,[这里][12]有一个非常简短的解释。 -Concurrent programming in complex applications is never easy regardless of the specific technique, partly due to the possibility of race conditions. +无论具体技术如何,复杂应用中的并发编程都不容易,部分原因在于竞争条件的可能性。 -Simply put, race conditions happen when several concurrent operations finish in an unpredicted order. It might lead to a huge number of bugs, which are particularly hard to chase down. Ever spent a day debugging an integration test which only worked in about 80% of executions? It probably was a race condition. +简单地说,当几个并发操作以不可预测的顺序完成时,竞争条件就会发生。它可能会导致大量的错误,特别难以追查。如果你曾经花了一天时间调试集成测试,该测试仅在大约 80% 的执行中起作用?这可能是竞争条件引起的。 -All that said, concurrent programming is taken very seriously in Go and, luckily, we have quite a powerful tool to hunt those race conditions down. It is fully integrated into Go’s toolchain. +总而言之,在 Go 中非常重视并发编程,幸运的是,我们有一个强大的工具来捕捉这些竞争条件。它完全集成到 Go 的工具链中。 -You can read more about it and learn how to use it here: [Introducing the Go Race Detector — The Go Blog][13]. +您可以在这里阅读更多相关信息并了解如何使用它:[介绍 Go 中的竞争条件检测 - Go Blog][13]。 -### Learning curve +### 学习曲线 -You can learn ALL Go’s language features in one evening. I mean it. Of course, there are also the standard library, and the best practices in different, more specific areas. But two hours would totally be enough time to get you confidently writing a simple HTTP server, or a command-line app. +您可以在一个晚上学习所有 Go 的语言功能。我是认真的。当然,还有标准库,以及不同,更具体领域的最佳实践。但是两个小时就足以让你自信地编写一个简单的 HTTP 服务器或命令行应用程序。 -The project has [marvelous documentation][14], and most of the advanced topics have already been covered on their blog: [The Go Programming Language Blog][15]. +Golang 拥有[出色的文档][14],大部分高级主题已经在博客上进行了介绍:[The Go Programming Language Blog][15]。 -Go is much easier to bring to your team than Java (and the family), Javascript, Ruby, Python, or even PHP. The environment is easy to setup, and the investment your team needs to make is much smaller before they can complete your first production code. +比起 Java(以及 Java 家族的语言),Javascript,Ruby,Python 甚至 PHP,你可以更轻松地把 Go 语言带到你的团队中。由于环境易于设置,您的团队在完成第一个生产代码之前需要进行的投资要小得多。 -### Reflection +### 反射(Reflection) -Code reflection is essentially an ability to sneak under the hood and access different kinds of meta-information about your language constructs, such as variables or functions. +代码反射本质上是一种隐藏在编译器下并访问有关语言结构的各种元信息的能力,例如变量或函数。 -Given that Go is a statically typed language, it’s exposed to a number of various limitations when it comes to more loosely typed abstract programming. Especially compared to languages like Javascript or Python. +鉴于 Go 是一种静态类型语言,当涉及更松散类型的抽象编程时,它会受到许多各种限制。特别是与 Javascript 或 Python 等语言相比。 -Moreover, Go [doesn’t implement a concept called Generics][16] which makes it even more challenging to work with multiple types in an abstract way. Nevertheless, many people think it’s actually beneficial for the language because of the amount of complexity Generics bring along. And I totally agree. +此外,Go [没有实现一个名为泛型的概念][16],这使得以抽象方式处理多种类型更具挑战性。然而,由于泛型带来的复杂程度,许多人认为不实现泛型对语言实际上是有益的。我完全同意。 -According to Go’s philosophy (which is a separate topic itself), you should try hard to not over-engineer your solutions. And this also applies to dynamically-typed programming. Stick to static types as much as possible, and use interfaces when you know exactly what sort of types you’re dealing with. Interfaces are very powerful and ubiquitous in Go. +根据 Go 的理念(这是一个单独的主题),您应该努力不要过度设计您的解决方案。这也适用于动态类型编程。尽可能坚持使用静态类型,并在确切知道要处理的类型时使用接口(interfaces)。接口在 Go 中非常强大且无处不在。 -However, there are still cases in which you can’t possibly know what sort of data you are facing. A great example is JSON. You convert all the kinds of data back and forth in your applications. Strings, buffers, all sorts of numbers, nested structs and more. +但是,仍然存在一些情况,你无法知道你处理的数据类型。一个很好的例子是 JSON。您可以在应用程序中来回转换所有类型的数据。字符串,缓冲区,各种数字,嵌套结构等。 -In order to pull that off, you need a tool to examine all the data in runtime that acts differently depending on its type and structure. Reflection to rescue! Go has a first-class [reflect][17] package to enable your code to be as dynamic as it would be in a language like Javascript. +为了解决这个问题,您需要一个工具来检查运行时的数据并根据其类型和结构采取不同行为。反射(Reflect)可以帮到你。Go 拥有一流的反射包,使您的代码能够像 Javascript 这样的语言一样动态。 -An important caveat is to know what price you pay for using it — and only use it when there is no simpler way. +一个重要的警告是知道你使用它所带来的代价 - 并且只有知道在没有更简单的方法时才使用它。 -You can read more about it here: [The Laws of Reflection — The Go Blog][18]. +你可以在这里阅读更多相关信息: [反射的法则 — Go 博客][18]. -You can also read some real code from the JSON package sources here: [src/encoding/json/encode.go — Source Code][19] +您还可以在此处阅读 JSON 包源码中的一些实际代码: [src/encoding/json/encode.go — Source Code][19] ### Opinionatedness -Is there such a word, by the way? +顺便问一下,有这样一个单词吗? -Coming from the Javascript world, one of the most daunting processes I faced was deciding which conventions and tools I needed to use. How should I style my code? What testing library should I use? How should I go about structure? What programming paradigms and approaches should I rely on? +来自 Javascript 世界,我面临的最艰巨的困难之一是决定我需要使用哪些约定和工具。我应该如何设计代码?我应该使用什么测试库?我该怎么设计结构?我应该依赖哪些编程范例和方法? -Which sometimes basically got me stuck. I was doing this instead of writing the code and satisfying the users. +这有时候基本上让我卡住了。我需要花时间思考这些事情而不是编写代码并满足用户。 -To begin with, I should note that I totally get where those conventions should come from. It’s always you and your team. Anyway, even a group of experienced Javascript developers can easily find themselves having most of the experience with entirely different tools and paradigms to achieve kind of the same results. +首先,我应该注意到我完全可以得到这些惯例的来源,它总是来源于你或者你的团队。无论如何,即使是一群经验丰富的 Javascript 开发人员也可以轻松地发现自己拥有完全不同的工具和范例的大部分经验,以实现相同的结果。 -This makes the analysis paralysis cloud explode over the whole team, and also makes it harder for the individuals to integrate with each other. +这导致整个团队中分析的瘫痪,并且使得个体之间更难以相互协作。 -Well, Go is different. You have only one style guide that everyone follows. You have only one testing framework which is built into the basic toolchain. You have a lot of strong opinions on how to structure and maintain your code. How to pick names. What structuring patterns to follow. How to do concurrency better. +嗯,Go 是不同的。即使您对如何构建和维护代码有很多强烈的意见,例如:如何命名,要遵循哪些结构模式,如何更好地实现并发。但你只有一个每个人都遵循的风格指南。你只有一个内置在基本工具链中的测试框架。 -While this might seem too restrictive, it saves tons of time for you and your team. Being somewhat limited is actually a great thing when you are coding. It gives you a more straightforward way to go when architecting new code, and makes it easier to reason about the existing one. +虽然这似乎过于严格,但它为您和您的团队节省了大量时间。当你写代码时,受一点限制实际上是一件好事。在构建新代码时,它为您提供了一种更直接的方法,并且可以更容易地调试现有代码。 -As a result, most of the Go projects look pretty alike code-wise. +因此,大多数 Go 项目在代码方面看起来非常相似。 -### Culture +### 文化 -People say that every time you learn a new spoken language, you also soak in some part of the culture of the people who speak that language. Thus, the more languages you learn, more personal changes you might experience. +人们说,每当你学习一门新的口语时,你也会沉浸在说这种语言的人的某些文化中。因此,您学习的语言越多,您可能会有更多的变化。 -It’s the same with programming languages. Regardless of how you are going to apply a new programming language in the future, it always gives you a new perspective on programming in general, or on some specific techniques. +编程语言也是如此。无论您将来如何应用新的编程语言,它总能给的带来新的编程视角或某些特别的技术。 -Be it functional programming, pattern matching, or prototypal inheritance. Once you’ve learned it, you carry these approaches with you which broadens the problem-solving toolset that you have as a software developer. It also changes the way you see high-quality programming in general. +无论是函数式编程,模式匹配(pattern matching)还是原型继承(prototypal inheritance)。一旦你学会了它们,你就可以随身携带这些编程思想,这扩展了你作为软件开发人员所拥有的问题解决工具集。它们也改变了你阅读高质量代码的方式。 -And Go is a terrific investment here. The main pillar of Go’s culture is keeping simple, down-to-earth code without creating many redundant abstractions and putting the maintainability at the top. It’s also a part of the culture to spend the most time actually working on the codebase, instead of tinkering with the tools and the environment. Or choosing between different variations of those. +而 Go 在方面有一项了不起的财富。Go 文化的主要支柱是保持简单,脚踏实地的代码,而不会产生许多冗余的抽象概念,并将可维护性放在首位。大部分时间花费在代码的编写工作上,而不是在修补工具和环境或者选择不同的实现方式上,这也是 Go文化的一部分。 -Go is also all about “there should be only one way of doing a thing.” +Go 文化也可以总结为:“应当只用一种方法去做一件事”。 -A little side note. It’s also partially true that Go usually gets in your way when you need to build relatively complex abstractions. Well, I’d say that’s the tradeoff for its simplicity. +一点注意事项。当你需要构建相对复杂的抽象代码时,Go 通常会妨碍你。好吧,我会说这是简单的权衡。 -If you really need to write a lot of abstract code with complex relationships, you’d be better off using languages like Java or Python. However, even when it’s not obvious, it’s very rarely the case. +如果你真的需要编写大量具有复杂关系的抽象代码,那么最好使用 Java 或 Python 等语言。然而,这种情况却很少。 -Always use the best tool for the job! +在工作时始终使用最好的工具! -### Conclusion +### 总结 -You might have heard of Go before. Or maybe it’s something that has been staying out of your radar for a while. Either way, chances are, Go can be a very decent choice for you or your team when starting a new project or improving the existing one. +你或许之前听说过 Go,或者它暂时在你圈子以外的地方。但无论怎样,在开始新项目或改进现有项目时,Go 可能是您或您团队的一个非常不错的选择。 -This is not a complete list of all the amazing things about Go. Just the undervalued ones. +这不是 Go 的所有惊人的优点的完整列表,只是一些被人低估的特性。 -Please, give Go a try with [A Tour of Go][20] which is an incredible place to start. +请尝试一下从 [Go 之旅(A Tour of Go)][20]来开始学习 Go,这将是一个令人惊叹的开始。 -If you wish to learn more about Go’s benefits, you can check out these links: +如果您想了解有关 Go 的优点的更多信息,可以查看以下链接: -* [Why should you learn Go? — Keval Patel — Medium][2] +* [你为什么要学习 Go? - Keval Patel][2] -* [Farewell Node.js — TJ Holowaychuk — Medium][3] +* [告别Node.js - TJ Holowaychuk][3] -Share your observations down in the comments! +并在评论中分享您的阅读感悟! -Even if you are not specifically looking for a new language to use, it’s worth it to spend an hour or two getting the feel of it. And maybe it can become quite useful for you in the future. +即使您不是为了专门寻找新的编程语言语言,也值得花一两个小时来感受它。也许它对你来说可能会变得非常有用。 -Always be looking for the best tools for your craft! +不断为您的工作寻找最好的工具! * * * @@ -194,7 +194,7 @@ Software Engineer and Traveler. Coding for fun. Javascript enthusiast. Tinkering via: https://medium.freecodecamp.org/here-are-some-amazing-advantages-of-go-that-you-dont-hear-much-about-1af99de3b23a 作者:[Kirill Rogovoy][a] -译者:[译者ID](https://github.com/译者ID) +译者:[译者ID](https://github.com/imquanquan) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 751c4e230f6c1fa79c19ac87fc03b47794acac35 Mon Sep 17 00:00:00 2001 From: imquanquan Date: Mon, 3 Sep 2018 12:07:34 +0800 Subject: [PATCH 037/455] =?UTF-8?q?=20=E8=BF=99=E6=98=AF=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=202=20=E4=B8=AA=E6=8F=90=E4=BA=A4=E7=9A=84=E7=BB=84=E5=90=88?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tranlated tranlated --- ...ges of Go that you dont hear much about.md | 101 +++++++++--------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/translated/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md b/translated/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md index 2c5c6b3177..954d800b25 100644 --- a/translated/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md +++ b/translated/tech/20180201 Here are some amazing advantages of Go that you dont hear much about.md @@ -35,11 +35,10 @@ Golang 是可能是最近几年里你经常听人说起的编程语言。尽管 * 反射(Reflection) -* 专制独裁的 Go +* Opinionatedness(专制独裁的 Go) * 文化 -Please, note that the list doesn’t follow any particular order. It is also opinionated as hell. 请注意,这个列表不遵循任何特定顺序来讨论。 ### GoDoc @@ -60,7 +59,7 @@ GoDoc 是 Go 的唯一文档引擎,供整个社区使用。这意味着用 Go Go 严重依赖于静态代码分析。例子包括 godoc 文档,gofmt 代码格式化,golint 代码风格统一,等等。 -There are so many of them that there’s even an everything-included-kind-of project called [gometalinter][10] to compose them all into a single utility. +其中有很多甚至全部包含在类似 [gometalinter][10] 的项目中,这些将它们全部组合成一个实用程序。 这些工具通常作为独立的命令行应用程序实现,并可轻松与任何编码环境集成。 @@ -80,101 +79,101 @@ Go 附带内置测试工具,旨在简化和提高效率。它为您提供了 它可以开箱即用地生成持续集成友好的输出,而且它的用法很简单,只需运行 `go test`。当然,它还支持高级功能,如并行运行测试,跳过标记代码,以及其他更多功能。 -### Race condition detection +### 竞争条件检测 -You might already know about Goroutines, which are used in Go to achieve concurrent code execution. If you don’t, [here’s][12] a really brief explanation. +您可能已经了解了 Goroutines,它们在 Go 中用于实现并发代码执行。如果你未曾了解过,[这里][12]有一个非常简短的解释。 -Concurrent programming in complex applications is never easy regardless of the specific technique, partly due to the possibility of race conditions. +无论具体技术如何,复杂应用中的并发编程都不容易,部分原因在于竞争条件的可能性。 -Simply put, race conditions happen when several concurrent operations finish in an unpredicted order. It might lead to a huge number of bugs, which are particularly hard to chase down. Ever spent a day debugging an integration test which only worked in about 80% of executions? It probably was a race condition. +简单地说,当几个并发操作以不可预测的顺序完成时,竞争条件就会发生。它可能会导致大量的错误,特别难以追查。如果你曾经花了一天时间调试集成测试,该测试仅在大约 80% 的执行中起作用?这可能是竞争条件引起的。 -All that said, concurrent programming is taken very seriously in Go and, luckily, we have quite a powerful tool to hunt those race conditions down. It is fully integrated into Go’s toolchain. +总而言之,在 Go 中非常重视并发编程,幸运的是,我们有一个强大的工具来捕捉这些竞争条件。它完全集成到 Go 的工具链中。 -You can read more about it and learn how to use it here: [Introducing the Go Race Detector — The Go Blog][13]. +您可以在这里阅读更多相关信息并了解如何使用它:[介绍 Go 中的竞争条件检测 - Go Blog][13]。 -### Learning curve +### 学习曲线 -You can learn ALL Go’s language features in one evening. I mean it. Of course, there are also the standard library, and the best practices in different, more specific areas. But two hours would totally be enough time to get you confidently writing a simple HTTP server, or a command-line app. +您可以在一个晚上学习所有 Go 的语言功能。我是认真的。当然,还有标准库,以及不同,更具体领域的最佳实践。但是两个小时就足以让你自信地编写一个简单的 HTTP 服务器或命令行应用程序。 -The project has [marvelous documentation][14], and most of the advanced topics have already been covered on their blog: [The Go Programming Language Blog][15]. +Golang 拥有[出色的文档][14],大部分高级主题已经在博客上进行了介绍:[The Go Programming Language Blog][15]。 -Go is much easier to bring to your team than Java (and the family), Javascript, Ruby, Python, or even PHP. The environment is easy to setup, and the investment your team needs to make is much smaller before they can complete your first production code. +比起 Java(以及 Java 家族的语言),Javascript,Ruby,Python 甚至 PHP,你可以更轻松地把 Go 语言带到你的团队中。由于环境易于设置,您的团队在完成第一个生产代码之前需要进行的投资要小得多。 -### Reflection +### 反射(Reflection) -Code reflection is essentially an ability to sneak under the hood and access different kinds of meta-information about your language constructs, such as variables or functions. +代码反射本质上是一种隐藏在编译器下并访问有关语言结构的各种元信息的能力,例如变量或函数。 -Given that Go is a statically typed language, it’s exposed to a number of various limitations when it comes to more loosely typed abstract programming. Especially compared to languages like Javascript or Python. +鉴于 Go 是一种静态类型语言,当涉及更松散类型的抽象编程时,它会受到许多各种限制。特别是与 Javascript 或 Python 等语言相比。 -Moreover, Go [doesn’t implement a concept called Generics][16] which makes it even more challenging to work with multiple types in an abstract way. Nevertheless, many people think it’s actually beneficial for the language because of the amount of complexity Generics bring along. And I totally agree. +此外,Go [没有实现一个名为泛型的概念][16],这使得以抽象方式处理多种类型更具挑战性。然而,由于泛型带来的复杂程度,许多人认为不实现泛型对语言实际上是有益的。我完全同意。 -According to Go’s philosophy (which is a separate topic itself), you should try hard to not over-engineer your solutions. And this also applies to dynamically-typed programming. Stick to static types as much as possible, and use interfaces when you know exactly what sort of types you’re dealing with. Interfaces are very powerful and ubiquitous in Go. +根据 Go 的理念(这是一个单独的主题),您应该努力不要过度设计您的解决方案。这也适用于动态类型编程。尽可能坚持使用静态类型,并在确切知道要处理的类型时使用接口(interfaces)。接口在 Go 中非常强大且无处不在。 -However, there are still cases in which you can’t possibly know what sort of data you are facing. A great example is JSON. You convert all the kinds of data back and forth in your applications. Strings, buffers, all sorts of numbers, nested structs and more. +但是,仍然存在一些情况,你无法知道你处理的数据类型。一个很好的例子是 JSON。您可以在应用程序中来回转换所有类型的数据。字符串,缓冲区,各种数字,嵌套结构等。 -In order to pull that off, you need a tool to examine all the data in runtime that acts differently depending on its type and structure. Reflection to rescue! Go has a first-class [reflect][17] package to enable your code to be as dynamic as it would be in a language like Javascript. +为了解决这个问题,您需要一个工具来检查运行时的数据并根据其类型和结构采取不同行为。反射(Reflect)可以帮到你。Go 拥有一流的反射包,使您的代码能够像 Javascript 这样的语言一样动态。 -An important caveat is to know what price you pay for using it — and only use it when there is no simpler way. +一个重要的警告是知道你使用它所带来的代价 - 并且只有知道在没有更简单的方法时才使用它。 -You can read more about it here: [The Laws of Reflection — The Go Blog][18]. +你可以在这里阅读更多相关信息: [反射的法则 — Go 博客][18]. -You can also read some real code from the JSON package sources here: [src/encoding/json/encode.go — Source Code][19] +您还可以在此处阅读 JSON 包源码中的一些实际代码: [src/encoding/json/encode.go — Source Code][19] ### Opinionatedness -Is there such a word, by the way? +顺便问一下,有这样一个单词吗? -Coming from the Javascript world, one of the most daunting processes I faced was deciding which conventions and tools I needed to use. How should I style my code? What testing library should I use? How should I go about structure? What programming paradigms and approaches should I rely on? +来自 Javascript 世界,我面临的最艰巨的困难之一是决定我需要使用哪些约定和工具。我应该如何设计代码?我应该使用什么测试库?我该怎么设计结构?我应该依赖哪些编程范例和方法? -Which sometimes basically got me stuck. I was doing this instead of writing the code and satisfying the users. +这有时候基本上让我卡住了。我需要花时间思考这些事情而不是编写代码并满足用户。 -To begin with, I should note that I totally get where those conventions should come from. It’s always you and your team. Anyway, even a group of experienced Javascript developers can easily find themselves having most of the experience with entirely different tools and paradigms to achieve kind of the same results. +首先,我应该注意到我完全可以得到这些惯例的来源,它总是来源于你或者你的团队。无论如何,即使是一群经验丰富的 Javascript 开发人员也可以轻松地发现自己拥有完全不同的工具和范例的大部分经验,以实现相同的结果。 -This makes the analysis paralysis cloud explode over the whole team, and also makes it harder for the individuals to integrate with each other. +这导致整个团队中分析的瘫痪,并且使得个体之间更难以相互协作。 -Well, Go is different. You have only one style guide that everyone follows. You have only one testing framework which is built into the basic toolchain. You have a lot of strong opinions on how to structure and maintain your code. How to pick names. What structuring patterns to follow. How to do concurrency better. +嗯,Go 是不同的。即使您对如何构建和维护代码有很多强烈的意见,例如:如何命名,要遵循哪些结构模式,如何更好地实现并发。但你只有一个每个人都遵循的风格指南。你只有一个内置在基本工具链中的测试框架。 -While this might seem too restrictive, it saves tons of time for you and your team. Being somewhat limited is actually a great thing when you are coding. It gives you a more straightforward way to go when architecting new code, and makes it easier to reason about the existing one. +虽然这似乎过于严格,但它为您和您的团队节省了大量时间。当你写代码时,受一点限制实际上是一件好事。在构建新代码时,它为您提供了一种更直接的方法,并且可以更容易地调试现有代码。 -As a result, most of the Go projects look pretty alike code-wise. +因此,大多数 Go 项目在代码方面看起来非常相似。 -### Culture +### 文化 -People say that every time you learn a new spoken language, you also soak in some part of the culture of the people who speak that language. Thus, the more languages you learn, more personal changes you might experience. +人们说,每当你学习一门新的口语时,你也会沉浸在说这种语言的人的某些文化中。因此,您学习的语言越多,您可能会有更多的变化。 -It’s the same with programming languages. Regardless of how you are going to apply a new programming language in the future, it always gives you a new perspective on programming in general, or on some specific techniques. +编程语言也是如此。无论您将来如何应用新的编程语言,它总能给的带来新的编程视角或某些特别的技术。 -Be it functional programming, pattern matching, or prototypal inheritance. Once you’ve learned it, you carry these approaches with you which broadens the problem-solving toolset that you have as a software developer. It also changes the way you see high-quality programming in general. +无论是函数式编程,模式匹配(pattern matching)还是原型继承(prototypal inheritance)。一旦你学会了它们,你就可以随身携带这些编程思想,这扩展了你作为软件开发人员所拥有的问题解决工具集。它们也改变了你阅读高质量代码的方式。 -And Go is a terrific investment here. The main pillar of Go’s culture is keeping simple, down-to-earth code without creating many redundant abstractions and putting the maintainability at the top. It’s also a part of the culture to spend the most time actually working on the codebase, instead of tinkering with the tools and the environment. Or choosing between different variations of those. +而 Go 在方面有一项了不起的财富。Go 文化的主要支柱是保持简单,脚踏实地的代码,而不会产生许多冗余的抽象概念,并将可维护性放在首位。大部分时间花费在代码的编写工作上,而不是在修补工具和环境或者选择不同的实现方式上,这也是 Go文化的一部分。 -Go is also all about “there should be only one way of doing a thing.” +Go 文化也可以总结为:“应当只用一种方法去做一件事”。 -A little side note. It’s also partially true that Go usually gets in your way when you need to build relatively complex abstractions. Well, I’d say that’s the tradeoff for its simplicity. +一点注意事项。当你需要构建相对复杂的抽象代码时,Go 通常会妨碍你。好吧,我会说这是简单的权衡。 -If you really need to write a lot of abstract code with complex relationships, you’d be better off using languages like Java or Python. However, even when it’s not obvious, it’s very rarely the case. +如果你真的需要编写大量具有复杂关系的抽象代码,那么最好使用 Java 或 Python 等语言。然而,这种情况却很少。 -Always use the best tool for the job! +在工作时始终使用最好的工具! -### Conclusion +### 总结 -You might have heard of Go before. Or maybe it’s something that has been staying out of your radar for a while. Either way, chances are, Go can be a very decent choice for you or your team when starting a new project or improving the existing one. +你或许之前听说过 Go,或者它暂时在你圈子以外的地方。但无论怎样,在开始新项目或改进现有项目时,Go 可能是您或您团队的一个非常不错的选择。 -This is not a complete list of all the amazing things about Go. Just the undervalued ones. +这不是 Go 的所有惊人的优点的完整列表,只是一些被人低估的特性。 -Please, give Go a try with [A Tour of Go][20] which is an incredible place to start. +请尝试一下从 [Go 之旅(A Tour of Go)][20]来开始学习 Go,这将是一个令人惊叹的开始。 -If you wish to learn more about Go’s benefits, you can check out these links: +如果您想了解有关 Go 的优点的更多信息,可以查看以下链接: -* [Why should you learn Go? — Keval Patel — Medium][2] +* [你为什么要学习 Go? - Keval Patel][2] -* [Farewell Node.js — TJ Holowaychuk — Medium][3] +* [告别Node.js - TJ Holowaychuk][3] -Share your observations down in the comments! +并在评论中分享您的阅读感悟! -Even if you are not specifically looking for a new language to use, it’s worth it to spend an hour or two getting the feel of it. And maybe it can become quite useful for you in the future. +即使您不是为了专门寻找新的编程语言语言,也值得花一两个小时来感受它。也许它对你来说可能会变得非常有用。 -Always be looking for the best tools for your craft! +不断为您的工作寻找最好的工具! * * * @@ -194,7 +193,7 @@ Software Engineer and Traveler. Coding for fun. Javascript enthusiast. Tinkering via: https://medium.freecodecamp.org/here-are-some-amazing-advantages-of-go-that-you-dont-hear-much-about-1af99de3b23a 作者:[Kirill Rogovoy][a] -译者:[译者ID](https://github.com/译者ID) +译者:[译者ID](https://github.com/imquanquan) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 0e0ce619814c3d5f2ec37ef931aa34c444adb7ad Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:06:19 +0800 Subject: [PATCH 038/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=206=20places=20to?= =?UTF-8?q?=20host=20your=20git=20repository?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...30 6 places to host your git repository.md | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 sources/tech/20180830 6 places to host your git repository.md diff --git a/sources/tech/20180830 6 places to host your git repository.md b/sources/tech/20180830 6 places to host your git repository.md new file mode 100644 index 0000000000..671b120a39 --- /dev/null +++ b/sources/tech/20180830 6 places to host your git repository.md @@ -0,0 +1,57 @@ +6 places to host your git repository +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/house_home_colors_live_building.jpg?itok=HLpsIfIL) + +Perhaps you're one of the few people who didn't notice, but a few months back, [Microsoft bought GitHub][1]. Nothing against either company. Microsoft has become a vocal supporter of open source in recent years, and GitHub has been the de facto code repository for a heaping large number of open source projects almost since its inception. + +However, the recent(-ish) purchase may have gotten you a little itchy. After all, there's nothing quite like a corporate buy-out to make you realize you've had your open source code sitting on a commercial platform. Maybe you're not quite ready to jump ship just yet, but it would at least be helpful to know your options. Let's have a look around the web and see what's available. + +### Option 1: GitHub + +Seriously, this is a valid option. [GitHub][2] doesn't have a history of acting in bad faith, and Microsoft certainly has been smiling on open source of late. There's nothing wrong with keeping your project on GitHub and taking a wait-and-see perspective. It's still the largest community website for software development, and it still has some of the best tools for issue tracking, code review, continuous integration, and general code management. And its underpinnings are still on Git, everyone's favorite open source distributed version control system. Your code is still your code. There's nothing wrong with leaving things where they are if nothing is broken. + +### Option 2: GitLab + +[GitLab][3] is probably the leading contender when it comes to alternative code platforms. It's fully open source. You can host your code right on GitLab's site much like you would on GitHub, but you can also choose to self-host a GitLab instance of your own on your own server and have full control over who has access to everything there and how things are managed. GitLab pretty much has feature parity with GitHub, and some folks might even say its continuous integration and testing tools are superior. Although the community of developers on GitLab is certainly smaller than the one on GitHub, it's still nothing to sneeze at. And it's possible that you'll find more like-minded developers among the population there. + +### Option 3: Bitbucket + +[Bitbucket][4] has been around for many years. In some ways, it could serve as a looking glass into the future of GitHub. Bitbucket was acquired by a larger corporation (Atlassian) eight years ago and has already been through some of that change-over process. It's still a commercial platform like GitHub, but it's far from being a startup, and it's on pretty stable footing, organizationally speaking. Bitbucket shares most of the features available on GitHub and GitLab, plus a few novel features of its own, like native support for [Mercurial][5] repositories. + +### Option 4: SourceForge + +The granddaddy of open source code repository sites is [SourceForge][6]. It used to be that if you had an open source project, SourceForge was the place to host your code and share your releases. It took a little while to migrate to Git for version control, and it had its own rash of commercial acquiring and re-acquiring events, coupled with a few unfortunate bundling decisions for a few open source projects. That said, SourceForge seems to have recovered since then, and the site is still a place where quite a few open source projects live. A lot of folks still feel a bit burned, though, and some people aren't huge fans of its various attempts to monetize the platform, so be sure you go in with open eyes. + +### Option 5: Roll your own + +If you want full control of your project's destiny (and no one to blame but yourself), then doing it all yourself may be the best option for you. It is a good alternative for both large and small projects. Git is open source, so it's easily self-hosted. If you want issue tracking and code review, you can run an instance of GitLab or [Phabricator][7]. For continuous integration, you can set up your own instance of the [Jenkins][8] automation server. Yes, you'll need to take responsibility for your own infrastructure overhead and the associated security requirements. However, it's not that hard to get yourself set up. And if you want a sure-fire way to avoid being beholden to the whims of anyone else's platform, this is the way to do it. + +### Option 6: All of the above + +Here's the beauty of all of this: Despite the proprietary drapery strewn over some of these platforms, they're still built on top of solid open source technology. And not just open source, but explicitly designed to be distributed across multiple nodes on a large network (like the internet). You're not required to use just one. You can use a couple… or all of them. Roll your own setup as a guaranteed home base using GitLab and have clone repositories on GitHub and Bitbucket for issue tracking and continuous integration. Keep your main codebase on GitHub but have "backup" clones sitting on GitLab for your own piece of mind. + +The key thing is you have options. And we have those options thanks to open source licensing on very useful and powerful projects. The future is bright. + +Of course, I'm bound to have missed some of the open source options available out there. Feel free to pipe up with your favorites. Are you using multiple platforms? What's your setup? Let everyone know in the comments! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/github-alternatives + +作者:[Jason van Gumster][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mairin +[1]: https://www.theverge.com/2018/6/4/17422788/microsoft-github-acquisition-official-deal +[2]: https://github.com/ +[3]: https://gitlab.com +[4]: https://bitbucket.org +[5]: https://www.mercurial-scm.org/wiki/Repository +[6]: https://sourceforge.net +[7]: https://phacility.com/phabricator/ +[8]: https://jenkins.io From 6aca361dcf1f6974a7e4bd85cecef0d21ed3b72f Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:10:29 +0800 Subject: [PATCH 039/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20A=20quick=20guide?= =?UTF-8?q?=20to=20DNF=20for=20yum=20users?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0830 A quick guide to DNF for yum users.md | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 sources/tech/20180830 A quick guide to DNF for yum users.md diff --git a/sources/tech/20180830 A quick guide to DNF for yum users.md b/sources/tech/20180830 A quick guide to DNF for yum users.md new file mode 100644 index 0000000000..559591b516 --- /dev/null +++ b/sources/tech/20180830 A quick guide to DNF for yum users.md @@ -0,0 +1,131 @@ +A quick guide to DNF for yum users +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/dropbox.jpg?itok=qFwcqboT) + +Dandified yum, better known as [DNF][1], is a software package manager for RPM-based Linux distributions that installs, updates, and removes packages. It was first introduced in Fedora 18 in a testable state (i.e., tech preview), but it's been Fedora's default package manager since Fedora 22. + + * Dependency calculation based on modern dependency-solving technology + * Optimized memory-intensive operations + * The ability to run in Python 2 and Python 3 + * Complete documentation available for Python APIs + + + +Since it is the next-generation version of the traditional yum package manager, it has more advanced and robust features than you'll find in yum. Some of the features that distinguish DNF from yum are: + +DNF uses [hawkey][2] libraries, which resolve RPM dependencies for running queries on client machines. These are built on top of libsolv, a package-dependency solver that uses a satisfiability algorithm. You can find more details on the algorithm in [libsolv's GitHub][3] repository. + +### CLI commands that differ in DNF and yum + +Following are some of the changes to yum's command-line interface (CLI) you will find in DNF. + +**dnf update** or **dnf upgrade:** Executing either dnf update or dnf upgrade has the same effect in the system: both update installed packages. However, dnf upgrade is preferred since it works exactly like **yum --obsoletes update**. + +**resolvedep:** This command doesn't exist in DNF. Instead, execute **dnf provides** to find out which package provides a particular file. + +**deplist:** Yum's deplist command, which lists RPM dependencies, was removed in DNF because it uses the package-dependency solver algorithm to solve the dependency query. + +**dnf remove :** You must specify concrete versions of whatever you want to remove. For example, **dnf remove kernel** will delete all packages called "kernel," so make sure to use something like **dnf remove kernel-4.16.x**. + +**dnf history rollback:** This check, which undoes transactions after the one you specifiy, was dropped since not all the possible changes in the RPM Database Tool are stored in the history of the transaction. + +**--skip-broken:** This install command, which checks packages for dependency problems, is triggered in yum with --skip-broken. However, now it is part of dnf update by default, so there is no longer any need for it. + +**-b, --best:** These switches select the best available package versions in transactions. During dnf upgrade, which by default skips over updates that cannot be installed for dependency reasons, this switch forces DNF to consider only the latest packages. Use **dnf upgrade --best**. + +**--allowerasing:** Allows erasing of installed packages to resolve dependencies. This option could be used as an alternative to the **yum swap X Y** command, in which the packages to remove are not explicitly defined. + +For example: **dnf --allowerasing install Y**. + +**\--enableplugin:** This switch is not recognized and has been dropped. + +### DNF Automatic + +The [DNF Automatic][4] tool is an alternative CLI to dnf upgrade. It can execute automatically and regularly from systemd timers, cron jobs, etc. for auto-notification, downloads, or updates. + +To start, install dnf-automatic rpm and enable the systemd timer unit (dnf-automatic.timer). It behaves as specified by the default configuration file (which is /etc/dnf/automatic.conf). +``` +# yum install dnf-automatic +# systemctl enable dnf-automatic.timer +# systemctl start dnf-automatic.timer +# systemctl status dnf-automatic.timer +``` + +![](https://opensource.com/sites/default/files/uploads/dnf-automatic-timer.png) + +Other timer units that override the default configuration are listed below. Select the one that meets your system requirements. + + * **dnf-automatic-notifyonly.timer:** Notifies the available updates + * **dnf-automatic-download.timer:** Downloads packages, but doesn't install them + * **dnf-automatic-install.timer:** Downloads and installs updates + + + +### Basic DNF commands useful for package management + +**# yum install dnf:** This installs DNF RPM from the yum package manager. + +![](https://opensource.com/sites/default/files/uploads/yum-install-dnf.png) + +**# dnf –version:** This specifies the DNF version. + +![](https://opensource.com/sites/default/files/uploads/dnf-version.png) + +**# dnf list all** or **# dnf list :** This lists all or specific packages; this example lists the kernel RPM available in the system. + +![](https://opensource.com/sites/default/files/uploads/dnf-list-kernel.png) + +**# dnf check-update** or **# dnf check-update kernel:** This views updates in the system. + +![](https://opensource.com/sites/default/files/uploads/dnf-check-update_0.png) + +**# dnf search :** When you search for a specific package via DNF, it will search for an exact match as well as all wildcard searches available in the repository. + +![](https://opensource.com/sites/default/files/uploads/dnf-search.png) + +**# dnf repolist all:** This downloads and lists all enabled repositories in the system. + +![](https://opensource.com/sites/default/files/uploads/dnf-repolist.png) + +**# dnf list --recent** or **# dnf list --recent :** The **\--recent** option dumps all recently added packages in the system. Other list options are **\--extras** , **\--upgrades** , and **\--obsoletes**. + +![](https://opensource.com/sites/default/files/uploads/dnf-list-recent.png) + +**# dnf updateinfo list available** or **# dnf updateinfo list available sec:** These list all the advisories available in the system; including the sec option will list all advisories labeled "security fix." + +![](https://opensource.com/sites/default/files/uploads/dnf-updateinfo-list-available-sec.png) + +**# dnf updateinfo list available sec --sec-severity Critical:** This lists all the security advisories in the system marked "critical." + +![](https://opensource.com/sites/default/files/uploads/dnfupdateinfo-severity-critical.png) + +**# dnf updateinfo FEDORA-2018-a86100a264 –info:** This verifies the information of any advisory via the **\--info** switch. + +![](https://opensource.com/sites/default/files/uploads/dnf-updateinfo-fedora.png) + +**# dnf upgrade --security** or **# dnf upgrade --sec-severity Critical:** This applies all the security advisories available in the system. With the **\--sec-severity** option, you can include the packages with severity marked either Critical, Important, Moderate, or Low. + +![](https://opensource.com/sites/default/files/uploads/dnf-upgrade-security.png) + +### Summary + +These are just a small number of DNF's features, changes, and commands. For complete information about DNF's CLI, new plugins, and hook APIs, refer to the [DNF guide][5]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/guide-yum-dnf + +作者:[Amit Das][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/amit-das +[1]: https://fedoraproject.org/wiki/DNF?rd=Dnf +[2]: https://fedoraproject.org/wiki/Features/Hawkey +[3]: https://github.com/openSUSE/libsolv +[4]: https://dnf.readthedocs.io/en/latest/automatic.html +[5]: https://dnf.readthedocs.io/en/latest/index.html From a6d4b95af508e46683468f92f22519bec3f04efe Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:13:44 +0800 Subject: [PATCH 040/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=206=20open=20source?= =?UTF-8?q?=20tools=20for=20making=20your=20own=20VPN?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...en source tools for making your own VPN.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 sources/tech/20180831 6 open source tools for making your own VPN.md diff --git a/sources/tech/20180831 6 open source tools for making your own VPN.md b/sources/tech/20180831 6 open source tools for making your own VPN.md new file mode 100644 index 0000000000..fe033bfd5c --- /dev/null +++ b/sources/tech/20180831 6 open source tools for making your own VPN.md @@ -0,0 +1,108 @@ +6 open source tools for making your own VPN +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/vpn_scrabble_networking.jpg?itok=pdsUHw5N) + +If you want to try your hand at building your own VPN but aren’t sure where to start, you’ve come to the right place. I’ll compare six of the best free and open source tools to set up and use a VPN on your own server. These VPNs work whether you want to set up a site-to-site VPN for your business or just create a remote access proxy to unblock websites and hide your internet traffic from ISPs. + +Which is best depends on your needs and limitations, so take into consideration your own technical expertise, environment, and what you want to achieve with your VPN. In particular, consider the following factors: + + * VPN protocol + * Number of clients and types of devices + * Server distro compatibility + * Technical expertise required + + + +### Algo + +[Algo][1] was designed from the bottom up to create VPNs for corporate travelers who need a secure proxy to the internet. It “includes only the minimal software you need,” meaning you sacrifice extensibility for simplicity. Algo is based on StrongSwan but cuts out all the things that you don’t need, which has the added benefit of removing security holes that a novice might otherwise not notice. + +As an added bonus, it even blocks ads! + +Algo supports only the IKEv2 protocol and Wireguard. Because IKEv2 support is built into most devices these days, it doesn’t require a client app like OpenVPN. Algo can be deployed using Ansible on Ubuntu (the preferred option), Windows, RedHat, CentOS, and FreeBSD. Setup is automated using Ansible, which configures the server based on your answers to a short set of questions. It’s also very easy to tear down and re-deploy on demand. + +Algo is probably the easiest and fastest VPN to set up and deploy on this list. It’s extremely tidy and well thought out. If you don’t need any of the more advanced features offered by other tools and just need a secure proxy, it’s a great option. Note that Algo explicitly states it’s not meant for geo-unblocking or evading censorship, and was primarily designed for confidentiality. + +### Streisand + +[Streisand][2] can be installed on any Ubuntu 16.04 server using a single command; the process takes about 10 minutes. It supports L2TP, OpenConnect, OpenSSH, OpenVPN, Shadowsocks, Stunnel, Tor bridge, and WireGuard. Depending on which protocol you choose, you may need to install a client app. + +In many ways, Streisand is similar to Algo, but it offers more protocols and customization. This takes a bit more effort to manage and secure but is also more flexible. Note Streisand does not support IKEv2. I would say Streisand is more effective for bypassing censorship in places like China and Turkey due to its versatility, but Algo is easier and faster to set up. + +The setup is automated using Ansible, so there’s not much technical expertise required. You can easily add more users by sending them custom-generated connection instructions, which include an embedded copy of the server’s SSL certificate. + +Tearing down Streisand is a quick and painless process, and you can re-deploy on demand. + +### OpenVPN + +[OpenVPN][3] requires both client and server applications to set up VPN connections using the protocol of the same name. OpenVPN can be tweaked and customized to fit your needs, but it also requires the most technical expertise of the tools covered here. Both remote access and site-to-site configurations are supported; the former is what you’ll need if you plan on using your VPN as a proxy to the internet. Because client apps are required to use OpenVPN on most devices, the end user must keep them updated. + +Server-side, you can opt to deploy in the cloud or on your Linux server. Compatible distros include CentOS, Ubuntu, Debian, and openSUSE. Client apps are available for Windows, MacOS, iOS, and Android, and there are unofficial apps for other devices. Enterprises can opt to set up an OpenVPN Access Server, but that’s probably overkill for individuals, who will want the Community Edition. + +OpenVPN is relatively easy to configure with static key encryption, but it isn’t all that secure. Instead, I recommend setting it up with [easy-rsa][4], a key management package you can use to set up a public key infrastructure. This allows you to connect multiple devices at a time and protect them with perfect forward secrecy, among other benefits. OpenVPN uses SSL/TLS for encryption, and you can specify DNS servers in your configuration. + +OpenVPN can traverse firewalls and NAT firewalls, which means you can use it to bypass gateways and firewalls that might otherwise block the connection. It supports both TCP and UDP transports. + +### StrongSwan + +You might have come across a few different VPN tools with “Swan” in the name. FreeS/WAN, OpenSwan, LibreSwan, and [strongSwan][5] are all forks of the same project, and the lattermost is my personal favorite. Server-side, strongSwan runs on Linux 2.6, 3.x, and 4x kernels, Android, FreeBSD, macOS, iOS, and Windows. + +StrongSwan uses the IKEv2 protocol and IPSec. Compared to OpenVPN, IKEv2 connects much faster while offering comparable speed and security. This is useful if you prefer a protocol that doesn’t require installing an additional app on the client, as most newer devices manufactured today natively support IKEv2, including Windows, MacOS, iOS, and Android. + +StrongSwan is not particularly easy to use, and despite decent documentation, it uses a different vocabulary than most other tools, which can be confusing. Its modular design makes it great for enterprises, but that also means it’s not the most streamlined. It’s certainly not as straightforward as Algo or Streisand. + +Access control can be based on group memberships using X.509 attribute certificates, a feature unique to strongSwan. It supports EAP authentication methods for integration into other environments like Windows Active Directory. StrongSwan can traverse NAT firewalls. + +### SoftEther + +[SoftEther][6] started out as a project by a graduate student at the University of Tsukuba in Japan. SoftEther VPN Server and VPN Bridge run on Windows, Linux, OSX, FreeBSD, and Solaris, while the client app works on Windows, Linux, and MacOS. VPN Bridge is mainly for enterprises that need to set up site-to-site VPNs, so individual users will just need the server and client programs to set up remote access. + +SoftEther supports the OpenVPN, L2TP, SSTP, and EtherIP protocols, but its own SoftEther protocol claims to be able to be immunized against deep packet inspection thanks to “Ethernet over HTTPS” camouflage. SoftEther also makes a few tweaks to reduce latency and increase throughput. Additionally, SoftEther includes a clone function that allows you to easily transition from OpenVPN to SoftEther. + +SoftEther can traverse NAT firewalls and bypass firewalls. On restricted networks that permit only ICMP and DNS packets, you can utilize SoftEther’s VPN over ICMP or VPN over DNS options to penetrate the firewall. SoftEther works with both IPv4 and IPv6. + +SoftEther is easier to set up than OpenVPN and strongSwan but is a bit more complicated than Streisand and Algo. + +### WireGuard + +[WireGuard][7] is the newest tool on this list; it's so new that it’s not even finished yet. That being said, it offers a fast and easy way to deploy a VPN. It aims to improve on IPSec by making it simpler and leaner like SSH. + +Like OpenVPN, WireGuard is both a protocol and a software tool used to deploy a VPN that uses said protocol. A key feature is “crypto key routing,” which associates public keys with a list of IP addresses allowed inside the tunnel. + +WireGuard is available for Ubuntu, Debian, Fedora, CentOS, MacOS, Windows, and Android. WireGuard works on both IPv4 and IPv6. + +WireGuard is much lighter than most other VPN protocols, and it transmits packets only when data needs to be sent. + +The developers say WireGuard should not yet be trusted because it hasn’t been fully audited yet, but you’re welcome to give it a spin. It could be the next big thing! + +### Homemade VPN vs. commercial VPN + +Making your own VPN adds a layer of privacy and security to your internet connection, but if you’re the only one using it, then it would be relatively easy for a well-equipped third party, such as a government agency, to trace activity back to you. + +Furthermore, if you plan to use your VPN to unblock geo-locked content, a homemade VPN may not be the best option. Since you’ll only be connecting from a single IP address, your VPN server is fairly easy to block. + +Good commercial VPNs don’t have these issues. With a provider like [ExpressVPN][8], you share the server’s IP address with dozens or even hundreds of other users, making it nigh-impossible to track a single user’s activity. You also get a huge range of hundreds or thousands of servers to choose from, so if one has been blacklisted, you can just switch to another. + +The tradeoff of a commercial VPN, however, is that you must trust the provider not to snoop on your internet traffic. Be sure to choose a reputable provider with a clear no-logs policy. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/open-source-tools-vpn + +作者:[Paul Bischoff][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[1]: https://blog.trailofbits.com/2016/12/12/meet-algo-the-vpn-that-works/ +[2]: https://github.com/StreisandEffect/streisand +[3]: https://openvpn.net/ +[4]: https://github.com/OpenVPN/easy-rsa +[5]: https://www.strongswan.org/ +[6]: https://www.softether.org/ +[7]: https://www.wireguard.com/ +[8]: https://www.comparitech.com/vpn/reviews/expressvpn/ From 9a6117aef5b4f4ce0ce47db2f712876db342a2d6 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:15:26 +0800 Subject: [PATCH 041/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Test=20containers?= =?UTF-8?q?=20with=20Python=20and=20Conu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...31 Test containers with Python and Conu.md | 164 ++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 sources/tech/20180831 Test containers with Python and Conu.md diff --git a/sources/tech/20180831 Test containers with Python and Conu.md b/sources/tech/20180831 Test containers with Python and Conu.md new file mode 100644 index 0000000000..e28ca4674e --- /dev/null +++ b/sources/tech/20180831 Test containers with Python and Conu.md @@ -0,0 +1,164 @@ +Test containers with Python and Conu +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/08/conu-816x345.jpg) + +More and more developers are using containers to develop and deploy their applications. This means that easily testing containers is also becoming important. [Conu][1] (short for container utilities) is a Python library that makes it easy to write tests for your containers. This article shows you how to use it to test your containers. + +### Getting started + +First you need a container application to test. For that, the following commands create a new directory with a container Dockerfile, and a Flask application to be served by the container. +``` +$ mkdir container_test +$ cd container_test +$ touch Dockerfile +$ touch app.py + +``` + +Copy the following code inside the app.py file. This is the customary basic Flask application that returns the string “Hello Container World!” +``` +from flask import Flask +app = Flask(__name__) + +@app.route('/') +def hello_world(): + return 'Hello Container World!' + +if __name__ == '__main__': + app.run(debug=True,host='0.0.0.0') + +``` + +### Create and Build a Test Container + +To build the test container, add the following instructions to the Dockerfile. +``` +FROM registry.fedoraproject.org/fedora-minimal:latest +RUN microdnf -y install python3-flask && microdnf clean all +ADD ./app.py /srv +CMD ["python3", "/srv/app.py"] + +``` + +Then build the container using the Docker CLI tool. +``` +$ sudo dnf -y install docker +$ sudo systemctl start docker +$ sudo docker build . -t flaskapp_container + +``` + +Note : The first two commands are only needed if Docker is not installed on your system. + +After the build use the following command to run the container. +``` +$ sudo docker run -p 5000:5000 --rm flaskapp_container +* Running on http://0.0.0.0:5000/ (Press CTRL+C to quit) +* Restarting with stat +* Debugger is active! +* Debugger PIN: 473-505-51 + +``` + +Finally, use curl to check that the Flask application is correctly running inside the container: +``` +$ curl http://127.0.0.1:5000 +Hello Container World! + +``` + +With the flaskapp_container now running and ready for testing, you can stop it using **Ctrl+C**. + +### Create a test script + +Before you write the test script, you must install conu. Inside the previously created container_test directory run the following commands. +``` +$ python3 -m venv .venv +$ source .venv/bin/activate +(.venv)$ pip install --upgrade pip +(.venv)$ pip install conu + +$ touch test_container.py + +``` + +Then copy and save the following script in the test_container.py file. +``` +import conu + +PORT = 5000 + +with conu.DockerBackend() as backend: + image = backend.ImageClass("flaskapp_container") + options = ["-p", "5000:5000"] + container = image.run_via_binary(additional_opts=options) + + try: + # Check that the container is running and wait for the flask application to start. + assert container.is_running() + container.wait_for_port(PORT) + + # Run a GET request on / port 5000. + http_response = container.http_request(path="/", port=PORT) + + # Check the response status code is 200 + assert http_response.ok + + # Get the response content + response_content = http_response.content.decode("utf-8") + + # Check that the "Hello Container World!" string is served. + assert "Hello Container World!" in response_content + + # Get the logs from the container + logs = [line for line in container.logs()] + # Check the the Flask application saw the GET request. + assert b'"GET / HTTP/1.1" 200 -' in logs[-1] + + finally: + container.stop() + container.delete() + +``` + +#### Test Setup + +The script starts by setting conu to use Docker as a backend to run the container. Then it sets the container image to use the flaskapp_container you built in the first part of this tutorial. + +The next step is to configure the options needed to run the container. In this example, the Flask application serves the content on port 5000. Therefore you need to expose this port and map it to the same port on the host. + +Finally, the script starts the container, and it’s now ready to be tested. + +#### Testing methods + +Before testing a container, check that the container is running and ready. The example script is using container.is_running and container.wait_for_port. These methods ensure the container is running and the service is available on the expected port. + +The container.http_request is a wrapper around the [requests][2] library which makes it convenient to send HTTP requests during the tests. This method returns a [requests.Response][3]object, so it’s easy to access the content of the response for testing. + +Conu also gives access to the container logs. Once again, this can be useful during testing. In the example above, the container.logs method returns the container logs. You can use them to assert that a specific log was printed, or for example that no exceptions were raised during testing. + +Conu provides many other useful methods to interface with containers. A full list of the APIs is available in the [documentation][4]. You can also consult the examples available on [GitHub][5]. + +All the code and files needed to run this tutorial are available on [GitHub][6] as well. For readers who want to take this example further, you can look at using [pytest][7] to run the tests and build a container test suite. + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/test-containers-python-conu/ + +作者:[Clément Verna][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/cverna/ +[1]: https://github.com/user-cont/conu +[2]: http://docs.python-requests.org/en/master/ +[3]: http://docs.python-requests.org/en/master/api/#requests.Response +[4]: https://conu.readthedocs.io/en/latest/index.html +[5]: https://github.com/user-cont/conu/tree/master/docs/source/examples +[6]: https://github.com/cverna/container_test_script +[7]: https://docs.pytest.org/en/latest/ From 53dbff700fa4635b4dff595c6dea52ef71b71a6a Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:19:09 +0800 Subject: [PATCH 042/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=203=20innovative=20?= =?UTF-8?q?open=20source=20projects=20for=20the=20new=20school=20year?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...source projects for the new school year.md | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 sources/tech/20180831 3 innovative open source projects for the new school year.md diff --git a/sources/tech/20180831 3 innovative open source projects for the new school year.md b/sources/tech/20180831 3 innovative open source projects for the new school year.md new file mode 100644 index 0000000000..e8493ed501 --- /dev/null +++ b/sources/tech/20180831 3 innovative open source projects for the new school year.md @@ -0,0 +1,59 @@ +3 innovative open source projects for the new school year +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/desk_clock_job_work.jpg?itok=Nj4fuhl6) + +I first wrote about open source learning software for educators in the fall of 2013. Fast-forward five years—today, open source software and principles have moved from outsiders in the education industry to the popular crowd. + +Since Penn Manor School District has [adopted open software][1] and cultivated a learning community built on trust, we've watched student creativity, ingenuity, and engagement soar. Here are three free and open source software tools we’ve used during the past school year. All three have enabled great student projects and may spark cool classroom ideas for open-minded educators. + +### Catch a wave: Software-defined radio + +Students may love the modern sounds of Spotify and Soundcloud, but there's an old-school charm to snatching noise from the atmosphere. Penn Manor help desk student apprentices had serious fun with [software-defined radio][2] (SDR). With an inexpensive software-defined radio kit, students can capture much more than humdrum FM radio stations. One of our help desk apprentices, JR, discovered everything from local emergency radio chatter to unencrypted pager messages. + +Our basic setup involved a student’s Linux laptop running [gqrx software][3] paired with a [USB RTL-SDR tuner and a simple antenna][4]. It was light enough to fit in a student backpack for SDR on the go. And the kit was great for creative hacking, which JR demonstrated when he improvised all manner of antennas, including a frying pan, in an attempt to capture signals from the U.S. weather satellite [NOAA-18][5]. + +Former Penn Manor IT specialist Tom Swartz maintains an excellent [quick-start resource for SDR][6]. + +### Stream far for a middle school crowd: OBS Studio + +Remember live morning TV announcements in school? Amateur weather reports, daily news updates, middle school puns... In-house video studios are an excellent opportunity for fun collaboration and technical learning. But many schools are stuck running proprietary broadcast and video mixing software, and many more are unable to afford costly production hardware such as [NewTek’s TriCaster][7]. + +Cue [OBS Studio][8], a free, open source, real-time broadcasting program ideally suited for school projects as well as professional video streaming. During the past six months, several Penn Manor schools successfully upgraded to OBS Studio running on Linux. OBS handles our multi-source video and audio mixing, chroma key compositing, transitions, and just about anything else students need to run a surprising polished video broadcast. + +Penn Manor students stream a live morning show via UDP multicast to staff and students tuned in via the [mpv][9] media player. OBS also supports live streaming to YouTube, Facebook Live, and Twitch, which means students can broadcast daily school lunch menus and other vital updates to the world. + +### Self-drive by light: TurtleBot3 and Lidar + +Of course, robots are cool, but robots with lasers are ace. The newest star of the Penn Manor student help desk is Patch, a petite educational robot built with the [TurtleBot3][10] open hardware and software kit. The Turtlebot platform is extensible and great for hardware hacking, but we were most interested in creating a self-driving gadget. + +We used the Turtlebot3 Burger, the entry-level kit powered by a Raspberry PI and loaded with a laser distance sensor. New student tech apprentices Aiden, Alex, and Tristen were challenged to make the robot autonomously navigate down one Penn Manor High School hallway and back to the technology center. It was a tall order: The team spent several months building the bot, and then working through the [ROS][11]-based programming, [rviz][12] (a 3D environment visualizer) and mapping for simultaneous localization and mapping (SLAM). + +Building the robot was a joy, but without a doubt, the programming challenged the students, none of whom had previously touched any of the ROS software tools. However, after much persistence, trial and error, and tenacity, Aiden and Tristen succeeded in achieving both the hallway navigation goal and in confusing fellow students with a tiny robot transversing school corridors and magically avoiding objects and people in its path. + +I recommend the TurtleBot3, but educators should be aware of the cost (approximately US$ 500) and the complexity. However, the kit is an outstanding resource for students aspiring to technology careers or those who want to build something amazing. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/back-school-project-ideas + +作者:[Charlie Reisinger][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/charlie +[1]: https://opensource.com/education/14/9/interview-charlie-reisinger-penn-manor +[2]: https://en.wikipedia.org/wiki/Software-defined_radio +[3]: http://gqrx.dk/ +[4]: https://www.amazon.com/JahyShow%C2%AE-RTL2832U-RTL-SDR-Receiver-Compatible/dp/B01H830YQ6 +[5]: https://en.wikipedia.org/wiki/NOAA-18 +[6]: https://github.com/tomswartz07/CPOSC2017 +[7]: https://www.newtek.com/tricaster/ +[8]: https://obsproject.com/ +[9]: https://mpv.io/ +[10]: https://www.turtlebot.com/ +[11]: http://www.ros.org/ +[12]: http://wiki.ros.org/rviz From 9a1c25213f5dd89f81a12eb6fec6a91485a06489 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:28:37 +0800 Subject: [PATCH 043/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Flameshot=20?= =?UTF-8?q?=E2=80=93=20A=20Simple,=20Yet=20Powerful=20Feature-rich=20Scree?= =?UTF-8?q?nshot=20Tool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...t Powerful Feature-rich Screenshot Tool.md | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 sources/tech/20180901 Flameshot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md diff --git a/sources/tech/20180901 Flameshot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md b/sources/tech/20180901 Flameshot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md new file mode 100644 index 0000000000..f6bec82f02 --- /dev/null +++ b/sources/tech/20180901 Flameshot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md @@ -0,0 +1,168 @@ +Flameshot – A Simple, Yet Powerful Feature-rich Screenshot Tool +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Flameshot-720x340.png) + +Capturing screenshots is part of my job. I have been using Deepin-screenshot tool for taking screenshots. It’s a simple, light-weight and quite neat screenshot tool. It comes with all options such as mart window identification, shortcuts supporting, image editing, delay screenshot, social sharing, smart saving, and image resolution adjusting etc. Today, I stumbled upon yet another screenshot tool that ships with many features. Say hello to **Flameshot** , a simple and powerful, feature-rich screenshot tool for Unix-like operating systems. It is easy to use, customizable and has an option to upload your screenshots to **imgur** , an online image sharing website. And also, Flameshot has a CLI version, so you can take screenshots from commandline as well. Flameshot is completely free and open source tool. In this guide, we will see how to install Flameshot and how to take screenshots using it. + +### Install Flameshot + +**On Arch Linux:** + +Flameshot is available [community] repository in Arch Linux. Make sure you have enabled community repository and install Flameshot using pacman as shown below. +``` +$ sudo pacman -S flameshot + +``` + +It is also available in [**AUR**][1], so you can install it using any AUR helper programs, for example [**Yay**][2], in Arch-based systems. +``` +$ yay -S flameshot-git + +``` + +**On Fedora:** +``` +$ sudo dnf install flameshot + +``` + +On **Debian 10+** and **Ubuntu 18.04+** , install it using APT package manager. +``` +$ sudo apt install flameshot + +``` + +**On openSUSE:** +``` +$ sudo zypper install flameshot + +``` + +On other distributions, compile and install it from source code. The compilation requires **Qt version 5.3** or higher and **GCC 4.9.2** or higher. + +### Usage + +Launch Flameshot from menu or application launcher. On MATE desktop environment, It usually found under **Applications - > Graphics**. + +Once you opened it, you will see Flameshot systray icon in your system’s panel. + +**Note:** + +If you are using Gnome you need to install the [TopIcons][3] extension in order to see the systemtray icon. + +Right click on the tray icon and you’ll see some menu items to open the configuration window and the information window or quit the application. + +To capture screenshot, just click on the tray icon. You will see help window that says how to use Flameshot. Choose an area to capture and hit **ENTER** key to capture the screen. Press right click to show the color picker, hit spacebar to view the side panel. You can use increase or decrease the pointer’s thickness by using the Mouse scroll button. + +Flameshot comes with quite good set of features, such as, + + * Free hand writing + * Line drawing + * Rectangle / Circle drawing + * Rectangle selection + * Arrows + * Marker to highlight important points + * Add text + * Blur the image/text + * Show the dimension of the image + * Undo/Redo the changes while editing images + * Copy the selection to the clipboard + * Save the selection + * Leave the capture screen + * Choose an app to open images + * Upload the selection to imgur site + * Pin image to desktop + + + +Here is a sample demo: + + + +**Keyboard shortcuts** + +Frameshot supports keyboard shortcuts. Right click on Flameshot tray icon and click **Information** window to see all the available shortcuts in the graphical capture mode. Here is the list of available keyboard shortcuts in GUI mode. + +| Keys | Description | +|------------------------|------------------------------| +| ←, ↓, ↑, → | Move selection 1px | +| Shift + ←, ↓, ↑, → | Resize selection 1px | +| Esc | Quit capture | +| Ctrl + C | Copy to clipboard | +| Ctrl + S | Save selection as a file | +| Ctrl + Z | Undo the last modification | +| Right Click | Show color picker | +| Mouse Wheel | Change the tool’s thickness | + +Shift + drag a handler of the selection area: mirror redimension in the opposite handler. + +**Command line options** + +Flameshot also has a set of command line options to delay the screenshots and save images in custom paths. + +To capture screen with Flameshot GUI, run: +``` +$ flameshot gui + +``` + +To capture screen with GUI and save it in a custom path of your choice: +``` +$ flameshot gui -p ~/myStuff/captures + +``` + +To open GUI with a delay of 2 seconds: +``` +$ flameshot gui -d 2000 + +``` + +To capture fullscreen with custom save path (no GUI) with a delay of 2 seconds: +``` +$ flameshot full -p ~/myStuff/captures -d 2000 + +``` + +To capture fullscreen with custom save path copying to clipboard: +``` +$ flameshot full -c -p ~/myStuff/captures + +``` + +To capture the screen containing the mouse and print the image (bytes) in **PNG** format: +``` +$ flameshot screen -r + +``` + +To capture the screen number 1 and copy it to the clipboard: +``` +$ flameshot screen -n 1 -c + +``` + +What do you need? Flameshot has almost all features for capturing pictures, adding annotations, editing images, blur or highlight important points and a lot more. I think I will stick with Flameshot for a while as find it best replacement for my current screenshot tool. Give it a try and you won’t be disappointed. + +And, that’s all for now. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/flameshot-a-simple-yet-powerful-feature-rich-screenshot-tool/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://aur.archlinux.org/packages/flameshot-git +[2]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ +[3]: https://extensions.gnome.org/extension/1031/topicons/ From f2e6069fb4c3c128b9eba066b6c1b1b790c2abfa Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:30:57 +0800 Subject: [PATCH 044/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=205=20Ways=20to=20T?= =?UTF-8?q?ake=20Screenshot=20in=20Linux=20[GUI=20and=20Terminal]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Screenshot in Linux [GUI and Terminal].md | 222 ++++++++++++++++++ 1 file changed, 222 insertions(+) create mode 100644 sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md diff --git a/sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md b/sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md new file mode 100644 index 0000000000..465cdf02d2 --- /dev/null +++ b/sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md @@ -0,0 +1,222 @@ +5 Ways to Take Screenshot in Linux [GUI and Terminal] +====== +Here are several ways you can take screenshots and edit the screenshots by adding text, arrows etc. Instructions and mentioned screenshot tools are valid for Ubuntu and other major Linux distributions. + +![How to take screenshots in Ubuntu Linux][1] + +When I switched from Windows to Ubuntu as my primary OS, the first thing I was worried about was the availability of screenshot tools. Well, it is easy to utilize the default keyboard shortcuts in order to take screenshots but with a standalone tool, I get to annotate/edit the image while taking the screenshot. + +In this article, we will introduce you to the default methods/tools (without a 3rd party screenshot tool) to take a screenshot while also covering the list of best screenshot tools available for Linux. + +### Method 1: The default way to take screenshot in Linux + +Do you want to capture the image of your entire screen? A specific region? A specific window? + +If you just want a simple screenshot without any annotations/fancy editing capabilities, the default keyboard shortcuts will do the trick. These are not specific to Ubuntu. Almost all Linux distributions and desktop environments support these keyboard shortcuts. + +Let’s take a look at the list of keyboard shortcuts you can utilize: + +**PrtSc** – Save a screenshot of the entire screen to the “Pictures” directory. +**Shift + PrtSc** – Save a screenshot of a specific region to Pictures. +**Alt + PrtSc** – Save a screenshot of the current window to Pictures. +**Ctrl + PrtSc** – Copy the screenshot of the entire screen to the clipboard. +**Shift + Ctrl + PrtSc** – Copy the screenshot of a specific region to the clipboard. +**Ctrl + Alt + PrtSc** – Copy the screenshot of the current window to the clipboard. + +As you can see, taking screenshots in Linux is absolutely simple with the default screenshot tool. However, if you want to immediately annotate (or other editing features) without importing the screenshot to another application, you can use a dedicated screenshot tool. + +#### **Method 2: Take and edit screenshots in Linux with Flameshot** + +![flameshot][2] + +Feature Overview + + * Annotate (highlight, point, add text, box in) + * Blur part of an image + * Crop part of an image + * Upload to Imgur + * Open screenshot with another app + + + +Flameshot is a quite impressive screenshot tool which arrived on [GitHub][3] last year. + +If you have been searching for a screenshot tool that helps you annotate, blur, mark, and upload to imgur while being actively maintained unlike some outdated screenshot tools, Flameshot should be the one to have installed. + +Fret not, we will guide you how to install it and configure it as per your preferences. + +To install it on Ubuntu, you just need to search for it on Ubuntu Software center and get it installed. In case you want to use the terminal, here’s the command for it: +``` +sudo apt install flameshot + +``` + +If you face any trouble installing, you can follow their [official installation instructions][4]. After installation, you need to configure it. Well, you can always search for it and launch it, but if you want to trigger the Flameshot screenshot tool by using **PrtSc** key, you need to assign a custom keyboard shortcut. + +Here’s how you can do that: + + * Head to the system settings and navigate your way to the Keyboard settings. + * You will find all the keyboard shortcuts listed there, ignore them and scroll down to the bottom. Now, you will find a **+** button. + * Click the “+” button to add a custom shortcut. You need to enter the following in the fields you get: +**Name:** Anything You Want +**Command:** /usr/bin/flameshot gui + * Finally, set the shortcut to **PrtSc** – which will warn you that the default screenshot functionality will be disabled – so proceed doing it. + + + +For reference, your custom keyboard shortcut field should look like this after configuration: + +![][5] +Map keyboard shortcut with Flameshot + +### **Method 3: Take and edit screenshots in Linux with Shutter** + +![][6] + +Feature Overview: + + * Annotate (highlight, point, add text, box in) + * Blur part of an image + * Crop part of an image + * Upload to image hosting sites + + + +[Shutter][7] is a popular screenshot tool available for all major Linux distributions. Though it seems to be no more being actively developed, it is still an excellent choice for handling screenshots. + +You might encounter certain bugs/errors. The most common problem with Shutter on any latest Linux distro releases is that the ability to edit the screenshots is disabled by default along with the missing applet indicator. But, fret not, we have a solution to that. You just need to follow our guide to[fix the disabled edit option in Shutter and bring back the applet indicator][8]. + +After you’re done fixing the problem, you can utilize it to edit the screenshots in a jiffy. + +To install shutter, you can browse the software center and get it from there. Alternatively, you can use the following command in the terminal to install Shutter in Ubuntu-based distributions: +``` +sudo apt install shutter + +``` + +As we saw with Flameshot, you can either choose to use the app launcher to search for Shutter and manually launch the application, or you can follow the same set of instructions (with a different command) to set a custom shortcut to trigger Shutter when you press the **PrtSc** key. + +If you are going to assign a custom keyboard shortcut, you just need to use the following in the command field: +``` +shutter -f + +``` + +### Method 4: Use GIMP for taking screenshots in Linux + +![][9] + +Feature Overview: + + * Advanced Image Editing Capabilities (Scaling, Adding filters, color correction, Add layers, Crop, and so on.) + * Take a screenshot of the selected area + + + +If you happen to use GIMP a lot and you probably want some advance edits on your screenshots, GIMP would be a good choice for that. + +You should already have it installed, if not, you can always head to your software center to install it. If you have trouble installing, you can always refer to their [official website for installation instructions][10]. + +To take a screenshot with GIMP, you need to first launch it, and then navigate your way through **File- >Create->Screenshot**. + +After you click on the screenshot option, you will be greeted with a couple of tweaks to control the screenshot. That’s just it. Click “ **Snap** ” to take the screenshot and the image will automatically appear within GIMP, ready for you to edit. + +### Method 5: Taking screenshot in Linux using command line tools + +This section is strictly for terminal lovers. If you like using the terminal, you can utilize the **GNOME screenshot** tool or **ImageMagick** or **Deepin Scrot** – which comes baked in on most of the popular Linux distributions. + +To take a screenshot instantly, enter the following command: + +#### GNOME Screenshot (for GNOME desktop users) +``` +gnome-screenshot + +``` + +To take a screenshot with a delay, enter the following command (here, **5** – is the number of seconds you want to delay) + +GNOME screenshot is one of the default tools that exists in all distributions with GNOME desktop. +``` +gnome-screenshot -d -5 + +``` + +#### ImageMagick + +[ImageMagick][11] should be already pre-installed on your system if you are using Ubuntu, Mint, or any other popular Linux distribution. In case, it isn’t there, you can always install it by following the [official installation instructions (from source)][12]. In either case, you can enter the following in the terminal: +``` +sudo apt-get install imagemagick + +``` + +After you have it installed, you can type in the following commands to take a screenshot: + +To take the screenshot of your entire screen: +``` +import -window root image.png + +``` + +Here, “image.png” is your desired name for the screenshot. + +To take the screenshot of a specific area: +``` +import image.png + +``` + +#### Deepin Scrot + +Deepin Scrot is a slightly advanced terminal-based screenshot tool. Similar to the others, you should already have it installed. If not, get it installed through the terminal by typing: +``` +sudo apt-get install scrot + +``` + +After having it installed, follow the instructions below to take a screenshot: + +To take a screenshot of the entire screen: +``` +scrot myimage.png + +``` + +To take a screenshot of the selected aread: +``` +scrot -s myimage.png + +``` + +### Wrapping Up + +So, these are the best screenshot tools available for Linux. Yes, there are a few more tools available (like [Spectacle][13] for KDE-based distros), but if you end up comparing them, the above-mentioned tools will outshine them. + +In case you find a better screenshot tool than the ones mentioned in our article, feel free to let us know about it in the comments below. + +Also, do tell us about your favorite screenshot tool! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/take-screenshot-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/Taking-Screenshots-in-Linux.png +[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/flameshot-pic.png +[3]: https://github.com/lupoDharkael/flameshot +[4]: https://github.com/lupoDharkael/flameshot#installation +[5]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/flameshot-config-default.png +[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/shutter-screenshot.jpg +[7]: http://shutter-project.org/ +[8]: https://itsfoss.com/shutter-edit-button-disabled/ +[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/gimp-screenshot.jpg +[10]: https://www.gimp.org/downloads/ +[11]: https://www.imagemagick.org/script/index.php +[12]: https://www.imagemagick.org/script/install-source.php +[13]: https://www.kde.org/applications/graphics/spectacle/ From 12b8703141423193a2ae81882bca1db1c0cfe707 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:32:48 +0800 Subject: [PATCH 045/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Publishing=20Mark?= =?UTF-8?q?down=20to=20HTML=20with=20MDwiki?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Publishing Markdown to HTML with MDwiki.md | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 sources/tech/20180831 Publishing Markdown to HTML with MDwiki.md diff --git a/sources/tech/20180831 Publishing Markdown to HTML with MDwiki.md b/sources/tech/20180831 Publishing Markdown to HTML with MDwiki.md new file mode 100644 index 0000000000..c25239b7ba --- /dev/null +++ b/sources/tech/20180831 Publishing Markdown to HTML with MDwiki.md @@ -0,0 +1,73 @@ +Publishing Markdown to HTML with MDwiki +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o) + +There are plenty of reasons to like Markdown, a simple language with an easy-to-learn syntax that can be used with any text editor. Using tools like [Pandoc][1], you can convert Markdown text to [a variety of popular formats][2], including HTML. You can also automate that conversion process in a web server. An HTML5 and JavaScript application called [MDwiki][3], created by Timo Dörr, can take a stack of Markdown files and turn them into a website when requested from a browser. The MDwiki site includes a how-to guide and other information to help you get started: + +![MDwiki site getting started][5] + +What an Mdwiki site looks like. + +Inside the web server, a basic MDwiki site looks like this: + +![MDwiki site inside web server][7] + +What the webserver folder for that site looks like. + +I renamed the MDwiki HTML file `START.HTML` for this project. There is also one Markdown file that deals with navigation and a JSON file to hold a few configuration settings. Everything else is site content. + +While the overall website design is pretty much fixed by MDwiki, the content, styling, and number of pages are not. You can view a selection of different sites generated by MDwiki at [the MDwiki site][8]. It is fair to say that MDwiki sites lack the visual appeal that a web designer could achieve—but they are functional, and users should balance their simple appearance against the speed and ease of creating and editing them. + +Markdown comes in various flavors that extend a stable core functionality for different specific purposes. MDwiki uses GitHub flavor [Markdown][9], which adds features such as formatted code blocks and syntax highlighting for popular programming languages, making it well-suited for producing program documentation and tutorials. + +MDwiki also supports what it calls "gimmicks," which add extra functionality such as embedding YouTube video content and displaying mathematical formulas. These are worth exploring if you need them for specific projects. I find MDwiki an ideal tool for creating technical documentation and educational resources. I have also discovered some tricks and hacks that might not be immediately apparent. + +MDwiki works with any modern web browser when deployed in a web server; however, you do not need a web server if you access MDwiki with Mozilla Firefox. Most MDwiki users will opt to deploy completed projects on a web server to avoid excluding potential users, but development and testing can be done with just a text editor and Firefox. Completed MDwiki projects that are loaded into a Moodle Virtual Learning Environment (VLE) can be read by any modern browser, which could be useful in educational contexts. (This is probably also true for other VLE software, but you should test that.) + +MDwiki's default color scheme is not ideal for all projects, but you can replace it with another theme downloaded from [Bootswatch.com][10]. To do this, simply open the MDwiki HTML file in an editor, take out the `extlib/css/bootstrap-3.0.0.min.css` code, and insert the downloaded Bootswatch theme. There is also an MDwiki gimmick that lets users choose a Bootswatch theme to replace the default after MDwiki loads in their browser. I often work with users who have visual impairments, and they tend to prefer high-contrast themes, with white text on a dark background. + +![MDwiki screen with Bootswatch Superhero theme][12] + +MDwiki screen using the Bootswatch Superhero theme + +MDwiki, Markdown files, and static images are fine for many purposes. However, you might sometimes want to include, say, a JavaScript slideshow or a feedback form. Markdown files can include HTML code, but mixing Markdown with HTML can get confusing. One solution is to create the feature you want in a separate HTML file and display it inside a Markdown file with an iframe tag. I took this idea from the [Twine Cookbook][13], a support site for the Twine interactive fiction engine. The Twine Cookbook doesn’t actually use MDwiki, but combining Markdown and iframe tags opens up a wide range of creative possibilities. + +Here is an example: + +This HTML will display an HTML page created by the Twine interactive fiction engine inside a Markdown file. +``` + +``` + +The result in an MDwiki-generated site looks like this: + +![](https://opensource.com/sites/default/files/uploads/4_-_mdwiki_site_summary.png) + +In short, MDwiki is an excellent small application that achieves its purpose extremely well. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/markdown-html-publishing + +作者:[Peter Cheer][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/petercheer +[1]: https://pandoc.org/ +[2]: https://opensource.com/downloads/pandoc-cheat-sheet +[3]: http://dynalon.github.io/mdwiki/#!index.md +[4]: https://opensource.com/file/407306 +[5]: https://opensource.com/sites/default/files/uploads/1_-_mdwiki_screenshot.png (MDwiki site getting started) +[6]: https://opensource.com/file/407311 +[7]: https://opensource.com/sites/default/files/uploads/2_-_mdwiki_inside_web_server.png (MDwiki site inside web server) +[8]: http://dynalon.github.io/mdwiki/#!examples.md +[9]: https://guides.github.com/features/mastering-markdown/ +[10]: https://bootswatch.com/ +[11]: https://opensource.com/file/407316 +[12]: https://opensource.com/sites/default/files/uploads/3_-_mdwiki_bootswatch_superhero.png (MDwiki screen with Bootswatch Superhero theme) +[13]: https://github.com/iftechfoundation/twine-cookbook From edf29012db78a7c84b2712fd39ee806d628533a4 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:34:14 +0800 Subject: [PATCH 046/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Linux=20for=20Beg?= =?UTF-8?q?inners:=20Moving=20Things=20Around?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nux for Beginners- Moving Things Around.md | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 sources/tech/20180828 Linux for Beginners- Moving Things Around.md diff --git a/sources/tech/20180828 Linux for Beginners- Moving Things Around.md b/sources/tech/20180828 Linux for Beginners- Moving Things Around.md new file mode 100644 index 0000000000..abefc7c6f5 --- /dev/null +++ b/sources/tech/20180828 Linux for Beginners- Moving Things Around.md @@ -0,0 +1,201 @@ +Linux for Beginners: Moving Things Around +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/filesystem-linux.jpg?itok=NQCoYl1f) + +In previous installments of this series, [you learned about directories][1] and how [permissions to access directories work][2]. Most of what you learned in those articles can be applied to files, except how to make a file executable. + +So let's deal with that before moving on. + +### No _.exe_ Needed + +In other operating systems, the nature of a file is often determined by its extension. If a file has a _.jpg_ extension, the OS guesses it is an image; if it ends in _.wav_ , it is an audio file; and if it has an _.exe_ tacked onto the end of the file name, it is a program you can execute. + +This leads to serious problems, like trojans posing as documents. Fortunately, that is not how things work in Linux. Sure, you may see occasional executable file endings in _.sh_ that indicate they are runnable shell scripts, but this is mostly for the benefit of humans eyeballing files, the same way when you use `ls --color`, the names of executable files show up in bright green. + +The fact is most applications have no extension at all. What determines whether a file is really program is the _x_ (for _executable_ ) bit. You can make any file executable by running +``` +chmod a+x some_program + +``` + +regardless of its extension or lack thereof. The `x` in the command above sets the _x_ bit and the `a` says you are setting it for _all_ users. You could also set it only for the group of users that own the file (`g+x`), or for only one user, the owner (`u+x`). + +Although we will be covering creating and running scripts from the command line later in this series, know that you can run a program by writing the path to it and then tacking on the name of the program on the end: +``` +path/to/directory/some_program + +``` + +Or, if you are currently in the same directory, you can use: +``` +./some_program + +``` + +There are other ways of making your program available from anywhere in the directory tree (hint: look up the `$PATH` environment variable), but you will be reading about those when we talk about shell scripting. + +### Copying, Moving, Linking + +Obviously, there are more ways of modifying and handling files from the command line than just playing around with their permissions. Most applications will create a new file if you still try to open a file that doesn't exist. Both +``` +nano test.txt + +``` + +and +``` +vim test.txt + +``` + +([nano][3] and [vim][4] being to popular command line text editors) will create an empty _test.txt_ file for you to edit if _test.txt_ didn't exist beforehand. + +You can also create an empty file by _touching_ it: +``` +touch test.txt + +``` + +Will create a file, but not open it in any application. + +You can use `cp` to make a copy of a file in another location or under a new name: +``` +cp test.txt copy_of_test.txt + +``` + +You can also copy a whole bunch of files: +``` +cp *.png /home/images + +``` + +The instruction above copies all the PNG files in the current directory into an _images/_ directory hanging off of your home directory. The _images/_ directory has to exist before you try this, or `cp` will show an error. Also, be warned that, if you copy a file to a directory that contains another file with the same name, `cp` will silently overwrite the old file with the new one. + +You can use +``` +cp -i *.png /home/images + +``` + +If you want `cp` to warn you of any dangers (the `-i` options stands for _interactive_ ). + +You can also copy whole directories, but you need the `-r` option for that: +``` +cp -rv directory_a/ directory_b + +``` + +The `-r` option stands for _recursive_ , meaning that `cp` will drill down into _directory_a_ , copying over all the files and subdirectories contained within. I personally like to include the `-v` option, as it makes `cp` _verbose_ , meaning that it will show you what it is doing instead of just copying silently and then exiting. + +The `mv` command moves stuff. That is, it changes files from one location to another. In its simplest form, `mv` looks a lot like `cp`: +``` +mv test.txt new_test.txt + +``` + +The command above makes _new_test.txt_ appear and _test.txt_ disappear. +``` +mv *.png /home/images + +``` + +Moves all the PNG files in the current directory to a directory called _images/_ hanging of your home directory. Again you have to be careful you do not overwrite existing files by accident. Use +``` +mv -i *.png /home/images + +``` + +the same way you would with `cp` if you want to be on the safe side. + +Apart from moving versus copying, another difference between `mv` and `cp`is when you move a directory: +``` +mv directory_a/ directory_b + +``` + +No need for a recursive flag here. This is because what you are really doing is renaming the directory, the same way in the first example, you were renaming the file*. In fact, even when you "move" a file from one directory to another, as long as both directories are on the same storage device and partition, you are renaming the file. + +You can do an experiment to prove it. `time` is a tool that lets you measure how long a command takes to execute. Look for a hefty file, something that weighs several hundred MBs or even some GBs (say, something like a long video) and try copying it from one directory to another like this: +``` +$ time cp hefty_file.mkv another_directory/ +real 0m3,868s +user 0m0,016s +sys 0m0,887s + +``` + +In bold is what you have to type into the terminal and below what `time` outputs. The number to focus on is the one on the first line, _real_ time. It takes nearly 4 seconds to copy the 355 MBs of _hefty_file.mkv_ to _another_directory/_. + +Now let's try moving it: +``` +$ time mv hefty_file.mkv another_directory/ +real 0m0,004s +user 0m0,000s +sys 0m0,003s + +``` + +Moving is nearly instantaneous! This is counterintuitive, since it would seem that `mv` would have to copy the file and then delete the original. That is two things `mv` has to do versus `cp`'s one. But, somehow, `mv` is 1000 times faster. + +That is because the file system's structure, with all its tree of directories, only exists for the users convenience. At the beginning of each partition there is something called a _partition table_ that tells the operating system where to find each file on the actual physical disk. On the disk, data is not split up into directories or even files. [There are tracks, sectors and clusters instead][5]. When you "move" a file within the same partition, what the operating system does is just change the entry for that file in the partition table, but it still points to the same cluster of information on the disk. + +Yes! Moving is a lie! At least within the same partition that is. If you try and move a file to a different partition or a different device, `mv` is still fast, but is noticeably slower than moving stuff around within the same partition. That is because this time there is actually copying and erasing of data going on. + +### Renaming + +There are several distinct command line `rename` utilities around. None are fixtures like `cp` or `mv` and they can work in slightly different ways. What they all have in common is that they are used to change _parts_ of the names of files. + +In Debian and Ubuntu, the default `rename` utility uses [regular expressions][6] (patterns of strings of characters) to mass change files in a directory. The instruction: +``` +rename 's/\.JPEG$/.jpg/' * + +``` + +will change all the extensions of files with the extension _JPEG_ to _jpg_. The file _IMG001.JPEG_ becomes _IMG001.jpg_ , _my_pic.JPEG_ becomes _my_pic.jpg_ , and so on. + +Another version of `rename` available by default in Manjaro, a derivative of Arch, is much simpler, but arguably less powerful: +``` +rename .JPEG .jpg * + +``` + +This does the same renaming as you saw above. In this version, `.JPEG` is the string of characters you want to change, `.jpg` is what you want to change it to, and `*` represents all the files in the current directory. + +The bottom line is that you are better off using `mv` if all you want to do is rename one file or directory, and that's because `mv` is realiably the same in all distributions everywhere. + +### Learning more + +Check out the both `mv` and `cp`'s _man_ pages to learn more. Run +``` +man cp + +``` + +or +``` +man mv + +``` + +to read about all the options these commands come with and which make them more powerful and safer to use. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/2018/8/linux-beginners-moving-things-around + +作者:[Paul Brown][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/bro66 +[1]: https://www.linux.com/blog/learn/2018/5/manipulating-directories-linux +[2]: https://www.linux.com/blog/learn/intro-to-linux/2018/7/users-groups-and-other-linux-beasts-part-2 +[3]: https://www.nano-editor.org/ +[4]: https://www.vim.org/ +[5]: https://en.wikipedia.org/wiki/Disk_sector +[6]: https://en.wikipedia.org/wiki/Regular_expression From b4bec996d7d7ee48124ba5a46dccacbd17b238ad Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:44:33 +0800 Subject: [PATCH 047/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Reset?= =?UTF-8?q?=20MySQL=20Or=20MariaDB=20Root=20Password?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...To Reset MySQL Or MariaDB Root Password.md | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md diff --git a/sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md b/sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md new file mode 100644 index 0000000000..69bfa2e2de --- /dev/null +++ b/sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md @@ -0,0 +1,98 @@ +How To Reset MySQL Or MariaDB Root Password +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/08/Reset-MySQL-Or-MariaDB-Root-Password-720x340.png) + +Few months ago, I had [**setup LAMP stack in Ubuntu 18.04**][1] server. Today, I tried to login as root user in my database server, but I completely forgot the password. After couple Google searches and going through some blog posts, I successfully reset the password. For those wondering how to do this, this brief tutorial explains how can we reset MySQL or MariaDB Root password in Unix-like operating systems. + +### Reset MySQL or MariaDB Root password + +First, stop the database server. + +If you use MySQL, type the following command and hit ENTER key. +``` +$ sudo systemctl stop mysql + +``` + +For MariaDB: +``` +$ sudo systemctl stop mariadb + +``` + +Next, restart the database server without permission checking using the following command: +``` +$ sudo mysqld_safe --skip-grant-tables & + +``` + +Here, the **`--skip-grant-tables`**option allows you to connect without a password and with all privileges. If you start your server with this option, it also enables `--skip-networking`option which is used to prevent the other clients from connecting to the database server. And, the ampersand **( &)** symbol is used to run the command in background, so you could type the other commands in the following steps. Please be mindful that the above command is dangerous and your database server becomes insecure. You should run this command only for a brief period to reset the password. + +Next, login to your MySQL/MariaDB server as root user: +``` +$ mysql + +``` + +At the **mysql >** or **MariaDB [(none)] >** prompt, run the following command to reset the root user password: +``` +UPDATE mysql.user SET Password=PASSWORD('NEW-PASSWORD') WHERE User='root'; + +``` + +Replace **NEW-PASSWORD** in the above command with your own password. + +Then, type following commands to exit from the mysql console. +``` +FLUSH PRIVILEGES; + +exit + +``` + +Finally, shutdown the running database server that you started earlier with `--skip-grant-tables`option. To do so, run: +``` +$ sudo mysqladmin -u root -p shutdown + +``` + +You will be asked to enter your mysql/mariadb root user password that you set in the previous step. + +Now, start mysql/mariadb service normally using command: +``` +$ sudo systemctl start mysql + +``` + +For MariaDB: +``` +$ sudo systemctl start mariadb + +``` + +Verify if the password has really been changed using the following command: +``` +$ mysql -u root -p + +``` + +And, that’s all for today. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-reset-mysql-or-mariadb-root-password/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://www.ostechnix.com/install-apache-mariadb-php-lamp-stack-ubuntu-16-04/ From 3791b34c927911244f418d94c9488c0719e73645 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:45:59 +0800 Subject: [PATCH 048/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20Update?= =?UTF-8?q?=20Firmware=20on=20Ubuntu=2018.04?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... How to Update Firmware on Ubuntu 18.04.md | 97 +++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md diff --git a/sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md b/sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md new file mode 100644 index 0000000000..cac9c2aa3d --- /dev/null +++ b/sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md @@ -0,0 +1,97 @@ +How to Update Firmware on Ubuntu 18.04 +====== +Usually, the default software center in Ubuntu and other Linux handle the update of the firmware of your system. But if you encounter errors with it, you can use fwupd command line tool for updating the firmware of your system. + +I use [Dell XPS 13 Ubuntu edition][1] as my main operating system. I have done a fresh [installation of Ubuntu 18.04][2] on it and I cannot be happier with the hardware compatibility. Bluetooth, external USB headsets and speakers, multi-monitor, everything works out of the box. + +The one thing that troubled me was one of the [firmware][3] updates that appeared in the Software Center. + +![Updating firmware in Ubuntu][4] + +Clicking on the Update button resulted in an error a few seconds later. + +![Updating firmware in Ubuntu][5] + +The error message was: + +**Unable to update “Thunderbolt NVM for Xps Notebook 9360”: could not detect device after update: timed out while waiting for device** + +In this quick tip, I’ll show you how to update the firmware of your system in [Ubuntu][6]. + +### Updating firmware in Ubuntu 18.04 + +![How to update firmware in Ubuntu][7] + +One thing you should know that GNOME Software i.e. the software center in Ubuntu 18.04 is also capable of updating the firmware. But in situations when it fails for some reason, you can use the command line tool fwupd. + +[fwupd][8] is an open source daemon that handles firmware upgrades in Linux based systems. It is created by GNOME developer [Richard Hughes][9]. Developers from Dell also contributed to the development of this open source tool. + +Basically, it utilizes the LVFS, Linux Vendor Firmware Service. Hardware vendors upload redistributable firmware to the LVFS site and thanks to fwupd, you can upgrade those firmware from inside the operating system itself. fwupd is supported by major Linux distributions like Ubuntu and Fedora. + +Open a terminal and update your system first: +``` +sudo apt update && sudo apt upgrade -y + +``` + +After that you can use the following commands one by one to start the daemon, refresh the list of available firmware updates and install the firmware updates. +``` +sudo service fwupd start + +``` + +Once the daemon is running, check if there are any firmware updates available. +``` +sudo fwupdmgr refresh + +``` + +The output should look like this: + +Fetching metadata +Downloading… [****************************] +Fetching signature + +After this, run the firmware update: +``` +sudo fwupdmgr update + +``` + +The output of the firmware update could be similar to this: + +``` +No upgrades for XPS 13 9360 TPM 2.0, current is 1.3.1.0: 1.3.1.0=same +No upgrades for XPS 13 9360 System Firmware, current is 0.2.8.1: 0.2.8.1=same, 0.2.7.1=older, 0.2.6.2=older, 0.2.5.1=older, 0.2.4.2=older, 0.2.3.1=older, 0.2.2.1=older, 0.2.1.0=older, 0.1.3.7=older, 0.1.3.5=older, 0.1.3.2=older, 0.1.2.3=older +Downloading 21.00 for XPS13 9360 Thunderbolt Controller… +Updating 21.00 on XPS13 9360 Thunderbolt Controller… +Decompressing… [***********] +Authenticating… [***********] +Restarting device… [***********] +``` + +This should handle the firmware update in Ubuntu 18.04. I hope this quick tip helped you with firmware updates in Linux. + +If you have questions or suggestions, please feel free to use the comment section below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/update-firmware-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[1]: https://itsfoss.com/dell-xps-13-ubuntu-review/ +[2]: https://itsfoss.com/install-ubuntu-dual-boot-mode-windows/ +[3]: https://en.wikipedia.org/wiki/Firmware +[4]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/ubuntu-firmware-update-error-1.png +[5]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/ubuntu-firmware-update-error-2.jpg +[6]: https://www.ubuntu.com/ +[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/update-firmware-ubuntu.png +[8]: https://fwupd.org/ +[9]: https://github.com/hughsie/fwupd From aa10168f91226b08f33f2f931dc331b00020f551 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 3 Sep 2018 15:50:10 +0800 Subject: [PATCH 049/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Getting=20started?= =?UTF-8?q?=20with=20the=20i3=20window=20manager=20on=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ted with the i3 window manager on Linux.md | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 sources/tech/20180929 Getting started with the i3 window manager on Linux.md diff --git a/sources/tech/20180929 Getting started with the i3 window manager on Linux.md b/sources/tech/20180929 Getting started with the i3 window manager on Linux.md new file mode 100644 index 0000000000..0aa266b448 --- /dev/null +++ b/sources/tech/20180929 Getting started with the i3 window manager on Linux.md @@ -0,0 +1,118 @@ +Getting started with the i3 window manager on Linux +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows-tiling-windows-wall.png?itok=mTH7uVrn) + +In my article [5 reasons the i3 window manager makes Linux better][1], I shared the top five reasons I use and recommend the [i3 window manager][2] as an alternative Linux desktop experience. + +In this post, I will walk through the installation and basic configuration of i3 on Fedora 28 Linux. + +### 1\. Installation + +Log into a Fedora workstation and open up a terminal. Use `dnf` to install the required package, like this: +``` +[ricardo@f28i3 ~]$ sudo dnf install -y i3 i3-ipc i3status i3lock dmenu terminator --exclude=rxvt-unicode +Last metadata expiration check: 1:36:15 ago on Wed 08 Aug 2018 12:04:31 PM EDT. +Dependencies resolved. +================================================================================================ + Package                     Arch         Version                           Repository     Size +================================================================================================ +Installing: + dmenu                       x86_64       4.8-1.fc28                        fedora         33 k + i3                          x86_64       4.15-1.fc28                       fedora        323 k + i3-ipc                      noarch       0.1.4-12.fc28                     fedora         14 k + i3lock                      x86_64       2.9.1-2.fc28                      fedora         33 k + i3status                    x86_64       2.12-1.fc28                       updates        62 k + terminator                  noarch       1.91-4.fc28                       fedora        570 k +Installing dependencies: + dzen2                       x86_64       0.8.5-21.20100104svn.fc28         fedora         60 k + +... Skipping dependencies/install messages + +Complete! +[ricardo@f28i3 ~]$ +``` + +**Note:** In this command, I'm explicitly excluding the package `rxvt-unicode` because I prefer `terminator` as my terminal emulator. + +Depending on the status of your system, it may install many dependencies. Wait for the installation to complete successfully and then reboot your machine. + +### 2. First login and initial setup + +After your machine restarts, you're ready to log into i3 for the first time. In the GNOME Display Manager (GDM) screen, click on your username but—before typing the password to log in—click on the small gear icon and change the session to i3 instead of GNOME, like this: + +![](https://opensource.com/sites/default/files/uploads/i3_first_login_small.png) + +Type your password and click `Sign In`. On your first login, you are presented with the i3 configuration screen: + +![](https://opensource.com/sites/default/files/uploads/i3_first_configuration_small.png) + +Press `ENTER` to generate a config file in your `$HOME/.config/i3` directory. Later you can use this config file to further customize i3's behavior. + +On the next screen, you need to select your `Mod` key. This is important, as the `Mod` key is used to trigger most of i3's keyboard shortcuts. Press `ENTER` to use the default `Win` key as the `Mod` key. If you don't have a `Win` key on your keyboard or prefer to use `Alt` instead, use the arrow key to select it and press `ENTER` to confirm. + +![](https://opensource.com/sites/default/files/uploads/i3_generate_config_small.png) + +You're now logged into your i3 session. Because i3 is a minimalist window manager, you see a black screen with the status bar on the bottom: + +![](https://opensource.com/sites/default/files/uploads/i3_start_small.png) + +Next, let's look at navigating in i3. + +### 3\. Basic shortcuts + +Now that you're logged into an i3 session, you'll need a few basic keyboard shortcuts to get around. + +The majority of i3 shortcuts use the `Mod` key you defined during the initial configuration. When I refer to `Mod` in the following examples, press the key you defined. This will usually be the `Win` key, but it can also be the `Alt` key. + +First, to open up a terminal, use `Mod+ENTER`. Open more than one terminal and notice how i3 automatically tiles them to occupy all available space. By default, i3 splits the screen horizontally; use `Mod+v` to split vertically and press `Mod+h` to go back to the horizontal split. + +![](https://opensource.com/sites/default/files/uploads/i3_3terminal_tiled_small.png) + +To start other applications, press `Mod+d` to open `dmenu`, a simple text-based application menu. By default, `dmenu` presents a list of all applications available on your `$PATH`. Select the application you want to start by using the arrow keys or narrow down the search by typing parts of the application's name. Press `ENTER` to start the selected application. + +![](https://opensource.com/sites/default/files/uploads/i3_dmenu.png) + +If your application does not provide a way to close it, you can use i3 to kill a window by pressing `Mod+Shift+q`. Be careful, as you may lose unsaved work—this behavior depends on each application. + +Finally, to end your session and exit i3, press `Mod+Shift+e`. You are presented with a confirmation message at the top of your screen. Click on `Yes, exit i3` to exit or `X` to cancel. + +![](https://opensource.com/sites/default/files/uploads/i3_exit_small.png) + +This is just an initial list of shortcuts you can use to get around i3. For many more, consult i3's official [documentation][3]. + +### 4\. Replacing GDM + +Using i3 window manager reduces the memory utilization on your system; however, Fedora still uses the default GDM as its login screen. GDM loads several GNOME-related libraries and applications that consume memory. + +If you want to further reduce your system's memory utilization, you can replace GDM with a more lightweight display manager, such as `lightdm`, like this: +``` +[ricardo@f28i3 ~]$ sudo dnf install -y lightdm +[ricardo@f28i3 ~]$ sudo systemctl disable gdm +Removed /etc/systemd/system/display-manager.service. +[ricardo@f28i3 ~]$ sudo systemctl enable lightdm +Created symlink /etc/systemd/system/display-manager.service -> /usr/lib/systemd/system/lightdm.service. +[ricardo@f28i3 ~]$ +``` + +Restart your machine to see the Lightdm login screen. + +Now you're ready to log in and use i3. + +![](https://opensource.com/sites/default/files/uploads/i3_lightdm_small.png) + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/getting-started-i3-window-manager + +作者:[Ricardo Gerardi][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rgerardi +[1]: https://opensource.com/article/18/8/i3-tiling-window-manager +[2]: https://i3wm.org +[3]: https://i3wm.org/docs/userguide.html#_default_keybindings From 00fcd4ca2af972f0d5512f4f9fa662bfd725c9a6 Mon Sep 17 00:00:00 2001 From: David Chen Date: Mon, 3 Sep 2018 21:08:13 +0800 Subject: [PATCH 050/455] 20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md --- ...Hub on Ubuntu Linux- A beginner-s guide.md | 162 ------------------ ...Hub on Ubuntu Linux- A beginner-s guide.md | 147 ++++++++++++++++ 2 files changed, 147 insertions(+), 162 deletions(-) delete mode 100644 sources/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md create mode 100644 translated/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md diff --git a/sources/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md b/sources/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md deleted file mode 100644 index e8d4cb8a98..0000000000 --- a/sources/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md +++ /dev/null @@ -1,162 +0,0 @@ -Translating by DavidChenLiang - -Installing and using Git and GitHub on Ubuntu Linux: A beginner's guide -====== - -GitHub is a treasure trove of some of the world's best projects, built by the contributions of developers all across the globe. This simple, yet extremely powerful platform helps every individual interested in building or developing something big to contribute and get recognized in the open source community. - -This tutorial is a quick setup guide for installing and using GitHub and how to perform its various functions of creating a repository locally, connecting this repo to the remote host that contains your project (where everyone can see), committing the changes and finally pushing all the content in the local system to GitHub. - -Please note that this tutorial assumes that you have a basic knowledge of the terms used in Git such as push, pull requests, commit, repository, etc. It also requires you to register to GitHub [here][1] and make a note of your GitHub username. So let's begin: - -### 1 Installing Git for Linux - -Download and install Git for Linux: - -``` -sudo apt-get install git -``` - -The above command is for Ubuntu and works on all Recent Ubuntu versions, tested from Ubuntu 16.04 to Ubuntu 18.04 LTS (Bionic Beaver) and it's likely to work the same way on future versions. - -### 2 Configuring GitHub - -Once the installation has successfully completed, the next thing to do is to set up the configuration details of the GitHub user. To do this use the following two commands by replacing "user_name" with your GitHub username and replacing "email_id" with your email-id you used to create your GitHub account. - -``` -git config --global user.name "user_name" - -git config --global user.email "email_id" -``` - -The following image shows an example of my configuration with my "user_name" being "akshaypai" and my "email_id" being "[[email protected]][2]" - -[![Git config][3]][4] - -### 3 Creating a local repository - -Create a folder on your system. This will serve as a local repository which will later be pushed onto the GitHub website. Use the following command: - -``` -git init Mytest -``` - -If the repository is created successfully, then you will get the following line: - -Initialized empty Git repository in /home/akshay/Mytest/.git/ - -This line may vary depending on your system. - -So here, Mytest is the folder that is created and "init" makes the folder a GitHub repository. Change the directory to this newly created folder: - -``` -cd Mytest -``` - -### 4 Creating a README file to describe the repository - -Now create a README file and enter some text like "this is a git setup on Linux". The README file is generally used to describe what the repository contains or what the project is all about. Example: - -``` -gedit README -``` - -You can use any other text editors. I use gedit. The content of the README file will be: - -This is a git repo - -### 5 Adding repository files to an index - -This is an important step. Here we add all the things that need to be pushed onto the website into an index. These things might be the text files or programs that you might add for the first time into the repository or it could be adding a file that already exists but with some changes (a newer version/updated version). - -Here we already have the README file. So, let's create another file which contains a simple C program and call it sample.c. The contents of it will be: -``` - -#include -int main() -{ -printf("hello world"); -return 0; -} - -``` - -So, now that we have 2 files - -README and sample.c - -add it to the index by using the following 2 commands: - -``` -git add README - -git add smaple.c -``` - -Note that the "git add" command can be used to add any number of files and folders to the index. Here, when I say index, what I am referring to is a buffer like space that stores the files/folders that have to be added into the Git repository. - -### 6 Committing changes made to the index - -Once all the files are added, we can commit it. This means that we have finalized what additions and/or changes have to be made and they are now ready to be uploaded to our repository. Use the command : - -``` -git commit -m "some_message" -``` - -"some_message" in the above command can be any simple message like "my first commit" or "edit in readme", etc. - -### 7 Creating a repository on GitHub - -Create a repository on GitHub. Notice that the name of the repository should be the same as the repository's on the local system. In this case, it will be "Mytest". To do this login to your account on . Then click on the "plus(+)" symbol at the top right corner of the page and select "create new repository". Fill the details as shown in the image below and click on "create repository" button. - -[![Creating a repository on GitHub][5]][6] - -Once this is created, we can push the contents of the local repository onto the GitHub repository in your profile. Connect to the repository on GitHub using the command: - -Important Note: Make sure you replace 'user_name' and 'Mytest' in the path with your Github username and folder before running the command! - -``` -git remote add origin -``` - -### 8 Pushing files in local repository to GitHub repository - -The final step is to push the local repository contents into the remote host repository (GitHub), by using the command: - -``` -git push origin master -``` - -Enter the login credentials [user_name and password]. - -The following image shows the procedure from step 5 to step 8 - -[![Pushing files in local repository to GitHub repository][7]][8] - -So this adds all the contents of the 'Mytest' folder (my local repository) to GitHub. For subsequent projects or for creating repositories, you can start off with step 3 directly. Finally, if you log in to your GitHub account and click on your Mytest repository, you can see that the 2 files README and sample.c have been uploaded and are visible to all as shown in the following image. - -[![Content uploaded to Github][9]][10] - - --------------------------------------------------------------------------------- - -via: https://www.howtoforge.com/tutorial/install-git-and-github-on-ubuntu/ - -作者:[Akshay Pai][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.howtoforge.com/tutorial/installing-tensorflow-neural-network-software-for-cpu-and-gpu-on-ubuntu-16-04/ -[1]:https://github.com/ -[2]:https://www.howtoforge.com/cdn-cgi/l/email-protection -[3]:https://www.howtoforge.com/images/ubuntu_github_getting_started/config.png -[4]:https://www.howtoforge.com/images/ubuntu_github_getting_started/big/config.png -[5]:https://www.howtoforge.com/images/ubuntu_github_getting_started/details.png -[6]:https://www.howtoforge.com/images/ubuntu_github_getting_started/big/details.png -[7]:https://www.howtoforge.com/images/ubuntu_github_getting_started/steps.png -[8]:https://www.howtoforge.com/images/ubuntu_github_getting_started/big/steps.png -[9]:https://www.howtoforge.com/images/ubuntu_github_getting_started/final.png -[10]:https://www.howtoforge.com/images/ubuntu_github_getting_started/big/final.png diff --git a/translated/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md b/translated/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md new file mode 100644 index 0000000000..e52f108c39 --- /dev/null +++ b/translated/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md @@ -0,0 +1,147 @@ +在Ubuntu Linux上安装和使用Git和GitHub:初学者指南 +====== + +Github是一个存放着世界上最棒的一些软件项目的宝藏,这些软件项目由全世界的开发者无私贡献。这个看似简单,实则非常强大的平台因为大大帮助了那些对开发大规模软件感兴趣的开发者而被开源社区所称道。 + +这篇向导是对于安装和使用GitHub的的一个快速说明,本文还将涉及诸如创建本地仓库,如何链接这个本地仓库到包含你的项目的远程仓库(这样每个人都能看到你的项目了), 以及如何提交改变并最终推送所有的本地内容到Github。 + +请注意这篇向导假设你对Git术语有基本的了解,如推送,拉取请求,提交,仓库等等。并且希望你在GitHub上已注册成功并记下了你的GitHub用户名,那么我们这就进入正题吧: + +### 1 在Linux上安装Git + +下载并安装Git: + +``` +sudo apt-get install git +``` + +上面的命令适用于Ubuntu并且应该在所有最新版的Ubuntu上都能工作,它们在Ubuntu 16.04和Ubuntu 18.04 LTS (Bionic Beaver)上都测试过,在将来的版本上应该也能工作。 + + +### 2 配置GitHub + +一旦安装完成,接下去就是配置GitHub用户的详细配置信息。请使用下面的两条命令并确保用你自己的GitHub用户名替换"user_name",用你创建GitHub账户的电子邮件替换“email_id”。 + +``` +git config --global user.name "user_name" + +git config --global user.email "email_id" + +``` + +下面的图片显示的例子是如何用我的 GitHub “用户名”:“akshaypai”和我的"邮件地址"[[email protected]][2]来配置上面的命令。 + +[![Git config][3]][4] + +### 3 创建本地仓库 +在你的系统上创建一个目录。它将会被作为本地仓库使用,稍后它会被推送到 GitHub 的远程仓库。请使用如下命令: + +``` +git init Mytest +``` +如果目录被成功创建,你会看到如下信息: + +Initialized empty Git repository in /home/akshay/Mytest/.git/ + +这行信息可能随你的系统不同而变化。 +这里,Mytest 是创建的目录而“init” 将其转化为一个 GitHub 仓库。将当前目录改为这个新创建的目录。 + +``` +cd Mytest +``` + +### 4 新建一个 REAME 文件来描述仓库 +现在创建一个 README 文件并输入一些文本,如“this is git setup on linux”。REAME 文件一般用于描述这个仓库用来放置什么内容或这个项目是关于什么的。例如: + +``` +gedit README +``` +你可以使用任何文本编辑器。我喜欢使用gedit。README文件的内容可以为: + +This is a git repo + +### 5 将仓库里的文件加入一个索引 +这是很重要的一步。这里我们会将所有需要推送到 GitHub 的内容都加入一个索引。这些内容可能包括你第一次加入仓库的文本文件或者应用程序,也有可能是对已存在文件的一些编辑(文件的一个更新版本)。 +既然我们已经有了 README 文件,那么让我们创建一个别的文件吧,如一个简单的 C 程序,我们叫它sample.c。文件内容是: + +``` + +#include +int main() +{ +printf("hello world"); +return 0; +} + +``` + +现在我们有两个文件了。 +README 和 sample.c +用下面的命令将他们加入索引: + +``` +git add README + +git add smaple.c +``` + +请注意“git add” 命令能将任意数量的文件和目录加入到索引。这里,当我说“ 索引” 的时候,我是指一个有一定空间的缓冲区,这个缓冲区存储了所有已经被加入到 Git 仓库的文件或目录。 + +### 6 将所作的改动加入索引 +所有的文件都加好以后,你就可以提交了。这意味着你已经确定了最终的文件改动( 或增加),现在他们已经准备好被上传到我们自己的仓库了。请使用命令: + +``` +git commit -m "some_message" +``` +“some_message”在上面的命令里可以是一些简单的信息如“我的第一次提交”或者“ 编辑了readme 文件”,等等。 + +### 7 在GitHub上创建一个仓库 +在 GitHub 上创建一个仓库。请注意仓库的名字必须和你本地创建的仓库的名字严格一致。在这个例子里是'Mytest'。请首先登陆你的 GitHub 账户。点击页面右上角 的"plus(+)"符号,并选择"create nw repository"。如下图所示填入详细信息,点击“create repository”。 + +[![Creating a repository on GitHub][5]][6] +一旦创建完成,我们就能将本地的仓库推送到 GitHub 你名下的仓库,用下列命令连接 GitHub 上的仓库: +请注意:请确保在运行下列命令前替换了路径中的“user_name” 和“Mytest”为你的 GitHub 用户名和目录名! + +``` +git remote add origin https://github.com/user\_name/Mytest.git> +``` + +### 8 将本地仓库里的文件推送的GitHub仓库 +最后一步是用下列的命令将本地仓库的内容推送到远程仓库(GitHub) + + +``` +git push origin master +``` +当提示登陆名和密码时键入登陆名和密码。 +下面的图片显示了步骤5到步骤8的流程 + +[![Pushing files in local repository to GitHub repository][7]][8] + +上述将 Mytest 目录里的所有内容(文件) 推送到了GitHub。对于以后的项目或者创建新的仓库,你可以直接从步骤3开始。最后,如果你登陆你的 GitHub 账户并点击你的Mytest 仓库,你会看到这两个文件:README 和sample.c 已经被上传并像如下 图片显示: + +[![Content uploaded to Github][9]][10] + + +-------------------------------------------------------------------------------- + +via: https://www.howtoforge.com/tutorial/install-git-and-github-on-ubuntu/ + +作者:[Akshay Pai][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[DavidChenLiang](https://github.com/DavidChenLiang) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.howtoforge.com/tutorial/installing-tensorflow-neural-network-software-for-cpu-and-gpu-on-ubuntu-16-04/ +[1]:https://github.com/ +[2]:https://www.howtoforge.com/cdn-cgi/l/email-protection +[3]:https://www.howtoforge.com/images/ubuntu_github_getting_started/config.png +[4]:https://www.howtoforge.com/images/ubuntu_github_getting_started/big/config.png +[5]:https://www.howtoforge.com/images/ubuntu_github_getting_started/details.png +[6]:https://www.howtoforge.com/images/ubuntu_github_getting_started/big/details.png +[7]:https://www.howtoforge.com/images/ubuntu_github_getting_started/steps.png +[8]:https://www.howtoforge.com/images/ubuntu_github_getting_started/big/steps.png +[9]:https://www.howtoforge.com/images/ubuntu_github_getting_started/final.png +[10]:https://www.howtoforge.com/images/ubuntu_github_getting_started/big/final.png From 60ac299b3b72ce1a1059357481bd5ad19f26be4c Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 4 Sep 2018 09:07:13 +0800 Subject: [PATCH 051/455] translated --- ...ress blog to a static GitLab Pages site.md | 92 ------------------- ...ress blog to a static GitLab Pages site.md | 90 ++++++++++++++++++ 2 files changed, 90 insertions(+), 92 deletions(-) delete mode 100644 sources/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md create mode 100644 translated/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md diff --git a/sources/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md b/sources/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md deleted file mode 100644 index fd52def010..0000000000 --- a/sources/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md +++ /dev/null @@ -1,92 +0,0 @@ -translating---geekpi - -How to publish a WordPress blog to a static GitLab Pages site -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-design-monitor-website.png?itok=yUK7_qR0) - -A long time ago, I set up a WordPress blog for a family member. There are lots of options these days, but back then there were few decent choices if you needed a web-based CMS with a WYSIWYG editor. An unfortunate side effect of things working well is that the blog has generated a lot of content over time. That means I was also regularly updating WordPress to protect against the exploits that are constantly popping up. - -So I decided to convince the family member that switching to [Hugo][1] would be relatively easy, and the blog could then be hosted on [GitLab][2]. But trying to extract all that content and convert it to [Markdown][3] turned into a huge hassle. There were automated scripts that got me 95% there, but nothing worked perfectly. Manually updating all the posts was not something I wanted to do, so eventually, I gave up trying to move the blog. - -Recently, I started thinking about this again and realized there was a solution I hadn't considered: I could continue maintaining the WordPress server but set it up to publish a static mirror and serve that with [GitLab Pages][4] (or [GitHub Pages][5] if you like). This would allow me to automate [Let's Encrypt][6] certificate renewals as well as eliminate the security concerns associated with hosting a WordPress site. This would, however, mean comments would stop working, but that feels like a minor loss in this case because the blog did not garner many comments. - -Here's the solution I came up with, which so far seems to be working well: - - * Host WordPress site at URL that is not linked to or from anywhere else to reduce the odds of it being exploited. In this example, we'll use (even though this site is actually built with Pelican). - * [Set up hosting on GitLab Pages][7] for the public URL . - * Add a [cron job][8] that determines when the last-built date differs between the two URLs; if the build dates differ, mirror the WordPress version. - * After mirroring with `wget`, update all links from "private" version to "public" version. - * Do a `git push` to publish the new content. - - - -These are the two scripts I use: - -`check-diff.sh` (called by cron every 15 minutes) -``` -#!/bin/bash - -ORIGINDATE="$(curl -v --silent http://private.localconspiracy.com/feed/ 2>&1|grep lastBuildDate)" -PUBDATE="$(curl -v --silent https://www.localconspiracy.com/feed/ 2>&1|grep lastBuildDate)" - -if [ "$ORIGINDATE" !=  "$PUBDATE" ] -then -  /home/doc/repos/localconspiracy/mirror.sh -fi -``` - -`mirror.sh:` -``` -#!/bin/sh - -cd /home/doc/repos/localconspiracy - -wget \ ---mirror \ ---convert-links  \ ---adjust-extension \ ---page-requisites  \ ---retry-connrefused  \ ---exclude-directories=comments \ ---execute robots=off \ -http://private.localconspiracy.com - -git rm -rf public/* -mv private.localconspiracy.com/* public/. -rmdir private.localconspiracy.com -find ./public/ -type f -exec sed -i -e 's|http://private.localconspiracy|https://www.localconspiracy|g' {} \; -find ./public/ -type f -exec sed -i -e 's|http://www.localconspiracy|https://www.localconspiracy|g' {} \; -git add public/* -git commit -m "new snapshot" -git push origin master -``` - -That's it! Now, when the blog is changed, within 15 minutes the site is mirrored to a static version and pushed up to the repo where it will be reflected in GitLab pages. - -This concept could be extended a little further if you wanted to [run WordPress locally][9]. In that case, you would not need a server to host your WordPress blog; you could just run it on your local machine. In that scenario, there's no chance of your blog getting exploited. As long as you can run `wget` against it locally, you could use the approach outlined above to have a WordPress site hosted on GitLab Pages. - -_This article was originally posted at[Local Conspiracy][10]. Reposted with permission._ - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/publish-wordpress-static-gitlab-pages-site - -作者:[Christopher Aedo][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/docaedo -[1]:https://gohugo.io/ -[2]:https://gitlab.com/ -[3]:https://en.wikipedia.org/wiki/Markdown -[4]:https://docs.gitlab.com/ee/user/project/pages/ -[5]:https://pages.github.com/ -[6]:https://letsencrypt.org/ -[7]:https://about.gitlab.com/2016/04/07/gitlab-pages-setup/ -[8]:https://en.wikipedia.org/wiki/Cron -[9]:https://codex.wordpress.org/Installing_WordPress_Locally_on_Your_Mac_With_MAMP -[10]:https://localconspiracy.com/2018/08/wp-on-gitlab.html diff --git a/translated/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md b/translated/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md new file mode 100644 index 0000000000..dc10d754d0 --- /dev/null +++ b/translated/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md @@ -0,0 +1,90 @@ +如何将 WordPress 博客发布到静态 GitLab Pages 上 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-design-monitor-website.png?itok=yUK7_qR0) + +很久以前,我为一个家庭成员建立了一个 WordPress 博客。现在有很多选择,但是当时如果你需要一个带有 WYSIWYG 编辑器的基于网络的 CMS,那么当时很少有不错的选择。运行良好的一个不幸的副作用是博客随着时间的推移产生了很多内容。这意味着我要经常更新 WordPress 以防止不断出现的漏洞。 + +因此,我决定劝说家人切换到 [Hugo][1] 会相对容易,然后可以在 [GitLab][2] 上托管博客。但是尝试提取所有内容并将其转换为 [Markdown][3] 变成了一个巨大的麻烦。有自动脚本完成了 95% 的工作,但并不完美。手动更新所有帖子不是我想做的事情,所以最终,我放弃了试图移动博客。 + +最近,我又开始考虑这个问题,并意识到有一个我没有考虑过的解决方案:我可以继续维护 WordPress 服务器,但将其设置为发布静态镜像,并使用 [GitLab Pages][4](或 [ GitHub Pages][5] ,如果你喜欢的话)服务。这能让我自动化 [Let's Encrypt][6] 证书续订并消除与托管 WordPress 站点相关的安全问题。然而,这意味着评论将无法使用,但在这种情况下感觉就像是一个小损失,因为博客没有收到很多评论。 + +这是我提出的解决方案,到目前为止似乎运作良好: + + * WordPress 站点中的 URL 没有链接到或来自其他任何地方,以减少它被利用的几率。在此例中,我们将使用 (即使此站点实际上是使用 Pelican 构建的)。 + * 为公共 URL [在 GitLab Pages 上设置托管][7]。 + * 添加 [cron job][8],确定两个 URL 之间的最后构建日期何时不同。如果构建日期不同,则镜像 WordPress 版本。 + * 使用 `wget` 镜像后,将所有链接从“私有”更新成“公共”。 + * 运行 `git push` 来发布新内容。 + + + +这是我使用的两个脚本: + +`check-diff.sh` (cron 每 15 分钟调用一次) +``` +#!/bin/bash + +ORIGINDATE="$(curl -v --silent http://private.localconspiracy.com/feed/ 2>&1|grep lastBuildDate)" +PUBDATE="$(curl -v --silent https://www.localconspiracy.com/feed/ 2>&1|grep lastBuildDate)" + +if [ "$ORIGINDATE" !=  "$PUBDATE" ] +then +  /home/doc/repos/localconspiracy/mirror.sh +fi +``` + +`mirror.sh:` +``` +#!/bin/sh + +cd /home/doc/repos/localconspiracy + +wget \ +--mirror \ +--convert-links  \ +--adjust-extension \ +--page-requisites  \ +--retry-connrefused  \ +--exclude-directories=comments \ +--execute robots=off \ +http://private.localconspiracy.com + +git rm -rf public/* +mv private.localconspiracy.com/* public/. +rmdir private.localconspiracy.com +find ./public/ -type f -exec sed -i -e 's|http://private.localconspiracy|https://www.localconspiracy|g' {} \; +find ./public/ -type f -exec sed -i -e 's|http://www.localconspiracy|https://www.localconspiracy|g' {} \; +git add public/* +git commit -m "new snapshot" +git push origin master +``` + +就是这些了!现在,当博客发生变化时,在 15 分钟内将网站镜像到静态版本并推送到仓库,这将在 GitLab Pages 中反映出来。 + +如果你想[在本地运行 WordPress][9],这个概念可以进一步扩展。在这种情况下,你不需要服务器来托管你的 WordPress 博客。你可以在本机运行它。在这种情况下,你的博客不可能被利用。只要你可以在本地运行 `wget`,就可以使用上面的方法在 GitLab Pages 上托管 WordPress 站点。 + +_这篇文章最初发表于 [Local Conspiracy] [10]。允许转载。_ + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/publish-wordpress-static-gitlab-pages-site + +作者:[Christopher Aedo][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/docaedo +[1]:https://gohugo.io/ +[2]:https://gitlab.com/ +[3]:https://en.wikipedia.org/wiki/Markdown +[4]:https://docs.gitlab.com/ee/user/project/pages/ +[5]:https://pages.github.com/ +[6]:https://letsencrypt.org/ +[7]:https://about.gitlab.com/2016/04/07/gitlab-pages-setup/ +[8]:https://en.wikipedia.org/wiki/Cron +[9]:https://codex.wordpress.org/Installing_WordPress_Locally_on_Your_Mac_With_MAMP +[10]:https://localconspiracy.com/2018/08/wp-on-gitlab.html From 31b18a8a65719af73d858fe02e593eb6495d177c Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 4 Sep 2018 09:11:51 +0800 Subject: [PATCH 052/455] translating --- .../20180830 How To Reset MySQL Or MariaDB Root Password.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md b/sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md index 69bfa2e2de..5d4c316e6d 100644 --- a/sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md +++ b/sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md @@ -1,3 +1,5 @@ +translating---geekpi + How To Reset MySQL Or MariaDB Root Password ====== From d51234b9418762adb086bb74826191cc47419356 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 4 Sep 2018 11:10:03 +0800 Subject: [PATCH 053/455] PUB:20180427 An Official Introduction to the Go Compiler @stephenxs @pityonline https://linux.cn/article-9977-1.html --- .../20180427 An Official Introduction to the Go Compiler.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180427 An Official Introduction to the Go Compiler.md (100%) diff --git a/translated/tech/20180427 An Official Introduction to the Go Compiler.md b/published/20180427 An Official Introduction to the Go Compiler.md similarity index 100% rename from translated/tech/20180427 An Official Introduction to the Go Compiler.md rename to published/20180427 An Official Introduction to the Go Compiler.md From 2122101bd9c63719c4a7d89929cb0006306b15d9 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 4 Sep 2018 11:44:48 +0800 Subject: [PATCH 054/455] PRF: 20180618 Twitter Sentiment Analysis using NodeJS.md @BriFuture --- ...Twitter Sentiment Analysis using NodeJS.md | 30 +++++++------------ 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/translated/tech/20180618 Twitter Sentiment Analysis using NodeJS.md b/translated/tech/20180618 Twitter Sentiment Analysis using NodeJS.md index e9cf8d5849..a179c7bc4f 100644 --- a/translated/tech/20180618 Twitter Sentiment Analysis using NodeJS.md +++ b/translated/tech/20180618 Twitter Sentiment Analysis using NodeJS.md @@ -6,27 +6,25 @@ 如果你想知道大家对某件事情的看法,Twitter 是最好的地方了。Twitter 是观点持续不断的涌现出来的地方,每秒钟大概有 6000 条新 Twitter 发送出来。因特网上的发展很快,如果你想与时俱进或者跟上潮流,Twitter 就是你要去的地方。 -现在,我们生活在一个数据为王的时代,很多公司都善于运用 Twitter 上的数据。根据测量到的他们新产品的人气,尝试预测之后的市场趋势,分析 Twitter 上的数据有很多用处。通过数据,商人把产品卖给合适的用户,收集关于他们品牌和改进的反馈,或者获取他们产品或促销活动失败的原因。不仅仅是商人,很多政治和经济上的决定是在观察人们意见的基础上所作的。今天,我会试着让你感受下关于 Twitter 的简单 [情感分析][1],判断这个 Twitter 是正能量,负能量还是中性的。这不会像专业人士所用的那么复杂,但至少,它会让你知道挖掘观念的想法。 +现在,我们生活在一个数据为王的时代,很多公司都善于运用 Twitter 上的数据。根据测量到的他们新产品的人气,尝试预测之后的市场趋势,分析 Twitter 上的数据有很多用处。通过数据,商人把产品卖给合适的用户,收集关于他们品牌和改进的反馈,或者获取他们产品或促销活动失败的原因。不仅仅是商人,很多政治和经济上的决定是在观察人们意见的基础上所作的。今天,我会试着让你感受下关于 Twitter 的简单 [情感分析][1],判断这个 Twitter 是正能量、负能量还是中性的。这不会像专业人士所用的那么复杂,但至少,它会让你知道挖掘观念的想法。 我们将使用 NodeJs,因为 JavaScript 太常用了,而且它还是最容易入门的语言。 ### 前置条件: * 安装了 NodeJs 和 NPM - * 有 NodeJs 和 NPM 包的经验 - * 熟悉命令行。 -好了,就是这样。开始吧 +好了,就是这样。开始吧。 ### 开始 为了你的项目新建一个目录,进入这个目录下面。打开终端(或是命令行)。进入刚创建的目录下面,运行命令 `npm init -y`。这会在这个目录下创建一个 `package.json` 文件。现在我们可以安装需要的 npm 包了。只需要创建一个新文件,命名为 `index.js` 然后我们就完成了初始的编码。 -### 获取 tweets +### 获取推文 -好了,我们想要分析 Twitter ,为了实现这个目的,我们需要获取 Twitter 的标题。为此,我们要用到 [twit][2] 包。因此,先用 `npm i wit` 命令安装它。我们还需要在 APP 上注册账户,用来访问 Twitter 的 API。点击这个 [链接][3],填写所有项目,从 “Keys and Access Token” 标签页中复制 “Consumer Key”,“Consumer Secret”,“Access token” 和 “Access Token Secret” 这几项到 `.env` 文件中,就像这样: +好了,我们想要分析 Twitter ,为了实现这个目的,我们需要以编程的方式访问 Twitter。为此,我们要用到 [twit][2] 包。因此,先用 `npm i wit` 命令安装它。我们还需要注册一个 App,以通过我们的账户来访问 Twitter 的 API。点击这个 [链接][3],填写所有项目,从 “Keys and Access Token” 标签页中复制 “Consumer Key”、“Consumer Secret”、“Access token” 和 “Access Token Secret” 这几项到一个 `.env` 文件中,就像这样: ``` # .env @@ -35,7 +33,6 @@ CONSUMER_KEY=************ CONSUMER_SECRET=************ ACCESS_TOKEN=************ ACCESS_TOKEN_SECRET=************ - ``` 现在开始。 @@ -63,22 +60,20 @@ const config_twitter = { }; let api = new Twit(config_twitter); - ``` -这里已经用所需的配置文件建立了到 Twitter 上的连接。但我们什么事情都没做。先定义个获取 Twitter 的函数: +这里已经用所需的配置文件建立了到 Twitter 上的连接。但我们什么事情都没做。先定义个获取推文的函数: ``` async function get_tweets(q, count) { let tweets = await api.get('search/tweets', {q, count, tweet_mode: 'extended'}); return tweets.data.statuses.map(tweet => tweet.full_text); } - ``` -这是个 async 函数,因为 `api.get` 函数返回一个 promise 对象,而不是 `then` 链,我想通过这种简单的方式获取推文。它接收两个参数 -q 和 count,`q` 是查询或者我们想要搜索的关键字,`count` 是让这个 `api` 返回的 Twitter 数量。 +这是个 async 函数,因为 `api.get` 函数返回一个 promise 对象,而不是 `then` 链,我想通过这种简单的方式获取推文。它接收两个参数 `q` 和 `count`,`q` 是查询或者我们想要搜索的关键字,`count` 是让这个 `api` 返回的推文数量。 -目前为止我们拥有了一个从 Twitter 上获取完整文本的简单方法,我们要获取的文本中可能包含某些连接或者原推文可能已经被删除了。所以我们会编写另一个函数,获取并返回即便是转发的 Twitter 的文本,,并且删除其中存在的链接。 +目前为止我们拥有了一个从 Twitter 上获取完整文本的简单方法。不过这里有个问题,现在我们要获取的文本中可能包含某些连接或者由于转推而被截断了。所以我们会编写另一个函数,拆解并返回推文的文本,即便是转发的推文,并且其中有链接的话就删除。 ``` function get_text(tweet) { @@ -90,21 +85,18 @@ async function get_tweets(q, count) { let tweets = await api.get('search/tweets', {q, count, 'tweet_mode': 'extended'}); return tweets.data.statuses.map(get_text); } - ``` 现在我们拿到了文本。下一步是从文本中获取情感。为此我们会使用 `npm` 中的另一个包 —— [`sentiment`][4]。让我们像安装其他包那样安装 `sentiment`,添加到脚本中。 ``` const sentiment = require('sentiment') - ``` -`sentiment` 用起来很简单。我们只用把 `sentiment` 函数用在我们想要分析的文本上,它就能返回文本的相对分数。如果分数小于 0,它表达的就是消极情感,大于 0 的分数是积极情感,而 0,如你所料,表示中性的情感。基于此,我们将会把 tweets 打印成不同的颜色 —— 绿色表示积极,红色表示消极,蓝色表示中性。为此,我们会用到 [`colors`][5] 包。先安装这个包,然后添加到脚本中。 +`sentiment` 用起来很简单。我们只用把 `sentiment` 函数用在我们想要分析的文本上,它就能返回文本的相对分数。如果分数小于 0,它表达的就是消极情感,大于 0 的分数是积极情感,而 0,如你所料,表示中性的情感。基于此,我们将会把推文打印成不同的颜色 —— 绿色表示积极,红色表示消极,蓝色表示中性。为此,我们会用到 [`colors`][5] 包。先安装这个包,然后添加到脚本中。 ``` const colors = require('colors/safe'); - ``` 好了,现在把所有东西都整合到 `main` 函数中。 @@ -127,17 +119,15 @@ async function main() { console.log(tweet); } } - ``` 最后,执行 `main` 函数。 ``` main(); - ``` -就是这样,一个简单的分析 tweet 中的基本情感的脚本。 +就是这样,一个简单的分析推文中的基本情感的脚本。 ``` \\ full script @@ -201,7 +191,7 @@ via: https://boostlog.io/@anshulc95/twitter-sentiment-analysis-using-nodejs-5ad1 作者:[Anshul Chauhan][a] 译者:[BriFuture](https://github.com/BriFuture) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 30cc2c23fac4190b1ccc4f0d0b6acdf585170873 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 4 Sep 2018 11:45:35 +0800 Subject: [PATCH 055/455] PUB:20180618 Twitter Sentiment Analysis using NodeJS.md @BriFuture https://linux.cn/article-9978-1.html --- .../20180618 Twitter Sentiment Analysis using NodeJS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180618 Twitter Sentiment Analysis using NodeJS.md (100%) diff --git a/translated/tech/20180618 Twitter Sentiment Analysis using NodeJS.md b/published/20180618 Twitter Sentiment Analysis using NodeJS.md similarity index 100% rename from translated/tech/20180618 Twitter Sentiment Analysis using NodeJS.md rename to published/20180618 Twitter Sentiment Analysis using NodeJS.md From f6de522f46c8b49d9a7156afdbfc939eb39c8767 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 4 Sep 2018 12:09:59 +0800 Subject: [PATCH 056/455] PRF:20180525 Getting started with the Python debugger.md @Flowsnow --- ...etting started with the Python debugger.md | 88 +++++++++---------- 1 file changed, 43 insertions(+), 45 deletions(-) diff --git a/translated/tech/20180525 Getting started with the Python debugger.md b/translated/tech/20180525 Getting started with the Python debugger.md index 0049318223..b966b0a473 100644 --- a/translated/tech/20180525 Getting started with the Python debugger.md +++ b/translated/tech/20180525 Getting started with the Python debugger.md @@ -1,19 +1,19 @@ -开始使用Python调试器 +Python 调试器入门 ====== ![](https://fedoramagazine.org/wp-content/uploads/2018/05/pdb-816x345.jpg) -Python生态系统包含丰富的工具和库,可以改善开发人员的生活。 例如,杂志之前已经介绍了如何[使用交互式shell增强Python][1]。 本文重点介绍另一种可以节省时间并提高Python技能的工具:Python调试器。 +Python 生态系统包含丰富的工具和库,可以让开发人员更加舒适。 例如,我们之前已经介绍了如何[使用交互式 shell 增强 Python][1]。本文重点介绍另一种可以节省时间并提高 Python 技能的工具:Python 调试器。 -### Python调试器 +### Python 调试器 -Python标准库提供了一个名为pdb的调试器。 此调试器提供了调试所需的大多数功能,如断点,单行步进,堆栈帧的检查等等。 +Python 标准库提供了一个名为 pdb 的调试器。此调试器提供了调试所需的大多数功能,如断点、单行步进、堆栈帧的检查等等。 -pdb的基本知识很有用,因为它是标准库的一部分。 你可以在无法安装其他增强的调试器的环境中使用它。 +了解一些pdb 的基本知识很有用,因为它是标准库的一部分。 你可以在无法安装其他增强的调试器的环境中使用它。 -#### 运行pdb +#### 运行 pdb -运行pdb的最简单方法是从命令行,将程序作为参数传递给debug。 考虑以下脚本: +运行 pdb 的最简单方法是从命令行,将程序作为参数传递来调试。 看看以下脚本: ``` # pdb_test.py @@ -32,7 +32,7 @@ if __name__ == "__main__": countdown(seconds) ``` -你可以从命令行运行pdb,如下所示: +你可以从命令行运行 pdb,如下所示: ``` $ python3 -m pdb pdb_test.py @@ -41,7 +41,7 @@ $ python3 -m pdb pdb_test.py (Pdb) ``` -使用pdb的另一种方法是在程序中设置断点。 为此,请导入pdb模块并使用set_trace函数: +使用 pdb 的另一种方法是在程序中设置断点。为此,请导入 `pdb` 模块并使用`set_trace` 函数: ``` # pdb_test.py @@ -60,23 +60,24 @@ def countdown(number): if __name__ == "__main__": seconds = 10 countdown(seconds) +``` +``` $ python3 pdb_test.py > /tmp/pdb_test.py(6)countdown() -> print(i) (Pdb) ``` -脚本在断点处停止,pdb显示脚本中的下一行。 你也可以在失败后执行调试器。 这称为*事后调试(postmortem debugging)*。 +脚本在断点处停止,pdb 显示脚本中的下一行。 你也可以在失败后执行调试器。 这称为事后调试postmortem debugging。 -#### 导航执行堆栈 +#### 穿行于执行堆栈 -调试中的一个常见用例是导航执行堆栈。 Python调试器运行后,以下命令很有用: +调试中的一个常见用例是在执行堆栈中穿行。 Python 调试器运行后,可以使用以下命令: -+ w(here) : 显示当前执行的行以及执行堆栈的位置。 ++ `w(here)`:显示当前执行的行以及执行堆栈的位置。 - -``` + ``` $ python3 test_pdb.py > /tmp/test_pdb.py(10)countdown() -> print(i) @@ -88,10 +89,9 @@ $ python3 test_pdb.py (Pdb) ``` -+ l(ist) : 显示当前位置周围更多的上下文(代码)。 ++ `l(ist)`:显示当前位置周围更多的上下文(代码)。 - -``` + ``` $ python3 test_pdb.py > /tmp/test_pdb.py(10)countdown() -> print(i) @@ -109,10 +109,9 @@ $ python3 test_pdb.py 15 seconds = 10 ``` -+ u(p)/d(own) : 向上或向下导航调用堆栈。 ++ `u(p)`/`d(own)`:向上或向下穿行调用堆栈。 - -``` + ``` $ py3 test_pdb.py > /tmp/test_pdb.py(10)countdown() -> print(i) @@ -129,12 +128,11 @@ $ py3 test_pdb.py pdb提供以下命令来执行和单步执行代码: -+ n(ext): 继续执行,直到达到当前函数中的下一行,否则返回 -+ s(tep): 执行当前行并在第一个可能的场合停止(在被调用的函数或当前函数中) -+ c(ontinue): 继续执行,仅在断点处停止。 ++ `n(ext)`:继续执行,直到达到当前函数中的下一行,或者返回 ++ `s(tep)`:执行当前行并在第一个可能的场合停止(在被调用的函数或当前函数中) ++ `c(ontinue)`:继续执行,仅在断点处停止。 - -``` + ``` $ py3 test_pdb.py > /tmp/test_pdb.py(10)countdown() -> print(i) @@ -162,13 +160,13 @@ $ py3 test_pdb.py (Pdb) ``` -该示例显示了next和step之间的区别。 实际上,当使用step时,调试器会进入pdb模块源代码,而接下来就会执行set_trace函数。 + 该示例显示了 `next` 和 `step` 之间的区别。 实际上,当使用 `step` 时,调试器会进入 `pdb` 模块源代码,而接下来就会执行 `set_trace` 函数。 #### 检查变量内容 -pdb非常有用的地方是检查执行堆栈中存储的变量的内容。 例如,a(rgs)命令打印当前函数的变量,如下所示: ++ pdb 非常有用的地方是检查执行堆栈中存储的变量的内容。 例如,`a(rgs)` 命令打印当前函数的变量,如下所示: -``` + ``` py3 test_pdb.py > /tmp/test_pdb.py(10)countdown() -> print(i) @@ -182,11 +180,11 @@ number = 10 (Pdb) ``` -pdb打印变量的值,在本例中是10。 + pdb 打印变量的值,在本例中是 10。 -可用于打印变量值的另一个命令是p(rint)。 ++ 可用于打印变量值的另一个命令是 `p(rint)`。 -``` + ``` $ py3 test_pdb.py > /tmp/test_pdb.py(10)countdown() -> print(i) @@ -211,19 +209,19 @@ $ py3 test_pdb.py (Pdb) ``` -如示例中最后的命令所示,print可以在显示结果之前计算表达式。 + 如示例中最后的命令所示,`print` 可以在显示结果之前计算表达式。 -[Python文档][2]包含每个pdb命令的参考和示例。 对于开始使用Python调试器人来说,这是一个有用的读物。 +[Python 文档][2]包含每个 pdb 命令的参考和示例。 对于开始使用 Python 调试器人来说,这是一个有用的读物。 ### 增强的调试器 -一些增强的调试器提供了更好的用户体验。 大多数为pdb添加了有用的额外功能,例如语法突出高亮,更好的回溯和自我检查。 流行的增强调试器包括[IPython的ipdb][3]和[pdb ++][4]。 +一些增强的调试器提供了更好的用户体验。 大多数为 pdb 添加了有用的额外功能,例如语法突出高亮、更好的回溯和自省。 流行的增强调试器包括 [IPython 的 ipdb][3] 和 [pdb++][4]。 这些示例显示如何在虚拟环境中安装这两个调试器。 这些示例使用新的虚拟环境,但在调试应用程序的情况下,应使用应用程序的虚拟环境。 -#### 安装IPython的ipdb +#### 安装 IPython 的 ipdb -要安装IPython ipdb,请在虚拟环境中使用pip: +要安装 IPython ipdb,请在虚拟环境中使用 `pip`: ``` $ python3 -m venv .test_pdb @@ -231,21 +229,21 @@ $ source .test_pdb/bin/activate (test_pdb)$ pip install ipdb ``` -要在脚本中调用ipdb,必须使用以下命令。 请注意,该模块称为ipdb而不是pdb: +要在脚本中调用 ipdb,必须使用以下命令。 请注意,该模块称为 ipdb 而不是 pdb: ``` import ipdb; ipdb.set_trace() ``` -IPython的ipdb也可以在Fedora包中使用,所以你可以使用Fedora的包管理器dnf来安装它: +IPython 的 ipdb 也可以用 Fedora 包安装,所以你可以使用 Fedora 的包管理器 `dnf` 来安装它: ``` $ sudo dnf install python3-ipdb ``` -#### 安装pdb++ +#### 安装 pdb++ -你可以类似地安装pdb++: +你可以类似地安装 pdb++: ``` $ python3 -m venv .test_pdb @@ -253,15 +251,15 @@ $ source .test_pdb/bin/activate (test_pdb)$ pip install pdbp ``` -pdb++重写了pdb模块,因此你可以使用相同的语法在程序中添加断点: +pdb++ 重写了 pdb 模块,因此你可以使用相同的语法在程序中添加断点: ``` import pdb; pdb.set_trace() ``` -### Conclusion +### 总结 -学习如何使用Python调试器可以节省你在排查应用程序问题时的时间。 对于了解应用程序或某些库的复杂部分如何工作也是有用的,从而提高Python开发人员的技能。 +学习如何使用 Python 调试器可以节省你在排查应用程序问题时的时间。 对于了解应用程序或某些库的复杂部分如何工作也是有用的,从而提高 Python 开发人员的技能。 -------------------------------------------------------------------------------- @@ -270,7 +268,7 @@ via: https://fedoramagazine.org/getting-started-python-debugger/ 作者:[Clément Verna][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[Flowsnow](https://github.com/Flowsnow) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From b98f29701984de34efdd376a95b1db28335a5f58 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 4 Sep 2018 12:10:31 +0800 Subject: [PATCH 057/455] PUB:20180525 Getting started with the Python debugger.md @Flowsnow https://linux.cn/article-9979-1.html --- .../20180525 Getting started with the Python debugger.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180525 Getting started with the Python debugger.md (100%) diff --git a/translated/tech/20180525 Getting started with the Python debugger.md b/published/20180525 Getting started with the Python debugger.md similarity index 100% rename from translated/tech/20180525 Getting started with the Python debugger.md rename to published/20180525 Getting started with the Python debugger.md From 4013f994a8fa110a5d3490f71bde4d1f522aedfa Mon Sep 17 00:00:00 2001 From: David Chen Date: Tue, 4 Sep 2018 12:19:52 +0800 Subject: [PATCH 058/455] 20180827 An introduction to diffs and patches.md --- sources/tech/20180827 An introduction to diffs and patches.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180827 An introduction to diffs and patches.md b/sources/tech/20180827 An introduction to diffs and patches.md index 1c81b97bf6..cdd0c49d69 100644 --- a/sources/tech/20180827 An introduction to diffs and patches.md +++ b/sources/tech/20180827 An introduction to diffs and patches.md @@ -1,3 +1,5 @@ +Translating by DavidChenLiang + An introduction to diffs and patches ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0) From 816ee0fea899ecaed468c23bb8ca55dafcaed49c Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 4 Sep 2018 12:41:42 +0800 Subject: [PATCH 059/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Turn=20your=20vi?= =?UTF-8?q?=20editor=20into=20a=20productivity=20powerhouse?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...i editor into a productivity powerhouse.md | 343 ++++++++++++++++++ 1 file changed, 343 insertions(+) create mode 100644 sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md diff --git a/sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md b/sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md new file mode 100644 index 0000000000..359ecefee2 --- /dev/null +++ b/sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md @@ -0,0 +1,343 @@ +Turn your vi editor into a productivity powerhouse +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk) + +A versatile and powerful editor, vi includes a rich set of potent commands that make it a popular choice for many users. This article specifically looks at commands that are not enabled by default in vi but are nevertheless useful. The commands recommended here are expected to be set in a vi configuration file. Though it is possible to enable commands individually from each vi session, the purpose of this article is to create a highly productive environment out of the box. + +### Before you begin + +While "vim" is the technically correct name of the newer version of the vi editor, this article refers to it as "vi." vimrc is the configuration file used by vim. + +The commands or configurations discussed here go into the vi startup configuration file, vimrc, located in the user home directory. Follow the instructions below to set the commands in vimrc: + +(Note: The vimrc file is also used for system-wide configurations in Linux, such as `/etc/vimrc` or `/etc/vim/vimrc`. In this article, we'll consider only user-specific vimrc, present in user home folder.) + +In Linux: + + * Open the file with `vi $HOME/.vimrc` + * Type or copy/paste the commands in the cheat sheet at the end of this article + * Save and close (`:wq`) + + + +In Windows: + + * First, [install gvim][1] + * Open gvim + * Click Edit --> Startup settings, which opens the _vimrc file + * Type or copy/paste the commands in the cheat sheet at the end of this article + * Click File --> Save + + + +Let's delve into the individual vi productivity commands. These commands are classified into the following categories: + + 1. Indentation & Tabs + 2. Display & Format + 3. Search + 4. Browse & Scroll + 5. Spell + 6. Miscellaneous + + + +### 1\. Indentation & Tabs + +To automatically align the indentation of a line in a file: +``` +set autoindent + +``` + +Smart Indent uses the code syntax and style to align: +``` +set smartindent + +``` + +Tip: vi is language-aware and provides a default setting that works efficiently based on the programming language used in your file. There are many default configuration commands, including `axs cindent`, `cinoptions`, `indentexpr`, etc., which are not explained here. `syn` is a helpful command that shows or sets the file syntax. + +To set the number of spaces to display for a tab: +``` +set tabstop=4 + +``` + +To set the number of spaces to display for a “shift operation” (such as ‘>>’ or ‘<<’): +``` +set shiftwidth=4 + +``` + +If you prefer to use spaces instead of tabs, this option inserts spaces when the Tab key is pressed. This may cause problems for languages such as Python that rely on tabs instead of spaces. In such cases, you may set this option based on the file type (see `autocmd`). +``` +set expandtab + +``` + +### 2\. Display & Format + +To show line numbers: +``` +set number + +``` + +![](https://opensource.com/sites/default/files/uploads/picture01.png) + +To wrap text when it crosses the maximum line width: +``` +set textwidth=80 + +``` + +To wrap text based on a number of columns from the right side: +``` +set wrapmargin=2 + +``` + +To identify open and close brace positions when you traverse through the file: +``` +set showmatch + +``` + +![](https://opensource.com/sites/default/files/uploads/picture02-03.jpg) + +### 3\. Search + +To highlight the searched term in a file: +``` +set hlsearch + +``` + +![](https://opensource.com/sites/default/files/uploads/picture04.png) + +To perform incremental searches as you type: +``` +set incsearch + +``` + +![](https://opensource.com/sites/default/files/picture05.png) + +To search ignoring case (many users prefer not to use this command; set it only if you think it will be useful): +``` +set ignorecase + +``` + +To search without considering `ignorecase` when both `ignorecase` and `smartcase` are set and the search pattern contains uppercase: +``` +set smartcase + +``` + +For example, if the file contains: + +test +Test + +When both `ignorecase` and `smartcase` are set, a search for “test” finds and highlights both: + +test +Test + +A search for “Test” highlights or finds only the second line: + +test +Test + +### 4. Browse & Scroll + +For a better visual experience, you may prefer to have the cursor somewhere in the middle rather than on the first line. The following option sets the cursor position to the 5th row. +``` +set scrolloff=5 + +``` + +Example: + +The first image is with scrolloff=0 and the second image is with scrolloff=5. + +![](https://opensource.com/sites/default/files/uploads/picture06-07.jpg) + +Tip: `set sidescrolloff` is useful if you also set `nowrap.` + +To display a permanent status bar at the bottom of the vi screen showing the filename, row number, column number, etc.: +``` +set laststatus=2 + +``` + +![](https://opensource.com/sites/default/files/picture08.png) + +### 5. Spell + +vi has a built-in spell-checker that is quite useful for text editing as well as coding. vi recognizes the file type and checks the spelling of comments only in code. Use the following command to turn on spell-check for the English language: +``` +set spell spelllang=en_us + +``` + +### 6. Miscellaneous + +Disable creating backup file: When this option is on, vi creates a backup of the previous edit. If you do not want this feature, disable it as shown below. Backup files are named with a tilde (~) at the end of the filename. +``` +set nobackup + +``` + +Disable creating a swap file: When this option is on, vi creates a swap file that exists until you start editing the file. Swapfile is used to recover a file in the event of a crash or a use conflict. Swap files are hidden files that begin with `.` and end with `.swp`. +``` +set noswapfile + +``` + +Suppose you need to edit multiple files in the same vi session and switch between them. An annoying feature that's not readily apparent is that the working directory is the one from which you opened the first file. Often it is useful to automatically switch the working directory to that of the file being edited. To enable this option: +``` +set autochdir + +``` + +vi maintains an undo history that lets you undo changes. By default, this history is active only until the file is closed. vi includes a nifty feature that maintains the undo history even after the file is closed, which means you may undo your changes even after the file is saved, closed, and reopened. The undo file is a hidden file saved with the `.un~` extension. +``` +set undofile + +``` + +To set audible alert bells (which sound a warning if you try to scroll beyond the end of a line): +``` +set errorbells + +``` + +If you prefer, you may set visual alert bells: +``` +set visualbell + +``` + +### Bonus + +vi provides long-format as well as short-format commands. Either format can be used to set or unset the configuration. + +Long format for the `autoindent` command: +``` +set autoindent + +``` + +Short format for the `autoindent` command: +``` +set ai + +``` + +To see the current configuration setting of a command without changing its current value, use `?` at the end: +``` +set autoindent? + +``` + +To unset or turn off a command, most commands take `no` as a prefix: +``` +set noautoindent + +``` + +It is possible to set a command for one file but not for the global configuration. To do this, open the file and type `:`, followed by the `set` command. This configuration is effective only for the current file editing session. + +![](https://opensource.com/sites/default/files/uploads/picture09.png) + +For help on a command: +``` +:help autoindent + +``` + +![](https://opensource.com/sites/default/files/uploads/picture10-11.jpg) + +Note: The commands listed here were tested on Linux with Vim version 7.4 (2013 Aug 10) and Windows with Vim 8.0 (2016 Sep 12). + +These useful commands are sure to enhance your vi experience. Which other commands do you recommend? + +### Cheat sheet + +Copy/paste this list of commands in your vimrc file: +``` +" Indentation & Tabs + +set autoindent + +set smartindent + +set tabstop=4 + +set shiftwidth=4 + +set expandtab + +set smarttab + +" Display & format + +set number + +set textwidth=80 + +set wrapmargin=2 + +set showmatch + +" Search + +set hlsearch + +set incsearch + +set ignorecase + +set smartcase + +" Browse & Scroll + +set scrolloff=5 + +set laststatus=2 + +" Spell + +set spell spelllang=en_us + +" Miscellaneous + +set nobackup + +set noswapfile + +set autochdir + +set undofile + +set visualbell + +set errorbells +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/vi-editor-productivity-powerhouse + +作者:[Girish Managoli][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gammay +[1]: https://www.vim.org/download.php#pc From 31dd7a6514ab1e5b52fc2acfba2d285307c022e0 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 4 Sep 2018 12:43:22 +0800 Subject: [PATCH 060/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20A=20Cross-platfor?= =?UTF-8?q?m=20High-quality=20GIF=20Encoder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Cross-platform High-quality GIF Encoder.md | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 sources/tech/20180903 A Cross-platform High-quality GIF Encoder.md diff --git a/sources/tech/20180903 A Cross-platform High-quality GIF Encoder.md b/sources/tech/20180903 A Cross-platform High-quality GIF Encoder.md new file mode 100644 index 0000000000..7a7f79064b --- /dev/null +++ b/sources/tech/20180903 A Cross-platform High-quality GIF Encoder.md @@ -0,0 +1,160 @@ +A Cross-platform High-quality GIF Encoder +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/gifski-720x340.png) + +As a content writer, I needed to add images in my articles. Sometimes, it is better to add videos or gif images to explain the concept a bit easier. The readers can easily understand the guide much better by watching the output in video or gif format than the text. The day before, I have written about [**Flameshot**][1], a feature-rich and powerful screenshot tool for Linux. Today, I will show you how to make high quality gif images either from a video or set of images. Meet **Gifski** , a cross-platform, open source, command line High-quality GIF encoder based on **Pngquant**. + +For those wondering, pngquant is a command line lossy PNG image compressor. Trust me, pngquant is one of the best loss-less PNG compressor that I ever use. It compresses PNG images **upto 70%** without losing the original quality and and preserves full alpha transparency. The compressed images are compatible with all web browsers and operating systems. Since Gifski is based on Pngquant, it uses pngquant’s features for creating efficient GIF animations. Gifski is capable of creating animated GIFs that use thousands of colors per frame. Gifski is also requires **ffmpeg** to convert video into PNG images. + +### **Installing Gifski** + +Make sure you have installed FFMpeg and Pngquant. + +FFmpeg is available in the default repositories of most Linux distributions, so you can install it using the default package manager. For installation instructions, refer the following guide. + +Pngquant is available in [**AUR**][2]. To install it in Arch-based systems, use any AUR helper programs like [**Yay**][3]. +``` +$ yay -S pngquant + +``` + +On Debian-based systems, run: +``` +$ sudo apt install pngquant + +``` + +If pngquant is not available for your distro, compile and install it from source. You will need **`libpng-dev`** package installed with development headers. +``` +$ git clone --recursive https://github.com/kornelski/pngquant.git + +$ make + +$ sudo make install + +``` + +After installing the prerequisites, install Gifski. You can install it using **cargo** if you have installed [**Rust**][4] programming language. +``` +$ cargo install gifski + +``` + +You can also get it with [**Linuxbrew**][5] package manager. +``` +$ brew install gifski + +``` + +If you don’t want to install cargo or Linuxbrew, download the latest binary executables from [**releases page**][6] and compile and install gifski manually. + +### Create high-quality GIF animations using Gifski high-quality GIF encoder + +Go to the location where you have kept the PNG images and run the following command to create GIF animation from the set of images: +``` +$ gifski -o file.gif *.png + +``` + +Here file.gif is the final output gif animation. + +Gifski has also some other additional features, like; + + * Create GIF animation with specific dimension + * Show specific number of animations per second + * Encode with a specific quality + * Encode faster + * Encode images exactly in the order given, rather than sorted + + + +To create GIF animation with specific dimension, for example width=800 and height=400, use the following command: +``` +$ gifski -o file.gif -W 800 -H 400 *.png + +``` + +You can set how many number of animation frames per second you want in the gif animation. The default value is **20**. To do so, run: +``` +$ gifski -o file.gif --fps 1 *.png + +``` + +In the above example, I have used one animation frame per second. + +We can encode with specific quality on the scale of 1-100. Obviously, the lower quality may give smaller file and higher quality give bigger seize gif animation. +``` +$ gifski -o file.gif --quality 50 *.png + +``` + +Gifski will take more time when you encode large number of images. To make the encoding process 3 times faster than usual speed, run: +``` +$ gifski -o file.gif --fast *.png + +``` + +Please note that it will reduce quality to 10% and create bigger animation file. + +To encode images exactly in the order given (rather than sorted), use **`--nosort`** option. +``` +$ gifski -o file.gif --nosort *.png + +``` + +If you do not to loop the GIF, simple use **`--once`** option. +``` +$ gifski -o file.gif --once *.png + +``` + +**Create GIF animation from Video file** + +Some times you might want to an animated file from a video. It is also possible. This is where FFmpeg comes in help. First convert the video into PNG frames first like below. +``` +$ ffmpeg -i video.mp4 frame%04d.png + +``` + +The above command makes image files namely “frame0001.png”, “frame0002.png”, “frame0003.png”…, etc. from video.mp4 (%04d makes the frame number) and save them in the current working directory. + +After converting the image files, simply run the following command to make the animated GIF file. +``` +$ gifski -o file.gif *.png + +``` + +For more details, refer the help section. +``` +$ gifski -h + +``` + +Here is the sample animated file created using Gifski. + +As you can see, the quality of the GIF file is really great. + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/gifski-a-cross-platform-high-quality-gif-encoder/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://www.ostechnix.com/flameshot-a-simple-yet-powerful-feature-rich-screenshot-tool/ +[2]: https://aur.archlinux.org/packages/pngquant/ +[3]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ +[4]: https://www.ostechnix.com/install-rust-programming-language-in-linux/ +[5]: https://www.ostechnix.com/linuxbrew-common-package-manager-linux-mac-os-x/ +[6]: https://github.com/ImageOptim/gifski/releases From a24b69d0fe42313945ca50ae644289d21f48ba7f Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 4 Sep 2018 12:47:49 +0800 Subject: [PATCH 061/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20scale?= =?UTF-8?q?=20your=20website=20across=20all=20mobile=20devices?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... your website across all mobile devices.md | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 sources/tech/20180830 How to scale your website across all mobile devices.md diff --git a/sources/tech/20180830 How to scale your website across all mobile devices.md b/sources/tech/20180830 How to scale your website across all mobile devices.md new file mode 100644 index 0000000000..ad36b9017a --- /dev/null +++ b/sources/tech/20180830 How to scale your website across all mobile devices.md @@ -0,0 +1,85 @@ +How to scale your website across all mobile devices +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/migration_innovation_computer_software.png?itok=VCFLtd0q) + +Most of us surf the internet, make online purchases, and even pay bills using our mobile devices because they are handy and easily accessible. According to a Forrester study, [The Digital Business Imperative][1], 43% of banking customers in the US used mobile phones to complete banking transactions in a three-month period. + +The significant year-over-year growth of online business transactions done via mobile devices has encouraged companies to build websites and e-commerce sites that look, feel, and function identically on computers and smart mobile devices. However, many users still find the experience of browsing a website on a smartphone isn’t the same as on a computer. In order to develop websites that scale effectively and smoothly across different devices, it's important to understand what causes these differences across platforms. + +Web pages are usually composed of one or more of the following components: Header and footer, main content (text), images, forms, videos, and tables. Devices differ on features such as screen dimension (length x width), screen resolution (pixel density), compute power (CPU and memory), and operating system (iOS, Android, Windows, etc.). These differences contribute significantly to the overall performance and rendering of web components such as images, videos, and text across different devices. Another important factor is that mobile users may not always be connected to a high-speed network, so web pages should be carefully designed to work effectively on low-bandwidth connections. + +### The most troublesome issues on mobile platforms + +Here are some of the most common issues that can affect the performance and scalability of websites across devices: + + * **Sites do not automatically adapt to different screen sizes.** Some websites are designed to format for variable screen sizes, but their elements may not auto-scale. This would result in the site automatically adjusting itself for various screen sizes, but the elements in the site may look too large on smaller devices. Some sites may not be designed to adjust for variable screen sizes, causing the elements to look extremely small on devices with smaller screens. + * **Sites have too much content for mobile devices.** Some websites are loaded with content to fill empty space on a desktop screen. Websites developed without considering mobile users generally fall under this category. These sites take more time and bandwidth to load, and if the pages aren’t designed appropriately for mobile devices, some content may not even appear. + * **Sites take too long to load images.** Websites with too many images or heavy image files are likely to take a long time to load, especially if the images were not optimized during the design phase. + * **Data in tables looks complex and takes too long to load.** Many websites present data in a tabular fashion (for example, comparisons of competing products, airfare data from different travel sites, flight schedules, etc.), and on mobile devices, these tables can be slow and difficult to comprehend. + * **Websites host videos that don’t play on some devices.** Not all mobile devices support all video formats. Some websites host media that require licenses, Adobe Flash, or other players that some mobile devices may not support. This causes frustration and a poor overall user experience. + + + +### Design your sites to adapt to different devices + +All these issues can be addressed through proper design and by adopting a [mobile-first][2] approach. When working with limitations such as screen size, bandwidth, etc., focus on the right quantity and quality of content. A mobile-first strategy places content as the primary object and designs for the smallest devices, ensuring that a site includes only the most essential features. Address the design challenges for mobile devices first, and then progressively enhance the design for larger devices. + +Here are a few best practices to consider when designing websites that need to scale on different devices. + +* **Adapting to any screen size**. At a minimum, a web page needs to be scaled to fit the screen size of any mobile device. Today's mobile devices come with very high screen resolutions. The pixel density on mobile devices is much higher than that of desktop screens, so it is important to format pages to match the mobile screen’s width in device-independent pixels. The “meta viewport” tag included in the HTML document addresses this requirement. + +![](https://opensource.com/sites/default/files/uploads/image_1_0.png) + +The meta viewport value, as shown above, helps format the entire HTML page and render the content to match any screen size. + +* **" Content is king."** Content should determine the design of a website, not vice versa. Websites with too many elements such as tables, forms, charts, etc., become challenging when they need to scale on mobile devices. Developers end up hiding content for mobile users, and the desktop version and the mobile version become inconsistent. The design should focus on the core structure and content rather than decorative elements. The mobile-first methodology ensures a single version of content for both desktop and mobile users, so web designers should carefully consider, craft, and optimize content so that it not only satisfies business goals but also appeals to mobile users. Content that doesn’t appear in the mobile version may not even need to appear in the desktop version. +* **Responsive images**. The design should consider small hand-held devices operating in areas with low signal strength. Large photos and complex graphics are not suitable for mobile devices operating under such conditions. Make sure all images are optimized for different sizes of viewports and pixel densities. A recommended approach is [resolution switching][3], which enables the browser to select an appropriately sized image file, depending on the screen size of a device. Resolution switching uses two attributes—`srcset` and `sizes` (shown in the code snippet shown below)—which enable the browser to use the device width to select the most suitable media condition provided in the sizes list, choose the slot size based on that condition, and load the image referenced in the `srcset` that most closely matches the chosen slot size. + +![](https://opensource.com/sites/default/files/uploads/image_2_0.png) + +For example, if a device with a viewport of 320px loads the page, the media condition (max-width: 320px) in the sizes list will be true, and the corresponding 280px slot will be chosen. The width of the first image listed in `srcset` (elephant-320w.jpg) is the closest to this slot. Browsers that don’t support resolution switching display the image listed in the src attribute as the default image. This approach not only picks the right image for your device viewport, but it also prevents loading unnecessarily large images that consume significant bandwidth. + +![](https://opensource.com/sites/default/files/uploads/image_3_0.png) + +* **Responsive tables.** As the world becomes more data-driven, bringing critical, time-sensitive data to handheld devices provides power and freedom to users. The challenge is to present data in a way that is easy to load and read on mobile devices. Some data needs to be presented in the form of a table, but when data tables get too large and unwieldy, it can be frustrating for users to interpret them on a mobile device with a small screen. If the screen is much narrower than the width of the table, for example, users are forced to zoom out, making the text too small to read. Conversely, if the screen is wider than the table, users must zoom in to view the data, which requires constant vertical and horizontal scrolling. + +Fortunately, there are several ways to build [responsive tables][4]. Here is one of the most effective: + + * The table's columns are transposed into rows. Each column is sized to the same width as the screen, preventing the need to scroll horizontally. Use of color helps users clearly distinguish each individual row of data. In this case, for each “cell,” the CSS-generated content `(:before)` should be used to apply the label so that each piece of data can be identified clearly. + * Another approach is to display the data in one of two formats, based on screen width: chart format (for narrow screens) or complete table format (for wider screens). If the user wants to click the chart to see the complete table, the approach described above can be used to show the data in tabular form.(:before) + * A third approach is to show a mini-graphic in a narrow screen to indicate the presence of a table. The user can click on the graphic to expand and display the table. +* **Videos that always play.** [Video files][5] generally won’t play on mobile devices if their formats are unsupported or if they require a proprietary video player. The recommended approach is to use standard HTML5 tags for videos and animations. The video element in HTML5 can be used to load, decode, and play videos on your website. Produce video in multiple formats to suit different mobile platforms, and be sure to size videos appropriately so that they play within their containers. + +The example below shows the use of tags to specify different video formats (indicated by the type element). In this approach, the switch to the correct format happens at the client side, and only one request is made to the server. This reduces network latency and lets the browser select the most appropriate video format without first downloading it. + +![](https://opensource.com/sites/default/files/uploads/image_4_0.png) + +The `videoWidth` and `videoHeight` properties of the video element help identify the encoded size of a video. Video dimensions can be controlled using JavaScript or CSS. `max-width: 100%` helps size the videos to fit the screen. CSS media queries can be used to set the size based on the viewport dimensions. There are also several JavaScript libraries and plugins that can maintain the aspect ratio and size of videos. + +### All things considered… + +These days, users regularly surf the web and perform business transactions with their smartphones and tablets. The web is becoming the primary business channel for many businesses worldwide. Consequently, it is important to develop websites that work and scale well on mobile devices. The goal is to enhance the mobile user experience so that it mirrors the functionality and performance of desktop computers and large monitors. + +The mobile-first approach helps web designers create sites that operate well on small mobile devices. Design should focus on content that satisfies business requirements while also considering technical limitations such as screen size, processor speed, memory, and operating conditions (e.g., poor network signal strength). It must also ensure that pictures, videos, and data are responsive across all mobile devices while remaining sensitive to breakpoints, touch targets, etc. + +A well-designed website that works and scales on a small device can always be progressively enhanced to work on larger devices. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/how-scale-your-website-across-all-devices + +作者:[Sridhar Asvathanarayanan][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sasvathanarayanangmailcom +[1]: https://www.forrester.com/report/The+Digital+Business+Imperative/-/E-RES115784# +[2]: https://www.uxpin.com/studio/blog/a-hands-on-guide-to-mobile-first-design/ +[3]: https://developer.mozilla.org/en-US/docs/Learn/HTML/Multimedia_and_embedding/Responsive_images +[4]: https://css-tricks.com/responsive-data-tables/ +[5]: https://developers.google.com/web/fundamentals/media/video From 5a2c4532ffb554992db15d6532dec6ce1a016759 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Tue, 4 Sep 2018 13:18:59 +0800 Subject: [PATCH 062/455] =?UTF-8?q?=E9=80=89=E9=A2=98&=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=20by=20qhwdw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...feinated 6.828:Lab 2 Memory Management.md | 234 ++++++++++++++++++ 1 file changed, 234 insertions(+) create mode 100644 sources/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md diff --git a/sources/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md b/sources/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md new file mode 100644 index 0000000000..a52f7ac36a --- /dev/null +++ b/sources/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md @@ -0,0 +1,234 @@ +Translating by qhwdw + +# Caffeinated 6.828:Lab 2: Memory Management + +### Introduction + +In this lab, you will write the memory management code for your operating system. Memory management has two components. + +The first component is a physical memory allocator for the kernel, so that the kernel can allocate memory and later free it. Your allocator will operate in units of 4096 bytes, called pages. Your task will be to maintain data structures that record which physical pages are free and which are allocated, and how many processes are sharing each allocated page. You will also write the routines to allocate and free pages of memory. + +The second component of memory management is virtual memory, which maps the virtual addresses used by kernel and user software to addresses in physical memory. The x86 hardware’s memory management unit (MMU) performs the mapping when instructions use memory, consulting a set of page tables. You will modify JOS to set up the MMU’s page tables according to a specification we provide. + +### Getting started + +In this and future labs you will progressively build up your kernel. We will also provide you with some additional source. To fetch that source, use Git to commit changes you’ve made since handing in lab 1 (if any), fetch the latest version of the course repository, and then create a local branch called lab2 based on our lab2 branch, origin/lab2: + +``` +athena% cd ~/6.828/lab +athena% add git +athena% git pull +Already up-to-date. +athena% git checkout -b lab2 origin/lab2 +Branch lab2 set up to track remote branch refs/remotes/origin/lab2. +Switched to a new branch "lab2" +athena% +``` + +You will now need to merge the changes you made in your lab1 branch into the lab2 branch, as follows: + +``` +athena% git merge lab1 +Merge made by recursive. + kern/kdebug.c | 11 +++++++++-- + kern/monitor.c | 19 +++++++++++++++++++ + lib/printfmt.c | 7 +++---- + 3 files changed, 31 insertions(+), 6 deletions(-) +athena% +``` + +Lab 2 contains the following new source files, which you should browse through: + +- inc/memlayout.h +- kern/pmap.c +- kern/pmap.h +- kern/kclock.h +- kern/kclock.c + +memlayout.h describes the layout of the virtual address space that you must implement by modifying pmap.c. memlayout.h and pmap.h define the PageInfo structure that you’ll use to keep track of which pages of physical memory are free. kclock.c and kclock.h manipulate the PC’s battery-backed clock and CMOS RAM hardware, in which the BIOS records the amount of physical memory the PC contains, among other things. The code in pmap.c needs to read this device hardware in order to figure out how much physical memory there is, but that part of the code is done for you: you do not need to know the details of how the CMOS hardware works. + +Pay particular attention to memlayout.h and pmap.h, since this lab requires you to use and understand many of the definitions they contain. You may want to review inc/mmu.h, too, as it also contains a number of definitions that will be useful for this lab. + +Before beginning the lab, don’t forget to add exokernel to get the 6.828 version of QEMU. + +### Hand-In Procedure + +When you are ready to hand in your lab code and write-up, add your answers-lab2.txt to the Git repository, commit your changes, and then run make handin. + +``` +athena% git add answers-lab2.txt +athena% git commit -am "my answer to lab2" +[lab2 a823de9] my answer to lab2 4 files changed, 87 insertions(+), 10 deletions(-) +athena% make handin +``` + +### Part 1: Physical Page Management + +The operating system must keep track of which parts of physical RAM are free and which are currently in use. JOS manages the PC’s physical memory with page granularity so that it can use the MMU to map and protect each piece of allocated memory. + +You’ll now write the physical page allocator. It keeps track of which pages are free with a linked list of struct PageInfo objects, each corresponding to a physical page. You need to write the physical page allocator before you can write the rest of the virtual memory implementation, because your page table management code will need to allocate physical memory in which to store page tables. + +> Exercise 1 +> +> In the file kern/pmap.c, you must implement code for the following functions (probably in the order given). +> +> boot_alloc() +> +> mem_init() (only up to the call to check_page_free_list()) +> +> page_init() +> +> page_alloc() +> +> page_free() +> +> check_page_free_list() and check_page_alloc() test your physical page allocator. You should boot JOS and see whether check_page_alloc() reports success. Fix your code so that it passes. You may find it helpful to add your own assert()s to verify that your assumptions are correct. + +This lab, and all the 6.828 labs, will require you to do a bit of detective work to figure out exactly what you need to do. This assignment does not describe all the details of the code you’ll have to add to JOS. Look for comments in the parts of the JOS source that you have to modify; those comments often contain specifications and hints. You will also need to look at related parts of JOS, at the Intel manuals, and perhaps at your 6.004 or 6.033 notes. + +### Part 2: Virtual Memory + +Before doing anything else, familiarize yourself with the x86’s protected-mode memory management architecture: namely segmentationand page translation. + +> Exercise 2 +> +> Look at chapters 5 and 6 of the Intel 80386 Reference Manual, if you haven’t done so already. Read the sections about page translation and page-based protection closely (5.2 and 6.4). We recommend that you also skim the sections about segmentation; while JOS uses paging for virtual memory and protection, segment translation and segment-based protection cannot be disabled on the x86, so you will need a basic understanding of it. + +### Virtual, Linear, and Physical Addresses + +In x86 terminology, a virtual address consists of a segment selector and an offset within the segment. A linear address is what you get after segment translation but before page translation. A physical address is what you finally get after both segment and page translation and what ultimately goes out on the hardware bus to your RAM. + +![屏幕快照 2018-09-04 11.22.20](/Users/qhwdw/Desktop/屏幕快照 2018-09-04 11.22.20.png) + +Recall that in part 3 of lab 1, we installed a simple page table so that the kernel could run at its link address of 0xf0100000, even though it is actually loaded in physical memory just above the ROM BIOS at 0x00100000. This page table mapped only 4MB of memory. In the virtual memory layout you are going to set up for JOS in this lab, we’ll expand this to map the first 256MB of physical memory starting at virtual address 0xf0000000 and to map a number of other regions of virtual memory. + +> Exercise 3 +> +> While GDB can only access QEMU’s memory by virtual address, it’s often useful to be able to inspect physical memory while setting up virtual memory. Review the QEMU monitor commands from the lab tools guide, especially the xp command, which lets you inspect physical memory. To access the QEMU monitor, press Ctrl-a c in the terminal (the same binding returns to the serial console). +> +> Use the xp command in the QEMU monitor and the x command in GDB to inspect memory at corresponding physical and virtual addresses and make sure you see the same data. +> +> Our patched version of QEMU provides an info pg command that may also prove useful: it shows a compact but detailed representation of the current page tables, including all mapped memory ranges, permissions, and flags. Stock QEMU also provides an info mem command that shows an overview of which ranges of virtual memory are mapped and with what permissions. + +From code executing on the CPU, once we’re in protected mode (which we entered first thing in boot/boot.S), there’s no way to directly use a linear or physical address. All memory references are interpreted as virtual addresses and translated by the MMU, which means all pointers in C are virtual addresses. + +The JOS kernel often needs to manipulate addresses as opaque values or as integers, without dereferencing them, for example in the physical memory allocator. Sometimes these are virtual addresses, and sometimes they are physical addresses. To help document the code, the JOS source distinguishes the two cases: the type uintptr_t represents opaque virtual addresses, and physaddr_trepresents physical addresses. Both these types are really just synonyms for 32-bit integers (uint32_t), so the compiler won’t stop you from assigning one type to another! Since they are integer types (not pointers), the compiler will complain if you try to dereference them. + +The JOS kernel can dereference a uintptr_t by first casting it to a pointer type. In contrast, the kernel can’t sensibly dereference a physical address, since the MMU translates all memory references. If you cast a physaddr_t to a pointer and dereference it, you may be able to load and store to the resulting address (the hardware will interpret it as a virtual address), but you probably won’t get the memory location you intended. + +To summarize: + +| C type | Address type | +| ------------ | ------------ | +| `T*` | Virtual | +| `uintptr_t` | Virtual | +| `physaddr_t` | Physical | + +>Question +> +>Assuming that the following JOS kernel code is correct, what type should variable x have, >uintptr_t or physaddr_t? +> +>![屏幕快照 2018-09-04 11.48.54](/Users/qhwdw/Desktop/屏幕快照 2018-09-04 11.48.54.png) +> + +The JOS kernel sometimes needs to read or modify memory for which it knows only the physical address. For example, adding a mapping to a page table may require allocating physical memory to store a page directory and then initializing that memory. However, the kernel, like any other software, cannot bypass virtual memory translation and thus cannot directly load and store to physical addresses. One reason JOS remaps of all of physical memory starting from physical address 0 at virtual address 0xf0000000 is to help the kernel read and write memory for which it knows just the physical address. In order to translate a physical address into a virtual address that the kernel can actually read and write, the kernel must add 0xf0000000 to the physical address to find its corresponding virtual address in the remapped region. You should use KADDR(pa) to do that addition. + +The JOS kernel also sometimes needs to be able to find a physical address given the virtual address of the memory in which a kernel data structure is stored. Kernel global variables and memory allocated by boot_alloc() are in the region where the kernel was loaded, starting at 0xf0000000, the very region where we mapped all of physical memory. Thus, to turn a virtual address in this region into a physical address, the kernel can simply subtract 0xf0000000. You should use PADDR(va) to do that subtraction. + +### Reference counting + +In future labs you will often have the same physical page mapped at multiple virtual addresses simultaneously (or in the address spaces of multiple environments). You will keep a count of the number of references to each physical page in the pp_ref field of thestruct PageInfo corresponding to the physical page. When this count goes to zero for a physical page, that page can be freed because it is no longer used. In general, this count should equal to the number of times the physical page appears below UTOP in all page tables (the mappings above UTOP are mostly set up at boot time by the kernel and should never be freed, so there’s no need to reference count them). We’ll also use it to keep track of the number of pointers we keep to the page directory pages and, in turn, of the number of references the page directories have to page table pages. + +Be careful when using page_alloc. The page it returns will always have a reference count of 0, so pp_ref should be incremented as soon as you’ve done something with the returned page (like inserting it into a page table). Sometimes this is handled by other functions (for example, page_insert) and sometimes the function calling page_alloc must do it directly. + +### Page Table Management + +Now you’ll write a set of routines to manage page tables: to insert and remove linear-to-physical mappings, and to create page table pages when needed. + +> Exercise 4 +> +> In the file kern/pmap.c, you must implement code for the following functions. +> +> pgdir_walk() +> +> boot_map_region() +> +> page_lookup() +> +> page_remove() +> +> page_insert() +> +> check_page(), called from mem_init(), tests your page table management routines. You should make sure it reports success before proceeding. + +### Part 3: Kernel Address Space + +JOS divides the processor’s 32-bit linear address space into two parts. User environments (processes), which we will begin loading and running in lab 3, will have control over the layout and contents of the lower part, while the kernel always maintains complete control over the upper part. The dividing line is defined somewhat arbitrarily by the symbol ULIM in inc/memlayout.h, reserving approximately 256MB of virtual address space for the kernel. This explains why we needed to give the kernel such a high link address in lab 1: otherwise there would not be enough room in the kernel’s virtual address space to map in a user environment below it at the same time. + +You’ll find it helpful to refer to the JOS memory layout diagram in inc/memlayout.h both for this part and for later labs. + +### Permissions and Fault Isolation + +Since kernel and user memory are both present in each environment’s address space, we will have to use permission bits in our x86 page tables to allow user code access only to the user part of the address space. Otherwise bugs in user code might overwrite kernel data, causing a crash or more subtle malfunction; user code might also be able to steal other environments’ private data. + +The user environment will have no permission to any of the memory above ULIM, while the kernel will be able to read and write this memory. For the address range [UTOP,ULIM), both the kernel and the user environment have the same permission: they can read but not write this address range. This range of address is used to expose certain kernel data structures read-only to the user environment. Lastly, the address space below UTOP is for the user environment to use; the user environment will set permissions for accessing this memory. + +### Initializing the Kernel Address Space + +Now you’ll set up the address space above UTOP: the kernel part of the address space. inc/memlayout.h shows the layout you should use. You’ll use the functions you just wrote to set up the appropriate linear to physical mappings. + +> Exercise 5 +> +> Fill in the missing code in mem_init() after the call to check_page(). + +Your code should now pass the check_kern_pgdir() and check_page_installed_pgdir() checks. + +> Question +> +> ​ 1、What entries (rows) in the page directory have been filled in at this point? What addresses do they map and where do they point? In other words, fill out this table as much as possible: +> +> EntryBase Virtual AddressPoints to (logically): +> +> 1023 ? Page table for top 4MB of phys memory +> +> 1022 ? ? +> +> . ? ? +> +> . ? ? +> +> . ? ? +> +> 2 0x00800000 ? +> +> 1 0x00400000 ? +> +> 0 0x00000000 [see next question] +> +> ​ 2、(From 20 Lecture3) We have placed the kernel and user environment in the same address space. Why will user programs not be able to read or write the kernel’s memory? What specific mechanisms protect the kernel memory? +> +> ​ 3、What is the maximum amount of physical memory that this operating system can support? Why? +> +> ​ 4、How much space overhead is there for managing memory, if we actually had the maximum amount of physical memory? How is this overhead broken down? +> +> ​ 5、Revisit the page table setup in kern/entry.S and kern/entrypgdir.c. Immediately after we turn on paging, EIP is still a low number (a little over 1MB). At what point do we transition to running at an EIP above KERNBASE? What makes it possible for us to continue executing at a low EIP between when we enable paging and when we begin running at an EIP above KERNBASE? Why is this transition necessary? + +### Address Space Layout Alternatives + +The address space layout we use in JOS is not the only one possible. An operating system might map the kernel at low linear addresses while leaving the upper part of the linear address space for user processes. x86 kernels generally do not take this approach, however, because one of the x86’s backward-compatibility modes, known as virtual 8086 mode, is “hard-wired” in the processor to use the bottom part of the linear address space, and thus cannot be used at all if the kernel is mapped there. + +It is even possible, though much more difficult, to design the kernel so as not to have to reserve any fixed portion of the processor’s linear or virtual address space for itself, but instead effectively to allow allow user-level processes unrestricted use of the entire 4GB of virtual address space - while still fully protecting the kernel from these processes and protecting different processes from each other! + +Generalize the kernel’s memory allocation system to support pages of a variety of power-of-two allocation unit sizes from 4KB up to some reasonable maximum of your choice. Be sure you have some way to divide larger allocation units into smaller ones on demand, and to coalesce multiple small allocation units back into larger units when possible. Think about the issues that might arise in such a system. + +This completes the lab. Make sure you pass all of the make grade tests and don’t forget to write up your answers to the questions inanswers-lab2.txt. Commit your changes (including adding answers-lab2.txt) and type make handin in the lab directory to hand in your lab. + +------ + +via: + +作者:[Mit][] +译者:[译者ID](https://github.com/%E8%AF%91%E8%80%85ID) +校对:[校对者ID](https://github.com/%E6%A0%A1%E5%AF%B9%E8%80%85ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 \ No newline at end of file From 2dee36d1c33d8c3dc46a4929fed407dd56d2575b Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Tue, 4 Sep 2018 15:42:16 +0800 Subject: [PATCH 063/455] submit tech/20180725 How do private keys work in PKI and cryptography.md --- ...ivate keys work in PKI and cryptography.md | 103 ------------------ ...ivate keys work in PKI and cryptography.md | 101 +++++++++++++++++ 2 files changed, 101 insertions(+), 103 deletions(-) delete mode 100644 sources/tech/20180725 How do private keys work in PKI and cryptography.md create mode 100644 translated/tech/20180725 How do private keys work in PKI and cryptography.md diff --git a/sources/tech/20180725 How do private keys work in PKI and cryptography.md b/sources/tech/20180725 How do private keys work in PKI and cryptography.md deleted file mode 100644 index 7bb1528a71..0000000000 --- a/sources/tech/20180725 How do private keys work in PKI and cryptography.md +++ /dev/null @@ -1,103 +0,0 @@ -pinewall translating - -How do private keys work in PKI and cryptography? -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security_privacy_lock.png?itok=ZWjrpFzx) - -In [a previous article][1], I gave an overview of cryptography and discussed the core concepts of confidentiality (keeping data secret), integrity (protecting data from tampering), and authentication (knowing the identity of the data's source). Since authentication relates so closely to all the messiness of identity in the real world, a complex technological ecosystem has evolved around establishing that someone is who they claim to be. In this article, I'll describe in broad strokes how these systems work. - -### A quick review of public key cryptography and digital signatures - -Authentication in the online world relies on public key cryptography where a key has two parts: a private key kept secret by the owner and a public key shared with the world. After the public key encrypts data, only the private key can decrypt it. This feature is useful if a whistleblower wanted to establish contact with a [journalist][2], for example. More importantly for this article, a private key can be combined with a message to create a digital signature that provides integrity and authentication. - -In practice, what is signed is not the actual message, but a digest of a message attained by sending the message through a cryptographic hash function. Instead of signing an entire zip file of source code, the sender signs the 256-bit [SHA-256][3] digest of that zip file and sends the zip file in the clear. Recipients independently calculate the SHA-256 digest of the file they received. They input their digest, the signature they received, and the sender's public key into a signature verification algorithm. The verification process varies depending on the encryption algorithm, and there are enough subtleties that signature verification [vulnerabilities][4] still [pop up][5] . If the verification succeeds, the file has not been modified in transit and must have originated from the sender since only the sender has the private key that created the signature. - -### The missing piece of the puzzle - -There's one major detail missing from this scenario. Where do we get the sender's public key? The sender could send the public key along with a message, but then we have no proof of their identity beyond their own assertion. Imagine being a bank teller and a customer walks up and says, "Hello, I'm Jane Doe, and I'd like to make a withdrawal." When you ask for identification, she points to a name tag sticker on her shirt that says "Jane Doe." Personally, I would politely turn "Jane" away. - -If you already know the sender, you could meet in person and exchange public keys. If you don't, you could meet in person, examine their passport, and once you are satisfied it is authentic, accept their public key. To make the process more efficient, you could throw a [party][6], invite a bunch of people, examine all their passports, and accept all their public keys. Building off that, if you know Jane Doe and trust her (despite her unusual banking practices), Jane could go to the party, get the public keys, and give them to you. In fact, Jane could just sign the other public keys using her own private key, and then you could use [an online repository][7] of public keys, trusting the ones signed by Jane. If a person's public key is signed by multiple people you trust, then you might decide to trust that person as well (even though you don't know them). In this fashion, you can build a [web of trust][8]. - -But now things have gotten complicated: We need to decide on a standard way to encode a key and the identity associated with that key into a digital bundle we can sign. More properly, these digital bundles are called certificates. We'll also need tooling that can create, use, and manage these certificates. The way we solve these and other requirements is what constitutes a public key infrastructure (PKI). - -### Beyond the web of trust - -You can think of the web of trust as a network of people. A network with many interconnections between the people makes it easy to find a short path of trust: a social circle, for example. [GPG][9]-encrypted email relies on a web of trust, and it functions ([in theory][10]) since most of us communicate primarily with a relatively small group of friends, family, and co-workers. - -In practice, the web of trust has some [significant problems][11], many of them around scaling. When the network starts to get larger and there are few connections between people, the web of trust starts to break down. If the path of trust is attenuated across a long chain of people, you face a higher chance of encountering someone who carelessly or maliciously signed a key. And if there is no path at all, you have to create one by contacting the other party and verifying their key to your satisfaction. Imagine going to an online store that you and your friends have never used. Before you establish a secure communications channel to place an order, you'd need to verify the site's public key belongs to the company and not an impostor. That vetting would entail going to a physical store, making telephone calls, or some other laborious process. Online shopping would be a lot less convenient (or a lot less secure since many people would cut corners and accept the key without verifying it). - -What if the world had some exceptionally trustworthy people constantly verifying and signing keys for websites? You could just trust them, and browsing the internet would be much smoother. At a high level, that's how things work today. These "exceptionally trustworthy people" are companies called certificate authorities (CAs). When a website wants to get its public key signed, it submits a certificate signing request (CSR) to the CA. - -CSRs are like stub certificates that contain a public key and an identity (in this case, the hostname of the server), but are not signed by a CA. Before signing, the CA performs some verification steps. In some cases, the CA merely verifies that the requester controls the domain for the hostname listed in the CSR (via a challenge-and-response email exchange with the address in the WHOIS entry, for example). [In other cases][12], the CA inspects legal documents, like business licenses. Once the CA is satisfied (and usually after the requester has paid a fee), it takes the data from the CSR and signs it with its own private key to create a certificate. The CA then sends the certificate to the requester. The requester installs the certificate on their site's web server, and the certificate is delivered to users when they connect over HTTPS (or any other protocol secured with [TLS][13]). - -When users connect to the site, their browser looks at the certificate, checks that the hostname in the certificate is the same as the hostname it is connected to (more on this in a moment), and verifies the CA's signature. If any of these steps fail, the browser will show a warning and break off the connection. Otherwise, the browser uses the public key in the certificate to verify some signed information sent from the server to ensure that the server possesses the certificate's private key. These messages also serve as steps in one of several algorithms used to establish a shared secret key that will encrypt subsequent messages. Key exchange algorithms are beyond the scope of this article, but there's a good discussion of one of them in [this video][14]. - -### Creating trust - -You're probably wondering, "If the CA's private key signs a certificate, that means to verify a certificate we need the CA's public key. Where does it come from and who signs it?" The answer is the CA signs for itself! A certificate can be signed using the private key associated with the same certificate's public key. These certificates are said to be self-signed; they are the PKI equivalent of saying, "Trust me." (People often say, as a form of shorthand, that a certificate has signed something even though it's the private key—which isn't in the certificate at all—doing the actual signing.) - -By adhering to policies established by [web browser][15] and [operating system][16] vendors, CAs demonstrate they are trustworthy enough to be placed into a group of self-signed certificates built into the browser or operating system. These certificates are called trust anchors or root CA certificates, and they are placed in a root certificate store where they are trusted implicitly. - -A CA can also issue a certificate endowed with the ability to act as a CA itself. In this way, they can create a chain of certificates. To verify the chain, a program starts at the trust anchor and verifies (among other things) the signature on the next certificate using the public key of the current certificate. It continues down the chain, verifying each link until it reaches the end. If there are no problems along the way, a chain of trust is established. When a website pays a CA to sign a certificate for it, they are paying for the privilege of being placed at the end of that chain. CAs mark certificates sold to websites as not being allowed to sign subsequent certificates; this is so they can terminate the chain of trust at the appropriate place. - -Why would a chain ever be more than two links long? After all, a site just needs its certificate signed by a CA's root certificate. In practice, CAs create intermediate CA certificates for convenience (among other reasons). The private keys for a CA's root certificates are so valuable that they reside in a specialized device, a [hardware security module][17] (HSM), that requires multiple people to unlock it, is completely offline, and is kept inside a [vault][18] wired with alarms and cameras. - -CAB Forum, the association that governs CAs, [requires][19] any interaction with a CA's root certificate to be performed directly by a human. Issuing certificates for dozens of websites a day would be tedious if every certificate request required an employee to place the request on secure media, enter a vault, unlock the HSM with a coworker, sign the certificate, exit the vault, and then copy the signed certificate off the media. Instead, CAs create internal, intermediate CAs used to sign certificates automatically. - -You can see this chain in Firefox by clicking the lock icon in the URL bar, opening up the page information, and clicking the "View Certificate" button on the "Security" tab. As of this writing, [opensource.com][20] had the following chain: -``` -DigiCert High Assurance EV Root CA - -    DigiCert SHA2 High Assurance Server CA - -        opensource.com - -``` - -### The man in the middle - -I mentioned earlier that a browser needs to check that the hostname in the certificate is the same as the hostname it connected to. Why? The answer has to do with what's called a [man-in-the-middle (MITM) attack][21]. These are [network attacks][22] that allow an attacker to insert itself between a client and a server, masquerading as the server to the client and vice versa. If the traffic is over HTTPS, it's encrypted and eavesdropping is fruitless. Instead, the attacker can create a proxy that will accept HTTPS connections from the victim, decrypt the information, and then form an HTTPS connection with the original destination. To create the phony HTTPS connection, the proxy must return a certificate that our attacker has the private key for. Our attacker could generate self-signed certificates, but the victim's browser won't trust anything not signed by a CA's root certificate in the browser's root certificate store. What if instead, the attacker uses a certificate signed by a trusted CA for a domain it owns? - -Imagine we're back to our job in the bank. A man walks in and asks to withdraw money from Jane Doe's account. When asked for identification, the man hands us a valid driver's license for Joe Smith. We would be rightfully fired if we allowed the transaction to continue. If a browser detects a mismatch between the certificate hostname and the connection hostname, it will show a warning that says something like "Your connection is not secure" and an option to show additional details. In Firefox, this error is called SSL_ERROR_BAD_CERT_DOMAIN. - -If there's one lesson I want you to remember from this article, it's: If you see these warnings, **do not disregard them**! They signal that the site is either configured so erroneously that you shouldn't use it or that you're the potential victim of a MITM attack. - -### Final thoughts - -I've only scratched the surface of the PKI world in this article, but I hope that I've given you a map that you can use to guide your further explorations. Cryptography and PKI are fractal-like in their beauty and complexity. The further you dive in, the more there is to discover. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/7/private-keys - -作者:[Alex Wood][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/awood -[1]:https://opensource.com/article/18/5/cryptography-pki -[2]:https://theintercept.com/2014/10/28/smuggling-snowden-secrets/ -[3]:https://en.wikipedia.org/wiki/SHA-2 -[4]:https://www.ietf.org/mail-archive/web/openpgp/current/msg00999.html -[5]:https://www.imperialviolet.org/2014/09/26/pkcs1.html -[6]:https://en.wikipedia.org/wiki/Key_signing_party -[7]:https://en.wikipedia.org/wiki/Key_server_(cryptographic) -[8]:https://en.wikipedia.org/wiki/Web_of_trust -[9]:https://www.gnupg.org/gph/en/manual/x547.html -[10]:https://blog.cryptographyengineering.com/2014/08/13/whats-matter-with-pgp/ -[11]:https://lists.torproject.org/pipermail/tor-talk/2013-September/030235.html -[12]:https://en.wikipedia.org/wiki/Extended_Validation_Certificate -[13]:https://en.wikipedia.org/wiki/Transport_Layer_Security -[14]:https://www.youtube.com/watch?v=YEBfamv-_do -[15]:https://www.mozilla.org/en-US/about/governance/policies/security-group/certs/policy/ -[16]:https://technet.microsoft.com/en-us/library/cc751157.aspx -[17]:https://en.wikipedia.org/wiki/Hardware_security_module -[18]:https://arstechnica.com/information-technology/2012/11/inside-symantecs-ssl-certificate-vault/ -[19]:https://cabforum.org/baseline-requirements-documents/ -[20]:http://opensource.com -[21]:https://en.wikipedia.org/wiki/Man-in-the-middle_attack -[22]:http://www.shortestpathfirst.net/2010/11/18/man-in-the-middle-mitm-attacks-explained-arp-poisoining/ diff --git a/translated/tech/20180725 How do private keys work in PKI and cryptography.md b/translated/tech/20180725 How do private keys work in PKI and cryptography.md new file mode 100644 index 0000000000..6c42531396 --- /dev/null +++ b/translated/tech/20180725 How do private keys work in PKI and cryptography.md @@ -0,0 +1,101 @@ +PKI 和 密码学中的私钥的角色 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security_privacy_lock.png?itok=ZWjrpFzx) + +在[上一篇文章][1]中,我们概述了密码学并讨论了密码学的核心概念:保密性confidentiality (让数据保密),完整性integrity (防止数据被篡改)和身份认证authentication (确认数据源的身份identity)。由于要在存在各种身份混乱的现实世界中完成身份认证,人们逐渐建立起一个复杂的技术生态体系technological ecosystem,用于证明某人就是其声称的那个人。在本文中,我们将大致介绍这些体系是如何工作的。 + +### 公钥密码学及数字签名快速回顾 + +互联网世界中的身份认证依赖于公钥密码学,其中密钥分为两部分:拥有者需要保密的私钥和可以对外公开的公钥。经过公钥加密过的数据,只能用对应的私钥解密。举个例子,对于希望与[记者][2]建立联系的举报人来说,这个特性非常有用。但就本文介绍的内容而言,私钥更重要的用途是与一个消息一起创建一个数字签名digital signature,用于提供完整性和身份认证。 + +在实际应用中,我们签名的并不是真实消息,而是经过密码学哈希函数cryptographic hash function处理过的消息摘要digest。要发送一个包含源代码的压缩文件,发送者会对该压缩文件的 256 比特长度的 [SHA-256][3] 摘要而不是文件本身进行签名,然后用明文发送该压缩包(和签名)。接收者会独立计算收到文件的 SHA-256 摘要,然后结合该摘要、收到的签名及发送者的公钥,使用签名验证算法进行验证。验证过程取决于加密算法,加密算法不同,验证过程也相应不同;而且,由于不断发现微妙的触发条件,签名验证[漏洞][4]依然[层出不穷][5]。如果签名验证通过,说明文件在传输过程中没有被篡改而且来自于发送者,这是因为只有发送者拥有创建签名所需的私钥。 + +### 方案中缺失的环节 + +上述方案中缺失了一个重要的环节:我们从哪里获得发送者的公钥?发送者可以将公钥与消息一起发送,但除了发送者的自我宣称,我们无法核验其身份。假设你是一名银行柜员,一名顾客走过来向你说,“你好,我是 Jane Doe,我要取一笔钱”。当你要求其证明身份时,她指着衬衫上贴着的姓名标签说道,“看,Jane Doe!”。如果我是这个柜员,我会礼貌的拒绝她的请求。 + +如果你认识发送者,你们可以私下见面并彼此交换公钥。如果你并不认识发送者,你们可以私下见面,检查对方的证件,确认真实性后接受对方的公钥。为提高流程效率,你可以举办聚会并邀请一堆人,检查他们的证件,然后接受他们的公钥。此外,如果你认识并信任 Jane Doe (尽管她在银行的表现比较反常),Jane 可以参加聚会,收集大家的公钥然后交给你。事实上,Jane 可以使用她自己的私钥对这些公钥(及对应的身份信息)进行签名,进而你可以从一个[线上密钥库][7]获取公钥(及对应的身份信息)并信任已被 Jane 签名的那部分。如果一个人的公钥被很多你信任的人(即使你并不认识他们)签名,你也可能选择信任这个人。按照这种方式,你可以建立一个[信任网络Web of Trust][8]。 + +但事情也变得更加复杂:我们需要建立一种标准的编码机制,可以将公钥和其对应的身份信息编码成一个数字捆绑digital bundle,以便我们进一步进行签名。更准确的说,这类数字捆绑被称为证书cerificates。我们还需要可以创建、使用和管理这些证书的工具链。满足诸如此类的各种需求的方案构成了公钥基础设施public key infrastructure, PKI。 + +### 比信任网络更进一步 + +你可以用人际关系网类比信任网络。如果人们之间广泛互信,可以很容易找到(两个人之间的)一条短信任链short path of trust:不妨以社交圈为例。基于 [GPG][9] 加密的邮件依赖于信任网络,([理论上][10])只适用于与少量朋友、家庭或同事进行联系的情形。 + +(LCTT 译注:作者提到的“短信任链”应该是暗示“六度空间理论”,即任意两个陌生人之间所间隔的人一般不会超过 6 个。对 GPG 的唱衰,一方面是因为密钥管理的复杂性没有改善,另一方面 Yahoo 和 Google 都提出了更便利的端到端加密方案。) + +在实际应用中,信任网络有一些["硬伤"significant problems][11],主要是在可扩展性方面。当网络规模逐渐增大或者人们之间的连接逐渐降低时,信任网络就会慢慢失效。如果信任链逐渐变长,信任链中某人有意或无意误签证书的几率也会逐渐增大。如果信任链不存在,你不得不自己创建一条信任链;具体而言,你与其它组织建立联系,验证它们的密钥符合你的要求。考虑下面的场景,你和你的朋友要访问一个从未使用过的在线商店。你首先需要核验网站所用的公钥属于其对应的公司而不是伪造者,进而建立安全通信信道,最后完成下订单操作。核验公钥的方法包括去实体店、打电话等,都比较麻烦。这样会导致在线购物变得不那么便利(或者说不那么安全,毕竟很多人会图省事,不去核验密钥)。 + +如果世界上有那么几个格外值得信任的人,他们专门负责核验和签发网站证书,情况会怎样呢?你可以只信任他们,那么浏览互联网也会变得更加容易。整体来看,这就是当今互联网的工作方式。那些“格外值得信任的人”就是被称为证书颁发机构cerificate authorities, CAs的公司。当网站希望获得公钥签名时,只需向 CA 提交证书签名请求certificate signing request。 + +CSR 类似于包括公钥和身份信息(在本例中,即服务器的主机名)的存根stub证书,但CA 并不会直接对 CSR 本身进行签名。CA 在签名之前会进行一些验证。对于一些证书类型(LCTT 译注:DVDomain Validated 类型),CA 只验证申请者的确是 CSR 中列出主机名对应域名的控制者(例如通过邮件验证,让申请者完成指定的域名解析)。[对于另一些证书类型][12] (LCTT 译注:链接中提到EVExtended Validated 类型,其实还有 OVOrganization Validated 类型),CA 还会检查相关法律文书,例如公司营业执照等。一旦验证完成,CA(一般在申请者付费后)会从 CSR 中取出数据(即公钥和身份信息),使用 CA 自己的私钥进行签名,创建一个(签名)证书并发送给申请者。申请者将该证书部署在网站服务器上,当用户使用 HTTPS (或其它基于 [TLS][13] 加密的协议)与服务器通信时,该证书被分发给用户。 + +当用户访问该网站时,浏览器获取该证书,接着检查证书中的主机名是否与当前正在连接的网站一致(下文会详细说明),核验 CA 签名有效性。如果其中一步验证不通过,浏览器会给出安全警告并切断与网站的连接。反之,如果验证通过,浏览器会使用证书中的公钥核验服务器发送的签名信息,确认该服务器持有该证书的私钥。有几种算法用于协商后续通信用到的共享密钥shared secret key,其中一种也用到了服务器发送的签名信息。密钥交换Key exchange算法不在本文的讨论范围,可以参考这个[视频][14],其中仔细说明了一种密钥交换算法。 + +### 建立信任 + +你可能会问,“如果 CA 使用其私钥对证书进行签名,也就意味着我们需要使用 CA 的公钥验证证书。那么 CA 的公钥从何而来,谁对其进行签名呢?” 答案是 CA 对自己签名!可以使用证书公钥对应的私钥,对证书本身进行签名!这类签名证书被称为是自签名的self-signed;在 PKI 体系下,这意味着对你说“相信我”。(为了表达方便,人们通常说用证书进行了签名,虽然真正用于签名的私钥并不在证书中。) + +通过遵守[浏览器][15]和[操作系统][16]供应商建立的规则,CA 表明自己足够可靠并寻求加入到浏览器或操作系统预装的一组自签名证书中。这些证书被称为“信任锚trust anchors”或 CA 根证书root CA certificates,被存储在根证书区,我们约定implicitly信任该区域内的证书。 + +CA 也可以签发一种特殊的证书,该证书自身可以作为 CA。在这种情况下,它们可以生成一个证书链。要核验证书链,需要从“信任锚”(也就是 CA 根证书)开始,使用当前证书的公钥核验下一层证书的签名(或其它一些信息)。按照这个方式依次核验下一层证书,直到证书链底部。如果整个核验过程没有问题,信任链也建立完成。当向 CA 付费为网站签发证书时,实际购买的是将证书放置在证书链下的权利。CA 将卖出的证书标记为“不可签发子证书”,这样它们可以在适当的长度终止信任链(防止其继续向下扩展)。 + +为何要使用长度超过 2 的信任链呢?毕竟网站的证书可以直接被 CA 根证书签名。在实际应用中,很多因素促使 CA 创建中间 CA 证书intermediate CA certificate,最主要是为了方便。由于价值连城,CA 根证书对应的私钥通常被存放在特定的设备中,一种需要多人解锁的硬件安全模块hardware security module, HSM,该模块完全离线并被保管在配备监控和报警设备的[地下室][18]中。 + +CA/浏览器论坛CAB Forum, CA/Browser Forum负责管理 CA,[要求][19]任何与 CA 根证书(LCTT 译注:就像前文提到的那样,这里是指对应的私钥)相关的操作必须由人工完成。设想一下,如果每个证书请求都需要员工将请求内容拷贝到保密介质中、进入地下室、与同事一起解锁 HSM、(使用 CA 根证书对应的私钥)签名证书,最后将签名证书从保密介质中拷贝出来;那么每天为大量网站签发证书是相当繁重乏味的工作。因此,CA 创建内部使用的中间 CA,用于证书签发自动化。 + +如果想查看证书链,可以在 Firefox 中点击地址栏的锁型图标,接着打开页面信息,然后点击“安全”面板中的“查看证书”按钮。在本文写作时,[opensource.com][20] 使用的证书链如下: + +``` +DigiCert High Assurance EV Root CA +    DigiCert SHA2 High Assurance Server CA +        opensource.com +``` + +### 中间人 + +我之前提到,浏览器需要核验证书中的主机名与已经建立连接的主机名一致。为什么需要这一步呢?要回答这个问题,需要了解所谓的[中间人攻击man-in-the-middle, MIMT][22]。有一类[网络攻击][22]可以让攻击者将自己置身于客户端和服务端中间,冒充客户端与服务端连接,同时冒充服务端与客户端连接。如果网络流量是通过 HTTPS 传输的,加密的流量无法被窃听。此时,攻击者会创建一个代理,接收来自受害者的 HTTPS 连接,解密信息后构建一个新的 HTTPS 连接到原始目的地(即服务端)。为了建立假冒的 HTTPS 连接,代理必须返回一个攻击者具有对应私钥的证书。攻击者可以生成自签名证书,但受害者的浏览器并不会信任该证书,因为它并不是根证书库中的 CA 根证书签发的。换一个方法,攻击者使用一个受信任 CA 签发但主机名对应其自有域名的证书,结果会怎样呢? + +再回到银行的那个例子,我们是银行柜员,一位男性顾客进入银行要求从 Jane Doe 的账户上取钱。当被要求提供身份证明时,他给出了 Joe Smith 的有效驾驶执照。如果这个交易可以完成,我们无疑会被银行开除。类似的,如果检测到证书中的主机名与连接对应的主机名不一致,浏览器会给出类似“连接不安全”的警告和查看更多内容的选项。在 Firefox 中,这类错误被标记为 `SSL_ERROR_BAD_CERT_DOMAIN`。 + +我希望你阅读完本文起码记住这一点:如果看到这类警告,**不要无视它们**!它们出现意味着,或者该网站配置存在严重问题(不推荐访问),或者你已经是中间人攻击的潜在受害者。 + +### 总结 + +虽然本文只触及了 PKI 世界的一些皮毛,我希望我已经为你展示了便于后续探索的大致蓝图。密码学和 PKI 是美与复杂性的结合体。越深入研究,越能发现更多的美和复杂性,就像分形那样。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/7/private-keys + +作者:[Alex Wood][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[pinewall](https://github.com/pinewall) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/awood +[1]:https://opensource.com/article/18/5/cryptography-pki +[2]:https://theintercept.com/2014/10/28/smuggling-snowden-secrets/ +[3]:https://en.wikipedia.org/wiki/SHA-2 +[4]:https://www.ietf.org/mail-archive/web/openpgp/current/msg00999.html +[5]:https://www.imperialviolet.org/2014/09/26/pkcs1.html +[6]:https://en.wikipedia.org/wiki/Key_signing_party +[7]:https://en.wikipedia.org/wiki/Key_server_(cryptographic) +[8]:https://en.wikipedia.org/wiki/Web_of_trust +[9]:https://www.gnupg.org/gph/en/manual/x547.html +[10]:https://blog.cryptographyengineering.com/2014/08/13/whats-matter-with-pgp/ +[11]:https://lists.torproject.org/pipermail/tor-talk/2013-September/030235.html +[12]:https://en.wikipedia.org/wiki/Extended_Validation_Certificate +[13]:https://en.wikipedia.org/wiki/Transport_Layer_Security +[14]:https://www.youtube.com/watch?v=YEBfamv-_do +[15]:https://www.mozilla.org/en-US/about/governance/policies/security-group/certs/policy/ +[16]:https://technet.microsoft.com/en-us/library/cc751157.aspx +[17]:https://en.wikipedia.org/wiki/Hardware_security_module +[18]:https://arstechnica.com/information-technology/2012/11/inside-symantecs-ssl-certificate-vault/ +[19]:https://cabforum.org/baseline-requirements-documents/ +[20]:http://opensource.com +[21]:https://en.wikipedia.org/wiki/Man-in-the-middle_attack +[22]:http://www.shortestpathfirst.net/2010/11/18/man-in-the-middle-mitm-attacks-explained-arp-poisoining/ From 54aed21be40100e21754deaea8ffdfdb1d9c3852 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 5 Sep 2018 08:49:07 +0800 Subject: [PATCH 064/455] translated --- ...Ys Without Using Function Keys In Linux.md | 108 ------------------ ...Ys Without Using Function Keys In Linux.md | 106 +++++++++++++++++ 2 files changed, 106 insertions(+), 108 deletions(-) delete mode 100644 sources/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md create mode 100644 translated/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md diff --git a/sources/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md b/sources/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md deleted file mode 100644 index 6a260c291f..0000000000 --- a/sources/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md +++ /dev/null @@ -1,108 +0,0 @@ -translating---geekpi - -How To Switch Between TTYs Without Using Function Keys In Linux -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/08/Switch-Between-TTYs-720x340.png) - -This brief guide describes how to switch between TTYs without function keys in Unix-like operating systems. Before going further, we will see what TTY is. As mentioned in an [**answer**][1] in AskUbuntu forum, the word **TTY** came from **T** ele **TY** pewriter. Back in the early days of Unix, the user terminals connected to computers were electromechanical teleprinters or teletypewriters( tty in short). Since then, the name TTY has continued to be used for text-only consoles. Nowadays, all text consoles represents virtual consoles, not physical consoles. The TTY command prints the file name of the terminal connected to standard input. - -### Switch Between TTYs In Linux - -By default, there are 7 ttys in Linux. They are known as tty1, tty2….. tty7. The 1 to 6 ttys are command line only. The 7th tty is GUI (your X desktop session). You can switch between different TTYs by using **CTRL+ALT+Fn** keys. For example to switch to tty1, we type CTRL+ALT+F1. This is how tty1 looks in Ubuntu 18.04 LTS server. - -![](https://www.ostechnix.com/wp-content/uploads/2018/08/tty1.png) - -If your system has no X session, - -In some Linux editions (Eg. from Ubuntu 17.10 onwards), the login screen now uses virtual console 1 . So, you need to press CTRL+ALT+F3 up to CTRL+ALT+F6 for accessing the virtual consoles. To go back to desktop environment, press CTRL+ALT+F2 or CTRL+ALT+F7 on Ubuntu 17.10 and later. - -What we have seen so far is we can easily switch between TTYs using CTRL+ALT+Function_Key(F1-F7). However, if you don’t want to use the functions keys for any reason, there is a simple command named **“chvt”** in Linux. - -The “chvt N” command allows you to switch to foreground terminal N, the same as pressing CTRL+ALT+Fn. The corresponding screen is created if it did not exist yet. - -Let us see print the current tty: -``` -$ tty - -``` - -Sample output from my Ubuntu 18.04 LTS server. - -Now let us switch to tty2. To do so, type: -``` -$ sudo chvt 2 - -``` - -Remember you need to use “sudo” with chvt command. - -Now, check the current tty using command: -``` -$ tty - -``` - -You will see that the tty has changed now. - -Similarly, you can switch to tty3 using “sudo chvt 3”, tty4 using “sudo chvt 4” and so on. - -Chvt command can be useful when any one of your function keys doesn’t work. - -To view the total number of active virtual consoles, run: -``` -$ fgconsole -2 - -``` - -As you can see, there are two active VTs in my system. - -You can see the next unallocated virtual terminal using command: -``` -$ fgconsole --next-available -3 - -``` - -A virtual console is unused if it is not the foreground console, and no process has it open for reading or writing, and no text has been selected on its screen. - -To get rid of unused VTs, just type: -``` -$ deallocvt - -``` - -The above command deallocates kernel memory and data structures for all unused virtual consoles. To put this simply, this command will free all resources connected to the unused virtual consoles. - -For more details, refer the respective command’s man pages. -``` -$ man tty - -$ man chvt - -$ man fgconsole - -$ man deallocvt - -``` - -And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-switch-between-ttys-without-using-function-keys-in-linux/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.ostechnix.com/author/sk/ -[1]:https://askubuntu.com/questions/481906/what-does-tty-stand-for diff --git a/translated/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md b/translated/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md new file mode 100644 index 0000000000..5ca31d8351 --- /dev/null +++ b/translated/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md @@ -0,0 +1,106 @@ +如何在 Linux 中不使用功能键在 TTY 之间切换 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/08/Switch-Between-TTYs-720x340.png) + +本简要指南介绍了在类 Unix 操作系统中如何在不使用功能键的情况下切换 TTY。在进一步讨论之前,我们将了解 TTY 是什么。正如在 AskUbuntu 论坛的一个[**答案**][1]中所提到的,**TTY**这个词来自 **T**ele **TY** pewriter。在 Unix 的早期,连接到计算机的用户终端就是机电电传机或电传打字机(简称 tty)。从那时起,TTY 这个名称继续用于纯文本控制台。如今,所有文本控制台都代表虚拟控制台,而不是物理控制台。TTY 命令打印连接到标准输入的终端的文件名。 + +### 在 Linux 中切换 TTY + +默认情况下,Linux 中有 7 个 tty。它们被称为 tty1、tty2。。。tty7。1 到 6 tty 只是命令行。第 7 个 tty 是 GUI(你的 X 桌面会话)。你可以使用 **CTRL+ALT+Fn** 键在不同的 TTY 之间切换。例如,要切换到 tty1,我们按下 CTRL+ALT+F1。这就是 tty1 在 Ubuntu 18.04 LTS 服务器中的样子。 + +![](https://www.ostechnix.com/wp-content/uploads/2018/08/tty1.png) + +如果你的系统没有 X 会话, + +在某些 Linux 版本中(例如,从 Ubuntu 17.10 开始),登录页面开始使用虚拟控制台 1。因此,你需要按 CTRL+ALT+F3 到 CTRL+ALT+F6 来访问虚拟控制台。要返回桌面环境,请在 Ubuntu 17.10 及更高版本上按下 CTRL+ALT+F2 或 CTRL+ALT+F7。 + +目前为止我们看到我们可以使用 CTRL+ALT+功能键(F1-F7)在 TTY 之间轻松切换。但是,如果出于任何原因你不想使用功能键,那么在 Linux 中有一个名为 **“chvt”** 的简单命令。 + +“chvt N” 命令让你切换到前台终端 N,这与按 CTRL+ALT+Fn 相同。如果它不存在,则创建相应的屏幕。 + +让我们试试打印当前的 tty: +``` +$ tty + +``` + +我的 Ubuntu 18.04 LTS 服务器的示例输出。 + +现在让我们切换到 tty2。为此,请输入: +``` +$ sudo chvt 2 + +``` + +记住你需要在 chvt 命令中使用 “sudo”。 + +现在,使用命令检查当前的 tty: +``` +$ tty + +``` + +你会看到 tty 现在已经改变了。 + +同样,你可以使用 “sudo chvt 3” 切换到 tty3,使用 “sudo chvt 4” 切换到 tty4 等等。 + +当任何一个功能键不起作用时,chvt 命令会很有用。 + +要查看活动虚拟控制台的总数,请运行: +``` +$ fgconsole +2 + +``` + +如你所见,我的系统中有两个活动的 VT。 + +你可以使用以下命令查看下一个未分配的虚拟终端: +``` +$ fgconsole --next-available +3 + +``` + +如果虚拟控制台不是前台控制台,并且它没有打开任何进程来读取或写入,并且未在其屏幕上选择任何文本,则它是未使用的。 + +要移除未使用的 VT,只需键入: +``` +$ deallocvt + +``` + +上面的命令为所有未使用的虚拟控制台释放内核内存和数据结构。简单地说,此命令将释放连接到未使用的虚拟控制台的所有资源。 + +有关更多详细信息,请参阅相应命令的手册页。 +``` +$ man tty + +$ man chvt + +$ man fgconsole + +$ man deallocvt + +``` + +就是这些了。希望这很有用。还有更多的好东西。敬请关注! + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-switch-between-ttys-without-using-function-keys-in-linux/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://askubuntu.com/questions/481906/what-does-tty-stand-for From 99730a3d6484892973c5ab20c17d2bd9cf53f265 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 5 Sep 2018 09:02:14 +0800 Subject: [PATCH 065/455] translating --- sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md b/sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md index cac9c2aa3d..f0c0250a8f 100644 --- a/sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md +++ b/sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md @@ -1,3 +1,5 @@ +translating---geekpi + How to Update Firmware on Ubuntu 18.04 ====== Usually, the default software center in Ubuntu and other Linux handle the update of the firmware of your system. But if you encounter errors with it, you can use fwupd command line tool for updating the firmware of your system. From 26adb4ec6924a1a5783eee8ef6c2b38ea1568321 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 5 Sep 2018 11:48:54 +0800 Subject: [PATCH 066/455] PRF:20180813 MPV Player- A Minimalist Video Player for Linux.md @zpl1025 --- ...er- A Minimalist Video Player for Linux.md | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/translated/tech/20180813 MPV Player- A Minimalist Video Player for Linux.md b/translated/tech/20180813 MPV Player- A Minimalist Video Player for Linux.md index 699048139d..545753574a 100644 --- a/translated/tech/20180813 MPV Player- A Minimalist Video Player for Linux.md +++ b/translated/tech/20180813 MPV Player- A Minimalist Video Player for Linux.md @@ -1,17 +1,19 @@ MPV 播放器:Linux 下的极简视频播放器 ====== -MPV 是一个开源的,跨平台视频播放器,带有极简的 GUI 界面以及丰富的命令行控制。 + +> MPV 是一个开源的,跨平台视频播放器,带有极简的 GUI 界面以及丰富的命令行控制。 VLC 可能是 Linux 或者其他平台下最好的视频播放器。我已经使用 VLC 很多年了,它现在仍是我最喜欢的播放器。 不过最近,我倾向于使用简洁界面的极简应用。这也是我偶然发现 MPV 的原因。我太喜欢这个软件,并把它加入了 [Ubuntu 最佳应用][1]列表里。 -[MPV][2] 是一个开源的视频播放器,有 Linux,Windows,MacOS,BSD 以及 Android 等平台下的版本。它实际上是从 [MPlayer][3] 分支出来的。 +[MPV][2] 是一个开源的视频播放器,有 Linux、Windows、MacOS、BSD 以及 Android 等平台下的版本。它实际上是从 [MPlayer][3] 分支出来的。 它的图形界面只有必须的元素而且非常整洁。 ![MPV 播放器在 Linux 下的界面][4] -MPV 播放器 + +*MPV 播放器* ### MPV 的功能 @@ -24,20 +26,18 @@ MPV 有标准播放器该有的所有功能。你可以播放各种视频,以 * 可以通过命令行播放 YouTube 等流媒体视频。 * 命令行模式的 MPV 可以嵌入到网页或其他应用中。 - - 尽管 MPV 播放器只有极简的界面以及有限的选项,但请不要怀疑它的功能。它主要的能力都来自命令行版本。 -只需要输入命令 mpv --list-options,然后你会看到它所提供的 447 个不同的选项。但是本文不会介绍 MPV 的高级应用。让我们看看作为一个普通的桌面视频播放器,它能有多么优秀。 +只需要输入命令 `mpv --list-options`,然后你会看到它所提供的 447 个不同的选项。但是本文不会介绍 MPV 的高级应用。让我们看看作为一个普通的桌面视频播放器,它能有多么优秀。 ### 在 Linux 上安装 MPV MPV 是一个常用应用,加入了大多数 Linux 发行版默认仓库里。在软件中心里搜索一下就可以了。 我可以确认在 Ubuntu 的软件中心里能找到。你可以在里面选择安装,或者通过下面的命令安装: + ``` sudo apt install mpv - ``` 你可以在 [MPV 网站][5]上查看其他平台的安装指引。 @@ -47,13 +47,14 @@ sudo apt install mpv 在安装完成以后,你可以通过鼠标右键点击视频文件,然后在列表里选择 MPV 来播放。 ![MPV 播放器界面][6] -MPV 播放器界面 + +*MPV 播放器界面* 整个界面只有一个控制面板,只有在鼠标移动到播放窗口上才会显示出来。控制面板上有播放/暂停,选择视频轨道,切换音轨,字幕以及全屏等选项。 MPV 的默认大小取决于你所播放视频的画质。比如一个 240p 的视频,播放窗口会比较小,而在全高清显示器上播放 1080p 视频时,会几乎占满整个屏幕。不管视频大小,你总是可以在播放窗口上双击鼠标切换成全屏。 -#### The subtitle struggle +#### 字幕 如果你的视频带有字幕,MPV 会[自动加载字幕][7],你也可以选择关闭。不过,如果你想使用其他外挂字幕文件,不能直接在播放器界面上操作。 @@ -66,17 +67,18 @@ MPV 的默认大小取决于你所播放视频的画质。比如一个 240p 的 要播放在线视频,你只能使用命令行模式的 MPV。 打开终端窗口,然后用类似下面的方式来播放: + ``` mpv - ``` ![在 Linux 桌面上使用 MPV 播放 YouTube 视频][8] -在 Linux 桌面上使用 MPV 播放 YouTube 视频 + +*在 Linux 桌面上使用 MPV 播放 YouTube 视频* 用 MPV 播放 YouTube 视频的体验不怎么好。它总是在缓冲缓冲,有点烦。 -#### 是否需要安装 MPV 播放器? +### 是否安装 MPV 播放器? 这个看你自己。如果你想体验各种应用,大可以试试 MPV。否则,默认的视频播放器或者 VLC 就足够了。 @@ -95,7 +97,7 @@ via: https://itsfoss.com/mpv-video-player/ 作者:[Abhishek Prakash][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[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 f557f6d58f2a5739f20f5bfbd40395cd72b44d59 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 5 Sep 2018 11:50:26 +0800 Subject: [PATCH 067/455] PUB:20180813 MPV Player- A Minimalist Video Player for Linux.md @zpl1025 https://linux.cn/article-9980-1.html --- .../20180813 MPV Player- A Minimalist Video Player for Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180813 MPV Player- A Minimalist Video Player for Linux.md (100%) diff --git a/translated/tech/20180813 MPV Player- A Minimalist Video Player for Linux.md b/published/20180813 MPV Player- A Minimalist Video Player for Linux.md similarity index 100% rename from translated/tech/20180813 MPV Player- A Minimalist Video Player for Linux.md rename to published/20180813 MPV Player- A Minimalist Video Player for Linux.md From c873bbbca46663be5f94bbef05cf7e2975d02245 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 5 Sep 2018 12:49:37 +0800 Subject: [PATCH 068/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20blockchain?= =?UTF-8?q?=20can=20complement=20open=20source?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...w blockchain can complement open source.md | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 sources/talk/20180904 How blockchain can complement open source.md diff --git a/sources/talk/20180904 How blockchain can complement open source.md b/sources/talk/20180904 How blockchain can complement open source.md new file mode 100644 index 0000000000..7712539f3f --- /dev/null +++ b/sources/talk/20180904 How blockchain can complement open source.md @@ -0,0 +1,95 @@ +How blockchain can complement open source +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/block-quilt-chain.png?itok=mECoDbrc) + +[The Cathedral and The Bazaar][1] is a classic open source story, written 20 years ago by Eric Steven Raymond. In the story, Eric describes a new revolutionary software development model where complex software projects are built without (or with a very little) central management. This new model is open source. + +Eric's story compares two models: + + * The classic model (represented by the cathedral), in which software is crafted by a small group of individuals in a closed and controlled environment through slow and stable releases. + * And the new model (represented by the bazaar), in which software is crafted in an open environment where individuals can participate freely but still produce a stable and coherent system. + + + +Some of the reasons open source is so successful can be traced back to the founding principles Eric describes. Releasing early, releasing often, and accepting the fact that many heads are inevitably better than one allows open source projects to tap into the world’s pool of talent (and few companies can match that using the closed source model). + +Two decades after Eric's reflective analysis of the hacker community, we see open source becoming dominant. It is no longer a model only for scratching a developer’s personal itch, but instead, the place where innovation happens. Even the world's [largest][2] software companies are transitioning to this model in order to continue dominating. + +### A barter system + +If we look closely at how the open source model works in practice, we realize that it is a closed system, exclusive only to open source developers and techies. The only way to influence the direction of a project is by joining the open source community, understanding the written and the unwritten rules, learning how to contribute, the coding standards, etc., and doing it yourself. + +This is how the bazaar works, and it is where the barter system analogy comes from. A barter system is a method of exchanging services and goods in return for other services and goods. In the bazaar—where the software is built—that means in order to take something, you must also be a producer yourself and give something back in return. And that is by exchanging your time and knowledge for getting something done. A bazaar is a place where open source developers interact with other open source developers and produce open source software the open source way. + +The barter system is a great step forward and an evolution from the state of self-sufficiency where everybody must be a jack of all trades. The bazaar (open source model) using the barter system allows people with common interests and different skills to gather, collaborate, and create something that no individual can create on their own. The barter system is simple and lacks complex problems of the modern monetary systems, but it also has some limitations, such as: + + * Lack of divisibility: In the absence of a common medium of exchange, a large indivisible commodity/value cannot be exchanged for a smaller commodity/value. For example, if you want to do even a small change in an open source project, you may sometimes still need to go through a high entry barrier. + * Storing value: If a project is important to your company, you may want to have a large investment/commitment in it. But since it is a barter system among open source developers, the only way to have a strong say is by employing many open source committers, and that is not always possible. + * Transferring value: If you have invested in a project (trained employees, hired open source developers) and want to move focus to another project, it is not possible to transfer expertise, reputation, and influence quickly. + * Temporal decoupling: The barter system does not provide a good mechanism for deferred or advance commitments. In the open source world, that means a user cannot express commitment or interest in a project in a measurable way in advance, or continuously for future periods. + + + +Below, we will explore how to address these limitations using the back door to the bazaar. + +### A currency system + +People are hanging at the bazaar for different reasons: Some are there to learn, some are there to scratch a personal developer's itch, and some work for large software farms. Because the only way to have a say in the bazaar is to become part of the open source community and join the barter system, in order to gain credibility in the open source world, many large software companies employ these developers and pay them in monetary value. This represents the use of a currency system to influence the bazaar. Open source is no longer only for scratching the personal developer itch. It also accounts for a significant part of the overall software production worldwide, and there are many who want to have an influence. + +Open source sets the guiding principles through which developers interact and build a coherent system in a distributed way. It dictates how a project is governed, how software is built, and how the output distributed to users. It is an open consensus model for decentralized entities for building quality software together. But the open source model does not cover how open source is subsidized. Whether it is sponsored, directly or indirectly, through intrinsic or extrinsic motivators is irrelevant to the bazaar. + +![](https://opensource.com/sites/default/files/uploads/tokenomics_-_page_4.png) + +Currently, there is no equivalent of the decentralized open source development model for subsidization purposes. The majority of open source subsidization is centralized, where typically one company dominates a project by employing the majority of the open source developers of that project. And to be honest, this is currently the best-case scenario, as it guarantees that the developers will be paid for a long period and the project will continue to flourish. + +There are also exceptions for the project monopoly scenario: For example, some Cloud Native Computing Foundation projects are developed by a large number of competing companies. Also, the Apache Software Foundation aims for their projects not to be dominated by a single vendor by encouraging diverse contributors, but most of the popular projects, in reality, are still single-vendor projects. + +What we are missing is an open and decentralized model that works like the bazaar without a central coordination and ownership, where consumers (open source users) and producers (open source developers) interact with each other, driven by market forces and open source value. In order to complement open source, such a model must also be open and decentralized, and this is why I think the blockchain technology would [fit best here][3]. + +Most of the existing blockchain (and non-blockchain) platforms that aim to subsidize open source development are targeting primarily bug bounties, small and piecemeal tasks. A few also focus on funding new open source projects. But not many aim to provide mechanisms for sustaining continued development of open source projects—basically, a system that would emulate the behavior of an open source service provider company, or open core, open source-based SaaS product company: ensuring developers get continued and predictable incentives and guiding the project development based on the priorities of the incentivizers; i.e., the users. Such a model would address the limitations of the barter system listed above: + + * Allow divisibility: If you want something small fixed, you can pay a small amount rather than the full premium of becoming an open source developer for a project. + * Storing value: You can invest a large amount into a project and ensure both its continued development and that your voice is heard. + * Transferring value: At any point, you can stop investing in the project and move funds into other projects. + * Temporal decoupling: Allow regular recurring payments and subscriptions. + + + +There would be also other benefits, purely from the fact that such a blockchain-based system is transparent and decentralized: to quantify a project’s value/usefulness based on its users’ commitment, open roadmap commitment, decentralized decision making, etc. + +### Conclusion + +On the one hand, we see large companies hiring open source developers and acquiring open source startups and even foundational platforms (such as Microsoft buying GitHub). Many, if not most, long-running successful open source projects are centralized around a single vendor. The significance of open source and its centralization is a fact. + +On the other hand, the challenges around [sustaining open source][4] software are becoming more apparent, and many are investigating this space and its foundational issues more deeply. There are a few projects with high visibility and a large number of contributors, but there are also many other still-important projects that lack enough contributors and maintainers. + +There are [many efforts][3] trying to address the challenges of open source through blockchain. These projects should improve the transparency, decentralization, and subsidization and establish a direct link between open source users and developers. This space is still very young, but it is progressing quickly, and with time, the bazaar is going to have a cryptocurrency system. + +Given enough time and adequate technology, decentralization is happening at many levels: + + * The internet is a decentralized medium that has unlocked the world’s potential for sharing and acquiring knowledge. + * Open source is a decentralized collaboration model that has unlocked the world’s potential for innovation. + * Similarly, blockchain can complement open source and become the decentralized open source subsidization model. + + + +Follow me on [Twitter][5] for other posts in this space. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/barter-currency-system + +作者:[Bilgin lbryam][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bibryam +[1]: http://catb.org/ +[2]: http://oss.cash/ +[3]: https://opensource.com/article/18/8/open-source-tokenomics +[4]: https://www.youtube.com/watch?v=VS6IpvTWwkQ +[5]: http://twitter.com/bibryam From 93194e1c504938e7f36dcb9bc937e78372b462aa Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 5 Sep 2018 12:53:11 +0800 Subject: [PATCH 069/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Why=20I=20love=20?= =?UTF-8?q?Xonsh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/tech/20180904 Why I love Xonsh.md | 130 ++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 sources/tech/20180904 Why I love Xonsh.md diff --git a/sources/tech/20180904 Why I love Xonsh.md b/sources/tech/20180904 Why I love Xonsh.md new file mode 100644 index 0000000000..0bc485ee8d --- /dev/null +++ b/sources/tech/20180904 Why I love Xonsh.md @@ -0,0 +1,130 @@ +Why I love Xonsh +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/shelloff.png?itok=L8pjHXjW) + +Shell languages are useful for interactive use. But this optimization often comes with trade-offs against using them as programming languages, which is sometimes felt when writing shell scripts. + +What if your shell also understood a more scalable programming language? Say, Python? + +Enter [Xonsh][1]. + +Installing Xonsh is as simple as creating a virtual environment, running `pip install xonsh[ptk,linux]`, and then running `xonsh`. + +At first, you might wonder why your Python shell has a weird prompt: +``` +$ 1+1 +2 +``` + +Nice calculator! +``` +$ print("hello world") +hello world +``` + +We can also call other functions: +``` +$ from antigravity import geohash +$ geohash(37.421542, -122.085589, b'2005-05-26-10458.68') +37.857713 -122.544543 +``` + +However, we can still use it like a regular shell: +``` +$ echo "hello world" +hello world +``` + +We can even mix and match! +``` +$ for i in range(3): +.     echo "hello world" +. +hello world +hello world +hello world +``` + +Xonsh supports completion for both shell commands and Python expressions by using the [Prompt Toolkit][2]. Completions are visually informative, showing possible completions and having in-band dropdown lists. + +It also supports environment access. It uses a simple but powerful heuristic for applying Python types to environment variables. The default is "string," but, for example, path variables are automatically lists. +``` +$ '/usr/bin' in $PATH +True +``` + +Xonsh accepts either shell-style or Python-style boolean shortcut operators: +``` +$ cat things +foo +$ grep -q foo things and echo "found" +found +$ grep -q bar things && echo "found" +$ grep -q foo things or echo "found" +$ grep -q bar things || echo "found" +found +``` + +This means that Python keywords are interpreted. If we want to print the title of a famous Dr. Seuss book, we need to quote the keywords. +``` +$ echo green eggs "and" ham +green eggs and ham +``` + +If we do not, we are in for a surprise: +``` +$ echo green eggs and ham +green eggs +xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True +xonsh: subprocess mode: command not found: ham +Did you mean one of the following? +    as:   Command (/usr/bin/as) +    ht:   Command (/usr/bin/ht) +    mag:  Command (/usr/bin/mag) +    ar:   Command (/usr/bin/ar) +    nm:   Command (/usr/bin/nm) +``` + +Virtual environments can get a little tricky. Regular virtual environments, depending as they do on Bash-like syntax, cannot work. However, Xonsh comes with its own virtual environment management system called `vox`. + +`vox` can create, activate and deactivate environments in `~/.virtualenvs`; if you've used `virtualenvwrapper`, this is where the environments were. + +Note that the current activated environment doesn't affect `x``onsh`. It can't import anything from an activated environment. +``` +$ xontrib load vox +$ vox create my-environment                                                     +... +$ vox activate my-environment         +Activated "my-environment".                                                     +$ pip install money                                                             +... +$ python                                                               +... +>>> import money                                                               +>>> money.Money('3.14')                         +$ import money +xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True +ModuleNotFoundError: No module named 'money' +``` + +The first line enables `vox`: it is a `xontrib`, a third-party extension for Xonsh. The `xontrib` manager can list all possible `xontribs` and their current state (installed, loaded, or neither). + +It's possible to write a `xontrib` and just upload it to `PyPi` to make it available. However, it's good practice to add it to the `xontrib` index so Xonsh knows about it in advance. This allows, for example, the configuration wizard to suggest it. + +If you've ever wondered, "can Python be my shell?" then you are only a `pip install xonsh` away from finding out. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/xonsh-bash-alternative + +作者:[Moshe Zadka][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[1]: https://xon.sh/ +[2]: https://python-prompt-toolkit.readthedocs.io/en/master/ From 74195575dd74185d480a8cc1d6a83f33c5cfe17c Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 5 Sep 2018 12:57:49 +0800 Subject: [PATCH 070/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Why=20schools=20o?= =?UTF-8?q?f=20the=20future=20are=20open?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0904 Why schools of the future are open.md | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 sources/talk/20180904 Why schools of the future are open.md diff --git a/sources/talk/20180904 Why schools of the future are open.md b/sources/talk/20180904 Why schools of the future are open.md new file mode 100644 index 0000000000..32b2f58e99 --- /dev/null +++ b/sources/talk/20180904 Why schools of the future are open.md @@ -0,0 +1,48 @@ +Why schools of the future are open +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_OSDC_BYU_520x292_FINAL.png?itok=NVY7vR8o) + +Someone recently asked me what education will look like in the modern era. My response: Much like it has for the last 100 years. How's that for a pessimistic view of our education system? + +It's not a pessimistic view as much as it is a pragmatic one. Anyone who spends time in schools could walk away feeling similarly, given that the ways we teach young people are stubbornly resistant to change. As schools in the United States begin a new year, most students are returning to classrooms where desks are lined-up in rows, the instructional environment is primarily teacher-centred, progress is measured by Carnegie units and A-F grading, and collaboration is often considered cheating. + +Were we able to point to evidence that this industrialized model was producing the kind of results that are required, where every child is given the personal attention needed to grow a love of learning and develop the skills needed to thrive in today's innovation economy, then we could very well be satisfied with the status quo. But any honest and objective look at current metrics speaks to the need for fundamental change. + +But my view isn't a pessimistic one. In fact, it's quite optimistic. + +For as easy as it is to dwell on what's wrong with our current education model, I also know of example after example of where education stakeholders are willing to step out of what's comfortable and challenge this system that is so immune to change. Teachers are demanding more collaboration with peers and more ways to be open and transparent about prototyping ideas that lead to true innovation for students—not just repackaging of traditional methods with technology. Administrators are enabling deeper, more connected learning to real-world applications through community-focused, project-based learning—not just jumping through hoops of "doing projects" in isolated classrooms. And parents are demanding that the joy and wonder of learning return to the culture of their schools that have been corrupted by an emphasis on test prep. + +These and other types of cultural changes are never easy, especially in an environment so reluctant to take risks in the face of political backlash from any dip in test scores (regardless of statistical significance). So why am I optimistic that we are approaching a tipping point where the type of changes we desperately need can indeed overcome the inertia that has thwarted them for too long? + +Because there is something else in water at this point in our modern era that was not present before: an ethos of openness, catalyzed by digital technology. + +Think for a moment: If you need to learn how to speak basic French for an upcoming trip to France, where do you turn? You could sign up for a course at a local community college or check out a book from the library, but in all likelihood, you'll access a free online video and learn the basics you will need for your trip. Never before in human history has free, on-demand learning been so accessible. In fact, one can sign up right now for a free, online course from MIT on "[Special Topics in Mathematics with Applications: Linear Algebra and the Calculus of Variations][1]." Sign me up! + +Why do schools such as MIT, Stanford, and Harvard offer free access to their courses? Why are people and corporations willing to openly share what was once tightly controlled intellectual property? Why are people all over the planet willing to invest their time—for no pay—to help with citizen science projects? + +There is something else in water at this point in our modern era that was not present before: an ethos of openness, catalyzed by digital technology. + +In his wonderful book [Open: How We'll Work Live and Learn in the Future][2], author David Price clearly describes how informal, social learning is becoming the new norm of learning, especially among young people accustomed to being able to get the "just in time" knowledge they need. Through a series of case studies, Price paints a clear picture of what happens when traditional institutions don't adapt to this new reality and thus become less and less relevant. That's the missing ingredient that has the crowdsourced power of creating positive disruption. + +What Price points out (and what people are now demanding at a grassroots level) is nothing short of an open movement, one recognizing that open collaboration and free exchange of ideas have already disrupted ecosystems from music to software to publishing. And more than any top-down driven "reform," this expectation for openness has the potential to fundamentally alter an educational system that has resisted change for too long. In fact, one of the hallmarks of the open ethos is that it expects the transparent and fair democratization of knowledge for the benefit of all. So what better ecosystem for such an ethos to thrive than within the one that seeks to prepare young people to inherit the world and make it better? + +Sure, the pessimist in me says that my earlier prediction about the future of education may indeed be the state of education in the short term future. But I am also very optimistic that this prediction will be proven to be dead wrong. I know that I and many other kindred-spirit educators are working every day to ensure that it's wrong. Won't you join me as we start a movement to help our schools [transform into open organizations][3]—to transition from from an outdated, legacy model to one that is more open, nimble, and responsive to the needs of every student and the communities in which they serve? + +That's a true education model appropriate for the modern era. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/18/9/modern-education-open-education + +作者:[Ben Owens][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/engineerteacher +[1]: https://ocw.mit.edu/courses/mechanical-engineering/2-035-special-topics-in-mathematics-with-applications-linear-algebra-and-the-calculus-of-variations-spring-2007/ +[2]: https://www.goodreads.com/book/show/18730272-open +[3]: https://opensource.com/open-organization/resources/open-org-definition From 839cb0e2a9116084ec6943399ef051781cee41e9 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 5 Sep 2018 16:43:44 +0800 Subject: [PATCH 071/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20CLI:=20improved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/tech/20180823 CLI- improved.md | 297 +++++++++++++++++++++++++ 1 file changed, 297 insertions(+) create mode 100644 sources/tech/20180823 CLI- improved.md diff --git a/sources/tech/20180823 CLI- improved.md b/sources/tech/20180823 CLI- improved.md new file mode 100644 index 0000000000..d06bb1b2aa --- /dev/null +++ b/sources/tech/20180823 CLI- improved.md @@ -0,0 +1,297 @@ +CLI: improved +====== +I'm not sure many web developers can get away without visiting the command line. As for me, I've been using the command line since 1997, first at university when I felt both super cool l33t-hacker and simultaneously utterly out of my depth. + +Over the years my command line habits have improved and I often search for smarter tools for the jobs I commonly do. With that said, here's my current list of improved CLI tools. + + +### Ignoring my improvements + +In a number of cases I've aliased the new and improved command line tool over the original (as with `cat` and `ping`). + +If I want to run the original command, which is sometimes I do need to do, then there's two ways I can do this (I'm on a Mac so your mileage may vary): +``` +$ \cat # ignore aliases named "cat" - explanation: https://stackoverflow.com/a/16506263/22617 +$ command cat # ignore functions and aliases + +``` + +### bat > cat + +`cat` is used to print the contents of a file, but given more time spent in the command line, features like syntax highlighting come in very handy. I found [ccat][3] which offers highlighting then I found [bat][4] which has highlighting, paging, line numbers and git integration. + +The `bat` command also allows me to search during output (only if the output is longer than the screen height) using the `/` key binding (similarly to `less` searching). + +![Simple bat output][5] + +I've also aliased `bat` to the `cat` command: +``` +alias cat='bat' + +``` + +💾 [Installation directions][4] + +### prettyping > ping + +`ping` is incredibly useful, and probably my goto tool for the "oh crap is X down/does my internet work!!!". But `prettyping` ("pretty ping" not "pre typing"!) gives ping a really nice output and just makes me feel like the command line is a bit more welcoming. + +![/images/cli-improved/ping.gif][6] + +I've also aliased `ping` to the `prettyping` command: +``` +alias ping='prettyping --nolegend' + +``` + +💾 [Installation directions][7] + +### fzf > ctrl+r + +In the terminal, using `ctrl+r` will allow you to [search backwards][8] through your history. It's a nice trick, albeit a bit fiddly. + +The `fzf` tool is a **huge** enhancement on `ctrl+r`. It's a fuzzy search against the terminal history, with a fully interactive preview of the possible matches. + +In addition to searching through the history, `fzf` can also preview and open files, which is what I've done in the video below: + +For this preview effect, I created an alias called `preview` which combines `fzf` with `bat` for the preview and a custom key binding to open VS Code: +``` +alias preview="fzf --preview 'bat --color \"always\" {}'" +# add support for ctrl+o to open selected file in VS Code +export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort'" + +``` + +💾 [Installation directions][9] + +### htop > top + +`top` is my goto tool for quickly diagnosing why the CPU on the machine is running hard or my fan is whirring. I also use these tools in production. Annoyingly (to me!) `top` on the Mac is vastly different (and inferior IMHO) to `top` on linux. + +However, `htop` is an improvement on both regular `top` and crappy-mac `top`. Lots of colour coding, keyboard bindings and different views which have helped me in the past to understand which processes belong to which. + +Handy key bindings include: + + * P - sort by CPU + * M - sort by memory usage + * F4 - filter processes by string (to narrow to just "node" for instance) + * space - mark a single process so I can watch if the process is spiking + + + +![htop output][10] + +There is a weird bug in Mac Sierra that can be overcome by running `htop` as root (I can't remember exactly what the bug is, but this alias fixes it - though annoying that I have to enter my password every now and again): +``` +alias top="sudo htop" # alias top and fix high sierra bug + +``` + +💾 [Installation directions][11] + +### diff-so-fancy > diff + +I'm pretty sure I picked this one up from Paul Irish some years ago. Although I rarely fire up `diff` manually, my git commands use diff all the time. `diff-so-fancy` gives me both colour coding but also character highlight of changes. + +![diff so fancy][12] + +Then in my `~/.gitconfig` I have included the following entry to enable `diff-so-fancy` on `git diff` and `git show`: +``` +[pager] + diff = diff-so-fancy | less --tabs=1,5 -RFX + show = diff-so-fancy | less --tabs=1,5 -RFX + +``` + +💾 [Installation directions][13] + +### fd > find + +Although I use a Mac, I've never been a fan of Spotlight (I found it sluggish, hard to remember the keywords, the database update would hammer my CPU and generally useless!). I use [Alfred][14] a lot, but even the finder feature doesn't serve me well. + +I tend to turn the command line to find files, but `find` is always a bit of a pain to remember the right expression to find what I want (and indeed the Mac flavour is slightly different non-mac find which adds to frustration). + +`fd` is a great replacement (by the same individual who wrote `bat`). It is very fast and the common use cases I need to search with are simple to remember. + +A few handy commands: +``` +$ fd cli # all filenames containing "cli" +$ fd -e md # all with .md extension +$ fd cli -x wc -w # find "cli" and run `wc -w` on each file + +``` + +![fd output][15] + +💾 [Installation directions][16] + +### ncdu > du + +Knowing where disk space is being taking up is a fairly important task for me. I've used the Mac app [Disk Daisy][17] but I find that it can be a little slow to actually yield results. + +The `du -sh` command is what I'll use in the terminal (`-sh` means summary and human readable), but often I'll want to dig into the directories taking up the space. + +`ncdu` is a nice alternative. It offers an interactive interface and allows for quickly scanning which folders or files are responsible for taking up space and it's very quick to navigate. (Though any time I want to scan my entire home directory, it's going to take a long time, regardless of the tool - my directory is about 550gb). + +Once I've found a directory I want to manage (to delete, move or compress files), I'll use the cmd + click the pathname at the top of the screen in [iTerm2][18] to launch finder to that directory. + +![ncdu output][19] + +There's another [alternative called nnn][20] which offers a slightly nicer interface and although it does file sizes and usage by default, it's actually a fully fledged file manager. + +My `ncdu` is aliased to the following: +``` +alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules" + +``` + +The options are: + + * `--color dark` \- use a colour scheme + * `-rr` \- read-only mode (prevents delete and spawn shell) + * `--exclude` ignore directories I won't do anything about + + + +💾 [Installation directions][21] + +### tldr > man + +It's amazing that nearly every single command line tool comes with a manual via `man `, but navigating the `man` output can be sometimes a little confusing, plus it can be daunting given all the technical information that's included in the manual output. + +This is where the TL;DR project comes in. It's a community driven documentation system that's available from the command line. So far in my own usage, I've not come across a command that's not been documented, but you can [also contribute too][22]. + +![TLDR output for 'fd'][23] + +As a nicety, I've also aliased `tldr` to `help` (since it's quicker to type!): +``` +alias help='tldr' + +``` + +💾 [Installation directions][24] + +### ack || ag > grep + +`grep` is no doubt a powerful tool on the command line, but over the years it's been superseded by a number of tools. Two of which are `ack` and `ag`. + +I personally flitter between `ack` and `ag` without really remembering which I prefer (that's to say they're both very good and very similar!). I tend to default to `ack` only because it rolls of my fingers a little easier. Plus, `ack` comes with the mega `ack --bar` argument (I'll let you experiment)! + +Both `ack` and `ag` will (by default) use a regular expression to search, and extremely pertinent to my work, I can specify the file types to search within using flags like `--js` or `--html` (though here `ag` includes more files in the js filter than `ack`). + +Both tools also support the usual `grep` options, like `-B` and `-A` for before and after context in the grep. + +![ack in action][25] + +Since `ack` doesn't come with markdown support (and I write a lot in markdown), I've got this customisation in my `~/.ackrc` file: +``` +--type-set=md=.md,.mkd,.markdown +--pager=less -FRX + +``` + +💾 Installation directions: [ack][26], [ag][27] + +[Futher reading on ack & ag][28] + +### jq > grep et al + +I'm a massive fanboy of [jq][29]. At first I struggled with the syntax, but I've since come around to the query language and use `jq` on a near daily basis (whereas before I'd either drop into node, use grep or use a tool called [json][30] which is very basic in comparison). + +I've even started the process of writing a jq tutorial series (2,500 words and counting) and have published a [web tool][31] and a native mac app (yet to be released). + +`jq` allows me to pass in JSON and transform the source very easily so that the JSON result fits my requirements. One such example allows me to update all my node dependencies in one command (broken into multiple lines for readability): +``` +$ npm i $(echo $(\ + npm outdated --json | \ + jq -r 'to_entries | .[] | "\(.key)@\(.value.latest)"' \ +)) + +``` + +The above command will list all the node dependencies that are out of date, and use npm's JSON output format, then transform the source JSON from this: +``` +{ + "node-jq": { + "current": "0.7.0", + "wanted": "0.7.0", + "latest": "1.2.0", + "location": "node_modules/node-jq" + }, + "uuid": { + "current": "3.1.0", + "wanted": "3.2.1", + "latest": "3.2.1", + "location": "node_modules/uuid" + } +} + +``` + +…to this: + +That result is then fed into the `npm install` command and voilà, I'm all upgraded (using the sledgehammer approach). + +### Honourable mentions + +Some of the other tools that I've started poking around with, but haven't used too often (with the exception of ponysay, which appears when I start a new terminal session!): + + * [ponysay][32] > cowsay + * [csvkit][33] > awk et al + * [noti][34] > `display notification` + * [entr][35] > watch + + + +### What about you? + +So that's my list. How about you? What daily command line tools have you improved? I'd love to know. + + +-------------------------------------------------------------------------------- + +via: https://remysharp.com/2018/08/23/cli-improved + +作者:[Remy Sharp][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://remysharp.com +[1]: https://remysharp.com/images/terminal-600.jpg +[2]: https://training.leftlogic.com/buy/terminal/cli2?coupon=READERS-DISCOUNT&utm_source=blog&utm_medium=banner&utm_campaign=remysharp-discount +[3]: https://github.com/jingweno/ccat +[4]: https://github.com/sharkdp/bat +[5]: https://remysharp.com/images/cli-improved/bat.gif (Sample bat output) +[6]: https://remysharp.com/images/cli-improved/ping.gif (Sample ping output) +[7]: http://denilson.sa.nom.br/prettyping/ +[8]: https://lifehacker.com/278888/ctrl%252Br-to-search-and-other-terminal-history-tricks +[9]: https://github.com/junegunn/fzf +[10]: https://remysharp.com/images/cli-improved/htop.jpg (Sample htop output) +[11]: http://hisham.hm/htop/ +[12]: https://remysharp.com/images/cli-improved/diff-so-fancy.jpg (Sample diff output) +[13]: https://github.com/so-fancy/diff-so-fancy +[14]: https://www.alfredapp.com/ +[15]: https://remysharp.com/images/cli-improved/fd.png (Sample fd output) +[16]: https://github.com/sharkdp/fd/ +[17]: https://daisydiskapp.com/ +[18]: https://www.iterm2.com/ +[19]: https://remysharp.com/images/cli-improved/ncdu.png (Sample ncdu output) +[20]: https://github.com/jarun/nnn +[21]: https://dev.yorhel.nl/ncdu +[22]: https://github.com/tldr-pages/tldr#contributing +[23]: https://remysharp.com/images/cli-improved/tldr.png (Sample tldr output for 'fd') +[24]: http://tldr-pages.github.io/ +[25]: https://remysharp.com/images/cli-improved/ack.png (Sample ack output with grep args) +[26]: https://beyondgrep.com +[27]: https://github.com/ggreer/the_silver_searcher +[28]: http://conqueringthecommandline.com/book/ack_ag +[29]: https://stedolan.github.io/jq +[30]: http://trentm.com/json/ +[31]: https://jqterm.com +[32]: https://github.com/erkin/ponysay +[33]: https://csvkit.readthedocs.io/en/1.0.3/ +[34]: https://github.com/variadico/noti +[35]: http://www.entrproject.org/ From 0e0bb0c3acc83c9fa111ef8f51e1a5bcc86048db Mon Sep 17 00:00:00 2001 From: distant1219 Date: Wed, 5 Sep 2018 17:53:06 +0800 Subject: [PATCH 072/455] Create 20180720 An Introduction to Using Git.md finished trans --- .../20180720 An Introduction to Using Git.md | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 translated/tech/20180720 An Introduction to Using Git.md diff --git a/translated/tech/20180720 An Introduction to Using Git.md b/translated/tech/20180720 An Introduction to Using Git.md new file mode 100644 index 0000000000..de03252886 --- /dev/null +++ b/translated/tech/20180720 An Introduction to Using Git.md @@ -0,0 +1,173 @@ +Git 使用简介 +====== +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/developer-3461405_1920.png?itok=6H3sYe80) + +如果你是一个开发者,那你应该熟悉许多开发工具。你已经花了多年时间来学习一种或者多种编程语言并完善你的技巧。你可以熟练运用图形工具或者命令行工具开发。在你看来,没有任何事可以阻挡你。你的代码, 好像你的思想和你的手指一样,将会创建一个优雅的,完美评价的应用程序,并会风靡世界。 + +然而,如果你和其他人共同开发一个项目会发生什么呢?或者,你开发的应用程序变地越来越大,下一步你将如何去做?如果你想成功地和其他开发者合作,你定会想用一个分布式版本控制系统。使用这样一个系统,合作开发一个项目变得非常高效和可靠。这样的一个系统便是 [Git][1]。还有一个叫 [GitHub][2] 的方便的存储仓库,来存储你的项目代码,这样你的团队可以检查和修改代码。 + +我将向你介绍让 Git 的启动、运行,并和 GitHub 一起使用的基础知识,可以让你的应用程序的开发可以提升到一个新的水平。 我将在 Ubuntu 18.04 上进行演示,因此如果您选择的发行版本不同,您只需要修改 Git 安装命令以适合你的发行版的软件包管理器。 +### Git 和 GitHub + +第一件事就是创建一个免费的 GitHub 账号,打开 [GitHub 注册页面][3],然后填上需要的信息。完成这个之后,你就注备好开始安装 Git 了(这两件事谁先谁后都可以)。 + +安装 Git 非常简单,打开一个命令行终端,并输入命令: +``` +sudo apt install git-all + +``` +这将会安装大量依赖包,但是你将了解使用 Git 和 GitHub 所需的一切。 + +注意:我使用 Git 来下载程序的安装源码。有许多时候,内置的软件管理器不提供某个软件,除了去第三方库中下载源码,我经常去这个软件项目的 Git 主页,像这样克隆: +``` +git clone ADDRESS + +``` +ADDRESS就是那个软件项目的 Git 主页。这样我就可以确保自己安装那个软件的最新发行版了。 + +创建一个本地仓库并添加一个文件。 +下一步就是在你的电脑里创建一个本地仓库(本文称之为newproject,位于~/目录下),打开一个命令行终端,并输入下面的命令: +``` +cd ~/ + +mkdir newproject + +cd newproject + +``` + +现在你需要初始化这个仓库。在 ~/newproject 目录下,输入命令 git init,当命令运行完,你就可以看到一个刚刚创建的空的 Git 仓库了(图1)。 + +![new repository][5] + +图 1:初始化完成的新仓库 + +[使用许可][6] + +下一步就是往项目里添加文件。我们在项目根目录(~/newproject)输入下面的命令: + +``` +touch readme.txt + +``` + +现在项目里多了个空文件。输入 git status 来验证 Git 已经检测到多了个新文件(图2)。 + +![readme][8] + +图 2: Git 检测到新文件readme.txt + +[使用许可][6] + +即使 Git 检测到新的文件,但它并没有被真正的加入这个项目仓库。为此,你要输入下面的命令: + +``` +git add readme.txt + +``` + +一旦完成这个命令,再输入 git status 命令,可以看到,readme.txt 已经是这个项目里的新文件了(图3)。 +![file added][10] + +图 3: 我们的文件已经被添加进临时环境 + +[使用许可][6] +### 第一次提交 +当新文件添加进临时环境之后,我们现在就准备好第一次提交了。什么是提交呢?它是很简单的,一次提交就是记录你更改的项目的文件。创建一次提交也是非常简单的。但是,为提交创建一个描述信息非常重要。通过这样做,你将添加有关提交包含的内容的注释,比如你对文件做出的修改。然而,在这样做之前,我们需要确认我们的 Git 账户,输入以下命令: +``` +git config --global user.email EMAIL + +git config --global user.name “FULL NAME” + +``` +EMAIL 即你的 email 地址,FULL NAME 则是你的姓名。现在你可以通过以下命令创建一个提交: +``` +git commit -m “Descriptive Message” + +``` +Descriptive Message 即为你的提交的描述性信息。比如,当你第一次提交是提交一个 readme.txt 文件,你可以这样提交: +``` +git commit -m “First draft of readme.txt file” + +``` + +你可以看到输出显示一个文件已经修改,并且,为 readnme.txt 创建了一个新模式(图4) + +![success][12] + +图4:提交成功 + +[使用许可][6] +### 创建分支并推送至GitHub +分支是很重要的,它允许你从项目状态间中移动。假如,你想给你的应用创建一个新的特性。为了这样做,你创建了个新分支。一旦你完成你的新特性,你可以把这个新分支合并到你的主分支中去,使用以下命令创建一个新分支: +``` +git checkout -b BRANCH + +``` +BRANCH 即为你新分支的名字,一旦执行完命令,输入 git branch 命令来查看是否创建了新分支(图5) + +![featureX][14] + +图5:名为 featureX 的新分支 + +[使用许可][6] + +接下来,我们需要在GitHub上创建一个仓库。 登录GitHub帐户,请单击帐户主页上的“新建仓库”按钮。 填写必要的信息,然后单击Create repository(图6)。 + +![new repository][16] + +图6:在 GitHub 上新建一个仓库 + +[使用许可][6] + +在创建完一个仓库之后,你可以看到一个用于推送本地仓库的地址。若要推送,返回命令行窗口( ~/newproject 目录中),输入以下命令: +``` +git remote add origin URL + +git push -u origin master + +``` +URL 即为我们 GitHub 上新建的仓库地址。 + +系统会提示您,输入 GitHub 的用户名和密码,一旦授权成功,你的项目将会被推送到 GitHub 仓库中。 + +### 拉取项目 + +如果你的同事改变了你们 GitHub 上项目的代码,并且已经合并那些更改,你可以拉取那些项目文件到你的本地机器,这样,你系统中的文件就可以和远程用户的文件保持匹配。你可以输入以下命令来做这件事( ~/newproject 在目录中), +``` +git pull origin master + +``` + +以上的命令可以拉取任何新文件或修改过的文件到你的本地仓库。 +### 基础 + +这就是从命令行使用 Git 来处理存储在 GitHub 上的项目的基础知识。 还有很多东西需要学习,所以我强烈建议你使用 man git,man git-push 和 man git-pull 命令来更深入地了解 git 命令可以做什么。 + +开发快乐! + +了解更多关于 Linux的 内容,请访问来自 Linux 基金会和 edX 的免费的 ["Introduction to Linux" ][17]课程。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/7/introduction-using-git + +作者:[Jack Wallen][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[distant1219](https://github.com/distant1219) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/jlwallen +[1]:https://git-scm.com/ +[2]:https://github.com/ +[3]:https://github.com/join?source=header-home +[5]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_1.jpg?itok=FKkr5Mrk (new repository) +[6]:https://www.linux.com/licenses/category/used-permission +[8]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_2.jpg?itok=54G9KBHS (readme) +[10]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_3.jpg?itok=KAJwRJIB (file added) +[12]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_4.jpg?itok=qR0ighDz (success) +[14]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_5.jpg?itok=6m9RTWg6 (featureX) +[16]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_6.jpg?itok=d2toRrUq (new repository) +[17]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 1dbc8a38d8a1ca14c2921ece0f522b62b07f2113 Mon Sep 17 00:00:00 2001 From: distant1219 Date: Wed, 5 Sep 2018 17:53:43 +0800 Subject: [PATCH 073/455] Delete 20180720 An Introduction to Using Git.md --- .../20180720 An Introduction to Using Git.md | 193 ------------------ 1 file changed, 193 deletions(-) delete mode 100644 sources/tech/20180720 An Introduction to Using Git.md diff --git a/sources/tech/20180720 An Introduction to Using Git.md b/sources/tech/20180720 An Introduction to Using Git.md deleted file mode 100644 index 2a91406721..0000000000 --- a/sources/tech/20180720 An Introduction to Using Git.md +++ /dev/null @@ -1,193 +0,0 @@ -translating by distant1219 - -An Introduction to Using Git -====== -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/developer-3461405_1920.png?itok=6H3sYe80) -If you’re a developer, then you know your way around development tools. You’ve spent years studying one or more programming languages and have perfected your skills. You can develop with GUI tools or from the command line. On your own, nothing can stop you. You code as if your mind and your fingers are one to create elegant, perfectly commented, source for an app you know will take the world by storm. - -But what happens when you’re tasked with collaborating on a project? Or what about when that app you’ve developed becomes bigger than just you? What’s the next step? If you want to successfully collaborate with other developers, you’ll want to make use of a distributed version control system. With such a system, collaborating on a project becomes incredibly efficient and reliable. One such system is [Git][1]. Along with Git comes a handy repository called [GitHub][2], where you can house your projects, such that a team can check out and check in code. - -I will walk you through the very basics of getting Git up and running and using it with GitHub, so the development on your game-changing app can be taken to the next level. I’ll be demonstrating on Ubuntu 18.04, so if your distribution of choice is different, you’ll only need to modify the Git install commands to suit your distribution’s package manager. - -### Git and GitHub - -The first thing to do is create a free GitHub account. Head over to the [GitHub signup page][3] and fill out the necessary information. Once you’ve done that, you’re ready to move on to installing Git (you can actually do these two steps in any order). - -Installing Git is simple. Open up a terminal window and issue the command: -``` -sudo apt install git-all - -``` - -This will include a rather large number of dependencies, but you’ll wind up with everything you need to work with Git and GitHub. - -On a side note: I use Git quite a bit to download source for application installation. There are times when a piece of software isn’t available via the built-in package manager. Instead of downloading the source files from a third-party location, I’ll often go the project’s Git page and clone the package like so: -``` -git clone ADDRESS - -``` - -Where ADDRESS is the URL given on the software’s Git page. -Doing this most always ensures I am installing the latest release of a package. - -Create a local repository and add a file - -The next step is to create a local repository on your system (we’ll call it newproject and house it in ~/). Open up a terminal window and issue the commands: -``` -cd ~/ - -mkdir newproject - -cd newproject - -``` - -Now we must initialize the repository. In the ~/newproject folder, issue the command git init. When the command completes, you should see that the empty Git repository has been created (Figure 1). - -![new repository][5] - -Figure 1: Our new repository has been initialized. - -[Used with permission][6] - -Next we need to add a file to the project. From within the root folder (~/newproject) issue the command: -``` -touch readme.txt - -``` - -You will now have an empty file in your repository. Issue the command git status to verify that Git is aware of the new file (Figure 2). - -![readme][8] - -Figure 2: Git knows about our readme.txt file. - -[Used with permission][6] - -Even though Git is aware of the file, it hasn’t actually been added to the project. To do that, issue the command: -``` -git add readme.txt - -``` - -Once you’ve done that, issue the git status command again to see that readme.txt is now considered a new file in the project (Figure 3). - -![file added][10] - -Figure 3: Our file now has now been added to the staging environment. - -[Used with permission][6] - -### Your first commit - -With the new file in the staging environment, you are now ready to create your first commit. What is a commit? Easy: A commit is a record of the files you’ve changed within the project. Creating the commit is actually quite simple. It is important, however, that you include a descriptive message for the commit. By doing this, you are adding notes about what the commit contains (such as what changes you’ve made to the file). Before we do this, however, we have to inform Git who we are. To do this, issue the command: -``` -git config --global user.email EMAIL - -git config --global user.name “FULL NAME” - -``` - -Where EMAIL is your email address and FULL NAME is your name. - -Now we can create the commit by issuing the command: -``` -git commit -m “Descriptive Message” - -``` - -Where Descriptive Message is your message about the changes within the commit. For example, since this is the first commit for the readme.txt file, the commit could be: -``` -git commit -m “First draft of readme.txt file” - -``` - -You should see output indicating that 1 file has changed and a new mode was created for readme.txt (Figure 4). - -![success][12] - -Figure 4: Our commit was successful. - -[Used with permission][6] - -### Create a branch and push it to GitHub - -Branches are important, as they allow you to move between project states. Let’s say you want to create a new feature for your game-changing app. To do that, create a new branch. Once you’ve completed work on the feature you can merge this feature from the branch to the master branch. To create the new branch, issue the command: - -git checkout -b BRANCH - -where BRANCH is the name of the new branch. Once the command completes, issue the command git branch to see that it has been created (Figure 5). - -![featureX][14] - -Figure 5: Our new branch, called featureX. - -[Used with permission][6] - -Next we need to create a repository on GitHub. If you log into your GitHub account, click the New Repository button from your account main page. Fill out the necessary information and click Create repository (Figure 6). - -![new repository][16] - -Figure 6: Creating the new repository on GitHub. - -[Used with permission][6] - -After creating the repository, you will be presented with a URL to use for pushing our local repository. To do this, go back to the terminal window (still within ~/newproject) and issue the commands: -``` -git remote add origin URL - -git push -u origin master - -``` - -Where URL is the url for our new GitHub repository. - -You will be prompted for your GitHub username and password. Once you successfully authenticate, the project will be pushed to your GitHub repository and you’re ready to go. - -### Pulling the project - -Say your collaborators make changes to the code on the GitHub project and have merged those changes. You will then need to pull the project files to your local machine, so the files you have on your system match those on the remote account. To do this, issue the command (from within ~/newproject): -``` -git pull origin master - -``` - -The above command will pull down any new or changed files to your local repository. - -### The very basics - -And that is the very basics of using Git from the command line to work with a project stored on GitHub. There is quite a bit more to learn, so I highly recommend you issue the commands man git, man git-push, and man git-pull to get a more in-depth understanding of what the git command can do. - -Happy developing! - -Learn more about Linux through the free ["Introduction to Linux" ][17]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/7/introduction-using-git - -作者:[Jack Wallen][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://git-scm.com/ -[2]:https://github.com/ -[3]:https://github.com/join?source=header-home -[4]:/files/images/git1jpg -[5]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_1.jpg?itok=FKkr5Mrk (new repository) -[6]:https://www.linux.com/licenses/category/used-permission -[7]:/files/images/git2jpg -[8]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_2.jpg?itok=54G9KBHS (readme) -[9]:/files/images/git3jpg -[10]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_3.jpg?itok=KAJwRJIB (file added) -[11]:/files/images/git4jpg -[12]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_4.jpg?itok=qR0ighDz (success) -[13]:/files/images/git5jpg -[14]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_5.jpg?itok=6m9RTWg6 (featureX) -[15]:/files/images/git6jpg -[16]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/git_6.jpg?itok=d2toRrUq (new repository) -[17]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From c7ffbc3f942942a414b3509610c72fdb5c775eac Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 5 Sep 2018 18:10:07 +0800 Subject: [PATCH 074/455] PRF:20180516 How Graphics Cards Work.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @pinewall 翻译的很棒,很专业。 --- .../tech/20180516 How Graphics Cards Work.md | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/translated/tech/20180516 How Graphics Cards Work.md b/translated/tech/20180516 How Graphics Cards Work.md index 172b0d1166..ca5fdc1e8c 100644 --- a/translated/tech/20180516 How Graphics Cards Work.md +++ b/translated/tech/20180516 How Graphics Cards Work.md @@ -1,50 +1,59 @@ -显卡工作原理简介 +极致技术探索:显卡工作原理 ====== + ![AMD-Polaris][1] -自从 sdfx 推出最初的 Voodoo 加速器以来,不起眼的显卡对你的 PC 是否可以玩游戏起到决定性作用,PC 上任何其它设备都无法与其相比。其它组件当然也很重要,但对于一个拥有 32GB 内存、价值 500 美金的 CPU 和 基于 PCIe 的存储设备的高端 PC,如果使用 10 年前的显卡,都无法以最高分辨率和细节质量运行当前最高品质的游戏AAA titles,会发生卡顿甚至无响应。显卡(也常被称为 GPU, 或图形处理单元Graphic Processing Unit)对游戏性能影响极大,我们反复强调这一点;但我们通常并不会深入了解显卡的工作原理。 +自从 sdfx 推出最初的 Voodoo 加速器以来,不起眼的显卡对你的 PC 是否可以玩游戏起到决定性作用,PC 上任何其它设备都无法与其相比。其它组件当然也很重要,但对于一个拥有 32GB 内存、价值 500 美金的 CPU 和 基于 PCIe 的存储设备的高端 PC,如果使用 10 年前的显卡,都无法以最高分辨率和细节质量运行当前最高品质的游戏AAA titles,会发生卡顿甚至无响应。显卡(也常被称为 GPU,即图形处理单元Graphic Processing Unit),对游戏性能影响极大,我们反复强调这一点;但我们通常并不会深入了解显卡的工作原理。 -出于实际考虑,本文将概述 GPU 的上层功能特性,内容包括 AMD 显卡、Nvidia 显卡、Intel 集成显卡以及 Intel 后续可能发布的独立显卡之间共同的部分。也应该适用于 Apple, Imagination Technologies, Qualcomm, ARM 和 其它显卡生产商发布的移动平台 GPU。 +出于实际考虑,本文将概述 GPU 的上层功能特性,内容包括 AMD 显卡、Nvidia 显卡、Intel 集成显卡以及 Intel 后续可能发布的独立显卡之间共同的部分。也应该适用于 Apple、Imagination Technologies、Qualcomm、ARM 和其它显卡生产商发布的移动平台 GPU。 ### 我们为何不使用 CPU 进行渲染? -我要说明的第一点是我们为何不直接使用 CPU 完成游戏中的渲染工作。坦率的说,在理论上你确实可以直接使用 CPU 完成渲染rendering工作。在显卡没有广泛普及之前,早期的 3D 游戏就是完全基于 CPU 运行的,例如 Ultima Underworld(LCTT 译注:中文名为 _地下创世纪_ ,下文中简称 UU)。UU 是一个很特别的例子,原因如下:与 Doom (LCTT 译注:中文名 _毁灭战士_)相比,UU 具有一个更高级的渲染引擎,全面支持向上或向下查找looking up and down以及一些在当时比较高级的特性,例如纹理映射texture mapping。但为支持这些高级特性,需要付出高昂的代价,很少有人可以拥有真正能运行起 UU 的 PC。 +我要说明的第一点是我们为何不直接使用 CPU 完成游戏中的渲染工作。坦率的说,在理论上你确实可以直接使用 CPU 完成渲染rendering工作。在显卡没有广泛普及之前,早期的 3D 游戏就是完全基于 CPU 运行的,例如 《地下创世纪Ultima Underworld(下文中简称 UU)。UU 是一个很特别的例子,原因如下:与《毁灭战士Doom相比,UU 具有一个更高级的渲染引擎,全面支持“向上或向下看”以及一些在当时比较高级的特性,例如纹理映射texture mapping。但为支持这些高级特性,需要付出高昂的代价,很少有人可以拥有真正能运行起 UU 的 PC。 ![](https://www.extremetech.com/wp-content/uploads/2018/05/UU.jpg) -对于早期的 3D 游戏,包括 Half Life 和 Quake II 在内的很多游戏,内部包含一个软件渲染器,让没有 3D 加速器的玩家也可以玩游戏。但现代游戏都弃用了这种方式,原因很简单:CPU 是设计用于通用任务的微处理器,意味着缺少 GPU 提供的专用硬件specialized hardware功能capabilities。对于 18 年前使用软件渲染的那些游戏,当代 CPU 可以轻松胜任;但对于当代最高品质的游戏,除非明显降低景象质量scene、分辨率和各种虚拟特效,否则现有的 CPU 都无法胜任。 +*地下创世纪,图片来自 [GOG](https://www.gog.com/game/ultima_underworld_1_2)* + +对于早期的 3D 游戏,包括《半条命Half Life》和《雷神之锤 2Quake II》在内的很多游戏,内部包含一个软件渲染器,让没有 3D 加速器的玩家也可以玩游戏。但现代游戏都弃用了这种方式,原因很简单:CPU 是设计用于通用任务的微处理器,意味着缺少 GPU 提供的专用硬件specialized hardware功能capabilities。对于 18 年前使用软件渲染的那些游戏,当代 CPU 可以轻松胜任;但对于当代最高品质的游戏,除非明显降低景象质量scene、分辨率和各种虚拟特效,否则现有的 CPU 都无法胜任。 ### 什么是 GPU ? -GPU 是一种包含一系列专用硬件特性的设备,其中这些特性可以让各种 3D 引擎更好地执行代码,包括形状构建geometry setup,纹理映射,访存memory access着色器shaders等。3D 引擎的功能特性影响着设计者如何设计 GPU。可能有人还记得,AMD HD5000 系列使用 VLIW5 架构archtecture;但在更高端的 HD 6000 系列中使用了 VLIW4 架构。通过 GCN (LCTT 译注:GCN 是 Graphics Core Next 的缩写,字面意思是下一代图形核心,既是若干代微体系结构的代号,也是指令集的名称),AMD 改变了并行化的实现方法,提高了每个时钟周期的有效性能。 +GPU 是一种包含一系列专用硬件特性的设备,其中这些特性可以让各种 3D 引擎更好地执行代码,包括形状构建geometry setup,纹理映射,访存memory access着色器shaders等。3D 引擎的功能特性影响着设计者如何设计 GPU。可能有人还记得,AMD HD5000 系列使用 VLIW5 架构archtecture;但在更高端的 HD 6000 系列中使用了 VLIW4 架构。通过 GCN (LCTT 译注:GCN 是 Graphics Core Next 的缩写,字面意思是“下一代图形核心”,既是若干代微体系结构的代号,也是指令集的名称),AMD 改变了并行化的实现方法,提高了每个时钟周期的有效性能。 ![](https://www.extremetech.com/wp-content/uploads/2018/05/GPU-Evolution.jpg) +*“GPU 革命”的前两块奠基石属于 AMD 和 NV;而“第三个时代”则独属于 AMD。* + Nvidia 在发布首款 GeForce 256 时(大致对应 Microsoft 推出 DirectX7 的时间点)提出了 GPU 这个术语,这款 GPU 支持在硬件上执行转换和光照计算lighting calculation。将专用功能直接集成到硬件中是早期 GPU 的显著技术特点。很多专用功能还在(以一种极为不同的方式)使用,毕竟对于特定类型的工作任务,使用片上on-chip专用计算资源明显比使用一组可编程单元programmable cores要更加高效和快速。 -GPU 和 CPU 的核心有很多差异,但我们可以按如下方式比较其上层特性。CPU 一般被设计成尽可能快速和高效的执行单线程代码。虽然 同时多线程SMT, Simultaneous multithreading超线程Hyper-Threading在这方面有所改进,但我们实际上通过堆叠众多高效率的单线程核心来扩展多线程性能。AMD 的 32 核心/64 线程 Epyc CPU 已经是我们能买到的核心数最多的 CPU;相比而言,Nvidia 最低端的 Pascal GPU 都拥有 384 个核心。但相比 CPU 的核心,GPU 所谓的核心是处理能力低得多的的处理单元。 +GPU 和 CPU 的核心有很多差异,但我们可以按如下方式比较其上层特性。CPU 一般被设计成尽可能快速和高效的执行单线程代码。虽然 同时多线程 Simultaneous multithreading(SMT)或 超线程Hyper-Threading(HT)在这方面有所改进,但我们实际上通过堆叠众多高效率的单线程核心来扩展多线程性能。AMD 的 32 核心/64 线程 Epyc CPU 已经是我们能买到的核心数最多的 CPU;相比而言,Nvidia 最低端的 Pascal GPU 都拥有 384 个核心。但相比 CPU 的核心,GPU 所谓的核心是处理能力低得多的的处理单元。 **注意:** 简单比较 GPU 核心数,无法比较或评估 AMD 与 Nvidia 的相对游戏性能。在同样 GPU 系列(例如 Nvidia 的 GeForce GTX 10 系列,或 AMD 的 RX 4xx 或 5xx 系列)的情况下,更高的 GPU 核心数往往意味着更高的性能。 -你无法只根据核心数比较不同供应商或核心系列的 GPU 之间的性能,这是因为不同的架构对应的效率各不相同。与 CPU 不同,GPU 被设计用于并行计算。AMD 和 Nvidia 在结构上都划分为计算资源block。Nvidia 将这些块称之为流处理器SM, Streaming Multiprocessor,而 AMD 则称之为计算单元Compute Unit。 +你无法只根据核心数比较不同供应商或核心系列的 GPU 之间的性能,这是因为不同的架构对应的效率各不相同。与 CPU 不同,GPU 被设计用于并行计算。AMD 和 Nvidia 在结构上都划分为计算资源block。Nvidia 将这些块称之为流处理器Streaming Multiprocessor(SM),而 AMD 则称之为计算单元Compute Unit(CU)。 ![](https://www.extremetech.com/wp-content/uploads/2018/05/PascalSM.png) -每个块都包含如下组件:一组核心,一个调度器scheduler,一个寄存器文件register file,指令缓存,纹理和 L1 缓存以及纹理映射单元mapping units。SM/CU 可以被认为是 GPU 中最小的可工作块。SM/CU 没有涵盖全部的功能单元,例如视频解码引擎,实际在屏幕绘图所需的渲染输出,以及与板载onboard显存VRAM, Video Memory通信相关的内存接口memory interfaces都不在 SM/CU 的范围内;但当 AMD 提到一个 APU 拥有 8 或 11 个 Vega 计算单元时,所指的是(等价的)硅晶块block of silicon数目。如果你查看任意一款 GPU 的模块设计图,你会发现图中 SM/CU 是反复出现很多次的部分。 +*一个 Pascal 流处理器(SM)。* + +每个块都包含如下组件:一组核心、一个调度器scheduler、一个寄存器文件register file、指令缓存、纹理和 L1 缓存以及纹理映射单元mapping unit。SM/CU 可以被认为是 GPU 中最小的可工作块。SM/CU 没有涵盖全部的功能单元,例如视频解码引擎,实际在屏幕绘图所需的渲染输出,以及与板载onboard显存Video Memory(VRAM)通信相关的内存接口memory interfaces都不在 SM/CU 的范围内;但当 AMD 提到一个 APU 拥有 8 或 11 个 Vega 计算单元时,所指的是(等价的)硅晶块block of silicon数目。如果你查看任意一款 GPU 的模块设计图,你会发现图中 SM/CU 是反复出现很多次的部分。 ![](https://www.extremetech.com/wp-content/uploads/2016/11/Pascal-Diagram.jpg) +*这是 Pascal 的全平面图* + GPU 中的 SM/CU 数目越多,每个时钟周期内可以并行完成的工作也越多。渲染是一种通常被认为是“高度并行”的计算问题,意味着随着核心数增加带来的可扩展性很高。 -当我们讨论 GPU 设计时,我们通常会使用一种形如 4096:160:64 的格式,其中第一个数字代表核心数。在核心系列(如 GTX970/GTX 980/GTX 980 Ti, 如 RX 560/RX 580 等等)一致的情况下,核心数越高,GPU 也就相对更快。 +当我们讨论 GPU 设计时,我们通常会使用一种形如 4096:160:64 的格式,其中第一个数字代表核心数。在核心系列(如 GTX970/GTX 980/GTX 980 Ti,如 RX 560/RX 580 等等)一致的情况下,核心数越高,GPU 也就相对更快。 ### 纹理映射和渲染输出 GPU 的另外两个主要组件是纹理映射单元和渲染输出。设计中的纹理映射单元数目决定了最大的纹素texel输出以及可以多快的处理并将纹理映射到对象上。早期的 3D 游戏很少用到纹理,这是因为绘制 3D 多边形形状的工作有较大的难度。纹理其实并不是 3D 游戏必须的,但不使用纹理的现代游戏屈指可数。 -GPU 中的纹理映射单元数目用 4096:160:64 指标中的第二个数字表示。AMD,Nvidia 和 Intel 一般都等比例变更指标中的数字。换句话说,如果你找到一个指标为 4096:160:64 的 GPU,同系列中不会出现指标为 4096:320:64 的 GPU。纹理映射绝对有可能成为游戏的瓶颈,但产品系列中次高级别的 GPU 往往提供更多的核心和纹理映射单元(是否拥有更高的渲染输出单元取决于 GPU 系列和显卡的指标)。 +GPU 中的纹理映射单元数目用 4096:160:64 指标中的第二个数字表示。AMD、Nvidia 和 Intel 一般都等比例变更指标中的数字。换句话说,如果你找到一个指标为 4096:160:64 的 GPU,同系列中不会出现指标为 4096:320:64 的 GPU。纹理映射绝对有可能成为游戏的瓶颈,但产品系列中次高级别的 GPU 往往提供更多的核心和纹理映射单元(是否拥有更高的渲染输出单元取决于 GPU 系列和显卡的指标)。 -渲染输出单元Render outputs, ROPs(有时也叫做光栅操作管道raster operations pipelines是 GPU 输出汇集成图像的场所,图像最终会在显示器或电视上呈现。渲染输出单元的数目乘以 GPU 的时钟频率决定了像素填充速率pixel fill rate。渲染输出单元数目越多意味着可以同时输出的像素越多。渲染输出单元还处理抗锯齿antialiasing,启用抗锯齿(尤其是超级采样supersampled抗锯齿)会导致游戏填充速率受限。 +渲染输出单元Render outputs(ROP),有时也叫做光栅操作管道raster operations pipelines是 GPU 输出汇集成图像的场所,图像最终会在显示器或电视上呈现。渲染输出单元的数目乘以 GPU 的时钟频率决定了像素填充速率pixel fill rate。渲染输出单元数目越多意味着可以同时输出的像素越多。渲染输出单元还处理抗锯齿antialiasing,启用抗锯齿(尤其是超级采样supersampled抗锯齿)会导致游戏填充速率受限。 ### 显存带宽与显存容量 @@ -52,11 +61,11 @@ GPU 中的纹理映射单元数目用 4096:160:64 指标中的第二个数字表 在某些情况下,显存带宽不足会成为 GPU 的显著瓶颈。以 Ryzen 5 2400G 为例的 AMD APU 就是严重带宽受限的,以至于提高 DDR4 的时钟频率可以显著提高整体性能。导致瓶颈的显存带宽阈值,也与游戏引擎和游戏使用的分辨率相关。 -板载内存大小也是 GPU 的重要指标。如果按指定细节级别或分辨率运行所需的显存量超过了可用的资源量,游戏通常仍可以运行,但会使用 CPU 的主存存储额外的纹理数据;而从 DRAM 中提取数据比从板载显存中提取数据要慢得多。这会导致游戏在板载的快速访问内存池和系统内存中共同提取数据时出现明显的卡顿。 +板载内存大小也是 GPU 的重要指标。如果按指定细节级别或分辨率运行所需的显存量超过了可用的资源量,游戏通常仍可以运行,但会使用 CPU 的主存来存储额外的纹理数据;而从 DRAM 中提取数据比从板载显存中提取数据要慢得多。这会导致游戏在板载的快速访问内存池和系统内存中共同提取数据时出现明显的卡顿。 -有一点我们需要留意,GPU 生产厂家通常为一款低端或中端 GPU 配置比通常更大的显存,这是他们为产品提价的一种常用手段。很难说大显存是否更具有吸引力,毕竟需要具体问题具体分析。大多数情况下,用更高的价格购买一款仅显存更高的显卡是不划算的。经验规律告诉我们,低端显卡遇到显存瓶颈之前就会碰到其它瓶颈。如果存在疑问,可以查看相关评论,例如 4G 版本或其它数目的版本是否性能超过 2G 版本。更多情况下,如果其它指标都相同,购买大显存版本并不值得。 +有一点我们需要留意,GPU 生产厂家通常为一款低端或中端 GPU 配置比通常更大的显存,这是他们为产品提价的一种常用手段。很难说大显存是否更具有吸引力,毕竟需要具体问题具体分析。大多数情况下,用更高的价格购买一款仅是显存更高的显卡是不划算的。经验规律告诉我们,低端显卡遇到显存瓶颈之前就会碰到其它瓶颈。如果存在疑问,可以查看相关评论,例如 4G 版本或其它数目的版本是否性能超过 2G 版本。更多情况下,如果其它指标都相同,购买大显存版本并不值得。 -查看我们的[极致技术讲解][2]系列,深入了解更多当前最热的技术话题。 +查看我们的[极致技术探索][2]系列,深入了解更多当前最热的技术话题。 -------------------------------------------------------------------------------- @@ -65,7 +74,7 @@ via: https://www.extremetech.com/gaming/269335-how-graphics-cards-work 作者:[Joel Hruska][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[pinewall](https://github.com/pinewall) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 39f17544aca49ff41fd8178c0f5aea865cc425aa Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 5 Sep 2018 18:10:49 +0800 Subject: [PATCH 075/455] PUB:20180516 How Graphics Cards Work.md @pinewall https://linux.cn/article-9981-1.html --- .../tech => published}/20180516 How Graphics Cards Work.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180516 How Graphics Cards Work.md (100%) diff --git a/translated/tech/20180516 How Graphics Cards Work.md b/published/20180516 How Graphics Cards Work.md similarity index 100% rename from translated/tech/20180516 How Graphics Cards Work.md rename to published/20180516 How Graphics Cards Work.md From 990e7b8860c06b471cbab27a86bbf91626833dd2 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 5 Sep 2018 18:21:33 +0800 Subject: [PATCH 076/455] PRF:20180702 View The Contents Of An Archive Or Compressed File Without Extracting It.md @FSSlc --- ...r Compressed File Without Extracting It.md | 65 +++++++++---------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/translated/tech/20180702 View The Contents Of An Archive Or Compressed File Without Extracting It.md b/translated/tech/20180702 View The Contents Of An Archive Or Compressed File Without Extracting It.md index 6193dfcd9c..689061cb81 100644 --- a/translated/tech/20180702 View The Contents Of An Archive Or Compressed File Without Extracting It.md +++ b/translated/tech/20180702 View The Contents Of An Archive Or Compressed File Without Extracting It.md @@ -1,5 +1,6 @@ 查看一个归档或压缩文件的内容而无需解压它 ====== + ![](https://www.ostechnix.com/wp-content/uploads/2018/07/View-The-Contents-Of-An-Archive-Or-Compressed-File-720x340.png) 在本教程中,我们将学习如何在类 Unix 系统中查看一个归档或者压缩文件的内容而无需实际解压它。在深入之前,让我们先厘清归档和压缩文件的概念,它们之间有显著不同。归档是将多个文件或者目录归并到一个文件的过程,因此这个生成的文件是没有被压缩过的。而压缩则是结合多个文件或者目录到一个文件并最终压缩这个文件的方法。归档文件不是一个压缩文件,但压缩文件可以是一个归档文件,清楚了吗?好,那就让我们进入今天的主题。 @@ -8,44 +9,44 @@ 得益于 Linux 社区,有很多命令行工具可以来达成上面的目标。下面就让我们来看看使用它们的一些示例。 -**1 使用 Vim 编辑器** +#### 1、使用 vim 编辑器 -Vim 不只是一个编辑器,使用它我们可以干很多事情。下面的命令展示的是在没有解压的情况下使用 Vim 查看一个压缩的归档文件的内容: +vim 不只是一个编辑器,使用它我们可以干很多事情。下面的命令展示的是在没有解压的情况下使用 vim 查看一个压缩的归档文件的内容: ``` $ vim ostechnix.tar.gz - ``` ![][2] 你甚至还可以浏览归档文件的内容,打开其中的文本文件(假如有的话)。要打开一个文本文件,只需要用方向键将鼠标的游标放置到文件的前面,然后敲 ENTER 键来打开它。 -**2 使用 Tar 命令** +#### 2、使用 tar 命令 为了列出一个 tar 归档文件的内容,可以运行: + ``` $ tar -tf ostechnix.tar ostechnix/ ostechnix/image.jpg ostechnix/file.pdf ostechnix/song.mp3 - ``` -或者使用 **-v** 选项来查看归档文件的具体属性,例如它的文件所有者、属组、创建日期等等。 +或者使用 `-v` 选项来查看归档文件的具体属性,例如它的文件所有者、属组、创建日期等等。 + ``` $ tar -tvf ostechnix.tar drwxr-xr-x sk/users 0 2018-07-02 19:30 ostechnix/ -rw-r--r-- sk/users 53632 2018-06-29 15:57 ostechnix/image.jpg -rw-r--r-- sk/users 156831 2018-06-04 12:37 ostechnix/file.pdf -rw-r--r-- sk/users 9702219 2018-04-25 20:35 ostechnix/song.mp3 - ``` -**3 使用 Rar 命令** +#### 3、使用 rar 命令 要查看一个 rar 文件的内容,只需要执行: + ``` $ rar v ostechnix.rar @@ -62,12 +63,12 @@ Attributes Size Packed Ratio Date Time Checksum Name -rw-r--r-- 9702219 9658527 99% 2018-04-25 20:35 DD875AC4 ostechnix/song.mp3 ----------- --------- -------- ----- ---------- ----- -------- ---- 9912682 9849787 99% 3 - ``` -**4 使用 Unrar 命令** +#### 4、使用 unrar 命令 + +你也可以使用带有 `l` 选项的 `unrar` 来做到与上面相同的事情,展示如下: -你也可以使用带有 **l** 选项的 **Unrar** 来做到与上面相同的事情,展示如下: ``` $ unrar l ostechnix.rar @@ -83,23 +84,23 @@ Attributes Size Date Time Name -rw-r--r-- 9702219 2018-04-25 20:35 ostechnix/song.mp3 ----------- --------- ---------- ----- ---- 9912682 3 - ``` -**5 使用 Zip 命令** +#### 5、使用 zip 命令 + +为了查看一个 zip 文件的内容而无需解压它,可以使用下面的 `zip` 命令: -为了查看一个 zip 文件的内容而无需解压它,可以使用下面的 **zip** 命令: ``` $ zip -sf ostechnix.zip Archive contains: Life advices.jpg Total 1 entries (597219 bytes) - ``` -**6. 使用 Unzip 命令** +#### 6、使用 unzip 命令 + +你也可以像下面这样使用 `-l` 选项的 `unzip` 命令来呈现一个 zip 文件的内容: -你也可以像下面这样使用 **-l** 选项的 **Unzip** 命令来呈现一个 zip 文件的内容: ``` $ unzip -l ostechnix.zip Archive: ostechnix.zip @@ -108,10 +109,9 @@ Length Date Time Name 597219 2018-04-09 12:48 Life advices.jpg --------- ------- 597219 1 file - ``` -**7 使用 Zipinfo 命令** +#### 7、使用 zipinfo 命令 ``` $ zipinfo ostechnix.zip @@ -119,43 +119,42 @@ Archive: ostechnix.zip Zip file size: 584859 bytes, number of entries: 1 -rw-r--r-- 6.3 unx 597219 bx defN 18-Apr-09 12:48 Life advices.jpg 1 file, 597219 bytes uncompressed, 584693 bytes compressed: 2.1% - ``` 如你所见,上面的命令展示了一个 zip 文件的内容、它的权限、创建日期和压缩百分比等等信息。 -**8. 使用 Zcat 命令** +#### 8、使用 zcat 命令 + +要一个压缩的归档文件的内容而不解压它,使用 `zcat` 命令,我们可以得到: -要一个压缩的归档文件的内容而不解压它,使用 **zcat** 命令,我们可以得到: ``` $ zcat ostechnix.tar.gz - ``` -zcat 和 `gunzip -c` 命令相同。所以你可以使用下面的命令来查看归档或者压缩文件的内容: +`zcat` 和 `gunzip -c` 命令相同。所以你可以使用下面的命令来查看归档或者压缩文件的内容: + ``` $ gunzip -c ostechnix.tar.gz - ``` -**9. 使用 Zless 命令** +#### 9、使用 zless 命令 + +要使用 zless 命令来查看一个归档或者压缩文件的内容,只需: -要使用 Zless 命令来查看一个归档或者压缩文件的内容,只需: ``` $ zless ostechnix.tar.gz - ``` 这个命令类似于 `less` 命令,它将一页一页地展示其输出。 -**10. 使用 Less 命令** +#### 10、使用 less 命令 -可能你已经知道 **less** 命令可以打开文件来交互式地阅读它,并且它支持滚动和搜索。 +可能你已经知道 `less` 命令可以打开文件来交互式地阅读它,并且它支持滚动和搜索。 + +运行下面的命令来使用 `less` 命令查看一个归档或者压缩文件的内容: -运行下面的命令来使用 less 命令查看一个归档或者压缩文件的内容: ``` $ less ostechnix.tar.gz - ``` 上面便是全部的内容了。现在你知道了如何在 Linux 中使用各种命令查看一个归档或者压缩文件的内容了。希望本文对你有用。更多好的内容将呈现给大家,希望继续关注我们! @@ -169,7 +168,7 @@ via: https://www.ostechnix.com/how-to-view-the-contents-of-an-archive-or-compres 作者:[SK][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[FSSlc](https://github.com/FSSlc) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 7acc0fcb99871aeba1af59aa27ee4968f7281d1b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 5 Sep 2018 18:21:56 +0800 Subject: [PATCH 077/455] PUB:20180702 View The Contents Of An Archive Or Compressed File Without Extracting It.md @FSSlc https://linux.cn/article-9982-1.html --- ...ents Of An Archive Or Compressed File Without Extracting It.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180702 View The Contents Of An Archive Or Compressed File Without Extracting It.md (100%) diff --git a/translated/tech/20180702 View The Contents Of An Archive Or Compressed File Without Extracting It.md b/published/20180702 View The Contents Of An Archive Or Compressed File Without Extracting It.md similarity index 100% rename from translated/tech/20180702 View The Contents Of An Archive Or Compressed File Without Extracting It.md rename to published/20180702 View The Contents Of An Archive Or Compressed File Without Extracting It.md From b696ae3df2e2617cb539d9ad94bde97caa423bce Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 5 Sep 2018 20:40:37 +0800 Subject: [PATCH 078/455] PRF:20180424 A gentle introduction to FreeDOS.md @icecoobe --- ...180424 A gentle introduction to FreeDOS.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/translated/tech/20180424 A gentle introduction to FreeDOS.md b/translated/tech/20180424 A gentle introduction to FreeDOS.md index 70d85979bb..11c43870fd 100644 --- a/translated/tech/20180424 A gentle introduction to FreeDOS.md +++ b/translated/tech/20180424 A gentle introduction to FreeDOS.md @@ -1,11 +1,12 @@ -Free DOS 的简单介绍 +FreeDOS 的简单介绍 ====== +> 学习如何穿行于 C:\ 提示符下,就像上世纪 90 年代的 DOS 高手一样。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/freedos-fish-laptop-color.png?itok=vfv_Lpph) -FreeDOS 是一个古老的操作系统,但是对于多数人而言它又是陌生的。在 1994 年,我和几个开发者一起 [开发 FreeDOS][1]--一个完整、自由、DOS 兼容的操作系统,你可以用它来玩经典的 DOS 游戏、运行遗留的商业软件或者开发嵌入式系统。任何在 MS-DOS 下工作的程序在 FreeDOS 下也可以运行。 +FreeDOS 是一个古老的操作系统,但是对于多数人而言它又是陌生的。在 1994 年,我和几个开发者一起 [开发了 FreeDOS][1] —— 这是一个完整、自由、兼容 DOS 的操作系统,你可以用它来玩经典的 DOS 游戏、运行过时的商业软件或者开发嵌入式系统。任何在 MS-DOS 下工作的程序在 FreeDOS 下也可以运行。 -在 1994 年,任何一个曾经使用过微软专利的 MS-DOS 的人都会迅速地熟悉 FreeDOS。这是设计而为之的;FreeDOS 尽可能地去模仿 MS-DOS。结果,1990 年代的 DOS 用户能够直接转换到 FreeDOS。但是,时代变了。今天,开源的开发者们对于 Linux 命令行更熟悉或者他们可能倾向于像 [GNOME][2] 一样的图形桌面环境,这导致 FreeDOS 命令行界面最初看起来像个异类。 +在 1994 年,任何一个曾经使用过微软的商业版 MS-DOS 的人都会迅速地熟悉 FreeDOS。这是设计而为之的;FreeDOS 尽可能地去模仿 MS-DOS。结果,1990 年代的 DOS 用户能够直接转换到 FreeDOS。但是,时代变了。今天,开源的开发者们对于 Linux 命令行更熟悉,或者他们可能倾向于像 [GNOME][2] 一样的图形桌面环境,这导致 FreeDOS 命令行界面最初看起来像个异类。 新的用户通常会问,“我已经安装了 [FreeDOS][3],但是如何使用呢?”。如果你之前并没有使用过 DOS,那么闪烁的 `C:\>` DOS 提示符看起来会有点不太友好,而且可能有点吓人。这份 FreeDOS 的简单介绍将带你起步。它只提供了基础:如何浏览以及如何查看文件。如果你想了解比这里提及的更多的知识,访问 [FreeDOS 维基][4]。 @@ -15,13 +16,13 @@ FreeDOS 是一个古老的操作系统,但是对于多数人而言它又是陌 ![](https://opensource.com/sites/default/files/u128651/0-prompt.png) -DOS 是在个人电脑从软盘运行时期创建的一个“磁盘操作系统”。甚至当电脑支持硬盘了,在 1980 年代和 1990 年代,频繁地在不同的驱动器之间切换也是很普遍的。举例来说,你可能想将最重要的文件都备份一份拷贝到软盘中。 +DOS 是在个人电脑从软盘运行时期创建的一个“磁盘操作系统disk operating system”。甚至当电脑支持硬盘了,在 1980 年代和 1990 年代,频繁地在不同的驱动器之间切换也是很普遍的。举例来说,你可能想将最重要的文件都备份一份拷贝到软盘中。 DOS 使用一个字母来指代每个驱动器。早期的电脑仅拥有两个软盘驱动器,他们被分配了 `A:` 和 `B:` 盘符。硬盘上的第一个分区盘符是 `C:` ,然后其它的盘符依次这样分配下去。提示符中的 `C:` 表示你正在使用第一个硬盘的第一个分区。 从 1983 年的 PC-DOS 2.0 开始,DOS 也支持目录和子目录,非常类似 Linux 文件系统中的目录和子目录。但是跟 Linux 不一样的是,DOS 目录名由 `\` 分隔而不是 `/`。将这个与驱动器字母合起来看,提示符中的 `C:\` 表示你正在 `C:` 盘的顶端或者“根”目录。 -`>` 修饰符提示你输入 DOS 命令的地方,就像众多 Linux shell 的 `$`。`>` 前面的部分告诉你当前的工作目录,然后你在 `>` 提示符这输入命令。 +`>` 符号是提示你输入 DOS 命令的地方,就像众多 Linux shell 的 `$`。`>` 前面的部分告诉你当前的工作目录,然后你在 `>` 提示符这输入命令。 ### 在 DOS 中找到你的使用方式 @@ -33,7 +34,7 @@ DOS 使用一个字母来指代每个驱动器。早期的电脑仅拥有两个 ![](https://opensource.com/sites/default/files/u128651/1-dir.png) -如果你不想显示单个文件大小的额外细节,你可以在 `DIR` 命令中使用 `/w` 选项来显示一个“宽泛”文件夹。注意,Linux 用户使用连字号(`-`)或者双连字号(`--`)来开启命令行选项,而 DOS 使用斜线字符(`/`)。 +如果你不想显示单个文件大小的额外细节,你可以在 `DIR` 命令中使用 `/w` 选项来显示一个“宽”的目录列表。注意,Linux 用户使用连字号(`-`)或者双连字号(`--`)来开始命令行选项,而 DOS 使用斜线字符(`/`)。 ![](https://opensource.com/sites/default/files/u128651/2-dirw.png) @@ -64,7 +65,7 @@ FreeDOS 也从 Linux 那借鉴了一些特性:你可以使用 `CD -` 跳转回 ![](https://opensource.com/sites/default/files/u128651/8-d-dirw.png) -小心不要尝试切换到一个不存在的磁盘。DOS 可能会将它设置为工作磁盘,但是如果你尝试在那做任何事,你将会遇到略微臭名昭著的“退出、重试、失败” DOS 错误信息。 +小心不要尝试切换到一个不存在的磁盘。DOS 可能会将它设置为工作磁盘,但是如果你尝试在那做任何事,你将会遇到略微臭名昭著的“退出、重试、失败Abort, Retry, Fail” DOS 错误信息。 ![](https://opensource.com/sites/default/files/u128651/9-e-fail.png) @@ -86,7 +87,7 @@ FreeDOS 也从 Linux 那借鉴了一些特性:你可以使用 `CD -` 跳转回 在 FreeDOS 下,针对每个命令你都能够使用 `/?` 参数来获取简要的说明。举例来说,`EDIT /?` 会告诉你编辑器的用法和选项。或者你可以输入 `HELP` 来使用交互式帮助系统。 -像任何一个 DOS 一样,FreeDOS 被认为是一个简单的操作系统。仅使用一些基本命令就可以轻松浏览 DOS 文件系统。那么启动一个 QEMU 会话,安装 FreeDOS,然后尝试一下 DOS 命令行界面。也许它现在看起来就没那么吓人了。 +像任何一个 DOS 一样,FreeDOS 被认为是一个简单的操作系统。仅使用一些基本命令就可以轻松浏览 DOS 文件系统。那么,启动一个 QEMU 会话,安装 FreeDOS,然后尝试一下 DOS 命令行界面吧。也许它现在看起来就没那么吓人了。 -------------------------------------------------------------------------------- @@ -96,7 +97,7 @@ via: https://opensource.com/article/18/4/gentle-introduction-freedos 作者:[Jim Hall][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[icecoobe](https://github.com/icecoobe) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 84e16971a16fe89bc429c5c486c2636d6250c544 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 5 Sep 2018 20:40:59 +0800 Subject: [PATCH 079/455] PUB:20180424 A gentle introduction to FreeDOS.md @icecoobe https://linux.cn/article-9983-1.html --- .../20180424 A gentle introduction to FreeDOS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180424 A gentle introduction to FreeDOS.md (100%) diff --git a/translated/tech/20180424 A gentle introduction to FreeDOS.md b/published/20180424 A gentle introduction to FreeDOS.md similarity index 100% rename from translated/tech/20180424 A gentle introduction to FreeDOS.md rename to published/20180424 A gentle introduction to FreeDOS.md From 8b0102c28d6f12d791231617ede72ceb288ae350 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 5 Sep 2018 22:12:49 +0800 Subject: [PATCH 080/455] PRF:20180516 How Graphics Cards Work.md --- published/20180516 How Graphics Cards Work.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/published/20180516 How Graphics Cards Work.md b/published/20180516 How Graphics Cards Work.md index ca5fdc1e8c..690c121833 100644 --- a/published/20180516 How Graphics Cards Work.md +++ b/published/20180516 How Graphics Cards Work.md @@ -3,7 +3,7 @@ ![AMD-Polaris][1] -自从 sdfx 推出最初的 Voodoo 加速器以来,不起眼的显卡对你的 PC 是否可以玩游戏起到决定性作用,PC 上任何其它设备都无法与其相比。其它组件当然也很重要,但对于一个拥有 32GB 内存、价值 500 美金的 CPU 和 基于 PCIe 的存储设备的高端 PC,如果使用 10 年前的显卡,都无法以最高分辨率和细节质量运行当前最高品质的游戏AAA titles,会发生卡顿甚至无响应。显卡(也常被称为 GPU,即图形处理单元Graphic Processing Unit),对游戏性能影响极大,我们反复强调这一点;但我们通常并不会深入了解显卡的工作原理。 +自从 3dfx 推出最初的 Voodoo 加速器以来,不起眼的显卡对你的 PC 是否可以玩游戏起到决定性作用,PC 上任何其它设备都无法与其相比。其它组件当然也很重要,但对于一个拥有 32GB 内存、价值 500 美金的 CPU 和 基于 PCIe 的存储设备的高端 PC,如果使用 10 年前的显卡,都无法以最高分辨率和细节质量运行当前最高品质的游戏AAA titles,会发生卡顿甚至无响应。显卡(也常被称为 GPU,即图形处理单元Graphic Processing Unit),对游戏性能影响极大,我们反复强调这一点;但我们通常并不会深入了解显卡的工作原理。 出于实际考虑,本文将概述 GPU 的上层功能特性,内容包括 AMD 显卡、Nvidia 显卡、Intel 集成显卡以及 Intel 后续可能发布的独立显卡之间共同的部分。也应该适用于 Apple、Imagination Technologies、Qualcomm、ARM 和其它显卡生产商发布的移动平台 GPU。 From a879d71007aa518c2b11b77c4a3dafd3e919852a Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 6 Sep 2018 08:49:19 +0800 Subject: [PATCH 081/455] translated --- ...ll software from the Linux command line.md | 108 ------------------ ...ll software from the Linux command line.md | 106 +++++++++++++++++ 2 files changed, 106 insertions(+), 108 deletions(-) delete mode 100644 sources/tech/20180824 How to install software from the Linux command line.md create mode 100644 translated/tech/20180824 How to install software from the Linux command line.md diff --git a/sources/tech/20180824 How to install software from the Linux command line.md b/sources/tech/20180824 How to install software from the Linux command line.md deleted file mode 100644 index eccf8c5e17..0000000000 --- a/sources/tech/20180824 How to install software from the Linux command line.md +++ /dev/null @@ -1,108 +0,0 @@ -translating----geekpi - -How to install software from the Linux command line -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/suitcase_container_bag.png?itok=q40lKCBY) - -If you use Linux for any amount of time, you'll soon learn there are many different ways to do the same thing. This includes installing applications on a Linux machine via the command line. I have been a Linux user for roughly 25 years, and time and time again I find myself going back to the command line to install my apps. - -The most common method of installing apps from the command line is through software repositories (a place where software is stored) using what's called a package manager. All Linux apps are distributed as packages, which are nothing more than files associated with a package management system. Every Linux distribution comes with a package management system, but they are not all the same. - -### What is a package management system? - -A package management system is comprised of sets of tools and file formats that are used together to install, update, and uninstall Linux apps. The two most common package management systems are from Red Hat and Debian. Red Hat, CentOS, and Fedora all use the `rpm` system (.rpm files), while Debian, Ubuntu, Mint, and Ubuntu use `dpkg` (.deb files). Gentoo Linux uses a system called Portage, and Arch Linux uses nothing but tarballs (.tar files). The primary difference between these systems is how they install and maintain apps. - -You might be wondering what's inside an `.rpm`, `.deb`, or `.tar` file. You might be surprised to learn that all are nothing more than plain old archive files (like `.zip`) that contain an application's code, instructions on how to install it, dependencies (what other apps it may depend on), and where its configuration files should be placed. The software that reads and executes all of those instructions is called a package manager. - -### Debian, Ubuntu, Mint, and others - -Debian, Ubuntu, Mint, and other Debian-based distributions all use `.deb` files and the `dpkg` package management system. There are two ways to install apps via this system. You can use the `apt` application to install from a repository, or you can use the `dpkg` app to install apps from `.deb` files. Let's take a look at how to do both. - -Installing apps using `apt` is as easy as: -``` -$ sudo apt install app_name - -``` - -Uninstalling an app via `apt` is also super easy: -``` -$ sudo apt remove app_name - -``` - -To upgrade your installed apps, you'll first need to update the app repository: -``` -$ sudo apt update - -``` - -Once finished, you can update any apps that need updating with the following: -``` -$ sudo apt upgrade - -``` - -What if you want to update only a single app? No problem. -``` -$ sudo apt update app_name - -``` - -Finally, let's say the app you want to install is not available in the Debian repository, but it is available as a `.deb` download. -``` -$ sudo dpkg -i app_name.deb - -``` - -### Red Hat, CentOS, and Fedora - -Red Hat, by default, uses several package management systems. These systems, while using their own terminology, are still very similar to each other and to the one used in Debian. For example, we can use either the `yum` or `dnf` manager to install apps. -``` -$ sudo yum install app_name - -$ sudo dnf install app_name - -``` - -Apps in the `.rpm` format can also be installed with the `rpm` command. -``` -$ sudo rpm -i app_name.rpm - -``` - -Removing unwanted applications is just as easy. -``` -$ sudo yum remove app_name - -$ sudo dnf remove app_name - -``` - -Updating apps is similarly easy. -``` -$ yum update - -$ sudo dnf upgrade --refresh - -``` - -As you can see, installing, uninstalling, and updating Linux apps from the command line isn't hard at all. In fact, once you get used to it, you'll find it's faster than using desktop GUI-based management tools! - -For more information on installing apps from the command line, please visit the Debian [Apt wiki][1], the [Yum cheat sheet][2], and the [DNF wiki][3]. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/how-install-software-linux-command-line - -作者:[Patrick H.Mullins][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/pmullins -[1]:https://wiki.debian.org/Apt -[2]:https://access.redhat.com/articles/yum-cheat-sheet -[3]:https://fedoraproject.org/wiki/DNF?rd=Dnf diff --git a/translated/tech/20180824 How to install software from the Linux command line.md b/translated/tech/20180824 How to install software from the Linux command line.md new file mode 100644 index 0000000000..efcc0ce464 --- /dev/null +++ b/translated/tech/20180824 How to install software from the Linux command line.md @@ -0,0 +1,106 @@ +如何从 Linux 命令行安装软件 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/suitcase_container_bag.png?itok=q40lKCBY) + +如果你在任何时间都使用 Linux,你很快就会发现有很多不同的方法可以做同样的事情。这包括通过命令行在 Linux 上安装应用。我已经是大约 25 年的 Linux 用户,我一次又一次地回到命令行来安装我的应用。 + +从命令行安装应用程序最常用的方法是使用称为包管理器的软件库(存储软件的地方)。所有 Linux 应用都作为软件包分发,这些软件包只不过是与软件包管理系统相关的文件。每个 Linux 发行版都附带一个包管理系统,但它们并不完全相同。 + +### 什么是包管理系统? + +包管理系统由多组工具和文件格式组成,它们一起用于安装、更新和卸载 Linux 应用。两种最常见的包管理系统来自 Red Hat 和 Debian。 Red Hat、CentOS 和 Fedora 都使用 `rpm` 系统(.rpm 文件),而Debian、Ubuntu、Mint 和 Ubuntu 都使用 `dpkg`(.deb 文件)。Gentoo Linux 使用名为 Portage 的系统,Arch Linux 只使用 tarball(.tar 文件)。这些系统之间的主要区别在于它们如何安装和维护应用。 + +你可能想知道 `.rpm`、`.deb` 或 `.tar` 文件中的内容。你可能会惊讶地发现,所有这些都只是普通的老式归档文件(如 `.zip`),其中包含应用的代码,如何安装它的说明,依赖项(它可能依赖的其他应用),以及配置文件的位置。读取和执行所有这些指令的软件称为包管理器。 + +### Debian、Ubuntu、Mint 等 + +Debian、Ubuntu、Mint 和其他基于 Debian 的发行版都使用 `.deb` 文件和 `dpkg` 包管理系统。有两种方法可以通过此系统安装应用。你可以使用 `apt` 程序从仓库进行安装,也可以使用 `dpkg` 程序从 `.deb` 文件安装应用。我们来看看如何做到这两点。 + +使用 `apt` 安装应用非常简单: +``` +$ sudo apt install app_name + +``` + +通过 `apt` 卸载应用也非常简单: +``` +$ sudo apt remove app_name + +``` + +要升级已安装的应用,首先需要更新应用仓库: +``` +$ sudo apt update + +``` + +完成后,你可以使用以下命令更新任何程序: +``` +$ sudo apt upgrade + +``` + +如果你只想更新一个应用,该怎么办?没问题。 +``` +$ sudo apt update app_name + +``` + +最后,假设你要安装的应用不存在于 Debian 仓库中,但有 `.deb` 下载。 +``` +$ sudo dpkg -i app_name.deb + +``` + +### Red Hat、CentOS 和 Fedora + +默认情况下,Red Hat 使用多个包管理系统。这些系统在使用自己的命令时,互相仍然非常相似,而且与 Debian 中使用的也相似。例如,我们可以使用 `yum` 或 `dnf` 管理器来安装应用。 +``` +$ sudo yum install app_name + +$ sudo dnf install app_name + +``` + +`.rpm` 格式的应用也可以使用 `rpm` 命令安装。 +``` +$ sudo rpm -i app_name.rpm + +``` + +删除不需要的应用同样容易。 +``` +$ sudo yum remove app_name + +$ sudo dnf remove app_name + +``` + +更新应用同样容易。 +``` +$ yum update + +$ sudo dnf upgrade --refresh + +``` + +如你所见,从命令行安装、卸载和更新 Linux 应用并不难。事实上,一旦你习惯它,你会发现它比使用基于桌面 GUI 的管理工具更快! + +有关从命令行安装应用程序的更多信息,请访问 Debian [Apt wiki][1]、[Yum 速查表][2] 和 [DNF wiki][3]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/how-install-software-linux-command-line + +作者:[Patrick H.Mullins][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/pmullins +[1]:https://wiki.debian.org/Apt +[2]:https://access.redhat.com/articles/yum-cheat-sheet +[3]:https://fedoraproject.org/wiki/DNF?rd=Dnf From 853fe8aa4e7c64b07eb2ebf3e0aa1acf22f205e7 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 6 Sep 2018 08:53:49 +0800 Subject: [PATCH 082/455] translating --- sources/tech/20180904 Why I love Xonsh.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180904 Why I love Xonsh.md b/sources/tech/20180904 Why I love Xonsh.md index 0bc485ee8d..a02fce1fe5 100644 --- a/sources/tech/20180904 Why I love Xonsh.md +++ b/sources/tech/20180904 Why I love Xonsh.md @@ -1,3 +1,5 @@ +translating---geekpi + Why I love Xonsh ====== From 1f8107143649b6398e6861ccafda7fa81572744c Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Thu, 6 Sep 2018 10:10:05 +0800 Subject: [PATCH 083/455] add translation tag --- ...GUIs to your programs and scripts easily with PySimpleGUI.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md b/sources/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md index 383d4c514f..1274e3574b 100644 --- a/sources/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md +++ b/sources/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md @@ -1,3 +1,5 @@ +pinewall translating + Add GUIs to your programs and scripts easily with PySimpleGUI ====== From e235e143387c92b9c5c2cc861c7803dcc43e51f9 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Thu, 6 Sep 2018 10:22:14 +0800 Subject: [PATCH 084/455] add translating tag --- .../20180727 How to analyze your system with perf and Python.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180727 How to analyze your system with perf and Python.md b/sources/tech/20180727 How to analyze your system with perf and Python.md index c1be98cc0e..ccc66b04a7 100644 --- a/sources/tech/20180727 How to analyze your system with perf and Python.md +++ b/sources/tech/20180727 How to analyze your system with perf and Python.md @@ -1,3 +1,5 @@ +pinewall translating + How to analyze your system with perf and Python ====== From d5a80aa4cec8b0ebd877072d683c25f9d57c8711 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 6 Sep 2018 10:56:28 +0800 Subject: [PATCH 085/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=208=20Linux=20comma?= =?UTF-8?q?nds=20for=20effective=20process=20management?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...mmands for effective process management.md | 268 ++++++++++++++++++ 1 file changed, 268 insertions(+) create mode 100644 sources/tech/20180904 8 Linux commands for effective process management.md diff --git a/sources/tech/20180904 8 Linux commands for effective process management.md b/sources/tech/20180904 8 Linux commands for effective process management.md new file mode 100644 index 0000000000..cddf56708c --- /dev/null +++ b/sources/tech/20180904 8 Linux commands for effective process management.md @@ -0,0 +1,268 @@ +8 Linux commands for effective process management +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg) + +Generally, an application process' lifecycle has three main states: start, run, and stop. Each state can and should be managed carefully if we want to be competent administrators. These eight commands can be used to manage processes through their lifecycles. + +### Starting a process + +The easiest way to start a process is to type its name at the command line and press Enter. If you want to start an Nginx web server, type **nginx**. Perhaps you just want to check the version. +``` +alan@workstation:~$ nginx + +alan@workstation:~$ nginx -v +nginx version: nginx/1.14.0 +``` + +### Viewing your executable path + +The above demonstration of starting a process assumes the executable file is located in your executable path. Understanding this path is key to reliably starting and managing a process. Administrators often customize this path for their desired purpose. You can view your executable path using **echo $PATH**. +``` +alan@workstation:~$ echo $PATH +/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin +``` + +#### WHICH + +Use the which command to view the full path of an executable file. +``` +alan@workstation:~$ which nginx                                                     +/opt/nginx/bin/nginx +``` + +I will use the popular web server software Nginx for my examples. Let's assume that Nginx is installed. If the command **which nginx** returns nothing, then Nginx was not found because which searches only your defined executable path. There are three ways to remedy a situation where a process cannot be started simply by name. The first is to type the full path. Although, I'd rather not have to type all of that, would you? +``` +alan@workstation:~$ /home/alan/web/prod/nginx/sbin/nginx -v +nginx version: nginx/1.14.0 +``` + +The second solution would be to install the application in a directory in your executable's path. However, this may not be possible, particularly if you don't have root privileges. + +The third solution is to update your executable path environment variable to include the directory where the specific application you want to use is installed. This solution is shell-dependent. For example, Bash users would need to edit the PATH= line in their .bashrc file. +``` +PATH="$HOME/web/prod/nginx/sbin:$PATH" +``` + +Now, repeat your echo and which commands or try to check the version. Much easier! +``` +alan@workstation:~$ echo $PATH +/home/alan/web/prod/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin + +alan@workstation:~$ which nginx +/home/alan/web/prod/nginx/sbin/nginx + +alan@workstation:~$ nginx -v                                                 +nginx version: nginx/1.14.0 +``` + +### Keeping a process running + +#### NOHUP + +A process may not continue to run when you log out or close your terminal. This special case can be avoided by preceding the command you want to run with the nohup command. Also, appending an ampersand (&) will send the process to the background and allow you to continue using the terminal. For example, suppose you want to run myprogram.sh. +``` +nohup myprogram.sh & +``` + +One nice thing nohup does is return the running process's PID. I'll talk more about the PID next. + +### Manage a running process + +Each process is given a unique process identification number (PID). This number is what we use to manage each process. We can also use the process name, as I'll demonstrate below. There are several commands that can check the status of a running process. Let's take a quick look at these. + +#### PS + +The most common is ps. The default output of ps is a simple list of the processes running in your current terminal. As you can see below, the first column contains the PID. +``` +alan@workstation:~$ ps +PID TTY          TIME CMD +23989 pts/0    00:00:00 bash +24148 pts/0    00:00:00 ps +``` + +I'd like to view the Nginx process I started earlier. To do this, I tell ps to show me every running process ( **-e** ) and a full listing ( **-f** ). +``` +alan@workstation:~$ ps -ef +UID        PID  PPID  C STIME TTY          TIME CMD +root         1     0  0 Aug18 ?        00:00:10 /sbin/init splash +root         2     0  0 Aug18 ?        00:00:00 [kthreadd] +root         4     2  0 Aug18 ?        00:00:00 [kworker/0:0H] +root         6     2  0 Aug18 ?        00:00:00 [mm_percpu_wq] +root         7     2  0 Aug18 ?        00:00:00 [ksoftirqd/0] +root         8     2  0 Aug18 ?        00:00:20 [rcu_sched] +root         9     2  0 Aug18 ?        00:00:00 [rcu_bh] +root        10     2  0 Aug18 ?        00:00:00 [migration/0] +root        11     2  0 Aug18 ?        00:00:00 [watchdog/0] +root        12     2  0 Aug18 ?        00:00:00 [cpuhp/0] +root        13     2  0 Aug18 ?        00:00:00 [cpuhp/1] +root        14     2  0 Aug18 ?        00:00:00 [watchdog/1] +root        15     2  0 Aug18 ?        00:00:00 [migration/1] +root        16     2  0 Aug18 ?        00:00:00 [ksoftirqd/1] +alan     20506 20496  0 10:39 pts/0    00:00:00 bash +alan     20520  1454  0 10:39 ?        00:00:00 nginx: master process nginx +alan     20521 20520  0 10:39 ?        00:00:00 nginx: worker process +alan     20526 20506  0 10:39 pts/0    00:00:00 man ps +alan     20536 20526  0 10:39 pts/0    00:00:00 pager +alan     20564 20496  0 10:40 pts/1    00:00:00 bash +``` + +You can see the Nginx processes in the output of the ps command above. The command displayed almost 300 lines, but I shortened it for this illustration. As you can imagine, trying to handle 300 lines of process information is a bit messy. We can pipe this output to grep to filter out nginx. +``` +alan@workstation:~$ ps -ef |grep nginx +alan     20520  1454  0 10:39 ?        00:00:00 nginx: master process nginx +alan     20521 20520  0 10:39 ?        00:00:00 nginx: worker process +``` + +That's better. We can quickly see that Nginx has PIDs of 20520 and 20521. + +#### PGREP + +The pgrep command was created to further simplify things by removing the need to call grep separately. +``` +alan@workstation:~$ pgrep nginx +20520 +20521 +``` + +Suppose you are in a hosting environment where multiple users are running several different instances of Nginx. You can exclude others from the output with the **-u** option. +``` +alan@workstation:~$ pgrep -u alan nginx +20520 +20521 +``` + +#### PIDOF + +Another nifty one is pidof. This command will check the PID of a specific binary even if another process with the same name is running. To set up an example, I copied my Nginx to a second directory and started it with the prefix set accordingly. In real life, this instance could be in a different location, such as a directory owned by a different user. If I run both Nginx instances, the **ps -ef** output shows all their processes. +``` +alan@workstation:~$ ps -ef |grep nginx +alan     20881  1454  0 11:18 ?        00:00:00 nginx: master process ./nginx -p /home/alan/web/prod/nginxsec +alan     20882 20881  0 11:18 ?        00:00:00 nginx: worker process +alan     20895  1454  0 11:19 ?        00:00:00 nginx: master process nginx +alan     20896 20895  0 11:19 ?        00:00:00 nginx: worker process +``` + +Using grep or pgrep will show PID numbers, but we may not be able to discern which instance is which. +``` +alan@workstation:~$ pgrep nginx +20881 +20882 +20895 +20896 +``` + +The pidof command can be used to determine the PID of each specific Nginx instance. +``` +alan@workstation:~$ pidof /home/alan/web/prod/nginxsec/sbin/nginx +20882 20881 + +alan@workstation:~$ pidof /home/alan/web/prod/nginx/sbin/nginx +20896 20895 +``` + +#### TOP + +The top command has been around a long time and is very useful for viewing details of running processes and quickly identifying issues such as memory hogs. Its default view is shown below. +``` +top - 11:56:28 up 1 day, 13:37,  1 user,  load average: 0.09, 0.04, 0.03 +Tasks: 292 total,   3 running, 225 sleeping,   0 stopped,   0 zombie +%Cpu(s):  0.1 us,  0.2 sy,  0.0 ni, 99.7 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st +KiB Mem : 16387132 total, 10854648 free,  1859036 used,  3673448 buff/cache +KiB Swap:        0 total,        0 free,        0 used. 14176540 avail Mem + +  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND +17270 alan      20   0 3930764 247288  98992 R   0.7  1.5   5:58.22 gnome-shell +20496 alan      20   0  816144  45416  29844 S   0.5  0.3   0:22.16 gnome-terminal- +21110 alan      20   0   41940   3988   3188 R   0.1  0.0   0:00.17 top +    1 root      20   0  225564   9416   6768 S   0.0  0.1   0:10.72 systemd +    2 root      20   0       0      0      0 S   0.0  0.0   0:00.01 kthreadd +    4 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 kworker/0:0H +    6 root       0 -20       0      0      0 I   0.0  0.0   0:00.00 mm_percpu_wq +    7 root      20   0       0      0      0 S   0.0  0.0   0:00.08 ksoftirqd/0 +``` + +The update interval can be changed by typing the letter **s** followed by the number of seconds you prefer for updates. To make it easier to monitor our example Nginx processes, we can call top and pass the PID(s) using the **-p** option. This output is much cleaner. +``` +alan@workstation:~$ top -p20881 -p20882 -p20895 -p20896 + +Tasks:   4 total,   0 running,   4 sleeping,   0 stopped,   0 zombie +%Cpu(s):  2.8 us,  1.3 sy,  0.0 ni, 95.9 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st +KiB Mem : 16387132 total, 10856008 free,  1857648 used,  3673476 buff/cache +KiB Swap:        0 total,        0 free,        0 used. 14177928 avail Mem + +  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND +20881 alan      20   0   12016    348      0 S   0.0  0.0   0:00.00 nginx +20882 alan      20   0   12460   1644    932 S   0.0  0.0   0:00.00 nginx +20895 alan      20   0   12016    352      0 S   0.0  0.0   0:00.00 nginx +20896 alan      20   0   12460   1628    912 S   0.0  0.0   0:00.00 nginx +``` + +It is important to correctly determine the PID when managing processes, particularly stopping one. Also, if using top in this manner, any time one of these processes is stopped or a new one is started, top will need to be informed of the new ones. + +### Stopping a process + +#### KILL + +Interestingly, there is no stop command. In Linux, there is the kill command. Kill is used to send a signal to a process. The most commonly used signal is "terminate" (SIGTERM) or "kill" (SIGKILL). However, there are many more. Below are some examples. The full list can be shown with **kill -L**. +``` + 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP + 6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1 +11) SIGSEGV     12) SIGUSR2     13) SIGPIPE     14) SIGALRM     15) SIGTERM + +``` + +Notice signal number nine is SIGKILL. Usually, we issue a command such as **kill -9 20896**. The default signal is 15, which is SIGTERM. Keep in mind that many applications have their own method for stopping. Nginx uses a **-s** option for passing a signal such as "stop" or "reload." Generally, I prefer to use an application's specific method to stop an operation. However, I'll demonstrate the kill command to stop Nginx process 20896 and then confirm it is stopped with pgrep. The PID 20896 no longer appears. +``` +alan@workstation:~$ kill -9 20896 +  +alan@workstation:~$ pgrep nginx +20881 +20882 +20895 +22123 +``` + +#### PKILL + +The command pkill is similar to pgrep in that it can search by name. This means you have to be very careful when using pkill. In my example with Nginx, I might not choose to use it if I only want to kill one Nginx instance. I can pass the Nginx option **-s** **stop** to a specific instance to kill it, or I need to use grep to filter on the full ps output. +``` +/home/alan/web/prod/nginx/sbin/nginx -s stop + +/home/alan/web/prod/nginxsec/sbin/nginx -s stop +``` + +If I want to use pkill, I can include the **-f** option to ask pkill to filter across the full command line argument. This of course also applies to pgrep. So, first I can check with **pgrep -a** before issuing the **pkill -f**. +``` +alan@workstation:~$ pgrep -a nginx +20881 nginx: master process ./nginx -p /home/alan/web/prod/nginxsec +20882 nginx: worker process +20895 nginx: master process nginx +20896 nginx: worker process +``` + +I can also narrow down my result with **pgrep -f**. The same argument used with pkill stops the process. +``` +alan@workstation:~$ pgrep -f nginxsec +20881 +                                            +alan@workstation:~$ pkill -f nginxsec +``` + +The key thing to remember with pgrep (and especially pkill) is that you must always be sure that your search result is accurate so you aren't unintentionally affecting the wrong processes. + +Most of these commands have many command line options, so I always recommend reading the [man page][1] on each one. While most of these exist across platforms such as Linux, Solaris, and BSD, there are a few differences. Always test and be ready to correct as needed when working at the command line or writing scripts. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/linux-commands-process-management + +作者:[Alan Formy-Duval][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/alanfdoss +[1]: https://www.kernel.org/doc/man-pages/ From 9f3ad7d8c3be39d293fb0236caf88f765eaa2c5c Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 6 Sep 2018 11:03:53 +0800 Subject: [PATCH 086/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Run=20?= =?UTF-8?q?MS-DOS=20Games=20And=20Programs=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Run MS-DOS Games And Programs In Linux.md | 253 ++++++++++++++++++ 1 file changed, 253 insertions(+) create mode 100644 sources/tech/20180905 How To Run MS-DOS Games And Programs In Linux.md diff --git a/sources/tech/20180905 How To Run MS-DOS Games And Programs In Linux.md b/sources/tech/20180905 How To Run MS-DOS Games And Programs In Linux.md new file mode 100644 index 0000000000..0552fb3d09 --- /dev/null +++ b/sources/tech/20180905 How To Run MS-DOS Games And Programs In Linux.md @@ -0,0 +1,253 @@ +How To Run MS-DOS Games And Programs In Linux +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/dosbox-720x340.png) + +If you ever wanted to try some good-old MS-DOS games and defunct C++ compilers like Turbo C++ in Linux? Good! This tutorial will teach you how to run MS-DOS games and programs under Linux environment using **DOSBox**. It is an x86 PC DOS-emulator that can be used to run classic DOS games or programs. DOSBox emulates an Intel x86 PC with sound, graphics, mouse, joystick, and modem etc., that allows you to run many old MS-DOS games and programs that simply cannot be run on any modern PCs and operating systems, such as Microsoft Windows XP and later, Linux and FreeBSD. It is free, written using C++ programming language and distributed under GPL. + +### Install DOSBox In Linux + +DOSBox is available in the default repositories of most Linux distributions. + +On Arch Linux and its variants like Antergos, Manjaro Linux: +``` +$ sudo pacman -S dosbox + +``` + +On Debian, Ubuntu, Linux Mint: +``` +$ sudo apt-get install dosbox + +``` + +On Fedora: +``` +$ sudo dnf install dosbox + +``` + +### Configure DOSBox + +There is no initial configuration required to use DOSBox and it just works out of the box. The default configuration file named `dosbox-x.xx.conf` exists in your **`~/.dosbox`** folder. In this configuration file, you can edit/modify various settings, such as starting DOSBox in fullscreen mode, use double buffering in fullscreen, set preferred resolution to use for fullscreen, mouse sensitivity, enable or disable sound, speaker, joystick and a lot more. As I mentioned earlier, the default settings will work just fine. You need not to make any changes. + +### Run MS-DOS Games And Programs In Linux + +To launch DOSBox, run the following command from the Terminal: +``` +$ dosbox + +``` + +This is how DOSBox interface looks like. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Dosbox-prompt.png) + +As you can see, DOSBox comes with its own DOS-like command prompt with a virtual `Z:\` Drive, so if you’re familiar with MS-DOS, you wouldn’t find any difficulties to work in DOSBox environment. + +Here is the output of `dir`command (Equivalent of `ls` command in Linux) output: + +![](http://www.ostechnix.com/wp-content/uploads/2018/09/dir-command-output.png) + +If you’re a new user and it is the first time you use DOSBox, you can view the short introduction about DOSBox by entering the following command in DOSBox prompt: +``` +intro + +``` + +Press ENTER to go through next page of the introduction section. + +To view the list of most often used commands in DOS, use this command: +``` +help + +``` + +To view list of all supported commands in DOSBox, type: +``` +help /all + +``` + +Remember, these commands should be used in the DOSBox prompt, not in your Linux Terminal. + +DOSBox also supports a good set of keyboard bindings. Here is the default keyboard shortcuts to effectively use DOSBox. + +![](http://www.ostechnix.com/wp-content/uploads/2018/09/Dosbox-keyboard-shortcuts.png) + +To exit from DOSBox, simply type and hit ENTER: +``` +exit + +``` + +By default, DOSBox starts with a normal window-sized screen like above. + +To start dosbox directly in fullscreen, edit your `dosbox-x.xx.conf` file and set the value of **fullscreen** variable as **enable**. Now, DosBox will start in fullscreen mode. To go back to normal screen, press **ALT+ENTER**. + +Hope you get the basic usage of DOSBox. + +Let us go ahead and install some DOS programs and games. + +First, we need to create directories to save the programs and games in our Linux system. I am going to create two directories named **`~/dosprograms`** and **`~/dosgames`** , the first one for storing programs and latter for storing games. +``` +$ mkdir ~/dosprograms ~/dosgames + +``` + +For the purpose of this guide, I will show you how to install **Turbo C++** program and Mario game. First, we will see how to install Turbo. + +Download the latest Turbo C++ compiler, extract it and save the contents file in **`~/dosprograms`** directory. I have save the contents turbo c++ in my **~/dosprograms/TC/** directory. +``` +$ ls dosprograms/tc/ +BGI BIN CLASSLIB DOC EXAMPLES FILELIST.DOC INCLUDE LIB README README.COM + +``` + +Start Dosbox: +``` +$ dosbox + +``` + +And mount the **`~/dosprograms`** directory as virtual drive **C:\** in DOSBox. +``` +Z:\>mount c ~/dosprograms + +``` + +You will see an output something like below. +``` +Drive C is mounted as local directory /home/sk/dosprograms. + +``` + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Dosbox-prompt-1.png) + +Now, change to the C drive using command: +``` +Z:\>c: + +``` + +And then, switch to **tc/bin** directory: +``` +Z:\>cd tc/bin + +``` + +Finally, run turbo c++ executable file: +``` +Z:\>tc.exe + +``` + +**Note:** Just type first few letters and hit ENTER to autocomplete the file name. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Dosbox-prompt-4.png) + +You will now be in Turbo C++ console. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Dosbox-prompt-5.png) + +Create new file (ATL+F) and start coding: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Dosbox-prompt-6.png) + +Similarly, you can install and run other classic DOS programs. + +**Troubleshooting:** + +You might be encountered with following error while running turbo c++ or any other dos programs: +``` +DOSBox switched to max cycles, because of the setting: cycles=auto. If the game runs too fast try a fixed cycles amount in DOSBox's options. Exit to error: DRC64:Unhandled memory reference + +``` + +To fix this, edit your **~/.dosbox/dosbox-x.xx.conf** file: +``` +$ nano ~/.dosbox/dosbox-0.74.conf + +``` + +Find the following variable and change its value from: +``` +core=auto + +``` + +to +``` +core=normal + +``` + +Save and close the file. Now you can be able to run the dos programs without any problems. + +Now, let us see how to run a dos-based game, for example **Mario Bros VGA**. + +Download Mario game from [**here**][1] and extract the contents in **~/dosgames** directory in your Linux machine. + +Start DOSBox: +``` +$ dosbox + +``` + +We have used virtual drive **c:** for dos programs. For games, let us use **d:** as virtual drive. + +At the DOSBox prompt, run the following command to mount **~/dosgames** directory as virtuald drive **d**. +``` +Z:\>mount d ~/dosgames + +``` + +Switch to D: drive: +``` +Z:\>d: + +``` + +And then go to mario game directory and run the **mario.exe** file to launch the game. +``` +Z:\>cd mario + +Z:\>mario.exe + +``` + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Dosbox-prompt-7.png) + +Start playing the game: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Mario-game-in-dosbox.png) + +Similarly, you can run any dos-based games as described above. You can view the complete list of supported games that can be run using DOSBox [**here**][2]. + +### Conclusion + +Even though DOSBOX is not a complete replacement for MS-DOS and it lacks many of the features found in MS-DOS, it is just enough to install and run most DOS games and programs. + +For more details, refer the official [**DOSBox manual**][3]. + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-run-ms-dos-games-and-programs-in-linux/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://www.dosgames.com/game/mario-bros-vga +[2]: https://www.dosbox.com/comp_list.php +[3]: https://www.dosbox.com/DOSBoxManual.html From 245bf2c547358a2926c7fec722b8db0ab62bce2a Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 6 Sep 2018 11:05:31 +0800 Subject: [PATCH 087/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Find=20your=20sys?= =?UTF-8?q?tems=20easily=20on=20a=20LAN=20with=20mDNS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... your systems easily on a LAN with mDNS.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 sources/tech/20180905 Find your systems easily on a LAN with mDNS.md diff --git a/sources/tech/20180905 Find your systems easily on a LAN with mDNS.md b/sources/tech/20180905 Find your systems easily on a LAN with mDNS.md new file mode 100644 index 0000000000..ca21d2b66b --- /dev/null +++ b/sources/tech/20180905 Find your systems easily on a LAN with mDNS.md @@ -0,0 +1,108 @@ +Find your systems easily on a LAN with mDNS +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/09/mDNS-816x345.jpg) + +Multicast DNS, or mDNS, lets systems broadcast queries on a local network to find other resources by name. Fedora users often own multiple Linux systems on a router without sophisticated name services. In that case, mDNS lets you talk to your multiple systems by name — without touching the router in most cases. You also don’t have to keep files like /etc/hosts in sync on all the local systems. This article shows you how to set it up. + +mDNS is a zero-configuration networking service that’s been around for quite a while. Fedora ships Avahi, a zero-configuration stack that includes mDNS, as part of Workstation. (mDNS is also part of Bonjour, found on Mac OS.) + +This article assumes you have two systems running supported versions of Fedora (27 or 28). Their host names are meant to be castor and pollux. + +### Installing packages + +Make sure the nss-mdns and avahi packages are installed on your system. You might have a different version, which is fine: +``` +$ rpm -q nss-mdns avahi +nss-mdns-0.14.1-1.fc28.x86_64 +avahi-0.7-13.fc28.x86_64 + +``` + +Fedora Workstation provides both of these packages by default. If not present, install them: +``` +$ sudo dnf install nss-mdns avahi + +``` + +Make sure the avahi-daemon.service unit is enabled and running. Again, this is the default on Fedora Workstation. +``` +$ sudo systemctl enable --now avahi-daemon.service + +``` + +Although optional, you might also want to install the avahi-tools package. This package includes a number of handy utilities for checking how well the zero-configuration services on your system are working. Use this sudo command: +``` +$ sudo dnf install avahi-tools + +``` + +The /etc/nsswitch.conf file controls which services your system uses to resolve services, and in what order. You should see a line like this in that file: +``` +hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname + +``` + +Notice the commands mdns4_minimal [NOTFOUND=return]. They tell your system to use the multicast DNS resolver to resolve a hostname to an IP address. Even if that service works, the remaining services are tried if the name doesn’t resolve. + +If you don’t see a configuration similar to this, you can edit it (as the root user). However, the nss-mdns package handles this for you. Remove and reinstall that package to fix the file, if you’re uncomfortable editing it yourself. + +Follow the steps above for **both systems**. + +### Setting host name and testing + +Now that you’ve done the common configuration work, set up each host’s name in one of these ways: + + 1. If you’re using Fedora Workstation, [you can use this procedure][1]. + + 2. If not, use hostnamectl to do the honors. Do this for the first box: +``` +$ hostnamectl set-hostname castor + +``` + + 3. You can also edit the /etc/avahi/avahi-daemon.conf file, remove the comment on the host-name setting line, and set the name there. By default, though, Avahi uses the system provided host name, so you **shouldn’t** need this method. + +Next, restart the Avahi daemon so it picks up changes: +``` +$ sudo systemctl restart avahi-daemon.service + +``` + +Then set your other box properly: +``` +$ hostnamectl set-hostname pollux +$ sudo systemctl restart avahi-daemon.service + +``` + +As long as your network router is not disallowing mDNS traffic, you should now be able to login to castor and ping the other box. You should use the default .local domain name so resolution works correctly: +``` +$ ping pollux.local +PING pollux.local (192.168.0.1) 56(84) bytes of data. +64 bytes from 192.168.0.1 (192.168.0.1): icmp_seq=1 ttl=64 time=3.17 ms +64 bytes from 192.168.0.1 (192.168.0.1): icmp_seq=2 ttl=64 time=1.24 ms +... + +``` + +The same trick should also work from pollux if you ping castor.local. It’s much more convenient now to access your systems around the network! + +Moreover, don’t be surprised if your router advertises services. Modern WiFi and wired routers often provide these services to make life easier for consumers. + +This process works for most systems. However, if you run into trouble, use avahi-browse and other tools from the avahi-tools package to see what services are available. + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/find-systems-easily-lan-mdns/ + +作者:[Paul W. Frields][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[1]: https://fedoramagazine.org/set-hostname-fedora/ From ad41119b26fff78064f437ac3ec3306102b19530 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 6 Sep 2018 11:08:16 +0800 Subject: [PATCH 088/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20Create?= =?UTF-8?q?=20a=20Slideshow=20of=20Photos=20in=20Ubuntu=2018.04=20and=20ot?= =?UTF-8?q?her=20Linux=20Distributions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ntu 18.04 and other Linux Distributions.md | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 sources/talk/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md diff --git a/sources/talk/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md b/sources/talk/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md new file mode 100644 index 0000000000..370e31c6a9 --- /dev/null +++ b/sources/talk/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md @@ -0,0 +1,68 @@ +How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions +====== +Creating a slideshow of photos is a matter of a few clicks. Here’s how to make a slideshow of pictures in Ubuntu 18.04 and other Linux distributions. + +![How to create slideshow of photos in Ubuntu Linux][1] + +Imagine yourself in a situation where your friends and family are visiting you and request you to show the pictures of a recent event/trip. + +You have the photos saved on your computers, neatly in a separate folder. You invite everyone near the computer. You go to the folder, click on one of the pictures and start showing them the photos one by one by pressing the arrow keys. + +But that’s tiring! It will be a lot better if those images get changed automatically every few seconds. + +That’s called a slideshow and I am going to show you how to create a slideshow of photos in Ubuntu. This will allow you to loop pictures from a folder and display them in fullscreen mode. + +### Creating photo slideshow in Ubuntu 18.04 and other Linux distributions + +While you could use several image viewers for this purpose, I am going to show you two of the most popular tools that should be available in most distributions. + +#### Method 1: Photo slideshow with GNOME’s default image viewer + +If you are using GNOME in Ubuntu 18.04 or any other distribution, you are in luck. The default image viewer of Gnome, Eye of GNOME, is well capable of displaying the slideshow of pictures in the current folder. + +Just click on one of the pictures and you’ll see the settings option on the top right side of the application menu. It looks like three bars stacked over the top of one another. + +You’ll see several options here. Check the Slideshow box and it will go fullscreen displaying the images. + +![How to create slideshow of photos in Ubuntu Linux][2] + +By default, the images change at an interval of 5 seconds. You can change the slideshow interval by going to the Preferences->Slideshow. + +![change slideshow interval in Ubuntu][3]Changing slideshow interval + +#### Method 2: Photo slideshow with Shotwell Photo Manager + +[Shotwell][4] is a popular [photo management application for Linux][5]. and available for all major Linux distributions. + +If it is not installed already, search for Shotwell in your distribution’s software center and install it. + +Shotwell works slightly different. If you directly open a photo in Shotwell Viewer, you won’t see preferences or options for a slideshow. + +For slideshow and other options, you have to open Shotwell and import the folders containing those pictures. Once you have imported the folder in here, select that folder from left side-pane and then click on View in the menu. You should see the option of Slideshow here. Just click on it to create the slideshow of all the images in the selected folder. + +![How to create slideshow of photos in Ubuntu Linux][6] + +You can also change the slideshow settings. This option is presented when the images are displayed in the full view. Just hover the mouse to the lower bottom and you’ll see a settings option appearing. + +#### It’s easy to create photo slideshow + +As you can see, it’s really simple to create slideshow of photos in Linux. I hope you find this simple tip useful. If you have questions or suggestions, please let me know in the comment section below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/photo-slideshow-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/Create-photos-Slideshow-Linux.png +[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/create-slideshow-photos-ubuntu-gnome.jpeg +[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/change-slideshow-interval-gnome-image.jpeg +[4]: https://wiki.gnome.org/Apps/Shotwell +[5]: https://itsfoss.com/linux-photo-management-software/ +[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/create-slideshow-photos-shotwell.jpeg From b60a844e0e6527f887952a0e166fc920a2fb1dbc Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 6 Sep 2018 11:10:01 +0800 Subject: [PATCH 089/455] add done: 20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md --- ...how of Photos in Ubuntu 18.04 and other Linux Distributions.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sources/{talk => tech}/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md (100%) diff --git a/sources/talk/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md b/sources/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md similarity index 100% rename from sources/talk/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md rename to sources/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md From 5bb7453f3b09b17f464b400ca5c242ca9313c174 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 6 Sep 2018 11:13:47 +0800 Subject: [PATCH 090/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=205=20tips=20to=20i?= =?UTF-8?q?mprove=20productivity=20with=20zsh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...5 tips to improve productivity with zsh.md | 290 ++++++++++++++++++ 1 file changed, 290 insertions(+) create mode 100644 sources/tech/20180905 5 tips to improve productivity with zsh.md diff --git a/sources/tech/20180905 5 tips to improve productivity with zsh.md b/sources/tech/20180905 5 tips to improve productivity with zsh.md new file mode 100644 index 0000000000..c1ad0d988c --- /dev/null +++ b/sources/tech/20180905 5 tips to improve productivity with zsh.md @@ -0,0 +1,290 @@ +5 tips to improve productivity with zsh +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/features_solutions_command_data.png?itok=4_VQN3RK) + +The Z shell known as [zsh][1] is a [shell][2] for Linux/Unix-like operating systems. It has similarities to other shells in the `sh` (Bourne shell) family, such as as `bash` and `ksh`, but it provides many advanced features and powerful command line editing options, such as enhanced Tab completion. + +It would be impossible to cover all the options of zsh here; there are literally hundreds of pages [documenting][3] its many features. In this article, I'll present five tips to make you more productive using the command line with zsh. + +### 1\. Themes and plugins + +Through the years, the open source community has developed countless themes and plugins for zsh. A theme is a predefined prompt configuration, while a plugin is a set of useful aliases and functions that make it easier to use a specific command or programming language. + +The quickest way to get started using themes and plugins is to use a zsh configuration framework. There are many available, but the most popular is [Oh My Zsh][4]. By default, it enables some sensible zsh configuration options and it comes loaded with hundreds of themes and plugins. + +A theme makes you more productive as it adds useful information to your prompt, such as the status of your Git repository or Python virtualenv in use. Having this information at a glance saves you from typing the equivalent commands to obtain it, and it's a cool look. Here's an example of [Powerlevel9k][5], my theme of choice: + +![zsh Powerlevel9K theme][7] + +The Powerlevel9k theme for zsh + +In addition to themes, Oh My Zsh bundles tons of useful plugins for zsh. For example, enabling the Git plugin gives you access to a number of useful aliases, such as: +``` +$ alias | grep -i git | sort -R | head -10 +g=git +ga='git add' +gapa='git add --patch' +gap='git apply' +gdt='git diff-tree --no-commit-id --name-only -r' +gau='git add --update' +gstp='git stash pop' +gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' +gcs='git commit -S' +glg='git log --stat' +``` + +There are plugins available for many programming languages, packaging systems, and other tools you commonly use on the command line. Here's a list of plugins I use in my Fedora workstation: +``` +git golang fedora docker oc sudo vi-mode virtualenvwrapper +``` + +### 2\. Clever aliases + +Aliases are very useful in zsh. Defining aliases for your most-used commands saves you a lot of typing. Oh My Zsh configures several useful aliases by default, including aliases to navigate directories and replacements for common commands with additional options such as: +``` +ls='ls --color=tty' +grep='grep  --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}' +``` + +In addition to command aliases, zsh enables two additional useful alias types: the suffix alias and the global alias. + +A suffix alias allows you to open the file you type in the command line using the specified program based on the file extension. For example, to open YAML files using vim, define the following alias: +``` +alias -s {yml,yaml}=vim +``` + +Now if you type any file name ending with `yml` or `yaml` in the command line, zsh opens that file using vim: +``` +$ playbook.yml +# Opens file playbook.yml using vim +``` + +A global alias enables you to create an alias that is expanded anywhere in the command line, not just at the beginning. This is very useful to replace common filenames or piped commands. For example: +``` +alias -g G='| grep -i' +``` + +To use this alias, type `G` anywhere you would type the piped command: +``` +$ ls -l G do +drwxr-xr-x.  5 rgerardi rgerardi 4096 Aug  7 14:08 Documents +drwxr-xr-x.  6 rgerardi rgerardi 4096 Aug 24 14:51 Downloads +``` + +Next, let's see how zsh helps to navigate the filesystem. + +### 3\. Easy directory navigation + +When you're using the command line, navigating across different directories is one of the most common tasks. Zsh makes this easier by providing some useful directory navigation features. These features are enabled with Oh My Zsh, but you can enable them by using this command: +``` +setopt  autocd autopushd \ pushdignoredups +``` + +With these options set, you don't need to type `cd` to change directories. Just type the directory name, and zsh switches to it: +``` +$ pwd +/home/rgerardi +$ /tmp +$ pwd +/tmp +``` + +To move back, type `-`: + +Zsh keeps the history of directories you visited so you can quickly switch to any of them. To see the list, type `dirs -v`: +``` +$ dirs -v +0       ~ +1       /var/log +2       /var/opt +3       /usr/bin +4       /usr/local +5       /usr/lib +6       /tmp +7       ~/Projects/Opensource.com/zsh-5tips +8       ~/Projects +9       ~/Projects/ansible +10      ~/Documents +``` + +Switch to any directory in this list by typing `~#` where # is the number of the directory in the list. For example: +``` +$ pwd +/home/rgerardi +$ ~4 +$ pwd +/usr/local +``` + +Combine these with aliases to make it even easier to navigate: +``` +d='dirs -v | head -10' +1='cd -' +2='cd -2' +3='cd -3' +4='cd -4' +5='cd -5' +6='cd -6' +7='cd -7' +8='cd -8' +9='cd -9' +``` + +Now you can type `d` to see the first ten items in the list and the number to switch to it: +``` +$ d +0       /usr/local +1       ~ +2       /var/log +3       /var/opt +4       /usr/bin +5       /usr/lib +6       /tmp +7       ~/Projects/Opensource.com/zsh-5tips +8       ~/Projects +9       ~/Projects/ansible +$ pwd +/usr/local +$ 6 +/tmp +$ pwd +/tmp +``` + +Finally, zsh automatically expands directory names with Tab completion. Type the first letters of the directory names and `TAB` to use it: +``` +$ pwd +/home/rgerardi +$ p/o/z (TAB) +$ Projects/Opensource.com/zsh-5tips/ +``` + +This is just one of the features enabled by zsh's powerful Tab completion system. Let's look at some more. + +### 4\. Advanced Tab completion + +Zsh's powerful completion system is one of its hallmarks. For simplification, I call it Tab completion, but under the hood, more than one thing is happening. There's usually expansion and command completion. I'll discuss them together here. For details, check this [User's Guide][8]. + +Command completion is enabled by default with Oh My Zsh. To enable it, add the following lines to your `.zshrc` file: +``` +autoload -U compinit +compinit +``` + +Zsh's completion system is smart. It tries to suggest only items that can be used in certain contexts—for example, if you type `cd` and `TAB`, zsh suggests only directory names as it knows `cd` does not work with anything else. + +Conversely, it suggests usernames when running user-related commands or hostnames when using `ssh` or `ping`, for example. + +It has a vast completion library and understands many different commands. For example, if you're using the `tar` command, you can press Tab to see a list of files available in the package as candidates for extraction: +``` +$ tar -xzvf test1.tar.gz test1/file1 (TAB) +file1 file2 +``` + +Here's a more advanced example, using `git`. In this example, when typing `TAB`, zsh automatically completes the name of the only file in the repository that can be staged: +``` +$ ls +original  plan.txt  zsh-5tips.md  zsh_theme_small.png +$ git status +On branch master +Your branch is up to date with 'origin/master'. + +Changes not staged for commit: +  (use "git add ..." to update what will be committed) +  (use "git checkout -- ..." to discard changes in working directory) + +        modified:   zsh-5tips.md + +no changes added to commit (use "git add" and/or "git commit -a") +$ git add (TAB) +$ git add zsh-5tips.md +``` + +It also understands command line options and suggests only the ones that are relevant to the subcommand selected: +``` +$ git commit - (TAB) +--all                  -a       -- stage all modified and deleted paths +--allow-empty                   -- allow recording an empty commit +--allow-empty-message           -- allow recording a commit with an empty message +--amend                         -- amend the tip of the current branch +--author                        -- override the author name used in the commit +--branch                        -- show branch information +--cleanup                       -- specify how the commit message should be cleaned up +--date                          -- override the author date used in the commit +--dry-run                       -- only show the list of paths that are to be committed or not, and any untracked +--edit                 -e       -- edit the commit message before committing +--file                 -F       -- read commit message from given file +--gpg-sign             -S       -- GPG-sign the commit +--include              -i       -- update the given files and commit the whole index +--interactive                   -- interactively update paths in the index file +--message              -m       -- use the given message as the commit message +... TRUNCATED ... +``` + +After typing `TAB`, you can use the arrow keys to navigate the options list and select the one you need. Now you don't need to memorize all those Git options. + +There are many options available. The best way to find what is most helpful to you is by using it. + +### 5\. Command line editing and history + +Zsh's command line editing capabilities are also useful. By default, it emulates emacs. If, like me, you prefer vi/vim, enable vi bindings with the following command: +``` +$ bindkey -v +``` + +If you're using Oh My Zsh, the `vi-mode` plugin enables additional bindings and a mode indicator on your prompt—very useful. + +After enabling vi bindings, you can edit the command line using vi commands. For example, press `ESC+/` to search the command line history. While searching, pressing `n` brings the next matching line, and `N` the previous one. Most common vi commands work after pressing `ESC` such as `0` to jump to the start of the line, `$` to jump to the end, `i` to insert, `a` to append, etc. Even commands followed by motion work, such as `cw` to change a word. + +In addition to command line editing, zsh provides several useful command line history features if you want to fix or re-execute previous used commands. For example, if you made a mistake, typing `fc` brings the last command in your favorite editor to fix it. It respects the `$EDITOR` variable and by default uses vi. + +Another useful command is `r`, which re-executes the last command; and `r `, which executes the last command that contains the string `WORD`. + +Finally, typing double bangs (`!!`) brings back the last command anywhere in the line. This is useful, for instance, if you forgot to type `sudo` to execute commands that require elevated privileges: +``` +$ less /var/log/dnf.log +/var/log/dnf.log: Permission denied +$ sudo !! +$ sudo less /var/log/dnf.log +``` + +These features make it easier to find and re-use previously typed commands. + +### Where to go from here? + +These are just a few of the zsh features that can make you more productive; there are many more. For additional information, consult the following resources: + +[An Introduction to the Z Shell][9] + +[A User's Guide to ZSH][10] + +[Archlinux Wiki][11] + +[zsh-lovers][12] + +Do you have any zsh productivity tips to share? I would love to hear about them in the comments below. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/tips-productivity-zsh + +作者:[Ricardo Gerardi][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rgerardi +[1]: http://www.zsh.org/ +[2]: https://en.wikipedia.org/wiki/Shell_(computing) +[3]: http://zsh.sourceforge.net/Doc/Release/zsh_toc.html +[4]: https://ohmyz.sh/ +[5]: https://github.com/bhilburn/powerlevel9k +[7]: https://opensource.com/sites/default/files/uploads/zsh_theme_small.png (zsh Powerlevel9K theme) +[8]: http://zsh.sourceforge.net/Guide/zshguide06.html#l144 +[9]: http://zsh.sourceforge.net/Intro/intro_toc.html +[10]: http://zsh.sourceforge.net/Guide/ +[11]: https://wiki.archlinux.org/index.php/zsh +[12]: https://grml.org/zsh/ From 7336eacf8077ec5196fc862c6e829cc7c7fc4b57 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 6 Sep 2018 11:33:24 +0800 Subject: [PATCH 091/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=208=20great=20Pytho?= =?UTF-8?q?n=20libraries=20for=20side=20projects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...reat Python libraries for side projects.md | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 sources/tech/20180905 8 great Python libraries for side projects.md diff --git a/sources/tech/20180905 8 great Python libraries for side projects.md b/sources/tech/20180905 8 great Python libraries for side projects.md new file mode 100644 index 0000000000..b901e2c4c7 --- /dev/null +++ b/sources/tech/20180905 8 great Python libraries for side projects.md @@ -0,0 +1,66 @@ +8 great Python libraries for side projects +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd) + +We have a saying in the Python/Django world: We came for the language and stayed for the community. That is true for most of us, but something else that has kept us in the Python world is how easy it is to have an idea and quickly work through it over lunch or in a few hours at night. + +This month we're diving into Python libraries we love to use to quickly scratch those side-project or lunchtime itches. + +### To save data in a database on the fly: Dataset + +[Dataset][1] is our go-to library when we quickly want to collect data and save it into a database before we know what our final database tables will look like. Dataset has a simple, yet powerful API that makes it easy to put data in and sort it out later. + +Dataset is built on top of SQLAlchemy, so extending it will feel familiar. The underlying database models are a breeze to import into Django using Django's built-in [inspectdb][2] management command. This makes working with existing databases pretty painless. + +### To scrape data from web pages: Beautiful Soup + +[Beautiful Soup][3] (BS4 as of this writing) makes extracting information out of HTML pages easy. It's our go-to anytime we need to turn unstructured or loosely structured HTML into structured data. It's also great for working with XML data that might otherwise not be readable. + +### To work with HTTP content: Requests + +[Requests][4] is arguably one of the gold standard libraries for working with HTTP content. Anytime we need to consume an HTML page or even an API, Requests has us covered. It's also very well documented. + +### To write command-line utilities: Click + +When we need to write a native Python script, [Click][5] is our favorite library for writing command-line utilities. The API is straightforward, well thought out, and there are only a few patterns to remember. The docs are great, which makes looking up advanced features easy. + +### To name things: Python Slugify + +As we all know, naming things is hard. [Python Slugify][6] is a useful library for turning a title or description into a unique(ish) identifier. If you are working on a web project and you want to use SEO-friendly URLs, Python Slugify makes this easier. + +### To work with plugins: Pluggy + +[Pluggy][7] is relatively new, but it's also one of the best and easiest ways to add a plugin system to your existing application. If you have ever worked with pytest, you have used pluggy without knowing it. + +### To convert CSV files into APIs: Datasette + +[Datasette][8], not to be confused with Dataset, is an amazing tool for easily turning CSV files into full-featured read-only REST JSON APIs. Datasette has tons of features, including charting and geo (for creating interactive maps), and it's easy to deploy via a container or third-party web host. + +### To handle environment variables and more: Envparse + +If you need to parse environment variables because you don't want to save API keys, database credentials, or other sensitive information in your source code, then [envparse][9] is one of your best bets. Envparse handles environment variables, ENV files, variable types, and even pre- and post-processors (in case you want to ensure that a variable is always upper or lower case, for instance). + +Do you have a favorite Python library for side projects that's not on this list? Please share it in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/python-libraries-side-projects + +作者:[Jeff Triplett][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/laceynwilliams +[1]: https://dataset.readthedocs.io/en/latest/ +[2]: https://docs.djangoproject.com/en/2.1/ref/django-admin/#django-admin-inspectdb +[3]: https://www.crummy.com/software/BeautifulSoup/ +[4]: http://docs.python-requests.org/ +[5]: http://click.pocoo.org/5/ +[6]: https://github.com/un33k/python-slugify +[7]: https://pluggy.readthedocs.io/en/latest/ +[8]: https://github.com/simonw/datasette +[9]: https://github.com/rconradharris/envparse From 203c019e61c2ea0913f30b01ecd822f83543d13c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=B3=A5?= Date: Thu, 6 Sep 2018 11:53:51 +0800 Subject: [PATCH 092/455] first commmit --- ...eb File Manager With Console And Editor.md | 83 ++++++++++--------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md b/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md index 0b842e32b1..3e6d24ca67 100644 --- a/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md +++ b/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md @@ -1,37 +1,38 @@ fuzheng1998 translating ====== -Cloud Commander – A Web File Manager With Console And Editor +Cloud Commander – 一个有控制台和编辑器在Web 上的文件管家 ====== ![](https://www.ostechnix.com/wp-content/uploads/2016/05/Cloud-Commander-A-Web-File-Manager-With-Console-And-Editor-720x340.png) -**Cloud commander** is a web-based file manager application that allows you to view, access, and manage the files and folders of your system from any computer, mobile, and tablet Pc via a web browser. It has two simple and classic panels, and automatically converts it’s size as per your device’s display size. It also has two built-in editors namely **Dword** and **Edward** with support of Syntax-highlighting and one **Console** with support of your system’s command line. So you can edit your files on the go. Cloud Commander server is a cross-platform application that runs on Linux, Windows and Mac OS X operating systems, and the client will run on any web browser. It is written using **JavaScript/Node.Js** , and is licensed under **MIT**. +**Cloud Commander** 是一个基于 web 的文件管理程序,它允许你通过任何计算机、移动端或平板电脑的 web 浏览器查看、访问或管理系统文件或文件夹。他有两个简单而又经典的面板,并且会自动。It has two simple and classic panels, and automatically converts it’s size as per your device’s display size. It also has two built-in editors namely **Dword** and **Edward** with support of Syntax-highlighting and one **Console** with support of your system’s command line. So you can edit your files on the go. Cloud Commander server is a cross-platform application that runs on Linux, Windows and Mac OS X operating systems, and 客户端将在任何一款浏览器上运行the client will run on any web browser. 它是用 **JavaScript/Node.Js**,and is licensed under **MIT**. -In this brief tutorial, let us see how to install Cloud Commander in Ubuntu 18.04 LTS server. +在这个简易教程中,让我们看一看如何在 Ubuntu 18.04 LTS 服务器上安装 Cloud Commander。 -### Prerequisites +### 前提条件 -As I mentioned earlier, Cloud Commander is written using Node.Js. So, in order to install Cloud Commander we need to install Node.Js first. To do so, refer the following guide. +像我之前提到的,是用 Node.js 写的。所以为了安装 Cloud Commander,我们需要首先安装 Node.js。To do so, refer the following guide. -### Install Cloud Commander +### 安装 Cloud Commander -After installing Node.Js, run the following command to install Cloud Commander: +在安装 Node.js 之后,运行下列命令安装 Cloud Commander: ``` $ npm i cloudcmd -g ``` -Congratulations! Cloud Commander has been installed. Let us go ahead and see the basic usage of Cloud Commander. +祝贺!Cloud Commander 已经被安装了。让我们往下继续看看 Cloud Commander 的基本使用。 -### Getting started with Cloud Commander +### 开始使用 Cloud Commander -Run the following command to start Cloud Commander: +运行以下命令启动 Cloud Commander: ``` $ cloudcmd ``` -**Sample output:** +**输出示例:** + ``` url: http://localhost:8000 @@ -43,82 +44,82 @@ From now on, you can create, delete, view, manage files or folders right in the ![][2] -As you can see in the above screenshot, Cloud Commander has two panels, ten hotkeys (F1 to F10), and Console. +当你看见上面的截图时,Clouder Commander 有两个面板,十个热键 (F1 to F10),和控制台。 -Each hotkey does a unique job. +每个热键执行的都是一个任务。 - * F1 – Help - * F2 – Rename file/folder - * F3 – View files and folders - * F4 – Edit files - * F5 – Copy files/folders - * F6 – Move files/folders - * F7 – Create new directory - * F8 – Delete file/folder - * F9 – Open Menu - * F10 – Open config + * F1 – 帮助 + * F2 – 重命名文件/文件夹 + * F3 – 查看文件/文件夹 + * F4 – 编辑文件 + * F5 – 复制文件/文件夹 + * F6 – 移动文件/文件夹 + * F7 – 创建新目录 + * F8 – 删除文件/文件夹 + * F9 – 打开菜单 + * F10 – 打开设置 -#### Cloud Commander console +#### Cloud Commmander 控制台 -Click on the Console icon. This will open your default system’s shell. +点击控制台图标。 This will open your default system’s shell. ![][3] -From this console you can do all sort of administration tasks such as installing packages, removing packages, update your system etc. You can even shutdown or reboot system. Therefore, Cloud Commander is not just a file manager, but also has the functionality of a remote administration tool. +在此控制台中,您可以执行各种管理任务,例如安装软件包,删除软件包,更新系统等。您甚至可以关闭或重新引导系统。 因此,Cloud Commander 不仅仅是一个文件管理器,还具有远程管理工具的功能。 -#### Creating files/folders +#### 创建文件/文件夹 -To create a new file or folder Right click on any empty place and go to **New - >File or Directory**. +要创建新的文件或文件夹 Right click on any empty place and go to **New - >File or Directory**. ![][4] -#### View files +#### 查看文件 -You can view pictures, watch audio and video files. +你可以查看图片,查看音视频文件。 ![][5] -#### Upload files +#### 上传文件 -The other cool feature is we can easily upload a file to Cloud Commander system from any system or device. +另一个很酷的特性是我们可以从任何系统或设备简单地上传一个文件到 Cloud Commander 系统。 -To upload a file, right click on any empty space in the Cloud Commander panel, and click on the **Upload** option. +要上传文件,右键单击 Cloud Commander 面板的任意空白处,并且单击**上传**选项。 ![][6] -Select the files you want to upload. +选择你想要上传的文件。 Also, you can upload files from the Cloud services like Google drive, Dropbox, Amazon cloud drive, Facebook, Twitter, Gmail, GtiHub, Picasa, Instagram and many. -To upload files from Cloud, right click on any empty space in the panel and select **Upload from Cloud**. +要从云端上传文件, 右键单击面板的任意空白处,并且右键单击面板任意空白处并选择**从云端上传**。 ![][7] -Select any web service of your choice, for example Google drive. Click **Connect to Google drive** button. +选择任意一个你选择的网络服务,例如谷歌云盘。点击**连接到谷歌云盘**按钮。 ![][8] -In the next step, authenticate your google drive with Cloud Commander. Finally, select the files from your Google drive and click **Upload**. +下一步,用 Cloud Commander 验证你的谷歌云端硬盘,从谷歌云端硬盘选择文件并点击**上传**。 ![][9] -#### Update Cloud Commander +#### 更新 Cloud Commander -To update Cloud Commander to the latest available version, run the following command: +要更新到最新的可提供版本,执行下面的命令: ``` $ npm update cloudcmd -g ``` -#### Conclusion +#### 总结 As far as I tested Cloud Commander, It worked like charm. I didn’t face a single issue during the testing in my Ubuntu server. Also, Cloud Commander is not just a web-based file manager, but also acts as a remote administration tool that performs most Linux administration tasks. You can create a files/folders, rename, delete, edit, and view them. Also, You can install, update, upgrade, and remove any package as the way you do in the local system from the Terminal. And, of course, you can even shutdown or restart the system from the Cloud Commander console itself. What do you need more? Give it a try, you will find it useful. That’s all for now. I will be here soon with another interesting article. Until then, stay tuned with OSTechNix. -Cheers! +祝贺! From 68d092aa4736217928f37e74e64999554d06b765 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 6 Sep 2018 21:53:29 +0800 Subject: [PATCH 093/455] PRF:20180226 Linux Virtual Machines vs Linux Live Images.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @sober-wang 本篇翻译质量不好,翻译应当用心。 --- ...x Virtual Machines vs Linux Live Images.md | 53 ++++++++++--------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md index 9e73c63ede..f45b04cd48 100644 --- a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md +++ b/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md @@ -1,56 +1,59 @@ -Linxu 虚拟机 vs Linux 实体机 +Linux 虚拟机与 Linux 现场镜像版 ====== -首先我得承认,我非常倾向于频繁尝试新的[ linux 发行版本 ][1],我的目标是为了解决每一个 Linux 发行版的依赖,所以我用一些方法来测试它们。在一些文章中,我们将会看到两种运行 Linux 的模式,虚拟机或实体机。每一种方式都存在优势,但是有一些障碍会伴随着这两种方式。 -### 第一时间测试一个新的 Linux 发行版 +> Linux 虚拟机与 Linux 现场镜像版各有优势,也有不足。 -为了第一时间去做 Linux 发型版本的依赖测试,我把它们运行在我目前所拥有的所有类型的 PC 上。如果我用我的台式机,我将运行一个 Linux 虚拟机做测试。使用这种方法的原因是,不仅仅是生活环境下我可以下载测并测试发行版,但也会用稳定的生产环境安装。 +首先我得承认,我非常喜欢频繁尝试新的 [Linux 发行版本][1]。然而,我用来测试它们的方法根据每次目标而有所不同。在这篇文章中,我们来看看两种运行 Linux 的模式:虚拟机或现场镜像版live image。每一种方式都存在优势,但是也有一些不足。 -在另一方面,如果我在工作中我的PC不具备强力的硬件条件的,在一个虚拟机上测试 Linux 发型版本的时候将会产生相反的效果。老实的讲,我会将电脑性能压榨到极限,如果在经济条件服务的情况下我会使用实体机运行 Linux 镜像替代虚拟机 +### 首次测试一个全新的 Linux 发行版 -### 在一个新的 Linux 发行版本上运行旅游软件 +当我首次测试一个全新 Linux 发行版时,我使用的方法很大程度上依赖于我当前所拥有的 PC 资源。如果我使用台式机,我会在一台虚拟机中运行该发行版来测试。使用这种方法的原因是,我可以下载并测试该发行版,不只是在一个现场环境中,而且也可以作为一个带有持久存储的安装的系统。 -如果你有兴趣查看发行版本的桌面环境或购买软件,你不能因为发行版本的一个实时图片而诽谤它。一个生活环境提供给你希望的鸟瞰全局的视角,如何使用户体验更好是由应用程序提供的。 +另一方面,如果我的 PC 不具备强劲的硬件,那么通过 Linux 的虚拟机安装来测试发行版是适得其反的。我会将那台 PC 压榨到它的极限,诚然,更好的是使用现场版的 Linux 映像,而不是从闪存驱动器中运行。 -公平的说,一个虚拟化安装你也可以做同样的事,但是它有点不好,如果这么做你将要消除硬件上的许多数据。毕竟这是一个简单的发行版。记得我说过在第一部分-我做测试喜欢在虚拟机上运行 Linux 。这个方式我就能看见如何去安装它,使用镜像安装时你讲看不见有区别的操作和其他工作原理。 +### 体验新的 Linux 发行版本的软件 -通常你仅能看见一个关于发行版本的简短介绍,关于功能用最少的阻力和时间投入,是解决这个问题的好办法。 +如果你有兴趣查看发行版本的桌面环境或可用的软件,那使用它的现场镜像版就没错了。一个现场版环境可以提供给你所预期的全局视角、其所提供的软件和用户体验的整体感受。 -### 随身携带一个 +公平的说,你也可以在虚拟机上达到同样的效果,但是它有一点不好,如果这么做会让更多数据填满你的磁盘空间。毕竟这只是对发行版的一个简单体验。记得我在第一节说过:我喜欢在虚拟机上运行 Linux 来做测试。用这个方式我就能看到如何去安装它、分区是怎么样的等等,而使用现场镜像版时你就看不到这些。 -这个话题虽然不像几年前那样普遍,使用 Linux 发行版的能力可能是许多用户所顾虑的。明显,适合他们自己携带的系统,虚拟机是无法提供的。无论如何,一个 Linux 发行版本的镜像是具有可移植性的。一个镜像能够轻松的写入到 DVD 或者 Flash 存储设备中。 +这种体验方式通常表明你只想对该发行版本有个大致了解,所以在这种情况下,这种只需要付出最小的精力和时间的方式是一种不错的办法。 -在 Linux 可移植性的概念上花费时间,这有益于在一个朋友的电脑上使用 Flash 存储设备安装镜像版 Linux 。这个授权使你能证明 Linux 能充实他们的生活,虽然在他们的 PC 上运行一个虚拟机是不可靠的。在喜爱使用镜像的用户哪里,它是双赢的。 +### 随身携带一个发行版 -### 选择做双系统 Linux +这种方式虽然不像几年前那样普遍,这种随身携带一个 Linux 发行版的能力也许是出于对某些用户的考虑。显然,虚拟机安装对于便携性并无太多帮助。不过,现场镜像版实际上是十分便携的。现场镜像版可以写入到 DVD 当中或复制到一个闪存盘中而便于携带。 -这是一个巨大的项目。考虑一些事,例如你在使用 Windows .你喜欢玩 Linux ,但是宁可不获取插件。在一些出状况或考虑你不是拥有单独分区,双系统将是一个问题。不管什么样的情况,同时使用 Linux 虚拟机和镜像系统都对于你是一个很好的选择。 +从 Linux 的便携性这个概念上展开来说,当要在一个朋友的电脑上展示 Linux 如何工作,使用一个闪存盘上的现场镜像版也是很方便的。这可以使你能演示 Linux 如何丰富他们的生活,而不用必须在他们的 PC 上运行一个虚拟机。使用现场镜像版这就有点双赢的感觉了。 -现在,我在一些事物上采取奇怪的立场。长期运行 Linux 镜像在 Flash 存储或虚拟机,我知道你将为了更多的价值走更远。对于这个说法有两个原因。第一个,在 Windows 中安装一个虚拟机 VS 真正的运行的 Linux 。第二,用一个持续的存储设备你的 Flash 存储,安装 Linux 和你的数据。 +### 选择做双引导 Linux -我知道你会说用一个虚拟机运行 Linux 也是如此,无论如何你都无法升级到用镜像安装的地步。为什么?你不会更新你的宿主系统或者客户系统。记住,有一些发行 Linux 发行版本被设定为只能在持久存储中运行。Puppy Linux 就是一个非常好的例子。它仅能运行在个人 PC 上,否则它将进入死循环或被丢弃,它允许你永远不被单调的系统省级困扰,由于发行版会安全的处理这些更新。它不是一个正常的 Linux 发行版,有一个持久的免费镜像这样的方式用一堵墙个离开,多么可怕。 +这接下来的方式是个大工程。考虑一下,也许你是一个 Windows 用户。你喜欢玩 Linux,但又不愿意冒险。除了在某些情况下会出些状况或者识别个别分区时遇到问题,双引导方式就没啥挑剔的。无论如何,使用 Linux 虚拟机或现场镜像版都对于你来说是一个很好的选择。 -### Linux 虚拟机是一个绝好的选择 +现在,我在某些事情上采取了奇怪的立场。我认为长期在闪存盘上运行现场镜像版要比虚拟机更有价值。这有两个原因。首先,您将会习惯于真正运行 Linux,而不是在 Windows 之上的虚拟机中运行它。其次,您可以设置闪存盘以包含持久存储的用户数据。 -我就讲到这里,这篇文章是时候结束了。Virtual Box 绝对是一个非常不错的运行 Linux 虚拟机的虚拟化产品。 +我知道你会说用一个虚拟机运行 Linux 也是如此,然而,使用现场镜像版的方式,你绝不会因为更新而被破坏任何东西。为什么?因为你不会更新你的宿主系统或者客户系统。请记住,有整个 Linux 发行版本被设计为持久存储的 Linux 发行版。Puppy Linux 就是一个非常好的例子。它不仅能运行在要被回收或丢弃的个人 PC 上,它也可以让你永远不被频繁的系统升级所困扰,这要感谢该发行版处理安全更新的方式。这不是一个常规的 Linux 发行版,而是以这样的一种方式封闭了安全问题——即持久存储的现场镜像版中没有什么令人担心的坏东西。 -例如,我制作了一个录像,里面介绍和评论了许多 Linux 发行版。硬件安装或者虚拟机安装一个从 Linux 发行版镜像库获得的镜像,一个实时的操作我们需要通过屏幕去捕获它。很明显,虚拟机运行 Linux 和 镜像安装更适合。 +### Linux 虚拟机绝对是一个最好的选择 -一旦你需要在音频资料中采集到混音,这没有问题,那如果你用软件去采集你的信息,为了一个合理的采集环境,你将需要一个本地安装的系统,这里面包含了所有的基本要求。在一次,用一个硬件安装方式,但是这开销可能很大,如果你仅仅是用与视频和音频操作,这需要花费一部分时间。 +在我结束这篇文章时,让我告诉你。有一种场景下,使用 Virtual Box 等虚拟机绝对比现场镜像版更好:记录 Linux 发行版的桌面环境。 -### Linux 虚拟机 VS Linux 镜像 +例如,我制作了一个视频,里面介绍和点评了许多 Linux 发行版。使用现场镜像版进行此操作需要我用硬件设备捕获屏幕,或者从现场镜像版的软件仓库中安装捕获软件。显然,虚拟机比 Linux 发行版的现场镜像版更适合这项工作。 -你最喜欢尝试新发行版的方式是那些?也许,你会格式化磁盘,然后豁出去了,因此,不需要任何理由 +一旦你需要采集音频进行混音,毫无疑问,如果您要使用软件来捕获您的点评语音,那么您肯定希望拥有一个宿主操作系统,里面包含了一个起码的捕获环境的所有基本需求。同样,您可以使用硬件设备来完成所有这一切,但如果您只是做兼职的视频/音频捕获, 那么这可能要付出成本高昂的代价。 -大多数人告诉我他们喜欢上面的方法,但是我很像知道哪种方式更加适合你。点击评论,让我知道在 Linux 发行世界最伟大和最新的版本时,您更喜欢哪种方法。 +### Linux 虚拟机 VS. Linux 现场镜像版 + +你最喜欢尝试新发行版的方式是哪些?也许,你是那种可以很好地格式化磁盘、将风险置之脑后的人,所以这里说的这些都是没用的? + +我在网上互动的大多数人都倾向于遵循我上面提及的方法,但是我很想知道哪种方式更加适合你。点击评论框,让我知道在体验 Linux 发行版世界最伟大和最新的版本时,您更喜欢哪种方法。 -------------------------------------------------------------------------------- via: https://www.datamation.com/open-source/linux-virtual-machines-vs-linux-live-images.html 作者:[Matt Hartley][a] -译者:[sober-wang](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[sober-wang](https://github.com/sober-wang) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From d302c0304b7c9bafb86d91ca9d8ba8e2eed21795 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 6 Sep 2018 21:54:31 +0800 Subject: [PATCH 094/455] PUB:20180226 Linux Virtual Machines vs Linux Live Images.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @sober-wang 本篇首发地址: https://linux.cn/article-9984-1.html 你的 LCTT 专页地址:https://linux.cn/lctt/sober-wang --- .../20180226 Linux Virtual Machines vs Linux Live Images.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180226 Linux Virtual Machines vs Linux Live Images.md (100%) diff --git a/translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md b/published/20180226 Linux Virtual Machines vs Linux Live Images.md similarity index 100% rename from translated/tech/20180226 Linux Virtual Machines vs Linux Live Images.md rename to published/20180226 Linux Virtual Machines vs Linux Live Images.md From 6a06caf44b2fe94ceb8e69faf815e438c8c2fb7f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 6 Sep 2018 22:11:27 +0800 Subject: [PATCH 095/455] PRF:20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md @geekpi --- ...Ys Without Using Function Keys In Linux.md | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/translated/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md b/translated/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md index 5ca31d8351..0b27f921c8 100644 --- a/translated/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md +++ b/translated/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md @@ -3,86 +3,85 @@ ![](https://www.ostechnix.com/wp-content/uploads/2018/08/Switch-Between-TTYs-720x340.png) -本简要指南介绍了在类 Unix 操作系统中如何在不使用功能键的情况下切换 TTY。在进一步讨论之前,我们将了解 TTY 是什么。正如在 AskUbuntu 论坛的一个[**答案**][1]中所提到的,**TTY**这个词来自 **T**ele **TY** pewriter。在 Unix 的早期,连接到计算机的用户终端就是机电电传机或电传打字机(简称 tty)。从那时起,TTY 这个名称继续用于纯文本控制台。如今,所有文本控制台都代表虚拟控制台,而不是物理控制台。TTY 命令打印连接到标准输入的终端的文件名。 +本简要指南介绍了在类 Unix 操作系统中如何在不使用功能键的情况下切换 TTY。在进一步讨论之前,我们将了解 TTY 是什么。正如在 AskUbuntu 论坛的一个[答案][1]中所提到的,**TTY**这个词来自 **T**ele**TY**pewriter(电传打字机)。在 Unix 的早期,连接到计算机的用户终端就是机电的电传机或电传打字机(简称 tty)。从那时起,TTY 这个名称继续用于纯文本控制台。如今,所有文本控制台都代表虚拟控制台,而不是物理控制台。TTY 命令打印连接到标准输入的终端的文件名。 ### 在 Linux 中切换 TTY -默认情况下,Linux 中有 7 个 tty。它们被称为 tty1、tty2。。。tty7。1 到 6 tty 只是命令行。第 7 个 tty 是 GUI(你的 X 桌面会话)。你可以使用 **CTRL+ALT+Fn** 键在不同的 TTY 之间切换。例如,要切换到 tty1,我们按下 CTRL+ALT+F1。这就是 tty1 在 Ubuntu 18.04 LTS 服务器中的样子。 +默认情况下,Linux 中有 7 个 tty。它们被称为 tty1、tty2……tty7。1 到 6 的 tty 只是命令行。第 7 个 tty 是 GUI(你的 X 桌面会话)。你可以使用 `CTRL+ALT+Fn` 键在不同的 TTY 之间切换。例如,要切换到 tty1,我们按下 `CTRL+ALT+F1`。这就是 tty1 在 Ubuntu 18.04 LTS 服务器中的样子。 ![](https://www.ostechnix.com/wp-content/uploads/2018/08/tty1.png) -如果你的系统没有 X 会话, +如果你的系统没有 X 会话, 只需要按下 `Alt+Fn` 键,不需要按下 `CTRL`。 -在某些 Linux 版本中(例如,从 Ubuntu 17.10 开始),登录页面开始使用虚拟控制台 1。因此,你需要按 CTRL+ALT+F3 到 CTRL+ALT+F6 来访问虚拟控制台。要返回桌面环境,请在 Ubuntu 17.10 及更高版本上按下 CTRL+ALT+F2 或 CTRL+ALT+F7。 +在某些 Linux 版本中(例如,从 Ubuntu 17.10 开始),登录屏开始使用 1 号虚拟控制台。因此,你需要按 `CTRL+ALT+F3` 到 `CTRL+ALT+F6` 来访问虚拟控制台。要返回桌面环境,请在 Ubuntu 17.10 及更高版本上按下 `CTRL+ALT+F2` 或 `CTRL+ALT+F7`。 -目前为止我们看到我们可以使用 CTRL+ALT+功能键(F1-F7)在 TTY 之间轻松切换。但是,如果出于任何原因你不想使用功能键,那么在 Linux 中有一个名为 **“chvt”** 的简单命令。 +目前为止我们看到我们可以使用 `CTRL+ALT+Fn`(`F1` - `F7`)在 TTY 之间轻松切换。但是,如果出于任何原因你不想使用功能键,那么在 Linux 中有一个名为 `chvt` 的简单命令。 -“chvt N” 命令让你切换到前台终端 N,这与按 CTRL+ALT+Fn 相同。如果它不存在,则创建相应的屏幕。 +`chvt N` 命令让你切换到前台终端 N,这与按 `CTRL+ALT+Fn` 相同。如果它不存在,则创建相应的屏幕。 + +让我们试试显示当前的 tty: -让我们试试打印当前的 tty: ``` $ tty - ``` 我的 Ubuntu 18.04 LTS 服务器的示例输出。 +![](https://www.ostechnix.com/wp-content/uploads/2018/08/tty-command-output.png) + 现在让我们切换到 tty2。为此,请输入: + ``` $ sudo chvt 2 - ``` -记住你需要在 chvt 命令中使用 “sudo”。 +记住你需要在 `chvt` 命令一同使用 `sudo`。 现在,使用命令检查当前的 tty: + ``` $ tty - ``` 你会看到 tty 现在已经改变了。 -同样,你可以使用 “sudo chvt 3” 切换到 tty3,使用 “sudo chvt 4” 切换到 tty4 等等。 +同样,你可以使用 `sudo chvt 3` 切换到 tty3,使用 `sudo chvt 4` 切换到 tty4 等等。 -当任何一个功能键不起作用时,chvt 命令会很有用。 +当任何一个功能键不起作用时,`chvt` 命令会很有用。 要查看活动虚拟控制台的总数,请运行: + ``` $ fgconsole 2 - ``` -如你所见,我的系统中有两个活动的 VT。 +如你所见,我的系统中有两个活动的虚拟终端。 你可以使用以下命令查看下一个未分配的虚拟终端: + ``` $ fgconsole --next-available 3 - ``` 如果虚拟控制台不是前台控制台,并且它没有打开任何进程来读取或写入,并且未在其屏幕上选择任何文本,则它是未使用的。 -要移除未使用的 VT,只需键入: +要移除未使用的虚拟终端,只需键入: + ``` $ deallocvt - ``` 上面的命令为所有未使用的虚拟控制台释放内核内存和数据结构。简单地说,此命令将释放连接到未使用的虚拟控制台的所有资源。 有关更多详细信息,请参阅相应命令的手册页。 + ``` $ man tty - $ man chvt - $ man fgconsole - $ man deallocvt - ``` 就是这些了。希望这很有用。还有更多的好东西。敬请关注! @@ -90,7 +89,6 @@ $ man deallocvt 干杯! - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-switch-between-ttys-without-using-function-keys-in-linux/ @@ -98,7 +96,7 @@ via: https://www.ostechnix.com/how-to-switch-between-ttys-without-using-function 作者:[SK][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 50f81e94519e49fe282f64b58372a5524dc0216e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 6 Sep 2018 22:11:56 +0800 Subject: [PATCH 096/455] PUB:20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md @geekpi https://linux.cn/article-9985-1.html --- ...To Switch Between TTYs Without Using Function Keys In Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md (100%) diff --git a/translated/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md b/published/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md similarity index 100% rename from translated/tech/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md rename to published/20180822 How To Switch Between TTYs Without Using Function Keys In Linux.md From ab59520c1159468a7fa0a51480fec53e5ac9502d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 6 Sep 2018 22:30:40 +0800 Subject: [PATCH 097/455] PRF:20180529 How To Add Additional IP (Secondary IP) In Ubuntu System.md @MjSeven --- ...onal IP (Secondary IP) In Ubuntu System.md | 343 +++++++++--------- 1 file changed, 174 insertions(+), 169 deletions(-) diff --git a/translated/tech/20180529 How To Add Additional IP (Secondary IP) In Ubuntu System.md b/translated/tech/20180529 How To Add Additional IP (Secondary IP) In Ubuntu System.md index 53d9a090ba..37a95c6b0b 100644 --- a/translated/tech/20180529 How To Add Additional IP (Secondary IP) In Ubuntu System.md +++ b/translated/tech/20180529 How To Add Additional IP (Secondary IP) In Ubuntu System.md @@ -12,92 +12,98 @@ Linux 管理员应该意识到这一点,因为这是一项例行任务。很 这是业界的最佳实践,它允许用户安装 SSL 证书。大多数系统都配有单块网卡,这足以添加额外的 IP 地址。 **建议阅读:** -**(#)** [在 Linux 命令行中 9 种方法检查公共 IP 地址][1] -**(#)** [在 Linux 终端中 3 种简单的方式来检查 DNS(域名服务器)记录][2] -**(#)** [在 Linux 上使用 Dig 命令检查 DNS(域名服务器)记录][3] -**(#)** [在 Linux 上使用 Nslookup 命令检查 DNS(域名服务器)记录][4] -**(#)** [在 Linux 上使用 Host 命令检查 DNS(域名服务器)记录][5] + +- [在 Linux 命令行中 9 种方法检查公共 IP 地址][1] +- [在 Linux 终端中 3 种简单的方式来检查 DNS(域名服务器)记录][2] +- [在 Linux 上使用 Dig 命令检查 DNS(域名服务器)记录][3] +- [在 Linux 上使用 Nslookup 命令检查 DNS(域名服务器)记录][4] +- [在 Linux 上使用 Host 命令检查 DNS(域名服务器)记录][5] 我们可以在同一个接口上添加 IP 地址,或者在同一设备上创建子接口,然后在其中添加 IP。默认情况下,一直到 Ubuntu 14.04 LTS,接口给名称为 `ethX (eth0)`,但是从 Ubuntu 15.10 之后网络接口名称已从 `ethX` 更改为 `enXXXXX`(对于服务器是 ens33,桌面版是 enp0s3)。 在本文中,我们将教你如何在 Ubuntu 上执行此操作,并且衍生到其它发行版(to 校正:这句自己加的)。 -**`注意:`**别在 DNS 详细信息后添加 IP 地址。如果是这样,DNS 将无法正常工作。 +**注意:**别在 DNS 详细信息后添加 IP 地址。如果是这样,DNS 将无法正常工作。 ### 如何在 Ubuntu 14.04 LTS 中添加临时辅助 IP 地址 在系统中添加 IP 地址之前,运行以下任一命令即可验证服务器主 IP 地址: + ``` # ifconfig - -or +或 +# ip addr # ip addr -eth0 Link encap:Ethernet HWaddr 08:00:27:98:b7:36 - inet addr:192.168.56.150 Bcast:192.168.56.255 Mask:255.255.255.0 - inet6 addr: fe80::a00:27ff:fe98:b736/64 Scope:Link - UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 - RX packets:4 errors:0 dropped:0 overruns:0 frame:0 - TX packets:105 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:902 (902.0 B) TX bytes:16423 (16.4 KB) +eth0 Link encap:Ethernet HWaddr 08:00:27:98:b7:36 + inet addr:192.168.56.150 Bcast:192.168.56.255 Mask:255.255.255.0 + inet6 addr: fe80::a00:27ff:fe98:b736/64 Scope:Link + UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 + RX packets:4 errors:0 dropped:0 overruns:0 frame:0 + TX packets:105 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:1000 + RX bytes:902 (902.0 B) TX bytes:16423 (16.4 KB) -eth1 Link encap:Ethernet HWaddr 08:00:27:6a:cf:d3 - inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0 - inet6 addr: fe80::a00:27ff:fe6a:cfd3/64 Scope:Link - UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 - RX packets:80 errors:0 dropped:0 overruns:0 frame:0 - TX packets:146 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:8698 (8.6 KB) TX bytes:17047 (17.0 KB) - -lo Link encap:Local Loopback - inet addr:127.0.0.1 Mask:255.0.0.0 - inet6 addr: ::1/128 Scope:Host - UP LOOPBACK RUNNING MTU:65536 Metric:1 - RX packets:25 errors:0 dropped:0 overruns:0 frame:0 - TX packets:25 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1 - RX bytes:1730 (1.7 KB) TX bytes:1730 (1.7 KB) +eth1 Link encap:Ethernet HWaddr 08:00:27:6a:cf:d3 + inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0 + inet6 addr: fe80::a00:27ff:fe6a:cfd3/64 Scope:Link + UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 + RX packets:80 errors:0 dropped:0 overruns:0 frame:0 + TX packets:146 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:1000 + RX bytes:8698 (8.6 KB) TX bytes:17047 (17.0 KB) +lo Link encap:Local Loopback + inet addr:127.0.0.1 Mask:255.0.0.0 + inet6 addr: ::1/128 Scope:Host + UP LOOPBACK RUNNING MTU:65536 Metric:1 + RX packets:25 errors:0 dropped:0 overruns:0 frame:0 + TX packets:25 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:1 + RX bytes:1730 (1.7 KB) TX bytes:1730 (1.7 KB) ``` 如我所见,服务器主 IP 地址是 `192.168.56.150`,我将下一个 IP `192.168.56.151` 作为辅助 IP,使用以下方法完成: + ``` # ip addr add 192.168.56.151/24 broadcast 192.168.56.255 dev eth0 label eth0:1 - ``` 输入以下命令以检查新添加的 IP 地址。如果你重新启动服务器,那么新添加的 IP 地址会消失,因为我们的 IP 是临时添加的。 + ``` # ip addr -1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 - link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 - inet 127.0.0.1/8 scope host lo - valid_lft forever preferred_lft forever - inet6 ::1/128 scope host - valid_lft forever preferred_lft forever -2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 - link/ether 08:00:27:98:b7:36 brd ff:ff:ff:ff:ff:ff - inet 192.168.56.150/24 brd 192.168.56.255 scope global eth0 - valid_lft forever preferred_lft forever - inet 192.168.56.151/24 brd 192.168.56.255 scope global secondary eth0:1 - valid_lft forever preferred_lft forever - inet6 fe80::a00:27ff:fe98:b736/64 scope link - valid_lft forever preferred_lft forever -3: eth1: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 - link/ether 08:00:27:6a:cf:d3 brd ff:ff:ff:ff:ff:ff - inet 10.0.3.15/24 brd 10.0.3.255 scope global eth1 - valid_lft forever preferred_lft forever - inet6 fe80::a00:27ff:fe6a:cfd3/64 scope link - valid_lft forever preferred_lft forever - +1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 + inet 127.0.0.1/8 scope host lo + valid_lft forever preferred_lft forever + inet6 ::1/128 scope host + valid_lft forever preferred_lft forever +2: eth0: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 08:00:27:98:b7:36 brd ff:ff:ff:ff:ff:ff + inet 192.168.56.150/24 brd 192.168.56.255 scope global eth0 + valid_lft forever preferred_lft forever + inet 192.168.56.151/24 brd 192.168.56.255 scope global secondary eth0:1 + valid_lft forever preferred_lft forever + inet6 fe80::a00:27ff:fe98:b736/64 scope link + valid_lft forever preferred_lft forever +3: eth1: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 08:00:27:6a:cf:d3 brd ff:ff:ff:ff:ff:ff + inet 10.0.3.15/24 brd 10.0.3.255 scope global eth1 + valid_lft forever preferred_lft forever + inet6 fe80::a00:27ff:fe6a:cfd3/64 scope link + valid_lft forever preferred_lft forever ``` ### 如何在 Ubuntu 14.04 LTS 中添加永久辅助 IP 地址 要在 Ubuntu 系统上添加永久辅助 IP 地址,只需编辑 `/etc/network/interfaces` 文件并添加所需的 IP 详细信息。 + +``` +# vi /etc/network/interfaces +``` + ``` # vi /etc/network/interfaces @@ -108,61 +114,60 @@ iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static - address 192.168.56.150 - netmask 255.255.255.0 - network 192.168.56.0 - broadcast 192.168.56.255 - gateway 192.168.56.1 + address 192.168.56.150 + netmask 255.255.255.0 + network 192.168.56.0 + broadcast 192.168.56.255 + gateway 192.168.56.1 auto eth0:1 iface eth0:1 inet static - address 192.168.56.151 - netmask 255.255.255.0 - + address 192.168.56.151 + netmask 255.255.255.0 ``` 保存并关闭文件,然后重启网络接口服务。 + ``` # service networking restart -or +或 # ifdown eth0:1 && ifup eth0:1 - ``` 验证新添加的 IP 地址: + ``` # ifconfig -eth0 Link encap:Ethernet HWaddr 08:00:27:98:b7:36 - inet addr:192.168.56.150 Bcast:192.168.56.255 Mask:255.255.255.0 - inet6 addr: fe80::a00:27ff:fe98:b736/64 Scope:Link - UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 - RX packets:5 errors:0 dropped:0 overruns:0 frame:0 - TX packets:84 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:962 (962.0 B) TX bytes:11905 (11.9 KB) +eth0 Link encap:Ethernet HWaddr 08:00:27:98:b7:36 + inet addr:192.168.56.150 Bcast:192.168.56.255 Mask:255.255.255.0 + inet6 addr: fe80::a00:27ff:fe98:b736/64 Scope:Link + UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 + RX packets:5 errors:0 dropped:0 overruns:0 frame:0 + TX packets:84 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:1000 + RX bytes:962 (962.0 B) TX bytes:11905 (11.9 KB) -eth0:1 Link encap:Ethernet HWaddr 08:00:27:98:b7:36 - inet addr:192.168.56.151 Bcast:192.168.56.255 Mask:255.255.255.0 - UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 +eth0:1 Link encap:Ethernet HWaddr 08:00:27:98:b7:36 + inet addr:192.168.56.151 Bcast:192.168.56.255 Mask:255.255.255.0 + UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 -eth1 Link encap:Ethernet HWaddr 08:00:27:6a:cf:d3 - inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0 - inet6 addr: fe80::a00:27ff:fe6a:cfd3/64 Scope:Link - UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 - RX packets:4924 errors:0 dropped:0 overruns:0 frame:0 - TX packets:3185 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1000 - RX bytes:4037636 (4.0 MB) TX bytes:422516 (422.5 KB) - -lo Link encap:Local Loopback - inet addr:127.0.0.1 Mask:255.0.0.0 - inet6 addr: ::1/128 Scope:Host - UP LOOPBACK RUNNING MTU:65536 Metric:1 - RX packets:0 errors:0 dropped:0 overruns:0 frame:0 - TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 - collisions:0 txqueuelen:1 - RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) +eth1 Link encap:Ethernet HWaddr 08:00:27:6a:cf:d3 + inet addr:10.0.3.15 Bcast:10.0.3.255 Mask:255.255.255.0 + inet6 addr: fe80::a00:27ff:fe6a:cfd3/64 Scope:Link + UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 + RX packets:4924 errors:0 dropped:0 overruns:0 frame:0 + TX packets:3185 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:1000 + RX bytes:4037636 (4.0 MB) TX bytes:422516 (422.5 KB) +lo Link encap:Local Loopback + inet addr:127.0.0.1 Mask:255.0.0.0 + inet6 addr: ::1/128 Scope:Host + UP LOOPBACK RUNNING MTU:65536 Metric:1 + RX packets:0 errors:0 dropped:0 overruns:0 frame:0 + TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 + collisions:0 txqueuelen:1 + RX bytes:0 (0.0 B) TX bytes:0 (0.0 B) ``` ### 如何在 Ubuntu 16.04 LTS 中临时添加辅助 IP 地址 @@ -170,79 +175,80 @@ lo Link encap:Local Loopback 正如本文开头所述,网络接口名称从 Ubuntu 15.10 就开始从 ‘ethX’ 更改为 ‘enXXXX’ (enp0s3),所以,替换你的接口名称。 在执行此操作之前,先检查系统上的 IP 信息: + ``` # ifconfig -or +或 # ip addr -enp0s3: flags=4163 mtu 1500 - inet 192.168.56.201 netmask 255.255.255.0 broadcast 192.168.56.255 - inet6 fe80::a00:27ff:fe97:132e prefixlen 64 scopeid 0x20 - ether 08:00:27:97:13:2e txqueuelen 1000 (Ethernet) - RX packets 7 bytes 420 (420.0 B) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 294 bytes 24747 (24.7 KB) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 +enp0s3: flags=4163 mtu 1500 + inet 192.168.56.201 netmask 255.255.255.0 broadcast 192.168.56.255 + inet6 fe80::a00:27ff:fe97:132e prefixlen 64 scopeid 0x20 + ether 08:00:27:97:13:2e txqueuelen 1000 (Ethernet) + RX packets 7 bytes 420 (420.0 B) + RX errors 0 dropped 0 overruns 0 frame 0 + TX packets 294 bytes 24747 (24.7 KB) + TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 -enp0s8: flags=4163 mtu 1500 - inet 10.0.3.15 netmask 255.255.255.0 broadcast 10.0.3.255 - inet6 fe80::344b:6259:4dbe:eabb prefixlen 64 scopeid 0x20 - ether 08:00:27:12:e8:c1 txqueuelen 1000 (Ethernet) - RX packets 1 bytes 590 (590.0 B) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 97 bytes 10209 (10.2 KB) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 - -lo: flags=73 mtu 65536 - inet 127.0.0.1 netmask 255.0.0.0 - inet6 ::1 prefixlen 128 scopeid 0x10 - loop txqueuelen 1000 (Local Loopback) - RX packets 325 bytes 24046 (24.0 KB) - RX errors 0 dropped 0 overruns 0 frame 0 - TX packets 325 bytes 24046 (24.0 KB) - TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 +enp0s8: flags=4163 mtu 1500 + inet 10.0.3.15 netmask 255.255.255.0 broadcast 10.0.3.255 + inet6 fe80::344b:6259:4dbe:eabb prefixlen 64 scopeid 0x20 + ether 08:00:27:12:e8:c1 txqueuelen 1000 (Ethernet) + RX packets 1 bytes 590 (590.0 B) + RX errors 0 dropped 0 overruns 0 frame 0 + TX packets 97 bytes 10209 (10.2 KB) + TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 +lo: flags=73 mtu 65536 + inet 127.0.0.1 netmask 255.0.0.0 + inet6 ::1 prefixlen 128 scopeid 0x10 + loop txqueuelen 1000 (Local Loopback) + RX packets 325 bytes 24046 (24.0 KB) + RX errors 0 dropped 0 overruns 0 frame 0 + TX packets 325 bytes 24046 (24.0 KB) + TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ``` 如我所见,服务器主 IP 地址是 `192.168.56.201`,所以,我将下一个 IP `192.168.56.202` 作为辅助 IP,使用以下命令完成。 + ``` # ip addr add 192.168.56.202/24 broadcast 192.168.56.255 dev enp0s3 - ``` 运行以下命令来检查是否已分配了新的 IP。当你重启机器时,它会消失。 + ``` # ip addr -1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 - link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 - inet 127.0.0.1/8 scope host lo - valid_lft forever preferred_lft forever - inet6 ::1/128 scope host - valid_lft forever preferred_lft forever -2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 - link/ether 08:00:27:97:13:2e brd ff:ff:ff:ff:ff:ff - inet 192.168.56.201/24 brd 192.168.56.255 scope global enp0s3 - valid_lft forever preferred_lft forever - inet 192.168.56.202/24 brd 192.168.56.255 scope global secondary enp0s3 - valid_lft forever preferred_lft forever - inet6 fe80::a00:27ff:fe97:132e/64 scope link - valid_lft forever preferred_lft forever -3: enp0s8: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 - link/ether 08:00:27:12:e8:c1 brd ff:ff:ff:ff:ff:ff - inet 10.0.3.15/24 brd 10.0.3.255 scope global dynamic enp0s8 - valid_lft 86353sec preferred_lft 86353sec - inet6 fe80::344b:6259:4dbe:eabb/64 scope link - valid_lft forever preferred_lft forever - +1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 + inet 127.0.0.1/8 scope host lo + valid_lft forever preferred_lft forever + inet6 ::1/128 scope host + valid_lft forever preferred_lft forever +2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 08:00:27:97:13:2e brd ff:ff:ff:ff:ff:ff + inet 192.168.56.201/24 brd 192.168.56.255 scope global enp0s3 + valid_lft forever preferred_lft forever + inet 192.168.56.202/24 brd 192.168.56.255 scope global secondary enp0s3 + valid_lft forever preferred_lft forever + inet6 fe80::a00:27ff:fe97:132e/64 scope link + valid_lft forever preferred_lft forever +3: enp0s8: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 08:00:27:12:e8:c1 brd ff:ff:ff:ff:ff:ff + inet 10.0.3.15/24 brd 10.0.3.255 scope global dynamic enp0s8 + valid_lft 86353sec preferred_lft 86353sec + inet6 fe80::344b:6259:4dbe:eabb/64 scope link + valid_lft forever preferred_lft forever ``` ### 如何在 Ubuntu 16.04 LTS 中添加永久辅助 IP 地址 要在 Ubuntu 系统上添加永久辅助 IP 地址,只需编辑 `/etc/network/interfaces` 文件并添加所需 IP 的详细信息。 -我们不应该在 dns-nameservers 之后添加辅助 IP 地址,因为它不会起作用,应该以下面的格式添加 IP 详情。 +我们不应该在 `dns-nameservers` 行之后添加辅助 IP 地址,因为它不会起作用,应该以下面的格式添加 IP 详情。 此外,我们不需要添加子接口(我们之前在 Ubuntu 14.04 LTS 中的做法): + ``` # vi /etc/network/interfaces @@ -264,45 +270,45 @@ gateway 192.168.56.1 network 192.168.56.0 broadcast 192.168.56.255 dns-nameservers 8.8.8.8 8.8.4.4 -dns-search 2daygeek.local - +dns-search 2daygeek.local ``` 保存并关闭文件,然后重启网络接口服务: + ``` # systemctl restart networking -or +或 # ifdown enp0s3 && ifup enp0s3 - ``` 运行以下命令来检查是否已经分配了新的 IP: + ``` # ip addr -1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 - link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 - inet 127.0.0.1/8 scope host lo - valid_lft forever preferred_lft forever - inet6 ::1/128 scope host - valid_lft forever preferred_lft forever -2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 - link/ether 08:00:27:97:13:2e brd ff:ff:ff:ff:ff:ff - inet 192.168.56.201/24 brd 192.168.56.255 scope global enp0s3 - valid_lft forever preferred_lft forever - inet 192.168.56.202/24 brd 192.168.56.255 scope global secondary enp0s3 - valid_lft forever preferred_lft forever - inet6 fe80::a00:27ff:fe97:132e/64 scope link - valid_lft forever preferred_lft forever -3: enp0s8: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 - link/ether 08:00:27:12:e8:c1 brd ff:ff:ff:ff:ff:ff - inet 10.0.3.15/24 brd 10.0.3.255 scope global dynamic enp0s8 - valid_lft 86353sec preferred_lft 86353sec - inet6 fe80::344b:6259:4dbe:eabb/64 scope link - valid_lft forever preferred_lft forever - +1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 + inet 127.0.0.1/8 scope host lo + valid_lft forever preferred_lft forever + inet6 ::1/128 scope host + valid_lft forever preferred_lft forever +2: enp0s3: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 08:00:27:97:13:2e brd ff:ff:ff:ff:ff:ff + inet 192.168.56.201/24 brd 192.168.56.255 scope global enp0s3 + valid_lft forever preferred_lft forever + inet 192.168.56.202/24 brd 192.168.56.255 scope global secondary enp0s3 + valid_lft forever preferred_lft forever + inet6 fe80::a00:27ff:fe97:132e/64 scope link + valid_lft forever preferred_lft forever +3: enp0s8: mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 + link/ether 08:00:27:12:e8:c1 brd ff:ff:ff:ff:ff:ff + inet 10.0.3.15/24 brd 10.0.3.255 scope global dynamic enp0s8 + valid_lft 86353sec preferred_lft 86353sec + inet6 fe80::344b:6259:4dbe:eabb/64 scope link + valid_lft forever preferred_lft forever ``` 让我来 ping 一下新 IP 地址: + ``` # ping 192.168.56.202 -c 4 PING 192.168.56.202 (192.168.56.202) 56(84) bytes of data. @@ -314,7 +320,6 @@ PING 192.168.56.202 (192.168.56.202) 56(84) bytes of data. --- 192.168.56.202 ping statistics --- 4 packets transmitted, 4 received, 0% packet loss, time 3068ms rtt min/avg/max/mdev = 0.019/0.045/0.087/0.026 ms - ``` -------------------------------------------------------------------------------- @@ -324,7 +329,7 @@ via: https://www.2daygeek.com/how-to-add-additional-ip-secondary-ip-in-ubuntu-de 作者:[Prakash Subramanian][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2051edc325a0df78ceb6c6744cb34df6adcca8e5 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 6 Sep 2018 22:31:04 +0800 Subject: [PATCH 098/455] PUB:20180529 How To Add Additional IP (Secondary IP) In Ubuntu System.md @MjSeven https://linux.cn/article-9986-1.html --- ...29 How To Add Additional IP (Secondary IP) In Ubuntu System.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180529 How To Add Additional IP (Secondary IP) In Ubuntu System.md (100%) diff --git a/translated/tech/20180529 How To Add Additional IP (Secondary IP) In Ubuntu System.md b/published/20180529 How To Add Additional IP (Secondary IP) In Ubuntu System.md similarity index 100% rename from translated/tech/20180529 How To Add Additional IP (Secondary IP) In Ubuntu System.md rename to published/20180529 How To Add Additional IP (Secondary IP) In Ubuntu System.md From dbd30ef55c2e4032059ee409c0b788cdd81fe9b7 Mon Sep 17 00:00:00 2001 From: shangmo Date: Thu, 6 Sep 2018 23:32:22 +0800 Subject: [PATCH 099/455] =?UTF-8?q?30=E4=B8=AA=E6=9C=80=E4=BD=B3=E7=9A=84?= =?UTF-8?q?=20Linux=20*BSD=20Unix=20=E5=9C=A8=E7=BA=BF=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... - -BSD - Unix Documentation On the Web.md | 467 ++++++++++++++++++ 1 file changed, 467 insertions(+) create mode 100644 translated/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md diff --git a/translated/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md b/translated/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md new file mode 100644 index 0000000000..349973bec0 --- /dev/null +++ b/translated/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md @@ -0,0 +1,467 @@ +# sober-wang 翻译中 + + + +30 Best Sources For Linux / *BSD / Unix Documentation On the Web +====== + +# 30 个最佳的 Linux / *BSD / Unix 在线文档 + + + +Man pages are written by sys-admin and developers for IT techs, and are intended more as a reference than as a how to. Man pages are very useful for people who are already familiar with Linux, Unix, and BSD operating systems. Use man pages when you just need to know the syntax for particular commands or configuration file, but they are not helpful for new Linux users. Man pages are not good for learning something new for the first time. Here are thirty best documentation sites on the web for learning Linux and Unix like operating systems. + +![Dennis Ritchie and Ken Thompson working with UNIX PDP11][1] + +Please note that BSD manpages are usually better as compare to Linux. + +## #1: Red Hat Enterprise Linux + +![Red hat Enterprise Linux Docs][2] + +RHEL is developed by Red Hat and targeted toward the commercial market. It has one of the best documentations covering basis of RHEL to advanced topics like security, SELinux, virtualization, directory server, clustering, JBOSS, HPC, and much more. Red Hat documentation has been translated into twenty-two languages and is available in multi-page HTML, single-page HTML, PDF, and EPUB formats. The good news is you can use the same documentation for CentOS or Scientific Linux (community enterprise distros). All of these documents ship with the OS, so if you don't have a network connection, then you have them there as well. The RHEL docs **covers everything from installation to configuring clusters**. The only downside is you need to be a paid customer. This is perfect for an enterprise company. + + 1. RHEL Documentation: [in HTML/PDF format][3] + 2. Support forums: Only available to Red Hat customer portal to submit a support case. + + + +### A Note About CentOS Wiki and Forums + +![Centos Linux Wiki][4] + +CentOS (Community ENTerprise Operating System) is a free rebuild of source packages freely available from a RHEL. It provides truly reliable, free enterprise Linux for personal and other usage. You will get RHEL stability without the cost of certification and support. CentOS wiki divided into Howtos, Tips & Tricks, and much more at the following locations: + + 1. [Documentation Wiki][87] + 2. [Support forum][88] + +## #2: Arch Wiki and Forums + +![Arch Linux wiki and tutorials][5] + +Arch Linux is an independently developed, Linux operating system and it comes with pretty good documentation in form of wiki based site. It is developed collaboratively by a community of Arch users, allowing any user to add and edit content. The articles are divided into various categories like [networking][6], optimization, package management, system administration, X window system, and getting & installing Arch Linux. The official [forums][7] are useful for solving many issues. It has total 40k+ registered users with over 1 million posts. The wiki contains some **general information that can also apply in other Linux distros**. + + 1. Arch community Documentation: [Wiki format][8] + 2. Support forums: [Yes][7] + + + +## #3: Gentoo Linux Wiki and Forums + +![Gentoo Linux Handbook and Wiki][9] + +Gentoo Linux is based on the Portage package management system. The Gentoo user compiles the source code locally according to their chosen configuration. The majority of users have configurations and sets of installed programs which are unique to themselves. The Gentoo give you some explanation about the Gentoo Linux and answer most of your questions regarding installations, packages, networking, and much more. Gentoo has **very helpful forum** with over one hundred thirty-four thousand plus users who have posted a total of 5442416 articles. + + 1. Gentoo community documentation: [Handbook][10] and [Wiki format][11] + 2. Support forums: [Yes][12] + 3. User-supplied documentation available at [gentoo-wiki.com][13] + + + +## #4: Ubuntu Wiki and Documentation + +Ubuntu is one of the leading desktop and laptop distro. The official documentation developed and maintained by the Ubuntu Documentation Project. You can access a wealth of information including a getting started Guide. The best part is information contained herein may also work with other Debian-based systems. You will also find the community documentation for Ubuntu created by its users. This is a reference for Ubuntu-related 'Howtos, Tips, Tricks, and Hacks'. Ubuntu Linux has one of the biggest Linux communities on the web. It offers help to the both new and experienced users. + +![Ubuntu Linux Wiki and Forums][14] + + 1. Ubuntu community documentation: [wiki format][15]. + 2. Ubuntu official documentation: [wiki format][16]. + 3. Support forums: [Yes][17]. + + + +## #5: IBM Developer Works + +IBM developer works offers technical resources for Linux programmers and system administrators. It contains hundreds of articles, tutorials, and tips to help developers with Linux programming and application development, as well as Linux system administration. + +![IBM: Technical for Linux programmers and system administrators][18] + + 1. IBM Developer Works Documentation: [HTML format][19] + 2. Support forums: [Yes][20]. + + + +## #6: FreeBSD Documentation and Handbook + +The FreeBSD handbook is created by the FreeBSD Documentation Project. It describes the installation, administration and day-to-day use of the FreeBSD OS. BSD manpages are usually better as compare to GNU/Linux man pages. The FreeBSD **comes with all the documents** with upto date man pages. The FreeBSD Handbook **covers everything**. The handbook contains some general Unix information that can also apply in other Linux distros. The official FreeBSD forums also provides helps whenever you will get stuck with problems. + +![Freebsd Documentation][21] + + 1. FreeBSD Documentation: [HTML/PDF format][90] + 2. Support forums: [Yes][91]. + + +## #7: Bash Hackers Wiki + +![Bash hackers wiki for bash users][22] +This is an excellent resource for bash user. The bash hackers wiki is intended to hold documentations of any kind about the GNU Bash. The main motivation was to provide human-readable documentation and information to not force users to read every bit of the Bash manpage - which is hard sometimes. The wiki is divided into various sections such as - scripting and general information, howtos, coding style, bash syntax, and much more. + + 1. Bash hackers [wiki][23] in wiki format + + + +## #8: Bash FAQ + +![Bash FAQ: Answers to frequently asked questions about GNU/BASH][24] +A wiki designed for new bash users. It has good collections to frequently asked questions on channel #bash on the freenode IRC network. These answers are contributed by the regular members of the channel. Don't forget to check out common mistakes made by Bash programmers, in [BashPitfalls][25] section. The answers given in this FAQ may be slanted toward Bash, or they may be slanted toward the lowest common denominator Bourne shell, depending on who wrote the answer. In most cases, an effort is made to provide both a portable (Bourne) and an efficient (Bash, where appropriate) answer. + + 1. Bash FAQ [in wiki ][26] format. + + + +## #9: Howtoforge - Linux Tutorials + +![Howtoforge][27] + +Fellow blogger Falko has some great stuff over at How-To Forge. The site provides Linux tutorials about various topic including its famous "The Perfect Server" series. The site is divided into various topics such as web-server, Linux distros, DNS servers, Virtualization, High-availability, Email and anti-spam, FTP servers, programming topics, and much more. The site is also available in German language. + + 1. Howtoforge [in html][28] format. + 2. Support forums: Yes + + + +## #10: OpenBSD FAQ and Documentation + +![OpenBSD Documenation][29] + +OpenBSD is another Unix-like computer operating system based on Berkeley Software Distribution (BSD). It was forked from NetBSD by project. The OpenBSD is well known for the **quality code, documentation** , uncompromising position on software licensing, with strong focus on security. The documenation is divided into various topics such as - installations, package management, firewall setup, user management, networking, disk / RAID management and much more. + + 1. OpenBSD [in html][30] format. + 2. Support forums: No, but [mail lists][31] are available. + + + +## #11: Calomel - Open Source Research and Reference + +This amazing site dedicated to documenting open source software, and programs with special focus on OpenBSD. This is one of the cleanest and easy to to navigate website, with focus on the quality content. The site is divided into various server topic such as DNS, OpeBSD, security, web-server, Samba file server, various tools, and much more. + +![Open Source Research and Reference Documentation][32] + + 1. Calomel Org [in html][33] format. + 2. Support forums: No + + + +## #12: Slackware Book Project + +![Slackware Linux Book and Documentation ][34] +Slackware Linux was my first distro. It was one of the earliest distro based on the Linux kernel and is the oldest currently being maintained. The distro is targeted towards power users with strong focus on stability. Slackware is one of few the most "Unix-like" Linux distribution. The official slackware book is designed to get you started with the Slackware Linux operating system. It's not meant to cover every single aspect of the distribution, but rather to show what it is capable of and give you a basic working knowledge of the system. The book is divided into various topics such as Installation, Network & System Configuration, System administration, Package management, and much more. + + 1. Slackware [Linux books in html][35], pdf, and other format. + 2. Support forums: Yes + + + +## #13: The Linux Documentation Project (TLDP) + +![Linux Learning Site and Documentation ][36] + +The Linux Documentation Project is working towards developing free, high quality documentation for the Linux operating system. The site is created and maintained by volunteers. The site is divided into subject-specific help, longer and in-depth guide books, and much more. I recommend [this document][37] which is both a tutorial and a reference on shell scripting with Bash. The [single list][38] of HOWTOs is also a good starting point for new users. + + 1. The Linux [documentation project][39] available in multiple formats. + 2. Support forums: No + + + +## #14: Linux Home Networking + +![Linux Home Networking ][40] + +Linux home networking is another good resource for learning Linux. This site covers topics needed for Linux software certification exams, such as the RHCE, and many computer training courses. The site is divided into various topics such as networking, samba file server, wirless networking, web-server, and much more. + + 1. Linux [home networking][41] available in html and PDF (with small fee) formats. + 2. Support forums: Yes + + + +## #15: Linux Action Show + +![Linux Podcast ][42] + +Linux Action Show ("LAS") is a podcast about Linux. The show is hosted by Bryan Lunduke, Allan Jude, and Chris Fisher. It covers the latest news in the FOSS world. The show reviews various apps and Linux distros. Sometime an interview with a major personal in the open source world is posted on the show. + + 1. Linux [action show][43] available in audio/video format. + 2. Support forums: Yes + + + +## #16: Commandlinefu + +Commandlinefu lists various shell commands that you may find interesting and useful. All commands can be commented on, discussed and voted up or down. Ths is an awesome resource for all Unix command line users. Don't forget to checkout all [top voted][44] commands here. + +![The best Unix / Linux Commands By Commandlinefu][45] + + 1. [Commandlinefu][46] available in html format. + 2. Support forums: No + + + +## #17: Debian Administration Tips and Resources + +This site covers topics, tips, and tutorial only related to Debian GNU/Linux. It contain interesting and useful information related to the System Administration. You can contribute an article, tip, or question here. Don't forget to checkout [top articles][47] posted in the hall of fame section. +![Debian Linux Adminstration: Tips and Tutorial For Sys Admin][48] + + 1. Debian [administration][49] available in html format. + 2. Support forums: No + + + +## #18: Catonmat - Sed, Awk, Perl Tutorials + +![Sed, Awk, Perl Tutorials][50] + +This site run by a fellow blogger Peteris Krumins. The main focus is on command line and Unix programming topics such as sed, perl, awk, and others. Don't forget to check out [introduction to sed][51], sed [one liner][52] explained, the definitive [guide][53] to Bash Command line history, and [awk][54] liner explained. + + 1. [catonmat][55] available in html format. + 2. Support forums: No + + + +## #19: Debian GNU/Linux Documentation and Wiki + +![Debian Linux Tutorials and Wiki][56] + +Debian is another Linux based operating system that primarily uses software released under the GNU General Public. Debian is well known for strict adherence to the philosophies of Unix and free software. It is also one of popular and influential Linux distribution. It is also used as a base for many other distributions such as Ubuntu and others. The Debian project provides its users with proper documentation in an easily accessible form. The site is divided into wiki, installation guide, faqs, and support forum. + + 1. Debian GNU/Linux [documentation][57] available in html and other format. + 2. Debian GNU/Linux [wiki][58] + 3. Support forums: [Yes][59] + + + +## #20: Linux Sea + +The book "Linux Sea" offers a gentle yet technical (from end-user perspective) introduction to the Linux operating system, using Gentoo Linux as the example Linux distribution. It does not nor will it ever talk about the history of the Linux kernel or Linux distributions or dive into details that are less interesting for Linux users. + + 1. Linux [sea][60] available in html format. + 2. Support forums: No + + + +## #21: Oreilly Commons + +![Oreilly Free Linux / Unix / Php / Javascript / Ubuntu Books][61] + +The oreilly publishing house has posted quite a few titles in wiki format for all. The purpose of this site is to provide content to communities that would like to create, reference, use, modify, update and revise material from O'Reilly or other sources. The site includes books about Ubuntu, Php, Spamassassin, Linux, and much more all for free. + + 1. Oreilly [commons][62] available in wiki format. + 2. Support forums: No + + + +## #22: Ubuntu Pocket Guide + +![Ubuntu Book For New Users][63] + +This book is written by Keir Thomas. This guide/book is a good read for everyday Ubuntu user. The purpose of this book is to introduce you to the Ubuntu operating system, and the philosophy that underpins it. You can download a pdf version from the official site or order a print version using Amazon. + + 1. Ubuntu [pocket guide][64] available in pdf and print formats. + 2. Support forums: No + + + +## #23: Linux: Rute User's Tutorial and Exposition + +![GNU/LINUX system administration book][65] + +This book covers GNU/LINUX system administration, for popular distributions like RedHat and Debian, as a tutorial for new users and a reference for advanced administrators. It aims to give concise, thorough explanations and practical examples of each aspect of a UNIX system. Anyone who wants a comprehensive text on (what is commercially called) LINUX need look no further-there is little that is not covered here. + + 1. Linux: [Rute User's Tutorial and Exposition][66] available in print and html formats. + 2. Support forums: No + + + +## #24: Advanced Linux Programming + +![Advanced Linux Programming][67] + +This book is intended for the programmer already familiar with the C programming language. It take a tutorial approach and teach the most important concepts and power features of the GNU/Linux system in application programs. If you're a developer already experienced with programming for the GNU/Linux system, are experienced with another UNIX-like system and are interested in developing GNU/Linux software, or want to make the transition for a non-UNIX environment and are already familiar with the general principles of writing good software, this book is for you. In addition, you will find that this book is equally applicable to C and C++ programming. + + 1. Advanced [Linux programming][68] available in print and pdf formats. + 2. Support forums: No + + + +## #25: LPI 101 Course Notes + +![Linux Professional Institute Certification Books][69] + +LPIC-1/2/3 levels are certification for Linux administrators. This site provides training manuals for LPI 101 and 102 exams. These are licenced under the GNU Free Documentation Licence (FDL). This course material is based on the objectives for the Linux Professionals Institutea€™s LPI 101 and 102 examination. The course is intended to provide you with the skills required for operating and administering Linux systems. + + 1. Download LPI [training manuals][70] in pdf format. + 2. Support forums: No + + + +## #26: FOSS Manuals + +FLOSS Manuals is a collection of manuals about free and open source software together with the tools used to create them and the community that uses those tools. They include authors, editors, artists, software developers, activists, and many others. There are manuals that explain how to install and use a range of free and open source softwares, about how to do things (like design or stay safe online) with open source software, and manuals about free culture services that use or support free software and formats. You will find manuals about software such as VLC, [Linux video editing][71], Linux, OLPC / SUGAR, GRAPHICS, and much more. + +![FLOSS Manuals is a collection of manuals about free and open source software][72] + + 1. You can browse [FOSS manuals][73] in wiki format. + 2. Support forums: No + + + +## #27: Linux Starter Pack + +![The Linux Starter Pack][74] + +New to the wonderful world of Linux? Looking for an easy way to get started? You can download 130-page guide and get to grips with the OS. This will show you how to install Linux onto your PC, navigate around the desktop, master the most popular Linux programs and fix any problems that may arise. + + 1. Download [Linux starter][75] pack in pdf format. + 2. Support forums: No + + + +## #28: Linux.com - The Source of Linux Info + +Linux.com is a product of the Linux Foundation. The side provides news, guides, tutorials and other information about Linux by harnessing the power of Linux users worldwide to inform, collaborate and connect on all matters Linux. + + 1. Visit [Linux.com][76] online. + 2. Support forums: Yes + + + +## #29: LWN + +LWN is a site with an emphasis on free software and software for Linux and other Unix-like operating systems. It consists of a weekly issue, separate stories which are published most days, and threaded discussion attached to every story. The site provide comprehensive coverage of development, legal, commercial, and security issues related to Linux and FOSS. + + 1. Visit [lwn.net][77] online. + 2. Support forums: No + + + +## #30: Mac OS X Related sites + +A quick links to Max OS X related sites: + + * [Mac OS X Hints][78] - This site is dedicated to the Apple's Mac OS X unix operating systems. It has tons of tips, tricks and tutorial about Bash, and OS X + * [Mac OS development library][79] - Apple has good collection related to OS X development. Don't forget to checkout [bash shell scripting primer][80]. + * [Apple kbase][81] - This is like RHN kbase. It provides guides and troublshooting tips for all apple products including OS X. + + + +## #30: NetBSD + +NetBSD is another free open source operating system based upon the Berkeley Software Distribution (BSD) Unix operating system. The NetBSD project is primarily focused on high quality design, stability and performance of the system. Due to its portability and Berkeley-style license, NetBSD is often used in embedded systems. This site provides links to the official NetBSD documentation and also links to various external documents. + + 1. View [netbsd][82] documentation online in html / pdf format. + 2. Support forums: No + + + +## Your Turn: + +This is my personal list and it is not absolutely definitive, so if you've got your own favorite Unix/Linux specific site, share in the comments below. + +// Image credit: [Flickr photo][83] by PanelSwitchman. Some links are suggested by user on our facebook fan page. + +// For those who celebrate, Merry Christmas! For everyone else, enjoy the weekend. + +## About the author + +The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][84], [Facebook][85], [Google+][86]. + +-------------------------------------------------------------------------------- + +via: https://www.cyberciti.biz/tips/linux-unix-bsd-documentations.html + +作者:[Vivek Gite][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.cyberciti.biz +[1]:https://www.cyberciti.biz/media/new/tips/2011/12/unix-pdp11.jpg "Dennis Ritchie and Ken Thompson working with UNIX PDP11" +[2]:https://www.cyberciti.biz/media/new/tips/2011/12/redhat-enterprise-linux-docs-150x150.png "Red hat Enterprise Linux Docs" +[3]:https://access.redhat.com/documentation/en-us/ +[4]:https://www.cyberciti.biz/media/new/tips/2011/12/centos-linux-wiki-150x150.png "Centos Linux Wiki, Support, Documents" +[5]:https://www.cyberciti.biz/media/new/tips/2011/12/arch-linux-wiki-150x150.png "Arch Linux wiki and tutorials " +[6]:https://wiki.archlinux.org/index.php/Category:Networking_%28English%29 +[7]:https://bbs.archlinux.org/ +[8]:https://wiki.archlinux.org/ +[9]:https://www.cyberciti.biz/media/new/tips/2011/12/gentoo-linux-wiki1-150x150.png "Gentoo Linux Handbook and Wiki" +[10]:http://www.gentoo.org/doc/en/handbook/ +[11]:https://wiki.gentoo.org +[12]:https://forums.gentoo.org/ +[13]:http://gentoo-wiki.com +[14]:https://www.cyberciti.biz/media/new/tips/2011/12/ubuntu-linux-wiki.png "Ubuntu Linux Wiki and Forums" +[15]:https://help.ubuntu.com/community +[16]:https://help.ubuntu.com/ +[17]:https://ubuntuforums.org/ +[18]:https://www.cyberciti.biz/media/new/tips/2011/12/ibm-devel.png "IBM: Technical for Linux programmers and system administrators" +[19]:https://www.ibm.com/developerworks/learn/linux/index.html +[20]:https://www.ibm.com/developerworks/community/forums/html/public?lang=en +[21]:https://www.cyberciti.biz/media/new/tips/2011/12/freebsd-docs.png "Freebsd Documentation" +[22]:https://www.cyberciti.biz/media/new/tips/2011/12/bash-hackers-wiki-150x150.png "Bash hackers wiki for bash users" +[23]:http://wiki.bash-hackers.org/doku.php +[24]:https://www.cyberciti.biz/media/new/tips/2011/12/bash-faq-150x150.png "Bash FAQ: Answers to frequently asked questions about GNU/BASH" +[25]:http://mywiki.wooledge.org/BashPitfalls +[26]:https://mywiki.wooledge.org/BashFAQ +[27]:https://www.cyberciti.biz/media/new/tips/2011/12/howtoforge-150x150.png "Howtoforge tutorials" +[28]:https://howtoforge.com/ +[29]:https://www.cyberciti.biz/media/new/tips/2011/12/openbsd-faq-150x150.png "OpenBSD Documenation" +[30]:https://www.openbsd.org/faq/index.html +[31]:https://www.openbsd.org/mail.html +[32]:https://www.cyberciti.biz/media/new/tips/2011/12/calomel_org.png "Open Source Research and Reference Documentation" +[33]:https://calomel.org +[34]:https://www.cyberciti.biz/media/new/tips/2011/12/slackware-linux-book-150x150.png "Slackware Linux Book and Documentation " +[35]:http://www.slackbook.org/ +[36]:https://www.cyberciti.biz/media/new/tips/2011/12/tldp-150x150.png "Linux Learning Site and Documentation " +[37]:http://tldp.org/LDP/abs/html/index.html +[38]:http://tldp.org/HOWTO/HOWTO-INDEX/howtos.html +[39]:http://tldp.org/ +[40]:https://www.cyberciti.biz/media/new/tips/2011/12/linuxhomenetworking-150x150.png "Linux Home Networking " +[41]:http://www.linuxhomenetworking.com/ +[42]:https://www.cyberciti.biz/media/new/tips/2011/12/linux-action-show-150x150.png "Linux Podcast " +[43]:http://www.jupiterbroadcasting.com/show/linuxactionshow/ +[44]:https://www.commandlinefu.com/commands/browse/sort-by-votes +[45]:https://www.cyberciti.biz/media/new/tips/2011/12/commandlinefu.png "The best Unix / Linux Commands " +[46]:https://commandlinefu.com/ +[47]:https://www.debian-administration.org/hof +[48]:https://www.cyberciti.biz/media/new/tips/2011/12/debian-admin.png "Debian Linux Adminstration: Tips and Tutorial For Sys Admin" +[49]:https://www.debian-administration.org/ +[50]:https://www.cyberciti.biz/media/new/tips/2011/12/catonmat-150x150.png "Sed, Awk, Perl Tutorials" +[51]:http://www.catonmat.net/blog/worlds-best-introduction-to-sed/ +[52]:https://www.catonmat.net/blog/sed-one-liners-explained-part-one/ +[53]:https://www.catonmat.net/blog/the-definitive-guide-to-bash-command-line-history/ +[54]:https://www.catonmat.net/blog/awk-one-liners-explained-part-one/ +[55]:https://catonmat.net/ +[56]:https://www.cyberciti.biz/media/new/tips/2011/12/debian-wiki-150x150.png "Debian Linux Tutorials and Wiki" +[57]:https://www.debian.org/doc/ +[58]:https://wiki.debian.org/ +[59]:https://www.debian.org/support +[60]:http://swift.siphos.be/linux_sea/ +[61]:https://www.cyberciti.biz/media/new/tips/2011/12/orelly-150x150.png "Oreilly Free Linux / Unix / Php / Javascript / Ubuntu Books" +[62]:http://commons.oreilly.com/wiki/index.php/O%27Reilly_Commons +[63]:https://www.cyberciti.biz/media/new/tips/2011/12/ubuntu-guide-150x150.png "Ubuntu Book For New Users" +[64]:http://ubuntupocketguide.com/ +[65]:https://www.cyberciti.biz/media/new/tips/2011/12/rute-150x150.png "GNU/LINUX system administration free book" +[66]:https://web.archive.org/web/20160204213406/http://rute.2038bug.com/rute.html.gz +[67]:https://www.cyberciti.biz/media/new/tips/2011/12/advanced-linux-programming-150x150.png "Download Advanced Linux Programming PDF version" +[68]:https://github.com/MentorEmbedded/advancedlinuxprogramming +[69]:https://www.cyberciti.biz/media/new/tips/2011/12/lpic-150x150.png "Download Linux Professional Institute Certification PDF Book" +[70]:http://academy.delmar.edu/Courses/ITSC1358/eBooks/LPI-101.LinuxTrainingCourseNotes.pdf +[71]://www.cyberciti.biz/faq/top5-linux-video-editing-system-software/ +[72]:https://www.cyberciti.biz/media/new/tips/2011/12/floss-manuals.png "Download manuals about free and open source software" +[73]:https://flossmanuals.net/ +[74]:https://www.cyberciti.biz/media/new/tips/2011/12/linux-starter-150x150.png "New to Linux? Start Linux starter book [ PDF version ]" +[75]:http://www.tuxradar.com/linuxstarterpack +[76]:https://linux.com +[77]:https://lwn.net/ +[78]:http://hints.macworld.com/ +[79]:https://developer.apple.com/library/mac/navigation/ +[80]:https://developer.apple.com/library/mac/#documentation/OpenSource/Conceptual/ShellScripting/Introduction/Introduction.html +[81]:https://support.apple.com/kb/index?page=search&locale=en_US&q= +[82]:https://www.netbsd.org/docs/ +[83]:https://www.flickr.com/photos/9479603@N02/3311745151/in/set-72157614479572582/ +[84]:https://twitter.com/nixcraft +[85]:https://facebook.com/nixcraft +[86]:https://plus.google.com/+CybercitiBiz +[87]:https://wiki.centos.org/ +[88]:https://www.centos.org/forums/ +[90]: https://www.freebsd.org/docs.html +[91]: https://forums.freebsd.org/ From 8701e5b6f00ad3973465b992ea86e98eb6096daa Mon Sep 17 00:00:00 2001 From: shangmo Date: Fri, 7 Sep 2018 00:02:40 +0800 Subject: [PATCH 100/455] =?UTF-8?q?=E7=BF=BB=E8=AF=91=20RHEL=20=E5=AE=98?= =?UTF-8?q?=E6=96=B9=E6=96=87=E6=A1=A3=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... - -BSD - Unix Documentation On the Web.md | 458 ------------------ ... - -BSD - Unix Documentation On the Web.md | 12 +- 2 files changed, 10 insertions(+), 460 deletions(-) delete mode 100644 sources/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md diff --git a/sources/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md b/sources/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md deleted file mode 100644 index ac35f7c596..0000000000 --- a/sources/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md +++ /dev/null @@ -1,458 +0,0 @@ -30 Best Sources For Linux / *BSD / Unix Documentation On the Web -====== -Man pages are written by sys-admin and developers for IT techs, and are intended more as a reference than as a how to. Man pages are very useful for people who are already familiar with Linux, Unix, and BSD operating systems. Use man pages when you just need to know the syntax for particular commands or configuration file, but they are not helpful for new Linux users. Man pages are not good for learning something new for the first time. Here are thirty best documentation sites on the web for learning Linux and Unix like operating systems. - -![Dennis Ritchie and Ken Thompson working with UNIX PDP11][1] - -Please note that BSD manpages are usually better as compare to Linux. - -## #1: Red Hat Enterprise Linux - -![Red hat Enterprise Linux Docs][2] - -RHEL is developed by Red Hat and targeted toward the commercial market. It has one of the best documentations covering basis of RHEL to advanced topics like security, SELinux, virtualization, directory server, clustering, JBOSS, HPC, and much more. Red Hat documentation has been translated into twenty-two languages and is available in multi-page HTML, single-page HTML, PDF, and EPUB formats. The good news is you can use the same documentation for CentOS or Scientific Linux (community enterprise distros). All of these documents ship with the OS, so if you don't have a network connection, then you have them there as well. The RHEL docs **covers everything from installation to configuring clusters**. The only downside is you need to be a paid customer. This is perfect for an enterprise company. - - 1. RHEL Documentation: [in HTML/PDF format][3] - 2. Support forums: Only available to Red Hat customer portal to submit a support case. - - - -### A Note About CentOS Wiki and Forums - -![Centos Linux Wiki][4] - -CentOS (Community ENTerprise Operating System) is a free rebuild of source packages freely available from a RHEL. It provides truly reliable, free enterprise Linux for personal and other usage. You will get RHEL stability without the cost of certification and support. CentOS wiki divided into Howtos, Tips & Tricks, and much more at the following locations: - - 1. [Documentation Wiki][87] - 2. [Support forum][88] - -## #2: Arch Wiki and Forums - -![Arch Linux wiki and tutorials][5] - -Arch Linux is an independently developed, Linux operating system and it comes with pretty good documentation in form of wiki based site. It is developed collaboratively by a community of Arch users, allowing any user to add and edit content. The articles are divided into various categories like [networking][6], optimization, package management, system administration, X window system, and getting & installing Arch Linux. The official [forums][7] are useful for solving many issues. It has total 40k+ registered users with over 1 million posts. The wiki contains some **general information that can also apply in other Linux distros**. - - 1. Arch community Documentation: [Wiki format][8] - 2. Support forums: [Yes][7] - - - -## #3: Gentoo Linux Wiki and Forums - -![Gentoo Linux Handbook and Wiki][9] - -Gentoo Linux is based on the Portage package management system. The Gentoo user compiles the source code locally according to their chosen configuration. The majority of users have configurations and sets of installed programs which are unique to themselves. The Gentoo give you some explanation about the Gentoo Linux and answer most of your questions regarding installations, packages, networking, and much more. Gentoo has **very helpful forum** with over one hundred thirty-four thousand plus users who have posted a total of 5442416 articles. - - 1. Gentoo community documentation: [Handbook][10] and [Wiki format][11] - 2. Support forums: [Yes][12] - 3. User-supplied documentation available at [gentoo-wiki.com][13] - - - -## #4: Ubuntu Wiki and Documentation - -Ubuntu is one of the leading desktop and laptop distro. The official documentation developed and maintained by the Ubuntu Documentation Project. You can access a wealth of information including a getting started Guide. The best part is information contained herein may also work with other Debian-based systems. You will also find the community documentation for Ubuntu created by its users. This is a reference for Ubuntu-related 'Howtos, Tips, Tricks, and Hacks'. Ubuntu Linux has one of the biggest Linux communities on the web. It offers help to the both new and experienced users. - -![Ubuntu Linux Wiki and Forums][14] - - 1. Ubuntu community documentation: [wiki format][15]. - 2. Ubuntu official documentation: [wiki format][16]. - 3. Support forums: [Yes][17]. - - - -## #5: IBM Developer Works - -IBM developer works offers technical resources for Linux programmers and system administrators. It contains hundreds of articles, tutorials, and tips to help developers with Linux programming and application development, as well as Linux system administration. - -![IBM: Technical for Linux programmers and system administrators][18] - - 1. IBM Developer Works Documentation: [HTML format][19] - 2. Support forums: [Yes][20]. - - - -## #6: FreeBSD Documentation and Handbook - -The FreeBSD handbook is created by the FreeBSD Documentation Project. It describes the installation, administration and day-to-day use of the FreeBSD OS. BSD manpages are usually better as compare to GNU/Linux man pages. The FreeBSD **comes with all the documents** with upto date man pages. The FreeBSD Handbook **covers everything**. The handbook contains some general Unix information that can also apply in other Linux distros. The official FreeBSD forums also provides helps whenever you will get stuck with problems. - -![Freebsd Documentation][21] - - 1. FreeBSD Documentation: [HTML/PDF format][90] - 2. Support forums: [Yes][91]. - - -## #7: Bash Hackers Wiki - -![Bash hackers wiki for bash users][22] -This is an excellent resource for bash user. The bash hackers wiki is intended to hold documentations of any kind about the GNU Bash. The main motivation was to provide human-readable documentation and information to not force users to read every bit of the Bash manpage - which is hard sometimes. The wiki is divided into various sections such as - scripting and general information, howtos, coding style, bash syntax, and much more. - - 1. Bash hackers [wiki][23] in wiki format - - - -## #8: Bash FAQ - -![Bash FAQ: Answers to frequently asked questions about GNU/BASH][24] -A wiki designed for new bash users. It has good collections to frequently asked questions on channel #bash on the freenode IRC network. These answers are contributed by the regular members of the channel. Don't forget to check out common mistakes made by Bash programmers, in [BashPitfalls][25] section. The answers given in this FAQ may be slanted toward Bash, or they may be slanted toward the lowest common denominator Bourne shell, depending on who wrote the answer. In most cases, an effort is made to provide both a portable (Bourne) and an efficient (Bash, where appropriate) answer. - - 1. Bash FAQ [in wiki ][26] format. - - - -## #9: Howtoforge - Linux Tutorials - -![Howtoforge][27] - -Fellow blogger Falko has some great stuff over at How-To Forge. The site provides Linux tutorials about various topic including its famous "The Perfect Server" series. The site is divided into various topics such as web-server, Linux distros, DNS servers, Virtualization, High-availability, Email and anti-spam, FTP servers, programming topics, and much more. The site is also available in German language. - - 1. Howtoforge [in html][28] format. - 2. Support forums: Yes - - - -## #10: OpenBSD FAQ and Documentation - -![OpenBSD Documenation][29] - -OpenBSD is another Unix-like computer operating system based on Berkeley Software Distribution (BSD). It was forked from NetBSD by project. The OpenBSD is well known for the **quality code, documentation** , uncompromising position on software licensing, with strong focus on security. The documenation is divided into various topics such as - installations, package management, firewall setup, user management, networking, disk / RAID management and much more. - - 1. OpenBSD [in html][30] format. - 2. Support forums: No, but [mail lists][31] are available. - - - -## #11: Calomel - Open Source Research and Reference - -This amazing site dedicated to documenting open source software, and programs with special focus on OpenBSD. This is one of the cleanest and easy to to navigate website, with focus on the quality content. The site is divided into various server topic such as DNS, OpeBSD, security, web-server, Samba file server, various tools, and much more. - -![Open Source Research and Reference Documentation][32] - - 1. Calomel Org [in html][33] format. - 2. Support forums: No - - - -## #12: Slackware Book Project - -![Slackware Linux Book and Documentation ][34] -Slackware Linux was my first distro. It was one of the earliest distro based on the Linux kernel and is the oldest currently being maintained. The distro is targeted towards power users with strong focus on stability. Slackware is one of few the most "Unix-like" Linux distribution. The official slackware book is designed to get you started with the Slackware Linux operating system. It's not meant to cover every single aspect of the distribution, but rather to show what it is capable of and give you a basic working knowledge of the system. The book is divided into various topics such as Installation, Network & System Configuration, System administration, Package management, and much more. - - 1. Slackware [Linux books in html][35], pdf, and other format. - 2. Support forums: Yes - - - -## #13: The Linux Documentation Project (TLDP) - -![Linux Learning Site and Documentation ][36] - -The Linux Documentation Project is working towards developing free, high quality documentation for the Linux operating system. The site is created and maintained by volunteers. The site is divided into subject-specific help, longer and in-depth guide books, and much more. I recommend [this document][37] which is both a tutorial and a reference on shell scripting with Bash. The [single list][38] of HOWTOs is also a good starting point for new users. - - 1. The Linux [documentation project][39] available in multiple formats. - 2. Support forums: No - - - -## #14: Linux Home Networking - -![Linux Home Networking ][40] - -Linux home networking is another good resource for learning Linux. This site covers topics needed for Linux software certification exams, such as the RHCE, and many computer training courses. The site is divided into various topics such as networking, samba file server, wirless networking, web-server, and much more. - - 1. Linux [home networking][41] available in html and PDF (with small fee) formats. - 2. Support forums: Yes - - - -## #15: Linux Action Show - -![Linux Podcast ][42] - -Linux Action Show ("LAS") is a podcast about Linux. The show is hosted by Bryan Lunduke, Allan Jude, and Chris Fisher. It covers the latest news in the FOSS world. The show reviews various apps and Linux distros. Sometime an interview with a major personal in the open source world is posted on the show. - - 1. Linux [action show][43] available in audio/video format. - 2. Support forums: Yes - - - -## #16: Commandlinefu - -Commandlinefu lists various shell commands that you may find interesting and useful. All commands can be commented on, discussed and voted up or down. Ths is an awesome resource for all Unix command line users. Don't forget to checkout all [top voted][44] commands here. - -![The best Unix / Linux Commands By Commandlinefu][45] - - 1. [Commandlinefu][46] available in html format. - 2. Support forums: No - - - -## #17: Debian Administration Tips and Resources - -This site covers topics, tips, and tutorial only related to Debian GNU/Linux. It contain interesting and useful information related to the System Administration. You can contribute an article, tip, or question here. Don't forget to checkout [top articles][47] posted in the hall of fame section. -![Debian Linux Adminstration: Tips and Tutorial For Sys Admin][48] - - 1. Debian [administration][49] available in html format. - 2. Support forums: No - - - -## #18: Catonmat - Sed, Awk, Perl Tutorials - -![Sed, Awk, Perl Tutorials][50] - -This site run by a fellow blogger Peteris Krumins. The main focus is on command line and Unix programming topics such as sed, perl, awk, and others. Don't forget to check out [introduction to sed][51], sed [one liner][52] explained, the definitive [guide][53] to Bash Command line history, and [awk][54] liner explained. - - 1. [catonmat][55] available in html format. - 2. Support forums: No - - - -## #19: Debian GNU/Linux Documentation and Wiki - -![Debian Linux Tutorials and Wiki][56] - -Debian is another Linux based operating system that primarily uses software released under the GNU General Public. Debian is well known for strict adherence to the philosophies of Unix and free software. It is also one of popular and influential Linux distribution. It is also used as a base for many other distributions such as Ubuntu and others. The Debian project provides its users with proper documentation in an easily accessible form. The site is divided into wiki, installation guide, faqs, and support forum. - - 1. Debian GNU/Linux [documentation][57] available in html and other format. - 2. Debian GNU/Linux [wiki][58] - 3. Support forums: [Yes][59] - - - -## #20: Linux Sea - -The book "Linux Sea" offers a gentle yet technical (from end-user perspective) introduction to the Linux operating system, using Gentoo Linux as the example Linux distribution. It does not nor will it ever talk about the history of the Linux kernel or Linux distributions or dive into details that are less interesting for Linux users. - - 1. Linux [sea][60] available in html format. - 2. Support forums: No - - - -## #21: Oreilly Commons - -![Oreilly Free Linux / Unix / Php / Javascript / Ubuntu Books][61] - -The oreilly publishing house has posted quite a few titles in wiki format for all. The purpose of this site is to provide content to communities that would like to create, reference, use, modify, update and revise material from O'Reilly or other sources. The site includes books about Ubuntu, Php, Spamassassin, Linux, and much more all for free. - - 1. Oreilly [commons][62] available in wiki format. - 2. Support forums: No - - - -## #22: Ubuntu Pocket Guide - -![Ubuntu Book For New Users][63] - -This book is written by Keir Thomas. This guide/book is a good read for everyday Ubuntu user. The purpose of this book is to introduce you to the Ubuntu operating system, and the philosophy that underpins it. You can download a pdf version from the official site or order a print version using Amazon. - - 1. Ubuntu [pocket guide][64] available in pdf and print formats. - 2. Support forums: No - - - -## #23: Linux: Rute User's Tutorial and Exposition - -![GNU/LINUX system administration book][65] - -This book covers GNU/LINUX system administration, for popular distributions like RedHat and Debian, as a tutorial for new users and a reference for advanced administrators. It aims to give concise, thorough explanations and practical examples of each aspect of a UNIX system. Anyone who wants a comprehensive text on (what is commercially called) LINUX need look no further-there is little that is not covered here. - - 1. Linux: [Rute User's Tutorial and Exposition][66] available in print and html formats. - 2. Support forums: No - - - -## #24: Advanced Linux Programming - -![Advanced Linux Programming][67] - -This book is intended for the programmer already familiar with the C programming language. It take a tutorial approach and teach the most important concepts and power features of the GNU/Linux system in application programs. If you're a developer already experienced with programming for the GNU/Linux system, are experienced with another UNIX-like system and are interested in developing GNU/Linux software, or want to make the transition for a non-UNIX environment and are already familiar with the general principles of writing good software, this book is for you. In addition, you will find that this book is equally applicable to C and C++ programming. - - 1. Advanced [Linux programming][68] available in print and pdf formats. - 2. Support forums: No - - - -## #25: LPI 101 Course Notes - -![Linux Professional Institute Certification Books][69] - -LPIC-1/2/3 levels are certification for Linux administrators. This site provides training manuals for LPI 101 and 102 exams. These are licenced under the GNU Free Documentation Licence (FDL). This course material is based on the objectives for the Linux Professionals Institutea€™s LPI 101 and 102 examination. The course is intended to provide you with the skills required for operating and administering Linux systems. - - 1. Download LPI [training manuals][70] in pdf format. - 2. Support forums: No - - - -## #26: FOSS Manuals - -FLOSS Manuals is a collection of manuals about free and open source software together with the tools used to create them and the community that uses those tools. They include authors, editors, artists, software developers, activists, and many others. There are manuals that explain how to install and use a range of free and open source softwares, about how to do things (like design or stay safe online) with open source software, and manuals about free culture services that use or support free software and formats. You will find manuals about software such as VLC, [Linux video editing][71], Linux, OLPC / SUGAR, GRAPHICS, and much more. - -![FLOSS Manuals is a collection of manuals about free and open source software][72] - - 1. You can browse [FOSS manuals][73] in wiki format. - 2. Support forums: No - - - -## #27: Linux Starter Pack - -![The Linux Starter Pack][74] - -New to the wonderful world of Linux? Looking for an easy way to get started? You can download 130-page guide and get to grips with the OS. This will show you how to install Linux onto your PC, navigate around the desktop, master the most popular Linux programs and fix any problems that may arise. - - 1. Download [Linux starter][75] pack in pdf format. - 2. Support forums: No - - - -## #28: Linux.com - The Source of Linux Info - -Linux.com is a product of the Linux Foundation. The side provides news, guides, tutorials and other information about Linux by harnessing the power of Linux users worldwide to inform, collaborate and connect on all matters Linux. - - 1. Visit [Linux.com][76] online. - 2. Support forums: Yes - - - -## #29: LWN - -LWN is a site with an emphasis on free software and software for Linux and other Unix-like operating systems. It consists of a weekly issue, separate stories which are published most days, and threaded discussion attached to every story. The site provide comprehensive coverage of development, legal, commercial, and security issues related to Linux and FOSS. - - 1. Visit [lwn.net][77] online. - 2. Support forums: No - - - -## #30: Mac OS X Related sites - -A quick links to Max OS X related sites: - - * [Mac OS X Hints][78] - This site is dedicated to the Apple's Mac OS X unix operating systems. It has tons of tips, tricks and tutorial about Bash, and OS X - * [Mac OS development library][79] - Apple has good collection related to OS X development. Don't forget to checkout [bash shell scripting primer][80]. - * [Apple kbase][81] - This is like RHN kbase. It provides guides and troublshooting tips for all apple products including OS X. - - - -## #30: NetBSD - -NetBSD is another free open source operating system based upon the Berkeley Software Distribution (BSD) Unix operating system. The NetBSD project is primarily focused on high quality design, stability and performance of the system. Due to its portability and Berkeley-style license, NetBSD is often used in embedded systems. This site provides links to the official NetBSD documentation and also links to various external documents. - - 1. View [netbsd][82] documentation online in html / pdf format. - 2. Support forums: No - - - -## Your Turn: - -This is my personal list and it is not absolutely definitive, so if you've got your own favorite Unix/Linux specific site, share in the comments below. - -// Image credit: [Flickr photo][83] by PanelSwitchman. Some links are suggested by user on our facebook fan page. - -// For those who celebrate, Merry Christmas! For everyone else, enjoy the weekend. - -## About the author - -The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][84], [Facebook][85], [Google+][86]. - --------------------------------------------------------------------------------- - -via: https://www.cyberciti.biz/tips/linux-unix-bsd-documentations.html - -作者:[Vivek Gite][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.cyberciti.biz -[1]:https://www.cyberciti.biz/media/new/tips/2011/12/unix-pdp11.jpg (Dennis Ritchie and Ken Thompson working with UNIX PDP11) -[2]:https://www.cyberciti.biz/media/new/tips/2011/12/redhat-enterprise-linux-docs-150x150.png (Red hat Enterprise Linux Docs) -[3]:https://access.redhat.com/documentation/en-us/ -[4]:https://www.cyberciti.biz/media/new/tips/2011/12/centos-linux-wiki-150x150.png (Centos Linux Wiki, Support, Documents) -[5]:https://www.cyberciti.biz/media/new/tips/2011/12/arch-linux-wiki-150x150.png (Arch Linux wiki and tutorials ) -[6]:https://wiki.archlinux.org/index.php/Category:Networking_%28English%29 -[7]:https://bbs.archlinux.org/ -[8]:https://wiki.archlinux.org/ -[9]:https://www.cyberciti.biz/media/new/tips/2011/12/gentoo-linux-wiki1-150x150.png (Gentoo Linux Handbook and Wiki) -[10]:http://www.gentoo.org/doc/en/handbook/ -[11]:https://wiki.gentoo.org -[12]:https://forums.gentoo.org/ -[13]:http://gentoo-wiki.com -[14]:https://www.cyberciti.biz/media/new/tips/2011/12/ubuntu-linux-wiki.png (Ubuntu Linux Wiki and Forums) -[15]:https://help.ubuntu.com/community -[16]:https://help.ubuntu.com/ -[17]:https://ubuntuforums.org/ -[18]:https://www.cyberciti.biz/media/new/tips/2011/12/ibm-devel.png (IBM: Technical for Linux programmers and system administrators) -[19]:https://www.ibm.com/developerworks/learn/linux/index.html -[20]:https://www.ibm.com/developerworks/community/forums/html/public?lang=en -[21]:https://www.cyberciti.biz/media/new/tips/2011/12/freebsd-docs.png (Freebsd Documentation) -[22]:https://www.cyberciti.biz/media/new/tips/2011/12/bash-hackers-wiki-150x150.png (Bash hackers wiki for bash users) -[23]:http://wiki.bash-hackers.org/doku.php -[24]:https://www.cyberciti.biz/media/new/tips/2011/12/bash-faq-150x150.png (Bash FAQ: Answers to frequently asked questions about GNU/BASH) -[25]:http://mywiki.wooledge.org/BashPitfalls -[26]:https://mywiki.wooledge.org/BashFAQ -[27]:https://www.cyberciti.biz/media/new/tips/2011/12/howtoforge-150x150.png (Howtoforge tutorials) -[28]:https://howtoforge.com/ -[29]:https://www.cyberciti.biz/media/new/tips/2011/12/openbsd-faq-150x150.png (OpenBSD Documenation) -[30]:https://www.openbsd.org/faq/index.html -[31]:https://www.openbsd.org/mail.html -[32]:https://www.cyberciti.biz/media/new/tips/2011/12/calomel_org.png (Open Source Research and Reference Documentation) -[33]:https://calomel.org -[34]:https://www.cyberciti.biz/media/new/tips/2011/12/slackware-linux-book-150x150.png (Slackware Linux Book and Documentation ) -[35]:http://www.slackbook.org/ -[36]:https://www.cyberciti.biz/media/new/tips/2011/12/tldp-150x150.png (Linux Learning Site and Documentation ) -[37]:http://tldp.org/LDP/abs/html/index.html -[38]:http://tldp.org/HOWTO/HOWTO-INDEX/howtos.html -[39]:http://tldp.org/ -[40]:https://www.cyberciti.biz/media/new/tips/2011/12/linuxhomenetworking-150x150.png (Linux Home Networking ) -[41]:http://www.linuxhomenetworking.com/ -[42]:https://www.cyberciti.biz/media/new/tips/2011/12/linux-action-show-150x150.png (Linux Podcast ) -[43]:http://www.jupiterbroadcasting.com/show/linuxactionshow/ -[44]:https://www.commandlinefu.com/commands/browse/sort-by-votes -[45]:https://www.cyberciti.biz/media/new/tips/2011/12/commandlinefu.png (The best Unix / Linux Commands ) -[46]:https://commandlinefu.com/ -[47]:https://www.debian-administration.org/hof -[48]:https://www.cyberciti.biz/media/new/tips/2011/12/debian-admin.png (Debian Linux Adminstration: Tips and Tutorial For Sys Admin) -[49]:https://www.debian-administration.org/ -[50]:https://www.cyberciti.biz/media/new/tips/2011/12/catonmat-150x150.png (Sed, Awk, Perl Tutorials) -[51]:http://www.catonmat.net/blog/worlds-best-introduction-to-sed/ -[52]:https://www.catonmat.net/blog/sed-one-liners-explained-part-one/ -[53]:https://www.catonmat.net/blog/the-definitive-guide-to-bash-command-line-history/ -[54]:https://www.catonmat.net/blog/awk-one-liners-explained-part-one/ -[55]:https://catonmat.net/ -[56]:https://www.cyberciti.biz/media/new/tips/2011/12/debian-wiki-150x150.png (Debian Linux Tutorials and Wiki) -[57]:https://www.debian.org/doc/ -[58]:https://wiki.debian.org/ -[59]:https://www.debian.org/support -[60]:http://swift.siphos.be/linux_sea/ -[61]:https://www.cyberciti.biz/media/new/tips/2011/12/orelly-150x150.png (Oreilly Free Linux / Unix / Php / Javascript / Ubuntu Books) -[62]:http://commons.oreilly.com/wiki/index.php/O%27Reilly_Commons -[63]:https://www.cyberciti.biz/media/new/tips/2011/12/ubuntu-guide-150x150.png (Ubuntu Book For New Users) -[64]:http://ubuntupocketguide.com/ -[65]:https://www.cyberciti.biz/media/new/tips/2011/12/rute-150x150.png (GNU/LINUX system administration free book) -[66]:https://web.archive.org/web/20160204213406/http://rute.2038bug.com/rute.html.gz -[67]:https://www.cyberciti.biz/media/new/tips/2011/12/advanced-linux-programming-150x150.png (Download Advanced Linux Programming PDF version) -[68]:https://github.com/MentorEmbedded/advancedlinuxprogramming -[69]:https://www.cyberciti.biz/media/new/tips/2011/12/lpic-150x150.png (Download Linux Professional Institute Certification PDF Book) -[70]:http://academy.delmar.edu/Courses/ITSC1358/eBooks/LPI-101.LinuxTrainingCourseNotes.pdf -[71]://www.cyberciti.biz/faq/top5-linux-video-editing-system-software/ -[72]:https://www.cyberciti.biz/media/new/tips/2011/12/floss-manuals.png (Download manuals about free and open source software) -[73]:https://flossmanuals.net/ -[74]:https://www.cyberciti.biz/media/new/tips/2011/12/linux-starter-150x150.png (New to Linux? Start Linux starter book [ PDF version ]) -[75]:http://www.tuxradar.com/linuxstarterpack -[76]:https://linux.com -[77]:https://lwn.net/ -[78]:http://hints.macworld.com/ -[79]:https://developer.apple.com/library/mac/navigation/ -[80]:https://developer.apple.com/library/mac/#documentation/OpenSource/Conceptual/ShellScripting/Introduction/Introduction.html -[81]:https://support.apple.com/kb/index?page=search&locale=en_US&q= -[82]:https://www.netbsd.org/docs/ -[83]:https://www.flickr.com/photos/9479603@N02/3311745151/in/set-72157614479572582/ -[84]:https://twitter.com/nixcraft -[85]:https://facebook.com/nixcraft -[86]:https://plus.google.com/+CybercitiBiz -[87]:https://wiki.centos.org/ -[88]:https://www.centos.org/forums/ -[90]: https://www.freebsd.org/docs.html -[91]: https://forums.freebsd.org/ diff --git a/translated/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md b/translated/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md index 349973bec0..f12810e602 100644 --- a/translated/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md +++ b/translated/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md @@ -11,18 +11,26 @@ Man pages are written by sys-admin and developers for IT techs, and are intended more as a reference than as a how to. Man pages are very useful for people who are already familiar with Linux, Unix, and BSD operating systems. Use man pages when you just need to know the syntax for particular commands or configuration file, but they are not helpful for new Linux users. Man pages are not good for learning something new for the first time. Here are thirty best documentation sites on the web for learning Linux and Unix like operating systems. +首先我要说 Man 手册是为系统管理员和开发人员编写的,多数时间它是用来查询信息,而不是用于学习。Man 手册对于熟悉 Linux , Unix , BSD 系统操作的人来说非常有用。当您只需要知道特定命令或配置文件的语法时,请使用 Man 手册,但它们对新 Linux 用户没有帮助。 手册页不适合第一次学习新东西。 这里有三十个最好的文档站点,用于学习 Linux 和 Unix 之类的操作系统。 + ![Dennis Ritchie and Ken Thompson working with UNIX PDP11][1] Please note that BSD manpages are usually better as compare to Linux. +请注意 BSD 的 Man 手册比 Linux 的更好一些。 + ## #1: Red Hat Enterprise Linux ![Red hat Enterprise Linux Docs][2] RHEL is developed by Red Hat and targeted toward the commercial market. It has one of the best documentations covering basis of RHEL to advanced topics like security, SELinux, virtualization, directory server, clustering, JBOSS, HPC, and much more. Red Hat documentation has been translated into twenty-two languages and is available in multi-page HTML, single-page HTML, PDF, and EPUB formats. The good news is you can use the same documentation for CentOS or Scientific Linux (community enterprise distros). All of these documents ship with the OS, so if you don't have a network connection, then you have them there as well. The RHEL docs **covers everything from installation to configuring clusters**. The only downside is you need to be a paid customer. This is perfect for an enterprise company. - 1. RHEL Documentation: [in HTML/PDF format][3] - 2. Support forums: Only available to Red Hat customer portal to submit a support case. +RHEL 由 Red Hat 开发,面向商业市场的 Linux 发行版。 它有一个最好的文档,涵盖 RHEL 的基础,如安全性,SELinux,虚拟化,目录服务器,集群,JBOSS ,HPC 等高级主题。 Red Hat 文档已被翻译成二十二种语言,并提供多页 HTML,单页 HTML ,PDF 和 EPUB 格式。 好消息是您可以使用 CentOS 或 Scientific Linux(社区企业发行版)的相同文档。 所有这些文件都附带在操作系统里,因此如果您没有网络连接,那么您也可以使用它们。 RHEL文档涵盖从安装到配置集群的所有内容。 唯一的缺点是你需要成为付费客户。 这对于企业公司来说是完美的。 + + 1. RHEL Documentation: [in HTML/PDF format][3] + 2. RHEL 官方文档连接:[in HTML/PDF format][3] + 3. Support forums: Only available to Red Hat customer portal to submit a support case. + 4. 技术支持论坛:仅适用于 Red Hat 客户提交报告使用 From 3cd20f5274d5024d600779043ac9c1811988d8b5 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 7 Sep 2018 09:09:48 +0800 Subject: [PATCH 101/455] translated --- ...To Reset MySQL Or MariaDB Root Password.md | 100 ------------------ ...To Reset MySQL Or MariaDB Root Password.md | 98 +++++++++++++++++ 2 files changed, 98 insertions(+), 100 deletions(-) delete mode 100644 sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md create mode 100644 translated/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md diff --git a/sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md b/sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md deleted file mode 100644 index 5d4c316e6d..0000000000 --- a/sources/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md +++ /dev/null @@ -1,100 +0,0 @@ -translating---geekpi - -How To Reset MySQL Or MariaDB Root Password -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/08/Reset-MySQL-Or-MariaDB-Root-Password-720x340.png) - -Few months ago, I had [**setup LAMP stack in Ubuntu 18.04**][1] server. Today, I tried to login as root user in my database server, but I completely forgot the password. After couple Google searches and going through some blog posts, I successfully reset the password. For those wondering how to do this, this brief tutorial explains how can we reset MySQL or MariaDB Root password in Unix-like operating systems. - -### Reset MySQL or MariaDB Root password - -First, stop the database server. - -If you use MySQL, type the following command and hit ENTER key. -``` -$ sudo systemctl stop mysql - -``` - -For MariaDB: -``` -$ sudo systemctl stop mariadb - -``` - -Next, restart the database server without permission checking using the following command: -``` -$ sudo mysqld_safe --skip-grant-tables & - -``` - -Here, the **`--skip-grant-tables`**option allows you to connect without a password and with all privileges. If you start your server with this option, it also enables `--skip-networking`option which is used to prevent the other clients from connecting to the database server. And, the ampersand **( &)** symbol is used to run the command in background, so you could type the other commands in the following steps. Please be mindful that the above command is dangerous and your database server becomes insecure. You should run this command only for a brief period to reset the password. - -Next, login to your MySQL/MariaDB server as root user: -``` -$ mysql - -``` - -At the **mysql >** or **MariaDB [(none)] >** prompt, run the following command to reset the root user password: -``` -UPDATE mysql.user SET Password=PASSWORD('NEW-PASSWORD') WHERE User='root'; - -``` - -Replace **NEW-PASSWORD** in the above command with your own password. - -Then, type following commands to exit from the mysql console. -``` -FLUSH PRIVILEGES; - -exit - -``` - -Finally, shutdown the running database server that you started earlier with `--skip-grant-tables`option. To do so, run: -``` -$ sudo mysqladmin -u root -p shutdown - -``` - -You will be asked to enter your mysql/mariadb root user password that you set in the previous step. - -Now, start mysql/mariadb service normally using command: -``` -$ sudo systemctl start mysql - -``` - -For MariaDB: -``` -$ sudo systemctl start mariadb - -``` - -Verify if the password has really been changed using the following command: -``` -$ mysql -u root -p - -``` - -And, that’s all for today. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-reset-mysql-or-mariadb-root-password/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/sk/ -[1]: https://www.ostechnix.com/install-apache-mariadb-php-lamp-stack-ubuntu-16-04/ diff --git a/translated/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md b/translated/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md new file mode 100644 index 0000000000..86abdf1151 --- /dev/null +++ b/translated/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md @@ -0,0 +1,98 @@ +如何重置 MySQL 或 MariaDB 的 Root 密码 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/08/Reset-MySQL-Or-MariaDB-Root-Password-720x340.png) + +几个月前,我在[**Ubuntu 18.04 上安装了 LAMP**][1]。今天,我尝试以 root 用户身份登录数据库,但我完全忘记了密码。经过一阵 Google 搜索并浏览一些文章后,我成功重置了密码。对于那些想知道如何做到这一点的人,这个简短的教程解释了如何在类 Unix 操作系统中重置 MySQL 或 MariaDB Root 密码。 + +### 重置 MySQL 或 MariaDB Root 密码 + +首先,停止数据库。 + +如果你使用 MySQL,请输入以下命令并下按回车键。 +``` +$ sudo systemctl stop mysql + +``` + +对于 MariaDB: +``` +$ sudo systemctl stop mariadb + +``` + +接下来,使用以下命令在没有权限检查的情况下重新启动数据库: +``` +$ sudo mysqld_safe --skip-grant-tables & + +``` + +这里, **`--skip-grant-tables`** 选项让你在没有密码和所有权限的情况下进行连接。如果使用此选项启动服务器,它还会启用 `--skip-networking` 选项,这用于防止其他客户端连接到数据库服务器。并且,**( &)**符号用于在后台运行命令,因此你可以在以下步骤中输入其他命令。请注意,上述命令很危险,并且你的数据库会变得不安全。你应该只在短时间内运行此命令以重置密码。 + +接下来,以 root 用户身份登录 MySQL/MariaDB 服务器: +``` +$ mysql + +``` + +在 **mysql >** 或 **MariaDB [(none)] >** 提示符下,运行以下命令重置 root 用户密码: +``` +UPDATE mysql.user SET Password=PASSWORD('NEW-PASSWORD') WHERE User='root'; + +``` + +使用你自己的密码替换上述命令中的 **NEW-PASSWORD**。 + +然后,输入以下命令退出 mysql 控制台。 +``` +FLUSH PRIVILEGES; + +exit + +``` + +最后,关闭之前使用 `--skip-grant-tables` 选项运行的数据库。为此,运行: +``` +$ sudo mysqladmin -u root -p shutdown + +``` + +系统将要求你输入在上一步中设置的 mysql/mariadb 用户密码。 + +现在,使用以下命令正常启动 mysql/mariadb 服务: +``` +$ sudo systemctl start mysql + +``` + +对于 MariaDB: +``` +$ sudo systemctl start mariadb + +``` + +使用以下命令验证密码是否确实已更改: +``` +$ mysql -u root -p + +``` + +今天就是这些了。还有更多好东西。敬请期待! + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-reset-mysql-or-mariadb-root-password/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://www.ostechnix.com/install-apache-mariadb-php-lamp-stack-ubuntu-16-04/ From 3161e73b701489d232adc2fd1936032e55d10066 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 7 Sep 2018 09:14:16 +0800 Subject: [PATCH 102/455] translating --- .../20180905 Find your systems easily on a LAN with mDNS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180905 Find your systems easily on a LAN with mDNS.md b/sources/tech/20180905 Find your systems easily on a LAN with mDNS.md index ca21d2b66b..40da04358e 100644 --- a/sources/tech/20180905 Find your systems easily on a LAN with mDNS.md +++ b/sources/tech/20180905 Find your systems easily on a LAN with mDNS.md @@ -1,3 +1,5 @@ +translating---geekpi + Find your systems easily on a LAN with mDNS ====== From 7b91f799ba918f1c083ac7f721c93107fc8660c1 Mon Sep 17 00:00:00 2001 From: sober-wang Date: Fri, 7 Sep 2018 10:42:22 +0800 Subject: [PATCH 103/455] =?UTF-8?q?=E7=94=B3=E8=AF=B7=20pr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nux - -BSD - Unix Documentation On the Web.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) rename {translated => sources}/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md (94%) diff --git a/translated/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md b/sources/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md similarity index 94% rename from translated/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md rename to sources/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md index f12810e602..81e3acacdb 100644 --- a/translated/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md +++ b/sources/tech/20111221 30 Best Sources For Linux - -BSD - Unix Documentation On the Web.md @@ -2,35 +2,25 @@ -30 Best Sources For Linux / *BSD / Unix Documentation On the Web +30 Best Sources For Linux / *BSD / Unix Documentation On the We ====== -# 30 个最佳的 Linux / *BSD / Unix 在线文档 - Man pages are written by sys-admin and developers for IT techs, and are intended more as a reference than as a how to. Man pages are very useful for people who are already familiar with Linux, Unix, and BSD operating systems. Use man pages when you just need to know the syntax for particular commands or configuration file, but they are not helpful for new Linux users. Man pages are not good for learning something new for the first time. Here are thirty best documentation sites on the web for learning Linux and Unix like operating systems. -首先我要说 Man 手册是为系统管理员和开发人员编写的,多数时间它是用来查询信息,而不是用于学习。Man 手册对于熟悉 Linux , Unix , BSD 系统操作的人来说非常有用。当您只需要知道特定命令或配置文件的语法时,请使用 Man 手册,但它们对新 Linux 用户没有帮助。 手册页不适合第一次学习新东西。 这里有三十个最好的文档站点,用于学习 Linux 和 Unix 之类的操作系统。 - ![Dennis Ritchie and Ken Thompson working with UNIX PDP11][1] Please note that BSD manpages are usually better as compare to Linux. -请注意 BSD 的 Man 手册比 Linux 的更好一些。 - ## #1: Red Hat Enterprise Linux ![Red hat Enterprise Linux Docs][2] RHEL is developed by Red Hat and targeted toward the commercial market. It has one of the best documentations covering basis of RHEL to advanced topics like security, SELinux, virtualization, directory server, clustering, JBOSS, HPC, and much more. Red Hat documentation has been translated into twenty-two languages and is available in multi-page HTML, single-page HTML, PDF, and EPUB formats. The good news is you can use the same documentation for CentOS or Scientific Linux (community enterprise distros). All of these documents ship with the OS, so if you don't have a network connection, then you have them there as well. The RHEL docs **covers everything from installation to configuring clusters**. The only downside is you need to be a paid customer. This is perfect for an enterprise company. -RHEL 由 Red Hat 开发,面向商业市场的 Linux 发行版。 它有一个最好的文档,涵盖 RHEL 的基础,如安全性,SELinux,虚拟化,目录服务器,集群,JBOSS ,HPC 等高级主题。 Red Hat 文档已被翻译成二十二种语言,并提供多页 HTML,单页 HTML ,PDF 和 EPUB 格式。 好消息是您可以使用 CentOS 或 Scientific Linux(社区企业发行版)的相同文档。 所有这些文件都附带在操作系统里,因此如果您没有网络连接,那么您也可以使用它们。 RHEL文档涵盖从安装到配置集群的所有内容。 唯一的缺点是你需要成为付费客户。 这对于企业公司来说是完美的。 - 1. RHEL Documentation: [in HTML/PDF format][3] - 2. RHEL 官方文档连接:[in HTML/PDF format][3] - 3. Support forums: Only available to Red Hat customer portal to submit a support case. - 4. 技术支持论坛:仅适用于 Red Hat 客户提交报告使用 + 2. Support forums: Only available to Red Hat customer portal to submit a support case. @@ -463,7 +453,7 @@ via: https://www.cyberciti.biz/tips/linux-unix-bsd-documentations.html [78]:http://hints.macworld.com/ [79]:https://developer.apple.com/library/mac/navigation/ [80]:https://developer.apple.com/library/mac/#documentation/OpenSource/Conceptual/ShellScripting/Introduction/Introduction.html -[81]:https://support.apple.com/kb/index?page=search&locale=en_US&q= +[81]:https://support.apple.com/kb/index?page=search&locale=en_US&q= [82]:https://www.netbsd.org/docs/ [83]:https://www.flickr.com/photos/9479603@N02/3311745151/in/set-72157614479572582/ [84]:https://twitter.com/nixcraft From 3e48ea7e365cd29f749face8d7f822df41ec0f17 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 7 Sep 2018 11:13:50 +0800 Subject: [PATCH 104/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Two=20open=20sour?= =?UTF-8?q?ce=20alternatives=20to=20Flash=20Player?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...pen source alternatives to Flash Player.md | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 sources/tech/20180906 Two open source alternatives to Flash Player.md diff --git a/sources/tech/20180906 Two open source alternatives to Flash Player.md b/sources/tech/20180906 Two open source alternatives to Flash Player.md new file mode 100644 index 0000000000..c128c484e1 --- /dev/null +++ b/sources/tech/20180906 Two open source alternatives to Flash Player.md @@ -0,0 +1,56 @@ +Two open source alternatives to Flash Player +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bulb-light-energy-power-idea.png?itok=zTEEmTZB) + +In July 2017, Adobe sounded the [death knell][1] for its Flash Media Player, announcing it would end support for the once-ubiquitous online video player in 2020. In truth, however, Flash has been on the decline for the past eight years following a rash of zero-day attacks that damaged its reputation. Its future dimmed after Apple announced in 2010 it would not support the technology, and its demise accelerated in 2016 after Google stopped enabling Flash by default (in favor of HTML5) in the Chrome browser. + +Even so, Adobe is still issuing monthly updates for the software, which has slipped from being used on 28.5% of all websites in 2011 to [only 4.4.%][2] as of August 2018. More evidence of Flash’s decline: Google director of engineering [Parisa Tabriz said][3] the number of Chrome users who access Flash content via the browser has declined from 80% in 2014 to under eight percent in 2018. + +Although few* video creators are publishing in Flash format today, there are still a lot of Flash videos out there that people will want to access for years to come. Given that the official application’s days are numbered, open source software creators have a great opportunity to step in with alternatives to Adobe Flash Media Player. Two of those applications are Lightspark and GNU Gnash. Neither are perfect substitutions, but help from willing contributors could make them viable alternatives. + +### Lightspark + +[Lightspark][4] is a Flash Player alternative for Linux machines. While it’s still in alpha, development has accelerated since Adobe announced it would sunset Flash in 2017. According to its website, Lightspark implements about 60% of the Flash APIs and [works][5] on many leading websites including BBC News, Google Play Music, and Amazon Music. + +Lightspark is written in C++/C and licensed under [LGPLv3][6]. The project lists 41 contributors and is actively soliciting bug reports and other contributions. For more information, check out its [GitHub repository][5]. + +### GNU Gnash + +[GNU Gnash][7] is a Flash Player for GNU/Linux operating systems including Ubuntu, Fedora, and Debian. It works as standalone software and as a plugin for the Firefox and Konqueror browsers. + +Gnash’s main drawback is that it doesn’t support the latest versions of Flash files—it supports most Flash SWF v7 features, some v8 and v9 features, and offers no support for v10 files. It’s in beta release, and since it’s licensed under the [GNU GPLv3 or later][8], you can help contribute to modernizing it. Access its [project page][9] for more information. + +### Want to create Flash? + +*Just because most people aren't publishing Flash videos these days, that doesn't mean there will never, ever be a need to create SWF files. If you find yourself in that position, these two open source tools might help: + + * [Motion-Twin ActionScript 2 Compiler][10] (MTASC): A command-line compiler that can generate SWF files without Adobe Animate (the current iteration of Adobe's video-creator software). + * [Ming][11]: A library written in C that can generate SWF files. It also contains some [utilities][12] you can use to work with Flash files. + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/alternatives/flash-media-player + +作者:[Opensource.com][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com +[1]: https://theblog.adobe.com/adobe-flash-update/ +[2]: https://w3techs.com/technologies/details/cp-flash/all/all +[3]: https://www.bleepingcomputer.com/news/security/google-chrome-flash-usage-declines-from-80-percent-in-2014-to-under-8-percent-today/ +[4]: http://lightspark.github.io/ +[5]: https://github.com/lightspark/lightspark/wiki/Site-Support +[6]: https://github.com/lightspark/lightspark/blob/master/COPYING +[7]: https://www.gnu.org/software/gnash/ +[8]: http://www.gnu.org/licenses/gpl-3.0.html +[9]: http://savannah.gnu.org/projects/gnash/ +[10]: http://tech.motion-twin.com/mtasc.html +[11]: http://www.libming.org/ +[12]: http://www.libming.org/WhatsIncluded From 2913c2f38e049f55cdae3ce22b400dfed1d5e471 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 7 Sep 2018 11:20:14 +0800 Subject: [PATCH 105/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=203=20top=20open=20?= =?UTF-8?q?source=20JavaScript=20chart=20libraries?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... open source JavaScript chart libraries.md | 246 ++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 sources/tech/20180906 3 top open source JavaScript chart libraries.md diff --git a/sources/tech/20180906 3 top open source JavaScript chart libraries.md b/sources/tech/20180906 3 top open source JavaScript chart libraries.md new file mode 100644 index 0000000000..096d7ce5e6 --- /dev/null +++ b/sources/tech/20180906 3 top open source JavaScript chart libraries.md @@ -0,0 +1,246 @@ +3 top open source JavaScript chart libraries +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/books_library_reading_list_colorful.jpg?itok=jJtnyniB) + +Charts and graphs are important for visualizing data and making websites appealing. Visual presentations make it easier to analyze big chunks of data and convey information. JavaScript chart libraries enable you to visualize data in a stunning, easy to comprehend, and interactive manner and improve your website's design. + +In this article, learn about three top open source JavaScript chart libraries. + +### 1\. Chart.js + +[Chart.js][1] is an open source JavaScript library that allows you to create animated, beautiful, and interactive charts on your application. It's available under the MIT License. + +With Chart.js, you can create various impressive charts and graphs, including bar charts, line charts, area charts, linear scale, and scatter charts. It is completely responsive across various devices and utilizes the HTML5 Canvas element for rendering. + +Here is example code that draws a bar chart using the library. We'll include it in this example using the Chart.js content delivery network (CDN). Note that the data used is for illustration purposes only. +``` + + + +  + + + +    +    + +    +    +    +    + + +``` + +As you can see from this code, bar charts are constructed by setting **type** to **bar**. You can change the direction of the bar to other types—such as setting **type** to **horizontalBar**. + +The bars' colors are set by providing the type of color in the **backgroundColor** array parameter. + +The colors are allocated to the label and data that share the same index in their corresponding array. For example, "Latin America," the second label, will be set to "blue" (the second color) and 4 (the second number in the data). + +Here is the output of this code. + +![](https://opensource.com/sites/default/files/uploads/chartjs-output.png) + +### 2\. Chartist.js + +[Chartist.js][2] is a simple JavaScript animation library that allows you to create customizable and beautiful responsive charts and other designs. The open source library is available under the WTFPL or MIT License. + +The library was developed by a group of developers who were dissatisfied with existing charting tools, so it offers wonderful functionalities to designers and developers. + +After including the Chartist.js library and its CSS files in your project, you can use them to create various types of charts, including animations, bar charts, and line charts. It utilizes SVG to render the charts dynamically. + +Here is an example of code that draws a pie chart using the library. +``` + + + +    +    +    +    +      + + + +   
+ +    + +    + + +``` + +Instead of specifying various style-related components of your project, the Chartist JavaScript library allows you to use various pre-built CSS styles. You can use them to control the appearance of the created charts. + + +For example, the pre-created CSS classis used to build the container for the pie chart. And, theclass is used to get the aspect ratios, which scale with responsive designs and saves you the hassle of calculating fixed dimensions. Chartist also provides other classes of container ratios you can utilize in your project. + +For styling the various pie slices, you can use the default . **ct-series-a** class. The letter **a** is iterated with every series count (a, b, c, etc.) such that it corresponds with the slice to be styled. + +The **Chartist.Pie** method is used for creating a pie chart. To create another type of chart, such as a line chart, use **Chartist.Line.** + +Here is the output of the code. + +![](https://opensource.com/sites/default/files/uploads/chartistjs-output.png) + +### 3\. D3.js + +[D3.js][3] is another great open source JavaScript chart library. It's available under the BSD license. D3 is mainly used for manipulating and adding interactivity to documents based on the provided data. + +You can use this amazing 3D animation library to visualize your data using HTML5, SVG, and CSS and make your website appealing. Essentially, D3 enables you to bind data to the Document Object Model (DOM) and then use data-based functions to make changes to the document. + +Here is example code that draws a simple bar chart using the library. +``` + + + +      +    +      + + + +   
+    +    + +    + + +``` + +The main concept in using the D3 library is to first apply CSS-style selections to point to the DOM nodes and then apply operators to manipulate them—just like in other DOM frameworks like jQuery. + +After the data is bound to a document, the . **enter()** function is invoked to build new nodes for incoming data. All the methods invoked after the . **enter()** function will be called for every item in the data. + +Here is the output of the code. + +![](https://opensource.com/sites/default/files/uploads/d3js-output.png) + +### Wrapping up + +[JavaScript][4] charting libraries provide you with powerful tools for implementing data visualization on your web properties. With these three open source libraries, you can enhance the beauty and interactivity of your websites. + +Do you know of another powerful frontend library for creating JavaScript animation effects? Please let us know in the comment section below. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/open-source-javascript-chart-libraries + +作者:[Dr.Michael J.Garbade][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/drmjg +[1]: https://www.chartjs.org/ +[2]: https://gionkunz.github.io/chartist-js/ +[3]: https://d3js.org/ +[4]: https://www.liveedu.tv/guides/programming/javascript/ From 29d8fa6ac93a3aa80f6254668ef55e0659edddbd Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 7 Sep 2018 11:23:50 +0800 Subject: [PATCH 106/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20What=20a=20shell?= =?UTF-8?q?=20dotfile=20can=20do=20for=20you?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...906 What a shell dotfile can do for you.md | 238 ++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 sources/tech/20180906 What a shell dotfile can do for you.md diff --git a/sources/tech/20180906 What a shell dotfile can do for you.md b/sources/tech/20180906 What a shell dotfile can do for you.md new file mode 100644 index 0000000000..35593e1e32 --- /dev/null +++ b/sources/tech/20180906 What a shell dotfile can do for you.md @@ -0,0 +1,238 @@ +What a shell dotfile can do for you +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o) + +Ask not what you can do for your shell dotfile, but what a shell dotfile can do for you! + +I've been all over the OS map, but for the past several years my daily drivers have been Macs. For a long time, I used Bash, but when a few friends started proselytizing [zsh][1], I gave it a shot. It didn't take long for me to appreciate it, and several years later, I strongly prefer it for many of the little things that it does. + +I've been using zsh (provided via [Homebrew][2], not the system installed), and the [Oh My Zsh enhancement][3]. + +The examples in this article are for my personal `.zshrc`. Most will work directly in Bash, and I don't believe that any rely on Oh My Zsh, but your mileage may vary. There was a period when I was maintaining a shell dotfile for both zsh and Bash, but I did eventually give up on my `.bashrc`. + +### We're all mad here + +If you want the possibility of using the same dotfile across OS's, you'll want to give your dotfile a little smarts. +``` +### Mac Specifics +if [[ "$OSTYPE" == "darwin"* ]]; then +        # Mac-specific stuff here. +fi +``` + +For instance, I expect the Alt + arrow keys to move the cursor by the word rather than by a single space. To make this happen in [iTerm2][4] (my preferred shell), I add this snippet to the Mac-specific portion of my .zshrc: +``` +### Mac Specifics +if [[ "$OSTYPE" == "darwin"* ]]; then +        ### Mac cursor commands for iTerm2; map ctrl+arrows or alt+arrows to fast-move +        bindkey -e +        bindkey '^[[1;9C' forward-word +        bindkey '^[[1;9D' backward-word +        bindkey '\e\e[D' backward-word +        bindkey '\e\e[C' forward-word +fi +``` + +### What about Bob? + +While I came to love my shell dotfile, I didn't always want the same things available on my home machines as on my work machines. One way to solve this is to have supplementary dotfiles to use at home but not at work. Here's how I accomplished this: +``` +if [[ `egrep 'dnssuffix1|dnssuffix2' /etc/resolv.conf` ]]; then +        if [ -e $HOME/.work ] +                source $HOME/.work +        else +                echo "This looks like a work machine, but I can't find the ~/.work file" +        fi +fi +``` + +In this case, I key off of my work dns suffix (or multiple suffixes, depending on your situation) and source a separate file that makes my life at work a little better. + +### That thing you do + +Now is probably a good time to quit using the tilde (`~`) to represent your home directory when writing scripts. You'll find that there are some contexts where it's not recognized. Getting in the habit of using the environment variable `$HOME` will save you a lot of troubleshooting time and headaches later on. + +The logical extension would be to have OS-specific dotfiles to include if you are so inclined. + +### Memory, all alone in the moonlight + +I've written embarrassing amounts of shell, and I've come to the conclusion that I really don't want to write more. It's not that shell can't do what I need most of the time, but I find that if I'm writing shell, I'm probably slapping together a duct-tape solution rather than permanently solving the problem. + +Likewise, I hate memorizing things, and throughout my career, I have had to do radical context shifting during the course of a day. The practical consequence is that I've had to re-learn many things several times over the years. ("Wait... which for-loop structure does this language use?") + +So, every so often I decide that I'm tired of looking up how to do something again. One way that I improve my life is by adding aliases. + +A common scenario for anyone who works with systems is finding out what's taking up all of the disk. Unfortunately, I have never been able to remember this incantation, so I made a shell alias, creatively called `bigdirs`: +``` +alias bigdirs='du --max-depth=1 2> /dev/null | sort -n -r | head -n20' +``` + +While I could be less lazy and actually memorize it, well, that's just not the Unix way... + +### Typos, and the people who love them + +Another way that using shell aliases improves my life is by saving me from typos. I don't know why, but I've developed this nasty habit of typing a `w` after the sequence `ea`, so if I want to clear my terminal, I'll often type `cleawr`. Unfortunately, that doesn't mean anything to my shell. Until I add this little piece of gold: +``` +alias cleawr='clear' +``` + +In one instance of Windows having an equivalent, but better, command, I find myself typing `cls`. It's frustrating to see your shell throw up its hands, so I add: +``` +alias cls='clear' +``` + +Yes, I'm aware of `ctrl + l`, but I never use it. + +### Amuse yourself + +Work can be stressful. Sometimes you just need to have a little fun. If your shell doesn't know the command that it clearly should just do, maybe you want to shrug your shoulders right back at it! You can do this with a function: +``` +shrug() { echo "¯\_(ツ)_/¯"; } +``` + +If that doesn't work, maybe you need to flip a table: +``` +fliptable() { echo "(╯°□°)╯ ┻━┻"; } # Flip a table. Example usage: fsck -y /dev/sdb1 || fliptable +``` + +Imagine my chagrin and frustration when I needed to flip a desk and I couldn't remember what I had called it. So I added some more shell aliases: +``` +alias flipdesk='fliptable' +alias deskflip='fliptable' +alias tableflip='fliptable' +``` + +And sometimes you need to celebrate: +``` +disco() { +        echo "(•_•)" +        echo "<)   )╯" +        echo " /    \ " +        echo "" +        echo "\(•_•)" +        echo " (   (>" +        echo " /    \ " +        echo "" +        echo " (•_•)" +        echo "<)   )>" +        echo " /    \ " +} +``` + +Typically, I'll pipe the output of these commands to `pbcopy `and paste it into the relevant chat tool I'm using. + +I got this fun function from a Twitter account that I follow called "Command Line Magic:" [@climagic][5]. Since I live in Florida now, I'm very happy that this is the only snow in my life: +``` +snow() { +        clear;while :;do echo $LINES $COLUMNS $(($RANDOM%$COLUMNS));sleep 0.1;done|gawk '{a[$3]=0;for(x in a) {o=a[x];a[x]=a[x]+1;printf "\033[%s;%sH ",o,x;printf "\033[%s;%sH*\033[0;0H",a[x],x;}}' +} + +``` + +### Fun with functions + +We've seen some examples of functions that I use. Since few of these examples require an argument, they could be done as aliases. I use functions out of personal preference when it's more than a single short statement. + +At various times in my career, I've run [Graphite][6], an open-source, scalable, time-series metrics solution. There have been enough instances where I needed to transpose a metric path (delineated with periods) to a filesystem path (delineated with slashes), or vice versa, that it became useful to have dedicated functions for these tasks: +``` +# Useful for converting between Graphite metrics and file paths +function dottoslash() { +        echo $1 | sed 's/\./\//g' +} +function slashtodot() { +        echo $1 | sed 's/\//\./g' +} +``` + +During another time in my career, I was running a lot of Kubernetes. If you aren't familiar with running Kubernetes, you need to write a lot of YAML. Unfortunately, it's not hard to write invalid YAML. Worse, Kubernetes doesn't validate YAML before trying to apply it, so you won't find out it's invalid until you apply it. Unless you validate it first: +``` +function yamllint() { +        for i in $(find . -name '*.yml' -o -name '*.yaml'); do echo $i; ruby -e "require 'yaml';YAML.load_file(\"$i\")"; done +} +``` + +Because I got tired of embarrassing myself and occasionally breaking a customer's setup, I wrote this little snippet and added it as a pre-commit hook to all of my relevant repos. Something similar would be very helpful as part of your continuous integration process, especially if you're working as part of a team. + +### Oh, fingers, where art thou? + +I was once an excellent touch-typist. Those days are long gone. I typo more than I would have believed possible. + +At different times, I have used a fair amount of either Chef or Kubernetes. Fortunately for me, I never used both at the same time. + +Part of the Chef ecosystem is Test Kitchen, a suite of tools that facilitate testing, which is invoked with the commands `kitchen test`. Kubernetes is managed with a CLI tool `kubectl`. Both commands require several subcommands, and neither rolls off the fingers particularly fluidly. + +Rather than create a bunch of "typo aliases," I aliased those commands to `k`: +``` +alias k='kitchen test $@' +``` + +or +``` +alias k='kubectl $@' +``` + +### Timesplitters + +The last half of my career has involved writing more code with other people. I've worked in many environments where we have forked copies of repos on our account and use pull requests as part of the review process. When I want to make sure that my fork of a given repo is up to date with the parent, I use `fetchupstream`: +``` +alias fetchupstream='git fetch upstream && git checkout master && git merge upstream/master && git push' +``` + +### Mine eyes have seen the glory of the coming of color + +I like color. It can make things like diffs easier to use. +``` +alias diff='colordiff' +``` + +I thought that colorized man pages was a neat trick, so I incorporated this function: +``` +# Colorized man pages, from: +# http://boredzo.org/blog/archives/2016-08-15/colorized-man-pages-understood-and-customized +man() { +        env \ +                LESS_TERMCAP_md=$(printf "\e[1;36m") \ +                LESS_TERMCAP_me=$(printf "\e[0m") \ +                LESS_TERMCAP_se=$(printf "\e[0m") \ +                LESS_TERMCAP_so=$(printf "\e[1;44;33m") \ +                LESS_TERMCAP_ue=$(printf "\e[0m") \ +                LESS_TERMCAP_us=$(printf "\e[1;32m") \ +                man "$@" +} +``` + +I love the command `which`. It simply tells you where in the filesystem the command you're running comes from—unless it's a shell function. After multiple cascading dotfiles, sometimes it's not clear where a function is defined or what it does. It turns out that the `whence` and `type` commands can help with that. +``` +# Where is a function defined? +whichfunc() { +        whence -v $1 +        type -a $1 +} +``` + +### Conclusion + +I hope this article helps and inspires you to find ways to improve your daily shell-using experience. They don't need to be huge, novel, or complex. They might solve a minor but frequent bit of friction, create a shortcut, or even offer a solution to reducing common typos. + +You're welcome to look through my [dotfiles repo][7], but I warn you that it could use a lot of cleaning up. Feel free to use anything that you find helpful, and please be excellent to one another. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/shell-dotfile + +作者:[H.Waldo Grunenwald][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gwaldo +[1]: http://www.zsh.org/ +[2]: https://brew.sh/ +[3]: https://github.com/robbyrussell/oh-my-zsh +[4]: https://www.iterm2.com/ +[5]: https://twitter.com/climagic +[6]: https://github.com/graphite-project/ +[7]: https://github.com/gwaldo/dotfiles From 351adbb0932f211020f89af7b6e0968895630f89 Mon Sep 17 00:00:00 2001 From: feng lv Date: Fri, 7 Sep 2018 12:15:47 +0800 Subject: [PATCH 107/455] ucasFL translating --- ... To Set Up PF Firewall on FreeBSD to Protect a Web Server.md | 2 ++ ...rash-Cli - A Command Line Interface For Trashcan On Linux.md | 2 ++ ...0171202 Scrot Linux command-line screen grabs made simple.md | 2 ++ .../20180324 How To Compress And Decompress Files In Linux.md | 2 ++ .../tech/20180905 8 great Python libraries for side projects.md | 2 ++ 5 files changed, 10 insertions(+) diff --git a/sources/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md b/sources/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md index 45ce0c0a7a..2f4465a4ac 100644 --- a/sources/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md +++ b/sources/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md @@ -1,3 +1,5 @@ +ucasFL translating + How To Set Up PF Firewall on FreeBSD to Protect a Web Server ====== diff --git a/sources/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md b/sources/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md index 29902a588f..4bb10f4f64 100644 --- a/sources/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md +++ b/sources/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md @@ -1,3 +1,5 @@ +ucasFL translating + Trash-Cli : A Command Line Interface For Trashcan On Linux ====== Everyone knows about `Trashcan` which is common for all users like Linux, or Windows, or Mac. Whenever you delete a file or folder, it will be moved to trash. diff --git a/sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md b/sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md index c1f3ee8cf6..f198f1dd65 100644 --- a/sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md +++ b/sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md @@ -1,3 +1,5 @@ +ucasFL translating + # Scrot: Linux command-line screen grabs made simple by [Scott Nesbitt][a] · November 30, 2017 diff --git a/sources/tech/20180324 How To Compress And Decompress Files In Linux.md b/sources/tech/20180324 How To Compress And Decompress Files In Linux.md index 8766b9e39b..4989527f13 100644 --- a/sources/tech/20180324 How To Compress And Decompress Files In Linux.md +++ b/sources/tech/20180324 How To Compress And Decompress Files In Linux.md @@ -1,3 +1,5 @@ +ucasFL translating + How To Compress And Decompress Files In Linux ====== diff --git a/sources/tech/20180905 8 great Python libraries for side projects.md b/sources/tech/20180905 8 great Python libraries for side projects.md index b901e2c4c7..3623c37c6d 100644 --- a/sources/tech/20180905 8 great Python libraries for side projects.md +++ b/sources/tech/20180905 8 great Python libraries for side projects.md @@ -1,3 +1,5 @@ +ucasFL translating + 8 great Python libraries for side projects ====== From 6e9aaf8a0b1258e972c1a53ff31e69fd4453ee65 Mon Sep 17 00:00:00 2001 From: feng lv Date: Fri, 7 Sep 2018 17:53:00 +0800 Subject: [PATCH 108/455] translated --- ...wall on FreeBSD to Protect a Web Server.md | 150 +++++++++--------- 1 file changed, 77 insertions(+), 73 deletions(-) rename {sources => translated}/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md (73%) diff --git a/sources/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md b/translated/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md similarity index 73% rename from sources/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md rename to translated/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md index 2f4465a4ac..cf4fdef529 100644 --- a/sources/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md +++ b/translated/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md @@ -1,87 +1,84 @@ -ucasFL translating - -How To Set Up PF Firewall on FreeBSD to Protect a Web Server +如何在 FreeBSD 上设置 PF 防火墙来保护 Web 服务器 ====== -I am a new FreeBSD server user and moved from netfilter on Linux. How do I setup a firewall with PF on FreeBSD server to protect a web server with single public IP address and interface? +[![How To Set Up a Firewall with PF on FreeBSD to Protect a Web Server][1]][1] +我是从 Linux 迁移过来的 FreeBSD 新用户,Linux 中使用的是 netfilter 防火墙框架(LCTT 译注:netfilter 是由 Rusty Russell 提出的 Linux 2.4 内核防火墙框架)。那么在 FreeBSD 上,我该如何设置 PF 防火墙,从而来保护只有一个公共 IP 地址和端口的 web 服务器呢? -PF is an acronym for packet filter. It was created for OpenBSD but has been ported to FreeBSD and other operating systems. It is a stateful packet filtering engine. This tutorial will show you how to set up a firewall with PF on FreeBSD 10.x and 11.x server to protect your web server. +PF 是包过滤器packet filter的简称。它是为 OpenBSD开发的,但是已经被移植到了 FreeBSD 以及其它操作系统上。PF 是一个状态包过滤引擎。在这篇教程中,我将向你展示如何在 FreeBSD 10.x 以及 11.x 中设置 PF 防火墙,从而来保护 web 服务器。 +### 第一步:开启 PF 防火墙 -## Step 1 - Turn on PF firewall +你需要把下面这几行内容添加到文件 “/etc/rc.conf” 文件中: -You need to add the following three lines to /etc/rc.conf file: ``` # echo 'pf_enable="YES"' >> /etc/rc.conf # echo 'pf_rules="/usr/local/etc/pf.conf"' >> /etc/rc.conf # echo 'pflog_enable="YES"' >> /etc/rc.conf # echo 'pflog_logfile="/var/log/pflog"' >> /etc/rc.conf ``` -Where, +在这里: - 1. **pf_enable="YES"** - Turn on PF service. - 2. **pf_rules="/usr/local/etc/pf.conf"** - Read PF rules from this file. - 3. **pflog_enable="YES"** - Turn on logging support for PF. - 4. **pflog_logfile="/var/log/pflog"** - File where pflogd should store the logfile i.e. store logs in /var/log/pflog file. + 1. **pf_enable="YES"** - 开启 PF 服务 + 2. **pf_rules="/usr/local/etc/pf.conf"** - 从文件 “/usr/local/etc/pf.conf” 中读取 PF 规则 + 3. **pflog_enable="YES"** - 为 PF 服务打开日志支持 + 4. **pflog_logfile="/var/log/pflog"** - 存储日志的文件,即日志存于文件 “/var/log/pflog” 中 +### 第二步:在 “/usr/local/etc/pf.conf” 文件中创建防火墙规则 +输入下面这个命令打开文件(超级用户模式下): -[![How To Set Up a Firewall with PF on FreeBSD to Protect a Web Server][1]][1] - -## Step 2 - Creating firewall rules in /usr/local/etc/pf.conf - -Type the following command: ``` # vi /usr/local/etc/pf.conf ``` -Append the following PF rulesets : +在文件中添加下面这些 PF 规则集: + ``` # vim: set ft=pf # /usr/local/etc/pf.conf -## Set your public interface ## +## 设置公共端口 ## ext_if="vtnet0" -## Set your server public IP address ## +## 设置服务器公共 IP 地址 ## ext_if_ip="172.xxx.yyy.zzz" -## Set and drop these IP ranges on public interface ## +## 设置并删除下面这些公共端口上的 IP 范围 ## martians = "{ 127.0.0.0/8, 192.168.0.0/16, 172.16.0.0/12, \ 10.0.0.0/8, 169.254.0.0/16, 192.0.2.0/24, \ 0.0.0.0/8, 240.0.0.0/4 }" -## Set http(80)/https (443) port here ## +## 设置 http(80)/https (443) 端口 ## webports = "{http, https}" -## enable these services ## +## 启用下面这些服务 ## int_tcp_services = "{domain, ntp, smtp, www, https, ftp, ssh}" int_udp_services = "{domain, ntp}" -## Skip loop back interface - Skip all PF processing on interface ## +## 跳过回环端口 - 跳过端口上的所有 PF 处理 ## set skip on lo -## Sets the interface for which PF should gather statistics such as bytes in/out and packets passed/blocked ## +## 设置 PF 应该统计的端口信息,如发送/接收字节数,通过/禁止的包的数目 ## set loginterface $ext_if -## Set default policy ## +## 设置默认策略 ## block return in log all block out all -# Deal with attacks based on incorrect handling of packet fragments +# 基于 IP 分片的错误处理来防御攻击 scrub in all -# Drop all Non-Routable Addresses +# 删除所有不可达路由地址 block drop in quick on $ext_if from $martians to any block drop out quick on $ext_if from any to $martians -## Blocking spoofed packets +## 禁止欺骗包 antispoof quick for $ext_if -# Open SSH port which is listening on port 22 from VPN 139.xx.yy.zz Ip only -# I do not allow or accept ssh traffic from ALL for security reasons +# 打开 SSH 端口,SSH 服务仅从 VPN IP 139.xx.yy.zz 监听 22 号端口 +# 出于安全原因,我不允许/接收 SSH 流量 pass in quick on $ext_if inet proto tcp from 139.xxx.yyy.zzz to $ext_if_ip port = ssh flags S/SA keep state label "USER_RULE: Allow SSH from 139.xxx.yyy.zzz" -## Use the following rule to enable ssh for ALL users from any IP address # +## 使用下面这些规则来为所有来自任何 IP 地址的用户开启 SSH 服务 # ## pass in inet proto tcp to $ext_if port ssh ### [ OR ] ### ## pass in inet proto tcp to $ext_if port 22 @@ -92,44 +89,46 @@ pass inet proto icmp icmp-type echoreq # All access to our Nginx/Apache/Lighttpd Webserver ports pass proto tcp from any to $ext_if port $webports -# Allow essential outgoing traffic +# 允许重要的发送流量 pass out quick on $ext_if proto tcp to any port $int_tcp_services pass out quick on $ext_if proto udp to any port $int_udp_services -# Add custom rules below +# 在下面添加自定义规则 ``` -Save and close the file. PR [welcome here to improve rulesets][2]. To check for syntax error, run: +保存并关闭文件。欢迎来参考我的[规则集][2]。如果要检查语法错误,可以运行: + `# service pf check` -OR +或 `/etc/rc.d/pf check` -OR +或 `# pfctl -n -f /usr/local/etc/pf.conf ` -## Step 3 - Start PF firewall +### 第三步:开始运行 PF 防火墙 -The commands are as follows. Be careful you might be disconnected from your server over ssh based session: +命令如下。请小心,如果是基于 SSH 的会话,你可能会和服务器断开连接。 -### Start PF +*开启 PF 防火墙:* `# service pf start` -### Stop PF +*停用 PF 防火墙:* `# service pf stop` -### Check PF for syntax error +*检查语法错误:* `# service pf check` -### Restart PF +*重启服务:* `# service pf restart` -### See PF status +*查看 PF 状态:* `# service pf status` -Sample outputs: +示例输出: + ``` Status: Enabled for 0 days 00:02:18 Debug: Urgent @@ -167,24 +166,24 @@ Counters map-failed 0 0.0/s ``` +#### 开启/关闭/重启 pflog 服务的命令 -### Command to start/stop/restart pflog service - -Type the following commands: +输入下面这些命令 ``` # service pflog start # service pflog stop # service pflog restart ``` -## Step 4 - A quick introduction to pfctl command +### 第四步:`pfctl` 命令的简单介绍 -You need to use the pfctl command to see PF ruleset and parameter configuration including status information from the packet filter. Let us see all common commands: +你需要使用 `pfctl` 命令来查看 PF 规则集和参数配置,包括来自包过滤器packet filter的状态信息。让我们来看一下所有常见命令: -### Show PF rules information +#### 显示 PF 规则信息 `# pfctl -s rules` -Sample outputs: +示例输出: + ``` block return in log all block drop out all @@ -203,15 +202,15 @@ pass out quick on vtnet0 proto udp from any to any port = domain keep state pass out quick on vtnet0 proto udp from any to any port = ntp keep state ``` -#### Show verbose output for each rule +#### 显示每条规则的详细内容 `# pfctl -v -s rules` -#### Add rule numbers with verbose output for each rule +在每条规则的详细输出中添加规则编号: `# pfctl -vvsr show` -#### Show state +#### 显示状态信息 ``` # pfctl -s state @@ -219,18 +218,19 @@ pass out quick on vtnet0 proto udp from any to any port = ntp keep state # pfctl -s state | grep 'something' ``` -### How to disable PF from the CLI +#### 如何在命令行中禁止 PF 服务 `# pfctl -d ` -### How to enable PF from the CLI +#### 如何在命令行中启用 PF 服务 `# pfctl -e ` -### How to flush ALL PF rules/nat/tables from the CLI +#### 如何在命令行中刷新 PF 规则/NAT/路由表 `# pfctl -F all` -Sample outputs: +示例输出: + ``` rules cleared nat cleared @@ -241,27 +241,29 @@ pf: statistics cleared pf: interface flags reset ``` -#### How to flush only the PF RULES from the CLI +#### 如何在命令行中仅刷新 PF 规则 `# pfctl -F rules ` -#### How to flush only queue's from the CLI +#### 如何在命令行中仅刷新队列 `# pfctl -F queue ` -#### How to flush all stats that are not part of any rule from the CLI +#### 如何在命令行中刷新统计信息(它不是任何规则的一部分) `# pfctl -F info` -#### How to clear all counters from the CLI +#### 如何在命令行中清除所有计数器 `# pfctl -z clear ` -## Step 5 - See PF log +### 第五步:查看 PF 日志 + +PF 日志是二进制格式的。使用下面这一命令来查看: -PF logs are in binary format. To see them type: `# tcpdump -n -e -ttt -r /var/log/pflog` -Sample outputs: +示例输出: + ``` Aug 29 15:41:11.757829 rule 0/(match) block in on vio0: 86.47.225.151.55806 > 45.FOO.BAR.IP.23: S 757158343:757158343(0) win 52206 [tos 0x28] Aug 29 15:41:44.193309 rule 0/(match) block in on vio0: 5.196.83.88.25461 > 45.FOO.BAR.IP.26941: S 2224505792:2224505792(0) ack 4252565505 win 17520 (DF) [tos 0x24] @@ -297,30 +299,32 @@ Aug 29 15:55:07.001743 rule 0/(match) block in on vio0: 190.83.174.214.58863 > 4 Aug 29 15:55:51.269549 rule 0/(match) block in on vio0: 142.217.201.69.26112 > 45.FOO.BAR.IP.22: S 757158343:757158343(0) win 22840 Aug 29 15:58:41.346028 rule 0/(match) block in on vio0: 169.1.29.111.29765 > 45.FOO.BAR.IP.23: S 757158343:757158343(0) win 28509 Aug 29 15:59:11.575927 rule 0/(match) block in on vio0: 187.160.235.162.32427 > 45.FOO.BAR.IP.5358: S 22445:22445(0) win 14600 [tos 0x28] -Aug 29 15:59:37.826598 rule 0/(match) block in on vio0: 94.74.81.97.54656 > 45.FOO.BAR.IP.3128: S 2720157526:2720157526(0) win 1024 [tos 0x28] +Aug 29 15:59:37.826598 rule 0/(match) block in on vio0: 94.74.81.97.54656 > 45.FOO.BAR.IP.3128: S 2720157526:2720157526(0) win 1024 [tos 0x28]stateful Aug 29 15:59:37.991171 rule 0/(match) block in on vio0: 94.74.81.97.54656 > 45.FOO.BAR.IP.3128: R 2720157527:2720157527(0) win 1200 [tos 0x28] Aug 29 16:01:36.990050 rule 0/(match) block in on vio0: 182.18.8.28.23299 > 45.FOO.BAR.IP.445: S 1510146048:1510146048(0) win 16384 ``` -To see live log run: +如果要查看实时日志,可以运行: `# tcpdump -n -e -ttt -i pflog0` -For more info the [PF FAQ][3], [FreeBSD HANDBOOK][4] and the following man pages: + +如果你想了解更多信息,可以访问 [PF FAQ][3] 和 [FreeBSD HANDBOOK][4] 以及下面这些 man 页面: + ``` # man tcpdump # man pfctl # man pf ``` -## about the author: +### 关于作者 -The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on [Twitter][5], [Facebook][6], [Google+][7]. +我是 nixCraft 的创立者,一个经验丰富的系统管理员,同时也是一位 Linux 操作系统/Unix shell 脚本培训师。我在不同的行业与全球客户工作过,包括 IT、教育、国防和空间研究、以及非营利组织。你可以在 [Twitter][5]、[Facebook][6] 或 [Google+][7] 上面关注我。 -------------------------------------------------------------------------------- via: https://www.cyberciti.biz/faq/how-to-set-up-a-firewall-with-pf-on-freebsd-to-protect-a-web-server/ 作者:[Vivek Gite][a] -译者:[译者ID](https://github.com/译者ID) +译者:[ucasFL](https://github.com/ucasFL) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -332,4 +336,4 @@ via: https://www.cyberciti.biz/faq/how-to-set-up-a-firewall-with-pf-on-freebsd-t [4]:https://www.freebsd.org/doc/handbook/firewalls.html [5]:https://twitter.com/nixcraft [6]:https://facebook.com/nixcraft -[7]:https://plus.google.com/+CybercitiBiz +[7]:https://plus.google.com/+CybercitiBiz \ No newline at end of file From f5e0d8248d2bae9e4392dea840597a74e249a0a2 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 7 Sep 2018 20:55:17 +0800 Subject: [PATCH 109/455] PRF:20180203 API Star- Python 3 API Framework - Polyglot.Ninja().md @MjSeven --- ...thon 3 API Framework - Polyglot.Ninja().md | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/translated/tech/20180203 API Star- Python 3 API Framework - Polyglot.Ninja().md b/translated/tech/20180203 API Star- Python 3 API Framework - Polyglot.Ninja().md index 88f15c218a..56ed6a6dde 100644 --- a/translated/tech/20180203 API Star- Python 3 API Framework - Polyglot.Ninja().md +++ b/translated/tech/20180203 API Star- Python 3 API Framework - Polyglot.Ninja().md @@ -1,34 +1,35 @@ -API Star: Python 3 的 API 框架 – Polyglot.Ninja() +API Star:一个 Python 3 的 API 框架 ====== -为了在 Python 中快速构建 API,我主要依赖于 [Flask][1]。最近我遇到了一个名为 “API Star” 的基于 Python 3 的新 API 框架。由于几个原因,我对它很感兴趣。首先,该框架包含 Python 新特点,如类型提示和 asyncio。接着它再进一步并且为开发人员提供了很棒的开发体验。我们很快就会讲到这些功能,但在我们开始之前,我首先要感谢 Tom Christie,感谢他为 Django REST Framework 和 API Star 所做的所有工作。 +为了在 Python 中快速构建 API,我主要依赖于 [Flask][1]。最近我遇到了一个名为 “API Star” 的基于 Python 3 的新 API 框架。由于几个原因,我对它很感兴趣。首先,该框架包含 Python 新特点,如类型提示和 asyncio。而且它再进一步为开发人员提供了很棒的开发体验。我们很快就会讲到这些功能,但在我们开始之前,我首先要感谢 Tom Christie,感谢他为 Django REST Framework 和 API Star 所做的所有工作。 -现在说回 API Star -- 我感觉这个框架很有成效。我可以选择基于 asyncio 编写异步代码,或者可以选择传统后端方式就像 WSGI 那样。它配备了一个命令行工具 - `apistar` 来帮助我们更快地完成工作。它支持 Django ORM 和 SQLAlchemy,这是可选的。它有一个出色类型系统,使我们能够定义输入和输出的约束,API Star 可以自动生成 api 模式(包括文档),提供验证和序列化功能等等。虽然 API Star 专注于构建 API,但你也可以非常轻松地在其上构建 Web 应用程序。在我们自己构建一些东西之前,所有这些可能都没有意义的。 +现在说回 API Star —— 我感觉这个框架很有成效。我可以选择基于 asyncio 编写异步代码,或者可以选择传统后端方式就像 WSGI 那样。它配备了一个命令行工具 —— `apistar` 来帮助我们更快地完成工作。它支持 Django ORM 和 SQLAlchemy,这是可选的。它有一个出色的类型系统,使我们能够定义输入和输出的约束,API Star 可以自动生成 API 的模式(包括文档),提供验证和序列化功能等等。虽然 API Star 专注于构建 API,但你也可以非常轻松地在其上构建 Web 应用程序。在我们自己构建一些东西之前,所有这些可能都没有意义的。 ### 开始 我们将从安装 API Star 开始。为此实验创建一个虚拟环境是一个好主意。如果你不知道如何创建一个虚拟环境,不要担心,继续往下看。 + ``` pip install apistar - ``` + (译注:上面的命令是在 Python 3 虚拟环境下使用的) -如果你没有使用虚拟环境或者 Python 3 的 `pip`,它被称为 `pip3`,那么使用 `pip3 install apistar` 代替。 +如果你没有使用虚拟环境或者你的 Python 3 的 `pip` 名为 `pip3`,那么使用 `pip3 install apistar` 代替。 一旦我们安装了这个包,我们就应该可以使用 `apistar` 命令行工具了。我们可以用它创建一个新项目,让我们在当前目录中创建一个新项目。 + ``` apistar new . - ``` 现在我们应该创建两个文件:`app.py`,它包含主应用程序,然后是 `test.py`,它用于测试。让我们来看看 `app.py` 文件: + ``` from apistar import Include, Route from apistar.frameworks.wsgi import WSGIApp as App from apistar.handlers import docs_urls, static_urls - def welcome(name=None): if name is None: return {'message': 'Welcome to API Star!'} @@ -46,34 +47,34 @@ app = App(routes=routes) if __name__ == '__main__': app.main() - ``` 在我们深入研究代码之前,让我们运行应用程序并查看它是否正常工作。我们在浏览器中输入 `http://127.0.0.1:8080/`,我们将得到以下响应: + ``` {"message": "Welcome to API Star!"} - ``` 如果我们输入:`http://127.0.0.1:8080/?name=masnun` + ``` {"message": "Welcome to API Star, masnun!"} - ``` 同样的,输入 `http://127.0.0.1:8080/docs/`,我们将看到自动生成的 API 文档。 -现在让我们来看看代码。我们有一个 `welcome` 函数,它接收一个名为 `name` 的参数,其默认值为 `None`。API Star 是一个智能的 api 框架。它将尝试在 url 路径或者查询字符串中找到 `name` 键并将其传递给我们的函数,它还基于其生成 API 文档。这真是太好了,不是吗? +现在让我们来看看代码。我们有一个 `welcome` 函数,它接收一个名为 `name` 的参数,其默认值为 `None`。API Star 是一个智能的 API 框架。它将尝试在 url 路径或者查询字符串中找到 `name` 键并将其传递给我们的函数,它还基于其生成 API 文档。这真是太好了,不是吗? -然后,我们创建一个 `Route` 和 `Include` 实例列表,并将列表传递给 `App` 实例。`Route` 对象用于定义用户自定义路由。顾名思义,`Include` 包含了在给定的路径下的其它 url 路径。 +然后,我们创建一个 `Route` 和 `Include` 实例的列表,并将列表传递给 `App` 实例。`Route` 对象用于定义用户自定义路由。顾名思义,`Include` 包含了在给定的路径下的其它 url 路径。 ### 路由 路由很简单。当构造 `App` 实例时,我们需要传递一个列表作为 `routes` 参数,这个列表应该有我们刚才看到的 `Route` 或 `Include` 对象组成。对于 `Route`,我们传递一个 url 路径,http 方法和可调用的请求处理程序(函数或者其他)。对于 `Include` 实例,我们传递一个 url 路径和一个 `Routes` 实例列表。 -##### 路径参数 +#### 路径参数 我们可以在花括号内添加一个名称来声明 url 路径参数。例如 `/user/{user_id}` 定义了一个 url,其中 `user_id` 是路径参数,或者说是一个将被注入到处理函数(实际上是可调用的)中的变量。这有一个简单的例子: + ``` from apistar import Route from apistar.frameworks.wsgi import WSGIApp as App @@ -91,22 +92,22 @@ app = App(routes=routes) if __name__ == '__main__': app.main() - ``` 如果我们访问 `http://127.0.0.1:8080/user/23`,我们将得到以下响应: + ``` {"message": "Your profile id is: 23"} - ``` 但如果我们尝试访问 `http://127.0.0.1:8080/user/some_string`,它将无法匹配。因为我们定义了 `user_profile` 函数,且为 `user_id` 参数添加了一个类型提示。如果它不是整数,则路径不匹配。但是如果我们继续删除类型提示,只使用 `user_profile(user_id)`,它将匹配此 url。这也展示了 API Star 的智能之处和利用类型和好处。 #### 包含/分组路由 -有时候将某些 url 组合在一起是有意义的。假设我们有一个处理用户相关功能的 `user` 模块,将所有与用户相关的 url 分组在 `/user` 路径下可能会更好。例如 `/user/new`, `/user/1`, `/user/1/update` 等等。我们可以轻松地在单独的模块或包中创建我们的处理程序和路由,然后将它们包含在我们自己的路由中。 +有时候将某些 url 组合在一起是有意义的。假设我们有一个处理用户相关功能的 `user` 模块,将所有与用户相关的 url 分组在 `/user` 路径下可能会更好。例如 `/user/new`、`/user/1`、`/user/1/update` 等等。我们可以轻松地在单独的模块或包中创建我们的处理程序和路由,然后将它们包含在我们自己的路由中。 让我们创建一个名为 `user` 的新模块,文件名为 `user.py`。我们将以下代码放入这个文件: + ``` from apistar import Route @@ -128,10 +129,10 @@ user_routes = [ Route("/{user_id}/update", "GET", user_update), Route("/{user_id}/profile", "GET", user_profile), ] - ``` 现在我们可以从 app 主文件中导入 `user_routes`,并像这样使用它: + ``` from apistar import Include from apistar.frameworks.wsgi import WSGIApp as App @@ -146,7 +147,6 @@ app = App(routes=routes) if __name__ == '__main__': app.main() - ``` 现在 `/user/new` 将委托给 `user_new` 函数。 @@ -154,21 +154,22 @@ if __name__ == '__main__': ### 访问查询字符串/查询参数 查询参数中传递的任何参数都可以直接注入到处理函数中。比如 url `/call?phone=1234`,处理函数可以定义一个 `phone` 参数,它将从查询字符串/查询参数中接收值。如果 url 查询字符串不包含 `phone` 的值,那么它将得到 `None`。我们还可以为参数设置一个默认值,如下所示: + ``` def welcome(name=None): if name is None: return {'message': 'Welcome to API Star!'} return {'message': 'Welcome to API Star, %s!' % name} - ``` 在上面的例子中,我们为 `name` 设置了一个默认值 `None`。 ### 注入对象 -通过给一个请求程序添加类型提示,我们可以将不同的对象注入到视图中。注入请求相关对象有助于处理程序直接从内部访问它们。API Star 内置的 `http` 包中有几个内置对象。我们也可以使用它的类型系统来创建我们自己的自定义对象并将它们注入到我们的函数中。API Star 还根据指定的约束进行数据验证。 +通过给一个请求程序添加类型提示,我们可以将不同的对象注入到视图中。注入请求相关的对象有助于处理程序直接从内部访问它们。API Star 内置的 `http` 包中有几个内置对象。我们也可以使用它的类型系统来创建我们自己的自定义对象并将它们注入到我们的函数中。API Star 还根据指定的约束进行数据验证。 让我们定义自己的 `User` 类型,并将其注入到我们的请求处理程序中: + ``` from apistar import Include, Route from apistar.frameworks.wsgi import WSGIApp as App @@ -197,10 +198,10 @@ app = App(routes=routes) if __name__ == '__main__': app.main() - ``` 现在如果我们发送这样的请求: + ``` curl -X POST \ http://127.0.0.1:8080/ \ @@ -214,6 +215,7 @@ curl -X POST \ ### 发送响应 如果你已经注意到,到目前为止,我们只可以传递一个字典,它将被转换为 JSON 并作为默认返回。但是,我们可以使用 `apistar` 中的 `Response` 类来设置状态码和其它任意响应头。这有一个简单的例子: + ``` from apistar import Route, Response from apistar.frameworks.wsgi import WSGIApp as App @@ -236,15 +238,13 @@ app = App(routes=routes) if __name__ == '__main__': app.main() - ``` 它应该返回纯文本响应和一个自定义标响应头。请注意,`content` 应该是字节,而不是字符串。这就是我编码它的原因。 ### 继续 -我刚刚介绍了 API -Star 的一些特性,API Star 中还有许多非常酷的东西,我建议通过 [Github Readme][2] 文件来了解这个优秀框架所提供的不同功能的更多信息。我还将尝试在未来几天内介绍关于 API Star 的更多简短的,集中的教程。 +我刚刚介绍了 API Star 的一些特性,API Star 中还有许多非常酷的东西,我建议通过 [Github Readme][2] 文件来了解这个优秀框架所提供的不同功能的更多信息。我还将尝试在未来几天内介绍关于 API Star 的更多简短的,集中的教程。 -------------------------------------------------------------------------------- @@ -253,7 +253,7 @@ via: http://polyglot.ninja/api-star-python-3-api-framework/ 作者:[MASNUN][a] 译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 6f8e46ad3ae97cac7e5c29620937de02c27ad484 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 7 Sep 2018 20:55:41 +0800 Subject: [PATCH 110/455] PUB:20180203 API Star- Python 3 API Framework - Polyglot.Ninja().md @MjSeven https://linux.cn/article-9987-1.html --- ...0180203 API Star- Python 3 API Framework - Polyglot.Ninja().md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180203 API Star- Python 3 API Framework - Polyglot.Ninja().md (100%) diff --git a/translated/tech/20180203 API Star- Python 3 API Framework - Polyglot.Ninja().md b/published/20180203 API Star- Python 3 API Framework - Polyglot.Ninja().md similarity index 100% rename from translated/tech/20180203 API Star- Python 3 API Framework - Polyglot.Ninja().md rename to published/20180203 API Star- Python 3 API Framework - Polyglot.Ninja().md From 3fd39668f80fb923ae758013c55097ee28e389ea Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 08:07:11 +0800 Subject: [PATCH 111/455] PRF:20180720 How to Install 2048 Game in Ubuntu and Other Linux Distributions.md @geekpi --- ...in Ubuntu and Other Linux Distributions.md | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/translated/tech/20180720 How to Install 2048 Game in Ubuntu and Other Linux Distributions.md b/translated/tech/20180720 How to Install 2048 Game in Ubuntu and Other Linux Distributions.md index a74fe0c0c7..35228c9f36 100644 --- a/translated/tech/20180720 How to Install 2048 Game in Ubuntu and Other Linux Distributions.md +++ b/translated/tech/20180720 How to Install 2048 Game in Ubuntu and Other Linux Distributions.md @@ -1,10 +1,11 @@ -如何在 Ubuntu 和其他 Linux 发行版中安装 2048 游戏 +如何在 Linux 中安装 2048 游戏 ====== -**流行的移动益智游戏 2048 也可以在 Ubuntu 和 Linux 发行版上玩。啊!你甚至可以在 Linux 终端上玩 2048。如果你的生产率因为这个让人上瘾的游戏下降,请不要怪我。** + +> 流行的移动益智游戏 2048 也可以在 Ubuntu 和 Linux 发行版上玩。啊!你甚至可以在 Linux 终端上玩 2048。如果你的生产率因为这个让人上瘾的游戏下降,请不要怪我。 早在 2014 年,2048 就是 iOS 和 Android 上最受欢迎的游戏之一。这款令人上瘾的游戏非常受欢迎,它在 Linux 上有[浏览器版][1]、桌面版和终端版。 - +![](https://media.giphy.com/media/wT8XEi5gckwJW/giphy.gif) 通过向上和向下,向左和向右移动滑块来玩这个小游戏。这个益智游戏的目的是通过组合匹配的滑块到数字 2048。因此 2+2 变成 4,4+4 变成 16,依此类推。这可能听起来简单而无聊,但相信我是一个令人上瘾的游戏。 @@ -13,9 +14,9 @@ 在 Ubuntu 和其他 Linux 中有些 2048 游戏。你可以在软件中心中搜索它,你可以在那里找到一些。 有一个[基于 Qt ][2]的 2048 游戏,你可以在 Ubuntu 和其他基于 Debian 和 Ubuntu 的 Linux 发行版上安装。你可以使用以下命令安装它: + ``` sudo apt install 2048-qt - ``` 安装完成后,你可以在菜单中找到该游戏并启动它。你可以使用箭头键移动数字。你的最高分也会保存。 @@ -28,14 +29,14 @@ sudo apt install 2048-qt 现在,有几种方法可以在 Linux 终端中玩 2048。我在这里提其中两个。 -#### 1\. term2048 Snap 程序 +#### 1、term2048 Snap 程序 -有一个名为 [term2048][6] 的[ snap 程序][5]可以安装在任何[支持 Snap 的 Linux 发行版][7]中。 +有一个名为 [term2048][6] 的 [snap 程序][5]可以安装在任何[支持 Snap 的 Linux 发行版][7]中。 如果你启用了 Snap,只需使用此命令安装 term2048: + ``` sudo snap install term2048 - ``` Ubuntu 用户也可以在软件中心找到这个游戏并从那里安装它。 @@ -48,17 +49,17 @@ Ubuntu 用户也可以在软件中心找到这个游戏并从那里安装它。 你可以使用箭头键移动。 -#### 2\. 2048 游戏的 Bash 脚本 +#### 2、2048 游戏的 Bash 脚本 这个游戏实际上是一个 shell 脚本,你可以在任何 Linux 终端上运行。从 Github 下载游戏/脚本: -[下载 Bash2048][10] +- [下载 Bash2048][10] 解压下载的文件。进入解压后的目录,你将看到名为 2048.sh 的 shell 脚本。只需运行 shell 脚本。游戏将立即开始。你可以使用箭头键移动滑块。 ![Linux Terminal game 2048][11] -#### 你在Linux上玩什么游戏? +### 你在Linux上玩什么游戏? 如果你喜欢在 Linux 终端上玩游戏,你也应该尝试 [Linux 终端中的经典 Snake 游戏][12]。 @@ -71,7 +72,7 @@ via: https://itsfoss.com/2048-game/ 作者:[Abhishek Prakash][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 75bbfa5426e6c0f4565d74826b0253fd1ff10c1c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 08:07:33 +0800 Subject: [PATCH 112/455] PUB:20180720 How to Install 2048 Game in Ubuntu and Other Linux Distributions.md @geekpi https://linux.cn/article-9988-1.html --- ...o Install 2048 Game in Ubuntu and Other Linux Distributions.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180720 How to Install 2048 Game in Ubuntu and Other Linux Distributions.md (100%) diff --git a/translated/tech/20180720 How to Install 2048 Game in Ubuntu and Other Linux Distributions.md b/published/20180720 How to Install 2048 Game in Ubuntu and Other Linux Distributions.md similarity index 100% rename from translated/tech/20180720 How to Install 2048 Game in Ubuntu and Other Linux Distributions.md rename to published/20180720 How to Install 2048 Game in Ubuntu and Other Linux Distributions.md From 912ef0ca54731300b46b5651216a2a19d12a1583 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 08:32:27 +0800 Subject: [PATCH 113/455] PRF:20180730 How to use VS Code for your Python projects.md @idea2act --- ...to use VS Code for your Python projects.md | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/translated/tech/20180730 How to use VS Code for your Python projects.md b/translated/tech/20180730 How to use VS Code for your Python projects.md index a83e9e4e94..c332a42d60 100644 --- a/translated/tech/20180730 How to use VS Code for your Python projects.md +++ b/translated/tech/20180730 How to use VS Code for your Python projects.md @@ -3,9 +3,9 @@ ![](https://fedoramagazine.org/wp-content/uploads/2018/07/pythonvscode-816x345.jpg) -Visual Studio Code,简称 VS Code,是一个开源的文本编辑器,包含用于构建和调试应用程序的工具。安装启用 Python 扩展后,VS Code 可以配置成 Python 开发的理想工作环境。本文将介绍一些有用的 VS Code 扩展,并配置它们以充分提高 Python 开发效率。 +Visual Studio Code,简称 VS Code,是一个开源的文本编辑器,包含用于构建和调试应用程序的工具。安装启用 Python 扩展后,VS Code 可以配置成理想的 Python 开发工作环境。本文将介绍一些有用的 VS Code 扩展,并配置它们以充分提高 Python 开发效率。 -如果你的计算机上还没有安装 VS Code,可以参考文章 [Using Visual Studio Code on Fedora ](https://fedoramagazine.org/using-visual-studio-code-fedora/) 安装。 +如果你的计算机上还没有安装 VS Code,可以参考文章 [在 Fedora 上使用 VS Code](https://fedoramagazine.org/using-visual-studio-code-fedora/) 来安装。 ### 在 VS Code 中安装 Python 扩展 @@ -20,11 +20,12 @@ VS Code 通过两个 JSON 文件管理设置: * 一个文件用于 VS Code 的全局设置,作用于所有的项目 * 另一个文件用于特殊设置,作用于单独项目 -可以用快捷键 **Ctrl+,** (逗号)打开全局设置,也可以通过 **文件 -> 首选项 -> 设置** 来打开。 +可以用快捷键 `Ctrl+,` (逗号)打开全局设置,也可以通过 **文件 -> 首选项 -> 设置** 来打开。 #### 设置 Python 路径 -您可以在全局设置中配置 python.pythonPath 使 VS Code 自动为每个项目选择最适合的 Python 解释器。 。 +您可以在全局设置中配置 `python.pythonPath` 使 VS Code 自动为每个项目选择最适合的 Python 解释器。 + ``` // 将设置放在此处以覆盖默认设置和用户设置。 // Path to Python, you can use a custom version of Python by modifying this setting to include the full path. @@ -33,18 +34,20 @@ VS Code 通过两个 JSON 文件管理设置: } ``` -这样,VS Code 将使用虚拟环境目录 .venv 下项目根目录中的 Python 解释器。 +这样,VS Code 将使用虚拟环境目录 `.venv` 下项目根目录中的 Python 解释器。 #### 使用环境变量 -默认情况下,VS Code 使用项目根目录下的 .env 文件中定义的环境变量。 这对于设置环境变量很有用,如: +默认情况下,VS Code 使用项目根目录下的 `.env` 文件中定义的环境变量。 这对于设置环境变量很有用,如: + ``` PYTHONWARNINGS="once" ``` 可使程序在运行时显示警告。 -可以通过设置 python.envFile 来加载其他的默认环境变量文件: +可以通过设置 `python.envFile` 来加载其他的默认环境变量文件: + ``` // Absolute path to a file containing environment variable definitions. "python.envFile": "${workspaceFolder}/.env", @@ -52,9 +55,10 @@ PYTHONWARNINGS="once" ### 代码分析 -Python 扩展还支持不同的代码分析工具(pep8,flake8,pylint)。要启用你喜欢的或者正在进行的项目所使用的分析工具,只需要进行一些简单的配置。 +Python 扩展还支持不同的代码分析工具(pep8、flake8、pylint)。要启用你喜欢的或者正在进行的项目所使用的分析工具,只需要进行一些简单的配置。 扩展默认情况下使用 pylint 进行代码分析。你可以这样配置以使用 flake8 进行分析: + ``` "python.linting.pylintEnabled": false, "python.linting.flake8Path": "${workspaceRoot}/.venv/bin/flake8", @@ -68,7 +72,8 @@ Python 扩展还支持不同的代码分析工具(pep8,flake8,pylint)。 ### 格式化代码 -可以配置 VS Code 使其自动格式化代码。目前支持 autopep8,black 和 yapf。下面的设置将启用 “black” 模式。 +可以配置 VS Code 使其自动格式化代码。目前支持 autopep8、black 和 yapf。下面的设置将启用 “black” 模式。 + ``` // Provider for formatting. Possible options include 'autopep8', 'black', and 'yapf'. "python.formatting.provider": "black", @@ -77,7 +82,7 @@ Python 扩展还支持不同的代码分析工具(pep8,flake8,pylint)。 "editor.formatOnSave": true, ``` -如果不需要编辑器在保存时自动格式化代码,可以将 editor.formatOnSave 设置为 false 并手动使用快捷键 **Ctrl + Shift + I** 格式化当前文档中的代码。 注意,项目的虚拟环境中需要安装有 black,此示例方能有效。 +如果不需要编辑器在保存时自动格式化代码,可以将 `editor.formatOnSave` 设置为 `false` 并手动使用快捷键 `Ctrl + Shift + I` 格式化当前文档中的代码。 注意,项目的虚拟环境中需要安装有 black,此示例方能有效。 ### 运行任务 @@ -89,7 +94,8 @@ VS Code 的一个重要特点是它可以运行任务。需要运行的任务保 ![][4] -编辑如下所示的 tasks.json 文件,创建新任务来运行 Flask 开发服务: +编辑如下所示的 `tasks.json` 文件,创建新任务来运行 Flask 开发服务: + ``` { // See https://go.microsoft.com/fwlink/?LinkId=733558 @@ -110,19 +116,21 @@ VS Code 的一个重要特点是它可以运行任务。需要运行的任务保 } ``` -Flask 开发服务使用环境变量来获取应用程序的入口点。 如 **使用环境变量** 一节所说,可以在 .env 文件中声明这些变量: +Flask 开发服务使用环境变量来获取应用程序的入口点。 如 **使用环境变量** 一节所说,可以在 `.env` 文件中声明这些变量: + ``` FLASK_APP=wsgi.py FLASK_DEBUG=True ``` -这样就可以使用快捷键 **Ctrl + Shift + B** 来执行任务了。 +这样就可以使用快捷键 `Ctrl + Shift + B` 来执行任务了。 ### 单元测试 -VS Code 还支持单元测试框架 pytest,unittest 和 nosetest。启用测试框架后,可以在 VS Code 中单独运行搜索到的单元测试,通过测试套件运行测试或者运行所有的测试。 +VS Code 还支持单元测试框架 pytest、unittest 和 nosetest。启用测试框架后,可以在 VS Code 中单独运行搜索到的单元测试,通过测试套件运行测试或者运行所有的测试。 例如,可以这样启用 pytest 测试框架: + ``` "python.unitTest.pyTestEnabled": true, "python.unitTest.pyTestPath": "${workspaceRoot}/.venv/bin/pytest", @@ -140,7 +148,7 @@ via: https://fedoramagazine.org/vscode-python-howto/ 作者:[Clément Verna][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[idea2act](https://github.com/idea2act) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 4219363e10c4477412bd6524d1dc237662747210 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 08:34:00 +0800 Subject: [PATCH 114/455] PUB:20180730 How to use VS Code for your Python projects.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @idea2act 恭喜你完成了第一篇翻译! 本文首发地址: https://linux.cn/article-9989-1.html 您的 LCTT 专页地址: https://linux.cn/lctt/idea2act 请去 https://lctt.linux.cn 注册领取您的 LCCN 奖励 --- .../20180730 How to use VS Code for your Python projects.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180730 How to use VS Code for your Python projects.md (100%) diff --git a/translated/tech/20180730 How to use VS Code for your Python projects.md b/published/20180730 How to use VS Code for your Python projects.md similarity index 100% rename from translated/tech/20180730 How to use VS Code for your Python projects.md rename to published/20180730 How to use VS Code for your Python projects.md From e7fb7694eb5c138ba456f239c7bd99dacb5bbe51 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 08:52:38 +0800 Subject: [PATCH 115/455] PRF:20180830 How To Reset MySQL Or MariaDB Root Password.md @geekpi --- ...To Reset MySQL Or MariaDB Root Password.md | 33 +++++++++---------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/translated/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md b/translated/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md index 86abdf1151..42aa6e912b 100644 --- a/translated/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md +++ b/translated/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md @@ -3,86 +3,83 @@ ![](https://www.ostechnix.com/wp-content/uploads/2018/08/Reset-MySQL-Or-MariaDB-Root-Password-720x340.png) -几个月前,我在[**Ubuntu 18.04 上安装了 LAMP**][1]。今天,我尝试以 root 用户身份登录数据库,但我完全忘记了密码。经过一阵 Google 搜索并浏览一些文章后,我成功重置了密码。对于那些想知道如何做到这一点的人,这个简短的教程解释了如何在类 Unix 操作系统中重置 MySQL 或 MariaDB Root 密码。 +几个月前,我在[Ubuntu 18.04 上安装了 LAMP][1]。今天,我尝试以 root 用户身份登录数据库,但我完全忘记了密码。经过一阵 Google 搜索并浏览一些文章后,我成功重置了密码。对于那些想知道如何做到这一点的人,这个简短的教程解释了如何在类 Unix 操作系统中重置 MySQL 或 MariaDB Root 密码。 ### 重置 MySQL 或 MariaDB Root 密码 首先,停止数据库。 如果你使用 MySQL,请输入以下命令并下按回车键。 + ``` $ sudo systemctl stop mysql - ``` 对于 MariaDB: + ``` $ sudo systemctl stop mariadb - ``` 接下来,使用以下命令在没有权限检查的情况下重新启动数据库: + ``` $ sudo mysqld_safe --skip-grant-tables & - ``` -这里, **`--skip-grant-tables`** 选项让你在没有密码和所有权限的情况下进行连接。如果使用此选项启动服务器,它还会启用 `--skip-networking` 选项,这用于防止其他客户端连接到数据库服务器。并且,**( &)**符号用于在后台运行命令,因此你可以在以下步骤中输入其他命令。请注意,上述命令很危险,并且你的数据库会变得不安全。你应该只在短时间内运行此命令以重置密码。 +这里, `--skip-grant-tables` 选项让你在没有密码和所有权限的情况下进行连接。如果使用此选项启动服务器,它还会启用 `--skip-networking` 选项,这用于防止其他客户端连接到数据库服务器。并且,`&` 符号用于在后台运行命令,因此你可以在以下步骤中输入其他命令。请注意,上述命令很危险,并且你的数据库会变得不安全。你应该只在短时间内运行此命令以重置密码。 接下来,以 root 用户身份登录 MySQL/MariaDB 服务器: + ``` $ mysql - ``` 在 **mysql >** 或 **MariaDB [(none)] >** 提示符下,运行以下命令重置 root 用户密码: + ``` UPDATE mysql.user SET Password=PASSWORD('NEW-PASSWORD') WHERE User='root'; - ``` 使用你自己的密码替换上述命令中的 **NEW-PASSWORD**。 然后,输入以下命令退出 mysql 控制台。 + ``` FLUSH PRIVILEGES; - exit - ``` 最后,关闭之前使用 `--skip-grant-tables` 选项运行的数据库。为此,运行: + ``` $ sudo mysqladmin -u root -p shutdown - ``` -系统将要求你输入在上一步中设置的 mysql/mariadb 用户密码。 +系统将要求你输入在上一步中设置的 MySQL/MariaDB 用户密码。 + +现在,使用以下命令正常启动 MySQL/MariaDB 服务: -现在,使用以下命令正常启动 mysql/mariadb 服务: ``` $ sudo systemctl start mysql - ``` 对于 MariaDB: + ``` $ sudo systemctl start mariadb - ``` 使用以下命令验证密码是否确实已更改: + ``` $ mysql -u root -p - ``` 今天就是这些了。还有更多好东西。敬请期待! 干杯! - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-reset-mysql-or-mariadb-root-password/ @@ -90,7 +87,7 @@ via: https://www.ostechnix.com/how-to-reset-mysql-or-mariadb-root-password/ 作者:[SK][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 25716d8a1b4a0e11c3f49e22247d5bd519930b9c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 08:53:12 +0800 Subject: [PATCH 116/455] PUB:20180830 How To Reset MySQL Or MariaDB Root Password.md @geekpi https://linux.cn/article-9990-1.html --- .../20180830 How To Reset MySQL Or MariaDB Root Password.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180830 How To Reset MySQL Or MariaDB Root Password.md (100%) diff --git a/translated/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md b/published/20180830 How To Reset MySQL Or MariaDB Root Password.md similarity index 100% rename from translated/tech/20180830 How To Reset MySQL Or MariaDB Root Password.md rename to published/20180830 How To Reset MySQL Or MariaDB Root Password.md From ddfdca1510aaea62343016d2eca014fde0c454c6 Mon Sep 17 00:00:00 2001 From: zafiry Date: Sat, 8 Sep 2018 13:17:59 +0800 Subject: [PATCH 117/455] Zafiry translating... --- sources/tech/20180822 What is a Makefile and how does it work.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180822 What is a Makefile and how does it work.md b/sources/tech/20180822 What is a Makefile and how does it work.md index cf168cc44d..dc205f78dc 100644 --- a/sources/tech/20180822 What is a Makefile and how does it work.md +++ b/sources/tech/20180822 What is a Makefile and how does it work.md @@ -1,3 +1,4 @@ +Zafiry translating... What is a Makefile and how does it work? ====== From 4e1c6f85513397b25f2220d47afe225a97638465 Mon Sep 17 00:00:00 2001 From: feng lv Date: Sat, 8 Sep 2018 15:54:39 +0800 Subject: [PATCH 118/455] translated --- ...nd Line Interface For Trashcan On Linux.md | 147 ----------------- ...nd Line Interface For Trashcan On Linux.md | 150 ++++++++++++++++++ 2 files changed, 150 insertions(+), 147 deletions(-) delete mode 100644 sources/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md create mode 100644 translated/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md diff --git a/sources/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md b/sources/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md deleted file mode 100644 index 4bb10f4f64..0000000000 --- a/sources/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md +++ /dev/null @@ -1,147 +0,0 @@ -ucasFL translating - -Trash-Cli : A Command Line Interface For Trashcan On Linux -====== -Everyone knows about `Trashcan` which is common for all users like Linux, or Windows, or Mac. Whenever you delete a file or folder, it will be moved to trash. - -Note that moving files to the trash does not free up space on the file system until the Trashcan is empty. - -Trash stores deleted files temporarily which help us to restore when it's necessary, if you don't want these files then delete it permanently (empty the trash). - -Make sure, you won't find any files or folders in the trash when you delete using `rm` command. So, think twice before performing rm command. If you did a mistake that's it, it'll go away and you can't restore back. since metadata is not stored on disk nowadays. - -Trash is a feature provided by the desktop manager such as GNOME, KDE, and XFCE, etc, as per [freedesktop.org specification][1]. when you delete a file or folder from file manger then it will go to trash and the trash folder can be found @ `$HOME/.local/share/Trash`. - -Trash folder contains two folder `files` & `info`. Files folder stores actual deleted files and folders & Info folder contains deleted files & folders information such as file path, deleted date & time in separate file. - -You might ask, Why you want CLI utility When having GUI Trashcan, most of the NIX guys (including me) play around CLI instead of GUI even though when they working GUI based system. So, if some one looking for CLI based Trashcan then this is the right choice for them. - -### What's Trash-Cli - -[trash-cli][2] is a command line interface for Trashcan utility compliant with the FreeDesktop.org trash specifications. It stores the name, original path, deletion date, and permissions of each trashed file. - -### How to Install Trash-Cli in Linux - -Trash-Cli is available on most of the Linux distribution official repository, so run the following command to install. - -For **`Debian/Ubuntu`** , use [apt-get command][3] or [apt command][4] to install Trash-Cli. -``` -$ sudo apt install trash-cli - -``` - -For **`RHEL/CentOS`** , use [YUM Command][5] to install Trash-Cli. -``` -$ sudo yum install trash-cli - -``` - -For **`Fedora`** , use [DNF Command][6] to install Trash-Cli. -``` -$ sudo dnf install trash-cli - -``` - -For **`Arch Linux`** , use [Pacman Command][7] to install Trash-Cli. -``` -$ sudo pacman -S trash-cli - -``` - -For **`openSUSE`** , use [Zypper Command][8] to install Trash-Cli. -``` -$ sudo zypper in trash-cli - -``` - -If you distribution doesn't offer Trash-cli, we can easily install from pip. Your system should have pip package manager, in order to install python packages. -``` -$ sudo pip install trash-cli -Collecting trash-cli - Downloading trash-cli-0.17.1.14.tar.gz -Installing collected packages: trash-cli - Running setup.py bdist_wheel for trash-cli ... done -Successfully installed trash-cli-0.17.1.14 - -``` - -### How to Use Trash-Cli - -It's not a big deal since it's offering native syntax. It provides following commands. - - * **`trash-put:`** Delete files and folders. - * **`trash-list:`** Pint Deleted files and folders. - * **`trash-restore:`** Restore a file or folder from trash. - * **`trash-rm:`** Remove individual files from the trashcan. - * **`trash-empty:`** Empty the trashcan(s). - - - -Let's try some examples to experiment this. - -1) Delete files and folders : In our case, we are going to send a file named `2g.txt` and folder named `magi` to Trash by running following command. -``` -$ trash-put 2g.txt magi - -``` - -You can see the same in file manager. - -2) Pint Delete files and folders : To view deleted files and folders, run the following command. As i can see detailed infomation about deleted files and folders such as name, date & time, and file path. -``` -$ trash-list -2017-10-01 01:40:50 /home/magi/magi/2g.txt -2017-10-01 01:40:50 /home/magi/magi/magi - -``` - -3) Restore a file or folder from trash : At any point of time you can restore a files and folders by running following command. It will ask you to enter the choice which you want to restore. In our case, we are going to restore `2g.txt` file, so my option is `0`. -``` -$ trash-restore - 0 2017-10-01 01:40:50 /home/magi/magi/2g.txt - 1 2017-10-01 01:40:50 /home/magi/magi/magi -What file to restore [0..1]: 0 - -``` - -4) Remove individual files from the trashcan : If you want to remove specific files from trashcan, run the following command. In our case, we are going to remove `magi` folder. -``` -$ trash-rm magi - -``` - -5) Empty the trashcan : To remove everything from the trashcan, run the following command. -``` -$ trash-empty - -``` - -6) Remove older then X days file : Alternatively you can remove older then X days files so, run the following command to do it. In our case, we are going to remove `10` days old items from trashcan. -``` -$ trash-empty 10 - -``` - -trash-cli works great but if you want to try alternative, give a try to [gvfs-trash][9] & [autotrash][10] - --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/trash-cli-command-line-trashcan-linux-system/ - -作者:[2daygeek][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.2daygeek.com/author/2daygeek/ -[1]:https://freedesktop.org/wiki/Specifications/trash-spec/ -[2]:https://github.com/andreafrancia/trash-cli -[3]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ -[4]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ -[5]:https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ -[6]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ -[7]:https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ -[8]:https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ -[9]:http://manpages.ubuntu.com/manpages/trusty/man1/gvfs-trash.1.html -[10]:https://github.com/bneijt/autotrash diff --git a/translated/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md b/translated/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md new file mode 100644 index 0000000000..198c8d0ffa --- /dev/null +++ b/translated/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md @@ -0,0 +1,150 @@ +Trash-Cli : Linux 上的命令行回收站工具 +====== + +相信每个人都对回收站trashcan很熟悉,因为无论是对 Linux 用户,还是 Windows 用户,或者 Mac 用户来说,它都很常见。当你删除一个文件或目录的时候,该文件或目录会被移动到回收站中。 + +需要注意的是,当把文件移动到回收站以后,文件系统空间并没有被释放,除非把回收站清空。 + +如果不想永久删除文件的话(清空回收站),可以利用回收站临时存储被删除了的文件,从而在必要的时候能够帮助我们恢复删除了的文件。 + +但是,如果在命令行使用 `rm` 命令进行删除操作,那么你是不可能在回收站中找到任何被删除了的文件或目录的。所以,在执行 `rm` 命令前请一定要三思。如果你犯了错误(执行了 `rm` 命令),那么文件就被永久删除了,无法再恢复回来,因为存储在磁盘上的元数据已经不在了。 + +根据 [freedesktop.org 规范][1],垃圾trash是由桌面管理器比如 GNOME、KDE 和 XFCE 等提供的一个特性。当通过文件管理器删除一个文件或目录的时候,该文件或目录将会成为垃圾trash,然后被移动到回收站中,回收站对应的目录是 `$HOME/.local/share/Trash` 。 + +回收站目录包含两个子目录:`files` 和 `info` 。`files` 目录存储实际被删除了的文件和目录,`info` 目录包含被删除了的文件和目录的信息,比如文件路径、删除日期和时间,每个文件单独存储。 + +你可能会问,既然已经有了图形用户界面GUI的回收站,为什么还需要命令行工具呢?因为对于大多数使用 *NIX 系统的家伙(包括我)来说,即使使用的是基于图形用户界面的系统,也更喜欢使用命令行而不是图形用户界面。所以,如果有人在寻找一个命令行回收站工具,那么这儿有一个不错的选择。 + +### Trash-Cli 是什么 + +[trash-cli][2] 是一个命令行回收站工具,并且符合 FreeDesktop.org 的垃圾trash规范。它能够存储每一个垃圾文件的名字、原始路径、删除日期和权限。 + +### 如何在 Linux 上安装 Trash-Cli + +绝大多数的 Linux 发行版官方仓库都提供了 Trash-Cli 的安装包,所以你可以运行下面这些命令来安装。 + +对于 Debian/Ubuntu 用户,使用 [apt-get][3] 或 [apt][4] 命令来安装 Trash-Cli: + +``` +$ sudo apt install trash-cli +``` + +对于 RHEL/CentOS 用户,使用 [yum][5] 命令来安装 Trash-Cli: + +``` +$ sudo yum install trash-cli + +``` + +对于 Fedora 用户,使用 [dnf][6] 命令来安装 Trash-Cli: + +``` +$ sudo dnf install trash-cli + +``` + +对于 Arch Linux 用户,使用 [pacman][7] 命令来安装 Trash-Cli: + +``` +$ sudo pacman -S trash-cli + +``` + +对于 openSUSE 用户,使用 [zypper][8] 命令来安装 Trash-Cli: + +``` +$ sudo zypper in trash-cli + +``` + +如果你的发行版中没有提供 Trash-Cli 的安装包,那么你也可以使用 pip 来安装。为了能够安装 python 包,你的系统中应该会有 pip 包管理器。 + +``` +$ sudo pip install trash-cli +Collecting trash-cli + Downloading trash-cli-0.17.1.14.tar.gz +Installing collected packages: trash-cli + Running setup.py bdist_wheel for trash-cli ... done +Successfully installed trash-cli-0.17.1.14 + +``` + +### 如何使用 Trash-Cli + +Trash-Cli 的使用不难,因为它提供了一个很简单的语法。Trash-Cli 提供了下面这些命令: + + * `trash-put`: 删除文件和目录(仅放入回收站中) + * `trash-list` :列出被删除了的文件和目录 + * `trash-restore`:从回收站中恢复文件或目录 trash. + * `trash-rm`:删除回收站中的文件 + * `trash-empty`:清空回收站 + +下面,让我们通过一些例子来试验一下。 + +1)删除文件和目录:在这个例子中,我们通过运行下面这个命令,将 2g.txt 这一文件和 magi 这一文件夹移动到回收站中。 + +``` +$ trash-put 2g.txt magi +``` + +和你在文件管理器中看到的一样。 + +2)列出被删除了的文件和目录:为了查看被删除了的文件和目录,你需要运行下面这个命令。之后,你可以在输出中看到被删除文件和目录的详细信息,比如名字、删除日期和时间,以及文件路径。 + +``` +$ trash-list +2017-10-01 01:40:50 /home/magi/magi/2g.txt +2017-10-01 01:40:50 /home/magi/magi/magi +``` + +3)从回收站中恢复文件或目录:任何时候,你都可以通过运行下面这个命令来恢复文件和目录。它将会询问你来选择你想要恢复的文件或目录。在这个例子中,我打算恢复 2g.txt 文件,所以我的选择是 0 。 + +``` +$ trash-restore + 0 2017-10-01 01:40:50 /home/magi/magi/2g.txt + 1 2017-10-01 01:40:50 /home/magi/magi/magi +What file to restore [0..1]: 0 +``` + +4)从回收站中删除文件:如果你想删除回收站中的特定文件,那么可以运行下面这个命令。在这个例子中,我将删除 magi 目录。 + +``` +$ trash-rm magi +``` + +5)清空回收站:如果你想删除回收站中的所有文件和目录,可以运行下面这个命令。 + +``` +$ trash-empty +``` + +6)删除超过 X 天的垃圾文件:或者,你可以通过运行下面这个命令来删除回收站中超过 X 天的文件。在这个例子中,我将删除回收站中超过 10 天的项目。 + +``` +$ trash-empty 10 + +``` + +Trash-Cli 可以工作的很好,但是如果你想尝试它的一些替代品,那么你也可以试一试 [gvfs-trash][9] 和 [autotrash][10] 。 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/trash-cli-command-line-trashcan-linux-system/ + +作者:[2daygeek][a] +译者:[ucasFL](https://github.com/ucasFL) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.2daygeek.com/author/2daygeek/ +[1]:https://freedesktop.org/wiki/Specifications/trash-spec/ +[2]:https://github.com/andreafrancia/trash-cli +[3]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[4]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[5]:https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[6]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[7]:https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ +[8]:https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ +[9]:http://manpages.ubuntu.com/manpages/trusty/man1/gvfs-trash.1.html +[10]:https://github.com/bneijt/autotrash From cbe1999ea7fb44c1719f8d2cf933b417c335835e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 19:11:11 +0800 Subject: [PATCH 119/455] PRF:20180730 How to use VS Code for your Python projects.md --- ...to use VS Code for your Python projects.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/published/20180730 How to use VS Code for your Python projects.md b/published/20180730 How to use VS Code for your Python projects.md index c332a42d60..2ae8bbd3c3 100644 --- a/published/20180730 How to use VS Code for your Python projects.md +++ b/published/20180730 How to use VS Code for your Python projects.md @@ -98,21 +98,21 @@ VS Code 的一个重要特点是它可以运行任务。需要运行的任务保 ``` { - // See https://go.microsoft.com/fwlink/?LinkId=733558 - // for the documentation about the tasks.json format - "version": "2.0.0", - "tasks": [ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ { - "label": "Run Debug Server", - "type": "shell", - "command": "${workspaceRoot}/.venv/bin/flask run -h 0.0.0.0 -p 5000", - "group": { - "kind": "build", - "isDefault": true + "label": "Run Debug Server", + "type": "shell", + "command": "${workspaceRoot}/.venv/bin/flask run -h 0.0.0.0 -p 5000", + "group": { + "kind": "build", + "isDefault": true + } } - } - ] + ] } ``` From 09f73b9566d44999d24ec76ceb7e3747ec5a38e1 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 21:43:06 +0800 Subject: [PATCH 120/455] PRF:20180402 Understanding Linux filesystems- ext4 and beyond.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 部分 --- ...ding Linux filesystems- ext4 and beyond.md | 129 +++++++++--------- 1 file changed, 64 insertions(+), 65 deletions(-) diff --git a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md index b437df4350..eb5bd97879 100644 --- a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md +++ b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md @@ -1,43 +1,46 @@ -理解 Linux 文件系统:ext4 以及更多文件系统 -========================================== +理解 Linux 文件系统:ext4 等文件系统 +======= + +> 了解 ext4 的历史,包括其与 ext3 和之前的其它文件系统之间的区别。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR) -目前的大部分 Linux 文件系统都默认采用 ext4 文件系统, 正如以前的 Linux 发行版默认使用 ext3、ext2 以及更久前的 ext。对于不熟悉 Linux 或文件系统的朋友而言,你可能不清楚 ext4 相对于上一版本 ext3 带来了什么变化。你可能还想知道在一连串关于可替代文件系统例如 btrfs、xfs 和 zfs 不断被发布的情况下,ext4 是否仍然能得到进一步的发展 。 - -在一篇文章中,我们不可能讲述文件系统的所有方面,但我们尝试让您尽快了解 Linux 默认文件系统的发展历史,包括它的产生以及未来发展。我仔细研究了维基百科里的各种关于 ext 文件系统文章、kernel.org‘s wiki 中关于 ext4 的条目以及结合自己的经验写下这篇文章。 +目前的大部分 Linux 文件系统都默认采用 ext4 文件系统, 正如以前的 Linux 发行版默认使用 ext3、ext2 以及更久前的 ext。 + +对于不熟悉 Linux 或文件系统的朋友而言,你可能不清楚 ext4 相对于上一版本 ext3 带来了什么变化。你可能还想知道在一连串关于替代的文件系统例如 btrfs、xfs 和 zfs 不断被发布的情况下,ext4 是否仍然能得到进一步的发展。 + +在一篇文章中,我们不可能讲述文件系统的所有方面,但我们尝试让您尽快了解 Linux 默认文件系统的发展历史,包括它的产生以及未来发展。我仔细研究了维基百科里的各种关于 ext 文件系统文章、kernel.org 的 wiki 中关于 ext4 的条目以及结合自己的经验写下这篇文章。 ### ext 简史 #### MINIX 文件系统 -在有 ext 之前, 使用的是 MINIX 文件系统。如果你不熟悉 Linux 历史, 那么可以理解为 MINIX 相对于 IBM PC/AT 微型计算机来说是一个非常小的类 Unix 系统。Andrew Tannenbaum 为了教学的目的而开发了它并于 1987 年发布了源代码(印刷版!)。 - +在有 ext 之前, 使用的是 MINIX 文件系统。如果你不熟悉 Linux 历史, 那么可以理解为 MINIX 是用于 IBM PC/AT 微型计算机的一个非常小的类 Unix 系统。Andrew Tannenbaum 为了教学的目的而开发了它,并于 1987 年发布了源代码(以印刷版的格式!)。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/ibm_pc_at.jpg?itok=Tfk3hQYB) +*IBM 1980 中期的 PC/AT,[MBlairMartin](https://commons.wikimedia.org/wiki/File:IBM_PC_AT.jpg),[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/deed.en)* -虽然你可以读阅 MINIX 的源代码,但实际上它并不是免费的开源软件(FOSS)。出版 Tannebaum 著作的出版商要求你花 69 美元的许可费来获得 MINIX 的操作权,而这笔费用包含在书籍的费用中。尽管如此,在那时来说非常便宜,并且 MINIX 的使用得到迅速发展,很快超过了 Tannebaum 当初使用它来教授操作系统编码的意图。在整个 20 世纪 90 年代,你可以发现 MINIX 的安装在世界各个大学里面非常流行。 -而此时,年轻的 Lius Torvalds 使用 MINIX 来开发原始 Linux 内核,并于 1991 年首次公布。而后在 1992 年 12 月在 GPL 开源协议下发布。 +虽然你可以细读 MINIX 的源代码,但实际上它并不是自由开源软件(FOSS)。出版 Tannebaum 著作的出版商要求你花 69 美元的许可费来运行 MINIX,而这笔费用包含在书籍的费用中。尽管如此,在那时来说非常便宜,并且 MINIX 的使用得到迅速发展,很快超过了 Tannebaum 当初使用它来教授操作系统编码的意图。在整个 20 世纪 90 年代,你可以发现 MINIX 的安装在世界各个大学里面非常流行。而此时,年轻的 Lius Torvalds 使用 MINIX 来开发原始 Linux 内核,并于 1991 年首次公布。而后在 1992 年 12 月在 GPL 开源协议下发布。 -但是等等,这是一篇以*文件系统*为主题的文章不是吗?是的,MINIX 有自己的文件系统,早期的 Linux 版本依赖于它。跟 MINIX 一样,Linux 的文件系统也如同玩具那般小 —— MINX 文件系统最多能处理 14 个字符的文件名,并且只能处理 64MB 的存储空间。到了 1991 年,一般的硬盘尺寸已经达到了 40-140MB。很显然,Linux 需要一个更好的文件系统。 +但是等等,这是一篇以*文件系统*为主题的文章不是吗?是的,MINIX 有自己的文件系统,早期的 Linux 版本依赖于它。跟 MINIX 一样,Linux 的文件系统也如同玩具那般小 —— MINIX 文件系统最多能处理 14 个字符的文件名,并且只能处理 64MB 的存储空间。到了 1991 年,一般的硬盘尺寸已经达到了 40-140MB。很显然,Linux 需要一个更好的文件系统。 #### ext 当 Linus 开发出刚起步的 Linux 内核时,Rémy Card 从事第一代的 ext 文件系统的开发工作。 ext 文件系统在 1992 首次实现并发布 —— 仅在 Linux 首次发布后的一年! —— ext 解决了 MINIX 文件系统中最糟糕的问题。 -1992年的 ext 使用在 Linux 内核中的新虚拟文件系统(VFS)抽象层。与之前的 MINIX 文件系统不同的是,ext 可以处理高达 2GB 存储空间并处理 255 个字符的文件名。 +1992 年的 ext 使用在 Linux 内核中的新虚拟文件系统(VFS)抽象层。与之前的 MINIX 文件系统不同的是,ext 可以处理高达 2GB 存储空间并处理 255 个字符的文件名。 -但 ext 并没有长时间占统治地位,主要是由于它的原始时间戳(每个文件仅有一个时间戳,而不是今天我们所熟悉的有 inode 、最近文件访问时间和最新文件修改时间的时间戳。)仅仅一年后,ext2 就替代了它。 +但 ext 并没有长时间占统治地位,主要是由于它原始的时间戳(每个文件仅有一个时间戳,而不是今天我们所熟悉的有 inode 、最近文件访问时间和最新文件修改时间的时间戳。)仅仅一年后,ext2 就替代了它。 #### ext2 -Rémy 很快就意识到 ext 的局限性,所以一年后他设计出 ext2 替代它。当 ext 仍然根植于 "玩具” 操作系统时,ext2 从一开始就被设计为一个商业级文件系统,沿用 BSD 的 Berkeley 文件系统的设计原理。 +Rémy 很快就意识到 ext 的局限性,所以一年后他设计出 ext2 替代它。当 ext 仍然根植于 “玩具” 操作系统时,ext2 从一开始就被设计为一个商业级文件系统,沿用 BSD 的 Berkeley 文件系统的设计原理。 -Ext2 提供了 GB 级别的最大文件大小和 TB 级别的文件系统大小,使其在 20 世纪 90 年代的地位牢牢巩固在文件系统大联盟中。很快它被广泛地使用,无论是在 Linux 内核中还是最终在 MINIX 中,且利用第三方模块可以使其应用于 MacOs 和 Windows。 +Ext2 提供了 GB 级别的最大文件大小和 TB 级别的文件系统大小,使其在 20 世纪 90 年代的地位牢牢巩固在文件系统大联盟中。很快它被广泛地使用,无论是在 Linux 内核中还是最终在 MINIX 中,且利用第三方模块可以使其应用于 MacOS 和 Windows。 -但这里仍然有一些问题需要解决:ext2 文件系统与 20 世纪 90 年代的大多数文件系统一样,如果在将数据写入到磁盘的时候,系统发生奔溃或断电,则容易发生灾难性的数据损坏。随着时间的推移,由于碎片(单个文件存储在多个位置,物理上其分散在旋转的磁盘上),它们也遭受了严重的性能损失。 +但这里仍然有一些问题需要解决:ext2 文件系统与 20 世纪 90 年代的大多数文件系统一样,如果在将数据写入到磁盘的时候,系统发生崩溃或断电,则容易发生灾难性的数据损坏。随着时间的推移,由于碎片(单个文件存储在多个位置,物理上其分散在旋转的磁盘上),它们也遭受了严重的性能损失。 尽管存在这些问题,但今天 ext2 还是用在某些特殊的情况下 —— 最常见的是,作为便携式 USB 拇指驱动器的文件系统格式。 @@ -45,21 +48,19 @@ Ext2 提供了 GB 级别的最大文件大小和 TB 级别的文件系统大小 1998 年, 在 ext2 被采用后的 6 年后,Stephen Tweedie 宣布他正在致力于改进 ext2。这成了 ext3,并于 2001 年 11 月在 2.4.15 内核版本中被采用到 Linux 内核主线中。 - ![Packard Bell 计算机][2] -20世纪90年代中期的 Packard Bell 计算机, [Spacekid][3], [CC0][4] +*20 世纪 90 年代中期的 Packard Bell 计算机,[Spacekid][3],[CC0][4]* -在大部分情况下,Ext2 在 Linux 发行版中做得很好,但像 FAT、FAT32、HFS 和当时的其他文件系统一样 —— 在断电时容易发生灾难性的破坏。如果在将数据写入文件系统时候发生断电,则可能会将其留在所谓 *不一致* 的状态 —— 事情只完成一半而另一半未完成。这可能导致大量文件丢失或损坏,这些文件与正在保存的文件无关甚至导致整个文件系统无法卸载。 +在大部分情况下,Ext2 在 Linux 发行版中工作得很好,但像 FAT、FAT32、HFS 和当时的其他文件系统一样 —— 在断电时容易发生灾难性的破坏。如果在将数据写入文件系统时候发生断电,则可能会将其留在所谓*不一致*的状态 —— 事情只完成一半而另一半未完成。这可能导致大量文件丢失或损坏,这些文件与正在保存的文件无关甚至导致整个文件系统无法卸载。 -Ext3 和 20 世纪 90 年代后期的其他文件系统,如微软的 NTFS ,使用*日志*来解决这个问题。 日志是磁盘上的一种特殊分配,其写入存储在事务中;如果事务完成写入磁盘,则日志中的数据将提交给文件系统它本身。如果文件在它提交操作前崩溃,则重新启动的系统识别其为未完成的事务而将其进行回滚,就像从未发生过一样。这意味着正在处理的文件可能依然会丢失,但文件系统本身保持一致,且其他所有数据都是安全的。 +Ext3 和 20 世纪 90 年代后期的其他文件系统,如微软的 NTFS ,使用*日志*来解决这个问题。日志是磁盘上的一种特殊的分配区域,其写入被存储在事务中;如果该事务完成磁盘写入,则日志中的数据将提交给文件系统自身。如果系统在该操作提交前崩溃,则重新启动的系统识别其为未完成的事务而将其进行回滚,就像从未发生过一样。这意味着正在处理的文件可能依然会丢失,但文件系统*本身*保持一致,且其他所有数据都是安全的。 -在使用 ext3 文件系统的 Linux 内核中实现了三个级别的日志记录方式:**日记(journal)** , **顺序(ordered)** , 和 **回写(writeback)**。 - - * **日记(Journal)** 是最低风险模式,在将数据和元数据提交给文件系统之前将其写入日志。这可以保证正在写入的文件与整个文件系统的一致性,但其显著降低了性能。 - * **顺序(Ordered)** 是大多数 Linux 发行版默认模式;ordered 模式将元数据写入日志且直接将数据提交到文件系统。顾名思义,这里的操作顺序是固定的:首先,元数据提交到日志;其次,数据写入文件系统,然后才将日志中关联的元数据更新到文件系统。这确保了在发生奔溃时,与未完整写入相关联的元数据仍在日志中,且文件系统可以在回滚日志时清理那些不完整的写入事务。在 ordered 模式下,系统崩溃可能导致在崩溃期间文件被主动写入或损坏,但文件系统它本身 —— 以及未被主动写入的文件 —— 确保是安全的。 - * **回写(Writeback)** 是第三种模式 —— 也是最不安全的日志模式。在 writeback 模式下,像 ordered 模式一样,元数据会被记录,但数据不会。与 ordered 模式不同,元数据和数据都可以以任何有利于获得最佳性能的顺序写入。这可以显著提高性能,但安全性低很多。尽管 wireteback 模式仍然保证文件系统本身的安全性,但在奔溃或之前写入的文件很容易丢失或损坏。 +在使用 ext3 文件系统的 Linux 内核中实现了三个级别的日志记录方式:日记journal顺序ordered回写writeback。 + * **日记** 是最低风险模式,在将数据和元数据提交给文件系统之前将其写入日志。这可以保证正在写入的文件与整个文件系统的一致性,但其显著降低了性能。 + * **顺序** 是大多数 Linux 发行版默认模式;顺序模式将元数据写入日志而直接将数据提交到文件系统。顾名思义,这里的操作顺序是固定的:首先,元数据提交到日志;其次,数据写入文件系统,然后才将日志中关联的元数据更新到文件系统。这确保了在发生崩溃时,那些与未完整写入相关联的元数据仍在日志中,且文件系统可以在回滚日志时清理那些不完整的写入事务。在顺序模式下,系统崩溃可能导致在崩溃期间文件的错误被主动写入,但文件系统它本身 —— 以及未被主动写入的文件 —— 确保是安全的。 + * **回写** 是第三种模式 —— 也是最不安全的日志模式。在回写模式下,像顺序模式一样,元数据会被记录到日志,但数据不会。与顺序模式不同,元数据和数据都可以以任何有利于获得最佳性能的顺序写入。这可以显著提高性能,但安全性低很多。尽管回写模式仍然保证文件系统本身的安全性,但在崩溃或崩溃之前写入的文件很容易丢失或损坏。 跟之前的 ext2 类似,ext3 使用 16 位内部寻址。这意味着对于有着 4K 块大小的 ext3 在最大规格为 16TiB 的文件系统中可以处理的最大文件大小为 2TiB。 @@ -67,101 +68,99 @@ Ext3 和 20 世纪 90 年代后期的其他文件系统,如微软的 NTFS , Theodore Ts'o (是当时 ext3 主要开发人员) 在 2006 年发表的 ext4 ,于两年后在 2.6.28 内核版本中被加入到了 Linux 主线。 -Ts’o 将 ext4 描述为一个显著扩展 ext3 的临时技术,但它仍然依赖于旧技术。他预计 ext4 终将会被真正的下一代文件系统所取代。 +Ts’o 将 ext4 描述为一个显著扩展 ext3 但仍然依赖于旧技术的临时技术。他预计 ext4 终将会被真正的下一代文件系统所取代。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/dell_precision_380_workstation.jpeg?itok=3EjYXY2i) -Ext4 在功能上与 Ext3 在功能上非常相似,但大大支持文件系统、提高了对碎片的抵抗力,有更高的性能以及更好的时间戳。 +*Dell Precision 380 工作站,[Lance Fisher](https://commons.wikimedia.org/wiki/File:Dell_Precision_380_Workstation.jpeg),[CC BY-SA 2.0](https://creativecommons.org/licenses/by-sa/2.0/deed.en)* -### Ext4 vs ext3 +Ext4 在功能上与 Ext3 在功能上非常相似,但支持大文件系统、提高了对碎片的抵抗力,有更高的性能以及更好的时间戳。 -Ext3 和 Ext4 有一些非常明确的差别,在这里集中讨论下。 +### ext4 vs ext3 + +ext3 和 ext4 有一些非常明确的差别,在这里集中讨论下。 #### 向后兼容性 -Ext4 特地设计为尽可能地向后兼容 ext3。这不仅允许 ext3 文件系统升级到 ext4;也允许 ext4 驱动程序在 ext3 模式下自动挂载 ext3 文件系统,因此使它无需单独维护两个代码库。 +ext4 特地设计为尽可能地向后兼容 ext3。这不仅允许 ext3 文件系统原地升级到 ext4;也允许 ext4 驱动程序以 ext3 模式自动挂载 ext3 文件系统,因此使它无需单独维护两个代码库。 #### 大文件系统 -Ext3 文进系统使用 32 为寻址,这限制它仅支持 2TiB 文件大小和 16TiB 文件系统系统大小(这是假设在块大小为 4KiB 的情况下,一些 ext3 文件系统使用更小的块大小,因此对其进一步做了限制)。 +ext3 文件系统使用 32 位寻址,这限制它仅支持 2TiB 文件大小和 16TiB 文件系统系统大小(这是假设在块大小为 4KiB 的情况下,一些 ext3 文件系统使用更小的块大小,因此对其进一步被限制)。 -Ext4 使用 48 位的内部寻址,理论上可以在文件系统上分配高达 16TiB 大小的文件,其中文件系统大小最高可达 1000 000 TiB(1EiB)。在早期 ext4 的实现中 有些用户空间的程序仍然将其限制为最大大小为 16TiB 的文件系统,但截至 2011 年,e2fsprogs 已经直接支持大于 16TiB 大小的 ext4 文件系统。例如,红帽企业 Linux 合同上仅支持最高 50TiB 的 ext4 文件系统,并建议 ext4 卷不超过 100TiB。 +ext4 使用 48 位的内部寻址,理论上可以在文件系统上分配高达 16TiB 大小的文件,其中文件系统大小最高可达 1000000 TiB(1EiB)。在早期 ext4 的实现中有些用户空间的程序仍然将其限制为最大大小为 16TiB 的文件系统,但截至 2011 年,e2fsprogs 已经直接支持大于 16TiB 大小的 ext4 文件系统。例如,红帽企业 Linux 在其合同上仅支持最高 50TiB 的 ext4 文件系统,并建议 ext4 卷不超过 100TiB。 -#### 分配改进 +#### 分配方式改进 -Ext4 在将存储块写入磁盘之前对存储块的分配方式进行了大量改进,这可以显著提高读写性能。 +ext4 在将存储块写入磁盘之前对存储块的分配方式进行了大量改进,这可以显著提高读写性能。 -##### 区段(extent) +##### 区段 -extent 是一系列连续的物理块大小 (最多达 128 MiB,假设块大小为 4KiB),可以一次性保留和寻址。使用区段可以减少给定未见所需的 inode 数量,并显著减少碎片并提高写入大文件时的性能。 +区段extent是一系列连续的物理块 (最多达 128 MiB,假设块大小为 4KiB),可以一次性保留和寻址。使用区段可以减少给定文件所需的 inode 数量,并显著减少碎片并提高写入大文件时的性能。 ##### 多块分配 -Ext3 为每一个新分配的块调用一次块分配器。当多个块调用同时打开分配器时,很容易导致严重的碎片。然而,ext4 使用延迟分配,这允许它合并写入并更好地决定如何为尚未提交的写入分配块。 +ext3 为每一个新分配的块调用一次块分配器。当多个写入同时打开分配器时,很容易导致严重的碎片。然而,ext4 使用延迟分配,这允许它合并写入并更好地决定如何为尚未提交的写入分配块。 -##### 持续的预分配 +##### 持久的预分配 -在为文件预分配磁盘空间时,大部分文件系统必须在创建时将零写入该文件的块中。Ext4 允许使用 `fallocate()`,它保证了空间的可用性(并试图为它找到连续的空间),而不需要县写入它。 -这显著提高了写入和将来读取流和数据库应用程序的写入数据的性能。 +在为文件预分配磁盘空间时,大部分文件系统必须在创建时将零写入该文件的块中。ext4 允许替代使用 `fallocate()`,它保证了空间的可用性(并试图为它找到连续的空间),而不需要先写入它。这显著提高了写入和将来读取流和数据库应用程序的写入数据的性能。 ##### 延迟分配 -这是一个耐人嚼味而有争议性的功能。延迟分配允许 ext4 等待分配将写入数据的实际块,直到它准备好将数据提交到磁盘。(相比之下,即使数据仍然在写入缓存,ext3 也会立即分配块。) +这是一个耐人寻味而有争议性的功能。延迟分配允许 ext4 等待分配将写入数据的实际块,直到它准备好将数据提交到磁盘。(相比之下,即使数据仍然在往写入缓存中写入,ext3 也会立即分配块。) -当缓存中的数据累积时,延迟分配块允许文件系统做出更好的选择。然而不幸的是,当程序员想确保数据完全刷新到磁盘时,它增加了在还没有专门编写调用 ‘fsync()’方法的程序中的数据丢失的可能性。 +当缓存中的数据累积时,延迟分配块允许文件系统对如何分配块做出更好的选择,降低碎片(写入,以及稍后的读)并显著提升性能。然而不幸的是,它*增加*了还没有专门调用 `fsync()` 方法(当程序员想确保数据完全刷新到磁盘时)的程序的数据丢失的可能性。 假设一个程序完全重写了一个文件: -`fd=open("file" ,O_TRUNC); write(fd, data); close(fd);` +``` +fd=open("file" ,O_TRUNC); write(fd, data); close(fd); +``` -使用旧的文件系统, `close(fd);` 足以保证 `file` 中的内存刷新到磁盘。即使严格来说,写不是事务性的,但如果文件关闭后发生崩溃,则丢失数据的风险很小。如果写入不成功(由于程序上的错误、磁盘上的错误、断电等),文件的原始版本和较新版本都可能丢失数据或损坏。如果其他进程在写入文件时访问文件,则会看到损坏的版本。 -如果其他进程打开文件并且不希望其内容发生更改 —— 例如,映射到多个正在运行的程序的共享库。这些进程可能会崩溃。 +使用旧的文件系统, `close(fd);` 足以保证 `file` 中的内容刷新到磁盘。即使严格来说,写不是事务性的,但如果文件关闭后发生崩溃,则丢失数据的风险很小。 + +如果写入不成功(由于程序上的错误、磁盘上的错误、断电等),文件的原始版本和较新版本都可能丢失数据或损坏。如果其他进程在写入文件时访问文件,则会看到损坏的版本。如果其他进程打开文件并且不希望其内容发生更改 —— 例如,映射到多个正在运行的程序的共享库。这些进程可能会崩溃。 为了避免这些问题,一些程序员完全避免使用 `O_TRUNC`。相反,他们可能会写入一个新文件,关闭它,然后将其重命名为旧文件名: -`fd=open("newfile"); write(fd, data); close(fd); rename("newfile", "file");` +``` +fd=open("newfile"); write(fd, data); close(fd); rename("newfile", "file"); +``` -在没有延迟分配的文件系统下,这足以避免上面列出的潜在的损坏和崩溃问题:因为`rename()` 是原子操作,所以它不会被崩溃中断;并且运行的程序将引用旧的。现在 `file` 的未链接版本主要有一个打开的文件文件句柄即可。 -但是因为 ext4 的延迟分配会导致写入被延迟和重新排序,`rename("newfile","file")` 可以在 `newfile` 的内容实际写入磁盘内容之前执行,这打开了并行进行再次获得 `file` 坏版本的问题。 +在*没有*延迟分配的文件系统下,这足以避免上面列出的潜在的损坏和崩溃问题:因为`rename()` 是原子操作,所以它不会被崩溃中断;并且运行的程序将继续引用旧的文件。现在 `file` 的未链接版本只要有一个打开的文件文件句柄即可。但是因为 ext4 的延迟分配会导致写入被延迟和重新排序,`rename("newfile","file")` 可以在 `newfile` 的内容实际写入磁盘内容之前执行,这出现了并行进行再次获得 `file` 坏版本的问题。 - -为了缓解这种情况,Linux 内核(自版本 2.6.30 )尝试检测这些常见代码情况并强制立即分配。这减少但不能防止数据丢失的可能性 —— 并且它对新文件没有任何帮助。如果你是一位开发人员,请注意: - -保证数据立即写入磁盘的方法是正确调用 `fsync()` 。 +为了缓解这种情况,Linux 内核(自版本 2.6.30 )尝试检测这些常见代码情况并强制立即分配。这会减少但不能防止数据丢失的可能性 —— 并且它对新文件没有任何帮助。如果你是一位开发人员,请注意:保证数据立即写入磁盘的唯一方法是正确调用 `fsync()` 。 #### 无限制的子目录 -Ext3 仅限于 32000 个子目录;ext4 允许无限数量的子目录。从 2.6.23 内核版本开始,ext4 使用 HTree 索引来减少大量子目录的性能损失。 +ext3 仅限于 32000 个子目录;ext4 允许无限数量的子目录。从 2.6.23 内核版本开始,ext4 使用 HTree 索引来减少大量子目录的性能损失。 #### 日志校验 -Ext3 没有对日志进行校验,这给内核直接控制之外的磁盘或控制器设备带来了自己的缓存问题。如果控制器或具有子集对缓存的磁盘确实无序写入,则可能会破坏 ext3 的日记事务顺序, -从而可能破坏在崩溃期间(或之前一段时间)写入的文件。 +ext3 没有对日志进行校验,这给处于内核直接控制之外的磁盘或带有自己的缓存的控制器设备带来了问题。如果控制器或具有自己的缓存的磁盘脱离了写入顺序,则可能会破坏 ext3 的日记事务顺序,从而可能破坏在崩溃期间(或之前一段时间)写入的文件。 -理论上,这个问题可以使用 write barriers —— 在安装文件系统时,你在挂载选项设置 `barrier=1` ,然后将设备 `fsync` 一直向下调用直到 metal。通过实践,可以发现存储设备和控制器经常不遵守 write barriers —— 提高性能(和 benchmarks,跟竞争对手比较),但增加了本应该防止数据损坏的可能性。 +理论上,这个问题可以使用写入障碍barrier —— 在安装文件系统时,你在挂载选项设置 `barrier=1` ,然后设备就会忠实地执行 `fsync` 一直向下到底层硬件。通过实践,可以发现存储设备和控制器经常不遵守写入障碍 —— 提高性能(和跟竞争对手比较的性能基准),但增加了本应该防止数据损坏的可能性。 -对日志进行校验和允许文件系统奔溃后意识到其某些条目在第一次安装时无效或无序。因此,这避免了即使部分存储设备不存在 barriers ,也会回滚部分或无序日志条目和进一步损坏的文件系统的错误。 +对日志进行校验和允许文件系统崩溃后第一次挂载时意识到其某些条目是无效或无序的。因此,这避免了回滚部分条目或无序日志条目的错误,并进一步损坏的文件系统——即使部分存储设备假做或不遵守写入障碍。 #### 快速文件系统检查 -在 ext3 下,整个文件系统 —— 包括已删除或空文件 —— 在 `fsck` 被调用时需要检查。相比之下,ext4 标记了未分配块和 inode 表的小部分,从而允许 `fsck` 完全跳过它们。 -这大大减少了在大多数文件系统上运行 `fsck` 的时间,并从内核 2.6.24 开始实现。 +在 ext3 下,在 `fsck` 被调用时会检查整个文件系统 —— 包括已删除或空文件。相比之下,ext4 标记了 inode 表未分配的块和扇区,从而允许 `fsck` 完全跳过它们。这大大减少了在大多数文件系统上运行 `fsck` 的时间,它实现于内核 2.6.24。 #### 改进的时间戳 -Ext3 提供粒度为一秒的时间戳。虽然足以满足大多数用途,但任务关键型应用程序经常需要更严格的时间控制。Ext4 通过提供纳秒级的时间戳,使其可用于那些企业,科学以及任务关键型的应用程序。 +ext3 提供粒度为一秒的时间戳。虽然足以满足大多数用途,但任务关键型应用程序经常需要更严格的时间控制。ext4 通过提供纳秒级的时间戳,使其可用于那些企业、科学以及任务关键型的应用程序。 -Ext3文件系统也没有提供足够的位来存储 2038 年 1 月 18 日以后的日期。Ext4 在这里增加了两位,将 [the Unix epoch][5] 扩展了 408 年。如果你在公元 2446 年读到这篇文章, -你很有可能已经转移到一个更好的文件系统 —— 如果你还在测量 UTC 00:00,1970 年 1 月 1 日以来的时间,这会让我非常非常高兴。 +ext3 文件系统也没有提供足够的位来存储 2038 年 1 月 18 日以后的日期。ext4 在这里增加了两个位,将 [Unix 纪元][5] 扩展了 408 年。如果你在公元 2446 年读到这篇文章,你很有可能已经转移到一个更好的文件系统 —— 如果你还在测量自 1970 年 1 月 1 日 00:00(UTC)以来的时间,这会让我死后得以安眠。 #### 在线碎片整理 -ext2 和 ext3 都不直接支持在线碎片整理 —— 即在挂载时会对文件系统进行碎片整理。Ext2 有一个包含的实用程序,**e2defrag**,它的名字暗示 —— 它需要在文件系统未挂载时脱机运行。(显然,这对于根文件系统来说非常有问题。)在 ext3 中的情况甚至更糟糕 —— 虽然 ext3 比 ext2 更不容易受到严重碎片的影响,但 ext3 文件系统运行 **e2defrag** 可能会导致灾难性损坏和数据丢失。 +ext2 和 ext3 都不直接支持在线碎片整理 —— 即在挂载时会对文件系统进行碎片整理。ext2 有一个包含的实用程序,**e2defrag**,它的名字暗示 —— 它需要在文件系统未挂载时脱机运行。(显然,这对于根文件系统来说非常有问题。)在 ext3 中的情况甚至更糟糕 —— 虽然 ext3 比 ext2 更不容易受到严重碎片的影响,但 ext3 文件系统运行 **e2defrag** 可能会导致灾难性损坏和数据丢失。 -尽管 ext3 最初被认为“不受碎片影响”,但对同一文件(例如 BitTorrent)采用大规模并行写入过程的过程清楚地表明情况并非完全如此。一些用户空间攻击和解决方法,例如 [Shake][6], -以这种或那种方式解决了这个问题 —— 但它们比真正的、文件系统感知的、内核级碎片整理过程更慢并且在各方面都不太令人满意。 +尽管 ext3 最初被认为“不受碎片影响”,但对同一文件(例如 BitTorrent)采用大规模并行写入过程的过程清楚地表明情况并非完全如此。一些用户空间的手段和解决方法,例如 [Shake][6],以这样或那样方式解决了这个问题 —— 但它们比真正的、文件系统感知的、内核级碎片整理过程更慢并且在各方面都不太令人满意。 -Ext4通过 **e4defrag** 解决了这个问题,且是一个在线、内核模式、文件系统感知、块和范围级别的碎片整理实用程序。 +ext4通过 **e4defrag** 解决了这个问题,且是一个在线、内核模式、文件系统感知、块和区段级别的碎片整理实用程序。 ### 正在进行的ext4开发 From 766aacf081c2f693661d1c0de93fea5a5d28e02d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 22:05:01 +0800 Subject: [PATCH 121/455] PRF:20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @DavidChenLiang 翻译时中文版式请遵循本项目仓库下的“中文排版指北”。 --- ...Hub on Ubuntu Linux- A beginner-s guide.md | 93 +++++++++++-------- 1 file changed, 52 insertions(+), 41 deletions(-) diff --git a/translated/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md b/translated/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md index e52f108c39..1ccbadd579 100644 --- a/translated/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md +++ b/translated/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md @@ -1,128 +1,139 @@ -在Ubuntu Linux上安装和使用Git和GitHub:初学者指南 +初学者指南:在 Ubuntu Linux 上安装和使用 Git 和 GitHub ====== -Github是一个存放着世界上最棒的一些软件项目的宝藏,这些软件项目由全世界的开发者无私贡献。这个看似简单,实则非常强大的平台因为大大帮助了那些对开发大规模软件感兴趣的开发者而被开源社区所称道。 +Github 是一个存放着世界上最棒的一些软件项目的宝藏,这些软件项目由全世界的开发者无私贡献。这个看似简单,实则非常强大的平台因为大大帮助了那些对开发大规模软件感兴趣的开发者而被开源社区所称道。 -这篇向导是对于安装和使用GitHub的的一个快速说明,本文还将涉及诸如创建本地仓库,如何链接这个本地仓库到包含你的项目的远程仓库(这样每个人都能看到你的项目了), 以及如何提交改变并最终推送所有的本地内容到Github。 +这篇向导是对于安装和使用 GitHub 的的一个快速说明,本文还将涉及诸如创建本地仓库,如何链接这个本地仓库到包含你的项目的远程仓库(这样每个人都能看到你的项目了),以及如何提交改变并最终推送所有的本地内容到 Github。 -请注意这篇向导假设你对Git术语有基本的了解,如推送,拉取请求,提交,仓库等等。并且希望你在GitHub上已注册成功并记下了你的GitHub用户名,那么我们这就进入正题吧: +请注意这篇向导假设你对 Git 术语有基本的了解,如推送、拉取请求(PR)、提交、仓库等等。并且希望你在 GitHub 上已注册成功并记下了你的 GitHub 用户名,那么我们这就进入正题吧: -### 1 在Linux上安装Git +### 1、在 Linux 上安装 Git -下载并安装Git: +下载并安装 Git: ``` sudo apt-get install git ``` -上面的命令适用于Ubuntu并且应该在所有最新版的Ubuntu上都能工作,它们在Ubuntu 16.04和Ubuntu 18.04 LTS (Bionic Beaver)上都测试过,在将来的版本上应该也能工作。 +上面的命令适用于 Ubuntu 并且应该在所有最新版的 Ubuntu 上都能工作,它们在 Ubuntu 16.04 和 Ubuntu 18.04 LTS (Bionic Beaver)上都测试过,在将来的版本上应该也能工作。 +### 2、配置 GitHub -### 2 配置GitHub - -一旦安装完成,接下去就是配置GitHub用户的详细配置信息。请使用下面的两条命令并确保用你自己的GitHub用户名替换"user_name",用你创建GitHub账户的电子邮件替换“email_id”。 +一旦安装完成,接下去就是配置 GitHub 用户的详细配置信息。请使用下面的两条命令,并确保用你自己的 GitHub 用户名替换 `user_name`,用你创建 GitHub 账户的电子邮件替换 `email_id`。 ``` git config --global user.name "user_name" - git config --global user.email "email_id" - ``` -下面的图片显示的例子是如何用我的 GitHub “用户名”:“akshaypai”和我的"邮件地址"[[email protected]][2]来配置上面的命令。 +下面的图片显示的例子是如何用我的 GitHub 用户名:“akshaypai” 和我的邮件地址 “abc123@gmail.com” 来配置上面的命令。 [![Git config][3]][4] -### 3 创建本地仓库 +### 3、创建本地仓库 + 在你的系统上创建一个目录。它将会被作为本地仓库使用,稍后它会被推送到 GitHub 的远程仓库。请使用如下命令: ``` git init Mytest ``` + 如果目录被成功创建,你会看到如下信息: +``` Initialized empty Git repository in /home/akshay/Mytest/.git/ +``` 这行信息可能随你的系统不同而变化。 -这里,Mytest 是创建的目录而“init” 将其转化为一个 GitHub 仓库。将当前目录改为这个新创建的目录。 + +这里,`Mytest` 是创建的目录,而 `init` 将其转化为一个 GitHub 仓库。将当前目录改为这个新创建的目录。 ``` cd Mytest ``` -### 4 新建一个 REAME 文件来描述仓库 -现在创建一个 README 文件并输入一些文本,如“this is git setup on linux”。REAME 文件一般用于描述这个仓库用来放置什么内容或这个项目是关于什么的。例如: +### 4、新建一个 README 文件来描述仓库 + +现在创建一个 `README` 文件并输入一些文本,如 “this is git setup on linux”。README 文件一般用于描述这个仓库用来放置什么内容或这个项目是关于什么的。例如: ``` gedit README ``` -你可以使用任何文本编辑器。我喜欢使用gedit。README文件的内容可以为: -This is a git repo - -### 5 将仓库里的文件加入一个索引 -这是很重要的一步。这里我们会将所有需要推送到 GitHub 的内容都加入一个索引。这些内容可能包括你第一次加入仓库的文本文件或者应用程序,也有可能是对已存在文件的一些编辑(文件的一个更新版本)。 -既然我们已经有了 README 文件,那么让我们创建一个别的文件吧,如一个简单的 C 程序,我们叫它sample.c。文件内容是: +你可以使用任何文本编辑器。我喜欢使用 gedit。`README` 文件的内容可以为: +``` +This is a git repo ``` +### 5、将仓库里的文件加入一个索引 + +这是很重要的一步。这里我们会将所有需要推送到 GitHub 的内容都加入一个索引。这些内容可能包括你第一次加入仓库的文本文件或者应用程序,也有可能是对已存在文件的一些编辑(文件的一个更新版本)。 + +既然我们已经有了 `README` 文件,那么让我们创建一个别的文件吧,如一个简单的 C 程序,我们叫它 `sample.c`。文件内容是: + +``` #include int main() { printf("hello world"); return 0; } - ``` -现在我们有两个文件了。 -README 和 sample.c -用下面的命令将他们加入索引: +现在我们有两个文件了。`README` 和 `sample.c`。 + +用下面的命令将它们加入索引: ``` git add README - git add smaple.c ``` -请注意“git add” 命令能将任意数量的文件和目录加入到索引。这里,当我说“ 索引” 的时候,我是指一个有一定空间的缓冲区,这个缓冲区存储了所有已经被加入到 Git 仓库的文件或目录。 +请注意 `git add` 命令能将任意数量的文件和目录加入到索引。这里,当我说 “索引” 的时候,我是指一个有一定空间的缓冲区,这个缓冲区存储了所有已经被加入到 Git 仓库的文件或目录。 -### 6 将所作的改动加入索引 -所有的文件都加好以后,你就可以提交了。这意味着你已经确定了最终的文件改动( 或增加),现在他们已经准备好被上传到我们自己的仓库了。请使用命令: +### 6、将所作的改动加入索引 + +所有的文件都加好以后,你就可以提交了。这意味着你已经确定了最终的文件改动(或增加),现在它们已经准备好被上传到我们自己的仓库了。请使用命令: ``` git commit -m "some_message" ``` -“some_message”在上面的命令里可以是一些简单的信息如“我的第一次提交”或者“ 编辑了readme 文件”,等等。 -### 7 在GitHub上创建一个仓库 -在 GitHub 上创建一个仓库。请注意仓库的名字必须和你本地创建的仓库的名字严格一致。在这个例子里是'Mytest'。请首先登陆你的 GitHub 账户。点击页面右上角 的"plus(+)"符号,并选择"create nw repository"。如下图所示填入详细信息,点击“create repository”。 +“some_message” 在上面的命令里可以是一些简单的信息如“我的第一次提交”或者“ 编辑了readme 文件”,等等。 + +### 7、在 GitHub 上创建一个仓库 + +在 GitHub 上创建一个仓库。请注意仓库的名字必须和你本地创建的仓库的名字严格一致。在这个例子里是 “Mytest”。请首先登录你的 [GitHub](https://github.com) 账户 。点击页面右上角的 “+” 符号,并选择“create nw repository”。如下图所示填入详细信息,点击 “create repository”。 [![Creating a repository on GitHub][5]][6] + 一旦创建完成,我们就能将本地的仓库推送到 GitHub 你名下的仓库,用下列命令连接 GitHub 上的仓库: -请注意:请确保在运行下列命令前替换了路径中的“user_name” 和“Mytest”为你的 GitHub 用户名和目录名! + +> 请注意:请确保在运行下列命令前替换了路径中的 “user_name” 和 “Mytest” 为你的 GitHub 用户名和目录名! ``` git remote add origin https://github.com/user\_name/Mytest.git> ``` -### 8 将本地仓库里的文件推送的GitHub仓库 -最后一步是用下列的命令将本地仓库的内容推送到远程仓库(GitHub) +### 8、将本地仓库里的文件推送到 GitHub 仓库 +最后一步是用下列的命令将本地仓库的内容推送到远程仓库(GitHub): ``` git push origin master ``` -当提示登陆名和密码时键入登陆名和密码。 + +当提示登录名和密码时键入登录名和密码。 + 下面的图片显示了步骤5到步骤8的流程 [![Pushing files in local repository to GitHub repository][7]][8] -上述将 Mytest 目录里的所有内容(文件) 推送到了GitHub。对于以后的项目或者创建新的仓库,你可以直接从步骤3开始。最后,如果你登陆你的 GitHub 账户并点击你的Mytest 仓库,你会看到这两个文件:README 和sample.c 已经被上传并像如下 图片显示: +上述将 Mytest 目录里的所有内容(文件)推送到了 GitHub。对于以后的项目或者创建新的仓库,你可以直接从步骤 3 开始。最后,如果你登录你的 GitHub 账户并点击你的 Mytest 仓库,你会看到这两个文件:`README` 和 `sample.c` 已经被上传并像如下图片显示: [![Content uploaded to Github][9]][10] - -------------------------------------------------------------------------------- via: https://www.howtoforge.com/tutorial/install-git-and-github-on-ubuntu/ @@ -130,7 +141,7 @@ via: https://www.howtoforge.com/tutorial/install-git-and-github-on-ubuntu/ 作者:[Akshay Pai][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[DavidChenLiang](https://github.com/DavidChenLiang) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 486dc203bfd8a58b6d6b790e2c611e281574d1a7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 22:05:35 +0800 Subject: [PATCH 122/455] PUB:20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md @DavidChenLiang https://linux.cn/article-9991-1.html --- ...nd using Git and GitHub on Ubuntu Linux- A beginner-s guide.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md (100%) diff --git a/translated/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md b/published/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md similarity index 100% rename from translated/tech/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md rename to published/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md From 6c7c6a27f753f2400c36d44e624765a4d7c6dbb5 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 22:43:45 +0800 Subject: [PATCH 123/455] PRF:20180823 An introduction to pipes and named pipes in Linux.md @geekpi --- ...ction to pipes and named pipes in Linux.md | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/translated/tech/20180823 An introduction to pipes and named pipes in Linux.md b/translated/tech/20180823 An introduction to pipes and named pipes in Linux.md index f50af52225..bea644e6c4 100644 --- a/translated/tech/20180823 An introduction to pipes and named pipes in Linux.md +++ b/translated/tech/20180823 An introduction to pipes and named pipes in Linux.md @@ -1,37 +1,39 @@ 介绍 Linux 中的管道和命名管道 ====== +> 要在命令间移动数据?使用管道可使此过程便捷。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW-Internet_construction_9401467_520x292_0512_dc.png?itok=RPkPPtDe) -在 Linux 中,`pipe` 能让你将一个命令的输出发送给另一个命令。管道,如它的名称那样,能重定向一个进程的标准输出、输入、和错误到另一个进程,以便于进一步处理。 +在 Linux 中,`pipe` 能让你将一个命令的输出发送给另一个命令。管道,如它的名称那样,能重定向一个进程的标准输出、输入和错误到另一个进程,以便于进一步处理。 -`pipe` 或者 `unnamed pipe` 命令的语法是在两个命令之间加上 `|` 字符: +“管道”(或称“未命名管道”)命令的语法是在两个命令之间加上 `|` 字符: +``` +Command-1 | Command-2 | ...| Command-N +``` -`Command-1 | Command-2 | …| Command-N` - -这里,管道不能通过另一个会话访问;它被临时创建用于接收 `Command-1` 的执行并重定向标准输出。它在成功执行之后删除。 +这里,该管道不能通过另一个会话访问;它被临时创建用于接收 `Command-1` 的执行并重定向标准输出。它在成功执行之后删除。 ![](https://opensource.com/sites/default/files/uploads/pipe.png) -在上面的示例中,contents.txt 包含特定目录中所有文件的列表 - 具体来说,就 是ls -al 命令的输出。我们首先通过管道(如图所示)使用 contents.txt 中的 “file” 关键字 grep 文件名,因此 cat 命令的输出作为 grep 命令的输入提供。接下来,我们添加管道来执行 awk 命令,该命令显示 grep 命令的过滤输出中的第 9 列。我们还可以使用 wc -l 命令计算 contents.txt 中的行数。 +在上面的示例中,`contents.txt` 包含特定目录中所有文件的列表 —— 具体来说,就是 `ls -al` 命令的输出。我们首先通过管道(如图所示)使用 “file” 关键字从 `contents.txt` 中 `grep` 文件名,因此 `cat` 命令的输出作为 `grep` 命令的输入提供。接下来,我们添加管道来执行 `awk` 命令,该命令显示 `grep` 命令的过滤输出中的第 9 列。我们还可以使用 `wc -l` 命令计算 `contents.txt` 中的行数。 只要系统启动并运行或直到它被删除,命名管道就可以持续使用。它是一个遵循 [FIFO][1](先进先出)机制的特殊文件。它可以像普通文件一样使用。也就是,你可以写入,从中读取,然后打开或关闭它。要创建命名管道,命令为: ``` mkfifo - ``` 这将创建一个命名管道文件,它甚至可以在多个 shell 会话中使用。 创建 FIFO 命名管道的另一种方法是使用此命令: + ``` mknod p - ``` - `>` 符号。要重定向任何命令的标准输入,请使用 `<` 符号。 +要重定向任何命令的标准输出到其它命令,请使用 `>` 符号。要重定向任何命令的标准输入,请使用 `<` 符号。 ![](https://opensource.com/sites/default/files/uploads/redirection.png) @@ -41,9 +43,9 @@ mknod p ![](https://opensource.com/sites/default/files/uploads/verify-output.png) -这里,我们创建了一个命名管道 `my-named-pipe`,并将 `ls -al` 命令的输出重定向到命名管道。我们可以打开一个新的 shell 会话并 `cat` 命名管道的内容,如前所述,它显示了 `ls -al`命令的输出。请注意,命名管道的大小为零,并有一副标志 “p”。 +这里,我们创建了一个命名管道 `my-named-pipe`,并将 `ls -al` 命令的输出重定向到命名管道。我们可以打开一个新的 shell 会话并 `cat` 命名管道的内容,如前所述,它显示了 `ls -al` 命令的输出。请注意,命名管道的大小为零,并有一个标志 “p”。 -因此,下次你在 Linux 终端上使用命令并在命令之间移动数据时,希望管道使过程快速简便。 +因此,下次你在 Linux 终端上使用命令并在命令之间移动数据时,希望管道使这个过程快速简便。 -------------------------------------------------------------------------------- @@ -52,7 +54,7 @@ via: https://opensource.com/article/18/8/introduction-pipes-linux 作者:[Archit Modi][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 192c61070ba5cbf0473a6e75853560612c0c76fe Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 22:44:07 +0800 Subject: [PATCH 124/455] PUB:20180823 An introduction to pipes and named pipes in Linux.md @geekpi https://linux.cn/article-9992-1.html --- .../20180823 An introduction to pipes and named pipes in Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180823 An introduction to pipes and named pipes in Linux.md (100%) diff --git a/translated/tech/20180823 An introduction to pipes and named pipes in Linux.md b/published/20180823 An introduction to pipes and named pipes in Linux.md similarity index 100% rename from translated/tech/20180823 An introduction to pipes and named pipes in Linux.md rename to published/20180823 An introduction to pipes and named pipes in Linux.md From 5072c4384052e0fd96ba3c825d7551f8e5e36ed4 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 23:06:02 +0800 Subject: [PATCH 125/455] PRF:20180823 How to publish a WordPress blog to a static GitLab Pages site.md @geekpi --- ...ress blog to a static GitLab Pages site.md | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/translated/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md b/translated/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md index dc10d754d0..d6843be2bf 100644 --- a/translated/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md +++ b/translated/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md @@ -1,27 +1,28 @@ 如何将 WordPress 博客发布到静态 GitLab Pages 上 ====== +> 通过 GitLab 或 GitHub Pages 来提供一个 WordPress 镜像站点, 从而最小化安全问题。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web-design-monitor-website.png?itok=yUK7_qR0) -很久以前,我为一个家庭成员建立了一个 WordPress 博客。现在有很多选择,但是当时如果你需要一个带有 WYSIWYG 编辑器的基于网络的 CMS,那么当时很少有不错的选择。运行良好的一个不幸的副作用是博客随着时间的推移产生了很多内容。这意味着我要经常更新 WordPress 以防止不断出现的漏洞。 +很久以前,我为一个家庭成员建立了一个 WordPress 博客。如今有很多选择,但是当时如果你需要一个带有所见即所得的编辑器的基于 Web 的 CMS,那么就没什么像样的的选择了。而一切运行良好的不幸的副作用是随着时间的推移该博客产生了很多内容。这意味着我要经常更新 WordPress 以防止不断出现的漏洞。 -因此,我决定劝说家人切换到 [Hugo][1] 会相对容易,然后可以在 [GitLab][2] 上托管博客。但是尝试提取所有内容并将其转换为 [Markdown][3] 变成了一个巨大的麻烦。有自动脚本完成了 95% 的工作,但并不完美。手动更新所有帖子不是我想做的事情,所以最终,我放弃了试图移动博客。 +因此,当我决定劝说家人切换到 [Hugo][1] 会相对容易,然后可以在 [GitLab][2] 上托管博客。但是尝试提取所有内容并将其转换为 [Markdown][3] 变成了一个巨大的麻烦。有自动脚本完成了 95% 的工作,但并不完美。手动更新所有帖子不是我想做的事情,所以最终,我放弃了试图移动博客。 -最近,我又开始考虑这个问题,并意识到有一个我没有考虑过的解决方案:我可以继续维护 WordPress 服务器,但将其设置为发布静态镜像,并使用 [GitLab Pages][4](或 [ GitHub Pages][5] ,如果你喜欢的话)服务。这能让我自动化 [Let's Encrypt][6] 证书续订并消除与托管 WordPress 站点相关的安全问题。然而,这意味着评论将无法使用,但在这种情况下感觉就像是一个小损失,因为博客没有收到很多评论。 +最近,我又开始考虑这个问题,并意识到有一个我没有考虑过的解决方案:我可以继续维护 WordPress 服务器,但将其设置为发布静态镜像,并使用 [GitLab Pages][4](或 [GitHub Pages][5] ,如果你喜欢的话)提供服务。这能让我自动化 [Let's Encrypt][6] 证书续订并消除与托管 WordPress 站点相关的安全问题。然而,这意味着评论将无法使用,但在这种情况下感觉就像是一个小损失,因为博客没有收到很多评论。 这是我提出的解决方案,到目前为止似乎运作良好: - * WordPress 站点中的 URL 没有链接到或来自其他任何地方,以减少它被利用的几率。在此例中,我们将使用 (即使此站点实际上是使用 Pelican 构建的)。 - * 为公共 URL [在 GitLab Pages 上设置托管][7]。 - * 添加 [cron job][8],确定两个 URL 之间的最后构建日期何时不同。如果构建日期不同,则镜像 WordPress 版本。 + * 托管 WordPress 站点中的 URL 没有链接到或来自其他任何地方,以减少它被利用的几率。在此例中,我们将使用 (即使此站点实际上是使用 Pelican 构建的)。 + * 将公共 URL [托管到 GitLab Pages 上][7]。 + * 添加 [cron 任务][8],确定两个 URL 之间的最后构建日期何时不同。如果构建日期不同,则镜像 WordPress 版本。 * 使用 `wget` 镜像后,将所有链接从“私有”更新成“公共”。 * 运行 `git push` 来发布新内容。 - - 这是我使用的两个脚本: -`check-diff.sh` (cron 每 15 分钟调用一次) +`check-diff.sh` (cron 每 15 分钟调用一次): + ``` #!/bin/bash @@ -34,7 +35,8 @@ then fi ``` -`mirror.sh:` +`mirror.sh`: + ``` #!/bin/sh @@ -62,7 +64,7 @@ git push origin master 就是这些了!现在,当博客发生变化时,在 15 分钟内将网站镜像到静态版本并推送到仓库,这将在 GitLab Pages 中反映出来。 -如果你想[在本地运行 WordPress][9],这个概念可以进一步扩展。在这种情况下,你不需要服务器来托管你的 WordPress 博客。你可以在本机运行它。在这种情况下,你的博客不可能被利用。只要你可以在本地运行 `wget`,就可以使用上面的方法在 GitLab Pages 上托管 WordPress 站点。 +如果你想[在本地运行 WordPress][9],这个概念可以进一步扩展。在这种情况下,你不需要服务器来托管你的 WordPress 博客。你可以在本机运行它。在这种情况下,你的博客不可能被攻击利用。只要你可以在本地运行 `wget`,就可以使用上面的方法在 GitLab Pages 上托管 WordPress 站点。 _这篇文章最初发表于 [Local Conspiracy] [10]。允许转载。_ @@ -72,8 +74,8 @@ via: https://opensource.com/article/18/8/publish-wordpress-static-gitlab-pages-s 作者:[Christopher Aedo][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 4a1d9ea2d6081cfb7cee078dba0fcea7de71e3f1 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 23:06:31 +0800 Subject: [PATCH 126/455] PUB:20180823 How to publish a WordPress blog to a static GitLab Pages site.md @geekpi https://linux.cn/article-9993-1.html --- ...w to publish a WordPress blog to a static GitLab Pages site.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180823 How to publish a WordPress blog to a static GitLab Pages site.md (100%) diff --git a/translated/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md b/published/20180823 How to publish a WordPress blog to a static GitLab Pages site.md similarity index 100% rename from translated/tech/20180823 How to publish a WordPress blog to a static GitLab Pages site.md rename to published/20180823 How to publish a WordPress blog to a static GitLab Pages site.md From d96b7fe8a7c6f121e40c5dd3a77b5aa2822cee7e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 8 Sep 2018 23:13:03 +0800 Subject: [PATCH 127/455] PRF:20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md --- ...and GitHub on Ubuntu Linux- A beginner-s guide.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/published/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md b/published/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md index 1ccbadd579..5c2e7d40b5 100644 --- a/published/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md +++ b/published/20180806 Installing and using Git and GitHub on Ubuntu Linux- A beginner-s guide.md @@ -15,7 +15,7 @@ Github 是一个存放着世界上最棒的一些软件项目的宝藏,这些 sudo apt-get install git ``` -上面的命令适用于 Ubuntu 并且应该在所有最新版的 Ubuntu 上都能工作,它们在 Ubuntu 16.04 和 Ubuntu 18.04 LTS (Bionic Beaver)上都测试过,在将来的版本上应该也能工作。 +上面的命令适用于 Ubuntu 并且应该在所有最新版的 Ubuntu 上都能工作,它们在 Ubuntu 16.04 和 Ubuntu 18.04 LTS(Bionic Beaver)上都测试过,在将来的版本上应该也能工作。 ### 2、配置 GitHub @@ -76,8 +76,8 @@ This is a git repo #include int main() { -printf("hello world"); -return 0; + printf("hello world"); + return 0; } ``` @@ -100,11 +100,11 @@ git add smaple.c git commit -m "some_message" ``` -“some_message” 在上面的命令里可以是一些简单的信息如“我的第一次提交”或者“ 编辑了readme 文件”,等等。 +“some_message” 在上面的命令里可以是一些简单的信息如“我的第一次提交”或者“编辑了readme 文件”,等等。 ### 7、在 GitHub 上创建一个仓库 -在 GitHub 上创建一个仓库。请注意仓库的名字必须和你本地创建的仓库的名字严格一致。在这个例子里是 “Mytest”。请首先登录你的 [GitHub](https://github.com) 账户 。点击页面右上角的 “+” 符号,并选择“create nw repository”。如下图所示填入详细信息,点击 “create repository”。 +在 GitHub 上创建一个仓库。请注意仓库的名字必须和你本地创建的仓库的名字严格一致。在这个例子里是 “Mytest”。请首先登录你的 [GitHub](https://github.com) 账户。点击页面右上角的 “+” 符号,并选择“create nw repository”。如下图所示填入详细信息,点击 “create repository”。 [![Creating a repository on GitHub][5]][6] @@ -126,7 +126,7 @@ git push origin master 当提示登录名和密码时键入登录名和密码。 -下面的图片显示了步骤5到步骤8的流程 +下面的图片显示了步骤 5 到步骤 8 的流程 [![Pushing files in local repository to GitHub repository][7]][8] From b950953eb196bcace021613ddef469105473af91 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 09:34:58 +0800 Subject: [PATCH 128/455] PRF:20180402 Understanding Linux filesystems- ext4 and beyond.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 部分 --- ...ding Linux filesystems- ext4 and beyond.md | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md index eb5bd97879..58e6c8f237 100644 --- a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md +++ b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md @@ -156,52 +156,49 @@ ext3 文件系统也没有提供足够的位来存储 2038 年 1 月 18 日以 #### 在线碎片整理 -ext2 和 ext3 都不直接支持在线碎片整理 —— 即在挂载时会对文件系统进行碎片整理。ext2 有一个包含的实用程序,**e2defrag**,它的名字暗示 —— 它需要在文件系统未挂载时脱机运行。(显然,这对于根文件系统来说非常有问题。)在 ext3 中的情况甚至更糟糕 —— 虽然 ext3 比 ext2 更不容易受到严重碎片的影响,但 ext3 文件系统运行 **e2defrag** 可能会导致灾难性损坏和数据丢失。 +ext2 和 ext3 都不直接支持在线碎片整理 —— 即在挂载时会对文件系统进行碎片整理。ext2 有一个包含的实用程序,`e2defrag`,它的名字暗示 —— 它需要在文件系统未挂载时脱机运行。(显然,这对于根文件系统来说非常有问题。)在 ext3 中的情况甚至更糟糕 —— 虽然 ext3 比 ext2 更不容易受到严重碎片的影响,但 ext3 文件系统运行 `e2defrag` 可能会导致灾难性损坏和数据丢失。 尽管 ext3 最初被认为“不受碎片影响”,但对同一文件(例如 BitTorrent)采用大规模并行写入过程的过程清楚地表明情况并非完全如此。一些用户空间的手段和解决方法,例如 [Shake][6],以这样或那样方式解决了这个问题 —— 但它们比真正的、文件系统感知的、内核级碎片整理过程更慢并且在各方面都不太令人满意。 -ext4通过 **e4defrag** 解决了这个问题,且是一个在线、内核模式、文件系统感知、块和区段级别的碎片整理实用程序。 +ext4通过 `e4defrag` 解决了这个问题,且是一个在线、内核模式、文件系统感知、块和区段级别的碎片整理实用程序。 -### 正在进行的ext4开发 +### 正在进行的 ext4 开发 -Ext4,正如 Monty Python 中瘟疫感染者曾经说过的那样,“我还没死呢!” 虽然它的[主要开发人员][7]认为它只是一个真正的[下一代文件系统][8]的权宜之计,但是在一段时间内,没有任何可能的候选人准备好(由于技术或许可问题)部署为根文件系统。 +ext4,正如 Monty Python 中瘟疫感染者曾经说过的那样,“我还没死呢!” 虽然它的[主要开发人员][7]认为它只是一个真正的[下一代文件系统][8]的权宜之计,但是在一段时间内,没有任何可能的候选人准备好(由于技术或许可问题)部署为根文件系统。 -在未来的 ext4 版本中仍然有一些关键功能,包括元数据校验和、一流的配额支持和大型分配块。 +在未来的 ext4 版本中仍然有一些关键功能要开发,包括元数据校验和、一流的配额支持和大分配块。 #### 元数据校验和 由于 ext4 具有冗余超级块,因此为文件系统校验其中的元数据提供了一种方法,可以自行确定主超级块是否已损坏并需要使用备用块。可以在没有校验和的情况下,从损坏的超级块恢复 —— 但是用户首先需要意识到它已损坏,然后尝试使用备用方法手动挂载文件系统。由于在某些情况下,使用损坏的主超级块安装文件系统读写可能会造成进一步的损坏,即使是经验丰富的用户也无法避免,这也不是一个完美的解决方案! -与 btrfs 或 zfs 等下一代文件系统提供的极其强大的每块校验和相比,ext4 的元数据校验和功能非常弱。但它总比没有好。虽然校验和所有的事情都听起来很简单!—— 事实上,将校验和连接到文件系统有一些重大的挑战; 请参阅[设计文档][9]了解详细信息。 +与 btrfs 或 zfs 等下一代文件系统提供的极其强大的每块校验和相比,ext4 的元数据校验和的功能非常弱。但它总比没有好。虽然校验**所有的事情**都听起来很简单!—— 事实上,将校验和与文件系统连接到一起有一些重大的挑战;请参阅[设计文档][9]了解详细信息。 #### 一流的配额支持 -等等,配额?!从 ext2 出现的那条开始我们就有了这些!是的,但他们一直都是事后的想法,而且他们总是有点傻逼。这里可能不值得详细介绍, -但[设计文档][10]列出了配额将从用户空间移动到内核中的方式,并且能够更加正确和高效地执行。 +等等,配额?!从 ext2 出现的那天开始我们就有了这些!是的,但它们一直都是事后的添加的东西,而且它们总是犯傻。这里可能不值得详细介绍,但[设计文档][10]列出了配额将从用户空间移动到内核中的方式,并且能够更加正确和高效地执行。 #### 大分配块 -随着时间的推移,那些讨厌的存储系统不断变得越来越大。由于一些固态硬盘已经使用 8K 硬件模块,因此 ext4 对 4K 模块的当前限制越来越受到限制。 -较大的存储块可以显着减少碎片并提高性能,代价是增加“松弛”空间(当您只需要块的一部分来存储文件或文件的最后一块时留下的空间)。 + +随着时间的推移,那些讨厌的存储系统不断变得越来越大。由于一些固态硬盘已经使用 8K 硬件块大小,因此 ext4 对 4K 模块的当前限制越来越受到限制。较大的存储块可以显著减少碎片并提高性能,代价是增加“松弛”空间(当您只需要块的一部分来存储文件或文件的最后一块时留下的空间)。 您可以在[设计文档][11]中查看详细说明。 -### ext4的实际限制 +### ext4 的实际限制 -Ext4 是一个健壮,稳定的文件系统。它是大多数人应该都在 2018 年用它作为根文件系统,但它无法处理所有需求。让我们简单地谈谈你不应该期待的一些事情 —— 现在或可能在未来。 +ext4 是一个健壮、稳定的文件系统。如今大多数人都应该在用它作为根文件系统,但它无法处理所有需求。让我们简单地谈谈你不应该期待的一些事情 —— 现在或可能在未来: -虽然 ext4 可以处理高达 1 EiB 大小相当于 1,000,000 TiB 大小的数据,但你真的、真的不应该尝试这样做。除了仅仅能够记住更多块的地址之外,还存在规模上的问题 -并且现在 ext4 不会处理(并且可能永远不会)超过 50 —— 100TiB 的数据。 +虽然 ext4 可以处理高达 1 EiB 大小(相当于 1,000,000 TiB)大小的数据,但你真的、*真的*不应该尝试这样做。除了能够记住更多块的地址之外,还存在规模上的问题。并且现在 ext4 不会处理(并且可能永远不会)超过 50 —— 100TiB 的数据。 -Ext4 也不足以保证数据的完整性。随着日志记录的重大进展又回到了前 3 天,它并未涵盖数据损坏的许多常见原因。如果数据已经在磁盘上被[破坏][12]——由于故障硬件, -宇宙射线的影响(是的,真的),或者数据随时间的简单降级 —— ext4无法检测或修复这种损坏。 +ext4 也不足以保证数据的完整性。随着日志记录的重大进展又回到了 ext3 的那个时候,它并未涵盖数据损坏的许多常见原因。如果数据已经在磁盘上被[破坏][12]——由于故障硬件,宇宙射线的影响(是的,真的),或者只是数据随时间衰减 —— ext4 无法检测或修复这种损坏。 -最后两点是,ext4 只是一个纯文件系统,而不是存储卷管理器。这意味着,即使你有多个磁盘 ——也就是奇偶校验或冗余,理论上你可以从 ext4 中恢复损坏的数据,但无法知道使用它是否对你有利。虽然理论上可以在离散层中分离文件系统和存储卷管理系统而不会丢失自动损坏检测和修复功能,但这不是当前存储系统的设计方式,并且它将给新设计带来重大挑战。 +基于上面两点,ext4 只是一个纯*文件系统*,而不是存储卷管理器。这意味着,即使你有多个磁盘——也就是奇偶校验或冗余,理论上你可以从 ext4 中恢复损坏的数据,但无法知道使用它是否对你有利。虽然理论上可以在不同的层中分离文件系统和存储卷管理系统而不会丢失自动损坏检测和修复功能,但这不是当前存储系统的设计方式,并且它将给新设计带来重大挑战。 ### 备用文件系统 -在我们开始之前,提醒一句:要非常小心这是没有内置任何备用的文件系统,并直接支持为您分配的主线内核的一部分! -即使文件系统是安全的,如果在内核升级期间出现问题,使用它作为根文件系统也是非常可怕的。如果你没有充分的想法通过一个 chroot 去使用介质引导,耐心地操作内核模块和 grub 配置, -和 DKMS...不要在一个很重要的系统中去掉对根文件的备份。 +在我们开始之前,提醒一句:要非常小心,没有任何备用的文件系统作为主线内核的一部分而内置和直接支持! + +即使一个文件系统是*安全的*,如果在内核升级期间出现问题,使用它作为根文件系统也是非常可怕的。如果你没有充分的理由通过一个 chroot 去使用介质引导,耐心地操作内核模块和 grub 配置,和 DKMS...不要在一个很重要的系统中去掉对根文件的备份。 可能有充分的理由使用您的发行版不直接支持的文件系统 —— 但如果您这样做,我强烈建议您在系统启动并可用后再安装它。 (例如,您可能有一个 ext4 根文件系统,但是将大部分数据存储在 zfs 或 btrfs 池中。) From 27960b0a0e321da4e071811f4cd3481770501092 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 10:07:02 +0800 Subject: [PATCH 129/455] PRF:20180824 How to install software from the Linux command line.md @geekpi --- ...ll software from the Linux command line.md | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/translated/tech/20180824 How to install software from the Linux command line.md b/translated/tech/20180824 How to install software from the Linux command line.md index efcc0ce464..6d84eec83c 100644 --- a/translated/tech/20180824 How to install software from the Linux command line.md +++ b/translated/tech/20180824 How to install software from the Linux command line.md @@ -1,88 +1,86 @@ 如何从 Linux 命令行安装软件 ====== +> 学习一种不同的包管理器和怎么使用它。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/suitcase_container_bag.png?itok=q40lKCBY) -如果你在任何时间都使用 Linux,你很快就会发现有很多不同的方法可以做同样的事情。这包括通过命令行在 Linux 上安装应用。我已经是大约 25 年的 Linux 用户,我一次又一次地回到命令行来安装我的应用。 +如果你在一直在使用 Linux,你很快就会发现做同样的事情有很多不同的方法。这包括通过命令行在 Linux 上安装应用。我已经是大约 25 年的 Linux 用户,我一次又一次地回到命令行来安装我的应用。 -从命令行安装应用程序最常用的方法是使用称为包管理器的软件库(存储软件的地方)。所有 Linux 应用都作为软件包分发,这些软件包只不过是与软件包管理系统相关的文件。每个 Linux 发行版都附带一个包管理系统,但它们并不完全相同。 +从命令行安装应用程序最常用的方法是使用称为包管理器通过软件库(存储软件的地方)安装。所有 Linux 应用都作为软件包分发,这些软件包只不过是与软件包管理系统相关的文件。每个 Linux 发行版都附带一个包管理系统,但它们并不完全相同。 ### 什么是包管理系统? -包管理系统由多组工具和文件格式组成,它们一起用于安装、更新和卸载 Linux 应用。两种最常见的包管理系统来自 Red Hat 和 Debian。 Red Hat、CentOS 和 Fedora 都使用 `rpm` 系统(.rpm 文件),而Debian、Ubuntu、Mint 和 Ubuntu 都使用 `dpkg`(.deb 文件)。Gentoo Linux 使用名为 Portage 的系统,Arch Linux 只使用 tarball(.tar 文件)。这些系统之间的主要区别在于它们如何安装和维护应用。 +包管理系统由一组工具和文件格式组成,它们一起用于安装、更新和卸载 Linux 应用。两种最常见的包管理系统来自 Red Hat 和 Debian。 Red Hat、CentOS 和 Fedora 都使用 `rpm` 系统(.rpm 文件),而 Debian、Ubuntu、Mint 和 Ubuntu 都使用 `dpkg`(.deb 文件)。Gentoo Linux 使用名为 Portage 的系统,Arch Linux 只使用 tarball(.tar 文件)。这些系统之间的主要区别在于它们如何安装和维护应用。 你可能想知道 `.rpm`、`.deb` 或 `.tar` 文件中的内容。你可能会惊讶地发现,所有这些都只是普通的老式归档文件(如 `.zip`),其中包含应用的代码,如何安装它的说明,依赖项(它可能依赖的其他应用),以及配置文件的位置。读取和执行所有这些指令的软件称为包管理器。 ### Debian、Ubuntu、Mint 等 -Debian、Ubuntu、Mint 和其他基于 Debian 的发行版都使用 `.deb` 文件和 `dpkg` 包管理系统。有两种方法可以通过此系统安装应用。你可以使用 `apt` 程序从仓库进行安装,也可以使用 `dpkg` 程序从 `.deb` 文件安装应用。我们来看看如何做到这两点。 +Debian、Ubuntu、Mint 和其它基于 Debian 的发行版都使用 `.deb` 文件和 `dpkg` 包管理系统。有两种方法可以通过此系统安装应用。你可以使用 `apt` 程序从仓库进行安装,也可以使用 `dpkg` 程序从 `.deb` 文件安装应用。我们来看看如何做到这两点。 使用 `apt` 安装应用非常简单: + ``` $ sudo apt install app_name - ``` 通过 `apt` 卸载应用也非常简单: + ``` $ sudo apt remove app_name - ``` 要升级已安装的应用,首先需要更新应用仓库: + ``` $ sudo apt update - ``` 完成后,你可以使用以下命令更新任何程序: + ``` $ sudo apt upgrade - ``` 如果你只想更新一个应用,该怎么办?没问题。 + ``` $ sudo apt update app_name - ``` 最后,假设你要安装的应用不存在于 Debian 仓库中,但有 `.deb` 下载。 + ``` $ sudo dpkg -i app_name.deb - ``` ### Red Hat、CentOS 和 Fedora 默认情况下,Red Hat 使用多个包管理系统。这些系统在使用自己的命令时,互相仍然非常相似,而且与 Debian 中使用的也相似。例如,我们可以使用 `yum` 或 `dnf` 管理器来安装应用。 + ``` $ sudo yum install app_name - $ sudo dnf install app_name - ``` `.rpm` 格式的应用也可以使用 `rpm` 命令安装。 + ``` $ sudo rpm -i app_name.rpm - ``` 删除不需要的应用同样容易。 + ``` $ sudo yum remove app_name - $ sudo dnf remove app_name - ``` 更新应用同样容易。 + ``` $ yum update - $ sudo dnf upgrade --refresh - ``` 如你所见,从命令行安装、卸载和更新 Linux 应用并不难。事实上,一旦你习惯它,你会发现它比使用基于桌面 GUI 的管理工具更快! @@ -96,7 +94,7 @@ via: https://opensource.com/article/18/8/how-install-software-linux-command-line 作者:[Patrick H.Mullins][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From ffacab44feae24b7aebf5542a657123f0dd0cf7a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 10:07:30 +0800 Subject: [PATCH 130/455] PUB:20180824 How to install software from the Linux command line.md @geekpi https://linux.cn/article-9994-1.html --- ...0180824 How to install software from the Linux command line.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180824 How to install software from the Linux command line.md (100%) diff --git a/translated/tech/20180824 How to install software from the Linux command line.md b/published/20180824 How to install software from the Linux command line.md similarity index 100% rename from translated/tech/20180824 How to install software from the Linux command line.md rename to published/20180824 How to install software from the Linux command line.md From a43d89c10aca5b4f7f51844e545fe7e26cb0afe4 Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Sun, 9 Sep 2018 11:48:37 +0800 Subject: [PATCH 131/455] heguangzhi translating --- ...op 7 open source project management tools for agile teams.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180102 Top 7 open source project management tools for agile teams.md b/sources/tech/20180102 Top 7 open source project management tools for agile teams.md index 81eca56adb..bbaaf41294 100644 --- a/sources/tech/20180102 Top 7 open source project management tools for agile teams.md +++ b/sources/tech/20180102 Top 7 open source project management tools for agile teams.md @@ -1,3 +1,5 @@ +heguangzhi Translating + Top 7 open source project management tools for agile teams ====== From 2d1ad7d625f0a7940cb07872ee15ae31a025683d Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Sun, 9 Sep 2018 14:40:10 +0800 Subject: [PATCH 132/455] translated --- ...roject management tools for agile teams.md | 135 -------------- ...roject management tools for agile teams.md | 168 ++++++++++++++++++ 2 files changed, 168 insertions(+), 135 deletions(-) delete mode 100644 sources/tech/20180102 Top 7 open source project management tools for agile teams.md create mode 100644 translated/tech/20180102 Top 7 open source project management tools for agile teams.md diff --git a/sources/tech/20180102 Top 7 open source project management tools for agile teams.md b/sources/tech/20180102 Top 7 open source project management tools for agile teams.md deleted file mode 100644 index bbaaf41294..0000000000 --- a/sources/tech/20180102 Top 7 open source project management tools for agile teams.md +++ /dev/null @@ -1,135 +0,0 @@ -heguangzhi Translating - -Top 7 open source project management tools for agile teams -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_orgchart1.png?itok=tukiFj89) - -Opensource.com has surveyed the landscape of popular open source project management tools. We've done this before—but this year we've added a twist. This time, we're looking specifically at tools that support [agile][1] methodology, including related practices such as [Scrum][2], Lean, and Kanban. - -The growth of interest in and use of agile is why we've decided to focus on these types of tools this year. A majority of organizations—71%—say they [are using agile approaches][3] at least sometimes. In addition, agile projects are [28% more successful][4] than projects managed with traditional approaches. - -For this roundup, we looked at the project management tools we covered in [2014][5], [2015][6], and [2016][7] and plucked the ones that support agile, then did research to uncover any additions or changes. Whether your organization is already using agile or is one of the many planning to adopt agile approaches in 2018, one of these seven open source project management tools may be exactly what you're looking for. - -### MyCollab - -![](https://opensource.com/sites/default/files/u128651/mycollab_kanban-board.png) - -[MyCollab][8] is a suite of three collaboration modules for small and midsize businesses: project management, customer relationship management (CRM), and document creation and editing software. There are two licensing options: a commercial "ultimate" edition, which is faster and can be run on-premises or in the cloud, and the open source "community edition," which is the version we're interested in here. - -The community edition doesn't have a cloud option and is slower, due to not using query cache, but provides essential project management features, including tasks, issues management, activity stream, roadmap view, and a Kanban board for agile teams. While it doesn't have a separate mobile app, it works on mobile devices as well as Windows, MacOS, Linux, and Unix computers. - -The latest version of MyCollab is 5.4.10 and the source code is available on [GitHub][9]. It is licensed under AGPLv3 and requires a Java runtime and MySQL stack to operate. It's available for [download][10] for Windows, Linux, Unix, and MacOS. - -### Odoo - -![](https://opensource.com/sites/default/files/u128651/odoo_projects_screenshots_01a.gif) - -[Odoo][11] is more than project management software; it's a full, integrated business application suite that includes accounting, human resources, website & e-commerce, inventory, manufacturing, sales management (CRM), and other tools. - -The free and open source community edition has limited [features][12] compared to the paid enterprise suite. Its project management application includes a Kanban-style task-tracking view for agile teams, which was updated in its latest release, Odoo 11.0, to include a progress bar and animation for tracking project status. The project management tool also includes Gantt charts, tasks, issues, graphs, and more. Odoo has a thriving [community][13] and provides [user guides][14] and other training resources. - -It is licensed under GPLv3 and requires Python and PostgreSQL. It is available for [download][15] for Windows, Linux, and Red Hat Package Manager, as a [Docker][16] image, and as source on [GitHub][17]. - -### OpenProject - -![](https://opensource.com/sites/default/files/u128651/openproject-screenshot-agile-scrum.png) - -[OpenProject][18] is a powerful open source project management tool that is notable for its ease of use and rich project management and team collaboration features. - -Its modules support project planning, scheduling, roadmap and release planning, time tracking, cost reporting, budgeting, bug tracking, and agile and Scrum. Its agile features, including creating stories, prioritizing sprints, and tracking tasks, are integrated with OpenProject's other modules. - -OpenProject is licensed under GPLv3 and its source code is available on [GitHub][19]. Its latest version, 7.3.2. is available for [download][20] for Linux; you can learn more about installing and configuring it in Birthe Lindenthal's article "[Getting started with OpenProject][21]." - -### OrangeScrum - -![](https://opensource.com/sites/default/files/u128651/orangescrum_kanban.png) - -As you would expect from its name, [OrangeScrum][22] supports agile methodologies, specifically with a Scrum task board and Kanban-style workflow view. It's geared for smaller organizations—freelancers, agencies, and small and midsize businesses. - -The open source version offers many of the [features][23] in OrangeScrum's paid editions, including a mobile app, resource utilization, and progress tracking. Other features, including Gantt charts, time logs, invoicing, and client management, are available as paid add-ons, and the paid editions include a cloud option, which the community version does not. - -OrangeScrum is licensed under GPLv3 and is based on the CakePHP framework. It requires Apache, PHP 5.3 or higher, and MySQL 4.1 or higher, and works on Windows, Linux, and MacOS. Its latest release, 1.6.1. is available for [download][24], and its source code can be found on [GitHub][25]. - -### ]project-open[ - -![](https://opensource.com/sites/default/files/u128651/projectopen_dashboard.png) - -[]project-open[][26] is a dual-licensed enterprise project management tool, meaning that its core is open source, and some additional features are available in commercially licensed modules. According to the project's [comparison][27] of the community and enterprise editions, the open source core offers plenty of features for small and midsize organizations. - -]project-open[ supports [agile][28] projects with Scrum and Kanban support, as well as classic Gantt/waterfall projects and hybrid or mixed projects. - -The application is licensed under GPL and the [source code][29] is accessible via CVS. ]project-open[ is available as [installers][26] for both Linux and Windows, but also in cloud images and as a virtual appliance. - -### Taiga - -![](https://opensource.com/sites/default/files/u128651/taiga_screenshot.jpg) - -[Taiga][30] is an open source project management platform that focuses on Scrum and agile development, with features including a Kanban board, tasks, sprints, issues, a backlog, and epics. Other features include ticket management, multi-project support, wiki pages, and third-party integrations. - -It also offers a free mobile app for iOS, Android, and Windows devices, and provides import tools that make it easy to migrate from other popular project management applications. - -Taiga is free for public projects, with no restrictions on either the number of projects or the number of users. For private projects, there is a wide range of [paid plans][31] available under a "freemium" model, but, notably, the software's features are the same, no matter which type of plan you have. - -Taiga is licensed under GNU Affero GPLv3, and requires a stack that includes Nginx, Python, and PostgreSQL. The latest release, [3.1.0 Perovskia atriplicifolia][32], is available on [GitHub][33]. - -### Tuleap - -![](https://opensource.com/sites/default/files/u128651/tuleap-scrum-prioritized-backlog.png) - -[Tuleap][34] is an application lifecycle management (ALM) platform that aims to manage projects for every type of team—small, midsize, large, waterfall, agile, or hybrid—but its support for agile teams is prominent. Notably, it offers support for Scrum, Kanban, sprints, tasks, reports, continuous integration, backlogs, and more. - -Other [features][35] include issue tracking, document tracking, collaboration tools, and integration with Git, SVN, and Jenkins, all of which make it an appealing choice for open source software development projects. - -Tuleap is licensed under GPLv2. More information, including Docker and CentOS downloads, is available on their [Get Started][36] page. You can also get the source code for its latest version, 9.14, on Tuleap's [Git][37]. - -The trouble with this type of list is that it's usually out of date as soon as it's published. Are you using an open source project management tool that supports agile that we forgot to include? Or do you have feedback on the ones we mentioned? Please leave a comment below. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/agile-project-management-tools - -作者:[Opensource.com][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 -[1]:http://agilemanifesto.org/principles.html -[2]:https://opensource.com/resources/scrum -[3]:https://www.pmi.org/-/media/pmi/documents/public/pdf/learning/thought-leadership/pulse/pulse-of-the-profession-2017.pdf -[4]:https://www.pwc.com/gx/en/actuarial-insurance-services/assets/agile-project-delivery-confidence.pdf -[5]:https://opensource.com/business/14/1/top-project-management-tools-2014 -[6]:https://opensource.com/business/15/1/top-project-management-tools-2015 -[7]:https://opensource.com/business/16/3/top-project-management-tools-2016 -[8]:https://community.mycollab.com/ -[9]:https://github.com/MyCollab/mycollab -[10]:https://www.mycollab.com/ce-registration/ -[11]:https://www.odoo.com/ -[12]:https://www.odoo.com/page/editions -[13]:https://www.odoo.com/page/community -[14]:https://www.odoo.com/documentation/user/11.0/ -[15]:https://www.odoo.com/page/download -[16]:https://hub.docker.com/_/odoo/ -[17]:https://github.com/odoo/odoo -[18]:https://www.openproject.org/ -[19]:https://github.com/opf/openproject -[20]:https://www.openproject.org/download-and-installation/ -[21]:https://opensource.com/article/17/11/how-install-and-use-openproject -[22]:https://www.orangescrum.org/ -[23]:https://www.orangescrum.org/compare-orangescrum -[24]:http://www.orangescrum.org/free-download -[25]:https://github.com/Orangescrum/orangescrum/ -[26]:http://www.project-open.com/en/list-installers -[27]:http://www.project-open.com/en/products/editions.html -[28]:http://www.project-open.com/en/project-type-agile -[29]:http://www.project-open.com/en/developers-cvs-checkout -[30]:https://taiga.io/ -[31]:https://tree.taiga.io/support/subscription-and-plans/payment-process-faqs/#q.-what-s-about-custom-plans-private-projects-with-more-than-25-members-? -[32]:https://blog.taiga.io/taiga-perovskia-atriplicifolia-release-310.html -[33]:https://github.com/taigaio -[34]:https://www.tuleap.org/ -[35]:https://www.tuleap.org/features/project-management -[36]:https://www.tuleap.org/get-started -[37]:https://tuleap.net/plugins/git/tuleap/tuleap/stable diff --git a/translated/tech/20180102 Top 7 open source project management tools for agile teams.md b/translated/tech/20180102 Top 7 open source project management tools for agile teams.md new file mode 100644 index 0000000000..02c9259ba5 --- /dev/null +++ b/translated/tech/20180102 Top 7 open source project management tools for agile teams.md @@ -0,0 +1,168 @@ +heguangzhi Translating + + + +面向敏捷开发团队的7个开源项目管理工具 +====== + + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_orgchart1.png?itok=tukiFj89) + + +Opensource.com 以前对流行的开源项目管理工具的过相应的调研。但是今年我们增加了一个特点。本次,我们特别关注支持[敏捷][1]方法的工具,包括相关的实践,如[Scrum][2]、 Lean, and Kanban。 + + +对敏捷开发的兴趣和使用的增长是我们今年决定专注于这些工具的原因。大多数组织-71%的人说他们至少使用了敏捷方法(3)[are using agile approaches][3]。此外,敏捷项目比传统方法管理的项目要高出28%(4)[28% more successful][4] 。 + + +我们查看了[2014][5]、[2015][6]和[2016][7]中涉及的项目管理工具,并挑选了支持敏捷的工具,然后进行了研究并做了添加或更改。不管您的组织是否已经在使用敏捷开发,或者是2018年采用敏捷方法的作为众多计划之一,这七个开源项目管理工具之一可能正是您所要找寻的。 + +### MyCollab + +![](https://opensource.com/sites/default/files/u128651/mycollab_kanban-board.png) + + +MyCollab][8]是一套针对中小型企业的三个协作模块:项目管理、客户关系管理(CRM)和文档创建和编辑的软件。有两个许可选项:一个商业的“终极”版本,它更快,可以在内部或云中运行;另一个开源的“社区版本”,这个正是我们感兴趣的版本。 + +由于没有使用查询缓存,社区版本没有云选项,并且速度较慢,但是提供了基本的项目管理特性,包括任务、问题管理、活动流、路线图视图和敏捷团队看板。虽然它没有单独的移动应用程序,但它也适用于移动设备,包括 Windows、Mac OS、Linux 和 UNIX 计算机。 + +The latest version of MyCollab is 5.4.10 and the source code is available on [GitHub][9]. It is licensed under AGPLv3 and requires a Java runtime and MySQL stack to operate. It's available for [download][10] for Windows, Linux, Unix, and MacOS. + + + + +MyCulb的最新版本是5.4.10,源代码可在 [GitHub][9] 上下载。它是在 AgPLv3 下进行授权的,需要 Java 运行和 MySQL支持。它可运行于 Windows、Linux、UNIX 和 MacOS 。下载地址 [download][10]。 + +### Odoo + +![](https://opensource.com/sites/default/files/u128651/odoo_projects_screenshots_01a.gif) + + +[Odoo][11] 不仅仅是项目管理软件;它是一个完整的集成商业应用套件,包括会计、人力资源、网站和电子商务、库存、制造、销售管理(CRM)和其他工具。 + +与付费企业套件相比,免费开源社区版具有有限的[特性][12] 。它的项目管理应用程序包括敏捷团队的看板式任务跟踪视图,在最新版本Odoo 11.0中更新了该视图,以包括用于跟踪项目状态的进度条和动画。项目管理工具还包括甘特图、任务、问题、图表等等。Odoo有一个繁荣的[社区][13],并提供 [用户指南][14] 及其他培训资源。 + + +它是在 GPLv3 下授权的,需要 Python 和 PostgreSQL 支持。作为[Docker][16] 镜像 可以运行在 Windows、Linux 和 Red Hat 包管理器中,下载地址[download][15],源代码[GitHub][17]。 + +### OpenProject + +![](https://opensource.com/sites/default/files/u128651/openproject-screenshot-agile-scrum.png) + + +[OpenProject][18] 是一个强大的开源项目管理工具,以其易用性和丰富的项目管理和团队协作特性而著称。 + + +它的模块支持项目计划、调度、路线图和发布计划、时间跟踪、成本报告、预算、bug跟踪以及敏捷和Scrum。它的敏捷特性,包括创建Story、确定sprint的优先级以及跟踪任务,都与OpenProject的其他模块集成在一起。 + + +OpenProject 在 GPLv3 下获得许可,其源代码可在[GitHub][19]上。最新版本7.3.2 for Linux [download][20];您可以在 Birthe Lindenthal 的文章 “[Getting start of OpenProject][21]"中了解更多关于安装和配置它的信息。 + +### OrangeScrum + +![](https://opensource.com/sites/default/files/u128651/orangescrum_kanban.png) + + +正如从其名称中猜到的,[OrangeScrum][22]支持敏捷方法,特别是使用Scrum任务板和看板式工作流视图。它面向较小的组织自由职业者、中介机构和中小型企业。 + +源版本提供了 OrangeScrum 付费版本中的许多[特性][23],包括移动应用程序、资源利用率和进度跟踪。其他特性,包括甘特图、时间日志、发票和客户端管理,可以作为付费附加组件提供,付费版本包括云选项,而社区版本不提供。 + +OrangeScrum 是基于 GPLv3 授权的,是基于 CakePHP 框架开发。它需要 Apache、PHP 5.3 或更高版本和 MySQL 4.1 或更高版本支持,并可以在 Windows、Linux 和 Mac OS 上运行。其最新版本1.1.1,下载地址 [download][24],其源码[GitHub] [25]。 + + +### ]project-open[ + +![](https://opensource.com/sites/default/files/u128651/projectopen_dashboard.png) + + +[]project-open[][26]是一个双许可的企业项目管理工具,这意味着其核心是开源的,并且在商业许可的模块中可以使用一些附加特性。根据社区和企业版本的项目[比较][27],开源核心为中小型组织提供了许多特性。 + +]project-open[ 支持Scrum和看板[敏捷][28]项目,以及经典的甘特/瀑布项目和混合或混合项目。 + + +该应用程序是在 GPL 下授权的,并且[source code][29]是通过 CVS 访问的。 ]project-open[ 在 Linux 和 Windows 的安装可用 [installers][26],但也可以在云镜像和虚拟设备中使用。 + +### Taiga + +![](https://opensource.com/sites/default/files/u128651/taiga_screenshot.jpg) + + +[Taiga][30] 是一个开源项目管理平台,它专注于Scrum和敏捷开发,其特征包括看板、任务、sprints、问题、backlog 和epics。其他功能包括 ticke 管理、多项目支持、Wiki页面和第三方集成。 + +它还为iOS、Android和Windows设备提供免费的移动应用程序,并提供导入工具,使从其他流行的项目管理应用程序迁移变得容易。 + + +Taiga 对于公共项目是免费的,对项目数量或用户数量没有限制。对于私有项目,在“免费增值”模式下,有很多[付费计划][31]可用,但是值得注意的是,无论您有哪种类型,软件的功能特性都是一样的。 + + +Taiga 是在GNU Affero GPLv3 下授权的,并且软件需要 Nginx、Python 和 PostgreSQL 支持。最新版本[3.1.0 PrimovsialpopiculoLII][32],可在[GitHub][33]上下载。 + +### Tuleap + +![](https://opensource.com/sites/default/files/u128651/tuleap-scrum-prioritized-backlog.png) + + + +[Tuleap][34]是一个应用程序生命周期管理(ALM)平台,旨在为每种类型的团队管理项目——小型、中型、大型、瀑布、敏捷或混合型——但是它对敏捷团队的支持是显著的。值得注意的是,它为Scrum、看板、sprints、任务、报告、持续集成、backlogs等提供支持. + + +其他的[特性][35]包括问题跟踪、文档跟踪、协作工具,以及与 Git、SVN 和 Jenkins 的集成,所有这些都使它成为开放源码软件开发项目的吸引人的选择。 + + +TuleAP 是在 GPLv2 下授权的。更多信息,包括 Docker 和 CentOS 下载,可以在他们的 [Get Started][36] 页面上找到。您还可以在TuleAP的 [Git][37] 上获取其最新版本9.14的源代码。 + + +这种类型的列表的麻烦在于它一发布就过时了。使用开源项目管理工具来支持我们忘记包含的敏捷吗?或者你对我们提到的有反馈吗?请在下面留下评论。 + +这种类型的文章的麻烦在于它一发布就过时了。那些您正在使用开源项目管理工具,而被我们遗漏了?或者您对我们提到的有反馈意见吗?请在下面留下留言。 + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/2/agile-project-management-tools + +作者:[Opensource.com][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 +[1]:http://agilemanifesto.org/principles.html +[2]:https://opensource.com/resources/scrum +[3]:https://www.pmi.org/-/media/pmi/documents/public/pdf/learning/thought-leadership/pulse/pulse-of-the-profession-2017.pdf +[4]:https://www.pwc.com/gx/en/actuarial-insurance-services/assets/agile-project-delivery-confidence.pdf +[5]:https://opensource.com/business/14/1/top-project-management-tools-2014 +[6]:https://opensource.com/business/15/1/top-project-management-tools-2015 +[7]:https://opensource.com/business/16/3/top-project-management-tools-2016 +[8]:https://community.mycollab.com/ +[9]:https://github.com/MyCollab/mycollab +[10]:https://www.mycollab.com/ce-registration/ +[11]:https://www.odoo.com/ +[12]:https://www.odoo.com/page/editions +[13]:https://www.odoo.com/page/community +[14]:https://www.odoo.com/documentation/user/11.0/ +[15]:https://www.odoo.com/page/download +[16]:https://hub.docker.com/_/odoo/ +[17]:https://github.com/odoo/odoo +[18]:https://www.openproject.org/ +[19]:https://github.com/opf/openproject +[20]:https://www.openproject.org/download-and-installation/ +[21]:https://opensource.com/article/17/11/how-install-and-use-openproject +[22]:https://www.orangescrum.org/ +[23]:https://www.orangescrum.org/compare-orangescrum +[24]:http://www.orangescrum.org/free-download +[25]:https://github.com/Orangescrum/orangescrum/ +[26]:http://www.project-open.com/en/list-installers +[27]:http://www.project-open.com/en/products/editions.html +[28]:http://www.project-open.com/en/project-type-agile +[29]:http://www.project-open.com/en/developers-cvs-checkout +[30]:https://taiga.io/ +[31]:https://tree.taiga.io/support/subscription-and-plans/payment-process-faqs/#q.-what-s-about-custom-plans-private-projects-with-more-than-25-members-? +[32]:https://blog.taiga.io/taiga-perovskia-atriplicifolia-release-310.html +[33]:https://github.com/taigaio +[34]:https://www.tuleap.org/ +[35]:https://www.tuleap.org/features/project-management +[36]:https://www.tuleap.org/get-started +[37]:https://tuleap.net/plugins/git/tuleap/tuleap/stable From 85be9806765795b848554b182babb08b91cae024 Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Sun, 9 Sep 2018 15:04:08 +0800 Subject: [PATCH 133/455] heguangzhi translating --- .../20180831 6 open source tools for making your own VPN.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180831 6 open source tools for making your own VPN.md b/sources/tech/20180831 6 open source tools for making your own VPN.md index fe033bfd5c..ce8b27dcb1 100644 --- a/sources/tech/20180831 6 open source tools for making your own VPN.md +++ b/sources/tech/20180831 6 open source tools for making your own VPN.md @@ -1,3 +1,5 @@ +heguangzhi Translating + 6 open source tools for making your own VPN ====== From 3f332e2221dc38c253c7db5d7fb68fbe9a5cdca5 Mon Sep 17 00:00:00 2001 From: feng lv Date: Sun, 9 Sep 2018 15:10:29 +0800 Subject: [PATCH 134/455] translated --- ...x command-line screen grabs made simple.md | 72 ------------------- ...x command-line screen grabs made simple.md | 66 +++++++++++++++++ 2 files changed, 66 insertions(+), 72 deletions(-) delete mode 100644 sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md create mode 100644 translated/tech/20171202 Scrot Linux command-line screen grabs made simple.md diff --git a/sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md b/sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md deleted file mode 100644 index f198f1dd65..0000000000 --- a/sources/tech/20171202 Scrot Linux command-line screen grabs made simple.md +++ /dev/null @@ -1,72 +0,0 @@ -ucasFL translating - -# 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] -译者:[译者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/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/translated/tech/20171202 Scrot Linux command-line screen grabs made simple.md b/translated/tech/20171202 Scrot Linux command-line screen grabs made simple.md new file mode 100644 index 0000000000..c771ab0fba --- /dev/null +++ b/translated/tech/20171202 Scrot Linux command-line screen grabs made simple.md @@ -0,0 +1,66 @@ +# Scrot:让你在命令行中进行截屏更加简单 +> Scrot 是一个简单、灵活,并且提供了许多选项的 Linux 命令行截屏工具。 + +[![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] + + +Linux 桌面上有许多用于截屏的优秀工具,比如 [Ksnapshot][1] 和 [Shutter][2] 。甚至 GNOME 桌面自带的简易截屏工具也能够很好的工作。但是,如果你很少截屏,或者你使用的 Linux 发行版没有内建截屏工具,或者你使用的是一台资源有限的老电脑,那么你该怎么办呢? + +或许你可以转向命令行,使用一个叫做 [Scrot][4] 的实用工具。它能够完成简单的截屏工作,同时它所具有的一些特性也许会让你感到非常惊喜。 + +### 走近 Scrot +许多 Linux 发行版都会预先安装上 Scrot ,可以输入 `which scrot` 命令来查看系统中是否安装有 Scrot 。如果没有,那么可以使用你的 Linux 发行版的包管理器来安装。如果你想从源代码编译安装,那么也可以从 [GitHub][5] 上下载源代码。 + +如果要进行截屏,首先打开一个终端窗口,然后输入 `scrot [filename]` ,`[filename]` 是你想要保存的图片文件的名字(比如 `desktop.png`)。如果缺省了该参数,那么 scrot 会自动创建一个名字,比如 `2017-09-24-185009_1687x938_scrot.png` 。(这个名字缺乏了对图片内容的描述,这就是为什么最好在命令中指定一个名字作为参数。) + +如果不带任何参数运行 Scrot,那么它将会对整个桌面进行截屏。如果不想这样,那么你也可以对屏幕中的一个小区域进行截图。 + +### 对单一窗口进行截屏 + +可以通过输入 `scrot -u [filename]` 命令来对一个窗口进行截屏。 + +`-u` 选项告诉 Scrot 对当前窗口进行截屏,这通常是我们正在工作的终端窗口,也许不是你想要的。 + +如果要对桌面上的另一个窗口进行截屏,需要输入 `scrot -s [filename]` 。 + +`-s` 选项可以让你做下面两件事的其中一件: + +* 选择一个打开着的窗口 + +* 在一个窗口的周围或一片区域画一个矩形进行捕获 + +你也可以设置一个时延,这样让你能够有时间来选择你想要捕获的窗口。可以通过 `scrot -u -d [num] [filename]` 来设置时延。 + +`-d` 选项告诉 Scrot 在捕获窗口前先等待一段时间,`[num]` 是需要等待的秒数。指定为 `-d 5` (等待 5 秒)应该能够让你有足够的时间来选择窗口。 + +### 更多有用的选项 + +Scrot 还提供了许多额外的特性(绝大多数我从来没有使用过)。下面是我发现的一些有用的选项: + +* `-b` 捕获窗口的边界 + +* `-t` 捕获窗口并创建一个缩略图。当你需要把截图张贴到网上的时候,这会非常有用 + +* `-c` 当你同时使用了 `-d` 选项的时候,在终端中创建倒计时 + +如果你想了解 Scrot 的其他选项,可以在终端中输入 `man scrot` 来查看它的手册,或者[在线阅读][6]。然后开始使用 Scrot 进行截屏。 + +虽然 Scrot 很简单,但它的确能够工作得很好。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/17/11/taking-screen-captures-linux-command-line-scrot + +作者:[Scott Nesbitt][a] +译者:[ucasFL](https://github.com/ucasFL) +校对:[校对者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 a4105181c7079287b758226f9ad98f85ac67607b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 16:47:52 +0800 Subject: [PATCH 135/455] PRF:20180803 10 Popular Windows Apps That Are Also Available on Linux.md @geekpi --- ...s Apps That Are Also Available on Linux.md | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/translated/tech/20180803 10 Popular Windows Apps That Are Also Available on Linux.md b/translated/tech/20180803 10 Popular Windows Apps That Are Also Available on Linux.md index f6ad7b42ea..7e49ec1195 100644 --- a/translated/tech/20180803 10 Popular Windows Apps That Are Also Available on Linux.md +++ b/translated/tech/20180803 10 Popular Windows Apps That Are Also Available on Linux.md @@ -1,114 +1,116 @@ -10 个在 Linux 上也有的流行 Windows 程序 +10 个在 Linux 上也有的流行的 Windows 程序 ====== +![](https://www.fossmint.com/wp-content/uploads/2018/08/Install-Windows-Apps-on-Linux.png) + 回顾过去,2018 年是 Linux 社区的好年景。许多仅在 Windows 和/或 Mac上 有的程序可在 Linux 平台上使用了,而且不用麻烦。向 [Snap][3] 和 [Flatpak][4] 技术致敬,这些技术已经为 Linux 用户带来了许多“受限制”的程序。 -**另请阅读**:[所有很酷的 Linux 程序和工具][5] +**另请阅读**:[很酷的 Linux 程序和工具大全][5] 今天,我们为你提供了一个有名的 Windows 程序列表,你不需要寻找它们的替代品,因为它们已经在 Linux 上可用。 -### 1\. Skype +### 1、Skype + +它可以说是世界上最受欢迎的 VoIP 程序,**Skype** 提供出色的视频和语音通话质量,以及其他功能,如拨打本地和国际电话、固定电话、即时消息、表情符号等功能。 -可以说是世界上最受欢迎的 VoIP 程序,**Skype** 提供出色的视频和语音通话质量,以及其他功能,如拨打本地和国际电话、固定电话、即时消息、表情符号等功能。 ``` $ sudo snap install skype --classic - ``` -### 2\. Spotify +### 2、Spotify + +**Spotify** 是最流行的音乐流媒体平台,在很长一段时间里,Linux 用户需要使用脚本和一些手段才能在他们的机器上设置该程序,感谢 snap,安装和使用 Spotify 就像点击一个按钮那样简单。 -**Spotify** 是最流行的音乐流媒体平台,在很长一段时间里,Linux 用户需要使用脚本和黑客技巧在他们的机器上设置程序,感谢 snap,安装和使用 Spotify 就像点击一个按钮那样简单。 ``` $ sudo snap install spotify - ``` -### 3\. Minecraft +### 3、Minecraft + +**Minecraft** 被证明是一款年度好游戏。更酷的是,它持续地得到维护。如果你不了解 Minecraft,它是一款冒险游戏,它可以让你在一个无限无边的虚拟世界中使用积木创建任何你想创建的虚拟事物。 -**Minecraft** 被证明是一款年度好游戏。更酷的是,它持续地得到维护。如果你不了解 Mincraft,它是一款冒险游戏,它可以让你在一个无限无边的虚拟世界中使用积木创建任何你想创建的虚拟事物。 ``` $ sudo snap install minecraft - ``` -### 4\. JetBrains Dev Suite +### 4、JetBrains Dev Suite -**JetBrains** 以其高级开发 IDE 套件而闻名,其最受欢迎的程序声称可在 Linux 上使用而不会有任何麻烦。 +**JetBrains** 以其高级的开发 IDE 套件而闻名,他们这个最受欢迎的程序声称可在 Linux 上使用而不会有任何麻烦。 #### 安装 IDEA Community – Java IDE + ``` $ sudo snap install intellij-idea-community --classic - ``` #### 安装 PyCharm EDU – Python IDE + ``` $ sudo snap install pycharm-educational --classic - ``` #### 安装 PhpStorm – PHP IDE + ``` $ sudo snap install phpstorm --classic - ``` #### 安装 WebStorm – JavaScript IDE + ``` $ sudo snap install webstorm --classic - ``` #### 安装 RubyMine – Ruby and Rails IDE + ``` $ sudo snap install rubymine --classic - ``` -### 5\. PowerShell +### 5、PowerShell **PowerShell** 是一个用于管理 PC 自动化和配置的平台,它提供了一个带有相关脚本语言的命令行 shell。如果你认为它仅在 Windows 上可用,那么请再想一想。 + ``` $ sudo snap install powershell --classic - ``` -### 6\. Ghost +### 6、Ghost **Ghost** 是一款现代桌面程序,可让用户在无干扰的环境中管理多个 Ghost 博客、杂志、在线出版物等。 + ``` $ sudo snap install ghost-desktop - ``` -### 7\. MySQL Workbench +### 7、MySQL Workbench **MySQL Workbench** 是一个 GUI 程序,用于设计和管理集成 SQL 功能的数据库。 -[**下载 MySQL Workbench**][6] +- [**下载 MySQL Workbench**][6] -### 8\. PlayOnLinux 中的 Adobe App Suite +### 8、PlayOnLinux 中的 Adobe App Suite 你可能错过了我们在 [PlayOnLinux][7] 上发表的文章,所以这是另一个了解的机会。 -PlayOnLinux 基本上是 **wine** 的改进实现,允许用户更轻松地安装 Adobe 的创意云程序。请注意,试用和订阅限制仍然适用。 +PlayOnLinux 基本上是 **wine** 的改进版本,允许用户更轻松地安装 Adobe 的创意云程序。请注意,试用和订阅限制仍然适用。 -[**如何使用 PlayOnLinux**][8] +- [**如何使用 PlayOnLinux**][8] -### 9\. Slack +### 9、Slack 这据说是开发人员和项目经理之间最常用的团队沟通软件,**Slack** 提供了每个人似乎无法满足的有各种文档和消息管理功能的工作空间。 + ``` $ sudo snap install slack --classic - ``` -### 10\. Blender +### 10、Blender **Blender** 是最受欢迎的 3D 创作程序之一。它是免费的、开源的,并且支持完整 3D 管道。 + ``` $ sudo snap install blender --classic - ``` 就是这些了!我们知道列表还有很多,但我们只能列出这么多。我们是否省略了你认为应该将其列入清单的任何程序?在下面的评论栏添加你的建议。 @@ -117,10 +119,10 @@ $ sudo snap install blender --classic via: https://www.fossmint.com/install-popular-windows-apps-on-linux/ -作者:[Martins D. Okoi;View All Posts][a] +作者:[Martins D. Okoi][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 9fb204a9ef31ff4ab54cfb838a41059600dc5d86 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 16:48:15 +0800 Subject: [PATCH 136/455] PUB:20180803 10 Popular Windows Apps That Are Also Available on Linux.md @geekpi https://linux.cn/article-9995-1.html --- ...03 10 Popular Windows Apps That Are Also Available on Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180803 10 Popular Windows Apps That Are Also Available on Linux.md (100%) diff --git a/translated/tech/20180803 10 Popular Windows Apps That Are Also Available on Linux.md b/published/20180803 10 Popular Windows Apps That Are Also Available on Linux.md similarity index 100% rename from translated/tech/20180803 10 Popular Windows Apps That Are Also Available on Linux.md rename to published/20180803 10 Popular Windows Apps That Are Also Available on Linux.md From e64b6d5da3e2c3bb26d698df8d556528d24cab83 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 18:24:02 +0800 Subject: [PATCH 137/455] PRF:20180808 5 open source role-playing games for Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @hopefully2333 翻译的不错。 --- ...pen source role-playing games for Linux.md | 92 ++++++++++++++----- 1 file changed, 67 insertions(+), 25 deletions(-) diff --git a/translated/tech/20180808 5 open source role-playing games for Linux.md b/translated/tech/20180808 5 open source role-playing games for Linux.md index 50a091ce14..4399c9ceb9 100644 --- a/translated/tech/20180808 5 open source role-playing games for Linux.md +++ b/translated/tech/20180808 5 open source role-playing games for Linux.md @@ -2,75 +2,117 @@ 五个 Linux 上的开源角色扮演游戏 ====== +> 换一个新的身份,并用这些开源的角色扮演游戏探索新世界。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/dice_tabletop_board_gaming_game.jpg?itok=y93eW7HN) -游戏是 Linux 的传统弱点之一,感谢 Stean、GOG 和其他的游戏开发商将商业游戏移植到了多个操作系统,Linux 的这个弱点在近几年有所改观,但是这些游戏通常都不是开源的。当然,这些游戏可以在开源系统上运行,但是对于开源的纯粹主义者来说这还不够好。 +游戏是 Linux 的传统弱项之一,感谢 Steam、GOG 和其他的游戏开发商将商业游戏移植到了多个操作系统,Linux 的这个弱项在近几年有所改观,但是这些游戏通常都不是开源的。当然,这些游戏可以在开源系统上运行,但是对于开源的纯粹主义者来说这还不够好。 -那么,有没有一款能让只使用免费和开源软件的人在不影响他们开源理念的情况下也能享受到可靠游戏体验的精致游戏呢? +那么,有没有一款能让只使用自由开源软件的人在不影响他们开源理念的情况下也能享受到可靠游戏体验的精致游戏呢? -当然有啦!虽然开源游戏不太可能和拥有大量开发预算的 3A 级大作相媲美,但有许多类型的开源游戏也很有趣,而且他们可以直接从大多数主要的 Linux 发行版的仓库中进行安装。即使某个游戏没有被某些仓库打包,你也可以很简单地从这个游戏的官网下载它,并进行安装和运行。 +当然有啦!虽然开源游戏不太可能和拥有大量开发预算的 3A 级大作相媲美,但有许多类型的开源游戏也很有趣,而且它们可以直接从大多数主要的 Linux 发行版的仓库中进行安装。即使某个游戏没有被某些仓库打包,你也可以很简单地从这个游戏的官网下载它,并进行安装和运行。 -这篇文章着眼于角色扮演游戏,我已经写过关于街机游戏,棋牌游戏,益智游戏,以及赛车和飞行游戏。在本系列的最后一篇文章中,我打算覆盖战略游戏和模拟游戏这两方面。 +这篇文章着眼于角色扮演游戏,我已经写过关于[街机游戏][1]、[棋牌游戏][2]、[益智游戏][3],以及[赛车和飞行游戏][4]。在本系列的最后一篇文章中,我打算覆盖战略游戏和模拟游戏这两方面。 ### Endless Sky ![](https://opensource.com/sites/default/files/uploads/endless_sky.png) -Endless Sky 是 Ambrosia Software 的 Escape Velocity 系列的开源克隆。玩家乘坐一艘宇宙飞船,在不同的世界之间旅行来运送货物和乘客,并在沿途中承接其他任务,或者玩家也可以变成海盗,并从其他货船中偷取货物。这个游戏让玩家自己决定要如何去体验这个游戏,以太阳系为背景的超大地图是非常具有探索性的。Endless Sky 是那些违背正常游戏类别分类的游戏之一。但这个兼具动作、角色扮演、太空模拟和交易这四种类型的游戏非常值得一试。 +[Endless Sky][5] 是 Ambrosia Software 的 [Escape Velocity][6] 系列的开源克隆品。玩家乘坐一艘宇宙飞船,在不同的世界之间旅行来运送货物和乘客,并在沿途中承接其他任务,或者玩家也可以变成海盗,并从其他货船中偷取货物。这个游戏让玩家自己决定要如何去体验这个游戏,以太阳系为背景的超大地图是非常具有探索性的。Endless Sky 是那些违背正常游戏类别分类的游戏之一。但这个兼具动作、角色扮演、太空模拟和交易这四种类型的游戏非常值得一试。 -如果要安装 Endless Sky ,请运行下面的命令: +如果要安装 Endless Sky ,请运行下面的命令。 -在 Fedora 上: `dnf install endless-sky` +在 Fedora 上: -在 Debian/Ubuntu 上: `apt install endless-sky` +``` +dnf install endless-sky +``` + +在 Debian/Ubuntu 上: + +``` +apt install endless-sky +``` ### FreeDink ![](https://opensource.com/sites/default/files/uploads/freedink.png) -FreeDink 是 Dink Smallwood 的开源版本,Dink Smallwood 是一个由 RTSoft 在1997 年发售的动作角色扮演游戏。Dink Smallwood 在 1999 年时变为了免费游戏,并在 2003 年时公布了源代码。在 2008 年时,游戏的数据除了少部分的声音文件,都在开源协议下进行了开源。FreeDink 用一些替代的声音文件替换了缺少的那部分文件,来提供了一个完整的游戏。游戏的玩法类似于任天堂的塞尔达传说系列。玩家控制的角色和 Dink Smallwood 同名,他在从一个任务地点移动到下一个任务地点的时候,探索这个充满隐藏物品和隐藏洞穴的世界地图。由于这个游戏的年龄,FreeDink 不能和现代的商业游戏相抗衡,但它仍然是一个拥有着有趣故事的有趣的游戏。游戏可以通过 D-Mods 进行扩展,D-Mods 是提供额外任务的附加模块,但是 D-Mods 在复杂性,质量,和年龄适应性上确实有很大的差异。游戏主要适合青少年,但也有部分额外组件适用于成年玩家。 +[FreeDink][7] 是 [Dink Smallwood][8] 的开源版本,Dink Smallwood 是一个由 RTSoft 在 1997 年发售的动作角色扮演游戏。Dink Smallwood 在 1999 年时变为了免费游戏,并在 2003 年时公布了源代码。在 2008 年时,游戏的数据除了少部分的声音文件,都在开源协议下进行了开源。FreeDink 用一些替代的声音文件替换了缺少的那部分文件,来提供了一个完整的游戏。游戏的玩法类似于任天堂的[塞尔达传说][9]系列。玩家控制的角色和 Dink Smallwood 同名,他在从一个任务地点移动到下一个任务地点的时候,探索这个充满隐藏物品和隐藏洞穴的世界地图。由于这个游戏的年龄,FreeDink 不能和现代的商业游戏相抗衡,但它仍然是一个拥有着有趣故事的有趣的游戏。游戏可以通过 [D-Mods][10] 进行扩展,D-Mods 是提供额外任务的附加模块,但是 D-Mods 在复杂性、质量,和年龄适应性上确实有很大的差异。游戏主要适合青少年,但也有部分额外组件适用于成年玩家。 -要安装 FreeDink ,请运行下面的命令: +要安装 FreeDink ,请运行下面的命令。 -在 Fedora 上: `dnf install freedink` +在 Fedora 上: -在 Debian/Ubuntu 上: `apt install freedink` +``` +dnf install freedink +``` + +在 Debian/Ubuntu 上: + +``` +apt install freedink +``` ### ManaPlus ![](https://opensource.com/sites/default/files/uploads/manaplus.png) -从技术上讲,ManaPlus 本身并不是一个游戏,它是一个访问各种大型多人在线角色扮演游戏的客户端。The Mana World 和 Evol Online 是两款可以通过 ManaPlus 访问的开源游戏,但是游戏的服务器不在那里。这个游戏的 2D 精灵图像让人想起超级任天堂游戏,虽然 ManaPlus 支持的游戏没有一款能像商业游戏那样受欢迎的,但他们都有一个有趣的世界,并且在绝大部分时间里都有至少一小部分玩家在线。一个玩家不太可能遇到很多的其他玩家,但通常都能有足够的人一起在这个 MMORPG 游戏里进行冒险,而不是一个需要连接到服务器的单机游戏。Mana World 和 Evol Online 的开发者联合起来进行未来的开发,但是对于目前而言,Mana World 的历史服务器和 Evol Online 提供了不同的游戏体验。 +从技术上讲,[ManaPlus][11] 本身并不是一个游戏,它是一个访问各种大型多人在线角色扮演游戏的客户端。[The Mana World][12] 和 [Evol Online][13] 是两款可以通过 ManaPlus 访问的开源游戏,但是游戏的服务器不在那里。这个游戏的 2D 精灵图像让人想起超级任天堂游戏,虽然 ManaPlus 支持的游戏没有一款能像商业游戏那样受欢迎的,但它们都有一个有趣的世界,并且在绝大部分时间里都有至少一小部分玩家在线。一个玩家不太可能遇到很多的其他玩家,但通常都能有足够的人一起在这个 [MMORPG][14] 游戏里进行冒险,而不是一个需要连接到服务器的单机游戏。Mana World 和 Evol Online 的开发者联合起来进行未来的开发,但是对于目前而言,Mana World 的历史服务器和 Evol Online 提供了不同的游戏体验。 -要安装 ManaPlus,请运行下面的命令: +要安装 ManaPlus,请运行下面的命令。 -在 Fedora 上: `dnf install manaplus` +在 Fedora 上: -在 Debian/Ubuntu 上: `apt install manaplus` +``` +dnf install manaplus +``` + +在 Debian/Ubuntu 上: + +``` +apt install manaplus +``` ### Minetest ![](https://opensource.com/sites/default/files/uploads/minetest.png) -使用 Minetest 来在一个开放式世界里进行探索和创造,Minetest 是 Minecraft 的克隆,就像它所基于的游戏一样,Minetest 提供了一个开放的世界,玩家可以在这个世界里探索和创造他们想要的一切。Minetest 提供了各种各样的方块和工具,对于想要一个比 Minecraft 更加开放的游戏的人来说,Minetest 是一个很好的替代品。除了基本的游戏之外,Minetest 还可以通过额外的模块进行可扩展,增加更多的选项。 +使用 [Minetest][15] 来在一个开放式世界里进行探索和创造,Minetest 是 Minecraft 的克隆品。就像它所基于的 Minecraft 一样,Minetest 提供了一个开放的世界,玩家可以在这个世界里探索和创造他们想要的一切。Minetest 提供了各种各样的方块和工具,对于想要一个比 Minecraft 更加开放的游戏的人来说,Minetest 是一个很好的替代品。除了基本的游戏之外,Minetest 还可以通过[额外的模块][16]进行可扩展,增加更多的选项。 -如果要安装 Minetest ,请运行下面的命令: +如果要安装 Minetest ,请运行下面的命令。 -在 Fedora 上: `dnf install minetest` +在 Fedora 上: -在 Debian/Ubuntu 上: `apt install minetest` +``` +dnf install minetest +``` + +在 Debian/Ubuntu 上: + +``` +apt install minetest +``` ### NetHack ![](https://opensource.com/sites/default/files/uploads/nethack.png) -NetHack 是一款经典的 Roguelike 类型的角色扮演游戏,玩家可以从不同的角色种族、层次和路线中进行选择,来探索这个多层次的地下层。这个游戏的目的就是找回 Yendor 的护身符,玩家从地下层的第一层开始探索,并尝试向下一层移动,每一层都是随机生成的,这样每次都能获得不同的游戏体验。虽然这个游戏只具有 ASCII 图形和基本图形,但是游戏玩法的深度能够弥补画面的不足。玩家如果想要更好一些的画面的话,可能就需要去查看 NetHack 中的 Vulture 了,这个选项可以提供更好的图像、声音和背景音乐。 +[NetHack][17] 是一款经典的 [Roguelike][18] 类型的角色扮演游戏,玩家可以从不同的角色种族、分类和阵营中进行选择,来探索这个多层次的地下城。这个游戏的目的就是找回 Yendor 的护身符,玩家从地下层的第一层开始探索,并尝试向下一层移动,每一层都是随机生成的,这样每次都能获得不同的游戏体验。虽然这个游戏只具有 ASCII 图形和基本图形,但是游戏玩法的深度能够弥补画面的不足。玩家如果想要更好一些的画面的话,可能就需要去查看 [NetHack 的 Vulture][19] 了,这个方式可以提供更好的图像、声音和背景音乐。 -如果要安装 NetHack ,请运行下面的命令: +如果要安装 NetHack ,请运行下面的命令。 -在 Fedora 上: `dnf install nethack` +在 Fedora 上: -在 Debian/Ubuntu 上: `apt install nethack-x11 or apt install nethack-console` +``` +dnf install nethack +``` + +在 Debian/Ubuntu 上: + +``` +apt install nethack-x11 or apt install nethack-console +``` 我有错过了你最喜欢的角色扮演游戏吗?请在下面的评论区分享出来。 @@ -81,7 +123,7 @@ via: https://opensource.com/article/18/8/role-playing-games-linux 作者:[Joshua Allen Holm][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[hopefully2333](https://github.com/hopefully2333) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From fc8ab1415beec7fc86172c54a2d00b8e80d842a0 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 18:24:34 +0800 Subject: [PATCH 138/455] PUB:20180808 5 open source role-playing games for Linux.md @hopefully2333 https://linux.cn/article-9996-1.html --- .../20180808 5 open source role-playing games for Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180808 5 open source role-playing games for Linux.md (100%) diff --git a/translated/tech/20180808 5 open source role-playing games for Linux.md b/published/20180808 5 open source role-playing games for Linux.md similarity index 100% rename from translated/tech/20180808 5 open source role-playing games for Linux.md rename to published/20180808 5 open source role-playing games for Linux.md From 8bc5badda516361f80df852b650185e914943169 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 18:34:41 +0800 Subject: [PATCH 139/455] PRF:20171202 Scrot Linux command-line screen grabs made simple.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @ucasFL 翻译的干净利落,不错。 --- ...crot Linux command-line screen grabs made simple.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/translated/tech/20171202 Scrot Linux command-line screen grabs made simple.md b/translated/tech/20171202 Scrot Linux command-line screen grabs made simple.md index c771ab0fba..3b5d483f85 100644 --- a/translated/tech/20171202 Scrot Linux command-line screen grabs made simple.md +++ b/translated/tech/20171202 Scrot Linux command-line screen grabs made simple.md @@ -1,4 +1,6 @@ -# Scrot:让你在命令行中进行截屏更加简单 +Scrot:让你在命令行中进行截屏更加简单 +====== + > Scrot 是一个简单、灵活,并且提供了许多选项的 Linux 命令行截屏工具。 [![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] @@ -9,6 +11,7 @@ Linux 桌面上有许多用于截屏的优秀工具,比如 [Ksnapshot][1] 和 或许你可以转向命令行,使用一个叫做 [Scrot][4] 的实用工具。它能够完成简单的截屏工作,同时它所具有的一些特性也许会让你感到非常惊喜。 ### 走近 Scrot + 许多 Linux 发行版都会预先安装上 Scrot ,可以输入 `which scrot` 命令来查看系统中是否安装有 Scrot 。如果没有,那么可以使用你的 Linux 发行版的包管理器来安装。如果你想从源代码编译安装,那么也可以从 [GitHub][5] 上下载源代码。 如果要进行截屏,首先打开一个终端窗口,然后输入 `scrot [filename]` ,`[filename]` 是你想要保存的图片文件的名字(比如 `desktop.png`)。如果缺省了该参数,那么 scrot 会自动创建一个名字,比如 `2017-09-24-185009_1687x938_scrot.png` 。(这个名字缺乏了对图片内容的描述,这就是为什么最好在命令中指定一个名字作为参数。) @@ -26,7 +29,6 @@ Linux 桌面上有许多用于截屏的优秀工具,比如 [Ksnapshot][1] 和 `-s` 选项可以让你做下面两件事的其中一件: * 选择一个打开着的窗口 - * 在一个窗口的周围或一片区域画一个矩形进行捕获 你也可以设置一个时延,这样让你能够有时间来选择你想要捕获的窗口。可以通过 `scrot -u -d [num] [filename]` 来设置时延。 @@ -38,9 +40,7 @@ Linux 桌面上有许多用于截屏的优秀工具,比如 [Ksnapshot][1] 和 Scrot 还提供了许多额外的特性(绝大多数我从来没有使用过)。下面是我发现的一些有用的选项: * `-b` 捕获窗口的边界 - * `-t` 捕获窗口并创建一个缩略图。当你需要把截图张贴到网上的时候,这会非常有用 - * `-c` 当你同时使用了 `-d` 选项的时候,在终端中创建倒计时 如果你想了解 Scrot 的其他选项,可以在终端中输入 `man scrot` 来查看它的手册,或者[在线阅读][6]。然后开始使用 Scrot 进行截屏。 @@ -53,7 +53,7 @@ via: https://opensource.com/article/17/11/taking-screen-captures-linux-command-l 作者:[Scott Nesbitt][a] 译者:[ucasFL](https://github.com/ucasFL) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From b9675df7bc271b235aa1395e725943e2be51c61a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 18:35:20 +0800 Subject: [PATCH 140/455] PUB:20171202 Scrot Linux command-line screen grabs made simple.md @ucasFL https://linux.cn/article-9997-1.html --- .../20171202 Scrot Linux command-line screen grabs made simple.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171202 Scrot Linux command-line screen grabs made simple.md (100%) diff --git a/translated/tech/20171202 Scrot Linux command-line screen grabs made simple.md b/published/20171202 Scrot Linux command-line screen grabs made simple.md similarity index 100% rename from translated/tech/20171202 Scrot Linux command-line screen grabs made simple.md rename to published/20171202 Scrot Linux command-line screen grabs made simple.md From ba84035350bec7cbc38f3b70e9a10e7aa311eaf4 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 18:51:04 +0800 Subject: [PATCH 141/455] PRF:20180717 Getting started with Etcher.io.md @geekpi --- ...20180717 Getting started with Etcher.io.md | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/translated/tech/20180717 Getting started with Etcher.io.md b/translated/tech/20180717 Getting started with Etcher.io.md index a42f270a00..4cfc89741a 100644 --- a/translated/tech/20180717 Getting started with Etcher.io.md +++ b/translated/tech/20180717 Getting started with Etcher.io.md @@ -1,60 +1,56 @@ Etcher.io 入门 ====== +> 用这个易用的媒体创建工具来创建一个可引导的 USB 盘或 SD 卡。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/community-penguins-osdc-lead.png?itok=BmqsAF4A) -可启动 USB 盘是尝试新的 Linux 发行版的很好的方式,以便在安装之前查看你是否喜欢它。虽然一些 Linux 发行版(如 [Fedora][1])可以轻松创建可启动媒体,但大多数其他发行版提供 ISO 或镜像文件,并将创建媒体决定留给用户。用户总是可以选择使用 `dd` 在命令行上创建媒体 - 但让我们面对它,即使对于最有经验的用户来说,这仍然很痛苦。还有其他程序,如 Mac 上的 UnetBootIn、Disk Utility 和 Windows 上的 Win32DiskImager,它们都可以创建可启动的 USB。 +可启动 USB 盘是尝试新的 Linux 发行版的很好的方式,以便在安装之前查看你是否喜欢它。虽然一些 Linux 发行版(如 [Fedora][1])可以轻松创建可启动媒体,但大多数其他发行版提供 ISO 或镜像文件,并将创建媒体决定留给用户。用户总是可以选择使用 `dd` 在命令行上创建媒体——但让我们面对现实,即使对于最有经验的用户来说,这仍然很痛苦。也有一些其它程序,如 Mac 上的 UnetBootIn、Disk Utility 和 Windows 上的 Win32DiskImager,它们都可以创建可启动的 USB。 ### 安装 Etcher -大约 18 个月前,我遇到了 [Etcher.io][2],这是一个很棒的开源项目,可以在 Linux、Windows 或 MacOS 上轻松,简单地创建媒体。Etcher.io 已成为我为 Linux 创建可启动媒体的“首选”程序。我可以轻松下载 ISO 或 IMG 文件并将其刻录到闪存和 SD 卡。这是一个 [Apache 2.0][3] 许可证下的开源项目,[源代码][4] 可在 GitHub 上获得。 +大约 18 个月前,我遇到了 [Etcher.io][2],这是一个很棒的开源项目,可以在 Linux、Windows 或 MacOS 上轻松、简单地创建媒体。Etcher.io 已成为我为 Linux 创建可启动媒体的“首选”程序。我可以轻松下载 ISO 或 IMG 文件并将其刻录到闪存和 SD 卡。这是一个 [Apache 2.0][3] 许可证下的开源项目,[源代码][4] 可在 GitHub 上获得。 -进入 [Etcher.io][5] 网站,然后单击适用于你的操作系统-32 位或 64 位 Linux,32 位或 64 位 Windows 或 MacOS 的下载链接。 +进入 [Etcher.io][5] 网站,然后单击适用于你的操作系统:32 位或 64 位 Linux、32 位或 64 位 Windows 或 MacOS 的下载链接。 ![](https://opensource.com/sites/default/files/uploads/etcher_1.png) -Etcher 在 GitHub 仓库中提供了很好的指导,用于将 Etcher 添加到你的 Linux 实用程序集合中。 +Etcher 在 GitHub 仓库中提供了很好的指导,可以将 Etcher 添加到你的 Linux 实用程序集合中。 如果你使用的是 Debian 或 Ubuntu,请添加 Etcher Debian 仓库: + +``` +$echo "deb https://dl.bintray.com/resin-io/debian stable etcher" | sudo tee /etc/apt/sources.list.d/etcher.list ``` -$echo "deb https://dl.bintray.com/resin-io/debian stable etcher" | sudo tee - -/etc/apt/sources.list.d/etcher.list - - 信任 Bintray.com GPG 密钥 +``` $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 379CE192D401AB61 - ``` 然后更新你的系统并安装: + ``` $ sudo apt-get update - $ sudo apt-get install etcher-electron - ``` 如果你使用的是 Fedora 或 Red Hat Enterprise Linux,请添加 Etcher RPM 仓库: + ``` -$ sudo wget https://bintray.com/resin-io/redhat/rpm -O /etc/yum.repos.d/bintray- - -resin-io-redhat.repo - +$ sudo wget https://bintray.com/resin-io/redhat/rpm -O /etc/yum.repos.d/bintray-resin-io-redhat.repo ``` 使用以下任一方式更新和安装: + ``` $ sudo yum install -y etcher-electron - ``` 或者: + ``` $ sudo dnf install -y etcher-electron - ``` ### 创建可启动盘 @@ -65,13 +61,13 @@ $ sudo dnf install -y etcher-electron ![](https://opensource.com/sites/default/files/uploads/etcher_2.png) -单击 **Select Image**。在本例中,我想创建一个可启动的 USB 盘,以便在新计算机上安装 Ubermix。在我选择了我的 Ubermix 镜像文件并将我的 USB 盘插入计算机,Etcher.io “看到”了驱动器,我就可以开始在 USB 上安装 Ubermix 了。 +单击 “Select Image”。在本例中,我想创建一个可启动的 USB 盘,以便在新计算机上安装 Ubermix。在我选择了我的 Ubermix 镜像文件并将我的 USB 盘插入计算机,Etcher.io “看到”了驱动器,我就可以开始在 USB 上安装 Ubermix 了。 ![](https://opensource.com/sites/default/files/uploads/etcher_3.png) -在我点击 **Flash** 后,安装就开始了。所需时间取决于镜像的大小。在驱动器上安装镜像后,软件会验证安装。最后,一条提示宣布我的媒体创建已经完成。 +在我点击 “Flash” 后,安装就开始了。所需时间取决于镜像的大小。在驱动器上安装镜像后,软件会验证安装。最后,一条提示宣布我的媒体创建已经完成。 -如果您需要[ Etcher 的帮助][7],请通过其 [Discourse][8] 论坛联系社区。Etcher 非常易于使用,它已经取代了我所有其他的媒体创建工具,因为它们都不像 Etcher 那样轻松地完成工作。 +如果您需要 [Etcher 的帮助][7],请通过其 [Discourse][8] 论坛联系社区。Etcher 非常易于使用,它已经取代了我所有其他的媒体创建工具,因为它们都不像 Etcher 那样轻松地完成工作。 -------------------------------------------------------------------------------- @@ -80,7 +76,7 @@ via: https://opensource.com/article/18/7/getting-started-etcherio 作者:[Don Watkins][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From c2ac69c5e43511afc05ae8611dd86b274ca7c0ef Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 18:51:35 +0800 Subject: [PATCH 142/455] PUB:20180717 Getting started with Etcher.io.md @geekpi https://linux.cn/article-9998-1.html --- .../tech => published}/20180717 Getting started with Etcher.io.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180717 Getting started with Etcher.io.md (100%) diff --git a/translated/tech/20180717 Getting started with Etcher.io.md b/published/20180717 Getting started with Etcher.io.md similarity index 100% rename from translated/tech/20180717 Getting started with Etcher.io.md rename to published/20180717 Getting started with Etcher.io.md From edfacbfeee7600a3ff9fa150ff496fcb3aac0250 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 21:25:58 +0800 Subject: [PATCH 143/455] PRF:20180402 Understanding Linux filesystems- ext4 and beyond.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @HardworkFish 翻译的非常好。 请 @pityonline 复校一遍。 --- ...ding Linux filesystems- ext4 and beyond.md | 36 +++++++------------ 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md index 58e6c8f237..130e5893bf 100644 --- a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md +++ b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md @@ -198,47 +198,37 @@ ext4 也不足以保证数据的完整性。随着日志记录的重大进展又 在我们开始之前,提醒一句:要非常小心,没有任何备用的文件系统作为主线内核的一部分而内置和直接支持! -即使一个文件系统是*安全的*,如果在内核升级期间出现问题,使用它作为根文件系统也是非常可怕的。如果你没有充分的理由通过一个 chroot 去使用介质引导,耐心地操作内核模块和 grub 配置,和 DKMS...不要在一个很重要的系统中去掉对根文件的备份。 +即使一个文件系统是*安全的*,如果在内核升级期间出现问题,使用它作为根文件系统也是非常可怕的。如果你没有充分的理由通过一个 chroot 去使用替代介质引导,耐心地操作内核模块、 grub 配置和 DKMS...不要在一个很重要的系统中去掉预留的根文件。 -可能有充分的理由使用您的发行版不直接支持的文件系统 —— 但如果您这样做,我强烈建议您在系统启动并可用后再安装它。 -(例如,您可能有一个 ext4 根文件系统,但是将大部分数据存储在 zfs 或 btrfs 池中。) +可能有充分的理由使用您的发行版不直接支持的文件系统 —— 但如果您这样做,我强烈建议您在系统启动并可用后再安装它。(例如,您可能有一个 ext4 根文件系统,但是将大部分数据存储在 zfs 或 btrfs 池中。) #### XFS -XFS 与 非 ext 文件系统在Linux下的主线一样。它是一个 64 位的日志文件系统,自 2001 年以来内置于 Linux 内核中,为大型文件系统和高度并发性提供了高性能 -(即,大量的进程都会立即写入文件系统)。 +XFS 与非 ext 文件系统在 Linux 中的主线中的地位一样。它是一个 64 位的日志文件系统,自 2001 年以来内置于 Linux 内核中,为大型文件系统和高度并发性提供了高性能(即,大量的进程都会立即写入文件系统)。 -从 RHEL 7开始,XFS 成为 Red Hat Enterprise Linux 的默认文件系统。对于家庭或小型企业用户来说,它仍然有一些缺点 —— 最值得注意的是,重新调整现有 XFS 文件系统 -是一件非常痛苦的事情,不如创建另一个并复制数据更有意义。 +从 RHEL 7 开始,XFS 成为 Red Hat Enterprise Linux 的默认文件系统。对于家庭或小型企业用户来说,它仍然有一些缺点 —— 最值得注意的是,重新调整现有 XFS 文件系统是一件非常痛苦的事情,不如创建另一个并复制数据更有意义。 -虽然 XFS 是稳定且是高性能的,但它和 ext4 之间没有足够的具体的最终用途差异来推荐它在非默认值的任何地方使用(例如,RHEL7),除非它解决了对 ext4 的特定问题,例如> 50 TiB容量的文件系统。 +虽然 XFS 是稳定且是高性能的,但它和 ext4 之间没有足够具体的最终用途差异,以值得推荐在非默认(例如,RHEL7)的任何地方使用它,除非它解决了对 ext4 的特定问题,例如 > 50 TiB 容量的文件系统。 -XFS 在任何方面都不是 ZFS,btrfs 甚至 WAFL(专有 SAN 文件系统)的“下一代”文件系统。就像 ext4 一样,它应该被视为一种更好的方式的权宜之计。 +XFS 在任何方面都不是 ZFS、btrfs 甚至 WAFL(一个专有的 SAN 文件系统)的“下一代”文件系统。就像 ext4 一样,它应该被视为一种更好的方式的权宜之计。 #### ZFS ZFS 由 Sun Microsystems 开发,以 zettabyte 命名 —— 相当于 1 万亿 GB —— 因为它理论上可以解决大型存储系统。 -作为真正的下一代文件系统,ZFS 提供卷管理(能够在单个文件系统中处理多个单独的存储设备),块级加密校验和(允许以极高的准确率检测数据损坏), -[自动损坏修复][12](其中冗余或奇偶校验存储可用),[快速异步增量复制][13],内联压缩等,[还有更多][14]。 +作为真正的下一代文件系统,ZFS 提供卷管理(能够在单个文件系统中处理多个单独的存储设备),块级加密校验和(允许以极高的准确率检测数据损坏),[自动损坏修复][12](其中冗余或奇偶校验存储可用),[快速异步增量复制][13],内联压缩等,[以及更多][14]。 -从 Linux 用户的角度来看,ZFS 的最大问题是许可证问题。ZFS 许可证是 CDDL 许可证,这是一种与 GPL 冲突的半许可许可证。关于在 Linux 内核中使用 ZFS 的意义存在很多争议, -其争议范围从“它是 GPL 违规”到“它是 CDDL 违规”到“它完全没问题,它还没有在法庭上进行过测试。 “ 最值得注意的是,自2016 年以来,Canonical 已将 ZFS 代码内联 -在其默认内核中,而且目前尚无法律挑战。 +从 Linux 用户的角度来看,ZFS 的最大问题是许可证问题。ZFS 许可证是 CDDL 许可证,这是一种与 GPL 冲突的半许可许可证。关于在 Linux 内核中使用 ZFS 的意义存在很多争议,其争议范围从“它是 GPL 违规”到“它是 CDDL 违规”到“它完全没问题,它还没有在法庭上进行过测试。 ” 最值得注意的是,自 2016 年以来 Canonical 已将 ZFS 代码内联在其默认内核中,而且目前尚无法律挑战。 -此时,即使我作为一个非常狂热于 ZFS 的用户,我也不建议将 ZFS 作为 Linux的 root 文件系统。如果你想在 Linux 上利用 ZFS 的优势,在 ext4 上设置一个小的根文件系统, -然后将 ZFS 放在你剩余的存储上,把数据,应用程序以及你喜欢的东西放在它上面 —— 但在 ext4 上保持 root,直到你的发行版明显支持 zfs 根目录。 +此时,即使我作为一个非常狂热于 ZFS 的用户,我也不建议将 ZFS 作为 Linux 的 root 文件系统。如果你想在 Linux 上利用 ZFS 的优势,用 ext4 设置一个小的根文件系统,然后将 ZFS 用在你剩余的存储上,把数据、应用程序以及你喜欢的东西放在它上面 —— 但把 root 保留在 ext4 上,直到你的发行版明显支持 zfs 根目录。 #### BTRFS -Btrfs 是 B-Tree Filesystem 的简称,通常发音为 “butter” —— 由 Chris Mason 于 2007 年在 Oracle 任职期间宣布。BTRFS 旨在跟 ZFS 有大部分相同的目标, -提供多种设备管理,每块校验、异步复制、直列压缩等,[还有更多][8]。 +Btrfs 是 B-Tree Filesystem 的简称,通常发音为 “butter” —— 由 Chris Mason 于 2007 年在 Oracle 任职期间发布。BTRFS 旨在跟 ZFS 有大部分相同的目标,提供多种设备管理、每块校验、异步复制、直列压缩等,[还有更多][8]。 -截至 2018 年,btrfs 相当稳定,可用作标准的单磁盘文件系统,但可能不应该依赖于卷管理器。与许多常见用例中的 ext4,XFS 或 ZFS 相比,它存在严重的性能问题, -其下一代功能 —— 复制(replication),多磁盘拓扑和快照管理 —— 可能非常多,其结果可能是从灾难性地性能降低到实际数据的丢失。 +截至 2018 年,btrfs 相当稳定,可用作标准的单磁盘文件系统,但可能不应该依赖于卷管理器。与许多常见用例中的 ext4、XFS 或 ZFS 相比,它存在严重的性能问题,其下一代功能 —— 复制、多磁盘拓扑和快照管理 —— 可能非常多,其结果可能是从灾难性地性能降低到实际数据的丢失。 -btrfs 的持续状态是有争议的; SUSE Enterprise Linux 在 2015 年采用它作为默认文件系统,而 Red Hat 宣布它将不再支持从 2017 年开始使用 RHEL 7.4 的 btrfs。 -可能值得注意的是,生产,支持的 btrfs 部署将其用作单磁盘文件系统,而不是作为一个多磁盘卷管理器 —— a la ZFS —— 甚至 Synology 在它的存储设备使用 BTRFS, +btrfs 的维持状态是有争议的;SUSE Enterprise Linux 在 2015 年采用它作为默认文件系统,而 Red Hat 于 2017 年宣布它从 RHEL 7.4 开始不再支持 btrfs。可能值得注意的是,该产品支持 btrfs 部署用作单磁盘文件系统,而不是像 ZFS 中的多磁盘卷管理器,甚至 Synology 在它的存储设备使用 BTRFS, 但是它在传统 Linux 内核 RAID(mdraid)之上分层来管理磁盘。 -------------------------------------------------------------------------------- @@ -247,7 +237,7 @@ via: https://opensource.com/article/18/4/ext4-filesystem 作者:[Jim Salter][a] 译者:[HardworkFish](https://github.com/HardworkFish) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From e28aa917fd07093d55ef6aa75491da539cd2ccab Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 9 Sep 2018 23:42:06 +0800 Subject: [PATCH 144/455] =?UTF-8?q?LCTT=205=20=E5=91=A8=E5=B9=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lctt2018.md | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 lctt2018.md diff --git a/lctt2018.md b/lctt2018.md new file mode 100644 index 0000000000..7e2f3cb4df --- /dev/null +++ b/lctt2018.md @@ -0,0 +1,75 @@ +LCTT 2018:五周年纪念日 +====== + +我是老王,可能大家有不少人知道我,由于历史原因,我有好几个生日(;o),但是这些年来,我又多了一个生日,或者说纪念日——每过两年,我就要严肃认真地写一篇 [LCTT](https://linux.cn/lctt) 生日纪念文章。 + +喏,这一篇,就是今年的了,LCTT 如今已经五岁了! + +或许如同小孩子过生日总是比较快乐,而随着年岁渐长,过生日往往有不少负担——比如说,每次写这篇纪念文章时,我就需要回忆、反思这两年的做了些什么,往往颇为汗颜。 + +不过不管怎么说,总要总结一下这两年我们做了什么,有什么不足,也发一些展望吧。 + +### 江山代有英豪出 + +LCTT,如同一般的开源贡献组织,总是有不断的新老传承。我们的翻译组,也有不少成员,由于工作学习的原因,慢慢淡出,但同时,也不断有新的成员加入并接过前辈手中的旗帜(就是没人接我的)。 + +> **加入方式** + +> 请首先加入翻译组的 QQ 群,群号是:**198889102**,加群时请说明是“**志愿者**”。加入后记得修改您的群名片为您的 GitHub 的 ID。 + +> 加入的成员,请先阅读 [WIKI 如何开始](https://github.com/LCTT/TranslateProject/wiki/01-%E5%A6%82%E4%BD%95%E5%BC%80%E5%A7%8B)。 + +比如说,我们这两年来,oska874 承担了主要的选题工作,然后 lujun9972 适时的出现接过了不少选题工作;再比如说,qhwdw 出现后承担了大量繁难文章的翻译,pityonline 则专注于校对,甚至其校对的严谨程度让我都甘拜下风。还有 MjSeven 也同 qhwdw 一样,以极高的翻译频率从一星译者迅速登顶五星译者。当然,还有 Bestony、Locez、VizV 等人为 LCTT 提供了不少技术支持和开发工作。 + +### 硕果累累 + +我们并没有特别的招新渠道,但是总是时不时会有新的成员慕名而来,到目前为止,我们已经有 [331](https://linux.cn/lctt-list) 位做过贡献的成员,已经翻译发布了 3885 篇译文,合计字节达 33MB 之多! + +这两年,我们不但翻译了很多技术、新闻和评论类文章,也新增了新的翻译类型:[漫画](https://linux.cn/talk/comic/),其中一些漫画得到了很多好评。 + +我们发布的文章有一些达到了 100000+ 的访问量,这对于我们这种技术垂直内容可不容易。 + +而同时,[Linux 中国](https://linux.cn/)也发布了近万篇文章,而这一篇,应该就是第 [9999](https://linux.cn/article-9999-1.html) 篇文章,我们将在明天,进入新的篇章。 + +### 贡献者主页和贡献者证书 + +为了彰显诸位贡献者的贡献,我们为每位贡献者创立的自己的专页,并据此建立了[排行榜](https://linux.cn/lctt-list)。 + +同时,我们还特意请 Bestony 和“一一”设计开发和”贡献者证书”,大家可以在 [LCTT 贡献平台](https://lctt.linux.cn/)中领取。 + +### 规则进化 + +LCTT 最初创立时,甚至都没有采用 PR 模式。但是随着贡献者的增多,我们也逐渐在改善我们的流程、方法。 + +之前采用了很粗糙的 PR 模式,对 PR 中的文件、提交乃至于信息都没有进行硬性约束。后来在 VizV 的帮助下,建立了对 PR 的合规性检查;又在 pityonline 的督促下,采用了更为严格的 PR 审查机制。 + +LCTT 创立几年来,我们的一些流程和规范,已经成为其它一些翻译组的参考范本,我们也希望我们的这些经验,可以进一步帮助到其它的开源社区。 + +### 仓库重建和版权问题 + +今年还发生一次严重的事故,由于对选题来源把控不严和对版权问题没有引起足够的重视,我们引用的一篇文章违背了原文的版权规定,结果被原文作者投诉到 GitHub。而我并没有及时看到 GitHub 给我发的 DMCA 处理邮件,因此错过了处理窗口期,从而被 GitHub 将整个库予以删除。 + +出现这样的重大失误之后,经过大家的帮助,我们历经周折才将仓库基本恢复。这要特别感谢 VizV 的辛苦工作。 + +在此之后,我们对译文选文的规则进行了梳理,并全面清查了文章版权。这个教训对我们来说弥足沉重。 + +### 通证时代 + +在 Linux 中国及 LCTT 发展过程中,我一直小心翼翼注意商业化的问题。严格来说,没有经济支持的开源组织如同无根之木,无源之水,是长久不了的。而商业化的技术社区又难免为了三斗米而折腰。所以往往很多技术社区要么渐渐凋零,要么就变成了商业机构。 + +从中国电信辞职后,我专职运营 Linux 中国这个开源社区已经近三年了,其间也有一些商业性收入,但是仅能勉强承担基本的运营费用。 + +这种尴尬的局面,使我,以及其它的开源社区同仁们纷纷寻求更好的发展之路。 + +去年参加中国开源年会时,在闭门会上,大家的讨论启发了我和诸位同仁,我们认为,开源社区结合通证经济,似乎是一条可行的开源社区发展之路。 + +今年 8 月 1 日,我们经过了半年的论证和实验,[发布了社区通证 LCCN](https://linux.cn/article-9886-1.html),并已经初步发放到了各位译者手中。我们还在继续建设通证生态各种工具,如合约、交易商城等。 + +我们希望能够通过通证为开源社区转入新的活力,也愿意将在探索道路上遇到的问题和解决的思路、工具链分享给更多的社区。 + +### 总结 + +从上一次总结以来,这又是七百多天,时光荏苒,而 LCTT 的创立也近两千天了。我希望,我们的翻译组以及更多的贡献者可以在通证经济的推动下,找到自洽、自治的发展道路;也希望能有更多的贡献者涌现出来接过我们的大旗,将开源发扬光大。 + +wxy +2018/9/9 夜 From d1540d5345b880733d7feed45769f9cdd4d3e74e Mon Sep 17 00:00:00 2001 From: feng lv Date: Mon, 10 Sep 2018 00:39:01 +0800 Subject: [PATCH 145/455] translated --- ... Compress And Decompress Files In Linux.md | 212 ------------------ ... Compress And Decompress Files In Linux.md | 211 +++++++++++++++++ 2 files changed, 211 insertions(+), 212 deletions(-) delete mode 100644 sources/tech/20180324 How To Compress And Decompress Files In Linux.md create mode 100644 translated/tech/20180324 How To Compress And Decompress Files In Linux.md diff --git a/sources/tech/20180324 How To Compress And Decompress Files In Linux.md b/sources/tech/20180324 How To Compress And Decompress Files In Linux.md deleted file mode 100644 index 4989527f13..0000000000 --- a/sources/tech/20180324 How To Compress And Decompress Files In Linux.md +++ /dev/null @@ -1,212 +0,0 @@ -ucasFL translating - -How To Compress And Decompress Files In Linux -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/03/compress-720x340.jpg) -Compressing is quite useful when backing up important files and also sending large files over Internet. Please note that compressing an already compressed file adds extra overhead, hence you will get a slightly bigger file. So, stop compressing a compressed file. There are many programs to compress and decompress files in GNU/Linux. In this tutorial, we’re going to learn about two applications only. - -### Compress and decompress files - -The most common programs used to compress files in Unix-like systems are: - - 1. gzip - 2. bzip2 - - - -##### 1\. Compress and decompress files using Gzip program - -The gzip is an utility to compress and decompress files using Lempel-Ziv coding (LZ77) algorithm. - -**1.1 Compress files** - -To compress a file named **ostechnix.txt** , replacing it with a gzipped compressed version, run: -``` -$ gzip ostechnix.txt - -``` - -Gzip will replace the original file **ostechnix.txt** with a gzipped compressed version named **ostechnix.txt.gz**. - -The gzip command can also be used in other ways too. One fine example is we can create a compressed version of a specific command’s output. Look at the following command. -``` -$ ls -l Downloads/ | gzip > ostechnix.txt.gz - -``` - -The above command creates compressed version of the directory listing of Downloads folder. - -**1.2 Compress files and write the output to different files (Don’t replace the original file) -** - -By default, gzip program will compress the given file, replacing it with a gzipped compressed version. You can, however, keep the original file and write the output to standard output. For example, the following command, compresses **ostechnix.txt** and writes the output to **output.txt.gz**. -``` -$ gzip -c ostechnix.txt > output.txt.gz - -``` - -Similarly, to decompress a gzipped file specifying the output filename: -``` -$ gzip -c -d output.txt.gz > ostechnix1.txt - -``` - -The above command decompresses the **output.txt.gz** file and writes the output to **ostechnix1.txt** file. In both cases, it won’t delete the original file. - -**1.3 Decompress files** - -To decompress the file **ostechnix.txt.gz** , replacing it with the original uncompressed version, we do: -``` -$ gzip -d ostechnix.txt.gz - -``` - -We can also use gunzip to decompress the files. -``` -$ gunzip ostechnix.txt.gz - -``` - -**1.4 View contents of compressed files without decompressing them** - -To view the contents of the compressed file using gzip without decompressing it, use **-c** flag as shown below: -``` -$ gunzip -c ostechnix1.txt.gz - -``` - -Alternatively, use **zcat** utility like below. -``` -$ zcat ostechnix.txt.gz - -``` - -You can also pipe the output to “less” command to view the output page by page like below. -``` -$ gunzip -c ostechnix1.txt.gz | less - -$ zcat ostechnix.txt.gz | less - -``` - -Alternatively, there is a **zless** program which performs the same function as the pipeline above. -``` -$ zless ostechnix1.txt.gz - -``` - -**1.5 Compress file with gzip by specifying compression level** - -Another notable advantage of gzip is it supports compression level. It supports 3 compression levels as given below. - - * **1** – Fastest (Worst) - * **9** – Slowest (Best) - * **6** – Default level - - - -To compress a file named **ostechnix.txt** , replacing it with a gzipped compressed version with **best** compression level, we use: -``` -$ gzip -9 ostechnix.txt - -``` - -**1.6 Concatenate multiple compressed files** - -It is also possible to concatenate multiple compressed files into one. How? Have a look at the following example. -``` -$ gzip -c ostechnix1.txt > output.txt.gz - -$ gzip -c ostechnix2.txt >> output.txt.gz - -``` - -The above two commands will compress ostechnix1.txt and ostechnix2.txt and saves them in one file named **output.txt.gz**. - -You can view the contents of both files (ostechnix1.txt and ostechnix2.txt) without extracting them using any one of the following commands: -``` -$ gunzip -c output.txt.gz - -$ gunzip -c output.txt - -$ zcat output.txt.gz - -$ zcat output.txt - -``` - -For more details, refer the man pages. -``` -$ man gzip - -``` - -##### 2\. Compress and decompress files using bzip2 program - -The **bzip2** is very similar to gzip program, but uses different compression algorithm named the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. The files compressed using bzip2 will end with **.bz2** extension. - -Like I said, the usage of bzip2 is almost same as gzip. Just replace **gzip** in the above examples with **bzip2** , **gunzip** with **bunzip2** , **zcat** with **bzcat** and so on. - -To compress a file using bzip2, replacing it with compressed version, run: -``` -$ bzip2 ostechnix.txt - -``` - -If you don’t want to replace the original file, use **-c** flag and write the output to a new file. -``` -$ bzip2 -c ostechnix.txt > output.txt.bz2 - -``` - -To decompress a compressed file: -``` -$ bzip2 -d ostechnix.txt.bz2 - -``` - -Or, -``` -$ bunzip2 ostechnix.txt.bz2 - -``` - -To view the contents of a compressed file without decompressing it: -``` -$ bunzip2 -c ostechnix.txt.bz2 - -``` - -Or, -``` -$ bzcat ostechnix.txt.bz2 - -``` - -For more details, refer man pages. -``` -$ man bzip2 - -``` - -##### Summary - -In this tutorial, we learned what is gzip and bzip2 programs and how to use them to compress and decompress files with some examples in GNU/Linux. In this next, guide we are going to learn how to archive files and directories in Linux. - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-compress-and-decompress-files-in-linux/ - -作者:[SK][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) -选题:[lujun9972](https://github.com/lujun9972) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.ostechnix.com/author/sk/ diff --git a/translated/tech/20180324 How To Compress And Decompress Files In Linux.md b/translated/tech/20180324 How To Compress And Decompress Files In Linux.md new file mode 100644 index 0000000000..a9ef889130 --- /dev/null +++ b/translated/tech/20180324 How To Compress And Decompress Files In Linux.md @@ -0,0 +1,211 @@ +如何在 Linux 中压缩和解压缩文件 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/03/compress-720x340.jpg) + +当在备份重要文件和通过网络发送大文件的时候,对文件进行压缩非常有用。请注意,压缩一个已经压缩过的文件会增加额外开销,因此你将会得到一个更大一些的文件。所以,请不要压缩已经压缩过的文件。在 GNU/Linux 中,有许多程序可以用来压缩和解压缩文件。在这篇教程中,我们仅学习其中两个应用程序。 + +### 压缩和解压缩文件 + +在类 Unix 系统中,最常见的用来压缩文件的程序是: + + 1. gzip + 2. bzip2 + + + +##### 1\. 使用 Gzip 程序来压缩和解压缩文件 + +Gzip 是一个使用 Lempel-Ziv 编码(LZ77)算法来压缩和解压缩文件的实用工具。 + +**1.1 压缩文件** + +如果要压缩一个名为 ostechnix.txt 的文件,使之成为 gzip 格式的压缩文件,那么只需运行如下命令: +``` +$ gzip ostechnix.txt + +``` + +上面的命令运行结束之后,将会出现一个名为 ostechnix.txt.gz 的 gzip 格式压缩文件,代替原始的 ostechnix.txt 文件。 + +gzip 命令还可以有其他用法。一个有趣的例子是,我们可以将一个特定命令的输出通过管道传递,然后作为 gzip 程序的输入来创建一个压缩文件。看下面的命令: +``` +$ ls -l Downloads/ | gzip > ostechnix.txt.gz + +``` + +上面的命令将会创建一个 gzip 格式的压缩文件,文件的内容为 “Downloads” 目录的目录项。 + +**1.2 压缩文件并将输出写到新文件中(不覆盖原始文件) +** + +默认情况下,gzip 程序会压缩给定文件,并以压缩文件替代原始文件。但是,你也可以保留原始文件,并将输出写到标准输出。比如,下面这个命令将会压缩 ostechnix.txt 文件,并将输出写入文件 output.txt.gz 。 +``` +$ gzip -c ostechnix.txt > output.txt.gz + +``` + +类似地,要解压缩一个 gzip 格式的压缩文件并指定输出文件的文件名,只需运行: +``` +$ gzip -c -d output.txt.gz > ostechnix1.txt + +``` + +上面的命令将会解压缩 output.txt.gz 文件,并将输出写入到文件 ostechnix1.txt 中。在上面两个例子中,原始文件均不会被删除。 + +**1.3 解压缩文件** + +如果要解压缩 ostechnix.txt.gz 文件,并以原始未压缩版本的文件来代替它,那么只需运行: +``` +$ gzip -d ostechnix.txt.gz + +``` + +我们也可以使用 gunzip 程序来解压缩文件: +``` +$ gunzip ostechnix.txt.gz + +``` + +**1.4 在不解压缩的情况下查看压缩文件的内容** + +如果你想在不解压缩的情况下,使用 gzip 程序查看压缩文件的内容,那么可以像下面这样使用 -c 选项: +``` +$ gunzip -c ostechnix1.txt.gz + +``` + +或者,你也可以像下面这样使用 zcat 程序: +``` +$ zcat ostechnix.txt.gz + +``` + +你也可以通过管道将输出传递给 less 命令,从而一页一页的来查看输出,就像下面这样: +``` +$ gunzip -c ostechnix1.txt.gz | less + +$ zcat ostechnix.txt.gz | less + +``` + +另外,zless 程序也能够实现和上面的管道同样的功能。 +``` +$ zless ostechnix1.txt.gz + +``` + +**1.5 使用 gzip 压缩文件并指定压缩级别** + +Gzip 的另外一个显著优点是支持压缩级别。它支持下面给出的 3 个压缩级别: + + * **1** – 最快 (最差) + * **9** – 最慢 (最好) + * **6** – 默认级别 + + + +要压缩名为 ostechnix.txt 的文件,使之成为“最好”压缩级别的 gzip 压缩文件,可以运行: +``` +$ gzip -9 ostechnix.txt + +``` + +**1.6 连接多个压缩文件** + +我们也可以把多个需要压缩的文件压缩到同一个文件中。如何实现呢?看下面这个例子。 +``` +$ gzip -c ostechnix1.txt > output.txt.gz + +$ gzip -c ostechnix2.txt >> output.txt.gz + +``` + +上面的两个命令将会压缩文件 ostechnix1.txt 和 ostechnix2.txt,并将输出保存到一个文件 output.txt.gz 中。 + +你可以通过下面其中任何一个命令,在不解压缩的情况下,查看两个文件 ostechnix1.txt 和 ostechnix2.txt 的内容: +``` +$ gunzip -c output.txt.gz + +$ gunzip -c output.txt + +$ zcat output.txt.gz + +$ zcat output.txt + +``` + +如果你想了解关于 gzip 的更多细节,请参阅它的 man 手册。 +``` +$ man gzip + +``` + +##### 2\. 使用 bzip2 程序来压缩和解压缩文件 + +bzip2 和 gzip 非常类似,但是 bzip2 使用的是 Burrows-Wheeler 块排序压缩算法,并使用哈夫曼Huffman编码。使用 bzip2 压缩的文件以 “.bz2” 扩展结尾。 + +正如我上面所说的, bzip2 的用法和 gzip 几乎完全相同。只需在上面的例子中将 gzip 换成 bzip2,将 gunzip 换成 bunzip2,将 zcat 换成 bzcat 即可。 + +要使用 bzip2 压缩一个文件,并以压缩后的文件取而代之,只需运行: +``` +$ bzip2 ostechnix.txt + +``` + +如果你不想替换原始文件,那么可以使用 -c 选项,并把输出写入到新文件中。 +``` +$ bzip2 -c ostechnix.txt > output.txt.bz2 + +``` + +如果要解压缩文件,则运行: +``` +$ bzip2 -d ostechnix.txt.bz2 + +``` + +或者, +``` +$ bunzip2 ostechnix.txt.bz2 + +``` + +如果要在不解压缩的情况下查看一个压缩文件的内容,则运行: +``` +$ bunzip2 -c ostechnix.txt.bz2 + +``` + +或者, +``` +$ bzcat ostechnix.txt.bz2 + +``` + +如果你想了解关于 bzip2 的更多细节,请参阅它的 man 手册。 +``` +$ man bzip2 + +``` + +##### 总结 + +在这篇教程中,我们学习了 gzip 和 bzip2 程序是什么,并通过 GNU/Linux 下的一些例子学习了如何使用它们来压缩和解压缩文件。接下来,我们将要学习如何在 Linux 中将文件和目录归档。 + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-compress-and-decompress-files-in-linux/ + +作者:[SK][a] +译者:[ucasFL](https://github.com/ucasFL) +校对:[校对者ID](https://github.com/校对者ID) +选题:[lujun9972](https://github.com/lujun9972) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ From 2707c9e2054cb2bd062ee2c6a097c2e35b7911ae Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 10 Sep 2018 08:51:04 +0800 Subject: [PATCH 146/455] translated --- ... How to Update Firmware on Ubuntu 18.04.md | 99 ------------------- ... How to Update Firmware on Ubuntu 18.04.md | 99 +++++++++++++++++++ 2 files changed, 99 insertions(+), 99 deletions(-) delete mode 100644 sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md create mode 100644 translated/tech/20180830 How to Update Firmware on Ubuntu 18.04.md diff --git a/sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md b/sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md deleted file mode 100644 index f0c0250a8f..0000000000 --- a/sources/tech/20180830 How to Update Firmware on Ubuntu 18.04.md +++ /dev/null @@ -1,99 +0,0 @@ -translating---geekpi - -How to Update Firmware on Ubuntu 18.04 -====== -Usually, the default software center in Ubuntu and other Linux handle the update of the firmware of your system. But if you encounter errors with it, you can use fwupd command line tool for updating the firmware of your system. - -I use [Dell XPS 13 Ubuntu edition][1] as my main operating system. I have done a fresh [installation of Ubuntu 18.04][2] on it and I cannot be happier with the hardware compatibility. Bluetooth, external USB headsets and speakers, multi-monitor, everything works out of the box. - -The one thing that troubled me was one of the [firmware][3] updates that appeared in the Software Center. - -![Updating firmware in Ubuntu][4] - -Clicking on the Update button resulted in an error a few seconds later. - -![Updating firmware in Ubuntu][5] - -The error message was: - -**Unable to update “Thunderbolt NVM for Xps Notebook 9360”: could not detect device after update: timed out while waiting for device** - -In this quick tip, I’ll show you how to update the firmware of your system in [Ubuntu][6]. - -### Updating firmware in Ubuntu 18.04 - -![How to update firmware in Ubuntu][7] - -One thing you should know that GNOME Software i.e. the software center in Ubuntu 18.04 is also capable of updating the firmware. But in situations when it fails for some reason, you can use the command line tool fwupd. - -[fwupd][8] is an open source daemon that handles firmware upgrades in Linux based systems. It is created by GNOME developer [Richard Hughes][9]. Developers from Dell also contributed to the development of this open source tool. - -Basically, it utilizes the LVFS, Linux Vendor Firmware Service. Hardware vendors upload redistributable firmware to the LVFS site and thanks to fwupd, you can upgrade those firmware from inside the operating system itself. fwupd is supported by major Linux distributions like Ubuntu and Fedora. - -Open a terminal and update your system first: -``` -sudo apt update && sudo apt upgrade -y - -``` - -After that you can use the following commands one by one to start the daemon, refresh the list of available firmware updates and install the firmware updates. -``` -sudo service fwupd start - -``` - -Once the daemon is running, check if there are any firmware updates available. -``` -sudo fwupdmgr refresh - -``` - -The output should look like this: - -Fetching metadata -Downloading… [****************************] -Fetching signature - -After this, run the firmware update: -``` -sudo fwupdmgr update - -``` - -The output of the firmware update could be similar to this: - -``` -No upgrades for XPS 13 9360 TPM 2.0, current is 1.3.1.0: 1.3.1.0=same -No upgrades for XPS 13 9360 System Firmware, current is 0.2.8.1: 0.2.8.1=same, 0.2.7.1=older, 0.2.6.2=older, 0.2.5.1=older, 0.2.4.2=older, 0.2.3.1=older, 0.2.2.1=older, 0.2.1.0=older, 0.1.3.7=older, 0.1.3.5=older, 0.1.3.2=older, 0.1.2.3=older -Downloading 21.00 for XPS13 9360 Thunderbolt Controller… -Updating 21.00 on XPS13 9360 Thunderbolt Controller… -Decompressing… [***********] -Authenticating… [***********] -Restarting device… [***********] -``` - -This should handle the firmware update in Ubuntu 18.04. I hope this quick tip helped you with firmware updates in Linux. - -If you have questions or suggestions, please feel free to use the comment section below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/update-firmware-ubuntu/ - -作者:[Abhishek Prakash][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/abhishek/ -[1]: https://itsfoss.com/dell-xps-13-ubuntu-review/ -[2]: https://itsfoss.com/install-ubuntu-dual-boot-mode-windows/ -[3]: https://en.wikipedia.org/wiki/Firmware -[4]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/ubuntu-firmware-update-error-1.png -[5]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/ubuntu-firmware-update-error-2.jpg -[6]: https://www.ubuntu.com/ -[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/update-firmware-ubuntu.png -[8]: https://fwupd.org/ -[9]: https://github.com/hughsie/fwupd diff --git a/translated/tech/20180830 How to Update Firmware on Ubuntu 18.04.md b/translated/tech/20180830 How to Update Firmware on Ubuntu 18.04.md new file mode 100644 index 0000000000..701d12ddaa --- /dev/null +++ b/translated/tech/20180830 How to Update Firmware on Ubuntu 18.04.md @@ -0,0 +1,99 @@ +如何在 Ubuntu 18.04 上更新固件 +====== +通常,Ubuntu 和其他 Linux 中的默认软件中心会处理系统固件的更新。但是如果你遇到了错误,你可以使用 fwupd 命令行工具更新系统的固件。 + +我使用 [Dell XPS 13 Ubuntu 版本][1]作为我的主要操作系统。我全新[安装了 Ubuntu 18.04][2],我对硬件兼容性感到满意。蓝牙、外置 USB 耳机和扬声器、多显示器,一切都开箱即用。 + +困扰我的一件事是软件中心出现的一个[固件][3]更新。 + +![Updating firmware in Ubuntu][4] + +单击“更新”按钮会在几秒钟后出现错误。 + +![Updating firmware in Ubuntu][5] + +错误消息是: + +**Unable to update “Thunderbolt NVM for Xps Notebook 9360”: could not detect device after update: timed out while waiting for device** + +在这篇文章中,我将向你展示如何在 [Ubuntu][6] 中更新系统固件。 + +### 在 Ubuntu 18.04 中更新固件 + +![How to update firmware in Ubuntu][7] + +有一件事你应该知道 GNOME Softwar 即 Ubuntu 18.04 中的软件中心也能够更新固件。但是在由于某种原因失败的情况下,你可以使用命令行工具 fwupd。 + +[fwupd][8] 是一个开源守护进程,可以处理基于 Linux 的系统中的固件升级。它由 GNOME 开发人员 [Richard Hughes][9] 创建。戴尔的开发人员也为这一开源工具的开发做出了贡献。 + +基本上,它使用 LVFS,Linux 供应商固件服务 (Linux Vendor Firmware Service)。硬件供应商将可再发行固件上传到 LVFS 站点,并且多亏 fwupd,你可以从操作系统内部升级这些固件。fwupd 受到 Ubuntu 和 Fedora 等主要 Linux 发行版的支持。 + +首先打开终端并更新系统: +``` +sudo apt update && sudo apt upgrade -y + +``` + +之后,你可以逐个使用以下命令来启动守护程序,刷新可用固件更新列表并安装固件更新。 +``` +sudo service fwupd start + +``` + +守护进程运行后,检查是否有可用的固件更新。 +``` +sudo fwupdmgr refresh + +``` + +输出应如下所示: + +``` +Fetching metadata +Downloading… [****************************] +Fetching signature +``` + +在此之后,运行固件更新: +``` +sudo fwupdmgr update + +``` + +固件更新的输出可能与此类似: + +``` +No upgrades for XPS 13 9360 TPM 2.0, current is 1.3.1.0: 1.3.1.0=same +No upgrades for XPS 13 9360 System Firmware, current is 0.2.8.1: 0.2.8.1=same, 0.2.7.1=older, 0.2.6.2=older, 0.2.5.1=older, 0.2.4.2=older, 0.2.3.1=older, 0.2.2.1=older, 0.2.1.0=older, 0.1.3.7=older, 0.1.3.5=older, 0.1.3.2=older, 0.1.2.3=older +Downloading 21.00 for XPS13 9360 Thunderbolt Controller… +Updating 21.00 on XPS13 9360 Thunderbolt Controller… +Decompressing… [***********] +Authenticating… [***********] +Restarting device… [***********] +``` + +这应该处理了在 Ubuntu 18.04 中的固件更新。我希望这篇文章可以帮助你在 Linux 中进行固件更新。 + +如果你有任何问题或建议,请在下面的评论栏留言。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/update-firmware-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[1]: https://itsfoss.com/dell-xps-13-ubuntu-review/ +[2]: https://itsfoss.com/install-ubuntu-dual-boot-mode-windows/ +[3]: https://en.wikipedia.org/wiki/Firmware +[4]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/ubuntu-firmware-update-error-1.png +[5]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/ubuntu-firmware-update-error-2.jpg +[6]: https://www.ubuntu.com/ +[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/update-firmware-ubuntu.png +[8]: https://fwupd.org/ +[9]: https://github.com/hughsie/fwupd From 79dbfc606c196bcf422d79245bf2e35108f536d3 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 10 Sep 2018 08:55:47 +0800 Subject: [PATCH 147/455] translating --- .../20180906 Two open source alternatives to Flash Player.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180906 Two open source alternatives to Flash Player.md b/sources/tech/20180906 Two open source alternatives to Flash Player.md index c128c484e1..831a96ab2f 100644 --- a/sources/tech/20180906 Two open source alternatives to Flash Player.md +++ b/sources/tech/20180906 Two open source alternatives to Flash Player.md @@ -1,3 +1,5 @@ +translating---geekpi + Two open source alternatives to Flash Player ====== From f61ed21ee80d5d3844299cedc614e109e899d6f2 Mon Sep 17 00:00:00 2001 From: David Chen Date: Mon, 10 Sep 2018 11:01:37 +0800 Subject: [PATCH 148/455] 20180827 An introduction to diffs and patches.md --- ...27 An introduction to diffs and patches.md | 112 ---------------- ...27 An introduction to diffs and patches.md | 125 ++++++++++++++++++ 2 files changed, 125 insertions(+), 112 deletions(-) delete mode 100644 sources/tech/20180827 An introduction to diffs and patches.md create mode 100644 translated/tech/20180827 An introduction to diffs and patches.md diff --git a/sources/tech/20180827 An introduction to diffs and patches.md b/sources/tech/20180827 An introduction to diffs and patches.md deleted file mode 100644 index 1c81b97bf6..0000000000 --- a/sources/tech/20180827 An introduction to diffs and patches.md +++ /dev/null @@ -1,112 +0,0 @@ -An introduction to diffs and patches -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0) - -If you’ve ever worked on a large codebase with a distributed development model, you’ve probably heard people say things like “Sue just sent a patch,” or “Rajiv is checking out the diff.” Maybe those terms were new to you and you wondered what they meant. Open source has had an impact here, as the main development model of large projects from Apache web server to the Linux kernel have been “patch-based” development projects throughout their lifetime. In fact, did you know that Apache’s name originated from the set of patches that were collected and collated against the original [NCSA HTTPd server source code][1]? - -You might think this is folklore, but an early [capture of the Apache website][2] claims that the name was derived from this original “patch” collection; hence **APA** t **CH** y server, which was then simplified to Apache. - -But enough history trivia. What exactly are these patches and diffs that developers talk about? - -First, for the sake of this article, let’s assume that these two terms reference one and the same thing. “Diff” is simply short for “difference;” a Unix utility by the same name reveals the difference between one or more files. We will look at a diff utility example below. - -A “patch” refers to a specific collection of differences between files that can be applied to a source code tree using the Unix diff utility. So we can create diffs (or patches) using the diff tool and apply them to an unpatched version of that same source code using the patch tool. As an aside (and breaking my rule of no more history trivia), the word “patch” comes from the physical covering of punchcard holes to make software changes in the early computing days, when punchcards represented the program executed by the computer’s processor. The image below, found on this [Wikipedia page][3] describing software patches, shows this original “patching” concept: - -![](https://opensource.com/sites/default/files/uploads/360px-harvard_mark_i_program_tape.agr_.jpg) - -Now that you have a basic understanding of patches and diffs, let’s explore how software developers use these tools. If you haven’t used a source code control system like [Git][4] or [Subversion][5], I will set the stage for how most non-trivial software projects are developed. If you think of the life of a software project as a set of actions along a timeline, you might visualize changes to the software—such as adding a feature or a function to a source code file or fixing a bug—appearing at different points on the timeline, with each discrete point representing the state of all the source code files at that time. We will call these points of change “commits,” using the same nomenclature that today’s most popular source code control tool, Git, uses. When you want to see the difference between the source code before and after a certain commit, or between many commits, you can use a tool to show us diffs, or differences. - -If you are developing software using this same source code control tool, Git, you may have changes in your local system that you want to provide for others to potentially add as commits to their own tree. One way to provide local changes to others is to create a diff of your local tree's changes and send this “patch” to others who are working on the same source code. This lets others patch their tree and see the source code tree with your changes applied. - -### Linux, Git, and GitHub - -This model of sharing patch files is how the Linux kernel community operates regarding proposed changes today. If you look at the archives for any of the popular Linux kernel mailing lists—[LKML][6] is the primary one, but others include [linux-containers][7], [fs-devel][8], [Netdev][9], to name a few—you’ll find many developers posting patches that they wish to have others review, test, and possibly bring into the official Linux kernel Git tree at some point. It is outside of the scope of this article to discuss Git, the source code control system written by Linus Torvalds, in more detail, but it's worth noting that Git enables this distributed development model, allowing patches to live separately from a main repository, pushing and pulling into different trees and following their specific development flow. - -Before moving on, we can’t ignore the most popular service in which patches and diffs are relevant: [GitHub][10]. Given its name, you can probably guess that GitHub is based on Git, but it offers a web- and API-based workflow around the Git tool for distributed open source project development. One of the main ways that patches are shared in GitHub is not via email, like the Linux kernel, but by creating a **pull request**. When you commit changes on your own copy of a source code tree, you can share those changes by creating a pull request against a commonly shared repository for that software project. GitHub is used by many active and popular open source projects today, such as [Kubernetes][11], [Docker][12], [the Container Network Interface (CNI)][13], [Istio][14], and many others. In the GitHub world, users tend to use the web-based interface to review the diffs or patches that comprise a pull request, but you can still access the raw patch files and use them at the command line with the patch utility. - -### Getting down to business - -Now that we’ve covered patches and diffs and how they are used in popular open source communities or tools, let's look at a few examples. - -The first example includes two copies of a source tree, and one has changes that we want to visualize using the diff utility. In our examples, we will look at “unified” diffs because that is the expected view for patches in most of the modern software development world. Check the diff manual page for more information on options and ways to produce differences. The original source code is located in sources-orig and our second, modified codebase is located in a directory named sources-fixed. To show the differences in a unified diff format in your terminal, use the following command: -``` -$ diff -Naur sources-orig/ sources-fixed/ -``` - -...which then shows the following diff command output: -``` -diff -Naur sources-orig/officespace/interest.go sources-fixed/officespace/interest.go ---- sources-orig/officespace/interest.go        2018-08-10 16:39:11.000000000 -0400 -+++ sources-fixed/officespace/interest.go       2018-08-10 16:39:40.000000000 -0400 -@@ -11,15 +11,13 @@ -   InterestRate float64 - } - -+// compute the rounded interest for a transaction - func computeInterest(acct *Account, t Transaction) float64 { - -   interest := t.Amount 选题模板.txt 中文排版指北.md comic core.md Dict.md lctt2014.md lctt2016.md LCTT翻译规范.md LICENSE Makefile published README.md sign.md sources translated t.InterestRate -   roundedInterest := math.Floor(interest*100) / 100.0 -   remainingInterest := interest - roundedInterest - --  // a little extra.. --  remainingInterest *= 1000 -- -   // Save the remaining interest into an account we control: -   acct.Balance = acct.Balance + remainingInterest -``` - -The first few lines of the diff command output could use some explanation: The three `---` signs show the original filename; any lines that exist in the original file but not in the compared new file will be prefixed with a single `-` to note that this line was “subtracted” from the sources. The `+++` signs show the opposite: The compared new file and additions found in this file are marked with a single `+` symbol to show they were added in the new version of the file. Each “hunk” (that’s what sections prefixed by `@@` are called) of the difference patch file has contextual line numbers that help the patch tool (or other processors) know where to apply this change. You can see from the "Office Space" movie reference function that we’ve corrected (by removing three lines) the greed of one of our software developers, who added a bit to the rounded-out interest calculation along with a comment to our function. - -If you want someone else to test the changes from this tree, you could save this output from diff into a patch file: -``` -$ diff -Naur sources-orig/ sources-fixed/ >myfixes.patch -``` - -Now you have a patch file, myfixes.patch, which can be shared with another developer to apply and test this set of changes. A fellow developer can apply the changes using the patch tool, given that their current working directory is in the base of the source code tree: -``` -$ patch -p1 < ../myfixes.patch -patching file officespace/interest.go -``` - -Now your fellow developer’s source tree is patched and ready to build and test the changes that were applied via the patch. What if this developer had made changes to interest.go separately? As long as the changes do not conflict directly—for example, change the same exact lines—the patch tool should be able to solve where to merge the changes in. As an example, an interest.go file with several other changes is used in the following example run of patch: -``` -$ patch -p1 < ../myfixes.patch -patching file officespace/interest.go -Hunk #1 succeeded at 26 (offset 15 lines). -``` - -In this case, patch warns that the changes did not apply at the original location in the file, but were offset by 15 lines. If you have heavily changed files, patch may give up trying to find where the changes fit, but it does provide options (with requisite warnings in the documentation) for turning up the matching “fuzziness” (which are beyond the scope of this article). - -If you are using Git and/or GitHub, you will probably not use the diff or patch tools as standalone tools. Git offers much of this functionality so you can use the built-in capabilities of working on a shared source tree with merging and pulling other developer’s changes. One similar capability is to use git diff to provide the unified diff output in your local tree or between any two references (a commit identifier, the name of a tag or branch, and so on). You can even create a patch file that someone not using Git might find useful by simply piping the git diff output to a file, given that it uses the exact format of the diffcommand that patch can consume. Of course, GitHub takes these capabilities into a web-based user interface so you can view file changes on a pull request. In this view, you will note that it is effectively a unified diff view in your web browser, and GitHub allows you to download these changes as a raw patch file. - -### Summary - -You’ve learned what a diff and a patch are, as well as the common Unix/Linux command line tools that interact with them. Unless you are a developer on a project still using a patch file-based development method—like the Linux kernel—you will consume these capabilities primarily through a source code control system like Git. But it’s helpful to know the background and underpinnings of features many developers use daily through higher-level tools like GitHub. And who knows—they may come in handy someday when you need to work with patches from a mailing list in the Linux world. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/diffs-patches - -作者:[Phil Estes][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/estesp -[1]:https://github.com/TooDumbForAName/ncsa-httpd -[2]:https://web.archive.org/web/19970615081902/http:/www.apache.org/info.html -[3]:https://en.wikipedia.org/wiki/Patch_(computing) -[4]:https://git-scm.com/ -[5]:https://subversion.apache.org/ -[6]:https://lkml.org/ -[7]:https://lists.linuxfoundation.org/pipermail/containers/ -[8]:https://patchwork.kernel.org/project/linux-fsdevel/list/ -[9]:https://www.spinics.net/lists/netdev/ -[10]:https://github.com/ -[11]:https://kubernetes.io/ -[12]:https://www.docker.com/ -[13]:https://github.com/containernetworking/cni -[14]:https://istio.io/ diff --git a/translated/tech/20180827 An introduction to diffs and patches.md b/translated/tech/20180827 An introduction to diffs and patches.md new file mode 100644 index 0000000000..c043f95f2d --- /dev/null +++ b/translated/tech/20180827 An introduction to diffs and patches.md @@ -0,0 +1,125 @@ +差异文件(diffs)和补丁文件(patches)简介 +====== +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0) + + 如果你曾有机会在一个使用分布式开发模型的大型代码库上工作过,你就应该听说过类似下面的话,"Sue刚发过来一个补丁","Rajiv 正在签出差异文件", 可能这些词(补丁,差异文件)对你而言很陌生,而你确定很想搞懂他们到底指什么。开源软件对上述提到的名词有很大的贡献,作为从开发 Apache web 服务器到开发Linux 内核的开发模型,"基于补丁文件的开发" 这一模式贯穿了上述项目的始终。实际上,你可能不知道 Apache 的名字就来自一系列的代码补丁,他们被一一收集起来并针对原来的[NCSA HTTPd server source code][1]进行了校对 + + 你可能认为前面说的只不过是些逸闻,但是一份早期的[capture of the Apache website][2]声称Apache 的名字就是来自于最早的“补丁文件”集合;(译注:Apache 英文音和补丁相似),是“打了补丁的”服务器的英文名字简化。 + +好了,言归正传,程序员嘴里说的"差异"和"补丁" 到底是什么? + +首先,在这篇文章里,我们可以认为这两个术语都指向同一个概念。“差异” 就是”补丁“。Unix 下的同名工具程序diff("差异")和patch("补丁")剖析了一个或多个文件之间的”差异”。下面我们看看diff 的例子: + +一个"补丁"指的是文件之间一系列差异,这些差异能被 Unix 的 diff程序应用在源代码树上,使之转变为程序员想要的文件状态。我们能使用diff 工具来创建“差异”( 或“补丁”),然后将他们“打” 在一个没有这个补丁的源代码版本上,此外,(我又要开始跑题了...),“补丁” 这个词真的指在计算机的早期使用打卡机的时候,用来覆盖在纸带上的用于修复代码错误的覆盖纸,那个时代纸带(上面有孔)就是在计算机处理器上运行的程序。下面的这张图,来自[Wikipedia Page][3] 真切的描绘了最初的“ 打补丁”这个词的出处: + + +![](https://opensource.com/sites/default/files/uploads/360px-harvard_mark_i_program_tape.agr_.jpg) + +现在你对补丁和差异就了一个基本的概念,让我们来看看软件开发者是怎么使用这些工具的。如果你还没有使用过类似于[Git][4]这样的源代码版本控制工具的话,我将会一步步展示最流行的软件项目是怎么使用它们的。如果你将一个软件的生命周期看成是一条时间线的话,你就能看见这个软件的点滴变化,比如在何时源代码树加上了一个功能,在何时源代码树修复了一个功能缺陷。我们称这些改变的点为“进行了一次提交”,”提交“这个词被当今最流行的源代码版本管理工具Git使用, 当你想检查在一个提交前后的代码变化的话,(或者在许多个提交之间的代码变化),你都可以使用工具来观察文件差异。 + +如果你在使用 Git 开发软件的话,你开发环境本地有可能就有你想交给别的开发者的提交,为了给别的开发者你的提交,一个方法就是创建一个你本地文件的差异文件,然后将这个“补丁”发送给和你工作在同一个源代码树的别的开发者。别的开发者在“打”了你的补丁之后,就能看到在你的代码变树上的变化。 + + +### Linux, Git, 和 GitHub + +这种共享补丁的开发模型正是现今 Linux 内核社区如何处理内核修改提议而采用的模型。如果你有机会浏览任何一个主流的 Linux 内核邮件列表-主要是[LKML][6],包括[linux-containers][7],[fs-devel][8],[Netdev][9]等等,你能看到很多开发者会贴出他们想让其他内核开发者审核,测试或者合入Linux官方Git代码树某个提交的补丁。当然,讨论 Git 不在这篇文章范围之内(Git 是由 Linus Torvalds 开发的源代码控制系统,它支持分布式开发模型以及允许独立于主要代码仓库的补丁包,这些补丁包能被推送或拉取到不同的源代码树上并遵守这些代码树各自的开发流程。) + +在继续我们的话题之前,我们当然不能忽略和补丁和差异这个概念最相关的的服务:[GitHub][10]。从它的名字就能猜想出 GitHub 是基于 Git 的,而且它还围绕着 Git对分布式开源代码开发模型提供了基于Web 和 API 的工作流管理。(译注:即Pull Request -- 拉取请求)。在 GitHub 上,分享补丁的方式不是像 Linux 内核社区那样通过邮件列表,而是通过创建一个 **拉取请求** 。当你提交你自己源代码的改动时,你能通过创建一个针对软件项目的主仓库的“拉取请求”来分享你的代码改动(译注:即核心开发者维护一个主仓库,开发者去“fork”这个仓库,待各自的提交后再创建针对这个主仓库的拉取请求,所有的拉取请求由主仓库的核心开发者批准后才能合入主代码库。)GitHub 被当今很多活跃的开源社区所采用,如[Kubernetes][11],[Docker][12],[the Container Network Interface (CNI)][13],[Istio][14]等等。在 GitHub 的世界里,用户会倾向于使用基于 Web 页面的方式来审核一个拉取请求里的补丁或差异,你也可以直接访问原始的补丁并在命令行上直接使用它们。 + + + + +### 该说点干货了 + +我们前面已经讲了在流行的开源社区了是怎么应用补丁和 diff的,现在看看一些例子。 + +第一个例子包括一个源代码树的两个不同拷贝,其中一个有代码改动,我们想用 diff来看看这些改动是什么。这个例子里,我们想看的是“合并格式”的补丁,这是现在软件开发世界里最通用的格式。如果想知道更详细参数的用法以及如何生成diff,请参考diff手册。原始的代码在sources-orig目录 而改动后的代码在sources-fixed目录. 如果要在你的命令行上用“合并格式”来展示补丁,请运行如下命令。(译注: 参数 N 代表如果比较的文件不存在,则认为是个空文件, a代表将所有文件都作为文本文件对待,u 代表使用合并格式并输出上下文,r 代表递归比较目录) + + +``` +$ diff -Naur sources-orig/ sources-fixed/ +``` + +...下面是 diff命令的输出: + +``` +diff -Naur sources-orig/officespace/interest.go sources-fixed/officespace/interest.go +--- sources-orig/officespace/interest.go        2018-08-10 16:39:11.000000000 -0400 ++++ sources-fixed/officespace/interest.go       2018-08-10 16:39:40.000000000 -0400 +@@ -11,15 +11,13 @@ +   InterestRate float64 + } + ++// compute the rounded interest for a transaction + func computeInterest(acct *Account, t Transaction) float64 { + +   interest := t.Amount * t.InterestRate +   roundedInterest := math.Floor(interest*100) / 100.0 +   remainingInterest := interest - roundedInterest + +-  // a little extra.. +-  remainingInterest *= 1000 +- +   // Save the remaining interest into an account we control: +   acct.Balance = acct.Balance + remainingInterest +``` +最开始几行 diff的输出可以这样解释:三个‘---’显示了原来文件的名字;任何在原文件(译注:不是源文件)里存在而在新文件里不存在的行将会用前缀‘-’,用来表示这些行被从源代码里‘减去’了。而‘+++’表示的则相反:在新文件里被加上的行会被放上前缀‘+’,表示这是在新文件里被'加上'的行。每一个补丁”块“(用@@作为前缀的的部分)都有上下文的行号,这能帮助补丁工具(或其他处理器)知道在代码的哪里应用这个补丁块。你能看到我们已经修改了”办公室“这部电影里提到的那个函数(移除了三行并加上了一行代码注释),电影里那个有点贪心的工程师可是偷偷的在计算利息的函数里加了点”料“哦。( LCTT译注:剧情详情请见电影 https://movie.douban.com/subject/1296424/) + + +如果你想找人来测试你的代码改动,你可以将差异保存到一个补丁里: + +``` +$ diff -Naur sources-orig/ sources-fixed/ >myfixes.patch +``` + +现在你有补丁 myfixes.patch了,你能把它分享给别的开发者,他们可以将这个补丁打在他们自己的源代码树上从而得到和你一样的代码并测试他们。如果一个开发者的当前工作目录就是他的源代码树的根的话,他可以用下面的命令来打补丁: + + +``` +$ patch -p1 < ../myfixes.patch +patching file officespace/interest.go +``` +现在这个开发者的源代码树已经打好补丁并准备好构建和测试文件的修改了。那么如果这个开发者在打补丁之前已经改动过了怎么办?只要这些改动没有直接冲突(译注:比如改在同一行上),补丁工具就能自动的合并代码的改动。例如下面的interest.go 文件,他有其他几处改动,然后它想打上myfixes.patch 这个补丁: + + +``` +$ patch -p1 < ../myfixes.patch +patching file officespace/interest.go +Hunk #1 succeeded at 26 (offset 15 lines). +``` +在这个例子中,补丁警告说代码改动并不在文件原来的地方而是偏移了15行。如果你文件改动的很厉害,补丁可能干脆说找不到要应用的地方,还好补丁程序提供了提供了打开”模糊“匹配的选项(这个选项在文档里有预置的警告信息,对其讲解已经超出了本文的范围) + +如果你使用 Git 或者 GitHub 的话,你可能不会直接使用diff或patch。Git 已经内置了这些功能,你能使用这些功能和共享一个源代码树的其他开发者交互,拉取或合并代码。Git一个比较相近的功能是可以使用 git diff 来对你的本地代码树生成全局差异,又或者对你的任意两次”引用“(可能是一个代表提交的数字,或一个标记或分支的名字,等等)做全局补丁。你甚至能简单的用管道将 git diff的输出到一个文件里(这个文件必须严格符合将要被使用它的程序的输入要求),然后将这个文件交给一个并不使用 Git 的开发者应用到他的代码上。当然,GitHub 把这些功能放到了 Web 上,你能直接在 Web 页面上查看一个拉取请求的文件变动。在Web 上你能看到所展示的合并差异,GitHub 还允许你将这些代码改动下载为原始的补丁文件。 + + +### 总结 + +好了,你已经学到了”差异“和”补丁“是什么,以及在 Unix/Linux 上怎么使用命令行工具和他们交互。除非你还在像 Linux 内核开发这样的项目中工作而使用完全基于补丁的开发方式,你应该会主要通过你的源代码控制系统(如Git)来使用补丁。但熟悉像 GitHub 这样的高级别工具的技术背景和技术底层对你的工作也是大有裨益的。谁知道会不会有一天你需要和一个来自 Linux 世界邮件列表的补丁包打交道呢? + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/diffs-patches + +作者:[Phil Estes][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[David Chen](https://github.com/DavidChenLiang) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/estesp +[1]:https://github.com/TooDumbForAName/ncsa-httpd +[2]:https://web.archive.org/web/19970615081902/http:/www.apache.org/info.html +[3]:https://en.wikipedia.org/wiki/Patch_(computing) +[4]:https://git-scm.com/ +[5]:https://subversion.apache.org/ +[6]:https://lkml.org/ +[7]:https://lists.linuxfoundation.org/pipermail/containers/ +[8]:https://patchwork.kernel.org/project/linux-fsdevel/list/ +[9]:https://www.spinics.net/lists/netdev/ +[10]:https://github.com/ +[11]:https://kubernetes.io/ +[12]:https://www.docker.com/ +[13]:https://github.com/containernetworking/cni +[14]:https://istio.io/ From d6cb0481cb7f6976a2711ec3ebfee265be644a39 Mon Sep 17 00:00:00 2001 From: zafiry Date: Mon, 10 Sep 2018 11:41:09 +0800 Subject: [PATCH 149/455] translated --- ...What is a Makefile and how does it work.md | 323 ------------------ ...What is a Makefile and how does it work.md | 322 +++++++++++++++++ 2 files changed, 322 insertions(+), 323 deletions(-) delete mode 100644 sources/tech/20180822 What is a Makefile and how does it work.md create mode 100644 translated/tech/20180822 What is a Makefile and how does it work.md diff --git a/sources/tech/20180822 What is a Makefile and how does it work.md b/sources/tech/20180822 What is a Makefile and how does it work.md deleted file mode 100644 index dc205f78dc..0000000000 --- a/sources/tech/20180822 What is a Makefile and how does it work.md +++ /dev/null @@ -1,323 +0,0 @@ -Zafiry translating... -What is a Makefile and how does it work? -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_liberate%20docs_1109ay.png?itok=xQOLreya) -If you want to run or update a task when certain files are updated, the `make` utility can come in handy. The `make` utility requires a file, `Makefile` (or `makefile`), which defines set of tasks to be executed. You may have used `make` to compile a program from source code. Most open source projects use `make` to compile a final executable binary, which can then be installed using `make install`. - -In this article, we'll explore `make` and `Makefile` using basic and advanced examples. Before you start, ensure that `make` is installed in your system. - -### Basic examples - -Let's start by printing the classic "Hello World" on the terminal. Create a empty directory `myproject` containing a file `Makefile` with this content: -``` -say_hello: - -        echo "Hello World" - -``` - -Now run the file by typing `make` inside the directory `myproject`. The output will be: -``` -$ make - -echo "Hello World" - -Hello World - -``` - -In the example above, `say_hello` behaves like a function name, as in any programming language. This is called the target. The prerequisites or dependencies follow the target. For the sake of simplicity, we have not defined any prerequisites in this example. The command `echo "Hello World"` is called the recipe. The recipe uses prerequisites to make a target. The target, prerequisites, and recipes together make a rule. - -To summarize, below is the syntax of a typical rule: -``` -target: prerequisites - - recipe - -``` - -As an example, a target might be a binary file that depends on prerequisites (source files). On the other hand, a prerequisite can also be a target that depends on other dependencies: -``` -final_target: sub_target final_target.c - -        Recipe_to_create_final_target - - - -sub_target: sub_target.c - -        Recipe_to_create_sub_target - -``` - -It is not necessary for the target to be a file; it could be just a name for the recipe, as in our example. We call these "phony targets." - -Going back to the example above, when `make` was executed, the entire command `echo "Hello World"` was displayed, followed by actual command output. We often don't want that. To suppress echoing the actual command, we need to start `echo` with `@`: -``` -say_hello: - -        @echo "Hello World" - -``` - -Now try to run `make` again. The output should display only this: -``` -$ make - -Hello World - -``` - -Let's add a few more phony targets: `generate` and `clean` to the `Makefile`: -``` -say_hello: -        @echo "Hello World" - -generate: -        @echo "Creating empty text files..." -        touch file-{1..10}.txt - -clean: -        @echo "Cleaning up..." -        rm *.txt -``` - -If we try to run `make` after the changes, only the target `say_hello` will be executed. That's because only the first target in the makefile is the default target. Often called the default goal, this is the reason you will see `all` as the first target in most projects. It is the responsibility of `all` to call other targets. We can override this behavior using a special phony target called `.DEFAULT_GOAL`. - -Let's include that at the beginning of our makefile: -``` -.DEFAULT_GOAL := generate -``` - -This will run the target `generate` as the default: -``` -$ make -Creating empty text files... -touch file-{1..10}.txt -``` - -As the name suggests, the phony target `.DEFAULT_GOAL` can run only one target at a time. This is why most makefiles include `all` as a target that can call as many targets as needed. - -Let's include the phony target `all` and remove `.DEFAULT_GOAL`: -``` -all: say_hello generate - -say_hello: -        @echo "Hello World" - -generate: -        @echo "Creating empty text files..." -        touch file-{1..10}.txt - -clean: -        @echo "Cleaning up..." -        rm *.txt -``` - -Before running `make`, let's include another special phony target, `.PHONY`, where we define all the targets that are not files. `make` will run its recipe regardless of whether a file with that name exists or what its last modification time is. Here is the complete makefile: -``` -.PHONY: all say_hello generate clean - -all: say_hello generate - -say_hello: -        @echo "Hello World" - -generate: -        @echo "Creating empty text files..." -        touch file-{1..10}.txt - -clean: -        @echo "Cleaning up..." -        rm *.txt -``` - -The `make` should call `say_hello` and `generate`: -``` -$ make -Hello World -Creating empty text files... -touch file-{1..10}.txt -``` - -It is a good practice not to call `clean` in `all` or put it as the first target. `clean` should be called manually when cleaning is needed as a first argument to `make`: -``` -$ make clean -Cleaning up... -rm *.txt -``` - -Now that you have an idea of how a basic makefile works and how to write a simple makefile, let's look at some more advanced examples. - -### Advanced examples - -#### Variables - -In the above example, most target and prerequisite values are hard-coded, but in real projects, these are replaced with variables and patterns. - -The simplest way to define a variable in a makefile is to use the `=` operator. For example, to assign the command `gcc` to a variable `CC`: -``` -CC = gcc -``` - -This is also called a recursive expanded variable, and it is used in a rule as shown below: -``` -hello: hello.c -    ${CC} hello.c -o hello -``` - -As you may have guessed, the recipe expands as below when it is passed to the terminal: -``` -gcc hello.c -o hello -``` - -Both `${CC}` and `$(CC)` are valid references to call `gcc`. But if one tries to reassign a variable to itself, it will cause an infinite loop. Let's verify this: -``` -CC = gcc -CC = ${CC} - -all: -    @echo ${CC} -``` - -Running `make` will result in: -``` -$ make -Makefile:8: *** Recursive variable 'CC' references itself (eventually).  Stop. -``` - -To avoid this scenario, we can use the `:=` operator (this is also called the simply expanded variable). We should have no problem running the makefile below: -``` -CC := gcc -CC := ${CC} - -all: -    @echo ${CC} -``` - -#### Patterns and functions - -The following makefile can compile all C programs by using variables, patterns, and functions. Let's explore it line by line: -``` -# Usage: -# make        # compile all binary -# make clean  # remove ALL binaries and objects - -.PHONY = all clean - -CC = gcc                        # compiler to use - -LINKERFLAG = -lm - -SRCS := $(wildcard *.c) -BINS := $(SRCS:%.c=%) - -all: ${BINS} - -%: %.o -        @echo "Checking.." -        ${CC} ${LINKERFLAG} $< -o $@ - -%.o: %.c -        @echo "Creating object.." -        ${CC} -c $< - -clean: -        @echo "Cleaning up..." -        rm -rvf *.o ${BINS} -``` - - * Lines starting with `#` are comments. - - * Line `.PHONY = all clean` defines phony targets `all` and `clean`. - - * Variable `LINKERFLAG` defines flags to be used with `gcc` in a recipe. - - * `SRCS := $(wildcard *.c)`: `$(wildcard pattern)` is one of the functions for filenames. In this case, all files with the `.c` extension will be stored in a variable `SRCS`. - - * `BINS := $(SRCS:%.c=%)`: This is called as substitution reference. In this case, if `SRCS` has values `'foo.c bar.c'`, `BINS` will have `'foo bar'`. - - * Line `all: ${BINS}`: The phony target `all` calls values in`${BINS}` as individual targets. - - * Rule: -``` -%: %.o -   @echo "Checking.." -   ${CC} ${LINKERFLAG} $< -o $@ -``` - -Let's look at an example to understand this rule. Suppose `foo` is one of the values in `${BINS}`. Then `%` will match `foo`(`%` can match any target name). Below is the rule in its expanded form: -``` -foo: foo.o -   @echo "Checking.." -   gcc -lm foo.o -o foo - -``` - -As shown, `%` is replaced by `foo`. `$<` is replaced by `foo.o`. `$<` is patterned to match prerequisites and `$@` matches the target. This rule will be called for every value in `${BINS}` - - * Rule: -``` -%.o: %.c -   @echo "Creating object.." -   ${CC} -c $< -``` - -Every prerequisite in the previous rule is considered a target for this rule. Below is the rule in its expanded form: -``` -foo.o: foo.c -  @echo "Creating object.." -  gcc -c foo.c -``` - - * Finally, we remove all binaries and object files in target `clean`. - - - - -Below is the rewrite of the above makefile, assuming it is placed in the directory having a single file `foo.c:` -``` -# Usage: -# make        # compile all binary -# make clean  # remove ALL binaries and objects - -.PHONY = all clean - -CC = gcc                        # compiler to use - -LINKERFLAG = -lm - -SRCS := foo.c -BINS := foo - -all: foo - -foo: foo.o -        @echo "Checking.." -        gcc -lm foo.o -o foo - -foo.o: foo.c -        @echo "Creating object.." -        gcc -c foo.c - -clean: -        @echo "Cleaning up..." -        rm -rvf foo.o foo -``` - -For more on makefiles, refer to the [GNU Make manual][1], which offers a complete reference and examples. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/what-how-makefile - -作者:[Sachin Patil][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/psachin -[1]:https://www.gnu.org/software/make/manual/make.pdf diff --git a/translated/tech/20180822 What is a Makefile and how does it work.md b/translated/tech/20180822 What is a Makefile and how does it work.md new file mode 100644 index 0000000000..b2996ec35d --- /dev/null +++ b/translated/tech/20180822 What is a Makefile and how does it work.md @@ -0,0 +1,322 @@ +Makefile及其工作原理 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_liberate%20docs_1109ay.png?itok=xQOLreya) +当你在一些源文件改变后需要运行或更新一个任务时,make工具通常会被用到。make工具需要读取Makefile(或makefile)文件,在该文件中定义了一系列需要执行的任务。make可以用来将源代码编译为可执行程序。大部分开源项目会使用make来实现二进制文件的编译,然后使用make istall命令来执行安装。 + +本文将通过一些基础和进阶的示例来展示make和Makefile的使用方法。在开始前,请确保你的系统中安装了make。 + +### 基础示例 + +依然从打印“Hello World”开始。首先创建一个名字为myproject的目录,目录下新建Makefile文件,文件内容为: +``` +say_hello: + +        echo "Hello World" + +``` + +在myproject目录下执行make,会有如下输出: +``` +$ make + +echo "Hello World" + +Hello World + +``` + +在上面的例子中,“say_hello”类似于其他编程语言中的函数名。在此可以成为target。在target之后的是预置条件和依赖。为了简单期间,我们在示例中没有定义预置条件。“echo ‘Hello World'"命令被称为recipe。recipe基于预置条件来实现target。target、预置条件和recipe共同构成一个规则。 + +总结一下,一个典型的规则的语法为: +``` +target: 预置条件 + + recipe + +``` + +在示例中,target是一个基于源代码这个预置条件的二进制文件。另外,在另一规则中,这个预置条件也可以是依赖其他预置条件的target。 +``` +final_target: sub_target final_target.c + +        Recipe_to_create_final_target + + + +sub_target: sub_target.c + +        Recipe_to_create_sub_target + +``` + +target不要求是一个文件,也可以只是方便recipe使用的名字。我们称之为伪target。 + +再回到上面的示例中,当make被执行时,整条指令‘echo "Hello World"’都被打印出来,之后才是真正的执行结果。如果不希望指令本身被打印处理,需要在echo前添加@。 +``` +say_hello: + +        @echo "Hello World" + +``` + +重新运行make,将会只有如下输出: +``` +$ make + +Hello World + +``` + +接下来在Makefile中添加如下伪target:generate和clean: +``` +say_hello: +        @echo "Hello World" + +generate: +        @echo "Creating empty text files..." +        touch file-{1..10}.txt + +clean: +        @echo "Cleaning up..." +        rm *.txt +``` + +随后当我们运行make时,只有‘say_hello’这个target被执行。这是因为makefile中的默认target为第一个target。通常情况下只有默认的target会被调用,大多数项目会将“all”作为默认target。“all”负责来调用其他的target。我们可以通过.DEFAULT_GOAL这个特殊的伪target来覆盖掉默认的行为。 + +在makefile文件开头增加.DEFAULT_GOAL: +``` +.DEFAULT_GOAL := generate +``` + +make会将generate作为默认target: +``` +$ make +Creating empty text files... +touch file-{1..10}.txt +``` + +顾名思义,.DEFAULT_GOAL伪target仅能定义一个target。这就是为什么很多项目仍然会有all这个target。这样可以保证多个target的实现。 + +下面删除掉.DEFAULT_GOAL,增加all target: +``` +all: say_hello generate + +say_hello: +        @echo "Hello World" + +generate: +        @echo "Creating empty text files..." +        touch file-{1..10}.txt + +clean: +        @echo "Cleaning up..." +        rm *.txt +``` + +运行之前,我们再增加一些特殊的伪target。.PHONY用来定义这些不是file的target。make会默认调用这写伪target下的recipe,而不去检查文件是否存在或最后修改日期。完整的makefile如下: +``` +.PHONY: all say_hello generate clean + +all: say_hello generate + +say_hello: +        @echo "Hello World" + +generate: +        @echo "Creating empty text files..." +        touch file-{1..10}.txt + +clean: +        @echo "Cleaning up..." +        rm *.txt +``` + +make命令会调用say_hello和generate: +``` +$ make +Hello World +Creating empty text files... +touch file-{1..10}.txt +``` + +clean不应该被放入all中,或者被放入第一个target。clean应当在需要清理时手动调用,调用方法为make clean。 +``` +$ make clean +Cleaning up... +rm *.txt +``` + +现在你应该已经对makefile有了基础的了解,接下来我们看一些进阶的示例。 + +### 进阶示例 + +#### 变量 + +在之前的实例中,大部分target和预置条件是已经固定了的,但在实际项目中,它们通常用变量和模式来代替。 + +定义变量最简单的方式是使用‘=’操作符。例如,将命令gcc赋值给变量CC: +``` +CC = gcc +``` + +这被称为递归扩展变量,用于如下所示的规则中: +``` +hello: hello.c +    ${CC} hello.c -o hello +``` + +你可能已经想到了,recipe将会在传递给终端时展开为: +``` +gcc hello.c -o hello +``` + +${CC}和$(CC)都能对gcc进行引用。但如果一个变量尝试将它本身赋值给自己,将会造成死循环。让我们验证一下: +``` +CC = gcc +CC = ${CC} + +all: +    @echo ${CC} +``` + +此时运行make会导致: +``` +$ make +Makefile:8: *** Recursive variable 'CC' references itself (eventually).  Stop. +``` + +为了避免这种情况发生,可以使用“:=”操作符(这被称为简单扩展变量)。以下代码不会造成上述问题: +``` +CC := gcc +CC := ${CC} + +all: +    @echo ${CC} +``` + +#### 模式和函数 + +下面的makefile使用了变量、模式和函数来实现所有C代码的编译。我们来逐行分析下: +``` +# Usage: +# make        # compile all binary +# make clean  # remove ALL binaries and objects + +.PHONY = all clean + +CC = gcc                        # compiler to use + +LINKERFLAG = -lm + +SRCS := $(wildcard *.c) +BINS := $(SRCS:%.c=%) + +all: ${BINS} + +%: %.o +        @echo "Checking.." +        ${CC} ${LINKERFLAG} $< -o $@ + +%.o: %.c +        @echo "Creating object.." +        ${CC} -c $< + +clean: +        @echo "Cleaning up..." +        rm -rvf *.o ${BINS} +``` + + * 以“#”开头的行是评论。 + + * `.PHONY = all clean` 定义了“all”和“clean”两个伪代码。 + + * 变量`LINKERFLAG` recipe中gcc命令需要用到的参数。 + + * `SRCS := $(wildcard *.c)`: `$(wildcard pattern)` 是与文件名相关的一个函数。在本示例中,所有“.c"后缀的文件会被存入“SRCS”变量。 + + * `BINS := $(SRCS:%.c=%)`: 这被称为替代引用。本例中,如果“SRCS”的值为“'foo.c bar.c'”,则“BINS”的值为“'foo bar'”。 + + * Line `all: ${BINS}`: 伪target “all”调用“${BINS}”变量中的所有值作为子target。 + + * 规则: +``` +%: %.o +   @echo "Checking.." +   ${CC} ${LINKERFLAG} $< -o $@ +``` + +下面通过一个示例来理解这条规则。假定“foo”是变量“${BINS}”中的一个值。“%”会匹配到“foo”(“%”匹配任意一个target)。下面是规则展开后的内容: +``` +foo: foo.o +   @echo "Checking.." +   gcc -lm foo.o -o foo + +``` + +如上所示,“%”被“foo”替换掉了。“$<”被“foo.o”替换掉。“$<”用于匹配预置条件,`$@`匹配target。对“${BINS}”中的每个值,这条规则都会被调用一遍。 + + * 规则: +``` +%.o: %.c +   @echo "Creating object.." +   ${CC} -c $< +``` + +之前规则中的每个预置条件在这条规则中都会都被作为一个target。下面是展开后的内容: +``` +foo.o: foo.c +  @echo "Creating object.." +  gcc -c foo.c +``` + + * 最后,在target “clean”中,所有的而简直文件和编译文件将被删除。 + + + + +下面是重写后的makefile,该文件应该被放置在一个有foo.c文件的目录下: +``` +# Usage: +# make        # compile all binary +# make clean  # remove ALL binaries and objects + +.PHONY = all clean + +CC = gcc                        # compiler to use + +LINKERFLAG = -lm + +SRCS := foo.c +BINS := foo + +all: foo + +foo: foo.o +        @echo "Checking.." +        gcc -lm foo.o -o foo + +foo.o: foo.c +        @echo "Creating object.." +        gcc -c foo.c + +clean: +        @echo "Cleaning up..." +        rm -rvf foo.o foo +``` + +关于makefiles的更多信息,[GNU Make manual][1]提供了更完整的说明和实例。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/what-how-makefile + +作者:[Sachin Patil][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[Zafiry](https://github.com/zafiry) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/psachin +[1]:https://www.gnu.org/software/make/manual/make.pdf From 243efe0b21c68a37d44628e501966c6fff18c420 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 10 Sep 2018 13:09:18 +0800 Subject: [PATCH 150/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Limit?= =?UTF-8?q?=20Network=20Bandwidth=20In=20Linux=20Using=20Wondershaper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...k Bandwidth In Linux Using Wondershaper.md | 196 ++++++++++++++++++ 1 file changed, 196 insertions(+) create mode 100644 sources/tech/20180906 How To Limit Network Bandwidth In Linux Using Wondershaper.md diff --git a/sources/tech/20180906 How To Limit Network Bandwidth In Linux Using Wondershaper.md b/sources/tech/20180906 How To Limit Network Bandwidth In Linux Using Wondershaper.md new file mode 100644 index 0000000000..11d266e163 --- /dev/null +++ b/sources/tech/20180906 How To Limit Network Bandwidth In Linux Using Wondershaper.md @@ -0,0 +1,196 @@ +How To Limit Network Bandwidth In Linux Using Wondershaper +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Wondershaper-1-720x340.jpg) + +This tutorial will help you to easily limit network bandwidth and shape your network traffic in Unix-like operating systems. By limiting the network bandwidth usage, you can save unnecessary bandwidth consumption’s by applications, such as package managers (pacman, yum, apt), web browsers, torrent clients, download managers etc., and prevent the bandwidth abuse by a single or multiple users in the network. For the purpose of this tutorial, we will be using a command line utility named **Wondershaper**. Trust me, it is not that hard as you may think. It is one of the easiest and quickest way ever I have come across to limit the Internet or local network bandwidth usage in your own Linux system. Read on. + +Please be mindful that the aforementioned utility can only limit the incoming and outgoing traffic of your local network interfaces, not the interfaces of your router or modem. In other words, Wondershaper will only limit the network bandwidth in your local system itself, not any other systems in the network. These utility is mainly designed for limiting the bandwidth of one or more network adapters in your local system. Hope you got my point. + +Let us see how to use Wondershaper to shape the network traffic. + +### Limit Network Bandwidth In Linux Using Wondershaper + +**Wondershaper** is simple script used to limit the bandwidth of your system’s network adapter(s). It limits the bandwidth iproute’s tc command, but greatly simplifies its operation. + +**Installing Wondershaper** + +To install the latest version, git clone wondershaoer repository: + +``` +$ git clone https://github.com/magnific0/wondershaper.git + +``` + +Go to the wondershaper directory and install it as show below + +``` +$ cd wondershaper + +$ sudo make install + +``` + +And, run the following command to start wondershaper service automatically on every reboot. + +``` +$ sudo systemctl enable wondershaper.service + +$ sudo systemctl start wondershaper.service + +``` + +You can also install using your distribution’s package manager (official or non-official) if you don’t mind the latest version. + +Wondershaper is available in [**AUR**][1], so you can install it in Arch-based systems using AUR helper programs such as [**Yay**][2]. + +``` +$ yay -S wondershaper-git + +``` + +On Debian, Ubuntu, Linux Mint: + +``` +$ sudo apt-get install wondershaper + +``` + +On Fedora: + +``` +$ sudo dnf install wondershaper + +``` + +On RHEL, CentOS, enable EPEL repository and install wondershaper as shown below. + +``` +$ sudo yum install epel-release + +$ sudo yum install wondershaper + +``` + +Finally, start wondershaper service automatically on every reboot. + +``` +$ sudo systemctl enable wondershaper.service + +$ sudo systemctl start wondershaper.service + +``` + +**Usage** + +First, find the name of your network interface. Here are some common ways to find the details of a network card. + +``` +$ ip addr + +$ route + +$ ifconfig + +``` + +Once you find the network card name, you can limit the bandwidth rate as shown below. + +``` +$ sudo wondershaper -a -d -u + +``` + +For instance, if your network card name is **enp0s8** and you wanted to limit the bandwidth to **1024 Kbps** for **downloads** and **512 kbps** for **uploads** , the command would be: + +``` +$ sudo wondershaper -a enp0s8 -d 1024 -u 512 + +``` + +Where, + + * **-a** : network card name + * **-d** : download rate + * **-u** : upload rate + + + +To clear the limits from a network adapter, simply run: + +``` +$ sudo wondershaper -c -a enp0s8 + +``` + +Or + +``` +$ sudo wondershaper -c enp0s8 + +``` + +Just in case, there are more than one network card available in your system, you need to manually set the download/upload rates for each network interface card as described above. + +If you have installed Wondershaper by cloning its GitHub repository, there is a configuration named **wondershaper.conf** exists in **/etc/conf.d/** location. Make sure you have set the download or upload rates by modifying the appropriate values(network card name, download/upload rate) in this file. + +``` +$ sudo nano /etc/conf.d/wondershaper.conf + +[wondershaper] +# Adapter +# +IFACE="eth0" + +# Download rate in Kbps +# +DSPEED="2048" + +# Upload rate in Kbps +# +USPEED="512" + +``` + +Here is the sample before Wondershaper: + +After enabling Wondershaper: + +As you can see, the download rate has been tremendously reduced after limiting the bandwidth using WOndershaper in my Ubuntu 18.o4 LTS server. + +For more details, view the help section by running the following command: + +``` +$ wondershaper -h + +``` + +Or, refer man pages. + +``` +$ man wondershaper + +``` + +As far as tested, Wondershaper worked just fine as described above. Give it a try and let us know what do you think about this utility. + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned. + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-limit-network-bandwidth-in-linux-using-wondershaper/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://aur.archlinux.org/packages/wondershaper-git/ +[2]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ From 702baeacb850e0a71a5a31c804190797d53e4a6a Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 10 Sep 2018 13:11:22 +0800 Subject: [PATCH 151/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20Use=20?= =?UTF-8?q?the=20Netplan=20Network=20Configuration=20Tool=20on=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...lan Network Configuration Tool on Linux.md | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 sources/tech/20180907 How to Use the Netplan Network Configuration Tool on Linux.md diff --git a/sources/tech/20180907 How to Use the Netplan Network Configuration Tool on Linux.md b/sources/tech/20180907 How to Use the Netplan Network Configuration Tool on Linux.md new file mode 100644 index 0000000000..9ba21a367f --- /dev/null +++ b/sources/tech/20180907 How to Use the Netplan Network Configuration Tool on Linux.md @@ -0,0 +1,229 @@ +How to Use the Netplan Network Configuration Tool on Linux +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/netplan.jpg?itok=Gu_ZfNGa) + +For years Linux admins and users have configured their network interfaces in the same way. For instance, if you’re a Ubuntu user, you could either configure the network connection via the desktop GUI or from within the /etc/network/interfaces file. The configuration was incredibly easy and never failed to work. The configuration within that file looked something like this: + +``` +auto enp10s0 + +iface enp10s0 inet static + +address 192.168.1.162 + +netmask 255.255.255.0 + +gateway 192.168.1.100 + +dns-nameservers 1.0.0.1,1.1.1.1 + +``` + +Save and close that file. Restart networking with the command: + +``` +sudo systemctl restart networking + +``` + +Or, if you’re not using a non-systemd distribution, you could restart networking the old fashioned way like so: + +``` +sudo /etc/init.d/networking restart + +``` + +Your network will restart and the newly configured interface is good to go. + +That’s how it’s been done for years. Until now. With certain distributions (such as Ubuntu Linux 18.04), the configuration and control of networking has changed considerably. Instead of that interfaces file and using the /etc/init.d/networking script, we now turn to [Netplan][1]. Netplan is a command line utility for the configuration of networking on certain Linux distributions. Netplan uses YAML description files to configure network interfaces and, from those descriptions, will generate the necessary configuration options for any given renderer tool. + +I want to show you how to use Netplan on Linux, to configure a static IP address and a DHCP address. I’ll be demonstrating on Ubuntu Server 18.04. I will give you one word of warning, the .yaml files you create for Netplan must be consistent in spacing, otherwise they’ll fail to work. You don’t have to use a specific spacing for each line, it just has to remain consistent. + +### The new configuration files + +Open a terminal window (or log into your Ubuntu Server via SSH). You will find the new configuration files for Netplan in the /etc/netplan directory. Change into that directory with the command cd /etc/netplan. Once in that directory, you will probably only see a single file: + +``` +01-netcfg.yaml + +``` + +You can create a new file or edit the default. If you opt to edit the default, I suggest making a copy with the command: + +``` +sudo cp /etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml.bak + +``` + +With your backup in place, you’re ready to configure. + +### Network Device Name + +Before you configure your static IP address, you’ll need to know the name of device to be configured. To do that, you can issue the command ip a and find out which device is to be used (Figure 1). + +![netplan][3] + +Figure 1: Finding our device name with the ip a command. + +[Used with permission][4] + +I’ll be configuring ens5 for a static IP address. + +### Configuring a Static IP Address + +Open the original .yaml file for editing with the command: + +``` +sudo nano /etc/netplan/01-netcfg.yaml + +``` + +The layout of the file looks like this: + +network: + +Version: 2 + +Renderer: networkd + +ethernets: + +DEVICE_NAME: + +Dhcp4: yes/no + +Addresses: [IP/NETMASK] + +Gateway: GATEWAY + +Nameservers: + +Addresses: [NAMESERVER, NAMESERVER] + +Where: + + * DEVICE_NAME is the actual device name to be configured. + + * yes/no is an option to enable or disable dhcp4. + + * IP is the IP address for the device. + + * NETMASK is the netmask for the IP address. + + * GATEWAY is the address for your gateway. + + * NAMESERVER is the comma-separated list of DNS nameservers. + + + + +Here’s a sample .yaml file: + +``` +network: + + version: 2 + + renderer: networkd + + ethernets: + + ens5: + + dhcp4: no + + addresses: [192.168.1.230/24] + + gateway4: 192.168.1.254 + + nameservers: + + addresses: [8.8.4.4,8.8.8.8] + +``` + +Edit the above to fit your networking needs. Save and close that file. + +Notice the netmask is no longer configured in the form 255.255.255.0. Instead, the netmask is added to the IP address. + +### Testing the Configuration + +Before we apply the change, let’s test the configuration. To do that, issue the command: + +``` +sudo netplan try + +``` + +The above command will validate the configuration before applying it. If it succeeds, you will see Configuration accepted. In other words, Netplan will attempt to apply the new settings to a running system. Should the new configuration file fail, Netplan will automatically revert to the previous working configuration. Should the new configuration work, it will be applied. + +### Applying the New Configuration + +If you are certain of your configuration file, you can skip the try option and go directly to applying the new options. The command for this is: + +``` +sudo netplan apply + +``` + +At this point, you can issue the command ip a to see that your new address configurations are in place. + +### Configuring DHCP + +Although you probably won’t be configuring your server for DHCP, it’s always good to know how to do this. For example, you might not know what static IP addresses are currently available on your network. You could configure the device for DHCP, get an IP address, and then reconfigure that address as static. + +To use DHCP with Netplan, the configuration file would look something like this: + +``` +network: + + version: 2 + + renderer: networkd + + ethernets: + + ens5: + + Addresses: [] + + dhcp4: true + + optional: true + +``` + +Save and close that file. Test the file with: + +``` +sudo netplan try + +``` + +Netplan should succeed and apply the DHCP configuration. You could then issue the ip a command, get the dynamically assigned address, and then reconfigure a static address. Or, you could leave it set to use DHCP (but seeing as how this is a server, you probably won’t want to do that). + +Should you have more than one interface, you could name the second .yaml configuration file 02-netcfg.yaml. Netplan will apply the configuration files in numerical order, so 01 will be applied before 02. Create as many configuration files as needed for your server. + +### That’s All There Is + +Believe it or not, that’s all there is to using Netplan. Although it is a significant change to how we’re accustomed to configuring network addresses, it’s not all that hard to get used to. But this style of configuration is here to stay… so you will need to get used to it. + +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/2018/9/how-use-netplan-network-configuration-tool-linux + +作者:[Jack Wallen][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/jlwallen +[1]: https://netplan.io/ +[3]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/netplan_1.jpg?itok=XuIsXWbV (netplan) +[4]: /licenses/category/used-permission +[5]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From e0256b23307eae1cc8877ad857fe046ccfe92fac Mon Sep 17 00:00:00 2001 From: feng lv Date: Mon, 10 Sep 2018 13:54:12 +0800 Subject: [PATCH 152/455] translated --- ...reat Python libraries for side projects.md | 68 ------------------- ...reat Python libraries for side projects.md | 66 ++++++++++++++++++ 2 files changed, 66 insertions(+), 68 deletions(-) delete mode 100644 sources/tech/20180905 8 great Python libraries for side projects.md create mode 100644 translated/tech/20180905 8 great Python libraries for side projects.md diff --git a/sources/tech/20180905 8 great Python libraries for side projects.md b/sources/tech/20180905 8 great Python libraries for side projects.md deleted file mode 100644 index 3623c37c6d..0000000000 --- a/sources/tech/20180905 8 great Python libraries for side projects.md +++ /dev/null @@ -1,68 +0,0 @@ -ucasFL translating - -8 great Python libraries for side projects -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd) - -We have a saying in the Python/Django world: We came for the language and stayed for the community. That is true for most of us, but something else that has kept us in the Python world is how easy it is to have an idea and quickly work through it over lunch or in a few hours at night. - -This month we're diving into Python libraries we love to use to quickly scratch those side-project or lunchtime itches. - -### To save data in a database on the fly: Dataset - -[Dataset][1] is our go-to library when we quickly want to collect data and save it into a database before we know what our final database tables will look like. Dataset has a simple, yet powerful API that makes it easy to put data in and sort it out later. - -Dataset is built on top of SQLAlchemy, so extending it will feel familiar. The underlying database models are a breeze to import into Django using Django's built-in [inspectdb][2] management command. This makes working with existing databases pretty painless. - -### To scrape data from web pages: Beautiful Soup - -[Beautiful Soup][3] (BS4 as of this writing) makes extracting information out of HTML pages easy. It's our go-to anytime we need to turn unstructured or loosely structured HTML into structured data. It's also great for working with XML data that might otherwise not be readable. - -### To work with HTTP content: Requests - -[Requests][4] is arguably one of the gold standard libraries for working with HTTP content. Anytime we need to consume an HTML page or even an API, Requests has us covered. It's also very well documented. - -### To write command-line utilities: Click - -When we need to write a native Python script, [Click][5] is our favorite library for writing command-line utilities. The API is straightforward, well thought out, and there are only a few patterns to remember. The docs are great, which makes looking up advanced features easy. - -### To name things: Python Slugify - -As we all know, naming things is hard. [Python Slugify][6] is a useful library for turning a title or description into a unique(ish) identifier. If you are working on a web project and you want to use SEO-friendly URLs, Python Slugify makes this easier. - -### To work with plugins: Pluggy - -[Pluggy][7] is relatively new, but it's also one of the best and easiest ways to add a plugin system to your existing application. If you have ever worked with pytest, you have used pluggy without knowing it. - -### To convert CSV files into APIs: Datasette - -[Datasette][8], not to be confused with Dataset, is an amazing tool for easily turning CSV files into full-featured read-only REST JSON APIs. Datasette has tons of features, including charting and geo (for creating interactive maps), and it's easy to deploy via a container or third-party web host. - -### To handle environment variables and more: Envparse - -If you need to parse environment variables because you don't want to save API keys, database credentials, or other sensitive information in your source code, then [envparse][9] is one of your best bets. Envparse handles environment variables, ENV files, variable types, and even pre- and post-processors (in case you want to ensure that a variable is always upper or lower case, for instance). - -Do you have a favorite Python library for side projects that's not on this list? Please share it in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/python-libraries-side-projects - -作者:[Jeff Triplett][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/laceynwilliams -[1]: https://dataset.readthedocs.io/en/latest/ -[2]: https://docs.djangoproject.com/en/2.1/ref/django-admin/#django-admin-inspectdb -[3]: https://www.crummy.com/software/BeautifulSoup/ -[4]: http://docs.python-requests.org/ -[5]: http://click.pocoo.org/5/ -[6]: https://github.com/un33k/python-slugify -[7]: https://pluggy.readthedocs.io/en/latest/ -[8]: https://github.com/simonw/datasette -[9]: https://github.com/rconradharris/envparse diff --git a/translated/tech/20180905 8 great Python libraries for side projects.md b/translated/tech/20180905 8 great Python libraries for side projects.md new file mode 100644 index 0000000000..26eb3e9a23 --- /dev/null +++ b/translated/tech/20180905 8 great Python libraries for side projects.md @@ -0,0 +1,66 @@ +8 个用于业余项目side projects的优秀 Python 库 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd) + +在 Python/Django 的世界里有这样一个谚语:为语言而来,为社区而留。对绝大多数人来说的确是这样的,但是,还有一件事情使得我们一直停留在 Python 的世界里,不愿离开,那就是我们可以很容易地利用一顿午餐或晚上几个小时的时间,把一个想法快速地实现出来。 + +这个月,我们来探讨一些我们喜欢用来快速完成业余项目side projects或打发午餐时间的 Python 库。 + +### 在数据库中即时保存数据:Dataset + +当我们想要在不知道最终数据库表长什么样的情况下,快速收集数据并保存到数据库中的时候,[Dataset][1] 库将是我们的最佳选择。Dataset 库有一个简单但功能强大的 API,因此我们可以很容易的把数据保存下来,之后再进行排序。 + +Dataset 建立在 SQLAlchemy 之上,所以如果需要对它进行扩展,你会感到非常熟悉。使用 Django 内建的 [inspectdb][2] 管理命令可以很容易地把底层数据库模型导入 Django 中,这使得和现有数据库一同工作不会出现任何障碍。 + +### 从网页抓取数据:Beautiful Soup + +[Beautiful Soup][3](一般写作 BS4)库使得从 HTML 网页中提取信息变得非常简单。当我们需要把非结构化或弱结构化的 HTML 转换为结构化数据的时候,就需要使用 Beautiful Soup 。用它来处理 XML 数据也是一个很好的选择,否则 XML 的可读性或许会很差。 + +### 和 HTTP 内容打交道:Requests + +当需要和 HTTP 内容打交道的时候,[Requests][4] 毫无疑问是最好的标准库。当我们想要抓取 HTML 网页或连接 API 的时候,都离不开 Requests 库。同时,它也有很好的文档。 + +### 编写命令行工具:Click + +当需要写一个简单的 Python 脚本作为命令行工具的时候,[Click][5] 是我最喜欢用的库。它的 API 非常直观,并且在实现时经过了深思熟虑,我们只需要记住很少的几个模式。它的文档也很优秀,这使得学习其高级特性更加容易。 + +### 对事物命名:Python Slugify + +众所周知,命名是一件困难的事情。[Python Slugify][6] 是一个非常有用的库,它可以把一个标题或描述转成一个带有特性的唯一标识符。如果你正在做一个 Web 项目,并且你想要使用对搜索引擎优化友好SEO-friendly的链接,那么,使用 Python Slugify 可以让这件事变得很容易。 + +### 和插件打交道:Pluggy + +[Pluggy][7] 库相对较新,但是如果你想添加一个插件系统到现有应用中,那么使用 Pluggy 是最好也是最简单的方式。如果你使用过 pytest,那么实际上相当于已经使用过 Pluggy 了,虽然你还不知道它。 + +### 把 CSV 文件转换到 API 中:DataSette + +[DataSette][8] 是一个神奇的工具,它可以很容易地把 CSV 文件转换进全特性只读 REST JSON API,同时,不要把它和 Dataset 库混淆。Datasette 有许多特性,包括创建图表和 geo(用于创建交互式图表),并且很容易通过容器或第三方网络主机进行部署。 + +### 处理环境变量等:Envparse + +如果你不想在源代码中保存 API 密钥、数据库凭证或其他敏感信息,那么你便需要解析环境变量,这时候 [envparse][9] 是最好的选择。Envparse 能够处理环境变量、ENV 文件、变量类型,甚至还可以进行预处理和后处理(例如,你想要确保变量名总是大写或小写的) + +有什么你最喜欢的用于业余项目side projects的 Python 库不在这个列表中吗?请在评论中和我们分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/python-libraries-side-projects + +作者:[Jeff Triplett][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[ucasFL](https://github.com/ucasFL) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/laceynwilliams +[1]: https://dataset.readthedocs.io/en/latest/ +[2]: https://docs.djangoproject.com/en/2.1/ref/django-admin/#django-admin-inspectdb +[3]: https://www.crummy.com/software/BeautifulSoup/ +[4]: http://docs.python-requests.org/ +[5]: http://click.pocoo.org/5/ +[6]: https://github.com/un33k/python-slugify +[7]: https://pluggy.readthedocs.io/en/latest/ +[8]: https://github.com/simonw/datasette +[9]: https://github.com/rconradharris/envparse From f36fa0e18daf890bddedfe151ed3ee3c0f484915 Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Mon, 10 Sep 2018 14:16:37 +0800 Subject: [PATCH 153/455] translated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6个开源工具制作自己的VPN --- ...en source tools for making your own VPN.md | 110 -------------- ...en source tools for making your own VPN.md | 137 ++++++++++++++++++ 2 files changed, 137 insertions(+), 110 deletions(-) delete mode 100644 sources/tech/20180831 6 open source tools for making your own VPN.md create mode 100644 translated/tech/20180831 6 open source tools for making your own VPN.md diff --git a/sources/tech/20180831 6 open source tools for making your own VPN.md b/sources/tech/20180831 6 open source tools for making your own VPN.md deleted file mode 100644 index ce8b27dcb1..0000000000 --- a/sources/tech/20180831 6 open source tools for making your own VPN.md +++ /dev/null @@ -1,110 +0,0 @@ -heguangzhi Translating - -6 open source tools for making your own VPN -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/vpn_scrabble_networking.jpg?itok=pdsUHw5N) - -If you want to try your hand at building your own VPN but aren’t sure where to start, you’ve come to the right place. I’ll compare six of the best free and open source tools to set up and use a VPN on your own server. These VPNs work whether you want to set up a site-to-site VPN for your business or just create a remote access proxy to unblock websites and hide your internet traffic from ISPs. - -Which is best depends on your needs and limitations, so take into consideration your own technical expertise, environment, and what you want to achieve with your VPN. In particular, consider the following factors: - - * VPN protocol - * Number of clients and types of devices - * Server distro compatibility - * Technical expertise required - - - -### Algo - -[Algo][1] was designed from the bottom up to create VPNs for corporate travelers who need a secure proxy to the internet. It “includes only the minimal software you need,” meaning you sacrifice extensibility for simplicity. Algo is based on StrongSwan but cuts out all the things that you don’t need, which has the added benefit of removing security holes that a novice might otherwise not notice. - -As an added bonus, it even blocks ads! - -Algo supports only the IKEv2 protocol and Wireguard. Because IKEv2 support is built into most devices these days, it doesn’t require a client app like OpenVPN. Algo can be deployed using Ansible on Ubuntu (the preferred option), Windows, RedHat, CentOS, and FreeBSD. Setup is automated using Ansible, which configures the server based on your answers to a short set of questions. It’s also very easy to tear down and re-deploy on demand. - -Algo is probably the easiest and fastest VPN to set up and deploy on this list. It’s extremely tidy and well thought out. If you don’t need any of the more advanced features offered by other tools and just need a secure proxy, it’s a great option. Note that Algo explicitly states it’s not meant for geo-unblocking or evading censorship, and was primarily designed for confidentiality. - -### Streisand - -[Streisand][2] can be installed on any Ubuntu 16.04 server using a single command; the process takes about 10 minutes. It supports L2TP, OpenConnect, OpenSSH, OpenVPN, Shadowsocks, Stunnel, Tor bridge, and WireGuard. Depending on which protocol you choose, you may need to install a client app. - -In many ways, Streisand is similar to Algo, but it offers more protocols and customization. This takes a bit more effort to manage and secure but is also more flexible. Note Streisand does not support IKEv2. I would say Streisand is more effective for bypassing censorship in places like China and Turkey due to its versatility, but Algo is easier and faster to set up. - -The setup is automated using Ansible, so there’s not much technical expertise required. You can easily add more users by sending them custom-generated connection instructions, which include an embedded copy of the server’s SSL certificate. - -Tearing down Streisand is a quick and painless process, and you can re-deploy on demand. - -### OpenVPN - -[OpenVPN][3] requires both client and server applications to set up VPN connections using the protocol of the same name. OpenVPN can be tweaked and customized to fit your needs, but it also requires the most technical expertise of the tools covered here. Both remote access and site-to-site configurations are supported; the former is what you’ll need if you plan on using your VPN as a proxy to the internet. Because client apps are required to use OpenVPN on most devices, the end user must keep them updated. - -Server-side, you can opt to deploy in the cloud or on your Linux server. Compatible distros include CentOS, Ubuntu, Debian, and openSUSE. Client apps are available for Windows, MacOS, iOS, and Android, and there are unofficial apps for other devices. Enterprises can opt to set up an OpenVPN Access Server, but that’s probably overkill for individuals, who will want the Community Edition. - -OpenVPN is relatively easy to configure with static key encryption, but it isn’t all that secure. Instead, I recommend setting it up with [easy-rsa][4], a key management package you can use to set up a public key infrastructure. This allows you to connect multiple devices at a time and protect them with perfect forward secrecy, among other benefits. OpenVPN uses SSL/TLS for encryption, and you can specify DNS servers in your configuration. - -OpenVPN can traverse firewalls and NAT firewalls, which means you can use it to bypass gateways and firewalls that might otherwise block the connection. It supports both TCP and UDP transports. - -### StrongSwan - -You might have come across a few different VPN tools with “Swan” in the name. FreeS/WAN, OpenSwan, LibreSwan, and [strongSwan][5] are all forks of the same project, and the lattermost is my personal favorite. Server-side, strongSwan runs on Linux 2.6, 3.x, and 4x kernels, Android, FreeBSD, macOS, iOS, and Windows. - -StrongSwan uses the IKEv2 protocol and IPSec. Compared to OpenVPN, IKEv2 connects much faster while offering comparable speed and security. This is useful if you prefer a protocol that doesn’t require installing an additional app on the client, as most newer devices manufactured today natively support IKEv2, including Windows, MacOS, iOS, and Android. - -StrongSwan is not particularly easy to use, and despite decent documentation, it uses a different vocabulary than most other tools, which can be confusing. Its modular design makes it great for enterprises, but that also means it’s not the most streamlined. It’s certainly not as straightforward as Algo or Streisand. - -Access control can be based on group memberships using X.509 attribute certificates, a feature unique to strongSwan. It supports EAP authentication methods for integration into other environments like Windows Active Directory. StrongSwan can traverse NAT firewalls. - -### SoftEther - -[SoftEther][6] started out as a project by a graduate student at the University of Tsukuba in Japan. SoftEther VPN Server and VPN Bridge run on Windows, Linux, OSX, FreeBSD, and Solaris, while the client app works on Windows, Linux, and MacOS. VPN Bridge is mainly for enterprises that need to set up site-to-site VPNs, so individual users will just need the server and client programs to set up remote access. - -SoftEther supports the OpenVPN, L2TP, SSTP, and EtherIP protocols, but its own SoftEther protocol claims to be able to be immunized against deep packet inspection thanks to “Ethernet over HTTPS” camouflage. SoftEther also makes a few tweaks to reduce latency and increase throughput. Additionally, SoftEther includes a clone function that allows you to easily transition from OpenVPN to SoftEther. - -SoftEther can traverse NAT firewalls and bypass firewalls. On restricted networks that permit only ICMP and DNS packets, you can utilize SoftEther’s VPN over ICMP or VPN over DNS options to penetrate the firewall. SoftEther works with both IPv4 and IPv6. - -SoftEther is easier to set up than OpenVPN and strongSwan but is a bit more complicated than Streisand and Algo. - -### WireGuard - -[WireGuard][7] is the newest tool on this list; it's so new that it’s not even finished yet. That being said, it offers a fast and easy way to deploy a VPN. It aims to improve on IPSec by making it simpler and leaner like SSH. - -Like OpenVPN, WireGuard is both a protocol and a software tool used to deploy a VPN that uses said protocol. A key feature is “crypto key routing,” which associates public keys with a list of IP addresses allowed inside the tunnel. - -WireGuard is available for Ubuntu, Debian, Fedora, CentOS, MacOS, Windows, and Android. WireGuard works on both IPv4 and IPv6. - -WireGuard is much lighter than most other VPN protocols, and it transmits packets only when data needs to be sent. - -The developers say WireGuard should not yet be trusted because it hasn’t been fully audited yet, but you’re welcome to give it a spin. It could be the next big thing! - -### Homemade VPN vs. commercial VPN - -Making your own VPN adds a layer of privacy and security to your internet connection, but if you’re the only one using it, then it would be relatively easy for a well-equipped third party, such as a government agency, to trace activity back to you. - -Furthermore, if you plan to use your VPN to unblock geo-locked content, a homemade VPN may not be the best option. Since you’ll only be connecting from a single IP address, your VPN server is fairly easy to block. - -Good commercial VPNs don’t have these issues. With a provider like [ExpressVPN][8], you share the server’s IP address with dozens or even hundreds of other users, making it nigh-impossible to track a single user’s activity. You also get a huge range of hundreds or thousands of servers to choose from, so if one has been blacklisted, you can just switch to another. - -The tradeoff of a commercial VPN, however, is that you must trust the provider not to snoop on your internet traffic. Be sure to choose a reputable provider with a clear no-logs policy. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/open-source-tools-vpn - -作者:[Paul Bischoff][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: -[1]: https://blog.trailofbits.com/2016/12/12/meet-algo-the-vpn-that-works/ -[2]: https://github.com/StreisandEffect/streisand -[3]: https://openvpn.net/ -[4]: https://github.com/OpenVPN/easy-rsa -[5]: https://www.strongswan.org/ -[6]: https://www.softether.org/ -[7]: https://www.wireguard.com/ -[8]: https://www.comparitech.com/vpn/reviews/expressvpn/ diff --git a/translated/tech/20180831 6 open source tools for making your own VPN.md b/translated/tech/20180831 6 open source tools for making your own VPN.md new file mode 100644 index 0000000000..0ff7ad847e --- /dev/null +++ b/translated/tech/20180831 6 open source tools for making your own VPN.md @@ -0,0 +1,137 @@ +heguangzhi Translating + +6个开源工具制作自己的VPN +====== + + + + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/vpn_scrabble_networking.jpg?itok=pdsUHw5N) + +如果您想尝试建立您自己的 VPN,但是不确定从哪里开始,那么您来对地方了。我将挑选6个最好的免费和开源工具在您自己的服务器上搭建和使用 VPN。这些 VPN 软件不管您是想为您的企业建立站点到站点的,还是仅创建远程代理访问以解除访问限制,并隐藏来自ISP的互联网流量都可以得到解决。 + +根据您的需求和条件,并参考您自己的技术特长,环境以及您想要通过 VPN 实现的目标。需要考虑以下因素: + + * VPN 协议 + * 客户端的数量和设备类型 + * 服务端的兼容性 + * 技术专业的能力 + +### Algo + + +[Algo][1] 是从下往上的设计的,为需要互联网安全代理的企业创建 VPN 专用网。它“只包括您需要的最小化的软件”,这意味着您为了简单而牺牲了可扩展性。Algo 是基于 StrongSwan 的,但是删除了所有您不需要的东西,这有另外一个好处,那就是删除了新手可能不会注意到的安全漏洞。 + + +作为额外的奖励,它甚至屏蔽了广告! + +Algo supports only the IKEv2 protocol and Wireguard. Because IKEv2 support is built into most devices these days, it doesn’t require a client app like OpenVPN. Algo can be deployed using Ansible on Ubuntu (the preferred option), Windows, RedHat, CentOS, and FreeBSD. Setup is automated using Ansible, which configures the server based on your answers to a short set of questions. It’s also very easy to tear down and re-deploy on demand. + + +Algo 只支持 IKEv2 协议和 Wireguard 。因为 IKEv2 支持现在已经内置在大多数设备中,所以它不需要像 OpenVPN 这样的客户端应用程序。Algo 可以使用 Ansible 在 Ubuntu (首选选项)、Windows、RedHat、CentOS 和 FreeBSD 上部署。自动化的安装 Ansible,它根据您对一组简短问题的回答来配置服务。终止和重新部署也非常容易。 + + +Algo 可能是在本篇文章中安装和部署的最简单和最快的VPN。它非常简洁,考虑周全。如果您不需要其他工具提供的任何更高级的功能,只需要一个安全的代理,这是一个很好的选择。请注意,Algo 明确表示,它不是为了解除地理封锁或逃避审查,主要是为了加密。 + +### Streisand + + + +[Streisand][2] 可以使用一个命令安装在任何 Ubuntu 16.04 服务器上;这个过程大约需要10分钟。它支持 L2TP、OpenConnect、OpenSSH、OpenVPN、Shadowsocks、Stunnel、Tor bridge 和 WireGuard。根据您选择的协议,您可能需要安装客户端应用程序。 + + +在很多方面,Streisand 与 Algo 相似,但是它提供了更多的协议和定制。这需要更多的工作来管理和维护,但也更加灵活。注意 Streisand 不支持 IKEv2 。我认为 Streisand 在中国和土耳其这样的地方绕过审查制度更有效,因为它的多功能性,但是 Algo 更容易和更快地安装。 + + +使用 Ansible 可以自动化安装,所以不需要太多的专业技术知识。通过向用户发送自定义生成的连接指令,包括服务器 SSL 证书的嵌入副本,可以轻松添加更多用户。 + + +卸载 Streisand 是一个快速无痛的过程,您可以按需重新部署。 + +### OpenVPN + + +[OpenVPN][3] 要求客户端和服务器应用程序使用同名协议建立 VPN 连接。OpenVPN 可以根据您的需求进行调整和定制,但它也需要更多专业技术知识。支持远程访问和站点到站点配置;如果您计划使 VPN 作为互联网的代理,前者是您需要的。因为客户端应用程序需要在大多数设备上使用 OpenVPN ,最终用户必须保持更新。 + + +在服务器端,您可以选择部署在云中或 Linux 服务器上。兼容的发行版包括 CentOS 、Ubuntu 、Debian 和 openSUSE。Windows 、MacOS 、iOS 和 Android 都有客户端应用程序,其他设备也有非官方应用程序。企业可以选择设置一个 OpenVPN 接入服务器,但是对于想要社区版的个人来说,这可能太过分了。 + + +OpenVPN 相对容易配置静态密钥加密,但并不完全安全。相反,我建议使用 [easy-rsa][4] 来设置它,这是一个密钥管理包,可以用来设置公钥基础设施。这允许您一次连接多个设备,并以完美的前向保密和其他好处来保护它们。OpenVPN 使用 SSL/TLS 进行加密,您可以在配置中指定 DNS 服务器。 + + +OpenVPN 可以穿越防火墙和 NAT 防火墙,这意味着您可以使用它绕过网关和防火墙,否则它们可能会阻止连接。它同时支持 TCP 和 UDP 传输。 + +### StrongSwan + +您可能会遇到一些不同的 VPN 工具,名称中有“Swan”。FreeS/WAN, 、OpenSwan、LibreSwan和[strongSwan][5] 都是同一个项目的分叉,后者是我个人最喜欢的。服务器端,strongSwan 运行在 Linux 2.6、3.x和4x内核、Android、FreeBSD、macOS、iOS 和 Windows上。 + + +StrongSwan 使用 IKEv2 协议和 IPSec 。与 OpenVPN 相比,IKEv2 连接速度更快,同时提供了很好的速度和安全性。如果您更喜欢不需要在客户端安装额外应用程序的协议,这将非常有用,因为现在生产的大多数新设备都支持 IKEv2,,包括 Windows、MacOS、iOS和Android。 + +StrongSwan 并不特别容易使用,尽管文档不错,但它使用的词汇与大多数其他工具不同,这可能会让人比较困惑。它的模块化设计让它对企业来说很棒,但这也意味着它不是最精简。这当然不像 Algo 或Streisand 那么简单。 + + +访问控制可以基于使用X.509 属性证书的组成员身份,这是 strongSwan 独有的功能。它支持用于集成到其他环境(如Windows Active Directory )中的EAP身份验证方法。strongSwan可以穿越NAT 网络防火墙。 + +### SoftEther + + +[SoftEther][6] 是由日本筑波大学的一名研究生发起的一个项目。SoftEther VPN 服务器和 VPN网桥在 Windows、Linux、OSX、FreeBSD 和 Solaris 上运行,而客户端应用程序在Windows、Linux和 MacOS 上运行。VPN 网桥主要用于需要设置站点到站点VPN的企业,因此单个用户只需要服务器和客户端程序来设置远程访问。 + + +SoftEther 支持 OpenVPN、L2TP、SSTP 和 EtherIP 协议,由于“基于HTTPS的以太网”伪装,它自己的 SoftEther 协议声称能够免疫深度数据包检测。SoftEther 还做了一些调整,以减少延迟并增加吞吐量。此外,SoftEther 还包括一个克隆功能,允许您轻松地从 OpenVPN 过渡到SoftEther。 + +SoftEther 可以穿透 NAT 防火墙并绕过防火墙。在只允许 ICMP 和 DNS 数据包的受限网络上,您可以通过 ICMP 利用SoftEther的VPN 或者通过 DNS 利用 VPN 选项来穿透防火墙。SoftEther 可与IPv4 和IPv6 一起工作。 + + +SoftEther 比 OpenVPN 和strongSwan更容易设置,但比 Streisand 和 Algo 更复杂。 + +### WireGuard + + +[WireGuard][7] 是这个名单上最新的工具;它太新了,甚至还没有完成。也就是说,它为部署VPN提供了一种快速简便的方法。它旨在通过使 IPSec 更简单、更精简来改进它,就像SSH一样。 + +与OpenVPN一样,WireGuard 既是一种协议,也是一种软件工具,用于部署使用所述协议的VPN。一个关键特性是“加密密钥路由”,它将公钥与隧道内允许的 IP 地址列表相关联。 + + +WireGuard可用于 Ubuntu、Debian、Fedora、CentOS、MacOS、Windows 和安卓系统。WireGuard可在 IPv4和 IPv6 上工作。 + +WireGuard比大多数其他VPN协议轻得多,它只在需要发送数据时才发送数据包。 + + +开发人员说,WireGuard还不应该被信任,因为它还没有被完全审计过,但是欢迎你给它一个机会。这可能是下一件大事! + +### 自制 VPN vs. 商业 VPN + +制作您自己的 VPN 为您的互联网连接增加了一层隐私和安全,但是如果您是唯一一个使用它的人,那么装备精良的第三方,比如政府机构,将很容易追踪到你的活动。 + +此外,如果您计划使用您的 VPN 来解锁地理锁定的内容,自制的VPN可能不是最好的选择。因为您只能从一个IP地址连接,所以你的 VPN 服务器很容易被阻止。 + + +好的商业 VPN 不存在这些问题。有了像[ExpressVPN][8]这样的提供商,您可以与数十甚至数百个其他用户共享服务器的IP地址,这使得跟踪一个用户的活动几乎变得不可能。您也可以从成百上千的服务器中选择,所以如果其中一台被列入黑名单,你可以切换到另一台。 + + +然而,商业VPN的权衡是,您必须相信提供商不会窥探您的互联网流量。一定要选择一个有明确的无日志政策的信誉良好的供应商。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/open-source-tools-vpn + +作者:[Paul Bischoff][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: +[1]: https://blog.trailofbits.com/2016/12/12/meet-algo-the-vpn-that-works/ +[2]: https://github.com/StreisandEffect/streisand +[3]: https://openvpn.net/ +[4]: https://github.com/OpenVPN/easy-rsa +[5]: https://www.strongswan.org/ +[6]: https://www.softether.org/ +[7]: https://www.wireguard.com/ +[8]: https://www.comparitech.com/vpn/reviews/expressvpn/ From 0af0281f8b2443fa1309a7be9244421eb6a5d662 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Mon, 10 Sep 2018 15:48:56 +0800 Subject: [PATCH 154/455] submit tech/20180806 Anatomy of a Linux DNS Lookup - Part IV.md --- ...Anatomy of a Linux DNS Lookup - Part IV.md | 182 ------------------ ...Anatomy of a Linux DNS Lookup - Part IV.md | 165 ++++++++++++++++ 2 files changed, 165 insertions(+), 182 deletions(-) delete mode 100644 sources/tech/20180806 Anatomy of a Linux DNS Lookup - Part IV.md create mode 100644 translated/tech/20180806 Anatomy of a Linux DNS Lookup - Part IV.md diff --git a/sources/tech/20180806 Anatomy of a Linux DNS Lookup - Part IV.md b/sources/tech/20180806 Anatomy of a Linux DNS Lookup - Part IV.md deleted file mode 100644 index 03b763fd44..0000000000 --- a/sources/tech/20180806 Anatomy of a Linux DNS Lookup - Part IV.md +++ /dev/null @@ -1,182 +0,0 @@ -pinewall is translating - -[Anatomy of a Linux DNS Lookup – Part IV][2] -============================================ - -In [Anatomy of a Linux DNS Lookup – Part I][3], [Part II][4], and [Part III][5] I covered: - -* `nsswitch` - -* `/etc/hosts` - -* `/etc/resolv.conf` - -* `ping` vs `host` style lookups - -* `systemd` and its `networking` service - -* `ifup` and `ifdown` - -* `dhclient` - -* `resolvconf` - -* `NetworkManager` - -* `dnsmasq` - -In Part IV I’ll cover how containers do DNS. Yes, that’s not simple either… - -* * * - -1) Docker and DNS -============================================================ - -In [part III][6] we looked at DNSMasq, and learned that it works by directing DNS queries to the localhost address `127.0.0.1`, and a process listening on port 53 there will accept the request. - -So when you run up a Docker container, on a host set up like this, what do you expect to see in its `/etc/resolv.conf`? - -Have a think, and try and guess what it will be. - -Here’s the default output if you run a default Docker setup: - -``` -$ docker run  ubuntu cat /etc/resolv.conf -# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) -#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN -# 127.0.0.53 is the systemd-resolved stub resolver. -# run "systemd-resolve --status" to see details about the actual nameservers. - -search home -nameserver 8.8.8.8 -nameserver 8.8.4.4 -``` - -Hmmm. - -#### Where did the addresses `8.8.8.8` and `8.8.4.4` come from? - -When I pondered this question, my first thought was that the container would inherit the `/etc/resolv.conf` settings from the host. But a little thought shows that that won’t always work. - -If you have DNSmasq set up on the host, the `/etc/resolv.conf` file will be pointed at the `127.0.0.1` loopback address. If this were passed through to the container, the container would look up DNS addresses from within its own networking context, and there’s no DNS server available within the container context, so the DNS lookups would fail. - -‘A-ha!’ you might think: we can always use the host’s DNS server by using the  _host’s_  IP address, available from within the container as the default route: - -``` -root@79a95170e679:/# ip route                                                                -default via 172.17.0.1 dev eth0                                                -172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.2      -``` - -#### Use the host? - -From that we can work out that the ‘host’ is on the ip address: `172.17.0.1`, so we could try manually pointing DNS at that using dig (you could also update the `/etc/resolv.conf` and then run `ping`, this just seems like a good time to introduce `dig` and its `@` flag, which points the request at the ip address you specify): - -``` -root@79a95170e679:/# dig @172.17.0.1 google.com | grep -A1 ANSWER.SECTION -;; ANSWER SECTION: -google.com.             112     IN      A       172.217.23.14 -``` - -However: that might work if you use DNSMasq, but if you don’t it won’t, as there’s no DNS server on the host to look up. - -So Docker’s solution to this quandary is to bypass all that complexity and point your DNS lookups to Google’s DNS servers at `8.8.8.8` and `8.8.4.4`, ignoring whatever the host context is. - - _Anecdote: This was the source of my first problem with Docker back in 2013\. Our corporate network blocked access to those IP addresses, so my containers couldn’t resolve URLs._ - -So that’s Docker containers, but container  _orchestrators_  such as Kubernetes can do different things again… - -# 2) Kubernetes and DNS - -The unit of container deployment in Kubernetes is a Pod. A pod is a set of co-located containers that (among other things) share the same IP address. - -An extra challenge with Kubernetes is to forward requests for Kubernetes services to the right resolver (eg `myservice.kubernetes.io`) to the private network allocated to those service addresses. These addresses are said to be on the ‘cluster domain’. This cluster domain is configurable by the administrator, so it might be `cluster.local` or `myorg.badger` depending on the configuration you set up. - -In Kubernetes you have four options for configuring how DNS lookup works within your pod. - -* Default - -This (misleadingly-named) option takes the same DNS resolution path as the host the pod runs on, as in the ‘naive’ DNS lookup described earlier. It’s misleadingly named because it’s not the default! ClusterFirst is. - -If you want to override the `/etc/resolv.conf` entries, you can in your config for the kubelet. - -* ClusterFirst - -ClusterFirst does selective forwarding on the DNS request. This is achieved in one of two ways based on the configuration. - -In the first, older and simpler setup, a rule was followed where if the cluster domain was not found in the request, then it was forwarded to the host. - -In the second, newer approach, you can configure selective forwarding on an internal DNS - -Here’s what the config looks like and a diagram lifted from the [Kubernetes docs][7] which shows the flow: - -``` -apiVersion: v1 -kind: ConfigMap -metadata: - name: kube-dns - namespace: kube-system -data: - stubDomains: | - {"acme.local": ["1.2.3.4"]} - upstreamNameservers: | - ["8.8.8.8", "8.8.4.4"] -``` - -The `stubDomains` entry defines specific DNS servers to use for specific domains. The upstream servers are the servers we defer to when nothing else has picked up the DNS request. - -This is achieved with our old friend DNSMasq running in a pod. - -![kubedns](https://zwischenzugs.files.wordpress.com/2018/08/kubedns.png?w=525) - -The other two options are more niche: - -* ClusterFirstWithHostNet - -This applies if you use host network for your pods, ie you bypass the Docker networking setup to use the same network as you would directly on the host the pod is running on. - -* None - -None does nothing to DNS but forces you to specify the DNS settings in the `dnsConfig` field in the pod specification. - -### CoreDNS Coming - -And if that wasn’t enough, this is set to change again as CoreDNS comes to Kubernetes, replacing kube-dns. CoreDNS will offer a few benefits over kube-dns, being more configurabe and more efficient. - -Find out more [here][8]. - -If you’re interested in OpenShift networking, I wrote a post on that [here][9]. But that was for 3.6 so is likely out of date now. - -### End of Part IV - -That’s part IV done. In it we covered. - -* Docker DNS lookups - -* Kubernetes DNS lookups - -* Selective forwarding (stub domains) - -* kube-dns - - --------------------------------------------------------------------------------- - -via: https://zwischenzugs.com/2018/08/06/anatomy-of-a-linux-dns-lookup-part-iv/ - -作者:[zwischenzugs][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://zwischenzugs.com/ -[1]:https://zwischenzugs.com/2018/08/06/anatomy-of-a-linux-dns-lookup-part-iv/ -[2]:https://zwischenzugs.com/2018/08/06/anatomy-of-a-linux-dns-lookup-part-iv/ -[3]:https://zwischenzugs.com/2018/06/08/anatomy-of-a-linux-dns-lookup-part-i/ -[4]:https://zwischenzugs.com/2018/06/18/anatomy-of-a-linux-dns-lookup-part-ii/ -[5]:https://zwischenzugs.com/2018/07/06/anatomy-of-a-linux-dns-lookup-part-iii/ -[6]:https://zwischenzugs.com/2018/07/06/anatomy-of-a-linux-dns-lookup-part-iii/ -[7]:https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/#impacts-on-pods -[8]:https://coredns.io/ -[9]:https://zwischenzugs.com/2017/10/21/openshift-3-6-dns-in-pictures/ diff --git a/translated/tech/20180806 Anatomy of a Linux DNS Lookup - Part IV.md b/translated/tech/20180806 Anatomy of a Linux DNS Lookup - Part IV.md new file mode 100644 index 0000000000..9f3dd93437 --- /dev/null +++ b/translated/tech/20180806 Anatomy of a Linux DNS Lookup - Part IV.md @@ -0,0 +1,165 @@ +Linux DNS 查询剖析(第四部分) +============================================ + +在 [Linux DNS 查询剖析(第一部分)][1],[Linux DNS 查询剖析(第二部分)][2] 和 [Linux DNS 查询剖析(第三部分)][3] 中,我们已经介绍了以下内容: + +* `nsswitch` +* `/etc/hosts` +* `/etc/resolv.conf` +* `ping` 与 `host` 查询方式的对比 +* `systemd` 和对应的 `networking` 服务 +* `ifup` 和 `ifdown` +* `dhclient` +* `resolvconf` +* `NetworkManager` +* `dnsmasq` + +在第四部分中,我将介绍容器如何完成 DNS 查询。你想的没错,也不是那么简单。 + +* * * + +### 1) Docker 和 DNS + +============================================================ + +在 [Linux DNS 查询剖析(第三部分)][3] 中,我们介绍了 `dnsmasq`,其工作方式如下:将 DNS 查询指向到 localhost 地址 `127.0.0.1`,同时启动一个进程监听 `53` 端口并处理查询请求。 + +在按上述方式配置 DNS 的主机上,如果运行了一个 Docker 容器,容器内的 `/etc/resolv.conf` 文件会是怎样的呢? + +我们来动手试验一下吧。 + +按照默认 Docker 创建流程,可以看到如下的默认输出: + +``` +$ docker run  ubuntu cat /etc/resolv.conf +# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) +#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN +# 127.0.0.53 is the systemd-resolved stub resolver. +# run "systemd-resolve --status" to see details about the actual nameservers. + +search home +nameserver 8.8.8.8 +nameserver 8.8.4.4 +``` + +奇怪! + +#### 地址 `8.8.8.8` 和 `8.8.4.4` 从何而来呢? + +当我思考容器内的 `/etc/resolv.conf` 配置时,我的第一反应是继承主机的 `/etc/resolv.conf`。但只要稍微进一步分析,就会发现这样并不总是有效的。 + +如果在主机上配置了 `dnsmasq`,那么 `/etc/resolv.conf` 文件总会指向 `127.0.0.1` 这个回环地址loopback address。如果这个地址被容器继承,容器会在其本身的网络上下文networking context中使用;由于容器内并没有运行(在 `127.0.0.1` 地址的)DNS 服务器,因此 DNS 查询都会失败。 + +“有了!”你可能有了新主意:将 _主机的_ 的 IP 地址用作 DNS 服务器地址,其中这个 IP 地址可以从容器的默认路由default route中获取: + +``` +root@79a95170e679:/# ip route +default via 172.17.0.1 dev eth0 +172.17.0.0/16 dev eth0 proto kernel scope link src 172.17.0.2 +``` + +#### 使用主机 IP 地址真的可行吗? + +从默认路由中,我们可以找到主机的 IP 地址 `172.17.0.1`,进而可以通过手动指定 DNS 服务器的方式进行测试(你也可以更新 `/etc/resolv.conf` 文件并使用 `ping` 进行测试;但我觉得这里很适合介绍新的 `dig` 工具及其 `@` 参数,后者用于指定需要查询的 DNS 服务器地址): + +``` +root@79a95170e679:/# dig @172.17.0.1 google.com | grep -A1 ANSWER.SECTION +;; ANSWER SECTION: +google.com.             112     IN      A       172.217.23.14 +``` + +但是还有一个问题,这种方式仅适用于主机配置了 `dnsmasq` 的情况;如果主机没有配置 `dnsmasq`,主机上并不存在用于查询的 DNS 服务器。 + +在这个问题上,Docker 的解决方案是忽略所有可能的复杂情况,即无论主机中使用什么 DNS 服务器,容器内都使用 Google 的 DNS 服务器 `8.8.8.8` 和 `8.8.4.4` 完成 DNS 查询。 + + _我的经历:在 2013 年,我遇到了使用 Docker 以来的第一个问题,与 Docker 的这种 DNS 解决方案密切相关。我们公司的网络屏蔽了 `8.8.8.8` 和 `8.8.4.4`,导致容器无法解析域名。_ + +这就是 Docker 容器的情况,但对于包括 Kubernetes 在内的容器 _编排引擎orchestrators_,情况又有些不同。 + +### 2) Kubernetes 和 DNS + +在 Kubernetes 中,最小部署单元是 `pod`;`pod` 是一组相互协作的容器,共享 IP 地址(和其它资源)。 + +Kubernetes 面临的一个额外的挑战是,将 Kubernetes 服务请求(例如,`myservice.kubernetes.io`)通过对应的解析器resolver,转发到具体服务地址对应的内网地址private network。这里提到的服务地址被称为归属于“集群域cluster domain”。集群域可由管理员配置,根据配置可以是 `cluster.local` 或 `myorg.badger` 等。 + +在 Kubernetes 中,你可以为 `pod` 指定如下四种 `pod` 内 DNS 查询的方式。 + +* Default + +在这种(名称容易让人误解)的方式中,`pod` 与其所在的主机采用相同的 DNS 查询路径,与前面介绍的主机 DNS 查询一致。我们说这种方式的名称容易让人误解,因为该方式并不是默认选项!`ClusterFirst` 才是默认选项。 + +如果你希望覆盖 `/etc/resolv.conf` 中的条目,你可以添加到 `kubelet` 的配置中。 + +* ClusterFirst + +在 `ClusterFirst` 方式中,遇到 DNS 查询请求会做有选择的转发。根据配置的不同,有以下两种方式: + +第一种方式配置相对古老但更简明,即采用一个规则:如果请求的域名不是集群域的子域,那么将其转发到 `pod` 所在的主机。 + +第二种方式相对新一些,你可以在内部 DNS 中配置选择性转发。 + +下面给出示例配置并从 [Kubernetes 文档][4]中选取一张图说明流程: + +``` +apiVersion: v1 +kind: ConfigMap +metadata: + name: kube-dns + namespace: kube-system +data: + stubDomains: | + {"acme.local": ["1.2.3.4"]} + upstreamNameservers: | + ["8.8.8.8", "8.8.4.4"] +``` + +在 `stubDomains` 条目中,可以为特定域名指定特定的 DNS 服务器;而 `upstreamNameservers` 条目则给出,待查询域名不是集群域子域情况下用到的 DNS 服务器。 + +这是通过在一个 `pod` 中运行我们熟知的 `dnsmasq` 实现的。 + +![kubedns](https://zwischenzugs.files.wordpress.com/2018/08/kubedns.png?w=525) + +剩下两种选项都比较小众: + +* ClusterFirstWithHostNet + +适用于 `pod` 使用主机网络的情况,例如绕开 Docker 网络配置,直接使用与 `pod` 对应主机相同的网络。 + +* None + +`None` 意味着不改变 DNS,但强制要求你在 `pod` 规范文件specification的 `dnsConfig` 条目中指定 DNS 配置。 + +### CoreDNS 即将到来 + +除了上面提到的那些,一旦 `CoreDNS` 取代Kubernetes 中的 `kube-dns`,情况还会发生变化。`CoreDNS` 相比 `kube-dns` 具有可配置性更高、效率更高等优势。 + +如果想了解更多,参考[这里][5]。 + +如果你对 OpenShift 的网络感兴趣,我曾写过一篇[文章][6]可供你参考。但文章中 OpenShift 的版本是 `3.6`,可能有些过时。 + +### 第四部分总结 + +第四部分到此结束,其中我们介绍了: + +* Docker DNS 查询 +* Kubernetes DNS 查询 +* 选择性转发(子域不转发) +* kube-dns + +-------------------------------------------------------------------------------- + +via: https://zwischenzugs.com/2018/08/06/anatomy-of-a-linux-dns-lookup-part-iv/ + +作者:[zwischenzugs][a] +译者:[pinewall](https://github.com/pinewall) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://zwischenzugs.com/ +[1]:https://zwischenzugs.com/2018/06/08/anatomy-of-a-linux-dns-lookup-part-i/ +[2]:https://zwischenzugs.com/2018/06/18/anatomy-of-a-linux-dns-lookup-part-ii/ +[3]:https://zwischenzugs.com/2018/07/06/anatomy-of-a-linux-dns-lookup-part-iii/ +[4]:https://kubernetes.io/docs/tasks/administer-cluster/dns-custom-nameservers/#impacts-on-pods +[5]:https://coredns.io/ +[6]:https://zwischenzugs.com/2017/10/21/openshift-3-6-dns-in-pictures/ From e56c7c824df0f7b8f0ef2691305e04fcd59abaec Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 10 Sep 2018 15:52:10 +0800 Subject: [PATCH 155/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=206=20open=20source?= =?UTF-8?q?=20tools=20for=20writing=20a=20book?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... 6 open source tools for writing a book.md | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 sources/tech/20180907 6 open source tools for writing a book.md diff --git a/sources/tech/20180907 6 open source tools for writing a book.md b/sources/tech/20180907 6 open source tools for writing a book.md new file mode 100644 index 0000000000..8b8140bd61 --- /dev/null +++ b/sources/tech/20180907 6 open source tools for writing a book.md @@ -0,0 +1,67 @@ +6 open source tools for writing a book +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-lead-austen-writing-code.png?itok=XPxRMtQ4) + +I first used and contributed to free and open source software in 1993, and since then I've been an open source software developer and evangelist. I've written or contributed to dozens of open source software projects, although the one that I'll be remembered for is the [FreeDOS Project][1], an open source implementation of the DOS operating system. + +I recently wrote a book about FreeDOS. [_Using FreeDOS_][2] is my celebration of the 24th anniversary of FreeDOS. It is a collection of how-to's about installing and using FreeDOS, essays about my favorite DOS applications, and quick-reference guides to the DOS command line and DOS batch programming. I've been working on this book for the last few months, with the help of a great professional editor. + +_Using FreeDOS_ is available under the Creative Commons Attribution (cc-by) International Public License. You can download the EPUB and PDF versions at no charge from the [FreeDOS e-books][2] website. (I'm also planning a print version, for those who prefer a bound copy.) + +The book was produced almost entirely with open source software. I'd like to share a brief insight into the tools I used to create, edit, and produce _Using FreeDOS_. + +### Google Docs + +[Google Docs][3] is the only tool I used that isn't open source software. I uploaded my first drafts to Google Docs so my editor and I could collaborate. I'm sure there are open source collaboration tools, but Google Doc's ability to let two people edit the same document at the same time, make comments, edit suggestions, and change tracking—not to mention its use of paragraph styles and the ability to download the finished document—made it a valuable part of the editing process. + +### LibreOffice + +I started on [LibreOffice][4] 6.0 but I finished the book using LibreOffice 6.1. I love LibreOffice's rich support of styles. Paragraph styles made it easy to apply a style for titles, headers, body text, sample code, and other text. Character styles let me modify the appearance of text within a paragraph, such as inline sample code or a different style to indicate a filename. Graphics styles let me apply certain styling to screenshots and other images. And page styles allowed me to easily modify the layout and appearance of the page. + +### GIMP + +My book includes a lot of DOS program screenshots, website screenshots, and FreeDOS logos. I used [GIMP][5] to modify these images for the book. Usually, this was simply cropping or resizing an image, but as I prepare the print edition of the book, I'm using GIMP to create a few images that will be simpler for print layout. + +### Inkscape + +Most of the FreeDOS logos and fish mascots are in SVG format, and I used [Inkscape][6] for any image tweaking here. And in preparing the PDF version of the ebook, I wanted a simple blue banner at top of the page, with the FreeDOS logo in the corner. After some experimenting, I found it easier to create an SVG image in Inkscape that looked like the banner I wanted, and I pasted that into the header. + +### ImageMagick + +While it's great to use GIMP to do the fine work, sometimes it's faster to run an [ImageMagick][7] command over a set of images, such as to convert into PNG format or to resize images. + +### Sigil + +LibreOffice can export directly to EPUB format, but it wasn't a great transfer. I haven't tried creating an EPUB with LibreOffice 6.1, but LibreOffice 6.0 didn't include my images. It also added styles in a weird way. I used [Sigil][8] to tweak the EPUB file and make everything look right. Sigil even has a preview function so you can see what the EPUB will look like. + +### QEMU + +Because this book is about installing and running FreeDOS, I needed to actually run FreeDOS. You can boot FreeDOS inside any PC emulator, including VirtualBox, QEMU, GNOME Boxes, PCem, and Bochs. But I like the simplicity of [QEMU][9]. And the QEMU console lets you issue a screen dump in PPM format, which is ideal for grabbing screenshots to include in the book. + +Of course, I have to mention running [GNOME][10] on [Linux][11]. I use the [Fedora][12] distribution of Linux. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/writing-book-open-source-tools + +作者:[Jim Hall][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jim-hall +[1]: http://www.freedos.org/ +[2]: http://www.freedos.org/ebook/ +[3]: https://www.google.com/docs/about/ +[4]: https://www.libreoffice.org/ +[5]: https://www.gimp.org/ +[6]: https://inkscape.org/ +[7]: https://www.imagemagick.org/ +[8]: https://sigil-ebook.com/ +[9]: https://www.qemu.org/ +[10]: https://www.gnome.org/ +[11]: https://www.kernel.org/ +[12]: https://getfedora.org/ From 67553008b7e8e212816f86e54165fc911e0d5666 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 10 Sep 2018 15:53:24 +0800 Subject: [PATCH 156/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20What=20do=20open?= =?UTF-8?q?=20source=20and=20cooking=20have=20in=20common=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... open source and cooking have in common.md | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 sources/talk/20180907 What do open source and cooking have in common.md diff --git a/sources/talk/20180907 What do open source and cooking have in common.md b/sources/talk/20180907 What do open source and cooking have in common.md new file mode 100644 index 0000000000..4dacfe62f0 --- /dev/null +++ b/sources/talk/20180907 What do open source and cooking have in common.md @@ -0,0 +1,79 @@ +What do open source and cooking have in common? +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/waffles-recipe-eggs-cooking-mix.png?itok=Fp06VOBx) + +What’s a fun way to promote the principles of free software without actually coding? Here’s an idea: open source cooking. For the past eight years, this is what we’ve been doing in Munich. + +The idea of _open source cooking_ grew out of our regular open source meetups because we realized that cooking and free software have a lot in common. + +### Cooking together + +The [Munich Open Source Meetings][1] is a series of recurring Friday night events that was born in [Café Netzwerk][2] in July 2009. The meetings help provide a way for open source project members and enthusiasts to get to know each other. Our motto is: “Every fourth Friday for free software.” In addition to adding some weekend workshops, we soon introduced other side events, including white sausage breakfast, sauna, and cooking. + +The first official _Open Source Cooking_ meetup was admittedly rather chaotic, but we’ve improved our routine over the past eight years and 15 events, and we’ve mastered the art of cooking delicious food for 25-30 people. + +Looking back at all those evenings, similarities between cooking together and working together in open source communities have become more clear. + +### FLOSS principles at play + +Here are a few ways cooking together is like working together on open source projects: + + * We enjoy collaborating and working toward a result we share. + * We’ve become a community. + * As we share a common interest and enthusiasm, we learn more about ourselves, each other, and what we’re working on together. + * Mistakes happen. We learn from them and share our knowledge to our mutual benefit, so hopefully we avoid repeating the same mistakes. + * Everyone contributes what they’re best at, as everyone has something they’re better at than someone else. + * We motivate others to contribute and join us. + * Coordination is key, but a bit chaotic. + * Everyone benefits from the results! + + + +### Smells like open source + +Like any successful open source-related meetup, open source cooking requires some coordination and structure. Ahead of the event, we run a _call for recipes_ in which all participants can vote. Rather than throwing a pizza into a microwave, we want to create something delicious and tasty, and so far we’ve had Japanese, Mexican, Hungarian, and Indian food, just to name a few. + +Like in real life, cooking together requires having respect and mutual understanding for each other, so we always try to have dishes for vegans, vegetarians, and people with allergies and food preferences. A little beta test at home can be helpful (and fun!) when preparing for the big release. + +Scalability matters, and shopping for our “build requirements” at the grocery store easily can eat up three hours. We use a spreadsheet (LibreOffice Calc, naturally) for calculating ingredient requirements and costs. + +For every dinner course we have a “package maintainer” working with volunteers to make the menu in time and to find unconventional solutions to problems that arise. + +Not everyone is a cook by profession, but with a little bit of help and a good distribution of tasks and responsibilities, it’s rather easy to parallelize things — at some point, 18kg of tomatoes and 100 eggs really don’t worry you anymore, believe me! The only real scalability limit is the stove with its four hotplates, so maybe it’s time to invest in an infrastructure budget. + +Time-based releasing, on the other hand, isn’t working as reliably as it should, as we usually serve the main dish at a rather “flexible” time between 21:30 und 01:30, but that’s not a release blocker, either. + +And, as with in many open source projects, cooking documentation has room for improvement. Cleanup tasks such as washing the dishes, surely can be optimized further, too. + +### Future flavor releases + +Some of our future ideas include: + + * cooking in a foreign country, + * finally buying and cooking that large 700 € pumpkin, and + * find a grocery store that donates a percentage of our purchases to a good cause. + + + +The last item is also an important aspect about the free software movement: Always remember there are people who are not living on the sunny side, who do not have the same access to resources, and who are otherwise struggling. How can the open nature of what we’re doing help them? + +With all that in mind, I am looking forward to the next Open Source Cooking meetup. If reading about them makes you hungry and you’d like to run own event, we’d love to see you adapt our idea or even fork it. And we’d love to have you join us in a meetup, and perhaps even do some mentoring and QA. + +Article originally appeared on [blog.effenberger.org][3]. Reprinted with permission. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/open-source-cooking + +作者:[Florian Effenberger][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/floeff +[1]: https://www.opensourcetreffen.de/ +[2]: http://www.cafe-netzwerk.de/ +[3]: https://blog.effenberger.org/2018/05/28/what-do-open-source-and-cooking-have-in-common/ From 4ced01fa9f6981718cc7a966641a7816c9a410a1 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 10 Sep 2018 15:57:27 +0800 Subject: [PATCH 157/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20DevOps:=20The=20c?= =?UTF-8?q?onsequences=20of=20blame?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...80906 DevOps- The consequences of blame.md | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 sources/talk/20180906 DevOps- The consequences of blame.md diff --git a/sources/talk/20180906 DevOps- The consequences of blame.md b/sources/talk/20180906 DevOps- The consequences of blame.md new file mode 100644 index 0000000000..f7efed4d66 --- /dev/null +++ b/sources/talk/20180906 DevOps- The consequences of blame.md @@ -0,0 +1,67 @@ +DevOps: The consequences of blame +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mistake_bug_fix_find_error.png?itok=PZaz3dga) + +Merriam-Webster defines "blame" as both a verb and a noun. As a verb, it means "to find fault with or to hold responsible." As a noun, it means "an expression of disapproval or responsibility for something believed to deserve censure." + +Either way, blame isn’t a pleasant thing. It can create feelings of fear and shame, foster power imbalances, and cause us to devalue others. + +Just think of what it felt like the last time you were yelled at or accused of something. Conversely, consider the opposite of blame: Praise, flattery, and approval. How does it feel to be complimented or commended for a job well done? + +You may be wondering what all this talk about blame has to do with DevOps. Read on: + +### DevOps and blame + +The three pillars of DevOps are flow, feedback, and continuous improvement. How can an organization or a team improve if its members are focused on finding someone to blame? For a DevOps culture to succeed, blame must be eliminated. + +For example, suppose your product has a bug or experiences an outage. If your organization's leaders react to this by looking for someone to blame, there’s little chance for feedback on how to improve. Look at how blame is flowing in your organization and work to remove it. Strive for blameless post-mortems and move away from _root-cause analysis_ , which tends to focus on assigning blame. In today’s complex business infrastructure, many factors can contribute to bugs and other problems. Successful DevOps teams practice post-incident reviews to examine the bigger picture when things go wrong. + +### Consequences of blame + +DevOps is about creating a culture of collaboration and community. This is not possible in a culture of blame. Because blame does not correct behavior, there is no continuous learning. What _is_ learned is how to avoid blame—so instead of solving problems, team members focus on how they can avoid being blamed for them. + +What about accountability? Avoiding blame does not mean avoiding accountability or consequences. Here are some tips to create an environment in which people are held accountable without blame: + + * When mistakes are made, focus on what steps you can take to avoid making the same mistake in the future. What did you learn, and how can you apply that knowledge to improving things? + + * When something goes wrong, people feel stress. Work toward eliminating or reducing that stress. Avoid yelling and putting additional pressure on people. + + * Accept that mistakes will happen. Nobody—and nothing—is perfect. + + * When corrective actions are necessary, provide them privately, not publicly. + + + + +As a child, I loved reading the [Family Circus][1] comic strip, especially the ones featuring “Not Me.” Not Me frequently appeared with “Ida Know” and “Nobody” when Mom and Dad asked an accusatory question. Why did the kids in Family Circus blame Not Me? Look no further than the parents' angry, frustrated expressions. Like the kids in the comic strip, we quickly learn to assign blame or look for faults in others because blaming ourselves is too painful. + +In his book, [_Thinking, Fast and Slow_][2], author Daniel Kanheman points out that most of us spend as little time as possible thinking—after all, thinking is hard. To make things easier, we learn from previous experiences, which in turn creates biases. If blame is part of that equation, it will be included in our bias: _“The last time a question was asked in a meeting and I took responsibility, I was chewed out in front of all my co-workers. I won’t do that again.”_ + +When something goes wrong, we want answers and accountability. Uncertainty is scary and leads to stress; we prefer predictable scenarios. This drives us to look for root causes, which often leads to blame. + +But what if, instead of assigning blame, we turned the situation into something constructive and helpful—an opportunity for learning? It isn't always easy, but working to eliminate blame will build a stronger DevOps team and a happier, more productive company. + +Next time you find yourself starting to look for someone to blame, think of this poem by Rupi Kaur: + +_“It takes grace_ + +_To remain kind_ + +_In cruel situations”_ + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/consequences-blame-your-devops-team + +作者:[Dawn Parzych][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dawnparzych +[1]: http://familycircus.com/comics/september-1-2012/ +[2]: https://www.amazon.com/Thinking-Fast-Slow-Daniel-Kahneman/dp/0374533555 From 788f374d8fe7f0f90805937546f4c8004499007a Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 10 Sep 2018 16:01:28 +0800 Subject: [PATCH 158/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20What=20is=20ZFS?= =?UTF-8?q?=3F=20Why=20People=20Use=20ZFS=3F=20[Explained=20for=20Beginner?= =?UTF-8?q?s]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ople Use ZFS- [Explained for Beginners].md | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md diff --git a/sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md b/sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md new file mode 100644 index 0000000000..10425b2054 --- /dev/null +++ b/sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md @@ -0,0 +1,114 @@ +What is ZFS? Why People Use ZFS? [Explained for Beginners] +====== +Today, we will take a look at ZFS, an advanced file system. We will discuss where it came from, what it is, and why it is so popular among techies and enterprise. + +Even though I’m from the US, I prefer to pronounce it ZedFS instead of ZeeFS because it sounds cooler. You are free to pronounce it however you like. + +Note: You will see ZFS repeated many times in the article. When I talk about feature and installation, I’m talking about OpenZFS. ZFS (developed by Oracle) and OpenZFS have followed different paths since Oracle shutdown OpenSolaris. (More on that later.) + +### History of ZFS + +The Z File System (ZFS) was created by [Matthew Ahrens and Jeff Bonwick][1] in 2001. ZFS was designed to be a next generation file system for [Sun Microsystems’][2] [OpenSolaris][3]. In 2008, ZFS was ported to FreeBSD. The same year a project was started to port [ZFS to Linux][4]. However, since ZFS is licensed under the [Common Development and Distribution License][5], which is incompatible with the [GNU General Public License][6], it cannot be included in the Linux kernel. To get around this problem, most Linux distros offer methods to install ZFS. + +Shortly after Oracle purchased Sun Microsystems, OpenSolaris became close-source. All further development of ZFS became closed source, as well. Many of the developers of ZFS where unhappy about this turn of events. [Two-thirds of the core ZFS devlopers][1], including Ahrens and Bonwick, left Oracle due to this decision. They joined other companies and created the [OpenZFS project][7] in September of 2013. The project has spearheaded the open-source development of ZFS. + +Let’s go back to the license issue mentioned above. Since the OpenZFS project is separate from Oracle, some probably wonder why they don’t change the license to something that is compatible with the GPL so it can be included in the Linux kernel. According to the [OpenZFS website][8], changing the license would involve contacting anyone who contributed code to the current OpenZFS implementation (including the initial, common ZFS code till OpenSolaris) and get their permission to change the license. Since this job is near impossible (because some contributors may be dead or hard to find), they have decided to keep the license they have. + +### What is ZFS? What are its features? + +![ZFS filesystem][9] + +As I said before, ZFS is an advanced file system. As such, it has some interesting [features][10]. Such as: + + * Pooled storage + * Copy-on-write + * Snapshots + * Data integrity verification and automatic repair + * RAID-Z + * Maximum 16 Exabyte file size + * Maximum 256 Quadrillion Zettabytes storage + + + +Let’s break down a couple of those features. + +#### Pooled Storage + +Unlike most files systems, ZFS combines the features of a file system and a volume manager. This means that unlike other file systems, ZFS can create a file system that spans across a series of drives or a pool. Not only that but you can add storage to a pool by adding another drive. ZFS will handle [partitioning and formatting][11]. + +![Pooled storage in ZFS][12]Pooled storage in ZFS + +#### Copy-on-write + +[Copy-on-write][13] is another interesting (and cool) features. On most files system, when data is overwritten, it is lost forever. On ZFS, the new information is written to a different block. Once the write is complete, the file systems metadata is updated to point to the new info. This ensures that if the system crashes (or something else happens) while the write is taking place, the old data will be preserved. It also means that the system does not need to run [fsck][14] after a system crash. + +#### Snapshots + +Copy-on-write leads into another ZFS feature: snapshots. ZFS uses snapshots to track changes in the file system. “[The snapshot][13] contains the original version of the file system, and the live filesystem contains any changes made since the snapshot was taken. No additional space is used. As new data is written to the live file system, new blocks are allocated to store this data.” It a file is deleted, the snapshot reference is removed, as well. So, snapshots are mainly designed to track changes to files, but not the addition and creation of files. + +Snapshots can be mounted as read-only to recover a past version of a file. It is also possible to rollback the live system to a previous snapshot. All changes made since the snapshot will be lost. + +#### Data integrity verification and automatic repair + +Whenever new data is written to ZFS, it creates a checksum for that data. When that data is read, the checksum is verified. If the checksum does not match, then ZFS knows that an error has been detected. ZFS will then automatically attempt to correct the error. + +#### RAID-Z + +ZFS can handle RAID without requiring any extra software or hardware. Unsurprisingly, ZFS has its own implementation of RAID: RAID-Z. RAID-Z is actually a variation of RAID-5. However, it is designed to overcome the RAID-5 write hole error, “in which the data and parity information become inconsistent after an unexpected restart”. To use the basic [level of RAID-Z][15] (RAID-Z1) you need at least two disks for storage and one for [parity][16]. RAID-Z2 required at least two storage drives and two drive for parity. RAID-Z3 requires at least two storage drives and three drive for parity. When drives are added to the RAID-Z pools, they have to be added in multiples of two. + +#### Huge Storage potential + +When ZFS was created, it was designed to be [the last word in file systems][17]. At a time when most file systems where 64-bit, the ZFS creators decided to jump right to 128-bit to future proof it. This means that ZFS “offers 16 billion billion times the capacity of 32- or 64-bit systems”. In fact, Jeff Bonwick (one of the creators) said [that powering][18] a “fully populating a 128-bit storage pool would, literally, require more energy than boiling the oceans.” + +### How to Install ZFS? + +If you want to use ZFS out of the box, it would require installing either [FreeBSD][19] or an [operating system using the illumos kernel][20]. [illumos][21] is a fork of the OpenSolaris kernel. + +In fact, support for [ZFS is one of the main reasons why some experienced Linux users opt for BSD][22]. + +If you want to try ZFS on Linux, you can only use it at your storage file system. As a far as I know, no Linux distro give you the option to install ZFS on your root out of the box. If you are interested in trying ZFS on Linux, the [ZFS on Linux project][4] has a number of tutorials on how to do that. + +### Caveat + +This article has sung the benefits of ZFS. Now let me tell you a quick problem with ZFS. Using RAID-Z [can be expensive][23] because of the number of drives you need to purchase to add storage space. + +Have you every ZFS? What was your experience like? Let us know in the comments below. + +If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][24]. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/what-is-zfs/ + +作者:[John Paul][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[1]: https://wiki.gentoo.org/wiki/ZFS +[2]: http://en.wikipedia.org/wiki/Sun_Microsystems +[3]: http://en.wikipedia.org/wiki/Opensolaris +[4]: https://zfsonlinux.org/ +[5]: https://en.wikipedia.org/wiki/Common_Development_and_Distribution_License +[6]: https://en.wikipedia.org/wiki/GNU_General_Public_License +[7]: http://www.open-zfs.org/wiki/Main_Page +[8]: http://www.open-zfs.org/wiki/FAQ#Do_you_plan_to_release_OpenZFS_under_a_license_other_than_the_CDDL.3F +[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/what-is-zfs.png +[10]: https://wiki.archlinux.org/index.php/ZFS +[11]: https://www.howtogeek.com/175159/an-introduction-to-the-z-file-system-zfs-for-linux/ +[12]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/zfs-overview.png +[13]: https://www.freebsd.org/doc/handbook/zfs-term.html +[14]: https://en.wikipedia.org/wiki/Fsck +[15]: https://wiki.archlinux.org/index.php/ZFS/Virtual_disks#Creating_and_Destroying_Zpools +[16]: https://www.pcmag.com/encyclopedia/term/60364/raid-parity +[17]: https://web.archive.org/web/20060428092023/http://www.sun.com/2004-0914/feature/ +[18]: https://blogs.oracle.com/bonwick/128-bit-storage:-are-you-high +[19]: https://www.freebsd.org/ +[20]: https://wiki.illumos.org/display/illumos/Distributions +[21]: https://wiki.illumos.org/display/illumos/illumos+Home +[22]: https://itsfoss.com/why-use-bsd/ +[23]: http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html +[24]: http://reddit.com/r/linuxusersgroup From 2ae9fa1fc080143d33257d826f3b140eeb93f0ff Mon Sep 17 00:00:00 2001 From: David Chen Date: Mon, 10 Sep 2018 16:06:32 +0800 Subject: [PATCH 159/455] 20180827 An introduction to diffs and patches.md --- ...27 An introduction to diffs and patches.md | 114 ------------------ ...27 An introduction to diffs and patches.md | 1 - 2 files changed, 115 deletions(-) delete mode 100644 sources/tech/20180827 An introduction to diffs and patches.md diff --git a/sources/tech/20180827 An introduction to diffs and patches.md b/sources/tech/20180827 An introduction to diffs and patches.md deleted file mode 100644 index cdd0c49d69..0000000000 --- a/sources/tech/20180827 An introduction to diffs and patches.md +++ /dev/null @@ -1,114 +0,0 @@ -Translating by DavidChenLiang - -An introduction to diffs and patches -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0) - -If you’ve ever worked on a large codebase with a distributed development model, you’ve probably heard people say things like “Sue just sent a patch,” or “Rajiv is checking out the diff.” Maybe those terms were new to you and you wondered what they meant. Open source has had an impact here, as the main development model of large projects from Apache web server to the Linux kernel have been “patch-based” development projects throughout their lifetime. In fact, did you know that Apache’s name originated from the set of patches that were collected and collated against the original [NCSA HTTPd server source code][1]? - -You might think this is folklore, but an early [capture of the Apache website][2] claims that the name was derived from this original “patch” collection; hence **APA** t **CH** y server, which was then simplified to Apache. - -But enough history trivia. What exactly are these patches and diffs that developers talk about? - -First, for the sake of this article, let’s assume that these two terms reference one and the same thing. “Diff” is simply short for “difference;” a Unix utility by the same name reveals the difference between one or more files. We will look at a diff utility example below. - -A “patch” refers to a specific collection of differences between files that can be applied to a source code tree using the Unix diff utility. So we can create diffs (or patches) using the diff tool and apply them to an unpatched version of that same source code using the patch tool. As an aside (and breaking my rule of no more history trivia), the word “patch” comes from the physical covering of punchcard holes to make software changes in the early computing days, when punchcards represented the program executed by the computer’s processor. The image below, found on this [Wikipedia page][3] describing software patches, shows this original “patching” concept: - -![](https://opensource.com/sites/default/files/uploads/360px-harvard_mark_i_program_tape.agr_.jpg) - -Now that you have a basic understanding of patches and diffs, let’s explore how software developers use these tools. If you haven’t used a source code control system like [Git][4] or [Subversion][5], I will set the stage for how most non-trivial software projects are developed. If you think of the life of a software project as a set of actions along a timeline, you might visualize changes to the software—such as adding a feature or a function to a source code file or fixing a bug—appearing at different points on the timeline, with each discrete point representing the state of all the source code files at that time. We will call these points of change “commits,” using the same nomenclature that today’s most popular source code control tool, Git, uses. When you want to see the difference between the source code before and after a certain commit, or between many commits, you can use a tool to show us diffs, or differences. - -If you are developing software using this same source code control tool, Git, you may have changes in your local system that you want to provide for others to potentially add as commits to their own tree. One way to provide local changes to others is to create a diff of your local tree's changes and send this “patch” to others who are working on the same source code. This lets others patch their tree and see the source code tree with your changes applied. - -### Linux, Git, and GitHub - -This model of sharing patch files is how the Linux kernel community operates regarding proposed changes today. If you look at the archives for any of the popular Linux kernel mailing lists—[LKML][6] is the primary one, but others include [linux-containers][7], [fs-devel][8], [Netdev][9], to name a few—you’ll find many developers posting patches that they wish to have others review, test, and possibly bring into the official Linux kernel Git tree at some point. It is outside of the scope of this article to discuss Git, the source code control system written by Linus Torvalds, in more detail, but it's worth noting that Git enables this distributed development model, allowing patches to live separately from a main repository, pushing and pulling into different trees and following their specific development flow. - -Before moving on, we can’t ignore the most popular service in which patches and diffs are relevant: [GitHub][10]. Given its name, you can probably guess that GitHub is based on Git, but it offers a web- and API-based workflow around the Git tool for distributed open source project development. One of the main ways that patches are shared in GitHub is not via email, like the Linux kernel, but by creating a **pull request**. When you commit changes on your own copy of a source code tree, you can share those changes by creating a pull request against a commonly shared repository for that software project. GitHub is used by many active and popular open source projects today, such as [Kubernetes][11], [Docker][12], [the Container Network Interface (CNI)][13], [Istio][14], and many others. In the GitHub world, users tend to use the web-based interface to review the diffs or patches that comprise a pull request, but you can still access the raw patch files and use them at the command line with the patch utility. - -### Getting down to business - -Now that we’ve covered patches and diffs and how they are used in popular open source communities or tools, let's look at a few examples. - -The first example includes two copies of a source tree, and one has changes that we want to visualize using the diff utility. In our examples, we will look at “unified” diffs because that is the expected view for patches in most of the modern software development world. Check the diff manual page for more information on options and ways to produce differences. The original source code is located in sources-orig and our second, modified codebase is located in a directory named sources-fixed. To show the differences in a unified diff format in your terminal, use the following command: -``` -$ diff -Naur sources-orig/ sources-fixed/ -``` - -...which then shows the following diff command output: -``` -diff -Naur sources-orig/officespace/interest.go sources-fixed/officespace/interest.go ---- sources-orig/officespace/interest.go        2018-08-10 16:39:11.000000000 -0400 -+++ sources-fixed/officespace/interest.go       2018-08-10 16:39:40.000000000 -0400 -@@ -11,15 +11,13 @@ -   InterestRate float64 - } - -+// compute the rounded interest for a transaction - func computeInterest(acct *Account, t Transaction) float64 { - -   interest := t.Amount 选题模板.txt 中文排版指北.md comic core.md Dict.md lctt2014.md lctt2016.md LCTT翻译规范.md LICENSE Makefile published README.md sign.md sources translated t.InterestRate -   roundedInterest := math.Floor(interest*100) / 100.0 -   remainingInterest := interest - roundedInterest - --  // a little extra.. --  remainingInterest *= 1000 -- -   // Save the remaining interest into an account we control: -   acct.Balance = acct.Balance + remainingInterest -``` - -The first few lines of the diff command output could use some explanation: The three `---` signs show the original filename; any lines that exist in the original file but not in the compared new file will be prefixed with a single `-` to note that this line was “subtracted” from the sources. The `+++` signs show the opposite: The compared new file and additions found in this file are marked with a single `+` symbol to show they were added in the new version of the file. Each “hunk” (that’s what sections prefixed by `@@` are called) of the difference patch file has contextual line numbers that help the patch tool (or other processors) know where to apply this change. You can see from the "Office Space" movie reference function that we’ve corrected (by removing three lines) the greed of one of our software developers, who added a bit to the rounded-out interest calculation along with a comment to our function. - -If you want someone else to test the changes from this tree, you could save this output from diff into a patch file: -``` -$ diff -Naur sources-orig/ sources-fixed/ >myfixes.patch -``` - -Now you have a patch file, myfixes.patch, which can be shared with another developer to apply and test this set of changes. A fellow developer can apply the changes using the patch tool, given that their current working directory is in the base of the source code tree: -``` -$ patch -p1 < ../myfixes.patch -patching file officespace/interest.go -``` - -Now your fellow developer’s source tree is patched and ready to build and test the changes that were applied via the patch. What if this developer had made changes to interest.go separately? As long as the changes do not conflict directly—for example, change the same exact lines—the patch tool should be able to solve where to merge the changes in. As an example, an interest.go file with several other changes is used in the following example run of patch: -``` -$ patch -p1 < ../myfixes.patch -patching file officespace/interest.go -Hunk #1 succeeded at 26 (offset 15 lines). -``` - -In this case, patch warns that the changes did not apply at the original location in the file, but were offset by 15 lines. If you have heavily changed files, patch may give up trying to find where the changes fit, but it does provide options (with requisite warnings in the documentation) for turning up the matching “fuzziness” (which are beyond the scope of this article). - -If you are using Git and/or GitHub, you will probably not use the diff or patch tools as standalone tools. Git offers much of this functionality so you can use the built-in capabilities of working on a shared source tree with merging and pulling other developer’s changes. One similar capability is to use git diff to provide the unified diff output in your local tree or between any two references (a commit identifier, the name of a tag or branch, and so on). You can even create a patch file that someone not using Git might find useful by simply piping the git diff output to a file, given that it uses the exact format of the diffcommand that patch can consume. Of course, GitHub takes these capabilities into a web-based user interface so you can view file changes on a pull request. In this view, you will note that it is effectively a unified diff view in your web browser, and GitHub allows you to download these changes as a raw patch file. - -### Summary - -You’ve learned what a diff and a patch are, as well as the common Unix/Linux command line tools that interact with them. Unless you are a developer on a project still using a patch file-based development method—like the Linux kernel—you will consume these capabilities primarily through a source code control system like Git. But it’s helpful to know the background and underpinnings of features many developers use daily through higher-level tools like GitHub. And who knows—they may come in handy someday when you need to work with patches from a mailing list in the Linux world. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/diffs-patches - -作者:[Phil Estes][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/estesp -[1]:https://github.com/TooDumbForAName/ncsa-httpd -[2]:https://web.archive.org/web/19970615081902/http:/www.apache.org/info.html -[3]:https://en.wikipedia.org/wiki/Patch_(computing) -[4]:https://git-scm.com/ -[5]:https://subversion.apache.org/ -[6]:https://lkml.org/ -[7]:https://lists.linuxfoundation.org/pipermail/containers/ -[8]:https://patchwork.kernel.org/project/linux-fsdevel/list/ -[9]:https://www.spinics.net/lists/netdev/ -[10]:https://github.com/ -[11]:https://kubernetes.io/ -[12]:https://www.docker.com/ -[13]:https://github.com/containernetworking/cni -[14]:https://istio.io/ diff --git a/translated/tech/20180827 An introduction to diffs and patches.md b/translated/tech/20180827 An introduction to diffs and patches.md index c043f95f2d..190d62f122 100644 --- a/translated/tech/20180827 An introduction to diffs and patches.md +++ b/translated/tech/20180827 An introduction to diffs and patches.md @@ -28,7 +28,6 @@ - ### 该说点干货了 我们前面已经讲了在流行的开源社区了是怎么应用补丁和 diff的,现在看看一些例子。 From b1eb591f2c55e434192ed9320278208e74e14f5b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 10 Sep 2018 17:01:11 +0800 Subject: [PATCH 160/455] PRF:20180830 How to Update Firmware on Ubuntu 18.04.md @geekpi --- ... How to Update Firmware on Ubuntu 18.04.md | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/translated/tech/20180830 How to Update Firmware on Ubuntu 18.04.md b/translated/tech/20180830 How to Update Firmware on Ubuntu 18.04.md index 701d12ddaa..fc8922b48c 100644 --- a/translated/tech/20180830 How to Update Firmware on Ubuntu 18.04.md +++ b/translated/tech/20180830 How to Update Firmware on Ubuntu 18.04.md @@ -1,6 +1,7 @@ 如何在 Ubuntu 18.04 上更新固件 ====== -通常,Ubuntu 和其他 Linux 中的默认软件中心会处理系统固件的更新。但是如果你遇到了错误,你可以使用 fwupd 命令行工具更新系统的固件。 + +通常,Ubuntu 和其他 Linux 中的默认软件中心会处理系统固件的更新。但是如果你遇到了错误,你可以使用 `fwupd` 命令行工具更新系统的固件。 我使用 [Dell XPS 13 Ubuntu 版本][1]作为我的主要操作系统。我全新[安装了 Ubuntu 18.04][2],我对硬件兼容性感到满意。蓝牙、外置 USB 耳机和扬声器、多显示器,一切都开箱即用。 @@ -14,7 +15,7 @@ 错误消息是: -**Unable to update “Thunderbolt NVM for Xps Notebook 9360”: could not detect device after update: timed out while waiting for device** +> Unable to update “Thunderbolt NVM for Xps Notebook 9360”: could not detect device after update: timed out while waiting for device 在这篇文章中,我将向你展示如何在 [Ubuntu][6] 中更新系统固件。 @@ -22,42 +23,42 @@ ![How to update firmware in Ubuntu][7] -有一件事你应该知道 GNOME Softwar 即 Ubuntu 18.04 中的软件中心也能够更新固件。但是在由于某种原因失败的情况下,你可以使用命令行工具 fwupd。 +有一件事你应该知道 GNOME Software(即 Ubuntu 18.04 中的软件中心)也能够更新固件。但是在由于某种原因失败的情况下,你可以使用命令行工具 `fwupd`。 [fwupd][8] 是一个开源守护进程,可以处理基于 Linux 的系统中的固件升级。它由 GNOME 开发人员 [Richard Hughes][9] 创建。戴尔的开发人员也为这一开源工具的开发做出了贡献。 -基本上,它使用 LVFS,Linux 供应商固件服务 (Linux Vendor Firmware Service)。硬件供应商将可再发行固件上传到 LVFS 站点,并且多亏 fwupd,你可以从操作系统内部升级这些固件。fwupd 受到 Ubuntu 和 Fedora 等主要 Linux 发行版的支持。 +基本上,它使用 LVFS —— Linux 供应商固件服务Linux Vendor Firmware Service。硬件供应商将可再发行固件上传到 LVFS 站点,并且多亏 `fwupd`,你可以从操作系统内部升级这些固件。`fwupd` 得到了 Ubuntu 和 Fedora 等主要 Linux 发行版的支持。 首先打开终端并更新系统: + ``` sudo apt update && sudo apt upgrade -y - ``` 之后,你可以逐个使用以下命令来启动守护程序,刷新可用固件更新列表并安装固件更新。 + ``` sudo service fwupd start - ``` 守护进程运行后,检查是否有可用的固件更新。 + ``` sudo fwupdmgr refresh - ``` 输出应如下所示: ``` -Fetching metadata -Downloading… [****************************] -Fetching signature +Fetching metadata https://cdn.fwupd.org/downloads/firmware.xml.gz +Downloading… [****************************] +Fetching signature https://cdn.fwupd.org/downloads/firmware.xml.gz.asc ``` 在此之后,运行固件更新: + ``` sudo fwupdmgr update - ``` 固件更新的输出可能与此类似: @@ -67,8 +68,8 @@ No upgrades for XPS 13 9360 TPM 2.0, current is 1.3.1.0: 1.3.1.0=same No upgrades for XPS 13 9360 System Firmware, current is 0.2.8.1: 0.2.8.1=same, 0.2.7.1=older, 0.2.6.2=older, 0.2.5.1=older, 0.2.4.2=older, 0.2.3.1=older, 0.2.2.1=older, 0.2.1.0=older, 0.1.3.7=older, 0.1.3.5=older, 0.1.3.2=older, 0.1.2.3=older Downloading 21.00 for XPS13 9360 Thunderbolt Controller… Updating 21.00 on XPS13 9360 Thunderbolt Controller… -Decompressing… [***********] -Authenticating… [***********] +Decompressing… [***********] +Authenticating… [***********] Restarting device… [***********] ``` @@ -83,7 +84,7 @@ via: https://itsfoss.com/update-firmware-ubuntu/ 作者:[Abhishek Prakash][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From c8c60da517d74b9a61921598136c6c144ce1f8c7 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 10 Sep 2018 17:01:29 +0800 Subject: [PATCH 161/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Autotrash=20?= =?UTF-8?q?=E2=80=93=20A=20CLI=20Tool=20To=20Automatically=20Purge=20Old?= =?UTF-8?q?=20Trashed=20Files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...o Automatically Purge Old Trashed Files.md | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md diff --git a/sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md b/sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md new file mode 100644 index 0000000000..be3295a0a1 --- /dev/null +++ b/sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md @@ -0,0 +1,140 @@ +Autotrash – A CLI Tool To Automatically Purge Old Trashed Files +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/autotrash-720x340.png) + +**Autotrash** is a command line utility to automatically purge old trashed files. It will purge files that have been in the trash for more then a given number of days. You don’t need to empty the trash folder or do SHIFT+DELETE to permanently purge the files/folders. Autortrash will handle the contents of your Trash folder and delete them automatically after a particular period of time. In a nutshell, Autotrash will never allow your trash to grow too big. + +### Installing Autotrash + +Autotrash is available in the default repositories of Debian-based systems. To install autotrash on Debian, Ubuntu, Linux Mint, run: + +``` +$ sudo apt-get install autotrash + +``` + +On Fedora: + +``` +$ sudo dnf install autotrash + +``` + +For Arch linux and its variants, you can install it using any AUR helper programs such as [**Yay**][1]. + +``` +$ yay -S autotrash-git + +``` + +### Automatically Purge Old Trashed Files + +Whenever you run autotrash, It will scan your **`~/.local/share/Trash/info`** directory and read the **`.trashinfo`** files to find their deletion date. If the files have been in trash folder for more than the defined date, they will be deleted. + +Let me show you some examples. + +To purge files which are in the trash folder for more than 30 days, run: + +``` +$ autotrash -d 30 + +``` + +As per above example, if the files in your Trash folder are more than 30-days old, Autotrash will automatically delete them from your Trash. You don’t need to manually delete them. Just send the unnecessary junk to your trash folder and forget about them. Autotrash will take care of the trashed files. + +The above command will only process currently logged-in user’s trash directory. If you want to make autotrash to process trash directories of all users (not just in your home directory), use **-t** option like below. + +``` +$ autotrash -td 30 + +``` + +Autotrash also allows you to delete trashed files based on the space left or available on the trash filesystem. + +For example, have a look at the following example. + +``` +$ autotrash --max-free 1024 -d 30 + +``` + +As per the above command, autotrash will only purge trashed files that are older than **30 days** from the trash if there is less than **1GB of space left** on the trash filesystem. This can be useful if your trash filesystem is running out of the space. + +We can also purge files from trash, oldest first, till there is at least 1GB of space on the trash filesystem. + +``` +$ autotrash --min-free 1024 + +``` + +In this case, there is no restriction on how old trashed files are. + +You can combine both options ( **`--min-free`** and **`--max-free`** ) in a single command like below. + +``` +$ autotrash --max-free 2048 --min-free 1024 -d 30 + +``` + +As per the above command, autotrash will start reading the trash if there is less than **2GB** of free space, then start keeping an eye on. At that point, remove files older than 30 days and if there is less than **1GB** of free space after that remove even newer files. + +As you can see, all command should be manually run by the user. You might wonder, how can I automate this task?? That’s easy! Just add autotrash as crontab entry. Now, the commands will automatically run at a scheduled time and purge the files in your trash depending on the defined options. + +To add these commands in crontab file, run: + +``` +$ crontab -e + +``` + +Add the entries, for example: + +``` +@daily /usr/bin/autotrash -d 30 + +``` + +Now autotrash will purge files which are in the trash folder for more than 30 days, everyday. + +For more details about scheduling tasks, refer the following links. + + ++ [A Beginners Guide To Cron Jobs][2] ++ [How To Easily And Safely Manage Cron Jobs In Linux][3] + + +Please be mindful that if you have deleted any important files inadvertently, they will be permanently gone after the defined days, so just be careful. + +Refer man pages to know more about Autotrash. + +``` +$ man autotrash + +``` + +Emptying Trash folder or pressing SHIFT+DELETE to permanently get rid of unnecessary stuffs from the Linux system is no big deal. It will just take a couple seconds. However, if you wanted an extra utility to take care of your junk files, Autotrash might be helpful. Give it a try and see how it works. + +And, that’s all for now. Hope this helps. More good stuffs to come. + +Cheers! + + + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/autotrash-a-cli-tool-to-automatically-purge-old-trashed-files/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ +[2]: https://www.ostechnix.com/a-beginners-guide-to-cron-jobs/ +[3]: https://www.ostechnix.com/how-to-easily-and-safely-manage-cron-jobs-in-linux/ From 443dc05f0e2fb4c55042f8f35892df34de6b4917 Mon Sep 17 00:00:00 2001 From: DavidChenLiang Date: Mon, 10 Sep 2018 17:23:50 +0800 Subject: [PATCH 162/455] Update 20171124 How do groups work on Linux.md --- 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..5071c7a8a3 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 @@ +Translating by DavidChen + How do groups work on Linux? ============================================================ From ce59ed46f6e539636cd582288664340c0a64ebf0 Mon Sep 17 00:00:00 2001 From: idea2act Date: Mon, 10 Sep 2018 20:41:59 +0800 Subject: [PATCH 163/455] idea2act-translate --- ...180903 Turn your vi editor into a productivity powerhouse.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md b/sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md index 359ecefee2..f3fc89ed4b 100644 --- a/sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md +++ b/sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md @@ -1,3 +1,5 @@ +idea2act translating + Turn your vi editor into a productivity powerhouse ====== From 8deda9e7432a96e2bc73232e6f438cd0301ad058 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 10 Sep 2018 20:51:41 +0800 Subject: [PATCH 164/455] PRF:20171010 Operating a Kubernetes network.md @qhwdw --- ...20171010 Operating a Kubernetes network.md | 88 +++++++------------ 1 file changed, 31 insertions(+), 57 deletions(-) diff --git a/translated/tech/20171010 Operating a Kubernetes network.md b/translated/tech/20171010 Operating a Kubernetes network.md index ef7bb6b888..44f053f3e3 100644 --- a/translated/tech/20171010 Operating a Kubernetes network.md +++ b/translated/tech/20171010 Operating a Kubernetes network.md @@ -1,36 +1,32 @@ -运营一个 Kubernetes 网络 -============================================================ +Kubernetes 网络运维 +====== -最近我一直在研究 Kubernetes 网络。我注意到一件事情就是,虽然关于如何设置 Kubernetes 网络的文章很多,也写得很不错,但是却没有看到关于如何去运营 Kubernetes 网络的文章、以及如何完全确保它不会给你造成生产事故。 +最近我一直在研究 Kubernetes 网络。我注意到一件事情就是,虽然关于如何设置 Kubernetes 网络的文章很多,也写得很不错,但是却没有看到关于如何去运维 Kubernetes 网络的文章、以及如何完全确保它不会给你造成生产事故。 在本文中,我将尽力让你相信三件事情(我觉得这些都很合理 :)): * 避免生产系统网络中断非常重要 +* 运维联网软件是很难的 +* 有关你的网络基础设施的重要变化值得深思熟虑,以及这种变化对可靠性的影响。 -* 运营联网软件是很难的 - -* 有关你的网络基础设施的重要变化值得深思熟虑,以及这种变化对可靠性的影响。虽然非常“牛x”的谷歌人常说“这是我们在谷歌正在用的”(谷歌工程师在 Kubernetes 上正做着很重大的工作!但是我认为重要的仍然是研究架构,并确保它对你的组织有意义)。 +虽然非常“牛x”的谷歌人常说“这是我们在谷歌正在用的”(谷歌工程师在 Kubernetes 上正做着很重大的工作!但是我认为重要的仍然是研究架构,并确保它对你的组织有意义)。 我肯定不是 Kubernetes 网络方面的专家,但是我在配置 Kubernetes 网络时遇到了一些问题,并且比以前更加了解 Kubernetes 网络了。 -### 运营联网软件是很难的 +### 运维联网软件是很难的 -在这里,我并不讨论有关运营物理网络的话题(对于它我不懂),而是讨论关于如何让像 DNS 服务、负载均衡以及代理这样的软件正常工作方面的内容。 +在这里,我并不讨论有关运维物理网络的话题(对于它我不懂),而是讨论关于如何让像 DNS 服务、负载均衡以及代理这样的软件正常工作方面的内容。 -我在一个负责很多网络基础设施的团队工作过一年时间,并且因此学到了一些运营网络基础设施的知识!(显然我还有很多的知识需要继续学习)在我们开始之前有三个整体看法: - -* 联网软件经常重度依赖 Linux 内核。因此除了正确配置软件之外,你还需要确保许多不同的系统控制(sysctl)配置正确,而一个错误配置的系统控制就很容易让你处于“一切都很好”和“到处都出问题”的差别中。 +我在一个负责很多网络基础设施的团队工作过一年时间,并且因此学到了一些运维网络基础设施的知识!(显然我还有很多的知识需要继续学习)在我们开始之前有三个整体看法: +* 联网软件经常重度依赖 Linux 内核。因此除了正确配置软件之外,你还需要确保许多不同的系统控制(`sysctl`)配置正确,而一个错误配置的系统控制就很容易让你处于“一切都很好”和“到处都出问题”的差别中。 * 联网需求会随时间而发生变化(比如,你的 DNS 查询或许比上一年多了五倍!或者你的 DNS 服务器突然开始返回 TCP 协议的 DNS 响应而不是 UDP 的,它们是完全不同的内核负载!)。这意味着之前正常工作的软件突然开始出现问题。 - * 修复一个生产网络的问题,你必须有足够的经验。(例如,看这篇 [由 Sophie Haskins 写的关于 kube-dns 问题调试的文章][1])我在网络调试方面比以前进步多了,但那也是我花费了大量时间研究 Linux 网络知识之后的事了。 -我距离成为一名网络运营专家还差得很远,但是我认为以下几点很重要: +我距离成为一名网络运维专家还差得很远,但是我认为以下几点很重要: 1. 对生产网络的基础设施做重要的更改是很难得的(因为它会产生巨大的混乱) - 2. 当你对网络基础设施做重大更改时,真的应该仔细考虑如果新网络基础设施失败该如何处理 - 3. 是否有很多人都能理解你的网络配置 切换到 Kubernetes 显然是个非常大的更改!因此,我们来讨论一下可能会导致错误的地方! @@ -40,85 +36,71 @@ 在本文中我们将要讨论的 Kubernetes 网络组件有: * 网络覆盖后端(像 flannel/calico/weave 网络/romana) - * `kube-dns` - * `kube-proxy` - * 入站控制器 / 负载均衡器 - * `kubelet` 如果你打算配置 HTTP 服务,或许这些你都会用到。这些组件中的大部分我都不会用到,但是我尽可能去理解它们,因此,本文将涉及它们有关的内容。 ### 最简化的方式:为所有容器使用宿主机网络 -我们从你能做到的最简单的东西开始。这并不能让你在 Kubernetes 中运行 HTTP 服务。我认为它是非常安全的,因为在这里面可以让你动的东西很少。 +让我们从你能做到的最简单的东西开始。这并不能让你在 Kubernetes 中运行 HTTP 服务。我认为它是非常安全的,因为在这里面可以让你动的东西很少。 如果你为所有容器使用宿主机网络,我认为需要你去做的全部事情仅有: 1. 配置 kubelet,以便于容器内部正确配置 DNS - 2. 没了,就这些! -如果你为每个 Pod 直接使用宿主机网络,那就不需要 kube-dns 或者 kube-proxy 了。你都不需要一个作为基础的覆盖网络。 +如果你为每个 pod 直接使用宿主机网络,那就不需要 kube-dns 或者 kube-proxy 了。你都不需要一个作为基础的覆盖网络。 这种配置方式中,你的 pod 们都可以连接到外部网络(同样的方式,你的宿主机上的任何进程都可以与外部网络对话),但外部网络不能连接到你的 pod 们。 这并不是最重要的(我认为大多数人想在 Kubernetes 中运行 HTTP 服务并与这些服务进行真实的通讯),但我认为有趣的是,从某种程度上来说,网络的复杂性并不是绝对需要的,并且有时候你不用这么复杂的网络就可以实现你的需要。如果可以的话,尽可能地避免让网络过于复杂。 -### 运营一个覆盖网络 +### 运维一个覆盖网络 我们将要讨论的第一个网络组件是有关覆盖网络的。Kubernetes 假设每个 pod 都有一个 IP 地址,这样你就可以与那个 pod 中的服务进行通讯了。我在说到“覆盖网络”这个词时,指的就是这个意思(“让你通过它的 IP 地址指向到 pod 的系统)。 所有其它的 Kubernetes 网络的东西都依赖正确工作的覆盖网络。更多关于它的内容,你可以读 [这里的 kubernetes 网络模型][10]。 -Kelsey Hightower 在 [kubernetes the hard way][11] 中描述的方式看起来似乎很好,但是,事实上它的作法在超过 50 个节点的 AWS 上是行不通的,因此,我不打算讨论它了。 +Kelsey Hightower 在 [kubernetes 艰难之路][11] 中描述的方式看起来似乎很好,但是,事实上它的作法在超过 50 个节点的 AWS 上是行不通的,因此,我不打算讨论它了。 有许多覆盖网络后端(calico、flannel、weaveworks、romana)并且规划非常混乱。就我的观点来看,我认为一个覆盖网络有 2 个职责: 1. 确保你的 pod 能够发送网络请求到外部的集群 - 2. 保持一个到子网络的稳定的节点映射,并且保持集群中每个节点都可以使用那个映射得以更新。当添加和删除节点时,能够做出正确的反应。 Okay! 因此!你的覆盖网络可能会出现的问题是什么呢? -* 覆盖网络负责设置 iptables 规则(最基本的是 `iptables -A -t nat POSTROUTING -s $SUBNET -j MASQUERADE`),以确保那个容器能够向 Kubernetes 之外发出网络请求。如果在这个规则上有错误,你的容器就不能连接到外部网络。这并不很难(它只是几条 iptables 规则而已),但是它非常重要。我发起了一个 [pull request][2],因为我想确保它有很好的弹性。 - -* 添加或者删除节点时可能会有错误。我们使用 `flannel hostgw` 后端,我们开始使用它的时候,节点删除 [尚未开始工作][3]。 - +* 覆盖网络负责设置 iptables 规则(最基本的是 `iptables -A -t nat POSTROUTING -s $SUBNET -j MASQUERADE`),以确保那个容器能够向 Kubernetes 之外发出网络请求。如果在这个规则上有错误,你的容器就不能连接到外部网络。这并不很难(它只是几条 iptables 规则而已),但是它非常重要。我发起了一个 [拉取请求][2],因为我想确保它有很好的弹性。 +* 添加或者删除节点时可能会有错误。我们使用 `flannel hostgw` 后端,我们开始使用它的时候,节点删除功能 [尚未开始工作][3]。 * 你的覆盖网络或许依赖一个分布式数据库(etcd)。如果那个数据库发生什么问题,这将导致覆盖网络发生问题。例如,[https://github.com/coreos/flannel/issues/610][4] 上说,如果在你的 `flannel etcd` 集群上丢失了数据,最后的结果将是在容器中网络连接会丢失。(现在这个问题已经被修复了) - * 你升级 Docker 以及其它东西导致的崩溃 - * 还有更多的其它的可能性! -我在这里主要讨论的是过去发生在 Flannel 中的问题,但是我并不是要承诺不去使用 Flannel —— 事实上我很喜欢 Flannel,因为我觉得它很简单(比如,类似 [vxlan 在后端这一块的部分][12] 只有 500 行代码),并且我觉得对我来说,通过代码来找出问题的根源成为了可能。并且很显然,它在不断地改进。他们在审查 `pull requests` 方面做的很好。 +我在这里主要讨论的是过去发生在 Flannel 中的问题,但是我并不是要承诺不去使用 Flannel —— 事实上我很喜欢 Flannel,因为我觉得它很简单(比如,类似 [vxlan 在后端这一块的部分][12] 只有 500 行代码),对我来说,通过代码来找出问题的根源成为了可能。并且很显然,它在不断地改进。他们在审查拉取请求方面做的很好。 -到目前为止,我运营覆盖网络的方法是: +到目前为止,我运维覆盖网络的方法是: * 学习它的工作原理的详细内容以及如何去调试它(比如,Flannel 用于创建路由的 hostgw 网络后端,因此,你只需要使用 `sudo ip route list` 命令去查看它是否正确即可) - * 如果需要的话,维护一个内部构建版本,这样打补丁比较容易 - * 有问题时,向上游贡献补丁 -我认为去遍历所有已合并的 PR 以及过去已修复的 bug 清单真的是非常有帮助的 —— 这需要花费一些时间,但这是得到一个其它人遇到的各种问题的清单的好方法。 +我认为去遍历所有已合并的拉取请求以及过去已修复的 bug 清单真的是非常有帮助的 —— 这需要花费一些时间,但这是得到一个其它人遇到的各种问题的清单的好方法。 -对其他人来说,他们的覆盖网络可能工作的很好,但是我并不能从中得到任何经验,并且我也曾听说过其他人报告类似的问题。如果你有一个类似配置的覆盖网络:a) 在 AWS 上并且 b) 在多于 50-100 节点上运行,我想知道你运营这样的一个网络有多大的把握。 +对其他人来说,他们的覆盖网络可能工作的很好,但是我并不能从中得到任何经验,并且我也曾听说过其他人报告类似的问题。如果你有一个类似配置的覆盖网络:a) 在 AWS 上并且 b) 在多于 50-100 节点上运行,我想知道你运维这样的一个网络有多大的把握。 -### 运营 kube-proxy 和 kube-dns? +### 运维 kube-proxy 和 kube-dns? -现在,我有一些关于运营覆盖网络的想法,我们来讨论一下。 +现在,我有一些关于运维覆盖网络的想法,我们来讨论一下。 -这个标题的最后面有一个问号,那是因为我并没有真的去运营过。在这里我还有更多的问题要问答。 +这个标题的最后面有一个问号,那是因为我并没有真的去运维过。在这里我还有更多的问题要问答。 这里的 Kubernetes 服务是如何工作的!一个服务是一群 pod 们,它们中的每个都有自己的 IP 地址(像 10.1.0.3、10.2.3.5、10.3.5.6 这样) 1. 每个 Kubernetes 服务有一个 IP 地址(像 10.23.1.2 这样) - 2. `kube-dns` 去解析 Kubernetes 服务 DNS 名字为 IP 地址(因此,my-svc.my-namespace.svc.cluster.local 可能映射到 10.23.1.2 上) - 3. `kube-proxy` 配置 `iptables` 规则是为了在它们之间随机进行均衡负载。Kube-proxy 也有一个用户空间的轮询负载均衡器,但是在我的印象中,他们并不推荐使用它。 因此,当你发出一个请求到 `my-svc.my-namespace.svc.cluster.local` 时,它将解析为 10.23.1.2,然后,在你本地主机上的 `iptables` 规则(由 kube-proxy 生成)将随机重定向到 10.1.0.3 或者 10.2.3.5 或者 10.3.5.6 中的一个上。 @@ -126,9 +108,7 @@ Okay! 因此!你的覆盖网络可能会出现的问题是什么呢? 在这个过程中我能想像出的可能出问题的地方: * `kube-dns` 配置错误 - * `kube-proxy` 挂了,以致于你的 `iptables` 规则没有得以更新 - * 维护大量的 `iptables` 规则相关的一些问题 我们来讨论一下 `iptables` 规则,因为创建大量的 `iptables` 规则是我以前从没有听过的事情! @@ -141,7 +121,6 @@ kube-proxy 像如下这样为每个目标主机创建一个 `iptables` 规则: -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 - ``` 因此,kube-proxy 创建了许多 `iptables` 规则。它们都是什么意思?它对我的网络有什么样的影响?这里有一个来自华为的非常好的演讲,它叫做 [支持 50,000 个服务的可伸缩 Kubernetes][14],它说如果在你的 Kubernetes 集群中有 5,000 服务,增加一个新规则,将需要 **11 分钟**。如果这种事情发生在真实的集群中,我认为这将是一件非常糟糕的事情。 @@ -152,19 +131,16 @@ kube-proxy 像如下这样为每个目标主机创建一个 `iptables` 规则: 但是,我觉得使用 HAProxy 更舒服!它能够用于去替换 kube-proxy!我用谷歌搜索了一下,然后发现了这个 [thread on kubernetes-sig-network][15],它说: -> kube-proxy 是很难用的,我们在生产系统中使用它近一年了,它在大部分的时间都表现的很好,但是,随着我们集群中的服务越来越多,我们发现它的排错和维护工作越来越难。在我们的团队中没有 iptables 方面的专家,我们只有 HAProxy&LVS 方面的专家,由于我们已经使用它们好几年了,因此我们决定使用一个中心化的 HAProxy 去替换分布式的代理。我觉得这可能会对在 Kubernetes 中使用 HAProxy 的其他人有用,因此,我们更新了这个项目,并将它开源:[https://github.com/AdoHe/kube2haproxy][5]。如果你发现它有用,你可以去看一看、试一试。 +> kube-proxy 是很难用的,我们在生产系统中使用它近一年了,它在大部分的时间都表现的很好,但是,随着我们集群中的服务越来越多,我们发现它的排错和维护工作越来越难。在我们的团队中没有 iptables 方面的专家,我们只有 HAProxy & LVS 方面的专家,由于我们已经使用它们好几年了,因此我们决定使用一个中心化的 HAProxy 去替换分布式的代理。我觉得这可能会对在 Kubernetes 中使用 HAProxy 的其他人有用,因此,我们更新了这个项目,并将它开源:[https://github.com/AdoHe/kube2haproxy][5]。如果你发现它有用,你可以去看一看、试一试。 因此,那是一个有趣的选择!我在这里确实没有答案,但是,有一些想法: * 负载均衡器是很复杂的 - * DNS 也很复杂 +* 如果你有运维某种类型的负载均衡器(比如 HAProxy)的经验,与其使用一个全新的负载均衡器(比如 kube-proxy),还不如做一些额外的工作去使用你熟悉的那个来替换,或许更有意义。 +* 我一直在考虑,我们希望在什么地方能够完全使用 kube-proxy 或者 kube-dns —— 我认为,最好是只在 Envoy 上投入,并且在负载均衡&服务发现上完全依赖 Envoy 来做。因此,你只需要将 Envoy 运维好就可以了。 -* 如果你有运营某种类型的负载均衡器(比如 HAProxy)的经验,与其使用一个全新的负载均衡器(比如 kube-proxy),还不如做一些额外的工作去使用你熟悉的那个来替换,或许更有意义。 - -* 我一直在考虑,我们希望在什么地方能够完全使用 kube-proxy 或者 kube-dns —— 我认为,最好是只在 Envoy 上投入,并且在负载均衡&服务发现上完全依赖 Envoy 来做。因此,你只需要将 Envoy 运营好就可以了。 - -正如你所看到的,我在关于如何运营 Kubernetes 中的内部代理方面的思路还是很混乱的,并且我也没有使用它们的太多经验。总体上来说,kube-proxy 和 kube-dns 还是很好的,也能够很好地工作,但是我仍然认为应该去考虑使用它们可能产生的一些问题(例如,”你不能有超出 5000 的 Kubernetes 服务“)。 +正如你所看到的,我在关于如何运维 Kubernetes 中的内部代理方面的思路还是很混乱的,并且我也没有使用它们的太多经验。总体上来说,kube-proxy 和 kube-dns 还是很好的,也能够很好地工作,但是我仍然认为应该去考虑使用它们可能产生的一些问题(例如,”你不能有超出 5000 的 Kubernetes 服务“)。 ### 入口 @@ -175,14 +151,12 @@ kube-proxy 像如下这样为每个目标主机创建一个 `iptables` 规则: 几个有用的链接,总结如下: * [Kubernetes 网络模型][6] - * GKE 网络是如何工作的:[https://www.youtube.com/watch?v=y2bhV81MfKQ][7] - * 上述的有关 `kube-proxy` 上性能的讨论:[https://www.youtube.com/watch?v=4-pawkiazEg][8] -### 我认为网络运营很重要 +### 我认为网络运维很重要 -我对 Kubernetes 的所有这些联网软件的感觉是,它们都仍然是非常新的,并且我并不能确定我们(作为一个社区)真的知道如何去把它们运营好。这让我作为一个操作者感到很焦虑,因为我真的想让我的网络运行的很好!:) 而且我觉得作为一个组织,运行你自己的 Kubernetes 集群需要相当大的投入,以确保你理解所有的代码片段,这样当它们出现问题时你可以去修复它们。这不是一件坏事,它只是一个事而已。 +我对 Kubernetes 的所有这些联网软件的感觉是,它们都仍然是非常新的,并且我并不能确定我们(作为一个社区)真的知道如何去把它们运维好。这让我作为一个操作者感到很焦虑,因为我真的想让我的网络运行的很好!:) 而且我觉得作为一个组织,运行你自己的 Kubernetes 集群需要相当大的投入,以确保你理解所有的代码片段,这样当它们出现问题时你可以去修复它们。这不是一件坏事,它只是一个事而已。 我现在的计划是,继续不断地学习关于它们都是如何工作的,以尽可能多地减少对我动过的那些部分的担忧。 @@ -194,7 +168,7 @@ via: https://jvns.ca/blog/2017/10/10/operating-a-kubernetes-network/ 作者:[Julia Evans ][a] 译者:[qhwdw](https://github.com/qhwdw) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 5f49c561409906b615570a924c65be054e83953b Mon Sep 17 00:00:00 2001 From: pityonline Date: Mon, 10 Sep 2018 22:21:58 +0800 Subject: [PATCH 165/455] =?UTF-8?q?PRF:=20#10126=20=E6=A0=A1=E5=AF=B9?= =?UTF-8?q?=E5=B9=B6=E5=88=9D=E6=AD=A5=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 --- ...ding Linux filesystems- ext4 and beyond.md | 115 +++++++++--------- 1 file changed, 57 insertions(+), 58 deletions(-) diff --git a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md index 130e5893bf..2105d19f2d 100644 --- a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md +++ b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md @@ -1,44 +1,43 @@ - 理解 Linux 文件系统:ext4 等文件系统 -======= +====== > 了解 ext4 的历史,包括其与 ext3 和之前的其它文件系统之间的区别。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_linux11x_cc.png?itok=XMDOouJR) -目前的大部分 Linux 文件系统都默认采用 ext4 文件系统, 正如以前的 Linux 发行版默认使用 ext3、ext2 以及更久前的 ext。 +目前的大部分 Linux 文件系统都默认采用 ext4 文件系统,正如以前的 Linux 发行版默认使用 ext3、ext2 以及更久前的 ext。 对于不熟悉 Linux 或文件系统的朋友而言,你可能不清楚 ext4 相对于上一版本 ext3 带来了什么变化。你可能还想知道在一连串关于替代的文件系统例如 btrfs、xfs 和 zfs 不断被发布的情况下,ext4 是否仍然能得到进一步的发展。 -在一篇文章中,我们不可能讲述文件系统的所有方面,但我们尝试让您尽快了解 Linux 默认文件系统的发展历史,包括它的产生以及未来发展。我仔细研究了维基百科里的各种关于 ext 文件系统文章、kernel.org 的 wiki 中关于 ext4 的条目以及结合自己的经验写下这篇文章。 +在一篇文章中,我们不可能讲述文件系统的所有方面,但我们尝试让你尽快了解 Linux 默认文件系统的发展历史,包括它的产生以及未来发展。我仔细研究了维基百科里的各种关于 ext 文件系统文章、kernel.org 的 wiki 中关于 ext4 的条目以及结合自己的经验写下这篇文章。 ### ext 简史 #### MINIX 文件系统 -在有 ext 之前, 使用的是 MINIX 文件系统。如果你不熟悉 Linux 历史, 那么可以理解为 MINIX 是用于 IBM PC/AT 微型计算机的一个非常小的类 Unix 系统。Andrew Tannenbaum 为了教学的目的而开发了它,并于 1987 年发布了源代码(以印刷版的格式!)。 +在有 ext 之前,使用的是 MINIX 文件系统。如果你不熟悉 Linux 历史,那么可以理解为 MINIX 是用于 IBM PC/AT 微型计算机的一个非常小的类 Unix 系统。Andrew Tannenbaum 为了教学的目的而开发了它,并于 1987 年发布了源代码(以印刷版的格式!)。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/ibm_pc_at.jpg?itok=Tfk3hQYB) *IBM 1980 中期的 PC/AT,[MBlairMartin](https://commons.wikimedia.org/wiki/File:IBM_PC_AT.jpg),[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/deed.en)* -虽然你可以细读 MINIX 的源代码,但实际上它并不是自由开源软件(FOSS)。出版 Tannebaum 著作的出版商要求你花 69 美元的许可费来运行 MINIX,而这笔费用包含在书籍的费用中。尽管如此,在那时来说非常便宜,并且 MINIX 的使用得到迅速发展,很快超过了 Tannebaum 当初使用它来教授操作系统编码的意图。在整个 20 世纪 90 年代,你可以发现 MINIX 的安装在世界各个大学里面非常流行。而此时,年轻的 Lius Torvalds 使用 MINIX 来开发原始 Linux 内核,并于 1991 年首次公布。而后在 1992 年 12 月在 GPL 开源协议下发布。 +虽然你可以细读 MINIX 的源代码,但实际上它并不是自由开源软件(FOSS)。出版 Tannebaum 著作的出版商要求你花 69 美元的许可费来运行 MINIX,而这笔费用包含在书籍的费用中。尽管如此,在那时来说非常便宜,并且 MINIX 的使用得到迅速发展,很快超过了 Tannebaum 当初使用它来教授操作系统编码的意图。在整个 20 世纪 90 年代,你可以发现 MINIX 的安装在世界各个大学里面非常流行。而此时,年轻的 Linus Torvalds 使用 MINIX 来开发原始 Linux 内核,并于 1991 年首次公布。而后在 1992 年 12 月在 GPL 开源协议下发布。 -但是等等,这是一篇以*文件系统*为主题的文章不是吗?是的,MINIX 有自己的文件系统,早期的 Linux 版本依赖于它。跟 MINIX 一样,Linux 的文件系统也如同玩具那般小 —— MINIX 文件系统最多能处理 14 个字符的文件名,并且只能处理 64MB 的存储空间。到了 1991 年,一般的硬盘尺寸已经达到了 40-140MB。很显然,Linux 需要一个更好的文件系统。 +但是等等,这是一篇以 *文件系统* 为主题的文章不是吗?是的,MINIX 有自己的文件系统,早期的 Linux 版本依赖于它。跟 MINIX 一样,Linux 的文件系统也如同玩具那般小 —— MINIX 文件系统最多能处理 14 个字符的文件名,并且只能处理 64MB 的存储空间。到了 1991 年,一般的硬盘尺寸已经达到了 40-140MB。很显然,Linux 需要一个更好的文件系统。 #### ext -当 Linus 开发出刚起步的 Linux 内核时,Rémy Card 从事第一代的 ext 文件系统的开发工作。 ext 文件系统在 1992 首次实现并发布 —— 仅在 Linux 首次发布后的一年! —— ext 解决了 MINIX 文件系统中最糟糕的问题。 +当 Linus 开发出刚起步的 Linux 内核时,Rémy Card 从事第一代的 ext 文件系统的开发工作。ext 文件系统在 1992 首次实现并发布 —— 仅在 Linux 首次发布后的一年!—— ext 解决了 MINIX 文件系统中最糟糕的问题。 1992 年的 ext 使用在 Linux 内核中的新虚拟文件系统(VFS)抽象层。与之前的 MINIX 文件系统不同的是,ext 可以处理高达 2GB 存储空间并处理 255 个字符的文件名。 -但 ext 并没有长时间占统治地位,主要是由于它原始的时间戳(每个文件仅有一个时间戳,而不是今天我们所熟悉的有 inode 、最近文件访问时间和最新文件修改时间的时间戳。)仅仅一年后,ext2 就替代了它。 +但 ext 并没有长时间占统治地位,主要是由于它原始的时间戳(每个文件仅有一个时间戳,而不是今天我们所熟悉的有 inode、最近文件访问时间和最新文件修改时间的时间戳。)仅仅一年后,ext2 就替代了它。 #### ext2 Rémy 很快就意识到 ext 的局限性,所以一年后他设计出 ext2 替代它。当 ext 仍然根植于 “玩具” 操作系统时,ext2 从一开始就被设计为一个商业级文件系统,沿用 BSD 的 Berkeley 文件系统的设计原理。 -Ext2 提供了 GB 级别的最大文件大小和 TB 级别的文件系统大小,使其在 20 世纪 90 年代的地位牢牢巩固在文件系统大联盟中。很快它被广泛地使用,无论是在 Linux 内核中还是最终在 MINIX 中,且利用第三方模块可以使其应用于 MacOS 和 Windows。 +ext2 提供了 GB 级别的最大文件大小和 TB 级别的文件系统大小,使其在 20 世纪 90 年代的地位牢牢巩固在文件系统大联盟中。很快它被广泛地使用,无论是在 Linux 内核中还是最终在 MINIX 中,且利用第三方模块可以使其应用于 MacOS 和 Windows。 但这里仍然有一些问题需要解决:ext2 文件系统与 20 世纪 90 年代的大多数文件系统一样,如果在将数据写入到磁盘的时候,系统发生崩溃或断电,则容易发生灾难性的数据损坏。随着时间的推移,由于碎片(单个文件存储在多个位置,物理上其分散在旋转的磁盘上),它们也遭受了严重的性能损失。 @@ -46,35 +45,35 @@ Ext2 提供了 GB 级别的最大文件大小和 TB 级别的文件系统大小 #### ext3 -1998 年, 在 ext2 被采用后的 6 年后,Stephen Tweedie 宣布他正在致力于改进 ext2。这成了 ext3,并于 2001 年 11 月在 2.4.15 内核版本中被采用到 Linux 内核主线中。 +1998 年,在 ext2 被采用后的 6 年后,Stephen Tweedie 宣布他正在致力于改进 ext2。这成了 ext3,并于 2001 年 11 月在 2.4.15 内核版本中被采用到 Linux 内核主线中。 ![Packard Bell 计算机][2] *20 世纪 90 年代中期的 Packard Bell 计算机,[Spacekid][3],[CC0][4]* -在大部分情况下,Ext2 在 Linux 发行版中工作得很好,但像 FAT、FAT32、HFS 和当时的其他文件系统一样 —— 在断电时容易发生灾难性的破坏。如果在将数据写入文件系统时候发生断电,则可能会将其留在所谓*不一致*的状态 —— 事情只完成一半而另一半未完成。这可能导致大量文件丢失或损坏,这些文件与正在保存的文件无关甚至导致整个文件系统无法卸载。 +在大部分情况下,ext2 在 Linux 发行版中工作得很好,但像 FAT、FAT32、HFS 和当时的其他文件系统一样 —— 在断电时容易发生灾难性的破坏。如果在将数据写入文件系统时候发生断电,则可能会将其留在所谓 *不一致* 的状态 —— 事情只完成一半而另一半未完成。这可能导致大量文件丢失或损坏,这些文件与正在保存的文件无关甚至导致整个文件系统无法卸载。 -Ext3 和 20 世纪 90 年代后期的其他文件系统,如微软的 NTFS ,使用*日志*来解决这个问题。日志是磁盘上的一种特殊的分配区域,其写入被存储在事务中;如果该事务完成磁盘写入,则日志中的数据将提交给文件系统自身。如果系统在该操作提交前崩溃,则重新启动的系统识别其为未完成的事务而将其进行回滚,就像从未发生过一样。这意味着正在处理的文件可能依然会丢失,但文件系统*本身*保持一致,且其他所有数据都是安全的。 +ext3 和 20 世纪 90 年代后期的其他文件系统,如微软的 NTFS,使用 *日志* 来解决这个问题。日志是磁盘上的一种特殊的分配区域,其写入被存储在事务中;如果该事务完成磁盘写入,则日志中的数据将提交给文件系统自身。如果系统在该操作提交前崩溃,则重新启动的系统识别其为未完成的事务而将其进行回滚,就像从未发生过一样。这意味着正在处理的文件可能依然会丢失,但文件系统 *本身* 保持一致,且其他所有数据都是安全的。 在使用 ext3 文件系统的 Linux 内核中实现了三个级别的日志记录方式:日记journal顺序ordered回写writeback。 - * **日记** 是最低风险模式,在将数据和元数据提交给文件系统之前将其写入日志。这可以保证正在写入的文件与整个文件系统的一致性,但其显著降低了性能。 - * **顺序** 是大多数 Linux 发行版默认模式;顺序模式将元数据写入日志而直接将数据提交到文件系统。顾名思义,这里的操作顺序是固定的:首先,元数据提交到日志;其次,数据写入文件系统,然后才将日志中关联的元数据更新到文件系统。这确保了在发生崩溃时,那些与未完整写入相关联的元数据仍在日志中,且文件系统可以在回滚日志时清理那些不完整的写入事务。在顺序模式下,系统崩溃可能导致在崩溃期间文件的错误被主动写入,但文件系统它本身 —— 以及未被主动写入的文件 —— 确保是安全的。 - * **回写** 是第三种模式 —— 也是最不安全的日志模式。在回写模式下,像顺序模式一样,元数据会被记录到日志,但数据不会。与顺序模式不同,元数据和数据都可以以任何有利于获得最佳性能的顺序写入。这可以显著提高性能,但安全性低很多。尽管回写模式仍然保证文件系统本身的安全性,但在崩溃或崩溃之前写入的文件很容易丢失或损坏。 +* **日记** 是最低风险模式,在将数据和元数据提交给文件系统之前将其写入日志。这可以保证正在写入的文件与整个文件系统的一致性,但其显著降低了性能。 +* **顺序** 是大多数 Linux 发行版默认模式;顺序模式将元数据写入日志而直接将数据提交到文件系统。顾名思义,这里的操作顺序是固定的:首先,元数据提交到日志;其次,数据写入文件系统,然后才将日志中关联的元数据更新到文件系统。这确保了在发生崩溃时,那些与未完整写入相关联的元数据仍在日志中,且文件系统可以在回滚日志时清理那些不完整的写入事务。在顺序模式下,系统崩溃可能导致在崩溃期间文件的错误被主动写入,但文件系统它本身 —— 以及未被主动写入的文件 —— 确保是安全的。 +* **回写** 是第三种模式 —— 也是最不安全的日志模式。在回写模式下,像顺序模式一样,元数据会被记录到日志,但数据不会。与顺序模式不同,元数据和数据都可以以任何有利于获得最佳性能的顺序写入。这可以显著提高性能,但安全性低很多。尽管回写模式仍然保证文件系统本身的安全性,但在崩溃或崩溃之前写入的文件很容易丢失或损坏。 跟之前的 ext2 类似,ext3 使用 16 位内部寻址。这意味着对于有着 4K 块大小的 ext3 在最大规格为 16TiB 的文件系统中可以处理的最大文件大小为 2TiB。 #### ext4 -Theodore Ts'o (是当时 ext3 主要开发人员) 在 2006 年发表的 ext4 ,于两年后在 2.6.28 内核版本中被加入到了 Linux 主线。 +Theodore Ts'o(是当时 ext3 主要开发人员)在 2006 年发表的 ext4,于两年后在 2.6.28 内核版本中被加入到了 Linux 主线。 -Ts’o 将 ext4 描述为一个显著扩展 ext3 但仍然依赖于旧技术的临时技术。他预计 ext4 终将会被真正的下一代文件系统所取代。 +Ts'o 将 ext4 描述为一个显著扩展 ext3 但仍然依赖于旧技术的临时技术。他预计 ext4 终将会被真正的下一代文件系统所取代。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/dell_precision_380_workstation.jpeg?itok=3EjYXY2i) *Dell Precision 380 工作站,[Lance Fisher](https://commons.wikimedia.org/wiki/File:Dell_Precision_380_Workstation.jpeg),[CC BY-SA 2.0](https://creativecommons.org/licenses/by-sa/2.0/deed.en)* -Ext4 在功能上与 Ext3 在功能上非常相似,但支持大文件系统、提高了对碎片的抵抗力,有更高的性能以及更好的时间戳。 +ext4 在功能上与 ext3 在功能上非常相似,但支持大文件系统、提高了对碎片的抵抗力,有更高的性能以及更好的时间戳。 ### ext4 vs ext3 @@ -110,15 +109,15 @@ ext3 为每一个新分配的块调用一次块分配器。当多个写入同时 这是一个耐人寻味而有争议性的功能。延迟分配允许 ext4 等待分配将写入数据的实际块,直到它准备好将数据提交到磁盘。(相比之下,即使数据仍然在往写入缓存中写入,ext3 也会立即分配块。) -当缓存中的数据累积时,延迟分配块允许文件系统对如何分配块做出更好的选择,降低碎片(写入,以及稍后的读)并显著提升性能。然而不幸的是,它*增加*了还没有专门调用 `fsync()` 方法(当程序员想确保数据完全刷新到磁盘时)的程序的数据丢失的可能性。 +当缓存中的数据累积时,延迟分配块允许文件系统对如何分配块做出更好的选择,降低碎片(写入,以及稍后的读)并显著提升性能。然而不幸的是,它 *增加* 了还没有专门调用 `fsync()` 方法(当程序员想确保数据完全刷新到磁盘时)的程序的数据丢失的可能性。 假设一个程序完全重写了一个文件: ``` -fd=open("file" ,O_TRUNC); write(fd, data); close(fd); +fd=open("file", O_TRUNC); write(fd, data); close(fd); ``` -使用旧的文件系统, `close(fd);` 足以保证 `file` 中的内容刷新到磁盘。即使严格来说,写不是事务性的,但如果文件关闭后发生崩溃,则丢失数据的风险很小。 +使用旧的文件系统,`close(fd);` 足以保证 `file` 中的内容刷新到磁盘。即使严格来说,写不是事务性的,但如果文件关闭后发生崩溃,则丢失数据的风险很小。 如果写入不成功(由于程序上的错误、磁盘上的错误、断电等),文件的原始版本和较新版本都可能丢失数据或损坏。如果其他进程在写入文件时访问文件,则会看到损坏的版本。如果其他进程打开文件并且不希望其内容发生更改 —— 例如,映射到多个正在运行的程序的共享库。这些进程可能会崩溃。 @@ -128,9 +127,9 @@ fd=open("file" ,O_TRUNC); write(fd, data); close(fd); fd=open("newfile"); write(fd, data); close(fd); rename("newfile", "file"); ``` -在*没有*延迟分配的文件系统下,这足以避免上面列出的潜在的损坏和崩溃问题:因为`rename()` 是原子操作,所以它不会被崩溃中断;并且运行的程序将继续引用旧的文件。现在 `file` 的未链接版本只要有一个打开的文件文件句柄即可。但是因为 ext4 的延迟分配会导致写入被延迟和重新排序,`rename("newfile","file")` 可以在 `newfile` 的内容实际写入磁盘内容之前执行,这出现了并行进行再次获得 `file` 坏版本的问题。 +在 *没有* 延迟分配的文件系统下,这足以避免上面列出的潜在的损坏和崩溃问题:因为 `rename()` 是原子操作,所以它不会被崩溃中断;并且运行的程序将继续引用旧的文件。现在 `file` 的未链接版本只要有一个打开的文件文件句柄即可。但是因为 ext4 的延迟分配会导致写入被延迟和重新排序,`rename("newfile","file")` 可以在 `newfile` 的内容实际写入磁盘内容之前执行,这出现了并行进行再次获得 `file` 坏版本的问题。 -为了缓解这种情况,Linux 内核(自版本 2.6.30 )尝试检测这些常见代码情况并强制立即分配。这会减少但不能防止数据丢失的可能性 —— 并且它对新文件没有任何帮助。如果你是一位开发人员,请注意:保证数据立即写入磁盘的唯一方法是正确调用 `fsync()` 。 +为了缓解这种情况,Linux 内核(自版本 2.6.30)尝试检测这些常见代码情况并强制立即分配。这会减少但不能防止数据丢失的可能性 —— 并且它对新文件没有任何帮助。如果你是一位开发人员,请注意:保证数据立即写入磁盘的唯一方法是正确调用 `fsync()`。 #### 无限制的子目录 @@ -139,10 +138,10 @@ ext3 仅限于 32000 个子目录;ext4 允许无限数量的子目录。从 2. #### 日志校验 ext3 没有对日志进行校验,这给处于内核直接控制之外的磁盘或带有自己的缓存的控制器设备带来了问题。如果控制器或具有自己的缓存的磁盘脱离了写入顺序,则可能会破坏 ext3 的日记事务顺序,从而可能破坏在崩溃期间(或之前一段时间)写入的文件。 - -理论上,这个问题可以使用写入障碍barrier —— 在安装文件系统时,你在挂载选项设置 `barrier=1` ,然后设备就会忠实地执行 `fsync` 一直向下到底层硬件。通过实践,可以发现存储设备和控制器经常不遵守写入障碍 —— 提高性能(和跟竞争对手比较的性能基准),但增加了本应该防止数据损坏的可能性。 -对日志进行校验和允许文件系统崩溃后第一次挂载时意识到其某些条目是无效或无序的。因此,这避免了回滚部分条目或无序日志条目的错误,并进一步损坏的文件系统——即使部分存储设备假做或不遵守写入障碍。 +理论上,这个问题可以使用写入障碍barrier —— 在安装文件系统时,你在挂载选项设置 `barrier=1`,然后设备就会忠实地执行 `fsync` 一直向下到底层硬件。通过实践,可以发现存储设备和控制器经常不遵守写入障碍 —— 提高性能(和跟竞争对手比较的性能基准),但增加了本应该防止数据损坏的可能性。 + +对日志进行校验和允许文件系统崩溃后第一次挂载时意识到其某些条目是无效或无序的。因此,这避免了回滚部分条目或无序日志条目的错误,并进一步损坏的文件系统 —— 即使部分存储设备假做或不遵守写入障碍。 #### 快速文件系统检查 @@ -152,7 +151,7 @@ ext3 没有对日志进行校验,这给处于内核直接控制之外的磁盘 ext3 提供粒度为一秒的时间戳。虽然足以满足大多数用途,但任务关键型应用程序经常需要更严格的时间控制。ext4 通过提供纳秒级的时间戳,使其可用于那些企业、科学以及任务关键型的应用程序。 -ext3 文件系统也没有提供足够的位来存储 2038 年 1 月 18 日以后的日期。ext4 在这里增加了两个位,将 [Unix 纪元][5] 扩展了 408 年。如果你在公元 2446 年读到这篇文章,你很有可能已经转移到一个更好的文件系统 —— 如果你还在测量自 1970 年 1 月 1 日 00:00(UTC)以来的时间,这会让我死后得以安眠。 +ext3 文件系统也没有提供足够的位来存储 2038 年 1 月 18 日以后的日期。ext4 在这里增加了两个位,将 [Unix 纪元][5]扩展了 408 年。如果你在公元 2446 年读到这篇文章,你很有可能已经转移到一个更好的文件系统 —— 如果你还在测量自 1970 年 1 月 1 日 00:00(UTC)以来的时间,这会让我死后得以安眠。 #### 在线碎片整理 @@ -160,11 +159,11 @@ ext2 和 ext3 都不直接支持在线碎片整理 —— 即在挂载时会对 尽管 ext3 最初被认为“不受碎片影响”,但对同一文件(例如 BitTorrent)采用大规模并行写入过程的过程清楚地表明情况并非完全如此。一些用户空间的手段和解决方法,例如 [Shake][6],以这样或那样方式解决了这个问题 —— 但它们比真正的、文件系统感知的、内核级碎片整理过程更慢并且在各方面都不太令人满意。 -ext4通过 `e4defrag` 解决了这个问题,且是一个在线、内核模式、文件系统感知、块和区段级别的碎片整理实用程序。 +ext4 通过 `e4defrag` 解决了这个问题,且是一个在线、内核模式、文件系统感知、块和区段级别的碎片整理实用程序。 ### 正在进行的 ext4 开发 -ext4,正如 Monty Python 中瘟疫感染者曾经说过的那样,“我还没死呢!” 虽然它的[主要开发人员][7]认为它只是一个真正的[下一代文件系统][8]的权宜之计,但是在一段时间内,没有任何可能的候选人准备好(由于技术或许可问题)部署为根文件系统。 +ext4,正如 Monty Python 中瘟疫感染者曾经说过的那样,“我还没死呢!”虽然它的[主要开发人员][7]认为它只是一个真正的[下一代文件系统][8]的权宜之计,但是在一段时间内,没有任何可能的候选人准备好(由于技术或许可问题)部署为根文件系统。 在未来的 ext4 版本中仍然有一些关键功能要开发,包括元数据校验和、一流的配额支持和大分配块。 @@ -172,7 +171,7 @@ ext4,正如 Monty Python 中瘟疫感染者曾经说过的那样,“我还 由于 ext4 具有冗余超级块,因此为文件系统校验其中的元数据提供了一种方法,可以自行确定主超级块是否已损坏并需要使用备用块。可以在没有校验和的情况下,从损坏的超级块恢复 —— 但是用户首先需要意识到它已损坏,然后尝试使用备用方法手动挂载文件系统。由于在某些情况下,使用损坏的主超级块安装文件系统读写可能会造成进一步的损坏,即使是经验丰富的用户也无法避免,这也不是一个完美的解决方案! -与 btrfs 或 zfs 等下一代文件系统提供的极其强大的每块校验和相比,ext4 的元数据校验和的功能非常弱。但它总比没有好。虽然校验**所有的事情**都听起来很简单!—— 事实上,将校验和与文件系统连接到一起有一些重大的挑战;请参阅[设计文档][9]了解详细信息。 +与 btrfs 或 zfs 等下一代文件系统提供的极其强大的每块校验和相比,ext4 的元数据校验和的功能非常弱。但它总比没有好。虽然校验 **所有的事情** 都听起来很简单!—— 事实上,将校验和与文件系统连接到一起有一些重大的挑战;请参阅[设计文档][9]了解详细信息。 #### 一流的配额支持 @@ -180,35 +179,35 @@ ext4,正如 Monty Python 中瘟疫感染者曾经说过的那样,“我还 #### 大分配块 -随着时间的推移,那些讨厌的存储系统不断变得越来越大。由于一些固态硬盘已经使用 8K 硬件块大小,因此 ext4 对 4K 模块的当前限制越来越受到限制。较大的存储块可以显著减少碎片并提高性能,代价是增加“松弛”空间(当您只需要块的一部分来存储文件或文件的最后一块时留下的空间)。 +随着时间的推移,那些讨厌的存储系统不断变得越来越大。由于一些固态硬盘已经使用 8K 硬件块大小,因此 ext4 对 4K 模块的当前限制越来越受到限制。较大的存储块可以显著减少碎片并提高性能,代价是增加“松弛”空间(当你只需要块的一部分来存储文件或文件的最后一块时留下的空间)。 -您可以在[设计文档][11]中查看详细说明。 +你可以在[设计文档][11]中查看详细说明。 ### ext4 的实际限制 ext4 是一个健壮、稳定的文件系统。如今大多数人都应该在用它作为根文件系统,但它无法处理所有需求。让我们简单地谈谈你不应该期待的一些事情 —— 现在或可能在未来: -虽然 ext4 可以处理高达 1 EiB 大小(相当于 1,000,000 TiB)大小的数据,但你真的、*真的*不应该尝试这样做。除了能够记住更多块的地址之外,还存在规模上的问题。并且现在 ext4 不会处理(并且可能永远不会)超过 50 —— 100TiB 的数据。 +虽然 ext4 可以处理高达 1 EiB 大小(相当于 1,000,000 TiB)大小的数据,但你 *真的* 不应该尝试这样做。除了能够记住更多块的地址之外,还存在规模上的问题。并且现在 ext4 不会处理(并且可能永远不会)超过 50-100TiB 的数据。 -ext4 也不足以保证数据的完整性。随着日志记录的重大进展又回到了 ext3 的那个时候,它并未涵盖数据损坏的许多常见原因。如果数据已经在磁盘上被[破坏][12]——由于故障硬件,宇宙射线的影响(是的,真的),或者只是数据随时间衰减 —— ext4 无法检测或修复这种损坏。 +ext4 也不足以保证数据的完整性。随着日志记录的重大进展又回到了 ext3 的那个时候,它并未涵盖数据损坏的许多常见原因。如果数据已经在磁盘上被[破坏][12] —— 由于故障硬件,宇宙射线的影响(是的,真的),或者只是数据随时间衰减 —— ext4 无法检测或修复这种损坏。 -基于上面两点,ext4 只是一个纯*文件系统*,而不是存储卷管理器。这意味着,即使你有多个磁盘——也就是奇偶校验或冗余,理论上你可以从 ext4 中恢复损坏的数据,但无法知道使用它是否对你有利。虽然理论上可以在不同的层中分离文件系统和存储卷管理系统而不会丢失自动损坏检测和修复功能,但这不是当前存储系统的设计方式,并且它将给新设计带来重大挑战。 +基于上面两点,ext4 只是一个纯 *文件系统*,而不是存储卷管理器。这意味着,即使你有多个磁盘 —— 也就是奇偶校验或冗余,理论上你可以从 ext4 中恢复损坏的数据,但无法知道使用它是否对你有利。虽然理论上可以在不同的层中分离文件系统和存储卷管理系统而不会丢失自动损坏检测和修复功能,但这不是当前存储系统的设计方式,并且它将给新设计带来重大挑战。 ### 备用文件系统 在我们开始之前,提醒一句:要非常小心,没有任何备用的文件系统作为主线内核的一部分而内置和直接支持! -即使一个文件系统是*安全的*,如果在内核升级期间出现问题,使用它作为根文件系统也是非常可怕的。如果你没有充分的理由通过一个 chroot 去使用替代介质引导,耐心地操作内核模块、 grub 配置和 DKMS...不要在一个很重要的系统中去掉预留的根文件。 +即使一个文件系统是 *安全的*,如果在内核升级期间出现问题,使用它作为根文件系统也是非常可怕的。如果你没有充分的理由通过一个 chroot 去使用替代介质引导,耐心地操作内核模块、grub 配置和 DKMS……不要在一个很重要的系统中去掉预留的根文件。 -可能有充分的理由使用您的发行版不直接支持的文件系统 —— 但如果您这样做,我强烈建议您在系统启动并可用后再安装它。(例如,您可能有一个 ext4 根文件系统,但是将大部分数据存储在 zfs 或 btrfs 池中。) +可能有充分的理由使用你的发行版不直接支持的文件系统 —— 但如果你这样做,我强烈建议你在系统启动并可用后再安装它。(例如,你可能有一个 ext4 根文件系统,但是将大部分数据存储在 zfs 或 btrfs 池中。) #### XFS -XFS 与非 ext 文件系统在 Linux 中的主线中的地位一样。它是一个 64 位的日志文件系统,自 2001 年以来内置于 Linux 内核中,为大型文件系统和高度并发性提供了高性能(即,大量的进程都会立即写入文件系统)。 +XFS 与非 ext 文件系统在 Linux 中的主线中的地位一样。它是一个 64 位的日志文件系统,自 2001 年以来内置于 Linux 内核中,为大型文件系统和高度并发性提供了高性能(即大量的进程都会立即写入文件系统)。 从 RHEL 7 开始,XFS 成为 Red Hat Enterprise Linux 的默认文件系统。对于家庭或小型企业用户来说,它仍然有一些缺点 —— 最值得注意的是,重新调整现有 XFS 文件系统是一件非常痛苦的事情,不如创建另一个并复制数据更有意义。 -虽然 XFS 是稳定且是高性能的,但它和 ext4 之间没有足够具体的最终用途差异,以值得推荐在非默认(例如,RHEL7)的任何地方使用它,除非它解决了对 ext4 的特定问题,例如 > 50 TiB 容量的文件系统。 +虽然 XFS 是稳定且是高性能的,但它和 ext4 之间没有足够具体的最终用途差异,以值得推荐在非默认(如 RHEL7)的任何地方使用它,除非它解决了对 ext4 的特定问题,例如 > 50 TiB 容量的文件系统。 XFS 在任何方面都不是 ZFS、btrfs 甚至 WAFL(一个专有的 SAN 文件系统)的“下一代”文件系统。就像 ext4 一样,它应该被视为一种更好的方式的权宜之计。 @@ -218,13 +217,13 @@ ZFS 由 Sun Microsystems 开发,以 zettabyte 命名 —— 相当于 1 万亿 作为真正的下一代文件系统,ZFS 提供卷管理(能够在单个文件系统中处理多个单独的存储设备),块级加密校验和(允许以极高的准确率检测数据损坏),[自动损坏修复][12](其中冗余或奇偶校验存储可用),[快速异步增量复制][13],内联压缩等,[以及更多][14]。 -从 Linux 用户的角度来看,ZFS 的最大问题是许可证问题。ZFS 许可证是 CDDL 许可证,这是一种与 GPL 冲突的半许可许可证。关于在 Linux 内核中使用 ZFS 的意义存在很多争议,其争议范围从“它是 GPL 违规”到“它是 CDDL 违规”到“它完全没问题,它还没有在法庭上进行过测试。 ” 最值得注意的是,自 2016 年以来 Canonical 已将 ZFS 代码内联在其默认内核中,而且目前尚无法律挑战。 +从 Linux 用户的角度来看,ZFS 的最大问题是许可证问题。ZFS 许可证是 CDDL 许可证,这是一种与 GPL 冲突的半许可许可证。关于在 Linux 内核中使用 ZFS 的意义存在很多争议,其争议范围从“它是 GPL 违规”到“它是 CDDL 违规”到“它完全没问题,它还没有在法庭上进行过测试。”最值得注意的是,自 2016 年以来 Canonical 已将 ZFS 代码内联在其默认内核中,而且目前尚无法律挑战。 此时,即使我作为一个非常狂热于 ZFS 的用户,我也不建议将 ZFS 作为 Linux 的 root 文件系统。如果你想在 Linux 上利用 ZFS 的优势,用 ext4 设置一个小的根文件系统,然后将 ZFS 用在你剩余的存储上,把数据、应用程序以及你喜欢的东西放在它上面 —— 但把 root 保留在 ext4 上,直到你的发行版明显支持 zfs 根目录。 #### BTRFS -Btrfs 是 B-Tree Filesystem 的简称,通常发音为 “butter” —— 由 Chris Mason 于 2007 年在 Oracle 任职期间发布。BTRFS 旨在跟 ZFS 有大部分相同的目标,提供多种设备管理、每块校验、异步复制、直列压缩等,[还有更多][8]。 +btrfs 是 B-Tree Filesystem 的简称,通常发音为 “butter” —— 由 Chris Mason 于 2007 年在 Oracle 任职期间发布。BTRFS 旨在跟 ZFS 有大部分相同的目标,提供多种设备管理、每块校验、异步复制、直列压缩等,[还有更多][8]。 截至 2018 年,btrfs 相当稳定,可用作标准的单磁盘文件系统,但可能不应该依赖于卷管理器。与许多常见用例中的 ext4、XFS 或 ZFS 相比,它存在严重的性能问题,其下一代功能 —— 复制、多磁盘拓扑和快照管理 —— 可能非常多,其结果可能是从灾难性地性能降低到实际数据的丢失。 @@ -237,22 +236,22 @@ via: https://opensource.com/article/18/4/ext4-filesystem 作者:[Jim Salter][a] 译者:[HardworkFish](https://github.com/HardworkFish) -校对:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy)、[pityonline](https://github.com/pityonline) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 -[a]:https://opensource.com/users/jim-salter -[1]:https://opensource.com/file/391546 -[2]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/packard_bell_pc.jpg?itok=VI8dzcwp (Packard Bell computer) -[3]:https://commons.wikimedia.org/wiki/File:Old_packard_bell_pc.jpg -[4]:https://creativecommons.org/publicdomain/zero/1.0/deed.en -[5]:https://en.wikipedia.org/wiki/Unix_time -[6]:https://vleu.net/shake/ -[7]:http://www.linux-mag.com/id/7272/ -[8]:https://arstechnica.com/information-technology/2014/01/bitrot-and-atomic-cows-inside-next-gen-filesystems/ -[9]:https://ext4.wiki.kernel.org/index.php/Ext4_Metadata_Checksums -[10]:https://ext4.wiki.kernel.org/index.php/Design_For_1st_Class_Quota_in_Ext4 -[11]:https://ext4.wiki.kernel.org/index.php/Design_for_Large_Allocation_Blocks -[12]:https://en.wikipedia.org/wiki/Data_degradation#Visual_example_of_data_degradation -[13]:https://arstechnica.com/information-technology/2015/12/rsync-net-zfs-replication-to-the-cloud-is-finally-here-and-its-fast/ -[14]:https://arstechnica.com/information-technology/2014/02/ars-walkthrough-using-the-zfs-next-gen-filesystem-on-linux/ +[a]: https://opensource.com/users/jim-salter +[1]: https://opensource.com/file/391546 +[2]: https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/packard_bell_pc.jpg?itok=VI8dzcwp (Packard Bell computer) +[3]: https://commons.wikimedia.org/wiki/File:Old_packard_bell_pc.jpg +[4]: https://creativecommons.org/publicdomain/zero/1.0/deed.en +[5]: https://en.wikipedia.org/wiki/Unix_time +[6]: https://vleu.net/shake/ +[7]: http://www.linux-mag.com/id/7272/ +[8]: https://arstechnica.com/information-technology/2014/01/bitrot-and-atomic-cows-inside-next-gen-filesystems/ +[9]: https://ext4.wiki.kernel.org/index.php/Ext4_Metadata_Checksums +[10]: https://ext4.wiki.kernel.org/index.php/Design_For_1st_Class_Quota_in_Ext4 +[11]: https://ext4.wiki.kernel.org/index.php/Design_for_Large_Allocation_Blocks +[12]: https://en.wikipedia.org/wiki/Data_degradation#Visual_example_of_data_degradation +[13]: https://arstechnica.com/information-technology/2015/12/rsync-net-zfs-replication-to-the-cloud-is-finally-here-and-its-fast/ +[14]: https://arstechnica.com/information-technology/2014/02/ars-walkthrough-using-the-zfs-next-gen-filesystem-on-linux/ From c932875f7558b92cdaf1ff7aa24372376d1474a1 Mon Sep 17 00:00:00 2001 From: pityonline Date: Mon, 10 Sep 2018 22:26:19 +0800 Subject: [PATCH 166/455] =?UTF-8?q?PRF:=20#10126=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=93=E6=9C=89=E5=90=8D=E8=AF=8D=E6=8B=BC=E5=86=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nding Linux filesystems- ext4 and beyond.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md index 2105d19f2d..b0bfd6f30b 100644 --- a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md +++ b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md @@ -7,7 +7,7 @@ 目前的大部分 Linux 文件系统都默认采用 ext4 文件系统,正如以前的 Linux 发行版默认使用 ext3、ext2 以及更久前的 ext。 -对于不熟悉 Linux 或文件系统的朋友而言,你可能不清楚 ext4 相对于上一版本 ext3 带来了什么变化。你可能还想知道在一连串关于替代的文件系统例如 btrfs、xfs 和 zfs 不断被发布的情况下,ext4 是否仍然能得到进一步的发展。 +对于不熟悉 Linux 或文件系统的朋友而言,你可能不清楚 ext4 相对于上一版本 ext3 带来了什么变化。你可能还想知道在一连串关于替代的文件系统例如 Btrfs、XFS 和 ZFS 不断被发布的情况下,ext4 是否仍然能得到进一步的发展。 在一篇文章中,我们不可能讲述文件系统的所有方面,但我们尝试让你尽快了解 Linux 默认文件系统的发展历史,包括它的产生以及未来发展。我仔细研究了维基百科里的各种关于 ext 文件系统文章、kernel.org 的 wiki 中关于 ext4 的条目以及结合自己的经验写下这篇文章。 @@ -171,7 +171,7 @@ ext4,正如 Monty Python 中瘟疫感染者曾经说过的那样,“我还 由于 ext4 具有冗余超级块,因此为文件系统校验其中的元数据提供了一种方法,可以自行确定主超级块是否已损坏并需要使用备用块。可以在没有校验和的情况下,从损坏的超级块恢复 —— 但是用户首先需要意识到它已损坏,然后尝试使用备用方法手动挂载文件系统。由于在某些情况下,使用损坏的主超级块安装文件系统读写可能会造成进一步的损坏,即使是经验丰富的用户也无法避免,这也不是一个完美的解决方案! -与 btrfs 或 zfs 等下一代文件系统提供的极其强大的每块校验和相比,ext4 的元数据校验和的功能非常弱。但它总比没有好。虽然校验 **所有的事情** 都听起来很简单!—— 事实上,将校验和与文件系统连接到一起有一些重大的挑战;请参阅[设计文档][9]了解详细信息。 +与 Btrfs 或 ZFS 等下一代文件系统提供的极其强大的每块校验和相比,ext4 的元数据校验和的功能非常弱。但它总比没有好。虽然校验 **所有的事情** 都听起来很简单!—— 事实上,将校验和与文件系统连接到一起有一些重大的挑战;请参阅[设计文档][9]了解详细信息。 #### 一流的配额支持 @@ -199,7 +199,7 @@ ext4 也不足以保证数据的完整性。随着日志记录的重大进展又 即使一个文件系统是 *安全的*,如果在内核升级期间出现问题,使用它作为根文件系统也是非常可怕的。如果你没有充分的理由通过一个 chroot 去使用替代介质引导,耐心地操作内核模块、grub 配置和 DKMS……不要在一个很重要的系统中去掉预留的根文件。 -可能有充分的理由使用你的发行版不直接支持的文件系统 —— 但如果你这样做,我强烈建议你在系统启动并可用后再安装它。(例如,你可能有一个 ext4 根文件系统,但是将大部分数据存储在 zfs 或 btrfs 池中。) +可能有充分的理由使用你的发行版不直接支持的文件系统 —— 但如果你这样做,我强烈建议你在系统启动并可用后再安装它。(例如,你可能有一个 ext4 根文件系统,但是将大部分数据存储在 ZFS 或 Btrfs 池中。) #### XFS @@ -209,7 +209,7 @@ XFS 与非 ext 文件系统在 Linux 中的主线中的地位一样。它是一 虽然 XFS 是稳定且是高性能的,但它和 ext4 之间没有足够具体的最终用途差异,以值得推荐在非默认(如 RHEL7)的任何地方使用它,除非它解决了对 ext4 的特定问题,例如 > 50 TiB 容量的文件系统。 -XFS 在任何方面都不是 ZFS、btrfs 甚至 WAFL(一个专有的 SAN 文件系统)的“下一代”文件系统。就像 ext4 一样,它应该被视为一种更好的方式的权宜之计。 +XFS 在任何方面都不是 ZFS、Btrfs 甚至 WAFL(一个专有的 SAN 文件系统)的“下一代”文件系统。就像 ext4 一样,它应该被视为一种更好的方式的权宜之计。 #### ZFS @@ -219,15 +219,15 @@ ZFS 由 Sun Microsystems 开发,以 zettabyte 命名 —— 相当于 1 万亿 从 Linux 用户的角度来看,ZFS 的最大问题是许可证问题。ZFS 许可证是 CDDL 许可证,这是一种与 GPL 冲突的半许可许可证。关于在 Linux 内核中使用 ZFS 的意义存在很多争议,其争议范围从“它是 GPL 违规”到“它是 CDDL 违规”到“它完全没问题,它还没有在法庭上进行过测试。”最值得注意的是,自 2016 年以来 Canonical 已将 ZFS 代码内联在其默认内核中,而且目前尚无法律挑战。 -此时,即使我作为一个非常狂热于 ZFS 的用户,我也不建议将 ZFS 作为 Linux 的 root 文件系统。如果你想在 Linux 上利用 ZFS 的优势,用 ext4 设置一个小的根文件系统,然后将 ZFS 用在你剩余的存储上,把数据、应用程序以及你喜欢的东西放在它上面 —— 但把 root 保留在 ext4 上,直到你的发行版明显支持 zfs 根目录。 +此时,即使我作为一个非常狂热于 ZFS 的用户,我也不建议将 ZFS 作为 Linux 的 root 文件系统。如果你想在 Linux 上利用 ZFS 的优势,用 ext4 设置一个小的根文件系统,然后将 ZFS 用在你剩余的存储上,把数据、应用程序以及你喜欢的东西放在它上面 —— 但把 root 保留在 ext4 上,直到你的发行版明显支持 ZFS 根目录。 -#### BTRFS +#### Btrfs -btrfs 是 B-Tree Filesystem 的简称,通常发音为 “butter” —— 由 Chris Mason 于 2007 年在 Oracle 任职期间发布。BTRFS 旨在跟 ZFS 有大部分相同的目标,提供多种设备管理、每块校验、异步复制、直列压缩等,[还有更多][8]。 +Btrfs 是 B-Tree Filesystem 的简称,通常发音为 “butter” —— 由 Chris Mason 于 2007 年在 Oracle 任职期间发布。Btrfs 旨在跟 ZFS 有大部分相同的目标,提供多种设备管理、每块校验、异步复制、直列压缩等,[还有更多][8]。 -截至 2018 年,btrfs 相当稳定,可用作标准的单磁盘文件系统,但可能不应该依赖于卷管理器。与许多常见用例中的 ext4、XFS 或 ZFS 相比,它存在严重的性能问题,其下一代功能 —— 复制、多磁盘拓扑和快照管理 —— 可能非常多,其结果可能是从灾难性地性能降低到实际数据的丢失。 +截至 2018 年,Btrfs 相当稳定,可用作标准的单磁盘文件系统,但可能不应该依赖于卷管理器。与许多常见用例中的 ext4、XFS 或 ZFS 相比,它存在严重的性能问题,其下一代功能 —— 复制、多磁盘拓扑和快照管理 —— 可能非常多,其结果可能是从灾难性地性能降低到实际数据的丢失。 -btrfs 的维持状态是有争议的;SUSE Enterprise Linux 在 2015 年采用它作为默认文件系统,而 Red Hat 于 2017 年宣布它从 RHEL 7.4 开始不再支持 btrfs。可能值得注意的是,该产品支持 btrfs 部署用作单磁盘文件系统,而不是像 ZFS 中的多磁盘卷管理器,甚至 Synology 在它的存储设备使用 BTRFS, +Btrfs 的维持状态是有争议的;SUSE Enterprise Linux 在 2015 年采用它作为默认文件系统,而 Red Hat 于 2017 年宣布它从 RHEL 7.4 开始不再支持 Btrfs。可能值得注意的是,该产品支持 Btrfs 部署用作单磁盘文件系统,而不是像 ZFS 中的多磁盘卷管理器,甚至 Synology 在它的存储设备使用 Btrfs, 但是它在传统 Linux 内核 RAID(mdraid)之上分层来管理磁盘。 -------------------------------------------------------------------------------- From 2b333b752161235d00b68804f75f7239f9cfa6bb Mon Sep 17 00:00:00 2001 From: pityonline Date: Mon, 10 Sep 2018 22:34:18 +0800 Subject: [PATCH 167/455] =?UTF-8?q?PRF:=20#10126=20=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E6=A0=A1=E5=AF=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 其他 => 其它 * 调整语句及用词 * 调整数字与单位之间的空白 --- ...ding Linux filesystems- ext4 and beyond.md | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md index b0bfd6f30b..88f265ae29 100644 --- a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md +++ b/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md @@ -9,7 +9,9 @@ 对于不熟悉 Linux 或文件系统的朋友而言,你可能不清楚 ext4 相对于上一版本 ext3 带来了什么变化。你可能还想知道在一连串关于替代的文件系统例如 Btrfs、XFS 和 ZFS 不断被发布的情况下,ext4 是否仍然能得到进一步的发展。 -在一篇文章中,我们不可能讲述文件系统的所有方面,但我们尝试让你尽快了解 Linux 默认文件系统的发展历史,包括它的产生以及未来发展。我仔细研究了维基百科里的各种关于 ext 文件系统文章、kernel.org 的 wiki 中关于 ext4 的条目以及结合自己的经验写下这篇文章。 +在一篇文章中,我们不可能讲述文件系统的所有方面,但我们尝试让你尽快了解 Linux 默认文件系统的发展历史,包括它的诞生以及未来发展。 + +我仔细研究了维基百科里的各种关于 ext 文件系统文章、kernel.org 的 wiki 中关于 ext4 的条目以及结合自己的经验写下这篇文章。 ### ext 简史 @@ -21,15 +23,15 @@ *IBM 1980 中期的 PC/AT,[MBlairMartin](https://commons.wikimedia.org/wiki/File:IBM_PC_AT.jpg),[CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/deed.en)* -虽然你可以细读 MINIX 的源代码,但实际上它并不是自由开源软件(FOSS)。出版 Tannebaum 著作的出版商要求你花 69 美元的许可费来运行 MINIX,而这笔费用包含在书籍的费用中。尽管如此,在那时来说非常便宜,并且 MINIX 的使用得到迅速发展,很快超过了 Tannebaum 当初使用它来教授操作系统编码的意图。在整个 20 世纪 90 年代,你可以发现 MINIX 的安装在世界各个大学里面非常流行。而此时,年轻的 Linus Torvalds 使用 MINIX 来开发原始 Linux 内核,并于 1991 年首次公布。而后在 1992 年 12 月在 GPL 开源协议下发布。 +虽然你可以细读 MINIX 的源代码,但实际上它并不是自由开源软件(FOSS)。出版 Tannebaum 著作的出版商要求你花 69 美元的许可费来运行 MINIX,而这笔费用包含在书籍的费用中。尽管如此,在那时来说非常便宜,并且 MINIX 的使用得到迅速发展,很快超过了 Tannebaum 当初使用它来教授操作系统编码的意图。在整个 20 世纪 90 年代,你可以发现 MINIX 的安装在世界各个大学里面非常流行。而此时,年轻的 Linus Torvalds 使用 MINIX 来开发原始 Linux 内核,并于 1991 年首次公布,而后在 1992 年 12 月在 GPL 开源协议下发布。 -但是等等,这是一篇以 *文件系统* 为主题的文章不是吗?是的,MINIX 有自己的文件系统,早期的 Linux 版本依赖于它。跟 MINIX 一样,Linux 的文件系统也如同玩具那般小 —— MINIX 文件系统最多能处理 14 个字符的文件名,并且只能处理 64MB 的存储空间。到了 1991 年,一般的硬盘尺寸已经达到了 40-140MB。很显然,Linux 需要一个更好的文件系统。 +但是等等,这是一篇以 *文件系统* 为主题的文章不是吗?是的,MINIX 有自己的文件系统,早期的 Linux 版本依赖于它。跟 MINIX 一样,Linux 的文件系统也如同玩具那般小 —— MINIX 文件系统最多能处理 14 个字符的文件名,并且只能处理 64MB 的存储空间。到了 1991 年,一般的硬盘尺寸已经达到了 40-140 MB。很显然,Linux 需要一个更好的文件系统。 #### ext -当 Linus 开发出刚起步的 Linux 内核时,Rémy Card 从事第一代的 ext 文件系统的开发工作。ext 文件系统在 1992 首次实现并发布 —— 仅在 Linux 首次发布后的一年!—— ext 解决了 MINIX 文件系统中最糟糕的问题。 +当 Linus 开发出刚起步的 Linux 内核时,Rémy Card 从事第一代的 ext 文件系统的开发工作。ext 文件系统在 1992 年首次实现并发布 —— 仅在 Linux 首次发布后的一年!—— ext 解决了 MINIX 文件系统中最糟糕的问题。 -1992 年的 ext 使用在 Linux 内核中的新虚拟文件系统(VFS)抽象层。与之前的 MINIX 文件系统不同的是,ext 可以处理高达 2GB 存储空间并处理 255 个字符的文件名。 +1992 年的 ext 使用在 Linux 内核中的新虚拟文件系统(VFS)抽象层。与之前的 MINIX 文件系统不同的是,ext 可以处理高达 2 GB 存储空间并处理 255 个字符的文件名。 但 ext 并没有长时间占统治地位,主要是由于它原始的时间戳(每个文件仅有一个时间戳,而不是今天我们所熟悉的有 inode、最近文件访问时间和最新文件修改时间的时间戳。)仅仅一年后,ext2 就替代了它。 @@ -41,7 +43,7 @@ ext2 提供了 GB 级别的最大文件大小和 TB 级别的文件系统大小 但这里仍然有一些问题需要解决:ext2 文件系统与 20 世纪 90 年代的大多数文件系统一样,如果在将数据写入到磁盘的时候,系统发生崩溃或断电,则容易发生灾难性的数据损坏。随着时间的推移,由于碎片(单个文件存储在多个位置,物理上其分散在旋转的磁盘上),它们也遭受了严重的性能损失。 -尽管存在这些问题,但今天 ext2 还是用在某些特殊的情况下 —— 最常见的是,作为便携式 USB 拇指驱动器的文件系统格式。 +尽管存在这些问题,但今天 ext2 还是用在某些特殊的情况下 —— 最常见的是,作为便携式 USB 驱动器的文件系统格式。 #### ext3 @@ -51,9 +53,9 @@ ext2 提供了 GB 级别的最大文件大小和 TB 级别的文件系统大小 *20 世纪 90 年代中期的 Packard Bell 计算机,[Spacekid][3],[CC0][4]* -在大部分情况下,ext2 在 Linux 发行版中工作得很好,但像 FAT、FAT32、HFS 和当时的其他文件系统一样 —— 在断电时容易发生灾难性的破坏。如果在将数据写入文件系统时候发生断电,则可能会将其留在所谓 *不一致* 的状态 —— 事情只完成一半而另一半未完成。这可能导致大量文件丢失或损坏,这些文件与正在保存的文件无关甚至导致整个文件系统无法卸载。 +在大部分情况下,ext2 在 Linux 发行版中工作得很好,但像 FAT、FAT32、HFS 和当时的其它文件系统一样 —— 在断电时容易发生灾难性的破坏。如果在将数据写入文件系统时候发生断电,则可能会将其留在所谓 *不一致* 的状态 —— 事情只完成一半而另一半未完成。这可能导致大量文件丢失或损坏,这些文件与正在保存的文件无关甚至导致整个文件系统无法卸载。 -ext3 和 20 世纪 90 年代后期的其他文件系统,如微软的 NTFS,使用 *日志* 来解决这个问题。日志是磁盘上的一种特殊的分配区域,其写入被存储在事务中;如果该事务完成磁盘写入,则日志中的数据将提交给文件系统自身。如果系统在该操作提交前崩溃,则重新启动的系统识别其为未完成的事务而将其进行回滚,就像从未发生过一样。这意味着正在处理的文件可能依然会丢失,但文件系统 *本身* 保持一致,且其他所有数据都是安全的。 +ext3 和 20 世纪 90 年代后期的其它文件系统,如微软的 NTFS,使用 *日志* 来解决这个问题。日志是磁盘上的一种特殊的分配区域,其写入被存储在事务中;如果该事务完成磁盘写入,则日志中的数据将提交给文件系统自身。如果系统在该操作提交前崩溃,则重新启动的系统识别其为未完成的事务而将其进行回滚,就像从未发生过一样。这意味着正在处理的文件可能依然会丢失,但文件系统 *本身* 保持一致,且其它所有数据都是安全的。 在使用 ext3 文件系统的 Linux 内核中实现了三个级别的日志记录方式:日记journal顺序ordered回写writeback。 @@ -61,7 +63,7 @@ ext3 和 20 世纪 90 年代后期的其他文件系统,如微软的 NTFS, * **顺序** 是大多数 Linux 发行版默认模式;顺序模式将元数据写入日志而直接将数据提交到文件系统。顾名思义,这里的操作顺序是固定的:首先,元数据提交到日志;其次,数据写入文件系统,然后才将日志中关联的元数据更新到文件系统。这确保了在发生崩溃时,那些与未完整写入相关联的元数据仍在日志中,且文件系统可以在回滚日志时清理那些不完整的写入事务。在顺序模式下,系统崩溃可能导致在崩溃期间文件的错误被主动写入,但文件系统它本身 —— 以及未被主动写入的文件 —— 确保是安全的。 * **回写** 是第三种模式 —— 也是最不安全的日志模式。在回写模式下,像顺序模式一样,元数据会被记录到日志,但数据不会。与顺序模式不同,元数据和数据都可以以任何有利于获得最佳性能的顺序写入。这可以显著提高性能,但安全性低很多。尽管回写模式仍然保证文件系统本身的安全性,但在崩溃或崩溃之前写入的文件很容易丢失或损坏。 -跟之前的 ext2 类似,ext3 使用 16 位内部寻址。这意味着对于有着 4K 块大小的 ext3 在最大规格为 16TiB 的文件系统中可以处理的最大文件大小为 2TiB。 +跟之前的 ext2 类似,ext3 使用 16 位内部寻址。这意味着对于有着 4K 块大小的 ext3 在最大规格为 16 TiB 的文件系统中可以处理的最大文件大小为 2 TiB。 #### ext4 @@ -73,7 +75,7 @@ Ts'o 将 ext4 描述为一个显著扩展 ext3 但仍然依赖于旧技术的临 *Dell Precision 380 工作站,[Lance Fisher](https://commons.wikimedia.org/wiki/File:Dell_Precision_380_Workstation.jpeg),[CC BY-SA 2.0](https://creativecommons.org/licenses/by-sa/2.0/deed.en)* -ext4 在功能上与 ext3 在功能上非常相似,但支持大文件系统、提高了对碎片的抵抗力,有更高的性能以及更好的时间戳。 +ext4 在功能上与 ext3 在功能上非常相似,但支持大文件系统,提高了对碎片的抵抗力,有更高的性能以及更好的时间戳。 ### ext4 vs ext3 @@ -85,9 +87,9 @@ ext4 特地设计为尽可能地向后兼容 ext3。这不仅允许 ext3 文件 #### 大文件系统 -ext3 文件系统使用 32 位寻址,这限制它仅支持 2TiB 文件大小和 16TiB 文件系统系统大小(这是假设在块大小为 4KiB 的情况下,一些 ext3 文件系统使用更小的块大小,因此对其进一步被限制)。 +ext3 文件系统使用 32 位寻址,这限制它仅支持 2 TiB 文件大小和 16 TiB 文件系统系统大小(这是假设在块大小为 4 KiB 的情况下,一些 ext3 文件系统使用更小的块大小,因此对其进一步被限制)。 -ext4 使用 48 位的内部寻址,理论上可以在文件系统上分配高达 16TiB 大小的文件,其中文件系统大小最高可达 1000000 TiB(1EiB)。在早期 ext4 的实现中有些用户空间的程序仍然将其限制为最大大小为 16TiB 的文件系统,但截至 2011 年,e2fsprogs 已经直接支持大于 16TiB 大小的 ext4 文件系统。例如,红帽企业 Linux 在其合同上仅支持最高 50TiB 的 ext4 文件系统,并建议 ext4 卷不超过 100TiB。 +ext4 使用 48 位的内部寻址,理论上可以在文件系统上分配高达 16 TiB 大小的文件,其中文件系统大小最高可达 1000000 TiB(1 EiB)。在早期 ext4 的实现中有些用户空间的程序仍然将其限制为最大大小为 16 TiB 的文件系统,但截至 2011 年,e2fsprogs 已经直接支持大于 16 TiB 大小的 ext4 文件系统。例如,红帽企业 Linux 在其合同上仅支持最高 50 TiB 的 ext4 文件系统,并建议 ext4 卷不超过 100 TiB。 #### 分配方式改进 @@ -95,7 +97,7 @@ ext4 在将存储块写入磁盘之前对存储块的分配方式进行了大量 ##### 区段 -区段extent是一系列连续的物理块 (最多达 128 MiB,假设块大小为 4KiB),可以一次性保留和寻址。使用区段可以减少给定文件所需的 inode 数量,并显著减少碎片并提高写入大文件时的性能。 +区段extent是一系列连续的物理块 (最多达 128 MiB,假设块大小为 4 KiB),可以一次性保留和寻址。使用区段可以减少给定文件所需的 inode 数量,并显著减少碎片并提高写入大文件时的性能。 ##### 多块分配 @@ -119,7 +121,7 @@ fd=open("file", O_TRUNC); write(fd, data); close(fd); 使用旧的文件系统,`close(fd);` 足以保证 `file` 中的内容刷新到磁盘。即使严格来说,写不是事务性的,但如果文件关闭后发生崩溃,则丢失数据的风险很小。 -如果写入不成功(由于程序上的错误、磁盘上的错误、断电等),文件的原始版本和较新版本都可能丢失数据或损坏。如果其他进程在写入文件时访问文件,则会看到损坏的版本。如果其他进程打开文件并且不希望其内容发生更改 —— 例如,映射到多个正在运行的程序的共享库。这些进程可能会崩溃。 +如果写入不成功(由于程序上的错误、磁盘上的错误、断电等),文件的原始版本和较新版本都可能丢失数据或损坏。如果其它进程在写入文件时访问文件,则会看到损坏的版本。如果其它进程打开文件并且不希望其内容发生更改 —— 例如,映射到多个正在运行的程序的共享库。这些进程可能会崩溃。 为了避免这些问题,一些程序员完全避免使用 `O_TRUNC`。相反,他们可能会写入一个新文件,关闭它,然后将其重命名为旧文件名: @@ -127,7 +129,7 @@ fd=open("file", O_TRUNC); write(fd, data); close(fd); fd=open("newfile"); write(fd, data); close(fd); rename("newfile", "file"); ``` -在 *没有* 延迟分配的文件系统下,这足以避免上面列出的潜在的损坏和崩溃问题:因为 `rename()` 是原子操作,所以它不会被崩溃中断;并且运行的程序将继续引用旧的文件。现在 `file` 的未链接版本只要有一个打开的文件文件句柄即可。但是因为 ext4 的延迟分配会导致写入被延迟和重新排序,`rename("newfile","file")` 可以在 `newfile` 的内容实际写入磁盘内容之前执行,这出现了并行进行再次获得 `file` 坏版本的问题。 +在 *没有* 延迟分配的文件系统下,这足以避免上面列出的潜在的损坏和崩溃问题:因为 `rename()` 是原子操作,所以它不会被崩溃中断;并且运行的程序将继续引用旧的文件。现在 `file` 的未链接版本只要有一个打开的文件文件句柄即可。但是因为 ext4 的延迟分配会导致写入被延迟和重新排序,`rename("newfile", "file")` 可以在 `newfile` 的内容实际写入磁盘内容之前执行,这出现了并行进行再次获得 `file` 坏版本的问题。 为了缓解这种情况,Linux 内核(自版本 2.6.30)尝试检测这些常见代码情况并强制立即分配。这会减少但不能防止数据丢失的可能性 —— 并且它对新文件没有任何帮助。如果你是一位开发人员,请注意:保证数据立即写入磁盘的唯一方法是正确调用 `fsync()`。 @@ -137,7 +139,7 @@ ext3 仅限于 32000 个子目录;ext4 允许无限数量的子目录。从 2. #### 日志校验 -ext3 没有对日志进行校验,这给处于内核直接控制之外的磁盘或带有自己的缓存的控制器设备带来了问题。如果控制器或具有自己的缓存的磁盘脱离了写入顺序,则可能会破坏 ext3 的日记事务顺序,从而可能破坏在崩溃期间(或之前一段时间)写入的文件。 +ext3 没有对日志进行校验,这给处于内核直接控制之外的磁盘或自带缓存的控制器设备带来了问题。如果控制器或具自带缓存的磁盘脱离了写入顺序,则可能会破坏 ext3 的日记事务顺序,从而可能破坏在崩溃期间(或之前一段时间)写入的文件。 理论上,这个问题可以使用写入障碍barrier —— 在安装文件系统时,你在挂载选项设置 `barrier=1`,然后设备就会忠实地执行 `fsync` 一直向下到底层硬件。通过实践,可以发现存储设备和控制器经常不遵守写入障碍 —— 提高性能(和跟竞争对手比较的性能基准),但增加了本应该防止数据损坏的可能性。 @@ -155,7 +157,7 @@ ext3 文件系统也没有提供足够的位来存储 2038 年 1 月 18 日以 #### 在线碎片整理 -ext2 和 ext3 都不直接支持在线碎片整理 —— 即在挂载时会对文件系统进行碎片整理。ext2 有一个包含的实用程序,`e2defrag`,它的名字暗示 —— 它需要在文件系统未挂载时脱机运行。(显然,这对于根文件系统来说非常有问题。)在 ext3 中的情况甚至更糟糕 —— 虽然 ext3 比 ext2 更不容易受到严重碎片的影响,但 ext3 文件系统运行 `e2defrag` 可能会导致灾难性损坏和数据丢失。 +ext2 和 ext3 都不直接支持在线碎片整理 —— 即在挂载时会对文件系统进行碎片整理。ext2 有一个包含的实用程序 `e2defrag`,它的名字暗示 —— 它需要在文件系统未挂载时脱机运行。(显然,这对于根文件系统来说非常有问题。)在 ext3 中的情况甚至更糟糕 —— 虽然 ext3 比 ext2 更不容易受到严重碎片的影响,但 ext3 文件系统运行 `e2defrag` 可能会导致灾难性损坏和数据丢失。 尽管 ext3 最初被认为“不受碎片影响”,但对同一文件(例如 BitTorrent)采用大规模并行写入过程的过程清楚地表明情况并非完全如此。一些用户空间的手段和解决方法,例如 [Shake][6],以这样或那样方式解决了这个问题 —— 但它们比真正的、文件系统感知的、内核级碎片整理过程更慢并且在各方面都不太令人满意。 @@ -187,7 +189,7 @@ ext4,正如 Monty Python 中瘟疫感染者曾经说过的那样,“我还 ext4 是一个健壮、稳定的文件系统。如今大多数人都应该在用它作为根文件系统,但它无法处理所有需求。让我们简单地谈谈你不应该期待的一些事情 —— 现在或可能在未来: -虽然 ext4 可以处理高达 1 EiB 大小(相当于 1,000,000 TiB)大小的数据,但你 *真的* 不应该尝试这样做。除了能够记住更多块的地址之外,还存在规模上的问题。并且现在 ext4 不会处理(并且可能永远不会)超过 50-100TiB 的数据。 +虽然 ext4 可以处理高达 1 EiB 大小(相当于 1,000,000 TiB)大小的数据,但你 *真的* 不应该尝试这样做。除了能够记住更多块的地址之外,还存在规模上的问题。并且现在 ext4 不会处理(并且可能永远不会)超过 50-100 TiB 的数据。 ext4 也不足以保证数据的完整性。随着日志记录的重大进展又回到了 ext3 的那个时候,它并未涵盖数据损坏的许多常见原因。如果数据已经在磁盘上被[破坏][12] —— 由于故障硬件,宇宙射线的影响(是的,真的),或者只是数据随时间衰减 —— ext4 无法检测或修复这种损坏。 @@ -207,7 +209,7 @@ XFS 与非 ext 文件系统在 Linux 中的主线中的地位一样。它是一 从 RHEL 7 开始,XFS 成为 Red Hat Enterprise Linux 的默认文件系统。对于家庭或小型企业用户来说,它仍然有一些缺点 —— 最值得注意的是,重新调整现有 XFS 文件系统是一件非常痛苦的事情,不如创建另一个并复制数据更有意义。 -虽然 XFS 是稳定且是高性能的,但它和 ext4 之间没有足够具体的最终用途差异,以值得推荐在非默认(如 RHEL7)的任何地方使用它,除非它解决了对 ext4 的特定问题,例如 > 50 TiB 容量的文件系统。 +虽然 XFS 是稳定的且是高性能的,但它和 ext4 之间没有足够具体的最终用途差异,以值得推荐在非默认(如 RHEL7)的任何地方使用它,除非它解决了对 ext4 的特定问题,例如大于 50 TiB 容量的文件系统。 XFS 在任何方面都不是 ZFS、Btrfs 甚至 WAFL(一个专有的 SAN 文件系统)的“下一代”文件系统。就像 ext4 一样,它应该被视为一种更好的方式的权宜之计。 @@ -217,9 +219,9 @@ ZFS 由 Sun Microsystems 开发,以 zettabyte 命名 —— 相当于 1 万亿 作为真正的下一代文件系统,ZFS 提供卷管理(能够在单个文件系统中处理多个单独的存储设备),块级加密校验和(允许以极高的准确率检测数据损坏),[自动损坏修复][12](其中冗余或奇偶校验存储可用),[快速异步增量复制][13],内联压缩等,[以及更多][14]。 -从 Linux 用户的角度来看,ZFS 的最大问题是许可证问题。ZFS 许可证是 CDDL 许可证,这是一种与 GPL 冲突的半许可许可证。关于在 Linux 内核中使用 ZFS 的意义存在很多争议,其争议范围从“它是 GPL 违规”到“它是 CDDL 违规”到“它完全没问题,它还没有在法庭上进行过测试。”最值得注意的是,自 2016 年以来 Canonical 已将 ZFS 代码内联在其默认内核中,而且目前尚无法律挑战。 +从 Linux 用户的角度来看,ZFS 的最大问题是许可证问题。ZFS 许可证是 CDDL 许可证,这是一种与 GPL 冲突的半许可的许可证。关于在 Linux 内核中使用 ZFS 的意义存在很多争议,其争议范围从“它是 GPL 违规”到“它是 CDDL 违规”到“它完全没问题,它还没有在法庭上进行过测试。”最值得注意的是,自 2016 年以来 Canonical 已将 ZFS 代码内联在其默认内核中,而且目前尚无法律挑战。 -此时,即使我作为一个非常狂热于 ZFS 的用户,我也不建议将 ZFS 作为 Linux 的 root 文件系统。如果你想在 Linux 上利用 ZFS 的优势,用 ext4 设置一个小的根文件系统,然后将 ZFS 用在你剩余的存储上,把数据、应用程序以及你喜欢的东西放在它上面 —— 但把 root 保留在 ext4 上,直到你的发行版明显支持 ZFS 根目录。 +此时,即使我作为一个非常狂热于 ZFS 的用户,我也不建议将 ZFS 作为 Linux 的根文件系统。如果你想在 Linux 上利用 ZFS 的优势,用 ext4 设置一个小的根文件系统,然后将 ZFS 用在你剩余的存储上,把数据、应用程序以及你喜欢的东西放在它上面 —— 但把 root 分区保留在 ext4 上,直到你的发行版明确支持 ZFS 根目录。 #### Btrfs @@ -227,8 +229,7 @@ Btrfs 是 B-Tree Filesystem 的简称,通常发音为 “butter” —— 由 截至 2018 年,Btrfs 相当稳定,可用作标准的单磁盘文件系统,但可能不应该依赖于卷管理器。与许多常见用例中的 ext4、XFS 或 ZFS 相比,它存在严重的性能问题,其下一代功能 —— 复制、多磁盘拓扑和快照管理 —— 可能非常多,其结果可能是从灾难性地性能降低到实际数据的丢失。 -Btrfs 的维持状态是有争议的;SUSE Enterprise Linux 在 2015 年采用它作为默认文件系统,而 Red Hat 于 2017 年宣布它从 RHEL 7.4 开始不再支持 Btrfs。可能值得注意的是,该产品支持 Btrfs 部署用作单磁盘文件系统,而不是像 ZFS 中的多磁盘卷管理器,甚至 Synology 在它的存储设备使用 Btrfs, -但是它在传统 Linux 内核 RAID(mdraid)之上分层来管理磁盘。 +Btrfs 的维持状态是有争议的;SUSE Enterprise Linux 在 2015 年采用它作为默认文件系统,而 Red Hat 于 2017 年宣布它从 RHEL 7.4 开始不再支持 Btrfs。可能值得注意的是,该产品支持 Btrfs 部署用作单磁盘文件系统,而不是像 ZFS 中的多磁盘卷管理器,甚至 Synology 在它的存储设备使用 Btrfs,但是它在传统 Linux 内核 RAID(mdraid)之上分层来管理磁盘。 -------------------------------------------------------------------------------- From 50dcca9ac511f0c879e747defe6dce5b1db4424d Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Tue, 11 Sep 2018 08:52:40 +0800 Subject: [PATCH 168/455] heguangzhi translating --- ...0180904 8 Linux commands for effective process management.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180904 8 Linux commands for effective process management.md b/sources/tech/20180904 8 Linux commands for effective process management.md index cddf56708c..08d4770cb2 100644 --- a/sources/tech/20180904 8 Linux commands for effective process management.md +++ b/sources/tech/20180904 8 Linux commands for effective process management.md @@ -1,3 +1,5 @@ +heguangzhi Translating + 8 Linux commands for effective process management ====== From fb794e5087419a601d9154465ff07bc2fcc5b4fe Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 11 Sep 2018 08:53:50 +0800 Subject: [PATCH 169/455] translated --- sources/tech/20180904 Why I love Xonsh.md | 132 ------------------- translated/tech/20180904 Why I love Xonsh.md | 130 ++++++++++++++++++ 2 files changed, 130 insertions(+), 132 deletions(-) delete mode 100644 sources/tech/20180904 Why I love Xonsh.md create mode 100644 translated/tech/20180904 Why I love Xonsh.md diff --git a/sources/tech/20180904 Why I love Xonsh.md b/sources/tech/20180904 Why I love Xonsh.md deleted file mode 100644 index a02fce1fe5..0000000000 --- a/sources/tech/20180904 Why I love Xonsh.md +++ /dev/null @@ -1,132 +0,0 @@ -translating---geekpi - -Why I love Xonsh -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/shelloff.png?itok=L8pjHXjW) - -Shell languages are useful for interactive use. But this optimization often comes with trade-offs against using them as programming languages, which is sometimes felt when writing shell scripts. - -What if your shell also understood a more scalable programming language? Say, Python? - -Enter [Xonsh][1]. - -Installing Xonsh is as simple as creating a virtual environment, running `pip install xonsh[ptk,linux]`, and then running `xonsh`. - -At first, you might wonder why your Python shell has a weird prompt: -``` -$ 1+1 -2 -``` - -Nice calculator! -``` -$ print("hello world") -hello world -``` - -We can also call other functions: -``` -$ from antigravity import geohash -$ geohash(37.421542, -122.085589, b'2005-05-26-10458.68') -37.857713 -122.544543 -``` - -However, we can still use it like a regular shell: -``` -$ echo "hello world" -hello world -``` - -We can even mix and match! -``` -$ for i in range(3): -.     echo "hello world" -. -hello world -hello world -hello world -``` - -Xonsh supports completion for both shell commands and Python expressions by using the [Prompt Toolkit][2]. Completions are visually informative, showing possible completions and having in-band dropdown lists. - -It also supports environment access. It uses a simple but powerful heuristic for applying Python types to environment variables. The default is "string," but, for example, path variables are automatically lists. -``` -$ '/usr/bin' in $PATH -True -``` - -Xonsh accepts either shell-style or Python-style boolean shortcut operators: -``` -$ cat things -foo -$ grep -q foo things and echo "found" -found -$ grep -q bar things && echo "found" -$ grep -q foo things or echo "found" -$ grep -q bar things || echo "found" -found -``` - -This means that Python keywords are interpreted. If we want to print the title of a famous Dr. Seuss book, we need to quote the keywords. -``` -$ echo green eggs "and" ham -green eggs and ham -``` - -If we do not, we are in for a surprise: -``` -$ echo green eggs and ham -green eggs -xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True -xonsh: subprocess mode: command not found: ham -Did you mean one of the following? -    as:   Command (/usr/bin/as) -    ht:   Command (/usr/bin/ht) -    mag:  Command (/usr/bin/mag) -    ar:   Command (/usr/bin/ar) -    nm:   Command (/usr/bin/nm) -``` - -Virtual environments can get a little tricky. Regular virtual environments, depending as they do on Bash-like syntax, cannot work. However, Xonsh comes with its own virtual environment management system called `vox`. - -`vox` can create, activate and deactivate environments in `~/.virtualenvs`; if you've used `virtualenvwrapper`, this is where the environments were. - -Note that the current activated environment doesn't affect `x``onsh`. It can't import anything from an activated environment. -``` -$ xontrib load vox -$ vox create my-environment                                                     -... -$ vox activate my-environment         -Activated "my-environment".                                                     -$ pip install money                                                             -... -$ python                                                               -... ->>> import money                                                               ->>> money.Money('3.14')                         -$ import money -xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True -ModuleNotFoundError: No module named 'money' -``` - -The first line enables `vox`: it is a `xontrib`, a third-party extension for Xonsh. The `xontrib` manager can list all possible `xontribs` and their current state (installed, loaded, or neither). - -It's possible to write a `xontrib` and just upload it to `PyPi` to make it available. However, it's good practice to add it to the `xontrib` index so Xonsh knows about it in advance. This allows, for example, the configuration wizard to suggest it. - -If you've ever wondered, "can Python be my shell?" then you are only a `pip install xonsh` away from finding out. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/xonsh-bash-alternative - -作者:[Moshe Zadka][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/moshez -[1]: https://xon.sh/ -[2]: https://python-prompt-toolkit.readthedocs.io/en/master/ diff --git a/translated/tech/20180904 Why I love Xonsh.md b/translated/tech/20180904 Why I love Xonsh.md new file mode 100644 index 0000000000..f3506d6b6a --- /dev/null +++ b/translated/tech/20180904 Why I love Xonsh.md @@ -0,0 +1,130 @@ +我为什么喜欢 Xonsh +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/shelloff.png?itok=L8pjHXjW) + +Shell 语言对交互式使用很有用。但是在使用它们作为编程语言时这种优化需要权衡,这有时在编写 shell 脚本时会感觉到。 + +如果你的 shell 时一种更可伸缩的语言会怎样?比如说,Python? + +进入 [Xonsh][1]。 + +安装 Xonsh 就像创建虚拟环境一样简单,运行 `pip install xonsh [ptk,linux]`,然后运行 `xonsh`。 + +首先,你可能想知道为什么你的 Python shell 有一个奇怪的提示: +``` +$ 1+1 +2 +``` + +好的计算器! +``` +$ print("hello world") +hello world +``` + +我们还可以调用其他函数: +``` +$ from antigravity import geohash +$ geohash(37.421542, -122.085589, b'2005-05-26-10458.68') +37.857713 -122.544543 +``` + +然而,我们仍然可以像常规 shell 一样使用它: +``` +$ echo "hello world" +hello world +``` + +我们甚至可以混搭! +``` +$ for i in range(3): +.     echo "hello world" +. +hello world +hello world +hello world +``` + +Xonsh 支持使用 [Prompt Toolkit][2] 补全 shell 命令和 Python 表达式。补全有可视化提示,会显示可能的补全并有下拉列表。 + +它还支持访问环境变量。它使用简单但强大的启发式方法将 Python 类型应用于环境变量。默认值为 “string”,但是,例如,路径变量是自动列表。 +``` +$ '/usr/bin' in $PATH +True +``` + +Xonsh 接受 shell 形式或 Python 形式的布尔快捷运算符: +``` +$ cat things +foo +$ grep -q foo things and echo "found" +found +$ grep -q bar things && echo "found" +$ grep -q foo things or echo "found" +$ grep -q bar things || echo "found" +found +``` + +这意味着 Python 关键字是被解释了。如果我们想要打印著名的 Dr. Seuss 书的标题,我们需要引用关键词。 +``` +$ echo green eggs "and" ham +green eggs and ham +``` + +如果我们不这样做,我们会感到惊讶: +``` +$ echo green eggs and ham +green eggs +xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True +xonsh: subprocess mode: command not found: ham +Did you mean one of the following? +    as:   Command (/usr/bin/as) +    ht:   Command (/usr/bin/ht) +    mag:  Command (/usr/bin/mag) +    ar:   Command (/usr/bin/ar) +    nm:   Command (/usr/bin/nm) +``` + +虚拟环境可能会有点棘手。一般的虚拟环境(取决于它们类似 Bash 的语法)无法工作。但是,Xonsh 自带了一个名为 `vox` 的虚拟环境管理系统。 + +`vox` 可以创建,激活和停用 `~/.virtualenvs` 中的环境。如果你用过 `virtualenvwrapper`,这就是环境变量所在的地方。 + +请注意,当前激活的环境不会影响 `xonsh`。它无法从激活的环境中导入任何内容。 +``` +$ xontrib load vox +$ vox create my-environment                                                     +... +$ vox activate my-environment         +Activated "my-environment".                                                     +$ pip install money                                                             +... +$ python                                                               +... +>>> import money                                                               +>>> money.Money('3.14')                         +$ import money +xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True +ModuleNotFoundError: No module named 'money' +``` + +第一行启用 `vox`:它是一个 `xontrib`,Xonsh 的一个第三方扩展。`xontrib` 管理器可以列出所有可能的 `xontribs` 及其当前状态(已安装,已加载或未加载)。 + +可以编写一个 `xontrib` 并上传到 `PyPi` 以使其可用。但是,最好将它添加到 `xontrib` 索引中,以便 Xonsh 提前知道它。比如,这能让配置向导建议它。 + +如果你曾经想过,“Python 可以成为我的 shell 吗?”,然后你只要 `pip install xonsh` 一下就能知道。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/xonsh-bash-alternative + +作者:[Moshe Zadka][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[1]: https://xon.sh/ +[2]: https://python-prompt-toolkit.readthedocs.io/en/master/ From fc42fd8d968f24bc2f8a873a800566ba0a121130 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 11 Sep 2018 09:01:22 +0800 Subject: [PATCH 170/455] translating --- ...s Linux Beginners To Choose A Suitable Linux Distribution.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md b/sources/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md index fb2df2e1f5..79f8dfb3f9 100644 --- a/sources/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md +++ b/sources/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md @@ -1,3 +1,5 @@ +translating---geekpi + Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-logo-720x340.png) From 3c63f684bf4e4c10a2780eab458396621b396f6e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 11 Sep 2018 09:23:42 +0800 Subject: [PATCH 171/455] PRF:20180822 What is a Makefile and how does it work.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @zafiry 恭喜你完成了第一篇翻译! --- ...What is a Makefile and how does it work.md | 149 +++++++++--------- 1 file changed, 74 insertions(+), 75 deletions(-) diff --git a/translated/tech/20180822 What is a Makefile and how does it work.md b/translated/tech/20180822 What is a Makefile and how does it work.md index b2996ec35d..8a550c1572 100644 --- a/translated/tech/20180822 What is a Makefile and how does it work.md +++ b/translated/tech/20180822 What is a Makefile and how does it work.md @@ -1,74 +1,67 @@ -Makefile及其工作原理 +Makefile 及其工作原理 ====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_liberate%20docs_1109ay.png?itok=xQOLreya) -当你在一些源文件改变后需要运行或更新一个任务时,make工具通常会被用到。make工具需要读取Makefile(或makefile)文件,在该文件中定义了一系列需要执行的任务。make可以用来将源代码编译为可执行程序。大部分开源项目会使用make来实现二进制文件的编译,然后使用make istall命令来执行安装。 +> 用这个方便的工具来更有效的运行和编译你的程序。 -本文将通过一些基础和进阶的示例来展示make和Makefile的使用方法。在开始前,请确保你的系统中安装了make。 +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc_liberate%20docs_1109ay.png?itok=xQOLreya) + +当你需要在一些源文件改变后运行或更新一个任务时,通常会用到 `make` 工具。`make` 工具需要读取一个 `Makefile`(或 `makefile`)文件,在该文件中定义了一系列需要执行的任务。你可以使用 `make` 来将源代码编译为可执行程序。大部分开源项目会使用 `make` 来实现最终的二进制文件的编译,然后使用 `make install` 命令来执行安装。 + +本文将通过一些基础和进阶的示例来展示 `make` 和 `Makefile` 的使用方法。在开始前,请确保你的系统中安装了 `make`。 ### 基础示例 -依然从打印“Hello World”开始。首先创建一个名字为myproject的目录,目录下新建Makefile文件,文件内容为: +依然从打印 “Hello World” 开始。首先创建一个名字为 `myproject` 的目录,目录下新建 `Makefile` 文件,文件内容为: + ``` say_hello: -         echo "Hello World" - ``` -在myproject目录下执行make,会有如下输出: +在 `myproject` 目录下执行 `make`,会有如下输出: + ``` $ make - echo "Hello World" - Hello World - ``` -在上面的例子中,“say_hello”类似于其他编程语言中的函数名。在此可以成为target。在target之后的是预置条件和依赖。为了简单期间,我们在示例中没有定义预置条件。“echo ‘Hello World'"命令被称为recipe。recipe基于预置条件来实现target。target、预置条件和recipe共同构成一个规则。 +在上面的例子中,“say_hello” 类似于其他编程语言中的函数名。这被称之为目标target。在该目标之后的是预置条件或依赖。为了简单起见,我们在这个示例中没有定义预置条件。`echo ‘Hello World'` 命令被称为步骤recipe。这些步骤基于预置条件来实现目标。目标、预置条件和步骤共同构成一个规则。 总结一下,一个典型的规则的语法为: -``` -target: 预置条件 - - recipe +``` +目标: 预置条件 + 步骤 ``` -在示例中,target是一个基于源代码这个预置条件的二进制文件。另外,在另一规则中,这个预置条件也可以是依赖其他预置条件的target。 +作为示例,目标可以是一个基于预置条件(源代码)的二进制文件。另一方面,预置条件也可以是依赖其他预置条件的目标。 + ``` final_target: sub_target final_target.c -         Recipe_to_create_final_target - - - +        sub_target: sub_target.c -         Recipe_to_create_sub_target - ``` -target不要求是一个文件,也可以只是方便recipe使用的名字。我们称之为伪target。 +目标并不要求是一个文件,也可以只是步骤的名字,就如我们的例子中一样。我们称之为“伪目标”。 -再回到上面的示例中,当make被执行时,整条指令‘echo "Hello World"’都被打印出来,之后才是真正的执行结果。如果不希望指令本身被打印处理,需要在echo前添加@。 +再回到上面的示例中,当 `make` 被执行时,整条指令 `echo "Hello World"` 都被显示出来,之后才是真正的执行结果。如果不希望指令本身被打印处理,需要在 `echo` 前添加 `@`。 ``` say_hello: -         @echo "Hello World" - ``` -重新运行make,将会只有如下输出: +重新运行 `make`,将会只有如下输出: + ``` $ make - Hello World - ``` -接下来在Makefile中添加如下伪target:generate和clean: +接下来在 `Makefile` 中添加如下伪目标:`generate` 和 `clean`: + ``` say_hello:         @echo "Hello World" @@ -82,23 +75,26 @@ clean:         rm *.txt ``` -随后当我们运行make时,只有‘say_hello’这个target被执行。这是因为makefile中的默认target为第一个target。通常情况下只有默认的target会被调用,大多数项目会将“all”作为默认target。“all”负责来调用其他的target。我们可以通过.DEFAULT_GOAL这个特殊的伪target来覆盖掉默认的行为。 +随后当我们运行 `make` 时,只有 `say_hello` 这个目标被执行。这是因为`Makefile` 中的第一个目标为默认目标。通常情况下会调用默认目标,这就是你在大多数项目中看到 `all` 作为第一个目标而出现。`all` 负责来调用它他的目标。我们可以通过 `.DEFAULT_GOAL` 这个特殊的伪目标来覆盖掉默认的行为。 + +在 `Makefile` 文件开头增加 `.DEFAULT_GOAL`: -在makefile文件开头增加.DEFAULT_GOAL: ``` .DEFAULT_GOAL := generate ``` -make会将generate作为默认target: +`make` 会将 `generate` 作为默认目标: + ``` $ make Creating empty text files... touch file-{1..10}.txt ``` -顾名思义,.DEFAULT_GOAL伪target仅能定义一个target。这就是为什么很多项目仍然会有all这个target。这样可以保证多个target的实现。 +顾名思义,`.DEFAULT_GOAL` 伪目标仅能定义一个目标。这就是为什么很多 `Makefile` 会包括 `all` 这个目标,这样可以调用多个目标。 + +下面删除掉 `.DEFAULT_GOAL`,增加 `all` 目标: -下面删除掉.DEFAULT_GOAL,增加all target: ``` all: say_hello generate @@ -114,7 +110,8 @@ clean:         rm *.txt ``` -运行之前,我们再增加一些特殊的伪target。.PHONY用来定义这些不是file的target。make会默认调用这写伪target下的recipe,而不去检查文件是否存在或最后修改日期。完整的makefile如下: +运行之前,我们再增加一些特殊的伪目标。`.PHONY` 用来定义这些不是文件的目标。`make` 会默认调用这些伪目标下的步骤,而不去检查文件名是否存在或最后修改日期。完整的 `Makefile` 如下: + ``` .PHONY: all say_hello generate clean @@ -132,7 +129,8 @@ clean:         rm *.txt ``` -make命令会调用say_hello和generate: +`make` 命令会调用 `say_hello` 和 `generate`: + ``` $ make Hello World @@ -140,38 +138,43 @@ Creating empty text files... touch file-{1..10}.txt ``` -clean不应该被放入all中,或者被放入第一个target。clean应当在需要清理时手动调用,调用方法为make clean。 +`clean` 不应该被放入 `all` 中,或者被放入第一个目标中。`clean` 应当在需要清理时手动调用,调用方法为 `make clean`。 + ``` $ make clean Cleaning up... rm *.txt ``` -现在你应该已经对makefile有了基础的了解,接下来我们看一些进阶的示例。 +现在你应该已经对 `Makefile` 有了基础的了解,接下来我们看一些进阶的示例。 ### 进阶示例 #### 变量 -在之前的实例中,大部分target和预置条件是已经固定了的,但在实际项目中,它们通常用变量和模式来代替。 +在之前的实例中,大部分目标和预置条件是已经固定了的,但在实际项目中,它们通常用变量和模式来代替。 + +定义变量最简单的方式是使用 `=` 操作符。例如,将命令 `gcc` 赋值给变量 `CC`: -定义变量最简单的方式是使用‘=’操作符。例如,将命令gcc赋值给变量CC: ``` CC = gcc ``` 这被称为递归扩展变量,用于如下所示的规则中: + ``` hello: hello.c     ${CC} hello.c -o hello ``` -你可能已经想到了,recipe将会在传递给终端时展开为: +你可能已经想到了,这些步骤将会在传递给终端时展开为: + ``` gcc hello.c -o hello ``` -${CC}和$(CC)都能对gcc进行引用。但如果一个变量尝试将它本身赋值给自己,将会造成死循环。让我们验证一下: +`${CC}` 和 `$(CC)` 都能对 `gcc` 进行引用。但如果一个变量尝试将它本身赋值给自己,将会造成死循环。让我们验证一下: + ``` CC = gcc CC = ${CC} @@ -180,13 +183,15 @@ all:     @echo ${CC} ``` -此时运行make会导致: +此时运行 `make` 会导致: + ``` $ make Makefile:8: *** Recursive variable 'CC' references itself (eventually).  Stop. ``` -为了避免这种情况发生,可以使用“:=”操作符(这被称为简单扩展变量)。以下代码不会造成上述问题: +为了避免这种情况发生,可以使用 `:=` 操作符(这被称为简单扩展变量)。以下代码不会造成上述问题: + ``` CC := gcc CC := ${CC} @@ -197,7 +202,8 @@ all: #### 模式和函数 -下面的makefile使用了变量、模式和函数来实现所有C代码的编译。我们来逐行分析下: +下面的 `Makefile` 使用了变量、模式和函数来实现所有 C 代码的编译。我们来逐行分析下: + ``` # Usage: # make        # compile all binary @@ -227,55 +233,48 @@ clean:         rm -rvf *.o ${BINS} ``` - * 以“#”开头的行是评论。 +* 以 `#` 开头的行是评论。 +* `.PHONY = all clean` 行定义了 `all` 和 `clean` 两个伪目标。 +* 变量 `LINKERFLAG` 定义了在步骤中 `gcc` 命令需要用到的参数。 +* `SRCS := $(wildcard *.c)`:`$(wildcard pattern)` 是与文件名相关的一个函数。在本示例中,所有 “.c”后缀的文件会被存入 `SRCS` 变量。 +* `BINS := $(SRCS:%.c=%)`:这被称为替代引用。本例中,如果 `SRCS` 的值为 `'foo.c bar.c'`,则 `BINS`的值为 `'foo bar'`。 +* `all: ${BINS}` 行:伪目标 `all` 调用 `${BINS}` 变量中的所有值作为子目标。 +* 规则: - * `.PHONY = all clean` 定义了“all”和“clean”两个伪代码。 - - * 变量`LINKERFLAG` recipe中gcc命令需要用到的参数。 - - * `SRCS := $(wildcard *.c)`: `$(wildcard pattern)` 是与文件名相关的一个函数。在本示例中,所有“.c"后缀的文件会被存入“SRCS”变量。 - - * `BINS := $(SRCS:%.c=%)`: 这被称为替代引用。本例中,如果“SRCS”的值为“'foo.c bar.c'”,则“BINS”的值为“'foo bar'”。 - - * Line `all: ${BINS}`: 伪target “all”调用“${BINS}”变量中的所有值作为子target。 - - * 规则: -``` + ``` %: %.o   @echo "Checking.."   ${CC} ${LINKERFLAG} $< -o $@ ``` -下面通过一个示例来理解这条规则。假定“foo”是变量“${BINS}”中的一个值。“%”会匹配到“foo”(“%”匹配任意一个target)。下面是规则展开后的内容: -``` + 下面通过一个示例来理解这条规则。假定 `foo` 是变量 `${BINS}` 中的一个值。`%` 会匹配到 `foo`(`%`匹配任意一个目标)。下面是规则展开后的内容: + + ``` foo: foo.o   @echo "Checking.."   gcc -lm foo.o -o foo - ``` -如上所示,“%”被“foo”替换掉了。“$<”被“foo.o”替换掉。“$<”用于匹配预置条件,`$@`匹配target。对“${BINS}”中的每个值,这条规则都会被调用一遍。 + 如上所示,`%` 被 `foo` 替换掉了。`$<` 被 `foo.o` 替换掉。`$<`用于匹配预置条件,`$@` 匹配目标。对 `${BINS}` 中的每个值,这条规则都会被调用一遍。 +* 规则: - * 规则: -``` + ``` %.o: %.c   @echo "Creating object.."   ${CC} -c $< ``` -之前规则中的每个预置条件在这条规则中都会都被作为一个target。下面是展开后的内容: -``` + 之前规则中的每个预置条件在这条规则中都会都被作为一个目标。下面是展开后的内容: + + ``` foo.o: foo.c   @echo "Creating object.."   gcc -c foo.c ``` +* 最后,在 `clean` 目标中,所有的二进制文件和编译文件将被删除。 - * 最后,在target “clean”中,所有的而简直文件和编译文件将被删除。 +下面是重写后的 `Makefile`,该文件应该被放置在一个有 `foo.c` 文件的目录下: - - - -下面是重写后的makefile,该文件应该被放置在一个有foo.c文件的目录下: ``` # Usage: # make        # compile all binary @@ -305,7 +304,7 @@ clean:         rm -rvf foo.o foo ``` -关于makefiles的更多信息,[GNU Make manual][1]提供了更完整的说明和实例。 +关于 `Makefile` 的更多信息,[GNU Make 手册][1]提供了更完整的说明和实例。 -------------------------------------------------------------------------------- @@ -314,7 +313,7 @@ via: https://opensource.com/article/18/8/what-how-makefile 作者:[Sachin Patil][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[Zafiry](https://github.com/zafiry) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8ed24fe79507514e70d3d27eade4449d02d4acdd Mon Sep 17 00:00:00 2001 From: imquanquan Date: Tue, 11 Sep 2018 09:28:54 +0800 Subject: [PATCH 172/455] imquanquan Translating --- sources/tech/20180130 Trying Other Go Versions.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sources/tech/20180130 Trying Other Go Versions.md b/sources/tech/20180130 Trying Other Go Versions.md index 731747d19a..1ab1b4f948 100644 --- a/sources/tech/20180130 Trying Other Go Versions.md +++ b/sources/tech/20180130 Trying Other Go Versions.md @@ -1,3 +1,4 @@ +imquanquan Translating Trying Other Go Versions ============================================================ @@ -109,4 +110,4 @@ via: https://pocketgophers.com/trying-other-versions/ [8]:https://pocketgophers.com/trying-other-versions/#trying-a-specific-release [9]:https://pocketgophers.com/guide-to-json/ [10]:https://pocketgophers.com/trying-other-versions/#trying-any-release -[11]:https://pocketgophers.com/trying-other-versions/#trying-a-source-build-e-g-tip \ No newline at end of file +[11]:https://pocketgophers.com/trying-other-versions/#trying-a-source-build-e-g-tip From 93e3c5d5fbda4982dab3053859ac78cdd9035960 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 11 Sep 2018 09:59:38 +0800 Subject: [PATCH 173/455] PUB: 20180402 Understanding Linux filesystems- ext4 and beyond.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @HardworkFish @pityonline https://linux.cn/article-10000-1.html 第 10000 篇留给好文章~ --- ...180402 Understanding Linux filesystems- ext4 and beyond.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename {translated/talk => published}/20180402 Understanding Linux filesystems- ext4 and beyond.md (99%) diff --git a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md b/published/20180402 Understanding Linux filesystems- ext4 and beyond.md similarity index 99% rename from translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md rename to published/20180402 Understanding Linux filesystems- ext4 and beyond.md index 88f265ae29..e091f265d3 100644 --- a/translated/talk/20180402 Understanding Linux filesystems- ext4 and beyond.md +++ b/published/20180402 Understanding Linux filesystems- ext4 and beyond.md @@ -1,4 +1,4 @@ -理解 Linux 文件系统:ext4 等文件系统 +理解 ext4 等 Linux 文件系统 ====== > 了解 ext4 的历史,包括其与 ext3 和之前的其它文件系统之间的区别。 @@ -237,7 +237,7 @@ via: https://opensource.com/article/18/4/ext4-filesystem 作者:[Jim Salter][a] 译者:[HardworkFish](https://github.com/HardworkFish) -校对:[wxy](https://github.com/wxy)、[pityonline](https://github.com/pityonline) +校对:[wxy](https://github.com/wxy), [pityonline](https://github.com/pityonline) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 1c5a2ac5ce7a3b64e005252ed0c79cedc63a89da Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 11 Sep 2018 10:09:03 +0800 Subject: [PATCH 174/455] PUB:20180822 What is a Makefile and how does it work.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @zafiry 本文首发地址: https://linux.cn/article-10001-1.html 您的 LCTT 专页地址:https://linux.cn/lctt/Zafiry 请到 LCCN 平台注册并领取通证:https://lctt.linux.cn/ --- .../20180822 What is a Makefile and how does it work.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180822 What is a Makefile and how does it work.md (100%) diff --git a/translated/tech/20180822 What is a Makefile and how does it work.md b/published/20180822 What is a Makefile and how does it work.md similarity index 100% rename from translated/tech/20180822 What is a Makefile and how does it work.md rename to published/20180822 What is a Makefile and how does it work.md From 9e13a8b579776ee03d23feb0209a260dad03f496 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 11 Sep 2018 10:18:10 +0800 Subject: [PATCH 175/455] PUB: 20180830 How to Update Firmware on Ubuntu 18.04.md @geekpi https://linux.cn/article-10002-1.html --- .../20180830 How to Update Firmware on Ubuntu 18.04.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180830 How to Update Firmware on Ubuntu 18.04.md (100%) diff --git a/translated/tech/20180830 How to Update Firmware on Ubuntu 18.04.md b/published/20180830 How to Update Firmware on Ubuntu 18.04.md similarity index 100% rename from translated/tech/20180830 How to Update Firmware on Ubuntu 18.04.md rename to published/20180830 How to Update Firmware on Ubuntu 18.04.md From 204d905c0c27d50e4dc18f58145699d1f519277d Mon Sep 17 00:00:00 2001 From: zafiry Date: Tue, 11 Sep 2018 11:00:50 +0800 Subject: [PATCH 176/455] zafiry is translating 20180205 Writing eBPF tracing tools in Rust.md --- sources/tech/20180205 Writing eBPF tracing tools in Rust.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180205 Writing eBPF tracing tools in Rust.md b/sources/tech/20180205 Writing eBPF tracing tools in Rust.md index 18b8eb5742..093d3de215 100644 --- a/sources/tech/20180205 Writing eBPF tracing tools in Rust.md +++ b/sources/tech/20180205 Writing eBPF tracing tools in Rust.md @@ -1,3 +1,4 @@ +Zafiry translating... Writing eBPF tracing tools in Rust ============================================================ From ebfd164ceb26b35f32de4289186233ee632b6368 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 11 Sep 2018 12:50:43 +0800 Subject: [PATCH 177/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Randomize=20your?= =?UTF-8?q?=20MAC=20address=20using=20NetworkManager?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e your MAC address using NetworkManager.md | 109 ++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 sources/tech/20180910 Randomize your MAC address using NetworkManager.md diff --git a/sources/tech/20180910 Randomize your MAC address using NetworkManager.md b/sources/tech/20180910 Randomize your MAC address using NetworkManager.md new file mode 100644 index 0000000000..7595843d1b --- /dev/null +++ b/sources/tech/20180910 Randomize your MAC address using NetworkManager.md @@ -0,0 +1,109 @@ +Randomize your MAC address using NetworkManager +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/09/randomizemacaddress-816x345.png) + +Today, users run their notebooks everywhere. To stay connected you use the local wifi to access the internet, on the couch at home or in a little cafe with your favorite coffee. But modern hotspots track you based on your MAC address, [an address that is unique per network card][1], and in this way identifies your device. Read more below about how to avoid this kind of tracking. + +Why is this a problem? Many people use the word “privacy” to talk about this issue. But the concern is not about someone accessing the private contents of your laptop (that’s a separate issue). Instead, it’s about legibility — in simple terms, the ability to be easily counted and tracked. You can and should [read more about legibility][2]. But the bottom line is legibility gives the tracker power over the tracked. For instance, timed WiFi leases at the airport can only be enforced when you’re legible. + +Since a fixed MAC address for your laptop is so legible (easily tracked), you should change it often. A random address is a good choice. Since MAC-addresses are only used within a local network, a random MAC-address is unlikely to cause a [collision.][3] + +### Configuring NetworkManager + +To apply randomized MAC-addresses by default to all WiFi connections, create the following file /etc/NetworkManager/conf.d/00-macrandomize.conf : + +``` +[device] +wifi.scan-rand-mac-address=yes + +[connection] +wifi.cloned-mac-address=stable +ethernet.cloned-mac-address=stable +connection.stable-id=${CONNECTION}/${BOOT} + +``` + +Afterward, restart NetworkManager: + +``` +systemctl restart NetworkManager + +``` + +Set cloned-mac-address to stable to generate the same hashed MAC every time a NetworkManager connection activates, but use a different MAC with each connection. To get a truly random MAC with every activation, use random instead. + +The stable setting is useful to get the same IP address from DHCP, or a captive portal might remember your login status based on the MAC address. With random you may be required to re-authenticate (or click “I agree”) on every connect. You probably want “random” for that airport WiFi. See the NetworkManager [blog post][4] for a more detailed discussion and instructions for using nmcli to configure specific connections from the terminal. + +To see your current MAC addresses, use ip link. The MAC follows the word ether. + +``` +$ ip link +1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 +2: enp2s0: mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 + link/ether 52:54:00:5f:d5:4e brd ff:ff:ff:ff:ff:ff +3: wlp1s0: mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000 + link/ether 52:54:00:03:23:59 brd ff:ff:ff:ff:ff:ff + +``` + +### When not to randomize your MAC address + +Naturally, there are times when you do need to be legible. For instance, on your home network, you may have configured your router to assign your notebook a consistent private IP for port forwarding. Or you might allow only certain MAC addresses to use the WiFi. Your employer probably requires legibility as well. +To change a specific WiFi connection, use nmcli to see your NetworkManager connections and show the current settings: + +``` +$ nmcli c | grep wifi +Amtrak_WiFi 5f4b9f75-9e41-47f8-8bac-25dae779cd87 wifi -- +StaplesHotspot de57940c-32c2-468b-8f96-0a3b9a9b0a5e wifi -- +MyHome e8c79829-1848-4563-8e44-466e14a3223d wifi wlp1s0 +... +$ nmcli c show 5f4b9f75-9e41-47f8-8bac-25dae779cd87 | grep cloned +802-11-wireless.cloned-mac-address: -- +$ nmcli c show e8c79829-1848-4563-8e44-466e14a3223d | grep cloned +802-11-wireless.cloned-mac-address: stable + +``` + +This example uses a fully random MAC for Amtrak (which is currently using the default), and the permanent MAC for MyHome (currently set to stable). The permanent MAC was assigned to your network interface when it was manufactured. Network admins like to use the permanent MAC to see [manufacturer IDs on the wire][5]. + +Now, make the changes and reconnect the active interface: + +``` +$ nmcli c modify 5f4b9f75-9e41-47f8-8bac-25dae779cd87 802-11-wireless.cloned-mac-address random +$ nmcli c modify e8c79829-1848-4563-8e44-466e14a3223d 802-11-wireless.cloned-mac-address permanent +$ nmcli c down e8c79829-1848-4563-8e44-466e14a3223d +$ nmcli c up e8c79829-1848-4563-8e44-466e14a3223d +$ ip link +... + +``` + +You can also install NetworkManager-tui to get the nmtui command for nice menus when editing connections. + +### Conclusion + +When you walk down the street, you should [stay aware of your surroundings][6], and on the [alert for danger][7]. In the same way, learn to be aware of your legibility when using public internet resources. + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/randomize-mac-address-nm/ + +作者:[sheogorath][a],[Stuart D Gathman][b] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/sheogorath/ +[b]: https://fedoramagazine.org/author/sdgathman/ +[1]: https://en.wikipedia.org/wiki/MAC_address +[2]: https://www.ribbonfarm.com/2010/07/26/a-big-little-idea-called-legibility/ +[3]: https://serverfault.com/questions/462178/duplicate-mac-address-on-the-same-lan-possible +[4]: https://blogs.gnome.org/thaller/2016/08/26/mac-address-spoofing-in-networkmanager-1-4-0/ +[5]: https://www.wireshark.org/tools/oui-lookup.html +[6]: https://www.isba.org/committees/governmentlawyers/newsletter/2013/06/becomingmoreawareafewtipsonkeepingy +[7]: http://www.selectinternational.com/safety-blog/aware-of-surroundings-can-reduce-safety-incidents From 51b46b0c3be240ff2a9aafb2e2b1e2bd9b4fdb41 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 11 Sep 2018 12:53:34 +0800 Subject: [PATCH 178/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=2013=20Keyboard=20S?= =?UTF-8?q?hortcut=20Every=20Ubuntu=2018.04=20User=20Should=20Know?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...cut Every Ubuntu 18.04 User Should Know.md | 166 ++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md diff --git a/sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md b/sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md new file mode 100644 index 0000000000..5feab2f4b2 --- /dev/null +++ b/sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md @@ -0,0 +1,166 @@ +13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know +====== +Knowing keyboard shortcuts increase your productivity. Here are some useful Ubuntu shortcut keys that will help you use Ubuntu like a pro. + +You can use an operating system with the combination of keyboard and mouse + +Note: The keyboard shortcuts mentioned in the list is intended for Ubuntu 18.04 GNOME edition. Usually, most of them (if not all) should work on other Ubuntu versions as well, but I cannot vouch for it. + +![Ubuntu keyboard shortcuts][1] + +### Useful Ubuntu keyboard shortcuts + +Let’s have a look at some of the must know keyboard shortcut for Ubuntu GNOME. I have not included universal keyboard shortcuts like Ctrl+C (copy), Ctrl+V (paste) or Ctrl+S (save). + +Note: Super key in Linux refers to the key with Windows logo. I have used capital letters in the shortcuts but it doesn’t mean you have to press the shift key. For example, T means ‘t’ key only, not Shift+t. + +#### 1\. Super key: Opens Activities search + +Super Key Opens the activities menuIf you have to use just one keyboard shortcut on Ubuntu, this has to be the one. + +You want to open an application? Press the super key and search for the application. If the application is not installed, it will even suggest applications from software center. + +You want to see the running applications? Press super key and it will show you all the running GUI applications. + +You want to use workspaces? Simply press the super key and you can see the workspaces option on the right-hand side. + +#### 2\. Ctrl+Alt+T: Ubuntu terminal shortcut + +![Ubuntu Terminal Shortcut][2]Use Ctrl+alt+T to open terminal + +You want to open a new terminal. The combination of three keys Ctrl+Alt+T is what you need. This is my favorite keyboard shortcut in Ubuntu. I even mention it in various tutorials on It’s FOSS when it involves opening a terminal. + +#### 3\. Super+L or Ctrl+Alt+L: Locks the screen + +Locking screen when you are not at your desk is one of the most basic security tips. Instead of going to the top right corner and then choosing the lock screen option, you can simply use the Super+L key combination. + +Some systems also use Ctrl+Alt+L keys for locking the screen. + +#### 4\. Super+D or Ctrl+Alt+D: Show desktop + +Pressing Super+D minimizes all running application windows and shows the desktop. + +Pressing Super+D again will open all the running applications windows as it was previously. + +You may also use Ctrl+Alt+D for this purpose. + +#### 5\. Super+A: Shows the application menu + +You can open the application menu in Ubuntu 18.04 GNOME by clicking on the 9 dots on the left bottom of the screen. However, a quicker way would be to use Super+A key combination. + +It will show the application menu where you can see the installed applications on your systems and can also search for them. + +You can use Esc key to move out of the application menu screen. + +#### 6\. Super+Tab or Alt+Tab: Switch between running applications + +If you have more than one applications running, you can switch between the applications using the Super+Tab or Alt+Tab key combinations. + +Keep holding the super key and press tab and you’ll the application switcher appearing. While holding the super key, keep on tapping the tab key to select between applications. When you are at the desired application, release both super and tab keys. + +By default, the application switcher moves from left to right. If you want to move from right to left, use the Super+Shift+Tab key combination. + +You can also use Alt key instead of Super here. + +Tip: If there are multiple instances of an application, you can switch between those instances by using Super+` key combination. + +#### 7\. Super+Arrow keys: Snap windows + + + +This is available in Windows as well. While using an application, press Super and left arrow key and the application will go to the left edge of the screen, taking half of the screen. + +Similarly, pressing Super and right arrow keys will move the application to the right edge. + +Super and up arrow keys will maximize the application window and super and down arrow will bring the application back to its usual self. + +#### 8\. Super+M: Toggle notification tray + +GNOME has a notification tray where you can see notifications for various system and application activities. You also have the calendar here. + +![Notification Tray Ubuntu 18.04 GNOME][3] +Notification Tray + +With Super+M key combination, you can open this notification area. If you press these keys again, an opened notification tray will be closed. + +You can also use Super+V for toggling the notification tray. + +#### 9\. Super+Space: Change input keyboard (for multilingual setup) + +If you are multilingual, perhaps you have more than one keyboards installed on your system. For example, I use [Hindi on Ubuntu][4] along with English and I have Hindi (Devanagari) keyboard installed along with the default English one. + +If you also use a multilingual setup, you can quickly change the input keyboard with the Super+Space shortcut. + +#### 10\. Alt+F2: Run console + +This is for power users. If you want to run a quick command, instead of opening a terminal and running the command there, you can use Alt+F2 to run the console. + +![Alt+F2 to run commands in Ubuntu][5] +Console + +This is particularly helpful when you have to use applications that can only be run from the terminal. + +#### 11\. Ctrl+Q: Close an application window + +If you have an application running, you can close the application window using the Ctrl+Q key combination. You can also use Ctrl+W for this purpose. + +Alt+F4 is more ‘universal’ shortcut for closing an application window. + +It not work on a few applications such as the default terminal in Ubuntu. + +#### 12\. Ctrl+Alt+arrow: Move between workspaces + +![Workspace switching][6] +Workspace switching + +If you are one of the power users who use workspaces, you can use the Ctrl+Alt+Up arrow and Ctrl+Alt+Down arrow keys to switch between the workspaces. + +#### 13\. Ctrl+Alt+Del: Log out + +No! Like Windows, the famous combination of Ctrl+Alt+Del won’t bring task manager in Linux (unless you use custom keyboard shortcuts for it). + +![Log Out Ubuntu][7] +Log Out + +In the normal GNOME desktop environment, you can bring the power off menu using the Ctrl+Alt+Del keys but Ubuntu doesn’t always follow the norms and hence it opens the logout dialogue box when you use Ctrl+Alt+Del in Ubuntu. + +### Use custom keyboard shortcuts in Ubuntu + +You are not limited to the default keyboard shortcuts. You can create your own custom keyboard shortcuts as you like. + +Go to Settings->Devices->Keyboard. You’ll see all the keyboard shortcuts here for your system. Scroll down to the bottom and you’ll see the Custom Shortcuts option. + +![Add custom keyboard shortcut in Ubuntu][8] + +You have to provide an easy-to-recognize name of the shortcut, the command that will be run when the key combinations are used and of course the keys you are going to use for the shortcut. + +### What are your favorite keyboard shortcuts in Ubuntu? + +There is no end to shortcuts. If you want, you can have a look at all the possible [GNOME shortcuts][9] here and see if there are some more shortcuts you would like to use. + +You can, and you should also learn keyboard shortcuts for the applications you use most of the time. For example, I use Kazam for [screen recording][10], and the keyboard shortcuts help me a lot in pausing and resuming the recording. + +What are your favorite Ubuntu shortcuts that you cannot live without? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-shortcuts/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ubuntu-keyboard-shortcuts.jpeg +[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ubuntu-terminal-shortcut.jpg +[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/notification-tray-ubuntu-gnome.jpeg +[4]: https://itsfoss.com/type-indian-languages-ubuntu/ +[5]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/console-alt-f2-ubuntu-gnome.jpeg +[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/workspace-switcher-ubuntu.png +[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/log-out-ubuntu.jpeg +[8]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/custom-keyboard-shortcut.jpg +[9]: https://wiki.gnome.org/Design/OS/KeyboardShortcuts +[10]: https://itsfoss.com/best-linux-screen-recorders/ From b17ead6eec937daf208d28010289305ebeae569e Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Tue, 11 Sep 2018 13:38:54 +0800 Subject: [PATCH 179/455] translated --- ...mmands for effective process management.md | 108 +++++++++++++----- 1 file changed, 79 insertions(+), 29 deletions(-) rename {sources => translated}/tech/20180904 8 Linux commands for effective process management.md (58%) diff --git a/sources/tech/20180904 8 Linux commands for effective process management.md b/translated/tech/20180904 8 Linux commands for effective process management.md similarity index 58% rename from sources/tech/20180904 8 Linux commands for effective process management.md rename to translated/tech/20180904 8 Linux commands for effective process management.md index 08d4770cb2..cefd79adac 100644 --- a/sources/tech/20180904 8 Linux commands for effective process management.md +++ b/translated/tech/20180904 8 Linux commands for effective process management.md @@ -1,15 +1,18 @@ heguangzhi Translating -8 Linux commands for effective process management +8个Linux命令用于有效的进程管理 ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg) -Generally, an application process' lifecycle has three main states: start, run, and stop. Each state can and should be managed carefully if we want to be competent administrators. These eight commands can be used to manage processes through their lifecycles. +一般来说,应用程序的生命周期有三种主要状态:启动、运行和停止。如果我们想成为称职的管理员,每个状态都可以而且应该得到认真的管理。这八个命令可用于管理进程的整个生命周期。 -### Starting a process -The easiest way to start a process is to type its name at the command line and press Enter. If you want to start an Nginx web server, type **nginx**. Perhaps you just want to check the version. +### 启动进程 + + +启动进程的最简单方法是在命令行中键入其名称,然后按 Enter 键。如果要启动 Nginx web 服务器,请键入 **nginx** 。也许您只是想看看其版本。 + ``` alan@workstation:~$ nginx @@ -17,9 +20,11 @@ alan@workstation:~$ nginx -v nginx version: nginx/1.14.0 ``` -### Viewing your executable path -The above demonstration of starting a process assumes the executable file is located in your executable path. Understanding this path is key to reliably starting and managing a process. Administrators often customize this path for their desired purpose. You can view your executable path using **echo $PATH**. +### 查看您的可执行路径 + +以上启动进程的演示是假设可执行文件位于您的可执行路径中。理解这条路径是是否启动和管理进程的关键。管理员通常会为他们想要的目的定制这条路径。您可以使用 **echo $PATH** 查看您的可执行路径。 + ``` alan@workstation:~$ echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin @@ -27,26 +32,36 @@ alan@workstation:~$ echo $PATH #### WHICH -Use the which command to view the full path of an executable file. + +使用 which 命令查看可执行文件的完整路径。 + ``` alan@workstation:~$ which nginx                                                     /opt/nginx/bin/nginx ``` -I will use the popular web server software Nginx for my examples. Let's assume that Nginx is installed. If the command **which nginx** returns nothing, then Nginx was not found because which searches only your defined executable path. There are three ways to remedy a situation where a process cannot be started simply by name. The first is to type the full path. Although, I'd rather not have to type all of that, would you? + +我将使用流行的 web 服务器软件 Nginx 作为我的例子。假设安装了 Nginx。如果执行 **which nginx** 的命令什么也不返回,那么 Nginx 就找不到了,因为它只搜索您指定的可执行路径。有三种方法可以补救一个进程不能简单地通过名字启动的情况。首先是键入完整路径。虽然,我不情愿输入全部路径,您会吗? + + ``` alan@workstation:~$ /home/alan/web/prod/nginx/sbin/nginx -v nginx version: nginx/1.14.0 ``` -The second solution would be to install the application in a directory in your executable's path. However, this may not be possible, particularly if you don't have root privileges. -The third solution is to update your executable path environment variable to include the directory where the specific application you want to use is installed. This solution is shell-dependent. For example, Bash users would need to edit the PATH= line in their .bashrc file. +第二个解决方案是将应用程序安装在可执行文件路径中的目录中。然而,这可能是不可能的,特别是如果您没有 root 权限。 + + +第三个解决方案是更新您的可执行路径环境变量,包括要使用的特定应用程序的安装目录。这个解决方案是 shell-dependent。例如,Bash 用户需要在他们的 .bashrc 文件中编辑 PATH= line。 + ``` PATH="$HOME/web/prod/nginx/sbin:$PATH" ``` -Now, repeat your echo and which commands or try to check the version. Much easier! + +现在,重复您的 echo 和 which命令或者尝试检查版本。容易多了! + ``` alan@workstation:~$ echo $PATH /home/alan/web/prod/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin @@ -58,24 +73,27 @@ alan@workstation:~$ nginx -v                                   nginx version: nginx/1.14.0 ``` -### Keeping a process running +### 保持进程运行 #### NOHUP -A process may not continue to run when you log out or close your terminal. This special case can be avoided by preceding the command you want to run with the nohup command. Also, appending an ampersand (&) will send the process to the background and allow you to continue using the terminal. For example, suppose you want to run myprogram.sh. + +注销或关闭终端时,进程可能不会继续运行。这种特殊情况可以通过在要使用 nohup 命令放在要运行的命令前面让进程持续运行。此外,附加一个&符号将会把进程发送到后台,并允许您继续使用终端。例如,假设您想运行 myprogram.sh 。 ``` nohup myprogram.sh & ``` -One nice thing nohup does is return the running process's PID. I'll talk more about the PID next. +nohup 会返回运行进程的PID。接下来我会更多地谈论PID。 -### Manage a running process +### 管理正在运行的进程 -Each process is given a unique process identification number (PID). This number is what we use to manage each process. We can also use the process name, as I'll demonstrate below. There are several commands that can check the status of a running process. Let's take a quick look at these. + +每个进程都有一个唯一的进程标识号 (PID) 。这个数字是我们用来管理每个进程的。我们还可以使用进程名称,我将在下面演示。有几个命令可以检查正在运行的进程的状态。让我们快速看看这些命令。 #### PS -The most common is ps. The default output of ps is a simple list of the processes running in your current terminal. As you can see below, the first column contains the PID. +最常见的是 ps 命令。ps 的默认输出是当前终端中运行的进程的简单列表。如下所示,第一列包含PID。 + ``` alan@workstation:~$ ps PID TTY          TIME CMD @@ -83,7 +101,8 @@ PID TTY          TIME CMD 24148 pts/0    00:00:00 ps ``` -I'd like to view the Nginx process I started earlier. To do this, I tell ps to show me every running process ( **-e** ) and a full listing ( **-f** ). + +我想看看我之前开始的 Nginx 进程。为此,我告诉 ps 给我展示每一个正在运行的进程( **-e** ) 和完整的列表 ( **-f** )。 ``` alan@workstation:~$ ps -ef UID        PID  PPID  C STIME TTY          TIME CMD @@ -109,25 +128,29 @@ alan     20536 20526  0 10:39 pts/0    00:00:00 pager alan     20564 20496  0 10:40 pts/1    00:00:00 bash ``` -You can see the Nginx processes in the output of the ps command above. The command displayed almost 300 lines, but I shortened it for this illustration. As you can imagine, trying to handle 300 lines of process information is a bit messy. We can pipe this output to grep to filter out nginx. + +您可以在上面 ps 命令的输出中看到 Nginx 进程。这个命令显示了将近300行,但是我在这个例子中缩短了它。可以想象,试图处理300行过程信息有点混乱。我们可以将这个输出输送到 grep, 过滤一下仅显示 nginx。 ``` alan@workstation:~$ ps -ef |grep nginx alan     20520  1454  0 10:39 ?        00:00:00 nginx: master process nginx alan     20521 20520  0 10:39 ?        00:00:00 nginx: worker process ``` -That's better. We can quickly see that Nginx has PIDs of 20520 and 20521. + +确实更好了。我们可以很快看到,Nginx 有20520和2052的PIDs。 #### PGREP -The pgrep command was created to further simplify things by removing the need to call grep separately. +pgrep 命令更加简化单独调用 grep 遇到的问题。 + ``` alan@workstation:~$ pgrep nginx 20520 20521 ``` -Suppose you are in a hosting environment where multiple users are running several different instances of Nginx. You can exclude others from the output with the **-u** option. +假设您在一个托管环境中,多个用户正在运行几个不同的 Nginx 实例。您可以使用 **-u** 选项将其他人排除在输出之外。 + ``` alan@workstation:~$ pgrep -u alan nginx 20520 @@ -136,7 +159,8 @@ alan@workstation:~$ pgrep -u alan nginx #### PIDOF -Another nifty one is pidof. This command will check the PID of a specific binary even if another process with the same name is running. To set up an example, I copied my Nginx to a second directory and started it with the prefix set accordingly. In real life, this instance could be in a different location, such as a directory owned by a different user. If I run both Nginx instances, the **ps -ef** output shows all their processes. + +另一个好用的是pidof。此命令将检查特定二进制文件的 PID,即使另一个同名进程正在运行。为了建立一个例子,我将我的 Nginx 复制到第二个目录,并以相应的前缀集开始。在现实生活中,这个实例可能位于不同的位置,例如由不同用户拥有的目录。如果我运行两个 Nginx 实例,则pidof 输出显示它们的所有进程。 ``` alan@workstation:~$ ps -ef |grep nginx alan     20881  1454  0 11:18 ?        00:00:00 nginx: master process ./nginx -p /home/alan/web/prod/nginxsec @@ -145,7 +169,8 @@ alan     20895  1454  0 11:19 ?        00:00:00 nginx: master process ng alan     20896 20895  0 11:19 ?        00:00:00 nginx: worker process ``` -Using grep or pgrep will show PID numbers, but we may not be able to discern which instance is which. +使用 grep 或 pgrep 将显示 PID 数字,但我们可能无法辨别哪个实例是哪个。 + ``` alan@workstation:~$ pgrep nginx 20881 @@ -154,7 +179,8 @@ alan@workstation:~$ pgrep nginx 20896 ``` -The pidof command can be used to determine the PID of each specific Nginx instance. +pidof 命令可用于确定每个特定 Nginx 实例的PID。 + ``` alan@workstation:~$ pidof /home/alan/web/prod/nginxsec/sbin/nginx 20882 20881 @@ -165,7 +191,7 @@ alan@workstation:~$ pidof /home/alan/web/prod/nginx/sbin/nginx #### TOP -The top command has been around a long time and is very useful for viewing details of running processes and quickly identifying issues such as memory hogs. Its default view is shown below. +top 命令已经有很长时间了,对于查看运行进程的细节和快速识别内存消耗等问题是非常有用的。其默认视图如下所示。 ``` top - 11:56:28 up 1 day, 13:37,  1 user,  load average: 0.09, 0.04, 0.03 Tasks: 292 total,   3 running, 225 sleeping,   0 stopped,   0 zombie @@ -184,7 +210,7 @@ KiB Swap:        0 total,        0 free,        0 used. 14176540 ava     7 root      20   0       0      0      0 S   0.0  0.0   0:00.08 ksoftirqd/0 ``` -The update interval can be changed by typing the letter **s** followed by the number of seconds you prefer for updates. To make it easier to monitor our example Nginx processes, we can call top and pass the PID(s) using the **-p** option. This output is much cleaner. +可以通过键入字母 **s** 和您喜欢的更新秒数来更改更新间隔。为了更容易监控我们的示例 Nginx 进程,我们可以使用 **-p** 选项调用top并通过PID。这个输出要干净得多。 ``` alan@workstation:~$ top -p20881 -p20882 -p20895 -p20896 @@ -200,13 +226,17 @@ KiB Swap:        0 total,        0 free,        0 used. 14177928 ava 20896 alan      20   0   12460   1628    912 S   0.0  0.0   0:00.00 nginx ``` -It is important to correctly determine the PID when managing processes, particularly stopping one. Also, if using top in this manner, any time one of these processes is stopped or a new one is started, top will need to be informed of the new ones. +在管理进程,特别是终止进程时,正确确定PID是非常重要。此外,如果以这种方式使用top,每当这些进程中的一个停止或一个新进程开始时,top都需要被告知有新的更新。 -### Stopping a process +### 终止进程 #### KILL Interestingly, there is no stop command. In Linux, there is the kill command. Kill is used to send a signal to a process. The most commonly used signal is "terminate" (SIGTERM) or "kill" (SIGKILL). However, there are many more. Below are some examples. The full list can be shown with **kill -L**. + + +有趣的是,没有 stop 命令。在 Linux中,有 kill 命令。kill 用于向进程发送信号。最常用的信号是“终止”( SIGTERM )或“杀死”( SIGKILL )。然而,还有更多。下面是一些例子。完整的列表可以用 **kill -L** 显示。 + ```  1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP  6) SIGABRT      7) SIGBUS       8) SIGFPE       9) SIGKILL     10) SIGUSR1 @@ -215,6 +245,10 @@ Interestingly, there is no stop command. In Linux, there is the kill command. Ki ``` Notice signal number nine is SIGKILL. Usually, we issue a command such as **kill -9 20896**. The default signal is 15, which is SIGTERM. Keep in mind that many applications have their own method for stopping. Nginx uses a **-s** option for passing a signal such as "stop" or "reload." Generally, I prefer to use an application's specific method to stop an operation. However, I'll demonstrate the kill command to stop Nginx process 20896 and then confirm it is stopped with pgrep. The PID 20896 no longer appears. + +注意第九号信号是 SIGKILL。通常,我们会发布一个命令,比如 **kill -9 20896** 。默认信号是15,这是SIGTERM。请记住,许多应用程序都有自己的停止方法。Nginx 使用 **-s** 选项传递信号,如“停止”或“重新加载”。“通常,我更喜欢使用应用程序的特定方法来停止操作。然而,我将演示 kill 命令来停止 Nginx process 20896,然后用 pgrep 确认它已经停止。PID 20896 就不再出现。 + + ``` alan@workstation:~$ kill -9 20896   @@ -228,6 +262,9 @@ alan@workstation:~$ pgrep nginx #### PKILL The command pkill is similar to pgrep in that it can search by name. This means you have to be very careful when using pkill. In my example with Nginx, I might not choose to use it if I only want to kill one Nginx instance. I can pass the Nginx option **-s** **stop** to a specific instance to kill it, or I need to use grep to filter on the full ps output. + +命令 pkill 类似于 pgrep,因为它可以按名称搜索。这意味着在使用 pkill 时必须非常小心。在我的 Nginx 示例中,如果我只想杀死一个 Nginx 实例,我可能不会选择使用它。我可以将 Nginx 选项 **-s** **stop** 传递给特定的实例来消除它,或者我需要使用grep来过滤整个 ps 输出。 + ``` /home/alan/web/prod/nginx/sbin/nginx -s stop @@ -235,6 +272,9 @@ The command pkill is similar to pgrep in that it can search by name. This means ``` If I want to use pkill, I can include the **-f** option to ask pkill to filter across the full command line argument. This of course also applies to pgrep. So, first I can check with **pgrep -a** before issuing the **pkill -f**. + +如果我想使用 pkill,我可以包括 **-f** 选项,让 pkill 过滤整个命令行参数。这当然也适用于 pgrep。所以,在执行 **pkill -f** 之前,首先我可以用 **pgrep -a** 确认一下。 + ``` alan@workstation:~$ pgrep -a nginx 20881 nginx: master process ./nginx -p /home/alan/web/prod/nginxsec @@ -244,6 +284,10 @@ alan@workstation:~$ pgrep -a nginx ``` I can also narrow down my result with **pgrep -f**. The same argument used with pkill stops the process. + +我也可以用 **pgrep -f** 缩小我的结果。pkill 使用的相同参数会停止该进程。 + + ``` alan@workstation:~$ pgrep -f nginxsec 20881 @@ -253,8 +297,14 @@ alan@workstation:~$ pkill -f nginxsec The key thing to remember with pgrep (and especially pkill) is that you must always be sure that your search result is accurate so you aren't unintentionally affecting the wrong processes. +pgrep (尤其是pkill )要记住的关键点是,您必须始终确保搜索结果准确性,这样您就不会无意中影响到错误的进程。 + Most of these commands have many command line options, so I always recommend reading the [man page][1] on each one. While most of these exist across platforms such as Linux, Solaris, and BSD, there are a few differences. Always test and be ready to correct as needed when working at the command line or writing scripts. + + +大多数这些命令都有许多命令行选项,所以我总是建议阅读每一个命令的 [man page][1]。虽然大多数这些都存在于 Linux、Solaris 和 BSD 等平台上,但也有一些不同之处。在命令行工作或编写脚本时,始终测试并随时准备根据需要进行更正。 + -------------------------------------------------------------------------------- via: https://opensource.com/article/18/9/linux-commands-process-management From 1b5d86ae0e74f5adc1ddd14ae918f57a3b4e207d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 11 Sep 2018 22:02:57 +0800 Subject: [PATCH 180/455] PUB:20171010 Operating a Kubernetes network.md @qhwdw https://linux.cn/article-10003-1.html --- .../20171010 Operating a Kubernetes network.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) rename {translated/tech => published}/20171010 Operating a Kubernetes network.md (97%) diff --git a/translated/tech/20171010 Operating a Kubernetes network.md b/published/20171010 Operating a Kubernetes network.md similarity index 97% rename from translated/tech/20171010 Operating a Kubernetes network.md rename to published/20171010 Operating a Kubernetes network.md index 44f053f3e3..74c061d675 100644 --- a/translated/tech/20171010 Operating a Kubernetes network.md +++ b/published/20171010 Operating a Kubernetes network.md @@ -7,9 +7,7 @@ Kubernetes 网络运维 * 避免生产系统网络中断非常重要 * 运维联网软件是很难的 -* 有关你的网络基础设施的重要变化值得深思熟虑,以及这种变化对可靠性的影响。 - -虽然非常“牛x”的谷歌人常说“这是我们在谷歌正在用的”(谷歌工程师在 Kubernetes 上正做着很重大的工作!但是我认为重要的仍然是研究架构,并确保它对你的组织有意义)。 +* 有关你的网络基础设施的重要变化值得深思熟虑,以及这种变化对可靠性的影响。虽然非常“牛x”的谷歌人常说“这是我们在谷歌正在用的”(谷歌工程师在 Kubernetes 上正做着很重大的工作!但是我认为重要的仍然是研究架构,并确保它对你的组织有意义)。 我肯定不是 Kubernetes 网络方面的专家,但是我在配置 Kubernetes 网络时遇到了一些问题,并且比以前更加了解 Kubernetes 网络了。 @@ -35,7 +33,7 @@ Kubernetes 网络运维 在本文中我们将要讨论的 Kubernetes 网络组件有: -* 网络覆盖后端(像 flannel/calico/weave 网络/romana) +* 覆盖网络overlay network的后端(像 flannel/calico/weave 网络/romana) * `kube-dns` * `kube-proxy` * 入站控制器 / 负载均衡器 @@ -166,7 +164,7 @@ kube-proxy 像如下这样为每个目标主机创建一个 `iptables` 规则: via: https://jvns.ca/blog/2017/10/10/operating-a-kubernetes-network/ -作者:[Julia Evans ][a] +作者:[Julia Evans][a] 译者:[qhwdw](https://github.com/qhwdw) 校对:[wxy](https://github.com/wxy) From 5055251b31067893fd28e0e9b3f63012fbc7c70e Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 12 Sep 2018 09:51:53 +0800 Subject: [PATCH 181/455] translated --- ... your systems easily on a LAN with mDNS.md | 110 ------------------ ... your systems easily on a LAN with mDNS.md | 108 +++++++++++++++++ 2 files changed, 108 insertions(+), 110 deletions(-) delete mode 100644 sources/tech/20180905 Find your systems easily on a LAN with mDNS.md create mode 100644 translated/tech/20180905 Find your systems easily on a LAN with mDNS.md diff --git a/sources/tech/20180905 Find your systems easily on a LAN with mDNS.md b/sources/tech/20180905 Find your systems easily on a LAN with mDNS.md deleted file mode 100644 index 40da04358e..0000000000 --- a/sources/tech/20180905 Find your systems easily on a LAN with mDNS.md +++ /dev/null @@ -1,110 +0,0 @@ -translating---geekpi - -Find your systems easily on a LAN with mDNS -====== - -![](https://fedoramagazine.org/wp-content/uploads/2018/09/mDNS-816x345.jpg) - -Multicast DNS, or mDNS, lets systems broadcast queries on a local network to find other resources by name. Fedora users often own multiple Linux systems on a router without sophisticated name services. In that case, mDNS lets you talk to your multiple systems by name — without touching the router in most cases. You also don’t have to keep files like /etc/hosts in sync on all the local systems. This article shows you how to set it up. - -mDNS is a zero-configuration networking service that’s been around for quite a while. Fedora ships Avahi, a zero-configuration stack that includes mDNS, as part of Workstation. (mDNS is also part of Bonjour, found on Mac OS.) - -This article assumes you have two systems running supported versions of Fedora (27 or 28). Their host names are meant to be castor and pollux. - -### Installing packages - -Make sure the nss-mdns and avahi packages are installed on your system. You might have a different version, which is fine: -``` -$ rpm -q nss-mdns avahi -nss-mdns-0.14.1-1.fc28.x86_64 -avahi-0.7-13.fc28.x86_64 - -``` - -Fedora Workstation provides both of these packages by default. If not present, install them: -``` -$ sudo dnf install nss-mdns avahi - -``` - -Make sure the avahi-daemon.service unit is enabled and running. Again, this is the default on Fedora Workstation. -``` -$ sudo systemctl enable --now avahi-daemon.service - -``` - -Although optional, you might also want to install the avahi-tools package. This package includes a number of handy utilities for checking how well the zero-configuration services on your system are working. Use this sudo command: -``` -$ sudo dnf install avahi-tools - -``` - -The /etc/nsswitch.conf file controls which services your system uses to resolve services, and in what order. You should see a line like this in that file: -``` -hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname - -``` - -Notice the commands mdns4_minimal [NOTFOUND=return]. They tell your system to use the multicast DNS resolver to resolve a hostname to an IP address. Even if that service works, the remaining services are tried if the name doesn’t resolve. - -If you don’t see a configuration similar to this, you can edit it (as the root user). However, the nss-mdns package handles this for you. Remove and reinstall that package to fix the file, if you’re uncomfortable editing it yourself. - -Follow the steps above for **both systems**. - -### Setting host name and testing - -Now that you’ve done the common configuration work, set up each host’s name in one of these ways: - - 1. If you’re using Fedora Workstation, [you can use this procedure][1]. - - 2. If not, use hostnamectl to do the honors. Do this for the first box: -``` -$ hostnamectl set-hostname castor - -``` - - 3. You can also edit the /etc/avahi/avahi-daemon.conf file, remove the comment on the host-name setting line, and set the name there. By default, though, Avahi uses the system provided host name, so you **shouldn’t** need this method. - -Next, restart the Avahi daemon so it picks up changes: -``` -$ sudo systemctl restart avahi-daemon.service - -``` - -Then set your other box properly: -``` -$ hostnamectl set-hostname pollux -$ sudo systemctl restart avahi-daemon.service - -``` - -As long as your network router is not disallowing mDNS traffic, you should now be able to login to castor and ping the other box. You should use the default .local domain name so resolution works correctly: -``` -$ ping pollux.local -PING pollux.local (192.168.0.1) 56(84) bytes of data. -64 bytes from 192.168.0.1 (192.168.0.1): icmp_seq=1 ttl=64 time=3.17 ms -64 bytes from 192.168.0.1 (192.168.0.1): icmp_seq=2 ttl=64 time=1.24 ms -... - -``` - -The same trick should also work from pollux if you ping castor.local. It’s much more convenient now to access your systems around the network! - -Moreover, don’t be surprised if your router advertises services. Modern WiFi and wired routers often provide these services to make life easier for consumers. - -This process works for most systems. However, if you run into trouble, use avahi-browse and other tools from the avahi-tools package to see what services are available. - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/find-systems-easily-lan-mdns/ - -作者:[Paul W. Frields][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/pfrields/ -[1]: https://fedoramagazine.org/set-hostname-fedora/ diff --git a/translated/tech/20180905 Find your systems easily on a LAN with mDNS.md b/translated/tech/20180905 Find your systems easily on a LAN with mDNS.md new file mode 100644 index 0000000000..48d9434b58 --- /dev/null +++ b/translated/tech/20180905 Find your systems easily on a LAN with mDNS.md @@ -0,0 +1,108 @@ +使用 mDNS 在局域网中轻松发现系统 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/09/mDNS-816x345.jpg) + +多播 DNS 或 mDNS 允许系统通过在广播查询局域网中的其他资源。Fedora 用户经常在没有复杂名称服务的路由器上拥有多个 Linux 系统。在这种情况下,mDNS 允许你按名称与多个系统通信 - 多数情况下不用路由器。你也不必在所有本地系统上同步类似 /etc/hosts 之类的文件。本文介绍如何设置它。 + +mDNS 是一个零配置网络服务,它已经诞生了很长一段时间。Fedora 将 Avahi (包含 mDNS 的零配置系统)作为工作站的一部分。 (mDNS 也是 Bonjour 的一部分,可在 Mac OS 上找到。) + +本文假设你有两个系统运行受支持的 Fedora 版本(27 或 28)。它们的主机名是 castor 和 pollux。 + +### 安装包 + +确保系统上安装了 nss-mdns 和 avahi 软件包。你可能是不同的版本,这也没问题: +``` +$ rpm -q nss-mdns avahi +nss-mdns-0.14.1-1.fc28.x86_64 +avahi-0.7-13.fc28.x86_64 + +``` + +Fedora Workstation 默认提供这两个包。如果不存在,请安装它们: +``` +$ sudo dnf install nss-mdns avahi + +``` + +确保 avahi-daemon.service 单元已启用并正在运行。同样,这是 Fedora Workstation 的默认设置。 +``` +$ sudo systemctl enable --now avahi-daemon.service + +``` + +虽然是可选的,但你可能还需要安装 avahi-tools 软件包。该软件包包括许多方便的程序,用于检查系统上的零配置服务的工作情况。使用这个 sudo 命令: +``` +$ sudo dnf install avahi-tools + +``` + +/etc/nsswitch.conf 控制系统使用哪个服务用于解析,以及它们的顺序。你应该在那个文件中看到这样的一行: +``` +hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname + +``` + +注意命令 mdns4_minimal [NOTFOUND=return]。它们告诉你的系统使用多播 DNS 解析程序将主机名解析为 IP 地址。即使该服务有效,如果名称无法解析,也会尝试其余服务。 + +如果你没有看到与此类似的配置,则可以对其进行编辑(以 root 用户身份)。但是,nss-mdns 包会为你处理此问题。如果你对自己编辑它感到不舒服,请删除并重新安装该软件包以修复该文件。 + +在**两个系统**中执行同样的步骤 。 + +### 设置主机名并测试 + +现在你已完成常见的配置工作,请使用以下方法之一设置每个主机的名称: + + 1. 如果你正在使用 Fedora Workstation,[你可以使用这个步骤][1]。 + + 2. 如果没有,请使用 hostnamectl 来做。在第一台机器上这么做: +``` +$ hostnamectl set-hostname castor + +``` + + 3. 你还可以编辑 /etc/avahi/avahi-daemon.conf,删除主机名设置行上的注释,并在那里设置名称。但是,默认情况下,Avahi 使用系统提供的主机名,因此你**不应该**需要此方法。 + +接下来,重启 Avahi 守护进程,以便它接收更改: +``` +$ sudo systemctl restart avahi-daemon.service + +``` + +然后正确设置另一台机器: +``` +$ hostnamectl set-hostname pollux +$ sudo systemctl restart avahi-daemon.service + +``` + +只要你的路由器没有禁止 mDNS 流量,你现在应该能够登录到 castor 并 ping 通另一台机器。你应该使用默认的 .local 域名,以便解析正常工作: +``` +$ ping pollux.local +PING pollux.local (192.168.0.1) 56(84) bytes of data. +64 bytes from 192.168.0.1 (192.168.0.1): icmp_seq=1 ttl=64 time=3.17 ms +64 bytes from 192.168.0.1 (192.168.0.1): icmp_seq=2 ttl=64 time=1.24 ms +... + +``` + +如果你在 pollux ping castor.local,同样的技巧也适用 。现在在网络中访问你的系统更方便了! + +此外,如果你的路由器宣传这个服务,请不要感到惊讶。现代 WiFi 和有线路由器通常提供这些服务,以使消费者的生活更轻松。 + +此过程适用于大多数系统。但是,如果遇到麻烦,请使用 avahi-browse 和 avahi-tools 软件包中的其他工具来查看可用的服务。 + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/find-systems-easily-lan-mdns/ + +作者:[Paul W. Frields][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[1]: https://fedoramagazine.org/set-hostname-fedora/ From bf45e1628c79506b25e9d4f860d82d70204d48a5 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 12 Sep 2018 09:57:19 +0800 Subject: [PATCH 182/455] translating --- ...w of Photos in Ubuntu 18.04 and other Linux Distributions.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md b/sources/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md index 370e31c6a9..3dc6a33407 100644 --- a/sources/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md +++ b/sources/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md @@ -1,3 +1,5 @@ +translating---geekpi + How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions ====== Creating a slideshow of photos is a matter of a few clicks. Here’s how to make a slideshow of pictures in Ubuntu 18.04 and other Linux distributions. From 91b72056de83995862e3bc291e27e1dcb7082b0e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 12 Sep 2018 10:41:21 +0800 Subject: [PATCH 183/455] PRF:20180827 An introduction to diffs and patches.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @DavidChenLiang 很用心。 --- ...27 An introduction to diffs and patches.md | 50 +++++++++---------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/translated/tech/20180827 An introduction to diffs and patches.md b/translated/tech/20180827 An introduction to diffs and patches.md index 190d62f122..734b1cc978 100644 --- a/translated/tech/20180827 An introduction to diffs and patches.md +++ b/translated/tech/20180827 An introduction to diffs and patches.md @@ -1,45 +1,44 @@ -差异文件(diffs)和补丁文件(patches)简介 +差异文件(diff)和补丁文件(patch)简介 ====== + +> 这篇文章介绍差异文件diff补丁文件patch,以及它们如何在开源项目中使用的例子。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0) - 如果你曾有机会在一个使用分布式开发模型的大型代码库上工作过,你就应该听说过类似下面的话,"Sue刚发过来一个补丁","Rajiv 正在签出差异文件", 可能这些词(补丁,差异文件)对你而言很陌生,而你确定很想搞懂他们到底指什么。开源软件对上述提到的名词有很大的贡献,作为从开发 Apache web 服务器到开发Linux 内核的开发模型,"基于补丁文件的开发" 这一模式贯穿了上述项目的始终。实际上,你可能不知道 Apache 的名字就来自一系列的代码补丁,他们被一一收集起来并针对原来的[NCSA HTTPd server source code][1]进行了校对 +如果你曾有机会在一个使用分布式开发模型的大型代码库上工作过,你就应该听说过类似下面的话,“Sue 刚发过来一个补丁patch”,“Rajiv 正在签出checking out差异diff”, 可能这些词(补丁、差异文件)对你而言很陌生,而你确定很想搞懂他们到底指什么。开源软件对上述提到的名词有很大的贡献,作为大型项目从 Apache web 服务器到 Linux 内核的开发模型,“基于补丁文件的开发” 这一模式贯穿了上述项目的始终。实际上,你可能不知道 Apache 的名字就来自“一系列的代码补丁”(LCTT 译注:Apache 英文发音和补丁的英文 patch 相似),它们被一一收集起来并针对原来的 [NCSA HTTPd server source code][1] 进行了修订。 - 你可能认为前面说的只不过是些逸闻,但是一份早期的[capture of the Apache website][2]声称Apache 的名字就是来自于最早的“补丁文件”集合;(译注:Apache 英文音和补丁相似),是“打了补丁的”服务器的英文名字简化。 +你可能认为这只不过是些逸闻,但是一份早期的 [Apache 网站的存档中][2] 声称 Apache 的名字就是来自于最早的“补丁”集合;即“打了补丁的APAtCHy”服务器,简化为 Apache。 -好了,言归正传,程序员嘴里说的"差异"和"补丁" 到底是什么? +好了,言归正传,程序员嘴里说的“差异”和“补丁”到底是什么? -首先,在这篇文章里,我们可以认为这两个术语都指向同一个概念。“差异” 就是”补丁“。Unix 下的同名工具程序diff("差异")和patch("补丁")剖析了一个或多个文件之间的”差异”。下面我们看看diff 的例子: - -一个"补丁"指的是文件之间一系列差异,这些差异能被 Unix 的 diff程序应用在源代码树上,使之转变为程序员想要的文件状态。我们能使用diff 工具来创建“差异”( 或“补丁”),然后将他们“打” 在一个没有这个补丁的源代码版本上,此外,(我又要开始跑题了...),“补丁” 这个词真的指在计算机的早期使用打卡机的时候,用来覆盖在纸带上的用于修复代码错误的覆盖纸,那个时代纸带(上面有孔)就是在计算机处理器上运行的程序。下面的这张图,来自[Wikipedia Page][3] 真切的描绘了最初的“ 打补丁”这个词的出处: +首先,在这篇文章里,我们可以认为这两个术语都指向同一个概念。“diff” 是 ”difference“ 的简写;Unix 下的同名工具程序 `diff`剖析了一个或多个文件之间的“差异”。下面我们会看到 `diff` 的例子: +一个“补丁”指的是文件之间一系列差异,这些差异能被 Unix 的 `diff` 程序应用在源代码树上。我们能使用 `diff` 工具来创建“差异”(或“补丁”),然后使用该工具将它们 “打” 在一个没有这个补丁的同样的源代码版本上。此外,(我又要开始跑题说些历史轶事了……),“补丁” 这个词真的指在计算机的早期使用打卡机的时候,用来覆盖在打孔纸带上来对软件进行修改的覆盖纸,那个时代打孔纸带就是在计算机处理器上运行的程序。下面来自 [维基页面][3] 的这张图真切的描绘了最初的“打补丁”这个词的出处: ![](https://opensource.com/sites/default/files/uploads/360px-harvard_mark_i_program_tape.agr_.jpg) -现在你对补丁和差异就了一个基本的概念,让我们来看看软件开发者是怎么使用这些工具的。如果你还没有使用过类似于[Git][4]这样的源代码版本控制工具的话,我将会一步步展示最流行的软件项目是怎么使用它们的。如果你将一个软件的生命周期看成是一条时间线的话,你就能看见这个软件的点滴变化,比如在何时源代码树加上了一个功能,在何时源代码树修复了一个功能缺陷。我们称这些改变的点为“进行了一次提交”,”提交“这个词被当今最流行的源代码版本管理工具Git使用, 当你想检查在一个提交前后的代码变化的话,(或者在许多个提交之间的代码变化),你都可以使用工具来观察文件差异。 +现在你对补丁和差异就了一个基本的概念,让我们来看看软件开发者是怎么使用这些工具的。如果你还没有使用过类似于 [Git][4] 或 [subversion][5] 这样的源代码版本控制工具的话,我将会一步步展示最流行的软件项目是怎么使用它们的。如果你将一个软件的生命周期看成是一条时间线的话,你就能看见这个软件的点滴变化,比如在何时源代码加上了一个功能,在何时源代码修复了一个功能缺陷。我们称这些改变的点为“提交commit”,“提交”这个词被当今最流行的源代码版本管理工具 Git 所使用,当你想检查在一个提交前后的代码变化的话,(或者在许多个提交之间的代码变化),你都可以使用工具来观察文件差异。 -如果你在使用 Git 开发软件的话,你开发环境本地有可能就有你想交给别的开发者的提交,为了给别的开发者你的提交,一个方法就是创建一个你本地文件的差异文件,然后将这个“补丁”发送给和你工作在同一个源代码树的别的开发者。别的开发者在“打”了你的补丁之后,就能看到在你的代码变树上的变化。 +如果你同样在使用 Git 开发软件的话,你可以在你的本地开发环境做些希望交给别的开发者的提交,以添加到他们的源代码树中。为了给别的开发者你的提交,一个方法就是创建一个你本地文件的差异文件,然后将这个“补丁”发送给和你工作在同一个源代码树的别的开发者。别的开发者在“打”了你的补丁之后,就能看到在你的代码变树上的变化。 +### Linux、Git 和 GitHub -### Linux, Git, 和 GitHub - -这种共享补丁的开发模型正是现今 Linux 内核社区如何处理内核修改提议而采用的模型。如果你有机会浏览任何一个主流的 Linux 内核邮件列表-主要是[LKML][6],包括[linux-containers][7],[fs-devel][8],[Netdev][9]等等,你能看到很多开发者会贴出他们想让其他内核开发者审核,测试或者合入Linux官方Git代码树某个提交的补丁。当然,讨论 Git 不在这篇文章范围之内(Git 是由 Linus Torvalds 开发的源代码控制系统,它支持分布式开发模型以及允许独立于主要代码仓库的补丁包,这些补丁包能被推送或拉取到不同的源代码树上并遵守这些代码树各自的开发流程。) - -在继续我们的话题之前,我们当然不能忽略和补丁和差异这个概念最相关的的服务:[GitHub][10]。从它的名字就能猜想出 GitHub 是基于 Git 的,而且它还围绕着 Git对分布式开源代码开发模型提供了基于Web 和 API 的工作流管理。(译注:即Pull Request -- 拉取请求)。在 GitHub 上,分享补丁的方式不是像 Linux 内核社区那样通过邮件列表,而是通过创建一个 **拉取请求** 。当你提交你自己源代码的改动时,你能通过创建一个针对软件项目的主仓库的“拉取请求”来分享你的代码改动(译注:即核心开发者维护一个主仓库,开发者去“fork”这个仓库,待各自的提交后再创建针对这个主仓库的拉取请求,所有的拉取请求由主仓库的核心开发者批准后才能合入主代码库。)GitHub 被当今很多活跃的开源社区所采用,如[Kubernetes][11],[Docker][12],[the Container Network Interface (CNI)][13],[Istio][14]等等。在 GitHub 的世界里,用户会倾向于使用基于 Web 页面的方式来审核一个拉取请求里的补丁或差异,你也可以直接访问原始的补丁并在命令行上直接使用它们。 - +这种分享补丁的开发模型正是现今 Linux 内核社区如何处理内核修改提议而采用的模型。如果你有机会浏览任何一个主流的 Linux 内核邮件列表 —— 主要是 [LKML][6],也包括 [linux-containers][7]、[fs-devel][8]、[Netdev][9] 等等,你能看到很多开发者会贴出他们想让其他内核开发者审核、测试或者合入 Linux 官方 Git 代码树某个位置的补丁。当然,讨论 Git 不在这篇文章范围之内(Git 是由 Linus Torvalds 开发的源代码控制系统,它支持分布式开发模型以及允许独立于主要代码仓库的补丁包,这些补丁包能被推送或拉取到不同的源代码树上,并遵守这些代码树各自的开发流程。) +在继续我们的话题之前,我们当然不能忽略和补丁和差异这个概念相关的最流行的服务:[GitHub][10]。从它的名字就能猜想出 GitHub 是基于 Git 的,而且它还围绕着 Git 对分布式开源代码开发模型提供了基于 Web 和 API 的工作流管理。(LCTT 译注:即拉取请求Pull Request)。在 GitHub 上,分享补丁的方式不是像 Linux 内核社区那样通过邮件列表,而是通过创建一个 **拉取请求** 。当你提交你自己的源代码树的改动时,你能通过创建一个针对软件项目的共享仓库的“拉取请求”来分享你的代码改动(LCTT 译注:即核心开发者维护一个主仓库,开发者去“复刻fork”这个仓库,待各自的提交后再创建针对这个主仓库的拉取请求,所有的拉取请求由主仓库的核心开发者批准后才能合入主代码库。)GitHub 被当今很多活跃的开源社区所采用,如 [Kubernetes][11]、[Docker][12]、[容器网络接口 (CNI)][13]、[Istio][14] 等等。在 GitHub 的世界里,用户会倾向于使用基于 Web 页面的方式来审核一个拉取请求里的补丁或差异,你也可以直接访问原始的补丁并在命令行上直接使用它们。 ### 该说点干货了 -我们前面已经讲了在流行的开源社区了是怎么应用补丁和 diff的,现在看看一些例子。 +我们前面已经讲了在流行的开源社区里是怎么应用补丁和差异的,现在看看一些例子。 -第一个例子包括一个源代码树的两个不同拷贝,其中一个有代码改动,我们想用 diff来看看这些改动是什么。这个例子里,我们想看的是“合并格式”的补丁,这是现在软件开发世界里最通用的格式。如果想知道更详细参数的用法以及如何生成diff,请参考diff手册。原始的代码在sources-orig目录 而改动后的代码在sources-fixed目录. 如果要在你的命令行上用“合并格式”来展示补丁,请运行如下命令。(译注: 参数 N 代表如果比较的文件不存在,则认为是个空文件, a代表将所有文件都作为文本文件对待,u 代表使用合并格式并输出上下文,r 代表递归比较目录) +第一个例子包括一个源代码树的两个不同副本,其中一个有代码改动,我们想用 `diff` 来看看这些改动是什么。这个例子里,我们想看的是“合并格式unified”的补丁,这是现在软件开发世界里最通用的格式。如果想知道更详细参数的用法以及如何生成差异文件,请参考 `diff` 手册。原始的代码在 `sources-orig` 目录,而改动后的代码在 `sources-fixed` 目录。如果要在你的命令行上用“合并格式”来展示补丁,请运行如下命令。(LCTT 译注:参数 `-N` 代表如果比较的文件不存在,则认为是个空文件, `-a` 代表将所有文件都作为文本文件对待,`-u` 代表使用合并格式并输出上下文,`-r` 代表递归比较目录) ``` $ diff -Naur sources-orig/ sources-fixed/ ``` -...下面是 diff命令的输出: +……下面是 `diff` 命令的输出: ``` diff -Naur sources-orig/officespace/interest.go sources-fixed/officespace/interest.go @@ -62,8 +61,8 @@ diff -Naur sources-orig/officespace/interest.go sources-fixed/officespace/intere    // Save the remaining interest into an account we control:    acct.Balance = acct.Balance + remainingInterest ``` -最开始几行 diff的输出可以这样解释:三个‘---’显示了原来文件的名字;任何在原文件(译注:不是源文件)里存在而在新文件里不存在的行将会用前缀‘-’,用来表示这些行被从源代码里‘减去’了。而‘+++’表示的则相反:在新文件里被加上的行会被放上前缀‘+’,表示这是在新文件里被'加上'的行。每一个补丁”块“(用@@作为前缀的的部分)都有上下文的行号,这能帮助补丁工具(或其他处理器)知道在代码的哪里应用这个补丁块。你能看到我们已经修改了”办公室“这部电影里提到的那个函数(移除了三行并加上了一行代码注释),电影里那个有点贪心的工程师可是偷偷的在计算利息的函数里加了点”料“哦。( LCTT译注:剧情详情请见电影 https://movie.douban.com/subject/1296424/) +最开始几行 `diff` 命令的输出可以这样解释:三个 `---` 显示了原来文件的名字;任何在原文件(LCTT 译注:不是源文件)里存在而在新文件里不存在的行将会用前缀 `-`,用来表示这些行被从源代码里“减去”了。而 `+++` 表示的则相反:在新文件里被加上的行会被放上前缀 `+`,表示这是在新文件里被“加上”的行。补丁文件中的每一个补丁“块”(用 `@@` 作为前缀的的部分)都有上下文的行号,这能帮助补丁工具(或其它处理器)知道在代码的哪里应用这个补丁块。你能看到我们已经修改了“Office Space”这部电影里提到的那个函数(移除了三行并加上了一行代码注释),电影里那个有点贪心的工程师可是偷偷的在计算利息的函数里加了点“料”哦。(LCTT译注:剧情详情请见电影 https://movie.douban.com/subject/1296424/) 如果你想找人来测试你的代码改动,你可以将差异保存到一个补丁里: @@ -71,29 +70,28 @@ diff -Naur sources-orig/officespace/interest.go sources-fixed/officespace/intere $ diff -Naur sources-orig/ sources-fixed/ >myfixes.patch ``` -现在你有补丁 myfixes.patch了,你能把它分享给别的开发者,他们可以将这个补丁打在他们自己的源代码树上从而得到和你一样的代码并测试他们。如果一个开发者的当前工作目录就是他的源代码树的根的话,他可以用下面的命令来打补丁: - +现在你有补丁 `myfixes.patch` 了,你能把它分享给别的开发者,他们可以将这个补丁打在他们自己的源代码树上从而得到和你一样的代码并测试他们。如果一个开发者的当前工作目录就是他的源代码树的根的话,他可以用下面的命令来打补丁: ``` $ patch -p1 < ../myfixes.patch patching file officespace/interest.go ``` -现在这个开发者的源代码树已经打好补丁并准备好构建和测试文件的修改了。那么如果这个开发者在打补丁之前已经改动过了怎么办?只要这些改动没有直接冲突(译注:比如改在同一行上),补丁工具就能自动的合并代码的改动。例如下面的interest.go 文件,他有其他几处改动,然后它想打上myfixes.patch 这个补丁: +现在这个开发者的源代码树已经打好补丁并准备好构建和测试文件的修改了。那么如果这个开发者在打补丁之前已经改动过了怎么办?只要这些改动没有直接冲突(LCTT 译注:比如改在同一行上),补丁工具就能自动的合并代码的改动。例如下面的interest.go 文件,它有其它几处改动,然后它想打上 `myfixes.patch` 这个补丁: ``` $ patch -p1 < ../myfixes.patch patching file officespace/interest.go Hunk #1 succeeded at 26 (offset 15 lines). ``` -在这个例子中,补丁警告说代码改动并不在文件原来的地方而是偏移了15行。如果你文件改动的很厉害,补丁可能干脆说找不到要应用的地方,还好补丁程序提供了提供了打开”模糊“匹配的选项(这个选项在文档里有预置的警告信息,对其讲解已经超出了本文的范围) -如果你使用 Git 或者 GitHub 的话,你可能不会直接使用diff或patch。Git 已经内置了这些功能,你能使用这些功能和共享一个源代码树的其他开发者交互,拉取或合并代码。Git一个比较相近的功能是可以使用 git diff 来对你的本地代码树生成全局差异,又或者对你的任意两次”引用“(可能是一个代表提交的数字,或一个标记或分支的名字,等等)做全局补丁。你甚至能简单的用管道将 git diff的输出到一个文件里(这个文件必须严格符合将要被使用它的程序的输入要求),然后将这个文件交给一个并不使用 Git 的开发者应用到他的代码上。当然,GitHub 把这些功能放到了 Web 上,你能直接在 Web 页面上查看一个拉取请求的文件变动。在Web 上你能看到所展示的合并差异,GitHub 还允许你将这些代码改动下载为原始的补丁文件。 +在这个例子中,补丁警告说代码改动并不在文件原来的地方而是偏移了 15 行。如果你文件改动的很厉害,补丁可能干脆说找不到要应用的地方,还好补丁程序提供了提供了打开“模糊”匹配的选项(这个选项在文档里有预置的警告信息,对其讲解已经超出了本文的范围)。 +如果你使用 Git 或者 GitHub 的话,你可能不会直接使用补丁或差异。Git 已经内置了这些功能,你能使用这些功能和共享一个源代码树的其他开发者交互,拉取或合并代码。Git 一个比较相近的功能是可以使用 `git diff` 来对你的本地代码树生成全局差异,又或者对你的任意两次”引用“(可能是一个代表提交的数字,或一个标记或分支的名字,等等)做全局补丁。你甚至能简单的用管道将 `git diff` 的输出到一个文件里(这个文件必须严格符合将要被使用它的程序的输入要求),然后将这个文件交给一个并不使用 Git 的开发者应用到他的代码上。当然,GitHub 把这些功能放到了 Web 上,你能直接在 Web 页面上查看一个拉取请求的文件变动。在 Web 上你能看到所展示的合并差异,GitHub 还允许你将这些代码改动下载为原始的补丁文件。 ### 总结 -好了,你已经学到了”差异“和”补丁“是什么,以及在 Unix/Linux 上怎么使用命令行工具和他们交互。除非你还在像 Linux 内核开发这样的项目中工作而使用完全基于补丁的开发方式,你应该会主要通过你的源代码控制系统(如Git)来使用补丁。但熟悉像 GitHub 这样的高级别工具的技术背景和技术底层对你的工作也是大有裨益的。谁知道会不会有一天你需要和一个来自 Linux 世界邮件列表的补丁包打交道呢? +好了,你已经学到了”差异“和”补丁“是什么,以及在 Unix/Linux 上怎么使用命令行工具和它们交互。除非你还在像 Linux 内核开发这样的项目中工作而使用完全基于补丁文件的开发方式,你应该会主要通过你的源代码控制系统(如 Git)来使用补丁。但熟悉像 GitHub 这样的高级别工具的技术背景和技术底层对你的工作也是大有裨益的。谁知道会不会有一天你需要和一个来自 Linux 世界邮件列表的补丁包打交道呢? -------------------------------------------------------------------------------- @@ -103,7 +101,7 @@ via: https://opensource.com/article/18/8/diffs-patches 作者:[Phil Estes][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[David Chen](https://github.com/DavidChenLiang) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From d7b3a6ab4c4675f90afcd18ffe2497e4eaeddeeb Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 12 Sep 2018 10:41:55 +0800 Subject: [PATCH 184/455] PUB: 20180827 An introduction to diffs and patches.md @DavidChenLiang https://linux.cn/article-10005-1.html --- .../20180827 An introduction to diffs and patches.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180827 An introduction to diffs and patches.md (100%) diff --git a/translated/tech/20180827 An introduction to diffs and patches.md b/published/20180827 An introduction to diffs and patches.md similarity index 100% rename from translated/tech/20180827 An introduction to diffs and patches.md rename to published/20180827 An introduction to diffs and patches.md From 2aa4c4adbf49d7f59d9c2dd68d4b513d9bdc0884 Mon Sep 17 00:00:00 2001 From: songshunqiang Date: Wed, 12 Sep 2018 12:21:22 +0800 Subject: [PATCH 185/455] submit tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md --- ...ams and scripts easily with PySimpleGUI.md | 327 ----------------- ...ams and scripts easily with PySimpleGUI.md | 346 ++++++++++++++++++ 2 files changed, 346 insertions(+), 327 deletions(-) delete mode 100644 sources/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md create mode 100644 translated/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md diff --git a/sources/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md b/sources/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md deleted file mode 100644 index 1274e3574b..0000000000 --- a/sources/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md +++ /dev/null @@ -1,327 +0,0 @@ -pinewall translating - -Add GUIs to your programs and scripts easily with PySimpleGUI -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh) - -Few people run Python programs by double-clicking the .py file as if it were a .exe file. When a typical user (non-programmer types) double-clicks an .exe file, they expect it to pop open with a window they can interact with. While GUIs, using tkinter, are possible using standard Python installations, it's unlikely many programs do this. - -What if it were so easy to open a Python program into a GUI that complete beginners could do it? Would anyone care? Would anyone use it? It's difficult to answer because to date it's not been easy to build a custom GUI. - -There seems to be a gap in the ability to add a GUI onto a Python program/script. Complete beginners are left using only the command line and many advanced programmers don't want to take the time required to code up a tkinter GUI. - -### GUI frameworks - -There is no shortage of GUI frameworks for Python. Tkinter, WxPython, Qt, and Kivy are a few of the major packages. In addition, there are a good number of dumbed-down GUI packages that "wrap" one of the major packages, including EasyGUI, PyGUI, and Pyforms. - -The problem is that beginners (those with less than six weeks of experience) can't learn even the simplest of the major packages. That leaves the wrapper packages as a potential option, but it will still be difficult or impossible for most new users to build a custom GUI layout. Even if it's possible, the wrappers still require pages of code. - -[PySimpleGUI][1] attempts to address these GUI challenges by providing a super-simple, easy-to-understand interface to GUIs that can be easily customized. Even many complex GUIs require less than 20 lines of code when PySimpleGUI is used. - -### The secret - -What makes PySimpleGUI superior for newcomers is that the package contains the majority of the code that the user is normally expected to write. Button callbacks are handled by PySimpleGUI, not the user's code. Beginners struggle to grasp the concept of a function, and expecting them to understand a call-back function in the first few weeks is a stretch. - -With most GUIs, arranging GUI widgets often requires several lines of code… at least one or two lines per widget. PySimpleGUI uses an "auto-packer" that automatically creates the layout. No pack or grid system is needed to lay out a GUI window. - -Finally, PySimpleGUI leverages the Python language constructs in clever ways that shorten the amount of code and return the GUI data in a straightforward manner. When a widget is created in a form layout, it is configured in place, not several lines of code away. - -### What is a GUI? - -Most GUIs do one thing: collect information from the user and return it. From a programmer's viewpoint, this could be summed up as a function call that looks like this: -``` -button, values = GUI_Display(gui_layout) - -``` - -What's expected from most GUIs is the button that was clicked (e.g., OK, cancel, save, yes, no, etc.) and the values input by the user. The essence of a GUI can be boiled down to a single line of code. - -This is exactly how PySimpleGUI works (for simple GUIs). When the call is made to display the GUI, nothing executes until a button is clicked that closes the form. - -There are more complex GUIs, such as those that don't close after a button is clicked. Examples include a remote control interface for a robot and a chat window. These complex forms can also be created with PySimpleGUI. - -### Making a quick GUI - -When is PySimpleGUI useful? Immediately, whenever you need a GUI. It takes less than five minutes to create and try a GUI. The quickest way to make a GUI is to copy one from the [PySimpleGUI Cookbook][2]. Follow these steps: - - * Find a GUI that looks similar to what you want to create - * Copy code from the Cookbook - * Paste it into your IDE and run it - - - -Let's look at the first recipe from the book. -``` -import PySimpleGUI as sg - -# Very basic form.  Return values as a list -form = sg.FlexForm('Simple data entry form')  # begin with a blank form - -layout = [ -          [sg.Text('Please enter your Name, Address, Phone')], -          [sg.Text('Name', size=(15, 1)), sg.InputText('name')], -          [sg.Text('Address', size=(15, 1)), sg.InputText('address')], -          [sg.Text('Phone', size=(15, 1)), sg.InputText('phone')], -          [sg.Submit(), sg.Cancel()] -         ] - -button, values = form.LayoutAndRead(layout) - -print(button, values[0], values[1], values[2]) -``` -It's a reasonably sized form. - -![](https://opensource.com/sites/default/files/uploads/pysimplegui_cookbook-form.jpg) - -If you just need to collect a few values and they're all basically strings, you could copy this recipe and modify it to suit your needs. - -You can even create a custom GUI layout in just five lines of code. -``` -import PySimpleGUI as sg - -form = sg.FlexForm('My first GUI') - -layout = [ [sg.Text('Enter your name'), sg.InputText()], -           [sg.OK()] ] - -button, (name,) = form.LayoutAndRead(layout) -``` - -![](https://opensource.com/sites/default/files/uploads/pysimplegui-5-line-form.jpg) - -### Making a custom GUI in five minutes - -If you have a straightforward layout, you should be able create a custom layout in PySimpleGUI in less than five minutes by modifying code from the Cookbook. - -Widgets are called elements in PySimpleGUI. These elements are spelled exactly as you would type them into your Python code. - -#### Core elements -``` -Text -InputText -Multiline -InputCombo -Listbox -Radio -Checkbox -Spin -Output -SimpleButton -RealtimeButton -ReadFormButton -ProgressBar -Image -Slider -Column -``` - -#### Shortcut list - -PySimpleGUI also has two types of element shortcuts. One type is simply other names for the exact same element (e.g., `T` instead of `Text`). The second type configures an element with a particular setting, sparing you from specifying all parameters (e.g., `Submit` is a button with the text "Submit" on it) -``` -T = Text -Txt = Text -In = InputText -Input = IntputText -Combo = InputCombo -DropDown = InputCombo -Drop = InputCombo -``` - -#### Button shortcuts - -A number of common buttons have been implemented as shortcuts. These include: -``` -FolderBrowse -FileBrowse -FileSaveAs -Save -Submit -OK -Ok -Cancel -Quit -Exit -Yes -No -``` - -There are also shortcuts for more generic button functions. -``` -SimpleButton -ReadFormButton -RealtimeButton -``` - -These are all the GUI widgets you can choose from in PySimpleGUI. If one isn't on these lists, it doesn't go in your form layout. - -#### GUI design pattern - -The stuff that tends not to change in GUIs are the calls that set up and show a window. The layout of the elements is what changes from one program to another. - -Here is the code from the example above with the layout removed: -``` -import PySimpleGUI as sg - -form = sg.FlexForm('Simple data entry form') -# Define your form here (it's a list of lists) -button, values = form.LayoutAndRead(layout) -``` - -The flow for most GUIs is: - - * Create the form object - * Define the GUI as a list of lists - * Show the GUI and get results - - - -These are line-for-line what you see in PySimpleGUI's design pattern. - -#### GUI layout - -To create your custom GUI, first break your form down into rows, because forms are defined one row at a time. Then place one element after another, working from left to right. - -The result is a "list of lists" that looks something like this: -``` -layout = [  [Text('Row 1')], -            [Text('Row 2'), Checkbox('Checkbox 1', OK()), Checkbox('Checkbox 2'), OK()] ] - -``` - -This layout produces this window: - -![](https://opensource.com/sites/default/files/uploads/pysimplegui-custom-form.jpg) - -### Displaying the GUI - -Once you have your layout complete and you've copied the lines of code that set up and show the form, it's time to display the form and get values from the user. - -This is the line of code that displays the form and provides the results: -``` -button, values = form.LayoutAndRead(layout) -``` - -Forms return two values: the text of the button that is clicked and a list of values the user enters into the form. - -If the example form is displayed and the user does nothing other than clicking the OK button, the results would be: -``` -button == 'OK' -values == [False, False] -``` - -Checkbox elements return a value of True or False. Because the checkboxes defaulted to unchecked, both the values returned were False. - -### Displaying results - -Once you have the values from the GUI, it's nice to check what values are in the variables. Rather than printing them out using a `print` statement, let's stick with the GUI idea and output the data to a window. - -PySimpleGUI has a number of message boxes to choose from. The data passed to the message box is displayed in a window. The function takes any number of arguments. You can simply indicate all the variables you want to see in the call. - -The most commonly used message box in PySimpleGUI is MsgBox. To display the results from the previous example, write: -``` -MsgBox('The GUI returned:', button, values) -``` - -### Putting it all together - -Now that you know the basics, let's put together a form that contains as many of PySimpleGUI's elements as possible. Also, to give it a nice appearance, we'll change the "look and feel" to a green and tan color scheme. -``` -import PySimpleGUI as sg - -sg.ChangeLookAndFeel('GreenTan') - -form = sg.FlexForm('Everything bagel', default_element_size=(40, 1)) - -column1 = [[sg.Text('Column 1', background_color='#d3dfda', justification='center', size=(10,1))], -           [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')], -           [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 2')], -           [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')]] -layout = [ -    [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], -    [sg.Text('Here is some text.... and a place to enter text')], -    [sg.InputText('This is my text')], -    [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], -    [sg.Radio('My first Radio!     ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], -    [sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(35, 3)), -     sg.Multiline(default_text='A second multi-line', size=(35, 3))], -    [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), -     sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)], -    [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)), -     sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), -     sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), -     sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), -     sg.Column(column1, background_color='#d3dfda')], -    [sg.Text('_'  * 80)], -    [sg.Text('Choose A Folder', size=(35, 1))], -    [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), -     sg.InputText('Default Folder'), sg.FolderBrowse()], -    [sg.Submit(), sg.Cancel()] -     ] - -button, values = form.LayoutAndRead(layout) -sg.MsgBox(button, values) -``` - -This may seem like a lot of code, but try coding this same GUI layout directly in tkinter and you'll quickly realize how tiny it is. - -![](https://opensource.com/sites/default/files/uploads/pysimplegui-everything.jpg) - -The last line of code opens a message box. This is how it looks: - -![](https://opensource.com/sites/default/files/uploads/pysimplegui-message-box.jpg) - -Each parameter to the message box call is displayed on a new line. There are two lines of text in the message box; the second line is very long and wrapped a number of times - -Take a moment and pair up the results values with the GUI to get an understanding of how results are created and returned. - -### Adding a GUI to Your Program or Script - -If you have a script that uses the command line, you don't have to abandon it in order to add a GUI. An easy solution is that if there are zero parameters given on the command line, then the GUI is run. Otherwise, execute the command line as you do today. - -This kind of logic is all that's needed: -``` -if len(sys.argv) == 1: -        # collect arguments from GUI -else: -    # collect arguements from sys.argv -``` - -The easiest way to get a GUI up and running quickly is to copy and modify one of the recipes from the [PySimpleGUI Cookbook][2]. - -Have some fun! Spice up the scripts you're tired of running by hand. Spend 5 or 10 minutes playing with the demo scripts. You may find one already exists that does exactly what you need. If not, you will find it's simple to create your own. If you really get lost, you've only invested 10 minutes. - -### Resources - -#### Installation - -PySimpleGUI works on all systems that run tkinter, including Raspberry Pi, and it requires Python 3 -``` -pip install PySimpleGUI -``` - -#### Documentation - -+ [Manual][3] -+ [Cookbook][4] -+ [GitHub repository][5] - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/pysimplegui - -作者:[Mike Barnett][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/pysimplegui -[1]: https://github.com/MikeTheWatchGuy/PySimpleGUI -[2]: https://pysimplegui.readthedocs.io/en/latest/cookbook/ -[3]: https://pysimplegui.readthedocs.io/en/latest/cookbook/ -[4]: https://pysimplegui.readthedocs.io/en/latest/cookbook/ -[5]: https://github.com/MikeTheWatchGuy/PySimpleGUI diff --git a/translated/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md b/translated/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md new file mode 100644 index 0000000000..ce4a4c2b08 --- /dev/null +++ b/translated/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md @@ -0,0 +1,346 @@ +使用 PySimpleGUI 轻松为程序和脚本增加 GUI +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh) + +对于 `.exe` 类型的程序文件,我们可以通过双击鼠标左键打开;但对于 `.py` 类型的 Python 程序,几乎不会有人尝试同样的操作。对于一个(非程序员类型的)典型用户,他们双击打开 `.exe` 文件时预期弹出一个可以交互的窗体。基于 `Tkinter`,可以通过标准 Python 安装standard Python installations的方式提供 GUI,但很多程序都不太可能这样做。 + +如果打开 Python 程序并进入 GUI 界面变得如此容易,以至于真正的初学者也可以掌握,会怎样呢?会有人感兴趣并使用吗?这个问题不好回答,因为直到今天创建自定义 GUI 布局仍不是件容易的事情。 + +在为程序或脚本增加 GUI 这件事上,似乎存在能力的“错配”。(缺乏这方面能力的)真正的初学者被迫只能使用命令行方式,而很多(具备这方面能力的)高级程序员却不愿意花时间创建一个 `Tkinter` GUI。 + +### GUI 框架 + +Python 的 GUI 框架并不少,其中 `Tkinter`,`wxPython`,`Qt` 和 `Kivy` 是几种比较主流的框架。此外,还有不少在上述框架基础上封装的简化框架,例如 `EasyGUI`,`PyGUI` 和 `Pyforms` 等。 + +但问题在于,对于初学者(这里是指编程经验不超过 6 个月的用户)而言,即使是最简单的主流框架,他们也无从下手;他们也可以选择封装过的(简化)框架,但仍难以甚至无法创建自定义 GUI 布局layout。即便学会了某种(简化)框架,也需要编写连篇累牍的代码。 + +[`PySimpleGUI`][1] 尝试解决上述 GUI 难题,它提供了一种简单明了、易于理解、方便自定义的 GUI 接口。如果使用 `PySimpleGUI`,很多复杂的 GUI 也仅需不到 20 行代码。 + +### 秘诀 + +`PySimpleGUI` 极为适合初学者的秘诀在于,它已经包含了绝大多数原本需要用户编写的代码。`PySimpleGUI` 处理按钮回调callback,无需用户编写代码。对于初学者,在几周内掌握函数的概念已经不容易了,要求其理解回调函数似乎有些强人所难。 + +在大部分 GUI 框架中,布局 GUI 小部件widgets通常需要写一些代码,每个小部件至少 1-2 行。`PySimpleGUI` 使用了“auto-packer”技术,可以自动创建布局。因而,布局 GUI 窗口不再需要 `pack` 或 `grid` 系统。 + +(LCTT 译注:这里提到的 `pack` 和 `grid` 都是 `Tkinter` 的布局管理器,另外一种叫做 `place`) + +最后,`PySimpleGUI` 框架编写中有效利用 Python 语言特性,降低用户代码量并简化GUI 数据返回的方式。在窗体form布局中创建小部件时,小部件会被部署到对应的布局中,无需额外的代码。 + +### GUI 是什么? + +绝大多数 GUI 只完成一件事情:收集用户数据并返回。在程序员看来,可以归纳为如下的函数调用: + +``` +button, values = GUI_Display(gui_layout) +``` + +绝大多数 GUI 支持的用户行为包括鼠标点击(例如,“确认”,“取消”,“保存”,“是”和“否”等)和内容输入。GUI 本质上可以归结为一行代码。 + +这也正是 `PySimpleGUI` (简单 GUI 模式)的工作原理。当执行命令显示 GUI 后,除非点击鼠标关闭窗体,否则不会执行任何代码。 + +当然还有更复杂的 GUI,其中鼠标点击后窗口并不关闭;例如,机器人的远程控制界面,聊天窗口等。这类复杂的窗体也可以用 `PySimpleGUI` 创建。 + +### 快速创建 GUI + +`PySimpleGUI` 什么时候有用呢?显然,是你需要 GUI 的时候。仅需不超过 5 分钟,就可以让你创建并尝试 GUI。最便捷的 GUI 创建方式就是从 [PySimpleGUI 经典实例][2]中拷贝一份代码。具体操作流程如下: + +* 找到一个与你需求最接近的 GUI +* 从经典实例中拷贝代码 +* 粘贴到 IDE 中并运行 + +下面我们看一下书中的第一个经典实例recipe: + +``` +import PySimpleGUI as sg + +# Very basic form.  Return values as a list +form = sg.FlexForm('Simple data entry form')  # begin with a blank form + +layout = [ +          [sg.Text('Please enter your Name, Address, Phone')], +          [sg.Text('Name', size=(15, 1)), sg.InputText('name')], +          [sg.Text('Address', size=(15, 1)), sg.InputText('address')], +          [sg.Text('Phone', size=(15, 1)), sg.InputText('phone')], +          [sg.Submit(), sg.Cancel()] +         ] + +button, values = form.LayoutAndRead(layout) + +print(button, values[0], values[1], values[2]) +``` + +运行后会打开一个大小适中的窗体。 + +![](https://opensource.com/sites/default/files/uploads/pysimplegui_cookbook-form.jpg) + +如果你只是想收集一些字符串类型的值,拷贝上述经典实例中的代码,稍作修改即可满足你的需求。 + +你甚至可以只用 5 行代码创建一个自定义 GUI 布局。 + +``` +import PySimpleGUI as sg + +form = sg.FlexForm('My first GUI') + +layout = [ [sg.Text('Enter your name'), sg.InputText()], +           [sg.OK()] ] + +button, (name,) = form.LayoutAndRead(layout) +``` + +![](https://opensource.com/sites/default/files/uploads/pysimplegui-5-line-form.jpg) + +### 5 分钟内创建一个自定义 GUI + +在简单布局的基础上,通过修改经典实例中的代码,5 分钟内即可使用 `PySimpleGUI` 创建自定义布局。 + +在 `PySimpleGUI` 中,小部件widgets被称为元素elements。元素的名称与编码中使用的名称保持一致。 + +(LCTT 译注:`Tkinter` 中使用小部件这个词) + +#### 核心元素 +``` +Text +InputText +Multiline +InputCombo +Listbox +Radio +Checkbox +Spin +Output +SimpleButton +RealtimeButton +ReadFormButton +ProgressBar +Image +Slider +Column +``` + +#### 元素简写 + +`PySimpleGUI` 还包含两种元素简写方式。一种是元素类型名称简写,例如 `T` 用作 `Text` 的简写;另一种是元素参数被配置了默认值,你可以无需指定所有参数,例如 `Submit` 按钮默认的文本就是“Submit”。 + +``` +T = Text +Txt = Text +In = InputText +Input = IntputText +Combo = InputCombo +DropDown = InputCombo +Drop = InputCombo +``` + +(LCTT 译注:第一种简写就是 Python 类的别名,第二种简写是在返回元素对象的 Python 函数定义时指定了参数的默认值) + +#### 按钮简写 + +一些通用按钮具有简写实现,包括: + +``` +FolderBrowse +FileBrowse +FileSaveAs +Save +Submit +OK +Ok (LCTT 译注:这里 `k` 是小写) +Cancel +Quit +Exit +Yes +No +``` + +此外,还有通用按钮功能对应的简写: + +``` +SimpleButton +ReadFormButton +RealtimeButton +``` + +(LCTT 译注:其实就是返回 `Button` 类实例的函数) + +上面就是 `PySimpleGUI` 支持的全部元素。如果不在上述列表之中,就不会在你的窗口布局中生效。 + +(LCTT 译注:上述都是 `PySimpleGUI` 的类名、类别名或返回实例的函数,自然只能使用列表内的。) + +#### GUI 设计模式 + +对于 GUI 程序,创建并展示窗口的调用大同小异,差异在于元素的布局。 + +设计模式代码与上面的例子基本一致,只是移除了布局: + +``` +import PySimpleGUI as sg + +form = sg.FlexForm('Simple data entry form') +# Define your form here (it's a list of lists) +button, values = form.LayoutAndRead(layout) +``` + +(LCTT 译注:这段代码无法运行,只是为了说明每个程序都会用到的设计模式) + +对于绝大多数 GUI,编码流程如下: + +* 创建窗体对象 +* 以“列表的列表”的形式定义 GUI +* 展示 GUI 并获取元素的值 + +上述流程与 `PySimpleGUI` 设计模式部分的代码一一对应。 + +#### GUI 布局 + +要创建自定义 GUI,首先要将窗体分割成多个行,因为窗体是一行一行定义的。然后,在每一行中从左到右依次放置元素。 + +我们得到的就是一个“列表的列表”,类似如下: + +``` +layout = [  [Text('Row 1')], +            [Text('Row 2'), Checkbox('Checkbox 1', OK()), Checkbox('Checkbox 2'), OK()] ] + +``` + +上述布局对应的效果如下: + +![](https://opensource.com/sites/default/files/uploads/pysimplegui-custom-form.jpg) + +### 展示 GUI + +当你完成布局、拷贝完用于创建和展示窗体的代码后,下一步就是展示窗体并收集用户数据。 + +下面这行代码用于展示窗体并返回收集的数据: + +``` +button, values = form.LayoutAndRead(layout) +``` + +窗体返回的结果由两部分组成:一部分是被点击按钮的名称,另一部分是一个列表,包含所有用户输入窗体的值。 + +在这个例子中,窗体显示后用户直接点击 `OK` 按钮,返回的结果如下: + +``` +button == 'OK' +values == [False, False] +``` + +`Checkbox` 类型元素返回 `True` 或 `False` 类型的值。由于默认处于未选中状态,两个元素的值都是 `False`。 + +### 显示元素的值 + +一旦从 GUI 获取返回值,检查返回变量中的值是个不错的想法。与其使用 `print` 语句进行打印,我们不妨坚持使用 GUI 并在一个窗口中输出这些值。 + +(LCTT 译注:考虑使用的是 Python 3 版本,`print` 应该是函数而不是语句) + +在 `PySimpleGUI` 中,有多种消息框可供选取。传递给消息框(函数)的数据会被显示在消息框中;函数可以接受任意数目的参数,你可以轻松的将所有要查看的变量展示出来。 + +在 `PySimpleGUI` 中,最常用的消息框是 `MsgBox`。要展示上面例子中的数据,只需编写一行代码: + +``` +MsgBox('The GUI returned:', button, values) +``` + +### 整合 + +好了,你已经了解了基础知识,让我们创建一个包含尽可能多 `PySimpleGUI` 元素的窗体吧!此外,为了更好的感观效果,我们将采用绿色/棕褐色的配色方案。 + +``` +import PySimpleGUI as sg + +sg.ChangeLookAndFeel('GreenTan') + +form = sg.FlexForm('Everything bagel', default_element_size=(40, 1)) + +column1 = [[sg.Text('Column 1', background_color='#d3dfda', justification='center', size=(10,1))], +           [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 1')], +           [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 2')], +           [sg.Spin(values=('Spin Box 1', '2', '3'), initial_value='Spin Box 3')]] +layout = [ +    [sg.Text('All graphic widgets in one form!', size=(30, 1), font=("Helvetica", 25))], +    [sg.Text('Here is some text.... and a place to enter text')], +    [sg.InputText('This is my text')], +    [sg.Checkbox('My first checkbox!'), sg.Checkbox('My second checkbox!', default=True)], +    [sg.Radio('My first Radio!     ', "RADIO1", default=True), sg.Radio('My second Radio!', "RADIO1")], +    [sg.Multiline(default_text='This is the default Text should you decide not to type anything', size=(35, 3)), +     sg.Multiline(default_text='A second multi-line', size=(35, 3))], +    [sg.InputCombo(('Combobox 1', 'Combobox 2'), size=(20, 3)), +     sg.Slider(range=(1, 100), orientation='h', size=(34, 20), default_value=85)], +    [sg.Listbox(values=('Listbox 1', 'Listbox 2', 'Listbox 3'), size=(30, 3)), +     sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=25), +     sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=75), +     sg.Slider(range=(1, 100), orientation='v', size=(5, 20), default_value=10), +     sg.Column(column1, background_color='#d3dfda')], +    [sg.Text('_'  * 80)], +    [sg.Text('Choose A Folder', size=(35, 1))], +    [sg.Text('Your Folder', size=(15, 1), auto_size_text=False, justification='right'), +     sg.InputText('Default Folder'), sg.FolderBrowse()], +    [sg.Submit(), sg.Cancel()] +     ] + +button, values = form.LayoutAndRead(layout) +sg.MsgBox(button, values) +``` + +看上面要写不少代码,但如果你试着直接使用 `Tkinter` 框架实现同样的 GUI,你很快就会发现 `PySimpleGUI` 版本的代码是多么的简洁。 + +![](https://opensource.com/sites/default/files/uploads/pysimplegui-everything.jpg) + +代码的最后一行打开了一个消息框,效果如下: + +![](https://opensource.com/sites/default/files/uploads/pysimplegui-message-box.jpg) + +消息框函数中的每一个参数的内容都会被打印到单独的行中。本例的消息框中包含两行,其中第二行非常长而且包含列表嵌套。 + +建议花一点时间将上述结果与 GUI 中的元素一一比对,这样可以更好的理解这些结果是如何产生的。 + +### 为你的程序或脚本添加 GUI + +如果你有一个命令行方式使用的脚本,添加 GUI 不一定意味着完全放弃该脚本。一种简单的方案如下:如果脚本不需要命令行参数,那么可以直接使用 GUI 调用该脚本;反之,就按原来的方式运行脚本。 + +仅需类似如下的逻辑: + +``` +if len(sys.argv) == 1: +        # collect arguments from GUI +else: +    # collect arguements from sys.argv +``` + +创建并运行 GUI 最便捷的方式就是从 [PySimpleGUI 经典实例][2]中拷贝一份代码并修改。 + +快来试试吧!给你一直疲于手动执行的脚本增加一些趣味。只需 5-10 分钟即可玩转示例脚本。你可能发现一个几乎满足你需求的经典实例;如果找不到,也很容易自己编写一个。即使你真的玩不转,也只是浪费了 5-10 分钟而已。 + +### 资源 + +#### 安装方式 + +支持 `Tkinter` 的系统就支持 `PySimpleGUI`,甚至包括树莓派Raspberry Pi,但你需要使用 Python 3。 + +``` +pip install PySimpleGUI +``` + +#### 文档 + +* [手册][3] +* [经典实例][2] +* [GitHub repository][1] + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/pysimplegui + +作者:[Mike Barnett][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[pinewall](https://github.com/pinewall) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/pysimplegui +[1]: https://github.com/MikeTheWatchGuy/PySimpleGUI +[2]: https://pysimplegui.readthedocs.io/en/latest/cookbook/ +[3]: https://pysimplegui.readthedocs.io/en/latest/ From c8adbfe31488856cdf33eda8525016578e7bd947 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 12 Sep 2018 18:40:00 +0800 Subject: [PATCH 186/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=203=20open=20source?= =?UTF-8?q?=20log=20aggregation=20tools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...910 3 open source log aggregation tools.md | 110 ++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 sources/tech/20180910 3 open source log aggregation tools.md diff --git a/sources/tech/20180910 3 open source log aggregation tools.md b/sources/tech/20180910 3 open source log aggregation tools.md new file mode 100644 index 0000000000..0f63de0e3b --- /dev/null +++ b/sources/tech/20180910 3 open source log aggregation tools.md @@ -0,0 +1,110 @@ +3 open source log aggregation tools +====== +Log aggregation systems can help with troubleshooting and other tasks. Here are three top options. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr) + +How is metrics aggregation different from log aggregation? Can’t logs include metrics? Can’t log aggregation systems do the same things as metrics aggregation systems? + +These are questions I hear often. I’ve also seen vendors pitching their log aggregation system as the solution to all observability problems. Log aggregation is a valuable tool, but it isn’t normally a good tool for time-series data. + +A couple of valuable features in a time-series metrics aggregation system are the regular interval and the storage system customized specifically for time-series data. The regular interval allows a user to derive real mathematical results consistently. If a log aggregation system is collecting metrics in a regular interval, it can potentially work the same way. However, the storage system isn’t optimized for the types of queries that are typical in a metrics aggregation system. These queries will take more resources and time to process using storage systems found in log aggregation tools. + +So, we know a log aggregation system is likely not suitable for time-series data, but what is it good for? A log aggregation system is a great place for collecting event data. These are irregular activities that are significant. An example might be access logs for a web service. These are significant because we want to know what is accessing our systems and when. Another example would be an application error condition—because it is not a normal operating condition, it might be valuable during troubleshooting. + +A handful of rules for logging: + + * DO include a timestamp + * DO format in JSON + * DON’T log insignificant events + * DO log all application errors + * MAYBE log warnings + * DO turn on logging + * DO write messages in a human-readable form + * DON’T log informational data in production + * DON’T log anything a human can’t read or react to + + + +### Cloud costs + +When investigating log aggregation tools, the cloud might seem like an attractive option. However, it can come with significant costs. Logs represent a lot of data when aggregated across hundreds or thousands of hosts and applications. The ingestion, storage, and retrieval of that data are expensive in cloud-based systems. + +As a point of reference from a real system, a collection of around 500 nodes with a few hundred apps results in 200GB of log data per day. There’s probably room for improvement in that system, but even reducing it by half will cost nearly $10,000 per month in many SaaS offerings. This often includes retention of only 30 days, which isn’t very long if you want to look at trending data year-over-year. + +This isn’t to discourage the use of these systems, as they can be very valuable—especially for smaller organizations. The purpose is to point out that there could be significant costs, and it can be discouraging when they are realized. The rest of this article will focus on open source and commercial solutions that are self-hosted. + +### Tool options + +#### ELK + +[ELK][1], short for Elasticsearch, Logstash, and Kibana, is the most popular open source log aggregation tool on the market. It’s used by Netflix, Facebook, Microsoft, LinkedIn, and Cisco. The three components are all developed and maintained by [Elastic][2]. [Elasticsearch][3] is essentially a NoSQL, Lucene search engine implementation. [Logstash][4] is a log pipeline system that can ingest data, transform it, and load it into a store like Elasticsearch. [Kibana][5] is a visualization layer on top of Elasticsearch. + +A few years ago, Beats were introduced. Beats are data collectors. They simplify the process of shipping data to Logstash. Instead of needing to understand the proper syntax of each type of log, a user can install a Beat that will export NGINX logs or Envoy proxy logs properly so they can be used effectively within Elasticsearch. + +When installing a production-level ELK stack, a few other pieces might be included, like [Kafka][6], [Redis][7], and [NGINX][8]. Also, it is common to replace Logstash with Fluentd, which we’ll discuss later. This system can be complex to operate, which in its early days led to a lot of problems and complaints. These have largely been fixed, but it’s still a complex system, so you might not want to try it if you’re a smaller operation. + +That said, there are services available so you don’t have to worry about that. [Logz.io][9] will run it for you, but its list pricing is a little steep if you have a lot of data. Of course, you’re probably smaller and may not have a lot of data. If you can’t afford Logz.io, you could look at something like [AWS Elasticsearch Service][10] (ES). ES is a service Amazon Web Services (AWS) offers that makes it very easy to get Elasticsearch working quickly. It also has tooling to get all AWS logs into ES using Lambda and S3. This is a much cheaper option, but there is some management required and there are a few limitations. + +Elastic, the parent company of the stack, [offers][11] a more robust product that uses the open core model, which provides additional options around analytics tools, and reporting. It can also be hosted on Google Cloud Platform or AWS. This might be the best option, as this combination of tools and hosting platforms offers a cheaper solution than most SaaS options and still provides a lot of value. This system could effectively replace or give you the capability of a [security information and event management][12] (SIEM) system. + +The ELK stack also offers great visualization tools through Kibana, but it lacks an alerting function. Elastic provides alerting functionality within the paid X-Pack add-on, but there is nothing built in for the open source system. Yelp has created a solution to this problem, called [ElastAlert][13], and there are probably others. This additional piece of software is fairly robust, but it increases the complexity of an already complex system. + +#### Graylog + +[Graylog][14] has recently risen in popularity, but it got its start when Lennart Koopmann created it back in 2010. A company was born with the same name two years later. Despite its increasing use, it still lags far behind the ELK stack. This also means it has fewer community-developed features, but it can use the same Beats that the ELK stack uses. Graylog has gained praise in the Go community with the introduction of the Graylog Collector Sidecar written in [Go][15]. + +Graylog uses Elasticsearch, [MongoDB][16], and the Graylog Server under the hood. This makes it as complex to run as the ELK stack and maybe a little more. However, Graylog comes with alerting built into the open source version, as well as several other notable features like streaming, message rewriting, and geolocation. + +The streaming feature allows for data to be routed to specific Streams in real time while they are being processed. With this feature, a user can see all database errors in a single Stream and web server errors in a different Stream. Alerts can even be based on these Streams as new items are added or when a threshold is exceeded. Latency is probably one of the biggest issues with log aggregation systems, and Streams eliminate that issue in Graylog. As soon as the log comes in, it can be routed to other systems through a Stream without being processed fully. + +The message rewriting feature uses the open source rules engine [Drools][17]. This allows all incoming messages to be evaluated against a user-defined rules file enabling a message to be dropped (called Blacklisting), a field to be added or removed, or the message to be modified. + +The coolest feature might be Graylog’s geolocation capability, which supports plotting IP addresses on a map. This is a fairly common feature and is available in Kibana as well, but it adds a lot of value—especially if you want to use this as your SIEM system. The geolocation functionality is provided in the open source version of the system. + +Graylog, the company, charges for support on the open source version if you want it. It also offers an open core model for its Enterprise version that offers archiving, audit logging, and additional support. There aren’t many other options for support or hosting, so you’ll likely be on your own if you don’t use Graylog (the company). + +#### Fluentd + +[Fluentd][18] was developed at [Treasure Data][19], and the [CNCF][20] has adopted it as an Incubating project. It was written in C and Ruby and is recommended by [AWS][21] and [Google Cloud][22]. Fluentd has become a common replacement for Logstash in many installations. It acts as a local aggregator to collect all node logs and send them off to central storage systems. It is not a log aggregation system. + +It uses a robust plugin system to provide quick and easy integrations with different data sources and data outputs. Since there are over 500 plugins available, most of your use cases should be covered. If they aren’t, this sounds like an opportunity to contribute back to the open source community. + +Fluentd is a common choice in Kubernetes environments due to its low memory requirements (just tens of megabytes) and its high throughput. In an environment like [Kubernetes][23], where each pod has a Fluentd sidecar, memory consumption will increase linearly with each new pod created. Using Fluentd will drastically reduce your system utilization. This is becoming a common problem with tools developed in Java that are intended to run one per node where the memory overhead hasn’t been a major issue. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/open-source-log-aggregation-tools + +作者:[Dan Barker][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/barkerd427 +[1]: https://www.elastic.co/webinars/introduction-elk-stack +[2]: https://www.elastic.co/ +[3]: https://www.elastic.co/products/elasticsearch +[4]: https://www.elastic.co/products/logstash +[5]: https://www.elastic.co/products/kibana +[6]: http://kafka.apache.org/ +[7]: https://redis.io/ +[8]: https://www.nginx.com/ +[9]: https://logz.io/ +[10]: https://aws.amazon.com/elasticsearch-service/ +[11]: https://www.elastic.co/cloud +[12]: https://en.wikipedia.org/wiki/Security_information_and_event_management +[13]: https://github.com/Yelp/elastalert +[14]: https://www.graylog.org/ +[15]: https://opensource.com/tags/go +[16]: https://www.mongodb.com/ +[17]: https://www.drools.org/ +[18]: https://www.fluentd.org/ +[19]: https://www.treasuredata.com/ +[20]: https://www.cncf.io/ +[21]: https://aws.amazon.com/blogs/aws/all-your-data-fluentd/ +[22]: https://cloud.google.com/logging/docs/agent/ +[23]: https://opensource.com/resources/what-is-kubernetes From 3bb282510b1d172085e2c1ea3c74ee87a76adb35 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 12 Sep 2018 18:52:41 +0800 Subject: [PATCH 187/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Visualize=20Disk?= =?UTF-8?q?=20Usage=20On=20Your=20Linux=20System?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...sualize Disk Usage On Your Linux System.md | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 sources/tech/20180911 Visualize Disk Usage On Your Linux System.md diff --git a/sources/tech/20180911 Visualize Disk Usage On Your Linux System.md b/sources/tech/20180911 Visualize Disk Usage On Your Linux System.md new file mode 100644 index 0000000000..8b39f156a6 --- /dev/null +++ b/sources/tech/20180911 Visualize Disk Usage On Your Linux System.md @@ -0,0 +1,103 @@ +Visualize Disk Usage On Your Linux System +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-720x340.png) + +Finding disk space usage is no big deal in Unix-like operating systems. We have a built-in command named [**du**][1] that can be used to calculate and summarize the disk space usage in minutes. And, we have some third-party tools like [**Ncdu**][2] and [**Agedu**][3] which can also be used to track down the disk usage. As you already know, these are all command line utilities and you will see the disk usage results in plain-text format. However, some of you’d like to view the results in visual or kind of image format. No worries! I know one such GUI tool to find out the disk usage details. Say hello to **“Filelight”** , a graphical utility to visualize disk usage on your Linux system and displays the disk usage results in a colored radial layout. Filelight is one of the oldest project and it has been around for a long time. It is completely free to use and open source. + +### Installing Filelight + +Filelight is part of KDE applications and comes pre-installed with KDE-based Linux distributions. + +If you’re using non-KDE distros, Filelight is available in the official repositories, so you can install it using the default package manager. + +On Arch Linux and its variants such as Antergos, Manjaro Linux, Filelight can be installed as below. + +``` +$ sudo pacman -S filelight +``` + +On Debian, Ubuntu, Linux Mint: + +``` +$ sudo apt install filelight +``` + +On Fedora: + +``` +$ sudo dnf install filelight +``` + +On openSUSE: + +``` +$ sudo zypper install filelight +``` + +### Visualize Disk Usage On Your Linux System + +Once installed, launch Filelight from Menu or application launcher. + +FIlelight graphically represents your filesystem as a set of concentric segmented-rings. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-1-1.png) + +As you can see, Filelight displays the disk usage of the **/** and **/boot** filesystems by default. + +You can also scan the individual folders of your choice to view the disk usage of that particular folder. To do so, go to **Filelight - > Scan -> Scan Folder** and choose the folder you want to scan. + +Filelight excludes the following directories from scanning: + + * /dev + * /proc + * /sys + * /root + + + +This option is helpful to skip the directories that you may not have permissions to read, or folders that are part of a virtual filesystem, such as /proc. + +If you want to add any folder in this list, go to **Filelight - > Settings -> Scanning** and click “add” button and choose the folder you want to add in this list. + +![](http://www.ostechnix.com/wp-content/uploads/2018/09/filelight-settings.png) + +Similarly, to remove a folder from the list, choose the folder and click on “Remove”. + +If you want to change the way filelight looks, go to **Settings - > Appearance** tab and change the color scheme as per your liking. + +Each segment in the radial layout is represented with different colors. The following image represents the entire radial layout of **/** filesystem. To view the full information of files and folders, just hover the mouse pointer over them. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-2.png) + +You can navigate around the the filesystem by simply clicking on the respective segment. To view the disk usage of any file or folder, just click on them and you will get the complete disk usage details of that particular folder/file. + +Not just local filesystem, Filelight can able to scan your local, remote and removable disks. If you’re using any KDE-based Linux distribution, it can be integrated into file managers like Konqueror, Dolphin and Krusader. + +Unlike the CLI utilities, you don’t have to use any extra arguments or options to view the results in human-readable format. Filelight will display the disk usage in human-readable format by default. + +### Conclusion + +By using Filelight, you can quickly discover where exactly your diskspace is being used in your filesystem and free up the space wherever necessary by deleting the unwanted files or folders. If you are looking for some simple and user-learnedly graphical disk usage viewer, Filelight is worth trying. + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/filelight-visualize-disk-usage-on-your-linux-system/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://www.ostechnix.com/find-size-directory-linux/ +[2]: https://www.ostechnix.com/check-disk-space-usage-linux-using-ncdu/ +[3]: https://www.ostechnix.com/agedu-find-out-wasted-disk-space-in-linux/ From ce26c190919b35ff98eef17049ab36b230111646 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 12 Sep 2018 18:59:27 +0800 Subject: [PATCH 188/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20List?= =?UTF-8?q?=20An=20Available=20Package=20Groups=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...st An Available Package Groups In Linux.md | 644 ++++++++++++++++++ 1 file changed, 644 insertions(+) create mode 100644 sources/tech/20180910 How To List An Available Package Groups In Linux.md diff --git a/sources/tech/20180910 How To List An Available Package Groups In Linux.md b/sources/tech/20180910 How To List An Available Package Groups In Linux.md new file mode 100644 index 0000000000..754c2d0c3a --- /dev/null +++ b/sources/tech/20180910 How To List An Available Package Groups In Linux.md @@ -0,0 +1,644 @@ +How To List An Available Package Groups In Linux +====== +As we know, if we want to install any packages in Linux we need to use the distribution package manager to get it done. + +Package manager is playing major role in Linux as this used most of the time by admin. + +If you would like to install group of package in one shot what would be the possible option. + +Is it possible in Linux? if so, what would be the command for it. + +Yes, this can be done in Linux by using the package manager. Each package manager has their own option to perform this task, as i know apt or apt-get package manager doesn’t has this option. + +For Debian based system we need to use tasksel command instead of official package managers called apt or apt-get. + +What is the benefit if we install group of package in Linux? Yes, there is lot of benefit is available in Linux when we install group of package because if you want to install LAMP separately we need to include so many packages but that can be done using single package when we use group of package command. + +Say for example, as you get a request from Application team to install LAMP but you don’t know what are the packages needs to be installed, this is where group of package comes into picture. + +Group option is a handy tool for Linux systems which will install Group of Software in a single click on your system without headache. + +A package group is a collection of packages that serve a common purpose, for instance System Tools or Sound and Video. Installing a package group pulls a set of dependent packages, saving time considerably. + +**Suggested Read :** +**(#)** [How To List Installed Packages By Size (Largest) On Linux][1] +**(#)** [How To View/List The Available Packages Updates In Linux][2] +**(#)** [How To View A Particular Package Installed/Updated/Upgraded/Removed/Erased Date On Linux][3] +**(#)** [How To View Detailed Information About A Package In Linux][4] +**(#)** [How To Search If A Package Is Available On Your Linux Distribution Or Not][5] +**(#)** [Newbies corner – A Graphical frontend tool for Linux Package Manager][6] +**(#)** [Linux Expert should knows, list of Command line Package Manager & Usage][7] + +### How To List An Available Package Groups In CentOS/RHEL Systems + +RHEL & CentOS systems are using RPM packages hence we can use the `Yum Package Manager` to get this information. + +YUM stands for Yellowdog Updater, Modified is an open-source command-line front-end package-management utility for RPM based systems such as Red Hat Enterprise Linux (RHEL) and CentOS. + +Yum is the primary tool for getting, installing, deleting, querying, and managing RPM packages from distribution repositories, as well as other third-party repositories. + +**Suggested Read :** [YUM Command To Manage Packages on RHEL/CentOS Systems][8] + +``` +# yum grouplist +Loaded plugins: fastestmirror, security +Setting up Group Process +Loading mirror speeds from cached hostfile + * epel: epel.mirror.constant.com +Installed Groups: + Base + E-mail server + Graphical Administration Tools + Hardware monitoring utilities + Legacy UNIX compatibility + Milkymist + Networking Tools + Performance Tools + Perl Support + Security Tools +Available Groups: + Additional Development + Backup Client + Backup Server + CIFS file server + Client management tools + Compatibility libraries + Console internet tools + Debugging Tools + Desktop +. +. +Available Language Groups: + Afrikaans Support [af] + Albanian Support [sq] + Amazigh Support [ber] + Arabic Support [ar] + Armenian Support [hy] + Assamese Support [as] + Azerbaijani Support [az] +. +. +Done + +``` + +If you would like to list what are the packages is associated on it, run the below command. In this example we are going to list what are the packages is associated with “Performance Tools” group. + +``` +# yum groupinfo "Performance Tools" +Loaded plugins: fastestmirror, security +Setting up Group Process +Loading mirror speeds from cached hostfile + * epel: ewr.edge.kernel.org + +Group: Performance Tools + Description: Tools for diagnosing system and application-level performance problems. + Mandatory Packages: + blktrace + sysstat + Default Packages: + dstat + iotop + latencytop + latencytop-tui + oprofile + perf + powertop + seekwatcher + Optional Packages: + oprofile-jit + papi + sdparm + sg3_utils + tiobench + tuned + tuned-utils + +``` + +### How To List An Available Package Groups In Fedora + +Fedora system uses DNF package manager hence we can use the Dnf Package Manager to get this information. + +DNF stands for Dandified yum. We can tell DNF, the next generation of yum package manager (Fork of Yum) using hawkey/libsolv library for backend. Aleš Kozumplík started working on DNF since Fedora 18 and its implemented/launched in Fedora 22 finally. + +Dnf command is used to install, update, search & remove packages on Fedora 22 and later system. It automatically resolve dependencies and make it smooth package installation without any trouble. + +Yum replaced by DNF due to several long-term problems in Yum which was not solved. Asked why ? he did not patches the Yum issues. Aleš Kozumplík explains that patching was technically hard and YUM team wont accept the changes immediately and other major critical, YUM is 56K lines but DNF is 29K lies. So, there is no option for further development, except to fork. + +**Suggested Read :** [DNF (Fork of YUM) Command To Manage Packages on Fedora System][9] + +``` +# dnf grouplist +Last metadata expiration check: 0:00:00 ago on Sun 09 Sep 2018 07:10:36 PM IST. +Available Environment Groups: + Fedora Custom Operating System + Minimal Install + Fedora Server Edition + Fedora Workstation + Fedora Cloud Server + KDE Plasma Workspaces + Xfce Desktop + LXDE Desktop + Hawaii Desktop + LXQt Desktop + Cinnamon Desktop + MATE Desktop + Sugar Desktop Environment + Development and Creative Workstation + Web Server + Infrastructure Server + Basic Desktop +Installed Groups: + C Development Tools and Libraries + Development Tools +Available Groups: + 3D Printing + Administration Tools + Ansible node + Audio Production + Authoring and Publishing + Books and Guides + Cloud Infrastructure + Cloud Management Tools + Container Management + D Development Tools and Libraries +. +. + RPM Development Tools + Security Lab + Text-based Internet + Window Managers + GNOME Desktop Environment + Graphical Internet + KDE (K Desktop Environment) + Fonts + Games and Entertainment + Hardware Support + Sound and Video + System Tools + +``` + +If you would like to list what are the packages is associated on it, run the below command. In this example we are going to list what are the packages is associated with “Editor” group. + +``` + +# dnf groupinfo Editors +Last metadata expiration check: 0:04:57 ago on Sun 09 Sep 2018 07:10:36 PM IST. + +Group: Editors + Description: Sometimes called text editors, these are programs that allow you to create and edit text files. This includes Emacs and Vi. + Optional Packages: + code-editor + cssed + emacs + emacs-auctex + emacs-bbdb + emacs-ess + emacs-vm + geany + gobby + jed + joe + leafpad + nedit + poedit + psgml + vim-X11 + vim-enhanced + xemacs + xemacs-packages-base + xemacs-packages-extra + xemacs-xft + xmlcopyeditor + zile +``` + +### How To List An Available Package Groups In openSUSE System + +openSUSE system uses zypper package manager hence we can use the zypper Package Manager to get this information. + +Zypper is a command line package manager for suse & openSUSE distributions. It’s used to install, update, search & remove packages & manage repositories, perform various queries, and more. Zypper command-line interface to ZYpp system management library (libzypp). + +**Suggested Read :** [Zypper Command To Manage Packages On openSUSE & suse Systems][10] + +``` +# zypper patterns +Loading repository data... +Warning: Repository 'Update Repository (Non-Oss)' appears to be outdated. Consider using a different mirror or server. +Warning: Repository 'Main Update Repository' appears to be outdated. Consider using a different mirror or server. +Reading installed packages... +S | Name | Version | Repository | Dependency +---|----------------------|---------------|-----------------------|----------- + | 64bit | 20150918-25.1 | Main Repository (OSS) | + | apparmor | 20150918-25.1 | Main Repository (OSS) | +i | apparmor | 20150918-25.1 | @System | + | base | 20150918-25.1 | Main Repository (OSS) | +i+ | base | 20150918-25.1 | @System | + | books | 20150918-25.1 | Main Repository (OSS) | + | console | 20150918-25.1 | Main Repository (OSS) | + | devel_C_C++ | 20150918-25.1 | Main Repository (OSS) | +i | enhanced_base | 20150918-25.1 | @System | + | enlightenment | 20150918-25.1 | Main Repository (OSS) | + | file_server | 20150918-25.1 | Main Repository (OSS) | + | fonts | 20150918-25.1 | Main Repository (OSS) | +i | fonts | 20150918-25.1 | @System | + | games | 20150918-25.1 | Main Repository (OSS) | +i | games | 20150918-25.1 | @System | + | gnome | 20150918-25.1 | Main Repository (OSS) | + | gnome_basis | 20150918-25.1 | Main Repository (OSS) | +i | imaging | 20150918-25.1 | @System | + | kde | 20150918-25.1 | Main Repository (OSS) | +i+ | kde | 20150918-25.1 | @System | + | kde_plasma | 20150918-25.1 | Main Repository (OSS) | +i | kde_plasma | 20150918-25.1 | @System | + | lamp_server | 20150918-25.1 | Main Repository (OSS) | + | laptop | 20150918-25.1 | Main Repository (OSS) | +i+ | laptop | 20150918-25.1 | @System | + | lxde | 20150918-25.1 | Main Repository (OSS) | + | lxqt | 20150918-25.1 | Main Repository (OSS) | +i | multimedia | 20150918-25.1 | @System | + | network_admin | 20150918-25.1 | Main Repository (OSS) | + | non_oss | 20150918-25.1 | Main Repository (OSS) | +i | non_oss | 20150918-25.1 | @System | + | office | 20150918-25.1 | Main Repository (OSS) | +i | office | 20150918-25.1 | @System | + | print_server | 20150918-25.1 | Main Repository (OSS) | + | remote_desktop | 20150918-25.1 | Main Repository (OSS) | + | x11 | 20150918-25.1 | Main Repository (OSS) | +i+ | x11 | 20150918-25.1 | @System | + | x86 | 20150918-25.1 | Main Repository (OSS) | + | xen_server | 20150918-25.1 | Main Repository (OSS) | + | xfce | 20150918-25.1 | Main Repository (OSS) | + | xfce_basis | 20150918-25.1 | Main Repository (OSS) | + | yast2_basis | 20150918-25.1 | Main Repository (OSS) | +i | yast2_basis | 20150918-25.1 | @System | + | yast2_install_wf | 20150918-25.1 | Main Repository (OSS) | +``` + +If you would like to list what are the packages is associated on it, run the below command. In this example we are going to list what are the packages is associated with “file_server” group. +Additionally zypper command allows a user to perform the same action with different options. + +``` +# zypper info file_server +Loading repository data... +Warning: Repository 'Update Repository (Non-Oss)' appears to be outdated. Consider using a different mirror or server. +Warning: Repository 'Main Update Repository' appears to be outdated. Consider using a different mirror or server. +Reading installed packages... + +Information for pattern file_server: +------------------------------------ +Repository : Main Repository (OSS) +Name : file_server +Version : 20150918-25.1 +Arch : x86_64 +Vendor : openSUSE +Installed : No +Visible to User : Yes +Summary : File Server +Description : + File services to host files so that they may be accessed or retrieved by other computers on the same network. This includes the FTP, SMB, and NFS protocols. +Contents : + S | Name | Type | Dependency + ---|-------------------------------|---------|------------ + i+ | patterns-openSUSE-base | package | Required + | patterns-openSUSE-file_server | package | Required + | nfs-kernel-server | package | Recommended + i | nfsidmap | package | Recommended + i | samba | package | Recommended + i | samba-client | package | Recommended + i | samba-winbind | package | Recommended + | tftp | package | Recommended + | vsftpd | package | Recommended + | yast2-ftp-server | package | Recommended + | yast2-nfs-server | package | Recommended + i | yast2-samba-server | package | Recommended + | yast2-tftp-server | package | Recommended +``` + +If you would like to list what are the packages is associated on it, run the below command. + +``` +# zypper pattern-info file_server +Loading repository data... +Warning: Repository 'Update Repository (Non-Oss)' appears to be outdated. Consider using a different mirror or server. +Warning: Repository 'Main Update Repository' appears to be outdated. Consider using a different mirror or server. +Reading installed packages... + + +Information for pattern file_server: +------------------------------------ +Repository : Main Repository (OSS) +Name : file_server +Version : 20150918-25.1 +Arch : x86_64 +Vendor : openSUSE +Installed : No +Visible to User : Yes +Summary : File Server +Description : + File services to host files so that they may be accessed or retrieved by other computers on the same network. This includes the FTP, SMB, and NFS protocols. +Contents : + S | Name | Type | Dependency + ---|-------------------------------|---------|------------ + i+ | patterns-openSUSE-base | package | Required + | patterns-openSUSE-file_server | package | Required + | nfs-kernel-server | package | Recommended + i | nfsidmap | package | Recommended + i | samba | package | Recommended + i | samba-client | package | Recommended + i | samba-winbind | package | Recommended + | tftp | package | Recommended + | vsftpd | package | Recommended + | yast2-ftp-server | package | Recommended + | yast2-nfs-server | package | Recommended + i | yast2-samba-server | package | Recommended + | yast2-tftp-server | package | Recommended +``` + +If you would like to list what are the packages is associated on it, run the below command. + +``` +# zypper info pattern file_server +Loading repository data... +Warning: Repository 'Update Repository (Non-Oss)' appears to be outdated. Consider using a different mirror or server. +Warning: Repository 'Main Update Repository' appears to be outdated. Consider using a different mirror or server. +Reading installed packages... + +Information for pattern file_server: +------------------------------------ +Repository : Main Repository (OSS) +Name : file_server +Version : 20150918-25.1 +Arch : x86_64 +Vendor : openSUSE +Installed : No +Visible to User : Yes +Summary : File Server +Description : + File services to host files so that they may be accessed or retrieved by other computers on the same network. This includes the FTP, SMB, and NFS protocols. +Contents : + S | Name | Type | Dependency + ---|-------------------------------|---------|------------ + i+ | patterns-openSUSE-base | package | Required + | patterns-openSUSE-file_server | package | Required + | nfs-kernel-server | package | Recommended + i | nfsidmap | package | Recommended + i | samba | package | Recommended + i | samba-client | package | Recommended + i | samba-winbind | package | Recommended + | tftp | package | Recommended + | vsftpd | package | Recommended + | yast2-ftp-server | package | Recommended + | yast2-nfs-server | package | Recommended + i | yast2-samba-server | package | Recommended + | yast2-tftp-server | package | Recommended +``` + +If you would like to list what are the packages is associated on it, run the below command. + +``` +# zypper info -t pattern file_server +Loading repository data... +Warning: Repository 'Update Repository (Non-Oss)' appears to be outdated. Consider using a different mirror or server. +Warning: Repository 'Main Update Repository' appears to be outdated. Consider using a different mirror or server. +Reading installed packages... + + +Information for pattern file_server: +------------------------------------ +Repository : Main Repository (OSS) +Name : file_server +Version : 20150918-25.1 +Arch : x86_64 +Vendor : openSUSE +Installed : No +Visible to User : Yes +Summary : File Server +Description : + File services to host files so that they may be accessed or retrieved by other computers on the same network. This includes the FTP, SMB, and NFS protocols. +Contents : + S | Name | Type | Dependency + ---|-------------------------------|---------|------------ + i+ | patterns-openSUSE-base | package | Required + | patterns-openSUSE-file_server | package | Required + | nfs-kernel-server | package | Recommended + i | nfsidmap | package | Recommended + i | samba | package | Recommended + i | samba-client | package | Recommended + i | samba-winbind | package | Recommended + | tftp | package | Recommended + | vsftpd | package | Recommended + | yast2-ftp-server | package | Recommended + | yast2-nfs-server | package | Recommended + i | yast2-samba-server | package | Recommended + | yast2-tftp-server | package | Recommended +``` + +### How To List An Available Package Groups In Debian/Ubuntu Systems + +Since APT or APT-GET package manager doesn’t offer this option for Debian/Ubuntu based systems hence, we are using tasksel command to get this information. + +[Tasksel][11] is a handy tool for Debian/Ubuntu systems which will install Group of Software in a single click on your system. Tasks are defined in `.desc` files and located at `/usr/share/tasksel`. + +By default, tasksel tool installed on Debian system as part of Debian installer but it’s not installed on Ubuntu desktop editions. This functionality is similar to that of meta-packages, like how package managers have. + +Tasksel tool offer a simple user interface based on zenity (popup Graphical dialog box in command line). + +**Suggested Read :** [Tasksel – Install Group of Software in A Single Click on Debian/Ubuntu][12] + +``` +# tasksel --list-task +u kubuntu-live Kubuntu live CD +u lubuntu-live-gtk Lubuntu live CD (GTK part) +u ubuntu-budgie-live Ubuntu Budgie live CD +u ubuntu-live Ubuntu live CD +u ubuntu-mate-live Ubuntu MATE Live CD +u ubuntustudio-dvd-live Ubuntu Studio live DVD +u vanilla-gnome-live Ubuntu GNOME live CD +u xubuntu-live Xubuntu live CD +u cloud-image Ubuntu Cloud Image (instance) +u dns-server DNS server +u kubuntu-desktop Kubuntu desktop +u kubuntu-full Kubuntu full +u lamp-server LAMP server +u lubuntu-core Lubuntu minimal installation +u lubuntu-desktop Lubuntu Desktop +u lubuntu-gtk-core Lubuntu minimal installation (GTK part) +u lubuntu-gtk-desktop Lubuntu Desktop (GTK part) +u lubuntu-qt-core Lubuntu minimal installation (Qt part) +u lubuntu-qt-desktop Lubuntu Qt Desktop (Qt part) +u mail-server Mail server +u postgresql-server PostgreSQL database +i print-server Print server +u samba-server Samba file server +u tomcat-server Tomcat Java server +u ubuntu-budgie-desktop Ubuntu Budgie desktop +i ubuntu-desktop Ubuntu desktop +u ubuntu-mate-core Ubuntu MATE minimal +u ubuntu-mate-desktop Ubuntu MATE desktop +i ubuntu-usb Ubuntu desktop USB +u ubuntustudio-audio Audio recording and editing suite +u ubuntustudio-desktop Ubuntu Studio desktop +u ubuntustudio-desktop-core Ubuntu Studio minimal DE installation +u ubuntustudio-fonts Large selection of font packages +u ubuntustudio-graphics 2D/3D creation and editing suite +u ubuntustudio-photography Photograph touchup and editing suite +u ubuntustudio-publishing Publishing applications +u ubuntustudio-video Video creation and editing suite +u vanilla-gnome-desktop Vanilla GNOME desktop +u xubuntu-core Xubuntu minimal installation +u xubuntu-desktop Xubuntu desktop +u openssh-server OpenSSH server +u server Basic Ubuntu server +``` + +If you would like to list what are the packages is associated on it, run the below command. In this example we are going to list what are the packages is associated with “file_server” group. + +``` +# tasksel --task-desc "lamp-server" +Selects a ready-made Linux/Apache/MySQL/PHP server. +``` + +### How To List An Available Package Groups In Arch Linux based Systems + +Arch Linux based systems are using pacman package manager hence we can use the pacman Package Manager to get this information. + +pacman stands for package manager utility (pacman). pacman is a command-line utility to install, build, remove and manage Arch Linux packages. pacman uses libalpm (Arch Linux Package Management (ALPM) library) as a back-end to perform all the actions. + +**Suggested Read :** [Pacman Command To Manage Packages On Arch Linux Based Systems][13] + +``` +# pacman -Sg +base-devel +base +multilib-devel +gnome-extra +kde-applications +kdepim +kdeutils +kdeedu +kf5 +kdemultimedia +gnome +plasma +kdegames +kdesdk +kdebase +xfce4 +fprint +kdegraphics +kdenetwork +kdeadmin +kf5-aids +kdewebdev +. +. +dlang-ldc +libretro +ring +lxqt +non-daw +non +alsa +qtcurve +realtime +sugar-fructose +tesseract-data +vim-plugins + +``` + +If you would like to list what are the packages is associated on it, run the below command. In this example we are going to list what are the packages is associated with “gnome” group. + +``` +# pacman -Sg gnome +gnome baobab +gnome cheese +gnome eog +gnome epiphany +gnome evince +gnome file-roller +gnome gdm +gnome gedit +gnome gnome-backgrounds +gnome gnome-calculator +gnome gnome-calendar +gnome gnome-characters +gnome gnome-clocks +gnome gnome-color-manager +gnome gnome-contacts +gnome gnome-control-center +gnome gnome-dictionary +gnome gnome-disk-utility +gnome gnome-documents +gnome gnome-font-viewer +. +. +gnome sushi +gnome totem +gnome tracker +gnome tracker-miners +gnome vino +gnome xdg-user-dirs-gtk +gnome yelp +gnome gnome-boxes +gnome gnome-software +gnome simple-scan + +``` + +Alternatively we can check the same by running following command. + +``` +# pacman -S gnome +:: There are 64 members in group gnome: +:: Repository extra + 1) baobab 2) cheese 3) eog 4) epiphany 5) evince 6) file-roller 7) gdm 8) gedit 9) gnome-backgrounds 10) gnome-calculator 11) gnome-calendar 12) gnome-characters 13) gnome-clocks + 14) gnome-color-manager 15) gnome-contacts 16) gnome-control-center 17) gnome-dictionary 18) gnome-disk-utility 19) gnome-documents 20) gnome-font-viewer 21) gnome-getting-started-docs + 22) gnome-keyring 23) gnome-logs 24) gnome-maps 25) gnome-menus 26) gnome-music 27) gnome-photos 28) gnome-screenshot 29) gnome-session 30) gnome-settings-daemon 31) gnome-shell + 32) gnome-shell-extensions 33) gnome-system-monitor 34) gnome-terminal 35) gnome-themes-extra 36) gnome-todo 37) gnome-user-docs 38) gnome-user-share 39) gnome-video-effects 40) grilo-plugins + 41) gvfs 42) gvfs-afc 43) gvfs-goa 44) gvfs-google 45) gvfs-gphoto2 46) gvfs-mtp 47) gvfs-nfs 48) gvfs-smb 49) mousetweaks 50) mutter 51) nautilus 52) networkmanager 53) orca 54) rygel + 55) sushi 56) totem 57) tracker 58) tracker-miners 59) vino 60) xdg-user-dirs-gtk 61) yelp +:: Repository community + 62) gnome-boxes 63) gnome-software 64) simple-scan + +Enter a selection (default=all): ^C +Interrupt signal received + +``` + +To know exactly how many packages is associated on it, run the following command. + +``` +# pacman -Sg gnome | wc -l +64 + +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-list-an-available-package-groups-in-linux/ + +作者:[Prakash Subramanian][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/prakash/ +[1]: https://www.2daygeek.com/how-to-list-installed-packages-by-size-largest-on-linux/ +[2]: https://www.2daygeek.com/how-to-view-list-the-available-packages-updates-in-linux/ +[3]: https://www.2daygeek.com/how-to-view-a-particular-package-installed-updated-upgraded-removed-erased-date-on-linux/ +[4]: https://www.2daygeek.com/how-to-view-detailed-information-about-a-package-in-linux/ +[5]: https://www.2daygeek.com/how-to-search-if-a-package-is-available-on-your-linux-distribution-or-not/ +[6]: https://www.2daygeek.com/list-of-graphical-frontend-tool-for-linux-package-manager/ +[7]: https://www.2daygeek.com/list-of-command-line-package-manager-for-linux/ +[8]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[9]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[10]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ +[11]: https://wiki.debian.org/tasksel +[12]: https://www.2daygeek.com/tasksel-install-group-of-software-in-a-single-click-or-single-command-on-debian-ubuntu/ +[13]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ From 5b0c826155bb68bac4457044b0059bf3705ffda0 Mon Sep 17 00:00:00 2001 From: qq15 Date: Wed, 12 Sep 2018 20:26:12 +0800 Subject: [PATCH 189/455] =?UTF-8?q?GraveAccent=E5=9C=A8=E7=BF=BB=E8=AF=912?= =?UTF-8?q?0180815HowToEnable...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...erated Video Decoding In Chromium On Ubuntu Or Linux Mint.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md b/sources/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md index 563e724c0f..62482fdb1e 100644 --- a/sources/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md +++ b/sources/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md @@ -1,4 +1,4 @@ -How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint +Grave Accent翻译中 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint ====== You may have noticed that watching HD videos from Youtube and other similar websites in Google Chrome or Chromium browsers on Linux considerably increases your CPU usage and, if you use a laptop, it gets quite hot and the battery drains very quickly. That's because Chrome / Chromium (Firefox too but there's no way to force this) doesn't support hardware accelerated video decoding on Linux. From fc2131289a6f376738fcf756fe80663c7a25a620 Mon Sep 17 00:00:00 2001 From: GraveAccent Date: Wed, 12 Sep 2018 21:15:49 +0800 Subject: [PATCH 190/455] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ing In Chromium On Ubuntu Or Linux Mint.md | 113 ------------------ ...ing In Chromium On Ubuntu Or Linux Mint.md | 112 +++++++++++++++++ 2 files changed, 112 insertions(+), 113 deletions(-) delete mode 100644 sources/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md create mode 100644 translated/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md diff --git a/sources/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md b/sources/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md deleted file mode 100644 index 62482fdb1e..0000000000 --- a/sources/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md +++ /dev/null @@ -1,113 +0,0 @@ -Grave Accent翻译中 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint -====== -You may have noticed that watching HD videos from Youtube and other similar websites in Google Chrome or Chromium browsers on Linux considerably increases your CPU usage and, if you use a laptop, it gets quite hot and the battery drains very quickly. That's because Chrome / Chromium (Firefox too but there's no way to force this) doesn't support hardware accelerated video decoding on Linux. - -**This article explains how to install a Chromium development build which includes a patch that enables VA-API on Linux, bringing support for GPU accelerated video decoding, which should significantly decrease the CPU usage when watching HD videos online. The instructions cover only Intel and Nvidia graphics cards, as I don't have an ATI/AMD graphics card to try this, nor do I have experience with such graphics cards.** - -This is Chromium from the Ubuntu (18.04) repositories without GPU accelerated video decoding playing a 1080p YouTube video: - -![](https://4.bp.blogspot.com/-KtUQni2PMvE/W3KlJ62yLLI/AAAAAAAABW4/NrNVFaTAkZ8AmwqWwRvWD6czT51ni-R-gCLcBGAs/s1600/chromium-default-no-accel.png) - -The same 1080p YouTube video playing in Chromium with the VA-API patch and hardware accelerated video decode enabled on Ubuntu 18.04: - -![](https://4.bp.blogspot.com/-0c-wb4UNhW8/W3KlQBfeFnI/AAAAAAAABW8/WVUAYzM6hA8wRTlCcrPXPMpoXoFVR6b1QCLcBGAs/s1600/chromium-hardware-acceleration-enabled.png) - -Notice the CPU usage in the screenshots. Both screenshots were taken on my old, but still quite powerful desktop. On my laptop, the Chromium CPU usage without hardware acceleration goes way higher. - -The _Enable VAVDA, VAVEA and VAJDA on linux with VAAPI only_ " was was initially submitted to Chromium more than a year ago, but it has yet to be merged. - -Chrome has an option to override the software rendering list ( - -`#ignore-gpu-blacklist` - -), but this option does not enable hardware accelerated video decoding. After enabling this option, you may find the following when visiting - -`chrome://gpu` - -: " _Video Decode: Hardware accelerated_ ", but this does not mean it actually works. Open a HD video on YouTube and check the CPU usage in a tool such as - -`htop` - -(this is what I'm using in the screenshots above to check the CPU usage) - you should see high CPU usage because GPU video decoding is not actually enabled. There's also a section below for how to check if you're actually using hardware accelerated video decoding. - -**The patches used by the Chromium Ubuntu builds with VA-API enabled used in this article are available[here][1].** - -### Installing and using Chromium browser with VA-API support on Ubuntu or Linux Mint - -**It should be clear to everyone reading this that Chromium Dev Branch is not considered stable. So you might find bugs, it may crash, etc. It works fine right now but who knows what may happen after some update.** - -**What's more, the Chromium Dev Branch PPA requires you to perform some extra steps if you want to enable Widevine support** (so you can play Netflix videos and paid YouTube videos, etc.), **or if you need features like Sync** (which needs registering an API key and setting it up on your system). Instructions for performing these tweaks are explained in the - -Chromium with the VA-API patch is also available for some other Linux distributions, in third-party repositories, like - -**1\. Install Chromium Dev Branch with VA-API support.** - -There's a Chromium Beta PPA with the VA-API patch, but it lacks vdpau-video for Ubuntu 18.04. If you want, you can use the `vdpau-va-driver` from the You can add the Chromium -``` -sudo add-apt-repository ppa:saiarcot895/chromium-dev -sudo apt-get update -sudo apt install chromium-browser - -``` - -**2\. Install the VA-API driver** - -For Intel graphics cards, you'll need to install the `i965-va-driver` package (it may already be installed): -``` -sudo apt install i965-va-driver - -``` - -For Nvidia graphics cards (it should work with both the open source Nouveau drivers and the proprietary Nvidia drivers), install `vdpau-va-driver` : -``` -sudo apt install vdpau-va-driver - -``` - -**3\. Enable the Hardware-accelerated video option in Chromium.** - -Copy and paste the following in the Chrome URL bar: `chrome://flags/#enable-accelerated-video` (or search for the `Hardware-accelerated video` option in `chrome://flags`) and enable it, then restart Chromium browser. - -On a default Google Chrome / Chromium build, this option shows as unavailable, but you'll be able to enable it now because we've used the VA-API enabled Chromium build. - -**4\. Install[h264ify][2] Chrome extension.** - -YouTube (and probably some other websites as well) uses VP8 or VP9 video codecs by default, and many GPUs don't support hardware decoding for this codec. The h264ify extension will force YouTube to use H.264, which should be supported by most GPUs, instead of VP8/VP9. - -This extension can also block 60fps videos, useful on lower end machines. - -You can check the codec used by a YouTube video by right clicking on the video and selecting `Stats for nerds` . With the h264ify extension enabled, you should see avc / mp4a as the codecs. Without this extension, the codec should be something like vp09 / opus. - -### How to check if Chromium is using GPU video decoding - -Open a video on YouTube. Next, open a new tab in Chromium and enter the following in the URL bar: `chrome://media-internals` . - -On the `chrome://media-internals` tab, click on the video url (in order to expand it), scroll down and look under `Player Properties` , and you should find the `video_decoder` property. If the `video_decoder` value is `GpuVideoDecoder` it means that the video that's currently playing on YouTube in the other tab is using hardware-accelerated video decoding. - -![](https://4.bp.blogspot.com/-COBJWVT_Y0Q/W3KnG7AeHsI/AAAAAAAABXM/W2XAJA_S0BIHug4eQKTMOdIfXHhgkXhhQCLcBGAs/s1600/chromium-gpuvideodecoder-linux.png) - -If it says `FFmpegVideoDecoder` or `VpxVideoDecoder` , accelerated video decoding is not working, or maybe you forgot to install or disabled the h264ify Chrome extension. - -If it's not working, you could try to debug it by running `chromium-browser` from the command line and see if it shows any VA-API related errors. You can also run `vainfo` (install it in Ubuntu or Linux Mint: `sudo apt install vainfo`) and `vdpauinfo` (for Nvidia; install it in Ubuntu or Linux Mint: `sudo apt install vdpauinfo`) and see if it shows an error. - - --------------------------------------------------------------------------------- - -via: https://www.linuxuprising.com/2018/08/how-to-enable-hardware-accelerated.html - -作者:[Logix][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://plus.google.com/118280394805678839070 -[1]:https://github.com/saiarcot895/chromium-ubuntu-build/tree/master/debian/patches -[2]:https://chrome.google.com/webstore/detail/h264ify/aleakchihdccplidncghkekgioiakgal -[3]:https://chromium-review.googlesource.com/c/chromium/src/+/532294 -[4]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-dev -[5]:https://aur.archlinux.org/packages/?O=0&SeB=nd&K=chromium+vaapi&outdated=&SB=n&SO=a&PP=50&do_Search=Go -[6]:https://aur.archlinux.org/packages/libva-vdpau-driver-chromium/ -[7]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta -[8]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-dev/+packages diff --git a/translated/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md b/translated/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md new file mode 100644 index 0000000000..d7a6d16fb5 --- /dev/null +++ b/translated/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md @@ -0,0 +1,112 @@ +如何在 Ubuntu 或 Linux Mint 启用硬件加速的视频解码 +====== +你或许已经注意到了,在 Linux 上使用 Google Chrome 或 Chromium 浏览器在 YouTube 或其它类似网站观看高清视频会增加你的 CPU 使用率,如果你用的是笔记本,电脑会发热而且电池会很快用完。这是因为Chrome/Chromium(Firefox 也是如此,但是 Firefox 的问题没有办法解决)在 Linux 上不支持硬件加速的视频解码。 + +**这篇文章讲述了如何在 Linux 环境安装带有 VA-API 补丁的 Chromium 开发版,它支持 GPU 加速的视频解码,可以显著减少观看在线高清视频时的 CPU 使用率,这篇教程只适用于 Intel 和 Nvidia 的显卡,我没有 ATI/AMD 的显卡可以试验,也没有使用过这几种显卡。** + +这是 Chromium 浏览器在 Ubuntu18.04 中,没有 GPU 加速视频解码时正在播放一个 1080p 的 YouTube 视频: + +![](https://4.bp.blogspot.com/-KtUQni2PMvE/W3KlJ62yLLI/AAAAAAAABW4/NrNVFaTAkZ8AmwqWwRvWD6czT51ni-R-gCLcBGAs/s1600/chromium-default-no-accel.png) + +这是带有 VA-API 补丁的 Chromium 浏览器在 Ubuntu18.04 中,GPU 加速视频解码时正在播放同样的 1080p 的 YouTube 视频: + +![](https://4.bp.blogspot.com/-0c-wb4UNhW8/W3KlQBfeFnI/AAAAAAAABW8/WVUAYzM6hA8wRTlCcrPXPMpoXoFVR6b1QCLcBGAs/s1600/chromium-hardware-acceleration-enabled.png) + +注意截图中的 CPU 使用率。两张截图都是在我老旧而依然强大的桌面上捕捉的。在我的笔记本上,没有硬件加速的 Chromium 带来更高的CPU使用率。 + +"只需 VAAPI 即可在 Linux 启用 VAVDA,VAVEA 和 VAJDA" 这篇文章在一年多以前就提交给了Chromium,但是它还没有合并请求。 + +Chrome有一个选项可以覆盖软件渲染列表( + +`#ignore-gpu-blacklist` + +),但是这个选项不能启用硬件加速的视频解码。启用这个选项以后,你或许会在访问 + +`chrome://gpu` + +时发现这些信息:“_Video Decode: Hardware accelerated_ “,然而这个并不意味着真的有效。在 YouTube 打开一个高清视频并用工具查看CPU使用率如 + +`htop` + +(这是我在以上截图中用来查看 CPU 使用率的)。因为 GPU 视频解码没有真的被启用,你应该看到较高的 CPU 使用率。下面有一个部分是关于你是否真的在使用硬件加速的视频解码的。 + +**文中使用的 Chromium 浏览器 Ubuntu 版启用 VA-API 的补丁在[这个地址][1]可以获得** + +### 在 Ubuntu 和 Linux Mint 安装和使用带有 VA-API 支持的 Chromium 浏览器 + +**每个人都该知道 Chromium 开发版本没有理想中那么稳定。所以你可能发现 bug,它可能会发生崩溃等情况。它现在可能正常运行,但是谁知道几次更新以后会发生什么。** + +**还有,如果你想启用 Widevine 支持(这样你才能观看 Netflix 视频和 YouTube 付费视频),Chromium dev 分支 PPA 要求你执行一些额外步骤。 ** **如果你想要一些功能,比如同步,也是如此**(需要注册 API key还要在你的系统上设置好)。执行这些任务的说明在本文中被详细解释了。 + +带有 VA-API 补丁的 Chromium 在其它Linux发行版本也可以获得,但是这里选择 Ubuntu。 + +**1\. 安装带有 VA-API 补丁的 Chromium ** + +有一个带 VA-API 补丁的 Chromium Beta,但是它缺少适用于 Ubuntu 18.04 的 vdpau-video。 +``` +sudo add-apt-repository ppa:saiarcot895/chromium-dev +sudo apt-get update +sudo apt install chromium-browser + +``` + +**2\. 安装 VA-API 驱动** + +对于Intel的显卡,你需要安装 `i965-va-driver` 这个包(它可能早就安装好了) +``` +sudo apt install i965-va-driver +``` + +对于 Nvidia 的显卡(在开源和闭源的 Nvidia 驱动上,它应该都有效), 安装`vdpau-va-driver` : +``` +sudo apt install vdpau-va-driver +``` + +**3\. 在 Chromium 启用硬件加速视频选项** + +复制这串地址,粘贴进 Chromium 的 URL 栏: `chrome://flags/#enable-accelerated-video` (或者在 `chrome://flags` 搜索 `Hardware-accelerated video` )并启用它,然后重启 Chromium 浏览器。 + +在默认的 Google Chrome / Chromium 版本,这个选项不可用,但是你可以在启用了 VP-API 的 Chromium 版本启用它。 + +**4\. 安装 [h264ify][2] Chrome 扩展** + +YouTube(可能还有其它一些网址也是如此)默认使用 VP8 或 VP9 编码解码器,许多 GPU 不支持这种编码解码器的硬件解码。h264ify 会强制 YouTube 使用大多数 GPU 都支持的 H.264 而不是 VP8/VP9。 + +这个扩展还能阻塞 60fps 的视频,对低性能机器有用。 + +你可以点击这个视频并且选择 `Stats for nerds` 以查看编码解码器,如果启用了 h264ify 扩展,你可以看到编码解码器是 avc / mp4a。如果没有启用,编码解码器应该是 vp09 / opus。 + +### 如何检查 Chromium 是否在使用 GPU 视频解码 + +在 YouTube 打开一个视频,然后,在 Chromium 打开一个新的标签页并将以下地址输入 URL 栏: + + `chrome://media-internals` + +在 `chrome://media-internals` 标签页中,点击视频的URL(为了展开它), 往下滚动查看 `Player Properties` 的下面,你应该可以找到 `video_decoder` 属性。如果`video_decoder` 的值是 `GpuVideoDecoder` ,这说明当前在另一个标签页播放的 YouTube 视频正在使用硬件加速的的视频解码。 + +![](https://4.bp.blogspot.com/-COBJWVT_Y0Q/W3KnG7AeHsI/AAAAAAAABXM/W2XAJA_S0BIHug4eQKTMOdIfXHhgkXhhQCLcBGAs/s1600/chromium-gpuvideodecoder-linux.png) + +如果它显示的是 `FFmpegVideoDecoder` 或 `VpxVideoDecoder` ,说明加速视频解码无效或者你忘记安装或禁用了 h264ify 这个 Chrome 扩展。 + +如果无效,你可以通过在命令行运行 `chromium-browser` ,通过查看是否有 VA-API 相关的错误显示出来以调试。你也可以运行`vainfo` (在 Ubuntu 或 Linux Mint 安装:`sudo apt install vainfo`)和 `vdpauinfo` (对于 Nvidia,在 Ubuntu 或 Linux Mint 安装:`sudo apt install vdpauinfo`)并且查看是否有显示任何错误。 + +-------------------------------------------------------------------------------- + +via: https://www.linuxuprising.com/2018/08/how-to-enable-hardware-accelerated.html + +作者:[Logix][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[GraveAccent](https://github.com/GraveAccent) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://plus.google.com/118280394805678839070 +[1]:https://github.com/saiarcot895/chromium-ubuntu-build/tree/master/debian/patches +[2]:https://chrome.google.com/webstore/detail/h264ify/aleakchihdccplidncghkekgioiakgal +[3]:https://chromium-review.googlesource.com/c/chromium/src/+/532294 +[4]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-dev +[5]:https://aur.archlinux.org/packages/?O=0&SeB=nd&K=chromium+vaapi&outdated=&SB=n&SO=a&PP=50&do_Search=Go +[6]:https://aur.archlinux.org/packages/libva-vdpau-driver-chromium/ +[7]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta +[8]:https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-dev/+packages From feffda0c0bf602591278d9a6ad3b779c76c7f52e Mon Sep 17 00:00:00 2001 From: idea2act Date: Wed, 12 Sep 2018 22:00:58 +0800 Subject: [PATCH 191/455] idea2act translated --- ...i editor into a productivity powerhouse.md | 345 ----------------- ...i editor into a productivity powerhouse.md | 356 ++++++++++++++++++ 2 files changed, 356 insertions(+), 345 deletions(-) delete mode 100644 sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md create mode 100644 translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md diff --git a/sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md b/sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md deleted file mode 100644 index f3fc89ed4b..0000000000 --- a/sources/tech/20180903 Turn your vi editor into a productivity powerhouse.md +++ /dev/null @@ -1,345 +0,0 @@ -idea2act translating - -Turn your vi editor into a productivity powerhouse -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk) - -A versatile and powerful editor, vi includes a rich set of potent commands that make it a popular choice for many users. This article specifically looks at commands that are not enabled by default in vi but are nevertheless useful. The commands recommended here are expected to be set in a vi configuration file. Though it is possible to enable commands individually from each vi session, the purpose of this article is to create a highly productive environment out of the box. - -### Before you begin - -While "vim" is the technically correct name of the newer version of the vi editor, this article refers to it as "vi." vimrc is the configuration file used by vim. - -The commands or configurations discussed here go into the vi startup configuration file, vimrc, located in the user home directory. Follow the instructions below to set the commands in vimrc: - -(Note: The vimrc file is also used for system-wide configurations in Linux, such as `/etc/vimrc` or `/etc/vim/vimrc`. In this article, we'll consider only user-specific vimrc, present in user home folder.) - -In Linux: - - * Open the file with `vi $HOME/.vimrc` - * Type or copy/paste the commands in the cheat sheet at the end of this article - * Save and close (`:wq`) - - - -In Windows: - - * First, [install gvim][1] - * Open gvim - * Click Edit --> Startup settings, which opens the _vimrc file - * Type or copy/paste the commands in the cheat sheet at the end of this article - * Click File --> Save - - - -Let's delve into the individual vi productivity commands. These commands are classified into the following categories: - - 1. Indentation & Tabs - 2. Display & Format - 3. Search - 4. Browse & Scroll - 5. Spell - 6. Miscellaneous - - - -### 1\. Indentation & Tabs - -To automatically align the indentation of a line in a file: -``` -set autoindent - -``` - -Smart Indent uses the code syntax and style to align: -``` -set smartindent - -``` - -Tip: vi is language-aware and provides a default setting that works efficiently based on the programming language used in your file. There are many default configuration commands, including `axs cindent`, `cinoptions`, `indentexpr`, etc., which are not explained here. `syn` is a helpful command that shows or sets the file syntax. - -To set the number of spaces to display for a tab: -``` -set tabstop=4 - -``` - -To set the number of spaces to display for a “shift operation” (such as ‘>>’ or ‘<<’): -``` -set shiftwidth=4 - -``` - -If you prefer to use spaces instead of tabs, this option inserts spaces when the Tab key is pressed. This may cause problems for languages such as Python that rely on tabs instead of spaces. In such cases, you may set this option based on the file type (see `autocmd`). -``` -set expandtab - -``` - -### 2\. Display & Format - -To show line numbers: -``` -set number - -``` - -![](https://opensource.com/sites/default/files/uploads/picture01.png) - -To wrap text when it crosses the maximum line width: -``` -set textwidth=80 - -``` - -To wrap text based on a number of columns from the right side: -``` -set wrapmargin=2 - -``` - -To identify open and close brace positions when you traverse through the file: -``` -set showmatch - -``` - -![](https://opensource.com/sites/default/files/uploads/picture02-03.jpg) - -### 3\. Search - -To highlight the searched term in a file: -``` -set hlsearch - -``` - -![](https://opensource.com/sites/default/files/uploads/picture04.png) - -To perform incremental searches as you type: -``` -set incsearch - -``` - -![](https://opensource.com/sites/default/files/picture05.png) - -To search ignoring case (many users prefer not to use this command; set it only if you think it will be useful): -``` -set ignorecase - -``` - -To search without considering `ignorecase` when both `ignorecase` and `smartcase` are set and the search pattern contains uppercase: -``` -set smartcase - -``` - -For example, if the file contains: - -test -Test - -When both `ignorecase` and `smartcase` are set, a search for “test” finds and highlights both: - -test -Test - -A search for “Test” highlights or finds only the second line: - -test -Test - -### 4. Browse & Scroll - -For a better visual experience, you may prefer to have the cursor somewhere in the middle rather than on the first line. The following option sets the cursor position to the 5th row. -``` -set scrolloff=5 - -``` - -Example: - -The first image is with scrolloff=0 and the second image is with scrolloff=5. - -![](https://opensource.com/sites/default/files/uploads/picture06-07.jpg) - -Tip: `set sidescrolloff` is useful if you also set `nowrap.` - -To display a permanent status bar at the bottom of the vi screen showing the filename, row number, column number, etc.: -``` -set laststatus=2 - -``` - -![](https://opensource.com/sites/default/files/picture08.png) - -### 5. Spell - -vi has a built-in spell-checker that is quite useful for text editing as well as coding. vi recognizes the file type and checks the spelling of comments only in code. Use the following command to turn on spell-check for the English language: -``` -set spell spelllang=en_us - -``` - -### 6. Miscellaneous - -Disable creating backup file: When this option is on, vi creates a backup of the previous edit. If you do not want this feature, disable it as shown below. Backup files are named with a tilde (~) at the end of the filename. -``` -set nobackup - -``` - -Disable creating a swap file: When this option is on, vi creates a swap file that exists until you start editing the file. Swapfile is used to recover a file in the event of a crash or a use conflict. Swap files are hidden files that begin with `.` and end with `.swp`. -``` -set noswapfile - -``` - -Suppose you need to edit multiple files in the same vi session and switch between them. An annoying feature that's not readily apparent is that the working directory is the one from which you opened the first file. Often it is useful to automatically switch the working directory to that of the file being edited. To enable this option: -``` -set autochdir - -``` - -vi maintains an undo history that lets you undo changes. By default, this history is active only until the file is closed. vi includes a nifty feature that maintains the undo history even after the file is closed, which means you may undo your changes even after the file is saved, closed, and reopened. The undo file is a hidden file saved with the `.un~` extension. -``` -set undofile - -``` - -To set audible alert bells (which sound a warning if you try to scroll beyond the end of a line): -``` -set errorbells - -``` - -If you prefer, you may set visual alert bells: -``` -set visualbell - -``` - -### Bonus - -vi provides long-format as well as short-format commands. Either format can be used to set or unset the configuration. - -Long format for the `autoindent` command: -``` -set autoindent - -``` - -Short format for the `autoindent` command: -``` -set ai - -``` - -To see the current configuration setting of a command without changing its current value, use `?` at the end: -``` -set autoindent? - -``` - -To unset or turn off a command, most commands take `no` as a prefix: -``` -set noautoindent - -``` - -It is possible to set a command for one file but not for the global configuration. To do this, open the file and type `:`, followed by the `set` command. This configuration is effective only for the current file editing session. - -![](https://opensource.com/sites/default/files/uploads/picture09.png) - -For help on a command: -``` -:help autoindent - -``` - -![](https://opensource.com/sites/default/files/uploads/picture10-11.jpg) - -Note: The commands listed here were tested on Linux with Vim version 7.4 (2013 Aug 10) and Windows with Vim 8.0 (2016 Sep 12). - -These useful commands are sure to enhance your vi experience. Which other commands do you recommend? - -### Cheat sheet - -Copy/paste this list of commands in your vimrc file: -``` -" Indentation & Tabs - -set autoindent - -set smartindent - -set tabstop=4 - -set shiftwidth=4 - -set expandtab - -set smarttab - -" Display & format - -set number - -set textwidth=80 - -set wrapmargin=2 - -set showmatch - -" Search - -set hlsearch - -set incsearch - -set ignorecase - -set smartcase - -" Browse & Scroll - -set scrolloff=5 - -set laststatus=2 - -" Spell - -set spell spelllang=en_us - -" Miscellaneous - -set nobackup - -set noswapfile - -set autochdir - -set undofile - -set visualbell - -set errorbells -``` - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/vi-editor-productivity-powerhouse - -作者:[Girish Managoli][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/gammay -[1]: https://www.vim.org/download.php#pc diff --git a/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md b/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md new file mode 100644 index 0000000000..e1bbd55920 --- /dev/null +++ b/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md @@ -0,0 +1,356 @@ + + +增强 Vim 编辑器,提高编辑效率 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk) + +编者注:标题和文章最初提到的 `vi` 编辑器,现已更新为编辑器的正确名称:`Vim`。 + +`Vim` 作为一款功能强大、选项丰富的编辑器,为许多用户所热爱。本文介绍了一些在 `Vim` 中默认未启用但实际非常有用的选项。虽然可以在每个 `Vim` 会话中单独启用,但为了创建一个开箱即用的高效编辑环境,还是建议在 `Vim` 的配置文件中配置这些命令。 + +## 开始前的准备 + +这里所说的选项或配置均位于用户主目录中的 `Vim` 启动配置文件 `.vimrc`。 按照下面的说明在 `.vimrc` 中设置选项: + +(注意:`vimrc` 文件也用于 `Linux` 中的全局配置,如 `/etc/vimrc` 或 `/etc/vim/vimrc`。本文所说的 `.vimrc` 均是指位于用户主目录中的 `.vimrc` 文件。) + +`Linux` 系统中: + + * 用 `Vim` 打开 `.vimrc` 文件: `vim ~/.vimrc` + * 复制本文最后的 `选项列表` 粘贴到 `.vimrc` 文件 + * 保存并关闭 (`:wq`) + +译者注:此处不建议使用 `Vim` 编辑 `.vimrc` 文件,因为很可能无法粘贴成功,可以选择 `gedit` 编辑器编辑 `.vimrc` 文件。 + +`Windows` 系统中: + + * 首先,[安装 gvim][1] + * 打开 `gvim` + * 单击 `编辑` -> `启动设置`,打开 `.vimrc` 文件 + * 复制本文最后的 `选项列表` 粘贴到 `.vimrc` 文件 + * 单击 `文件` -> `保存` + +译者注:此处应注意不要使用 `Windows` 自带的记事本编辑该 `.vimrc` 文件。 + +下面,我们将深入研究提高 `Vim` 编辑效率的选项。主要分为以下几类: + + 1. 缩进 & 制表符 + 2. 显示 & 格式化 + 3. 搜索 + 4. 浏览 & 滚动 + 5. 拼写 + 6. 其他选项 + +## 1. 缩进 & 制表符 + +使 `Vim` 在创建新行的时候使用与上一行同样的缩进: + +```vim +set autoindent +``` + +创建新行时使用智能缩进,主要用于 `C` 语言一类的程序。通常,打开 `smartindent` 时也应该打开 `autoindent`: + +```vim +set smartindent +``` + +注意:`Vim` 具有语言感知功能,且其默认设置可以基于文件中的编程语言来改变配置以提高效率。有许多默认的配置选项,包括 `axs cindent`,`cinoptions`,`indentexpr` 等,没有在这里说明。 `syn` 是一个非常有用的命令,用于设置文件的语法以更改显示模式。 + +译者注:这里的 `syn` 是指 `syntax`,可用于设置文件所用的编程语言,开启对应的语法高亮,以及执行自动事件 (`autocmd`)。 + +设置文件里的制表符 `(TAB)` 的宽度(以空格的数量表示): + +```vim +set tabstop=4 +``` + +设置移位操作 `>>` 或 `<<` 的缩进长度(以空格的数量表示): + +```vim +set shiftwidth=4 +``` + +如果你更喜欢在编辑文件时使用空格而不是制表符,设置以下选项可以使 `Vim` 在你按下 `Tab` 键时用空格代替制表符。 + +```vim +set expandtab +``` + +注意:这可能会导致依赖于制表符的 `Python` 等编程语言出现问题。这时,你可以根据文件类型设置该选项(请参考 `autocmd`)。 + +## 2. 显示 & 格式化 + +要在每行的前面显示行号: + +```vim +set number +``` + +![](https://opensource.com/sites/default/files/uploads/picture01.png) + +要在文本行超过一定长度时自动换行: + +```vim +set textwidth=80 +``` + +要根据从窗口右侧向左数的列数来自动换行: + +```vim +set wrapmargin=2 +``` + +译者注:如果 `textwidth` 选项不等于零,本选项无效。 + +插入括号时,短暂地跳转到匹配的括号: + +```vim +set showmatch +``` + +![](https://opensource.com/sites/default/files/uploads/picture02-03.jpg) + +## 3. 搜索 + +高亮搜索内容的所有匹配位置: + +```vim +set hlsearch +``` + +![](https://opensource.com/sites/default/files/uploads/picture04.png) + +搜索过程中动态显示匹配内容: + +```vim +set incsearch +``` + +![](https://opensource.com/sites/default/files/picture05.png) + +搜索时忽略大小写: + +```vim +set ignorecase +``` + +在打开 `ignorecase` 选项的条件下,搜索内容包含部分大写字符时,要使搜索大小写敏感: + +```vim +set smartcase +``` + +例如,如果文件内容是: + +> test\ +> Test + +当打开 `ignorecase` 和 `smartcase` 选项时,搜索 `test` 时的突出显示: + +> test\ +> Test + +搜索 `Test` 时的突出显示: + +> test\ +> Test + +## 4. 浏览 & 滚动 + +为获得更好的视觉体验,你可能希望将光标放在窗口中间而不是第一行,以下选项使光标距窗口上下保留 5 行。 + +```vim +set scrolloff=5 +``` + +一个例子: + +第一张图中 `scrolloff=0`,第二张图中 `scrolloff=5`。 + +![](https://opensource.com/sites/default/files/uploads/picture06-07.jpg) + +提示:如果你没有设置选项 `nowrap`,那么设置 `sidescrolloff` 将非常有用。 + +在 `Vim` 窗口底部显示一个永久状态栏,可以显示文件名、行号和列号等内容: + +```vim +set laststatus=2 +``` + +![](https://opensource.com/sites/default/files/picture08.png) + +## 5. 拼写 + +`Vim` 有一个内置的拼写检查器,对于文本编辑和编码非常有用。`Vim` 可以识别文件类型并仅对代码中的注释进行拼写检查。使用下面的选项打开英语拼写检查: + +```vim +set spell spelllang=en_us +``` + +译者注:中文、日文或其它东亚语字符通常会在打开拼写检查时被标为拼写错误,因为拼写检查不支持这些语种,可以在 `spelllang` 选项中加入 `cjk` 来忽略这些错误标注。 + +## 6. 其他选项 + +禁止创建备份文件:启用此选项后,`Vim` 将在覆盖文件前创建一个备份,文件成功写入后保留该备份。如果不想保留该备份文件,可以按下面的方式关闭: + +```vim +set nobackup +``` + +禁止创建交换文件:启用此选项后,`Vim` 将在编辑该文件时创建一个交换文件。 交换文件用于在崩溃或发生使用冲突时恢复文件。交换文件是以 `.` 开头并以 `.swp` 结尾的隐藏文件。 + +```vim +set noswapfile +``` + +如果需要在同一个 `Vim` 窗口中编辑多个文件并进行切换。默认情况下,工作目录是打开的第一个文件的目录。而将工作目录自动切换到正在编辑的文件的目录是非常有用的。要自动切换工作目录: + +```vim +set autochdir +``` + +`Vim` 自动维护编辑的历史记录,允许撤消更改。默认情况下,该历史记录仅在文件关闭之前有效。`Vim` 包含一个增强功能,使得即使在文件关闭后也可以维护撤消历史记录,这意味着即使在保存、关闭和重新打开文件后,也可以撤消之前的更改。历史记录文件是使用 `.un~` 扩展名保存的隐藏文件。 + +```vim +set undofile +``` + +错误信息响铃,只对错误信息起作用: + +```vim +set errorbells +``` + +如果你愿意,还可以设置错误视觉提示: + +```vim +set visualbell +``` + +## 惊喜 + +vi provides long-format as well as short-format commands. Either format can be used to set or unset the configuration. + +`Vim` 提供长格式和短格式命令,两种格式都可用于设置或取消选项配置。 + +`autoindent` 选项的长格式是: + +```vim +set autoindent +``` + +`autoindent` 选项的短格式是: + +```vim +set ai +``` + +To see the current configuration setting of a command without changing its current value, use `?` at the end: + +要在不更改选项当前值的情况下查看其当前设置,可以在 `Vim` 的命令行上使用在末尾加上 `?` 的命令: + +```vim +set autoindent? +``` + +在大多数选项前加上 `no` 前缀可以取消或关闭选项: + +```vim +set noautoindent +``` + +可以为单独的文件配置选项,而不必修改全局配置文件。需要的话,请打开文件并输入 `:`,然后键入 `set`命令。这样的话,配置仅对当前的文件编辑会话有效。 + +![](https://opensource.com/sites/default/files/uploads/picture09.png) + +使用命令行获取帮助: + +```vim +:help autoindent +``` + +![](https://opensource.com/sites/default/files/uploads/picture10-11.jpg) + +注意:此处列出的命令仅对 `Linux` 上的 `Vim 7.4` 版本和 `Windows` 上的 `Vim 8.0` 版本进行了测试。 + +这些有用的命令肯定会增强您的 `Vim` 使用体验。你会推荐哪些其他有用的命令? + +## 选项列表 + +复制该选项列表粘贴到 `.vimrc` 文件中: + +```vim +" Indentation & Tabs + +set autoindent + +set smartindent + +set tabstop=4 + +set shiftwidth=4 + +set expandtab + +set smarttab + +" Display & format + +set number + +set textwidth=80 + +set wrapmargin=2 + +set showmatch + +" Search + +set hlsearch + +set incsearch + +set ignorecase + +set smartcase + +" Browse & Scroll + +set scrolloff=5 + +set laststatus=2 + +" Spell + +set spell spelllang=en_us + +" Miscellaneous + +set nobackup + +set noswapfile + +set autochdir + +set undofile + +set visualbell + +set errorbells +``` + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/vi-editor-productivity-powerhouse + +作者:[Girish Managoli][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[idea2act](https://github.com/idea2act) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/gammay +[1]: https://www.vim.org/download.php#pc \ No newline at end of file From b54f2c67f5d5dcf38d005c9aa8537e2d894d5eb1 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 12 Sep 2018 22:43:51 +0800 Subject: [PATCH 192/455] PRF:20170706 Docker Guide Dockerizing Python Django Application.md @MjSeven --- ...e Dockerizing Python Django Application.md | 261 +++++++++--------- 1 file changed, 133 insertions(+), 128 deletions(-) diff --git a/translated/tech/20170706 Docker Guide Dockerizing Python Django Application.md b/translated/tech/20170706 Docker Guide Dockerizing Python Django Application.md index 98fd65b47d..e89a2065f5 100644 --- a/translated/tech/20170706 Docker Guide Dockerizing Python Django Application.md +++ b/translated/tech/20170706 Docker Guide Dockerizing Python Django Application.md @@ -1,57 +1,27 @@ -Docker 指南:Docker 化 Python Django 应用程序 +如何 Docker 化 Python Django 应用程序 ====== -### 目录 - -1. [我们要做什么?][6] - -2. [步骤 1 - 安装 Docker-ce][7] - -3. [步骤 2 - 安装 Docker-compose][8] - -4. [步骤 3 - 配置项目环境][9] - 1. [创建一个新的 requirements.txt 文件][1] - - 2. [创建 Nginx 虚拟主机文件 django.conf][2] - - 3. [创建 Dockerfile][3] - - 4. [创建 Docker-compose 脚本][4] - - 5. [配置 Django 项目][5] - -5. [步骤 4 - 构建并运行 Docker 镜像][10] - -6. [步骤 5 - 测试][11] - -7. [参考][12] - - -Docker 是一个开源项目,为开发人员和系统管理员提供了一个开放平台,作为一个轻量级容器,它可以在任何地方构建,打包和运行应用程序。Docker 在软件容器中自动部署应用程序。 +Docker 是一个开源项目,为开发人员和系统管理员提供了一个开放平台,可以将应用程序构建、打包为一个轻量级容器,并在任何地方运行。Docker 会在软件容器中自动部署应用程序。 Django 是一个用 Python 编写的 Web 应用程序框架,遵循 MVC(模型-视图-控制器)架构。它是免费的,并在开源许可下发布。它速度很快,旨在帮助开发人员尽快将他们的应用程序上线。 -在本教程中,我将逐步向你展示在 Ubuntu 16.04 如何为现有的 Django 应用程序创建 docker 镜像。我们将学习如何 docker 化一个 Python Django 应用程序,然后使用一个 docker-compose 脚本将应用程序作为容器部署到 docker 环境。 +在本教程中,我将逐步向你展示在 Ubuntu 16.04 中如何为现有的 Django 应用程序创建 docker 镜像。我们将学习如何 docker 化一个 Python Django 应用程序,然后使用一个 `docker-compose` 脚本将应用程序作为容器部署到 docker 环境。 -为了部署我们的 Python Django 应用程序,我们需要其他 docker 镜像:一个用于 Web 服务器的 nginx docker 镜像和用于数据库的 PostgreSQL 镜像。 +为了部署我们的 Python Django 应用程序,我们需要其它 docker 镜像:一个用于 Web 服务器的 nginx docker 镜像和用于数据库的 PostgreSQL 镜像。 ### 我们要做什么? 1. 安装 Docker-ce - 2. 安装 Docker-compose - 3. 配置项目环境 - 4. 构建并运行 - 5. 测试 ### 步骤 1 - 安装 Docker-ce -在本教程中,我们将重 docker 仓库安装 docker-ce 社区版。我们将安装 docker-ce 社区版和 docker-compose,其支持 compose 文件版本 3(to 校正者:此处不太明白具体意思)。 +在本教程中,我们将从 docker 仓库安装 docker-ce 社区版。我们将安装 docker-ce 社区版和 `docker-compose`(其支持 compose 文件版本 3)。 -在安装 docker-ce 之前,先使用 apt 命令安装所需的 docker 依赖项。 +在安装 docker-ce 之前,先使用 `apt` 命令安装所需的 docker 依赖项。 ``` sudo apt install -y \ @@ -71,7 +41,7 @@ sudo add-apt-repository \    stable" ``` - [![安装 Docker-ce](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/1.png)][14] +[![安装 Docker-ce](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/1.png)][14] 更新仓库并安装 docker-ce。 @@ -87,16 +57,16 @@ systemctl start docker systemctl enable docker ``` -接着,我们将添加一个名为 'omar' 的新用户并将其添加到 docker 组。 +接着,我们将添加一个名为 `omar` 的新用户并将其添加到 `docker` 组。 ``` useradd -m -s /bin/bash omar usermod -a -G docker omar ``` - [![启动 Docker](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/2.png)][15] +[![启动 Docker](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/2.png)][15] -以 omar 用户身份登录并运行 docker 命令,如下所示。 +以 `omar` 用户身份登录并运行 `docker` 命令,如下所示。 ``` su - omar @@ -107,13 +77,13 @@ docker run hello-world [![检查 Docker 安装](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/3.png)][16] - Docker-ce 安装已经完成。 +Docker-ce 安装已经完成。 - ### 步骤 2 - 安装 Docker-compose +### 步骤 2 - 安装 Docker-compose -在本教程中,我们将使用最新的 docker-compose 支持 compose 文件版本 3。我们将手动安装 docker-compose。 +在本教程中,我们将使用支持 compose 文件版本 3 的最新 `docker-compose`。我们将手动安装 `docker-compose`。 -使用 curl 命令将最新版本的 docker-compose 下载到 `/usr/local/bin` 目录,并使用 chmod 命令使其有执行权限。 +使用 `curl` 命令将最新版本的 `docker-compose` 下载到 `/usr/local/bin` 目录,并使用 `chmod` 命令使其有执行权限。 运行以下命令: @@ -122,7 +92,7 @@ sudo curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-c sudo chmod +x /usr/local/bin/docker-compose ``` -现在检查 docker-compose 版本。 +现在检查 `docker-compose` 版本。 ``` docker-compose version @@ -132,26 +102,26 @@ docker-compose version [![安装 Docker-compose](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/4.png)][17] -已安装支持 compose 文件版本 3 的 docker-compose 最新版本。 +已安装支持 compose 文件版本 3 的 `docker-compose` 最新版本。 ### 步骤 3 - 配置项目环境 -在这一步中,我们将配置 Python Django 项目环境。我们将创建新目录 'guide01',并使其成为我们项目文件的主目录,例如 Dockerfile,Django 项目,nginx 配置文件等。 +在这一步中,我们将配置 Python Django 项目环境。我们将创建新目录 `guide01`,并使其成为我们项目文件的主目录,例如包括 Dockerfile、Django 项目、nginx 配置文件等。 -登录到 'omar' 用户。 +登录到 `omar` 用户。 ``` su - omar ``` -创建一个新目录 'guide01',并进入目录。 +创建一个新目录 `guide01`,并进入目录。 ``` mkdir -p guide01 cd guide01/ ``` -现在在 'guide01' 目录下,创建两个新目录 'project' 和 'config'。 +现在在 `guide01` 目录下,创建两个新目录 `project` 和 `config`。 ``` mkdir project/ config/ @@ -159,118 +129,151 @@ mkdir project/ config/ 注意: -* 'project' 目录:我们所有的 python Django 项目文件都将放在该目录中。 +* `project` 目录:我们所有的 python Django 项目文件都将放在该目录中。 +* `config` 目录:项目配置文件的目录,包括 nginx 配置文件、python pip 的`requirements.txt` 文件等。 -* 'config' 目录:项目配置文件的目录,包括 nginx 配置文件,python pip requirements 文件等。 +#### 创建一个新的 requirements.txt 文件 -### 创建一个新的 requirements.txt 文件 - -接下来,使用 vim 命令在 'config' 目录中创建一个新的 requirements.txt 文件 +接下来,使用 `vim` 命令在 `config` 目录中创建一个新的 `requirements.txt` 文件。 ``` vim config/requirements.txt ``` -粘贴下面的配置。 +粘贴下面的配置: ``` Django==2.0.4  - gunicorn==19.7.0  - psycopg2==2.7.4 +gunicorn==19.7.0  +psycopg2==2.7.4 ``` 保存并退出。 -### 创建 Dockerfile +#### 创建 Nginx 虚拟主机文件 django.conf -在 'guide01' 目录下创建新文件 'Dockerfile'。 +在 `config` 目录下创建 nginx 配置目录并添加虚拟主机配置文件 `django.conf`。 -运行以下命令。 +``` +mkdir -p config/nginx/ +vim config/nginx/django.conf +``` + +粘贴下面的配置: + +``` +upstream web { + ip_hash; + server web:8000; +} + +# portal +server { + location / { + proxy_pass http://web/; + } + listen 8000; + server_name localhost; + + location /static { + autoindex on; + alias /src/static/; + } +} +``` + +保存并退出。 + +#### 创建 Dockerfile + +在 `guide01` 目录下创建新文件 `Dockerfile`。 + +运行以下命令: ``` vim Dockerfile ``` -现在粘贴下面的 Dockerfile 脚本。 +现在粘贴下面的 Dockerfile 脚本: ``` FROM python:3.5-alpine - ENV PYTHONUNBUFFERED 1  +ENV PYTHONUNBUFFERED 1  - RUN apk update && \ -     apk add --virtual build-deps gcc python-dev musl-dev && \ -     apk add postgresql-dev bash +RUN apk update && \ +    apk add --virtual build-deps gcc python-dev musl-dev && \ +    apk add postgresql-dev bash - RUN mkdir /config  - ADD /config/requirements.txt /config/  - RUN pip install -r /config/requirements.txt - RUN mkdir /src - WORKDIR /src +RUN mkdir /config  +ADD /config/requirements.txt /config/  +RUN pip install -r /config/requirements.txt +RUN mkdir /src +WORKDIR /src ``` 保存并退出。 注意: -我们想要为我们的 Django 项目构建基于 Alpine Linux 的 Docker 镜像,Alpine 是最小的 Linux 版本。我们的 Django 项目将运行在带有 Python3.5 的 Alpine Linux 上,并添加 postgresql-dev 包以支持 PostgreSQL 数据库。然后,我们将使用 python pip 命令安装在 'requirements.txt' 上列出的所有 Python 包,并为我们的项目创建新目录 '/src'。 +我们想要为我们的 Django 项目构建基于 Alpine Linux 的 Docker 镜像,Alpine 是最小的 Linux 版本。我们的 Django 项目将运行在带有 Python 3.5 的 Alpine Linux 上,并添加 postgresql-dev 包以支持 PostgreSQL 数据库。然后,我们将使用 python `pip` 命令安装在 `requirements.txt` 上列出的所有 Python 包,并为我们的项目创建新目录 `/src`。 -### 创建 Docker-compose 脚本 +#### 创建 Docker-compose 脚本 -使用 [vim][18] 命令在 'guide01' 目录下创建 'docker-compose.yml' 文件。 +使用 [vim][18] 命令在 `guide01` 目录下创建 `docker-compose.yml` 文件。 ``` vim docker-compose.yml ``` -粘贴以下配置内容。 +粘贴以下配置内容: ``` version: '3' - services: -   db: -     image: postgres:10.3-alpine -     container_name: postgres01 -   nginx: -     image: nginx:1.13-alpine -     container_name: nginx01 -     ports: -       - "8000:8000" -     volumes: -       - ./project:/src -       - ./config/nginx:/etc/nginx/conf.d -     depends_on: -       - web -   web: -     build: . -     container_name: django01 -     command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py collectstatic --noinput && gunicorn hello_django.wsgi -b 0.0.0.0:8000" -     depends_on: -       - db -     volumes: -       - ./project:/src -     expose: -       - "8000" -     restart: always + services: +   db: +      image: postgres:10.3-alpine +     container_name: postgres01 +   nginx: +     image: nginx:1.13-alpine +     container_name: nginx01 +     ports: +       - "8000:8000" +     volumes: +       - ./project:/src +       - ./config/nginx:/etc/nginx/conf.d +     depends_on: +       - web +   web: +     build: . +     container_name: django01 +     command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py collectstatic --noinput && gunicorn hello_django.wsgi -b 0.0.0.0:8000" +     depends_on: +       - db +     volumes: +       - ./project:/src +     expose: +       - "8000" +     restart: always ``` 保存并退出。 注意: -使用这个 docker-compose 文件脚本,我们将创建三个服务。使用 PostgreSQL alpine Linux 创建名为 'db' 的数据库服务,再次使用 Nginx alpine Linux 创建 'nginx' 服务,并使用从 Dockerfile 生成的自定义 docker 镜像创建我们的 python Django 容器。 +使用这个 `docker-compose` 文件脚本,我们将创建三个服务。使用 alpine Linux 版的 PostgreSQL 创建名为 `db` 的数据库服务,再次使用 alpine Linux 版的 Nginx 创建 `nginx` 服务,并使用从 Dockerfile 生成的自定义 docker 镜像创建我们的 python Django 容器。 - [![配置项目环境](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/5.png)][19] +[![配置项目环境](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/5.png)][19] - ### 配置 Django 项目 +#### 配置 Django 项目 -将 Django 项目文件复制到 'project' 目录。 +将 Django 项目文件复制到 `project` 目录。 ``` cd ~/django cp -r * ~/guide01/project/ ``` -进入 'project' 目录并编辑应用程序设置 'settings.py'。 +进入 `project` 目录并编辑应用程序设置 `settings.py`。 ``` cd ~/guide01/project/ @@ -279,29 +282,29 @@ vim hello_django/settings.py 注意: -我们将部署名为 'hello_django' 的简单 Django 应用程序。 +我们将部署名为 “hello_django” 的简单 Django 应用程序。 -在 'ALLOW_HOSTS' 行中,添加服务名称 'web'。 +在 `ALLOW_HOSTS` 行中,添加服务名称 `web`。 ``` ALLOW_HOSTS = ['web'] ``` -现在更改数据库设置,我们将使用 PostgreSQL 数据库,'db' 数据库作为服务运行,使用默认用户和密码。 +现在更改数据库设置,我们将使用 PostgreSQL 数据库来运行名为 `db` 的服务,使用默认用户和密码。 ``` DATABASES = {  -     'default': { -         'ENGINE': 'django.db.backends.postgresql_psycopg2', -         'NAME': 'postgres', -         'USER': 'postgres', -         'HOST': 'db', -         'PORT': 5432, -     } - } +    'default': { +        'ENGINE': 'django.db.backends.postgresql_psycopg2', +        'NAME': 'postgres', +        'USER': 'postgres', +        'HOST': 'db', +        'PORT': 5432, +    } +} ``` -至于 'STATIC_ROOT' 配置目录,将此行添加到文件行的末尾。 +至于 `STATIC_ROOT` 配置目录,将此行添加到文件行的末尾。 ``` STATIC_ROOT = os.path.join(BASE_DIR, 'static/') @@ -309,21 +312,21 @@ STATIC_ROOT = os.path.join(BASE_DIR, 'static/') 保存并退出。 - [![配置 Django 项目](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/6.png)][20] +[![配置 Django 项目](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/6.png)][20] 现在我们准备在 docker 容器下构建和运行 Django 项目。 ### 步骤 4 - 构建并运行 Docker 镜像 -在这一步中,我们想要使用 'guide01' 目录中的配置为我们的 Django 项目构建一个 Docker 镜像。 +在这一步中,我们想要使用 `guide01` 目录中的配置为我们的 Django 项目构建一个 Docker 镜像。 -进入 'guide01' 目录。 +进入 `guide01` 目录。 ``` cd ~/guide01/ ``` -现在使用 docker-compose 命令构建 docker 镜像。 +现在使用 `docker-compose` 命令构建 docker 镜像。 ``` docker-compose build @@ -331,7 +334,7 @@ docker-compose build [![运行 docker 镜像](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/7.png)][21] -启动 docker-compose 脚本中的所有服务。 +启动 `docker-compose` 脚本中的所有服务。 ``` docker-compose up -d @@ -348,7 +351,7 @@ docker-compose ps docker-compose images ``` -现在,你将在系统上运行三个容器并列出 Docker 镜像,如下所示。 +现在,你将在系统上运行三个容器,列出 Docker 镜像,如下所示。 [![docke-compose ps 命令](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/9.png)][23] @@ -356,17 +359,19 @@ docker-compose images ### 步骤 5 - 测试 -打开 Web 浏览器并使用端口 8000 键入服务器地址,我的是:http://ovh01:8000/ +打开 Web 浏览器并使用端口 8000 键入服务器地址,我的是:`http://ovh01:8000/`。 -现在你将获得默认的 Django 主页。 +现在你将看到默认的 Django 主页。 [![默认 Django 项目主页](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/10.png)][24] -接下来,通过在 URL 上添加 “/admin” 路径来测试管理页面。 +接下来,通过在 URL 上添加 `/admin` 路径来测试管理页面。 +``` http://ovh01:8000/admin/ +``` -然后你将会看到 Django admin 登录页面。 +然后你将会看到 Django 管理登录页面。 [![Django administration](https://www.howtoforge.com/images/docker_guide_dockerizing_python_django_application/11.png)][25] @@ -383,7 +388,7 @@ via: https://www.howtoforge.com/tutorial/docker-guide-dockerizing-python-django- 作者:[Muhammad Arul][a] 译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From bc409f2edb40f19360f73f88cc9d18e276ea271d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 12 Sep 2018 22:44:29 +0800 Subject: [PATCH 193/455] PUB:20170706 Docker Guide Dockerizing Python Django Application.md @MjSeven https://linux.cn/article-10006-1.html --- ...20170706 Docker Guide Dockerizing Python Django Application.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170706 Docker Guide Dockerizing Python Django Application.md (100%) diff --git a/translated/tech/20170706 Docker Guide Dockerizing Python Django Application.md b/published/20170706 Docker Guide Dockerizing Python Django Application.md similarity index 100% rename from translated/tech/20170706 Docker Guide Dockerizing Python Django Application.md rename to published/20170706 Docker Guide Dockerizing Python Django Application.md From 51901d7584d273e360d3ab3b609d2d5ebdb3d653 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 13 Sep 2018 00:31:44 +0800 Subject: [PATCH 194/455] PRF:20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @GraveAccent 恭喜你完成了第一篇翻译。 (校对中补充的内容,应该是选题 @lujun9972 的选题工具问题) --- ...ing In Chromium On Ubuntu Or Linux Mint.md | 69 +++++++++---------- 1 file changed, 32 insertions(+), 37 deletions(-) diff --git a/translated/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md b/translated/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md index d7a6d16fb5..53ec95d09b 100644 --- a/translated/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md +++ b/translated/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md @@ -1,48 +1,43 @@ -如何在 Ubuntu 或 Linux Mint 启用硬件加速的视频解码 +如何在 Ubuntu 或 Linux Mint 启用 Chromium 硬件加速的视频解码 ====== -你或许已经注意到了,在 Linux 上使用 Google Chrome 或 Chromium 浏览器在 YouTube 或其它类似网站观看高清视频会增加你的 CPU 使用率,如果你用的是笔记本,电脑会发热而且电池会很快用完。这是因为Chrome/Chromium(Firefox 也是如此,但是 Firefox 的问题没有办法解决)在 Linux 上不支持硬件加速的视频解码。 -**这篇文章讲述了如何在 Linux 环境安装带有 VA-API 补丁的 Chromium 开发版,它支持 GPU 加速的视频解码,可以显著减少观看在线高清视频时的 CPU 使用率,这篇教程只适用于 Intel 和 Nvidia 的显卡,我没有 ATI/AMD 的显卡可以试验,也没有使用过这几种显卡。** +你或许已经注意到了,在 Linux 上使用 Google Chrome 或 Chromium 浏览器在 YouTube 或其它类似网站观看高清视频会增加你的 CPU 使用率,如果你用的是笔记本,电脑会发热而且电池会很快用完。这是因为 Chrome/Chromium(Firefox 也是如此,但是 Firefox 的问题没有办法解决)在 Linux 上不支持硬件加速的视频解码。 -这是 Chromium 浏览器在 Ubuntu18.04 中,没有 GPU 加速视频解码时正在播放一个 1080p 的 YouTube 视频: +这篇文章讲述了如何在 Linux 环境安装带有 VA-API 补丁的 Chromium 开发版,它支持 GPU 加速的视频解码,可以显著减少观看在线高清视频时的 CPU 使用率,这篇教程只适用于 Intel 和 Nvidia 的显卡,我没有 ATI/AMD 的显卡可以试验,也没有使用过这几种显卡。 + +这是 Chromium 浏览器在 Ubuntu18.04 中,在没有 GPU 加速视频解码的情况下播放一个 1080p 的 YouTube 视频: ![](https://4.bp.blogspot.com/-KtUQni2PMvE/W3KlJ62yLLI/AAAAAAAABW4/NrNVFaTAkZ8AmwqWwRvWD6czT51ni-R-gCLcBGAs/s1600/chromium-default-no-accel.png) -这是带有 VA-API 补丁的 Chromium 浏览器在 Ubuntu18.04 中,GPU 加速视频解码时正在播放同样的 1080p 的 YouTube 视频: +这是带有 VA-API 补丁的 Chromium 浏览器在 Ubuntu18.04 中,在带有 GPU 加速视频解码的情况下播放同样的 1080p 的 YouTube 视频: ![](https://4.bp.blogspot.com/-0c-wb4UNhW8/W3KlQBfeFnI/AAAAAAAABW8/WVUAYzM6hA8wRTlCcrPXPMpoXoFVR6b1QCLcBGAs/s1600/chromium-hardware-acceleration-enabled.png) -注意截图中的 CPU 使用率。两张截图都是在我老旧而依然强大的桌面上捕捉的。在我的笔记本上,没有硬件加速的 Chromium 带来更高的CPU使用率。 +注意截图中的 CPU 使用率。两张截图都是在我老旧而依然强大的桌面计算机上捕捉的。在我的笔记本电脑上,没有硬件加速的 Chromium 带来更高的 CPU 使用率。 -"只需 VAAPI 即可在 Linux 启用 VAVDA,VAVEA 和 VAJDA" 这篇文章在一年多以前就提交给了Chromium,但是它还没有合并请求。 +“只需 VA-API 即可在 Linux 启用 VAVDA、VAVEA 和 VAJDA” 这个[补丁][3]在一年多以前就提交给了 Chromium,但是它还没有合并。 -Chrome有一个选项可以覆盖软件渲染列表( - -`#ignore-gpu-blacklist` - -),但是这个选项不能启用硬件加速的视频解码。启用这个选项以后,你或许会在访问 - -`chrome://gpu` - -时发现这些信息:“_Video Decode: Hardware accelerated_ “,然而这个并不意味着真的有效。在 YouTube 打开一个高清视频并用工具查看CPU使用率如 - -`htop` - -(这是我在以上截图中用来查看 CPU 使用率的)。因为 GPU 视频解码没有真的被启用,你应该看到较高的 CPU 使用率。下面有一个部分是关于你是否真的在使用硬件加速的视频解码的。 +Chrome 有一个选项可以覆盖软件渲染列表(`#ignore-gpu-blacklist`),但是这个选项不能启用硬件加速的视频解码。启用这个选项以后,你或许会在访问 `chrome://gpu` 时发现这些信息:“_Video Decode: Hardware accelerated_ “,然而这个并不意味着真的可以工作。在 YouTube 打开一个高清视频并用诸如 `htop` 的工具查看 CPU 使用率(这是我在以上截图中用来查看 CPU 使用率的)。因为 GPU 视频解码没有真的被启用,你应该看到较高的 CPU 使用率。下面有一个部分是关于检查你是否真的在使用硬件加速的视频解码的。 **文中使用的 Chromium 浏览器 Ubuntu 版启用 VA-API 的补丁在[这个地址][1]可以获得** ### 在 Ubuntu 和 Linux Mint 安装和使用带有 VA-API 支持的 Chromium 浏览器 -**每个人都该知道 Chromium 开发版本没有理想中那么稳定。所以你可能发现 bug,它可能会发生崩溃等情况。它现在可能正常运行,但是谁知道几次更新以后会发生什么。** +每个人都该知道 Chromium 开发版本没有理想中那么稳定。所以你可能发现 bug,它可能会发生崩溃等情况。它现在可能正常运行,但是谁知道几次更新以后会发生什么。 -**还有,如果你想启用 Widevine 支持(这样你才能观看 Netflix 视频和 YouTube 付费视频),Chromium dev 分支 PPA 要求你执行一些额外步骤。 ** **如果你想要一些功能,比如同步,也是如此**(需要注册 API key还要在你的系统上设置好)。执行这些任务的说明在本文中被详细解释了。 +还有,如果你想启用 Widevine 支持(这样你才能观看 Netflix 视频和 YouTube 付费视频),Chromium dev 分支 PPA 要求你执行一些额外步骤。 如果你想要一些功能,比如同步,也是如此(需要注册 API 密钥还要在你的系统上设置好)。执行这些任务的说明在 [Chromium 开发版本的 PPA][4] 中有详细解释。 -带有 VA-API 补丁的 Chromium 在其它Linux发行版本也可以获得,但是这里选择 Ubuntu。 +对于 Nvidia 显卡,vdpau 视频驱动程序需要更新以便显示 vaQuerySurfaceAttributes。所以 Nvidia 需要使用打过补丁的 vdpau-va-driver。值得庆幸的是,Chromium-dev PPA 提供了这个打过补丁的包。 + +带有 VA-API 补丁的 Chromium 也可用于其它 Linux 发行版,在第三方仓库,比如说 [Arch Linux][5](对于 Nvidia 你需要[这个][6]补丁过的 libva-vdpau-driver)。如果你不使用 Ubuntu 或 Linux Mint,你得自己找那些包。 + +#### 1、安装带有 VA-API 补丁的 Chromium + +有一个带 VA-API 补丁的 Chromium Beta PPA,但是它缺少适用于 Ubuntu 18.04 的 vdpau-video。如果你需要,你可以使用这个 [Beta PPA][7],而不是我在下面的步骤中使用 [Dev PPA][8],不过如果你使用 Nvidia 显卡,你需要从这个 Dev PPA 中下载安装 vdpau-va-driver,并确认 Ubuntu/Linux Mint 不更新这个包(有点复杂,如果你准备根据下面步骤使用 Dev PPA 的话,不需要手动做这些)。 + +你可以添加 [Chromium 开发分支 PPA][4],并在 Ubuntu 或 Linux Mint(及其它基于 Ubuntu 的发行版,如 elementary,以及 Ubuntu 或 Linux Mint 的风味版,如 Xubuntu、Kubuntu、Ubuntu MATE、Linux Mint MATE 等等)上安装最新的 Chromium 浏览器开发版: -**1\. 安装带有 VA-API 补丁的 Chromium ** -有一个带 VA-API 补丁的 Chromium Beta,但是它缺少适用于 Ubuntu 18.04 的 vdpau-video。 ``` sudo add-apt-repository ppa:saiarcot895/chromium-dev sudo apt-get update @@ -50,45 +45,45 @@ sudo apt install chromium-browser ``` -**2\. 安装 VA-API 驱动** +#### 2、安装 VA-API 驱动 + +对于 Intel 的显卡,你需要安装 `i965-va-driver` 这个包(它可能早就安装好了) -对于Intel的显卡,你需要安装 `i965-va-driver` 这个包(它可能早就安装好了) ``` sudo apt install i965-va-driver ``` -对于 Nvidia 的显卡(在开源和闭源的 Nvidia 驱动上,它应该都有效), 安装`vdpau-va-driver` : +对于 Nvidia 的显卡(在开源的 Nouveau 驱动和闭源的 Nvidia 驱动上,它应该都有效), 安装 `vdpau-va-driver`: + ``` sudo apt install vdpau-va-driver ``` -**3\. 在 Chromium 启用硬件加速视频选项** +#### 3、在 Chromium 启用硬件加速视频选项 复制这串地址,粘贴进 Chromium 的 URL 栏: `chrome://flags/#enable-accelerated-video` (或者在 `chrome://flags` 搜索 `Hardware-accelerated video` )并启用它,然后重启 Chromium 浏览器。 在默认的 Google Chrome / Chromium 版本,这个选项不可用,但是你可以在启用了 VP-API 的 Chromium 版本启用它。 -**4\. 安装 [h264ify][2] Chrome 扩展** +#### 4、安装 [h264ify][2] Chrome 扩展 YouTube(可能还有其它一些网址也是如此)默认使用 VP8 或 VP9 编码解码器,许多 GPU 不支持这种编码解码器的硬件解码。h264ify 会强制 YouTube 使用大多数 GPU 都支持的 H.264 而不是 VP8/VP9。 这个扩展还能阻塞 60fps 的视频,对低性能机器有用。 -你可以点击这个视频并且选择 `Stats for nerds` 以查看编码解码器,如果启用了 h264ify 扩展,你可以看到编码解码器是 avc / mp4a。如果没有启用,编码解码器应该是 vp09 / opus。 +你可以在视频上右键点击,并且选择 `Stats for nerds` 以查看 Youtube 视频所使用额编码解码器,如果启用了 h264ify 扩展,你可以看到编码解码器是 avc / mp4a。如果没有启用,编码解码器应该是 vp09 / opus。 ### 如何检查 Chromium 是否在使用 GPU 视频解码 -在 YouTube 打开一个视频,然后,在 Chromium 打开一个新的标签页并将以下地址输入 URL 栏: +在 YouTube 打开一个视频,然后,在 Chromium 打开一个新的标签页并将以下地址输入 URL 栏:`chrome://media-internals`。 - `chrome://media-internals` - -在 `chrome://media-internals` 标签页中,点击视频的URL(为了展开它), 往下滚动查看 `Player Properties` 的下面,你应该可以找到 `video_decoder` 属性。如果`video_decoder` 的值是 `GpuVideoDecoder` ,这说明当前在另一个标签页播放的 YouTube 视频正在使用硬件加速的的视频解码。 +在 `chrome://media-internals` 标签页中,点击视频的 URL(为了展开它), 往下滚动查看 `Player Properties` 的下面,你应该可以找到 `video_decoder` 属性。如果`video_decoder` 的值是 `GpuVideoDecoder` ,这说明当前在另一个标签页播放的 YouTube 视频正在使用硬件加速的的视频解码。 ![](https://4.bp.blogspot.com/-COBJWVT_Y0Q/W3KnG7AeHsI/AAAAAAAABXM/W2XAJA_S0BIHug4eQKTMOdIfXHhgkXhhQCLcBGAs/s1600/chromium-gpuvideodecoder-linux.png) 如果它显示的是 `FFmpegVideoDecoder` 或 `VpxVideoDecoder` ,说明加速视频解码无效或者你忘记安装或禁用了 h264ify 这个 Chrome 扩展。 -如果无效,你可以通过在命令行运行 `chromium-browser` ,通过查看是否有 VA-API 相关的错误显示出来以调试。你也可以运行`vainfo` (在 Ubuntu 或 Linux Mint 安装:`sudo apt install vainfo`)和 `vdpauinfo` (对于 Nvidia,在 Ubuntu 或 Linux Mint 安装:`sudo apt install vdpauinfo`)并且查看是否有显示任何错误。 +如果无效,你可以通过在命令行运行 `chromium-browser` ,通过查看是否有 VA-API 相关的错误显示出来以调试。你也可以运行 `vainfo`(在 Ubuntu 或 Linux Mint 上安装:`sudo apt install vainfo`)和 `vdpauinfo` (对于 Nvidia,在 Ubuntu 或 Linux Mint 上安装:`sudo apt install vdpauinfo`)并且查看是否有显示任何错误。 -------------------------------------------------------------------------------- @@ -97,7 +92,7 @@ via: https://www.linuxuprising.com/2018/08/how-to-enable-hardware-accelerated.ht 作者:[Logix][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[GraveAccent](https://github.com/GraveAccent) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 9955858955a0e82b234e8dda99ebd95fa53d4848 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 13 Sep 2018 00:33:30 +0800 Subject: [PATCH 195/455] PUB:20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @GraveAccent 本文首发地址: https://linux.cn/article-10007-1.html 您的 LCTT 专页地址: https://linux.cn/lctt/GraveAccent 请到通证激励平台注册获取 LCCN: https://lctt.linux.cn/ --- ...elerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md (100%) diff --git a/translated/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md b/published/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md similarity index 100% rename from translated/tech/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md rename to published/20180815 How To Enable Hardware Accelerated Video Decoding In Chromium On Ubuntu Or Linux Mint.md From 91c6ad94ade444a43fb8418765835a54e5688365 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 13 Sep 2018 08:33:25 +0800 Subject: [PATCH 196/455] PRF:20180905 8 great Python libraries for side projects.md @ucasFL --- ...5 8 great Python libraries for side projects.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/translated/tech/20180905 8 great Python libraries for side projects.md b/translated/tech/20180905 8 great Python libraries for side projects.md index 26eb3e9a23..f8d05dc41a 100644 --- a/translated/tech/20180905 8 great Python libraries for side projects.md +++ b/translated/tech/20180905 8 great Python libraries for side projects.md @@ -1,6 +1,8 @@ -8 个用于业余项目side projects的优秀 Python 库 +8 个用于业余项目的优秀 Python 库 ====== +> 这些库可以使你更容易构架个人项目。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python-programming-code-keyboard.png?itok=fxiSpmnd) 在 Python/Django 的世界里有这样一个谚语:为语言而来,为社区而留。对绝大多数人来说的确是这样的,但是,还有一件事情使得我们一直停留在 Python 的世界里,不愿离开,那就是我们可以很容易地利用一顿午餐或晚上几个小时的时间,把一个想法快速地实现出来。 @@ -9,7 +11,7 @@ ### 在数据库中即时保存数据:Dataset -当我们想要在不知道最终数据库表长什么样的情况下,快速收集数据并保存到数据库中的时候,[Dataset][1] 库将是我们的最佳选择。Dataset 库有一个简单但功能强大的 API,因此我们可以很容易的把数据保存下来,之后再进行排序。 +当我们想要在不知道最终数据库表长什么样的情况下,快速收集数据并保存到数据库中的时候,[Dataset][1] 库将是我们的最佳选择。Dataset 库有一个简单但功能强大的 API,因此我们可以很容易的把数据保存下来,之后再进行整理。 Dataset 建立在 SQLAlchemy 之上,所以如果需要对它进行扩展,你会感到非常熟悉。使用 Django 内建的 [inspectdb][2] 管理命令可以很容易地把底层数据库模型导入 Django 中,这使得和现有数据库一同工作不会出现任何障碍。 @@ -35,13 +37,13 @@ Dataset 建立在 SQLAlchemy 之上,所以如果需要对它进行扩展,你 ### 把 CSV 文件转换到 API 中:DataSette -[DataSette][8] 是一个神奇的工具,它可以很容易地把 CSV 文件转换进全特性只读 REST JSON API,同时,不要把它和 Dataset 库混淆。Datasette 有许多特性,包括创建图表和 geo(用于创建交互式图表),并且很容易通过容器或第三方网络主机进行部署。 +[DataSette][8] 是一个神奇的工具,它可以很容易地把 CSV 文件转换为全特性的只读 REST JSON API,同时,不要把它和 Dataset 库混淆。Datasette 有许多特性,包括创建图表和 geo(用于创建交互式地图),并且很容易通过容器或第三方网络主机进行部署。 ### 处理环境变量等:Envparse -如果你不想在源代码中保存 API 密钥、数据库凭证或其他敏感信息,那么你便需要解析环境变量,这时候 [envparse][9] 是最好的选择。Envparse 能够处理环境变量、ENV 文件、变量类型,甚至还可以进行预处理和后处理(例如,你想要确保变量名总是大写或小写的) +如果你不想在源代码中保存 API 密钥、数据库凭证或其他敏感信息,那么你便需要解析环境变量,这时候 [envparse][9] 是最好的选择。Envparse 能够处理环境变量、ENV 文件、变量类型,甚至还可以进行预处理和后处理(例如,你想要确保变量名总是大写或小写的)。 -有什么你最喜欢的用于业余项目side projects的 Python 库不在这个列表中吗?请在评论中和我们分享。 +有什么你最喜欢的用于业余项目的 Python 库不在这个列表中吗?请在评论中和我们分享。 -------------------------------------------------------------------------------- @@ -50,7 +52,7 @@ via: https://opensource.com/article/18/9/python-libraries-side-projects 作者:[Jeff Triplett][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[ucasFL](https://github.com/ucasFL) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From a1734d96bfb24d4fdeb41fcabaad268f20110be7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 13 Sep 2018 08:33:57 +0800 Subject: [PATCH 197/455] PUB:20180905 8 great Python libraries for side projects.md @ucasFL https://linux.cn/article-10008-1.html --- .../20180905 8 great Python libraries for side projects.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180905 8 great Python libraries for side projects.md (100%) diff --git a/translated/tech/20180905 8 great Python libraries for side projects.md b/published/20180905 8 great Python libraries for side projects.md similarity index 100% rename from translated/tech/20180905 8 great Python libraries for side projects.md rename to published/20180905 8 great Python libraries for side projects.md From 80359ffc9578254b170f3e9d09383610b93f212e Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 13 Sep 2018 08:56:53 +0800 Subject: [PATCH 198/455] translated --- ...pen source alternatives to Flash Player.md | 58 ------------------- ...pen source alternatives to Flash Player.md | 56 ++++++++++++++++++ 2 files changed, 56 insertions(+), 58 deletions(-) delete mode 100644 sources/tech/20180906 Two open source alternatives to Flash Player.md create mode 100644 translated/tech/20180906 Two open source alternatives to Flash Player.md diff --git a/sources/tech/20180906 Two open source alternatives to Flash Player.md b/sources/tech/20180906 Two open source alternatives to Flash Player.md deleted file mode 100644 index 831a96ab2f..0000000000 --- a/sources/tech/20180906 Two open source alternatives to Flash Player.md +++ /dev/null @@ -1,58 +0,0 @@ -translating---geekpi - -Two open source alternatives to Flash Player -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bulb-light-energy-power-idea.png?itok=zTEEmTZB) - -In July 2017, Adobe sounded the [death knell][1] for its Flash Media Player, announcing it would end support for the once-ubiquitous online video player in 2020. In truth, however, Flash has been on the decline for the past eight years following a rash of zero-day attacks that damaged its reputation. Its future dimmed after Apple announced in 2010 it would not support the technology, and its demise accelerated in 2016 after Google stopped enabling Flash by default (in favor of HTML5) in the Chrome browser. - -Even so, Adobe is still issuing monthly updates for the software, which has slipped from being used on 28.5% of all websites in 2011 to [only 4.4.%][2] as of August 2018. More evidence of Flash’s decline: Google director of engineering [Parisa Tabriz said][3] the number of Chrome users who access Flash content via the browser has declined from 80% in 2014 to under eight percent in 2018. - -Although few* video creators are publishing in Flash format today, there are still a lot of Flash videos out there that people will want to access for years to come. Given that the official application’s days are numbered, open source software creators have a great opportunity to step in with alternatives to Adobe Flash Media Player. Two of those applications are Lightspark and GNU Gnash. Neither are perfect substitutions, but help from willing contributors could make them viable alternatives. - -### Lightspark - -[Lightspark][4] is a Flash Player alternative for Linux machines. While it’s still in alpha, development has accelerated since Adobe announced it would sunset Flash in 2017. According to its website, Lightspark implements about 60% of the Flash APIs and [works][5] on many leading websites including BBC News, Google Play Music, and Amazon Music. - -Lightspark is written in C++/C and licensed under [LGPLv3][6]. The project lists 41 contributors and is actively soliciting bug reports and other contributions. For more information, check out its [GitHub repository][5]. - -### GNU Gnash - -[GNU Gnash][7] is a Flash Player for GNU/Linux operating systems including Ubuntu, Fedora, and Debian. It works as standalone software and as a plugin for the Firefox and Konqueror browsers. - -Gnash’s main drawback is that it doesn’t support the latest versions of Flash files—it supports most Flash SWF v7 features, some v8 and v9 features, and offers no support for v10 files. It’s in beta release, and since it’s licensed under the [GNU GPLv3 or later][8], you can help contribute to modernizing it. Access its [project page][9] for more information. - -### Want to create Flash? - -*Just because most people aren't publishing Flash videos these days, that doesn't mean there will never, ever be a need to create SWF files. If you find yourself in that position, these two open source tools might help: - - * [Motion-Twin ActionScript 2 Compiler][10] (MTASC): A command-line compiler that can generate SWF files without Adobe Animate (the current iteration of Adobe's video-creator software). - * [Ming][11]: A library written in C that can generate SWF files. It also contains some [utilities][12] you can use to work with Flash files. - - - --------------------------------------------------------------------------------- - -via: https://opensource.com/alternatives/flash-media-player - -作者:[Opensource.com][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com -[1]: https://theblog.adobe.com/adobe-flash-update/ -[2]: https://w3techs.com/technologies/details/cp-flash/all/all -[3]: https://www.bleepingcomputer.com/news/security/google-chrome-flash-usage-declines-from-80-percent-in-2014-to-under-8-percent-today/ -[4]: http://lightspark.github.io/ -[5]: https://github.com/lightspark/lightspark/wiki/Site-Support -[6]: https://github.com/lightspark/lightspark/blob/master/COPYING -[7]: https://www.gnu.org/software/gnash/ -[8]: http://www.gnu.org/licenses/gpl-3.0.html -[9]: http://savannah.gnu.org/projects/gnash/ -[10]: http://tech.motion-twin.com/mtasc.html -[11]: http://www.libming.org/ -[12]: http://www.libming.org/WhatsIncluded diff --git a/translated/tech/20180906 Two open source alternatives to Flash Player.md b/translated/tech/20180906 Two open source alternatives to Flash Player.md new file mode 100644 index 0000000000..0126bf950a --- /dev/null +++ b/translated/tech/20180906 Two open source alternatives to Flash Player.md @@ -0,0 +1,56 @@ +Flash Player 的两种开源替代方案 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bulb-light-energy-power-idea.png?itok=zTEEmTZB) + +2017 年 7 月,Adobe 为 Flash Media Player 敲响了[丧钟][1],宣布将在 2020 年终止对曾经无处不在的在线视频播放器的支持。但事实上,在一系列损害了其声誉的零日攻击后,Flash 的份额在过去的 8 年一直在下跌。苹果公司在 2010 年宣布它不会支持这项技术后,其未来趋于黯淡,并且在谷歌停止在 Chrome 浏览器中默认启用 Flash(支持 HTML5)后,它的消亡在 2016 年加速。 + +即便如此,Adobe 仍然每月发布该软件的更新,截至 2018 年 8 月,它在网站的使用率从 2011 年的 28.5% 下降到[仅 4.4%] [2]。还有更多证据表明 Flash 的下滑:谷歌工程总监 [Parisa Tabriz 说][3]通过浏览器访问 Flash 内容的 Chrome 用户数量从 2014 年的 80% 下降到 2018 年的 8%。 + +尽管如今很少有视频创作者以 Flash 格式发布,但仍有很多人们希望在未来几年内访问的 Flash 视频。鉴于官方支持的日期已经屈指可数,开源软件创建者有很好的机会介入 Adobe Flash Media Player 的替代品。这其中两个应用是 Lightspark 和 GNU Gnash。它们都不是完美的替代品,但来自贡献者的帮助可以使它们成为可行的替代品。 + +### Lightspark + +[Lightspark][4] 是 Linux 上的 Flash Player 替代品。虽然它仍处于 alpha 状态,但自从 Adobe 在 2017 宣布废弃 Adobe 以来,开发速度已经加快。据其网站称,Lightspark 实现了 60% 的 Flash API,可在许多流行网站包括 BBC 新闻、Google Play 音乐和亚马逊音乐上[使用][5]。 + +Lightspark 是用 C++/C 编写的,并在 [LGPLv3][6] 下许可。该项目列出了 41 个贡献者,并正在积极征求错误报告和其他贡献。有关更多信息,请查看其[ GitHub 仓库][5]。 + +### GNU Gnash + +[GNU Gnash][7] 是一个用于 GNU/Linux 操作系统,包括 Ubuntu、Fedora 和 Debian 的 Flash Player。它作为独立软件和插件可用于 Firefox 和 Konqueror 浏览器中。 + +Gnash 的主要缺点是它不支持最新版本的 Flash 文件 - 它支持大多数 Flash SWF v7 功能,一些 v8 和 v9 功能,不支持 v10 文件。它处于测试阶段,由于它在[ GNU GPLv3 或更高版本][8]下许可,因此你可以帮助实现它的现代化。访问其[项目页面][9]获取更多信息。 + +### 想要创建Flash吗? + +* 仅因为大多数人都不会发布 Flash 视频,但这并不意味着永远不需要创建 SWF 文件。如果你发现自己需要,这两个开源工具可能会有所帮助: + + * [Motion-Twin ActionScript 2 编译器][10](MTASC):一个命令行编译器,它可以在没有 Adobe Animate(Adobe 当前的视频创建软件)的情况下生成 SWF 文件。 +  * [Ming][11]:用 C 编写的可以生成 SWF 文件的库。它还包含一些可用于处理 Flash 的[程序][12]。 + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/alternatives/flash-media-player + +作者:[Opensource.com][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com +[1]: https://theblog.adobe.com/adobe-flash-update/ +[2]: https://w3techs.com/technologies/details/cp-flash/all/all +[3]: https://www.bleepingcomputer.com/news/security/google-chrome-flash-usage-declines-from-80-percent-in-2014-to-under-8-percent-today/ +[4]: http://lightspark.github.io/ +[5]: https://github.com/lightspark/lightspark/wiki/Site-Support +[6]: https://github.com/lightspark/lightspark/blob/master/COPYING +[7]: https://www.gnu.org/software/gnash/ +[8]: http://www.gnu.org/licenses/gpl-3.0.html +[9]: http://savannah.gnu.org/projects/gnash/ +[10]: http://tech.motion-twin.com/mtasc.html +[11]: http://www.libming.org/ +[12]: http://www.libming.org/WhatsIncluded From 6b402c865cfe86b9465b1ab739f4c0be91037eb4 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 13 Sep 2018 09:05:11 +0800 Subject: [PATCH 199/455] translating --- .../tech/20180720 How to build a URL shortener with Apache.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180720 How to build a URL shortener with Apache.md b/sources/tech/20180720 How to build a URL shortener with Apache.md index ede90814af..2599b9ecca 100644 --- a/sources/tech/20180720 How to build a URL shortener with Apache.md +++ b/sources/tech/20180720 How to build a URL shortener with Apache.md @@ -1,3 +1,5 @@ +translating---geekpi + How to build a URL shortener with Apache ====== From b31c45535742b1ffd476ec46b32c4ec1a4584b01 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 13 Sep 2018 15:00:29 +0800 Subject: [PATCH 200/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20build?= =?UTF-8?q?=20rpm=20packages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180912 How to build rpm packages.md | 395 ++++++++++++++++++ 1 file changed, 395 insertions(+) create mode 100644 sources/tech/20180912 How to build rpm packages.md diff --git a/sources/tech/20180912 How to build rpm packages.md b/sources/tech/20180912 How to build rpm packages.md new file mode 100644 index 0000000000..97b630707d --- /dev/null +++ b/sources/tech/20180912 How to build rpm packages.md @@ -0,0 +1,395 @@ +How to build rpm packages +====== + +Save time and effort installing files and scripts across multiple hosts. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1) + +I have used rpm-based package managers to install software on Red Hat and Fedora Linux since I started using Linux more than 20 years ago. I have used the **rpm** program itself, **yum** , and **DNF** , which is a close descendant of yum, to install and update packages on my Linux hosts. The yum and DNF tools are wrappers around the rpm utility that provide additional functionality, such as the ability to find and install package dependencies. + +Over the years I have created a number of Bash scripts, some of which have separate configuration files, that I like to install on most of my new computers and virtual machines. It reached the point that it took a great deal of time to install all of these packages, so I decided to automate that process by creating an rpm package that I could copy to the target hosts and install all of these files in their proper locations. Although the **rpm** tool was formerly used to build rpm packages, that function was removed and a new tool,was created to build new rpms. + +When I started this project, I found very little information about creating rpm packages, but I managed to find a book, Maximum RPM, that helped me figure it out. That book is now somewhat out of date, as is the vast majority of information I have found. It is also out of print, and used copies go for hundreds of dollars. The online version of [Maximum RPM][1] is available at no charge and is kept up to date. The [RPM website][2] also has links to other websites that have a lot of documentation about rpm. What other information there is tends to be brief and apparently assumes that you already have a good deal of knowledge about the process. + +In addition, every one of the documents I found assumes that the code needs to be compiled from sources as in a development environment. I am not a developer. I am a sysadmin, and we sysadmins have different needs because we don’t—or we shouldn’t—compile code to use for administrative tasks; we should use shell scripts. So we have no source code in the sense that it is something that needs to be compiled into binary executables. What we have is a source that is also the executable. + +For the most part, this project should be performed as the non-root user student. Rpms should never be built by root, but only by non-privileged users. I will indicate which parts should be performed as root and which by a non-root, unprivileged user. + +### Preparation + +First, open one terminal session and `su` to root. Be sure to use the `-` option to ensure that the complete root environment is enabled. I do not believe that sysadmins should use `sudo` for any administrative tasks. Find out why in my personal blog post: [Real SysAdmins don’t sudo][3]. + +``` +[student@testvm1 ~]$ su - +Password: +[root@testvm1 ~]# +``` + +Create a student user that can be used for this project and set a password for that user. + +``` +[root@testvm1 ~]# useradd -c "Student User" student +[root@testvm1 ~]# passwd student +Changing password for user student. +New password: +Retype new password: +passwd: all authentication tokens updated successfully. +[root@testvm1 ~]# +``` + +Building rpm packages requires the `rpm-build` package, which is likely not already installed. Install it now as root. Note that this command will also install several dependencies. The number may vary, depending upon the packages already installed on your host; it installed a total of 17 packages on my test VM, which is pretty minimal. + +``` +dnf install -y rpm-build +``` + +The rest of this project should be performed as the user student unless otherwise explicitly directed. Open another terminal session and use `su` to switch to that user to perform the rest of these steps. Download a tarball that I have prepared of a development directory structure, utils.tar, from GitHub using the following command: + +``` +wget https://github.com/opensourceway/how-to-rpm/raw/master/utils.tar +``` + +This tarball includes all of the files and Bash scripts that will be installed by the final rpm. There is also a complete spec file, which you can use to build the rpm. We will go into detail about each section of the spec file. + +As user student, using your home directory as your present working directory (pwd), untar the tarball. + +``` +[student@testvm1 ~]$ cd ; tar -xvf utils.tar +``` + +Use the `tree` command to verify that the directory structure of ~/development and the contained files looks like the following output: + +``` +[student@testvm1 ~]$ tree development/ +development/ +├── license +│   ├── Copyright.and.GPL.Notice.txt +│   └── GPL_LICENSE.txt +├── scripts +│   ├── create_motd +│   ├── die +│   ├── mymotd +│   └── sysdata +└── spec +    └── utils.spec + +3 directories, 7 files +[student@testvm1 ~]$ +``` + +The `mymotd` script creates a “Message Of The Day” data stream that is sent to stdout. The `create_motd` script runs the `mymotd` scripts and redirects the output to the /etc/motd file. This file is used to display a daily message to users who log in remotely using SSH. + +The `die` script is my own script that wraps the `kill` command in a bit of code that can find running programs that match a specified string and kill them. It uses `kill -9` to ensure that they cannot ignore the kill message. + +The `sysdata` script can spew tens of thousands of lines of data about your computer hardware, the installed version of Linux, all installed packages, and the metadata of your hard drives. I use it to document the state of a host at a point in time. I can later use it for reference. I used to do this to maintain a record of hosts that I installed for customers. + +You may need to change ownership of these files and directories to student.student. Do this, if necessary, using the following command: + +``` +chown -R student.student development +``` + +Most of the files and directories in this tree will be installed on Fedora systems by the rpm you create during this project. + +### Creating the build directory structure + +The `rpmbuild` command requires a very specific directory structure. You must create this directory structure yourself because no automated way is provided. Create the following directory structure in your home directory: + +``` +~ ─ rpmbuild +    ├── RPMS +    │   └── noarch +    ├── SOURCES +    ├── SPECS +    └── SRPMS +``` + +We will not create the rpmbuild/RPMS/X86_64 directory because that would be architecture-specific for 64-bit compiled binaries. We have shell scripts that are not architecture-specific. In reality, we won’t be using the SRPMS directory either, which would contain source files for the compiler. + +### Examining the spec file + +Each spec file has a number of sections, some of which may be ignored or omitted, depending upon the specific circumstances of the rpm build. This particular spec file is not an example of a minimal file required to work, but it is a good example of a moderately complex spec file that packages files that do not need to be compiled. If a compile were required, it would be performed in the `%build` section, which is omitted from this spec file because it is not required. + +#### Preamble + +This is the only section of the spec file that does not have a label. It consists of much of the information you see when the command `rpm -qi [Package Name]` is run. Each datum is a single line which consists of a tag, which identifies it and text data for the value of the tag. + +``` +############################################################################### +# Spec file for utils +################################################################################ +# Configured to be built by user student or other non-root user +################################################################################ +# +Summary: Utility scripts for testing RPM creation +Name: utils +Version: 1.0.0 +Release: 1 +License: GPL +URL: http://www.both.org +Group: System +Packager: David Both +Requires: bash +Requires: screen +Requires: mc +Requires: dmidecode +BuildRoot: ~/rpmbuild/ + +# Build with the following syntax: +# rpmbuild --target noarch -bb utils.spec +``` + +Comment lines are ignored by the `rpmbuild` program. I always like to add a comment to this section that contains the exact syntax of the `rpmbuild` command required to create the package. The Summary tag is a short description of the package. The Name, Version, and Release tags are used to create the name of the rpm file, as in utils-1.00-1.rpm. Incrementing the release and version numbers lets you create rpms that can be used to update older ones. + +The License tag defines the license under which the package is released. I always use a variation of the GPL. Specifying the license is important to clarify the fact that the software contained in the package is open source. This is also why I included the license and GPL statement in the files that will be installed. + +The URL is usually the web page of the project or project owner. In this case, it is my personal web page. + +The Group tag is interesting and is usually used for GUI applications. The value of the Group tag determines which group of icons in the applications menu will contain the icon for the executable in this package. Used in conjunction with the Icon tag (which we are not using here), the Group tag allows adding the icon and the required information to launch a program into the applications menu structure. + +The Packager tag is used to specify the person or organization responsible for maintaining and creating the package. + +The Requires statements define the dependencies for this rpm. Each is a package name. If one of the specified packages is not present, the DNF installation utility will try to locate it in one of the defined repositories defined in /etc/yum.repos.d and install it if it exists. If DNF cannot find one or more of the required packages, it will throw an error indicating which packages are missing and terminate. + +The BuildRoot line specifies the top-level directory in which the `rpmbuild` tool will find the spec file and in which it will create temporary directories while it builds the package. The finished package will be stored in the noarch subdirectory that we specified earlier. The comment showing the command syntax used to build this package includes the option `–target noarch`, which defines the target architecture. Because these are Bash scripts, they are not associated with a specific CPU architecture. If this option were omitted, the build would be targeted to the architecture of the CPU on which the build is being performed. + +The `rpmbuild` program can target many different architectures, and using the `--target` option allows us to build architecture-specific packages on a host with a different architecture from the one on which the build is performed. So I could build a package intended for use on an i686 architecture on an x86_64 host, and vice versa. + +Change the packager name to yours and the URL to your own website if you have one. + +#### %description + +The `%description` section of the spec file contains a description of the rpm package. It can be very short or can contain many lines of information. Our `%description` section is rather terse. + +``` +%description +A collection of utility scripts for testing RPM creation. +``` + +#### %prep + +The `%prep` section is the first script that is executed during the build process. This script is not executed during the installation of the package. + +This script is just a Bash shell script. It prepares the build directory, creating directories used for the build as required and copying the appropriate files into their respective directories. This would include the sources required for a complete compile as part of the build. + +The $RPM_BUILD_ROOT directory represents the root directory of an installed system. The directories created in the $RPM_BUILD_ROOT directory are fully qualified paths, such as /user/local/share/utils, /usr/local/bin, and so on, in a live filesystem. + +In the case of our package, we have no pre-compile sources as all of our programs are Bash scripts. So we simply copy those scripts and other files into the directories where they belong in the installed system. + +``` +%prep +################################################################################ +# Create the build tree and copy the files from the development directories    # +# into the build tree.                                                         # +################################################################################ +echo "BUILDROOT = $RPM_BUILD_ROOT" +mkdir -p $RPM_BUILD_ROOT/usr/local/bin/ +mkdir -p $RPM_BUILD_ROOT/usr/local/share/utils + +cp /home/student/development/utils/scripts/* $RPM_BUILD_ROOT/usr/local/bin +cp /home/student/development/utils/license/* $RPM_BUILD_ROOT/usr/local/share/utils +cp /home/student/development/utils/spec/* $RPM_BUILD_ROOT/usr/local/share/utils + +exit +``` + +Note that the exit statement at the end of this section is required. + +#### %files + +This section of the spec file defines the files to be installed and their locations in the directory tree. It also specifies the file attributes and the owner and group owner for each file to be installed. The file permissions and ownerships are optional, but I recommend that they be explicitly set to eliminate any chance for those attributes to be incorrect or ambiguous when installed. Directories are created as required during the installation if they do not already exist. + +``` +%files +%attr(0744, root, root) /usr/local/bin/* +%attr(0644, root, root) /usr/local/share/utils/* +``` + +#### %pre + +This section is empty in our lab project’s spec file. This would be the place to put any scripts that are required to run during installation of the rpm but prior to the installation of the files. + +#### %post + +This section of the spec file is another Bash script. This one runs after the installation of files. This section can be pretty much anything you need or want it to be, including creating files, running system commands, and restarting services to reinitialize them after making configuration changes. The `%post` script for our rpm package performs some of those tasks. + +``` +%post +################################################################################ +# Set up MOTD scripts                                                          # +################################################################################ +cd /etc +# Save the old MOTD if it exists +if [ -e motd ] +then +   cp motd motd.orig +fi +# If not there already, Add link to create_motd to cron.daily +cd /etc/cron.daily +if [ ! -e create_motd ] +then +   ln -s /usr/local/bin/create_motd +fi +# create the MOTD for the first time +/usr/local/bin/mymotd > /etc/motd +``` + +The comments included in this script should make its purpose clear. + +#### %postun + +This section contains a script that would be run after the rpm package is uninstalled. Using rpm or DNF to remove a package removes all of the files listed in the `%files` section, but it does not remove files or links created by the `%post` section, so we need to handle that in this section. + +This script usually consists of cleanup tasks that simply erasing the files previously installed by the rpm cannot accomplish. In the case of our package, it includes removing the link created by the `%post` script and restoring the saved original of the motd file. + +``` +%postun +# remove installed files and links +rm /etc/cron.daily/create_motd + +# Restore the original MOTD if it was backed up +if [ -e /etc/motd.orig ] +then +   mv -f /etc/motd.orig /etc/motd +fi +``` + +#### %clean + +This Bash script performs cleanup after the rpm build process. The two lines in the `%clean` section below remove the build directories created by the `rpm-build` command. In many cases, additional cleanup may also be required. + +``` +%clean +rm -rf $RPM_BUILD_ROOT/usr/local/bin +rm -rf $RPM_BUILD_ROOT/usr/local/share/utils +``` + +#### %changelog + +This optional text section contains a list of changes to the rpm and files it contains. The newest changes are recorded at the top of this section. + +``` +%changelog +* Wed Aug 29 2018 Your Name +  - The original package includes several useful scripts. it is +    primarily intended to be used to illustrate the process of +    building an RPM. +``` + +Replace the data in the header line with your own name and email address. + +### Building the rpm + +The spec file must be in the SPECS directory of the rpmbuild tree. I find it easiest to create a link to the actual spec file in that directory so that it can be edited in the development directory and there is no need to copy it to the SPECS directory. Make the SPECS directory your pwd, then create the link. + +``` +cd ~/rpmbuild/SPECS/ +ln -s ~/development/spec/utils.spec +``` + +Run the following command to build the rpm. It should only take a moment to create the rpm if no errors occur. + +``` +rpmbuild --target noarch -bb utils.spec +``` + +Check in the ~/rpmbuild/RPMS/noarch directory to verify that the new rpm exists there. + +``` +[student@testvm1 ~]$ cd rpmbuild/RPMS/noarch/ +[student@testvm1 noarch]$ ll +total 24 +-rw-rw-r--. 1 student student 24364 Aug 30 10:00 utils-1.0.0-1.noarch.rpm +[student@testvm1 noarch]$ +``` + +### Testing the rpm + +As root, install the rpm to verify that it installs correctly and that the files are installed in the correct directories. The exact name of the rpm will depend upon the values you used for the tags in the Preamble section, but if you used the ones in the sample, the rpm name will be as shown in the sample command below: + +``` +[root@testvm1 ~]# cd /home/student/rpmbuild/RPMS/noarch/ +[root@testvm1 noarch]# ll +total 24 +-rw-rw-r--. 1 student student 24364 Aug 30 10:00 utils-1.0.0-1.noarch.rpm +[root@testvm1 noarch]# rpm -ivh utils-1.0.0-1.noarch.rpm +Preparing...                          ################################# [100%] +Updating / installing... +   1:utils-1.0.0-1                    ################################# [100%] +``` + +Check /usr/local/bin to ensure that the new files are there. You should also verify that the create_motd link in /etc/cron.daily has been created. + +Use the `rpm -q --changelog utils` command to view the changelog. View the files installed by the package using the `rpm -ql utils` command (that is a lowercase L in `ql`.) + +``` +[root@testvm1 noarch]# rpm -q --changelog utils +* Wed Aug 29 2018 Your Name +- The original package includes several useful scripts. it is +    primarily intended to be used to illustrate the process of +    building an RPM. + +[root@testvm1 noarch]# rpm -ql utils +/usr/local/bin/create_motd +/usr/local/bin/die +/usr/local/bin/mymotd +/usr/local/bin/sysdata +/usr/local/share/utils/Copyright.and.GPL.Notice.txt +/usr/local/share/utils/GPL_LICENSE.txt +/usr/local/share/utils/utils.spec +[root@testvm1 noarch]# +``` + +Remove the package. + +``` +rpm -e utils +``` + +### Experimenting + +Now you will change the spec file to require a package that does not exist. This will simulate a dependency that cannot be met. Add the following line immediately under the existing Requires line: + +``` +Requires: badrequire +``` + +Build the package and attempt to install it. What message is displayed? + +We used the `rpm` command to install and delete the `utils` package. Try installing the package with yum or DNF. You must be in the same directory as the package or specify the full path to the package for this to work. + +### Conclusion + +There are many tags and a couple sections that we did not cover in this look at the basics of creating an rpm package. The resources listed below can provide more information. Building rpm packages is not difficult; you just need the right information. I hope this helps you—it took me months to figure things out on my own. + +We did not cover building from source code, but if you are a developer, that should be a simple step from this point. + +Creating rpm packages is another good way to be a lazy sysadmin and save time and effort. It provides an easy method for distributing and installing the scripts and other files that we as sysadmins need to install on many hosts. + +### Resources + + * Edward C. Baily, Maximum RPM, Sams Publishing, 2000, ISBN 0-672-31105-4 + + * Edward C. Baily, [Maximum RPM][1], updated online version + + * [RPM Documentation][4]: This web page lists most of the available online documentation for rpm. It includes many links to other websites and information about rpm. + + + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/how-build-rpm-packages + +作者:[David Both][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dboth +[1]: http://ftp.rpm.org/max-rpm/ +[2]: http://rpm.org/index.html +[3]: http://www.both.org/?p=960 +[4]: http://rpm.org/documentation.html From 9893e264868bfe80555a229497e371f47e34ed11 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 13 Sep 2018 15:03:43 +0800 Subject: [PATCH 201/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20subroutine?= =?UTF-8?q?=20signatures=20work=20in=20Perl=206?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ow subroutine signatures work in Perl 6.md | 335 ++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 sources/tech/20180912 How subroutine signatures work in Perl 6.md diff --git a/sources/tech/20180912 How subroutine signatures work in Perl 6.md b/sources/tech/20180912 How subroutine signatures work in Perl 6.md new file mode 100644 index 0000000000..79606380bd --- /dev/null +++ b/sources/tech/20180912 How subroutine signatures work in Perl 6.md @@ -0,0 +1,335 @@ +How subroutine signatures work in Perl 6 +====== +In the fourth article in this series comparing Perl 5 to Perl 6, learn how signatures work in Perl 6. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/collab-team-pair-programming-code-keyboard2.png?itok=WnKfsl-G) + +In the [first article][1] in this series comparing Perl 5 to Perl 6, we looked into some of the issues you might encounter when migrating code into Perl 6. In the [second article][2], we examined how garbage collection works in Perl 6, and in the [third article][3], we looked at how containers replaced references in Perl 6. Here in the fourth article, we will focus on (subroutine) signatures in Perl 6 and how they differ from those in Perl 5. + +### Experimental signatures in Perl 5 + +If you're migrating from Perl 5 code to Perl 6, you're probably not using the [experimental signature feature][4] that became available in Perl 5.20 or any of the older CPAN modules like [signatures][5], [Function::Parameters][6], or any of the other Perl 5 modules on CPAN with ["signature" in their name][7]. + +Also, in my experience, [prototypes][8] haven't been used very often in the Perl programs out in the world (e.g., the [DarkPAN][9] ). + +For these reasons, I will compare Perl 6 functionality only with the most common use of "classic" Perl 5 argument passing. + +### Argument passing in Perl 5 + +All arguments you pass to a Perl 5 subroutine are flattened and put into the automatically defined `@_` array variable inside. That is basically all Perl 5 does with passing arguments to subroutines. Nothing more, nothing less. There are, however, several idioms in Perl 5 that take it from there. The most common (I would say "standard") idiom in my experience is: + +``` +# Perl 5 +sub do_something { +    my ($foo, $bar) = @_; +    # actually do something with $foo and $bar +} +``` + +This idiom performs a list assignment (copy) to two (new) lexical variables. This way of accessing the arguments to a subroutine is also supported in Perl 6, but it's intended just as a way to make migrations easier. + +If you expect a fixed number of arguments followed by a variable number of arguments, the following idiom is typically used: + +``` +# Perl 5 +sub do_something { +    my $foo = shift; +    my $bar = shift; +    for (@_) { +        # do something for each element in @_ +    } +}do_something +``` + +This idiom depends on the magic behavior of [shift][10], which shifts from `@_` in this context. If the subroutine is intended to be called as a method, something like this is usually seen: + +``` +# Perl 5 +sub do_something { +    my $self = shift; +    # do something with $self +}do_something +``` + +as the first argument passed is the [invocant][11] in Perl 5. + +By the way, this idiom can also be written in the first idiom: + +``` +# Perl 5 +sub do_something { +    my ($foo, $bar, @rest) = @_; +    for (@rest) { +        # do something for each element in @rest +    } +} +``` + +But that would be less efficient, as it would involve copying a potentially long list of values. + +The third idiom revolves on directly accessing the `@_` array. + +``` +# Perl 5 +sub sum_two { +    return $_[0] + $_[1];  # return the sum of the two parameters +}sum_two +``` + +This idiom is typically used for small, one-line subroutines, as it is one of the most efficient ways of handling arguments because no copying takes place. + +This idiom is also used if you want to change any variable that is passed as a parameter. Since the elements in `@_` are aliases to any variables specified (in Perl 6 you would say: "are bound to the variables"), it is possible to change the contents: + +``` +# Perl 5 +sub make42 { +    $_[0] = 42; +} +my $a = 666; +make42($a); +say $a;      # 42 +``` + +### Named arguments in Perl 5 + +Named arguments (as such) don't exist in Perl 5. But there is an often-used idiom that effectively mimics named arguments: + +``` +# Perl 5 +sub do_something { +    my %named = @_; +    if (exists %named{bar}) { +        # do stuff if named variable "bar" exists +    } +}do_somethingbar +``` + +This initializes the hash `%named` by alternately taking a key and a value from the `@_` array. If you call a subroutine with arguments using the fat-comma syntax: + +``` +# Perl 5 +frobnicate( bar => 42 ); +``` + +it will pass two values, `"foo"` and `42`, which will be placed into the `%named` hash as the value `42` associated with key `"foo"`. But the same thing would have happened if you had specified: + +``` +# Perl 5 +frobnicate( "bar", 42 ); +``` + +The `=>` is syntactic sugar for automatically quoting the left side. Otherwise, it functions just like a comma (hence the name "fat comma"). + +If a subroutine is called as a method with named arguments, this idiom is combined with the standard idiom: + +``` +# Perl 5 +sub do_something { +    my ($self, %named) = @_; +    # do something with $self and %named +} +``` + +alternatively: + +``` +# Perl 5 +sub do_something { +    my $self  = shift; +    my %named = @_; +    # do something with $self and %named +}do_something +``` + +### Argument passing in Perl 6 + +In their simplest form, subroutine signatures in Perl 6 are very much like the "standard" idiom of Perl 5. But instead of being part of the code, they are part of the definition of the subroutine, and you don't need to do the assignment: + +``` +# Perl 6 +sub do-something($foo, $bar) { +    # actually do something with $foo and $bar +} +``` + +versus: + +``` +# Perl 5 +sub do_something { +    my ($foo, $bar) = @_; +    # actually do something with $foo and $bar +} +``` + +In Perl 6, the `($foo, $bar)` part is called the signature of the subroutine. + +Since Perl 6 has an actual `method` keyword, it is not necessary to take the invocant into account, as that is automatically available with the `self` term: + +``` +# Perl 6 +class Foo { +    method do-something-else($foo, $bar) { +        # do something else with self, $foo and $bar +    } +} +``` + +Such parameters are called positional parameters in Perl 6. Unless indicated otherwise, positional parameters must be specified when calling the subroutine. + +If you need the aliasing behavior of using `$_[0]` directly in Perl 5, you can mark the parameter as writable by specifying the `is rw` trait: + +``` +# Perl 6 +sub make42($foo is rw) { +    $foo = 42; +} +my $a = 666; +make42($a); +say $a;      # 42 +``` + +When you pass an array as an argument to a subroutine, it doesn't get flattened in Perl 6. You only need to accept an array as an array in the signature: + +``` +# Perl 6 +sub handle-array(@a) { +    # do something with @a +} +my @foo = "a" .. "z"; +handle-array(@foo); +``` + +You can pass any number of arrays: + +``` +# Perl 6 +sub handle-two-arrays(@a, @b) { +    # do something with @a and @b +} +my @bar = 1..26; +handle-two-arrays(@foo, @bar); +``` + +If you want the ([variadic][12]) flattening semantics of Perl 5, you can indicate this with a so-called "slurpy array" by prefixing the array with an asterisk in the signature: + +``` +# Perl 6 +sub slurp-an-array(*@values) { +    # do something with @values +} +slurp-an-array("foo", 42, "baz");slurpanarrayslurpanarray +``` + +A slurpy array can occur only as the last positional parameter in a signature. + +If you prefer to use the Perl 5 way of specifying parameters in Perl 6, you can do this by specifying a slurpy array `*@_` in the signature: + +``` +# Perl 6 +sub do-like-5(*@_) { +    my ($foo, $bar) = @_; +} +``` + +### Named arguments in Perl 6 + +On the calling side, named arguments in Perl 6 can be expressed very similarly to how they are expressed in Perl 5: + +``` +# Perl 5 and Perl 6 +frobnicate( bar => 42 ); +``` + +However, on the definition side of the subroutine, things are very different: + +``` +# Perl 6 +sub frobnicate(:$bar) { +    # do something with $bar +} +``` + +The difference between an ordinary (positional) parameter and a named parameter is the colon, which precedes the [sigil][13] and the variable name in the definition: + +``` +$foo      # positional parameter, receives in $foo +:$bar     # named parameter "bar", receives in $bar +``` + +Unless otherwise specified, named parameters are optional. If a named argument is not specified, the associated variable will contain the default value, which usually is the type object `Any`. + +If you want to catch any (other) named arguments, you can use a so-called "slurpy hash." Just like the slurpy array, it is indicated with an asterisk before a hash: + +``` +# Perl 6 +sub slurp-nameds(*%nameds) { +    say "Received: " ~ join ", ", sort keys %nameds; +} +slurp-nameds(foo => 42, bar => 666); # Received: bar, fooslurpnamedssayslurpnamedsfoobar +``` + +As with the slurpy array, there can be only one slurpy hash in a signature, and it must be specified after any other named parameters. + +Often you want to pass a named argument to a subroutine from a variable with the same name. In Perl 5 this looks like: `do_something(bar => $bar)`. In Perl 6, you can specify this in the same way: `do-something(bar => $bar)`. But you can also use a shortcut: `do-something(:$bar)`. This means less typing–and less chance of typos. + +### Default values in Perl 6 + +Perl 5 has the following idiom for making parameters optional with a default value: + +``` +# Perl 5 +sub dosomething_with_defaults { +    my $foo = @_ ? shift : 42; +    my $bar = @_ ? shift : 666; +    # actually do something with $foo and $bar +}dosomething_with_defaults +``` + +In Perl 6, you can specify default values as part of the signature by specifying an equal sign and an expression: + +``` +# Perl 6 +sub dosomething-with-defaults($foo = 42, :$bar = 666) { +    # actually do something with $foo and $bar +} +``` + +Positional parameters become optional if a default value is specified for them. Named parameters stay optional regardless of any default value. + +### Summary + +Perl 6 has a way of describing how arguments to a subroutine should be captured into parameters of that subroutine. Positional parameters are indicated by their name and the appropriate sigil (e.g., `$foo`). Named parameters are prefixed with a colon (e.g. `:$bar`). Positional parameters can be marked as `is rw` to allow changing variables in the caller's scope. + +Positional arguments can be flattened in a slurpy array, which is prefixed by an asterisk (e.g., `*@values`). Unexpected named arguments can be collected using a slurpy hash, which is also prefixed with an asterisk (e.g., `*%nameds`). + +Default values can be specified inside the signature by adding an expression after an equal sign (e.g., `$foo = 42`), which makes that parameter optional. + +Signatures in Perl 6 have many other interesting features, aside from the ones summarized here; if you want to know more about them, check out the Perl 6 [signature object documentation][14]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/signatures-perl-6 + +作者:[Elizabeth Mattijsen][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lizmat +[1]: https://opensource.com/article/18/7/migrating-perl-5-perl-6 +[2]: https://opensource.com/article/18/7/garbage-collection-perl-6 +[3]: https://opensource.com/article/18/7/containers-perl-6 +[4]: https://metacpan.org/pod/distribution/perl/pod/perlsub.pod#Signatures +[5]: https://metacpan.org/pod/signatures +[6]: https://metacpan.org/pod/Function::Parameters +[7]: https://metacpan.org/search?q=signature +[8]: https://metacpan.org/pod/perlsub#Prototypes +[9]: http://modernperlbooks.com/mt/2009/02/the-darkpan-dependency-management-and-support-problem.html +[10]: https://perldoc.perl.org/functions/shift.html +[11]: https://docs.perl6.org/routine/invocant +[12]: https://en.wikipedia.org/wiki/Variadic_function +[13]: https://www.perl.com/article/on-sigils/ +[14]: https://docs.perl6.org/type/Signature From 203e154ed0f8e6ae5a04148808ddf45ce76e98d8 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 13 Sep 2018 15:06:08 +0800 Subject: [PATCH 202/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20turn?= =?UTF-8?q?=20on=20an=20LED=20with=20Fedora=20IoT?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2 How to turn on an LED with Fedora IoT.md | 201 ++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 sources/tech/20180912 How to turn on an LED with Fedora IoT.md diff --git a/sources/tech/20180912 How to turn on an LED with Fedora IoT.md b/sources/tech/20180912 How to turn on an LED with Fedora IoT.md new file mode 100644 index 0000000000..007cfc27ab --- /dev/null +++ b/sources/tech/20180912 How to turn on an LED with Fedora IoT.md @@ -0,0 +1,201 @@ +How to turn on an LED with Fedora IoT +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/08/LED-IoT-816x345.jpg) + +Do you enjoy running Fedora, containers, and have a Raspberry Pi? What about using all three together to play with LEDs? This article introduces Fedora IoT and shows you how to install a preview image on a Raspberry Pi. You’ll also learn how to interact with GPIO in order to light up an LED. + +### What is Fedora IoT? + +Fedora IoT is one of the current Fedora Project objectives, with a plan to become a full Fedora Edition. The result will be a system that runs on ARM (aarch64 only at the moment) devices such as the Raspberry Pi, as well as on the x86_64 architecture. + +![][1] + +Fedora IoT is based on OSTree, like [Fedora Silverblue][2] and the former [Atomic Host][3]. + +### Download and install Fedora IoT + +The official Fedora IoT images are coming with the Fedora 29 release. However, in the meantime you can download a [Fedora 28-based image][4] for this experiment. + +You have two options to install the system: either flash the SD card using a dd command, or use a fedora-arm-installer tool. The Fedora Wiki offers more information about [setting up a physical device][5] for IoT. Also, remember that you might need to resize the third partition. + +Once you insert the SD card into the device, you’ll need to complete the installation by creating a user. This step requires either a serial connection, or a HDMI display with a keyboard to interact with the device. + +When the system is installed and ready, the next step is to configure a network connection. Log in to the system with the user you have just created choose one of the following options: + + * If you need to configure your network manually, run a command similar to the following. Remember to use the right addresses for your network: +``` + $ nmcli connection add con-name cable ipv4.addresses \ + 192.168.0.10/24 ipv4.gateway 192.168.0.1 \ + connection.autoconnect true ipv4.dns "8.8.8.8,1.1.1.1" \ + type ethernet ifname eth0 ipv4.method manual + +``` + + * If there’s a DHCP service on your network, run a command like this: + +``` + $ nmcli con add type ethernet con-name cable ifname eth0 +``` + + + + +### **The GPIO interface in Fedora** + +Many tutorials about GPIO on Linux focus on a legacy GPIO sysfis interface. This interface is deprecated, and the upstream Linux kernel community plan to remove it completely, due to security and other issues. + +The Fedora kernel is already compiled without this legacy interface, so there’s no /sys/class/gpio on the system. This tutorial uses a new character device /dev/gpiochipN provided by the upstream kernel. This is the current way of interacting with GPIO. + +To interact with this new device, you need to use a library and a set of command line interface tools. The common command line tools such as echo or cat won’t work with this device. + +You can install the CLI tools by installing the libgpiod-utils package. A corresponding Python library is provided by the python3-libgpiod package. + +### **Creating a container with Podman** + +[Podman][6] is a container runtime with a command line interface similar to Docker. The big advantage of Podman is it doesn’t run any daemon in the background. That’s especially useful for devices with limited resources. Podman also allows you to start containerized services with systemd unit files. Plus, it has many additional features. + +We’ll create a container in these two steps: + + 1. Create a layered image containing the required packages. + 2. Create a new container starting from our image. + + + +First, create a file Dockerfile with the content below. This tells podman to build an image based on the latest Fedora image available in the registry. Then it updates the system inside and installs some packages: + +``` +FROM fedora:latest +RUN  dnf -y update +RUN  dnf -y install libgpiod-utils python3-libgpiod + +``` + +You have created a build recipe of a container image based on the latest Fedora with updates, plus packages to interact with GPIO. + +Now, run the following command to build your base image: + +``` +$ sudo podman build --tag fedora:gpiobase -f ./Dockerfile + +``` + +You have just created your custom image with all the bits in place. You can play with this base container images as many times as you want without installing the packages every time you run it. + +### Working with Podman + +To verify the image is present, run the following command: + +``` +$ sudo podman images +REPOSITORY                 TAG        IMAGE ID       CREATED          SIZE +localhost/fedora           gpiobase   67a2b2b93b4b   10 minutes ago  488MB +docker.io/library/fedora   latest     c18042d7fac6   2 days ago     300MB + +``` + +Now, start the container and do some actual experiments. Containers are normally isolated and don’t have an access to the host system, including the GPIO interface. Therefore, you need to mount it inside while starting the container. To do this, use the –device option in the following command: + +``` +$ sudo podman run -it --name gpioexperiment --device=/dev/gpiochip0 localhost/fedora:gpiobase /bin/bash + +``` + +You are now inside the running container. Before you move on, here are some more container commands. For now, exit the container by typing exit or pressing **Ctrl+D**. + +To list the the existing containers, including those not currently running, such as the one you just created, run: + +``` +$ sudo podman container ls -a +CONTAINER ID   IMAGE             COMMAND     CREATED          STATUS                              PORTS   NAMES +64e661d5d4e8   localhost/fedora:gpiobase   /bin/bash 37 seconds ago Exited (0) Less than a second ago           gpioexperiment + +``` + +To create a new container, run this command: + +``` +$ sudo podman run -it --name newexperiment --device=/dev/gpiochip0 localhost/fedora:gpiobase /bin/bash + +``` + +Delete it with the following command: + +``` +$ sudo podman rm newexperiment + +``` + +### **Turn on an LED** + +Now you can use the container you already created. If you exited from the container, start it again with this command: + +``` +$ sudo podman start -ia gpioexperiment + +``` + +As already discussed, you can use the CLI tools provided by the libgpiod-utils package in Fedora. To list the available GPIO chips, run: + +``` +$ gpiodetect +gpiochip0 [pinctrl-bcm2835] (54 lines) + +``` + +To get the list of the lines exposed by a specific chip, run: + +``` +$ gpioinfo gpiochip0 + +``` + +Notice there’s no correlation between the number of physical pins and the number of lines printed by the previous command. What’s important is the BCM number, as shown on [pinout.xyz][7]. It is not advised to play with the lines that don’t have a corresponding BCM number. + +Now, connect an LED to the physical pin 40, that is BCM 21. Remember: the shorter leg of the LED (the negative leg, called the cathode) must be connected to a GND pin of the Raspberry Pi with a 330 ohm resistor, and the long leg (the anode) to the physical pin 40. + +To turn the LED on, run the following command. It will stay on until you press **Ctrl+C** : + +``` +$ gpioset --mode=wait gpiochip0 21=1 + +``` + +To light it up for a certain period of time, add the -b (run in the background) and -s NUM (how many seconds) parameters, as shown below. For example, to light the LED for 5 seconds, run: + +``` +$ gpioset -b -s 5 --mode=time gpiochip0 21=1 + +``` + +Another useful command is gpioget. It gets the status of a pin (high or low), and can be useful to detect buttons and switches. + +![Closeup of LED connection with GPIO][8] + +### **Conclusion** + +You can also play with LEDs using Python — [there are some examples here][9]. And you can also use the i2c devices inside the container as well. In addition, Podman is not strictly related to this Fedora edition. You can install it on any existing Fedora Edition, or try it on the two new OSTree-based systems in Fedora: [Fedora Silverblue][2] and [Fedora CoreOS][10]. + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/turnon-led-fedora-iot/ + +作者:[Alessio Ciregia][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://alciregi.id.fedoraproject.org/ +[1]: https://fedoramagazine.org/wp-content/uploads/2018/08/oled-1024x768.png +[2]: https://teamsilverblue.org/ +[3]: https://www.projectatomic.io/ +[4]: https://kojipkgs.fedoraproject.org/compose/iot/latest-Fedora-IoT-28/compose/IoT/ +[5]: https://fedoraproject.org/wiki/InternetOfThings/GettingStarted#Setting_up_a_Physical_Device +[6]: https://github.com/containers/libpod +[7]: https://pinout.xyz/ +[8]: https://fedoramagazine.org/wp-content/uploads/2018/08/breadboard-1024x768.png +[9]: https://github.com/brgl/libgpiod/tree/master/bindings/python/examples +[10]: https://coreos.fedoraproject.org/ From a5b58a605353837a5626d477fe544e5d0ec770b3 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 13 Sep 2018 15:08:02 +0800 Subject: [PATCH 203/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Config?= =?UTF-8?q?ure=20Mouse=20Support=20For=20Linux=20Virtual=20Consoles?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ouse Support For Linux Virtual Consoles.md | 124 ++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md diff --git a/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md b/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md new file mode 100644 index 0000000000..c8b495cebe --- /dev/null +++ b/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md @@ -0,0 +1,124 @@ +How To Configure Mouse Support For Linux Virtual Consoles +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/GPM-1-720x340.png) + +I use Oracle VirtualBox to test various Unix-like operating systems. Most of my VMs are headless servers that does not have graphical desktop environment. For a long time, I have been wondering how can we use the mouse in the text-based terminals in headless Linux servers. Thanks to **GPM** , today I learned that we can use Mouse in virtual consoles for copy and paste operations. **GPM** , acronym for **G** eneral **P** urpose **M** ouse, is a daemon that helps you to configure mouse support for Linux virtual consoles. Please do not confuse GPM with **GDM** (GNOME Display manager). Both serves entirely different purpose. + +GPM is especially useful in the following scenarios: + + * New Linux server installations or for systems that cannot or do not use an X windows system by default, like Arch Linux and Gentoo. + * Use copy/paste operations around in the virtual terminals/consoles. + * Use copy/paste in text-based editors and browsers (Eg. emacs, lynx). + * Use copy/paste in text file managers (Eg. Ranger, Midnight commander). + + + +In this brief tutorial, we are going to see how to use Mouse in Text-based terminals in Unix-like operating systems. + +### Installing GPM + +To enable mouse support in Text-only Linux systems, install GPM package. It is available in the default repositories of most Linux distributions. + +On Arch Linux and its variants like Antergos, Manjaro Linux, run the following command to install GPM: + +``` +$ sudo pacman -S gpm +``` + +On Debian, Ubuntu, Linux Mint: + +``` +$ sudo apt install gpm +``` + +On Fedora: + +``` +$ sudo dnf install gpm +``` + +On openSUSE: + +``` +$ sudo zypper install gpm +``` + +Once installed, enable and start GPM service using the following commands: + +``` +$ sudo systemctl enable gpm +$ sudo systemctl start gpm +``` + +In Debian-based systems, gpm service will be automatically started after you installed it, so you need not to manually start the service as shown above. + +### Configure Mouse Support For Linux Virtual Consoles + +There is no special configuration required. GPM will start working as soon as you installed it and started gpm service. + +Have a look at the following screenshot of my Ubuntu 18.04 LTS server before installing GPM: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Ubuntu-18.04-CLI.png) + +As you see in the above screenshot, there is no visible Mouse pointer in my Ubuntu 18.04 LTS headless server. Only a blinking cursor and it won’t let me to select a text, copy/paste text using mouse. In CLI-only Linux servers, the mouse is literally not useful at all. + +Now check the following screenshot of Ubuntu 18.04 LTS server after installing GPM: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/GPM.png) + +See? I can now be able to select the text. + +To select, copy and paste text, do the following: + + * To select text, press the left mouse button and drag the mouse. + * Once you selected the text, release the left mouse button and paste text in the same or another console by pressing the middle mouse button. + * The right button is used to extend the selection, like in `xterm’. + * If you’re using two-button mouse, use the right button to paste text. + + + +It’s that simple! + +Like I already said, GPM works just fine and there is no extra configuration needed. Here is the sample contents of GPM configuration file **/etc/gpm.conf** (or `/etc/conf.d/gpm` in some distributions): + +``` +# protected from evaluation (i.e. by quoting them). +# +# This file is used by /etc/init.d/gpm and can be modified by +# "dpkg-reconfigure gpm" or by hand at your option. +# +device=/dev/input/mice +responsiveness= +repeat_type=none +type=exps2 +append='' +sample_rate= +``` + +In my example, I use USB mouse. If you’re using different mouse, you might have to change the values of **device=/dev/input/mice** and **type=exps2** parameters. + +For more details, refer man pages. + +``` +$ man gpm +``` + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-configure-mouse-support-for-linux-virtual-consoles/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ From fae0a21253276bc1e58537c6e84b60140866eb13 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 13 Sep 2018 15:09:20 +0800 Subject: [PATCH 204/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Know=20Your=20Sto?= =?UTF-8?q?rage:=20Block,=20File=20&=20Object?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Know Your Storage- Block, File - Object.md | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 sources/tech/20180911 Know Your Storage- Block, File - Object.md diff --git a/sources/tech/20180911 Know Your Storage- Block, File - Object.md b/sources/tech/20180911 Know Your Storage- Block, File - Object.md new file mode 100644 index 0000000000..24f179d9d5 --- /dev/null +++ b/sources/tech/20180911 Know Your Storage- Block, File - Object.md @@ -0,0 +1,62 @@ +Know Your Storage: Block, File & Object +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/block2_1920.jpg?itok=s1y6RLhT) + +Dealing with the tremendous amount of data generated today presents a big challenge for companies who create or consume such data. It’s a challenge for tech companies that are dealing with related storage issues. + +“Data is growing exponentially each year, and we find that the majority of data growth is due to increased consumption and industries adopting transformational projects to expand value. Certainly, the Internet of Things (IoT) has contributed greatly to data growth, but the key challenge for software-defined storage is how to address the use cases associated with data growth,” said Michael St. Jean, principal product marketing manager, Red Hat Storage. + +Every challenge is an opportunity. “The deluge of data being generated by old and new sources today is certainly presenting us with opportunities to meet our customers escalating needs in the areas of scale, performance, resiliency, and governance,” said Tad Brockway, General Manager for Azure Storage, Media and Edge. + +### Trinity of modern software-defined storage + +There are three different kinds of storage solutions -- block, file, and object -- each serving a different purpose while working with the others. + +Block storage is the oldest form of data storage, where data is stored in fixed-length blocks or chunks of data. Block storage is used in enterprise storage environments and usually is accessed using Fibre Channel or iSCSI interface. “Block storage requires an application to map where the data is stored on the storage device,” according to SUSE’s Larry Morris, Sr. Product Manager, Software Defined Storage. + +Block storage is virtualized in storage area network and software defined storage systems, which are abstracted logical devices that reside on a shared hardware infrastructure and are created and presented to the host operating system of a server, virtual server, or hypervisor via protocols like SCSI, SATA, SAS, FCP, FCoE, or iSCSI. + +“Block storage splits a single storage volume (like a virtual or cloud storage node, or a good old fashioned hard disk) into individual instances known as blocks,” said St. Jean. + +Each block exists independently and can be formatted with its own data transfer protocol and operating system — giving users complete configuration autonomy. Because block storage systems aren’t burdened with the same investigative file-finding duties as the file storage systems, block storage is a faster storage system. Pairing that speed with configuration flexibility makes block storage ideal for raw server storage or rich media databases. + +Block storage can be used to host operating systems, applications, databases, entire virtual machines and containers. Traditionally, block storage can only be accessed by individual machine, or machines in a cluster, to which it has been presented. + +### File-based storage + +File-based storage uses a filesystem to map where the data is stored on the storage device. It’s a dominant technology used on direct- and networked-attached storage system, and it takes care of two things: organizing data and representing it to users. “With file storage, data is arranged on the server side in the exact same format as the clients see it. This allows the user to request a file by some unique identifier — like a name, location, or URL — which is communicated to the storage system using specific data transfer protocols,” said St. Jean. + +The result is a type of hierarchical file structure that can be navigated from top to bottom. File storage is layered on top of block storage, allowing users to see and access data as files and folders, but restricting access to the blocks that stand up those files and folders. + +“File storage is typically represented by shared filesystems like NFS and CIFS/SMB that can be accessed by many servers over an IP network. Access can be controlled at a file, directory, and export level via user and group permissions. File storage can be used to store files needed by multiple users and machines, application binaries, databases, virtual machines, and can be used by containers,” explained Brockway. + +### Object storage + +Object storage is the newest form of data storage, and it provides a repository for unstructured data which separates the content from the indexing and allows the concatenation of multiple files into an object. An object is a piece of data paired with any associated metadata that provides context about the bytes contained within the object (things like how old or big the data is). Those two things together — the data and metadata — make an object. + +One advantage of object storage is the unique identifier associated with each piece of data. Accessing the data involves using the unique identifier and does not require the application or user to know where the data is actually stored. Object data is accessed through APIs. + +“The data stored in objects is uncompressed and unencrypted, and the objects themselves are arranged in object stores (a central repository filled with many other objects) or containers (a package that contains all of the files an application needs to run). Objects, object stores, and containers are very flat in nature — compared to the hierarchical structure of file storage systems — which allow them to be accessed very quickly at huge scale,” explained St. Jean. + +Object stores can scale to many petabytes to accommodate the largest datasets and are a great choice for images, audio, video, logs, backups, and data used by analytics services. + +### Conclusion + +Now you know about the various types of storage and how they are used. Stay tuned to learn more about software-defined storage as we examine the topic in the future. + +Join us at [Open Source Summit + Embedded Linux Conference Europe][1] in Edinburgh, UK on October 22-24, 2018, for 100+ sessions on Linux, Cloud, Containers, AI, Community, and more. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/2018/9/know-your-storage-block-file-object + +作者:[Swapnil Bhartiya][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/arnieswap +[1]: https://events.linuxfoundation.org/events/elc-openiot-europe-2018/ From 2d958595d64f1f73bf118852da9a4fb47d159fcc Mon Sep 17 00:00:00 2001 From: XiatianSummer Date: Thu, 13 Sep 2018 17:08:40 +0800 Subject: [PATCH 205/455] Update 20180911 Visualize Disk Usage On Your Linux System.md translating --- .../tech/20180911 Visualize Disk Usage On Your Linux System.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180911 Visualize Disk Usage On Your Linux System.md b/sources/tech/20180911 Visualize Disk Usage On Your Linux System.md index 8b39f156a6..dccb9de4c2 100644 --- a/sources/tech/20180911 Visualize Disk Usage On Your Linux System.md +++ b/sources/tech/20180911 Visualize Disk Usage On Your Linux System.md @@ -1,3 +1,5 @@ +XiatianSummer translating + Visualize Disk Usage On Your Linux System ====== From e9d0e0feb860d18e9134e4e7f2d2a1818a257f0a Mon Sep 17 00:00:00 2001 From: XiatianSummer Date: Thu, 13 Sep 2018 17:15:47 +0800 Subject: [PATCH 206/455] Update 20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md translating --- ... 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md b/sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md index 5feab2f4b2..1706bc6989 100644 --- a/sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md +++ b/sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md @@ -1,3 +1,5 @@ +XiatianSummer translating + 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know ====== Knowing keyboard shortcuts increase your productivity. Here are some useful Ubuntu shortcut keys that will help you use Ubuntu like a pro. From adf156b6402bb598a7977b1750d847d0f4c2c53b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 13 Sep 2018 19:07:52 +0800 Subject: [PATCH 207/455] PRF:20180308 What is open source programming.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 邀请 @pityonline @PurlingNayuki 审校。CC @Valoniakim --- ...0180308 What is open source programming.md | 49 +++++++++---------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/translated/talk/20180308 What is open source programming.md b/translated/talk/20180308 What is open source programming.md index 5b4427f46c..ad732e1996 100644 --- a/translated/talk/20180308 What is open source programming.md +++ b/translated/talk/20180308 What is open source programming.md @@ -1,73 +1,72 @@ -何为开源? +何谓开源编程? ====== +> 开源就是丢一些代码到 GitHub 上。了解一下它是什么,以及不是什么? ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82) -简单来说,开源项目就是书写一些大家可以随意取用、修改的代码。但你肯定听过关于Go语言的那个笑话,说 Go 语言简单到看一眼就可以明白规则,但需要一辈子去学会运用它。其实写开源代码也是这样的。往 GitHub, Bitbucket, SourceForge 等网站或者是你自己的博客,网站上丢几行代码不是难事,但想要有效地操作,还需要个人的努力付出,和高瞻远瞩。 +最简单的来说,开源编程就是编写一些大家可以随意取用、修改的代码。但你肯定听过关于 Go 语言的那个老笑话,说 Go 语言“简单到看一眼就可以明白规则,但需要一辈子去学会运用它”。其实写开源代码也是这样的。往 GitHub、Bitbucket、 SourceForge 等网站或者是你自己的博客或网站上丢几行代码不是难事,但想要卓有成效,还需要个人的努力付出和高瞻远瞩。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/floorgoban.jpeg?itok=r8gA5jOk) -### 我们对开源项目的误解 +### 我们对开源编程的误解 -首先我要说清楚一点:把你的代码写在 GitHub 的公开资源库中并不意味着把你的代码开源化了。在几乎全世界,根本不用创作者做什么,只要作品形成,版权就随之而生了。在创作者进行授权之前,只有作者可以行使版权相关的权力。未经创作者授权的代码,不论有多少人在使用,都是一颗定时炸弹,只有愚蠢的人才会去用它。 +首先我要说清楚一点:把你的代码放在 GitHub 的公开仓库中并不意味着把你的代码开源了。在几乎全世界,根本不用创作者做什么,只要作品形成,版权就随之而生了。在创作者进行授权之前,只有作者可以行使版权相关的权力。未经创作者授权的代码,不论有多少人在使用,都是一颗定时炸弹,只有愚蠢的人才会去用它。 -有些创作者很善良,认为“很明显我的代码是免费提供给大家使用的。”,他也并不想起诉那些用了他的代码的人,但这并不意味着这些代码可以放心使用。不论在你眼中创作者们多么善良,他们都是有权力起诉任何使用、修改代码,或未经明确授权就将代码嵌入的人。 +有些创作者很善良,认为“很明显我的代码是免费提供给大家使用的。”,他也并不想起诉那些用了他的代码的人,但这并不意味着这些代码可以放心使用。不论在你眼中创作者们多么善良,他们都是*有权力*起诉任何使用、修改代码,或未经明确授权就将代码嵌入的人。 -很明显,你不应该在没有指定开源许可证的情况下将你的源代码发布到网上然后期望别人使用它并为其做出贡献,我建议你也尽量避免使用这种代码,甚至疑似未授权的也不要使用。如果你开发了一个函数和实现,它和之前一个疑似未授权代码很像,源代码作者就可以对你就侵权提起诉讼。 +很明显,你不应该在没有指定开源许可证的情况下将你的源代码发布到网上然后期望别人使用它并为其做出贡献,我建议你也尽量避免使用这种代码,甚至疑似未授权的也不要使用。如果你开发了一个函数和例程,它和之前一个疑似未授权代码很像,源代码作者就可以对你就侵权提起诉讼。 举个例子, Jill Schmill 写了 AwesomeLib 然后未明确授权就把它放到了 GitHub 上,就算 Jill Schmill 不起诉任何人,只要她把 AwesomeLib 的完整版权都卖给 EvilCorp,EvilCorp 就会起诉之前违规使用这段代码的人。这种行为就好像是埋下了计算机安全隐患,总有一天会为人所用。 -没有许可证的代码的危险的,以上。 +没有许可证的代码的危险的,切记。 ### 选择恰当的开源许可证 -假设你证要写一个新程序,而且打算把它放在开源平台上,你需要选择最贴合你需求的[许可证][1]。和宣传中说的一样,你可以从 [GitHub-curated][2] 上得到你想要的信息。这个网站设置得像个小问卷,特别方便快捷,点几下就能找到合适的许可证。 +假设你正要写一个新程序,而且打算让人们以开源的方式使用它,你需要做的就是选择最贴合你需求的[许可证][1]。和宣传中说的一样,你可以从 GitHub 所支持的 [choosealicense.com][2] 开始。这个网站设置得像个简单的问卷,特别方便快捷,点几下就能找到合适的许可证。 -没有许可证的代码的危险的,切记。 +警示:在选择许可证时不要过于自负,如果你选的是 [Apache 许可证][3] 或者 [GPLv3][4] 这种广为使用的许可证,人们很容易理解其对于权利的规划,你也不需要请律师来排查其中的漏洞。你选择的许可证使用的人越少,带来的麻烦越多。 -在选择许可证时不要过于自负,如果你选的是 [Apache License][3] 或者 [GPLv3][4] 这种广为使用的许可证,人们很容易理解其对于权利的规划,你也不需要请律师来排查其中的漏洞。你选择的许可证使用的人越少,带来的麻烦越多。 +最重要的一点是:*千万不要试图自己编造许可证!*自己编造许可证会给大家带来更多的困惑和困扰,不要这样做。如果在现有的许可证中确实找不到你需要的条款,你可以在现有的许可证中附加上你的要求,并且重点标注出来,提醒使用者们注意。 -最重要的一点是:千万不要试图自己编造许可证!自己编造许可证会给大家带来更多的困惑和困扰,不要这样做。如果在现有的许可证中确实找不到你需要的程式,你可以在现有的许可证中附加上你的要求,并且重点标注出来,提醒使用者们注意。 - -我知道有些人会说:“我才懒得管什么许可证,我已经把代码发到公共域了。”但问题是,公共域的法律效力并不是受全世界认可的。在不同的国家,公共域的效力和表现形式不同。有些国家的政府管控下,你甚至不可以把自己的源代码发到公共域中。万幸,[Unlicense][5] 可以弥补这些漏洞,它语言简洁,但其效力为全世界认可。 +我知道有些人会说:“我才懒得管什么许可证,我已经把代码发到公开领域public domain了。”但问题是,公开领域的法律效力并不是受全世界认可的。在不同的国家,公开领域的效力和表现形式不同。有些国家的政府管控下,你甚至不可以把自己的源代码发到公开领域中。万幸,[Unlicense][5] 可以弥补这些漏洞,它语言简洁,使用几个词清楚地描述了“就把它放到公开领域”,但其效力为全世界认可。 ### 怎样引入许可证 -确定使用哪个许可证之后,你需要明文指定它。如果你是在 GitHub 、 GitLab 或 BitBucket 这几个网站发布,你需要构建很多个文件夹,在根文件夹中,你应把许可证创建为一个以 LICENSE 命名的 txt 格式明文文件。 +确定使用哪个许可证之后,你需要清晰而无疑义地指定它。如果你是在 GitHub、 GitLab 或 BitBucket 这几个网站发布,你需要构建很多个文件夹,在根文件夹中,你应把许可证创建为一个以 `LICENSE.txt` 命名的明文文件。 -创建 LICENSE.txt 这个文件之后还有其他事要做。你需要在每个有效文件的页眉中添加注释块来申明许可证。如果你使用的是一现有的许可证,这一步对你来说十分简便。一个 `# 项目名 (c)2018作者名, GPLv3 许可证,详情见 https://www.gnu.org/licenses/gpl-3.0.en.html` 这样的注释块比隐约指代的许可证的效力要强得多。 +创建 `LICENSE.txt` 这个文件之后还有其他事要做。你需要在每个有效文件的页眉中添加注释块来申明许可证。如果你使用的是一现有的许可证,这一步对你来说十分简便。一个 `# 项目名 (c)2018 作者名, GPLv3 许可证,详情见 https://www.gnu.org/licenses/gpl-3.0.en.html` 这样的注释块比隐约指代的许可证的效力要强得多。 -如果你是要发布在自己的网站上,步骤也差不多。先创建 LICENSE.txt 文件,放入许可证,再表明许可证出处。 +如果你是要发布在自己的网站上,步骤也差不多。先创建 `LICENSE.txt` 文件,放入许可证,再表明许可证出处。 ### 开源代码的不同之处 -开源代码和专有代码的一个区别的开源代码写出来就是为了给别人看的。我是个40多岁的系统管理员,已经写过许许多多的代码。最开始我写代码是为了工作,为了解决公司的问题,所以其中大部分代码都是专有代码。这种代码的目的很简单,只要能在特定场合通过特定方式发挥作用就行。 +开源代码和专有代码的一个主要区别是开源代码写出来就是为了给别人看的。我是个 40 多岁的系统管理员,已经写过许许多多的代码。最开始我写代码是为了工作,为了解决公司的问题,所以其中大部分代码都是专有代码。这种代码的目的很简单,只要能在特定场合通过特定方式发挥作用就行。 -开源代码则大不相同。在写开源代码时,你知道它可能会被用于各种各样的环境中。也许你的使用案例的环境条件很局限,但你仍旧希望它能在各种环境下发挥理想的效果。不同的人使用这些代码时,你会看到各类冲突,还有你没有考虑过的思路。虽然代码不一定要满足所有人,但最少它们可以顺利解决使用者遇到的问题,就算解决不了,也可以转换回常见的逻辑,不会给使用者添麻烦。(例如“第583行的内容除以零”就不能作为命令行参数正确的结果) +开源代码则大不相同。在写开源代码时,你知道它可能会被用于各种各样的环境中。也许你的使用案例的环境条件很局限,但你仍旧希望它能在各种环境下发挥理想的效果。不同的人使用这些代码时,你会看到各类冲突,还有你没有考虑过的思路。虽然代码不一定要满足所有人,但最少它们可以顺利解决使用者遇到的问题,就算解决不了,也可以转换回常见的逻辑,不会给使用者添麻烦。(例如“第 583 行出现零除错误”就不能作为错误地提供命令行参数的响应结果) -你的源代码也可能逼疯你,尤其是在你一遍又一遍地修改错误的函数或是子过程后,终于出现了你希望的结果,这时你不会叹口气就继续下一个任务,你会把过程清理干净,因为你不会愿意别人看出你一遍遍尝试的痕迹。比如你会把 `$variable` `$lol`全都换成有意义的 `$iterationcounter` 和 `$modelname`。这意味着你要认真专业地进行注释(尽管对于头脑风暴中的你来说它并不难懂),但为了之后有更多的人可以使用你的代码,你会尽力去注释,但注意适可而止。 +你的源代码也可能逼疯你,尤其是在你一遍又一遍地修改错误的函数或是子过程后,终于出现了你希望的结果,这时你不会叹口气就继续下一个任务,你会把过程清理干净,因为你不会愿意别人看出你一遍遍尝试的痕迹。比如你会把 `$variable`、`$lol` 全都换成有意义的 `$iterationcounter` 和 `$modelname`。这意味着你要认真专业地进行注释(尽管对于头脑风暴中的你来说它并不难懂),但为了之后有更多的人可以使用你的代码,你会尽力去注释,但注意适可而止。 -这个过程难免有些痛苦沮丧,毕竟这不是你常做的事,会有些不习惯。但它会使你成为一位更好的程序员,也会让你的代码升华。即使你的项目只有你在贡献,清理代码也会节约你后期的很多工作,相信我一年后你更新 app 时,你会庆幸自己现在写下的是 `$modelname`,还有清晰的注释,而不是什么不知名的数列,甚至连 `$lol`也不是。 +这个过程难免有些痛苦沮丧,毕竟这不是你常做的事,会有些不习惯。但它会使你成为一位更好的程序员,也会让你的代码升华。即使你的项目只有你一位贡献者,清理代码也会节约你后期的很多工作,相信我一年后你更新 app 时,你会庆幸自己现在写下的是 `$modelname`,还有清晰的注释,而不是什么不知名的数列,甚至连 `$lol`也不是。 ### 你并不是为你一人而写 开源的真正核心并不是那些代码,是社区。更大的社区的项目维持的时间更长,也更容易为人们接受。因此不仅要加入社区,还要多多为社区发展贡献思路,让自己的项目能够为社区所用。 -蝙蝠侠为了完成目标暗中独自花了很大功夫,你用不着这样,你可以登录 Twitter , Reddit, 或者给你项目的相关人士发邮件,发布你正在筹备新项目的消息,仔细聊聊项目的设计初衷和你的计划,让大家一起帮忙,向大家征集数据输入,类似的使用案例,把这些信息整合起来,用在你的代码里。你不用看所有的回复,但你要对它有个大概把握,这样在你之后完善时可以躲过一些陷阱。 +蝙蝠侠为了完成目标暗中独自花了很大功夫,你用不着这样,你可以登录 Twitter、 Reddit,或者给你项目的相关人士发邮件,发布你正在筹备新项目的消息,仔细聊聊项目的设计初衷和你的计划,让大家一起帮忙,向大家征集数据输入,类似的使用案例,把这些信息整合起来,用在你的代码里。你不用看所有的回复,但你要对它有个大概把握,这样在你之后完善时可以躲过一些陷阱。 不发首次通告这个过程还不算完整。如果你希望大家能够接受你的作品,并且使用它,你就要以此为初衷来设计。公众说不定可以帮到你,你不必对公开这件事如临大敌。所以不要闭门造车,既然你是为大家而写,那就开设一个真实、公开的项目,想象你在社区的监督下,认真地一步步完成它。 ### 建立项目的方式 -你可以在 GitHub, GitLab, or BitBucket 上免费注册账号来管理你的项目。注册之后,创建知识库,建立 README 文件,分配一个许可证,一步步写入代码。这样可以帮你建立好习惯,让你之后和现实中的团队一起工作时,也能目的清晰地朝着目标稳妥地进行工作。这样你做得越久,就越有兴趣。 +你可以在 GitHub、 GitLab 或 BitBucket 上免费注册账号来管理你的项目。注册之后,创建知识库,建立 `README` 文件,分配一个许可证,一步步写入代码。这样可以帮你建立好习惯,让你之后和现实中的团队一起工作时,也能目的清晰地朝着目标稳妥地进行工作。这样你做得越久,就越有兴趣。 用户们会开始对你产生兴趣,这会让你开心也会让你不爽,但你应该亲切礼貌地对待他们,就算他们很多人根本不知道你的项目做的是什么,你可以把文件给他们看,让他们了解你在干什么。有些还在犹豫的用户可以给你提个醒,告诉你最开始设计的用户范围中落下了哪些人。 -如果你的项目很受用户青睐,总会有开发者出现,并表示出兴趣。这也许是好事,也可能激怒你。最开始你可能只会做简单的错误修正,但总有一天你会收到拉请求,有可能是特殊利基案例,它可能改变你项目的作用域,甚至改变你项目的初衷。你需要学会分辨哪个有贡献,根据这个决定合并哪个,婉拒哪个。 +如果你的项目很受用户青睐,总会有开发者出现,并表示出兴趣。这也许是好事,也可能激怒你。最开始你可能只会做简单的错误修正,但总有一天你会收到拉取请求,有可能是特殊利基案例,它可能改变你项目的作用域,甚至改变你项目的初衷。你需要学会分辨哪个有贡献,根据这个决定合并哪个,婉拒哪个。 ### 我们为什么要开源? -开源听起来任务繁重,它也确实是这样。但它对你也有很多好处。它可以在无形之中磨练你,让你写出纯净持久的代码,也教会你与人沟通,团队协作。对于一位志向远大的专业开发者来说,它是最好的简历书写者。你的未来雇主很有可能点开你的知识库,了解你的能力范围;而你的开发者也有可能想带你进全球信息网络工作。 +开源听起来任务繁重,它也确实是这样。但它对你也有很多好处。它可以在无形之中磨练你,让你写出纯净持久的代码,也教会你与人沟通,团队协作。对于一位志向远大的专业开发者来说,它是最好的简历书写者。你的未来雇主很有可能点开你的仓库,了解你的能力范围;而社区项目的开发者也有可能给你带来工作。 最后,为开源工作,意味着个人的提升,因为你在做的事不是为了你一个人,这比养活自己重要得多。 @@ -77,7 +76,7 @@ via: https://opensource.com/article/18/3/what-open-source-programming 作者:[Jim Salter][a] 译者:[Valoniakim](https://github.com/Valoniakim) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From d4326b05aa58b0ec5e21472d39a8e51e24530e36 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 13 Sep 2018 22:00:45 +0800 Subject: [PATCH 208/455] PRF:20180324 How To Compress And Decompress Files In Linux.md @ucasFL --- ... Compress And Decompress Files In Linux.md | 123 ++++++++---------- 1 file changed, 55 insertions(+), 68 deletions(-) diff --git a/translated/tech/20180324 How To Compress And Decompress Files In Linux.md b/translated/tech/20180324 How To Compress And Decompress Files In Linux.md index a9ef889130..d968bbd6db 100644 --- a/translated/tech/20180324 How To Compress And Decompress Files In Linux.md +++ b/translated/tech/20180324 How To Compress And Decompress Files In Linux.md @@ -5,206 +5,193 @@ 当在备份重要文件和通过网络发送大文件的时候,对文件进行压缩非常有用。请注意,压缩一个已经压缩过的文件会增加额外开销,因此你将会得到一个更大一些的文件。所以,请不要压缩已经压缩过的文件。在 GNU/Linux 中,有许多程序可以用来压缩和解压缩文件。在这篇教程中,我们仅学习其中两个应用程序。 -### 压缩和解压缩文件 - 在类 Unix 系统中,最常见的用来压缩文件的程序是: 1. gzip 2. bzip2 +### 1. 使用 gzip 程序来压缩和解压缩文件 +`gzip` 是一个使用 Lempel-Ziv 编码(LZ77)算法来压缩和解压缩文件的实用工具。 -##### 1\. 使用 Gzip 程序来压缩和解压缩文件 +#### 1.1 压缩文件 -Gzip 是一个使用 Lempel-Ziv 编码(LZ77)算法来压缩和解压缩文件的实用工具。 +如果要压缩一个名为 `ostechnix.txt` 的文件,使之成为 gzip 格式的压缩文件,那么只需运行如下命令: -**1.1 压缩文件** - -如果要压缩一个名为 ostechnix.txt 的文件,使之成为 gzip 格式的压缩文件,那么只需运行如下命令: ``` $ gzip ostechnix.txt - ``` -上面的命令运行结束之后,将会出现一个名为 ostechnix.txt.gz 的 gzip 格式压缩文件,代替原始的 ostechnix.txt 文件。 +上面的命令运行结束之后,将会出现一个名为 `ostechnix.txt.gz` 的 gzip 格式压缩文件,代替了原始的 `ostechnix.txt` 文件。 + +`gzip` 命令还可以有其他用法。一个有趣的例子是,我们可以将一个特定命令的输出通过管道传递,然后作为 `gzip` 程序的输入来创建一个压缩文件。看下面的命令: -gzip 命令还可以有其他用法。一个有趣的例子是,我们可以将一个特定命令的输出通过管道传递,然后作为 gzip 程序的输入来创建一个压缩文件。看下面的命令: ``` $ ls -l Downloads/ | gzip > ostechnix.txt.gz - ``` -上面的命令将会创建一个 gzip 格式的压缩文件,文件的内容为 “Downloads” 目录的目录项。 +上面的命令将会创建一个 gzip 格式的压缩文件,文件的内容为 `Downloads` 目录的目录项。 -**1.2 压缩文件并将输出写到新文件中(不覆盖原始文件) -** +#### 1.2 压缩文件并将输出写到新文件中(不覆盖原始文件) + +默认情况下,`gzip` 程序会压缩给定文件,并以压缩文件替代原始文件。但是,你也可以保留原始文件,并将输出写到标准输出。比如,下面这个命令将会压缩 `ostechnix.txt` 文件,并将输出写入文件 `output.txt.gz`。 -默认情况下,gzip 程序会压缩给定文件,并以压缩文件替代原始文件。但是,你也可以保留原始文件,并将输出写到标准输出。比如,下面这个命令将会压缩 ostechnix.txt 文件,并将输出写入文件 output.txt.gz 。 ``` $ gzip -c ostechnix.txt > output.txt.gz - ``` -类似地,要解压缩一个 gzip 格式的压缩文件并指定输出文件的文件名,只需运行: +类似地,要解压缩一个 `gzip` 格式的压缩文件并指定输出文件的文件名,只需运行: + ``` $ gzip -c -d output.txt.gz > ostechnix1.txt - ``` -上面的命令将会解压缩 output.txt.gz 文件,并将输出写入到文件 ostechnix1.txt 中。在上面两个例子中,原始文件均不会被删除。 +上面的命令将会解压缩 `output.txt.gz` 文件,并将输出写入到文件 `ostechnix1.txt` 中。在上面两个例子中,原始文件均不会被删除。 -**1.3 解压缩文件** +#### 1.3 解压缩文件 + +如果要解压缩 `ostechnix.txt.gz` 文件,并以原始未压缩版本的文件来代替它,那么只需运行: -如果要解压缩 ostechnix.txt.gz 文件,并以原始未压缩版本的文件来代替它,那么只需运行: ``` $ gzip -d ostechnix.txt.gz - ``` -我们也可以使用 gunzip 程序来解压缩文件: +我们也可以使用 `gunzip` 程序来解压缩文件: + ``` $ gunzip ostechnix.txt.gz - ``` -**1.4 在不解压缩的情况下查看压缩文件的内容** +#### 1.4 在不解压缩的情况下查看压缩文件的内容 + +如果你想在不解压缩的情况下,使用 `gzip` 程序查看压缩文件的内容,那么可以像下面这样使用 `-c` 选项: -如果你想在不解压缩的情况下,使用 gzip 程序查看压缩文件的内容,那么可以像下面这样使用 -c 选项: ``` $ gunzip -c ostechnix1.txt.gz - ``` -或者,你也可以像下面这样使用 zcat 程序: +或者,你也可以像下面这样使用 `zcat` 程序: + ``` $ zcat ostechnix.txt.gz - ``` -你也可以通过管道将输出传递给 less 命令,从而一页一页的来查看输出,就像下面这样: +你也可以通过管道将输出传递给 `less` 命令,从而一页一页的来查看输出,就像下面这样: + ``` $ gunzip -c ostechnix1.txt.gz | less - $ zcat ostechnix.txt.gz | less - ``` -另外,zless 程序也能够实现和上面的管道同样的功能。 +另外,`zless` 程序也能够实现和上面的管道同样的功能。 + ``` $ zless ostechnix1.txt.gz - ``` -**1.5 使用 gzip 压缩文件并指定压缩级别** +#### 1.5 使用 gzip 压缩文件并指定压缩级别 -Gzip 的另外一个显著优点是支持压缩级别。它支持下面给出的 3 个压缩级别: +`gzip` 的另外一个显著优点是支持压缩级别。它支持下面给出的 3 个压缩级别: * **1** – 最快 (最差) * **9** – 最慢 (最好) * **6** – 默认级别 +要压缩名为 `ostechnix.txt` 的文件,使之成为“最好”压缩级别的 gzip 压缩文件,可以运行: - -要压缩名为 ostechnix.txt 的文件,使之成为“最好”压缩级别的 gzip 压缩文件,可以运行: ``` $ gzip -9 ostechnix.txt - ``` -**1.6 连接多个压缩文件** +#### 1.6 连接多个压缩文件 我们也可以把多个需要压缩的文件压缩到同一个文件中。如何实现呢?看下面这个例子。 + ``` $ gzip -c ostechnix1.txt > output.txt.gz - $ gzip -c ostechnix2.txt >> output.txt.gz - ``` -上面的两个命令将会压缩文件 ostechnix1.txt 和 ostechnix2.txt,并将输出保存到一个文件 output.txt.gz 中。 +上面的两个命令将会压缩文件 `ostechnix1.txt` 和 `ostechnix2.txt`,并将输出保存到一个文件 `output.txt.gz` 中。 + +你可以通过下面其中任何一个命令,在不解压缩的情况下,查看两个文件 `ostechnix1.txt` 和 `ostechnix2.txt` 的内容: -你可以通过下面其中任何一个命令,在不解压缩的情况下,查看两个文件 ostechnix1.txt 和 ostechnix2.txt 的内容: ``` $ gunzip -c output.txt.gz - $ gunzip -c output.txt - $ zcat output.txt.gz - $ zcat output.txt - ``` -如果你想了解关于 gzip 的更多细节,请参阅它的 man 手册。 +如果你想了解关于 `gzip` 的更多细节,请参阅它的 man 手册。 + ``` $ man gzip - ``` -##### 2\. 使用 bzip2 程序来压缩和解压缩文件 +### 2. 使用 bzip2 程序来压缩和解压缩文件 -bzip2 和 gzip 非常类似,但是 bzip2 使用的是 Burrows-Wheeler 块排序压缩算法,并使用哈夫曼Huffman编码。使用 bzip2 压缩的文件以 “.bz2” 扩展结尾。 +`bzip2` 和 `gzip` 非常类似,但是 `bzip2` 使用的是 Burrows-Wheeler 块排序压缩算法,并使用哈夫曼Huffman编码。使用 `bzip2` 压缩的文件以 “.bz2” 扩展结尾。 -正如我上面所说的, bzip2 的用法和 gzip 几乎完全相同。只需在上面的例子中将 gzip 换成 bzip2,将 gunzip 换成 bunzip2,将 zcat 换成 bzcat 即可。 +正如我上面所说的, `bzip2` 的用法和 `gzip` 几乎完全相同。只需在上面的例子中将 `gzip` 换成 `bzip2`,将 `gunzip` 换成 `bunzip2`,将 `zcat` 换成 `bzcat` 即可。 + +要使用 `bzip2` 压缩一个文件,并以压缩后的文件取而代之,只需运行: -要使用 bzip2 压缩一个文件,并以压缩后的文件取而代之,只需运行: ``` $ bzip2 ostechnix.txt - ``` -如果你不想替换原始文件,那么可以使用 -c 选项,并把输出写入到新文件中。 +如果你不想替换原始文件,那么可以使用 `-c` 选项,并把输出写入到新文件中。 + ``` $ bzip2 -c ostechnix.txt > output.txt.bz2 - ``` 如果要解压缩文件,则运行: + ``` $ bzip2 -d ostechnix.txt.bz2 - ``` 或者, + ``` $ bunzip2 ostechnix.txt.bz2 - ``` 如果要在不解压缩的情况下查看一个压缩文件的内容,则运行: + ``` $ bunzip2 -c ostechnix.txt.bz2 - ``` 或者, + ``` $ bzcat ostechnix.txt.bz2 - ``` -如果你想了解关于 bzip2 的更多细节,请参阅它的 man 手册。 +如果你想了解关于 `bzip2` 的更多细节,请参阅它的 man 手册。 + ``` $ man bzip2 - ``` -##### 总结 +### 总结 -在这篇教程中,我们学习了 gzip 和 bzip2 程序是什么,并通过 GNU/Linux 下的一些例子学习了如何使用它们来压缩和解压缩文件。接下来,我们将要学习如何在 Linux 中将文件和目录归档。 +在这篇教程中,我们学习了 `gzip` 和 `bzip2` 程序是什么,并通过 GNU/Linux 下的一些例子学习了如何使用它们来压缩和解压缩文件。接下来,我们将要学习如何在 Linux 中将文件和目录归档。 干杯! - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-compress-and-decompress-files-in-linux/ 作者:[SK][a] -译者:[ucasFL](https://github.com/ucasFL) -校对:[校对者ID](https://github.com/校对者ID) 选题:[lujun9972](https://github.com/lujun9972) +译者:[ucasFL](https://github.com/ucasFL) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 205e1f3f615c672549f23089a3be046041df159c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 13 Sep 2018 22:01:50 +0800 Subject: [PATCH 209/455] PUB:20180324 How To Compress And Decompress Files In Linux.md @ucasFL https://linux.cn/article-10009-1.html --- .../20180324 How To Compress And Decompress Files In Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180324 How To Compress And Decompress Files In Linux.md (100%) diff --git a/translated/tech/20180324 How To Compress And Decompress Files In Linux.md b/published/20180324 How To Compress And Decompress Files In Linux.md similarity index 100% rename from translated/tech/20180324 How To Compress And Decompress Files In Linux.md rename to published/20180324 How To Compress And Decompress Files In Linux.md From 95f92e769b0277a170751a2c07c2ff1847674daf Mon Sep 17 00:00:00 2001 From: andrew Date: Fri, 14 Sep 2018 07:57:34 +0800 Subject: [PATCH 210/455] =?UTF-8?q?=E3=80=90=E7=BF=BB=E8=AF=91=E4=B8=AD?= =?UTF-8?q?=E3=80=915=20tips=20to=20improve=20productivity=20with=20zsh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tech/20180905 5 tips to improve productivity with zsh.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180905 5 tips to improve productivity with zsh.md b/sources/tech/20180905 5 tips to improve productivity with zsh.md index c1ad0d988c..0de2e6a05c 100644 --- a/sources/tech/20180905 5 tips to improve productivity with zsh.md +++ b/sources/tech/20180905 5 tips to improve productivity with zsh.md @@ -1,6 +1,8 @@ 5 tips to improve productivity with zsh ====== +### **[翻译中] by tnuoccalanosrep** + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/features_solutions_command_data.png?itok=4_VQN3RK) The Z shell known as [zsh][1] is a [shell][2] for Linux/Unix-like operating systems. It has similarities to other shells in the `sh` (Bourne shell) family, such as as `bash` and `ksh`, but it provides many advanced features and powerful command line editing options, such as enhanced Tab completion. From d11cf6d498bbc1b64d2ad9a0cc53de1ec4ab7f39 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 14 Sep 2018 08:54:29 +0800 Subject: [PATCH 211/455] translated --- ...To Choose A Suitable Linux Distribution.md | 79 ------------------- ...To Choose A Suitable Linux Distribution.md | 78 ++++++++++++++++++ 2 files changed, 78 insertions(+), 79 deletions(-) delete mode 100644 sources/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md create mode 100644 translated/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md diff --git a/sources/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md b/sources/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md deleted file mode 100644 index 79f8dfb3f9..0000000000 --- a/sources/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md +++ /dev/null @@ -1,79 +0,0 @@ -translating---geekpi - -Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution -====== -![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-logo-720x340.png) -Howdy Linux newbies! Today, I have come up with a good news for you!! You might wondering how to choose a suitable Linux distribution for you. Of course, you might already have consulted some Linux experts to help you to select a Linux distribution for your needs. And some of you might have googled and gone through various resources, Linux forums, websites and blogs in the pursuit of finding perfect distro. Well, you need not to do that anymore. Meet **Distrochooser** , a website that helps you to easily find out a Linux distribution. - -### How Distrochooser will help Linux beginners choose a suitable Linux distribution? - -The Distrochooser will ask you a series of questions and suggests you different suitable Linux distributions to try, based on your answers. Excited? Great! Let us go ahead and see how to find out a suitable Linux distribution. Click on the following link to get started. - -![][2] - -You will be now redirected to Distrochooser home page where a small test is awaiting for you to enroll. -![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-home-page.png) - -You need to answer a series of questions (16 questions to be precise). Both single choice and multiple choice questions are provided there. Here are the complete list of questions. - - 1. Software: Use case - 2. Computer knowledge - 3. Linux Knowledge - 4. Installation: Presets - 5. Installation: Live-Test needed? - 6. Installation: Hardware support - 7. Configuration: Help source - 8. Distributions: User experience concept - 9. Distributions: Price - 10. Distributions: Scope - 11. Distributions: Ideology - 12. Distributions: Privacy - 13. Distributions: Preset themes, icons and wallpapers - 14. Distribution: Special features - 15. Software: Administration - 16. Software: Updates - - - -Carefully read the questions and choose the appropriate answer(s) below the respective questions. Distrochooser gives more options to choose a near-perfect distribution. - - * You can always skip questions, - * You can always click on ‘get result’, - * You can answer in arbitrary order, - * You can delete answers at any time, - * You can weight properties at the end of the test to emphasize what is important to you. - - - -After choosing the answer(s) for a question, click **Proceed** to move to the next question. Once you are done, click on **Get result** button. You can also clear the selection at any time by clicking on the **“Clear”** button below the answers. - -### Results? - -I didn’t believe Distrochooser will exactly find what I am looking for. Oh boy, I was wrong! To my surprise, it did indeed a good job. The results were almost accurate to me. I was expecting Arch Linux in the result and indeed it was my top recommendation, followed by 11 other recommendations such as NixOS, Void Linux, Qubes OS, Scientific Linux, Devuan, Gentoo Linux, Bedrock Linux, Slackware, CentOS, Linux from scratch and Redhat Enterprise Linux. Totally, I got 12 recommendations and each result is very detailed along with distribution’s description and home page link for each distribution. - -![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-result.png) - -I posted Distrochooser link on Reddit and 80% of the users could be able to find suitable Linux distribution for them. However, I won’t claim Distrochooser alone is enough to find good results for everyone. Some users disappointed about the survey result and the result wasn’t even close to what they use or want to use. So, I strongly recommend you to consult other Linux experts, websites, forums before trying any Linux. You can read the full Reddit discussion [**here**][3]. - -What are you waiting for? Go to the Distrochooser site and choose a suitable Linux distribution for you. - -And, that’s all for now, folks. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/distrochooser-helps-linux-beginners-to-choose-a-suitable-linux-distribution/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.ostechnix.com/author/sk/ -[2]:https://distrochooser.de/en -[3]:https://www.reddit.com/r/linux/comments/93p6az/distrochooser_helps_linux_beginners_to_choose_a/ diff --git a/translated/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md b/translated/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md new file mode 100644 index 0000000000..b3362c4a37 --- /dev/null +++ b/translated/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md @@ -0,0 +1,78 @@ +Distrochooser 帮助 Linux 初学者选择合适的 Linux 发行版 +====== +![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-logo-720x340.png) +你好 Linux 新手!今天,我为你们带来了一个好消息!你也许想知道如何选择合适的 Linux 发行版。当然,你可能已经咨询过一些 Linux 专家来帮助你的需要选择 Linux 发行版。你们中的一些人可能已经用 Google 搜索并浏览了各种资源、Linux 论坛、网站和博客来寻找完美的发行版。好了,你不必再那样做了。有了 **Distrochooser**,一个帮助你轻松找到 Linux 发行版的网站。 + + +### Distrochooser 如何帮助 Linux 初学者选择合适的 Linux 发行版? + +Distrochooser 会根据你的答案向你询问一系列问题并建议你尝试不同的 Linux 发行版。激动吗?太好了!让我们继续看看如何找到合适的 Linux 发行版。单击以下链接开始。 + +![][2] + +你将被重定向到 Distrochooser 主页,其中有一个小测试在等待你注册。 +![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-home-page.png) + +你需要回答一系列问题(准确地说是 16 个问题)。问题同时有单选和多选。以下是完整的问题列表。 + + 1. 软件:使用情况 + 2. 计算机知识 + 3. Linux 知识 + 4. 安装:预设 + 5. 安装:需要 Live 测试么? + 6. 安装:硬件支持 + 7. 配置:帮助源 + 8. 发行版:用户体验概念 + 9. 发行版:价格 + 10. 发行版:范围 + 11. 发行版:意识形态 + 12. 发行版:隐私 + 13. 发行版:预设主题,图标和壁纸 + 14. 发行版:特色 + 15. 软件:管理 + 16. 软件:更新 + + + +仔细阅读问题并在相应问题下面选择合适的答案。Distrochooser 提供了更多选择来选择接近完美的发行版。 + + * 你总是可以跳过问题, + * 你可以随时点击“获取结果”, + * 你可以任意顺序回答, + * 你可以随时删除答案, + * 你可以在测试结束时对属性进行加权,以强调对你来说重要的内容。 + + + +选择问题的答案后,单击**继续**以转到下一个问题。完成后,单击**获取结果**按钮。你也可以通过单击答案下面的**“清除”**按钮随时清除选择。 + +### 结果? + +我以前不相信 Distrochooser 会找到我想要的东西。哦,我错了!令我惊讶的是,它确实做得很好。结果对我来说几乎是准确的。我期待 Arch Linux 在结果中,结果确实是在推荐第一位,接下来是其他 11 个建议,如 NixOS、Void Linux、Qubes OS、Scientific Linux、Devuan、Gentoo Linux、Bedrock Linux、Slackware、CentOS、Linux from scratch、Redhat Enterprise Linux。总共有 12 个推荐,每个结果都非常详细,带有发行版的描述和主页。 + +![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-result.png) + +我在 Reddit 上发布了 Distrochooser 链接,80% 的用户可以找到合适的 Linux 发行版。但是,我不会声称 Distrochooser 足以为每个人找到好结果。一些用户对调查结果感到失望,甚至结果与他们使用中或者想要使用的一点不接近。因此,我强烈建议你在尝试任何 Linux 之前咨询其他 Linux 专家、网站和论坛。你可以在[**这里**][3]阅读完整的 Reddit 讨论。 + +你在等什么?进入 Distrochooser 网站并为你选择合适的 Linux 发行版吧。 + +就是这些了。还有更多好东西。敬请期待! + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/distrochooser-helps-linux-beginners-to-choose-a-suitable-linux-distribution/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[2]:https://distrochooser.de/en +[3]:https://www.reddit.com/r/linux/comments/93p6az/distrochooser_helps_linux_beginners_to_choose_a/ From ca2d8290cc3e54488c23979bd6edfe4a2fc76943 Mon Sep 17 00:00:00 2001 From: XiatianSummer Date: Fri, 14 Sep 2018 09:04:03 +0800 Subject: [PATCH 212/455] Delete 20180911 Visualize Disk Usage On Your Linux System.md --- ...sualize Disk Usage On Your Linux System.md | 105 ------------------ 1 file changed, 105 deletions(-) delete mode 100644 sources/tech/20180911 Visualize Disk Usage On Your Linux System.md diff --git a/sources/tech/20180911 Visualize Disk Usage On Your Linux System.md b/sources/tech/20180911 Visualize Disk Usage On Your Linux System.md deleted file mode 100644 index dccb9de4c2..0000000000 --- a/sources/tech/20180911 Visualize Disk Usage On Your Linux System.md +++ /dev/null @@ -1,105 +0,0 @@ -XiatianSummer translating - -Visualize Disk Usage On Your Linux System -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-720x340.png) - -Finding disk space usage is no big deal in Unix-like operating systems. We have a built-in command named [**du**][1] that can be used to calculate and summarize the disk space usage in minutes. And, we have some third-party tools like [**Ncdu**][2] and [**Agedu**][3] which can also be used to track down the disk usage. As you already know, these are all command line utilities and you will see the disk usage results in plain-text format. However, some of you’d like to view the results in visual or kind of image format. No worries! I know one such GUI tool to find out the disk usage details. Say hello to **“Filelight”** , a graphical utility to visualize disk usage on your Linux system and displays the disk usage results in a colored radial layout. Filelight is one of the oldest project and it has been around for a long time. It is completely free to use and open source. - -### Installing Filelight - -Filelight is part of KDE applications and comes pre-installed with KDE-based Linux distributions. - -If you’re using non-KDE distros, Filelight is available in the official repositories, so you can install it using the default package manager. - -On Arch Linux and its variants such as Antergos, Manjaro Linux, Filelight can be installed as below. - -``` -$ sudo pacman -S filelight -``` - -On Debian, Ubuntu, Linux Mint: - -``` -$ sudo apt install filelight -``` - -On Fedora: - -``` -$ sudo dnf install filelight -``` - -On openSUSE: - -``` -$ sudo zypper install filelight -``` - -### Visualize Disk Usage On Your Linux System - -Once installed, launch Filelight from Menu or application launcher. - -FIlelight graphically represents your filesystem as a set of concentric segmented-rings. - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-1-1.png) - -As you can see, Filelight displays the disk usage of the **/** and **/boot** filesystems by default. - -You can also scan the individual folders of your choice to view the disk usage of that particular folder. To do so, go to **Filelight - > Scan -> Scan Folder** and choose the folder you want to scan. - -Filelight excludes the following directories from scanning: - - * /dev - * /proc - * /sys - * /root - - - -This option is helpful to skip the directories that you may not have permissions to read, or folders that are part of a virtual filesystem, such as /proc. - -If you want to add any folder in this list, go to **Filelight - > Settings -> Scanning** and click “add” button and choose the folder you want to add in this list. - -![](http://www.ostechnix.com/wp-content/uploads/2018/09/filelight-settings.png) - -Similarly, to remove a folder from the list, choose the folder and click on “Remove”. - -If you want to change the way filelight looks, go to **Settings - > Appearance** tab and change the color scheme as per your liking. - -Each segment in the radial layout is represented with different colors. The following image represents the entire radial layout of **/** filesystem. To view the full information of files and folders, just hover the mouse pointer over them. - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-2.png) - -You can navigate around the the filesystem by simply clicking on the respective segment. To view the disk usage of any file or folder, just click on them and you will get the complete disk usage details of that particular folder/file. - -Not just local filesystem, Filelight can able to scan your local, remote and removable disks. If you’re using any KDE-based Linux distribution, it can be integrated into file managers like Konqueror, Dolphin and Krusader. - -Unlike the CLI utilities, you don’t have to use any extra arguments or options to view the results in human-readable format. Filelight will display the disk usage in human-readable format by default. - -### Conclusion - -By using Filelight, you can quickly discover where exactly your diskspace is being used in your filesystem and free up the space wherever necessary by deleting the unwanted files or folders. If you are looking for some simple and user-learnedly graphical disk usage viewer, Filelight is worth trying. - -And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/filelight-visualize-disk-usage-on-your-linux-system/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/sk/ -[1]: https://www.ostechnix.com/find-size-directory-linux/ -[2]: https://www.ostechnix.com/check-disk-space-usage-linux-using-ncdu/ -[3]: https://www.ostechnix.com/agedu-find-out-wasted-disk-space-in-linux/ From 13c29fa13b7fa0c8da935bdd5ee81cf768f051f0 Mon Sep 17 00:00:00 2001 From: XiatianSummer Date: Fri, 14 Sep 2018 09:04:38 +0800 Subject: [PATCH 213/455] Create 20180911 Visualize Disk Usage On Your Linux System.md --- ...sualize Disk Usage On Your Linux System.md | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 translated/tech/20180911 Visualize Disk Usage On Your Linux System.md diff --git a/translated/tech/20180911 Visualize Disk Usage On Your Linux System.md b/translated/tech/20180911 Visualize Disk Usage On Your Linux System.md new file mode 100644 index 0000000000..4f18f8a786 --- /dev/null +++ b/translated/tech/20180911 Visualize Disk Usage On Your Linux System.md @@ -0,0 +1,101 @@ +可视化查看 Linux 系统上的磁盘使用情况 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-720x340.png) + +查看硬盘使用情况对于类 Unix 操作系统来说不是什么大问题。我们有一个名为 [**du**][1] 的内置命令,可以在分钟之内计算和汇总磁盘空间的使用情况。此外,我们还有一些第三方工具,比如 [**Ncdu**][2] and [**Agedu**][3],它们也可以用来追踪磁盘使用情况。如您所见,这些都是命令行中的实用程序,磁盘使用情况将以纯文本的形式显示。但是,有些人希望以可视化、图表的形式查看结果。别担心!我知道一个 GUI 工具可以显示磁盘使用细节。它就是“**Filelight**”,这是一个图形化实用程序,用于可视化显示 Linux 系统上的磁盘使用情况,并以彩色径向图显示结果。Filelight 是历史最悠久的项目之一,它已经存在了很长时间,它完全免费使用并开源。 + +### 安装 Filelight + +Filelight 是 KDE 应用程序的一部分,并预装在基于 KDE 的 Linux 发行版上。 + +如果您使用的是非 KDE 发行版,官方存储库中包含了 Filelight,因此您可以使用默认的包管理器进行安装。 + +在 Arch Linux 及其衍生版,如 Antergos,Manjaro Linux 中,Filelight 可以按照如下方法安装。 + +``` +$ sudo pacman -S filelight +``` + +在 Debian、Ubuntu、Linux Mint 中, + +``` +$ sudo apt install filelight +``` + +在 Fedora 中, + +``` +$ sudo dnf install filelight +``` + +在 openSUSE 中, + +``` +$ sudo zypper install filelight +``` + +### 可视化查看 Linux 系统上的磁盘使用情况 + +安装后,从菜单或应用程序启动器启动 Filelight。 + +Filelight 以图形方式将您的文件系统表示为一组同心圆环段。 + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-1-1.png) + +如您所见,Filelight 默认显示磁盘中 **/** 和 **/boot** 文件系统的使用情况。 + +您还可以选择扫描的各个文件夹,以查看该特定文件夹的磁盘使用情况。为此,请到 **Filelight - > Scan -> Scan Folder** 并选择要扫描的文件夹。 + +Filelight 在扫描时排除以下目录: + + * /dev + * /proc + * /sys + * /root + + + +此选项有助于跳过您可能没有权限读取的目录,或者属于虚拟文件系统的文件夹,例如 **/proc**。 + +如果您想要在此列表中增加文件夹,请到 **Filelight - > Settings -> Scanning** 并点击“Add”按钮然后选择您想要增加的文件夹。 + +![](http://www.ostechnix.com/wp-content/uploads/2018/09/filelight-settings.png) + +类似的,要想从此列表中移除某个文件夹,选择文件夹并点击“Remove”。 + +如果您想要改变 Filelight 的外观,请到 **Settings - > Appearance** 栏,按照您的喜好改变配色方案。 + +径向图中的每个段用不同的颜色表示。下图显示了 **/** 文件系统的整个径向布局。要查看文件和文件夹的完整信息,只需将鼠标指针悬停在它们上边。 + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-2.png) + +只需点击相应的段即可浏览文件系统。要查看某个文件或文件夹的磁盘使用情况,只需单击它们即可获得该特定文件夹、文件的完整磁盘使用情况。 + +不仅仅是本地文件系统,Filelight 还能够扫描远程磁盘和可移动磁盘。 如果您使用任何基于 KDE 的 Linux 发行版,它可以集成到 Konqueror,Dolphin 和 Krusader 等文件管理器中。 + +与 CLI 实用程序不同,您不必使用任何额外的参数或选项来以易读的(而非乱码的)格式查看结果。 默认情况下,Filelight 将自动以易读的格式显示磁盘使用情况。 + +### 总结 + +使用 Filelight,您可以快速找到文件系统中占用磁盘空间的位置,并通过删除不需要的文件或文件夹释放空间。 如果您正在寻找一些简单且易上手的图形界面磁盘使用情况查看器,那么 Filelight 值得一试。 + +就是这样。希望这篇文章对您有用。更多的好文章,敬请关注! + +干杯! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/filelight-visualize-disk-usage-on-your-linux-system/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[XiatianSummer](https://github.com/XiatianSummer) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://www.ostechnix.com/find-size-directory-linux/ +[2]: https://www.ostechnix.com/check-disk-space-usage-linux-using-ncdu/ +[3]: https://www.ostechnix.com/agedu-find-out-wasted-disk-space-in-linux/ From c93dcf8b75830310dc1aa2eb9b7a4c3d9453beb6 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 14 Sep 2018 09:06:41 +0800 Subject: [PATCH 214/455] translating --- ...ash - A CLI Tool To Automatically Purge Old Trashed Files.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md b/sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md index be3295a0a1..a11675a264 100644 --- a/sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md +++ b/sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md @@ -1,3 +1,5 @@ +translating---geekpi + Autotrash – A CLI Tool To Automatically Purge Old Trashed Files ====== From 1cf9a835b4845aef048b98ffe67eb1ef61a28c17 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 14 Sep 2018 09:53:07 +0800 Subject: [PATCH 215/455] PRF:20180425 Understanding metrics and monitoring with Python - Opensource.com.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @qhwdw 辛苦了。 --- ...monitoring with Python - Opensource.com.md | 240 +++++++++--------- 1 file changed, 114 insertions(+), 126 deletions(-) diff --git a/translated/tech/20180425 Understanding metrics and monitoring with Python - Opensource.com.md b/translated/tech/20180425 Understanding metrics and monitoring with Python - Opensource.com.md index 278759ad6a..29cf30dc41 100644 --- a/translated/tech/20180425 Understanding metrics and monitoring with Python - Opensource.com.md +++ b/translated/tech/20180425 Understanding metrics and monitoring with Python - Opensource.com.md @@ -1,22 +1,16 @@ -# 理解指标和使用 Python 去监视 +理解监测指标,并使用 Python 去监测它们 +====== +> 通过学习这些关键的术语和概念来理解 Python 应用监测。 ![Understanding metrics and monitoring with Python](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_graph_stats_blue.png?itok=OKCc_60D "Understanding metrics and monitoring with Python") -Image by :  +当我第一次看到术语“计数器counter”和“计量器gauge”和使用颜色及标记着“平均数”和“大于 90%”的数字图表时,我的反应之一是逃避。就像我看到它们一样,我并不感兴趣,因为我不理解它们是干什么的或如何去使用。因为我的工作不需要我去注意它们,它们被我完全无视。 -opensource.com +这都是在两年以前的事了。随着我的职业发展,我希望去了解更多关于我们的网络应用程序的知识,而那个时候就是我开始去学习监测指标metrics的时候。 -## 获取订阅 +我的理解监测的学习之旅共有三个阶段(到目前为止),它们是: -加入我们吧,我们有 85,000 位开源支持者,加入后会定期接收到我们免费提供的提示和文章摘要。 - -当我第一次看到术语“计数器”和“计量器”和使用颜色及标记着“意思”和“最大 90”的数字图表时,我的反应之一是逃避。就像我看到它们一样,我并不感兴趣,因为我不理解它们是干什么的或如何去使用。因为我的工作不需要我去注意它们,它们被我完全无视。 - -这都是在两年以前的事了。随着我的职业发展,我希望去了解更多关于我们的网络应用程序的知识,而那个时候就是我开始去学习指标的时候。 - -我的理解监视的学习之旅共有三个阶段(到目前为止),它们是: - -* 阶段 1:什么?(看别处) +* 阶段 1:什么?(王顾左右) * 阶段 2:没有指标,我们真的是瞎撞。 * 阶段 3:出现不合理的指标我们该如何做? @@ -24,21 +18,13 @@ opensource.com 我们开始吧! -## 需要的软件 - -更多关于 Python 的资源 - -* [Python 是什么?][1] -* [Python IDE 排行榜][2] -* [Python GUI 框架排行榜][3] -* [最新的 Python 主题][4] -* [更多开发者资源][5] +### 需要的软件 在文章中讨论时用到的 demo 都可以在 [我的 GitHub 仓库][6] 中找到。你需要安装 docker 和 docker-compose 才能使用它们。 -## 为什么要监视? +### 为什么要监测? -关于监视的主要原因是: +关于监测的主要原因是: * 理解 _正常的_ 和 _不正常的_ 系统和服务的特征 * 做容量规划、弹性伸缩 @@ -47,43 +33,43 @@ opensource.com * 测量响应中的系统行为变化 * 当系统出现意外行为时发出警报 -## 指标和指标类型 +### 指标和指标类型 -从我们的用途来看,一个**指标**就是在一个给定时间点上的某些数量的 _测量_ 值。博客文章的总点击次数、参与讨论的总人数、在缓存系统中数据没有被找到的次数、你的网站上的已登录用户数 —— 这些都是指标的例子。 +从我们的用途来看,一个**指标**就是在一个给定*时间*点上的某些数量的 _测量_ 值。博客文章的总点击次数、参与讨论的总人数、在缓存系统中数据没有被找到的次数、你的网站上的已登录用户数 —— 这些都是指标的例子。 它们总体上可以分为三类: -### 计数器 +#### 计数器 -以你的个人博客为例。你发布一篇文章后,过一段时间后,你希望去了解有多少点击量,数字只会增加。这就是一个**计数器**指标。在你的博客文章的生命周期中,它的值从 0 开始增加。用图表来表示,一个计数器看起来应该像下面的这样: +以你的个人博客为例。你发布一篇文章后,过一段时间后,你希望去了解有多少点击量,这是一个只会增加的数字。这就是一个计数器counter指标。在你的博客文章的生命周期中,它的值从 0 开始增加。用图表来表示,一个计数器看起来应该像下面的这样: ![Counter metric](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/counter-graph.png?itok=BZYrB-Hn "Counter metric") -一个计数器指标总是在增加的。 +*一个计数器指标总是在增加的。* -### 计量器 +#### 计量器 -如果你想去跟踪你的博客每天或每周的点击量,而不是基于时间的总点击量。这种指标被称为一个**计量器**,它的值可上可下。用图表来表示,一个计量器看起来应该像下面的样子: +如果你想去跟踪你的博客每天或每周的点击量,而不是基于时间的总点击量。这种指标被称为一个计量器gauge,它的值可上可下。用图表来表示,一个计量器看起来应该像下面的样子: ![gauge metric](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gauge-graph.png?itok=UA4u4cwz "gauge metric") -一个计量器指标可以增加或减少。 +*一个计量器指标可以增加或减少。* -一个计量器的值在某些时间窗口内通常有一个_最大值_ 和 _最小值_ 。 +一个计量器的值在某些时间窗口内通常有一个最大值ceilingfloor。 -### 柱状图和计时器 +#### 柱状图和计时器 -一个**柱状图**(在 Prometheus 中这么叫它)或一个**计时器**(在 StatsD 中这么叫它)是跟踪已采样的_观测结果_ 的指标。不像一个计数器类或计量器类指标,柱状图指标的值并不是显示为上或下的样式。我知道这可能并没有太多的意义,并且可能和一个计量器图看上去没有什么不同。它们的这同之处在于,你期望使用柱状图数据来做什么,而不是与一个计量器图做比较。因此,监视系统需要知道那个指标是一个柱状图类型,它允许你去做哪些事情。 +柱状图histogram(在 Prometheus 中这么叫它)或计时器 timer(在 StatsD 中这么叫它)是一个跟踪 _已采样的观测结果_ 的指标。不像一个计数器类或计量器类指标,柱状图指标的值并不是显示为上或下的样式。我知道这可能并没有太多的意义,并且可能和一个计量器图看上去没有什么不同。它们的不同之处在于,你期望使用柱状图数据来做什么,而不是与一个计量器图做比较。因此,监测系统需要知道那个指标是一个柱状图类型,它允许你去做哪些事情。 ![Histogram metric](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/histogram-graph.png?itok=cHI1v7Ly "Histogram metric") -一个柱状图指标可以增加或减少。 +*一个柱状图指标可以增加或减少。* -## Demo 1:计算和报告指标 +### Demo 1:计算和报告指标 [Demo 1][7] 是使用 [Flask][8] 框架写的一个基本的 web 应用程序。它演示了我们如何去 _计算_ 和 _报告_ 指标。 -在 src 目录中有 `app.py` 和 `src/helpers/middleware.py` 应用程序,包含以下内容: +在 `src` 目录中有 `app.py` 和 `src/helpers/middleware.py` 应用程序,包含以下内容: ``` from flask import request @@ -110,9 +96,9 @@ def setup_metrics(app):     app.after_request(stop_timer) ``` -当在应用程序中调用 `setup_metrics()` 时,它在请求处理之前被配置为调用 `start_timer()` 函数,然后在请求处理之后、响应发送之前调用 `stop_timer()` 函数。在上面的函数中,我们写了时间戳并用它来计算处理请求所花费的时间。 +当在应用程序中调用 `setup_metrics()` 时,它配置在一个请求被处理之前调用 `start_timer()` 函数,然后在该请求处理之后、响应发送之前调用 `stop_timer()` 函数。在上面的函数中,我们写了时间戳并用它来计算处理请求所花费的时间。 -当我们在 demo1 目录中的 docker-compose 上开始去启动 web 应用程序,然后在一个客户端容器中生成一些对 web 应用程序的请求。你将会看到创建了一个 `src/metrics.csv` 文件,它有两个字段:timestamp 和 request_latency。 +当我们在 `demo1` 目录中运行 `docker-compose up`,它会启动这个 web 应用程序,然后在一个客户端容器中可以生成一些对 web 应用程序的请求。你将会看到创建了一个 `src/metrics.csv` 文件,它有两个字段:`timestamp` 和 `request_latency`。 通过查看这个文件,我们可以推断出两件事情: @@ -121,45 +107,47 @@ def setup_metrics(app): 没有观测到与指标相关的特征,我们就不能说这个指标与哪个 HTTP 端点有关联,或这个指标是由哪个应用程序的节点所生成的。因此,我们需要使用合适的元数据去限定每个观测指标。 -## Statistics 101~~(译者注:这是一本统计学入门教材的名字)~~ +### 《Statistics 101》 -假如我们回到高中数学,我们应该回忆起一些统计术语,虽然不太确定,但应该包括平均数、中位数、百分位、和柱状图。我们来简要地回顾一下它们,不用去管他们的用法,就像是在上高中一样。 +(LCTT 译注:这是一本统计学入门教材的名字) -### 平均数 +假如我们回到高中数学,我们应该回忆起一些统计术语,虽然不太确定,但应该包括平均数、中位数、百分位和柱状图。我们来简要地回顾一下它们,不用去管它们的用法,就像是在上高中一样。 -**平均数**,或一系列数字的平均值,是将数字汇总然后除以列表的个数。3、2、和 10 的平均数是 (3+2+10)/3 = 5。 +#### 平均数 -### 中位数 +平均数mean,即一系列数字的平均值,是将数字汇总然后除以列表的个数。3、2 和 10 的平均数是 (3+2+10)/3 = 5。 -**中位数**是另一种类型的平均,但它的计算方式不同;它是列表从小到大排序(反之亦然)后取列表的中间数字。以我们上面的列表中(2、3、10),中位数是 3。计算并不简单,它取决于列表中数字的个数。 +#### 中位数 -### 百分位 +中位数median是另一种类型的平均,但它的计算方式不同;它是列表从小到大排序(反之亦然)后取列表的中间数字。以我们上面的列表中(2、3、10),中位数是 3。计算并不是非常直观,它取决于列表中数字的个数。 -**百分位**是指那个百(千)分比数字低于我们给定的百分数的程度。在一些场景中,百分位是指这个测量值低于我们数据的百(千)分比数字的程度。比如,上面列表中 95% 是 9.29999。百分位的测量范围是 0 到 100(不包括)。0% 是一组数字的最小分数。你可能会想到它的中位数是 50%,它的结果是 3。 +#### 百分位 -一些监视系统将百分位称为 `upper_X`,其中 _X_ 就是百分位;`_upper 90_` 指的是值在 90%的位置。 +百分位percentile是指那个百(千)分比数字低于我们给定的百分数的程度。在一些场景中,它是指这个测量值低于我们数据的百(千)分比数字的程度。比如,上面列表中 95% 是 9.29999。百分位的测量范围是 0 到 100(不包括)。0% 是一组数字的最小分数。你可能会想到它的中位数是 50%,它的结果是 3。 -### 分位数 +一些监测系统将百分位称为 `upper_X`,其中 _X_ 就是百分位;`upper 90` 指的是在 90% 的位置的值。 -**q-Quantile** 是将有 _N_ 个数的集合等分为 q_N_ 个集合。**q** 的取值范围为 0 到 1(全部都包括)。当 **q** 取值为 0.5 时,值就是中位数。分位数和百分位数的关系是,分位数值 **q** 等于 **100_q_** 百分位值。 +#### 分位数 -### 柱状图 +“q-分位数”是将有 _N_ 个数的集合等分为 `qN` 级。`q` 的取值范围为 0 到 1(全部都包括)。当 `q` 取值为 0.5 时,值就是中位数。(分位数quantile)和百分位数的关系是,分位数值 `q` 等于 `100` 百分位值。 -**柱状图**这个指标,我们早期学习过,它是监视系统中一个_详细的实现_。在统计学中,一个柱状图是一个将数据分组为 _桶_ 的图表。我们来考虑一个人为的、不同的示例:阅读你的博客的人的年龄。如果你有一些这样的数据,并想将它进行大致的分组,绘制成的柱状图将看起来像下面的这样: +#### 柱状图 + +histogram这个指标,我们前面学习过,它是监测系统中一个_实现细节_。在统计学中,一个柱状图是一个将数据分组为 _桶_ 的图表。我们来考虑一个人为的不同示例:阅读你的博客的人的年龄。如果你有一些这样的数据,并想将它进行大致的分组,绘制成的柱状图将看起来像下面的这样: ![Histogram graph](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/histogram.png?itok=gqfhjB8p "Histogram graph") -### 累积柱状图 +#### 累积柱状图 -一个**累积柱状图**也是一个柱状图,它的每个桶的数包含前一个桶的数,因此命名为_累积_。将上面的数据集做成累积柱状图后,看起来应该是这样的: +一个累积柱状图cumulative histogram也是一个柱状图,它的每个桶的数包含前一个桶的数,因此命名为_累积_。将上面的数据集做成累积柱状图后,看起来应该是这样的: ![Cumulative histogram](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/cumulative-histogram.png?itok=wIGQdZnT "Cumulative histogram") -### 我们为什么需要做统计? +#### 我们为什么需要做统计? -在上面的 Demo 1 中,我们注意到在我们报告指标时,这里生成了许多数据。当我们将它用于指标时我们需要做统计,因为它们实在是太多了。我们需要的是整体行为,我们没法去处理单个值。我们预期展现出来的值的行为应该是代表我们观察的系统的行为。 +在上面的 Demo 1 中,我们注意到在我们报告指标时,这里生成了许多数据。当我们将它们用于指标时我们需要做统计,因为它们实在是太多了。我们需要的是整体行为,我们没法去处理单个值。我们预期展现出来的值的行为应该是代表我们观察的系统的行为。 -## Demo 2:指标上增加特征 +### Demo 2:在指标上增加特征 在我们上面的的 Demo 1 应用程序中,当我们计算和报告一个请求的延迟时,它指向了一个由一些_特征_ 唯一标识的特定请求。下面是其中一些: @@ -169,7 +157,7 @@ def setup_metrics(app): 如果我们将这些特征附加到要观察的指标上,每个指标将有更多的内容。我们来解释一下 [Demo 2][9] 中添加到我们的指标上的特征。 -在写入指标时,src/helpers/middleware.py 文件将在 CSV 文件中写入多个列: +在写入指标时,`src/helpers/middleware.py` 文件将在 CSV 文件中写入多个列: ``` node_ids = ['10.0.1.1', '10.1.3.4'] @@ -194,20 +182,20 @@ def stop_timer(response):     return response ``` -因为这只是一个演示,在报告指标时,我们将随意的报告一些随机 IP 作为节点的 ID。当我们在 demo2 目录下运行 docker-compose 时,我们的结果将是一个有多个列的 CSV 文件。 +因为这只是一个演示,在报告指标时,我们将随意的报告一些随机 IP 作为节点的 ID。当我们在 `demo2` 目录下运行 `docker-compose up` 时,我们的结果将是一个有多个列的 CSV 文件。 -### 用 pandas 分析指标 +#### 用 pandas 分析指标 -我们将使用 [pandas][10] 去分析这个 CSV 文件。运行中的 docker-compose 将打印出一个 URL,我们将使用它来打开一个 [Jupyter][11] 会话。一旦我们上传 `Analysis.ipynb notebook` 到会话中,我们就可以将 CSV 文件读入到一个 pandas 数据帧中: +我们将使用 [pandas][10] 去分析这个 CSV 文件。运行 `docker-compose up` 将打印出一个 URL,我们将使用它来打开一个 [Jupyter][11] 会话。一旦我们上传 `Analysis.ipynb notebook` 到会话中,我们就可以将 CSV 文件读入到一个 pandas 数据帧DataFrame中: ``` import pandas as pd metrics = pd.read_csv('/data/metrics.csv', index_col=0) ``` -index_col 指定时间戳作为索引。 +`index_col` 表明我们要指定时间戳作为索引。 -因为每个特征我们都在数据帧中添加一个列,因此我们可以基于这些列进行分组和聚合: +因为每个特征我们都要在数据帧中添加一个列,因此我们可以基于这些列进行分组和聚合: ``` import numpy as np @@ -216,48 +204,48 @@ metrics.groupby(['node_id', 'http_status']).latency.aggregate(np.percentile, 99. 更多内容请参考 Jupyter notebook 在数据上的分析示例。 -## 我应该监视什么? +### 我应该监测什么? 一个软件系统有许多的变量,这些变量的值在它的生命周期中不停地发生变化。软件是运行在某种操作系统上的,而操作系统同时也在不停地变化。在我看来,当某些东西出错时,你所拥有的数据越多越好。 -我建议去监视的关键操作系统指标有: +我建议去监测的关键操作系统指标有: * CPU 使用 * 系统内存使用 * 文件描述符使用 * 磁盘使用 -还需要监视的其它关键指标根据你的软件应用程序不同而不同。 +还需要监测的其它关键指标根据你的软件应用程序不同而不同。 -### 网络应用程序 +#### 网络应用程序 如果你的软件是一个监听客户端请求和为它提供服务的网络应用程序,需要测量的关键指标还有: * 入站请求数(计数器) * 未处理的错误(计数器) * 请求延迟(柱状图/计时器) -* 队列时间,如果在你的应用程序中有队列(柱状图/计时器) +* 排队时间,如果在你的应用程序中有队列(柱状图/计时器) * 队列大小,如果在你的应用程序中有队列(计量器) -* 工作进程/线程使用(计量器) +* 工作进程/线程用量(计量器) -如果你的网络应用程序在一个客户端请求的环境中向其它服务发送请求,那么它应该有一个指标去记录它与那个服务之间的通讯行为。需要监视的关键指标包括请求数、请求延迟、和响应状态。 +如果你的网络应用程序在一个客户端请求的环境中向其它服务发送请求,那么它应该有一个指标去记录它与那个服务之间的通讯行为。需要监测的关键指标包括请求数、请求延迟、和响应状态。 -### HTTP web 应用程序后端 +#### HTTP web 应用程序后端 -HTTP 应用程序应该监视上面所列出的全部指标。除此之外,还应该按 HTTP 状态代码分组监视所有非 200 的 HTTP 状态代码的大致数据。如果你的 web 应用程序有用户注册和登录功能,同时也应该为这个功能设置指标。 +HTTP 应用程序应该监测上面所列出的全部指标。除此之外,还应该按 HTTP 状态代码分组监测所有非 200 的 HTTP 状态代码的大致数据。如果你的 web 应用程序有用户注册和登录功能,同时也应该为这个功能设置指标。 -### 长周期运行的进程 +#### 长时间运行的进程 -长周期运行的进程如 Rabbit MQ 消费者或 task-queue 工作进程,虽然它们不是网络服务,它们以选取一个任务并处理它的工作模型来运行。因此,我们应该监视请求的进程数和这些进程的请求延迟。 +长时间运行的进程如 Rabbit MQ 消费者或任务队列的工作进程,虽然它们不是网络服务,它们以选取一个任务并处理它的工作模型来运行。因此,我们应该监测请求的进程数和这些进程的请求延迟。 不管是什么类型的应用程序,都有指标与合适的**元数据**相关联。 -## 将监视集成到一个 Python 应用程序中 +### 将监测集成到一个 Python 应用程序中 -将监视集成到 Python 应用程序中需要涉及到两个组件: +将监测集成到 Python 应用程序中需要涉及到两个组件: * 更新你的应用程序去计算和报告指标 -* 配置一个监视基础设施来容纳应用程序的指标,并允许去查询它们 +* 配置一个监测基础设施来容纳应用程序的指标,并允许去查询它们 下面是记录和报告指标的基本思路: @@ -276,15 +264,15 @@ def work(): 考虑到上面的模式,我们经常使用修饰符、内容管理器、中间件(对于网络应用程序)所带来的好处去计算和报告指标。在 Demo 1 和 Demo 2 中,我们在一个 Flask 应用程序中使用修饰符。 -### 指标报告时的拉取和推送模型 +#### 指标报告时的拉取和推送模型 -大体来说,在一个 Python 应用程序中报告指标有两种模式。在 _拉取_ 模型中,监视系统在一个预定义的 HTTP 端点上“刮取”应用程序。在_推送_ 模型中,应用程序发送数据到监视系统。 +大体来说,在一个 Python 应用程序中报告指标有两种模式。在 _拉取_ 模型中,监测系统在一个预定义的 HTTP 端点上“刮取”应用程序。在_推送_ 模型中,应用程序发送数据到监测系统。 ![Pull and push models](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pull_push_model.png?itok=U093wSy8 "Pull and push models") -工作在 _拉取_ 模型中的监视系统的一个例子是 [Prometheus][12]。而 [StatsD][13] 是 _推送_ 模型的一个例子。 +工作在 _拉取_ 模型中的监测系统的一个例子是 [Prometheus][12]。而 [StatsD][13] 是 _推送_ 模型的一个例子。 -### 集成 StatsD +#### 集成 StatsD 将 StatsD 集成到一个 Python 应用程序中,我们将使用 [StatsD Python 客户端][14],然后更新我们的指标报告部分的代码,调用合适的库去推送数据到 StatsD 中。 @@ -308,13 +296,13 @@ statsd.timing(key, resp_time) statsd.incr(key) ``` -将指标关联到元数据上,一个键的定义为:metadata1.metadata2.metric,其中每个 metadataX 是一个可以进行聚合和分组的字段。 +将指标关联到元数据上,一个键的定义为:`metadata1.metadata2.metric`,其中每个 metadataX 是一个可以进行聚合和分组的字段。 这个演示应用程序 [StatsD][15] 是将 statsd 与 Python Flask 应用程序集成的一个完整示例。 -### 集成 Prometheus +#### 集成 Prometheus -去使用 Prometheus 监视系统,我们使用 [Promethius Python 客户端][16]。我们将首先去创建有关的指标类对象: +要使用 Prometheus 监测系统,我们使用 [Promethius Python 客户端][16]。我们将首先去创建有关的指标类对象: ``` REQUEST_LATENCY = Histogram('request_latency_seconds', 'Request latency', @@ -340,76 +328,76 @@ def metrics(): 这个演示应用程序 [Prometheus][17] 是将 prometheus 与 Python Flask 应用程序集成的一个完整示例。 -### 哪个更好:StatsD 还是 Prometheus? +#### 哪个更好:StatsD 还是 Prometheus? 本能地想到的下一个问题便是:我应该使用 StatsD 还是 Prometheus?关于这个主题我写了几篇文章,你可能发现它们对你很有帮助: -* [Your options for monitoring multi-process Python applications with Prometheus][18] -* [Monitoring your synchronous Python web applications using Prometheus][19] -* [Monitoring your asynchronous Python web applications using Prometheus][20] +* [使用 Prometheus 监测多进程 Python 应用的方式][18] +* [使用 Prometheus 监测你的同步 Python 应用][19] +* [使用 Prometheus 监测你的异步 Python 应用][20] -## 指标的使用方式 +### 指标的使用方式 -我们已经学习了一些关于为什么要在我们的应用程序上配置监视的原因,而现在我们来更深入地研究其中的两个用法:报警和自动扩展。 +我们已经学习了一些关于为什么要在我们的应用程序上配置监测的原因,而现在我们来更深入地研究其中的两个用法:报警和自动扩展。 -### 使用指标进行报警 +#### 使用指标进行报警 -指标的一个关键用途是创建警报。例如,假如过去的五分钟,你的 HTTP 500 的数量持续增加,你可能希望给相关的人发送一封电子邮件或页面提示。对于配置警报做什么取决于我们的监视设置。对于 Prometheus 我们可以使用 [Alertmanager][21],而对于 StatsD,我们使用 [Nagios][22]。 +指标的一个关键用途是创建警报。例如,假如过去的五分钟,你的 HTTP 500 的数量持续增加,你可能希望给相关的人发送一封电子邮件或页面提示。对于配置警报做什么取决于我们的监测设置。对于 Prometheus 我们可以使用 [Alertmanager][21],而对于 StatsD,我们使用 [Nagios][22]。 -### 使用指标进行自动扩展 +#### 使用指标进行自动扩展 在一个云基础设施中,如果我们当前的基础设施供应过量或供应不足,通过指标不仅可以让我们知道,还可以帮我们实现一个自动伸缩的策略。例如,如果在过去的五分钟里,在我们服务器上的工作进程使用率达到 90%,我们可以水平扩展。我们如何去扩展取决于云基础设施。AWS 的自动扩展,缺省情况下,扩展策略是基于系统的 CPU 使用率、网络流量、以及其它因素。然而,让基础设施伸缩的应用程序指标,我们必须发布 [自定义的 CloudWatch 指标][23]。 -## 在多服务架构中的应用程序监视 +### 在多服务架构中的应用程序监测 -当我们超越一个单应用程序架构时,比如当客户端的请求在响应被发回之前,能够触发调用多个服务,就需要从我们的指标中获取更多的信息。我们需要一个统一的延迟视图指标,这样我们就能够知道响应这个请求时每个服务花费了多少时间。这可以用 [distributed tracing][24] 来实现。 +当我们超越一个单应用程序架构时,比如当客户端的请求在响应被发回之前,能够触发调用多个服务,就需要从我们的指标中获取更多的信息。我们需要一个统一的延迟视图指标,这样我们就能够知道响应这个请求时每个服务花费了多少时间。这可以用 [分布式跟踪][24] 来实现。 -你可以在我的博客文章 [在你的 Python 应用程序中通过 Zipkin 引入分布式跟踪][25] 中看到在 Python 中进行分布式跟踪的示例。 +你可以在我的博客文章 《[在你的 Python 应用程序中通过 Zipkin 引入分布式跟踪][25]》 中看到在 Python 中进行分布式跟踪的示例。 -## 划重点 +### 划重点 总之,你需要记住以下几点: -* 理解你的监视系统中指标类型的含义 -* 知道监视系统需要的你的数据的测量单位 -* 监视你的应用程序中的大多数关键组件 -* 监视你的应用程序在它的大多数关键阶段的行为 +* 理解你的监测系统中指标类型的含义 +* 知道监测系统需要的你的数据的测量单位 +* 监测你的应用程序中的大多数关键组件 +* 监测你的应用程序在它的大多数关键阶段的行为 -以上要点是假设你不去管理你的监视系统。如果管理你的监视系统是你的工作的一部分,那么你还要考虑更多的问题! +以上要点是假设你不去管理你的监测系统。如果管理你的监测系统是你的工作的一部分,那么你还要考虑更多的问题! -## 其它资源 +### 其它资源 -以下是我在我的监视学习过程中找到的一些非常有用的资源: +以下是我在我的监测学习过程中找到的一些非常有用的资源: -### 综合的 +#### 综合的 -* [监视分布式系统][26] -* [观测和监视最佳实践][27] +* [监测分布式系统][26] +* [观测和监测最佳实践][27] * [谁想使用秒?][28] -### StatsD/Graphite +#### StatsD/Graphite * [StatsD 指标类型][29] -### Prometheus +#### Prometheus * [Prometheus 指标类型][30] -* [How does a Prometheus gauge work?][31] -* [Why are Prometheus histograms cumulative?][32] -* [在 Python 中监视批作业][33] -* [Prometheus:监视 SoundCloud][34] +* [Prometheus 计量器如何工作?][31] +* [为什么用 Prometheus 累积柱形图?][32] +* [在 Python 中监测批量作业][33] +* [Prometheus:监测 SoundCloud][34] -## 避免犯错(即第 3 阶段的学习) +### 避免犯错(即第 3 阶段的学习) -在我们学习监视的基本知识时,时刻注意不要犯错误是很重要的。以下是我偶然发现的一些很有见解的资源: +在我们学习监测的基本知识时,时刻注意不要犯错误是很重要的。以下是我偶然发现的一些很有见解的资源: -* [How not to measure latency][35] -* [Histograms with Prometheus: A tale of woe][36] -* [Why averages suck and percentiles are great][37] -* [Everything you know about latency is wrong][38] -* [Who moved my 99th percentile latency?][39] -* [Logs and metrics and graphs][40] -* [HdrHistogram: A better latency capture method][41] +* [如何不测量延迟][35] +* [Prometheus 柱形图:悲伤的故事][36] +* [为什么平均值很讨厌,而百分位很棒][37] +* [对延迟的认知错误][38] +* [谁动了我的 99% 延迟?][39] +* [日志、指标和图形][40] +* [HdrHistogram:一个更好的延迟捕获方式][41] --- @@ -419,7 +407,7 @@ def metrics(): [![](https://opensource.com/sites/default/files/styles/profile_pictures/public/osdc_default_avatar_1.png?itok=mmbfqFXm)][44] -Amit Saha — 我是一名对基础设施、监视、和工具感兴趣的软件工程师。我是“用 Python 做数学”的作者和创始人,以及 Fedora Scientific Spin 维护者。 +Amit Saha — 我是一名对基础设施、监测、和工具感兴趣的软件工程师。我是“用 Python 做数学”的作者和创始人,以及 Fedora Scientific Spin 维护者。 [关于我的更多信息][45] @@ -429,7 +417,7 @@ Amit Saha — 我是一名对基础设施、监视、和工具感兴趣的软件 via: [https://opensource.com/article/18/4/metrics-monitoring-and-python][47] -作者: [Amit Saha][48] 选题者: [@lujun9972][49] 译者: [qhwdw][50] 校对: [校对者ID][51] +作者: [Amit Saha][48] 选题者: [lujun9972][49] 译者: [qhwdw][50] 校对: [wxy][51] 本文由 [LCTT][52] 原创编译,[Linux中国][53] 荣誉推出 @@ -483,6 +471,6 @@ via: [https://opensource.com/article/18/4/metrics-monitoring-and-python][47] [48]: https://opensource.com/users/amitsaha [49]: https://github.com/lujun9972 [50]: https://github.com/qhwdw -[51]: https://github.com/校对者ID +[51]: https://github.com/wxy [52]: https://github.com/LCTT/TranslateProject [53]: https://linux.cn/ From 7ee01908db7bdb9537a89dff1ba37cb858f71e8c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 14 Sep 2018 09:55:14 +0800 Subject: [PATCH 216/455] PUB:20180425 Understanding metrics and monitoring with Python - Opensource.com.md @qhwdw https://linux.cn/article-10011-1.html --- ...tanding metrics and monitoring with Python - Opensource.com.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180425 Understanding metrics and monitoring with Python - Opensource.com.md (100%) diff --git a/translated/tech/20180425 Understanding metrics and monitoring with Python - Opensource.com.md b/published/20180425 Understanding metrics and monitoring with Python - Opensource.com.md similarity index 100% rename from translated/tech/20180425 Understanding metrics and monitoring with Python - Opensource.com.md rename to published/20180425 Understanding metrics and monitoring with Python - Opensource.com.md From 484ed70516c40739a9aeded57f6ca5506e9901a1 Mon Sep 17 00:00:00 2001 From: HankChow <280630620@qq.com> Date: Fri, 14 Sep 2018 10:03:23 +0800 Subject: [PATCH 217/455] HankChow translating --- .../20180910 Randomize your MAC address using NetworkManager.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180910 Randomize your MAC address using NetworkManager.md b/sources/tech/20180910 Randomize your MAC address using NetworkManager.md index 7595843d1b..e55776b257 100644 --- a/sources/tech/20180910 Randomize your MAC address using NetworkManager.md +++ b/sources/tech/20180910 Randomize your MAC address using NetworkManager.md @@ -1,3 +1,5 @@ +HankChow translating + Randomize your MAC address using NetworkManager ====== From 3eee480d34f93b1e80b2a7f6f2a57757a30c270d Mon Sep 17 00:00:00 2001 From: HankChow <280630620@qq.com> Date: Fri, 14 Sep 2018 11:56:13 +0800 Subject: [PATCH 218/455] translated --- ...e your MAC address using NetworkManager.md | 111 ------------------ ...e your MAC address using NetworkManager.md | 108 +++++++++++++++++ 2 files changed, 108 insertions(+), 111 deletions(-) delete mode 100644 sources/tech/20180910 Randomize your MAC address using NetworkManager.md create mode 100644 translated/tech/20180910 Randomize your MAC address using NetworkManager.md diff --git a/sources/tech/20180910 Randomize your MAC address using NetworkManager.md b/sources/tech/20180910 Randomize your MAC address using NetworkManager.md deleted file mode 100644 index e55776b257..0000000000 --- a/sources/tech/20180910 Randomize your MAC address using NetworkManager.md +++ /dev/null @@ -1,111 +0,0 @@ -HankChow translating - -Randomize your MAC address using NetworkManager -====== - -![](https://fedoramagazine.org/wp-content/uploads/2018/09/randomizemacaddress-816x345.png) - -Today, users run their notebooks everywhere. To stay connected you use the local wifi to access the internet, on the couch at home or in a little cafe with your favorite coffee. But modern hotspots track you based on your MAC address, [an address that is unique per network card][1], and in this way identifies your device. Read more below about how to avoid this kind of tracking. - -Why is this a problem? Many people use the word “privacy” to talk about this issue. But the concern is not about someone accessing the private contents of your laptop (that’s a separate issue). Instead, it’s about legibility — in simple terms, the ability to be easily counted and tracked. You can and should [read more about legibility][2]. But the bottom line is legibility gives the tracker power over the tracked. For instance, timed WiFi leases at the airport can only be enforced when you’re legible. - -Since a fixed MAC address for your laptop is so legible (easily tracked), you should change it often. A random address is a good choice. Since MAC-addresses are only used within a local network, a random MAC-address is unlikely to cause a [collision.][3] - -### Configuring NetworkManager - -To apply randomized MAC-addresses by default to all WiFi connections, create the following file /etc/NetworkManager/conf.d/00-macrandomize.conf : - -``` -[device] -wifi.scan-rand-mac-address=yes - -[connection] -wifi.cloned-mac-address=stable -ethernet.cloned-mac-address=stable -connection.stable-id=${CONNECTION}/${BOOT} - -``` - -Afterward, restart NetworkManager: - -``` -systemctl restart NetworkManager - -``` - -Set cloned-mac-address to stable to generate the same hashed MAC every time a NetworkManager connection activates, but use a different MAC with each connection. To get a truly random MAC with every activation, use random instead. - -The stable setting is useful to get the same IP address from DHCP, or a captive portal might remember your login status based on the MAC address. With random you may be required to re-authenticate (or click “I agree”) on every connect. You probably want “random” for that airport WiFi. See the NetworkManager [blog post][4] for a more detailed discussion and instructions for using nmcli to configure specific connections from the terminal. - -To see your current MAC addresses, use ip link. The MAC follows the word ether. - -``` -$ ip link -1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 - link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 -2: enp2s0: mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 - link/ether 52:54:00:5f:d5:4e brd ff:ff:ff:ff:ff:ff -3: wlp1s0: mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000 - link/ether 52:54:00:03:23:59 brd ff:ff:ff:ff:ff:ff - -``` - -### When not to randomize your MAC address - -Naturally, there are times when you do need to be legible. For instance, on your home network, you may have configured your router to assign your notebook a consistent private IP for port forwarding. Or you might allow only certain MAC addresses to use the WiFi. Your employer probably requires legibility as well. -To change a specific WiFi connection, use nmcli to see your NetworkManager connections and show the current settings: - -``` -$ nmcli c | grep wifi -Amtrak_WiFi 5f4b9f75-9e41-47f8-8bac-25dae779cd87 wifi -- -StaplesHotspot de57940c-32c2-468b-8f96-0a3b9a9b0a5e wifi -- -MyHome e8c79829-1848-4563-8e44-466e14a3223d wifi wlp1s0 -... -$ nmcli c show 5f4b9f75-9e41-47f8-8bac-25dae779cd87 | grep cloned -802-11-wireless.cloned-mac-address: -- -$ nmcli c show e8c79829-1848-4563-8e44-466e14a3223d | grep cloned -802-11-wireless.cloned-mac-address: stable - -``` - -This example uses a fully random MAC for Amtrak (which is currently using the default), and the permanent MAC for MyHome (currently set to stable). The permanent MAC was assigned to your network interface when it was manufactured. Network admins like to use the permanent MAC to see [manufacturer IDs on the wire][5]. - -Now, make the changes and reconnect the active interface: - -``` -$ nmcli c modify 5f4b9f75-9e41-47f8-8bac-25dae779cd87 802-11-wireless.cloned-mac-address random -$ nmcli c modify e8c79829-1848-4563-8e44-466e14a3223d 802-11-wireless.cloned-mac-address permanent -$ nmcli c down e8c79829-1848-4563-8e44-466e14a3223d -$ nmcli c up e8c79829-1848-4563-8e44-466e14a3223d -$ ip link -... - -``` - -You can also install NetworkManager-tui to get the nmtui command for nice menus when editing connections. - -### Conclusion - -When you walk down the street, you should [stay aware of your surroundings][6], and on the [alert for danger][7]. In the same way, learn to be aware of your legibility when using public internet resources. - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/randomize-mac-address-nm/ - -作者:[sheogorath][a],[Stuart D Gathman][b] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/sheogorath/ -[b]: https://fedoramagazine.org/author/sdgathman/ -[1]: https://en.wikipedia.org/wiki/MAC_address -[2]: https://www.ribbonfarm.com/2010/07/26/a-big-little-idea-called-legibility/ -[3]: https://serverfault.com/questions/462178/duplicate-mac-address-on-the-same-lan-possible -[4]: https://blogs.gnome.org/thaller/2016/08/26/mac-address-spoofing-in-networkmanager-1-4-0/ -[5]: https://www.wireshark.org/tools/oui-lookup.html -[6]: https://www.isba.org/committees/governmentlawyers/newsletter/2013/06/becomingmoreawareafewtipsonkeepingy -[7]: http://www.selectinternational.com/safety-blog/aware-of-surroundings-can-reduce-safety-incidents diff --git a/translated/tech/20180910 Randomize your MAC address using NetworkManager.md b/translated/tech/20180910 Randomize your MAC address using NetworkManager.md new file mode 100644 index 0000000000..1b9eeece65 --- /dev/null +++ b/translated/tech/20180910 Randomize your MAC address using NetworkManager.md @@ -0,0 +1,108 @@ +使用 NetworkManager 随机化你的 MAC 地址 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/09/randomizemacaddress-816x345.png) + +今时今日,无论在家里的沙发上,还是在外面的咖啡厅,只要打开笔记本电脑,连上 Wi-Fi,就能通过网络与外界保持联系。但现在的 Wi-Fi 热点们大都能够通过[每张网卡对应的唯一 MAC 地址][1]来追踪你的设备。下面就来看一下如何避免被追踪。 + +现在很多人已经开始注重个人隐私这个问题。个人隐私问题并不仅仅指防止他人能够访问到你电脑上的私有内容(这又是另一个问题了),而更多的是指可追踪性,也就是是否能够被轻易地统计和追踪到。大家都应该[对此更加重视][2]。同时,这方面的底线是,服务提供者在得到了用户的授权后才能对用户进行追踪,例如机场的计时 Wi-Fi 只有在用户授权后才能够使用。 + +因为固定的 MAC 地址能被轻易地追踪到,所以应该定时进行更换,随机的 MAC 地址是一个好的选择。由于 MAC 地址一般只在局域网内使用,因此随机的 MAC 地址也不太容易产生[冲突][3]。 + +### 配置 NetworkManager + +要将随机的 MAC 地址默认应用与所有的 Wi-Fi 连接,需要创建 /etc/NetworkManager/conf.d/00-macrandomize.conf 这个文件: + +``` +[device] +wifi.scan-rand-mac-address=yes + +[connection] +wifi.cloned-mac-address=stable +ethernet.cloned-mac-address=stable +connection.stable-id=${CONNECTION}/${BOOT} + +``` + +然后重启 NetworkManager : + +``` +systemctl restart NetworkManager + +``` + +以上配置文件中,将 cloned-mac-address 的值设置为 stable 就可以在每次 NetworkManager 激活连接的时候都生成相同的 MAC 地址,但连接时使用不同的 MAC 地址。如果要在每次激活连接时获得随机的 MAC 地址,需要将 cloned-mac-address 的值设置为 random。 + +设置为 stable 可以从 DHCP 获取相同的 IP 地址,也可以让 Wi-Fi 的强制主页根据 MAC 地址记住你的登录状态。如果设置为 random ,在每次连接的时候都需要重新认证(或者点击“我同意”),在使用机场 Wi-Fi 的时候会需要到这种 random 模式。可以在 NetworkManager 的[博客文章][4]中参阅到有关使用 nmcli 从终端配置特定连接的详细说明。 + +使用 ip link 命令可以查看当前的 MAC 地址,MAC 地址将会显示在 ether 一词的后面。 + +``` +$ ip link +1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 +2: enp2s0: mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 + link/ether 52:54:00:5f:d5:4e brd ff:ff:ff:ff:ff:ff +3: wlp1s0: mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000 + link/ether 52:54:00:03:23:59 brd ff:ff:ff:ff:ff:ff + +``` + +### 什么时候不能随机化 MAC 地址 + +当然,在某些情况下确实需要能被追踪到。例如在家用网络中,可能需要将路由器配置为对电脑分配一致的 IP 地址以进行端口转发;再例如公司的雇主可能需要根据 MAC 地址来提供 Wi-Fi 服务,这时候就需要进行追踪。要更改特定的 Wi-Fi 连接,请使用 nmcli 查看 NetworkManager 连接并显示当前设置: + +``` +$ nmcli c | grep wifi +Amtrak_WiFi 5f4b9f75-9e41-47f8-8bac-25dae779cd87 wifi -- +StaplesHotspot de57940c-32c2-468b-8f96-0a3b9a9b0a5e wifi -- +MyHome e8c79829-1848-4563-8e44-466e14a3223d wifi wlp1s0 +... +$ nmcli c show 5f4b9f75-9e41-47f8-8bac-25dae779cd87 | grep cloned +802-11-wireless.cloned-mac-address: -- +$ nmcli c show e8c79829-1848-4563-8e44-466e14a3223d | grep cloned +802-11-wireless.cloned-mac-address: stable + +``` + +以下这个例子使用 Amtrak 的完全随机 MAC 地址(使用默认配置)和 MyHome 的永久 MAC 地址(使用 stable 配置)。永久 MAC 地址是在硬件生产的时候分配到网络接口上的,网络管理员能够根据永久 MAC 地址来查看[设备的制造商 ID][5]。 + +更改配置并重新连接活动的接口: + +``` +$ nmcli c modify 5f4b9f75-9e41-47f8-8bac-25dae779cd87 802-11-wireless.cloned-mac-address random +$ nmcli c modify e8c79829-1848-4563-8e44-466e14a3223d 802-11-wireless.cloned-mac-address permanent +$ nmcli c down e8c79829-1848-4563-8e44-466e14a3223d +$ nmcli c up e8c79829-1848-4563-8e44-466e14a3223d +$ ip link +... + +``` + +你还可以安装 NetworkManager-tui ,就可以通过可视化界面菜单来编辑连接。 + +### 总结 + +当你走在路上时,你要[留意周围的环境][6],并[警惕可能的危险][7]。同样,在使用公共互联网资源时也要注意你自己的可追踪性。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/randomize-mac-address-nm/ + +作者:[sheogorath][a],[Stuart D Gathman][b] +选题:[lujun9972](https://github.com/lujun9972) +译者:[HankChow](https://github.com/HankChow) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/sheogorath/ +[b]: https://fedoramagazine.org/author/sdgathman/ +[1]: https://en.wikipedia.org/wiki/MAC_address +[2]: https://www.ribbonfarm.com/2010/07/26/a-big-little-idea-called-legibility/ +[3]: https://serverfault.com/questions/462178/duplicate-mac-address-on-the-same-lan-possible +[4]: https://blogs.gnome.org/thaller/2016/08/26/mac-address-spoofing-in-networkmanager-1-4-0/ +[5]: https://www.wireshark.org/tools/oui-lookup.html +[6]: https://www.isba.org/committees/governmentlawyers/newsletter/2013/06/becomingmoreawareafewtipsonkeepingy +[7]: http://www.selectinternational.com/safety-blog/aware-of-surroundings-can-reduce-safety-incidents + From 4c95467144cb44708e9077784d6967abe7be586b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 14 Sep 2018 12:35:04 +0800 Subject: [PATCH 219/455] PRF:20180102 Top 7 open source project management tools for agile teams.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @heguangzhi 恭喜你完成了第一篇翻译! --- ...roject management tools for agile teams.md | 84 +++++++------------ 1 file changed, 29 insertions(+), 55 deletions(-) diff --git a/translated/tech/20180102 Top 7 open source project management tools for agile teams.md b/translated/tech/20180102 Top 7 open source project management tools for agile teams.md index 02c9259ba5..144b5fc3d4 100644 --- a/translated/tech/20180102 Top 7 open source project management tools for agile teams.md +++ b/translated/tech/20180102 Top 7 open source project management tools for agile teams.md @@ -1,46 +1,35 @@ -heguangzhi Translating - - - -面向敏捷开发团队的7个开源项目管理工具 +面向敏捷开发团队的 7 个开源项目管理工具 ====== +> 在这篇开源项目管理工具的综述中,让我们来了解一下支持 Scrum、看板Kanban 等敏捷开发模式的软件。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_orgchart1.png?itok=tukiFj89) +Opensource.com 以前对流行的开源项目管理工具做过相应的调研。但是今年我们增加了一个特点。本次,我们特别关注支持[敏捷][1]方法的工具,包括相关的实践,如 [Scrum][2]、Lean 和 看板Kanban。 -Opensource.com 以前对流行的开源项目管理工具的过相应的调研。但是今年我们增加了一个特点。本次,我们特别关注支持[敏捷][1]方法的工具,包括相关的实践,如[Scrum][2]、 Lean, and Kanban。 +对敏捷开发的兴趣和使用的增长是我们今年决定专注于这些工具的原因。大多数组织(71%)的人说他们至少[使用了敏捷方式][3]。此外,敏捷项目比传统方法管理的项目 [要高出 28% 的成功率][4] 。 - -对敏捷开发的兴趣和使用的增长是我们今年决定专注于这些工具的原因。大多数组织-71%的人说他们至少使用了敏捷方法(3)[are using agile approaches][3]。此外,敏捷项目比传统方法管理的项目要高出28%(4)[28% more successful][4] 。 - - -我们查看了[2014][5]、[2015][6]和[2016][7]中涉及的项目管理工具,并挑选了支持敏捷的工具,然后进行了研究并做了添加或更改。不管您的组织是否已经在使用敏捷开发,或者是2018年采用敏捷方法的作为众多计划之一,这七个开源项目管理工具之一可能正是您所要找寻的。 +我们查看了 [2014][5]、[2015][6] 和 [2016][7] 中涉及的项目管理工具,并挑选了支持敏捷的工具,然后对没有涉及的或变化了的进行了研究。不管您的组织是否已经在使用敏捷开发,或者在 2018 年的众多计划之一是采用敏捷方法,这七个开源项目管理工具之一可能正是您所要找寻的。 ### MyCollab ![](https://opensource.com/sites/default/files/u128651/mycollab_kanban-board.png) -MyCollab][8]是一套针对中小型企业的三个协作模块:项目管理、客户关系管理(CRM)和文档创建和编辑的软件。有两个许可选项:一个商业的“终极”版本,它更快,可以在内部或云中运行;另一个开源的“社区版本”,这个正是我们感兴趣的版本。 +[MyCollab][8] 是一套针对中小型企业的三个协作模块套件:项目管理、客户关系管理(CRM)和文档创建和编辑软件。有两个许可证选项:一个商业的“终极”版本,它更快,可以在内部或云中运行;另一个开源的“社区版本”,这个正是我们感兴趣的版本。 -由于没有使用查询缓存,社区版本没有云选项,并且速度较慢,但是提供了基本的项目管理特性,包括任务、问题管理、活动流、路线图视图和敏捷团队看板。虽然它没有单独的移动应用程序,但它也适用于移动设备,包括 Windows、Mac OS、Linux 和 UNIX 计算机。 +由于没有使用查询缓存,社区版本没有云方式,并且速度较慢,但是提供了基本的项目管理特性,包括任务、问题管理、活动流、路线图视图和敏捷团队看板。虽然它没有单独的移动应用程序,但它也适用于移动设备,包括 Windows、Mac OS、Linux 和 UNIX 计算机。 -The latest version of MyCollab is 5.4.10 and the source code is available on [GitHub][9]. It is licensed under AGPLv3 and requires a Java runtime and MySQL stack to operate. It's available for [download][10] for Windows, Linux, Unix, and MacOS. - - - - -MyCulb的最新版本是5.4.10,源代码可在 [GitHub][9] 上下载。它是在 AgPLv3 下进行授权的,需要 Java 运行和 MySQL支持。它可运行于 Windows、Linux、UNIX 和 MacOS 。下载地址 [download][10]。 +MyCollab 的最新版本是 5.4.10,源代码可在 [GitHub][9] 上下载。它是在 AGPLv3 下进行授权的,需要 Java 运行时环境和 MySQL 支持。它可运行于 Windows、Linux、UNIX 和 MacOS。[下载地址][10]。 ### Odoo ![](https://opensource.com/sites/default/files/u128651/odoo_projects_screenshots_01a.gif) -[Odoo][11] 不仅仅是项目管理软件;它是一个完整的集成商业应用套件,包括会计、人力资源、网站和电子商务、库存、制造、销售管理(CRM)和其他工具。 +[Odoo][11] 不仅仅是项目管理软件;它是一个完整的集成商业应用套件,包括会计、人力资源、网站和电子商务、库存、制造、销售管理(CRM)和其它工具。 -与付费企业套件相比,免费开源社区版具有有限的[特性][12] 。它的项目管理应用程序包括敏捷团队的看板式任务跟踪视图,在最新版本Odoo 11.0中更新了该视图,以包括用于跟踪项目状态的进度条和动画。项目管理工具还包括甘特图、任务、问题、图表等等。Odoo有一个繁荣的[社区][13],并提供 [用户指南][14] 及其他培训资源。 +与付费企业套件相比,免费的开源社区版具有有限的 [特性][12] 。它的项目管理应用程序包括敏捷团队的看板式任务跟踪视图,在最新版本 Odoo 11.0 中更新了该视图,以包括用于跟踪项目状态的进度条和动画。项目管理工具还包括甘特图、任务、问题、图表等等。Odoo 有一个繁荣的[社区][13],并提供 [用户指南][14] 及其他培训资源。 它是在 GPLv3 下授权的,需要 Python 和 PostgreSQL 支持。作为[Docker][16] 镜像 可以运行在 Windows、Linux 和 Red Hat 包管理器中,下载地址[download][15],源代码[GitHub][17]。 @@ -49,73 +38,58 @@ MyCulb的最新版本是5.4.10,源代码可在 [GitHub][9] 上下载。它是 ![](https://opensource.com/sites/default/files/u128651/openproject-screenshot-agile-scrum.png) - [OpenProject][18] 是一个强大的开源项目管理工具,以其易用性和丰富的项目管理和团队协作特性而著称。 +它的模块支持项目计划、调度、路线图和发布计划、时间跟踪、成本报告、预算、bug 跟踪以及敏捷和 Scrum。它的敏捷特性,包括创建 Story、确定 sprint 的优先级以及跟踪任务,都与 OpenProject 的其他模块集成在一起。 -它的模块支持项目计划、调度、路线图和发布计划、时间跟踪、成本报告、预算、bug跟踪以及敏捷和Scrum。它的敏捷特性,包括创建Story、确定sprint的优先级以及跟踪任务,都与OpenProject的其他模块集成在一起。 - - -OpenProject 在 GPLv3 下获得许可,其源代码可在[GitHub][19]上。最新版本7.3.2 for Linux [download][20];您可以在 Birthe Lindenthal 的文章 “[Getting start of OpenProject][21]"中了解更多关于安装和配置它的信息。 +OpenProject 在 GPLv3 下获得许可,其源代码可在[GitHub][19]上。最新版本 7.3.2 的 Linux 版本 [在此下载][20];您可以在 Birthe Lindenthal 的文章 “[OpenProject 入门][21]”中了解更多关于安装和配置它的信息。 ### OrangeScrum ![](https://opensource.com/sites/default/files/u128651/orangescrum_kanban.png) +正如从其名称中猜到的,[OrangeScrum][22] 支持敏捷方法,特别是使用 Scrum 任务板和看板式工作流视图。它面向较小的组织自由职业者、中介机构和中小型企业。 -正如从其名称中猜到的,[OrangeScrum][22]支持敏捷方法,特别是使用Scrum任务板和看板式工作流视图。它面向较小的组织自由职业者、中介机构和中小型企业。 +开源版本提供了 OrangeScrum 付费版本中的许多 [特性][23],包括移动应用程序、资源利用率和进度跟踪。其他特性,包括甘特图、时间日志、发票和客户端管理,可以作为付费附加组件提供,付费版本包括云选项,而社区版本不提供。 -源版本提供了 OrangeScrum 付费版本中的许多[特性][23],包括移动应用程序、资源利用率和进度跟踪。其他特性,包括甘特图、时间日志、发票和客户端管理,可以作为付费附加组件提供,付费版本包括云选项,而社区版本不提供。 - -OrangeScrum 是基于 GPLv3 授权的,是基于 CakePHP 框架开发。它需要 Apache、PHP 5.3 或更高版本和 MySQL 4.1 或更高版本支持,并可以在 Windows、Linux 和 Mac OS 上运行。其最新版本1.1.1,下载地址 [download][24],其源码[GitHub] [25]。 +OrangeScrum 是基于 GPLv3 授权的,是基于 CakePHP 框架开发。它需要 Apache、PHP 5.3 或更高版本和 MySQL 4.1 或更高版本支持,并可以在 Windows、Linux 和 Mac OS 上运行。其最新版本 1.1.1 [在此下载][24],其源码在 [GitHub] [25]。 ### ]project-open[ ![](https://opensource.com/sites/default/files/u128651/projectopen_dashboard.png) +[\]project-open\[][26] 是一个双许可证的企业项目管理工具,这意味着其核心是开源的,并且在商业许可的模块中可以使用一些附加特性。根据该项目的社区和企业版本的 [比较][27],开源核心为中小型组织提供了许多特性。 -[]project-open[][26]是一个双许可的企业项目管理工具,这意味着其核心是开源的,并且在商业许可的模块中可以使用一些附加特性。根据社区和企业版本的项目[比较][27],开源核心为中小型组织提供了许多特性。 +]project-open[ 支持带有 Scrum 和看板功能的 [敏捷][28] 项目,以及经典的甘特/瀑布项目和混合或混合项目。 -]project-open[ 支持Scrum和看板[敏捷][28]项目,以及经典的甘特/瀑布项目和混合或混合项目。 - - -该应用程序是在 GPL 下授权的,并且[source code][29]是通过 CVS 访问的。 ]project-open[ 在 Linux 和 Windows 的安装可用 [installers][26],但也可以在云镜像和虚拟设备中使用。 +该应用程序是在 GPL 下授权的,并且 [源代码][29]是通过 CVS 访问的。 ]project-open[ 在 Linux 和 Windows 的安装有 [安装程序][26],但也可以在云镜像和虚拟设备中使用。 ### Taiga ![](https://opensource.com/sites/default/files/u128651/taiga_screenshot.jpg) +[Taiga][30] 是一个开源项目管理平台,它专注于 Scrum 和敏捷开发,其特征包括看板、任务、sprints、问题、backlog 和 epics。其他功能包括凭证管理、多项目支持、Wiki 页面和第三方集成。 -[Taiga][30] 是一个开源项目管理平台,它专注于Scrum和敏捷开发,其特征包括看板、任务、sprints、问题、backlog 和epics。其他功能包括 ticke 管理、多项目支持、Wiki页面和第三方集成。 +它还为 iOS、Android 和 Windows 设备提供免费的移动应用程序,并提供导入工具,使从其他流行的项目管理应用程序迁移变得容易。 -它还为iOS、Android和Windows设备提供免费的移动应用程序,并提供导入工具,使从其他流行的项目管理应用程序迁移变得容易。 +Taiga 对于公共项目是免费的,对项目数量或用户数量没有限制。对于私有项目,在“免费增值”模式下,有很多 [付费计划][31] 可用,但是值得注意的是,无论您属于哪种类型,软件的功能特性都是一样的。 - -Taiga 对于公共项目是免费的,对项目数量或用户数量没有限制。对于私有项目,在“免费增值”模式下,有很多[付费计划][31]可用,但是值得注意的是,无论您有哪种类型,软件的功能特性都是一样的。 - - -Taiga 是在GNU Affero GPLv3 下授权的,并且软件需要 Nginx、Python 和 PostgreSQL 支持。最新版本[3.1.0 PrimovsialpopiculoLII][32],可在[GitHub][33]上下载。 +Taiga 是在 GNU Affero GPLv3 下授权的,并且软件需要 Nginx、Python 和 PostgreSQL 支持。最新版本[3.1.0 Perovskia atriplicifolia][32],可在 [GitHub][33] 上下载。 ### Tuleap ![](https://opensource.com/sites/default/files/u128651/tuleap-scrum-prioritized-backlog.png) +[Tuleap][34] 是一个应用程序生命周期管理(ALM)平台,旨在为每种类型的团队管理项目——小型、中型、大型、瀑布、敏捷或混合型——但是它对敏捷团队的支持是显著的。值得注意的是,它为 Scrum、看板、sprints、任务、报告、持续集成、backlogs 等提供支持. +其他的 [特性][35] 包括问题跟踪、文档跟踪、协作工具,以及与 Git、SVN 和 Jenkins 的集成,所有这些都使它成为开放源码软件开发项目的吸引人的选择。 -[Tuleap][34]是一个应用程序生命周期管理(ALM)平台,旨在为每种类型的团队管理项目——小型、中型、大型、瀑布、敏捷或混合型——但是它对敏捷团队的支持是显著的。值得注意的是,它为Scrum、看板、sprints、任务、报告、持续集成、backlogs等提供支持. +Tuleap 是在 GPLv2 下授权的。更多信息,包括 Docker 和 CentOS 下载,可以在他们的 [入门][36] 页面上找到。您还可以在 Tuleap 的 [Git][37] 上获取其最新版本 9.14 的源代码。 +--- -其他的[特性][35]包括问题跟踪、文档跟踪、协作工具,以及与 Git、SVN 和 Jenkins 的集成,所有这些都使它成为开放源码软件开发项目的吸引人的选择。 - - -TuleAP 是在 GPLv2 下授权的。更多信息,包括 Docker 和 CentOS 下载,可以在他们的 [Get Started][36] 页面上找到。您还可以在TuleAP的 [Git][37] 上获取其最新版本9.14的源代码。 - - -这种类型的列表的麻烦在于它一发布就过时了。使用开源项目管理工具来支持我们忘记包含的敏捷吗?或者你对我们提到的有反馈吗?请在下面留下评论。 - -这种类型的文章的麻烦在于它一发布就过时了。那些您正在使用开源项目管理工具,而被我们遗漏了?或者您对我们提到的有反馈意见吗?请在下面留下留言。 - +这种类型的文章的麻烦在于它一发布就过时了。您正在使用哪些开源项目管理工具,而被我们遗漏了?或者您对我们提到的有反馈意见吗?请在下面留下留言。 -------------------------------------------------------------------------------- @@ -123,8 +97,8 @@ TuleAP 是在 GPLv2 下授权的。更多信息,包括 Docker 和 CentOS 下 via: https://opensource.com/article/18/2/agile-project-management-tools 作者:[Opensource.com][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 6e38c9be2ee8c18d74b0d0ddd6357aacba9a34dc Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 14 Sep 2018 12:36:25 +0800 Subject: [PATCH 220/455] PUB:20180102 Top 7 open source project management tools for agile teams.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @heguangzhi 本文首发地址: https://linux.cn/article-10012-1.html 您的 LCTT 专页地址: https://linux.cn/lctt/heguangzhi 请到 LCTT 平台注册并领取 LCCN https://lctt.linux.cn/ --- ... Top 7 open source project management tools for agile teams.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180102 Top 7 open source project management tools for agile teams.md (100%) diff --git a/translated/tech/20180102 Top 7 open source project management tools for agile teams.md b/published/20180102 Top 7 open source project management tools for agile teams.md similarity index 100% rename from translated/tech/20180102 Top 7 open source project management tools for agile teams.md rename to published/20180102 Top 7 open source project management tools for agile teams.md From f4392c9e94a2e19047d60e5aa1074235da0979c5 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 14 Sep 2018 12:50:11 +0800 Subject: [PATCH 221/455] PRF:20180822 What is a Makefile and how does it work.md --- published/20180822 What is a Makefile and how does it work.md | 1 + 1 file changed, 1 insertion(+) diff --git a/published/20180822 What is a Makefile and how does it work.md b/published/20180822 What is a Makefile and how does it work.md index 8a550c1572..152a511265 100644 --- a/published/20180822 What is a Makefile and how does it work.md +++ b/published/20180822 What is a Makefile and how does it work.md @@ -48,6 +48,7 @@ sub_target: sub_target.c 目标并不要求是一个文件,也可以只是步骤的名字,就如我们的例子中一样。我们称之为“伪目标”。 再回到上面的示例中,当 `make` 被执行时,整条指令 `echo "Hello World"` 都被显示出来,之后才是真正的执行结果。如果不希望指令本身被打印处理,需要在 `echo` 前添加 `@`。 + ``` say_hello:         @echo "Hello World" From 905b4cb9ce9837e8496e1a050f00ff63f3deb4e4 Mon Sep 17 00:00:00 2001 From: sd886393 Date: Fri, 14 Sep 2018 15:24:15 +0800 Subject: [PATCH 222/455] =?UTF-8?q?=E3=80=90=E7=BF=BB=E8=AF=91=E4=B8=AD?= =?UTF-8?q?=E3=80=91sd886393=20=E9=80=89=E5=8F=96sources=20tech=2020180929?= =?UTF-8?q?=20Getting=20started=20with=20the=20i3=20window=20manager=20on?= =?UTF-8?q?=20linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...180929 Getting started with the i3 window manager on Linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180929 Getting started with the i3 window manager on Linux.md b/sources/tech/20180929 Getting started with the i3 window manager on Linux.md index 0aa266b448..20ac244390 100644 --- a/sources/tech/20180929 Getting started with the i3 window manager on Linux.md +++ b/sources/tech/20180929 Getting started with the i3 window manager on Linux.md @@ -1,3 +1,4 @@ +[sd886393]翻译中 Getting started with the i3 window manager on Linux ====== From 9e14a31cb72e9cf2fbb8ed218f5151a83836a8a2 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 14 Sep 2018 16:34:23 +0800 Subject: [PATCH 223/455] PRF:20180911 Visualize Disk Usage On Your Linux System.md @XiatianSummer --- ...sualize Disk Usage On Your Linux System.md | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/translated/tech/20180911 Visualize Disk Usage On Your Linux System.md b/translated/tech/20180911 Visualize Disk Usage On Your Linux System.md index 4f18f8a786..4e92b49723 100644 --- a/translated/tech/20180911 Visualize Disk Usage On Your Linux System.md +++ b/translated/tech/20180911 Visualize Disk Usage On Your Linux System.md @@ -1,9 +1,9 @@ -可视化查看 Linux 系统上的磁盘使用情况 +Filelight:可视化查看 Linux 系统上的磁盘使用情况 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-720x340.png) -查看硬盘使用情况对于类 Unix 操作系统来说不是什么大问题。我们有一个名为 [**du**][1] 的内置命令,可以在分钟之内计算和汇总磁盘空间的使用情况。此外,我们还有一些第三方工具,比如 [**Ncdu**][2] and [**Agedu**][3],它们也可以用来追踪磁盘使用情况。如您所见,这些都是命令行中的实用程序,磁盘使用情况将以纯文本的形式显示。但是,有些人希望以可视化、图表的形式查看结果。别担心!我知道一个 GUI 工具可以显示磁盘使用细节。它就是“**Filelight**”,这是一个图形化实用程序,用于可视化显示 Linux 系统上的磁盘使用情况,并以彩色径向图显示结果。Filelight 是历史最悠久的项目之一,它已经存在了很长时间,它完全免费使用并开源。 +查看硬盘使用情况对于类 Unix 操作系统来说不是什么大问题。我们有一个名为 [du][1] 的内置命令,可以在几分钟之内计算和汇总磁盘空间的使用情况。此外,我们还有一些第三方工具,比如 [Ncdu][2] 和 [Agedu][3],它们也可以用来追踪磁盘使用情况。如您所见,这些都是命令行中的实用程序,磁盘使用情况将以纯文本的形式显示。但是,有些人希望以可视化、图表的形式查看结果。别担心!我知道一个 GUI 工具可以显示磁盘使用细节。它就是 “**Filelight**”,这是一个图形化实用程序,用于可视化显示 Linux 系统上的磁盘使用情况,并以彩色径向图显示结果。Filelight 是历史最悠久的项目之一,它已经存在了很长时间,它完全免费使用并开源。 ### 安装 Filelight @@ -11,7 +11,7 @@ Filelight 是 KDE 应用程序的一部分,并预装在基于 KDE 的 Linux 如果您使用的是非 KDE 发行版,官方存储库中包含了 Filelight,因此您可以使用默认的包管理器进行安装。 -在 Arch Linux 及其衍生版,如 Antergos,Manjaro Linux 中,Filelight 可以按照如下方法安装。 +在 Arch Linux 及其衍生版,如 Antergos、Manjaro Linux 中,Filelight 可以按照如下方法安装。 ``` $ sudo pacman -S filelight @@ -43,36 +43,34 @@ Filelight 以图形方式将您的文件系统表示为一组同心圆环段。 ![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-1-1.png) -如您所见,Filelight 默认显示磁盘中 **/** 和 **/boot** 文件系统的使用情况。 +如您所见,Filelight 默认显示磁盘中 `/` 和 `/boot` 文件系统的使用情况。 -您还可以选择扫描的各个文件夹,以查看该特定文件夹的磁盘使用情况。为此,请到 **Filelight - > Scan -> Scan Folder** 并选择要扫描的文件夹。 +您还可以选择扫描的各个文件夹,以查看该特定文件夹的磁盘使用情况。为此,请到 “Filelight -> Scan -> Scan Folder” 并选择要扫描的文件夹。 Filelight 在扫描时排除以下目录: - * /dev - * /proc - * /sys - * /root + * `/dev` + * `/proc` + * `/sys` + * `/root` +此选项有助于跳过您可能没有权限读取的目录,或者属于虚拟文件系统的文件夹,例如 `/proc`。 - -此选项有助于跳过您可能没有权限读取的目录,或者属于虚拟文件系统的文件夹,例如 **/proc**。 - -如果您想要在此列表中增加文件夹,请到 **Filelight - > Settings -> Scanning** 并点击“Add”按钮然后选择您想要增加的文件夹。 +如果您想要在此列表中增加文件夹,请到 “Filelight -> Settings -> Scanning” 并点击 “Add” 按钮然后选择您想要增加的文件夹。 ![](http://www.ostechnix.com/wp-content/uploads/2018/09/filelight-settings.png) -类似的,要想从此列表中移除某个文件夹,选择文件夹并点击“Remove”。 +类似的,要想从此列表中移除某个文件夹,选择文件夹并点击 “Remove”。 -如果您想要改变 Filelight 的外观,请到 **Settings - > Appearance** 栏,按照您的喜好改变配色方案。 +如果您想要改变 Filelight 的外观,请到 “Settings - > Appearance” 栏,按照您的喜好改变配色方案。 -径向图中的每个段用不同的颜色表示。下图显示了 **/** 文件系统的整个径向布局。要查看文件和文件夹的完整信息,只需将鼠标指针悬停在它们上边。 +径向图中的每个段用不同的颜色表示。下图显示了 `/` 文件系统的整个径向布局。要查看文件和文件夹的完整信息,只需将鼠标指针悬停在它们上边。 ![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-2.png) 只需点击相应的段即可浏览文件系统。要查看某个文件或文件夹的磁盘使用情况,只需单击它们即可获得该特定文件夹、文件的完整磁盘使用情况。 -不仅仅是本地文件系统,Filelight 还能够扫描远程磁盘和可移动磁盘。 如果您使用任何基于 KDE 的 Linux 发行版,它可以集成到 Konqueror,Dolphin 和 Krusader 等文件管理器中。 +不仅仅是本地文件系统,Filelight 还能够扫描远程磁盘和可移动磁盘。 如果您使用任何基于 KDE 的 Linux 发行版,它可以集成到 Konqueror、Dolphin 和 Krusader 等文件管理器中。 与 CLI 实用程序不同,您不必使用任何额外的参数或选项来以易读的(而非乱码的)格式查看结果。 默认情况下,Filelight 将自动以易读的格式显示磁盘使用情况。 @@ -91,7 +89,7 @@ via: https://www.ostechnix.com/filelight-visualize-disk-usage-on-your-linux-syst 作者:[SK][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[XiatianSummer](https://github.com/XiatianSummer) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 3bdfe2f31329aef87474565bdedb2c2f93dd9786 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 14 Sep 2018 16:34:49 +0800 Subject: [PATCH 224/455] PUB: XiatianSummer @XiatianSummer https://linux.cn/article-10013-1.html --- .../20180911 Visualize Disk Usage On Your Linux System.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180911 Visualize Disk Usage On Your Linux System.md (100%) diff --git a/translated/tech/20180911 Visualize Disk Usage On Your Linux System.md b/published/20180911 Visualize Disk Usage On Your Linux System.md similarity index 100% rename from translated/tech/20180911 Visualize Disk Usage On Your Linux System.md rename to published/20180911 Visualize Disk Usage On Your Linux System.md From 5b330c85ceeadeb9d13a469635ef69e9d35a24d4 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 14 Sep 2018 16:59:59 +0800 Subject: [PATCH 225/455] PRF:20180904 Why I love Xonsh.md @geekpi --- translated/tech/20180904 Why I love Xonsh.md | 28 ++++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/translated/tech/20180904 Why I love Xonsh.md b/translated/tech/20180904 Why I love Xonsh.md index f3506d6b6a..c852b24088 100644 --- a/translated/tech/20180904 Why I love Xonsh.md +++ b/translated/tech/20180904 Why I love Xonsh.md @@ -1,29 +1,34 @@ 我为什么喜欢 Xonsh ====== +> 有没有想过用 Python 做你的 shell? + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/shelloff.png?itok=L8pjHXjW) -Shell 语言对交互式使用很有用。但是在使用它们作为编程语言时这种优化需要权衡,这有时在编写 shell 脚本时会感觉到。 +Shell 语言对交互式使用很有用。但是在使用它们作为编程语言时这种优化就需要权衡,有时在编写 shell 脚本时会感觉到这点。 -如果你的 shell 时一种更可伸缩的语言会怎样?比如说,Python? +如果你的 shell 也能理解一种更可伸缩的语言会怎样?比如说,Python? 进入 [Xonsh][1]。 安装 Xonsh 就像创建虚拟环境一样简单,运行 `pip install xonsh [ptk,linux]`,然后运行 `xonsh`。 -首先,你可能想知道为什么你的 Python shell 有一个奇怪的提示: +首先,你可能奇怪为什么你的 Python shell 有一个奇怪的提示: + ``` $ 1+1 2 ``` -好的计算器! +好的,计算器! + ``` $ print("hello world") hello world ``` 我们还可以调用其他函数: + ``` $ from antigravity import geohash $ geohash(37.421542, -122.085589, b'2005-05-26-10458.68') @@ -31,12 +36,14 @@ $ geohash(37.421542, -122.085589, b'2005-05-26-10458.68') ``` 然而,我们仍然可以像常规 shell 一样使用它: + ``` $ echo "hello world" hello world ``` 我们甚至可以混搭! + ``` $ for i in range(3): .     echo "hello world" @@ -49,12 +56,14 @@ hello world Xonsh 支持使用 [Prompt Toolkit][2] 补全 shell 命令和 Python 表达式。补全有可视化提示,会显示可能的补全并有下拉列表。 它还支持访问环境变量。它使用简单但强大的启发式方法将 Python 类型应用于环境变量。默认值为 “string”,但是,例如,路径变量是自动列表。 + ``` $ '/usr/bin' in $PATH True ``` Xonsh 接受 shell 形式或 Python 形式的布尔快捷运算符: + ``` $ cat things foo @@ -66,13 +75,15 @@ $ grep -q bar things || echo "found" found ``` -这意味着 Python 关键字是被解释了。如果我们想要打印著名的 Dr. Seuss 书的标题,我们需要引用关键词。 +这意味着 Python 关键字是被解释了。如果我们想要打印著名的《苏斯博士》书的标题,我们需要引用关键词。 + ``` $ echo green eggs "and" ham green eggs and ham ``` 如果我们不这样做,我们会感到惊讶: + ``` $ echo green eggs and ham green eggs @@ -88,9 +99,10 @@ Did you mean one of the following? 虚拟环境可能会有点棘手。一般的虚拟环境(取决于它们类似 Bash 的语法)无法工作。但是,Xonsh 自带了一个名为 `vox` 的虚拟环境管理系统。 -`vox` 可以创建,激活和停用 `~/.virtualenvs` 中的环境。如果你用过 `virtualenvwrapper`,这就是环境变量所在的地方。 +`vox` 可以创建、激活和停用 `~/.virtualenvs` 中的环境。如果你用过 `virtualenvwrapper`,这就是环境变量所在的地方。 请注意,当前激活的环境不会影响 `xonsh`。它无法从激活的环境中导入任何内容。 + ``` $ xontrib load vox $ vox create my-environment                                                     @@ -108,7 +120,7 @@ xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True ModuleNotFoundError: No module named 'money' ``` -第一行启用 `vox`:它是一个 `xontrib`,Xonsh 的一个第三方扩展。`xontrib` 管理器可以列出所有可能的 `xontribs` 及其当前状态(已安装,已加载或未加载)。 +第一行启用 `vox`:它是一个 `xontrib`,是 Xonsh 的一个第三方扩展。`xontrib` 管理器可以列出所有可能的 `xontribs` 及其当前状态(已安装、已加载或未加载)。 可以编写一个 `xontrib` 并上传到 `PyPi` 以使其可用。但是,最好将它添加到 `xontrib` 索引中,以便 Xonsh 提前知道它。比如,这能让配置向导建议它。 @@ -121,7 +133,7 @@ via: https://opensource.com/article/18/9/xonsh-bash-alternative 作者:[Moshe Zadka][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 9157d798fefedeed9744702104f88882c5a97b7f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 14 Sep 2018 17:00:26 +0800 Subject: [PATCH 226/455] PUB:20180904 Why I love Xonsh.md @geekpi https://linux.cn/article-10014-1.html --- {translated/tech => published}/20180904 Why I love Xonsh.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180904 Why I love Xonsh.md (100%) diff --git a/translated/tech/20180904 Why I love Xonsh.md b/published/20180904 Why I love Xonsh.md similarity index 100% rename from translated/tech/20180904 Why I love Xonsh.md rename to published/20180904 Why I love Xonsh.md From 1517647d604a02a0e6c1cb83c48f59b943c63562 Mon Sep 17 00:00:00 2001 From: HankChow <280630620@qq.com> Date: Fri, 14 Sep 2018 17:07:46 +0800 Subject: [PATCH 227/455] HankChow translating --- .../20180730 7 Python libraries for more maintainable code.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180730 7 Python libraries for more maintainable code.md b/sources/tech/20180730 7 Python libraries for more maintainable code.md index 24b3daa886..67657f3890 100644 --- a/sources/tech/20180730 7 Python libraries for more maintainable code.md +++ b/sources/tech/20180730 7 Python libraries for more maintainable code.md @@ -1,3 +1,5 @@ +HankChow translating + 7 Python libraries for more maintainable code ====== From 0447df4911cfbe238069f997bc53b1138d5a0c9c Mon Sep 17 00:00:00 2001 From: sd886393 Date: Fri, 14 Sep 2018 17:18:57 +0800 Subject: [PATCH 228/455] =?UTF-8?q?=E3=80=90=E5=AE=8C=E6=88=90=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E3=80=91sd886393=20=E6=8F=90=E4=BA=A4translated=20tec?= =?UTF-8?q?h=2020180929=20Getting=20started=20with=20the=20i3=20window=20m?= =?UTF-8?q?anager=20on=20linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ted with the i3 window manager on Linux.md | 119 ------------------ ...ted with the i3 window manager on Linux.md | 118 +++++++++++++++++ 2 files changed, 118 insertions(+), 119 deletions(-) delete mode 100644 sources/tech/20180929 Getting started with the i3 window manager on Linux.md create mode 100644 translated/tech/20180929 Getting started with the i3 window manager on Linux.md diff --git a/sources/tech/20180929 Getting started with the i3 window manager on Linux.md b/sources/tech/20180929 Getting started with the i3 window manager on Linux.md deleted file mode 100644 index 20ac244390..0000000000 --- a/sources/tech/20180929 Getting started with the i3 window manager on Linux.md +++ /dev/null @@ -1,119 +0,0 @@ -[sd886393]翻译中 -Getting started with the i3 window manager on Linux -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows-tiling-windows-wall.png?itok=mTH7uVrn) - -In my article [5 reasons the i3 window manager makes Linux better][1], I shared the top five reasons I use and recommend the [i3 window manager][2] as an alternative Linux desktop experience. - -In this post, I will walk through the installation and basic configuration of i3 on Fedora 28 Linux. - -### 1\. Installation - -Log into a Fedora workstation and open up a terminal. Use `dnf` to install the required package, like this: -``` -[ricardo@f28i3 ~]$ sudo dnf install -y i3 i3-ipc i3status i3lock dmenu terminator --exclude=rxvt-unicode -Last metadata expiration check: 1:36:15 ago on Wed 08 Aug 2018 12:04:31 PM EDT. -Dependencies resolved. -================================================================================================ - Package                     Arch         Version                           Repository     Size -================================================================================================ -Installing: - dmenu                       x86_64       4.8-1.fc28                        fedora         33 k - i3                          x86_64       4.15-1.fc28                       fedora        323 k - i3-ipc                      noarch       0.1.4-12.fc28                     fedora         14 k - i3lock                      x86_64       2.9.1-2.fc28                      fedora         33 k - i3status                    x86_64       2.12-1.fc28                       updates        62 k - terminator                  noarch       1.91-4.fc28                       fedora        570 k -Installing dependencies: - dzen2                       x86_64       0.8.5-21.20100104svn.fc28         fedora         60 k - -... Skipping dependencies/install messages - -Complete! -[ricardo@f28i3 ~]$ -``` - -**Note:** In this command, I'm explicitly excluding the package `rxvt-unicode` because I prefer `terminator` as my terminal emulator. - -Depending on the status of your system, it may install many dependencies. Wait for the installation to complete successfully and then reboot your machine. - -### 2. First login and initial setup - -After your machine restarts, you're ready to log into i3 for the first time. In the GNOME Display Manager (GDM) screen, click on your username but—before typing the password to log in—click on the small gear icon and change the session to i3 instead of GNOME, like this: - -![](https://opensource.com/sites/default/files/uploads/i3_first_login_small.png) - -Type your password and click `Sign In`. On your first login, you are presented with the i3 configuration screen: - -![](https://opensource.com/sites/default/files/uploads/i3_first_configuration_small.png) - -Press `ENTER` to generate a config file in your `$HOME/.config/i3` directory. Later you can use this config file to further customize i3's behavior. - -On the next screen, you need to select your `Mod` key. This is important, as the `Mod` key is used to trigger most of i3's keyboard shortcuts. Press `ENTER` to use the default `Win` key as the `Mod` key. If you don't have a `Win` key on your keyboard or prefer to use `Alt` instead, use the arrow key to select it and press `ENTER` to confirm. - -![](https://opensource.com/sites/default/files/uploads/i3_generate_config_small.png) - -You're now logged into your i3 session. Because i3 is a minimalist window manager, you see a black screen with the status bar on the bottom: - -![](https://opensource.com/sites/default/files/uploads/i3_start_small.png) - -Next, let's look at navigating in i3. - -### 3\. Basic shortcuts - -Now that you're logged into an i3 session, you'll need a few basic keyboard shortcuts to get around. - -The majority of i3 shortcuts use the `Mod` key you defined during the initial configuration. When I refer to `Mod` in the following examples, press the key you defined. This will usually be the `Win` key, but it can also be the `Alt` key. - -First, to open up a terminal, use `Mod+ENTER`. Open more than one terminal and notice how i3 automatically tiles them to occupy all available space. By default, i3 splits the screen horizontally; use `Mod+v` to split vertically and press `Mod+h` to go back to the horizontal split. - -![](https://opensource.com/sites/default/files/uploads/i3_3terminal_tiled_small.png) - -To start other applications, press `Mod+d` to open `dmenu`, a simple text-based application menu. By default, `dmenu` presents a list of all applications available on your `$PATH`. Select the application you want to start by using the arrow keys or narrow down the search by typing parts of the application's name. Press `ENTER` to start the selected application. - -![](https://opensource.com/sites/default/files/uploads/i3_dmenu.png) - -If your application does not provide a way to close it, you can use i3 to kill a window by pressing `Mod+Shift+q`. Be careful, as you may lose unsaved work—this behavior depends on each application. - -Finally, to end your session and exit i3, press `Mod+Shift+e`. You are presented with a confirmation message at the top of your screen. Click on `Yes, exit i3` to exit or `X` to cancel. - -![](https://opensource.com/sites/default/files/uploads/i3_exit_small.png) - -This is just an initial list of shortcuts you can use to get around i3. For many more, consult i3's official [documentation][3]. - -### 4\. Replacing GDM - -Using i3 window manager reduces the memory utilization on your system; however, Fedora still uses the default GDM as its login screen. GDM loads several GNOME-related libraries and applications that consume memory. - -If you want to further reduce your system's memory utilization, you can replace GDM with a more lightweight display manager, such as `lightdm`, like this: -``` -[ricardo@f28i3 ~]$ sudo dnf install -y lightdm -[ricardo@f28i3 ~]$ sudo systemctl disable gdm -Removed /etc/systemd/system/display-manager.service. -[ricardo@f28i3 ~]$ sudo systemctl enable lightdm -Created symlink /etc/systemd/system/display-manager.service -> /usr/lib/systemd/system/lightdm.service. -[ricardo@f28i3 ~]$ -``` - -Restart your machine to see the Lightdm login screen. - -Now you're ready to log in and use i3. - -![](https://opensource.com/sites/default/files/uploads/i3_lightdm_small.png) - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/getting-started-i3-window-manager - -作者:[Ricardo Gerardi][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/rgerardi -[1]: https://opensource.com/article/18/8/i3-tiling-window-manager -[2]: https://i3wm.org -[3]: https://i3wm.org/docs/userguide.html#_default_keybindings diff --git a/translated/tech/20180929 Getting started with the i3 window manager on Linux.md b/translated/tech/20180929 Getting started with the i3 window manager on Linux.md new file mode 100644 index 0000000000..ade4e98fcc --- /dev/null +++ b/translated/tech/20180929 Getting started with the i3 window manager on Linux.md @@ -0,0 +1,118 @@ +[sd886393]翻译中 +Getting started with the i3 window manager on Linux +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows-tiling-windows-wall.png?itok=mTH7uVrn) + +在我的文章[5 reasons the i3 window manager makes Linux better][1],我分享了选择 [i3 window manager][2] 作为一种Linux桌面替代方案的最主要五个理由。 +在本篇文章中,我将向大家展示,如何在 Fedora 28 上安装与配置 i3。 + +### 1\. 安装 + +首先进入 Fedora 系统中,打开一个终端。使用 `dnf` 来安装需要的软件包,如下: +``` +[ricardo@f28i3 ~]$ sudo dnf install -y i3 i3-ipc i3status i3lock dmenu terminator --exclude=rxvt-unicode +Last metadata expiration check: 1:36:15 ago on Wed 08 Aug 2018 12:04:31 PM EDT. +Dependencies resolved. +================================================================================================ + Package                     Arch         Version                           Repository     Size +================================================================================================ +Installing: + dmenu                       x86_64       4.8-1.fc28                        fedora         33 k + i3                          x86_64       4.15-1.fc28                       fedora        323 k + i3-ipc                      noarch       0.1.4-12.fc28                     fedora         14 k + i3lock                      x86_64       2.9.1-2.fc28                      fedora         33 k + i3status                    x86_64       2.12-1.fc28                       updates        62 k + terminator                  noarch       1.91-4.fc28                       fedora        570 k +Installing dependencies: + dzen2                       x86_64       0.8.5-21.20100104svn.fc28         fedora         60 k + +... Skipping dependencies/install messages + +Complete! +[ricardo@f28i3 ~]$ +``` + +注意:在这个命令中,我排除了 `rxvt-unicode` 这个包,因为我更喜欢 `terminator` 作为我的终端模拟器。 + +据用户目前的系统状态,在命令执行过程中可能会安装很多依赖。等待所有的依赖安装完成,之后重启你的电脑。 + +### 2. 登录与初始化 + +在你的机器重启之后,你便可以第一次体验 i3 了。在 GNOME Display Manager (GDM),选择你的用户名,之后先别着急输密码,点击下方的密码输入框下方的小齿轮,之后选择 i3 ,像下方这样: + +![](https://opensource.com/sites/default/files/uploads/i3_first_login_small.png) + +输入你的密码,并点击 `Sign In`。在你第一次登入之后,会先看到 i3 的配置界面: + +![](https://opensource.com/sites/default/files/uploads/i3_first_configuration_small.png) + +点击 `ENTER` 就会在 `$HOME/.config/i3` 生成一个配置文件,之后你可以通过这个配置文件来定制化 i3's 的一些行为。 + +在下一屏,你需要选择你的 `Mod` 键。这一步很关键,因为 `Mod` 键通常都会作为 i3's 命令快捷键的发起键。按 `ENTER` 会选择 `Win` 键作为默认的 `Mod` 键。如果你的键盘没有 `Win` 键,用 `Alt` 键做替代,用方向键键选择后按 `ENTER` 确认。 + +![](https://opensource.com/sites/default/files/uploads/i3_generate_config_small.png) + +现在你就登录到了 i3 的系统中。由于 i3 是一个最小化的窗口管理器,你会看到一个黑屏窗口,以及屏幕底端显式的状态栏: + +![](https://opensource.com/sites/default/files/uploads/i3_start_small.png) + +接下来,让我们看看 i3 的如何实际使用。 + +### 3\. 基本的快捷键 + +现在你已经登录到了 i3 的会话中,你需要几个基本的快捷键来应对基本的操作。 + +大多数的 i3 快捷键都会用到之前配置的 `Mod` 键。在下面的例子中,当我提到 `Mod` 键,请根据情况使用你定义的做替换。通常使用 `Win` 键或者 `Alt` 键。 + +首先,打开一个终端,使用 `Mod+ENTER`。重复打开几个终端,观察 i3 是如何自动将它们在桌面中排列。默认情况下, i3 会在水平的方向分割屏幕;使用 `Mod + v` 来垂直分割,再按 `Mod + h` 会恢复水平分割模式。 + +![](https://opensource.com/sites/default/files/uploads/i3_3terminal_tiled_small.png) + +当需要启动其他的应用,按 `Mod + d` 来打开 `dmenu`,一个简单的文字应用菜单。默认情况下,`dmenu` 会呈现出所有在你 `$PATH` 中设置的应用。使用方向键来选择你想启动的应用,同时你可以键入应用的名称,来缩小选择的范围,之后按 `ENTER` 来启动选择的应用。 + +![](https://opensource.com/sites/default/files/uploads/i3_dmenu.png) + +如果你的应用没有提供退出的方法,你可以使用 i3 来关闭对应的窗口,通过按 `Mod + Shift +q`。注意,你可能会丢失未保存的工作内容。 + +最后,当你想关闭会话并退出 i3,按 `Mod + Shift +e`。之后会在窗口的上方提示你是否退出。点击 `Yes, exit i3` 退出,或选择 `X` 来取消。 + +![](https://opensource.com/sites/default/files/uploads/i3_exit_small.png) + +这些就是 i3 中最基本的快捷键,如果想了解更多,请查阅官方文档 [documentation][3]。 + +### 4\. 替换GDM + +使用 i3 window manager 会降低你操作系统的内存占用;然而,Fedora 依然会使用 GDM 作为登录的窗口。GDM 会载入几个与 GNOME 相关的库从而占用内存。 + +如果你想进一步的降低你的内存占用,你可以使用一些更轻量级的窗口管理器来替换 GDM,比如 `lightdm`: +``` +[ricardo@f28i3 ~]$ sudo dnf install -y lightdm +[ricardo@f28i3 ~]$ sudo systemctl disable gdm +Removed /etc/systemd/system/display-manager.service. +[ricardo@f28i3 ~]$ sudo systemctl enable lightdm +Created symlink /etc/systemd/system/display-manager.service -> /usr/lib/systemd/system/lightdm.service. +[ricardo@f28i3 ~]$ +``` + +之后重启你的机器来使用 Lightdm 的登录界面。 + +现在你可以继续登录并使用 i3了。 + +![](https://opensource.com/sites/default/files/uploads/i3_lightdm_small.png) + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/getting-started-i3-window-manager + +作者:[Ricardo Gerardi][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[sd886393](https://github.com/sd886393) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rgerardi +[1]: https://opensource.com/article/18/8/i3-tiling-window-manager +[2]: https://i3wm.org +[3]: https://i3wm.org/docs/userguide.html#_default_keybindings From bae1e78a23b73fabecd2f36c87e60924b7cce784 Mon Sep 17 00:00:00 2001 From: sd886393 Date: Fri, 14 Sep 2018 17:22:39 +0800 Subject: [PATCH 229/455] Update 20180929 Getting started with the i3 window manager on Linux.md --- ...0929 Getting started with the i3 window manager on Linux.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/translated/tech/20180929 Getting started with the i3 window manager on Linux.md b/translated/tech/20180929 Getting started with the i3 window manager on Linux.md index ade4e98fcc..70f4b895dc 100644 --- a/translated/tech/20180929 Getting started with the i3 window manager on Linux.md +++ b/translated/tech/20180929 Getting started with the i3 window manager on Linux.md @@ -1,5 +1,4 @@ -[sd886393]翻译中 -Getting started with the i3 window manager on Linux +在Linux上使用 i3 作为窗口管理器的入门教程 ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows-tiling-windows-wall.png?itok=mTH7uVrn) From fa2bee1a3fbf73f7480e174b0af9ca78ba4d36ec Mon Sep 17 00:00:00 2001 From: feng lv Date: Fri, 14 Sep 2018 20:34:33 +0800 Subject: [PATCH 230/455] translating --- ...hat is ZFS- Why People Use ZFS- [Explained for Beginners].md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md b/sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md index 10425b2054..dae1b06df3 100644 --- a/sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md +++ b/sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md @@ -1,3 +1,5 @@ +ucasFL translating + What is ZFS? Why People Use ZFS? [Explained for Beginners] ====== Today, we will take a look at ZFS, an advanced file system. We will discuss where it came from, what it is, and why it is so popular among techies and enterprise. From e92da88bae2a5a815a7087a08af36a0837f7c1b4 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 14 Sep 2018 21:24:46 +0800 Subject: [PATCH 231/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20ScreenCloud:=20Th?= =?UTF-8?q?e=20Screenshot++=20App?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...80913 ScreenCloud- The Screenshot-- App.md | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 sources/tech/20180913 ScreenCloud- The Screenshot-- App.md diff --git a/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md b/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md new file mode 100644 index 0000000000..147937ab14 --- /dev/null +++ b/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md @@ -0,0 +1,77 @@ +ScreenCloud: The Screenshot++ App +====== +[ScreenCloud][1] is an amazing little app, that you don’t even know you need. The default screenshot procedure on desktop Linux is great (Prt Scr Button) and we even have some[powerful screenshot utilities][2]like [Shutter][3]. But ScreenCloud brings one more really simple yet really convenient feature that I just fell in love with. But before we get into it, let’s catch a little backstory. + +I take a lot of screenshots. A lot more than average. Receipts, registration details, development work, screenshots of applications for articles, and lot more. The next thing I do is open a browser, browse to my favorite cloud storage and dump the important ones there so that I can access them on my phone and also across multiple operating systems on my PC. This also allows me to easily share screenshots of the apps that I’m working on with my team. + +I had no complaints with this standard procedure of taking screenshots, opening a browser and logging into my cloud and then uploading the screenshots manually, until I came across ScreenCloud. + +### ScreenCloud + +ScreenCloud is cross-platform utility that provides easy screenshot capture and management along with flexible [cloud backup options][4]. including your own [FTP server][5]. + +![][6] + +ScreenCloud is really streamlined with a lot of attention given to the smaller things. It provides you very easy to remember hotkeys to capture the full screen, the active window or capture an area selected with the mouse. + +![][7]Default keyboard shortcuts for ScreenCloud + +Once a screenshot is taken, you can either set ScreenCloud to ask what to do with the image or to directly upload it the cloud service of your choice. Even SFTP is supported. Once the screenshot it uploaded, generally within a couple of seconds, the link to the image is automatically copied to the clipboard, which you can easily share. + +![][8] + +You can also do some basic editing with ScreenCloud. For this, you should have “Save to” set to “Ask me”. This setting is available from the application indicator and is usually set by default. With this, when you take a screenshot, you’ll see the option for editing the file. Here, you can add arrows, text and numbers to the screenshot. + +![Editing screenshots with ScreenCloud][9]Editing screenshots with ScreenCloud + +### Installing ScreenCloud on Linux + +ScreenCloud is available in the [Snap store][10]. So you can easily install it on Ubuntu and other [Snap enabled][11] distros by visiting the [Snap store][12] or by running the following command. + +``` +sudo snap install screencloud + +``` + +And for Linux distros which can’t install apps through Snap, You can download the AppImage [here][1]. The browse to the download location, right click and open a terminal there. Then run the command below. + +``` +sudo chmod +x ScreenCloud-v1.4.0-x86_64.AppImage + +``` + +You can then launch the app by double clicking on the downloaded file. + +![][13] + +### Wrapping up + +Is ScreenCloud for everybody? Probably not. Is it better than the default screenshot? Probably yes. See if you’re taking a screenshot of something, then chances are, that it’s probably important or you intend to share it. ScreenCloud makes backing up or sharing that screenshot easier and considerably faster. So yeah, you should give ScreenCloud a try if you want these features. + +Your thoughts and comments are always welcome, use the comments section below. And don’t forget to share this article with your friends. Cheers. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/screencloud-app/ + +作者:[Aquil Roshan][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/aquil/ +[1]: https://screencloud.net +[2]: https://itsfoss.com/take-screenshot-linux/ +[3]: http://shutter-project.org +[4]: https://itsfoss.com/cloud-services-linux/ +[5]: https://itsfoss.com/set-ftp-server-linux/ +[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/screencloud3.jpg +[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/screencloud2.jpg +[8]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ScrenCloud6.jpg +[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/editing-with-screencloud.png +[10]: https://snapcraft.io/ +[11]: https://itsfoss.com/install-snap-linux/ +[12]: https://snapcraft.io/screencloud +[13]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ScrenCloud4.jpg From 949b3a687a8e258cf3b7fba39ce4ae784e8ade32 Mon Sep 17 00:00:00 2001 From: feng lv Date: Sat, 15 Sep 2018 01:34:50 +0800 Subject: [PATCH 232/455] translated --- ...ople Use ZFS- [Explained for Beginners].md | 116 ------------------ ...ople Use ZFS- [Explained for Beginners].md | 116 ++++++++++++++++++ 2 files changed, 116 insertions(+), 116 deletions(-) delete mode 100644 sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md create mode 100644 translated/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md diff --git a/sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md b/sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md deleted file mode 100644 index dae1b06df3..0000000000 --- a/sources/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md +++ /dev/null @@ -1,116 +0,0 @@ -ucasFL translating - -What is ZFS? Why People Use ZFS? [Explained for Beginners] -====== -Today, we will take a look at ZFS, an advanced file system. We will discuss where it came from, what it is, and why it is so popular among techies and enterprise. - -Even though I’m from the US, I prefer to pronounce it ZedFS instead of ZeeFS because it sounds cooler. You are free to pronounce it however you like. - -Note: You will see ZFS repeated many times in the article. When I talk about feature and installation, I’m talking about OpenZFS. ZFS (developed by Oracle) and OpenZFS have followed different paths since Oracle shutdown OpenSolaris. (More on that later.) - -### History of ZFS - -The Z File System (ZFS) was created by [Matthew Ahrens and Jeff Bonwick][1] in 2001. ZFS was designed to be a next generation file system for [Sun Microsystems’][2] [OpenSolaris][3]. In 2008, ZFS was ported to FreeBSD. The same year a project was started to port [ZFS to Linux][4]. However, since ZFS is licensed under the [Common Development and Distribution License][5], which is incompatible with the [GNU General Public License][6], it cannot be included in the Linux kernel. To get around this problem, most Linux distros offer methods to install ZFS. - -Shortly after Oracle purchased Sun Microsystems, OpenSolaris became close-source. All further development of ZFS became closed source, as well. Many of the developers of ZFS where unhappy about this turn of events. [Two-thirds of the core ZFS devlopers][1], including Ahrens and Bonwick, left Oracle due to this decision. They joined other companies and created the [OpenZFS project][7] in September of 2013. The project has spearheaded the open-source development of ZFS. - -Let’s go back to the license issue mentioned above. Since the OpenZFS project is separate from Oracle, some probably wonder why they don’t change the license to something that is compatible with the GPL so it can be included in the Linux kernel. According to the [OpenZFS website][8], changing the license would involve contacting anyone who contributed code to the current OpenZFS implementation (including the initial, common ZFS code till OpenSolaris) and get their permission to change the license. Since this job is near impossible (because some contributors may be dead or hard to find), they have decided to keep the license they have. - -### What is ZFS? What are its features? - -![ZFS filesystem][9] - -As I said before, ZFS is an advanced file system. As such, it has some interesting [features][10]. Such as: - - * Pooled storage - * Copy-on-write - * Snapshots - * Data integrity verification and automatic repair - * RAID-Z - * Maximum 16 Exabyte file size - * Maximum 256 Quadrillion Zettabytes storage - - - -Let’s break down a couple of those features. - -#### Pooled Storage - -Unlike most files systems, ZFS combines the features of a file system and a volume manager. This means that unlike other file systems, ZFS can create a file system that spans across a series of drives or a pool. Not only that but you can add storage to a pool by adding another drive. ZFS will handle [partitioning and formatting][11]. - -![Pooled storage in ZFS][12]Pooled storage in ZFS - -#### Copy-on-write - -[Copy-on-write][13] is another interesting (and cool) features. On most files system, when data is overwritten, it is lost forever. On ZFS, the new information is written to a different block. Once the write is complete, the file systems metadata is updated to point to the new info. This ensures that if the system crashes (or something else happens) while the write is taking place, the old data will be preserved. It also means that the system does not need to run [fsck][14] after a system crash. - -#### Snapshots - -Copy-on-write leads into another ZFS feature: snapshots. ZFS uses snapshots to track changes in the file system. “[The snapshot][13] contains the original version of the file system, and the live filesystem contains any changes made since the snapshot was taken. No additional space is used. As new data is written to the live file system, new blocks are allocated to store this data.” It a file is deleted, the snapshot reference is removed, as well. So, snapshots are mainly designed to track changes to files, but not the addition and creation of files. - -Snapshots can be mounted as read-only to recover a past version of a file. It is also possible to rollback the live system to a previous snapshot. All changes made since the snapshot will be lost. - -#### Data integrity verification and automatic repair - -Whenever new data is written to ZFS, it creates a checksum for that data. When that data is read, the checksum is verified. If the checksum does not match, then ZFS knows that an error has been detected. ZFS will then automatically attempt to correct the error. - -#### RAID-Z - -ZFS can handle RAID without requiring any extra software or hardware. Unsurprisingly, ZFS has its own implementation of RAID: RAID-Z. RAID-Z is actually a variation of RAID-5. However, it is designed to overcome the RAID-5 write hole error, “in which the data and parity information become inconsistent after an unexpected restart”. To use the basic [level of RAID-Z][15] (RAID-Z1) you need at least two disks for storage and one for [parity][16]. RAID-Z2 required at least two storage drives and two drive for parity. RAID-Z3 requires at least two storage drives and three drive for parity. When drives are added to the RAID-Z pools, they have to be added in multiples of two. - -#### Huge Storage potential - -When ZFS was created, it was designed to be [the last word in file systems][17]. At a time when most file systems where 64-bit, the ZFS creators decided to jump right to 128-bit to future proof it. This means that ZFS “offers 16 billion billion times the capacity of 32- or 64-bit systems”. In fact, Jeff Bonwick (one of the creators) said [that powering][18] a “fully populating a 128-bit storage pool would, literally, require more energy than boiling the oceans.” - -### How to Install ZFS? - -If you want to use ZFS out of the box, it would require installing either [FreeBSD][19] or an [operating system using the illumos kernel][20]. [illumos][21] is a fork of the OpenSolaris kernel. - -In fact, support for [ZFS is one of the main reasons why some experienced Linux users opt for BSD][22]. - -If you want to try ZFS on Linux, you can only use it at your storage file system. As a far as I know, no Linux distro give you the option to install ZFS on your root out of the box. If you are interested in trying ZFS on Linux, the [ZFS on Linux project][4] has a number of tutorials on how to do that. - -### Caveat - -This article has sung the benefits of ZFS. Now let me tell you a quick problem with ZFS. Using RAID-Z [can be expensive][23] because of the number of drives you need to purchase to add storage space. - -Have you every ZFS? What was your experience like? Let us know in the comments below. - -If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][24]. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/what-is-zfs/ - -作者:[John Paul][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/john/ -[1]: https://wiki.gentoo.org/wiki/ZFS -[2]: http://en.wikipedia.org/wiki/Sun_Microsystems -[3]: http://en.wikipedia.org/wiki/Opensolaris -[4]: https://zfsonlinux.org/ -[5]: https://en.wikipedia.org/wiki/Common_Development_and_Distribution_License -[6]: https://en.wikipedia.org/wiki/GNU_General_Public_License -[7]: http://www.open-zfs.org/wiki/Main_Page -[8]: http://www.open-zfs.org/wiki/FAQ#Do_you_plan_to_release_OpenZFS_under_a_license_other_than_the_CDDL.3F -[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/what-is-zfs.png -[10]: https://wiki.archlinux.org/index.php/ZFS -[11]: https://www.howtogeek.com/175159/an-introduction-to-the-z-file-system-zfs-for-linux/ -[12]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/zfs-overview.png -[13]: https://www.freebsd.org/doc/handbook/zfs-term.html -[14]: https://en.wikipedia.org/wiki/Fsck -[15]: https://wiki.archlinux.org/index.php/ZFS/Virtual_disks#Creating_and_Destroying_Zpools -[16]: https://www.pcmag.com/encyclopedia/term/60364/raid-parity -[17]: https://web.archive.org/web/20060428092023/http://www.sun.com/2004-0914/feature/ -[18]: https://blogs.oracle.com/bonwick/128-bit-storage:-are-you-high -[19]: https://www.freebsd.org/ -[20]: https://wiki.illumos.org/display/illumos/Distributions -[21]: https://wiki.illumos.org/display/illumos/illumos+Home -[22]: https://itsfoss.com/why-use-bsd/ -[23]: http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html -[24]: http://reddit.com/r/linuxusersgroup diff --git a/translated/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md b/translated/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md new file mode 100644 index 0000000000..152bb75d23 --- /dev/null +++ b/translated/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md @@ -0,0 +1,116 @@ +初学者指南:ZFS 是什么,为什么要使用 ZFS? +====== + +![ZFS filesystem][9] + +今天,我们来谈论一下 ZFS,一个高级文件系统。我们将讨论 ZFS 从何而来,它是什么,以及为什么它在科技界和企业界如此受欢迎。 + +虽然我是一个美国人,但我更喜欢读成 ZedFS 而不是 ZeeFS,因为前者听起来更酷一些。你可以根据你的个人喜好来发音。 + +注意:在这篇文章中,你将会看到很多次 ZFS。当我在谈论特性和安装的时候,我所指的是 OpenZFS 。自从 Oracle 公司放弃 OpenSolaris 项目之后,ZFS(由 Oracle 公司开发)和 OpenZFS 已经走向了不同的发展道路。 + +### ZFS 的历史 + +Z 文件系统(ZFS)是在 2001 年由 [Matthew Ahrens 和 Jeff Bonwick][1] 开发的。ZFS 是作为 Sun 公司的[微系统MicroSystem][2] [OpenSolaris][3] 的下一代文件系统而设计的。在 2008 年,ZFS 被移植到了 FreeBSD 。同一年,一个新的项目也开始了:[ZFS to Linux][4] 。然而,由于 ZFS 是[通用开发和发布许可证(CDDL)][5]许可的,它和 [GNU 通用公共许可证][6] 不兼容,因此不能将它迁移到 Linux 内核中。为了解决这个问题,绝大多数 Linux 发行版提供了一些方法来安装 ZFS 。 + +在 Oracle 公司收购 Sun 公司之后不久,微系统 OpenSolaris 就闭源了,这使得 ZFS 的最新开发也闭源了。许多 ZFS 开发者对这件事情非常不开心。[三分之二的 ZFS 核心开发者][1],包括 Ahrens 和 Bonwick,因为这个决定而离开了 Oracle 公司。他们加入其他公司,并于 2013 年 9 月创立了 [OpenZFS][7] 这一项目。该项目引领着 ZFS 的开源开发。 + +让我们回到上面提到的许可证问题上。既然 OpenZFS 项目已经和 Oracle 公司分离开了,有人可能好奇他们为什么不使用和 GPL 兼容的许可证,这样就可以把它加入到 Linux 内核中了。根据 [OpenZFS 官网][8] 的介绍,更改许可证需要联系所有为当前 OpenZFS 实现贡献过代码的人(包括初始公共 ZFS 代码以及 OpenSolaris 代码),并得到他们的许可才行。这几乎是不可能的(因为一些贡献者可能已经去世了或者很难找到),因此他们决定保留原来的许可证。 + +### ZFS 是什么,它有什么特性? + +正如前面所说过的,ZFS 是一个高级文件系统。因此,它有一些有趣的[特性][10]。比如: + + * 存储池 + * 写时拷贝 + * 快照 + * 数据完整性验证和自动修复 + * RAID-Z + * 最大单个文件大小为 16 EB(1 EB = 1024 PB) + * 最大 256 万亿的四次方 ZB(1 ZB = 1024 EB)的存储 + + + +让我们来深入了解一下其中一些特性。 + +#### 存储池 + +与大多数文件系统不同,ZFS 结合了文件系统和卷管理器的特性。这意味着,它与其他文件系统不同,ZFS 可以创建跨域一系列硬盘或池的文件系统。不仅如此,你还可以通过添加硬盘来增大池的存储容量。ZFS 可以进行[分区和格式化][11]。 + +![Pooled storage in ZFS][12] +*ZFS 存储池* + +#### 写时拷贝 + +[写时拷贝Copy-on-write][13]是另一个有趣并且很酷的特性。在大多数文件系统上,当数据被重写时,它将永久丢失。而在 ZFS 中,新数据会写到不同的块。写完成之后,更新文件系统元数据信息,使之指向新的数据块(LCTT 译注:更新之后,原数据块成为磁盘上的垃圾,需要有对应的垃圾回收机制)。这确保了如果在写新数据的时候系统崩溃(或者发生其它事,比如突然断电),那么原数据将会保存下来。这也意味着,在系统发生崩溃之后,不需要运行 [fsck][14] 来检查和修复文件系统。 + +#### 快照 + +写时拷贝使得 ZFS 有了另一个特性:快照snapshots。ZFS 使用快照来跟踪文件系统中的更改。[快照][13]包含文件系统的原始版本(文件系统的一个只读版本),实时文件系统则包含了自从快照创建之后的任何更改。没有使用额外的空间。因为新数据将会写到实时文件系统新分配的块上。如果一个文件被删除了,那么它在快照中的索引也会被删除。所以,快照主要是用来跟踪文件的更改,而不是文件的增加和创建。 + +快照可以挂载成只读的,以用来恢复一个文件的过去版本。实时系统也可以回滚到之前的快照。回滚之后,自从快照创建之后的所有更改将会丢失。 + +#### 数据完整性验证和自动修复 + +当向 ZFS 写入新数据时,会创建该数据的校验和。在读取数据的时候,使用校验和进行验证。如果前后校验和不匹配,那么就说明检测到了错误,然后,ZFS 会尝试自动修正错误。 + +#### RAID-Z + +ZFS 不需要任何额外软件或硬件就可以处理 RAID(磁盘阵列)。毫无奇怪,因为 ZFS 有自己的 RAID 实现:RAID-Z 。RAID-Z 是 RAID-5 的一个变种,不过它克服了 RAID-5 的写漏洞:意外重启之后,数据和校验信息会变得不同步(LCTT 译注:RAID-5 的 stripe 在正写数据时,如果这时候电源中断,那么奇偶校验数据将跟该部分数据不同步,因此前边的写无效;RAID-Z 用了 “variable-width RAID stripes” 技术,因此所有的写都是 full-stripe writes)。为了使用基本级别的 [RAID-Z][15](RAID-Z1),你需要至少三块磁盘,其中两块用来存储数据,另外一块用来存储[奇偶校验信息][16]。而RAID-Z2 需要至少两块磁盘存储数据以及两块磁盘存储校验信息。RAID-Z3 需要至少两块磁盘存储数据以及三块磁盘存储校验信息。另外,只能向 RAID-Z 池中加入偶数倍的磁盘,而不能是奇数倍的。 + +#### 巨大的存储潜力 + +创建 ZFS 的时候,它就被设计成了[最后一个文件系统][17] 。那时候,大多数文件系统都是 64 位的,ZFS 的创建者决定直接跳到 128 位,等到将来再来证明这是对的。这意味着 ZFS 的容量大小是 32 位或 64 位文件系统的 160 亿亿倍。事实上,Jeff Bonwick(其中一个创建者)说:“完全填满一个 128 位的存储池所需要的[能量][18],从字面上讲,比煮沸海洋需要的还多。” + +### 如何安装 ZFS? + +如果你想立刻使用 ZFS(开箱即用),那么你需要安装 [FreeBSD][19] 或一个[使用 illumos 内核的操作系统][20]。[illumos][21] 是 OpenSolaris 内核的一个克隆版本。 + +事实上,支持 [ZFS 是一些有经验的 Linux 用户选择 BSD 的主要原因][22]。 + +如果你想在 Linux 上尝试 ZFS,那么只能在存储文件系统上使用。据我所知,没有任何 Linux 发行版可以在根目录上安装 ZFS,实现开箱即用。如果你对在 Linux 上尝试 ZFS 感兴趣,那么 [ZFS on Linux 项目][4] 上有大量的教程可以指导你怎么做。 + +### 附加说明 + +这篇文章论述了 ZFS 的优点。现在,让我来告诉你一个关于 ZFS 很现实的问题。使用 RAID-Z [会很贵][23],因为你需要购买大量的磁盘来增大存储空间。 + +你已经使用过 ZFS 了吗?你的使用经验是什么样的?请在下面的评论中告诉我们。 + +如果你觉得这篇文章有趣,请花一分钟的时间把它分享到社交媒体、极客新闻或 [Reddit][24] 。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/what-is-zfs/ + +作者:[John Paul][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[ucasFL](https://github.com/ucasFL) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[1]: https://wiki.gentoo.org/wiki/ZFS +[2]: http://en.wikipedia.org/wiki/Sun_Microsystems +[3]: http://en.wikipedia.org/wiki/Opensolaris +[4]: https://zfsonlinux.org/ +[5]: https://en.wikipedia.org/wiki/Common_Development_and_Distribution_License +[6]: https://en.wikipedia.org/wiki/GNU_General_Public_License +[7]: http://www.open-zfs.org/wiki/Main_Page +[8]: http://www.open-zfs.org/wiki/FAQ#Do_you_plan_to_release_OpenZFS_under_a_license_other_than_the_CDDL.3F +[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/what-is-zfs.png +[10]: https://wiki.archlinux.org/index.php/ZFS +[11]: https://www.howtogeek.com/175159/an-introduction-to-the-z-file-system-zfs-for-linux/ +[12]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/zfs-overview.png +[13]: https://www.freebsd.org/doc/handbook/zfs-term.html +[14]: https://en.wikipedia.org/wiki/Fsck +[15]: https://wiki.archlinux.org/index.php/ZFS/Virtual_disks#Creating_and_Destroying_Zpools +[16]: https://www.pcmag.com/encyclopedia/term/60364/raid-parity +[17]: https://web.archive.org/web/20060428092023/http://www.sun.com/2004-0914/feature/ +[18]: https://blogs.oracle.com/bonwick/128-bit-storage:-are-you-high +[19]: https://www.freebsd.org/ +[20]: https://wiki.illumos.org/display/illumos/Distributions +[21]: https://wiki.illumos.org/display/illumos/illumos+Home +[22]: https://itsfoss.com/why-use-bsd/ +[23]: http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html +[24]: http://reddit.com/r/linuxusersgroup From ed522a52db83dc80f310e26a4e2ad43e4bfcfae1 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 15 Sep 2018 08:38:41 +0800 Subject: [PATCH 233/455] PRF:20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md @geekpi --- ...ners To Choose A Suitable Linux Distribution.md | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/translated/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md b/translated/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md index b3362c4a37..1cb44b2ed1 100644 --- a/translated/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md +++ b/translated/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md @@ -1,8 +1,9 @@ Distrochooser 帮助 Linux 初学者选择合适的 Linux 发行版 ====== -![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-logo-720x340.png) -你好 Linux 新手!今天,我为你们带来了一个好消息!你也许想知道如何选择合适的 Linux 发行版。当然,你可能已经咨询过一些 Linux 专家来帮助你的需要选择 Linux 发行版。你们中的一些人可能已经用 Google 搜索并浏览了各种资源、Linux 论坛、网站和博客来寻找完美的发行版。好了,你不必再那样做了。有了 **Distrochooser**,一个帮助你轻松找到 Linux 发行版的网站。 +![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-logo-720x340.png) + +你好 Linux 新手!今天,我为你们带来了一个好消息!你也许想知道如何选择合适的 Linux 发行版。当然,你可能已经咨询过一些 Linux 专家来帮助你的需要选择 Linux 发行版。你们中的一些人可能已经用 Google 搜索并浏览了各种资源、Linux 论坛、网站和博客来寻找完美的发行版。好了,你不必再那样做了。有了 **Distrochooser**,一个帮助你轻松找到 Linux 发行版的网站。 ### Distrochooser 如何帮助 Linux 初学者选择合适的 Linux 发行版? @@ -11,6 +12,7 @@ Distrochooser 会根据你的答案向你询问一系列问题并建议你尝试 ![][2] 你将被重定向到 Distrochooser 主页,其中有一个小测试在等待你注册。 + ![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-home-page.png) 你需要回答一系列问题(准确地说是 16 个问题)。问题同时有单选和多选。以下是完整的问题列表。 @@ -32,8 +34,6 @@ Distrochooser 会根据你的答案向你询问一系列问题并建议你尝试 15. 软件:管理 16. 软件:更新 - - 仔细阅读问题并在相应问题下面选择合适的答案。Distrochooser 提供了更多选择来选择接近完美的发行版。 * 你总是可以跳过问题, @@ -42,9 +42,7 @@ Distrochooser 会根据你的答案向你询问一系列问题并建议你尝试 * 你可以随时删除答案, * 你可以在测试结束时对属性进行加权,以强调对你来说重要的内容。 - - -选择问题的答案后,单击**继续**以转到下一个问题。完成后,单击**获取结果**按钮。你也可以通过单击答案下面的**“清除”**按钮随时清除选择。 +选择问题的答案后,单击“Proceed”以转到下一个问题。完成后,单击“Get Result”按钮。你也可以通过单击答案下面的“Clear”按钮随时清除选择。 ### 结果? @@ -69,7 +67,7 @@ via: https://www.ostechnix.com/distrochooser-helps-linux-beginners-to-choose-a-s 作者:[SK][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 81ff4e50e855788e7a466991bafd34f613cd0d16 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 15 Sep 2018 08:39:44 +0800 Subject: [PATCH 234/455] PUB:20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md @geekpi https://linux.cn/article-10015-1.html --- ...lps Linux Beginners To Choose A Suitable Linux Distribution.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md (100%) diff --git a/translated/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md b/published/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md similarity index 100% rename from translated/tech/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md rename to published/20180802 Distrochooser Helps Linux Beginners To Choose A Suitable Linux Distribution.md From 13444696738e381ad7c9ddfedc2b8ba43868e742 Mon Sep 17 00:00:00 2001 From: jamelouis Date: Sat, 15 Sep 2018 12:39:57 +0800 Subject: [PATCH 235/455] translating 20180518 masteringci-cd at opendev --- sources/talk/20180518 Mastering CI-CD at OpenDev.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/talk/20180518 Mastering CI-CD at OpenDev.md b/sources/talk/20180518 Mastering CI-CD at OpenDev.md index cb8b9fdfc8..d33282c1d4 100644 --- a/sources/talk/20180518 Mastering CI-CD at OpenDev.md +++ b/sources/talk/20180518 Mastering CI-CD at OpenDev.md @@ -1,3 +1,5 @@ +[translating by jamelouis] + Mastering CI/CD at OpenDev ====== From e034341e680586c5c2e53aaa1fa5eb4faac877e5 Mon Sep 17 00:00:00 2001 From: MZZZ Date: Sat, 15 Sep 2018 14:26:27 +0800 Subject: [PATCH 236/455] Delete 20180828 15 command-line aliases to save you time.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 删除源文件 --- ...5 command-line aliases to save you time.md | 104 ------------------ 1 file changed, 104 deletions(-) delete mode 100644 sources/talk/20180828 15 command-line aliases to save you time.md diff --git a/sources/talk/20180828 15 command-line aliases to save you time.md b/sources/talk/20180828 15 command-line aliases to save you time.md deleted file mode 100644 index f357896293..0000000000 --- a/sources/talk/20180828 15 command-line aliases to save you time.md +++ /dev/null @@ -1,104 +0,0 @@ -15 command-line aliases to save you time -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_blue.png?itok=IfckxN48) - -Linux command-line aliases are great for helping you work more efficiently. Better still, some are included by default in your installed Linux distro. - -This is an example of a command-line alias in Fedora 27: - -![](https://opensource.com/sites/default/files/uploads/default.png) - -The command `alias` shows the list of existing aliases. Setting an alias is as simple as typing: - -`alias new_name="command"` - -Here are 15 command-line aliases that will save you time: - -1. To install any utility/application: - -`alias install="sudo yum install -y"` - -Here, `sudo` and `-y` are optional as per user’s preferences: - - -![install alias.png][2] - -2. To update the system: - -`alias update="sudo yum update -y"` - -3. To upgrade the system: - -`alias upgrade="sudo yum upgrade -y"` - -4. To change to the root user: - -`alias root="sudo su -"` - -5. To change to "user," where "user" is set as your username: - -`alias user="su user"` - -6. To display the list of all available ports, their status, and IP: - -`alias myip="ip -br -c a"` - -7. To `ssh` to the server `myserver`: - -`alias myserver="ssh user@my_server_ip”` - -8. To list all processes in the system: - -`alias process="ps -aux"` - -9. To check the status of any system service: - -`alias sstatus="sudo systemctl status"` - -10. To restart any system service: - -`alias srestart="sudo systemctl restart"` - -11. To kill any process by its name: - -`alias kill="sudo pkill"` - -![kill process alias.png][4] - -12. To display the total used and free memory of the system: - -`alias mem="free -h"` - -13. To display the CPU architecture, number of CPUs, threads, etc. of the system: - -`alias cpu="lscpu"` - -14. To display the total disk size of the system: - -`alias disk="df -h"` - -15. To display the current system Linux distro (for CentOS, Fedora, and Red Hat): - -`alias os="cat /etc/redhat-release"` - -![system_details alias.png][6] - - - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/time-saving-command-line-aliases - -作者:[Aarchit Modi][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/architmodi -[2]:https://opensource.com/sites/default/files/uploads/install.png (install alias.png) -[4]:https://opensource.com/sites/default/files/uploads/kill.png (kill process alias.png) -[6]:https://opensource.com/sites/default/files/uploads/system_details.png (system_details alias.png) From ad38c9c473f9e5bb7a0c9a31e440eed08b3d4250 Mon Sep 17 00:00:00 2001 From: MZZZ Date: Sat, 15 Sep 2018 14:29:37 +0800 Subject: [PATCH 237/455] Create 20180828 15 command-line aliases to save you time.md translated by MZqk --- ...5 command-line aliases to save you time.md | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 translated/talk/20180828 15 command-line aliases to save you time.md diff --git a/translated/talk/20180828 15 command-line aliases to save you time.md b/translated/talk/20180828 15 command-line aliases to save you time.md new file mode 100644 index 0000000000..476b77799b --- /dev/null +++ b/translated/talk/20180828 15 command-line aliases to save you time.md @@ -0,0 +1,100 @@ +15 个可以节省你时间的命令别名 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_blue.png?itok=IfckxN48) + +Linux 命令行别名非常适合帮助你提高工作效率。更好的是,有些 Linux 发行版中就默认包含一些别名。 + +这是 Fedora 27 中的命令别名的示例: + +![](https://opensource.com/sites/default/files/uploads/default.png) + +这个 `alias` 命令列出了已有的别名。设置别名也十分简单: + +`alias new_name="command"` + +这里有 15 个命令行别名,可以节省你的时间: + +1. 安装任何应用实用 / 应用程序: + +`alias install="sudo yum install -y"` + +在这里, `sudo` 和 `-y` 是可选的,因为每个用户的偏好: + +![install alias.png][2] + +2. 更新系统: + +`alias update="sudo yum update -y"` + +3. 升级系统: +`alias upgrade="sudo yum upgrade -y"` + +4. 切换 root 用户: + +`alias root="sudo su -"` + +5. 要更改"用户", 其中"user"设置为你的用户名: + +`alias user="su user"` + +6. 显示列出所有可用端口,状态还有 IP: + +`alias myip="ip -br -c a"` + +7. `ssh`你的服务器`myserver`: + +`alias myserver="ssh user@my_server_ip”` + +8. 列出系统中所有进程: + +`alias process="ps -aux"` + +9. 检查系统的服务状态: + +`alias sstatus="sudo systemctl status"` + +10. 重启系统服务在: + +`alias srestart="sudo systemctl restart"` + +11. 按名称杀死进程: + +`alias kill="sudo pkill"` + +![kill process alias.png][4] + +12. 显示系统系统总使用内存和空闲内存 : + +`alias mem="free -h"` + +13. 显示系统 CPU 框架结构,CPU 数量,线程数等: + +`alias cpu="lscpu"` + +14. 显示系统总磁盘大小: + +`alias disk="df -h"` + +15. 显示当前系统 Linux 发行版本(适用于 CentOS,Fedora 和 Red Hat): + +`alias os="cat /etc/redhat-release"` + +![system_details alias.png][6] + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/time-saving-command-line-aliases + +作者:[Aarchit Modi][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[MZqk](https://github.com/) +校对:[校对者 ID](https://github.com/ 校对者 ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/architmodi +[2]:https://opensource.com/sites/default/files/uploads/install.png (install alias.png) +[4]:https://opensource.com/sites/default/files/uploads/kill.png (kill process alias.png) +[6]:https://opensource.com/sites/default/files/uploads/system_details.png (system_details alias.png) From 8ab0b6ccd7fb6da546290ec9a663ee23f4ac8a84 Mon Sep 17 00:00:00 2001 From: name1e5s <836401406@qq.com> Date: Sat, 15 Sep 2018 14:38:43 +0800 Subject: [PATCH 238/455] [Translating] Know Your Storage- Block, File - Object --- sources/tech/20180911 Know Your Storage- Block, File - Object.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180911 Know Your Storage- Block, File - Object.md b/sources/tech/20180911 Know Your Storage- Block, File - Object.md index 24f179d9d5..186b41d41a 100644 --- a/sources/tech/20180911 Know Your Storage- Block, File - Object.md +++ b/sources/tech/20180911 Know Your Storage- Block, File - Object.md @@ -1,3 +1,4 @@ +translating by name1e5s Know Your Storage: Block, File & Object ====== From 0899226b21bcb673888030f6c439ccbe27429f2f Mon Sep 17 00:00:00 2001 From: HankChow <280630620@qq.com> Date: Sat, 15 Sep 2018 15:08:13 +0800 Subject: [PATCH 239/455] translated --- ...on libraries for more maintainable code.md | 123 ------------------ ...on libraries for more maintainable code.md | 120 +++++++++++++++++ 2 files changed, 120 insertions(+), 123 deletions(-) delete mode 100644 sources/tech/20180730 7 Python libraries for more maintainable code.md create mode 100644 translated/tech/20180730 7 Python libraries for more maintainable code.md diff --git a/sources/tech/20180730 7 Python libraries for more maintainable code.md b/sources/tech/20180730 7 Python libraries for more maintainable code.md deleted file mode 100644 index 67657f3890..0000000000 --- a/sources/tech/20180730 7 Python libraries for more maintainable code.md +++ /dev/null @@ -1,123 +0,0 @@ -HankChow translating - -7 Python libraries for more maintainable code -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_keyboard_coding.png?itok=E0Vvam7A) - -> Readability counts. -> — [The Zen of Python][1], Tim Peters - -It's easy to let readability and coding standards fall by the wayside when a software project moves into "maintenance mode." (It's also easy to never establish those standards in the first place.) But maintaining consistent style and testing standards across a codebase is an important part of decreasing the maintenance burden, ensuring that future developers are able to quickly grok what's happening in a new-to-them project and safeguarding the health of the app over time. - -### Check your code style - -A great way to protect the future maintainability of a project is to use external libraries to check your code health for you. These are a few of our favorite libraries for [linting code][2] (checking for PEP 8 and other style errors), enforcing a consistent style, and ensuring acceptable test coverage as a project reaches maturity. - -[PEP 8][3] is the Python code style guide, and it sets out rules for things like line length, indentation, multi-line expressions, and naming conventions. Your team might also have your own style rules that differ slightly from PEP 8. The goal of any code style guide is to enforce consistent standards across a codebase to make it more readable, and thus more maintainable. Here are three libraries to help prettify your code. - -#### 1\. Pylint - -[Pylint][4] is a library that checks for PEP 8 style violations and common errors. It integrates well with several popular [editors and IDEs][5] and can also be run from the command line. - -To install, run `pip install pylint`. - -To use Pylint from the command line, run `pylint [options] path/to/dir` or `pylint [options] path/to/module.py`. Pylint will output warnings about style violations and other errors to the console. - -You can customize what errors Pylint checks for with a [configuration file][6] called `pylintrc`. - -#### 2\. Flake8 - -[Flake8][7] is a "Python tool that glues together PEP8, Pyflakes (similar to Pylint), McCabe (code complexity checker), and third-party plugins to check the style and quality of some Python code." - -To use Flake8, run `pip install flake8`. Then run `flake8 [options] path/to/dir` or `flake8 [options] path/to/module.py` to see its errors and warnings. - -Like Pylint, Flake8 permits some customization for what it checks for with a [configuration file][8]. It has very clear docs, including some on useful [commit hooks][9] to automatically check your code as part of your development workflow. - -Flake8 integrates with popular editors and IDEs, but those instructions generally aren't found in the docs. To integrate Flake8 with your favorite editor or IDE, search online for plugins (for example, [Flake8 plugin for Sublime Text][10]). - -#### 3\. Isort - -[Isort][11] is a library that sorts your imports alphabetically and breaks them up into [appropriate sections][12] (e.g., standard library imports, third-party library imports, imports from your own project, etc.). This increases readability and makes it easier to locate imports if you have a lot of them in your module. - -Install isort with `pip install isort`, and run it with `isort path/to/module.py`. More configuration options are in the [documentation][13]. For example, you can [configure][14] how isort handles multi-line imports from one library in an `.isort.cfg` file. - -Like Flake8 and Pylint, isort also provides plugins that integrate it with popular [editors and IDEs][15]. - -### Outsource your code style - -Remembering to run linters manually from the command line for each file you change is a pain, and you might not like how a particular plugin behaves with your IDE. Also, your colleagues might prefer different linters or might not have plugins for their favorite editors, or you might be less meticulous about always running the linter and correcting the warnings. Over time, the codebase you all share will get messy and harder to read. - -A great solution is to use a library that automatically reformats your code into something that passes PEP 8 for you. The three libraries we recommend all have different levels of customization and different defaults for how they format code. Some of these are more opinionated than others, so like with Pylint and Flake8, you'll want to test these out to see which offers the customizations you can't live without… and the unchangeable defaults you can live with. - -#### 4\. Autopep8 - -[Autopep8][16] automatically formats the code in the module you specify. It will re-indent lines, fix indentation, remove extraneous whitespace, and refactor common comparison mistakes (like with booleans and `None`). See a full [list of corrections][17] in the docs. - -To install, run `pip install --upgrade autopep8`. To reformat code in place, run `autopep8 --in-place --aggressive --aggressive `. The `aggressive` flags (and the number of them) indicate how much control you want to give autopep8 over your code style. Read more about [aggressive][18] options. - -#### 5\. Yapf - -[Yapf][19] is yet another option for reformatting code that comes with its own list of [configuration options][20]. It differs from autopep8 in that it doesn't just address PEP 8 violations. It also reformats code that doesn't violate PEP 8 specifically but isn't styled consistently or could be formatted better for readability. - -To install, run `pip install yapf`. To reformat code, run, `yapf [options] path/to/dir` or `yapf [options] path/to/module.py`. There is also a full list of [customization options][20]. - -#### 6\. Black - -[Black][21] is the new kid on the block for linters that reformat code in place. It's similar to autopep8 and Yapf, but way more opinionated. It has very few options for customization, which is kind of the point. The idea is that you shouldn't have to make decisions about code style; the only decision to make is to let Black decide for you. You can read about [limited customization options][22] and instructions on [storing them in a configuration file][23]. - -Black requires Python 3.6+ but can format Python 2 code. To use, run `pip install black`. To prettify your code, run: `black path/to/dir` or `black path/to/module.py`. - -### Check your test coverage - -You're writing tests, right? Then you will want to make sure new code committed to your codebase is tested and doesn't drop your overall amount of test coverage. While percentage of test coverage is not the only metric you should use to measure the effectiveness and sufficiency of your tests, it is one way to ensure basic testing standards are being followed in your project. For measuring test coverage, we have one recommendation: Coverage. - -#### 7\. Coverage - -[Coverage][24] has several options for the way it reports your test coverage to you, including outputting results to the console or to an HTML page and indicating which line numbers are missing test coverage. You can set up a [configuration file][25] to customize what Coverage checks for and make it easier to run. - -To install, run `pip install coverage`. To run a program and see its output, run `coverage run [path/to/module.py] [args]`, and you will see your program's output. To see a report of which lines of code are missing coverage, run `coverage report -m`. - -Continuous integration (CI) is a series of processes you can run to automatically check for linter errors and test coverage minimums before you merge and deploy code. There are lots of free or paid tools to automate this process, and a thorough walkthrough is beyond the scope of this article. But because setting up a CI process is an important step in removing blocks to more readable and maintainable code, you should investigate continuous integration tools in general; check out [Travis CI][26] and [Jenkins][27] in particular. - -These are only a handful of the libraries available to check your Python code. If you have a favorite that's not on this list, please share it in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/7/7-python-libraries-more-maintainable-code - -作者:[Jeff Triplett][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/laceynwilliams -[1]:https://www.python.org/dev/peps/pep-0020/ -[2]:https://en.wikipedia.org/wiki/Lint_(software) -[3]:https://www.python.org/dev/peps/pep-0008/ -[4]:https://www.pylint.org/ -[5]:https://pylint.readthedocs.io/en/latest/user_guide/ide-integration.html -[6]:https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options -[7]:http://flake8.pycqa.org/en/latest/ -[8]:http://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations -[9]:http://flake8.pycqa.org/en/latest/user/using-hooks.html -[10]:https://github.com/SublimeLinter/SublimeLinter-flake8 -[11]:https://github.com/timothycrosley/isort -[12]:https://github.com/timothycrosley/isort#how-does-isort-work -[13]:https://github.com/timothycrosley/isort#using-isort -[14]:https://github.com/timothycrosley/isort#configuring-isort -[15]:https://github.com/timothycrosley/isort/wiki/isort-Plugins -[16]:https://github.com/hhatto/autopep8 -[17]:https://github.com/hhatto/autopep8#id4 -[18]:https://github.com/hhatto/autopep8#id5 -[19]:https://github.com/google/yapf -[20]:https://github.com/google/yapf#usage -[21]:https://github.com/ambv/black -[22]:https://github.com/ambv/black#command-line-options -[23]:https://github.com/ambv/black#pyprojecttoml -[24]:https://coverage.readthedocs.io/en/latest/ -[25]:https://coverage.readthedocs.io/en/latest/config.html -[26]:https://travis-ci.org/ -[27]:https://jenkins.io/ diff --git a/translated/tech/20180730 7 Python libraries for more maintainable code.md b/translated/tech/20180730 7 Python libraries for more maintainable code.md new file mode 100644 index 0000000000..de08df9304 --- /dev/null +++ b/translated/tech/20180730 7 Python libraries for more maintainable code.md @@ -0,0 +1,120 @@ +这 7 个 Python 库让你写出更易维护的代码 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_keyboard_coding.png?itok=E0Vvam7A) + +> 可读性很重要。 +> — [Python 之禅(The Zen of Python)][1], Tim Peters + +尽管很多项目一开始的时候就有可读性和编码标准的要求,但随着项目进入“维护模式”,这些要求都会变得虎头蛇尾。然而,在代码库中保持一致的代码风格和测试标准能够显著减轻维护的压力,也能确保新的开发者能够快速了解项目的情况,同时能更好地保持应用程序的运行良好。 + +### 检查你的代码风格 + +使用外部库来检查代码运行情况不失为保护项目未来可维护性的一个好方法。以下会推荐一些我们最喜爱的[检查代码][2](包括检查 PEP 8 和其它代码风格错误)的库,用它们来强制保持代码风格一致,并确保在项目成熟时有一个可接受的测试覆盖率。 + +[PEP 8][3]是Python代码风格规范,规定了行长度,缩进,多行表达式、变量命名约定等内容。尽管你的团队自身可能也会有不同于 PEP 8 的代码风格规范,但任何代码风格规范的目标都是在代码库中强制实施一致的标准,使代码的可读性更强、更易于维护。下面三个库就可以用来帮助你美化代码。 + +#### 1\. Pylint + +[Pylint][4] 是一个检查违反 PEP 8 规范和常见错误的库。它在一些流行的编辑器和 IDE 中都有集成,也可以单独从命令行运行。 + +执行 `pip install pylint`安装 Pylint 。然后运行 `pylint [options] path/to/dir` 或者 `pylint [options] path/to/module.py` 就可以在命令行中使用 Pylint,它会向控制台输出代码中违反规范和出现错误的地方。 + +你还可以使用 `pylintrc` [配置文件][6]来自定义 Pylint 对哪些代码错误进行检查。 + +#### 2\. Flake8 + +对 [Flake8][7] 的描述是“将 PEP 8、Pyflakes(类似 Pylint)、McCabe(代码复杂性检查器)、第三方插件整合到一起,以检查 Python 代码风格和质量的一个 Python 工具”。 + +执行 `pip install flake8` 安装 flake8 ,然后执行 `flake8 [options] path/to/dir` 或者 `flake8 [options] path/to/module.py` 可以查看报出的错误和警告。 + +和 Pylint 类似,Flake8 允许通过[配置文件][8]来自定义检查的内容。它有非常清晰的文档,包括一些有用的[提交钩子][9],可以将自动检查代码纳入到开发工作流程之中。 + +Flake8 也允许集成到一些流行的编辑器和 IDE 当中,但在文档中并没有详细说明。要将 Flake8 集成到喜欢的编辑器或 IDE 中,可以搜索插件(例如 [Sublime Text 的 Flake8 插件][10])。 + +#### 3\. Isort + +[Isort][11] 这个库能将你在项目中导入的库按字母顺序,并将其[正确划分为不同部分][12](例如标准库、第三方库,自建的库等)。这样提高了代码的可读性,并且可以在导入的库较多的时候轻松找到各个库。 + +执行 `pip install isort` 安装 isort,然后执行 `isort path/to/module.py` 就可以运行了。文档中还提供了更多的配置项,例如通过配置 `.isort.cfg` 文件来决定 isort 如何处理一个库的多行导入。 + +和 Flake8、Pylint 一样,isort 也提供了将其与流行的[编辑器和 IDE][15] 集成的插件。 + +### 共享代码风格 + +每次文件发生变动之后都用命令行手动检查代码是一件痛苦的事,你可能也不太喜欢通过运行 IDE 中某个插件来实现这个功能。同样地,你的同事可能会用不同的代码检查方式,也许他们的编辑器中也没有安装插件,甚至自己可能也不会严格检查代码和按照警告来更正代码。总之,你共享的代码库将会逐渐地变得混乱且难以阅读。 + +一个很好的解决方案是使用一个库,自动将代码按照 PEP 8 规范进行格式化。我们推荐的三个库都有不同的自定义级别来控制如何格式化代码。其中有一些设置较为特殊,例如 Pylint 和 Flake8 ,你需要先行测试,看看是否有你无法忍受蛋有不能修改的默认配置。 + +#### 4\. Autopep8 + +[Autopep8][16] 可以自动格式化指定的模块中的代码,包括重新缩进行,修复缩进,删除多余的空格,并重构常见的比较错误(例如布尔值和 `None` 值)。你可以查看文档中完整的[更正列表][17]。 + +运行 `pip install --upgrade autopep8` 安装 autopep8。然后执行 `autopep8 --in-place --aggressive --aggressive ` 就可以重新格式化你的代码。`aggressive` 标记的数量表示 auotopep8 在代码风格控制上有多少控制权。在这里可以详细了解 [aggressive][18] 选项。 + +#### 5\. Yapf + +[Yapf][19] 是另一种有自己的[配置项][20]列表的重新格式化代码的工具。它与 autopep8 的不同之处在于它不仅会指出代码中违反 PEP 8 规范的地方,还会对没有违反 PEP 8 但代码风格不一致的地方重新格式化,旨在令代码的可读性更强。 + +执行`pip install yapf` 安装 Yapf,然后执行 `yapf [options] path/to/dir` 或 `yapf [options] path/to/module.py` 可以对代码重新格式化。 + +#### 6\. Black + +[Black][21] 在代码检查工具当中算是比较新的一个。它与 autopep8 和 Yapf 类似,但限制较多,没有太多的自定义选项。这样的好处是你不需要去决定使用怎么样的代码风格,让 black 来给你做决定就好。你可以在这里查阅 black 的[自定义选项][22]以及[如何在配置文件中对其进行设置][23]。 + +Black 依赖于 Python 3.6+,但它可以格式化用 Python 2 编写的代码。执行 `pip install black` 安装 black,然后执行 `black path/to/dir` 或 `black path/to/module.py` 就可以使用 black 优化你的代码。 + +### 检查你的测试覆盖率 + +如果你正在进行测试工作,你需要确保提交到代码库的新代码都已经测试通过,并且不会降低测试覆盖率。虽然测试覆盖率不是衡量测试有效性和充分性的唯一指标,但它是确保项目遵循基本测试标准的一种方法。对于计算测试覆盖率,我们推荐使用 Coverage 这个库。 + +#### 7\. Coverage + +[Coverage][24] 有数种显示测试覆盖率的方式,包括将结果输出到控制台或 HTML 页面,并指出哪些具体哪些地方没有被覆盖到。你可以通过配置文件自定义 Coverage 检查的内容,让你更方便使用。 + +执行 `pip install coverage` 安装 Converage 。然后执行 `coverage [path/to/module.py] [args]` 可以运行程序并查看输出结果。如果要查看哪些代码行没有被覆盖,执行 `coverage report -m` 即可。 + +持续集成(Continuous integration, CI)是在合并和部署代码之前自动检查代码风格错误和测试覆盖率最小值的过程。很多免费或付费的工具都可以用于执行这项工作,具体的过程不在本文中赘述,但 CI 过程是令代码更易读和更易维护的重要步骤,关于这一部分可以参考 [Travis CI][26] 和 [Jenkins][27]。 + +以上这些只是用于检查 Python 代码的各种工具中的其中几个。如果你有其它喜爱的工具,欢迎在评论中分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/7/7-python-libraries-more-maintainable-code + +作者:[Jeff Triplett][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[HankChow](https://github.com/HankChow) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/laceynwilliams +[1]:https://www.python.org/dev/peps/pep-0020/ +[2]:https://en.wikipedia.org/wiki/Lint_(software) +[3]:https://www.python.org/dev/peps/pep-0008/ +[4]:https://www.pylint.org/ +[5]:https://pylint.readthedocs.io/en/latest/user_guide/ide-integration.html +[6]:https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options +[7]:http://flake8.pycqa.org/en/latest/ +[8]:http://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations +[9]:http://flake8.pycqa.org/en/latest/user/using-hooks.html +[10]:https://github.com/SublimeLinter/SublimeLinter-flake8 +[11]:https://github.com/timothycrosley/isort +[12]:https://github.com/timothycrosley/isort#how-does-isort-work +[13]:https://github.com/timothycrosley/isort#using-isort +[14]:https://github.com/timothycrosley/isort#configuring-isort +[15]:https://github.com/timothycrosley/isort/wiki/isort-Plugins +[16]:https://github.com/hhatto/autopep8 +[17]:https://github.com/hhatto/autopep8#id4 +[18]:https://github.com/hhatto/autopep8#id5 +[19]:https://github.com/google/yapf +[20]:https://github.com/google/yapf#usage +[21]:https://github.com/ambv/black +[22]:https://github.com/ambv/black#command-line-options +[23]:https://github.com/ambv/black#pyprojecttoml +[24]:https://coverage.readthedocs.io/en/latest/ +[25]:https://coverage.readthedocs.io/en/latest/config.html +[26]:https://travis-ci.org/ +[27]:https://jenkins.io/ + From e6618f7101b22e0076d5cd5d2c4e665791c081da Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Sat, 15 Sep 2018 15:51:11 +0800 Subject: [PATCH 240/455] heguangzhi translating 3 open source log aggregation tools --- sources/tech/20180910 3 open source log aggregation tools.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180910 3 open source log aggregation tools.md b/sources/tech/20180910 3 open source log aggregation tools.md index 0f63de0e3b..de41debf57 100644 --- a/sources/tech/20180910 3 open source log aggregation tools.md +++ b/sources/tech/20180910 3 open source log aggregation tools.md @@ -1,3 +1,5 @@ +heguangzhi Translating + 3 open source log aggregation tools ====== Log aggregation systems can help with troubleshooting and other tasks. Here are three top options. From 1afacea2801d7d4607462b00615c7a73717d424b Mon Sep 17 00:00:00 2001 From: hopefully2333 <787016457@qq.com> Date: Sat, 15 Sep 2018 16:50:58 +0800 Subject: [PATCH 241/455] Update 20180824 Steam Makes it Easier to Play Windows Games on Linux.md --- ...0824 Steam Makes it Easier to Play Windows Games on Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md b/sources/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md index 07d22aaad0..73080089bf 100644 --- a/sources/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md +++ b/sources/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md @@ -1,3 +1,5 @@ +translated by hopefully2333 + Steam Makes it Easier to Play Windows Games on Linux ====== ![Steam Wallpaper][1] From 62db391f1e1caa7acfd2201d5aa89b24838be282 Mon Sep 17 00:00:00 2001 From: jamelouis Date: Sat, 15 Sep 2018 17:30:47 +0800 Subject: [PATCH 242/455] finishing the translation about ci-cd talk --- .../20180518 Mastering CI-CD at OpenDev.md | 55 ------------------- .../20180518 Mastering CI-CD at OpenDev.md | 55 +++++++++++++++++++ 2 files changed, 55 insertions(+), 55 deletions(-) delete mode 100644 sources/talk/20180518 Mastering CI-CD at OpenDev.md create mode 100644 translated/talk/20180518 Mastering CI-CD at OpenDev.md diff --git a/sources/talk/20180518 Mastering CI-CD at OpenDev.md b/sources/talk/20180518 Mastering CI-CD at OpenDev.md deleted file mode 100644 index d33282c1d4..0000000000 --- a/sources/talk/20180518 Mastering CI-CD at OpenDev.md +++ /dev/null @@ -1,55 +0,0 @@ -[translating by jamelouis] - -Mastering CI/CD at OpenDev -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_opennature_3.png?itok=J1OSECM_) -After launching in 2017, the [OpenDev Conference][1] is now an annual event. At the inaugural event last September, the conference focus was on edge computing. This year's event, taking place May 22-23, will be focused on Continuous Integration/Continuous Deployment (CI/CD) and will be co-located with the OpenStack Summit in Vancouver. - - - -I was invited to participate in the program committee for OpenDev CI/CD based on my background on the CI/CD system for the OpenStack project and my recent move into the container space. Today I frequently talk about CI/CD pipelines using various open source technologies, including [Jenkins][3] [GitLab][2],[Spinnaker][4] , and [Artifactory][5] - -This event is exciting for me because we're bringing two open source infrastructure ideas together into one event. First, we'll be discussing CI/CD tooling that can be used by any organization. To this end, in the [keynotes][6] we'll hear practical talks about open source CI/CD tooling, including a talk about Spinnaker from Boris Renski and one from Jim Blair on [Zuul][7]. The keynotes also will include higher-level talks about the preference for open technologies, especially across communities and inside open source projects themselves. From Fatih Degirmenci and Daniel Farrell we'll hear about sharing continuous delivery practices across communities, and Benjamin Mako Hill will join us to talk about why free software needs free tools. - -Given the relative newness of CI/CD, the rest of the event is a mix of talks, workshops, and collaborative discussions. When selecting from talks and workshops submitted, and coming up with collaborative discussion topics, we wanted to make sure there was a diverse schedule so anyone on the open CI/CD spectrum would find something interesting. - -The talks will be standard conference style, selected to cover key topics like crafting CI/CD pipelines, improving security when practicing DevOps, and more specific solutions like container-based [Aptomi][8] on Kubernetes and doing CI/CD in ETSI NFV environments. Many of these sessions will serve as an introduction to these topics, ideal for those who are new to the CI/CD space or any of these specific technologies. - -The hands-on workshops are longer and will have specific outcomes in mind for attendees. These include "[Anomaly Detection in Continuous Integration Jobs][9]," "[How to Install Zuul and Configure Your First Jobs][10]," and "[Spinnaker 101: Releasing Software with Velocity and Confidence][11]." (Note that space is limited in these workshops, so an RSVP system has been set up. You'll find an RSVP button on the session links provided here.) - -Perhaps what I'm most excited about are the collaborative discussions, and these take up over half of the conference schedule. The topics were chosen by the program committee based on what we've been seeing in our communities. These are "fishbowl"-style sessions, where several people get in a room together to discuss a specific topic around CI/CD. - -The idea for this style of session was taken from developer summits that the Ubuntu community pioneered and the OpenStack community continued. Topics for these collaborative discussions include separate sessions for CI and CD fundamentals, improvements that can be made to encourage cross-community collaboration, driving CI/CD culture in organizations, and why open source CI/CD tooling is so important. Shared documents are used to take notes during these sessions to make sure that as much knowledge shared during the session is retained as possible. It's also common for action items to come from these discussions, so community members can push forward initiatives related to the topic being covered. - -The event concludes with a [Joint Conclusion Session][12], which will be summarizing the key points from the collaborative discussions and identifying work areas that attendees wish to work on in future. - -Registration for this event is included in [OpenStack Summit registration][13], or tickets for this event only can be purchased for $199 onsite at the Vancouver Convention Center. Learn more about tickets and the full agenda on the [OpenDev website][1]. - -I hope you'll join us in Vancouver for an exciting two days of learning, collaborating and making progress together on CI/CD. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/5/opendev - -作者:[Elizabeth K.Joseph][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/pleia2 -[1]:http://2018.opendevconf.com/ -[2]:https://about.gitlab.com/ -[3]:https://jenkins.io/ -[4]:https://www.spinnaker.io/ -[5]:https://jfrog.com/artifactory/ -[6]:http://2018.opendevconf.com/schedule/ -[7]:https://zuul-ci.org/ -[8]:http://aptomi.io/ -[9]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21692/anomaly-detection-in-continuous-integration-jobs -[10]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21693/how-to-install-zuul-and-configure-your-first-jobs -[11]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21699/spinnaker-101-releasing-software-with-velocity-and-confidence -[12]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21831/opendev-cicd-joint-collab-conclusion -[13]:https://www.eventbrite.com/e/openstack-summit-may-2018-vancouver-tickets-40845826968?aff=VancouverSummit2018 diff --git a/translated/talk/20180518 Mastering CI-CD at OpenDev.md b/translated/talk/20180518 Mastering CI-CD at OpenDev.md new file mode 100644 index 0000000000..5937acb05a --- /dev/null +++ b/translated/talk/20180518 Mastering CI-CD at OpenDev.md @@ -0,0 +1,55 @@ +[translating by jamelouis] + +Mastering CI/CD at OpenDev +在OpenDev上,掌握CI/CD(持续集成/持续发布) +====== + +![在OpenDev上,掌握CI/CD](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_opennature_3.png?itok=J1OSECM_) + +在2017年启动后,OpenDev会议现在是一个年度活动。在去年9月的首届活动上,会议的重点是边缘计算。今年的活动,将于5月22-23日举行,会议的重点是持续集成和持续发布 (CI/CD),并将与OpenStack峰会一起在温哥华举行。 + +基于我在OpenStack项目的CI/CD系统的技术背景和近期进入容器下的CI/CD方面的经验,我被邀请加入OpenDev CI/CD的编程委员会。今天我经常通过很多开源技术,例如[Jenkins][3] [GitLab][2],[Spinnaker][4],和[Artifactory][5],来讨论CI/CD流水管线。 + +这次活动对我来说是很激动人心的,因为我们将在这个活动中融合两个开源基础设施理念。首先,我们将讨论可以被任何组织使用的CI/CD工具。为此目的,在[keynotes][6],我们将听到关于开源CI/CD工具的使用讲座,一场来自Boris Renski的关于Spinnaker的和一场来自Jim Blair的关于[Zuul][7]的。同时,讲座会涉及关于开源技术的偏好的高级别话题,特别是那种跨社区的和本身就是开源项目的。从Fatih Degirmenci和Daniel Farrel那里,我们将听到关于在不同社区分享持续发布实践经历,接着Benjamin Mako Hill会为我带来一场关于为什么免费软件需要免费工具的分享。 + +在分享CI/CD相对新颖特性后,接下来的活动是对话,研讨会和协作讨论的混合组合。当从所提交的讲座和研讨会选择,并提出协作讨论主题时,我们希望确保有一个多样灵活的日程表,这样任何参与者都能在CI/CD活动进程中发现有趣的东西。 + +这些讲座会是标准的会议风格,选择以涵盖关键主题,如制作CI/CD管线,在实践DevOps时提升安全性,以及更具体的解决方案,如基于容器关于Kubernetes的[Aptomi][8]和在ETSI NFV环境下CI/CD。这些会话的大部分将会是作为给新接触CI/CD或这些特定技术的参与者关于这些话题和理念的简介。 + +交互式的研讨会会持续相对比较长的时间,参与者将会在思想上得到特定的体验。这些研讨会包括"[Anomaly Detection in Continous Integration Jobs(在持续集成任务中的异常检测)][9]","[How to Install Zuul and Configure Your First Jobs(如何安装Zuul和配置第一个任务)][10]",和"[Spinnake 101: Releasing Software with Velocity and Confidence(Spinnake 101:快速可靠的软件发布)][11]."(注意这些研讨会空间是有限的,所以设立了一个RSVP系统。你们将会在会议的链接里找到一个RSVP的按钮。) + +可能最让我最兴奋的是协作讨论,这些协作讨论占据了一半以上的活动安排。协作讨论的主题由编程委员会选取。编程委员会是根据我们在社区里所看到选取对应的主题。这是“鱼缸”风格式的会议,通常是几个人聚在一个房间里围绕着CI/CD讨论某一个主题。 + +这次会议风格的理念是来自于开发者峰会,最初是由Ubuntu社区提出,接着OpenStack社区在活动上采纳。这些协作讨论的主题包含不同的会议,这些会议是关于CI/CD基础,可以鼓励跨社区协作的提升举措,在组织里推行CI/CD文化,和为什么开源CI/CD工具如此重要。采用共享文档来做会议笔记,以确保尽可能的在会议的过程中分享知识。在讨论过程中,提出行动项目也是很常见的,因此社区成员可以推动和所涉及的主题相关的倡议。 + +活动将以联合总结会议结束。联合总结会议将总结来自协同讨论的关键点和为即将在这个领域工作的参与者指出可选的职业范围。 + +可以在[OpenStack Summit registration(OpenStack峰会注册)][13]上注册参加活动。或者可以在温哥华唯一指定售票的会议中心购买活动的入场券,价格是$199。更多关于票和全部的活动安排见官网[OpenDev website][1]。 + +我希望你们能够加入我们,并在温哥华渡过令人激动的两天,并且在这两天的活动中学习,协作和在CI/CD取得进展。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/opendev + +作者:[Elizabeth K.Joseph][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[jamelouis](https://github.com/jamelouis) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/pleia2 +[1]:http://2018.opendevconf.com/ +[2]:https://about.gitlab.com/ +[3]:https://jenkins.io/ +[4]:https://www.spinnaker.io/ +[5]:https://jfrog.com/artifactory/ +[6]:http://2018.opendevconf.com/schedule/ +[7]:https://zuul-ci.org/ +[8]:http://aptomi.io/ +[9]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21692/anomaly-detection-in-continuous-integration-jobs +[10]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21693/how-to-install-zuul-and-configure-your-first-jobs +[11]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21699/spinnaker-101-releasing-software-with-velocity-and-confidence +[12]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21831/opendev-cicd-joint-collab-conclusion +[13]:https://www.eventbrite.com/e/openstack-summit-may-2018-vancouver-tickets-40845826968?aff=VancouverSummit2018 From 4ad495ea0851dce5ef32cb333bb36b2f4e56d147 Mon Sep 17 00:00:00 2001 From: jamelouis Date: Sat, 15 Sep 2018 17:38:01 +0800 Subject: [PATCH 243/455] translated --- translated/talk/20180518 Mastering CI-CD at OpenDev.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/translated/talk/20180518 Mastering CI-CD at OpenDev.md b/translated/talk/20180518 Mastering CI-CD at OpenDev.md index 5937acb05a..74e6d1c972 100644 --- a/translated/talk/20180518 Mastering CI-CD at OpenDev.md +++ b/translated/talk/20180518 Mastering CI-CD at OpenDev.md @@ -1,6 +1,3 @@ -[translating by jamelouis] - -Mastering CI/CD at OpenDev 在OpenDev上,掌握CI/CD(持续集成/持续发布) ====== From e7144341d9c33329c0053cd45931436ff548ddb9 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 15 Sep 2018 22:43:09 +0800 Subject: [PATCH 244/455] PRF:20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md @ucasFL --- ...wall on FreeBSD to Protect a Web Server.md | 124 +++++++++++++----- 1 file changed, 88 insertions(+), 36 deletions(-) diff --git a/translated/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md b/translated/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md index cf4fdef529..c14e204ebd 100644 --- a/translated/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md +++ b/translated/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md @@ -3,13 +3,13 @@ [![How To Set Up a Firewall with PF on FreeBSD to Protect a Web Server][1]][1] -我是从 Linux 迁移过来的 FreeBSD 新用户,Linux 中使用的是 netfilter 防火墙框架(LCTT 译注:netfilter 是由 Rusty Russell 提出的 Linux 2.4 内核防火墙框架)。那么在 FreeBSD 上,我该如何设置 PF 防火墙,从而来保护只有一个公共 IP 地址和端口的 web 服务器呢? +我是从 Linux 迁移过来的 FreeBSD 新用户,Linux 中使用的是 netfilter 防火墙框架(LCTT 译注:netfilter 是由 Rusty Russell 提出的 Linux 2.4 内核防火墙框架)。那么在 FreeBSD 上,我该如何设置 PF 防火墙,来保护只有一个公共 IP 地址和端口的 web 服务器呢? -PF 是包过滤器packet filter的简称。它是为 OpenBSD开发的,但是已经被移植到了 FreeBSD 以及其它操作系统上。PF 是一个状态包过滤引擎。在这篇教程中,我将向你展示如何在 FreeBSD 10.x 以及 11.x 中设置 PF 防火墙,从而来保护 web 服务器。 +PF 是包过滤器packet filter的简称。它是为 OpenBSD 开发的,但是已经被移植到了 FreeBSD 以及其它操作系统上。PF 是一个包状态过滤引擎。在这篇教程中,我将向你展示如何在 FreeBSD 10.x 以及 11.x 中设置 PF 防火墙,从而来保护 web 服务器。 ### 第一步:开启 PF 防火墙 -你需要把下面这几行内容添加到文件 “/etc/rc.conf” 文件中: +你需要把下面这几行内容添加到文件 `/etc/rc.conf` 文件中: ``` # echo 'pf_enable="YES"' >> /etc/rc.conf @@ -17,20 +17,22 @@ PF 是包过滤器packet filter的简称。它是为 OpenB # echo 'pflog_enable="YES"' >> /etc/rc.conf # echo 'pflog_logfile="/var/log/pflog"' >> /etc/rc.conf ``` + 在这里: - 1. **pf_enable="YES"** - 开启 PF 服务 - 2. **pf_rules="/usr/local/etc/pf.conf"** - 从文件 “/usr/local/etc/pf.conf” 中读取 PF 规则 - 3. **pflog_enable="YES"** - 为 PF 服务打开日志支持 - 4. **pflog_logfile="/var/log/pflog"** - 存储日志的文件,即日志存于文件 “/var/log/pflog” 中 + 1. `pf_enable="YES"` - 开启 PF 服务 + 2. `pf_rules="/usr/local/etc/pf.conf"` - 从文件 `/usr/local/etc/pf.conf` 中读取 PF 规则 + 3. `pflog_enable="YES"` - 为 PF 服务打开日志支持 + 4. `pflog_logfile="/var/log/pflog"` - 存储日志的文件,即日志存于文件 `/var/log/pflog` 中 -### 第二步:在 “/usr/local/etc/pf.conf” 文件中创建防火墙规则 +### 第二步:在 `/usr/local/etc/pf.conf` 文件中创建防火墙规则 输入下面这个命令打开文件(超级用户模式下): ``` # vi /usr/local/etc/pf.conf ``` + 在文件中添加下面这些 PF 规则集: ``` @@ -98,35 +100,56 @@ pass out quick on $ext_if proto udp to any port $int_udp_services 保存并关闭文件。欢迎来参考我的[规则集][2]。如果要检查语法错误,可以运行: -`# service pf check` +``` +# service pf check +``` + 或 -`/etc/rc.d/pf check` + +``` +/etc/rc.d/pf check +``` + 或 -`# pfctl -n -f /usr/local/etc/pf.conf ` + +``` +# pfctl -n -f /usr/local/etc/pf.conf +``` ### 第三步:开始运行 PF 防火墙 命令如下。请小心,如果是基于 SSH 的会话,你可能会和服务器断开连接。 -*开启 PF 防火墙:* +#### 开启 PF 防火墙: -`# service pf start` +``` +# service pf start +``` -*停用 PF 防火墙:* +#### 停用 PF 防火墙: -`# service pf stop` +``` +# service pf stop +``` -*检查语法错误:* +#### 检查语法错误: -`# service pf check` +``` +# service pf check +``` -*重启服务:* +#### 重启服务: -`# service pf restart` +``` +# service pf restart +``` -*查看 PF 状态:* +#### 查看 PF 状态: + +``` +# service pf status +``` -`# service pf status` 示例输出: ``` @@ -168,7 +191,8 @@ Counters #### 开启/关闭/重启 pflog 服务的命令 -输入下面这些命令 +输入下面这些命令: + ``` # service pflog start # service pflog stop @@ -181,7 +205,10 @@ Counters #### 显示 PF 规则信息 -`# pfctl -s rules` +``` +# pfctl -s rules +``` + 示例输出: ``` @@ -204,11 +231,15 @@ pass out quick on vtnet0 proto udp from any to any port = ntp keep state #### 显示每条规则的详细内容 -`# pfctl -v -s rules` +``` +# pfctl -v -s rules +``` 在每条规则的详细输出中添加规则编号: -`# pfctl -vvsr show` +``` +# pfctl -vvsr show +``` #### 显示状态信息 @@ -220,15 +251,22 @@ pass out quick on vtnet0 proto udp from any to any port = ntp keep state #### 如何在命令行中禁止 PF 服务 -`# pfctl -d ` +``` +# pfctl -d +``` #### 如何在命令行中启用 PF 服务 -`# pfctl -e ` +``` +# pfctl -e +``` #### 如何在命令行中刷新 PF 规则/NAT/路由表 -`# pfctl -F all` +``` +# pfctl -F all +``` + 示例输出: ``` @@ -243,25 +281,36 @@ pf: interface flags reset #### 如何在命令行中仅刷新 PF 规则 -`# pfctl -F rules ` +``` +# pfctl -F rules +``` #### 如何在命令行中仅刷新队列 -`# pfctl -F queue ` +``` +# pfctl -F queue +``` #### 如何在命令行中刷新统计信息(它不是任何规则的一部分) -`# pfctl -F info` +``` +# pfctl -F info +``` #### 如何在命令行中清除所有计数器 -`# pfctl -z clear ` +``` +# pfctl -z clear +``` ### 第五步:查看 PF 日志 PF 日志是二进制格式的。使用下面这一命令来查看: -`# tcpdump -n -e -ttt -r /var/log/pflog` +``` +# tcpdump -n -e -ttt -r /var/log/pflog +``` + 示例输出: ``` @@ -305,7 +354,10 @@ Aug 29 16:01:36.990050 rule 0/(match) block in on vio0: 182.18.8.28.23299 > 45.F ``` 如果要查看实时日志,可以运行: -`# tcpdump -n -e -ttt -i pflog0` + +``` +# tcpdump -n -e -ttt -i pflog0 +``` 如果你想了解更多信息,可以访问 [PF FAQ][3] 和 [FreeBSD HANDBOOK][4] 以及下面这些 man 页面: @@ -325,7 +377,7 @@ via: https://www.cyberciti.biz/faq/how-to-set-up-a-firewall-with-pf-on-freebsd-t 作者:[Vivek Gite][a] 译者:[ucasFL](https://github.com/ucasFL) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -336,4 +388,4 @@ via: https://www.cyberciti.biz/faq/how-to-set-up-a-firewall-with-pf-on-freebsd-t [4]:https://www.freebsd.org/doc/handbook/firewalls.html [5]:https://twitter.com/nixcraft [6]:https://facebook.com/nixcraft -[7]:https://plus.google.com/+CybercitiBiz \ No newline at end of file +[7]:https://plus.google.com/+CybercitiBiz From 4720d873695c877e0458fb1b50f269f7976477fd Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 15 Sep 2018 22:43:41 +0800 Subject: [PATCH 245/455] PUB:20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md @ucasFL https://linux.cn/article-10016-1.html --- ...ow To Set Up PF Firewall on FreeBSD to Protect a Web Server.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md (100%) diff --git a/translated/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md b/published/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md similarity index 100% rename from translated/tech/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md rename to published/20170829 How To Set Up PF Firewall on FreeBSD to Protect a Web Server.md From 8a4a6c64a18706a00c84dcedb6d1d3f1061c1b0f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 15 Sep 2018 23:11:14 +0800 Subject: [PATCH 246/455] PRF:20180828 15 command-line aliases to save you time.md @MZqk --- ...5 command-line aliases to save you time.md | 104 ++++++++++++------ 1 file changed, 69 insertions(+), 35 deletions(-) diff --git a/translated/talk/20180828 15 command-line aliases to save you time.md b/translated/talk/20180828 15 command-line aliases to save you time.md index 476b77799b..77d7f713b7 100644 --- a/translated/talk/20180828 15 command-line aliases to save you time.md +++ b/translated/talk/20180828 15 command-line aliases to save you time.md @@ -1,9 +1,10 @@ 15 个可以节省你时间的命令别名 ====== +> 在你安装的 Linux 发行版中默认就包含了一些别名。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_blue.png?itok=IfckxN48) -Linux 命令行别名非常适合帮助你提高工作效率。更好的是,有些 Linux 发行版中就默认包含一些别名。 +Linux 命令行别名非常适合帮助你提高工作效率。更好的是,在你安装的 Linux 发行版中默认就包含了一些别名。 这是 Fedora 27 中的命令别名的示例: @@ -11,74 +12,107 @@ Linux 命令行别名非常适合帮助你提高工作效率。更好的是, 这个 `alias` 命令列出了已有的别名。设置别名也十分简单: -`alias new_name="command"` +``` +alias new_name="command" +``` 这里有 15 个命令行别名,可以节省你的时间: -1. 安装任何应用实用 / 应用程序: +1、安装任何应用实用 / 应用程序: -`alias install="sudo yum install -y"` +``` +alias install="sudo yum install -y" +``` -在这里, `sudo` 和 `-y` 是可选的,因为每个用户的偏好: +在这里,根据每个用户的偏好,`sudo` 和 `-y` 是可选的: ![install alias.png][2] -2. 更新系统: +2、更新系统: -`alias update="sudo yum update -y"` +``` +alias update="sudo yum update -y" +``` -3. 升级系统: -`alias upgrade="sudo yum upgrade -y"` +3、升级系统: -4. 切换 root 用户: +``` +alias upgrade="sudo yum upgrade -y" +``` -`alias root="sudo su -"` +4、切换 root 用户: -5. 要更改"用户", 其中"user"设置为你的用户名: +``` +alias root="sudo su -" +``` -`alias user="su user"` +5、切换到 “user” 用户, 其中 `user` 设置为你的用户名: -6. 显示列出所有可用端口,状态还有 IP: +``` +alias user="su user" +``` -`alias myip="ip -br -c a"` +6、显示列出所有可用端口、状态还有 IP: -7. `ssh`你的服务器`myserver`: +``` +alias myip="ip -br -c a" +``` -`alias myserver="ssh user@my_server_ip”` +7、`ssh` 到你的服务器 `myserver`: -8. 列出系统中所有进程: +``` +alias myserver="ssh user@my_server_ip” +``` -`alias process="ps -aux"` +8、列出系统中所有进程: -9. 检查系统的服务状态: +``` +alias process="ps -aux" +``` -`alias sstatus="sudo systemctl status"` +9、检查系统的服务状态: -10. 重启系统服务在: +``` +alias sstatus="sudo systemctl status" +``` -`alias srestart="sudo systemctl restart"` +10、重启系统服务: -11. 按名称杀死进程: +``` +alias srestart="sudo systemctl restart" +``` -`alias kill="sudo pkill"` +11、按名称杀死进程: + +``` +alias kill="sudo pkill" +``` ![kill process alias.png][4] -12. 显示系统系统总使用内存和空闲内存 : +12、显示系统系统总使用内存和空闲内存 : -`alias mem="free -h"` +``` +alias mem="free -h" +``` -13. 显示系统 CPU 框架结构,CPU 数量,线程数等: +13、显示系统 CPU 框架结构、CPU 数量、线程数等: -`alias cpu="lscpu"` +``` +alias cpu="lscpu" +``` -14. 显示系统总磁盘大小: +14、显示系统总磁盘大小: -`alias disk="df -h"` +``` +alias disk="df -h" +``` -15. 显示当前系统 Linux 发行版本(适用于 CentOS,Fedora 和 Red Hat): +15、显示当前系统 Linux 发行版本(适用于 CentOS、Fedora 和 Red Hat): -`alias os="cat /etc/redhat-release"` +``` +alias os="cat /etc/redhat-release" +``` ![system_details alias.png][6] @@ -89,8 +123,8 @@ via: https://opensource.com/article/18/8/time-saving-command-line-aliases 作者:[Aarchit Modi][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[MZqk](https://github.com/) -校对:[校对者 ID](https://github.com/ 校对者 ID) +译者:[MZqk](https://github.com/MZqk) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出 From 36a9d5e802094a88b5bcf349bceda1bb9a280225 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 15 Sep 2018 23:11:51 +0800 Subject: [PATCH 247/455] PUB:20180828 15 command-line aliases to save you time.md @MZqk https://linux.cn/article-10017-1.html --- .../20180828 15 command-line aliases to save you time.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20180828 15 command-line aliases to save you time.md (100%) diff --git a/translated/talk/20180828 15 command-line aliases to save you time.md b/published/20180828 15 command-line aliases to save you time.md similarity index 100% rename from translated/talk/20180828 15 command-line aliases to save you time.md rename to published/20180828 15 command-line aliases to save you time.md From 5391292cbb9694938c5031d3b509a09d49461596 Mon Sep 17 00:00:00 2001 From: Kevin Sicong Jiang Date: Sat, 15 Sep 2018 14:54:37 -0500 Subject: [PATCH 248/455] Update 20180907 6 open source tools for writing a book.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit KevinSJ 翻译中 --- sources/tech/20180907 6 open source tools for writing a book.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180907 6 open source tools for writing a book.md b/sources/tech/20180907 6 open source tools for writing a book.md index 8b8140bd61..3a2328e7f1 100644 --- a/sources/tech/20180907 6 open source tools for writing a book.md +++ b/sources/tech/20180907 6 open source tools for writing a book.md @@ -1,3 +1,4 @@ +KevinSJ 翻译中 6 open source tools for writing a book ====== From 82ab38c1efccf2f4010420a018ba1b50228e48ea Mon Sep 17 00:00:00 2001 From: jrg Date: Sun, 16 Sep 2018 12:48:53 +0800 Subject: [PATCH 249/455] Update 20180804 Installing Android on VirtualBox.md --- sources/tech/20180804 Installing Android on VirtualBox.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180804 Installing Android on VirtualBox.md b/sources/tech/20180804 Installing Android on VirtualBox.md index 2ed0af3105..a57c5066a5 100644 --- a/sources/tech/20180804 Installing Android on VirtualBox.md +++ b/sources/tech/20180804 Installing Android on VirtualBox.md @@ -1,3 +1,5 @@ +Translating by jrglinux!!!!!! + Installing Android on VirtualBox ====== If you are developing mobile apps Android can be a bit of a hassle. While iOS comes with its niceties, provided you are using macOS, Android comes with just Android Studio which is designed to support more than a few Android version, including wearables. From d51fcfba0d385735410fa8550d771f9b80b68ab0 Mon Sep 17 00:00:00 2001 From: jrg Date: Sun, 16 Sep 2018 12:50:22 +0800 Subject: [PATCH 250/455] Update 20180804 Installing Android on VirtualBox.md --- sources/tech/20180804 Installing Android on VirtualBox.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20180804 Installing Android on VirtualBox.md b/sources/tech/20180804 Installing Android on VirtualBox.md index a57c5066a5..82b2444296 100644 --- a/sources/tech/20180804 Installing Android on VirtualBox.md +++ b/sources/tech/20180804 Installing Android on VirtualBox.md @@ -1,4 +1,4 @@ -Translating by jrglinux!!!!!! +[Translating by jrglinux!!!!!!] Installing Android on VirtualBox ====== From 939d80ffec63cb4bac12470c9a9991c847ca01a1 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 16 Sep 2018 13:02:43 +0800 Subject: [PATCH 251/455] PRF:20180710 How To View Detailed Information About A Package In Linux.md @DavidChenLiang --- ...ed Information About A Package In Linux.md | 393 +++++++++--------- 1 file changed, 196 insertions(+), 197 deletions(-) diff --git a/translated/tech/20180710 How To View Detailed Information About A Package In Linux.md b/translated/tech/20180710 How To View Detailed Information About A Package In Linux.md index 2ef1d008ac..8aa1121bae 100644 --- a/translated/tech/20180710 How To View Detailed Information About A Package In Linux.md +++ b/translated/tech/20180710 How To View Detailed Information About A Package In Linux.md @@ -1,161 +1,159 @@ -如何在Linux上检查一个包(package)的详细信息 +如何在 Linux 上检查一个软件包的详细信息 ====== +我们可以就这个已经被广泛讨论的话题写出大量的文章,大多数情况下,因为各种各样的原因,我们都愿意让包管理器package manager来帮我们做这些事情。 -我们可以就这个已经被广泛讨论的话题写出大量的文档,大多数情况下,因为各种各样的原因,我们都愿意让包管理器(package manager)来帮我们做这些事情。 - -每个Linux发行版都有自己的包管理器,并且每个都有各自有不同的特性,这些特性包括允许用户执行安装新软件包,删除无用的软件包,更新现存的软件包,搜索某些具体的软件包,以及更新整个系统到其最新的状态之类的操作。 - -习惯于命令行的用户大多数时间都会使用基于命令行方式的包管理器。对于Linux而言,这些基于命令行的包管理器有Yum,Dnf, Rpm, Apt, Apt-Get, Deb, pacman 和zypper. +每个 Linux 发行版都有自己的包管理器,并且每个都有各自有不同的特性,这些特性包括允许用户执行安装新软件包,删除无用的软件包,更新现存的软件包,搜索某些具体的软件包,以及更新整个系统到其最新的状态之类的操作。 +习惯于命令行的用户大多数时间都会使用基于命令行方式的包管理器。对于 Linux 而言,这些基于命令行的包管理器有 `yum`、`dnf`、`rpm`、`apt`、`apt-get`、`dpkg`、`pacman` 和 `zypper`。 **推荐阅读** -**(#)** [List of Command line Package Managers For Linux & Usage][1] -**(#)** [A Graphical frontend tool for Linux Package Manager][2] -**(#)** [How To Search If A Package Is Available On Your Linux Distribution Or Not][3] -**(#)** [How To Add, Enable And Disable A Repository By Using The DNF/YUM Config Manager Command On Linux][4] +- [Linux 命令行包管理器列表及其用法][1] +- [一个图形化的 Linux 包管理器前端工具][2] +- [如何搜索知道一个软件包是否存在于你的 Linux 发行版][3] +- [如何使用 dnf/yum 配置包管理器在 Linux 上来添加、启用和禁用软件仓库][4] -作为一个系统管理员你应该熟知以下事实:安装包来自何方,具体来自哪个软件仓库,包的具体版本,包的大小,发行版的版本,包的源URL,包的许可证信息,等等等等。 +作为一个系统管理员你应该清楚地知道:安装包来自何方,具体来自哪个软件仓库,包的具体版本,包的大小,版本,包的源代码 URL,包的许可证信息,等等。 +这篇短文将用尽可能简单的方式帮你从随包自带的总结和描述中了解该包的用法。按你所使用的 Linux 发行版的不同,运行下面相应的命令,你能得到你所使用的发行版下的包的详细信息。 -这篇短文将用尽可能简单的方式帮你理解包管理器的用法,这些用法正是来自随包自带的总结和描述文件。按你所使用的Linux发行版的不同,运行下面相应的命令,你能得到你所使用的发行版下的包的详细信息。 +### YUM 命令:在 RHEL 和 CentOS 系统上获得包的信息 -### [YUM 命令][5] : 在RHEL和CentOS系统上获得包的信息 +[YUM][5] 英文直译是“黄狗更新器--修改版Yellowdog Updater, Modified”,它是一个开源的基于命令行的包管理器前端实用工具。它被广泛应用在基于 RPM 的系统上,例如:RHEL 和 CentOS。 +Yum 是用于在官方发行版仓库以及其他第三方发行版仓库下获取、安装、删除、查询 RPM 包的主要工具。 -YUM 英文直译是黄狗更新器--修改版,它是一个开源的基于命令行的包管理器前端实用工具。它被广泛应用在基于RPM的系统上,例如:RHEL和CentOS。 - -Yum是用于在官方发行版仓库以及其他第三方发行版仓库下获取,安装,删除,查询RPM包的主要工具。 +(LCTT 译注:用 `yum info` 获取 python 包的信息) ``` -# yum info python(LCTT译注:用yum info 获取python包的信息) +# yum info python Loaded plugins: fastestmirror, security Loading mirror speeds from cached hostfile * epel: epel.mirror.constant.com Installed Packages -Name : python -Arch : x86_64 -Version : 2.6.6 -Release : 66.el6_8 -Size : 78 k -Repo : installed -From repo : updates -Summary : An interpreted, interactive, object-oriented programming language -URL : http://www.python.org/ -License : Python +Name : python +Arch : x86_64 +Version : 2.6.6 +Release : 66.el6_8 +Size : 78 k +Repo : installed +From repo : updates +Summary : An interpreted, interactive, object-oriented programming language +URL : http://www.python.org/ +License : Python Description : Python is an interpreted, interactive, object-oriented programming - : language often compared to Tcl, Perl, Scheme or Java. Python includes - : modules, classes, exceptions, very high level dynamic data types and - : dynamic typing. Python supports interfaces to many system calls and - : libraries, as well as to various windowing systems (X11, Motif, Tk, - : Mac and MFC). - : - : Programmers can write new built-in modules for Python in C or C++. - : Python can be used as an extension language for applications that need - : a programmable interface. - : - : Note that documentation for Python is provided in the python-docs - : package. - : - : This package provides the "python" executable; most of the actual - : implementation is within the "python-libs" package. + : language often compared to Tcl, Perl, Scheme or Java. Python includes + : modules, classes, exceptions, very high level dynamic data types and + : dynamic typing. Python supports interfaces to many system calls and + : libraries, as well as to various windowing systems (X11, Motif, Tk, + : Mac and MFC). + : + : Programmers can write new built-in modules for Python in C or C++. + : Python can be used as an extension language for applications that need + : a programmable interface. + : + : Note that documentation for Python is provided in the python-docs + : package. + : + : This package provides the "python" executable; most of the actual + : implementation is within the "python-libs" package. ``` -### YUMDB 命令: 查看RHEL和CentOS系统上的包信息 +### YUMDB 命令:查看 RHEL 和 CentOS 系统上的包信息 +`yumdb info` 这个命令提供与 `yum info` 相类似的的信息,不过它还额外提供了诸如包校验值、包类型、用户信息(由何人安装)。从 yum 3.2.26 版本后,`yum` 开始在 rpm 数据库外储存额外的信息了(此处如显示 `user` 表明该包由用户安装,而 `dep` 说明该包是被作为被依赖的包而被安装的)。 -Yumdb info这个命令提供与yum info相类似的的信息,不过它还额外提供了诸如包校验值,包类型,用户信息(由何人安装)。从yum 3.2.26版本后,yum开始在rpm数据库外储存额外的信息了(下文输出的用户信息指该python由该用户安装,而dep说明该包是被作为被依赖的包而被安装的)。 +(LCTT 译注:用 `yumdb info` 来获取 python 包的信息) ``` -# yumdb info python(LCTT译注:用yumdb info 来获取Python的信息) +# yumdb info python Loaded plugins: fastestmirror python-2.6.6-66.el6_8.x86_64 - changed_by = 4294967295 - checksum_data = 53c75a1756e5b4f6564c5229a37948c9b4561e0bf58076bd7dab7aff85a417f2 - checksum_type = sha256 - command_line = update -y - from_repo = updates - from_repo_revision = 1488370672 - from_repo_timestamp = 1488371100 - installed_by = 4294967295 - reason = dep - releasever = 6 - - + changed_by = 4294967295 + checksum_data = 53c75a1756e5b4f6564c5229a37948c9b4561e0bf58076bd7dab7aff85a417f2 + checksum_type = sha256 + command_line = update -y + from_repo = updates + from_repo_revision = 1488370672 + from_repo_timestamp = 1488371100 + installed_by = 4294967295 + reason = dep + releasever = 6 ``` -### [RPM 命令][6] : 在RHEL/CentOS/Fedora系统上查看包的信息 +### RPM 命令:在 RHEL/CentOS/Fedora 系统上查看包的信息 +[RPM][6] 英文直译为“红帽包管理器Red Hat Package Manager”,这是一个在 RedHat 以及其变种发行版(如RHEL、CentOS、Fedora、openSUSE、Megeia)下的功能强大的命令行包管理工具。它能让你轻松的安装、升级、删除、查询以及校验你的系统或服务器上的软件。RPM 文件以 `.rpm` 结尾。RPM 包由它所依赖的软件库以及其他依赖构成,它不会与系统上已经安装的包冲突。 -RPM 英文直译为红帽包管理器,这是一个在RedHat以及其变种发行版(如RHEL, CentOS, Fedora, openSUSE,Megeia)下的功能强大的命令行包管理工具。它能让你轻松的安装,升级,删除,查询以及校验你的系统或服务器上的软件。RPM文件以.rpm结尾。RPM包由它所依赖的软件库以及其他依赖构成,它不会与系统上已经安装的包冲突。 +(LCTT 译注:用 `rpm -qi` 查询 nano 包的具体信息) ``` -# rpm -qi nano (LCTT译注:用RPM -qi 查询nano包的具体信息) -Name : nano Relocations: (not relocatable) -Version : 2.0.9 Vendor: CentOS -Release : 7.el6 Build Date: Fri 12 Nov 2010 02:18:36 AM EST -Install Date: Fri 03 Mar 2017 08:57:47 AM EST Build Host: c5b2.bsys.dev.centos.org -Group : Applications/Editors Source RPM: nano-2.0.9-7.el6.src.rpm -Size : 1588347 License: GPLv3+ -Signature : RSA/8, Sun 03 Jul 2011 12:46:50 AM EDT, Key ID 0946fca2c105b9de -Packager : CentOS BuildSystem -URL : http://www.nano-editor.org -Summary : A small text editor +# rpm -qi nano +Name : nano Relocations: (not relocatable) +Version : 2.0.9 Vendor: CentOS +Release : 7.el6 Build Date: Fri 12 Nov 2010 02:18:36 AM EST +Install Date: Fri 03 Mar 2017 08:57:47 AM EST Build Host: c5b2.bsys.dev.centos.org +Group : Applications/Editors Source RPM: nano-2.0.9-7.el6.src.rpm +Size : 1588347 License: GPLv3+ +Signature : RSA/8, Sun 03 Jul 2011 12:46:50 AM EDT, Key ID 0946fca2c105b9de +Packager : CentOS BuildSystem +URL : http://www.nano-editor.org +Summary : A small text editor Description : GNU nano is a small and friendly text editor. - ``` -### [DNF 命令][7] : 在Fedora系统上查看报信息 +### DNF 命令:在 Fedora 系统上查看包信息 +[DNF][7] 指“时髦版的 YumDandified yum”,我们也可以认为 DNF 是下一代的 yum 包管理器(Yum 的一个分支),它在后台使用了 hawkey/libsolv 库。Aleš Kozumplík 在Fedora 18 上开始开发 DNF,在 Fedora 22 上正式最后发布。 `dnf` 命令用来在 Fedora 22 及以后的系统上安装、更新、搜索以及删除包。它能自动的解决包安装过程中的包依赖问题。 -DNF指时髦版的Yum,我们也可以认为DNF是下一代的YUM包管理器(Yum的一个分支),它在后台使用了hawkey/libsolv库。Aleš Kozumplík在Fedora 18上开始开发DNF,在Fedora 22上正式最后发布。 DNF命令用来在Fedora 22及以后系统安装, 更新,搜索以及删除包。它能自动的解决包安装过程中的包依赖问题。 +(LCTT 译注: 用 `dnf info` 查看 tilix 包信息) ``` -$ dnf info tilix (LCTT译注: 用dnf info 查看tilix的包信息) +$ dnf info tilix Last metadata expiration check: 27 days, 10:00:23 ago on Wed 04 Oct 2017 06:43:27 AM IST. Installed Packages -Name : tilix -Version : 1.6.4 -Release : 1.fc26 -Arch : x86_64 -Size : 3.6 M -Source : tilix-1.6.4-1.fc26.src.rpm -Repo : @System -From repo : @commandline -Summary : Tiling terminal emulator -URL : https://github.com/gnunn1/tilix -License : MPLv2.0 and GPLv3+ and CC-BY-SA -Description : Tilix is a tiling terminal emulator with the following features: - : - : - Layout terminals in any fashion by splitting them horizontally or vertically - : - Terminals can be re-arranged using drag and drop both within and between - : windows - : - Terminals can be detached into a new window via drag and drop - : - Input can be synchronized between terminals so commands typed in one - : terminal are replicated to the others - : - The grouping of terminals can be saved and loaded from disk - : - Terminals support custom titles - : - Color schemes are stored in files and custom color schemes can be created by - : simply creating a new file - : - Transparent background - : - Supports notifications when processes are completed out of view - : - : The application was written using GTK 3 and an effort was made to conform to - : GNOME Human Interface Guidelines (HIG). - +Name : tilix +Version : 1.6.4 +Release : 1.fc26 +Arch : x86_64 +Size : 3.6 M +Source : tilix-1.6.4-1.fc26.src.rpm +Repo : @System +From repo : @commandline +Summary : Tiling terminal emulator +URL : https://github.com/gnunn1/tilix +License : MPLv2.0 and GPLv3+ and CC-BY-SA +Description : Tilix is a tiling terminal emulator with the following features: + : + : - Layout terminals in any fashion by splitting them horizontally or vertically + : - Terminals can be re-arranged using drag and drop both within and between + : windows + : - Terminals can be detached into a new window via drag and drop + : - Input can be synchronized between terminals so commands typed in one + : terminal are replicated to the others + : - The grouping of terminals can be saved and loaded from disk + : - Terminals support custom titles + : - Color schemes are stored in files and custom color schemes can be created by + : simply creating a new file + : - Transparent background + : - Supports notifications when processes are completed out of view + : + : The application was written using GTK 3 and an effort was made to conform to + : GNOME Human Interface Guidelines (HIG). ``` -### [Zypper 命令][8] : 在openSUSE系统上查看包信息 +### Zypper 命令:在 openSUSE 系统上查看包信息 +[zypper][8] 是一个使用 libzypp 库的命令行包管理器。`zypper` 提供诸如软件仓库访问,安装依赖解决,软件包安装等等功能。 -Zypper是一个使用libzypp库的命令行包管理器。Zypper提供诸如软件仓库访问,安装依赖解决,软件包安装等等功能。 +(LCTT 译注: 用 `zypper info` 查询 nano 包的信息) ``` -$ zypper info nano (译注: 用zypper info查询nano的信息) +$ zypper info nano Loading repository data... Reading installed packages... @@ -163,73 +161,73 @@ Reading installed packages... Information for package nano: ----------------------------- -Repository : Main Repository (OSS) -Name : nano -Version : 2.4.2-5.3 -Arch : x86_64 -Vendor : openSUSE -Installed Size : 1017.8 KiB -Installed : No -Status : not installed -Source package : nano-2.4.2-5.3.src -Summary : Pico editor clone with enhancements -Description : - GNU nano is a small and friendly text editor. It aims to emulate - the Pico text editor while also offering a few enhancements. - +Repository : Main Repository (OSS) +Name : nano +Version : 2.4.2-5.3 +Arch : x86_64 +Vendor : openSUSE +Installed Size : 1017.8 KiB +Installed : No +Status : not installed +Source package : nano-2.4.2-5.3.src +Summary : Pico editor clone with enhancements +Description : + GNU nano is a small and friendly text editor. It aims to emulate + the Pico text editor while also offering a few enhancements. ``` -### [pacman 命令][9] :在ArchLinux及Manjaro系统上查看包信息 +### Pacman 命令:在 ArchLinux 及 Manjaro 系统上查看包信息 -Pacman指包管理器实用工具。pacman是一个用于安装,构建,删除,管理Arch Linux上包的命令行工具。它后端使用libalpm(Arch Linux package Manager(ALPM)库)来完成所有功能。 +[Pacman][9] 意即包管理器package manager实用工具。`pacman` 是一个用于安装、构建、删除、管理 Arch Linux 上包的命令行工具。它后端使用 libalpm(Arch Linux package Manager(ALPM)库)来完成所有功能。 + +(LCTT 译注: 用 `pacman -Qi` 来查询 bash 包信息) ``` -$ pacman -Qi bash (LCTT译注: 用pacman -Qi 来查询bash) -Name : bash -Version : 4.4.012-2 -Description : The GNU Bourne Again shell -Architecture : x86_64 -URL : http://www.gnu.org/software/bash/bash.html -Licenses : GPL -Groups : base -Provides : sh -Depends On : readline>=7.0 glibc ncurses -Optional Deps : bash-completion: for tab completion -Required By : autoconf automake bison bzip2 ca-certificates-utils db - dhcpcd diffutils e2fsprogs fakeroot figlet findutils - flex freetype2 gawk gdbm gettext gmp grub gzip icu - iptables keyutils libgpg-error libksba libpcap libpng - libtool lvm2 m4 man-db mkinitcpio nano neofetch nspr - nss openresolv os-prober pacman pcre pcre2 shadow - systemd texinfo vte-common which xdg-user-dirs xdg-utils - xfsprogs xorg-mkfontdir xorg-xpr xz -Optional For : None -Conflicts With : None -Replaces : None -Installed Size : 7.13 MiB -Packager : Jan Alexander Steffens (heftig) -Build Date : Tue 14 Feb 2017 01:16:51 PM UTC -Install Date : Thu 24 Aug 2017 06:08:12 AM UTC -Install Reason : Explicitly installed -Install Script : No -Validated By : Signature - +$ pacman -Qi bash +Name : bash +Version : 4.4.012-2 +Description : The GNU Bourne Again shell +Architecture : x86_64 +URL : http://www.gnu.org/software/bash/bash.html +Licenses : GPL +Groups : base +Provides : sh +Depends On : readline>=7.0 glibc ncurses +Optional Deps : bash-completion: for tab completion +Required By : autoconf automake bison bzip2 ca-certificates-utils db + dhcpcd diffutils e2fsprogs fakeroot figlet findutils + flex freetype2 gawk gdbm gettext gmp grub gzip icu + iptables keyutils libgpg-error libksba libpcap libpng + libtool lvm2 m4 man-db mkinitcpio nano neofetch nspr + nss openresolv os-prober pacman pcre pcre2 shadow + systemd texinfo vte-common which xdg-user-dirs xdg-utils + xfsprogs xorg-mkfontdir xorg-xpr xz +Optional For : None +Conflicts With : None +Replaces : None +Installed Size : 7.13 MiB +Packager : Jan Alexander Steffens (heftig) +Build Date : Tue 14 Feb 2017 01:16:51 PM UTC +Install Date : Thu 24 Aug 2017 06:08:12 AM UTC +Install Reason : Explicitly installed +Install Script : No +Validated By : Signature ``` -### [Apt-Cache 命令][10] :在Debian/Ubuntu/Mint系统上查看包信息 +### apt-cache 命令:在 Debian/Ubuntu/Mint 系统上查看包信息 +[apt-cache][10] 命令能显示 apt 内部数据库中的大量信息。这些信息是从 `sources.list` 中的不同的软件源中搜集而来,因此从某种意义上这些信息也可以被认为是某种缓存。这些信息搜集工作是在运行 `apt update` 命令时执行的。 -apt-cache命令能显示Apt内部数据库中的大量信息。这些信息是从sources.list中的不同的软件源中搜集而来,因此从某种意义上这些信息也可以被认为是某种缓存。 -这些信息搜集工作是在运行apt update命令时执行的。 +(LCTT 译注:用管理员权限查询 apache2 包的信息) ``` -$ sudo apt-cache show apache2 (LCTT译注:用管理员权限查询apache2的信息) +$ sudo apt-cache show apache2 Package: apache2 Priority: optional Section: web Installed-Size: 473 -Maintainer: Ubuntu Developers -Original-Maintainer: Debian Apache Maintainers +Maintainer: Ubuntu Developers +Original-Maintainer: Debian Apache Maintainers Architecture: amd64 Version: 2.4.12-2ubuntu2 Replaces: apache2.2-common @@ -257,23 +255,23 @@ Bugs: https://bugs.launchpad.net/ubuntu/+filebug Origin: Ubuntu Supported: 9m Task: lamp-server, mythbuntu-frontend, mythbuntu-desktop, mythbuntu-backend-slave, mythbuntu-backend-master, mythbuntu-backend-master - ``` -### [APT 命令][11] : 查看Debian/Ubuntu/Mint系统上的包信息 +### APT 命令:查看 Debian/Ubuntu/Mint 系统上的包信息 +[APT][11] 意为高级打包工具Advanced Packaging Tool,就像 DNF 将如何替代 YUM 一样,APT 是 apt-get 的替代物。它功能丰富的命令行工具包括了如下所有命令的功能如 `apt-cache`、`apt-search`、`dpkg`、`apt-cdrom`、`apt-config`、`apt-key` 等等,我们可以方便的通过 `apt` 来安装 `.dpkg` 包,但是我们却不能通过 `apt-get` 来完成这一点,还有一些其他的类似的功能也不能用 `apt-get` 来完成,所以 `apt-get` 因为没有解决上述功能缺乏的原因而被 `apt` 所取代。 -APT意为高级打包工具,就像DNF将如何替代YUM一样,APT是apt-get的替代物。它功能丰富的命令行工具包括了如下所有命令的功能如apt-cache,apt-search,dpkg, apt-cdrom, apt-config, apt-key等等,我们可以方便的通过apt来安装.dpkg包,但是我们却不能通过apt-get来完成这一点,还有一些其他的类似的功能也不能用apt-get来完成,所以apt-get因为没有解决上述功能缺乏的原因而被apt所取代。 +(LCTT 译注: 用 `apt show` 查看 nano 包信息) ``` -$ apt show nano (LCTT译注: 用apt show查看nano) +$ apt show nano Package: nano Version: 2.8.6-3 Priority: standard Section: editors Origin: Ubuntu -Maintainer: Ubuntu Developers -Original-Maintainer: Jordi Mallach +Maintainer: Ubuntu Developers +Original-Maintainer: Jordi Mallach Bugs: https://bugs.launchpad.net/ubuntu/+filebug Installed-Size: 766 kB Depends: libc6 (>= 2.14), libncursesw5 (>= 6), libtinfo5 (>= 6) @@ -293,34 +291,35 @@ Description: small, friendly text editor inspired by Pico (itself now available under the Apache License as Alpine). . However, GNU nano also implements many features missing in pico, including: - - undo/redo - - line numbering - - syntax coloring - - soft-wrapping of overlong lines - - selecting text by holding Shift - - interactive search and replace (with regular expression support) - - a go-to line (and column) command - - support for multiple file buffers - - auto-indentation - - tab completion of filenames and search terms - - toggling features while running - - and full internationalization support - + - undo/redo + - line numbering + - syntax coloring + - soft-wrapping of overlong lines + - selecting text by holding Shift + - interactive search and replace (with regular expression support) + - a go-to line (and column) command + - support for multiple file buffers + - auto-indentation + - tab completion of filenames and search terms + - toggling features while running + - and full internationalization support ``` -### [dpkg 命令][12] : 查看Debian/Ubuntu/Mint系统上的包信息 +### dpkg 命令:查看Debian/Ubuntu/Mint系统上的包信息 -dpkg意指Debian包管理器(dpkg)。dpkg用于Debian系统上的安装,构建,移除以及管理Debian包的命令行工具。dpkg 使用Aptitude(因为它更为主流及用户友好)作为前端工具来完成所有的功能。其他的工具如dpkg-deb和dpkg-query使用dpkg做为前端来实现功能。尽管系统管理员还是时不时会在必要时使用dpkg来完成一些软件安装的任务,他大多数情况下还是会因为APt,Apt-Get以及Aptitude的健壮性而使用后者。 +[dpkg][12] 意指 Debian 包管理器Debian package manager。`dpkg` 是用于 Debian 系统上安装、构建、移除以及管理 Debian 包的命令行工具。`dpkg` 使用 `aptitude`(因为它更为主流及用户友好)作为前端工具来完成所有的功能。其他的工具如` dpkg-deb` 和 `dpkg-query` 使用 `dpkg` 做为前端来实现功能。尽管系统管理员还是时不时会在必要时使用 `dpkg` 来完成一些软件安装的任务,他大多数情况下还是会因为 `apt`、`apt-get` 以及 `aptitude` 的健壮性而使用后者。 + +(LCTT 译注: 用 `dpkg -s` 查看 python 包的信息) ``` -$ dpkg -s python (LCTT译注: 用dpkg -s查看python) +$ dpkg -s python Package: python Status: install ok installed Priority: optional Section: python Installed-Size: 626 -Maintainer: Ubuntu Developers +Maintainer: Ubuntu Developers Architecture: amd64 Multi-Arch: allowed Source: python-defaults @@ -340,21 +339,21 @@ Description: interactive high-level object-oriented language (default version) This package is a dependency package, which depends on Debian's default Python version (currently v2.7). Homepage: http://www.python.org/ -Original-Maintainer: Matthias Klose - +Original-Maintainer: Matthias Klose ``` +我们也可使用 `dpkg` 的 `-p` 选项,这个选项提供和 `dpkg -s` 相类似的信息,但是它还提供了包的校验值和包类型。 -我们也可使用dpkg的‘-p’选项,这个选项提供和‘dpkg -s’相类似的信息,但是它还提供了包的校验值和包类型。 +(LCTT 译注: 用 `dpkg -p` 查看 python3 包的信息) ``` -$ dpkg -p python3 (LCTT译注: 用dpkg -p查看python3的信息) +$ dpkg -p python3 Package: python3 Priority: important Section: python Installed-Size: 67 Origin: Ubuntu -Maintainer: Ubuntu Developers +Maintainer: Ubuntu Developers Bugs: https://bugs.launchpad.net/ubuntu/+filebug Architecture: amd64 Multi-Arch: allowed @@ -369,41 +368,41 @@ Filename: pool/main/p/python3-defaults/python3_3.6.3-0ubuntu2_amd64.deb Size: 8712 MD5sum: a8bae494c6e5d1896287675faf40d373 Description: interactive high-level object-oriented language (default python3 version) -Original-Maintainer: Matthias Klose +Original-Maintainer: Matthias Klose SHA1: 2daec885cea7d4dc83c284301c3bebf42b23e095 SHA256: 865e509c91d2504a16c4b573dbe27e260c36fceec2add3fa43a30c1751d7e9bb Homepage: http://www.python.org/ Task: minimal, ubuntu-core, ubuntu-core Description-md5: 950ebd8122c0a7340f0a740c295b9eab Supported: 9m - ``` -### Aptitude 命令 : 查看Debian/Ubuntu/Mint 系统上的包信息 +### aptitude 命令:查看 Debian/Ubuntu/Mint 系统上的包信息 -aptitude是Debian GNU/Linux包管理系统的面向文本的接口。它允许用户查看已安装的包的列表,以及完成诸如安装,升级,删除包之类的包管理任务。这些管理行为也能从图形接口来执行。 +`aptitude` 是 Debian GNU/Linux 包管理系统的文本界面。它允许用户查看已安装的包的列表,以及完成诸如安装、升级、删除包之类的包管理任务。这些管理行为也能从图形接口来执行。 + +(LCTT 译注: 用 `aptitude show` 查看 htop 包信息) ``` -$ aptitude show htop (LCTT译注: 用aptitude show查看htop信息) -Package: htop +$ aptitude show htop +Package: htop Version: 2.0.2-1 State: installed Automatically installed: no Priority: optional Section: universe/utils -Maintainer: Ubuntu Developers +Maintainer: Ubuntu Developers Architecture: amd64 Uncompressed Size: 216 k Depends: libc6 (>= 2.15), libncursesw5 (>= 6), libtinfo5 (>= 6) Suggests: lsof, strace Conflicts: htop:i386 Description: interactive processes viewer - Htop is an ncursed-based process viewer similar to top, but it allows one to scroll the list vertically and horizontally to see all processes and their full command lines. - + Htop is an ncursed-based process viewer similar to top, but it allows one to scroll the list vertically and horizontally to see all processes and their full command lines. + Tasks related to processes (killing, renicing) can be done without entering their PIDs. Homepage: http://hisham.hm/htop/ - ``` -------------------------------------------------------------------------------- @@ -413,7 +412,7 @@ via: https://www.2daygeek.com/how-to-view-detailed-information-about-a-package-i 作者:[Prakash Subramanian][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[DavidChenLiang](https://github.com/davidchenliang) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8adfdeb9eafe73217bc672911cca68c484f08ce0 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 16 Sep 2018 13:03:26 +0800 Subject: [PATCH 252/455] PUB:20180710 How To View Detailed Information About A Package In Linux.md @DavidChenLiang https://linux.cn/article-10018-1.html --- ...0 How To View Detailed Information About A Package In Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180710 How To View Detailed Information About A Package In Linux.md (100%) diff --git a/translated/tech/20180710 How To View Detailed Information About A Package In Linux.md b/published/20180710 How To View Detailed Information About A Package In Linux.md similarity index 100% rename from translated/tech/20180710 How To View Detailed Information About A Package In Linux.md rename to published/20180710 How To View Detailed Information About A Package In Linux.md From e09cfc34a61bc6fe5720be6c1b06d3dc5ed8931f Mon Sep 17 00:00:00 2001 From: darksun Date: Sun, 16 Sep 2018 13:38:05 +0800 Subject: [PATCH 253/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Linux=20vs=20Mac:?= =?UTF-8?q?=207=20Reasons=20Why=20Linux=20is=20a=20Better=20Choice=20than?= =?UTF-8?q?=20Mac?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...s Why Linux is a Better Choice than Mac.md | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 sources/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md diff --git a/sources/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md b/sources/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md new file mode 100644 index 0000000000..ab2e0633b8 --- /dev/null +++ b/sources/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md @@ -0,0 +1,131 @@ +Linux vs Mac: 7 Reasons Why Linux is a Better Choice than Mac +====== +Recently, we highlighted a few points about [why Linux is better than Windows][1]. Unquestionably, Linux is a superior platform. But, like other operating systems it has its drawbacks as well. For a very particular set of tasks (such as Gaming), Windows OS might prove to be better. And, likewise, for another set of tasks (such as video editing), a Mac-powered system might come in handy. It all trickles down to your preference and what you would like to do with your system. So, in this article, we will highlight a number of reasons why Linux is better than Mac. + +If you’re already using a Mac or planning to get one, we recommend you to thoroughly analyze the reasons and decide whether you want to switch/keep using Linux or continue using Mac. + +### 7 Reasons Why Linux is Better Than Mac + +![Linux vs Mac: Why Linux is a Better Choice][2] + +Both Linux and macOS are Unix-like OS and give access to Unix commands, BASH and other shells. Both of them have fewer applications and games than Windows. But the similarity ends here. + +Graphic designers and video editors swear by macOS whereas Linux is a favorite of developers, sysadmins and devops. + +So the question is should you use Linux over Mac? If yes, why? Let me give you some practical and some ideological reasons why Linux is better than Mac. + +#### 1\. Price + +![Linux vs Mac: Why Linux is a Better Choice][3] + +Let’s suppose, you use the system only to browse stuff, watch movies, download photos, write a document, create a spreadsheet, and other similar stuff. And, in addition to those activities, you want to have a secure operating system. + +In that case, you could choose to spend a couple of hundred bucks for a system to get things done. Or do you think spending more for a MacBook is a good idea? Well, you are the judge. + +So, it really depends on what you prefer. Whether you want to spend on a Mac-powered system or get a budget laptop/PC and install any Linux distro for free. Personally, I’ll be happy with a Linux system except for editing videos and music production. In that case, Final Cut Pro (for video editing) and Logic Pro X (for music production) will be my preference. + +#### 2\. Hardware Choices + +![Linux vs Mac: Why Linux is a Better Choice][4] + +Linux is free. You can install it on computers with any configuration. No matter how powerful/old your system is, Linux will work. [Even if you have an 8-year old PC laying around, you can have Linux installed and expect it to run smoothly by selecting the right distro][5]. + +But, Mac is as an Apple-exclusive. If you want to assemble a PC or get a budget laptop (with DOS) and expect to install Mac OS, it’s almost impossible. Mac comes baked in with the system Apple manufactures. + +There are [ways to install macOS on non Apple devices][6]. However, the kind of expertise and troubles it requires, it makes you question whether it’s worth the effort. + +You will have a wide range of hardware choices when you go with Linux but a minimal set of configurations when it comes to Mac OS. + +#### 3\. Security + +![Linux vs Mac: Why Linux is a Better Choice][7] + +A lot of people are all praises for iOS and Mac for being a secure platform. Well, yes, it is secure in a way (maybe more secure than Windows OS), but probably not as secure as Linux. + +I am not bluffing. There are malware and adware targeting macOS and the [number is growing every day][8]. I have seen not-so-techie users struggling with their slow mac. A quick investigation revealed that a [browser hijacking malware][9] was the culprit. + +There are no 100% secure operating systems and Linux is not an exception. There are vulnerabilities in the Linux world as well but they are duly patched by the timely updates provided by Linux distributions. + +Thankfully, we don’t have auto-running viruses or browser hijacking malwares in Linux world so far. And that’s one more reason why you should use Linux instead of a Mac. + +#### 4\. Customization & Flexibility + +![Linux vs Mac: Why Linux is a Better Choice][10] + +You don’t like something? Customize it or remove it. End of the story. + +For example, if you do not like the [Gnome desktop environment][11] on Ubuntu 18.04.1, you might as well change it to [KDE Plasma][11]. You can also try some of the [Gnome extensions][12] to enhance your desktop experience. You won’t find this level of freedom and customization on Mac OS. + +Besides, you can even modify the source code of your OS to add/remove something (which requires necessary technical knowledge) and create your own custom OS. Can you do that on Mac OS? + +Moreover, you get an array of Linux distributions to choose from as per your needs. For instance, if you need to mimic the workflow on Mac OS, [Elementary OS][13] would help. Do you want to have a lightweight Linux distribution installed on your old PC? We’ve got you covered in our list of [lightweight Linux distros][5]. Mac OS lacks this kind of flexibility. + +#### 5\. Using Linux helps your professional career [For IT/Tech students] + +![Linux vs Mac: Why Linux is a Better Choice][14] + +This is kind of controversial and applicable to students and job seekers in the IT field. Using Linux doesn’t make you a super-intelligent being and could possibly get you any IT related job. + +However, as you start using Linux and exploring it, you gain experience. As a techie, sooner or later you dive into the terminal, learning your way to move around the file system, installing applications via command line. You won’t even realize that you have learned the skills that newcomers in IT companies get trained on. + +In addition to that, Linux has enormous scope in the job market. There are so many Linux related technologies (Cloud, Kubernetes, Sysadmin etc.) you can learn, earn certifications and get a nice paying job. And to learn these, you have to use Linux. + +#### 6\. Reliability + +![Linux vs Mac: Why Linux is a Better Choice][15] + +Ever wondered why Linux is the best OS to run on any server? Because it is more reliable! + +But, why is that? Why is Linux more reliable than Mac OS? + +The answer is simple – more control to the user while providing better security. Mac OS does not provide you with the full control of its platform. It does that to make things easier for you simultaneously enhancing your user experience. With Linux, you can do whatever you want – which may result in poor user experience (for some) – but it does make it more reliable. + +#### 7\. Open Source + +![Linux vs Mac: Why Linux is a Better Choice][16] + +Open Source is something not everyone cares about. But to me, the most important aspect of Linux being a superior choice is its Open Source nature. And, most of the points discussed below are the direct advantages of an Open Source software. + +To briefly explain, you get to see/modify the source code yourself if it is an open source software. But, for Mac, Apple gets an exclusive control. Even if you have the required technical knowledge, you will not be able to independently take a look at the source code of Mac OS. + +In other words, a Mac-powered system enables you to get a car for yourself but the downside is you cannot open up the hood to see what’s inside. That’s bad! + +If you want to dive in deeper to know about the benefits of an open source software, you should go through [Ben Balter’s article][17] on OpenSource.com. + +### Wrapping Up + +Now that you’ve known why Linux is better than Mac OS. What do you think about it? Are these reasons enough for you to choose Linux over Mac OS? If not, then what do you prefer and why? + +Let us know your thoughts in the comments below. + +Note: The artwork here is based on Club Penguins. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-vs-mac/ + +作者:[Ankush Das][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[1]: https://itsfoss.com/linux-better-than-windows/ +[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/Linux-vs-mac-featured.png +[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-1.jpeg +[4]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-4.jpeg +[5]: https://itsfoss.com/lightweight-linux-beginners/ +[6]: https://hackintosh.com/ +[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-2.jpeg +[8]: https://www.computerworld.com/article/3262225/apple-mac/warning-as-mac-malware-exploits-climb-270.html +[9]: https://www.imore.com/how-to-remove-browser-hijack +[10]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-3.jpeg +[11]: https://www.gnome.org/ +[12]: https://itsfoss.com/best-gnome-extensions/ +[13]: https://elementary.io/ +[14]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-5.jpeg +[15]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-6.jpeg +[16]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-7.jpeg +[17]: https://opensource.com/life/15/12/why-open-source From 44dd947ac245e593f1abd62ed3f92df03857bc8d Mon Sep 17 00:00:00 2001 From: darksun Date: Sun, 16 Sep 2018 13:43:03 +0800 Subject: [PATCH 254/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Convert=20files?= =?UTF-8?q?=20at=20the=20command=20line=20with=20Pandoc?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...t files at the command line with Pandoc.md | 394 ++++++++++++++++++ 1 file changed, 394 insertions(+) create mode 100644 sources/tech/20180914 Convert files at the command line with Pandoc.md diff --git a/sources/tech/20180914 Convert files at the command line with Pandoc.md b/sources/tech/20180914 Convert files at the command line with Pandoc.md new file mode 100644 index 0000000000..7b72da76a5 --- /dev/null +++ b/sources/tech/20180914 Convert files at the command line with Pandoc.md @@ -0,0 +1,394 @@ +Convert files at the command line with Pandoc +====== + +This guide shows you how to use Pandoc to convert your documents into many different file formats + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_paper_envelope_document.png?itok=uPj_kouJ) + +Pandoc is a command-line tool for converting files from one markup language to another. Markup languages use tags to annotate sections of a document. Commonly used markup languages include Markdown, ReStructuredText, HTML, LaTex, ePub, and Microsoft Word DOCX. + +In plain English, [Pandoc][1] allows you to convert a bunch of files from one markup language into another one. Typical examples include converting a Markdown file into a presentation, LaTeX, PDF, or even ePub. + +This article will explain how to produce documentation in multiple formats from a single markup language (in this case Markdown) using Pandoc. It will guide you through Pandoc installation, show how to create several types of documents, and offer tips on how to write documentation that is easy to port to other formats. It will also explain the value of using meta-information files to create a separation between the content and the meta-information (e.g., author name, template used, bibliographic style, etc.) of your documentation. + +### Installation and requirements + +Pandoc is installed by default in most Linux distributions. This tutorial uses pandoc-2.2.3.2 and pandoc-citeproc-0.14.3. If you don't intend to generate PDFs, those two packages are enough. However, I recommend installing texlive as well, so you have the option to generate PDFs. + +To install these programs on Linux, type the following on the command line: + +``` +sudo apt-get install pandoc pandoc-citeproc texlive +``` + +You can find [installation instructions][2] for other platforms on Pandoc's website. + +I highly recommend installing [pandoc][3][-crossref][3], a "filter for numbering figures, equations, tables, and cross-references to them." The easiest option is to download a [prebuilt executable][4], but you can install it from Haskell's package manager, cabal, by typing: + +``` +cabal update +cabal install pandoc-crossref +``` + +Consult pandoc-crossref's GitHub repository if you need additional Haskell [installation information][5]. + +### Some examples + +I'll demonstrate how Pandoc works by explaining how to produce three types of documents: + + * A website from a LaTeX file containing math formulas + * A Reveal.js slideshow from a Markdown file + * A contract agreement document that mixes Markdown and LaTeX + + + +#### Create a website with math formulas + +One of the ways Pandoc excels is displaying math formulas in different output file formats. For instance, let's generate a website from a LaTeX document (named math.tex) containing some math symbols (written in LaTeX). + +The math.tex document looks like: + +``` +% Pandoc math demos + +$a^2 + b^2 = c^2$ + +$v(t) = v_0 + \frac{1}{2}at^2$ + +$\gamma = \frac{1}{\sqrt{1 - v^2/c^2}}$ + +$\exists x \forall y (Rxy \equiv Ryx)$ + +$p \wedge q \models p$ + +$\Box\diamond p\equiv\diamond p$ + +$\int_{0}^{1} x dx = \left[ \frac{1}{2}x^2 \right]_{0}^{1} = \frac{1}{2}$ + +$e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty} (1+x/n)^n$ +``` + +Convert the LaTeX document into a website named mathMathML.html by entering the following command: + +``` +pandoc math.tex -s --mathml  -o mathMathML.html +``` + +The flag **-s** tells Pandoc to generate a standalone website (instead of a fragment, so it will include the head and body HTML tags), and the **–mathml** flag forces Pandoc to convert the math in LaTeX to MathML, which can be rendered by modern browsers. + +![](https://opensource.com/sites/default/files/uploads/pandoc_math-formulas.png) + +Take a look at the [website result][6] and the [code][7]; the code repository contains a Makefile to make things even simpler. + +#### Make a Reveal.js slideshow + +It's easy to generate simple presentations from a Markdown file using Pandoc. The slides contain top-level slides and nested slides underneath. The presentation can be controlled from the keyboard, and you can jump from one top-level slide to the next top-level slide or show the nested slides on a per-top-level basis. This structure is typical in HTML-based presentation frameworks. + +Let's create a slide document named SLIDES (see the [code repository][8]). First, add the slides' meta-information (e.g., title, author, and date) prepended by the **%** symbol: + +``` +% Case Study +% Kiko Fernandez Reyes +% Sept 27, 2017 +``` + +This meta-information also creates the first slide. To add more slides, declare top-level slides using Markdown heading H1 (line 5 in the example below, [heading 1 in Markdown][9] , designated by). + +For example, if we want to create a presentation with the title Case Study that starts with a top-level slide titled Wine Management System, write: + +``` +% Case Study +% Kiko Fernandez Reyes +% Sept 27, 2017 + +# Wine Management System +``` + +To put content (such as slides that explain a new management system and its implementation) inside this top-level section, use a Markdown header H2. Let's add two more slides (lines 7 and 14 below, [heading 2 in Markdown][9], designated by **##** ): + + * The first second-level slide has the title Idea and shows an image of the Swiss flag + * The second second-level slide has the title Implementation + + + +``` +% Case Study +% Kiko Fernandez Reyes +% Sept 27, 2017 + +# Wine Management System + +## Idea + +## Implementation +``` + +We now have a top-level slide ( **# Wine Management System** ) that contains two slides ( **## Idea** and **## Implementation** ). + +Let's put some content in these two slides using incremental bulleted lists by creating a Markdown list prepended by the symbol **>**. Continuing from above, add two items in the first slide (lines 9–10 below) and five items in the second slide (lines 16–20): + +``` +% Case Study +% Kiko Fernandez Reyes +% Sept 27, 2017 + +# Wine Management System + +## Idea + +>- Swiss love their **wine** and cheese +>- Create a *simple* wine tracker system + +![](img/matterhorn.jpg) + +## Implementation + +>- Bottles have a RFID tag +>- RFID reader (emits and read signal) +>- **Raspberry Pi** +>- **Server (online shop)** +>- Mobile app +``` + +We added an image of the Matterhorn mountain. Your slides can be improved by using plain Markdown or adding plain HTML. + +To generate the slides, Pandoc needs to point to the Reveal.js library, so it must be in the same folder as the SLIDES file. The command to generate the slides is: + +``` +pandoc -t revealjs -s --self-contained SLIDES \ +-V theme=white -V slideNumber=true -o index.html +``` + +![](https://opensource.com/sites/default/files/uploads/pandoc_matterhorn-slide.png) + +The above Pandoc command uses the following flags: + + * **-t revealjs** specifies we are going to output a **revealjs** presentation + * **-s** tells Pandoc to generate a standalone document + * **\--self-contained** produces HTML with no external dependencies + * **-V** sets the following variables: +– **theme=white** sets the theme of the slideshow to **white** +– **slideNumber=true** shows the slide number + * **-o index.html** generates the slides in the file named **index.html** + + + +To make things simpler and avoid typing this long command, create the following Makefile: + +``` +all: generate + +generate: +    pandoc -t revealjs -s --self-contained SLIDES \ +    -V theme=white -V slideNumber=true -o index.html + +clean: index.html +    rm index.html + +.PHONY: all clean generate +``` + +You can find all the code in [this repository][8]. + +#### Make a multi-format contract + +Let's say you are preparing a document and (as things are nowadays) some people want it in Microsoft Word format, others use free software and would like an ODT, and others need a PDF. You do not have to use OpenOffice nor LibreOffice to generate the DOCX or PDF file. You can create your document in Markdown (with some bits of LaTeX if you need advanced formatting) and generate any of these file types. + +As before, begin by declaring the document's meta-information (title, author, and date): + +``` +% Contract Agreement for Software X +% Kiko Fernandez-Reyes +% August 28th, 2018 +``` + +Then write the document in Markdown (and add LaTeX if you require advanced formatting). For example, create a table that needs fixed separation space (declared in LaTeX with **\hspace{3cm}** ) and a line where a client and a contractor should sign (declared in LaTeX with **\hrulefill** ). After that, add a table written in Markdown. + +Here's what the document will look like: + +![](https://opensource.com/sites/default/files/uploads/pandoc_agreement.png) + +The code to create this document is: + +``` +% Contract Agreement for Software X +% Kiko Fernandez-Reyes +% August 28th, 2018 + +... + +### Work Order + +\begin{table}[h] +\begin{tabular}{ccc} +The Contractor & \hspace{3cm} & The Customer \\ +& & \\ +& & \\ +\hrulefill & \hspace{3cm} & \hrulefill \\ +% +Name & \hspace{3cm} & Name \\ +& & \\ +& & \\ +\hrulefill & \hspace{3cm} & \hrulefill \\ +... +\end{tabular} +\end{table} + +\vspace{1cm} + ++--------------------------------------------|----------|-------------+ +| Type of Service                            | Cost     |     Total   | ++:===========================================+=========:+:===========:+ +| Game Engine                                | 70.0     | 70.0        | +|                                            |          |             | ++--------------------------------------------|----------|-------------+ +|                                            |          |             | ++--------------------------------------------|----------|-------------+ +| Extra: Comply with defined API functions   | 10.0     | 10.0        | +|        and expected returned format        |          |             | ++--------------------------------------------|----------|-------------+ +|                                            |          |             | ++--------------------------------------------|----------|-------------+ +| **Total Cost**                             |          | **80.0**    | ++--------------------------------------------|----------|-------------+ +``` + +To generate the three different output formats needed for this document, write a Makefile: + +``` +DOCS=contract-agreement.md + +all: $(DOCS) +    pandoc -s $(DOCS) -o $(DOCS:md=pdf) +    pandoc -s $(DOCS) -o $(DOCS:md=docx) +    pandoc -s $(DOCS) -o $(DOCS:md=odt) + +clean: +    rm *.pdf *.docx *.odt + +.PHONY: all clean +``` + +Lines 4–7 contain the commands to generate the different outputs. + +If you have several Markdown files and want to merge them into one document, issue a command with the files in the order you want them to appear. For example, when writing this article, I created three documents: an introduction document, three examples, and some advanced uses. The following tells Pandoc to merge these files together in the specified order and produce a PDF named document.pdf. + +``` +pandoc -s introduction.md examples.md advanced-uses.md -o document.pdf +``` + +### Templates and meta-information + +Writing a complex document is no easy task. You need to stick to a set of rules that are independent from your content, such as using a specific template, writing an abstract, embedding specific fonts, and maybe even declaring keywords. All of this has nothing to do with your content: simply put, it is meta-information. + +Pandoc uses templates to generate different output formats. There is a template for LaTeX, another for ePub, etc. These templates have unfulfilled variables that are set with the meta-information given to Pandoc. To find out what meta-information is available in a Pandoc template, type: + +``` +pandoc -D FORMAT +``` + +For example, the template for LaTeX would be: + +``` +pandoc -D latex +``` + +Which outputs something along these lines: + +``` +$if(title)$ +\title{$title$$if(thanks)$\thanks{$thanks$}$endif$} +$endif$ +$if(subtitle)$ +\providecommand{\subtitle}[1]{} +\subtitle{$subtitle$} +$endif$ +$if(author)$ +\author{$for(author)$$author$$sep$ \and $endfor$} +$endif$ +$if(institute)$ +\providecommand{\institute}[1]{} +\institute{$for(institute)$$institute$$sep$ \and $endfor$} +$endif$ +\date{$date$} +$if(beamer)$ +$if(titlegraphic)$ +\titlegraphic{\includegraphics{$titlegraphic$}} +$endif$ +$if(logo)$ +\logo{\includegraphics{$logo$}} +$endif$ +$endif$ + +\begin{document} +``` + +As you can see, there are **title** , **thanks** , **author** , **subtitle** , and **institute** template variables (and many others are available). These are easily set using YAML metablocks. In lines 1–5 of the example below, we declare a YAML metablock and set some of those variables (using the contract agreement example above): + +``` +--- +title: Contract Agreement for Software X +author: Kiko Fernandez-Reyes +date: August 28th, 2018 +--- + +(continue writing document as in the previous example) +``` + +This works like a charm and is equivalent to the previous code: + +``` +% Contract Agreement for Software X +% Kiko Fernandez-Reyes +% August 28th, 2018 +``` + +However, this ties the meta-information to the content; i.e., Pandoc will always use this information to output files in the new format. If you know you need to produce multiple file formats, you better be careful. For example, what if you need to produce the contract in ePub and in HTML, and the ePub and HTML need specific and different styling rules? + +Let's consider the cases: + + * If you simply try to embed the YAML variable **css: style-epub.css** , you would be excluding the one from the HTML version. This does not work. + * Duplicating the document is obviously not a good solution either, as changes in one version would not be in sync with the other copy. + * You can add variables to the Pandoc command line as follows: + + + +``` +pandoc -s -V css=style-epub.css document.md document.epub +pandoc -s -V css=style-html.css document.md document.html +``` + +My opinion is that it is easy to overlook these variables from the command line, especially when you need to set tens of these (which can happen in complex documents). Now, if you put them all together under the same roof (a meta.yaml file), you only need to update or create a new meta-information file to produce the desired output. You would then write: + +``` +pandoc -s meta-pub.yaml document.md document.epub +pandoc -s meta-html.yaml document.md document.html +``` + +This is a much cleaner version, and you can update all the meta-information from a single file without ever having to update the content of your document. + +### Wrapping up + +With these basic examples, I have shown how Pandoc can do a really good job at converting Markdown documents into other formats. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/intro-pandoc + +作者:[Kiko Fernandez-Reyes][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/kikofernandez +[1]: https://pandoc.org/ +[2]: http://pandoc.org/installing.html +[3]: https://hackage.haskell.org/package/pandoc-crossref +[4]: https://github.com/lierdakil/pandoc-crossref/releases/tag/v0.3.2.1 +[5]: https://github.com/lierdakil/pandoc-crossref#installation +[6]: http://pandoc.org/demo/mathMathML.html +[7]: https://github.com/kikofernandez/pandoc-examples/tree/master/math +[8]: https://github.com/kikofernandez/pandoc-examples/tree/master/slides +[9]: https://daringfireball.net/projects/markdown/syntax#header From 5785a5e4449df46cd6d6e82b03f0a3eb3e0f9d3e Mon Sep 17 00:00:00 2001 From: darksun Date: Sun, 16 Sep 2018 13:45:29 +0800 Subject: [PATCH 255/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20A=20day=20in=20th?= =?UTF-8?q?e=20life=20of=20a=20log=20message?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0914 A day in the life of a log message.md | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 sources/tech/20180914 A day in the life of a log message.md diff --git a/sources/tech/20180914 A day in the life of a log message.md b/sources/tech/20180914 A day in the life of a log message.md new file mode 100644 index 0000000000..8d60ec9fe6 --- /dev/null +++ b/sources/tech/20180914 A day in the life of a log message.md @@ -0,0 +1,57 @@ +A day in the life of a log message +====== + +Navigating a modern distributed system from the perspective of a log message. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/plane_travel_world_international.png?itok=jG3sYPty) + +Chaotic systems tend to be unpredictable. This is especially evident when architecting something as complex as a distributed system. Left unchecked, this unpredictability can waste boundless amounts of time. This is why every single component of a distributed system, no matter how small, must be designed to fit together in a streamlined way. + +[Kubernetes][1] provides a promising model for abstracting compute resources—but even it must be reconciled with other distributed platforms such as [Apache Kafka][2] to ensure reliable data delivery. If someone were to integrate these two platforms, how would it work? Furthermore, if you were to trace something as simple as a log message through such a system, what would it look like? This article will focus on how a log message from an application running inside [OKD][3], the Origin Community Distribution of Kubernetes that powers Red Hat OpenShift, gets to a data warehouse through Kafka. + +### OKD-defined environment + +Such a journey begins in OKD, since the container platform completely overlays the hardware it abstracts. This means that the log message waits to be written to **stdout** or **stderr** streams by an application residing in a container. From there, the log message is redirected onto the node's filesystem by a container engine such as [CRI-O][4]. + +![](https://opensource.com/sites/default/files/uploads/logmessagepathway.png) + +ithin OpenShift, one or more containers are encapsulated within virtual compute nodes known as pods. In fact, all applications running within OKD are abstracted as pods. This allows the applications to be manipulated in a uniform way. This also greatly simplifies communication between distributed components, since pods are systematically addressable through IP addresses and [load-balanced services][5] . So when the log message is taken from the node's filesystem by a log-collector application, it can easily be delivered to another pod running within OpenShift. + +### Two peas in a pod + +To ensure ubiquitous dispersal of the log message throughout the distributed system, the log collector needs to deliver the log message into a Kafka cluster data hub running within OpenShift. Through Kafka, the log message can be delivered to the consuming applications in a reliable and fault-tolerant way with low latency. However, in order to reap the benefits of Kafka within an OKD-defined environment, Kafka needs to be fully integrated into OKD. + +Running a [Strimzi operator][6] will instantiate all Kafka components as pods and integrate them to run within an OKD environment. This includes Kafka brokers for queuing log messages, Kafka connectors for reading and writing from Kafka brokers, and Zookeeper nodes for managing the Kafka cluster state. Strimzi can also instantiate the log collector to double as a Kafka connector, allowing the log collector to feed the log messages directly into a Kafka broker pod running within OKD. + +### Kafka inside OKD + +When the log-collector pod delivers the log message to a Kafka broker, the collector writes to a single broker partition, appending the message to the end of the partition. One of the advantages of using Kafka is that it decouples the log collector from the log's final destination. Thanks to the decoupling, the log collector doesn't care whether the logs end up in [Elasticsearch][7], Hadoop, Amazon S3, or all of them at the same time. Kafka is well-connected to all infrastructure, so the Kafka connectors can take the log message wherever it needs to go. + +Once written to a Kafka broker's partition, the log message is replicated across the broker partitions within the Kafka cluster. This is a very powerful concept on its own; combined with the self-healing features of the platform, it creates a very resilient distributed system. For example, when a node becomes unavailable, the applications running on the node are almost instantaneously spawned on healthy node(s). So even if a node with the Kafka broker is lost or damaged, the log message is guaranteed to survive as many deaths as it was replicated and a new Kafka broker will quickly take the original's place. + +### Off to storage + +After it is committed to a Kafka topic, the log message waits to be consumed by a Kafka connector sink, which relays the log message to either an analytics engine or logging warehouse. Upon delivery to its final destination, the log message could be studied for anomaly detection, queried for immediate root-cause analysis, or used for other purposes. Either way, the log message is delivered by Kafka to its destination in a safe and reliable manner. + +OKD and Kafka are powerful distributed platforms that are evolving rapidly. It is vital to create systems that can abstract the complicated nature of distributed computing without compromising performance. After all, how can we boast of systemwide efficiency if we cannot simplify the journey of a single log message? + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/life-log-message + +作者:[Josef Karásek][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jkarasek +[1]: https://kubernetes.io/ +[2]: https://kafka.apache.org/ +[3]: https://www.okd.io/ +[4]: http://cri-o.io/ +[5]: https://kubernetes.io/docs/concepts/services-networking/service/ +[6]: http://strimzi.io/ +[7]: https://www.elastic.co/ From ac5f9b8c18139b48fb0cc1789ef68a6f6c607f9c Mon Sep 17 00:00:00 2001 From: HankChow <280630620@qq.com> Date: Sun, 16 Sep 2018 14:15:29 +0800 Subject: [PATCH 256/455] HankChow translating --- ...901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md b/sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md index 465cdf02d2..6f91b77563 100644 --- a/sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md +++ b/sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md @@ -1,3 +1,5 @@ +HankChow translating + 5 Ways to Take Screenshot in Linux [GUI and Terminal] ====== Here are several ways you can take screenshots and edit the screenshots by adding text, arrows etc. Instructions and mentioned screenshot tools are valid for Ubuntu and other major Linux distributions. From d9ceda8abf34d41c2e2380b8bbe15324fa33884e Mon Sep 17 00:00:00 2001 From: jrg Date: Sun, 16 Sep 2018 18:21:32 +0800 Subject: [PATCH 257/455] Creat 20180804 Installing Andriod on VirtualBox [translated] 20180804 Installing Andriod on VirtualBox --- ...180804 Installing Andriod on VirtualBox.md | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 translated/tech/20180804 Installing Andriod on VirtualBox.md diff --git a/translated/tech/20180804 Installing Andriod on VirtualBox.md b/translated/tech/20180804 Installing Andriod on VirtualBox.md new file mode 100644 index 0000000000..e1cd153fd4 --- /dev/null +++ b/translated/tech/20180804 Installing Andriod on VirtualBox.md @@ -0,0 +1,160 @@ +在VirtualBox中安装Andriod系统 +====== + +如果你正在开发安卓 app 应用,也许会遇到小麻烦。诚然,ios 移动开发有 macOS 系统平台为其提供友好便利性,安卓开发仅有支持少部分安卓系统(其中还包括可穿戴设备系统)的 Andriod Studio 工具。 + +毋庸置疑,所有的二进制工具、SDK 工具、开发框架工具以及调试器都会产生大量日志和其他各种文件来使得你的文件系统很混乱。一个有效的解决方法就是在 VirtualBox 中安装 Andriod 系统,这样还解决了 Andriod 开发中最为棘手问题之一——设备模拟器。你可以在该虚拟机里测试应用程序,也可以使用 Andriod 的内部功能。因此,让我们迫不及待的开始吧! + +### 准备工作 + +首先,你需要在你的系统上安装 VirtualBox,可从]这里][1]下载 windows 版本、macOS 版本或者各种 Linux 版本的 VitualBox。然后,你需要一个能在 x86 平台运行的 Andriod 镜像,因为 VirtualBox 为虚拟机提供运行 x86 或者 x86_64(包括 AMD64)平台的功能。 + +虽然大部分 Andriod 设备都在 ARM 上运行,但我们依然可以在 x86 平台上获得 [Andriod 项目帮助][2]。这些优秀的开发者已经将 Andriod 移植到 x86 平台上运行(包括实体机和虚拟机),我们可以下载最新版本的 Andriod 7.1。你也可以用之前更为稳定的版本,本文写作时最新稳定版是 Andriod 6.0。 + +### 创建 VM 虚拟机 + +打开 VirtualBox,单击左上角的 ” 新建 ” 按钮,在弹出的窗口中选择 “ 类型:Linux ” ,然后根据下载的ISO镜像来确定版本,x86 对应 32-bit,x86_64 对应 64-bit,此处选择 Linux 2.6 / 3.x / 4.x (64-bit)。 + +RAM 大小设置 2 GB 到你系统能提供的最大内存之间。如果你想模拟真实的使用环境你可以设置 6 GB RAM和 32 GB ROM。 + +![][3] + +![][4] + +创建完成后,你还需要做一些设置,添加核心处理器,提高开机显示内存。在 VM 上打开设置选项,“ 设置 -> 系统 -> 处理器 ”,如果硬件条件允许,可以多分配一些处理器。 + +![][5] + +在 “ 设置 -> 显示 -> 显存大小 ” 中,你可以分配一大块内存并开启 3D 加速功能。 + +![][6] + +现在我们可以启动 VM 虚拟机了。 + +### 安装 Andriod + +首次启动 VM 虚拟机,VirtualBox 会提示你需要提供启动媒介,选择之前下载好的Andriod 镜像。 + +![][7] + +下一步,如果想长时间使用 Andriod,选择 Installation 选项,你也可以选择 Live 模式体验 Andriod 环境。 + +![][8] + +##### 分区 + +分区是通过文本界面操作,并没有友好的 GUI 界面,所以每个操作都需要小心对待。例如,在首页中还没有创建分区并且只检测到很少的虚拟硬盘时显示如下。 + +![][9] + +红色字母 C 和 D 提示 C 开头选项可以创建或者修改分区,D 开头选项可以检测设备。你可以选择 D 开头选项,然后它就会检测硬盘,也可不进行这步操作,因为在启动的时候它会自动检测。 + +我们选择 C 开头选项,在虚拟盘中创建分区。官方不推荐使用 GPT 格式,所以我们选择 No。 + +![][10] + +现在你被引导到 fdisk 工具页面。 + +![][11] + +为了简洁,我们就只创建一个较大的分区,使用方向键来选择 “ New ” ,然后选择“ Primary ”,确认。 + +![][12] + +分区大小系统已经为你计算好了,确认。 + +![][13] + +这个分区就是 Andriod 系统所在的分区,所以需要它是可启动的。选择 “ Bootable ”,然后 enter(上方表格中 Flags 标志下面会出现 boot 标志),进一步,选择 “ Write ” 选项,保存刚才的操作记录并写入分区表。 + +![][14] + +现在你可以选择退出分区工具,然后继续安装过程。 + +![][15] + +##### 文件系统格式化 + +在分区页面上会出现一个刚刚我们创建的分区,选择它并进入。 + +![][16] + +选择 Ext4 文件系统,在下一页中选择 Yes 然后格式化开始。会提示是否安装 GRUB 引导工具以及是否允许在根目录 / 进行读写,都选择 Yes 。现在,安装进程开始。 + +安装完成后,当系统提示可以 reboot 的时候你可以 reboot 系统。在重启之前,你可以先关机,然后在 VitualBox 的 ” 设置 -> 存储 ” 中检查 Andriod iso 镜像是否还依附在虚拟机上,如果在,将它移除。 + +移除安装镜像并保存,再去启动 VM 虚拟机。 + +![][17] + +##### 运行 Andriod + +在 GRUB 引导界面,有 debug 模式和 normal 模式的选项。我们选择默认选项,如下图所示。 + +![][18] + +如果一切正常,你将会看到如下界面: + +![][19] + +如今的 Andriod 系统使用触摸交互而不是鼠标。不过Andriod-x86 平台提供了鼠标操作支持,但开始时可能需要方向键来辅助操作。 + +![][20] + +选择 “ Set up as new ” 选项,回车确认。 + +![][21] + +在提示用谷歌账户登陆之前,系统检查更新并检测设备信息。你可以跳过这一步,直接去设置日期和时间、用户名等。 + +还有一些其他的选项,和让你选择创建一个新的 Andriod 设备类似。选择 “ I Agree ” 选项同意有关更新、服务等的 policy。 + +![][22] + +在这之后,因为它是个虚拟机,所以可能需要添加额外的 email 账户来设置 “ On-body detection ",大部分的选项对我们来说都没有多大作用,因此可以选择 ” All Set “。 + +接下来,它会提示你选择家庭 App。这个根据个人需求选择。 + +![][23] + +如果你需要在 VM 做一些交互测试,有个可触摸屏幕会提供很大的方便,因为那样才更接近真实使用环境。 + +希望这篇教程会给你带来帮助。如果还有类似的教程写作需求,欢迎联系我们。 + +-------------------------------------------------------------------------------- + +via: https://linuxhint.com/install_android_virtualbox/ + +作者:[Ranvir Singh][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[jrglinux](https://github.com/jrglinux) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://linuxhint.com/author/sranvir155/ +[1]:https://www.virtualbox.org/wiki/Downloads +[2]:http://www.android-x86.org/ +[3]:https://linuxhint.com/wp-content/uploads/2018/08/a.png +[4]:https://linuxhint.com/wp-content/uploads/2018/08/a1.png +[5]:https://linuxhint.com/wp-content/uploads/2018/08/a2.png +[6]:https://linuxhint.com/wp-content/uploads/2018/08/a3.png +[7]:https://linuxhint.com/wp-content/uploads/2018/08/a4.png +[8]:https://linuxhint.com/wp-content/uploads/2018/08/a5.png +[9]:https://linuxhint.com/wp-content/uploads/2018/08/a6.png +[10]:https://linuxhint.com/wp-content/uploads/2018/08/a7.png +[11]:https://linuxhint.com/wp-content/uploads/2018/08/a8.png +[12]:https://linuxhint.com/wp-content/uploads/2018/08/a9.png +[13]:https://linuxhint.com/wp-content/uploads/2018/08/a10.png +[14]:https://linuxhint.com/wp-content/uploads/2018/08/a11.png +[15]:https://linuxhint.com/wp-content/uploads/2018/08/a12.png +[16]:https://linuxhint.com/wp-content/uploads/2018/08/a13.png +[17]:https://linuxhint.com/wp-content/uploads/2018/08/a14.png +[18]:https://linuxhint.com/wp-content/uploads/2018/08/a16.png +[19]:https://linuxhint.com/wp-content/uploads/2018/08/a17.png +[20]:https://linuxhint.com/wp-content/uploads/2018/08/a18.png +[21]:https://linuxhint.com/wp-content/uploads/2018/08/a19.png +[22]:https://linuxhint.com/wp-content/uploads/2018/08/a20.png +[23]:https://linuxhint.com/wp-content/uploads/2018/08/a21.png + + From ce72140f295629c4d9b0069dd4ea298bc84edb21 Mon Sep 17 00:00:00 2001 From: jrg Date: Sun, 16 Sep 2018 18:22:14 +0800 Subject: [PATCH 258/455] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B6=85=E9=93=BE?= =?UTF-8?q?=E6=8E=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- translated/tech/20180804 Installing Andriod on VirtualBox.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20180804 Installing Andriod on VirtualBox.md b/translated/tech/20180804 Installing Andriod on VirtualBox.md index e1cd153fd4..7c70925a86 100644 --- a/translated/tech/20180804 Installing Andriod on VirtualBox.md +++ b/translated/tech/20180804 Installing Andriod on VirtualBox.md @@ -7,7 +7,7 @@ ### 准备工作 -首先,你需要在你的系统上安装 VirtualBox,可从]这里][1]下载 windows 版本、macOS 版本或者各种 Linux 版本的 VitualBox。然后,你需要一个能在 x86 平台运行的 Andriod 镜像,因为 VirtualBox 为虚拟机提供运行 x86 或者 x86_64(包括 AMD64)平台的功能。 +首先,你需要在你的系统上安装 VirtualBox,可从[这里][1]下载 windows 版本、macOS 版本或者各种 Linux 版本的 VitualBox。然后,你需要一个能在 x86 平台运行的 Andriod 镜像,因为 VirtualBox 为虚拟机提供运行 x86 或者 x86_64(包括 AMD64)平台的功能。 虽然大部分 Andriod 设备都在 ARM 上运行,但我们依然可以在 x86 平台上获得 [Andriod 项目帮助][2]。这些优秀的开发者已经将 Andriod 移植到 x86 平台上运行(包括实体机和虚拟机),我们可以下载最新版本的 Andriod 7.1。你也可以用之前更为稳定的版本,本文写作时最新稳定版是 Andriod 6.0。 From 3f7d2bf732af090e69df3e842593f8d61f3139d4 Mon Sep 17 00:00:00 2001 From: jrg Date: Sun, 16 Sep 2018 18:23:15 +0800 Subject: [PATCH 259/455] Delete 20180804 Installing Android on VirtualBox.md translated ok 20180804 Installing Andriod on VirtualBox,md --- ...180804 Installing Android on VirtualBox.md | 161 ------------------ 1 file changed, 161 deletions(-) delete mode 100644 sources/tech/20180804 Installing Android on VirtualBox.md diff --git a/sources/tech/20180804 Installing Android on VirtualBox.md b/sources/tech/20180804 Installing Android on VirtualBox.md deleted file mode 100644 index 82b2444296..0000000000 --- a/sources/tech/20180804 Installing Android on VirtualBox.md +++ /dev/null @@ -1,161 +0,0 @@ -[Translating by jrglinux!!!!!!] - -Installing Android on VirtualBox -====== -If you are developing mobile apps Android can be a bit of a hassle. While iOS comes with its niceties, provided you are using macOS, Android comes with just Android Studio which is designed to support more than a few Android version, including wearables. - -Needless to say, all the binaries, SDKs, frameworks and debuggers are going to pollute your filesystem with lots and lots of files, logs and other miscellaneous objects. An efficient work around for this is installing Android on your VirtualBox which takes away one of the sluggiest aspect of Android development — The device emulator. You can use this VM to run your test application or just fiddle with Android’s internals. So without further ado let’s set on up! - -### Getting Started - -To get started we will need to have VirtualBox installed on our system, you can get a copy for Windows, macOS or any major distro of Linux [here][1]. Next you would need a copy of Android meant to run on x86 hardware, because that’s what VirtualBox is going to offer to a Virtual Machine an x86 or an x86_64 (a.k.a AMD64) platform to run. - -While most Android devices run on ARM, we can take help of the project [Android on x86][2]. These fine folks have ported Android to run on x86 hardware (both real and virtual) and we can get a copy of the latest release candidate (Android 7.1) for our purposes. You may prefer using a more stable release but in that case Android 6.0 is about as latest as you can get, at the time of this writing. - -#### Creating VM - -Open VirtualBox and click on “New” (top-left corner) and in the Create Virtual Machine window select the type to be Linux and version Linux 2.6 / 3.x /4.x (64-bit) or (32-bit) depending upon whether the ISO you downloaded was x86_64 or x86 respectively. - -RAM size could be anywhere from 2 GB to as much as your system resources can allow. Although if you want to emulate real world devices you should allocate upto 6GB for memory and 32GB for disk size which are typical in Android devices. - -![][3] - -![][4] - -Upon creation, you might want to tweak a few additional settings, add in an additional processor core and improve display memory for starters. To do this, right-click on the VM and open up settings. In the Settings → System → Processor section you can allocate a few more cores if your desktop can pull it off. - -![][5] - -And in Settings → Display → Video Memory you can allocate a decent chunk of memory and enable 3D acceleration for a more responsive experience. - -![][6] - -Now we are ready to boot the VM. - -#### Installing Android - -Starting the VM for the first time, VirtualBox will insist you to supply it with a bootable media. Select the Android iso that you previously downloaded to boot the machine of with. - -![][7] - -Next, select the Installation option if you wish to install Android on the VM for a long term use, otherwise feel free to log into the live media and play around with the environment. - -![][8] - -Hit . - -##### Partitioning the Drive - -Partitioning is done using a textual interface, which means we don’t get the niceties of a GUI and we will have to use the follow careful at what is being shown on the screen. For example, in the first screen when no partition has been created and just a raw (virtual) disk is detected you will see the following. - -![][9] - -The red lettered C and D indicates that if you hit the key C you can create or modify partitions and D will detect additional devices. You can press D and the live media will detect the disks attached, but that is optional since it did a check during the boot. - -Let’s hit C and create partitions in the virtual disk. The offical page recommends against using GPT so we will not use that scheme. Select No using the arrow keys and hit . - -![][10] - -And now you will be ushered into the fdisk utility. - -![][11] - -We will create just a single giant partition so as to keep things simple. Using arrow keys navigate to the New option and hit . Select primary as the type of partition, and hit to confirm - -![][12] - -The maximum size will already be selected for you, hit to confirm that. - -![][13] - -This partition is where Android OS will reside, so of course we want it to be bootable. So select Bootable and hit enter (Boot will appear in the flags section in the table above) and then you can navigate to the Write section and hit to write the changes to the partitioning table. - -![][14] - -Then you can Quit the partitioning utility and move on with the installation. - -![][15] - -##### Formatting with Ext4 and installing Android - -A new partition will come in the Choose Partition menu where we were before we down the partitioning digression. Let’s select this partition and hit OK. - -![][16] - -Select ext4 as the de facto file system in the next menu. Confirm the changes in the next window by selecting **Yes** and the formatting will begin. When asked, say **Yes** to the GRUB boot loader installation. Similarly, say **Yes** to allowing read-write operations on the /system directory. Now the installation will begin. - -Once it is installed, you can safely reboot the system when prompted to reboot. You may have to power down the machine before the next reboot happens, go to Settings → Storage and remove the android iso if it is still attached to the VM. - -![][17] - -Remove the media and save the changes, before starting up the VM. - -##### Running Android - -In the GRUB menu you will get options for running the OS in debug mode or the normal way. Let’s take a tour of Android in a VM using the default option, as shown below: - -![][18] - -And if everything works fine, you will see this: - -![][19] - -Now Android uses touch screen as an interface instead of a mouse, as far as its normal use is concerned. While the x86 port does come with a mouse point-and-click support you may have to use arrow keys a lot in the beginning. - -![][20] - -Navigate to let’s go, and hit enter, if you are using arrow keys and then select Setup as New. - -![][21] - -It will check for updates and device info, before asking you to sign in using a Google account. You can skip this if you want and move on to setting up Data and Time and give your username to the device after that. - -A few other options would be presented, similar to the options you see when setting up a new Android device. Select appropriate options for privacy, updates, etc and of course Terms of Service, which we might have to Agree to. - -![][22] - -After this, it may ask you to add another email account or set up “On-body detection” since it is a VM, neither of the options are of much use to us and we can click on “All Set” - -It would ask you to select Home App after that, which is upto you to decide, as it is a matter of Preference and you will finally be in a virtualized Android system. - -![][23] - -You may benefit greatly from a touch screen laptop if you desire to do some intensive testing on this VM, since that would emulate a real world use case much closely. - -Hope you have found this tutorial useful in case, you have any other similar request for us to write about, please feel free to reach out to us. - --------------------------------------------------------------------------------- - -via: https://linuxhint.com/install_android_virtualbox/ - -作者:[Ranvir Singh][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://linuxhint.com/author/sranvir155/ -[1]:https://www.virtualbox.org/wiki/Downloads -[2]:http://www.android-x86.org/ -[3]:https://linuxhint.com/wp-content/uploads/2018/08/a.png -[4]:https://linuxhint.com/wp-content/uploads/2018/08/a1.png -[5]:https://linuxhint.com/wp-content/uploads/2018/08/a2.png -[6]:https://linuxhint.com/wp-content/uploads/2018/08/a3.png -[7]:https://linuxhint.com/wp-content/uploads/2018/08/a4.png -[8]:https://linuxhint.com/wp-content/uploads/2018/08/a5.png -[9]:https://linuxhint.com/wp-content/uploads/2018/08/a6.png -[10]:https://linuxhint.com/wp-content/uploads/2018/08/a7.png -[11]:https://linuxhint.com/wp-content/uploads/2018/08/a8.png -[12]:https://linuxhint.com/wp-content/uploads/2018/08/a9.png -[13]:https://linuxhint.com/wp-content/uploads/2018/08/a10.png -[14]:https://linuxhint.com/wp-content/uploads/2018/08/a11.png -[15]:https://linuxhint.com/wp-content/uploads/2018/08/a12.png -[16]:https://linuxhint.com/wp-content/uploads/2018/08/a13.png -[17]:https://linuxhint.com/wp-content/uploads/2018/08/a14.png -[18]:https://linuxhint.com/wp-content/uploads/2018/08/a16.png -[19]:https://linuxhint.com/wp-content/uploads/2018/08/a17.png -[20]:https://linuxhint.com/wp-content/uploads/2018/08/a18.png -[21]:https://linuxhint.com/wp-content/uploads/2018/08/a19.png -[22]:https://linuxhint.com/wp-content/uploads/2018/08/a20.png -[23]:https://linuxhint.com/wp-content/uploads/2018/08/a21.png From 12264686f15584468725b17cee293c096bedac95 Mon Sep 17 00:00:00 2001 From: LuMing <784315443@qq.com> Date: Sun, 16 Sep 2018 20:26:25 +0800 Subject: [PATCH 260/455] LuuMing translating --- ...709 How To Configure SSH Key-based Authentication In Linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md b/sources/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md index 06ca1b9178..8932e488e0 100644 --- a/sources/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md +++ b/sources/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md @@ -1,3 +1,4 @@ +LuMing translating How To Configure SSH Key-based Authentication In Linux ====== From 923cb41193883eeb675005c50db2186df4b1cab1 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 16 Sep 2018 22:07:35 +0800 Subject: [PATCH 261/455] PRF:20180316 How to Encrypt Files From Within a File Manager.md @Auk7f7 --- ...ncrypt Files From Within a File Manager.md | 125 ++++++------------ 1 file changed, 44 insertions(+), 81 deletions(-) diff --git a/translated/tech/20180316 How to Encrypt Files From Within a File Manager.md b/translated/tech/20180316 How to Encrypt Files From Within a File Manager.md index d74fc29022..c130f2e31d 100644 --- a/translated/tech/20180316 How to Encrypt Files From Within a File Manager.md +++ b/translated/tech/20180316 How to Encrypt Files From Within a File Manager.md @@ -1,162 +1,125 @@ -如何从文件管理器中加密文件 +如何从 Linux 的文件管理器中加密文件 ====== ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/encryption.jpg?itok=Pk3_x5hz) -Linux 桌面版和服务器版具有卓越的安全性。然而这并不意味着你可以放松警惕。你应该一直认为你的数据总是很快就会被破坏。也就是说,你可能需要使用各种加密工具。比如 GnuPG,它可以让你加密和解密文件等更多功能。GnuPG 的一个问题是一些用户不想扰乱命令行。如果是这样的话,你可以转向桌面文件管理器。许多 Linux 桌面版包含了简易的加密和解密文件的功能,如果这种功能没有内置,那么也是很容易添加的。 + +Linux 桌面版和服务器版具有卓越的安全性。然而这并不意味着你可以放松警惕。你应该一直认为你的数据总是很快就会被破坏。也就是说,你可能需要使用各种加密工具。比如 GnuPG,它可以让你加密和解密文件等更多功能。GnuPG 的一个问题是一些用户不想在命令行输入那么复杂的命令。如果是这样的话,你可以转向桌面文件管理器。许多 Linux 桌面版包含了简易的加密和解密文件的功能,如果这种功能没有内置,那么也是很容易添加的。 我将引导你完成从三个流行的 Linux 文件管理器中对文件进行加密和解密过程: - * Nautilus (aka GNOME Files) - + * Nautilus (即 GNOME Files) * Dolphin - * Thunar - - - ### 安装 GnuPG -在我们讨论如何处理这个问题之前,我们必须确保你的系统包含了必要的基本组件... [GnuPG][1]。大多数发行版本都包含 GnuPG。 在某些偶然情况下,你使用的是没有自带 GnuPG 的发行版本,以下是安装方法: +在我们讨论如何处理这个问题之前,我们必须确保你的系统包含了必要的基本组件 —— [GnuPG][1]。大多数发行版本都包含 GnuPG。 在某些偶然情况下,你使用的是没有自带 GnuPG 的发行版,以下是安装方法: - * 基于 Ubuntu 的发行版: sudo apt install gnupg - - * 基于 Fedora 的发行版: sudo yum install gnupg - - * openSUSE: sudo zypper in gnupg - - * 基于 Arch 的发行版:sudo pacman -S gnupg + * 基于 Ubuntu 的发行版: `sudo apt install gnupg` + * 基于 Fedora 的发行版: `sudo yum install gnupg` + * openSUSE: `sudo zypper in gnupg` + * 基于 Arch 的发行版:`sudo pacman -S gnupg` +无论你是刚刚安装了 GnuPG,还是默认安装的,你都必须创建一个 GPG 密钥才能使用。每个桌面版都使用不同的 GUI 工具完成这个工作(或者甚至根本没有包含一个完成这个任务的 GUI 工具),所以让我们从命令行中创建这个密钥。打开终端窗口并输入以下指令: - -无论你是刚刚安装了 GnuPG,还是默认安装的,你都必须创建一个 GPG 密钥才能使用。每个桌面版都使用了不同的 GUI 工具(或者甚至不包含一个 GUI 工具来完成这个任务),所以让我们从命令行中创建这个密钥。打开终端窗口并输入以下指令: ``` gpg --gen-key - ``` 然后,你将被要求回答以下问题。除非你有充分的理由,否则你可以接受默认值: * 你想要哪种密钥? + * 你想要多长的密钥? + * 密钥有效期? - * 你想要多大的密钥? - - * 密钥是否有效? - - - - -一旦你回答了这些问题,输入 y 来表示答案是正确的。接下来你需要提供以下信息: +一旦你回答了这些问题,输入 `y` 来表示答案是正确的。接下来你需要提供以下信息: * 真实姓名。 - * Email 地址。 + * 备注。 - * 评论。 - - - - -完成上述操作后,然后在提示的时候输入 o (为了 ok )。然后,你将被要求为新密钥输入一个密码。一旦系统收集到了足够的熵(你需要在桌面上做一些工作才能做到这一点),你的密钥就会被创建,然后你就可以开始工作了。 +完成上述操作后,然后在提示的时候输入 `O` (即 ok)。然后,你将被要求为新密钥输入一个密码。一旦系统收集到了足够的熵(你需要在桌面上做一些工作才能做到这一点,LCTT 译注:比如随便敲击键盘),你的密钥就会被创建,然后你就可以开始工作了。 让我们看看如何从文件管理器中加密/解密文件: ### Nautilus -让我们从默认的 GNOME 文件管理器开始,因为它是最简单的。Nautilus 不需要额外的安装或额外的工作就可以从精心设计的接口内加密/解密文件。一旦你创建完 gpg 密钥后,就可以打开文件管理器,导航到包含要加密的文件的目录,右键单击要加密的文件,然后从菜单中选择 Encrypt (图1)。 - +让我们从默认的 GNOME 文件管理器开始,因为它是最简单的。Nautilus 不需要额外安装什么或额外的工作就可以从精心设计的界面内加密/解密文件。一旦你创建完 gpg 密钥后,就可以打开文件管理器,导航到包含要加密的文件的目录,右键单击要加密的文件,然后从菜单中选择 “Encrypt” (图1)。 ![nautilus][3] -图1:从 Nautilus 中加密文件。 +*图1:从 Nautilus 中加密文件。* -[Used with permission][4] - -你将被要求选择一个收件人(或者收件人列表—图2)。注意:收件人将是那些你已经导入了公钥的用户。选择所需的密钥,然后从签名信息下拉列表中选择你的密钥(电子邮件地址)。 +你将被要求选择一个收件人(或者收件人列表 —— 图2)。注意:收件人将是那些你已经导入了公钥的用户。选择所需的密钥,然后从签名信息下拉列表中选择你的密钥(电子邮件地址)。 ![nautilus][6] -图2:选择收件人和签名者。 +*图2:选择收件人和签名者。* -[Used with permission][4] +注意:你还可以选择仅使用密码来加密文件。如果文件将保留在你的本地机器上,这一点非常重要(稍后将详细介绍)。一旦你设置好加密后,单击 “OK” 并(在提示时)输入 gpg 密钥的密码。文件将被加密(现在文件名以 .gpg 结尾)并保存在工作目录中。现在你可以将加密后的文件发送给在加密过程中已选择的收件人。 -注意:你还可以选择仅使用密码来加密文件。如果文件将保留在你的本地机器上,这一点非常重要(稍后将详细介绍)。一旦你设置好加密后,单击 OK 并(在提示时)输入 gpg 密钥的密码。文件将被加密(现在以 .gpg 结尾)并保存在工作目录中。现在你可以将加密后的文件发送给在加密过程中已选择的收件人。 - -说某人(谁拥有你的公钥)已经给你发送了一个加密文件。保存该文件,打开文件管理器,导航到该文件所在的目录,右击加密文件,选择 Open With Decrypt File,给文件一个新名称(不带 .gpg 的扩展名),然后单击“保存”。当提示时,输入你的 gpg 密钥的密码,该文件将被解密并准备使用。 +比如说(有你的公钥的)某人已经给你发送了一个加密文件。保存该文件,打开文件管理器,导航到该文件所在的目录,右击这个加密文件,选择 “Open With Decrypt File”,给文件一个新名称(不带 .gpg 的扩展名),然后单击“Save”。当提示时,输入你的 gpg 密钥的密码,该文件就会被解密并准备使用。 ### Dolphin -在KDE前端,必须安装一个软件包才能使用 Dolphin 文件管理器进行加密/解密。 登录到你的KDE桌面,打开终端窗口,然后输入以下命令(我正在使用 Neon 进行演示。如果你的发行版不是基于Ubuntu 的,则必须相应地更改命令): +在 KDE 前端,必须安装一个软件包才能使用 Dolphin 文件管理器进行加密/解密。 登录到你的 KDE 桌面,打开终端窗口,然后输入以下命令(我正在使用 Neon 进行演示。如果你的发行版不是基于 Ubuntu 的,则必须相应地更改命令): + ``` sudo apt install kgpg - ``` -安装完毕后,注销并重新登录KDE桌面。 你可以打开 Dolphin 并右键单击要加密的文件。 由于这是你第一次使用 kgpg,因此你必须完成快速设置向导(不言自明)。 当完成向导后,你可以返回该文件,右键单击它(图3),然后选择 Encrypt File。 - +安装完毕后,注销并重新登录 KDE 桌面。 你可以打开 Dolphin 并右键单击要加密的文件。 由于这是你第一次使用 kgpg,因此你必须完成快速设置向导(不言自明)。当完成该向导后,你可以返回该文件,右键单击它(图3),然后选择 Encrypt File。 ![Dolphin][8] -图3:在 Dolphin 中加密文件。 +*图3:在 Dolphin 中加密文件。* -[Used with permission][4] - -系统将提示你选择用于加密的密钥(图4)。 进行选择并单击 OK。 该文件将被加密,而且你已准备好将其发送给收件人。 +系统将提示你选择用于加密的密钥(图4)。 进行选择并单击 “OK”。 该文件将被加密,而且你已准备好将其发送给收件人。 注意:使用 KDE 的 Dolphin 文件管理器市,你无法仅使用密码加密。 - ![Dolphin][10] -图4:选择要加密的收件人。 +*图4:选择要加密的收件人。* -[Used with permission][4] - -如果你收到来自拥有公钥的用户的加密文件(或者你有自己加密的文件),请打开 Dolphin,导航到相关文件,双击该文件,为该文件指定一个新名称 ,键入加密密码并单击 OK。 你现在可以读取到新解密的文件。 如果你使用自己的密钥加密了该文件,则不会提示你键入密码(因为它已经被存储了)。 +如果你收到来自有你的公钥的用户的加密文件(或者你有一个自己加密的文件),请打开 Dolphin,导航到相关文件,双击该文件,为该文件指定一个新名称 ,键入加密密码并单击 “OK”。 你现在可以读取到新解密的文件。 如果你使用自己的密钥加密了该文件,则不会提示你键入密码(因为它已经被存储了)。 ### Thunar -Thunar文件管理器有点棘手。 没有任何额外的软件包可供安装; 相反,你需要为了加密创建新的自定义操作。完成此操作后,你将能够在文件管理器中执行此操作。 +Thunar 文件管理器有点棘手。 没有任何额外的软件包可供安装;相反,你需要为了加密创建新的自定义操作。完成此操作后,你将能够在文件管理器中执行此操作。 -要创建自定义操作,请打开 Thunar 文件管理器,然后单击 Edit > Configure Custom Actions。 在所得到的窗口中,单击 + 按钮(图5)并为加密操作输入以下内容: +要创建自定义操作,请打开 Thunar 文件管理器,然后单击 “Edit > Configure Custom Actions”。 在所得到的窗口中,单击 “+” 按钮(图5)并为加密操作输入以下内容: -名称:加密 - -描述:文件加密 - -命令:gnome-terminal -x gpg --encrypt --recipient%f - -单击 OK 以保存此操作。 +- 名称:加密 +- 描述:文件加密 +- 命令:`gnome-terminal -x gpg --encrypt --recipient %f` +单击 “OK” 以保存此操作。 ![Thunar][12] -图5:在Thunar中创建自定义操作。 - -[Used with permission][4] +*图5:在Thunar中创建自定义操作。* 注意:如果 gnome-terminal 不是你的默认终端,请替换该命令以打开你的默认终端。 -你还可以创建仅使用密码加密(不是密钥)的操作。 为此,该操作的详细动作将会是以下内容: +你还可以创建仅使用密码(而非密钥)加密的操作。 为此,该操作的详细动作将会是以下内容: -名称:加密密码 +- 名称:加密密码 +- 说明:仅使用密码加密 +- 命令:`gnome-terminal -x gpg -c %f` -说明:仅使用密码加密 - -命令:gnome-terminal -x gpg -c%f - -你不需要为解密过程创建一个自定义操作,因为 Thunar 已经知道如何处理一个加密文件。 要解密文件,只需右键单击它(在 Thunar 中),选择 Open With Decrypt File,为解密文件命名,然后(在提示时)键入加密密码。 Viola,你的加密文件已被解密并可以使用。 +你不需要为解密过程创建一个自定义操作,因为 Thunar 已经知道如何处理一个加密文件。 要解密文件,只需(在 Thunar 中)右键单击它,选择 “Open With Decrypt File”,为解密文件命名,然后(在提示时)键入加密密码。 Viola,你的加密文件已被解密并可以使用。 ### 一个警告 -请注意:如果你使用自己的密钥加密自己的文件,则无需输入加密密码来解密它们(因为你的公钥已存储)。 但是,如果你收到其他人(谁拥有你的公钥)的文件,则需要输入你的密码。 如果你想要存储自己的加密文件,而不是使用密钥来加密它们,请使用仅使用密码加密。 Nautilus 和Thunar(但不是KDE)可以做到这一点。 通过选择密码加密(通过密钥加密),当你解密文件时,它将始终提示你输入密码。 +请注意:如果你使用自己的密钥加密自己的文件,则无需输入加密密码来解密它们(因为你的公钥已存储)。 但是,如果你收到(拥有你的公钥的)其他人的文件,则需要输入你的密码。 如果你想要存储自己的加密文件,而不是使用密钥来加密它们,请使用仅使用密码加密。 Nautilus 和Thunar(但不是 KDE)可以做到这一点。 通过选择密码加密(通过密钥加密),当你解密文件时,它将始终提示你输入密码。 ### 其他文件管理器 -还有很多其他的文件管理器,他们中的一些可以使用加密,有些则不能。 你很有可能正在使用这三种工具中的一种,因此不仅可以将加密 / 解密添加到上下文菜单,而且是非常容易。 尝试一下,看看它是否会使加密和解密的过程变得更容易。 +还有很多其它的文件管理器,它们中的一些可以使用加密,有些则不能。 你很有可能正在使用这三种工具中的一种,因此不仅可以将加密 / 解密添加到上下文菜单,而且是非常容易。 尝试一下,看看它是否会使加密和解密的过程变得更容易。 -从 Linux 基金会和 edX 免费提供的["Linux 介绍" ][13]课程了解更多关于 Linux 的信息。 +从 Linux 基金会和 edX 免费提供的[“Linux 介绍”][13]课程了解更多关于 Linux 的信息。 -------------------------------------------------------------------------------- @@ -164,7 +127,7 @@ via: https://www.linux.com/learn/intro-to-linux/2018/3/how-encrypt-files-within- 作者:[JACK WALLEN][a] 译者:[Auk7f7](https://github.com/Auk7f7) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From b2072cb7758a774f624185abd2d6eff53a6eeec0 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 16 Sep 2018 22:08:07 +0800 Subject: [PATCH 262/455] PUB:20180316 How to Encrypt Files From Within a File Manager @Auk7f7 https://linux.cn/article-10019-1.html --- .../20180316 How to Encrypt Files From Within a File Manager.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180316 How to Encrypt Files From Within a File Manager.md (100%) diff --git a/translated/tech/20180316 How to Encrypt Files From Within a File Manager.md b/published/20180316 How to Encrypt Files From Within a File Manager.md similarity index 100% rename from translated/tech/20180316 How to Encrypt Files From Within a File Manager.md rename to published/20180316 How to Encrypt Files From Within a File Manager.md From d0c0dd2ec55644b3b68629443c6a2a890b9a1fe9 Mon Sep 17 00:00:00 2001 From: z52527 Date: Sun, 16 Sep 2018 22:52:54 +0800 Subject: [PATCH 263/455] Update 20180828 A Cat Clone With Syntax Highlighting And Git Integration.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【翻译中】20180828 A Cat Clone With Syntax Highlighting And Git Integration.md --- ...A Cat Clone With Syntax Highlighting And Git Integration.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20180828 A Cat Clone With Syntax Highlighting And Git Integration.md b/sources/tech/20180828 A Cat Clone With Syntax Highlighting And Git Integration.md index bddc4cac5b..d71bf7f93a 100644 --- a/sources/tech/20180828 A Cat Clone With Syntax Highlighting And Git Integration.md +++ b/sources/tech/20180828 A Cat Clone With Syntax Highlighting And Git Integration.md @@ -1,3 +1,6 @@ +Translating by z52527 + + A Cat Clone With Syntax Highlighting And Git Integration ====== From 0eae334bed982aace2d227a231e3644c41ca98e8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 16 Sep 2018 22:54:40 +0800 Subject: [PATCH 264/455] PRF:20180904 8 Linux commands for effective process management.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @heguangzhi 请提交译文时再校对一遍。 --- ...mmands for effective process management.md | 106 +++++++----------- 1 file changed, 39 insertions(+), 67 deletions(-) diff --git a/translated/tech/20180904 8 Linux commands for effective process management.md b/translated/tech/20180904 8 Linux commands for effective process management.md index cefd79adac..5f17d5832d 100644 --- a/translated/tech/20180904 8 Linux commands for effective process management.md +++ b/translated/tech/20180904 8 Linux commands for effective process management.md @@ -1,17 +1,15 @@ -heguangzhi Translating - -8个Linux命令用于有效的进程管理 +8 个用于有效地管理进程的 Linux 命令 ====== +> 通过这些关键的命令来全程管理你的应用。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg) -一般来说,应用程序的生命周期有三种主要状态:启动、运行和停止。如果我们想成为称职的管理员,每个状态都可以而且应该得到认真的管理。这八个命令可用于管理进程的整个生命周期。 - +一般来说,应用程序进程的生命周期有三种主要状态:启动、运行和停止。如果我们想成为称职的管理员,每个状态都可以而且应该得到认真的管理。这八个命令可用于管理进程的整个生命周期。 ### 启动进程 - -启动进程的最简单方法是在命令行中键入其名称,然后按 Enter 键。如果要启动 Nginx web 服务器,请键入 **nginx** 。也许您只是想看看其版本。 +启动进程的最简单方法是在命令行中键入其名称,然后按回车键。如果要启动 Nginx web 服务器,请键入 `nginx` 。也许您只是想看看其版本。 ``` alan@workstation:~$ nginx @@ -20,10 +18,9 @@ alan@workstation:~$ nginx -v nginx version: nginx/1.14.0 ``` +### 查看您的可执行路径 -### 查看您的可执行路径 - -以上启动进程的演示是假设可执行文件位于您的可执行路径中。理解这条路径是是否启动和管理进程的关键。管理员通常会为他们想要的目的定制这条路径。您可以使用 **echo $PATH** 查看您的可执行路径。 +以上启动进程的演示是假设可执行文件位于您的可执行路径中。理解这个路径是可靠地启动和管理进程的关键。管理员通常会为他们想要的目的定制这条路径。您可以使用 `echo $PATH` 查看您的可执行路径。 ``` alan@workstation:~$ echo $PATH @@ -32,35 +29,29 @@ alan@workstation:~$ echo $PATH #### WHICH - -使用 which 命令查看可执行文件的完整路径。 +使用 `which` 命令查看可执行文件的完整路径。 ``` -alan@workstation:~$ which nginx                                                     +alan@workstation:~$ which nginx /opt/nginx/bin/nginx ``` - -我将使用流行的 web 服务器软件 Nginx 作为我的例子。假设安装了 Nginx。如果执行 **which nginx** 的命令什么也不返回,那么 Nginx 就找不到了,因为它只搜索您指定的可执行路径。有三种方法可以补救一个进程不能简单地通过名字启动的情况。首先是键入完整路径。虽然,我不情愿输入全部路径,您会吗? - +我将使用流行的 web 服务器软件 Nginx 作为我的例子。假设安装了 Nginx。如果执行 `which nginx` 的命令什么也不返回,那么是找不到 Nginx 了,因为它只搜索您指定的可执行路径。有三种方法可以补救一个进程不能简单地通过名字启动的情况。首先是键入完整路径 —— 虽然,我不情愿输入全部路径,您会吗? ``` alan@workstation:~$ /home/alan/web/prod/nginx/sbin/nginx -v nginx version: nginx/1.14.0 ``` +第二个解决方案是将应用程序安装在可执行文件路径中的目录中。然而,这有时可能是办不到的,特别是如果您没有 root 权限。 -第二个解决方案是将应用程序安装在可执行文件路径中的目录中。然而,这可能是不可能的,特别是如果您没有 root 权限。 - - -第三个解决方案是更新您的可执行路径环境变量,包括要使用的特定应用程序的安装目录。这个解决方案是 shell-dependent。例如,Bash 用户需要在他们的 .bashrc 文件中编辑 PATH= line。 +第三个解决方案是更新您的可执行路径环境变量,包括要使用的特定应用程序的安装目录。这个解决方案是与 shell 相关的。例如,Bash 用户需要在他们的 `.bashrc` 文件中编辑 `PATH=` 行。 ``` PATH="$HOME/web/prod/nginx/sbin:$PATH" ``` - -现在,重复您的 echo 和 which命令或者尝试检查版本。容易多了! +现在,重复您的 `echo` 和 `which` 命令或者尝试检查版本。容易多了! ``` alan@workstation:~$ echo $PATH @@ -77,22 +68,21 @@ nginx version: nginx/1.14.0 #### NOHUP +注销或关闭终端时,进程可能不会继续运行。这种特殊情况可以通过在要使用 `nohup` 命令放在要运行的命令前面让进程持续运行。此外,附加一个`&` 符号将会把进程发送到后台,并允许您继续使用终端。例如,假设您想运行 `myprogram.sh` 。 -注销或关闭终端时,进程可能不会继续运行。这种特殊情况可以通过在要使用 nohup 命令放在要运行的命令前面让进程持续运行。此外,附加一个&符号将会把进程发送到后台,并允许您继续使用终端。例如,假设您想运行 myprogram.sh 。 ``` nohup myprogram.sh & ``` -nohup 会返回运行进程的PID。接下来我会更多地谈论PID。 +`nohup` 会返回运行进程的 PID。接下来我会更多地谈论 PID。 ### 管理正在运行的进程 - 每个进程都有一个唯一的进程标识号 (PID) 。这个数字是我们用来管理每个进程的。我们还可以使用进程名称,我将在下面演示。有几个命令可以检查正在运行的进程的状态。让我们快速看看这些命令。 #### PS -最常见的是 ps 命令。ps 的默认输出是当前终端中运行的进程的简单列表。如下所示,第一列包含PID。 +最常见的是 `ps` 命令。`ps` 的默认输出是当前终端中运行的进程的简单列表。如下所示,第一列包含 PID。 ``` alan@workstation:~$ ps @@ -101,8 +91,8 @@ PID TTY          TIME CMD 24148 pts/0    00:00:00 ps ``` +我想看看我之前启动的 Nginx 进程。为此,我告诉 `ps` 给我展示每一个正在运行的进程(`-e`)和完整的列表(`-f`)。 -我想看看我之前开始的 Nginx 进程。为此,我告诉 ps 给我展示每一个正在运行的进程( **-e** ) 和完整的列表 ( **-f** )。 ``` alan@workstation:~$ ps -ef UID        PID  PPID  C STIME TTY          TIME CMD @@ -128,20 +118,19 @@ alan     20536 20526  0 10:39 pts/0    00:00:00 pager alan     20564 20496  0 10:40 pts/1    00:00:00 bash ``` +您可以在上面 `ps` 命令的输出中看到 Nginx 进程。这个命令显示了将近 300 行,但是我在这个例子中缩短了它。可以想象,试图处理 300 行过程信息有点混乱。我们可以将这个输出输送到 `grep`,过滤一下仅显示 nginx。 -您可以在上面 ps 命令的输出中看到 Nginx 进程。这个命令显示了将近300行,但是我在这个例子中缩短了它。可以想象,试图处理300行过程信息有点混乱。我们可以将这个输出输送到 grep, 过滤一下仅显示 nginx。 ``` alan@workstation:~$ ps -ef |grep nginx alan     20520  1454  0 10:39 ?        00:00:00 nginx: master process nginx alan     20521 20520  0 10:39 ?        00:00:00 nginx: worker process ``` - -确实更好了。我们可以很快看到,Nginx 有20520和2052的PIDs。 +确实更好了。我们可以很快看到,Nginx 有 20520 和 20521 的 PID。 #### PGREP -pgrep 命令更加简化单独调用 grep 遇到的问题。 +`pgrep` 命令更加简化单独调用 `grep` 遇到的问题。 ``` alan@workstation:~$ pgrep nginx @@ -149,7 +138,7 @@ alan@workstation:~$ pgrep nginx 20521 ``` -假设您在一个托管环境中,多个用户正在运行几个不同的 Nginx 实例。您可以使用 **-u** 选项将其他人排除在输出之外。 +假设您在一个托管环境中,多个用户正在运行几个不同的 Nginx 实例。您可以使用 `-u` 选项将其他人排除在输出之外。 ``` alan@workstation:~$ pgrep -u alan nginx @@ -160,7 +149,8 @@ alan@workstation:~$ pgrep -u alan nginx #### PIDOF -另一个好用的是pidof。此命令将检查特定二进制文件的 PID,即使另一个同名进程正在运行。为了建立一个例子,我将我的 Nginx 复制到第二个目录,并以相应的前缀集开始。在现实生活中,这个实例可能位于不同的位置,例如由不同用户拥有的目录。如果我运行两个 Nginx 实例,则pidof 输出显示它们的所有进程。 +另一个好用的是 `pidof`。此命令将检查特定二进制文件的 PID,即使另一个同名进程正在运行。为了建立一个例子,我将我的 Nginx 复制到第二个目录,并以相应的路径前缀启动。在现实生活中,这个实例可能位于不同的位置,例如由不同用户拥有的目录。如果我运行两个 Nginx 实例,则`pidof` 输出显示它们的所有进程。 + ``` alan@workstation:~$ ps -ef |grep nginx alan     20881  1454  0 11:18 ?        00:00:00 nginx: master process ./nginx -p /home/alan/web/prod/nginxsec @@ -169,7 +159,7 @@ alan     20895  1454  0 11:19 ?        00:00:00 nginx: master process ng alan     20896 20895  0 11:19 ?        00:00:00 nginx: worker process ``` -使用 grep 或 pgrep 将显示 PID 数字,但我们可能无法辨别哪个实例是哪个。 +使用 `grep` 或 `pgrep` 将显示 PID 数字,但我们可能无法辨别哪个实例是哪个。 ``` alan@workstation:~$ pgrep nginx @@ -179,7 +169,7 @@ alan@workstation:~$ pgrep nginx 20896 ``` -pidof 命令可用于确定每个特定 Nginx 实例的PID。 +`pidof` 命令可用于确定每个特定 Nginx 实例的 PID。 ``` alan@workstation:~$ pidof /home/alan/web/prod/nginxsec/sbin/nginx @@ -191,7 +181,8 @@ alan@workstation:~$ pidof /home/alan/web/prod/nginx/sbin/nginx #### TOP -top 命令已经有很长时间了,对于查看运行进程的细节和快速识别内存消耗等问题是非常有用的。其默认视图如下所示。 +`top` 命令已经有很久的历史了,对于查看运行进程的细节和快速识别内存消耗等问题是非常有用的。其默认视图如下所示。 + ``` top - 11:56:28 up 1 day, 13:37,  1 user,  load average: 0.09, 0.04, 0.03 Tasks: 292 total,   3 running, 225 sleeping,   0 stopped,   0 zombie @@ -210,7 +201,8 @@ KiB Swap:        0 total,        0 free,        0 used. 14176540 ava     7 root      20   0       0      0      0 S   0.0  0.0   0:00.08 ksoftirqd/0 ``` -可以通过键入字母 **s** 和您喜欢的更新秒数来更改更新间隔。为了更容易监控我们的示例 Nginx 进程,我们可以使用 **-p** 选项调用top并通过PID。这个输出要干净得多。 +可以通过键入字母 `s` 和您喜欢的更新秒数来更改更新间隔。为了更容易监控我们的示例 Nginx 进程,我们可以使用 `-p` 选项并传递 PID 来调用 `top`。这个输出要干净得多。 + ``` alan@workstation:~$ top -p20881 -p20882 -p20895 -p20896 @@ -226,16 +218,13 @@ KiB Swap:        0 total,        0 free,        0 used. 14177928 ava 20896 alan      20   0   12460   1628    912 S   0.0  0.0   0:00.00 nginx ``` -在管理进程,特别是终止进程时,正确确定PID是非常重要。此外,如果以这种方式使用top,每当这些进程中的一个停止或一个新进程开始时,top都需要被告知有新的更新。 +在管理进程,特别是终止进程时,正确确定 PID 是非常重要。此外,如果以这种方式使用 `top`,每当这些进程中的一个停止或一个新进程开始时,`top` 都需要被告知有新的进程。 ### 终止进程 #### KILL -Interestingly, there is no stop command. In Linux, there is the kill command. Kill is used to send a signal to a process. The most commonly used signal is "terminate" (SIGTERM) or "kill" (SIGKILL). However, there are many more. Below are some examples. The full list can be shown with **kill -L**. - - -有趣的是,没有 stop 命令。在 Linux中,有 kill 命令。kill 用于向进程发送信号。最常用的信号是“终止”( SIGTERM )或“杀死”( SIGKILL )。然而,还有更多。下面是一些例子。完整的列表可以用 **kill -L** 显示。 +有趣的是,没有 `stop` 命令。在 Linux 中,有 `kill` 命令。`kill` 用于向进程发送信号。最常用的信号是“终止”(`SIGTERM`)或“杀死”(`SIGKILL`)。然而,还有更多。下面是一些例子。完整的列表可以用 `kill -L` 显示。 ```  1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP @@ -244,10 +233,7 @@ Interestingly, there is no stop command. In Linux, there is the kill command. Ki ``` -Notice signal number nine is SIGKILL. Usually, we issue a command such as **kill -9 20896**. The default signal is 15, which is SIGTERM. Keep in mind that many applications have their own method for stopping. Nginx uses a **-s** option for passing a signal such as "stop" or "reload." Generally, I prefer to use an application's specific method to stop an operation. However, I'll demonstrate the kill command to stop Nginx process 20896 and then confirm it is stopped with pgrep. The PID 20896 no longer appears. - -注意第九号信号是 SIGKILL。通常,我们会发布一个命令,比如 **kill -9 20896** 。默认信号是15,这是SIGTERM。请记住,许多应用程序都有自己的停止方法。Nginx 使用 **-s** 选项传递信号,如“停止”或“重新加载”。“通常,我更喜欢使用应用程序的特定方法来停止操作。然而,我将演示 kill 命令来停止 Nginx process 20896,然后用 pgrep 确认它已经停止。PID 20896 就不再出现。 - +注意第 9 号信号是 `SIGKILL`,通常,我们会发出比如 `kill -9 20896` 这样的命令。默认信号是 15,这是 `SIGTERM`。请记住,许多应用程序都有自己的停止方法。Nginx 使用 `-s` 选项传递信号,如 `stop` 或 `reload`。通常,我更喜欢使用应用程序的特定方法来停止操作。然而,我将演示用 `kill` 命令来停止 Nginx 进程 20896,然后用 `pgrep` 确认它已经停止。PID 20896 就不再出现。 ``` alan@workstation:~$ kill -9 20896 @@ -261,19 +247,14 @@ alan@workstation:~$ pgrep nginx #### PKILL -The command pkill is similar to pgrep in that it can search by name. This means you have to be very careful when using pkill. In my example with Nginx, I might not choose to use it if I only want to kill one Nginx instance. I can pass the Nginx option **-s** **stop** to a specific instance to kill it, or I need to use grep to filter on the full ps output. - -命令 pkill 类似于 pgrep,因为它可以按名称搜索。这意味着在使用 pkill 时必须非常小心。在我的 Nginx 示例中,如果我只想杀死一个 Nginx 实例,我可能不会选择使用它。我可以将 Nginx 选项 **-s** **stop** 传递给特定的实例来消除它,或者我需要使用grep来过滤整个 ps 输出。 +命令 `pkill` 类似于 `pgrep`,因为它可以按名称搜索。这意味着在使用 `pkill` 时必须非常小心。在我的 Nginx 示例中,如果我只想杀死一个 Nginx 实例,我可能不会选择使用它。我可以将 Nginx 选项 `-s stop` 传递给特定的实例来消除它,或者我需要使用 `grep` 来过滤整个 `ps` 输出。 ``` /home/alan/web/prod/nginx/sbin/nginx -s stop - /home/alan/web/prod/nginxsec/sbin/nginx -s stop ``` -If I want to use pkill, I can include the **-f** option to ask pkill to filter across the full command line argument. This of course also applies to pgrep. So, first I can check with **pgrep -a** before issuing the **pkill -f**. - -如果我想使用 pkill,我可以包括 **-f** 选项,让 pkill 过滤整个命令行参数。这当然也适用于 pgrep。所以,在执行 **pkill -f** 之前,首先我可以用 **pgrep -a** 确认一下。 +如果我想使用 `pkill`,我可以包括 `-f` 选项,让 `pkill` 过滤整个命令行参数。这当然也适用于 `pgrep`。所以,在执行 `pkill -f` 之前,首先我可以用 `pgrep -a` 确认一下。 ``` alan@workstation:~$ pgrep -a nginx @@ -283,10 +264,7 @@ alan@workstation:~$ pgrep -a nginx 20896 nginx: worker process ``` -I can also narrow down my result with **pgrep -f**. The same argument used with pkill stops the process. - -我也可以用 **pgrep -f** 缩小我的结果。pkill 使用的相同参数会停止该进程。 - +我也可以用 `pgrep -f` 缩小我的结果。`pkill` 使用相同参数会停止该进程。 ``` alan@workstation:~$ pgrep -f nginxsec @@ -295,15 +273,9 @@ alan@workstation:~$ pgrep -f nginxsec alan@workstation:~$ pkill -f nginxsec ``` -The key thing to remember with pgrep (and especially pkill) is that you must always be sure that your search result is accurate so you aren't unintentionally affecting the wrong processes. +`pgrep`(尤其是 `pkill`)要记住的关键点是,您必须始终确保搜索结果准确性,这样您就不会无意中影响到错误的进程。 -pgrep (尤其是pkill )要记住的关键点是,您必须始终确保搜索结果准确性,这样您就不会无意中影响到错误的进程。 - -Most of these commands have many command line options, so I always recommend reading the [man page][1] on each one. While most of these exist across platforms such as Linux, Solaris, and BSD, there are a few differences. Always test and be ready to correct as needed when working at the command line or writing scripts. - - - -大多数这些命令都有许多命令行选项,所以我总是建议阅读每一个命令的 [man page][1]。虽然大多数这些都存在于 Linux、Solaris 和 BSD 等平台上,但也有一些不同之处。在命令行工作或编写脚本时,始终测试并随时准备根据需要进行更正。 +大多数这些命令都有许多命令行选项,所以我总是建议阅读每一个命令的 [man 手册页][1]。虽然大多数这些命令都存在于 Linux、Solaris 和 BSD 等平台上,但也有一些不同之处。在命令行工作或编写脚本时,始终测试并随时准备根据需要进行更正。 -------------------------------------------------------------------------------- @@ -311,8 +283,8 @@ via: https://opensource.com/article/18/9/linux-commands-process-management 作者:[Alan Formy-Duval][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From fe51b00b8da37fb5e3b5748dc28f74d9a78ff0ab Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 16 Sep 2018 22:55:17 +0800 Subject: [PATCH 265/455] PUB:20180904 8 Linux commands for effective process management.md @heguangzhi https://linux.cn/article-10020-1.html --- .../20180904 8 Linux commands for effective process management.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180904 8 Linux commands for effective process management.md (100%) diff --git a/translated/tech/20180904 8 Linux commands for effective process management.md b/published/20180904 8 Linux commands for effective process management.md similarity index 100% rename from translated/tech/20180904 8 Linux commands for effective process management.md rename to published/20180904 8 Linux commands for effective process management.md From b0ec8a54eace58e6b9f23e169ffe32296c0fa791 Mon Sep 17 00:00:00 2001 From: Ryze-Borgia <42087725+Ryze-Borgia@users.noreply.github.com> Date: Sun, 16 Sep 2018 23:39:25 +0800 Subject: [PATCH 266/455] Update 20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md apply for translating this passage --- ...x vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md b/sources/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md index ab2e0633b8..42f842a803 100644 --- a/sources/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md +++ b/sources/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md @@ -1,3 +1,5 @@ +Translating by Ryze-Borgia + Linux vs Mac: 7 Reasons Why Linux is a Better Choice than Mac ====== Recently, we highlighted a few points about [why Linux is better than Windows][1]. Unquestionably, Linux is a superior platform. But, like other operating systems it has its drawbacks as well. For a very particular set of tasks (such as Gaming), Windows OS might prove to be better. And, likewise, for another set of tasks (such as video editing), a Mac-powered system might come in handy. It all trickles down to your preference and what you would like to do with your system. So, in this article, we will highlight a number of reasons why Linux is better than Mac. From a8af9e896f94bf5d7d7d8e73ff1716638fe3ef5d Mon Sep 17 00:00:00 2001 From: sd886393 Date: Mon, 17 Sep 2018 09:26:28 +0800 Subject: [PATCH 267/455] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E6=AE=B5=E7=9A=84=E7=BF=BB=E8=AF=91=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...180929 Getting started with the i3 window manager on Linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/translated/tech/20180929 Getting started with the i3 window manager on Linux.md b/translated/tech/20180929 Getting started with the i3 window manager on Linux.md index ade4e98fcc..9aa4e80b3c 100644 --- a/translated/tech/20180929 Getting started with the i3 window manager on Linux.md +++ b/translated/tech/20180929 Getting started with the i3 window manager on Linux.md @@ -1,6 +1,7 @@ [sd886393]翻译中 Getting started with the i3 window manager on Linux ====== +本篇文章会介绍如何在Fedora系统中,安装、配置、使用i3桌面管理器。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows-tiling-windows-wall.png?itok=mTH7uVrn) From a72d95ffed2d08b0f58bac4909d185db1051c304 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 17 Sep 2018 09:44:39 +0800 Subject: [PATCH 268/455] translated --- ...ntu 18.04 and other Linux Distributions.md | 70 ------------------- ...ntu 18.04 and other Linux Distributions.md | 68 ++++++++++++++++++ 2 files changed, 68 insertions(+), 70 deletions(-) delete mode 100644 sources/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md create mode 100644 translated/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md diff --git a/sources/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md b/sources/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md deleted file mode 100644 index 3dc6a33407..0000000000 --- a/sources/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md +++ /dev/null @@ -1,70 +0,0 @@ -translating---geekpi - -How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions -====== -Creating a slideshow of photos is a matter of a few clicks. Here’s how to make a slideshow of pictures in Ubuntu 18.04 and other Linux distributions. - -![How to create slideshow of photos in Ubuntu Linux][1] - -Imagine yourself in a situation where your friends and family are visiting you and request you to show the pictures of a recent event/trip. - -You have the photos saved on your computers, neatly in a separate folder. You invite everyone near the computer. You go to the folder, click on one of the pictures and start showing them the photos one by one by pressing the arrow keys. - -But that’s tiring! It will be a lot better if those images get changed automatically every few seconds. - -That’s called a slideshow and I am going to show you how to create a slideshow of photos in Ubuntu. This will allow you to loop pictures from a folder and display them in fullscreen mode. - -### Creating photo slideshow in Ubuntu 18.04 and other Linux distributions - -While you could use several image viewers for this purpose, I am going to show you two of the most popular tools that should be available in most distributions. - -#### Method 1: Photo slideshow with GNOME’s default image viewer - -If you are using GNOME in Ubuntu 18.04 or any other distribution, you are in luck. The default image viewer of Gnome, Eye of GNOME, is well capable of displaying the slideshow of pictures in the current folder. - -Just click on one of the pictures and you’ll see the settings option on the top right side of the application menu. It looks like three bars stacked over the top of one another. - -You’ll see several options here. Check the Slideshow box and it will go fullscreen displaying the images. - -![How to create slideshow of photos in Ubuntu Linux][2] - -By default, the images change at an interval of 5 seconds. You can change the slideshow interval by going to the Preferences->Slideshow. - -![change slideshow interval in Ubuntu][3]Changing slideshow interval - -#### Method 2: Photo slideshow with Shotwell Photo Manager - -[Shotwell][4] is a popular [photo management application for Linux][5]. and available for all major Linux distributions. - -If it is not installed already, search for Shotwell in your distribution’s software center and install it. - -Shotwell works slightly different. If you directly open a photo in Shotwell Viewer, you won’t see preferences or options for a slideshow. - -For slideshow and other options, you have to open Shotwell and import the folders containing those pictures. Once you have imported the folder in here, select that folder from left side-pane and then click on View in the menu. You should see the option of Slideshow here. Just click on it to create the slideshow of all the images in the selected folder. - -![How to create slideshow of photos in Ubuntu Linux][6] - -You can also change the slideshow settings. This option is presented when the images are displayed in the full view. Just hover the mouse to the lower bottom and you’ll see a settings option appearing. - -#### It’s easy to create photo slideshow - -As you can see, it’s really simple to create slideshow of photos in Linux. I hope you find this simple tip useful. If you have questions or suggestions, please let me know in the comment section below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/photo-slideshow-ubuntu/ - -作者:[Abhishek Prakash][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/abhishek/ -[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/Create-photos-Slideshow-Linux.png -[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/create-slideshow-photos-ubuntu-gnome.jpeg -[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/change-slideshow-interval-gnome-image.jpeg -[4]: https://wiki.gnome.org/Apps/Shotwell -[5]: https://itsfoss.com/linux-photo-management-software/ -[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/create-slideshow-photos-shotwell.jpeg diff --git a/translated/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md b/translated/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md new file mode 100644 index 0000000000..2109a450fa --- /dev/null +++ b/translated/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md @@ -0,0 +1,68 @@ +如何在 Ubuntu 18.04 和其他 Linux 发行版中创建照片幻灯片 +====== +创建照片幻灯片只需点击几下。以下是如何在 Ubuntu 18.04 和其他 Linux 发行版中制作照片幻灯片。 + +![How to create slideshow of photos in Ubuntu Linux][1] + +想象一下,你的朋友和亲戚正在拜访你,并请求你展示最近的活动/旅行照片。 + +你将照片保存在计算机上,并整齐地放在单独的文件夹中。你邀请计算机附近的所有人。你进入该文件夹​​,单击其中一张图片,然后按箭头键逐个显示照片。 + +但那太累了!如果这些图片每隔几秒自动更改一次,那将会好很多。 + +这称之为为幻灯片,我将向你展示如何在 Ubuntu 中创建照片幻灯片。这能让你在文件夹中循环播放图片并以全屏模式显示它们。 + +### 在 Ubuntu 18.04 和其他 Linux 发行版中创建照片幻灯片 + +虽然有几种图像浏览器可以做到,但我将向你展示大多数发行版中应该提供的两种最常用的工具。 + +#### 方法 1:使用 GNOME 默认图像浏览器浏览照片幻灯片 + +如果你在 Ubuntu 18.04 或任何其他发行版中使用 GNOME,那么你很幸运。Gnome 的默认图像浏览器,Eye of GNOME,能够在当前文件夹中显示图片的幻灯片。 + +只需单击其中一张图片,你将在程序的右上角菜单中看到设置选项。它看起来像三条横栏堆在彼此的顶部。 + +你会在这里看到几个选项。勾选幻灯片选项,它将全屏显示图像。 + +![How to create slideshow of photos in Ubuntu Linux][2] + +默认情况下,图像以 5 秒的间隔变化。你可以进入 Preferences->Slideshow 来更改幻灯片放映间隔。 + +![change slideshow interval in Ubuntu][3]Changing slideshow interval + +#### 方法 2:使用 Shotwell Photo Manager 进行照片幻灯片放映 + +[Shotwell][4] 是一种流行的[ Linux 照片管理程序][5]。适用于所有主要的 Linux 发行版。 + +如果尚未安装,请在你的发行版软件中心中搜索 Shotwell 并安装。 + +Shotwell 的运行略有不同。如果你在 Shotwell Viewer 中直接打开照片,则不会看到首选项或者幻灯片的选项。 + +对于幻灯片放映和其他选项,你必须打开 Shotwell 并导入包含这些图片的文件夹。导入文件夹后,从左侧窗格中选择该文件夹,然后单击菜单中的 “View”。你应该在此处看到幻灯片选项。只需单击它即可创建所选文件夹中所有图像的幻灯片。 + +![How to create slideshow of photos in Ubuntu Linux][6] + +你还可以更改幻灯片设置。当图像以全屏显示时,将显示此选项。只需将鼠标悬停在底部,你就会看到一个设置选项。 + +#### 创建照片幻灯片很容易 + +如你所见,在 Linux 中创建照片幻灯片非常简单。我希望你觉得这个简单的提示有用。如果你有任何问题或建议,请在下面的评论栏告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/photo-slideshow-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/Create-photos-Slideshow-Linux.png +[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/create-slideshow-photos-ubuntu-gnome.jpeg +[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/change-slideshow-interval-gnome-image.jpeg +[4]: https://wiki.gnome.org/Apps/Shotwell +[5]: https://itsfoss.com/linux-photo-management-software/ +[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/create-slideshow-photos-shotwell.jpeg From 1456f08a739e87e9452f12c1118d666103e25383 Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 17 Sep 2018 09:49:33 +0800 Subject: [PATCH 269/455] translating --- ...How To Configure Mouse Support For Linux Virtual Consoles.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md b/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md index c8b495cebe..3a4412e5c1 100644 --- a/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md +++ b/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md @@ -1,3 +1,5 @@ +translating---geekpi + How To Configure Mouse Support For Linux Virtual Consoles ====== From 67fa76bddde2b3b0c2664cf98fbedc168449235d Mon Sep 17 00:00:00 2001 From: belitex Date: Mon, 17 Sep 2018 10:54:09 +0800 Subject: [PATCH 270/455] =?UTF-8?q?=E7=94=B3=E9=A2=86=E7=BF=BB=E8=AF=91=20?= =?UTF-8?q?How=20to=20get=20into=20DevOps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/talk/20180117 How to get into DevOps.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/talk/20180117 How to get into DevOps.md b/sources/talk/20180117 How to get into DevOps.md index 09e50ae4f2..184b18b1d1 100644 --- a/sources/talk/20180117 How to get into DevOps.md +++ b/sources/talk/20180117 How to get into DevOps.md @@ -1,3 +1,4 @@ +belitex 翻译中 How to get into DevOps ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_resume_rh1x.png?itok=S3HGxi6E) From 38fce5ec189d7ec1c5e4a5b85b008c24c9f8164d Mon Sep 17 00:00:00 2001 From: sd886393 Date: Mon, 17 Sep 2018 15:07:21 +0800 Subject: [PATCH 271/455] =?UTF-8?q?=E4=B8=BA=E4=BE=BF=E4=BA=8E=E7=90=86?= =?UTF-8?q?=E8=A7=A3=EF=BC=8C=E5=B0=86=E6=8C=87=E5=AE=9A=E7=9A=84=E8=B6=85?= =?UTF-8?q?=E9=93=BE=E6=8E=A5=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...80929 Getting started with the i3 window manager on Linux.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20180929 Getting started with the i3 window manager on Linux.md b/translated/tech/20180929 Getting started with the i3 window manager on Linux.md index 6f23ea6606..8a14891ce6 100644 --- a/translated/tech/20180929 Getting started with the i3 window manager on Linux.md +++ b/translated/tech/20180929 Getting started with the i3 window manager on Linux.md @@ -4,7 +4,7 @@ ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows-tiling-windows-wall.png?itok=mTH7uVrn) -在我的文章[5 reasons the i3 window manager makes Linux better][1],我分享了选择 [i3 window manager][2] 作为一种Linux桌面替代方案的最主要五个理由。 +在我的文章[i3 桌面让Linux更好的5个理由][1],我分享了选择 [i3 桌面管理器][2] 作为一种Linux桌面替代方案的最主要五个理由。 在本篇文章中,我将向大家展示,如何在 Fedora 28 上安装与配置 i3。 ### 1\. 安装 From c141769e439b8c82f192506d265f8c8ee35c0123 Mon Sep 17 00:00:00 2001 From: "Y.C.S.M" Date: Mon, 17 Sep 2018 15:50:24 +0800 Subject: [PATCH 272/455] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=EF=BC=8C=E5=88=A0=E9=99=A4=E5=8E=9F=E6=96=87=20(#10234)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 翻译部分内容 * 继续翻译一小部分 * 翻译第四部分(未完成) * 完成翻译 * 优化翻译 * 完成翻译:5 tips to improve productivity with zsh * 从source中删除文章 * 删除原文,保留翻译结果 --- ...5 tips to improve productivity with zsh.md | 292 ---------------- ...5 tips to improve productivity with zsh.md | 313 ++++++++++++++++++ 2 files changed, 313 insertions(+), 292 deletions(-) delete mode 100644 sources/tech/20180905 5 tips to improve productivity with zsh.md create mode 100644 translated/tech/20180905 5 tips to improve productivity with zsh.md diff --git a/sources/tech/20180905 5 tips to improve productivity with zsh.md b/sources/tech/20180905 5 tips to improve productivity with zsh.md deleted file mode 100644 index 0de2e6a05c..0000000000 --- a/sources/tech/20180905 5 tips to improve productivity with zsh.md +++ /dev/null @@ -1,292 +0,0 @@ -5 tips to improve productivity with zsh -====== - -### **[翻译中] by tnuoccalanosrep** - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/features_solutions_command_data.png?itok=4_VQN3RK) - -The Z shell known as [zsh][1] is a [shell][2] for Linux/Unix-like operating systems. It has similarities to other shells in the `sh` (Bourne shell) family, such as as `bash` and `ksh`, but it provides many advanced features and powerful command line editing options, such as enhanced Tab completion. - -It would be impossible to cover all the options of zsh here; there are literally hundreds of pages [documenting][3] its many features. In this article, I'll present five tips to make you more productive using the command line with zsh. - -### 1\. Themes and plugins - -Through the years, the open source community has developed countless themes and plugins for zsh. A theme is a predefined prompt configuration, while a plugin is a set of useful aliases and functions that make it easier to use a specific command or programming language. - -The quickest way to get started using themes and plugins is to use a zsh configuration framework. There are many available, but the most popular is [Oh My Zsh][4]. By default, it enables some sensible zsh configuration options and it comes loaded with hundreds of themes and plugins. - -A theme makes you more productive as it adds useful information to your prompt, such as the status of your Git repository or Python virtualenv in use. Having this information at a glance saves you from typing the equivalent commands to obtain it, and it's a cool look. Here's an example of [Powerlevel9k][5], my theme of choice: - -![zsh Powerlevel9K theme][7] - -The Powerlevel9k theme for zsh - -In addition to themes, Oh My Zsh bundles tons of useful plugins for zsh. For example, enabling the Git plugin gives you access to a number of useful aliases, such as: -``` -$ alias | grep -i git | sort -R | head -10 -g=git -ga='git add' -gapa='git add --patch' -gap='git apply' -gdt='git diff-tree --no-commit-id --name-only -r' -gau='git add --update' -gstp='git stash pop' -gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' -gcs='git commit -S' -glg='git log --stat' -``` - -There are plugins available for many programming languages, packaging systems, and other tools you commonly use on the command line. Here's a list of plugins I use in my Fedora workstation: -``` -git golang fedora docker oc sudo vi-mode virtualenvwrapper -``` - -### 2\. Clever aliases - -Aliases are very useful in zsh. Defining aliases for your most-used commands saves you a lot of typing. Oh My Zsh configures several useful aliases by default, including aliases to navigate directories and replacements for common commands with additional options such as: -``` -ls='ls --color=tty' -grep='grep  --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}' -``` - -In addition to command aliases, zsh enables two additional useful alias types: the suffix alias and the global alias. - -A suffix alias allows you to open the file you type in the command line using the specified program based on the file extension. For example, to open YAML files using vim, define the following alias: -``` -alias -s {yml,yaml}=vim -``` - -Now if you type any file name ending with `yml` or `yaml` in the command line, zsh opens that file using vim: -``` -$ playbook.yml -# Opens file playbook.yml using vim -``` - -A global alias enables you to create an alias that is expanded anywhere in the command line, not just at the beginning. This is very useful to replace common filenames or piped commands. For example: -``` -alias -g G='| grep -i' -``` - -To use this alias, type `G` anywhere you would type the piped command: -``` -$ ls -l G do -drwxr-xr-x.  5 rgerardi rgerardi 4096 Aug  7 14:08 Documents -drwxr-xr-x.  6 rgerardi rgerardi 4096 Aug 24 14:51 Downloads -``` - -Next, let's see how zsh helps to navigate the filesystem. - -### 3\. Easy directory navigation - -When you're using the command line, navigating across different directories is one of the most common tasks. Zsh makes this easier by providing some useful directory navigation features. These features are enabled with Oh My Zsh, but you can enable them by using this command: -``` -setopt  autocd autopushd \ pushdignoredups -``` - -With these options set, you don't need to type `cd` to change directories. Just type the directory name, and zsh switches to it: -``` -$ pwd -/home/rgerardi -$ /tmp -$ pwd -/tmp -``` - -To move back, type `-`: - -Zsh keeps the history of directories you visited so you can quickly switch to any of them. To see the list, type `dirs -v`: -``` -$ dirs -v -0       ~ -1       /var/log -2       /var/opt -3       /usr/bin -4       /usr/local -5       /usr/lib -6       /tmp -7       ~/Projects/Opensource.com/zsh-5tips -8       ~/Projects -9       ~/Projects/ansible -10      ~/Documents -``` - -Switch to any directory in this list by typing `~#` where # is the number of the directory in the list. For example: -``` -$ pwd -/home/rgerardi -$ ~4 -$ pwd -/usr/local -``` - -Combine these with aliases to make it even easier to navigate: -``` -d='dirs -v | head -10' -1='cd -' -2='cd -2' -3='cd -3' -4='cd -4' -5='cd -5' -6='cd -6' -7='cd -7' -8='cd -8' -9='cd -9' -``` - -Now you can type `d` to see the first ten items in the list and the number to switch to it: -``` -$ d -0       /usr/local -1       ~ -2       /var/log -3       /var/opt -4       /usr/bin -5       /usr/lib -6       /tmp -7       ~/Projects/Opensource.com/zsh-5tips -8       ~/Projects -9       ~/Projects/ansible -$ pwd -/usr/local -$ 6 -/tmp -$ pwd -/tmp -``` - -Finally, zsh automatically expands directory names with Tab completion. Type the first letters of the directory names and `TAB` to use it: -``` -$ pwd -/home/rgerardi -$ p/o/z (TAB) -$ Projects/Opensource.com/zsh-5tips/ -``` - -This is just one of the features enabled by zsh's powerful Tab completion system. Let's look at some more. - -### 4\. Advanced Tab completion - -Zsh's powerful completion system is one of its hallmarks. For simplification, I call it Tab completion, but under the hood, more than one thing is happening. There's usually expansion and command completion. I'll discuss them together here. For details, check this [User's Guide][8]. - -Command completion is enabled by default with Oh My Zsh. To enable it, add the following lines to your `.zshrc` file: -``` -autoload -U compinit -compinit -``` - -Zsh's completion system is smart. It tries to suggest only items that can be used in certain contexts—for example, if you type `cd` and `TAB`, zsh suggests only directory names as it knows `cd` does not work with anything else. - -Conversely, it suggests usernames when running user-related commands or hostnames when using `ssh` or `ping`, for example. - -It has a vast completion library and understands many different commands. For example, if you're using the `tar` command, you can press Tab to see a list of files available in the package as candidates for extraction: -``` -$ tar -xzvf test1.tar.gz test1/file1 (TAB) -file1 file2 -``` - -Here's a more advanced example, using `git`. In this example, when typing `TAB`, zsh automatically completes the name of the only file in the repository that can be staged: -``` -$ ls -original  plan.txt  zsh-5tips.md  zsh_theme_small.png -$ git status -On branch master -Your branch is up to date with 'origin/master'. - -Changes not staged for commit: -  (use "git add ..." to update what will be committed) -  (use "git checkout -- ..." to discard changes in working directory) - -        modified:   zsh-5tips.md - -no changes added to commit (use "git add" and/or "git commit -a") -$ git add (TAB) -$ git add zsh-5tips.md -``` - -It also understands command line options and suggests only the ones that are relevant to the subcommand selected: -``` -$ git commit - (TAB) ---all                  -a       -- stage all modified and deleted paths ---allow-empty                   -- allow recording an empty commit ---allow-empty-message           -- allow recording a commit with an empty message ---amend                         -- amend the tip of the current branch ---author                        -- override the author name used in the commit ---branch                        -- show branch information ---cleanup                       -- specify how the commit message should be cleaned up ---date                          -- override the author date used in the commit ---dry-run                       -- only show the list of paths that are to be committed or not, and any untracked ---edit                 -e       -- edit the commit message before committing ---file                 -F       -- read commit message from given file ---gpg-sign             -S       -- GPG-sign the commit ---include              -i       -- update the given files and commit the whole index ---interactive                   -- interactively update paths in the index file ---message              -m       -- use the given message as the commit message -... TRUNCATED ... -``` - -After typing `TAB`, you can use the arrow keys to navigate the options list and select the one you need. Now you don't need to memorize all those Git options. - -There are many options available. The best way to find what is most helpful to you is by using it. - -### 5\. Command line editing and history - -Zsh's command line editing capabilities are also useful. By default, it emulates emacs. If, like me, you prefer vi/vim, enable vi bindings with the following command: -``` -$ bindkey -v -``` - -If you're using Oh My Zsh, the `vi-mode` plugin enables additional bindings and a mode indicator on your prompt—very useful. - -After enabling vi bindings, you can edit the command line using vi commands. For example, press `ESC+/` to search the command line history. While searching, pressing `n` brings the next matching line, and `N` the previous one. Most common vi commands work after pressing `ESC` such as `0` to jump to the start of the line, `$` to jump to the end, `i` to insert, `a` to append, etc. Even commands followed by motion work, such as `cw` to change a word. - -In addition to command line editing, zsh provides several useful command line history features if you want to fix or re-execute previous used commands. For example, if you made a mistake, typing `fc` brings the last command in your favorite editor to fix it. It respects the `$EDITOR` variable and by default uses vi. - -Another useful command is `r`, which re-executes the last command; and `r `, which executes the last command that contains the string `WORD`. - -Finally, typing double bangs (`!!`) brings back the last command anywhere in the line. This is useful, for instance, if you forgot to type `sudo` to execute commands that require elevated privileges: -``` -$ less /var/log/dnf.log -/var/log/dnf.log: Permission denied -$ sudo !! -$ sudo less /var/log/dnf.log -``` - -These features make it easier to find and re-use previously typed commands. - -### Where to go from here? - -These are just a few of the zsh features that can make you more productive; there are many more. For additional information, consult the following resources: - -[An Introduction to the Z Shell][9] - -[A User's Guide to ZSH][10] - -[Archlinux Wiki][11] - -[zsh-lovers][12] - -Do you have any zsh productivity tips to share? I would love to hear about them in the comments below. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/tips-productivity-zsh - -作者:[Ricardo Gerardi][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/rgerardi -[1]: http://www.zsh.org/ -[2]: https://en.wikipedia.org/wiki/Shell_(computing) -[3]: http://zsh.sourceforge.net/Doc/Release/zsh_toc.html -[4]: https://ohmyz.sh/ -[5]: https://github.com/bhilburn/powerlevel9k -[7]: https://opensource.com/sites/default/files/uploads/zsh_theme_small.png (zsh Powerlevel9K theme) -[8]: http://zsh.sourceforge.net/Guide/zshguide06.html#l144 -[9]: http://zsh.sourceforge.net/Intro/intro_toc.html -[10]: http://zsh.sourceforge.net/Guide/ -[11]: https://wiki.archlinux.org/index.php/zsh -[12]: https://grml.org/zsh/ diff --git a/translated/tech/20180905 5 tips to improve productivity with zsh.md b/translated/tech/20180905 5 tips to improve productivity with zsh.md new file mode 100644 index 0000000000..05c7e845ab --- /dev/null +++ b/translated/tech/20180905 5 tips to improve productivity with zsh.md @@ -0,0 +1,313 @@ +用 zsh 提高生产力的5个 tips +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/features_solutions_command_data.png?itok=4_VQN3RK) + +Z shell (亦称 zsh) 是 *unx 系统中的命令解析器 。 它跟 `sh` (Bourne shell) 家族的其他解析器 ( 如 `bash` 和 `ksh` ) 有着相似的特点,但它还提供了大量的高级特性以及强大的命令行编辑功能(选项?),如增强版tab补全。 + +由于 zsh 有好几百页的文档去描述他的特性,所以我无法在这里阐明 zsh 的所有功能。在本文,我会列出5个 tips,让你通过使用 zsh 来提高你的生产力。 + +### 1\. 主题和插件 + +多年来,开源社区已经为 zsh 开发了数不清的主题和插件。主题是预定义提示符的配置,而插件则是一组常用的别名命令和功能,让你更方便的使用一种特定的命令或者编程语言。 + +如果你现在想开始用 zsh 的主题和插件,那么使用 zsh 的配置框架 (configuiration framework) 是你最快的入门方式。在众多的配置框架中,最受欢迎的则是 [Oh My Zsh][4]。在默认配置中,他就已经为 zsh 启用了一些合理的配置,同时它也自带多个主题和插件。 + +由于主题会在你的命令行提示符之前添加一些常用的信息,比如你 Git 仓库的状态,或者是当前使用的 Python 虚拟环境,所以它会让你的工作更高效。只需要看到这些信息,你就不用再敲命令去重新获取它们,而且这些提示也相当酷炫。 +下图就是我(作者)选用的主题 [Powerlevel9k][5] + +![zsh Powerlevel9K theme][7] + +zsh 主题 Powerlevel9k + +除了主题,Oh my Zsh 还自带了大量常用的 zsh 插件。比如,通过启用 Git 插件,你可以用一组简便的命令别名操作 Git, 比如 + +``` +$ alias | grep -i git | sort -R | head -10 +g=git +ga='git add' +gapa='git add --patch' +gap='git apply' +gdt='git diff-tree --no-commit-id --name-only -r' +gau='git add --update' +gstp='git stash pop' +gbda='git branch --no-color --merged | command grep -vE "^(\*|\s*(master|develop|dev)\s*$)" | command xargs -n 1 git branch -d' +gcs='git commit -S' +glg='git log --stat' +``` + +zsh 还有许多插件是用于多种编程语言,打包系统和一些平时在命令行中常用的工具。 +以下是我(作者) Ferdora 工作站中用到的插件表: + +``` +git golang fedora docker oc sudo vi-mode virtualenvwrapper +``` + +### 2\. 智能的命令别名 + +命令别名在 zsh 中十分常用。为你常用的命令定义别名可以节省你的打字时间。Oh My Zsh 默认配置了一些常用的命令别名,包括目录导航命令别名,为常用的命令添加额外的选项,比如: + +``` +ls='ls --color=tty' +grep='grep  --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}' +``` + + +除了命令别名意外, zsh 还自带两种额外常用的别名类型:后缀别名和全局别名。 + +后缀别名可以让你在基于文件后缀的前提下,在命令行中利用指定程序打开这个文件。比如,要用 vim 打开 YAML 文件,可以定义以下命令行别名: + +``` +alias -s {yml,yaml}=vim +``` + +现在,如果你在命令行中输入任何后缀名为 `yml` 或 `yaml` 文件, zsh 都会用 vim 打开这个文件 + +``` +$ playbook.yml +# Opens file playbook.yml using vim +``` + +全局别名可以让你在使用命令行的任何时刻创建命令别名,而不仅仅是在开始的时候。这个在你想替换常用文件名或者管道命令的时候就显得非常有用了。比如 + +``` +alias -g G='| grep -i' +``` + +要使用这个别名,只要你在想用管道命令的时候输入 `G` 就好了: + +``` +$ ls -l G do +drwxr-xr-x.  5 rgerardi rgerardi 4096 Aug  7 14:08 Documents +drwxr-xr-x.  6 rgerardi rgerardi 4096 Aug 24 14:51 Downloads +``` + +接着,我们就来看看 zsh 是如何导航文件系统的。 + +### 3\. 便捷的目录导航 + +当你使用命令行的时候, 在不同的目录之间切换访问是最常见的工作了。 zsh 提供了一些十分有用的目录导航功能来简化这个操作。这些功能已经集成到 Oh My Zsh 中了, 而你可以用以下命令来启用它 + +``` +setopt  autocd autopushd \ pushdignoredups +``` + +使用了上面的配置后,你就不用输入 `cd` 来切换目录了,只需要输入目录名称,zsh 就会自动切换到这个目录中: + +``` +$ pwd +/home/rgerardi +$ /tmp +$ pwd +/tmp +``` + +如果想要回退,只要输入 `-`: + +Zsh 会记录你访问过的目录,这样下次你就可以快速切换到这些目录中。如果想要看这个目录列表,只要输入 `dirs -v`: + +``` +$ dirs -v +0       ~ +1       /var/log +2       /var/opt +3       /usr/bin +4       /usr/local +5       /usr/lib +6       /tmp +7       ~/Projects/Opensource.com/zsh-5tips +8       ~/Projects +9       ~/Projects/ansible +10      ~/Documents +``` + +如果想要切换到这个列表中的其中一个目录,只需输入 `~#` (`#` 代表目录在列表中的序号)就可以了。比如 + +``` +$ pwd +/home/rgerardi +$ ~4 +$ pwd +/usr/local +``` + +你甚至可以用别名组合这些命令,这样切换起来就变得更简单: + +``` +d='dirs -v | head -10' +1='cd -' +2='cd -2' +3='cd -3' +4='cd -4' +5='cd -5' +6='cd -6' +7='cd -7' +8='cd -8' +9='cd -9' +``` + +现在你可以通过输入 `d` 来查看这个目录列表的前10个,然后用目录的序号来进行切换: + +``` +$ d +0       /usr/local +1       ~ +2       /var/log +3       /var/opt +4       /usr/bin +5       /usr/lib +6       /tmp +7       ~/Projects/Opensource.com/zsh-5tips +8       ~/Projects +9       ~/Projects/ansible +$ pwd +/usr/local +$ 6 +/tmp +$ pwd +/tmp +``` + +最后,你可以在 zsh 中利用 Tab 来自动补全目录名称。你可以先输入目录的首字母,然后用 `TAB` 来补全它们: + +``` +$ pwd +/home/rgerardi +$ p/o/z (TAB) +$ Projects/Opensource.com/zsh-5tips/ +``` + +以上仅仅是 zsh 强大的 Tab 补全系统中的一个功能。接来下我们来探索它更多的功能。 + +### 4\. 先进的 Tab 补全 + +Zsh 强大的补全系统是它其中一个卖点。为了简便起见,我称它为 Tab 补全,然而在系统底层,它不仅仅只做一件事。这里通常包括扩展以及命令的补全,我会在这里同时讨论它们。如果想了解更多,详见 [用户手册][8] ( [User's Guide][8] )。 + +在 Oh My Zsh 中,命令补全是默认可用的。要启用它,你只要在 `.zshrc` 文件中添加以下命令: +``` +autoload -U compinit +compinit +``` + +Zsh 的补全系统非常智能。他会根据当前上下文来进行命令的提示——比如,你输入了 `cd` 和 `TAB`,zsh 只会为你提示目录名,因为它知道 +当前的 `cd` 没有任何作用。 + +反之,如果你使用 `ssh` 或者 `ping` 这类与用户或者主机相关的命令, zsh 便会提示用户名。 + +`zsh` 拥有一个巨大而又完整的库,因此它能识别许多不同的命令。比如,如果你使用 `tar` 命令, 你可以按 Tab 键,他会为你展示一个可以用于解压的文件列表: + +``` +$ tar -xzvf test1.tar.gz test1/file1 (TAB) +file1 file2 +``` + +如果使用 `git` 的话,这里有个更高级的示例。在这个示例中,当你按 `TAB` 键, zsh 会自动补全当前库可以操作的文件: + +``` +$ ls +original  plan.txt  zsh-5tips.md  zsh_theme_small.png +$ git status +On branch master +Your branch is up to date with 'origin/master'. + +Changes not staged for commit: +  (use "git add ..." to update what will be committed) +  (use "git checkout -- ..." to discard changes in working directory) + +        modified:   zsh-5tips.md + +no changes added to commit (use "git add" and/or "git commit -a") +$ git add (TAB) +$ git add zsh-5tips.md +``` + +zsh 还能识别命令行选项,同时他只会提示与选中子命令相关的命令列表: + +``` +$ git commit - (TAB) +--all                  -a       -- stage all modified and deleted paths +--allow-empty                   -- allow recording an empty commit +--allow-empty-message           -- allow recording a commit with an empty message +--amend                         -- amend the tip of the current branch +--author                        -- override the author name used in the commit +--branch                        -- show branch information +--cleanup                       -- specify how the commit message should be cleaned up +--date                          -- override the author date used in the commit +--dry-run                       -- only show the list of paths that are to be committed or not, and any untracked +--edit                 -e       -- edit the commit message before committing +--file                 -F       -- read commit message from given file +--gpg-sign             -S       -- GPG-sign the commit +--include              -i       -- update the given files and commit the whole index +--interactive                   -- interactively update paths in the index file +--message              -m       -- use the given message as the commit message +... TRUNCATED ... +``` + +在按 `TAB` 键之后,你可以使用方向键来选择你想用的命令。现在你就不用记住所有的 Git 命令项了。 + +zsh 还有很多有用的功能。当你用它的时候,你就知道哪些对你才是最有用的。 + +### 5\. 命令行编辑与历史记录 + +Zsh 的命令行编辑功能也十分有效。默认条件下,他是模拟 emacs 编辑器的。如果你是跟我一样更喜欢用 vi/vim,你可以用以下命令启用 vi 编辑。 + +``` +$ bindkey -v +``` + +如果你使用 Oh My Zsh,`vi-mode` 插件可以启用额外的绑定,同时会在你的命令提示符上增加 vi 的模式提示--这个非常有用。 + +当启用 vi 的绑定后,你可以再命令行中使用 vi 命令进行编辑。比如,输入 `ESC+/` 来查找命令行记录。在查找的时候,输入 `n` 来找下一个匹配行,输入 `N` 来找上一个。输入 `ESC` 后,最常用的 vi 命令有以下几个,如输入 `0` 跳转到第一行,输入 `$` 跳转到最后一行,输入 `i` 来插入文本,输入 `a` 来追加文本等等,一些直接操作的命令也同样有效,比如输入 `cw` 来修改单词。 + +除了命令行编辑,如果你想修改或重新执行之前使用过的命令,zsh 还提供几个常用的命令行历史功能。比如,你打错了一个命令,输入 `fc`,你可以在你偏好的编辑器中修复最后一条命令。使用哪个编辑是参照 `$EDITOR` 变量的,而默认是使用 vi。 + +另外一个有用的命令是 `r`, 他会重新执行上一条命令;而 `r ` 则会执行上一条包含 `WORD` 的命令。 + +最后,输入两个感叹号( `!!` ),可以在命令行中回溯最后一条命令。这个十分有用,比如,当你忘记使用 `sudo` 去执行需要权限的命令时: + +``` +$ less /var/log/dnf.log +/var/log/dnf.log: Permission denied +$ sudo !! +$ sudo less /var/log/dnf.log +``` + +这个功能让查找并且重新执行之前命令的操作更加方便。 + +### 何去何从? + +这里仅仅介绍了几个可以让你提高生产率的 zsh 特性;其实还有更多功能带你发掘;想知道更多的信息,你可以访问以下的资源: + +[An Introduction to the Z Shell][9] + +[A User's Guide to ZSH][10] + +[Archlinux Wiki][11] + +[zsh-lovers][12] + +你有使用 zsh 提高生产力的tips可以分享吗?我(作者)很乐意在下方评论看到它们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/tips-productivity-zsh + +作者:[Ricardo Gerardi][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[tnuoccalanosrep](https://github.com/tnuoccalanosrep) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rgerardi +[1]: http://www.zsh.org/ +[2]: https://en.wikipedia.org/wiki/Shell_(computing) +[3]: http://zsh.sourceforge.net/Doc/Release/zsh_toc.html +[4]: https://ohmyz.sh/ +[5]: https://github.com/bhilburn/powerlevel9k +[7]: https://opensource.com/sites/default/files/uploads/zsh_theme_small.png (zsh Powerlevel9K theme) +[8]: http://zsh.sourceforge.net/Guide/zshguide06.html#l144 +[9]: http://zsh.sourceforge.net/Intro/intro_toc.html +[10]: http://zsh.sourceforge.net/Guide/ +[11]: https://wiki.archlinux.org/index.php/zsh +[12]: https://grml.org/zsh/ From db0fd0446520ae89e4c5aa707ca2fed904edab95 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 17 Sep 2018 17:28:53 +0800 Subject: [PATCH 273/455] PRF:20180929 Getting started with the i3 window manager on Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @sd886393 恭喜你,完成了第一篇翻译贡献! --- ...ted with the i3 window manager on Linux.md | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/translated/tech/20180929 Getting started with the i3 window manager on Linux.md b/translated/tech/20180929 Getting started with the i3 window manager on Linux.md index 8a14891ce6..2aa0df4c6b 100644 --- a/translated/tech/20180929 Getting started with the i3 window manager on Linux.md +++ b/translated/tech/20180929 Getting started with the i3 window manager on Linux.md @@ -1,31 +1,34 @@ -在Linux上使用 i3 作为窗口管理器的入门教程 +i3 窗口管理器入门 ====== -本篇文章会介绍如何在Fedora系统中,安装、配置、使用i3桌面管理器。 + +> 本篇文章会介绍如何在 Fedora 系统中,安装、配置、使用 i3 瓦片式桌面管理器。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows-tiling-windows-wall.png?itok=mTH7uVrn) -在我的文章[i3 桌面让Linux更好的5个理由][1],我分享了选择 [i3 桌面管理器][2] 作为一种Linux桌面替代方案的最主要五个理由。 -在本篇文章中,我将向大家展示,如何在 Fedora 28 上安装与配置 i3。 +在我的文章 [i3 桌面让 Linux 更好的 5 个理由][1],我分享了选择 [i3 桌面管理器][2] 作为一种 Linux 桌面替代方案的最主要五个理由。 -### 1\. 安装 +在本篇文章中,我将向大家展示,如何在 Fedora 28 上安装与简单配置 i3。 + +### 1、 安装 首先进入 Fedora 系统中,打开一个终端。使用 `dnf` 来安装需要的软件包,如下: + ``` [ricardo@f28i3 ~]$ sudo dnf install -y i3 i3-ipc i3status i3lock dmenu terminator --exclude=rxvt-unicode Last metadata expiration check: 1:36:15 ago on Wed 08 Aug 2018 12:04:31 PM EDT. Dependencies resolved. ================================================================================================ - Package                     Arch         Version                           Repository     Size + Package Arch Version Repository Size ================================================================================================ Installing: - dmenu                       x86_64       4.8-1.fc28                        fedora         33 k - i3                          x86_64       4.15-1.fc28                       fedora        323 k - i3-ipc                      noarch       0.1.4-12.fc28                     fedora         14 k - i3lock                      x86_64       2.9.1-2.fc28                      fedora         33 k - i3status                    x86_64       2.12-1.fc28                       updates        62 k - terminator                  noarch       1.91-4.fc28                       fedora        570 k + dmenu x86_64 4.8-1.fc28 fedora 33 k + i3 x86_64 4.15-1.fc28 fedora 323 k + i3-ipc noarch 0.1.4-12.fc28 fedora 14 k + i3lock x86_64 2.9.1-2.fc28 fedora 33 k + i3status x86_64 2.12-1.fc28 updates 62 k + terminator noarch 1.91-4.fc28 fedora 570 k Installing dependencies: - dzen2                       x86_64       0.8.5-21.20100104svn.fc28         fedora         60 k + dzen2 x86_64 0.8.5-21.20100104svn.fc28 fedora 60 k ... Skipping dependencies/install messages @@ -37,55 +40,56 @@ Complete! 据用户目前的系统状态,在命令执行过程中可能会安装很多依赖。等待所有的依赖安装完成,之后重启你的电脑。 -### 2. 登录与初始化 +### 2、 首次登录与初始化 -在你的机器重启之后,你便可以第一次体验 i3 了。在 GNOME Display Manager (GDM),选择你的用户名,之后先别着急输密码,点击下方的密码输入框下方的小齿轮,之后选择 i3 ,像下方这样: +在你的机器重启之后,你便可以第一次体验 i3 了。在 GNOME 显示管理器(GDM)屏幕,选择你的用户名,之后先别着急输密码,点击下方的密码输入框下方的小齿轮,之后选择 i3 而不是 GNOME,像下方这样: ![](https://opensource.com/sites/default/files/uploads/i3_first_login_small.png) -输入你的密码,并点击 `Sign In`。在你第一次登入之后,会先看到 i3 的配置界面: +输入你的密码,并点击 “Sign In”。在你第一次登入之后,会先看到 i3 的配置界面: ![](https://opensource.com/sites/default/files/uploads/i3_first_configuration_small.png) -点击 `ENTER` 就会在 `$HOME/.config/i3` 生成一个配置文件,之后你可以通过这个配置文件来定制化 i3's 的一些行为。 +点击回车键就会在 `$HOME/.config/i3` 生成一个配置文件,之后你可以通过这个配置文件来定制化 i3 的一些行为。 -在下一屏,你需要选择你的 `Mod` 键。这一步很关键,因为 `Mod` 键通常都会作为 i3's 命令快捷键的发起键。按 `ENTER` 会选择 `Win` 键作为默认的 `Mod` 键。如果你的键盘没有 `Win` 键,用 `Alt` 键做替代,用方向键键选择后按 `ENTER` 确认。 +在下一屏,你需要选择你的 `Mod` 键。这一步很关键,因为 `Mod` 键通常都会作为 i3 命令快捷键的发起键。按回车会选择 `Win` 键作为默认的 `Mod` 键。如果你的键盘没有 `Win` 键,用 `Alt` 键做替代,用方向键键选择后按回车键确认。 ![](https://opensource.com/sites/default/files/uploads/i3_generate_config_small.png) -现在你就登录到了 i3 的系统中。由于 i3 是一个最小化的窗口管理器,你会看到一个黑屏窗口,以及屏幕底端显式的状态栏: +现在你就登录到了 i3 的系统中。由于 i3 是一个极简的窗口管理器,你会看到一个黑屏窗口,以及屏幕底端显示的状态栏: ![](https://opensource.com/sites/default/files/uploads/i3_start_small.png) 接下来,让我们看看 i3 的如何实际使用。 -### 3\. 基本的快捷键 +### 3、 基本的快捷键 -现在你已经登录到了 i3 的会话中,你需要几个基本的快捷键来应对基本的操作。 +现在你已经登录到了 i3 会话中,你需要几个基本的快捷键来应对基本的操作。 大多数的 i3 快捷键都会用到之前配置的 `Mod` 键。在下面的例子中,当我提到 `Mod` 键,请根据情况使用你定义的做替换。通常使用 `Win` 键或者 `Alt` 键。 -首先,打开一个终端,使用 `Mod+ENTER`。重复打开几个终端,观察 i3 是如何自动将它们在桌面中排列。默认情况下, i3 会在水平的方向分割屏幕;使用 `Mod + v` 来垂直分割,再按 `Mod + h` 会恢复水平分割模式。 +首先,要打开一个终端,可以使用 `Mod+ENTER`。重复打开几个终端,观察 i3 是如何自动将它们在桌面中排列。默认情况下, i3 会在水平的方向分割屏幕;使用 `Mod + v` 来垂直分割,再按 `Mod + h` 会恢复水平分割模式。 ![](https://opensource.com/sites/default/files/uploads/i3_3terminal_tiled_small.png) -当需要启动其他的应用,按 `Mod + d` 来打开 `dmenu`,一个简单的文字应用菜单。默认情况下,`dmenu` 会呈现出所有在你 `$PATH` 中设置的应用。使用方向键来选择你想启动的应用,同时你可以键入应用的名称,来缩小选择的范围,之后按 `ENTER` 来启动选择的应用。 +当需要启动其他的应用,按 `Mod + d` 来打开 `dmenu`,一个简单的文字应用菜单。默认情况下,`dmenu` 会呈现出所有在你 `$PATH` 中设置的应用。使用方向键来选择你想启动的应用,同时你可以键入应用的名称,来缩小选择的范围,之后按回车键来启动选择的应用。 ![](https://opensource.com/sites/default/files/uploads/i3_dmenu.png) 如果你的应用没有提供退出的方法,你可以使用 i3 来关闭对应的窗口,通过按 `Mod + Shift +q`。注意,你可能会丢失未保存的工作内容。 -最后,当你想关闭会话并退出 i3,按 `Mod + Shift +e`。之后会在窗口的上方提示你是否退出。点击 `Yes, exit i3` 退出,或选择 `X` 来取消。 +最后,当你想关闭会话并退出 i3,按 `Mod + Shift +e`。之后会在窗口的上方提示你是否退出。点击 “Yes, exit i3” 退出,或选择 “X” 来取消。 ![](https://opensource.com/sites/default/files/uploads/i3_exit_small.png) -这些就是 i3 中最基本的快捷键,如果想了解更多,请查阅官方文档 [documentation][3]。 +这些就是 i3 中最基本的快捷键,如果想了解更多,请查阅官方[文档][3]。 -### 4\. 替换GDM +### 4、 替换 GDM -使用 i3 window manager 会降低你操作系统的内存占用;然而,Fedora 依然会使用 GDM 作为登录的窗口。GDM 会载入几个与 GNOME 相关的库从而占用内存。 +使用 i3 窗口管理器会降低你操作系统的内存占用;然而,Fedora 依然会使用 GDM 作为登录屏。GDM 会载入几个与 GNOME 相关的库从而占用内存。 + +如果你想进一步的降低你的内存占用,你可以使用一些更轻量级的显示管理器来替换 GDM,比如 lightdm : -如果你想进一步的降低你的内存占用,你可以使用一些更轻量级的窗口管理器来替换 GDM,比如 `lightdm`: ``` [ricardo@f28i3 ~]$ sudo dnf install -y lightdm [ricardo@f28i3 ~]$ sudo systemctl disable gdm @@ -108,7 +112,7 @@ via: https://opensource.com/article/18/8/getting-started-i3-window-manager 作者:[Ricardo Gerardi][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[sd886393](https://github.com/sd886393) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From f53c3f747c7d64e75f2ffaaf5de9eb96db01f324 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 17 Sep 2018 17:30:37 +0800 Subject: [PATCH 274/455] PUB:20180929 Getting started with the i3 window manager on Linux.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @sd886393 本文首发地址: https://linux.cn/article-10021-1.html 您的 LCTT 专页地址: https://linux.cn/lctt/sd886393 请登录 LCTT 贡献平台领取 LCCN :https://lctt.linux.cn/ --- ...0180929 Getting started with the i3 window manager on Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180929 Getting started with the i3 window manager on Linux.md (100%) diff --git a/translated/tech/20180929 Getting started with the i3 window manager on Linux.md b/published/20180929 Getting started with the i3 window manager on Linux.md similarity index 100% rename from translated/tech/20180929 Getting started with the i3 window manager on Linux.md rename to published/20180929 Getting started with the i3 window manager on Linux.md From 1beb6d2638e8257357a9582255beaca2b54240a7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 17 Sep 2018 23:22:09 +0800 Subject: [PATCH 275/455] PRF&PUB:20180518 Mastering CI CD at OpenDev (#10236) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * PRF:20180518 Mastering CI-CD at OpenDev.md @jamelouis 恭喜你完成了第一篇翻译贡献(虽然这篇消息已经过时了,但是翻译的不错) * PUB: 20180518 Mastering CI-CD at OpenDev.md @jamelouis 本文首发地址: https://linux.cn/article-10023-1.html 您的 LCTT 专页地址: https://linux.cn/lctt/jamelouis 请在 LCTT 平台上注册以领取 LCCN: https://lctt.linux.cn/ --- .../20180518 Mastering CI-CD at OpenDev.md | 53 +++++++++++++++++++ .../20180518 Mastering CI-CD at OpenDev.md | 52 ------------------ 2 files changed, 53 insertions(+), 52 deletions(-) create mode 100644 published/20180518 Mastering CI-CD at OpenDev.md delete mode 100644 translated/talk/20180518 Mastering CI-CD at OpenDev.md diff --git a/published/20180518 Mastering CI-CD at OpenDev.md b/published/20180518 Mastering CI-CD at OpenDev.md new file mode 100644 index 0000000000..5418e196e9 --- /dev/null +++ b/published/20180518 Mastering CI-CD at OpenDev.md @@ -0,0 +1,53 @@ +在 OpenDev 大会上学习 CI/CD +====== +> 未来的开发工作需要非常精通 CI/CD 流程。 + +![在OpenDev上,掌握CI/CD](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_opennature_3.png?itok=J1OSECM_) + +在 2017 年启动后,OpenDev 大会现在已是一个年度活动。在去年 9 月的首届活动上,会议的重点是边缘计算。今年的活动,于 5 月 22 - 23 日举行,会议的重点是持续集成和持续发布 (CI/CD),并与 OpenStack 峰会一起在温哥华举行。 + +基于我在 OpenStack 项目的 CI/CD 系统的技术背景和我近期进入容器下的 CI/CD 方面的经验,我被邀请加入 OpenDev CI/CD 计划委员会。今天我经常借助很多开源技术,例如 [Jenkins][3]、[GitLab][2]、[Spinnaker][4] 和 [Artifactory][5] 来讨论 CI/CD 流程。 + +这次活动对我来说是很激动人心的,因为我们将在这个活动中融合两个开源基础设施理念。首先,我们将讨论可以被任何组织使用的 CI/CD 工具。为此目的,在 [讲演][6] 中,我们将听到关于开源 CI/CD 工具的使用讲演,一场来自 Boris Renski 的关于 Spinnaker 的讲演,和一场来自 Jim Blair 的关于 [Zuul][7] 的讲演。同时,讲演会涉及关于开源技术的偏好的高级别话题,特别是那种跨社区的和本身就是开源项目的。从Fatih Degirmenci 和 Daniel Farrel 那里,我们将听到关于在不同社区分享持续发布实践经历,接着 Benjamin Mako Hill 会为我们带来一场关于为什么自由软件需要自由工具的分享。 + +在分享 CI/CD 相对新颖的特性后,接下来的活动是对话、研讨会和协作讨论的混合组合。当从人们所提交的讲座和研讨会中进行选择,并提出协作讨论主题时,我们希望确保有一个多样灵活的日程表,这样任何参与者都能在 CI/CD 活动进程中发现有趣的东西。 + +这些讲座会是标准的会议风格,选择涵盖关键主题,如制定 CI/CD 流程,在实践 DevOps 时提升安全性,以及更具体的解决方案,如基于容器关于 Kubernetes 的 [Aptomi][8] 和在 ETSI NFV 环境下 CI/CD。这些会话的大部分将会是作为给新接触 CI/CD 或这些特定技术的参与者关于这些话题和理念的简介。 + +交互式的研讨会会持续相对比较长的时间,参与者将会在思想上得到特定的体验。这些研讨会包括 “[在持续集成任务中的异常检测][9]”、“[如何安装 Zuul 和配置第一个任务][10]”,和“[Spinnake 101:快速可靠的软件发布][11]”。(注意这些研讨会空间是有限的,所以设立了一个 RSVP 系统。你们将会在会议的链接里找到一个 RSVP 的按钮。) + +可能最让我最兴奋的是协作讨论,这些协作讨论占据了一半以上的活动安排。协作讨论的主题由计划委员会选取。计划委员会根据我们在社区里所看到来选取对应的主题。这是“鱼缸”风格式的会议,通常是几个人聚在一个房间里围绕着 CI/CD 讨论某一个主题。 + +这次会议风格的理念是来自于开发者峰会,最初是由 Ubuntu 社区提出,接着 OpenStack 社区也在活动上采纳。这些协作讨论的主题包含不同的会议,这些会议是关于 CI/CD 基础,可以鼓励跨社区协作的提升举措,在组织里推行 CI/CD 文化,和为什么开源 CI/CD 工具如此重要。采用共享文档来做会议笔记,以确保尽可能的在会议的过程中分享知识。在讨论过程中,提出行动项目也是很常见的,因此社区成员可以推动和所涉及的主题相关的倡议。 + +活动将以联合总结会议结束。联合总结会议将总结来自协同讨论的关键点和为即将在这个领域工作的参与者指出可选的职业范围。 + +可以在 [OpenStack 峰会注册页][13] 上注册参加活动。或者可以在温哥华唯一指定售票的会议中心购买活动的入场券,价格是 $199。更多关于票和全部的活动安排见官网 [OpenDev 网站][1]。 + +我希望你们能够加入我们,并在温哥华渡过令人激动的两天,并且在这两天的活动中学习,协作和在 CI/CD 取得进展。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/opendev + +作者:[Elizabeth K.Joseph][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[jamelouis](https://github.com/jamelouis) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/pleia2 +[1]:http://2018.opendevconf.com/ +[2]:https://about.gitlab.com/ +[3]:https://jenkins.io/ +[4]:https://www.spinnaker.io/ +[5]:https://jfrog.com/artifactory/ +[6]:http://2018.opendevconf.com/schedule/ +[7]:https://zuul-ci.org/ +[8]:http://aptomi.io/ +[9]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21692/anomaly-detection-in-continuous-integration-jobs +[10]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21693/how-to-install-zuul-and-configure-your-first-jobs +[11]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21699/spinnaker-101-releasing-software-with-velocity-and-confidence +[12]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21831/opendev-cicd-joint-collab-conclusion +[13]:https://www.eventbrite.com/e/openstack-summit-may-2018-vancouver-tickets-40845826968?aff=VancouverSummit2018 diff --git a/translated/talk/20180518 Mastering CI-CD at OpenDev.md b/translated/talk/20180518 Mastering CI-CD at OpenDev.md deleted file mode 100644 index 74e6d1c972..0000000000 --- a/translated/talk/20180518 Mastering CI-CD at OpenDev.md +++ /dev/null @@ -1,52 +0,0 @@ -在OpenDev上,掌握CI/CD(持续集成/持续发布) -====== - -![在OpenDev上,掌握CI/CD](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_opennature_3.png?itok=J1OSECM_) - -在2017年启动后,OpenDev会议现在是一个年度活动。在去年9月的首届活动上,会议的重点是边缘计算。今年的活动,将于5月22-23日举行,会议的重点是持续集成和持续发布 (CI/CD),并将与OpenStack峰会一起在温哥华举行。 - -基于我在OpenStack项目的CI/CD系统的技术背景和近期进入容器下的CI/CD方面的经验,我被邀请加入OpenDev CI/CD的编程委员会。今天我经常通过很多开源技术,例如[Jenkins][3] [GitLab][2],[Spinnaker][4],和[Artifactory][5],来讨论CI/CD流水管线。 - -这次活动对我来说是很激动人心的,因为我们将在这个活动中融合两个开源基础设施理念。首先,我们将讨论可以被任何组织使用的CI/CD工具。为此目的,在[keynotes][6],我们将听到关于开源CI/CD工具的使用讲座,一场来自Boris Renski的关于Spinnaker的和一场来自Jim Blair的关于[Zuul][7]的。同时,讲座会涉及关于开源技术的偏好的高级别话题,特别是那种跨社区的和本身就是开源项目的。从Fatih Degirmenci和Daniel Farrel那里,我们将听到关于在不同社区分享持续发布实践经历,接着Benjamin Mako Hill会为我带来一场关于为什么免费软件需要免费工具的分享。 - -在分享CI/CD相对新颖特性后,接下来的活动是对话,研讨会和协作讨论的混合组合。当从所提交的讲座和研讨会选择,并提出协作讨论主题时,我们希望确保有一个多样灵活的日程表,这样任何参与者都能在CI/CD活动进程中发现有趣的东西。 - -这些讲座会是标准的会议风格,选择以涵盖关键主题,如制作CI/CD管线,在实践DevOps时提升安全性,以及更具体的解决方案,如基于容器关于Kubernetes的[Aptomi][8]和在ETSI NFV环境下CI/CD。这些会话的大部分将会是作为给新接触CI/CD或这些特定技术的参与者关于这些话题和理念的简介。 - -交互式的研讨会会持续相对比较长的时间,参与者将会在思想上得到特定的体验。这些研讨会包括"[Anomaly Detection in Continous Integration Jobs(在持续集成任务中的异常检测)][9]","[How to Install Zuul and Configure Your First Jobs(如何安装Zuul和配置第一个任务)][10]",和"[Spinnake 101: Releasing Software with Velocity and Confidence(Spinnake 101:快速可靠的软件发布)][11]."(注意这些研讨会空间是有限的,所以设立了一个RSVP系统。你们将会在会议的链接里找到一个RSVP的按钮。) - -可能最让我最兴奋的是协作讨论,这些协作讨论占据了一半以上的活动安排。协作讨论的主题由编程委员会选取。编程委员会是根据我们在社区里所看到选取对应的主题。这是“鱼缸”风格式的会议,通常是几个人聚在一个房间里围绕着CI/CD讨论某一个主题。 - -这次会议风格的理念是来自于开发者峰会,最初是由Ubuntu社区提出,接着OpenStack社区在活动上采纳。这些协作讨论的主题包含不同的会议,这些会议是关于CI/CD基础,可以鼓励跨社区协作的提升举措,在组织里推行CI/CD文化,和为什么开源CI/CD工具如此重要。采用共享文档来做会议笔记,以确保尽可能的在会议的过程中分享知识。在讨论过程中,提出行动项目也是很常见的,因此社区成员可以推动和所涉及的主题相关的倡议。 - -活动将以联合总结会议结束。联合总结会议将总结来自协同讨论的关键点和为即将在这个领域工作的参与者指出可选的职业范围。 - -可以在[OpenStack Summit registration(OpenStack峰会注册)][13]上注册参加活动。或者可以在温哥华唯一指定售票的会议中心购买活动的入场券,价格是$199。更多关于票和全部的活动安排见官网[OpenDev website][1]。 - -我希望你们能够加入我们,并在温哥华渡过令人激动的两天,并且在这两天的活动中学习,协作和在CI/CD取得进展。 - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/5/opendev - -作者:[Elizabeth K.Joseph][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[jamelouis](https://github.com/jamelouis) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/pleia2 -[1]:http://2018.opendevconf.com/ -[2]:https://about.gitlab.com/ -[3]:https://jenkins.io/ -[4]:https://www.spinnaker.io/ -[5]:https://jfrog.com/artifactory/ -[6]:http://2018.opendevconf.com/schedule/ -[7]:https://zuul-ci.org/ -[8]:http://aptomi.io/ -[9]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21692/anomaly-detection-in-continuous-integration-jobs -[10]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21693/how-to-install-zuul-and-configure-your-first-jobs -[11]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21699/spinnaker-101-releasing-software-with-velocity-and-confidence -[12]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21831/opendev-cicd-joint-collab-conclusion -[13]:https://www.eventbrite.com/e/openstack-summit-may-2018-vancouver-tickets-40845826968?aff=VancouverSummit2018 From 56ba34b3f5f1b369c8e901a163f0012f207da791 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 18 Sep 2018 08:43:55 +0800 Subject: [PATCH 276/455] translated --- ...ow to build a URL shortener with Apache.md | 84 ------------------- ...ow to build a URL shortener with Apache.md | 82 ++++++++++++++++++ 2 files changed, 82 insertions(+), 84 deletions(-) delete mode 100644 sources/tech/20180720 How to build a URL shortener with Apache.md create mode 100644 translated/tech/20180720 How to build a URL shortener with Apache.md diff --git a/sources/tech/20180720 How to build a URL shortener with Apache.md b/sources/tech/20180720 How to build a URL shortener with Apache.md deleted file mode 100644 index 2599b9ecca..0000000000 --- a/sources/tech/20180720 How to build a URL shortener with Apache.md +++ /dev/null @@ -1,84 +0,0 @@ -translating---geekpi - -How to build a URL shortener with Apache -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openweb-osdc-lead.png?itok=yjU4KliG) - -Long ago, folks started sharing links on Twitter. The 140-character limit meant that URLs might consume most (or all) of a tweet, so people turned to URL shorteners. Eventually, Twitter added a built-in URL shortener ([t.co][1]). - -Character count isn't as important now, but there are still other reasons to shorten links. For one, the shortening service may provide analytics—you can see how popular the links are that you share. It also simplifies making easy-to-remember URLs. For example, [bit.ly/INtravel][2] is much easier to remember than . And URL shorteners can come in handy if you want to pre-share a link but don't know the final destination yet. - -Like any technology, URL shorteners aren't all positive. By masking the ultimate destination, shortened links can be used to direct people to malicious or offensive content. But if you surf carefully, URL shorteners are a useful tool. - -We [covered shorteners previously][3] on this site, but maybe you want to run something simple that's powered by a text file. In this article, we'll show how to use the Apache HTTP server's mod_rewrite feature to set up your own URL shortener. If you're not familiar with the Apache HTTP server, check out David Both's article on [installing and configuring][4] it. - -### Create a VirtualHost - -In this tutorial, I'm assuming you bought a cool domain that you'll use exclusively for the URL shortener. For example, my website is [funnelfiasco.com][5] , so I bought [funnelfias.co][6] to use for my URL shortener (okay, it's not exactly short, but it feeds my vanity). If you won't run the shortener as a separate domain, skip to the next section. - -The first step is to set up the VirtualHost that will be used for the URL shortener. For more information on VirtualHosts, see [David Both's article][7]. This setup requires just a few basic lines: -``` -    - -        ServerName funnelfias.co - -    - -``` - -### Create the rewrites - -This service uses HTTPD's rewrite engine to rewrite the URLs. If you created a VirtualHost in the section above, the configuration below goes into your VirtualHost section. Otherwise, it goes in the VirtualHost or main HTTPD configuration for your server. -``` -    RewriteEngine on - -    RewriteMap shortlinks txt:/data/web/shortlink/links.txt - -    RewriteRule ^/(.+)$ ${shortlinks:$1} [R=temp,L] - -``` - -The first line simply enables the rewrite engine. The second line builds a map of the short links from a text file. The path above is only an example; you will need to use a valid path on your system (make sure it's readable by the user account that runs HTTPD). The last line rewrites the URL. In this example, it takes any characters and looks them up in the rewrite map. You may want to have your rewrites use a particular string at the beginning. For example, if you wanted all your shortened links to be of the form "slX" (where X is a number), you would replace `(.+)` above with `(sl\d+)`. - -I used a temporary (HTTP 302) redirect here. This allows me to update the destination URL later. If you want the short link to always point to the same target, you can use a permanent (HTTP 301) redirect instead. Replace `temp` on line three with `permanent`. - -### Build your map - -Edit the file you specified on the `RewriteMap` line of the configuration. The format is a space-separated key-value store. Put one link on each line: -``` -    osdc https://opensource.com/users/bcotton - -    twitter https://twitter.com/funnelfiasco - -    swody1 https://www.spc.noaa.gov/products/outlook/day1otlk.html - -``` - -### Restart HTTPD - -The last step is to restart the HTTPD process. This is done with `systemctl restart httpd` or similar (the command and daemon name may differ by distribution). Your link shortener is now up and running. When you're ready to edit your map, you don't need to restart the web server. All you have to do is save the file, and the web server will pick up the differences. - -### Future work - -This example gives you a basic URL shortener. It can serve as a good starting point if you want to develop your own management interface as a learning project. Or you can just use it to share memorable links to forgettable URLs. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/7/apache-url-shortener - -作者:[Ben Cotton][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/bcotton -[1]:http://t.co -[2]:http://bit.ly/INtravel -[3]:https://opensource.com/article/17/3/url-link-shortener -[4]:https://opensource.com/article/18/2/how-configure-apache-web-server -[5]:http://funnelfiasco.com -[6]:http://funnelfias.co -[7]:https://opensource.com/article/18/3/configuring-multiple-web-sites-apache diff --git a/translated/tech/20180720 How to build a URL shortener with Apache.md b/translated/tech/20180720 How to build a URL shortener with Apache.md new file mode 100644 index 0000000000..8a88338a9c --- /dev/null +++ b/translated/tech/20180720 How to build a URL shortener with Apache.md @@ -0,0 +1,82 @@ +如何使用 Apache 构建 URL 缩短器 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openweb-osdc-lead.png?itok=yjU4KliG) + +很久以前,人们开始在 Twitter 上分享链接。140 个字符的限制意味着 URL 可能消耗一条推文的大部分(或全部),因此人们使用 URL 缩短器。最终,Twitter 加入了一个内置的 URL 缩短器([t.co][1])。 + +字符数现在不重要了,但还有其他原因要缩短链接。首先,缩短服务可以提供分析 - 你可以看到你分享的链接的受欢迎程度。它还简化了制作易于记忆的 URL。例如,[bit.ly/INtravel][2] 比更容易记住。如果你想预先共享一个链接,但还不知道最终地址,这时 URL 缩短器可以派上用场。。 + +与任何技术一样,URL 缩短器并非都是正面的。通过屏蔽最终地址,缩短的链接可用于指向恶意或冒犯性内容。但是,如果你仔细上网,URL 缩短器是一个有用的工具。 + +我们之前在网站上[发布过缩短器的文章][3],但也许你想要运行一些由简单的文本驱动的缩短器。在本文中,我们将展示如何使用 Apache HTTP 服务器的 mod_rewrite 功能来设置自己的 URL 缩短器。如果你不熟悉 Apache HTTP 服务器,请查看 David Both 关于[安装和配置][4]的文章。 + +### 创建一个 VirtualHost + +在本教程中,我假设你购买了一个很酷的域名,你将它专门用于 URL 缩短器。例如,我的网站是 [funnelfiasco.com][5],所以我买了 [funnelfias.co][6] 用于我的 URL 缩短器(好吧,它不是很短,但它可以满足我的虚荣心)。如果你不将缩短器作为单独的域运行,请跳到下一部分。 + +第一步是设置将用于 URL 缩短器的 VirtualHost。有关 VirtualHosts 的更多信息,请参[ David Both 的文章][7]。这步只需要几行: +``` +    + +        ServerName funnelfias.co + +    + +``` + +### 创建 rewrite + +此服务使用 HTTPD 的重写引擎来重写 URL。如果你在上面的部分中创建了 VirtualHost,则下面的配置跳到你的 VirtualHost 部分。否则跳到服务器的 VirtualHost 或主 HTTPD 配置。 +``` +    RewriteEngine on + +    RewriteMap shortlinks txt:/data/web/shortlink/links.txt + +    RewriteRule ^/(.+)$ ${shortlinks:$1} [R=temp,L] + +``` + +第一行只是启用重写引擎。第二行在文本文件构建短链接的映射。上面的路径只是一个例子。你需要使用系统上使用有效路径(确保它可由运行 HTTPD 的用户帐户读取)。最后一行重写 URL。在此例中,它接受任何字符并在重写映射中查找它们。你可能希望重写时使用特定的字符串。例如,如果你希望所有缩短的链接都是 “slX”(其中 X 是数字),则将上面的 `(.+)` 替换为 `(sl\d+)`。 + +我在这里使用了临时 (HTTP 302) 重定向。这能让我稍后更新目标 URL。如果希望短链接始终指向同一目标,则可以使用永久 (HTTP 301) 重定向。用 `permanent` 替换第三行的 `temp`。 + +### 构建你的映射 + +编辑配置文件 “RewriteMap” 行中的指定文件。格式是空格分隔的键值存储。在每一行上放一个链接: +``` +    osdc https://opensource.com/users/bcotton + +    twitter https://twitter.com/funnelfiasco + +    swody1 https://www.spc.noaa.gov/products/outlook/day1otlk.html + +``` + +### 重启 HTTPD + +最后一步是重启 HTTPD 进程。这是通过 `systemctl restart httpd` 或类似命令完成的(命令和守护进程名称可能因发行版而不同)。你的链接缩短器现已启动并运行。当你准备编辑映射时,无需重新启动 Web 服务器。你所要做的就是保存文件,Web 服务器将获取到差异。 + +### 未来的工作 + +此示例为你提供了基本的 URL 缩短器。如果你想将开发自己的管理接口作为学习项目,它可以作为一个很好的起点。或者你可以使用它分享容易记住的链接到那些容易忘记的 URL。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/7/apache-url-shortener + +作者:[Ben Cotton][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/bcotton +[1]:http://t.co +[2]:http://bit.ly/INtravel +[3]:https://opensource.com/article/17/3/url-link-shortener +[4]:https://opensource.com/article/18/2/how-configure-apache-web-server +[5]:http://funnelfiasco.com +[6]:http://funnelfias.co +[7]:https://opensource.com/article/18/3/configuring-multiple-web-sites-apache From c2d1a21552004cc2f6b7b5043abdb27f09f04d75 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 18 Sep 2018 08:48:15 +0800 Subject: [PATCH 277/455] translating --- sources/tech/20180913 ScreenCloud- The Screenshot-- App.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md b/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md index 147937ab14..f7bab2090a 100644 --- a/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md +++ b/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md @@ -1,3 +1,5 @@ +translating---geekpi + ScreenCloud: The Screenshot++ App ====== [ScreenCloud][1] is an amazing little app, that you don’t even know you need. The default screenshot procedure on desktop Linux is great (Prt Scr Button) and we even have some[powerful screenshot utilities][2]like [Shutter][3]. But ScreenCloud brings one more really simple yet really convenient feature that I just fell in love with. But before we get into it, let’s catch a little backstory. From 6a6008ac7634b5bbc0991e931f652629475a2a79 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 18 Sep 2018 09:02:45 +0800 Subject: [PATCH 278/455] translated (#10238) --- ...ow to build a URL shortener with Apache.md | 84 ------------------- ...ow to build a URL shortener with Apache.md | 82 ++++++++++++++++++ 2 files changed, 82 insertions(+), 84 deletions(-) delete mode 100644 sources/tech/20180720 How to build a URL shortener with Apache.md create mode 100644 translated/tech/20180720 How to build a URL shortener with Apache.md diff --git a/sources/tech/20180720 How to build a URL shortener with Apache.md b/sources/tech/20180720 How to build a URL shortener with Apache.md deleted file mode 100644 index 2599b9ecca..0000000000 --- a/sources/tech/20180720 How to build a URL shortener with Apache.md +++ /dev/null @@ -1,84 +0,0 @@ -translating---geekpi - -How to build a URL shortener with Apache -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openweb-osdc-lead.png?itok=yjU4KliG) - -Long ago, folks started sharing links on Twitter. The 140-character limit meant that URLs might consume most (or all) of a tweet, so people turned to URL shorteners. Eventually, Twitter added a built-in URL shortener ([t.co][1]). - -Character count isn't as important now, but there are still other reasons to shorten links. For one, the shortening service may provide analytics—you can see how popular the links are that you share. It also simplifies making easy-to-remember URLs. For example, [bit.ly/INtravel][2] is much easier to remember than . And URL shorteners can come in handy if you want to pre-share a link but don't know the final destination yet. - -Like any technology, URL shorteners aren't all positive. By masking the ultimate destination, shortened links can be used to direct people to malicious or offensive content. But if you surf carefully, URL shorteners are a useful tool. - -We [covered shorteners previously][3] on this site, but maybe you want to run something simple that's powered by a text file. In this article, we'll show how to use the Apache HTTP server's mod_rewrite feature to set up your own URL shortener. If you're not familiar with the Apache HTTP server, check out David Both's article on [installing and configuring][4] it. - -### Create a VirtualHost - -In this tutorial, I'm assuming you bought a cool domain that you'll use exclusively for the URL shortener. For example, my website is [funnelfiasco.com][5] , so I bought [funnelfias.co][6] to use for my URL shortener (okay, it's not exactly short, but it feeds my vanity). If you won't run the shortener as a separate domain, skip to the next section. - -The first step is to set up the VirtualHost that will be used for the URL shortener. For more information on VirtualHosts, see [David Both's article][7]. This setup requires just a few basic lines: -``` -    - -        ServerName funnelfias.co - -    - -``` - -### Create the rewrites - -This service uses HTTPD's rewrite engine to rewrite the URLs. If you created a VirtualHost in the section above, the configuration below goes into your VirtualHost section. Otherwise, it goes in the VirtualHost or main HTTPD configuration for your server. -``` -    RewriteEngine on - -    RewriteMap shortlinks txt:/data/web/shortlink/links.txt - -    RewriteRule ^/(.+)$ ${shortlinks:$1} [R=temp,L] - -``` - -The first line simply enables the rewrite engine. The second line builds a map of the short links from a text file. The path above is only an example; you will need to use a valid path on your system (make sure it's readable by the user account that runs HTTPD). The last line rewrites the URL. In this example, it takes any characters and looks them up in the rewrite map. You may want to have your rewrites use a particular string at the beginning. For example, if you wanted all your shortened links to be of the form "slX" (where X is a number), you would replace `(.+)` above with `(sl\d+)`. - -I used a temporary (HTTP 302) redirect here. This allows me to update the destination URL later. If you want the short link to always point to the same target, you can use a permanent (HTTP 301) redirect instead. Replace `temp` on line three with `permanent`. - -### Build your map - -Edit the file you specified on the `RewriteMap` line of the configuration. The format is a space-separated key-value store. Put one link on each line: -``` -    osdc https://opensource.com/users/bcotton - -    twitter https://twitter.com/funnelfiasco - -    swody1 https://www.spc.noaa.gov/products/outlook/day1otlk.html - -``` - -### Restart HTTPD - -The last step is to restart the HTTPD process. This is done with `systemctl restart httpd` or similar (the command and daemon name may differ by distribution). Your link shortener is now up and running. When you're ready to edit your map, you don't need to restart the web server. All you have to do is save the file, and the web server will pick up the differences. - -### Future work - -This example gives you a basic URL shortener. It can serve as a good starting point if you want to develop your own management interface as a learning project. Or you can just use it to share memorable links to forgettable URLs. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/7/apache-url-shortener - -作者:[Ben Cotton][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/bcotton -[1]:http://t.co -[2]:http://bit.ly/INtravel -[3]:https://opensource.com/article/17/3/url-link-shortener -[4]:https://opensource.com/article/18/2/how-configure-apache-web-server -[5]:http://funnelfiasco.com -[6]:http://funnelfias.co -[7]:https://opensource.com/article/18/3/configuring-multiple-web-sites-apache diff --git a/translated/tech/20180720 How to build a URL shortener with Apache.md b/translated/tech/20180720 How to build a URL shortener with Apache.md new file mode 100644 index 0000000000..8a88338a9c --- /dev/null +++ b/translated/tech/20180720 How to build a URL shortener with Apache.md @@ -0,0 +1,82 @@ +如何使用 Apache 构建 URL 缩短器 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openweb-osdc-lead.png?itok=yjU4KliG) + +很久以前,人们开始在 Twitter 上分享链接。140 个字符的限制意味着 URL 可能消耗一条推文的大部分(或全部),因此人们使用 URL 缩短器。最终,Twitter 加入了一个内置的 URL 缩短器([t.co][1])。 + +字符数现在不重要了,但还有其他原因要缩短链接。首先,缩短服务可以提供分析 - 你可以看到你分享的链接的受欢迎程度。它还简化了制作易于记忆的 URL。例如,[bit.ly/INtravel][2] 比更容易记住。如果你想预先共享一个链接,但还不知道最终地址,这时 URL 缩短器可以派上用场。。 + +与任何技术一样,URL 缩短器并非都是正面的。通过屏蔽最终地址,缩短的链接可用于指向恶意或冒犯性内容。但是,如果你仔细上网,URL 缩短器是一个有用的工具。 + +我们之前在网站上[发布过缩短器的文章][3],但也许你想要运行一些由简单的文本驱动的缩短器。在本文中,我们将展示如何使用 Apache HTTP 服务器的 mod_rewrite 功能来设置自己的 URL 缩短器。如果你不熟悉 Apache HTTP 服务器,请查看 David Both 关于[安装和配置][4]的文章。 + +### 创建一个 VirtualHost + +在本教程中,我假设你购买了一个很酷的域名,你将它专门用于 URL 缩短器。例如,我的网站是 [funnelfiasco.com][5],所以我买了 [funnelfias.co][6] 用于我的 URL 缩短器(好吧,它不是很短,但它可以满足我的虚荣心)。如果你不将缩短器作为单独的域运行,请跳到下一部分。 + +第一步是设置将用于 URL 缩短器的 VirtualHost。有关 VirtualHosts 的更多信息,请参[ David Both 的文章][7]。这步只需要几行: +``` +    + +        ServerName funnelfias.co + +    + +``` + +### 创建 rewrite + +此服务使用 HTTPD 的重写引擎来重写 URL。如果你在上面的部分中创建了 VirtualHost,则下面的配置跳到你的 VirtualHost 部分。否则跳到服务器的 VirtualHost 或主 HTTPD 配置。 +``` +    RewriteEngine on + +    RewriteMap shortlinks txt:/data/web/shortlink/links.txt + +    RewriteRule ^/(.+)$ ${shortlinks:$1} [R=temp,L] + +``` + +第一行只是启用重写引擎。第二行在文本文件构建短链接的映射。上面的路径只是一个例子。你需要使用系统上使用有效路径(确保它可由运行 HTTPD 的用户帐户读取)。最后一行重写 URL。在此例中,它接受任何字符并在重写映射中查找它们。你可能希望重写时使用特定的字符串。例如,如果你希望所有缩短的链接都是 “slX”(其中 X 是数字),则将上面的 `(.+)` 替换为 `(sl\d+)`。 + +我在这里使用了临时 (HTTP 302) 重定向。这能让我稍后更新目标 URL。如果希望短链接始终指向同一目标,则可以使用永久 (HTTP 301) 重定向。用 `permanent` 替换第三行的 `temp`。 + +### 构建你的映射 + +编辑配置文件 “RewriteMap” 行中的指定文件。格式是空格分隔的键值存储。在每一行上放一个链接: +``` +    osdc https://opensource.com/users/bcotton + +    twitter https://twitter.com/funnelfiasco + +    swody1 https://www.spc.noaa.gov/products/outlook/day1otlk.html + +``` + +### 重启 HTTPD + +最后一步是重启 HTTPD 进程。这是通过 `systemctl restart httpd` 或类似命令完成的(命令和守护进程名称可能因发行版而不同)。你的链接缩短器现已启动并运行。当你准备编辑映射时,无需重新启动 Web 服务器。你所要做的就是保存文件,Web 服务器将获取到差异。 + +### 未来的工作 + +此示例为你提供了基本的 URL 缩短器。如果你想将开发自己的管理接口作为学习项目,它可以作为一个很好的起点。或者你可以使用它分享容易记住的链接到那些容易忘记的 URL。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/7/apache-url-shortener + +作者:[Ben Cotton][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/bcotton +[1]:http://t.co +[2]:http://bit.ly/INtravel +[3]:https://opensource.com/article/17/3/url-link-shortener +[4]:https://opensource.com/article/18/2/how-configure-apache-web-server +[5]:http://funnelfiasco.com +[6]:http://funnelfias.co +[7]:https://opensource.com/article/18/3/configuring-multiple-web-sites-apache From 80d0a2502088249e3f4c70ebd34be65cb6dfa085 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 18 Sep 2018 09:04:13 +0800 Subject: [PATCH 279/455] translating (#10239) --- sources/tech/20180913 ScreenCloud- The Screenshot-- App.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md b/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md index 147937ab14..f7bab2090a 100644 --- a/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md +++ b/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md @@ -1,3 +1,5 @@ +translating---geekpi + ScreenCloud: The Screenshot++ App ====== [ScreenCloud][1] is an amazing little app, that you don’t even know you need. The default screenshot procedure on desktop Linux is great (Prt Scr Button) and we even have some[powerful screenshot utilities][2]like [Shutter][3]. But ScreenCloud brings one more really simple yet really convenient feature that I just fell in love with. But before we get into it, let’s catch a little backstory. From aa7b4cef62182ef6c5e7da4a22641ae445a7f561 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 18 Sep 2018 09:04:58 +0800 Subject: [PATCH 280/455] PRF&PUB:20180804 Installing Andriod on VirtualBox (#10237) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * PRF:20180804 Installing Andriod on VirtualBox.md @jrglinux 欢迎回来~ * PUB:20180804 Installing Andriod on VirtualBox.md @jrglinux https://linux.cn/article-10024-1.html --- ...180804 Installing Andriod on VirtualBox.md | 162 ++++++++++++++++++ ...180804 Installing Andriod on VirtualBox.md | 160 ----------------- 2 files changed, 162 insertions(+), 160 deletions(-) create mode 100644 published/20180804 Installing Andriod on VirtualBox.md delete mode 100644 translated/tech/20180804 Installing Andriod on VirtualBox.md diff --git a/published/20180804 Installing Andriod on VirtualBox.md b/published/20180804 Installing Andriod on VirtualBox.md new file mode 100644 index 0000000000..19aa27d4f9 --- /dev/null +++ b/published/20180804 Installing Andriod on VirtualBox.md @@ -0,0 +1,162 @@ +在 VirtualBox 中安装 Andriod 系统 +====== + +如果你正在开发 Andriod 应用,也许会遇到小麻烦。诚然,ios 移动开发有 macOS 系统平台为其提供友好便利性, Andriod 开发仅有支持少部分 Andriod 系统(其中还包括可穿戴设备系统)的 Andriod Studio 工具。 + +毋庸置疑,所有的二进制工具、SDK 工具、开发框架工具以及调试器都会产生大量日志和其他各种文件,使得你的文件系统很混乱。一个有效的解决方法就是在 VirtualBox 中安装 Andriod 系统,这样还解决了 Andriod 开发中最为棘手问题之一 —— 设备模拟器。你可以在该虚拟机里测试应用程序,也可以使用 Andriod 的内部功能。因此,让我们迫不及待的开始吧! + +### 准备工作 + +首先,你需要在你的系统上安装 VirtualBox,可从[这里][1]下载 Windows 版本、macOS 版本或者各种 Linux 版本的 VitualBox。然后,你需要一个能在 x86 平台运行的 Andriod 镜像,因为 VirtualBox 为虚拟机提供运行 x86 或者 x86\_64(即 AMD64)平台的功能。 + +虽然大部分 Andriod 设备都在 ARM 上运行,但我们依然可以从 [Andriod on x86 项目][2] 中获得帮助。这些优秀的开发者已经将 Andriod 移植到 x86 平台上运行(包括实体机和虚拟机),我们可以下载最新版本的 Andriod 7.1。你也可以用之前更为稳定的版本,本文写作时最新稳定版是 Andriod 6.0。 + +### 创建 VM 虚拟机 + +打开 VirtualBox,单击左上角的 “新建” 按钮,在弹出的窗口中选择 “类型:Linux” ,然后根据下载的 ISO 镜像来确定版本,x86 对应 “32-bit”,x86_64 对应 “64-bit”,此处选择 “Linux 2.6 / 3.x / 4.x (64-bit)”。 + +RAM 大小设置为 2 GB 到你系统能提供的最大内存之间。如果你想模拟真实的使用环境你可以设置 6 GB RAM 和 32 GB ROM。 + +![][3] + +![][4] + +创建完成后,你还需要做一些设置,添加更多的处理器核心,提高开机显示内存。在 VM 上打开设置选项,“设置 -> 系统 -> 处理器”,如果硬件条件允许,可以多分配一些处理器。 + +![][5] + +在 “设置 -> 显示 -> 显存大小” 中,你可以分配一大块内存并开启 3D 加速功能。 + +![][6] + +现在我们可以启动 VM 虚拟机了。 + +### 安装 Andriod + +首次启动 VM 虚拟机,VirtualBox 会提示你需要提供启动媒介,选择之前下载好的Andriod 镜像。 + +![][7] + +下一步,如果想长时间使用 Andriod,选择 “Installation” 选项,你也可以选择 Live 模式体验 Andriod 环境。 + +![][8] + +按回车键。 + +#### 分区 + +分区是通过文本界面操作,并没有友好的 GUI 界面,所以每个操作都需要小心对待。例如,在第一屏中还没有创建分区并且只检测到原始(虚拟)硬盘时显示如下。 + +![][9] + +红色字母 `C` 和 `D` 表明 `C` 开头选项可以创建或者修改分区,`D` 开头选项可以检测设备。你可以选择 `D` 开头选项,然后它就会检测硬盘,也可不进行这步操作,因为在启动的时候它会自动检测。 + +我们选择 `C` 开头选项,在虚拟盘中创建分区。官方不推荐使用 GPT 格式,所以我们选择 “No” 并按回车键。 + +![][10] + +现在你被引导到 fdisk 工具页面。 + +![][11] + +为了简洁起见,我们就只创建一个较大的分区,使用方向键来选择 “New” ,然后选择 “Primary”,按回车键以确认。 + +![][12] + +分区大小系统已经为你计算好了,按回车键确认。 + +![][13] + +这个分区就是 Andriod 系统所在的分区,所以需要它是可启动的。选择 “Bootable”,然后按回车键(上方表格中 “Flags” 标志下面会出现 “boot” 标志),进一步,选择 “Write” 选项,保存刚才的操作记录并写入分区表。 + +![][14] + +现在你可以选择退出分区工具,然后继续安装过程。 + +![][15] + +#### 文件系统格式化为 EXT4 并安装 Android + +在“Choose Partition”分区页面上会出现一个刚刚我们创建的分区,选择它并点击“OK”进入。 + +![][16] + +在下一个菜单中选择 Ext4 作为实际的文件系统,在下一页中选择 “Yes” 然后格式化开始。会提示是否安装 GRUB 引导工具以及是否允许在目录 `/system` 进行读写,都选择 “Yes” 。现在,安装进程开始。 + +安装完成后,当系统提示可以重启的时候你可以安全地重启系统。在重启之前,你可以先关机,然后在 VitualBox 的 “设置 -> 存储” 中检查 Andriod iso 镜像是否还连接在虚拟机上,如果在,将它移除。 + +![][17] + +移除安装媒介并保存修改,再去启动 VM 虚拟机。 + +#### 运行 Andriod + +在 GRUB 引导界面,有调试模式和普通模式的选项。我们选择默认选项,如下图所示。 + +![][18] + +如果一切正常,你将会看到如下界面: + +![][19] + +如今的 Andriod 系统使用触摸交互而不是鼠标。不过 Andriod-x86 平台提供了鼠标操作支持,但开始时可能需要方向键来辅助操作。 + +![][20] + +移动到”let’s go“按钮并按下回车键。选择 “Set up as new” 选项,回车确认。 + +![][21] + +在提示用谷歌账户登陆之前,系统检查更新并检测设备信息。你可以跳过这一步,直接去设置日期和时间、用户名等。 + +还有一些其他的选项,和让你设置一个新的 Andriod 设备类似。选择 “I Agree” 选项同意有关更新、服务等的相应的选项,当然谷歌的服务条款是不得不同意的。 + +![][22] + +在这之后,因为它是个虚拟机,所以可能需要添加额外的 email 账户来设置 “On-body detection”,大部分的选项对我们来说都没有多大作用,因此可以选择 ”All Set“。 + +接下来,它会提示你选择主屏应用,这个根据个人需求选择。现在我们进入了一个虚拟的 Android 系统。 + +![][23] + +如果你需要在 VM 做一些交互测试,有个可触摸屏幕会提供很大的方便,因为那样才更接近真实使用环境。 + +希望这篇教程会给你带来帮助。 + +-------------------------------------------------------------------------------- + +via: https://linuxhint.com/install_android_virtualbox/ + +作者:[Ranvir Singh][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[jrglinux](https://github.com/jrglinux) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://linuxhint.com/author/sranvir155/ +[1]:https://www.virtualbox.org/wiki/Downloads +[2]:http://www.android-x86.org/ +[3]:https://linuxhint.com/wp-content/uploads/2018/08/a.png +[4]:https://linuxhint.com/wp-content/uploads/2018/08/a1.png +[5]:https://linuxhint.com/wp-content/uploads/2018/08/a2.png +[6]:https://linuxhint.com/wp-content/uploads/2018/08/a3.png +[7]:https://linuxhint.com/wp-content/uploads/2018/08/a4.png +[8]:https://linuxhint.com/wp-content/uploads/2018/08/a5.png +[9]:https://linuxhint.com/wp-content/uploads/2018/08/a6.png +[10]:https://linuxhint.com/wp-content/uploads/2018/08/a7.png +[11]:https://linuxhint.com/wp-content/uploads/2018/08/a8.png +[12]:https://linuxhint.com/wp-content/uploads/2018/08/a9.png +[13]:https://linuxhint.com/wp-content/uploads/2018/08/a10.png +[14]:https://linuxhint.com/wp-content/uploads/2018/08/a11.png +[15]:https://linuxhint.com/wp-content/uploads/2018/08/a12.png +[16]:https://linuxhint.com/wp-content/uploads/2018/08/a13.png +[17]:https://linuxhint.com/wp-content/uploads/2018/08/a14.png +[18]:https://linuxhint.com/wp-content/uploads/2018/08/a16.png +[19]:https://linuxhint.com/wp-content/uploads/2018/08/a17.png +[20]:https://linuxhint.com/wp-content/uploads/2018/08/a18.png +[21]:https://linuxhint.com/wp-content/uploads/2018/08/a19.png +[22]:https://linuxhint.com/wp-content/uploads/2018/08/a20.png +[23]:https://linuxhint.com/wp-content/uploads/2018/08/a21.png + + diff --git a/translated/tech/20180804 Installing Andriod on VirtualBox.md b/translated/tech/20180804 Installing Andriod on VirtualBox.md deleted file mode 100644 index 7c70925a86..0000000000 --- a/translated/tech/20180804 Installing Andriod on VirtualBox.md +++ /dev/null @@ -1,160 +0,0 @@ -在VirtualBox中安装Andriod系统 -====== - -如果你正在开发安卓 app 应用,也许会遇到小麻烦。诚然,ios 移动开发有 macOS 系统平台为其提供友好便利性,安卓开发仅有支持少部分安卓系统(其中还包括可穿戴设备系统)的 Andriod Studio 工具。 - -毋庸置疑,所有的二进制工具、SDK 工具、开发框架工具以及调试器都会产生大量日志和其他各种文件来使得你的文件系统很混乱。一个有效的解决方法就是在 VirtualBox 中安装 Andriod 系统,这样还解决了 Andriod 开发中最为棘手问题之一——设备模拟器。你可以在该虚拟机里测试应用程序,也可以使用 Andriod 的内部功能。因此,让我们迫不及待的开始吧! - -### 准备工作 - -首先,你需要在你的系统上安装 VirtualBox,可从[这里][1]下载 windows 版本、macOS 版本或者各种 Linux 版本的 VitualBox。然后,你需要一个能在 x86 平台运行的 Andriod 镜像,因为 VirtualBox 为虚拟机提供运行 x86 或者 x86_64(包括 AMD64)平台的功能。 - -虽然大部分 Andriod 设备都在 ARM 上运行,但我们依然可以在 x86 平台上获得 [Andriod 项目帮助][2]。这些优秀的开发者已经将 Andriod 移植到 x86 平台上运行(包括实体机和虚拟机),我们可以下载最新版本的 Andriod 7.1。你也可以用之前更为稳定的版本,本文写作时最新稳定版是 Andriod 6.0。 - -### 创建 VM 虚拟机 - -打开 VirtualBox,单击左上角的 ” 新建 ” 按钮,在弹出的窗口中选择 “ 类型:Linux ” ,然后根据下载的ISO镜像来确定版本,x86 对应 32-bit,x86_64 对应 64-bit,此处选择 Linux 2.6 / 3.x / 4.x (64-bit)。 - -RAM 大小设置 2 GB 到你系统能提供的最大内存之间。如果你想模拟真实的使用环境你可以设置 6 GB RAM和 32 GB ROM。 - -![][3] - -![][4] - -创建完成后,你还需要做一些设置,添加核心处理器,提高开机显示内存。在 VM 上打开设置选项,“ 设置 -> 系统 -> 处理器 ”,如果硬件条件允许,可以多分配一些处理器。 - -![][5] - -在 “ 设置 -> 显示 -> 显存大小 ” 中,你可以分配一大块内存并开启 3D 加速功能。 - -![][6] - -现在我们可以启动 VM 虚拟机了。 - -### 安装 Andriod - -首次启动 VM 虚拟机,VirtualBox 会提示你需要提供启动媒介,选择之前下载好的Andriod 镜像。 - -![][7] - -下一步,如果想长时间使用 Andriod,选择 Installation 选项,你也可以选择 Live 模式体验 Andriod 环境。 - -![][8] - -##### 分区 - -分区是通过文本界面操作,并没有友好的 GUI 界面,所以每个操作都需要小心对待。例如,在首页中还没有创建分区并且只检测到很少的虚拟硬盘时显示如下。 - -![][9] - -红色字母 C 和 D 提示 C 开头选项可以创建或者修改分区,D 开头选项可以检测设备。你可以选择 D 开头选项,然后它就会检测硬盘,也可不进行这步操作,因为在启动的时候它会自动检测。 - -我们选择 C 开头选项,在虚拟盘中创建分区。官方不推荐使用 GPT 格式,所以我们选择 No。 - -![][10] - -现在你被引导到 fdisk 工具页面。 - -![][11] - -为了简洁,我们就只创建一个较大的分区,使用方向键来选择 “ New ” ,然后选择“ Primary ”,确认。 - -![][12] - -分区大小系统已经为你计算好了,确认。 - -![][13] - -这个分区就是 Andriod 系统所在的分区,所以需要它是可启动的。选择 “ Bootable ”,然后 enter(上方表格中 Flags 标志下面会出现 boot 标志),进一步,选择 “ Write ” 选项,保存刚才的操作记录并写入分区表。 - -![][14] - -现在你可以选择退出分区工具,然后继续安装过程。 - -![][15] - -##### 文件系统格式化 - -在分区页面上会出现一个刚刚我们创建的分区,选择它并进入。 - -![][16] - -选择 Ext4 文件系统,在下一页中选择 Yes 然后格式化开始。会提示是否安装 GRUB 引导工具以及是否允许在根目录 / 进行读写,都选择 Yes 。现在,安装进程开始。 - -安装完成后,当系统提示可以 reboot 的时候你可以 reboot 系统。在重启之前,你可以先关机,然后在 VitualBox 的 ” 设置 -> 存储 ” 中检查 Andriod iso 镜像是否还依附在虚拟机上,如果在,将它移除。 - -移除安装镜像并保存,再去启动 VM 虚拟机。 - -![][17] - -##### 运行 Andriod - -在 GRUB 引导界面,有 debug 模式和 normal 模式的选项。我们选择默认选项,如下图所示。 - -![][18] - -如果一切正常,你将会看到如下界面: - -![][19] - -如今的 Andriod 系统使用触摸交互而不是鼠标。不过Andriod-x86 平台提供了鼠标操作支持,但开始时可能需要方向键来辅助操作。 - -![][20] - -选择 “ Set up as new ” 选项,回车确认。 - -![][21] - -在提示用谷歌账户登陆之前,系统检查更新并检测设备信息。你可以跳过这一步,直接去设置日期和时间、用户名等。 - -还有一些其他的选项,和让你选择创建一个新的 Andriod 设备类似。选择 “ I Agree ” 选项同意有关更新、服务等的 policy。 - -![][22] - -在这之后,因为它是个虚拟机,所以可能需要添加额外的 email 账户来设置 “ On-body detection ",大部分的选项对我们来说都没有多大作用,因此可以选择 ” All Set “。 - -接下来,它会提示你选择家庭 App。这个根据个人需求选择。 - -![][23] - -如果你需要在 VM 做一些交互测试,有个可触摸屏幕会提供很大的方便,因为那样才更接近真实使用环境。 - -希望这篇教程会给你带来帮助。如果还有类似的教程写作需求,欢迎联系我们。 - --------------------------------------------------------------------------------- - -via: https://linuxhint.com/install_android_virtualbox/ - -作者:[Ranvir Singh][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[jrglinux](https://github.com/jrglinux) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://linuxhint.com/author/sranvir155/ -[1]:https://www.virtualbox.org/wiki/Downloads -[2]:http://www.android-x86.org/ -[3]:https://linuxhint.com/wp-content/uploads/2018/08/a.png -[4]:https://linuxhint.com/wp-content/uploads/2018/08/a1.png -[5]:https://linuxhint.com/wp-content/uploads/2018/08/a2.png -[6]:https://linuxhint.com/wp-content/uploads/2018/08/a3.png -[7]:https://linuxhint.com/wp-content/uploads/2018/08/a4.png -[8]:https://linuxhint.com/wp-content/uploads/2018/08/a5.png -[9]:https://linuxhint.com/wp-content/uploads/2018/08/a6.png -[10]:https://linuxhint.com/wp-content/uploads/2018/08/a7.png -[11]:https://linuxhint.com/wp-content/uploads/2018/08/a8.png -[12]:https://linuxhint.com/wp-content/uploads/2018/08/a9.png -[13]:https://linuxhint.com/wp-content/uploads/2018/08/a10.png -[14]:https://linuxhint.com/wp-content/uploads/2018/08/a11.png -[15]:https://linuxhint.com/wp-content/uploads/2018/08/a12.png -[16]:https://linuxhint.com/wp-content/uploads/2018/08/a13.png -[17]:https://linuxhint.com/wp-content/uploads/2018/08/a14.png -[18]:https://linuxhint.com/wp-content/uploads/2018/08/a16.png -[19]:https://linuxhint.com/wp-content/uploads/2018/08/a17.png -[20]:https://linuxhint.com/wp-content/uploads/2018/08/a18.png -[21]:https://linuxhint.com/wp-content/uploads/2018/08/a19.png -[22]:https://linuxhint.com/wp-content/uploads/2018/08/a20.png -[23]:https://linuxhint.com/wp-content/uploads/2018/08/a21.png - - From 21722140ba84e072b0d1f269eacf94b62e00527b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 18 Sep 2018 10:38:07 +0800 Subject: [PATCH 281/455] PRF:20180804 Installing Andriod on VirtualBox.md (#10241) --- ...180804 Installing Andriod on VirtualBox.md | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/published/20180804 Installing Andriod on VirtualBox.md b/published/20180804 Installing Andriod on VirtualBox.md index 19aa27d4f9..5f69eee83a 100644 --- a/published/20180804 Installing Andriod on VirtualBox.md +++ b/published/20180804 Installing Andriod on VirtualBox.md @@ -1,15 +1,15 @@ -在 VirtualBox 中安装 Andriod 系统 +在 VirtualBox 中安装 Android 系统 ====== -如果你正在开发 Andriod 应用,也许会遇到小麻烦。诚然,ios 移动开发有 macOS 系统平台为其提供友好便利性, Andriod 开发仅有支持少部分 Andriod 系统(其中还包括可穿戴设备系统)的 Andriod Studio 工具。 +如果你正在开发 Android 应用,也许会遇到小麻烦。诚然,ios 移动开发有 macOS 系统平台为其提供友好便利性, Android 开发仅有支持少部分 Android 系统(其中还包括可穿戴设备系统)的 Android Studio 工具。 -毋庸置疑,所有的二进制工具、SDK 工具、开发框架工具以及调试器都会产生大量日志和其他各种文件,使得你的文件系统很混乱。一个有效的解决方法就是在 VirtualBox 中安装 Andriod 系统,这样还解决了 Andriod 开发中最为棘手问题之一 —— 设备模拟器。你可以在该虚拟机里测试应用程序,也可以使用 Andriod 的内部功能。因此,让我们迫不及待的开始吧! +毋庸置疑,所有的二进制工具、SDK 工具、开发框架工具以及调试器都会产生大量日志和其他各种文件,使得你的文件系统很混乱。一个有效的解决方法就是在 VirtualBox 中安装 Android 系统,这样还解决了 Android 开发中最为棘手问题之一 —— 设备模拟器。你可以在该虚拟机里测试应用程序,也可以使用 Android 的内部功能。因此,让我们迫不及待的开始吧! ### 准备工作 -首先,你需要在你的系统上安装 VirtualBox,可从[这里][1]下载 Windows 版本、macOS 版本或者各种 Linux 版本的 VitualBox。然后,你需要一个能在 x86 平台运行的 Andriod 镜像,因为 VirtualBox 为虚拟机提供运行 x86 或者 x86\_64(即 AMD64)平台的功能。 +首先,你需要在你的系统上安装 VirtualBox,可从[这里][1]下载 Windows 版本、macOS 版本或者各种 Linux 版本的 VitualBox。然后,你需要一个能在 x86 平台运行的 Android 镜像,因为 VirtualBox 为虚拟机提供运行 x86 或者 x86\_64(即 AMD64)平台的功能。 -虽然大部分 Andriod 设备都在 ARM 上运行,但我们依然可以从 [Andriod on x86 项目][2] 中获得帮助。这些优秀的开发者已经将 Andriod 移植到 x86 平台上运行(包括实体机和虚拟机),我们可以下载最新版本的 Andriod 7.1。你也可以用之前更为稳定的版本,本文写作时最新稳定版是 Andriod 6.0。 +虽然大部分 Android 设备都在 ARM 上运行,但我们依然可以从 [Android on x86 项目][2] 中获得帮助。这些优秀的开发者已经将 Android 移植到 x86 平台上运行(包括实体机和虚拟机),我们可以下载最新版本的 Android 7.1。你也可以用之前更为稳定的版本,本文写作时最新稳定版是 Android 6.0。 ### 创建 VM 虚拟机 @@ -31,13 +31,13 @@ RAM 大小设置为 2 GB 到你系统能提供的最大内存之间。如果你 现在我们可以启动 VM 虚拟机了。 -### 安装 Andriod +### 安装 Android -首次启动 VM 虚拟机,VirtualBox 会提示你需要提供启动媒介,选择之前下载好的Andriod 镜像。 +首次启动 VM 虚拟机,VirtualBox 会提示你需要提供启动媒介,选择之前下载好的Android 镜像。 ![][7] -下一步,如果想长时间使用 Andriod,选择 “Installation” 选项,你也可以选择 Live 模式体验 Andriod 环境。 +下一步,如果想长时间使用 Android,选择 “Installation” 选项,你也可以选择 Live 模式体验 Android 环境。 ![][8] @@ -67,7 +67,7 @@ RAM 大小设置为 2 GB 到你系统能提供的最大内存之间。如果你 ![][13] -这个分区就是 Andriod 系统所在的分区,所以需要它是可启动的。选择 “Bootable”,然后按回车键(上方表格中 “Flags” 标志下面会出现 “boot” 标志),进一步,选择 “Write” 选项,保存刚才的操作记录并写入分区表。 +这个分区就是 Android 系统所在的分区,所以需要它是可启动的。选择 “Bootable”,然后按回车键(上方表格中 “Flags” 标志下面会出现 “boot” 标志),进一步,选择 “Write” 选项,保存刚才的操作记录并写入分区表。 ![][14] @@ -83,13 +83,13 @@ RAM 大小设置为 2 GB 到你系统能提供的最大内存之间。如果你 在下一个菜单中选择 Ext4 作为实际的文件系统,在下一页中选择 “Yes” 然后格式化开始。会提示是否安装 GRUB 引导工具以及是否允许在目录 `/system` 进行读写,都选择 “Yes” 。现在,安装进程开始。 -安装完成后,当系统提示可以重启的时候你可以安全地重启系统。在重启之前,你可以先关机,然后在 VitualBox 的 “设置 -> 存储” 中检查 Andriod iso 镜像是否还连接在虚拟机上,如果在,将它移除。 +安装完成后,当系统提示可以重启的时候你可以安全地重启系统。在重启之前,你可以先关机,然后在 VitualBox 的 “设置 -> 存储” 中检查 Android iso 镜像是否还连接在虚拟机上,如果在,将它移除。 ![][17] 移除安装媒介并保存修改,再去启动 VM 虚拟机。 -#### 运行 Andriod +#### 运行 Android 在 GRUB 引导界面,有调试模式和普通模式的选项。我们选择默认选项,如下图所示。 @@ -99,7 +99,7 @@ RAM 大小设置为 2 GB 到你系统能提供的最大内存之间。如果你 ![][19] -如今的 Andriod 系统使用触摸交互而不是鼠标。不过 Andriod-x86 平台提供了鼠标操作支持,但开始时可能需要方向键来辅助操作。 +如今的 Android 系统使用触摸交互而不是鼠标。不过 Android-x86 平台提供了鼠标操作支持,但开始时可能需要方向键来辅助操作。 ![][20] @@ -109,7 +109,7 @@ RAM 大小设置为 2 GB 到你系统能提供的最大内存之间。如果你 在提示用谷歌账户登陆之前,系统检查更新并检测设备信息。你可以跳过这一步,直接去设置日期和时间、用户名等。 -还有一些其他的选项,和让你设置一个新的 Andriod 设备类似。选择 “I Agree” 选项同意有关更新、服务等的相应的选项,当然谷歌的服务条款是不得不同意的。 +还有一些其他的选项,和让你设置一个新的 Android 设备类似。选择 “I Agree” 选项同意有关更新、服务等的相应的选项,当然谷歌的服务条款是不得不同意的。 ![][22] From d2c45c2c6345ac1777c7daf81f9108fa09632d7c Mon Sep 17 00:00:00 2001 From: HankChow <280630620@qq.com> Date: Tue, 18 Sep 2018 10:38:28 +0800 Subject: [PATCH 282/455] translated --- ... Screenshot in Linux [GUI and Terminal].md | 224 ------------------ ... Screenshot in Linux [GUI and Terminal].md | 211 +++++++++++++++++ 2 files changed, 211 insertions(+), 224 deletions(-) delete mode 100644 sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md create mode 100644 translated/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md diff --git a/sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md b/sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md deleted file mode 100644 index 6f91b77563..0000000000 --- a/sources/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md +++ /dev/null @@ -1,224 +0,0 @@ -HankChow translating - -5 Ways to Take Screenshot in Linux [GUI and Terminal] -====== -Here are several ways you can take screenshots and edit the screenshots by adding text, arrows etc. Instructions and mentioned screenshot tools are valid for Ubuntu and other major Linux distributions. - -![How to take screenshots in Ubuntu Linux][1] - -When I switched from Windows to Ubuntu as my primary OS, the first thing I was worried about was the availability of screenshot tools. Well, it is easy to utilize the default keyboard shortcuts in order to take screenshots but with a standalone tool, I get to annotate/edit the image while taking the screenshot. - -In this article, we will introduce you to the default methods/tools (without a 3rd party screenshot tool) to take a screenshot while also covering the list of best screenshot tools available for Linux. - -### Method 1: The default way to take screenshot in Linux - -Do you want to capture the image of your entire screen? A specific region? A specific window? - -If you just want a simple screenshot without any annotations/fancy editing capabilities, the default keyboard shortcuts will do the trick. These are not specific to Ubuntu. Almost all Linux distributions and desktop environments support these keyboard shortcuts. - -Let’s take a look at the list of keyboard shortcuts you can utilize: - -**PrtSc** – Save a screenshot of the entire screen to the “Pictures” directory. -**Shift + PrtSc** – Save a screenshot of a specific region to Pictures. -**Alt + PrtSc** – Save a screenshot of the current window to Pictures. -**Ctrl + PrtSc** – Copy the screenshot of the entire screen to the clipboard. -**Shift + Ctrl + PrtSc** – Copy the screenshot of a specific region to the clipboard. -**Ctrl + Alt + PrtSc** – Copy the screenshot of the current window to the clipboard. - -As you can see, taking screenshots in Linux is absolutely simple with the default screenshot tool. However, if you want to immediately annotate (or other editing features) without importing the screenshot to another application, you can use a dedicated screenshot tool. - -#### **Method 2: Take and edit screenshots in Linux with Flameshot** - -![flameshot][2] - -Feature Overview - - * Annotate (highlight, point, add text, box in) - * Blur part of an image - * Crop part of an image - * Upload to Imgur - * Open screenshot with another app - - - -Flameshot is a quite impressive screenshot tool which arrived on [GitHub][3] last year. - -If you have been searching for a screenshot tool that helps you annotate, blur, mark, and upload to imgur while being actively maintained unlike some outdated screenshot tools, Flameshot should be the one to have installed. - -Fret not, we will guide you how to install it and configure it as per your preferences. - -To install it on Ubuntu, you just need to search for it on Ubuntu Software center and get it installed. In case you want to use the terminal, here’s the command for it: -``` -sudo apt install flameshot - -``` - -If you face any trouble installing, you can follow their [official installation instructions][4]. After installation, you need to configure it. Well, you can always search for it and launch it, but if you want to trigger the Flameshot screenshot tool by using **PrtSc** key, you need to assign a custom keyboard shortcut. - -Here’s how you can do that: - - * Head to the system settings and navigate your way to the Keyboard settings. - * You will find all the keyboard shortcuts listed there, ignore them and scroll down to the bottom. Now, you will find a **+** button. - * Click the “+” button to add a custom shortcut. You need to enter the following in the fields you get: -**Name:** Anything You Want -**Command:** /usr/bin/flameshot gui - * Finally, set the shortcut to **PrtSc** – which will warn you that the default screenshot functionality will be disabled – so proceed doing it. - - - -For reference, your custom keyboard shortcut field should look like this after configuration: - -![][5] -Map keyboard shortcut with Flameshot - -### **Method 3: Take and edit screenshots in Linux with Shutter** - -![][6] - -Feature Overview: - - * Annotate (highlight, point, add text, box in) - * Blur part of an image - * Crop part of an image - * Upload to image hosting sites - - - -[Shutter][7] is a popular screenshot tool available for all major Linux distributions. Though it seems to be no more being actively developed, it is still an excellent choice for handling screenshots. - -You might encounter certain bugs/errors. The most common problem with Shutter on any latest Linux distro releases is that the ability to edit the screenshots is disabled by default along with the missing applet indicator. But, fret not, we have a solution to that. You just need to follow our guide to[fix the disabled edit option in Shutter and bring back the applet indicator][8]. - -After you’re done fixing the problem, you can utilize it to edit the screenshots in a jiffy. - -To install shutter, you can browse the software center and get it from there. Alternatively, you can use the following command in the terminal to install Shutter in Ubuntu-based distributions: -``` -sudo apt install shutter - -``` - -As we saw with Flameshot, you can either choose to use the app launcher to search for Shutter and manually launch the application, or you can follow the same set of instructions (with a different command) to set a custom shortcut to trigger Shutter when you press the **PrtSc** key. - -If you are going to assign a custom keyboard shortcut, you just need to use the following in the command field: -``` -shutter -f - -``` - -### Method 4: Use GIMP for taking screenshots in Linux - -![][9] - -Feature Overview: - - * Advanced Image Editing Capabilities (Scaling, Adding filters, color correction, Add layers, Crop, and so on.) - * Take a screenshot of the selected area - - - -If you happen to use GIMP a lot and you probably want some advance edits on your screenshots, GIMP would be a good choice for that. - -You should already have it installed, if not, you can always head to your software center to install it. If you have trouble installing, you can always refer to their [official website for installation instructions][10]. - -To take a screenshot with GIMP, you need to first launch it, and then navigate your way through **File- >Create->Screenshot**. - -After you click on the screenshot option, you will be greeted with a couple of tweaks to control the screenshot. That’s just it. Click “ **Snap** ” to take the screenshot and the image will automatically appear within GIMP, ready for you to edit. - -### Method 5: Taking screenshot in Linux using command line tools - -This section is strictly for terminal lovers. If you like using the terminal, you can utilize the **GNOME screenshot** tool or **ImageMagick** or **Deepin Scrot** – which comes baked in on most of the popular Linux distributions. - -To take a screenshot instantly, enter the following command: - -#### GNOME Screenshot (for GNOME desktop users) -``` -gnome-screenshot - -``` - -To take a screenshot with a delay, enter the following command (here, **5** – is the number of seconds you want to delay) - -GNOME screenshot is one of the default tools that exists in all distributions with GNOME desktop. -``` -gnome-screenshot -d -5 - -``` - -#### ImageMagick - -[ImageMagick][11] should be already pre-installed on your system if you are using Ubuntu, Mint, or any other popular Linux distribution. In case, it isn’t there, you can always install it by following the [official installation instructions (from source)][12]. In either case, you can enter the following in the terminal: -``` -sudo apt-get install imagemagick - -``` - -After you have it installed, you can type in the following commands to take a screenshot: - -To take the screenshot of your entire screen: -``` -import -window root image.png - -``` - -Here, “image.png” is your desired name for the screenshot. - -To take the screenshot of a specific area: -``` -import image.png - -``` - -#### Deepin Scrot - -Deepin Scrot is a slightly advanced terminal-based screenshot tool. Similar to the others, you should already have it installed. If not, get it installed through the terminal by typing: -``` -sudo apt-get install scrot - -``` - -After having it installed, follow the instructions below to take a screenshot: - -To take a screenshot of the entire screen: -``` -scrot myimage.png - -``` - -To take a screenshot of the selected aread: -``` -scrot -s myimage.png - -``` - -### Wrapping Up - -So, these are the best screenshot tools available for Linux. Yes, there are a few more tools available (like [Spectacle][13] for KDE-based distros), but if you end up comparing them, the above-mentioned tools will outshine them. - -In case you find a better screenshot tool than the ones mentioned in our article, feel free to let us know about it in the comments below. - -Also, do tell us about your favorite screenshot tool! - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/take-screenshot-linux/ - -作者:[Ankush Das][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/Taking-Screenshots-in-Linux.png -[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/flameshot-pic.png -[3]: https://github.com/lupoDharkael/flameshot -[4]: https://github.com/lupoDharkael/flameshot#installation -[5]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/flameshot-config-default.png -[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/shutter-screenshot.jpg -[7]: http://shutter-project.org/ -[8]: https://itsfoss.com/shutter-edit-button-disabled/ -[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/gimp-screenshot.jpg -[10]: https://www.gimp.org/downloads/ -[11]: https://www.imagemagick.org/script/index.php -[12]: https://www.imagemagick.org/script/install-source.php -[13]: https://www.kde.org/applications/graphics/spectacle/ diff --git a/translated/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md b/translated/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md new file mode 100644 index 0000000000..b8872981fe --- /dev/null +++ b/translated/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md @@ -0,0 +1,211 @@ +5 种在 Linux 图形界面或命令行界面截图的方法 +====== +下面介绍几种获取屏幕截图并对其编辑的方法,而且其中的屏幕截图工具在 Ubuntu 和其它主流 Linux 发行版中都能够使用。 + +![在 Ubuntu Linux 中如何获取屏幕截图][1] + +当我的主力操作系统从 Windows 转换到 Ubuntu 的时候,首要考虑的就是屏幕截图工具的可用性。尽管使用默认的键盘快捷键也可以获取屏幕截图,但如果使用屏幕截图工具,可以更方便地对屏幕截图进行编辑。 + +本文将会介绍在不适用第三方工具的情况下,如何通过系统自带的方法和工具获取屏幕截图,另外还会介绍一些可用于 Linux 的最佳截图工具。 + +### 方法 1: 在 Linux 中截图的默认方式 + +你是否需要截取整个屏幕?屏幕中的某个区域?某个特定的窗口? + +如果只需要获取一张屏幕截图,不对其进行编辑的话,那么键盘的默认快捷键就可以满足要求了。而且不仅仅是 Ubuntu ,绝大部分的 Linux 发行版和桌面环境都支持以下这些快捷键: + +**PrtSc** – 获取整个屏幕的截图并保存到 Pictures 目录。 +**Shift + PrtSc** – 获取屏幕的某个区域截图并保存到 Pictures 目录。 +**Alt + PrtSc** –获取当前窗口的截图并保存到 Pictures 目录。 +**Ctrl + PrtSc** – 获取整个屏幕的截图并存放到剪贴板。 +**Shift + Ctrl + PrtSc** – 获取屏幕的某个区域截图并存放到剪贴板。 +**Ctrl + Alt + PrtSc** – 获取当前窗口的 截图并存放到剪贴板。 + +如上所述,在 Linux 中使用默认的快捷键获取屏幕截图是相当简单的。但如果要在不把屏幕截图导入到其它应用程序的情况下对屏幕截图进行编辑,还是使用屏幕截图工具比较方便。 + +#### **方法 2: 在 Linux 中使用 Flameshot 获取屏幕截图并编辑** + +![flameshot][2] + +功能概述 + + * 注释 (高亮、标示、添加文本、框选) + * 图片模糊 + * 图片裁剪 + * 上传到 Imgur + * 用另一个应用打开截图 + + + +Flameshot 在去年发布到 [GitHub][3],并成为一个引人注目的工具。如果你需要的是一个能够用于标注、模糊、上传到 imgur 的新式截图工具,那么 Flameshot 是一个好的选择。 + +下面将会介绍如何安装 Flameshot 并根据你的偏好进行配置。 + +如果你用的是 Ubuntu,那么只需要在 Ubuntu 软件中心上搜索,就可以找到 Flameshot 进而完成安装了。要是你想使用终端来安装,可以执行以下命令: +``` +sudo apt install flameshot + +``` + +如果你在安装过程中遇到问题,可以按照[官方的安装说明][4]进行操作。安装完成后,你还需要进行配置。尽管可以通过搜索来随时启动 Flameshot,但如果想使用 PrtSc 键触发启动,则需要指定对应的键盘快捷键。以下是相关配置步骤: + + * 进入系统设置中的键盘设置 + * 页面中会列出所有现有的键盘快捷键,拉到底部就会看见一个 **+** 按钮 + * 点击 “+” 按钮添加自定义快捷键并输入以下两个字段: +**名称:** 任意名称均可 +**命令:** /usr/bin/flameshot gui + * 最后将这个快捷操作绑定到 **PrtSc** 键上,可能会提示与系统的截图功能相冲突,但可以忽略掉这个警告。 + + + +配置之后,你的自定义快捷键页面大概会是以下这样: + +![][5] +将键盘快捷键映射到 Flameshot + +### **方法 3: 在 Linux 中使用 Shutter 获取屏幕截图并编辑** + +![][6] + +功能概述: + + * 注释 (高亮、标示、添加文本、框选) + * 图片模糊 + * 图片裁剪 + * 上传到图片网站 + + + +[Shutter][7] 是一个对所有主流 Linux 发行版都适用的屏幕截图工具。尽管最近已经不太更新了,但仍然是操作屏幕截图的一个优秀工具。 + +在使用过程中可能会遇到这个工具的一些缺陷。Shutter 在任何一款最新的 Linux 发行版上最常见的问题就是由于缺少了任务栏上的程序图标,导致默认禁用了编辑屏幕截图的功能。 对于这个缺陷,还是有解决方案的。下面介绍一下如何[在 Shutter 中重新打开这个功能并将程序图标在任务栏上显示出来][8]。问题修复后,就可以使用 Shutter 来快速编辑屏幕截图了。 + +同样地,在软件中心搜索也可以找到进而安装 Shutter,也可以在基于 Ubuntu 的发行版中执行以下命令使用命令行安装: +``` +sudo apt install shutter + +``` + +类似 Flameshot,你可以通过搜索 Shutter 手动启动它,也可以按照相似的方式设置自定义快捷方式以 **PrtSc** 键唤起 Shutter。 + +如果要指定自定义键盘快捷键,只需要执行以下命令: +``` +shutter -f + +``` + +### 方法 4: 在 Linux 中使用 GIMP 获取屏幕截图 + +![][9] + +功能概述: + + * 高级图像编辑功能(缩放、添加滤镜、颜色校正、添加图层、裁剪等) + * 截取某一区域的屏幕截图 + + + +如果需要对屏幕截图进行一些预先编辑,GIMP 是一个不错的选择。 + +通过软件中心可以安装 GIMP。如果在安装时遇到问题,可以参考其[官方网站的安装说明][10]。 + +要使用 GIMP 获取屏幕截图,需要先启动程序,然后通过 **File-> Create-> Screenshot** 导航。 + +打开 Screenshot 选项后,会看到几个控制点来控制屏幕截图范围。点击 **Snap** 截取屏幕截图,图像将自动显示在 GIMP 中可供编辑。 + +### 方法 5: 在 Linux 中使用命令行工具获取屏幕截图 + +这一节内容仅适用于终端爱好者。如果你也喜欢使用终端,可以使用 **GNOME 截图工具**或 **ImageMagick** 或 **Deepin Scrot**,大部分流行的 Linux 发行版中都自带这些工具。 + +要立即获取屏幕截图,可以执行以下命令: + +#### GNOME Screenshot(可用于 GNOME 桌面) +``` +gnome-screenshot + +``` + +GNOME Screenshot 是使用 GNOME 桌面的 Linux 发行版中都自带的一个默认工具。如果需要延时获取屏幕截图,可以执行以下命令(这里的 **5** 是需要延迟的秒数): + +``` +gnome-screenshot -d -5 + +``` + +#### ImageMagick + +如果你的操作系统是 Ubuntu、Mint 或其它流行的 Linux 发行版,一般会自带 [ImageMagick][11] 这个工具。如果没有这个工具,也可以按照[官方安装说明][12]使用安装源来安装。你也可以在终端中执行这个命令: +``` +sudo apt-get install imagemagick + +``` + +安装完成后,执行下面的命令就可以获取到屏幕截图(截取整个屏幕): + +``` +import -window root image.png + +``` + +这里的“image.png”就是屏幕截图文件保存的名称。 + +要获取屏幕一个区域的截图,可以执行以下命令: +``` +import image.png + +``` + +#### Deepin Scrot + +Deepin Scrot 是基于终端的一个较新的截图工具。和前面两个工具类似,一般自带于 Linux 发行版中。如果需要自行安装,可以执行以下命令: +``` +sudo apt-get install scrot + +``` + +安装完成后,使用下面这些命令可以获取屏幕截图。 + +获取整个屏幕的截图: +``` +scrot myimage.png + +``` + +获取屏幕某一区域的截图: +``` +scrot -s myimage.png + +``` + +### 总结 + +以上是一些在 Linux 上的优秀截图工具。当然还有很多截图工具没有提及(例如 [Spectacle][13] for KDE-distros),但相比起来还是上面几个工具更为好用。 + +如果你有比文章中提到的更好的截图工具,欢迎讨论! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/take-screenshot-linux/ + +作者:[Ankush Das][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/Taking-Screenshots-in-Linux.png +[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/flameshot-pic.png +[3]: https://github.com/lupoDharkael/flameshot +[4]: https://github.com/lupoDharkael/flameshot#installation +[5]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/flameshot-config-default.png +[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/shutter-screenshot.jpg +[7]: http://shutter-project.org/ +[8]: https://itsfoss.com/shutter-edit-button-disabled/ +[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/gimp-screenshot.jpg +[10]: https://www.gimp.org/downloads/ +[11]: https://www.imagemagick.org/script/index.php +[12]: https://www.imagemagick.org/script/install-source.php +[13]: https://www.kde.org/applications/graphics/spectacle/ + From c06a2a964a97dd2c24be7945dc3309b3c619ddfe Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 18 Sep 2018 11:58:06 +0800 Subject: [PATCH 283/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Linus,=20His=20Ap?= =?UTF-8?q?ology,=20And=20Why=20We=20Should=20Support=20Him?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Apology, And Why We Should Support Him.md | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md diff --git a/sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md b/sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md new file mode 100644 index 0000000000..c3c159aa30 --- /dev/null +++ b/sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md @@ -0,0 +1,54 @@ +Linus, His Apology, And Why We Should Support Him +====== + +![](https://i1.wp.com/www.jonobacon.com/wp-content/uploads/2018/09/Linus-Torvalds-640x353.jpg?resize=640%2C353&ssl=1) + +Today, Linus Torvalds, the creator of Linux, which powers everything from smartwatches to electrical grids posted [a pretty remarkable note on the kernel mailing list][1]. + +As a little bit of backstory, Linus has sometimes come under fire for the ways in which he has expressed feedback, provided criticism, and reacted to various scenarios on the kernel mailing list. This criticism has been fair in many cases: he has been overly aggressive at times, and while the kernel maintainers are a tight-knit group, the optics, particularly for those new to kernel development has often been pretty bad. + +Like many conflict scenarios, this feedback has been communicated back to him in both constructive and non-constructive ways. Historically he has been seemingly reluctant to really internalize this feedback, I suspect partially because (a) the Linux kernel is a very successful project, and (b) some of the critics have at times gone nuclear at him (which often doesn’t work as a strategy towards defensive people). Well, things changed today. + +In his post today he shared some self-reflection on this feedback: + +> This week people in our community confronted me about my lifetime of not understanding emotions. My flippant attacks in emails have been both unprofessional and uncalled for. Especially at times when I made it personal. In my quest for a better patch, this made sense to me. I know now this was not OK and I am truly sorry. + +He went on to not just share an admission that this has been a problem, but to also share a very personal acceptance that he struggles to understand and engage with people’s emotions: + +> The above is basically a long-winded way to get to the somewhat painful personal admission that hey, I need to change some of my behavior, and I want to apologize to the people that my personal behavior hurt and possibly drove away from kernel development entirely. I am going to take time off and get some assistance on how to understand people’s emotions and respond appropriately. + +His post is sure to light up the open source, Linux, and tech world for the next few weeks. For some it will be celebrated as a step in the right direction. For some it will be too little too late, and their animus will remain. For some they will be cautiously supportive, but defer judgement until they have seen his future behavior demonstrate substantive changes. + +### My Take + +I wouldn’t say I know Linus very closely; we have a casual relationship. I see him at conferences from time to time, and we often bump into each other and catch up. I interviewed him for my book and for the Global Learning XPRIZE. From my experience he is a funny, genuine, friendly guy. Interestingly, and not unusually at all for open source, his online persona is rather different to his in-person persona. I am not going to deny that when I would see these dust-ups on LKML, it didn’t reflect the Linus I know. I chalked it down to a mixture of his struggles with social skills, dogmatic pragmatism, and ego. + +His post today is a pretty remarkable change of posture for him, and I encourage that we as a community support him in making these changes. + +**Accepting these personal challenges is tough, particularly for someone in his position**. Linux is a global phenomenon. It has resulted in billions of dollars of technology creation, powering thousands of companies, and changing the norms around of how software is consumed and created. It is easy to forget that Linux was started by a quiet Finnish kid in his university dorm room. It is important to remember that **just because Linux has scaled elegantly, it doesn’t mean that Linus has been able to**. He isn’t a codebase, he is a human being, and bugs are harder to spot and fix in humans. You can’t just deploy a fix immediately. It takes time to identify the problem and foster and grow a change. The starting point for this is to support people in that desire for change, not re-litigate the ills of the past: that will get us nowhere quickly. + +[![Young Linus Torvalds][2]][3] + +I am also mindful of ego. None of us like to admit we have an ago, but we all do. You don’t get to build one of the most fundamental technologies in the last thirty years and not have an ego. He built it…they came…and a revolution was energized because of what he created. While Linus’s ego is more subtle, and thankfully doesn’t extend to faddish self-promotion, overly expensive suits, and forays into Hollywood (quite the opposite), his ego has naturally resulted in abrupt opinions on how his project should run, sometimes plugging fingers in his ears to particularly challenging viewpoints from others. **His post today is a clear example of him putting Linux as a project ahead of his own personal ego**. + +This is important for a few reasons. Firstly, being in such a public position and accepting your personal flaws isn’t a problem many people face, and isn’t a situation many people handle well. I work with a lot of CEOs, and they often say it is the loneliest job on the planet. I have heard American presidents say the same in interviews. This is because they are the top of the tree with all the responsibility and expectations on their shoulders. Put yourself in Linus’s position: his little project has blown up into a global phenomenon, and he didn’t necessarily have the social tools to be able to handle this change. Ego forces these internal struggles under the surface and to push them down and avoid them. So, to accept them as publicly and openly as he did today is a very firm step in the right direction. Now, the true test will be results, but we need to all provide the breathing space for him to accomplish them. + +So, I would encourage everyone to give Linus a shot. This doesn’t mean the frustrations of the past are erased, and he has acknowledged and apologized for these mistakes as a first step. He has accepted he struggles with understanding other’s emotions, and a desire to help improve this for the betterment of the project and himself. **He is a human, and the best tonic for humans to resolve their own internal struggles is the support and encouragement of other humans**. This is not unique to Linus, but to anyone who faces similar struggles. + +All the best, Linus. + +-------------------------------------------------------------------------------- + +via: https://www.jonobacon.com/2018/09/16/linus-his-apology-and-why-we-should-support-him/ + +作者:[Jono Bacon][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.jonobacon.com/author/admin/ +[1]: https://lkml.org/lkml/2018/9/16/167 +[2]: https://i1.wp.com/www.jonobacon.com/wp-content/uploads/2018/09/linus.jpg?resize=499%2C342&ssl=1 +[3]: https://i1.wp.com/www.jonobacon.com/wp-content/uploads/2018/09/linus.jpg?ssl=1 From e4e88586f4aa54f6aa1fdcec2009f1fd54b6391e Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 18 Sep 2018 12:00:26 +0800 Subject: [PATCH 284/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Freespire=20Linux?= =?UTF-8?q?:=20A=20Great=20Desktop=20for=20the=20Open=20Source=20Purist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...reat Desktop for the Open Source Purist.md | 114 ++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 sources/tech/20180914 Freespire Linux- A Great Desktop for the Open Source Purist.md diff --git a/sources/tech/20180914 Freespire Linux- A Great Desktop for the Open Source Purist.md b/sources/tech/20180914 Freespire Linux- A Great Desktop for the Open Source Purist.md new file mode 100644 index 0000000000..baaf08e92d --- /dev/null +++ b/sources/tech/20180914 Freespire Linux- A Great Desktop for the Open Source Purist.md @@ -0,0 +1,114 @@ +Freespire Linux: A Great Desktop for the Open Source Purist +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/freespire.jpg?itok=ReIrw_11) + +Quick. Click on your Linux desktop menu and scan through the list of installed software. How much of that software is strictly open sources To make matters a bit more complicated, have you installed closed source media codecs (to play the likes of MP3 files perhaps)? Is everything fully open, or do you have a mixture of open and closed source tools? + +If you’re a purist, you probably strive to only use open source tools on your desktop. But how do you know, for certain, that your distribution only includes open source software? Fortunately, a few distributions go out of their way to only include applications that are 100% open. One such distro is [Freespire][1]. + +Does that name sound familiar? It should, as it is closely related to[Linspire][2]. Now we’re talking familiarity. Remember back in the early 2000s, when Walmart sold Linux desktop computers? Those computers were powered by the Linspire operating system. Linspire went above and beyond to create an experience that would be similar to that of Windows—even including the tools to install Windows apps on Linux. That experiment failed, mostly because consumers thought they were getting a Windows desktop machine for a dirt cheap price. After that debacle, Linspire went away for a while. It’s now back, thanks to [PC/OpenSystems LLC][3]. Their goal isn’t to recreate the past but to offer two different flavors of Linux: + + * Linspire—a commercial distribution of Linux that includes proprietary software and does have an associated cost ($39.99 USD for a single license). + + * Freespire—a non-commercial distribution of Linux that only includes open source software and is free to download. + + + + +We’re here to discuss Freespire and why it is an outstanding addition to the Linux community, especially those who strive to use only free and open source software. This version of Freespire (4.0) was released on August 20, 2018, so it’s fresh and ready to go. + +Let’s dig into the operating system and see what makes this a viable candidate for open source fans. + +### Installation + +In keeping with my usual approach, there’s very little reason to even mention the installation of Freespire Linux. There is nothing out of the ordinary here. Download the ISO image, burn it to a USB Drive (or CD/DVD if you’re dealing with older hardware), boot the drive, click the Install icon, answer a few simple questions, and wait for the installation to prompt for a reboot. That’s how far we’ve come with Linux installations… they are simple, and rarely will you have a single issue with the process. In the end, you’ll be presented with a simple (modified) Mate desktop (Figure 1) that makes it easy for any user (of any skill level) to feel right at home. + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/freespire.jpg?itok=ReIrw_11) + +### Software Titles + +Once you’ve logged into the desktop, you’ll find a main menu where you can view all of the installed applications. That list of software includes: + + * Geary + + * Chromium Browser + + * Abiword + + * Gnumeric + + * Calendar + + * Audacious + + * Totem Video Player + + * Software Center + + * Synaptic + + * G-Debi + + + + +Also rolled into the system is support for both Flatpak and Snap applications, so you shouldn’t miss out on any software you need, which brings me to the part when purists might want to look away. + +Just because Freespire is marketed as a purely open source distribution, it doesn’t mean users are locked down to only open source software. In fact, if you open the Software Center, you can do a quick search for Spotify (a closed source application with an available Linux desktop client) and there it is! (Figure 2). + +![Spotify][5] + +Figure 2: The closed source Spotify client available for installation. + +[Used with permission][6] + +Fortunately, for those productive-minded folks, the likes of LibreOffice (which is not installed by default) is open source and can be installed easily from the Software Center. That doesn’t mean you must install other software, but those who need to do serious business-centric work (such as collaborating on documents), will likely want/need to install a more powerful office suite (as Abiword won’t cut it as a business-level word processor). + +For those who tend to work long hours on the Linux desktop and want to protect their eyes from extended strain, Freespire does include a nightlight tool that can adjust the color temperature of the interface. To open this tool, click on the main desktop menu and type night in the Search bar (Figure 3). + +![Night Light][8] + +Figure 3: Opening the Night Light tool. + +[Used with permission][6] + +Once opened, Night Light will automatically adjust the color temperature, based on the time of day. From the notification tray, you can click the icon to suspend Night Light, set it to autostart, and close the service (Figure 4). + +![Night Light controls.][10] + +Figure 4: The Night Light controls. + +[Used with permission][6] + +### Beyond the Mate Desktop + +As is, Mate fans might not exactly recognize the Freespire desktop. The developers have clearly given Mate a significant set of tweaks to make it slightly resemble the Mac OS desktop. It’s not quite as elegant as, say, Elementary OS, but this is certainly an outstanding take on the Linux desktop. Whether you’re a fan of Mate or Mac OS, you should feel immediately at home on the desktop. On the top bar, the developers have included an appmenu that changes, based on what application you have open. Start any app and you’ll find that app’s menu appears in the top bar. This active menu makes the desktop quite efficient. + +### Are you ready for Freespire? + +Every piece of the Freespire puzzle is equally as user-friendly as it is intuitive. The developers of Freespire have gone to great lengths to make this pure open source distribution a treat to use. Even if a 100% open source desktop isn’t your thing, Freespire is still a worthy contender in the world of desktop Linux. It’s clean and stable (as it’s based on Ubuntu 18.04) and able to help you be efficient and productive on the desktop. + +Learn more about Linux through the free ["Introduction to Linux" ][11]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/9/freespire-linux-great-desktop-open-source-purist + +作者:[Jack Wallen][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/jlwallen +[1]: https://www.freespirelinux.com/ +[2]: https://www.linspirelinux.com/ +[3]: https://www.pc-opensystems.com +[5]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/freespire_2.jpg?itok=zcr94Dk6 (Spotify) +[6]: /licenses/category/used-permission +[8]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/freespire_3.jpg?itok=aZYtBPgE (Night Light) +[9]: /files/images/freespire4jpg +[10]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/freespire_4.jpg?itok=JCcQwmJ5 (Night Light controls.) +[11]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From e1685a35f5162c90ec4f82e8786457285061920b Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 18 Sep 2018 12:02:00 +0800 Subject: [PATCH 285/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Getting=20started?= =?UTF-8?q?=20with=20openmediavault:=20A=20home=20NAS=20solution?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ith openmediavault- A home NAS solution.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 sources/tech/20180917 Getting started with openmediavault- A home NAS solution.md diff --git a/sources/tech/20180917 Getting started with openmediavault- A home NAS solution.md b/sources/tech/20180917 Getting started with openmediavault- A home NAS solution.md new file mode 100644 index 0000000000..7f5b29c092 --- /dev/null +++ b/sources/tech/20180917 Getting started with openmediavault- A home NAS solution.md @@ -0,0 +1,74 @@ +Getting started with openmediavault: A home NAS solution +====== +This network-attached file server offers a solid array of features and is easy to install and configure. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-cloud.png?itok=vz0PIDDS) + +With so many cloud storage options readily available, some folks might question the value of having a home NAS (network-attached storage) server. After all, with your files on the cloud, you don't have to worry about managing the maintenance, updates, and security of your own server. + +But that's not entirely true, is it? You have a home network, so you've got to pay at least some attention to that network's health and security. Assuming you're already keeping on top of that, then [a home NAS][1] really isn't adding that much additional hassle. And there are all kinds of benefits to gain from that minor amount of work. + +You can have a local backup of every computer in your house (you can also back up off-site). Have a media server that holds movies, music, and photos regardless of whether your internet connection flakes out. Work on large files on multiple computers in your home without waiting for them to traverse from some random computer somewhere else on the internet. Plus, you can have your NAS pull double duty with other services, like hosting local email or a household wiki. Perhaps most importantly, with a home NAS, your data is your data—under your control and always accessible. + +The follow-on question is which NAS solution to choose. Sure, you could buy a pre-built solution and call it a day, but what fun is that? And practically speaking, although it's great to have an appliance that handles everything for you, it's often better to have a rig that you can fix and upgrade yourself. This is the situation I found myself in recently. I chose to install and set up [openmediavault][2]. + +### Why openmediavault? + +There are a few open source NAS solutions out there, some arguably more popular than openmediavault. When I asked around, for instance, [FreeNAS][3] was recommended the most. So why didn't I go with that? After all, it is more widely used, includes more features, and offers more support options, [according to a comparison on the FreeNAS website][4]. That's certainly all true. But openmediavault is no slouch. It's actually based on an earlier version of FreeNAS, and while its numbers are lower in terms of downloads and features, they're more than adequate for my needs. + +Another factor was a simple matter of comfort. Openmediavault's underlying operating system is [Debian][5], whereas FreeNAS sits atop [FreeBSD][6]. I'm personally not as familiar with FreeBSD, so that would make it more difficult for me to fix things if my NAS starts misbehaving. It also makes it more difficult for me to tweak things or add my own services to the machine if I want. Sure, I could learn FreeBSD and get more familiar with it, but I'm already home-building this NAS; I've found that projects tend to be more successful if you limit the number of "learning opportunities" you give yourself to complete them. + +Every situation is different, of course, so do your research and decide what seems to be the best fit for you. FreeNAS looks like the right solution for a lot of people. Openmediavault was the right one for me. + +### Installation and configuration + +The installation process is pretty well covered in the [openmediavault documentation][7], so I won't rehash that here. If you've ever installed a Linux distribution, most of the steps should look familiar to you (though with a somewhat uglier [Ncurses][8] interface than you might see on modern distributions). I installed it using the [dedicated drive][9] instructions. However, those instructions, while good, are rather spartan. When you're done, you have a base system installed, but there's more to do before you can actually use your NAS to store any files. For instance, the dedicated drive instructions install openmediavault on a hard drive, but that's the operating system drive, not the one with the shared space that's accessible to other computers on your network. You need to walk yourself through setting that up and configuring it. + +The first thing you should do is load up the administrative web interface and change the default password. This password is different from the root password you set during the installation process. It's the administrative account for the web interface, and the default username and password are `admin` and `openmediavault`, respectively—definitely something you'll want to change immediately after logging in. + +#### Set up your drives + +Once you've installed openmediavault, you need it to actually do stuff for you. The first logical step is to set up the drives that you're going to use for storage. I'm assuming that you've already got them physically installed, so all you have to do at this point is get openmediavault to recognize them and configure them. The first step is making sure those disks are visible. The sidebar menu has a lot of options, but it's very sensibly organized. Go to **Storage - > Disks**. Once you click that, you should see all of the drives you've installed on your server, including the one where you actually installed openmediavault. If you don't see all of your drives there, click the Scan button to see if it picks them up. Usually, it's not a problem. + +You could mount these drives individually to set them up as your file share, but for a file server, you'll want some redundancy. You want to be able to treat multiple drives as a single volume and recover your data if a drive fails or add new drives when you start running out of space. That means you're going to want a [RAID][10]. The topic of what specific type of RAID configuration you want is a deep rabbit hole that deserves an article all of its own (and many have been written), but suffice it to say that you'll need more than one drive, and in the best case, all of your drives store the same amount of data. + +Openmediavault supports all standard RAID levels, so you're good to go there. Configure your RAID in **Storage - > RAID Management**. Configuration is absurdly simple: Click the Create button, choose the disks you want in your RAID array, the RAID level you want to use, and a name for the array. Openmediavault handles the rest for you. There's no messing around at the command line, trying to remember which flags to use with the `mdadm` command. In my specific case, I have six 2-TB drives that I've set up as RAID 10. + +With your RAID set up, you've almost got a place to store things. You just need to set up a file system. Just like your desktop computer, a hard drive doesn't do you any good until you format it. So the next place to go in openmediavault's control panel is **Storage - > File Systems**. Just like configuring your RAID, click the Create button and follow the prompts. In this case, you choose the device to format. If you have only the one RAID on your server, it should be something like `md0`. You'll also need to choose the filesystem type. If you're not sure, just use the standard ext4 type. + +#### Define your shares + +Sweet! You've got a place to store files. Now you just need to make it visible on your home network. Configure this from the **Services** section of the openmediavault control panel. When it comes to setting up a file share on a network, there are really two main choices: NFS or SMB/CIFS. As a rule of thumb, if all of the computers on your network are running Linux distributions, then you're probably better off using NFS. However, if your home network is a mixed environment with a combination of Linux, Windows, Mac OS, and embedded devices, then SMB/CIFS is probably the right choice. + +These options aren't mutually exclusive. You could actually run both services on your server and get the best of both worlds. Or you could mix it up if you have specific devices dedicated to particular tasks. Whatever your usage scenario, configuring these services is dirt simple. Click on the service you want, enable it from its Settings, and define the shared folders you want visible on the network. In the case of SMB/CIFS shares, there are a few more settings available than with NFS, but most of the defaults are fine to start with. The cool thing is that since it's so easy to configure, it's also pretty easy to change on the fly. + +#### Configure users + +You're almost done. You've configured your drives in a RAID. You've formatted that RAID with a file system. And you've defined shared folders on that formatted RAID. The only thing left is saying who can access those shares and how much. This is handled from the **Access Rights Management** section. Use the **User** and **Group** sections to define the users who connect to your shared folders and the permissions they have with the files in those folders. + +Once you do that, you're pretty much good to go. You'll need to access your shares from your various client machines, but that's a topic for another article. + +Have fun! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/openmediavault + +作者:[Jason van Gumster][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mairin +[1]: https://opensource.com/article/18/8/automate-backups-raspberry-pi +[2]: https://openmediavault.org +[3]: https://freenas.org +[4]: http://www.freenas.org/freenas-vs-openmediavault/ +[5]: https://www.debian.org/ +[6]: https://www.freebsd.org/ +[7]: https://openmediavault.readthedocs.io/en/latest/installation/index.html +[8]: https://invisible-island.net/ncurses/ +[9]: https://openmediavault.readthedocs.io/en/latest/installation/via_iso.html +[10]: https://en.wikipedia.org/wiki/RAID From b0813db05d9b32be52ec749ad056f3f93363e40b Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 18 Sep 2018 12:04:00 +0800 Subject: [PATCH 286/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20gaming=20tu?= =?UTF-8?q?rned=20me=20into=20a=20coder?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...80917 How gaming turned me into a coder.md | 103 ++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 sources/talk/20180917 How gaming turned me into a coder.md diff --git a/sources/talk/20180917 How gaming turned me into a coder.md b/sources/talk/20180917 How gaming turned me into a coder.md new file mode 100644 index 0000000000..f5675c4628 --- /dev/null +++ b/sources/talk/20180917 How gaming turned me into a coder.md @@ -0,0 +1,103 @@ +How gaming turned me into a coder +====== + +Text-based adventure gaming leads to a satisfying career in tech. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/keyboard_numbers_letters_type_game.jpg?itok=fLlWGw1K) + +I think the first word I learned to type fast—and I mean really fast—was "fireball." + +Like most of us, I started my typing career with a "hunt-and-peck" technique, using my index fingers and keeping my eyes focused on the keyboard to find letters as I needed them. It's not a technique that allows you to read and write at the same time; you might call it half-duplex. It was okay for typing **cd** and **dir** , but it wasn't nearly fast enough to get ahead in the game. Especially if that game was a MUD. + +### Gaming with multi-user dungeons + +MUD is short for multi-user dungeon. Or multi-user domain, depending on who (and when) you ask. MUDs are text-based adventure games, like [Colossal Cave Adventure][1] and Zork, which you may have heard about in Season 2 [Episode 1][2] of [Command Line Heroes][3]. But MUDs have an extra twist: you aren't the only person playing them. They allow you to group with others to tackle particularly nasty beasts, trade goods, and make new friends. They were the great granddaddies of modern massively multiplayer online role-playing games (MMORPGs) like Everquest and World of Warcraft. And, for an aspiring command-line hero, they offered an experience those modern games still don't. + +My "home MUD" was NyxMud, which you could access by telnetting to port 2000 of nyx.cs.du.edu. It was the first command line I ever mastered. In a lot of ways, it allowed me to be a hero—or at least play the part of one. + +One special quality of NyxMud was that every time you connected to play, you started with an empty inventory. The gold you collected was still there from your last session, but none of your hard-won weapons, armor, or magical items were. So, at the end of every session, you had to make it back to a store to sell everything… and you would get a fraction of what you paid. If you were killed, the first player who encountered your lifeless body could take everything you had. + +![dying and losing everything in a MUD.][5] + +This shows what it looks like when you die and lose everything in a MUD + +This made the game extremely sticky. Selling everything and quitting was a horrible thing to do, fiscally speaking. It meant that your session had to be profitable. If you didn't earn enough gold through looting and quests between the time you bought and sold your gear, you wouldn't be able to equip yourself as well the next time you played. If you died, it was even worse: You might find yourself killing balls of slime with a newbie sword as you scraped together enough gold for better gear. + +I never wanted to "pay the store tax" by selling my gear, which meant a lot of late nights and sleeping through morning biology classes. Every modern game designer wants you to say, "I can't have dinner now, Dad, I have to keep playing or I'm in big trouble." NyxMud had me so hooked that I was saying that several decades ago. + +So when it came time to "cast fireball" or die an imminent and ruinous death, I was forced to learn how to type properly. It also forced me to take a social approach to the game—having friends around to fight off scavengers allowed me to reclaim my gear when I died. + +Command-line heroes all have some things in common: They work with others and they type wicked fast. NyxMud trained me to do both. + +### From gamer to creator + +NyxMud was not the largest MUD by any measure. But it was still an expansive world filled with hundreds of areas and dozens of epic adventures, each one tailored to a different level of a player's advancement. Over time, it became apparent that not all these areas were created by the same person. The term "user-generated content" was yet to be invented, but the concept was dead simple even to my young mind: This entire world was created by a group of people, other players. + +Once you completed each of the challenging quests and achieved level 20, you became a wizard. This was a singularity of sorts, beyond which existed a reality known only to a few. During lunch breaks at school, my circle of friends would muse about the powers of a wizard; you see, we knew wizards could create rooms, beasts, items, and quests. We knew they could kill players at will. We really didn't know much else about their powers. The whole thing was shrouded in mystery. + +In our group of high school friends, Eddie was the first to become a wizard. His flaunting and taunting threw us into overdrive, and Jared was quick to follow. I was last, but only by a day or two. Now that 25 years have passed, let's just call it a three-way tie. We discovered it was pretty much what we thought. We could create rooms, beasts, items, and quests. We could kill players. Oh, and we could become invisible. In NyxMud, that was just about it. + +![a wizard’s private workroom][7] + +This shows a wizard’s private workroom. + +Wizards used the Wand of Creation, an item invented by Quasi (rhymed with "crazy"), the grand wizard. He alone had access to the code for the engine, due to a strict policy set by the administrator of the Nyx system where it ran. So, he created a complicated, magical object that would allow users to generate new game elements. This wand, when invoked, ran the wizard through a menu-based workflow for creating rooms and objects, establishing quest objectives, and designing terrible monsters. + +Having that magical wand was enough. I immediately set to work creating new lands and grand adventures across a series of islands, each with a different, exotic climate and theme. I found immense pleasure in hovering, invisible, as the savage beasts from my imagination would slay intrepid adventurers over and over again. But it was even better to see players persevere after a hard battle, knowing I had tweaked and tuned my quests to be just within the realm of possibility. + +Being accepted into this elite group of creators was one of the more rewarding and satisfying moments of my young life. Each new wizard would have to pass my test, spending countless hours and sleepless nights, just as I did, to complete the quests of the wizards before me. I had proven my value through dedication and contribution. It was just a game, but it was also a community—the first one I encountered, and the one that showed me how powerful a properly run [meritocracy][8] could be. + +### From creator to coder + +NyxMud was based on the LPMud codebase, which was created by Lars Pensjö. LPMud was not the first MUD software developed, but it contained one very important innovation: It allowed players to code the game from within the game. It accomplished this by separating the mudlib, which contained all the content and user-facing functionality, from the driver, which acted as a real-time interpreter for the mudlib and provided access to basic network and storage resources. This architecture meant the mudlib could be edited on-the-fly by virtually untrusted people (e.g., players like me) who could augment the game experience without being able to do anything particularly harmful to the server it was running on. The driver provided an "air gap." + +This air gap was not enough for NyxMud; it was allowed to exist only if a single person could be trusted to write all the code. In most LPMud systems, players who became wizards could use **ls** , **cd** , and **ed** to traverse the mudlib and modify files, all from the same command line they had used countless times for casting fireballs and drinking potions. Quasi went to great lengths to modify the Nyx mudlib so wizards couldn't traipse around the system with a full set of sharp tools. The Wand of Creation was born. + +As a wizard who hadn't played any other MUDs, I didn't miss what I never had. Besides, I didn't have a way to access any systems at the time—telnet was disabled on Nyx, which was my only connection to the internet. But I did have access to Usenet, which provided me with [The Totally Unofficial List of Internet Muds][9]. It was clear there was more of the MUD universe for me to discover. I read all the documentation about mudlibs I could get my hands on and got some exposure to [LPC][10], the niche programming language used to create new content. + +I convinced my dad to make an investment in my future by paying for a shell account at Netcom (remember that?). With that account, I could connect to any MUD I wanted, and, based on several strong recommendations, I chose Viking MUD. It still [exists today][11]. It was a real MUD, the bleeding edge, and it showcased the true potential of a universe built with code instead of the limited menu system of a magical wand. But, to be honest, I never got very far as a player. I really wanted to learn how to code, and I didn't want to slay slimeballs with a noobsword for hours to get there. + +There was a very small window of time—between February and August 1992, according to Lauren P. Burka's [Mud Timeline][12]—where the perfect place existed for my exploration. The Mud Institute (TMI for short) was a very special MUD designed to teach people how to program in LPC, illuminating the darkest corners of the mudlib. It offered immediate omnipotence to all who applied and built a community for the development of a new generation of LPMuds. + +![a snippet of code from the wizard's workroom][14] + +This is a snippet of code from the wizard's workroom. + +This was my first exposure to C programming, as LPC was essentially a flavor of C that shared the same types, control structures, and syntax. It was C with training wheels, designed for rapid creation of content but allowing coders to develop intricate game scenarios (if they had the chops). I had always seen the curly brace on my keyboard, and now I knew what it was used for. The only thing I can remember creating was a special vending machine, somewhat inspired by the Wand of Creation, that would create the monster of your choice on-the-spot. + +TMI was not a long-lasting phenomenon; in fact, it was gone almost before I had a chance to discover it. It quickly abandoned its educational charter, although its efforts were ultimately productive with the release of [MudOS][15]—which still lives through its modern-day descendant, [FluffOS][16]. But what a treasure trove of knowledge about a highly specific subject! Immediately after logging in, I was presented with a complete set of developer tools, a library of instructional materials, and a ton of interesting sample code to learn from. + +I never talked to anyone or asked for any help, and I never had to. The community had published just enough resources for me to get started by myself. I was able to learn the basics of structured programming without a textbook or teacher, all within the context of a fantastical computer game. As a result, I have had a long and (mostly) fulfilling career in technology. + +The line from Field of Dreams, "if you build it, they will come," is almost certainly untrue for communities.** **The folks at The Mud Institute built the makings of a great community, but I can't say they were successful. They didn't become a widely known wizarding school—in fact, it's really hard to find any information about TMI at all. If you build it, they may not come; if they do, you may still fail. But it still accomplished something wonderful that its creators never thought to predict: It got me excited about programming. + +For more on the gamer-to-coder phenomenon and its effect on open source community culture, check out [Episode 1 of Season 2 of Command Line Heroes][2]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/gamer-coder + +作者:[Ross Turk][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rossturk +[1]: https://opensource.com/article/17/6/revisit-colossal-cave-adventure-open-adventure +[2]: https://www.redhat.com/en/command-line-heroes/season-2/press-start +[3]: https://www.redhat.com/en/command-line-heroes +[4]: /file/409311 +[5]: https://opensource.com/sites/default/files/uploads/sourcecode_wizard_workroom.png (dying and losing everything in a MUD) +[6]: /file/409306 +[7]: https://opensource.com/sites/default/files/uploads/wizard_workroom.png (a wizard’s private workroom) +[8]: https://opensource.com/open-organization/16/8/how-make-meritocracy-work +[9]: http://textfiles.com/internet/mudlist.txt +[10]: https://en.wikipedia.org/wiki/LPC_(programming_language) +[11]: https://www.vikingmud.org +[12]: http://www.linnaean.org/~lpb/muddex/mudline.html +[13]: /file/409301 +[14]: https://opensource.com/sites/default/files/uploads/firstroom_newplayer.png (a snippet of code from the wizard's workroom) +[15]: https://en.wikipedia.org/wiki/MudOS +[16]: https://github.com/fluffos/fluffos From 4ec4f5d7e6e12ea3b399766db9e70ef033b46ac4 Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Tue, 18 Sep 2018 15:03:21 +0800 Subject: [PATCH 287/455] translated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 3个开源日志聚合工具 --- ...910 3 open source log aggregation tools.md | 112 ----------------- ...910 3 open source log aggregation tools.md | 117 ++++++++++++++++++ 2 files changed, 117 insertions(+), 112 deletions(-) delete mode 100644 sources/tech/20180910 3 open source log aggregation tools.md create mode 100644 translated/tech/20180910 3 open source log aggregation tools.md diff --git a/sources/tech/20180910 3 open source log aggregation tools.md b/sources/tech/20180910 3 open source log aggregation tools.md deleted file mode 100644 index de41debf57..0000000000 --- a/sources/tech/20180910 3 open source log aggregation tools.md +++ /dev/null @@ -1,112 +0,0 @@ -heguangzhi Translating - -3 open source log aggregation tools -====== -Log aggregation systems can help with troubleshooting and other tasks. Here are three top options. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr) - -How is metrics aggregation different from log aggregation? Can’t logs include metrics? Can’t log aggregation systems do the same things as metrics aggregation systems? - -These are questions I hear often. I’ve also seen vendors pitching their log aggregation system as the solution to all observability problems. Log aggregation is a valuable tool, but it isn’t normally a good tool for time-series data. - -A couple of valuable features in a time-series metrics aggregation system are the regular interval and the storage system customized specifically for time-series data. The regular interval allows a user to derive real mathematical results consistently. If a log aggregation system is collecting metrics in a regular interval, it can potentially work the same way. However, the storage system isn’t optimized for the types of queries that are typical in a metrics aggregation system. These queries will take more resources and time to process using storage systems found in log aggregation tools. - -So, we know a log aggregation system is likely not suitable for time-series data, but what is it good for? A log aggregation system is a great place for collecting event data. These are irregular activities that are significant. An example might be access logs for a web service. These are significant because we want to know what is accessing our systems and when. Another example would be an application error condition—because it is not a normal operating condition, it might be valuable during troubleshooting. - -A handful of rules for logging: - - * DO include a timestamp - * DO format in JSON - * DON’T log insignificant events - * DO log all application errors - * MAYBE log warnings - * DO turn on logging - * DO write messages in a human-readable form - * DON’T log informational data in production - * DON’T log anything a human can’t read or react to - - - -### Cloud costs - -When investigating log aggregation tools, the cloud might seem like an attractive option. However, it can come with significant costs. Logs represent a lot of data when aggregated across hundreds or thousands of hosts and applications. The ingestion, storage, and retrieval of that data are expensive in cloud-based systems. - -As a point of reference from a real system, a collection of around 500 nodes with a few hundred apps results in 200GB of log data per day. There’s probably room for improvement in that system, but even reducing it by half will cost nearly $10,000 per month in many SaaS offerings. This often includes retention of only 30 days, which isn’t very long if you want to look at trending data year-over-year. - -This isn’t to discourage the use of these systems, as they can be very valuable—especially for smaller organizations. The purpose is to point out that there could be significant costs, and it can be discouraging when they are realized. The rest of this article will focus on open source and commercial solutions that are self-hosted. - -### Tool options - -#### ELK - -[ELK][1], short for Elasticsearch, Logstash, and Kibana, is the most popular open source log aggregation tool on the market. It’s used by Netflix, Facebook, Microsoft, LinkedIn, and Cisco. The three components are all developed and maintained by [Elastic][2]. [Elasticsearch][3] is essentially a NoSQL, Lucene search engine implementation. [Logstash][4] is a log pipeline system that can ingest data, transform it, and load it into a store like Elasticsearch. [Kibana][5] is a visualization layer on top of Elasticsearch. - -A few years ago, Beats were introduced. Beats are data collectors. They simplify the process of shipping data to Logstash. Instead of needing to understand the proper syntax of each type of log, a user can install a Beat that will export NGINX logs or Envoy proxy logs properly so they can be used effectively within Elasticsearch. - -When installing a production-level ELK stack, a few other pieces might be included, like [Kafka][6], [Redis][7], and [NGINX][8]. Also, it is common to replace Logstash with Fluentd, which we’ll discuss later. This system can be complex to operate, which in its early days led to a lot of problems and complaints. These have largely been fixed, but it’s still a complex system, so you might not want to try it if you’re a smaller operation. - -That said, there are services available so you don’t have to worry about that. [Logz.io][9] will run it for you, but its list pricing is a little steep if you have a lot of data. Of course, you’re probably smaller and may not have a lot of data. If you can’t afford Logz.io, you could look at something like [AWS Elasticsearch Service][10] (ES). ES is a service Amazon Web Services (AWS) offers that makes it very easy to get Elasticsearch working quickly. It also has tooling to get all AWS logs into ES using Lambda and S3. This is a much cheaper option, but there is some management required and there are a few limitations. - -Elastic, the parent company of the stack, [offers][11] a more robust product that uses the open core model, which provides additional options around analytics tools, and reporting. It can also be hosted on Google Cloud Platform or AWS. This might be the best option, as this combination of tools and hosting platforms offers a cheaper solution than most SaaS options and still provides a lot of value. This system could effectively replace or give you the capability of a [security information and event management][12] (SIEM) system. - -The ELK stack also offers great visualization tools through Kibana, but it lacks an alerting function. Elastic provides alerting functionality within the paid X-Pack add-on, but there is nothing built in for the open source system. Yelp has created a solution to this problem, called [ElastAlert][13], and there are probably others. This additional piece of software is fairly robust, but it increases the complexity of an already complex system. - -#### Graylog - -[Graylog][14] has recently risen in popularity, but it got its start when Lennart Koopmann created it back in 2010. A company was born with the same name two years later. Despite its increasing use, it still lags far behind the ELK stack. This also means it has fewer community-developed features, but it can use the same Beats that the ELK stack uses. Graylog has gained praise in the Go community with the introduction of the Graylog Collector Sidecar written in [Go][15]. - -Graylog uses Elasticsearch, [MongoDB][16], and the Graylog Server under the hood. This makes it as complex to run as the ELK stack and maybe a little more. However, Graylog comes with alerting built into the open source version, as well as several other notable features like streaming, message rewriting, and geolocation. - -The streaming feature allows for data to be routed to specific Streams in real time while they are being processed. With this feature, a user can see all database errors in a single Stream and web server errors in a different Stream. Alerts can even be based on these Streams as new items are added or when a threshold is exceeded. Latency is probably one of the biggest issues with log aggregation systems, and Streams eliminate that issue in Graylog. As soon as the log comes in, it can be routed to other systems through a Stream without being processed fully. - -The message rewriting feature uses the open source rules engine [Drools][17]. This allows all incoming messages to be evaluated against a user-defined rules file enabling a message to be dropped (called Blacklisting), a field to be added or removed, or the message to be modified. - -The coolest feature might be Graylog’s geolocation capability, which supports plotting IP addresses on a map. This is a fairly common feature and is available in Kibana as well, but it adds a lot of value—especially if you want to use this as your SIEM system. The geolocation functionality is provided in the open source version of the system. - -Graylog, the company, charges for support on the open source version if you want it. It also offers an open core model for its Enterprise version that offers archiving, audit logging, and additional support. There aren’t many other options for support or hosting, so you’ll likely be on your own if you don’t use Graylog (the company). - -#### Fluentd - -[Fluentd][18] was developed at [Treasure Data][19], and the [CNCF][20] has adopted it as an Incubating project. It was written in C and Ruby and is recommended by [AWS][21] and [Google Cloud][22]. Fluentd has become a common replacement for Logstash in many installations. It acts as a local aggregator to collect all node logs and send them off to central storage systems. It is not a log aggregation system. - -It uses a robust plugin system to provide quick and easy integrations with different data sources and data outputs. Since there are over 500 plugins available, most of your use cases should be covered. If they aren’t, this sounds like an opportunity to contribute back to the open source community. - -Fluentd is a common choice in Kubernetes environments due to its low memory requirements (just tens of megabytes) and its high throughput. In an environment like [Kubernetes][23], where each pod has a Fluentd sidecar, memory consumption will increase linearly with each new pod created. Using Fluentd will drastically reduce your system utilization. This is becoming a common problem with tools developed in Java that are intended to run one per node where the memory overhead hasn’t been a major issue. - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/open-source-log-aggregation-tools - -作者:[Dan Barker][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/barkerd427 -[1]: https://www.elastic.co/webinars/introduction-elk-stack -[2]: https://www.elastic.co/ -[3]: https://www.elastic.co/products/elasticsearch -[4]: https://www.elastic.co/products/logstash -[5]: https://www.elastic.co/products/kibana -[6]: http://kafka.apache.org/ -[7]: https://redis.io/ -[8]: https://www.nginx.com/ -[9]: https://logz.io/ -[10]: https://aws.amazon.com/elasticsearch-service/ -[11]: https://www.elastic.co/cloud -[12]: https://en.wikipedia.org/wiki/Security_information_and_event_management -[13]: https://github.com/Yelp/elastalert -[14]: https://www.graylog.org/ -[15]: https://opensource.com/tags/go -[16]: https://www.mongodb.com/ -[17]: https://www.drools.org/ -[18]: https://www.fluentd.org/ -[19]: https://www.treasuredata.com/ -[20]: https://www.cncf.io/ -[21]: https://aws.amazon.com/blogs/aws/all-your-data-fluentd/ -[22]: https://cloud.google.com/logging/docs/agent/ -[23]: https://opensource.com/resources/what-is-kubernetes diff --git a/translated/tech/20180910 3 open source log aggregation tools.md b/translated/tech/20180910 3 open source log aggregation tools.md new file mode 100644 index 0000000000..99a365e042 --- /dev/null +++ b/translated/tech/20180910 3 open source log aggregation tools.md @@ -0,0 +1,117 @@ +heguangzhi Translating + + +3个开源日志聚合工具 +====== + +日志聚合系统可以帮助我们故障排除并进行其他的任务。以下是三个主要工具介绍。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr) + + + +指标聚合与日志聚合有何不同?日志不能包括指标吗?日志聚合系统不能做与指标聚合系统相同的事情吗? + +这些是我经常听到的问题。我还看到供应商推销他们的日志聚合系统作为所有可观察问题的解决方案。日志聚合是一个有价值的工具,但它通常对时间序列数据的支持不够好。 + +时间序列指标聚合系统中几个有价值的功能为规则间隔与专门为时间序列数据定制的存储系统。规则间隔允许用户一次性地导出真实的数据结果。如果要求日志聚合系统定期收集指标数据,它也可以。但是,它的存储系统没有针对指标聚合系统中典型的查询类型进行优化。使用日志聚合工具中的存储系统处理这些查询将花费更多的资源和时间。 + +所以,我们知道日志聚合系统可能不适合时间序列数据,但是它有什么好处呢?日志聚合系统是收集事件数据的好地方。这些是非常重要的不规则活动。最好的例子为 web 服务的访问日志。这些都很重要,因为我们想知道什么东西正在访问我们的系统,什么时候访问。另一个例子是应用程序错误记录——因为它不是正常的操作记录,所以在故障排除过程中可能很有价值的。 + +日志记录的一些规则: + + * 包含时间戳 + * 包含 JSON 格式 + * 不记录无关紧要的事件 + * 记录所有应用程序的错误 + * 记录警告错误 + * 日志记录开关 + * 以可读的形式记录信息 + * 不在生产环境中记录信息 + * 不记录任何无法阅读或无反馈的内容 + + +### 云的成本 + +当研究日志聚合工具时,云可能看起来是一个有吸引力的选择。然而,这可能会带来巨大的成本。当跨数百或数千台主机和应用程序聚合时,日志数据是大量的。在基于云的系统中,数据的接收、存储和检索是昂贵的。 + +作为一个真实的系统,大约500个节点和几百个应用程序的集合每天产生 200GB 的日志数据。这个系统可能还有改进的空间,但是在许多 SaaS 产品中,即使将它减少一半,每月也要花费将近10,000美元。这通常包括仅保留30天,如果你想查看一年一年的趋势数据,就不可能了。 + +并不是要不使用这些系统,尤其是对于较小的组织它们可能非常有价值的。目的是指出可能会有很大的成本,当这些成本达到时,就可能令人非常的沮丧。本文的其余部分将集中讨论自托管的开源和商业解决方案。 + + +### 工具选择 + +#### ELK + +[ELK][1] ,简称 Elasticsearch、Logstash 和 Kibana,是最流行的开源日志聚合工具。它被Netflix、Facebook、微软、LinkedIn 和思科使用。这三个组件都是由 [Elastic][2] 开发和维护的。[Elasticsearch][3] 本质上是一个NoSQL,Lucene 搜索引擎实现的。[Logstash][4] 是一个日志管道系统,可以接收数据,转换数据,并将其加载到像 Elasticsearch 这样的应用中。[Kibana][5] 是 Elasticsearch 之上的可视化层。 + +几年前,Beats 被引入。Beats 是数据采集器。它们简化了将数据运送到日志存储的过程。用户不需要了解每种日志的正确语法,而是可以安装一个 Beats 来正确导出 NGINX 日志或代理日志,以便在Elasticsearch 中有效地使用它们。 + +安装生产环境级 ELK stack 时,可能会包括其他几个部分,如 [Kafka][6], [Redis][7], and [NGINX][8]。此外,用 Fluentd 替换 Logstash 也很常见,我们将在后面讨论。这个系统操作起来很复杂,这在早期导致很多问题和投诉。目前,这些基本上已经被修复,不过它仍然是一个复杂的系统,如果你使用少部分的功能,建议不要使用它了。 + +也就是说,服务是可用的,所以你不必担心。[Logz.io][9] 也可以使用,但是如果你有很多数据,它的标价有点高。当然,你可能没有很多数据,来使用用它。如果你买不起 Logz.io,你可以看看 [AWS Elasticsearch Service][10] (ES) 。ES 是 Amazon Web Services (AWS) 提供的一项服务,它使得 Elasticsearch 很容易快速工作。它还拥有使用 Lambda 和 S3 将所有AWS日志记录到 ES 的工具。这是一个更便宜的选择,但是需要一些管理操作,并有一些功能限制。 + + +Elastic [offers][11] 的母公司提供一款更强大的产品,它使用开放核心模型,为分析工具和报告提供了额外的选项。它也可以在谷歌云平台或 AWS 上托管。由于这种工具和托管平台的组合提供了比大多数 SaaS 选项更加便宜,这将是最好的选择并且具有很大的价值。该系统可以有效地取代或提供[security information and event management][12] ( SIEM )系统的功能。 + +ELK 栈通过 Kibana 提供了很好的可视化工具,但是它缺少警报功能。Elastic 在付费的 X-Pack 插件中提供了提醒功能,但是在开源系统没有内置任何功能。Yelp 已经开发了一种解决这个问题的方法,[ElastAlert][13], 不过还有其他方式。这个额外的软件相当健壮,但是它增加了已经复杂的系统的复杂性。 + +#### Graylog + +[Graylog][14] 最近越来越受欢迎,但它是在2010年 Lennart Koopmann 创建并开发的。两年后,一家公司以同样的名字诞生了。尽管它的使用者越来越多,但仍然远远落后于 ELK 栈。这也意味着它具有较少的社区开发特征,但是它可以使用与 ELK stack 相同的 Beats 。Graylog 由于 Graylog Collector Sidecar 使用 [Go][15] 编写所以在 Go 社区赢得了赞誉。 + +Graylog 使用 Elasticsearch、[MongoDB][16] 并且 提供 Graylog Server 。这使得它像ELK 栈一样复杂,也许还要复杂一些。然而,Graylog 附带了内置于开源版本中的报警功能,以及其他一些值得注意的功能,如 streaming 、消息重写 和 地理定位。 + +streaming 能允许数据在被处理时被实时路由到特定的 Streams。使用此功能,用户可以在单个Stream 中看到所有数据库错误,在不同的 Stream 中看到 web 服务器错误。当添加新项目或超过阈值时,甚至可以基于这些 Stream 提供警报。延迟可能是日志聚合系统中最大的问题之一,Stream消除了灰色日志中的这一问题。一旦日志进入,它就可以通过 Stream 路由到其他系统,而无需全部处理。 + +消息重写功能使用开源规则引擎 [Drools][17] 。允许根据用户定义的规则文件评估所有传入的消息,从而可以删除消息(称为黑名单)、添加或删除字段或修改消息。 + +Graylog 最酷的功能是它的地理定位功能,它支持在地图上绘制 IP 地址。这是一个相当常见的功能,在 Kibana 也可以这样使用,但是它增加了很多价值——特别是如果你想将它用作 SIEM 系统。地理定位功能在系统的开源版本中提供。 + +Graylog 如果你想要的话,它会对开源版本的支持收费。它还为其企业版提供了一个开放的核心模型,提供存档、审计日志记录和其他支持。如果你不需要 Graylog (the company) 支持或托管的,你可以独立使用。 + +#### Fluentd + +[Fluentd][18] 是 [Treasure Data][19] 开发的,[CNCF][20] 已经将它作为一个孵化项目。它是用 C 和 Ruby 编写的,并由[AWS][21] 和 [Google Cloud][22]推荐。fluentd已经成为许多装置中logstach的常用替代品。它充当本地聚合器,收集所有节点日志并将其发送到中央存储系统。它不是日志聚合系统。 + +它使用一个强大的插件系统,提供不同数据源和数据输出的快速和简单的集成功能。因为有超过500个插件可用,所以你的大多数用例都应该包括在内。如果没有,这听起来是一个为开源社区做出贡献的机会。 + +Fluentd 由于占用内存少(只有几十兆字节)和高吞吐量特性,是 Kubernetes 环境中的常见选择。在像 [Kubernetes][23] 这样的环境中,每个pod 都有一个 Fluentd sidecar ,内存消耗会随着每个新 pod 的创建而线性增加。在这中情况下,使用 Fluentd 将大大降低你的系统利用率。这对于Java开发的工具来说,这是一个常见的问题,这些工具旨在为每个节点运行一个工具,而内存开销并不是主要问题。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/open-source-log-aggregation-tools + +作者:[Dan Barker][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/barkerd427 +[1]: https://www.elastic.co/webinars/introduction-elk-stack +[2]: https://www.elastic.co/ +[3]: https://www.elastic.co/products/elasticsearch +[4]: https://www.elastic.co/products/logstash +[5]: https://www.elastic.co/products/kibana +[6]: http://kafka.apache.org/ +[7]: https://redis.io/ +[8]: https://www.nginx.com/ +[9]: https://logz.io/ +[10]: https://aws.amazon.com/elasticsearch-service/ +[11]: https://www.elastic.co/cloud +[12]: https://en.wikipedia.org/wiki/Security_information_and_event_management +[13]: https://github.com/Yelp/elastalert +[14]: https://www.graylog.org/ +[15]: https://opensource.com/tags/go +[16]: https://www.mongodb.com/ +[17]: https://www.drools.org/ +[18]: https://www.fluentd.org/ +[19]: https://www.treasuredata.com/ +[20]: https://www.cncf.io/ +[21]: https://aws.amazon.com/blogs/aws/all-your-data-fluentd/ +[22]: https://cloud.google.com/logging/docs/agent/ +[23]: https://opensource.com/resources/what-is-kubernetes From b1c5388ba2eae11a756bd9d708395de269aa2f08 Mon Sep 17 00:00:00 2001 From: Andrew Lyu Date: Tue, 18 Sep 2018 15:04:49 +0800 Subject: [PATCH 288/455] Proof: Turn your vi editor into a productivity powerhouse --- ... your vi editor into a productivity powerhouse.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md b/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md index e1bbd55920..e2e209017f 100644 --- a/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md +++ b/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md @@ -1,5 +1,3 @@ - - 增强 Vim 编辑器,提高编辑效率 ====== @@ -27,11 +25,11 @@ * 首先,[安装 gvim][1] * 打开 `gvim` - * 单击 `编辑` -> `启动设置`,打开 `.vimrc` 文件 - * 复制本文最后的 `选项列表` 粘贴到 `.vimrc` 文件 + * 单击 `编辑` -> `启动设置`,打开 `_vimrc` 文件 + * 复制本文最后的 `选项列表` 粘贴到 `_vimrc` 文件 * 单击 `文件` -> `保存` -译者注:此处应注意不要使用 `Windows` 自带的记事本编辑该 `.vimrc` 文件。 +译者注:此处应注意不要使用 `Windows` 自带的记事本编辑该 `_vimrc` 文件。 下面,我们将深入研究提高 `Vim` 编辑效率的选项。主要分为以下几类: @@ -348,9 +346,9 @@ via: https://opensource.com/article/18/9/vi-editor-productivity-powerhouse 作者:[Girish Managoli][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[idea2act](https://github.com/idea2act) -校对:[校对者ID](https://github.com/校对者ID) +校对:[apemost](https://github.com/apemost) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]: https://opensource.com/users/gammay -[1]: https://www.vim.org/download.php#pc \ No newline at end of file +[1]: https://www.vim.org/download.php#pc From 7c733c7bd6329ef2862e61ab0453c54fdb9c66f1 Mon Sep 17 00:00:00 2001 From: sd886393 Date: Tue, 18 Sep 2018 15:30:02 +0800 Subject: [PATCH 289/455] =?UTF-8?q?=E3=80=90=E8=AE=A4=E9=A2=8620180907=20W?= =?UTF-8?q?hat=20do=20open=20source=20and=20cooking=20have=20in=20common.m?= =?UTF-8?q?d=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180907 What do open source and cooking have in common.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/talk/20180907 What do open source and cooking have in common.md b/sources/talk/20180907 What do open source and cooking have in common.md index 4dacfe62f0..173eab02d9 100644 --- a/sources/talk/20180907 What do open source and cooking have in common.md +++ b/sources/talk/20180907 What do open source and cooking have in common.md @@ -1,3 +1,4 @@ +【tranlating by sd886393】 What do open source and cooking have in common? ====== From 326cf0172a6e2fe504ea00cd1c9989108f0b4cb8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 18 Sep 2018 15:49:54 +0800 Subject: [PATCH 290/455] Rename 20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md to 20180901 5 Ways to Take Screenshot in Linux GUI and Terminal.md --- ...180901 5 Ways to Take Screenshot in Linux GUI and Terminal.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/tech/{20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md => 20180901 5 Ways to Take Screenshot in Linux GUI and Terminal.md} (100%) diff --git a/translated/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md b/translated/tech/20180901 5 Ways to Take Screenshot in Linux GUI and Terminal.md similarity index 100% rename from translated/tech/20180901 5 Ways to Take Screenshot in Linux [GUI and Terminal].md rename to translated/tech/20180901 5 Ways to Take Screenshot in Linux GUI and Terminal.md From 0de6dfe349bcbfc028cb935d2253a099ddf8b984 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 18 Sep 2018 16:58:26 +0800 Subject: [PATCH 291/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Backup=20Installe?= =?UTF-8?q?d=20Packages=20And=20Restore=20Them=20On=20Freshly=20Installed?= =?UTF-8?q?=20Ubuntu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...estore Them On Freshly Installed Ubuntu.md | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 sources/tech/20180915 Backup Installed Packages And Restore Them On Freshly Installed Ubuntu.md diff --git a/sources/tech/20180915 Backup Installed Packages And Restore Them On Freshly Installed Ubuntu.md b/sources/tech/20180915 Backup Installed Packages And Restore Them On Freshly Installed Ubuntu.md new file mode 100644 index 0000000000..d5927effee --- /dev/null +++ b/sources/tech/20180915 Backup Installed Packages And Restore Them On Freshly Installed Ubuntu.md @@ -0,0 +1,107 @@ +Backup Installed Packages And Restore Them On Freshly Installed Ubuntu +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/apt-clone-720x340.png) + +Installing the same set of packages on multiple Ubuntu systems is time consuming and boring task. You don’t want to spend your time to install the same packages over and over on multiple systems. When it comes to install packages on similar architecture Ubuntu systems, there are many methods available to make this task easier. You could simply migrate your old Ubuntu system’s applications, settings and data to a newly installed system with a couple mouse clicks using [**Aptik**][1]. Or, you can take the [**backup entire list of installed packages**][2] using your package manager (Eg. APT), and install them later on a freshly installed system. Today, I learned that there is also yet another dedicated utility available to do this job. Say hello to **apt-clone** , a simple tool that lets you to create a list of installed packages for Debian/Ubuntu systems that can be restored on freshly installed systems or containers or into a directory. + +Apt-clone will help you on situations where you want to, + + * Install consistent applications across multiple systems running with similar Ubuntu (and derivatives) OS. + * Install same set of packages on multiple systems often. + * Backup the entire list of installed applications and restore them on demand wherever and whenever necessary. + + + +In this brief guide, we will be discussing how to install and use Apt-clone on Debian-based systems. I tested this utility on Ubuntu 18.04 LTS system, however it should work on all Debian and Ubuntu-based systems. + +### Backup Installed Packages And Restore Them Later On Freshly Installed Ubuntu System + +Apt-clone is available in the default repositories. To install it, just enter the following command from the Terminal: + +``` +$ sudo apt install apt-clone +``` + +Once installed, simply create the list of installed packages and save them in any location of your choice. + +``` +$ mkdir ~/mypackages + +$ sudo apt-clone clone ~/mypackages +``` + +The above command saved all installed packages in my Ubuntu system in a file named **apt-clone-state-ubuntuserver.tar.gz** under **~/mypackages** directory. + +To view the details of the backup file, run: + +``` +$ apt-clone info mypackages/apt-clone-state-ubuntuserver.tar.gz +Hostname: ubuntuserver +Arch: amd64 +Distro: bionic +Meta: +Installed: 516 pkgs (33 automatic) +Date: Sat Sep 15 10:23:05 2018 +``` + +As you can see, I have 516 packages in total in my Ubuntu server. + +Now, copy this file on your USB or external drive and go to any other system that want to install the same set of packages. Or you can also transfer the backup file to the system on the network and install the packages by using the following command: + +``` +$ sudo apt-clone restore apt-clone-state-ubuntuserver.tar.gz +``` + +Please be mindful that this command will overwrite your existing **/etc/apt/sources.list** and will install/remove packages. You have been warned! Also, just make sure the destination system is on same arch and same OS. For example, if the source system is running with 18.04 LTS 64bit, the destination system must also has the same. + +If you don’t want to restore packages on the system, you can simply use `--destination /some/location` option to debootstrap the clone into this directory. + +``` +$ sudo apt-clone restore apt-clone-state-ubuntuserver.tar.gz --destination ~/oldubuntu +``` + +In this case, the above command will restore the packages in a folder named **~/oldubuntu**. + +For more details, refer help section: + +``` +$ apt-clone -h +``` + +Or, man pages: + +``` +$ man apt-clone +``` + +**Suggested read:** + ++ [Systemback – Restore Ubuntu Desktop and Server to previous state][3] ++ [Cronopete – An Apple’s Time Machine Clone For Linux][4] + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/backup-installed-packages-and-restore-them-on-freshly-installed-ubuntu-system/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://www.ostechnix.com/how-to-migrate-system-settings-and-data-from-an-old-system-to-a-newly-installed-ubuntu-system/ +[2]: https://www.ostechnix.com/create-list-installed-packages-install-later-list-centos-ubuntu/#comment-12598 + +[3]: https://www.ostechnix.com/systemback-restore-ubuntu-desktop-and-server-to-previous-state/ + +[4]: https://www.ostechnix.com/cronopete-apples-time-machine-clone-linux/ From 882cc5270ab4909fd6dee2a0bd71fe0b0817bb98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=B3=A5?= Date: Tue, 18 Sep 2018 18:12:03 +0800 Subject: [PATCH 292/455] =?UTF-8?q?As=20far=20as=20I=20tested=20Cloud=20Co?= =?UTF-8?q?mmander,=20It=20worked=20like=20charm.=E6=B2=A1=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=E5=A5=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eb File Manager With Console And Editor.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md b/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md index 3e6d24ca67..50e4987973 100644 --- a/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md +++ b/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md @@ -5,13 +5,13 @@ Cloud Commander – 一个有控制台和编辑器在Web 上的文件管家 ![](https://www.ostechnix.com/wp-content/uploads/2016/05/Cloud-Commander-A-Web-File-Manager-With-Console-And-Editor-720x340.png) -**Cloud Commander** 是一个基于 web 的文件管理程序,它允许你通过任何计算机、移动端或平板电脑的 web 浏览器查看、访问或管理系统文件或文件夹。他有两个简单而又经典的面板,并且会自动。It has two simple and classic panels, and automatically converts it’s size as per your device’s display size. It also has two built-in editors namely **Dword** and **Edward** with support of Syntax-highlighting and one **Console** with support of your system’s command line. So you can edit your files on the go. Cloud Commander server is a cross-platform application that runs on Linux, Windows and Mac OS X operating systems, and 客户端将在任何一款浏览器上运行the client will run on any web browser. 它是用 **JavaScript/Node.Js**,and is licensed under **MIT**. +**Cloud Commander** 是一个基于 web 的文件管理程序,它允许你通过任何计算机、移动端或平板电脑的浏览器查看、访问或管理系统文件或文件夹。他有两个简单而又经典的面板,并且会像你设备的显示尺寸一样自动转换大小。它也拥有两款内置的叫做 **Dword** 和 **Edward** 的文本编辑器,它们支持语法高亮和带有一个支持系统命令行的控制台。因此,您可以随时随地编辑文件。Cloud Commander 服务器是一款在 Linux,Windows,Mac OS X 运行的跨平台应用,而且该应用客户端将在任何一款浏览器上运行。它是用 **JavaScript/Node.Js** 写的,并使用 **MIT** 许可。 在这个简易教程中,让我们看一看如何在 Ubuntu 18.04 LTS 服务器上安装 Cloud Commander。 ### 前提条件 -像我之前提到的,是用 Node.js 写的。所以为了安装 Cloud Commander,我们需要首先安装 Node.js。To do so, refer the following guide. +像我之前提到的,是用 Node.js 写的。所以为了安装 Cloud Commander,我们需要首先安装 Node.js。要执行安装,参考下面的指南。 ### 安装 Cloud Commander @@ -38,13 +38,13 @@ url: http://localhost:8000 ``` -Now, open your web browser and navigate to the URL: ** ****. +现在,打开你的浏览器并转到链接:**http://localhost:8000** or ****. -From now on, you can create, delete, view, manage files or folders right in the web browser from the local system or remote system, or mobile, tablet etc. +从现在开始,您可以直接在本地系统或远程系统或移动设备,平板电脑等Web浏览器中创建,删除,查看,管理文件或文件夹。 ![][2] -当你看见上面的截图时,Clouder Commander 有两个面板,十个热键 (F1 to F10),和控制台。 +当你看见上面的截图时,Clouder Commander 有两个面板,十个热键 (F1 to F10),还有控制台。 每个热键执行的都是一个任务。 @@ -63,7 +63,7 @@ From now on, you can create, delete, view, manage files or folders right in the #### Cloud Commmander 控制台 -点击控制台图标。 This will open your default system’s shell. +点击控制台图标。这即将打开系统默认的命令行界面。 ![][3] @@ -71,7 +71,7 @@ From now on, you can create, delete, view, manage files or folders right in the #### 创建文件/文件夹 -要创建新的文件或文件夹 Right click on any empty place and go to **New - >File or Directory**. +要创建新的文件或文件夹就右键单击任意空位置并找到 **New - >File or Directory**。 ![][4] @@ -91,7 +91,7 @@ From now on, you can create, delete, view, manage files or folders right in the 选择你想要上传的文件。 -Also, you can upload files from the Cloud services like Google drive, Dropbox, Amazon cloud drive, Facebook, Twitter, Gmail, GtiHub, Picasa, Instagram and many. +另外,你也可以上传来自像 Google 云盘, Dropbox, Amazon 云盘, Facebook, Twitter, Gmail, GtiHub, Picasa, Instagram 还有很多的云服务上的文件。 要从云端上传文件, 右键单击面板的任意空白处,并且右键单击面板任意空白处并选择**从云端上传**。 @@ -107,7 +107,7 @@ Also, you can upload files from the Cloud services like Google drive, Dropbox, A #### 更新 Cloud Commander -要更新到最新的可提供版本,执行下面的命令: +要更新到最新的可用版本,执行下面的命令: ``` $ npm update cloudcmd -g @@ -115,9 +115,9 @@ $ npm update cloudcmd -g #### 总结 -As far as I tested Cloud Commander, It worked like charm. I didn’t face a single issue during the testing in my Ubuntu server. Also, Cloud Commander is not just a web-based file manager, but also acts as a remote administration tool that performs most Linux administration tasks. You can create a files/folders, rename, delete, edit, and view them. Also, You can install, update, upgrade, and remove any package as the way you do in the local system from the Terminal. And, of course, you can even shutdown or restart the system from the Cloud Commander console itself. What do you need more? Give it a try, you will find it useful. +据我测试,它运行地像魔幻一般。在我的Ubuntu服务器测试期间,我没有遇到任何问题。此外,Cloud Commander不仅是基于 Web 的文件管理器,还充当执行大多数Linux管理任务的远程管理工具。 您可以创建文件/文件夹,重命名,删除,编辑和查看它们。此外,您可以像在终端中在本地系统中那样安装,更新,升级和删除任何软件包。当然,您甚至可以从 Cloud Commander 控制台本身关闭或重启系统。 还有什么需要的吗? 尝试一下,你会发现它很有用。 -That’s all for now. I will be here soon with another interesting article. Until then, stay tuned with OSTechNix. +目前为止就这样吧。 我将很快在这里发表另一篇有趣的文章。 在此之前,请继续关注 OSTechNix。 祝贺! @@ -129,7 +129,7 @@ via: https://www.ostechnix.com/cloud-commander-a-web-file-manager-with-console-a 作者:[SK][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:[fuzheng1998](https://github.com/fuzheng1998) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 19c4671fdaf63fd06b8499b098ed5fa3d1658b05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=B3=A5?= Date: Tue, 18 Sep 2018 18:13:21 +0800 Subject: [PATCH 293/455] delete username head --- ...ud Commander - A Web File Manager With Console And Editor.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md b/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md index 50e4987973..335fdd59b1 100644 --- a/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md +++ b/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md @@ -1,5 +1,3 @@ -fuzheng1998 translating -====== Cloud Commander – 一个有控制台和编辑器在Web 上的文件管家 ====== From 498f37c1627b1c9aa7da0d54ed466f8318f0be97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=B3=A5?= Date: Tue, 18 Sep 2018 18:23:00 +0800 Subject: [PATCH 294/455] move files to translated --- ...loud Commander - A Web File Manager With Console And Editor.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources/tech => translated}/20160503 Cloud Commander - A Web File Manager With Console And Editor.md (100%) diff --git a/sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md b/translated/20160503 Cloud Commander - A Web File Manager With Console And Editor.md similarity index 100% rename from sources/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md rename to translated/20160503 Cloud Commander - A Web File Manager With Console And Editor.md From 58cd79764c0922a38a2a8678b18117ce6a4fe0ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=B3=A5?= <24203166+fuzheng1998@users.noreply.github.com> Date: Tue, 18 Sep 2018 19:03:30 +0800 Subject: [PATCH 295/455] Update 20160503 Cloud Commander - A Web File Manager With Console And Editor.md --- ...ud Commander - A Web File Manager With Console And Editor.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/20160503 Cloud Commander - A Web File Manager With Console And Editor.md b/translated/20160503 Cloud Commander - A Web File Manager With Console And Editor.md index 335fdd59b1..2854b9d4ad 100644 --- a/translated/20160503 Cloud Commander - A Web File Manager With Console And Editor.md +++ b/translated/20160503 Cloud Commander - A Web File Manager With Console And Editor.md @@ -1,4 +1,4 @@ -Cloud Commander – 一个有控制台和编辑器在Web 上的文件管家 +Cloud Commander – 一个有控制台和编辑器在 Web 上的文件管家 ====== ![](https://www.ostechnix.com/wp-content/uploads/2016/05/Cloud-Commander-A-Web-File-Manager-With-Console-And-Editor-720x340.png) From 4ffee71be9214979b4e070c73c1acd66c6ff523e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 18 Sep 2018 20:28:26 +0800 Subject: [PATCH 296/455] Rename translated/20160503 Cloud Commander - A Web File Manager With Console And Editor.md to translated/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md --- ...loud Commander - A Web File Manager With Console And Editor.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename translated/{ => tech}/20160503 Cloud Commander - A Web File Manager With Console And Editor.md (100%) diff --git a/translated/20160503 Cloud Commander - A Web File Manager With Console And Editor.md b/translated/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md similarity index 100% rename from translated/20160503 Cloud Commander - A Web File Manager With Console And Editor.md rename to translated/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md From 71629b05645aae1ae9aa8ff1de734d626c37d162 Mon Sep 17 00:00:00 2001 From: sd886393 Date: Tue, 18 Sep 2018 21:30:15 +0800 Subject: [PATCH 297/455] =?UTF-8?q?=E3=80=90=E7=BF=BB=E8=AF=91=E5=AE=8C?= =?UTF-8?q?=E6=AF=95=E3=80=91talk-20180907-what=20do=20open=20source=20and?= =?UTF-8?q?=20cooking=20have=20in=20common?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... open source and cooking have in common.md | 79 ------------------- ... open source and cooking have in common.md | 79 +++++++++++++++++++ 2 files changed, 79 insertions(+), 79 deletions(-) delete mode 100644 sources/talk/20180907 What do open source and cooking have in common.md create mode 100644 translated/talk/20180907 What do open source and cooking have in common.md diff --git a/sources/talk/20180907 What do open source and cooking have in common.md b/sources/talk/20180907 What do open source and cooking have in common.md deleted file mode 100644 index 4dacfe62f0..0000000000 --- a/sources/talk/20180907 What do open source and cooking have in common.md +++ /dev/null @@ -1,79 +0,0 @@ -What do open source and cooking have in common? -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/waffles-recipe-eggs-cooking-mix.png?itok=Fp06VOBx) - -What’s a fun way to promote the principles of free software without actually coding? Here’s an idea: open source cooking. For the past eight years, this is what we’ve been doing in Munich. - -The idea of _open source cooking_ grew out of our regular open source meetups because we realized that cooking and free software have a lot in common. - -### Cooking together - -The [Munich Open Source Meetings][1] is a series of recurring Friday night events that was born in [Café Netzwerk][2] in July 2009. The meetings help provide a way for open source project members and enthusiasts to get to know each other. Our motto is: “Every fourth Friday for free software.” In addition to adding some weekend workshops, we soon introduced other side events, including white sausage breakfast, sauna, and cooking. - -The first official _Open Source Cooking_ meetup was admittedly rather chaotic, but we’ve improved our routine over the past eight years and 15 events, and we’ve mastered the art of cooking delicious food for 25-30 people. - -Looking back at all those evenings, similarities between cooking together and working together in open source communities have become more clear. - -### FLOSS principles at play - -Here are a few ways cooking together is like working together on open source projects: - - * We enjoy collaborating and working toward a result we share. - * We’ve become a community. - * As we share a common interest and enthusiasm, we learn more about ourselves, each other, and what we’re working on together. - * Mistakes happen. We learn from them and share our knowledge to our mutual benefit, so hopefully we avoid repeating the same mistakes. - * Everyone contributes what they’re best at, as everyone has something they’re better at than someone else. - * We motivate others to contribute and join us. - * Coordination is key, but a bit chaotic. - * Everyone benefits from the results! - - - -### Smells like open source - -Like any successful open source-related meetup, open source cooking requires some coordination and structure. Ahead of the event, we run a _call for recipes_ in which all participants can vote. Rather than throwing a pizza into a microwave, we want to create something delicious and tasty, and so far we’ve had Japanese, Mexican, Hungarian, and Indian food, just to name a few. - -Like in real life, cooking together requires having respect and mutual understanding for each other, so we always try to have dishes for vegans, vegetarians, and people with allergies and food preferences. A little beta test at home can be helpful (and fun!) when preparing for the big release. - -Scalability matters, and shopping for our “build requirements” at the grocery store easily can eat up three hours. We use a spreadsheet (LibreOffice Calc, naturally) for calculating ingredient requirements and costs. - -For every dinner course we have a “package maintainer” working with volunteers to make the menu in time and to find unconventional solutions to problems that arise. - -Not everyone is a cook by profession, but with a little bit of help and a good distribution of tasks and responsibilities, it’s rather easy to parallelize things — at some point, 18kg of tomatoes and 100 eggs really don’t worry you anymore, believe me! The only real scalability limit is the stove with its four hotplates, so maybe it’s time to invest in an infrastructure budget. - -Time-based releasing, on the other hand, isn’t working as reliably as it should, as we usually serve the main dish at a rather “flexible” time between 21:30 und 01:30, but that’s not a release blocker, either. - -And, as with in many open source projects, cooking documentation has room for improvement. Cleanup tasks such as washing the dishes, surely can be optimized further, too. - -### Future flavor releases - -Some of our future ideas include: - - * cooking in a foreign country, - * finally buying and cooking that large 700 € pumpkin, and - * find a grocery store that donates a percentage of our purchases to a good cause. - - - -The last item is also an important aspect about the free software movement: Always remember there are people who are not living on the sunny side, who do not have the same access to resources, and who are otherwise struggling. How can the open nature of what we’re doing help them? - -With all that in mind, I am looking forward to the next Open Source Cooking meetup. If reading about them makes you hungry and you’d like to run own event, we’d love to see you adapt our idea or even fork it. And we’d love to have you join us in a meetup, and perhaps even do some mentoring and QA. - -Article originally appeared on [blog.effenberger.org][3]. Reprinted with permission. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/open-source-cooking - -作者:[Florian Effenberger][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/floeff -[1]: https://www.opensourcetreffen.de/ -[2]: http://www.cafe-netzwerk.de/ -[3]: https://blog.effenberger.org/2018/05/28/what-do-open-source-and-cooking-have-in-common/ diff --git a/translated/talk/20180907 What do open source and cooking have in common.md b/translated/talk/20180907 What do open source and cooking have in common.md new file mode 100644 index 0000000000..2f5f150f1a --- /dev/null +++ b/translated/talk/20180907 What do open source and cooking have in common.md @@ -0,0 +1,79 @@ +开源与烹饪有什么相似之处? +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/waffles-recipe-eggs-cooking-mix.png?itok=Fp06VOBx) + +有什么好的方法,既可以宣传开源的精神又不用写代码呢?这里有个点子:“开源食堂”。在过去的8年间,这就是我们在慕尼黑做的事情。 + +开源食堂已经是我们常规的开源宣传活动了,因为我们发现开源与烹饪有很多共同点。 + +### 协作烹饪 + +[慕尼黑开源聚会][1]自2009年7月在[Café Netzwerk][2]创办以来,已经组织了若干次活动,活动一般在星期五的晚上组织。该聚会为开源项目工作者或者开源爱好者们提供了相互认识的方式。我们的信条是:“每四周的星期五属于免费软件(Every fourth Friday for free software)”。当然在一些周末,我们还会举办一些研讨会。那之后,我们很快加入了很多其他的活动,包括白香肠早餐、桑拿与烹饪活动。 + +事实上,第一次开源烹饪聚会举办的有些混乱,但是我们经过这8年来以及15次的组织,已经可以为25-30个与会者提供丰盛的美食了。 + +回头看看这些夜晚,我们愈发发现共同烹饪与开源社区协作之间,有很多相似之处。 + +### 烹饪步骤中的开源精神 + +这里是几个烹饪与开源精神相同的地方: + + * 我们乐于合作且朝着一个共同的目标前进 + * 我们成立社区组织 + * 由于我们有相同的兴趣与爱好,我们可以更多的了解我们自身与他人,并且可以一同协作 + * 我们也会犯错,但我们会从错误中学习,并为了共同的李医生去分享关于错误的经验,从而让彼此避免再犯相同的错误 + * 每个人都会贡献自己擅长的事情,因为每个人都有自己的一技之长 + * 我们会动员其他人去做出贡献并加入到我们之中 + * 虽说协作是关键,但难免会有点混乱 + * 每个人都会从中收益 + + + +### 烹饪中的开源气息 + +同很多成功的开源聚会一样,开源烹饪也需要一些协作和组织结构。在每次活动之前,我们会组织所有的成员对菜单进行投票,而不单单是直接给每个人分一角披萨,我们希望真正的作出一道美味,迄今为止我们做过日本、墨西哥、匈牙利、印度等地区风味的美食,限于篇幅就不一一列举了。 + +就像在生活中,共同烹饪一样需要各个成员之间相互的尊重和理解,所以我们也会试着为素食主义者、食物过敏者、或者对某些事物有偏好的人提供针对性的事物。正式开始烹饪之前,在家预先进行些小规模的测试会非常有帮助(乐趣!) + +可扩展性也很重要,在杂货店采购必要的食材很容易就消耗掉3个小时。所以我们使用一些表格工具(自然是 LibreOffice Calc)来做一些所需要的食材以及相应的成本。 + +我们会同志愿者一起,为每次晚餐准备一个“包管理器”,从而及时的制作出菜单并在问题产生的时候寻找一些独到的解决方法。 + +虽然不是所有人都是大厨,但是只要给与一些帮助,并比较合理的分配任务和责任,就很容易让每个人都参与其中。某种程度上来说,处理 18kg 的西红柿和 100 个鸡蛋都不会让你觉得是件难事,相信我!唯一的限制是一个烤炉只有四个灶,所以可能是时候对基础设施加大投入了。 + +发布有时间要求,当然要求也不那么严格,我们通常会在21:30和01:30之间的相当“灵活”时间内供应主菜,即便如此,这个时间也是硬性的发布规定。 + +最后,想很多开源项目一样,烹饪文档同样有提升的空间。类似洗碟子这样的扫尾工作同样也有可优化的地方。 + +### 未来的一些新功能点 + +我们预计的一些想法包括: + + * 在其他的国家开展活动 + * 购买和烹饪一个价值 700 欧元的大南瓜,并且 + * 找家可以为我们采购提供折扣的商店 + + +最后一点,也是开源软件的动机:永远记住,还有一些人们生活在阴影中,他们为没有同等的权限去访问资源而苦恼着。我们如何通过开源的精神去帮助他们呢? + +一想到这点,我便期待这下一次的开源烹饪聚会。如果读了上面的东西让你觉得不够完美,并且想自己运作这样的活动,我们非常乐意你能够借鉴我们的想法,甚至抄袭一个。我们也乐意你能够参与到我们其中,甚至做一些演讲和问答。 + +Article originally appeared on [blog.effenberger.org][3]. Reprinted with permission. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/open-source-cooking + +作者:[Florian Effenberger][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/sd886393) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/floeff +[1]: https://www.opensourcetreffen.de/ +[2]: http://www.cafe-netzwerk.de/ +[3]: https://blog.effenberger.org/2018/05/28/what-do-open-source-and-cooking-have-in-common/ +[4]: https://en.wikipedia.org/wiki/Free_and_open-source_software From f98ec0c834674efc3e9b0e938f1801157c085c02 Mon Sep 17 00:00:00 2001 From: jamelouis Date: Tue, 18 Sep 2018 22:24:20 +0800 Subject: [PATCH 298/455] translating nas --- ...7 Getting started with openmediavault- A home NAS solution.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180917 Getting started with openmediavault- A home NAS solution.md b/sources/tech/20180917 Getting started with openmediavault- A home NAS solution.md index 7f5b29c092..42bb1bfe17 100644 --- a/sources/tech/20180917 Getting started with openmediavault- A home NAS solution.md +++ b/sources/tech/20180917 Getting started with openmediavault- A home NAS solution.md @@ -1,3 +1,4 @@ +[translating by jamelouis] Getting started with openmediavault: A home NAS solution ====== This network-attached file server offers a solid array of features and is easy to install and configure. From 00a321afa3ae08194407543d9c4a218f48eb642b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 18 Sep 2018 22:28:57 +0800 Subject: [PATCH 299/455] PRF&PUB:20180808 5 applications to manage your to do list on Fedora (#10251) * PRF:20180808 5 applications to manage your to-do list on Fedora.md @geekpi * PUB:20180808 5 applications to manage your to-do list on Fedora.md @geekpi https://linux.cn/article-10025-1.html --- ...ons to manage your to-do list on Fedora.md | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) rename {translated/tech => published}/20180808 5 applications to manage your to-do list on Fedora.md (58%) diff --git a/translated/tech/20180808 5 applications to manage your to-do list on Fedora.md b/published/20180808 5 applications to manage your to-do list on Fedora.md similarity index 58% rename from translated/tech/20180808 5 applications to manage your to-do list on Fedora.md rename to published/20180808 5 applications to manage your to-do list on Fedora.md index dbd9aac972..99a163bf4f 100644 --- a/translated/tech/20180808 5 applications to manage your to-do list on Fedora.md +++ b/published/20180808 5 applications to manage your to-do list on Fedora.md @@ -3,46 +3,45 @@ ![](https://fedoramagazine.org/wp-content/uploads/2018/08/todoapps-816x345.jpg) -有效管理待办事项可以为你的工作效率创造奇迹。有些人更喜欢在文本中保存待办事项,甚至只使用记事本和笔。对于需要更多待办事项功能的用户,他们通常会使用应用程序。在本文中,我们将重点介绍 4 个图形程序和一个基于终端的工具来管理待办事项。 +有效管理待办事项(to-do)可以为你的工作效率创造奇迹。有些人更喜欢在文本中保存待办事项,甚至只使用记事本和笔。对于需要更多待办事项功能的用户,他们通常会使用应用程序。在本文中,我们将重点介绍 4 个图形程序和一个基于终端的工具来管理待办事项。 ### GNOME To Do -GNOME To Do][1] 是专为 GNOME 桌面(Fedora Workstation 的默认桌面)设计的个人任务管理器。将 GNOME To Do 与其他程序进行比较时,它有一系列简洁的功能。 +[GNOME To Do][1] 是专为 GNOME 桌面(Fedora Workstation 的默认桌面)设计的个人任务管理器。GNOME To Do 与其他程序进行比较,它有一系列简洁的功能。 -GNOME To Do 提供列表形式的任务组织,并能为该列表指定颜色。此外,可以为各个任务分配截止日期和优先级,以及每项任务的注释。此外,GNOME To Do 还支持扩展,能添加更多功能,包括支持 [todo.txt][2] 以及与 [todoist][3] 等在线服务同步。 +GNOME To Do 提供列表形式的任务组织方式,并能为该列表指定颜色。此外,可以为各个任务分配截止日期和优先级,以及每项任务的注释。此外,GNOME To Do 还支持扩展,能添加更多功能,包括支持 [todo.txt][2] 以及与 [todoist][3] 等在线服务同步。 ![][4] 使用软件中心或者在终端中使用下面的命令安装 GNOME To Do: + ``` sudo dnf install gnome-todo - ``` ### Getting things GNOME! -、在 GNOME To Do 存在之前,在 GNOME 上追踪任务的首选程序是 [Getting things GNOME!][5] 这个稍来的 GNOME 程序有多个窗口层,能然你同时显示多个任务的细节。GTG 没有任务列表,它能在任务中添加子任务,甚至在子任务中添加子任务。GTG 同样能添加截止日期和开始日期。通过插件同步其他程序和服务也是可能的。 +在 GNOME To Do 出现之前,在 GNOME 上追踪任务的首选程序是 [Getting things GNOME!][5] 这个老式的 GNOME 程序采用多窗口布局,能让你同时显示多个任务的细节。GTG 没有任务列表,它能在任务中添加子任务,甚至在子任务中添加子任务。GTG 同样能添加截止日期和开始日期。也可以通过插件同步其他程序和服务。 ![][6] 在软件中心或者在终端中使用下面的命令安装 Getting Things GNOME: + ``` sudo dnf install gtg - ``` ### Go For It! -[Go For It!][7] 是一个超级简单的任务管理程序。它能简单地创建一个任务列表,并在完成后标记它们。它没有组任务,也不能创建子任务。默认 Go For It! 将任务存储在 todo.txt 中,这能更方便地同步到在线服务或者其他程序中。额外地,Go For It! 包含了一个简单定时器来追踪你在当前任务花费了多少时间。 +[Go For It!][7] 是一个超级简单的任务管理程序。它能简单地创建一个任务列表,并在完成后标记它们。它不能将任务分组,也不能创建子任务。Go For It! 默认将任务存储为 todo.txt 格式,这能更方便地同步到在线服务或者其他程序中。额外地,Go For It! 包含了一个简单定时器来追踪你在当前任务花费了多少时间。 ![][8] -Go For It 能在 Flathub 应用仓库中找到。要安装它,只需[启用 Flathub 作为软件源][9],接着在软件中心中安装。 - +Go For It! 能在 Flathub 应用仓库中找到。要安装它,只需[启用 Flathub 作为软件源][9],接着在软件中心中安装。 ### Agenda -如果你在寻找一款非常简单的待办应用,[Agenda][10] 非常合适。创建任务,标记完成,接着从列表中删除它们。Agenda 会在你删除它们之前显示所有任务(完成或者进行中)。 +如果你在寻找一款非常简单的待办应用,非 [Agenda][10] 莫属。创建任务,标记完成,接着从列表中删除它们。Agenda 会在你删除它们之前一直显示所有任务(完成的或者进行中)。 ![][11] @@ -57,12 +56,11 @@ Agenda 能从 Flathub 应用仓库下载。要安装它,只需[启用 Flathub ![][14] 在终端中使用这个命令安装 Taskwarrior: + ``` sudo dnf install task - ``` - -------------------------------------------------------------------------------- via: https://fedoramagazine.org/5-tools-to-manage-your-to-do-list-on-fedora/ @@ -70,7 +68,7 @@ via: https://fedoramagazine.org/5-tools-to-manage-your-to-do-list-on-fedora/ 作者:[Ryan Lerch][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -88,4 +86,4 @@ via: https://fedoramagazine.org/5-tools-to-manage-your-to-do-list-on-fedora/ [11]:https://fedoramagazine.org/wp-content/uploads/2018/08/agenda.png [12]:https://taskwarrior.org/ [13]:https://fedoramagazine.org/getting-started-taskwarrior/ -[14]:https://fedoramagazine.org/wp-content/uploads/2018/08/taskwarrior.png \ No newline at end of file +[14]:https://fedoramagazine.org/wp-content/uploads/2018/08/taskwarrior.png From c9f615c7cd12cbfa714254ea87655a94e895d3a4 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 18 Sep 2018 23:06:49 +0800 Subject: [PATCH 300/455] PRF&PUB:20180831 6 open source tools for making your own VPN (#10254) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * PRF:20180831 6 open source tools for making your own VPN.md @heguangzhi 翻译的很好~ * PUB:20180831 6 open source tools for making your own VPN.md @heguangzhi https://linux.cn/article-10026-1.html --- ...en source tools for making your own VPN.md | 109 ++++++++++++++ ...en source tools for making your own VPN.md | 137 ------------------ 2 files changed, 109 insertions(+), 137 deletions(-) create mode 100644 published/20180831 6 open source tools for making your own VPN.md delete mode 100644 translated/tech/20180831 6 open source tools for making your own VPN.md diff --git a/published/20180831 6 open source tools for making your own VPN.md b/published/20180831 6 open source tools for making your own VPN.md new file mode 100644 index 0000000000..19e668c20c --- /dev/null +++ b/published/20180831 6 open source tools for making your own VPN.md @@ -0,0 +1,109 @@ +6 个打造你自己的 VPN 的开源工具 +====== + +> 想尝试建立您自己的 VPN,但是不确定从哪里开始吗? + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/vpn_scrabble_networking.jpg?itok=pdsUHw5N) + +如果您想尝试建立您自己的 VPN,但是不确定从哪里开始,那么您来对地方了。我将比较 6 个在您自己的服务器上搭建和使用 VPN 的最好的自由和开源工具。不管您是想为您的企业建立站点到站点的 VPN,还是只是想创建一个远程代理访问以解除访问限制并对 ISP 隐藏你的互联网流量,都可以通过 VPN 来达成。 + +根据您的需求和条件,并参考您自己的技术特长、环境以及您想要通过 VPN 实现的目标。需要考虑以下因素: + + * VPN 协议 + * 客户端的数量和设备类型 + * 服务端的兼容性 + * 需要的技术专业能力 + +### Algo + +[Algo][1] 是从下往上设计的,可以为需要互联网安全代理的商务旅客创建 VPN 专用网。它“只包括您所需要的最小化的软件”,这意味着为了简单而牺牲了可扩展性。Algo 是基于 StrongSwan 的,但是删除了所有您不需要的东西,这有另外一个好处,那就是去除了新手可能不会注意到的安全漏洞。 + +作为额外的奖励,它甚至可以屏蔽广告! + +Algo 只支持 IKEv2 协议和 Wireguard。因为对 IKEv2 的支持现在已经内置在大多数设备中,所以它不需要像 OpenVPN 这样的客户端应用程序。Algo 可以使用 Ansible 在 Ubuntu (首选选项)、Windows、RedHat、CentOS 和 FreeBSD 上部署。 使用 Ansible 可以自动化安装,它会根据您对一组简短的问题的回答来配置服务。卸载和重新部署也非常容易。 + +Algo 可能是在本文中安装和部署最简单和最快的 VPN。它非常简洁,考虑周全。如果您不需要其他工具提供的高级功能,只需要一个安全代理,这是一个很好的选择。请注意,Algo 明确表示,它不是为了解除地理封锁或逃避审查,主要是为了加密。 + +### Streisand + +[Streisand][2] 可以使用一个命令安装在任何 Ubuntu 16.04 服务器上;这个过程大约需要 10 分钟。它支持 L2TP、OpenConnect、OpenSSH、OpenVPN、Shadowsocks、Stunnel、Tor bridge 和 WireGuard。根据您选择的协议,您可能需要安装客户端应用程序。 + +在很多方面,Streisand 与 Algo 相似,但是它提供了更多的协议和定制。这需要更多的工作来管理和维护,但也更加灵活。注意 Streisand 不支持 IKEv2。因为它的多功能性,我认为 Streisand 在某国和土耳其这样的地方绕过审查制度更有效,但是 Algo 的安装更容易和更快。 + +使用 Ansible 可以自动化安装,所以不需要太多的专业技术知识。通过向用户发送自定义生成的连接指令,包括服务器 SSL 证书的嵌入副本,可以轻松添加更多用户。 + +卸载 Streisand 是一个快速无痛的过程,您也可以随时重新部署。 + +### OpenVPN + +[OpenVPN][3] 要求客户端和服务器应用程序使用其同名的协议建立 VPN 连接。OpenVPN 可以根据您的需求进行调整和定制,但它也需要更多专业技术知识。它支持远程访问和站点到站点配置;如果您计划使用 VPN 作为互联网代理,前者是您所需要的。因为在大多数设备上使用 OpenVPN 需要客户端应用程序,所以最终用户必须保持更新。 + +服务器端您可以选择部署在云端或你自己的 Linux 服务器上。兼容的发行版包括 CentOS 、Ubuntu 、Debian 和 openSUSE。Windows 、MacOS 、iOS 和 Android 都有客户端应用程序,其他设备也有非官方应用程序。企业可以选择设置一个 OpenVPN 接入服务器,但是对于想要使用社区版的个人来说,这可能有点过分。 + +OpenVPN 使用静态密钥加密来配置相对容易,但并不十分安全。相反,我建议使用 [easy-rsa][4] 来设置它,这是一个密钥管理包,可以用来设置公钥基础设施(PKI)。这允许您一次连接多个设备,并因此得到完美前向保密perfect forward secrecy和其他好处的保护。OpenVPN 使用 SSL/TLS 进行加密,而且您可以在配置中指定 DNS 服务器。 + +OpenVPN 可以穿透防火墙和 NAT 防火墙,这意味着您可以使用它绕过可能会阻止连接的网关和防火墙。它同时支持 TCP 和 UDP 传输。 + +### StrongSwan + +您可能会遇到一些名称中有 “Swan” 的各种 VPN 工具。FreeS/WAN 、OpenSwan、LibreSwan 和 [strongSwan][5] 都是同一个项目的分叉,后者是我个人最喜欢的。在服务器端,strongSwan 可以运行在 Linux 2.6、3.x 和 4x 内核、Android、FreeBSD、macOS、iOS 和 Windows 上。 + +StrongSwan 使用 IKEv2 协议和 IPSec 。与 OpenVPN 相比,IKEv2 连接速度更快,同时提供了很好的速度和安全性。如果您更喜欢不需要在客户端安装额外应用程序的协议,这将非常有用,因为现在生产的大多数新设备都支持 IKEv2,包括 Windows、MacOS、iOS 和 Android。 + +StrongSwan 并不特别容易使用,尽管文档不错,但它使用的词汇与大多数其他工具不同,这可能会让人比较困惑。它的模块化设计让它对企业来说很棒,但这也意味着它不是很精简。这当然不像 Algo 或 Streisand 那么简单。 + +访问控制可以基于使用 X.509 属性证书的组成员身份,这是 strongSwan 独有的功能。它支持用于集成到其他环境(如 Windows Active Directory)中的 EAP 身份验证方法。strongSwan 可以穿透NAT 网络防火墙。 + +### SoftEther + +[SoftEther][6] 是由日本筑波大学的一名研究生发起的一个项目。SoftEther VPN 服务器和 VPN 网桥可以运行在 Windows、Linux、OSX、FreeBSD 和 Solaris 上,而客户端应用程序可以运行在 Windows、Linux 和 MacOS 上。VPN 网桥主要用于需要设置站点到站点 VPN 的企业,因此单个用户只需要服务器和客户端程序来设置远程访问。 + +SoftEther 支持 OpenVPN、L2TP、SSTP 和 EtherIP 协议,由于采用“基于 HTTPS 的以太网”伪装,它自己的 SoftEther 协议声称能够免疫深度数据包检测。SoftEther 还做了一些调整,以减少延迟并增加吞吐量。此外,SoftEther 还包括一个克隆功能,允许您轻松地从 OpenVPN 过渡到 SoftEther。 + +SoftEther 可以穿透 NAT 防火墙并绕过防火墙。在只允许 ICMP 和 DNS 数据包的受限网络上,您可以利用 SoftEther 的基于 ICMP 或 DNS 的 VPN 方式来穿透防火墙。SoftEther 可与 IPv4 和 IPv6 一起工作。 + +SoftEther 比 OpenVPN 和 strongSwan 更容易设置,但比 Streisand 和 Algo 要复杂。 + +### WireGuard + +[WireGuard][7] 是这个名单上最新的工具;它太新了,甚至还没有完成。也就是说,它为部署 VPN 提供了一种快速简便的方法。它旨在通过使 IPSec 更简单、更精简来改进它,就像 SSH 一样。 + +与 OpenVPN 一样,WireGuard 既是一种协议,也是一种用于部署使用所述协议的 VPN 的软件工具。一个关键特性是“加密密钥路由”,它将公钥与隧道内允许的 IP 地址列表相关联。 + +WireGuard 可用于 Ubuntu、Debian、Fedora、CentOS、MacOS、Windows 和安卓系统。WireGuard 可在 IPv4 和 IPv6 上工作。 + +WireGuard 比大多数其他 VPN 协议轻得多,它只在需要发送数据时才发送数据包。 + +开发人员说,WireGuard 还不应该被信任,因为它还没有被完全审计过,但是欢迎你给它一个机会。这可能是下一个热门! + +### 自制 VPN vs. 商业 VPN + +制作您自己的 VPN 为您的互联网连接增加了一层隐私和安全,但是如果您是唯一一个使用它的人,那么装备精良的第三方,比如政府机构,将很容易追踪到你的活动。 + +此外,如果您计划使用您的 VPN 来解锁地理锁定的内容,自制的 VPN 可能不是最好的选择。因为您只能从一个 IP 地址连接,所以你的 VPN 服务器很容易被阻止。 + +好的商业 VPN 不存在这些问题。有了像 [ExpressVPN][8] 这样的提供商,您可以与数十甚至数百个其他用户共享服务器的 IP 地址,这使得跟踪一个用户的活动几乎变得不可能。您也可以从成百上千的服务器中选择,所以如果其中一台被列入黑名单,你可以切换到另一台。 + +然而,商业 VPN 的权衡是,您必须相信提供商不会窥探您的互联网流量。一定要选择一个有明确的无日志政策的信誉良好的供应商。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/open-source-tools-vpn + +作者:[Paul Bischoff][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[heguangzhi](https://github.com/heguangzhi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/paulbischoff +[1]: https://blog.trailofbits.com/2016/12/12/meet-algo-the-vpn-that-works/ +[2]: https://github.com/StreisandEffect/streisand +[3]: https://openvpn.net/ +[4]: https://github.com/OpenVPN/easy-rsa +[5]: https://www.strongswan.org/ +[6]: https://www.softether.org/ +[7]: https://www.wireguard.com/ +[8]: https://www.comparitech.com/vpn/reviews/expressvpn/ diff --git a/translated/tech/20180831 6 open source tools for making your own VPN.md b/translated/tech/20180831 6 open source tools for making your own VPN.md deleted file mode 100644 index 0ff7ad847e..0000000000 --- a/translated/tech/20180831 6 open source tools for making your own VPN.md +++ /dev/null @@ -1,137 +0,0 @@ -heguangzhi Translating - -6个开源工具制作自己的VPN -====== - - - - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/vpn_scrabble_networking.jpg?itok=pdsUHw5N) - -如果您想尝试建立您自己的 VPN,但是不确定从哪里开始,那么您来对地方了。我将挑选6个最好的免费和开源工具在您自己的服务器上搭建和使用 VPN。这些 VPN 软件不管您是想为您的企业建立站点到站点的,还是仅创建远程代理访问以解除访问限制,并隐藏来自ISP的互联网流量都可以得到解决。 - -根据您的需求和条件,并参考您自己的技术特长,环境以及您想要通过 VPN 实现的目标。需要考虑以下因素: - - * VPN 协议 - * 客户端的数量和设备类型 - * 服务端的兼容性 - * 技术专业的能力 - -### Algo - - -[Algo][1] 是从下往上的设计的,为需要互联网安全代理的企业创建 VPN 专用网。它“只包括您需要的最小化的软件”,这意味着您为了简单而牺牲了可扩展性。Algo 是基于 StrongSwan 的,但是删除了所有您不需要的东西,这有另外一个好处,那就是删除了新手可能不会注意到的安全漏洞。 - - -作为额外的奖励,它甚至屏蔽了广告! - -Algo supports only the IKEv2 protocol and Wireguard. Because IKEv2 support is built into most devices these days, it doesn’t require a client app like OpenVPN. Algo can be deployed using Ansible on Ubuntu (the preferred option), Windows, RedHat, CentOS, and FreeBSD. Setup is automated using Ansible, which configures the server based on your answers to a short set of questions. It’s also very easy to tear down and re-deploy on demand. - - -Algo 只支持 IKEv2 协议和 Wireguard 。因为 IKEv2 支持现在已经内置在大多数设备中,所以它不需要像 OpenVPN 这样的客户端应用程序。Algo 可以使用 Ansible 在 Ubuntu (首选选项)、Windows、RedHat、CentOS 和 FreeBSD 上部署。自动化的安装 Ansible,它根据您对一组简短问题的回答来配置服务。终止和重新部署也非常容易。 - - -Algo 可能是在本篇文章中安装和部署的最简单和最快的VPN。它非常简洁,考虑周全。如果您不需要其他工具提供的任何更高级的功能,只需要一个安全的代理,这是一个很好的选择。请注意,Algo 明确表示,它不是为了解除地理封锁或逃避审查,主要是为了加密。 - -### Streisand - - - -[Streisand][2] 可以使用一个命令安装在任何 Ubuntu 16.04 服务器上;这个过程大约需要10分钟。它支持 L2TP、OpenConnect、OpenSSH、OpenVPN、Shadowsocks、Stunnel、Tor bridge 和 WireGuard。根据您选择的协议,您可能需要安装客户端应用程序。 - - -在很多方面,Streisand 与 Algo 相似,但是它提供了更多的协议和定制。这需要更多的工作来管理和维护,但也更加灵活。注意 Streisand 不支持 IKEv2 。我认为 Streisand 在中国和土耳其这样的地方绕过审查制度更有效,因为它的多功能性,但是 Algo 更容易和更快地安装。 - - -使用 Ansible 可以自动化安装,所以不需要太多的专业技术知识。通过向用户发送自定义生成的连接指令,包括服务器 SSL 证书的嵌入副本,可以轻松添加更多用户。 - - -卸载 Streisand 是一个快速无痛的过程,您可以按需重新部署。 - -### OpenVPN - - -[OpenVPN][3] 要求客户端和服务器应用程序使用同名协议建立 VPN 连接。OpenVPN 可以根据您的需求进行调整和定制,但它也需要更多专业技术知识。支持远程访问和站点到站点配置;如果您计划使 VPN 作为互联网的代理,前者是您需要的。因为客户端应用程序需要在大多数设备上使用 OpenVPN ,最终用户必须保持更新。 - - -在服务器端,您可以选择部署在云中或 Linux 服务器上。兼容的发行版包括 CentOS 、Ubuntu 、Debian 和 openSUSE。Windows 、MacOS 、iOS 和 Android 都有客户端应用程序,其他设备也有非官方应用程序。企业可以选择设置一个 OpenVPN 接入服务器,但是对于想要社区版的个人来说,这可能太过分了。 - - -OpenVPN 相对容易配置静态密钥加密,但并不完全安全。相反,我建议使用 [easy-rsa][4] 来设置它,这是一个密钥管理包,可以用来设置公钥基础设施。这允许您一次连接多个设备,并以完美的前向保密和其他好处来保护它们。OpenVPN 使用 SSL/TLS 进行加密,您可以在配置中指定 DNS 服务器。 - - -OpenVPN 可以穿越防火墙和 NAT 防火墙,这意味着您可以使用它绕过网关和防火墙,否则它们可能会阻止连接。它同时支持 TCP 和 UDP 传输。 - -### StrongSwan - -您可能会遇到一些不同的 VPN 工具,名称中有“Swan”。FreeS/WAN, 、OpenSwan、LibreSwan和[strongSwan][5] 都是同一个项目的分叉,后者是我个人最喜欢的。服务器端,strongSwan 运行在 Linux 2.6、3.x和4x内核、Android、FreeBSD、macOS、iOS 和 Windows上。 - - -StrongSwan 使用 IKEv2 协议和 IPSec 。与 OpenVPN 相比,IKEv2 连接速度更快,同时提供了很好的速度和安全性。如果您更喜欢不需要在客户端安装额外应用程序的协议,这将非常有用,因为现在生产的大多数新设备都支持 IKEv2,,包括 Windows、MacOS、iOS和Android。 - -StrongSwan 并不特别容易使用,尽管文档不错,但它使用的词汇与大多数其他工具不同,这可能会让人比较困惑。它的模块化设计让它对企业来说很棒,但这也意味着它不是最精简。这当然不像 Algo 或Streisand 那么简单。 - - -访问控制可以基于使用X.509 属性证书的组成员身份,这是 strongSwan 独有的功能。它支持用于集成到其他环境(如Windows Active Directory )中的EAP身份验证方法。strongSwan可以穿越NAT 网络防火墙。 - -### SoftEther - - -[SoftEther][6] 是由日本筑波大学的一名研究生发起的一个项目。SoftEther VPN 服务器和 VPN网桥在 Windows、Linux、OSX、FreeBSD 和 Solaris 上运行,而客户端应用程序在Windows、Linux和 MacOS 上运行。VPN 网桥主要用于需要设置站点到站点VPN的企业,因此单个用户只需要服务器和客户端程序来设置远程访问。 - - -SoftEther 支持 OpenVPN、L2TP、SSTP 和 EtherIP 协议,由于“基于HTTPS的以太网”伪装,它自己的 SoftEther 协议声称能够免疫深度数据包检测。SoftEther 还做了一些调整,以减少延迟并增加吞吐量。此外,SoftEther 还包括一个克隆功能,允许您轻松地从 OpenVPN 过渡到SoftEther。 - -SoftEther 可以穿透 NAT 防火墙并绕过防火墙。在只允许 ICMP 和 DNS 数据包的受限网络上,您可以通过 ICMP 利用SoftEther的VPN 或者通过 DNS 利用 VPN 选项来穿透防火墙。SoftEther 可与IPv4 和IPv6 一起工作。 - - -SoftEther 比 OpenVPN 和strongSwan更容易设置,但比 Streisand 和 Algo 更复杂。 - -### WireGuard - - -[WireGuard][7] 是这个名单上最新的工具;它太新了,甚至还没有完成。也就是说,它为部署VPN提供了一种快速简便的方法。它旨在通过使 IPSec 更简单、更精简来改进它,就像SSH一样。 - -与OpenVPN一样,WireGuard 既是一种协议,也是一种软件工具,用于部署使用所述协议的VPN。一个关键特性是“加密密钥路由”,它将公钥与隧道内允许的 IP 地址列表相关联。 - - -WireGuard可用于 Ubuntu、Debian、Fedora、CentOS、MacOS、Windows 和安卓系统。WireGuard可在 IPv4和 IPv6 上工作。 - -WireGuard比大多数其他VPN协议轻得多,它只在需要发送数据时才发送数据包。 - - -开发人员说,WireGuard还不应该被信任,因为它还没有被完全审计过,但是欢迎你给它一个机会。这可能是下一件大事! - -### 自制 VPN vs. 商业 VPN - -制作您自己的 VPN 为您的互联网连接增加了一层隐私和安全,但是如果您是唯一一个使用它的人,那么装备精良的第三方,比如政府机构,将很容易追踪到你的活动。 - -此外,如果您计划使用您的 VPN 来解锁地理锁定的内容,自制的VPN可能不是最好的选择。因为您只能从一个IP地址连接,所以你的 VPN 服务器很容易被阻止。 - - -好的商业 VPN 不存在这些问题。有了像[ExpressVPN][8]这样的提供商,您可以与数十甚至数百个其他用户共享服务器的IP地址,这使得跟踪一个用户的活动几乎变得不可能。您也可以从成百上千的服务器中选择,所以如果其中一台被列入黑名单,你可以切换到另一台。 - - -然而,商业VPN的权衡是,您必须相信提供商不会窥探您的互联网流量。一定要选择一个有明确的无日志政策的信誉良好的供应商。 - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/open-source-tools-vpn - -作者:[Paul Bischoff][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: -[1]: https://blog.trailofbits.com/2016/12/12/meet-algo-the-vpn-that-works/ -[2]: https://github.com/StreisandEffect/streisand -[3]: https://openvpn.net/ -[4]: https://github.com/OpenVPN/easy-rsa -[5]: https://www.strongswan.org/ -[6]: https://www.softether.org/ -[7]: https://www.wireguard.com/ -[8]: https://www.comparitech.com/vpn/reviews/expressvpn/ From 89a6d1efcf43c800103ec0cdbbde6f6e9cbeaf11 Mon Sep 17 00:00:00 2001 From: pityonline Date: Tue, 18 Sep 2018 23:12:49 +0800 Subject: [PATCH 301/455] =?UTF-8?q?PRF:=20#10184=20=E6=A0=A1=E5=AF=B9?= =?UTF-8?q?=E5=B9=B6=E5=88=9D=E6=AD=A5=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 --- ...0180308 What is open source programming.md | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/translated/talk/20180308 What is open source programming.md b/translated/talk/20180308 What is open source programming.md index ad732e1996..4791a64aab 100644 --- a/translated/talk/20180308 What is open source programming.md +++ b/translated/talk/20180308 What is open source programming.md @@ -1,10 +1,11 @@ -何谓开源编程? +何谓开源编程? ====== + > 开源就是丢一些代码到 GitHub 上。了解一下它是什么,以及不是什么? ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82) -最简单的来说,开源编程就是编写一些大家可以随意取用、修改的代码。但你肯定听过关于 Go 语言的那个老笑话,说 Go 语言“简单到看一眼就可以明白规则,但需要一辈子去学会运用它”。其实写开源代码也是这样的。往 GitHub、Bitbucket、 SourceForge 等网站或者是你自己的博客或网站上丢几行代码不是难事,但想要卓有成效,还需要个人的努力付出和高瞻远瞩。 +最简单的来说,开源编程就是编写一些大家可以随意取用、修改的代码。但你肯定听过关于 Go 语言的那个老笑话,说 Go 语言“简单到看一眼就可以明白规则,但需要一辈子去学会运用它”。其实写开源代码也是这样的。往 GitHub、Bitbucket、SourceForge 等网站或者是你自己的博客或网站上丢几行代码不是难事,但想要卓有成效,还需要个人的努力付出和高瞻远瞩。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/floorgoban.jpeg?itok=r8gA5jOk) @@ -12,29 +13,29 @@ 首先我要说清楚一点:把你的代码放在 GitHub 的公开仓库中并不意味着把你的代码开源了。在几乎全世界,根本不用创作者做什么,只要作品形成,版权就随之而生了。在创作者进行授权之前,只有作者可以行使版权相关的权力。未经创作者授权的代码,不论有多少人在使用,都是一颗定时炸弹,只有愚蠢的人才会去用它。 -有些创作者很善良,认为“很明显我的代码是免费提供给大家使用的。”,他也并不想起诉那些用了他的代码的人,但这并不意味着这些代码可以放心使用。不论在你眼中创作者们多么善良,他们都是*有权力*起诉任何使用、修改代码,或未经明确授权就将代码嵌入的人。 +有些创作者很善良,认为“很明显我的代码是免费提供给大家使用的。”,他也并不想起诉那些用了他的代码的人,但这并不意味着这些代码可以放心使用。不论在你眼中创作者们多么善良,他们都是 *有权力* 起诉任何使用、修改代码,或未经明确授权就将代码嵌入的人。 很明显,你不应该在没有指定开源许可证的情况下将你的源代码发布到网上然后期望别人使用它并为其做出贡献,我建议你也尽量避免使用这种代码,甚至疑似未授权的也不要使用。如果你开发了一个函数和例程,它和之前一个疑似未授权代码很像,源代码作者就可以对你就侵权提起诉讼。 -举个例子, Jill Schmill 写了 AwesomeLib 然后未明确授权就把它放到了 GitHub 上,就算 Jill Schmill 不起诉任何人,只要她把 AwesomeLib 的完整版权都卖给 EvilCorp,EvilCorp 就会起诉之前违规使用这段代码的人。这种行为就好像是埋下了计算机安全隐患,总有一天会为人所用。 - +举个例子,Jill Schmill 写了 AwesomeLib 然后未明确授权就把它放到了 GitHub 上,就算 Jill Schmill 不起诉任何人,只要她把 AwesomeLib 的完整版权都卖给 EvilCorp,EvilCorp 就会起诉之前违规使用这段代码的人。这种行为就好像是埋下了计算机安全隐患,总有一天会为人所用。 + 没有许可证的代码的危险的,切记。 - + ### 选择恰当的开源许可证 假设你正要写一个新程序,而且打算让人们以开源的方式使用它,你需要做的就是选择最贴合你需求的[许可证][1]。和宣传中说的一样,你可以从 GitHub 所支持的 [choosealicense.com][2] 开始。这个网站设置得像个简单的问卷,特别方便快捷,点几下就能找到合适的许可证。 -警示:在选择许可证时不要过于自负,如果你选的是 [Apache 许可证][3] 或者 [GPLv3][4] 这种广为使用的许可证,人们很容易理解其对于权利的规划,你也不需要请律师来排查其中的漏洞。你选择的许可证使用的人越少,带来的麻烦越多。 +警示:在选择许可证时不要过于自负,如果你选的是 [Apache 许可证][3]或者 [GPLv3][4] 这种广为使用的许可证,人们很容易理解其对于权利的规划,你也不需要请律师来排查其中的漏洞。你选择的许可证使用的人越少,带来的麻烦越多。 -最重要的一点是:*千万不要试图自己编造许可证!*自己编造许可证会给大家带来更多的困惑和困扰,不要这样做。如果在现有的许可证中确实找不到你需要的条款,你可以在现有的许可证中附加上你的要求,并且重点标注出来,提醒使用者们注意。 +最重要的一点是: *千万不要试图自己编造许可证!* 自己编造许可证会给大家带来更多的困惑和困扰,不要这样做。如果在现有的许可证中确实找不到你需要的条款,你可以在现有的许可证中附加上你的要求,并且重点标注出来,提醒使用者们注意。 我知道有些人会说:“我才懒得管什么许可证,我已经把代码发到公开领域public domain了。”但问题是,公开领域的法律效力并不是受全世界认可的。在不同的国家,公开领域的效力和表现形式不同。有些国家的政府管控下,你甚至不可以把自己的源代码发到公开领域中。万幸,[Unlicense][5] 可以弥补这些漏洞,它语言简洁,使用几个词清楚地描述了“就把它放到公开领域”,但其效力为全世界认可。 ### 怎样引入许可证 -确定使用哪个许可证之后,你需要清晰而无疑义地指定它。如果你是在 GitHub、 GitLab 或 BitBucket 这几个网站发布,你需要构建很多个文件夹,在根文件夹中,你应把许可证创建为一个以 `LICENSE.txt` 命名的明文文件。 +确定使用哪个许可证之后,你需要清晰而无疑义地指定它。如果你是在 GitHub、GitLab 或 BitBucket 这几个网站发布,你需要构建很多个文件夹,在根文件夹中,你应把许可证创建为一个以 `LICENSE.txt` 命名的明文文件。 -创建 `LICENSE.txt` 这个文件之后还有其他事要做。你需要在每个有效文件的页眉中添加注释块来申明许可证。如果你使用的是一现有的许可证,这一步对你来说十分简便。一个 `# 项目名 (c)2018 作者名, GPLv3 许可证,详情见 https://www.gnu.org/licenses/gpl-3.0.en.html` 这样的注释块比隐约指代的许可证的效力要强得多。 +创建 `LICENSE.txt` 这个文件之后还有其他事要做。你需要在每个有效文件的页眉中添加注释块来申明许可证。如果你使用的是一现有的许可证,这一步对你来说十分简便。一个 `# 项目名 (c)2018 作者名,GPLv3 许可证,详情见 https://www.gnu.org/licenses/gpl-3.0.en.html` 这样的注释块比隐约指代的许可证的效力要强得多。 如果你是要发布在自己的网站上,步骤也差不多。先创建 `LICENSE.txt` 文件,放入许可证,再表明许可证出处。 @@ -46,19 +47,19 @@ 你的源代码也可能逼疯你,尤其是在你一遍又一遍地修改错误的函数或是子过程后,终于出现了你希望的结果,这时你不会叹口气就继续下一个任务,你会把过程清理干净,因为你不会愿意别人看出你一遍遍尝试的痕迹。比如你会把 `$variable`、`$lol` 全都换成有意义的 `$iterationcounter` 和 `$modelname`。这意味着你要认真专业地进行注释(尽管对于头脑风暴中的你来说它并不难懂),但为了之后有更多的人可以使用你的代码,你会尽力去注释,但注意适可而止。 -这个过程难免有些痛苦沮丧,毕竟这不是你常做的事,会有些不习惯。但它会使你成为一位更好的程序员,也会让你的代码升华。即使你的项目只有你一位贡献者,清理代码也会节约你后期的很多工作,相信我一年后你更新 app 时,你会庆幸自己现在写下的是 `$modelname`,还有清晰的注释,而不是什么不知名的数列,甚至连 `$lol`也不是。 +这个过程难免有些痛苦沮丧,毕竟这不是你常做的事,会有些不习惯。但它会使你成为一位更好的程序员,也会让你的代码升华。即使你的项目只有你一位贡献者,清理代码也会节约你后期的很多工作,相信我一年后你更新 app 时,你会庆幸自己现在写下的是 `$modelname`,还有清晰的注释,而不是什么不知名的数列,甚至连 `$lol` 也不是。 ### 你并不是为你一人而写 开源的真正核心并不是那些代码,是社区。更大的社区的项目维持的时间更长,也更容易为人们接受。因此不仅要加入社区,还要多多为社区发展贡献思路,让自己的项目能够为社区所用。 -蝙蝠侠为了完成目标暗中独自花了很大功夫,你用不着这样,你可以登录 Twitter、 Reddit,或者给你项目的相关人士发邮件,发布你正在筹备新项目的消息,仔细聊聊项目的设计初衷和你的计划,让大家一起帮忙,向大家征集数据输入,类似的使用案例,把这些信息整合起来,用在你的代码里。你不用看所有的回复,但你要对它有个大概把握,这样在你之后完善时可以躲过一些陷阱。 +蝙蝠侠为了完成目标暗中独自花了很大功夫,你用不着这样,你可以登录 Twitter、Reddit,或者给你项目的相关人士发邮件,发布你正在筹备新项目的消息,仔细聊聊项目的设计初衷和你的计划,让大家一起帮忙,向大家征集数据输入,类似的使用案例,把这些信息整合起来,用在你的代码里。你不用看所有的回复,但你要对它有个大概把握,这样在你之后完善时可以躲过一些陷阱。 不发首次通告这个过程还不算完整。如果你希望大家能够接受你的作品,并且使用它,你就要以此为初衷来设计。公众说不定可以帮到你,你不必对公开这件事如临大敌。所以不要闭门造车,既然你是为大家而写,那就开设一个真实、公开的项目,想象你在社区的监督下,认真地一步步完成它。 ### 建立项目的方式 -你可以在 GitHub、 GitLab 或 BitBucket 上免费注册账号来管理你的项目。注册之后,创建知识库,建立 `README` 文件,分配一个许可证,一步步写入代码。这样可以帮你建立好习惯,让你之后和现实中的团队一起工作时,也能目的清晰地朝着目标稳妥地进行工作。这样你做得越久,就越有兴趣。 +你可以在 GitHub、GitLab 或 BitBucket 上免费注册账号来管理你的项目。注册之后,创建知识库,建立 `README` 文件,分配一个许可证,一步步写入代码。这样可以帮你建立好习惯,让你之后和现实中的团队一起工作时,也能目的清晰地朝着目标稳妥地进行工作。这样你做得越久,就越有兴趣。 用户们会开始对你产生兴趣,这会让你开心也会让你不爽,但你应该亲切礼貌地对待他们,就算他们很多人根本不知道你的项目做的是什么,你可以把文件给他们看,让他们了解你在干什么。有些还在犹豫的用户可以给你提个醒,告诉你最开始设计的用户范围中落下了哪些人。 @@ -80,9 +81,9 @@ via: https://opensource.com/article/18/3/what-open-source-programming 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 -[a]:https://opensource.com/users/jim-salter -[1]:https://opensource.com/tags/licensing -[2]:https://choosealicense.com/ -[3]:https://choosealicense.com/licenses/apache-2.0/ -[4]:https://choosealicense.com/licenses/gpl-3.0/ -[5]:https://choosealicense.com/licenses/unlicense/ +[a]: https://opensource.com/users/jim-salter +[1]: https://opensource.com/tags/licensing +[2]: https://choosealicense.com/ +[3]: https://choosealicense.com/licenses/apache-2.0/ +[4]: https://choosealicense.com/licenses/gpl-3.0/ +[5]: https://choosealicense.com/licenses/unlicense/ From 5c70bc587ba8e62856b0e626fdd192d183161d79 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 18 Sep 2018 23:35:52 +0800 Subject: [PATCH 302/455] PRF:20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @pinewall 翻译的很棒 --- ...ams and scripts easily with PySimpleGUI.md | 60 ++++++++++--------- 1 file changed, 31 insertions(+), 29 deletions(-) diff --git a/translated/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md b/translated/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md index ce4a4c2b08..9eff0b65d3 100644 --- a/translated/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md +++ b/translated/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md @@ -1,31 +1,33 @@ 使用 PySimpleGUI 轻松为程序和脚本增加 GUI ====== +> 五分钟创建定制 GUI。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh) -对于 `.exe` 类型的程序文件,我们可以通过双击鼠标左键打开;但对于 `.py` 类型的 Python 程序,几乎不会有人尝试同样的操作。对于一个(非程序员类型的)典型用户,他们双击打开 `.exe` 文件时预期弹出一个可以交互的窗体。基于 `Tkinter`,可以通过标准 Python 安装standard Python installations的方式提供 GUI,但很多程序都不太可能这样做。 +对于 `.exe` 类型的程序文件,我们可以通过双击鼠标左键打开;但对于 `.py` 类型的 Python 程序,几乎不会有人尝试同样的操作。对于一个(非程序员类型的)典型用户,他们双击打开 `.exe` 文件时预期弹出一个可以交互的窗体。基于 Tkinter,可以通过标准 Python 安装standard Python installations的方式提供 GUI,但很多程序都不太可能这样做。 如果打开 Python 程序并进入 GUI 界面变得如此容易,以至于真正的初学者也可以掌握,会怎样呢?会有人感兴趣并使用吗?这个问题不好回答,因为直到今天创建自定义 GUI 布局仍不是件容易的事情。 -在为程序或脚本增加 GUI 这件事上,似乎存在能力的“错配”。(缺乏这方面能力的)真正的初学者被迫只能使用命令行方式,而很多(具备这方面能力的)高级程序员却不愿意花时间创建一个 `Tkinter` GUI。 +在为程序或脚本增加 GUI 这件事上,似乎存在能力的“错配”。(缺乏这方面能力的)真正的初学者被迫只能使用命令行方式,而很多(具备这方面能力的)高级程序员却不愿意花时间创建一个 Tkinter GUI。 ### GUI 框架 -Python 的 GUI 框架并不少,其中 `Tkinter`,`wxPython`,`Qt` 和 `Kivy` 是几种比较主流的框架。此外,还有不少在上述框架基础上封装的简化框架,例如 `EasyGUI`,`PyGUI` 和 `Pyforms` 等。 +Python 的 GUI 框架并不少,其中 Tkinter,wxPython,Qt 和 Kivy 是几种比较主流的框架。此外,还有不少在上述框架基础上封装的简化框架,例如 EasyGUI,PyGUI 和 Pyforms 等。 但问题在于,对于初学者(这里是指编程经验不超过 6 个月的用户)而言,即使是最简单的主流框架,他们也无从下手;他们也可以选择封装过的(简化)框架,但仍难以甚至无法创建自定义 GUI 布局layout。即便学会了某种(简化)框架,也需要编写连篇累牍的代码。 -[`PySimpleGUI`][1] 尝试解决上述 GUI 难题,它提供了一种简单明了、易于理解、方便自定义的 GUI 接口。如果使用 `PySimpleGUI`,很多复杂的 GUI 也仅需不到 20 行代码。 +[PySimpleGUI][1] 尝试解决上述 GUI 难题,它提供了一种简单明了、易于理解、方便自定义的 GUI 接口。如果使用 PySimpleGUI,很多复杂的 GUI 也仅需不到 20 行代码。 ### 秘诀 -`PySimpleGUI` 极为适合初学者的秘诀在于,它已经包含了绝大多数原本需要用户编写的代码。`PySimpleGUI` 处理按钮回调callback,无需用户编写代码。对于初学者,在几周内掌握函数的概念已经不容易了,要求其理解回调函数似乎有些强人所难。 +PySimpleGUI 极为适合初学者的秘诀在于,它已经包含了绝大多数原本需要用户编写的代码。PySimpleGUI 会处理按钮回调callback,无需用户编写代码。对于初学者,在几周内掌握函数的概念已经不容易了,要求其理解回调函数似乎有些强人所难。 -在大部分 GUI 框架中,布局 GUI 小部件widgets通常需要写一些代码,每个小部件至少 1-2 行。`PySimpleGUI` 使用了“auto-packer”技术,可以自动创建布局。因而,布局 GUI 窗口不再需要 `pack` 或 `grid` 系统。 +在大部分 GUI 框架中,布局 GUI 小部件widgets通常需要写一些代码,每个小部件至少 1-2 行。PySimpleGUI 使用了 “auto-packer” 技术,可以自动创建布局。因而,布局 GUI 窗口不再需要 pack 或 grid 系统。 -(LCTT 译注:这里提到的 `pack` 和 `grid` 都是 `Tkinter` 的布局管理器,另外一种叫做 `place`) +(LCTT 译注:这里提到的 pack 和 grid 都是 Tkinter 的布局管理器,另外一种叫做 place 。) -最后,`PySimpleGUI` 框架编写中有效利用 Python 语言特性,降低用户代码量并简化GUI 数据返回的方式。在窗体form布局中创建小部件时,小部件会被部署到对应的布局中,无需额外的代码。 +最后,PySimpleGUI 框架编写中有效地利用了 Python 语言特性,降低用户代码量并简化 GUI 数据返回的方式。在窗体form布局中创建小部件时,小部件会被部署到对应的布局中,无需额外的代码。 ### GUI 是什么? @@ -37,13 +39,13 @@ button, values = GUI_Display(gui_layout) 绝大多数 GUI 支持的用户行为包括鼠标点击(例如,“确认”,“取消”,“保存”,“是”和“否”等)和内容输入。GUI 本质上可以归结为一行代码。 -这也正是 `PySimpleGUI` (简单 GUI 模式)的工作原理。当执行命令显示 GUI 后,除非点击鼠标关闭窗体,否则不会执行任何代码。 +这也正是 PySimpleGUI (的简单 GUI 模式)的工作原理。当执行命令显示 GUI 后,除非点击鼠标关闭窗体,否则不会执行任何代码。 -当然还有更复杂的 GUI,其中鼠标点击后窗口并不关闭;例如,机器人的远程控制界面,聊天窗口等。这类复杂的窗体也可以用 `PySimpleGUI` 创建。 +当然还有更复杂的 GUI,其中鼠标点击后窗口并不关闭;例如,机器人的远程控制界面,聊天窗口等。这类复杂的窗体也可以用 PySimpleGUI 创建。 ### 快速创建 GUI -`PySimpleGUI` 什么时候有用呢?显然,是你需要 GUI 的时候。仅需不超过 5 分钟,就可以让你创建并尝试 GUI。最便捷的 GUI 创建方式就是从 [PySimpleGUI 经典实例][2]中拷贝一份代码。具体操作流程如下: +PySimpleGUI 什么时候有用呢?显然,是你需要 GUI 的时候。仅需不超过 5 分钟,就可以让你创建并尝试 GUI。最便捷的 GUI 创建方式就是从 [PySimpleGUI 经典实例][2]中拷贝一份代码。具体操作流程如下: * 找到一个与你需求最接近的 GUI * 从经典实例中拷贝代码 @@ -93,13 +95,14 @@ button, (name,) = form.LayoutAndRead(layout) ### 5 分钟内创建一个自定义 GUI -在简单布局的基础上,通过修改经典实例中的代码,5 分钟内即可使用 `PySimpleGUI` 创建自定义布局。 +在简单布局的基础上,通过修改经典实例中的代码,5 分钟内即可使用 PySimpleGUI 创建自定义布局。 -在 `PySimpleGUI` 中,小部件widgets被称为元素elements。元素的名称与编码中使用的名称保持一致。 +在 PySimpleGUI 中,小部件widgets被称为元素elements。元素的名称与编码中使用的名称保持一致。 -(LCTT 译注:`Tkinter` 中使用小部件这个词) +(LCTT 译注:Tkinter 中使用小部件这个词) #### 核心元素 + ``` Text InputText @@ -121,7 +124,7 @@ Column #### 元素简写 -`PySimpleGUI` 还包含两种元素简写方式。一种是元素类型名称简写,例如 `T` 用作 `Text` 的简写;另一种是元素参数被配置了默认值,你可以无需指定所有参数,例如 `Submit` 按钮默认的文本就是“Submit”。 +PySimpleGUI 还包含两种元素简写方式。一种是元素类型名称简写,例如 `T` 用作 `Text` 的简写;另一种是元素参数被配置了默认值,你可以无需指定所有参数,例如 `Submit` 按钮默认的文本就是 “Submit”。 ``` T = Text @@ -164,9 +167,9 @@ RealtimeButton (LCTT 译注:其实就是返回 `Button` 类实例的函数) -上面就是 `PySimpleGUI` 支持的全部元素。如果不在上述列表之中,就不会在你的窗口布局中生效。 +上面就是 PySimpleGUI 支持的全部元素。如果不在上述列表之中,就不会在你的窗口布局中生效。 -(LCTT 译注:上述都是 `PySimpleGUI` 的类名、类别名或返回实例的函数,自然只能使用列表内的。) +(LCTT 译注:上述都是 PySimpleGUI 的类名、类别名或返回实例的函数,自然只能使用列表内的。) #### GUI 设计模式 @@ -182,7 +185,7 @@ form = sg.FlexForm('Simple data entry form') button, values = form.LayoutAndRead(layout) ``` -(LCTT 译注:这段代码无法运行,只是为了说明每个程序都会用到的设计模式) +(LCTT 译注:这段代码无法运行,只是为了说明每个程序都会用到的设计模式。) 对于绝大多数 GUI,编码流程如下: @@ -190,7 +193,7 @@ button, values = form.LayoutAndRead(layout) * 以“列表的列表”的形式定义 GUI * 展示 GUI 并获取元素的值 -上述流程与 `PySimpleGUI` 设计模式部分的代码一一对应。 +上述流程与 PySimpleGUI 设计模式部分的代码一一对应。 #### GUI 布局 @@ -201,7 +204,6 @@ button, values = form.LayoutAndRead(layout) ``` layout = [  [Text('Row 1')],             [Text('Row 2'), Checkbox('Checkbox 1', OK()), Checkbox('Checkbox 2'), OK()] ] - ``` 上述布局对应的效果如下: @@ -220,24 +222,24 @@ button, values = form.LayoutAndRead(layout) 窗体返回的结果由两部分组成:一部分是被点击按钮的名称,另一部分是一个列表,包含所有用户输入窗体的值。 -在这个例子中,窗体显示后用户直接点击 `OK` 按钮,返回的结果如下: +在这个例子中,窗体显示后用户直接点击 “OK” 按钮,返回的结果如下: ``` button == 'OK' values == [False, False] ``` -`Checkbox` 类型元素返回 `True` 或 `False` 类型的值。由于默认处于未选中状态,两个元素的值都是 `False`。 +Checkbox 类型元素返回 `True` 或 `False` 类型的值。由于默认处于未选中状态,两个元素的值都是 `False`。 ### 显示元素的值 一旦从 GUI 获取返回值,检查返回变量中的值是个不错的想法。与其使用 `print` 语句进行打印,我们不妨坚持使用 GUI 并在一个窗口中输出这些值。 -(LCTT 译注:考虑使用的是 Python 3 版本,`print` 应该是函数而不是语句) +(LCTT 译注:考虑使用的是 Python 3 版本,`print` 应该是函数而不是语句。) -在 `PySimpleGUI` 中,有多种消息框可供选取。传递给消息框(函数)的数据会被显示在消息框中;函数可以接受任意数目的参数,你可以轻松的将所有要查看的变量展示出来。 +在 PySimpleGUI 中,有多种消息框可供选取。传递给消息框(函数)的数据会被显示在消息框中;函数可以接受任意数目的参数,你可以轻松的将所有要查看的变量展示出来。 -在 `PySimpleGUI` 中,最常用的消息框是 `MsgBox`。要展示上面例子中的数据,只需编写一行代码: +在 PySimpleGUI 中,最常用的消息框是 `MsgBox`。要展示上面例子中的数据,只需编写一行代码: ``` MsgBox('The GUI returned:', button, values) @@ -245,7 +247,7 @@ MsgBox('The GUI returned:', button, values) ### 整合 -好了,你已经了解了基础知识,让我们创建一个包含尽可能多 `PySimpleGUI` 元素的窗体吧!此外,为了更好的感观效果,我们将采用绿色/棕褐色的配色方案。 +好了,你已经了解了基础知识,让我们创建一个包含尽可能多 PySimpleGUI 元素的窗体吧!此外,为了更好的感观效果,我们将采用绿色/棕褐色的配色方案。 ``` import PySimpleGUI as sg @@ -284,7 +286,7 @@ button, values = form.LayoutAndRead(layout) sg.MsgBox(button, values) ``` -看上面要写不少代码,但如果你试着直接使用 `Tkinter` 框架实现同样的 GUI,你很快就会发现 `PySimpleGUI` 版本的代码是多么的简洁。 +看上面要写不少代码,但如果你试着直接使用 Tkinter 框架实现同样的 GUI,你很快就会发现 PySimpleGUI 版本的代码是多么的简洁。 ![](https://opensource.com/sites/default/files/uploads/pysimplegui-everything.jpg) @@ -317,7 +319,7 @@ else: #### 安装方式 -支持 `Tkinter` 的系统就支持 `PySimpleGUI`,甚至包括树莓派Raspberry Pi,但你需要使用 Python 3。 +支持 Tkinter 的系统就支持 PySimpleGUI,甚至包括树莓派Raspberry Pi,但你需要使用 Python 3。 ``` pip install PySimpleGUI @@ -336,7 +338,7 @@ via: https://opensource.com/article/18/8/pysimplegui 作者:[Mike Barnett][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[pinewall](https://github.com/pinewall) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 3f58d297e99748103be940fb24c6355e2b69663e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 18 Sep 2018 23:36:30 +0800 Subject: [PATCH 303/455] PUB:20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md @pinewall https://linux.cn/article-10027-1.html --- ...d GUIs to your programs and scripts easily with PySimpleGUI.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md (100%) diff --git a/translated/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md b/published/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md similarity index 100% rename from translated/tech/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md rename to published/20180829 Add GUIs to your programs and scripts easily with PySimpleGUI.md From 51deb395463ecdaa1d17aa1644ebcd24bcfda24e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 19 Sep 2018 08:12:25 +0800 Subject: [PATCH 304/455] PRF:20180910 Randomize your MAC address using NetworkManager.md @HankChow --- ...e your MAC address using NetworkManager.md | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/translated/tech/20180910 Randomize your MAC address using NetworkManager.md b/translated/tech/20180910 Randomize your MAC address using NetworkManager.md index 1b9eeece65..54485e6ca4 100644 --- a/translated/tech/20180910 Randomize your MAC address using NetworkManager.md +++ b/translated/tech/20180910 Randomize your MAC address using NetworkManager.md @@ -5,13 +5,13 @@ 今时今日,无论在家里的沙发上,还是在外面的咖啡厅,只要打开笔记本电脑,连上 Wi-Fi,就能通过网络与外界保持联系。但现在的 Wi-Fi 热点们大都能够通过[每张网卡对应的唯一 MAC 地址][1]来追踪你的设备。下面就来看一下如何避免被追踪。 -现在很多人已经开始注重个人隐私这个问题。个人隐私问题并不仅仅指防止他人能够访问到你电脑上的私有内容(这又是另一个问题了),而更多的是指可追踪性,也就是是否能够被轻易地统计和追踪到。大家都应该[对此更加重视][2]。同时,这方面的底线是,服务提供者在得到了用户的授权后才能对用户进行追踪,例如机场的计时 Wi-Fi 只有在用户授权后才能够使用。 +现在很多人已经开始注重个人隐私这个问题。个人隐私问题并不仅仅指防止他人能够访问到你电脑上的私有内容(这又是另一个问题了),而更多的是指可追踪性legibility,也就是是否能够被轻易地统计和追踪到。大家都应该[对此更加重视][2]。同时,这方面的底线是,服务提供者在得到了用户的授权后才能对用户进行追踪,例如机场的计时 Wi-Fi 只有在用户授权后才能够使用。 -因为固定的 MAC 地址能被轻易地追踪到,所以应该定时进行更换,随机的 MAC 地址是一个好的选择。由于 MAC 地址一般只在局域网内使用,因此随机的 MAC 地址也不太容易产生[冲突][3]。 +因为固定的 MAC 地址能被轻易地追踪到,所以应该定时进行更换,随机的 MAC 地址是一个好的选择。由于 MAC 地址一般只在局域网内使用,因此随机的 MAC 地址也不大会产生[冲突][3]。 ### 配置 NetworkManager -要将随机的 MAC 地址默认应用与所有的 Wi-Fi 连接,需要创建 /etc/NetworkManager/conf.d/00-macrandomize.conf 这个文件: +要将随机的 MAC 地址默认地用于所有的 Wi-Fi 连接,需要创建 `/etc/NetworkManager/conf.d/00-macrandomize.conf` 这个文件: ``` [device] @@ -21,51 +21,47 @@ wifi.scan-rand-mac-address=yes wifi.cloned-mac-address=stable ethernet.cloned-mac-address=stable connection.stable-id=${CONNECTION}/${BOOT} - ``` 然后重启 NetworkManager : ``` systemctl restart NetworkManager - ``` -以上配置文件中,将 cloned-mac-address 的值设置为 stable 就可以在每次 NetworkManager 激活连接的时候都生成相同的 MAC 地址,但连接时使用不同的 MAC 地址。如果要在每次激活连接时获得随机的 MAC 地址,需要将 cloned-mac-address 的值设置为 random。 +以上配置文件中,将 `cloned-mac-address` 的值设置为 `stable` 就可以在每次 NetworkManager 激活连接的时候都生成相同的 MAC 地址,但连接时使用不同的 MAC 地址。如果要在每次激活连接时也获得随机的 MAC 地址,需要将 `cloned-mac-address` 的值设置为 `random`。 -设置为 stable 可以从 DHCP 获取相同的 IP 地址,也可以让 Wi-Fi 的强制主页根据 MAC 地址记住你的登录状态。如果设置为 random ,在每次连接的时候都需要重新认证(或者点击“我同意”),在使用机场 Wi-Fi 的时候会需要到这种 random 模式。可以在 NetworkManager 的[博客文章][4]中参阅到有关使用 nmcli 从终端配置特定连接的详细说明。 +设置为 `stable` 可以从 DHCP 获取相同的 IP 地址,也可以让 Wi-Fi 的[强制主页](https://en.wikipedia.org/wiki/Captive_portal)captive portal根据 MAC 地址记住你的登录状态。如果设置为 `random` ,在每次连接的时候都需要重新认证(或者点击“我同意”),在使用机场 Wi-Fi 的时候会需要到这种 `random` 模式。可以在这篇 NetworkManager 的[博客文章][4]中参阅到有关使用 `nmcli` 从终端配置特定连接的详细说明。 -使用 ip link 命令可以查看当前的 MAC 地址,MAC 地址将会显示在 ether 一词的后面。 +使用 `ip link` 命令可以查看当前的 MAC 地址,MAC 地址将会显示在 `ether` 一词的后面。 ``` $ ip link 1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 - link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp2s0: mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000 - link/ether 52:54:00:5f:d5:4e brd ff:ff:ff:ff:ff:ff + link/ether 52:54:00:5f:d5:4e brd ff:ff:ff:ff:ff:ff 3: wlp1s0: mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000 - link/ether 52:54:00:03:23:59 brd ff:ff:ff:ff:ff:ff - + link/ether 52:54:00:03:23:59 brd ff:ff:ff:ff:ff:ff ``` ### 什么时候不能随机化 MAC 地址 -当然,在某些情况下确实需要能被追踪到。例如在家用网络中,可能需要将路由器配置为对电脑分配一致的 IP 地址以进行端口转发;再例如公司的雇主可能需要根据 MAC 地址来提供 Wi-Fi 服务,这时候就需要进行追踪。要更改特定的 Wi-Fi 连接,请使用 nmcli 查看 NetworkManager 连接并显示当前设置: +当然,在某些情况下确实需要能被追踪到。例如在家用网络中,可能需要将路由器配置为对电脑分配一致的 IP 地址以进行端口转发;再例如公司的雇主可能需要根据 MAC 地址来提供 Wi-Fi 服务,这时候就需要进行追踪。要更改特定的 Wi-Fi 连接,请使用 `nmcli` 查看 NetworkManager 连接并显示当前设置: ``` $ nmcli c | grep wifi -Amtrak_WiFi 5f4b9f75-9e41-47f8-8bac-25dae779cd87 wifi -- -StaplesHotspot de57940c-32c2-468b-8f96-0a3b9a9b0a5e wifi -- -MyHome e8c79829-1848-4563-8e44-466e14a3223d wifi wlp1s0 +Amtrak_WiFi 5f4b9f75-9e41-47f8-8bac-25dae779cd87 wifi -- +StaplesHotspot de57940c-32c2-468b-8f96-0a3b9a9b0a5e wifi -- +MyHome e8c79829-1848-4563-8e44-466e14a3223d wifi wlp1s0 ... $ nmcli c show 5f4b9f75-9e41-47f8-8bac-25dae779cd87 | grep cloned -802-11-wireless.cloned-mac-address: -- +802-11-wireless.cloned-mac-address: -- $ nmcli c show e8c79829-1848-4563-8e44-466e14a3223d | grep cloned -802-11-wireless.cloned-mac-address: stable - +802-11-wireless.cloned-mac-address: stable ``` -以下这个例子使用 Amtrak 的完全随机 MAC 地址(使用默认配置)和 MyHome 的永久 MAC 地址(使用 stable 配置)。永久 MAC 地址是在硬件生产的时候分配到网络接口上的,网络管理员能够根据永久 MAC 地址来查看[设备的制造商 ID][5]。 +这个例子在 Amtrak 使用完全随机 MAC 地址(使用默认配置)和 MyHome 的永久 MAC 地址(使用 `stable` 配置)。永久 MAC 地址是在硬件生产的时候分配到网络接口上的,网络管理员能够根据永久 MAC 地址来查看[设备的制造商 ID][5]。 更改配置并重新连接活动的接口: @@ -76,7 +72,6 @@ $ nmcli c down e8c79829-1848-4563-8e44-466e14a3223d $ nmcli c up e8c79829-1848-4563-8e44-466e14a3223d $ ip link ... - ``` 你还可以安装 NetworkManager-tui ,就可以通过可视化界面菜单来编辑连接。 @@ -92,7 +87,7 @@ via: https://fedoramagazine.org/randomize-mac-address-nm/ 作者:[sheogorath][a],[Stuart D Gathman][b] 选题:[lujun9972](https://github.com/lujun9972) 译者:[HankChow](https://github.com/HankChow) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 77c339d08117f0d03e8e877ae18c476af4c70279 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 19 Sep 2018 08:13:11 +0800 Subject: [PATCH 305/455] PUB:20180910 Randomize your MAC address using NetworkManager.md @HankChow https://linux.cn/article-10028-1.html --- .../20180910 Randomize your MAC address using NetworkManager.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180910 Randomize your MAC address using NetworkManager.md (100%) diff --git a/translated/tech/20180910 Randomize your MAC address using NetworkManager.md b/published/20180910 Randomize your MAC address using NetworkManager.md similarity index 100% rename from translated/tech/20180910 Randomize your MAC address using NetworkManager.md rename to published/20180910 Randomize your MAC address using NetworkManager.md From 38cb6a75edd0395758ca0f40641b451e889597a6 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 19 Sep 2018 08:28:46 +0800 Subject: [PATCH 306/455] PRF:20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md @ucasFL --- ...nd Line Interface For Trashcan On Linux.md | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/translated/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md b/translated/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md index 198c8d0ffa..b6bb716ece 100644 --- a/translated/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md +++ b/translated/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md @@ -1,4 +1,4 @@ -Trash-Cli : Linux 上的命令行回收站工具 +Trash-Cli:Linux 上的命令行回收站工具 ====== 相信每个人都对回收站trashcan很熟悉,因为无论是对 Linux 用户,还是 Windows 用户,或者 Mac 用户来说,它都很常见。当你删除一个文件或目录的时候,该文件或目录会被移动到回收站中。 @@ -33,31 +33,27 @@ $ sudo apt install trash-cli ``` $ sudo yum install trash-cli - ``` 对于 Fedora 用户,使用 [dnf][6] 命令来安装 Trash-Cli: ``` $ sudo dnf install trash-cli - ``` 对于 Arch Linux 用户,使用 [pacman][7] 命令来安装 Trash-Cli: ``` $ sudo pacman -S trash-cli - ``` 对于 openSUSE 用户,使用 [zypper][8] 命令来安装 Trash-Cli: ``` $ sudo zypper in trash-cli - ``` -如果你的发行版中没有提供 Trash-Cli 的安装包,那么你也可以使用 pip 来安装。为了能够安装 python 包,你的系统中应该会有 pip 包管理器。 +如果你的发行版中没有提供 Trash-Cli 的安装包,那么你也可以使用 `pip` 来安装。为了能够安装 python 包,你的系统中应该会有 `pip` 包管理器。 ``` $ sudo pip install trash-cli @@ -66,7 +62,6 @@ Collecting trash-cli Installing collected packages: trash-cli Running setup.py bdist_wheel for trash-cli ... done Successfully installed trash-cli-0.17.1.14 - ``` ### 如何使用 Trash-Cli @@ -81,7 +76,7 @@ Trash-Cli 的使用不难,因为它提供了一个很简单的语法。Trash-C 下面,让我们通过一些例子来试验一下。 -1)删除文件和目录:在这个例子中,我们通过运行下面这个命令,将 2g.txt 这一文件和 magi 这一文件夹移动到回收站中。 +1) 删除文件和目录:在这个例子中,我们通过运行下面这个命令,将 `2g.txt` 这一文件和 `magi` 这一文件夹移动到回收站中。 ``` $ trash-put 2g.txt magi @@ -89,7 +84,7 @@ $ trash-put 2g.txt magi 和你在文件管理器中看到的一样。 -2)列出被删除了的文件和目录:为了查看被删除了的文件和目录,你需要运行下面这个命令。之后,你可以在输出中看到被删除文件和目录的详细信息,比如名字、删除日期和时间,以及文件路径。 +2) 列出被删除了的文件和目录:为了查看被删除了的文件和目录,你需要运行下面这个命令。之后,你可以在输出中看到被删除文件和目录的详细信息,比如名字、删除日期和时间,以及文件路径。 ``` $ trash-list @@ -97,7 +92,7 @@ $ trash-list 2017-10-01 01:40:50 /home/magi/magi/magi ``` -3)从回收站中恢复文件或目录:任何时候,你都可以通过运行下面这个命令来恢复文件和目录。它将会询问你来选择你想要恢复的文件或目录。在这个例子中,我打算恢复 2g.txt 文件,所以我的选择是 0 。 +3) 从回收站中恢复文件或目录:任何时候,你都可以通过运行下面这个命令来恢复文件和目录。它将会询问你来选择你想要恢复的文件或目录。在这个例子中,我打算恢复 `2g.txt` 文件,所以我的选择是 `0` 。 ``` $ trash-restore @@ -106,7 +101,7 @@ $ trash-restore What file to restore [0..1]: 0 ``` -4)从回收站中删除文件:如果你想删除回收站中的特定文件,那么可以运行下面这个命令。在这个例子中,我将删除 magi 目录。 +4) 从回收站中删除文件:如果你想删除回收站中的特定文件,那么可以运行下面这个命令。在这个例子中,我将删除 `magi` 目录。 ``` $ trash-rm magi @@ -118,11 +113,10 @@ $ trash-rm magi $ trash-empty ``` -6)删除超过 X 天的垃圾文件:或者,你可以通过运行下面这个命令来删除回收站中超过 X 天的文件。在这个例子中,我将删除回收站中超过 10 天的项目。 +6)删除超过 X 天的垃圾文件:或者,你可以通过运行下面这个命令来删除回收站中超过 X 天的文件。在这个例子中,我将删除回收站中超过 `10` 天的项目。 ``` $ trash-empty 10 - ``` Trash-Cli 可以工作的很好,但是如果你想尝试它的一些替代品,那么你也可以试一试 [gvfs-trash][9] 和 [autotrash][10] 。 @@ -133,7 +127,7 @@ via: https://www.2daygeek.com/trash-cli-command-line-trashcan-linux-system/ 作者:[2daygeek][a] 译者:[ucasFL](https://github.com/ucasFL) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 72e286c05658b08f3403957bc90e605ed685d170 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 19 Sep 2018 08:29:19 +0800 Subject: [PATCH 307/455] PUB:20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md @ucasFL https://linux.cn/article-10029-1.html --- ... Trash-Cli - A Command Line Interface For Trashcan On Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md (100%) diff --git a/translated/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md b/published/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md similarity index 100% rename from translated/tech/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md rename to published/20171003 Trash-Cli - A Command Line Interface For Trashcan On Linux.md From 5d19bdeef6365a8976cd2d4273600921aace3a3f Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Wed, 19 Sep 2018 08:29:31 +0800 Subject: [PATCH 308/455] Translated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在文章后面修改了 翻译ID --- .../tech/20180910 3 open source log aggregation tools.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/translated/tech/20180910 3 open source log aggregation tools.md b/translated/tech/20180910 3 open source log aggregation tools.md index 99a365e042..a026b47625 100644 --- a/translated/tech/20180910 3 open source log aggregation tools.md +++ b/translated/tech/20180910 3 open source log aggregation tools.md @@ -1,4 +1,4 @@ -heguangzhi Translating + 3个开源日志聚合工具 @@ -86,7 +86,7 @@ via: https://opensource.com/article/18/9/open-source-log-aggregation-tools 作者:[Dan Barker][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:[heguangzhi](https://github.com/heguangzhi) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -115,3 +115,4 @@ via: https://opensource.com/article/18/9/open-source-log-aggregation-tools [21]: https://aws.amazon.com/blogs/aws/all-your-data-fluentd/ [22]: https://cloud.google.com/logging/docs/agent/ [23]: https://opensource.com/resources/what-is-kubernetes + From 452a7fe4669302353e405e1ae70dce2001be53ee Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 19 Sep 2018 08:54:09 +0800 Subject: [PATCH 309/455] translated --- ...ouse Support For Linux Virtual Consoles.md | 126 ------------------ ...ouse Support For Linux Virtual Consoles.md | 124 +++++++++++++++++ 2 files changed, 124 insertions(+), 126 deletions(-) delete mode 100644 sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md create mode 100644 translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md diff --git a/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md b/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md deleted file mode 100644 index 3a4412e5c1..0000000000 --- a/sources/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md +++ /dev/null @@ -1,126 +0,0 @@ -translating---geekpi - -How To Configure Mouse Support For Linux Virtual Consoles -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/GPM-1-720x340.png) - -I use Oracle VirtualBox to test various Unix-like operating systems. Most of my VMs are headless servers that does not have graphical desktop environment. For a long time, I have been wondering how can we use the mouse in the text-based terminals in headless Linux servers. Thanks to **GPM** , today I learned that we can use Mouse in virtual consoles for copy and paste operations. **GPM** , acronym for **G** eneral **P** urpose **M** ouse, is a daemon that helps you to configure mouse support for Linux virtual consoles. Please do not confuse GPM with **GDM** (GNOME Display manager). Both serves entirely different purpose. - -GPM is especially useful in the following scenarios: - - * New Linux server installations or for systems that cannot or do not use an X windows system by default, like Arch Linux and Gentoo. - * Use copy/paste operations around in the virtual terminals/consoles. - * Use copy/paste in text-based editors and browsers (Eg. emacs, lynx). - * Use copy/paste in text file managers (Eg. Ranger, Midnight commander). - - - -In this brief tutorial, we are going to see how to use Mouse in Text-based terminals in Unix-like operating systems. - -### Installing GPM - -To enable mouse support in Text-only Linux systems, install GPM package. It is available in the default repositories of most Linux distributions. - -On Arch Linux and its variants like Antergos, Manjaro Linux, run the following command to install GPM: - -``` -$ sudo pacman -S gpm -``` - -On Debian, Ubuntu, Linux Mint: - -``` -$ sudo apt install gpm -``` - -On Fedora: - -``` -$ sudo dnf install gpm -``` - -On openSUSE: - -``` -$ sudo zypper install gpm -``` - -Once installed, enable and start GPM service using the following commands: - -``` -$ sudo systemctl enable gpm -$ sudo systemctl start gpm -``` - -In Debian-based systems, gpm service will be automatically started after you installed it, so you need not to manually start the service as shown above. - -### Configure Mouse Support For Linux Virtual Consoles - -There is no special configuration required. GPM will start working as soon as you installed it and started gpm service. - -Have a look at the following screenshot of my Ubuntu 18.04 LTS server before installing GPM: - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/Ubuntu-18.04-CLI.png) - -As you see in the above screenshot, there is no visible Mouse pointer in my Ubuntu 18.04 LTS headless server. Only a blinking cursor and it won’t let me to select a text, copy/paste text using mouse. In CLI-only Linux servers, the mouse is literally not useful at all. - -Now check the following screenshot of Ubuntu 18.04 LTS server after installing GPM: - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/GPM.png) - -See? I can now be able to select the text. - -To select, copy and paste text, do the following: - - * To select text, press the left mouse button and drag the mouse. - * Once you selected the text, release the left mouse button and paste text in the same or another console by pressing the middle mouse button. - * The right button is used to extend the selection, like in `xterm’. - * If you’re using two-button mouse, use the right button to paste text. - - - -It’s that simple! - -Like I already said, GPM works just fine and there is no extra configuration needed. Here is the sample contents of GPM configuration file **/etc/gpm.conf** (or `/etc/conf.d/gpm` in some distributions): - -``` -# protected from evaluation (i.e. by quoting them). -# -# This file is used by /etc/init.d/gpm and can be modified by -# "dpkg-reconfigure gpm" or by hand at your option. -# -device=/dev/input/mice -responsiveness= -repeat_type=none -type=exps2 -append='' -sample_rate= -``` - -In my example, I use USB mouse. If you’re using different mouse, you might have to change the values of **device=/dev/input/mice** and **type=exps2** parameters. - -For more details, refer man pages. - -``` -$ man gpm -``` - -And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-configure-mouse-support-for-linux-virtual-consoles/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/sk/ diff --git a/translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md b/translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md new file mode 100644 index 0000000000..a01ffa267c --- /dev/null +++ b/translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md @@ -0,0 +1,124 @@ +如何为 Linux 虚拟控制台配置鼠标支持 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/GPM-1-720x340.png) + +我使用 Oracle VirtualBox 来测试各种类 Unix 操作系统。我的大多数虚拟机都是无头服务器,它们没有图形桌面环境。很长一段时间,我一直想知道如何在无头 Linux 服务器的基于文本的终端中使用鼠标。感谢 **GPM**,今天我了解到我们可以在虚拟控制台中使用鼠标进行复制和粘贴操作。 **GPM**,**G** eneral **P** urpose **M** ouse 的首字母缩写,它是一个守护程序,可以帮助你配置 Linux 虚拟控制台的鼠标支持。请不要将 GPM 与 **GDM**(GNOME 显示管理器)混淆。两者有完全不同的用途。 + +GPM 在以下场景中特别有用: + + * 新的 Linux 服务器安装或默认情况下不能或不使用 X Windows 的系统,如 Arch Linux 和 Gentoo。 + * 在虚拟终端/控制台中使用复制/粘贴操作。 + * 在基于文本的编辑器和浏览器中使用复制/粘贴(例如,emacs、lynx)。 + * 在文本文件管理器中使用复制/粘贴(例如 Ranger、Midnight commander)。 + + + +在这个简短的教程中,我们将看到如何在类 Unix 操作系统中在基于文本的终端中使用鼠标。 + +### 安装 GPM + +要在纯文本 Linux 系统中启用鼠标支持,请安装 GPM 包。它在大多数 Linux 发行版的默认仓库中都有。 + +在 Arch Linux 及其变体如 Antergos、Manjaro Linux 上,运行以下命令来安装 GPM: + +``` +$ sudo pacman -S gpm +``` + +在 Debian、Ubuntu、Linux Mint 中: + +``` +$ sudo apt install gpm +``` + +在 Fedora 上: + +``` +$ sudo dnf install gpm +``` + +在 openSUSE 上: + +``` +$ sudo zypper install gpm +``` + +安装后,使用以下命令启用并启动 GPM 服务: + +``` +$ sudo systemctl enable gpm +$ sudo systemctl start gpm +``` + +在基于 Debian 的系统中,gpm 服务将在你安装后自动启动,因此你无需如上所示手动启动服务。 + +### 为 Linux 虚拟控制台配置鼠标支持 + +无需特殊配置。GPM 将在你安装并启动 gpm 服务后立即开始工作。 + +在安装 GPM 之前,看下我的 Ubuntu 18.04 LTS 服务器的屏幕截图: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Ubuntu-18.04-CLI.png) + +正如你在上面的截图中看到的,我的 Ubuntu 18.04 LTS 无头服务器中没有可见的鼠标指针。只有一个闪烁的光标,它不能让我选择文本,使用鼠标复制/粘贴文本。在仅限 CLI 的 Linux 服务器中,鼠标根本没用。 + +在安装 GPM 后查看 Ubuntu 18.04 LTS 服务器的以下截图: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/GPM.png) + +看见了吗?我现在可以选择文字了。 + +要选择,复制和粘贴文本,请执行以下操作: + + * 要选择文本,请按下鼠标左键并拖动鼠标。 + * 选择文本后,放开鼠标左键,并按下中键在同一个或另一个控制台中粘贴文本。 + * 右键用于扩展选择,就像在 `xterm` 中。 + * 如果你使用的是双键鼠标,请使用右键粘贴文本。 + + + +就这么简单! + +就像我已经说过的那样,GPM 工作得很好,并且不需要额外的配置。以下是 GPM 配置文件 **/etc/gpm.conf**(或在某些发行版中是 `/etc/conf.d/gpm`)的示例内容: + +``` +# protected from evaluation (i.e. by quoting them). +# +# This file is used by /etc/init.d/gpm and can be modified by +# "dpkg-reconfigure gpm" or by hand at your option. +# +device=/dev/input/mice +responsiveness= +repeat_type=none +type=exps2 +append='' +sample_rate= +``` + +在我的例子中,我使用 USB 鼠标。如果你使用的是其他鼠标,则可能需要更改 **device=/dev/input/mice** 和 **type=exps2** 参数的值。 + +有关更多详细信息,请参阅手册页。 + +``` +$ man gpm +``` + +就是这些了。希望这个有用。还有更多的好东西。敬请期待! + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-configure-mouse-support-for-linux-virtual-consoles/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ From 194865841d6732f9ba5aee581dd334dffb5a300e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 19 Sep 2018 09:02:26 +0800 Subject: [PATCH 310/455] PRF:translated/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md @fuzheng1998 --- ...eb File Manager With Console And Editor.md | 63 +++++++++---------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/translated/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md b/translated/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md index 2854b9d4ad..ff9792dbea 100644 --- a/translated/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md +++ b/translated/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md @@ -1,9 +1,9 @@ -Cloud Commander – 一个有控制台和编辑器在 Web 上的文件管家 +Cloud Commander:一个有控制台和编辑器的 Web 文件管理器 ====== ![](https://www.ostechnix.com/wp-content/uploads/2016/05/Cloud-Commander-A-Web-File-Manager-With-Console-And-Editor-720x340.png) -**Cloud Commander** 是一个基于 web 的文件管理程序,它允许你通过任何计算机、移动端或平板电脑的浏览器查看、访问或管理系统文件或文件夹。他有两个简单而又经典的面板,并且会像你设备的显示尺寸一样自动转换大小。它也拥有两款内置的叫做 **Dword** 和 **Edward** 的文本编辑器,它们支持语法高亮和带有一个支持系统命令行的控制台。因此,您可以随时随地编辑文件。Cloud Commander 服务器是一款在 Linux,Windows,Mac OS X 运行的跨平台应用,而且该应用客户端将在任何一款浏览器上运行。它是用 **JavaScript/Node.Js** 写的,并使用 **MIT** 许可。 +**Cloud Commander** 是一个基于 web 的文件管理程序,它允许你通过任何计算机、移动端或平板电脑的浏览器查看、访问或管理系统文件或文件夹。它有两个简单而又经典的面板,并且会像你设备的显示尺寸一样自动转换大小。它也拥有两款内置的叫做 **Dword** 和 **Edward** 的文本编辑器,它们支持语法高亮,并带有一个支持系统命令行的控制台。因此,您可以随时随地编辑文件。Cloud Commander 服务器是一款在 Linux、Windows、Mac OS X 运行的跨平台应用,而且该应用客户端可以在任何一款浏览器上运行。它是用 **JavaScript/Node.Js** 写的,并使用 **MIT** 许可证。 在这个简易教程中,让我们看一看如何在 Ubuntu 18.04 LTS 服务器上安装 Cloud Commander。 @@ -11,53 +11,52 @@ Cloud Commander – 一个有控制台和编辑器在 Web 上的文件管家 像我之前提到的,是用 Node.js 写的。所以为了安装 Cloud Commander,我们需要首先安装 Node.js。要执行安装,参考下面的指南。 +- [如何在 Linux 上安装 Node.js](https://www.ostechnix.com/install-node-js-linux/) + ### 安装 Cloud Commander 在安装 Node.js 之后,运行下列命令安装 Cloud Commander: + ``` $ npm i cloudcmd -g - ``` -祝贺!Cloud Commander 已经被安装了。让我们往下继续看看 Cloud Commander 的基本使用。 +祝贺!Cloud Commander 已经安装好了。让我们往下继续看看 Cloud Commander 的基本使用。 ### 开始使用 Cloud Commander -运行以下命令启动 Cloud Commander: +运行以下命令启动 Cloud Commander: + ``` $ cloudcmd - ``` **输出示例:** ``` url: http://localhost:8000 - ``` -现在,打开你的浏览器并转到链接:**http://localhost:8000** or ****. +现在,打开你的浏览器并转到链接:`http://localhost:8000` 或 `http://IP-address:8000`。 从现在开始,您可以直接在本地系统或远程系统或移动设备,平板电脑等Web浏览器中创建,删除,查看,管理文件或文件夹。 ![][2] -当你看见上面的截图时,Clouder Commander 有两个面板,十个热键 (F1 to F10),还有控制台。 +如你所见上面的截图,Clouder Commander 有两个面板,十个热键 (`F1` 到 `F10`),还有控制台。 每个热键执行的都是一个任务。 - * F1 – 帮助 - * F2 – 重命名文件/文件夹 - * F3 – 查看文件/文件夹 - * F4 – 编辑文件 - * F5 – 复制文件/文件夹 - * F6 – 移动文件/文件夹 - * F7 – 创建新目录 - * F8 – 删除文件/文件夹 - * F9 – 打开菜单 - * F10 – 打开设置 - - + * `F1` – 帮助 + * `F2` – 重命名文件/文件夹 + * `F3` – 查看文件/文件夹 + * `F4` – 编辑文件 + * `F5` – 复制文件/文件夹 + * `F6` – 移动文件/文件夹 + * `F7` – 创建新目录 + * `F8` – 删除文件/文件夹 + * `F9` – 打开菜单 + * `F10` – 打开设置 #### Cloud Commmander 控制台 @@ -65,11 +64,11 @@ url: http://localhost:8000 ![][3] -在此控制台中,您可以执行各种管理任务,例如安装软件包,删除软件包,更新系统等。您甚至可以关闭或重新引导系统。 因此,Cloud Commander 不仅仅是一个文件管理器,还具有远程管理工具的功能。 +在此控制台中,您可以执行各种管理任务,例如安装软件包、删除软件包、更新系统等。您甚至可以关闭或重新引导系统。 因此,Cloud Commander 不仅仅是一个文件管理器,还具有远程管理工具的功能。 #### 创建文件/文件夹 -要创建新的文件或文件夹就右键单击任意空位置并找到 **New - >File or Directory**。 +要创建新的文件或文件夹就右键单击任意空位置并找到 “New - >File or Directory”。 ![][4] @@ -83,39 +82,39 @@ url: http://localhost:8000 另一个很酷的特性是我们可以从任何系统或设备简单地上传一个文件到 Cloud Commander 系统。 -要上传文件,右键单击 Cloud Commander 面板的任意空白处,并且单击**上传**选项。 +要上传文件,右键单击 Cloud Commander 面板的任意空白处,并且单击“Upload”选项。 ![][6] 选择你想要上传的文件。 -另外,你也可以上传来自像 Google 云盘, Dropbox, Amazon 云盘, Facebook, Twitter, Gmail, GtiHub, Picasa, Instagram 还有很多的云服务上的文件。 +另外,你也可以上传来自像 Google 云盘、Dropbox、Amazon 云盘、Facebook、Twitter、Gmail、GitHub、Picasa、Instagram 还有很多的云服务上的文件。 -要从云端上传文件, 右键单击面板的任意空白处,并且右键单击面板任意空白处并选择**从云端上传**。 +要从云端上传文件, 右键单击面板的任意空白处,并且右键单击面板任意空白处并选择“Upload from Cloud”。 ![][7] -选择任意一个你选择的网络服务,例如谷歌云盘。点击**连接到谷歌云盘**按钮。 +选择任意一个你选择的网络服务,例如谷歌云盘。点击“Connect to Google drive”按钮。 ![][8] -下一步,用 Cloud Commander 验证你的谷歌云端硬盘,从谷歌云端硬盘选择文件并点击**上传**。 +下一步,用 Cloud Commander 验证你的谷歌云端硬盘,从谷歌云端硬盘选择文件并点击“Upload”。 ![][9] #### 更新 Cloud Commander 要更新到最新的可用版本,执行下面的命令: + ``` $ npm update cloudcmd -g - ``` #### 总结 -据我测试,它运行地像魔幻一般。在我的Ubuntu服务器测试期间,我没有遇到任何问题。此外,Cloud Commander不仅是基于 Web 的文件管理器,还充当执行大多数Linux管理任务的远程管理工具。 您可以创建文件/文件夹,重命名,删除,编辑和查看它们。此外,您可以像在终端中在本地系统中那样安装,更新,升级和删除任何软件包。当然,您甚至可以从 Cloud Commander 控制台本身关闭或重启系统。 还有什么需要的吗? 尝试一下,你会发现它很有用。 +据我测试,它运行很好。在我的 Ubuntu 服务器测试期间,我没有遇到任何问题。此外,Cloud Commander 不仅是基于 Web 的文件管理器,还可以充当执行大多数 Linux 管理任务的远程管理工具。 您可以创建文件/文件夹、重命名、删除、编辑和查看它们。此外,您可以像在终端中在本地系统中那样安装、更新、升级和删除任何软件包。当然,您甚至可以从 Cloud Commander 控制台本身关闭或重启系统。 还有什么需要的吗? 尝试一下,你会发现它很有用。 -目前为止就这样吧。 我将很快在这里发表另一篇有趣的文章。 在此之前,请继续关注 OSTechNix。 +目前为止就这样吧。 我将很快在这里发表另一篇有趣的文章。 在此之前,请继续关注我们。 祝贺! @@ -128,7 +127,7 @@ via: https://www.ostechnix.com/cloud-commander-a-web-file-manager-with-console-a 作者:[SK][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[fuzheng1998](https://github.com/fuzheng1998) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 1ac085dcbc42ac311cf36d448d7be2d853735b6c Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 19 Sep 2018 09:02:30 +0800 Subject: [PATCH 311/455] translating --- ...8 How to Play Windows-only Games on Linux with Steam Play.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md b/sources/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md index e0eea91e8b..d4ff9692d6 100644 --- a/sources/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md +++ b/sources/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md @@ -1,3 +1,5 @@ +translating---geekpi + How to Play Windows-only Games on Linux with Steam Play ====== The new experimental feature of Steam allows you to play Windows-only games on Linux. Here’s how to use this feature in Steam right now. From 91f43ff50ccee0c3b0cb7a935f9dcc082be08333 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 19 Sep 2018 09:02:54 +0800 Subject: [PATCH 312/455] PUB:20160503 Cloud Commander - A Web File Manager With Console And Editor.md @fuzheng1998 https://linux.cn/article-10030-1.html --- ...loud Commander - A Web File Manager With Console And Editor.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20160503 Cloud Commander - A Web File Manager With Console And Editor.md (100%) diff --git a/translated/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md b/published/20160503 Cloud Commander - A Web File Manager With Console And Editor.md similarity index 100% rename from translated/tech/20160503 Cloud Commander - A Web File Manager With Console And Editor.md rename to published/20160503 Cloud Commander - A Web File Manager With Console And Editor.md From a3d2ba325fc73d47837d1cd94544cdc29a68cac3 Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Wed, 19 Sep 2018 09:42:11 +0800 Subject: [PATCH 313/455] heguangzhi Translating --- ...0180916 Linus, His Apology, And Why We Should Support Him.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md b/sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md index c3c159aa30..5794aaa635 100644 --- a/sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md +++ b/sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md @@ -1,3 +1,5 @@ +heguangzhi translating + Linus, His Apology, And Why We Should Support Him ====== From 8aa4e068c342ddae4e41ca4a1581106bea421752 Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Wed, 19 Sep 2018 09:44:58 +0800 Subject: [PATCH 314/455] heguangzhi translating Linus, His Apology, And Why We Should Support Him --- ...20180916 Linus, His Apology, And Why We Should Support Him.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md b/sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md index 5794aaa635..e2bf768324 100644 --- a/sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md +++ b/sources/talk/20180916 Linus, His Apology, And Why We Should Support Him.md @@ -1,5 +1,6 @@ heguangzhi translating + Linus, His Apology, And Why We Should Support Him ====== From 41f4e466e874319b665c0759f8aa0996352ee897 Mon Sep 17 00:00:00 2001 From: David Chen Date: Wed, 19 Sep 2018 10:39:40 +0800 Subject: [PATCH 315/455] 20171124 How do groups work on Linux.md --- .../20171124 How do groups work on Linux.md | 143 ---------------- .../20171124 How do groups work on Linux.md | 152 ++++++++++++++++++ 2 files changed, 152 insertions(+), 143 deletions(-) delete mode 100644 sources/tech/20171124 How do groups work on Linux.md create mode 100644 translated/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 deleted file mode 100644 index 5071c7a8a3..0000000000 --- a/sources/tech/20171124 How do groups work on Linux.md +++ /dev/null @@ -1,143 +0,0 @@ -Translating by DavidChen - -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/ diff --git a/translated/tech/20171124 How do groups work on Linux.md b/translated/tech/20171124 How do groups work on Linux.md new file mode 100644 index 0000000000..ace322775a --- /dev/null +++ b/translated/tech/20171124 How do groups work on Linux.md @@ -0,0 +1,152 @@ +"组"在 Linux 上到底是怎么工作的? +============================================================ + + +你好!就在上周,我还自认为对 Linux 上的用户和组的工作机制了如指掌。我认为它们的关系是这样的: + +1. 每个进程都属于一个用户( 比如用户`julia`) + +2. 当这个进程试图读取一个被某个组所拥有的文件时, Linux 会 a)先检查用户`julia` 是否有权限访问文件。(LCTT译注:检查文件的所有者是否就是`julia`) b)检查`julia` 属于哪些组,并进一步检查在这些组里是否有某个组拥有这个文件或者有权限访问这个文件。 + +3. 如果上述a,b任一为真( 或者`其他`位设为有权限访问),那么这个进程就有权限访问这个文件。 + +比如说,如果一个进程被用户`julia`拥有并且`julia` 在`awesome`组,那么这个进程就能访问下面这个文件。 + +``` +r--r--r-- 1 root awesome 6872 Sep 24 11:09 file.txt + +``` + +然而上述的机制我并没有考虑得非常清楚,如果你硬要我阐述清楚,我会说进程可能会在**运行时**去检查`/etc/group` 文件里是否有某些组拥有当前的用户。 + +### 然而这并不是Linux 里“组”的工作机制 + +我在上个星期的工作中发现了一件有趣的事,事实证明我前面的理解错了,我对组的工作机制的描述并不准确。特别是Linux**并不会**在进程每次试图访问一个文件时就去检查这个进程的用户属于哪些组。 + +我在读了[The Linux Programming +Interface][1]这本书的第九章后才恍然大悟(这本书真是太棒了。)这才是组真正的工作方式!我意识到之前我并没有真正理解用户和组是怎么工作的,我信心满满的尝试了下面的内容并且验证到底发生了什么,事实证明现在我的理解才是对的。 + +### 用户和组权限检查是怎么完成的 + +现在这些关键的知识在我看来非常简单! 这本书的第九章上来就告诉我如下事实:用户和组ID是**进程的属性**,它们是: + +* 真实用户ID和组ID; + +* 有效用户ID和组ID; + +* 被保存的set-user-ID和被保存的set-group-ID; + +* 文件系统用户ID和组ID(特定于 Linux); + +* 增补的组ID; + +这说明Linux**实际上**检查一个进程能否访问一个文件所做的组检查是这样的: + +* 检查一个进程的组ID和补充组ID(这些ID就在进程的属性里,**并不是**实时在`/etc/group`里查找这些ID) + +* 检查要访问的文件的访问属性里的组设置 + + +* 确定进程对文件是否有权限访问(LCTT 译注:即文件的组是否是以上的组之一) + +通常当访问控制的时候使用的是**有效**用户/组ID,而不是**真实**用户/组ID。技术上来说当访问一个文件时使用的是**文件系统**ID,他们实际上和有效用户/组ID一样。(LCTT译注:这句话针对 Linux 而言。) + +### 将一个用户加入一个组并不会将一个已存在的进程(的用户)加入那个组 + +下面是一个有趣的例子:如果我创建了一个新的组:`panda` 组并且将我自己(bork)加入到这个组,然后运行`groups` 来检查我是否在这个组里:结果是我(bork)竟然不在这个组?! + + +``` +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 + +``` + +`panda`并不在上面的组里!为了再次确定我们的发现,让我们建一个文件,这个文件被`panda`组拥有,看看我能否访问它。 + + +``` +$ 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 + +``` + +好吧,确定了,我(bork)无法访问`panda-file.txt`。这一点都不让人吃惊,我的命令解释器并没有`panda` 组作为补充组ID,运行`adduser bork panda`并不会改变这一点。 + + +### 那进程一开始是怎么得到用户的组的呢? + + +这真是个非常令人困惑的问题,对吗?如果进程会将组的信息预置到进程的属性里面,进程在初始化的时候怎么取到组的呢?很明显你无法给你自己指定更多的组(否则就会和Linux访问控制的初衷相违背了。。。) + +有一点还是很清楚的:一个新的进程是怎么从我的命令行解释器(/bash/fish)里被**执行**而得到它的组的。(新的)进程将拥有我的用户 ID(bork),并且进程属性里还有很多组ID。从我的命令解释器里执行的所有进程是从这个命令解释器里`复刻`而来的,所以这个新进程得到了和命令解释器同样的组。 + +因此一定存在一个“第一个”进程来把你的组设置到进程属性里,而所有由此进程而衍生的进程将都设置这些组。而那个“第一个”进程就是你的**登录命令**,在我的笔记本电脑上,它是由‘登录’程序(`/bin/login`)实例化而来。` 登录程序` 以root身份运行,然后调用了一个 C 的库函数-`initgroups`来设置你的进程的组(具体来说是通过读取`/etc/group` 文件),因为登录程序是以root运行的,所以它能设置你的进程的组。 + + +### 让我们再登录一次 + +好了!既然我们的`login shell`正在运行,而我又想刷新我的进程的组设置,从我们前面所学到的进程是怎么初始化组ID的,我应该可以通过再次运行`login` 程序来刷新我的进程组并启动一个新的`login shell`! + +让我们试试下边的方法: + +``` +$ 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! + +``` + +当然,成功了!现在由登录程序衍生的程序的用户是组`panda`的一部分了!太棒了!这并不会影响我其他的已经在运行的登录程序(及其子进程),如果我真的希望“所有的”进程都能对`panda` +组有访问权限。我必须完全的重启我的登陆会话,这意味着我必须退出我的窗口管理器然后再重新`login`。(LCTT译注:即更新进程树的树根进程,这里是窗口管理器进程。) + +### newgrp命令 + + +在 Twitter 上有人告诉我如果只是想启动一个刷新了组信息的命令解释器的话,你可以使用`newgrp`(LCTT译注:不启动新的命令解释器),如下: + +``` +sudo addgroup panda +sudo adduser bork panda +newgrp panda # starts a new shell, and you don't have to be root to run it! + +``` + + +你也可以用`sg panda bash` 来完成同样的效果,这个命令能启动一个`bash` 登录程序,而这个程序就有`panda` 组。 + +### seduid 将设置有效用户 ID + +其实我一直对一个进程如何以`setuid root`的权限来运行意味着什么有点似是而非。现在我知道了,事实上所发生的是:setuid 设置了`有效用户ID`! 如果我('julia')运行了一个`setuid root` 的进程( 比如`passwd`),那么进程的**真实**用户 ID 将为`julia`,而**有效**用户 ID 将被设置为`root`。 + +`passwd` 需要以root权限来运行,但是它能看到进程的真实用户ID是`julia` ,是`julia`启动了这个进程,`passwd`会阻止这个进程修改除了`julia`之外的用户密码。 + +### 就是这些了! + +在 Linux Programming Interface 这本书里有很多Linux上一些功能的罕见使用方法以及Linux上所有的事物到底是怎么运行的详细解释,这里我就不一一展开了。那本书棒极了,我上面所说的都在该书的第九章,这章在1300页的书里只占了17页。 + +我最爱这本书的一点是我只用读17页关于用户和组是怎么工作的内容,而这区区17页就能做到内容完备,详实有用。我不用读完所有的1300页书就能得到有用的东西,太棒了! + +-------------------------------------------------------------------------------- + +via: https://jvns.ca/blog/2017/11/20/groups/ + +作者:[Julia Evans ][a] +译者:[DavidChen](https://github.com/DavidChenLiang) +校对:[校对者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 6e8c6ad7387ce68be19644107bd4a54c92b3be7d Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 19 Sep 2018 19:18:42 +0800 Subject: [PATCH 316/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=204=20scanning=20to?= =?UTF-8?q?ols=20for=20the=20Linux=20desktop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... 4 scanning tools for the Linux desktop.md | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 sources/tech/20180917 4 scanning tools for the Linux desktop.md diff --git a/sources/tech/20180917 4 scanning tools for the Linux desktop.md b/sources/tech/20180917 4 scanning tools for the Linux desktop.md new file mode 100644 index 0000000000..a239c87768 --- /dev/null +++ b/sources/tech/20180917 4 scanning tools for the Linux desktop.md @@ -0,0 +1,72 @@ +4 scanning tools for the Linux desktop +====== +Go paperless by driving your scanner with one of these open source applications. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/osdc-photo-camera-blue.png?itok=AsIMZ9ga) + +While the paperless world isn't here quite yet, more and more people are getting rid of paper by scanning documents and photos. Having a scanner isn't enough to do the deed, though. You need software to drive that scanner. + +But the catch is many scanner makers don't have Linux versions of the software they bundle with their devices. For the most part, that doesn't matter. Why? Because there are good scanning applications available for the Linux desktop. They work with a variety of scanners and do a good job. + +Let's take a look at four simple but flexible open source Linux scanning tools. I've used each of these tools (and even wrote about three of them [back in 2014][1]) and found them very useful. You might, too. + +### Simple Scan + +One of my longtime favorites, [Simple Scan][2] is small, quick, efficient, and easy to use. If you've seen it before, that's because Simple Scan is the default scanner application on the GNOME desktop, as well as for a number of Linux distributions. + +Scanning a document or photo takes one click. After scanning something, you can rotate or crop it and save it as an image (JPEG or PNG only) or as a PDF. That said, Simple Scan can be slow, even if you scan documents at lower resolutions. On top of that, Simple Scan uses a set of global defaults for scanning, like 150dpi for text and 300dpi for photos. You need to go into Simple Scan's preferences to change those settings. + +If you've scanned something with more than a couple of pages, you can reorder the pages before you save. And if necessary—say you're submitting a signed form—you can email from within Simple Scan. + +### Skanlite + +In many ways, [Skanlite][3] is Simple Scan's cousin in the KDE world. Skanlite has few features, but it gets the job done nicely. + +The software has options that you can configure, including automatically saving scanned files, setting the quality of the scan, and identifying where to save your scans. Skanlite can save to these image formats: JPEG, PNG, BMP, PPM, XBM, and XPM. + +One nifty feature is the software's ability to save portions of what you've scanned to separate files. That comes in handy when, say, you want to excise someone or something from a photo. + +### Gscan2pdf + +Another old favorite, [gscan2pdf][4] might be showing its age, but it still packs a few more features than some of the other applications mentioned here. Even so, gscan2pdf is still comparatively light. + +In addition to saving scans in various image formats (JPEG, PNG, and TIFF), gscan2pdf also saves them as PDF or [DjVu][5] files. You can set the scan's resolution, whether it's black and white or color, and paper size before you click the Scan button. That beats going into gscan2pdf's preferences every time you want to change any of those settings. You can also rotate, crop, and delete pages. + +While none of those features are truly killer, they give you a bit more flexibility. + +### GIMP + +You probably know [GIMP][6] as an image-editing tool. But did you know you can use it to drive your scanner? + +You'll need to install the [XSane][7] scanner software and the GIMP XSane plugin. Both of those should be available from your Linux distro's package manager. From there, select File > Create > Scanner/Camera. From there, click on your scanner and then the Scan button. + +If that's not your cup of tea, or if it doesn't work, you can combine GIMP with a plugin called [QuiteInsane][8]. With either plugin, GIMP becomes a powerful scanning application that lets you set a number of options like whether to scan in color or black and white, the resolution of the scan, and whether or not to compress results. You can also use GIMP's tools to touch up or apply effects to your scans. This makes it great for scanning photos and art. + +### Do they really just work? + +All of this software works well for the most part and with a variety of hardware. I've used them with several multifunction printers that I've owned over the years—whether connecting using a USB cable or over wireless. + +You might have noticed that I wrote "works well for the most part" in the previous paragraph. I did run into one exception: an inexpensive Canon multifunction printer. None of the software I used could detect it. I had to download and install Canon's Linux scanner software, which did work. + +What's your favorite open source scanning tool for Linux? Share your pick by leaving a comment. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/linux-scanner-tools + +作者:[Scott Nesbitt][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[1]: https://opensource.com/life/14/8/3-tools-scanners-linux-desktop +[2]: https://gitlab.gnome.org/GNOME/simple-scan +[3]: https://www.kde.org/applications/graphics/skanlite/ +[4]: http://gscan2pdf.sourceforge.net/ +[5]: http://en.wikipedia.org/wiki/DjVu +[6]: http://www.gimp.org/ +[7]: https://en.wikipedia.org/wiki/Scanner_Access_Now_Easy#XSane +[8]: http://sourceforge.net/projects/quiteinsane/ From cbefc1020a5e1e7ef1fff71950b9dd0266b566ba Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 19 Sep 2018 19:23:12 +0800 Subject: [PATCH 317/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Linux=20firewalls?= =?UTF-8?q?:=20What=20you=20need=20to=20know=20about=20iptables=20and=20fi?= =?UTF-8?q?rewalld?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ed to know about iptables and firewalld.md | 168 ++++++++++++++++++ 1 file changed, 168 insertions(+) create mode 100644 sources/tech/20180918 Linux firewalls- What you need to know about iptables and firewalld.md diff --git a/sources/tech/20180918 Linux firewalls- What you need to know about iptables and firewalld.md b/sources/tech/20180918 Linux firewalls- What you need to know about iptables and firewalld.md new file mode 100644 index 0000000000..1297916194 --- /dev/null +++ b/sources/tech/20180918 Linux firewalls- What you need to know about iptables and firewalld.md @@ -0,0 +1,168 @@ +Linux firewalls: What you need to know about iptables and firewalld +====== +Here's how to use the iptables and firewalld tools to manage Linux firewall connectivity rules. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openwires_fromRHT_520_0612LL.png?itok=PqZi55Ab) +This article is excerpted from my book, [Linux in Action][1], and a second Manning project that’s yet to be released. + +### The firewall + +A firewall is a set of rules. When a data packet moves into or out of a protected network space, its contents (in particular, information about its origin, target, and the protocol it plans to use) are tested against the firewall rules to see if it should be allowed through. Here’s a simple example: + +![firewall filtering request][3] + +A firewall can filter requests based on protocol or target-based rules. + +On the one hand, [iptables][4] is a tool for managing firewall rules on a Linux machine. + +On the other hand, [firewalld][5] is also a tool for managing firewall rules on a Linux machine. + +You got a problem with that? And would it spoil your day if I told you that there was another tool out there, called [nftables][6]? + +OK, I’ll admit that the whole thing does smell a bit funny, so let me explain. It all starts with Netfilter, which controls access to and from the network stack at the Linux kernel module level. For decades, the primary command-line tool for managing Netfilter hooks was the iptables ruleset. + +Because the syntax needed to invoke those rules could come across as a bit arcane, various user-friendly implementations like [ufw][7] and firewalld were introduced as higher-level Netfilter interpreters. Ufw and firewalld are, however, primarily designed to solve the kinds of problems faced by stand-alone computers. Building full-sized network solutions will often require the extra muscle of iptables or, since 2014, its replacement, nftables (through the nft command line tool). + +iptables hasn’t gone anywhere and is still widely used. In fact, you should expect to run into iptables-protected networks in your work as an admin for many years to come. But nftables, by adding on to the classic Netfilter toolset, has brought some important new functionality. + +From here on, I’ll show by example how firewalld and iptables solve simple connectivity problems. + +### Configure HTTP access using firewalld + +As you might have guessed from its name, firewalld is part of the [systemd][8] family. Firewalld can be installed on Debian/Ubuntu machines, but it’s there by default on Red Hat and CentOS. If you’ve got a web server like Apache running on your machine, you can confirm that the firewall is working by browsing to your server’s web root. If the site is unreachable, then firewalld is doing its job. + +You’ll use the `firewall-cmd` tool to manage firewalld settings from the command line. Adding the `–state` argument returns the current firewall status: + +``` +# firewall-cmd --state +running +``` + +By default, firewalld will be active and will reject all incoming traffic with a couple of exceptions, like SSH. That means your website won’t be getting too many visitors, which will certainly save you a lot of data transfer costs. As that’s probably not what you had in mind for your web server, though, you’ll want to open the HTTP and HTTPS ports that by convention are designated as 80 and 443, respectively. firewalld offers two ways to do that. One is through the `–add-port` argument that references the port number directly along with the network protocol it’ll use (TCP in this case). The `–permanent` argument tells firewalld to load this rule each time the server boots: + +``` +# firewall-cmd --permanent --add-port=80/tcp +# firewall-cmd --permanent --add-port=443/tcp +``` + +The `–reload` argument will apply those rules to the current session: + +``` +# firewall-cmd --reload +``` + +Curious as to the current settings on your firewall? Run `–list-services`: + +``` +# firewall-cmd --list-services +dhcpv6-client http https ssh +``` + +Assuming you’ve added browser access as described earlier, the HTTP, HTTPS, and SSH ports should now all be open—along with `dhcpv6-client`, which allows Linux to request an IPv6 IP address from a local DHCP server. + +### Configure a locked-down customer kiosk using iptables + +I’m sure you’ve seen kiosks—they’re the tablets, touchscreens, and ATM-like PCs in a box that airports, libraries, and business leave lying around, inviting customers and passersby to browse content. The thing about most kiosks is that you don’t usually want users to make themselves at home and treat them like their own devices. They’re not generally meant for browsing, viewing YouTube videos, or launching denial-of-service attacks against the Pentagon. So to make sure they’re not misused, you need to lock them down. + +One way is to apply some kind of kiosk mode, whether it’s through clever use of a Linux display manager or at the browser level. But to make sure you’ve got all the holes plugged, you’ll probably also want to add some hard network controls through a firewall. In the following section, I'll describe how I would do it using iptables. + +There are two important things to remember about using iptables: The order you give your rules is critical, and by themselves, iptables rules won’t survive a reboot. I’ll address those here one at a time. + +### The kiosk project + +To illustrate all this, let’s imagine we work for a store that’s part of a larger chain called BigMart. They’ve been around for decades; in fact, our imaginary grandparents probably grew up shopping there. But these days, the guys at BigMart corporate headquarters are probably just counting the hours before Amazon drives them under for good. + +Nevertheless, BigMart’s IT department is doing its best, and they’ve just sent you some WiFi-ready kiosk devices that you’re expected to install at strategic locations throughout your store. The idea is that they’ll display a web browser logged into the BigMart.com products pages, allowing them to look up merchandise features, aisle location, and stock levels. The kiosks will also need access to bigmart-data.com, where many of the images and video media are stored. + +Besides those, you’ll want to permit updates and, whenever necessary, package downloads. Finally, you’ll want to permit inbound SSH access only from your local workstation, and block everyone else. The figure below illustrates how it will all work: + +![kiosk traffic flow ip tables][10] + +The kiosk traffic flow being controlled by iptables. + +### The script + +Here’s how that will all fit into a Bash script: + +``` +#!/bin/bash +iptables -A OUTPUT -p tcp -d bigmart.com -j ACCEPT +iptables -A OUTPUT -p tcp -d bigmart-data.com -j ACCEPT +iptables -A OUTPUT -p tcp -d ubuntu.com -j ACCEPT +iptables -A OUTPUT -p tcp -d ca.archive.ubuntu.com -j ACCEPT +iptables -A OUTPUT -p tcp --dport 80 -j DROP +iptables -A OUTPUT -p tcp --dport 443 -j DROP +iptables -A INPUT -p tcp -s 10.0.3.1 --dport 22 -j ACCEPT +iptables -A INPUT -p tcp -s 0.0.0.0/0 --dport 22 -j DROP +``` + +The basic anatomy of our rules starts with `-A`, telling iptables that we want to add the following rule. `OUTPUT` means that this rule should become part of the OUTPUT chain. `-p` indicates that this rule will apply only to packets using the TCP protocol, where, as `-d` tells us, the destination is [bigmart.com][11]. The `-j` flag points to `ACCEPT` as the action to take when a packet matches the rule. In this first rule, that action is to permit, or accept, the request. But further down, you can see requests that will be dropped, or denied. + +Remember that order matters. And that’s because iptables will run a request past each of its rules, but only until it gets a match. So an outgoing browser request for, say, [youtube.com][12] will pass the first four rules, but when it gets to either the `–dport 80` or `–dport 443` rule—depending on whether it’s an HTTP or HTTPS request—it’ll be dropped. iptables won’t bother checking any further because that was a match. + +On the other hand, a system request to ubuntu.com for a software upgrade will get through when it hits its appropriate rule. What we’re doing here, obviously, is permitting outgoing HTTP or HTTPS requests to only our BigMart or Ubuntu destinations and no others. + +The final two rules will deal with incoming SSH requests. They won’t already have been denied by the two previous drop rules since they don’t use ports 80 or 443, but 22. In this case, login requests from my workstation will be accepted but requests for anywhere else will be dropped. This is important: Make sure the IP address you use for your port 22 rule matches the address of the machine you’re using to log in—if you don’t do that, you’ll be instantly locked out. It's no big deal, of course, because the way it’s currently configured, you could simply reboot the server and the iptables rules will all be dropped. If you’re using an LXC container as your server and logging on from your LXC host, then use the IP address your host uses to connect to the container, not its public address. + +You’ll need to remember to update this rule if my machine’s IP ever changes; otherwise, you’ll be locked out. + +Playing along at home (hopefully on a throwaway VM of some sort)? Great. Create your own script. Now I can save the script, use `chmod` to make it executable, and run it as `sudo`. Don’t worry about that `bigmart-data.com not found` error—of course it’s not found; it doesn’t exist. + +``` +chmod +X scriptname.sh +sudo ./scriptname.sh +``` + +You can test your firewall from the command line using `cURL`. Requesting ubuntu.com works, but [manning.com][13] fails. + +``` +curl ubuntu.com +curl manning.com +``` + +### Configuring iptables to load on system boot + +Now, how do I get these rules to automatically load each time the kiosk boots? The first step is to save the current rules to a .rules file using the `iptables-save` tool. That’ll create a file in the root directory containing a list of the rules. The pipe, followed by the tee command, is necessary to apply my `sudo` authority to the second part of the string: the actual saving of a file to the otherwise restricted root directory. + +I can then tell the system to run a related tool called `iptables-restore` every time it boots. A regular cron job of the kind we saw in the previous module won’t help because they’re run at set times, but we have no idea when our computer might decide to crash and reboot. + +There are lots of ways to handle this problem. Here’s one: + +On my Linux machine, I’ll install a program called [anacron][14] that will give us a file in the /etc/ directory called anacrontab. I’ll edit the file and add this `iptables-restore` command, telling it to load the current values of that .rules file into iptables each day (when necessary) one minute after a boot. I’ll give the job an identifier (`iptables-restore`) and then add the command itself. Since you’re playing along with me at home, you should test all this out by rebooting your system. + +``` +sudo iptables-save | sudo tee /root/my.active.firewall.rules +sudo apt install anacron +sudo nano /etc/anacrontab +1 1 iptables-restore iptables-restore < /root/my.active.firewall.rules + +``` + +I hope these practical examples have illustrated how to use iptables and firewalld for managing connectivity issues on Linux-based firewalls. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/linux-iptables-firewalld + +作者:[David Clinton][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/remyd +[1]: https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&a_bid=4ca15fc9&chan=opensource +[2]: /file/409116 +[3]: https://opensource.com/sites/default/files/uploads/iptables1.jpg (firewall filtering request) +[4]: https://en.wikipedia.org/wiki/Iptables +[5]: https://firewalld.org/ +[6]: https://wiki.nftables.org/wiki-nftables/index.php/Main_Page +[7]: https://en.wikipedia.org/wiki/Uncomplicated_Firewall +[8]: https://en.wikipedia.org/wiki/Systemd +[9]: /file/409121 +[10]: https://opensource.com/sites/default/files/uploads/iptables2.jpg (kiosk traffic flow ip tables) +[11]: http://bigmart.com/ +[12]: http://youtube.com/ +[13]: http://manning.com/ +[14]: https://sourceforge.net/projects/anacron/ From 5665b57292c11fbe777e5958ff861e62e093a4ea Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 19 Sep 2018 19:28:29 +0800 Subject: [PATCH 318/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Cozy=20Is=20A=20N?= =?UTF-8?q?ice=20Linux=20Audiobook=20Player=20For=20DRM-Free=20Audio=20Fil?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...diobook Player For DRM-Free Audio Files.md | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 sources/tech/20180918 Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files.md diff --git a/sources/tech/20180918 Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files.md b/sources/tech/20180918 Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files.md new file mode 100644 index 0000000000..93d6399267 --- /dev/null +++ b/sources/tech/20180918 Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files.md @@ -0,0 +1,73 @@ +Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files +====== +[Cozy][1] **is a free and open source audiobook player for the Linux desktop. The application lets you listen to DRM-free audiobooks (mp3, m4a, flac, ogg and wav) using a modern Gtk3 interface.** + +![](https://4.bp.blogspot.com/-A1TWkOasR7s/W6DevbmTH9I/AAAAAAAABho/VSjQkiDeWK49xzJ2MXvvwk0T_AhGWqQRgCLcBGAs/s1600/cozy-audiobook-player.png) + +You could use any audio player to listen to audiobooks, but a specialized audiobook player like Cozy makes everything easier, by **remembering your playback position and continuing from where you left off for each audiobook** , or by letting you **set the playback speed of each book individually** , among others. + +The Cozy interface lets you browse books by author, reader or recency, while also providing search functionality. **Books front covers are supported by Cozy** \- either by using embedded images, or by adding a cover.jpg or cover.png image in the book folder, which is automatically picked up and displayed by Cozy. + +When you click on an audiobook, Cozy lists the book chapters on the right, while displaying the book cover (if available) on the left, along with the book name, author and the last played time, along with total and remaining time: + +![](https://4.bp.blogspot.com/-hqBITKAiYaM/W6De4HzckRI/AAAAAAAABhs/GxSjfpND4hkk6ZM29TKfwB1zzXPxNa0_gCLcBGAs/s640/cozy-audiobook-player-playback-chapters.png) + +From the application toolbar you can easily **go back 30 seconds** by clicking the rewind icon from its top left-hand side corner. Besides regular controls, cover and title, you'll also find a playback speed button on the toolbar, which lets you increase the playback speed up to 2X. + +**A sleep timer is also available**. It can be set to stop after the current chapter or after a given number of minutes. + +Other Cozy features worth mentioning: + + * **Mpris integration** (Media keys & playback info) + * **Supports multiple storage locations** + * **Drag'n'drop support for importing new audiobooks** + * **Offline Mode**. If your audiobooks are on an external or network drive, you can switch the download button to keep a local cached copy of the book to listen to on the go. To enable this feature you have to set your storage location to external in the settings + * **Prevents your system from suspend during playback** + * **Dark mode** + + + +What I'd like to see in Cozy is a way to get audiobooks metadata, including the book cover, automatically. A feature to retrieve metadata from Audible.com was proposed on the Cozy GitHub project page and the developer seems interested in this, but it's not clear when or if this will be implemented. + +Like I was mentioning in the beginning of the article, Cozy only supports DRM-free audio files. Currently it supports mp3, m4a, flac, ogg and wav. Support for more formats will probably come in the future, with m4b being listed on the Cozy 0.7.0 todo list. + +Cozy cannot play Audible audiobooks due to DRM. But you'll find some solutions out there for converting Audible (.aa/.aax) audiobooks to mp3, like + +### Install Cozy + +**Any Linux distribution / Flatpak** : Cozy is available as a Flatpak on FlatHub. To install it, follow the quick Flatpak [setup][4], then go to the Cozy FlaHub [page][5] and click the install button, or use the install command at the bottom if its page. + +**elementary OS** : Cozy is available in the [AppCenter][6]. + +**Ubuntu 18.04 / Linux Mint 19** : you can install Cozy from its repository: + +``` +wget -nv https://download.opensuse.org/repositories/home:geigi/Ubuntu_18.04/Release.key -O Release.key +sudo apt-key add - < Release.key +sudo sh -c "echo 'deb http://download.opensuse.org/repositories/home:/geigi/Ubuntu_18.04/ /' > /etc/apt/sources.list.d/home:geigi.list" +sudo apt update +sudo apt install com.github.geigi.cozy +``` + +**For other ways of installing Cozy check out its[website][2].** + +You could use any audio player to listen to audiobooks, but a specialized audiobook player like Cozy makes everything easier, by, or by letting you, among others.The Cozy interface lets you browse books by author, reader or recency, while also providing search functionality.- either by using embedded images, or by adding a cover.jpg or cover.png image in the book folder, which is automatically picked up and displayed by Cozy.When you click on an audiobook, Cozy lists the book chapters on the right, while displaying the book cover (if available) on the left, along with the book name, author and the last played time, along with total and remaining time:From the application toolbar you can easilyby clicking the rewind icon from its top left-hand side corner. Besides regular controls, cover and title, you'll also find a playback speed button on the toolbar, which lets you increase the playback speed up to 2X.. It can be set to stop after the current chapter or after a given number of minutes.Other Cozy features worth mentioning:What I'd like to see in Cozy is a way to get audiobooks metadata, including the book cover, automatically. A feature to retrieve metadata from Audible.com was proposed on the Cozy GitHub project page and the developer seems interested in this, but it's not clear when or if this will be implemented.Like I was mentioning in the beginning of the article, Cozy only supports DRM-free audio files. Currently it supports mp3, m4a, flac, ogg and wav. Support for more formats will probably come in the future, with m4b being listed on the Cozy 0.7.0 todo list.Cozy cannot play Audible audiobooks due to DRM. But you'll find some solutions out there for converting Audible (.aa/.aax) audiobooks to mp3, like [this script][3] : Cozy is available as a Flatpak on FlatHub. To install it, follow the quick Flatpak: Cozy is available in the : you can install Cozy from its repository: + +-------------------------------------------------------------------------------- + +via: https://www.linuxuprising.com/2018/09/cozy-is-nice-linux-audiobook-player-for.html + +作者:[Logix][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://plus.google.com/118280394805678839070 +[1]: https://cozy.geigi.de/ +[2]: https://cozy.geigi.de/#how-can-i-get-it +[3]: https://gitlab.com/ReverendJ1/audiblefreedom/blob/master/audiblefreedom +[4]: https://flatpak.org/setup/ +[5]: https://flathub.org/apps/details/com.github.geigi.cozy +[6]: https://appcenter.elementary.io/com.github.geigi.cozy/ From 705645fcc45e1885d494e6cbec79527c805f218f Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 19 Sep 2018 19:28:54 +0800 Subject: [PATCH 319/455] add done: 20180918 Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files.md --- ... Is A Nice Linux Audiobook Player For DRM-Free Audio Files.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sources/tech/20180918 Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files.md b/sources/tech/20180918 Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files.md index 93d6399267..8450d6fd11 100644 --- a/sources/tech/20180918 Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files.md +++ b/sources/tech/20180918 Cozy Is A Nice Linux Audiobook Player For DRM-Free Audio Files.md @@ -51,7 +51,6 @@ sudo apt install com.github.geigi.cozy **For other ways of installing Cozy check out its[website][2].** -You could use any audio player to listen to audiobooks, but a specialized audiobook player like Cozy makes everything easier, by, or by letting you, among others.The Cozy interface lets you browse books by author, reader or recency, while also providing search functionality.- either by using embedded images, or by adding a cover.jpg or cover.png image in the book folder, which is automatically picked up and displayed by Cozy.When you click on an audiobook, Cozy lists the book chapters on the right, while displaying the book cover (if available) on the left, along with the book name, author and the last played time, along with total and remaining time:From the application toolbar you can easilyby clicking the rewind icon from its top left-hand side corner. Besides regular controls, cover and title, you'll also find a playback speed button on the toolbar, which lets you increase the playback speed up to 2X.. It can be set to stop after the current chapter or after a given number of minutes.Other Cozy features worth mentioning:What I'd like to see in Cozy is a way to get audiobooks metadata, including the book cover, automatically. A feature to retrieve metadata from Audible.com was proposed on the Cozy GitHub project page and the developer seems interested in this, but it's not clear when or if this will be implemented.Like I was mentioning in the beginning of the article, Cozy only supports DRM-free audio files. Currently it supports mp3, m4a, flac, ogg and wav. Support for more formats will probably come in the future, with m4b being listed on the Cozy 0.7.0 todo list.Cozy cannot play Audible audiobooks due to DRM. But you'll find some solutions out there for converting Audible (.aa/.aax) audiobooks to mp3, like [this script][3] : Cozy is available as a Flatpak on FlatHub. To install it, follow the quick Flatpak: Cozy is available in the : you can install Cozy from its repository: -------------------------------------------------------------------------------- From 91aa8afd07475915232a8077efb0c9964baf79f9 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 19 Sep 2018 19:30:13 +0800 Subject: [PATCH 320/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Force?= =?UTF-8?q?=20APT=20Package=20Manager=20To=20Use=20IPv4=20In=20Ubuntu=2016?= =?UTF-8?q?.04?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...age Manager To Use IPv4 In Ubuntu 16.04.md | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md diff --git a/sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md b/sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md new file mode 100644 index 0000000000..0a9444acc4 --- /dev/null +++ b/sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md @@ -0,0 +1,47 @@ +How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/ipv4-720x340.png) + +**APT** , short or **A** dvanced **P** ackage **T** ool, is the default package manager for Debian-based systems. Using APT, we can install, update, upgrade and remove applications from the system. Lately, I have been facing a strange error. Whenever I try update my Ubuntu 16.04 box, I get this error – **“0% [Connecting to in.archive.ubuntu.com (2001:67c:1560:8001::14)]”** and the update process gets stuck for a long time. My Internet connection is working well and I can able to ping all websites including Ubuntu official site. After a couple Google searches, I realized that sometimes the Ubuntu mirrors are not reachable over IPv6. This problem is solved after I force APT package manager to use IPv4 in place of IPv6 to access Ubuntu mirrors while updating the system. If you ever encountered with this error, you can solve it as described below. + +### Force APT Package Manager To Use IPv4 In Ubuntu 16.04 + +To force APT to use IPv4 in place of IPv6 while updating and upgrading your Ubuntu 16.04 LTS systems, simply use the following commands: + +``` +$ sudo apt-get -o Acquire::ForceIPv4=true update + +$ sudo apt-get -o Acquire::ForceIPv4=true upgrade +``` + +Voila! This time update process run and completed quickly. + +You can also make this persistent for all **apt-get** transactions in the future by adding the following line in **/etc/apt/apt.conf.d/99force-ipv4** file using command: + +``` +$ echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4 +``` + +**Disclaimer:** + +I don’t know if anyone is having this issue lately, but I kept getting this error today at least four to five times in my Ubuntu 16.04 LTS virtual machine and I solved it as described above. I am not sure that it is the recommended solution. Go through Ubuntu forums and make sure this method is legitimate. Since mine is just a VM which I use it only for testing and learning purposes, I don’t mind about the authenticity of this method. Use it on your own risk. + +Hope this helps. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-force-apt-package-manager-to-use-ipv4-in-ubuntu-16-04/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ From 2cd1ce3ae52260481400ec5543f624bf25638a78 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 19 Sep 2018 19:33:03 +0800 Subject: [PATCH 321/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Linux=20tricks=20?= =?UTF-8?q?that=20can=20save=20you=20time=20and=20trouble?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...icks that can save you time and trouble.md | 169 ++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 sources/tech/20180917 Linux tricks that can save you time and trouble.md diff --git a/sources/tech/20180917 Linux tricks that can save you time and trouble.md b/sources/tech/20180917 Linux tricks that can save you time and trouble.md new file mode 100644 index 0000000000..786e2df2c1 --- /dev/null +++ b/sources/tech/20180917 Linux tricks that can save you time and trouble.md @@ -0,0 +1,169 @@ +Linux tricks that can save you time and trouble +====== +Some command line tricks can make you even more productive on the Linux command line. + +![](https://images.idgesg.net/images/article/2018/09/boy-jumping-off-swing-100772498-large.jpg) + +Good Linux command line tricks don’t only save you time and trouble. They also help you remember and reuse complex commands, making it easier for you to focus on what you need to do, not how you should go about doing it. In this post, we’ll look at some handy command line tricks that you might come to appreciate. + +### Editing your commands + +When making changes to a command that you're about to run on the command line, you can move your cursor to the beginning or the end of the command line to facilitate your changes using the ^a (control key plus “a”) and ^e (control key plus “e”) sequences. + +You can also fix and rerun a previously entered command with an easy text substitution by putting your before and after strings between **^** characters -- as in ^before^after^. + +``` +$ eho hello world <== oops! + +Command 'eho' not found, did you mean: + + command 'echo' from deb coreutils + command 'who' from deb coreutils + +Try: sudo apt install + +$ ^e^ec^ <== replace text +echo hello world +hello world + +``` + +### Logging into a remote system with just its name + +If you log into other systems from the command line (I do this all the time), you might consider adding some aliases to your system to supply the details. Your alias can provide the username you want to use (which may or may not be the same as your username on your local system) and the identity of the remote server. Use an alias server_name=’ssh -v -l username IP-address' type of command like this: + +``` +$ alias butterfly=”ssh -v -l jdoe 192.168.0.11” +``` + +You can use the system name in place of the IP address if it’s listed in your /etc/hosts file or available through your DNS server. + +And remember you can list your aliases with the **alias** command. + +``` +$ alias +alias butterfly='ssh -v -l jdoe 192.168.0.11' +alias c='clear' +alias egrep='egrep --color=auto' +alias fgrep='fgrep --color=auto' +alias grep='grep --color=auto' +alias l='ls -CF' +alias la='ls -A' +alias list_repos='grep ^[^#] /etc/apt/sources.list /etc/apt/sources.list.d/*' +alias ll='ls -alF' +alias ls='ls --color=auto' +alias show_dimensions='xdpyinfo | grep '\''dimensions:'\''' +``` + +It's good practice to test new aliases and then add them to your ~/.bashrc or similar file to be sure they will be available any time you log in. + +### Freezing and thawing out your terminal window + +The ^s (control key plus “s”) sequence will stop a terminal from providing output by running an XOFF (transmit off) flow control. This affects PuTTY sessions, as well as terminal windows on your desktop. Sometimes typed by mistake, however, the way to make the terminal window responsive again is to enter ^q (control key plus “q”). The only real trick here is remembering ^q since you aren't very likely run into this situation very often. + +### Repeating commands + +Linux provides many ways to reuse commands. The key to command reuse is your history buffer and the commands it collects for you. The easiest way to repeat a command is to type an ! followed by the beginning letters of a recently used command. Another is to press the up-arrow on your keyboard until you see the command you want to reuse and then press enter. You can also display previously entered commands and then type ! followed by the number shown next to the command you want to reuse in the displayed command history entries. + +``` +!! <== repeat previous command +!ec <== repeat last command that started with "ec" +!76 <== repeat command #76 from command history +``` + +### Watching a log file for updates + +Commands such as tail -f /var/log/syslog will show you lines as they are being added to the specified log file — very useful if you are waiting for some particular activity or want to track what’s happening right now. The command will show the end of the file and then additional lines as they are added. + +``` +$ tail -f /var/log/auth.log +Sep 17 09:41:01 fly CRON[8071]: pam_unix(cron:session): session closed for user smmsp +Sep 17 09:45:01 fly CRON[8115]: pam_unix(cron:session): session opened for user root +Sep 17 09:45:01 fly CRON[8115]: pam_unix(cron:session): session closed for user root +Sep 17 09:47:00 fly sshd[8124]: Accepted password for shs from 192.168.0.22 port 47792 +Sep 17 09:47:00 fly sshd[8124]: pam_unix(sshd:session): session opened for user shs by +Sep 17 09:47:00 fly systemd-logind[776]: New session 215 of user shs. +Sep 17 09:55:01 fly CRON[8208]: pam_unix(cron:session): session opened for user root +Sep 17 09:55:01 fly CRON[8208]: pam_unix(cron:session): session closed for user root + <== waits for additional lines to be added +``` + +### Asking for help + +For most Linux commands, you can enter the name of the command followed by the option **\--help** to get some fairly succinct information on what the command does and how to use it. Less extensive than the man command, the --help option often tells you just what you need to know without expanding on all of the options available. + +``` +$ mkdir --help +Usage: mkdir [OPTION]... DIRECTORY... +Create the DIRECTORY(ies), if they do not already exist. + +Mandatory arguments to long options are mandatory for short options too. + -m, --mode=MODE set file mode (as in chmod), not a=rwx - umask + -p, --parents no error if existing, make parent directories as needed + -v, --verbose print a message for each created directory + -Z set SELinux security context of each created directory + to the default type + --context[=CTX] like -Z, or if CTX is specified then set the SELinux + or SMACK security context to CTX + --help display this help and exit + --version output version information and exit + +GNU coreutils online help: +Full documentation at: +or available locally via: info '(coreutils) mkdir invocation' +``` + +### Removing files with care + +To add a little caution to your use of the rm command, you can set it up with an alias that asks you to confirm your request to delete files before it goes ahead and deletes them. Some sysadmins make this the default. In that case, you might like the next option even more. + +``` +$ rm -i <== prompt for confirmation +``` + +### Turning off aliases + +You can always disable an alias interactively by using the unalias command. It doesn’t change the configuration of the alias in question; it just disables it until the next time you log in or source the file in which the alias is set up. + +``` +$ unalias rm +``` + +If the **rm -i** alias is set up as the default and you prefer to never have to provide confirmation before deleting files, you can put your **unalias** command in one of your startup files (e.g., ~/.bashrc). + +### Remembering to use sudo + +If you often forget to precede commands that only root can run with “sudo”, there are two things you can do. You can take advantage of your command history by using the “sudo !!” (use sudo to run your most recent command with sudo prepended to it), or you can turn some of these commands into aliases with the required "sudo" attached. + +``` +$ alias update=’sudo apt update’ +``` + +### More complex tricks + +Some useful command line tricks require a little more than a clever alias. An alias, after all, replaces a command, often inserting options so you don't have to enter them and allowing you to tack on additional information. If you want something more complex than an alias can manage, you can write a simple script or add a function to your .bashrc or other start-up file. The function below, for example, creates a directory and moves you into it. Once it's been set up, source your .bashrc or other file and you can use commands such as "md temp" to set up a directory and cd into it. + +``` +md () { mkdir -p "$@" && cd "$1"; } +``` + +### Wrap-up + +Working on the Linux command line remains one of the most productive and enjoyable ways to get work done on my Linux systems, but a group of command line tricks and clever aliases can make that experience even better. + +Join the Network World communities on [Facebook][1] and [LinkedIn][2] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3305811/linux/linux-tricks-that-even-you-can-love.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[1]: https://www.facebook.com/NetworkWorld/ +[2]: https://www.linkedin.com/company/network-world From 2c96f4d5ca0d85f484a987a02f4733fa5e47a562 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 19 Sep 2018 19:35:54 +0800 Subject: [PATCH 322/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Top=203=20Python?= =?UTF-8?q?=20libraries=20for=20data=20science?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Top 3 Python libraries for data science.md | 242 ++++++++++++++++++ 1 file changed, 242 insertions(+) create mode 100644 sources/tech/20180918 Top 3 Python libraries for data science.md diff --git a/sources/tech/20180918 Top 3 Python libraries for data science.md b/sources/tech/20180918 Top 3 Python libraries for data science.md new file mode 100644 index 0000000000..37315fed6b --- /dev/null +++ b/sources/tech/20180918 Top 3 Python libraries for data science.md @@ -0,0 +1,242 @@ +Top 3 Python libraries for data science +====== +Turn Python into a scientific data analysis and modeling tool with these libraries. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr) + +Python's many attractions—such as efficiency, code readability, and speed—have made it the go-to programming language for data science enthusiasts. Python is usually the preferred choice for data scientists and machine learning experts who want to escalate the functionalities of their applications. (For example, Andrey Bulezyuk used the Python programming language to create an amazing [machine learning application][1].) + +Because of its extensive usage, Python has a huge number of libraries that make it easier for data scientists to complete complicated tasks without many coding hassles. Here are the top 3 Python libraries for data science; check them out if you want to kickstart your career in the field. + +### 1\. NumPy + +[NumPy][2] (short for Numerical Python) is one of the top libraries equipped with useful resources to help data scientists turn Python into a powerful scientific analysis and modelling tool. The popular open source library is available under the BSD license. It is the foundational Python library for performing tasks in scientific computing. NumPy is part of a bigger Python-based ecosystem of open source tools called SciPy. + +The library empowers Python with substantial data structures for effortlessly performing multi-dimensional arrays and matrices calculations. Besides its uses in solving linear algebra equations and other mathematical calculations, NumPy is also used as a versatile multi-dimensional container for different types of generic data. + +Furthermore, it integrates flawlessly with other programming languages like C/C++ and Fortran. The versatility of the NumPy library allows it to easily and swiftly coalesce with an extensive range of databases and tools. For example, let's see how NumPy (abbreviated **np** ) can be used for multiplying two matrices. + +Let's start by importing the library (we'll be using the Jupyter notebook for these examples). + +``` +import numpy as np +``` + +Next, let's use the **eye()** function to generate an identity matrix with the stipulated dimensions. + +``` +matrix_one = np.eye(3) +matrix_one +``` + +Here is the output: + +``` +array([[1., 0., 0.], +       [0., 1., 0.], +       [0., 0., 1.]]) +``` + +Let's generate another 3x3 matrix. + +We'll use the **arange([starting number], [stopping number])** function to arrange numbers. Note that the first parameter in the function is the initial number to be listed and the last number is not included in the generated results. + +Also, the **reshape()** function is applied to modify the dimensions of the originally generated matrix into the desired dimension. For the matrices to be "multiply-able," they should be of the same dimension. + +``` +matrix_two = np.arange(1,10).reshape(3,3) +matrix_two +``` + +Here is the output: + +``` +array([[1, 2, 3], +       [4, 5, 6], +       [7, 8, 9]]) +``` + +Let's use the **dot()** function to multiply the two matrices. + +``` +matrix_multiply = np.dot(matrix_one, matrix_two) + +matrix_multiply + +``` + +Here is the output: + +``` +array([[1., 2., 3.], +       [4., 5., 6.], +       [7., 8., 9.]]) +``` + +Great! + +We managed to multiply two matrices without using vanilla Python. + +Here is the entire code for this example: + +``` +import numpy as np +#generating a 3 by 3 identity matrix +matrix_one = np.eye(3) +matrix_one +#generating another 3 by 3 matrix for multiplication +matrix_two = np.arange(1,10).reshape(3,3) +matrix_two +#multiplying the two arrays +matrix_multiply = np.dot(matrix_one, matrix_two) +matrix_multiply +``` + +### 2\. Pandas + +[Pandas][3] is another great library that can enhance your Python skills for data science. Just like NumPy, it belongs to the family of SciPy open source software and is available under the BSD free software license. + +Pandas offers versatile and powerful tools for munging data structures and performing extensive data analysis. The library works well with incomplete, unstructured, and unordered real-world data—and comes with tools for shaping, aggregating, analyzing, and visualizing datasets. + +There are three types of data structures in this library: + + * Series: single-dimensional, homogeneous array + * DataFrame: two-dimensional with heterogeneously typed columns + * Panel: three-dimensional, size-mutable array + + + +For example, let's see how the Panda Python library (abbreviated **pd** ) can be used for performing some descriptive statistical calculations. + +Let's start by importing the library. + +``` +import pandas as pd +``` + +Let's create a dictionary of series. + +``` +d = {'Name':pd.Series(['Alfrick','Michael','Wendy','Paul','Dusan','George','Andreas', +   'Irene','Sagar','Simon','James','Rose']), +   'Years of Experience':pd.Series([5,9,1,4,3,4,7,9,6,8,3,1]), +   'Programming Language':pd.Series(['Python','JavaScript','PHP','C++','Java','Scala','React','Ruby','Angular','PHP','Python','JavaScript']) +    } +``` + +Let's create a DataFrame. + +``` +df = pd.DataFrame(d) +``` + +Here is a nice table of the output: + +``` +      Name Programming Language  Years of Experience +0   Alfrick               Python                    5 +1   Michael           JavaScript                    9 +2     Wendy                  PHP                    1 +3      Paul                  C++                    4 +4     Dusan                 Java                    3 +5    George                Scala                    4 +6   Andreas                React                    7 +7     Irene                 Ruby                    9 +8     Sagar              Angular                    6 +9     Simon                  PHP                    8 +10    James               Python                    3 +11     Rose           JavaScript                    1 +``` + +Here is the entire code for this example: + +``` +import pandas as pd +#creating a dictionary of series +d = {'Name':pd.Series(['Alfrick','Michael','Wendy','Paul','Dusan','George','Andreas', +   'Irene','Sagar','Simon','James','Rose']), +   'Years of Experience':pd.Series([5,9,1,4,3,4,7,9,6,8,3,1]), +   'Programming Language':pd.Series(['Python','JavaScript','PHP','C++','Java','Scala','React','Ruby','Angular','PHP','Python','JavaScript']) +    } + +#Create a DataFrame +df = pd.DataFrame(d) +print(df) +``` + +### 3\. Matplotlib + +[Matplotlib][4] is also part of the SciPy core packages and offered under the BSD license. It is a popular Python scientific library used for producing simple and powerful visualizations. You can use the Python framework for data science for generating creative graphs, charts, histograms, and other shapes and figures—without worrying about writing many lines of code. For example, let's see how the Matplotlib library can be used to create a simple bar chart. + +Let's start by importing the library. + +``` +from matplotlib import pyplot as plt +``` + +Let's generate values for both the x-axis and the y-axis. + +``` +x = [2, 4, 6, 8, 10] +y = [10, 11, 6, 7, 4] +``` + +Let's call the function for plotting the bar chart. + +``` +plt.bar(x,y) +``` + +Let's show the plot. + +``` +plt.show() +``` + +Here is the bar chart: + +![](https://opensource.com/sites/default/files/uploads/matplotlib_barchart.png) + +Here is the entire code for this example: + +``` +#importing Matplotlib Python library +from matplotlib import pyplot as plt +#same as import matplotlib.pyplot as plt +  +#generating values for x-axis +x = [2, 4, 6, 8, 10] +  +#generating vaues for y-axis +y = [10, 11, 6, 7, 4] +  +#calling function for plotting the bar chart +plt.bar(x,y) +  +#showing the plot +plt.show() +``` + +### Wrapping up + +The Python programming language has always done a good job in data crunching and preparation, but less so for complicated scientific data analysis and modeling. The top Python frameworks for [data science][5] help fill this gap, allowing you to carry out complex mathematical computations and create sophisticated models that make sense of your data. + +Which other Python data-mining libraries do you know? What's your experience with them? Please share your comments below. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/top-3-python-libraries-data-science + +作者:[Dr.Michael J.Garbade][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/drmjg +[1]: https://www.liveedu.tv/andreybu/REaxr-machine-learning-model-python-sklearn-kera/oPGdP-machine-learning-model-python-sklearn-kera/ +[2]: http://www.numpy.org/ +[3]: http://pandas.pydata.org/ +[4]: https://matplotlib.org/ +[5]: https://www.liveedu.tv/guides/data-science/ From 5934c3f30a69ea6bdf25d38192425f824026896d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BB=98=E5=B3=A5?= <24203166+fuzheng1998@users.noreply.github.com> Date: Wed, 19 Sep 2018 20:20:45 +0800 Subject: [PATCH 323/455] apply for translation --- .../tech/20171005 10 Games You Can Play on Linux with Wine.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20171005 10 Games You Can Play on Linux with Wine.md b/sources/tech/20171005 10 Games You Can Play on Linux with Wine.md index 5bab9d8c65..37b1adb669 100644 --- a/sources/tech/20171005 10 Games You Can Play on Linux with Wine.md +++ b/sources/tech/20171005 10 Games You Can Play on Linux with Wine.md @@ -1,3 +1,4 @@ +### fuzheng1998 translating 10 Games You Can Play on Linux with Wine ====== ![](https://www.maketecheasier.com/assets/uploads/2017/09/wine-games-feat.jpg) From b057ca9e2b9973ceb8c537f58da96ac0817cc49d Mon Sep 17 00:00:00 2001 From: feng lv Date: Wed, 19 Sep 2018 22:31:03 +0800 Subject: [PATCH 324/455] translating --- .../tech/20180918 Top 3 Python libraries for data science.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180918 Top 3 Python libraries for data science.md b/sources/tech/20180918 Top 3 Python libraries for data science.md index 37315fed6b..2c4b88595d 100644 --- a/sources/tech/20180918 Top 3 Python libraries for data science.md +++ b/sources/tech/20180918 Top 3 Python libraries for data science.md @@ -1,3 +1,5 @@ +ucasFL translating + Top 3 Python libraries for data science ====== Turn Python into a scientific data analysis and modeling tool with these libraries. From eb5f87063a8ad878eb23e8d1766a7ef792cd189e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 19 Sep 2018 22:32:25 +0800 Subject: [PATCH 325/455] PRF:20180720 How to build a URL shortener with Apache.md @geekpi --- ...ow to build a URL shortener with Apache.md | 39 ++++++++----------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/translated/tech/20180720 How to build a URL shortener with Apache.md b/translated/tech/20180720 How to build a URL shortener with Apache.md index 8a88338a9c..8fc2d473d1 100644 --- a/translated/tech/20180720 How to build a URL shortener with Apache.md +++ b/translated/tech/20180720 How to build a URL shortener with Apache.md @@ -1,65 +1,60 @@ -如何使用 Apache 构建 URL 缩短器 +如何使用 Apache 构建 URL 缩短服务 ====== +> 用 Apache HTTP 服务器的 mod_rewrite 功能创建你自己的短链接。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openweb-osdc-lead.png?itok=yjU4KliG) -很久以前,人们开始在 Twitter 上分享链接。140 个字符的限制意味着 URL 可能消耗一条推文的大部分(或全部),因此人们使用 URL 缩短器。最终,Twitter 加入了一个内置的 URL 缩短器([t.co][1])。 +很久以前,人们开始在 Twitter 上分享链接。140 个字符的限制意味着 URL 可能消耗一条推文的大部分(或全部),因此人们使用 URL 缩短服务。最终,Twitter 加入了一个内置的 URL 缩短服务([t.co][1])。 -字符数现在不重要了,但还有其他原因要缩短链接。首先,缩短服务可以提供分析 - 你可以看到你分享的链接的受欢迎程度。它还简化了制作易于记忆的 URL。例如,[bit.ly/INtravel][2] 比更容易记住。如果你想预先共享一个链接,但还不知道最终地址,这时 URL 缩短器可以派上用场。。 +字符数现在不重要了,但还有其他原因要缩短链接。首先,缩短服务可以提供分析功能 —— 你可以看到你分享的链接的受欢迎程度。它还简化了制作易于记忆的 URL。例如,[bit.ly/INtravel][2] 比更容易记住。如果你想预先共享一个链接,但还不知道最终地址,这时 URL 缩短服务可以派上用场。。 -与任何技术一样,URL 缩短器并非都是正面的。通过屏蔽最终地址,缩短的链接可用于指向恶意或冒犯性内容。但是,如果你仔细上网,URL 缩短器是一个有用的工具。 +与任何技术一样,URL 缩短服务并非都是正面的。通过屏蔽最终地址,缩短的链接可用于指向恶意或冒犯性内容。但是,如果你仔细上网,URL 缩短服务是一个有用的工具。 -我们之前在网站上[发布过缩短器的文章][3],但也许你想要运行一些由简单的文本驱动的缩短器。在本文中,我们将展示如何使用 Apache HTTP 服务器的 mod_rewrite 功能来设置自己的 URL 缩短器。如果你不熟悉 Apache HTTP 服务器,请查看 David Both 关于[安装和配置][4]的文章。 +我们之前在网站上[发布过缩短服务的文章][3],但也许你想要运行一些由简单的文本文件支持的缩短服务。在本文中,我们将展示如何使用 Apache HTTP 服务器的 mod_rewrite 功能来设置自己的 URL 缩短服务。如果你不熟悉 Apache HTTP 服务器,请查看 David Both 关于[安装和配置][4]它的文章。 ### 创建一个 VirtualHost -在本教程中,我假设你购买了一个很酷的域名,你将它专门用于 URL 缩短器。例如,我的网站是 [funnelfiasco.com][5],所以我买了 [funnelfias.co][6] 用于我的 URL 缩短器(好吧,它不是很短,但它可以满足我的虚荣心)。如果你不将缩短器作为单独的域运行,请跳到下一部分。 +在本教程中,我假设你购买了一个很酷的域名,你将它专门用于 URL 缩短服务。例如,我的网站是 [funnelfiasco.com][5],所以我买了 [funnelfias.co][6] 用于我的 URL 缩短服务(好吧,它不是很短,但它可以满足我的虚荣心)。如果你不将缩短服务作为单独的域运行,请跳到下一部分。 + +第一步是设置将用于 URL 缩短服务的 VirtualHost。有关 VirtualHost 的更多信息,请参阅 [David Both 的文章][7]。这步只需要几行: -第一步是设置将用于 URL 缩短器的 VirtualHost。有关 VirtualHosts 的更多信息,请参[ David Both 的文章][7]。这步只需要几行: ```     -         ServerName funnelfias.co -     - ``` -### 创建 rewrite +### 创建重写规则 此服务使用 HTTPD 的重写引擎来重写 URL。如果你在上面的部分中创建了 VirtualHost,则下面的配置跳到你的 VirtualHost 部分。否则跳到服务器的 VirtualHost 或主 HTTPD 配置。 + ```     RewriteEngine on -     RewriteMap shortlinks txt:/data/web/shortlink/links.txt -     RewriteRule ^/(.+)$ ${shortlinks:$1} [R=temp,L] - ``` 第一行只是启用重写引擎。第二行在文本文件构建短链接的映射。上面的路径只是一个例子。你需要使用系统上使用有效路径(确保它可由运行 HTTPD 的用户帐户读取)。最后一行重写 URL。在此例中,它接受任何字符并在重写映射中查找它们。你可能希望重写时使用特定的字符串。例如,如果你希望所有缩短的链接都是 “slX”(其中 X 是数字),则将上面的 `(.+)` 替换为 `(sl\d+)`。 -我在这里使用了临时 (HTTP 302) 重定向。这能让我稍后更新目标 URL。如果希望短链接始终指向同一目标,则可以使用永久 (HTTP 301) 重定向。用 `permanent` 替换第三行的 `temp`。 +我在这里使用了临时重定向(HTTP 302)。这能让我稍后更新目标 URL。如果希望短链接始终指向同一目标,则可以使用永久重定向(HTTP 301)。用 `permanent` 替换第三行的 `temp`。 ### 构建你的映射 -编辑配置文件 “RewriteMap” 行中的指定文件。格式是空格分隔的键值存储。在每一行上放一个链接: +编辑配置文件 `RewriteMap` 行中的指定文件。格式是空格分隔的键值存储。在每一行上放一个链接: + ```     osdc https://opensource.com/users/bcotton -     twitter https://twitter.com/funnelfiasco -     swody1 https://www.spc.noaa.gov/products/outlook/day1otlk.html - ``` ### 重启 HTTPD -最后一步是重启 HTTPD 进程。这是通过 `systemctl restart httpd` 或类似命令完成的(命令和守护进程名称可能因发行版而不同)。你的链接缩短器现已启动并运行。当你准备编辑映射时,无需重新启动 Web 服务器。你所要做的就是保存文件,Web 服务器将获取到差异。 +最后一步是重启 HTTPD 进程。这是通过 `systemctl restart httpd` 或类似命令完成的(命令和守护进程名称可能因发行版而不同)。你的链接缩短服务现已启动并运行。当你准备编辑映射时,无需重新启动 Web 服务器。你所要做的就是保存文件,Web 服务器将获取到差异。 ### 未来的工作 -此示例为你提供了基本的 URL 缩短器。如果你想将开发自己的管理接口作为学习项目,它可以作为一个很好的起点。或者你可以使用它分享容易记住的链接到那些容易忘记的 URL。 +此示例为你提供了基本的 URL 缩短服务。如果你想将开发自己的管理接口作为学习项目,它可以作为一个很好的起点。或者你可以使用它分享容易记住的链接到那些容易忘记的 URL。 -------------------------------------------------------------------------------- @@ -68,7 +63,7 @@ via: https://opensource.com/article/18/7/apache-url-shortener 作者:[Ben Cotton][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From cb016e9d6fa764c64f3fa3b8753d296188ced4f7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 19 Sep 2018 22:33:07 +0800 Subject: [PATCH 326/455] PUB:20180720 How to build a URL shortener with Apache.md @geekpi https://linux.cn/article-10031-1.html --- .../20180720 How to build a URL shortener with Apache.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180720 How to build a URL shortener with Apache.md (100%) diff --git a/translated/tech/20180720 How to build a URL shortener with Apache.md b/published/20180720 How to build a URL shortener with Apache.md similarity index 100% rename from translated/tech/20180720 How to build a URL shortener with Apache.md rename to published/20180720 How to build a URL shortener with Apache.md From 51dec09f82a768b17242c26ebb2ed9ab18b37077 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 19 Sep 2018 23:26:18 +0800 Subject: [PATCH 327/455] PRF:20180131 What I Learned from Programming Interviews.md @DavidChenLiang --- ...t I Learned from Programming Interviews.md | 73 ++++++++----------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/translated/tech/20180131 What I Learned from Programming Interviews.md b/translated/tech/20180131 What I Learned from Programming Interviews.md index 2f9c01b6ff..1c090b8e97 100644 --- a/translated/tech/20180131 What I Learned from Programming Interviews.md +++ b/translated/tech/20180131 What I Learned from Programming Interviews.md @@ -1,29 +1,28 @@ 我从编程面试中学到的 -============================================================ - +====== ![](https://cdn-images-1.medium.com/max/1250/1*DXPdaGPM4oM6p5nSkup7IQ.jpeg) -聊聊白板编程面试 -在2017年,我参加了[Grace Hopper Celebration][1]‘计算机行业中的女性’这一活动。这个活动是这类科技活动中最大的一个。共有17,000名女性IT工作者参加。 +*聊聊白板编程面试* -这个会议有个大型的配套招聘会,会上有招聘公司来面试会议参加者。有些人甚至现场拿到offer。我在现场晃荡了一下,注意到一些应聘者看上去非常紧张忧虑。我还隐隐听到应聘者之间的谈话,其中一些人谈到在面试中做的并不好。 +在 2017 年,我参加了 ‘计算机行业中的女性’ 的[Grace Hopper 庆祝活动][1]。这个活动是这类科技活动中最大的一个。共有 17,000 名女性IT工作者参加。 -我走近我听到谈话的那群人并和她们聊了起来并给了一些面试上的小建议。我想我的建议还是比较偏基本的,如“(在面试时)一开始给出个能工作的解决方案也还说的过去”之类的,但是当她们听到我的一些其他的建议时还是颇为吃惊。 +这个会议有个大型的配套招聘会,会上有招聘公司来面试会议参加者。有些人甚至现场拿到 offer。我在现场晃荡了一下,注意到一些应聘者看上去非常紧张忧虑。我还隐隐听到应聘者之间的谈话,其中一些人谈到在面试中做的并不好。 -为了能更多的帮到像她们一样的白面面试者,我收集了一些过去对我有用的小点子,这些小点子我已经发表在了[prodcast episode][2]上。它们也是这篇文章的主题。 +我走近我听到谈话的那群人并和她们聊了起来并给了一些面试上的小建议。我想我的建议还是比较偏基本的,如“(在面试时)一开始给出个能工作的解决方案也还说的过去”之类的,但是当她们听到我的一些其他的建议时还是颇为吃惊。 + +为了能更多的帮到像她们一样的小白面试者,我收集了一些过去对我有用的小点子,这些小点子我已经发表在了 [prodcast episode][2] 上。它们也是这篇文章的主题。 为了实习生职位和全职工作,我做过很多次的面试。当我还在大学主修计算机科学时,学校每个秋季学期都有招聘会,第一轮招聘会在校园里举行。(我在第一和最后一轮都搞砸过。)不过,每次面试后,我都会反思哪些方面我能做的更好,我还会和朋友们做模拟面试,这样我就能从他们那儿得到更多的面试反馈。 -不管我们怎么样找工作: 工作中介,网络,或者学校招聘,他们的招聘流程中都会涉及到技术面试: +不管我们怎么样找工作: 工作中介、网络,或者学校招聘,他们的招聘流程中都会涉及到技术面试: 近年来,我注意到了一些新的不同的面试形式出现了: * 与招聘方的一位工程师结对编程 * 网络在线测试及在线编码 -* 白板编程(LCTT译者注: 这种形式应该不新了) - +* 白板编程(LCTT 译注: 这种形式应该不新了) 我将重点谈谈白板面试,这种形式我经历的最多。我有过很多次面试,有些挺不错的,有些被我搞砸了。 @@ -31,7 +30,7 @@ 首先,我想回顾一下我做的不好的地方。知错能改,善莫大焉。 -当面试者提出一个要我解决的问题时, 我立即马上立刻开始在白板上写代码,_什么都不问。_ +当面试者提出一个要我解决的问题时, 我立即马上立刻开始在白板上写代码,_什么都不问。_ 这里我犯了两个错误: @@ -41,7 +40,7 @@ #### 只会默默思考,不去记录想法或和面试官沟通 -在面试中,很多时候我也会傻傻站在那思考,什么都不写。我和一个朋友模拟面试的时候,他告诉我因为他曾经和我一起工作过所以他知道我在思考,但是如果他是个陌生的面试官的话,他会觉得要么我正站在那冥思苦想,毫无头绪。不要急匆匆的直奔解题而去是很重要的。花点时间多想想各种解题的可能性。有时候面试官会乐意和你一起探索解题的步骤。不管怎样,这就是在一家公司开工作会议的的普遍方式,大家各抒己见,一起讨论如何解决问题。 +在面试中,很多时候我也会傻傻站在那思考,什么都不写。我和一个朋友模拟面试的时候,他告诉我因为他曾经和我一起工作过所以他知道我在思考,但是如果他是个陌生的面试官的话,他会觉得我正站在那冥思苦想,毫无头绪。不要急匆匆的直奔解题而去是很重要的。花点时间多想想各种解题的可能性。有时候面试官会乐意和你一起探索解题的步骤。不管怎样,这就是在一家公司开工作会议的的普遍方式,大家各抒己见,一起讨论如何解决问题。 ### 想到一个解题方法 @@ -50,30 +49,27 @@ 这是对我管用的步骤: 1. 头脑风暴 - 2. 写代码 - 3. 处理错误路径 - 4. 测试 -#### 1\. 头脑风暴 +#### 1、 头脑风暴 对我来说,我会首先通过一些例子来视觉化我要解决的问题。比如说如果这个问题和数据结构中的树有关,我就会从树底层的空节点开始思考,如何处理一个节点的情况呢?两个节点呢?三个节点呢?这能帮助你从具体例子里抽象出你的解决方案。 -在白板上先写下你的算法要做的事情列表。这样做,你往往能在开始写代码前就发现bug和缺陷(不过你可得掌握好时间)。我犯过的一个错误是我花了过多的时间在澄清问题和头脑风暴上,最后几乎没有留下时间给我写代码。你的面试官可能没有机会看你在白板上写下代码,这可太糟了。你可以带块手表,或者房间有钟的话,你也可以抬头看看时间。有些时候面试者会提醒你你已经得到了所有的信息(这时你就不要再问别的了),'我想我们已经把所有需要的信息都澄清了,让我们写代码实现吧' +在白板上先写下你的算法要做的事情列表。这样做,你往往能在开始写代码前就发现 bug 和缺陷(不过你可得掌握好时间)。我犯过的一个错误是我花了过多的时间在澄清问题和头脑风暴上,最后几乎没有留下时间给我写代码。你的面试官可能没有机会看你在白板上写下代码,这可太糟了。你可以带块手表,或者房间有钟的话,你也可以抬头看看时间。有些时候面试者会提醒你你已经得到了所有的信息(这时你就不要再问别的了),“我想我们已经把所有需要的信息都澄清了,让我们写代码实现吧”。 -#### 2\. 开始写代码,一气呵成 +#### 2、 开始写代码,一气呵成 -如果你还没有得到问题的完美解决方法,从最原始的解法开始总的可以的。当你在向面试官解释最显而易见的解法时,你要想想怎么去完善它,并指明这种做法是最原始,未加优化的。(请熟悉算法中的O()的概念,这对面试非常有用。)在向面试者提交前请仔细检查你的解决方案两三遍。面试者有时会给你些提示, ‘还有更好的方法吗?’,这句话的意思是面试官提示你有更优化的解决方案。 +如果你还没有得到问题的完美解决方法,从最原始的解法开始总是可以的。当你在向面试官解释最显而易见的解法时,你要想想怎么去完善它,并指明这种做法是最原始的,未加优化的。(请熟悉算法中的 `O()` 的概念,这对面试非常有用。)在向面试者提交前请仔细检查你的解决方案两三遍。面试者有时会给你些提示, “还有更好的方法吗?”,这句话的意思是面试官提示你有更优化的解决方案。 -#### 3\. 错误处理 +#### 3、 错误处理 -当你在编码时,对你想做错误处理的代码行做个注释。当面试者说,'很好,这里你想到了错误处理。你想怎么处理呢?抛出异常还是返回错误码?',这将给你个机会去引出关于代码质量的一番讨论。当然,这种地方提出几个就够了。有时,面试者为了节省编码的时间,会告诉你可以假设外界输入的参数都已经通过了校验。不管怎样,你都要展现你对错误处理和编码质量的重要性的认识。 +当你在编码时,对你想做错误处理的代码行做个注释。当面试者说,“很好,这里你想到了错误处理。你想怎么处理呢?抛出异常还是返回错误码?”,这将给你个机会去引出关于代码质量的一番讨论。当然,这种地方提出几个就够了。有时,面试者为了节省编码的时间,会告诉你可以假设外界输入的参数都已经通过了校验。不管怎样,你都要展现你对错误处理和编码质量的重要性的认识。 -#### 4\. 测试 +#### 4、 测试 -在编码完成后,用你在前面头脑风暴中写的用例来在你脑子里“跑”一下你的代码,确定万无一失。例如你可以说,‘让我用前面写下的树的例子来跑一下我的代码,如果是一个节点是什么结果,如果是两个节点是什么结果。。。’ +在编码完成后,用你在前面头脑风暴中写的用例来在你脑子里“跑”一下你的代码,确定万无一失。例如你可以说,“让我用前面写下的树的例子来跑一下我的代码,如果是一个节点是什么结果,如果是两个节点是什么结果……” 在你结束之后,面试者有时会问你你将会怎么测试你的代码,你会涉及什么样的测试用例。我建议你用下面不同的分类来组织你的错误用例: @@ -83,7 +79,7 @@ 2. 错误用例 3. 期望的正常用例 -对于性能测试,要考虑极端数量下的情况。例如,如果问题是关于列表的,你可以说你将会使用一个非常大的列表以及的非常小的列表来测试。如果和数字有关,你将会测试系统中的最大整数和最小整数。我建议读一些有关软件测试的书来得到更多的知识。在这个领域我最喜欢的书是[How We Test Software at Microsoft][3]。 +对于性能测试,要考虑极端数量下的情况。例如,如果问题是关于列表的,你可以说你将会使用一个非常大的列表以及的非常小的列表来测试。如果和数字有关,你将会测试系统中的最大整数和最小整数。我建议读一些有关软件测试的书来得到更多的知识。在这个领域我最喜欢的书是 《[我们在微软如何测试软件][3]》。 对于错误用例,想一下什么是期望的错误情况并一一写下。 @@ -91,50 +87,45 @@ ### “你还有什么要问我的吗?” -面试最后总是会留几分钟给你问问题。我建议你在面试前写下你想问的问题。千万别说,‘我没什么问题了’,就算你觉得面试砸了或者你对这间公司不怎么感兴趣,你总有些东西可以问问。你甚至可以问面试者他最喜欢自己的工作什么,最讨厌自己的工作什么。或者你可以问问面试官的工作具体是什么,在用什么技术和实践。不要因为觉得自己在面试中做的不好而心灰意冷,不想问什么问题。 +面试最后总是会留几分钟给你问问题。我建议你在面试前写下你想问的问题。千万别说,“我没什么问题了”,就算你觉得面试砸了或者你对这间公司不怎么感兴趣,你总有些东西可以问问。你甚至可以问面试者他最喜欢自己的工作什么,最讨厌自己的工作什么。或者你可以问问面试官的工作具体是什么,在用什么技术和实践。不要因为觉得自己在面试中做的不好而心灰意冷,不想问什么问题。 ### 申请一份工作 - -关于找工作申请工作,有人曾经告诉我,你应该去找你真正有激情工作的地方。去找一家你喜欢的公司,或者你喜欢使用的产品,看看你能不能去那儿工作。 +关于找工作和申请工作,有人曾经告诉我,你应该去找你真正有激情工作的地方。去找一家你喜欢的公司,或者你喜欢使用的产品,看看你能不能去那儿工作。 我个人并不推荐你用上述的方法去找工作。你会排除很多很好的公司,特别是你是在找实习工作或者入门级的职位时。 -你也可以集中在其他的一些目标上。如:我想从这个工作里得到哪方面的更多经验?这个工作是关于云计算?Web开发?或是人工智能?当在招聘会上与招聘公司沟通是,看看他们的工作单位有没有在这些领域的。你可能会在一家并非在你的想去公司列表上的公司(或非盈利机构)里找到你想找的职位。 +你也可以集中在其他的一些目标上。如:我想从这个工作里得到哪方面的更多经验?这个工作是关于云计算?Web 开发?或是人工智能?当在招聘会上与招聘公司沟通时,看看他们的工作单位有没有在这些领域的。你可能会在一家并非在你的想去公司列表上的公司(或非盈利机构)里找到你想找的职位。 #### 换组 -在这家公司里的第一个组里呆了一年半以后,我觉得是时候去探索一下不同的东西了。我找到了一个我喜欢的组并进行了4轮面试。结果我搞砸了。 - - -我什么都没有准备,甚至都没在白板上练练手。我当时的逻辑是,如果我都已经在一家公司干了快2年了,我还需要练什么?我完全错了,我在接下去的白板面试中跌跌撞撞。我的板书写得太小,而且因为没有从最左上角开始写代码,我的代码大大超出了一个白板的空间,这些都导致了白板面试失败。 +在这家公司里的第一个组里呆了一年半以后,我觉得是时候去探索一下不同的东西了。我找到了一个我喜欢的组并进行了 4 轮面试。结果我搞砸了。 +我什么都没有准备,甚至都没在白板上练练手。我当时的逻辑是,如果我都已经在一家公司干了快 2 年了,我还需要练什么?我完全错了,我在接下去的白板面试中跌跌撞撞。我的板书写得太小,而且因为没有从最左上角开始写代码,我的代码大大超出了一个白板的空间,这些都导致了白板面试失败。 我在面试前也没有刷过数据结构和算法题。如果我做了的话,我将会在面试中更有信心。就算你已经在一家公司担任了软件工程师,在你去另外一个组面试前,我强烈建议你在一块白板上演练一下如何写代码。 +对于换项目组这件事,如果你是在公司内部换组的话,事先能同那个组的人非正式聊聊会很有帮助。对于这一点,我发现几乎每个人都很乐于和你一起吃个午饭。人一般都会在中午有空,约不到人或者别人正好有会议冲突的风险会很低。这是一种非正式的途径来了解你想去的组正在干什么,以及这个组成员个性是怎么样的。相信我,你能从一次午餐中得到很多信息,这可会对你的正式面试帮助不小。 -对于换项目组这件事,如果你是在公司内部换组的话,事先能同那个组的人非正式聊聊会很有帮助。对于这一点,我发现几乎每个人都很乐于和你一起吃个午饭。人一般都会在中午有空,约不到人或者别人正好有会议冲突的风险会很低。这是一种非正式的途径来了解你想去的组正在干什么,以及这个组成员个性是怎么样的。相信我, 你能从一次午餐中得到很多信息,这可会对你的正式面试帮助不小。 +非常重要的一点是,你在面试一个特定的组时,就算你在面试中做的很好,因为文化不契合的原因,你也很可能拿不到 offer。这也是为什么我一开始就想去见见组里不同的人的原因(有时这也不太可能),我希望你不要被一次拒绝所击倒,请保持开放的心态,选择新的机会,并多多练习。 -非常重要的一点是,你在面试一个特定的组时,就算你在面试中做的很好,因为文化不契合的原因,你也很可能拿不到offer。这也是为什么我一开始就想去见见组里不同的人的原因(有时这也不太可能),我希望你不要被一次拒绝所击倒,请保持开放的心态,选择新的机会,并多多练习。 - - -以上内容来自["Programming interviews"][4] 章节,选自 [The Women in Tech Show: Technical Interviews with Prominent Women in Tech][5] +以上内容选自 《[The Women in Tech Show: Technical Interviews with Prominent Women in Tech][5]》的 “[编程面试][4]”章节, -------------------------------------------------------------------------------- 作者简介: -微软研究院Software Engineer II, www.thewomenintechshow.com站长,所有观点都只代表本人意见。 +微软研究院 Software Engineer II, www.thewomenintechshow.com 站长,所有观点都只代表本人意见。 ------------ via: https://medium.freecodecamp.org/what-i-learned-from-programming-interviews-29ba49c9b851 -作者:[Edaena Salinas ][a] -译者:DavidChenLiang (https://github.com/DavidChenLiang) -校对:[校对者ID](https://github.com/校对者ID) +作者:[Edaena Salinas][a] +译者:[DavidChenLiang](https://github.com/DavidChenLiang) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8a99cac72bdf3b05ade1047d0b655899f2e28378 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 19 Sep 2018 23:27:14 +0800 Subject: [PATCH 328/455] PUB: 20180131 What I Learned from Programming Interviews.md @DavidChenLiang https://linux.cn/article-10032-1.html --- .../20180131 What I Learned from Programming Interviews.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180131 What I Learned from Programming Interviews.md (100%) diff --git a/translated/tech/20180131 What I Learned from Programming Interviews.md b/published/20180131 What I Learned from Programming Interviews.md similarity index 100% rename from translated/tech/20180131 What I Learned from Programming Interviews.md rename to published/20180131 What I Learned from Programming Interviews.md From 75257b55288660d78d71340e378a0be92d22ee0f Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 20 Sep 2018 08:53:41 +0800 Subject: [PATCH 329/455] translated --- ...o Automatically Purge Old Trashed Files.md | 142 ------------------ ...o Automatically Purge Old Trashed Files.md | 140 +++++++++++++++++ 2 files changed, 140 insertions(+), 142 deletions(-) delete mode 100644 sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md create mode 100644 translated/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md diff --git a/sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md b/sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md deleted file mode 100644 index a11675a264..0000000000 --- a/sources/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md +++ /dev/null @@ -1,142 +0,0 @@ -translating---geekpi - -Autotrash – A CLI Tool To Automatically Purge Old Trashed Files -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/autotrash-720x340.png) - -**Autotrash** is a command line utility to automatically purge old trashed files. It will purge files that have been in the trash for more then a given number of days. You don’t need to empty the trash folder or do SHIFT+DELETE to permanently purge the files/folders. Autortrash will handle the contents of your Trash folder and delete them automatically after a particular period of time. In a nutshell, Autotrash will never allow your trash to grow too big. - -### Installing Autotrash - -Autotrash is available in the default repositories of Debian-based systems. To install autotrash on Debian, Ubuntu, Linux Mint, run: - -``` -$ sudo apt-get install autotrash - -``` - -On Fedora: - -``` -$ sudo dnf install autotrash - -``` - -For Arch linux and its variants, you can install it using any AUR helper programs such as [**Yay**][1]. - -``` -$ yay -S autotrash-git - -``` - -### Automatically Purge Old Trashed Files - -Whenever you run autotrash, It will scan your **`~/.local/share/Trash/info`** directory and read the **`.trashinfo`** files to find their deletion date. If the files have been in trash folder for more than the defined date, they will be deleted. - -Let me show you some examples. - -To purge files which are in the trash folder for more than 30 days, run: - -``` -$ autotrash -d 30 - -``` - -As per above example, if the files in your Trash folder are more than 30-days old, Autotrash will automatically delete them from your Trash. You don’t need to manually delete them. Just send the unnecessary junk to your trash folder and forget about them. Autotrash will take care of the trashed files. - -The above command will only process currently logged-in user’s trash directory. If you want to make autotrash to process trash directories of all users (not just in your home directory), use **-t** option like below. - -``` -$ autotrash -td 30 - -``` - -Autotrash also allows you to delete trashed files based on the space left or available on the trash filesystem. - -For example, have a look at the following example. - -``` -$ autotrash --max-free 1024 -d 30 - -``` - -As per the above command, autotrash will only purge trashed files that are older than **30 days** from the trash if there is less than **1GB of space left** on the trash filesystem. This can be useful if your trash filesystem is running out of the space. - -We can also purge files from trash, oldest first, till there is at least 1GB of space on the trash filesystem. - -``` -$ autotrash --min-free 1024 - -``` - -In this case, there is no restriction on how old trashed files are. - -You can combine both options ( **`--min-free`** and **`--max-free`** ) in a single command like below. - -``` -$ autotrash --max-free 2048 --min-free 1024 -d 30 - -``` - -As per the above command, autotrash will start reading the trash if there is less than **2GB** of free space, then start keeping an eye on. At that point, remove files older than 30 days and if there is less than **1GB** of free space after that remove even newer files. - -As you can see, all command should be manually run by the user. You might wonder, how can I automate this task?? That’s easy! Just add autotrash as crontab entry. Now, the commands will automatically run at a scheduled time and purge the files in your trash depending on the defined options. - -To add these commands in crontab file, run: - -``` -$ crontab -e - -``` - -Add the entries, for example: - -``` -@daily /usr/bin/autotrash -d 30 - -``` - -Now autotrash will purge files which are in the trash folder for more than 30 days, everyday. - -For more details about scheduling tasks, refer the following links. - - -+ [A Beginners Guide To Cron Jobs][2] -+ [How To Easily And Safely Manage Cron Jobs In Linux][3] - - -Please be mindful that if you have deleted any important files inadvertently, they will be permanently gone after the defined days, so just be careful. - -Refer man pages to know more about Autotrash. - -``` -$ man autotrash - -``` - -Emptying Trash folder or pressing SHIFT+DELETE to permanently get rid of unnecessary stuffs from the Linux system is no big deal. It will just take a couple seconds. However, if you wanted an extra utility to take care of your junk files, Autotrash might be helpful. Give it a try and see how it works. - -And, that’s all for now. Hope this helps. More good stuffs to come. - -Cheers! - - - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/autotrash-a-cli-tool-to-automatically-purge-old-trashed-files/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/sk/ -[1]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ -[2]: https://www.ostechnix.com/a-beginners-guide-to-cron-jobs/ -[3]: https://www.ostechnix.com/how-to-easily-and-safely-manage-cron-jobs-in-linux/ diff --git a/translated/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md b/translated/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md new file mode 100644 index 0000000000..03d429fef3 --- /dev/null +++ b/translated/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md @@ -0,0 +1,140 @@ +Autotrash - 一个自动清除旧垃圾的命令行工具 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/autotrash-720x340.png) + +**Autotrash** 是一个命令行程序,它用于自动清除旧的已删除文件。它将清除超过指定天数的在回收站中的文件。你不需要清空回收站或执行 SHIFT+DELETE 以永久清除文件/文件夹。Autortrash 将处理回收站中的内容,并在特定时间段后自动删除它们。简而言之,Autotrash 永远不会让你的垃圾变得太大。 + +### 安装 Autotrash + +Autotrash 默认存在于基于 Debian 系统的仓库中。要在 Debian、Ubuntu、Linux Mint 上安装 autotrash,请运行: + +``` +$ sudo apt-get install autotrash + +``` + +在 Fedora 上: + +``` +$ sudo dnf install autotrash + +``` + +对于 Arch linux 及其变体,你可以使用任何 AUR 助手程序, 如 [**Yay**][1] 安装它。 + +``` +$ yay -S autotrash-git + +``` + +### 自动清除旧的垃圾文件 + +每当你运行 autotrash 时,它会扫描你的 **`~/.local/share/Trash/info`** 目录并读取 **`.trashinfo`** 以找出它们的删除日期。如果文件已在回收站中超过指定的日期,那么就会删除它们。 + +让我举几个例子。 + +要删除回收站中超过 30 天的文件,请运行: + +``` +$ autotrash -d 30 + +``` + +如上例所示,如果回收站中的文件超过 30 天,Autotrash 会自动将其从回收站中删除。你无需手动删除它们。只需将没用的文件放到回收站即可忘记。Autotrash 将处理已删除的文件。 + +以上命令仅处理当前登录用户的垃圾目录。如果要使 autotrash 处理所有用户的垃圾目录(不仅仅是在你的家目录中),请使用 **-t** 选项,如下所示。 + +``` +$ autotrash -td 30 + +``` + +Autotrash 还允许你根据回收站可用容量或磁盘可用空间来删除已删除的文件。 + +例如,看下下面的例子。 + +``` +$ autotrash --max-free 1024 -d 30 + +``` + +根据上面的命令,如果回收站的剩余的空间少于**1GB**,那么 autotrash 将从回收站中清除超过**30 天**的已删除文件。如果你的回收站空间不足,这可能很有用。 + +我们还可以从回收站中按最早的时间清除文件直到回收站至少有 1GB 的空间。 + +``` +$ autotrash --min-free 1024 + +``` + +在这种情况下,对旧的已删除文件没有限制。 + +你可以将这两个选项(**`--min-free`** 和 **`--max-free`**)组合在一个命令中,如下所示。 + +``` +$ autotrash --max-free 2048 --min-free 1024 -d 30 + +``` + +根据上面的命令,如果可用空间小于 **2GB**,autotrash 将读取回收站,接着关注容量。此时,删除超过 30 天的文件,如果少于 **1GB** 的可用空间,则删除更新的文件。 + +如你所见,所有命令都应由用户手动运行。你可能想知道,我该如何自动执行此任务?这很容易!只需将 autotrash 添加为 crontab 任务即可。现在,命令将在计划的时间自动运行,并根据定义的选项清除回收站中的文件。 + +要在 crontab 中添加这些命令,请运行: + +``` +$ crontab -e + +``` + +添加任务,例如: + +``` +@daily /usr/bin/autotrash -d 30 + +``` + +现在,autotrash 将每天清除回收站中超过 30 天的文件。 + +有关计划任务的更多详细信息,请参阅以下链接。 + + ++ [Cron 任务的初学者指南]][2] ++ [如何在 Linux 中轻松安全地管理 Cron 作业]][3] + + +请注意,如果你无意中删除了任何重要文件,它们将在规定的日期后永久消失,所以请小心。 + +请参阅手册页以了解有关 Autotrash 的更多信息。 + +``` +$ man autotrash + +``` + +清空回收站或按 SHIFT+DELETE 永久删除 Linux 系统中没用的东西没什么大不了的。它只需要几秒钟。但是,如果你需要额外的程序来处理垃圾文件,Autotrash 可能会有所帮助。试一下,看看它是如何工作的。 + +就是这些了。希望这个有用。还有更多的好东西。 + +干杯! + + + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/autotrash-a-cli-tool-to-automatically-purge-old-trashed-files/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ +[2]: https://www.ostechnix.com/a-beginners-guide-to-cron-jobs/ +[3]: https://www.ostechnix.com/how-to-easily-and-safely-manage-cron-jobs-in-linux/ From 7c43e9983aac69106bb3c4de966b724d993b50db Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 20 Sep 2018 09:06:39 +0800 Subject: [PATCH 330/455] translating --- ... To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md b/sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md index 0a9444acc4..f81d944570 100644 --- a/sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md +++ b/sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md @@ -1,3 +1,5 @@ +translating---geekpi + How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04 ====== From 20a0921cb754bd1f049d633b436b84cbaa178132 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 20 Sep 2018 09:49:39 +0800 Subject: [PATCH 331/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Linux=20Has=20a?= =?UTF-8?q?=20Code=20of=20Conduct=20and=20Not=20Everyone=20is=20Happy=20Wi?= =?UTF-8?q?th=20it?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...nduct and Not Everyone is Happy With it.md | 167 ++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 sources/talk/20180919 Linux Has a Code of Conduct and Not Everyone is Happy With it.md diff --git a/sources/talk/20180919 Linux Has a Code of Conduct and Not Everyone is Happy With it.md b/sources/talk/20180919 Linux Has a Code of Conduct and Not Everyone is Happy With it.md new file mode 100644 index 0000000000..e161ec4eec --- /dev/null +++ b/sources/talk/20180919 Linux Has a Code of Conduct and Not Everyone is Happy With it.md @@ -0,0 +1,167 @@ +Linux Has a Code of Conduct and Not Everyone is Happy With it +====== +**Linux kernel has a new code of conduct (CoC). Linus Torvalds took a break from Linux kernel development just 30 minutes after signing this code of conduct. And since **the writer of this code of conduct has had a controversial past,** it has now become a point of heated discussion. With all the politics involved, not many people are happy with this new CoC.** + +If you do not know already, [Linux creator Linus Torvalds has apologized for his past behavior and has taken a temporary break from Linux kernel development to improve his behavior][1]. + +### The new code of conduct for Linux kernel development + +Linux kernel developers have a code of conduct. It’s not like they didn’t have a code before, but the previous [code of conflict][2] is now replaced by this new code of conduct to “help make the kernel community a welcoming environment to participate in.” + +> “In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.” + +You can read the entire code of conduct on this commit page. + +[Linux Code of Conduct][33] + + +### Was Linus Torvalds forced to apologize and take a break? + +![Linus Torvalds Apologizes][3] + +The code of conduct was signed off by Linus Torvalds and Greg Kroah-Hartman (kind of second-in-command after Torvalds). Dan Williams of Intel and Chris Mason from Facebook were some of the other signees. + +If I have read through the timeline correctly, half an hour after signing this code of conduct, Torvalds sent a [mail apologizing for his past behavior][4]. He also announced taking a temporary break to improve upon his behavior. + +But at this point some people started reading between the lines, with a special attention to this line from his mail: + +> **This week people in our community confronted me about my lifetime of not understanding emotions**. My flippant attacks in emails have been both unprofessional and uncalled for. Especially at times when I made it personal. In my quest for a better patch, this made sense to me. I know now this was not OK and I am truly sorry. + +This particular line could be read as if he was coerced into apologizing and taking a break because of the new code of conduct. Though it could also be a precautionary measure to prevent Torvalds from violating the newly created code of conduct. + +### The controversy around Contributor Convent creator Coraline Ada Ehmke + +The Linux code of conduct is based on the [Contributor Covenant, version 1.4][5]. Contributor Convent has been adopted by hundreds of open source projects. Eclipse, Angular, Ruby, Kubernetes are some of the [many adopters of Contributor Convent][6]. + +Contributor Covenant has been created by [Coraline Ada Ehmke][7], a software developer, an open-source advocate, and an [LGBT][8] activist. She has been instrumental in promoting diversity in the open source world. + +Coraline has also been vocal about her stance against [meritocracy][9]. The Latin word meritocracy originally refers to a “system under which advancement within the system turns on “merits”, like intelligence, credentials, and education.” But activists like [Coraline believe][10] that meritocracy is a negative system where the worth of an individual is measured not by their humanity, but solely by their intellectual output. + +[![croraline meritocracy][11]][12] +Image credit: Twitter user @nickmon1112 + +Remember that [Linus Torvalds has repeatedly said that he cares about the code, not the person who writes it][13]. Clearly, this goes against Coraline’s view on meritocracy. + +Coraline has had a troubled incident in the past with a contributor of [Opal project][14]. There was a [discussion taking place on Twitter][15] where Elia, a core contributor to Opal project from Italy, said “(trans people) not accepting reality is the problem here”. + +Coraline was neither in the discussion nor was she a contributor to the Opal project. But as an LGBT activist, she took it to herself and [demanded that Elia be removed from the Opal Project][16] for his ‘views against trans people’. A lengthy and heated discussion took place on Opal’s GitHub repository. Coraline and her supporters, who never contributed to Opal, tried to coerce the moderators into removing Elia, a core contributor of the project. + +While Elia wasn’t removed from the project, Opal project maintainers agreed to put up a code of conduct in place. And this code of conduct was nothing else but Coraline’s famed Contributor Covenant that she had pitched to the maintainers herself. + +But the story didn’t end here. The Contributor Covenant was then modified and a [new clause added in order to get to Elia][17]. The new clause widened the scope of conduct in public spaces. This malicious change was [spotted by the maintainers][18] and they edited the clause. Opal eventually got rid of the Contributor Covenant and put in place its own guideline. + +This is a classic example of how a few offended people, who never contributed a single line of code to the project, tried to oust its core contributor. + +### People’s reaction on Linux Code of Conduct and Torvalds’ apology + +As soon as Linux code of conduct and Torvalds’ apology went public, Social Media and forums were rife with rumors and [speculations][19]. While many people appreciated this new development, there were some who saw a conspiracy by [SJW infiltrating Linux][20]. + +A sarcastic tweet by Caroline only fueled the fire. + +> I can’t wait for the mass exodus from Linux now that it’s been infiltrated by SJWs. Hahahah [pic.twitter.com/eFeY6r4ENv][21] +> +> — Coraline Ada Ehmke (@CoralineAda) [September 16, 2018][22] + +In the wake of the Linux CoC controversy, Coraline openly said that the Contributor Convent code of conduct is a political document. This did not go down well with the people who want the political stuff out of the open source projects. + +> Some people are saying that the Contributor Covenant is a political document, and they’re right. +> +> — Coraline Ada Ehmke (@CoralineAda) [September 16, 2018][23] + +Nick Monroe, a freelance journalist, dig up the past of Coraline in order to validate his claim that there is more to Linux CoC than meets the eye. You can go by the entire thread if you want. + +> Alright. You've seen this a million times before. It's a code of conduct blah blah blah +> +> that has social justice baked right into it. blah blah blah. +> +> But something is different about this. [pic.twitter.com/8NUL2K1gu2][24] +> +> — Nick Monroe (@nickmon1112) [September 17, 2018][25] + +Nick wasn’t the only one to disapprove of the new Linux CoC. The [SJW][26] involvement led to more skepticism. + +> I guess the big news in Linux today is that the Linux kernel is now governed by a Code of Conduct and a “post meritocracy” world view. +> +> In principle these CoCs look great. In practice they are abused tools to hunt people SJWs don’t like. And they don’t like a lot of people. +> +> — Mark Kern (@Grummz) [September 17, 2018][27] + +While there were many who appreciated Torvalds’ apology, there were a few who blamed Torvalds’ attitude: + +> Am I the only one who thinks Linus Torvalds attitude for decades was a prime contributors to how many of the condescending, rudes, jerks in Linux and open source "communities" behaved? I've never once felt welcomed into the Linux community as a new user. +> +> — Jonathan Frappier (@jfrappier) [September 17, 2018][28] + +And some were simply not amused with his apology: + +> Oh look, an abusive OSS maintainer finally admitted, after *decades* of abusive and toxic behavior, that his behavior *might* be an issue. +> +> And a bunch of people I follow are tripping all over themselves to give him cookies for that. 🙄🙄🙄 +> +> — Kelly Ellis (@justkelly_ok) [September 17, 2018][29] + +The entire Torvalds apology episode has raised a genuine concern ;) + +> Do we have to put "I don't/do forgive Linus Torvalds" in our bio now? +> +> — Verónica. (@maria_fibonacci) [September 17, 2018][30] + +Jokes apart, the genuine concern was raised by Sharp, who had [quit Linux Kernel development][31] in 2015 due to the ‘toxic community’. + +> The real test here is whether the community that built Linus up and protected his right to be verbally abusive will change. Linus not only needs to change himself, but the Linux kernel community needs to change as well. +> +> — Sage Sharp (@_sagesharp_) [September 17, 2018][32] + +### What do you think of Linux Code of Conduct? + +If you ask my opinion, I do think that a Code of Conduct is the need of the time. It guides people in behaving in a respectable way and helps create a positive environment for all kind of people irrespective of their race, ethnicity, religion, nationality and political views (both left and right). + +What are your views on the entire episode? Do you think the CoC will help Linux kernel development? Or will it deteriorate with the involvement of anti-meritocracy SJWs? + +We don’t have a code of conduct at It’s FOSS but let’s keep the discussion civil :) + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-code-of-conduct/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[1]: https://itsfoss.com/torvalds-takes-a-break-from-linux/ +[2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/CodeOfConflict?id=ddbd2b7ad99a418c60397901a0f3c997d030c65e +[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linus-torvalds-apologizes.jpeg +[4]: https://lkml.org/lkml/2018/9/16/167 +[5]: https://www.contributor-covenant.org/version/1/4/code-of-conduct.html +[6]: https://www.contributor-covenant.org/adopters +[7]: https://en.wikipedia.org/wiki/Coraline_Ada_Ehmke +[8]: https://en.wikipedia.org/wiki/LGBT +[9]: https://en.wikipedia.org/wiki/Meritocracy +[10]: https://modelviewculture.com/pieces/the-dehumanizing-myth-of-the-meritocracy +[11]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/croraline-meritocracy.jpg +[12]: https://pbs.twimg.com/media/DnTTfi7XoAAdk08.jpg +[13]: https://arstechnica.com/information-technology/2015/01/linus-torvalds-on-why-he-isnt-nice-i-dont-care-about-you/ +[14]: https://opalrb.com/ +[15]: https://twitter.com/krainboltgreene/status/611569515315507200 +[16]: https://github.com/opal/opal/issues/941 +[17]: https://github.com/opal/opal/pull/948/commits/817321e27eccfffb3841f663815c17eecb8ef061#diff-a1ee87dafebc22cbd96979f1b2b7e837R11 +[18]: https://github.com/opal/opal/pull/948#issuecomment-113486020 +[19]: https://www.reddit.com/r/linux/comments/9go8cp/linus_torvalds_daughter_has_signed_the/ +[20]: https://snew.github.io/r/linux/comments/9ghrrj/linuxs_new_coc_is_a_piece_of_shit/ +[21]: https://t.co/eFeY6r4ENv +[22]: https://twitter.com/CoralineAda/status/1041441155874009093?ref_src=twsrc%5Etfw +[23]: https://twitter.com/CoralineAda/status/1041465346656530432?ref_src=twsrc%5Etfw +[24]: https://t.co/8NUL2K1gu2 +[25]: https://twitter.com/nickmon1112/status/1041668315947708416?ref_src=twsrc%5Etfw +[26]: https://www.urbandictionary.com/define.php?term=SJW +[27]: https://twitter.com/Grummz/status/1041524170331287552?ref_src=twsrc%5Etfw +[28]: https://twitter.com/jfrappier/status/1041486055038492674?ref_src=twsrc%5Etfw +[29]: https://twitter.com/justkelly_ok/status/1041522269002985473?ref_src=twsrc%5Etfw +[30]: https://twitter.com/maria_fibonacci/status/1041538148121997313?ref_src=twsrc%5Etfw +[31]: https://www.networkworld.com/article/2988850/opensource-subnet/linux-kernel-dev-sarah-sharp-quits-citing-brutal-communications-style.html +[32]: https://twitter.com/_sagesharp_/status/1041480963287539712?ref_src=twsrc%5Etfw +[33]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8a104f8b5867c682d994ffa7a74093c54469c11f From baa133ff415e40d0f42527e50ff6a3635427308d Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 20 Sep 2018 09:54:55 +0800 Subject: [PATCH 332/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Streama=20?= =?UTF-8?q?=E2=80=93=20Setup=20Your=20Own=20Streaming=20Media=20Server=20I?= =?UTF-8?q?n=20Minutes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...r Own Streaming Media Server In Minutes.md | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 sources/tech/20180919 Streama - Setup Your Own Streaming Media Server In Minutes.md diff --git a/sources/tech/20180919 Streama - Setup Your Own Streaming Media Server In Minutes.md b/sources/tech/20180919 Streama - Setup Your Own Streaming Media Server In Minutes.md new file mode 100644 index 0000000000..521a8f5b95 --- /dev/null +++ b/sources/tech/20180919 Streama - Setup Your Own Streaming Media Server In Minutes.md @@ -0,0 +1,171 @@ +Streama – Setup Your Own Streaming Media Server In Minutes +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/streama-720x340.png) + +**Streama** is a free, open source application that helps to setup your own personal streaming media server in minutes in Unix-like operating systems. It’s like Netflix, but self-hostable. You can deploy it on your local system or VPS or dedicated server and stream the media files across multiple devices. The media files can be accessed from a web-browser from any system on your network. If you have deployed on your VPS, you can access it from anywhere. Streama works like your own personal Netflix system to stream your TV shows, videos, audios and movies. Streama is a web-based application written using Grails 3 (server-side) with SpringSecurity and all frond-end components are written in AngularJS. The built-in player is completely HTML5-based. + +### Prominent Features + +Streama ships with a lot features as listed below. + + * Easy to install configure. You can either download docker instance and fire up your media server in minutes or install vanilla version on your local or VPS or dedicated server. + * Drag and drop support to upload media files. + * Live sync watching support. You can watch videos with your friends, family remotely. It doesn’t matter where they are. You can all watch the same video at a time. + * Built-in beautiful video player to watch/listen video and audio. + * Built-in browser to access the media files in the server. + * Multi-user support. You can create individual user accounts to your family members and access the media server simultaneously. + * Streama supports pause-play option. Pause the playback at any time and Streama remembers where you left off last time. + * Streama can be able to detect similar movies and videos and shows for you to add. + * Self-hostable + * It is completely free and open source. + + + +What do you need more? Streama has everything you to need to setup a full-fledged streaming media server in your Linux box. + +### Setup Your Own Streaming Media Server Using Streama + +Streama requires JAVA 8 or later, preferably **OpenJDK**. And, the recommended OS is **Ubuntu**. For the purpose of this guide, I will be using Ubuntu 18.04 LTS. + +By default, the latest Ubuntu 18.04 includes Open JDK 11. To install default openJDK in Ubuntu 18.04 or later, run: + +``` +$ sudo apt install default-jdk + +``` + +Java 8 is the latest stable Long Time Support version. If you prefer to use Java LTS, run: + +``` +$ sudo apt install openjdk-8-jdk +``` + +I have installed openjdk-8-jdk. To check the installed Java version, run: + +``` +$ java -version +openjdk version "1.8.0_181" +OpenJDK Runtime Environment (build 1.8.0_181-8u181-b13-0ubuntu0.18.04.1-b13) +OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode) +``` + +Once java installed, create a directory to save Streama executable and yml files. + +``` +$ sudo mkdir /data + +$ sudo mkdir /data/streama +``` + +I followed the official documentation, so I used this path – /data/streama. It is optional. You’re free to use any location of your choice. + +Switch to streama directory: + +``` +$ cd /data/streama +``` + +Download the latest Streama executable file from [**releases page**][1]. As of writing this guide, the latest version was **v1.6.0-RC8**. + +``` +$ sudo wget https://github.com/streamaserver/streama/releases/download/v1.6.0-RC8/streama-1.6.0-RC8.war +``` + +Make it executable: + +``` +$ sudo chmod +x streama-1.6.0-RC8.war +``` + +Now, run Streama application using command: + +``` +$ sudo ./streama-1.6.0-RC8.war +``` + +If you an output something like below, Streama is working! + +``` +INFO streama.Application - Starting Application on ubuntuserver with PID 26714 (/data/streama/streama-1.6.0-RC8.war started by root in /data/streama) +DEBUG streama.Application - Running with Spring Boot v1.4.4.RELEASE, Spring v4.3.6.RELEASE +INFO streama.Application - The following profiles are active: production + +Configuring Spring Security Core ... +... finished configuring Spring Security Core + +INFO streama.Application - Started Application in 92.003 seconds (JVM running for 98.66) +Grails application running at http://localhost:8080 in environment: production +``` + +Open your web browser and navigate to URL – **** + +You should see Streama login screen. Login with default credentials – **admin/admin** + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/streama-login-page.png) + +Now, You need to fill out some required base-settings. Click OK button in the next screen and you will be redirected to the settings page. In the Settings page, you need to set some parameters such as the location of the Uploads directory, Streama logo, name of the media server, base URL, allow anonymous access, allow users to download videos. All fields marked with ***** is necessary to fill. Once you provided the details, click **Save settings** button. + +![](http://www.ostechnix.com/wp-content/uploads/2018/09/streama-settings.png) + +Congratulations! Your media server is ready to use! + +Here is how Stream dashboard looks like. + +![](http://www.ostechnix.com/wp-content/uploads/2018/09/Streama-dashboard.png) + +And, this is the contents management page where you can upload movies, shows, access files via file manager, view the notifications and highlights. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Manage-contents-in-Streama.png) + +### Adding movies/shows + +Let me show you how to add a movie. + +Go to the **“Manage Content”** page from the dashboard and click **“Create New Movie”** link. + +Enter the movie details, such as name, release date, IMDB ID and movie description and click **Save**. These are all optional, you can simply ignore them if you don’t know about the details. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Add-movie-in-Streama-1.png) + +We have added the movie details, but we haven’t added the actual movie yet. To do so, click on the red box in the bottom that says – **“No video file yet! Drop file or Click here to add”**. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Add-movie-in-Streama-2.png) + +You could either drag and drop the movie file inside this dashboard or click on the red box to manually upload it. + +Choose the movie file to upload and click Upload. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Add-movie-in-Streama-3.png) + +Once the upload is completed, you could see the uploaded movie details. Click on the three horizontal lines next to the movie if you want to edit/modify movie details. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Add-movie-in-Streama-4.png) + +Similarly, you can create TV shows, videos and audios. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Add-movie-in-Streama-5.png) + +And also the movies/shows are started to appear in the home screen of your dashboard. Simply click on it to play the video and enjoy Netflix experience right from your Linux desktop. + +For more details, refer the product’s official website. + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/streama-setup-your-own-streaming-media-server-in-minutes/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://github.com/streamaserver/streama/releases From 94331d9d05eb8ecab59b98e9fa4fcd31ab5cb940 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 20 Sep 2018 09:56:28 +0800 Subject: [PATCH 333/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Understand=20Fedo?= =?UTF-8?q?ra=20memory=20usage=20with=20top?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Understand Fedora memory usage with top.md | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 sources/tech/20180919 Understand Fedora memory usage with top.md diff --git a/sources/tech/20180919 Understand Fedora memory usage with top.md b/sources/tech/20180919 Understand Fedora memory usage with top.md new file mode 100644 index 0000000000..591cbcba00 --- /dev/null +++ b/sources/tech/20180919 Understand Fedora memory usage with top.md @@ -0,0 +1,60 @@ +Understand Fedora memory usage with top +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/09/memory-top-816x345.jpg) + +Have you used the top utility in a terminal to see memory usage on your Fedora system? If so, you might be surprised to see some of the numbers there. It might look like a lot more memory is consumed than your system has available. This article will explain a little more about memory usage, and how to read these numbers. + +### Memory usage in real terms + +The way the operating system (OS) uses memory may not be self-evident. In fact, some ingenious, behind-the-scenes techniques are at play. They help your OS use memory more efficiently, without involving you. + +Most applications are not self contained. Instead, each relies on sets of functions collected in libraries. These libraries are also installed on the system. In Fedora, the RPM packaging system ensures that when you install an app, any libraries on which it relies are installed, too. + +When an app runs, the OS doesn’t necessarily load all the information it uses into real memory. Instead, it builds a map to the storage where that code is stored, called virtual memory. The OS then loads only the parts it needs. When it no longer needs portions of memory, it might release or swap them out as appropriate. + +This means an app can map a very large amount of virtual memory, while using less real memory on the system at one time. It might even map more RAM than the system has available! In fact, across a whole OS that’s often the case. + +In addition, related applications may rely on the same libraries. The Linux kernel in your Fedora system often shares memory between applications. It doesn’t need to load multiple copies of the same library for related apps. This works similarly for separate instances of the same app, too. + +Without understanding these details, the output of the top application can be confusing. The following example will clarify this view into memory usage. + +### Viewing memory usage in top + +If you haven’t tried yet, open a terminal and run the top command to see some output. Hit **Shift+M** to see the list sorted by memory usage. Your display may look slightly different than this example from a running Fedora Workstation: + + + +There are three columns showing memory usage to examine: VIRT, RES, and SHR. The measurements are currently shown in kilobytes (KB). + +The VIRT column is the virtual memory mapped for this process. Recall from the earlier description that virtual memory is not actual RAM consumed. For example, the GNOME Shell process gnome-shell is not actually consuming over 3.1 gigabytes of actual RAM. However, it’s built on a number of lower and higher level libraries. The system must map each of those to ensure they can be loaded when necessary. + +The RES column shows you how much actual (resident) memory is consumed by the app. In the case of GNOME Shell, that’s about 180788 KB. The example system has roughly 7704 MB of physical memory, which is why the memory usage shows up as 2.3%. + +However, of that number, at least 88212 KB is shared memory, shown in the SHR column. This memory might be, for example, library functions that other apps also use. This means the GNOME Shell is using about 92 MB on its own not shared with other processes. Notice that other apps in the example share an even higher percentage of their resident memory. In some apps, the shared portion is the vast majority of the memory usage. + +There is a wrinkle here, which is that sometimes processes communicate with each other via memory. That memory is also shared, but can’t necessarily be detected by a utility like top. So yes — even the above clarifications still have some uncertainty! + +### A note about swap + +Your system has another facility it uses to store information, which is swap. Typically this is an area of slower storage (like a hard disk). If the physical memory on the system fills up as needs increase, the OS looks for portions of memory that haven’t been needed in a while. It writes them out to the swap area, where they sit until needed later. + +Therefore, prolonged, high swap usage usually means a system is suffering from too little memory for its demands. Sometimes an errant application may be at fault. Or, if you see this often on your system, consider upgrading your machine’s memory, or restricting what you run. + +Photo courtesy of [Stig Nygaard][1], via [Flickr][2] (CC BY 2.0). + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/understand-fedora-memory-usage-top/ + +作者:[Paul W. Frields][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[1]: https://www.flickr.com/photos/stignygaard/ +[2]: https://www.flickr.com/photos/stignygaard/3138001676/ From 2b0d1e101645ad858b5e2d7fe7ed81f8b473892a Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 20 Sep 2018 09:58:36 +0800 Subject: [PATCH 334/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20Writing=20C?= =?UTF-8?q?an=20Expand=20Your=20Skills=20and=20Grow=20Your=20Career?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Expand Your Skills and Grow Your Career.md | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sources/talk/20180919 How Writing Can Expand Your Skills and Grow Your Career.md diff --git a/sources/talk/20180919 How Writing Can Expand Your Skills and Grow Your Career.md b/sources/talk/20180919 How Writing Can Expand Your Skills and Grow Your Career.md new file mode 100644 index 0000000000..a862920028 --- /dev/null +++ b/sources/talk/20180919 How Writing Can Expand Your Skills and Grow Your Career.md @@ -0,0 +1,46 @@ +How Writing Can Expand Your Skills and Grow Your Career +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/graffiti-1281310_1920.jpg?itok=RCayfGKv) + +At the recent [Open Source Summit in Vancouver][1], I participated in a panel discussion called [How Writing can Change Your Career for the Better (Even if You don't Identify as a Writer][2]. The panel was moderated by Rikki Endsley, Community Manager and Editor for Opensource.com, and it included VM (Vicky) Brasseur, Open Source Strategy Consultant; Alex Williams, Founder, Editor in Chief, The New Stack; and Dawn Foster, Consultant, The Scale Factory. + +The talk was [inspired by this article][3], in which Rikki examined some ways that writing can "spark joy" and improve your career in unexpected ways. Full disclosure: I have known Rikki for a long time. We worked at the same company for many years, raised our children together, and remain close friends. + +### Write and learn + +As Rikki noted in the talk description, “even if you don't consider yourself to be ‘a writer,’ you should consider writing about your open source contributions, project, or community.” Writing can be a great way to share knowledge and engage others in your work, but it has personal benefits as well. It can help you meet new people, learn new skills, and improve your communication style. + +I find that writing often clarifies for me what I don’t know about a particular topic. The process highlights gaps in my understanding and motivates me to fill in those gaps through further research, reading, and asking questions. + +“Writing about what you don't know can be much harder and more time consuming, but also much more fulfilling and help your career. I've found that writing about what I don't know helps me learn, because I have to research it and understand it well enough to explain it,” Rikki said. + +Writing about what you’ve just learned can be valuable to other learners as well. In her blog, [Julia Evans][4] often writes about learning new technical skills. She has a friendly, approachable style along with the ability to break down topics into bite-sized pieces. In her posts, Evans takes readers through her learning process, identifying what was and was not helpful to her along the way, essentially removing obstacles for her readers and clearing a path for those new to the topic. + +### Communicate more clearly + +Writing can help you practice thinking and speaking more precisely, especially if you’re writing (or speaking) for an international audience. [In this article,][5] for example, Isabel Drost-Fromm provides tips for removing ambiguity for non-native English speakers. Writing can also help you organize your thoughts before a presentation, whether you’re speaking at a conference or to your team. + +“The process of writing the articles helps me organize my talks and slides, and it was a great way to provide ‘notes’ for conference attendees, while sharing the topic with a larger international audience that wasn't at the event in person,” Rikki stated. + +If you’re interested in writing, I encourage you to do it. I highly recommend the articles mentioned here as a way to get started thinking about the story you have to tell. Unfortunately, our discussion at Open Source Summit was not recorded, but I hope we can do another talk in the future and share more ideas. + +Check out the schedule of talks for Open Source Summit Europe and sign up to receive updates: + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/2018/9/how-writing-can-help-you-learn-new-skills-and-grow-your-career + +作者:[Amber Ankerholz][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/aankerholz +[1]: https://events.linuxfoundation.org/events/open-source-summit-north-america-2018/ +[2]: https://ossna18.sched.com/event/FAOF/panel-discussion-how-writing-can-change-your-career-for-the-better-even-if-you-dont-identify-as-a-writer-moderated-by-rikki-endsley-opensourcecom-red-hat?iframe=no# +[3]: https://opensource.com/article/18/2/career-changing-magic-writing +[4]: https://jvns.ca/ +[5]: https://www.linux.com/blog/event/open-source-summit-eu/2017/12/technical-writing-international-audience From 5a50efceafc14e90d1d0346909aaf428b927616e Mon Sep 17 00:00:00 2001 From: HankChow <280630620@qq.com> Date: Thu, 20 Sep 2018 12:16:09 +0800 Subject: [PATCH 335/455] HankChow translating --- .../tech/20180919 Understand Fedora memory usage with top.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180919 Understand Fedora memory usage with top.md b/sources/tech/20180919 Understand Fedora memory usage with top.md index 591cbcba00..ef72988469 100644 --- a/sources/tech/20180919 Understand Fedora memory usage with top.md +++ b/sources/tech/20180919 Understand Fedora memory usage with top.md @@ -1,3 +1,5 @@ +HankChow translating + Understand Fedora memory usage with top ====== From 32b77557cd49fa3f76f9c2a82988ba78ceb1019c Mon Sep 17 00:00:00 2001 From: Lv Feng Date: Thu, 20 Sep 2018 15:06:04 +0800 Subject: [PATCH 336/455] translated (#10281) --- ...Top 3 Python libraries for data science.md | 244 ----------------- ...Top 3 Python libraries for data science.md | 246 ++++++++++++++++++ 2 files changed, 246 insertions(+), 244 deletions(-) delete mode 100644 sources/tech/20180918 Top 3 Python libraries for data science.md create mode 100644 translated/tech/20180918 Top 3 Python libraries for data science.md diff --git a/sources/tech/20180918 Top 3 Python libraries for data science.md b/sources/tech/20180918 Top 3 Python libraries for data science.md deleted file mode 100644 index 2c4b88595d..0000000000 --- a/sources/tech/20180918 Top 3 Python libraries for data science.md +++ /dev/null @@ -1,244 +0,0 @@ -ucasFL translating - -Top 3 Python libraries for data science -====== -Turn Python into a scientific data analysis and modeling tool with these libraries. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr) - -Python's many attractions—such as efficiency, code readability, and speed—have made it the go-to programming language for data science enthusiasts. Python is usually the preferred choice for data scientists and machine learning experts who want to escalate the functionalities of their applications. (For example, Andrey Bulezyuk used the Python programming language to create an amazing [machine learning application][1].) - -Because of its extensive usage, Python has a huge number of libraries that make it easier for data scientists to complete complicated tasks without many coding hassles. Here are the top 3 Python libraries for data science; check them out if you want to kickstart your career in the field. - -### 1\. NumPy - -[NumPy][2] (short for Numerical Python) is one of the top libraries equipped with useful resources to help data scientists turn Python into a powerful scientific analysis and modelling tool. The popular open source library is available under the BSD license. It is the foundational Python library for performing tasks in scientific computing. NumPy is part of a bigger Python-based ecosystem of open source tools called SciPy. - -The library empowers Python with substantial data structures for effortlessly performing multi-dimensional arrays and matrices calculations. Besides its uses in solving linear algebra equations and other mathematical calculations, NumPy is also used as a versatile multi-dimensional container for different types of generic data. - -Furthermore, it integrates flawlessly with other programming languages like C/C++ and Fortran. The versatility of the NumPy library allows it to easily and swiftly coalesce with an extensive range of databases and tools. For example, let's see how NumPy (abbreviated **np** ) can be used for multiplying two matrices. - -Let's start by importing the library (we'll be using the Jupyter notebook for these examples). - -``` -import numpy as np -``` - -Next, let's use the **eye()** function to generate an identity matrix with the stipulated dimensions. - -``` -matrix_one = np.eye(3) -matrix_one -``` - -Here is the output: - -``` -array([[1., 0., 0.], -       [0., 1., 0.], -       [0., 0., 1.]]) -``` - -Let's generate another 3x3 matrix. - -We'll use the **arange([starting number], [stopping number])** function to arrange numbers. Note that the first parameter in the function is the initial number to be listed and the last number is not included in the generated results. - -Also, the **reshape()** function is applied to modify the dimensions of the originally generated matrix into the desired dimension. For the matrices to be "multiply-able," they should be of the same dimension. - -``` -matrix_two = np.arange(1,10).reshape(3,3) -matrix_two -``` - -Here is the output: - -``` -array([[1, 2, 3], -       [4, 5, 6], -       [7, 8, 9]]) -``` - -Let's use the **dot()** function to multiply the two matrices. - -``` -matrix_multiply = np.dot(matrix_one, matrix_two) - -matrix_multiply - -``` - -Here is the output: - -``` -array([[1., 2., 3.], -       [4., 5., 6.], -       [7., 8., 9.]]) -``` - -Great! - -We managed to multiply two matrices without using vanilla Python. - -Here is the entire code for this example: - -``` -import numpy as np -#generating a 3 by 3 identity matrix -matrix_one = np.eye(3) -matrix_one -#generating another 3 by 3 matrix for multiplication -matrix_two = np.arange(1,10).reshape(3,3) -matrix_two -#multiplying the two arrays -matrix_multiply = np.dot(matrix_one, matrix_two) -matrix_multiply -``` - -### 2\. Pandas - -[Pandas][3] is another great library that can enhance your Python skills for data science. Just like NumPy, it belongs to the family of SciPy open source software and is available under the BSD free software license. - -Pandas offers versatile and powerful tools for munging data structures and performing extensive data analysis. The library works well with incomplete, unstructured, and unordered real-world data—and comes with tools for shaping, aggregating, analyzing, and visualizing datasets. - -There are three types of data structures in this library: - - * Series: single-dimensional, homogeneous array - * DataFrame: two-dimensional with heterogeneously typed columns - * Panel: three-dimensional, size-mutable array - - - -For example, let's see how the Panda Python library (abbreviated **pd** ) can be used for performing some descriptive statistical calculations. - -Let's start by importing the library. - -``` -import pandas as pd -``` - -Let's create a dictionary of series. - -``` -d = {'Name':pd.Series(['Alfrick','Michael','Wendy','Paul','Dusan','George','Andreas', -   'Irene','Sagar','Simon','James','Rose']), -   'Years of Experience':pd.Series([5,9,1,4,3,4,7,9,6,8,3,1]), -   'Programming Language':pd.Series(['Python','JavaScript','PHP','C++','Java','Scala','React','Ruby','Angular','PHP','Python','JavaScript']) -    } -``` - -Let's create a DataFrame. - -``` -df = pd.DataFrame(d) -``` - -Here is a nice table of the output: - -``` -      Name Programming Language  Years of Experience -0   Alfrick               Python                    5 -1   Michael           JavaScript                    9 -2     Wendy                  PHP                    1 -3      Paul                  C++                    4 -4     Dusan                 Java                    3 -5    George                Scala                    4 -6   Andreas                React                    7 -7     Irene                 Ruby                    9 -8     Sagar              Angular                    6 -9     Simon                  PHP                    8 -10    James               Python                    3 -11     Rose           JavaScript                    1 -``` - -Here is the entire code for this example: - -``` -import pandas as pd -#creating a dictionary of series -d = {'Name':pd.Series(['Alfrick','Michael','Wendy','Paul','Dusan','George','Andreas', -   'Irene','Sagar','Simon','James','Rose']), -   'Years of Experience':pd.Series([5,9,1,4,3,4,7,9,6,8,3,1]), -   'Programming Language':pd.Series(['Python','JavaScript','PHP','C++','Java','Scala','React','Ruby','Angular','PHP','Python','JavaScript']) -    } - -#Create a DataFrame -df = pd.DataFrame(d) -print(df) -``` - -### 3\. Matplotlib - -[Matplotlib][4] is also part of the SciPy core packages and offered under the BSD license. It is a popular Python scientific library used for producing simple and powerful visualizations. You can use the Python framework for data science for generating creative graphs, charts, histograms, and other shapes and figures—without worrying about writing many lines of code. For example, let's see how the Matplotlib library can be used to create a simple bar chart. - -Let's start by importing the library. - -``` -from matplotlib import pyplot as plt -``` - -Let's generate values for both the x-axis and the y-axis. - -``` -x = [2, 4, 6, 8, 10] -y = [10, 11, 6, 7, 4] -``` - -Let's call the function for plotting the bar chart. - -``` -plt.bar(x,y) -``` - -Let's show the plot. - -``` -plt.show() -``` - -Here is the bar chart: - -![](https://opensource.com/sites/default/files/uploads/matplotlib_barchart.png) - -Here is the entire code for this example: - -``` -#importing Matplotlib Python library -from matplotlib import pyplot as plt -#same as import matplotlib.pyplot as plt -  -#generating values for x-axis -x = [2, 4, 6, 8, 10] -  -#generating vaues for y-axis -y = [10, 11, 6, 7, 4] -  -#calling function for plotting the bar chart -plt.bar(x,y) -  -#showing the plot -plt.show() -``` - -### Wrapping up - -The Python programming language has always done a good job in data crunching and preparation, but less so for complicated scientific data analysis and modeling. The top Python frameworks for [data science][5] help fill this gap, allowing you to carry out complex mathematical computations and create sophisticated models that make sense of your data. - -Which other Python data-mining libraries do you know? What's your experience with them? Please share your comments below. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/top-3-python-libraries-data-science - -作者:[Dr.Michael J.Garbade][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/drmjg -[1]: https://www.liveedu.tv/andreybu/REaxr-machine-learning-model-python-sklearn-kera/oPGdP-machine-learning-model-python-sklearn-kera/ -[2]: http://www.numpy.org/ -[3]: http://pandas.pydata.org/ -[4]: https://matplotlib.org/ -[5]: https://www.liveedu.tv/guides/data-science/ diff --git a/translated/tech/20180918 Top 3 Python libraries for data science.md b/translated/tech/20180918 Top 3 Python libraries for data science.md new file mode 100644 index 0000000000..4026b751d5 --- /dev/null +++ b/translated/tech/20180918 Top 3 Python libraries for data science.md @@ -0,0 +1,246 @@ +3 个用于数据科学的顶级 Python 库 +====== + +>使用这些库把 Python 变成一个科学数据分析和建模工具。 + +![][7] + +Python 的许多特性,比如开发效率、代码可读性、速度等使之成为了数据科学爱好者的首选编程语言。对于想要升级应用程序功能的数据科学家和机器学习专家来说,Python 通常是最好的选择(比如,Andrey Bulezyuk 使用 Python 语言创造了一个优秀的[机器学习应用程序][1])。 + +由于 Python 的广泛使用,因此它拥有大量的库,使得数据科学家能够很容易地完成复杂的任务,而且不会遇到许多编码困难。下面列出 3 个用于数据科学的顶级 Python 库。如果你想在数据科学这一领域开始你的职业生涯,就去了解一下它们吧。 + +### NumPy + +[NumPy][2](数值 Python 的简称)是其中一个顶级数据科学库,它拥有许多有用的资源,从而帮助数据科学家把 Python 变成一个强大的科学分析和建模工具。NumPy 是在 BSD 许可证的许可下开源的,它是在科学计算中执行任务的基础 Python 库。SciPy 是一个更大的基于 Python 生态系统的开源工具,而 NumPy 是 SciPy 非常重要的一部分。 + +NumPy 为 Python 提供了大量数据结构,从而能够轻松地执行多维数组和矩阵运算。除了用于求解线性代数方程和其它数学计算之外,NumPy 还可以用做不同类型通用数据的多维容器。 + +此外,NumPy 还可以和其他编程语言无缝集成,比如 C/C++ 和 Fortran。NumPy 的多功能性使得它可以简单而快速地与大量数据库和工具结合。比如,让我们来看一下如何使用 NumPy(缩写成 `np`)来实现两个矩阵的乘法运算。 + +我们首先导入 NumPy 库(在这些例子中,我将使用 Jupyter notebook): + +``` +import numpy as np +``` + +接下来,使用 `eye()` 函数来生成指定维数的单位矩阵: + +``` +matrix_one = np.eye(3) +matrix_one +``` + +输出如下: + +``` +array([[1., 0., 0.], +       [0., 1., 0.], +       [0., 0., 1.]]) +``` + +让我们生成另一个 3x3 矩阵。 + +我们使用 `arange([starting number], [stopping number])` 函数来排列数字。注意,函数中的第一个参数是需要列出的初始数字,而后一个数字不包含在生成的结果中。 + +另外,使用 `reshape()` 函数把原始生成的矩阵的维度改成我们需要的维度。为了使两个矩阵“可乘”,它们需要有相同的维度。 + +``` +matrix_two = np.arange(1,10).reshape(3,3) +matrix_two +``` + +Here is the output: +输出如下: + +``` +array([[1, 2, 3], +       [4, 5, 6], +       [7, 8, 9]]) +``` + +接下来,使用 `dot()` 函数将两个矩阵相乘。 + +``` +matrix_multiply = np.dot(matrix_one, matrix_two) + +matrix_multiply + +``` + +相乘后的输出如下: + +``` +array([[1., 2., 3.], +       [4., 5., 6.], +       [7., 8., 9.]]) +``` + +太好了! + +我们成功使用 NumPy 完成了两个矩阵的相乘,而不是使用普通冗长vanilla的 Python 代码。 + +下面是这个例子的完整代码: + +``` +import numpy as np +#生成一个 3x3 单位矩阵 +matrix_one = np.eye(3) +matrix_one +#生成另一个 3x3 矩阵以用来做乘法运算 +matrix_two = np.arange(1,10).reshape(3,3) +matrix_two +#将两个矩阵相乘 +matrix_multiply = np.dot(matrix_one, matrix_two) +matrix_multiply +``` + +### Pandas + +[Pandas][3] 是另一个可以提高你的 Python 数据科学技能的优秀库。就和 NumPy 一样,它属于 SciPy 开源软件家族,可以在 BSD 免费许可证许可下使用。 + +Pandas 提供了多功能并且很强大的工具用于管理数据结构和执行大量数据分析。该库能够很好的处理不完整、非结构化和无序的真实世界数据,并且提供了用于整形、聚合、分析和可视化数据集的工具 + +Pandas 中有三种类型的数据结构: + + * Series: 一维、相同数据类型的数组 + * DataFrame: 二维异型矩阵 + * Panel: 三维大小可变数组 + + + +例如,我们来看一下如何使用 Panda 库(缩写成 `pd`)来执行一些描述性统计计算。 + +首先导入该库: + +``` +import pandas as pd +``` + +然后,创建一个序列series字典: + +``` +d = {'Name':pd.Series(['Alfrick','Michael','Wendy','Paul','Dusan','George','Andreas', +   'Irene','Sagar','Simon','James','Rose']), +   'Years of Experience':pd.Series([5,9,1,4,3,4,7,9,6,8,3,1]), +   'Programming Language':pd.Series(['Python','JavaScript','PHP','C++','Java','Scala','React','Ruby','Angular','PHP','Python','JavaScript']) +    } +``` + +接下来,再创建一个数据框DataFrame: + +``` +df = pd.DataFrame(d) +``` + +输出是一个非常规整的表: + +``` +      Name Programming Language  Years of Experience +0   Alfrick               Python                    5 +1   Michael           JavaScript                    9 +2     Wendy                  PHP                    1 +3      Paul                  C++                    4 +4     Dusan                 Java                    3 +5    George                Scala                    4 +6   Andreas                React                    7 +7     Irene                 Ruby                    9 +8     Sagar              Angular                    6 +9     Simon                  PHP                    8 +10    James               Python                    3 +11     Rose           JavaScript                    1 +``` + +下面是这个例子的完整代码: + +``` +import pandas as pd +#创建一个序列字典 +d = {'Name':pd.Series(['Alfrick','Michael','Wendy','Paul','Dusan','George','Andreas', +   'Irene','Sagar','Simon','James','Rose']), +   'Years of Experience':pd.Series([5,9,1,4,3,4,7,9,6,8,3,1]), +   'Programming Language':pd.Series(['Python','JavaScript','PHP','C++','Java','Scala','React','Ruby','Angular','PHP','Python','JavaScript']) +    } + +#创建一个数据框 +df = pd.DataFrame(d) +print(df) +``` + +### Matplotlib + +[Matplotlib][4] 也是 Scipy 核心包的一部分,并且在 BSD 许可证下可用。它是一个非常流行的科学库,用于实现简单而强大的可视化。你可以使用这个 Python 数据科学框架来生成曲线图、柱状图、直方图以及各种不同形状的图表,并且不用担心需要写很多行的代码。例如,我们来看一下如何使用 Matplotlib 库来生成一个简单的柱状图。 + +首先导入该库: + +``` +from matplotlib import pyplot as plt +``` + +然后生成 x 轴和 y 轴的数值: + +``` +x = [2, 4, 6, 8, 10] +y = [10, 11, 6, 7, 4] +``` + +接下来,调用函数来绘制柱状图: + +``` +plt.bar(x,y) +``` + +最后,显示图表: + +``` +plt.show() +``` + +柱状图如下: + +![][6] + +下面是这个例子的完整代码: + +``` +#导入 Matplotlib 库 +from matplotlib import pyplot as plt +#和 import matplotlib.pyplot as plt 一样 +  +#生成 x 轴的数值 +x = [2, 4, 6, 8, 10] +  +#生成 y 轴的数值 +y = [10, 11, 6, 7, 4] +  +#调用函数来绘制柱状图 +plt.bar(x,y) +  +#显示图表 +plt.show() +``` + +### 总结 + +Python 编程语言非常擅长数据处理和准备,但是在科学数据分析和建模方面就没有那么优秀了。幸好有这些用于[数据科学][5]的顶级 Python 框架填补了这一空缺,从而你能够进行复杂的数学计算以及创建复杂模型,进而让数据变得更有意义。 + +你还知道其它的 Python 数据挖掘库吗?你的使用经验是什么样的?请在下面的评论中和我们分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/top-3-python-libraries-data-science + +作者:[Dr.Michael J.Garbade][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[ucasFL](https://github.com/ucasFL) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/drmjg +[1]: https://www.liveedu.tv/andreybu/REaxr-machine-learning-model-python-sklearn-kera/oPGdP-machine-learning-model-python-sklearn-kera/ +[2]: http://www.numpy.org/ +[3]: http://pandas.pydata.org/ +[4]: https://matplotlib.org/ +[5]: https://www.liveedu.tv/guides/data-science/ +[6]: https://opensource.com/sites/default/files/uploads/matplotlib_barchart.png +[7]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr From e7611efa9df33ffa8950072e0378061885d0fde4 Mon Sep 17 00:00:00 2001 From: sd886393 Date: Thu, 20 Sep 2018 15:52:10 +0800 Subject: [PATCH 337/455] =?UTF-8?q?=E3=80=90=E8=AE=A4=E9=A2=86=E3=80=91201?= =?UTF-8?q?80522=20Free=20Resources=20for=20Securing=20Your=20Open=20Sourc?= =?UTF-8?q?e=20Code=20(#10282)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 认领Free Resources for Securing Your Open Source Code * 删除已经翻译的 20180907 What do open source and cooking have in common.md --- ...20180522 Free Resources for Securing Your Open Source Code.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180522 Free Resources for Securing Your Open Source Code.md b/sources/tech/20180522 Free Resources for Securing Your Open Source Code.md index 4a7522ff9f..1480f3102d 100644 --- a/sources/tech/20180522 Free Resources for Securing Your Open Source Code.md +++ b/sources/tech/20180522 Free Resources for Securing Your Open Source Code.md @@ -1,3 +1,4 @@ +sd886393 is dragging this out to translating Free Resources for Securing Your Open Source Code ====== From cddbd578103832bbee135142863660aafc28492e Mon Sep 17 00:00:00 2001 From: heguangzhi <7731226@qq.com> Date: Thu, 20 Sep 2018 16:26:03 +0800 Subject: [PATCH 338/455] heguangzhi translating (#10283) Linux firewalls: What you need to know about iptables and firewalld --- ...walls- What you need to know about iptables and firewalld.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180918 Linux firewalls- What you need to know about iptables and firewalld.md b/sources/tech/20180918 Linux firewalls- What you need to know about iptables and firewalld.md index 1297916194..98e38a02cd 100644 --- a/sources/tech/20180918 Linux firewalls- What you need to know about iptables and firewalld.md +++ b/sources/tech/20180918 Linux firewalls- What you need to know about iptables and firewalld.md @@ -1,3 +1,5 @@ +heguangzhi translating + Linux firewalls: What you need to know about iptables and firewalld ====== Here's how to use the iptables and firewalld tools to manage Linux firewall connectivity rules. From e8520d0d5b771194525995aa2e515c294a89d652 Mon Sep 17 00:00:00 2001 From: brifuture Date: Thu, 20 Sep 2018 16:28:46 +0800 Subject: [PATCH 339/455] BriFuture picked tech/20180906 3 top open source JavaScript chart libraries.md --- .../20180906 3 top open source JavaScript chart libraries.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180906 3 top open source JavaScript chart libraries.md b/sources/tech/20180906 3 top open source JavaScript chart libraries.md index 096d7ce5e6..eeb5bd377d 100644 --- a/sources/tech/20180906 3 top open source JavaScript chart libraries.md +++ b/sources/tech/20180906 3 top open source JavaScript chart libraries.md @@ -1,3 +1,5 @@ +BriFuture is translating + 3 top open source JavaScript chart libraries ====== From bb574a2bec8e5d7b91288ecaf165d5e9412e419e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 20 Sep 2018 23:17:37 +0800 Subject: [PATCH 340/455] PRF:20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md @ucasFL --- ...ople Use ZFS- [Explained for Beginners].md | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/translated/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md b/translated/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md index 152bb75d23..652ebd6c1d 100644 --- a/translated/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md +++ b/translated/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md @@ -3,23 +3,23 @@ ![ZFS filesystem][9] -今天,我们来谈论一下 ZFS,一个高级文件系统。我们将讨论 ZFS 从何而来,它是什么,以及为什么它在科技界和企业界如此受欢迎。 +今天,我们来谈论一下 ZFS,一个先进的文件系统。我们将讨论 ZFS 从何而来,它是什么,以及为什么它在科技界和企业界如此受欢迎。 虽然我是一个美国人,但我更喜欢读成 ZedFS 而不是 ZeeFS,因为前者听起来更酷一些。你可以根据你的个人喜好来发音。 -注意:在这篇文章中,你将会看到很多次 ZFS。当我在谈论特性和安装的时候,我所指的是 OpenZFS 。自从 Oracle 公司放弃 OpenSolaris 项目之后,ZFS(由 Oracle 公司开发)和 OpenZFS 已经走向了不同的发展道路。 +> 注意:在这篇文章中,你将会看到 ZFS 被提到很多次。当我在谈论特性和安装的时候,我所指的是 OpenZFS 。自从甲骨文Oracle公司放弃 OpenSolaris 项目之后,ZFS(由甲骨文公司开发)和 OpenZFS 已经走向了不同的发展道路。(后面详述) ### ZFS 的历史 -Z 文件系统(ZFS)是在 2001 年由 [Matthew Ahrens 和 Jeff Bonwick][1] 开发的。ZFS 是作为 Sun 公司的[微系统MicroSystem][2] [OpenSolaris][3] 的下一代文件系统而设计的。在 2008 年,ZFS 被移植到了 FreeBSD 。同一年,一个新的项目也开始了:[ZFS to Linux][4] 。然而,由于 ZFS 是[通用开发和发布许可证(CDDL)][5]许可的,它和 [GNU 通用公共许可证][6] 不兼容,因此不能将它迁移到 Linux 内核中。为了解决这个问题,绝大多数 Linux 发行版提供了一些方法来安装 ZFS 。 +Z 文件系统Z File System(ZFS)是由 [Matthew Ahrens 和 Jeff Bonwick][1] 在 2001 年开发的。ZFS 是作为[太阳微系统Sun MicroSystem][2] 公司的 [OpenSolaris][3] 的下一代文件系统而设计的。在 2008 年,ZFS 被移植到了 FreeBSD 。同一年,一个移植 [ZFS 到 Linux][4] 的项目也启动了。然而,由于 ZFS 是[通用开发和发布许可证][5]Common Development and Distribution License(CDDL)许可的,它和 [GNU 通用公共许可证][6] 不兼容,因此不能将它迁移到 Linux 内核中。为了解决这个问题,绝大多数 Linux 发行版提供了一些方法来安装 ZFS 。 -在 Oracle 公司收购 Sun 公司之后不久,微系统 OpenSolaris 就闭源了,这使得 ZFS 的最新开发也闭源了。许多 ZFS 开发者对这件事情非常不开心。[三分之二的 ZFS 核心开发者][1],包括 Ahrens 和 Bonwick,因为这个决定而离开了 Oracle 公司。他们加入其他公司,并于 2013 年 9 月创立了 [OpenZFS][7] 这一项目。该项目引领着 ZFS 的开源开发。 +在甲骨文公司收购太阳微系统公司之后不久,OpenSolaris 就闭源了,这使得 ZFS 的之后的开发也变成闭源的了。许多 ZFS 开发者对这件事情非常不满。[三分之二的 ZFS 核心开发者][1],包括 Ahrens 和 Bonwick,因为这个决定而离开了甲骨文公司。他们加入了其它公司,并于 2013 年 9 月创立了 [OpenZFS][7] 这一项目。该项目引领着 ZFS 的开源开发。 -让我们回到上面提到的许可证问题上。既然 OpenZFS 项目已经和 Oracle 公司分离开了,有人可能好奇他们为什么不使用和 GPL 兼容的许可证,这样就可以把它加入到 Linux 内核中了。根据 [OpenZFS 官网][8] 的介绍,更改许可证需要联系所有为当前 OpenZFS 实现贡献过代码的人(包括初始公共 ZFS 代码以及 OpenSolaris 代码),并得到他们的许可才行。这几乎是不可能的(因为一些贡献者可能已经去世了或者很难找到),因此他们决定保留原来的许可证。 +让我们回到上面提到的许可证问题上。既然 OpenZFS 项目已经和 Oracle 公司分离开了,有人可能好奇他们为什么不使用和 GPL 兼容的许可证,这样就可以把它加入到 Linux 内核中了。根据 [OpenZFS 官网][8] 的介绍,更改许可证需要联系所有为当前 OpenZFS 实现贡献过代码的人(包括初始的公共 ZFS 代码以及 OpenSolaris 代码),并得到他们的许可才行。这几乎是不可能的(因为一些贡献者可能已经去世了或者很难找到),因此他们决定保留原来的许可证。 ### ZFS 是什么,它有什么特性? -正如前面所说过的,ZFS 是一个高级文件系统。因此,它有一些有趣的[特性][10]。比如: +正如前面所说过的,ZFS 是一个先进的文件系统。因此,它有一些有趣的[特性][10]。比如: * 存储池 * 写时拷贝 @@ -27,28 +27,27 @@ Z 文件系统(ZFS)是在 2001 年由 [Matthew Ahrens 和 Jeff Bonwick][1] * 数据完整性验证和自动修复 * RAID-Z * 最大单个文件大小为 16 EB(1 EB = 1024 PB) - * 最大 256 万亿的四次方 ZB(1 ZB = 1024 EB)的存储 - - + * 最大 256 千万亿(256*10^15 )的 ZB(1 ZB = 1024 EB)的存储 让我们来深入了解一下其中一些特性。 #### 存储池 -与大多数文件系统不同,ZFS 结合了文件系统和卷管理器的特性。这意味着,它与其他文件系统不同,ZFS 可以创建跨域一系列硬盘或池的文件系统。不仅如此,你还可以通过添加硬盘来增大池的存储容量。ZFS 可以进行[分区和格式化][11]。 +与大多数文件系统不同,ZFS 结合了文件系统和卷管理器的特性。这意味着,它与其他文件系统不同,ZFS 可以创建跨越一系列硬盘或池的文件系统。不仅如此,你还可以通过添加硬盘来增大池的存储容量。ZFS 可以进行[分区和格式化][11]。 ![Pooled storage in ZFS][12] + *ZFS 存储池* #### 写时拷贝 -[写时拷贝Copy-on-write][13]是另一个有趣并且很酷的特性。在大多数文件系统上,当数据被重写时,它将永久丢失。而在 ZFS 中,新数据会写到不同的块。写完成之后,更新文件系统元数据信息,使之指向新的数据块(LCTT 译注:更新之后,原数据块成为磁盘上的垃圾,需要有对应的垃圾回收机制)。这确保了如果在写新数据的时候系统崩溃(或者发生其它事,比如突然断电),那么原数据将会保存下来。这也意味着,在系统发生崩溃之后,不需要运行 [fsck][14] 来检查和修复文件系统。 +[写时拷贝][13]Copy-on-write是另一个有趣并且很酷的特性。在大多数文件系统上,当数据被重写时,它将永久丢失。而在 ZFS 中,新数据会写到不同的块。写完成之后,更新文件系统元数据信息,使之指向新的数据块(LCTT 译注:更新之后,原数据块成为磁盘上的垃圾,需要有对应的垃圾回收机制)。这确保了如果在写新数据的时候系统崩溃(或者发生其它事,比如突然断电),那么原数据将会保存下来。这也意味着,在系统发生崩溃之后,不需要运行 [fsck][14] 来检查和修复文件系统。 #### 快照 写时拷贝使得 ZFS 有了另一个特性:快照snapshots。ZFS 使用快照来跟踪文件系统中的更改。[快照][13]包含文件系统的原始版本(文件系统的一个只读版本),实时文件系统则包含了自从快照创建之后的任何更改。没有使用额外的空间。因为新数据将会写到实时文件系统新分配的块上。如果一个文件被删除了,那么它在快照中的索引也会被删除。所以,快照主要是用来跟踪文件的更改,而不是文件的增加和创建。 -快照可以挂载成只读的,以用来恢复一个文件的过去版本。实时系统也可以回滚到之前的快照。回滚之后,自从快照创建之后的所有更改将会丢失。 +快照可以挂载成只读的,以用来恢复一个文件的过去版本。实时文件系统也可以回滚到之前的快照。回滚之后,自从快照创建之后的所有更改将会丢失。 #### 数据完整性验证和自动修复 @@ -56,11 +55,11 @@ Z 文件系统(ZFS)是在 2001 年由 [Matthew Ahrens 和 Jeff Bonwick][1] #### RAID-Z -ZFS 不需要任何额外软件或硬件就可以处理 RAID(磁盘阵列)。毫无奇怪,因为 ZFS 有自己的 RAID 实现:RAID-Z 。RAID-Z 是 RAID-5 的一个变种,不过它克服了 RAID-5 的写漏洞:意外重启之后,数据和校验信息会变得不同步(LCTT 译注:RAID-5 的 stripe 在正写数据时,如果这时候电源中断,那么奇偶校验数据将跟该部分数据不同步,因此前边的写无效;RAID-Z 用了 “variable-width RAID stripes” 技术,因此所有的写都是 full-stripe writes)。为了使用基本级别的 [RAID-Z][15](RAID-Z1),你需要至少三块磁盘,其中两块用来存储数据,另外一块用来存储[奇偶校验信息][16]。而RAID-Z2 需要至少两块磁盘存储数据以及两块磁盘存储校验信息。RAID-Z3 需要至少两块磁盘存储数据以及三块磁盘存储校验信息。另外,只能向 RAID-Z 池中加入偶数倍的磁盘,而不能是奇数倍的。 +ZFS 不需要任何额外软件或硬件就可以处理 RAID(磁盘阵列)。毫不奇怪,因为 ZFS 有自己的 RAID 实现:RAID-Z 。RAID-Z 是 RAID-5 的一个变种,不过它克服了 RAID-5 的写漏洞:意外重启之后,数据和校验信息会变得不同步(LCTT 译注:RAID-5 的条带在正写入数据时,如果这时候电源中断,那么奇偶校验数据将跟该部分数据不同步,因此前边的写无效;RAID-Z 用了 “可变宽的 RAID 条带” 技术,因此所有的写都是全条带写入)。为了使用[基本级别的 RAID-Z][15](RAID-Z1),你需要至少三块磁盘,其中两块用来存储数据,另外一块用来存储[奇偶校验信息][16]。而 RAID-Z2 需要至少两块磁盘存储数据以及两块磁盘存储校验信息。RAID-Z3 需要至少两块磁盘存储数据以及三块磁盘存储校验信息。另外,只能向 RAID-Z 池中加入偶数倍的磁盘,而不能是奇数倍的。 #### 巨大的存储潜力 -创建 ZFS 的时候,它就被设计成了[最后一个文件系统][17] 。那时候,大多数文件系统都是 64 位的,ZFS 的创建者决定直接跳到 128 位,等到将来再来证明这是对的。这意味着 ZFS 的容量大小是 32 位或 64 位文件系统的 160 亿亿倍。事实上,Jeff Bonwick(其中一个创建者)说:“完全填满一个 128 位的存储池所需要的[能量][18],从字面上讲,比煮沸海洋需要的还多。” +创建 ZFS 的时候,它是作为[最后一个文件系统][17]而设计的 。那时候,大多数文件系统都是 64 位的,ZFS 的创建者决定直接跳到 128 位,等到将来再来证明这是对的。这意味着 ZFS 的容量大小是 32 位或 64 位文件系统的 1600 亿亿倍。事实上,Jeff Bonwick(其中一个创建者)说:“完全填满一个 128 位的存储池所需要的[能量][18],从字面上讲,比煮沸海洋需要的还多。” ### 如何安装 ZFS? @@ -85,7 +84,7 @@ via: https://itsfoss.com/what-is-zfs/ 作者:[John Paul][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[ucasFL](https://github.com/ucasFL) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 1861a7738d00374150525bd36251da543579346e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 20 Sep 2018 23:18:03 +0800 Subject: [PATCH 341/455] PUB:20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md @ucasFL https://linux.cn/article-10034-1.html --- ... What is ZFS- Why People Use ZFS- [Explained for Beginners].md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md (100%) diff --git a/translated/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md b/published/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md similarity index 100% rename from translated/tech/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md rename to published/20180909 What is ZFS- Why People Use ZFS- [Explained for Beginners].md From e8dc64027f0f872d3dc42d7f02053e9ca15ccf19 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 21 Sep 2018 08:56:29 +0800 Subject: [PATCH 342/455] translated --- ...80913 ScreenCloud- The Screenshot-- App.md | 79 ------------------- ...80913 ScreenCloud- The Screenshot-- App.md | 77 ++++++++++++++++++ 2 files changed, 77 insertions(+), 79 deletions(-) delete mode 100644 sources/tech/20180913 ScreenCloud- The Screenshot-- App.md create mode 100644 translated/tech/20180913 ScreenCloud- The Screenshot-- App.md diff --git a/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md b/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md deleted file mode 100644 index f7bab2090a..0000000000 --- a/sources/tech/20180913 ScreenCloud- The Screenshot-- App.md +++ /dev/null @@ -1,79 +0,0 @@ -translating---geekpi - -ScreenCloud: The Screenshot++ App -====== -[ScreenCloud][1] is an amazing little app, that you don’t even know you need. The default screenshot procedure on desktop Linux is great (Prt Scr Button) and we even have some[powerful screenshot utilities][2]like [Shutter][3]. But ScreenCloud brings one more really simple yet really convenient feature that I just fell in love with. But before we get into it, let’s catch a little backstory. - -I take a lot of screenshots. A lot more than average. Receipts, registration details, development work, screenshots of applications for articles, and lot more. The next thing I do is open a browser, browse to my favorite cloud storage and dump the important ones there so that I can access them on my phone and also across multiple operating systems on my PC. This also allows me to easily share screenshots of the apps that I’m working on with my team. - -I had no complaints with this standard procedure of taking screenshots, opening a browser and logging into my cloud and then uploading the screenshots manually, until I came across ScreenCloud. - -### ScreenCloud - -ScreenCloud is cross-platform utility that provides easy screenshot capture and management along with flexible [cloud backup options][4]. including your own [FTP server][5]. - -![][6] - -ScreenCloud is really streamlined with a lot of attention given to the smaller things. It provides you very easy to remember hotkeys to capture the full screen, the active window or capture an area selected with the mouse. - -![][7]Default keyboard shortcuts for ScreenCloud - -Once a screenshot is taken, you can either set ScreenCloud to ask what to do with the image or to directly upload it the cloud service of your choice. Even SFTP is supported. Once the screenshot it uploaded, generally within a couple of seconds, the link to the image is automatically copied to the clipboard, which you can easily share. - -![][8] - -You can also do some basic editing with ScreenCloud. For this, you should have “Save to” set to “Ask me”. This setting is available from the application indicator and is usually set by default. With this, when you take a screenshot, you’ll see the option for editing the file. Here, you can add arrows, text and numbers to the screenshot. - -![Editing screenshots with ScreenCloud][9]Editing screenshots with ScreenCloud - -### Installing ScreenCloud on Linux - -ScreenCloud is available in the [Snap store][10]. So you can easily install it on Ubuntu and other [Snap enabled][11] distros by visiting the [Snap store][12] or by running the following command. - -``` -sudo snap install screencloud - -``` - -And for Linux distros which can’t install apps through Snap, You can download the AppImage [here][1]. The browse to the download location, right click and open a terminal there. Then run the command below. - -``` -sudo chmod +x ScreenCloud-v1.4.0-x86_64.AppImage - -``` - -You can then launch the app by double clicking on the downloaded file. - -![][13] - -### Wrapping up - -Is ScreenCloud for everybody? Probably not. Is it better than the default screenshot? Probably yes. See if you’re taking a screenshot of something, then chances are, that it’s probably important or you intend to share it. ScreenCloud makes backing up or sharing that screenshot easier and considerably faster. So yeah, you should give ScreenCloud a try if you want these features. - -Your thoughts and comments are always welcome, use the comments section below. And don’t forget to share this article with your friends. Cheers. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/screencloud-app/ - -作者:[Aquil Roshan][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/aquil/ -[1]: https://screencloud.net -[2]: https://itsfoss.com/take-screenshot-linux/ -[3]: http://shutter-project.org -[4]: https://itsfoss.com/cloud-services-linux/ -[5]: https://itsfoss.com/set-ftp-server-linux/ -[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/screencloud3.jpg -[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/screencloud2.jpg -[8]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ScrenCloud6.jpg -[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/editing-with-screencloud.png -[10]: https://snapcraft.io/ -[11]: https://itsfoss.com/install-snap-linux/ -[12]: https://snapcraft.io/screencloud -[13]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ScrenCloud4.jpg diff --git a/translated/tech/20180913 ScreenCloud- The Screenshot-- App.md b/translated/tech/20180913 ScreenCloud- The Screenshot-- App.md new file mode 100644 index 0000000000..a7002183c3 --- /dev/null +++ b/translated/tech/20180913 ScreenCloud- The Screenshot-- App.md @@ -0,0 +1,77 @@ +ScreenCloud:一个截屏程序 +====== +[ScreenCloud][1]是一个很棒的小程序,你甚至不知道你需要它。桌面 Linux 的默认屏幕截图流程很好(Prt Scr 按钮),我们甚至有一些[强大的截图工具][2],如 [Shutter][3]。但是,ScreenCloud 有一个非常简单但非常方便的功能,让我爱上了它。在我们深入它之前,让我们先看一个背景故事。 + +我截取了很多截图。远远超过平均水平。收据、注册详细信息、开发工作、文章中程序的截图等等。我接下来要做的就是打开浏览器,浏览我最喜欢的云存储并将重要的内容转储到那里,以便我可以在手机上以及 PC 上的多个操作系统上访问它们。这也让我可以轻松与我的团队分享我正在使用的程序的截图。 + +我对这个标准的截图流程没有抱怨,打开浏览器并登录我的云,然后手动上传屏幕截图,直到我遇到 ScreenCloud。 + +### ScreenCloud + +ScreenCloud 是跨平台的程序,它提供简单的屏幕截图和灵活的[云备份选项][4]管理。这包括使用你自己的[ FTP 服务器][5]。 + +![][6] + +ScreenCloud 很精简,投入了大量的注意力给小的东西。它为你提供了非常容易记住的热键来捕获全屏、活动窗口或捕获用鼠标选择的区域。 + +![][7]ScreenCloud 的默认键盘快捷键 + +截取屏幕截图后,你可以设置 ScreenCloud 如何处理图像或直接将其上传到你选择的云服务。它甚至支持 SFTP。截图上传后(通常在几秒钟内),图像链接就会被自动复制到剪贴板,这让你可以轻松共享。 + +![][8] + +你还可以使用 ScreenCloud 进行一些基本编辑。为此,你需要将 “Save to” 设置为 “Ask me”。此设置在下拉框中有并且通常是默认设置。当使用它时,当你截取屏幕截图时,你会看到编辑文件的选项。在这里,你可以在屏幕截图中添加箭头、文本和数字。 + +![Editing screenshots with ScreenCloud][9]Editing screenshots with ScreenCloud + +### 在 Linux 上安装 ScreenCloud + +ScreenCloud 可在[ Snap 商店][10]中找到。因此,你可以通过访问[ Snap 商店][12]或运行以下命令,轻松地将其安装在 Ubuntu 和其他[启用 Snap ][11]的发行版上。 + +``` +sudo snap install screencloud + +``` + +对于无法通过 Snap 安装程序的 Linux 发行版,你可以[在这里][1]下载 AppImage。进入下载文件夹,右键单击并在那里打开终端。然后运行以下命令。 + +``` +sudo chmod +x ScreenCloud-v1.4.0-x86_64.AppImage + +``` + +然后,你可以通过双击下载的文件来启动程序。 + +![][13] + +### 总结 + +ScreenCloud 适合所有人吗?可能不会。它比默认屏幕截图更好吗?可能是。如果你正在截某些屏幕,有可能它是重要的或是你想分享的。ScreenCloud 可以更轻松,更快速地备份或共享屏幕截图。所以,如果你想要这些功能,你应该试试 ScreenCloud。 + +欢迎在用下面的评论栏提出你的想法和意见。还有不要忘记与朋友分享这篇文章。干杯。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/screencloud-app/ + +作者:[Aquil Roshan][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/aquil/ +[1]: https://screencloud.net +[2]: https://itsfoss.com/take-screenshot-linux/ +[3]: http://shutter-project.org +[4]: https://itsfoss.com/cloud-services-linux/ +[5]: https://itsfoss.com/set-ftp-server-linux/ +[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/screencloud3.jpg +[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/screencloud2.jpg +[8]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ScrenCloud6.jpg +[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/editing-with-screencloud.png +[10]: https://snapcraft.io/ +[11]: https://itsfoss.com/install-snap-linux/ +[12]: https://snapcraft.io/screencloud +[13]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ScrenCloud4.jpg From baaea62c83ecf6ba227467753ebdde87cbe8c69b Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 21 Sep 2018 09:03:33 +0800 Subject: [PATCH 343/455] translating --- sources/tech/20180824 5 cool music player apps.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180824 5 cool music player apps.md b/sources/tech/20180824 5 cool music player apps.md index 3a8d90400c..fbacc8f8b4 100644 --- a/sources/tech/20180824 5 cool music player apps.md +++ b/sources/tech/20180824 5 cool music player apps.md @@ -1,3 +1,5 @@ +translating---geekpi + 5 cool music player apps ====== From e7c3e652270c0edcb521525eef9accd5f6d19920 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 21 Sep 2018 11:30:36 +0800 Subject: [PATCH 344/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Host=20your=20own?= =?UTF-8?q?=20cloud=20with=20Raspberry=20Pi=20NAS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...st your own cloud with Raspberry Pi NAS.md | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md diff --git a/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md b/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md new file mode 100644 index 0000000000..6e7893313e --- /dev/null +++ b/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md @@ -0,0 +1,111 @@ +Host your own cloud with Raspberry Pi NAS +====== + +Protect and secure your data with a self-hosted cloud powered by your Raspberry Pi. + +In the first two parts of this series, we discussed the [hardware and software fundamentals][1] for building network-attached storage (NAS) on a Raspberry Pi. We also put a proper [backup strategy][2] in place to secure the data on the NAS. In this third part, we will talk about a convenient way to store, access, and share your data with [Nextcloud][3]. + +### Prerequisites + +To use Nextcloud conveniently, you have to meet a few prerequisites. First, you should have a domain you can use for the Nextcloud instance. For the sake of simplicity in this how-to, we'll use **nextcloud.pi-nas.com**. This domain should be directed to your Raspberry Pi. If you want to run it on your home network, you probably need to set up dynamic DNS for this domain and enable port forwarding of ports 80 and 443 (if you go for an SSL setup, which is highly recommended; otherwise port 80 should be sufficient) from your router to the Raspberry Pi. + +You can automate dynamic DNS updates from the Raspberry Pi using [ddclient][4]. + +### Install Nextcloud + +To run Nextcloud on your Raspberry Pi (using the setup described in the [first part][1] of this series), install the following packages as dependencies to Nextcloud using **apt**. + +``` +sudo apt install unzip wget php apache2 mysql-server php-zip php-mysql php-dom php-mbstring php-gd php-curl +``` + +The next step is to download Nextcloud. [Get the latest release's URL][5] and copy it to download via **wget** on the Raspberry Pi. In the first article in this series, we attached two disk drives to the Raspberry Pi, one for current data and one for backups. Install Nextcloud on the data drive to make sure data is backed up automatically every night. + +``` +sudo mkdir -p /nas/data/nextcloud +sudo chown pi /nas/data/nextcloud +cd /nas/data/ +wget https://download.nextcloud.com/server/releases/nextcloud-14.0.0.zip -O /nas/data/nextcloud.zip +unzip nextcloud.zip +sudo ln -s /nas/data/nextcloud /var/www/nextcloud +sudo chown -R www-data:www-data /nas/data/nextcloud +``` + +When I wrote this, the latest release (as you see in the code above) was 14. Nextcloud is under heavy development, so you may find a newer version when installing your copy of Nextcloud onto your Raspberry Pi. + +### Database setup + +When we installed Nextcloud above, we also installed MySQL as a dependency to use it for all the metadata Nextcloud generates (for example, the users you create to access Nextcloud). If you would rather use a Postgres database, you'll need to adjust some of the modules installed above. + +To access the MySQL database as root, start the MySQL client as root: + +``` +sudo mysql +``` + +This will open a SQL prompt where you can insert the following commands—substituting the placeholder with the password you want to use for the database connection—to create a database for Nextcloud. + +``` +CREATE USER nextcloud IDENTIFIED BY ''; +CREATE DATABASE nextcloud; +GRANT ALL ON nextcloud.* TO nextcloud; +``` + +You can exit the SQL prompt by pressing **Ctrl+D** or entering **quit**. + +### Web server configuration + +Nextcloud can be configured to run using Nginx or other web servers, but for this how-to, I decided to go with the Apache web server on my Raspberry Pi NAS. (Feel free to try out another alternative and let me know if you think it performs better.) + +To set it up, configure a virtual host for the domain you created for your Nextcloud instance **nextcloud.pi-nas.com**. To create a virtual host, create the file **/etc/apache2/sites-available/001-nextcloud.conf** with content similar to the following. Make sure to adjust the ServerName to your domain and paths, if you didn't use the ones suggested earlier in this series. + +``` + +ServerName nextcloud.pi-nas.com +ServerAdmin admin@pi-nas.com +DocumentRoot /var/www/nextcloud/ + + +AllowOverride None + + +``` + +To enable this virtual host, run the following two commands. + +``` +a2ensite 001-nextcloud +sudo systemctl reload apache2 +``` + +With this configuration, you should now be able to reach the web server with your domain via the web browser. To secure your data, I recommend using HTTPS instead of HTTP to access Nextcloud. A very easy (and free) way is to obtain a [Let's Encrypt][6] certificate with [Certbot][7] and have a cron job automatically refresh it. That way you don't have to mess around with self-signed or expiring certificates. Follow Certbot's simple how-to [instructions to install it on your Raspberry Pi][8]. During Certbot configuration, you can even decide to automatically forward HTTP to HTTPS, so visitors to **** will be redirected to ****. Please note, if your Raspberry Pi is running behind your home router, you must have port forwarding enabled for ports 443 and 80 to obtain Let's Encrypt certificates. + +### Configure Nextcloud + +The final step is to visit your fresh Nextcloud instance in a web browser to finish the configuration. To do so, open your domain in a browser and insert the database details from above. You can also set up your first Nextcloud user here, the one you can use for admin tasks. By default, the data directory should be inside the Nextcloud folder, so you don't need to change anything for the backup mechanisms from the [second part of this series][2] to pick up the data stored by users in Nextcloud. + +Afterward, you will be directed to your Nextcloud and can log in with the admin user you created previously. To see a list of recommended steps to ensure a performant and secure Nextcloud installation, visit the Basic Settings tab in the Settings page (in our example: settings/admin) and see the Security & Setup Warnings section. + +Congratulations! You've set up your own Nextcloud powered by a Raspberry Pi. Go ahead and [download a Nextcloud client][9] from the Nextcloud page to sync data with your client devices and access it offline. Mobile clients even provide features like instant upload of pictures you take, so they'll automatically sync to your desktop PC without wondering how to get them there. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/host-cloud-nas-raspberry-pi + +作者:[Manuel Dewald][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ntlx +[1]: https://opensource.com/article/18/7/network-attached-storage-Raspberry-Pi +[2]: https://opensource.com/article/18/8/automate-backups-raspberry-pi +[3]: https://nextcloud.com/ +[4]: https://sourceforge.net/p/ddclient/wiki/Home/ +[5]: https://nextcloud.com/install/#instructions-server +[6]: https://letsencrypt.org/ +[7]: https://certbot.eff.org/ +[8]: https://certbot.eff.org/lets-encrypt/debianother-apache +[9]: https://nextcloud.com/install/#install-clients From 45fccd3b21241b14db67309d44f787ae5859dc7a Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 21 Sep 2018 11:32:57 +0800 Subject: [PATCH 345/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Record=20Screen?= =?UTF-8?q?=20in=20Ubuntu=20Linux=20With=20Kazam=20[Beginner=E2=80=99s=20G?= =?UTF-8?q?uide]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...untu Linux With Kazam -Beginner-s Guide.md | 185 ++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 sources/tech/20180920 Record Screen in Ubuntu Linux With Kazam -Beginner-s Guide.md diff --git a/sources/tech/20180920 Record Screen in Ubuntu Linux With Kazam -Beginner-s Guide.md b/sources/tech/20180920 Record Screen in Ubuntu Linux With Kazam -Beginner-s Guide.md new file mode 100644 index 0000000000..a2f57f592a --- /dev/null +++ b/sources/tech/20180920 Record Screen in Ubuntu Linux With Kazam -Beginner-s Guide.md @@ -0,0 +1,185 @@ +Record Screen in Ubuntu Linux With Kazam [Beginner’s Guide] +====== +**This tutorial shows you how to install Kazam screen recorder and explains how to record screen in Ubuntu. The guide also lists useful shortcuts and handy tips for using Kazam.** + +![How to record your screen in Ubuntu Linux with Kazam][1] + +[Kazam][2] is one of the [best screen recorders for Linux][3]. To me, it’s the best screen recording tool. I have been using it for years. All the video tutorials on YouTube have been recorded with Kazam. + +Some of the main features of Kazam are: + + * Record entire screen, part of screen, application window or all screens (for multi-monitor setup) + * Take screenshots + * Keyboard shortcut support for easily pausing and resuming while recording screen + * Record in various file formats such as MP4, AVI and more. + * Capture audio from speaker or microphone while recording the screen + * Capture mouse clicks and key presses + * Capture video from webcam + * Insert a webcam window on the side + * Broadcast to YouTube live video + + + +Like the screenshot tool [Shutter][4], Kazam is also not being actively developed for the last couple of years. And like Shutter, the present Kazam release works just fine. + +I am using Ubuntu in the tutorial. The installation instructions should work for other Ubuntu-based distributions such as Linux Mint, elementary OS etc. For all the other distributions, you can still read about using Kazam and its features. + +### Install Kazam in Ubuntu + +Kazam is available in the official repository in Ubuntu. However, the official repository consists Kazam version 1.4.5, the last stable version of Kazam. + +![Kazam Version 1.4.5][5] +Kazam Version 1.4.5 + +Kazam developer(s) also worked on a newer release, Kazam 1.5.3. The version was almost sable and ready to release, but for unknown reasons, the development stopped after this. There have been [no updates][6] since then. + +You can use either of Kazam 1.4.5 and 1.5.3 without hesitating. Kazam 1.5 provides additional features like recording mouse clicks and key presses, webcam support, live broadcast support, and a refreshed countdown timer. + +![Kazam Version 1.5.3][7] +Kazam Version 1.5.3 + +It’s up to you to decide which version you want to use. I would suggest go for version 1.5.3 because it has more features. + +You can install the older Kazam 1.4.5 from the Software Center. You can also use the command below: + +``` +sudo apt install kazam +``` + +If you want to install the newer Kazam 1.5.3, you can use this [unofficial PPA][8] that is available for Ubuntu 18.04 and 16.04: + +``` +sudo add-apt-repository ppa:sylvain-pineau/kazam +sudo apt-get update +sudo apt install kazam +``` + +You also need to install a few libraries in order to record the mouse clicks and keyboard presses. + +``` +sudo apt install python3-cairo python3-xlib +``` + +### Recording your screen with Kazam + +Once you have installed Kazam, search for it in the application menu and start it. You should see a screen like this with some options on it. You can check the options as per your need and click on capture to start recording screen with Kazam. + +![Screen recording with Kazam][9] +Screen recording with Kazam + +It will show you a countdown before recording the screen. The default wait time is 5 seconds and you can change it from Kazam interface (see the previous image). It gives you a breathing time so that you can prepare for your recording. + +![Countdown before screen recording][10] +Countdown before screen recording + +Once the recording starts,the main Kazam interface disappears and an indicator appears in the panel. If you want to pause the recording or finish the recording, you can do it from this indicator. + +![Pause or finish screen recording][11] +Pause or finish screen recording + +If you choose to finish the recording, it will give you the option to “Save for later”. If you have a [video editor installed in Linux][12], you can also start editing the recording from this point. + +![Save screen recording in Kazam][13] +Save recording + +By default it prompts you to install the recording in Videos folder but you can change the location and save it elsewhere as well. + +That’s the basic you need to know about screen recording in Linux with Kazam. + +Now let me give you a few tips on how to utilize more features in Kazam. + +### Getting more out of Kazam screen recorder + +Kazam is a featureful screen recorder for Linux. You can access its advanced or additional features from the preferences. + +![Accessing Kazam preferences][14] +Accessing Kazam preferences + +#### Autosave screen recording in a specified location + +You can choose to automatically save the screen recordings in Kazam. The default location is Videos but you can change it to any other location. + +![Autosave screen recordings in a chosen location][15] +Autosave in a chosen location + +#### Avoid screen recording in RAW mode + +You can save your screen recordings in file formats like WEBM, MP4, AVI etc. You are free to choose what you want. However, I would advise avoiding RAW (AVI) file format. If you use RAW file format, the recorded files will be in GBs even for a few minutes of recordings. + +It’s wise to verify that Kazam is not using the RAW file format for recording. If you ask my suggestion, prefer H264 with MP4 file format. + +![file format in Kazam][16] +Don’t use RAW files + +#### Capture mouse clicks and key presses while screen recording + +If you want to highlight when a mouse was clicked, you can easily do that in the newer version of Kazam. + +![Record mouse clicks while screen recording with Kazam][17] +Record mouse clicks + +All you have to do is to check the “Key presses and mouse clicks” option on the Kazam interface (the same screen where you press Capture). + +#### Use keyboard shortcuts for more efficient screen recordings + +Imagine you are recording screen in Linux and suddenly you realized that you have to pause the recording for some reasons. Now, you can pause the recording by going to the Kazam indicator and selecting the pause option. But this activity of selecting the pause option will also be recorded. + +You can edit out this part later but it unnecessarily adds to the already cumbersome editing task. + +A better option will be to use the [keyboard shortcuts in Ubuntu][18]. Screen recording becomes a lot better if you use the shortcuts. + +While Kazam is running, you can use the following hotkeys: + + * Super+Ctrl+R: Start recording + * Super+Ctrl+P: Pause recording, press again for resuming the recording + * Super+Ctrl+F: Finish recording + * Super+Ctrl+Q: Quit recording + + + +Super key is the Windows key on your keyboard. + +The most important is Super+Ctrl+P for pausing and resuming the recording. + +You can further explore the Kazam preferences for webcam recording and YouTube live broadcasting options. + +### Do you like Kazam? + +I am repeating myself here. I love Kazam. I have used other screen recorders like [SimpleScreenRecorder][19] or [Green Recorder][20] but I feel a lot more comfortable with Kazam. + +I hope you like Kazam for screen recording in Ubuntu or any other Linux distribution. I have tried highlighting some of the additional features here to help you with a better screen recording. + +What features do you like about Kazam? Do you use some other screen recorder? Do they work better than Kazam? Please share your views in the comments section below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/kazam-screen-recorder/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/screen-recording-kazam-ubuntu-linux.png +[2]: https://launchpad.net/kazam +[3]: https://itsfoss.com/best-linux-screen-recorders/ +[4]: http://shutter-project.org/ +[5]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/kazam-1-4-5.png +[6]: https://launchpad.net/~kazam-team/+archive/ubuntu/unstable-series +[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/kazam-1-5-3.png +[8]: https://launchpad.net/~sylvain-pineau/+archive/ubuntu/kazam +[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/kazam-start-recording.png +[10]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/kazam-countdown.jpg +[11]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/kazam-finish-recording.png +[12]: https://itsfoss.com/best-video-editing-software-linux/ +[13]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/kazam-save-recording.jpg +[14]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/kazam-preferences.png +[15]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/kazam-auto-save.jpg +[16]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/select-file-type-kazam.jpg +[17]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/record-mouse-clicks-kazam.jpeg +[18]: https://itsfoss.com/ubuntu-shortcuts/ +[19]: https://itsfoss.com/record-screen-ubuntu-simplescreenrecorder/ +[20]: https://itsfoss.com/green-recorder-3/ From 032794817cb2b80a04cd3d19a952e9e0e5e80753 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 21 Sep 2018 11:36:09 +0800 Subject: [PATCH 346/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=208=20Python=20pack?= =?UTF-8?q?ages=20that=20will=20simplify=20your=20life=20with=20Django?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...hat will simplify your life with Django.md | 123 ++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 sources/tech/20180920 8 Python packages that will simplify your life with Django.md diff --git a/sources/tech/20180920 8 Python packages that will simplify your life with Django.md b/sources/tech/20180920 8 Python packages that will simplify your life with Django.md new file mode 100644 index 0000000000..58bb3716f8 --- /dev/null +++ b/sources/tech/20180920 8 Python packages that will simplify your life with Django.md @@ -0,0 +1,123 @@ +8 Python packages that will simplify your life with Django +====== + +This month's Python column looks at Django packages that will benefit your work, personal, or side projects. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/water-stone-balance-eight-8.png?itok=1aht_V5V) + +Django developers, we're devoting this month's Python column to packages that will help you. These are our favorite [Django][1] libraries for saving time, cutting down on boilerplate code, and generally simplifying our lives. We've got six packages for Django apps and two for Django's REST Framework, and we're not kidding when we say these packages show up in almost every project we work on. + +But first, see our tips for making the [Django Admin more secure][2] and an article on 5 favorite [open source Django packages][3]. + +### A kitchen sink of useful time-savers: django-extensions + +[Django-extensions][4] is a favorite Django package chock full of helpful tools like these management commands: + + * **shell_plus** starts the Django shell with all your database models already loaded. No more importing from several different apps to test one complex relationship! + * **clean_pyc** removes all .pyc projects from everywhere inside your project directory. + * **create_template_tags** creates a template tag directory structure inside the app you specify. + * **describe_form** displays a form definition for a model, which you can then copy/paste into forms.py. (Note that this produces a regular Django form, not a ModelForm.) + * **notes** displays all comments with stuff like TODO, FIXME, etc. throughout your project. + + + * **TimeStampedModel** : This base class includes the fields **created** and **modified** and a **save()** method that automatically updates these fields appropriately. + * **ActivatorModel** : If your model will need fields like **status** , **activate_date** , and **deactivate_date** , use this base class. It comes with a manager that enables **.active()** and **.inactive()** querysets. + * **TitleDescriptionModel** and **TitleSlugDescriptionModel** : These include the **title** and **description** fields, and the latter also includes a **slug** field. The **slug** field will automatically populate based on the **title** field. + + + +Django-extensions also includes useful abstract base classes to use for common patterns in your own models. Inherit from these base classes when you create your models to get their: + +Django-extensions has more features you may find useful in your projects, so take a tour through its [docs][5]! + +### 12-factor-app settings: django-environ + +[Django-environ][6] allows you to use [12-factor app][7] methodology to manage your settings in your Django project. It collects other libraries, including [envparse][8] and [honcho][9]. Once you install django-environ, create an .env file at your project's root. Define in that module any settings variables that may change between environments or should remain secret (like API keys, debug status, and database URLs). + +Then, in your project's settings.py file, import **environ** and set up variables for **environ.PATH()** and **environ.Env()** according to the [example][10]. Access settings variables defined in your .env file with **env('VARIABLE_NAME')**. + +### Creating great management commands: django-click + +[Django-click][11], based on [Click][12] (which we have recommended [before][13]… [twice][14]), helps you write Django management commands. This library doesn't have extensive documentation, but it does have a directory of [test commands][15] in its repository that are pretty useful. A basic Hello World command would look like this: + +``` +# app_name.management.commands.hello.py +import djclick as click + +@click.command() +@click.argument('name') +def command(name): +    click.secho(f'Hello, {name}') +``` + +Then in the command line, run: + +``` +>> ./manage.py hello Lacey +Hello, Lacey +``` + +### Handling finite state machines: django-fsm + +[Django-fsm][16] adds support for finite state machines to your Django models. If you run a news website and need articles to process through states like Writing, Editing, and Published, django-fsm can help you define those states and manage the rules and restrictions around moving from one state to another. + +Django-fsm provides an FSMField to use for the model attribute that defines the model instance's state. Then you can use django-fsm's **@transition** decorator to define methods that move the model instance from one state to another and handle any side effects from that transition. + +Although django-fsm is light on documentation, [Workflows (States) in Django][17] is a gist that serves as an excellent introduction to both finite state machines and django-fsm. + +### Contact forms: #django-contact-form + +A contact form is such a standard thing on a website. But don't write all that boilerplate code yourself—set yours up in minutes with [django-contact-form][18]. It comes with an optional spam-filtering contact form class (and a regular, non-filtering class) and a **ContactFormView** base class with methods you can override or customize, and it walks you through the templates you will need to create to make your form work. + +### Registering and authenticating users: django-allauth + +[Django-allauth][19] is an app that provides views, forms, and URLs for registering users, logging them in and out, resetting their passwords, and authenticating users with outside sites like GitHub or Twitter. It supports email-as-username authentication and is extensively documented. It can be a little confusing to set up the first time you use it; follow the [installation instructions][20] carefully and read closely when you [customize your settings][21] to make sure you're using all the settings you need to enable a specific feature. + +### Handling user authentication with Django REST Framework: django-rest-auth + +If your Django development includes writing APIs, you're probably using [Django REST Framework][22] (DRF). If you're using DRF, you should check out [django-rest-auth][23], a package that enables endpoints for user registration, login/logout, password reset, and social media authentication (by adding django-allauth, which works well with django-rest-auth). + +### Visualizing a Django REST Framework API: django-rest-swagger + +[Django REST Swagger][24] provides a feature-rich user interface for interacting with your Django REST Framework API. Once you've installed Django REST Swagger and added it to installed apps, add the Swagger view and URL pattern to your urls.py file; the rest is taken care of in the docstrings of your APIs. + +![](https://opensource.com/sites/default/files/uploads/swagger-ui.png) + +The UI for your API will include all your endpoints and available methods broken out by app. It will also list available operations for those endpoints and enable you to interact with the API (adding/deleting/fetching records, for example). It uses the docstrings in your API views to generate documentation for each endpoint, creating a set of API documentation for your project that's useful to you, your frontend developers, and your users. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/django-packages + +作者:[Jeff Triplett][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/laceynwilliams +[1]: https://www.djangoproject.com/ +[2]: https://opensource.com/article/18/1/10-tips-making-django-admin-more-secure +[3]: https://opensource.com/business/15/12/5-favorite-open-source-django-packages +[4]: https://django-extensions.readthedocs.io/en/latest/ +[5]: https://django-extensions.readthedocs.io/ +[6]: https://django-environ.readthedocs.io/en/latest/ +[7]: https://www.12factor.net/ +[8]: https://github.com/rconradharris/envparse +[9]: https://github.com/nickstenning/honcho +[10]: https://django-environ.readthedocs.io/ +[11]: https://github.com/GaretJax/django-click +[12]: http://click.pocoo.org/5/ +[13]: https://opensource.com/article/18/9/python-libraries-side-projects +[14]: https://opensource.com/article/18/5/3-python-command-line-tools +[15]: https://github.com/GaretJax/django-click/tree/master/djclick/test/testprj/testapp/management/commands +[16]: https://github.com/viewflow/django-fsm +[17]: https://gist.github.com/Nagyman/9502133 +[18]: https://django-contact-form.readthedocs.io/en/1.5/ +[19]: https://django-allauth.readthedocs.io/en/latest/ +[20]: https://django-allauth.readthedocs.io/en/latest/installation.html +[21]: https://django-allauth.readthedocs.io/en/latest/configuration.html +[22]: http://www.django-rest-framework.org/ +[23]: https://django-rest-auth.readthedocs.io/ +[24]: https://django-rest-swagger.readthedocs.io/en/latest/ From 8be9ca3571ed6f71eda20a9044a315c224d8e4fa Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 21 Sep 2018 11:38:27 +0800 Subject: [PATCH 347/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Building=20a=20Se?= =?UTF-8?q?cure=20Ecosystem=20for=20Node.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Building a Secure Ecosystem for Node.js.md | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 sources/talk/20180920 Building a Secure Ecosystem for Node.js.md diff --git a/sources/talk/20180920 Building a Secure Ecosystem for Node.js.md b/sources/talk/20180920 Building a Secure Ecosystem for Node.js.md new file mode 100644 index 0000000000..a64f0e32cc --- /dev/null +++ b/sources/talk/20180920 Building a Secure Ecosystem for Node.js.md @@ -0,0 +1,51 @@ +Building a Secure Ecosystem for Node.js +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/node-collective.jpg?itok=0e7Y9Iy3) + +At[Node+JS Interactive][1], attendees collaborate face to face, network, and learn how to improve their skills with JS in serverless, IoT, and more. [Stephanie Evans][2], Content Manager for Back-end Web Development at LinkedIn Learning, will be speaking at the upcoming conference about building a secure ecosystem for Node.js. Here she answers a few questions about teaching and learning basic security practices. + +**Linux.com: Your background is in tech education, can you provide more details on how you would define this and how you got into this area of expertise?** + +**Stephanie Evans:** It sounds cliché, but I’ve always been passionate about education and helping others. After college, I started out as an instructor of a thoroughly analog skill: reading. I worked my way up to hiring and training reading teachers and discovered my passion for helping people share their knowledge and refine their teaching craft. Later, I went to work for McGraw Hill Education, publishing self-study certification books on popular IT certs like CompTIA’s Network+ and Security+, ISAAP’s CISSP, etc. My job was to figure out who the biggest audiences in IT were; what they needed to know to succeed professionally; hire the right book author; and help develop the manuscript with them. + +I moved into online learning/e-learning 4 years ago and shifted to video training courses geared towards developers. I enjoy working with people who spend their time building and solving complex problems. I now manage the video training library for back-end web developers at LinkedIn Learning/Lynda.com and figure out what developers need to know; hire instructors to create that content; and work together to figure out how best to teach it to them. And, then update those courses when they inevitably become out of date. + +**Linux.com: What initially drove you to use your skill set in education to help with security practices?** + +**Evans:** I attend a lot of conferences, watch a lot of talks, and chat to a lot of developers as part of my job. I distinctly remember attending a security best practices talk at a very large, enterprise-tech focused conference and was surprised by the rudimentary content being covered. Poor guy, I’d thought…he’s going to get panned by this audience. But then I looked around and most everyone was engaged. They were learning something new and compelling. And it hit me: I had been in a security echo chamber of my own making. Just like the mainstream developer isn’t working with the cutting-edge technology people are raving about on Twitter, they aren’t necessarily as fluent in basic security practices as I’d assumed. A mix of unawareness, intense time pressure, and perhaps some misplaced trust can lead to a “security later” mentality. But with the global cost of cybercrime up to 6 00 billion a year from 500 billion in 2014 as well as the [exploding amount of data on the web][3]. We can’t afford to be working around security or assuming everyone knows the basics. + +**Linux.com: What do you think are some common misconceptions about security with Node.js and in general with developers?** + +**Evans:** I think one of the biggest misconceptions is that security awareness and practices should come “later” in a developer’s career (and later in the development cycle). Yes, your first priority is to learn that Java and JavaScript are not the same thing—that’s obviously most important. And you do have to understand how to create a form before you can understand how to prevent cross-site -scripting attacks. But helping developers understand—at all stages of their career and learning journey—what the potential vulnerabilities are and how they can be exploited needs to be a much higher priority and come earlier than we may intuitively think. + +I joke with my instructors that we have to sneak in the ‘eat your vegetables’ content to our courses. Security is an exciting, complex and challenging topic, but it can feel like you’re having to eat your vegetables as a developer when you dig into it. Often ‘security’ is a separate department (that can be perceived as ‘slowing things down’ or getting in the way of deploying code) and it can further distance developers from their role in securing their applications. + +I also think that those who truly understand security can feel that it’s overwhelmingly complex to teach—but we have to start somewhere. I attended an introductory npm talk last year that talked about how to work with dependencies and packages…but never once mentioned the possibility of malicious code making it into your application through these packages. I’m all about teaching just enough at the right time and not throwing the kitchen sink of knowledge at new developers. We should stop thinking of security—or even just security awareness—as an intermediate or advanced skill and start bringing it up early and often. + +**Linux.com: How can we infuse tech education into our security practices? Where does this begin?** + +**Evans:** It definitely goes both ways. Clear documentation and practical resources right alongside security recommendations go a long way towards ensuring understanding and adoption. You have to make things as easy as possible if you want people to actually do it. And you have to make those best practices accessible enough to understand. + +The [2018 Node User Survey Report][4] from the Node.js Foundation showed that while learning resources around Node.js and JavaScript development improved, the availability and quality of learning resources for Node.js Security received the lowest scores across the board. + +After documentation and Stack Overflow, many developers rely on online videos and tutorials—we need to push security education to the forefront, rather than expecting developers to seek it out. OWASP, the nodegoat project, and the Node.js Security Working Group are doing great work here to move the needle. I think tech education can do even more to bring security in earlier in the learning journey and create awareness about common exploits and important resources. + +Learn more at [Node+JS Interactive][1], coming up October 10-12, 2018 in Vancouver, Canada. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/node-js/2018/9/building-secure-ecosystem-nodejs + +作者:[The Linux Foundation][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/ericstephenbrown +[1]: https://events.linuxfoundation.org/events/node-js-interactive-2018/?utm_source=Linux.com&utm_medium=article&utm_campaign=jsint18 +[2]: https://jsi2018.sched.com/speaker/stevans1?iframe=no +[3]: https://www.forbes.com/sites/bernardmarr/2018/05/21/how-much-data-do-we-create-every-day-the-mind-blowing-stats-everyone-should-read/#101d261a60ba +[4]: https://nodejs.org/en/user-survey-report/ From 37ec86d411a74004aed103c73e47b637ea4036ac Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 21 Sep 2018 11:40:02 +0800 Subject: [PATCH 348/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20WinWorld=20?= =?UTF-8?q?=E2=80=93=20A=20Large=20Collection=20Of=20Defunct=20OSs,=20Soft?= =?UTF-8?q?ware=20And=20Games?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tion Of Defunct OSs, Software And Games.md | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 sources/talk/20180920 WinWorld - A Large Collection Of Defunct OSs, Software And Games.md diff --git a/sources/talk/20180920 WinWorld - A Large Collection Of Defunct OSs, Software And Games.md b/sources/talk/20180920 WinWorld - A Large Collection Of Defunct OSs, Software And Games.md new file mode 100644 index 0000000000..93c84ae43c --- /dev/null +++ b/sources/talk/20180920 WinWorld - A Large Collection Of Defunct OSs, Software And Games.md @@ -0,0 +1,126 @@ +WinWorld – A Large Collection Of Defunct OSs, Software And Games +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/WinWorld-720x340.jpeg) + +The other day, I was testing **Dosbox** which is used to [**run MS-DOS games and programs in Linux**][1]. While searching for some classic programs like Turbo C++, I stumbled upon a website named **WinWorld**. I went through a few links in this site and quite surprised. WinWorld has a plenty of good-old and classic OSs, software, applications, development tools, games and a lot of other miscellaneous utilities which are abandoned by the developers a long time ago. It is an online museum run by community members, volunteers and is dedicated to the preservation and sharing of vintage, abandoned, and pre-release software. + +WinWorld was started back in 2003 and its founder claims that the idea to start this site inspired by Yahoo briefcases. The primary purpose of this site is to preserve and share old software. Over the years, many people volunteered to improve this site in numerous ways and the collection of old software in WinWorld has grown exponentially. The entire WinWorld library is free, open and available to everyone. + +### WinWorld Hosts A Huge Collection Of Defunct OSs, Software, System Applications And Games + +Like I already said, WinWorld hosts a huge collection of abandonware which are no-longer in development. + +**Linux and Unix:** + +Here, I have given the complete list of UNIX and LINUX OSs with brief summary of the each OS and the release year of first version. + + * **A/UX** – An early port of Unix to Apple’s 68k based Macintosh platform, released in 1988. + * **AIX** – A Unix port originally developed by IBM, released in 1986. + * **AT &T System V Unix** – One of the first commercial versions of the Unix OS, released in 1983. + * **Banyan VINES** – A network operating system originally designed for Unix, released in 1984. + * **Corel Linux** – A commercial Linux distro, released in 1999. + * **DEC OSF-1** – A version of UNIX developed by Digital Equipment Corporation (DEC), released in 1991. + * **Digital UNIX** – A renamed version of **OSF-1** , released by DEC in 1995.** +** + * **FreeBSD** **1.0** – The first release of FreeBSD, released in 1993. It is based on 4.3BSD. + * **Gentus Linux** – A distribution that failed to comply with GPL. Developed by ABIT and released in 2000. + * **HP-UX** – A UNIX variant, released in 1992. + * **IRIX** – An a operating system developed by Silicon Graphics Inc (SGI ) and it is released in 1988. + * **Lindows** – Similar to Corel Linux. It is developed for commercial purpose and released in 2002. + * **Linux Kernel** – A copy of the Linux Sourcecode, version 0.01. Released in the early 90’s. + * **Mandrake Linux** – A Linux distribution based on Red Hat Linux. It was later renamed to Mandriva. Released in 1999. + * **NEWS-OS** – A variant of BSD, developed by Sony and released in 1989. + * **NeXTStep** – A Unix based OS from NeXT computers headed by **Steve Jobs**. It is released in 1987. + * **PC/IX** – A UNIX variant created for IBM PCs. Released in 1984. + * **Red Hat Linux 5.0** – A commercial Linux distribution by Red Hat. + * **Sun Solaris** – A Unix based OS by Sun Microsystems. Released in 1992. + * **SunOS** – A Unix-based OS derived from BSD by Sun Microsystems, released in 1982. + * **Tru64 UNIX** – A formerly known OSF/1 by DEC. + * **Ubuntu 4.10** – The well-known OS based on Debian.This was a beta pre-release, prior to the very first official Ubuntu release. + * **Ultrix** – A UNIX clone developed by DEC. + * **UnixWare** – A UNIX variant from Novell. + * **Xandros Linux** – A proprietary variant of Linux. It is based on Corel Linux. The first version is released in 2003. + * **Xenix** – A UNIX variant originally published by Microsoft released in 1984. + + + +Not just Linux/Unix, you can find other operating systems including DOS, Windows, Apple/Mac, OS 2, Novell netware and other OSs and shells. + +**DOS & CP/M:** + + * 86-DOS + * Concurrent CPM-86 & Concurrent DOS + * CP/M 86 & CP/M-80 + * DOS Plus + * DR-DOS + * GEM + * MP/M + * MS-DOS + * Multitasking MS-DOS 4.00 + * Multiuser DOS + * PC-DOS + * PC-MOS + * PTS-DOS + * Real/32 + * Tandy Deskmate + * Wendin DOS + + + +**Windows:** + + * BackOffice Server + * Windows 1.0/2.x/3.0/3.1/95/98/2000/ME/NT 3.X/NT 4.0 + * Windows Whistler + * WinFrame + + + +**Apple/Mac:** + + * Mac OS 7/8/9 + * Mac OS X + * System Software (0-6) + + + +**OS/2:** + + * Citrix Multiuser + * OS/2 1.x + * OS/2 2.0 + * OS/2 3.x + * OS/2 Warp 4 + + + +Also, WinWorld hosts a huge collection of old software, system applications, development tools and games. Go and check them out as well. + +To be honest, I don’t even know the existence of most of the stuffs listed in this site. Some of the tools listed here were released years before I was born. + +Just in case, If you ever in need of or wanted to test a classic stuff (be it a game, software, OS), look nowhere, just head over to WinWorld library and download them that you want to explore. Good luck! + +**Disclaimer:** + +OSTechNix is not affiliated with WinWorld site in any way. We, at OSTechNix, don’t know the authenticity and integrity of the stuffs hosted in this site. Also, downloading software from third-party sites is not safe or may be illegal in your region. Neither the author nor OSTechNix is responsible for any kind of damage. Use this service at your own risk. + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/winworld-a-large-collection-of-defunct-oss-software-and-games/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://www.ostechnix.com/how-to-run-ms-dos-games-and-programs-in-linux/ From 9f02fbfffcd80773c59bc415d83f9dde2034ddf1 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 21 Sep 2018 11:42:30 +0800 Subject: [PATCH 349/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=205=20ways=20DevSec?= =?UTF-8?q?Ops=20changes=20security?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...80919 5 ways DevSecOps changes security.md | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 sources/talk/20180919 5 ways DevSecOps changes security.md diff --git a/sources/talk/20180919 5 ways DevSecOps changes security.md b/sources/talk/20180919 5 ways DevSecOps changes security.md new file mode 100644 index 0000000000..28e4b90eec --- /dev/null +++ b/sources/talk/20180919 5 ways DevSecOps changes security.md @@ -0,0 +1,76 @@ +5 ways DevSecOps changes security +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-password.jpg?itok=KJMdkKum) + +There’s been an ongoing kerfuffle over whether we need to expand [DevOps][1] to explicitly bring in security. After all, the thinking goes, [DevOps][2] has always been something of a shorthand for a broad set of new practices, using new tools (often open source) and built on more collaborative cultures. Why not [DevBizOps][3] for better aligning with business needs? Or DevChatOps to emphasize better and faster communications? + +However, [as John Willis wrote earlier this year][4] on his coming around to the [DevSecOps][5] terminology, “Hopefully, someday we will have a world where we no longer have to use the word DevSecOps and security will be an inherent part of all service delivery discussions. Until that day, and at this point, my general conclusion is that it’s just three new characters. More importantly, the name really differentiates the problem statement in a world where we as an industry are not doing a great job on information security.” + +So why aren’t we doing a great job on [information security][6], and what does it mean to do a great job in a DevSecOps context? + +We’ve arguably never done a great job of information security in spite of (or maybe because of) the vast industry of complex point products addressing narrow problems. But we also arguably did a good enough job during the era when defending against threats focused on securing the perimeter, network connections were limited, and most users were employees using company-provided devices. + +Those circumstances haven’t accurately described most organizations’ reality for a number of years now. But the current era, which brings in not only DevSecOps but new application architectural patterns, development practices, and an increasing number of threats, defines a stark new normal that requires a faster pace of change. It’s not so much that DevSecOps in isolation changes security, but that infosec circa 2018 requires new approaches. + +Consider these five areas. + +### Automation + +Lots of automation is a hallmark of DevOps generally. It’s partly about speed. If you’re going to move fast (and not break things), you need to have repeatable processes that execute without a lot of human intervention. Indeed, automation is one of the best entry points for DevOps, even in organizations that are still mostly working on monolithic legacy apps. Automating routine processes associated with configurations or testing with easy-to-use tools such as [Ansible][7] is a common quick hit for starting down the path to DevOps. + +DevSecOps is no different. Security today is a continuous process rather than a discrete checkpoint in the application lifecycle, or even a weekly or monthly check. When vulnerabilities are found and fixes issued by a vendor, it’s important they be applied quickly given that exploits taking advantage of those vulnerabilities will be out soon. + +### "Shift left" + +Traditional security is often viewed as a gatekeeper at the end of the development process. Check all the boxes and your app goes into production. Otherwise, try again. Security teams have a reputation for saying no a lot. + +Therefore, the thinking goes, why not move security earlier (left in a typical left-to-right drawing of a development pipeline)? Security may still say no, but the consequences of rework in early-stage development are a lot less than they are when the app is complete and ready to ship. + +I don’t like the “shift left” term, though. It implies that security is still a one-time event that’s just been moved earlier. Security needs to be a largely automated process everywhere in the application lifecycle, from the supply chain to the development and test process all the way through deployment. + +### Manage dependencies + +One of the big changes we see with modern app development is that you often don’t write most of the code. Using open source libraries and frameworks is one obvious case in point. But you may also just use external services from public cloud providers or other sources. In many cases, this external code and services will dwarf what you write yourself. + +As a result, DevSecOps needs to include a serious focus on your [software supply chain][8]. Are you getting your software from trusted sources? Is it up to date? Is it integrated into the security processes that you use for your own code? What policies do you have in place for which code and APIs you can use? Is commercial support available for the components that you are using for your own production code? + +No set of answers are going to be appropriate in all cases. They may be different for a proof-of-concept versus an at-scale production workload. But, as has been the case in manufacturing for a long time (and DevSecOps has many analogs in how manufacturing has evolved), the integrity of the supply chain is critical. + +### Visibility + +I’ve talked a lot about the need for automation throughout all the stages of the application lifecycle. That makes the assumption that we can see what’s going on in each of those stages. + +Effective DevSecOps requires effective instrumentation so that automation knows what to do. This instrumentation falls into a number of categories. There are long-term and high-level metrics that help tell us if the overall DevSecOps process is working well. There are critical alerts that require immediate human intervention (the security scanning system is down!). There are alerts, such as for a failed scan, that require remediation. And there are logs of the many parameters we capture for later analysis (what’s changing over time? What caused that failure?). + +### Services vs. monoliths + +While DevSecOps practices can be applied across many types of application architectures, they’re most effective with small and loosely coupled components that can be updated and reused without potentially forcing changes elsewhere in the app. In their purest form, these components can be [microservices][9] or functions, but the general principles apply wherever you have loosely coupled services communicating over a network. + +This pattern does introduce some new security challenges. The interactions between components can be complex and the total attack surface can be larger because there are now more entry points to the application across the network. + +On the other hand, this type of architecture also means that automated security and monitoring also has more granular visibility into the application components because they’re no longer buried deep within a monolithic application. + +Don’t get too wrapped up in the DevSecOps term, but take it as a reminder that security is evolving because the way that we write and deploy applications is evolving. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/devsecops-changes-security + +作者:[Gordon Haff][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ghaff +[1]: https://opensource.com/resources/devops +[2]: https://opensource.com/tags/devops +[3]: https://opensource.com/article/18/5/steps-apply-devops-culture-beyond-it +[4]: https://www.devsecopsdays.com/articles/its-just-a-name +[5]: https://opensource.com/article/18/4/devsecops +[6]: https://opensource.com/article/18/6/where-cycle-security-devops +[7]: https://opensource.com/tags/ansible +[8]: https://opensource.com/article/17/1/be-open-source-supply-chain +[9]: https://opensource.com/tags/microservices From 2f5be6776d34eb78ecb1ce3219f41770e4a09f84 Mon Sep 17 00:00:00 2001 From: sd886393 Date: Fri, 21 Sep 2018 14:44:52 +0800 Subject: [PATCH 350/455] =?UTF-8?q?=E5=AE=8C=E6=88=90FreeResourcesForSecur?= =?UTF-8?q?ingYourOpenSourceCode=20=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rces for Securing Your Open Source Code.md | 83 +++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 translated/tech/20180522 Free Resources for Securing Your Open Source Code.md diff --git a/translated/tech/20180522 Free Resources for Securing Your Open Source Code.md b/translated/tech/20180522 Free Resources for Securing Your Open Source Code.md new file mode 100644 index 0000000000..4e63a64e43 --- /dev/null +++ b/translated/tech/20180522 Free Resources for Securing Your Open Source Code.md @@ -0,0 +1,83 @@ +一些提高你开源源码安全性的工具 +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-security.jpg?itok=R3M5LDrb) + +虽然目前开源依然发展势头较好,并被广大的厂商所采用,然而最近由 Black Duck 和 Synopsys 发布的[2018开源安全与风险评估报告][1]指出了一些存在的风险并重点阐述了对于健全安全措施的需求。这份报告的分析资料素材来自经过脱敏后的 1100 个商业代码库,这些代码所涉及:自动化、大数据、企业级软件、金融服务业、健康医疗、物联网、制造业等多个领域。 + +这份报告强调开源软件正在被大量的使用,扫描结果中有 96% 的应用都使用了开源组件。然而,报告还指出许多其中存在很多漏洞。具体在 [这里][2]: + + * 令人担心的是扫描的所有结果中,有 78% 的代码库存在至少一个开源的漏洞,平均每个代码库有 64 个漏洞。 + + * 在经过代码审计过后代码库中,发现超过 54% 的漏洞经验证是高危漏洞。 + + * 17% 的代码库包括一种已经早已公开的漏洞,包括:Heartbleed、Logjam、Freak、Drown、Poddle。 + + + + +Tim Mackey,Synopsys 旗下 Black Duck 的技术负责人称,"这份报告清楚的阐述了:随着开源软件正在被企业广泛的使用,企业与组织也应当使用一些工具来检测可能出现在这些开源软件中的漏洞,并且管理其所使用的开源软件的方式是否符合相应的许可证规则" + +确实,随着越来越具有影响力的安全威胁出现,历史上从未有过我们目前对安全工具和实践的需求。大多数的组织已经意识到网络与系统管理员需要具有相应的较强的安全技能和安全证书。[在这篇文章中,][3] 我们给出一些具有较大影响力的工具、认证和实践。 + +Linux 基金会已经在安全方面提供了许多关于安全的信息与教育资源。比如,Linux 社区提供许多免费的用来针对一些平台的工具,其中[Linux 服务器安全检查表][4] 其中提到了很多有用的基础信息。线上的一些发表刊物也可以提升用户针对某些平台对于漏洞的保护,如:[Fedora 安全指南][5],[Debian 安全手册][6]。 + +目前被广泛使用的私有云平台 OpenStack 也加强了关于基于云的智能安全需求。根据 Linux 基金会发布的 [公有云指南][7]:“据 Gartner 的调研结果,尽管公有云的服务商在安全和审查方面做的都还不错,安全问题是企业考虑向公有云转移的最重要的考量之一” + +无论是对于组织还是个人,千里之堤毁于蚁穴,这些“蚁穴”无论是来自路由器、防火墙、VPNs或虚拟机都可能导致灾难性的后果。以下是一些免费的工具可能对于检测这些漏洞提供帮助: + + * [Wireshark][8], 流量包分析工具 + + * [KeePass Password Safe][9], 免费开源的密码管理器 + + * [Malwarebytes][10], 免费的反病毒和勒索软件工具 + + * [NMAP][11], 安全扫描器 + + * [NIKTO][12], 开源 web 扫描器 + + * [Ansible][13], 自动化的配置运维工具,可以辅助做安全基线 + + * [Metasploit][14], 渗透测试工具,可辅助理解攻击向量 + + + +这里有一些对上面工具讲解的视频。比如[Metasploit 教学][15]、[Wireshark 教学][16]。还有一些传授安全技能的免费电子书,比如:由 Ibrahim Haddad 博士和 Linux 基金会共同出版的[并购过程中的开源审计][17],里面阐述了多条在技术平台合并过程中,因没有较好的进行开源审计,从而引发的安全问题。当然,书中也记录了如何在这一过程中进行代码合规检查、准备以及文档编写。 + +同时,我们 [之前提到的一个免费的电子书][18], 由来自[The New Stack][19] 编写的“Docker与容器中的网络、安全和存储”,里面也提到了关于加强容器网络安全的最新技术,以及Docker本身可提供的关于,提升其网络的安全与效率的最佳实践。这本电子书还记录了关于如何构建安全容器集群的最佳实践。 + +所有这些工具和资源,可以在很大的程度上预防安全问题,正如人们所说的未雨绸缪,考虑到一直存在的安全问题,现在就应该开始学习这些安全合规资料与工具。 +想要了解更多的安全、合规以及开源项目问题,点击[这里][20] + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/2018/5/free-resources-securing-your-open-source-code + +作者:[Sam Dean][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/sd886393) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/sam-dean +[1]:https://www.blackducksoftware.com/open-source-security-risk-analysis-2018 +[2]:https://www.prnewswire.com/news-releases/synopsys-report-finds-majority-of-software-plagued-by-known-vulnerabilities-and-license-conflicts-as-open-source-adoption-soars-300648367.html +[3]:https://www.linux.com/blog/sysadmin-ebook/2017/8/future-proof-your-sysadmin-career-locking-down-security +[4]:http://go.linuxfoundation.org/ebook_workstation_security +[5]:https://docs.fedoraproject.org/en-US/Fedora/19/html/Security_Guide/index.html +[6]:https://www.debian.org/doc/manuals/securing-debian-howto/index.en.html +[7]:https://www.linux.com/publications/2016-guide-open-cloud +[8]:https://www.wireshark.org/ +[9]:http://keepass.info/ +[10]:https://www.malwarebytes.com/ +[11]:http://searchsecurity.techtarget.co.uk/tip/Nmap-tutorial-Nmap-scan-examples-for-vulnerability-discovery +[12]:https://cirt.net/Nikto2 +[13]:https://www.ansible.com/ +[14]:https://www.metasploit.com/ +[15]:http://www.computerweekly.com/tutorial/The-Metasploit-Framework-Tutorial-PDF-compendium-Your-ready-reckoner +[16]:https://www.youtube.com/watch?v=TkCSr30UojM +[17]:https://www.linuxfoundation.org/resources/open-source-audits-merger-acquisition-transactions/ +[18]:https://www.linux.com/news/networking-security-storage-docker-containers-free-ebook-covers-essentials +[19]:http://thenewstack.io/ebookseries/ +[20]:https://www.linuxfoundation.org/projects/security-compliance/ From 1ac6e2b39ca1365ba59136d0f955d7d058070579 Mon Sep 17 00:00:00 2001 From: sd886393 Date: Fri, 21 Sep 2018 14:52:07 +0800 Subject: [PATCH 351/455] =?UTF-8?q?=E5=AE=8C=E6=88=90FreeResourcesForSecur?= =?UTF-8?q?ingYourOpenSourceCode=20=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rces for Securing Your Open Source Code.md | 84 ------------------- 1 file changed, 84 deletions(-) delete mode 100644 sources/tech/20180522 Free Resources for Securing Your Open Source Code.md diff --git a/sources/tech/20180522 Free Resources for Securing Your Open Source Code.md b/sources/tech/20180522 Free Resources for Securing Your Open Source Code.md deleted file mode 100644 index 1480f3102d..0000000000 --- a/sources/tech/20180522 Free Resources for Securing Your Open Source Code.md +++ /dev/null @@ -1,84 +0,0 @@ -sd886393 is dragging this out to translating -Free Resources for Securing Your Open Source Code -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/open-security.jpg?itok=R3M5LDrb) - -While the widespread adoption of open source continues at a healthy rate, the recent [2018 Open Source Security and Risk Analysis Report][1] from Black Duck and Synopsys reveals some common concerns and highlights the need for sound security practices. The report examines findings from the anonymized data of over 1,100 commercial codebases with represented Industries from automotive, Big Data, enterprise software, financial services, healthcare, IoT, manufacturing, and more. - -The report highlights a massive uptick in open source adoption, with 96 percent of the applications scanned containing open source components. However, the report also includes warnings about existing vulnerabilities. Among the [findings][2]: - - * “What is worrisome is that 78 percent of the codebases examined contained at least one open source vulnerability, with an average 64 vulnerabilities per codebase.” - - * “Over 54 percent of the vulnerabilities found in audited codebases are considered high-risk vulnerabilities.” - - * Seventeen percent of the codebases contained a highly publicized vulnerability such as Heartbleed, Logjam, Freak, Drown, or Poodle. - - - - -"The report clearly demonstrates that with the growth in open source use, organizations need to ensure they have the tools to detect vulnerabilities in open source components and manage whatever license compliance their use of open source may require," said Tim Mackey, technical evangelist at Black Duck by Synopsys. - -Indeed, with ever more impactful security threats emerging,the need for fluency with security tools and practices has never been more pronounced. Most organizations are aware that network administrators and sysadmins need to have strong security skills, and, in many cases security certifications. [In this article,][3] we explored some of the tools, certifications and practices that many of them wisely embrace. - -The Linux Foundation has also made available many informational and educational resources on security. Likewise, the Linux community offers many free resources for specific platforms and tools. For example, The Linux Foundation has published a [Linux workstation security checklist][4] that covers a lot of good ground. Online publications ranging from the [Fedora security guide][5] to the[Securing Debian Manual][6] can also help users protect against vulnerabilities within specific platforms. - -The widespread use of cloud platforms such as OpenStack is also stepping up the need for cloud-centric security smarts. According to The Linux Foundation’s[Guide to the Open Cloud][7]: “Security is still a top concern among companies considering moving workloads to the public cloud, according to Gartner, despite a strong track record of security and increased transparency from cloud providers. Rather, security is still an issue largely due to companies’ inexperience and improper use of cloud services.” - -For both organizations and individuals, the smallest holes in implementation of routers, firewalls, VPNs, and virtual machines can leave room for big security problems. Here is a collection of free tools that can plug these kinds of holes: - - * [Wireshark][8], a packet analyzer - - * [KeePass Password Safe][9], a free open source password manager - - * [Malwarebytes][10], a free anti-malware and antivirus tool - - * [NMAP][11], a powerful security scanner - - * [NIKTO][12], an open source web server scanner - - * [Ansible][13], a tool for automating secure IT provisioning - - * [Metasploit][14], a tool for understanding attack vectors and doing penetration testing - - - - -Instructional videos abound for these tools. You’ll find a whole[tutorial series][15] for Metasploit, and [video tutorials][16] for Wireshark. Quite a few free ebooks provide good guidance on security as well. For example, one of the common ways for security threats to invade open source platforms occurs in M&A scenarios, where technology platforms are merged—often without proper open source audits. In an ebook titled [Open Source Audits in Merger and Acquisition Transactions][17], from Ibrahim Haddad and The Linux Foundation, you’ll find an overview of the open source audit process and important considerations for code compliance, preparation, and documentation. - -Meanwhile, we’ve[previously covered][18] a free ebook from the editors at[The New Stack][19] called Networking, Security & Storage with Docker & Containers. It covers the latest approaches to secure container networking, as well as native efforts by Docker to create efficient and secure networking practices. The ebook is loaded with best practices for locking down security at scale. - -All of these tools and resources, and many more, can go a long way toward preventing security problems, and an ounce of prevention is, as they say, worth a pound of cure. With security breaches continuing, now is an excellent time to look into the many security and compliance resources for open source tools and platforms available. Learn more about security, compliance, and open source project health [here][20]. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/2018/5/free-resources-securing-your-open-source-code - -作者:[Sam Dean][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/sam-dean -[1]:https://www.blackducksoftware.com/open-source-security-risk-analysis-2018 -[2]:https://www.prnewswire.com/news-releases/synopsys-report-finds-majority-of-software-plagued-by-known-vulnerabilities-and-license-conflicts-as-open-source-adoption-soars-300648367.html -[3]:https://www.linux.com/blog/sysadmin-ebook/2017/8/future-proof-your-sysadmin-career-locking-down-security -[4]:http://go.linuxfoundation.org/ebook_workstation_security -[5]:https://docs.fedoraproject.org/en-US/Fedora/19/html/Security_Guide/index.html -[6]:https://www.debian.org/doc/manuals/securing-debian-howto/index.en.html -[7]:https://www.linux.com/publications/2016-guide-open-cloud -[8]:https://www.wireshark.org/ -[9]:http://keepass.info/ -[10]:https://www.malwarebytes.com/ -[11]:http://searchsecurity.techtarget.co.uk/tip/Nmap-tutorial-Nmap-scan-examples-for-vulnerability-discovery -[12]:https://cirt.net/Nikto2 -[13]:https://www.ansible.com/ -[14]:https://www.metasploit.com/ -[15]:http://www.computerweekly.com/tutorial/The-Metasploit-Framework-Tutorial-PDF-compendium-Your-ready-reckoner -[16]:https://www.youtube.com/watch?v=TkCSr30UojM -[17]:https://www.linuxfoundation.org/resources/open-source-audits-merger-acquisition-transactions/ -[18]:https://www.linux.com/news/networking-security-storage-docker-containers-free-ebook-covers-essentials -[19]:http://thenewstack.io/ebookseries/ -[20]:https://www.linuxfoundation.org/projects/security-compliance/ From c155c5d5cd69e2490702c4131c4ae19c5ab2155d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 21 Sep 2018 16:12:25 +0800 Subject: [PATCH 352/455] PRF:20180906 Two open source alternatives to Flash Player.md @geekpi --- ...pen source alternatives to Flash Player.md | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/translated/tech/20180906 Two open source alternatives to Flash Player.md b/translated/tech/20180906 Two open source alternatives to Flash Player.md index 0126bf950a..1d0911abcd 100644 --- a/translated/tech/20180906 Two open source alternatives to Flash Player.md +++ b/translated/tech/20180906 Two open source alternatives to Flash Player.md @@ -1,33 +1,33 @@ Flash Player 的两种开源替代方案 ====== +> Adobe 将于 2020 年终止对 Flash 媒体播放器的支持,但仍有很多人们希望访问的 Flash 视频。这里有两个开源的替代品或许可以帮到你。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bulb-light-energy-power-idea.png?itok=zTEEmTZB) -2017 年 7 月,Adobe 为 Flash Media Player 敲响了[丧钟][1],宣布将在 2020 年终止对曾经无处不在的在线视频播放器的支持。但事实上,在一系列损害了其声誉的零日攻击后,Flash 的份额在过去的 8 年一直在下跌。苹果公司在 2010 年宣布它不会支持这项技术后,其未来趋于黯淡,并且在谷歌停止在 Chrome 浏览器中默认启用 Flash(支持 HTML5)后,它的消亡在 2016 年加速。 +2017 年 7 月,Adobe 为 Flash Media Player 敲响了[丧钟][1],宣布将在 2020 年终止对曾经无处不在的在线视频播放器的支持。但事实上,在一系列损害了其声誉的零日攻击后,Flash 的份额在过去的 8 年一直在下跌。苹果公司在 2010 年宣布它不会支持这项技术后,其未来趋于黯淡,并且在谷歌停止在 Chrome 浏览器中默认启用 Flash(支持 HTML5)后,它的消亡在 2016 年进一步加速。 即便如此,Adobe 仍然每月发布该软件的更新,截至 2018 年 8 月,它在网站的使用率从 2011 年的 28.5% 下降到[仅 4.4%] [2]。还有更多证据表明 Flash 的下滑:谷歌工程总监 [Parisa Tabriz 说][3]通过浏览器访问 Flash 内容的 Chrome 用户数量从 2014 年的 80% 下降到 2018 年的 8%。 -尽管如今很少有视频创作者以 Flash 格式发布,但仍有很多人们希望在未来几年内访问的 Flash 视频。鉴于官方支持的日期已经屈指可数,开源软件创建者有很好的机会介入 Adobe Flash Media Player 的替代品。这其中两个应用是 Lightspark 和 GNU Gnash。它们都不是完美的替代品,但来自贡献者的帮助可以使它们成为可行的替代品。 +尽管如今很少有视频创作者以 Flash 格式发布,但仍有很多人们希望在未来几年内访问的 Flash 视频。鉴于官方支持的日期已经屈指可数,开源软件创建者有很好的机会涉足 Adobe Flash 媒体播放器的替代品。这其中两个应用是 Lightspark 和 GNU Gnash。它们都不是完美的替代品,但来自贡献者的帮助可以使它们成为可行的替代品。 ### Lightspark [Lightspark][4] 是 Linux 上的 Flash Player 替代品。虽然它仍处于 alpha 状态,但自从 Adobe 在 2017 宣布废弃 Adobe 以来,开发速度已经加快。据其网站称,Lightspark 实现了 60% 的 Flash API,可在许多流行网站包括 BBC 新闻、Google Play 音乐和亚马逊音乐上[使用][5]。 -Lightspark 是用 C++/C 编写的,并在 [LGPLv3][6] 下许可。该项目列出了 41 个贡献者,并正在积极征求错误报告和其他贡献。有关更多信息,请查看其[ GitHub 仓库][5]。 +Lightspark 是用 C++/C 编写的,并在 [LGPLv3][6] 下许可。该项目列出了 41 个贡献者,并正在积极征求错误报告和其他贡献。有关更多信息,请查看其 [GitHub 仓库][5]。 ### GNU Gnash [GNU Gnash][7] 是一个用于 GNU/Linux 操作系统,包括 Ubuntu、Fedora 和 Debian 的 Flash Player。它作为独立软件和插件可用于 Firefox 和 Konqueror 浏览器中。 -Gnash 的主要缺点是它不支持最新版本的 Flash 文件 - 它支持大多数 Flash SWF v7 功能,一些 v8 和 v9 功能,不支持 v10 文件。它处于测试阶段,由于它在[ GNU GPLv3 或更高版本][8]下许可,因此你可以帮助实现它的现代化。访问其[项目页面][9]获取更多信息。 +Gnash 的主要缺点是它不支持最新版本的 Flash 文件 —— 它支持大多数 Flash SWF v7 功能,一些 v8 和 v9 功能,不支持 v10 文件。它处于测试阶段,由于它在 [GNU GPLv3 或更高版本][8]下许可,因此你可以帮助实现它的现代化。访问其[项目页面][9]获取更多信息。 -### 想要创建Flash吗? +### 想要创建 Flash 吗? -* 仅因为大多数人都不会发布 Flash 视频,但这并不意味着永远不需要创建 SWF 文件。如果你发现自己需要,这两个开源工具可能会有所帮助: - - * [Motion-Twin ActionScript 2 编译器][10](MTASC):一个命令行编译器,它可以在没有 Adobe Animate(Adobe 当前的视频创建软件)的情况下生成 SWF 文件。 -  * [Ming][11]:用 C 编写的可以生成 SWF 文件的库。它还包含一些可用于处理 Flash 的[程序][12]。 +仅因为大多数人都不会发布 Flash 视频,但这并不意味着永远不需要创建 SWF 文件。如果你发现自己需要,这两个开源工具可能会有所帮助: +* [Motion-Twin ActionScript 2 编译器][10](MTASC):一个命令行编译器,它可以在没有 Adobe Animate(Adobe 当前的视频创建软件)的情况下生成 SWF 文件。 +* [Ming][11]:用 C 编写的可以生成 SWF 文件的库。它还包含一些可用于处理 Flash 的[程序][12]。 -------------------------------------------------------------------------------- @@ -37,7 +37,7 @@ via: https://opensource.com/alternatives/flash-media-player 作者:[Opensource.com][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 215c2c0b6708cb7a52870ce06567baf95993b529 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 21 Sep 2018 16:12:46 +0800 Subject: [PATCH 353/455] PUB:20180906 Two open source alternatives to Flash Player.md @geekpi https://linux.cn/article-10035-1.html --- .../20180906 Two open source alternatives to Flash Player.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180906 Two open source alternatives to Flash Player.md (100%) diff --git a/translated/tech/20180906 Two open source alternatives to Flash Player.md b/published/20180906 Two open source alternatives to Flash Player.md similarity index 100% rename from translated/tech/20180906 Two open source alternatives to Flash Player.md rename to published/20180906 Two open source alternatives to Flash Player.md From 13c2ddcb3eb338e822728c436c8ce729a933f429 Mon Sep 17 00:00:00 2001 From: belitex Date: Fri, 21 Sep 2018 19:31:09 +0800 Subject: [PATCH 354/455] =?UTF-8?q?[=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90]?= =?UTF-8?q?=20How=20to=20get=20into=20DevOps=20=E5=88=9D=E7=A8=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../talk/20180117 How to get into DevOps.md | 144 ----------------- .../talk/20180117 How to get into DevOps.md | 145 ++++++++++++++++++ 2 files changed, 145 insertions(+), 144 deletions(-) delete mode 100644 sources/talk/20180117 How to get into DevOps.md create mode 100644 translated/talk/20180117 How to get into DevOps.md diff --git a/sources/talk/20180117 How to get into DevOps.md b/sources/talk/20180117 How to get into DevOps.md deleted file mode 100644 index 184b18b1d1..0000000000 --- a/sources/talk/20180117 How to get into DevOps.md +++ /dev/null @@ -1,144 +0,0 @@ -belitex 翻译中 -How to get into DevOps -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_resume_rh1x.png?itok=S3HGxi6E) - -I've observed a sharp uptick of developers and systems administrators interested in "getting into DevOps" within the past year or so. This pattern makes sense: In an age in which a single developer can spin up a globally distributed infrastructure for an application with a few dollars and a few API calls, the gap between development and systems administration is closer than ever. Although I've seen plenty of blog posts and articles about cool DevOps tools and thoughts to think about, I've seen fewer content on pointers and suggestions for people looking to get into this work. - -My goal with this article is to draw what that path looks like. My thoughts are based upon several interviews, chats, late-night discussions on [reddit.com/r/devops][1], and random conversations, likely over beer and delicious food. I'm also interested in hearing feedback from those who have made the jump; if you have, please reach out through [my blog][2], [Twitter][3], or in the comments below. I'd love to hear your thoughts and stories. - -### Olde world IT - -Understanding history is key to understanding the future, and DevOps is no exception. To understand the pervasiveness and popularity of the DevOps movement, understanding what IT was like in the late '90s and most of the '00s is helpful. This was my experience. - -I started my career in late 2006 as a Windows systems administrator in a large, multi-national financial services firm. In those days, adding new compute involved calling Dell (or, in our case, CDW) and placing a multi-hundred-thousand-dollar order of servers, networking equipment, cables, and software, all destined for your on- and offsite datacenters. Although VMware was still convincing companies that using virtual machines was, indeed, a cost-effective way of hosting its "performance-sensitive" application, many companies, including mine, pledged allegiance to running applications on their physical hardware. - -Our technology department had an entire group dedicated to datacenter engineering and operations, and its job was to negotiate our leasing rates down to some slightly less absurd monthly rate and ensure that our systems were being cooled properly (an exponentially difficult problem if you have enough equipment). If the group was lucky/wealthy enough, the offshore datacenter crew knew enough about all of our server models to not accidentally pull the wrong thing during after-hours trading. Amazon Web Services and Rackspace were slowly beginning to pick up steam, but were far from critical mass. - -In those days, we also had teams dedicated to ensuring that the operating systems and software running on top of that hardware worked when they were supposed to. The engineers were responsible for designing reliable architectures for patching, monitoring, and alerting these systems as well as defining what the "gold image" looked like. Most of this work was done with a lot of manual experimentation, and the extent of most tests was writing a runbook describing what you did, and ensuring that what you did actually did what you expected it to do after following said runbook. This was important in a large organization like ours, since most of the level 1 and 2 support was offshore, and the extent of their training ended with those runbooks. - -(This is the world that your author lived in for the first three years of his career. My dream back then was to be the one who made the gold standard!) - -Software releases were another beast altogether. Admittedly, I didn't gain a lot of experience working on this side of the fence. However, from stories that I've gathered (and recent experience), much of the daily grind for software development during this time went something like this: - - * Developers wrote code as specified by the technical and functional requirements laid out by business analysts from meetings they weren't invited to. - * Optionally, developers wrote unit tests for their code to ensure that it didn't do anything obviously crazy, like try to divide over zero without throwing an exception. - * When done, developers would mark their code as "Ready for QA." A quality assurance person would pick up the code and run it in their own environment, which might or might not be like production or even the environment the developer used to test their own code against. - * Failures would get sent back to the developers within "a few days or weeks" depending on other business activities and where priorities fell. - - - -Although sysadmins and developers didn't often see eye to eye, the one thing they shared a common hatred for was "change management." This was a composition of highly regulated (and in the case of my employer at the time), highly necessary rules and procedures governing when and how technical changes happened in a company. Most companies followed [ITIL][4] practices, which, in a nutshell, asked a lot of questions around why, when, where, and how things happened and provided a process for establishing an audit trail of the decisions that led up to those answers. - -As you could probably gather from my short history lesson, many, many things were done manually in IT. This led to a lot of mistakes. Lots of mistakes led up to lots of lost revenue. Change management's job was to minimize those lost revenues; this usually came in the form of releases only every two weeks and changes to servers, regardless of their impact or size, queued up to occur between Friday at 4 p.m. and Monday at 5:59 a.m. (Ironically, this batching of work led to even more mistakes, usually more serious ones.) - -### DevOps isn't a Tiger Team - -You might be thinking "What is Carlos going on about, and when is he going to talk about Ansible playbooks?" I love Ansible tons, but hang on; this is important. - -Have you ever been assigned to a project where you had to interact with the "DevOps" team? Or did you have to rely on a "configuration management" or "CI/CD" team to ensure your pipeline was set up properly? Have you had to attend meetings about your release and what it pertains to--weeks after the work was marked "code complete"? - -If so, then you're reliving history. All of that comes from all of the above. - -[Silos form][5] out of an instinctual draw to working with people like ourselves. Naturally, it's no surprise that this human trait also manifests in the workplace. I even saw this play out at a 250-person startup where I used to work. When I started, developers all worked in common pods and collaborated heavily with each other. As the codebase grew in complexity, developers who worked on common features naturally aligned with each other to try and tackle the complexity within their own feature. Soon afterwards, feature teams were officially formed. - -Sysadmins and developers at many of the companies I worked at not only formed natural silos like this, but also fiercely competed with each other. Developers were mad at sysadmins when their environments were broken. Developers were mad at sysadmins when their environments were too locked down. Sysadmins were mad that developers were breaking their environments in arbitrary ways all of the time. Sysadmins were mad at developers for asking for way more computing power than they needed. Neither side understood each other, and worse yet, neither side wanted to. - -Most developers were uninterested in the basics of operating systems, kernels, or, in some cases, computer hardware. As well, most sysadmins, even Linux sysadmins, took a 10-foot pole approach to learning how to code. They tried a bit of C in college, hated it and never wanted to touch an IDE again. Consequently, developers threw their environment problems over the wall to sysadmins, sysadmins prioritized them with the hundreds of other things that were thrown over the wall to them, and everyone busy-waited angrily while hating each other. The purpose of DevOps was to put an end to this. - -DevOps isn't a team. CI/CD isn't a group in Jira. DevOps is a way of thinking. According to the movement, in an ideal world, developers, sysadmins, and business stakeholders would be working as one team. While they might not know everything about each other's worlds, not only do they all know enough to understand each other and their backlogs, but they can, for the most part, speak the same language. - -This is the basis behind having all infrastructure and business logic be in code and subject to the same deployment pipelines as the software that sits on top of it. Everybody is winning because everyone understands each other. This is also the basis behind the rise of other tools like chatbots and easily accessible monitoring and graphing. - -[Adam Jacob said][6] it best: "DevOps is the word we will use to describe the operational side of the transition to enterprises being software led." - -### What do I need to know to get into DevOps? - -I'm commonly asked this question, and the answer, like most open-ended questions like this, is: It depends. - -At the moment, the "DevOps engineer" varies from company to company. Smaller companies that have plenty of software developers but fewer folks that understand infrastructure will likely look for people with more experience administrating systems. Other, usually larger and/or older companies that have a solid sysadmin organization will likely optimize for something closer to a [Google site reliability engineer][7], i.e. "a software engineer to design an operations function." This isn't written in stone, however, as, like any technology job, the decision largely depends on the hiring manager sponsoring it. - -That said, we typically look for engineers who are interested in learning more about: - - * How to administrate and architect secure and scalable cloud platforms (usually on AWS, but Azure, Google Cloud Platform, and PaaS providers like DigitalOcean and Heroku are popular too); - * How to build and optimize deployment pipelines and deployment strategies on popular [CI/CD][8] tools like Jenkins, Go continuous delivery, and cloud-based ones like Travis CI or CircleCI; - * How to monitor, log, and alert on changes in your system with timeseries-based tools like Kibana, Grafana, Splunk, Loggly, or Logstash; and - * How to maintain infrastructure as code with configuration management tools like Chef, Puppet, or Ansible, as well as deploy said infrastructure with tools like Terraform or CloudFormation. - - - -Containers are becoming increasingly popular as well. Despite the [beef against the status quo][9] surrounding Docker at scale, containers are quickly becoming a great way of achieving an extremely high density of services and applications running on fewer systems while increasing their reliability. (Orchestration tools like Kubernetes or Mesos can spin up new containers in seconds if the host they're being served by fails.) Given this, having knowledge of Docker or rkt and an orchestration platform will go a long way. - -If you're a systems administrator that's looking to get into DevOps, you will also need to know how to write code. Python and Ruby are popular languages for this purpose, as they are portable (i.e., can be used on any operating system), fast, and easy to read and learn. They also form the underpinnings of the industry's most popular configuration management tools (Python for Ansible, Ruby for Chef and Puppet) and cloud API clients (Python and Ruby are commonly used for AWS, Azure, and Google Cloud Platform clients). - -If you're a developer looking to make this change, I highly recommend learning more about Unix, Windows, and networking fundamentals. Even though the cloud abstracts away many of the complications of administrating a system, debugging slow application performance is aided greatly by knowing how these things work. I've included a few books on this topic in the next section. - -If this sounds overwhelming, you aren't alone. Fortunately, there are plenty of small projects to dip your feet into. One such toy project is Gary Stafford's Voter Service, a simple Java-based voting platform. We ask our candidates to take the service from GitHub to production infrastructure through a pipeline. One can combine that with Rob Mile's awesome DevOps Tutorial repository to learn about ways of doing this. - -Another great way of becoming familiar with these tools is taking popular services and setting up an infrastructure for them using nothing but AWS and configuration management. Set it up manually first to get a good idea of what to do, then replicate what you just did using nothing but CloudFormation (or Terraform) and Ansible. Surprisingly, this is a large part of the work that we infrastructure devs do for our clients on a daily basis. Our clients find this work to be highly valuable! - -### Books to read - -If you're looking for other resources on DevOps, here are some theory and technical books that are worth a read. - -#### Theory books - - * [The Phoenix Project][10] by Gene Kim. This is a great book that covers much of the history I explained earlier (with much more color) and describes the journey to a lean company running on agile and DevOps. - * [Driving Technical Change][11] by Terrance Ryan. Awesome little book on common personalities within most technology organizations and how to deal with them. This helped me out more than I expected. - * [Peopleware][12] by Tom DeMarco and Tim Lister. A classic on managing engineering organizations. A bit dated, but still relevant. - * [Time Management for System Administrators][13] by Tom Limoncelli. While this is heavily geared towards sysadmins, it provides great insight into the life of a systems administrator at most large organizations. If you want to learn more about the war between sysadmins and developers, this book might explain more. - * [The Lean Startup][14] by Eric Ries. Describes how Eric's 3D avatar company, IMVU, discovered how to work lean, fail fast, and find profit faster. - * [Lean Enterprise][15] by Jez Humble and friends. This book is an adaption of The Lean Startup for the enterprise. Both are great reads and do a good job of explaining the business motivation behind DevOps. - * [Infrastructure As Code][16] by Kief Morris. Awesome primer on, well, infrastructure as code! It does a great job of describing why it's essential for any business to adopt this for their infrastructure. - * [Site Reliability Engineering][17] by Betsy Beyer, Chris Jones, Jennifer Petoff, and Niall Richard Murphy. A book explaining how Google does SRE, or also known as "DevOps before DevOps was a thing." Provides interesting opinions on how to handle uptime, latency, and keeping engineers happy. - - - -#### Technical books - -If you're looking for books that'll take you straight to code, you've come to the right section. - - * [TCP/IP Illustrated][18] by the late W. Richard Stevens. This is the classic (and, arguably, complete) tome on the fundamental networking protocols, with special emphasis on TCP/IP. If you've heard of Layers 1, 2, 3, and 4 and are interested in learning more, you'll need this book. - * [UNIX and Linux System Administration Handbook][19] by Evi Nemeth, Trent Hein, and Ben Whaley. A great primer into how Linux and Unix work and how to navigate around them. - * [Learn Windows Powershell In A Month of Lunches][20] by Don Jones and Jeffrey Hicks. If you're doing anything automated with Windows, you will need to learn how to use Powershell. This is the book that will help you do that. Don Jones is a well-known MVP in this space. - * Practically anything by [James Turnbull][21]. He puts out great technical primers on popular DevOps-related tools. - - - -From companies deploying everything to bare metal (there are plenty that still do, for good reasons) to trailblazers doing everything serverless, DevOps is likely here to stay for a while. The work is interesting, the results are impactful, and, most important, it helps bridge the gap between technology and business. It's a wonderful thing to see. - -Originally published at [Neurons Firing on a Keyboard][22], CC-BY-SA. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/getting-devops - -作者:[Carlos Nunez][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/carlosonunez -[1]:https://www.reddit.com/r/devops/ -[2]:https://carlosonunez.wordpress.com/ -[3]:https://twitter.com/easiestnameever -[4]:https://en.wikipedia.org/wiki/ITIL -[5]:https://www.psychologytoday.com/blog/time-out/201401/getting-out-your-silo -[6]:https://twitter.com/adamhjk/status/572832185461428224 -[7]:https://landing.google.com/sre/interview/ben-treynor.html -[8]:https://en.wikipedia.org/wiki/CI/CD -[9]:https://thehftguy.com/2016/11/01/docker-in-production-an-history-of-failure/ -[10]:https://itrevolution.com/book/the-phoenix-project/ -[11]:https://pragprog.com/book/trevan/driving-technical-change -[12]:https://en.wikipedia.org/wiki/Peopleware:_Productive_Projects_and_Teams -[13]:http://shop.oreilly.com/product/9780596007836.do -[14]:http://theleanstartup.com/ -[15]:https://info.thoughtworks.com/lean-enterprise-book.html -[16]:http://infrastructure-as-code.com/book/ -[17]:https://landing.google.com/sre/book.html -[18]:https://en.wikipedia.org/wiki/TCP/IP_Illustrated -[19]:http://www.admin.com/ -[20]:https://www.manning.com/books/learn-windows-powershell-in-a-month-of-lunches-third-edition -[21]:https://jamesturnbull.net/ -[22]:https://carlosonunez.wordpress.com/2017/03/02/getting-into-devops/ diff --git a/translated/talk/20180117 How to get into DevOps.md b/translated/talk/20180117 How to get into DevOps.md new file mode 100644 index 0000000000..ec169be76f --- /dev/null +++ b/translated/talk/20180117 How to get into DevOps.md @@ -0,0 +1,145 @@ + +DevOps 实践指南 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_resume_rh1x.png?itok=S3HGxi6E) + +在去年大概一年的时间里,我注意到对“Devops 实践”感兴趣的开发人员和系统管理员突然有了明显的增加。这样的变化也合理:现在开发者只要花很少的钱,调用一些 API, 就能单枪匹马地在一整套分布式基础设施上运行自己的应用, 在这个时代,开发和运维的紧密程度前所未有。我看过许多博客和文章介绍很酷的 DevOps 工具和相关思想,但是给那些希望践行 DevOps 的人以指导和建议的内容,我却很少看到。 + +这篇文章的目的就是描述一下如何去实践。我的想法基于 Reddit 上 [devops][1] 的一些访谈、聊天和深夜讨论,还有一些随机谈话,一般都发生在享受啤酒和美食的时候。如果你已经开始这样实践,我对你的反馈很感兴趣,请通过 [我的博客][2] 或者 [Twitter][3] 联系我,也可以直接在下面评论。我很乐意听到你们的想法和故事。 + +### 古代的 IT + +了解历史是搞清楚未来的关键,DevOps 也不例外。想搞清楚 DevOps 运动的普及和流行,去了解一下上世纪 90 年代后期和 21 世纪前十年 IT 的情况会有帮助。这是我的经验。 + +我的第一份工作是在一家大型跨国金融服务公司做 Windows 系统管理员。当时给计算资源扩容需要给 Dell 打电话 (或者像我们公司那样打给 CDW ),并下一个价值数十万美元的订单,包含服务器、网络设备、电缆和软件,所有这些都要运到在线或离线的数据中心去。虽然 VMware 仍在尝试说服企业使用虚拟机运行他们的“性能敏感”型程序是更划算的,但是包括我们在内的很多公司都还忠于使用他们的物理机运行应用。 + +在我们技术部门,有一个专门做数据中心工程和操作的完整团队,他们的工作包括价格谈判,让荒唐的租赁月费能够下降一点点,还包括保证我们的系统能够正常冷却(如果设备太多,这个事情的难度会呈指数增长)。如果这个团队足够幸运足够有钱,境外数据中心的工作人员对我们所有的服务器型号又都有足够的了解,就能避免在盘后交易中不小心扯错东西。那时候亚马逊 AWS 和 Rackspace 逐渐开始加速扩张,但还远远没到临界规模。 + +当时我们还有专门的团队来保证硬件上运行着的操作系统和软件能够按照预期工作。这些工程师负责设计可靠的架构以方便给系统打补丁,监控和报警,还要定义基础镜像 (gold image) 的内容。这些大都是通过很多手工实验完成的,很多手工实验是为了编写一个运行说明书 (runbook) 来描述要做的事情,并确保按照它执行后的结果确实在预期内。在我们这么大的组织里,这样做很重要,因为一线和二线的技术支持都是境外的,而他们的培训内容只覆盖到了这些运行说明而已。 + +(这是我职业生涯前三年的世界。我那时候的梦想是成为制定金本位制的人!) + +软件发布则完全是另外一头怪兽。无可否认,我在这方面并没有积累太多经验。但是,从我收集的故事(和最近的经历)来看,当时大部分软件开发的日常大概是这样: + + * 开发人员按照技术和功能需求来编写代码,这些需求来自于业务分析人员的会议,但是会议并没有邀请开发人员参加。 + * 开发人员可以选择为他们的代码编写单元测试,以确保在代码里没有任何明显的疯狂行为,比如除以 0 但不抛出异常。 + * 然后开发者会把他们的代码标记为 "Ready for QA."(准备好了接受测试),质量保障的成员会把这个版本的代码发布到他们自己的环境中,这个环境和生产环境可能相似,也可能不相似,甚至和开发环境相比也不一定相似。 + * 故障会在几天或者几个星期内反馈到开发人员那里,这个时长取决于其他业务活动和优先事项。 + + + +虽然系统管理员和开发人员经常有不一致的意见,但是对“变更管理”的痛恨却是一致的。变更管理由高度规范的(就我当时的雇主而言)和非常有必要的规则和程序组成,用来管理一家公司应该什么时候做技术变更,以及如何做。很多公司都按照 [ITIL][4] 来操作, 简单的说,ITIL 问了很多和事情发生的原因、时间、地点和方式相关的问题,而且提供了一个过程,对产生最终答案的决定做审计跟踪。 + +你可能从我的简短历史课上了解到,当时 IT 的很多很多事情都是手工完成的。这导致了很多错误。错误又导致了很多财产损失。变更管理的工作就是尽量减少这些损失,它常常以这样的形式出现:不管变更的影响和规模大小,每两周才能发布部署一次。周五下午 4 点到周一早上 5 点 59 分这段时间,需要排队等候发布窗口。(讽刺的是,这种流程导致了更多错误,通常还是更严重的那种错误) + +### DevOps 不是专家团 + +你可能在想 "Carlos 你在讲啥啊,什么时候才能说到 Ansible playbooks? ",我热爱 Ansible, 但是请再等一会;下面这些很重要。 + +你有没有过被分配到过需要跟"DevOps"小组打交道的项目?你有没有依赖过“配置管理”或者“持续集成/持续交付”小组来保证业务流水线设置正确?你有没有在代码开发完的数周之后才参加发布部署的会议? + +如果有过,那么你就是在重温历史,这个历史是由上面所有这些导致的。 + +出于本能,我们喜欢和像自己的人一起工作,这会导致[筒仓][5]的行成。很自然,这种人类特质也会在工作场所表现出来是不足为奇的。我甚至在一个 250 人的创业公司里见到过这样的现象,当时我在那里工作。刚开始的时候,开发人员都在聚在一起工作,彼此深度协作。随着代码变得复杂,开发相同功能的人自然就坐到了一起,解决他们自己的复杂问题。然后按功能划分的小组很快就正式形成了。 + +在我工作过的很多公司里,系统管理员和开发人员不仅像这样形成了天然的筒仓,而且彼此还有激烈的对抗。开发人员的环境出问题了或者他们的权限太小了,就会对系统管理员很恼火。系统管理员怪开发者无时不刻的不在用各种方式破坏他们的环境,怪开发人员申请的计算资源严重超过他们的需要。双方都不理解对方,更糟糕的是,双方都不愿意去理解对方。 + +大部分开发人员对操作系统,内核或计算机硬件都不感兴趣。同样的,大部分系统管理员,即使是 Linux 的系统管理员,也都不愿意学习编写代码,他们在大学期间学过一些 C 语言,然后就痛恨它,并且永远都不想再碰 IDE. 所以,开发人员把运行环境的问题甩给围墙外的系统管理员,系统管理员把这些问题和甩过来的其他上百个问题放在一起,做一个优先级安排。每个人都很忙,心怀怨恨的等待着。DevOps 的目的就是解决这种矛盾。 + +DevOps 不是一个团队,CI/CD 也不是 Jira 系统的一个用户组。DevOps 是一种思考方式。根据这个运动来看,在理想的世界里,开发人员、系统管理员和业务相关人将作为一个团队工作。虽然他们可能不完全了解彼此的世界,可能没有足够的知识去了解彼此的积压任务,但他们在大多数情况下能有一致的看法。 + +把所有基础设施和业务逻辑都代码化,再串到一个发布部署流水线里,就像是运行在这之上的应用一样。这个理念的基础就是 DevOps. 因为大家都理解彼此,所以人人都是赢家。聊天机器人和易用的监控工具、可视化工具的兴起,背后的基础也是 DevOps. + +[Adam Jacob][6] 说的最好:"DevOps 就是企业往软件导向型过渡时我们用来描述操作的词" + +### 要实践 DevOps 我需要知道些什么 + +我经常被问到这个问题,它的答案,和同属于开放式的其他大部分问题一样:视情况而定。 + +现在“DevOps 工程师”在不同的公司有不同的含义。在软件开发人员比较多但是很少有人懂基础设施的小公司,他们很可能是在找有更多系统管理经验的人。而其他公司,通常是大公司或老公司或又大又老的公司,已经有一个稳固的系统管理团队了,他们在向类似于谷歌 [SRE][7] 的方向做优化,也就是“设计操作功能的软件工程师”。但是,这并不是金科玉律,就像其他技术类工作一样,这个决定很大程度上取决于他的招聘经理。 + +也就是说,我们一般是在找对深入学习以下内容感兴趣的工程师: + + * 如何管理和设计安全、可扩展的云上的平台(通常是在 AWS 上,不过微软的 Azure, 谷歌的 Cloud Platform,还有 DigitalOcean 和 Heroku 这样的 PaaS 提供商,也都很流行) + * 如何用流行的 [CI/CD][8] 工具,比如 Jenkins,Gocd,还有基于云的 Travis CI 或者 CircleCI,来构造一条优化的发布部署流水线,和发布部署策略。 + * 如何在你的系统中使用基于时间序列的工具,比如 Kibana,Grafana,Splunk,Loggly 或者 Logstash,来监控,记录,并在变化的时候报警,还有 + * 如何使用配置管理工具,例如 Chef,Puppet 或者 Ansible 做到“基础设施即代码”,以及如何使用像 Terraform 或 CloudFormation 的工具发布这些基础设施。 + + + +容器也变得越来越受欢迎。尽管有人对大规模使用 Docker 的现状[表示不满][9],但容器正迅速地成为一种很好的方式来实现在更少的操作系统上运行超高密度的服务和应用,同时提高它们的可靠性。(像 Kubernetes 或者 Mesos 这样的容器编排工具,能在宿主机故障的时候,几秒钟之内重新启动新的容器。)考虑到这些,掌握 Docker 或者 rkt 以及容器编排平台的知识会对你大有帮助。 + +如果你是希望做 DevOps 实践的系统管理员,你还需要知道如何写代码。Python 和 Ruby 是 DevOps 领域的流行语言,因为他们是可移植的(也就是说可以在任何操作系统上运行),快速的,而且易读易学。它们还支撑着这个行业最流行的配置管理工具(Ansible 是使用 Python 写的,Chef 和 Puppet 是使用 Ruby 写的)以及云平台的 API 客户端(亚马逊 AWS, 微软 Azure, 谷歌 Cloud Platform 的客户端通常会提供 Python 和 Ruby 语言的版本)。 + +如果你是开发人员,也希望做 DevOps 的实践,我强烈建议你去学习 Unix,Windows 操作系统以及网络基础知识。虽然云计算把很多系统管理的难题抽象化了,但是对慢应用的性能做 debug 的时候,你知道操作系统如何工作的就会有很大的帮助。下文包含了一些这个主题的图书。 + +如果你觉得这些东西听起来内容太多,大家都是这么想的。幸运的是,有很多小项目可以让你开始探索。其中一个启动项目是 Gary Stafford 的[选举服务](https://github.com/garystafford/voter-service), 一个基于 Java 的简单投票平台。我们要求面试候选人通过一个流水线将该服务从 GitHub 部署到生产环境基础设施上。你可以把这个服务与 Rob Mile 写的了不起的 DevOps [入门教程](https://github.com/maxamg/cd-office-hours)结合起来,学习如何编写流水线。 + +还有一个熟悉这些工具的好方法,找一个流行的服务,然后只使用 AWS 和配置管理工具来搭建这个服务所需要的基础设施。第一次先手动搭建,了解清楚要做的事情,然后只用 CloudFormation (或者 Terraform) 和 Ansible 重写刚才的手动操作。令人惊讶的是,这就是我们基础设施开发人员为客户所做的大部分日常工作,我们的客户认为这样的工作非常有意义! + +### 需要读的书 + +如果你在找 DevOps 的其他资源,下面这些理论和技术书籍值得一读。 + +#### 理论书籍 + + * Gene Kim 写的 [The Phoenix Project (凤凰项目)][10]。这是一本很不错的书,内容涵盖了我上文解释过的历史(写的更生动形象),描述了一个运行在敏捷和 DevOps 之上的公司向精益前进的过程。 + * Terrance Ryan 写的 [Driving Technical Change (布道之道)][11]。非常好的一小本书,讲了大多数技术型组织内的常见性格特点以及如何和他们打交道。这本书对我的帮助比我想象的更多。 + * Tom DeMarco 和 Tim Lister 合著的 [Peopleware (人件)][12]。管理工程师团队的经典图书,有一点过时,但仍然很有价值。 + * Tom Limoncelli 写的 [Time Management for System Administrators (时间管理: 给系统管理员)][13]。这本书主要面向系统管理员,它对很多大型组织内的系统管理员生活做了深入的展示。如果你想了解更多系统管理员和开发人员之间的冲突,这本书可能解释了更多。 + * Eric Ries 写的 [The Lean Startup (精益创业)][14]。描述了 Eric 自己的 3D 虚拟形象公司,IMVU, 发现了如何精益工作,快速失败和更快盈利。 + * Jez Humble 和他的朋友写的[Lean Enterprise (精益企业)][15]。这本书是对精益创业做的改编,以更适应企业,两本书都很棒,都很好的解释了 DevOps 背后的商业动机。 + * Kief Morris 写的 [Infrastructure As Code (基础设施即代码)][16]。关于 "基础设施即代码" 的非常好的入门读物!很好的解释了为什么所有公司都有必要采纳这种做法。 + * Betsy Beyer, Chris Jones, Jennifer Petoff 和 Niall Richard Murphy 合著的 [Site Reliability Engineering (站点可靠性工程师)][17]。一本解释谷歌 SRE 实践的书,也因为是 "DevOps 诞生之前的 DevOps" 被人熟知。在如何处理运行时间、时延和保持工程师快乐方面提供了有趣的看法。 + + + +#### 技术书籍 + +如果你想找的是让你直接跟代码打交道的书,看这里就对了。 + + * W. Richard Stevens 的 [TCP/IP Illustrated (TCP/IP 详解)][18]。这是一套经典的(也可以说是最全面的)讲解基本网络协议的巨著,重点介绍了 TCP/IP 协议族。如果你听说过 1,2, 3,4 层网络,而且对深入学习他们感兴趣,那么你需要这本书。 + * Evi Nemeth, Trent Hein 和 Ben Whaley 合著的 [UNIX and Linux System Administration Handbook (UNIX/Linux 系统管理员手册)][19]。一本很好的入门书,介绍 Linux/Unix 如何工作以及如何使用。 + * Don Jones 和 Jeffrey Hicks 合著的 [Learn Windows Powershell In A Month of Lunches (Windows PowerShell实战指南)][20]. 如果你在 Windows 系统下做自动化任务,你需要学习怎么使用 Powershell。这本书能够帮助你。Don Jones 是这方面著名的 MVP。 + * 几乎所有 [James Turnbull][21] 写的东西,针对流行的 DevOps 工具,他发表了很好的技术入门读物。 + + + +不管是在那些把所有应用都直接部署在物理机上的公司,(现在很多公司仍然有充分的理由这样做)还是在那些把所有应用都做成 serverless 的先驱公司,DevOps 都很可能会持续下去。这部分工作很有趣,产出也很有影响力,而且最重要的是,它搭起桥梁衔接了技术和业务之间的缺口。DevOps 是一个值得期待的美好事物。 + +首次发表在 [Neurons Firing on a Keyboard][22]。使用 CC-BY-SA 协议。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/1/getting-devops + +作者:[Carlos Nunez][a] +译者:[belitex](https://github.com/belitex) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/carlosonunez +[1]:https://www.reddit.com/r/devops/ +[2]:https://carlosonunez.wordpress.com/ +[3]:https://twitter.com/easiestnameever +[4]:https://en.wikipedia.org/wiki/ITIL +[5]:https://www.psychologytoday.com/blog/time-out/201401/getting-out-your-silo +[6]:https://twitter.com/adamhjk/status/572832185461428224 +[7]:https://landing.google.com/sre/interview/ben-treynor.html +[8]:https://en.wikipedia.org/wiki/CI/CD +[9]:https://thehftguy.com/2016/11/01/docker-in-production-an-history-of-failure/ +[10]:https://itrevolution.com/book/the-phoenix-project/ +[11]:https://pragprog.com/book/trevan/driving-technical-change +[12]:https://en.wikipedia.org/wiki/Peopleware:_Productive_Projects_and_Teams +[13]:http://shop.oreilly.com/product/9780596007836.do +[14]:http://theleanstartup.com/ +[15]:https://info.thoughtworks.com/lean-enterprise-book.html +[16]:http://infrastructure-as-code.com/book/ +[17]:https://landing.google.com/sre/book.html +[18]:https://en.wikipedia.org/wiki/TCP/IP_Illustrated +[19]:http://www.admin.com/ +[20]:https://www.manning.com/books/learn-windows-powershell-in-a-month-of-lunches-third-edition +[21]:https://jamesturnbull.net/ +[22]:https://carlosonunez.wordpress.com/2017/03/02/getting-into-devops/ From c9bb7fd0307c368f352c90f9eff22c328cac8d70 Mon Sep 17 00:00:00 2001 From: BeliteX <43316924+belitex@users.noreply.github.com> Date: Fri, 21 Sep 2018 19:36:53 +0800 Subject: [PATCH 355/455] =?UTF-8?q?[=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90]?= =?UTF-8?q?=20How=20to=20get=20into=20DevOps=20=E5=88=9D=E7=A8=BF=20(#1030?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../talk/20180117 How to get into DevOps.md | 144 ----------------- .../talk/20180117 How to get into DevOps.md | 145 ++++++++++++++++++ 2 files changed, 145 insertions(+), 144 deletions(-) delete mode 100644 sources/talk/20180117 How to get into DevOps.md create mode 100644 translated/talk/20180117 How to get into DevOps.md diff --git a/sources/talk/20180117 How to get into DevOps.md b/sources/talk/20180117 How to get into DevOps.md deleted file mode 100644 index 184b18b1d1..0000000000 --- a/sources/talk/20180117 How to get into DevOps.md +++ /dev/null @@ -1,144 +0,0 @@ -belitex 翻译中 -How to get into DevOps -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_resume_rh1x.png?itok=S3HGxi6E) - -I've observed a sharp uptick of developers and systems administrators interested in "getting into DevOps" within the past year or so. This pattern makes sense: In an age in which a single developer can spin up a globally distributed infrastructure for an application with a few dollars and a few API calls, the gap between development and systems administration is closer than ever. Although I've seen plenty of blog posts and articles about cool DevOps tools and thoughts to think about, I've seen fewer content on pointers and suggestions for people looking to get into this work. - -My goal with this article is to draw what that path looks like. My thoughts are based upon several interviews, chats, late-night discussions on [reddit.com/r/devops][1], and random conversations, likely over beer and delicious food. I'm also interested in hearing feedback from those who have made the jump; if you have, please reach out through [my blog][2], [Twitter][3], or in the comments below. I'd love to hear your thoughts and stories. - -### Olde world IT - -Understanding history is key to understanding the future, and DevOps is no exception. To understand the pervasiveness and popularity of the DevOps movement, understanding what IT was like in the late '90s and most of the '00s is helpful. This was my experience. - -I started my career in late 2006 as a Windows systems administrator in a large, multi-national financial services firm. In those days, adding new compute involved calling Dell (or, in our case, CDW) and placing a multi-hundred-thousand-dollar order of servers, networking equipment, cables, and software, all destined for your on- and offsite datacenters. Although VMware was still convincing companies that using virtual machines was, indeed, a cost-effective way of hosting its "performance-sensitive" application, many companies, including mine, pledged allegiance to running applications on their physical hardware. - -Our technology department had an entire group dedicated to datacenter engineering and operations, and its job was to negotiate our leasing rates down to some slightly less absurd monthly rate and ensure that our systems were being cooled properly (an exponentially difficult problem if you have enough equipment). If the group was lucky/wealthy enough, the offshore datacenter crew knew enough about all of our server models to not accidentally pull the wrong thing during after-hours trading. Amazon Web Services and Rackspace were slowly beginning to pick up steam, but were far from critical mass. - -In those days, we also had teams dedicated to ensuring that the operating systems and software running on top of that hardware worked when they were supposed to. The engineers were responsible for designing reliable architectures for patching, monitoring, and alerting these systems as well as defining what the "gold image" looked like. Most of this work was done with a lot of manual experimentation, and the extent of most tests was writing a runbook describing what you did, and ensuring that what you did actually did what you expected it to do after following said runbook. This was important in a large organization like ours, since most of the level 1 and 2 support was offshore, and the extent of their training ended with those runbooks. - -(This is the world that your author lived in for the first three years of his career. My dream back then was to be the one who made the gold standard!) - -Software releases were another beast altogether. Admittedly, I didn't gain a lot of experience working on this side of the fence. However, from stories that I've gathered (and recent experience), much of the daily grind for software development during this time went something like this: - - * Developers wrote code as specified by the technical and functional requirements laid out by business analysts from meetings they weren't invited to. - * Optionally, developers wrote unit tests for their code to ensure that it didn't do anything obviously crazy, like try to divide over zero without throwing an exception. - * When done, developers would mark their code as "Ready for QA." A quality assurance person would pick up the code and run it in their own environment, which might or might not be like production or even the environment the developer used to test their own code against. - * Failures would get sent back to the developers within "a few days or weeks" depending on other business activities and where priorities fell. - - - -Although sysadmins and developers didn't often see eye to eye, the one thing they shared a common hatred for was "change management." This was a composition of highly regulated (and in the case of my employer at the time), highly necessary rules and procedures governing when and how technical changes happened in a company. Most companies followed [ITIL][4] practices, which, in a nutshell, asked a lot of questions around why, when, where, and how things happened and provided a process for establishing an audit trail of the decisions that led up to those answers. - -As you could probably gather from my short history lesson, many, many things were done manually in IT. This led to a lot of mistakes. Lots of mistakes led up to lots of lost revenue. Change management's job was to minimize those lost revenues; this usually came in the form of releases only every two weeks and changes to servers, regardless of their impact or size, queued up to occur between Friday at 4 p.m. and Monday at 5:59 a.m. (Ironically, this batching of work led to even more mistakes, usually more serious ones.) - -### DevOps isn't a Tiger Team - -You might be thinking "What is Carlos going on about, and when is he going to talk about Ansible playbooks?" I love Ansible tons, but hang on; this is important. - -Have you ever been assigned to a project where you had to interact with the "DevOps" team? Or did you have to rely on a "configuration management" or "CI/CD" team to ensure your pipeline was set up properly? Have you had to attend meetings about your release and what it pertains to--weeks after the work was marked "code complete"? - -If so, then you're reliving history. All of that comes from all of the above. - -[Silos form][5] out of an instinctual draw to working with people like ourselves. Naturally, it's no surprise that this human trait also manifests in the workplace. I even saw this play out at a 250-person startup where I used to work. When I started, developers all worked in common pods and collaborated heavily with each other. As the codebase grew in complexity, developers who worked on common features naturally aligned with each other to try and tackle the complexity within their own feature. Soon afterwards, feature teams were officially formed. - -Sysadmins and developers at many of the companies I worked at not only formed natural silos like this, but also fiercely competed with each other. Developers were mad at sysadmins when their environments were broken. Developers were mad at sysadmins when their environments were too locked down. Sysadmins were mad that developers were breaking their environments in arbitrary ways all of the time. Sysadmins were mad at developers for asking for way more computing power than they needed. Neither side understood each other, and worse yet, neither side wanted to. - -Most developers were uninterested in the basics of operating systems, kernels, or, in some cases, computer hardware. As well, most sysadmins, even Linux sysadmins, took a 10-foot pole approach to learning how to code. They tried a bit of C in college, hated it and never wanted to touch an IDE again. Consequently, developers threw their environment problems over the wall to sysadmins, sysadmins prioritized them with the hundreds of other things that were thrown over the wall to them, and everyone busy-waited angrily while hating each other. The purpose of DevOps was to put an end to this. - -DevOps isn't a team. CI/CD isn't a group in Jira. DevOps is a way of thinking. According to the movement, in an ideal world, developers, sysadmins, and business stakeholders would be working as one team. While they might not know everything about each other's worlds, not only do they all know enough to understand each other and their backlogs, but they can, for the most part, speak the same language. - -This is the basis behind having all infrastructure and business logic be in code and subject to the same deployment pipelines as the software that sits on top of it. Everybody is winning because everyone understands each other. This is also the basis behind the rise of other tools like chatbots and easily accessible monitoring and graphing. - -[Adam Jacob said][6] it best: "DevOps is the word we will use to describe the operational side of the transition to enterprises being software led." - -### What do I need to know to get into DevOps? - -I'm commonly asked this question, and the answer, like most open-ended questions like this, is: It depends. - -At the moment, the "DevOps engineer" varies from company to company. Smaller companies that have plenty of software developers but fewer folks that understand infrastructure will likely look for people with more experience administrating systems. Other, usually larger and/or older companies that have a solid sysadmin organization will likely optimize for something closer to a [Google site reliability engineer][7], i.e. "a software engineer to design an operations function." This isn't written in stone, however, as, like any technology job, the decision largely depends on the hiring manager sponsoring it. - -That said, we typically look for engineers who are interested in learning more about: - - * How to administrate and architect secure and scalable cloud platforms (usually on AWS, but Azure, Google Cloud Platform, and PaaS providers like DigitalOcean and Heroku are popular too); - * How to build and optimize deployment pipelines and deployment strategies on popular [CI/CD][8] tools like Jenkins, Go continuous delivery, and cloud-based ones like Travis CI or CircleCI; - * How to monitor, log, and alert on changes in your system with timeseries-based tools like Kibana, Grafana, Splunk, Loggly, or Logstash; and - * How to maintain infrastructure as code with configuration management tools like Chef, Puppet, or Ansible, as well as deploy said infrastructure with tools like Terraform or CloudFormation. - - - -Containers are becoming increasingly popular as well. Despite the [beef against the status quo][9] surrounding Docker at scale, containers are quickly becoming a great way of achieving an extremely high density of services and applications running on fewer systems while increasing their reliability. (Orchestration tools like Kubernetes or Mesos can spin up new containers in seconds if the host they're being served by fails.) Given this, having knowledge of Docker or rkt and an orchestration platform will go a long way. - -If you're a systems administrator that's looking to get into DevOps, you will also need to know how to write code. Python and Ruby are popular languages for this purpose, as they are portable (i.e., can be used on any operating system), fast, and easy to read and learn. They also form the underpinnings of the industry's most popular configuration management tools (Python for Ansible, Ruby for Chef and Puppet) and cloud API clients (Python and Ruby are commonly used for AWS, Azure, and Google Cloud Platform clients). - -If you're a developer looking to make this change, I highly recommend learning more about Unix, Windows, and networking fundamentals. Even though the cloud abstracts away many of the complications of administrating a system, debugging slow application performance is aided greatly by knowing how these things work. I've included a few books on this topic in the next section. - -If this sounds overwhelming, you aren't alone. Fortunately, there are plenty of small projects to dip your feet into. One such toy project is Gary Stafford's Voter Service, a simple Java-based voting platform. We ask our candidates to take the service from GitHub to production infrastructure through a pipeline. One can combine that with Rob Mile's awesome DevOps Tutorial repository to learn about ways of doing this. - -Another great way of becoming familiar with these tools is taking popular services and setting up an infrastructure for them using nothing but AWS and configuration management. Set it up manually first to get a good idea of what to do, then replicate what you just did using nothing but CloudFormation (or Terraform) and Ansible. Surprisingly, this is a large part of the work that we infrastructure devs do for our clients on a daily basis. Our clients find this work to be highly valuable! - -### Books to read - -If you're looking for other resources on DevOps, here are some theory and technical books that are worth a read. - -#### Theory books - - * [The Phoenix Project][10] by Gene Kim. This is a great book that covers much of the history I explained earlier (with much more color) and describes the journey to a lean company running on agile and DevOps. - * [Driving Technical Change][11] by Terrance Ryan. Awesome little book on common personalities within most technology organizations and how to deal with them. This helped me out more than I expected. - * [Peopleware][12] by Tom DeMarco and Tim Lister. A classic on managing engineering organizations. A bit dated, but still relevant. - * [Time Management for System Administrators][13] by Tom Limoncelli. While this is heavily geared towards sysadmins, it provides great insight into the life of a systems administrator at most large organizations. If you want to learn more about the war between sysadmins and developers, this book might explain more. - * [The Lean Startup][14] by Eric Ries. Describes how Eric's 3D avatar company, IMVU, discovered how to work lean, fail fast, and find profit faster. - * [Lean Enterprise][15] by Jez Humble and friends. This book is an adaption of The Lean Startup for the enterprise. Both are great reads and do a good job of explaining the business motivation behind DevOps. - * [Infrastructure As Code][16] by Kief Morris. Awesome primer on, well, infrastructure as code! It does a great job of describing why it's essential for any business to adopt this for their infrastructure. - * [Site Reliability Engineering][17] by Betsy Beyer, Chris Jones, Jennifer Petoff, and Niall Richard Murphy. A book explaining how Google does SRE, or also known as "DevOps before DevOps was a thing." Provides interesting opinions on how to handle uptime, latency, and keeping engineers happy. - - - -#### Technical books - -If you're looking for books that'll take you straight to code, you've come to the right section. - - * [TCP/IP Illustrated][18] by the late W. Richard Stevens. This is the classic (and, arguably, complete) tome on the fundamental networking protocols, with special emphasis on TCP/IP. If you've heard of Layers 1, 2, 3, and 4 and are interested in learning more, you'll need this book. - * [UNIX and Linux System Administration Handbook][19] by Evi Nemeth, Trent Hein, and Ben Whaley. A great primer into how Linux and Unix work and how to navigate around them. - * [Learn Windows Powershell In A Month of Lunches][20] by Don Jones and Jeffrey Hicks. If you're doing anything automated with Windows, you will need to learn how to use Powershell. This is the book that will help you do that. Don Jones is a well-known MVP in this space. - * Practically anything by [James Turnbull][21]. He puts out great technical primers on popular DevOps-related tools. - - - -From companies deploying everything to bare metal (there are plenty that still do, for good reasons) to trailblazers doing everything serverless, DevOps is likely here to stay for a while. The work is interesting, the results are impactful, and, most important, it helps bridge the gap between technology and business. It's a wonderful thing to see. - -Originally published at [Neurons Firing on a Keyboard][22], CC-BY-SA. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/1/getting-devops - -作者:[Carlos Nunez][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/carlosonunez -[1]:https://www.reddit.com/r/devops/ -[2]:https://carlosonunez.wordpress.com/ -[3]:https://twitter.com/easiestnameever -[4]:https://en.wikipedia.org/wiki/ITIL -[5]:https://www.psychologytoday.com/blog/time-out/201401/getting-out-your-silo -[6]:https://twitter.com/adamhjk/status/572832185461428224 -[7]:https://landing.google.com/sre/interview/ben-treynor.html -[8]:https://en.wikipedia.org/wiki/CI/CD -[9]:https://thehftguy.com/2016/11/01/docker-in-production-an-history-of-failure/ -[10]:https://itrevolution.com/book/the-phoenix-project/ -[11]:https://pragprog.com/book/trevan/driving-technical-change -[12]:https://en.wikipedia.org/wiki/Peopleware:_Productive_Projects_and_Teams -[13]:http://shop.oreilly.com/product/9780596007836.do -[14]:http://theleanstartup.com/ -[15]:https://info.thoughtworks.com/lean-enterprise-book.html -[16]:http://infrastructure-as-code.com/book/ -[17]:https://landing.google.com/sre/book.html -[18]:https://en.wikipedia.org/wiki/TCP/IP_Illustrated -[19]:http://www.admin.com/ -[20]:https://www.manning.com/books/learn-windows-powershell-in-a-month-of-lunches-third-edition -[21]:https://jamesturnbull.net/ -[22]:https://carlosonunez.wordpress.com/2017/03/02/getting-into-devops/ diff --git a/translated/talk/20180117 How to get into DevOps.md b/translated/talk/20180117 How to get into DevOps.md new file mode 100644 index 0000000000..ec169be76f --- /dev/null +++ b/translated/talk/20180117 How to get into DevOps.md @@ -0,0 +1,145 @@ + +DevOps 实践指南 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003784_02_os.comcareers_resume_rh1x.png?itok=S3HGxi6E) + +在去年大概一年的时间里,我注意到对“Devops 实践”感兴趣的开发人员和系统管理员突然有了明显的增加。这样的变化也合理:现在开发者只要花很少的钱,调用一些 API, 就能单枪匹马地在一整套分布式基础设施上运行自己的应用, 在这个时代,开发和运维的紧密程度前所未有。我看过许多博客和文章介绍很酷的 DevOps 工具和相关思想,但是给那些希望践行 DevOps 的人以指导和建议的内容,我却很少看到。 + +这篇文章的目的就是描述一下如何去实践。我的想法基于 Reddit 上 [devops][1] 的一些访谈、聊天和深夜讨论,还有一些随机谈话,一般都发生在享受啤酒和美食的时候。如果你已经开始这样实践,我对你的反馈很感兴趣,请通过 [我的博客][2] 或者 [Twitter][3] 联系我,也可以直接在下面评论。我很乐意听到你们的想法和故事。 + +### 古代的 IT + +了解历史是搞清楚未来的关键,DevOps 也不例外。想搞清楚 DevOps 运动的普及和流行,去了解一下上世纪 90 年代后期和 21 世纪前十年 IT 的情况会有帮助。这是我的经验。 + +我的第一份工作是在一家大型跨国金融服务公司做 Windows 系统管理员。当时给计算资源扩容需要给 Dell 打电话 (或者像我们公司那样打给 CDW ),并下一个价值数十万美元的订单,包含服务器、网络设备、电缆和软件,所有这些都要运到在线或离线的数据中心去。虽然 VMware 仍在尝试说服企业使用虚拟机运行他们的“性能敏感”型程序是更划算的,但是包括我们在内的很多公司都还忠于使用他们的物理机运行应用。 + +在我们技术部门,有一个专门做数据中心工程和操作的完整团队,他们的工作包括价格谈判,让荒唐的租赁月费能够下降一点点,还包括保证我们的系统能够正常冷却(如果设备太多,这个事情的难度会呈指数增长)。如果这个团队足够幸运足够有钱,境外数据中心的工作人员对我们所有的服务器型号又都有足够的了解,就能避免在盘后交易中不小心扯错东西。那时候亚马逊 AWS 和 Rackspace 逐渐开始加速扩张,但还远远没到临界规模。 + +当时我们还有专门的团队来保证硬件上运行着的操作系统和软件能够按照预期工作。这些工程师负责设计可靠的架构以方便给系统打补丁,监控和报警,还要定义基础镜像 (gold image) 的内容。这些大都是通过很多手工实验完成的,很多手工实验是为了编写一个运行说明书 (runbook) 来描述要做的事情,并确保按照它执行后的结果确实在预期内。在我们这么大的组织里,这样做很重要,因为一线和二线的技术支持都是境外的,而他们的培训内容只覆盖到了这些运行说明而已。 + +(这是我职业生涯前三年的世界。我那时候的梦想是成为制定金本位制的人!) + +软件发布则完全是另外一头怪兽。无可否认,我在这方面并没有积累太多经验。但是,从我收集的故事(和最近的经历)来看,当时大部分软件开发的日常大概是这样: + + * 开发人员按照技术和功能需求来编写代码,这些需求来自于业务分析人员的会议,但是会议并没有邀请开发人员参加。 + * 开发人员可以选择为他们的代码编写单元测试,以确保在代码里没有任何明显的疯狂行为,比如除以 0 但不抛出异常。 + * 然后开发者会把他们的代码标记为 "Ready for QA."(准备好了接受测试),质量保障的成员会把这个版本的代码发布到他们自己的环境中,这个环境和生产环境可能相似,也可能不相似,甚至和开发环境相比也不一定相似。 + * 故障会在几天或者几个星期内反馈到开发人员那里,这个时长取决于其他业务活动和优先事项。 + + + +虽然系统管理员和开发人员经常有不一致的意见,但是对“变更管理”的痛恨却是一致的。变更管理由高度规范的(就我当时的雇主而言)和非常有必要的规则和程序组成,用来管理一家公司应该什么时候做技术变更,以及如何做。很多公司都按照 [ITIL][4] 来操作, 简单的说,ITIL 问了很多和事情发生的原因、时间、地点和方式相关的问题,而且提供了一个过程,对产生最终答案的决定做审计跟踪。 + +你可能从我的简短历史课上了解到,当时 IT 的很多很多事情都是手工完成的。这导致了很多错误。错误又导致了很多财产损失。变更管理的工作就是尽量减少这些损失,它常常以这样的形式出现:不管变更的影响和规模大小,每两周才能发布部署一次。周五下午 4 点到周一早上 5 点 59 分这段时间,需要排队等候发布窗口。(讽刺的是,这种流程导致了更多错误,通常还是更严重的那种错误) + +### DevOps 不是专家团 + +你可能在想 "Carlos 你在讲啥啊,什么时候才能说到 Ansible playbooks? ",我热爱 Ansible, 但是请再等一会;下面这些很重要。 + +你有没有过被分配到过需要跟"DevOps"小组打交道的项目?你有没有依赖过“配置管理”或者“持续集成/持续交付”小组来保证业务流水线设置正确?你有没有在代码开发完的数周之后才参加发布部署的会议? + +如果有过,那么你就是在重温历史,这个历史是由上面所有这些导致的。 + +出于本能,我们喜欢和像自己的人一起工作,这会导致[筒仓][5]的行成。很自然,这种人类特质也会在工作场所表现出来是不足为奇的。我甚至在一个 250 人的创业公司里见到过这样的现象,当时我在那里工作。刚开始的时候,开发人员都在聚在一起工作,彼此深度协作。随着代码变得复杂,开发相同功能的人自然就坐到了一起,解决他们自己的复杂问题。然后按功能划分的小组很快就正式形成了。 + +在我工作过的很多公司里,系统管理员和开发人员不仅像这样形成了天然的筒仓,而且彼此还有激烈的对抗。开发人员的环境出问题了或者他们的权限太小了,就会对系统管理员很恼火。系统管理员怪开发者无时不刻的不在用各种方式破坏他们的环境,怪开发人员申请的计算资源严重超过他们的需要。双方都不理解对方,更糟糕的是,双方都不愿意去理解对方。 + +大部分开发人员对操作系统,内核或计算机硬件都不感兴趣。同样的,大部分系统管理员,即使是 Linux 的系统管理员,也都不愿意学习编写代码,他们在大学期间学过一些 C 语言,然后就痛恨它,并且永远都不想再碰 IDE. 所以,开发人员把运行环境的问题甩给围墙外的系统管理员,系统管理员把这些问题和甩过来的其他上百个问题放在一起,做一个优先级安排。每个人都很忙,心怀怨恨的等待着。DevOps 的目的就是解决这种矛盾。 + +DevOps 不是一个团队,CI/CD 也不是 Jira 系统的一个用户组。DevOps 是一种思考方式。根据这个运动来看,在理想的世界里,开发人员、系统管理员和业务相关人将作为一个团队工作。虽然他们可能不完全了解彼此的世界,可能没有足够的知识去了解彼此的积压任务,但他们在大多数情况下能有一致的看法。 + +把所有基础设施和业务逻辑都代码化,再串到一个发布部署流水线里,就像是运行在这之上的应用一样。这个理念的基础就是 DevOps. 因为大家都理解彼此,所以人人都是赢家。聊天机器人和易用的监控工具、可视化工具的兴起,背后的基础也是 DevOps. + +[Adam Jacob][6] 说的最好:"DevOps 就是企业往软件导向型过渡时我们用来描述操作的词" + +### 要实践 DevOps 我需要知道些什么 + +我经常被问到这个问题,它的答案,和同属于开放式的其他大部分问题一样:视情况而定。 + +现在“DevOps 工程师”在不同的公司有不同的含义。在软件开发人员比较多但是很少有人懂基础设施的小公司,他们很可能是在找有更多系统管理经验的人。而其他公司,通常是大公司或老公司或又大又老的公司,已经有一个稳固的系统管理团队了,他们在向类似于谷歌 [SRE][7] 的方向做优化,也就是“设计操作功能的软件工程师”。但是,这并不是金科玉律,就像其他技术类工作一样,这个决定很大程度上取决于他的招聘经理。 + +也就是说,我们一般是在找对深入学习以下内容感兴趣的工程师: + + * 如何管理和设计安全、可扩展的云上的平台(通常是在 AWS 上,不过微软的 Azure, 谷歌的 Cloud Platform,还有 DigitalOcean 和 Heroku 这样的 PaaS 提供商,也都很流行) + * 如何用流行的 [CI/CD][8] 工具,比如 Jenkins,Gocd,还有基于云的 Travis CI 或者 CircleCI,来构造一条优化的发布部署流水线,和发布部署策略。 + * 如何在你的系统中使用基于时间序列的工具,比如 Kibana,Grafana,Splunk,Loggly 或者 Logstash,来监控,记录,并在变化的时候报警,还有 + * 如何使用配置管理工具,例如 Chef,Puppet 或者 Ansible 做到“基础设施即代码”,以及如何使用像 Terraform 或 CloudFormation 的工具发布这些基础设施。 + + + +容器也变得越来越受欢迎。尽管有人对大规模使用 Docker 的现状[表示不满][9],但容器正迅速地成为一种很好的方式来实现在更少的操作系统上运行超高密度的服务和应用,同时提高它们的可靠性。(像 Kubernetes 或者 Mesos 这样的容器编排工具,能在宿主机故障的时候,几秒钟之内重新启动新的容器。)考虑到这些,掌握 Docker 或者 rkt 以及容器编排平台的知识会对你大有帮助。 + +如果你是希望做 DevOps 实践的系统管理员,你还需要知道如何写代码。Python 和 Ruby 是 DevOps 领域的流行语言,因为他们是可移植的(也就是说可以在任何操作系统上运行),快速的,而且易读易学。它们还支撑着这个行业最流行的配置管理工具(Ansible 是使用 Python 写的,Chef 和 Puppet 是使用 Ruby 写的)以及云平台的 API 客户端(亚马逊 AWS, 微软 Azure, 谷歌 Cloud Platform 的客户端通常会提供 Python 和 Ruby 语言的版本)。 + +如果你是开发人员,也希望做 DevOps 的实践,我强烈建议你去学习 Unix,Windows 操作系统以及网络基础知识。虽然云计算把很多系统管理的难题抽象化了,但是对慢应用的性能做 debug 的时候,你知道操作系统如何工作的就会有很大的帮助。下文包含了一些这个主题的图书。 + +如果你觉得这些东西听起来内容太多,大家都是这么想的。幸运的是,有很多小项目可以让你开始探索。其中一个启动项目是 Gary Stafford 的[选举服务](https://github.com/garystafford/voter-service), 一个基于 Java 的简单投票平台。我们要求面试候选人通过一个流水线将该服务从 GitHub 部署到生产环境基础设施上。你可以把这个服务与 Rob Mile 写的了不起的 DevOps [入门教程](https://github.com/maxamg/cd-office-hours)结合起来,学习如何编写流水线。 + +还有一个熟悉这些工具的好方法,找一个流行的服务,然后只使用 AWS 和配置管理工具来搭建这个服务所需要的基础设施。第一次先手动搭建,了解清楚要做的事情,然后只用 CloudFormation (或者 Terraform) 和 Ansible 重写刚才的手动操作。令人惊讶的是,这就是我们基础设施开发人员为客户所做的大部分日常工作,我们的客户认为这样的工作非常有意义! + +### 需要读的书 + +如果你在找 DevOps 的其他资源,下面这些理论和技术书籍值得一读。 + +#### 理论书籍 + + * Gene Kim 写的 [The Phoenix Project (凤凰项目)][10]。这是一本很不错的书,内容涵盖了我上文解释过的历史(写的更生动形象),描述了一个运行在敏捷和 DevOps 之上的公司向精益前进的过程。 + * Terrance Ryan 写的 [Driving Technical Change (布道之道)][11]。非常好的一小本书,讲了大多数技术型组织内的常见性格特点以及如何和他们打交道。这本书对我的帮助比我想象的更多。 + * Tom DeMarco 和 Tim Lister 合著的 [Peopleware (人件)][12]。管理工程师团队的经典图书,有一点过时,但仍然很有价值。 + * Tom Limoncelli 写的 [Time Management for System Administrators (时间管理: 给系统管理员)][13]。这本书主要面向系统管理员,它对很多大型组织内的系统管理员生活做了深入的展示。如果你想了解更多系统管理员和开发人员之间的冲突,这本书可能解释了更多。 + * Eric Ries 写的 [The Lean Startup (精益创业)][14]。描述了 Eric 自己的 3D 虚拟形象公司,IMVU, 发现了如何精益工作,快速失败和更快盈利。 + * Jez Humble 和他的朋友写的[Lean Enterprise (精益企业)][15]。这本书是对精益创业做的改编,以更适应企业,两本书都很棒,都很好的解释了 DevOps 背后的商业动机。 + * Kief Morris 写的 [Infrastructure As Code (基础设施即代码)][16]。关于 "基础设施即代码" 的非常好的入门读物!很好的解释了为什么所有公司都有必要采纳这种做法。 + * Betsy Beyer, Chris Jones, Jennifer Petoff 和 Niall Richard Murphy 合著的 [Site Reliability Engineering (站点可靠性工程师)][17]。一本解释谷歌 SRE 实践的书,也因为是 "DevOps 诞生之前的 DevOps" 被人熟知。在如何处理运行时间、时延和保持工程师快乐方面提供了有趣的看法。 + + + +#### 技术书籍 + +如果你想找的是让你直接跟代码打交道的书,看这里就对了。 + + * W. Richard Stevens 的 [TCP/IP Illustrated (TCP/IP 详解)][18]。这是一套经典的(也可以说是最全面的)讲解基本网络协议的巨著,重点介绍了 TCP/IP 协议族。如果你听说过 1,2, 3,4 层网络,而且对深入学习他们感兴趣,那么你需要这本书。 + * Evi Nemeth, Trent Hein 和 Ben Whaley 合著的 [UNIX and Linux System Administration Handbook (UNIX/Linux 系统管理员手册)][19]。一本很好的入门书,介绍 Linux/Unix 如何工作以及如何使用。 + * Don Jones 和 Jeffrey Hicks 合著的 [Learn Windows Powershell In A Month of Lunches (Windows PowerShell实战指南)][20]. 如果你在 Windows 系统下做自动化任务,你需要学习怎么使用 Powershell。这本书能够帮助你。Don Jones 是这方面著名的 MVP。 + * 几乎所有 [James Turnbull][21] 写的东西,针对流行的 DevOps 工具,他发表了很好的技术入门读物。 + + + +不管是在那些把所有应用都直接部署在物理机上的公司,(现在很多公司仍然有充分的理由这样做)还是在那些把所有应用都做成 serverless 的先驱公司,DevOps 都很可能会持续下去。这部分工作很有趣,产出也很有影响力,而且最重要的是,它搭起桥梁衔接了技术和业务之间的缺口。DevOps 是一个值得期待的美好事物。 + +首次发表在 [Neurons Firing on a Keyboard][22]。使用 CC-BY-SA 协议。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/1/getting-devops + +作者:[Carlos Nunez][a] +译者:[belitex](https://github.com/belitex) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/carlosonunez +[1]:https://www.reddit.com/r/devops/ +[2]:https://carlosonunez.wordpress.com/ +[3]:https://twitter.com/easiestnameever +[4]:https://en.wikipedia.org/wiki/ITIL +[5]:https://www.psychologytoday.com/blog/time-out/201401/getting-out-your-silo +[6]:https://twitter.com/adamhjk/status/572832185461428224 +[7]:https://landing.google.com/sre/interview/ben-treynor.html +[8]:https://en.wikipedia.org/wiki/CI/CD +[9]:https://thehftguy.com/2016/11/01/docker-in-production-an-history-of-failure/ +[10]:https://itrevolution.com/book/the-phoenix-project/ +[11]:https://pragprog.com/book/trevan/driving-technical-change +[12]:https://en.wikipedia.org/wiki/Peopleware:_Productive_Projects_and_Teams +[13]:http://shop.oreilly.com/product/9780596007836.do +[14]:http://theleanstartup.com/ +[15]:https://info.thoughtworks.com/lean-enterprise-book.html +[16]:http://infrastructure-as-code.com/book/ +[17]:https://landing.google.com/sre/book.html +[18]:https://en.wikipedia.org/wiki/TCP/IP_Illustrated +[19]:http://www.admin.com/ +[20]:https://www.manning.com/books/learn-windows-powershell-in-a-month-of-lunches-third-edition +[21]:https://jamesturnbull.net/ +[22]:https://carlosonunez.wordpress.com/2017/03/02/getting-into-devops/ From f21ff0975c34ca978acaabb841b06eeb284d10f4 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Fri, 21 Sep 2018 19:43:03 +0800 Subject: [PATCH 356/455] Translated by qhwdw --- ...feinated 6.828:Lab 2 Memory Management.md | 234 ------------------ ...feinated 6.828:Lab 2 Memory Management.md | 232 +++++++++++++++++ 2 files changed, 232 insertions(+), 234 deletions(-) delete mode 100644 sources/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md create mode 100644 translated/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md diff --git a/sources/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md b/sources/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md deleted file mode 100644 index a52f7ac36a..0000000000 --- a/sources/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md +++ /dev/null @@ -1,234 +0,0 @@ -Translating by qhwdw - -# Caffeinated 6.828:Lab 2: Memory Management - -### Introduction - -In this lab, you will write the memory management code for your operating system. Memory management has two components. - -The first component is a physical memory allocator for the kernel, so that the kernel can allocate memory and later free it. Your allocator will operate in units of 4096 bytes, called pages. Your task will be to maintain data structures that record which physical pages are free and which are allocated, and how many processes are sharing each allocated page. You will also write the routines to allocate and free pages of memory. - -The second component of memory management is virtual memory, which maps the virtual addresses used by kernel and user software to addresses in physical memory. The x86 hardware’s memory management unit (MMU) performs the mapping when instructions use memory, consulting a set of page tables. You will modify JOS to set up the MMU’s page tables according to a specification we provide. - -### Getting started - -In this and future labs you will progressively build up your kernel. We will also provide you with some additional source. To fetch that source, use Git to commit changes you’ve made since handing in lab 1 (if any), fetch the latest version of the course repository, and then create a local branch called lab2 based on our lab2 branch, origin/lab2: - -``` -athena% cd ~/6.828/lab -athena% add git -athena% git pull -Already up-to-date. -athena% git checkout -b lab2 origin/lab2 -Branch lab2 set up to track remote branch refs/remotes/origin/lab2. -Switched to a new branch "lab2" -athena% -``` - -You will now need to merge the changes you made in your lab1 branch into the lab2 branch, as follows: - -``` -athena% git merge lab1 -Merge made by recursive. - kern/kdebug.c | 11 +++++++++-- - kern/monitor.c | 19 +++++++++++++++++++ - lib/printfmt.c | 7 +++---- - 3 files changed, 31 insertions(+), 6 deletions(-) -athena% -``` - -Lab 2 contains the following new source files, which you should browse through: - -- inc/memlayout.h -- kern/pmap.c -- kern/pmap.h -- kern/kclock.h -- kern/kclock.c - -memlayout.h describes the layout of the virtual address space that you must implement by modifying pmap.c. memlayout.h and pmap.h define the PageInfo structure that you’ll use to keep track of which pages of physical memory are free. kclock.c and kclock.h manipulate the PC’s battery-backed clock and CMOS RAM hardware, in which the BIOS records the amount of physical memory the PC contains, among other things. The code in pmap.c needs to read this device hardware in order to figure out how much physical memory there is, but that part of the code is done for you: you do not need to know the details of how the CMOS hardware works. - -Pay particular attention to memlayout.h and pmap.h, since this lab requires you to use and understand many of the definitions they contain. You may want to review inc/mmu.h, too, as it also contains a number of definitions that will be useful for this lab. - -Before beginning the lab, don’t forget to add exokernel to get the 6.828 version of QEMU. - -### Hand-In Procedure - -When you are ready to hand in your lab code and write-up, add your answers-lab2.txt to the Git repository, commit your changes, and then run make handin. - -``` -athena% git add answers-lab2.txt -athena% git commit -am "my answer to lab2" -[lab2 a823de9] my answer to lab2 4 files changed, 87 insertions(+), 10 deletions(-) -athena% make handin -``` - -### Part 1: Physical Page Management - -The operating system must keep track of which parts of physical RAM are free and which are currently in use. JOS manages the PC’s physical memory with page granularity so that it can use the MMU to map and protect each piece of allocated memory. - -You’ll now write the physical page allocator. It keeps track of which pages are free with a linked list of struct PageInfo objects, each corresponding to a physical page. You need to write the physical page allocator before you can write the rest of the virtual memory implementation, because your page table management code will need to allocate physical memory in which to store page tables. - -> Exercise 1 -> -> In the file kern/pmap.c, you must implement code for the following functions (probably in the order given). -> -> boot_alloc() -> -> mem_init() (only up to the call to check_page_free_list()) -> -> page_init() -> -> page_alloc() -> -> page_free() -> -> check_page_free_list() and check_page_alloc() test your physical page allocator. You should boot JOS and see whether check_page_alloc() reports success. Fix your code so that it passes. You may find it helpful to add your own assert()s to verify that your assumptions are correct. - -This lab, and all the 6.828 labs, will require you to do a bit of detective work to figure out exactly what you need to do. This assignment does not describe all the details of the code you’ll have to add to JOS. Look for comments in the parts of the JOS source that you have to modify; those comments often contain specifications and hints. You will also need to look at related parts of JOS, at the Intel manuals, and perhaps at your 6.004 or 6.033 notes. - -### Part 2: Virtual Memory - -Before doing anything else, familiarize yourself with the x86’s protected-mode memory management architecture: namely segmentationand page translation. - -> Exercise 2 -> -> Look at chapters 5 and 6 of the Intel 80386 Reference Manual, if you haven’t done so already. Read the sections about page translation and page-based protection closely (5.2 and 6.4). We recommend that you also skim the sections about segmentation; while JOS uses paging for virtual memory and protection, segment translation and segment-based protection cannot be disabled on the x86, so you will need a basic understanding of it. - -### Virtual, Linear, and Physical Addresses - -In x86 terminology, a virtual address consists of a segment selector and an offset within the segment. A linear address is what you get after segment translation but before page translation. A physical address is what you finally get after both segment and page translation and what ultimately goes out on the hardware bus to your RAM. - -![屏幕快照 2018-09-04 11.22.20](/Users/qhwdw/Desktop/屏幕快照 2018-09-04 11.22.20.png) - -Recall that in part 3 of lab 1, we installed a simple page table so that the kernel could run at its link address of 0xf0100000, even though it is actually loaded in physical memory just above the ROM BIOS at 0x00100000. This page table mapped only 4MB of memory. In the virtual memory layout you are going to set up for JOS in this lab, we’ll expand this to map the first 256MB of physical memory starting at virtual address 0xf0000000 and to map a number of other regions of virtual memory. - -> Exercise 3 -> -> While GDB can only access QEMU’s memory by virtual address, it’s often useful to be able to inspect physical memory while setting up virtual memory. Review the QEMU monitor commands from the lab tools guide, especially the xp command, which lets you inspect physical memory. To access the QEMU monitor, press Ctrl-a c in the terminal (the same binding returns to the serial console). -> -> Use the xp command in the QEMU monitor and the x command in GDB to inspect memory at corresponding physical and virtual addresses and make sure you see the same data. -> -> Our patched version of QEMU provides an info pg command that may also prove useful: it shows a compact but detailed representation of the current page tables, including all mapped memory ranges, permissions, and flags. Stock QEMU also provides an info mem command that shows an overview of which ranges of virtual memory are mapped and with what permissions. - -From code executing on the CPU, once we’re in protected mode (which we entered first thing in boot/boot.S), there’s no way to directly use a linear or physical address. All memory references are interpreted as virtual addresses and translated by the MMU, which means all pointers in C are virtual addresses. - -The JOS kernel often needs to manipulate addresses as opaque values or as integers, without dereferencing them, for example in the physical memory allocator. Sometimes these are virtual addresses, and sometimes they are physical addresses. To help document the code, the JOS source distinguishes the two cases: the type uintptr_t represents opaque virtual addresses, and physaddr_trepresents physical addresses. Both these types are really just synonyms for 32-bit integers (uint32_t), so the compiler won’t stop you from assigning one type to another! Since they are integer types (not pointers), the compiler will complain if you try to dereference them. - -The JOS kernel can dereference a uintptr_t by first casting it to a pointer type. In contrast, the kernel can’t sensibly dereference a physical address, since the MMU translates all memory references. If you cast a physaddr_t to a pointer and dereference it, you may be able to load and store to the resulting address (the hardware will interpret it as a virtual address), but you probably won’t get the memory location you intended. - -To summarize: - -| C type | Address type | -| ------------ | ------------ | -| `T*` | Virtual | -| `uintptr_t` | Virtual | -| `physaddr_t` | Physical | - ->Question -> ->Assuming that the following JOS kernel code is correct, what type should variable x have, >uintptr_t or physaddr_t? -> ->![屏幕快照 2018-09-04 11.48.54](/Users/qhwdw/Desktop/屏幕快照 2018-09-04 11.48.54.png) -> - -The JOS kernel sometimes needs to read or modify memory for which it knows only the physical address. For example, adding a mapping to a page table may require allocating physical memory to store a page directory and then initializing that memory. However, the kernel, like any other software, cannot bypass virtual memory translation and thus cannot directly load and store to physical addresses. One reason JOS remaps of all of physical memory starting from physical address 0 at virtual address 0xf0000000 is to help the kernel read and write memory for which it knows just the physical address. In order to translate a physical address into a virtual address that the kernel can actually read and write, the kernel must add 0xf0000000 to the physical address to find its corresponding virtual address in the remapped region. You should use KADDR(pa) to do that addition. - -The JOS kernel also sometimes needs to be able to find a physical address given the virtual address of the memory in which a kernel data structure is stored. Kernel global variables and memory allocated by boot_alloc() are in the region where the kernel was loaded, starting at 0xf0000000, the very region where we mapped all of physical memory. Thus, to turn a virtual address in this region into a physical address, the kernel can simply subtract 0xf0000000. You should use PADDR(va) to do that subtraction. - -### Reference counting - -In future labs you will often have the same physical page mapped at multiple virtual addresses simultaneously (or in the address spaces of multiple environments). You will keep a count of the number of references to each physical page in the pp_ref field of thestruct PageInfo corresponding to the physical page. When this count goes to zero for a physical page, that page can be freed because it is no longer used. In general, this count should equal to the number of times the physical page appears below UTOP in all page tables (the mappings above UTOP are mostly set up at boot time by the kernel and should never be freed, so there’s no need to reference count them). We’ll also use it to keep track of the number of pointers we keep to the page directory pages and, in turn, of the number of references the page directories have to page table pages. - -Be careful when using page_alloc. The page it returns will always have a reference count of 0, so pp_ref should be incremented as soon as you’ve done something with the returned page (like inserting it into a page table). Sometimes this is handled by other functions (for example, page_insert) and sometimes the function calling page_alloc must do it directly. - -### Page Table Management - -Now you’ll write a set of routines to manage page tables: to insert and remove linear-to-physical mappings, and to create page table pages when needed. - -> Exercise 4 -> -> In the file kern/pmap.c, you must implement code for the following functions. -> -> pgdir_walk() -> -> boot_map_region() -> -> page_lookup() -> -> page_remove() -> -> page_insert() -> -> check_page(), called from mem_init(), tests your page table management routines. You should make sure it reports success before proceeding. - -### Part 3: Kernel Address Space - -JOS divides the processor’s 32-bit linear address space into two parts. User environments (processes), which we will begin loading and running in lab 3, will have control over the layout and contents of the lower part, while the kernel always maintains complete control over the upper part. The dividing line is defined somewhat arbitrarily by the symbol ULIM in inc/memlayout.h, reserving approximately 256MB of virtual address space for the kernel. This explains why we needed to give the kernel such a high link address in lab 1: otherwise there would not be enough room in the kernel’s virtual address space to map in a user environment below it at the same time. - -You’ll find it helpful to refer to the JOS memory layout diagram in inc/memlayout.h both for this part and for later labs. - -### Permissions and Fault Isolation - -Since kernel and user memory are both present in each environment’s address space, we will have to use permission bits in our x86 page tables to allow user code access only to the user part of the address space. Otherwise bugs in user code might overwrite kernel data, causing a crash or more subtle malfunction; user code might also be able to steal other environments’ private data. - -The user environment will have no permission to any of the memory above ULIM, while the kernel will be able to read and write this memory. For the address range [UTOP,ULIM), both the kernel and the user environment have the same permission: they can read but not write this address range. This range of address is used to expose certain kernel data structures read-only to the user environment. Lastly, the address space below UTOP is for the user environment to use; the user environment will set permissions for accessing this memory. - -### Initializing the Kernel Address Space - -Now you’ll set up the address space above UTOP: the kernel part of the address space. inc/memlayout.h shows the layout you should use. You’ll use the functions you just wrote to set up the appropriate linear to physical mappings. - -> Exercise 5 -> -> Fill in the missing code in mem_init() after the call to check_page(). - -Your code should now pass the check_kern_pgdir() and check_page_installed_pgdir() checks. - -> Question -> -> ​ 1、What entries (rows) in the page directory have been filled in at this point? What addresses do they map and where do they point? In other words, fill out this table as much as possible: -> -> EntryBase Virtual AddressPoints to (logically): -> -> 1023 ? Page table for top 4MB of phys memory -> -> 1022 ? ? -> -> . ? ? -> -> . ? ? -> -> . ? ? -> -> 2 0x00800000 ? -> -> 1 0x00400000 ? -> -> 0 0x00000000 [see next question] -> -> ​ 2、(From 20 Lecture3) We have placed the kernel and user environment in the same address space. Why will user programs not be able to read or write the kernel’s memory? What specific mechanisms protect the kernel memory? -> -> ​ 3、What is the maximum amount of physical memory that this operating system can support? Why? -> -> ​ 4、How much space overhead is there for managing memory, if we actually had the maximum amount of physical memory? How is this overhead broken down? -> -> ​ 5、Revisit the page table setup in kern/entry.S and kern/entrypgdir.c. Immediately after we turn on paging, EIP is still a low number (a little over 1MB). At what point do we transition to running at an EIP above KERNBASE? What makes it possible for us to continue executing at a low EIP between when we enable paging and when we begin running at an EIP above KERNBASE? Why is this transition necessary? - -### Address Space Layout Alternatives - -The address space layout we use in JOS is not the only one possible. An operating system might map the kernel at low linear addresses while leaving the upper part of the linear address space for user processes. x86 kernels generally do not take this approach, however, because one of the x86’s backward-compatibility modes, known as virtual 8086 mode, is “hard-wired” in the processor to use the bottom part of the linear address space, and thus cannot be used at all if the kernel is mapped there. - -It is even possible, though much more difficult, to design the kernel so as not to have to reserve any fixed portion of the processor’s linear or virtual address space for itself, but instead effectively to allow allow user-level processes unrestricted use of the entire 4GB of virtual address space - while still fully protecting the kernel from these processes and protecting different processes from each other! - -Generalize the kernel’s memory allocation system to support pages of a variety of power-of-two allocation unit sizes from 4KB up to some reasonable maximum of your choice. Be sure you have some way to divide larger allocation units into smaller ones on demand, and to coalesce multiple small allocation units back into larger units when possible. Think about the issues that might arise in such a system. - -This completes the lab. Make sure you pass all of the make grade tests and don’t forget to write up your answers to the questions inanswers-lab2.txt. Commit your changes (including adding answers-lab2.txt) and type make handin in the lab directory to hand in your lab. - ------- - -via: - -作者:[Mit][] -译者:[译者ID](https://github.com/%E8%AF%91%E8%80%85ID) -校对:[校对者ID](https://github.com/%E6%A0%A1%E5%AF%B9%E8%80%85ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 \ No newline at end of file diff --git a/translated/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md b/translated/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md new file mode 100644 index 0000000000..0e2a348679 --- /dev/null +++ b/translated/tech/20140114 Caffeinated 6.828:Lab 2 Memory Management.md @@ -0,0 +1,232 @@ +# Caffeinated 6.828:实验 2:内存管理 + +### 简介 + +在本实验中,你将为你的操作系统写内存管理方面的代码。内存管理有两部分组成。 + +第一部分是内核的物理内存分配器,内核通过它来分配内存,以及在不需要时释放所分配的内存。分配器以页为单位分配内存,每个页的大小为 4096 字节。你的任务是去维护那个数据结构,它负责记录物理页的分配和释放,以及每个分配的页有多少进程共享它。本实验中你将要写出分配和释放内存页的全套代码。 + +第二个部分是虚拟内存的管理,它负责由内核和用户软件使用的虚拟内存地址到物理内存地址之间的映射。当使用内存时,x86 架构的硬件是由内存管理单元(MMU)负责执行映射操作来查阅一组页表。接下来你将要修改 JOS,以根据我们提供的特定指令去设置 MMU 的页表。 + +### 预备知识 + +在本实验及后面的实验中,你将逐步构建你的内核。我们将会为你提供一些附加的资源。使用 Git 去获取这些资源、提交自实验 1 以来的改变(如有需要的话)、获取课程仓库的最新版本、以及在我们的实验 2 (origin/lab2)的基础上创建一个称为 lab2 的本地分支: + +``` +athena% cd ~/6.828/lab +athena% add git +athena% git pull +Already up-to-date. +athena% git checkout -b lab2 origin/lab2 +Branch lab2 set up to track remote branch refs/remotes/origin/lab2. +Switched to a new branch "lab2" +athena% +``` + +现在,你需要将你在 lab1 分支中的改变合并到 lab2 分支中,命令如下: + +``` +athena% git merge lab1 +Merge made by recursive. + kern/kdebug.c | 11 +++++++++-- + kern/monitor.c | 19 +++++++++++++++++++ + lib/printfmt.c | 7 +++---- + 3 files changed, 31 insertions(+), 6 deletions(-) +athena% +``` + +实验 2 包含如下的新源代码,后面你将遍历它们: + +- inc/memlayout.h +- kern/pmap.c +- kern/pmap.h +- kern/kclock.h +- kern/kclock.c + +`memlayout.h` 描述虚拟地址空间的布局,这个虚拟地址空间是通过修改 `pmap.c`、`memlayout.h` 和 `pmap.h` 所定义的 *PageInfo* 数据结构来实现的,这个数据结构用于跟踪物理内存页面是否被释放。`kclock.c` 和 `kclock.h` 维护 PC 基于电池的时钟和 CMOS RAM 硬件,在 BIOS 中记录了 PC 上安装的物理内存数量,以及其它的一些信息。在 `pmap.c` 中的代码需要去读取这个设备硬件信息,以算出在这个设备上安装了多少物理内存,这些只是由你来完成的一部分代码:你不需要知道 CMOS 硬件工作原理的细节。 + +特别需要注意的是 `memlayout.h` 和 `pmap.h`,因为本实验需要你去使用和理解的大部分内容都包含在这两个文件中。你或许还需要去复习 `inc/mmu.h` 这个文件,因为它也包含了本实验中用到的许多定义。 + +开始本实验之前,记得去添加 `exokernel` 以获取 QEMU 的 6.828 版本。 + +### 实验过程 + +在你准备进行实验和写代码之前,先添加你的 `answers-lab2.txt` 文件到 Git 仓库,提交你的改变然后去运行 `make handin`。 + +``` +athena% git add answers-lab2.txt +athena% git commit -am "my answer to lab2" +[lab2 a823de9] my answer to lab2 4 files changed, 87 insertions(+), 10 deletions(-) +athena% make handin +``` + +### 第 1 部分:物理页面管理 + +操作系统必须跟踪物理内存页是否使用的状态。JOS 以页为最小粒度来管理 PC 的物理内存,以便于它使用 MMU 去映射和保护每个已分配的内存片段。 + +现在,你将要写内存的物理页分配器的代码。它使用链接到 `PageInfo` 数据结构的一组列表来保持对物理页的状态跟踪,每个列表都对应到一个物理内存页。在你能够写出剩下的虚拟内存实现之前,你需要先写出物理内存页面分配器,因为你的页表管理代码将需要去分配物理内存来存储页表。 + +> 练习 1 +> +> 在文件 `kern/pmap.c` 中,你需要去实现以下函数的代码(或许要按给定的顺序来实现)。 +> +> boot_alloc() +> +> mem_init()(只要能够调用 check_page_free_list() 即可) +> +> page_init() +> +> page_alloc() +> +> page_free() +> +> `check_page_free_list()` 和 `check_page_alloc()` 可以测试你的物理内存页分配器。你将需要引导 JOS 然后去看一下 `check_page_alloc()` 是否报告成功即可。如果没有报告成功,修复你的代码直到成功为止。你可以添加你自己的 `assert()` 以帮助你去验证是否符合你的预期。 + +本实验以及所有的 6.828 实验中,将要求你做一些检测工作,以便于你搞清楚它们是否按你的预期来工作。这个任务不需要详细描述你添加到 JOS 中的代码的细节。查找 JOS 源代码中你需要去修改的那部分的注释;这些注释中经常包含有技术规范和提示信息。你也可能需要去查阅 JOS、和 Intel 的技术手册、以及你的 6.004 或 6.033 课程笔记的相关部分。 + +### 第 2 部分:虚拟内存 + +在你开始动手之前,需要先熟悉 x86 内存管理架构的保护模式:即分段和页面转换。 + +> 练习 2 +> +> 如果你对 x86 的保护模式还不熟悉,可以查看 Intel 80386 参考手册的第 5 章和第 6 章。阅读这些章节(5.2 和 6.4)中关于页面转换和基于页面的保护。我们建议你也去了解关于段的章节;在虚拟内存和保护模式中,JOS 使用了分页、段转换、以及在 x86 上不能禁用的基于段的保护,因此你需要去理解这些基础知识。 + +### 虚拟地址、线性地址和物理地址 + +在 x86 的专用术语中,一个虚拟地址是由一个段选择器和在段中的偏移量组成。一个线性地址是在页面转换之前、段转换之后得到的一个地址。一个物理地址是段和页面转换之后得到的最终地址,它最终将进入你的物理内存中的硬件总线。 + +![屏幕快照 2018-09-04 11.22.20](https://ws1.sinaimg.cn/large/0069RVTdly1fuxgrc398jj30gx04bgm1.jpg) + +回顾实验 1 中的第 3 部分,我们安装了一个简单的页表,这样内核就可以在 0xf0100000 链接的地址上运行,尽管它实际上是加载在 0x00100000 处的 ROM BIOS 的物理内存上。这个页表仅映射了 4MB 的内存。在实验中,你将要为 JOS 去设置虚拟内存布局,我们将从虚拟地址 0xf0000000 处开始扩展它,首先将物理内存扩展到 256MB,并映射许多其它区域的虚拟内存。 + +> 练习 3 +> +> 虽然 GDB 能够通过虚拟地址访问 QEMU 的内存,它经常用于在配置虚拟内存期间检查物理内存。在实验工具指南中复习 QEMU 的监视器命令,尤其是 `xp` 命令,它可以让你去检查物理内存。访问 QEMU 监视器,可以在终端中按 `Ctrl-a c`(相同的绑定返回到串行控制台)。 +> +> 使用 QEMU 监视器的 `xp` 命令和 GDB 的 `x` 命令去检查相应的物理内存和虚拟内存,以确保你看到的是相同的数据。 +> +> 我们的打过补丁的 QEMU 版本提供一个非常有用的 `info pg` 命令:它可以展示当前页表的一个简单描述,包括所有已映射的内存范围、权限、以及标志。Stock QEMU 也提供一个 `info mem` 命令用于去展示一个概要信息,这个信息包含了已映射的虚拟内存范围和使用了什么权限。 + +在 CPU 上运行的代码,一旦处于保护模式(这是在 boot/boot.S 中所做的第一件事情)中,是没有办法去直接使用一个线性地址或物理地址的。所有的内存引用都被解释为虚拟地址,然后由 MMU 来转换,这意味着在 C 语言中的指针都是虚拟地址。 + +例如在物理内存分配器中,JOS 内存经常需要在不反向引用的情况下,去维护作为地址的一个很难懂的值或一个整数。有时它们是虚拟地址,而有时是物理地址。为便于在代码中证明,JOS 源文件中将它们区分为两种:类型 `uintptr_t` 表示一个难懂的虚拟地址,而类型 `physaddr_trepresents` 表示物理地址。这些类型其实不过是 32 位整数(uint32_t)的同义词,因此编译器不会阻止你将一个类型的数据指派为另一个类型!因为它们都是整数(而不是指针)类型,如果你想去反向引用它们,编译器将报错。 + +JOS 内核能够通过将它转换为指针类型的方式来反向引用一个 `uintptr_t` 类型。相反,内核不能反向引用一个物理地址,因为这是由 MMU 来转换所有的内存引用。如果你转换一个 `physaddr_t` 为一个指针类型,并反向引用它,你或许能够加载和存储最终结果地址(硬件将它解释为一个虚拟地址),但你并不会取得你想要的内存位置。 + +总结如下: + +| C type | Address type | +| ------------ | ------------ | +| `T*` | Virtual | +| `uintptr_t` | Virtual | +| `physaddr_t` | Physical | + +>问题: +> +>假设下面的 JOS 内核代码是正确的,那么变量 `x` 应该是什么类型?uintptr_t 还是 physaddr_t ? +> +>![屏幕快照 2018-09-04 11.48.54](https://ws3.sinaimg.cn/large/0069RVTdly1fuxgrbkqd3j30m302bmxc.jpg) +> + +JOS 内核有时需要去读取或修改它知道物理地址的内存。例如,添加一个映射到页表,可以要求分配物理内存去存储一个页目录,然后去初始化它们。然而,内核也和其它的软件一样,并不能跳过虚拟地址转换,内核并不能直接加载和存储物理地址。一个原因是 JOS 将重映射从虚拟地址 0xf0000000 处物理地址 0 开始的所有的物理地址,以帮助内核去读取和写入它知道物理地址的内存。为转换一个物理地址为一个内核能够真正进行读写操作的虚拟地址,内核必须添加 0xf0000000 到物理地址以找到在重映射区域中相应的虚拟地址。你应该使用 KADDR(pa) 去做那个添加操作。 + +JOS 内核有时也需要能够通过给定的内核数据结构中存储的虚拟地址找到内存中的物理地址。内核全局变量和通过 `boot_alloc()` 分配的内存是加载到内核的这些区域中,从 0xf0000000 处开始,到全部物理内存映射的区域。因此,在这些区域中转变一个虚拟地址为物理地址时,内核能够只是简单地减去 0xf0000000 即可得到物理地址。你应该使用 PADDR(va) 去做那个减法操作。 + +### 引用计数 + +在以后的实验中,你将会经常遇到多个虚拟地址(或多个环境下的地址空间中)同时映射到相同的物理页面上。你将在 PageInfo 数据结构中用 pp_ref 字段来提供一个引用到每个物理页面的计数器。如果一个物理页面的这个计数器为 0,表示这个页面已经被释放,因为它不再被使用了。一般情况下,这个计数器应该等于相应的物理页面出现在所有页表下面的 UTOP 的次数(UTOP 上面的映射大都是在引导时由内核设置的,并且它从不会被释放,因此不需要引用计数器)。我们也使用它去跟踪到页目录的指针数量,反过来就是,页目录到页表的数量。 + +使用 `page_alloc` 时要注意。它返回的页面引用计数总是为 0,因此,一旦对返回页做了一些操作(比如将它插入到页表),`pp_ref` 就应该增加。有时这需要通过其它函数(比如,`page_instert`)来处理,而有时这个函数是直接调用 `page_alloc` 来做的。 + +### 页表管理 + +现在,你将写一套管理页表的代码:去插入和删除线性地址到物理地址的映射表,并且在需要的时候去创建页表。 + +> 练习 4 +> +> 在文件 `kern/pmap.c` 中,你必须去实现下列函数的代码。 +> +> pgdir_walk() +> +> boot_map_region() +> +> page_lookup() +> +> page_remove() +> +> page_insert() +> +> `check_page()`,调用 `mem_init()`,测试你的页表管理动作。在进行下一步流程之前你应该确保它成功运行。 + +### 第 3 部分:内核地址空间 + +JOS 分割处理器的 32 位线性地址空间为两部分:用户环境(进程),我们将在实验 3 中开始加载和运行,它将控制其上的布局和低位部分的内容,而内核总是维护对高位部分的完全控制。线性地址的定义是在 `inc/memlayout.h` 中通过符号 ULIM 来划分的,它为内核保留了大约 256MB 的虚拟地址空间。这就解释了为什么我们要在实验 1 中给内核这样的一个高位链接地址的原因:如是不这样做的话,内核的虚拟地址空间将没有足够的空间去同时映射到下面的用户空间中。 + +你可以在 `inc/memlayout.h` 中找到一个图表,它有助于你去理解 JOS 内存布局,这在本实验和后面的实验中都会用到。 + +### 权限和缺页隔离 + +由于内核和用户的内存都存在于它们各自环境的地址空间中,因此我们需要在 x86 的页表中使用权限位去允许用户代码只能访问用户所属地址空间的部分。否则的话,用户代码中的 bug 可能会覆写内核数据,导致系统崩溃或者发生各种莫名其妙的的故障;用户代码也可能会偷窥其它环境的私有数据。 + +对于 ULIM 以上部分的内存,用户环境没有任何权限,只有内核才可以读取和写入这部分内存。对于 [UTOP,ULIM] 地址范围,内核和用户都有相同的权限:它们可以读取但不能写入这个地址范围。这个地址范围是用于向用户环境暴露某些只读的内核数据结构。最后,低于 UTOP 的地址空间是为用户环境所使用的;用户环境将为访问这些内核设置权限。 + +### 初始化内核地址空间 + +现在,你将去配置 UTOP 以上的地址空间:内核部分的地址空间。`inc/memlayout.h` 中展示了你将要使用的布局。我将使用函数去写相关的线性地址到物理地址的映射配置。 + +> 练习 5 +> +> 完成调用 `check_page()` 之后在 `mem_init()` 中缺失的代码。 + +现在,你的代码应该通过了 `check_kern_pgdir()` 和 `check_page_installed_pgdir()` 的检查。 + +> 问题: +> +> ​ 1、在这个时刻,页目录中的条目(行)是什么?它们映射的址址是什么?以及它们映射到哪里了?换句话说就是,尽可能多地填写这个表: +> +> EntryBase Virtual AddressPoints to (logically): +> +> 1023 ? Page table for top 4MB of phys memory +> +> 1022 ? ? +> +> . ? ? +> +> . ? ? +> +> . ? ? +> +> 2 0x00800000 ? +> +> 1 0x00400000 ? +> +> 0 0x00000000 [see next question] +> +> ​ 2、(来自课程 3) 我们将内核和用户环境放在相同的地址空间中。为什么用户程序不能去读取和写入内核的内存?有什么特殊机制保护内核内存? +> +> ​ 3、这个操作系统能够支持的最大的物理内存数量是多少?为什么? +> +> ​ 4、我们真实地拥有最大数量的物理内存吗?管理内存的开销有多少?这个开销可以减少吗? +> +> ​ 5、复习在 `kern/entry.S` 和 `kern/entrypgdir.c` 中的页表设置。一旦我们打开分页,EIP 中是一个很小的数字(稍大于 1MB)。在什么情况下,我们转而去运行在 KERNBASE 之上的一个 EIP?当我们启用分页并开始在 KERNBASE 之上运行一个 EIP 时,是什么让我们能够持续运行一个很低的 EIP?为什么这种转变是必需的? + +### 地址空间布局的其它选择 + +在 JOS 中我们使用的地址空间布局并不是我们唯一的选择。一个操作系统可以在低位的线性地址上映射内核,而为用户进程保留线性地址的高位部分。然而,x86 内核一般并不采用这种方法,而 x86 向后兼容模式是不这样做的其中一个原因,这种模式被称为“虚拟 8086 模式”,处理器使用线性地址空间的最下面部分是“不可改变的”,所以,如果内核被映射到这里是根本无法使用的。 + +虽然很困难,但是设计这样的内核是有这种可能的,即:不为处理器自身保留任何固定的线性地址或虚拟地址空间,而有效地允许用户级进程不受限制地使用整个 4GB 的虚拟地址空间 —— 同时还要在这些进程之间充分保护内核以及不同的进程之间相互受保护! + +将内核的内存分配系统进行概括类推,以支持二次幂为单位的各种页大小,从 4KB 到一些你选择的合理的最大值。你务必要有一些方法,将较大的分配单位按需分割为一些较小的单位,以及在需要时,将多个较小的分配单位合并为一个较大的分配单位。想一想在这样的一个系统中可能会出现些什么样的问题。 + +这个实验做完了。确保你通过了所有的等级测试,并记得在 `answers-lab2.txt` 中写下你对上述问题的答案。提交你的改变(包括添加 `answers-lab2.txt` 文件),并在 `lab` 目录下输入 `make handin` 去提交你的实验。 + +------ + +via: + +作者:[Mit][] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/%E6%A0%A1%E5%AF%B9%E8%80%85ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 \ No newline at end of file From a61da3dc091023708042bf93b0123d010382942e Mon Sep 17 00:00:00 2001 From: LuMing <784315443@qq.com> Date: Fri, 21 Sep 2018 23:10:55 +0800 Subject: [PATCH 357/455] translated --- ...e SSH Key-based Authentication In Linux.md | 226 ----------------- ...e SSH Key-based Authentication In Linux.md | 235 ++++++++++++++++++ 2 files changed, 235 insertions(+), 226 deletions(-) delete mode 100644 sources/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md create mode 100644 translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md diff --git a/sources/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md b/sources/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md deleted file mode 100644 index 8932e488e0..0000000000 --- a/sources/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md +++ /dev/null @@ -1,226 +0,0 @@ -LuMing translating -How To Configure SSH Key-based Authentication In Linux -====== - -![](https://www.ostechnix.com/wp-content/uploads/2017/01/Configure-SSH-Key-based-Authentication-In-Linux-720x340.png) - -### What is SSH Key-based authentication? - -As we all know, **Secure Shell** , shortly **SSH** , is the cryptographic network protocol that allows you to securely communicate/access a remote system over unsecured network, for example Internet. Whenever you send a data over an unsecured network using SSH, the data will be automatically encrypted in the source system, and decrypted in the destination side. SSH provides four authentication methods namely **password-based authentication** , **key-based authentication** , **Host-based authentication** , and **Keyboard authentication**. The most commonly used authentication methods are password-based and key-based authentication. - -In password-based authentication, all you need is the password of the remote system’s user. If you know the password of remote user, you can access the respective system using **“ssh[[email protected]][1]”**. On the other hand, in key-based authentication, you need to generate SSH key pairs and upload the SSH public key to the remote system in order to communicate it via SSH. Each SSH key pair consists of a private key and public key. The private key should be kept within the client system, and the public key should uploaded to the remote systems. You shouldn’t disclose the private key to anyone. Hope you got the basic idea about SSH and its authentication methods. - -In this tutorial, we will be discussing how to configure SSH key-based authentication in Linux. - -### Configure SSH Key-based Authentication In Linux - -For the purpose of this guide, I will be using Arch Linux system as local system and Ubuntu 18.04 LTS as remote system. - -Local system details: - - * **OS** : Arch Linux Desktop - * **IP address** : 192.168.225.37 /24 - - - -Remote system details: - - * **OS** : Ubuntu 18.04 LTS Server - * **IP address** : 192.168.225.22/24 - - - -### Local system configuration - -Like I said already, in SSH key-based authentication method, the public key should be uploaded to the remote system that you want to access via SSH. The public keys will usually be stored in a file called **~/.ssh/authorized_keys** in the remote SSH systems. - -**Important note:** Do not generate key pairs as **root** , as only root would be able to use those keys. Create key pairs as normal user. - -Now, let us create the SSH key pair in the local system. To do so, run the following command in your client system. -``` -$ ssh-keygen - -``` - -The above command will create 2048 bit RSA key pair. Enter the passphrase twice. More importantly, Remember your passphrase. You’ll need it later. - -**Sample output:** -``` -Generating public/private rsa key pair. -Enter file in which to save the key (/home/sk/.ssh/id_rsa): -Enter passphrase (empty for no passphrase): -Enter same passphrase again: -Your identification has been saved in /home/sk/.ssh/id_rsa. -Your public key has been saved in /home/sk/.ssh/id_rsa.pub. -The key fingerprint is: -SHA256:wYOgvdkBgMFydTMCUI3qZaUxvjs+p2287Tn4uaZ5KyE [email protected] -The key's randomart image is: -+---[RSA 2048]----+ -|+=+*= + | -|o.o=.* = | -|.oo * o + | -|. = + . o | -|. o + . S | -| . E . | -| + o | -| +.*o+o | -| .o*=OO+ | -+----[SHA256]-----+ - -``` - -In case you have already created the key pair, you will see the following message. Just type “y” to create overwrite the existing key . -``` -/home/username/.ssh/id_rsa already exists. -Overwrite (y/n)? - -``` - -Please note that **passphrase is optional**. If you give one, you’ll be asked to enter the password every time when you try to SSH a remote system unless you are using any SSH agent to store the password. If you don’t want passphrase(not safe though), simply press ENTER key twice when you’ll be asked to enter the passphrase. However, we recommend you to use passphrase. Using a password-less ssh key is generally not a good idea from a security point of view. They should be limited to very specific cases such as services having to access a remote system without the user intervention (e.g. remote backups with rsync, …). - -If you already have a ssh key without a passphrase in private file **~/.ssh/id_rsa** and wanted to update key with passphrase, use the following command: -``` -$ ssh-keygen -p -f ~/.ssh/id_rsa - -``` - -Sample output: -``` -Enter new passphrase (empty for no passphrase): -Enter same passphrase again: -Your identification has been saved with the new passphrase. - -``` - -Now, we have created the key pair in the local system. Now, copy the SSH public key to your remote SSH server using command: - -Here, I will be copying the local (Arch Linux) system’s public key to the remote system (Ubuntu 18.04 LTS in my case). Technically speaking, the above command will copy the contents of local system’s **~/.ssh/id_rsa.pub key** into remote system’s **~/.ssh/authorized_keys** file. Clear? Good. - -Type **yes** to continue connecting to your remote SSH server. And, then Enter the root user’s password of the remote system. -``` -/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed -/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys -[email protected]2.168.225.22's password: - -Number of key(s) added: 1 - -Now try logging into the machine, with: "ssh '[email protected]'" -and check to make sure that only the key(s) you wanted were added. - -``` - -If you have already copied the key, but want to update the key with new passphrase, use **-f** option to overwrite the existing key like below. - -We have now successfully added the local system’s SSH public key to the remote system. Now, let us disable the password-based authentication completely in the remote system. Because, we have configured key-based authentication, so we don’t need password-base authentication anymore. - -### Disable SSH Password-based authentication in remote system - -You need to perform the following commands as root or sudo user. - -To disable password-based authentication, go to your remote system’s console and edit **/etc/ssh/sshd_config** configuration file using any editor: -``` -$ sudo vi /etc/ssh/sshd_config - -``` - -Find the following line. Uncomment it and set it’s value as **no**. -``` -PasswordAuthentication no - -``` - -Restart ssh service to take effect the changes. -``` -$ sudo systemctl restart sshd - -``` - -### Access Remote system from local system - -Go to your local system and SSH into your remote server using command: - -Enter the passphrase. - -**Sample output:** -``` -Enter passphrase for key '/home/sk/.ssh/id_rsa': -Last login: Mon Jul 9 09:59:51 2018 from 192.168.225.37 -[email protected]:~$ - -``` - -Now, you’ll be able to SSH into your remote system. As you noticed, we have logged-in to the remote system’s account using passphrase which we created earlier using **ssh-keygen** command, not using the actual account’s password. - -If you try to ssh from another client system, you will get this error message. Say for example, I am tried to SSH into my Ubuntu system from my CentOS using command: - -**Sample output:** -``` -The authenticity of host '192.168.225.22 (192.168.225.22)' can't be established. -ECDSA key fingerprint is 67:fc:69:b7:d4:4d:fd:6e:38:44:a8:2f:08:ed:f4:21. -Are you sure you want to continue connecting (yes/no)? yes -Warning: Permanently added '192.168.225.22' (ECDSA) to the list of known hosts. -Permission denied (publickey). - -``` - -As you see in the above output, I can’t SSH into my remote Ubuntu 18.04 systems from any other systems, except the CentOS system. - -### Adding more Client system’s keys to SSH server - -This is very important. Like I said already, you can’t access the remote system via SSH, except the one you configured (In our case, it’s Ubuntu). I want to give permissions to more clients to access the remote SSH server. What should I do? Simple. You need to generate the SSH key pair in all your client systems and copy the ssh public key manually to the remote server that you want to access via SSH. - -To create SSH key pair on your client system’s, run: -``` -$ ssh-keygen - -``` - -Enter the passphrase twice. Now, the ssh key pair is generated. You need to copy the public ssh key (not private key) to your remote server manually. - -Display the pub key using command: -``` -$ cat ~/.ssh/id_rsa.pub - -``` - -You should an output something like below. - -Copy the entire contents (via USB drive or any medium) and go to your remote server’s console. Create a directory called **ssh** in the home directory as shown below. You need to execute the following commands as root user. -``` -$ mkdir -p ~/.ssh - -``` - -Now, append the your client system’s pub key which you generated in the previous step in a file called -``` -echo {Your_public_key_contents_here} >> ~/.ssh/authorized_keys - -``` - -Restart ssh service on the remote system. Now, you’ll be able to SSH to your server from the new client. - -If manually adding ssh pubkey seems difficult, enable password-based authentication temporarily in the remote system and copy the key using “ssh-copy-id” command from your local system and finally disable the password-based authentication. - -**Suggested read:** - -And, that’s all for now. SSH Key-based authentication provides an extra layer protection from brute-force attacks. As you can see, configuring key-based authentication is not that difficult either. It is one of the recommended method to keep your Linux servers safe and secure. - -I will be here soon with another useful article. Until then, stay tuned with OSTechNix. - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/configure-ssh-key-based-authentication-linux/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.ostechnix.com/author/sk/ -[1]:https://www.ostechnix.com/cdn-cgi/l/email-protection diff --git a/translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md b/translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md new file mode 100644 index 0000000000..5f88caedea --- /dev/null +++ b/translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md @@ -0,0 +1,235 @@ +如何在 Linux 中配置基于 SSH 密钥的认证 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2017/01/Configure-SSH-Key-based-Authentication-In-Linux-720x340.png) + +### 什么是基于 SSH密钥的认证? + +众所周知,**Secure Shell**,又称 **SSH**,是允许你通过无安全网络(例如 Internet)和远程系统之间安全访问/通信的加密网络协议。无论何时使用 SSH 在无安全网络上发送数据,它都会在源系统上自动地被加密,并且在目的系统上解密。SSH 提供了四种加密方式,**基于密码认证**,**基于密钥认证**,**基于主机认证**和**键盘认证**。最常用的认证方式是基于密码认证和基于密钥认证。 + +在基于密码认证中,你需要的仅仅是远程系统上用户的密码。如果你知道远程用户的密码,你可以使用**“ssh[[email protected]][1]”**访问各自的系统。另一方面,在基于密钥认证中,为了通过 SSH 通信,你需要生成 SSH 密钥对,并且为远程系统上传 SSH 公钥。每个 SSH 密钥对由私钥与公钥组成。私钥应该保存在客户系统上,公钥应该上传给远程系统。你不应该将私钥透露给任何人。希望你已经对 SSH 和它的认证方式有了基本的概念。 + +这篇教程,我们将讨论如何在 linux 上配置基于密钥认证的 SSH。 + +### 在 Linux 上配置基于密钥认证的SSH + +为本篇教程起见,我将使用 Arch Linux 为本地系统,Ubuntu 18.04 LTS 为远程系统。 + +本地系统详情: + * **OS** : Arch Linux Desktop + * **IP address** : 192.168.225.37 /24 + + + +远程系统详情: + * **OS** : Ubuntu 18.04 LTS Server + * **IP address** : 192.168.225.22/24 + + + +### 本地系统配置 + +就像我之前所说,在基于密钥认证的方法中,想要通过 SSH 访问远程系统,就应该将公钥上传给它。公钥通常会被保存在远程系统的一个文件**~/.ssh/authorized_keys** 中。 + +**注意事项:**不要使用**root** 用户生成密钥对,这样只有 root 用户才可以使用。使用普通用户创建密钥对。 + +现在,让我们在本地系统上创建一个 SSH 密钥对。只需要在客户端系统上运行下面的命令。 +``` +$ ssh-keygen + +``` + +上面的命令将会创建一个 2048 位的 RSA 密钥对。输入两次密码。更重要的是,记住你的密码。后面将会用到它。 + +**样例输出** +``` +Generating public/private rsa key pair. +Enter file in which to save the key (/home/sk/.ssh/id_rsa): +Enter passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved in /home/sk/.ssh/id_rsa. +Your public key has been saved in /home/sk/.ssh/id_rsa.pub. +The key fingerprint is: +SHA256:wYOgvdkBgMFydTMCUI3qZaUxvjs+p2287Tn4uaZ5KyE [email protected] +The key's randomart image is: ++---[RSA 2048]----+ +|+=+*= + | +|o.o=.* = | +|.oo * o + | +|. = + . o | +|. o + . S | +| . E . | +| + o | +| +.*o+o | +| .o*=OO+ | ++----[SHA256]-----+ + +``` + +如果你已经创建了密钥对,你将看到以下信息。输入 ‘y’ 就会覆盖已存在的密钥。 +``` +/home/username/.ssh/id_rsa already exists. +Overwrite (y/n)? + +``` + +请注意**密码是可选的**。如果你输入了密码,那么每次通过 SSH 访问远程系统时都要求输入密码,除非你使用了 SSH 代理保存了密码。如果你不想要密码(虽然不安全),简单地输入两次 ENTER。不过,我们建议你使用密码。从安全的角度来看,使用无密码的 ssh 密钥对大体上不是一个很好的主意。 这种方式应该限定在特殊的情况下使用,例如,没有用户介入的服务访问远程系统。(例如,用 rsync 远程备份...) + +如果你已经在个人文件 **~/.ssh/id_rsa** 中有了无密码的密钥对,但想要更新为带密码的密钥。使用下面的命令: +``` +$ ssh-keygen -p -f ~/.ssh/id_rsa + +``` + +样例输出: +``` +Enter new passphrase (empty for no passphrase): +Enter same passphrase again: +Your identification has been saved with the new passphrase. + +``` + +现在,我们已经在本地系统上创建了密钥对。接下来,使用下面的命令将 SSH 公钥拷贝到你的远程 SSH 服务端上。 +``` +$ ssh-copy-id sk@192.168.225.22 + +``` + +在这,我把本地(Arch Linux)系统上的公钥拷贝到了远程系统(Ubuntu 18.04 LTS)上。从技术上讲,上面的命令会把本地系统 **~/.ssh/id_rsa.pub key** 文件中的内容拷贝到远程系统**~/.ssh/authorized_keys** 中。明白了吗?非常棒。 + +输入 **yes** 来继续连接你的远程 SSH 服务端。接着,输入远程系统 root 用户的密码。 +``` +/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed +/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys +[email protected]2.168.225.22's password: + +Number of key(s) added: 1 + +Now try logging into the machine, with: "ssh '[email protected]'" +and check to make sure that only the key(s) you wanted were added. + +``` + +如果你已经拷贝了密钥,但想要替换为新的密码,使用 **-f** 选项覆盖已有的密钥。 +``` +$ ssh-copy-id -f sk@192.168.225.22 + +``` +我们现在已经成功地将本地系统的 SSH 公钥添加进了远程系统。现在,让我们在远程系统上完全禁用掉基于密码认证的方式。因为,我们已经配置了密钥认证,因此我们不再需要密码认证了。 + +### 在远程系统上禁用基于密码认证的 SSH + +你需要在 root 或者 sudo 用户下执行下面的命令。 + +为了禁用基于密码的认证,你需要在远程系统的控制台上编辑 **/etc/ssh/sshd_config** 配置文件: +``` +$ sudo vi /etc/ssh/sshd_config + +``` + +找到下面这一行,去掉注释然后将值设为 **no** + +``` +PasswordAuthentication no + +``` + +重启 ssh 服务让它生效。 +``` +$ sudo systemctl restart sshd + +``` + +### 从本地系统访问远程系统 + +在本地系统上使用命令 SSH 你的远程服务端: + +输入密码。 + +**样例输出:** +``` +Enter passphrase for key '/home/sk/.ssh/id_rsa': +Last login: Mon Jul 9 09:59:51 2018 from 192.168.225.37 +[email protected]:~$ + +``` + +现在,你就能 SSH 你的远程系统了。如你所见,我们已经使用之前 **ssh-keygen** 创建的密码登录进了远程系统的账户,而不是使用账户实际的密码。 + +如果你试图从其他客户端系统 ssh (远程系统),你将会得到这条错误信息。比如,我试图通过命令从 CentOS SSH 访问 Ubuntu 系统: + +**样例输出:** +``` +The authenticity of host '192.168.225.22 (192.168.225.22)' can't be established. +ECDSA key fingerprint is 67:fc:69:b7:d4:4d:fd:6e:38:44:a8:2f:08:ed:f4:21. +Are you sure you want to continue connecting (yes/no)? yes +Warning: Permanently added '192.168.225.22' (ECDSA) to the list of known hosts. +Permission denied (publickey). + +``` + +如你所见,除了 CentOS (译注:根据上文,这里应该是 Arch) 系统外,我不能通过其他任何系统 SSH 访问我的远程系统 Ubuntu 18.04。 + +### 为 SSH 服务端添加更多客户端系统的密钥 + +这点非常重要。就像我说过的那样,除非你配置过(在之前的例子中,是 Ubuntu),否则你不能通过 SSH 访问到远程系统。如果我希望给更多客户端予以权限去访问远程 SSH 服务端,我应该怎么做?很简单。你需要在所有的客户端系统上生成 SSH 密钥对并且手动拷贝 ssh 公钥到想要通过 ssh 访问的远程服务端上。 + +在客户端系统上创建 SSH 密钥对,运行: +``` +$ ssh-keygen + +``` + +输入两次密码。现在, ssh 密钥对已经生成了。你需要手动把公钥(不是私钥)拷贝到远程服务端上。 + +使用命令查看公钥: +``` +$ cat ~/.ssh/id_rsa.pub + +``` + +应该会输出如下信息: + +``` +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCt3a9tIeK5rPx9p74/KjEVXa6/OODyRp0QLS/sLp8W6iTxFL+UgALZlupVNgFjvRR5luJ9dLHWwc+d4umavAWz708e6Na9ftEPQtC28rTFsHwmyLKvLkzcGkC5+A0NdbiDZLaK3K3wgq1jzYYKT5k+IaNS6vtrx5LDObcPNPEBDt4vTixQ7GZHrDUUk5586IKeFfwMCWguHveTN7ykmo2EyL2rV7TmYq+eY2ZqqcsoK0fzXMK7iifGXVmuqTkAmZLGZK8a3bPb6VZd7KFum3Ezbu4BXZGp7FVhnOMgau2kYeOH/ItKPzpCAn+dg3NAAziCCxnII9b4nSSGz3mMY4Y7 ostechnix@centosserver + +``` +拷贝所有内容(通过 USB 驱动器或者其它任何介质),然后去你的远程服务端的控制台。像下面那样,在 home 下创建文件夹叫做 **ssh**。你需要以 root 身份执行命令。 +``` +$ mkdir -p ~/.ssh + +``` + +现在,将前几步创建的客户端系统的公钥添加进文件中。 +``` +echo {Your_public_key_contents_here} >> ~/.ssh/authorized_keys + +``` + +在远程系统上重启 ssh 服务。现在,你可以在新的客户端上 SSH 远程服务端了。 + +如果觉得手动添加 ssh 公钥有些困难,在远程系统上暂时性启用密码认证,使用 “ssh-copy-id“ 命令从本地系统上拷贝密钥,最后关闭密码认证。 + +**推荐阅读:** + +好了,到此为止。基于密钥认证的 SSH 提供了一层防止暴力破解的额外保护。如你所见,配置密钥认证一点也不困难。这是一个非常好的方法让你的 Linux 服务端安全可靠。 + +不久我就会带来另一篇有用的文章。到那时,继续关注 OSTechNix。 + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/configure-ssh-key-based-authentication-linux/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[LuuMing](https://github.com/LuuMing) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://www.ostechnix.com/cdn-cgi/l/email-protection From 76fb6f2950d49efe9d02d1175e96f3d7e187c880 Mon Sep 17 00:00:00 2001 From: pityonline Date: Thu, 20 Sep 2018 00:00:57 +0800 Subject: [PATCH 358/455] =?UTF-8?q?PRF:=20#10184=20=E6=A0=A1=E5=AF=B9?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0180308 What is open source programming.md | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/translated/talk/20180308 What is open source programming.md b/translated/talk/20180308 What is open source programming.md index 4791a64aab..1153bfe789 100644 --- a/translated/talk/20180308 What is open source programming.md +++ b/translated/talk/20180308 What is open source programming.md @@ -13,9 +13,9 @@ 首先我要说清楚一点:把你的代码放在 GitHub 的公开仓库中并不意味着把你的代码开源了。在几乎全世界,根本不用创作者做什么,只要作品形成,版权就随之而生了。在创作者进行授权之前,只有作者可以行使版权相关的权力。未经创作者授权的代码,不论有多少人在使用,都是一颗定时炸弹,只有愚蠢的人才会去用它。 -有些创作者很善良,认为“很明显我的代码是免费提供给大家使用的。”,他也并不想起诉那些用了他的代码的人,但这并不意味着这些代码可以放心使用。不论在你眼中创作者们多么善良,他们都是 *有权力* 起诉任何使用、修改代码,或未经明确授权就将代码嵌入的人。 +有些创作者很善良,认为“很明显我的代码是免费提供给大家使用的。”,他也并不想起诉那些用了他的代码的人,但这并不意味着这些代码可以放心使用。不论在你眼中创作者们多么善良,他们都 *有权力* 起诉任何使用、修改代码,或未经明确授权就将代码嵌入的人。 -很明显,你不应该在没有指定开源许可证的情况下将你的源代码发布到网上然后期望别人使用它并为其做出贡献,我建议你也尽量避免使用这种代码,甚至疑似未授权的也不要使用。如果你开发了一个函数和例程,它和之前一个疑似未授权代码很像,源代码作者就可以对你就侵权提起诉讼。 +很明显,你不应该在没有指定开源许可证的情况下将你的源代码发布到网上然后期望别人使用它并为其做出贡献。我建议你也尽量避免使用这种代码,甚至疑似未授权的也不要使用。如果你开发了一个函数和例程,它和之前一个疑似未授权代码很像,源代码作者就可以对你就侵权提起诉讼。 举个例子,Jill Schmill 写了 AwesomeLib 然后未明确授权就把它放到了 GitHub 上,就算 Jill Schmill 不起诉任何人,只要她把 AwesomeLib 的完整版权都卖给 EvilCorp,EvilCorp 就会起诉之前违规使用这段代码的人。这种行为就好像是埋下了计算机安全隐患,总有一天会为人所用。 @@ -23,19 +23,19 @@ ### 选择恰当的开源许可证 -假设你正要写一个新程序,而且打算让人们以开源的方式使用它,你需要做的就是选择最贴合你需求的[许可证][1]。和宣传中说的一样,你可以从 GitHub 所支持的 [choosealicense.com][2] 开始。这个网站设置得像个简单的问卷,特别方便快捷,点几下就能找到合适的许可证。 +假设你正要写一个新程序,而且打算让人们以开源的方式使用它,你需要做的就是选择最贴合你需求的[许可证][1]。和宣传中说的一样,你可以从 GitHub 所支持的 [choosealicense.com][2] 开始。这个网站设计得像个简单的问卷,特别方便快捷,点几下就能找到合适的许可证。 -警示:在选择许可证时不要过于自负,如果你选的是 [Apache 许可证][3]或者 [GPLv3][4] 这种广为使用的许可证,人们很容易理解其对于权利的规划,你也不需要请律师来排查其中的漏洞。你选择的许可证使用的人越少,带来的麻烦越多。 +警示:在选择许可证时不要过于自负,如果你选的是 [Apache 许可证][3]或者 [GPLv3][4] 这种广为使用的许可证,人们很容易理解他们和你都有什么权利,你也不需要请律师来排查其中的漏洞。你选择的许可证使用的人越少,带来的麻烦就越多。 -最重要的一点是: *千万不要试图自己编造许可证!* 自己编造许可证会给大家带来更多的困惑和困扰,不要这样做。如果在现有的许可证中确实找不到你需要的条款,你可以在现有的许可证中附加上你的要求,并且重点标注出来,提醒使用者们注意。 +最重要的一点是: *千万不要试图自己制造许可证!* 自己制造许可证会给大家带来更多的困惑和困扰,不要这样做。如果在现有的许可证中确实找不到你需要的条款,你可以在现有的许可证中附加上你的要求,并且重点标注出来,提醒使用者们注意。 -我知道有些人会说:“我才懒得管什么许可证,我已经把代码发到公开领域public domain了。”但问题是,公开领域的法律效力并不是受全世界认可的。在不同的国家,公开领域的效力和表现形式不同。有些国家的政府管控下,你甚至不可以把自己的源代码发到公开领域中。万幸,[Unlicense][5] 可以弥补这些漏洞,它语言简洁,使用几个词清楚地描述了“就把它放到公开领域”,但其效力为全世界认可。 +我知道有些人会站出来说:“我才懒得管什么许可证,我已经把代码发到公开领域public domain了。”但问题是,公开领域的法律效力并不是受全世界认可的。在不同的国家,公开领域的效力和表现形式不同。在有些国家的政府管控下,你甚至不可以把自己的源代码发到公开领域。万幸,[Unlicense][5] 可以弥补这些漏洞,它语言简洁,使用几个词清楚地描述了“就把它放到公开领域”,但其效力为全世界认可。 ### 怎样引入许可证 确定使用哪个许可证之后,你需要清晰而无疑义地指定它。如果你是在 GitHub、GitLab 或 BitBucket 这几个网站发布,你需要构建很多个文件夹,在根文件夹中,你应把许可证创建为一个以 `LICENSE.txt` 命名的明文文件。 -创建 `LICENSE.txt` 这个文件之后还有其他事要做。你需要在每个有效文件的页眉中添加注释块来申明许可证。如果你使用的是一现有的许可证,这一步对你来说十分简便。一个 `# 项目名 (c)2018 作者名,GPLv3 许可证,详情见 https://www.gnu.org/licenses/gpl-3.0.en.html` 这样的注释块比隐约指代的许可证的效力要强得多。 +创建 `LICENSE.txt` 这个文件之后还有其它事要做。你需要在每个重要文件的头部添加注释块来申明许可证。如果你使用的是一个现有的许可证,这一步对你来说十分简便。一个 `# 项目名 (c)2018 作者名,GPLv3 许可证,详情见 https://www.gnu.org/licenses/gpl-3.0.en.html` 这样的注释块比隐约指代的许可证的效力要强得多。 如果你是要发布在自己的网站上,步骤也差不多。先创建 `LICENSE.txt` 文件,放入许可证,再表明许可证出处。 @@ -43,31 +43,31 @@ 开源代码和专有代码的一个主要区别是开源代码写出来就是为了给别人看的。我是个 40 多岁的系统管理员,已经写过许许多多的代码。最开始我写代码是为了工作,为了解决公司的问题,所以其中大部分代码都是专有代码。这种代码的目的很简单,只要能在特定场合通过特定方式发挥作用就行。 -开源代码则大不相同。在写开源代码时,你知道它可能会被用于各种各样的环境中。也许你的使用案例的环境条件很局限,但你仍旧希望它能在各种环境下发挥理想的效果。不同的人使用这些代码时,你会看到各类冲突,还有你没有考虑过的思路。虽然代码不一定要满足所有人,但最少它们可以顺利解决使用者遇到的问题,就算解决不了,也可以转换回常见的逻辑,不会给使用者添麻烦。(例如“第 583 行出现零除错误”就不能作为错误地提供命令行参数的响应结果) +开源代码则大不相同。在写开源代码时,你知道它可能会被用于各种各样的环境中。也许你的用例的环境条件很局限,但你仍旧希望它能在各种环境下发挥理想的效果。不同的人使用这些代码时会出现各种用例,你会看到各类冲突,还有你没有考虑过的思路。虽然代码不一定要满足所有人,但至少应该得体地处理他们遇到的问题,就算解决不了,也可以转换回常见的逻辑,不会给使用者添麻烦。(例如“第 583 行出现零除错误”就不能作为错误地提供命令行参数的响应结果) -你的源代码也可能逼疯你,尤其是在你一遍又一遍地修改错误的函数或是子过程后,终于出现了你希望的结果,这时你不会叹口气就继续下一个任务,你会把过程清理干净,因为你不会愿意别人看出你一遍遍尝试的痕迹。比如你会把 `$variable`、`$lol` 全都换成有意义的 `$iterationcounter` 和 `$modelname`。这意味着你要认真专业地进行注释(尽管对于头脑风暴中的你来说它并不难懂),但为了之后有更多的人可以使用你的代码,你会尽力去注释,但注意适可而止。 +你的源代码也可能逼疯你,尤其是在你一遍又一遍地修改错误的函数或是子过程后,终于出现了你希望的结果,这时你不会叹口气就继续下一个任务,你会把过程清理干净,因为你不会愿意别人看出你一遍遍尝试的痕迹。比如你会把 `$variable`、`$lol` 全都换成有意义的 `$iterationcounter` 和 `$modelname`。这意味着你要认真专业地进行注释(尽管对于你所处的背景知识热度来说它并不难懂),因为你期望有更多的人可以使用你的代码。 -这个过程难免有些痛苦沮丧,毕竟这不是你常做的事,会有些不习惯。但它会使你成为一位更好的程序员,也会让你的代码升华。即使你的项目只有你一位贡献者,清理代码也会节约你后期的很多工作,相信我一年后你更新 app 时,你会庆幸自己现在写下的是 `$modelname`,还有清晰的注释,而不是什么不知名的数列,甚至连 `$lol` 也不是。 +这个过程难免有些痛苦沮丧,毕竟这不是你常做的事,会有些不习惯。但它会使你成为一位更好的程序员,也会让你的代码升华。即使你的项目只有你一位贡献者,清理代码也会节约你后期的很多工作,相信我一年后你再看你的 app 代码时,你会庆幸自己写下的是 `$modelname`,还有清晰的注释,而不是什么不知名的数列,甚至连 `$lol` 也不是。 ### 你并不是为你一人而写 -开源的真正核心并不是那些代码,是社区。更大的社区的项目维持的时间更长,也更容易为人们接受。因此不仅要加入社区,还要多多为社区发展贡献思路,让自己的项目能够为社区所用。 +开源的真正核心并不是那些代码,而是社区。更大的社区的项目维持时间更长,也更容易为人们所接受。因此不仅要加入社区,还要多多为社区发展贡献思路,让自己的项目能够为社区所用。 -蝙蝠侠为了完成目标暗中独自花了很大功夫,你用不着这样,你可以登录 Twitter、Reddit,或者给你项目的相关人士发邮件,发布你正在筹备新项目的消息,仔细聊聊项目的设计初衷和你的计划,让大家一起帮忙,向大家征集数据输入,类似的使用案例,把这些信息整合起来,用在你的代码里。你不用看所有的回复,但你要对它有个大概把握,这样在你之后完善时可以躲过一些陷阱。 +蝙蝠侠为了完成目标暗中独自花了很大功夫,你用不着这样,你可以登录 Twitter、Reddit,或者给你项目的相关人士发邮件,发布你正在筹备新项目的消息,仔细聊聊项目的设计初衷和你的计划,让大家一起帮忙,向大家征集数据输入,类似的使用案例,把这些信息整合起来,用在你的代码里。你不用接受所有的建议和请求,但你要对它有个大概把握,这样在你之后完善时可以躲过一些陷阱。 -不发首次通告这个过程还不算完整。如果你希望大家能够接受你的作品,并且使用它,你就要以此为初衷来设计。公众说不定可以帮到你,你不必对公开这件事如临大敌。所以不要闭门造车,既然你是为大家而写,那就开设一个真实、公开的项目,想象你在社区的监督下,认真地一步步完成它。 +发布了首次通告这个过程还不算完整。如果你希望大家能够接受你的作品并且使用它,你就要以此为初衷来设计。公众说不定可以帮到你,你不必对公开这件事如临大敌。所以不要闭门造车,既然你是为大家而写,那就开设一个真实、公开的项目,想象你在社区的帮助和监督下,认真地一步步完成它。 ### 建立项目的方式 -你可以在 GitHub、GitLab 或 BitBucket 上免费注册账号来管理你的项目。注册之后,创建知识库,建立 `README` 文件,分配一个许可证,一步步写入代码。这样可以帮你建立好习惯,让你之后和现实中的团队一起工作时,也能目的清晰地朝着目标稳妥地进行工作。这样你做得越久,就越有兴趣。 +你可以在 GitHub、GitLab 或 BitBucket 上免费注册账号来管理你的项目。注册之后,创建知识库,建立 `README` 文件,分配一个许可证,一步步写入代码。这样可以帮你建立好习惯,让你之后和现实中的团队一起工作时,也能目的清晰地朝着目标稳妥地开展工作。这样你做得越久,就越有兴趣 —— 通常会有用户先对你的项目产生兴趣。 -用户们会开始对你产生兴趣,这会让你开心也会让你不爽,但你应该亲切礼貌地对待他们,就算他们很多人根本不知道你的项目做的是什么,你可以把文件给他们看,让他们了解你在干什么。有些还在犹豫的用户可以给你提个醒,告诉你最开始设计的用户范围中落下了哪些人。 +用户会开始提一些问题,这会让你开心也会让你不爽,你应该亲切礼貌地对待他们,就算他们很多人对项目有很多误解甚至根本不知道你的项目做的是什么,你也应该礼貌专业地对待。一方面,你可以引导他们,让他们了解你在干什么。另一方面,他们也会慢慢地将你带入更大的社区。 -如果你的项目很受用户青睐,总会有开发者出现,并表示出兴趣。这也许是好事,也可能激怒你。最开始你可能只会做简单的错误修正,但总有一天你会收到拉取请求,有可能是特殊利基案例,它可能改变你项目的作用域,甚至改变你项目的初衷。你需要学会分辨哪个有贡献,根据这个决定合并哪个,婉拒哪个。 +如果你的项目很受用户青睐,总会有高级开发者出现,并表示出兴趣。这也许是好事,也可能激怒你。最开始你可能只会做简单的问题修复,但总有一天你会收到拉取请求,有可能是硬编码或特殊用例(可能会让项目变得难以维护),它可能改变你项目的作用域,甚至改变你项目的初衷。你需要学会分辨哪个有贡献,根据这个决定合并哪个,婉拒哪个。 ### 我们为什么要开源? -开源听起来任务繁重,它也确实是这样。但它对你也有很多好处。它可以在无形之中磨练你,让你写出纯净持久的代码,也教会你与人沟通,团队协作。对于一位志向远大的专业开发者来说,它是最好的简历书写者。你的未来雇主很有可能点开你的仓库,了解你的能力范围;而社区项目的开发者也有可能给你带来工作。 +开源听起来任务繁重,它也确实是这样。但它对你也有很多好处。它可以在无形之中磨练你,让你写出纯净持久的代码,也教会你与人沟通,团队协作。对于一个志向远大的专业开发者来说,它是最好的简历素材。你的未来雇主很有可能点开你的仓库,了解你的能力范围;而社区项目的开发者也有可能给你带来工作。 最后,为开源工作,意味着个人的提升,因为你在做的事不是为了你一个人,这比养活自己重要得多。 @@ -77,7 +77,7 @@ via: https://opensource.com/article/18/3/what-open-source-programming 作者:[Jim Salter][a] 译者:[Valoniakim](https://github.com/Valoniakim) -校对:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy)、[pityonline](https://github.com/pityonline) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 35d54c3449ad9a47bd6b1a75f762254ed2aa2ca4 Mon Sep 17 00:00:00 2001 From: LuMing <784315443@qq.com> Date: Sat, 22 Sep 2018 09:55:44 +0800 Subject: [PATCH 359/455] =?UTF-8?q?=E5=A2=9E=E5=87=8F=E7=A9=BA=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e SSH Key-based Authentication In Linux.md | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md b/translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md index 5f88caedea..d407e3835a 100644 --- a/translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md +++ b/translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md @@ -1,4 +1,4 @@ -如何在 Linux 中配置基于 SSH 密钥的认证 +如何在 Linux 中配置基于密钥认证的 SSH ====== ![](https://www.ostechnix.com/wp-content/uploads/2017/01/Configure-SSH-Key-based-Authentication-In-Linux-720x340.png) @@ -19,14 +19,10 @@ * **OS** : Arch Linux Desktop * **IP address** : 192.168.225.37 /24 - - 远程系统详情: * **OS** : Ubuntu 18.04 LTS Server * **IP address** : 192.168.225.22/24 - - ### 本地系统配置 就像我之前所说,在基于密钥认证的方法中,想要通过 SSH 访问远程系统,就应该将公钥上传给它。公钥通常会被保存在远程系统的一个文件**~/.ssh/authorized_keys** 中。 @@ -34,6 +30,7 @@ **注意事项:**不要使用**root** 用户生成密钥对,这样只有 root 用户才可以使用。使用普通用户创建密钥对。 现在,让我们在本地系统上创建一个 SSH 密钥对。只需要在客户端系统上运行下面的命令。 + ``` $ ssh-keygen @@ -42,6 +39,7 @@ $ ssh-keygen 上面的命令将会创建一个 2048 位的 RSA 密钥对。输入两次密码。更重要的是,记住你的密码。后面将会用到它。 **样例输出** + ``` Generating public/private rsa key pair. Enter file in which to save the key (/home/sk/.ssh/id_rsa): @@ -67,6 +65,7 @@ The key's randomart image is: ``` 如果你已经创建了密钥对,你将看到以下信息。输入 ‘y’ 就会覆盖已存在的密钥。 + ``` /home/username/.ssh/id_rsa already exists. Overwrite (y/n)? @@ -76,12 +75,14 @@ Overwrite (y/n)? 请注意**密码是可选的**。如果你输入了密码,那么每次通过 SSH 访问远程系统时都要求输入密码,除非你使用了 SSH 代理保存了密码。如果你不想要密码(虽然不安全),简单地输入两次 ENTER。不过,我们建议你使用密码。从安全的角度来看,使用无密码的 ssh 密钥对大体上不是一个很好的主意。 这种方式应该限定在特殊的情况下使用,例如,没有用户介入的服务访问远程系统。(例如,用 rsync 远程备份...) 如果你已经在个人文件 **~/.ssh/id_rsa** 中有了无密码的密钥对,但想要更新为带密码的密钥。使用下面的命令: + ``` $ ssh-keygen -p -f ~/.ssh/id_rsa ``` 样例输出: + ``` Enter new passphrase (empty for no passphrase): Enter same passphrase again: @@ -90,6 +91,7 @@ Your identification has been saved with the new passphrase. ``` 现在,我们已经在本地系统上创建了密钥对。接下来,使用下面的命令将 SSH 公钥拷贝到你的远程 SSH 服务端上。 + ``` $ ssh-copy-id sk@192.168.225.22 @@ -98,6 +100,7 @@ $ ssh-copy-id sk@192.168.225.22 在这,我把本地(Arch Linux)系统上的公钥拷贝到了远程系统(Ubuntu 18.04 LTS)上。从技术上讲,上面的命令会把本地系统 **~/.ssh/id_rsa.pub key** 文件中的内容拷贝到远程系统**~/.ssh/authorized_keys** 中。明白了吗?非常棒。 输入 **yes** 来继续连接你的远程 SSH 服务端。接着,输入远程系统 root 用户的密码。 + ``` /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys @@ -111,10 +114,12 @@ and check to make sure that only the key(s) you wanted were added. ``` 如果你已经拷贝了密钥,但想要替换为新的密码,使用 **-f** 选项覆盖已有的密钥。 + ``` $ ssh-copy-id -f sk@192.168.225.22 ``` + 我们现在已经成功地将本地系统的 SSH 公钥添加进了远程系统。现在,让我们在远程系统上完全禁用掉基于密码认证的方式。因为,我们已经配置了密钥认证,因此我们不再需要密码认证了。 ### 在远程系统上禁用基于密码认证的 SSH @@ -122,6 +127,7 @@ $ ssh-copy-id -f sk@192.168.225.22 你需要在 root 或者 sudo 用户下执行下面的命令。 为了禁用基于密码的认证,你需要在远程系统的控制台上编辑 **/etc/ssh/sshd_config** 配置文件: + ``` $ sudo vi /etc/ssh/sshd_config @@ -135,6 +141,7 @@ PasswordAuthentication no ``` 重启 ssh 服务让它生效。 + ``` $ sudo systemctl restart sshd @@ -144,9 +151,15 @@ $ sudo systemctl restart sshd 在本地系统上使用命令 SSH 你的远程服务端: +``` +$ ssh sk@192.168.225.22 + +``` + 输入密码。 **样例输出:** + ``` Enter passphrase for key '/home/sk/.ssh/id_rsa': Last login: Mon Jul 9 09:59:51 2018 from 192.168.225.37 @@ -159,6 +172,7 @@ Last login: Mon Jul 9 09:59:51 2018 from 192.168.225.37 如果你试图从其他客户端系统 ssh (远程系统),你将会得到这条错误信息。比如,我试图通过命令从 CentOS SSH 访问 Ubuntu 系统: **样例输出:** + ``` The authenticity of host '192.168.225.22 (192.168.225.22)' can't be established. ECDSA key fingerprint is 67:fc:69:b7:d4:4d:fd:6e:38:44:a8:2f:08:ed:f4:21. @@ -175,6 +189,7 @@ Permission denied (publickey). 这点非常重要。就像我说过的那样,除非你配置过(在之前的例子中,是 Ubuntu),否则你不能通过 SSH 访问到远程系统。如果我希望给更多客户端予以权限去访问远程 SSH 服务端,我应该怎么做?很简单。你需要在所有的客户端系统上生成 SSH 密钥对并且手动拷贝 ssh 公钥到想要通过 ssh 访问的远程服务端上。 在客户端系统上创建 SSH 密钥对,运行: + ``` $ ssh-keygen @@ -183,6 +198,7 @@ $ ssh-keygen 输入两次密码。现在, ssh 密钥对已经生成了。你需要手动把公钥(不是私钥)拷贝到远程服务端上。 使用命令查看公钥: + ``` $ cat ~/.ssh/id_rsa.pub @@ -194,13 +210,16 @@ $ cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCt3a9tIeK5rPx9p74/KjEVXa6/OODyRp0QLS/sLp8W6iTxFL+UgALZlupVNgFjvRR5luJ9dLHWwc+d4umavAWz708e6Na9ftEPQtC28rTFsHwmyLKvLkzcGkC5+A0NdbiDZLaK3K3wgq1jzYYKT5k+IaNS6vtrx5LDObcPNPEBDt4vTixQ7GZHrDUUk5586IKeFfwMCWguHveTN7ykmo2EyL2rV7TmYq+eY2ZqqcsoK0fzXMK7iifGXVmuqTkAmZLGZK8a3bPb6VZd7KFum3Ezbu4BXZGp7FVhnOMgau2kYeOH/ItKPzpCAn+dg3NAAziCCxnII9b4nSSGz3mMY4Y7 ostechnix@centosserver ``` + 拷贝所有内容(通过 USB 驱动器或者其它任何介质),然后去你的远程服务端的控制台。像下面那样,在 home 下创建文件夹叫做 **ssh**。你需要以 root 身份执行命令。 + ``` $ mkdir -p ~/.ssh ``` 现在,将前几步创建的客户端系统的公钥添加进文件中。 + ``` echo {Your_public_key_contents_here} >> ~/.ssh/authorized_keys @@ -212,6 +231,8 @@ echo {Your_public_key_contents_here} >> ~/.ssh/authorized_keys **推荐阅读:** +(译者注:在原文中此处有超链接) + 好了,到此为止。基于密钥认证的 SSH 提供了一层防止暴力破解的额外保护。如你所见,配置密钥认证一点也不困难。这是一个非常好的方法让你的 Linux 服务端安全可靠。 不久我就会带来另一篇有用的文章。到那时,继续关注 OSTechNix。 From 1d58e2a774ffaad09407ed56c7fcff87f163ba2c Mon Sep 17 00:00:00 2001 From: LuMing <784315443@qq.com> Date: Sat, 22 Sep 2018 12:26:06 +0800 Subject: [PATCH 360/455] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=A9=BA=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e SSH Key-based Authentication In Linux.md | 21 ------------------- 1 file changed, 21 deletions(-) diff --git a/translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md b/translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md index d407e3835a..5c69d6a92b 100644 --- a/translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md +++ b/translated/tech/20180709 How To Configure SSH Key-based Authentication In Linux.md @@ -33,7 +33,6 @@ ``` $ ssh-keygen - ``` 上面的命令将会创建一个 2048 位的 RSA 密钥对。输入两次密码。更重要的是,记住你的密码。后面将会用到它。 @@ -61,7 +60,6 @@ The key's randomart image is: | +.*o+o | | .o*=OO+ | +----[SHA256]-----+ - ``` 如果你已经创建了密钥对,你将看到以下信息。输入 ‘y’ 就会覆盖已存在的密钥。 @@ -69,7 +67,6 @@ The key's randomart image is: ``` /home/username/.ssh/id_rsa already exists. Overwrite (y/n)? - ``` 请注意**密码是可选的**。如果你输入了密码,那么每次通过 SSH 访问远程系统时都要求输入密码,除非你使用了 SSH 代理保存了密码。如果你不想要密码(虽然不安全),简单地输入两次 ENTER。不过,我们建议你使用密码。从安全的角度来看,使用无密码的 ssh 密钥对大体上不是一个很好的主意。 这种方式应该限定在特殊的情况下使用,例如,没有用户介入的服务访问远程系统。(例如,用 rsync 远程备份...) @@ -78,7 +75,6 @@ Overwrite (y/n)? ``` $ ssh-keygen -p -f ~/.ssh/id_rsa - ``` 样例输出: @@ -87,14 +83,12 @@ $ ssh-keygen -p -f ~/.ssh/id_rsa Enter new passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved with the new passphrase. - ``` 现在,我们已经在本地系统上创建了密钥对。接下来,使用下面的命令将 SSH 公钥拷贝到你的远程 SSH 服务端上。 ``` $ ssh-copy-id sk@192.168.225.22 - ``` 在这,我把本地(Arch Linux)系统上的公钥拷贝到了远程系统(Ubuntu 18.04 LTS)上。从技术上讲,上面的命令会把本地系统 **~/.ssh/id_rsa.pub key** 文件中的内容拷贝到远程系统**~/.ssh/authorized_keys** 中。明白了吗?非常棒。 @@ -110,14 +104,12 @@ Number of key(s) added: 1 Now try logging into the machine, with: "ssh '[email protected]'" and check to make sure that only the key(s) you wanted were added. - ``` 如果你已经拷贝了密钥,但想要替换为新的密码,使用 **-f** 选项覆盖已有的密钥。 ``` $ ssh-copy-id -f sk@192.168.225.22 - ``` 我们现在已经成功地将本地系统的 SSH 公钥添加进了远程系统。现在,让我们在远程系统上完全禁用掉基于密码认证的方式。因为,我们已经配置了密钥认证,因此我们不再需要密码认证了。 @@ -130,21 +122,18 @@ $ ssh-copy-id -f sk@192.168.225.22 ``` $ sudo vi /etc/ssh/sshd_config - ``` 找到下面这一行,去掉注释然后将值设为 **no** ``` PasswordAuthentication no - ``` 重启 ssh 服务让它生效。 ``` $ sudo systemctl restart sshd - ``` ### 从本地系统访问远程系统 @@ -153,7 +142,6 @@ $ sudo systemctl restart sshd ``` $ ssh sk@192.168.225.22 - ``` 输入密码。 @@ -164,7 +152,6 @@ $ ssh sk@192.168.225.22 Enter passphrase for key '/home/sk/.ssh/id_rsa': Last login: Mon Jul 9 09:59:51 2018 from 192.168.225.37 [email protected]:~$ - ``` 现在,你就能 SSH 你的远程系统了。如你所见,我们已经使用之前 **ssh-keygen** 创建的密码登录进了远程系统的账户,而不是使用账户实际的密码。 @@ -179,7 +166,6 @@ ECDSA key fingerprint is 67:fc:69:b7:d4:4d:fd:6e:38:44:a8:2f:08:ed:f4:21. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '192.168.225.22' (ECDSA) to the list of known hosts. Permission denied (publickey). - ``` 如你所见,除了 CentOS (译注:根据上文,这里应该是 Arch) 系统外,我不能通过其他任何系统 SSH 访问我的远程系统 Ubuntu 18.04。 @@ -192,7 +178,6 @@ Permission denied (publickey). ``` $ ssh-keygen - ``` 输入两次密码。现在, ssh 密钥对已经生成了。你需要手动把公钥(不是私钥)拷贝到远程服务端上。 @@ -201,28 +186,24 @@ $ ssh-keygen ``` $ cat ~/.ssh/id_rsa.pub - ``` 应该会输出如下信息: ``` ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCt3a9tIeK5rPx9p74/KjEVXa6/OODyRp0QLS/sLp8W6iTxFL+UgALZlupVNgFjvRR5luJ9dLHWwc+d4umavAWz708e6Na9ftEPQtC28rTFsHwmyLKvLkzcGkC5+A0NdbiDZLaK3K3wgq1jzYYKT5k+IaNS6vtrx5LDObcPNPEBDt4vTixQ7GZHrDUUk5586IKeFfwMCWguHveTN7ykmo2EyL2rV7TmYq+eY2ZqqcsoK0fzXMK7iifGXVmuqTkAmZLGZK8a3bPb6VZd7KFum3Ezbu4BXZGp7FVhnOMgau2kYeOH/ItKPzpCAn+dg3NAAziCCxnII9b4nSSGz3mMY4Y7 ostechnix@centosserver - ``` 拷贝所有内容(通过 USB 驱动器或者其它任何介质),然后去你的远程服务端的控制台。像下面那样,在 home 下创建文件夹叫做 **ssh**。你需要以 root 身份执行命令。 ``` $ mkdir -p ~/.ssh - ``` 现在,将前几步创建的客户端系统的公钥添加进文件中。 ``` echo {Your_public_key_contents_here} >> ~/.ssh/authorized_keys - ``` 在远程系统上重启 ssh 服务。现在,你可以在新的客户端上 SSH 远程服务端了。 @@ -239,8 +220,6 @@ echo {Your_public_key_contents_here} >> ~/.ssh/authorized_keys 干杯! - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/configure-ssh-key-based-authentication-linux/ From 33ad7e72dd099931c2f2d014d75cc9b3f8ccd43c Mon Sep 17 00:00:00 2001 From: jamelouis Date: Sat, 22 Sep 2018 12:36:46 +0800 Subject: [PATCH 361/455] translated --- ...ith openmediavault- A home NAS solution.md | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) rename {sources => translated}/tech/20180917 Getting started with openmediavault- A home NAS solution.md (60%) diff --git a/sources/tech/20180917 Getting started with openmediavault- A home NAS solution.md b/translated/tech/20180917 Getting started with openmediavault- A home NAS solution.md similarity index 60% rename from sources/tech/20180917 Getting started with openmediavault- A home NAS solution.md rename to translated/tech/20180917 Getting started with openmediavault- A home NAS solution.md index 42bb1bfe17..0c07c44ec8 100644 --- a/sources/tech/20180917 Getting started with openmediavault- A home NAS solution.md +++ b/translated/tech/20180917 Getting started with openmediavault- A home NAS solution.md @@ -1,42 +1,72 @@ [translating by jamelouis] Getting started with openmediavault: A home NAS solution + +openmediavault入门:一个家庭NAS解决方案 ====== This network-attached file server offers a solid array of features and is easy to install and configure. +这个网络附加文件服务提供了一序列功能,并且易于安装和配置。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-cloud.png?itok=vz0PIDDS) With so many cloud storage options readily available, some folks might question the value of having a home NAS (network-attached storage) server. After all, with your files on the cloud, you don't have to worry about managing the maintenance, updates, and security of your own server. +面对许多可供选择的云存储方案,一些人可能会质疑一个家庭网络附加存储服务的价值。毕竟,当所有你的文件存储在云上,你不需要为你自己云服务的维护,更新,和安全担忧。 + But that's not entirely true, is it? You have a home network, so you've got to pay at least some attention to that network's health and security. Assuming you're already keeping on top of that, then [a home NAS][1] really isn't adding that much additional hassle. And there are all kinds of benefits to gain from that minor amount of work. +但是,这不完全对,是不是?你由一个家庭网络,所以你不得不负责维护网络的健康和安全。假定你已经维护一个家庭网络,那么[一个家庭NAS][1]并不会增加额外负担。反而你能从少量的工作中得到许多的好处。 + You can have a local backup of every computer in your house (you can also back up off-site). Have a media server that holds movies, music, and photos regardless of whether your internet connection flakes out. Work on large files on multiple computers in your home without waiting for them to traverse from some random computer somewhere else on the internet. Plus, you can have your NAS pull double duty with other services, like hosting local email or a household wiki. Perhaps most importantly, with a home NAS, your data is your data—under your control and always accessible. +你可以为你家里所有的计算机备份(你也可以备份离线网站).构架一个存储电影,音乐和照片的媒体服务器,不管网络连接是否连接。在家里的多台计算机处理大型文件,不需要等待从网络其他随机的计算机传输这些文件过来。另外,可以让NAS与其他服务一起进行双重任务,如托管本地邮件或者家庭Wiki。也许最重要的是,构架家庭NAS,数据完全是你的,始终在控制下和随时可访问的。 + The follow-on question is which NAS solution to choose. Sure, you could buy a pre-built solution and call it a day, but what fun is that? And practically speaking, although it's great to have an appliance that handles everything for you, it's often better to have a rig that you can fix and upgrade yourself. This is the situation I found myself in recently. I chose to install and set up [openmediavault][2]. -### Why openmediavault? +接下来的问题是如何选择NAS方案。当然,你可以购买预先建立的解决方案,并在某一天打电话购买,但是这会有什么乐趣呢?实际上,尽管拥有一个能处理一切的设备很棒,但最好还是有一个可以修复和升级的钻机。这是一个我近期发现的解决方案。我选择安装和配置[openmediavault][2]。 + +### 为什么选择openmediavault? There are a few open source NAS solutions out there, some arguably more popular than openmediavault. When I asked around, for instance, [FreeNAS][3] was recommended the most. So why didn't I go with that? After all, it is more widely used, includes more features, and offers more support options, [according to a comparison on the FreeNAS website][4]. That's certainly all true. But openmediavault is no slouch. It's actually based on an earlier version of FreeNAS, and while its numbers are lower in terms of downloads and features, they're more than adequate for my needs. +市面上有不少开源的NAS解决方案,其中有点无可争议的比openmediavault好。当我询问周遭,例如,[freeNAS][3]最常被推荐给我。那么为什么我不采纳他们的建议呢?毕竟,它被大范围的使用,包含很多的功能,和提供许多支持选项,[基于FreeNAS官网的一份对比数据][4]。当然这些全部是对的。但是openmediavault还是不错的。它是基于FreeNAS早期版本,虽然它在下载和功能方面的数量较低,但是对于我的需求而言,它已经相当足够了。 + Another factor was a simple matter of comfort. Openmediavault's underlying operating system is [Debian][5], whereas FreeNAS sits atop [FreeBSD][6]. I'm personally not as familiar with FreeBSD, so that would make it more difficult for me to fix things if my NAS starts misbehaving. It also makes it more difficult for me to tweak things or add my own services to the machine if I want. Sure, I could learn FreeBSD and get more familiar with it, but I'm already home-building this NAS; I've found that projects tend to be more successful if you limit the number of "learning opportunities" you give yourself to complete them. +另外一个因素是它很舒适。openmediavault的底层操作系统是[Debian][5],然而FreeNAS是[FreeBSD][6]。由于我个人对FressBSD不是很熟悉,因此如果我的NAS出现故障,必定会很难在FreeBSD上修复故障。同样的,也会是我很难微调配置或添加服务到机器上。当然,我可以学习FreeBSD和更熟悉它,但是我已经在家里构架了这个NAS;我发现,如果限制给定自己完成构建NAS的“学习机会”的数量,构建NAS往往会更成功。 + Every situation is different, of course, so do your research and decide what seems to be the best fit for you. FreeNAS looks like the right solution for a lot of people. Openmediavault was the right one for me. -### Installation and configuration +当然,每个情况都不同,所以你要自己调研,然后作出最适合自己方案的决定。FreeNAS对于许多人似乎都是不错的解决方案。Openmediavault正是适合我的解决方案。 + +### 安装与配置 The installation process is pretty well covered in the [openmediavault documentation][7], so I won't rehash that here. If you've ever installed a Linux distribution, most of the steps should look familiar to you (though with a somewhat uglier [Ncurses][8] interface than you might see on modern distributions). I installed it using the [dedicated drive][9] instructions. However, those instructions, while good, are rather spartan. When you're done, you have a base system installed, but there's more to do before you can actually use your NAS to store any files. For instance, the dedicated drive instructions install openmediavault on a hard drive, but that's the operating system drive, not the one with the shared space that's accessible to other computers on your network. You need to walk yourself through setting that up and configuring it. +在[openmediavault文档]里详细记录了安装步骤,所以我不在这里重述了。如果你曾经安装过任何一个linux版本,大部分安装步骤都是很类似的(虽然在相对丑陋的[Ucurses][9]界面,不像你可能在现代版本的相对美观的安装界面)。我通过使用[专用驱动器][9]指令来安装它。然而,这些指令不但很好,而且相当精炼的。当你搞定这些指令,你安装了一个基本的系统,但是你还需要做很多才能真正构建好NAS来存储任何文件。例如,专用驱动器指令在硬盘驱动上安装openmediavault,但那是操作系统的驱动,而不是和网络上其他计算机共享空间的那个驱动。你需要自己把这些建立起来并且配置好。 + The first thing you should do is load up the administrative web interface and change the default password. This password is different from the root password you set during the installation process. It's the administrative account for the web interface, and the default username and password are `admin` and `openmediavault`, respectively—definitely something you'll want to change immediately after logging in. -#### Set up your drives +你要做的第一件事是加载管理的网页界面和修改默认密码。这个密码和之前你安装过程设置的根密码是不同的。这是网页洁面的管理员账号,和默认的账户和密码分别是’admin‘和‘openmediavault’,当你登入后自然而然地会修改这些配置属性。 + +#### 设置你的驱动 Once you've installed openmediavault, you need it to actually do stuff for you. The first logical step is to set up the drives that you're going to use for storage. I'm assuming that you've already got them physically installed, so all you have to do at this point is get openmediavault to recognize them and configure them. The first step is making sure those disks are visible. The sidebar menu has a lot of options, but it's very sensibly organized. Go to **Storage - > Disks**. Once you click that, you should see all of the drives you've installed on your server, including the one where you actually installed openmediavault. If you don't see all of your drives there, click the Scan button to see if it picks them up. Usually, it's not a problem. +一旦你安装好openmediavault,你需要它为你做一些工作。逻辑上的第一个步骤是设置好你即将用来作为存储的驱动。在这里,我假定你已经物理上安装好它们了,所以接下来你要做的就是让openmediavault识别和配置它们。第一步是确保这些磁盘是可见的。侧边栏菜单有很多选项,而且被精心的归类了。选择**存储 - > 磁盘**。一旦你点击该菜单,你应该能够看到所有你已经安装到该服务器的驱动,包括那个你已经用来安装openmediavault的驱动。如果你没有在那里看到所有驱动,点击扫描按钮去看它能够接载它们。通常,这不会是一个问题。 + You could mount these drives individually to set them up as your file share, but for a file server, you'll want some redundancy. You want to be able to treat multiple drives as a single volume and recover your data if a drive fails or add new drives when you start running out of space. That means you're going to want a [RAID][10]. The topic of what specific type of RAID configuration you want is a deep rabbit hole that deserves an article all of its own (and many have been written), but suffice it to say that you'll need more than one drive, and in the best case, all of your drives store the same amount of data. +当你的文件共享时,你可以独立的挂载和设置这些驱动,但是对于一个文件服务器,你将想要一些冗余驱动。你想要能够把很多驱动当作一个单一卷和能够在某一个驱动出现故障或者空间不足下安装新驱动的情况下恢复你的数据。这意味你将需要一个[RAID][10]。你想要的什么特定类型的RAID的主题是一个深深的兔子洞,是一个值得另写一片文章专门来讲述它(而且已经有很多关于该主题的文章了),但是简而言之是你将需要不仅仅一个驱动和最好的情况下,你的所有驱动都存储一样数量的数据。 + Openmediavault supports all standard RAID levels, so you're good to go there. Configure your RAID in **Storage - > RAID Management**. Configuration is absurdly simple: Click the Create button, choose the disks you want in your RAID array, the RAID level you want to use, and a name for the array. Openmediavault handles the rest for you. There's no messing around at the command line, trying to remember which flags to use with the `mdadm` command. In my specific case, I have six 2-TB drives that I've set up as RAID 10. +openmedia支持所有标准的RAID级别,所以多了解RAID对你很有好处的。可以在**存储 - > RAID管理**配置你的RAID。配置是相当简单:点击创建按钮,在你的RAID阵列里选择你想要的磁盘和你想要使用的RAID级别,和给这个阵列一个名字。openmediavault为你处理剩下的工作。没有混乱的命令行,试图记住‘mdadm'命令的一些标志参数。在我特别的例子,我有六个2TB驱动,并被设置为RAID 10. + With your RAID set up, you've almost got a place to store things. You just need to set up a file system. Just like your desktop computer, a hard drive doesn't do you any good until you format it. So the next place to go in openmediavault's control panel is **Storage - > File Systems**. Just like configuring your RAID, click the Create button and follow the prompts. In this case, you choose the device to format. If you have only the one RAID on your server, it should be something like `md0`. You'll also need to choose the filesystem type. If you're not sure, just use the standard ext4 type. +当你的RAID构建好了,基本上你已经有一个地方可以存储东西了。你仅仅需要设置一个文件系统。正如你的桌面系统,一个硬盘驱动在没有格式化情况下是没什么用处的。所以下一个你要去的地方的是位于openmediavault控制面板里的**存储 - > 文件系统**。和配置你的RAID一样,点击创建按钮,然后跟着提示操作。如果你只有一个RAID在你的服务器上,你应该可以看到一个像’md0‘的东西。你也需要选择文件系统的类别。如果你不能确定,选择标准的ext4类型即可。 + #### Define your shares Sweet! You've got a place to store files. Now you just need to make it visible on your home network. Configure this from the **Services** section of the openmediavault control panel. When it comes to setting up a file share on a network, there are really two main choices: NFS or SMB/CIFS. As a rule of thumb, if all of the computers on your network are running Linux distributions, then you're probably better off using NFS. However, if your home network is a mixed environment with a combination of Linux, Windows, Mac OS, and embedded devices, then SMB/CIFS is probably the right choice. @@ -51,6 +81,8 @@ Once you do that, you're pretty much good to go. You'll need to access your shar Have fun! +玩得开心! + -------------------------------------------------------------------------------- via: https://opensource.com/article/18/9/openmediavault From 8ff74ac4fc0e985716ddbc4ba83bf837255caaa3 Mon Sep 17 00:00:00 2001 From: jrg Date: Sat, 22 Sep 2018 13:18:00 +0800 Subject: [PATCH 362/455] Update 20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md --- ...minutes with Hugo, a static site generator written in Go.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md b/sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md index 465941491c..cc1b5531d1 100644 --- a/sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md +++ b/sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md @@ -1,3 +1,6 @@ +【翻译中】translating by jrglinux! + + Start a blog in 30 minutes with Hugo, a static site generator written in Go ====== From 7a7dcf7a422622db3d8fb4bfcee010551b02cc4a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 22 Sep 2018 13:30:59 +0800 Subject: [PATCH 363/455] PRF:20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md @geekpi --- ...o Automatically Purge Old Trashed Files.md | 40 ++++++------------- 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/translated/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md b/translated/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md index 03d429fef3..a16e264dcb 100644 --- a/translated/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md +++ b/translated/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md @@ -1,36 +1,33 @@ -Autotrash - 一个自动清除旧垃圾的命令行工具 +Autotrash:一个自动清除旧垃圾的命令行工具 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/09/autotrash-720x340.png) -**Autotrash** 是一个命令行程序,它用于自动清除旧的已删除文件。它将清除超过指定天数的在回收站中的文件。你不需要清空回收站或执行 SHIFT+DELETE 以永久清除文件/文件夹。Autortrash 将处理回收站中的内容,并在特定时间段后自动删除它们。简而言之,Autotrash 永远不会让你的垃圾变得太大。 +**Autotrash** 是一个命令行程序,它用于自动清除旧的已删除文件。它将清除超过指定天数的在回收站中的文件。你不需要清空回收站或执行 `SHIFT+DELETE` 以永久清除文件/文件夹。Autortrash 将处理回收站中的内容,并在特定时间段后自动删除它们。简而言之,Autotrash 永远不会让你的垃圾变得太大。 ### 安装 Autotrash -Autotrash 默认存在于基于 Debian 系统的仓库中。要在 Debian、Ubuntu、Linux Mint 上安装 autotrash,请运行: +Autotrash 默认存在于基于 Debian 系统的仓库中。要在 Debian、Ubuntu、Linux Mint 上安装 `autotrash`,请运行: ``` $ sudo apt-get install autotrash - ``` 在 Fedora 上: ``` $ sudo dnf install autotrash - ``` 对于 Arch linux 及其变体,你可以使用任何 AUR 助手程序, 如 [**Yay**][1] 安装它。 ``` $ yay -S autotrash-git - ``` ### 自动清除旧的垃圾文件 -每当你运行 autotrash 时,它会扫描你的 **`~/.local/share/Trash/info`** 目录并读取 **`.trashinfo`** 以找出它们的删除日期。如果文件已在回收站中超过指定的日期,那么就会删除它们。 +每当你运行 `autotrash` 时,它会扫描你的 `~/.local/share/Trash/info` 目录并读取 `.trashinfo` 以找出它们的删除日期。如果文件已在回收站中超过指定的日期,那么就会删除它们。 让我举几个例子。 @@ -38,91 +35,78 @@ $ yay -S autotrash-git ``` $ autotrash -d 30 - ``` 如上例所示,如果回收站中的文件超过 30 天,Autotrash 会自动将其从回收站中删除。你无需手动删除它们。只需将没用的文件放到回收站即可忘记。Autotrash 将处理已删除的文件。 -以上命令仅处理当前登录用户的垃圾目录。如果要使 autotrash 处理所有用户的垃圾目录(不仅仅是在你的家目录中),请使用 **-t** 选项,如下所示。 +以上命令仅处理当前登录用户的垃圾目录。如果要使 autotrash 处理所有用户的垃圾目录(不仅仅是在你的家目录中),请使用 `-t` 选项,如下所示。 ``` $ autotrash -td 30 - ``` Autotrash 还允许你根据回收站可用容量或磁盘可用空间来删除已删除的文件。 -例如,看下下面的例子。 +例如,看下下面的例子: ``` $ autotrash --max-free 1024 -d 30 - ``` -根据上面的命令,如果回收站的剩余的空间少于**1GB**,那么 autotrash 将从回收站中清除超过**30 天**的已删除文件。如果你的回收站空间不足,这可能很有用。 +根据上面的命令,如果回收站的剩余的空间少于 **1GB**,那么 autotrash 将从回收站中清除超过 **30 天**的已删除文件。如果你的回收站空间不足,这可能很有用。 我们还可以从回收站中按最早的时间清除文件直到回收站至少有 1GB 的空间。 ``` $ autotrash --min-free 1024 - ``` 在这种情况下,对旧的已删除文件没有限制。 -你可以将这两个选项(**`--min-free`** 和 **`--max-free`**)组合在一个命令中,如下所示。 +你可以将这两个选项(`--min-free` 和 `--max-free`)组合在一个命令中,如下所示。 ``` $ autotrash --max-free 2048 --min-free 1024 -d 30 - ``` -根据上面的命令,如果可用空间小于 **2GB**,autotrash 将读取回收站,接着关注容量。此时,删除超过 30 天的文件,如果少于 **1GB** 的可用空间,则删除更新的文件。 +根据上面的命令,如果可用空间小于 **2GB**,`autotrash` 将读取回收站,接着关注容量。此时,删除超过 30 天的文件,如果少于 **1GB** 的可用空间,则删除更新的文件。 -如你所见,所有命令都应由用户手动运行。你可能想知道,我该如何自动执行此任务?这很容易!只需将 autotrash 添加为 crontab 任务即可。现在,命令将在计划的时间自动运行,并根据定义的选项清除回收站中的文件。 +如你所见,所有命令都应由用户手动运行。你可能想知道,我该如何自动执行此任务?这很容易!只需将 `autotrash` 添加为 crontab 任务即可。现在,命令将在计划的时间自动运行,并根据定义的选项清除回收站中的文件。 要在 crontab 中添加这些命令,请运行: ``` $ crontab -e - ``` 添加任务,例如: ``` @daily /usr/bin/autotrash -d 30 - ``` 现在,autotrash 将每天清除回收站中超过 30 天的文件。 有关计划任务的更多详细信息,请参阅以下链接。 - + [Cron 任务的初学者指南]][2] + [如何在 Linux 中轻松安全地管理 Cron 作业]][3] - 请注意,如果你无意中删除了任何重要文件,它们将在规定的日期后永久消失,所以请小心。 请参阅手册页以了解有关 Autotrash 的更多信息。 ``` $ man autotrash - ``` -清空回收站或按 SHIFT+DELETE 永久删除 Linux 系统中没用的东西没什么大不了的。它只需要几秒钟。但是,如果你需要额外的程序来处理垃圾文件,Autotrash 可能会有所帮助。试一下,看看它是如何工作的。 +清空回收站或按 `SHIFT+DELETE` 永久删除 Linux 系统中没用的东西没什么大不了的。它只需要几秒钟。但是,如果你需要额外的程序来处理垃圾文件,Autotrash 可能会有所帮助。试一下,看看它是如何工作的。 就是这些了。希望这个有用。还有更多的好东西。 干杯! - - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/autotrash-a-cli-tool-to-automatically-purge-old-trashed-files/ @@ -130,7 +114,7 @@ via: https://www.ostechnix.com/autotrash-a-cli-tool-to-automatically-purge-old-t 作者:[SK][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 1c95e77056f5f9845b3534ded9d42742bfeac7b7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 22 Sep 2018 13:31:20 +0800 Subject: [PATCH 364/455] PUB:20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md @geekpi https://linux.cn/article-10038-1.html --- ...trash - A CLI Tool To Automatically Purge Old Trashed Files.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md (100%) diff --git a/translated/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md b/published/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md similarity index 100% rename from translated/tech/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md rename to published/20180907 Autotrash - A CLI Tool To Automatically Purge Old Trashed Files.md From 18d6e8fb62bd52ec48c93f81063d3d0b871f75d7 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 22 Sep 2018 14:09:15 +0800 Subject: [PATCH 365/455] PRF:20180903 Turn your vi editor into a productivity powerhouse.md @idea2act --- ...i editor into a productivity powerhouse.md | 89 +++++++------------ 1 file changed, 30 insertions(+), 59 deletions(-) diff --git a/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md b/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md index e2e209017f..ab3876c3e0 100644 --- a/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md +++ b/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md @@ -1,9 +1,10 @@ 增强 Vim 编辑器,提高编辑效率 ====== +> 这 20 多个有用的命令可以增强你使用 Vi 的体验。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk) -编者注:标题和文章最初提到的 `vi` 编辑器,现已更新为编辑器的正确名称:`Vim`。 +*编者注:标题和文章最初称呼的 `vi` 编辑器,现已更新为编辑器的正确名称:`Vim`。* `Vim` 作为一款功能强大、选项丰富的编辑器,为许多用户所热爱。本文介绍了一些在 `Vim` 中默认未启用但实际非常有用的选项。虽然可以在每个 `Vim` 会话中单独启用,但为了创建一个开箱即用的高效编辑环境,还是建议在 `Vim` 的配置文件中配置这些命令。 @@ -13,23 +14,23 @@ (注意:`vimrc` 文件也用于 `Linux` 中的全局配置,如 `/etc/vimrc` 或 `/etc/vim/vimrc`。本文所说的 `.vimrc` 均是指位于用户主目录中的 `.vimrc` 文件。) -`Linux` 系统中: +Linux 系统中: * 用 `Vim` 打开 `.vimrc` 文件: `vim ~/.vimrc` * 复制本文最后的 `选项列表` 粘贴到 `.vimrc` 文件 * 保存并关闭 (`:wq`) -译者注:此处不建议使用 `Vim` 编辑 `.vimrc` 文件,因为很可能无法粘贴成功,可以选择 `gedit` 编辑器编辑 `.vimrc` 文件。 +(LCTT 译注:此处不建议使用 `Vim` 编辑 `.vimrc` 文件,因为很可能无法粘贴成功,可以选择 `gedit` 编辑器编辑 `.vimrc` 文件。) -`Windows` 系统中: +Windows 系统中: * 首先,[安装 gvim][1] * 打开 `gvim` - * 单击 `编辑` -> `启动设置`,打开 `_vimrc` 文件 - * 复制本文最后的 `选项列表` 粘贴到 `_vimrc` 文件 - * 单击 `文件` -> `保存` + * 单击 “编辑” -> “启动设置”,打开 `_vimrc` 文件 + * 复制本文最后的 “选项列表” 粘贴到 `_vimrc` 文件 + * 单击 “文件” -> “保存” -译者注:此处应注意不要使用 `Windows` 自带的记事本编辑该 `_vimrc` 文件。 +(LCTT 译注:此处应注意不要使用 `Windows` 自带的记事本编辑该 `_vimrc` 文件,否则可能会因为行结束符不同而导致问题。) 下面,我们将深入研究提高 `Vim` 编辑效率的选项。主要分为以下几类: @@ -40,7 +41,7 @@ 5. 拼写 6. 其他选项 -## 1. 缩进 & 制表符 +### 1. 缩进 & 制表符 使 `Vim` 在创建新行的时候使用与上一行同样的缩进: @@ -56,7 +57,7 @@ set smartindent 注意:`Vim` 具有语言感知功能,且其默认设置可以基于文件中的编程语言来改变配置以提高效率。有许多默认的配置选项,包括 `axs cindent`,`cinoptions`,`indentexpr` 等,没有在这里说明。 `syn` 是一个非常有用的命令,用于设置文件的语法以更改显示模式。 -译者注:这里的 `syn` 是指 `syntax`,可用于设置文件所用的编程语言,开启对应的语法高亮,以及执行自动事件 (`autocmd`)。 +(LCTT 译注:这里的 `syn` 是指 `syntax`,可用于设置文件所用的编程语言,开启对应的语法高亮,以及执行自动事件 (`autocmd`)。) 设置文件里的制表符 `(TAB)` 的宽度(以空格的数量表示): @@ -78,7 +79,7 @@ set expandtab 注意:这可能会导致依赖于制表符的 `Python` 等编程语言出现问题。这时,你可以根据文件类型设置该选项(请参考 `autocmd`)。 -## 2. 显示 & 格式化 +### 2. 显示 & 格式化 要在每行的前面显示行号: @@ -100,9 +101,9 @@ set textwidth=80 set wrapmargin=2 ``` -译者注:如果 `textwidth` 选项不等于零,本选项无效。 +(LCTT 译注:如果 `textwidth` 选项不等于零,本选项无效。) -插入括号时,短暂地跳转到匹配的括号: +当光标遍历文件时经过括号时,高亮标识匹配的括号: ```vim set showmatch @@ -110,7 +111,7 @@ set showmatch ![](https://opensource.com/sites/default/files/uploads/picture02-03.jpg) -## 3. 搜索 +### 3. 搜索 高亮搜索内容的所有匹配位置: @@ -142,20 +143,22 @@ set smartcase 例如,如果文件内容是: -> test\ -> Test +``` +test +Test +``` 当打开 `ignorecase` 和 `smartcase` 选项时,搜索 `test` 时的突出显示: -> test\ +> test > Test 搜索 `Test` 时的突出显示: -> test\ +> test > Test -## 4. 浏览 & 滚动 +### 4. 浏览 & 滚动 为获得更好的视觉体验,你可能希望将光标放在窗口中间而不是第一行,以下选项使光标距窗口上下保留 5 行。 @@ -163,7 +166,7 @@ set smartcase set scrolloff=5 ``` -一个例子: +一个例子: 第一张图中 `scrolloff=0`,第二张图中 `scrolloff=5`。 @@ -179,7 +182,7 @@ set laststatus=2 ![](https://opensource.com/sites/default/files/picture08.png) -## 5. 拼写 +### 5. 拼写 `Vim` 有一个内置的拼写检查器,对于文本编辑和编码非常有用。`Vim` 可以识别文件类型并仅对代码中的注释进行拼写检查。使用下面的选项打开英语拼写检查: @@ -187,9 +190,9 @@ set laststatus=2 set spell spelllang=en_us ``` -译者注:中文、日文或其它东亚语字符通常会在打开拼写检查时被标为拼写错误,因为拼写检查不支持这些语种,可以在 `spelllang` 选项中加入 `cjk` 来忽略这些错误标注。 +(LCTT 译注:中文、日文或其它东亚语字符通常会在打开拼写检查时被标为拼写错误,因为拼写检查不支持这些语种,可以在 `spelllang` 选项中加入 `cjk` 来忽略这些错误标注。) -## 6. 其他选项 +### 6. 其他选项 禁止创建备份文件:启用此选项后,`Vim` 将在覆盖文件前创建一个备份,文件成功写入后保留该备份。如果不想保留该备份文件,可以按下面的方式关闭: @@ -227,9 +230,7 @@ set errorbells set visualbell ``` -## 惊喜 - -vi provides long-format as well as short-format commands. Either format can be used to set or unset the configuration. +### 惊喜 `Vim` 提供长格式和短格式命令,两种格式都可用于设置或取消选项配置。 @@ -245,8 +246,6 @@ set autoindent set ai ``` -To see the current configuration setting of a command without changing its current value, use `?` at the end: - 要在不更改选项当前值的情况下查看其当前设置,可以在 `Vim` 的命令行上使用在末尾加上 `?` 的命令: ```vim @@ -271,71 +270,43 @@ set noautoindent ![](https://opensource.com/sites/default/files/uploads/picture10-11.jpg) -注意:此处列出的命令仅对 `Linux` 上的 `Vim 7.4` 版本和 `Windows` 上的 `Vim 8.0` 版本进行了测试。 +注意:此处列出的命令仅对 Linux 上的 Vim 7.4 版本和 Windows 上的 Vim 8.0 版本进行了测试。 这些有用的命令肯定会增强您的 `Vim` 使用体验。你会推荐哪些其他有用的命令? -## 选项列表 +### 选项列表 复制该选项列表粘贴到 `.vimrc` 文件中: ```vim " Indentation & Tabs - set autoindent - set smartindent - set tabstop=4 - set shiftwidth=4 - set expandtab - set smarttab - " Display & format - set number - set textwidth=80 - set wrapmargin=2 - set showmatch - " Search - set hlsearch - set incsearch - set ignorecase - set smartcase - " Browse & Scroll - set scrolloff=5 - set laststatus=2 - " Spell - set spell spelllang=en_us - " Miscellaneous - set nobackup - set noswapfile - set autochdir - set undofile - set visualbell - set errorbells ``` @@ -346,7 +317,7 @@ via: https://opensource.com/article/18/9/vi-editor-productivity-powerhouse 作者:[Girish Managoli][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[idea2act](https://github.com/idea2act) -校对:[apemost](https://github.com/apemost) +校对:[apemost](https://github.com/apemost), [wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From f6b283471b54eba02b8ab17cd507a699f8de31bc Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 22 Sep 2018 14:10:07 +0800 Subject: [PATCH 366/455] PUB:20180903 Turn your vi editor into a productivity powerhouse.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @idea2act https://linux.cn/article-10039-1.html 翻译的棒极了,很用心。 --- ...20180903 Turn your vi editor into a productivity powerhouse.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180903 Turn your vi editor into a productivity powerhouse.md (100%) diff --git a/translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md b/published/20180903 Turn your vi editor into a productivity powerhouse.md similarity index 100% rename from translated/tech/20180903 Turn your vi editor into a productivity powerhouse.md rename to published/20180903 Turn your vi editor into a productivity powerhouse.md From 7ada5aa2f946bceff8184776cf5b36716f7a6e06 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 22 Sep 2018 14:10:55 +0800 Subject: [PATCH 367/455] PRF:20180903 Turn your vi editor into a productivity powerhouse.md --- ...180903 Turn your vi editor into a productivity powerhouse.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/published/20180903 Turn your vi editor into a productivity powerhouse.md b/published/20180903 Turn your vi editor into a productivity powerhouse.md index ab3876c3e0..41fb8e50d7 100644 --- a/published/20180903 Turn your vi editor into a productivity powerhouse.md +++ b/published/20180903 Turn your vi editor into a productivity powerhouse.md @@ -8,7 +8,7 @@ `Vim` 作为一款功能强大、选项丰富的编辑器,为许多用户所热爱。本文介绍了一些在 `Vim` 中默认未启用但实际非常有用的选项。虽然可以在每个 `Vim` 会话中单独启用,但为了创建一个开箱即用的高效编辑环境,还是建议在 `Vim` 的配置文件中配置这些命令。 -## 开始前的准备 +### 开始前的准备 这里所说的选项或配置均位于用户主目录中的 `Vim` 启动配置文件 `.vimrc`。 按照下面的说明在 `.vimrc` 中设置选项: From 28510acb2f0ba5eea95c00efce4738e02bb383bd Mon Sep 17 00:00:00 2001 From: jamelouis Date: Sat, 22 Sep 2018 15:31:30 +0800 Subject: [PATCH 368/455] translated --- ...ith openmediavault- A home NAS solution.md | 59 ++++--------------- 1 file changed, 13 insertions(+), 46 deletions(-) diff --git a/translated/tech/20180917 Getting started with openmediavault- A home NAS solution.md b/translated/tech/20180917 Getting started with openmediavault- A home NAS solution.md index 0c07c44ec8..833180811a 100644 --- a/translated/tech/20180917 Getting started with openmediavault- A home NAS solution.md +++ b/translated/tech/20180917 Getting started with openmediavault- A home NAS solution.md @@ -1,85 +1,52 @@ -[translating by jamelouis] -Getting started with openmediavault: A home NAS solution - openmediavault入门:一个家庭NAS解决方案 ====== -This network-attached file server offers a solid array of features and is easy to install and configure. - 这个网络附加文件服务提供了一序列功能,并且易于安装和配置。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-cloud.png?itok=vz0PIDDS) -With so many cloud storage options readily available, some folks might question the value of having a home NAS (network-attached storage) server. After all, with your files on the cloud, you don't have to worry about managing the maintenance, updates, and security of your own server. - 面对许多可供选择的云存储方案,一些人可能会质疑一个家庭网络附加存储服务的价值。毕竟,当所有你的文件存储在云上,你不需要为你自己云服务的维护,更新,和安全担忧。 -But that's not entirely true, is it? You have a home network, so you've got to pay at least some attention to that network's health and security. Assuming you're already keeping on top of that, then [a home NAS][1] really isn't adding that much additional hassle. And there are all kinds of benefits to gain from that minor amount of work. +但是,这不完全对,是不是?你有一个家庭网络,所以你不得不负责维护网络的健康和安全。假定你已经维护一个家庭网络,那么[一个家庭NAS][1]并不会增加额外负担。反而你能从少量的工作中得到许多的好处。 -但是,这不完全对,是不是?你由一个家庭网络,所以你不得不负责维护网络的健康和安全。假定你已经维护一个家庭网络,那么[一个家庭NAS][1]并不会增加额外负担。反而你能从少量的工作中得到许多的好处。 - -You can have a local backup of every computer in your house (you can also back up off-site). Have a media server that holds movies, music, and photos regardless of whether your internet connection flakes out. Work on large files on multiple computers in your home without waiting for them to traverse from some random computer somewhere else on the internet. Plus, you can have your NAS pull double duty with other services, like hosting local email or a household wiki. Perhaps most importantly, with a home NAS, your data is your data—under your control and always accessible. - -你可以为你家里所有的计算机备份(你也可以备份离线网站).构架一个存储电影,音乐和照片的媒体服务器,不管网络连接是否连接。在家里的多台计算机处理大型文件,不需要等待从网络其他随机的计算机传输这些文件过来。另外,可以让NAS与其他服务一起进行双重任务,如托管本地邮件或者家庭Wiki。也许最重要的是,构架家庭NAS,数据完全是你的,始终在控制下和随时可访问的。 - -The follow-on question is which NAS solution to choose. Sure, you could buy a pre-built solution and call it a day, but what fun is that? And practically speaking, although it's great to have an appliance that handles everything for you, it's often better to have a rig that you can fix and upgrade yourself. This is the situation I found myself in recently. I chose to install and set up [openmediavault][2]. +你可以为你家里所有的计算机备份(你也可以备份离线网站).构架一个存储电影,音乐和照片的媒体服务器,无需担心网络连接是否连接。在家里的多台计算机处理大型文件,不需要等待从网络其他随机的计算机传输这些文件过来。另外,可以让NAS与其他服务一起进行双重任务,如托管本地邮件或者家庭Wiki。也许最重要的是,构架家庭NAS,数据完全是你的,始终在控制下和随时可访问的。 接下来的问题是如何选择NAS方案。当然,你可以购买预先建立的解决方案,并在某一天打电话购买,但是这会有什么乐趣呢?实际上,尽管拥有一个能处理一切的设备很棒,但最好还是有一个可以修复和升级的钻机。这是一个我近期发现的解决方案。我选择安装和配置[openmediavault][2]。 ### 为什么选择openmediavault? -There are a few open source NAS solutions out there, some arguably more popular than openmediavault. When I asked around, for instance, [FreeNAS][3] was recommended the most. So why didn't I go with that? After all, it is more widely used, includes more features, and offers more support options, [according to a comparison on the FreeNAS website][4]. That's certainly all true. But openmediavault is no slouch. It's actually based on an earlier version of FreeNAS, and while its numbers are lower in terms of downloads and features, they're more than adequate for my needs. +市面上有不少开源的NAS解决方案,其中有些无可争议的比openmediavault流行。当我询问周遭,例如,[freeNAS][3]最常被推荐给我。那么为什么我不采纳他们的建议呢?毕竟,它被大范围的使用,包含很多的功能,并且提供许多支持选项,[基于FreeNAS官网的一份对比数据][4]。当然这些全部是对的。但是openmediavault也不差。它是基于FreeNAS早期版本,虽然它在下载和功能方面的数量较低,但是对于我的需求而言,它已经相当足够了。 -市面上有不少开源的NAS解决方案,其中有点无可争议的比openmediavault好。当我询问周遭,例如,[freeNAS][3]最常被推荐给我。那么为什么我不采纳他们的建议呢?毕竟,它被大范围的使用,包含很多的功能,和提供许多支持选项,[基于FreeNAS官网的一份对比数据][4]。当然这些全部是对的。但是openmediavault还是不错的。它是基于FreeNAS早期版本,虽然它在下载和功能方面的数量较低,但是对于我的需求而言,它已经相当足够了。 - -Another factor was a simple matter of comfort. Openmediavault's underlying operating system is [Debian][5], whereas FreeNAS sits atop [FreeBSD][6]. I'm personally not as familiar with FreeBSD, so that would make it more difficult for me to fix things if my NAS starts misbehaving. It also makes it more difficult for me to tweak things or add my own services to the machine if I want. Sure, I could learn FreeBSD and get more familiar with it, but I'm already home-building this NAS; I've found that projects tend to be more successful if you limit the number of "learning opportunities" you give yourself to complete them. - -另外一个因素是它很舒适。openmediavault的底层操作系统是[Debian][5],然而FreeNAS是[FreeBSD][6]。由于我个人对FressBSD不是很熟悉,因此如果我的NAS出现故障,必定会很难在FreeBSD上修复故障。同样的,也会是我很难微调配置或添加服务到机器上。当然,我可以学习FreeBSD和更熟悉它,但是我已经在家里构架了这个NAS;我发现,如果限制给定自己完成构建NAS的“学习机会”的数量,构建NAS往往会更成功。 - -Every situation is different, of course, so do your research and decide what seems to be the best fit for you. FreeNAS looks like the right solution for a lot of people. Openmediavault was the right one for me. +另外一个因素是它让我感到很舒适。openmediavault的底层操作系统是[Debian][5],然而FreeNAS是[FreeBSD][6]。由于我个人对FressBSD不是很熟悉,因此如果我的NAS出现故障,必定会很难在FreeBSD上修复故障。同样的,也会让我觉得很难微调配置或添加服务到机器上。当然,我可以学习FreeBSD和更熟悉它,但是我已经在家里构架了这个NAS;我发现,如果限制给定自己完成构建NAS的“学习机会”的数量,构建NAS往往会更成功。 当然,每个情况都不同,所以你要自己调研,然后作出最适合自己方案的决定。FreeNAS对于许多人似乎都是不错的解决方案。Openmediavault正是适合我的解决方案。 ### 安装与配置 -The installation process is pretty well covered in the [openmediavault documentation][7], so I won't rehash that here. If you've ever installed a Linux distribution, most of the steps should look familiar to you (though with a somewhat uglier [Ncurses][8] interface than you might see on modern distributions). I installed it using the [dedicated drive][9] instructions. However, those instructions, while good, are rather spartan. When you're done, you have a base system installed, but there's more to do before you can actually use your NAS to store any files. For instance, the dedicated drive instructions install openmediavault on a hard drive, but that's the operating system drive, not the one with the shared space that's accessible to other computers on your network. You need to walk yourself through setting that up and configuring it. - 在[openmediavault文档]里详细记录了安装步骤,所以我不在这里重述了。如果你曾经安装过任何一个linux版本,大部分安装步骤都是很类似的(虽然在相对丑陋的[Ucurses][9]界面,不像你可能在现代版本的相对美观的安装界面)。我通过使用[专用驱动器][9]指令来安装它。然而,这些指令不但很好,而且相当精炼的。当你搞定这些指令,你安装了一个基本的系统,但是你还需要做很多才能真正构建好NAS来存储任何文件。例如,专用驱动器指令在硬盘驱动上安装openmediavault,但那是操作系统的驱动,而不是和网络上其他计算机共享空间的那个驱动。你需要自己把这些建立起来并且配置好。 -The first thing you should do is load up the administrative web interface and change the default password. This password is different from the root password you set during the installation process. It's the administrative account for the web interface, and the default username and password are `admin` and `openmediavault`, respectively—definitely something you'll want to change immediately after logging in. - -你要做的第一件事是加载管理的网页界面和修改默认密码。这个密码和之前你安装过程设置的根密码是不同的。这是网页洁面的管理员账号,和默认的账户和密码分别是’admin‘和‘openmediavault’,当你登入后自然而然地会修改这些配置属性。 +你要做的第一件事是加载用来管理的网页界面和修改默认密码。这个密码和之前你安装过程设置的根密码是不同的。这是网页洁面的管理员账号,和默认的账户和密码分别是 `admin` 和 `openmediavault`,当你登入后自然而然地会修改这些配置属性。 #### 设置你的驱动 -Once you've installed openmediavault, you need it to actually do stuff for you. The first logical step is to set up the drives that you're going to use for storage. I'm assuming that you've already got them physically installed, so all you have to do at this point is get openmediavault to recognize them and configure them. The first step is making sure those disks are visible. The sidebar menu has a lot of options, but it's very sensibly organized. Go to **Storage - > Disks**. Once you click that, you should see all of the drives you've installed on your server, including the one where you actually installed openmediavault. If you don't see all of your drives there, click the Scan button to see if it picks them up. Usually, it's not a problem. - 一旦你安装好openmediavault,你需要它为你做一些工作。逻辑上的第一个步骤是设置好你即将用来作为存储的驱动。在这里,我假定你已经物理上安装好它们了,所以接下来你要做的就是让openmediavault识别和配置它们。第一步是确保这些磁盘是可见的。侧边栏菜单有很多选项,而且被精心的归类了。选择**存储 - > 磁盘**。一旦你点击该菜单,你应该能够看到所有你已经安装到该服务器的驱动,包括那个你已经用来安装openmediavault的驱动。如果你没有在那里看到所有驱动,点击扫描按钮去看它能够接载它们。通常,这不会是一个问题。 -You could mount these drives individually to set them up as your file share, but for a file server, you'll want some redundancy. You want to be able to treat multiple drives as a single volume and recover your data if a drive fails or add new drives when you start running out of space. That means you're going to want a [RAID][10]. The topic of what specific type of RAID configuration you want is a deep rabbit hole that deserves an article all of its own (and many have been written), but suffice it to say that you'll need more than one drive, and in the best case, all of your drives store the same amount of data. - 当你的文件共享时,你可以独立的挂载和设置这些驱动,但是对于一个文件服务器,你将想要一些冗余驱动。你想要能够把很多驱动当作一个单一卷和能够在某一个驱动出现故障或者空间不足下安装新驱动的情况下恢复你的数据。这意味你将需要一个[RAID][10]。你想要的什么特定类型的RAID的主题是一个深深的兔子洞,是一个值得另写一片文章专门来讲述它(而且已经有很多关于该主题的文章了),但是简而言之是你将需要不仅仅一个驱动和最好的情况下,你的所有驱动都存储一样数量的数据。 -Openmediavault supports all standard RAID levels, so you're good to go there. Configure your RAID in **Storage - > RAID Management**. Configuration is absurdly simple: Click the Create button, choose the disks you want in your RAID array, the RAID level you want to use, and a name for the array. Openmediavault handles the rest for you. There's no messing around at the command line, trying to remember which flags to use with the `mdadm` command. In my specific case, I have six 2-TB drives that I've set up as RAID 10. - openmedia支持所有标准的RAID级别,所以多了解RAID对你很有好处的。可以在**存储 - > RAID管理**配置你的RAID。配置是相当简单:点击创建按钮,在你的RAID阵列里选择你想要的磁盘和你想要使用的RAID级别,和给这个阵列一个名字。openmediavault为你处理剩下的工作。没有混乱的命令行,试图记住‘mdadm'命令的一些标志参数。在我特别的例子,我有六个2TB驱动,并被设置为RAID 10. -With your RAID set up, you've almost got a place to store things. You just need to set up a file system. Just like your desktop computer, a hard drive doesn't do you any good until you format it. So the next place to go in openmediavault's control panel is **Storage - > File Systems**. Just like configuring your RAID, click the Create button and follow the prompts. In this case, you choose the device to format. If you have only the one RAID on your server, it should be something like `md0`. You'll also need to choose the filesystem type. If you're not sure, just use the standard ext4 type. +当你的RAID构建好了,基本上你已经有一个地方可以存储东西了。你仅仅需要设置一个文件系统。正如你的桌面系统,一个硬盘驱动在没有格式化情况下是没什么用处的。所以下一个你要去的地方的是位于openmediavault控制面板里的 **存储 - > 文件系统**。和配置你的RAID一样,点击创建按钮,然后跟着提示操作。如果你只有一个RAID在你的服务器上,你应该可以看到一个像 `md0`的东西。你也需要选择文件系统的类别。如果你不能确定,选择标准的ext4类型即可。 -当你的RAID构建好了,基本上你已经有一个地方可以存储东西了。你仅仅需要设置一个文件系统。正如你的桌面系统,一个硬盘驱动在没有格式化情况下是没什么用处的。所以下一个你要去的地方的是位于openmediavault控制面板里的**存储 - > 文件系统**。和配置你的RAID一样,点击创建按钮,然后跟着提示操作。如果你只有一个RAID在你的服务器上,你应该可以看到一个像’md0‘的东西。你也需要选择文件系统的类别。如果你不能确定,选择标准的ext4类型即可。 +#### 定义你的共享 -#### Define your shares +亲爱的!你有个地方可以存储文件了。现在你只需要让它在你的家庭网络中可见。可以从在openmediavault控制面板上的**服务**部分上配置。当谈到在网络上设置文件共享,有两个主要的选择:NFS或者SMB/CIFS. 根据以往经验,如果你网络上的所有计算机都是Linux系统,那么你使用NFS会更好。然而,当你家庭网络是一个混合环境,是一个包含Linux,Windows,苹果系统和嵌入式设备的组合,那么SMB/CIF可能会是你合适的选择。 -Sweet! You've got a place to store files. Now you just need to make it visible on your home network. Configure this from the **Services** section of the openmediavault control panel. When it comes to setting up a file share on a network, there are really two main choices: NFS or SMB/CIFS. As a rule of thumb, if all of the computers on your network are running Linux distributions, then you're probably better off using NFS. However, if your home network is a mixed environment with a combination of Linux, Windows, Mac OS, and embedded devices, then SMB/CIFS is probably the right choice. +这些选项不是互斥的。实际上,你可以在服务器上运行这些服务和同时拥有这些服务的好处。或者你可以混合起来,如果你有一个特定的设备做特定的任务。不管你的使用场景是怎样,配置这些服务是相当简单。点击你想要的服务,从它配置中激活它,和在网络中设定你想要的共享文件夹为可见。在基于SMB/CIFS共享的情况下,相对于NFS多了一些可用的配置,但是一般用默认配置就挺好的,接着可以在默认基础上修改配置。最酷的事情是它很容易配置,同时也很容易在需要的时候修改配置。 -These options aren't mutually exclusive. You could actually run both services on your server and get the best of both worlds. Or you could mix it up if you have specific devices dedicated to particular tasks. Whatever your usage scenario, configuring these services is dirt simple. Click on the service you want, enable it from its Settings, and define the shared folders you want visible on the network. In the case of SMB/CIFS shares, there are a few more settings available than with NFS, but most of the defaults are fine to start with. The cool thing is that since it's so easy to configure, it's also pretty easy to change on the fly. +#### 用户配置 -#### Configure users +基本上已将完成了。你已经在RAID配置你的驱动。你已经用一种文件系统格式化了RAID。和你已经在格式化的RAID上设定了共享文件夹。剩下来的一件事情是配置那些人可以访问这些共享和可以访问多少。这个可以在 **访问权限管理** 配置区设置。使用 **用户** 和 **群组** 选项来设定可以连接到你共享文件加的用户和设定这些共享文件的访问权限。 -You're almost done. You've configured your drives in a RAID. You've formatted that RAID with a file system. And you've defined shared folders on that formatted RAID. The only thing left is saying who can access those shares and how much. This is handled from the **Access Rights Management** section. Use the **User** and **Group** sections to define the users who connect to your shared folders and the permissions they have with the files in those folders. - -Once you do that, you're pretty much good to go. You'll need to access your shares from your various client machines, but that's a topic for another article. - -Have fun! +一旦你完成用户配置,你几乎准备好了。你需要从不同客户端机器访问你的共享,但是这是另外一个可以单独写个文章的话题了。 玩得开心! @@ -89,7 +56,7 @@ via: https://opensource.com/article/18/9/openmediavault 作者:[Jason van Gumster][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:[jamelouis](https://github.com/jamelouis) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 12e6e6cc5b37020e9478e674c2a8b9c0ff625c71 Mon Sep 17 00:00:00 2001 From: jrg Date: Sat, 22 Sep 2018 16:25:37 +0800 Subject: [PATCH 369/455] Create 20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md --- ..., a static site generator written in Go.md | 128 ++++++++++++++++++ 1 file changed, 128 insertions(+) create mode 100644 translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md diff --git a/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md b/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md new file mode 100644 index 0000000000..71528d7848 --- /dev/null +++ b/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md @@ -0,0 +1,128 @@ +Hugo,30分钟搭建博客,一个Go语言开发的静态站点生成工具 +====== + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy) + 你是不是强烈的想搭建博客来将自己对软件框架等的探索学习成果分享呢? + 你是不是面对缺乏指导文档而一团糟的项目就有一种想去改变它的冲动呢? + 或者换个角度,你是不是十分期待能创建一个属于自己的个人博客网站呢? + 很多人在想搭建博客之前都有一些严重的迟疑顾虑:感觉自己缺乏内容管理系统(CMS)的相关知识,更缺乏时间去学习这些知识。现在,如果我说不用花费大把的时间去学习 CMS 系统、学习如何创建一个静态网站、更不用操心如何去强化网站以防止它受到黑客攻击的问题,你就可以在 30 分钟之内创建一个博客?你信不信?利用 Hugo 工具,就可以实现这一切。 + ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_1.png?itok=JgxBSOBG) + Hugo 是一个基于 Go 语言开发的静态站点生成工具。也许你会问,为什么选择它? + * 无需数据库、无需需要各种权限的插件、无需跑在服务器上的底层平台,更没有额外的安全问题。 + * 都是静态站点,因此拥有轻量级、快速响应的服务性能。此外,所有的网页都是在部署的时候呈现,所以服务器负载很小。 + * 极易操作的版本控制。一些 CMS 平台使用它们自己的版本控制软件(VCS)或者在网页上集成 Git 工具。而 Hugo,所有的源文件都可以用你所选的 VCS 软件来管理。 + ### 0-5 分钟:下载 Hugo,生成一个网站 +直白的说,Hugo 使得写一个网站又一次变得有趣起来。让我们来个 30 分钟计时,搭建一个网站。 + 为了简化 Hugo 安装流程,这里直接使用 Hugo 可执行安装文件。 + 1. 下载和你操作系统匹配的 Hugo [版本][2]; + + 2. 压缩包解压到指定路径,例如 windows 系统的 `C:\hugo_dir` 或者 Linux 系统的 `~/hugo_dir` 目录;下文中的变量 `${HUGO_HOME}` 所指的路径就是这个安装目录; + 3. 打开命令行终端,进入安装目录:`cd ${HUGO_HOME}`; + + 4. 确认 Hugo 已经启动: + + * Unix 系统:`${HUGO_HOME}/[hugo version]`; + * Windows 系统:`${HUGO_HOME}\[hugo.exe version]`; + + 例如:Windows 系统下,cmd 命令行中输入:`c:\hugo_dir\hugo version` 。 + 为了书写上的简化,下文中的 `hugo` 就是指 hugo 可执行文件所在的路径(包括可执行文件),例如命令 `hugo version` 就是指命令 `c:\hugo_dir\hugo version` 。(译者注:可以把 hugo 可执行文件所在的路径添加到系统环境变量下,这样就可以直接在终端中输入 `hugo version`) + 如果命令 `hugo version` 报错,你可能下载了错误的版本。当然,有很多种方法安装 Hugo,更多详细信息请查阅 [官方文档][3]。最稳妥的方法就是把 Hugo 可执行文件放在某个路径下,然后执行的时候带上路径名 + 5. 创建一个新的站点来作为你的博客,输入命令:`hugo new site awesome-blog`; + + 6. 进入新创建的路径下: `cd awesome-blog`; + 恭喜你!你已经创建了自己的新博客。 + ### 5-10 分钟:为博客设置主题 + Hugo 中你可以自己构建博客的主题或者使用网上已经有的一些主题。这里选择 [Kiera][4] 主题,因为它简洁漂亮。按以下步骤来安装该主题: + 1. 进入主题所在目录:`cd themes`; + + 2. 克隆主题:`git clone https://github.com/avianto/hugo-kiera kiera`。如果你没有安装 Git 工具: + * 从 [Github][5] 上下载 hugo 的 .zip 格式的文件; + * 解压该 .zip 文件到你的博客主题 `theme` 路径; + * 重命名 `hugo-kiera-master` 为 `kiera`; + + 3. 返回博客主路径:`cd awesome-blog`; + + 4. 激活主题;通常来说,主题(包括 Kiera )都自带文件夹 `exampleSite`,里面存放了内容配置的示例文件。激活 Kiera 主题需要拷贝它提供的 `config.toml` 到你的博客下: + * Unix 系统:`cp themes/kiera/exampleSite/config.toml .`; + * Windows 系统:`copy themes\kiera\exampleSite\config.toml .`; + * 选择 `Yes` 来覆盖原有的 `config.toml`; + + 5. ( 可选操作 )你可以选择可视化的方式启动服务器来验证主题是否生效:`hugo server -D` 然后在浏览器中输入 `http://localhost:1313`。可用通过在终端中输入 `Crtl+C` 来停止服务器运行。现在你的博客还是空的,但这也给你留了写作的空间。它看起来如下所示: + ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_2.png?itok=PINOIOSU) + 你已经成功的给博客设置了主题!你可以在官方 [Hugo 主题][4] 网站上找到上百种漂亮的主题供你使用。 + ### 10-20 分钟:给博客添加内容 + 对于碗来说,它是空的时候用处最大,可以用来盛放东西;但对于博客来说不是这样,空博客几乎毫无用处。在这一步,你将会给博客添加内容。Hugo 和 Kiera 主题都为这个工作提供了方便性。按以下步骤来进行你的第一次提交: + 1. archetypes 将会是你的内容模板。 + + 2. 添加主题中的 archtypes 至你的博客: + * Unix 系统: `cp themes/kiera/archetypes/* archetypes/` + * Windows 系统:`copy themes\kiera\archetypes\* archetypes\` + * 选择 `Yes` 来覆盖原来的 `default.md` 内容架构类型 + 3. 创建博客 posts 目录: + * Unix 系统: `mkdir content/posts` + * Windows 系统: `mkdir content\posts` + + 4. 利用 Hugo 生成你的 post: + * Unix 系统:`hugo nes posts/first-post.md`; + * Windows 系统:`hugo new posts\first-post.md`; + + 5. 在文本编辑器中打开这个新建的 post 文件: + * Unix 系统:`gedit content/posts/first-post.md`; + * Windows 系统:`notepadd content\posts\first-post.md`; + 此刻,你可以疯狂起来了。注意到你的提交文件中包括两个部分。第一部分是以 `+++` 符号分隔开的。它包括了提交文档的主要数据,例如名称、时间等。在 Hugo 中,这叫做前缀。在前缀之后,才是正文。下面编辑第一个提交文件内容: + ``` ++++ + title = "First Post" + date = 2018-03-03T13:23:10+01:00 + draft = false + tags = ["Getting started"] + categories = [] + +++ + Hello Hugo world! No more excuses for having no blog or documentation now! + ``` + 现在你要做的就是启动你的服务器:`hugo server -D`;然后打开浏览器,输入 `http://localhost:1313/`。 +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_3.png?itok=I-_v0qLx) + ### 20-30 分钟:调整网站 + 前面的工作很完美,但还有一些问题需要解决。例如,简单地命名你的站点: + 1. 终端中按下 `Ctrl+C` 以停止服务器。 + + 2. 打开 `config.toml`,编辑博客的名称,版权,你的姓名,社交网站等等。 + 当你再次启动服务器后,你会发现博客私人订制味道更浓了。不过,还少一个重要的基础内容:主菜单。快速的解决这个问题。返回 `config.toml` 文件,在末尾插入如下一段: +``` +[[menu.main]] + name = "Home" #Name in the navigation bar + weight = 10 #The larger the weight, the more on the right this item will be + url = "/" #URL address + [[menu.main]] + name = "Posts" + weight = 20 + url = "/posts/" + ``` + 上面这段代码添加了 `Home` 和 `Posts` 到主菜单中。你还需要一个 `About` 页面。这次是创建一个 `.md` 文件,而不是编辑 `config.toml` 文件: + 1. 创建 `about.md` 文件:`hugo new about.md` 。注意它是 `about.md`,不是 `posts/about.md`。该页面不是博客提交内容,所以你不想它显示到博客内容提交当中吧。 + + 2. 用文本编辑器打开该文件,输入如下一段: +``` ++++ + title = "About" + date = 2018-03-03T13:50:49+01:00 + menu = "main" #Display this page on the nav menu + weight = "30" #Right-most nav item + meta = "false" #Do not display tags or categories + +++ + > Waves are the practice of the water. Shunryu Suzuki + ``` + 当你启动你的服务器并输入:`http://localhost:1313/`,你将会看到你的博客。(访问我 Gihub 主页上的 [例子][6] )如果你想让文章的菜单栏和 Github 相似,给 `themes/kiera/static/css/styles.css` 打上这个 [补丁][7]。 + -------------------------------------------------------------------------------- + via: https://opensource.com/article/18/3/start-blog-30-minutes-hugo + 作者:[Marek Czernek][a] +译者:[jrg](https://github.com/jrglinux) +校对:[校对者ID](https://github.com/校对者ID) + 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + [a]:https://opensource.com/users/mczernek +[1]:https://gohugo.io/ +[2]:https://github.com/gohugoio/hugo/releases +[3]:https://gohugo.io/getting-started/installing/ +[4]:https://themes.gohugo.io/ +[5]:https://github.com/avianto/hugo-kiera +[6]:https://m-czernek.github.io/awesome-blog/ +[7]:https://github.com/avianto/hugo-kiera/pull/18/files From 94734b077081011aba900164e39d21e79b604caa Mon Sep 17 00:00:00 2001 From: jrg Date: Sat, 22 Sep 2018 16:27:31 +0800 Subject: [PATCH 370/455] Update 20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md --- ...th Hugo, a static site generator written in Go.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md b/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md index 71528d7848..1b0059adad 100644 --- a/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md +++ b/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md @@ -110,15 +110,17 @@ Hugo,30分钟搭建博客,一个Go语言开发的静态站点生成工具 meta = "false" #Do not display tags or categories +++ > Waves are the practice of the water. Shunryu Suzuki + ``` 当你启动你的服务器并输入:`http://localhost:1313/`,你将会看到你的博客。(访问我 Gihub 主页上的 [例子][6] )如果你想让文章的菜单栏和 Github 相似,给 `themes/kiera/static/css/styles.css` 打上这个 [补丁][7]。 - -------------------------------------------------------------------------------- - via: https://opensource.com/article/18/3/start-blog-30-minutes-hugo - 作者:[Marek Czernek][a] + +-------------------------------------------------------------------------------- +via: https://opensource.com/article/18/3/start-blog-30-minutes-hugo +作者:[Marek Czernek][a] 译者:[jrg](https://github.com/jrglinux) 校对:[校对者ID](https://github.com/校对者ID) - 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - [a]:https://opensource.com/users/mczernek +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 +[a]:https://opensource.com/users/mczernek [1]:https://gohugo.io/ [2]:https://github.com/gohugoio/hugo/releases [3]:https://gohugo.io/getting-started/installing/ From 2ffa31f084d32d3d9d3fc743ef6eeea36f9a0d1c Mon Sep 17 00:00:00 2001 From: jrg Date: Sat, 22 Sep 2018 16:30:54 +0800 Subject: [PATCH 371/455] Update 20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md --- ..., a static site generator written in Go.md | 85 +++++++++++++++---- 1 file changed, 67 insertions(+), 18 deletions(-) diff --git a/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md b/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md index 1b0059adad..f5366353b3 100644 --- a/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md +++ b/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md @@ -1,38 +1,54 @@ Hugo,30分钟搭建博客,一个Go语言开发的静态站点生成工具 ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy) + 你是不是强烈的想搭建博客来将自己对软件框架等的探索学习成果分享呢? + 你是不是面对缺乏指导文档而一团糟的项目就有一种想去改变它的冲动呢? + 或者换个角度,你是不是十分期待能创建一个属于自己的个人博客网站呢? + 很多人在想搭建博客之前都有一些严重的迟疑顾虑:感觉自己缺乏内容管理系统(CMS)的相关知识,更缺乏时间去学习这些知识。现在,如果我说不用花费大把的时间去学习 CMS 系统、学习如何创建一个静态网站、更不用操心如何去强化网站以防止它受到黑客攻击的问题,你就可以在 30 分钟之内创建一个博客?你信不信?利用 Hugo 工具,就可以实现这一切。 + ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_1.png?itok=JgxBSOBG) + Hugo 是一个基于 Go 语言开发的静态站点生成工具。也许你会问,为什么选择它? - * 无需数据库、无需需要各种权限的插件、无需跑在服务器上的底层平台,更没有额外的安全问题。 - * 都是静态站点,因此拥有轻量级、快速响应的服务性能。此外,所有的网页都是在部署的时候呈现,所以服务器负载很小。 - * 极易操作的版本控制。一些 CMS 平台使用它们自己的版本控制软件(VCS)或者在网页上集成 Git 工具。而 Hugo,所有的源文件都可以用你所选的 VCS 软件来管理。 + * 无需数据库、无需需要各种权限的插件、无需跑在服务器上的底层平台,更没有额外的安全问题。 + * 都是静态站点,因此拥有轻量级、快速响应的服务性能。此外,所有的网页都是在部署的时候呈现,所以服务器负载很小。 + * 极易操作的版本控制。一些 CMS 平台使用它们自己的版本控制软件(VCS)或者在网页上集成 Git 工具。而 Hugo,所有的源文件都可以用你所选的 VCS 软件来管理。 + ### 0-5 分钟:下载 Hugo,生成一个网站 -直白的说,Hugo 使得写一个网站又一次变得有趣起来。让我们来个 30 分钟计时,搭建一个网站。 + + 直白的说,Hugo 使得写一个网站又一次变得有趣起来。让我们来个 30 分钟计时,搭建一个网站。 + 为了简化 Hugo 安装流程,这里直接使用 Hugo 可执行安装文件。 - 1. 下载和你操作系统匹配的 Hugo [版本][2]; + + 1. 下载和你操作系统匹配的 Hugo [版本][2]; 2. 压缩包解压到指定路径,例如 windows 系统的 `C:\hugo_dir` 或者 Linux 系统的 `~/hugo_dir` 目录;下文中的变量 `${HUGO_HOME}` 所指的路径就是这个安装目录; - 3. 打开命令行终端,进入安装目录:`cd ${HUGO_HOME}`; + + 3. 打开命令行终端,进入安装目录:`cd ${HUGO_HOME}`; 4. 确认 Hugo 已经启动: - * Unix 系统:`${HUGO_HOME}/[hugo version]`; * Windows 系统:`${HUGO_HOME}\[hugo.exe version]`; - 例如:Windows 系统下,cmd 命令行中输入:`c:\hugo_dir\hugo version` 。 - 为了书写上的简化,下文中的 `hugo` 就是指 hugo 可执行文件所在的路径(包括可执行文件),例如命令 `hugo version` 就是指命令 `c:\hugo_dir\hugo version` 。(译者注:可以把 hugo 可执行文件所在的路径添加到系统环境变量下,这样就可以直接在终端中输入 `hugo version`) - 如果命令 `hugo version` 报错,你可能下载了错误的版本。当然,有很多种方法安装 Hugo,更多详细信息请查阅 [官方文档][3]。最稳妥的方法就是把 Hugo 可执行文件放在某个路径下,然后执行的时候带上路径名 - 5. 创建一个新的站点来作为你的博客,输入命令:`hugo new site awesome-blog`; + 例如:Windows 系统下,cmd 命令行中输入:`c:\hugo_dir\hugo version`。 + + 为了书写上的简化,下文中的 `hugo` 就是指 hugo 可执行文件所在的路径(包括可执行文件),例如命令 `hugo version` 就是指命令 `c:\hugo_dir\hugo version` 。(译者注:可以把 hugo 可执行文件所在的路径添加到系统环境变量下,这样就可以直接在终端中输入 `hugo version`) + 如果命令 `hugo version` 报错,你可能下载了错误的版本。当然,有很多种方法安装 Hugo,更多详细信息请查阅 [官方文档][3]。最稳妥的方法就是把 Hugo 可执行文件放在某个路径下,然后执行的时候带上路径名 + + 5. 创建一个新的站点来作为你的博客,输入命令:`hugo new site awesome-blog`; 6. 进入新创建的路径下: `cd awesome-blog`; + 恭喜你!你已经创建了自己的新博客。 + ### 5-10 分钟:为博客设置主题 + Hugo 中你可以自己构建博客的主题或者使用网上已经有的一些主题。这里选择 [Kiera][4] 主题,因为它简洁漂亮。按以下步骤来安装该主题: - 1. 进入主题所在目录:`cd themes`; + + 1. 进入主题所在目录:`cd themes`; 2. 克隆主题:`git clone https://github.com/avianto/hugo-kiera kiera`。如果你没有安装 Git 工具: * 从 [Github][5] 上下载 hugo 的 .zip 格式的文件; @@ -47,17 +63,23 @@ Hugo,30分钟搭建博客,一个Go语言开发的静态站点生成工具 * 选择 `Yes` 来覆盖原有的 `config.toml`; 5. ( 可选操作 )你可以选择可视化的方式启动服务器来验证主题是否生效:`hugo server -D` 然后在浏览器中输入 `http://localhost:1313`。可用通过在终端中输入 `Crtl+C` 来停止服务器运行。现在你的博客还是空的,但这也给你留了写作的空间。它看起来如下所示: + ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_2.png?itok=PINOIOSU) + 你已经成功的给博客设置了主题!你可以在官方 [Hugo 主题][4] 网站上找到上百种漂亮的主题供你使用。 + ### 10-20 分钟:给博客添加内容 + 对于碗来说,它是空的时候用处最大,可以用来盛放东西;但对于博客来说不是这样,空博客几乎毫无用处。在这一步,你将会给博客添加内容。Hugo 和 Kiera 主题都为这个工作提供了方便性。按以下步骤来进行你的第一次提交: - 1. archetypes 将会是你的内容模板。 + + 1. archetypes 将会是你的内容模板。 2. 添加主题中的 archtypes 至你的博客: * Unix 系统: `cp themes/kiera/archetypes/* archetypes/` * Windows 系统:`copy themes\kiera\archetypes\* archetypes\` * 选择 `Yes` 来覆盖原来的 `default.md` 内容架构类型 - 3. 创建博客 posts 目录: + + 3. 创建博客 posts 目录: * Unix 系统: `mkdir content/posts` * Windows 系统: `mkdir content\posts` @@ -68,7 +90,9 @@ Hugo,30分钟搭建博客,一个Go语言开发的静态站点生成工具 5. 在文本编辑器中打开这个新建的 post 文件: * Unix 系统:`gedit content/posts/first-post.md`; * Windows 系统:`notepadd content\posts\first-post.md`; - 此刻,你可以疯狂起来了。注意到你的提交文件中包括两个部分。第一部分是以 `+++` 符号分隔开的。它包括了提交文档的主要数据,例如名称、时间等。在 Hugo 中,这叫做前缀。在前缀之后,才是正文。下面编辑第一个提交文件内容: + + 此刻,你可以疯狂起来了。注意到你的提交文件中包括两个部分。第一部分是以 `+++` 符号分隔开的。它包括了提交文档的主要数据,例如名称、时间等。在 Hugo 中,这叫做前缀。在前缀之后,才是正文。下面编辑第一个提交文件内容: + ``` +++ title = "First Post" @@ -79,14 +103,21 @@ Hugo,30分钟搭建博客,一个Go语言开发的静态站点生成工具 +++ Hello Hugo world! No more excuses for having no blog or documentation now! ``` + 现在你要做的就是启动你的服务器:`hugo server -D`;然后打开浏览器,输入 `http://localhost:1313/`。 + ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_3.png?itok=I-_v0qLx) + ### 20-30 分钟:调整网站 + 前面的工作很完美,但还有一些问题需要解决。例如,简单地命名你的站点: - 1. 终端中按下 `Ctrl+C` 以停止服务器。 + + 1. 终端中按下 `Ctrl+C` 以停止服务器。 2. 打开 `config.toml`,编辑博客的名称,版权,你的姓名,社交网站等等。 - 当你再次启动服务器后,你会发现博客私人订制味道更浓了。不过,还少一个重要的基础内容:主菜单。快速的解决这个问题。返回 `config.toml` 文件,在末尾插入如下一段: + + 当你再次启动服务器后,你会发现博客私人订制味道更浓了。不过,还少一个重要的基础内容:主菜单。快速的解决这个问题。返回 `config.toml` 文件,在末尾插入如下一段: + ``` [[menu.main]] name = "Home" #Name in the navigation bar @@ -97,10 +128,13 @@ Hugo,30分钟搭建博客,一个Go语言开发的静态站点生成工具 weight = 20 url = "/posts/" ``` + 上面这段代码添加了 `Home` 和 `Posts` 到主菜单中。你还需要一个 `About` 页面。这次是创建一个 `.md` 文件,而不是编辑 `config.toml` 文件: - 1. 创建 `about.md` 文件:`hugo new about.md` 。注意它是 `about.md`,不是 `posts/about.md`。该页面不是博客提交内容,所以你不想它显示到博客内容提交当中吧。 + + 1. 创建 `about.md` 文件:`hugo new about.md` 。注意它是 `about.md`,不是 `posts/about.md`。该页面不是博客提交内容,所以你不想它显示到博客内容提交当中吧。 2. 用文本编辑器打开该文件,输入如下一段: + ``` +++ title = "About" @@ -112,19 +146,34 @@ Hugo,30分钟搭建博客,一个Go语言开发的静态站点生成工具 > Waves are the practice of the water. Shunryu Suzuki ``` + 当你启动你的服务器并输入:`http://localhost:1313/`,你将会看到你的博客。(访问我 Gihub 主页上的 [例子][6] )如果你想让文章的菜单栏和 Github 相似,给 `themes/kiera/static/css/styles.css` 打上这个 [补丁][7]。 + -------------------------------------------------------------------------------- + via: https://opensource.com/article/18/3/start-blog-30-minutes-hugo + 作者:[Marek Czernek][a] + 译者:[jrg](https://github.com/jrglinux) + 校对:[校对者ID](https://github.com/校对者ID) + 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + [a]:https://opensource.com/users/mczernek + [1]:https://gohugo.io/ + [2]:https://github.com/gohugoio/hugo/releases + [3]:https://gohugo.io/getting-started/installing/ + [4]:https://themes.gohugo.io/ + [5]:https://github.com/avianto/hugo-kiera + [6]:https://m-czernek.github.io/awesome-blog/ + [7]:https://github.com/avianto/hugo-kiera/pull/18/files From 9c6a8a471c39cfb12475805b785ba2f51d8445f4 Mon Sep 17 00:00:00 2001 From: jrg Date: Sat, 22 Sep 2018 16:32:15 +0800 Subject: [PATCH 372/455] Delete 20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md --- ..., a static site generator written in Go.md | 194 ------------------ 1 file changed, 194 deletions(-) delete mode 100644 sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md diff --git a/sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md b/sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md deleted file mode 100644 index cc1b5531d1..0000000000 --- a/sources/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md +++ /dev/null @@ -1,194 +0,0 @@ -【翻译中】translating by jrglinux! - - -Start a blog in 30 minutes with Hugo, a static site generator written in Go -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy) -Do you want to start a blog to share your latest adventures with various software frameworks? Do you love a project that is poorly documented and want to fix that? Or do you just want to create a personal website? - -Many people who want to start a blog have a significant caveat: lack of knowledge about a content management system (CMS) or time to learn. Well, what if I said you don't need to spend days learning a new CMS, setting up a basic website, styling it, and hardening it against attackers? What if I said you could create a blog in 30 minutes, start to finish, with [Hugo][1]? - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_1.png?itok=JgxBSOBG) - -Hugo is a static site generator written in Go. Why use Hugo, you ask? - - * Because there is no database, no plugins requiring any permissions, and no underlying platform running on your server, there's no added security concern. - * The blog is a set of static websites, which means lightning-fast serve time. Additionally, all pages are rendered at deploy time, so your server's load is minimal. - * Version control is easy. Some CMS platforms use their own version control system (VCS) or integrate Git into their interface. With Hugo, all your source files can live natively on the VCS of your choice. - - - -### Minutes 0-5: Download Hugo and generate a site - -To put it bluntly, Hugo is here to make writing a website fun again. Let's time the 30 minutes, shall we? - -To simplify the installation of Hugo, download the binary file. To do so: - - 1. Download the appropriate [archive][2] for your operating system. - - 2. Unzip the archive into a directory of your choice, for example `C:\hugo_dir` or `~/hugo_dir`; this path will be referred to as `${HUGO_HOME}`. - - 3. Open the command line and change into your directory: `cd ${HUGO_HOME}`. - - 4. Verify that Hugo is working: - - * On Unix: `${HUGO_HOME}/[hugo version]` - * On Windows: `${HUGO_HOME}\[hugo.exe version]` -For example, `c:\hugo_dir\hugo version`. - -For simplicity, I'll refer to the path to the Hugo binary (including the binary) as `hugo`. For example, `hugo version` would translate to `C:\hugo_dir\hugo version` on your computer. - -If you get an error message, you may have downloaded the wrong version. Also note there are many possible ways to install Hugo. See the [official documentation][3] for more information. Ideally, you put the Hugo binary on PATH. For this quick start, it's fine to use the full path of the Hugo binary. - - - - 5. Create a new site that will become your blog: `hugo new site awesome-blog`. - 6. Change into the newly created directory: `cd awesome-blog`. - - - -Congratulations! You have just created your new blog. - -### Minutes 5-10: Theme your blog - -With Hugo, you can either theme your blog yourself or use one of the beautiful, ready-made [themes][4]. I chose [Kiera][5] because it is deliciously simple. To install the theme: - - 1. Change into the themes directory: `cd themes`. - 2. Clone your theme: `git clone https://github.com/avianto/hugo-kiera kiera`. If you do not have Git installed: - * Download the .zip file from [GitHub][5]. - * Unzip it to your site's `themes` directory. - * Rename the directory from `hugo-kiera-master` to `kiera`. - 3. Change the directory to the awesome-blog level: `cd awesome-blog`. - 4. Activate the theme. Themes (including Kiera) often come with a directory called `exampleSite`, which contains example content and an example settings file. To activate Kiera, copy the provided `config.toml` file to your blog: - * On Unix: `cp themes/kiera/exampleSite/config.toml .` - * On Windows: `copy themes\kiera\exampleSite\config.toml .` - * Confirm `Yes` to override the old `config.toml` - 5. (Optional) You can start your server to visually verify the theme is activated: `hugo server -D` and access `http://localhost:1313` in your web browser. Once you've reviewed your blog, you can turn off the server by pressing `Ctrl+C` in the command line. Your blog is empty, but we're getting someplace. It should look something like this: - -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_2.png?itok=PINOIOSU) - -You have just themed your blog! You can find hundreds of beautiful themes on the official [Hugo themes][4] site. - -### Minutes 10-20: Add content to your blog - -Whereas a bowl is most useful when it is empty, this is not the case for a blog. In this step, you'll add content to your blog. Hugo and the Kiera theme simplify this process. To add your first post: - - 1. Article archetypes are templates for your content. - 2. Add theme archetypes to your blog site: - * On Unix: `cp themes/kiera/archetypes/* archetypes/` - * On Windows: `copy themes\kiera\archetypes\* archetypes\` - * Confirm `Yes` to override the `default.md` archetype - 3. Create a new directory for your blog posts: - * On Unix: `mkdir content/posts` - * On Windows: `mkdir content\posts` - 4. Use Hugo to generate your post: - * On Unix: `hugo new posts/first-post.md` - * On Windows: `hugo new posts\first-post.md` - 5. Open the new post in a text editor of your choice: - * On Unix: `gedit content/posts/first-post.md` - * On Windows: `notepad content\posts\first-post.md` - - - -At this point, you can go wild. Notice that your post consists of two sections. The first one is separated by `+++`. It contains metadata about your post, such as its title. In Hugo, this is called front matter. After the front matter, the article begins. Create the first post: -``` -+++ - -title = "First Post" - -date = 2018-03-03T13:23:10+01:00 - -draft = false - -tags = ["Getting started"] - -categories = [] - -+++ - - - -Hello Hugo world! No more excuses for having no blog or documentation now! - -``` - -All you need to do now is start the server: `hugo server -D`. Open your browser and enter: `http://localhost:1313/`. -![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_3.png?itok=I-_v0qLx) - -### Minutes 20-30: Tweak your site - -What we've done is great, but there are still a few niggles to iron out. For example, naming your site is simple: - - 1. Stop your server by pressing `Ctrl+C` on the command line. - 2. Open `config.toml` and edit settings such as the blog's title, copyright, name, your social network links, etc. - - - -When you start your server again, you'll see your blog has a bit more personalization. One more basic thing is missing: menus. That's a quick fix as well. Back in `config.toml`, insert the following at the bottom: -``` -[[menu.main]] - -    name = "Home" #Name in the navigation bar - -    weight = 10 #The larger the weight, the more on the right this item will be - -    url = "/" #URL address - -[[menu.main]] - -    name = "Posts" - -    weight = 20 - -    url = "/posts/" - -``` - -This adds menus for Home and Posts. You still need an About page. Instead of referencing it from the `config.toml` file, reference it from a markdown file: - - 1. Create an About file: `hugo new about.md`. Notice that it's `about.md`, not `posts/about.md`. The About page is not a blog post, so you don't want it displayed in the Posts section. - 2. Open the file in a text editor and enter the following: - - -``` -+++ - -title = "About" - -date = 2018-03-03T13:50:49+01:00 - -menu = "main" #Display this page on the nav menu - -weight = "30" #Right-most nav item - -meta = "false" #Do not display tags or categories - -+++ - - - -> Waves are the practice of the water. Shunryu Suzuki - -``` - -When you start your Hugo server and open `http://localhost:1313/`, you should see your new blog ready to be used. (Check out [my example][6] on my GitHub page.) If you'd like to change the active style of menu items to make the padding slightly nicer (like the GitHub live version), apply [this patch][7] to your `themes/kiera/static/css/styles.css` file. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/start-blog-30-minutes-hugo - -作者:[Marek Czernek][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/mczernek -[1]:https://gohugo.io/ -[2]:https://github.com/gohugoio/hugo/releases -[3]:https://gohugo.io/getting-started/installing/ -[4]:https://themes.gohugo.io/ -[5]:https://github.com/avianto/hugo-kiera -[6]:https://m-czernek.github.io/awesome-blog/ -[7]:https://github.com/avianto/hugo-kiera/pull/18/files From 2930e0fb5eb50be1ed63453392dc9aefe0a042f9 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 22 Sep 2018 19:38:43 +0800 Subject: [PATCH 373/455] PRF:20180720 An Introduction to Using Git.md @distant1219 --- .../20180720 An Introduction to Using Git.md | 111 +++++++++--------- 1 file changed, 56 insertions(+), 55 deletions(-) diff --git a/translated/tech/20180720 An Introduction to Using Git.md b/translated/tech/20180720 An Introduction to Using Git.md index de03252886..f159653403 100644 --- a/translated/tech/20180720 An Introduction to Using Git.md +++ b/translated/tech/20180720 An Introduction to Using Git.md @@ -1,152 +1,153 @@ Git 使用简介 ====== +> 我将向你介绍让 Git 的启动、运行,并和 GitHub 一起使用的基础知识。 + ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/developer-3461405_1920.png?itok=6H3sYe80) -如果你是一个开发者,那你应该熟悉许多开发工具。你已经花了多年时间来学习一种或者多种编程语言并完善你的技巧。你可以熟练运用图形工具或者命令行工具开发。在你看来,没有任何事可以阻挡你。你的代码, 好像你的思想和你的手指一样,将会创建一个优雅的,完美评价的应用程序,并会风靡世界。 +如果你是一个开发者,那你应该熟悉许多开发工具。你已经花了多年时间来学习一种或者多种编程语言并打磨你的技巧。你可以熟练运用图形工具或者命令行工具开发。在你看来,没有任何事可以阻挡你。你的代码, 好像你的思想和你的手指一样,将会创建一个优雅的,完美评价的应用程序,并会风靡世界。 -然而,如果你和其他人共同开发一个项目会发生什么呢?或者,你开发的应用程序变地越来越大,下一步你将如何去做?如果你想成功地和其他开发者合作,你定会想用一个分布式版本控制系统。使用这样一个系统,合作开发一个项目变得非常高效和可靠。这样的一个系统便是 [Git][1]。还有一个叫 [GitHub][2] 的方便的存储仓库,来存储你的项目代码,这样你的团队可以检查和修改代码。 +然而,如果你和其他人共同开发一个项目会发生什么呢?或者,你开发的应用程序变地越来越大,下一步你将如何去做?如果你想成功地和其他开发者合作,你定会想用一个分布式版本控制系统。使用这样一个系统,合作开发一个项目变得非常高效和可靠。这样的一个系统便是 [Git][1]。还有一个叫 [GitHub][2] 的方便的存储仓库,用来存储你的项目代码,这样你的团队可以检查和修改代码。 + +我将向你介绍让 Git 的启动、运行,并和 GitHub 一起使用的基础知识,可以让你的应用程序的开发可以提升到一个新的水平。我将在 Ubuntu 18.04 上进行演示,因此如果您选择的发行版本不同,您只需要修改 Git 安装命令以适合你的发行版的软件包管理器。 -我将向你介绍让 Git 的启动、运行,并和 GitHub 一起使用的基础知识,可以让你的应用程序的开发可以提升到一个新的水平。 我将在 Ubuntu 18.04 上进行演示,因此如果您选择的发行版本不同,您只需要修改 Git 安装命令以适合你的发行版的软件包管理器。 ### Git 和 GitHub 第一件事就是创建一个免费的 GitHub 账号,打开 [GitHub 注册页面][3],然后填上需要的信息。完成这个之后,你就注备好开始安装 Git 了(这两件事谁先谁后都可以)。 安装 Git 非常简单,打开一个命令行终端,并输入命令: + ``` sudo apt install git-all - ``` + 这将会安装大量依赖包,但是你将了解使用 Git 和 GitHub 所需的一切。 -注意:我使用 Git 来下载程序的安装源码。有许多时候,内置的软件管理器不提供某个软件,除了去第三方库中下载源码,我经常去这个软件项目的 Git 主页,像这样克隆: +附注:我使用 Git 来下载程序的安装源码。有许多时候,内置的软件管理器不提供某个软件,除了去第三方库中下载源码,我经常去这个软件项目的 Git 主页,像这样克隆: + ``` git clone ADDRESS - ``` -ADDRESS就是那个软件项目的 Git 主页。这样我就可以确保自己安装那个软件的最新发行版了。 -创建一个本地仓库并添加一个文件。 -下一步就是在你的电脑里创建一个本地仓库(本文称之为newproject,位于~/目录下),打开一个命令行终端,并输入下面的命令: +“ADDRESS” 就是那个软件项目的 Git 主页。这样我就可以确保自己安装那个软件的最新发行版了。 + +### 创建一个本地仓库并添加一个文件 + +下一步就是在你的电脑里创建一个本地仓库(本文称之为 newproject,位于 `~/` 目录下),打开一个命令行终端,并输入下面的命令: + ``` cd ~/ - mkdir newproject - cd newproject - ``` -现在你需要初始化这个仓库。在 ~/newproject 目录下,输入命令 git init,当命令运行完,你就可以看到一个刚刚创建的空的 Git 仓库了(图1)。 +现在你需要初始化这个仓库。在 `~/newproject` 目录下,输入命令 `git init`,当命令运行完,你就可以看到一个刚刚创建的空的 Git 仓库了(图1)。 ![new repository][5] -图 1:初始化完成的新仓库 +*图 1: 初始化完成的新仓库* -[使用许可][6] - -下一步就是往项目里添加文件。我们在项目根目录(~/newproject)输入下面的命令: +下一步就是往项目里添加文件。我们在项目根目录(`~/newproject`)输入下面的命令: ``` touch readme.txt - ``` -现在项目里多了个空文件。输入 git status 来验证 Git 已经检测到多了个新文件(图2)。 +现在项目里多了个空文件。输入 `git status` 来验证 Git 已经检测到多了个新文件(图2)。 ![readme][8] -图 2: Git 检测到新文件readme.txt - -[使用许可][6] +*图 2: Git 检测到新文件readme.txt* 即使 Git 检测到新的文件,但它并没有被真正的加入这个项目仓库。为此,你要输入下面的命令: ``` git add readme.txt - ``` -一旦完成这个命令,再输入 git status 命令,可以看到,readme.txt 已经是这个项目里的新文件了(图3)。 +一旦完成这个命令,再输入 `git status` 命令,可以看到,`readme.txt` 已经是这个项目里的新文件了(图3)。 + ![file added][10] -图 3: 我们的文件已经被添加进临时环境 +*图 3: 我们的文件已经被添加进临时环境* -[使用许可][6] ### 第一次提交 -当新文件添加进临时环境之后,我们现在就准备好第一次提交了。什么是提交呢?它是很简单的,一次提交就是记录你更改的项目的文件。创建一次提交也是非常简单的。但是,为提交创建一个描述信息非常重要。通过这样做,你将添加有关提交包含的内容的注释,比如你对文件做出的修改。然而,在这样做之前,我们需要确认我们的 Git 账户,输入以下命令: + +当新文件添加进临时环境之后,我们现在就准备好创建第一个提交commit了。什么是提交呢?简单的说,一个提交就是你更改的项目的文件的记录。创建一个提交也是非常简单的。但是,为提交包含一个描述信息非常重要。通过这样做,你可以添加有关该提交包含的内容的注释,比如你对文件做出的何种修改。然而,在这样做之前,我们需要告知 Git 我们的账户,输入以下命令: + ``` git config --global user.email EMAIL - git config --global user.name “FULL NAME” - ``` -EMAIL 即你的 email 地址,FULL NAME 则是你的姓名。现在你可以通过以下命令创建一个提交: + +“EMAIL” 即你的 email 地址,“FULL NAME” 则是你的姓名。 + +现在你可以通过以下命令创建一个提交: + ``` git commit -m “Descriptive Message” - ``` -Descriptive Message 即为你的提交的描述性信息。比如,当你第一次提交是提交一个 readme.txt 文件,你可以这样提交: + +“Descriptive Message” 即为你的提交的描述性信息。比如,当你第一个提交是提交一个 `readme.txt` 文件,你可以这样提交: + ``` git commit -m “First draft of readme.txt file” - ``` -你可以看到输出显示一个文件已经修改,并且,为 readnme.txt 创建了一个新模式(图4) +你可以看到输出表明一个文件已经修改,并且,为 `readme.txt` 创建了一个新的文件模式(图4) ![success][12] -图4:提交成功 +*图4:提交成功* + + +### 创建分支并推送至 GitHub + +分支是很重要的,它允许你在项目状态间中移动。假如,你想给你的应用创建一个新的特性。为了这样做,你创建了个新分支。一旦你完成你的新特性,你可以把这个新分支合并到你的主分支中去,使用以下命令创建一个新分支: -[使用许可][6] -### 创建分支并推送至GitHub -分支是很重要的,它允许你从项目状态间中移动。假如,你想给你的应用创建一个新的特性。为了这样做,你创建了个新分支。一旦你完成你的新特性,你可以把这个新分支合并到你的主分支中去,使用以下命令创建一个新分支: ``` git checkout -b BRANCH - ``` -BRANCH 即为你新分支的名字,一旦执行完命令,输入 git branch 命令来查看是否创建了新分支(图5) + +“BRANCH” 即为你新分支的名字,一旦执行完命令,输入 `git branch` 命令来查看是否创建了新分支(图5) ![featureX][14] -图5:名为 featureX 的新分支 +*图5:名为 featureX 的新分支* -[使用许可][6] - -接下来,我们需要在GitHub上创建一个仓库。 登录GitHub帐户,请单击帐户主页上的“新建仓库”按钮。 填写必要的信息,然后单击Create repository(图6)。 +接下来,我们需要在 GitHub 上创建一个仓库。 登录 GitHub 帐户,请单击帐户主页上的“New Repository”按钮。 填写必要的信息,然后单击 “Create repository”(图6)。 ![new repository][16] -图6:在 GitHub 上新建一个仓库 +*图6:在 GitHub 上新建一个仓库* -[使用许可][6] +在创建完一个仓库之后,你可以看到一个用于推送本地仓库的地址。若要推送,返回命令行窗口(`~/newproject` 目录中),输入以下命令: -在创建完一个仓库之后,你可以看到一个用于推送本地仓库的地址。若要推送,返回命令行窗口( ~/newproject 目录中),输入以下命令: ``` git remote add origin URL - git push -u origin master - ``` -URL 即为我们 GitHub 上新建的仓库地址。 + +“URL” 即为我们 GitHub 上新建的仓库地址。 系统会提示您,输入 GitHub 的用户名和密码,一旦授权成功,你的项目将会被推送到 GitHub 仓库中。 ### 拉取项目 -如果你的同事改变了你们 GitHub 上项目的代码,并且已经合并那些更改,你可以拉取那些项目文件到你的本地机器,这样,你系统中的文件就可以和远程用户的文件保持匹配。你可以输入以下命令来做这件事( ~/newproject 在目录中), +如果你的同事改变了你们 GitHub 上项目的代码,并且已经合并那些更改,你可以拉取那些项目文件到你的本地机器,这样,你系统中的文件就可以和远程用户的文件保持匹配。你可以输入以下命令来做这件事(`~/newproject` 在目录中), + ``` git pull origin master - ``` 以上的命令可以拉取任何新文件或修改过的文件到你的本地仓库。 + ### 基础 -这就是从命令行使用 Git 来处理存储在 GitHub 上的项目的基础知识。 还有很多东西需要学习,所以我强烈建议你使用 man git,man git-push 和 man git-pull 命令来更深入地了解 git 命令可以做什么。 +这就是从命令行使用 Git 来处理存储在 GitHub 上的项目的基础知识。 还有很多东西需要学习,所以我强烈建议你使用 `man git`,`man git-push` 和 `man git-pull` 命令来更深入地了解 `git` 命令可以做什么。 开发快乐! -了解更多关于 Linux的 内容,请访问来自 Linux 基金会和 edX 的免费的 ["Introduction to Linux" ][17]课程。 +了解更多关于 Linux 的 内容,请访问来自 Linux 基金会和 edX 的免费的 ["Introduction to Linux"][17]课程。 -------------------------------------------------------------------------------- @@ -155,7 +156,7 @@ via: https://www.linux.com/learn/intro-to-linux/2018/7/introduction-using-git 作者:[Jack Wallen][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[distant1219](https://github.com/distant1219) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From b7fb6d05c80c0dce3c39c3908570d4c5816cdbaf Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 22 Sep 2018 19:40:23 +0800 Subject: [PATCH 374/455] PUB:20180720 An Introduction to Using Git.md @distant1219 https://linux.cn/article-10041-1.html --- .../tech => published}/20180720 An Introduction to Using Git.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180720 An Introduction to Using Git.md (100%) diff --git a/translated/tech/20180720 An Introduction to Using Git.md b/published/20180720 An Introduction to Using Git.md similarity index 100% rename from translated/tech/20180720 An Introduction to Using Git.md rename to published/20180720 An Introduction to Using Git.md From a37b135634269556021cfe6facb37807dadf8eb9 Mon Sep 17 00:00:00 2001 From: BeliteX <43316924+belitex@users.noreply.github.com> Date: Sat, 22 Sep 2018 20:17:43 +0800 Subject: [PATCH 375/455] Update 20180920 8 Python packages that will simplify your life with Django.md --- ...8 Python packages that will simplify your life with Django.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180920 8 Python packages that will simplify your life with Django.md b/sources/tech/20180920 8 Python packages that will simplify your life with Django.md index 58bb3716f8..e341a8b0a6 100644 --- a/sources/tech/20180920 8 Python packages that will simplify your life with Django.md +++ b/sources/tech/20180920 8 Python packages that will simplify your life with Django.md @@ -1,3 +1,4 @@ +belitex 翻译中 8 Python packages that will simplify your life with Django ====== From cbf6413b3d6086c426b43ff52328ceaf512d28d2 Mon Sep 17 00:00:00 2001 From: brifuture Date: Sun, 23 Sep 2018 15:12:16 +0800 Subject: [PATCH 376/455] Finish -- JavaScript chart libraries --- ... open source JavaScript chart libraries.md | 60 +++++++++---------- 1 file changed, 30 insertions(+), 30 deletions(-) rename {sources => translated}/tech/20180906 3 top open source JavaScript chart libraries.md (52%) diff --git a/sources/tech/20180906 3 top open source JavaScript chart libraries.md b/translated/tech/20180906 3 top open source JavaScript chart libraries.md similarity index 52% rename from sources/tech/20180906 3 top open source JavaScript chart libraries.md rename to translated/tech/20180906 3 top open source JavaScript chart libraries.md index eeb5bd377d..1da8956374 100644 --- a/sources/tech/20180906 3 top open source JavaScript chart libraries.md +++ b/translated/tech/20180906 3 top open source JavaScript chart libraries.md @@ -1,21 +1,20 @@ -BriFuture is translating - -3 top open source JavaScript chart libraries +最好的 3 个开源 JavaScript 图表库 ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/books_library_reading_list_colorful.jpg?itok=jJtnyniB) -Charts and graphs are important for visualizing data and making websites appealing. Visual presentations make it easier to analyze big chunks of data and convey information. JavaScript chart libraries enable you to visualize data in a stunning, easy to comprehend, and interactive manner and improve your website's design. +对于数据可视化和制作精美网站来说,图表和图形很重要。视觉上的展示让分析大块数据及传递信息变得更简单。JavaScript 图表库能让数据以极好的,易于理解的和交互的方式进行可视化,还能够优化你的网站设计。 -In this article, learn about three top open source JavaScript chart libraries. +本文会带你学习最好的 3 个开源 JavaScript 图表库。 ### 1\. Chart.js -[Chart.js][1] is an open source JavaScript library that allows you to create animated, beautiful, and interactive charts on your application. It's available under the MIT License. +[Chart.js][1] 是一个开源的 JavaScript 库,你可以在自己的应用中用它创建生动美丽和交互式的图表。使用它需要遵循 MIT 协议。 -With Chart.js, you can create various impressive charts and graphs, including bar charts, line charts, area charts, linear scale, and scatter charts. It is completely responsive across various devices and utilizes the HTML5 Canvas element for rendering. +使用 Chart.js,你可以创建各种各样令人印象深刻的图表和图形,包括条形图,折线图,范围图,线性标度,和散点图。它可以响应各种设备,使用 HTML5 Canvas 元素进行绘制。 + +示例代码如下,它使用该库绘制了一个条形图。本例中我们使用 Chart.js 内容分发网络(CDN)来包含这个库。注意这里使用的数据仅用于展示。 -Here is example code that draws a bar chart using the library. We'll include it in this example using the Chart.js content delivery network (CDN). Note that the data used is for illustration purposes only. ``` @@ -69,23 +68,23 @@ new Chart(document.getElementById("bar-chart"), { ``` -As you can see from this code, bar charts are constructed by setting **type** to **bar**. You can change the direction of the bar to other types—such as setting **type** to **horizontalBar**. +如你所见,通过设置 **type** 和 **bar** 来构造条形图。你可以把条形体的方向改成其他类型 —— 比如把 **type** 设置成 **horizontalBar**。 -The bars' colors are set by providing the type of color in the **backgroundColor** array parameter. +在 **backgroundColor** 数组参数中提供颜色类型,就可以设置条形图的颜色。 -The colors are allocated to the label and data that share the same index in their corresponding array. For example, "Latin America," the second label, will be set to "blue" (the second color) and 4 (the second number in the data). +颜色被分配给关联数组中相同索引的标签和数据。例如,第二个标签 “Latin American”,颜色会是 “蓝色(blue)”(第二个颜色),数值是 4(data 中的第二个数字)。 -Here is the output of this code. +代码的执行结果如下。 ![](https://opensource.com/sites/default/files/uploads/chartjs-output.png) ### 2\. Chartist.js -[Chartist.js][2] is a simple JavaScript animation library that allows you to create customizable and beautiful responsive charts and other designs. The open source library is available under the WTFPL or MIT License. +[Chartist.js][2] 是一个简单的 JavaScript 动画库,你能够自制美丽的响应式图表,或者进行其他创作。使用它需要遵循 WTFPL 或者 MIT 协议。 -The library was developed by a group of developers who were dissatisfied with existing charting tools, so it offers wonderful functionalities to designers and developers. +这个库是由一些对现有图表工具不满的开发者进行开发的,它可以为设计师或程序员提供美妙的功能。 -After including the Chartist.js library and its CSS files in your project, you can use them to create various types of charts, including animations, bar charts, and line charts. It utilizes SVG to render the charts dynamically. +在项目中包含 Chartist.js 库后,你可以使用它们来创建各式各样的图表,包括动画,条形图和折线图。它使用 SVG 来动态渲染图表。 Here is an example of code that draws a pie chart using the library. ``` @@ -152,26 +151,27 @@ Here is an example of code that draws a pie chart using the library. ``` -Instead of specifying various style-related components of your project, the Chartist JavaScript library allows you to use various pre-built CSS styles. You can use them to control the appearance of the created charts. +使用 Chartist JavaScript 库,你可以使用各种预先构建好的 CSS 样式,而不是在项目中指定各种与样式相关的部分。你可以使用这些样式来设置已创建的图表的外观。 +比如,预创建的 CSS 类 .ct-chart 是用来构建饼状图的容器。还有.ct-golden-section 类可用于获取纵横比,它基于响应式设计进行缩放,帮你解决了计算固定尺寸的麻烦。Chartist 还提供了其它类别的比例容器,你可以在自己的项目中使用它们。 -For example, the pre-created CSS classis used to build the container for the pie chart. And, theclass is used to get the aspect ratios, which scale with responsive designs and saves you the hassle of calculating fixed dimensions. Chartist also provides other classes of container ratios you can utilize in your project. - -For styling the various pie slices, you can use the default . **ct-series-a** class. The letter **a** is iterated with every series count (a, b, c, etc.) such that it corresponds with the slice to be styled. +为了给各个扇形设置样式,可以使用默认的 .**ct-serials-a** 类。字母 **a** 是根据系列的数量变化的(a、b、c,等等),因此它与每个要设置样式的扇形相对应。 The **Chartist.Pie** method is used for creating a pie chart. To create another type of chart, such as a line chart, use **Chartist.Line.** +**Chartist.Pie** 方法用来创建一个饼状图。要创建另一种类型的图表,比如折线图,请使用 **Chartist.Line**。 -Here is the output of the code. +代码的执行结果如下。 ![](https://opensource.com/sites/default/files/uploads/chartistjs-output.png) ### 3\. D3.js -[D3.js][3] is another great open source JavaScript chart library. It's available under the BSD license. D3 is mainly used for manipulating and adding interactivity to documents based on the provided data. +[D3.js][3] 是另一个好用的开源 JavaScript 图表库。使用它需要遵循 BSD license。D3 的主要用途是,根据提供的数据,处理和添加文档的交互功能,。 -You can use this amazing 3D animation library to visualize your data using HTML5, SVG, and CSS and make your website appealing. Essentially, D3 enables you to bind data to the Document Object Model (DOM) and then use data-based functions to make changes to the document. +借助这个 3D 动画库,你可以通过 HTML5、SVG 和 CSS 来可视化你的数据,并且让你的网站变得更精美。更重要的是,使用 D3,你可以把数据绑定到 Document Object Model(DOM)上,然后使用基于数据的函数改变文档。 + +示例代码如下,它使用该库绘制了一个简单的条形图。 -Here is example code that draws a simple bar chart using the library. ``` @@ -215,19 +215,19 @@ Here is example code that draws a simple bar chart using the library. ``` -The main concept in using the D3 library is to first apply CSS-style selections to point to the DOM nodes and then apply operators to manipulate them—just like in other DOM frameworks like jQuery. +使用 D3 库的主要概念是应用 CSS 样式选择器来定位 DOM 节点,然后对其执行操作,就像其它的 DOM 框架,比如 JQuery。 -After the data is bound to a document, the . **enter()** function is invoked to build new nodes for incoming data. All the methods invoked after the . **enter()** function will be called for every item in the data. +将数据绑定到文档上后,.**enter()** 函数会被调用,为即将到来的数据构建新的节点。所有在 .**enter()** 之后调用的方法会为数据中的每一个项目调用一次。 -Here is the output of the code. +代码的执行结果如下。 ![](https://opensource.com/sites/default/files/uploads/d3js-output.png) -### Wrapping up +### 总结 -[JavaScript][4] charting libraries provide you with powerful tools for implementing data visualization on your web properties. With these three open source libraries, you can enhance the beauty and interactivity of your websites. +[JavaScript][4] 图表库提供了强大的工具,你可以将自己的网络资源进行数据可视化。通过这三个开源库,你可以把自己的网站变得更好看,更容易使用。 -Do you know of another powerful frontend library for creating JavaScript animation effects? Please let us know in the comment section below. +你知道其它强大的用于创造 JavaScript 动画效果的前端库吗?请在下方的评论区留言分享。 -------------------------------------------------------------------------------- @@ -236,7 +236,7 @@ via: https://opensource.com/article/18/9/open-source-javascript-chart-libraries 作者:[Dr.Michael J.Garbade][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:[BriFuture](https://github.com/brifuture) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2a2754b67fd7c537e8c73fd6e6e3eca0385cce0e Mon Sep 17 00:00:00 2001 From: jrg Date: Sun, 23 Sep 2018 18:57:03 +0800 Subject: [PATCH 377/455] Update 20180814 Automating backups on a Raspberry Pi NAS.md --- .../tech/20180814 Automating backups on a Raspberry Pi NAS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180814 Automating backups on a Raspberry Pi NAS.md b/sources/tech/20180814 Automating backups on a Raspberry Pi NAS.md index 6d9f74be63..28f7a5db35 100644 --- a/sources/tech/20180814 Automating backups on a Raspberry Pi NAS.md +++ b/sources/tech/20180814 Automating backups on a Raspberry Pi NAS.md @@ -1,3 +1,5 @@ +[翻译中]translating by jrg! + Automating backups on a Raspberry Pi NAS ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X) From adb824ff080bd0c0bff87dca84f1f6d283ce0a57 Mon Sep 17 00:00:00 2001 From: jrg Date: Sun, 23 Sep 2018 18:59:41 +0800 Subject: [PATCH 378/455] Update 20180919 Host your own cloud with Raspberry Pi NAS.md --- .../tech/20180919 Host your own cloud with Raspberry Pi NAS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md b/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md index 6e7893313e..0ecb3801c9 100644 --- a/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md +++ b/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md @@ -1,3 +1,5 @@ +[翻译中]translating by jrg! + Host your own cloud with Raspberry Pi NAS ====== From 6c712a44b411eb8747771b67e1b5556824ffcc41 Mon Sep 17 00:00:00 2001 From: GraveAccent Date: Sun, 23 Sep 2018 19:19:37 +0800 Subject: [PATCH 379/455] =?UTF-8?q?GraveAccent=E7=BF=BB=E8=AF=91=E4=B8=AD:?= =?UTF-8?q?20171022Review-Algo...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Algorithms to Live By by Brian Christian - Tom Griffiths.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md b/sources/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md index edd1844f71..7f9242178c 100644 --- a/sources/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md +++ b/sources/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md @@ -1,4 +1,4 @@ -Review: Algorithms to Live By +GraveAccent翻译中 Review: Algorithms to Live By ====== ![](https://www.eyrie.org/~eagle/reviews/covers/1-62779-037-3.jpg) From fdf4e994664070ad5249792a458146a46e078faf Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 23 Sep 2018 21:50:15 +0800 Subject: [PATCH 380/455] PRF:20180912 How To Configure Mouse Support For Linux Virtual Consoles.md @geekpi --- ... Mouse Support For Linux Virtual Consoles.md | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md b/translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md index a01ffa267c..64052c2714 100644 --- a/translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md +++ b/translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md @@ -3,7 +3,7 @@ ![](https://www.ostechnix.com/wp-content/uploads/2018/09/GPM-1-720x340.png) -我使用 Oracle VirtualBox 来测试各种类 Unix 操作系统。我的大多数虚拟机都是无头服务器,它们没有图形桌面环境。很长一段时间,我一直想知道如何在无头 Linux 服务器的基于文本的终端中使用鼠标。感谢 **GPM**,今天我了解到我们可以在虚拟控制台中使用鼠标进行复制和粘贴操作。 **GPM**,**G** eneral **P** urpose **M** ouse 的首字母缩写,它是一个守护程序,可以帮助你配置 Linux 虚拟控制台的鼠标支持。请不要将 GPM 与 **GDM**(GNOME 显示管理器)混淆。两者有完全不同的用途。 +我使用 Oracle VirtualBox 来测试各种类 Unix 操作系统。我的大多数虚拟机都是无头headless服务器,它们没有图形桌面环境。很长一段时间,我一直想知道如何在无头 Linux 服务器的基于文本的终端中使用鼠标。感谢 **GPM**,今天我了解到我们可以在虚拟控制台中使用鼠标进行复制和粘贴操作。 **GPM**,是通用鼠标General Purpose Mouse的首字母缩写,它是一个守护程序,可以帮助你配置 Linux 虚拟控制台的鼠标支持。请不要将 GPM 与 **GDM**(GNOME 显示管理器GNOME Display manager)混淆。两者有完全不同的用途。 GPM 在以下场景中特别有用: @@ -12,8 +12,6 @@ GPM 在以下场景中特别有用: * 在基于文本的编辑器和浏览器中使用复制/粘贴(例如,emacs、lynx)。 * 在文本文件管理器中使用复制/粘贴(例如 Ranger、Midnight commander)。 - - 在这个简短的教程中,我们将看到如何在类 Unix 操作系统中在基于文本的终端中使用鼠标。 ### 安装 GPM @@ -76,11 +74,9 @@ $ sudo systemctl start gpm * 右键用于扩展选择,就像在 `xterm` 中。 * 如果你使用的是双键鼠标,请使用右键粘贴文本。 - - 就这么简单! -就像我已经说过的那样,GPM 工作得很好,并且不需要额外的配置。以下是 GPM 配置文件 **/etc/gpm.conf**(或在某些发行版中是 `/etc/conf.d/gpm`)的示例内容: +就像我已经说过的那样,GPM 工作得很好,并且不需要额外的配置。以下是 GPM 配置文件 `/etc/gpm.conf`(或在某些发行版中是 `/etc/conf.d/gpm`)的示例内容: ``` # protected from evaluation (i.e. by quoting them). @@ -96,7 +92,7 @@ append='' sample_rate= ``` -在我的例子中,我使用 USB 鼠标。如果你使用的是其他鼠标,则可能需要更改 **device=/dev/input/mice** 和 **type=exps2** 参数的值。 +在我的例子中,我使用 USB 鼠标。如果你使用的是其他鼠标,则可能需要更改 `device=/dev/input/mice` 和 `type=exps2` 参数的值。 有关更多详细信息,请参阅手册页。 @@ -108,16 +104,11 @@ $ man gpm 干杯! - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-configure-mouse-support-for-linux-virtual-consoles/ -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +作者:[SK][a] 
选题:[lujun9972](https://github.com/lujun9972) 
译者:[geekpi](https://github.com/geekpi) 
校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From acfdd57a58add626905ba51f1a949a6f5ac1974f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 23 Sep 2018 21:50:38 +0800 Subject: [PATCH 381/455] PUB:20180912 How To Configure Mouse Support For Linux Virtual Consoles.md @geekpi https://linux.cn/article-10042-1.html --- ...2 How To Configure Mouse Support For Linux Virtual Consoles.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md (100%) diff --git a/translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md b/published/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md similarity index 100% rename from translated/tech/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md rename to published/20180912 How To Configure Mouse Support For Linux Virtual Consoles.md From 23140a77a5b527ad61b69412ffeb93eeed239e4a Mon Sep 17 00:00:00 2001 From: XiatianSummer Date: Sun, 23 Sep 2018 21:55:03 +0800 Subject: [PATCH 382/455] Delete 20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md --- ...cut Every Ubuntu 18.04 User Should Know.md | 168 ------------------ 1 file changed, 168 deletions(-) delete mode 100644 sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md diff --git a/sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md b/sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md deleted file mode 100644 index 1706bc6989..0000000000 --- a/sources/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md +++ /dev/null @@ -1,168 +0,0 @@ -XiatianSummer translating - -13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know -====== -Knowing keyboard shortcuts increase your productivity. Here are some useful Ubuntu shortcut keys that will help you use Ubuntu like a pro. - -You can use an operating system with the combination of keyboard and mouse - -Note: The keyboard shortcuts mentioned in the list is intended for Ubuntu 18.04 GNOME edition. Usually, most of them (if not all) should work on other Ubuntu versions as well, but I cannot vouch for it. - -![Ubuntu keyboard shortcuts][1] - -### Useful Ubuntu keyboard shortcuts - -Let’s have a look at some of the must know keyboard shortcut for Ubuntu GNOME. I have not included universal keyboard shortcuts like Ctrl+C (copy), Ctrl+V (paste) or Ctrl+S (save). - -Note: Super key in Linux refers to the key with Windows logo. I have used capital letters in the shortcuts but it doesn’t mean you have to press the shift key. For example, T means ‘t’ key only, not Shift+t. - -#### 1\. Super key: Opens Activities search - -Super Key Opens the activities menuIf you have to use just one keyboard shortcut on Ubuntu, this has to be the one. - -You want to open an application? Press the super key and search for the application. If the application is not installed, it will even suggest applications from software center. - -You want to see the running applications? Press super key and it will show you all the running GUI applications. - -You want to use workspaces? Simply press the super key and you can see the workspaces option on the right-hand side. - -#### 2\. Ctrl+Alt+T: Ubuntu terminal shortcut - -![Ubuntu Terminal Shortcut][2]Use Ctrl+alt+T to open terminal - -You want to open a new terminal. The combination of three keys Ctrl+Alt+T is what you need. This is my favorite keyboard shortcut in Ubuntu. I even mention it in various tutorials on It’s FOSS when it involves opening a terminal. - -#### 3\. Super+L or Ctrl+Alt+L: Locks the screen - -Locking screen when you are not at your desk is one of the most basic security tips. Instead of going to the top right corner and then choosing the lock screen option, you can simply use the Super+L key combination. - -Some systems also use Ctrl+Alt+L keys for locking the screen. - -#### 4\. Super+D or Ctrl+Alt+D: Show desktop - -Pressing Super+D minimizes all running application windows and shows the desktop. - -Pressing Super+D again will open all the running applications windows as it was previously. - -You may also use Ctrl+Alt+D for this purpose. - -#### 5\. Super+A: Shows the application menu - -You can open the application menu in Ubuntu 18.04 GNOME by clicking on the 9 dots on the left bottom of the screen. However, a quicker way would be to use Super+A key combination. - -It will show the application menu where you can see the installed applications on your systems and can also search for them. - -You can use Esc key to move out of the application menu screen. - -#### 6\. Super+Tab or Alt+Tab: Switch between running applications - -If you have more than one applications running, you can switch between the applications using the Super+Tab or Alt+Tab key combinations. - -Keep holding the super key and press tab and you’ll the application switcher appearing. While holding the super key, keep on tapping the tab key to select between applications. When you are at the desired application, release both super and tab keys. - -By default, the application switcher moves from left to right. If you want to move from right to left, use the Super+Shift+Tab key combination. - -You can also use Alt key instead of Super here. - -Tip: If there are multiple instances of an application, you can switch between those instances by using Super+` key combination. - -#### 7\. Super+Arrow keys: Snap windows - - - -This is available in Windows as well. While using an application, press Super and left arrow key and the application will go to the left edge of the screen, taking half of the screen. - -Similarly, pressing Super and right arrow keys will move the application to the right edge. - -Super and up arrow keys will maximize the application window and super and down arrow will bring the application back to its usual self. - -#### 8\. Super+M: Toggle notification tray - -GNOME has a notification tray where you can see notifications for various system and application activities. You also have the calendar here. - -![Notification Tray Ubuntu 18.04 GNOME][3] -Notification Tray - -With Super+M key combination, you can open this notification area. If you press these keys again, an opened notification tray will be closed. - -You can also use Super+V for toggling the notification tray. - -#### 9\. Super+Space: Change input keyboard (for multilingual setup) - -If you are multilingual, perhaps you have more than one keyboards installed on your system. For example, I use [Hindi on Ubuntu][4] along with English and I have Hindi (Devanagari) keyboard installed along with the default English one. - -If you also use a multilingual setup, you can quickly change the input keyboard with the Super+Space shortcut. - -#### 10\. Alt+F2: Run console - -This is for power users. If you want to run a quick command, instead of opening a terminal and running the command there, you can use Alt+F2 to run the console. - -![Alt+F2 to run commands in Ubuntu][5] -Console - -This is particularly helpful when you have to use applications that can only be run from the terminal. - -#### 11\. Ctrl+Q: Close an application window - -If you have an application running, you can close the application window using the Ctrl+Q key combination. You can also use Ctrl+W for this purpose. - -Alt+F4 is more ‘universal’ shortcut for closing an application window. - -It not work on a few applications such as the default terminal in Ubuntu. - -#### 12\. Ctrl+Alt+arrow: Move between workspaces - -![Workspace switching][6] -Workspace switching - -If you are one of the power users who use workspaces, you can use the Ctrl+Alt+Up arrow and Ctrl+Alt+Down arrow keys to switch between the workspaces. - -#### 13\. Ctrl+Alt+Del: Log out - -No! Like Windows, the famous combination of Ctrl+Alt+Del won’t bring task manager in Linux (unless you use custom keyboard shortcuts for it). - -![Log Out Ubuntu][7] -Log Out - -In the normal GNOME desktop environment, you can bring the power off menu using the Ctrl+Alt+Del keys but Ubuntu doesn’t always follow the norms and hence it opens the logout dialogue box when you use Ctrl+Alt+Del in Ubuntu. - -### Use custom keyboard shortcuts in Ubuntu - -You are not limited to the default keyboard shortcuts. You can create your own custom keyboard shortcuts as you like. - -Go to Settings->Devices->Keyboard. You’ll see all the keyboard shortcuts here for your system. Scroll down to the bottom and you’ll see the Custom Shortcuts option. - -![Add custom keyboard shortcut in Ubuntu][8] - -You have to provide an easy-to-recognize name of the shortcut, the command that will be run when the key combinations are used and of course the keys you are going to use for the shortcut. - -### What are your favorite keyboard shortcuts in Ubuntu? - -There is no end to shortcuts. If you want, you can have a look at all the possible [GNOME shortcuts][9] here and see if there are some more shortcuts you would like to use. - -You can, and you should also learn keyboard shortcuts for the applications you use most of the time. For example, I use Kazam for [screen recording][10], and the keyboard shortcuts help me a lot in pausing and resuming the recording. - -What are your favorite Ubuntu shortcuts that you cannot live without? - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/ubuntu-shortcuts/ - -作者:[Abhishek Prakash][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/abhishek/ -[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ubuntu-keyboard-shortcuts.jpeg -[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ubuntu-terminal-shortcut.jpg -[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/notification-tray-ubuntu-gnome.jpeg -[4]: https://itsfoss.com/type-indian-languages-ubuntu/ -[5]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/console-alt-f2-ubuntu-gnome.jpeg -[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/workspace-switcher-ubuntu.png -[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/log-out-ubuntu.jpeg -[8]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/custom-keyboard-shortcut.jpg -[9]: https://wiki.gnome.org/Design/OS/KeyboardShortcuts -[10]: https://itsfoss.com/best-linux-screen-recorders/ From 4340e89d33d7358a24d548d5e1f69925b477ca8d Mon Sep 17 00:00:00 2001 From: XiatianSummer Date: Sun, 23 Sep 2018 21:55:44 +0800 Subject: [PATCH 383/455] Create 20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md --- ...cut Every Ubuntu 18.04 User Should Know.md | 172 ++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 translated/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md diff --git a/translated/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md b/translated/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md new file mode 100644 index 0000000000..c946493a6c --- /dev/null +++ b/translated/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md @@ -0,0 +1,172 @@ +每位 Ubuntu 18.04 用户都应该知道的快捷键 +====== +了解快捷键能够提升您的生产力。这里有一些实用的 Ubuntu 快捷键助您像专业人士一样使用 Ubuntu。 + +您可以使用有键盘和鼠标组合的操作系统。 + +注意:本文中提到的键盘快捷键适用于 Ubuntu 18.04 GNOME 版。 通常,它们中的大多数(或者全部)也适用于其他的 Ubuntu 版本,但我不能够保证。 + +![Ubuntu keyboard shortcuts][1] + +### 实用的 Ubuntu 快捷键 + +让我们来看一看 Ubuntu GNOME 必备的快捷键吧!通用的快捷键如 Ctrl+C(复制),Ctrl+V(粘贴)或者 Ctrl+S(保存)不再赘述。 + +注意:Linux 中的 Super 键即键盘上带有 Windows 图标的键,本文中我使用了大写字母,但这不代表你需要按下 shift 键,比如,T 代表键盘上的‘t’键,而不代表 Shift+t。 + +#### 1\. Super 键:打开活动搜索界面 + +使用 Super 键可以打开活动菜单。如果你只能在 Ubuntu 上使用一个快捷键,那只能是 Super 键。 + +想要打开一个应用程序?按下 Super 键然后搜索应用程序。如果搜索的应用程序未安装,它会推荐来自应用中心的应用程序。 + +想要看看有哪些正在运行的程序?按下 Super 键,屏幕上就会显示所有正在运行的 GUI 应用程序。 + +想要使用工作区吗?只需按下 Super 键,您就可以在屏幕右侧看到工作区选项。 + +#### 2\. Ctrl+Alt+T:打开 Ubuntu 终端窗口 + +![Ubuntu Terminal Shortcut][2] + +*使用 Ctrl+alt+T 来打开终端窗口* + +想要打开一个新的终端,您只需使用快捷键 Ctrl+Alt+T。这是我在 Ubuntu 中最喜欢的键盘快捷键。 甚至在我的许多 FOSS 教程中,当需要打开终端窗口是,我都会提到这个快捷键。 + +#### 3\. Super+L 或 Ctrl——Alt+L:锁屏 + +当您离开电脑时锁定屏幕,是最基本的安全习惯之一。您可以使用 Super + L 快捷键,而不是繁琐地点击屏幕右上角然后选择锁定屏幕选项。 + +有些系统也会使用 Ctrl+Alt+L 键锁定屏幕。 + +#### 4\. Super+D or Ctrl+Alt+D:显示桌面 + +按下 Super + D 可以最小化所有正在运行的应用程序窗口并显示桌面。 + +再次按 Super + D 将重新打开所有正在运行的应用程序窗口,像之前一样。 + +您也可以使用 Ctrl + Alt + D 来实现此目的。 + +#### 5\. Super+A:显示应用程序菜单 + +您可以通过单击屏幕左下角的 9个点打开 Ubuntu 18.04 GNOME 中的应用程序菜单。 但是一个更快捷的方法是使用 Super + A 快捷键。 + +它将显示应用程序菜单,您可以在其中查看或搜索系统上已安装的应用程序。 + +您可以使用 Esc 键退出应用程序菜单界面。 + +#### 6\. Super+Tab or Alt+Tab:在运行中的应用程序间切换 + +如果您运行的应用程序不止一个,则可以使用 Super + Tab 或 Alt + Tab 快捷键在应用程序之间切换。 + +按住 Super 键同时按下 Tab 键,即可显示应用程序切换器。 按住 Super 的同时,继续点击 Tab 键在应用程序之间进行选择。 当光标在所需的应用程序上时,松开 Super 和 Tab 键。 + +默认情况下,应用程序切换器从左向右移动。 如果要从右向左移动,可使用 Super + Shift + Tab 快捷键。 + +在这里您也可以用 Alt 键代替 Super 键。 + +提示:如果有多个应用程序实例,您可以使用 Super + \` 快捷键在这些实例之间切换。 + +#### 7\. Super+Arrow keys: 移动窗口位置 + + + +这个快捷键也适用于 Windows 系统。 使用应用程序时,按下 Super 和左箭头键,应用程序将贴合屏幕的左边缘,占用屏幕的左半边。 + +同样,按下 Super 和右箭头键会使应用程序贴合右边缘。 + +按下 Super 和上箭头键将最大化应用程序窗口,超级和下箭头将使应用程序恢复到其正常的大小。 + +#### 8\. Super+M: 切换到通知栏 + +GNOME 中有一个通知栏,您可以在其中查看系统和应用程序活动的通知,这里也有一个日历。 + +![Notification Tray Ubuntu 18.04 GNOME][3] + +*通知栏* + +使用 Super + M 快捷键,您可以打开此通知栏。 如果再次按这些键,将关闭打开的通知托盘。 + +使用 Super+V 也可实现相同的功能。 + +#### 9\. Super+Space:切换输入法(用于多语言设置) + +如果您使用多种语言,可能您的系统上安装了多个输入法。 例如,我需要在 Ubuntu 上同时使用[印地语] [4]和英语,所以我安装了印地语(梵文)输入法以及默认的英语输入法。 + +如果您也使用多语言设置,则可以使用 Super + Space 快捷键快速更改输入法。 + +#### 10\. Alt+F2:运行控制台 + +这适用于高级用户。 如果要运行快速命令,而不是打开终端并在其中运行命令,则可以使用 Alt + F2 运行控制台。 + +![Alt+F2 to run commands in Ubuntu][5] + +*控制台* + +当您使用只能在终端运行的应用程序时,这尤其有用。 + +#### 11\. Ctrl+Q:关闭应用程序窗口 + +如果您有正在运行的应用程序,可以使用 Ctrl + Q 快捷键关闭应用程序窗口。您也可以使用 Ctrl + W 来实现此目的。 + +Alt + F4 是关闭应用程序窗口更“通用”的快捷方式。 + +它不适用于一些应用程序,如 Ubuntu 中的默认终端。 + +#### 12\. Ctrl+Alt+arrow:切换工作区 + +![Workspace switching][6] + +*切换工作区* + +如果您是使用工作区的重度用户,可以使用 Ctrl + Alt + 上箭头和 Ctrl + Alt + 下箭头键在工作区之间切换。 + +#### 13\. Ctrl+Alt+Del:注销 + +不会!在 Linux 中使用著名的快捷键 Ctrl+Alt+Del 并不会像在 Windows 中一样打开任务管理器(除非您使用自定义快捷键)。 + +![Log Out Ubuntu][7] + +*注销* + +在普通的 GNOME 桌面环境中,您可以使用 Ctrl + Alt + Del 键打开关机菜单,但 Ubuntu 并不总是遵循此规范,因此当您在 Ubuntu 中使用 Ctrl + Alt + Del 键时,它会打开注销菜单。 + +### 在 Ubuntu 中使用自定义键盘快捷键 + +您不是只能使用默认的键盘快捷键,您可以根据需要创建自己的自定义键盘快捷键。 + +转到“设置->设备->键盘”,您将在这里看到系统的所有键盘快捷键。向下滚动到底部,您将看到“自定义快捷方式”选项。 + +![Add custom keyboard shortcut in Ubuntu][8] + +您需要提供易于识别的快捷键名称、使用快捷键时运行的命令,以及您自定义的按键组合。 + +### Ubuntu 中你最喜欢的键盘快捷键是什么? + +快捷键永无止境。如果需要,你可以看一看所有可能的 [GNOME 快捷键][9],看其中有没有你需要用到的快捷键。 + +您可以学习使用您经常使用应用程序的快捷键,这是很有必要的。例如,我使用 Kazam 进行[屏幕录制][10],键盘快捷键帮助我方便地暂停和开始录像。 + +您最喜欢、最离不开的 Ubuntu 快捷键是什么? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-shortcuts/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[XiatianSummer](https://github.com/XiatianSummer) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ubuntu-keyboard-shortcuts.jpeg +[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ubuntu-terminal-shortcut.jpg +[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/notification-tray-ubuntu-gnome.jpeg +[4]: https://itsfoss.com/type-indian-languages-ubuntu/ +[5]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/console-alt-f2-ubuntu-gnome.jpeg +[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/workspace-switcher-ubuntu.png +[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/log-out-ubuntu.jpeg +[8]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/custom-keyboard-shortcut.jpg +[9]: https://wiki.gnome.org/Design/OS/KeyboardShortcuts +[10]: https://itsfoss.com/best-linux-screen-recorders/ From 2bba08f37600a661f4b85ccb93e16a6fb29a0783 Mon Sep 17 00:00:00 2001 From: haoqixu Date: Sun, 23 Sep 2018 22:02:51 +0800 Subject: [PATCH 384/455] =?UTF-8?q?[=E7=94=B3=E8=AF=B7=E7=BF=BB=E8=AF=91]?= =?UTF-8?q?=20Writing=20a=20Time=20Series=20Database=20from=20Scratch.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20170410 Writing a Time Series Database from Scratch.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20170410 Writing a Time Series Database from Scratch.md b/sources/tech/20170410 Writing a Time Series Database from Scratch.md index a7f8289b63..ba66193a0d 100644 --- a/sources/tech/20170410 Writing a Time Series Database from Scratch.md +++ b/sources/tech/20170410 Writing a Time Series Database from Scratch.md @@ -1,4 +1,4 @@ -Writing a Time Series Database from Scratch +[haoqixu翻译中]Writing a Time Series Database from Scratch ============================================================ From 64269654a5e60f87ef475662035dcb0bc904f05e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 23 Sep 2018 22:07:00 +0800 Subject: [PATCH 385/455] PRF:20180905 Find your systems easily on a LAN with mDNS.md @geekpi --- ... your systems easily on a LAN with mDNS.md | 51 ++++++++----------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/translated/tech/20180905 Find your systems easily on a LAN with mDNS.md b/translated/tech/20180905 Find your systems easily on a LAN with mDNS.md index 48d9434b58..49be86d1ab 100644 --- a/translated/tech/20180905 Find your systems easily on a LAN with mDNS.md +++ b/translated/tech/20180905 Find your systems easily on a LAN with mDNS.md @@ -3,49 +3,49 @@ ![](https://fedoramagazine.org/wp-content/uploads/2018/09/mDNS-816x345.jpg) -多播 DNS 或 mDNS 允许系统通过在广播查询局域网中的其他资源。Fedora 用户经常在没有复杂名称服务的路由器上拥有多个 Linux 系统。在这种情况下,mDNS 允许你按名称与多个系统通信 - 多数情况下不用路由器。你也不必在所有本地系统上同步类似 /etc/hosts 之类的文件。本文介绍如何设置它。 +mDNS(多播 DNSMulticast DNS)允许系统在局域网中广播查询其他资源的名称。Fedora 用户经常在没有复杂名称服务的路由器上接有多个 Linux 系统。在这种情况下,mDNS 允许你按名称与多个系统通信 —— 多数情况下不用路由器。你也不必在所有本地系统上同步类似 `/etc/hosts` 之类的文件。本文介绍如何设置它。 -mDNS 是一个零配置网络服务,它已经诞生了很长一段时间。Fedora 将 Avahi (包含 mDNS 的零配置系统)作为工作站的一部分。 (mDNS 也是 Bonjour 的一部分,可在 Mac OS 上找到。) +mDNS 是一个零配置网络服务,它已经诞生了很长一段时间。Fedora Workstation 带有零配置系统 Avahi(它包含 mDNS)。 (mDNS 也是 Bonjour 的一部分,可在 Mac OS 上找到。) 本文假设你有两个系统运行受支持的 Fedora 版本(27 或 28)。它们的主机名是 castor 和 pollux。 ### 安装包 确保系统上安装了 nss-mdns 和 avahi 软件包。你可能是不同的版本,这也没问题: + ``` $ rpm -q nss-mdns avahi nss-mdns-0.14.1-1.fc28.x86_64 avahi-0.7-13.fc28.x86_64 - ``` Fedora Workstation 默认提供这两个包。如果不存在,请安装它们: + ``` $ sudo dnf install nss-mdns avahi - ``` -确保 avahi-daemon.service 单元已启用并正在运行。同样,这是 Fedora Workstation 的默认设置。 +确保 `avahi-daemon.service` 单元已启用并正在运行。同样,这是 Fedora Workstation 的默认设置。 + ``` $ sudo systemctl enable --now avahi-daemon.service - ``` -虽然是可选的,但你可能还需要安装 avahi-tools 软件包。该软件包包括许多方便的程序,用于检查系统上的零配置服务的工作情况。使用这个 sudo 命令: +虽然是可选的,但你可能还需要安装 avahi-tools 软件包。该软件包包括许多方便的程序,用于检查系统上的零配置服务的工作情况。使用这个 `sudo` 命令: + ``` $ sudo dnf install avahi-tools - ``` -/etc/nsswitch.conf 控制系统使用哪个服务用于解析,以及它们的顺序。你应该在那个文件中看到这样的一行: +`/etc/nsswitch.conf` 控制系统使用哪个服务用于解析,以及它们的顺序。你应该在那个文件中看到这样的一行: + ``` hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname - ``` -注意命令 mdns4_minimal [NOTFOUND=return]。它们告诉你的系统使用多播 DNS 解析程序将主机名解析为 IP 地址。即使该服务有效,如果名称无法解析,也会尝试其余服务。 +注意命令 `mdns4_minimal [NOTFOUND=return]`。它们告诉你的系统使用多播 DNS 解析程序将主机名解析为 IP 地址。即使该服务有效,如果名称无法解析,也会尝试其余服务。 -如果你没有看到与此类似的配置,则可以对其进行编辑(以 root 用户身份)。但是,nss-mdns 包会为你处理此问题。如果你对自己编辑它感到不舒服,请删除并重新安装该软件包以修复该文件。 +如果你没有看到与此类似的配置,则可以(以 root 用户身份)对其进行编辑。但是,nss-mdns 包会为你处理此问题。如果你对自己编辑它感到不舒服,请删除并重新安装该软件包以修复该文件。 在**两个系统**中执行同样的步骤 。 @@ -53,42 +53,36 @@ hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname 现在你已完成常见的配置工作,请使用以下方法之一设置每个主机的名称: - 1. 如果你正在使用 Fedora Workstation,[你可以使用这个步骤][1]。 - - 2. 如果没有,请使用 hostnamectl 来做。在第一台机器上这么做: -``` -$ hostnamectl set-hostname castor - -``` - - 3. 你还可以编辑 /etc/avahi/avahi-daemon.conf,删除主机名设置行上的注释,并在那里设置名称。但是,默认情况下,Avahi 使用系统提供的主机名,因此你**不应该**需要此方法。 +1. 如果你正在使用 Fedora Workstation,[你可以使用这个步骤][1]。 +2. 如果没有,请使用 `hostnamectl` 来做。在第一台机器上这么做:`$ hostnamectl set-hostname castor`。 +3. 你还可以编辑 `/etc/avahi/avahi-daemon.conf`,删除主机名设置行上的注释,并在那里设置名称。但是,默认情况下,Avahi 使用系统提供的主机名,因此你**不应该**需要此方法。 接下来,重启 Avahi 守护进程,以便它接收更改: + ``` $ sudo systemctl restart avahi-daemon.service - ``` 然后正确设置另一台机器: + ``` $ hostnamectl set-hostname pollux $ sudo systemctl restart avahi-daemon.service - ``` 只要你的路由器没有禁止 mDNS 流量,你现在应该能够登录到 castor 并 ping 通另一台机器。你应该使用默认的 .local 域名,以便解析正常工作: + ``` $ ping pollux.local PING pollux.local (192.168.0.1) 56(84) bytes of data. 64 bytes from 192.168.0.1 (192.168.0.1): icmp_seq=1 ttl=64 time=3.17 ms 64 bytes from 192.168.0.1 (192.168.0.1): icmp_seq=2 ttl=64 time=1.24 ms ... - ``` -如果你在 pollux ping castor.local,同样的技巧也适用 。现在在网络中访问你的系统更方便了! +如果你在 pollux `ping castor.local`,同样的技巧也适用。现在在网络中访问你的系统更方便了! -此外,如果你的路由器宣传这个服务,请不要感到惊讶。现代 WiFi 和有线路由器通常提供这些服务,以使消费者的生活更轻松。 +此外,如果你的路由器也支持这个服务,请不要感到惊讶。现代 WiFi 和有线路由器通常提供这些服务,以使消费者的生活更轻松。 此过程适用于大多数系统。但是,如果遇到麻烦,请使用 avahi-browse 和 avahi-tools 软件包中的其他工具来查看可用的服务。 @@ -97,10 +91,7 @@ PING pollux.local (192.168.0.1) 56(84) bytes of data. via: https://fedoramagazine.org/find-systems-easily-lan-mdns/ -作者:[Paul W. Frields][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +作者:[Paul W. Frields][a] 
选题:[lujun9972](https://github.com/lujun9972) 
译者:[geekpi](https://github.com/geekpi) 
校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 8bd366bebf0dbbfc29d8d2acfe88a4f0df9a511f Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 23 Sep 2018 22:07:19 +0800 Subject: [PATCH 386/455] PUB:20180905 Find your systems easily on a LAN with mDNS.md @geekpi https://linux.cn/article-10043-1.html --- .../20180905 Find your systems easily on a LAN with mDNS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180905 Find your systems easily on a LAN with mDNS.md (100%) diff --git a/translated/tech/20180905 Find your systems easily on a LAN with mDNS.md b/published/20180905 Find your systems easily on a LAN with mDNS.md similarity index 100% rename from translated/tech/20180905 Find your systems easily on a LAN with mDNS.md rename to published/20180905 Find your systems easily on a LAN with mDNS.md From 2cd2db9bd81e33ff011ed79bed1d76695bdf212d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 24 Sep 2018 07:55:20 +0800 Subject: [PATCH 387/455] PRF:20180906 3 top open source JavaScript chart libraries.md @BriFuture --- ... open source JavaScript chart libraries.md | 41 +++++++++---------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/translated/tech/20180906 3 top open source JavaScript chart libraries.md b/translated/tech/20180906 3 top open source JavaScript chart libraries.md index 1da8956374..5aabeaa9f9 100644 --- a/translated/tech/20180906 3 top open source JavaScript chart libraries.md +++ b/translated/tech/20180906 3 top open source JavaScript chart libraries.md @@ -1,19 +1,20 @@ 最好的 3 个开源 JavaScript 图表库 ====== +> 图表及其它可视化方式让传递数据的信息变得更简单。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/books_library_reading_list_colorful.jpg?itok=jJtnyniB) -对于数据可视化和制作精美网站来说,图表和图形很重要。视觉上的展示让分析大块数据及传递信息变得更简单。JavaScript 图表库能让数据以极好的,易于理解的和交互的方式进行可视化,还能够优化你的网站设计。 +对于数据可视化和制作精美网站来说,图表和图形很重要。视觉上的展示让分析大块数据及传递信息变得更简单。JavaScript 图表库能让数据以极好的、易于理解的和交互的方式进行可视化,还能够优化你的网站设计。 本文会带你学习最好的 3 个开源 JavaScript 图表库。 -### 1\. Chart.js +### 1、 Chart.js [Chart.js][1] 是一个开源的 JavaScript 库,你可以在自己的应用中用它创建生动美丽和交互式的图表。使用它需要遵循 MIT 协议。 -使用 Chart.js,你可以创建各种各样令人印象深刻的图表和图形,包括条形图,折线图,范围图,线性标度,和散点图。它可以响应各种设备,使用 HTML5 Canvas 元素进行绘制。 +使用 Chart.js,你可以创建各种各样令人印象深刻的图表和图形,包括条形图、折线图、范围图、线性标度和散点图。它可以响应各种设备,使用 HTML5 Canvas 元素进行绘制。 -示例代码如下,它使用该库绘制了一个条形图。本例中我们使用 Chart.js 内容分发网络(CDN)来包含这个库。注意这里使用的数据仅用于展示。 +示例代码如下,它使用该库绘制了一个条形图。本例中我们使用 Chart.js 的内容分发网络(CDN)来包含这个库。注意这里使用的数据仅用于展示。 ``` @@ -25,8 +26,7 @@         - -    +           -    ``` -如你所见,通过设置 **type** 和 **bar** 来构造条形图。你可以把条形体的方向改成其他类型 —— 比如把 **type** 设置成 **horizontalBar**。 +如你所见,通过设置 `type` 和 `bar` 来构造条形图。你可以把条形体的方向改成其他类型 —— 比如把 `type` 设置成 `horizontalBar`。 -在 **backgroundColor** 数组参数中提供颜色类型,就可以设置条形图的颜色。 +在 `backgroundColor` 数组参数中提供颜色类型,就可以设置条形图的颜色。 颜色被分配给关联数组中相同索引的标签和数据。例如,第二个标签 “Latin American”,颜色会是 “蓝色(blue)”(第二个颜色),数值是 4(data 中的第二个数字)。 @@ -78,7 +75,7 @@ new Chart(document.getElementById("bar-chart"), { ![](https://opensource.com/sites/default/files/uploads/chartjs-output.png) -### 2\. Chartist.js +### 2、 Chartist.js [Chartist.js][2] 是一个简单的 JavaScript 动画库,你能够自制美丽的响应式图表,或者进行其他创作。使用它需要遵循 WTFPL 或者 MIT 协议。 @@ -86,7 +83,8 @@ new Chart(document.getElementById("bar-chart"), { 在项目中包含 Chartist.js 库后,你可以使用它们来创建各式各样的图表,包括动画,条形图和折线图。它使用 SVG 来动态渲染图表。 -Here is an example of code that draws a pie chart using the library. +这里是使用该库绘制一个饼图的例子。 + ``` @@ -153,22 +151,21 @@ Here is an example of code that draws a pie chart using the library. 使用 Chartist JavaScript 库,你可以使用各种预先构建好的 CSS 样式,而不是在项目中指定各种与样式相关的部分。你可以使用这些样式来设置已创建的图表的外观。 -比如,预创建的 CSS 类 .ct-chart 是用来构建饼状图的容器。还有.ct-golden-section 类可用于获取纵横比,它基于响应式设计进行缩放,帮你解决了计算固定尺寸的麻烦。Chartist 还提供了其它类别的比例容器,你可以在自己的项目中使用它们。 +比如,预创建的 CSS 类 `.ct-chart` 是用来构建饼状图的容器。还有 `.ct-golden-section` 类可用于获取纵横比,它基于响应式设计进行缩放,帮你解决了计算固定尺寸的麻烦。Chartist 还提供了其它类别的比例容器,你可以在自己的项目中使用它们。 -为了给各个扇形设置样式,可以使用默认的 .**ct-serials-a** 类。字母 **a** 是根据系列的数量变化的(a、b、c,等等),因此它与每个要设置样式的扇形相对应。 +为了给各个扇形设置样式,可以使用默认的 `.ct-serials-a` 类。字母 `a` 是根据系列的数量变化的(a、b、c,等等),因此它与每个要设置样式的扇形相对应。 -The **Chartist.Pie** method is used for creating a pie chart. To create another type of chart, such as a line chart, use **Chartist.Line.** -**Chartist.Pie** 方法用来创建一个饼状图。要创建另一种类型的图表,比如折线图,请使用 **Chartist.Line**。 +`Chartist.Pie` 方法用来创建一个饼状图。要创建另一种类型的图表,比如折线图,请使用 `Chartist.Line`。 代码的执行结果如下。 ![](https://opensource.com/sites/default/files/uploads/chartistjs-output.png) -### 3\. D3.js +### 3、 D3.js -[D3.js][3] 是另一个好用的开源 JavaScript 图表库。使用它需要遵循 BSD license。D3 的主要用途是,根据提供的数据,处理和添加文档的交互功能,。 +[D3.js][3] 是另一个好用的开源 JavaScript 图表库。使用它需要遵循 BSD 许可证。D3 的主要用途是,根据提供的数据,处理和添加文档的交互功能,。 -借助这个 3D 动画库,你可以通过 HTML5、SVG 和 CSS 来可视化你的数据,并且让你的网站变得更精美。更重要的是,使用 D3,你可以把数据绑定到 Document Object Model(DOM)上,然后使用基于数据的函数改变文档。 +借助这个 3D 动画库,你可以通过 HTML5、SVG 和 CSS 来可视化你的数据,并且让你的网站变得更精美。更重要的是,使用 D3,你可以把数据绑定到文档对象模型(DOM)上,然后使用基于数据的函数改变文档。 示例代码如下,它使用该库绘制了一个简单的条形图。 @@ -217,7 +214,7 @@ The **Chartist.Pie** method is used for creating a pie chart. To create another 使用 D3 库的主要概念是应用 CSS 样式选择器来定位 DOM 节点,然后对其执行操作,就像其它的 DOM 框架,比如 JQuery。 -将数据绑定到文档上后,.**enter()** 函数会被调用,为即将到来的数据构建新的节点。所有在 .**enter()** 之后调用的方法会为数据中的每一个项目调用一次。 +将数据绑定到文档上后,.`enter()` 函数会被调用,为即将到来的数据构建新的节点。所有在 .`enter()` 之后调用的方法会为数据中的每一个项目调用一次。 代码的执行结果如下。 @@ -237,7 +234,7 @@ via: https://opensource.com/article/18/9/open-source-javascript-chart-libraries 作者:[Dr.Michael J.Garbade][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[BriFuture](https://github.com/brifuture) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 98c1936d18a8d76db41e0e82394c79f28cd9bea9 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 24 Sep 2018 07:55:51 +0800 Subject: [PATCH 388/455] PUB:20180906 3 top open source JavaScript chart libraries.md @BriFuture https://linux.cn/article-10044-1.html --- .../20180906 3 top open source JavaScript chart libraries.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180906 3 top open source JavaScript chart libraries.md (100%) diff --git a/translated/tech/20180906 3 top open source JavaScript chart libraries.md b/published/20180906 3 top open source JavaScript chart libraries.md similarity index 100% rename from translated/tech/20180906 3 top open source JavaScript chart libraries.md rename to published/20180906 3 top open source JavaScript chart libraries.md From fb10ea9fff64158f48906d13a426f1499ebc0229 Mon Sep 17 00:00:00 2001 From: FelixYFZ <33593534+FelixYFZ@users.noreply.github.com> Date: Mon, 24 Sep 2018 12:09:07 +0800 Subject: [PATCH 389/455] Update 20180209 How writing can change your career for the better, even if you don-t identify as a writer.md Translating by FelixYFZ --- ...er for the better, even if you don-t identify as a writer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/talk/20180209 How writing can change your career for the better, even if you don-t identify as a writer.md b/sources/talk/20180209 How writing can change your career for the better, even if you don-t identify as a writer.md index 55618326c6..98d57bcca3 100644 --- a/sources/talk/20180209 How writing can change your career for the better, even if you don-t identify as a writer.md +++ b/sources/talk/20180209 How writing can change your career for the better, even if you don-t identify as a writer.md @@ -1,4 +1,4 @@ -How writing can change your career for the better, even if you don't identify as a writer +How writing can change your career for the better, even if you don't identify as a writer Translating by FelixYFZ ====== Have you read Marie Kondo's book [The Life-Changing Magic of Tidying Up][1]? Or did you, like me, buy it and read a little bit and then add it to the pile of clutter next to your bed? From fae3a75bd8945d34ce9eff5fce3995f37a12c57e Mon Sep 17 00:00:00 2001 From: GraveAccent Date: Mon, 24 Sep 2018 22:58:59 +0800 Subject: [PATCH 390/455] =?UTF-8?q?tech20171022Review...=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...e By by Brian Christian - Tom Griffiths.md | 44 ------------------- ...e By by Brian Christian - Tom Griffiths.md | 44 +++++++++++++++++++ 2 files changed, 44 insertions(+), 44 deletions(-) delete mode 100644 sources/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md create mode 100644 translated/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md diff --git a/sources/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md b/sources/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md deleted file mode 100644 index 7f9242178c..0000000000 --- a/sources/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md +++ /dev/null @@ -1,44 +0,0 @@ -GraveAccent翻译中 Review: Algorithms to Live By -====== -![](https://www.eyrie.org/~eagle/reviews/covers/1-62779-037-3.jpg) - -Another read for the work book club. This was my favorite to date, apart from the books I recommended myself. - -One of the foundations of computer science as a field of study is research into algorithms: how do we solve problems efficiently using computer programs? This is a largely mathematical field, but it's often less about ideal or theoretical solutions and more about making the most efficient use of limited resources and arriving at an adequate, if not perfect, answer. Many of these problems are either day-to-day human problems or are closely related to them; after all, the purpose of computer science is to solve practical problems with computers. The question asked by Algorithms to Live By is "can we reverse this?": can we learn lessons from computer science's approach to problems that would help us make day-to-day decisions? - -There's a lot of interesting material in the eleven chapters of this book, but there's also an amusing theme: humans are already very good at this. Many chapters start with an examination of algorithms and mathematical analysis of problems, dive into a discussion of how we can use those results to make better decisions, then talk about studies of the decisions humans actually make... and discover that humans are already applying ad hoc versions of the best algorithms we've come up with, given the constraints of typical life situations. It tends to undermine the stated goal of the book. Thankfully, it in no way undermines interesting discussion of general classes of problems, how computer science has tackled them, and what we've learned about the mathematical and technical shapes of those problems. There's a bit less self-help utility here than I think the authors had intended, but lots of food for thought. - -(That said, it's worth considering whether this congruence is less because humans are already good at this and more because our algorithms are designed from human intuition. Maybe our best algorithms just reflect human thinking. In some cases we've checked our solutions against mathematical ideals, but in other cases they're still just our best guesses to date.) - -This is the sort of a book where a chapter listing is an important part of the review. The areas of algorithms discussed here are optimal stopping, explore/exploit decisions (when to go with the best thing you've found and when to look for something better), sorting, caching, scheduling, Bayes's rule (and prediction in general), overfitting when building models, relaxation (solving an easier problem than your actual problem), randomized algorithms, a collection of networking algorithms, and finally game theory. Each of these has useful insights and thought-provoking discussion of how these sometimes-theoretical concepts map surprisingly well onto daily problems. The book concludes with a discussion of "computational kindness": an encouragement to reduce the required computation and complexity penalty for both yourself and the people you interact with. - -If you have a computer science background (as I do), many of these will be familiar concepts, and you might be dubious that a popularization would tell you much that's new. Give this book a shot, though; the analogies are less stretched than you might fear, and the authors are both careful and smart about how they apply these principles. This book passes with flying colors a key sanity check: the chapters on topics that I know well or have thought about a lot make few or no obvious errors and say useful and important things. For example, the scheduling chapter, which unsurprisingly is about time management, surpasses more than half of the time management literature by jumping straight to the heart of most time management problems: if you're going to do everything on a list, it rarely matters the order in which you do it, so the hardest scheduling problems are about deciding what not to do rather than deciding order. - -The point in the book where the authors won my heart completely was in the chapter on Bayes's rule. Much of the chapter is about Bayesian priors, and how one's knowledge of past events is a vital part of analysis of future probabilities. The authors then discuss the (in)famous marshmallow experiment, in which children are given one marshmallow and told that if they refrain from eating it until the researcher returns, they'll get two marshmallows. Refraining from eating the marshmallow (delayed gratification, in the psychological literature) was found to be associated with better life outcomes years down the road. This experiment has been used and abused for years for all sorts of propaganda about how trading immediate pleasure for future gains leads to a successful life, and how failure in life is because of inability to delay gratification. More evil analyses have (of course) tied that capability to ethnicity, with predictably racist results. - -I have [kind of a thing][1] about the marshmallow experiment. It's a topic that reliably sends me off into angry rants. - -Algorithms to Live By is the only book I have ever read to mention the marshmallow experiment and then apply the analysis that I find far more convincing. This is not a test of innate capability in the children; it's a test of their Bayesian priors. When does it make perfect sense to eat the marshmallow immediately instead of waiting for a reward? When their past experience tells them that adults are unreliable, can't be trusted, disappear for unpredictable lengths of time, and lie. And, even better, the authors supported this analysis with both a follow-up study I hadn't heard of before and with the observation that some children would wait for some time and then "give in." This makes perfect sense if they were subconsciously using a Bayesian model with poor priors. - -This is a great book. It may try a bit too hard in places (applicability of the math of optimal stopping to everyday life is more contingent and strained than I think the authors want to admit), and some of this will be familiar if you've studied algorithms. But the writing is clear, succinct, and very well-edited. No part of the book outlives its welcome; the discussion moves right along. If you find yourself going "I know all this already," you'll still probably encounter a new concept or neat explanation in a few more pages. And sometimes the authors make connections that never would have occurred to me but feel right in retrospect, such as relating exponential backoff in networking protocols to choosing punishments in the criminal justice system. Or the realization that our modern communication world is not constantly connected, it's constantly buffered, and many of us are suffering from the characteristic signs of buffer bloat. - -I don't think you have to be a CS major, or know much about math, to read this book. There is a lot of mathematical details in the end notes if you want to dive in, but the main text is almost always readable and clear, at least so far as I could tell (as someone who was a CS major and has taken a lot of math, so a grain of salt may be indicated). And it still has a lot to offer even if you've studied algorithms for years. - -The more I read of this book, the more I liked it. Definitely recommended if you like reading this sort of analysis of life. - -Rating: 9 out of 10 - -Reviewed: 2017-10-22 - --------------------------------------------------------------------------------- - -via: https://www.eyrie.org/~eagle/reviews/books/1-62779-037-3.html - -作者:[Brian Christian;Tom Griffiths][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.eyrie.org -[1]:https://www.eyrie.org1-59184-679-X.html diff --git a/translated/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md b/translated/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md new file mode 100644 index 0000000000..eec0d29397 --- /dev/null +++ b/translated/tech/20171022 Review- Algorithms to Live By by Brian Christian - Tom Griffiths.md @@ -0,0 +1,44 @@ +书评|算法之美 +====== +![](https://www.eyrie.org/~eagle/reviews/covers/1-62779-037-3.jpg) + +又一次为了工作图书俱乐部而读书。除了其它我亲自推荐的书,这是我至今最喜爱的书。 + +作为计算机科学基础之一的研究领域是算法:我们如何高效地用计算机程序解决问题?这基本上属于数学领域,但是这很少关于理想的或理论上的解决方案,而是更在于最高效地利用有限的资源获得一个充足(如果不能完美)的答案。其中许多问题要么是日常的生活问题,要么与人们密切相关。毕竟,计算机科学的目的是为了用计算机解决实际问题。《算法之美》提出的问题是:“我们可以反过来吗”--我们可以通过学习计算机科学解决问题的方式来帮助我们做出日常决定吗? + +本书的十一个章节有很多有趣的内容,但也有一个有趣的主题:人类早已擅长这一点。很多章节以一个算法研究和对问题的数学分析作为开始,接着深入到探讨如何利用这些结果做出更好的决策,然后讨论关于人类真正会做出的决定的研究,之后,考虑到典型生活情境的限制,会发现人类早就在应用我们提出的最佳算法的特殊版本了。这往往会破坏本书的既定目标,值得庆幸的是,它决不会破坏对一般问题的有趣讨论,即计算机科学如何解决它们,以及我们对这些问题的数学和技术形态的了解。我认为这本书的自助效用比作者打算的少一些,但有很多可供思考的东西。 + +(也就是说,值得考虑这种一致性是否太少了,因为人类已经擅长这方面了,更因为我们的算法是根据人类直觉设计的。可能我们的最佳算法只是反映了人类的思想。在某些情况下,我们发现我们的方案和数学上的典范不一样, 但是在另一些情况下,它们仍然是我们当下最好的猜想。) + +这是那种章节列表是书评里重要部分的书。这里讨论的算法领域有最优停止、探索和利用决策(什么时候带着你发现的最好东西走以及什么时候寻觅更好的东西),以及排序、缓存、调度、贝叶斯定理(一般还有预测)、创建模型时的过拟合、放松(解决容易的问题而不是你的实际问题)、随机算法、一系列网络算法,最后还有游戏理论。其中每一项都有有用的见解和发人深省的讨论--这些有时显得十分理论化的概念令人吃惊地很好地映射到了日常生活。这本书以一段关于“可计算的善意”的讨论结束:鼓励减少你自己和你交往的人所需的计算和复杂性惩罚。 + +如果你有计算机科学背景(就像我一样),其中许多都是熟悉的概念,而且你因为被普及了很多新东西或许会有疑惑。然而,请给这本书一个机会,类比法没你担忧的那么令人紧张。作者既小心又聪明地应用了这些原则。这本书令人惊喜地通过了一个重要的合理性检查:涉及到我知道或反复思考过的主题的章节很少有或没有明显的错误,而且能讲出有用和重要的事情。比如,调度的那一章节毫不令人吃惊地和时间管理有关,通过直接跳到时间管理问题的核心而胜过了半数时间管理类书籍:如果你要做一个清单上的所有事情,你做这些事情的顺序很少要紧,所以最难的调度问题是决定不做哪些事情而不是做这些事情的顺序。 + +作者在贝叶斯定理这一章节中的观点完全赢得了我的心。本章的许多内容都是关于贝叶斯先验的,以及一个人对过去事件的了解为什么对分析未来的概率很重要。作者接着讨论了著名的棉花糖实验。即给了儿童一个棉花糖以后,儿童被研究者告知如果他们能够克制自己不吃这个棉花糖,等到研究者回来时,会给他们两个棉花糖。克制自己不吃棉花糖(在心理学文献中叫作“延迟满足”)被发现与未来几年更好的生活有关。这个实验多年来一直被引用和滥用于各种各样的宣传,关于选择未来的收益放弃即时的快乐从而拥有成功的生活,以及生活中的失败是因为无法延迟满足。更多的邪恶分析(当然)将这种能力与种族联系在一起,带有可想而知的种族主义结论。 + +我对棉花糖实验有点兴趣。这是一个百分百让我愤怒咆哮的话题。 + +《算法之美》是我读过的唯一提到了棉花糖实验并应用了我认为更有说服力的分析的书。这不是一个关于儿童天赋的实验,这是一个关于他们的贝叶斯先验的实验。什么时候立即吃棉花糖而不是等待奖励是完全合理的?当他们过去的经历告诉他们成年人不可靠,不可信任,会在不可预测的时间内消失并且撒谎的时候。而且,更好的是,作者用我之前没有听说过的后续研究和观察支持了这一分析,观察到的内容是,一些孩子会等待一段时间然后“放弃”。如果他们下意识地使用具有较差先验的贝叶斯模型,这就完全合情合理。 + +这是一本很好的书。它可能在某些地方的尝试有点太勉强(数学上最优停止对于日常生活的适用性比我认为作者想要表现的更加偶然和牵强附会),如果你学过算法,其中一些内容会感到熟悉,但是它的行文思路清晰,简洁,而且编辑得非常好。这本书没有哪一部分对不起它所受的欢迎,书中的讨论贯穿始终。如果你发现自己“已经知道了这一切”,你可能还会在接下来几页中遇到一个新的概念或一个简洁的解释。有时作者会做一些我从没想到但是回想起来正确的联系,比如将网络协议中的指数退避和司法系统中的选择惩罚联系起来。还有意识到我们的现代通信世界并不是一直联系的,它是不断缓冲的,我们中的许多人正深受缓冲膨胀这一独特现象的苦恼。 + +我认为你并不必须是计算机科学专业或者精通数学才能读这本书。如果你想深入,每章的结尾都有许多数学上的细节,但是正文总是易读而清晰,至少就我所知是这样(作为一个以计算机科学为专业并学到了很多数学知识的人,你至少可以有保留地相信我)。即使你已经钻研了多年的算法,这本书仍然可以提供很多东西。 + +这本书我读得越多越喜欢。如果你喜欢阅读这种对生活的分析,我当然是赞成的。 + +Rating: 9 out of 10 + +Reviewed: 2017-10-22 + +-------------------------------------------------------------------------------- + +via: https://www.eyrie.org/~eagle/reviews/books/1-62779-037-3.html + +作者:[Brian Christian;Tom Griffiths][a] +译者:[GraveAccent](https://github.com/GraveAccent) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.eyrie.org +[1]:https://www.eyrie.org1-59184-679-X.html From ab65a5b276a916b2c2734f97ba858573f1544afe Mon Sep 17 00:00:00 2001 From: sd886393 Date: Tue, 25 Sep 2018 01:09:25 +0800 Subject: [PATCH 391/455] =?UTF-8?q?[=E8=AE=A4=E9=A2=8620180531=20How=20to?= =?UTF-8?q?=20create=20shortcuts=20in=20vi]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/tech/20180531 How to create shortcuts in vi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sources/tech/20180531 How to create shortcuts in vi.md b/sources/tech/20180531 How to create shortcuts in vi.md index 0e9772e402..ba856e745a 100644 --- a/sources/tech/20180531 How to create shortcuts in vi.md +++ b/sources/tech/20180531 How to create shortcuts in vi.md @@ -1,4 +1,4 @@ -How to create shortcuts in vi +【sd886393认领翻译中】How to create shortcuts in vi ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/documentation-type-keys-yearbook.png?itok=Q-ELM2rn) From fe368d3427ea82a981463ddf85b011b7c002bda8 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 25 Sep 2018 08:59:00 +0800 Subject: [PATCH 392/455] translated --- ...ows-only Games on Linux with Steam Play.md | 93 ------------------- ...ows-only Games on Linux with Steam Play.md | 92 ++++++++++++++++++ 2 files changed, 92 insertions(+), 93 deletions(-) delete mode 100644 sources/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md create mode 100644 translated/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md diff --git a/sources/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md b/sources/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md deleted file mode 100644 index d4ff9692d6..0000000000 --- a/sources/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md +++ /dev/null @@ -1,93 +0,0 @@ -translating---geekpi - -How to Play Windows-only Games on Linux with Steam Play -====== -The new experimental feature of Steam allows you to play Windows-only games on Linux. Here’s how to use this feature in Steam right now. - -You have heard the news. Game distribution platform [Steam is implementing a fork of WINE to allow you to play games that are available on Windows only][1]. This is definitely a great news for us Linux users for we have complained about the lack of the number of games for Linux. - -This new feature is still in beta but you can try it out and play Windows-only games on Linux right now. Let’s see how to do that. - -### Play Windows-only games in Linux with Steam Play - -![Play Windows-only games on Linux][2] - -You need to install Steam first. Steam is available for all major Linux distributions. I have written in detail about [installing Steam on Ubuntu][3] and you may refer to that article if you don’t have Steam installed yet. - -Once you have Steam installed and you have logged into your Steam account, it’s time to see how to enable Windows games in Steam Linux client. - -#### Step 1: Go to Account Settings - -Run Steam client. On the top left, click on Steam and then on Settings. - -![Enable steam play beta on Linux][4] - -#### Step 2: Opt in to the beta program - -In the Settings, select Account from left side pane and then click on the CHANGE button under Beta participation. - -![Enable beta feature in Steam Linux][5] - -You should select Steam Beta Update here. - -![Enable beta feature in Steam Linux][6] - -Once you save the settings here, Steam will restart and download the new beta updates. - -#### Step 3: Enable Steam Play beta - -Once Steam has downloaded the new beta updates, it will be restarted. Now you are almost set. - -Go to Settings once again. You’ll see a new option Steam Play in the left side pane now. Click on it and check the boxes: - - * Enable Steam Play for supported titles (You can play the whitelisted Windows-only games) - * Enable Steam Play for all titles (You can try to play all Windows-only games) - - - -![Play Windows games on Linux using Steam Play][7] - -I don’t remember if Steam restarts at this point again or not but I guess that’s trivial. You should now see the option to install Windows-only games on Linux. - -For example, I have Age of Empires in my Steam library which is not available on Linux normally. But after I enabled Steam Play beta for all Windows titles, it now gives me the option for installing Age of Empires on Linux. - -![Install Windows-only games on Linux using Steam][8] -Windows-only games can now be installed on Linux - -### Things to know about Steam Play beta feature - -There are a few things you should know and keep in mind about using Windows-only games on Linux with Steam Play beta. - - * At present, [only 27 Windows-games are whitelisted][9] for Steam Play. These whitelisted games work seamlessly on Linux. - * You can try any Windows game with Steam Play beta but it might not work all the time. Some games will crash sometimes while some game might not run at all. - * While in beta, you won’t see the Windows-only games available for Linux in the Steam store. You’ll have to either try the game on your own or refer to [this community maintained list][10] to see the compatibility status of the said Windows game. You can also contribute to the list by filling [this form][11]. - * If you have games downloaded on Windows via Steam, you can save some download data by [sharing Steam game files between Linux and Windows][12]. - - - -I hope this tutorial helped you in running Windows-only games on Linux. Which game(s) are you looking forward to play on Linux? - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/steam-play/ - -作者:[Abhishek Prakash][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/abhishek/ -[1]:https://itsfoss.com/steam-play-proton/ -[2]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/play-windows-games-on-linux-featured.jpeg -[3]:https://itsfoss.com/install-steam-ubuntu-linux/ -[4]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/enable-steam-play-beta.jpeg -[5]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/enable-steam-play-beta-2.jpeg -[6]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/enable-steam-play-beta-3.jpeg -[7]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/enable-steam-play-beta-4.jpeg -[8]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/install-windows-games-linux.jpeg -[9]:https://steamcommunity.com/games/221410 -[10]:https://docs.google.com/spreadsheets/d/1DcZZQ4HL_Ol969UbXJmFG8TzOHNnHoj8Q1f8DIFe8-8/htmlview?sle=true# -[11]:https://docs.google.com/forms/d/e/1FAIpQLSeefaYQduMST_lg0IsYxZko8tHLKe2vtVZLFaPNycyhY4bidQ/viewform -[12]:https://itsfoss.com/share-steam-files-linux-windows/ diff --git a/translated/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md b/translated/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md new file mode 100644 index 0000000000..52a919ea57 --- /dev/null +++ b/translated/tech/20180828 How to Play Windows-only Games on Linux with Steam Play.md @@ -0,0 +1,92 @@ +如何使用 Steam Play 在 Linux 上玩仅限 Windows 的游戏 +====== +Steam 的新实验功能允许你在 Linux 上玩仅限 Windows 的游戏。以下是如何在 Steam 中使用此功能。 + +你已经听说过这个消息。游戏发行平台[ Steam 正在实现一个 WINE 分支来允许你玩仅在 Windows 上的游戏][1]。对于 Linux 用户来说,这绝对是一个好消息,因为我们抱怨 Linux 的游戏数量不足。 + +这个新功能仍处于测试阶段,但你现在可以在 Linux 上试用它并在 Linux 上玩仅限 Windows 的游戏。让我们看看如何做到这一点。 + +### 使用 Steam Play 在 Linux 中玩仅限 Windows 的游戏 + +![Play Windows-only games on Linux][2] + +你需要先安装 Steam。Steam 适用于所有主要 Linux 发行版。我已经详细介绍了[在 Ubuntu 上安装 Steam][3],如果你还没有安装 Steam,你可以参考那篇文章。 + +安装了 Steam 并且你已登录到 Steam 帐户,就可以了解如何在 Steam Linux 客户端中启用 Windows 游戏。 + + +#### 步骤 1:进入帐户设置 + +运行 Steam 客户端。在左上角,单击 Steam,然后单击 Settings。 + +![Enable steam play beta on Linux][4] + +#### 步骤 2:选择加入测试计划 + +在“设置”中,从左侧窗口中选择“帐户”,然后单击 “Beta participation” 下的 “CHANGE” 按钮。 + +![Enable beta feature in Steam Linux][5] + +你应该在此处选择 Steam Beta Update。 + +![Enable beta feature in Steam Linux][6] + +在此处保存设置后,Steam 将重新启动并下载新的测试版更新。 + +#### 步骤 3:启用 Steam Play 测试版 + +下载好 Steam 新的测试版更新后,它将重新启动。到这里就差不多了。 + +再次进入“设置”。你现在可以在左侧窗口看到新的 Steam Play 选项。单击它并选中复选框: + + * Enable Steam Play for supported titles (你可以玩列入白名单的 Windows 游戏) + * Enable Steam Play for all titles (你可以尝试玩所有仅限 Windows 的游戏) + + + +![Play Windows games on Linux using Steam Play][7] + +我不记得 Steam 是否会再次重启,但我想这是微不足道的。你现在应该可以在 Linux 上看到安装仅限 Windows 的游戏的选项了。 + +比如,我的 Steam 库中有 Age of Empires,正常情况下这个在 Linux 中没有。但我在 Steam Play 测试版启用所有 Windows 游戏后,现在我可以选择在 Linux 上安装 Age of Empires 了。 + +![Install Windows-only games on Linux using Steam][8] +现在可以在 Linux 上安装仅限 Windows 的游戏 + +### 有关 Steam Play 测试版功能的信息 + +在 Linux 上使用 Steam Play 测试版玩仅限 Windows 的游戏有一些事情你需要知道并且牢记。 + + * If you have games downloaded on Windows via Steam, you can save some download data by [sharing Steam game files between Linux and Windows][12]. + * 目前,[只有 27 个 Steam Play 中的 Windows 游戏被列入白名单][9]。这些白名单游戏在 Linux 上无缝运行。 + * 你可以使用 Steam Play 测试版尝试任何 Windows 游戏,但它可能无法一直运行。有些游戏有时会崩溃,而某些游戏可能根本无法运行。 + * 在测试版中,你无法 Steam 商店中看到适用于 Linux 的 Windows 限定游戏。你必须自己尝试游戏或参考[这个社区维护的列表][10]以查看该 Windows 游戏的兼容性状态。你也可以通过填写[此表][11]来为列表做出贡献。 + * 如果你通过 Steam 在 Windows 上下载游戏,那么可以通过[在 Linux 和 Windows 之间共享 Steam 游戏文件][12]来保存一些下载数据。 + + +我希望本教程能帮助你在 Linux 上运行仅限 Windows 的游戏。你期待在 Linux 上玩哪些游戏? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/steam-play/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[1]:https://itsfoss.com/steam-play-proton/ +[2]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/play-windows-games-on-linux-featured.jpeg +[3]:https://itsfoss.com/install-steam-ubuntu-linux/ +[4]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/enable-steam-play-beta.jpeg +[5]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/enable-steam-play-beta-2.jpeg +[6]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/enable-steam-play-beta-3.jpeg +[7]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/enable-steam-play-beta-4.jpeg +[8]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/install-windows-games-linux.jpeg +[9]:https://steamcommunity.com/games/221410 +[10]:https://docs.google.com/spreadsheets/d/1DcZZQ4HL_Ol969UbXJmFG8TzOHNnHoj8Q1f8DIFe8-8/htmlview?sle=true# +[11]:https://docs.google.com/forms/d/e/1FAIpQLSeefaYQduMST_lg0IsYxZko8tHLKe2vtVZLFaPNycyhY4bidQ/viewform +[12]:https://itsfoss.com/share-steam-files-linux-windows/ From 9356085f52f50a68fab2ae45ad45b0fb63a1c34f Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 25 Sep 2018 09:02:54 +0800 Subject: [PATCH 393/455] translating --- ...ss usr bin dpkg returned an error code 1- Error in Ubuntu.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180824 [Solved] -sub process usr bin dpkg returned an error code 1- Error in Ubuntu.md b/sources/tech/20180824 [Solved] -sub process usr bin dpkg returned an error code 1- Error in Ubuntu.md index 3cde4c7e9e..0200dfffdb 100644 --- a/sources/tech/20180824 [Solved] -sub process usr bin dpkg returned an error code 1- Error in Ubuntu.md +++ b/sources/tech/20180824 [Solved] -sub process usr bin dpkg returned an error code 1- Error in Ubuntu.md @@ -1,3 +1,5 @@ +translating---geekpi + [Solved] “sub process usr bin dpkg returned an error code 1″ Error in Ubuntu ====== If you are encountering “sub process usr bin dpkg returned an error code 1” while installing software on Ubuntu Linux, here is how you can fix it. From 894214831c1c67d3c9dc171ec59f8a3b66d079eb Mon Sep 17 00:00:00 2001 From: jlztan Date: Tue, 25 Sep 2018 09:42:18 +0800 Subject: [PATCH 394/455] =?UTF-8?q?=20=E7=94=B3=E8=AF=B7=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=EF=BC=9ATop=2010=20Raspberry=20Pi=20blogs=20to=20follow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/tech/20180827 Top 10 Raspberry Pi blogs to follow.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180827 Top 10 Raspberry Pi blogs to follow.md b/sources/tech/20180827 Top 10 Raspberry Pi blogs to follow.md index 243442906c..a6f4e965c5 100644 --- a/sources/tech/20180827 Top 10 Raspberry Pi blogs to follow.md +++ b/sources/tech/20180827 Top 10 Raspberry Pi blogs to follow.md @@ -1,3 +1,5 @@ +Translating by jlztan + Top 10 Raspberry Pi blogs to follow ====== From 79394ff5dd8147a8e8d0db5060d605bf892ebdf9 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 25 Sep 2018 11:41:53 +0800 Subject: [PATCH 395/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20A=20Simple,=20Bea?= =?UTF-8?q?utiful=20And=20Cross-platform=20Podcast=20App?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eautiful And Cross-platform Podcast App.md | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 sources/tech/20180924 A Simple, Beautiful And Cross-platform Podcast App.md diff --git a/sources/tech/20180924 A Simple, Beautiful And Cross-platform Podcast App.md b/sources/tech/20180924 A Simple, Beautiful And Cross-platform Podcast App.md new file mode 100644 index 0000000000..ae9f91b548 --- /dev/null +++ b/sources/tech/20180924 A Simple, Beautiful And Cross-platform Podcast App.md @@ -0,0 +1,112 @@ +A Simple, Beautiful And Cross-platform Podcast App +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/cpod-720x340.png) + +Podcasts have become very popular in the last few years. Podcasts are what’s called “infotainment”, they are generally light-hearted, but they generally give you valuable information. Podcasts have blown up in the last few years, and if you like something, chances are there is a podcast about it. There are a lot of podcast players out there for the Linux desktop, but if you want something that is visually beautiful, has slick animations, and works on every platform, there aren’t a lot of alternatives to **CPod**. CPod (formerly known as **Cumulonimbus** ) is an open source and slickest podcast app that works on Linux, MacOS and Windows. + +CPod runs on something called **Electron** – a tool that allows developers to build cross-platform (E.g Windows, MacOs and Linux) desktop GUI applications. In this brief guide, we will be discussing – how to install and use CPod podcast app in Linux. + +### Installing CPod + +Go to the [**releases page**][1] of CPod. Download and Install the binary for your platform of choice. If you use Ubuntu/Debian, you can just download and install the .deb file from the releases page as shown below. + +``` +$ wget https://github.com/z-------------/CPod/releases/download/v1.25.7/CPod_1.25.7_amd64.deb + +$ sudo apt update + +$ sudo apt install gdebi + +$ sudo gdebi CPod_1.25.7_amd64.deb +``` + +If you use any other distribution, you probably should use the **AppImage** in the releases page. + +Download the AppImage file from the releases page. + +Open your terminal, and go to the directory where the AppImage file has been stored. Change the permissions to allow execution: + +``` +$ chmod +x CPod-1.25.7-x86_64.AppImage +``` + +Execute the AppImage File: + +``` +$ ./CPod-1.25.7-x86_64.AppImage +``` + +You’ll be presented a dialog asking whether to integrate the app with the system. Click **Yes** if you want to do so. + +### Features + +**Explore Tab** + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPod-features-tab.png) + +CPod uses the Apple iTunes database to find podcasts. This is good, because the iTunes database is the biggest one out there. If there is a podcast out there, chances are it’s on iTunes. To find podcasts, just use the top search bar in the Explore section. The Explore Section also shows a few popular podcasts. + +**Home Tab** + +![](http://www.ostechnix.com/wp-content/uploads/2018/09/CPod-home-tab.png) + +The Home Tab is the tab that opens by default when you open the app. The Home Tab shows a chronological list of all the episodes of all the podcasts that you have subscribed to. + +From the home tab, you can: + + 1. Mark episodes read. + 2. Download them for offline playing + 3. Add them to the queue. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/The-podcasts-queue.png) + +**Subscriptions Tab** + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPod-subscriptions-tab.png) + +You can of course, subscribe to podcasts that you like. A few other things you can do in the Subscriptions Tab is: + + 1. Refresh Podcast Artwork + 2. Export and Import Subscriptions to/from an .OPML file. + + + +**The Player** + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPod-Podcast-Player.png) + +The player is perhaps the most beautiful part of CPod. The app changes the overall look and feel according to the banner of the podcast. There’s a sound visualiser at the bottom. To the right, you can see and search for other episodes of this podcast. + +**Cons/Missing Features** + +While I love this app, there are a few features and disadvantages that CPod does have: + + 1. Poor MPRIS Integration – You can play/pause the podcast from the media player dialog of your desktop environment, but not much more. The name of the podcast is not shown, and you can go to the next/previous episode. + 2. No support for chapters. + 3. No auto-downloading – you have to manually download episodes. + 4. CPU usage during use is pretty high (even for an Electron app). + + + +### Verdict + +While it does have its cons, CPod is clearly the most aesthetically pleasing podcast player app out there, and it has most basic features down. If you love using visually beautiful apps, and don’t need the advanced features, this is the perfect app for you. I know for a fact that I’m going to use it. + +Do you like CPod? Please put your opinions on the comments below! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/cpod-a-simple-beautiful-and-cross-platform-podcast-app/ + +作者:[EDITOR][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[1]: https://github.com/z-------------/CPod/releases From ead74acd359cd2bb75829d292b3770c2b3fbd4f2 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 25 Sep 2018 11:44:51 +0800 Subject: [PATCH 396/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Make=20The=20Outp?= =?UTF-8?q?ut=20Of=20Ping=20Command=20Prettier=20And=20Easier=20To=20Read?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ing Command Prettier And Easier To Read.md | 129 ++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md diff --git a/sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md b/sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md new file mode 100644 index 0000000000..39ca57bc43 --- /dev/null +++ b/sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md @@ -0,0 +1,129 @@ +Make The Output Of Ping Command Prettier And Easier To Read +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/prettyping-720x340.png) + +As we all know, the **ping** command is used to check if a target host is reachable or not. Using Ping command, we can send ICMP Echo request to our target host, and verify whether the destination host is up or down. If you use ping command often, I’d like to recommend you to try **“Prettyping”**. Prettyping is just a wrapper for the standard ping tool and makes the output of the ping command prettier, easier to read, colorful and compact. The prettyping runs the standard ping command in the background and parses the output with colors and unicode characters. It is free and open source tool written in **Bash** and **awk** and supports most Unix-like operating systems such as GNU/Linux, FreeBSD and Mac OS X. Prettyping is not only used to make the output of ping command prettier, but also ships with other notable features as listed below. + + * Detects the lost or missing packets and marks them in the output. + * Shows live statistics. The statistics are constantly updated after each response is received, while ping only shows after it ends. + * Smart enough to handle “unknown messages” (like error messages) without messing up the output. + * Avoids printing the repeated messages. + * You can use most common ping parameters with Prettyping. + * Can run as normal user. + * Can be able to redirect the output to a file. + * Requires no installation. Just download the binary, make it executable and run. + * Fast and lightweight. + * And, finally makes the output pretty, colorful and very intuitive. + + + +### Installing Prettyping + +Like I said already, Prettyping does not requires any installation. It is portable application! Just download the Prettyping binary file using command: + +``` +$ curl -O https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping +``` + +Move the binary file to your $PATH, for example **/usr/local/bin**. + +``` +$ sudo mv prettyping /usr/local/bin +``` + +And, make it executable as like below: + +``` +$ sudo chmod +x /usr/local/bin/prettyping +``` + +It’s that simple. + +### Let us Make The Output Of Ping Command Prettier And Easier To Read + +Once installed, ping any host or IP address and see the ping command output in graphical way. + +``` +$ prettyping ostechnix.com +``` + +Here is the visually displayed ping output: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/prettyping-in-action.gif) + +If you run Prettyping without any arguments, it will keep running until you manually stop it by pressing **Ctrl+c**. + +Since Prettyping is just a wrapper to the ping command, you can use most common ping parameters. For instance, you can use **-c** flag to ping a host only a specific number of times, for example **5** : + +``` +$ prettyping -c 5 ostechnix.com +``` + +By default, prettynping displays the output in colored format. Don’t like the colored output? No problem! Use `--nocolor` option. + +``` +$ prettyping --nocolor ostechnix.com +``` + +Similarly, you can disable mult-color support using `--nomulticolor` option: + +``` +$ prettyping --nomulticolor ostechnix.com +``` + +To disable unicode characters, use `--nounicode` option: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/prettyping-without-unicode-support.png) + +This can be useful if your terminal does not support **UTF-8**. If you can’t fix the unicode (fonts) in your system, simply pass `--nounicode` option. + +Prettyping can redirect the output to a file as well. The following command will write the output of `prettyping ostechnix.com` command in `ostechnix.txt` file. + +``` +$ prettyping ostechnix.com | tee ostechnix.txt +``` + +Prettyping has few more options which helps you to do various tasks, such as, + + * Enable/disable the latency legend. (default value is: enabled) + * Force the output designed to a terminal. (default: auto) + * Use the last “n” pings at the statistics line. (default: 60) + * Override auto-detection of terminal dimensions. + * Override the awk interpreter. (default: awk) + * Override the ping tool. (default: ping) + + + +For more details, view the help section: + +``` +$ prettyping --help +``` + +Even though Prettyping doesn’t add any extra functionality, I personally like the following feature implementations in it: + + * Live statistics – You can see all the live statistics all the time. The standard ping command will only shows the statistics after it ends. + * Compact – You can see a longer timespan at your terminal. + * Prettyping detects missing responses. + + + +If you’re ever looking for a way to visually display the output of the ping command, Prettyping will definitely help. Give it a try, you won’t be disappointed. + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/prettyping-make-the-output-of-ping-command-prettier-and-easier-to-read/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ From 631b6af13e46e307d2b70a27b95e2f7a55812916 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 25 Sep 2018 11:49:22 +0800 Subject: [PATCH 397/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=205=20ways=20to=20p?= =?UTF-8?q?lay=20old-school=20games=20on=20a=20Raspberry=20Pi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...play old-school games on a Raspberry Pi.md | 169 ++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 sources/tech/20180924 5 ways to play old-school games on a Raspberry Pi.md diff --git a/sources/tech/20180924 5 ways to play old-school games on a Raspberry Pi.md b/sources/tech/20180924 5 ways to play old-school games on a Raspberry Pi.md new file mode 100644 index 0000000000..539ac42082 --- /dev/null +++ b/sources/tech/20180924 5 ways to play old-school games on a Raspberry Pi.md @@ -0,0 +1,169 @@ +5 ways to play old-school games on a Raspberry Pi +====== + +Relive the golden age of gaming with these open source platforms for Raspberry Pi. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/arcade_game_gaming.jpg?itok=84Rjk_32) + +They don't make 'em like they used to, do they? Video games, I mean. + +Sure, there's a bit more grunt in the gear now. Princess Zelda used to be 16 pixels in each direction; there's now enough graphics power for every hair on her head. Today's processors could beat up 1988's processors in a cage-fight deathmatch without breaking a sweat. + +But you know what's missing? The fun. + +You've got a squillion and one buttons to learn just to get past the tutorial mission. There's probably a storyline, too. You shouldn't need a backstory to kill bad guys. All you need is jump and shoot. So, it's little wonder that one of the most enduring popular uses for a Raspberry Pi is to relive the 8- and 16-bit golden age of gaming in the '80s and early '90s. But where to start? + +There are a few ways to play old-school games on the Pi. Each has its strengths and weaknesses, which I'll discuss here. + +### Retropie + +[Retropie][1] is probably the most popular retro-gaming platform for the Raspberry Pi. It's a solid all-rounder and a great default option for emulating classic desktop and console gaming systems. + +#### What is it? + +Retropie is built to run on [Raspbian][2]. It can also be installed over an existing Raspbian image if you'd prefer. It uses [EmulationStation][3] as a graphical front-end for a library of open source emulators, including the [Libretro][4] emulators. + +You don't need to understand a word of that to play your games, though. + +#### What's great about it + +It's very easy to get started. All you need to do is burn the image to an SD card, configure your controllers, copy your games over, and start killing bad guys. + +The huge user base means that there is a wealth of support and information out there, and active online communities to turn to for questions. + +In addition to the emulators that come installed with the Retropie image, there's a huge library of emulators you can install from the package manager, and it's growing all the time. Retropie also offers a user-friendly menu system to manage this, saving you time. + +From the Retropie menu, it's easy to add Kodi and the Raspbian desktop, which comes with the Chromium web browser. This means your retro-gaming rig is also good for home theatre, [YouTube][5], [SoundCloud][6], and all those other “lounge room computer” goodies. + +Retropie also has a number of other customization options: You can change the graphics in the menus, set up different control pad configurations for different emulators, make your Raspberry Pi file system visible to your local Windows network—all sorts of stuff. + +Retropie is built on Raspbian, which means you have the Raspberry Pi's most popular operating system to explore. Most Raspberry Pi projects and tutorials you find floating around are written for Raspbian, making it easy to customize and install new things on it. I've used my Retropie rig as a wireless bridge, installed MIDI synthesizers on it, taught myself a bit of Python, and more—all without compromising its use as a gaming machine. + +#### What's not so great about it + +Retropie's simple installation and ease of use is, in a way, a double-edged sword. You can go for a long time with Retropie without ever learning simple stuff like `sudo apt-get`, which means you're missing out on a lot of the Raspberry Pi experience. + +It doesn't have to be this way; the command line is still there under the hood when you want it, but perhaps users are a bit too insulated from a Bash shell that's ultimately a lot less scary than it looks. Retropie's main menu is operable only with a control pad, which can be annoying when you don't have one plugged in because you've been using the system for things other than gaming. + +#### Who's it for? + +Anyone who wants to get straight into some gaming, anyone who wants the biggest and best library of emulators, and anyone who wants a great way to start exploring Linux when they're not playing games. + +### Recalbox + +[Recalbox][7] is a newer open source suite of emulators for the Raspberry Pi. It also supports other ARM-based small-board computers. + +#### What is it? + +Like Retropie, Recalbox is built on EmulationStation and Libretro. Where it differs is that it's not built on Raspbian, but on its own flavor of Linux: RecalboxOS. + +#### What's great about it + +The setup for Recalbox is even easier than for Retropie. You don't even need to image an SD card; simply copy some files over and go. It also has out-of-the-box support for some game controllers, getting you to Level 1 that little bit faster. Kodi comes preinstalled. This is a ready-to-go gaming and media rig. + +#### What's not so great about it + +Recalbox has fewer emulators than Retropie, fewer customization options, and a smaller user community. + +Your Recalbox rig is probably always just going to be for emulators and Kodi, the same as when you installed it. If you feel like getting deeper into Linux, you'll probably want a new SD card for Raspbian. + +#### Who's it for? + +Recalbox is great if you want the absolute easiest retro gaming experience and can happily go without some of the more obscure gaming platforms, or if you are intimidated by the idea of doing anything a bit technical (and have no interest in growing out of that). + +For most opensource.com readers, Recalbox will probably come in most handy to recommend to your not-so-technical friend or relative. Its super-simple setup and overall lack of options might even help you avoid having to help them with it. + +### Roll your own + +Ok, if you've been paying attention, you might have noticed that both Retropie and Recalbox are built from many of the same open source components. So what's to stop you from putting them together yourself? + +#### What is it? + +Whatever you want it to be, baby. The nature of open source software means you could use an existing emulator suite as a starting point, or pilfer from them at will. + +#### What's great about it + +If you have your own custom interface in mind, I guess there's nothing to do but roll your sleeves up and get to it. This is also a way to install emulators that haven't quite found their way into Retropie yet, such as [BeebEm][8] or [ArcEm][9]. + +#### What's not so great about it + +Well, it's a bit of work, isn't it? + +#### Who's it for? + +Hackers, tinkerers, builders, seasoned hobbyists, and such. + +### Native RISC OS gaming + +Now here's a dark horse: [RISC OS][10], the original operating system for ARM devices. + +#### What is it? + +Before ARM went on to become the world's most popular CPU architecture, it was originally built to be the heart of the Acorn Archimedes. That's kind of a forgotten beast nowadays, but for a few years it was light years ahead as the most powerful desktop computer in the world, and it attracted a lot of games development. + +Because the ARM processor in the Pi is the great-grandchild of the one in the Archimedes, we can still install RISC OS on it, and with a little bit of work, get these games running. This is different to the emulator options we've covered so far because we're playing our games on the operating system and CPU architecture for which they were written. + +#### What's great about it + +It's the perfect introduction to RISC OS. This is an absolute gem of an operating system and well worth checking out in its own right. + +The fact that you're using much the same operating system as back in the day to load and play your games makes your retro gaming rig just that little bit more of a time machine. This definitely adds some charm and retro value to the project. + +There are a few superb games that were released only on the Archimedes. The massive hardware advantage of the Archimedes also means that it often had the best graphics and smoothest gameplay of a lot of multi-platform titles. The rights holders to many of these games have been generous enough to make them legally available for free download. + +#### What's not so great about it + +Once you have installed RISC OS, it still takes a bit of elbow grease to get the games working. Here's a [guide to getting started][11]. + +This is definitely not a great all-rounder for the lounge room. There's nothing like [Kodi][12]. There's a web browser, [NetSurf][13], but it's struggling to catch up to the modern web. You won't get the range of titles to play as you would with an emulator suite. RISC OS Open is free for hobbyists to download and use and much of the source code has been made open. But despite the name, it's not a 100% open source operating system. + +#### Who's it for? + +This one's for novelty seekers, absolute retro heads, people who want to explore an interesting operating system from the '80s, people who are nostalgic for Acorn machines from back in the day, and people who want a totally different retro gaming project. + +### Command line gaming + +Do you really need to install an emulator or an exotic operating system just to relive the glory days? Why not just install some native linux games from the command line? + +#### What is it? + +There's a whole range of native Linux games tested to work on the [Raspberry Pi][14]. + +#### What's great about it + +You can install most of these from packages using the command line and start playing. Easy. If you've already got Raspbian up and running, it's probably your fastest path to getting a game running. + +#### What's not so great about it + +This isn't, strictly speaking, actual retro gaming. Linux was born in 1991 and took a while longer to come together as a gaming platform. This isn't quite gaming from the classic 8- and 16-bit era; these are ports and retro-influenced games that were built later. + +#### Who's it for? + +If you're just after a bucket of fun, no problem. But if you're trying to relive the actual era, this isn't quite it. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/retro-gaming-raspberry-pi + +作者:[James Mawson][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dxmjames +[1]: https://retropie.org.uk/ +[2]: https://www.raspbian.org/ +[3]: https://emulationstation.org/ +[4]: https://www.libretro.com/ +[5]: https://www.youtube.com/ +[6]: https://soundcloud.com/ +[7]: https://www.recalbox.com/ +[8]: http://www.mkw.me.uk/beebem/ +[9]: http://arcem.sourceforge.net/ +[10]: https://opensource.com/article/18/7/gentle-intro-risc-os +[11]: https://blog.dxmtechsupport.com.au/playing-badass-acorn-archimedes-games-on-a-raspberry-pi/ +[12]: https://kodi.tv/ +[13]: https://www.netsurf-browser.org/ +[14]: https://www.raspberrypi.org/forums/viewtopic.php?f=78&t=51794 From be92daaafcc72653662b7510887e207d8bdd2fe8 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 25 Sep 2018 12:04:38 +0800 Subject: [PATCH 398/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Gunpoint=20is=20a?= =?UTF-8?q?=20Delight=20for=20Stealth=20Game=20Fans?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...oint is a Delight for Stealth Game Fans.md | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 sources/tech/20180923 Gunpoint is a Delight for Stealth Game Fans.md diff --git a/sources/tech/20180923 Gunpoint is a Delight for Stealth Game Fans.md b/sources/tech/20180923 Gunpoint is a Delight for Stealth Game Fans.md new file mode 100644 index 0000000000..3ff6857f78 --- /dev/null +++ b/sources/tech/20180923 Gunpoint is a Delight for Stealth Game Fans.md @@ -0,0 +1,104 @@ +Gunpoint is a Delight for Stealth Game Fans +====== +Gunpoint is a 2D stealth game in which you play as a spy stealing secrets and hacking networks like Ethan Hunt of Mission Impossible movie series. + + + +Hi, Fellow Linux gamers. Let’s take a look at a fun stealth game. Let’s take a look at [Gunpoint][1]. + +Gunpoint is neither free nor open source. It is an independent game you can purchase directly from the creator or from Steam. + +![][2] + +### The Interesting History of Gunpoint + +> The instant success of Gunpoint enabled its creator to become a full time game developer. + +Gunpoint is a stealth game created by [Tom Francis][3]. Francis was inspired to create the game after he heard about Spelunky, which was created by one person. Francis played games as part of his day job, as an editor for PC Gamer UK magazine. He had no previous programming experience but used the easy-to-use Game Maker. He planned to create a demo with the hopes of getting a job as a developer. + +He released his first prototype in May 2010 under the name Private Dick. Based on the response, Francis continued to work on the game. The final version was released in June of 2013 to high praise. + +In a [blog post][4] weeks after Gunpoint’s launch, Francis revealed that he made back all the money he spent on development ($30 for Game Maker 8) in 64 seconds. Francis didn’t reveal Gunpoint’s sales figures, but he did quit his job and today creates [games][5] full time. + +### Experiencing the Gunpoint Gameplay + +![Gunpoint Gameplay][6] + +Like I said earlier, Gunpoint is a stealth game. You play a freelance spy named Richard Conway. As Conway, you will use a pair of Bullfrog hypertrousers to infiltrate buildings for clients. The hypertrousers allow you to jump very high, even through windows. You can also cling to walls or ceilings like a ninja. + +Another tool you have is the Crosslink, which allows you to rewire circuits. Often you will need to use the Crosslink to reroute motion detections to unlock doors instead of setting off an alarm or rewire a light switch to turn off the light on another floor to distract a guard. + +When you sneak into a building, your biggest concern is the on-site security guards. If they see Conway, they will shoot and in this game, it’s one shot one kill. You can jump off a three-story building no problem, but bullets will take you down. Thankfully, if Conway is killed you can just jump back a few seconds and try again. + +Along the way, you will earn money to upgrade your tools and unlock new features. For example, I just unlocked the ability to rewire a guard’s gun. Don’t ask me how that works. + +### Minimum System Requirements + +Here are the minimum system requirements for Gunpoint: + +##### Linux + + * Processor: 2GHz + * Memory: 1GB RAM + * Video card: 512MB + * Hard Drive: 700MB HD space + + + +##### Windows + + * OS: Windows XP, Visa, 7 or 8 + * Processor: 2GHz + * Memory: 1GB RAM + * Video card: 512MB + * DirectX®: 9.0 + * Hard Drive: 700MB HD space + + + +##### macOS + + * OS: OS X 10.7 or later + * Processor: 2GHz + * Memory: 1GB RAM + * Video card: 512MB + * Hard Drive: 700MB HD space + + + +### Thoughts on Gunpoint + +![Gunpoint game on Linux][7] +Image Courtesy: Steam Community + +Gunpoint is a very fun game. The early levels are easy to get through, but the later levels make you put your thinking cap on. The hypertrousers and Crosslink are fun to play with. There is nothing like turning the lights off on a guard and bouncing over his head to hack a terminal. + +Besides the fun mechanics, it also has an interesting [noir][8] murder mystery story. Several different (and conflicting) clients hire you to look into different aspects of the case. Some of them seem to have ulterior motives that are not in your best interest. + +I always enjoy good mysteries and this one is no different. If you like noir or platforming games, be sure to check out [Gunpoint][1]. + +Have you every played Gunpoint? What other games should we review for your entertainment? Let us know in the comments below. + +If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][9]. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/gunpoint-game-review/ + +作者:[John Paul][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[1]: http://www.gunpointgame.com/ +[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/gunpoint.jpg +[3]: https://www.pentadact.com/ +[4]: https://www.pentadact.com/2013-06-18-gunpoint-recoups-development-costs-in-64-seconds/ +[5]: https://www.pentadact.com/2014-08-09-what-im-working-on-and-what-ive-done/ +[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/gunpoint-gameplay-1.jpeg +[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/gunpoint-game-1.jpeg +[8]: https://en.wikipedia.org/wiki/Noir_fiction +[9]: http://reddit.com/r/linuxusersgroup From 75e68628bb808d678aedc7c39f2692800e9fea08 Mon Sep 17 00:00:00 2001 From: way-ww <40491614+way-ww@users.noreply.github.com> Date: Tue, 25 Sep 2018 12:43:07 +0800 Subject: [PATCH 399/455] Update 20180516 Manipulating Directories in Linux.md (#10335) request to translate --- sources/tech/20180516 Manipulating Directories in Linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180516 Manipulating Directories in Linux.md b/sources/tech/20180516 Manipulating Directories in Linux.md index 9c6df23e43..4cc8ca4ea1 100644 --- a/sources/tech/20180516 Manipulating Directories in Linux.md +++ b/sources/tech/20180516 Manipulating Directories in Linux.md @@ -1,3 +1,4 @@ +Translating by way-ww Manipulating Directories in Linux ====== From faf726be70bf8e91d6be6ebd60e72f321248e985 Mon Sep 17 00:00:00 2001 From: Hank Chow <280630620@qq.com> Date: Tue, 25 Sep 2018 12:48:10 +0800 Subject: [PATCH 400/455] translated (#10334) --- ...Understand Fedora memory usage with top.md | 62 ------------------- ...Understand Fedora memory usage with top.md | 60 ++++++++++++++++++ 2 files changed, 60 insertions(+), 62 deletions(-) delete mode 100644 sources/tech/20180919 Understand Fedora memory usage with top.md create mode 100644 translated/tech/20180919 Understand Fedora memory usage with top.md diff --git a/sources/tech/20180919 Understand Fedora memory usage with top.md b/sources/tech/20180919 Understand Fedora memory usage with top.md deleted file mode 100644 index ef72988469..0000000000 --- a/sources/tech/20180919 Understand Fedora memory usage with top.md +++ /dev/null @@ -1,62 +0,0 @@ -HankChow translating - -Understand Fedora memory usage with top -====== - -![](https://fedoramagazine.org/wp-content/uploads/2018/09/memory-top-816x345.jpg) - -Have you used the top utility in a terminal to see memory usage on your Fedora system? If so, you might be surprised to see some of the numbers there. It might look like a lot more memory is consumed than your system has available. This article will explain a little more about memory usage, and how to read these numbers. - -### Memory usage in real terms - -The way the operating system (OS) uses memory may not be self-evident. In fact, some ingenious, behind-the-scenes techniques are at play. They help your OS use memory more efficiently, without involving you. - -Most applications are not self contained. Instead, each relies on sets of functions collected in libraries. These libraries are also installed on the system. In Fedora, the RPM packaging system ensures that when you install an app, any libraries on which it relies are installed, too. - -When an app runs, the OS doesn’t necessarily load all the information it uses into real memory. Instead, it builds a map to the storage where that code is stored, called virtual memory. The OS then loads only the parts it needs. When it no longer needs portions of memory, it might release or swap them out as appropriate. - -This means an app can map a very large amount of virtual memory, while using less real memory on the system at one time. It might even map more RAM than the system has available! In fact, across a whole OS that’s often the case. - -In addition, related applications may rely on the same libraries. The Linux kernel in your Fedora system often shares memory between applications. It doesn’t need to load multiple copies of the same library for related apps. This works similarly for separate instances of the same app, too. - -Without understanding these details, the output of the top application can be confusing. The following example will clarify this view into memory usage. - -### Viewing memory usage in top - -If you haven’t tried yet, open a terminal and run the top command to see some output. Hit **Shift+M** to see the list sorted by memory usage. Your display may look slightly different than this example from a running Fedora Workstation: - - - -There are three columns showing memory usage to examine: VIRT, RES, and SHR. The measurements are currently shown in kilobytes (KB). - -The VIRT column is the virtual memory mapped for this process. Recall from the earlier description that virtual memory is not actual RAM consumed. For example, the GNOME Shell process gnome-shell is not actually consuming over 3.1 gigabytes of actual RAM. However, it’s built on a number of lower and higher level libraries. The system must map each of those to ensure they can be loaded when necessary. - -The RES column shows you how much actual (resident) memory is consumed by the app. In the case of GNOME Shell, that’s about 180788 KB. The example system has roughly 7704 MB of physical memory, which is why the memory usage shows up as 2.3%. - -However, of that number, at least 88212 KB is shared memory, shown in the SHR column. This memory might be, for example, library functions that other apps also use. This means the GNOME Shell is using about 92 MB on its own not shared with other processes. Notice that other apps in the example share an even higher percentage of their resident memory. In some apps, the shared portion is the vast majority of the memory usage. - -There is a wrinkle here, which is that sometimes processes communicate with each other via memory. That memory is also shared, but can’t necessarily be detected by a utility like top. So yes — even the above clarifications still have some uncertainty! - -### A note about swap - -Your system has another facility it uses to store information, which is swap. Typically this is an area of slower storage (like a hard disk). If the physical memory on the system fills up as needs increase, the OS looks for portions of memory that haven’t been needed in a while. It writes them out to the swap area, where they sit until needed later. - -Therefore, prolonged, high swap usage usually means a system is suffering from too little memory for its demands. Sometimes an errant application may be at fault. Or, if you see this often on your system, consider upgrading your machine’s memory, or restricting what you run. - -Photo courtesy of [Stig Nygaard][1], via [Flickr][2] (CC BY 2.0). - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/understand-fedora-memory-usage-top/ - -作者:[Paul W. Frields][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/pfrields/ -[1]: https://www.flickr.com/photos/stignygaard/ -[2]: https://www.flickr.com/photos/stignygaard/3138001676/ diff --git a/translated/tech/20180919 Understand Fedora memory usage with top.md b/translated/tech/20180919 Understand Fedora memory usage with top.md new file mode 100644 index 0000000000..a55d5d7b55 --- /dev/null +++ b/translated/tech/20180919 Understand Fedora memory usage with top.md @@ -0,0 +1,60 @@ +使用 `top` 命令了解 Fedora 的内存使用情况 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/09/memory-top-816x345.jpg) + +如果你使用过 `top` 命令来查看 Fedora 系统中的内存使用情况,你可能会惊讶,显示的数值看起来比系统可用的内存消耗更多。下面会详细介绍内存使用情况以及如何理解这些数据。 + +### 内存实际使用情况 + +操作系统对内存的使用方式并不是太通俗易懂,而是有很多不为人知的巧妙方式。通过这些方式,可以在无需用户干预的情况下,让操作系统更有效地使用内存。 + +大多数应用程序都不是系统自带的,但每个应用程序都依赖于安装在系统中的库中的一些函数集。在 Fedora 中,RPM 包管理系统能够确保在安装应用程序时也会安装所依赖的库。 + +当应用程序运行时,操作系统并不需要将它要用到的所有信息都加载到物理内存中。而是会为存放代码的存储构建一个映射,称为虚拟内存。操作系统只把需要的部分加载到内存中,当某一个部分不再需要后,这一部分内存就会被释放掉。 + +这意味着应用程序可以映射大量的虚拟内存,而使用较少的系统物理内存。特殊情况下,映射的虚拟内存甚至可以比系统实际可用的物理内存更多!而且在操作系统中这种情况也并不少见。 + +另外,不同的应用程序可能会对同一个库都有依赖。Fedora 中的 Linux 内核通常会在各个应用程序之间共享内存,而不需要为不同应用分别加载同一个库的多个副本。类似地,对于同一个应用程序的不同实例也是采用这种方式共享内存。 + +如果不首先了解这些细节,`top` 命令显示的数据可能会让人摸不着头脑。下面就举例说明如何正确查看内存使用量。 + +### 使用 `top` 命令查看内存使用量 + +如果你还没有使用过 `top` 命令,可以打开终端直接执行查看。使用 **Shift + M** 可以按照内存使用量来进行排序。下图是在 Fedora Workstation 中执行的结果,在你的机器上显示的结果可能会略有不同: + +![](https://fedoramagazine.org/wp-content/uploads/2018/09/Screenshot-from-2018-09-17-14-23-17.png) + +主要通过一下三列来查看内存使用情况:VIRT,RES 和 SHR。目前以 KB 为单位显示相关数值。 + +VIRT 列代表该进程映射的虚拟内存。如上所述,虚拟内存不是实际消耗的物理内存。例如, GNOME Shell 进程 gnome-shell 实际上没有消耗超过 3.1 GB 的物理内存,但它对很多更低或更高级的库都有依赖,系统必须对每个库都进行映射,以确保在有需要时可以加载这些库。 + +RES 列代表应用程序消耗了多少实际(驻留)内存。对于 GNOME Shell 大约是 180788 KB。例子中的系统拥有大约 7704 MB 的物理内存,因此内存使用率显示为 2.3%。 + +但根据 SHR 列显示,其中至少有 88212 KB 是共享内存,这部分内存可能是其它应用程序也在使用的库函数。这意味着 GNOME Shell 本身大约有 92 MB 内存不与其他进程共享。需要注意的是,上述例子中的其它程序也共享了很多内存。在某些应用程序中,共享内存在内存使用量中会占很大的比例。 + +值得一提的是,有时进程之间通过内存通信,这些内存也是共享的,但 `top` 工具却不一定能检测到,所以以上的说明也不一定准确。(这一句不太会翻译出来,烦请校对大佬帮忙看看,谢谢) + +### 关于交换分区 + +系统还可以通过交换分区来存储数据(例如硬盘),但读写的速度相对较慢。当物理内存渐渐用满,操作系统就会查找内存中暂时不会使用的部分,将其写出到交换区域等待需要的时候使用。 + +因此,如果交换内存的使用量一直偏高,表明系统的物理内存已经供不应求了。尽管错误的内存申请也有可能导致出现这种情况,但如果这种现象经常出现,就需要考虑提升物理内存或者限制某些程序的运行了。 + +感谢 [Stig Nygaard][1] 在 [Flickr][2] 上提供的图片(CC BY 2.0)。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/understand-fedora-memory-usage-top/ + +作者:[Paul W. Frields][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[HankChow](https://github.com/HankChow) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[1]: https://www.flickr.com/photos/stignygaard/ +[2]: https://www.flickr.com/photos/stignygaard/3138001676/ + From 57f6de97706dabb015b14dd3caa0fbf72ca6ebaa Mon Sep 17 00:00:00 2001 From: GraveAccent <39041505+GraveAccent@users.noreply.github.com> Date: Tue, 25 Sep 2018 12:50:22 +0800 Subject: [PATCH 401/455] =?UTF-8?q?GraveAccent=E7=94=B3=E8=AF=B7=E7=BF=BB?= =?UTF-8?q?=E8=AF=91=20(#10336)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0201 Conditional Rendering in React using Ternaries and.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sources/tech/20180201 Conditional Rendering in React using Ternaries and.md b/sources/tech/20180201 Conditional Rendering in React using Ternaries and.md index b5f740c92c..b99c787e31 100644 --- a/sources/tech/20180201 Conditional Rendering in React using Ternaries and.md +++ b/sources/tech/20180201 Conditional Rendering in React using Ternaries and.md @@ -1,4 +1,4 @@ -Conditional Rendering in React using Ternaries and Logical AND +GraveAccent 翻译中 Conditional Rendering in React using Ternaries and Logical AND ============================================================ @@ -203,4 +203,4 @@ via: https://medium.freecodecamp.org/conditional-rendering-in-react-using-ternar [a]:https://medium.freecodecamp.org/@donavon [1]:https://unsplash.com/photos/pKeF6Tt3c08?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText [2]:https://unsplash.com/search/photos/road-sign?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText -[3]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators \ No newline at end of file +[3]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators From 6e0980cf07857c1143cdb41248d6914d8e0cf001 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 25 Sep 2018 14:58:55 +0800 Subject: [PATCH 402/455] PUB:20180308 What is open source programming.md @Valoniakim https://linux.cn/article-10045-1.html --- .../20180308 What is open source programming.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20180308 What is open source programming.md (100%) diff --git a/translated/talk/20180308 What is open source programming.md b/published/20180308 What is open source programming.md similarity index 100% rename from translated/talk/20180308 What is open source programming.md rename to published/20180308 What is open source programming.md From d45f7d43cfa7d04899c93af48c6fbc1d6020e78d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 25 Sep 2018 15:09:02 +0800 Subject: [PATCH 403/455] PRF:20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md @geekpi --- ...buntu 18.04 and other Linux Distributions.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/translated/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md b/translated/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md index 2109a450fa..6dc4f4dba6 100644 --- a/translated/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md +++ b/translated/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md @@ -1,16 +1,17 @@ -如何在 Ubuntu 18.04 和其他 Linux 发行版中创建照片幻灯片 +如何在 Ubuntu 和其他 Linux 发行版中创建照片幻灯片 ====== + 创建照片幻灯片只需点击几下。以下是如何在 Ubuntu 18.04 和其他 Linux 发行版中制作照片幻灯片。 ![How to create slideshow of photos in Ubuntu Linux][1] -想象一下,你的朋友和亲戚正在拜访你,并请求你展示最近的活动/旅行照片。 +想象一下,你的朋友和亲戚正在拜访你,并请你展示最近的活动/旅行照片。 你将照片保存在计算机上,并整齐地放在单独的文件夹中。你邀请计算机附近的所有人。你进入该文件夹​​,单击其中一张图片,然后按箭头键逐个显示照片。 但那太累了!如果这些图片每隔几秒自动更改一次,那将会好很多。 -这称之为为幻灯片,我将向你展示如何在 Ubuntu 中创建照片幻灯片。这能让你在文件夹中循环播放图片并以全屏模式显示它们。 +这称之为幻灯片,我将向你展示如何在 Ubuntu 中创建照片幻灯片。这能让你在文件夹中循环播放图片并以全屏模式显示它们。 ### 在 Ubuntu 18.04 和其他 Linux 发行版中创建照片幻灯片 @@ -20,19 +21,19 @@ 如果你在 Ubuntu 18.04 或任何其他发行版中使用 GNOME,那么你很幸运。Gnome 的默认图像浏览器,Eye of GNOME,能够在当前文件夹中显示图片的幻灯片。 -只需单击其中一张图片,你将在程序的右上角菜单中看到设置选项。它看起来像三条横栏堆在彼此的顶部。 +只需单击其中一张图片,你将在程序的右上角菜单中看到设置选项。它看起来像堆叠在一起的三条横栏。 你会在这里看到几个选项。勾选幻灯片选项,它将全屏显示图像。 ![How to create slideshow of photos in Ubuntu Linux][2] -默认情况下,图像以 5 秒的间隔变化。你可以进入 Preferences->Slideshow 来更改幻灯片放映间隔。 +默认情况下,图像以 5 秒的间隔变化。你可以进入 “Preferences -> Slideshow” 来更改幻灯片放映间隔。 -![change slideshow interval in Ubuntu][3]Changing slideshow interval +![change slideshow interval in Ubuntu][3] #### 方法 2:使用 Shotwell Photo Manager 进行照片幻灯片放映 -[Shotwell][4] 是一种流行的[ Linux 照片管理程序][5]。适用于所有主要的 Linux 发行版。 +[Shotwell][4] 是一款流行的 [Linux 照片管理程序][5]。适用于所有主要的 Linux 发行版。 如果尚未安装,请在你的发行版软件中心中搜索 Shotwell 并安装。 @@ -55,7 +56,7 @@ via: https://itsfoss.com/photo-slideshow-ubuntu/ 作者:[Abhishek Prakash][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 3bb040ed3aa0459f4dff48de08e295e96e71890d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 25 Sep 2018 15:09:24 +0800 Subject: [PATCH 404/455] PUB:20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md @geekpi https://linux.cn/article-10046-1.html --- ...how of Photos in Ubuntu 18.04 and other Linux Distributions.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md (100%) diff --git a/translated/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md b/published/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md similarity index 100% rename from translated/tech/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md rename to published/20180831 How to Create a Slideshow of Photos in Ubuntu 18.04 and other Linux Distributions.md From bdcad5518f9988f5eccf4e9355b577651eff1819 Mon Sep 17 00:00:00 2001 From: HankChow <280630620@qq.com> Date: Tue, 25 Sep 2018 15:13:57 +0800 Subject: [PATCH 405/455] HankChow translating --- .../20180917 Linux tricks that can save you time and trouble.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180917 Linux tricks that can save you time and trouble.md b/sources/tech/20180917 Linux tricks that can save you time and trouble.md index 786e2df2c1..61fae6d4bc 100644 --- a/sources/tech/20180917 Linux tricks that can save you time and trouble.md +++ b/sources/tech/20180917 Linux tricks that can save you time and trouble.md @@ -1,3 +1,5 @@ +HankChow translating + Linux tricks that can save you time and trouble ====== Some command line tricks can make you even more productive on the Linux command line. From 5fe5882d962b8e906d5bb28c29c74c7b7888f0eb Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 25 Sep 2018 15:51:33 +0800 Subject: [PATCH 406/455] PRF:20180905 5 tips to improve productivity with zsh.md @tnuoccalanosrep --- ...5 tips to improve productivity with zsh.md | 91 +++++++++---------- 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/translated/tech/20180905 5 tips to improve productivity with zsh.md b/translated/tech/20180905 5 tips to improve productivity with zsh.md index 05c7e845ab..22cd2dfc2b 100644 --- a/translated/tech/20180905 5 tips to improve productivity with zsh.md +++ b/translated/tech/20180905 5 tips to improve productivity with zsh.md @@ -1,24 +1,24 @@ -用 zsh 提高生产力的5个 tips +用 zsh 提高生产力的 5 个技巧 ====== +> zsh 提供了数之不尽的功能和特性,这里有五个可以让你在命令行暴增效率的方法。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/features_solutions_command_data.png?itok=4_VQN3RK) -Z shell (亦称 zsh) 是 *unx 系统中的命令解析器 。 它跟 `sh` (Bourne shell) 家族的其他解析器 ( 如 `bash` 和 `ksh` ) 有着相似的特点,但它还提供了大量的高级特性以及强大的命令行编辑功能(选项?),如增强版tab补全。 +Z shell([zsh][1])是 Linux 和类 Unix 系统中的一个[命令解析器][2]。 它跟 sh (Bourne shell) 家族的其它解析器(如 bash 和 ksh)有着相似的特点,但它还提供了大量的高级特性以及强大的命令行编辑功能,如增强版 Tab 补全。 -由于 zsh 有好几百页的文档去描述他的特性,所以我无法在这里阐明 zsh 的所有功能。在本文,我会列出5个 tips,让你通过使用 zsh 来提高你的生产力。 +在这里不可能涉及到 zsh 的所有功能,[描述][3]它的特性需要好几百页。在本文中,我会列出 5 个技巧,让你通过在命令行使用 zsh 来提高你的生产力。 -### 1\. 主题和插件 +### 1、主题和插件 -多年来,开源社区已经为 zsh 开发了数不清的主题和插件。主题是预定义提示符的配置,而插件则是一组常用的别名命令和功能,让你更方便的使用一种特定的命令或者编程语言。 +多年来,开源社区已经为 zsh 开发了数不清的主题和插件。主题是一个预定义提示符的配置,而插件则是一组常用的别名命令和函数,可以让你更方便的使用一种特定的命令或者编程语言。 -如果你现在想开始用 zsh 的主题和插件,那么使用 zsh 的配置框架 (configuiration framework) 是你最快的入门方式。在众多的配置框架中,最受欢迎的则是 [Oh My Zsh][4]。在默认配置中,他就已经为 zsh 启用了一些合理的配置,同时它也自带多个主题和插件。 +如果你现在想开始用 zsh 的主题和插件,那么使用一种 zsh 的配置框架是你最快的入门方式。在众多的配置框架中,最受欢迎的则是 [Oh My Zsh][4]。在默认配置中,它就已经为 zsh 启用了一些合理的配置,同时它也自带上百个主题和插件。 -由于主题会在你的命令行提示符之前添加一些常用的信息,比如你 Git 仓库的状态,或者是当前使用的 Python 虚拟环境,所以它会让你的工作更高效。只需要看到这些信息,你就不用再敲命令去重新获取它们,而且这些提示也相当酷炫。 -下图就是我(作者)选用的主题 [Powerlevel9k][5] +主题会在你的命令行提示符之前添加一些有用的信息,比如你 Git 仓库的状态,或者是当前使用的 Python 虚拟环境,所以它会让你的工作更高效。只需要看到这些信息,你就不用再敲命令去重新获取它们,而且这些提示也相当酷炫。下图就是我选用的主题 [Powerlevel9k][5]: ![zsh Powerlevel9K theme][7] -zsh 主题 Powerlevel9k +*zsh 主题 Powerlevel9k* 除了主题,Oh my Zsh 还自带了大量常用的 zsh 插件。比如,通过启用 Git 插件,你可以用一组简便的命令别名操作 Git, 比如 @@ -36,39 +36,37 @@ gcs='git commit -S' glg='git log --stat' ``` -zsh 还有许多插件是用于多种编程语言,打包系统和一些平时在命令行中常用的工具。 -以下是我(作者) Ferdora 工作站中用到的插件表: +zsh 还有许多插件可以用于许多编程语言、打包系统和一些平时在命令行中常用的工具。以下是我 Ferdora 工作站中用到的插件表: ``` git golang fedora docker oc sudo vi-mode virtualenvwrapper ``` -### 2\. 智能的命令别名 +### 2、智能的命令别名 -命令别名在 zsh 中十分常用。为你常用的命令定义别名可以节省你的打字时间。Oh My Zsh 默认配置了一些常用的命令别名,包括目录导航命令别名,为常用的命令添加额外的选项,比如: +命令别名在 zsh 中十分有用。为你常用的命令定义别名可以节省你的打字时间。Oh My Zsh 默认配置了一些常用的命令别名,包括目录导航命令别名,为常用的命令添加额外的选项,比如: ``` ls='ls --color=tty' grep='grep  --color=auto --exclude-dir={.bzr,CVS,.git,.hg,.svn}' ``` +除了命令别名以外, zsh 还自带两种额外常用的别名类型:后缀别名和全局别名。 -除了命令别名意外, zsh 还自带两种额外常用的别名类型:后缀别名和全局别名。 - -后缀别名可以让你在基于文件后缀的前提下,在命令行中利用指定程序打开这个文件。比如,要用 vim 打开 YAML 文件,可以定义以下命令行别名: +后缀别名可以让你基于文件后缀,在命令行中利用指定程序打开这个文件。比如,要用 vim 打开 YAML 文件,可以定义以下命令行别名: ``` alias -s {yml,yaml}=vim ``` -现在,如果你在命令行中输入任何后缀名为 `yml` 或 `yaml` 文件, zsh 都会用 vim 打开这个文件 +现在,如果你在命令行中输入任何后缀名为 `yml` 或 `yaml` 文件, zsh 都会用 vim 打开这个文件。 ``` $ playbook.yml # Opens file playbook.yml using vim ``` -全局别名可以让你在使用命令行的任何时刻创建命令别名,而不仅仅是在开始的时候。这个在你想替换常用文件名或者管道命令的时候就显得非常有用了。比如 +全局别名可以让你创建一个可在命令行的任何地方展开的别名,而不仅仅是在命令开始的时候。这个在你想替换常用文件名或者管道命令的时候就显得非常有用了。比如: ``` alias -g G='| grep -i' @@ -84,9 +82,9 @@ drwxr-xr-x.  6 rgerardi rgerardi 4096 Aug 24 14:51 Downloads 接着,我们就来看看 zsh 是如何导航文件系统的。 -### 3\. 便捷的目录导航 +### 3、便捷的目录导航 -当你使用命令行的时候, 在不同的目录之间切换访问是最常见的工作了。 zsh 提供了一些十分有用的目录导航功能来简化这个操作。这些功能已经集成到 Oh My Zsh 中了, 而你可以用以下命令来启用它 +当你使用命令行的时候,在不同的目录之间切换访问是最常见的工作了。 zsh 提供了一些十分有用的目录导航功能来简化这个操作。这些功能已经集成到 Oh My Zsh 中了, 而你可以用以下命令来启用它 ``` setopt  autocd autopushd \ pushdignoredups @@ -104,7 +102,7 @@ $ pwd 如果想要回退,只要输入 `-`: -Zsh 会记录你访问过的目录,这样下次你就可以快速切换到这些目录中。如果想要看这个目录列表,只要输入 `dirs -v`: +zsh 会记录你访问过的目录,这样下次你就可以快速切换到这些目录中。如果想要看这个目录列表,只要输入 `dirs -v`: ``` $ dirs -v @@ -168,7 +166,7 @@ $ pwd /tmp ``` -最后,你可以在 zsh 中利用 Tab 来自动补全目录名称。你可以先输入目录的首字母,然后用 `TAB` 来补全它们: +最后,你可以在 zsh 中利用 Tab 来自动补全目录名称。你可以先输入目录的首字母,然后按 `TAB` 键来补全它们: ``` $ pwd @@ -179,22 +177,22 @@ $ Projects/Opensource.com/zsh-5tips/ 以上仅仅是 zsh 强大的 Tab 补全系统中的一个功能。接来下我们来探索它更多的功能。 -### 4\. 先进的 Tab 补全 +### 4、先进的 Tab 补全 -Zsh 强大的补全系统是它其中一个卖点。为了简便起见,我称它为 Tab 补全,然而在系统底层,它不仅仅只做一件事。这里通常包括扩展以及命令的补全,我会在这里同时讨论它们。如果想了解更多,详见 [用户手册][8] ( [User's Guide][8] )。 +zsh 强大的补全系统是它的卖点之一。为了简便起见,我称它为 Tab 补全,然而在系统底层,它起到了几个作用。这里通常包括展开以及命令补全,我会在这里用讨论它们。如果想了解更多,详见 [用户手册][8]。 + +在 Oh My Zsh 中,命令补全是默认启用的。要启用它,你只要在 `.zshrc` 文件中添加以下命令: -在 Oh My Zsh 中,命令补全是默认可用的。要启用它,你只要在 `.zshrc` 文件中添加以下命令: ``` autoload -U compinit compinit ``` -Zsh 的补全系统非常智能。他会根据当前上下文来进行命令的提示——比如,你输入了 `cd` 和 `TAB`,zsh 只会为你提示目录名,因为它知道 -当前的 `cd` 没有任何作用。 +zsh 的补全系统非常智能。它会尝试唯一提示可用在当前上下文环境中的项目 —— 比如,你输入了 `cd` 和 `TAB`,zsh 只会为你提示目录名,因为它知道其它的项目放在 `cd` 后面没用。 -反之,如果你使用 `ssh` 或者 `ping` 这类与用户或者主机相关的命令, zsh 便会提示用户名。 +反之,如果你使用与用户相关的命令便会提示用户名,而 `ssh` 或者 `ping` 这类则会提示主机名。 -`zsh` 拥有一个巨大而又完整的库,因此它能识别许多不同的命令。比如,如果你使用 `tar` 命令, 你可以按 Tab 键,他会为你展示一个可以用于解压的文件列表: +zsh 拥有一个巨大而又完整的库,因此它能识别许多不同的命令。比如,如果你使用 `tar` 命令, 你可以按 `TAB` 键,它会为你展示一个可以用于解压的文件列表: ``` $ tar -xzvf test1.tar.gz test1/file1 (TAB) @@ -221,7 +219,7 @@ $ git add (TAB) $ git add zsh-5tips.md ``` -zsh 还能识别命令行选项,同时他只会提示与选中子命令相关的命令列表: +zsh 还能识别命令行选项,同时它只会提示与选中子命令相关的命令列表: ``` $ git commit - (TAB) @@ -243,27 +241,27 @@ $ git commit - (TAB) ... TRUNCATED ... ``` -在按 `TAB` 键之后,你可以使用方向键来选择你想用的命令。现在你就不用记住所有的 Git 命令项了。 +在按 `TAB` 键之后,你可以使用方向键来选择你想用的命令。现在你就不用记住所有的 `git` 命令项了。 zsh 还有很多有用的功能。当你用它的时候,你就知道哪些对你才是最有用的。 -### 5\. 命令行编辑与历史记录 +### 5、命令行编辑与历史记录 -Zsh 的命令行编辑功能也十分有效。默认条件下,他是模拟 emacs 编辑器的。如果你是跟我一样更喜欢用 vi/vim,你可以用以下命令启用 vi 编辑。 +zsh 的命令行编辑功能也十分有用。默认条件下,它是模拟 emacs 编辑器的。如果你是跟我一样更喜欢用 vi/vim,你可以用以下命令启用 vi 的键绑定。 ``` $ bindkey -v ``` -如果你使用 Oh My Zsh,`vi-mode` 插件可以启用额外的绑定,同时会在你的命令提示符上增加 vi 的模式提示--这个非常有用。 +如果你使用 Oh My Zsh,`vi-mode` 插件可以启用额外的绑定,同时会在你的命令提示符上增加 vi 的模式提示 —— 这个非常有用。 -当启用 vi 的绑定后,你可以再命令行中使用 vi 命令进行编辑。比如,输入 `ESC+/` 来查找命令行记录。在查找的时候,输入 `n` 来找下一个匹配行,输入 `N` 来找上一个。输入 `ESC` 后,最常用的 vi 命令有以下几个,如输入 `0` 跳转到第一行,输入 `$` 跳转到最后一行,输入 `i` 来插入文本,输入 `a` 来追加文本等等,一些直接操作的命令也同样有效,比如输入 `cw` 来修改单词。 +当启用 vi 的绑定后,你可以在命令行中使用 vi 命令进行编辑。比如,输入 `ESC+/` 来查找命令行记录。在查找的时候,输入 `n` 来找下一个匹配行,输入 `N` 来找上一个。输入 `ESC` 后,常用的 vi 命令都可以使用,如输入 `0` 跳转到行首,输入 `$` 跳转到行尾,输入 `i` 来插入文本,输入 `a` 来追加文本等等,即使是跟随的命令也同样有效,比如输入 `cw` 来修改单词。 除了命令行编辑,如果你想修改或重新执行之前使用过的命令,zsh 还提供几个常用的命令行历史功能。比如,你打错了一个命令,输入 `fc`,你可以在你偏好的编辑器中修复最后一条命令。使用哪个编辑是参照 `$EDITOR` 变量的,而默认是使用 vi。 -另外一个有用的命令是 `r`, 他会重新执行上一条命令;而 `r ` 则会执行上一条包含 `WORD` 的命令。 +另外一个有用的命令是 `r`, 它会重新执行上一条命令;而 `r ` 则会执行上一条包含 `WORD` 的命令。 -最后,输入两个感叹号( `!!` ),可以在命令行中回溯最后一条命令。这个十分有用,比如,当你忘记使用 `sudo` 去执行需要权限的命令时: +最后,输入两个感叹号(`!!`),可以在命令行中回溯最后一条命令。这个十分有用,比如,当你忘记使用 `sudo` 去执行需要权限的命令时: ``` $ less /var/log/dnf.log @@ -274,19 +272,16 @@ $ sudo less /var/log/dnf.log 这个功能让查找并且重新执行之前命令的操作更加方便。 -### 何去何从? +### 下一步呢? -这里仅仅介绍了几个可以让你提高生产率的 zsh 特性;其实还有更多功能带你发掘;想知道更多的信息,你可以访问以下的资源: +这里仅仅介绍了几个可以让你提高生产率的 zsh 特性;其实还有更多功能有待你的发掘;想知道更多的信息,你可以访问以下的资源: -[An Introduction to the Z Shell][9] +- [An Introduction to the Z Shell][9] +- [A User's Guide to ZSH][10] +- [Archlinux Wiki][11] +- [zsh-lovers][12] -[A User's Guide to ZSH][10] - -[Archlinux Wiki][11] - -[zsh-lovers][12] - -你有使用 zsh 提高生产力的tips可以分享吗?我(作者)很乐意在下方评论看到它们。 +你有使用 zsh 提高生产力的技巧可以分享吗?我很乐意在下方评论中看到它们。 -------------------------------------------------------------------------------- @@ -295,7 +290,7 @@ via: https://opensource.com/article/18/9/tips-productivity-zsh 作者:[Ricardo Gerardi][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[tnuoccalanosrep](https://github.com/tnuoccalanosrep) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From f8fd032ec1bdf826324da2233a7a6d972dad4691 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 25 Sep 2018 15:52:10 +0800 Subject: [PATCH 407/455] PUB: 20180905 5 tips to improve productivity with zsh.md @tnuoccalanosrep https://linux.cn/article-10047-1.html --- .../20180905 5 tips to improve productivity with zsh.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180905 5 tips to improve productivity with zsh.md (100%) diff --git a/translated/tech/20180905 5 tips to improve productivity with zsh.md b/published/20180905 5 tips to improve productivity with zsh.md similarity index 100% rename from translated/tech/20180905 5 tips to improve productivity with zsh.md rename to published/20180905 5 tips to improve productivity with zsh.md From d54d204ffb0eaab55fdd1c23a46ffc245fbb00bb Mon Sep 17 00:00:00 2001 From: jrg Date: Tue, 25 Sep 2018 22:08:36 +0800 Subject: [PATCH 408/455] Delete 20180814 Automating backups on a Raspberry Pi NAS.md --- ...utomating backups on a Raspberry Pi NAS.md | 223 ------------------ 1 file changed, 223 deletions(-) delete mode 100644 sources/tech/20180814 Automating backups on a Raspberry Pi NAS.md diff --git a/sources/tech/20180814 Automating backups on a Raspberry Pi NAS.md b/sources/tech/20180814 Automating backups on a Raspberry Pi NAS.md deleted file mode 100644 index 28f7a5db35..0000000000 --- a/sources/tech/20180814 Automating backups on a Raspberry Pi NAS.md +++ /dev/null @@ -1,223 +0,0 @@ -[翻译中]translating by jrg! - -Automating backups on a Raspberry Pi NAS -====== -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X) - -In the [first part][1] of this three-part series using a Raspberry Pi for network-attached storage (NAS), we covered the fundamentals of the NAS setup, attached two 1TB hard drives (one for data and one for backups), and mounted the data drive on a remote device via the network filesystem (NFS). In part two, we will look at automating backups. Automated backups allow you to continually secure your data and recover from a hardware defect or accidental file removal. - -![](https://opensource.com/sites/default/files/uploads/nas_part2.png) - -### Backup strategy - -Let's get started by coming up with with a backup strategy for our small NAS. I recommend creating daily backups of your data and scheduling them for a time they won't interfere with other NAS activities, including when you need to access or store your files. For example, you could trigger the backup activities each day at 2am. - -You also need to decide how long you'll keep each backup, since you would quickly run out of storage if you kept each daily backup indefinitely. Keeping your daily backups for one week allows you to travel back into your recent history if you realize something went wrong over the previous seven days. But what if you need something from further in the past? Keeping each Monday backup for a month and one monthly backup for a longer period of time should be sufficient. Let's keep the monthly backups for a year and one backup every year for long-distance time travels, e.g., for the last five years. - -This results in a bunch of backups on your backup drive over a five-year period: - - * 7 daily backups - * 4 (approx.) weekly backups - * 12 monthly backups - * 5 annual backups - - - -You may recall that your backup drive and your data drive are of equal size (1TB each). How will more than 10 backups of 1TB from your data drive fit onto a 1TB backup disk? If you create full backups, they won't. Instead, you will create incremental backups, reusing the data from the last backup if it didn't change and creating replicas of new or changed files. That way, the backup doesn't double every night, but only grows a little bit depending on the changes that happen to your data over a day. - -Here is my situation: My NAS has been running since August 2016, and 20 backups are on the backup drive. Currently, I store 406GB of files on the data drive. The backups take up 726GB on my backup drive. Of course, this depends heavily on your data's change frequency, but as you can see, the incremental backups don't consume as much space as 20 full backups would. Nevertheless, over time the 1TB disk will probably become insufficient for your backups. Once your data grows close to the 1TB limit (or whatever your backup drive capacity), you should choose a bigger backup drive and move your data there. - -### Creating backups with rsync - -To create a full backup, you can use the rsync command line tool. Here is an example command to create the initial full backup. -``` -pi@raspberrypi:~ $ rsync -a /nas/data/ /nas/backup/2018-08-01 - -``` - -This command creates a full replica of all data stored on the data drive, mounted on `/nas/data`, on the backup drive. There, it will create the folder `2018-08-01` and create the backup inside it. The `-a` flag starts rsync in archive-mode, which means it preserves all kinds of metadata, like modification dates, permissions, and owners, and copies soft links as soft links. - -Now that you have created your full, initial backup as of August 1, on August 2, you will create your first daily incremental backup. -``` -pi@raspberrypi:~ $ rsync -a --link-dest /nas/backup/2018-08-01/ /nas/data/ /nas/backup/2018-08-02 - -``` - -This command tells rsync to again create a backup of `/nas/data`. The target directory this time is `/nas/backup/2018-08-02`. The script also specified the `--link-dest` option and passed the location of the last backup as an argument. With this option specified, rsync looks at the folder `/nas/backup/2018-08-01` and checks what data files changed compared to that folder's content. Unchanged files will not be copied, rather they will be hard-linked to their counterparts in yesterday's backup folder. - -When using a hard-linked file from a backup, you won't notice any difference between the initial copy and the link. They behave exactly the same, and if you delete either the link or the initial file, the other will still exist. You can imagine them as two equal entry points to the same file. Here is an example: - -![](https://opensource.com/sites/default/files/uploads/backup_flow.png) - -The left box reflects the state shortly after the second backup. The box in the middle is yesterday's replica. The `file2.txt` didn't exist yesterday, but the image `file1.jpg` did and was copied to the backup drive. The box on the right reflects today's incremental backup. The incremental backup command created `file2.txt`, which didn't exist yesterday. Since `file1.jpg` didn't change since yesterday, today a hard link is created so it doesn't take much additional space on the disk. - -### Automate your backups - -You probably don't want to execute your daily backup command by hand at 2am each day. Instead, you can automate your backup by using a script like the following, which you may want to start with a cron job. -``` -#!/bin/bash - - - -TODAY=$(date +%Y-%m-%d) - -DATADIR=/nas/data/ - -BACKUPDIR=/nas/backup/ - -SCRIPTDIR=/nas/data/backup_scripts - -LASTDAYPATH=${BACKUPDIR}/$(ls ${BACKUPDIR} | tail -n 1) - -TODAYPATH=${BACKUPDIR}/${TODAY} - -if [[ ! -e ${TODAYPATH} ]]; then - -        mkdir -p ${TODAYPATH} - -fi - - - -rsync -a --link-dest ${LASTDAYPATH} ${DATADIR} ${TODAYPATH} $@ - - - -${SCRIPTDIR}/deleteOldBackups.sh - -``` - -The first block calculates the last backup's folder name to use for links and the name of today's backup folder. The second block has the rsync command (as described above). The last block executes a `deleteOldBackups.sh` script. It will clean up the old, unnecessary backups based on the backup strategy outlined above. You could also execute the cleanup script independently from the backup script if you want it to run less frequently. - -The following script is an example implementation of the backup strategy in this how-to article. -``` -#!/bin/bash - -BACKUPDIR=/nas/backup/ - - - -function listYearlyBackups() { - -        for i in 0 1 2 3 4 5 - -                do ls ${BACKUPDIR} | egrep "$(date +%Y -d "${i} year ago")-[0-9]{2}-[0-9]{2}" | sort -u | head -n 1 - -        done - -} - - - -function listMonthlyBackups() { - -        for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 - -                do ls ${BACKUPDIR} | egrep "$(date +%Y-%m -d "${i} month ago")-[0-9]{2}" | sort -u | head -n 1 - -        done - -} - - - -function listWeeklyBackups() { - -        for i in 0 1 2 3 4 - -                do ls ${BACKUPDIR} | grep "$(date +%Y-%m-%d -d "last monday -${i} weeks")" - -        done - -} - - - -function listDailyBackups() { - -        for i in 0 1 2 3 4 5 6 - -                do ls ${BACKUPDIR} | grep "$(date +%Y-%m-%d -d "-${i} day")" - -        done - -} - - - -function getAllBackups() { - -        listYearlyBackups - -        listMonthlyBackups - -        listWeeklyBackups - -        listDailyBackups - -} - - - -function listUniqueBackups() { - -        getAllBackups | sort -u - -} - - - -function listBackupsToDelete() { - -        ls ${BACKUPDIR} | grep -v -e "$(echo -n $(listUniqueBackups) |sed "s/ /\\\|/g")" - -} - - - -cd ${BACKUPDIR} - -listBackupsToDelete | while read file_to_delete; do - -        rm -rf ${file_to_delete} - -done - -``` - -This script will first list all the backups to keep (according to our backup strategy), then it will delete all the backup folders that are not necessary anymore. - -To execute the scripts every night to create daily backups, schedule the backup script by running `crontab -e` as the root user. (You need to be in root to make sure it has permission to read all the files on the data drive, no matter who created them.) Add a line like the following, which starts the script every night at 2am. -``` -0 2 * * * /nas/data/backup_scripts/daily.sh - -``` - -For more information, read about [scheduling tasks with cron][2]. - - * Unmount your backup drive or mount it as read-only when no backups are running - * Attach the backup drive to a remote server and sync the files over the internet - - - -There are additional things you can do to fortify your backups against accidental removal or damage, including the following: - -This example backup strategy enables you to back up your valuable data to make sure it won't get lost. You can also easily adjust this technique for your personal needs and preferences. - -In part three of this series, we will talk about [Nextcloud][3], a convenient way to store and access data on your NAS system that also provides offline access as it synchronizes your data to the client devices. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/automate-backups-raspberry-pi - -作者:[Manuel Dewald][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/ntlx -[1]:https://opensource.com/article/18/7/network-attached-storage-Raspberry-Pi -[2]:https://opensource.com/article/17/11/how-use-cron-linux -[3]:https://nextcloud.com/ From 7dd12969ab56bd8c16a703673e8c9c28f28ebe88 Mon Sep 17 00:00:00 2001 From: jrg Date: Tue, 25 Sep 2018 22:11:10 +0800 Subject: [PATCH 409/455] Create 20180814 Automating backups on a Raspberry Pi NAS.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完成 20180814 Automating backups on a Raspberry Pi NAS.md --- ...utomating backups on a Raspberry Pi NAS.md | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 translated/tech/20180814 Automating backups on a Raspberry Pi NAS.md diff --git a/translated/tech/20180814 Automating backups on a Raspberry Pi NAS.md b/translated/tech/20180814 Automating backups on a Raspberry Pi NAS.md new file mode 100644 index 0000000000..111b508245 --- /dev/null +++ b/translated/tech/20180814 Automating backups on a Raspberry Pi NAS.md @@ -0,0 +1,229 @@ +Part-II 树莓派自建 NAS 云盘之数据自动备份 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X) + +在《树莓派自建 NAS 云盘》系列的 [第一篇][1] 文章中,我们讨论了建立 NAS 的一些基本步骤,添加了两块 1TB 的存储硬盘驱动(一个用于数据存储,一个用于数据备份),并且通过 网络文件系统(NFS)将数据存储盘挂载到远程终端上。本文是此系列的第二篇文章,我们将探讨数据自动备份。数据自动备份保证了数据的安全,为硬件损坏后的数据恢复提供便利以及减少了文件误操作带来的不必要的麻烦。 + + + +![](https://opensource.com/sites/default/files/uploads/nas_part2.png) + + + +### 备份策略 + +我们就从为小型 NAS 构想一个备份策略着手开始吧。我建议每天有时间节点有计划的去备份数据,以防止干扰到我们正常的访问 NAS,比如备份时间点避开正在访问 NAS 并写入文件的时间点。举个例子,你可以每天凌晨 2 点去进行数据备份。 + +另外,你还得决定每天的备份需要被保留的时间长短,因为如果没有时间限制,存储空间很快就会被用完。一般每天的备份保留一周便可以,如果数据出了问题,你便可以很方便的从备份中恢复出来原数据。但是如果需要恢复数据到更久之前怎么办?可以将每周一的备份文件保留一个月、每个月的备份保留更长时间。让我们把每月的备份保留一年时间,每一年的备份保留更长时间、例如五年。 + +这样,五年内在备份盘上产生大量备份: + +* 每周 7 个日备份 +* 每月 4 个周备份 +* 每年 12 个月备份 +* 每五年 5 个年备份 + + +你应该还记得,我们搭建的备份盘和数据盘大小相同(每个 1 TB)。如何将不止 10 个 1TB 数据的备份从数据盘存放到只有 1TB 大小的备份盘呢?如果你创建的是完整备份,这显然不可能。因此,你需要创建增量备份,它是每一份备份都基于上一份备份数据而创建的。增量备份方式不会每隔一天就成倍的去占用存储空间,它每天只会增加一点占用空间。 + +以下是我的情况:我的 NAS 自 2016 年 8 月开始运行,备份盘上有 20 个备份。目前,我在数据盘上存储了 406GB 的文件。我的备份盘用了 726GB。当然,备份盘空间使用率在很大程度上取决于数据的更改频率,但正如你所看到的,增量备份不会占用 20 个完整备份所需的空间。然而,随着时间的推移,1TB 空间也可能不足以进行备份。一旦数据增长接近 1TB 限制(或任何备份盘容量),应该选择更大的备份盘空间并将数据移动转移过去。 + +### 利用 rsync 进行数据备份 + +利用 rsync 命令行工具可以生成完整备份。 + +``` +pi@raspberrypi:~ $ rsync -a /nas/data/ /nas/backup/2018-08-01 + +``` + +这段命令将挂载在 /nas/data/ 目录下的数据盘中的数据进行了完整的复制备份。备份文件保存在 /nas/backup/2018-08-01 目录下。`-a` 参数是以归档模式进行备份,这将会备份所有的元数据,例如文件的修改日期、权限、拥有者以及软连接文件。 + +现在,你已经在 8 月 1 日创建了完整的初始备份,你将在 8 月 2 日创建第一个增量备份。 + +``` +pi@raspberrypi:~ $ rsync -a --link-dest /nas/backup/2018-08-01/ /nas/data/ /nas/backup/2018-08-02 + +``` + +上面这行代码又创建了一个关于 `/nas/data` 目录中数据的备份。备份路径是 `/nas/backup/2018-08-02`。这里的参数 `--link-dest` 指定了一个备份文件所在的路径。这样,这次备份会与 `/nas/backup/2018-08-01` 的备份进行比对,只备份已经修改过的文件,未做修改的文件将不会被复制,而是创建一个到上一个备份文件中它们的硬链接。 + +使用备份文件中的硬链接文件时,你一般不会注意到硬链接和初始拷贝之间的差别。它们表现的完全一样,如果删除其中一个硬链接或者文件,其他的依旧存在。你可以把它们看做是同一个文件的两个不同入口。下面就是一个例子: + +![](https://opensource.com/sites/default/files/uploads/backup_flow.png) + +左侧框是在进行了第二次备份后的原数据状态。中间的盒子是昨天的备份。昨天的备份中只有图片 `file1.jpg` 并没有 `file2.txt` 。右侧的框反映了今天的增量备份。增量备份命令创建昨天不存在的 `file2.txt`。由于 `file1.jpg` 自昨天以来没有被修改,所以今天创建了一个硬链接,它不会额外占用磁盘上的空间。 + +### 自动化备份 + +你肯定也不想每天凌晨去输入命令进行数据备份吧。你可以创建一个任务定时去调用下面的脚本让它自动化备份 + +``` +#!/bin/bash + + + +TODAY=$(date +%Y-%m-%d) + +DATADIR=/nas/data/ + +BACKUPDIR=/nas/backup/ + +SCRIPTDIR=/nas/data/backup_scripts + +LASTDAYPATH=${BACKUPDIR}/$(ls ${BACKUPDIR} | tail -n 1) + +TODAYPATH=${BACKUPDIR}/${TODAY} + +if [[ ! -e ${TODAYPATH} ]]; then + +        mkdir -p ${TODAYPATH} + +fi + + + +rsync -a --link-dest ${LASTDAYPATH} ${DATADIR} ${TODAYPATH} $@ + + + +${SCRIPTDIR}/deleteOldBackups.sh + +``` + +第一段代码指定了数据路径、备份路劲、脚本路径以及昨天和今天的备份路径。第二段代码调用 rsync 命令。最后一段代码执行 `deleteOldBackups.sh` 脚本,它会清除一些过期的没有必要的备份数据。如果不想频繁的调用 `deleteOldBackups.sh`,你也可以手动去执行它。 + +下面是今天讨论的备份策略的一个简单完整的示例脚本。 + +``` +#!/bin/bash + +BACKUPDIR=/nas/backup/ + + + +function listYearlyBackups() { + +        for i in 0 1 2 3 4 5 + +                do ls ${BACKUPDIR} | egrep "$(date +%Y -d "${i} year ago")-[0-9]{2}-[0-9]{2}" | sort -u | head -n 1 + +        done + +} + + + +function listMonthlyBackups() { + +        for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 + +                do ls ${BACKUPDIR} | egrep "$(date +%Y-%m -d "${i} month ago")-[0-9]{2}" | sort -u | head -n 1 + +        done + +} + + + +function listWeeklyBackups() { + +        for i in 0 1 2 3 4 + +                do ls ${BACKUPDIR} | grep "$(date +%Y-%m-%d -d "last monday -${i} weeks")" + +        done + +} + + + +function listDailyBackups() { + +        for i in 0 1 2 3 4 5 6 + +                do ls ${BACKUPDIR} | grep "$(date +%Y-%m-%d -d "-${i} day")" + +        done + +} + + + +function getAllBackups() { + +        listYearlyBackups + +        listMonthlyBackups + +        listWeeklyBackups + +        listDailyBackups + +} + + + +function listUniqueBackups() { + +        getAllBackups | sort -u + +} + + + +function listBackupsToDelete() { + +        ls ${BACKUPDIR} | grep -v -e "$(echo -n $(listUniqueBackups) |sed "s/ /\\\|/g")" + +} + + + +cd ${BACKUPDIR} + +listBackupsToDelete | while read file_to_delete; do + +        rm -rf ${file_to_delete} + +done + +``` + +这段脚本会首先根据你的备份策略列出所有需要保存的备份文件,然后它会删除那些再也不需要了的备份目录。 + +下面创建一个定时任务去执行上面这段代码。以 root 用户权限打开 `crontab -e`,输入以下这段命令,它将会创建一个每天凌晨 2 点去执行 `/nas/data/backup_scripts/daily.sh` 的定时任务。 + +``` +0 2 * * * /nas/data/backup_scripts/daily.sh + +``` + +有关创建定时任务请参考 [cron 创建定时任务][2]。 + +* 当没有备份任务时,卸载你的备份盘或者将它挂载为只读盘; +* 利用远程服务器作为你的备份盘,这样就可以通过互联网同步数据 + +你也可用下面的方法来加强你的备份策略,以防止备份数据的误删除或者被破坏: + +本文中备份策略示例是备份一些我觉得有价值的数据,你也可以根据个人需求去修改这些策略。 + +我将会在 《树莓派自建 NAS 云盘》 系列的第三篇文章中讨论 [Nextcloud][3]。Nextcloud 提供了更方便的方式去访问 NAS 云盘上的数据并且它还提供了离线操作,你还可以在客户端中同步你的数据。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/automate-backups-raspberry-pi + +作者:[Manuel Dewald][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[jrg](https://github.com/jrglinux) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ntlx +[1]: https://opensource.com/article/18/7/network-attached-storage-Raspberry-Pi +[2]: https://opensource.com/article/17/11/how-use-cron-linux +[3]: https://nextcloud.com/ + From 7c229082b54a20d46fb508bbc634431fe6704d02 Mon Sep 17 00:00:00 2001 From: jrg Date: Tue, 25 Sep 2018 22:13:42 +0800 Subject: [PATCH 410/455] Delete 20180919 Host your own cloud with Raspberry Pi NAS.md --- ...st your own cloud with Raspberry Pi NAS.md | 113 ------------------ 1 file changed, 113 deletions(-) delete mode 100644 sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md diff --git a/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md b/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md deleted file mode 100644 index 0ecb3801c9..0000000000 --- a/sources/tech/20180919 Host your own cloud with Raspberry Pi NAS.md +++ /dev/null @@ -1,113 +0,0 @@ -[翻译中]translating by jrg! - -Host your own cloud with Raspberry Pi NAS -====== - -Protect and secure your data with a self-hosted cloud powered by your Raspberry Pi. - -In the first two parts of this series, we discussed the [hardware and software fundamentals][1] for building network-attached storage (NAS) on a Raspberry Pi. We also put a proper [backup strategy][2] in place to secure the data on the NAS. In this third part, we will talk about a convenient way to store, access, and share your data with [Nextcloud][3]. - -### Prerequisites - -To use Nextcloud conveniently, you have to meet a few prerequisites. First, you should have a domain you can use for the Nextcloud instance. For the sake of simplicity in this how-to, we'll use **nextcloud.pi-nas.com**. This domain should be directed to your Raspberry Pi. If you want to run it on your home network, you probably need to set up dynamic DNS for this domain and enable port forwarding of ports 80 and 443 (if you go for an SSL setup, which is highly recommended; otherwise port 80 should be sufficient) from your router to the Raspberry Pi. - -You can automate dynamic DNS updates from the Raspberry Pi using [ddclient][4]. - -### Install Nextcloud - -To run Nextcloud on your Raspberry Pi (using the setup described in the [first part][1] of this series), install the following packages as dependencies to Nextcloud using **apt**. - -``` -sudo apt install unzip wget php apache2 mysql-server php-zip php-mysql php-dom php-mbstring php-gd php-curl -``` - -The next step is to download Nextcloud. [Get the latest release's URL][5] and copy it to download via **wget** on the Raspberry Pi. In the first article in this series, we attached two disk drives to the Raspberry Pi, one for current data and one for backups. Install Nextcloud on the data drive to make sure data is backed up automatically every night. - -``` -sudo mkdir -p /nas/data/nextcloud -sudo chown pi /nas/data/nextcloud -cd /nas/data/ -wget https://download.nextcloud.com/server/releases/nextcloud-14.0.0.zip -O /nas/data/nextcloud.zip -unzip nextcloud.zip -sudo ln -s /nas/data/nextcloud /var/www/nextcloud -sudo chown -R www-data:www-data /nas/data/nextcloud -``` - -When I wrote this, the latest release (as you see in the code above) was 14. Nextcloud is under heavy development, so you may find a newer version when installing your copy of Nextcloud onto your Raspberry Pi. - -### Database setup - -When we installed Nextcloud above, we also installed MySQL as a dependency to use it for all the metadata Nextcloud generates (for example, the users you create to access Nextcloud). If you would rather use a Postgres database, you'll need to adjust some of the modules installed above. - -To access the MySQL database as root, start the MySQL client as root: - -``` -sudo mysql -``` - -This will open a SQL prompt where you can insert the following commands—substituting the placeholder with the password you want to use for the database connection—to create a database for Nextcloud. - -``` -CREATE USER nextcloud IDENTIFIED BY ''; -CREATE DATABASE nextcloud; -GRANT ALL ON nextcloud.* TO nextcloud; -``` - -You can exit the SQL prompt by pressing **Ctrl+D** or entering **quit**. - -### Web server configuration - -Nextcloud can be configured to run using Nginx or other web servers, but for this how-to, I decided to go with the Apache web server on my Raspberry Pi NAS. (Feel free to try out another alternative and let me know if you think it performs better.) - -To set it up, configure a virtual host for the domain you created for your Nextcloud instance **nextcloud.pi-nas.com**. To create a virtual host, create the file **/etc/apache2/sites-available/001-nextcloud.conf** with content similar to the following. Make sure to adjust the ServerName to your domain and paths, if you didn't use the ones suggested earlier in this series. - -``` - -ServerName nextcloud.pi-nas.com -ServerAdmin admin@pi-nas.com -DocumentRoot /var/www/nextcloud/ - - -AllowOverride None - - -``` - -To enable this virtual host, run the following two commands. - -``` -a2ensite 001-nextcloud -sudo systemctl reload apache2 -``` - -With this configuration, you should now be able to reach the web server with your domain via the web browser. To secure your data, I recommend using HTTPS instead of HTTP to access Nextcloud. A very easy (and free) way is to obtain a [Let's Encrypt][6] certificate with [Certbot][7] and have a cron job automatically refresh it. That way you don't have to mess around with self-signed or expiring certificates. Follow Certbot's simple how-to [instructions to install it on your Raspberry Pi][8]. During Certbot configuration, you can even decide to automatically forward HTTP to HTTPS, so visitors to **** will be redirected to ****. Please note, if your Raspberry Pi is running behind your home router, you must have port forwarding enabled for ports 443 and 80 to obtain Let's Encrypt certificates. - -### Configure Nextcloud - -The final step is to visit your fresh Nextcloud instance in a web browser to finish the configuration. To do so, open your domain in a browser and insert the database details from above. You can also set up your first Nextcloud user here, the one you can use for admin tasks. By default, the data directory should be inside the Nextcloud folder, so you don't need to change anything for the backup mechanisms from the [second part of this series][2] to pick up the data stored by users in Nextcloud. - -Afterward, you will be directed to your Nextcloud and can log in with the admin user you created previously. To see a list of recommended steps to ensure a performant and secure Nextcloud installation, visit the Basic Settings tab in the Settings page (in our example: settings/admin) and see the Security & Setup Warnings section. - -Congratulations! You've set up your own Nextcloud powered by a Raspberry Pi. Go ahead and [download a Nextcloud client][9] from the Nextcloud page to sync data with your client devices and access it offline. Mobile clients even provide features like instant upload of pictures you take, so they'll automatically sync to your desktop PC without wondering how to get them there. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/host-cloud-nas-raspberry-pi - -作者:[Manuel Dewald][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/ntlx -[1]: https://opensource.com/article/18/7/network-attached-storage-Raspberry-Pi -[2]: https://opensource.com/article/18/8/automate-backups-raspberry-pi -[3]: https://nextcloud.com/ -[4]: https://sourceforge.net/p/ddclient/wiki/Home/ -[5]: https://nextcloud.com/install/#instructions-server -[6]: https://letsencrypt.org/ -[7]: https://certbot.eff.org/ -[8]: https://certbot.eff.org/lets-encrypt/debianother-apache -[9]: https://nextcloud.com/install/#install-clients From ab1707a35d097d10671d3f724db5b26a25626029 Mon Sep 17 00:00:00 2001 From: jrg Date: Tue, 25 Sep 2018 22:15:10 +0800 Subject: [PATCH 411/455] Create 20180919 Host your own cloud with Raspberry Pi NAS.md --- ...st your own cloud with Raspberry Pi NAS.md | 112 ++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 translated/tech/20180919 Host your own cloud with Raspberry Pi NAS.md diff --git a/translated/tech/20180919 Host your own cloud with Raspberry Pi NAS.md b/translated/tech/20180919 Host your own cloud with Raspberry Pi NAS.md new file mode 100644 index 0000000000..312fed7c4c --- /dev/null +++ b/translated/tech/20180919 Host your own cloud with Raspberry Pi NAS.md @@ -0,0 +1,112 @@ +Part-III 树莓派自建 NAS 云盘之云盘构建 +====== + +用树莓派 NAS 云盘来保护数据的安全! + +在前面两篇文章中(译注:文章链接 [Part-I][1],[Part-II][2]),我们讨论了用树莓派搭建一个 NAS(network-attached storage) 所需要的一些 [软硬件环境及其操作步骤][1]。我们还制定了适当的 [备份策略][2] 来保护NAS上的数据。本文中,我们将介绍讨论利用 [Nestcloud][3] 来方便快捷的存储、获取以及分享你的数据。 + +### 必要的准备工作 + +想要方便的使用 Nextcloud,需要一些必要的准备工作。首先,你需要一个指向 Nextcloud 的域名。方便起见,本文将使用 **nextcloud.pi-nas.com** 。如果你是在家庭网络里运行,你需要为该域名配置 DNS 服务(动态域名解析服务)并在路由器中开启 80 端口和 443 端口转发功能(如果需要使用 https,则需要开启 443 端口转发,如果只用 http,80 端口足以)。 + +你可以使用 [ddclient][4] 在树莓派中自动更新 DNS。 + +### 安装 Nextcloud + +为了在树莓派(参考 [Part-I][1] 中步骤设置)中运行 Nextcloud,首先用命令 **apt** 安装 以下的一些依赖软件包。 + +``` +sudo apt install unzip wget php apache2 mysql-server php-zip php-mysql php-dom php-mbstring php-gd php-curl +``` + +其次,下载 Nextcloud。在树莓派中利用 **wget** 下载其 [最新的版本][5]。在 [Part-I] 文章中,我们将两个磁盘驱动器连接到树莓派,一个用于存储当前数据,另一个用于备份。这里在数据存储盘上安装 Nextcloud,以确保每晚自动备份数据。 + +``` +sudo mkdir -p /nas/data/nextcloud +sudo chown pi /nas/data/nextcloud +cd /nas/data/ +wget https://download.nextcloud.com/server/releases/nextcloud-14.0.0.zip -O /nas/data/nextcloud.zip +unzip nextcloud.zip +sudo ln -s /nas/data/nextcloud /var/www/nextcloud +sudo chown -R www-data:www-data /nas/data/nextcloud +``` + +截止到写作本文时,Nextcloud 最新版更新到如上述代码中所示的 14.0.0 版本。Nextcloud 正在快速的迭代更新中,所以你可以在你的树莓派中安装更新一点的版本。 + +### 配置数据库 + +如上所述,Nextcloud 安装完毕。之前安装依赖软件包时就已经安装了 MySQL 数据库来存储 Nextcloud 的一些重要数据(例如,那些你创建的可以访问 Nextcloud 的用户的信息)。如果你更愿意使用 Pstgres 数据库,则上面的依赖软件包需要做一些调整。 + +以 root 权限启动 MySQL: + +``` +sudo mysql +``` + +这将会打开 SQL 提示符界面,在那里可以插入如下指令--使用数据库连接密码替换其中的占位符--为 Nextcloud 创建一个数据库。 + +``` +CREATE USER nextcloud IDENTIFIED BY ''; +CREATE DATABASE nextcloud; +GRANT ALL ON nextcloud.* TO nextcloud; +``` + +按 **Ctrl+D** 或输入 **quit** 退出 SQL 提示符界面。 + +### Web 服务器配置 + +Nextcloud 可以配置以适配于 Nginx 服务器或者其他 Web 服务器运行的环境。但本文中,我决定在我的树莓派 NAS 中运行 Apache 服务器(如果你有其他效果更好的服务器选择方案,不妨也跟我分享一下)。 + +首先为你的 Nextcloud 域名创建一个虚拟主机,创建配置文件 **/etc/apache2/sites-available/001-netxcloud.conf**,在其中输入下面的参数内容。修改其中 ServerName 为你的域名。 + +``` + +ServerName nextcloud.pi-nas.com +ServerAdmin admin@pi-nas.com +DocumentRoot /var/www/nextcloud/ + + +AllowOverride None + + +``` + +使用下面的命令来启动该虚拟主机。 + +``` +a2ensite 001-nextcloud +sudo systemctl reload apache2 +``` + +现在,你应该可以通过浏览器中输入域名访问到 web 服务器了。这里我推荐使用 HTTPS 协议而不是 HTTP 协议来访问 Nextcloud。一个简单而且免费的方法就是利用 [Certbot][7] 下载 [Let's Encrypt][6] 证书,然后设置定时任务自动刷新。这样就避免了自签证书等的麻烦。参考 [如何在树莓派中安装][8] Certbot 。在配置 Certbot 的时候,你甚至可以配置将 HTTP 自动转到 HTTPS ,例如访问 **** 自动跳转到 ****。注意,如果你的树莓派 NAS 运行在家庭路由器的下面,别忘了设置路由器的 443 端口和 80 端口转发。 + +### 配置 Nextcloud + +最后一步,通过浏览器访问 Nextcloud 来配置它。在浏览器中输入域名地址,插入上文中的数据库设置信息。这里,你可以创建 Nextcloud 管理员用户。默认情况下,数据保存目录在在 Nextcloud 目录下,所以你也无需修改我们在 [Part-II][2] 一文中设置的备份策略。 + +然后,页面会跳转到 Nextcloud 登陆界面,用刚才创建的管理员用户登陆。在设置页面中会有基础操作教程和安全安装教程(这里是访问 settings/admin)。 + +恭喜你,到此为止,你已经成功在树莓派中安装了你自己的云 Nextcloud。去 Nextcloud 主页 [下载 Nextcloud 客户端][9],客户端可以同步数据并且离线访问服务器。移动端甚至可以上传图片等资源,然后电脑桌面都可以去访问它们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/host-cloud-nas-raspberry-pi + +作者:[Manuel Dewald][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[jrg](https://github.com/jrglinux) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ntlx +[1]: https://opensource.com/article/18/7/network-attached-storage-Raspberry-Pi +[2]: https://opensource.com/article/18/8/automate-backups-raspberry-pi +[3]: https://nextcloud.com/ +[4]: https://sourceforge.net/p/ddclient/wiki/Home/ +[5]: https://nextcloud.com/install/#instructions-server +[6]: https://letsencrypt.org/ +[7]: https://certbot.eff.org/ +[8]: https://certbot.eff.org/lets-encrypt/debianother-apache +[9]: https://nextcloud.com/install/#install-clients + From 86dac844d8de74b9d770b30cb3bccf534df1db15 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 25 Sep 2018 22:38:20 +0800 Subject: [PATCH 412/455] PRF:20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @jrglinux 翻译的很好,就是 markdown 格式上再注意点,如果使用 Mac,可以使用 MacDown 编辑器。 --- ..., a static site generator written in Go.md | 232 ++++++++---------- 1 file changed, 104 insertions(+), 128 deletions(-) diff --git a/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md b/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md index f5366353b3..648073a246 100644 --- a/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md +++ b/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md @@ -1,179 +1,155 @@ -Hugo,30分钟搭建博客,一个Go语言开发的静态站点生成工具 +用 Hugo 30 分钟搭建静态博客 ====== - ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy) +> 了解 Hugo 如何使构建网站变得有趣。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming-code-keyboard-laptop-music-headphones.png?itok=EQZ2WKzy) - 你是不是强烈的想搭建博客来将自己对软件框架等的探索学习成果分享呢? +你是不是强烈地想搭建博客来将自己对软件框架等的探索学习成果分享呢?你是不是面对缺乏指导文档而一团糟的项目就有一种想去改变它的冲动呢?或者换个角度,你是不是十分期待能创建一个属于自己的个人博客网站呢? - 你是不是面对缺乏指导文档而一团糟的项目就有一种想去改变它的冲动呢? +很多人在想搭建博客之前都有一些严重的迟疑顾虑:感觉自己缺乏内容管理系统(CMS)的相关知识,更缺乏时间去学习这些知识。现在,如果我说不用花费大把的时间去学习 CMS 系统、学习如何创建一个静态网站、更不用操心如何去强化网站以防止它受到黑客攻击的问题,你就可以在 30 分钟之内创建一个博客?你信不信?利用 Hugo 工具,就可以实现这一切。 - 或者换个角度,你是不是十分期待能创建一个属于自己的个人博客网站呢? +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_1.png?itok=JgxBSOBG) - 很多人在想搭建博客之前都有一些严重的迟疑顾虑:感觉自己缺乏内容管理系统(CMS)的相关知识,更缺乏时间去学习这些知识。现在,如果我说不用花费大把的时间去学习 CMS 系统、学习如何创建一个静态网站、更不用操心如何去强化网站以防止它受到黑客攻击的问题,你就可以在 30 分钟之内创建一个博客?你信不信?利用 Hugo 工具,就可以实现这一切。 +Hugo 是一个基于 Go 语言开发的静态站点生成工具。也许你会问,为什么选择它? + +* 无需数据库、无需需要各种权限的插件、无需跑在服务器上的底层平台,更没有额外的安全问题。 +* 都是静态站点,因此拥有轻量级、快速响应的服务性能。此外,所有的网页都是在部署的时候生成,所以服务器负载很小。 +* 极易操作的版本控制。一些 CMS 平台使用它们自己的版本控制软件(VCS)或者在网页上集成 Git 工具。而 Hugo,所有的源文件都可以用你所选的 VCS 软件来管理。 - ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_1.png?itok=JgxBSOBG) +### 0-5 分钟:下载 Hugo,生成一个网站 - Hugo 是一个基于 Go 语言开发的静态站点生成工具。也许你会问,为什么选择它? - * 无需数据库、无需需要各种权限的插件、无需跑在服务器上的底层平台,更没有额外的安全问题。 - * 都是静态站点,因此拥有轻量级、快速响应的服务性能。此外,所有的网页都是在部署的时候呈现,所以服务器负载很小。 - * 极易操作的版本控制。一些 CMS 平台使用它们自己的版本控制软件(VCS)或者在网页上集成 Git 工具。而 Hugo,所有的源文件都可以用你所选的 VCS 软件来管理。 +直白的说,Hugo 使得写一个网站又一次变得有趣起来。让我们来个 30 分钟计时,搭建一个网站。 + +为了简化 Hugo 安装流程,这里直接使用 Hugo 可执行安装文件。 - ### 0-5 分钟:下载 Hugo,生成一个网站 +1. 下载和你操作系统匹配的 Hugo [版本][2]; +2. 压缩包解压到指定路径,例如 windows 系统的 `C:\hugo_dir` 或者 Linux 系统的 `~/hugo_dir` 目录;下文中的变量 `${HUGO_HOME}` 所指的路径就是这个安装目录; +3. 打开命令行终端,进入安装目录:`cd ${HUGO_HOME}`; +4. 确认 Hugo 已经启动: + * Unix 系统:`${HUGO_HOME}/[hugo version]`; + * Windows 系统:`${HUGO_HOME}\[hugo.exe version]`,例如:cmd 命令行中输入:`c:\hugo_dir\hugo version`。 + + 为了书写上的简化,下文中的 `hugo` 就是指 hugo 可执行文件所在的路径(包括可执行文件),例如命令 `hugo version` 就是指命令 `c:\hugo_dir\hugo version` 。(LCTT 译注:可以把 hugo 可执行文件所在的路径添加到系统环境变量下,这样就可以直接在终端中输入 `hugo version`) + + 如果命令 `hugo version` 报错,你可能下载了错误的版本。当然,有很多种方法安装 Hugo,更多详细信息请查阅 [官方文档][3]。最稳妥的方法就是把 Hugo 可执行文件放在某个路径下,然后执行的时候带上路径名 +5. 创建一个新的站点来作为你的博客,输入命令:`hugo new site awesome-blog`; +6. 进入新创建的路径下: `cd awesome-blog`; + +恭喜你!你已经创建了自己的新博客。 - 直白的说,Hugo 使得写一个网站又一次变得有趣起来。让我们来个 30 分钟计时,搭建一个网站。 +### 5-10 分钟:为博客设置主题 - 为了简化 Hugo 安装流程,这里直接使用 Hugo 可执行安装文件。 +Hugo 中你可以自己构建博客的主题或者使用网上已经有的一些主题。这里选择 [Kiera][4] 主题,因为它简洁漂亮。按以下步骤来安装该主题: + +1. 进入主题所在目录:`cd themes`; +2. 克隆主题:`git clone https://github.com/avianto/hugo-kiera kiera`。如果你没有安装 Git 工具: + * 从 [Github][5] 上下载 hugo 的 .zip 格式的文件; + * 解压该 .zip 文件到你的博客主题 `theme` 路径; + * 重命名 `hugo-kiera-master` 为 `kiera`; +3. 返回博客主路径:`cd awesome-blog`; +4. 激活主题;通常来说,主题(包括 Kiera)都自带文件夹 `exampleSite`,里面存放了内容配置的示例文件。激活 Kiera 主题需要拷贝它提供的 `config.toml` 到你的博客下: + * Unix 系统:`cp themes/kiera/exampleSite/config.toml .`; + * Windows 系统:`copy themes\kiera\exampleSite\config.toml .`; + * 选择 `Yes` 来覆盖原有的 `config.toml`; + +5. ( 可选操作 )你可以选择可视化的方式启动服务器来验证主题是否生效:`hugo server -D` 然后在浏览器中输入 `http://localhost:1313`。可用通过在终端中输入 `Crtl+C` 来停止服务器运行。现在你的博客还是空的,但这也给你留了写作的空间。它看起来如下所示: + +![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_2.png?itok=PINOIOSU) - 1. 下载和你操作系统匹配的 Hugo [版本][2]; - - 2. 压缩包解压到指定路径,例如 windows 系统的 `C:\hugo_dir` 或者 Linux 系统的 `~/hugo_dir` 目录;下文中的变量 `${HUGO_HOME}` 所指的路径就是这个安装目录; - - 3. 打开命令行终端,进入安装目录:`cd ${HUGO_HOME}`; - - 4. 确认 Hugo 已经启动: - * Unix 系统:`${HUGO_HOME}/[hugo version]`; - * Windows 系统:`${HUGO_HOME}\[hugo.exe version]`; - - 例如:Windows 系统下,cmd 命令行中输入:`c:\hugo_dir\hugo version`。 - - 为了书写上的简化,下文中的 `hugo` 就是指 hugo 可执行文件所在的路径(包括可执行文件),例如命令 `hugo version` 就是指命令 `c:\hugo_dir\hugo version` 。(译者注:可以把 hugo 可执行文件所在的路径添加到系统环境变量下,这样就可以直接在终端中输入 `hugo version`) - 如果命令 `hugo version` 报错,你可能下载了错误的版本。当然,有很多种方法安装 Hugo,更多详细信息请查阅 [官方文档][3]。最稳妥的方法就是把 Hugo 可执行文件放在某个路径下,然后执行的时候带上路径名 - - 5. 创建一个新的站点来作为你的博客,输入命令:`hugo new site awesome-blog`; - - 6. 进入新创建的路径下: `cd awesome-blog`; - - 恭喜你!你已经创建了自己的新博客。 +你已经成功的给博客设置了主题!你可以在官方 [Hugo 主题][4] 网站上找到上百种漂亮的主题供你使用。 - ### 5-10 分钟:为博客设置主题 +### 10-20 分钟:给博客添加内容 - Hugo 中你可以自己构建博客的主题或者使用网上已经有的一些主题。这里选择 [Kiera][4] 主题,因为它简洁漂亮。按以下步骤来安装该主题: - - 1. 进入主题所在目录:`cd themes`; - - 2. 克隆主题:`git clone https://github.com/avianto/hugo-kiera kiera`。如果你没有安装 Git 工具: - * 从 [Github][5] 上下载 hugo 的 .zip 格式的文件; - * 解压该 .zip 文件到你的博客主题 `theme` 路径; - * 重命名 `hugo-kiera-master` 为 `kiera`; - - 3. 返回博客主路径:`cd awesome-blog`; - - 4. 激活主题;通常来说,主题(包括 Kiera )都自带文件夹 `exampleSite`,里面存放了内容配置的示例文件。激活 Kiera 主题需要拷贝它提供的 `config.toml` 到你的博客下: - * Unix 系统:`cp themes/kiera/exampleSite/config.toml .`; - * Windows 系统:`copy themes\kiera\exampleSite\config.toml .`; - * 选择 `Yes` 来覆盖原有的 `config.toml`; - - 5. ( 可选操作 )你可以选择可视化的方式启动服务器来验证主题是否生效:`hugo server -D` 然后在浏览器中输入 `http://localhost:1313`。可用通过在终端中输入 `Crtl+C` 来停止服务器运行。现在你的博客还是空的,但这也给你留了写作的空间。它看起来如下所示: - - ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_2.png?itok=PINOIOSU) +对于碗来说,它是空的时候用处最大,可以用来盛放东西;但对于博客来说不是这样,空博客几乎毫无用处。在这一步,你将会给博客添加内容。Hugo 和 Kiera 主题都为这个工作提供了方便性。按以下步骤来进行你的第一次提交: - 你已经成功的给博客设置了主题!你可以在官方 [Hugo 主题][4] 网站上找到上百种漂亮的主题供你使用。 - - ### 10-20 分钟:给博客添加内容 - - 对于碗来说,它是空的时候用处最大,可以用来盛放东西;但对于博客来说不是这样,空博客几乎毫无用处。在这一步,你将会给博客添加内容。Hugo 和 Kiera 主题都为这个工作提供了方便性。按以下步骤来进行你的第一次提交: - - 1. archetypes 将会是你的内容模板。 - - 2. 添加主题中的 archtypes 至你的博客: - * Unix 系统: `cp themes/kiera/archetypes/* archetypes/` - * Windows 系统:`copy themes\kiera\archetypes\* archetypes\` - * 选择 `Yes` 来覆盖原来的 `default.md` 内容架构类型 - - 3. 创建博客 posts 目录: - * Unix 系统: `mkdir content/posts` - * Windows 系统: `mkdir content\posts` - - 4. 利用 Hugo 生成你的 post: +1. archetypes 将会是你的内容模板。 +2. 添加主题中的 archtypes 至你的博客: + * Unix 系统: `cp themes/kiera/archetypes/* archetypes/` + * Windows 系统:`copy themes\kiera\archetypes\* archetypes\` + * 选择 `Yes` 来覆盖原来的 `default.md` 内容架构类型 + +3. 创建博客 posts 目录: + * Unix 系统: `mkdir content/posts` + * Windows 系统: `mkdir content\posts` + +4. 利用 Hugo 生成你的 post: * Unix 系统:`hugo nes posts/first-post.md`; * Windows 系统:`hugo new posts\first-post.md`; - 5. 在文本编辑器中打开这个新建的 post 文件: +5. 在文本编辑器中打开这个新建的 post 文件: * Unix 系统:`gedit content/posts/first-post.md`; * Windows 系统:`notepadd content\posts\first-post.md`; - 此刻,你可以疯狂起来了。注意到你的提交文件中包括两个部分。第一部分是以 `+++` 符号分隔开的。它包括了提交文档的主要数据,例如名称、时间等。在 Hugo 中,这叫做前缀。在前缀之后,才是正文。下面编辑第一个提交文件内容: +此刻,你可以疯狂起来了。注意到你的提交文件中包括两个部分。第一部分是以 `+++` 符号分隔开的。它包括了提交文档的主要数据,例如名称、时间等。在 Hugo 中,这叫做前缀。在前缀之后,才是正文。下面编辑第一个提交文件内容: - ``` +``` +++ - title = "First Post" - date = 2018-03-03T13:23:10+01:00 - draft = false - tags = ["Getting started"] - categories = [] - +++ - Hello Hugo world! No more excuses for having no blog or documentation now! - ``` +title = "First Post" +date = 2018-03-03T13:23:10+01:00 +draft = false +tags = ["Getting started"] +categories = [] ++++ + +Hello Hugo world! No more excuses for having no blog or documentation now! +``` - 现在你要做的就是启动你的服务器:`hugo server -D`;然后打开浏览器,输入 `http://localhost:1313/`。 +现在你要做的就是启动你的服务器:`hugo server -D`;然后打开浏览器,输入 `http://localhost:1313/`。 ![](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/hugo_3.png?itok=I-_v0qLx) - ### 20-30 分钟:调整网站 +### 20-30 分钟:调整网站 - 前面的工作很完美,但还有一些问题需要解决。例如,简单地命名你的站点: - - 1. 终端中按下 `Ctrl+C` 以停止服务器。 +前面的工作很完美,但还有一些问题需要解决。例如,简单地命名你的站点: + +1. 终端中按下 `Ctrl+C` 以停止服务器。 +2. 打开 `config.toml`,编辑博客的名称,版权,你的姓名,社交网站等等。 - 2. 打开 `config.toml`,编辑博客的名称,版权,你的姓名,社交网站等等。 - - 当你再次启动服务器后,你会发现博客私人订制味道更浓了。不过,还少一个重要的基础内容:主菜单。快速的解决这个问题。返回 `config.toml` 文件,在末尾插入如下一段: +当你再次启动服务器后,你会发现博客私人订制味道更浓了。不过,还少一个重要的基础内容:主菜单。快速的解决这个问题。返回 `config.toml` 文件,在末尾插入如下一段: ``` [[menu.main]] - name = "Home" #Name in the navigation bar - weight = 10 #The larger the weight, the more on the right this item will be - url = "/" #URL address - [[menu.main]] - name = "Posts" - weight = 20 - url = "/posts/" - ``` + name = "Home" #Name in the navigation bar + weight = 10 #The larger the weight, the more on the right this item will be + url = "/" #URL address +[[menu.main]] + name = "Posts" + weight = 20 + url = "/posts/" +``` - 上面这段代码添加了 `Home` 和 `Posts` 到主菜单中。你还需要一个 `About` 页面。这次是创建一个 `.md` 文件,而不是编辑 `config.toml` 文件: +上面这段代码添加了 `Home` 和 `Posts` 到主菜单中。你还需要一个 `About` 页面。这次是创建一个 `.md` 文件,而不是编辑 `config.toml` 文件: - 1. 创建 `about.md` 文件:`hugo new about.md` 。注意它是 `about.md`,不是 `posts/about.md`。该页面不是博客提交内容,所以你不想它显示到博客内容提交当中吧。 - - 2. 用文本编辑器打开该文件,输入如下一段: - +1. 创建 `about.md` 文件:`hugo new about.md` 。注意它是 `about.md`,不是 `posts/about.md`。该页面不是博客提交内容,所以你不想它显示到博客内容提交当中吧。 +2. 用文本编辑器打开该文件,输入如下一段: + ``` +++ - title = "About" - date = 2018-03-03T13:50:49+01:00 - menu = "main" #Display this page on the nav menu - weight = "30" #Right-most nav item - meta = "false" #Do not display tags or categories - +++ - > Waves are the practice of the water. Shunryu Suzuki - - ``` - - 当你启动你的服务器并输入:`http://localhost:1313/`,你将会看到你的博客。(访问我 Gihub 主页上的 [例子][6] )如果你想让文章的菜单栏和 Github 相似,给 `themes/kiera/static/css/styles.css` 打上这个 [补丁][7]。 - +title = "About" +date = 2018-03-03T13:50:49+01:00 +menu = "main" #Display this page on the nav menu +weight = "30" #Right-most nav item +meta = "false" #Do not display tags or categories ++++ +> Waves are the practice of the water. Shunryu Suzuki +``` + +当你启动你的服务器并输入:`http://localhost:1313/`,你将会看到你的博客。(访问我 Gihub 主页上的 [例子][6] )如果你想让文章的菜单栏和 Github 相似,给 `themes/kiera/static/css/styles.css` 打上这个 [补丁][7]。 + -------------------------------------------------------------------------------- via: https://opensource.com/article/18/3/start-blog-30-minutes-hugo -作者:[Marek Czernek][a] - -译者:[jrg](https://github.com/jrglinux) - -校对:[校对者ID](https://github.com/校对者ID) +作者:[Marek Czernek][a] 
译者:[jrg](https://github.com/jrglinux) 
校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:https://opensource.com/users/mczernek - [1]:https://gohugo.io/ - [2]:https://github.com/gohugoio/hugo/releases - [3]:https://gohugo.io/getting-started/installing/ - [4]:https://themes.gohugo.io/ - [5]:https://github.com/avianto/hugo-kiera - [6]:https://m-czernek.github.io/awesome-blog/ - [7]:https://github.com/avianto/hugo-kiera/pull/18/files From 91ba4a1a4e21569a207d790e899be1a857c8c3e2 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 25 Sep 2018 22:38:49 +0800 Subject: [PATCH 413/455] PUB:20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md @jrglinux https://linux.cn/article-10048-1.html --- ...30 minutes with Hugo, a static site generator written in Go.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md (100%) diff --git a/translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md b/published/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md similarity index 100% rename from translated/tech/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md rename to published/20180326 Start a blog in 30 minutes with Hugo, a static site generator written in Go.md From 244a857e0f0f69d469a8ff6b1f96b6a6ca0f0a5e Mon Sep 17 00:00:00 2001 From: GraveAccent Date: Tue, 25 Sep 2018 23:25:55 +0800 Subject: [PATCH 414/455] =?UTF-8?q?GraveAccent=E7=BF=BB=E8=AF=91=E5=AE=8C?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Rendering in React using Ternaries and.md | 206 ------------------ ... Rendering in React using Ternaries and.md | 205 +++++++++++++++++ 2 files changed, 205 insertions(+), 206 deletions(-) delete mode 100644 sources/tech/20180201 Conditional Rendering in React using Ternaries and.md create mode 100644 translated/tech/20180201 Conditional Rendering in React using Ternaries and.md diff --git a/sources/tech/20180201 Conditional Rendering in React using Ternaries and.md b/sources/tech/20180201 Conditional Rendering in React using Ternaries and.md deleted file mode 100644 index b99c787e31..0000000000 --- a/sources/tech/20180201 Conditional Rendering in React using Ternaries and.md +++ /dev/null @@ -1,206 +0,0 @@ -GraveAccent 翻译中 Conditional Rendering in React using Ternaries and Logical AND -============================================================ - - -![](https://cdn-images-1.medium.com/max/2000/1*eASRJrCIVgsy5VbNMAzD9w.jpeg) -Photo by [Brendan Church][1] on [Unsplash][2] - -There are several ways that your React component can decide what to render. You can use the traditional `if` statement or the `switch` statement. In this article, we’ll explore a few alternatives. But be warned that some come with their own gotchas, if you’re not careful. - -### Ternary vs if/else - -Let’s say we have a component that is passed a `name` prop. If the string is non-empty, we display a greeting. Otherwise we tell the user they need to sign in. - -Here’s a Stateless Function Component (SFC) that does just that. - -``` -const MyComponent = ({ name }) => { - if (name) { - return ( -
- Hello {name} -
- ); - } - return ( -
- Please sign in -
- ); -}; -``` - -Pretty straightforward. But we can do better. Here’s the same component written using a conditional ternary operator. - -``` -const MyComponent = ({ name }) => ( -
- {name ? `Hello ${name}` : 'Please sign in'} -
-); -``` - -Notice how concise this code is compared to the example above. - -A few things to note. Because we are using the single statement form of the arrow function, the `return` statement is implied. Also, using a ternary allowed us to DRY up the duplicate `
` markup. 🎉 - -### Ternary vs Logical AND - -As you can see, ternaries are wonderful for `if/else` conditions. But what about simple `if` conditions? - -Let’s look at another example. If `isPro` (a boolean) is `true`, we are to display a trophy emoji. We are also to render the number of stars (if not zero). We could go about it like this. - -``` -const MyComponent = ({ name, isPro, stars}) => ( -
-
- Hello {name} - {isPro ? '🏆' : null} -
- {stars ? ( -
- Stars:{'⭐️'.repeat(stars)} -
- ) : null} -
-); -``` - -But notice the “else” conditions return `null`. This is becasue a ternary expects an else condition. - -For simple `if` conditions, we could use something a little more fitting: the logical AND operator. Here’s the same code written using a logical AND. - -``` -const MyComponent = ({ name, isPro, stars}) => ( -
-
- Hello {name} - {isPro && '🏆'} -
- {stars && ( -
- Stars:{'⭐️'.repeat(stars)} -
- )} -
-); -``` - -Not too different, but notice how we eliminated the `: null` (i.e. else condition) at the end of each ternary. Everything should render just like it did before. - - -Hey! What gives with John? There is a `0` when nothing should be rendered. That’s the gotcha that I was referring to above. Here’s why. - -[According to MDN][3], a Logical AND (i.e. `&&`): - -> `expr1 && expr2` - -> Returns `expr1` if it can be converted to `false`; otherwise, returns `expr2`. Thus, when used with Boolean values, `&&` returns `true` if both operands are true; otherwise, returns `false`. - -OK, before you start pulling your hair out, let me break it down for you. - -In our case, `expr1` is the variable `stars`, which has a value of `0`. Because zero is falsey, `0` is returned and rendered. See, that wasn’t too bad. - -I would write this simply. - -> If `expr1` is falsey, returns `expr1`, else returns `expr2`. - -So, when using a logical AND with non-boolean values, we must make the falsey value return something that React won’t render. Say, like a value of `false`. - -There are a few ways that we can accomplish this. Let’s try this instead. - -``` -{!!stars && ( -
- {'⭐️'.repeat(stars)} -
-)} -``` - -Notice the double bang operator (i.e. `!!`) in front of `stars`. (Well, actually there is no “double bang operator”. We’re just using the bang operator twice.) - -The first bang operator will coerce the value of `stars` into a boolean and then perform a NOT operation. If `stars` is `0`, then `!stars` will produce `true`. - -Then we perform a second NOT operation, so if `stars` is 0, `!!stars` would produce `false`. Exactly what we want. - -If you’re not a fan of `!!`, you can also force a boolean like this (which I find a little wordy). - -``` -{Boolean(stars) && ( -``` - -Or simply give a comparator that results in a boolean value (which some might say is even more semantic). - -``` -{stars > 0 && ( -``` - -#### A word on strings - -Empty string values suffer the same issue as numbers. But because a rendered empty string is invisible, it’s not a problem that you will likely have to deal with, or will even notice. However, if you are a perfectionist and don’t want an empty string on your DOM, you should take similar precautions as we did for numbers above. - -### Another solution - -A possible solution, and one that scales to other variables in the future, would be to create a separate `shouldRenderStars` variable. Then you are dealing with boolean values in your logical AND. - -``` -const shouldRenderStars = stars > 0; -``` - -``` -return ( -
- {shouldRenderStars && ( -
- {'⭐️'.repeat(stars)} -
- )} -
-); -``` - -Then, if in the future, the business rule is that you also need to be logged in, own a dog, and drink light beer, you could change how `shouldRenderStars` is computed, and what is returned would remain unchanged. You could also place this logic elsewhere where it’s testable and keep the rendering explicit. - -``` -const shouldRenderStars = - stars > 0 && loggedIn && pet === 'dog' && beerPref === 'light`; -``` - -``` -return ( -
- {shouldRenderStars && ( -
- {'⭐️'.repeat(stars)} -
- )} -
-); -``` - -### Conclusion - -I’m of the opinion that you should make best use of the language. And for JavaScript, this means using conditional ternary operators for `if/else`conditions and logical AND operators for simple `if` conditions. - -While we could just retreat back to our safe comfy place where we use the ternary operator everywhere, you now possess the knowledge and power to go forth AND prosper. - --------------------------------------------------------------------------------- - -作者简介: - -Managing Editor at the American Express Engineering Blog http://aexp.io and Director of Engineering @AmericanExpress. MyViews !== ThoseOfMyEmployer. - ----------------- - -via: https://medium.freecodecamp.org/conditional-rendering-in-react-using-ternaries-and-logical-and-7807f53b6935 - -作者:[Donavon West][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/@donavon -[1]:https://unsplash.com/photos/pKeF6Tt3c08?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText -[2]:https://unsplash.com/search/photos/road-sign?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText -[3]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators diff --git a/translated/tech/20180201 Conditional Rendering in React using Ternaries and.md b/translated/tech/20180201 Conditional Rendering in React using Ternaries and.md new file mode 100644 index 0000000000..aa7ba0017e --- /dev/null +++ b/translated/tech/20180201 Conditional Rendering in React using Ternaries and.md @@ -0,0 +1,205 @@ +在 React 条件渲染中使用三元表达式和 “&&” +============================================================ + +![](https://cdn-images-1.medium.com/max/2000/1*eASRJrCIVgsy5VbNMAzD9w.jpeg) +Photo by [Brendan Church][1] on [Unsplash][2] + +React 组件可以通过多种方式决定渲染内容。你可以使用传统的 if 语句或 switch 语句。在本文中,我们将探讨一些替代方案。但要注意,如果你不小心,有些方案会带来自己的陷阱。 + +### 三元表达式 vs if/else + +假设我们有一个组件被传进来一个 `name` prop。 如果这个字符串非空,我们会显示一个问候语。否则,我们会告诉用户他们需要登录。 + +这是一个只实现了如上功能的无状态函数式组件。 + +``` +const MyComponent = ({ name }) => { + if (name) { + return ( +
+ Hello {name} +
+ ); + } + return ( +
+ Please sign in +
+ ); +}; +``` + +这个很简单但是我们可以做得更好。这是使用三元运算符编写的相同组件。 + +``` +const MyComponent = ({ name }) => ( +
+ {name ? `Hello ${name}` : 'Please sign in'} +
+); +``` + +请注意这段代码与上面的例子相比是多么简洁。 + +有几点需要注意。因为我们使用了箭头函数的单语句形式,所以隐含了return语句。另外,使用三元运算符允许我们省略掉重复的 `
` 标记。🎉 + +### 三元表达式 vs && + +正如您所看到的,三元表达式用于表达 if/else 条件式非常好。但是对于简单的 if 条件式怎么样呢? + +让我们看另一个例子。如果 isPro(一个布尔值)为真,我们将显示一个奖杯表情符号。我们也要渲染星星的数量(如果不是0)。我们可以这样写。 + +``` +const MyComponent = ({ name, isPro, stars}) => ( +
+
+ Hello {name} + {isPro ? '🏆' : null} +
+ {stars ? ( +
+ Stars:{'⭐️'.repeat(stars)} +
+ ) : null} +
+); +``` + +请注意 “else” 条件返回 null 。 这是因为三元表达式要有"否则"条件。 + +对于简单的 “if” 条件式,我们可以使用更合适的东西:&& 运算符。这是使用 “&&” 编写的相同代码。 + +``` +const MyComponent = ({ name, isPro, stars}) => ( +
+
+ Hello {name} + {isPro && '🏆'} +
+ {stars && ( +
+ Stars:{'⭐️'.repeat(stars)} +
+ )} +
+); +``` + +没有太多区别,但是注意我们消除了每个三元表达式最后面的 `: null` (else 条件式)。一切都应该像以前一样渲染。 + + +嘿!约翰得到了什么?当什么都不应该渲染时,只有一个0。这就是我上面提到的陷阱。这里有解释为什么。 + +[根据 MDN][3],一个逻辑运算符“和”(也就是`&&`): + +> `expr1 && expr2` + +> 如果 `expr1` 可以被转换成 `false` ,返回 `expr1`;否则返回 `expr2`。 如此,当与布尔值一起使用时,如果两个操作数都是 true,`&&` 返回 `true` ;否则,返回 `false`。 + +好的,在你开始拔头发之前,让我为你解释它。 + +在我们这个例子里, `expr1` 是变量 `stars`,它的值是 `0`,因为0是 falsey 的值, `0` 会被返回和渲染。看,这还不算太坏。 + +我会简单地这么写。 + +> 如果 `expr1` 是 falsey,返回 `expr1` ,否则返回 `expr2` + +所以,当对非布尔值使用 “&&” 时,我们必须让 falsy 的值返回 React 无法渲染的东西,比如说,`false` 这个值。 + +我们可以通过几种方式实现这一目标。让我们试试吧。 + +``` +{!!stars && ( +
+ {'⭐️'.repeat(stars)} +
+)} +``` + +注意 `stars` 前的双感叹操作符( `!!`)(呃,其实没有双感叹操作符。我们只是用了感叹操作符两次)。 + +第一个感叹操作符会强迫 `stars` 的值变成布尔值并且进行一次“非”操作。如果 `stars` 是 `0` ,那么 `!stars` 会 是 `true`。 + +然后我们执行第二个`非`操作,所以如果 `stars` 是0,`!!stars` 会是 `false`。正好是我们想要的。 + +如果你不喜欢 `!!`,那么你也可以强制转换出一个布尔数比如这样(这种方式我觉得有点冗长)。 + +``` +{Boolean(stars) && ( +``` + +或者只是用比较符产生一个布尔值(有些人会说这样甚至更加语义化)。 + +``` +{stars > 0 && ( +``` + +#### 关于字符串 + +空字符串与数字有一样的毛病。但是因为渲染后的空字符串是不可见的,所以这不是那种你很可能会去处理的难题,甚至可能不会注意到它。然而,如果你是完美主义者并且不希望DOM上有空字符串,你应采取我们上面对数字采取的预防措施。 + +### 其它解决方案 + +一种可能的将来可扩展到其他变量的解决方案,是创建一个单独的 `shouldRenderStars` 变量。然后你用“&&”处理布尔值。 + +``` +const shouldRenderStars = stars > 0; +``` + +``` +return ( +
+ {shouldRenderStars && ( +
+ {'⭐️'.repeat(stars)} +
+ )} +
+); +``` + +之后,在将来,如果业务规则要求你还需要已登录,拥有一条狗以及喝淡啤酒,你可以改变 `shouldRenderStars` 的得出方式,而返回的内容保持不变。你还可以把这个逻辑放在其它可测试的地方,并且保持渲染明晰。 + +``` +const shouldRenderStars = + stars > 0 && loggedIn && pet === 'dog' && beerPref === 'light`; +``` + +``` +return ( +
+ {shouldRenderStars && ( +
+ {'⭐️'.repeat(stars)} +
+ )} +
+); +``` + +### 结论 + +我认为你应该充分利用这种语言。对于 JavaScript,这意味着为 `if/else` 条件式使用三元表达式,以及为 `if` 条件式使用 `&&` 操作符。 + +我们可以回到每处都使用三元运算符的舒适区,但你现在消化了这些知识和力量,可以继续前进 && 取得成功了。 + +-------------------------------------------------------------------------------- + +作者简介: + +美国运通工程博客的执行编辑 http://aexp.io 以及 @AmericanExpress 的工程总监。MyViews !== ThoseOfMyEmployer. + +---------------- + +via: https://medium.freecodecamp.org/conditional-rendering-in-react-using-ternaries-and-logical-and-7807f53b6935 + +作者:[Donavon West][a] +译者:[GraveAccent](https://github.com/GraveAccent) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://medium.freecodecamp.org/@donavon +[1]:https://unsplash.com/photos/pKeF6Tt3c08?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[2]:https://unsplash.com/search/photos/road-sign?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText +[3]:https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Logical_Operators From bb41fabb48c81c9f48faacdb09519cb1cc94c037 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 26 Sep 2018 08:57:21 +0800 Subject: [PATCH 415/455] translated --- ...age Manager To Use IPv4 In Ubuntu 16.04.md | 49 ------------------- ...age Manager To Use IPv4 In Ubuntu 16.04.md | 47 ++++++++++++++++++ 2 files changed, 47 insertions(+), 49 deletions(-) delete mode 100644 sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md create mode 100644 translated/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md diff --git a/sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md b/sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md deleted file mode 100644 index f81d944570..0000000000 --- a/sources/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md +++ /dev/null @@ -1,49 +0,0 @@ -translating---geekpi - -How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04 -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/ipv4-720x340.png) - -**APT** , short or **A** dvanced **P** ackage **T** ool, is the default package manager for Debian-based systems. Using APT, we can install, update, upgrade and remove applications from the system. Lately, I have been facing a strange error. Whenever I try update my Ubuntu 16.04 box, I get this error – **“0% [Connecting to in.archive.ubuntu.com (2001:67c:1560:8001::14)]”** and the update process gets stuck for a long time. My Internet connection is working well and I can able to ping all websites including Ubuntu official site. After a couple Google searches, I realized that sometimes the Ubuntu mirrors are not reachable over IPv6. This problem is solved after I force APT package manager to use IPv4 in place of IPv6 to access Ubuntu mirrors while updating the system. If you ever encountered with this error, you can solve it as described below. - -### Force APT Package Manager To Use IPv4 In Ubuntu 16.04 - -To force APT to use IPv4 in place of IPv6 while updating and upgrading your Ubuntu 16.04 LTS systems, simply use the following commands: - -``` -$ sudo apt-get -o Acquire::ForceIPv4=true update - -$ sudo apt-get -o Acquire::ForceIPv4=true upgrade -``` - -Voila! This time update process run and completed quickly. - -You can also make this persistent for all **apt-get** transactions in the future by adding the following line in **/etc/apt/apt.conf.d/99force-ipv4** file using command: - -``` -$ echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4 -``` - -**Disclaimer:** - -I don’t know if anyone is having this issue lately, but I kept getting this error today at least four to five times in my Ubuntu 16.04 LTS virtual machine and I solved it as described above. I am not sure that it is the recommended solution. Go through Ubuntu forums and make sure this method is legitimate. Since mine is just a VM which I use it only for testing and learning purposes, I don’t mind about the authenticity of this method. Use it on your own risk. - -Hope this helps. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-force-apt-package-manager-to-use-ipv4-in-ubuntu-16-04/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/sk/ diff --git a/translated/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md b/translated/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md new file mode 100644 index 0000000000..02bc39addc --- /dev/null +++ b/translated/tech/20180918 How To Force APT Package Manager To Use IPv4 In Ubuntu 16.04.md @@ -0,0 +1,47 @@ +如何在 Ubuntu 16.04 强制 APT 包管理器使用 IPv4 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/ipv4-720x340.png) + +**APT**, 是 **A** dvanced **P** ackage **T** ool 的缩写,是基于 Debian 的系统的默认包管理器。我们可以使用 APT 安装、更新、升级和删除应用程序。最近,我一直遇到一个奇怪的错误。每当我尝试更新我的 Ubuntu 16.04 时,我都会收到此错误 - **“0% [Connecting to in.archive.ubuntu.com (2001:67c:1560:8001::14)]”** ,同时更新流程会卡住很长时间。我的网络连接没问题,我可以 ping 通所有网站,包括 Ubuntu 官方网站。在搜索了一番谷歌后,我意识到 Ubuntu 镜像有时无法通过 IPv6 访问。在我强制将 APT 包管理器在更新系统时使用 IPv4 代替 IPv6 访问 Ubuntu 镜像后,此问题得以解决。如果你遇到过此错误,可以按照以下说明解决。 + +### 强制 APT 包管理器在 Ubuntu 16.04 中使用 IPv4 + +要在更新和升级 Ubuntu 16.04 LTS 系统时强制 APT 使用 IPv4 代替 IPv6,只需使用以下命令: + +``` +$ sudo apt-get -o Acquire::ForceIPv4=true update + +$ sudo apt-get -o Acquire::ForceIPv4=true upgrade +``` + +瞧!这次更新很快就完成了。 + +你还可以使用以下命令在 **/etc/apt/apt.conf.d/99force-ipv4** 中添加以下行,以便将来对所有 **apt-get** 事务保持持久性: + +``` +$ echo 'Acquire::ForceIPv4 "true";' | sudo tee /etc/apt/apt.conf.d/99force-ipv4 +``` + +**免责声明:** + +我不知道最近是否有人遇到这个问题,但我今天在我的 Ubuntu 16.04 LTS 虚拟机中遇到了至少四五次这样的错误,我按照上面的说法解决了这个问题。我不确定这是推荐的解决方案。请浏览 Ubuntu 论坛来确保此方法合法。由于我只是一个 VM,我只将它用于测试和学习目的,我不介意这种方法的真实性。请自行承担使用风险。 + +希望这有帮助。还有更多的好东西。敬请关注! + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-force-apt-package-manager-to-use-ipv4-in-ubuntu-16-04/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ From 557ab76142c14188ffce06d086757f49eff391b8 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 26 Sep 2018 09:03:16 +0800 Subject: [PATCH 416/455] translating --- ...Your Linux Desktop With browser-mpris2 (Chrome Extension).md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180816 Add YouTube Player Controls To Your Linux Desktop With browser-mpris2 (Chrome Extension).md b/sources/tech/20180816 Add YouTube Player Controls To Your Linux Desktop With browser-mpris2 (Chrome Extension).md index 1a0f1e9dbe..acc8f56e0c 100644 --- a/sources/tech/20180816 Add YouTube Player Controls To Your Linux Desktop With browser-mpris2 (Chrome Extension).md +++ b/sources/tech/20180816 Add YouTube Player Controls To Your Linux Desktop With browser-mpris2 (Chrome Extension).md @@ -1,3 +1,5 @@ +translating---geekpi + Add YouTube Player Controls To Your Linux Desktop With browser-mpris2 (Chrome Extension) ====== A Unity feature that I miss (it only actually worked for a short while though) is automatically getting player controls in the Ubuntu Sound Indicator when visiting a website like YouTube in a web browser, so you could pause or stop the video directly from the top bar, as well as see the video / song information and a preview. From db69db3e9257d0ff232615c8cb6d5691373f43ee Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 26 Sep 2018 09:09:53 +0800 Subject: [PATCH 417/455] PRF:20180725 How do private keys work in PKI and cryptography.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @pinewall 翻译的棒极了 --- ...ivate keys work in PKI and cryptography.md | 31 ++++++++++--------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/translated/tech/20180725 How do private keys work in PKI and cryptography.md b/translated/tech/20180725 How do private keys work in PKI and cryptography.md index 6c42531396..e52e7282a7 100644 --- a/translated/tech/20180725 How do private keys work in PKI and cryptography.md +++ b/translated/tech/20180725 How do private keys work in PKI and cryptography.md @@ -1,47 +1,48 @@ -PKI 和 密码学中的私钥的角色 +公钥基础设施和密码学中的私钥的角色 ====== +> 了解如何验证某人所声称的身份。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security_privacy_lock.png?itok=ZWjrpFzx) -在[上一篇文章][1]中,我们概述了密码学并讨论了密码学的核心概念:保密性confidentiality (让数据保密),完整性integrity (防止数据被篡改)和身份认证authentication (确认数据源的身份identity)。由于要在存在各种身份混乱的现实世界中完成身份认证,人们逐渐建立起一个复杂的技术生态体系technological ecosystem,用于证明某人就是其声称的那个人。在本文中,我们将大致介绍这些体系是如何工作的。 +在[上一篇文章][1]中,我们概述了密码学并讨论了密码学的核心概念:保密性confidentiality (让数据保密)、完整性integrity (防止数据被篡改)和身份认证authentication (确认数据源的身份identity)。由于要在存在各种身份混乱的现实世界中完成身份认证,人们逐渐建立起一个复杂的技术生态体系technological ecosystem,用于证明某人就是其声称的那个人。在本文中,我们将大致介绍这些体系是如何工作的。 -### 公钥密码学及数字签名快速回顾 +### 快速回顾公钥密码学及数字签名 互联网世界中的身份认证依赖于公钥密码学,其中密钥分为两部分:拥有者需要保密的私钥和可以对外公开的公钥。经过公钥加密过的数据,只能用对应的私钥解密。举个例子,对于希望与[记者][2]建立联系的举报人来说,这个特性非常有用。但就本文介绍的内容而言,私钥更重要的用途是与一个消息一起创建一个数字签名digital signature,用于提供完整性和身份认证。 -在实际应用中,我们签名的并不是真实消息,而是经过密码学哈希函数cryptographic hash function处理过的消息摘要digest。要发送一个包含源代码的压缩文件,发送者会对该压缩文件的 256 比特长度的 [SHA-256][3] 摘要而不是文件本身进行签名,然后用明文发送该压缩包(和签名)。接收者会独立计算收到文件的 SHA-256 摘要,然后结合该摘要、收到的签名及发送者的公钥,使用签名验证算法进行验证。验证过程取决于加密算法,加密算法不同,验证过程也相应不同;而且,由于不断发现微妙的触发条件,签名验证[漏洞][4]依然[层出不穷][5]。如果签名验证通过,说明文件在传输过程中没有被篡改而且来自于发送者,这是因为只有发送者拥有创建签名所需的私钥。 +在实际应用中,我们签名的并不是真实消息,而是经过密码学哈希函数cryptographic hash function处理过的消息摘要digest。要发送一个包含源代码的压缩文件,发送者会对该压缩文件的 256 比特长度的 [SHA-256][3] 摘要进行签名,而不是文件本身进行签名,然后用明文发送该压缩包(和签名)。接收者会独立计算收到文件的 SHA-256 摘要,然后结合该摘要、收到的签名及发送者的公钥,使用签名验证算法进行验证。验证过程取决于加密算法,加密算法不同,验证过程也相应不同;而且,很微妙的是签名验证[漏洞][4]依然[层出不穷][5]。如果签名验证通过,说明文件在传输过程中没有被篡改而且来自于发送者,这是因为只有发送者拥有创建签名所需的私钥。 ### 方案中缺失的环节 上述方案中缺失了一个重要的环节:我们从哪里获得发送者的公钥?发送者可以将公钥与消息一起发送,但除了发送者的自我宣称,我们无法核验其身份。假设你是一名银行柜员,一名顾客走过来向你说,“你好,我是 Jane Doe,我要取一笔钱”。当你要求其证明身份时,她指着衬衫上贴着的姓名标签说道,“看,Jane Doe!”。如果我是这个柜员,我会礼貌的拒绝她的请求。 -如果你认识发送者,你们可以私下见面并彼此交换公钥。如果你并不认识发送者,你们可以私下见面,检查对方的证件,确认真实性后接受对方的公钥。为提高流程效率,你可以举办聚会并邀请一堆人,检查他们的证件,然后接受他们的公钥。此外,如果你认识并信任 Jane Doe (尽管她在银行的表现比较反常),Jane 可以参加聚会,收集大家的公钥然后交给你。事实上,Jane 可以使用她自己的私钥对这些公钥(及对应的身份信息)进行签名,进而你可以从一个[线上密钥库][7]获取公钥(及对应的身份信息)并信任已被 Jane 签名的那部分。如果一个人的公钥被很多你信任的人(即使你并不认识他们)签名,你也可能选择信任这个人。按照这种方式,你可以建立一个[信任网络Web of Trust][8]。 +如果你认识发送者,你们可以私下见面并彼此交换公钥。如果你并不认识发送者,你们可以私下见面,检查对方的证件,确认真实性后接受对方的公钥。为提高流程效率,你可以举办[聚会][6]并邀请一堆人,检查他们的证件,然后接受他们的公钥。此外,如果你认识并信任 Jane Doe(尽管她在银行的表现比较反常),Jane 可以参加聚会,收集大家的公钥然后交给你。事实上,Jane 可以使用她自己的私钥对这些公钥(及对应的身份信息)进行签名,进而你可以从一个[线上密钥库][7]获取公钥(及对应的身份信息)并信任已被 Jane 签名的那部分。如果一个人的公钥被很多你信任的人(即使你并不认识他们)签名,你也可能选择信任这个人。按照这种方式,你可以建立一个[信任网络][8]Web of Trust。 -但事情也变得更加复杂:我们需要建立一种标准的编码机制,可以将公钥和其对应的身份信息编码成一个数字捆绑digital bundle,以便我们进一步进行签名。更准确的说,这类数字捆绑被称为证书cerificates。我们还需要可以创建、使用和管理这些证书的工具链。满足诸如此类的各种需求的方案构成了公钥基础设施public key infrastructure, PKI。 +但事情也变得更加复杂:我们需要建立一种标准的编码机制,可以将公钥和其对应的身份信息编码成一个数字捆绑digital bundle,以便我们进一步进行签名。更准确的说,这类数字捆绑被称为证书cerificate。我们还需要可以创建、使用和管理这些证书的工具链。满足诸如此类的各种需求的方案构成了公钥基础设施public key infrastructure(PKI)。 ### 比信任网络更进一步 -你可以用人际关系网类比信任网络。如果人们之间广泛互信,可以很容易找到(两个人之间的)一条短信任链short path of trust:不妨以社交圈为例。基于 [GPG][9] 加密的邮件依赖于信任网络,([理论上][10])只适用于与少量朋友、家庭或同事进行联系的情形。 +你可以用人际关系网类比信任网络。如果人们之间广泛互信,可以很容易找到(两个人之间的)一条短信任链short path of trust:就像一个社交圈。基于 [GPG][9] 加密的邮件依赖于信任网络,([理论上][10])只适用于与少量朋友、家庭或同事进行联系的情形。 (LCTT 译注:作者提到的“短信任链”应该是暗示“六度空间理论”,即任意两个陌生人之间所间隔的人一般不会超过 6 个。对 GPG 的唱衰,一方面是因为密钥管理的复杂性没有改善,另一方面 Yahoo 和 Google 都提出了更便利的端到端加密方案。) -在实际应用中,信任网络有一些["硬伤"significant problems][11],主要是在可扩展性方面。当网络规模逐渐增大或者人们之间的连接逐渐降低时,信任网络就会慢慢失效。如果信任链逐渐变长,信任链中某人有意或无意误签证书的几率也会逐渐增大。如果信任链不存在,你不得不自己创建一条信任链;具体而言,你与其它组织建立联系,验证它们的密钥符合你的要求。考虑下面的场景,你和你的朋友要访问一个从未使用过的在线商店。你首先需要核验网站所用的公钥属于其对应的公司而不是伪造者,进而建立安全通信信道,最后完成下订单操作。核验公钥的方法包括去实体店、打电话等,都比较麻烦。这样会导致在线购物变得不那么便利(或者说不那么安全,毕竟很多人会图省事,不去核验密钥)。 +在实际应用中,信任网络有一些“[硬伤][11]significant problems”,主要是在可扩展性方面。当网络规模逐渐增大或者人们之间的连接较少时,信任网络就会慢慢失效。如果信任链逐渐变长,信任链中某人有意或无意误签证书的几率也会逐渐增大。如果信任链不存在,你不得不自己创建一条信任链,与其它组织建立联系,验证它们的密钥以符合你的要求。考虑下面的场景,你和你的朋友要访问一个从未使用过的在线商店。你首先需要核验网站所用的公钥属于其对应的公司而不是伪造者,进而建立安全通信信道,最后完成下订单操作。核验公钥的方法包括去实体店、打电话等,都比较麻烦。这样会导致在线购物变得不那么便利(或者说不那么安全,毕竟很多人会图省事,不去核验密钥)。 -如果世界上有那么几个格外值得信任的人,他们专门负责核验和签发网站证书,情况会怎样呢?你可以只信任他们,那么浏览互联网也会变得更加容易。整体来看,这就是当今互联网的工作方式。那些“格外值得信任的人”就是被称为证书颁发机构cerificate authorities, CAs的公司。当网站希望获得公钥签名时,只需向 CA 提交证书签名请求certificate signing request。 +如果世界上有那么几个格外值得信任的人,他们专门负责核验和签发网站证书,情况会怎样呢?你可以只信任他们,那么浏览互联网也会变得更加容易。整体来看,这就是当今互联网的工作方式。那些“格外值得信任的人”就是被称为证书颁发机构cerificate authoritie(CA)的公司。当网站希望获得公钥签名时,只需向 CA 提交证书签名请求certificate signing request(CSR)。 -CSR 类似于包括公钥和身份信息(在本例中,即服务器的主机名)的存根stub证书,但CA 并不会直接对 CSR 本身进行签名。CA 在签名之前会进行一些验证。对于一些证书类型(LCTT 译注:DVDomain Validated 类型),CA 只验证申请者的确是 CSR 中列出主机名对应域名的控制者(例如通过邮件验证,让申请者完成指定的域名解析)。[对于另一些证书类型][12] (LCTT 译注:链接中提到EVExtended Validated 类型,其实还有 OVOrganization Validated 类型),CA 还会检查相关法律文书,例如公司营业执照等。一旦验证完成,CA(一般在申请者付费后)会从 CSR 中取出数据(即公钥和身份信息),使用 CA 自己的私钥进行签名,创建一个(签名)证书并发送给申请者。申请者将该证书部署在网站服务器上,当用户使用 HTTPS (或其它基于 [TLS][13] 加密的协议)与服务器通信时,该证书被分发给用户。 +CSR 类似于包括公钥和身份信息(在本例中,即服务器的主机名)的存根stub证书,但 CA 并不会直接对 CSR 本身进行签名。CA 在签名之前会进行一些验证。对于一些证书类型(LCTT 译注:域名证实Domain Validated(DV) 类型),CA 只验证申请者的确是 CSR 中列出主机名对应域名的控制者(例如通过邮件验证,让申请者完成指定的域名解析)。[对于另一些证书类型][12] (LCTT 译注:链接中提到扩展证实Extended Validated(EV)类型,其实还有 OVOrganization Validated 类型),CA 还会检查相关法律文书,例如公司营业执照等。一旦验证完成,CA(一般在申请者付费后)会从 CSR 中取出数据(即公钥和身份信息),使用 CA 自己的私钥进行签名,创建一个(签名)证书并发送给申请者。申请者将该证书部署在网站服务器上,当用户使用 HTTPS (或其它基于 [TLS][13] 加密的协议)与服务器通信时,该证书被分发给用户。 -当用户访问该网站时,浏览器获取该证书,接着检查证书中的主机名是否与当前正在连接的网站一致(下文会详细说明),核验 CA 签名有效性。如果其中一步验证不通过,浏览器会给出安全警告并切断与网站的连接。反之,如果验证通过,浏览器会使用证书中的公钥核验服务器发送的签名信息,确认该服务器持有该证书的私钥。有几种算法用于协商后续通信用到的共享密钥shared secret key,其中一种也用到了服务器发送的签名信息。密钥交换Key exchange算法不在本文的讨论范围,可以参考这个[视频][14],其中仔细说明了一种密钥交换算法。 +当用户访问该网站时,浏览器获取该证书,接着检查证书中的主机名是否与当前正在连接的网站一致(下文会详细说明),核验 CA 签名有效性。如果其中一步验证不通过,浏览器会给出安全警告并切断与网站的连接。反之,如果验证通过,浏览器会使用证书中的公钥来核验该服务器发送的签名信息,确认该服务器持有该证书的私钥。有几种算法用于协商后续通信用到的共享密钥shared secret key,其中一种也用到了服务器发送的签名信息。密钥交换key exchange算法不在本文的讨论范围,可以参考这个[视频][14],其中仔细说明了一种密钥交换算法。 ### 建立信任 你可能会问,“如果 CA 使用其私钥对证书进行签名,也就意味着我们需要使用 CA 的公钥验证证书。那么 CA 的公钥从何而来,谁对其进行签名呢?” 答案是 CA 对自己签名!可以使用证书公钥对应的私钥,对证书本身进行签名!这类签名证书被称为是自签名的self-signed;在 PKI 体系下,这意味着对你说“相信我”。(为了表达方便,人们通常说用证书进行了签名,虽然真正用于签名的私钥并不在证书中。) -通过遵守[浏览器][15]和[操作系统][16]供应商建立的规则,CA 表明自己足够可靠并寻求加入到浏览器或操作系统预装的一组自签名证书中。这些证书被称为“信任锚trust anchors”或 CA 根证书root CA certificates,被存储在根证书区,我们约定implicitly信任该区域内的证书。 +通过遵守[浏览器][15]和[操作系统][16]供应商建立的规则,CA 表明自己足够可靠并寻求加入到浏览器或操作系统预装的一组自签名证书中。这些证书被称为“信任锚trust anchor”或 CA 根证书root CA certificate,被存储在根证书区,我们约定implicitly信任该区域内的证书。 CA 也可以签发一种特殊的证书,该证书自身可以作为 CA。在这种情况下,它们可以生成一个证书链。要核验证书链,需要从“信任锚”(也就是 CA 根证书)开始,使用当前证书的公钥核验下一层证书的签名(或其它一些信息)。按照这个方式依次核验下一层证书,直到证书链底部。如果整个核验过程没有问题,信任链也建立完成。当向 CA 付费为网站签发证书时,实际购买的是将证书放置在证书链下的权利。CA 将卖出的证书标记为“不可签发子证书”,这样它们可以在适当的长度终止信任链(防止其继续向下扩展)。 -为何要使用长度超过 2 的信任链呢?毕竟网站的证书可以直接被 CA 根证书签名。在实际应用中,很多因素促使 CA 创建中间 CA 证书intermediate CA certificate,最主要是为了方便。由于价值连城,CA 根证书对应的私钥通常被存放在特定的设备中,一种需要多人解锁的硬件安全模块hardware security module, HSM,该模块完全离线并被保管在配备监控和报警设备的[地下室][18]中。 +为何要使用长度超过 2 的信任链呢?毕竟网站的证书可以直接被 CA 根证书签名。在实际应用中,很多因素促使 CA 创建中间 CA 证书intermediate CA certificate,最主要是为了方便。由于价值连城,CA 根证书对应的私钥通常被存放在特定的设备中,一种需要多人解锁的硬件安全模块hardware security module(HSM),该模块完全离线并被保管在配备监控和报警设备的[地下室][18]中。 CA/浏览器论坛CAB Forum, CA/Browser Forum负责管理 CA,[要求][19]任何与 CA 根证书(LCTT 译注:就像前文提到的那样,这里是指对应的私钥)相关的操作必须由人工完成。设想一下,如果每个证书请求都需要员工将请求内容拷贝到保密介质中、进入地下室、与同事一起解锁 HSM、(使用 CA 根证书对应的私钥)签名证书,最后将签名证书从保密介质中拷贝出来;那么每天为大量网站签发证书是相当繁重乏味的工作。因此,CA 创建内部使用的中间 CA,用于证书签发自动化。 @@ -72,12 +73,12 @@ via: https://opensource.com/article/18/7/private-keys 作者:[Alex Wood][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[pinewall](https://github.com/pinewall) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]:https://opensource.com/users/awood -[1]:https://opensource.com/article/18/5/cryptography-pki +[1]:https://linux.cn/article-9792-1.html [2]:https://theintercept.com/2014/10/28/smuggling-snowden-secrets/ [3]:https://en.wikipedia.org/wiki/SHA-2 [4]:https://www.ietf.org/mail-archive/web/openpgp/current/msg00999.html From 33031b4e014adb372bf439f1293bcf50a1b00f99 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 26 Sep 2018 09:10:24 +0800 Subject: [PATCH 418/455] PUB:20180725 How do private keys work in PKI and cryptography.md @pinewall https://linux.cn/article-10049-1.html --- .../20180725 How do private keys work in PKI and cryptography.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180725 How do private keys work in PKI and cryptography.md (100%) diff --git a/translated/tech/20180725 How do private keys work in PKI and cryptography.md b/published/20180725 How do private keys work in PKI and cryptography.md similarity index 100% rename from translated/tech/20180725 How do private keys work in PKI and cryptography.md rename to published/20180725 How do private keys work in PKI and cryptography.md From 832df53f305c831565142cb9d5b3475713ecde01 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 26 Sep 2018 09:55:09 +0800 Subject: [PATCH 419/455] PRF:20180826 How to capture and analyze packets with tcpdump command on Linux.md @ypingcn --- ...e packets with tcpdump command on Linux.md | 99 +++++++++---------- 1 file changed, 45 insertions(+), 54 deletions(-) diff --git a/translated/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md b/translated/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md index 307aeeb0ec..431bbefe5e 100644 --- a/translated/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md +++ b/translated/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md @@ -1,26 +1,27 @@ 如何在 Linux 上使用 tcpdump 命令捕获和分析数据包 ====== -tcpdump 是一个有名的命令行**数据包分析**工具。我们可以使用 tcpdump 命令捕获实时 TCP/IP 数据包,这些数据包也可以保存到文件中。之后这些捕获的数据包可以通过 tcpdump 命令进行分析。tcpdump 命令在网络级故障排除时变得非常方便。 + +`tcpdump` 是一个有名的命令行**数据包分析**工具。我们可以使用 `tcpdump` 命令捕获实时 TCP/IP 数据包,这些数据包也可以保存到文件中。之后这些捕获的数据包可以通过 `tcpdump` 命令进行分析。`tcpdump` 命令在网络层面进行故障排除时变得非常方便。 ![](https://www.linuxtechi.com/wp-content/uploads/2018/08/tcpdump-command-examples-linux.jpg) -tcpdump 在大多数 Linux 发行版中都能用,对于基于 Debian 的Linux,可以使用 apt 命令安装它 +`tcpdump` 在大多数 Linux 发行版中都能用,对于基于 Debian 的Linux,可以使用 `apt` 命令安装它。 ``` # apt install tcpdump -y ``` -在基于 RPM 的 Linux 操作系统上,可以使用下面的 yum 命令安装 tcpdump +在基于 RPM 的 Linux 操作系统上,可以使用下面的 `yum` 命令安装 `tcpdump`。 ``` # yum install tcpdump -y ``` -当我们在没用任何选项的情况下运行 tcpdump 命令时,它将捕获所有接口的数据包。因此,要停止或取消 tcpdump 命令,请输入 '**ctrl+c**'。在本教程中,我们将使用不同的实例来讨论如何捕获和分析数据包, +当我们在没用任何选项的情况下运行 `tcpdump` 命令时,它将捕获所有接口的数据包。因此,要停止或取消 `tcpdump` 命令,请键入 `ctrl+c`。在本教程中,我们将使用不同的实例来讨论如何捕获和分析数据包。 -### 示例: 1) 从特定接口捕获数据包 +### 示例:1)从特定接口捕获数据包 -当我们在没用任何选项的情况下运行 tcpdump 命令时,它将捕获所有接口上的数据包,因此,要从特定接口捕获数据包,请使用选项 '**-i**',后跟接口名称。 +当我们在没用任何选项的情况下运行 `tcpdump` 命令时,它将捕获所有接口上的数据包,因此,要从特定接口捕获数据包,请使用选项 `-i`,后跟接口名称。 语法: @@ -28,7 +29,7 @@ tcpdump 在大多数 Linux 发行版中都能用,对于基于 Debian 的Linux # tcpdump -i {接口名} ``` -假设我想从接口“enp0s3”捕获数据包 +假设我想从接口 `enp0s3` 捕获数据包。 输出将如下所示, @@ -49,21 +50,21 @@ listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes ``` -### 示例: 2) 从特定接口捕获特定数量数据包 +### 示例:2)从特定接口捕获特定数量数据包 -假设我们想从特定接口(如“enp0s3”)捕获12个数据包,这可以使用选项 '**-c {数量} -I {接口名称}**' 轻松实现 +假设我们想从特定接口(如 `enp0s3`)捕获 12 个数据包,这可以使用选项 `-c {数量} -I {接口名称}` 轻松实现。 ``` root@compute-0-1 ~]# tcpdump -c 12 -i enp0s3 ``` -上面的命令将生成如下所示的输出 +上面的命令将生成如下所示的输出, [![N-Number-Packsets-tcpdump-interface][1]][2] -### 示例: 3) 显示 tcpdump 的所有可用接口 +### 示例:3)显示 tcpdump 的所有可用接口 -使用 '**-D**' 选项显示 tcpdump 命令的所有可用接口, +使用 `-D` 选项显示 `tcpdump` 命令的所有可用接口, ``` [root@compute-0-1 ~]# tcpdump -D @@ -86,11 +87,11 @@ root@compute-0-1 ~]# tcpdump -c 12 -i enp0s3 [[email protected] ~]# ``` -我正在我的一个openstack计算节点上运行tcpdump命令,这就是为什么在输出中你会看到数字接口、标签接口、网桥和vxlan接口 +我正在我的一个 openstack 计算节点上运行 `tcpdump` 命令,这就是为什么在输出中你会看到数字接口、标签接口、网桥和 vxlan 接口 -### 示例: 4) 捕获带有可读时间戳(-tttt 选项)的数据包 +### 示例:4)捕获带有可读时间戳的数据包(`-tttt` 选项) -默认情况下,在tcpdump命令输出中,没有显示可读性好的时间戳,如果您想将可读性好的时间戳与每个捕获的数据包相关联,那么使用 '**-tttt**'选项,示例如下所示, +默认情况下,在 `tcpdump` 命令输出中,不显示可读性好的时间戳,如果您想将可读性好的时间戳与每个捕获的数据包相关联,那么使用 `-tttt` 选项,示例如下所示, ``` [[email protected] ~]# tcpdump -c 8 -tttt -i enp0s3 @@ -108,12 +109,11 @@ listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes 134 packets received by filter 69 packets dropped by kernel [[email protected] ~]# - ``` -### 示例: 5) 捕获数据包并将其保存到文件( -w 选项) +### 示例:5)捕获数据包并将其保存到文件(`-w` 选项) -使用 tcpdump 命令中的 '**-w**' 选项将捕获的 TCP/IP 数据包保存到一个文件中,以便我们可以在将来分析这些数据包以供进一步分析。 +使用 `tcpdump` 命令中的 `-w` 选项将捕获的 TCP/IP 数据包保存到一个文件中,以便我们可以在将来分析这些数据包以供进一步分析。 语法: @@ -121,9 +121,9 @@ listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes # tcpdump -w 文件名.pcap -i {接口名} ``` -注意:文件扩展名必须为 **.pcap** +注意:文件扩展名必须为 `.pcap`。 -假设我要把 '**enp0s3**' 接口捕获到的包保存到文件名为 **enp0s3-26082018.pcap** +假设我要把 `enp0s3` 接口捕获到的包保存到文件名为 `enp0s3-26082018.pcap`。 ``` [root@compute-0-1 ~]# tcpdump -w enp0s3-26082018.pcap -i enp0s3 @@ -140,24 +140,23 @@ tcpdump: listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 b [root@compute-0-1 ~]# ls anaconda-ks.cfg enp0s3-26082018.pcap [root@compute-0-1 ~]# - ``` -捕获并保存大小**大于 N 字节**的数据包 +捕获并保存大小**大于 N 字节**的数据包。 ``` [root@compute-0-1 ~]# tcpdump -w enp0s3-26082018-2.pcap greater 1024 ``` -捕获并保存大小**小于 N 字节**的数据包 +捕获并保存大小**小于 N 字节**的数据包。 ``` [root@compute-0-1 ~]# tcpdump -w enp0s3-26082018-3.pcap less 1024 ``` -### 示例: 6) 从保存的文件中读取数据包( -r 选项) +### 示例:6)从保存的文件中读取数据包(`-r` 选项) -在上面的例子中,我们已经将捕获的数据包保存到文件中,我们可以使用选项 '**-r**' 从文件中读取这些数据包,例子如下所示, +在上面的例子中,我们已经将捕获的数据包保存到文件中,我们可以使用选项 `-r` 从文件中读取这些数据包,例子如下所示, ``` [root@compute-0-1 ~]# tcpdump -r enp0s3-26082018.pcap @@ -183,12 +182,11 @@ p,TS val 81359114 ecr 81350901], length 508 2018-08-25 22:03:17.647502 IP controller0.example.com.amqp > compute-0-1.example.com.57788: Flags [.], ack 1956, win 1432, options [nop,nop,TS val 813 52753 ecr 81359114], length 0 ......................................................................................................................... - ``` -### 示例: 7) 仅捕获特定接口上的 IP 地址数据包( -n 选项) +### 示例:7)仅捕获特定接口上的 IP 地址数据包(`-n` 选项) -使用 tcpdump 命令中的 -n 选项,我们能只捕获特定接口上的 IP 地址数据包,示例如下所示, +使用 `tcpdump` 命令中的 `-n` 选项,我们能只捕获特定接口上的 IP 地址数据包,示例如下所示, ``` [root@compute-0-1 ~]# tcpdump -n -i enp0s3 @@ -211,19 +209,18 @@ listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes 22:22:28.539595 IP 169.144.0.1.39406 > 169.144.0.20.ssh: Flags [.], ack 1572, win 9086, options [nop,nop,TS val 20666614 ecr 82510006], length 0 22:22:28.539760 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 1572:1912, ack 1, win 291, options [nop,nop,TS val 82510007 ecr 20666614], length 340 ......................................................................... - ``` -您还可以使用 tcpdump 命令中的 -c 和 -N 选项捕获 N 个 IP 地址包, +您还可以使用 `tcpdump` 命令中的 `-c` 和 `-N` 选项捕获 N 个 IP 地址包, ``` [root@compute-0-1 ~]# tcpdump -c 25 -n -i enp0s3 ``` -### 示例: 8) 仅捕获特定接口上的TCP数据包 +### 示例:8)仅捕获特定接口上的 TCP 数据包 -在 tcpdump 命令中,我们能使用 '**tcp**' 选项来只捕获TCP数据包, +在 `tcpdump` 命令中,我们能使用 `tcp` 选项来只捕获 TCP 数据包, ``` [root@compute-0-1 ~]# tcpdump -i enp0s3 tcp @@ -241,9 +238,9 @@ listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes ................................................................................................................................................... ``` -### 示例: 9) 从特定接口上的特定端口捕获数据包 +### 示例:9)从特定接口上的特定端口捕获数据包 -使用 tcpdump 命令,我们可以从特定接口 enp0s3 上的特定端口(例如 22 )捕获数据包 +使用 `tcpdump` 命令,我们可以从特定接口 `enp0s3` 上的特定端口(例如 22)捕获数据包。 语法: @@ -262,13 +259,12 @@ listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes 22:54:55.038564 IP 169.144.0.1.39406 > compute-0-1.example.com.ssh: Flags [.], ack 940, win 9177, options [nop,nop,TS val 21153238 ecr 84456505], length 0 22:54:55.038708 IP compute-0-1.example.com.ssh > 169.144.0.1.39406: Flags [P.], seq 940:1304, ack 1, win 291, options [nop,nop,TS val 84456506 ecr 21153238], length 364 ............................................................................................................................ -[root@compute-0-1 ~]# ``` -### 示例: 10) 在特定接口上捕获来自特定来源 IP 的数据包 +### 示例:10)在特定接口上捕获来自特定来源 IP 的数据包 -在tcpdump命令中,使用 '**src**' 关键字后跟 '**IP 地址**',我们可以捕获来自特定来源 IP 的数据包, +在 `tcpdump` 命令中,使用 `src` 关键字后跟 IP 地址,我们可以捕获来自特定来源 IP 的数据包, 语法: @@ -296,17 +292,16 @@ listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes 10 packets captured 12 packets received by filter 0 packets dropped by kernel -[root@compute-0-1 ~]# - ``` -### 示例: 11) 在特定接口上捕获来自特定目的IP的数据包 +### 示例:11)在特定接口上捕获来自特定目的 IP 的数据包 语法: ``` # tcpdump -n -i {接口名} dst {IP 地址} ``` + ``` [root@compute-0-1 ~]# tcpdump -n -i enp0s3 dst 169.144.0.1 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode @@ -318,42 +313,39 @@ listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes 23:10:43.522157 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 800:996, ack 1, win 291, options [nop,nop,TS val 85404989 ecr 21390359], length 196 23:10:43.522346 IP 169.144.0.20.ssh > 169.144.0.1.39406: Flags [P.], seq 996:1192, ack 1, win 291, options [nop,nop,TS val 85404989 ecr 21390359], length 196 ......................................................................................... - ``` -### 示例: 12) 捕获两台主机之间的 TCP 数据包通信 +### 示例:12)捕获两台主机之间的 TCP 数据包通信 假设我想捕获两台主机 169.144.0.1 和 169.144.0.20 之间的 TCP 数据包,示例如下所示, ``` [root@compute-0-1 ~]# tcpdump -w two-host-tcp-comm.pcap -i enp0s3 tcp and \(host 169.144.0.1 or host 169.144.0.20\) - ``` -使用 tcpdump 命令只捕获两台主机之间的 SSH 数据包流, +使用 `tcpdump` 命令只捕获两台主机之间的 SSH 数据包流, ``` [root@compute-0-1 ~]# tcpdump -w ssh-comm-two-hosts.pcap -i enp0s3 src 169.144.0.1 and port 22 and dst 169.144.0.20 and port 22 - ``` -示例: 13) 捕获两台主机之间的 UDP 网络数据包(来回) +### 示例:13)捕获两台主机之间(来回)的 UDP 网络数据包 语法: ``` # tcpdump -w -s -i udp and \(host and host \) ``` + ``` [root@compute-0-1 ~]# tcpdump -w two-host-comm.pcap -s 1000 -i enp0s3 udp and \(host 169.144.0.10 and host 169.144.0.20\) - ``` -### 示例: 14) 捕获十六进制和ASCII格式的数据包 +### 示例:14)捕获十六进制和 ASCII 格式的数据包 -使用 tcpdump 命令,我们可以以 ASCII 和十六进制格式捕获 TCP/IP 数据包, +使用 `tcpdump` 命令,我们可以以 ASCII 和十六进制格式捕获 TCP/IP 数据包, -要使用** -A **选项捕获ASCII格式的数据包,示例如下所示: +要使用 `-A` 选项捕获 ASCII 格式的数据包,示例如下所示: ``` [root@compute-0-1 ~]# tcpdump -c 10 -A -i enp0s3 @@ -376,7 +368,7 @@ root@compute-0-1 @.......... .................................................................................................................................................. ``` -要同时以十六进制和 ASCII 格式捕获数据包,请使用** -XX **选项 +要同时以十六进制和 ASCII 格式捕获数据包,请使用 `-XX` 选项。 ``` [root@compute-0-1 ~]# tcpdump -c 10 -XX -i enp0s3 @@ -406,10 +398,9 @@ listening on enp0s3, link-type EN10MB (Ethernet), capture size 262144 bytes 0x0030: 3693 7c0e 0000 0101 080a 015a a734 0568 6.|........Z.4.h 0x0040: 39af ....................................................................... - ``` -这就是本文的全部内容,我希望您能了解如何使用 tcpdump 命令捕获和分析 TCP/IP 数据包。请分享你的反馈和评论。 +这就是本文的全部内容,我希望您能了解如何使用 `tcpdump` 命令捕获和分析 TCP/IP 数据包。请分享你的反馈和评论。 -------------------------------------------------------------------------------- @@ -418,7 +409,7 @@ via: https://www.linuxtechi.com/capture-analyze-packets-tcpdump-command-linux/ 作者:[Pradeep Kumar][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[ypingcn](https://github.com/ypingcn) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From f1d5a8dabc1fdca137acc696399688aa5e7b59c4 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 26 Sep 2018 09:57:04 +0800 Subject: [PATCH 420/455] PUB:20180826 How to capture and analyze packets with tcpdump command on Linux.md @ypingcn https://linux.cn/article-10050-1.html --- ...o capture and analyze packets with tcpdump command on Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180826 How to capture and analyze packets with tcpdump command on Linux.md (100%) diff --git a/translated/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md b/published/20180826 How to capture and analyze packets with tcpdump command on Linux.md similarity index 100% rename from translated/tech/20180826 How to capture and analyze packets with tcpdump command on Linux.md rename to published/20180826 How to capture and analyze packets with tcpdump command on Linux.md From e15bdabdf6660c98492672a8eb0d3a0a8278d018 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 26 Sep 2018 10:16:42 +0800 Subject: [PATCH 421/455] PRF:20180919 Understand Fedora memory usage with top.md @HankChow --- ...Understand Fedora memory usage with top.md | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/translated/tech/20180919 Understand Fedora memory usage with top.md b/translated/tech/20180919 Understand Fedora memory usage with top.md index a55d5d7b55..a8c6906ca1 100644 --- a/translated/tech/20180919 Understand Fedora memory usage with top.md +++ b/translated/tech/20180919 Understand Fedora memory usage with top.md @@ -1,17 +1,17 @@ -使用 `top` 命令了解 Fedora 的内存使用情况 +使用 top 命令了解 Fedora 的内存使用情况 ====== ![](https://fedoramagazine.org/wp-content/uploads/2018/09/memory-top-816x345.jpg) -如果你使用过 `top` 命令来查看 Fedora 系统中的内存使用情况,你可能会惊讶,显示的数值看起来比系统可用的内存消耗更多。下面会详细介绍内存使用情况以及如何理解这些数据。 +如果你使用过 `top` 命令来查看 Fedora 系统中的内存使用情况,你可能会惊讶,看起来消耗的数量比系统可用的内存更多。下面会详细介绍内存使用情况以及如何理解这些数据。 ### 内存实际使用情况 -操作系统对内存的使用方式并不是太通俗易懂,而是有很多不为人知的巧妙方式。通过这些方式,可以在无需用户干预的情况下,让操作系统更有效地使用内存。 +操作系统对内存的使用方式并不是太通俗易懂。事实上,其背后有很多不为人知的巧妙技术在发挥着作用。通过这些方式,可以在无需用户干预的情况下,让操作系统更有效地使用内存。 大多数应用程序都不是系统自带的,但每个应用程序都依赖于安装在系统中的库中的一些函数集。在 Fedora 中,RPM 包管理系统能够确保在安装应用程序时也会安装所依赖的库。 -当应用程序运行时,操作系统并不需要将它要用到的所有信息都加载到物理内存中。而是会为存放代码的存储构建一个映射,称为虚拟内存。操作系统只把需要的部分加载到内存中,当某一个部分不再需要后,这一部分内存就会被释放掉。 +当应用程序运行时,操作系统并不需要将它要用到的所有信息都加载到物理内存中。而是会为存放代码的存储空间构建一个映射,称为虚拟内存。操作系统只把需要的部分加载到内存中,当某一个部分不再需要后,这一部分内存就会被释放掉。 这意味着应用程序可以映射大量的虚拟内存,而使用较少的系统物理内存。特殊情况下,映射的虚拟内存甚至可以比系统实际可用的物理内存更多!而且在操作系统中这种情况也并不少见。 @@ -21,25 +21,25 @@ ### 使用 `top` 命令查看内存使用量 -如果你还没有使用过 `top` 命令,可以打开终端直接执行查看。使用 **Shift + M** 可以按照内存使用量来进行排序。下图是在 Fedora Workstation 中执行的结果,在你的机器上显示的结果可能会略有不同: +如果你还没有使用过 `top` 命令,可以打开终端直接执行查看。使用 `Shift + M` 可以按照内存使用量来进行排序。下图是在 Fedora Workstation 中执行的结果,在你的机器上显示的结果可能会略有不同: ![](https://fedoramagazine.org/wp-content/uploads/2018/09/Screenshot-from-2018-09-17-14-23-17.png) -主要通过一下三列来查看内存使用情况:VIRT,RES 和 SHR。目前以 KB 为单位显示相关数值。 +主要通过以下三列来查看内存使用情况:`VIRT`、`RES` 和 `SHR`。目前以 KB 为单位显示相关数值。 -VIRT 列代表该进程映射的虚拟内存。如上所述,虚拟内存不是实际消耗的物理内存。例如, GNOME Shell 进程 gnome-shell 实际上没有消耗超过 3.1 GB 的物理内存,但它对很多更低或更高级的库都有依赖,系统必须对每个库都进行映射,以确保在有需要时可以加载这些库。 +`VIRT` 列代表该进程映射的虚拟virtual内存。如上所述,虚拟内存不是实际消耗的物理内存。例如, GNOME Shell 进程 `gnome-shell` 实际上没有消耗超过 3.1 GB 的物理内存,但它对很多更低或更高级的库都有依赖,系统必须对每个库都进行映射,以确保在有需要时可以加载这些库。 -RES 列代表应用程序消耗了多少实际(驻留)内存。对于 GNOME Shell 大约是 180788 KB。例子中的系统拥有大约 7704 MB 的物理内存,因此内存使用率显示为 2.3%。 +`RES` 列代表应用程序消耗了多少实际(驻留resident)内存。对于 GNOME Shell 大约是 180788 KB。例子中的系统拥有大约 7704 MB 的物理内存,因此内存使用率显示为 2.3%。 -但根据 SHR 列显示,其中至少有 88212 KB 是共享内存,这部分内存可能是其它应用程序也在使用的库函数。这意味着 GNOME Shell 本身大约有 92 MB 内存不与其他进程共享。需要注意的是,上述例子中的其它程序也共享了很多内存。在某些应用程序中,共享内存在内存使用量中会占很大的比例。 +但根据 `SHR` 列显示,其中至少有 88212 KB 是共享shared内存,这部分内存可能是其它应用程序也在使用的库函数。这意味着 GNOME Shell 本身大约有 92 MB 内存不与其他进程共享。需要注意的是,上述例子中的其它程序也共享了很多内存。在某些应用程序中,共享内存在内存使用量中会占很大的比例。 -值得一提的是,有时进程之间通过内存通信,这些内存也是共享的,但 `top` 工具却不一定能检测到,所以以上的说明也不一定准确。(这一句不太会翻译出来,烦请校对大佬帮忙看看,谢谢) +值得一提的是,有时进程之间通过内存通信,这些内存也是共享的,但 `top` 这样的工具却不一定能检测到,所以以上的说明也不一定准确。 ### 关于交换分区 系统还可以通过交换分区来存储数据(例如硬盘),但读写的速度相对较慢。当物理内存渐渐用满,操作系统就会查找内存中暂时不会使用的部分,将其写出到交换区域等待需要的时候使用。 -因此,如果交换内存的使用量一直偏高,表明系统的物理内存已经供不应求了。尽管错误的内存申请也有可能导致出现这种情况,但如果这种现象经常出现,就需要考虑提升物理内存或者限制某些程序的运行了。 +因此,如果交换内存的使用量一直偏高,表明系统的物理内存已经供不应求了。有时候一个不正常的应用也有可能导致出现这种情况,但如果这种现象经常出现,就需要考虑提升物理内存或者限制某些程序的运行了。 感谢 [Stig Nygaard][1] 在 [Flickr][2] 上提供的图片(CC BY 2.0)。 @@ -50,7 +50,7 @@ via: https://fedoramagazine.org/understand-fedora-memory-usage-top/ 作者:[Paul W. Frields][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[HankChow](https://github.com/HankChow) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From ddfd8e8baad7cdea4fdfbe862b8bf36f93e511e8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 26 Sep 2018 10:17:09 +0800 Subject: [PATCH 422/455] PUB:20180919 Understand Fedora memory usage with top.md @HankChow https://linux.cn/article-10051-1.html --- .../20180919 Understand Fedora memory usage with top.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180919 Understand Fedora memory usage with top.md (100%) diff --git a/translated/tech/20180919 Understand Fedora memory usage with top.md b/published/20180919 Understand Fedora memory usage with top.md similarity index 100% rename from translated/tech/20180919 Understand Fedora memory usage with top.md rename to published/20180919 Understand Fedora memory usage with top.md From 6d4b83d471ed9b473d7aa7a4260c50df36ac328b Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Wed, 26 Sep 2018 12:13:48 +0800 Subject: [PATCH 423/455] Translating by qhwdw (#10351) --- ... of the Best Linux Educational Software and Games for Kids.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md b/sources/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md index f6013baab2..66850b2260 100644 --- a/sources/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md +++ b/sources/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md @@ -1,3 +1,4 @@ +Translating by qhwdw 5 of the Best Linux Educational Software and Games for Kids ====== From 9c982a4d75ee5612d522be463c93164bf336d6b4 Mon Sep 17 00:00:00 2001 From: Hank Chow <280630620@qq.com> Date: Wed, 26 Sep 2018 12:16:30 +0800 Subject: [PATCH 424/455] translated (#10352) --- ...icks that can save you time and trouble.md | 171 ------------------ ...icks that can save you time and trouble.md | 170 +++++++++++++++++ 2 files changed, 170 insertions(+), 171 deletions(-) delete mode 100644 sources/tech/20180917 Linux tricks that can save you time and trouble.md create mode 100644 translated/tech/20180917 Linux tricks that can save you time and trouble.md diff --git a/sources/tech/20180917 Linux tricks that can save you time and trouble.md b/sources/tech/20180917 Linux tricks that can save you time and trouble.md deleted file mode 100644 index 61fae6d4bc..0000000000 --- a/sources/tech/20180917 Linux tricks that can save you time and trouble.md +++ /dev/null @@ -1,171 +0,0 @@ -HankChow translating - -Linux tricks that can save you time and trouble -====== -Some command line tricks can make you even more productive on the Linux command line. - -![](https://images.idgesg.net/images/article/2018/09/boy-jumping-off-swing-100772498-large.jpg) - -Good Linux command line tricks don’t only save you time and trouble. They also help you remember and reuse complex commands, making it easier for you to focus on what you need to do, not how you should go about doing it. In this post, we’ll look at some handy command line tricks that you might come to appreciate. - -### Editing your commands - -When making changes to a command that you're about to run on the command line, you can move your cursor to the beginning or the end of the command line to facilitate your changes using the ^a (control key plus “a”) and ^e (control key plus “e”) sequences. - -You can also fix and rerun a previously entered command with an easy text substitution by putting your before and after strings between **^** characters -- as in ^before^after^. - -``` -$ eho hello world <== oops! - -Command 'eho' not found, did you mean: - - command 'echo' from deb coreutils - command 'who' from deb coreutils - -Try: sudo apt install - -$ ^e^ec^ <== replace text -echo hello world -hello world - -``` - -### Logging into a remote system with just its name - -If you log into other systems from the command line (I do this all the time), you might consider adding some aliases to your system to supply the details. Your alias can provide the username you want to use (which may or may not be the same as your username on your local system) and the identity of the remote server. Use an alias server_name=’ssh -v -l username IP-address' type of command like this: - -``` -$ alias butterfly=”ssh -v -l jdoe 192.168.0.11” -``` - -You can use the system name in place of the IP address if it’s listed in your /etc/hosts file or available through your DNS server. - -And remember you can list your aliases with the **alias** command. - -``` -$ alias -alias butterfly='ssh -v -l jdoe 192.168.0.11' -alias c='clear' -alias egrep='egrep --color=auto' -alias fgrep='fgrep --color=auto' -alias grep='grep --color=auto' -alias l='ls -CF' -alias la='ls -A' -alias list_repos='grep ^[^#] /etc/apt/sources.list /etc/apt/sources.list.d/*' -alias ll='ls -alF' -alias ls='ls --color=auto' -alias show_dimensions='xdpyinfo | grep '\''dimensions:'\''' -``` - -It's good practice to test new aliases and then add them to your ~/.bashrc or similar file to be sure they will be available any time you log in. - -### Freezing and thawing out your terminal window - -The ^s (control key plus “s”) sequence will stop a terminal from providing output by running an XOFF (transmit off) flow control. This affects PuTTY sessions, as well as terminal windows on your desktop. Sometimes typed by mistake, however, the way to make the terminal window responsive again is to enter ^q (control key plus “q”). The only real trick here is remembering ^q since you aren't very likely run into this situation very often. - -### Repeating commands - -Linux provides many ways to reuse commands. The key to command reuse is your history buffer and the commands it collects for you. The easiest way to repeat a command is to type an ! followed by the beginning letters of a recently used command. Another is to press the up-arrow on your keyboard until you see the command you want to reuse and then press enter. You can also display previously entered commands and then type ! followed by the number shown next to the command you want to reuse in the displayed command history entries. - -``` -!! <== repeat previous command -!ec <== repeat last command that started with "ec" -!76 <== repeat command #76 from command history -``` - -### Watching a log file for updates - -Commands such as tail -f /var/log/syslog will show you lines as they are being added to the specified log file — very useful if you are waiting for some particular activity or want to track what’s happening right now. The command will show the end of the file and then additional lines as they are added. - -``` -$ tail -f /var/log/auth.log -Sep 17 09:41:01 fly CRON[8071]: pam_unix(cron:session): session closed for user smmsp -Sep 17 09:45:01 fly CRON[8115]: pam_unix(cron:session): session opened for user root -Sep 17 09:45:01 fly CRON[8115]: pam_unix(cron:session): session closed for user root -Sep 17 09:47:00 fly sshd[8124]: Accepted password for shs from 192.168.0.22 port 47792 -Sep 17 09:47:00 fly sshd[8124]: pam_unix(sshd:session): session opened for user shs by -Sep 17 09:47:00 fly systemd-logind[776]: New session 215 of user shs. -Sep 17 09:55:01 fly CRON[8208]: pam_unix(cron:session): session opened for user root -Sep 17 09:55:01 fly CRON[8208]: pam_unix(cron:session): session closed for user root - <== waits for additional lines to be added -``` - -### Asking for help - -For most Linux commands, you can enter the name of the command followed by the option **\--help** to get some fairly succinct information on what the command does and how to use it. Less extensive than the man command, the --help option often tells you just what you need to know without expanding on all of the options available. - -``` -$ mkdir --help -Usage: mkdir [OPTION]... DIRECTORY... -Create the DIRECTORY(ies), if they do not already exist. - -Mandatory arguments to long options are mandatory for short options too. - -m, --mode=MODE set file mode (as in chmod), not a=rwx - umask - -p, --parents no error if existing, make parent directories as needed - -v, --verbose print a message for each created directory - -Z set SELinux security context of each created directory - to the default type - --context[=CTX] like -Z, or if CTX is specified then set the SELinux - or SMACK security context to CTX - --help display this help and exit - --version output version information and exit - -GNU coreutils online help: -Full documentation at: -or available locally via: info '(coreutils) mkdir invocation' -``` - -### Removing files with care - -To add a little caution to your use of the rm command, you can set it up with an alias that asks you to confirm your request to delete files before it goes ahead and deletes them. Some sysadmins make this the default. In that case, you might like the next option even more. - -``` -$ rm -i <== prompt for confirmation -``` - -### Turning off aliases - -You can always disable an alias interactively by using the unalias command. It doesn’t change the configuration of the alias in question; it just disables it until the next time you log in or source the file in which the alias is set up. - -``` -$ unalias rm -``` - -If the **rm -i** alias is set up as the default and you prefer to never have to provide confirmation before deleting files, you can put your **unalias** command in one of your startup files (e.g., ~/.bashrc). - -### Remembering to use sudo - -If you often forget to precede commands that only root can run with “sudo”, there are two things you can do. You can take advantage of your command history by using the “sudo !!” (use sudo to run your most recent command with sudo prepended to it), or you can turn some of these commands into aliases with the required "sudo" attached. - -``` -$ alias update=’sudo apt update’ -``` - -### More complex tricks - -Some useful command line tricks require a little more than a clever alias. An alias, after all, replaces a command, often inserting options so you don't have to enter them and allowing you to tack on additional information. If you want something more complex than an alias can manage, you can write a simple script or add a function to your .bashrc or other start-up file. The function below, for example, creates a directory and moves you into it. Once it's been set up, source your .bashrc or other file and you can use commands such as "md temp" to set up a directory and cd into it. - -``` -md () { mkdir -p "$@" && cd "$1"; } -``` - -### Wrap-up - -Working on the Linux command line remains one of the most productive and enjoyable ways to get work done on my Linux systems, but a group of command line tricks and clever aliases can make that experience even better. - -Join the Network World communities on [Facebook][1] and [LinkedIn][2] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3305811/linux/linux-tricks-that-even-you-can-love.html - -作者:[Sandra Henry-Stocker][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ -[1]: https://www.facebook.com/NetworkWorld/ -[2]: https://www.linkedin.com/company/network-world diff --git a/translated/tech/20180917 Linux tricks that can save you time and trouble.md b/translated/tech/20180917 Linux tricks that can save you time and trouble.md new file mode 100644 index 0000000000..1dbc81bfbd --- /dev/null +++ b/translated/tech/20180917 Linux tricks that can save you time and trouble.md @@ -0,0 +1,170 @@ +让你提高效率的 Linux 技巧 +====== +想要在 Linux 命令行工作中提高效率,你需要使用一些技巧。 + +![](https://images.idgesg.net/images/article/2018/09/boy-jumping-off-swing-100772498-large.jpg) + +巧妙的 Linux 命令行技巧能让你节省时间、避免出错,还能让你记住和复用各种复杂的命令,专注在需要做的事情本身,而不是做事的方式。以下介绍一些好用的命令行技巧。 + +### 命令编辑 + +如果要对一个已输入的命令进行修改,可以使用 ^a(ctrl + a)或 ^e(ctrl + e)将光标快速移动到命令的开头或命令的末尾。 + +还可以使用 `^` 字符实现对上一个命令的文本替换并重新执行命令,例如 `^before^after^` 相当于把上一个命令中的 `before` 替换为 `after` 然后重新执行一次。 + +``` +$ eho hello world <== 错误的命令 + +Command 'eho' not found, did you mean: + + command 'echo' from deb coreutils + command 'who' from deb coreutils + +Try: sudo apt install + +$ ^e^ec^ <== 替换 +echo hello world +hello world + +``` + +### 使用远程机器的名称登录到机器上 + +如果使用命令行登录其它机器上,可以考虑添加别名。在别名中,可以填入需要登录的用户名(与本地系统上的用户名可能相同,也可能不同)以及远程机器的登录信息。例如使用 `server_name ='ssh -v -l username IP-address'` 这样的别名命令: + +``` +$ alias butterfly=”ssh -v -l jdoe 192.168.0.11” +``` + +也可以通过在 `/etc/hosts` 文件中添加记录或者在 DNS 服务器中加入解析记录来把 IP 地址替换成易记的机器名称。 + +执行 `alias` 命令可以列出机器上已有的别名。 + +``` +$ alias +alias butterfly='ssh -v -l jdoe 192.168.0.11' +alias c='clear' +alias egrep='egrep --color=auto' +alias fgrep='fgrep --color=auto' +alias grep='grep --color=auto' +alias l='ls -CF' +alias la='ls -A' +alias list_repos='grep ^[^#] /etc/apt/sources.list /etc/apt/sources.list.d/*' +alias ll='ls -alF' +alias ls='ls --color=auto' +alias show_dimensions='xdpyinfo | grep '\''dimensions:'\''' +``` + +只要将新的别名添加到 `~/.bashrc` 或类似的文件中,就可以让别名在每次登录后都能立即生效。 + +### 冻结、解冻终端界面 + +^s(ctrl + s)将通过执行流量控制命令 XOFF 来停止终端输出内容,这会对 PuTTY 会话和桌面终端窗口产生影响。如果误输入了这个命令,可以使用 ^q(ctrl + q)让终端重新响应。所以只需要记住^q 这个组合键就可以了,毕竟这种情况并不多见。 + +### 复用命令 + +Linux 提供了很多让用户复用命令的方法,其核心是通过历史缓冲区收集执行过的命令。复用命令的最简单方法是输入 `!` 然后接最近使用过的命令的开头字母;当然也可以按键盘上的向上箭头,直到看到要复用的命令,然后按 Enter 键。还可以先使用 `history` 显示命令历史,然后输入 `!` 后面再接命令历史记录中需要复用的命令旁边的数字。 + +``` +!! <== 复用上一条命令 +!ec <== 复用上一条以 “ec” 开头的命令 +!76 <== 复用命令历史中的 76 号命令 +``` + +### 查看日志文件并动态显示更新内容 + +使用形如 `tail -f /var/log/syslog` 的命令可以查看指定的日志文件,并动态显示文件中增加的内容,需要监控向日志文件中追加内容的的事件时相当有用。这个命令会输出文件内容的末尾部分,并逐渐显示新增的内容。 + +``` +$ tail -f /var/log/auth.log +Sep 17 09:41:01 fly CRON[8071]: pam_unix(cron:session): session closed for user smmsp +Sep 17 09:45:01 fly CRON[8115]: pam_unix(cron:session): session opened for user root +Sep 17 09:45:01 fly CRON[8115]: pam_unix(cron:session): session closed for user root +Sep 17 09:47:00 fly sshd[8124]: Accepted password for shs from 192.168.0.22 port 47792 +Sep 17 09:47:00 fly sshd[8124]: pam_unix(sshd:session): session opened for user shs by +Sep 17 09:47:00 fly systemd-logind[776]: New session 215 of user shs. +Sep 17 09:55:01 fly CRON[8208]: pam_unix(cron:session): session opened for user root +Sep 17 09:55:01 fly CRON[8208]: pam_unix(cron:session): session closed for user root + <== 等待显示追加的内容 +``` + +### 寻求帮助 + +对于大多数 Linux 命令,都可以通过在输入命令后加上选项 `--help` 来获得这个命令的作用、用法以及它的一些相关信息。除了 `man` 命令之外, `--help` 选项可以让你在不使用所有扩展选项的情况下获取到所需要的内容。 + +``` +$ mkdir --help +Usage: mkdir [OPTION]... DIRECTORY... +Create the DIRECTORY(ies), if they do not already exist. + +Mandatory arguments to long options are mandatory for short options too. + -m, --mode=MODE set file mode (as in chmod), not a=rwx - umask + -p, --parents no error if existing, make parent directories as needed + -v, --verbose print a message for each created directory + -Z set SELinux security context of each created directory + to the default type + --context[=CTX] like -Z, or if CTX is specified then set the SELinux + or SMACK security context to CTX + --help display this help and exit + --version output version information and exit + +GNU coreutils online help: +Full documentation at: +or available locally via: info '(coreutils) mkdir invocation' +``` + +### 谨慎删除文件 + +如果要谨慎使用 `rm` 命令,可以为它设置一个别名,在删除文件之前需要进行确认才能删除。有些系统管理员会默认使用这个别名,对于这种情况,你可能需要看看下一个技巧。 + +``` +$ rm -i <== 请求确认 +``` + +### 关闭别名 + +你可以使用 `unalias` 命令以交互方式禁用别名。它不会更改别名的配置,而仅仅是暂时禁用,直到下次登录或重新设置了这一个别名才会重新生效。 + +``` +$ unalias rm +``` + +如果已经将 `rm -i` 默认设置为 `rm` 的别名,但你希望在删除文件之前不必进行确认,则可以将 `unalias` 命令放在一个启动文件(例如 ~/.bashrc)中。 + +### 使用 sudo + +如果你经常在只有 root 用户才能执行的命令前忘记使用 `sudo`,这里有两个方法可以解决。一是利用命令历史记录,可以使用 `sudo !!`(使用 `!!` 来运行最近的命令,并在前面添加 `sudo`)来重复执行,二是设置一些附加了所需 `sudo` 的命令别名。 + +``` +$ alias update=’sudo apt update’ +``` + +### 更复杂的技巧 + +有时命令行技巧并不仅仅是一个别名。毕竟,别名能帮你做的只有替换命令以及增加一些命令参数,节省了输入的时间。但如果需要比别名更复杂功能,可以通过编写脚本、向 `.bashrc` 或其他启动文件添加函数来实现。例如,下面这个函数会在创建一个目录后进入到这个目录下。在设置完毕后,执行 `source .bashrc`,就可以使用 `md temp` 这样的命令来创建目录立即进入这个目录下。 + +``` +md () { mkdir -p "$@" && cd "$1"; } +``` + +### 总结 + +使用 Linux 命令行是在 Linux 系统上工作最有效也最有趣的方法,但配合命令行技巧和巧妙的别名可以让你获得更好的体验。 + +加入 [Facebook][1] 和 [LinkedIn][2] 上的 Network World 社区可以和我们一起讨论。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3305811/linux/linux-tricks-that-even-you-can-love.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[HankChow](https://github.com/HankChow) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[1]: https://www.facebook.com/NetworkWorld/ +[2]: https://www.linkedin.com/company/network-world + From 5fe1a903760a28633a343e7b56f634b2269fd12a Mon Sep 17 00:00:00 2001 From: LuMing <784315443@qq.com> Date: Wed, 26 Sep 2018 12:17:18 +0800 Subject: [PATCH 425/455] LuuMing translating (#10353) --- ...How to Use the Netplan Network Configuration Tool on Linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180907 How to Use the Netplan Network Configuration Tool on Linux.md b/sources/tech/20180907 How to Use the Netplan Network Configuration Tool on Linux.md index 9ba21a367f..a9d3eb0895 100644 --- a/sources/tech/20180907 How to Use the Netplan Network Configuration Tool on Linux.md +++ b/sources/tech/20180907 How to Use the Netplan Network Configuration Tool on Linux.md @@ -1,3 +1,4 @@ +LuuMing translating How to Use the Netplan Network Configuration Tool on Linux ====== From 24b0867ee36f12df2aadfa08fa65fa95350217e7 Mon Sep 17 00:00:00 2001 From: hopefully2333 <787016457@qq.com> Date: Wed, 26 Sep 2018 12:20:36 +0800 Subject: [PATCH 426/455] translated over (#10354) * translated over translated over * Update 20180824 Steam Makes it Easier to Play Windows Games on Linux.md * translated over translated over --- ...t Easier to Play Windows Games on Linux.md | 74 ------------------- ...t Easier to Play Windows Games on Linux.md | 73 ++++++++++++++++++ 2 files changed, 73 insertions(+), 74 deletions(-) delete mode 100644 sources/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md create mode 100644 translated/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md diff --git a/sources/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md b/sources/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md deleted file mode 100644 index 73080089bf..0000000000 --- a/sources/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md +++ /dev/null @@ -1,74 +0,0 @@ -translated by hopefully2333 - -Steam Makes it Easier to Play Windows Games on Linux -====== -![Steam Wallpaper][1] - -It’s no secret that the [Linux gaming][2] library offers only a fraction of what the Windows library offers. In fact, many people wouldn’t even consider [switching to Linux][3] simply because most of the games they want to play aren’t available on the platform. - -At the time of writing this article, Linux has just over 5,000 games available on Steam compared to the library’s almost 27,000 total games. Now, 5,000 games may be a lot, but it isn’t 27,000 games, that’s for sure. - -And though almost every new indie game seems to launch with a Linux release, we are still left without a way to play many [Triple-A][4] titles. For me, though there are many titles I would love the opportunity to play, this has never been a make-or-break problem since almost all of my favorite titles are available on Linux since I primarily play indie and [retro games][5] anyway. - -### Meet Proton: a WINE Fork by Steam - -Now, that problem is a thing of the past since this week Valve [announced][6] a new update to Steam Play that adds a forked version of Wine to the Linux and Mac Steam clients called Proton. Yes, the tool is open-source, and Valve has made the source code available on [Github][7]. The feature is still in beta though, so you must opt into the beta Steam client in order to take advantage of this functionality. - -#### With proton, more Windows games are available for Linux on Steam - -What does that actually mean for us Linux users? In short, it means that both Linux and Mac computers can now play all 27,000 of those games without needing to configure something like [PlayOnLinux][8] or [Lutris][9] to do so! Which, let me tell you, can be quite the headache at times. - -The more complicated answer to this is that it sounds too good to be true for a reason. Though, in theory, you can play literally every Windows game on Linux this way, there is only a short list of games that are officially supported at launch, including DOOM, Final Fantasy VI, Tekken 7, Star Wars: Battlefront 2, and several more. - -#### You can play all Windows games on Linux (in theory) - -Though the list only has about 30 games thus far, you can force enable Steam to install and play any game through Proton by marking the “Enable Steam Play for all titles” checkbox. But don’t get your hopes too high. They do not guarantee the stability and performance you may be hoping for, so keep your expectations reasonable. - -![Steam Play][10] - -#### Experiencing Proton: Not as bad as I expected - -For example, I installed a few moderately taxing games to put Proton through its paces. One of which was The Elder Scrolls IV: Oblivion, and in the two hours I played the game, it only crashed once, and it was almost immediately after an autosave point during the tutorial. - -I have an Nvidia Gtx 1050 Ti, so I was able to play the game at 1080p with high settings, and I didn’t see a single problem outside of that one crash. The only negative feedback I really have is that the framerate was not nearly as high as it would have been if it was a native game. I got above 60 frames 90% of the time, but I admit it could have been better. - -Every other game that I have installed and launched has also worked flawlessly, granted I haven’t played any of them for an extended amount of time yet. Some games I installed include The Forest, Dead Rising 4, H1Z1, and Assassin’s Creed II (can you tell I like horror games?). - -#### Why is Steam (still) betting on Linux? - -Now, this is all fine and dandy, but why did this happen? Why would Valve spend the time, money, and resources needed to implement something like this? I like to think they did so because they value the Linux community, but if I am honest, I don’t believe we had anything to do with it. - -If I had to put money on it, I would say Valve has developed Proton because they haven’t given up on [Steam machines][11] yet. And since [Steam OS][12] is running on Linux, it is in their best interest financially to invest in something like this. The more games available on Steam OS, the more people might be willing to buy a Steam Machine. - -Maybe I am wrong, but I bet this means we will see a new wave of Steam machines coming in the not-so-distant future. Maybe we will see them in one year, or perhaps we won’t see them for another five, who knows! - -Either way, all I know is that I am beyond excited to finally play the games from my Steam library that I have slowly accumulated over the years from all of the Humble Bundles, promo codes, and random times I bought a game on sale just in case I wanted to try to get it running in Lutris. - -#### Excited for more gaming on Linux? - -What do you think? Are you excited about this, or are you afraid fewer developers will create native Linux games because there is almost no need to now? Does Valve love the Linux community, or do they love money? Let us know what you think in the comment section below, and check back in for more FOSS content like this. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/steam-play-proton/ - -作者:[Phillip Prado][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://itsfoss.com/author/phillip/ -[1]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/steam-wallpaper.jpeg -[2]:https://itsfoss.com/linux-gaming-guide/ -[3]:https://itsfoss.com/reasons-switch-linux-windows-xp/ -[4]:https://itsfoss.com/triplea-game-review/ -[5]:https://itsfoss.com/play-retro-games-linux/ -[6]:https://steamcommunity.com/games/221410 -[7]:https://github.com/ValveSoftware/Proton/ -[8]:https://www.playonlinux.com/en/ -[9]:https://lutris.net/ -[10]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/SteamProton.jpg -[11]:https://store.steampowered.com/sale/steam_machines -[12]:https://itsfoss.com/valve-annouces-linux-based-gaming-operating-system-steamos/ diff --git a/translated/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md b/translated/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md new file mode 100644 index 0000000000..75c42b3ab3 --- /dev/null +++ b/translated/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md @@ -0,0 +1,73 @@ + +steam 让我们在 Linux 上玩 Windows 的游戏更加容易 +====== +![Steam Wallpaper][1] + +总所周知,Linux 游戏库中的游戏只有 Windows 游戏库中的一部分,实际上,许多人甚至都不会考虑将操作系统转换为 Linux,原因很简单,因为他们喜欢的游戏,大多数都不能在这个平台上运行。 + +在撰写本文时,steam 上已有超过 5000 种游戏可以在 Linux 上运行,而 steam 上的游戏总数已经接近 27000 种了。现在 5000 种游戏可能看起来很多,但还没有达到 27000 种,确实没有。 + +虽然几乎所有的新的独立游戏都是在 Linux 中推出的,但我们仍然无法在这上面玩很多的 3A 大作。对我而言,虽然这其中有很多游戏我都很希望能有机会玩,但这从来都不是一个非黑即白的问题。因为我主要是玩独立游戏和复古游戏,所以几乎所有我喜欢的游戏都可以在 Linux 系统上运行。 + +### 认识 Proton,Steam 的一次 WINE 分叉。 + +现在,这个问题已经成为过去式了,因为本周 Valve 宣布要对 Steam Play 进行一次更新,此次更新会将一个名为 Proton 的分叉版本的 Wine 添加到 Linux 和 Mac 的客户端中。是的,这个工具是开源的,Valve 已经在 GitHub 上开源了源代码,但该功能仍然处于测试阶段,所以你必须使用测试版的 Steam 客户端才能使用这项功能。 + +#### 使用 proton ,可以在 Linux 系统上使用 Steam 运行更多的 Windows 上的游戏。 + +这对我们这些 Linux 用户来说,实际上意味着什么?简单来说,这意味着我们可以在 Linux 和 Mac 这两种操作系统的电脑上运行全部 27000 种游戏,而无需配置像 PlayOnLinux 或 Lutris 这样的服务。我要告诉你的是,配置这些东西有时候会非常让人头疼。 + +对此更为复杂的答案是,某种原因听起来非常美好。虽然在理论上,你可以用这种方式在 Linux 上玩所有的 Windows 平台上的游戏。但只有一少部分游戏在推出时会正式支持 Linux。这少部分游戏包括 DOOM,最终幻想 VI,铁拳 7,星球大战:前线 2,和其他几个。 + +#### 你可以在 Linux 上玩所有的 Windows 平台的游戏(理论上) + +虽然目前该列表只有大约 30 个游戏,你可以点击“为所有游戏使用 Steam play 进行运行”复选框来强制使用 Steam 的 Proton 来安装和运行任意游戏。但你最好不要有太高的期待,它们的稳定性和性能表现不一定有你希望的那么好,所以请把期望值压低一点。 + +![Steam Play][10] + +#### 体验 Proton,没有我想的那么烂。 + +例如,我安装了一些中等价格的游戏,使用 Proton 来进行安装。其中一个是上古卷轴 4:湮没,在我玩这个游戏的两个小时里,它只崩溃了一次,而且几乎是紧跟在游戏教程的自动保存点之后。 + +我有一块英伟达 Gtx 1050 Ti 的显卡。所以我可以使用 1080P 的高配置来玩这个游戏。而且我没有遇到除了这次崩溃之外的任何问题。我唯一真正感到不爽的只有它的帧数没有原本的高。在 90% 的时间里,游戏的帧数都在 60 帧以上,但我知道它的帧数应该能更高。 + +我安装和发布的其他所有游戏都运行得很完美,虽然我还没有较长时间地玩过它们中的任何一个。我安装的游戏中包括森林,丧尸围城 4,H1Z1,和刺客信条 2.(你能说我这是喜欢恐怖游戏吗?)。 + +#### 为什么 Steam(仍然)要下注在 Linux 上? + +现在,一切都很好,这件事为什么会发生呢?为什么 Valve 要花费时间,金钱和资源来做这样的事?我倾向于认为,他们这样做是因为他们懂得 Linux 社区的价值,但是如果要我老实地说,我不相信我们和它有任何的关系。 + +如果我一定要在这上面花钱,我想说 Valve 开发了 Proton,因为他们还没有放弃 Steam 机器。因为 Steam OS 是基于 Linux 的发行版,在这类东西上面投资可以获取最大的利润,Steam OS 上可用的游戏越多,就会有更多的人愿意购买 Steam 的机器。 + +可能我是错的,但是我敢打赌啊,我们会在不远的未来看到新一批的 Steam 机器。可能我们会在一年内看到它们,也有可能我们再等五年都见不到,谁知道呢! + +无论哪种方式,我所知道的是,我终于能兴奋地从我的 Steam 游戏库里玩游戏了。多年来我通过所有的收藏包,游戏促销,和不定时地买一个贱卖的游戏来以防万一,我想去尝试让它在 Lutris 中运行。 + +#### 为 Linux 上越来越多的游戏而激动? + +你怎么看?你对此感到激动吗?或者说你会害怕只有很少的开发者会开发 Linux 平台上的游戏,因为现在几乎没有需求?Valve 喜欢 Linux 社区,还是说他们喜欢钱?请在下面的评论区告诉我们您的想法,然后重新搜索来查看更多类似这样的开源软件方面的文章。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/steam-play-proton/ + +作者:[Phillip Prado][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[hopefully2333](https://github.com/hopefully2333) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://itsfoss.com/author/phillip/ +[1]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/steam-wallpaper.jpeg +[2]:https://itsfoss.com/linux-gaming-guide/ +[3]:https://itsfoss.com/reasons-switch-linux-windows-xp/ +[4]:https://itsfoss.com/triplea-game-review/ +[5]:https://itsfoss.com/play-retro-games-linux/ +[6]:https://steamcommunity.com/games/221410 +[7]:https://github.com/ValveSoftware/Proton/ +[8]:https://www.playonlinux.com/en/ +[9]:https://lutris.net/ +[10]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/SteamProton.jpg +[11]:https://store.steampowered.com/sale/steam_machines +[12]:https://itsfoss.com/valve-annouces-linux-based-gaming-operating-system-steamos/ From d5e112d38945d772a97645a90acd97eeb0290ebc Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 26 Sep 2018 14:42:58 +0800 Subject: [PATCH 427/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20Replac?= =?UTF-8?q?e=20one=20Linux=20Distro=20With=20Another=20in=20Dual=20Boot=20?= =?UTF-8?q?[Guide]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Distro With Another in Dual Boot -Guide.md | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 sources/tech/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md diff --git a/sources/tech/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md b/sources/tech/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md new file mode 100644 index 0000000000..ab9fa8acc3 --- /dev/null +++ b/sources/tech/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md @@ -0,0 +1,160 @@ +How to Replace one Linux Distro With Another in Dual Boot [Guide] +====== +**If you have a Linux distribution installed, you can replace it with another distribution in the dual boot. You can also keep your personal documents while switching the distribution.** + +![How to Replace One Linux Distribution With Another From Dual Boot][1] + +Suppose you managed to [successfully dual boot Ubuntu and Windows][2]. But after reading the [Linux Mint versus Ubuntu discussion][3], you realized that [Linux Mint][4] is more suited for your needs. What would you do now? How would you [remove Ubuntu][5] and [install Mint in dual boot][6]? + +You might think that you need to uninstall [Ubuntu][7] from dual boot first and then repeat the dual booting steps with Linux Mint. Let me tell you something. You don’t need to do all of that. + +If you already have a Linux distribution installed in dual boot, you can easily replace it with another. You don’t have to uninstall the existing Linux distribution. You simply delete its partition and install the new distribution on the disk space vacated by the previous distribution. + +Another good news is that you may be able to keep your Home directory with all your documents and pictures while switching the Linux distributions. + +Let me show you how to switch Linux distributions. + +### Replace one Linux with another from dual boot + + + +Let me describe the scenario I am going to use here. I have Linux Mint 19 installed on my system in dual boot mode with Windows 10. I am going to replace it with elementary OS 5. I’ll also keep my personal files (music, pictures, videos, documents from my home directory) while switching distributions. + +Let’s first take a look at the requirements: + + * A system with Linux and Windows dual boot + * Live USB of Linux you want to install + * Backup of your important files in Windows and in Linux on an external disk (optional yet recommended) + + + +#### Things to keep in mind for keeping your home directory while changing Linux distribution + +If you want to keep your files from existing Linux install as it is, you must have a separate root and home directory. You might have noticed that in my [dual boot tutorials][8], I always go for ‘Something Else’ option and then manually create root and home partitions instead of choosing ‘Install alongside Windows’ option. This is where all the troubles in manually creating separate home partition pay off. + +Keeping Home on a separate partition is helpful in situations when you want to replace your existing Linux install with another without losing your files. + +Note: You must remember the exact username and password of your existing Linux install in order to use the same home directory as it is in the new distribution. + +If you don’t have a separate Home partition, you may create it later as well BUT I won’t recommend that. That process is slightly complicated and I don’t want you to mess up your system. + +With that much background information, it’s time to see how to replace a Linux distribution with another. + +#### Step 1: Create a live USB of the new Linux distribution + +Alright! I already mentioned it in the requirements but I still included it in the main steps to avoid confusion. + +You can create a live USB using a start up disk creator like [Etcher][9] in Windows or Linux. The process is simple so I am not going to list the steps here. + +#### Step 2: Boot into live USB and proceed to installing Linux + +Since you have already dual booted before, you probably know the drill. Plugin the live USB, restart your system and at the boot time, press F10 or F12 repeatedly to enter BIOS settings. + +In here, choose to boot from the USB. And then you’ll see the option to try the live environment or installing it immediately. + +You should start the installation procedure. When you reach the ‘Installation type’ screen, choose the ‘Something else’ option. + +![Replacing one Linux with another from dual boot][10] +Select ‘Something else’ here + +#### Step 3: Prepare the partition + +You’ll see the partitioning screen now. Look closely and you’ll see your Linux installation with Ext4 file system type. + +![Identifying Linux partition in dual boot][11] +Identify where your Linux is installed + +In the above picture, the Ext4 partition labeled as Linux Mint 19 is the root partition. The second Ext4 partition of 82691 MB is the Home partition. I [haven’t used any swap space][12] here. + +Now, if you have just one Ext4 partition, that means that your home directory is on the same partition as root. In this case, you won’t be able to keep your Home directory. I suggest that you copy the important files to an external disk else you’ll lose them forever. + +It’s time to delete the root partition. Select the root partition and click the – sign. This will create some free space. + +![Delete root partition of your existing Linux install][13] +Delete root partition + +When you have the free space, click on + sign. + +![Create root partition for the new Linux][14] +Create a new root partition + +Now you should create a new partition out of this free space. If you had just one root partition in your previous Linux install, you should create root and home partitions here. You can also create the swap partition if you want to. + +If you had root and home partition separately, just create a root partition from the deleted root partition. + +![Create root partition for the new Linux][15] +Creating root partition + +You may ask why did I use delete and add instead of using the ‘change’ option. It’s because a few years ago, using change didn’t work for me. So I prefer to do a – and +. Is it superstition? Maybe. + +One important thing to do here is to mark the newly created partition for format. f you don’t change the size of the partition, it won’t be formatted unless you explicitly ask it to format. And if the partition is not formatted, you’ll have issues. + +![][16] +It’s important to format the root partition + +Now if you already had a separate Home partition on your existing Linux install, you should select it and click on change. + +![Recreate home partition][17] +Retouch the already existing home partition (if any) + +You just have to specify that you are mounting it as home partition. + +![Specify the home mount point][18] +Specify the home mount point + +If you had a swap partition, you can repeat the same steps as the home partition. This time specify that you want to use the space as swap. + +At this stage, you should have a root partition (with format option selected) and a home partition (and a swap if you want to). Hit the install now button to start the installation. + +![Verify partitions while replacing one Linux with another][19] +Verify the partitions + +The next few screens would be familiar to you. What matters is the screen where you are asked to create user and password. + +If you had a separate home partition previously and you want to use the same home directory, you MUST use the same username and password that you had before. Computer name doesn’t matter. + +![To keep the home partition intact, use the previous user and password][20] +To keep the home partition intact, use the previous user and password + +Your struggle is almost over. You don’t have to do anything else other than waiting for the installation to finish. + +![Wait for installation to finish][21] +Wait for installation to finish + +Once the installation is over, restart your system. You’ll have a new Linux distribution or version. + +In my case, I had the entire home directory of Linux Mint 19 as it is in the elementary OS. All the videos, pictures I had remained as it is. Isn’t that nice? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/replace-linux-from-dual-boot/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/Replace-Linux-Distro-from-dual-boot.png +[2]: https://itsfoss.com/install-ubuntu-1404-dual-boot-mode-windows-8-81-uefi/ +[3]: https://itsfoss.com/linux-mint-vs-ubuntu/ +[4]: https://www.linuxmint.com/ +[5]: https://itsfoss.com/uninstall-ubuntu-linux-windows-dual-boot/ +[6]: https://itsfoss.com/guide-install-linux-mint-16-dual-boot-windows/ +[7]: https://www.ubuntu.com/ +[8]: https://itsfoss.com/guide-install-elementary-os-luna/ +[9]: https://etcher.io/ +[10]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/replace-linux-with-another-1.jpg +[11]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/replace-linux-with-another-2.jpg +[12]: https://itsfoss.com/swap-size/ +[13]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/replace-linux-with-another-3.jpg +[14]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/replace-linux-with-another-4.jpg +[15]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/replace-linux-with-another-5.jpg +[16]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/replace-linux-with-another-6.jpg +[17]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/replace-linux-with-another-7.jpg +[18]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/replace-linux-with-another-8.jpg +[19]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/replace-linux-with-another-9.jpg +[20]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/replace-linux-with-another-10.jpg +[21]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/replace-linux-with-another-11.jpg From bade2cc0b46f98aaa8067426f60b1f9fc1ae2d6e Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 26 Sep 2018 14:46:34 +0800 Subject: [PATCH 428/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Why=20Linux=20use?= =?UTF-8?q?rs=20should=20try=20Rust?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0180924 Why Linux users should try Rust.md | 171 ++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 sources/tech/20180924 Why Linux users should try Rust.md diff --git a/sources/tech/20180924 Why Linux users should try Rust.md b/sources/tech/20180924 Why Linux users should try Rust.md new file mode 100644 index 0000000000..db60883eb9 --- /dev/null +++ b/sources/tech/20180924 Why Linux users should try Rust.md @@ -0,0 +1,171 @@ +Why Linux users should try Rust +====== + +![](https://images.idgesg.net/images/article/2018/09/rust-rusted-metal-100773678-large.jpg) + +Rust is a fairly young and modern programming language with a lot of features that make it incredibly flexible and very secure. It's also becoming quite popular, having won first place for the "most loved programming language" in the Stack Overflow Developer Survey three years in a row — [2016][1], [2017][2], and [2018][3]. + +Rust is also an _open-source_ language with a suite of special features that allow it to be adapted to many different programming projects. It grew out of what was a personal project of a Mozilla employee back in 2006, was picked up as a special project by Mozilla a few years later (2009), and then announced for public use in 2010. + +Rust programs run incredibly fast, prevent segfaults, and guarantee thread safety. These attributes make the language tremendously appealing to developers focused on application security. Rust is also a very readable language and one that can be used for anything from simple programs to very large and complex projects. + +Rust is: + + * Memory safe — Rust will not suffer from dangling pointers, buffer overflows, or other memory-related errors. And it provides memory safety without garbage collection. + * General purpose — Rust is an appropriate language for any type of programming + * Fast — Rust is comparable in performance to C/C++ but with far better security features. + * Efficient — Rust is built to facilitate concurrent programming. + * Project-oriented — Rust has a built-in dependency and build management system called Cargo. + * Well supported — Rust has an impressive [support community][4]. + + + +Rust also enforces RAII (Resource Acquisition Is Initialization). That means when an object goes out of scope, its destructor will be called and its resources will be freed, providing a shield against resource leaks. It provides functional abstractions and a great [type system][5] together with speed and mathematical soundness. + +In short, Rust is an impressive systems programming language with features that other most languages lack, making it a serious contender for languages like C, C++ and Objective-C that have been used for years. + +### Installing Rust + +Installing Rust is a fairly simple process. + +``` +$ curl https://sh.rustup.rs -sSf | sh +``` + +Once Rust in installed, calling rustc with the **\--version** argument or using the **which** command displays version information. + +``` +$ which rustc +rustc 1.27.2 (58cc626de 2018-07-18) +$ rustc --version +rustc 1.27.2 (58cc626de 2018-07-18) +``` + +### Getting started with Rust + +The simplest code example is not all that different from what you'd enter if you were using one of many scripting languages. + +``` +$ cat hello.rs +fn main() { + // Print a greeting + println!("Hello, world!"); +} +``` + +In these lines, we are setting up a function (main), adding a comment describing the function, and using a println statement to create output. You could compile and then run a program like this using the command shown below. + +``` +$ rustc hello.rs +$ ./hello +Hello, world! +``` + +Alternately, you might create a "project" (generally used only for more complex programs than this one!) to keep your code organized. + +``` +$ mkdir ~/projects +$ cd ~/projects +$ mkdir hello_world +$ cd hello_world +``` + +Notice that even a simple program, once compiled, becomes a fairly large executable. + +``` +$ ./hello +Hello, world! +$ ls -l hello* +-rwxrwxr-x 1 shs shs 5486784 Sep 23 19:02 hello <== executable +-rw-rw-r-- 1 shs shs 68 Sep 23 15:25 hello.rs +``` + +And, of course, that's just a start — the traditional "Hello, world!" program. The Rust language has a suite of features to get you moving quickly to advanced levels of programming skill. + +### Learning Rust + +![rust programming language book cover][6] +No Starch Press + +The Rust Programming Language book by Steve Klabnik and Carol Nichols (2018) provides one of the best ways to learn Rust. Written by two members of the core development team, this book is available in print from [No Starch Press][7] or in ebook format at [rust-lang.org][8]. It has earned its reference as "the book" among the Rust developer community. + +Among the many topics covered, you will learn about these advanced topics: + + * Ownership and borrowing + * Safety guarantees + * Testing and error handling + * Smart pointers and multi-threading + * Advanced pattern matching + * Using Cargo (the built-in package manager) + * Using Rust's advanced compiler + + + +#### Table of Contents + +The table of contents is shown below. + +``` +Foreword by Nicholas Matsakis and Aaron Turon +Acknowledgements +Introduction +Chapter 1: Getting Started +Chapter 2: Guessing Game +Chapter 3: Common Programming Concepts +Chapter 4: Understanding Ownership +Chapter 5: Structs +Chapter 6: Enums and Pattern Matching +Chapter 7: Modules +Chapter 8: Common Collections +Chapter 9: Error Handling +Chapter 10: Generic Types, Traits, and Lifetimes +Chapter 11: Testing +Chapter 12: An Input/Output Project +Chapter 13: Iterators and Closures +Chapter 14: More About Cargo and Crates.io +Chapter 15: Smart Pointers +Chapter 16: Concurrency +Chapter 17: Is Rust Object Oriented? +Chapter 18: Patterns +Chapter 19: More About Lifetimes +Chapter 20: Advanced Type System Features +Appendix A: Keywords +Appendix B: Operators and Symbols +Appendix C: Derivable Traits +Appendix D: Macros +Index + +``` + +[The Rust Programming Language][7] takes you from basic installation and language syntax to complex topics, such as modules, error handling, crates (synonymous with a ‘library’ or ‘package’ in other languages), modules (allowing you to partition your code within the crate itself), lifetimes, etc. + +Probably the most important thing to say is that the book can move you from basic programming skills to building and compiling complex, secure and very useful programs. + +### Wrap-up + +If you're ready to get into some serious programming with a language that's well worth the time and effort to study and becoming increasingly popular, Rust is a good bet! + +Join the Network World communities on [Facebook][9] and [LinkedIn][10] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3308162/linux/why-you-should-try-rust.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[1]: https://insights.stackoverflow.com/survey/2016#technology-most-loved-dreaded-and-wanted +[2]: https://insights.stackoverflow.com/survey/2017#technology-most-loved-dreaded-and-wanted-languages +[3]: https://insights.stackoverflow.com/survey/2018#technology-most-loved-dreaded-and-wanted-languages +[4]: https://www.rust-lang.org/en-US/community.html +[5]: https://doc.rust-lang.org/reference/type-system.html +[6]: https://images.idgesg.net/images/article/2018/09/rust-programming-language_book-cover-100773679-small.jpg +[7]: https://nostarch.com/Rust +[8]: https://doc.rust-lang.org/book/2018-edition/index.html +[9]: https://www.facebook.com/NetworkWorld/ +[10]: https://www.linkedin.com/company/network-world From e0285aa5ab48a6ce7082ae736f307391f2291387 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 26 Sep 2018 14:50:23 +0800 Subject: [PATCH 429/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Taking=20the=20Au?= =?UTF-8?q?diophile=20Linux=20distro=20for=20a=20spin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... the Audiophile Linux distro for a spin.md | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 sources/tech/20180925 Taking the Audiophile Linux distro for a spin.md diff --git a/sources/tech/20180925 Taking the Audiophile Linux distro for a spin.md b/sources/tech/20180925 Taking the Audiophile Linux distro for a spin.md new file mode 100644 index 0000000000..1c813cb30a --- /dev/null +++ b/sources/tech/20180925 Taking the Audiophile Linux distro for a spin.md @@ -0,0 +1,161 @@ +Taking the Audiophile Linux distro for a spin +====== + +This lightweight open source audio OS offers a rich feature set and high-quality digital sound. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LIFE_givingmusic.jpg?itok=xVKF1dlb) + +I recently stumbled on the [Audiophile Linux project][1], one of a number of special-purpose music-oriented Linux distributions. Audiophile Linux: + + 1. is based on [ArchLinux][2] + + 2. provides a real-time Linux kernel customized for playing music + + 3. uses the lightweight [Fluxbox][3] window manager + + 4. avoids unnecessary daemons and services + + 5. allows playback of DSF and supports the usual PCM formats + + 6. supports various music players, including one of my favorite combos: MPD + Cantata + + + + +The Audiophile Linux site hasn’t shown a lot of activity since April 2017, but it does contain some updates and commentary from this year. Given its orientation and feature set, I decided to take it for a spin on my old Toshiba laptop. + +### Installing Audiophile Linux + +The site provides [a clear set of install instructions][4] that require the use of the terminal. The first step after downloading the .iso is burning it to a USB stick. I used the GNOME Disks utility’s Restore Disk Image for this purpose. Once I had the USB set up and ready to go, I plugged it into the Toshiba and booted it. When the splash screen came up, I set the boot device to the USB stick and a minute or so later, the Arch Grub menu was displayed. I booted Linux from that menu, which put me in a root shell session, where I could carry out the install to the hard drive: + +![](https://opensource.com/sites/default/files/uploads/root_shell_session.jpg) + +I was willing to sacrifice the 320-GB hard drive in the Toshiba for this test, so I was able to use the previous Linux partitioning (from the last experiment). I then proceeded as follows: + +``` +fdisk -l              # find the disk / partition, in my case /dev/sda and /dev/sda1 +mkfs.ext4 /dev/sda1   # build the ext4 filesystem in the root partition +mount /dev/sda1 /mnt  # mount the new file system +time cp -ax / /mnt    # copy over the OS +        # reported back cp -ax / /mnt 1.36s user 136.54s system 88% cpu 2:36.37 total +arch-chroot /mnt /bin/bash # run in the new system root +cd /etc/apl-files +./runme.sh            # do the rest of the install +grub-install --target=i386-pc /dev/sda # make the new OS bootable part 1 +grub-mkconfig -o /boot/grub/grub.cfg   # part 2 +passwd root           # set root’s password +ln -s /usr/share/zoneinfo/America/Vancouver /etc/localtime # set my time zone +hwclock --systohc --utc # update the hardware clock +./autologin.sh        # set the system up so that it automatically logs in +exit                  # done with the chroot session +genfstab -U /mnt >> /mnt/etc/fstab # create the fstab for the new system +``` + +At that point, I was ready to boot the new operating system, so I did—and voilà, up came the system! + +![](https://opensource.com/sites/default/files/uploads/audiophile_linux.jpg) + +### Finishing the configuration + +Once Audiophile Linux was up and running, I needed to [finish the configuration][4] and load some music. Grabbing the application menu by right-clicking on the screen background, I started **X-terminal** and entered the remaining configuration commands: + +``` +ping 8.8.8.8 # check connectivity (works fine) +su # become root +pacman-key –init # create pacman’s encryption data part 1 +pacman-key --populate archlinux # part 2 +pacman -Sy # part 3 +pacman -S archlinux-keyring # part 4 +``` + +At this point, the install instructions note that there is a problem with updating software with the `pacman -Suy` command, and that first the **libxfont** package must be removed using `pacman -Rc libxfont`. I followed this instruction, but the second run of `pacman -Suy` led to another dependency error, this time with the **x265** package. I looked further down the page in the install instructions and saw this recommendation: + +_Again there is an error in upstream repo of Arch packages. Try to remove conflicting packages with “pacman -R ffmpeg2.8” and then do pacman -Suy later._ + +I chose to use `pacman -Rc ffmpeg2.8`, and then reran `pacman -Suy`. (As an aside, typing all these **pacman** commands made me realize how familiar I am with **apt** , and how much this whole process made me feel like I was trying to write an email in some language I don’t know using an online translator.) + +To be clear, here was my sequence of operations: + +``` +pacman -Suy # failed +pacman -Rc libxfont +pacman -Suy # failed, again +pacman -Rc ffmpeg2.8 # uninstalled Cantata, have to fix that later! +pacman -Suy # worked! +``` + +Now back to the rest of the instructions: + +``` +pacman -S terminus-font +pacman -S xorg-server +pacman -S firefox # the docs suggested installing chromium but I prefer FF +reboot +``` + +And the last little bit, fiddling `/etc/fstab` to avoid access time modifications. I also thought I’d try installing [Cantata][5] once more using `pacman -S cantata`, and it worked just fine (no `ffmpeg2.8` problems). + +I found the `DAC Setup > List cards` on the application menu, which showed the built-in Intel sound hardware plus my USB DAC that I had plugged in earlier. Then I selected `DAC Setup > Edit mpd.conf` and adjusted the output stanza of `mpd.conf`. I used `scp` to copy an album over from my main music server into **~/Music**. And finally, I used the application menu `DAC Setup > Restart mpd`. And… nothing… the **conky** info on the screen indicated “MPD not responding”. So I scanned again through the comments at the bottom of the installation instructions and spotted this: + +_After every update of mpd, you have to do: +1. Become root +``` +$su +``` +2. run this commands +``` +# cat /etc/apl-files/mpd.service > /usr/lib/systemd/system/mpd.service +# systemctl daemon-reload +# systemctl restart mpd.service_ +``` +_And this will be fixed._ + +![](https://opensource.com/sites/default/files/uploads/library.png) + +And it works! Right now I’m enjoying [Nils Frahm’s "All Melody"][6] from the album of the same name, playing over my [Schiit Fulla 2][7] in glorious high-resolution sound. Time to copy in some more music so I can give it a better listen. + +So… does it sound better than the same DAC connected to my regular work laptop and playing back through [Guayadeque][8] or [GogglesMM][9]? I’m going to see if I can detect a difference at some point, but right now all I can say is it sounds just wonderful; plus [I like the Cantata / mpd combo a lot][10], and I really enjoy having the heads-up display in the upper right of the screen. + +### As for the music... + +The other day I was reorganizing my work hard drive a bit and I decided to check to make sure that 1) all the music on it was also on the house music servers and 2) _vice versa_ (gotta set up `rsync` for that purpose one day soon). In doing so, I found some music I hadn’t enjoyed for a while, which is kind of like buying a brand-new album, except it costs much less. + +[Six Degrees Records][11] has long been one of my favorite purveyors of unusual music. A great example is the group [Zuco 103][12]'s album [Whaa!][13], whose CD version I purchased from Six Degrees’ online store some years ago. Check out [this fun documentary about the group][14]. + + + +For a completely different experience, take a look at the [Ragazze Quartet’s performance of Terry Riley’s "Four Four Three."][15] I picked up ahigh-resolutionn version of this fascinating music from [Channel Classics][16], which operates a Linux-friendly download store (no bloatware to install on your computer). + +And finally, I was saddened to hear of the recent passing of [Rachid Taha][17], whose wonderful blend of North African and French musical traditions, along with his frank confrontation of the challenges of being North African and living in Europe, has made some powerful—and fun—music. Check out [Taha’s version of "Rock the Casbah."][18] I have a few of his songs scattered around various compilation albums, and some time ago bought the CD version of [Rachid Taha: The Definitive Collection][19], which I’ve been enjoying again recently. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/audiophile-linux-distro + +作者:[Chris Hermansen][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/clhermansen +[1]: https://www.ap-linux.com/ +[2]: https://www.archlinux.org/ +[3]: http://fluxbox.org/ +[4]: https://www.ap-linux.com/documentation/ap-linux-v4-install-instructions/ +[5]: https://github.com/CDrummond/cantata +[6]: https://www.youtube.com/watch?v=1PTj1qIqcWM +[7]: https://www.audiostream.com/content/listening-session-history-lesson-bw-schiit-and-shinola-together-last +[8]: http://www.guayadeque.org/ +[9]: https://gogglesmm.github.io/ +[10]: https://opensource.com/article/17/8/cantata-music-linux +[11]: https://www.sixdegreesrecords.com/ +[12]: https://www.sixdegreesrecords.com/?s=zuco+103 +[13]: https://www.musicomh.com/reviews/albums/zuco-103-whaa +[14]: https://www.youtube.com/watch?v=ncaqD92cjQ8 +[15]: https://www.youtube.com/watch?v=DwMaO7bMVD4 +[16]: https://www.channelclassics.com/catalogue/37816-Riley-Four-Four-Three/ +[17]: https://en.wikipedia.org/wiki/Rachid_Taha +[18]: https://www.youtube.com/watch?v=n1p_dkJo6Y8 +[19]: http://www.bbc.co.uk/music/reviews/26rg/ From 02b69bf88a8005574b7cb77cd11908d2bb97e1b5 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 26 Sep 2018 14:58:15 +0800 Subject: [PATCH 430/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Clinews=20?= =?UTF-8?q?=E2=80=93=20Read=20News=20And=20Latest=20Headlines=20From=20Com?= =?UTF-8?q?mandline?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...s And Latest Headlines From Commandline.md | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 sources/tech/20180921 Clinews - Read News And Latest Headlines From Commandline.md diff --git a/sources/tech/20180921 Clinews - Read News And Latest Headlines From Commandline.md b/sources/tech/20180921 Clinews - Read News And Latest Headlines From Commandline.md new file mode 100644 index 0000000000..24ae89f461 --- /dev/null +++ b/sources/tech/20180921 Clinews - Read News And Latest Headlines From Commandline.md @@ -0,0 +1,136 @@ +Clinews – Read News And Latest Headlines From Commandline +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/clinews-720x340.jpeg) + +A while ago, we have written about a CLI news client named [**InstantNews**][1] that helps you to read news and latest headlines from commandline instantly. Today, I stumbled upon a similar utility named **Clinews** which serves the same purpose – reading news and latest headlines from popular websites, blogs from Terminal. You don’t need to install GUI applications or mobile apps. You can read what’s happening in the world right from your Terminal. It is free, open source utility written using **NodeJS**. + +### Installing Clinews + +Since Clinews is written using NodeJS, you can install it using NPM package manager. If you haven’t install NodeJS, install it as described in the following link. + +Once node installed, run the following command to install Clinews: + +``` +$ npm i -g clinews +``` + +You can also install Clinews using **Yarn** : + +``` +$ yarn global add clinews +``` + +Yarn itself can installed using npm + +``` +$ npm -i yarn +``` + +### Configure News API + +Clinews retrieves all news headlines from [**News API**][2]. News API is a simple and easy-to-use API that returns JSON metadata for the headlines currently published on a range of news sources and blogs. It currently provides live headlines from 70 popular sources, including Ars Technica, BBC, Blooberg, CNN, Daily Mail, Engadget, ESPN, Financial Times, Google News, hacker News, IGN, Mashable, National Geographic, Reddit r/all, Reuters, Speigel Online, Techcrunch, The Guardian, The Hindu, The Huffington Post, The Newyork Times, The Next Web, The Wall street Journal, USA today and [**more**][3]. + +First, you need an API key from News API. Go to [**https://newsapi.org/register**][4] URL and register a free account to get the API key. + +Once you got the API key from News API site, edit your **.bashrc** file: + +``` +$ vi ~/.bashrc + +``` + +Add newsapi API key at the end like below: + +``` +export IN_API_KEY="Paste-API-key-here" + +``` + +Please note that you need to paste the key inside the double quotes. Save and close the file. + +Run the following command to update the changes. + +``` +$ source ~/.bashrc + +``` + +Done. Now let us go ahead and fetch the latest headlines from new sources. + +### Read News And Latest Headlines From Commandline + +To read news and latest headlines from specific new source, for example **The Hindu** , run: + +``` +$ news fetch the-hindu + +``` + +Here, **“the-hindu”** is the new source id (fetch id). + +The above command will fetch latest 10 headlines from The Hindu news portel and display them in the Terminal. Also, it displays a brief description of the news, the published date and time, and the actual link to the source. + +**Sample output:** + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/clinews-1.png) + +To read a news in your browser, hold Ctrl key and click on the URL. It will open in your default web browser. + +To view all the sources you can get news from, run: + +``` +$ news sources + +``` + +**Sample output:** + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/clinews-2.png) + +As you see in the above screenshot, Clinews lists all news sources including the name of the news source, fetch id, description of the site, website URL and the country where it is located. As of writing this guide, Clinews currently supports 70+ news sources. + +Clinews can also able to search for news stories across all sources matching search criteria/term. Say for example, to list all news stories with titles containing the words **“Tamilnadu”** , use the following command: + +``` +$ news search "Tamilnadu" +``` + +This command will scrap all news sources for stories that match term **Tamilnadu**. + +Clinews has some extra flags that helps you to + + * limit the amount of news stories you want to see, + * sort news stories (top, latest, popular), + * display news stories category wise (E.g. business, entertainment, gaming, general, music, politics, science-and-nature, sport, technology) + + + +For more details, see the help section: + +``` +$ clinews -h +``` + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/clinews-read-news-and-latest-headlines-from-commandline/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://www.ostechnix.com/get-news-instantly-commandline-linux/ +[2]: https://newsapi.org/ +[3]: https://newsapi.org/sources +[4]: https://newsapi.org/register From d3f075d5e18638fbd3054c4536d78bae33961719 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 26 Sep 2018 14:59:14 +0800 Subject: [PATCH 431/455] PRF:20180907 What do open source and cooking have in common.md @sd886393 --- ... open source and cooking have in common.md | 31 ++++++++----------- 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/translated/talk/20180907 What do open source and cooking have in common.md b/translated/talk/20180907 What do open source and cooking have in common.md index 2f5f150f1a..ae99bed725 100644 --- a/translated/talk/20180907 What do open source and cooking have in common.md +++ b/translated/talk/20180907 What do open source and cooking have in common.md @@ -3,48 +3,46 @@ ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/waffles-recipe-eggs-cooking-mix.png?itok=Fp06VOBx) -有什么好的方法,既可以宣传开源的精神又不用写代码呢?这里有个点子:“开源食堂”。在过去的8年间,这就是我们在慕尼黑做的事情。 +有什么好的方法,既可以宣传开源的精神又不用写代码呢?这里有个点子:“开源食堂open source cooking”。在过去的 8 年间,这就是我们在慕尼黑做的事情。 开源食堂已经是我们常规的开源宣传活动了,因为我们发现开源与烹饪有很多共同点。 ### 协作烹饪 -[慕尼黑开源聚会][1]自2009年7月在[Café Netzwerk][2]创办以来,已经组织了若干次活动,活动一般在星期五的晚上组织。该聚会为开源项目工作者或者开源爱好者们提供了相互认识的方式。我们的信条是:“每四周的星期五属于免费软件(Every fourth Friday for free software)”。当然在一些周末,我们还会举办一些研讨会。那之后,我们很快加入了很多其他的活动,包括白香肠早餐、桑拿与烹饪活动。 +[慕尼黑开源聚会][1]自 2009 年 7 月在 [Café Netzwerk][2] 创办以来,已经组织了若干次活动,活动一般在星期五的晚上组织。该聚会为开源项目工作者或者开源爱好者们提供了相互认识的方式。我们的信条是:“每四周的星期五属于自由软件Every fourth Friday for free software”。当然在一些周末,我们还会举办一些研讨会。那之后,我们很快加入了很多其他的活动,包括白香肠早餐、桑拿与烹饪活动。 -事实上,第一次开源烹饪聚会举办的有些混乱,但是我们经过这8年来以及15次的组织,已经可以为25-30个与会者提供丰盛的美食了。 +事实上,第一次开源烹饪聚会举办的有些混乱,但是我们经过这 8 年来以及 15 次的活动,已经可以为 25-30 个与会者提供丰盛的美食了。 回头看看这些夜晚,我们愈发发现共同烹饪与开源社区协作之间,有很多相似之处。 -### 烹饪步骤中的开源精神 +### 烹饪步骤中的自由开源精神 这里是几个烹饪与开源精神相同的地方: * 我们乐于合作且朝着一个共同的目标前进 - * 我们成立社区组织 + * 我们成了一个社区 * 由于我们有相同的兴趣与爱好,我们可以更多的了解我们自身与他人,并且可以一同协作 - * 我们也会犯错,但我们会从错误中学习,并为了共同的李医生去分享关于错误的经验,从而让彼此避免再犯相同的错误 + * 我们也会犯错,但我们会从错误中学习,并为了共同的利益去分享关于错误的经验,从而让彼此避免再犯相同的错误 * 每个人都会贡献自己擅长的事情,因为每个人都有自己的一技之长 * 我们会动员其他人去做出贡献并加入到我们之中 * 虽说协作是关键,但难免会有点混乱 * 每个人都会从中收益 - - ### 烹饪中的开源气息 同很多成功的开源聚会一样,开源烹饪也需要一些协作和组织结构。在每次活动之前,我们会组织所有的成员对菜单进行投票,而不单单是直接给每个人分一角披萨,我们希望真正的作出一道美味,迄今为止我们做过日本、墨西哥、匈牙利、印度等地区风味的美食,限于篇幅就不一一列举了。 -就像在生活中,共同烹饪一样需要各个成员之间相互的尊重和理解,所以我们也会试着为素食主义者、食物过敏者、或者对某些事物有偏好的人提供针对性的事物。正式开始烹饪之前,在家预先进行些小规模的测试会非常有帮助(乐趣!) +就像在生活中,共同烹饪同样需要各个成员之间相互的尊重和理解,所以我们也会试着为素食主义者、食物过敏者、或者对某些事物有偏好的人提供针对性的事物。正式开始烹饪之前,在家预先进行些小规模的测试会非常有帮助(和乐趣!) -可扩展性也很重要,在杂货店采购必要的食材很容易就消耗掉3个小时。所以我们使用一些表格工具(自然是 LibreOffice Calc)来做一些所需要的食材以及相应的成本。 +可扩展性也很重要,在杂货店采购必要的食材很容易就消耗掉 3 个小时。所以我们使用一些表格工具(自然是 LibreOffice Calc)来做一些所需要的食材以及相应的成本。 -我们会同志愿者一起,为每次晚餐准备一个“包管理器”,从而及时的制作出菜单并在问题产生的时候寻找一些独到的解决方法。 +我们会同志愿者一起,对于每次晚餐我们都有一个“包维护者”,从而及时的制作出菜单并在问题产生的时候寻找一些独到的解决方法。 虽然不是所有人都是大厨,但是只要给与一些帮助,并比较合理的分配任务和责任,就很容易让每个人都参与其中。某种程度上来说,处理 18kg 的西红柿和 100 个鸡蛋都不会让你觉得是件难事,相信我!唯一的限制是一个烤炉只有四个灶,所以可能是时候对基础设施加大投入了。 -发布有时间要求,当然要求也不那么严格,我们通常会在21:30和01:30之间的相当“灵活”时间内供应主菜,即便如此,这个时间也是硬性的发布规定。 +发布有时间要求,当然要求也不那么严格,我们通常会在 21:30 和 01:30 之间的相当“灵活”时间内供应主菜,即便如此,这个时间也是硬性的发布规定。 -最后,想很多开源项目一样,烹饪文档同样有提升的空间。类似洗碟子这样的扫尾工作同样也有可优化的地方。 +最后,像很多开源项目一样,烹饪文档同样有提升的空间。类似洗碟子这样的扫尾工作同样也有可优化的地方。 ### 未来的一些新功能点 @@ -54,21 +52,18 @@ * 购买和烹饪一个价值 700 欧元的大南瓜,并且 * 找家可以为我们采购提供折扣的商店 - 最后一点,也是开源软件的动机:永远记住,还有一些人们生活在阴影中,他们为没有同等的权限去访问资源而苦恼着。我们如何通过开源的精神去帮助他们呢? 一想到这点,我便期待这下一次的开源烹饪聚会。如果读了上面的东西让你觉得不够完美,并且想自己运作这样的活动,我们非常乐意你能够借鉴我们的想法,甚至抄袭一个。我们也乐意你能够参与到我们其中,甚至做一些演讲和问答。 -Article originally appeared on [blog.effenberger.org][3]. Reprinted with permission. - -------------------------------------------------------------------------------- via: https://opensource.com/article/18/9/open-source-cooking 作者:[Florian Effenberger][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/sd886393) -校对:[校对者ID](https://github.com/校对者ID) +译者:[sd886393](https://github.com/sd886393) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2dd5f756e62d138abe843d914a3be0ed383e018b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 26 Sep 2018 14:59:32 +0800 Subject: [PATCH 432/455] PUB:20180907 What do open source and cooking have in common.md @sd886393 https://linux.cn/article-10052-1.html --- .../20180907 What do open source and cooking have in common.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20180907 What do open source and cooking have in common.md (100%) diff --git a/translated/talk/20180907 What do open source and cooking have in common.md b/published/20180907 What do open source and cooking have in common.md similarity index 100% rename from translated/talk/20180907 What do open source and cooking have in common.md rename to published/20180907 What do open source and cooking have in common.md From f1e6337f2faa1d4b7d370ffa77ff197cb13d576e Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 26 Sep 2018 15:19:09 +0800 Subject: [PATCH 433/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Find?= =?UTF-8?q?=20Out=20Which=20Port=20Number=20A=20Process=20Is=20Using=20In?= =?UTF-8?q?=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Port Number A Process Is Using In Linux.md | 278 ++++++++++++++++++ 1 file changed, 278 insertions(+) create mode 100644 sources/tech/20180924 How To Find Out Which Port Number A Process Is Using In Linux.md diff --git a/sources/tech/20180924 How To Find Out Which Port Number A Process Is Using In Linux.md b/sources/tech/20180924 How To Find Out Which Port Number A Process Is Using In Linux.md new file mode 100644 index 0000000000..21b6633730 --- /dev/null +++ b/sources/tech/20180924 How To Find Out Which Port Number A Process Is Using In Linux.md @@ -0,0 +1,278 @@ +How To Find Out Which Port Number A Process Is Using In Linux +====== +As a Linux administrator, you should know whether the corresponding service is binding/listening with correct port or not. + +This will help you to easily troubleshoot further when you are facing port related issues. + +A port is a logical connection that identifies a specific process on Linux. There are two kind of port are available like, physical and software. + +Since Linux operating system is a software hence, we are going to discuss about software port. + +Software port is always associated with an IP address of a host and the relevant protocol type for communication. The port is used to distinguish the application. + +Most of the network related services have to open up a socket to listen incoming network requests. Socket is unique for every service. + +**Suggested Read :** +**(#)** [4 Easiest Ways To Find Out Process ID (PID) In Linux][1] +**(#)** [3 Easy Ways To Kill Or Terminate A Process In Linux][2] + +Socket is combination of IP address, software Port and protocol. The port numbers area available for both TCP and UDP protocol. + +The Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP) use port numbers for communication. It is a value from 0 to 65535. + +Below are port assignments categories. + + * `0-1023:` Well Known Ports or System Ports + * `1024-49151:` Registered Ports for applications + * `49152-65535:` Dynamic Ports or Private Ports + + + +You can check the details of the reserved ports in the /etc/services file on Linux. + +``` +# less /etc/services +# /etc/services: +# $Id: services,v 1.55 2013/04/14 ovasik Exp $ +# +# Network services, Internet style +# IANA services version: last updated 2013-04-10 +# +# Note that it is presently the policy of IANA to assign a single well-known +# port number for both TCP and UDP; hence, most entries here have two entries +# even if the protocol doesn't support UDP operations. +# Updated from RFC 1700, ``Assigned Numbers'' (October 1994). Not all ports +# are included, only the more common ones. +# +# The latest IANA port assignments can be gotten from +# http://www.iana.org/assignments/port-numbers +# The Well Known Ports are those from 0 through 1023. +# The Registered Ports are those from 1024 through 49151 +# The Dynamic and/or Private Ports are those from 49152 through 65535 +# +# Each line describes one service, and is of the form: +# +# service-name port/protocol [aliases ...] [# comment] + +tcpmux 1/tcp # TCP port service multiplexer +tcpmux 1/udp # TCP port service multiplexer +rje 5/tcp # Remote Job Entry +rje 5/udp # Remote Job Entry +echo 7/tcp +echo 7/udp +discard 9/tcp sink null +discard 9/udp sink null +systat 11/tcp users +systat 11/udp users +daytime 13/tcp +daytime 13/udp +qotd 17/tcp quote +qotd 17/udp quote +msp 18/tcp # message send protocol (historic) +msp 18/udp # message send protocol (historic) +chargen 19/tcp ttytst source +chargen 19/udp ttytst source +ftp-data 20/tcp +ftp-data 20/udp +# 21 is registered to ftp, but also used by fsp +ftp 21/tcp +ftp 21/udp fsp fspd +ssh 22/tcp # The Secure Shell (SSH) Protocol +ssh 22/udp # The Secure Shell (SSH) Protocol +telnet 23/tcp +telnet 23/udp +# 24 - private mail system +lmtp 24/tcp # LMTP Mail Delivery +lmtp 24/udp # LMTP Mail Delivery + +``` + +This can be achieved using the below six methods. + + * `ss:` ss is used to dump socket statistics. + * `netstat:` netstat is displays a list of open sockets. + * `lsof:` lsof – list open files. + * `fuser:` fuser – list process IDs of all processes that have one or more files open + * `nmap:` nmap – Network exploration tool and security / port scanner + * `systemctl:` systemctl – Control the systemd system and service manager + + + +In this tutorial we are going to find out which port number the SSHD daemon is using. + +### Method-1: Using ss Command + +ss is used to dump socket statistics. It allows showing information similar to netstat. It can display more TCP and state informations than other tools. + +It can display stats for all kind of sockets such as PACKET, TCP, UDP, DCCP, RAW, Unix domain, etc. + +``` +# ss -tnlp | grep ssh +LISTEN 0 128 *:22 *:* users:(("sshd",pid=997,fd=3)) +LISTEN 0 128 :::22 :::* users:(("sshd",pid=997,fd=4)) +``` + +Alternatively you can check this with port number as well. + +``` +# ss -tnlp | grep ":22" +LISTEN 0 128 *:22 *:* users:(("sshd",pid=997,fd=3)) +LISTEN 0 128 :::22 :::* users:(("sshd",pid=997,fd=4)) +``` + +### Method-2: Using netstat Command + +netstat – Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. + +By default, netstat displays a list of open sockets. If you don’t specify any address families, then the active sockets of all configured address families will be printed. This program is obsolete. Replacement for netstat is ss. + +``` +# netstat -tnlp | grep ssh +tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 997/sshd +tcp6 0 0 :::22 :::* LISTEN 997/sshd +``` + +Alternatively you can check this with port number as well. + +``` +# netstat -tnlp | grep ":22" +tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1208/sshd +tcp6 0 0 :::22 :::* LISTEN 1208/sshd +``` + +### Method-3: Using lsof Command + +lsof – list open files. The Linux lsof command lists information about files that are open by processes running on the system. + +``` +# lsof -i -P | grep ssh +COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME +sshd 11584 root 3u IPv4 27625 0t0 TCP *:22 (LISTEN) +sshd 11584 root 4u IPv6 27627 0t0 TCP *:22 (LISTEN) +sshd 11592 root 3u IPv4 27744 0t0 TCP vps.2daygeek.com:ssh->103.5.134.167:49902 (ESTABLISHED) +``` + +Alternatively you can check this with port number as well. + +``` +# lsof -i tcp:22 +COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME +sshd 1208 root 3u IPv4 20919 0t0 TCP *:ssh (LISTEN) +sshd 1208 root 4u IPv6 20921 0t0 TCP *:ssh (LISTEN) +sshd 11592 root 3u IPv4 27744 0t0 TCP vps.2daygeek.com:ssh->103.5.134.167:49902 (ESTABLISHED) +``` + +### Method-4: Using fuser Command + +The fuser utility shall write to standard output the process IDs of processes running on the local system that have one or more named files open. + +``` +# fuser -v 22/tcp + USER PID ACCESS COMMAND +22/tcp: root 1208 F.... sshd + root 12388 F.... sshd + root 49339 F.... sshd +``` + +### Method-5: Using nmap Command + +Nmap (“Network Mapper”) is an open source tool for network exploration and security auditing. It was designed to rapidly scan large networks, although it works fine against single hosts. + +Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running, what type of packet filters/firewalls are in use, and dozens of other characteristics. + +``` +# nmap -sV -p 22 localhost + +Starting Nmap 6.40 ( http://nmap.org ) at 2018-09-23 12:36 IST +Nmap scan report for localhost (127.0.0.1) +Host is up (0.000089s latency). +Other addresses for localhost (not scanned): 127.0.0.1 +PORT STATE SERVICE VERSION +22/tcp open ssh OpenSSH 7.4 (protocol 2.0) + +Service detection performed. Please report any incorrect results at http://nmap.org/submit/ . +Nmap done: 1 IP address (1 host up) scanned in 0.44 seconds +``` + +### Method-6: Using systemctl Command + +systemctl – Control the systemd system and service manager. This is the replacement of old SysV init system management and most of the modern Linux operating systems were adapted systemd. + +**Suggested Read :** +**(#)** [chkservice – A Tool For Managing Systemd Units From Linux Terminal][3] +**(#)** [How To Check All Running Services In Linux][4] + +``` +# systemctl status sshd +● sshd.service - OpenSSH server daemon + Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) + Active: active (running) since Sun 2018-09-23 02:08:56 EDT; 6h 11min ago + Docs: man:sshd(8) + man:sshd_config(5) + Main PID: 11584 (sshd) + CGroup: /system.slice/sshd.service + └─11584 /usr/sbin/sshd -D + +Sep 23 02:08:56 vps.2daygeek.com systemd[1]: Starting OpenSSH server daemon... +Sep 23 02:08:56 vps.2daygeek.com sshd[11584]: Server listening on 0.0.0.0 port 22. +Sep 23 02:08:56 vps.2daygeek.com sshd[11584]: Server listening on :: port 22. +Sep 23 02:08:56 vps.2daygeek.com systemd[1]: Started OpenSSH server daemon. +Sep 23 02:09:15 vps.2daygeek.com sshd[11589]: Connection closed by 103.5.134.167 port 49899 [preauth] +Sep 23 02:09:41 vps.2daygeek.com sshd[11592]: Accepted password for root from 103.5.134.167 port 49902 ssh2 +``` + +The above out will be showing the actual listening port of SSH service when you start the SSHD service recently. Otherwise it won’t because it updates recent logs in the output frequently. + +``` +# systemctl status sshd +● sshd.service - OpenSSH server daemon + Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) + Active: active (running) since Thu 2018-09-06 07:40:59 IST; 2 weeks 3 days ago + Docs: man:sshd(8) + man:sshd_config(5) + Main PID: 1208 (sshd) + CGroup: /system.slice/sshd.service + ├─ 1208 /usr/sbin/sshd -D + ├─23951 sshd: [accepted] + └─23952 sshd: [net] + +Sep 23 12:50:36 vps.2daygeek.com sshd[23909]: Invalid user pi from 95.210.113.142 port 51666 +Sep 23 12:50:36 vps.2daygeek.com sshd[23909]: input_userauth_request: invalid user pi [preauth] +Sep 23 12:50:37 vps.2daygeek.com sshd[23911]: pam_unix(sshd:auth): check pass; user unknown +Sep 23 12:50:37 vps.2daygeek.com sshd[23911]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=95.210.113.142 +Sep 23 12:50:37 vps.2daygeek.com sshd[23909]: pam_unix(sshd:auth): check pass; user unknown +Sep 23 12:50:37 vps.2daygeek.com sshd[23909]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=95.210.113.142 +Sep 23 12:50:39 vps.2daygeek.com sshd[23911]: Failed password for invalid user pi from 95.210.113.142 port 51670 ssh2 +Sep 23 12:50:39 vps.2daygeek.com sshd[23909]: Failed password for invalid user pi from 95.210.113.142 port 51666 ssh2 +Sep 23 12:50:40 vps.2daygeek.com sshd[23911]: Connection closed by 95.210.113.142 port 51670 [preauth] +Sep 23 12:50:40 vps.2daygeek.com sshd[23909]: Connection closed by 95.210.113.142 port 51666 [preauth] +``` + +Most of the time the above output won’t shows the process actual port number. in this case i would suggest you to check the details using the below command from the journalctl log file. + +``` +# journalctl | grep -i "openssh\|sshd" +Sep 23 02:08:56 vps138235.vps.ovh.ca sshd[997]: Received signal 15; terminating. +Sep 23 02:08:56 vps138235.vps.ovh.ca systemd[1]: Stopping OpenSSH server daemon... +Sep 23 02:08:56 vps138235.vps.ovh.ca systemd[1]: Starting OpenSSH server daemon... +Sep 23 02:08:56 vps138235.vps.ovh.ca sshd[11584]: Server listening on 0.0.0.0 port 22. +Sep 23 02:08:56 vps138235.vps.ovh.ca sshd[11584]: Server listening on :: port 22. +Sep 23 02:08:56 vps138235.vps.ovh.ca systemd[1]: Started OpenSSH server daemon. +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-find-out-which-port-number-a-process-is-using-in-linux/ + +作者:[Prakash Subramanian][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/prakash/ +[1]: https://www.2daygeek.com/how-to-check-find-the-process-id-pid-ppid-of-a-running-program-in-linux/ +[2]: https://www.2daygeek.com/kill-terminate-a-process-in-linux-using-kill-pkill-killall-command/ +[3]: https://www.2daygeek.com/chkservice-a-tool-for-managing-systemd-units-from-linux-terminal/ +[4]: https://www.2daygeek.com/how-to-check-all-running-services-in-linux/ From 56e04296329b5b4357b9380e1584edc0adbf91a1 Mon Sep 17 00:00:00 2001 From: HankChow <280630620@qq.com> Date: Wed, 26 Sep 2018 15:26:12 +0800 Subject: [PATCH 434/455] hankchow translating --- ...ke The Output Of Ping Command Prettier And Easier To Read.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md b/sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md index 39ca57bc43..7ef713eae4 100644 --- a/sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md +++ b/sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md @@ -1,3 +1,5 @@ +HankChow translating + Make The Output Of Ping Command Prettier And Easier To Read ====== From 757a39980406948b0b921d0398489c9b71f88c42 Mon Sep 17 00:00:00 2001 From: belitex Date: Wed, 26 Sep 2018 17:04:20 +0800 Subject: [PATCH 435/455] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90:?= =?UTF-8?q?=208=20Python=20packages=20that=20will=20simplify=20your=20life?= =?UTF-8?q?=20with=20Django?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...hat will simplify your life with Django.md | 124 ------------------ ...hat will simplify your life with Django.md | 121 +++++++++++++++++ 2 files changed, 121 insertions(+), 124 deletions(-) delete mode 100644 sources/tech/20180920 8 Python packages that will simplify your life with Django.md create mode 100644 translated/tech/20180920 8 Python packages that will simplify your life with Django.md diff --git a/sources/tech/20180920 8 Python packages that will simplify your life with Django.md b/sources/tech/20180920 8 Python packages that will simplify your life with Django.md deleted file mode 100644 index e341a8b0a6..0000000000 --- a/sources/tech/20180920 8 Python packages that will simplify your life with Django.md +++ /dev/null @@ -1,124 +0,0 @@ -belitex 翻译中 -8 Python packages that will simplify your life with Django -====== - -This month's Python column looks at Django packages that will benefit your work, personal, or side projects. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/water-stone-balance-eight-8.png?itok=1aht_V5V) - -Django developers, we're devoting this month's Python column to packages that will help you. These are our favorite [Django][1] libraries for saving time, cutting down on boilerplate code, and generally simplifying our lives. We've got six packages for Django apps and two for Django's REST Framework, and we're not kidding when we say these packages show up in almost every project we work on. - -But first, see our tips for making the [Django Admin more secure][2] and an article on 5 favorite [open source Django packages][3]. - -### A kitchen sink of useful time-savers: django-extensions - -[Django-extensions][4] is a favorite Django package chock full of helpful tools like these management commands: - - * **shell_plus** starts the Django shell with all your database models already loaded. No more importing from several different apps to test one complex relationship! - * **clean_pyc** removes all .pyc projects from everywhere inside your project directory. - * **create_template_tags** creates a template tag directory structure inside the app you specify. - * **describe_form** displays a form definition for a model, which you can then copy/paste into forms.py. (Note that this produces a regular Django form, not a ModelForm.) - * **notes** displays all comments with stuff like TODO, FIXME, etc. throughout your project. - - - * **TimeStampedModel** : This base class includes the fields **created** and **modified** and a **save()** method that automatically updates these fields appropriately. - * **ActivatorModel** : If your model will need fields like **status** , **activate_date** , and **deactivate_date** , use this base class. It comes with a manager that enables **.active()** and **.inactive()** querysets. - * **TitleDescriptionModel** and **TitleSlugDescriptionModel** : These include the **title** and **description** fields, and the latter also includes a **slug** field. The **slug** field will automatically populate based on the **title** field. - - - -Django-extensions also includes useful abstract base classes to use for common patterns in your own models. Inherit from these base classes when you create your models to get their: - -Django-extensions has more features you may find useful in your projects, so take a tour through its [docs][5]! - -### 12-factor-app settings: django-environ - -[Django-environ][6] allows you to use [12-factor app][7] methodology to manage your settings in your Django project. It collects other libraries, including [envparse][8] and [honcho][9]. Once you install django-environ, create an .env file at your project's root. Define in that module any settings variables that may change between environments or should remain secret (like API keys, debug status, and database URLs). - -Then, in your project's settings.py file, import **environ** and set up variables for **environ.PATH()** and **environ.Env()** according to the [example][10]. Access settings variables defined in your .env file with **env('VARIABLE_NAME')**. - -### Creating great management commands: django-click - -[Django-click][11], based on [Click][12] (which we have recommended [before][13]… [twice][14]), helps you write Django management commands. This library doesn't have extensive documentation, but it does have a directory of [test commands][15] in its repository that are pretty useful. A basic Hello World command would look like this: - -``` -# app_name.management.commands.hello.py -import djclick as click - -@click.command() -@click.argument('name') -def command(name): -    click.secho(f'Hello, {name}') -``` - -Then in the command line, run: - -``` ->> ./manage.py hello Lacey -Hello, Lacey -``` - -### Handling finite state machines: django-fsm - -[Django-fsm][16] adds support for finite state machines to your Django models. If you run a news website and need articles to process through states like Writing, Editing, and Published, django-fsm can help you define those states and manage the rules and restrictions around moving from one state to another. - -Django-fsm provides an FSMField to use for the model attribute that defines the model instance's state. Then you can use django-fsm's **@transition** decorator to define methods that move the model instance from one state to another and handle any side effects from that transition. - -Although django-fsm is light on documentation, [Workflows (States) in Django][17] is a gist that serves as an excellent introduction to both finite state machines and django-fsm. - -### Contact forms: #django-contact-form - -A contact form is such a standard thing on a website. But don't write all that boilerplate code yourself—set yours up in minutes with [django-contact-form][18]. It comes with an optional spam-filtering contact form class (and a regular, non-filtering class) and a **ContactFormView** base class with methods you can override or customize, and it walks you through the templates you will need to create to make your form work. - -### Registering and authenticating users: django-allauth - -[Django-allauth][19] is an app that provides views, forms, and URLs for registering users, logging them in and out, resetting their passwords, and authenticating users with outside sites like GitHub or Twitter. It supports email-as-username authentication and is extensively documented. It can be a little confusing to set up the first time you use it; follow the [installation instructions][20] carefully and read closely when you [customize your settings][21] to make sure you're using all the settings you need to enable a specific feature. - -### Handling user authentication with Django REST Framework: django-rest-auth - -If your Django development includes writing APIs, you're probably using [Django REST Framework][22] (DRF). If you're using DRF, you should check out [django-rest-auth][23], a package that enables endpoints for user registration, login/logout, password reset, and social media authentication (by adding django-allauth, which works well with django-rest-auth). - -### Visualizing a Django REST Framework API: django-rest-swagger - -[Django REST Swagger][24] provides a feature-rich user interface for interacting with your Django REST Framework API. Once you've installed Django REST Swagger and added it to installed apps, add the Swagger view and URL pattern to your urls.py file; the rest is taken care of in the docstrings of your APIs. - -![](https://opensource.com/sites/default/files/uploads/swagger-ui.png) - -The UI for your API will include all your endpoints and available methods broken out by app. It will also list available operations for those endpoints and enable you to interact with the API (adding/deleting/fetching records, for example). It uses the docstrings in your API views to generate documentation for each endpoint, creating a set of API documentation for your project that's useful to you, your frontend developers, and your users. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/9/django-packages - -作者:[Jeff Triplett][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/laceynwilliams -[1]: https://www.djangoproject.com/ -[2]: https://opensource.com/article/18/1/10-tips-making-django-admin-more-secure -[3]: https://opensource.com/business/15/12/5-favorite-open-source-django-packages -[4]: https://django-extensions.readthedocs.io/en/latest/ -[5]: https://django-extensions.readthedocs.io/ -[6]: https://django-environ.readthedocs.io/en/latest/ -[7]: https://www.12factor.net/ -[8]: https://github.com/rconradharris/envparse -[9]: https://github.com/nickstenning/honcho -[10]: https://django-environ.readthedocs.io/ -[11]: https://github.com/GaretJax/django-click -[12]: http://click.pocoo.org/5/ -[13]: https://opensource.com/article/18/9/python-libraries-side-projects -[14]: https://opensource.com/article/18/5/3-python-command-line-tools -[15]: https://github.com/GaretJax/django-click/tree/master/djclick/test/testprj/testapp/management/commands -[16]: https://github.com/viewflow/django-fsm -[17]: https://gist.github.com/Nagyman/9502133 -[18]: https://django-contact-form.readthedocs.io/en/1.5/ -[19]: https://django-allauth.readthedocs.io/en/latest/ -[20]: https://django-allauth.readthedocs.io/en/latest/installation.html -[21]: https://django-allauth.readthedocs.io/en/latest/configuration.html -[22]: http://www.django-rest-framework.org/ -[23]: https://django-rest-auth.readthedocs.io/ -[24]: https://django-rest-swagger.readthedocs.io/en/latest/ diff --git a/translated/tech/20180920 8 Python packages that will simplify your life with Django.md b/translated/tech/20180920 8 Python packages that will simplify your life with Django.md new file mode 100644 index 0000000000..f242007433 --- /dev/null +++ b/translated/tech/20180920 8 Python packages that will simplify your life with Django.md @@ -0,0 +1,121 @@ +简化 Django 开发的八个 Python 包 +====== + +这个月的 Python 专栏将介绍一些 Django 包,它们有益于你的工作,以及你的个人或业余项目。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/water-stone-balance-eight-8.png?itok=1aht_V5V) + +Django 开发者们,在这个月的 Python 专栏中,我们会介绍一些能帮助你们的软件包。这些软件包是我们最喜欢的 [Django][1] 库,能够节省开发时间,减少样板代码,通常来说,这会让我们的生活更加轻松。我们为 Django 应用准备了六个包,为 Django 的 REST 框架准备了两个包。几乎所有我们的项目里,都用到了这些包,真的,不是说笑。 + +不过在继续阅读之前,请先看看我们关于[让 Django 管理后台更安全][2]的几个提示,以及这篇关于 [5 个最受欢迎的开源 Django 包][3] 的文章。 + +### 有用又省时的工具集合:django-extensions + +[Django-extensions][4] 这个 Django 包非常受欢迎,全是有用的工具,比如下面这些管理命令: + + * **shell_plus** 打开 Django 的管理 shell,这个 shell 已经自动导入了所有的数据库模型。在测试复杂的数据关系时,就不需要再从几个不同的应用里做 import 的操作了。 + * **clean_pyc** 删除项目目录下所有位置的 .pyc 文件 + * **create_template_tags** 在指定的应用下,创建模板标签的目录结构。 + * **describe_form** 输出模型的表单定义,可以粘贴到 forms.py 文件中。(需要注意的是,这种方法创建的是普通 Django 表单,而不是模型表单。) + * **notes** 输出你项目里所有带 TODO,FIXME 等标记的注释。 + +Django-extensions 还包括几个有用的抽象基类,在定义模型时,它们能满足常见的模式。当你需要以下模型时,可以继承这些基类: + + + * **TimeStampedModel** : 这个模型的基类包含了 **created** 字段和 **modified** 字段,还有一个 **save()** 方法,在适当的场景下,该方法自动更新 created 和 modified 字段的值。 + * **ActivatorModel** : 如果你的模型需要像 **status**,**activate_date** 和 **deactivate_date** 这样的字段,可以使用这个基类。它还自带了一个启用 **.active()** 和 **.inactive()** 查询集的 manager。 + * **TitleDescriptionModel** 和 **TitleSlugDescriptionModel** : 这两个模型包括了 **title** 和 **description** 字段,其中 description 字段还包括 **slug**,它根据 **title** 字段自动产生。 + +Django-extensions 还有其他更多的功能,也许对你的项目有帮助,所以,去浏览一下它的[文档][5]吧! + +### 12 因子应用的配置:django-environ + +在 Django 项目的配置方面,[Django-environ][6] 提供了符合 [12 因子应用][7] 方法论的管理方法。它是其他一些库的集合,包括 [envparse][8] 和 [honcho][9] 等。安装了 django-environ 之后,在项目的根目录创建一个 .env 文件,用这个文件去定义那些随环境不同而不同的变量,或者需要保密的变量。(比如 API keys,是否启用 debug,数据库的 URLs 等) + +然后,在项目的 settings.py 中引入 **environ**,并参考[官方文档的例子][10]设置好 **environ.PATH()** 和 **environ.Env()**。就可以通过 **env('VARIABLE_NAME')** 来获取 .env 文件中定义的变量值了。 + +### 创建出色的管理命令:django-click + +[Django-click][11] 是基于 [Click][12] 的, ( 我们[之前推荐过][13]… [两次][14] Click),它对编写 Django 管理命令很有帮助。这个库没有很多文档,但是代码仓库中有个存放[测试命令][15]的目录,非常有参考价值。 Django-click 基本的 Hello World 命令是这样写的: + +``` +# app_name.management.commands.hello.py +import djclick as click + +@click.command() +@click.argument('name') +def command(name): + click.secho(f'Hello, {name}') +``` + +在命令行下调用它,这样执行即可: + +``` +>> ./manage.py hello Lacey +Hello, Lacey +``` + +### 处理有限状态机:django-fsm + +[Django-fsm][16] 给 Django 的模型添加了有限状态机的支持。如果你管理一个新闻网站,想用类似于“写作中”,“编辑中”,“已发布”来流转文章的状态,django-fsm 能帮你定义这些状态,还能管理状态变化的规则与限制。 + +Django-fsm 为模型提供了 FSMField 字段,用来定义模型实例的状态。用 django-fsm 的 **@transition** 修饰符,可以定义状态变化的方法,并处理状态变化的任何副作用。 + +虽然 django-fsm 文档很轻量,不过 [Django 中的工作流(状态)][17] 这篇 GitHubGist 对有限状态机和 django-fsm 做了非常好的介绍。 + +### 联系人表单:#django-contact-form + +联系人表单可以说是网站的标配。但是不要自己去写全部的样板代码,用 [django-contact-form][18] 在几分钟内就可以搞定。它带有一个可选的能过滤垃圾邮件的表单类(也有不过滤的普通表单类)和一个 **ContactFormView** 基类,基类的方法可以覆盖或自定义修改。而且它还能引导你完成模板的创建,好让表单正常工作。 + +### 用户注册和认证:django-allauth + +[Django-allauth][19] 是一个 Django 应用,它为用户注册,登录注销,密码重置,还有第三方用户认证(比如 GitHub 或 Twitter)提供了视图,表单和 URLs,支持邮件地址作为用户名的认证方式,而且有大量的文档记录。第一次用的时候,它的配置可能会让人有点晕头转向;请仔细阅读[安装说明][20],在[自定义你的配置][21]时要专注,确保启用某个功能的所有配置都用对了。 + +### 处理 Django REST 框架的用户认证:django-rest-auth + +如果 Django 开发中涉及到对外提供 API,你很可能用到了 [Django REST Framework][22] (DRF)。如果你在用 DRF,那么你应该试试 django-rest-auth,它提供了用户注册,登录/注销,密码重置和社交媒体认证的 endpoints (是通过添加 django-allauth 的支持来实现的,这两个包协作得很好)。 + +### Django REST 框架的 API 可视化:django-rest-swagger + +[Django REST Swagger][24] 提供了一个功能丰富的用户界面,用来和 Django REST 框架的 API 交互。你只需要安装 Django REST Swagger,把它添加到 Django 项目的 installed apps 中,然后在 urls.py 中添加 Swagger 的视图和 URL 模式就可以了,剩下的事情交给 API 的 docstring 处理。 + +![](https://opensource.com/sites/default/files/uploads/swagger-ui.png) + +API 的用户界面按照 app 的维度展示了所有 endpoints 和可用方法,并列出了这些 endpoints 的可用操作,而且它提供了和 API 交互的功能(比如添加/删除/获取记录)。django-rest-swagger 从 API 视图中的 docstrings 生成每个 endpoint 的文档,通过这种方法,为你的项目创建了一份 API 文档,这对你,对前端开发人员和用户都很有用。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/django-packages + +作者:[Jeff Triplett][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[belitex](https://github.com/belitex) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/laceynwilliams +[1]: https://www.djangoproject.com/ +[2]: https://opensource.com/article/18/1/10-tips-making-django-admin-more-secure +[3]: https://opensource.com/business/15/12/5-favorite-open-source-django-packages +[4]: https://django-extensions.readthedocs.io/en/latest/ +[5]: https://django-extensions.readthedocs.io/ +[6]: https://django-environ.readthedocs.io/en/latest/ +[7]: https://www.12factor.net/ +[8]: https://github.com/rconradharris/envparse +[9]: https://github.com/nickstenning/honcho +[10]: https://django-environ.readthedocs.io/ +[11]: https://github.com/GaretJax/django-click +[12]: http://click.pocoo.org/5/ +[13]: https://opensource.com/article/18/9/python-libraries-side-projects +[14]: https://opensource.com/article/18/5/3-python-command-line-tools +[15]: https://github.com/GaretJax/django-click/tree/master/djclick/test/testprj/testapp/management/commands +[16]: https://github.com/viewflow/django-fsm +[17]: https://gist.github.com/Nagyman/9502133 +[18]: https://django-contact-form.readthedocs.io/en/1.5/ +[19]: https://django-allauth.readthedocs.io/en/latest/ +[20]: https://django-allauth.readthedocs.io/en/latest/installation.html +[21]: https://django-allauth.readthedocs.io/en/latest/configuration.html +[22]: http://www.django-rest-framework.org/ +[23]: https://django-rest-auth.readthedocs.io/ +[24]: https://django-rest-swagger.readthedocs.io/en/latest/ \ No newline at end of file From 50f53143e42ac21f9d481b03c218bbc076c656f1 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Wed, 26 Sep 2018 21:45:48 +0800 Subject: [PATCH 436/455] Translated by qhwdw --- ...Educational Software and Games for Kids.md | 82 ------------------- ...Educational Software and Games for Kids.md | 80 ++++++++++++++++++ 2 files changed, 80 insertions(+), 82 deletions(-) delete mode 100644 sources/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md create mode 100644 translated/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md diff --git a/sources/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md b/sources/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md deleted file mode 100644 index 66850b2260..0000000000 --- a/sources/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md +++ /dev/null @@ -1,82 +0,0 @@ -Translating by qhwdw -5 of the Best Linux Educational Software and Games for Kids -====== - -![](https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-programs-for-kids-featured.jpg) - -Linux is a very powerful operating system, and that explains why it powers most of the servers on the Internet. Though it may not be the best OS in terms of user friendliness, its diversity is commendable. Everyone has their own need for Linux. Be it for coding, educational purposes or the internet of things (IoT), you’ll always find a suitable Linux distro for every use. To that end, many have dubbed Linux as the OS for future computing. - -Because the future belongs to the kids of today, introducing them to Linux is the best way to prepare them for what the future holds. This OS may not have a reputation for popular games such as FIFA or PES; however, it offers the best educational software and games for kids. These are five of the best Linux educational software to keep your kids ahead of the game. - -**Related** : [The Beginner’s Guide to Using a Linux Distro][1] - -### 1. GCompris - -If you’re looking for the best educational software for kids, [GCompris][2] should be your starting point. This software is specifically designed for kids education and is ideal for kids between two and ten years old. As the pinnacle of all Linux educational software suites for children, GCompris offers about 100 activities for kids. It packs everything you want for your kids from reading practice to science, geography, drawing, algebra, quizzes, and more. - -![Linux educational software and games][3] - -GCompris even has activities for helping your kids learn computer peripherals. If your kids are young and you want them to learn alphabets, colors, and shapes, GCompris has programmes for those, too. What’s more, it also comes with helpful games for kids such as chess, tic-tac-toe, memory, and hangman. GCompris is not a Linux-only app. It’s also available for Windows and Android. - -### 2. TuxMath - -Most students consider math a tough subject. You can change that perception by acquainting your kids with mathematical skills through Linux software applications such as [TuxMath][4]. TuxMath is a top-rated educational Math tutorial game for kids. In this game your role is to help Tux the penguin of Linux protect his planet from a rain of mathematical problems. - -![linux-educational-software-tuxmath-1][5] - -By finding the answer, you help Tux save the planet by destroying the asteroids with your laser before they make an impact. The difficulty of the math problems increases with each level you pass. This game is ideal for kids, as it can help them rack their brains for solutions. Besides making them good at math, it also helps them improve their mental agility. - -### 3. Sugar on a Stick - -[Sugar on a Stick][6] is a dedicated learning program for kids – a brand new pedagogy that has gained a lot of traction. This program provides your kids with a fully-fledged learning platform where they can gain skills in creating, exploring, discovering and also reflecting on ideas. Just like GCompris, Sugar on a Stick comes with a host of learning resources for kids, including games and puzzles. - -![linux-educational-software-sugar-on-a-stick][7] - -The best thing about Sugar on a Stick is that you can set it up on a USB Drive. All you need is an X86-based PC, then plug in the USB, and boot the distro from it. Sugar on a Stick is a project by Sugar Labs – a non-profit organization that is run by volunteers. - -### 4. KDE Edu Suite - -[KDE Edu Suite][8] is a package of software for different user purposes. With a host of applications from different fields, the KDE community has proven that it isn’t just serious about empowering adults; it also cares about bringing the young generation to speed with everything surrounding them. It comes packed with various applications for kids ranging from science to math, geography, and more. - -![linux-educational-software-kde-1][9] - -The KDE Suite can be used for adult needs based on necessities, as a school teaching software, or as a kid’s leaning app. It offers a huge software package and is free to download. The KDE Edu suite can be installed on most GNU/Linux Distros. - -### 5. Tux Paint - -![linux-educational-software-tux-paint-2][10] - -[Tux Paint][11] is another great Linux educational software for kids. This award-winning drawing program is used in schools around the world to help children nurture the art of drawing. It comes with a clean, easy-to-use interface and fun sound effects that help children use the program. There is also an encouraging cartoon mascot that guides kids as they use the program. Tux Paint comes with a variety of drawing tools that help kids unleash their creativity. - -### Summing Up - -Due to the popularity of these educational software for kids, many institutions have embraced these programs as teaching aids in schools and kindergartens. A typical example is [Edubuntu][12], an Ubuntu-derived distro that is widely used by teachers and parents for educating kids. - -Tux Paint is another great example that has grown in popularity over the years and is being used in schools to teach children how to draw. This list is by no means exhaustive. There are hundreds of other Linux educational software and games that can be very useful for your kids. - -If you know of any other great Linux educational software and games for kids, share with us in the comments section below. - --------------------------------------------------------------------------------- - -via: https://www.maketecheasier.com/5-best-linux-software-packages-for-kids/ - -作者:[Kenneth Kimari][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.maketecheasier.com/author/kennkimari/ -[1]:https://www.maketecheasier.com/beginner-guide-to-using-linux-distro/ (The Beginner’s Guide to Using a Linux Distro) -[2]:http://www.gcompris.net/downloads-en.html -[3]:https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-software-gcompris.jpg (Linux educational software and games) -[4]:https://tuxmath.en.uptodown.com/ubuntu -[5]:https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-software-tuxmath-1.jpg (linux-educational-software-tuxmath-1) -[6]:http://wiki.sugarlabs.org/go/Sugar_on_a_Stick/Downloads -[7]:https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-software-sugar-on-a-stick.png (linux-educational-software-sugar-on-a-stick) -[8]:https://edu.kde.org/ -[9]:https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-software-kde-1.jpg (linux-educational-software-kde-1) -[10]:https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-software-tux-paint-2.jpg (linux-educational-software-tux-paint-2) -[11]:http://www.tuxpaint.org/ -[12]:http://edubuntu.org/ diff --git a/translated/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md b/translated/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md new file mode 100644 index 0000000000..3a1981f0bc --- /dev/null +++ b/translated/tech/20180813 5 of the Best Linux Educational Software and Games for Kids.md @@ -0,0 +1,80 @@ +# 5 个给孩子的非常好的 Linux 教育软件和游戏 + +![](https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-programs-for-kids-featured.jpg) + +Linux 是一个非常强大的操作系统,因此因特网上的大多数服务器都使用它。尽管它算不上是对用户友好的最佳操作系统,但它的多元化还是值的称赞的。对于 Linux 来说,每个人都能在它上面找到他们自己的所需。不论你是用它来写代码、还是用于教学或物联网(IoT),你总能找到一个适合你用的 Linux 发行版。为此,许多人认为 Linux 是未来计算的最佳操作系统。 + +未来是属于孩子们的,让孩子们了解 Linux 是他们掌控未来的最佳方式。这个操作系统上或许并没有一些像 FIFA 或 PES 那样的声名赫赫的游戏;但是,它为孩子们提供了一些非常好的教育软件和游戏。这里有五款最好的 Linux 教育软件,可以让你的孩子远离游戏。 + +**相关阅读**:[使用一个 Linux 发行版的新手指南][1] + +### 1. GCompris + +如果你正在为你的孩子寻找一款最佳的教育软件,[GCompris][2] 将是你的最好的开端。这款软件专门为 2 到 10 岁的孩子所设计。作为所有的 Linux 教育软件套装的巅峰之作,GCompris 为孩子们提供了大约 100 项活动。它囊括了你期望你的孩子学习的所有内容,从阅读材料到科学、地理、绘画、代数、测验、等等。 + +![Linux educational software and games][3] + +GCompris 甚至有一项活动可以帮你的孩子学习计算机的相关知识。如果你的孩子还很小,你希望他去学习字母、颜色、和形状,GCompris 也有这方面的相关内容。更重要的是,它也为孩子们准备了一些益智类游戏,比如国际象棋、井字棋、好记性、以及猜词游戏。GCompris 并不是一个仅在 Linux 上可运行的游戏。它也可以运行在 Windows 和 Android 上。 + +### 2. TuxMath + +很多学生认为数学是们非常难的课程。你可以通过 Linux 教育软件如 [TuxMath][4] 来让你的孩子了解数学技能,从而来改变这种看法。TuxMath 是为孩子开发的顶级的数学教育辅助游戏。在这个游戏中,你的角色是在如雨点般下降的数学问题中帮助 Linux 企鹅 Tux 来保护它的星球。 + +![linux-educational-software-tuxmath-1][5] + +在它们落下来毁坏 Tux 的星球之前,找到问题的答案,就可以使用你的激光去帮助 Tux 拯救它的星球。数字问题的难度每过一关就会提升一点。这个游戏非常适合孩子,因为它可以让孩子们去开动脑筋解决问题。而且还有助他们学好数学,以及帮助他们开发智力。 + +### 3. Sugar on a Stick + +[Sugar on a Stick][6] 是献给孩子们的学习程序 —— 一个广受好评的全新教学法。这个程序为你的孩子提供一个成熟的教学平台,在那里,他们可以收获创造、探索、发现和思考方面的技能。和 GCompris 一样,Sugar on a Stick 为孩子们带来了包括游戏和谜题在内的大量学习资源。 + +![linux-educational-software-sugar-on-a-stick][7] + +关于 Sugar on a Stick 最大的一个好处是你可以将它配置在一个 U 盘上。你只要有一台 X86 的 PC,插入那个 U 盘,然后就可以从 U 盘引导这个发行版。Sugar on a Stick 是由 Sugar 实验室提供的一个项目 —— 这个实验室是一个由志愿者运作的非盈利组织。 + +### 4. KDE Edu Suite + +[KDE Edu Suite][8] 是一个用途与众不同的软件包。带来了大量不同领域的应用程序,KDE 社区已经证实,它不仅是一系列成年人授权的问题;它还关心年青一代如何适应他们周围的一切。它囊括了一系列孩子们使用的应用程序,从科学到数学、地理等等。 + +![linux-educational-software-kde-1][9] + +KDE Edu 套件根据长大后所必需的知识为基础,既能够用作学校的教学软件,也能够作为孩子们的学习 APP。它提供了大量的可免费下载的软件包。KDE Edu 套件在主流的 GNU/Linux 发行版都能安装。 + +### 5. Tux Paint + +![linux-educational-software-tux-paint-2][10] + +[Tux Paint][11] 是给孩子们的另一个非常好的 Linux 教育软件。这个屡获殊荣的绘画软件在世界各地被用于帮助培养孩子们的绘画技能,它有一个简洁的、易于使用的界面和有趣的音效,可以高效地帮助孩子去使用这个程序。它也有一个卡通吉祥物去鼓励孩子们使用这个程序。Tux Paint 中有许多绘画工具,它们可以帮助孩子们放飞他们的创意。 + +### 总结 + +由于这些教育软件深受孩子们的欢迎,许多学校和幼儿园都使用这些程序进行辅助教学。典型的一个例子就是 [Edubuntu][12],它是儿童教育领域中广受老师和家长们欢迎的一个基于 Ubuntu 的发行版。 + +Tux Paint 是另一个非常好的例子,它在这些年越来越流行,它大量地用于学校中教孩子们如何绘画。以上的这个清单并不很详细。还有成百上千的对孩子有益的其它 Linux 教育软件和游戏。 + +如果你还知道给孩子们的其它非常好的 Linux 教育软件和游戏,在下面的评论区分享给我们吧。 + +------ + +via: https://www.maketecheasier.com/5-best-linux-software-packages-for-kids/ + +作者:[Kenneth Kimari][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.maketecheasier.com/author/kennkimari/ +[1]: https://www.maketecheasier.com/beginner-guide-to-using-linux-distro/ "The Beginner’s Guide to Using a Linux Distro" +[2]: http://www.gcompris.net/downloads-en.html +[3]: https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-software-gcompris.jpg "Linux educational software and games" +[4]: https://tuxmath.en.uptodown.com/ubuntu +[5]: https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-software-tuxmath-1.jpg "linux-educational-software-tuxmath-1" +[6]: http://wiki.sugarlabs.org/go/Sugar_on_a_Stick/Downloads +[7]: https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-software-sugar-on-a-stick.png "linux-educational-software-sugar-on-a-stick" +[8]: https://edu.kde.org/ +[9]: https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-software-kde-1.jpg "linux-educational-software-kde-1" +[10]: https://www.maketecheasier.com/assets/uploads/2018/07/Linux-educational-software-tux-paint-2.jpg "linux-educational-software-tux-paint-2" +[11]: http://www.tuxpaint.org/ +[12]: http://edubuntu.org/ \ No newline at end of file From 249d0c33d4d4ac1b33db6bb8818988ad9016c4fd Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 26 Sep 2018 23:23:39 +0800 Subject: [PATCH 437/455] PRF:20180910 3 open source log aggregation tools.md @heguangzhi --- ...910 3 open source log aggregation tools.md | 76 +++++++++---------- 1 file changed, 34 insertions(+), 42 deletions(-) diff --git a/translated/tech/20180910 3 open source log aggregation tools.md b/translated/tech/20180910 3 open source log aggregation tools.md index a026b47625..0bad973eba 100644 --- a/translated/tech/20180910 3 open source log aggregation tools.md +++ b/translated/tech/20180910 3 open source log aggregation tools.md @@ -1,83 +1,75 @@ - - - -3个开源日志聚合工具 +3 个开源日志聚合工具 ====== -日志聚合系统可以帮助我们故障排除并进行其他的任务。以下是三个主要工具介绍。 +> 日志聚合系统可以帮助我们进行故障排除和其它任务。以下是三个主要工具介绍。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr) - - -指标聚合与日志聚合有何不同?日志不能包括指标吗?日志聚合系统不能做与指标聚合系统相同的事情吗? +指标聚合metrics aggregation日志聚合log aggregation有何不同?日志不能包括指标吗?日志聚合系统不能做与指标聚合系统相同的事情吗? 这些是我经常听到的问题。我还看到供应商推销他们的日志聚合系统作为所有可观察问题的解决方案。日志聚合是一个有价值的工具,但它通常对时间序列数据的支持不够好。 -时间序列指标聚合系统中几个有价值的功能为规则间隔与专门为时间序列数据定制的存储系统。规则间隔允许用户一次性地导出真实的数据结果。如果要求日志聚合系统定期收集指标数据,它也可以。但是,它的存储系统没有针对指标聚合系统中典型的查询类型进行优化。使用日志聚合工具中的存储系统处理这些查询将花费更多的资源和时间。 +时间序列的指标聚合系统中几个有价值的功能是专门为时间序列数据定制的固定间隔regular interval和存储系统。固定间隔允许用户不断地收集实时的数据结果。如果要求日志聚合系统以固定间隔收集指标数据,它也可以。但是,它的存储系统没有针对指标聚合系统中典型的查询类型进行优化。使用日志聚合工具中的存储系统处理这些查询将花费更多的资源和时间。 -所以,我们知道日志聚合系统可能不适合时间序列数据,但是它有什么好处呢?日志聚合系统是收集事件数据的好地方。这些是非常重要的不规则活动。最好的例子为 web 服务的访问日志。这些都很重要,因为我们想知道什么东西正在访问我们的系统,什么时候访问。另一个例子是应用程序错误记录——因为它不是正常的操作记录,所以在故障排除过程中可能很有价值的。 +所以,我们知道日志聚合系统可能不适合时间序列数据,但是它有什么好处呢?日志聚合系统是收集事件数据的好地方。这些无规律的活动是非常重要的。最好的例子为 web 服务的访问日志,这些很重要,因为我们想知道什么正在访问我们的系统,什么时候访问的。另一个例子是应用程序错误记录 —— 因为它不是正常的操作记录,所以在故障排除过程中可能很有价值的。 -日志记录的一些规则: - - * 包含时间戳 - * 包含 JSON 格式 - * 不记录无关紧要的事件 - * 记录所有应用程序的错误 - * 记录警告错误 - * 日志记录开关 - * 以可读的形式记录信息 - * 不在生产环境中记录信息 - * 不记录任何无法阅读或无反馈的内容 +日志记录的一些规则: + * **须**包含时间戳 + * **须**格式化为 JSON + * **不**记录无关紧要的事件 + * **须**记录所有应用程序的错误 + * **可**记录警告错误 + * **可**开关的日志记录 + * **须**以可读的形式记录信息 + * **不**在生产环境中记录信息 + * **不**记录任何无法阅读或反馈的内容 ### 云的成本 -当研究日志聚合工具时,云可能看起来是一个有吸引力的选择。然而,这可能会带来巨大的成本。当跨数百或数千台主机和应用程序聚合时,日志数据是大量的。在基于云的系统中,数据的接收、存储和检索是昂贵的。 +当研究日志聚合工具时,云服务可能看起来是一个有吸引力的选择。然而,这可能会带来巨大的成本。当跨数百或数千台主机和应用程序聚合时,日志数据是大量的。在基于云的系统中,数据的接收、存储和检索是昂贵的。 -作为一个真实的系统,大约500个节点和几百个应用程序的集合每天产生 200GB 的日志数据。这个系统可能还有改进的空间,但是在许多 SaaS 产品中,即使将它减少一半,每月也要花费将近10,000美元。这通常包括仅保留30天,如果你想查看一年一年的趋势数据,就不可能了。 - -并不是要不使用这些系统,尤其是对于较小的组织它们可能非常有价值的。目的是指出可能会有很大的成本,当这些成本达到时,就可能令人非常的沮丧。本文的其余部分将集中讨论自托管的开源和商业解决方案。 +以一个真实的系统来参考,大约 500 个节点和几百个应用程序的集合每天产生 200GB 的日志数据。这个系统可能还有改进的空间,但是在许多 SaaS 产品中,即使将它减少一半,每月也要花费将近 10000 美元。而这通常仅保留 30 天,如果你想查看一年一年的趋势数据,就不可能了。 +并不是要不使用这些基于云的系统,尤其是对于较小的组织它们可能非常有价值的。这里的目的是指出可能会有很大的成本,当这些成本很高时,就可能令人非常的沮丧。本文的其余部分将集中讨论自托管的开源和商业解决方案。 ### 工具选择 #### ELK -[ELK][1] ,简称 Elasticsearch、Logstash 和 Kibana,是最流行的开源日志聚合工具。它被Netflix、Facebook、微软、LinkedIn 和思科使用。这三个组件都是由 [Elastic][2] 开发和维护的。[Elasticsearch][3] 本质上是一个NoSQL,Lucene 搜索引擎实现的。[Logstash][4] 是一个日志管道系统,可以接收数据,转换数据,并将其加载到像 Elasticsearch 这样的应用中。[Kibana][5] 是 Elasticsearch 之上的可视化层。 +[ELK][1],即 Elasticsearch、Logstash 和 Kibana 简称,是最流行的开源日志聚合工具。它被 Netflix、Facebook、微软、LinkedIn 和思科使用。这三个组件都是由 [Elastic][2] 开发和维护的。[Elasticsearch][3] 本质上是一个 NoSQL 数据库,以 Lucene 搜索引擎实现的。[Logstash][4] 是一个日志管道系统,可以接收数据,转换数据,并将其加载到像 Elasticsearch 这样的应用中。[Kibana][5] 是 Elasticsearch 之上的可视化层。 -几年前,Beats 被引入。Beats 是数据采集器。它们简化了将数据运送到日志存储的过程。用户不需要了解每种日志的正确语法,而是可以安装一个 Beats 来正确导出 NGINX 日志或代理日志,以便在Elasticsearch 中有效地使用它们。 +几年前,引入了 Beats 。Beats 是数据采集器。它们简化了将数据运送到 Logstash 的过程。用户不需要了解每种日志的正确语法,而是可以安装一个 Beats 来正确导出 NGINX 日志或 Envoy 代理日志,以便在 Elasticsearch 中有效地使用它们。 -安装生产环境级 ELK stack 时,可能会包括其他几个部分,如 [Kafka][6], [Redis][7], and [NGINX][8]。此外,用 Fluentd 替换 Logstash 也很常见,我们将在后面讨论。这个系统操作起来很复杂,这在早期导致很多问题和投诉。目前,这些基本上已经被修复,不过它仍然是一个复杂的系统,如果你使用少部分的功能,建议不要使用它了。 +安装生产环境级 ELK 套件时,可能会包括其他几个部分,如 [Kafka][6]、[Redis][7] 和 [NGINX][8]。此外,用 Fluentd 替换 Logstash 也很常见,我们将在后面讨论。这个系统操作起来很复杂,这在早期导致了很多问题和抱怨。目前,这些问题基本上已经被修复,不过它仍然是一个复杂的系统,如果你使用少部分的功能,建议不要使用它了。 -也就是说,服务是可用的,所以你不必担心。[Logz.io][9] 也可以使用,但是如果你有很多数据,它的标价有点高。当然,你可能没有很多数据,来使用用它。如果你买不起 Logz.io,你可以看看 [AWS Elasticsearch Service][10] (ES) 。ES 是 Amazon Web Services (AWS) 提供的一项服务,它使得 Elasticsearch 很容易快速工作。它还拥有使用 Lambda 和 S3 将所有AWS日志记录到 ES 的工具。这是一个更便宜的选择,但是需要一些管理操作,并有一些功能限制。 +也就是说,有其它可用的服务,所以你不必苦恼于此。可以使用 [Logz.io][9],但是如果你有很多数据,它的标价有点高。当然,你可能规模比较小,没有很多数据。如果你买不起 Logz.io,你可以看看 [AWS Elasticsearch Service][10] (ES) 。ES 是 Amazon Web Services (AWS) 提供的一项服务,它很容易就可以让 Elasticsearch 马上工作起来。它还拥有使用 Lambda 和 S3 将所有AWS 日志记录到 ES 的工具。这是一个更便宜的选择,但是需要一些管理操作,并有一些功能限制。 +ELK 套件的母公司 Elastic [提供][11] 一款更强大的产品,它使用开源核心open core模式,为分析工具和报告提供了额外的选项。它也可以在谷歌云平台或 AWS 上托管。由于这种工具和托管平台的组合提供了比大多数 SaaS 选项更加便宜,这也许是最好的选择,并且很有用。该系统可以有效地取代或提供 [安全信息和事件管理][12](SIEM)系统的功能。 -Elastic [offers][11] 的母公司提供一款更强大的产品,它使用开放核心模型,为分析工具和报告提供了额外的选项。它也可以在谷歌云平台或 AWS 上托管。由于这种工具和托管平台的组合提供了比大多数 SaaS 选项更加便宜,这将是最好的选择并且具有很大的价值。该系统可以有效地取代或提供[security information and event management][12] ( SIEM )系统的功能。 - -ELK 栈通过 Kibana 提供了很好的可视化工具,但是它缺少警报功能。Elastic 在付费的 X-Pack 插件中提供了提醒功能,但是在开源系统没有内置任何功能。Yelp 已经开发了一种解决这个问题的方法,[ElastAlert][13], 不过还有其他方式。这个额外的软件相当健壮,但是它增加了已经复杂的系统的复杂性。 +ELK 套件通过 Kibana 提供了很好的可视化工具,但是它缺少警报功能。Elastic 在付费的 X-Pack 插件中提供了警报功能,但是在开源系统没有内置任何功能。Yelp 已经开发了一种解决这个问题的方法,[ElastAlert][13],不过还有其他方式。这个额外的软件相当健壮,但是它增加了已经复杂的系统的复杂性。 #### Graylog -[Graylog][14] 最近越来越受欢迎,但它是在2010年 Lennart Koopmann 创建并开发的。两年后,一家公司以同样的名字诞生了。尽管它的使用者越来越多,但仍然远远落后于 ELK 栈。这也意味着它具有较少的社区开发特征,但是它可以使用与 ELK stack 相同的 Beats 。Graylog 由于 Graylog Collector Sidecar 使用 [Go][15] 编写所以在 Go 社区赢得了赞誉。 +[Graylog][14] 最近越来越受欢迎,但它是在 2010 年由 Lennart Koopmann 创建并开发的。两年后,一家公司以同样的名字诞生了。尽管它的使用者越来越多,但仍然远远落后于 ELK 套件。这也意味着它具有较少的社区开发特征,但是它可以使用与 ELK 套件相同的 Beats 。由于 Graylog Collector Sidecar 使用 [Go][15] 编写,所以 Graylog 在 Go 社区赢得了赞誉。 -Graylog 使用 Elasticsearch、[MongoDB][16] 并且 提供 Graylog Server 。这使得它像ELK 栈一样复杂,也许还要复杂一些。然而,Graylog 附带了内置于开源版本中的报警功能,以及其他一些值得注意的功能,如 streaming 、消息重写 和 地理定位。 +Graylog 使用 Elasticsearch、[MongoDB][16] 和底层的 Graylog Server 。这使得它像 ELK 套件一样复杂,也许还要复杂一些。然而,Graylog 附带了内置于开源版本中的报警功能,以及其他一些值得注意的功能,如流、消息重写和地理定位。 -streaming 能允许数据在被处理时被实时路由到特定的 Streams。使用此功能,用户可以在单个Stream 中看到所有数据库错误,在不同的 Stream 中看到 web 服务器错误。当添加新项目或超过阈值时,甚至可以基于这些 Stream 提供警报。延迟可能是日志聚合系统中最大的问题之一,Stream消除了灰色日志中的这一问题。一旦日志进入,它就可以通过 Stream 路由到其他系统,而无需全部处理。 +流功能可以允许数据在被处理时被实时路由到特定的 Stream。使用此功能,用户可以在单个 Stream 中看到所有数据库错误,在另外的 Stream 中看到 web 服务器错误。当添加新项目或超过阈值时,甚至可以基于这些 Stream 提供警报。延迟可能是日志聚合系统中最大的问题之一,Stream 消除了 Graylog 中的这一问题。一旦日志进入,它就可以通过 Stream 路由到其他系统,而无需完全处理好。 -消息重写功能使用开源规则引擎 [Drools][17] 。允许根据用户定义的规则文件评估所有传入的消息,从而可以删除消息(称为黑名单)、添加或删除字段或修改消息。 +消息重写功能使用开源规则引擎 [Drools][17] 。允许根据用户定义的规则文件评估所有传入的消息,从而可以删除消息(称为黑名单)、添加或删除字段或修改消息。 -Graylog 最酷的功能是它的地理定位功能,它支持在地图上绘制 IP 地址。这是一个相当常见的功能,在 Kibana 也可以这样使用,但是它增加了很多价值——特别是如果你想将它用作 SIEM 系统。地理定位功能在系统的开源版本中提供。 +Graylog 最酷的功能或许是它的地理定位功能,它支持在地图上绘制 IP 地址。这是一个相当常见的功能,在 Kibana 也可以这样使用,但是它增加了很多价值 —— 特别是如果你想将它用作 SIEM 系统。地理定位功能在系统的开源版本中提供。 -Graylog 如果你想要的话,它会对开源版本的支持收费。它还为其企业版提供了一个开放的核心模型,提供存档、审计日志记录和其他支持。如果你不需要 Graylog (the company) 支持或托管的,你可以独立使用。 +如果你需要的话,Graylog 公司会提供对开源版本的收费支持。它还为其企业版提供了一个开源核心模式,提供存档、审计日志记录和其他支持。其它提供支持或托管服务的不太多,如果你不需要 Graylog 公司的,你可以托管。 #### Fluentd -[Fluentd][18] 是 [Treasure Data][19] 开发的,[CNCF][20] 已经将它作为一个孵化项目。它是用 C 和 Ruby 编写的,并由[AWS][21] 和 [Google Cloud][22]推荐。fluentd已经成为许多装置中logstach的常用替代品。它充当本地聚合器,收集所有节点日志并将其发送到中央存储系统。它不是日志聚合系统。 +[Fluentd][18] 是 [Treasure Data][19] 开发的,[CNCF][20] 已经将它作为一个孵化项目。它是用 C 和 Ruby 编写的,并被 [AWS][21] 和 [Google Cloud][22] 所推荐。Fluentd 已经成为许多系统中 logstach 的常用替代品。它可以作为一个本地聚合器,收集所有节点日志并将其发送到中央存储系统。它不是日志聚合系统。 -它使用一个强大的插件系统,提供不同数据源和数据输出的快速和简单的集成功能。因为有超过500个插件可用,所以你的大多数用例都应该包括在内。如果没有,这听起来是一个为开源社区做出贡献的机会。 +它使用一个强大的插件系统,提供不同数据源和数据输出的快速和简单的集成功能。因为有超过 500 个插件可用,所以你的大多数用例都应该包括在内。如果没有,这听起来是一个为开源社区做出贡献的机会。 -Fluentd 由于占用内存少(只有几十兆字节)和高吞吐量特性,是 Kubernetes 环境中的常见选择。在像 [Kubernetes][23] 这样的环境中,每个pod 都有一个 Fluentd sidecar ,内存消耗会随着每个新 pod 的创建而线性增加。在这中情况下,使用 Fluentd 将大大降低你的系统利用率。这对于Java开发的工具来说,这是一个常见的问题,这些工具旨在为每个节点运行一个工具,而内存开销并不是主要问题。 +Fluentd 由于占用内存少(只有几十兆字节)和高吞吐量特性,是 Kubernetes 环境中的常见选择。在像 [Kubernetes][23] 这样的环境中,每个 pod 都有一个 Fluentd 附属件 ,内存消耗会随着每个新 pod 的创建而线性增加。在这种情况下,使用 Fluentd 将大大降低你的系统利用率。这对于 Java 开发的工具来说是一个常见的问题,这些工具旨在为每个节点运行一个工具,而内存开销并不是主要问题。 -------------------------------------------------------------------------------- @@ -87,7 +79,7 @@ via: https://opensource.com/article/18/9/open-source-log-aggregation-tools 作者:[Dan Barker][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[heguangzhi](https://github.com/heguangzhi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 521967e1f7aba7643d064fdab6992fc274458ca6 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 26 Sep 2018 23:24:02 +0800 Subject: [PATCH 438/455] PUB:20180910 3 open source log aggregation tools.md @heguangzhi https://linux.cn/article-10053-1.html --- .../20180910 3 open source log aggregation tools.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180910 3 open source log aggregation tools.md (100%) diff --git a/translated/tech/20180910 3 open source log aggregation tools.md b/published/20180910 3 open source log aggregation tools.md similarity index 100% rename from translated/tech/20180910 3 open source log aggregation tools.md rename to published/20180910 3 open source log aggregation tools.md From f4c58714b3d1d30cce80bfa0bda7170cefd9ec07 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 27 Sep 2018 00:08:08 +0800 Subject: [PATCH 439/455] PRF:20180824 Steam Makes it Easier to Play Windows Games on Linux.md @hopefully2333 --- ...t Easier to Play Windows Games on Linux.md | 41 +++++++++++-------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/translated/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md b/translated/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md index 75c42b3ab3..a257cee609 100644 --- a/translated/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md +++ b/translated/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md @@ -1,47 +1,50 @@ -steam 让我们在 Linux 上玩 Windows 的游戏更加容易 +Steam 让我们在 Linux 上玩 Windows 的游戏更加容易 ====== + ![Steam Wallpaper][1] -总所周知,Linux 游戏库中的游戏只有 Windows 游戏库中的一部分,实际上,许多人甚至都不会考虑将操作系统转换为 Linux,原因很简单,因为他们喜欢的游戏,大多数都不能在这个平台上运行。 +总所周知,[Linux 游戏][2]库中的游戏只有 Windows 游戏库中的一部分,实际上,许多人甚至都不会考虑将操作系统[转换为 Linux][3],原因很简单,因为他们喜欢的游戏,大多数都不能在这个平台上运行。 -在撰写本文时,steam 上已有超过 5000 种游戏可以在 Linux 上运行,而 steam 上的游戏总数已经接近 27000 种了。现在 5000 种游戏可能看起来很多,但还没有达到 27000 种,确实没有。 +在撰写本文时,Steam 上已有超过 5000 种游戏可以在 Linux 上运行,而 Steam 上的游戏总数已经接近 27000 种了。现在 5000 种游戏可能看起来很多,但还没有达到 27000 种,确实没有。 -虽然几乎所有的新的独立游戏都是在 Linux 中推出的,但我们仍然无法在这上面玩很多的 3A 大作。对我而言,虽然这其中有很多游戏我都很希望能有机会玩,但这从来都不是一个非黑即白的问题。因为我主要是玩独立游戏和复古游戏,所以几乎所有我喜欢的游戏都可以在 Linux 系统上运行。 +虽然几乎所有的新的独立游戏indie game都是在 Linux 中推出的,但我们仍然无法在这上面玩很多的 [3A 大作][4]。对我而言,虽然这其中有很多游戏我都很希望能有机会玩,但这从来都不是一个非黑即白的问题。因为我主要是玩独立游戏和[复古游戏][5],所以几乎所有我喜欢的游戏都可以在 Linux 系统上运行。 -### 认识 Proton,Steam 的一次 WINE 分叉。 +### 认识 Proton,Steam 的一个 WINE 复刻 -现在,这个问题已经成为过去式了,因为本周 Valve 宣布要对 Steam Play 进行一次更新,此次更新会将一个名为 Proton 的分叉版本的 Wine 添加到 Linux 和 Mac 的客户端中。是的,这个工具是开源的,Valve 已经在 GitHub 上开源了源代码,但该功能仍然处于测试阶段,所以你必须使用测试版的 Steam 客户端才能使用这项功能。 +现在,这个问题已经成为过去式了,因为本周 Valve [宣布][6]要对 Steam Play 进行一次更新,此次更新会将一个名为 Proton 的 Wine 复刻版本添加到 Linux 客户端中。是的,这个工具是开源的,Valve 已经在 [GitHub][7] 上开源了源代码,但该功能仍然处于测试阶段,所以你必须使用测试版的 Steam 客户端才能使用这项功能。 -#### 使用 proton ,可以在 Linux 系统上使用 Steam 运行更多的 Windows 上的游戏。 +#### 使用 proton ,可以在 Linux 系统上通过 Steam 运行更多 Windows 游戏 -这对我们这些 Linux 用户来说,实际上意味着什么?简单来说,这意味着我们可以在 Linux 和 Mac 这两种操作系统的电脑上运行全部 27000 种游戏,而无需配置像 PlayOnLinux 或 Lutris 这样的服务。我要告诉你的是,配置这些东西有时候会非常让人头疼。 +这对我们这些 Linux 用户来说,实际上意味着什么?简单来说,这意味着我们可以在 Linux 电脑上运行全部 27000 种游戏,而无需配置像 [PlayOnLinux][8] 或 [Lutris][9] 这样的东西。我要告诉你的是,配置这些东西有时候会非常让人头疼。 -对此更为复杂的答案是,某种原因听起来非常美好。虽然在理论上,你可以用这种方式在 Linux 上玩所有的 Windows 平台上的游戏。但只有一少部分游戏在推出时会正式支持 Linux。这少部分游戏包括 DOOM,最终幻想 VI,铁拳 7,星球大战:前线 2,和其他几个。 +对此更为复杂的答案是,某种原因听起来非常美好。虽然在理论上,你可以用这种方式在 Linux 上玩所有的 Windows 平台上的游戏。但只有一少部分游戏在推出时会正式支持 Linux。这少部分游戏包括 《DOOM》、《最终幻想 VI》、《铁拳 7》、《星球大战:前线 2》,和其他几个。 -#### 你可以在 Linux 上玩所有的 Windows 平台的游戏(理论上) +#### 你可以在 Linux 上玩所有的 Windows 游戏(理论上) -虽然目前该列表只有大约 30 个游戏,你可以点击“为所有游戏使用 Steam play 进行运行”复选框来强制使用 Steam 的 Proton 来安装和运行任意游戏。但你最好不要有太高的期待,它们的稳定性和性能表现不一定有你希望的那么好,所以请把期望值压低一点。 +虽然目前该列表只有大约 30 个游戏,你可以点击“为所有游戏启用 Steam Play”复选框来强制使用 Steam 的 Proton 来安装和运行任意游戏。但你最好不要有太高的期待,它们的稳定性和性能表现不一定有你希望的那么好,所以请把期望值压低一点。 ![Steam Play][10] -#### 体验 Proton,没有我想的那么烂。 +据[这份报告][13],已经有超过一千个游戏可以在 Linux 上玩了。按[此指南][14]来了解如何启用 Steam Play 测试版本。 -例如,我安装了一些中等价格的游戏,使用 Proton 来进行安装。其中一个是上古卷轴 4:湮没,在我玩这个游戏的两个小时里,它只崩溃了一次,而且几乎是紧跟在游戏教程的自动保存点之后。 +#### 体验 Proton,没有我想的那么烂 + +例如,我安装了一些难度适中的游戏,使用 Proton 来进行安装。其中一个是《上古卷轴 4:湮没》,在我玩这个游戏的两个小时里,它只崩溃了一次,而且几乎是紧跟在游戏教程的自动保存点之后。 我有一块英伟达 Gtx 1050 Ti 的显卡。所以我可以使用 1080P 的高配置来玩这个游戏。而且我没有遇到除了这次崩溃之外的任何问题。我唯一真正感到不爽的只有它的帧数没有原本的高。在 90% 的时间里,游戏的帧数都在 60 帧以上,但我知道它的帧数应该能更高。 -我安装和发布的其他所有游戏都运行得很完美,虽然我还没有较长时间地玩过它们中的任何一个。我安装的游戏中包括森林,丧尸围城 4,H1Z1,和刺客信条 2.(你能说我这是喜欢恐怖游戏吗?)。 +我安装和运行的其他所有游戏都运行得很完美,虽然我还没有较长时间地玩过它们中的任何一个。我安装的游戏中包括《森林》、《丧尸围城 4》和《刺客信条 2》。(你觉得我这是喜欢恐怖游戏吗?) #### 为什么 Steam(仍然)要下注在 Linux 上? 现在,一切都很好,这件事为什么会发生呢?为什么 Valve 要花费时间,金钱和资源来做这样的事?我倾向于认为,他们这样做是因为他们懂得 Linux 社区的价值,但是如果要我老实地说,我不相信我们和它有任何的关系。 -如果我一定要在这上面花钱,我想说 Valve 开发了 Proton,因为他们还没有放弃 Steam 机器。因为 Steam OS 是基于 Linux 的发行版,在这类东西上面投资可以获取最大的利润,Steam OS 上可用的游戏越多,就会有更多的人愿意购买 Steam 的机器。 +如果我一定要在这上面花钱,我想说 Valve 开发了 Proton,因为他们还没有放弃 [Steam Machine][11]。因为 [Steam OS][12] 是基于 Linux 的发行版,在这类东西上面投资可以获取最大的利润,Steam OS 上可用的游戏越多,就会有更多的人愿意购买 Steam Machine。 -可能我是错的,但是我敢打赌啊,我们会在不远的未来看到新一批的 Steam 机器。可能我们会在一年内看到它们,也有可能我们再等五年都见不到,谁知道呢! +可能我是错的,但是我敢打赌啊,我们会在不远的未来看到新一批的 Steam Machine。可能我们会在一年内看到它们,也有可能我们再等五年都见不到,谁知道呢! -无论哪种方式,我所知道的是,我终于能兴奋地从我的 Steam 游戏库里玩游戏了。多年来我通过所有的收藏包,游戏促销,和不定时地买一个贱卖的游戏来以防万一,我想去尝试让它在 Lutris 中运行。 +无论哪种方式,我所知道的是,我终于能兴奋地从我的 Steam 游戏库里玩游戏了。这个游戏库是多年来我通过各种慈善包、促销码和不定时地买的游戏慢慢积累的,只不过是想试试让它在 Lutris 中运行。 #### 为 Linux 上越来越多的游戏而激动? @@ -54,7 +57,7 @@ via: https://itsfoss.com/steam-play-proton/ 作者:[Phillip Prado][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[hopefully2333](https://github.com/hopefully2333) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -71,3 +74,5 @@ via: https://itsfoss.com/steam-play-proton/ [10]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/08/SteamProton.jpg [11]:https://store.steampowered.com/sale/steam_machines [12]:https://itsfoss.com/valve-annouces-linux-based-gaming-operating-system-steamos/ +[13]:https://spcr.netlify.com/ +[14]:https://itsfoss.com/steam-play/ From 82182f5de868fa6b1bb92811ed0fe4cd77ada7c4 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 27 Sep 2018 00:08:33 +0800 Subject: [PATCH 440/455] PUB: 20180824 Steam Makes it Easier to Play Windows Games on Linux.md @hopefully2333 https://linux.cn/article-10054-1.html --- ...180824 Steam Makes it Easier to Play Windows Games on Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180824 Steam Makes it Easier to Play Windows Games on Linux.md (100%) diff --git a/translated/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md b/published/20180824 Steam Makes it Easier to Play Windows Games on Linux.md similarity index 100% rename from translated/tech/20180824 Steam Makes it Easier to Play Windows Games on Linux.md rename to published/20180824 Steam Makes it Easier to Play Windows Games on Linux.md From 424e63e8e49a0bc7d4004d12516c5b98073110a9 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 27 Sep 2018 09:05:24 +0800 Subject: [PATCH 441/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Hegemon=20?= =?UTF-8?q?=E2=80=93=20A=20Modular=20System=20Monitor=20Application=20Writ?= =?UTF-8?q?ten=20In=20Rust?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tem Monitor Application Written In Rust.md | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 sources/tech/20180925 Hegemon - A Modular System Monitor Application Written In Rust.md diff --git a/sources/tech/20180925 Hegemon - A Modular System Monitor Application Written In Rust.md b/sources/tech/20180925 Hegemon - A Modular System Monitor Application Written In Rust.md new file mode 100644 index 0000000000..14f6a2e947 --- /dev/null +++ b/sources/tech/20180925 Hegemon - A Modular System Monitor Application Written In Rust.md @@ -0,0 +1,78 @@ +Hegemon – A Modular System Monitor Application Written In Rust +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/hegemon-720x340.png) + +When it comes to monitor running processes in Unix-like systems, the most commonly used applications are **top** and **htop** , which is an enhanced version of top. My personal favorite is htop. However, the developers are releasing few alternatives to these applications every now and then. One such alternative to top and htop utilities is **Hegemon**. It is a modular system monitor application written using **Rust** programming language. + +Concerning about the features of Hegemon, we can list the following: + + * Hegemon will monitor the usage of CPU, memory and Swap. + * It monitors the system’s temperature and fan speed. + * The update interval time can be adjustable. The default value is 3 seconds. + * We can reveal more detailed graph and additional information by expanding the data streams. + * Unit tests + * Clean interface + * Free and open source. + + + +### Installing Hegemon + +Make sure you have installed **Rust 1.26** or later version. To install Rust in your Linux distribution, refer the following guide: + +[Install Rust Programming Language In Linux][2] + +Also, install [libsensors][1] library. It is available in the default repositories of most Linux distributions. For example, you can install it in RPM based systems such as Fedora using the following command: + +``` +$ sudo dnf install lm_sensors-devel +``` + +On Debian-based systems like Ubuntu, Linux Mint, it can be installed using command: + +``` +$ sudo apt-get install libsensors4-dev +``` + +Once you installed Rust and libsensors, install Hegemon using command: + +``` +$ cargo install hegemon +``` + +Once hegemon installed, start monitoring the running processes in your Linux system using command: + +``` +$ hegemon +``` + +Here is the sample output from my Arch Linux desktop. + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Hegemon-in-action.gif) + +To exit, press **Q**. + + +Please be mindful that hegemon is still in its early development stage and it is not complete replacement for **top** command. There might be bugs and missing features. If you came across any bugs, report them in the project’s github page. The developer is planning to bring more features in the upcoming versions. So, keep an eye on this project. + +And, that’s all for now. Hope this helps. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/hegemon-a-modular-system-monitor-application-written-in-rust/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://github.com/lm-sensors/lm-sensors +[2]: https://www.ostechnix.com/install-rust-programming-language-in-linux/ From 40f74a4ac5ff341a4b5d656ddbebfeb606897db6 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 27 Sep 2018 09:08:01 +0800 Subject: [PATCH 442/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20CPU=20Power=20Man?= =?UTF-8?q?ager=20=E2=80=93=20Control=20And=20Manage=20CPU=20Frequency=20I?= =?UTF-8?q?n=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ntrol And Manage CPU Frequency In Linux.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 sources/talk/20180926 CPU Power Manager - Control And Manage CPU Frequency In Linux.md diff --git a/sources/talk/20180926 CPU Power Manager - Control And Manage CPU Frequency In Linux.md b/sources/talk/20180926 CPU Power Manager - Control And Manage CPU Frequency In Linux.md new file mode 100644 index 0000000000..aeffd1f144 --- /dev/null +++ b/sources/talk/20180926 CPU Power Manager - Control And Manage CPU Frequency In Linux.md @@ -0,0 +1,74 @@ +CPU Power Manager – Control And Manage CPU Frequency In Linux +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Manage-CPU-Frequency-720x340.jpeg) + +If you are a laptop user, you probably know that power management on Linux isn’t really as good as on other OSes. While there are tools like **TLP** , [**Laptop Mode Tools** and **powertop**][1] to help reduce power consumption, overall battery life on Linux isn’t as good as Windows or Mac OS. Another way to reduce power consumption is to limit the frequency of your CPU. While this is something that has always been doable, it generally requires complicated terminal commands, making it inconvenient. But fortunately, there’s a gnome extension that helps you easily set and manage your CPU’s frequency – **CPU Power Manager**. CPU Power Manager uses the **intel_pstate** frequency scaling driver (supported by almost every Intel CPU) to control and manage CPU frequency in your GNOME desktop. + +Another reason to use this extension is to reduce heating in your system. There are many systems out there which can get uncomfortably hot in normal usage. Limiting your CPU’s frequency could reduce heating. It will also decrease the wear and tear on your CPU and other components. + +### Installing CPU Power Manager + +First, go to the [**extension’s page**][2], and install the extension. + +Once the extension has installed, you’ll get a CPU icon at the right side of the Gnome top bar. Click the icon, and you get an option to install the extension: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPU-Power-Manager-icon.png) + +If you click **“Attempt Installation”** , you’ll get a password prompt. The extension needs root privileges to add policykit rule for controlling CPU frequency. This is what the prompt looks like: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPU-Power-Manager-1.png) + +Type in your password and Click **“Authenticate”** , and that finishes installation. The last action adds a policykit file – **mko.cpupower.setcpufreq.policy** at **/usr/share/polkit-1/actions**. + +After installation is complete, if you click the CPU icon at the top right, you’ll get something like this: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPU-Power-Manager.png) + +### Features + + * **See the current CPU frequency:** Obviously, you can use this window to see the frequency that your CPU is running at. + * **Set maximum and minimum frequency:** With this extension, you can set maximum and minimum frequency limits in terms of percentage of max frequency. Once these limits are set, the CPU will operate only in this range of frequencies. + * **Turn Turbo Boost On and Off:** This is my favorite feature. Most Intel CPU’s have “Turbo Boost” feature, whereby the one of the cores of the CPU is boosted past the normal maximum frequency for extra performance. While this can make your system more performant, it also increases power consumption a lot. So if you aren’t doing anything intensive, it’s nice to be able to turn off Turbo Boost and save power. In fact, in my case, I have Turbo Boost turned off most of the time. + * **Make Profiles:** You can make profiles with max and min frequency that you can turn on/off easily instead of fiddling with max and frequencies. + + + +### Preferences + +You can also customize the extension via the preferences window: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPU-Power-Manager-preferences.png) + +As you can see, you can set whether CPU frequency is to be displayed, and whether to display it in **Mhz** or **Ghz**. + +You can also edit and create/delete profiles: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPU-Power-Manager-preferences-1.png) + +You can set maximum and minimum frequencies, and turbo boost for each profile. + +### Conclusion + +As I said in the beginning, power management on Linux is not the best, and many people are always looking to eek out a few minutes more out of their Linux laptop. If you are one of those, check out this extension. This is a unconventional method to save power, but it does work. I certainly love this extension, and have been using it for a few months now. + +What do you think about this extension? Put your thoughts in the comments below! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/cpu-power-manager-control-and-manage-cpu-frequency-in-linux/ + +作者:[EDITOR][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[1]: https://www.ostechnix.com/improve-laptop-battery-performance-linux/ +[2]: https://extensions.gnome.org/extension/945/cpu-power-manager/ From 7e099356134a14883aa35081fbda3d25a61b0fea Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 27 Sep 2018 09:08:10 +0800 Subject: [PATCH 443/455] translating --- ...led Packages And Restore Them On Freshly Installed Ubuntu.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180915 Backup Installed Packages And Restore Them On Freshly Installed Ubuntu.md b/sources/tech/20180915 Backup Installed Packages And Restore Them On Freshly Installed Ubuntu.md index d5927effee..c775fd5040 100644 --- a/sources/tech/20180915 Backup Installed Packages And Restore Them On Freshly Installed Ubuntu.md +++ b/sources/tech/20180915 Backup Installed Packages And Restore Them On Freshly Installed Ubuntu.md @@ -1,3 +1,5 @@ +translating---geekpi + Backup Installed Packages And Restore Them On Freshly Installed Ubuntu ====== From 8a1bd55b95dae3a227404ca4b0d9a88966f5a0a7 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 27 Sep 2018 09:11:35 +0800 Subject: [PATCH 444/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20Boot?= =?UTF-8?q?=20Ubuntu=2018.04=20/=20Debian=209=20Server=20in=20Rescue=20(Si?= =?UTF-8?q?ngle=20User=20mode)=20/=20Emergency=20Mode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...cue (Single User mode) - Emergency Mode.md | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 sources/tech/20180925 How to Boot Ubuntu 18.04 - Debian 9 Server in Rescue (Single User mode) - Emergency Mode.md diff --git a/sources/tech/20180925 How to Boot Ubuntu 18.04 - Debian 9 Server in Rescue (Single User mode) - Emergency Mode.md b/sources/tech/20180925 How to Boot Ubuntu 18.04 - Debian 9 Server in Rescue (Single User mode) - Emergency Mode.md new file mode 100644 index 0000000000..ff33e7c175 --- /dev/null +++ b/sources/tech/20180925 How to Boot Ubuntu 18.04 - Debian 9 Server in Rescue (Single User mode) - Emergency Mode.md @@ -0,0 +1,88 @@ +How to Boot Ubuntu 18.04 / Debian 9 Server in Rescue (Single User mode) / Emergency Mode +====== +Booting a Linux Server into a single user mode or **rescue mode** is one of the important troubleshooting that a Linux admin usually follow while recovering the server from critical conditions. In Ubuntu 18.04 and Debian 9, single user mode is known as a rescue mode. + +Apart from the rescue mode, Linux servers can be booted in **emergency mode** , the main difference between them is that, emergency mode loads a minimal environment with read only root file system file system, also it does not enable any network or other services. But rescue mode try to mount all the local file systems & try to start some important services including network. + +In this article we will discuss how we can boot our Ubuntu 18.04 LTS / Debian 9 Server in rescue mode and emergency mode. + +#### Booting Ubuntu 18.04 LTS Server in Single User / Rescue Mode: + +Reboot your server and go to boot loader (Grub) screen and Select “ **Ubuntu** “, bootloader screen would look like below, + +![](https://www.linuxtechi.com/wp-content/uploads/2018/09/Bootloader-Screen-Ubuntu18-04-Server.jpg) + +Press “ **e** ” and then go the end of line which starts with word “ **linux** ” and append “ **systemd.unit=rescue.target** “. Remove the word “ **$vt_handoff** ” if it exists. + +![](https://www.linuxtechi.com/wp-content/uploads/2018/09/rescue-target-ubuntu18-04.jpg) + +Now Press Ctrl-x or F10 to boot, + +![](https://www.linuxtechi.com/wp-content/uploads/2018/09/rescue-mode-ubuntu18-04.jpg) + +Now press enter and then you will get the shell where all file systems will be mounted in read-write mode and do the troubleshooting. Once you are done with troubleshooting, you can reboot your server using “ **reboot** ” command. + +#### Booting Ubuntu 18.04 LTS Server in emergency mode + +Reboot the server and go the boot loader screen and select “ **Ubuntu** ” and then press “ **e** ” and go to the end of line which starts with word linux, and append “ **systemd.unit=emergency.target** ” + +![](https://www.linuxtechi.com/wp-content/uploads/2018/09/Emergecny-target-ubuntu18-04-server.jpg) + +Now Press Ctlr-x or F10 to boot in emergency mode, you will get a shell and do the troubleshooting from there. As we had already discussed that in emergency mode, file systems will be mounted in read-only mode and also there will be no networking in this mode, + +![](https://www.linuxtechi.com/wp-content/uploads/2018/09/Emergency-prompt-debian9.jpg) + +Use below command to mount the root file system in read-write mode, + +``` +# mount -o remount,rw / + +``` + +Similarly, you can remount rest of file systems in read-write mode . + +#### Booting Debian 9 into Rescue & Emergency Mode + +Reboot your Debian 9.x server and go to grub screen and select “ **Debian GNU/Linux** ” + +![](https://www.linuxtechi.com/wp-content/uploads/2018/09/Debian9-Grub-Screen.jpg) + +Press “ **e** ” and go to end of line which starts with word linux and append “ **systemd.unit=rescue.target** ” to boot the system in rescue mode and to boot in emergency mode then append “ **systemd.unit=emergency.target** ” + +#### Rescue mode : + +![](https://www.linuxtechi.com/wp-content/uploads/2018/09/Rescue-mode-Debian9.jpg) + +Now press Ctrl-x or F10 to boot in rescue mode + +![](https://www.linuxtechi.com/wp-content/uploads/2018/09/Rescue-Mode-Shell-Debian9.jpg) + +Press Enter to get the shell and from there you can start troubleshooting. + +#### Emergency Mode: + +![](https://www.linuxtechi.com/wp-content/uploads/2018/09/Emergency-target-grub-debian9.jpg) + +Now press ctrl-x or F10 to boot your system in emergency mode + +![](https://www.linuxtechi.com/wp-content/uploads/2018/09/Emergency-prompt-debian9.jpg) + +Press enter to get the shell and use “ **mount -o remount,rw /** ” command to mount the root file system in read-write mode. + +**Note:** In case root password is already set in Ubuntu 18.04 and Debian 9 Server then you must enter root password to get shell in rescue and emergency mode + +That’s all from this article, please do share your feedback and comments in case you like this article. + + +-------------------------------------------------------------------------------- + +via: https://www.linuxtechi.com/boot-ubuntu-18-04-debian-9-rescue-emergency-mode/ + +作者:[Pradeep Kumar][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.linuxtechi.com/author/pradeep/ From 6b52471d8f5834463e97f3f4c6b5e3680ee2e1c8 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 27 Sep 2018 09:19:52 +0800 Subject: [PATCH 445/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20An=20introduction?= =?UTF-8?q?=20to=20swap=20space=20on=20Linux=20systems?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...oduction to swap space on Linux systems.md | 300 ++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 sources/tech/20180926 An introduction to swap space on Linux systems.md diff --git a/sources/tech/20180926 An introduction to swap space on Linux systems.md b/sources/tech/20180926 An introduction to swap space on Linux systems.md new file mode 100644 index 0000000000..036890ef4b --- /dev/null +++ b/sources/tech/20180926 An introduction to swap space on Linux systems.md @@ -0,0 +1,300 @@ +An introduction to swap space on Linux systems +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh) + +Swap space is a common aspect of computing today, regardless of operating system. Linux uses swap space to increase the amount of virtual memory available to a host. It can use one or more dedicated swap partitions or a swap file on a regular filesystem or logical volume. + +There are two basic types of memory in a typical computer. The first type, random access memory (RAM), is used to store data and programs while they are being actively used by the computer. Programs and data cannot be used by the computer unless they are stored in RAM. RAM is volatile memory; that is, the data stored in RAM is lost if the computer is turned off. + +Hard drives are magnetic media used for long-term storage of data and programs. Magnetic media is nonvolatile; the data stored on a disk remains even when power is removed from the computer. The CPU (central processing unit) cannot directly access the programs and data on the hard drive; it must be copied into RAM first, and that is where the CPU can access its programming instructions and the data to be operated on by those instructions. During the boot process, a computer copies specific operating system programs, such as the kernel and init or systemd, and data from the hard drive into RAM, where it is accessed directly by the computer’s processor, the CPU. + +### Swap space + +Swap space is the second type of memory in modern Linux systems. The primary function of swap space is to substitute disk space for RAM memory when real RAM fills up and more space is needed. + +For example, assume you have a computer system with 8GB of RAM. If you start up programs that don’t fill that RAM, everything is fine and no swapping is required. But suppose the spreadsheet you are working on grows when you add more rows, and that, plus everything else that's running, now fills all of RAM. Without swap space available, you would have to stop working on the spreadsheet until you could free up some of your limited RAM by closing down some other programs. + +The kernel uses a memory management program that detects blocks, aka pages, of memory in which the contents have not been used recently. The memory management program swaps enough of these relatively infrequently used pages of memory out to a special partition on the hard drive specifically designated for “paging,” or swapping. This frees up RAM and makes room for more data to be entered into your spreadsheet. Those pages of memory swapped out to the hard drive are tracked by the kernel’s memory management code and can be paged back into RAM if they are needed. + +The total amount of memory in a Linux computer is the RAM plus swap space and is referred to as virtual memory. + +### Types of Linux swap + +Linux provides for two types of swap space. By default, most Linux installations create a swap partition, but it is also possible to use a specially configured file as a swap file. A swap partition is just what its name implies—a standard disk partition that is designated as swap space by the `mkswap` command. + +A swap file can be used if there is no free disk space in which to create a new swap partition or space in a volume group where a logical volume can be created for swap space. This is just a regular file that is created and preallocated to a specified size. Then the `mkswap` command is run to configure it as swap space. I don’t recommend using a file for swap space unless absolutely necessary. + +### Thrashing + +Thrashing can occur when total virtual memory, both RAM and swap space, become nearly full. The system spends so much time paging blocks of memory between swap space and RAM and back that little time is left for real work. The typical symptoms of this are obvious: The system becomes slow or completely unresponsive, and the hard drive activity light is on almost constantly. + +If you can manage to issue a command like `free` that shows CPU load and memory usage, you will see that the CPU load is very high, perhaps as much as 30 to 40 times the number of CPU cores in the system. Another symptom is that both RAM and swap space are almost completely allocated. + +After the fact, looking at SAR (system activity report) data can also show these symptoms. I install SAR on every system I work on and use it for post-repair forensic analysis. + +### What is the right amount of swap space? + +Many years ago, the rule of thumb for the amount of swap space that should be allocated on the hard drive was 2X the amount of RAM installed in the computer (of course, that was when most computers' RAM was measured in KB or MB). So if a computer had 64KB of RAM, a swap partition of 128KB would be an optimum size. This rule took into account the facts that RAM sizes were typically quite small at that time and that allocating more than 2X RAM for swap space did not improve performance. With more than twice RAM for swap, most systems spent more time thrashing than actually performing useful work. + +RAM has become an inexpensive commodity and most computers these days have amounts of RAM that extend into tens of gigabytes. Most of my newer computers have at least 8GB of RAM, one has 32GB, and my main workstation has 64GB. My older computers have from 4 to 8 GB of RAM. + +When dealing with computers having huge amounts of RAM, the limiting performance factor for swap space is far lower than the 2X multiplier. The Fedora 28 online Installation Guide, which can be found online at [Fedora Installation Guide][1], defines current thinking about swap space allocation. I have included below some discussion and the table of recommendations from that document. + +The following table provides the recommended size of a swap partition depending on the amount of RAM in your system and whether you want sufficient memory for your system to hibernate. The recommended swap partition size is established automatically during installation. To allow for hibernation, however, you will need to edit the swap space in the custom partitioning stage. + +_Table 1: Recommended system swap space in Fedora 28 documentation_ + +| **Amount of system RAM** | **Recommended swap space** | **Recommended swap with hibernation** | +|--------------------------|-----------------------------|---------------------------------------| +| less than 2 GB | 2 times the amount of RAM | 3 times the amount of RAM | +| 2 GB - 8 GB | Equal to the amount of RAM | 2 times the amount of RAM | +| 8 GB - 64 GB | 0.5 times the amount of RAM | 1.5 times the amount of RAM | +| more than 64 GB | workload dependent | hibernation not recommended | + +At the border between each range listed above (for example, a system with 2 GB, 8 GB, or 64 GB of system RAM), use discretion with regard to chosen swap space and hibernation support. If your system resources allow for it, increasing the swap space may lead to better performance. + +Of course, most Linux administrators have their own ideas about the appropriate amount of swap space—as well as pretty much everything else. Table 2, below, contains my recommendations based on my personal experiences in multiple environments. These may not work for you, but as with Table 1, they may help you get started. + +_Table 2: Recommended system swap space per the author_ + +| Amount of RAM | Recommended swap space | +|---------------|------------------------| +| ≤ 2GB | 2X RAM | +| 2GB – 8GB | = RAM | +| >8GB | 8GB | + +One consideration in both tables is that as the amount of RAM increases, beyond a certain point adding more swap space simply leads to thrashing well before the swap space even comes close to being filled. If you have too little virtual memory while following these recommendations, you should add more RAM, if possible, rather than more swap space. As with all recommendations that affect system performance, use what works best for your specific environment. This will take time and effort to experiment and make changes based on the conditions in your Linux environment. + +#### Adding more swap space to a non-LVM disk environment + +Due to changing requirements for swap space on hosts with Linux already installed, it may become necessary to modify the amount of swap space defined for the system. This procedure can be used for any general case where the amount of swap space needs to be increased. It assumes sufficient available disk space is available. This procedure also assumes that the disks are partitioned in “raw” EXT4 and swap partitions and do not use logical volume management (LVM). + +The basic steps to take are simple: + + 1. Turn off the existing swap space. + + 2. Create a new swap partition of the desired size. + + 3. Reread the partition table. + + 4. Configure the partition as swap space. + + 5. Add the new partition/etc/fstab. + + 6. Turn on swap. + + + + +A reboot should not be necessary. + +For safety's sake, before turning off swap, at the very least you should ensure that no applications are running and that no swap space is in use. The `free` or `top` commands can tell you whether swap space is in use. To be even safer, you could revert to run level 1 or single-user mode. + +Turn off the swap partition with the command which turns off all swap space: + +``` +swapoff -a + +``` + +Now display the existing partitions on the hard drive. + +``` +fdisk -l + +``` + +This displays the current partition tables on each drive. Identify the current swap partition by number. + +Start `fdisk` in interactive mode with the command: + +``` +fdisk /dev/ + +``` + +For example: + +``` +fdisk /dev/sda + +``` + +At this point, `fdisk` is now interactive and will operate only on the specified disk drive. + +Use the fdisk `p` sub-command to verify that there is enough free space on the disk to create the new swap partition. The space on the hard drive is shown in terms of 512-byte blocks and starting and ending cylinder numbers, so you may have to do some math to determine the available space between and at the end of allocated partitions. + +Use the `n` sub-command to create a new swap partition. fdisk will ask you the starting cylinder. By default, it chooses the lowest-numbered available cylinder. If you wish to change that, type in the number of the starting cylinder. + +The `fdisk` command now allows you to enter the size of the partitions in a number of formats, including the last cylinder number or the size in bytes, KB or MB. Type in 4000M, which will give about 4GB of space on the new partition (for example), and press Enter. + +Use the `p` sub-command to verify that the partition was created as you specified it. Note that the partition will probably not be exactly what you specified unless you used the ending cylinder number. The `fdisk` command can only allocate disk space in increments on whole cylinders, so your partition may be a little smaller or larger than you specified. If the partition is not what you want, you can delete it and create it again. + +Now it is necessary to specify that the new partition is to be a swap partition. The sub-command `t` allows you to specify the type of partition. So enter `t`, specify the partition number, and when it asks for the hex code partition type, type 82, which is the Linux swap partition type, and press Enter. + +When you are satisfied with the partition you have created, use the `w` sub-command to write the new partition table to the disk. The `fdisk` program will exit and return you to the command prompt after it completes writing the revised partition table. You will probably receive the following message as `fdisk` completes writing the new partition table: + +``` +The partition table has been altered! +Calling ioctl() to re-read partition table. +WARNING: Re-reading the partition table failed with error 16: Device or resource busy. +The kernel still uses the old table. +The new table will be used at the next reboot. +Syncing disks. +``` + +At this point, you use the `partprobe` command to force the kernel to re-read the partition table so that it is not necessary to perform a reboot. + +``` +partprobe +``` + +Now use the command `fdisk -l` to list the partitions and the new swap partition should be among those listed. Be sure that the new partition type is “Linux swap”. + +It will be necessary to modify the /etc/fstab file to point to the new swap partition. The existing line may look like this: + +``` +LABEL=SWAP-sdaX   swap        swap    defaults        0 0 + +``` + +where `X` is the partition number. Add a new line that looks similar this, depending upon the location of your new swap partition: + +``` +/dev/sdaY         swap        swap    defaults        0 0 + +``` + +Be sure to use the correct partition number. Now you can perform the final step in creating the swap partition. Use the `mkswap` command to define the partition as a swap partition. + +``` +mkswap /dev/sdaY + +``` + +The final step is to turn swap on using the command: + +``` +swapon -a + +``` + +Your new swap partition is now online along with the previously existing swap partition. You can use the `free` or `top` commands to verify this. + +#### Adding swap to an LVM disk environment + +If your disk setup uses LVM, changing swap space will be fairly easy. Again, this assumes that space is available in the volume group in which the current swap volume is located. By default, the installation procedures for Fedora Linux in an LVM environment create the swap partition as a logical volume. This makes it easy because you can simply increase the size of the swap volume. + +Here are the steps required to increase the amount of swap space in an LVM environment: + + 1. Turn off all swap. + + 2. Increase the size of the logical volume designated for swap. + + 3. Configure the resized volume as swap space. + + 4. Turn on swap. + + + + +First, let’s verify that swap exists and is a logical volume using the `lvs` command (list logical volume). + +``` +[root@studentvm1 ~]# lvs +  LV     VG                Attr       LSize  Pool   Origin Data%  Meta%  Move Log Cpy%Sync Convert +  home   fedora_studentvm1 -wi-ao----  2.00g                                                       +  pool00 fedora_studentvm1 twi-aotz--  2.00g               8.17   2.93                             +  root   fedora_studentvm1 Vwi-aotz--  2.00g pool00        8.17                                   +  swap   fedora_studentvm1 -wi-ao----  8.00g                                                       +  tmp    fedora_studentvm1 -wi-ao----  5.00g                                                       +  usr    fedora_studentvm1 -wi-ao---- 15.00g                                                       +  var    fedora_studentvm1 -wi-ao---- 10.00g                                                       +[root@studentvm1 ~]# +``` + +You can see that the current swap size is 8GB. In this case, we want to add 2GB to this swap volume. First, stop existing swap. You may have to terminate running programs if swap space is in use. + +``` +swapoff -a + +``` + +Now increase the size of the logical volume. + +``` +[root@studentvm1 ~]# lvextend -L +2G /dev/mapper/fedora_studentvm1-swap +  Size of logical volume fedora_studentvm1/swap changed from 8.00 GiB (2048 extents) to 10.00 GiB (2560 extents). +  Logical volume fedora_studentvm1/swap successfully resized. +[root@studentvm1 ~]# +``` + +Run the `mkswap` command to make this entire 10GB partition into swap space. + +``` +[root@studentvm1 ~]# mkswap /dev/mapper/fedora_studentvm1-swap +mkswap: /dev/mapper/fedora_studentvm1-swap: warning: wiping old swap signature. +Setting up swapspace version 1, size = 10 GiB (10737414144 bytes) +no label, UUID=3cc2bee0-e746-4b66-aa2d-1ea15ef1574a +[root@studentvm1 ~]# +``` + +Turn swap back on. + +``` +[root@studentvm1 ~]# swapon -a +[root@studentvm1 ~]# +``` + +Now verify the new swap space is present with the list block devices command. Again, a reboot is not required. + +``` +[root@studentvm1 ~]# lsblk +NAME                                 MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT +sda                                    8:0    0   60G  0 disk +|-sda1                                 8:1    0    1G  0 part /boot +`-sda2                                 8:2    0   59G  0 part +  |-fedora_studentvm1-pool00_tmeta   253:0    0    4M  0 lvm   +  | `-fedora_studentvm1-pool00-tpool 253:2    0    2G  0 lvm   +  |   |-fedora_studentvm1-root       253:3    0    2G  0 lvm  / +  |   `-fedora_studentvm1-pool00     253:6    0    2G  0 lvm   +  |-fedora_studentvm1-pool00_tdata   253:1    0    2G  0 lvm   +  | `-fedora_studentvm1-pool00-tpool 253:2    0    2G  0 lvm   +  |   |-fedora_studentvm1-root       253:3    0    2G  0 lvm  / +  |   `-fedora_studentvm1-pool00     253:6    0    2G  0 lvm   +  |-fedora_studentvm1-swap           253:4    0   10G  0 lvm  [SWAP] +  |-fedora_studentvm1-usr            253:5    0   15G  0 lvm  /usr +  |-fedora_studentvm1-home           253:7    0    2G  0 lvm  /home +  |-fedora_studentvm1-var            253:8    0   10G  0 lvm  /var +  `-fedora_studentvm1-tmp            253:9    0    5G  0 lvm  /tmp +sr0                                   11:0    1 1024M  0 rom   +[root@studentvm1 ~]# +``` + +You can also use the `swapon -s` command, or `top`, `free`, or any of several other commands to verify this. + +``` +[root@studentvm1 ~]# free +              total        used        free      shared  buff/cache   available +Mem:        4038808      382404     2754072        4152      902332     3404184 +Swap:      10485756           0    10485756 +[root@studentvm1 ~]# +``` + +Note that the different commands display or require as input the device special file in different forms. There are a number of ways in which specific devices are accessed in the /dev directory. My article, [Managing Devices in Linux][2], includes more information about the /dev directory and its contents. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/swap-space-linux-systems + +作者:[David Both][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/dboth +[1]: https://docs.fedoraproject.org/en-US/fedora/f28/install-guide/ +[2]: https://opensource.com/article/16/11/managing-devices-linux From 982cca6773a6fdba251cff08e669b1e5bf2fd46c Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 27 Sep 2018 09:22:13 +0800 Subject: [PATCH 446/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=209=20Easiest=20Way?= =?UTF-8?q?s=20To=20Find=20Out=20Process=20ID=20(PID)=20In=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...s To Find Out Process ID (PID) In Linux.md | 208 ++++++++++++++++++ 1 file changed, 208 insertions(+) create mode 100644 sources/tech/20180925 9 Easiest Ways To Find Out Process ID (PID) In Linux.md diff --git a/sources/tech/20180925 9 Easiest Ways To Find Out Process ID (PID) In Linux.md b/sources/tech/20180925 9 Easiest Ways To Find Out Process ID (PID) In Linux.md new file mode 100644 index 0000000000..ae353bf11f --- /dev/null +++ b/sources/tech/20180925 9 Easiest Ways To Find Out Process ID (PID) In Linux.md @@ -0,0 +1,208 @@ +9 Easiest Ways To Find Out Process ID (PID) In Linux +====== +Everybody knows about PID, Exactly what is PID? Why you want PID? What are you going to do using PID? Are you having the same questions on your mind? If so, you are in the right place to get all the details. + +Mainly, we are looking PID to kill an unresponsive program and it’s similar to Windows task manager. Linux GUI also offering the same feature but CLI is an efficient way to perform the kill operation. + +### What Is Process ID? + +PID stands for process identification number which is generally used by most operating system kernels such as Linux, Unix, macOS and Windows. It is a unique identification number that is automatically assigned to each process when it is created in an operating system. A process is a running instance of a program. + +**Suggested Read :** +**(#)** [How To Find Out Which Port Number A Process Is Using In Linux][1] +**(#)** [3 Easy Ways To Kill Or Terminate A Process In Linux][2] + +Each time process ID will be getting change to all the processes except init because init is always the first process on the system and is the ancestor of all other processes. It’s PID is 1. + +The default maximum value of PIDs is `32,768`. The same has been verified by running the following command on your system `cat /proc/sys/kernel/pid_max`. On 32-bit systems 32768 is the maximum value but we can set to any value up to 2^22 (approximately 4 million) on 64-bit systems. + +You may ask, why we need such amount of PIDs? because we can’t reused the PIDs immediately that’s why. Also in order to prevent possible errors. + +The PID for the running processes on the system can be found by using the below nine methods such as pidof command, pgrep command, ps command, pstree command, ss command, netstat command, lsof command, fuser command and systemctl command. + +This can be achieved using the below six methods. + + * `pidof:` pidof — find the process ID of a running program. + * `pgrep:` pgre – look up or signal processes based on name and other attributes. + * `ps:` ps – report a snapshot of the current processes. + * `pstree:` pstree – display a tree of processes. + * `ss:` ss is used to dump socket statistics. + * `netstat:` netstat is displays a list of open sockets. + * `lsof:` lsof – list open files. + * `fuser:` fuser – list process IDs of all processes that have one or more files open + * `systemctl:` systemctl – Control the systemd system and service manager + + + +In this tutorial we are going to find out the Apache process id to test this article. Make sure your need to input your process name instead of us. + +### Method-1 : Using pidof Command + +pidof used to find the process ID of a running program. It’s prints those id’s on the standard output. To demonstrate this, we are going to find out the Apache2 process id from Debian 9 (stretch) system. + +``` +# pidof apache2 +3754 2594 2365 2364 2363 2362 2361 + +``` + +From the above output you may face difficulties to identify the Process ID because it’s shows all the PIDs (included Parent and Childs) aginst the process name. Hence we need to find out the parent PID (PPID), which is the one we are looking. It could be the first number. In my case it’s `3754` and it’s shorted in descending order. + +### Method-2 : Using pgrep Command + +pgrep looks through the currently running processes and lists the process IDs which match the selection criteria to stdout. + +``` +# pgrep apache2 +2361 +2362 +2363 +2364 +2365 +2594 +3754 + +``` + +This also similar to the above output but it’s shorting the results in ascending order, which clearly says that the parent PID is the last one. In my case it’s `3754`. + +**Note :** If you have more than one process id of the process, you may face trouble to identify the parent process id when using pidof & pgrep command. + +### Method-3 : Using pstree Command + +pstree shows running processes as a tree. The tree is rooted at either pid or init if pid is omitted. If a user name is specified in the pstree command then it’s shows all the process owned by the corresponding user. + +pstree visually merges identical branches by putting them in square brackets and prefixing them with the repetition count. + +``` +# pstree -p | grep "apache2" + |-apache2(3754)-|-apache2(2361) + | |-apache2(2362) + | |-apache2(2363) + | |-apache2(2364) + | |-apache2(2365) + | `-apache2(2594) + +``` + +To get parent process alone, use the following format. + +``` +# pstree -p | grep "apache2" | head -1 + |-apache2(3754)-|-apache2(2361) + +``` + +pstree command is very simple because it’s segregating the Parent and Child processes separately but it’s not easy when using pidof & pgrep command. + +### Method-4 : Using ps Command + +ps displays information about a selection of the active processes. It displays the process ID (pid=PID), the terminal associated with the process (tname=TTY), the cumulated CPU time in [DD-]hh:mm:ss format (time=TIME), and the executable name (ucmd=CMD). Output is unsorted by default. + +``` +# ps aux | grep "apache2" +www-data 2361 0.0 0.4 302652 9732 ? S 06:25 0:00 /usr/sbin/apache2 -k start +www-data 2362 0.0 0.4 302652 9732 ? S 06:25 0:00 /usr/sbin/apache2 -k start +www-data 2363 0.0 0.4 302652 9732 ? S 06:25 0:00 /usr/sbin/apache2 -k start +www-data 2364 0.0 0.4 302652 9732 ? S 06:25 0:00 /usr/sbin/apache2 -k start +www-data 2365 0.0 0.4 302652 8400 ? S 06:25 0:00 /usr/sbin/apache2 -k start +www-data 2594 0.0 0.4 302652 8400 ? S 06:55 0:00 /usr/sbin/apache2 -k start +root 3754 0.0 1.4 302580 29324 ? Ss Dec11 0:23 /usr/sbin/apache2 -k start +root 5648 0.0 0.0 12784 940 pts/0 S+ 21:32 0:00 grep apache2 + +``` + +From the above output we can easily identify the parent process id (PPID) based on the process start date. In my case apache2 process was started @ `Dec11` which is the parent and others are child’s. PID of apache2 is `3754`. + +### Method-5: Using ss Command + +ss is used to dump socket statistics. It allows showing information similar to netstat. It can display more TCP and state informations than other tools. + +It can display stats for all kind of sockets such as PACKET, TCP, UDP, DCCP, RAW, Unix domain, etc. + +``` +# ss -tnlp | grep apache2 +LISTEN 0 128 :::80 :::* users:(("apache2",pid=3319,fd=4),("apache2",pid=3318,fd=4),("apache2",pid=3317,fd=4)) + +``` + +### Method-6: Using netstat Command + +netstat – Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. +By default, netstat displays a list of open sockets. + +If you don’t specify any address families, then the active sockets of all configured address families will be printed. This program is obsolete. Replacement for netstat is ss. + +``` +# netstat -tnlp | grep apache2 +tcp6 0 0 :::80 :::* LISTEN 3317/apache2 + +``` + +### Method-7: Using lsof Command + +lsof – list open files. The Linux lsof command lists information about files that are open by processes running on the system. + +``` +# lsof -i -P | grep apache2 +apache2 3317 root 4u IPv6 40518 0t0 TCP *:80 (LISTEN) +apache2 3318 www-data 4u IPv6 40518 0t0 TCP *:80 (LISTEN) +apache2 3319 www-data 4u IPv6 40518 0t0 TCP *:80 (LISTEN) + +``` + +### Method-8: Using fuser Command + +The fuser utility shall write to standard output the process IDs of processes running on the local system that have one or more named files open. + +``` +# fuser -v 80/tcp + USER PID ACCESS COMMAND +80/tcp: root 3317 F.... apache2 + www-data 3318 F.... apache2 + www-data 3319 F.... apache2 + +``` + +### Method-9: Using systemctl Command + +systemctl – Control the systemd system and service manager. This is the replacement of old SysV init system management and +most of the modern Linux operating systems were adapted systemd. + +``` +# systemctl status apache2 +● apache2.service - The Apache HTTP Server + Loaded: loaded (/lib/systemd/system/apache2.service; disabled; vendor preset: enabled) + Drop-In: /lib/systemd/system/apache2.service.d + └─apache2-systemd.conf + Active: active (running) since Tue 2018-09-25 10:03:28 IST; 3s ago + Process: 3294 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS) + Main PID: 3317 (apache2) + Tasks: 55 (limit: 4915) + Memory: 7.9M + CPU: 71ms + CGroup: /system.slice/apache2.service + ├─3317 /usr/sbin/apache2 -k start + ├─3318 /usr/sbin/apache2 -k start + └─3319 /usr/sbin/apache2 -k start + +Sep 25 10:03:28 ubuntu systemd[1]: Starting The Apache HTTP Server... +Sep 25 10:03:28 ubuntu systemd[1]: Started The Apache HTTP Server. + +``` + + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/9-methods-to-check-find-the-process-id-pid-ppid-of-a-running-program-in-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[1]: https://www.2daygeek.com/how-to-find-out-which-port-number-a-process-is-using-in-linux/ +[2]: https://www.2daygeek.com/kill-terminate-a-process-in-linux-using-kill-pkill-killall-command/ From cbb1782339f6b596c3188d6e248460475a5c45ce Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 27 Sep 2018 09:24:34 +0800 Subject: [PATCH 447/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20use=20?= =?UTF-8?q?the=20Scikit-learn=20Python=20library=20for=20data=20science=20?= =?UTF-8?q?projects?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ython library for data science projects.md | 258 ++++++++++++++++++ 1 file changed, 258 insertions(+) create mode 100644 sources/tech/20180926 How to use the Scikit-learn Python library for data science projects.md diff --git a/sources/tech/20180926 How to use the Scikit-learn Python library for data science projects.md b/sources/tech/20180926 How to use the Scikit-learn Python library for data science projects.md new file mode 100644 index 0000000000..4f5d9aedf6 --- /dev/null +++ b/sources/tech/20180926 How to use the Scikit-learn Python library for data science projects.md @@ -0,0 +1,258 @@ +How to use the Scikit-learn Python library for data science projects +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X) + +The Scikit-learn Python library, initially released in 2007, is commonly used in solving machine learning and data science problems—from the beginning to the end. The versatile library offers an uncluttered, consistent, and efficient API and thorough online documentation. + +### What is Scikit-learn? + +[Scikit-learn][1] is an open source Python library that has powerful tools for data analysis and data mining. It's available under the BSD license and is built on the following machine learning libraries: + + * **NumPy** , a library for manipulating multi-dimensional arrays and matrices. It also has an extensive compilation of mathematical functions for performing various calculations. + * **SciPy** , an ecosystem consisting of various libraries for completing technical computing tasks. + * **Matplotlib** , a library for plotting various charts and graphs. + + + +Scikit-learn offers an extensive range of built-in algorithms that make the most of data science projects. + +Here are the main ways the Scikit-learn library is used. + +#### 1. Classification + +The [classification][2] tools identify the category associated with provided data. For example, they can be used to categorize email messages as either spam or not. + + * Support vector machines (SVMs) + * Nearest neighbors + * Random forest + + + +#### 2. Regression + +Classification algorithms in Scikit-learn include: + +Regression involves creating a model that tries to comprehend the relationship between input and output data. For example, regression tools can be used to understand the behavior of stock prices. + +Regression algorithms include: + + * SVMs + * Ridge regression + * Lasso + + + +#### 3. Clustering + +The Scikit-learn clustering tools are used to automatically group data with the same characteristics into sets. For example, customer data can be segmented based on their localities. + +Clustering algorithms include: + + * K-means + * Spectral clustering + * Mean-shift + + + +#### 4. Dimensionality reduction + +Dimensionality reduction lowers the number of random variables for analysis. For example, to increase the efficiency of visualizations, outlying data may not be considered. + +Dimensionality reduction algorithms include: + + * Principal component analysis (PCA) + * Feature selection + * Non-negative matrix factorization + + + +#### 5. Model selection + +Model selection algorithms offer tools to compare, validate, and select the best parameters and models to use in your data science projects. + +Model selection modules that can deliver enhanced accuracy through parameter tuning include: + + * Grid search + * Cross-validation + * Metrics + + + +#### 6. Preprocessing + +The Scikit-learn preprocessing tools are important in feature extraction and normalization during data analysis. For example, you can use these tools to transform input data—such as text—and apply their features in your analysis. + +Preprocessing modules include: + + * Preprocessing + * Feature extraction + + + +### A Scikit-learn library example + +Let's use a simple example to illustrate how you can use the Scikit-learn library in your data science projects. + +We'll use the [Iris flower dataset][3], which is incorporated in the Scikit-learn library. The Iris flower dataset contains 150 details about three flower species: + + * Setosa—labeled 0 + * Versicolor—labeled 1 + * Virginica—labeled 2 + + + +The dataset includes the following characteristics of each flower species (in centimeters): + + * Sepal length + * Sepal width + * Petal length + * Petal width + + + +#### Step 1: Importing the library + +Since the Iris dataset is included in the Scikit-learn data science library, we can load it into our workspace as follows: + +``` +from sklearn import datasets +iris = datasets.load_iris() +``` + +These commands import the **datasets** module from **sklearn** , then use the **load_digits()** method from **datasets** to include the data in the workspace. + +#### Step 2: Getting dataset characteristics + +The **datasets** module contains several methods that make it easier to get acquainted with handling data. + +In Scikit-learn, a dataset refers to a dictionary-like object that has all the details about the data. The data is stored using the **.data** key, which is an array list. + +For instance, we can utilize **iris.data** to output information about the Iris flower dataset. + +``` +print(iris.data) +``` + +Here is the output (the results have been truncated): + +``` +[[5.1 3.5 1.4 0.2] + [4.9 3.  1.4 0.2] + [4.7 3.2 1.3 0.2] + [4.6 3.1 1.5 0.2] + [5.  3.6 1.4 0.2] + [5.4 3.9 1.7 0.4] + [4.6 3.4 1.4 0.3] + [5.  3.4 1.5 0.2] + [4.4 2.9 1.4 0.2] + [4.9 3.1 1.5 0.1] + [5.4 3.7 1.5 0.2] + [4.8 3.4 1.6 0.2] + [4.8 3.  1.4 0.1] + [4.3 3.  1.1 0.1] + [5.8 4.  1.2 0.2] + [5.7 4.4 1.5 0.4] + [5.4 3.9 1.3 0.4] + [5.1 3.5 1.4 0.3] +``` + +Let's also use **iris.target** to give us information about the different labels of the flowers. + +``` +print(iris.target) +``` + +Here is the output: + +``` +[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 + 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 + 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 + 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 + 2 2] + +``` + +If we use **iris.target_names** , we'll output an array of the names of the labels found in the dataset. + +``` +print(iris.target_names) +``` + +Here is the result after running the Python code: + +``` +['setosa' 'versicolor' 'virginica'] +``` + +#### Step 3: Visualizing the dataset + +We can use the [box plot][4] to produce a visual depiction of the Iris flower dataset. The box plot illustrates how the data is distributed over the plane through their quartiles. + +Here's how to achieve this: + +``` +import seaborn as sns +box_data = iris.data #variable representing the data array +box_target = iris.target #variable representing the labels array +sns.boxplot(data = box_data,width=0.5,fliersize=5) +sns.set(rc={'figure.figsize':(2,15)}) +``` + +Let's see the result: + +![](https://opensource.com/sites/default/files/uploads/scikit_boxplot.png) + +On the horizontal axis: + + * 0 is sepal length + * 1 is sepal width + * 2 is petal length + * 3 is petal width + + + +The vertical axis is dimensions in centimeters. + +### Wrapping up + +Here is the entire code for this simple Scikit-learn data science tutorial. + +``` +from sklearn import datasets +iris = datasets.load_iris() +print(iris.data) +print(iris.target) +print(iris.target_names) +import seaborn as sns +box_data = iris.data #variable representing the data array +box_target = iris.target #variable representing the labels array +sns.boxplot(data = box_data,width=0.5,fliersize=5) +sns.set(rc={'figure.figsize':(2,15)}) +``` + +Scikit-learn is a versatile Python library you can use to efficiently complete data science projects. + +If you want to learn more, check out the tutorials on [LiveEdu][5], such as Andrey Bulezyuk's video on using the Scikit-learn library to create a [machine learning application][6]. + +Do you have any questions or comments? Feel free to share them below. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/how-use-scikit-learn-data-science-projects + +作者:[Dr.Michael J.Garbade][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/drmjg +[1]: http://scikit-learn.org/stable/index.html +[2]: https://blog.liveedu.tv/regression-versus-classification-machine-learning-whats-the-difference/ +[3]: https://en.wikipedia.org/wiki/Iris_flower_data_set +[4]: https://en.wikipedia.org/wiki/Box_plot +[5]: https://www.liveedu.tv/guides/data-science/ +[6]: https://www.liveedu.tv/andreybu/REaxr-machine-learning-model-python-sklearn-kera/oPGdP-machine-learning-model-python-sklearn-kera/ From 05902bc1d225b9c9c5d54acd86b2df582a491cc8 Mon Sep 17 00:00:00 2001 From: HankChow <280630620@qq.com> Date: Thu, 27 Sep 2018 09:51:24 +0800 Subject: [PATCH 448/455] translated --- ...ing Command Prettier And Easier To Read.md | 131 ------------------ ...ing Command Prettier And Easier To Read.md | 128 +++++++++++++++++ 2 files changed, 128 insertions(+), 131 deletions(-) delete mode 100644 sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md create mode 100644 translated/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md diff --git a/sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md b/sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md deleted file mode 100644 index 7ef713eae4..0000000000 --- a/sources/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md +++ /dev/null @@ -1,131 +0,0 @@ -HankChow translating - -Make The Output Of Ping Command Prettier And Easier To Read -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/prettyping-720x340.png) - -As we all know, the **ping** command is used to check if a target host is reachable or not. Using Ping command, we can send ICMP Echo request to our target host, and verify whether the destination host is up or down. If you use ping command often, I’d like to recommend you to try **“Prettyping”**. Prettyping is just a wrapper for the standard ping tool and makes the output of the ping command prettier, easier to read, colorful and compact. The prettyping runs the standard ping command in the background and parses the output with colors and unicode characters. It is free and open source tool written in **Bash** and **awk** and supports most Unix-like operating systems such as GNU/Linux, FreeBSD and Mac OS X. Prettyping is not only used to make the output of ping command prettier, but also ships with other notable features as listed below. - - * Detects the lost or missing packets and marks them in the output. - * Shows live statistics. The statistics are constantly updated after each response is received, while ping only shows after it ends. - * Smart enough to handle “unknown messages” (like error messages) without messing up the output. - * Avoids printing the repeated messages. - * You can use most common ping parameters with Prettyping. - * Can run as normal user. - * Can be able to redirect the output to a file. - * Requires no installation. Just download the binary, make it executable and run. - * Fast and lightweight. - * And, finally makes the output pretty, colorful and very intuitive. - - - -### Installing Prettyping - -Like I said already, Prettyping does not requires any installation. It is portable application! Just download the Prettyping binary file using command: - -``` -$ curl -O https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping -``` - -Move the binary file to your $PATH, for example **/usr/local/bin**. - -``` -$ sudo mv prettyping /usr/local/bin -``` - -And, make it executable as like below: - -``` -$ sudo chmod +x /usr/local/bin/prettyping -``` - -It’s that simple. - -### Let us Make The Output Of Ping Command Prettier And Easier To Read - -Once installed, ping any host or IP address and see the ping command output in graphical way. - -``` -$ prettyping ostechnix.com -``` - -Here is the visually displayed ping output: - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/prettyping-in-action.gif) - -If you run Prettyping without any arguments, it will keep running until you manually stop it by pressing **Ctrl+c**. - -Since Prettyping is just a wrapper to the ping command, you can use most common ping parameters. For instance, you can use **-c** flag to ping a host only a specific number of times, for example **5** : - -``` -$ prettyping -c 5 ostechnix.com -``` - -By default, prettynping displays the output in colored format. Don’t like the colored output? No problem! Use `--nocolor` option. - -``` -$ prettyping --nocolor ostechnix.com -``` - -Similarly, you can disable mult-color support using `--nomulticolor` option: - -``` -$ prettyping --nomulticolor ostechnix.com -``` - -To disable unicode characters, use `--nounicode` option: - -![](https://www.ostechnix.com/wp-content/uploads/2018/09/prettyping-without-unicode-support.png) - -This can be useful if your terminal does not support **UTF-8**. If you can’t fix the unicode (fonts) in your system, simply pass `--nounicode` option. - -Prettyping can redirect the output to a file as well. The following command will write the output of `prettyping ostechnix.com` command in `ostechnix.txt` file. - -``` -$ prettyping ostechnix.com | tee ostechnix.txt -``` - -Prettyping has few more options which helps you to do various tasks, such as, - - * Enable/disable the latency legend. (default value is: enabled) - * Force the output designed to a terminal. (default: auto) - * Use the last “n” pings at the statistics line. (default: 60) - * Override auto-detection of terminal dimensions. - * Override the awk interpreter. (default: awk) - * Override the ping tool. (default: ping) - - - -For more details, view the help section: - -``` -$ prettyping --help -``` - -Even though Prettyping doesn’t add any extra functionality, I personally like the following feature implementations in it: - - * Live statistics – You can see all the live statistics all the time. The standard ping command will only shows the statistics after it ends. - * Compact – You can see a longer timespan at your terminal. - * Prettyping detects missing responses. - - - -If you’re ever looking for a way to visually display the output of the ping command, Prettyping will definitely help. Give it a try, you won’t be disappointed. - -And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/prettyping-make-the-output-of-ping-command-prettier-and-easier-to-read/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/sk/ diff --git a/translated/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md b/translated/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md new file mode 100644 index 0000000000..efca96da23 --- /dev/null +++ b/translated/tech/20180924 Make The Output Of Ping Command Prettier And Easier To Read.md @@ -0,0 +1,128 @@ +如何让 Ping 的输出更简单易读 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/prettyping-720x340.png) + +众所周知,`ping` 命令可以用来检查目标主机是否可达。使用 `ping` 命令的时候,会发送一个 ICMP Echo 请求,通过目标主机的响应与否来确定目标主机的状态。如果你经常使用 `ping` 命令,你可以尝试一下 `prettyping`。Prettyping 只是将一个标准的 ping 工具增加了一层封装,在运行标准 ping 命令的同时添加了颜色和 unicode 字符解析输出,所以它的输出更漂亮紧凑、清晰易读。它是用 `bash` 和 `awk` 编写的免费开源工具,支持大部分类 Unix 操作系统,包括 GNU/Linux、FreeBSD 和 Mac OS X。Prettyping 除了美化 ping 命令的输出,还有很多值得注意的功能。 + + * 检测丢失的数据包并在输出中标记出来。 + * 显示实时数据。每次收到响应后,都会更新统计数据,而对于普通 ping 命令,只会在执行结束后统计。 + * 能够在输出结果不混乱的前提下灵活处理“未知信息”(例如错误信息)。 + * 能够避免输出重复的信息。 + * 兼容常用的 ping 工具命令参数。 + * 能够由普通用户执行。 + * 可以将输出重定向到文件中。 + * 不需要安装,只需要下载二进制文件,赋予可执行权限即可执行。 + * 快速且轻巧。 + * 输出结果清晰直观。 + + + +### 安装 Prettyping + +如上所述,Prettyping 是一个绿色软件,不需要任何安装,只要使用以下命令下载 Prettyping 二进制文件: + +``` +$ curl -O https://raw.githubusercontent.com/denilsonsa/prettyping/master/prettyping +``` + +将二进制文件放置到 `$PATH`(例如 `/usr/local/bin`)中: + +``` +$ sudo mv prettyping /usr/local/bin +``` + +然后对其赋予可执行权限: + +``` +$ sudo chmod +x /usr/local/bin/prettyping +``` + +就可以使用了。 + +### 让 ping 的输出清晰易读 + +安装完成后,通过 `prettyping` 来 ping 任何主机或 IP 地址,就可以以图形方式查看输出。 + +``` +$ prettyping ostechnix.com +``` + +输出效果大概会是这样: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/prettyping-in-action.gif) + +如果你不带任何参数执行 `prettyping`,它就会一直运行直到被 ctrl + c 中断。 + +由于 Prettyping 只是一个对普通 ping 命令的封装,所以常用的 ping 参数也是有效的。例如使用 `-c 5` 来指定 ping 一台主机的 5 次: + +``` +$ prettyping -c 5 ostechnix.com +``` + +Prettyping 默认会使用彩色输出,如果你不喜欢彩色的输出,可以加上 `--nocolor` 参数: + +``` +$ prettyping --nocolor ostechnix.com +``` + +同样的,也可以用 `--nomulticolor` 参数禁用多颜色支持: + +``` +$ prettyping --nomulticolor ostechnix.com +``` + +使用 `--nounicode` 参数禁用 unicode 字符: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/prettyping-without-unicode-support.png) + +如果你的终端不支持 **UTF-8**,或者无法修复系统中的 unicode 字体,只需要加上 `--nounicode` 参数就能轻松解决。 + +Prettyping 支持将输出的内容重定向到文件中,例如执行以下这个命令会将 `prettyping ostechnix.com` 的输出重定向到 `ostechnix.txt` 中: + +``` +$ prettyping ostechnix.com | tee ostechnix.txt +``` + +Prettyping 还有很多选项帮助你完成各种任务,例如: + + * 启用/禁用延时图例(默认启用) + * 强制按照终端的格式输出(默认自动) + * 在统计数据中统计最后的 n 次 ping(默认 60 次) + * 覆盖对终端尺寸的检测 + * 覆盖 awk 解释器(默认不覆盖) + * 覆盖 ping 工具(默认不覆盖) + + + +查看帮助文档可以了解更多: + +``` +$ prettyping --help +``` + +尽管 prettyping 没有添加任何额外功能,但我个人喜欢它的这些优点: + + * 实时统计 - 可以随时查看所有实时统计信息,标准 `ping` 命令只会在命令执行结束后才显示统计信息。 + * 紧凑的显示 - 可以在终端看到更长的时间跨度。 + * 检测丢失的数据包并显示出来。 + + + +如果你一直在寻找可视化显示 `ping` 命令输出的工具,那么 Prettyping 肯定会有所帮助。尝试一下,你不会失望的。 + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/prettyping-make-the-output-of-ping-command-prettier-and-easier-to-read/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[HankChow](https://github.com/HankChow) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ + From cef6b4d99f7e92f4c82a1b411db32b0072be16fa Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 27 Sep 2018 09:52:20 +0800 Subject: [PATCH 449/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Control=20your=20?= =?UTF-8?q?data=20with=20Syncthing:=20An=20open=20source=20synchronization?= =?UTF-8?q?=20tool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ng- An open source synchronization tool.md | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 sources/tech/20180921 Control your data with Syncthing- An open source synchronization tool.md diff --git a/sources/tech/20180921 Control your data with Syncthing- An open source synchronization tool.md b/sources/tech/20180921 Control your data with Syncthing- An open source synchronization tool.md new file mode 100644 index 0000000000..32be152b4c --- /dev/null +++ b/sources/tech/20180921 Control your data with Syncthing- An open source synchronization tool.md @@ -0,0 +1,108 @@ +Control your data with Syncthing: An open source synchronization tool +====== +Decide how to store and share your personal information. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus_cloud_database.png?itok=lhhU42fg) + +These days, some of our most important possessions—from pictures and videos of family and friends to financial and medical documents—are data. And even as cloud storage services are booming, so there are concerns about privacy and lack of control over our personal data. From the PRISM surveillance program to Google [letting app developers scan your personal emails][1], the news is full of reports that should give us all pause regarding the security of our personal information. + +[Syncthing][2] can help put your mind at ease. An open source peer-to-peer file synchronization tool that runs on Linux, Windows, Mac, Android, and others (sorry, no iOS), Syncthing uses its own protocol, called [Block Exchange Protocol][3]. In brief, Syncthing lets you synchronize your data across many devices without owning a server. + +### Linux + +In this post, I will explain how to install and synchronize files between a Linux computer and an Android phone. + +Syncthing is readily available for most popular distributions. Fedora 28 includes the latest version. + +To install Syncthing in Fedora, you can either search for it in Software Center or execute the following command: + +``` +sudo dnf install syncthing syncthing-gtk + +``` + +Once it’s installed, open it. You’ll be welcomed by an assistant to help configure Syncthing. Click **Next** until it asks to configure the WebUI. The safest option is to keep the option **Listen on localhost**. That will disable the web interface and keep unauthorized users away. + +![Syncthing in Setup WebUI dialog box][5] + +Syncthing in Setup WebUI dialog box + +Close the dialog. Now that Syncthing is installed, it’s time to share a folder, connect a device, and start syncing. But first, let’s continue with your other client. + +### Android + +Syncthing is available in Google Play and in F-Droid app stores. + +![](https://opensource.com/sites/default/files/uploads/syncthing2.png) + +Once the application is installed, you’ll be welcomed by a wizard. Grant Syncthing permissions to your storage. You might be asked to disable battery optimization for this application. It is safe to do so as we will optimize the app to synchronize only when plugged in and connected to a wireless network. + +Click on the main menu icon and go to **Settings** , then **Run Conditions**. Tick **Always run in** **the background** , **Run only when charging** , and **Run only on wifi**. Now your Android client is ready to exchange files with your devices. + +There are two important concepts to remember in Syncthing: folders and devices. Folders are what you want to share, but you must have a device to share with. Syncthing allows you to share individual folders with different devices. Devices are added by exchanging device IDs. A device ID is a unique, cryptographically secure identifier that is created when Syncthing starts for the first time. + +### Connecting devices + +Now let’s connect your Linux machine and your Android client. + +In your Linux computer, open Syncthing, click on the **Settings** icon and click **Show ID**. A QR code will show up. + +In your Android mobile, open Syncthing. In the main screen, click the **Devices** tab and press the **+** symbol. In the first field, press the QR code symbol to open the QR scanner. + +Point your mobile camera to the computer QR code. The Device ID** **field will be populated with your desktop client Device ID. Give it a friendly name and save. Because adding a device goes two ways, you now need to confirm on the computer client that you want to add the Android mobile. It might take a couple of minutes for your computer client to ask for confirmation. When it does, click **Add**. + +![](https://opensource.com/sites/default/files/uploads/syncthing6.png) + +In the **New Device** window, you can verify and configure some options about your new device, like the **Device Name** and **Addresses**. If you keep dynamic, it will try to auto-discover the device IP, but if you want to force one, you can add it in this field. If you already created a folder (more on this later), you can also share it with this new device. + +![](https://opensource.com/sites/default/files/uploads/syncthing7.png) + +Your computer and Android are now paired and ready to exchange files. (If you have more than one computer or mobile phone, simply repeat these steps.) + +### Sharing folders + +Now that the devices you want to sync are already connected, it’s time to share a folder. You can share folders on your computer and the devices you add to that folder will get a copy. + +To share a folder, go to **Settings** and click **Add Shared Folder** : + +![](https://opensource.com/sites/default/files/uploads/syncthing8.png) + +In the next window, enter the information of the folder you want to share: + +![](https://opensource.com/sites/default/files/uploads/syncthing9.png) + +You can use any label you want. **Folder ID** will be generated randomly and will be used to identify the folder between the clients. In **Path** , click **Browse** and locate the folder you want to share. If you want Syncthing to monitor the folder for changes (such as deletes, new files, etc.), click **Monitor filesystem for changes**. + +Remember, when you share a folder, any change that happens on the other clients will be reflected on every single device. That means that if you share a folder containing pictures with other computers or mobile devices, changes in these other clients will be reflected everywhere. If this is not what you want, you can make your folder “Send Only” so it will send files to the clients, but the other clients’ changes won’t be synced. + +When this is done, go to **Share with Devices** and select the hosts you want to sync with your folder: + +All the devices you select will need to accept the share request; you will get a notification from the devices: + +Just as when you shared the folder, you must configure the new shared folder: + +![](https://opensource.com/sites/default/files/uploads/syncthing12.png) + +Again, here you can define any label, but the ID must match each client. In the folder option, select the destination for the folder and its files. Remember that any change done in this folder will be reflected with every device allowed in the folder. + +These are the steps to connect devices and share folders with Syncthing. It might take a few minutes to start copying, depending on your network settings or if you are not on the same network. + +Syncthing offers many more great features and options. Try it—and take control of your data. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/take-control-your-data-syncthing + +作者:[Michael Zamot][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mzamot +[1]: https://gizmodo.com/google-says-it-doesnt-go-through-your-inbox-anymore-bu-1827299695 +[2]: https://syncthing.net/ +[3]: https://docs.syncthing.net/specs/bep-v1.html +[4]: /file/410191 +[5]: https://opensource.com/sites/default/files/uploads/syncthing1.png (Syncthing in Setup WebUI dialog box) From f068057d362c6ec76f86eeae022fa459306ae2a8 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 27 Sep 2018 09:55:43 +0800 Subject: [PATCH 450/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20Instal?= =?UTF-8?q?l=20Cinnamon=20Desktop=20on=20Ubuntu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...w to Install Cinnamon Desktop on Ubuntu.md | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 sources/tech/20140805 How to Install Cinnamon Desktop on Ubuntu.md diff --git a/sources/tech/20140805 How to Install Cinnamon Desktop on Ubuntu.md b/sources/tech/20140805 How to Install Cinnamon Desktop on Ubuntu.md new file mode 100644 index 0000000000..78ba32e2a2 --- /dev/null +++ b/sources/tech/20140805 How to Install Cinnamon Desktop on Ubuntu.md @@ -0,0 +1,80 @@ +How to Install Cinnamon Desktop on Ubuntu +====== +**This tutorial shows you how to install Cinnamon desktop environment on Ubuntu.** + +[Cinnamon][1] is the default desktop environment of [Linux Mint][2]. Unlike Unity desktop environment in Ubuntu, Cinnamon is more traditional but elegant looking desktop environment with the bottom panel and app menu etc. Many Windows migrants [prefer Linux Mint over Ubuntu][3] because of Cinnamon desktop and its Windows-resembling user interface. + +Now, you don’t need to [install Linux Mint][4] just for trying Cinnamon. In this tutorial, I’ll show you **how to install Cinnamon in Ubuntu 18.04, 16.04 and 14.04**. + +You should note something before you install Cinnamon desktop on Ubuntu. Sometimes, installing additional desktop environments leads to conflict between the desktop environments. This may result in a broken session, broken applications and features etc. This is why you should be careful in making this choice. + +### How to Install Cinnamon on Ubuntu + +![How to install cinnamon desktop on Ubuntu Linux][5] + +There used to be a-sort-of official PPA from Cinnamon team for Ubuntu but it doesn’t exist anymore. Don’t lose heart. There is an unofficial PPA available and it works perfectly. This PPA consists of the latest Cinnamon version. + +Open a terminal and use the following commands: + +``` +sudo add-apt-repository ppa:embrosyn/cinnamon +sudo apt update && sudo apt install cinnamon + +``` + +It will download files of around 150 MB in size (if I remember correctly). This also provides you with Nemo (Nautilus fork) and Cinnamon Control Center. This bonus stuff gives a closer feel of Linux Mint. + +### Using Cinnamon desktop environment in Ubuntu + +Once you have installed Cinnamon, log out of the current session. At the login screen, click on the Ubuntu symbol beside the username: + +![](https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2014/08/Change_Desktop_Environment_Ubuntu.jpeg) + +When you do this, it will give you all the desktop environments available for your system. No need to tell you that you have to choose Cinnamon: + +![](https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2014/08/Install_Cinnamon_Ubuntu.jpeg) + +Now you should be logged in to Ubuntu with Cinnamon desktop environment. Remember, you can do the same to switch back to Unity. Here is a quick screenshot of what it looked like to run **Cinnamon in Ubuntu** : + +![](https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2014/08/Cinnamon_Ubuntu_1404.jpeg) + +Looks completely like Linux Mint, isn’t it? I didn’t find any compatibility issue between Cinnamon and Unity. I switched back and forth between Unity and Cinnamon and both worked perfectly. + +#### Remove Cinnamon from Ubuntu + +It is understandable that you might want to uninstall Cinnamon. We will use PPA Purge for this purpose. Let’s install PPA Purge first: + +``` +sudo apt-get install ppa-purge + +``` + +Afterward, use the following command to purge the PPA: + +``` +sudo ppa-purge ppa:embrosyn/cinnamon + +``` + +In related articles, I suggest you to read more about [how to remove PPA in Linux][6]. + +I hope this post helps you to **install Cinnamon in Ubuntu**. Do share your experience with Cinnamon. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-cinnamon-on-ubuntu/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[1]: http://cinnamon.linuxmint.com/ +[2]: http://www.linuxmint.com/ +[3]: https://itsfoss.com/linux-mint-vs-ubuntu/ +[4]: https://itsfoss.com/guide-install-linux-mint-16-dual-boot-windows/ +[5]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/install-cinnamon-ubuntu.png +[6]: https://itsfoss.com/how-to-remove-or-delete-ppas-quick-tip/ From 34d2cd8445f64a60f280c7577f5995cedb1f8ce6 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 27 Sep 2018 10:01:51 +0800 Subject: [PATCH 451/455] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Distributed=20tra?= =?UTF-8?q?cing=20in=20a=20microservices=20world?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ibuted tracing in a microservices world.md | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 sources/tech/20180920 Distributed tracing in a microservices world.md diff --git a/sources/tech/20180920 Distributed tracing in a microservices world.md b/sources/tech/20180920 Distributed tracing in a microservices world.md new file mode 100644 index 0000000000..1b39a5e30a --- /dev/null +++ b/sources/tech/20180920 Distributed tracing in a microservices world.md @@ -0,0 +1,113 @@ +Distributed tracing in a microservices world +====== +What is distributed tracing and why is it so important in a microservices environment? + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/pixelated-world.png?itok=fHjM6m53) + +[Microservices][1] have become the default choice for greenfield applications. After all, according to practitioners, microservices provide the type of decoupling required for a full digital transformation, allowing individual teams to innovate at a far greater speed than ever before. + +Microservices are nothing more than regular distributed systems, only at a larger scale. Therefore, they exacerbate the well-known problems that any distributed system faces, like lack of visibility into a business transaction across process boundaries. + +Given that it's extremely common to have multiple versions of a single service running in production at the same time—be it in a [A/B testing][2] scenario or as part of rolling out a new release following the [Canary release][3] technique—when we account for the fact that we are talking about hundreds of services, it's clear that what we have is chaos. It's almost impossible to map the interdependencies and understand the path of a business transaction across services and their versions. + +### Observability + +This chaos ends up being a good thing, as long as we can observe what's going on and diagnose the problems that will eventually occur. + +A system is said to be observable when we can understand its state based on the [metrics, logs, and traces][4] it emits. Given that we are talking about distributed systems, knowing the state of a single instance of a single service isn't enough; we need to be able to aggregate the metrics for all instances of a given service, perhaps grouped by version. Metrics solutions like [Prometheus][5] are very popular in tackling this aspect of the observability problem. Similarly, we need logs to be stored in a central location, as it's impossible to analyze the logs from the individual instances of each service. [Logstash][6] is usually applied here, in combination with a backing storage like [Elasticsearch][7]. And finally, we need to get end-to-end traces to understand the path a given transaction has taken. This is where distributed tracing solutions come into play. + +### Distributed tracing + +In monolithic web applications, logging frameworks provide enough capabilities to do a basic root-cause analysis when something fails. A developer just needs to place log statements in the code. Information like "context" (usually "thread") and "timestamp" are automatically added to the log entry, making it easier to understand the execution of a given request and correlate the entries. + +``` +Thread-1 2018-09-03T15:52:54+02:00 Request started +Thread-2 2018-09-03T15:52:55+02:00 Charging credit card x321 +Thread-1 2018-09-03T15:52:55+02:00 Order submitted +Thread-1 2018-09-03T15:52:56+02:00 Charging credit card x123 +Thread-1 2018-09-03T15:52:57+02:00 Changing order status +Thread-1 2018-09-03T15:52:58+02:00 Dispatching event to inventory +Thread-1 2018-09-03T15:52:59+02:00 Request finished +``` + +We can safely say that the second log entry above is not related to the other entries, as it's being executed in a different thread. + +In microservices architectures, logging alone fails to deliver the complete picture. Is this service the first one in the call chain? And what happened at the inventory service (where we apparently dispatched an event)? + +A common strategy to answer this question is creating an identifier at the very first building block of our transaction and propagating this identifier across all the calls, probably by sending it as an HTTP header whenever a remote call is made. + +In a central log collector, we could then see entries like the ones below. Note how we could log the correlation ID (the first column in our example), so we know that the second entry is not related to the other entries. + +``` +abc123 Order     2018-09-03T15:52:58+02:00 Dispatching event to inventory +def456 Order     2018-09-03T15:52:58+02:00 Dispatching event to inventory +abc123 Inventory 2018-09-03T15:52:59+02:00 Received `order-submitted` event +abc123 Inventory 2018-09-03T15:53:00+02:00 Checking inventory status +abc123 Inventory 2018-09-03T15:53:01+02:00 Updating inventory +abc123 Inventory 2018-09-03T15:53:02+02:00 Preparing order manifest +``` + +This technique is one of the concepts at the core of any modern distributed tracing solution, but it's not really new; correlating log entries is decades old, probably as old as "distributed systems" itself. + +What sets distributed tracing apart from regular logging is that the data structure that holds tracing data is more specialized, so we can also identify causality. Looking at the log entries above, it's hard to tell if the last step was caused by the previous entry, if they were performed concurrently, or if they share the same caller. Having a dedicated data structure also allows distributed tracing to record not only a message in a single point in time but also the start and end time of a given procedure. + +![Trace showing spans][9] + +Trace showing spans similar to the logs described above + +[Click to enlarge][10] + +Most of the modern distributed tracing tools are inspired by a 2010 [paper about Dapper][11], the distributed tracing solution used at Google. In that paper, the data structure described above was called a span, and you can see nine of them in the image above. This particular "forest" of spans is called a trace and is equivalent to the correlated log entries we've seen before. + +The image above is a screenshot of a trace displayed in [Jaeger][12], an open source distributed tracing solution hosted by the [Cloud Native Computing Foundation (CNCF)][13]. It marks each service with a color to make it easier to see the process boundaries. Timing information can be easily visualized, both by looking at the macro timeline at the top of the screen or at the individual spans, giving a sense of how long each span takes and how impactful it is in this particular execution. It's also easy to observe when processes are asynchronous and therefore may outlive the initial request. + +Like with logging, we need to annotate or instrument our code with the data we want to record. Unlike logging, we record spans instead of messages and do some demarcation to know when the span starts and finishes so we can get accurate timing information. As we would probably like to have our business code independent from a specific distributed tracing implementation, we can use an API such as [OpenTracing][14], leaving the decision about the concrete implementation as a packaging or runtime concern. Following is pseudo-Java code showing such demarcation. + +``` +try (Scope scope = tracer.buildSpan("submitOrder").startActive(true)) { +    scope.span().setTag("order-id", "c85b7644b6b5"); +    chargeCreditCard(); +    changeOrderStatus(); +    dispatchEventToInventory(); +} +``` + +Given the nature of the distributed tracing concept, it's clear the code executed "between" our business services can also be part of the trace. For instance, we could [turn on][15] the distributed tracing integration for [Istio][16], a service mesh solution that helps in the communication between microservices, and we'll suddenly have a better picture about the network latency and routing decisions made at this layer. Another example is the work done in the OpenTracing community to provide instrumentation for popular stacks, frameworks, and APIs, such as Java's [JAX-RS][17], [Spring Cloud][18], or [JDBC][19]. This enables us to see how our business code interacts with the rest of the middleware, understand where a potential problem might be happening, and identify the best areas to improve. In fact, today's middleware instrumentation is so rich that it's common to get started with distributed tracing by using only the so-called "framework instrumentation," leaving the business code free from any tracing-related code. + +While a microservices architecture is almost unavoidable nowadays for established companies to innovate faster and for ambitious startups to achieve web scale, it's easy to feel helpless while conducting a root cause analysis when something eventually fails and the right tools aren't available. The good news is tools like Prometheus, Logstash, OpenTracing, and Jaeger provide the pieces to bring observability to your application. + +Juraci Paixão Kröhling will present [What are My Microservices Doing?][20] at [Open Source Summit Europe][21], October 22-24 in Edinburgh, Scotland. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/distributed-tracing-microservices-world + +作者:[Juraci Paixão Kröhling][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jpkroehling +[1]: https://en.wikipedia.org/wiki/Microservices +[2]: https://en.wikipedia.org/wiki/A/B_testing +[3]: https://martinfowler.com/bliki/CanaryRelease.html +[4]: https://blog.twitter.com/engineering/en_us/a/2016/observability-at-twitter-technical-overview-part-i.html +[5]: https://prometheus.io/ +[6]: https://github.com/elastic/logstash +[7]: https://github.com/elastic/elasticsearch +[8]: /file/409621 +[9]: https://opensource.com/sites/default/files/uploads/distributed-trace.png (Trace showing spans) +[10]: /sites/default/files/uploads/trace.png +[11]: https://ai.google/research/pubs/pub36356 +[12]: https://www.jaegertracing.io/ +[13]: https://www.cncf.io/ +[14]: http://opentracing.io/ +[15]: https://istio.io/docs/tasks/telemetry/distributed-tracing/ +[16]: https://istio.io/ +[17]: https://github.com/opentracing-contrib/java-jaxrs +[18]: https://github.com/opentracing-contrib/java-spring-cloud +[19]: https://github.com/opentracing-contrib/java-jdbc +[20]: https://osseu18.sched.com/event/FxW3/what-are-my-microservices-doing-juraci-paixao-krohling-red-hat# +[21]: https://osseu18.sched.com/ From 5e8fd9321d044fb0d573b835cfec1124215130ca Mon Sep 17 00:00:00 2001 From: HankChow <280630620@qq.com> Date: Thu, 27 Sep 2018 10:08:24 +0800 Subject: [PATCH 452/455] hankchow translating --- ...To Find Out Which Port Number A Process Is Using In Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180924 How To Find Out Which Port Number A Process Is Using In Linux.md b/sources/tech/20180924 How To Find Out Which Port Number A Process Is Using In Linux.md index 21b6633730..add3ce719e 100644 --- a/sources/tech/20180924 How To Find Out Which Port Number A Process Is Using In Linux.md +++ b/sources/tech/20180924 How To Find Out Which Port Number A Process Is Using In Linux.md @@ -1,3 +1,5 @@ +HankChow translating + How To Find Out Which Port Number A Process Is Using In Linux ====== As a Linux administrator, you should know whether the corresponding service is binding/listening with correct port or not. From 5adaffeea5ff72b674b3bfcb52fbd2f59413ff98 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 27 Sep 2018 10:28:38 +0800 Subject: [PATCH 453/455] PRF:20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md @XiatianSummer --- ...cut Every Ubuntu 18.04 User Should Know.md | 97 ++++++++++--------- 1 file changed, 49 insertions(+), 48 deletions(-) diff --git a/translated/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md b/translated/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md index c946493a6c..461e586b2d 100644 --- a/translated/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md +++ b/translated/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md @@ -1,82 +1,83 @@ 每位 Ubuntu 18.04 用户都应该知道的快捷键 ====== + 了解快捷键能够提升您的生产力。这里有一些实用的 Ubuntu 快捷键助您像专业人士一样使用 Ubuntu。 -您可以使用有键盘和鼠标组合的操作系统。 +您可以用键盘和鼠标组合来使用操作系统。 -注意:本文中提到的键盘快捷键适用于 Ubuntu 18.04 GNOME 版。 通常,它们中的大多数(或者全部)也适用于其他的 Ubuntu 版本,但我不能够保证。 +> 注意:本文中提到的键盘快捷键适用于 Ubuntu 18.04 GNOME 版。 通常,它们中的大多数(或者全部)也适用于其他的 Ubuntu 版本,但我不能够保证。 ![Ubuntu keyboard shortcuts][1] ### 实用的 Ubuntu 快捷键 -让我们来看一看 Ubuntu GNOME 必备的快捷键吧!通用的快捷键如 Ctrl+C(复制),Ctrl+V(粘贴)或者 Ctrl+S(保存)不再赘述。 +让我们来看一看 Ubuntu GNOME 必备的快捷键吧!通用的快捷键如 `Ctrl+C`(复制)、`Ctrl+V`(粘贴)或者 `Ctrl+S`(保存)不再赘述。 -注意:Linux 中的 Super 键即键盘上带有 Windows 图标的键,本文中我使用了大写字母,但这不代表你需要按下 shift 键,比如,T 代表键盘上的‘t’键,而不代表 Shift+t。 +注意:Linux 中的 Super 键即键盘上带有 Windows 图标的键,本文中我使用了大写字母,但这不代表你需要按下 `shift` 键,比如,`T` 代表键盘上的 ‘t’ 键,而不代表 `Shift+t`。 -#### 1\. Super 键:打开活动搜索界面 +#### 1、 Super 键:打开活动搜索界面 -使用 Super 键可以打开活动菜单。如果你只能在 Ubuntu 上使用一个快捷键,那只能是 Super 键。 +使用 `Super` 键可以打开活动菜单。如果你只能在 Ubuntu 上使用一个快捷键,那只能是 `Super` 键。 -想要打开一个应用程序?按下 Super 键然后搜索应用程序。如果搜索的应用程序未安装,它会推荐来自应用中心的应用程序。 +想要打开一个应用程序?按下 `Super` 键然后搜索应用程序。如果搜索的应用程序未安装,它会推荐来自应用中心的应用程序。 -想要看看有哪些正在运行的程序?按下 Super 键,屏幕上就会显示所有正在运行的 GUI 应用程序。 +想要看看有哪些正在运行的程序?按下 `Super` 键,屏幕上就会显示所有正在运行的 GUI 应用程序。 -想要使用工作区吗?只需按下 Super 键,您就可以在屏幕右侧看到工作区选项。 +想要使用工作区吗?只需按下 `Super` 键,您就可以在屏幕右侧看到工作区选项。 -#### 2\. Ctrl+Alt+T:打开 Ubuntu 终端窗口 +#### 2、 Ctrl+Alt+T:打开 Ubuntu 终端窗口 ![Ubuntu Terminal Shortcut][2] *使用 Ctrl+alt+T 来打开终端窗口* -想要打开一个新的终端,您只需使用快捷键 Ctrl+Alt+T。这是我在 Ubuntu 中最喜欢的键盘快捷键。 甚至在我的许多 FOSS 教程中,当需要打开终端窗口是,我都会提到这个快捷键。 +想要打开一个新的终端,您只需使用快捷键 `Ctrl+Alt+T`。这是我在 Ubuntu 中最喜欢的键盘快捷键。 甚至在我的许多 FOSS 教程中,当需要打开终端窗口是,我都会提到这个快捷键。 -#### 3\. Super+L 或 Ctrl——Alt+L:锁屏 +#### 3、 Super+L 或 Ctrl+Alt+L:锁屏 -当您离开电脑时锁定屏幕,是最基本的安全习惯之一。您可以使用 Super + L 快捷键,而不是繁琐地点击屏幕右上角然后选择锁定屏幕选项。 +当您离开电脑时锁定屏幕,是最基本的安全习惯之一。您可以使用 `Super+L` 快捷键,而不是繁琐地点击屏幕右上角然后选择锁定屏幕选项。 -有些系统也会使用 Ctrl+Alt+L 键锁定屏幕。 +有些系统也会使用 `Ctrl+Alt+L` 键锁定屏幕。 -#### 4\. Super+D or Ctrl+Alt+D:显示桌面 +#### 4、 Super+D or Ctrl+Alt+D:显示桌面 -按下 Super + D 可以最小化所有正在运行的应用程序窗口并显示桌面。 +按下 `Super+D` 可以最小化所有正在运行的应用程序窗口并显示桌面。 -再次按 Super + D 将重新打开所有正在运行的应用程序窗口,像之前一样。 +再次按 `Super+D` 将重新打开所有正在运行的应用程序窗口,像之前一样。 -您也可以使用 Ctrl + Alt + D 来实现此目的。 +您也可以使用 `Ctrl+Alt+D` 来实现此目的。 -#### 5\. Super+A:显示应用程序菜单 +#### 5、 Super+A:显示应用程序菜单 -您可以通过单击屏幕左下角的 9个点打开 Ubuntu 18.04 GNOME 中的应用程序菜单。 但是一个更快捷的方法是使用 Super + A 快捷键。 +您可以通过单击屏幕左下角的 9 个点打开 Ubuntu 18.04 GNOME 中的应用程序菜单。 但是一个更快捷的方法是使用 `Super+A` 快捷键。 它将显示应用程序菜单,您可以在其中查看或搜索系统上已安装的应用程序。 -您可以使用 Esc 键退出应用程序菜单界面。 +您可以使用 `Esc` 键退出应用程序菜单界面。 -#### 6\. Super+Tab or Alt+Tab:在运行中的应用程序间切换 +#### 6、 Super+Tab 或 Alt+Tab:在运行中的应用程序间切换 -如果您运行的应用程序不止一个,则可以使用 Super + Tab 或 Alt + Tab 快捷键在应用程序之间切换。 +如果您运行的应用程序不止一个,则可以使用 `Super+Tab` 或 `Alt+Tab` 快捷键在应用程序之间切换。 -按住 Super 键同时按下 Tab 键,即可显示应用程序切换器。 按住 Super 的同时,继续点击 Tab 键在应用程序之间进行选择。 当光标在所需的应用程序上时,松开 Super 和 Tab 键。 +按住 `Super` 键同时按下 `Tab` 键,即可显示应用程序切换器。 按住 `Super` 的同时,继续按下 `Tab` 键在应用程序之间进行选择。 当光标在所需的应用程序上时,松开 `Super` 和 `Tab` 键。 -默认情况下,应用程序切换器从左向右移动。 如果要从右向左移动,可使用 Super + Shift + Tab 快捷键。 +默认情况下,应用程序切换器从左向右移动。 如果要从右向左移动,可使用 `Super+Shift+Tab` 快捷键。 -在这里您也可以用 Alt 键代替 Super 键。 +在这里您也可以用 `Alt` 键代替 `Super` 键。 -提示:如果有多个应用程序实例,您可以使用 Super + \` 快捷键在这些实例之间切换。 +> 提示:如果有多个应用程序实例,您可以使用 Super+` 快捷键在这些实例之间切换。 -#### 7\. Super+Arrow keys: 移动窗口位置 +#### 7、 Super+箭头:移动窗口位置 -这个快捷键也适用于 Windows 系统。 使用应用程序时,按下 Super 和左箭头键,应用程序将贴合屏幕的左边缘,占用屏幕的左半边。 +这个快捷键也适用于 Windows 系统。 使用应用程序时,按下 `Super+左箭头`,应用程序将贴合屏幕的左边缘,占用屏幕的左半边。 -同样,按下 Super 和右箭头键会使应用程序贴合右边缘。 +同样,按下 `Super+右箭头`会使应用程序贴合右边缘。 -按下 Super 和上箭头键将最大化应用程序窗口,超级和下箭头将使应用程序恢复到其正常的大小。 +按下 `Super+上箭头`将最大化应用程序窗口,`Super+下箭头`将使应用程序恢复到其正常的大小。 -#### 8\. Super+M: 切换到通知栏 +#### 8、 Super+M:切换到通知栏 GNOME 中有一个通知栏,您可以在其中查看系统和应用程序活动的通知,这里也有一个日历。 @@ -84,19 +85,19 @@ GNOME 中有一个通知栏,您可以在其中查看系统和应用程序活 *通知栏* -使用 Super + M 快捷键,您可以打开此通知栏。 如果再次按这些键,将关闭打开的通知托盘。 +使用 `Super+M` 快捷键,您可以打开此通知栏。 如果再次按这些键,将关闭打开的通知托盘。 -使用 Super+V 也可实现相同的功能。 +使用 `Super+V` 也可实现相同的功能。 -#### 9\. Super+Space:切换输入法(用于多语言设置) +#### 9、 Super+空格:切换输入法(用于多语言设置) 如果您使用多种语言,可能您的系统上安装了多个输入法。 例如,我需要在 Ubuntu 上同时使用[印地语] [4]和英语,所以我安装了印地语(梵文)输入法以及默认的英语输入法。 -如果您也使用多语言设置,则可以使用 Super + Space 快捷键快速更改输入法。 +如果您也使用多语言设置,则可以使用 `Super+空格` 快捷键快速更改输入法。 -#### 10\. Alt+F2:运行控制台 +#### 10、 Alt+F2:运行控制台 -这适用于高级用户。 如果要运行快速命令,而不是打开终端并在其中运行命令,则可以使用 Alt + F2 运行控制台。 +这适用于高级用户。 如果要运行快速命令,而不是打开终端并在其中运行命令,则可以使用 `Alt+F2` 运行控制台。 ![Alt+F2 to run commands in Ubuntu][5] @@ -104,31 +105,31 @@ GNOME 中有一个通知栏,您可以在其中查看系统和应用程序活 当您使用只能在终端运行的应用程序时,这尤其有用。 -#### 11\. Ctrl+Q:关闭应用程序窗口 +#### 11、 Ctrl+Q:关闭应用程序窗口 -如果您有正在运行的应用程序,可以使用 Ctrl + Q 快捷键关闭应用程序窗口。您也可以使用 Ctrl + W 来实现此目的。 +如果您有正在运行的应用程序,可以使用 `Ctrl+Q` 快捷键关闭应用程序窗口。您也可以使用 `Ctrl+W` 来实现此目的。 -Alt + F4 是关闭应用程序窗口更“通用”的快捷方式。 +`Alt+F4` 是关闭应用程序窗口更“通用”的快捷方式。 它不适用于一些应用程序,如 Ubuntu 中的默认终端。 -#### 12\. Ctrl+Alt+arrow:切换工作区 +#### 12、 Ctrl+Alt+箭头:切换工作区 ![Workspace switching][6] *切换工作区* -如果您是使用工作区的重度用户,可以使用 Ctrl + Alt + 上箭头和 Ctrl + Alt + 下箭头键在工作区之间切换。 +如果您是使用工作区的重度用户,可以使用 `Ctrl+Alt+上箭头`和 `Ctrl+Alt+下箭头`在工作区之间切换。 -#### 13\. Ctrl+Alt+Del:注销 +#### 13、 Ctrl+Alt+Del:注销 -不会!在 Linux 中使用著名的快捷键 Ctrl+Alt+Del 并不会像在 Windows 中一样打开任务管理器(除非您使用自定义快捷键)。 +不!在 Linux 中使用著名的快捷键 `Ctrl+Alt+Del` 并不会像在 Windows 中一样打开任务管理器(除非您使用自定义快捷键)。 ![Log Out Ubuntu][7] *注销* -在普通的 GNOME 桌面环境中,您可以使用 Ctrl + Alt + Del 键打开关机菜单,但 Ubuntu 并不总是遵循此规范,因此当您在 Ubuntu 中使用 Ctrl + Alt + Del 键时,它会打开注销菜单。 +在普通的 GNOME 桌面环境中,您可以使用 `Ctrl+Alt+Del` 键打开关机菜单,但 Ubuntu 并不总是遵循此规范,因此当您在 Ubuntu 中使用 `Ctrl+Alt+Del` 键时,它会打开注销菜单。 ### 在 Ubuntu 中使用自定义键盘快捷键 @@ -142,7 +143,7 @@ Alt + F4 是关闭应用程序窗口更“通用”的快捷方式。 ### Ubuntu 中你最喜欢的键盘快捷键是什么? -快捷键永无止境。如果需要,你可以看一看所有可能的 [GNOME 快捷键][9],看其中有没有你需要用到的快捷键。 +快捷键无穷无尽。如果需要,你可以看一看所有可能的 [GNOME 快捷键][9],看其中有没有你需要用到的快捷键。 您可以学习使用您经常使用应用程序的快捷键,这是很有必要的。例如,我使用 Kazam 进行[屏幕录制][10],键盘快捷键帮助我方便地暂停和开始录像。 @@ -155,7 +156,7 @@ via: https://itsfoss.com/ubuntu-shortcuts/ 作者:[Abhishek Prakash][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[XiatianSummer](https://github.com/XiatianSummer) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 0df4be75d82336f5d52527caeed0bb6e0048a64e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 27 Sep 2018 10:29:05 +0800 Subject: [PATCH 454/455] PUB: 20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md @XiatianSummer https://linux.cn/article-10055-1.html --- ...10 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md (100%) diff --git a/translated/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md b/published/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md similarity index 100% rename from translated/tech/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md rename to published/20180910 13 Keyboard Shortcut Every Ubuntu 18.04 User Should Know.md From 5adec56c31704b87574b79172f08a84067a47903 Mon Sep 17 00:00:00 2001 From: qhwdw <33189910+qhwdw@users.noreply.github.com> Date: Thu, 27 Sep 2018 11:02:04 +0800 Subject: [PATCH 455/455] Translating by qhwdw (#10386) --- ...jarne Stroustrup warns of dangerous future plans for his C.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180618 What-s all the C Plus Fuss- Bjarne Stroustrup warns of dangerous future plans for his C.md b/sources/tech/20180618 What-s all the C Plus Fuss- Bjarne Stroustrup warns of dangerous future plans for his C.md index 04644aebb2..2f9a6636e7 100644 --- a/sources/tech/20180618 What-s all the C Plus Fuss- Bjarne Stroustrup warns of dangerous future plans for his C.md +++ b/sources/tech/20180618 What-s all the C Plus Fuss- Bjarne Stroustrup warns of dangerous future plans for his C.md @@ -1,3 +1,4 @@ +Translating by qhwdw What's all the C Plus Fuss? Bjarne Stroustrup warns of dangerous future plans for his C++ ======