From 71623588fb73761f9fb5728d1aa561dfe8143d32 Mon Sep 17 00:00:00 2001 From: David Chen Date: Sat, 13 Oct 2018 21:34:58 +0800 Subject: [PATCH 001/158] Third commit --- sources/tech/20180823 CLI- improved.md | 121 ++++++++++++++++++++++++- 1 file changed, 120 insertions(+), 1 deletion(-) diff --git a/sources/tech/20180823 CLI- improved.md b/sources/tech/20180823 CLI- improved.md index 52edaa28c8..8fb3ea9100 100644 --- a/sources/tech/20180823 CLI- improved.md +++ b/sources/tech/20180823 CLI- improved.md @@ -2,16 +2,29 @@ Translating by DavidChenLiang CLI: improved ====== +命令行:增强 +====== + +我不确定有多少web 开发者能完全逃避使用命令行。就我来说,我从1997年上大学就开始使用命令行了,那时l33t-hacker 让我着迷,同时我觉得又很难掌握它。 + 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 +### 怎么忽略我的增强 + +在一些情况下我会用别名将新的和增强的命令行工具链接到原来的命令行(如`cat`和`ping`)。 In a number of cases I've aliased the new and improved command line tool over the original (as with `cat` and `ping`). +如果我需要运行原来的命令的话,有时我确实需要这么做,我能像下面这样来做。(我用的是Mac 你的输出可能不一样) + 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 @@ -20,13 +33,22 @@ $ command cat # ignore functions and aliases ### bat > cat +`cat`用于打印文件的内容,但是如果你在命令行上花了很多时间的话,例如语法高亮之类的功能会非常有用。我先发现了[ccat][3]这个有语法高亮功能的的工具, 然后我发现了[bat][4],它有语法高亮,分页,行号和git集成。 + `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. +`bat`命令也能让我在输出里(只要输出比屏幕的高度长) +使用`/`关键字绑定来搜索(和用`less`搜索功能一样)。 + 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] +我将别名`bat`链接到了`cat`命令: + I've also aliased `bat` to the `cat` command: + + ``` alias cat='bat' @@ -35,12 +57,18 @@ alias cat='bat' 💾 [Installation directions][4] ### prettyping > ping +### prettyping > ping + +`ping`非常有用,当我碰到“糟了,是不是神马服务挂了/我的网不通了?”这种情况下我最先想到的工具就是他了。但是`prettyping`(“prettyping” 可不是指"pre typing")(译注:英文字面意思是'预打印')在`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] +我也将`ping`用别名链接到了`prettyping`命令: + I've also aliased `ping` to the `prettyping` command: + ``` alias ping='prettyping --nolegend' @@ -50,13 +78,22 @@ alias ping='prettyping --nolegend' ### fzf > ctrl+r +在命令行上使用`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. +`fzf`这个工具相比于`ctrl+r`有了**巨大的**进步。它能针对命令行历史进行模糊查询,并且提供了对可能合格的结果的全面交互式预览。 + 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. +除了搜索命令历史,`fzf`还能预览和打开文件,我在下面的视频里展示了这些功能。 + In addition to searching through the history, `fzf` can also preview and open files, which is what I've done in the video below: +对于预览的效果,我创建了一个叫`preview`的别名,它将`fzf`和前文提到的`bat`组合起来完成预览功能,还给上面绑定了一个定制的热键Ctrl+o来打开 VS Code + 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 @@ -68,10 +105,21 @@ export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort'" ### htop > top +`top`是当我想快速诊断为什么机器上的CPU跑的那么累或者风扇为什么突然呼呼大做的时候首先会想到的工具。我在产品环境也会使用这个工具。讨厌的是Mac 上的`top`和 Linux 上的`top`有着极大的不同(包括其内部的 IMHO) + `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. +不过,`htop`是对 Linux 上的`top`和 Mac 上蹩脚的`top`的极大改进。它增加了包括颜色输出编码,键盘热键绑定以及不同的视图,这极大的帮助了我来理解进程之间的父子关系。 + 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. +方便的热键绑定包括: + + * P - CPU 使用率排序 + * M - 内存使用排序 + * F4 - 用字符串过滤进程(例如只看包括"node"的进程) + * space - 锚定一个单独进程,这样我能观察它是否有尖峰状态 + Handy key bindings include: * P - sort by CPU @@ -83,7 +131,10 @@ Handy key bindings include: ![htop output][10] +在Mac Sieera 上htop 有个奇怪的bug,可以通过以root 运行来绕过(我实在记不清这个bug 是什么,但是这个别名能搞定它,有点讨厌的是我得每次都输入 root 密码。): + 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 @@ -93,11 +144,16 @@ alias top="sudo htop" # alias top and fix high sierra bug ### diff-so-fancy > diff +我非常确定我是一些年前从 Paul Irish 那儿学来的这个技巧,尽管我很少直接使用`diff`,我的git 命令行会一直使用`diff`。`diff-so-fancy`给了我代码颜色和更改字符高亮的功能。 + 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] +在我的`~/.gitconfig`文件里我有下面的选项来打开`git diff`和`git show`的`diff-so-fancy`功能。 + 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 @@ -109,13 +165,22 @@ Then in my `~/.gitconfig` I have included the following entry to enable `diff-so ### fd > find +尽管我使用 Mac, 但我从来不是一个Spotlight的拥趸,我觉得他的功能很累赘,关键字也难记,更新它自己的数据库时会拖慢CPU,简直一无是处。我经常使用[Alfred][14],但是它额搜索功能也工作的不是很好。 + 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. +我倾向于在命令行中搜索文件,但是`find`的难用在于很难去记住那些合适的表达式来描述我想要的文件。(而且 Mac 上的 find 命令和非 Mac 的 find 命令还有些许不同,这更加深了我的失望。) + 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`是一个很好的替代品(它的作者和`bat`的作者是同一个人)。他非常快而且对于我经常要搜索的命令非常好记。 + `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 @@ -129,19 +194,33 @@ $ fd cli -x wc -w # find "cli" and run `wc -w` on each file ### ncdu > du +对我来说,知道当前的磁盘空间使用是非常重要的任务。我用过 Mac 上的[Dish Daisy][17],但是我觉得那个程序产生结果有点慢。 + 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. +`du -sh`命令是我经常会跑的命令(`-sh`是指结果以总结和人类可读的方式显示),不过我经常会想要深入挖掘那些占用了大量的目录。 + 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. +`nudu`是一个非常棒的替代。它提供了一个交互式的界面并且允许快速的扫描那些占用了大量磁盘空间的目录和文件,它又快又准。(尽管不管在哪个工具的情况下,扫描我的home目录都要很长时间,它有550G) + + `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). +一旦当我找到一个目录我想要`处理`一下(如删除,移动或压缩文件),我都会使用命令+点击屏幕[iTerm2][18]上部的目录名字来对那个目录执行搜索。 + 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] +还有另外一个选择[nnn][20],它提供了一个更漂亮的界面,尽管它也提供文件尺寸和使用情况,实际上它更像一个全功能的文件管理器。 + 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: + +我的`nudu`使用下面的别名链接: + ``` alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules" @@ -149,6 +228,13 @@ alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules" The options are: +选项有: + + * `--color dark` 使用颜色方案 + * `-rr` 只读模式(防止误删和运行新的登陆程序) + * `--exclude` 忽略不想操作的目录 + + * `--color dark` \- use a colour scheme * `-rr` \- read-only mode (prevents delete and spawn shell) * `--exclude` ignore directories I won't do anything about @@ -159,13 +245,20 @@ The options are: ### tldr > man +几乎所有的单独命令行工具都有一个相伴的手册,其可以被`man 命令`来调出,但是在`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. +这就是TL;DR(译注:英文里`文档太长,没空去读`的缩写)项目的初衷。这个一个由社区驱动的文档系统,它针对的是命令行。就我现在用下来,我还没碰到过一个命令它没有相应的文档,你[也可以做贡献][22]. + 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] +作为一个小技巧,我将`tldr`的别名链接到`help`(这样输入会快一点。。。) + As a nicety, I've also aliased `tldr` to `help` (since it's quicker to type!): + ``` alias help='tldr' @@ -175,17 +268,29 @@ alias help='tldr' ### ack || ag > grep +`grep`毫无疑问是一个命令行上的强力工具,但是经过这些年它已经被一些工具超越了。其中两个叫`ack`和`ag`。 + `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`. +我个人来说`ack`和`ag`都尝试过,并没有非常明显的个人偏好,(那也就是说他们都很棒,并且很相似)。我倾向于默认只使用`ack`,因为这三个字符就在指尖,很好打。并且,`ack`有大量的`ack --bar`参数可以使用,(你一定会体会到这一点。) + 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)! +`ack`和`ag`都将使用正则表达式来表达搜索,并且对我的工作有关,我能指定搜索的文件类型而不用使用类似于`--js`或`--html`的文件标识(尽管`ag`比`ack`在文件类型过滤器里包括了更多的文件类型。) + 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`). +两个工具都支持常见的`grep`选项,如`-B`和`-A`用于在搜索的上下文里指代`之前`和`之后`。 + Both tools also support the usual `grep` options, like `-B` and `-A` for before and after context in the grep. ![ack in action][25] +因为`ack`不支持markdown(而我又恰好写了很多markdown), 我在我的`~/.ackrc`文件里放了如下的定制语句: + 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 @@ -198,11 +303,19 @@ Since `ack` doesn't come with markdown support (and I write a lot in markdown), ### jq > grep et al +我是[jq][29]的粉丝之一。当然一开始我也在它的语法里苦苦挣扎,还好我对查询语言还算有些使用心得,现在我对`jq`可以说是每天都要用。(不过从前我要么使用grep 或者使用一个叫[json][30]的工具,相比而言后者非常基础了。) + 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). +我甚至开始撰写一个`jq`的说明系列(有2500字并且还在增加),我还发布了一个[web tool][31]和一个Mac 上的应用(这个还没有发布。) + 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`允许我传入一个 JSON 并且能非常简单的转变其为一个 JSON格式的适合我要求的结果。下面这个例子允许我用一个命令更新我的所有节点依赖(为了便于于都,我将其分成为多行。) + `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 | \ @@ -235,6 +348,9 @@ The above command will list all the node dependencies that are out of date, and That result is then fed into the `npm install` command and voilà, I'm all upgraded (using the sledgehammer approach). ### Honourable mentions +### 很荣幸提及一些其他的工具 + +我也在开始尝试一些别的工具,但我还没有完全掌握他们。(出了`ponysay`,当我新启动一个命令行会话时,它就会出现。) 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!): @@ -246,6 +362,9 @@ Some of the other tools that I've started poking around with, but haven't used t ### What about you? +### 你有什么好点子吗? + +上面是我的命令行清单。能告诉我们你的吗?你有没有增强一些你每天都会用到的命令呢?我非常乐意知道。 So that's my list. How about you? What daily command line tools have you improved? I'd love to know. @@ -256,7 +375,7 @@ via: https://remysharp.com/2018/08/23/cli-improved 作者:[Remy Sharp][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:DavidChenLiang(https://github.com/DavidChenLiang) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From e31dffe40db70904f3f6247484f696ec345afee6 Mon Sep 17 00:00:00 2001 From: distant1219 Date: Wed, 17 Oct 2018 10:42:14 +0800 Subject: [PATCH 002/158] Delete 20181012 Command line quick tips- Reading files different ways.md --- ...uick tips- Reading files different ways.md | 120 ------------------ 1 file changed, 120 deletions(-) delete mode 100644 sources/tech/20181012 Command line quick tips- Reading files different ways.md diff --git a/sources/tech/20181012 Command line quick tips- Reading files different ways.md b/sources/tech/20181012 Command line quick tips- Reading files different ways.md deleted file mode 100644 index 87e6e77d1e..0000000000 --- a/sources/tech/20181012 Command line quick tips- Reading files different ways.md +++ /dev/null @@ -1,120 +0,0 @@ -translating by distant1219 - -Command line quick tips: Reading files different ways -====== - -![](https://fedoramagazine.org/wp-content/uploads/2018/10/commandlinequicktips-816x345.jpg) - -Fedora is delightful to use as a graphical operating system. You can point and click your way through just about any task easily. But you’ve probably seen there is a powerful command line under the hood. To try it out in a shell, just open the Terminal application in your Fedora system. This article is one in a series that will show you some common command line utilities. - -In this installment you’ll learn how to read files in different ways. If you open a Terminal to do some work on your system, chances are good that you’ll need to read a file or two. - -### The whole enchilada - -The **cat** command is well known to terminal users. When you **cat** a file, you’re simply displaying the whole file to the screen. Really what’s happening under the hood is the file is read one line at a time, then each line is written to the screen. - -Imagine you have a file with one word per line, called myfile. To make this clear, the file will contain the word equivalent for a number on each line, like this: - -``` - - one - two - three - four - five - -``` - -So if you **cat** that file, you’ll see this output: - -``` - - $ cat myfile - one - two - three - four - five - -``` - -Nothing too surprising there, right? But here’s an interesting twist. You can also **cat** that file backward. For this, use the **tac** command. (Note that Fedora takes no blame for this debatable humor!) - -``` - - $ tac myfile - five - four - three - two - one - -``` - -The **cat** file also lets you ornament the file in different ways, in case that’s helpful. For instance, you can number lines: - -``` - - $ cat -n myfile - 1 one - 2 two - 3 three - 4 four - 5 five - -``` - -There are additional options that will show special characters and other features. To learn more, run the command **man cat** , and when done just hit **q** to exit back to the shell. - -### Picking over your food - -Often a file is too long to fit on a screen, and you may want to be able to go through it like a document. In that case, try the **less** command: - -``` - - $ less myfile - -``` - -You can use your arrow keys as well as **PgUp/PgDn** to move around the file. Again, you can use the **q** key to quit back to the shell. - -There’s actually a **more** command too, based on an older UNIX command. If it’s important to you to still see the file when you’re done, you might want to use it. The **less** command brings you back to the shell the way you left it, and clears the display of any sign of the file you looked at. - -### Just the appetizer (or dessert) - -Sometimes the output you want is just the beginning of a file. For instance, the file might be so long that when you **cat** the whole thing, the first few lines scroll past before you can see them. The **head** command will help you grab just those lines: - -``` - - $ head -n 2 myfile - one - two - -``` - -In the same way, you can use **tail** to just grab the end of a file: - -``` - - $ tail -n 3 myfile - three - four - five - -``` - -Of course these are only a few simple commands in this area. But they’ll get you started when it comes to reading files. - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/commandline-quick-tips-reading-files-different-ways/ - -作者:[Paul W. Frields][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/pfrields/ -[b]: https://github.com/lujun9972 From 32a6fc570a53c1ce76001e9f84c10b407a0bb8af Mon Sep 17 00:00:00 2001 From: distant1219 Date: Wed, 17 Oct 2018 10:43:50 +0800 Subject: [PATCH 003/158] Create 20181012 Command line quick tips- Reading files different ways.md --- ...uick tips- Reading files different ways.md | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 translated/tech/20181012 Command line quick tips- Reading files different ways.md diff --git a/translated/tech/20181012 Command line quick tips- Reading files different ways.md b/translated/tech/20181012 Command line quick tips- Reading files different ways.md new file mode 100644 index 0000000000..cbd0115294 --- /dev/null +++ b/translated/tech/20181012 Command line quick tips- Reading files different ways.md @@ -0,0 +1,116 @@ +命令行快速提示: 读取文件的不同方式 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/10/commandlinequicktips-816x345.jpg) + +作为图形操作系统,Fedora 的使用是令人愉快的。你可以轻松地点按,完成任何任务。 但你可能已经看到了,在引擎盖下还有一个强大的命令行。 想要在 shell 下使用,只需要在 Fedora 系统中打开你的命令行应用程序。 这篇文章是向你展示命令行使用方法的系列之一。 + +在这部分,你将学习如何以不同的方式读取文件,如果你在系统中打开一个命令行,你就有可能需要读取一个或两个文件。 + +### 一应俱全的大餐 + +对命令行终端的用户来说, **cat** 命令众所周知。 当你 **cat** 一个文件,你很容易的把整个文件内容展示在你的屏幕上。而真正发生在引擎盖下的是文件一次读取一行, 然后一行一行写入屏幕。 + +假设你有一个文件,叫做 myfile, 这个文件每行只有一个单词。为了简单起见,每行的单词就是这行的行号,就像这样: + +``` + + one + two + three + four + five + +``` + +所以如果你 **cat** 这个文件,你就会看到如下输出: + +``` + + $ cat myfile + one + two + three + four + five + +``` + +并没有太惊喜,不是吗? 但是有个有趣的转折,只要使用 **tac** 命令,你可以从后往前 **cat** 这个文件。(请注意, Fedora 对这种有争议的幽默不承担任何责任!) +``` + + $ tac myfile + five + four + three + two + one + +``` + +**cat** 命令允许你以不同的方式装饰输出,比如,你可以输出行号: + +``` + + $ cat -n myfile + 1 one + 2 two + 3 three + 4 four + 5 five + +``` + +还有其他选项将显示特殊字符和其他功能。 要了解更多, 请运行 **man cat** 命令, 看完之后, 按 **q** 即可退出回到 shell。 + +### 挑选你的食物 + +通常, 文件太长, 无法全部显示在屏幕上, 您可能希望能够像文档一样查看它。 这种情况下,可以试试 **less** 命令: + +``` + + $ less myfile + +``` + +你可以用方向键,也可以用 **PgUp/PgDn** 来查看文件, 按 **q** 就可以退回到 shell。 + +实际上,还有一个 **more** 命令,它是基于在旧的 UNIX 系统命令的。如果在退回 shell 后仍想看到该文件, 则可能需要使用它。**less** 命令使你回到你离开 shell 之前的样子,并且清除屏幕上你看到的所有的文件内容。 + +### 一点披萨或甜点 + +有时, 你所需的输出只是文件的开头。 比如,有一个非常长的文件,当你使用 **cat** 命令时,会显示这个文件所有内容,前几行的内容很容易滚动过去,导致你看不到。**head** 命令会帮你获取文件的前几行: + +``` + + $ head -n 2 myfile + one + two + +``` +同样,你会用 **tail** 命令来查看文件的末尾几行: + +``` + + $ tail -n 3 myfile + three + four + five + +``` + +当然, 这些只是在这个领域的几个简单的命令。但当涉及到阅读文件时,你就能容易地开始。 + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/commandline-quick-tips-reading-files-different-ways/ + +作者:[Paul W. Frields][a] +选题:[lujun9972][b] +译者:[distant1219](https://github.com/distant1219) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 From 863e8b777f632d26d169e4c01ebe96610051ffd7 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 17 Oct 2018 14:23:21 +0800 Subject: [PATCH 004/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20Enable?= =?UTF-8?q?=20or=20Disable=20Services=20on=20Boot=20in=20Linux=20Using=20c?= =?UTF-8?q?hkconfig=20and=20systemctl=20Command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...x Using chkconfig and systemctl Command.md | 246 ++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 sources/tech/20181015 How to Enable or Disable Services on Boot in Linux Using chkconfig and systemctl Command.md diff --git a/sources/tech/20181015 How to Enable or Disable Services on Boot in Linux Using chkconfig and systemctl Command.md b/sources/tech/20181015 How to Enable or Disable Services on Boot in Linux Using chkconfig and systemctl Command.md new file mode 100644 index 0000000000..cc75d4490f --- /dev/null +++ b/sources/tech/20181015 How to Enable or Disable Services on Boot in Linux Using chkconfig and systemctl Command.md @@ -0,0 +1,246 @@ +How to Enable or Disable Services on Boot in Linux Using chkconfig and systemctl Command +====== +It’s a important topic for Linux admin (such a wonderful topic) so, everyone must be aware of this and practice how to use this in the efficient way. + +In Linux, whenever we install any packages which has services or daemons. By default all the services “init & systemd” scripts will be added into it but it wont enabled. + +Hence, we need to enable or disable the service manually if it’s required. There are three major init systems are available in Linux which are very famous and still in use. + +### What is init System? + +In Linux/Unix based operating systems, init (short for initialization) is the first process that started during the system boot up by the kernel. + +It’s holding a process id (PID) of 1. It will be running in the background continuously until the system is shut down. + +Init looks at the `/etc/inittab` file to decide the Linux run level then it starts all other processes & applications in the background as per the run level. + +BIOS, MBR, GRUB and Kernel processes were kicked up before hitting init process as part of Linux booting process. + +Below are the available run levels for Linux (There are seven runlevels exist, from zero to six). + + * **`0:`** halt + * **`1:`** Single user mode + * **`2:`** Multiuser, without NFS + * **`3:`** Full multiuser mode + * **`4:`** Unused + * **`5:`** X11 (GUI – Graphical User Interface) + * **`:`** reboot + + + +Below three init systems are widely used in Linux. + + * System V (Sys V) + * Upstart + * systemd + + + +### What is System V (Sys V)? + +System V (Sys V) is one of the first and traditional init system for Unix like operating system. init is the first process that started during the system boot up by the kernel and it’s a parent process for everything. + +Most of the Linux distributions started using traditional init system called System V (Sys V) first. Over the years, several replacement init systems were released to address design limitations in the standard versions such as launchd, the Service Management Facility, systemd and Upstart. + +But systemd has been adopted by several major Linux distributions over the traditional SysV init systems. + +### What is Upstart? + +Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running. + +It was originally developed for the Ubuntu distribution, but is intended to be suitable for deployment in all Linux distributions as a replacement for the venerable System-V init. + +It was used in Ubuntu from 9.10 to Ubuntu 14.10 & RHEL 6 based systems after that they are replaced with systemd. + +### What is systemd? + +Systemd is a new init system and system manager which was implemented/adapted into all the major Linux distributions over the traditional SysV init systems. + +systemd is compatible with SysV and LSB init scripts. It can work as a drop-in replacement for sysvinit system. systemd is the first process get started by kernel and holding PID 1. + +It’s a parant process for everything and Fedora 15 is the first distribution which was adapted systemd instead of upstart. systemctl is command line utility and primary tool to manage the systemd daemons/services such as (start, restart, stop, enable, disable, reload & status). + +systemd uses .service files Instead of bash scripts (SysVinit uses). systemd sorts all daemons into their own Linux cgroups and you can see the system hierarchy by exploring `/cgroup/systemd` file. + +### How to Enable or Disable Services on Boot Using chkconfig Commmand? + +The chkconfig utility is a command-line tool that allows you to specify in which +runlevel to start a selected service, as well as to list all available services along with their current setting. + +Also, it will allows us to enable or disable a services from the boot. Make sure you must have superuser privileges (either root or sudo) to use this command. + +All the services script are located on `/etc/rd.d/init.d`. + +### How to list All Services in run-level + +The `-–list` parameter displays all the services along with their current status (What run-level the services are enabled or disabled). + +``` + # chkconfig --list + NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off + abrt-ccpp 0:off 1:off 2:off 3:on 4:off 5:on 6:off + abrtd 0:off 1:off 2:off 3:on 4:off 5:on 6:off + acpid 0:off 1:off 2:on 3:on 4:on 5:on 6:off + atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off + auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off + . + . +``` + +### How to check the Status of Specific Service + +If you would like to see a particular service status in run-level then use the following format and grep the required service. + +In this case, we are going to check the `auditd` service status in run-level. + +``` + # chkconfig --list| grep auditd + auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off +``` + +### How to Enable a Particular Service on Run Levels + +Use `--level` parameter to enable a service in the required run-level. In this case, we are going to enable `httpd` service on run-level 3 and 5. + +``` + # chkconfig --level 35 httpd on +``` + +### How to Disable a Particular Service on Run Levels + +Use `--level` parameter to disable a service in the required run-level. In this case, we are going to enable `httpd` service on run-level 3 and 5. + +``` + # chkconfig --level 35 httpd off +``` + +### How to Add a new Service to the Startup List + +The `-–add` parameter allows us to add any new service to the startup. By default, it will turn on level 2, 3, 4 and 5 automatically for that service. + +``` + # chkconfig --add nagios +``` + +### How to Remove a Service from Startup List + +Use `--del` parameter to remove the service from the startup list. Here, we are going to remove the Nagios service from the startup list. + +``` + # chkconfig --del nagios +``` + +### How to Enable or Disable Services on Boot Using systemctl Command? + +systemctl is command line utility and primary tool to manage the systemd daemons/services such as (start, restart, stop, enable, disable, reload & status). + +All the created systemd unit files are located on `/etc/systemd/system/`. + +### How to list All Services + +Use the following command to list all the services which included enabled and disabled. + +``` + # systemctl list-unit-files --type=service + UNIT FILE STATE + arp-ethers.service disabled + auditd.service enabled + [email protected] enabled + blk-availability.service disabled + brandbot.service static + [email protected] static + chrony-wait.service disabled + chronyd.service enabled + cloud-config.service enabled + cloud-final.service enabled + cloud-init-local.service enabled + cloud-init.service enabled + console-getty.service disabled + console-shell.service disabled + [email protected] static + cpupower.service disabled + crond.service enabled + . + . + 150 unit files listed. +``` + +If you would like to see a particular service status then use the following format and grep the required service. In this case, we are going to check the `httpd` service status. + +``` + # systemctl list-unit-files --type=service | grep httpd + httpd.service disabled +``` + +### How to Enable a Particular Service on boot + +Use the following systemctl command format to enable a particular service. To enable a service, it will create a symlink. The same can be found below. + +``` + # systemctl enable httpd + Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. +``` + +Run the following command to double check whether the services is enabled or not on boot. + +``` + # systemctl is-enabled httpd + enabled +``` + +### How to Disable a Particular Service on boot + +Use the following systemctl command format to disable a particular service. When you run the command, it will remove a symlink which was created by you while enabling the service. The same can be found below. + +``` + # systemctl disable httpd + Removed symlink /etc/systemd/system/multi-user.target.wants/httpd.service. +``` + +Run the following command to double check whether the services is disabled or not on boot. + +``` + # systemctl is-enabled httpd + disabled +``` + +### How to Check the current run level + +Use the following systemctl command to verify which run-level you are in. Still “runlevel” command works with systemd, however runlevels is a legacy concept in systemd so, i would advise you to use systemctl command for all activity. + +We are in `run-level 3`, the same is showing below as `multi-user.target`. + +``` + # systemctl list-units --type=target + UNIT LOAD ACTIVE SUB DESCRIPTION + basic.target loaded active active Basic System + cloud-config.target loaded active active Cloud-config availability + cryptsetup.target loaded active active Local Encrypted Volumes + getty.target loaded active active Login Prompts + local-fs-pre.target loaded active active Local File Systems (Pre) + local-fs.target loaded active active Local File Systems + multi-user.target loaded active active Multi-User System + network-online.target loaded active active Network is Online + network-pre.target loaded active active Network (Pre) + network.target loaded active active Network + paths.target loaded active active Paths + remote-fs.target loaded active active Remote File Systems + slices.target loaded active active Slices + sockets.target loaded active active Sockets + swap.target loaded active active Swap + sysinit.target loaded active active System Initialization + timers.target loaded active active Timers +``` +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-enable-or-disable-services-on-boot-in-linux-using-chkconfig-and-systemctl-command/ + +作者:[Prakash Subramanian][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/prakash/ +[b]: https://github.com/lujun9972 From af3281957a80000dbdb9d1c2b71fed85afc6cd36 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 17 Oct 2018 14:27:19 +0800 Subject: [PATCH 005/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Turn=20Your=20Old?= =?UTF-8?q?=20PC=20into=20a=20Retrogaming=20Console=20with=20Lakka=20Linux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... a Retrogaming Console with Lakka Linux.md | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md diff --git a/sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md b/sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md new file mode 100644 index 0000000000..7475e9c1b3 --- /dev/null +++ b/sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md @@ -0,0 +1,78 @@ +Turn Your Old PC into a Retrogaming Console with Lakka Linux +====== +**If you have an old computer gathering dust, you can turn it into a PlayStation like retrogaming console with Lakka Linux distribution. ** + +You probably already know that there are [Linux distributions specially crafted for reviving older computers][1]. But did you know about a Linux distribution that is created for the sole purpose of turning your old computer into a retro-gaming console? + +![Lakka is a Linux distribution specially for retrogaming][2] + +Meet [Lakka][3], a lightweight Linux distribution that will transform your old or low-end computer (like Raspberry Pi) into a complete retrogaming console, + +When I say retrogaming console, I am serious about the console part. If you have ever used a PlayStation of Xbox, you know what a typical console interface looks like. + +Lakka provides a similar interface and a similar experience. I’ll talk about the ‘experience’ later. Have a look at the interface first. + + +Lakka Retrogaming interface + +### Lakka: Linux distributions for retrogaming + +Lakka is the official Linux distribution of [RetroArch][4] and the [Libretro][5] ecosystem. + +RetroArch is a frontend for retro game emulators and game engines. The interface you saw in the video above is nothing but RetroArch. If you just want to play retro games, you can simply install RetroArch in your current Linux distribution. + +Lakka provides Libretro core with RetroArch. So you get a preconfigured operating system that you can install or plug in the live USB and start playing games. + +Lakka is lightweight and you can install it on most old systems or single board computers like Raspberry Pi. + +It supports a huge number of emulators. You just need to download the ROMs on your system and Lakka will play the games from these ROMs. You can find the list supported emulators and hardware [here][6]. + +It enables you to run classic games on a wide range of computers and consoles through its slick graphical interface. Settings are also unified so configuration is done once and for all. + +Let me summarize the main features of Lakka: + + * PlayStation like interface with RetroArch + * Support for a number of retro game emulators + * Supports up to 5 players gaming on the same system + * Savestates allow you to save your progress at any moment in the game + * You can improve the look of your old games with various graphical filters + * You can join multiplayer games over the network + * Out of the box support for a number of joypads like XBOX360, Dualshock 3, and 8bitdo + * Unlike trophies and badges by connecting to [RetroAchievements][7] + + + +### Getting Lakka + +Before you go on installing Lakka you should know that it is still under development so expect a few bugs here and there. + +Keep in mind that Lakka only supports MBR partitioning. So if it doesn’t read your hard drive while installing, this could be a reason. + +The [FAQ section of the project][8] answers the common doubts, so please refer to it for any further questions. + +[Get Lakka][9] + +Do you like playing retro games? What emulators do you use? Have you ever used Lakka before? Share your views with us in the comments section. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/lakka-retrogaming-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/lightweight-linux-beginners/ +[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/10/lakka-retrogaming-linux.jpeg +[3]: http://www.lakka.tv/ +[4]: https://www.retroarch.com/ +[5]: https://www.libretro.com/ +[6]: http://www.lakka.tv/powerful/ +[7]: https://retroachievements.org/ +[8]: http://www.lakka.tv/doc/FAQ/ +[9]; http://www.lakka.tv/disclaimer/ From 356161f2a9f18bc22fcc5a8b782ae96f9efff12c Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 17 Oct 2018 14:29:13 +0800 Subject: [PATCH 006/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Running=20Linux?= =?UTF-8?q?=20containers=20as=20a=20non-root=20with=20Podman?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ux containers as a non-root with Podman.md | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 sources/tech/20181015 Running Linux containers as a non-root with Podman.md diff --git a/sources/tech/20181015 Running Linux containers as a non-root with Podman.md b/sources/tech/20181015 Running Linux containers as a non-root with Podman.md new file mode 100644 index 0000000000..3a86e502b2 --- /dev/null +++ b/sources/tech/20181015 Running Linux containers as a non-root with Podman.md @@ -0,0 +1,82 @@ +Running Linux containers as a non-root with Podman +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/10/podman-816x345.jpg) + +Linux containers are processes with certain isolation features provided by a Linux kernel — including filesystem, process, and network isolation. Containers help with portability — applications can be distributed in container images along with their dependencies, and run on virtually any Linux system with a container runtime. + +Although container technologies exist for a very long time, Linux containers were widely popularized by Docker. The word “Docker” can refer to several different things, including the container technology and tooling, the community around that, or the Docker Inc. company. However, in this article, I’ll be using it to refer to the technology and the tooling that manages Linux containers. + +### What is Docker + +[Docker][1] is a daemon that runs on your system as root, and manages running containers by leveraging features of the Linux kernel. Apart from running containers, it also makes it easy to manage container images — interacting with container registries, storing images, managing container versions, etc. It basically supports all the operations you need to run individual containers. + +But even though Docker is very a handy tool for managing Linux containers, it has two drawbacks: it is a daemon that needs to run on your system, and it needs to run with root privileges which might have certain security implications. Both of those, however, are being addressed by Podman. + +### Introducing Podman + +[Podman][2] is a container runtime providing a very similar features as Docker. And as already hinted, it doesn’t require any daemon to run on your system, and it can also run without root privileges. So let’s have a look at some examples of using Podman to run Linux containers. + +#### Running containers with Podman + +One of the simplest examples could be running a Fedora container, printing “Hello world!” in the command line: + +``` + $ podman run --rm -it fedora:28 echo "Hello world!" +``` + +Building an image using the common Dockerfile works the same way as it does with Docker: + +``` + $ cat Dockerfile + FROM fedora:28 + RUN dnf -y install cowsay + + $ podman build . -t hello-world + ... output omitted ... + + $ podman run --rm -it hello-world cowsay "Hello!" +``` + +To build containers, Podman calls another tool called Buildah in the background. You can read a recent [post about building container images with Buildah][3] — not just using the typical Dockerfile. + +Apart from building and running containers, Podman can also interact with container registries. To log in to a container registry, for example the widely used Docker Hub, run: + +``` + $ podman login docker.io +``` + +To push the image I just built, I just need to tag so it refers to the specific container registry and my personal namespace, and then simply push it. + +``` + $ podman -t hello-world docker.io/asamalik/hello-world + $ podman push docker.io/asamalik/hello-world +``` + +By the way, have you noticed how I run everything as a non-root user? Also, there is no big fat daemon running on my system! + +#### Installing Podman + +Podman is available by default on [Silverblue][4] — a new generation of Linux Workstation for container-based workflows. To install it on any Fedora release, simply run: + +``` + $ sudo dnf install podman +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/running-containers-with-podman/ + +作者:[Adam Šamalík][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/asamalik/ +[b]: https://github.com/lujun9972 +[1]: https://docs.docker.com/ +[2]: https://podman.io/ +[3]: https://fedoramagazine.org/daemon-less-container-management-buildah/ +[4]: https://silverblue.fedoraproject.org/ From 3fe0c44f3ae9af686dc431e6025d9009a2d19d46 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 17 Oct 2018 14:32:48 +0800 Subject: [PATCH 007/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Kali=20Linux:=20W?= =?UTF-8?q?hat=20You=20Must=20Know=20Before=20Using=20it=20=E2=80=93=20FOS?= =?UTF-8?q?S=20Post?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...u Must Know Before Using it - FOSS Post.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 sources/tech/20181015 Kali Linux- What You Must Know Before Using it - FOSS Post.md diff --git a/sources/tech/20181015 Kali Linux- What You Must Know Before Using it - FOSS Post.md b/sources/tech/20181015 Kali Linux- What You Must Know Before Using it - FOSS Post.md new file mode 100644 index 0000000000..0a8571b7e6 --- /dev/null +++ b/sources/tech/20181015 Kali Linux- What You Must Know Before Using it - FOSS Post.md @@ -0,0 +1,93 @@ +Kali Linux: What You Must Know Before Using it – FOSS Post +====== +![](https://i1.wp.com/fosspost.org/wp-content/uploads/2018/10/kali-linux.png?fit=1237%2C527&ssl=1) + +Kali Linux is the industry’s leading Linux distribution in penetration testing and ethical hacking. It is a distribution that comes shipped with tons and tons of hacking and penetration tools and software by default, and is widely recognized in all parts of the world, even among Windows users who may not even know what Linux is. + +Because of the latter, many people are trying to get alone with Kali Linux although they don’t even understand the basics of a Linux system. The reasons may vary from having fun, faking being a hacker to impress a girlfriend or simply trying to hack the neighbors’ WiFi network to get a free Internet, all of which is a bad thing to do if you are planning to use Kali Linux. + +Here are some tips that you should know before even planning to use Kali Linux + +### Kali Linux is Not for Beginners + +![](https://i0.wp.com/fosspost.org/wp-content/uploads/2018/10/Kali-Linux-000.png?resize=850%2C478&ssl=1) +Kali Linux Default GNOME Desktop + +If you are someone who has just started to use Linux few months ago, or if you are don’t consider yourself to be above average in terms of knowledge, then Kali Linux is not for you. If you are going to ask stuff like “How do I install Steam on Kali? How do I make my printer work on Kali? How do I solve the APT sources error on Kali”? Then Kali Linux is not suitable for you. + +Kali Linux is mainly made for professionals wanting to run penetration testing suits or people who want to learn ethical hacking and digital forensics. But even if you were from the latter, the average Kali Linux user is expected to face a lot of trouble while using Kali Linux for his day-to-day usage. He’s also expected to take a very careful approach to how he uses the tools and software, it’s not just “let’s install it and run everything”. Every tool must be carefully used, every software you install must be carefully examined. + +**Good Read:** [What are the components of a Linux system?][1] + +Stuff which the average Linux user can’t do normally. A better approach would be to spend few weeks learning about Linux and its daemons, services, software, distributions and the way it works, and then watch few dozens of videos and courses about ethical hacking, and only then, try to use Kali to apply what you learned. + +### it Can Get You Hacked + +![](https://i0.wp.com/fosspost.org/wp-content/uploads/2018/10/Kali-Linux-001.png?resize=850%2C478&ssl=1) +Kali Linux Hacking & Testing Tools + +In a normal Linux system, there’s one account for normal user and one separate account for root. This is not the case in Kali Linux. Kali Linux uses the root account by default and doesn’t provide you with a normal user account. This is because almost all security tools available in Kali do require root privileges, and to avoid asking you for root password every minute, they designed it that way. + +Of course, you could simply create a normal user account and start using it. Well, it’s still not recommended because that’s not how the Kali Linux system design is meant to work. You’ll face a lot of problems then in using programs, opening ports, debugging software, discovering why this thing doesn’t work only to discover that it was a weird privilege bug. You will also be annoyed by all the tools that will require you to enter the password each time you try to do anything on your system. + +Now, since you are forced to use it in as a root user, all the software you run on your system will also run with root privileges. This is bad if you don’t know what you are doing, because if there’s a vulnerability in Firefox for example and you visit one of the infected dark web sites, the hacker will be able to get full root permissions on your PC and hack you, which would have been limited if you were using a normal user account. Also, some tools that you may install and use can open ports and leak information without your knowledge, so if you are not extremely careful, people can hack you in the same way you may try to hack them. + +If you visit Facebook groups related to Kali Linux on few occasions, you’ll notice that almost a quarter of the posts in these groups are people calling for help because someone hacked them. + +### it Can Get You in Jail + +Kali Linux provide the software as it is. Then, it is your own responsibility alone of how you use them. + +In most advanced countries around the world, using penetration testing tools against public WiFi networks or the devices of others can easily get you in jail. Now don’t think that you can’t be tracked just because you are using Kali, many systems are configured to have complex logging devices to simply track whoever tries to listen or hack their networks, and you may stumble upon one of these, and it will destroy you life. + +Don’t ever use Kali Linux tools against devices/networks which do not belong to you or given explicit permission to try hacking them. If you say that you didn’t know what you were doing, it won’t be accepted as an excuse in a court. + +### Modified Kernel and Software + +Kali is [based][2] on Debian (Testing branch, which means that Kali Linux uses a rolling release model), so it uses most of the software architecture from there, and you will find most of the software in Kali Linux just as they are in Debian. + +However, some packages were modified to harden security and fix some possible vulnerabilities. The Linux kernel that Kali uses for example is patched to allow wireless injection on various devices. These patches are not normally available in the vanilla kernel. Also, Kali Linux does not depend on Debian servers and mirrors, but builds the packages by its own servers. Here’s the default software sources in the latest release: + +``` + deb http://http.kali.org/kali kali-rolling main contrib non-free + deb-src http://http.kali.org/kali kali-rolling main contrib non-free +``` + +That’s why, for some specific software, you will find a different behaviour when using the same program in Kali Linux or using it in Fedora, for example. You can see a full list of Kali Linux software from [git.kali.org][3]. You can also find our [own generated list of installed packages][4] on Kali Linux (GNOME). + +More importantly, Kali Linux official documentation extremely suggests to NOT add any other 3rd-party software repositories, because since Kali Linux is a rolling release and depends on Debian Testing, you will most likely break your system by just adding a new repository source due to dependencies conflicts and package hooks. + +### Don’t Install Kali Linux + +![](https://i0.wp.com/fosspost.org/wp-content/uploads/2018/10/Kali-Linux-002.png?resize=750%2C504&ssl=1) +Running wpscan on fosspost.org using Kali Linux + +I use Kali Linux on rare occasions to test the software and servers I deploy. However, I will never dare to install it and use it as a primary system. + +If you are going to use it as a primary system, then you will have to keep your own personal files, password, data and everything else on your system. You will also need to install tons of daily-use software in order to ease your life. But as we mentioned above, using Kali Linux is very risky and should be done very carefully, and if you get hacked, you will lose all your data and it may get exposed to a wider audience. Your personal information can also be used to track you if you are doing non-legal stuff. You may even destroy your data by yourself if you are not careful about how you use the tools. + +Even professional white hackers don’t recommend installing it as a primary system, but rather, use it from USB to just do your penetration testing work and then leave back to your normal Linux distribution. + +### The Bottom Line + +As you may see now, using Kali is not an easy decision to take lightly. If you are planning to be a whiter hacker and you need to use Kali to learn, then go for it after learning the basics and spending few months with a normal system. But be careful for what you are doing to avoid being in trouble. + +If you are planning to use Kali or if you need any help, I’ll be happy to hear your thoughts in the comments. + +-------------------------------------------------------------------------------- + +via: https://fosspost.org/articles/must-know-before-using-kali-linux + +作者:[M.Hanny Sabbagh][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fosspost.org/author/mhsabbagh +[b]: https://github.com/lujun9972 +[1]: https://fosspost.org/articles/what-are-the-components-of-a-linux-distribution +[2]: https://www.kali.org/news/kali-linux-rolling-edition-2016-1/ +[3]: http://git.kali.org +[4]: https://paste.ubuntu.com/p/bctSVWwpVw/ From 9c2b118e7a7acf15c9dc6a3b806cebedc594e31a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 17 Oct 2018 21:43:53 +0800 Subject: [PATCH 008/158] PRF:20181011 Getting started with Minikube- Kubernetes on your laptop.md @Flowsnow --- ...ith Minikube- Kubernetes on your laptop.md | 56 +++++++++---------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/translated/tech/20181011 Getting started with Minikube- Kubernetes on your laptop.md b/translated/tech/20181011 Getting started with Minikube- Kubernetes on your laptop.md index 84f1187a32..7af8e05fdd 100644 --- a/translated/tech/20181011 Getting started with Minikube- Kubernetes on your laptop.md +++ b/translated/tech/20181011 Getting started with Minikube- Kubernetes on your laptop.md @@ -1,17 +1,20 @@ -Minikube入门:笔记本上的Kubernetes +Minikube 入门:笔记本上的 Kubernetes ====== -运行Minikube的分步指南。 + +> 运行 Minikube 的分步指南。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cube_innovation_process_block_container.png?itok=vkPYmSRQ) -在[Hello Minikube][1]教程页面上Minikube被宣传为基于Docker运行Kubernetes的一种简单方法。 虽然该文档非常有用,但它主要是为MacOS编写的。 你可以深入挖掘在Windows或某个Linux发行版上的使用说明,但它们不是很清楚。 许多文档都是针对Debian / Ubuntu用户的,比如[安装Minikube的驱动程序][2]。 +在 [Hello Minikube][1] 教程页面上 Minikube 被宣传为基于 Docker 运行 Kubernetes 的一种简单方法。 虽然该文档非常有用,但它主要是为 MacOS 编写的。 你可以深入挖掘在 Windows 或某个 Linux 发行版上的使用说明,但它们不是很清楚。 许多文档都是针对 Debian / Ubuntu 用户的,比如[安装 Minikube 的驱动程序][2]。 + +这篇指南旨在使得在基于 RHEL/Fedora/CentOS 的操作系统上更容易安装 Minikube。 ### 先决条件 -1. 你已经[安装了Docker][3]。 -2. 你的计算机是一个RHEL / CentOS / 基于Fedora的工作站。 -3. 你已经[安装了正常运行的KVM2虚拟机管理程序][4]。 -4. 你有一个运行的**docker-machine-driver-kvm2**。 以下命令将安装驱动程序: +1. 你已经[安装了 Docker][3]。 +2. 你的计算机是一个基于 RHEL / CentOS / Fedora 的工作站。 +3. 你已经[安装了正常运行的 KVM2 虚拟机管理程序][4]。 +4. 你有一个可以工作的 docker-machine-driver-kvm2。 以下命令将安装该驱动程序: ``` curl -Lo docker-machine-driver-kvm2 https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2 \ @@ -20,52 +23,51 @@ chmod +x docker-machine-driver-kvm2 \ && rm docker-machine-driver-kvm2 ``` -### 下载,安装和启动Minikube +### 下载、安装和启动Minikube - 1. 为你要即将下载的两个文件创建一个目录,两个文件分别是:[minikube][5]和[kubectl][6]。 +1、为你要即将下载的两个文件创建一个目录,两个文件分别是:[minikube][5] 和 [kubectl][6]。 - - 2. 打开终端窗口并运行以下命令来安装minikube。 +2、打开终端窗口并运行以下命令来安装 minikube。 ``` curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64 ``` -请注意,minikube版本(例如,minikube-linux-amd64)可能因计算机的规格而有所不同。 +请注意,minikube 版本(例如,minikube-linux-amd64)可能因计算机的规格而有所不同。 - 3. **chmod**加执行权限。 +3、`chmod` 加执行权限。 ``` chmod +x minikube ``` - 4. 将文件移动到**/usr/local/bin**路径下,以便你能将其作为命令运行。 +4、将文件移动到 `/usr/local/bin` 路径下,以便你能将其作为命令运行。 ``` mv minikube /usr/local/bin ``` - 5. 使用以下命令安装kubectl(类似于minikube的安装过程)。 +5、使用以下命令安装 `kubectl`(类似于 minikube 的安装过程)。 ``` curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl ``` -使用**curl**命令确定最新版本的Kubernetes。 +使用 `curl` 命令确定最新版本的Kubernetes。 - 6. **chmod**给kubectl加执行权限。 +6、`chmod` 给 `kubectl` 加执行权限。 ``` chmod +x kubectl ``` - 7. 将kubectl移动到**/usr/local/bin**路径下作为命令运行。 +7、将 `kubectl` 移动到 `/usr/local/bin` 路径下作为命令运行。 ``` mv kubectl /usr/local/bin ``` - 8. 运行**minikube start**命令。 为此,你需要有虚拟机管理程序。 我使用过KVM2,你也可以使用Virtualbox。 确保是用户而不是root身份运行以下命令,以便为用户而不是root存储配置。 +8、 运行 `minikube start` 命令。 为此,你需要有虚拟机管理程序。 我使用过 KVM2,你也可以使用 Virtualbox。 确保是以普通用户而不是 root 身份运行以下命令,以便为用户而不是 root 存储配置。 ``` minikube start --vm-driver=kvm2 @@ -73,33 +75,31 @@ minikube start --vm-driver=kvm2 这可能需要一段时间,等一会。 - 9. Minikube应该下载并开始。 使用以下命令确保成功。 +9、 Minikube 应该下载并启动。 使用以下命令确保成功。 ``` cat ~/.kube/config ``` - 10. 执行以下命令以运行Minikube作为上下文。 上下文决定了kubectl与哪个集群交互。 你可以在~/.kube/config文件中查看所有可用的上下文。 +10、 执行以下命令以运行 Minikube 作为上下文环境。 上下文环境决定了 `kubectl` 与哪个集群交互。 你可以在 `~/.kube/config` 文件中查看所有可用的上下文环境。 ``` kubectl config use-context minikube ``` - 11. 再次查看**config** 文件以检查Minikube是否存在上下文。 +11、再次查看 `config` 文件以检查 Minikube 是否存在上下文环境。 ``` cat ~/.kube/config ``` - 12. 最后,运行以下命令打开浏览器查看Kubernetes仪表板。 +12、最后,运行以下命令打开浏览器查看 Kubernetes 仪表板。 ``` minikube dashboard ``` -本指南旨在使RHEL / Fedora / CentOS操作系统用户操作更轻松。 - -现在Minikube已启动并运行,请阅读[通过Minikube在本地运行Kubernetes][7]这篇官网教程开始使用它。 +现在 Minikube 已启动并运行,请阅读[通过 Minikube 在本地运行 Kubernetes][7] 这篇官网教程开始使用它。 -------------------------------------------------------------------------------- @@ -108,11 +108,11 @@ via: https://opensource.com/article/18/10/getting-started-minikube 作者:[Bryant Son][a] 选题:[lujun9972][b] 译者:[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/) 荣誉推出 -[a]: +[a]: https://opensource.com/users/brson [b]: https://github.com/lujun9972 [1]: https://kubernetes.io/docs/tutorials/hello-minikube [2]: https://github.com/kubernetes/minikube/blob/master/docs/drivers.md From b0f70fba5e3a76dc7cd0ce4d9ddb5d278e55f1be Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 17 Oct 2018 21:44:15 +0800 Subject: [PATCH 009/158] PUB:20181011 Getting started with Minikube- Kubernetes on your laptop.md @Flowsnow https://linux.cn/article-10125-1.html --- ...11 Getting started with Minikube- Kubernetes on your laptop.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20181011 Getting started with Minikube- Kubernetes on your laptop.md (100%) diff --git a/translated/tech/20181011 Getting started with Minikube- Kubernetes on your laptop.md b/published/20181011 Getting started with Minikube- Kubernetes on your laptop.md similarity index 100% rename from translated/tech/20181011 Getting started with Minikube- Kubernetes on your laptop.md rename to published/20181011 Getting started with Minikube- Kubernetes on your laptop.md From 26df0590c93fbca0407e4ba75ee82e3acafc7d80 Mon Sep 17 00:00:00 2001 From: way-ww <40491614+way-ww@users.noreply.github.com> Date: Wed, 17 Oct 2018 21:45:17 +0800 Subject: [PATCH 010/158] Update 20180924 Why Linux users should try Rust.md request to translate --- sources/tech/20180924 Why Linux users should try Rust.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20180924 Why Linux users should try Rust.md b/sources/tech/20180924 Why Linux users should try Rust.md index db60883eb9..c4ab720700 100644 --- a/sources/tech/20180924 Why Linux users should try Rust.md +++ b/sources/tech/20180924 Why Linux users should try Rust.md @@ -1,3 +1,5 @@ +Translating by way-ww + Why Linux users should try Rust ====== From 509227cb3462cf2453fb17e324704a30b694fd78 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Wed, 17 Oct 2018 21:50:55 +0800 Subject: [PATCH 011/158] Delete 20180329 How to configure multiple websites with Apache web server.md --- ...ultiple websites with Apache web server.md | 160 ------------------ 1 file changed, 160 deletions(-) delete mode 100644 sources/tech/20180329 How to configure multiple websites with Apache web server.md diff --git a/sources/tech/20180329 How to configure multiple websites with Apache web server.md b/sources/tech/20180329 How to configure multiple websites with Apache web server.md deleted file mode 100644 index 671feb17b0..0000000000 --- a/sources/tech/20180329 How to configure multiple websites with Apache web server.md +++ /dev/null @@ -1,160 +0,0 @@ -Translating by MjSeven - - -How to configure multiple websites with Apache web server -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/apache-feathers.jpg?itok=fnrpsu3G) -In my [last post][1], I explained how to configure an Apache web server for a single website. It turned out to be very easy. In this post, I will show you how to serve multiple websites using a single instance of Apache. - -Note: I wrote this article on a virtual machine using Fedora 27 with Apache 2.4.29. If you have another distribution or release of Fedora, the commands you will use and the locations and content of the configuration files may be different. - -As my previous article mentioned, all of the configuration files for Apache are located in `/etc/httpd/conf` and `/etc/httpd/conf.d`. The data for the websites is located in `/var/www` by default. With multiple websites, you will need to provide multiple locations, one for each site you host. - -### Name-based virtual hosting - -With name-based virtual hosting, you can use a single IP address for multiple websites. Modern web servers, including Apache, use the `hostname` portion of the specified URL to determine which virtual web host responds to the page request. This requires only a little more configuration than for a single site. - -Even if you are starting with only a single website, I recommend that you set it up as a virtual host, which will make it easier to add more sites later. In this article, I'll pick up where we left off in the previous article, so you'll need to set up the original website, a name-based virtual website. - -### Preparing the original website - -Before you set up a second website, you need to get name-based virtual hosting working for the existing site. If you do not have an existing website, [go back and create one now][1]. - -Once you have your site, add the following stanza to the bottom of its `/etc/httpd/conf/httpd.conf` configuration file (adding this stanza is the only change you need to make to the `httpd.conf` file): -``` - - -    DocumentRoot /var/www/html - -    ServerName www.site1.org - - - -``` - -This will be the first virtual host stanza, and it should remain first, to make it the default definition. That means that HTTP access to the server by IP address, or by another name that resolves to this IP address but that does not have a specific named host configuration stanza, will be directed to this virtual host. All other virtual host configuration stanzas should follow this one. - -You also need to set up your websites with entries in `/etc/hosts` to provide name resolution. Last time, we just used the IP address for `localhost`. Normally, this would be done using whichever name service you use; for example, Google or Godaddy. For your test website, do this by adding a new name to the `localhost` line in `/etc/hosts`. Add the entries for both websites so you don't need to edit this file again later. The result looks like this: -``` -127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 www.site1.org www.site2.org - -``` - -Let’s also change the `/var/www/html/index.html` file to be a little more explicit. It should look like this (with some additional text to identify this as website number 1): -``` -

Hello World

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

Hello World -- Again

- - - -Web site 2. - -``` - -Create a new configuration stanza in `httpd.conf` for the second website and place it below the previous virtual host stanza (the two should look very similar). This stanza tells the web server where to find the HTML files for the second site. -``` - - -    DocumentRoot /var/www/html2 - -    ServerName www.site2.org - - - -``` - -Restart HTTPD again and use Lynx to view the results. -``` -[root@testvm1 httpd]# systemctl restart httpd - -[root@testvm1 httpd]# lynx www.site2.org - - - -                                    Hello World -- Again - - - -   Web site 2. - - - - - -Commands: Use arrow keys to move, '?' for help, 'q' to quit, '<-' to go back. - -Arrow keys: Up and Down to move.  Right to follow a link; Left to go back. - -H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list - -``` - -Here I have compressed the resulting output to fit this space. The difference in the page indicates that this is the second website. To show both websites at the same time, open another terminal session and use the Lynx web browser to view the other site. - -### Other considerations - -This simple example shows how to serve up two websites with a single instance of the Apache HTTPD server. Configuring the virtual hosts becomes a bit more complex when other factors are considered. - -For example, you may want to use some CGI scripts for one or both of these websites. To do this, you would create directories for the CGI programs in `/var/www`: `/var/www/cgi-bin` and `/var/www/cgi-bin2`, to be consistent with the HTML directory naming. You would then need to add configuration directives to the virtual host stanzas to specify the directory location for the CGI scripts. Each website could also have directories from which files could be downloaded; this would also require entries in the appropriate virtual host stanza. - -The [Apache website][2] describes other methods for managing multiple websites, as well as configuration options from performance tuning to security. - -Apache is a powerful web server that can be used to manage websites ranging from simple to highly complex. Although its overall share is shrinking, Apache remains the single most commonly used HTTPD server on the Internet. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/configuring-multiple-web-sites-apache - -作者:[David Both][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/dboth -[1]:https://opensource.com/article/18/2/how-configure-apache-web-server -[2]:https://httpd.apache.org/docs/2.4/ From e8f4795e2cc3d768e064023daf0bc4ef61b6c69b Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Wed, 17 Oct 2018 21:53:13 +0800 Subject: [PATCH 012/158] Create 20180329 How to configure multiple websites with Apache web server.md --- ...ultiple websites with Apache web server.md | 153 ++++++++++++++++++ 1 file changed, 153 insertions(+) create mode 100644 translated/tech/20180329 How to configure multiple websites with Apache web server.md diff --git a/translated/tech/20180329 How to configure multiple websites with Apache web server.md b/translated/tech/20180329 How to configure multiple websites with Apache web server.md new file mode 100644 index 0000000000..1b11518631 --- /dev/null +++ b/translated/tech/20180329 How to configure multiple websites with Apache web server.md @@ -0,0 +1,153 @@ +如何使用 Apache Web 服务器配置多个站点 + +===== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/apache-feathers.jpg?itok=fnrpsu3G) + +在我的[上一篇文章][1]中,我解释了如何为单个站点配置 Apache Web 服务器,事实证明这很容易。在这篇文章中,我将向你展示如何使用单个 Apache 实例来服务多个站点。 + +注意:我写这篇文章的环境是 Fedora 27 虚拟机,配置了 Apache 2.4.29。如果你有另一个 Fedora 的发行版,那么你使用的命令以及配置文件的位置和内容可能会有所不同。 + +正如我之前的文章中提到的,Apache 的所有配置文件都位于 `/etc/httpd/conf` 和 `/etc/httpd/conf.d`。默认情况下,站点的数据位于 `/var/www` 中。对于多个站点,你需要提供多个位置,每个位置对应托管的站点。 + +### 基于名称的虚拟主机 + +使用基于名称的虚拟主机,你可以为多个站点使用一个 IP 地址。现代 Web 服务器,包括 Apache,使用指定 URL 的 `hostname` 部分来确定哪个虚拟 Web 主机响应页面请求。这仅仅需要比一个站点更多的配置。 + +即使你只从单个站点开始,我也建议你将其设置为虚拟主机,这样可以在以后更轻松地添加更多站点。在本文中,我将在上一篇文章中介绍我们停止的位置,因此你需要设置原始站点,即基于名称的虚拟站点。 + +### 准备原始站点 + +在设置第二个站点之前,你需要为现有网站提供基于名称的虚拟主机。如果你现在没有网站,[请返回并立即创建一个][1]。 + +一旦你有了站点,将以下内容添加到 `/etc/httpd/conf/httpd.conf` 配置文件的底部(添加此内容是你需要对 `httpd.conf` 文件进行的唯一更改): +``` + + +    DocumentRoot /var/www/html + +    ServerName www.site1.org + + + +``` + +这将是第一个虚拟主机节(to 校正:这里虚拟主机节不太清除),它应该保持为第一个,以使其成为默认定义。这意味着通过 IP 地址或解析为此 IP 地址但没有特定命名主机配置节的其它名称对服务器的 HTTP 访问将定向到此虚拟主机。所有其它虚拟主机配置节都应遵循此节。 + +你还需要使用 `/etc/hosts` 中的条目设置你的网站以提供名称解析。上次,我们只使用了 `localhost` 的 IP 地址。通常,这可以使用你使用的任何名称服务来完成,例如 Google 或 Godaddy。对于你的测试网站,通过在 `/etc/hosts` 中的 `localhost` 行添加一个新名称来完成此操作。添加两个网站的条目,方便你以后不需再次编辑此文件。结果如下: +``` +127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 www.site1.org www.site2.org +``` + +让我们将 `/var/www/html/index.html` 文件改变得更加明显一点。它应该看起来像这样(带有一些额外的文本来识别这是站点 1): +``` +

Hello World

+ +Web site 1. + +``` + +重新启动 HTTPD 服务器,已启用对 `httpd` 配置的更改。然后,你可以从命令行使用 Lynx 文本模式查看网站。 +``` +[root@testvm1 ~]# systemctl restart httpd + +[root@testvm1 ~]# lynx www.site1.org + +                                              Hello World + +  Web site 1. + + + +Commands: Use arrow keys to move, '?' for help, 'q' to quit, '<-' to go back. + +Arrow keys: Up and Down to move.  Right to follow a link; Left to go back. + +H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list + +``` + +你可以看到原始网站的修改内容,没有明显的错误,先按下 "Q" 键,然后按 "Y" 退出 Lynx Web 浏览器。 + +### 配置第二个站点 + +现在你已经准备好建立第二个网站。使用以下命令创建新的网站目录结构: +``` +[root@testvm1 html]# mkdir -p /var/www/html2 + +``` + +注意,第二个站点只是第二个 `html` 目录,与第一个站点位于同一 `/var/www` 目录下。 + +现在创建一个新的索引文件 `/var/www/html2/index.html`,其中包含以下内容(此索引文件稍有不同,以区别于原始网站): +``` +

Hello World -- Again

+ +Web site 2. + +``` + +在 `httpd.conf` 中为第二个站点创建一个新的配置节,并将其放在上一个虚拟主机节下面(这两个应该看起来非常相似)。此节告诉 Web 服务器在哪里可以找到第二个站点的 HTML 文件。 +``` + + +    DocumentRoot /var/www/html2 + +    ServerName www.site2.org + + + +``` + +重启 HTTPD,并使用 Lynx 来查看结果。 +``` +[root@testvm1 httpd]# systemctl restart httpd + +[root@testvm1 httpd]# lynx www.site2.org + + + +                                    Hello World -- Again + + + +   Web site 2. + + + + + +Commands: Use arrow keys to move, '?' for help, 'q' to quit, '<-' to go back. + +Arrow keys: Up and Down to move.  Right to follow a link; Left to go back. + +H)elp O)ptions P)rint G)o M)ain screen Q)uit /=search [delete]=history list + +``` + +在这里,我压缩了输出结果以适应这个空间。页面的差异表明这是第二个站点。要同时显示两个站点,请打开另一个终端会话并使用 Lynx Web 浏览器查看另一个站点。 + +### 其他考虑 + +这个简单的例子展示了如何使用 Apache HTTPD 服务器的单个实例来服务于两个站点。当考虑其他因素时,配置虚拟主机会变得有点复杂。 + +例如,你可能希望为这些网站中的一个或全部使用一些 CGI 脚本。为此,你可能为 CGI 程序在 `/var/www` 目录下创建一些目录:`/var/www/cgi-bin` 和 `/var/www/cgi-bin2`,以与 HTML 目录命名一致。然后,你需要将配置指令添加到虚拟主机节,以指定 CGI 脚本的目录位置。每个站点可以有下载文件的目录。这还需要相应虚拟主机节中的条目。 + +[Apache 网站][2]描述了管理多个站点的其他方法,以及从性能调优到安全性的配置选项。 + +Apache 是一个强大的 Web 服务器,可以用来管理从简单到高度复杂的网站。尽管其总体市场份额在缩小,但它仍然是互联网上最常用的 HTTPD 服务器。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/configuring-multiple-web-sites-apache + +作者:[David Both][a] +译者:[MjSeven](https://github.com/MjSeven) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/dboth +[1]:https://opensource.com/article/18/2/how-configure-apache-web-server +[2]:https://httpd.apache.org/docs/2.4/ From fccfefe78ab3a47cf4d86c0fc49ca68cc4a6e1ee Mon Sep 17 00:00:00 2001 From: David Chen Date: Wed, 17 Oct 2018 21:58:22 +0800 Subject: [PATCH 013/158] Translated. --- sources/tech/20180823 CLI- improved.md | 165 +++++++------------------ 1 file changed, 48 insertions(+), 117 deletions(-) diff --git a/sources/tech/20180823 CLI- improved.md b/sources/tech/20180823 CLI- improved.md index 8fb3ea9100..6766f00275 100644 --- a/sources/tech/20180823 CLI- improved.md +++ b/sources/tech/20180823 CLI- improved.md @@ -1,52 +1,39 @@ -Translating by DavidChenLiang -CLI: improved -====== -命令行:增强 +命令行:增强版 ====== -我不确定有多少web 开发者能完全逃避使用命令行。就我来说,我从1997年上大学就开始使用命令行了,那时l33t-hacker 让我着迷,同时我觉得又很难掌握它。 +我不确定有多少Web 开发者能完全逃避使用命令行。就我来说,我从1997年上大学就开始使用命令行了,那时l33t-hacker 让我着迷,同时我也觉得它很难掌握。 -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 -### 怎么忽略我的增强 +### 怎么忽略我所做的命令行增强 -在一些情况下我会用别名将新的和增强的命令行工具链接到原来的命令行(如`cat`和`ping`)。 +通常情况下我会用别名将新的或者增强的命令行工具链接到原来的命令行(如`cat`和`ping`)。 -In a number of cases I've aliased the new and improved command line tool over the original (as with `cat` and `ping`). -如果我需要运行原来的命令的话,有时我确实需要这么做,我能像下面这样来做。(我用的是Mac 你的输出可能不一样) +如果我需要运行原来的命令的话(有时我确实需要这么做),我能像下面这样来运行未加修改的原来的命令行。(我用的是Mac, 你的输出可能不一样) -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 +$ \cat # 忽略叫 "cat" 的别名 - 具体解释: https://stackoverflow.com/a/16506263/22617 +$ command cat # 忽略函数和别名 ``` ### bat > cat -`cat`用于打印文件的内容,但是如果你在命令行上花了很多时间的话,例如语法高亮之类的功能会非常有用。我先发现了[ccat][3]这个有语法高亮功能的的工具, 然后我发现了[bat][4],它有语法高亮,分页,行号和git集成。 +`cat`用于打印文件的内容,如果你在命令行上要花很多时间的话,例如语法高亮之类的功能会非常有用。我首先发现了[ccat][3]这个有语法高亮功能的的工具,然后我发现了[bat][4],它的功能有语法高亮,分页,行号和git集成。 -`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. `bat`命令也能让我在输出里(只要输出比屏幕的高度长) 使用`/`关键字绑定来搜索(和用`less`搜索功能一样)。 -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] -我将别名`bat`链接到了`cat`命令: +我将别名`cat`链接到了`bat`命令: -I've also aliased `bat` to the `cat` command: ``` @@ -56,18 +43,15 @@ alias cat='bat' 💾 [Installation directions][4] -### prettyping > ping ### prettyping > ping -`ping`非常有用,当我碰到“糟了,是不是神马服务挂了/我的网不通了?”这种情况下我最先想到的工具就是他了。但是`prettyping`(“prettyping” 可不是指"pre typing")(译注:英文字面意思是'预打印')在`ping`上加上了友好的输出,这可让我感觉命令行友好了很多呢。 +`ping`非常有用,当我碰到“糟了,是不是什么服务挂了?/我的网不通了?”这种情况下我最先想到的工具就是它了。但是`prettyping`(“prettyping” 可不是指"pre typing")(译注:英文字面意思是'预打印')在`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] 我也将`ping`用别名链接到了`prettyping`命令: -I've also aliased `ping` to the `prettyping` command: ``` alias ping='prettyping --nolegend' @@ -78,25 +62,20 @@ alias ping='prettyping --nolegend' ### fzf > ctrl+r -在命令行上使用`ctrl+r`将允许你在命令历史里发现搜索使用过的命令,这是个挺好的小技巧,但是它需要你给出非常精确的输入才能正常运行。 +在命令行上使用`ctrl+r`将允许你在命令历史里[反向搜索][8]使用过的命令,这是个挺好的小技巧,但是它需要你给出非常精确的输入才能正常运行。 -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. +`fzf`这个工具相比于`ctrl+r`有了**巨大的**进步。它能针对命令行历史进行模糊查询,并且提供了对可能的合格结果进行全面交互式预览。 -`fzf`这个工具相比于`ctrl+r`有了**巨大的**进步。它能针对命令行历史进行模糊查询,并且提供了对可能合格的结果的全面交互式预览。 - -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. 除了搜索命令历史,`fzf`还能预览和打开文件,我在下面的视频里展示了这些功能。 -In addition to searching through the history, `fzf` can also preview and open files, which is what I've done in the video below: -对于预览的效果,我创建了一个叫`preview`的别名,它将`fzf`和前文提到的`bat`组合起来完成预览功能,还给上面绑定了一个定制的热键Ctrl+o来打开 VS Code +为了这个预览的效果,我创建了一个叫`preview`的别名,它将`fzf`和前文提到的`bat`组合起来完成预览功能,还给上面绑定了一个定制的热键Ctrl+o来打开 VS Code: -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 +# 支持在 VS Code 里用ctrl+o 来打开选择的文件 export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort'" ``` @@ -105,13 +84,11 @@ export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort'" ### htop > top -`top`是当我想快速诊断为什么机器上的CPU跑的那么累或者风扇为什么突然呼呼大做的时候首先会想到的工具。我在产品环境也会使用这个工具。讨厌的是Mac 上的`top`和 Linux 上的`top`有着极大的不同(包括其内部的 IMHO) +`top`是当我想快速诊断为什么机器上的CPU跑的那么累或者风扇为什么突然呼呼大做的时候首先会想到的工具。我在产品环境也会使用这个工具。讨厌的是Mac上的`top`和 Linux 上的`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. -不过,`htop`是对 Linux 上的`top`和 Mac 上蹩脚的`top`的极大改进。它增加了包括颜色输出编码,键盘热键绑定以及不同的视图,这极大的帮助了我来理解进程之间的父子关系。 +不过,`htop`是对 Linux 上的`top`和 Mac 上蹩脚的`top`的极大改进。它增加了包括颜色输出编码,键盘热键绑定以及不同的视图输出,这极大的帮助了我来理解进程之间的父子关系。 -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. 方便的热键绑定包括: @@ -120,39 +97,27 @@ However, `htop` is an improvement on both regular `top` and crappy-mac `top`. Lo * F4 - 用字符串过滤进程(例如只看包括"node"的进程) * space - 锚定一个单独进程,这样我能观察它是否有尖峰状态 -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] -在Mac Sieera 上htop 有个奇怪的bug,可以通过以root 运行来绕过(我实在记不清这个bug 是什么,但是这个别名能搞定它,有点讨厌的是我得每次都输入 root 密码。): +在Mac Sieera 上htop 有个奇怪的bug,不过可以通过以root 运行来绕过(我实在记不清这个bug 是什么,但是这个别名能搞定它,有点讨厌的是我得每次都输入 root 密码。): -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 - +alias top="sudo htop" # 给top加上别名并且绕过 Sieera 上的bug ``` 💾 [Installation directions][11] ### diff-so-fancy > diff -我非常确定我是一些年前从 Paul Irish 那儿学来的这个技巧,尽管我很少直接使用`diff`,我的git 命令行会一直使用`diff`。`diff-so-fancy`给了我代码颜色和更改字符高亮的功能。 +我非常确定我是一些年前从 Paul Irish 那儿学来的这个技巧,尽管我很少直接使用`diff`,但我的git命令行会一直使用`diff`。`diff-so-fancy`给了我代码颜色和更改字符高亮的功能。 -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] 在我的`~/.gitconfig`文件里我有下面的选项来打开`git diff`和`git show`的`diff-so-fancy`功能。 -Then in my `~/.gitconfig` I have included the following entry to enable `diff-so-fancy` on `git diff` and `git show`: ``` [pager] @@ -165,26 +130,22 @@ Then in my `~/.gitconfig` I have included the following entry to enable `diff-so ### fd > find -尽管我使用 Mac, 但我从来不是一个Spotlight的拥趸,我觉得他的功能很累赘,关键字也难记,更新它自己的数据库时会拖慢CPU,简直一无是处。我经常使用[Alfred][14],但是它额搜索功能也工作的不是很好。 +尽管我使用 Mac, 但我从来不是一个Spotlight的拥趸,我觉得它的性能很差,关键字也难记,加上更新它自己的数据库时会拖慢CPU,简直一无是处。我经常使用[Alfred][14],但是它的搜索功能也工作的不是很好。 -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. -我倾向于在命令行中搜索文件,但是`find`的难用在于很难去记住那些合适的表达式来描述我想要的文件。(而且 Mac 上的 find 命令和非 Mac 的 find 命令还有些许不同,这更加深了我的失望。) +我倾向于在命令行中搜索文件,但是`find`的难用在于很难去记住那些合适的表达式来描述我想要的文件。(而且 Mac 上的 find 命令和非Mac的find命令还有些许不同,这更加深了我的失望。) -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`是一个很好的替代品(它的作者和`bat`的作者是同一个人)。它非常快而且对于我经常要搜索的命令非常好记。 -`fd`是一个很好的替代品(它的作者和`bat`的作者是同一个人)。他非常快而且对于我经常要搜索的命令非常好记。 -`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 cli # 所有包含"cli"的文件名 +$ fd -e md # 所有以.md作为扩展名的文件 +$ fd cli -x wc -w # 搜索"cli"并且在每个搜索结果上运行`wc -w` + ``` @@ -196,37 +157,27 @@ $ fd cli -x wc -w # find "cli" and run `wc -w` on each file 对我来说,知道当前的磁盘空间使用是非常重要的任务。我用过 Mac 上的[Dish Daisy][17],但是我觉得那个程序产生结果有点慢。 -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. -`du -sh`命令是我经常会跑的命令(`-sh`是指结果以总结和人类可读的方式显示),不过我经常会想要深入挖掘那些占用了大量的目录。 +`du -sh`命令是我经常会跑的命令(`-sh`是指结果以总结和人类可读的方式显示),我经常会想要深入挖掘那些占用了大量磁盘空间的目录。 -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. - -`nudu`是一个非常棒的替代。它提供了一个交互式的界面并且允许快速的扫描那些占用了大量磁盘空间的目录和文件,它又快又准。(尽管不管在哪个工具的情况下,扫描我的home目录都要很长时间,它有550G) +`ncdu`是一个非常棒的替代品。它提供了一个交互式的界面并且允许快速的扫描那些占用了大量磁盘空间的目录和文件,它又快又准。(尽管不管在哪个工具的情况下,扫描我的home目录都要很长时间,它有550G) -`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). +一旦当我找到一个目录我想要“处理”一下(如删除,移动或压缩文件),我都会使用命令+点击屏幕[iTerm2][18]上部的目录名字来对那个目录执行搜索。 -一旦当我找到一个目录我想要`处理`一下(如删除,移动或压缩文件),我都会使用命令+点击屏幕[iTerm2][18]上部的目录名字来对那个目录执行搜索。 - -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] -还有另外一个选择[nnn][20],它提供了一个更漂亮的界面,尽管它也提供文件尺寸和使用情况,实际上它更像一个全功能的文件管理器。 +还有另外一个选择[一个叫nnn的另外选择][20],它提供了一个更漂亮的界面,它也提供文件尺寸和使用情况,实际上它更像一个全功能的文件管理器。 -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: - -我的`nudu`使用下面的别名链接: +我的`ncdu`使用下面的别名链接: ``` alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules" ``` -The options are: 选项有: @@ -235,30 +186,21 @@ The options are: * `--exclude` 忽略不想操作的目录 - * `--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 -几乎所有的单独命令行工具都有一个相伴的手册,其可以被`man 命令`来调出,但是在`man`的输出里找到东西可有点然人困惑,而且在一个包含了所有的技术细节的输出里找东西也挺可怕的。 +几乎所有的单独命令行工具都有一个相伴的手册,其可以被`man <命令名>`来调出,但是在`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. -这就是TL;DR(译注:英文里`文档太长,没空去读`的缩写)项目的初衷。这个一个由社区驱动的文档系统,它针对的是命令行。就我现在用下来,我还没碰到过一个命令它没有相应的文档,你[也可以做贡献][22]. +这就是TL;DR(译注:英文里`文档太长,没空去读`的缩写)项目的初衷。这个一个由社区驱动的文档系统,而且针对的是命令行。就我现在用下来,我还没碰到过一个命令它没有相应的文档,你[也可以做贡献][22]. -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] 作为一个小技巧,我将`tldr`的别名链接到`help`(这样输入会快一点。。。) -As a nicety, I've also aliased `tldr` to `help` (since it's quicker to type!): - ``` alias help='tldr' @@ -268,27 +210,22 @@ alias help='tldr' ### ack || ag > grep -`grep`毫无疑问是一个命令行上的强力工具,但是经过这些年它已经被一些工具超越了。其中两个叫`ack`和`ag`。 +`grep`毫无疑问是一个命令行上的强力工具,但是这些年来它已经被一些工具超越了。其中两个叫`ack`和`ag`。 -`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`. -我个人来说`ack`和`ag`都尝试过,并没有非常明显的个人偏好,(那也就是说他们都很棒,并且很相似)。我倾向于默认只使用`ack`,因为这三个字符就在指尖,很好打。并且,`ack`有大量的`ack --bar`参数可以使用,(你一定会体会到这一点。) +就我个人来说`ack`和`ag`都尝试过,并没有非常明显的个人偏好,(那也就是说他们都很棒,并且很相似)。我倾向于默认只使用`ack`,因为这三个字符就在指尖,很好打。并且,`ack`有大量的`ack --`参数可以使用,(你一定会体会到这一点。) -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)! -`ack`和`ag`都将使用正则表达式来表达搜索,并且对我的工作有关,我能指定搜索的文件类型而不用使用类似于`--js`或`--html`的文件标识(尽管`ag`比`ack`在文件类型过滤器里包括了更多的文件类型。) +`ack`和`ag`都将使用正则表达式来表达搜索,这非常契合我的工作,我能指定搜索的文件类型而不用使用类似于`--js`或`--html`的文件标识(尽管`ag`比`ack`在文件类型过滤器里包括了更多的文件类型。) -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`). 两个工具都支持常见的`grep`选项,如`-B`和`-A`用于在搜索的上下文里指代`之前`和`之后`。 -Both tools also support the usual `grep` options, like `-B` and `-A` for before and after context in the grep. ![ack in action][25] 因为`ack`不支持markdown(而我又恰好写了很多markdown), 我在我的`~/.ackrc`文件里放了如下的定制语句: -Since `ack` doesn't come with markdown support (and I write a lot in markdown), I've got this customisation in my `~/.ackrc` file: ``` @@ -303,17 +240,13 @@ Since `ack` doesn't come with markdown support (and I write a lot in markdown), ### jq > grep et al -我是[jq][29]的粉丝之一。当然一开始我也在它的语法里苦苦挣扎,还好我对查询语言还算有些使用心得,现在我对`jq`可以说是每天都要用。(不过从前我要么使用grep 或者使用一个叫[json][30]的工具,相比而言后者非常基础了。) +我是[jq][29]的粉丝之一。当然一开始我也在它的语法里苦苦挣扎,好在我对查询语言还算有些使用心得,现在我对`jq`可以说是每天都要用。(不过从前我要么使用grep 或者使用一个叫[json][30]的工具,相比而言后者的功能就非常基础了。) -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). -我甚至开始撰写一个`jq`的说明系列(有2500字并且还在增加),我还发布了一个[web tool][31]和一个Mac 上的应用(这个还没有发布。) +我甚至开始撰写一个`jq`的教程系列(有2500字并且还在增加),我还发布了一个[web tool][31]和一个Mac 上的应用(这个还没有发布。) -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`允许我传入一个 JSON 并且能非常简单的转变其为一个 JSON格式的适合我要求的结果。下面这个例子允许我用一个命令更新我的所有节点依赖(为了便于于都,我将其分成为多行。) - -`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): +`jq`允许我传入一个 JSON 并且能非常简单的将其转变为一个 使用JSON格式的结果,这正是我想要的。下面这个例子允许我用一个命令更新我的所有节点依赖(为了阅读方便,我将其分成为多行。) ``` @@ -323,8 +256,9 @@ $ npm i $(echo $(\ )) ``` +上面的命令将使用npm 的 JSON 输出格式来列出所有的过期节点依赖,然后将下面的源JSON转换为: + -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": { @@ -343,16 +277,15 @@ The above command will list all the node dependencies that are out of date, and ``` -…to this: +转换结果为:(译注:原文此处并未给出结果) + +上面的结果会被作为`npm install`的输入,你瞧,我的升级就这样全部搞定了。(当然,这里有点小题大做了。) -That result is then fed into the `npm install` command and voilà, I'm all upgraded (using the sledgehammer approach). -### Honourable mentions ### 很荣幸提及一些其他的工具 -我也在开始尝试一些别的工具,但我还没有完全掌握他们。(出了`ponysay`,当我新启动一个命令行会话时,它就会出现。) +我也在开始尝试一些别的工具,但我还没有完全掌握他们。(除了`ponysay`,当我新启动一个命令行会话时,它就会出现。) -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 @@ -361,12 +294,10 @@ Some of the other tools that I've started poking around with, but haven't used t -### What about you? ### 你有什么好点子吗? -上面是我的命令行清单。能告诉我们你的吗?你有没有增强一些你每天都会用到的命令呢?我非常乐意知道。 +上面是我的命令行清单。能告诉我们你的吗?你有没有试着去增强一些你每天都会用到的命令呢?请告诉我,我非常乐意知道。 -So that's my list. How about you? What daily command line tools have you improved? I'd love to know. -------------------------------------------------------------------------------- From 1e9ae6eb520f2def06e1ba67db8f8df0844d5793 Mon Sep 17 00:00:00 2001 From: David Chen Date: Wed, 17 Oct 2018 22:00:09 +0800 Subject: [PATCH 014/158] Translated. --- sources/tech/20180823 CLI- improved.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180823 CLI- improved.md b/sources/tech/20180823 CLI- improved.md index 6766f00275..b3056e6146 100644 --- a/sources/tech/20180823 CLI- improved.md +++ b/sources/tech/20180823 CLI- improved.md @@ -296,6 +296,7 @@ $ npm i $(echo $(\ ### 你有什么好点子吗? + 上面是我的命令行清单。能告诉我们你的吗?你有没有试着去增强一些你每天都会用到的命令呢?请告诉我,我非常乐意知道。 From 348f0f3ce3a02c485483fafdd73ebf022dd4a45c Mon Sep 17 00:00:00 2001 From: dianbanjiu Date: Wed, 17 Oct 2018 22:40:16 +0800 Subject: [PATCH 015/158] dianbanjiu translated --- ...005 Open Source Logging Tools for Linux.md | 189 ------------------ ...005 Open Source Logging Tools for Linux.md | 187 +++++++++++++++++ 2 files changed, 187 insertions(+), 189 deletions(-) delete mode 100644 sources/tech/20181005 Open Source Logging Tools for Linux.md create mode 100644 translated/tech/20181005 Open Source Logging Tools for Linux.md diff --git a/sources/tech/20181005 Open Source Logging Tools for Linux.md b/sources/tech/20181005 Open Source Logging Tools for Linux.md deleted file mode 100644 index f65309f9cf..0000000000 --- a/sources/tech/20181005 Open Source Logging Tools for Linux.md +++ /dev/null @@ -1,189 +0,0 @@ -translating by dianbanjiu -Open Source Logging Tools for Linux -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs-main.jpg?itok=voNrSz4H) - -If you’re a Linux systems administrator, one of the first tools you will turn to for troubleshooting are log files. These files hold crucial information that can go a long way to help you solve problems affecting your desktops and servers. For many sysadmins (especially those of an old-school sort), nothing beats the command line for checking log files. But for those who’d rather have a more efficient (and possibly modern) approach to troubleshooting, there are plenty of options. - -In this article, I’ll highlight a few such tools available for the Linux platform. I won’t be getting into logging tools that might be specific to a certain service (such as Kubernetes or Apache), and instead will focus on tools that work to mine the depths of all that magical information written into /var/log. - -Speaking of which… - -### What is /var/log? - -If you’re new to Linux, you might not know what the /var/log directory contains. However, the name is very telling. Within this directory is housed all of the log files from the system and any major service (such as Apache, MySQL, MariaDB, etc.) installed on the operating system. Open a terminal window and issue the command cd /var/log. Follow that with the command ls and you’ll see all of the various systems that have log files you can view (Figure 1). - -![/var/log/][2] - -Figure 1: Our ls command reveals the logs available in /var/log/. - -[Used with permission][3] - -Say, for instance, you want to view the syslog log file. Issue the command less syslog and you can scroll through all of the gory details of that particular log. But what if the standard terminal isn’t for you? What options do you have? Plenty. Let’s take a look at few such options. - -### Logs - -If you use the GNOME desktop (or other, as Logs can be installed on more than just GNOME), you have at your fingertips a log viewer that mainly just adds the slightest bit of GUI goodness over the log files to create something as simple as it is effective. Once installed (from the standard repositories), open Logs from the desktop menu, and you’ll be treated to an interface (Figure 2) that allows you to select from various types of logs (Important, All, System, Security, and Hardware), as well as select a boot period (from the top center drop-down), and even search through all of the available logs. - -![Logs tool][5] - -Figure 2: The GNOME Logs tool is one of the easiest GUI log viewers you’ll find for Linux. - -[Used with permission][3] - -Logs is a great tool, especially if you’re not looking for too many bells and whistles getting in the way of you viewing crucial log entries, so you can troubleshoot your systems. - -### KSystemLog - -KSystemLog is to KDE what Logs is to GNOME, but with a few more features to add into the mix. Although both make it incredibly simple to view your system log files, only KSystemLog includes colorized log lines, tabbed viewing, copy log lines to the desktop clipboard, built-in capability for sending log messages directly to the system, read detailed information for each log line, and more. KSystemLog views all the same logs found in GNOME Logs, only with a different layout. - -From the main window (Figure 3), you can view any of the different log (from System Log, Authentication Log, X.org Log, Journald Log), search the logs, filter by Date, Host, Process, Message, and select log priorities. - -![KSystemLog][7] - -Figure 3: The KSystemLog main window. - -[Used with permission][3] - -If you click on the Window menu, you can open a new tab, where you can select a different log/filter combination to view. From that same menu, you can even duplicate the current tab. If you want to manually add a log to a file, do the following: - - 1. Open KSystemLog. - - 2. Click File > Add Log Entry. - - 3. Create your log entry (Figure 4). - - 4. Click OK - - -![log entry][9] - -Figure 4: Creating a manual log entry with KSystemLog. - -[Used with permission][3] - -KSystemLog makes viewing logs in KDE an incredibly easy task. - -### Logwatch - -Logwatch isn’t a fancy GUI tool. Instead, logwatch allows you to set up a logging system that will email you important alerts. You can have those alerts emailed via an SMTP server or you can simply view them on the local machine. Logwatch can be found in the standard repositories for almost every distribution, so installation can be done with a single command, like so: - -``` -sudo apt-get install logwatch -``` - -Or: - -``` -sudo dnf install logwatch -``` - -During the installation, you will be required to select the delivery method for alerts (Figure 5). If you opt to go the local mail delivery only, you’ll need to install the mailutils app (so you can view mail locally, via the mail command). - -![ Logwatch][11] - -Figure 5: Configuring Logwatch alert sending method. - -[Used with permission][3] - -All Logwatch configurations are handled in a single file. To edit that file, issue the command sudo nano /usr/share/logwatch/default.conf/logwatch.conf. You’ll want to edit the MailTo = option. If you’re viewing this locally, set that to the Linux username you want the logs sent to (such as MailTo = jack). If you are sending these logs to an external email address, you’ll also need to change the MailFrom = option to a legitimate email address. From within that same configuration file, you can also set the detail level and the range of logs to send. Save and close that file. -Once configured, you can send your first mail with a command like: - -``` -logwatch --detail Med --mailto ADDRESS --service all --range today -Where ADDRESS is either the local user or an email address. - -``` - -For more information on using Logwatch, issue the command man logwatch. Read through the manual page to see the different options that can be used with the tool. - -### Rsyslog - -Rsyslog is a convenient way to send remote client logs to a centralized server. Say you have one Linux server you want to use to collect the logs from other Linux servers in your data center. With Rsyslog, this is easily done. Rsyslog has to be installed on all clients and the centralized server (by issuing a command like sudo apt-get install rsyslog). Once installed, create the /etc/rsyslog.d/server.conf file on the centralized server, with the contents: - -``` -# Provide UDP syslog reception -$ModLoad imudp -$UDPServerRun 514 - -# Provide TCP syslog reception -$ModLoad imtcp -$InputTCPServerRun 514 - -# Use custom filenaming scheme -$template FILENAME,"/var/log/remote/%HOSTNAME%.log" -*.* ?FILENAME - -$PreserveFQDN on - -``` - -Save and close that file. Now, on every client machine, create the file /etc/rsyslog.d/client.conf with the contents: - -``` -$PreserveFQDN on -$ActionQueueType LinkedList -$ActionQueueFileName srvrfwd -$ActionResumeRetryCount -1 -$ActionQueueSaveOnShutdown on -*.* @@SERVER_IP:514 - -``` - -Where SERVER_IP is the IP address of your centralized server. Save and close that file. Restart rsyslog on all machines with the command: - -``` -sudo systemctl restart rsyslog - -``` - -You can now view the centralized log files with the command (run on the centralized server): - -``` -tail -f /var/log/remote/*.log - -``` - -The tail command allows you to view those files as they are written to, in real time. You should see log entries appear that include the client hostname (Figure 6). - -![Rsyslog][13] - -Figure 6: Rsyslog showing entries for a connected client. - -[Used with permission][3] - -Rsyslog is a great tool for creating a single point of entry for viewing the logs of all of your Linux servers. - -### More where that came from - -This article only scratched the surface of the logging tools to be found on the Linux platform. And each of the above tools is capable of more than what is outlined here. However, this overview should give you a place to start your long day's journey into the Linux log file. - -Learn more about Linux through the free ["Introduction to Linux" ][14]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2018/10/open-source-logging-tools-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]: /files/images/logs1jpg -[2]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_1.jpg?itok=8yO2q1rW (/var/log/) -[3]: /licenses/category/used-permission -[4]: /files/images/logs2jpg -[5]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_2.jpg?itok=kF6V46ZB (Logs tool) -[6]: /files/images/logs3jpg -[7]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_3.jpg?itok=PhrIzI1N (KSystemLog) -[8]: /files/images/logs4jpg -[9]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_4.jpg?itok=OxsGJ-TJ (log entry) -[10]: /files/images/logs5jpg -[11]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_5.jpg?itok=GeAR551e (Logwatch) -[12]: /files/images/logs6jpg -[13]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_6.jpg?itok=ira8UZOr (Rsyslog) -[14]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/translated/tech/20181005 Open Source Logging Tools for Linux.md b/translated/tech/20181005 Open Source Logging Tools for Linux.md new file mode 100644 index 0000000000..9c5e594a2f --- /dev/null +++ b/translated/tech/20181005 Open Source Logging Tools for Linux.md @@ -0,0 +1,187 @@ +Linux 上的开源日志工具 +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs-main.jpg?itok=voNrSz4H) + +如果你是一位 Linux 系统管理员,你进行故障排除的第一个工具就是日志文件。这些文件会保留关键的信息,可以在很长一段时间内帮你去解决影响你桌面和服务器的问题。对于许多系统管理员(特别是对于老手),在命令行上没有什么比检查日志文件更好的方式了。但是对于那些想要更高效(也可能是更现代)的排除故障的人,这里也有许多的选择。 + +在这篇文章中,我将会罗列一些在 Linux 平台上一些值得一用的工具。一些特定于某项服务(例如 Kubernetes 或者 Apache)的日志工具将不会出现在该清单中,取而代之的将会是那些能够挖掘写入 /var/log 的所有神奇信息深度的工具。 + + +### 什么是 /var/log? + +如果你是刚开始使用 Linux ,你可能不知道 /var/log 目录都包含了些什么。然而,这个名字已经说明了一切。这个目录收容了所有系统以及安装在系统上的主要服务(如 Apache,MySQL,MariaDB 等)的日志信息。打开一个终端窗口键入 ``` cd /var/log ``` 命令,接着键入 ```ls``` 命令,您将看到所有可以查看的日志文件。(图 1) + +![/var/log/][2] + +图 1:```ls``` 命令显示在 /var/log 下可用的日志。 + +[经许可使用][3] + +如果你想查看 syslog 日志文件。运行 ```less syslog``` 命令,你就可以滚动查看特定日志的所有细节。但是如果标准的终端不适合你?你还有什么选择呢?其实有很多。让我们来看看以下几个选择。 + +### Logs + +如果你使用 Gnome 桌面(或是其他的桌面,Logs 不仅能安装在 Gnome),你就已经有了这样的一个工具了,它仅仅在日志文件上加上了一个轻量的图形化界面,却使得查看日志的过程更加简单和高效。(从标准库中)安装完成后,从桌面菜单中打开 Logs,然后你将看到一个(图 2 的)界面,在这里允许你从各种类型的日志中进行选择(重要、所有、系统、安全和硬件),也可以选择一个启动时段 (从顶部中间的下拉菜单中),甚至是从所有可用的日志中进行搜索。 + +![Logs tool][5] + +图 2:Gnome 日志工具是你可以找到的为 Linux 最简易的日志图形化软件之一。 + +[经许可使用][3] + +Logs 是一个非常好的工具,特别是如果你不想要太多花里胡哨,妨碍你查看日志的功能,Logs 对于你查看系统日志来说就是一个很好的工具。 + +### KSystemLog + +KSystemLog 是 KDE 的,Logs 是 GNOME 的,但是有许多功能都融合到了里面。尽管两者都使得查看系统的日志文件变得非常简单,但只有 KsystemLog 有彩色的日志行、分页查看、复制日志行到桌面剪贴板、内置直接发送日志信息到系统的功能、详细阅读每行日志的信息、以及更多。KSystemLog 查看的所有日志都可以从 Gnome 的 Logs 中找到,只是各有不同的格式。 + +从主窗口上(图 3),你可以看到许多不同的日志(来自于系统日志,认证日志,X.org 日志,Journald 日志),通过日期、拥有者、进程、信息选择一个日志优先级可以过滤日志。 + +![KSystemLog][7] + +图 3:KSystemLog 主界面 + +[经许可使用][3] + +如果你点击窗口菜单,你可以打开一个新的标签,你可以在里面选择一个不同的日志/筛选组合去查看。在同一个标签中,你甚至可以复制当前标签。你可以通过以下操作,手动添加一个日志到一个文件中。 + + 1. 打开 KSystemLog。 + + 2. 点击文件的标签 > 添加日志入口 + + 3. 创建你的日志入口(图 4)。 + + 4. 点击 OK。 + + + +![log entry][9] + +图 4:使用 KystemLog 创建一个手册日志 + +[经许可使用][3] + +KsystemLogs 使得在 KDE 下查看日志变为一个非常简单的操作。 + +### Logwatch + +Logwatch 不是一个花俏的图形化工具。相反,Logwatch 允许你设置一个日志记录系统 e-mail 给你重要的警告。你可以通过一个 SMTP 服务 e-mail 这些重要通知,或者你可以只是在本地机器上查看。你可以在几乎所有发行版的标准库中找到 Logwatch,所以可以使用一个简单的命令完成安装: + +``` +sudo apt-get install logwatch +``` + +或者: + +``` +sudo dnf install logwatch +``` + +在安装期间,你需要选择一个发送警告的方式(图 5)。如果你选择仅以本地邮件的方式发达,你需要安装 mailutils(这样你就能通过 ```mail``` 命令查看本地邮件)。 + +![ Logwatch][11] + +图 5:配置 Logwatch 警告发送方式 + +[经许可使用][3] + +所有的 Logwatch 配置文件都被放在一个文件中。可以使用 ``` sudo nano /usr/share/logwatch/default.conf/logwatch.conf``` 命令编辑该文件。你可能想要编辑 MailTo = 选项。如果你是在本地查看日志,设置这项为你想要为你想要接收日志的 Linux 用户名(例如 MailTo = jack)。如果你想要发送这些日志到一个外部的邮件地址,你需要修改 MailTo = 为一个正确的邮件地址。在同一个配置文件中你还可以设置日志的细节层级和发送范围。保存并关闭该文件。设置成功后,你就可以使用以下命令发送你的第一封邮件: + +``` +logwatch --detail Med --mailto ADDRESS --service all --range today +Where ADDRESS is either the local user or an email address. + +``` + +使用 ```man logwatch``` 可以查看更多有关使用 Logwatch 的信息。通过阅读手册页可以看到这个工具的不同选项。 + +### Rsyslog + +Rsyslog 是一个发送远程客户端的日志到集群服务的简便方式。你只有一台服务器,但你想收集在你数据中心的其他 Linux 服务的日志。有了 Rsyslog,这可以很方便的实现。Rsyslog 必须被安装在所有的客户端和集群服务上(通过运行```sudo apt-get install rsyslog```)。 安装完成后,在集群服务上创建 /etc/rsyslog.d/server.conf 文件,包含以下内容: + +``` +# Provide UDP syslog reception +$ModLoad imudp +$UDPServerRun 514 + +# Provide TCP syslog reception +$ModLoad imtcp +$InputTCPServerRun 514 + +# Use custom filenaming scheme +$template FILENAME,"/var/log/remote/%HOSTNAME%.log" +*.* ?FILENAME + +$PreserveFQDN on + +``` + +保存并退出这个文件。现在,在任意一台客户端机器上,创建这个文件 /etc/rsyslog.d/client.conf,包含以下内容: + +``` +$PreserveFQDN on +$ActionQueueType LinkedList +$ActionQueueFileName srvrfwd +$ActionResumeRetryCount -1 +$ActionQueueSaveOnShutdown on +*.* @@SERVER_IP:514 + +``` + +SERVER_IP 处是你的集群服务的 IP 地址。保存并关闭该文件。使用以下命令在所有机器上重启 rsyslog。 + +``` +sudo systemctl restart rsyslog + +``` + +你现在可以使用以下命令(运行在集群服务器上)查看集群日志文件。 + +``` +tail -f /var/log/remote/*.log + +``` + +```tail``` 命令允许你实时查看写入这些文件中的内容。你应该可以看到包含主机名的日志条目(图 6)。 + +![Rsyslog][13] + +图 6:Rsyslog 为一个已连接的客户端显示条目。 + +[经许可使用][3] + +如果你想要为你的 Linux 服务器上的所有用户,创建单一的日志查看入口点, Rsyslog 是一个非常好的工具。 + +### 了解更多 + +这篇文章仅仅搜集了为 Linux 平台创建的日志记录工具的一点皮毛。上述每个工具都能够比此处概述的内容做到更多。这篇梗概应该会对你开始你漫长的日志记录历程有一点帮助。 + +你可以从 Linux 基金会和 edx 的免费课程 ["Introduction to Linux" ][14]了解更多。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2018/10/open-source-logging-tools-linux + +作者:[JACK WALLEN][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[dianbanjiu](https://github.com/dianbanjiu) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/jlwallen +[1]: /files/images/logs1jpg +[2]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_1.jpg?itok=8yO2q1rW (/var/log/) +[3]: /licenses/category/used-permission +[4]: /files/images/logs2jpg +[5]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_2.jpg?itok=kF6V46ZB (Logs tool) +[6]: /files/images/logs3jpg +[7]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_3.jpg?itok=PhrIzI1N (KSystemLog) +[8]: /files/images/logs4jpg +[9]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_4.jpg?itok=OxsGJ-TJ (log entry) +[10]: /files/images/logs5jpg +[11]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_5.jpg?itok=GeAR551e (Logwatch) +[12]: /files/images/logs6jpg +[13]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/logs_6.jpg?itok=ira8UZOr (Rsyslog) +[14]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From 7695ee521b8620ca72c0db6b051f4dde4bec9a66 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 17 Oct 2018 23:20:30 +0800 Subject: [PATCH 016/158] PRF:20180919 Host your own cloud with Raspberry Pi NAS.md @jrglinux --- ...st your own cloud with Raspberry Pi NAS.md | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) 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 index 312fed7c4c..462a42ab16 100644 --- 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 @@ -1,9 +1,13 @@ -Part-III 树莓派自建 NAS 云盘之云盘构建 +树莓派自建 NAS 云盘之——云盘构建 ====== -用树莓派 NAS 云盘来保护数据的安全! +> 用自行托管的树莓派 NAS 云盘来保护数据的安全! -在前面两篇文章中(译注:文章链接 [Part-I][1],[Part-II][2]),我们讨论了用树莓派搭建一个 NAS(network-attached storage) 所需要的一些 [软硬件环境及其操作步骤][1]。我们还制定了适当的 [备份策略][2] 来保护NAS上的数据。本文中,我们将介绍讨论利用 [Nestcloud][3] 来方便快捷的存储、获取以及分享你的数据。 +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life_tree_clouds.png?itok=b_ftihhP) + +在前面两篇文章中,我们讨论了用树莓派搭建一个 NAS 云盘所需要的一些 [软硬件环境及其操作步骤][1]。我们还制定了适当的 [备份策略][2] 来保护 NAS 上的数据。本文中,我们将介绍讨论利用 [Nestcloud][3] 来方便快捷的存储、获取以及分享你的数据。 + +![](https://opensource.com/sites/default/files/uploads/nas_part3.png) ### 必要的准备工作 @@ -13,13 +17,13 @@ Part-III 树莓派自建 NAS 云盘之云盘构建 ### 安装 Nextcloud -为了在树莓派(参考 [Part-I][1] 中步骤设置)中运行 Nextcloud,首先用命令 **apt** 安装 以下的一些依赖软件包。 +为了在树莓派(参考 [第一篇][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,以确保每晚自动备份数据。 +其次,下载 Nextcloud。在树莓派中利用 `wget` 下载其 [最新的版本][5]。在 [第一篇][1] 文章中,我们将两个磁盘驱动器连接到树莓派,一个用于存储当前数据,另一个用于备份。这里在数据存储盘上安装 Nextcloud,以确保每晚自动备份数据。 ``` sudo mkdir -p /nas/data/nextcloud @@ -37,27 +41,27 @@ sudo chown -R www-data:www-data /nas/data/nextcloud 如上所述,Nextcloud 安装完毕。之前安装依赖软件包时就已经安装了 MySQL 数据库来存储 Nextcloud 的一些重要数据(例如,那些你创建的可以访问 Nextcloud 的用户的信息)。如果你更愿意使用 Pstgres 数据库,则上面的依赖软件包需要做一些调整。 -以 root 权限启动 MySQL: +以 root 权限启动 MySQL: ``` sudo mysql ``` -这将会打开 SQL 提示符界面,在那里可以插入如下指令--使用数据库连接密码替换其中的占位符--为 Nextcloud 创建一个数据库。 +这将会打开 SQL 提示符界面,在那里可以插入如下指令——使用数据库连接密码替换其中的占位符——为 Nextcloud 创建一个数据库。 ``` -CREATE USER nextcloud IDENTIFIED BY ''; +CREATE USER nextcloud IDENTIFIED BY '<这里插入密码>'; CREATE DATABASE nextcloud; GRANT ALL ON nextcloud.* TO nextcloud; ``` -按 **Ctrl+D** 或输入 **quit** 退出 SQL 提示符界面。 +按 `Ctrl+D` 或输入 `quit` 退出 SQL 提示符界面。 ### Web 服务器配置 Nextcloud 可以配置以适配于 Nginx 服务器或者其他 Web 服务器运行的环境。但本文中,我决定在我的树莓派 NAS 中运行 Apache 服务器(如果你有其他效果更好的服务器选择方案,不妨也跟我分享一下)。 -首先为你的 Nextcloud 域名创建一个虚拟主机,创建配置文件 **/etc/apache2/sites-available/001-netxcloud.conf**,在其中输入下面的参数内容。修改其中 ServerName 为你的域名。 +首先为你的 Nextcloud 域名创建一个虚拟主机,创建配置文件 `/etc/apache2/sites-available/001-netxcloud.conf`,在其中输入下面的参数内容。修改其中 `ServerName` 为你的域名。 ``` @@ -78,13 +82,13 @@ 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 端口转发。 +现在,你应该可以通过浏览器中输入域名访问到 web 服务器了。这里我推荐使用 HTTPS 协议而不是 HTTP 协议来访问 Nextcloud。一个简单而且免费的方法就是利用 [Certbot][7] 下载 [Let's Encrypt][6] 证书,然后设置定时任务自动刷新。这样就避免了自签证书等的麻烦。参考 [如何在树莓派中安装][8] Certbot 。在配置 Certbot 的时候,你甚至可以配置将 HTTP 自动转到 HTTPS ,例如访问 `http://nextcloud.pi-nas.com` 自动跳转到 `https://nextcloud.pi-nas.com`。注意,如果你的树莓派 NAS 运行在家庭路由器的下面,别忘了设置路由器的 443 端口和 80 端口转发。 ### 配置 Nextcloud -最后一步,通过浏览器访问 Nextcloud 来配置它。在浏览器中输入域名地址,插入上文中的数据库设置信息。这里,你可以创建 Nextcloud 管理员用户。默认情况下,数据保存目录在在 Nextcloud 目录下,所以你也无需修改我们在 [Part-II][2] 一文中设置的备份策略。 +最后一步,通过浏览器访问 Nextcloud 来配置它。在浏览器中输入域名地址,插入上文中的数据库设置信息。这里,你可以创建 Nextcloud 管理员用户。默认情况下,数据保存目录在在 Nextcloud 目录下,所以你也无需修改我们在 [第二篇][2] 一文中设置的备份策略。 -然后,页面会跳转到 Nextcloud 登陆界面,用刚才创建的管理员用户登陆。在设置页面中会有基础操作教程和安全安装教程(这里是访问 settings/admin)。 +然后,页面会跳转到 Nextcloud 登陆界面,用刚才创建的管理员用户登陆。在设置页面中会有基础操作教程和安全安装教程(这里是访问 `https://nextcloud.pi-nas.com/settings/admin`)。 恭喜你,到此为止,你已经成功在树莓派中安装了你自己的云 Nextcloud。去 Nextcloud 主页 [下载 Nextcloud 客户端][9],客户端可以同步数据并且离线访问服务器。移动端甚至可以上传图片等资源,然后电脑桌面都可以去访问它们。 @@ -95,13 +99,13 @@ 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) +校对:[wxy](https://github.com/wxy) 本文由 [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 +[1]: https://linux.cn/article-10104-1.html?utm_source=index&utm_medium=more +[2]: https://linux.cn/article-10112-1.html [3]: https://nextcloud.com/ [4]: https://sourceforge.net/p/ddclient/wiki/Home/ [5]: https://nextcloud.com/install/#instructions-server From 4c04de58685739a063a8ebf082add7bf42d2f921 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 17 Oct 2018 23:20:49 +0800 Subject: [PATCH 017/158] PUB:20180919 Host your own cloud with Raspberry Pi NAS.md @jrglinux https://linux.cn/article-10126-1.html --- .../20180919 Host your own cloud with Raspberry Pi NAS.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180919 Host your own cloud with Raspberry Pi NAS.md (100%) diff --git a/translated/tech/20180919 Host your own cloud with Raspberry Pi NAS.md b/published/20180919 Host your own cloud with Raspberry Pi NAS.md similarity index 100% rename from translated/tech/20180919 Host your own cloud with Raspberry Pi NAS.md rename to published/20180919 Host your own cloud with Raspberry Pi NAS.md From d5dd4741c496fb49124141e41988a26078a6b74a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 18 Oct 2018 00:05:41 +0800 Subject: [PATCH 018/158] PRF:20180926 3 open source distributed tracing tools.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @belitex 翻译的很好。另外,虽然目前业界并未对 trace 和 span 做翻译定名,不过我斟酌还是做了个初步的翻译定名。 --- ...3 open source distributed tracing tools.md | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/translated/tech/20180926 3 open source distributed tracing tools.md b/translated/tech/20180926 3 open source distributed tracing tools.md index 773ff3f940..edcc487e15 100644 --- a/translated/tech/20180926 3 open source distributed tracing tools.md +++ b/translated/tech/20180926 3 open source distributed tracing tools.md @@ -1,35 +1,35 @@ 三个开源的分布式追踪工具 ====== -这几个工具对复杂软件系统中的实时事件做了可视化,能帮助你快速发现性能问题。 +> 这几个工具对复杂软件系统中的实时事件做了可视化,能帮助你快速发现性能问题。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/server_data_system_admin.png?itok=q6HCfNQ8) -分布式追踪系统能够从头到尾地追踪分布式系统中的请求,跨越多个应用、服务、数据库以及像代理这样的中间件。它能帮助你更深入地理解系统中到底发生了什么。追踪系统以图形化的方式,展示出每个已知步骤以及某个请求在每个步骤上的耗时。 +分布式追踪系统能够从头到尾地追踪跨越了多个应用、服务、数据库以及像代理这样的中间件的分布式软件的请求。它能帮助你更深入地理解系统中到底发生了什么。追踪系统以图形化的方式,展示出每个已知步骤以及某个请求在每个步骤上的耗时。 -用户可以通过这些展示来判断系统的哪个环节有延迟或阻塞,当请求失败时,运维和开发人员可以看到准确的问题源头,而不需要去测试整个系统,比如用二叉查找树的方法去定位问题。在开发迭代的过程中,追踪系统还能够展示出可能引起性能变化的环节。通过异常行为的警告自动地感知到性能在退化,总是比客户告诉你要好。 +用户可以通过这些展示来判断系统的哪个环节有延迟或阻塞,当请求失败时,运维和开发人员可以看到准确的问题源头,而不需要去测试整个系统,比如用二叉查找树的方法去定位问题。在开发迭代的过程中,追踪系统还能够展示出可能引起性能变化的环节。通过异常行为的警告自动地感知到性能的退化,总是比客户告诉你要好。 -追踪是怎么工作的呢?给每个请求分配一个特殊 ID,这个 ID 通常会插入到请求头部中。它唯一标识了对应的事务。一般把事务叫做 trace,trace 是抽象整个事务的概念。每一个 trace 由 span 组成,span 代表着一次请求中真正执行的操作,比如一次服务调用,一次数据库请求等。每一个 span 也有自己唯一的 ID。span 之下也可以创建子 span,子 span 可以有多个父 span。 +这种追踪是怎么工作的呢?给每个请求分配一个特殊 ID,这个 ID 通常会插入到请求头部中。它唯一标识了对应的事务。一般把事务叫做踪迹trace,“踪迹”是整个事务的抽象概念。每一个“踪迹”由单元span组成,“单元”代表着一次请求中真正执行的操作,比如一次服务调用,一次数据库请求等。每一个“单元”也有自己唯一的 ID。“单元”之下也可以创建子“单元”,子“单元”可以有多个父“单元”。 -当一次事务(或者说 trace)运行过之后,就可以在追踪系统的表示层上搜索了。有几个工具可以用作表示层,我们下文会讨论,不过,我们先看下面的图,它是我在 [Istio walkthrough][2] 视频教程中提到的 [Jaeger][1] 界面,展示了单个 trace 中的多个 span。很明显,这个图能让你一目了然地对事务有更深的了解。 +当一次事务(或者说踪迹)运行过之后,就可以在追踪系统的表示层上搜索了。有几个工具可以用作表示层,我们下文会讨论,不过,我们先看下面的图,它是我在 [Istio walkthrough][2] 视频教程中提到的 [Jaeger][1] 界面,展示了单个踪迹中的多个单元。很明显,这个图能让你一目了然地对事务有更深的了解。 ![](https://opensource.com/sites/default/files/uploads/monitoring_guide_jaeger_istio_0.png) -这个 demo 使用了 Istio 内置的 OpenTracing 实现,所以我甚至不需要修改自己的应用代码就可以获得追踪数据。我也用到了 Jaeger,它是兼容 OpenTracing 的。 +这个演示使用了 Istio 内置的 OpenTracing 实现,所以我甚至不需要修改自己的应用代码就可以获得追踪数据。我也用到了 Jaeger,它是兼容 OpenTracing 的。 那么 OpenTracing 到底是什么呢?我们来看看。 ### OpenTracing API -[OpenTracing][3] 是源自 [Zipkin][4] 的规范,以提供跨平台兼容性。它提供了对厂商中立的 API,用来向应用程序添加追踪功能并将追踪数据发送到分布式的追踪系统。按照 OpenTracing 规范编写的库,可以被任何兼容 OpenTracing 的系统使用。采用这个开放标准的开源工具有 Zipkin,Jaeger,和 Appdash 等。甚至像 [Datadog][5] 和 [Instana][6] 这种付费工具也在采用。因为现在 OpenTracing 已经无处不在,这样的趋势有望继续发展下去。 +[OpenTracing][3] 是源自 [Zipkin][4] 的规范,以提供跨平台兼容性。它提供了对厂商中立的 API,用来向应用程序添加追踪功能并将追踪数据发送到分布式的追踪系统。按照 OpenTracing 规范编写的库,可以被任何兼容 OpenTracing 的系统使用。采用这个开放标准的开源工具有 Zipkin、Jaeger 和 Appdash 等。甚至像 [Datadog][5] 和 [Instana][6] 这种付费工具也在采用。因为现在 OpenTracing 已经无处不在,这样的趋势有望继续发展下去。 ### OpenCensus OpenTracing 已经说过了,可 [OpenCensus][7] 又是什么呢?它在搜索结果中老是出现。它是一个和 OpenTracing 完全不同或者互补的竞争标准吗? -这个问题的答案取决于你的提问对象。我先尽我所能地解释一下他们的不同(按照我的理解):OpenCensus 更加全面或者说它包罗万象。OpenTracing 专注于建立开放的 API 和规范,而不是为每一种开发语言和追踪系统都提供开放的实现。OpenCensus 不仅提供规范,还提供开发语言的实现,和连接协议,而且它不仅只做追踪,还引入了额外的度量指标,这些一般不在分布式追踪系统的职责范围。 +这个问题的答案取决于你的提问对象。我先尽我所能地解释一下它们的不同(按照我的理解):OpenCensus 更加全面或者说它包罗万象。OpenTracing 专注于建立开放的 API 和规范,而不是为每一种开发语言和追踪系统都提供开放的实现。OpenCensus 不仅提供规范,还提供开发语言的实现,和连接协议,而且它不仅只做追踪,还引入了额外的度量指标,这些一般不在分布式追踪系统的职责范围。 -使用 OpenCensus,我们能够在运行着应用程序的主机上查看追踪数据,但它也有个可插拔的导出器系统,用于导出数据到中心聚合器。目前 OpenCensus 团队提供的导出器包括 Zipkin,Prometheus,Jaeger,Stackdriver,Datadog 和 SignalFx,不过任何人都可以创建一个导出器。 +使用 OpenCensus,我们能够在运行着应用程序的主机上查看追踪数据,但它也有个可插拔的导出器系统,用于导出数据到中心聚合器。目前 OpenCensus 团队提供的导出器包括 Zipkin、Prometheus、Jaeger、Stackdriver、Datadog 和 SignalFx,不过任何人都可以创建一个导出器。 依我看这两者有很多重叠的部分,没有哪个一定比另外一个好,但是重要的是,要知道它们做什么事情和不做什么事情。OpenTracing 主要是一个规范,具体的实现和独断的设计由其他人来做。OpenCensus 更加独断地为本地组件提供了全面的解决方案,但是仍然需要其他系统做远程的聚合。 @@ -39,23 +39,23 @@ OpenTracing 已经说过了,可 [OpenCensus][7] 又是什么呢?它在搜索 Zipkin 是最早出现的这类工具之一。 谷歌在 2010 年发表了介绍其内部追踪系统 Dapper 的[论文][8],Twitter 以此为基础开发了 Zipkin。Zipkin 的开发语言 Java,用 Cassandra 或 ElasticSearch 作为可扩展的存储后端,这些选择能满足大部分公司的需求。Zipkin 支持的最低 Java 版本是 Java 6,它也使用了 [Thrift][9] 的二进制通信协议,Thrift 在 Twitter 的系统中很流行,现在作为 Apache 项目在托管。 -这个系统包括上报器(客户端),数据收集器,查询服务和一个 web 界面。Zipkin 只传输一个带事务上下文的 trace ID 来告知接收者追踪的进行,所以说在生产环境中是安全的。每一个客户端收集到的数据,会异步地传输到数据收集器。收集器把这些 span 的数据存到数据库,web 界面负责用可消费的格式展示这些数据给用户。客户端传输数据到收集器有三种方式:HTTP,Kafka 和 Scribe。 +这个系统包括上报器(客户端)、数据收集器、查询服务和一个 web 界面。Zipkin 只传输一个带事务上下文的踪迹 ID 来告知接收者追踪的进行,所以说在生产环境中是安全的。每一个客户端收集到的数据,会异步地传输到数据收集器。收集器把这些单元的数据存到数据库,web 界面负责用可消费的格式展示这些数据给用户。客户端传输数据到收集器有三种方式:HTTP、Kafka 和 Scribe。 -[Zipkin 社区][10] 还提供了 [Brave][11],一个跟 Zipkin 兼容的 Java 客户端的实现。由于 Brave 没有任何依赖,所以它不会拖累你的项目,也不会使用跟你们公司标准不兼容的库来搞乱你的项目。除 Brave 之外,还有很多其他的 Zipkin 客户端实现,因为 Zipkin 和 OpenTracing 标准是兼容的,所以这些实现也能用到其他的分布式追踪系统中。流行的 Spring 框架中一个叫 [Spring Cloud Sleuth][12] 的分布式追踪组件,它和 Zipkin 是兼容的。 +[Zipkin 社区][10] 还提供了 [Brave][11],一个跟 Zipkin 兼容的 Java 客户端的实现。由于 Brave 没有任何依赖,所以它不会拖累你的项目,也不会使用跟你们公司标准不兼容的库来搞乱你的项目。除 Brave 之外,还有很多其他的 Zipkin 客户端实现,因为 Zipkin 和 OpenTracing 标准是兼容的,所以这些实现也能用到其他的分布式追踪系统中。流行的 Spring 框架中一个叫 [Spring Cloud Sleuth][12] 的分布式追踪组件,它和 Zipkin 是兼容的。 #### Jaeger -[Jaeger][1] 来自 Uber,是一个比较新的项目,[CNCF][13] (云原生计算基金会)已经把 Jaeger 托管为孵化项目。Jaeger 使用 Golang 开发,因此你不用担心在服务器上安装依赖的问题,也不用担心开发语言的解释器或虚拟机的开销。和 Zipkin 类似,Jaeger 也支持用 Cassandra 和 ElasticSearch 做可扩展的存储后端。Jaeger 也完全兼容 OpenTracing 标准。 +[Jaeger][1] 来自 Uber,是一个比较新的项目,[CNCF][13](云原生计算基金会)已经把 Jaeger 托管为孵化项目。Jaeger 使用 Golang 开发,因此你不用担心在服务器上安装依赖的问题,也不用担心开发语言的解释器或虚拟机的开销。和 Zipkin 类似,Jaeger 也支持用 Cassandra 和 ElasticSearch 做可扩展的存储后端。Jaeger 也完全兼容 OpenTracing 标准。 -Jaeger 的架构跟 Zipkin 很像,有客户端(上报器),数据收集器,查询服务和一个 web 界面,不过它还有一个在各个服务器上运行着的代理,负责在服务器本地做数据聚合。代理通过一个 UDP 连接接收数据,然后分批处理,发送到数据收集器。收集器接收到的数据是 [Thrift][14] 协议的格式,它把数据存到 Cassandra 或者 ElasticSearch 中。查询服务能直接访问数据库,并给 web 界面提供所需的信息。 +Jaeger 的架构跟 Zipkin 很像,有客户端(上报器)、数据收集器、查询服务和一个 web 界面,不过它还有一个在各个服务器上运行着的代理,负责在服务器本地做数据聚合。代理通过一个 UDP 连接接收数据,然后分批处理,发送到数据收集器。收集器接收到的数据是 [Thrift][14] 协议的格式,它把数据存到 Cassandra 或者 ElasticSearch 中。查询服务能直接访问数据库,并给 web 界面提供所需的信息。 -默认情况下,Jaeger 客户端不会采集所有的追踪数据,只抽样了 0.1% 的( 1000 个采 1 个)追踪数据。对大多数系统来说,保留所有的追踪数据并传输的话就太多了。不过,通过配置代理可以调整这个值,客户端会从代理获取自己的配置。这个抽样并不是完全随机的,并且正在变得越来越好。Jaeger 使用概率抽样,试图对是否应该对新踪迹进行抽样进行有根据的猜测。 自适应采样已经在[路线图][15],它将通过添加额外的,能够帮助做决策的上下文,来改进采样算法。 +默认情况下,Jaeger 客户端不会采集所有的追踪数据,只抽样了 0.1% 的( 1000 个采 1 个)追踪数据。对大多数系统来说,保留所有的追踪数据并传输的话就太多了。不过,通过配置代理可以调整这个值,客户端会从代理获取自己的配置。这个抽样并不是完全随机的,并且正在变得越来越好。Jaeger 使用概率抽样,试图对是否应该对新踪迹进行抽样进行有根据的猜测。 [自适应采样已经在路线图当中][15],它将通过添加额外的、能够帮助做决策的上下文来改进采样算法。 #### Appdash [Appdash][16] 也是一个用 Golang 写的分布式追踪系统,和 Jaeger 一样。Appdash 是 [Sourcegraph][17] 公司基于谷歌的 Dapper 和 Twitter 的 Zipkin 开发的。同样的,它也支持 Opentracing 标准,不过这是后来添加的功能,依赖了一个与默认组件不同的组件,因此增加了风险和复杂度。 -从高层次来看,Appdash 的架构主要有三个部分:客户端,本地收集器和远程收集器。因为没有很多文档,所以这个架构描述是基于对系统的测试以及查看源码。写代码时需要把 Appdash 的客户端添加进来。 Appdash 提供了 Python,Golang 和 Ruby 的实现,不过 OpenTracing 库可以与 Appdash 的 OpenTracing 实现一起使用。 客户端收集 span 数据,并将它们发送到本地收集器。然后,本地收集器将数据发送到中心的 Appdash 服务器,这个服务器上运行着自己的本地收集器,它的本地收集器是其他所有节点的远程收集器。 +从高层次来看,Appdash 的架构主要有三个部分:客户端、本地收集器和远程收集器。因为没有很多文档,所以这个架构描述是基于对系统的测试以及查看源码。写代码时需要把 Appdash 的客户端添加进来。Appdash 提供了 Python、Golang 和 Ruby 的实现,不过 OpenTracing 库可以与 Appdash 的 OpenTracing 实现一起使用。 客户端收集单元数据,并将它们发送到本地收集器。然后,本地收集器将数据发送到中心的 Appdash 服务器,这个服务器上运行着自己的本地收集器,它的本地收集器是其他所有节点的远程收集器。 -------------------------------------------------------------------------------- @@ -64,7 +64,7 @@ via: https://opensource.com/article/18/9/distributed-tracing-tools 作者:[Dan Barker][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[belitex](https://github.com/belitex) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 450344c8a310eb551aa244259a8ad908b3bc24de Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 18 Oct 2018 00:06:12 +0800 Subject: [PATCH 019/158] PUB:20180926 3 open source distributed tracing tools.md @belitex https://linux.cn/article-10127-1.html --- .../20180926 3 open source distributed tracing tools.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180926 3 open source distributed tracing tools.md (100%) diff --git a/translated/tech/20180926 3 open source distributed tracing tools.md b/published/20180926 3 open source distributed tracing tools.md similarity index 100% rename from translated/tech/20180926 3 open source distributed tracing tools.md rename to published/20180926 3 open source distributed tracing tools.md From d2e065c8d233587ae2f6fd4623fa12ef04d863ff Mon Sep 17 00:00:00 2001 From: pityonline Date: Sat, 13 Oct 2018 22:34:03 +0800 Subject: [PATCH 020/158] =?UTF-8?q?PRF:=20#10600=20=E5=88=9D=E6=AD=A5?= =?UTF-8?q?=E6=A0=A1=E5=AF=B9=E5=B9=B6=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 * DOS => UNIX * 使用中文标点 * 调整空格的使用 --- ...s Why Linux is a Better Choice than Mac.md | 263 +++++++++--------- 1 file changed, 132 insertions(+), 131 deletions(-) diff --git a/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md b/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md index a9ece78ef7..c315e7a1e6 100644 --- a/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md +++ b/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md @@ -1,131 +1,132 @@ -Linux vs Mac: Linux 比 Mac 好的七个原因 -====== -最近我们谈论了一些[为什么 Linux 比 Windows 好][1]的原因。毫无疑问, Linux 是个非常优秀的平台。但是它和其他的操作系统一样也会有缺点。对于某些专门的领域,像是游戏, Windows 当然更好。 而对于视频编辑等任务, Mac 系统可能更为方便。这一切都取决于你的爱好,以及你想用你的系统做些什么。在这篇文章中,我们将会介绍一些 Linux 相对于 Mac 更好的一些地方。 - -如果你已经在用 Mac 或者打算买一台 Mac 电脑,我们建议你仔细考虑一下,看看是改为使用 Linux 还是继续使用 Mac 。 - -### Linux 比 Mac 好的 7 个原因 - -![Linux vs Mac: 为什么 Linux 更好][2] - -Linux 和 macOS 都是类 Unix 操作系统,并且都支持 Unix 命令行、 bash 和其他一些命令行工具,相比于 Windows ,他们所支持的应用和游戏比较少。但缺点也仅仅如此。 - -平面设计师和视频剪辑师更加倾向于使用 Mac 系统,而 Linux 更加适合做开发、系统管理、运维的工程师。 - -那要不要使用 Linux 呢,为什么要选择 Linux 呢?下面是根据实际经验和理性分析给出的一些建议。 - -#### 1\. 价格 - -![Linux vs Mac: 为什么 Linux 更好][3] - -假设你只是需要浏览文件、看电影、下载图片、写文档、制作报表或者做一些类似的工作,并且你想要一个更加安全的系统。 - -那在这种情况下,你觉得花费几百块买个系统完成这项工作,或者花费更多直接买个 Macbook 划算吗?当然,最终的决定权还是在你。 - -买个装好 Mac 系统的电脑还是买个便宜的电脑,然后自己装上免费的 Linux 系统,这个要看你自己的偏好。就我个人而言,除了音视频剪辑创作之外,Linux 都非常好地用,而对于音视频方面,我更倾向于使用 Final Cut Pro (专业的视频编辑软件) 和 Logic Pro X (专业的音乐制作软件)(这两款软件都是苹果公司推出的)。 - -#### 2\. 硬件支持 - -![Linux vs Mac: 为什么 Linux 更好][4] - -Linux 支持多种平台. 无论你的电脑配置如何,你都可以在上面安装 Linux,无论性能好或者差,Linux 都可以运行。[即使你的电脑已经使用很久了, 你仍然可以通过选择安装合适的发行版让 Linux 在你的电脑上流畅的运行][5]. - -而 Mac 不同,它是苹果机专用系统。如果你希望买个便宜的电脑,然后自己装上 Mac 系统,这几乎是不可能的。一般来说 Mac 都是和苹果设备连在一起的。 - -这是[在非苹果系统上安装 Mac OS 的教程][6]. 这里面需要用到的专业技术以及可能遇到的一些问题将会花费你许多时间,你需要想好这样做是否值得。 - -总之,Linux 所支持的硬件平台很广泛,而 MacOS 相对而言则非常少。 - -#### 3\. 安全性 - -![Linux vs Mac: 为什么 Linux 更好][7] - -很多人都说 ios 和 Mac 是非常安全的平台。的确,相比于 Windows ,它确实比较安全,可并不一定有 Linux 安全。 - -我不是在危言耸听。 Mac 系统上也有不少恶意软件和广告,并且[数量与日俱增][8]。我认识一些不太懂技术的用户 使用着非常缓慢的 Mac 电脑并且为此苦苦挣扎。一项快速调查显示[浏览器恶意劫持软件][9]是罪魁祸首. - -从来没有绝对安全的操作系统,Linux 也不例外。 Linux 也有漏洞,但是 Linux 发行版提供的及时更新弥补了这些漏洞。另外,到目前为止在 Linux 上还没有自动运行的病毒或浏览器劫持恶意软件的案例发生。 - -这可能也是一个你应该选择 Linux 而不是 Mac 的原因。 - -#### 4\. 可定制性与灵活性 - -![Linux vs Mac: 为什么 Linux 更好][10] - -如果你有不喜欢的东西,自己定制或者修改它都行。 - -举个例子,如果你不喜欢 Ubuntu 18.04.1 的 [Gnome 桌面环境][11],你可以换成 [KDE Plasma][11]。 你也可以尝试一些 [Gnome 扩展][12]丰富你的桌面选择。这种灵活性和可定制性在 Mac OS 是不可能有的。 - -除此之外你还可以根据需要修改一些操作系统的代码(但是可能需要一些专业知识)以创造出适合你的系统。这个在 Mac OS 上可以做吗? - -另外你可以根据需要从一系列的 Linux 发行版进行选择。比如说,如果你想喜欢 Mac OS上的工作流, [Elementary OS][13] 可能是个不错的选择。你想在你的旧电脑上装上一个轻量级的 Linux 发行版系统吗?这里是一个[轻量级 Linux 发行版列表][5]。相比较而言, Mac OS 缺乏这种灵活性。 - -#### 5\. 使用 Linux 有助于你的职业生涯 [针对 IT 行业和科学领域的学生] - -![Linux vs Mac: 为什么 Linux 更好][14] - -对于 IT 领域的学生和求职者而言,这是有争议的但是也是有一定的帮助的。使用 Linux 并不会让你成为一个优秀的人,也不一定能让你得到任何与 IT 相关的工作。 - -但是当你开始使用 Linux 并且开始探索如何使用的时候,你将会获得非常多的经验。作为一名技术人员,你迟早会接触终端,学习通过命令行实现文件系统管理以及应用程序安装。你可能不会知道这些都是一些 IT 公司的新职员需要培训的内容。 - -除此之外,Linux 在就业市场上还有很大的发展空间。 Linux 相关的技术有很多( Cloud 、 Kubernetes 、Sysadmin 等),您可以学习,获得证书并获得一份相关的高薪的工作。要学习这些,你必须使用 Linux 。 - -#### 6\. 可靠 - -![Linux vs Mac: 为什么 Linux 更好][15] - -想想为什么服务器上用的都是 Linux 系统,当然是因为它可靠。 - -但是它为什么可靠呢,相比于 Mac OS ,它的可靠体现在什么方面呢? - -答案很简单——给用户更多的控制权,同时提供更好的安全性。在 Mac OS 上,你并不能完全控制它,这样做是为了让操作变得更容易,同时提高你的用户体验。使用 Linux ,你可以做任何你想做的事情——这可能会导致(对某些人来说)糟糕的用户体验——但它确实使其更可靠。 - -#### 7\. 开源 - -![Linux vs Mac: 为什么 Linux 更好][16] - -开源并不是每个人都关心的。但对我来说,Linux 最重要的优势在于它的开源特性。下面讨论的大多数观点都是开源软件的直接优势。 - -简单解释一下,如果是开源软件,你可以自己查看或者修改它。但对 Mac 来说,苹果拥有独家控制权。即使你有足够的技术知识,也无法查看 Mac OS 的源代码。 - -形象点说,Mac 驱动的系统可以让你得到一辆车,但缺点是你不能打开引擎盖看里面是什么。那可能非常糟糕! - -如果你想深入了解开源软件的优势,可以在 OpenSource.com 上浏览一下 [Ben Balter 的文章][17]。 - -### 总结 - -现在你应该知道为什么 Linux 比 Mac 好了吧,你觉得呢?上面的这些原因可以说服你选择 Linux 吗?如果不行的话那又是为什么呢? - -在下方评论让我们知道你的想法。 - -Note: 这里的图片是以企鹅俱乐部为原型的。 - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/linux-vs-mac/ - -作者:[Ankush Das][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[Ryze-Borgia](https://github.com/Ryze-Borgia) -校对:[校对者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 +Linux vs Mac:Linux 比 Mac 好的 7 个原因 +====== + +最近我们谈论了一些[为什么 Linux 比 Windows 好][1]的原因。毫无疑问,Linux 是个非常优秀的平台。但是它和其他的操作系统一样也会有缺点。对于某些专门的领域,像是游戏,Windows 当然更好。而对于视频编辑等任务,Mac 系统可能更为方便。这一切都取决于你的爱好,以及你想用你的系统做些什么。在这篇文章中,我们将会介绍一些 Linux 相对于 Mac 更好的一些地方。 + +如果你已经在用 Mac 或者打算买一台 Mac 电脑,我们建议你仔细考虑一下,看看是改为使用 Linux 还是继续使用 Mac。 + +### Linux 比 Mac 好的 7 个原因 + +![Linux vs Mac:为什么 Linux 更好][2] + +Linux 和 macOS 都是类 Unix 操作系统,并且都支持 Unix 命令行、bash 和其他一些命令行工具,相比于 Windows,他们所支持的应用和游戏比较少。但缺点也仅仅如此。 + +平面设计师和视频剪辑师更加倾向于使用 Mac 系统,而 Linux 更加适合做开发、系统管理、运维的工程师。 + +那要不要使用 Linux 呢,为什么要选择 Linux 呢?下面是根据实际经验和理性分析给出的一些建议。 + +#### 1、价格 + +![Linux vs Mac:为什么 Linux 更好][3] + +假设你只是需要浏览文件、看电影、下载图片、写文档、制作报表或者做一些类似的工作,并且你想要一个更加安全的系统。 + +那在这种情况下,你觉得花费几百块买个系统完成这项工作,或者花费更多直接买个 Macbook 划算吗?当然,最终的决定权还是在你。 + +买个装好 Mac 系统的电脑还是买个便宜的电脑,然后自己装上免费的 Linux 系统,这个要看你自己的偏好。就我个人而言,除了音视频剪辑创作之外,Linux 都非常好地用,而对于音视频方面,我更倾向于使用 Final Cut Pro(专业的视频编辑软件)和 Logic Pro X(专业的音乐制作软件)(这两款软件都是苹果公司推出的)。 + +#### 2、硬件支持 + +![Linux vs Mac:为什么 Linux 更好][4] + +Linux 支持多种平台。无论你的电脑配置如何,你都可以在上面安装 Linux,无论性能好或者差,Linux 都可以运行。[即使你的电脑已经使用很久了,你仍然可以通过选择安装合适的发行版让 Linux 在你的电脑上流畅的运行][5]。 + +而 Mac 不同,它是苹果机专用系统。如果你希望买个便宜的电脑,然后自己装上 Mac 系统,这几乎是不可能的。一般来说 Mac 都是和苹果设备连在一起的。 + +这是[在非苹果系统上安装 Mac OS 的教程][6]。这里面需要用到的专业技术以及可能遇到的一些问题将会花费你许多时间,你需要想好这样做是否值得。 + +总之,Linux 所支持的硬件平台很广泛,而 MacOS 相对而言则非常少。 + +#### 3、安全性 + +![Linux vs Mac:为什么 Linux 更好][7] + +很多人都说 iOS 和 Mac 是非常安全的平台。的确,相比于 Windows,它确实比较安全,可并不一定有 Linux 安全。 + +我不是在危言耸听。Mac 系统上也有不少恶意软件和广告,并且[数量与日俱增][8]。我认识一些不太懂技术的用户使用着非常缓慢的 Mac 电脑并且为此苦苦挣扎。一项快速调查显示[浏览器恶意劫持软件][9]是罪魁祸首。 + +从来没有绝对安全的操作系统,Linux 也不例外。Linux 也有漏洞,但是 Linux 发行版提供的及时更新弥补了这些漏洞。另外,到目前为止在 Linux 上还没有自动运行的病毒或浏览器劫持恶意软件的案例发生。 + +这可能也是一个你应该选择 Linux 而不是 Mac 的原因。 + +#### 4、可定制性与灵活性 + +![Linux vs Mac:为什么 Linux 更好][10] + +如果你有不喜欢的东西,自己定制或者修改它都行。 + +举个例子,如果你不喜欢 Ubuntu 18.04.1 的 [Gnome 桌面环境][11],你可以换成 [KDE Plasma][11]。你也可以尝试一些 [Gnome 扩展][12]丰富你的桌面选择。这种灵活性和可定制性在 Mac OS 是不可能有的。 + +除此之外你还可以根据需要修改一些操作系统的代码(但是可能需要一些专业知识)以创造出适合你的系统。这个在 Mac OS 上可以做吗? + +另外你可以根据需要从一系列的 Linux 发行版进行选择。比如说,如果你想喜欢 Mac OS上的工作流,[Elementary OS][13] 可能是个不错的选择。你想在你的旧电脑上装上一个轻量级的 Linux 发行版系统吗?这里是一个[轻量级 Linux 发行版列表][5]。相比较而言,Mac OS 缺乏这种灵活性。 + +#### 5、使用 Linux 有助于你的职业生涯(针对 IT 行业和科学领域的学生) + +![Linux vs Mac:为什么 Linux 更好][14] + +对于 IT 领域的学生和求职者而言,这是有争议的但是也是有一定的帮助的。使用 Linux 并不会让你成为一个优秀的人,也不一定能让你得到任何与 IT 相关的工作。 + +但是当你开始使用 Linux 并且开始探索如何使用的时候,你将会获得非常多的经验。作为一名技术人员,你迟早会接触终端,学习通过命令行实现文件系统管理以及应用程序安装。你可能不会知道这些都是一些 IT 公司的新职员需要培训的内容。 + +除此之外,Linux 在就业市场上还有很大的发展空间。Linux 相关的技术有很多(Cloud、Kubernetes、Sysadmin 等),您可以学习,获得证书并获得一份相关的高薪的工作。要学习这些,你必须使用 Linux 。 + +#### 6、可靠 + +![Linux vs Mac:为什么 Linux 更好][15] + +想想为什么服务器上用的都是 Linux 系统,当然是因为它可靠。 + +但是它为什么可靠呢,相比于 Mac OS,它的可靠体现在什么方面呢? + +答案很简单——给用户更多的控制权,同时提供更好的安全性。在 Mac OS 上,你并不能完全控制它,这样做是为了让操作变得更容易,同时提高你的用户体验。使用 Linux,你可以做任何你想做的事情——这可能会导致(对某些人来说)糟糕的用户体验——但它确实使其更可靠。 + +#### 7、开源 + +![Linux vs Mac:为什么 Linux 更好][16] + +开源并不是每个人都关心的。但对我来说,Linux 最重要的优势在于它的开源特性。下面讨论的大多数观点都是开源软件的直接优势。 + +简单解释一下,如果是开源软件,你可以自己查看或者修改它。但对 Mac 来说,苹果拥有独家控制权。即使你有足够的技术知识,也无法查看 Mac OS 的源代码。 + +形象点说,Mac 驱动的系统可以让你得到一辆车,但缺点是你不能打开引擎盖看里面是什么。那可能非常糟糕! + +如果你想深入了解开源软件的优势,可以在 OpenSource.com 上浏览一下 [Ben Balter 的文章][17]。 + +### 总结 + +现在你应该知道为什么 Linux 比 Mac 好了吧,你觉得呢?上面的这些原因可以说服你选择 Linux 吗?如果不行的话那又是为什么呢? + +在下方评论让我们知道你的想法。 + +提示:这里的图片是以企鹅俱乐部为原型的。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-vs-mac/ + +作者:[Ankush Das][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[Ryze-Borgia](https://github.com/Ryze-Borgia) +校对:[pityonline](https://github.com/pityonline) + +本文由 [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 dbe98968061c286e58e00edf6c0cfdf9b3c76e58 Mon Sep 17 00:00:00 2001 From: pityonline Date: Tue, 16 Oct 2018 15:13:12 +0800 Subject: [PATCH 021/158] =?UTF-8?q?PRF:=20#10600=20=E4=BF=AE=E6=AD=A3=20KD?= =?UTF-8?q?E=20Plasma=20=E7=9A=84=E9=94=99=E8=AF=AF=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md b/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md index c315e7a1e6..9eab0f985d 100644 --- a/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md +++ b/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md @@ -55,7 +55,7 @@ Linux 支持多种平台。无论你的电脑配置如何,你都可以在上 如果你有不喜欢的东西,自己定制或者修改它都行。 -举个例子,如果你不喜欢 Ubuntu 18.04.1 的 [Gnome 桌面环境][11],你可以换成 [KDE Plasma][11]。你也可以尝试一些 [Gnome 扩展][12]丰富你的桌面选择。这种灵活性和可定制性在 Mac OS 是不可能有的。 +举个例子,如果你不喜欢 Ubuntu 18.04.1 的 [Gnome 桌面环境][11],你可以换成 [KDE Plasma][18]。你也可以尝试一些 [Gnome 扩展][12]丰富你的桌面选择。这种灵活性和可定制性在 Mac OS 是不可能有的。 除此之外你还可以根据需要修改一些操作系统的代码(但是可能需要一些专业知识)以创造出适合你的系统。这个在 Mac OS 上可以做吗? @@ -130,3 +130,4 @@ via: https://itsfoss.com/linux-vs-mac/ [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 +[18]: https://www.kde.org/plasma-desktop From 11c5f739a7cf8cc6a9da5f0d00e8311542a6b85e Mon Sep 17 00:00:00 2001 From: pityonline Date: Tue, 16 Oct 2018 08:37:55 +0800 Subject: [PATCH 022/158] =?UTF-8?q?PRF:=20#10600=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 --- ...s Why Linux is a Better Choice than Mac.md | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md b/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md index 9eab0f985d..5d660cb60e 100644 --- a/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md +++ b/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md @@ -1,7 +1,7 @@ Linux vs Mac:Linux 比 Mac 好的 7 个原因 ====== -最近我们谈论了一些[为什么 Linux 比 Windows 好][1]的原因。毫无疑问,Linux 是个非常优秀的平台。但是它和其他的操作系统一样也会有缺点。对于某些专门的领域,像是游戏,Windows 当然更好。而对于视频编辑等任务,Mac 系统可能更为方便。这一切都取决于你的爱好,以及你想用你的系统做些什么。在这篇文章中,我们将会介绍一些 Linux 相对于 Mac 更好的一些地方。 +最近我们谈论了一些[为什么 Linux 比 Windows 好][1]的原因。毫无疑问,Linux 是个非常优秀的平台。但是它和其它操作系统一样也会有缺点。对于某些专门的领域,像是游戏,Windows 当然更好。而对于视频编辑等任务,Mac 系统可能更为方便。这一切都取决于你的偏好,以及你想用你的系统做些什么。在这篇文章中,我们将会介绍一些 Linux 相对于 Mac 更好的一些地方。 如果你已经在用 Mac 或者打算买一台 Mac 电脑,我们建议你仔细考虑一下,看看是改为使用 Linux 还是继续使用 Mac。 @@ -9,7 +9,7 @@ Linux vs Mac:Linux 比 Mac 好的 7 个原因 ![Linux vs Mac:为什么 Linux 更好][2] -Linux 和 macOS 都是类 Unix 操作系统,并且都支持 Unix 命令行、bash 和其他一些命令行工具,相比于 Windows,他们所支持的应用和游戏比较少。但缺点也仅仅如此。 +Linux 和 macOS 都是类 Unix 操作系统,并且都支持 Unix 命令行、bash 和其它 shell,相比于 Windows,它们所支持的应用和游戏比较少。但也就是这点比较相似。 平面设计师和视频剪辑师更加倾向于使用 Mac 系统,而 Linux 更加适合做开发、系统管理、运维的工程师。 @@ -21,9 +21,9 @@ Linux 和 macOS 都是类 Unix 操作系统,并且都支持 Unix 命令行、b 假设你只是需要浏览文件、看电影、下载图片、写文档、制作报表或者做一些类似的工作,并且你想要一个更加安全的系统。 -那在这种情况下,你觉得花费几百块买个系统完成这项工作,或者花费更多直接买个 Macbook 划算吗?当然,最终的决定权还是在你。 +那在这种情况下,你觉得花费几百美金买个系统完成这项工作,或者花费更多直接买个 Macbook 更好?当然,最终的决定权还是在你。 -买个装好 Mac 系统的电脑还是买个便宜的电脑,然后自己装上免费的 Linux 系统,这个要看你自己的偏好。就我个人而言,除了音视频剪辑创作之外,Linux 都非常好地用,而对于音视频方面,我更倾向于使用 Final Cut Pro(专业的视频编辑软件)和 Logic Pro X(专业的音乐制作软件)(这两款软件都是苹果公司推出的)。 +买个装好 Mac 系统的电脑?还是买个便宜的电脑,然后自己装上免费的 Linux 系统?这个要看你自己的偏好。就我个人而言,除了音视频剪辑创作之外,Linux 都非常好地用,而对于音视频方面,我更倾向于使用 Final Cut Pro(专业的视频编辑软件)和 Logic Pro X(专业的音乐制作软件)(译注:这两款软件都是苹果公司推出的)。 #### 2、硬件支持 @@ -31,9 +31,9 @@ Linux 和 macOS 都是类 Unix 操作系统,并且都支持 Unix 命令行、b Linux 支持多种平台。无论你的电脑配置如何,你都可以在上面安装 Linux,无论性能好或者差,Linux 都可以运行。[即使你的电脑已经使用很久了,你仍然可以通过选择安装合适的发行版让 Linux 在你的电脑上流畅的运行][5]。 -而 Mac 不同,它是苹果机专用系统。如果你希望买个便宜的电脑,然后自己装上 Mac 系统,这几乎是不可能的。一般来说 Mac 都是和苹果设备连在一起的。 +而 Mac 不同,它是苹果机专用系统。如果你希望买个便宜的电脑,然后自己装上 Mac 系统,这几乎是不可能的。一般来说 Mac 都是和苹果设备配套的。 -这是[在非苹果系统上安装 Mac OS 的教程][6]。这里面需要用到的专业技术以及可能遇到的一些问题将会花费你许多时间,你需要想好这样做是否值得。 +这有一些[在非苹果系统上安装 Mac OS 的教程][6]。这里面需要用到的专业技术以及可能遇到的一些问题将会花费你许多时间,你需要想好这样做是否值得。 总之,Linux 所支持的硬件平台很广泛,而 MacOS 相对而言则非常少。 @@ -41,9 +41,9 @@ Linux 支持多种平台。无论你的电脑配置如何,你都可以在上 ![Linux vs Mac:为什么 Linux 更好][7] -很多人都说 iOS 和 Mac 是非常安全的平台。的确,相比于 Windows,它确实比较安全,可并不一定有 Linux 安全。 +很多人都说 iOS 和 Mac 是非常安全的平台。的确,或许相比于 Windows,它确实比较安全,可并不一定有 Linux 安全。 -我不是在危言耸听。Mac 系统上也有不少恶意软件和广告,并且[数量与日俱增][8]。我认识一些不太懂技术的用户使用着非常缓慢的 Mac 电脑并且为此苦苦挣扎。一项快速调查显示[浏览器恶意劫持软件][9]是罪魁祸首。 +我不是在危言耸听。Mac 系统上也有不少恶意软件和广告,并且[数量与日俱增][8]。我认识一些不太懂技术的用户使用着很慢的 Mac 电脑并且为此深受折磨。一项快速调查显示[浏览器恶意劫持软件][9]是罪魁祸首。 从来没有绝对安全的操作系统,Linux 也不例外。Linux 也有漏洞,但是 Linux 发行版提供的及时更新弥补了这些漏洞。另外,到目前为止在 Linux 上还没有自动运行的病毒或浏览器劫持恶意软件的案例发生。 @@ -57,9 +57,9 @@ Linux 支持多种平台。无论你的电脑配置如何,你都可以在上 举个例子,如果你不喜欢 Ubuntu 18.04.1 的 [Gnome 桌面环境][11],你可以换成 [KDE Plasma][18]。你也可以尝试一些 [Gnome 扩展][12]丰富你的桌面选择。这种灵活性和可定制性在 Mac OS 是不可能有的。 -除此之外你还可以根据需要修改一些操作系统的代码(但是可能需要一些专业知识)以创造出适合你的系统。这个在 Mac OS 上可以做吗? +除此之外,你还可以根据需要修改一些操作系统的代码(但是可能需要一些专业知识)来打造适合你的系统。这个在 Mac OS 上可以做吗? -另外你可以根据需要从一系列的 Linux 发行版进行选择。比如说,如果你想喜欢 Mac OS上的工作流,[Elementary OS][13] 可能是个不错的选择。你想在你的旧电脑上装上一个轻量级的 Linux 发行版系统吗?这里是一个[轻量级 Linux 发行版列表][5]。相比较而言,Mac OS 缺乏这种灵活性。 +另外你可以根据需要从一系列的 Linux 发行版进行选择。比如说,如果你喜欢 Mac OS 上的工作流,[Elementary OS][13] 可能是个不错的选择。你想在你的旧电脑上装上一个轻量级的 Linux 发行版系统吗?这里是一个[轻量级 Linux 发行版列表][5]。相比较而言,Mac OS 缺乏这种灵活性。 #### 5、使用 Linux 有助于你的职业生涯(针对 IT 行业和科学领域的学生) @@ -67,9 +67,9 @@ Linux 支持多种平台。无论你的电脑配置如何,你都可以在上 对于 IT 领域的学生和求职者而言,这是有争议的但是也是有一定的帮助的。使用 Linux 并不会让你成为一个优秀的人,也不一定能让你得到任何与 IT 相关的工作。 -但是当你开始使用 Linux 并且开始探索如何使用的时候,你将会获得非常多的经验。作为一名技术人员,你迟早会接触终端,学习通过命令行实现文件系统管理以及应用程序安装。你可能不会知道这些都是一些 IT 公司的新职员需要培训的内容。 +但是当你开始使用 Linux 并且探索如何使用的时候,你将会积累非常多的经验。作为一名技术人员,你迟早会接触终端,学习通过命令行操作文件系统以及安装应用程序。你可能不会知道这些都是一些 IT 公司的新员工需要培训的内容。 -除此之外,Linux 在就业市场上还有很大的发展空间。Linux 相关的技术有很多(Cloud、Kubernetes、Sysadmin 等),您可以学习,获得证书并获得一份相关的高薪的工作。要学习这些,你必须使用 Linux 。 +除此之外,Linux 在就业市场上还有很大的发展空间。Linux 相关的技术有很多(Cloud、Kubernetes、Sysadmin 等),你可以学习,考取专业技能证书并获得一份相关的高薪工作。要学习这些,你必须使用 Linux 。 #### 6、可靠 @@ -79,7 +79,7 @@ Linux 支持多种平台。无论你的电脑配置如何,你都可以在上 但是它为什么可靠呢,相比于 Mac OS,它的可靠体现在什么方面呢? -答案很简单——给用户更多的控制权,同时提供更好的安全性。在 Mac OS 上,你并不能完全控制它,这样做是为了让操作变得更容易,同时提高你的用户体验。使用 Linux,你可以做任何你想做的事情——这可能会导致(对某些人来说)糟糕的用户体验——但它确实使其更可靠。 +答案很简单 —— 给用户更多的控制权,同时提供更好的安全性。在 Mac OS 上,你并不能完全控制它,这样做是为了让操作变得更容易,同时提高你的用户体验。使用 Linux,你可以做任何你想做的事情 —— 这可能会导致(对某些人来说)糟糕的用户体验 —— 但它确实使其更可靠。 #### 7、开源 @@ -87,9 +87,9 @@ Linux 支持多种平台。无论你的电脑配置如何,你都可以在上 开源并不是每个人都关心的。但对我来说,Linux 最重要的优势在于它的开源特性。下面讨论的大多数观点都是开源软件的直接优势。 -简单解释一下,如果是开源软件,你可以自己查看或者修改它。但对 Mac 来说,苹果拥有独家控制权。即使你有足够的技术知识,也无法查看 Mac OS 的源代码。 +简单解释一下,如果是开源软件,你可以自己查看或者修改源代码。但对 Mac 来说,苹果拥有独家控制权。即使你有足够的技术知识,也无法查看 Mac OS 的源代码。 -形象点说,Mac 驱动的系统可以让你得到一辆车,但缺点是你不能打开引擎盖看里面是什么。那可能非常糟糕! +形象点说,Mac 驱动的系统可以让你得到一辆车,但缺点是你不能打开引擎盖看里面是什么。那可太差劲了! 如果你想深入了解开源软件的优势,可以在 OpenSource.com 上浏览一下 [Ben Balter 的文章][17]。 @@ -97,7 +97,7 @@ Linux 支持多种平台。无论你的电脑配置如何,你都可以在上 现在你应该知道为什么 Linux 比 Mac 好了吧,你觉得呢?上面的这些原因可以说服你选择 Linux 吗?如果不行的话那又是为什么呢? -在下方评论让我们知道你的想法。 +请在下方评论让我们知道你的想法。 提示:这里的图片是以企鹅俱乐部为原型的。 From e50f5e89a134abe8de90a8170637e7fec43ab8ce Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 18 Oct 2018 00:37:46 +0800 Subject: [PATCH 023/158] PRF:20181008 Python at the pump- A script for filling your gas tank.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @HankChow 翻译的很好,很有趣的文章 --- ...thon at the pump- A script for filling your gas tank.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/translated/tech/20181008 Python at the pump- A script for filling your gas tank.md b/translated/tech/20181008 Python at the pump- A script for filling your gas tank.md index 396ed17291..c555437541 100644 --- a/translated/tech/20181008 Python at the pump- A script for filling your gas tank.md +++ b/translated/tech/20181008 Python at the pump- A script for filling your gas tank.md @@ -1,6 +1,7 @@ 使用 Python 为你的油箱加油 ====== -我来介绍一下我是如何使用 Python 来节省成本的。 + +> 我来介绍一下我是如何使用 Python 来节省成本的。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bulb-light-energy-power-idea.png?itok=zTEEmTZB) @@ -82,7 +83,7 @@ while i < 21: # 20 次迭代 (加油次数) 如你所见,这个调整会令混合汽油号数始终略高于 91。当然,我的油量表并没有 1/12 的刻度,但是 7/12 略小于 5/8,我可以近似地计算。 -一个更简单地方案是每次都首先加满 93 号汽油,然后在油箱半满时加入 89 号汽油直到耗尽,这可能会是我的常规方案。但就我个人而言,这种方法并不太好,有时甚至会产生一些麻烦。但对于长途旅行来说,这种方案会相对简便一些。有时我也会因为油价突然下跌而购买一些汽油,所以,这个方案是我可以考虑的一系列选项之一。 +一个更简单地方案是每次都首先加满 93 号汽油,然后在油箱半满时加入 89 号汽油直到耗尽,这可能会是我的常规方案。就我个人而言,这种方法并不太好,有时甚至会产生一些麻烦。但对于长途旅行来说,这种方案会相对简便一些。有时我也会因为油价突然下跌而购买一些汽油,所以,这个方案是我可以考虑的一系列选项之一。 当然最重要的是:开车不写码,写码不开车! @@ -93,7 +94,7 @@ via: https://opensource.com/article/18/10/python-gas-pump 作者:[Greg Pittman][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 777e89e38ac0ac07b5b77055ac798e36cc7d31be Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 18 Oct 2018 00:38:20 +0800 Subject: [PATCH 024/158] PUB:20181008 Python at the pump- A script for filling your gas tank.md @HankChow https://linux.cn/article-10128-1.html --- ...1008 Python at the pump- A script for filling your gas tank.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20181008 Python at the pump- A script for filling your gas tank.md (100%) diff --git a/translated/tech/20181008 Python at the pump- A script for filling your gas tank.md b/published/20181008 Python at the pump- A script for filling your gas tank.md similarity index 100% rename from translated/tech/20181008 Python at the pump- A script for filling your gas tank.md rename to published/20181008 Python at the pump- A script for filling your gas tank.md From ed2a39daf7365c529e3adeddea0db574ec6e0e0e Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 18 Oct 2018 08:57:33 +0800 Subject: [PATCH 025/158] translated --- .../20180927 5 cool tiling window managers.md | 89 ------------------- .../20180927 5 cool tiling window managers.md | 87 ++++++++++++++++++ 2 files changed, 87 insertions(+), 89 deletions(-) delete mode 100644 sources/tech/20180927 5 cool tiling window managers.md create mode 100644 translated/tech/20180927 5 cool tiling window managers.md diff --git a/sources/tech/20180927 5 cool tiling window managers.md b/sources/tech/20180927 5 cool tiling window managers.md deleted file mode 100644 index 14da5f3479..0000000000 --- a/sources/tech/20180927 5 cool tiling window managers.md +++ /dev/null @@ -1,89 +0,0 @@ -translating---geekpi - -5 cool tiling window managers -====== - -![](https://fedoramagazine.org/wp-content/uploads/2018/09/tilingwindowmanagers-816x345.jpg) -The Linux desktop ecosystem offers multiple window managers (WMs). Some are developed as part of a desktop environment. Others are meant to be used as standalone application. This is the case of tiling WMs, which offer a more lightweight, customized environment. This article presents five such tiling WMs for you to try out. - -### i3 - -[i3][1] is one of the most popular tiling window managers. Like most other such WMs, i3 focuses on low resource consumption and customizability by the user. - -You can refer to [this previous article in the Magazine][2] to get started with i3 installation details and how to configure it. - -### sway - -[sway][3] is a tiling Wayland compositor. It has the advantage of compatibility with an existing i3 configuration, so you can use it to replace i3 and use Wayland as the display protocol. - -You can use dnf to install sway from Fedora repository: - -``` -$ sudo dnf install sway -``` - -If you want to migrate from i3 to sway, there’s a small [migration guide][4] available. - -### Qtile - -[Qtile][5] is another tiling manager that also happens to be written in Python. By default, you configure Qtile in a Python script located under ~/.config/qtile/config.py. When this script is not available, Qtile uses a default [configuration][6]. - -One of the benefits of Qtile being in Python is you can write scripts to control the WM. For example, the following script prints the screen details: - -``` -> from libqtile.command import Client -> c = Client() -> print(c.screen.info) -{'index': 0, 'width': 1920, 'height': 1006, 'x': 0, 'y': 0} -``` - -To install Qlite on Fedora, use the following command: - -``` -$ sudo dnf install qtile -``` - -### dwm - -The [dwm][7] window manager focuses more on being lightweight. One goal of the project is to keep dwm minimal and small. For example, the entire code base never exceeded 2000 lines of code. On the other hand, dwm isn’t as easy to customize and configure. Indeed, the only way to change dwm default configuration is to [edit the source code and recompile the application][8]. - -If you want to try the default configuration, you can install dwm in Fedora using dnf: - -``` -$ sudo dnf install dwm -``` - -For those who wand to change their dwm configuration, the dwm-user package is available in Fedora. This package automatically recompiles dwm using the configuration stored in the user home directory at ~/.dwm/config.h. - -### awesome - -[awesome][9] originally started as a fork of dwm, to provide configuration of the WM using an external configuration file. The configuration is done via Lua scripts, which allow you to write scripts to automate tasks or create widgets. - -You can check out awesome on Fedora by installing it like this: - -``` -$ sudo dnf install awesome -``` - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/5-cool-tiling-window-managers/ - -作者:[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 -[1]: https://i3wm.org/ -[2]: https://fedoramagazine.org/getting-started-i3-window-manager/ -[3]: https://swaywm.org/ -[4]: https://github.com/swaywm/sway/wiki/i3-Migration-Guide -[5]: http://www.qtile.org/ -[6]: https://github.com/qtile/qtile/blob/develop/libqtile/resources/default_config.py -[7]: https://dwm.suckless.org/ -[8]: https://dwm.suckless.org/customisation/ -[9]: https://awesomewm.org/ diff --git a/translated/tech/20180927 5 cool tiling window managers.md b/translated/tech/20180927 5 cool tiling window managers.md new file mode 100644 index 0000000000..22b9c455cb --- /dev/null +++ b/translated/tech/20180927 5 cool tiling window managers.md @@ -0,0 +1,87 @@ +5 个很酷的平铺窗口管理器 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/09/tilingwindowmanagers-816x345.jpg) +Linux 桌面生态中有多种窗口管理器 (WM)。有些是作为桌面环境的一部分开发的。有的则被用作独立程序。平铺 WM 就是这种情况,它提供了一个更轻量级的自定义环境。本文介绍了五种这样的平铺 WM 供你试用。 + +### i3 + +[i3][1] 是最受欢迎的平铺窗口管理器之一。与大多数其他此类 WM 一样,i3 专注于低资源消耗和用户可定制性。 + +您可以参考[Magazine 上的这篇文章][2]了解 i3 安装细节以及如何配置它。 + +### sway + +[sway][3] 是一个平铺 Wayland 合成器。它有与现有 i3 配置兼容的优点,因此你可以使用它来替换 i3 并使用 Wayland 作为显示协议。 + +您可以使用 dnf 从 Fedora 仓库安装 sway: + +``` +$ sudo dnf install sway +``` + +如果你想从 i3 迁移到 sway,这里有一个[迁移指南][4]。 + +### Qtile + +[Qtile][5] 是另一个平铺管理器,也恰好是用 Python 编写的。默认情况下,你在位于 ~/.config/qtile/config.py 下的 Python 脚本中配置 Qtile。当此脚本不存在时,Qtile 会使用默认[配置][6]。 + +Qtile 使用 Python 的一个好处是你可以编写脚本来控制 WM。例如,以下脚本打印屏幕详细信息: + +``` +> from libqtile.command import Client +> c = Client() +> print(c.screen.info) +{'index': 0, 'width': 1920, 'height': 1006, 'x': 0, 'y': 0} +``` + +要在 Fedora 上安装 Qlite,请使用以下命令: + +``` +$ sudo dnf install qtile +``` + +### dwm + +[dwm][7] 窗口管理器更侧重于轻量级。该项目的一个目标是保持 dwm 最小。例如,整个代码库从未超过 2000 行代码。另一方面,dwm 不容易定制和配置。实际上,改变 dwm 默认配置的唯一方法是[编辑源代码并重新编译程序][8]。 + +如果你想尝试默认配置,你可以使用 dnf 在 Fedora 中安装 dwm: + +``` +$ sudo dnf install dwm +``` + +对于那些想要改变 dwm 配置的人,Fedora 中有一个 dwm-user 包。该软件包使用用户主目录中 ~/.dwm/config.h 的配置自动重新编译 dwm。 + +### awesome + +[awesome][9] 最初是作为 dwm 的一个分支开发,使用外部配置文件提供 WM 的配置。配置通过 Lua 脚本完成,这些脚本允许你编写脚本以自动执行任务或创建 widget。 + +你可以使用这个命令在 Fedora 上安装 awesome: + +``` +$ sudo dnf install awesome +``` + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/5-cool-tiling-window-managers/ + +作者:[Clément Verna][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 +[1]: https://i3wm.org/ +[2]: https://fedoramagazine.org/getting-started-i3-window-manager/ +[3]: https://swaywm.org/ +[4]: https://github.com/swaywm/sway/wiki/i3-Migration-Guide +[5]: http://www.qtile.org/ +[6]: https://github.com/qtile/qtile/blob/develop/libqtile/resources/default_config.py +[7]: https://dwm.suckless.org/ +[8]: https://dwm.suckless.org/customisation/ +[9]: https://awesomewm.org/ From 74751b6d3a0fc7b6f11ea63dc7d4cf86d0cb8e57 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 18 Oct 2018 09:00:33 +0800 Subject: [PATCH 026/158] translating --- ...181015 Running Linux containers as a non-root with Podman.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20181015 Running Linux containers as a non-root with Podman.md b/sources/tech/20181015 Running Linux containers as a non-root with Podman.md index 3a86e502b2..4bf8f7c407 100644 --- a/sources/tech/20181015 Running Linux containers as a non-root with Podman.md +++ b/sources/tech/20181015 Running Linux containers as a non-root with Podman.md @@ -1,3 +1,5 @@ +translating---geekpi + Running Linux containers as a non-root with Podman ====== From 27551973da82e659ae521d81ddff473b3d00a669 Mon Sep 17 00:00:00 2001 From: David Chen Date: Thu, 18 Oct 2018 15:10:44 +0800 Subject: [PATCH 027/158] Translated. --- sources/tech/20180823 CLI- improved.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sources/tech/20180823 CLI- improved.md b/sources/tech/20180823 CLI- improved.md index b3056e6146..05ffb2318e 100644 --- a/sources/tech/20180823 CLI- improved.md +++ b/sources/tech/20180823 CLI- improved.md @@ -2,9 +2,9 @@ 命令行:增强版 ====== -我不确定有多少Web 开发者能完全逃避使用命令行。就我来说,我从1997年上大学就开始使用命令行了,那时l33t-hacker 让我着迷,同时我也觉得它很难掌握。 +我不确定有多少Web 开发者能完全逃避使用命令行。就我来说,我从1997年上大学就开始使用命令行了,那时的l33t-hacker 让我着迷,同时我也觉得它很难掌握。 -过去这些年我的命令行本领在逐步加强,我经常会去搜寻在我工作中能使用的更好的命令行工具。下面就是我现在使用的增强原有命令行工具的列表。 +过去这些年我的命令行本领在逐步加强,我经常会去搜寻在我工作中能使用的更好的命令行工具。下面就是我现在使用的用于增强原有命令行工具的列表。 ### 怎么忽略我所做的命令行增强 @@ -12,7 +12,7 @@ 通常情况下我会用别名将新的或者增强的命令行工具链接到原来的命令行(如`cat`和`ping`)。 -如果我需要运行原来的命令的话(有时我确实需要这么做),我能像下面这样来运行未加修改的原来的命令行。(我用的是Mac, 你的输出可能不一样) +如果我需要运行原来的命令的话(有时我确实需要这么做),我会像下面这样来运行未加修改的原来的命令行。(我用的是Mac,你的输出可能不一样) ``` @@ -92,7 +92,7 @@ export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort'" 方便的热键绑定包括: - * P - CPU 使用率排序 + * P - CPU使用率排序 * M - 内存使用排序 * F4 - 用字符串过滤进程(例如只看包括"node"的进程) * space - 锚定一个单独进程,这样我能观察它是否有尖峰状态 @@ -100,7 +100,7 @@ export FZF_DEFAULT_OPTS="--bind='ctrl-o:execute(code {})+abort'" ![htop output][10] -在Mac Sieera 上htop 有个奇怪的bug,不过可以通过以root 运行来绕过(我实在记不清这个bug 是什么,但是这个别名能搞定它,有点讨厌的是我得每次都输入 root 密码。): +在Mac Sieera 上htop 有个奇怪的bug,不过这个bug可以通过以root运行来绕过(我实在记不清这个bug 是什么,但是这个别名能搞定它,有点讨厌的是我得每次都输入root密码。): ``` @@ -111,7 +111,7 @@ alias top="sudo htop" # 给top加上别名并且绕过 Sieera 上的bug ### diff-so-fancy > diff -我非常确定我是一些年前从 Paul Irish 那儿学来的这个技巧,尽管我很少直接使用`diff`,但我的git命令行会一直使用`diff`。`diff-so-fancy`给了我代码颜色和更改字符高亮的功能。 +我非常确定我是一些年前从 Paul Irish 那儿学来的这个技巧,尽管我很少直接使用`diff`,但我的git命令行会一直使用`diff`。`diff-so-fancy`给了我代码语法颜色和更改字符高亮的功能。 ![diff so fancy][12] @@ -158,7 +158,7 @@ $ fd cli -x wc -w # 搜索"cli"并且在每个搜索结果上运行`wc -w` 对我来说,知道当前的磁盘空间使用是非常重要的任务。我用过 Mac 上的[Dish Daisy][17],但是我觉得那个程序产生结果有点慢。 -`du -sh`命令是我经常会跑的命令(`-sh`是指结果以总结和人类可读的方式显示),我经常会想要深入挖掘那些占用了大量磁盘空间的目录。 +`du -sh`命令是我经常会跑的命令(`-sh`是指结果以`总结`和`人类可读`的方式显示),我经常会想要深入挖掘那些占用了大量磁盘空间的目录,看看到底是什么在占用空间。 `ncdu`是一个非常棒的替代品。它提供了一个交互式的界面并且允许快速的扫描那些占用了大量磁盘空间的目录和文件,它又快又准。(尽管不管在哪个工具的情况下,扫描我的home目录都要很长时间,它有550G) @@ -194,7 +194,7 @@ alias du="ncdu --color dark -rr -x --exclude .git --exclude node_modules" 几乎所有的单独命令行工具都有一个相伴的手册,其可以被`man <命令名>`来调出,但是在`man`的输出里找到东西可有点让人困惑,而且在一个包含了所有的技术细节的输出里找东西也挺可怕的。 -这就是TL;DR(译注:英文里`文档太长,没空去读`的缩写)项目的初衷。这个一个由社区驱动的文档系统,而且针对的是命令行。就我现在用下来,我还没碰到过一个命令它没有相应的文档,你[也可以做贡献][22]. +这就是TL;DR(译注:英文里`文档太长,没空去读`的缩写)项目创建的初衷。这是一个由社区驱动的文档系统,而且针对的是命令行。就我现在用下来,我还没碰到过一个命令它没有相应的文档,你[也可以做贡献][22]。 ![TLDR output for 'fd'][23] @@ -210,10 +210,10 @@ alias help='tldr' ### ack || ag > grep -`grep`毫无疑问是一个命令行上的强力工具,但是这些年来它已经被一些工具超越了。其中两个叫`ack`和`ag`。 +`grep`毫无疑问是一个命令行上的强力工具,但是这些年来它已经被一些工具超越了,其中两个叫`ack`和`ag`。 -就我个人来说`ack`和`ag`都尝试过,并没有非常明显的个人偏好,(那也就是说他们都很棒,并且很相似)。我倾向于默认只使用`ack`,因为这三个字符就在指尖,很好打。并且,`ack`有大量的`ack --`参数可以使用,(你一定会体会到这一点。) +我个人对`ack`和`ag`都尝试过,而且没有非常明显的个人偏好,(那也就是说他们都很棒,并且很相似)。我倾向于默认只使用`ack`,因为这三个字符就在指尖,很好打。并且,`ack`有大量的`ack --`参数可以使用,(你一定会体会到这一点。) `ack`和`ag`都将使用正则表达式来表达搜索,这非常契合我的工作,我能指定搜索的文件类型而不用使用类似于`--js`或`--html`的文件标识(尽管`ag`比`ack`在文件类型过滤器里包括了更多的文件类型。) From be4faa02c1dc764becd9e2a5d164803f2d6cd16d Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 18 Oct 2018 15:34:40 +0800 Subject: [PATCH 028/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Chrony=20?= =?UTF-8?q?=E2=80=93=20An=20Alternative=20NTP=20Client=20And=20Server=20Fo?= =?UTF-8?q?r=20Unix-like=20Systems?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Client And Server For Unix-like Systems.md | 226 ++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 sources/tech/20181017 Chrony - An Alternative NTP Client And Server For Unix-like Systems.md diff --git a/sources/tech/20181017 Chrony - An Alternative NTP Client And Server For Unix-like Systems.md b/sources/tech/20181017 Chrony - An Alternative NTP Client And Server For Unix-like Systems.md new file mode 100644 index 0000000000..9f1d3f05be --- /dev/null +++ b/sources/tech/20181017 Chrony - An Alternative NTP Client And Server For Unix-like Systems.md @@ -0,0 +1,226 @@ +Chrony – An Alternative NTP Client And Server For Unix-like Systems +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/10/chrony-1-720x340.jpeg) + +In this tutorial, we will be discussing how to install and configure **Chrony** , an alternative NTP client and server for Unix-like systems. Chrony can synchronise the system clock faster with better time accuracy and it can be particularly useful for the systems which are not online all the time. Chrony is free, open source and supports GNU/Linux and BSD variants such as FreeBSD, NetBSD, macOS, and Solaris. + +### Installing Chrony + +Chrony is available in the default repositories of most Linux distributions. If you’re on Arch Linux, run the following command to install it: + +``` +$ sudo pacman -S chrony +``` + +On Debian, Ubuntu, Linux Mint: + +``` +$ sudo apt-get install chrony +``` + +On Fedora: + +``` +$ sudo dnf install chrony +``` + +Once installed, start **chronyd.service** daemon if it is not started already: + +``` +$ sudo systemctl start chronyd.service +``` + +Make it to start automatically on every reboot using command: + +``` +$ sudo systemctl enable chronyd.service +``` + +To verify if the Chronyd.service has been started, run: + +``` +$ sudo systemctl status chronyd.service +``` + +If everything is OK, you will see an output something like below. + +``` +● chrony.service - chrony, an NTP client/server +Loaded: loaded (/lib/systemd/system/chrony.service; enabled; vendor preset: ena +Active: active (running) since Wed 2018-10-17 10:34:53 UTC; 3min 15s ago +Docs: man:chronyd(8) +man:chronyc(1) +man:chrony.conf(5) +Main PID: 2482 (chronyd) +Tasks: 1 (limit: 2320) +CGroup: /system.slice/chrony.service +└─2482 /usr/sbin/chronyd + +Oct 17 10:34:53 ubuntuserver systemd[1]: Starting chrony, an NTP client/server... +Oct 17 10:34:53 ubuntuserver chronyd[2482]: chronyd version 3.2 starting (+CMDMON +Oct 17 10:34:53 ubuntuserver chronyd[2482]: Initial frequency -268.088 ppm +Oct 17 10:34:53 ubuntuserver systemd[1]: Started chrony, an NTP client/server. +Oct 17 10:35:03 ubuntuserver chronyd[2482]: Selected source 85.25.84.166 +Oct 17 10:35:03 ubuntuserver chronyd[2482]: Source 85.25.84.166 replaced with 2403 +Oct 17 10:35:03 ubuntuserver chronyd[2482]: Selected source 91.189.89.199 +Oct 17 10:35:06 ubuntuserver chronyd[2482]: Selected source 106.10.186.200 +``` + +As you can see, Chrony service is started and working! + +### Configure Chrony + +The NTP clients needs to know which NTP servers it should contact to get the current time. We can specify the NTP servers in the **server** or **pool** directive in the NTP configuration file. Usually, the default configuration file is **/etc/chrony/chrony.conf** or **/etc/chrony.conf** depending upon the Linux distribution version. For better reliability, it is recommended to specify at least three servers. + +The following lines are just an example taken from my Ubuntu 18.04 LTS server. + +``` +[...] +# About using servers from the NTP Pool Project in general see (LP: #104525). +# Approved by Ubuntu Technical Board on 2011-02-08. +# See http://www.pool.ntp.org/join.html for more information. +pool ntp.ubuntu.com iburst maxsources 4 +pool 0.ubuntu.pool.ntp.org iburst maxsources 1 +pool 1.ubuntu.pool.ntp.org iburst maxsources 1 +pool 2.ubuntu.pool.ntp.org iburst maxsources 2 +[...] +``` + +As you see in the above output, [**NTP Pool Project**][1] has been set as the default time server. For those wondering, NTP pool project is the cluster of time servers that provides NTP service for tens of millions clients across the world. It is the default time server for Ubuntu and most of the other major Linux distributions. + +Here, + + * the **iburst** option is used to speed up the initial synchronisation. + * the **maxsources** refers the maximum number of NTP sources. + + + +Please make sure that the NTP servers you have chosen are well synchronised, stable and close to your location to improve the accuracy of the time with NTP sources. + +### Manage Chronyd from command line + +Chrony has a command line utility named **chronyc** to control and monitor the **chrony** daemon (chronyd). + +To check if **chrony** is synchronized, we can use the **tracking** command as shown below. + +``` +$ chronyc tracking +Reference ID : 6A0ABAC8 (t1.time.sg3.yahoo.com) +Stratum : 3 +Ref time (UTC) : Wed Oct 17 11:48:51 2018 +System time : 0.000984587 seconds slow of NTP time +Last offset : -0.000912981 seconds +RMS offset : 0.007983995 seconds +Frequency : 23.704 ppm slow +Residual freq : +0.006 ppm +Skew : 1.734 ppm +Root delay : 0.089718960 seconds +Root dispersion : 0.008760406 seconds +Update interval : 515.1 seconds +Leap status : Normal +``` + +We can verify the current time sources that chrony uses with command: + +``` +$ chronyc sources +210 Number of sources = 8 +MS Name/IP address Stratum Poll Reach LastRx Last sample +=============================================================================== +^- chilipepper.canonical.com 2 10 377 296 +102ms[ +104ms] +/- 279ms +^- golem.canonical.com 2 10 377 302 +105ms[ +107ms] +/- 290ms +^+ pugot.canonical.com 2 10 377 297 +36ms[ +38ms] +/- 238ms +^- alphyn.canonical.com 2 10 377 279 -43ms[ -42ms] +/- 238ms +^- dadns.cdnetworks.co.kr 2 10 377 1070 +40ms[ +42ms] +/- 314ms +^* t1.time.sg3.yahoo.com 2 10 377 169 -13ms[ -11ms] +/- 80ms +^+ sin1.m-d.net 2 10 275 567 -9633us[-7826us] +/- 115ms +^- ns2.pulsation.fr 2 10 377 311 -75ms[ -73ms] +/- 250ms +``` + +Chronyc utility can find the statistics of each sources, such as drift rate and offset estimation process, using **sourcestats** command. + +``` +$ chronyc sourcestats +210 Number of sources = 8 +Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev +============================================================================== +chilipepper.canonical.com 32 16 89m +6.293 14.345 +30ms 24ms +golem.canonical.com 32 17 89m +0.312 18.887 +20ms 33ms +pugot.canonical.com 32 18 89m +0.281 11.237 +3307us 23ms +alphyn.canonical.com 31 20 88m -4.087 8.910 -58ms 17ms +dadns.cdnetworks.co.kr 29 16 76m -1.094 9.895 -83ms 14ms +t1.time.sg3.yahoo.com 32 16 91m +0.153 1.952 +2835us 4044us +sin1.m-d.net 29 13 83m +0.049 6.060 -8466us 9940us +ns2.pulsation.fr 32 17 88m +0.784 9.834 -62ms 22ms +``` + +If your system is not connected to Internet, you need to notify Chrony that the system is not connected to the Internet. To do so, run: + +``` +$ sudo chronyc offline +[sudo] password for sk: +200 OK +``` + +To verify the status of your NTP sources, simply run: + +``` +$ chronyc activity +200 OK +0 sources online +8 sources offline +0 sources doing burst (return to online) +0 sources doing burst (return to offline) +0 sources with unknown address +``` + +As you see, all my NTP sources are down at the moment. + +Once you’re connected to the Internet, just notify Chrony that your system is back online using command: + +``` +$ sudo chronyc online +200 OK +``` + +To view the status of NTP source(s), run: + +``` +$ chronyc activity +200 OK +8 sources online +0 sources offline +0 sources doing burst (return to online) +0 sources doing burst (return to offline) +0 sources with unknown address +``` + +For more detailed explanation of all options and parameters, refer the man pages. + +``` +$ man chronyc + +$ man chronyd +``` + +And, that’s all for now. Hope this was useful. In the subsequent tutorials, we will see how to setup a local NTP server using Chrony and configure the clients to use it to synchronise time. + +Stay tuned! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/chrony-an-alternative-ntp-client-and-server-for-unix-like-systems/ + +作者:[SK][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ntppool.org/en/ From 71940909a2ed55873399352c6c307afd9f8f271a Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 18 Oct 2018 15:42:50 +0800 Subject: [PATCH 029/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20piwheels:=20Speed?= =?UTF-8?q?y=20Python=20package=20installation=20for=20the=20Raspberry=20P?= =?UTF-8?q?i?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ckage installation for the Raspberry Pi.md | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 sources/tech/20181016 piwheels- Speedy Python package installation for the Raspberry Pi.md diff --git a/sources/tech/20181016 piwheels- Speedy Python package installation for the Raspberry Pi.md b/sources/tech/20181016 piwheels- Speedy Python package installation for the Raspberry Pi.md new file mode 100644 index 0000000000..a50f5d71d7 --- /dev/null +++ b/sources/tech/20181016 piwheels- Speedy Python package installation for the Raspberry Pi.md @@ -0,0 +1,87 @@ +piwheels: Speedy Python package installation for the Raspberry Pi +====== +https://opensource.com/article/18/10/piwheels-python-raspberrypi + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rainbow-pinwheel-piwheel-diversity-inclusion.png?itok=di41Wd3V) + +One of the great things about the Python programming language is [PyPI][1], the Python Package Index, where third-party libraries are hosted, available for anyone to install and gain access to pre-existing functionality without starting from scratch. These libraries are handy utilities, written by members of the community, that aren't found within the Python standard library. But they work in much the same way—you import them into your code and have access to functions and classes you didn't write yourself. + +### The cross-platform problem + +Many of the 150,000+ libraries hosted on PyPI are written in Python, but that's not the only option—you can write Python libraries in C, C++, or anything with Python bindings. The usual benefit of writing a library in C or C++ is speed. The NumPy project is a good example: NumPy provides highly powerful mathematical functionality for dealing with matrix operations. It is highly optimized code that allows users to write in Python but have access to speedy mathematics operations. + +The problem comes when trying to distribute libraries for others to use cross-platform. The standard is to create built distributions called Python wheels. While pure Python libraries are automatically compatible cross-platform, those implemented in C/C++ must be built separately for each operating system, Python version, and system architecture. So, if a library wanted to support Windows, MacOS, and Linux, for both 32-bit and 64-bit computers, and for Python 2.7, 3.4, 3.5, and 3.6, that would require 24 different versions! Some packages do this, but others rely on users building the package from the source code, which can take a long time and can often be complex. + +### Raspberry Pi and Arm + +While the Raspberry Pi runs Linux, it's not the same architecture as your regular PC—it's Arm, rather than Intel. That means the Linux wheels don't work, and Raspberry Pi users had to build from source—until the piwheels project came to fruition last year. [Piwheels][2] is an open source project that aims to build Raspberry Pi platform wheels for every package on PyPI. + +![](https://opensource.com/sites/default/files/uploads/pi3b.jpg) + +Packages are natively compiled on Raspberry Pi 3 hardware and hosted in a data center provided by UK-based [Mythic Beasts][3], which provides cloud Pis as part of its hosting service. The piwheels website hosts the wheels in a [pip][4]-compatible web server configuration so Raspberry Pi users can use them easily. Raspbian Stretch even comes preconfigured to use piwheels.org as an additional index to PyPI by default. + +### The piwheels stack + +The piwheels project runs (almost) entirely on Raspberry Pi hardware: + + * **Master** + * A Raspberry Pi web server hosts the wheel files and distributes jobs to the builder Pis. + * **Database server** + * All package information is stored in a [Postgres database][5]. + * The master logs build attempts and downloads. + * **Builders** + * Builder Pis are given build jobs to attempt, and they communicate with the database. + * The backlog of packages on PyPI was completed using around 20 Raspberry Pis. + * A smaller number of Pis is required to keep up with new releases. Currently, there are three with Raspbian Jessie (Python 3.4) and two with Raspbian Stretch (Python 3.5). + + + +The database server was originally a Raspberry Pi but was moved to another server when the database got too large. + +![](https://opensource.com/sites/default/files/uploads/piwheels-stack.png) + +### Time saved + +Around 500,000 packages are downloaded from piwheels.org every month. + +Every time a package is built by piwheels or downloaded by a user, its status information (including build duration) is recorded in a database. Therefore, it's possible to calculate how much time has been saved with pre-compiled packages. + +In the 10 months that the service has been running, over 25 years of build time has been saved. + +### Great for projects + +Raspberry Pi project tutorials requiring Python libraries often include warnings like "this step takes a few hours"—but that's no longer true, thanks to piwheels. Piwheels makes it easy for makers and developers to dive straight into their project and not get bogged down waiting for software to install. Amazing libraries are just a **pip install** away; no need to wait for compilation. + +Piwheels has wheels for NumPy, SciPy, OpenCV, Keras, and even [Tensorflow][6], Google's machine learning framework. These libraries are great for [home projects][7], including image and facial recognition with the [camera module][8]. For inspiration, take a look at the Raspberry Pi category on [PyImageSearch][9] (which is one of my [favorite Raspberry Pi blogs][10]) to follow. + +![](https://opensource.com/sites/default/files/uploads/camera_0.jpg) + +Read more about piwheels on the project's [blog][11] and the [Raspberry Pi blog][12], see the [source code on GitHub][13], and check out the [piwheels website][2]. If you want to contribute to the project, check the [missing packages tag][14] and see if you can successfully build one of them. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/piwheels-python-raspberrypi + +作者:[Ben Nuttall][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://pypi.org/ +[2]: https://www.piwheels.org/ +[3]: https://www.mythic-beasts.com/order/rpi +[4]: https://en.wikipedia.org/wiki/Pip_(package_manager) +[5]: https://opensource.com/article/17/10/set-postgres-database-your-raspberry-pi +[6]: https://www.tensorflow.org/ +[7]: https://opensource.com/article/17/4/5-projects-raspberry-pi-home +[8]: https://opensource.com/life/15/6/raspberry-pi-camera-projects +[9]: https://www.pyimagesearch.com/category/raspberry-pi/ +[10]: https://opensource.com/article/18/8/top-10-raspberry-pi-blogs-follow +[11]: https://blog.piwheels.org/ +[12]: https://www.raspberrypi.org/blog/piwheels/ +[13]: https://github.com/bennuttall/piwheels +[14]: https://github.com/bennuttall/piwheels/issues?q=is%3Aissue+is%3Aopen+label%3A%22missing+package%22 From 56f11ee39b8f839514434949c2be5deb6f0c7297 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 18 Oct 2018 15:44:16 +0800 Subject: [PATCH 030/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Browsing=20the=20?= =?UTF-8?q?web=20with=20Min,=20a=20minimalist=20open=20source=20web=20brow?= =?UTF-8?q?ser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...n, a minimalist open source web browser.md | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 sources/tech/20181017 Browsing the web with Min, a minimalist open source web browser.md diff --git a/sources/tech/20181017 Browsing the web with Min, a minimalist open source web browser.md b/sources/tech/20181017 Browsing the web with Min, a minimalist open source web browser.md new file mode 100644 index 0000000000..4bf7fee547 --- /dev/null +++ b/sources/tech/20181017 Browsing the web with Min, a minimalist open source web browser.md @@ -0,0 +1,80 @@ +Browsing the web with Min, a minimalist open source web browser +====== +Not every web browser needs to carry every single feature. Min puts a minimalist spin on the everyday web browser. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openweb-osdc-lead.png?itok=yjU4KliG) + +Does the world need another web browser? Even though the days of having a multiplicity of browsers to choose from are long gone, there still are folks out there developing new applications that help us use the web. + +One of those new-fangled browsers is [Min][1]. As its name suggests (well, suggests to me, anyway), Min is a minimalist browser. That doesn't mean it's deficient in any significant way, and its open source, Apache 2.0 license piques my interest. + +But is Min worth a look? Let's find out. + +### Getting going + +Min is one of many applications written using a development framework called [Electron][2]. (It's the same framework that brought us the [Atom text editor][3].) You can [get installers][4] for Linux, MacOS, and Windows. You can also grab the [source code from GitHub][5] and compile it if you're inclined. + +I run Manjaro Linux, and there isn't an installer for that distro. Luckily, I was able to install Min from Manjaro's package manager. + +Once that was done, I fired up Min by pressing Alt+F2, typing **min** in the run-application box, and pressing Enter, and I was ready to go. + +![](https://opensource.com/sites/default/files/uploads/min-main.png) + +Min is billed as a smarter, faster web browser. It definitely is fast—at the risk of drawing the ire of denizens of certain places on the web, I'll say that it starts faster than Firefox and Chrome on the laptops with which I tried it. + +Browsing with Min is like browsing with Firefox or Chrome. Type a URL in the address bar, press Enter, and away you go. + +### Min's features + +While Min doesn't pack everything you'd find in browsers like Firefox or Chrome, it doesn't do too badly. + +Like any other browser these days, Min supports multiple tabs. It also has a feature called Tasks, which lets you group your open tabs. + +Min's default search engine is [DuckDuckGo][6]. I really like that touch because DuckDuckGo is one of my search engines of choice. If DuckDuckGo isn't your thing, you can set another search engine as the default in Min's preferences. + +Instead of using tools like AdBlock to filter out content you don't want, Min has a built-in ad blocker. It uses the [EasyList filters][7], which were created for AdBlock. You can block scripts and images, and Min also has a built-in tracking blocker. + +Like Firefox, Min has a reading mode called Reading List. Flipping the Reading List switch (well, clicking the icon in the address bar) removes most of the cruft from a page so you can focus on the words you're reading. Pages stay in the Reading List for 30 days. + +![](https://opensource.com/sites/default/files/uploads/min-reading-list.png) + +Speaking of focus, Min also has a Focus Mode that hides and prevents you from opening other tabs. So, if you're working in a web application, you'll need to click a few times if you feel like procrastinating. + +Of course, Min has a number of keyboard shortcuts that can make using it a lot faster. You can find a reference for those shortcuts [on GitHub][8]. You can also change a number of them in Min's preferences. + +I was pleasantly surprised to find Min can play videos on YouTube, Vimeo, Dailymotion, and similar sites. I also played sample tracks at music retailer 7Digital. I didn't try playing music on popular sites like Spotify or Last.fm (because I don't have accounts with them). + +![](https://opensource.com/sites/default/files/uploads/min-video.png) + +### What's not there + +The features that Min doesn't pack are as noticeable as the ones it does. There doesn't seem to be a way to bookmark sites. You either have to rely on Min's search history to find your favorite links, or you'll have to rely on a bookmarking service. + +On top of that, Min doesn't support plugins. That's not a deal breaker for me—not having plugins is undoubtedly one of the reasons the browser starts and runs so quickly. I know a number of people who are … well, I wouldn't go so far to say junkies, but they really like their plugins. Min wouldn't cut it for them. + +### Final thoughts + +Min isn't a bad browser. It's light and fast enough to appeal to the minimalists out there. That said, it lacks features that hardcore web browser users clamor for. + +If you want a zippy browser that isn't weighed down by all the features of so-called modern web browsers, I suggest giving Min a serious look. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/min-web-browser + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[b]: https://github.com/lujun9972 +[1]: https://minbrowser.github.io/min/ +[2]: http://electron.atom.io/apps/ +[3]: https://opensource.com/article/17/5/atom-text-editor-packages-writers +[4]: https://github.com/minbrowser/min/releases/ +[5]: https://github.com/minbrowser/min +[6]: http://duckduckgo.com +[7]: https://easylist.to/ +[8]: https://github.com/minbrowser/min/wiki From b74fc9f42f7cc77e4ff2629ede18df49bec915c1 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 18 Oct 2018 15:47:28 +0800 Subject: [PATCH 031/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Automating=20upst?= =?UTF-8?q?ream=20releases=20with=20release-bot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ting upstream releases with release-bot.md | 327 ++++++++++++++++++ 1 file changed, 327 insertions(+) create mode 100644 sources/tech/20181017 Automating upstream releases with release-bot.md diff --git a/sources/tech/20181017 Automating upstream releases with release-bot.md b/sources/tech/20181017 Automating upstream releases with release-bot.md new file mode 100644 index 0000000000..7543af8981 --- /dev/null +++ b/sources/tech/20181017 Automating upstream releases with release-bot.md @@ -0,0 +1,327 @@ +Automating upstream releases with release-bot +====== +All you need to do is file an issue into your upstream repository and release-bot takes care of the rest. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_robots.png?itok=TOZgajrd) + +If you own or maintain a GitHub repo and have ever pushed a package from it into [PyPI][1] and/or [Fedora][2], you know it requires some additional work using the Fedora infrastructure. + +Good news: We have developed a tool called [release-bot][3] that automates the process. All you need to do is file an issue into your upstream repository and release-bot takes care of the rest. But let’s not get ahead of ourselves. First, let’s look at what needs to be set up for this automation to happen. I’ve chosen the **meta-test-family** upstream repository as an example. + +### Configuration files for release-bot + +There are two configuration files for release-bot: **conf.yaml** and **release-conf.yaml**. + +#### conf.yaml + +**conf.yaml** must be accessible during bot initialization; it specifies how to access the GitHub repository. To show that, I have created a new git repository named **mtf-release-bot** , which contains **conf.yaml** and the other secret files. + +``` +repository_name: name +repository_owner: owner +# https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/ +github_token: xxxxxxxxxxxxxxxxxxxxxxxxx +# time in seconds during checks for new releases +refresh_interval: 180 +``` + +For the meta-test-family case, the configuration file looks like this: + +``` +repository_name: meta-test-family +repository_owner: fedora-modularity +github_token: xxxxxxxxxxxxxxxxxxxxx +refresh_interval: 180 +``` + +#### release-conf.yaml + +**release-conf.yaml** must be stored [in the repository itself][4]; it specifies how to do GitHub/PyPI/Fedora releases. + +``` +# list of major python versions that bot will build separate wheels for +python_versions: +  - 2 +  - 3 +# optional: +changelog: +  - Example changelog entry +  - Another changelog entry +# this is info for the authorship of the changelog +# if this is not set, person who merged the release PR will be used as an author +author_name: John Doe +author_email: johndoe@example.com +# whether to release on fedora. False by default +fedora: false +# list of fedora branches bot should release on. Master is always implied +fedora_branches: +  - f27 +``` + +For the meta-test-family case, the configuration file looks like this: + +``` +python_versions: +-       2 +fedora: true +fedora_branches: +-       f29 +-       f28 +trigger_on_issue: true +``` + +#### PyPI configuration file + +The file **.pypirc** , stored in your **mtf-release-bot** private repository, is needed for uploading the new package version into PyPI: + +``` +[pypi] +username = phracek +password = xxxxxxxx +``` + +Private SSH key, **id_rsa** , that you configured in [FAS][5]. + +The final structure of the git repository, with **conf.yaml** and the others, looks like this: + +``` +$ ls -la +total 24 +drwxrwxr-x   3 phracek phracek 4096 Sep 24 12:38 . +drwxrwxr-x. 20 phracek phracek 4096 Sep 24 12:37 .. +-rw-rw-r--   1 phracek phracek  199 Sep 24 12:26 conf.yaml +drwxrwxr-x   8 phracek phracek 4096 Sep 24 12:38 .git +-rw-rw-r--   1 phracek phracek 3243 Sep 24 12:38 id_rsa +-rw-------   1 phracek phracek   78 Sep 24 12:28 .pypirc +``` + +### Requirements + +**requirements.txt** with both versions of pip. You must also set up your PyPI login details in **$HOME/.pypirc** , as described in the `-k/–keytab`. Also, **fedpkg** requires that you have an SSH key in your keyring that you uploaded to FAS. + +### How to deploy release-bot + +Releasing to PyPI requires the [wheel package][6] for both Python 2 and Python 3, so installwith both versions of pip. You must also set up your PyPI login details in, as described in the [PyPI documentation][7] . If you are releasing to Fedora, you must have an active [Kerberos][8] ticket while the bot runs, or specify the path to the Kerberos keytab file with. Also,requires that you have an SSH key in your keyring that you uploaded to FAS. + +There are two ways to use release-bot: as a Docker image or as an OpenShift template. + +#### Docker image + +Let’s build the image using the `s2i` command: + +``` +$ s2i build $CONFIGURATION_REPOSITORY_URL usercont/release-bot app-name +``` + +where `$CONFIGURATION_REPOSITORY_URL` is a reference to the GitHub repository, like _https:// /mtf-release-conf._ + +Let’s look at Docker images: + +``` +$ docker images +REPOSITORY                                      TAG                     IMAGE ID                CREATED                 SIZE +mtf-release-bot                         latest                  08897871e65e            6 minutes ago           705 MB +docker.io/usercont/release-bot                  latest                  5b34aa670639            9 days ago              705 MB +``` + +Now let’s try to run the **mtf-release-bot** image with this command: + +``` +$ docker run mtf-release-bot +---> Setting up ssh key... +Agent pid 12 +Identity added: ./.ssh/id_rsa (./.ssh/id_rsa) +12:21:18.982 configuration.py  DEBUG  Loaded configuration for fedora-modularity/meta-test-family +12:21:18.982 releasebot.py      INFO   release-bot v0.4.1 reporting for duty! +12:21:18.982 github.py          DEBUG  Fetching release-conf.yaml +12:21:37.611 releasebot.py      DEBUG  No merged release PR found +12:21:38.282 releasebot.py      INFO   Found new release issue with version: 0.8.5 +12:21:42.565 releasebot.py      DEBUG  No more open issues found +12:21:43.190 releasebot.py      INFO   Making a new PR for release of version 0.8.5 based on an issue. +12:21:46.709 utils.py           DEBUG  ['git', 'clone', 'https://github.com/fedora-modularity/meta-test-family.git', '.'] + +12:21:47.401 github.py          DEBUG  {"message":"Branch not found","documentation_url":"https://developer.github.com/v3/repos/branches/#get-branch"} +12:21:47.994 utils.py           DEBUG  ['git', 'config', 'user.email', 'the.conu.bot@gmail.com'] + +12:21:47.996 utils.py           DEBUG  ['git', 'config', 'user.name', 'Release bot'] + +12:21:48.009 utils.py           DEBUG  ['git', 'checkout', '-b', '0.8.5-release'] + +12:21:48.014 utils.py           ERROR  No version files found. Aborting version update. +12:21:48.014 utils.py           WARNING No CHANGELOG.md present in repository +[Errno 2] No such file or directory: '/tmp/tmpmbvb05jq/CHANGELOG.md' +12:21:48.020 utils.py           DEBUG  ['git', 'commit', '--allow-empty', '-m', '0.8.5 release'] +[0.8.5-release 7ee62c6] 0.8.5 release + +12:21:51.342 utils.py           DEBUG  ['git', 'push', 'origin', '0.8.5-release'] + +12:21:51.905 github.py          DEBUG  No open PR's found +12:21:51.905 github.py          DEBUG  Attempting a PR for 0.8.5-release branch +12:21:53.215 github.py          INFO   Created PR: https://github.com/fedora-modularity/meta-test-family/pull/243 +12:21:53.216 releasebot.py      INFO   I just made a PR request for a release version 0.8.5 +12:21:54.154 github.py          DEBUG  Comment added to PR: I just made a PR request for a release version 0.8.5 + Here's a [link to the PR](https://github.com/fedora-modularity/meta-test-family/pull/243) +12:21:54.154 github.py          DEBUG  Attempting to close issue #242 +12:21:54.992 github.py          DEBUG  Closed issue #242 +``` + +As you can see, release-bot automatically closed the following issue, requesting a new upstream release of the meta-test-family: [https://github.com/fedora-modularity/meta-test-family/issues/243][9]. + +In addition, release-bot created a new PR with changelog. You can update the PR—for example, squash changelog—and once you merge it, it will automatically release to GitHub, and PyPI and Fedora will start. + +You now have a working solution to easily release upstream versions of your package into PyPi and Fedora. + +#### OpenShift template + +Another option to deliver automated releases using release-bot is to deploy it in OpenShift. + +The OpenShift template looks as follows: + +``` +kind: Template +apiVersion: v1 +metadata: +  name: release-bot +  annotations: +    description: S2I Relase-bot image builder +    tags: release-bot s2i +    iconClass: icon-python +labels: +  template: release-bot +  role: releasebot_application_builder +objects: +  - kind : ImageStream +    apiVersion : v1 +    metadata : +        name : ${APP_NAME} +        labels : +          appid : release-bot-${APP_NAME} +  - kind : ImageStream +    apiVersion : v1 +    metadata : +      name : ${APP_NAME}-s2i +      labels : +        appid : release-bot-${APP_NAME} +    spec : +      tags : +        - name : latest +          from : +            kind : DockerImage +            name : usercont/release-bot:latest +         #importPolicy: +         #  scheduled: true +  - kind : BuildConfig +    apiVersion : v1 +    metadata : +      name : ${APP_NAME} +      labels : +        appid : release-bot-${APP_NAME} +    spec : +      triggers : +        - type : ConfigChange +        - type : ImageChange +      source : +        type : Git +        git : +          uri : ${CONFIGURATION_REPOSITORY} +          contextDir : ${CONFIGURATION_REPOSITORY} +        sourceSecret : +          name : release-bot-secret +      strategy : +        type : Source +        sourceStrategy : +          from : +            kind : ImageStreamTag +            name : ${APP_NAME}-s2i:latest +      output : +        to : +          kind : ImageStreamTag +          name : ${APP_NAME}:latest +  - kind : DeploymentConfig +    apiVersion : v1 +    metadata : +      name: ${APP_NAME} +      labels : +        appid : release-bot-${APP_NAME} +    spec : +      strategy : +        type : Rolling +      triggers : +         - type : ConfigChange +         - type : ImageChange +           imageChangeParams : +             automatic : true +             containerNames : +               - ${APP_NAME} +             from : +               kind : ImageStreamTag +               name : ${APP_NAME}:latest +      replicas : 1 +      selector : +        deploymentconfig : ${APP_NAME} +      template : +        metadata : +          labels : +            appid: release-bot-${APP_NAME} +            deploymentconfig : ${APP_NAME} +        spec : +          containers : +            - name : ${APP_NAME} +              image : ${APP_NAME}:latest +              resources: +                requests: +                  memory: "64Mi" +                  cpu: "50m" +                limits: +                  memory: "128Mi" +                  cpu: "100m" + +parameters : +  - name : APP_NAME +    description : Name of application +    value : +    required : true +  - name : CONFIGURATION_REPOSITORY +    description : Git repository with configuration +    value : +    required : true +``` + +The easiest way to deploy the **mtf-release-bot** repository with secret files into OpenShift is to use the following two commands: + +``` +$ curl -sLO https://github.com/user-cont/release-bot/raw/master/openshift-template.yml +``` + +In your OpenShift instance, deploy the template by running the following command: + +``` +oc process -p APP_NAME="mtf-release-bot" -p CONFIGURATION_REPOSITORY="git@/mtf-release-conf.git" -f openshift-template.yml | oc apply +``` + +### Summary + +See the [example pull request][10] in the meta-test-family upstream repository, where you'll find information about what release-bot released. Once you get to this point, you can see that release-bot is able to push new upstream versions into GitHub, PyPI, and Fedora without heavy user intervention. It automates all the steps so you don’t need to manually upload and build new upstream versions of your package. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/upstream-releases-pypi-fedora-release-bot + +作者:[Petr Stone Hracek][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/phracek +[b]: https://github.com/lujun9972 +[1]: https://pypi.org/ +[2]: https://getfedora.org/ +[3]: https://github.com/user-cont/release-bot +[4]: https://github.com/fedora-modularity/meta-test-family +[5]: https://admin.fedoraproject.org/accounts/ +[6]: https://pypi.org/project/wheel/ +[7]: https://packaging.python.org/tutorials/distributing-packages/#create-an-account +[8]: https://web.mit.edu/kerberos/ +[9]: https://github.com/fedora-modularity/meta-test-family/issues/238 +[10]: https://github.com/fedora-modularity/meta-test-family/pull/243 From d6fd48e57c555bedc6b5c52cf49e370c1058b788 Mon Sep 17 00:00:00 2001 From: darksun Date: Thu, 18 Oct 2018 15:48:43 +0800 Subject: [PATCH 032/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20An=20introduction?= =?UTF-8?q?=20to=20Ansible=20Operators=20in=20Kubernetes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tion to Ansible Operators in Kubernetes.md | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 sources/tech/20181015 An introduction to Ansible Operators in Kubernetes.md diff --git a/sources/tech/20181015 An introduction to Ansible Operators in Kubernetes.md b/sources/tech/20181015 An introduction to Ansible Operators in Kubernetes.md new file mode 100644 index 0000000000..a7d8fd86e7 --- /dev/null +++ b/sources/tech/20181015 An introduction to Ansible Operators in Kubernetes.md @@ -0,0 +1,81 @@ +An introduction to Ansible Operators in Kubernetes +====== +The new Operator SDK makes it easy to create a Kubernetes controller to deploy and manage a service or application in a cluster. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_barnraising_2.png?itok=JOBMbjTM) + +For years, Ansible has been a go-to choice for infrastructure automation. As Kubernetes adoption has skyrocketed, Ansible has continued to shine in the emerging container orchestration ecosystem. + +Ansible fits naturally into a Kubernetes workflow, using YAML to describe the desired state of the world. Multiple projects, including the [Automation Broker][1], are adapting Ansible for use behind specific APIs. This article will focus on a new technique, created through a joint effort by the Ansible core team and the developers of Automation Broker, that uses Ansible to create Operators with minimal effort. + +### What is an Operator? + +An [Operator][2] is a Kubernetes controller that deploys and manages a service or application in a cluster. It automates human operation knowledge and best practices to keep services running and healthy. Input is received in the form of a custom resource. Let's walk through that using a Memcached Operator as an example. + +The [Memcached Operator][3] can be deployed as a service running in a cluster, and it includes a custom resource definition (CRD) for a resource called Memcached. The end user creates an instance of that custom resource to describe how the Memcached Deployment should look. The following example requests a Deployment with three Pods. + +``` +apiVersion: "cache.example.com/v1alpha1" +kind: "Memcached" +metadata: +  name: "example-memcached" +spec: +  size: 3 +``` + +The Operator's job is called reconciliation—continuously ensuring that what is specified in the "spec" matches the real state of the world. This sample Operator delegates Pod management to a Deployment controller. So while it does not directly create or delete Pods, if you change the size, the Operator's reconciliation loop ensures that the new value is applied to the Deployment resource it created. + +A mature Operator can deploy, upgrade, back up, repair, scale, and reconfigure an application that it manages. As you can see, not only does an Operator provide a simple way to deploy arbitrary services using only native Kubernetes APIs; it enables full day-two (post-deployment, such as updates, backups, etc.) management, limited only by what you can code. + +### Creating an Operator + +The [Operator SDK][4] makes it easy to get started. It lays down the skeleton of a new Operator with many of the complex pieces already handled. You can focus on defining your custom resources and coding the reconciliation logic in Go. The SDK saves you a lot of time and ongoing maintenance burden, but you will still end up owning a substantial software project. + +Ansible was recently introduced to the Operator SDK as an even simpler way to make an Operator, with no coding required. To create an Operator, you merely: + + * Create a CRD in the form of YAML + * Define what reconciliation should do by creating an Ansible role or playbook + + + +It's YAML all the way down—a familiar experience for Kubernetes users. + +### How does it work? + +There is a preexisting Ansible Operator base container image that includes Ansible, [ansible-runner][5], and the Operator's executable service. The SDK helps to build a layer on top that adds one or more CRDs and associates each with an Ansible role or playbook. + +When it's running, the Operator uses a Kubernetes feature to "watch" for changes to any resource of the type defined. Upon receiving such a notification, it reconciles the resource that changed. The Operator runs the corresponding role or playbook, and information about the resource is passed to Ansible as [extra-vars][6]. + +### Using Ansible with Kubernetes + +Following several iterations, the Ansible community has produced a remarkably easy-to-use module for working with Kubernetes. Especially if you have any experience with a Kubernetes module prior to Ansible 2.6, you owe it to yourself to have a look at the [k8s module][7]. Creating, retrieving, and updating resources is a natural experience that will feel familiar to any Kubernetes user. It makes creating an Operator that much easier. + +### Give it a try + +If you need to build a Kubernetes Operator, doing so with Ansible could save time and complexity. To learn more, head over to the Operator SDK documentation and work through the [Getting Started Guide][8] for Ansible-based Operators. Then join us on the [Operator Framework mailing list][9] and let us know what you think. + +Michael Hrivnak will present [Automating Multi-Service Deployments on Kubernetes][10] at [LISA18][11], October 29-31 in Nashville, Tennessee, USA. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/ansible-operators-kubernetes + +作者:[Michael Hrivnak][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mhrivnak +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/article/18/2/automated-provisioning-kubernetes +[2]: https://coreos.com/operators/ +[3]: https://github.com/operator-framework/operator-sdk-samples/tree/master/memcached-operator +[4]: https://github.com/operator-framework/operator-sdk/ +[5]: https://github.com/ansible/ansible-runner +[6]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#passing-variables-on-the-command-line +[7]: https://docs.ansible.com/ansible/2.6/modules/k8s_module.html +[8]: https://github.com/operator-framework/operator-sdk/blob/master/doc/ansible/user-guide.md +[9]: https://groups.google.com/forum/#!forum/operator-framework +[10]: https://www.usenix.org/conference/lisa18/presentation/hrivnak +[11]: https://www.usenix.org/conference/lisa18 From b39279a7d37b736af4c217a62ee99d078e620ee8 Mon Sep 17 00:00:00 2001 From: hopefully2333 <787016457@qq.com> Date: Thu, 18 Oct 2018 18:36:36 +0800 Subject: [PATCH 033/158] translated over translated over --- ...es on Fedora with Steam Play and Proton.md | 48 +++++++++---------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/sources/tech/20181008 Play Windows games on Fedora with Steam Play and Proton.md b/sources/tech/20181008 Play Windows games on Fedora with Steam Play and Proton.md index 16930083fd..8f3a5a38c5 100644 --- a/sources/tech/20181008 Play Windows games on Fedora with Steam Play and Proton.md +++ b/sources/tech/20181008 Play Windows games on Fedora with Steam Play and Proton.md @@ -1,61 +1,59 @@ -translating by hopefully2333 - -Play Windows games on Fedora with Steam Play and Proton +在 Fedora 上使用 Steam play 和 Proton 来玩 Windows 游戏 ====== ![](https://fedoramagazine.org/wp-content/uploads/2018/09/steam-proton-816x345.jpg) -Some weeks ago, Steam [announced][1] a new addition to Steam Play with Linux support for Windows games using Proton, a fork from WINE. This capability is still in beta, and not all games work. Here are some more details about Steam and Proton. +几周前,Steam 宣布要给 Steam Play 增加一个新组件,用于支持在 Linux 平台上使用 Proton 来玩 Windows 的游戏,这个组件是 WINE 的一个分支。这个功能仍然处于测试阶段,且并非对所有游戏都有效。这里有一些关于 Steam 和 Proton 的细节。 -According to the Steam website, there are new features in the beta release: +据 Steam 网站称,测试版本中有以下这些新功能: - * Windows games with no Linux version currently available can now be installed and run directly from the Linux Steam client, complete with native Steamworks and OpenVR support. - * DirectX 11 and 12 implementations are now based on Vulkan, which improves game compatibility and reduces performance impact. - * Fullscreen support has been improved. Fullscreen games seamlessly stretch to the desired display without interfering with the native monitor resolution or requiring the use of a virtual desktop. - * Improved game controller support. Games automatically recognize all controllers supported by Steam. Expect more out-of-the-box controller compatibility than even the original version of the game. - * Performance for multi-threaded games has been greatly improved compared to vanilla WINE. + * 现在没有 Linux 版本的 Windows 游戏可以直接从 Linux 上的 Steam 客户端进行安装和运行,并且有完整、原生的 Steamworks 和 OpenVR 的支持。 + * 现在 DirectX 11 和 12 的实现都基于 Vulkan,它可以提高游戏的兼容性并减小游戏性能收到的影响。 + * 全屏支持已经得到了改进,全屏游戏时可以无缝扩展到所需的显示程度,而不会干扰到显示屏本身的分辨率或者说需要使用虚拟桌面。 + * 改进了对游戏控制器的支持,游戏自动识别所有 Steam 支持的控制器,比起游戏的原始版本,能够获得更多开箱即用的控制器兼容性。 + * 和 vanilla WINE 比起来,游戏的多线程性能得到了极大的提高。 -### Installation +### 安装 -If you’re interested in trying Steam with Proton out, just follow these easy steps. (Note that you can ignore the first steps to enable the Steam Beta if you have the [latest updated version of Steam installed][2]. In that case you no longer need Steam Beta to use Proton.) +如果你有兴趣,想尝试一下 Steam 和 Proton。请按照下面这些简单的步骤进行操作。(请注意,如果你已经安装了最新版本的 Steam,可以忽略启用 Steam 测试版这个第一步。在这种情况下,你不再需要通过 Steam 测试版来使用 Proton。) -Open up Steam and log in to your account. This example screenshot shows support for only 22 games before enabling Proton. +打开 Steam 并登陆到你的帐户,这个截屏示例显示的是在使用 Proton 之前仅支持22个游戏。 ![][3] -Now click on Steam option on top of the client. This displays a drop down menu. Then select Settings. +现在点击客户端顶部的 Steam 选项,这会显示一个下拉菜单。然后选择设置。 ![][4] -Now the settings window pops up. Select the Account option and next to Beta participation, click on change. +现在弹出了设置窗口,选择账户选项,并在 Beta participation 旁边,点击更改。 ![][5] -Now change None to Steam Beta Update. +现在将 None 更改为 Steam Beta Update。 ![][6] -Click on OK and a prompt asks you to restart. +点击确定,然后系统会提示你重新启动。 ![][7] -Let Steam download the update. This can take a while depending on your internet speed and computer resources. +让 Steam 下载更新,这会需要一段时间,具体需要多久这要取决于你的网络速度和电脑配置。 ![][8] -After restarting, go back to the Settings window. This time you’ll see a new option. Make sure the check boxes for Enable Steam Play for supported titles, Enable Steam Play for all titles and Use this tool instead of game-specific selections from Steam are enabled. The compatibility tool should be Proton. +在重新启动之后,返回到上面的设置窗口。这次你会看到一个新选项。确定有为提供支持的游戏使用 Stream Play 这个复选框,让所有的游戏都使用 Steam Play 进行运行,而不是 steam 中游戏特定的选项。兼容性工具应该是 Proton。 ![][9] -The Steam client asks you to restart. Do so, and once you log back into your Steam account, your game library for Linux should be extended. +Steam 客户端会要求你重新启动,照做,然后重新登陆你的 Steam 账户,你的 Linux 的游戏库就能得到扩展了。 ![][10] -### Installing a Windows game using Steam Play +### 使用 Steam Play 来安装一个 Windows 游戏 -Now that you have Proton enabled, install a game. Select the title you want and you’ll find the process is similar to installing a normal game on Steam, as shown in these screenshots. +现在你已经启用 Proton,开始安装游戏,选择你想要安装的游戏,然后你会发现这个安装过程类似于在 Steam 上安装一个普通游戏,如下面这些截图所示。 ![][11] @@ -65,13 +63,13 @@ Now that you have Proton enabled, install a game. Select the title you want and ![][14] -After the game is done downloading and installing, you can play it. +在下载和安装完游戏后,你就可以开始玩了。 ![][15] ![][16] -Some games may be affected by the beta nature of Proton. The game in this example, Chantelise, had no audio and a low frame rate. Keep in mind this capability is still in beta and Fedora is not responsible for results. If you’d like to read further, the community has created a [Google doc][17] with a list of games that have been tested. +一些游戏可能会受到 Proton 测试性质的影响,在下面这个叫 Chantelise 游戏中,没有了声音并且帧率很低。请记住这个功能仍然在测试阶段,Fedora 不会对结果负责。如果你想要了解更多,社区已经创建了一个 Google 文档,这个文档里有已经测试过的游戏的列表。 -------------------------------------------------------------------------------- @@ -80,7 +78,7 @@ via: https://fedoramagazine.org/play-windows-games-steam-play-proton/ 作者:[Francisco J. Vergara Torres][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:[hopefully2333](https://github.com/hopefully2333) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From deab798046883591c47fa629c5ba5cad6b79c4a8 Mon Sep 17 00:00:00 2001 From: LuMing <784315443@qq.com> Date: Thu, 18 Oct 2018 18:40:29 +0800 Subject: [PATCH 034/158] translating --- .../tech/20180723 Setting Up a Timer with systemd in Linux.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180723 Setting Up a Timer with systemd in Linux.md b/sources/tech/20180723 Setting Up a Timer with systemd in Linux.md index 27841dec61..1718f4fbde 100644 --- a/sources/tech/20180723 Setting Up a Timer with systemd in Linux.md +++ b/sources/tech/20180723 Setting Up a Timer with systemd in Linux.md @@ -1,3 +1,4 @@ +LuuMing translating Setting Up a Timer with systemd in Linux ====== From 2f48d8ea1db1d5243b4638ecbe439daf74fd3f64 Mon Sep 17 00:00:00 2001 From: ypingcn <1344632698@qq.com> Date: Thu, 18 Oct 2018 19:57:43 +0800 Subject: [PATCH 035/158] Create 20180921 Control your data with Syncthing- An open source synchronization tool.md --- ...ng- An open source synchronization tool.md | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 translated/tech/20180921 Control your data with Syncthing- An open source synchronization tool.md diff --git a/translated/tech/20180921 Control your data with Syncthing- An open source synchronization tool.md b/translated/tech/20180921 Control your data with Syncthing- An open source synchronization tool.md new file mode 100644 index 0000000000..869e596f89 --- /dev/null +++ b/translated/tech/20180921 Control your data with Syncthing- An open source synchronization tool.md @@ -0,0 +1,111 @@ +使用 Syncthing —— 一个开源同步工具来把握你数据的控制权 + +决定如何存储和共享您的个人信息。 + +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus_cloud_database.png?itok=lhhU42fg) + +如今,我们的一些最重要的财产——从家人和朋友的照片和视频到财务和医疗文件——都是数据。 +即便是云存储服务的迅猛发展,我们仍有对隐私和个人数据缺乏控制的担忧。从 PRISM 的监控计划到谷歌[让 APP 开发者扫描你的个人邮件][1],这些新闻的报道应该会让我们对我们个人信息的安全性有所顾虑。 + +[Syncthing][2] 可以让你放下心来。它是一款开源点对点的文件同步工具,可以运行在Linux、Windows、Mac、Android和其他 (抱歉,没有iOS)。Syncthing 使用自定的协议,叫[块交换协议](3)。简而言之,Syncting 能让你无需拥有服务器来跨设备同步数据,。 + +### Linux + +在这篇文章中,我将解释如何在 Linux 电脑和安卓手机之间安装和同步文件。 + +Syncting 在大多数流行的发行版都能下载。Fedora 28 包含其最新版本。 + +要在 Fedora 上安装 Syncthing,你能在软件中心搜索,或者执行以下命令: + +``` +sudo dnf install syncthing syncthing-gtk +``` + +一旦安装好后,打开它。你将会看到一个助手帮你配置 Syncthing。点击 **下一步** 直到它要求配置 WebUI。最安全的选项是选择**监听本地地址**。那将会禁止 Web 接口并且阻止未经授权的用户。 + +![Syncthing in Setup WebUI dialog box][5] + +Syncthing 安装时的 WebUI 对话框 + +关闭对话框。现在 Syncthing 安装好了。是时间分享一个文件夹,连接一台设备开始同步了。但是,让我们用你其他的客户端继续。 + +### Android + +Syncthing 在 Google Play 和 F-Droid 应用商店都能下载 + +![](https://opensource.com/sites/default/files/uploads/syncthing2.png) + +安装应用程序后,会显示欢迎界面。给 Syncthing 授予你设备存储的权限。 +你可能会被要求为了此应用程序而禁用电池优化。这样做是安全的,因为我们将优化应用程序,使其仅在插入并连接到无线网络时同步。 + +点击主菜单图标来到**设置**,然后是**运行条件**。点击**总是在后台运行**, **仅在充电时运行**和**仅在 WIFI 下运行**。现在你的安卓客户端已经准备好与你的设备交换文件。 + +Syncting 中有两个重要的概念需要记住:文件夹和设备。文件夹是你想要分享的,但是你必须有一台设备来分享。 Syncthing 允许你用不同的设备分享独立的文件夹。设备是通过交换设备 ID 来添加的。设备ID是在 Syncting 首次启动时创建的一个唯一的密码安全标识符。 + +### 连接设备 + +现在让我们连接你的Linux机器和你的Android客户端。 + +在您的Linux计算机中,打开 Syncting,单击 **设置** 图标,然后单击 **显示ID** ,就会显示一个二维码。 + +在你的安卓手机上,打开 Syncthing。在主界面上,点击 **设备** 页后点击 **+** 。在第一个区域内点击二维码符号来启动二维码扫描。 + +将你手机的摄像头对准电脑上的二维码。设备ID字段将由您的桌面客户端设备 ID 填充。起一个适合的名字并保存。因为添加设备有两种方式,现在你需要在电脑客户端上确认你想要添加安卓手机。你的电脑客户端可能会花上好几分钟来请求确认。当提示确认时,点击**添加**。 + +![](https://opensource.com/sites/default/files/uploads/syncthing6.png) + +在 **新设备** 窗口,你能确认并配置一些关于你设备的选项,像是**设备名** 和 **地址**。如果你在地址那一栏选择 dynamic (动态),客户端将会自动探测设备的 IP 地址,但是你想要保持住某一个 IP 地址,你能将该地址填进这一栏里。如果你已经创建了文件夹(或者在这之后),你也能与新设备分享这个文件夹。 + +![](https://opensource.com/sites/default/files/uploads/syncthing7.png) + +你的电脑和安卓设备已经配对,可以交换文件了。(如果你有多台电脑或手机,只需重复这些步骤。) + +### 分享文件夹 + +既然您想要同步的设备之间已经连接,现在是时候共享一个文件夹了。您可以在电脑上共享文件夹,添加了该文件夹中的设备将获得一份副本。 + +若要共享文件夹,请转至**设置**并单击**添加共享文件夹**: + +![](https://opensource.com/sites/default/files/uploads/syncthing8.png) + +在下一个窗口中,输入要共享的文件夹的信息: + +![](https://opensource.com/sites/default/files/uploads/syncthing9.png) + +你可以使用任何你想要的标签。**文件夹ID **将随机生成,用于识别客户端之间的文件夹。在**路径**里,点击**浏览**就能定位到你想要分享的文件夹。如果你想 Syncthing 监控文件夹的变化(例如删除,新建文件等),点击** 监控文件系统变化** + +记住,当你分享一个文件夹,在其他客户端的任何改动都将会反映到每一台设备上。这意味着如果你在其他电脑和手机设备之间分享了一个包含图片的文件夹,在这些客户端上的改动都会同步到每一台设备。如果这不是你想要的,你能让你的文件夹“只是发送"给其他客户端,但是其他客户端的改动都不会被同步。 + +完成后,转至**与设备共享**页并选择要与之同步文件夹的主机: + +您选择的所有设备都需要接受共享请求;您将在设备上收到通知。 + +正如共享文件夹时一样,您必须配置新的共享文件夹: + +![](https://opensource.com/sites/default/files/uploads/syncthing12.png) + +同样,在这里您可以定义任何标签,但是 ID 必须匹配每个客户端。在文件夹选项中,选择文件夹及其文件的位置。请记住,此文件夹中所做的任何更改都将反映到文件夹所允许同步的每个设备上。 + +这些是连接设备和与 Syncting 共享文件夹的步骤。开始复制可能需要几分钟时间,这取决于您的网络设置或您是否不在同一网络上。 + +Syncting 提供了更多出色的功能和选项。试试看,并把握你数据的控制权。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/take-control-your-data-syncthing + +作者:[Michael Zamot][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]: 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 09bb2374efe08cc303520238d95d4026bc68cdb6 Mon Sep 17 00:00:00 2001 From: ypingcn <1344632698@qq.com> Date: Thu, 18 Oct 2018 19:58:27 +0800 Subject: [PATCH 036/158] Delete 20180921 Control your data with Syncthing- An open source synchronization tool.md --- ...ng- An open source synchronization tool.md | 110 ------------------ 1 file changed, 110 deletions(-) delete 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 deleted file mode 100644 index 97aa36801b..0000000000 --- a/sources/tech/20180921 Control your data with Syncthing- An open source synchronization tool.md +++ /dev/null @@ -1,110 +0,0 @@ -translating by ypingcn - -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 70cde9dd13fddbd62c9a990f20ca459cf7a2ceda Mon Sep 17 00:00:00 2001 From: David Chen Date: Thu, 18 Oct 2018 20:23:46 +0800 Subject: [PATCH 037/158] Translated. --- {sources => translated}/tech/20180823 CLI- improved.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {sources => translated}/tech/20180823 CLI- improved.md (100%) diff --git a/sources/tech/20180823 CLI- improved.md b/translated/tech/20180823 CLI- improved.md similarity index 100% rename from sources/tech/20180823 CLI- improved.md rename to translated/tech/20180823 CLI- improved.md From 8e1845d974e82699ff7ca848cfaa296fa3d16870 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 18 Oct 2018 20:50:39 +0800 Subject: [PATCH 038/158] PRF:20181002 How use SSH and SFTP protocols on your home network.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @singledo 翻译应该更用心一些。 --- ...and SFTP protocols on your home network.md | 37 ++++++++----------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/translated/tech/20181002 How use SSH and SFTP protocols on your home network.md b/translated/tech/20181002 How use SSH and SFTP protocols on your home network.md index db202a3043..3eb4ac5fe1 100644 --- a/translated/tech/20181002 How use SSH and SFTP protocols on your home network.md +++ b/translated/tech/20181002 How use SSH and SFTP protocols on your home network.md @@ -1,62 +1,57 @@ 如何在家中使用 SSH 和 SFTP 协议 ====== -通过 SSH 和 SFTP 协议 ,我们能够访问其他设备 ,有效而且安全的传输文件及更多 。 +> 通过 SSH 和 SFTP 协议,我们能够访问其他设备,有效而且安全的传输文件等等。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/openwires_fromRHT_520_0612LL.png?itok=PqZi55Ab) -多年前 ,我决定配置一个额外的电脑 ,以便我能在工作时能够访问它来传输我所需要的文件 。最基本的一步是要求你的网络提供商 ( ISP )提供一个固定的地址 ( IP Address )。 +几年前,我决定配置另外一台电脑,以便我能在工作时访问它来传输我所需要的文件。要做到这一点,最基本的一步是要求你的网络提供商(ISP)提供一个固定的地址。 -保证你系统的访问是安全的 ,这是一个不必要但很重要的步骤 。在此种特殊情况下 ,我计划只在工作的时候能够访问它 。所以我能够约束访问的 IP 地址 。即使如此 ,你依然要尽多的采用安全措施 。一旦你建立起来这个 ,全世界的人们都能立即访问你的系统 。这是非常令人惊奇及恐慌的 。你能通过日志文件来发现这一点 。我推测有探测机器人在尽它们所能的搜索那些没有安全措施的系统 。 +有一个不必要但很重要的步骤,就是保证你的这个可以访问的系统是安全的。在我的这种情况下,我计划只在工作场所访问它,所以我能够限定访问的 IP 地址。即使如此,你依然要尽多的采用安全措施。一旦你建立起来这个系统,全世界的人们马上就能尝试访问你的系统。这是非常令人惊奇及恐慌的。你能通过日志文件来发现这一点。我推测有探测机器人在尽其所能的搜索那些没有安全措施的系统。 -在我建立系统不久后 ,我觉得我的访问是一个简单的玩具而不是我想要的 ,为此 ,我将它关闭了好让我不在为它而担心 。尽管如此 ,这个系统在家庭网络中对于 SSH 和 SFTP 还有其他的用途 ,它至少已经为你而创建了 。 +在我设置好系统不久后,我觉得这种访问没什么大用,为此,我将它关闭了以便不再为它操心。尽管如此,只要架设了它,在家庭网络中使用 SSH 和 SFTP 还是有点用的。 -一个必备条件 ,你家的另一台电脑必须已经开机了 ,至于电脑是否已经非常老旧是没有影响的 。你也需要知道另一台电脑的 IP 地址 。有两个方法能够知道做到 ,一个是通过网页进入你的路由器 ,一般情况下你的地址格式类似于 **192.168.1.254** 。通过一些搜索 ,找出当前是开机的并且和系统 eth0 或者 wifi 挂钩的系统是足够简单的 。如何组织你所敢兴趣的电脑是一个挑战 。 +当然,有一个必备条件,这个另外的电脑必须已经开机了,至于电脑是否登录与否无所谓的。你也需要知道其 IP 地址。有两个方法能够知道,一个是通过浏览器访问你的路由器,一般情况下你的地址格式类似于 192.168.1.254 这样。通过一些搜索,很容易找出当前是开机的并且接在 eth0 或者 wifi 上的系统。如何识别你所要找到的电脑可能是个挑战。 -询问电脑问题是简单的 ,打开 shell ,输入 : +更容易找到这个电脑的方式是,打开 shell,输入 : ``` ifconfig - ``` -命令会输出一些信息 ,你所需要的信息在 `inet` 后面 ,看起来和 **192.168.1.234** 类似 。当你发现这个后 ,回到你的客户端电脑 ,在命令行中输入 : +命令会输出一些信息,你所需要的信息在 `inet` 后面,看起来和 192.168.1.234 类似。当你发现这个后,回到你要访问这台主机的客户端电脑,在命令行中输入 : ``` ssh gregp@192.168.1.234 - ``` -上面的命令能够正常执行 ,**gregp** 必须在主机系统中是中确的用户名 。用户的密码也会被需要 。如果你键入的密码和用户名都是正确的 ,你将通过 shell 环境连接上了其他电脑 。我坦诚 ,对于 SSH 我并不是经常使用的 。我偶尔使用它 ,所以我能够运行 `dnf` 来更新我就坐的其他电脑 。通常 ,我用 SFTP : +如果要让上面的命令能够正常执行,`gregp` 必须是该主机系统中正确的用户名。你会被询问其密码。如果你键入的密码和用户名都是正确的,你将通过 shell 环境连接上了这台电脑。我坦诚,对于 SSH 我并不是经常使用的。我偶尔使用它,我能够运行 `dnf` 来更新我所常使用电脑之外的其它电脑。通常,我用 SFTP : ``` sftp grego@192.168.1.234 - ``` -对于用更简单的方法来把一个文件传输到另一个文件 ,我有很强烈的需求 。相对于闪存棒和额外的设备 ,它更加方便 ,耗时更少 。 +我更需要用简单的方法来把一个文件传输到另一个电脑。相对于闪存棒和额外的设备,它更加方便,耗时更少。 -一旦连接建立成功 ,SFTP 有两个基本的命令 ,`get` ,从主机接收文件 ;`put` ,向主机发送文件 。在客户端 ,我经常移动到我想接收或者传输的文件夹下 ,在开始连接之前 。在连接之后 ,你将在顶层目录 **home/gregp** 。一旦连接成功 ,你将和在客户端一样的使用 `cd` ,除非在主机上你改变了你的工作路径 。你会需要用 `ls` 来确认你的位置 。 +一旦连接建立成功,SFTP 有两个基本的命令,`get`,从主机接收文件 ;`put`,向主机发送文件。在连接之前,我经常在客户端移动到我想接收或者传输的文件夹下。在连接之后,你将处于一个顶层目录里,比如 `home/gregp`。一旦连接成功,你可以像在客户端一样的使用 `cd`,改变你在主机上的工作路径。你也许需要用 `ls` 来确认你的位置。 -在客户端 ,如果你想改变工作路劲 。用 `lcd` 命令 ( **local change directory**)。相同的 ,用 `lls` 来显示客户端工作目录的内容 。 +如果你想改变你的客户端的工作目录。用 `lcd` 命令( 即 local change directory 的意思)。同样的,用 `lls` 来显示客户端工作目录的内容。 -如果你不喜欢主机工作目录的名字时 ,你该怎么办 ?用 `mkdir` 在主机上创建一个新的文件夹 。或者将整个文件全拷贝到主机 : +如果主机上没有你想要的目录名,你该怎么办?用 `mkdir` 在主机上创建一个新的目录。或者你可以将整个目录的文件全拷贝到主机 : ``` put -r thisDir/ - ``` -在主机上创建文件夹和传输文件以及子文件夹是非常快速的 ,能达到硬件的上限 。在网络传输的过程中不会遇到瓶颈 。查看 SFTP 能够使用的功能 ,查看 : +这将在主机上创建该目录并复制它的全部文件和子目录到主机上。这种传输是非常快速的,能达到硬件的上限。不像在互联网传输一样遇到网络瓶颈。要查看你能在 SFTP 会话中能够使用的命令列表: ``` man sftp - ``` -在我的电脑上我也可以在 windows 虚拟机上用 SFTP ,另一个优势是配置一个虚拟机而不是一个双系统 。这让我能够在系统的 Linux 部分移入或者移出文件 。到目前为止 ,我只用了 windows 的客户端 。 +我也能够在我的电脑上的 Windows 虚拟机内用 SFTP,这是配置一个虚拟机而不是一个双系统的另外一个优势。这让我能够在系统的 Linux 部分移入或者移出文件。而我只需要在 Windows 中使用一个客户端就行。 -你能够进入到任何通过无线或者 WIFI 连接到你路由器的设备 。暂时 ,我使用一个叫做 [SSHDroid][1] 的应用 ,能够在被动模式下运行 SSH 。换句话来说 ,你能够用你的电脑访问作为主机的 Android 设备 。近来我还发现了另外一个应用 ,[Admin Hands][2] ,不管你的客户端是桌面还是手机 ,都能使用 SSH 或者 SFTP 操作 。这个应用对于备份和手机分享照片是极好的 。 +你能够使用 SSH 或 SFTP 访问通过网线或者 WIFI 连接到你路由器的任何设备。这里,我使用了一个叫做 [SSHDroid][1] 的应用,能够在被动模式下运行 SSH。换句话来说,你能够用你的电脑访问作为主机的 Android 设备。近来我还发现了另外一个应用,[Admin Hands][2],不管你的客户端是平板还是手机,都能使用 SSH 或者 SFTP 操作。这个应用对于备份和手机分享照片是极好的。 -------------------------------------------------------------------------------- @@ -65,7 +60,7 @@ via: https://opensource.com/article/18/10/ssh-sftp-home-network 作者:[Geg Pittman][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[singledo](https://github.com/singledo) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 20d500a0125a3b1dacee63957a065bb5a9476b7d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Thu, 18 Oct 2018 20:51:05 +0800 Subject: [PATCH 039/158] PUB:20181002 How use SSH and SFTP protocols on your home network.md @singledo https://linux.cn/article-10129-1.html --- ...0181002 How use SSH and SFTP protocols on your home network.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20181002 How use SSH and SFTP protocols on your home network.md (100%) diff --git a/translated/tech/20181002 How use SSH and SFTP protocols on your home network.md b/published/20181002 How use SSH and SFTP protocols on your home network.md similarity index 100% rename from translated/tech/20181002 How use SSH and SFTP protocols on your home network.md rename to published/20181002 How use SSH and SFTP protocols on your home network.md From f685c13af89a901f25d7fef544a65173c6d9a018 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Thu, 18 Oct 2018 22:38:00 +0800 Subject: [PATCH 040/158] Translated by qhwdw --- ...ide [Explained with Practical Examples].md | 1030 ----------------- ...ide [Explained with Practical Examples].md | 1029 ++++++++++++++++ 2 files changed, 1029 insertions(+), 1030 deletions(-) delete mode 100644 sources/tech/20180615 Complete Sed Command Guide [Explained with Practical Examples].md create mode 100644 translated/tech/20180615 Complete Sed Command Guide [Explained with Practical Examples].md diff --git a/sources/tech/20180615 Complete Sed Command Guide [Explained with Practical Examples].md b/sources/tech/20180615 Complete Sed Command Guide [Explained with Practical Examples].md deleted file mode 100644 index d2c50b6029..0000000000 --- a/sources/tech/20180615 Complete Sed Command Guide [Explained with Practical Examples].md +++ /dev/null @@ -1,1030 +0,0 @@ -Translating by qhwdw -Complete Sed Command Guide [Explained with Practical Examples] -====== -In a previous article, I showed the [basic usage of Sed][1], the stream editor, on a practical use case. Today, be prepared to gain more insight about Sed as we will take an in-depth tour of the sed execution model. This will be also an opportunity to make an exhaustive review of all Sed commands and to dive into their details and subtleties. So, if you are ready, launch a terminal, [download the test files][2] and sit comfortably before your keyboard: we will start our exploration right now! - -### A little bit of theory on Sed - -![complete reference guide to sed commands][4] - -#### A first look at the sed execution model - -To truly understand Sed you must first understand the tool execution model. - -When processing data, Sed reads one line of input at a time and stores it into the so-called pattern space. All Sed’s transformations apply to the pattern space. Transformations are described by one-letter commands provided on the command line or in an external Sed script file. Most Sed commands can be preceded by an address, or an address range, to limit their scope. - -By default, Sed prints the content of the pattern space at the end of each processing cycle, that is, just before overwriting the pattern space with the next line of input. We can summarize that model like that: - - 1. Try to read the next input line into the pattern space - - 2. If the read was successful: - - 1. Apply in the script order all commands whose address matches the current input line - - 2. If sed was not launched in quiet mode (`-n`) print the content of the (potentially modified) pattern space - - 3. got back to 1. - - - - -Since the content of the pattern space is lost after each line is processed, it is not suitable for long-term storage. For that purpose, Sed has a second buffer, the hold space. Sed never clears, puts or gets data from the hold space unless you explicitly request it. We will investigate that more in depth later when studying the exchange, get and hold commands. - -#### The Sed abstract machine - -The model explained above is what you will see described in many Sed tutorials. Indeed, it is correct enough to understand the most basic Sed programs. But when you start digging into more advanced commands, you will see it is not sufficient. So let’s try to be a little bit more formal now. - -Actually, Sed can be viewed as implementing an [abstract machine][5] whose [state][6] is defined by three [buffers][7], two [registers][8], and two [flags][9]: - - * **three buffers** to store arbitrary length text. Yes: three! In the basic execution model we talked about the pattern- and hold-space, but Sed has a third buffer: the append queue. From the Sed script perspective, it is a write-only buffer that Sed will flush automatically at predefined moments of its execution (broadly speaking before reading a new line from the input, or just before quitting). - - * Sed also maintains **two registers** : the line counter (LC) which holds the number of lines read from the input, and the program counter (PC) which always hold the index (“position” in the script) of the next command to execute. Sed automatically increments the PC as part of its main loop. But using specific commands, a script can also directly modify the PC to skip or repeat parts of the program. This is how loops or conditional statements can be implemented with Sed. More on that in the dedicated branches section below. - - * Finally **two flags** can modify the behavior of certain Sed commands: the auto-print flag (AP) the substitution flag (SF). When the auto-print flag is set, Sed will automatically print the content of the pattern space before overwriting it (notably before reading a new line of input but not only). When the auto-print flag is clear (“not set”), Sed will never print the content of the pattern space without an explicit command in the script. You can clear the auto-print flag by running Sed in “quiet mode” (using the `-n` command line option or by using the special comment`#n` on the very first line or the script). The “substitution flag” is set by the substitution command (the `s` command) when both its address and search pattern match the content of the pattern space. The substitution flag is cleared at the start of each new cycle, or when a new line is read from input, or after a conditional branch is taken. Here again, we will revisit that topic in details in the branches section. - - - - -In addition, Sed maintains the list of commands having entered their address range (more on that of the range addresses section) as well as a couple of file handles to read and write data. You will find some more information on that in the read and write command description. - -#### A more accurate Sed execution model - -As a picture worth thousands of words, I draw a flowchart describing the Sed execution model. I left a couple of things aside, like dealing with multiple input files or error handling, but I think this should be sufficient for you to understand the behavior of any Sed program and to avoid wasting your time by groping around while writing your own Sed scripts. - -![The Sed execution model][10] - -You may have noticed I didn’t describe the command-specific actions in the flowchart above. We will see that in detail for each command. So, without further ado, let’s start our tour! - -### The print command - -The print command (`p`) displays the content of the pattern space at the moment it is executed. It does not change in any way the state of the Sed abstract machine. - -![The Sed `print` command][11] - -For example: -``` -sed -e 'p' inputfile - -``` - -The command above will print each line of the input file … twice. Once because you explicitly requested it using the `print` command, and a second time implicitly at the end of the processing loop (because we didn’t launch Sed in “quiet mode” here). - -If we are not interested in seeing each line twice, we have two way of fixing that: -``` -sed -n -e 'p' inputfile # quiet mode with explicit print -sed -e '' inputfile # empty "do nothing" program, implicit print - -``` - -Note: the `-e` option introduces a Sed command. It is used to distinguish between commands and file names. Since a Sed invocation must contain at least one command, the `-e` flag is optional for that first command. However, I have the habit of using it, mostly for consistency with more complex cases where I have to give multiple Sed expressions on the command line. I let you figure by yourself if this is a good or bad habit, but I will follow that convention in the rest of the article. - -### Addresses - -Obviously, the print command is not very useful by itself. However, if you add an address before the command to apply it only to some lines of the input file, it suddenly becomes able to filter out unwanted lines from a file. But what’s an address for Sed? And how are identified the “lines” of the input file? - -#### Line numbers - -A Sed address can be either a line number (with the extension of `$` to mean “the last line”) or a regular expression. When using line numbers, you have to remember lines are numbered starting from one in Sed— and not starting from zero. -``` -sed -n -e '1p' inputfile # print only the first line of the file -sed -n -e '5p' inputfile # print only the line 5 -sed -n -e '$p' inputfile # print the last line of the file -sed -n -e '0p' inputfile # will result in an error because 0 is not a valid line number - -``` - -According to the [POSIX specifications][12], line numbers are cumulative if you specify several input files. In other words, the line counter is not reset when Sed opens a new input file. So, the two commands below will do the same thing, printing only one line of text to the output: -``` -sed -n -e '1p' inputfile1 inputfile2 inputfile3 -cat inputfile1 inputfile2 inputfile3 | sed -n -e '1p' - -``` - -Actually, this is exactly how POSIX defines multiple file handling: - -> If multiple file operands are specified, the named files shall be read in the order specified and the concatenation shall be edited. - -However, some Sed implementations offer command line options to change that behavior, like the GNU Sed `-s` flag (which is implicitly applied too when using the GNU Sed `-i` flags): -``` -sed -sn -e '1p' inputfile1 inputfile2 inputfile3 - -``` - -If your implementation of Sed supports such non-standard options, I let you check into the `man` for the details regarding them. - -#### Regular expressions - -I’ve said Sed addresses could be line numbers or regular expressions. But what is this regex thing? - -In just a few words, a [regular expression][13] is a way to describe a set of strings. If a given string pertains to the set described by a regular expression, we said the string matches the regular expression. - -A regular expression may contain literal characters that must be present verbatim into a string to have a match. For example, all letters and digits behave that way, as well as most printable characters. However, some symbols have a special meaning: - - * They could represent anchors, like `^` and `$` that respectively denotes the start or end of a line; - - * other symbols can serve as placeholders for entire sets of characters (like the dot that matches any single characters or the square brackets that are used to define a custom character set); - - * others again are quantifiers that serve to denotes repetitions (like the [Kleene star][14] that means 0, 1 or several occurrences of the previous pattern). - - - - -My goal here is not to give you a regular expression tutorial. So I will stick with just a few examples. However, feel free to search for more on the web about that topic: regular expressions are a really powerful feature available in many standard Unix commands and programming language and a skill every Unixien should master. - -Here are few examples used in the context of a Sed address: -``` -sed -n -e '/systemd/p' inputfile # print only lines *containing* the literal string "systemd" -sed -n -e '/nologin$/p' inputfile # print only lines ending with "nologin" -sed -n -e '/^bin/p' inputfile # print only lines starting with "bin" -sed -n -e '/^$/p' inputfile # print only empty lines (i.e.: nothing between the start and end of a line) -sed -n -e '/./p' inputfile # print only lines containing a character (i.e. print only non-empty lines) -sed -n -e '/^.$/p' inputfile # print only lines containing exactly one character -sed -n -e '/admin.*false/p' inputfile # print only lines containing "admin" followed by "false" (with any number of arbitrary characters between them) -sed -n -e '/1[0,3]/p' inputfile # print only lines containing a "1" followed by a "0" or "3" -sed -n -e '/1[0-2]/p' inputfile # print only lines containing a "1" followed by a "0", "1", "2" or "3" -sed -n -e '/1.*2/p' inputfile # print only lines containing the character "1" followed by a "2" (with any number of arbitrary characters between them) -sed -n -e '/1[0-9]*2/p' inputfile # print only lines containing the character "1" followed by zero, one or more digits, followed by a "2" - -``` - -If you want to remove the special meaning of a character in a regular expression (including the regex delimiter symbol), you have to precede it with a slash: -``` -# Print all lines containing the string "/usr/sbin/nologin" -sed -ne '/\/usr\/sbin\/nologin/p' inputfile - -``` - -You are not limited to use only the slash as the regular expression delimiter in an address. You can use any other character that could suit your needs and tastes by preceding the first delimiter by a backslash. This is particularly useful when you have addresses that should match literal slashes like when working with file paths: -``` -# Both commands are perfectly identical -sed -ne '/\/usr\/sbin\/nologin/p' inputfile -sed -ne '\=/usr/sbin/nologin=p' inputfile - -``` - -#### Extended regular expressions - -By default, the Sed regular expression engine only understands the [POSIX basic regular expression][15] syntax. If you need [extended regular expressions][16], you must add the `-E` flag to the Sed command. Extended regular expressions add a couple of extra feature to basic regular expressions and, most important maybe, they require far fewer backslashes. I let you compare: -``` -sed -n -e '/\(www\)\|\(mail\)/p' inputfile -sed -En -e '/(www)|(mail)/p' inputfile - -``` - -#### The bracket quantifier - -One powerful feature of regular expressions is the [range quantifier][17]`{,}`. Actually, when written exactly like that, this quantifier is a perfect synonym for the `*` quantifier. However, you can explicitly add a lower and upper bound on each side of the coma, something that gives a tremendous amount of flexibility. When the lower bound of the range quantifier is omitted, it is assumed to be zero. When the upper bound is omitted, it is assumed to be the infinity: - -|Bracket notation| Shorthand |Description| - -| {,} | * | zero, one or many occurrences of the preceding regex | -| {,1} | ? | zero or one occurrence of the preceding regex | -| {1,} | + | one or many occurrences of the preceding regex | -| {n,n} | {n} | exactly n occurrences of the preceding regex | - -The bracket notation is available in basic regular expressions too, but it requires backslashes. According to POSIX, the only quantifiers available in basic regular expression are the star and the bracket notation (with backslashes `\{m,n\}`). Many regex engines do support the `\?` and `\+` notation as an extension. However, why tempting the devil? If you need those quantifiers, using extended regular expressions will be both easier to write and more portable. - -If I took the time to talk about the bracket notation for regex quantifiers, this is because that feature is often useful in Sed scripts to count characters. -``` -sed -En -e '/^.{35}$/p' inputfile # Print lines containing exactly 35 characters -sed -En -e '/^.{0,35}$/p' inputfile # Print lines containing 35 characters or less -sed -En -e '/^.{,35}$/p' inputfile # Print lines containing 35 characters or less -sed -En -e '/^.{35,}$/p' inputfile # Print lines containing 35 characters or more -sed -En -e '/.{35}/p' inputfile # I let you figure out this one by yourself (test it!) - -``` - -#### Range addresses - -All the addresses we used so far were unique addresses. When using an unique address, the command is applied only the line(s) matching that address. However, Sed also supports range addresses. They are used to apply a command to all lines between the start and the end address of the range: -``` -sed -n -e '1,5p' inputfile # print only lines 1 through 5 -sed -n -e '5,$p' inputfile # print from line 5 to the end of the file - -sed -n -e '/www/,/systemd/p' inputfile # print from the first line matching the /www/ regular expression to the next line matching the /systemd/ regular expression. - -``` - -If the same line number is used both for the start and end address, the range is reduced to that line. Actually, if the second address is a number less than or equal to the line number of the first selected line of the range, only one line will be selected: -``` -printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '4,4p' - 4 bd -printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '4,3p' - 4 bd - -``` - -This is somewhat tricky, but the rule given in the previous paragraph also applies when the start address is a regular expression. In that case, Sed will compare the line number of the first line matching the regex with the explicit line number given as end address. Once again, if the end line number is lower or equal to the start line number, the range will be reduced to one line: -``` -# The /b/,4 address will match *three* one-line range -# since each matching line has a line number >= 4 -printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '/b/,4p' - 4 bd - 5 be - 6 bf - -# I let you figure by yourself how many ranges are matched -# by that second example: -printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '/d/,4p' - 1 ad - 2 ae - 3 af - 4 bd - 7 cd - -``` - -However, the behavior of Sed is different when the end address is a regular expression. In that case, the first line of the range is not tested against the end address, so the range will contain at least two lines (except of course if there is not enough input data): -``` -printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '/b/,/d/p' - 4 bd - 5 be - 6 bf - 7 cd - -printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '4,/d/p' - 4 bd - 5 be - 6 bf - 7 cd - -``` - -#### Complement - -Adding an exclamation mark (`!`) after an address select lines not matching that address. For example: -``` -sed -n -e '5!p' inputfile # Print all lines except line 5 -sed -n -e '5,10!p' inputfile # Print all lines except line 5 to 10 -sed -n -e '/sys/!p' inputfile # Print all lines except those containing "sys" - -``` - -#### Conjunctions - -Sed allows to group commands in blocks using brackets (`{…​}`). You can leverage that feature to combine several addresses. For example, let’s compare the output of those two commands: -``` -sed -n -e '/usb/{ -/daemon/p -}' inputfile - -sed -n -e '/usb.*daemon/p' inputfile - -``` - -By nesting commands in a block, we will select lines containing “usb” and “daemon” in any order. Whereas the regular expression “usb.*daemon” would only match lines where the “usb” string appears before the “daemon” string. - -After that long digression, let’s go back now to our review of the various Sed commands. - -### The quit command - -The quit command will stop Sed at the end of the current processing loop iteration. - -![The Sed `quit` command][18] - -The `quit` command is a way to stop input processing before reaching the end of the input file. Why would someone want to do that? - -Well, if you remember, we’ve seen you can print the lines 1 through 5 of a file using the following command: -``` -sed -n -e '1,5p' inputfile - -``` - -With most implementations of Sed, the tool will read and cycle over all the remaining input lines, even if only the first five can produce a result. This may have a significant impact if your file contains millions of rows (or even worst, if you read from an infinite stream of data like `/dev/urandom` for example). - -Using the quit command, the same program can be rewritten much more efficiently: -``` -sed -e '5q' inputfile - -``` - -Here, since I did not use the `-n` option, Sed will implicitly print the pattern space at the end of each cycle, but it will quit, and thus not reading more data, after having processed the line 5. - -We could use a similar trick to print only a specific line of a file. That will be a good occasion to see several ways of providing multiple Sed expressions from the command line. The three variations bellow take benefit of Sed accepting several commands, either as different `-e` options, or in the same expression, but separated by newlines or semi-colon: -``` -sed -n -e '5p' -e '5q' inputfile - -sed -n -e ' - 5p - 5q -' inputfile - -sed -n -e '5p;5q' inputfile - -``` - -If you remember it, we’ve seen earlier we can group commands using brackets, something that we could use here to avoid repeating the same address twice: -``` -# By grouping commands -sed -e '5{ - p - q -}' inputfile - -# Which can be shortened as: -sed '5{p;q;}' inputfile - -# As a POSIX extension, some implementations makes the semi-colon before the closing bracket optional: -sed '5{p;q}' inputfile - -``` - -### The substitution command - -You can imagine the substitution command as the Sed equivalent to the search-replace feature you can find on most WYSIWYG editors. An equivalent, albeit a more powerful one though. The substitution command being one of the best-known Sed commands, it is largely documented on the web. - -![The Sed `substitution` command][19] - -We already have covered it [in a previous article][20] so I will not repeat myself here. However there are some key points to remember if you’re not yet completely familiar with it: - - * The substitution command takes two parameters: the search pattern and the replacement string: `sed s/:/-----/ inputfile` - - * The command and its arguments are separated by an arbitrary character. Mostly by habit, 99% of the time we use a slash but any other character can be used: `sed s%:%-----% inputfile`, `sed sX:X-----X inputfile` or even `sed 's : ----- ' inputfile` - - * By default, the substitution is applied only to the first matching substring of the pattern space. You can change that by specifying the match index as a flag after the command: `sed 's/:/-----/1' inputfile`, `sed 's/:/-----/2' inputfile`, `sed 's/:/-----/3' inputfile`, … - - * If you want to perform a substitution globally (i.e.: on each non-overlapping match of the pattern space), you need to add the `g` flag: `sed 's/:/-----/g' inputfile` - - * In the replacement string, any occurrence of the ampersand (`&`) will be replaced by the substring matching the search pattern: `sed 's/:/-&&&-/g' inputfile`, `sed 's/…​./& /g' inputfile` - - * Parenthesis ( `(…​)` in extended regex or `\(…​\)` in basic regex) introduce a capturing group. That is a part of the matching string that can be referenced in the replacement string. `\1` is the content of the first capturing group, `\2` the content of the second one and so on: `sed -E 's/(.)(.)/\2\1/g' inputfile`, `sed -E 's/(.):x:(.):(.*)/\1:\3/' inputfile` (that latter works because [the star regular expression quantifier is greedy][21], and matches as many characters as it can) - - * In the search pattern or the replacement string you can remove the special meaning of any character by preceding it with a backslash: `sed 's/:/--\&--/g' inputfile`, `sed 's/\//\\/g' inputfile` - - - - -As all this might seem a little bit abstract, here are a couple of examples. To start, let’s say I want to display the first field of my test input file padded with spaces on the right up to 20 characters, I could write something like that: -``` -sed < inputfile -E -e ' - s/:/ / # replace the first field separator by 20 spaces - s/(.{20}).*/\1/ # keep only the first 20 characters of the line - s/.*/| & |/ # add vertical bars for a nice output -' - -``` - -As a second example, if I want to change the UID/GID of the user sonia to 1100, I could write something like that: -``` -sed -En -e ' - /sonia/{ - s/[0-9]+/1100/g - p - }' inputfile - -``` - -Notice the `g` option at the end of the substitution command. It modifies its behavior, so all occurrences of the search pattern are replaced. Without that option, only the first one would be. - -By the way, this is also a good occasion to mention the print command displays the content of the pattern space at the moment the command is executed. So, I can obtain a before-after output like that: -``` -sed -En -e ' - /sonia/{ - p - s/[0-9]+/1100/g - p - }' inputfile - -``` - -Actually, since printing a line after a substitution is a common use case, the substitution command also accepts the `p` option for that purpose: -``` -sed -En -e '/sonia/s/[0-9]+/1100/gp' inputfile - -``` - -Finally, I won’t be exhaustive without mentioning the `w` option of the substitution command. We will examine it in detail later. - -#### The delete command - -The delete command (`d`) is used to clear the pattern space and immediately start the next cycle. By doing so, it will also skip the implicit print of the pattern space even if the auto-print flag is set. - -![The Sed `delete` command][22] - -A particularly inefficient way of printing only the first five lines of a file would be: -``` -sed -e '6,$d' inputfile - -``` - -I let you guess why I said this was inefficient. If this is not obvious, try to re-read the section concerning the quit command. The answer is there! - -The delete command is particularly useful when combined with regular expression-based addresses to remove matching lines from the output: -``` -sed -e '/systemd/d' inputfile - -``` - -#### The next command - -This command prints the current pattern space if Sed is not running in quiet mode, then, in all cases, it reads the next input line into the pattern space and executes the remaining commands of the current cycle with the new pattern space. - -![The Sed `next` command][23] - -A common use case of the next command is to skip lines: -``` -cat -n inputfile | sed -n -e 'n;n;p' - -``` - -In the example above, Sed will implicitly read the first line of the input file. But the `next` command discards (and does not display because of the `-n` option) the pattern space and replaces it with the next line from the input. And the second `next` command will do the same thing, skipping now the line 2 of the input. And finally, the script explicitly prints the pattern space which now contains the third line of the input. Then Sed will start a new cycle, implicitly reading the line 4, then skipping it, as well as the line 5, because of the `next` commands, and it will print the line 6. And again and again until the end of the file. Concretely, this prints one line over three of the input file. - -Using the next command, we can also find a couple of other ways to display the first five lines of a file: -``` -cat -n inputfile | sed -n -e '1{p;n;p;n;p;n;p;n;p}' -cat -n inputfile | sed -n -e 'p;n;p;n;p;n;p;n;p;q' -cat -n inputfile | sed -e 'n;n;n;n;q' - -``` - -More interestingly, the next command is also very useful when you want to process lines relative to some address: -``` -cat -n inputfile | sed -n '/pulse/p' # print lines containing "pulse" -cat -n inputfile | sed -n '/pulse/{n;p}' # print the line following - # the line containing "pulse" -cat -n inputfile | sed -n '/pulse/{n;n;p}' # print the line following - # the line following - # the line containing "pulse" - -``` - -### Working with the hold space - -Until now, the command we’ve seen dealt only with the pattern space. However, as we’ve mentioned it at the very top of this article, there is a second buffer, the hold space, entirely under the control of the user. This will be the purpose of the commands described in this section. - -#### The exchange command - -As it names implies it, the exchange command (`x`) will swap the content of the hold and pattern space. Remember as long as you didn’t put anything into the hold space, it is empty. - -![The Sed `exchange` command][24] - -As a first example, we may use the exchange command to print in reverse order the first two lines of a file: -``` -cat -n inputfile | sed -n -e 'x;n;p;x;p;q' - -``` - -Of course, you don’t have to use the content of the hold space immediately after having set it, since the hold space remains untouched as long as you don’t explicitly modify it. In the following example, I use it to move the first line of the input after the fifth one: -``` -cat -n inputfile | sed -n -e ' - 1{x;n} # Swap the hold and pattern space - # to store line 1 into the hold buffer - # and then read line two - 5{ - p # print line 5 - x # swap the hold and pattern space to get - # back the content of line one into the - # pattern space - } - - 1,5p # triggered on lines 2 through 5 - # (not a typo! try to figure why this rule - # is NOT executed for line 1;) -' - -``` - -#### The hold commands - -The hold command (`h`) is used to store the content of the pattern space into the hold space. However, as opposed to the exchange command, this time the content of the pattern space is left unchanged. The hold commands came in two flavors: - - * `h` -that will copy the content of the pattern space into the hold space, overwriting any value already present - - * `H` -that will append the content of the pattern space to the hold space, using a newline as separator - - - - -![The Sed `hold` command][25] - -The example above using the exchange command can be rewritten using the hold command instead: -``` -cat -n inputfile | sed -n -e ' - 1{h;n} # Store line 1 into the hold buffer and continue - 5{ # on line 5 - x # switch the pattern and hold space - # (now the pattern space contains the line 1) - H # append the line 1 after the line 5 in the hold space - x # switch again to get back lines 5 and 1 into - # the pattern space - } - - 1,5p # triggered on lines 2 through 5 - # (not a typo! try to figure why this rule - # is NOT executed for line 1;) -' - -``` - -#### The get command - -The get command (`g`) does the exact opposite of the hold command: it takes the content of the hold space and put it into the pattern space. Here again, it comes in two flavors: - - * `g` -that will copy the content of the hold space into the pattern space, overwriting any value already present - - * `G` -that will append the content of the hold space to the pattern space, using a newline as separator - - - - -![The Sed `get` command][26] - -Together, the hold and get commands allow to store and recall data. As a little challenge, I let you rewrite the example of the previous section to put the line 1 of the input file after the line 5, but this time using the get and hold commands (lower- or upper-case version), but without using the exchange command. With a little bit of luck, it should be simpler that way! - -In the meantime, I can show you another example that could serve for your inspiration. The goal here is to separate the users having a login shell from the others: -``` -cat -n inputfile | sed -En -e ' - \=(/usr/sbin/nologin|/bin/false)$= { H;d; } - # Append matching lines to the hold buffer - # and continue to next cycle - p # Print other lines - $ { g;p } # On the last line, - # get and print the content of the hold buffer -' - -``` - -### print, delete and next revisited - -Now you’ve gained more familiarities with the hold space, let me go back on the `print`, `delete` and `next` commands. We already talked about the lower case `p`, `d` and `n` commands. But they also have an upper case version. As it seems to be a convention with Sed, the uppercase version of those commands will be related to multi-line buffers: - - * `P` -print the content of the pattern space up to the first newline - - * `D` -delete the content of the pattern space up and including the first newline then restart a cycle with the remaining text without reading any new input - - * `N` -read and append a new line of input to the pattern space using the newline character as a separator between the old and new data. Continue the execution of the current cycle. - - - - -![The Sed uppercase `Delete` command][27] -![The Sed uppercase `Next` command][28] - -The main use case for those commands is to implement queues ([FIFO lists][29]). The canonical example being removing the last 5 lines from a file: -``` -cat -n inputfile | sed -En -e ' - 1 { N;N;N;N } # ensure the pattern space contains *five* lines - - N # append a sixth line onto the queue - P # Print the head of the queue - D # Remove the head of the queue -' - -``` - -As a second example, we could display input data on two columns: -``` -# Print on two columns -sed < inputfile -En -e ' - $!N # Append a new line to the pattern space - # *except* on the last line of input - # This is a trick required to deal with - # inconsistencies between GNU Sed and POSIX Sed - # when using N on the last line of input - # https://www.gnu.org/software/sed/manual/sed.html#N_005fcommand_005flast_005fline - - # Right pad the first field of the first line - # with spaces and discard rest of the line - s/:.*\n/ \n/ - s/:.*// # Discard all but the first field on the second line - s/(.{20}).*\n/\1/ # Trim and join lines - p # Print result -' - -``` - -### Branching - -We just saw Sed has buffer capabilities through the hold space. But it also has test and branch instructions. Having both those features makes Sed a [Turing complete][30] language. It may sound silly, but that means you can write any program using Sed. You can do it, but that does not mean it would be an easy task, nor that the result would be particularly efficient of course. - -However, don’t panic. In this article, we will stay with simple examples of tests and branches. Even if these capabilities seem limited at first sight, remember some people have written [calculators], [Tetris] or many other kinds of applications using sed! - -#### labels and branches - -By some aspects, you can see Sed as a very limited assembly language. So you won’t find high-level “for” or “while” loops or “if … else” statements, but you can implement them using branches. - -![The Sed `branch` command][31] - -If you take a look at the flowchart describing the Sed execution model at the top of this article, you can see Sed automatically increments the program counter, resulting in the execution of the commands in the program’s instructions order. However, using branch instructions, you can break that sequential flow by continuing the execution with any command of your choice in the program. The destination of a jump is explicitly defined using a label. - -![The Sed `label` command][32] - -Here is an example: -``` -echo hello | sed -ne ' - :start # Put the "start" label on that line of the program - p # Print the pattern buffer - b start # Continue execution at the :start label -' | less - -``` - -The behavior of that Sed program is very close to the `yes` command: it takes a string and produces an infinite stream of lines containing that string. - -Branching to a label as we did bypass all Sed automatic features: it does not read any input, nor print anything, nor update any buffer. It just jumps to a different instruction instead of executing the next one in the source program order. - -Worth mentioning without any label specified as an argument, the branch command (`b`) will branch to the end of the program. So Sed will start a new cycle. This may be useful to bypass some instructions and thus may be used as an alternative to blocks: -``` -cat -n inputfile | sed -ne ' -/usb/!b -/daemon/!b -p -' - -``` - -#### Conditional branch - -Until now, we’ve seen the so-called unconditional branches, even if the term is somewhat misleading in this context since Sed commands are always conditional based on their optional address. - -However, in a more traditional sense, an unconditional branch is a branch that, when executed, will always jump to the specified destination, whereas a conditional branch may or may not jump to the specified instruction depending on the current state of the system. - -Sed has only one conditional instruction, the test (`t`) command. It jumps to a different instruction only if a substitution was executed since the start of the current cycle or since the previous conditional branch. More formally, the test command will branch only if the substitution flag is set. - -![The Sed `test` command][3]![The Sed `test` command][33] - -With the test instruction, you can easily perform loops in a Sed program. As a practical example, you can use that to pad lines to a certain length (something you can’t do with regex only): -``` -# Center text -cut -d: -f1 inputfile | sed -Ee ' - :start - s/^(.{,19})$/ \1 / # Pad lines shorter than 20 chars with - # a space at the start and another one - # at the end - t start # Go back to :start if we added a space - s/(.{20}).*/| \1 |/ # Keep only the first 20 char of the line - # to fix the off-by-one error caused by - # odd lines -' - -``` - -If you carefully read the previous example, you’ve noticed I cheated a little bit by using the cut command to pre-process the data before feeding them to sed. - -We can, however, perform the same task using only sed at the cost of a small modification to the program: -``` -cat inputfile | sed -Ee ' - s/:.*// # Remove all but the first field - t start - :start - s/^(.{,19})$/ \1 / # Pad lines shorter than 20 chars with - # a space at the start and another one - # at the end - t start # Go back to :start if we added a space - s/(.{20}).*/| \1 |/ # Keep only the first 20 char of the line - # to fix the off-by-one error caused by - # odd lines -' - -``` - -In the above example, you may be surprised by the following construct: -``` -t start -:start - -``` - -At first sight, the branch here seems useless since it will jump to the instruction that would have been executed anyway. However, if you read the definition of the `test` command attentively, you will see it branches only if there was a substitution since the start of the current cycle or since the previous test command was executed. In other words, the test instruction has the side effect of clearing the substitution flag. This is exactly the purpose of the code fragment above. This is a trick you will often see in Sed programs containing conditional branches to avoid false positive when using several substitutions commands. - -I agree though it wasn’t absolutely mandatory here to clear the substitution flag since the specific substitution command I used is idempotent once it has padded the string to the right length. So one extra iteration will not change the result. However, look at that second example now: -``` -# Classify user accounts based on their login program -cat inputfile | sed -Ene ' - s/^/login=/ - /nologin/s/^/type=SERV / - /false/s/^/type=SERV / - t print - s/^/type=USER / - :print - s/:.*//p -' - -``` - -My hope here was to tag the user accounts with either “SERV” or “USER” depending on the configured default login program. If you ran it, you’ve seen the “SERV” tag as expected. However, no trace of the “USER” tag in the output. Why? Because the `t print` instruction will always branch since whatever was the content of the line, the substitution flag was set by the very first substitution command of the program. Once set, the flag remains set until a next line is read— or until the next test command. And gives us the solution to fix that program: -``` -# Classify user accounts based on the login program -cat inputfile | sed -Ene ' - s/^/login=/ - - t classify # clear the "substitution flag" - :classify - - /nologin/s/^/type=SERV / - /false/s/^/type=SERV / - t print - s/^/type=USER / - :print - s/:.*//p -' - -``` - -### Handling verbatim text - -Sed is a text editor. A non-interactive one. But a text editor nevertheless. It wouldn’t be complete without some facility to insert literal text in the output. I’m not a big fan of that feature since I find the syntax awkward (even by the Sed standards), but sometimes you can’t avoid it. - -In the strict POSIX syntax, all the three commands to change (`c`), insert (`i`) or append (`a`) some literal text to the output follow the same specific syntax: the command letter is followed by a backslash, and the text to insert start on the next line of the script: -``` -head -5 inputfile | sed ' -1i\ -# List of user accounts -$a\ -# end -' - -``` - -To insert multiple lines of text, you must end each of them with a backslash: -``` -head -5 inputfile | sed ' -1i\ -# List of user accounts\ -# (users 1 through 5) -$a\ -# end -' - -``` - -Some Sed implementations, like GNU Sed, makes the newline after the initial backslash optional, even when forced in `--posix` mode. I didn’t find anything in the standard that authorizes that alternate syntax. So use it at your own risks if portability is a premium (or leave a comment if I missed that feature in the specifications!): -``` -# non-POSIX syntax: -head -5 inputfile | sed -e ' -1i \# List of user accounts -$a\# end -' - -``` - -Some Sed implementation also makes the initial backslash completely optional. Since this is, without any doubt this time, a vendor-specific extension to the POSIX specifications, I let you check the manual for the version of sed you use to check if it supports that syntax. - -After that quick overview, let’s review those commands in more details now, starting with the change command I didn’t have presented yet. - -#### The change command - -The change command (`c\`) deletes the pattern space and starts a new cycle just like the `d` command. The only difference is the user provided text is written on the output when the command is executed. - -![The Sed `change` command][34] -``` -cat -n inputfile | sed -e ' -/systemd/c\ -# :REMOVED: -s/:.*// # This will NOT be applied to the "changed" text -' - -``` - -If the change command is associated with a range address, the text is output only once, when reaching the last line of the range. Which somehow makes it an exception to the convention a Sed command is repeatedly applied to all lines of its range address: -``` -cat -n inputfile | sed -e ' -19,22c\ -# :REMOVED: -s/:.*// # This will NOT be applied to the "changed" text -' - -``` - -As a consequence, if you want the change command to be repeated for every line in a range, you have no other choice than wrapping it inside a block: -``` -cat -n inputfile | sed -e ' -19,22{c\ -# :REMOVED: -} -s/:.*// # This will NOT be applied to the "changed" text -' - -``` - -#### The insert command - -The insert command (`i\`) immediately print the user-provided text on the output. It does not alter in any way the program flow or buffer content. - -![The Sed `insert` command][35] -``` -# display the first five user names with a title on the first row -sed < inputfile -e ' -1i\ -USER NAME -s/:.*// -5q -' - -``` - -#### The append command - -The append command (`a\`) queues some text to be displayed when the next line of input will be read. The text is output at the end of the current cycle (including at the end of the program) or when a new line is read from the input using either the `n` or `N` command. - -![The Sed `append` command][36] - -Same example as above, but inserts this time a footer instead of a header: -``` -sed < inputfile -e ' -5a\ -USER NAME -s/:.*// -5q -' - -``` - -#### The read command - -There is a fourth command to insert literal content into the output stream: the read command (`r`). It works exactly like the append command, but instead of taking the text hardcoded from the Sed script itself, it will write the content of a file on the output. - -The read command only schedules the file to be read. That latter is effectively read when the append queue is flushed. Not when the read command is executed. This may have implications if there are concurrent accesses to the file to be read, if that file is not a regular file (for example, if it’s a character device or a named pipe), or if the file is modified during processing. - -As an illustration, if you use the write command we will see in detail in the next section together with the read command to write and re-read from a temporary file, you may obtain some creative results (using a French equivalent of the [Shiritori][37] game as an illustration): -``` -printf "%s\n" "Trois p'tits chats" "Chapeau d' paille" "Paillasson" | -sed -ne ' - r temp - a\ - ---- - w temp -' - -``` - -We’ve now ended the list of the Sed commands dedicated to the insertion of literal text in the stream output. My last example was mostly for fun, but since I mentioned there the write command, that makes a perfect transition with the next section where we will see how to write data to an external file from Sed. - -### Alternate output - -Sed is designed with the idea all text transformations will end-up being written on the standard output of the process. However, Sed also has some provision to send data to alternate destinations. You have two ways to do that: using the dedicated write command, or by adding the write flag to a substitution command. - -#### The write command - -The write command (`w`) appends the content of the pattern space to the given destination file. POSIX requires the destination file to be created by Sed before it starts processing any input data. If the file already exists, it is overwritten. - -![The Sed `write` command][38] - -As a consequence, even if you never really write to a file, it will be created anyway. For example, the following Sed program will create/overwrite the “output” file, even if the write command is never executed: -``` -echo | sed -ne ' -q # immediately quit -w output # this command is never executed -' - -``` - -You can have several write commands referencing the same destination file. All write commands at the destination of the same file will append content to that file (more or less in the same manner as the `>>` shell redirection). : -``` -sed < inputfile -ne ' -/:\/bin\/false$/w server -/:\/usr\/sbin\/nologin$/w server -w output -' -cat server - -``` - -#### The substitution command `write` flag - -A long time ago now, we had seen the substitution command has the `p` option for the common use case of printing the pattern space after a substitution. In a very similar manner it also has a `w` option to write the pattern space to a file after a substitution: -``` -sed < inputfile -ne ' -s/:.*\/nologin$//w server -s/:.*\/false$//w server -' -cat server - -``` - -I already used them countless times, but I never took the time to introduce them formally, so, let’s fix that: like in most programming languages, a comment is a way to add free-form text the software will not try to interpret. The Sed syntax being rather cryptic, I can’t insist enough on the need to comment your scripts. Otherwise, they will be hardly understandable by anyone except their author. - -![The Sed `comment` command][39] - -However, like many other parts of Sed, comments have their own share of subtleties. First, and the most important, comments are not a syntactic construct, but are full-fledged commands in Sed. A do-nothing (“no-op”) command, but a command anyway. At least, that is how there are defined by POSIX. So, strictly speaking, they should only be allowed where other commands are allowed. - -Most Sed implementation relaxes that requirement by allowing inline commands as I used them all over the place in that article. - -To close on that topic, worth mentioning the very special case of the `#n` comment (an octothorpe followed by the letter n without any space). If that exact comment if found on the very first line of a script, Sed should switch to quiet mode (i.e., clearing the auto-print flag) just like if the `-n` option was specified on the command line. - -### The commands you will rarely need - -Now, we have reviewed the commands that will allow you to write 99.99% of your scripts. But this tour wouldn’t be exhaustive if I didn’t mention the last remaining Sed commands. I left them aside until now because I rarely needed them. But maybe did you have on your side examples of practical use cases where you find them useful. If that is the case do not hesitate to share that with us using the comment section. - -#### The line number command - -The `=` command writes on the standard output the number of lines currently read by Sed, that is the content of the line counter register. There is no way to capture that number in one of the Sed buffers, nor to format the output. Two limitations that severely reduce the usefulness of that command. - -![The Sed `line number` command][40] - -Remember in strict POSIX compliance mode, when several input files are given on the command line, Sed does not reset that counter but continue to increment it just like if all the files where concatenated. Some Sed implementations like GNU Sed have options to reset the counter after each input file. - -#### The unambiguous print command - -The `l` (lowercase letter ell) is similar to the print command (`p`), but the content of the pattern space will be written in an unambiguous form. To quote [the POSIX standard][12]: - -> The characters listed in XBD Escape Sequences and Associated Actions ( ‘\\\’, ‘\a’, ‘\b’, ‘\f’, ‘\r’, ‘\t’, ‘\v’ ) shall be written as the corresponding escape sequence; the ‘\n’ in that table is not applicable. Non-printable characters not in that table shall be written as one three-digit octal number (with a preceding ) for each byte in the character (most significant byte first). Long lines shall be folded, with the point of folding indicated by writing a followed by a ; the length at which folding occurs is unspecified, but should be appropriate for the output device. The end of each line shall be marked with a ‘$’. - -![The Sed `unambiguous print` command][3]![The Sed `unambiguous print` command][41] - -I suspect this command was once used to exchange data over non [8-bits clean channels][42]. As of myself, I never used it for anything else than for debugging purposes. - -#### The transliterate command - -The transliterate (`y`) command allows mapping characters of the pattern space from a source set to a destination set. It is quite similar to the `tr` command, although more limited. - -![The Sed `transliterate` command][43] -``` -# The `y` c0mm4nd 1s for h4x0rz only -sed < inputfile -e ' - s/:.*// - y/abcegio/48<3610/ -' - -``` - -While the transliterate command syntax bears some resemblances with the substitution command syntax, it does not accept any option after the replacement string. The transliteration is always global. - -Beware that the transliterate command requires all the characters both in the original and destination set to be given verbatim. That means the following Sed program does not do what you might think at first sight: -``` -# BEWARE: this doesn't do what you may think! -sed < inputfile -e ' - s/:.*// - y/[a-z]/[A-Z]/ -' - -``` - -### The last word -``` -# What will this do? -# Hint: the answer is not far away... -sed -E ' - s/.*\W(.*)/\1/ - h - ${ x; p; } - d' < inputfile - -``` - -I can’t believe we did it! We’ve reviewed all the Sed commands. If you reached that point, you deserve congratulations, especially if you took the time to try the different examples on your system! - -As you’ve seen, Sed is a complex beast, not only because of its sparse syntax but also because of all the various corner cases or subtle differences in the command behavior. No doubt, we can blame historical reasons for that. Despite these drawbacks, it is a powerful tool and even today remains one of the most useful commands of the Unix toolbox. If it is time for me to conclude that article, I wouldn’t do it without first asking you a favor: please, share with us using the command section your most favorite or creative piece of Sed script. If we have enough of them, we could publish a compilation of those Sed gems! - --------------------------------------------------------------------------------- - -via: https://linuxhandbook.com/sed-reference-guide/ - -作者:[Sylvain Leroux][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://linuxhandbook.com/author/sylvain/ -[1]:https://linuxhandbook.com/sed-command-basics/ -[2]:https://gist.github.com/s-leroux/5cb36435bac46c10cfced26e4bf5588c -[3]:https://linuxhandbook.com/wp-content/plugins/jetpack/modules/lazy-images/images/1x1.trans.gif -[4]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05/sed-reference-guide.jpeg?resize=702%2C395&ssl=1 -[5]:http://mathworld.wolfram.com/AbstractMachine.html -[6]:https://en.wikipedia.org/wiki/State_(computer_science) -[7]:https://en.wikipedia.org/wiki/Data_buffer -[8]:https://en.wikipedia.org/wiki/Processor_register#Categories_of_registers -[9]:https://www.computerhope.com/jargon/f/flag.htm -[10]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-flowchart.png?w=702&ssl=1 -[11]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-print-command.png?w=702&ssl=1 -[12]:http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html -[13]:https://www.regular-expressions.info/ -[14]:https://chortle.ccsu.edu/FiniteAutomata/Section07/sect07_16.html -[15]:https://www.regular-expressions.info/posix.html#bre -[16]:https://www.regular-expressions.info/posix.html#ere -[17]:https://www.regular-expressions.info/repeat.html#limit -[18]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-quit-command.png?w=702&ssl=1 -[19]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-substitution-command.png?w=702&ssl=1 -[20]:https://linuxhandbook.com/?p=128 -[21]:https://www.regular-expressions.info/repeat.html#greedy -[22]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-delete-command.png?w=702&ssl=1 -[23]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-next-command.png?w=702&ssl=1 -[24]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-exchange-command.png?w=702&ssl=1 -[25]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-hold-command.png?w=702&ssl=1 -[26]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-get-command.png?w=702&ssl=1 -[27]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-delete-upper-command.png?w=702&ssl=1 -[28]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-next-upper-command.png?w=702&ssl=1 -[29]:https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics) -[30]:https://chortle.ccsu.edu/StructuredC/Chap01/struct01_5.html -[31]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-branch-command.png?w=702&ssl=1 -[32]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-label-command.png?w=702&ssl=1 -[33]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-test-command.png?w=702&ssl=1 -[34]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-change-command.png?w=702&ssl=1 -[35]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-insert-command.png?w=702&ssl=1 -[36]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-append-command.png?w=702&ssl=1 -[37]:https://en.wikipedia.org/wiki/Shiritori -[38]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-write-command.png?w=702&ssl=1 -[39]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-comment-command.png?w=702&ssl=1 -[40]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-current-line-command.png?w=702&ssl=1 -[41]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-unambiguous-print-command.png?w=702&ssl=1 -[42]:https://en.wikipedia.org/wiki/8-bit_clean -[43]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-transliterate-command.png?w=702&ssl=1 diff --git a/translated/tech/20180615 Complete Sed Command Guide [Explained with Practical Examples].md b/translated/tech/20180615 Complete Sed Command Guide [Explained with Practical Examples].md new file mode 100644 index 0000000000..558663de0d --- /dev/null +++ b/translated/tech/20180615 Complete Sed Command Guide [Explained with Practical Examples].md @@ -0,0 +1,1029 @@ +Sed 命令完全指南 +====== +在前面的文章中,我展示了 [Sed 命令的基本用法][1],它是一个功能强大的流编辑器。今天,我们准备去了解关于 Sed 更多的知识,深入了解 Sed 的运行模式。这将是你全面了解 Sed 命令的一个机会,深入挖掘它的运行细节和精妙之处。因此,如果你已经做好了准备,那就打开终端吧,[下载测试文件][2] 然后坐在电脑前:开始我们的探索之旅吧! + +### 关于 Sed 的一点点理论知识 + +![complete reference guide to sed commands][4] + +#### 首先我们看一下 sed 的运行模式 + +要准确理解 Sed 命令,你必须先了解工具的运行模式。 + +当处理数据时,Sed 从输入源一次读入一行,并将它保存到所谓的 `pattern` 空间中。所有 Sed 的变动都发生在 `pattern` 空间。变动都是由命令行上或外部 Sed 脚本文件提供的单字母命令来描述的。大多数 Sed 命令都可以由一个地址或一个地址范围作为前导来限制它们的作用范围。 + +默认情况下,Sed 在结束每个处理循环后输出 `pattern` 空间中的内容,也就是说,输出发生在输入的下一个行覆盖 `pattern` 空间之前。我们可以将这种运行模式总结如下: + + 1. 尝试将下一个行读入到 `pattern` 空间中 + + 2. 如果读取成功: + + 1. 按脚本中的顺序将所有命令应用到与那个地址匹配的当前输入行上 + + 2. 如果 sed 没有以静默(`-n`)模式运行,那么将输出 `pattern` 空间中的所有内容(可能会是修改过的)。 + + 3. 重新回到 1。 + + + + +因此,在每个行被处理完毕之后, `pattern` 空间中的内容将被丢弃,它并不适合长时间保存内容。基于这种目的,Sed 有第二个缓冲区:`hold` 空间。除非你显式地要求它将数据置入到 `hold` 空间、或从`hode` 空间中取得数据,否则 Sed 从不清除 `hold` 空间的内容。在我们后面学习到 `exchange`、`get`、`hold` 命令时将深入研究它。 + +#### Sed 的抽象机制 + +你将在许多的 Sed 教程中都会看到上面解释的模式。的确,这是充分正确理解大多数基本 Sed 程序所必需的。但是当你深入研究更多的高级命令时,你将会发现,仅这些知识还是不够的。因此,我们现在尝试去了解更深入的一些知识。 + +的确,Sed 可以被视为是[抽象机制][5]的实现,它的[状态][6]由三个[缓冲区][7] 、两个[寄存器][8]和两个[标志][9]来定义的: + + * **三个缓冲区**用于去保存任意长度的文本。是的,是三个!在前面的基本运行模式中我们谈到了两个: `pattern` 空间和 `hold` 空间,但是 Sed 还有第三个缓冲区:追加队列。从 Sed 脚本的角度来看,它是一个只写缓冲区,Sed 将在它运行时的预定义阶段来自动刷新它(一般是在从输入源读入一个新行之前,或仅在它退出运行之前)。 + + * Sed 也维护**两个寄存器**:行计数器(LC)用于保存从输入源读取的行数,而程序计数器(PC)总是用来保存下一个将要运行的命令的索引(就是脚本中的位置),Sed 将它作为它的主循环的一部分来自动增加 PC。但在使用特定的命令时,脚本也会直接修改 PC 去跳过或重复程序的一部分。这就像使用 Sed 实现的一个循环或条件语句。更多内容将在下面的专用分支一节中描述。 + + * 最后,**两个标志**可以被某些 Sed 命令的行为所修改:自动输出(AP)标志和替换标志(SF)。当自动输出标志 AP 被设置时,Sed 将在 `pattern` 空间的内容被覆盖前自动输出(尤其是(包括但不限于)在从输入源读入一个新行之前)。当自动输出标准被清除时(即:没有设置),Sed 在脚本中没有显式命令的情况下,将不会输出 `pattern` 空间中的内容。你可以通过在“静默模式”(使用命令行选项 `-n` 或者在第一行或脚本中使用特殊注释 `#n`)运行 Sed 命令来清除自动输出标志。当它的地址和查找模式与 `pattern` 空间中的内容都匹配时,“替换标志”将被替换命令(`s` 命令)设置。替换标志在每个新的循环开始时、或当从输入源读入一个新行时、或获得条件分支之后将被清除。我们将在分支一节中详细研究这一话题。 + + + + +另外,Sed 维护一个进入到它的地址范围(关于地址范围的更多知识将在地址范围一节详细描述)的命令列表,以及用于读取和写入数据的两个文件句柄(你将在读取和写入命令的描述中获得更多有关文件句柄的内容)。 + +#### 一个更精确的 Sed 运行模式 + +由于一张图胜过千言万语,所以我画了一个流程图去描述 Sed 的运行模式。我将两个东西放在了旁边,像处理多个输入文件或错误处理,但是我认为这足够你去理解任何 Sed 程序的行为了,并且可以避免你在编写你自己的 Sed 脚本时浪费在摸索上的时间。 + +![The Sed execution model][10] + +你可能已经注意到,在上面的流程图上我并没有描述特定的命令动作。对于命令,我们将逐个详细讲解。因此,不用着急,我们马上开始! + +### print 命令 + +print 命令(`p`)是用于输出在它运行时 `pattern` 空间中的内容。它并不会以任何方式改变 Sed 抽象机制中的状态。 + +![The Sed `print` command][11] + +示例: +``` +sed -e 'p' inputfile + +``` + +上面的命令将输出输入文件中每一行的内容两次,因为你一旦显式地要求使用 `print` 命令时,将会在每个处理循环结束时再隐式地输出一次(因为在这里我们不是在“静默模式”中运行 Sed)。 + +如果我们不想每个行看到两次,我们可以用两种方式去解决它: +``` +sed -n -e 'p' inputfile # 在静默模式中显式输出 +sed -e '' inputfile # 空的"什么都不做的"程序,隐式输出 + +``` + +注意:`-e` 选项是引入一个 Sed 命令。它被用于区分命令和文件名。由于一个 Sed 表达式必须包含至少一个命令,所以对于第一个命令,`-e` 标志不是必需的。但是,由于我个人使用习惯问题,为了与在这里的大多数的一个命令行上给出多个 Sed 表达式的更复杂的案例保持一致性。你自己去判断这是一个好习惯还是坏习惯,并且在本文的后面部分还将延用这一习惯。 + +### 地址 + +显而易见,`print` 命令本身并没有太多的用处。但是,如果你在它之前添加一个地址,这样它就只输出输入文件的一些行,这样它就突然变得能够从一个输入文件中过滤一些不希望的行。那么 Sed 的地址又是什么呢?它是如何来辨别输入文件的“行”呢? + +#### 行号 + +一个 Sed 的地址既可以是一个行号(`$` 表示“最后一行”)也可以是一个正则表达式。在使用行号时,你需要记住 Sed 中的行数是从 1 开始的 — 并且需要注意的是,它不是从 0 行开始的。 +``` +sed -n -e '1p' inputfile # 仅输出文件的第一行 +sed -n -e '5p' inputfile # 仅输出第 5 行 +sed -n -e '$p' inputfile # 输出文件的最后一行 +sed -n -e '0p' inputfile # 结果将是报错,因为 0 不是有效的行号 + +``` + +根据 [POSIX 规范][12],如果你指定了几个输出文件,那么它的行号是累加的。换句话说,当 Sed 打开一个新输入文件时,它的行计数器是不会被重置的。因此,以下的两个命令所做的事情是一样的。仅输出一行文本: +``` +sed -n -e '1p' inputfile1 inputfile2 inputfile3 +cat inputfile1 inputfile2 inputfile3 | sed -n -e '1p' + +``` + +实际上,确实在 POSIX 中规定了多个文件是如何处理的: + +> 如果指定了多个文件,将按指定的文件命名顺序进行读取并被串联编辑。 + +但是,一些 Sed 的实现提供了命令行选项去改变这种行为,比如, GNU Sed 的 `-s` 标志(在使用 GNU Sed `-i` 标志时,它也被隐式地应用): +``` +sed -sn -e '1p' inputfile1 inputfile2 inputfile3 + +``` + +如果你的 Sed 实现支持这种非标准选项,那么关于它的具体细节请查看 `man` 手册页。 + +#### 正则表达式 + +我前面说过,Sed 地址既可以是行号也可以是正则表达式。那么正则表达式是什么呢? + +正如它的名字,一个[正则表达式][13]是描述一个字符串集合的方法。如果一个指定的字符串符合一个正则表达式所描述的集合,那么我们就认为这个字符串与正则表达式匹配。 + +一个正则表达式也可以包含必须完全匹配的文本字符。例如,所有的字母和数字,以及大部分可以打印的字符。但是,一些符号有特定意义: + + * 它们可能相当于锚,像 `^` 和 `$` 它们分别表示一个行的开始和结束; + + * 对于整个字符集,另外的符号可能做为占位符(比如圆点 `.` 可以匹配任意单个字符,或者方括号用于定义一个自定义的字符集); + + * 另外的是表示重复出现的数量(像 [Kleene 星号][14] 表示前面的模式出现 0、1 或多次); + + + + +这篇文章的目的不是给大家讲正则表达式。因此,我只粘几个示例。但是,你可以在网络上随便找到很多关于正则表达式的教程,正则表达式的功能非常强大,它可用于许多标准的 Unix 命令和编程语言中,并且是每个 Unix 用户应该掌握的技能。 + +下面是使用 Sed 地址的几个示例: +``` +sed -n -e '/systemd/p' inputfile # 仅输出包含字符串"systemd"的行 +sed -n -e '/nologin$/p' inputfile # 仅输出以"nologin"结尾的行 +sed -n -e '/^bin/p' inputfile # 仅输出以"bin"开头的行 +sed -n -e '/^$/p' inputfile # 仅输出空行(即:开始和结束之间什么都没有的行) +sed -n -e '/./p' inputfile # 仅输出包含一个字符的行(即:非空行) +sed -n -e '/^.$/p' inputfile # 仅输出确实只包含一个字符的行 +sed -n -e '/admin.*false/p' inputfile # 仅输出包含字符串"admin"后面有字符串"false"的行(在它们之间有任意数量的任意字符) +sed -n -e '/1[0,3]/p' inputfile # 仅输出包含一个"1"并且后面是一个"0"或"3"的行 +sed -n -e '/1[0-2]/p' inputfile # 仅输出包含一个"1"并且后面是一个"0"、"1"、"2"或"3"的行 +sed -n -e '/1.*2/p' inputfile # 仅输出包含字符"1"后面是一个"2"(在它们之间有任意数量的字符)的行 +sed -n -e '/1[0-9]*2/p' inputfile # 仅输出包含字符"1"后面跟着0、1、或更多数字,最后面是一个"2"的行 + +``` + +如果你想在正则表达式(包括正则表达式分隔符)中去除字符的特殊意义,你可以在它前面使用一个斜杠: +``` +# 输出所有包含字符串"/usr/sbin/nologin"的行 +sed -ne '/\/usr\/sbin\/nologin/p' inputfile + +``` + +并不是限制你只能使用反斜杠作为地址中正则表达式的分隔符。你可以通过在第一个分隔符前面加上斜杠的方式,来使用任何你认为适合你需要和偏好的其它字符作为正则表达式的分隔符。当你用地址与带文件路径的字符一起来匹配的时,是非常有用的: +``` +# 以下两个命令是完全相同的 +sed -ne '/\/usr\/sbin\/nologin/p' inputfile +sed -ne '\=/usr/sbin/nologin=p' inputfile + +``` + +#### 扩展的正则表达式 + +默认情况下,Sed 的正则表达式引擎仅理解 [POSIX 基本正则表达式][15] 的语法。如果你需要用到 [扩展的正则表达式][16],你必须在 Sed 命令上添加 `-E` 标志。扩展的正则表达式在基本的正则表达式基础上增加了一组额外的特性,并且很多都是很重要的,他们所要求的斜杠要少很多。我们来比较一下: +``` +sed -n -e '/\(www\)\|\(mail\)/p' inputfile +sed -En -e '/(www)|(mail)/p' inputfile + +``` + +#### 括号量词 + +正则表达式之所以强大的一个原因是[范围量词][17]`{,}`。事实上,当你写一个不太精确匹配的正则表达式时,量词 `*` 就是一个非常完美的符号。但是,你需要显式在它边上添加一个下限和上限,这样就有了很好的灵活性。当量词范围的下限省略时,下限被假定为 0。当上限被省略时,上限被假定为无限大: + +|括号| 速记词 |解释| + +| {,} | * | 前面的规则出现 0、1、或许多遍 | +| {,1} | ? | 前面的规则出现 0 或 1 遍 | +| {1,} | + | 前面的规则出现 1 或许多遍 | +| {n,n} | {n} | 前面的规则精确地出现 n 遍 | + +括号在基本的正则表达式中也是可以使用的,但是它要求使用反斜杠。根据 POSIX 规范,在基本的正则表达式中可以使用的量词仅有星号(`*`)和括号(使用反斜杠 `\{m,n\}`)。许多正则表达式引擎都扩展支持 `\?` 和 `\+`。但是,为什么魔鬼如此有诱惑力呢?因为,如果你需要这些量词,使用扩展的正则表达式将不但易于写而且可移植性更好。 + +为什么我要花点时间去讨论关于正则表达式的括号量词,这是因为在 Sed 脚本中经常用这个特性去计数字符。 +``` +sed -En -e '/^.{35}$/p' inputfile # 输出精确包含 35 个字符的行 +sed -En -e '/^.{0,35}$/p' inputfile # 输出包含 35 个字符或更少字符的行 +sed -En -e '/^.{,35}$/p' inputfile # 输出包含 35 个字符或更少字符的行 +sed -En -e '/^.{35,}$/p' inputfile # 输出包含 35 个字符或更多字符的行 +sed -En -e '/.{35}/p' inputfile # 你自己指出它的输出内容(这是留给你的测试题) + +``` + +#### 地址范围 + +到目前为止,我们使用的所有地址都是唯一地址。在我们使用一个唯一地址时,命令是应用在与那个地址匹配的行上。但是,Sed 也支持地址范围。Sed 命令可以应用到那个地址范围中从开始到结束的所有地址中的所有行上: +``` +sed -n -e '1,5p' inputfile # 仅输出 1 到 5 行 +sed -n -e '5,$p' inputfile # 从第 5 行输出到文件结尾 + +sed -n -e '/www/,/systemd/p' inputfile # 输出与正则表达式 /www/ 匹配的第一行到与正则表达式 /systemd/ 匹配的接下来的行 + +``` + +如果在开始和结束地址上使用了同一个行号,那么范围就缩小为那个行。事实上,如果第二个地址的数字小于或等于地址范围中选定的第一个行的数字,那么仅有一个行被选定: +``` +printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '4,4p' + 4 bd +printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '4,3p' + 4 bd + +``` + +这就有点难了,但是在前面的段落中给出的规则也适用于起始地址是正则表达式的情况。在那种情况下,Sed 将对正则表达式匹配的第一个行的行号和给定的作为结束地址的显式的行号进行比较。再强调一次,如果结束行号小于或等于起始行号,那么这个范围将缩小为一行: +``` +# 这个 /b/,4 地址将匹配三个单行 +# 因为每个匹配的行有一个行号 >= 4 +printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '/b/,4p' + 4 bd + 5 be + 6 bf + +# 你自己指出匹配的范围是多少 +# 第二个例子: +printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '/d/,4p' + 1 ad + 2 ae + 3 af + 4 bd + 7 cd + +``` + +但是,当结束地址是一个正则表达式时,Sed 的行为将不一样。在那种情况下,地址范围的第一行将不会与结束地址进行检查,因此地址范围将至少包含两行(当然,如果输入数据不足的情况除外): +``` +printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '/b/,/d/p' + 4 bd + 5 be + 6 bf + 7 cd + +printf "%s\n" {a,b,c}{d,e,f} | cat -n | sed -ne '4,/d/p' + 4 bd + 5 be + 6 bf + 7 cd + +``` + +#### 互补 + +在一个地址选择行后面添加一个感叹号(`!`)表示不匹配那个地址。例如: +``` +sed -n -e '5!p' inputfile # 输出除了第 5 行外的所有行 +sed -n -e '5,10!p' inputfile # 输出除了第 5 到 10 之间的所有行 +sed -n -e '/sys/!p' inputfile # 输出除了包含字符串"sys"的所有行 + +``` + +#### 连接 + +Sed 允许在一个块中使用括号 (`{…}`) 组合命令。你可以利用这个特性去组合几个地址。例如,我们来比较下面两个命令的输出: +``` +sed -n -e '/usb/{ +/daemon/p +}' inputfile + +sed -n -e '/usb.*daemon/p' inputfile + +``` + +通过在一个块中嵌套命令,我们将在任意顺序中选择包含字符串 “usb” 和 “daemon” 的行。而正则表达式 “usb.*daemon” 将仅匹配在字符串 “daemon” 前面包含 “usb” 字符串的行。 + +离题太长时间后,我们现在重新回去学习各种 Sed 命令。 + +### quit 命令 + +quit 命令(`q`)是指在当前的迭代循环处理结束之后停止 Sed。 + +![The Sed `quit` command][18] + +quit 命令是在到达输入文件的尾部之前停止处理输入的方法。为什么会有人想去那样做呢? + +很好的问题,如果你还记得,我们可以使用下面的命令来输出文件中第 1 到第 5 的行: +``` +sed -n -e '1,5p' inputfile + +``` + +对于 大多数 Sed 的实现,工具将循环读取输入文件的所有行,那怕是你只处理结果中的前 5 行。如果你的输入文件包含了几百万行(或者更糟糕的情况是,你从一个无限的数据流(比如像 `/dev/urandom` )中读取)。 + +使用 quit 命令,相同的程序可以被修改的更高效: +``` +sed -e '5q' inputfile + +``` + +由于我在这里并不使用 `-n` 选项,Sed 将在每个循环结束后隐式输出 `pattern` 空间的内容。但是在你处理完第 5 行后,它将退出,并且因此不会去读取更多的数据。 + +我们能够使用一个类似的技巧只输出文件中一个特定的行。那将是一个好机会,你将看到从命令行中提供多个 Sed 表达式的几种方法。下面的三个变体都可以从 Sed 中接受命令,要么是不同的 `-e` 选项,要么是在相同的表达式中新起一行或用分号(`;`)隔开: +``` +sed -n -e '5p' -e '5q' inputfile + +sed -n -e ' + 5p + 5q +' inputfile + +sed -n -e '5p;5q' inputfile + +``` + +如果你还记得,我们在前面看到过能够使用括号将命令组合起来,在这里我们使用它来防止相同的地址重复两次: +``` +# 组合命令 +sed -e '5{ + p + q +}' inputfile + +# Which can be shortened as: +sed '5{p;q;}' inputfile + +# As a POSIX extension, some implementations makes the semi-colon before the closing bracket optional: +sed '5{p;q}' inputfile + +``` + +### substitution 命令 + +你可以将替换命令想像为 Sed 的“查找替换”功能,这个功能在大多数的“所见即所得”的编辑器上都能找到。Sed 的替换命令与之类似,但比它们更强大。替换命令是 Sed 中最著名的命令之一,在网上有大量的关于这个命令的文档。 + +![The Sed `substitution` command][19] + +[在前一篇文章][20]中我们已经讲过它了,因此,在这里就不再重复了。但是,如果你对它的使用不是很熟悉,那么你需要记住下面的这些关键点: + + * 替换命令有两个参数:查找模式和替换字符串:`sed s/:/-----/ inputfile` + + * 命令和它的参数是用任意一个字符来分隔的。这主要看你的习惯,在 99% 的时间中我都使用斜杠,但也会用其它的字符:`sed s%:%-----% inputfile`、`sed sX:X-----X inputfile` 或者甚至是 `sed 's : ----- ' inputfile` + + * 默认情况下,替换命令仅被应用到 `pattern` 空间中匹配到的第一个字符串上。你可以通过在命令之后指定一个匹配指数作为标志来改变这种情况:`sed 's/:/-----/1' inputfile`、`sed 's/:/-----/2' inputfile`、`sed 's/:/-----/3' inputfile`、… + + * 如果你想执行一个全面的替换(即:在 `pattern` 空间上的每个非重叠匹配),你需要增加 `g` 标志:`sed 's/:/-----/g' inputfile` + + * 在字符串替换中,出现的任何一个 `&` 符号都将被与查找模式匹配的子字符串替换:`sed 's/:/-&&&-/g' inputfile`、`sed 's/…./& /g' inputfile` + + * 圆括号(在扩展的正则表达式中的 `(…)` 或者基本的正则表达式中的 `\(…\)`)被引用为捕获组。那是匹配字符串的一部分,可以在替换字符串中被引用。`\1` 是第一个捕获组的内容,`\2` 是第二个捕获组的内容,依次类推:`sed -E 's/(.)(.)/\2\1/g' inputfile`、`sed -E 's/(.):x:(.):(.*)/\1:\3/' inputfile`(后者之所能正常工作是因为 [正则表达式中的量词星号表示重复匹配下去,直到不匹配为止][21],并且它可以匹配许多个字符) + + * 在查找模式或替换字符串时,你可以通过使用一个反斜杠来去除任何字符的特殊意义:`sed 's/:/--\&--/g' inputfile`,`sed 's/\//\\/g' inputfile` + + + + +所有的这些看起来有点抽象,下面是一些示例。首先,我想去显示我的测试输入文件的第一个字段并给它在右侧附加 20 个空格字符,我可以这样写: +``` +sed < inputfile -E -e ' + s/:/ / # 用 20 个空格替换第一个字段的分隔符 + s/(.{20}).*/\1/ # 只保留一行的前 20 个字符 + s/.*/| & |/ # 为了输出好看添加竖条 +' + +``` + +第二个示例是,如果我想将用户 sonia 的 UID/GID 修改为 1100,我可以这样写: +``` +sed -En -e ' + /sonia/{ + s/[0-9]+/1100/g + p + }' inputfile + +``` + +注意在替换命令结束部分的 `g` 选项。这个选项改变了它的行为,因此它将查找全部的 `pattern` 空间并替换,如果没有那个选项,它只替换查找到的第一个。 + +顺便说一下,这也是使用前面讲过的输出(`p`)命令的好机会,可以在命令运行时输出修改前后时刻 `pattern` 空间的内容。因此,为了获得替换前后的内容,我可以这样写: +``` +sed -En -e ' + /sonia/{ + p + s/[0-9]+/1100/g + p + }' inputfile + +``` + +事实上,替换后输出一个行是很常见的用法,因此,替换命令也接受 `p` 选项: +``` +sed -En -e '/sonia/s/[0-9]+/1100/gp' inputfile + +``` + +最后,我就不详细讲替换命令的 `w` 选项了,我们将在稍后的学习中详细介绍。 + +#### delete 命令 + +删除命令(`d`)用于清除 `pattern` 空间的内容,然后立即开始下一个处理循环。这样它将会跳过隐式输出 `pattern` 空间内容的行为,即便是你设置了自动输出标志(AP)也不会输出。 + +![The Sed `delete` command][22] + +只输出一个文件前五行的一个很低效率的方法将是: +``` +sed -e '6,$d' inputfile + +``` + +你猜猜看,我为什么说它很低效率?如果你猜不到,建议你再次去阅读前面的关于 quit 命令的章节,答案就在那里! + +当你组合使用正则表达式和地址,从输出中删除匹配的行时,delete 命令将非常有用: +``` +sed -e '/systemd/d' inputfile + +``` + +#### next 命令 + +如果 Sed 命令不是在静默模式中运行,这个命令将输出当前 `pattern` 空间的内容,然后,在任何情况下它将读取下一个输入行到 `pattern` 空间中,并使用新的 `pattern` 空间中的内容来运行当前循环中剩余的命令。 + +![The Sed `next` command][23] + +常见的用 next 命令去跳过行的一个示例: +``` +cat -n inputfile | sed -n -e 'n;n;p' + +``` + +在上面的例子中,Sed 将隐式地读取输入文件的第一行。但是 `next` 命令将丢弃对 `pattern` 空间中的内容的输出(不输出是因为使用了 `-n` 选项),并从输入文件中读取下一行来替换 `pattern` 空间中的内容。而第二个 `next` 命令做的事情和前一个是一模一样的,这就实现了跳过输入文件 2 行的目的。最后,这个脚本显式地输出包含在 `pattern ` 空间中的输入文件的第三行的内容。然后,Sed 将启动一个新的循环,由于 `next` 命令,它会隐式地读取第 4 行的内容,然后跳过它,同样地也跳过第 5 行,并输出第 6 行。如此循环,直到文件结束。总体来看,这个脚本就是读取输入文件然后每三行输出一行。 + +使用 next 命令,我们也可以找到一些显示输入文件的前五行的几种方法: +``` +cat -n inputfile | sed -n -e '1{p;n;p;n;p;n;p;n;p}' +cat -n inputfile | sed -n -e 'p;n;p;n;p;n;p;n;p;q' +cat -n inputfile | sed -e 'n;n;n;n;q' + +``` + +更有趣的是,如果你需要根据一些地址来处理行时,next 命令也非常有用: +``` +cat -n inputfile | sed -n '/pulse/p' # 输出包含 "pulse" 的行 +cat -n inputfile | sed -n '/pulse/{n;p}' # 输出包含 "pulse" 之后的行 +cat -n inputfile | sed -n '/pulse/{n;n;p}' # 输出下面的行 + # 下一行 + # 包含 "pulse" 的行 + +``` + +### 使用 `hold` 空间 + +到目前为止,我们所看到的命令都是仅使用了 `pattern` 空间。但是,我们在文章的开始部分已经提到过,还有第二个缓冲区:`hold` 空间,它完全由用户管理。它就是我们在第二节中描述的目标。 + +#### exchange 命令 + +正如它的名字所表示的,exchange 命令(`x`)将交换 `hold` 空间和 `pattern` 空间的内容。记住,你只要没有把任何东西放入到 `hold` 空间中,那么 `hold` 空间就是空的。 + +![The Sed `exchange` command][24] + +作为第一个示例,我们可使用 exchange 命令去反序输出一个输入文件的前两行: +``` +cat -n inputfile | sed -n -e 'x;n;p;x;p;q' + +``` + +当然,在你设置 `hold` 之后你并没有立即使用它的内容,因为只要你没有显式地去修改它, `hold` 空间中的内容就保持不变。在下面的例子中,我在输入一个文件的前五行后,使用它去删除第一行: +``` +cat -n inputfile | sed -n -e ' + 1{x;n} # 交换 hold 和 pattern 空间 + # 保存第 1 行到 hold 空间中 + # 然后读取第 2 行 + 5{ + p # 输出第 5 行 + x # 交换 hold 和 pattern 空间 + # 去取得第 1 行的内容放回到 + # pattern 空间 + } + + 1,5p # 输出第 2 到第 5 行 + # (不要输错了!尝试找出这个规则 + # 没有在第 1 行上运行的原因;) +' + +``` + +#### hold 命令 + +hold 命令(`h`)是用于将 `pattern` 空间中的内容保存到 `hold` 空间中。但是,与 exchange 命令不同的是,`pattern` 空间中的内容不会被改变。hold 命令有两种用法: + + * `h` +将复制 `pattern` 空间中的内容到 `hold` 空间中,将覆盖 `hold` 空间中任何已经存在的内容。 + + * `H` +使用一个独立的新行,追加 `pattern` 空间中的内容到 `hold` 空间中。 + + + + +![The Sed `hold` command][25] + +上面使用 exchange 命令的例子可以使用 hold 命令重写如下: +``` +cat -n inputfile | sed -n -e ' + 1{h;n} # 保存第 1 行的内容到 hold 缓冲区并继续 + 5{ # 到第 5 行 + x # 交换 pattern 和 hold 空间 + # (现在 pattern 空间包含了第 1 行) + H # 在 hold 空间的第 5 行后追回第 1 行 + x # 再次交换取回第 5 行并将第 1 行插入 + # 到 pattern 空间 + } + + 1,5p # 输出第 2 行到第 5 行 + # (不要输错!尝试去打到为什么这个规则 + # 不在第 1 行上运行;) +' + +``` + +#### get 命令 + +get 命令(`g`)与 hold 命令恰好相反:它从 `hold` 空间中取得内容并将它置入到 `pattern` 空间中。同样它也有两种方式: + + * `g` +它将复制 `hold` 空间中的内容并将其放入到 `pattern` 空间,覆盖 `pattern`空间中已存在的任何内容 + + * `G` +使用一个单独的新行,追加 `hold` 空间中的内容到 `pattern` 空间中 + + + + +![The Sed `get` command][26] + +将 hold 命令和 get 命令一起使用,可以允许你去存储并调回数据。作为一个小挑战,我让你重写前一节中的示例,将输入文件的第 1 行放置在第 5 行之后,但是这次必须使用 get 和 hold 命令(注意大小写)而不能使用 exchange 命令。只要运气好,它将使那个方式更简单! + +在这期间,我可以给你展示另一个示例,它能给你一些灵感。目标是将拥有登录 shell 权限的用户与其它用户分开: +``` +cat -n inputfile | sed -En -e ' + \=(/usr/sbin/nologin|/bin/false)$= { H;d; } + # 追回匹配的行到 hold 空间 + # 然后继续下一个循环 + p # 输出其它行 + $ { g;p } # 在最后一行上 + # 取得并输出 hold 空间中的内容 +' + +``` + +### 复习 print、delete 和 next + +现在你已经更熟悉使用 hold 空间了,我们回到 print、delete 和 next 命令。我们已经讨论了小写的 `p`、`d` 和 `n` 命令了。而它们也有大写的版本。因为每个命令都有大小写版本,似乎是 Sed 的习惯,这些命令的大写版本将与多行缓冲区有关: + + * `P` +将 `pattern` 空间中第一个新行之前的内容输出 + + * `D` +删除 `pattern` 空间中的内容并且包含新行,然后不读取任何新的输入而是使用剩余的文本去重启一个循环 + + * `N` +使用一个换行符作为新旧数据的分隔符,然后读取并追加一个输入的新行到 `pattern` 空间。继续运行当前的循环。 + + + + +![The Sed uppercase `Delete` command][27] +![The Sed uppercase `Next` command][28] + +这些命令的使用场景主要用于实现队列([FIFO 列表][29])。从一个输入文件中删除最后 5 行就是一个很权威的例子: +``` +cat -n inputfile | sed -En -e ' + 1 { N;N;N;N } # 确保 pattern 空间中包含 5 行 + + N # 追加第 6 行到队列中 + P # 输出队列的第 1 行 + D # 删除队列的第 1 行 +' + +``` + +作为第二个示例,我们可以在两个列上显示输入数据: +``` +# 输出两列 +sed < inputfile -En -e ' + $!N # 追加一个新行到 pattern 空间 + # 除了输入文件的最后一行 + # 当在输入文件的最后一行使用 N 命令时 + # GNU Sed 和 POSIX Sed 的行为是有差异的 + # 需要使用一个技巧去处理这种情况 + # https://www.gnu.org/software/sed/manual/sed.html#N_005fcommand_005flast_005fline + + # 用空间填充第 1 行的第 1 个字段 + # 并丢弃其余行 + s/:.*\n/ \n/ + s/:.*// # 除了第 2 行上的第 1 个字段外,丢弃其余的行 + s/(.{20}).*\n/\1/ # 修剪并连接行 + p # 输出结果 +' + +``` + +### 分支 + +我们刚才已经看到,Sed 因为有 `hold` 空间所以有了缓存的功能。其实它还有测试和分支的指令。因为有这些特性使得 Sed 是一个[图灵完备][30]的语言。虽然它可能看起来很傻,但意味着你可以使用 Sed 写任何程序。你可以实现任何你的目的,但并不意味着实现起来会很容易,而且结果也不一定会很高效。 + +但是,不用担心。在本文中,我们将使用能够展示测试和分支功能的最简单的例子。虽然这些功能乍一看似乎很有限,但请记住,有些人用 Sed 写了 [calculators]、 [Tetris] 或许多其它类型的应用程序! + +#### 标签和分支 + +从某些方面,你可以将 Sed 看到是一个功能有限的汇编语言。因此,你不会找到在高级语言中常见的 “for” 或 “while” 循环,或者 “if … else” 语句,但是你可以使用分支来实现同样的功能。 + +![The Sed `branch` command][31] + +如果你在本文开始部分看到了用流程图描述的 Sed 运行模型,那么你应该知道 Sed 会自动增加程序计数器的值,命令是按程序的指令顺序来运行的。但是,使用分支指令,你可以通过选择程序中的任意命令来改变顺序运行的程序。跳转目的地是使用一个标签来显式定义的。 + +![The Sed `label` command][32] + +这是一个这样的示例: +``` +echo hello | sed -ne ' + :start # 在程序的那个行上放置一个 "start" 标签 + p # 输出 pattern 空间内容 + b start # 继续在 :start 标签上运行 +' | less + +``` + +那个 Sed 程序的行为非常类似于 `yes` 命令:它获取一个流并产生一个包含那个字符串的无限流。 + +切换到一个标签就像我们旁通了 Sed 的自动化特性一样:它既不读取任何输入,也不输出任何内容,更不更新任何缓冲区。它只是跳转到一个不同于源程序指令顺序的另一个指令。 + +值得一提的是,如果在分支命令(`b`)上没有指定一个标签作为它的参数,那么分支将直接切换到程序结束的地方。因此,Sed 将启动一个新的循环。这个特性可以用于去旁通一些指令并且因此可以用于作为块的替代者: +``` +cat -n inputfile | sed -ne ' +/usb/!b +/daemon/!b +p +' + +``` + +#### 条件分支 + +到目前为止,我们已经看到了无条件分支,这个术语可能有点误导嫌疑,因为 Sed 命令总是基于它们的可选地址来作为条件的。 + +但是,在传统意义上,一个无条件分支也是一个分支,当它运行时,将跳转到特定的目的地,而条件分支既有可能也或许不可能跳转到特定的指令,这取决于系统的当前状态。 + +Sed 只有一个条件指令,就是 test(`t`) 命令。只有在当前循环的开始或因为前一个条件分支运行了替换,它才跳转到不同的指令。更多的情况是,只有替换标志被设置时,test 命令才会切换。 + +![The Sed `test` command][3]![The Sed `test` command][33] + +使用 test 指令,你可以在一个 Sed 程序中很轻松地执行一个循环。作为一个特定的示例,你可以用它将一个行填充到某个长度(这是使用正则表达式无法实现的): +``` +# Center text +cut -d: -f1 inputfile | sed -Ee ' + :start + s/^(.{,19})$/ \1 / # 用空格在开始处填充少于 20 个字符的行 + # 并在结束处 + # 添加一个空格 + t start # 如果我们已经添加了一个空格,则返回到 :start 标签 + s/(.{20}).*/| \1 |/ # 保留一个行的前 20 个字符 + # 以修复由于奇数行引起的 + # 差一错误 +' + +``` + +如果你仔细读前面的示例,你可能注意到,在将要把数据“喂”给 Sed 之前,我会通过使用 cut 命令创建一个比特去预处理数据。 + +然后,我们可以只使用 Sed 对程序做一些小的修改来执行相同的任务: +``` +cat inputfile | sed -Ee ' + s/:.*// # 除第 1 个字段外删除剩余字段 + t start + :start + s/^(.{,19})$/ \1 / # 在开始处使用空格去填充 + # 并在结束处填充一个空格 + # 使行的长度不短于 20 个字符 + t start # 如果添加了一个空格,则返回到 :start + s/(.{20}).*/| \1 |/ # 仅保留一个行的前 20 个字符 + # 以修复由于奇数行引起的 + # 差一错误 +' + +``` + +在上面的示例中,你或许对下列的结构感到惊奇: +``` +t start +:start + +``` + +乍一看,在这里的分支并没有用,因为它只是跳转到将要运行的指令处。但是,如果你仔细阅读了 `test` 命令的定义,你将会看到,如果在当前循环的开始或者前一个 test 命令运行后发生了一个替换,分支才会起作用。换句话说就是,test 指令有清除替换标志的副作用。这也正是上面的代码片段的真实目的。这是一个在包含条件分支的 Sed 程序中经常看到的技巧,用于在使用多个替换命令时避免出现 false 的情况。 + +通过它并不能绝对强制地清除替换标志,我同意这一说法。因为我使用的特定的替换命令在将字符串填充到正确的长度时是幂等的。因此,一个多余的迭代并不会改变结果。不过,我们可以现在再次看一下第二个示例: +``` +# 基于它们的登录程序来分类用户帐户 +cat inputfile | sed -Ene ' + s/^/login=/ + /nologin/s/^/type=SERV / + /false/s/^/type=SERV / + t print + s/^/type=USER / + :print + s/:.*//p +' + +``` + +我希望在这里根据用户默认配置的登录程序,为用户帐户打上 “SERV” 或 “USER” 的标签。如果你运行它,预计你将看到 “SERV” 标签。然而,并没有在输出中跟踪到 “USER” 标签。为什么呢?因为 `t print` 指令不论行的内容是什么,它总是切换,替换标志总是由程序的第一个替换命令来设置。一旦替换标志设置完成后,在下一个行被读取或直到下一个 test 命令之前,这个标志将保持不变。下面我们给出修复这个程序的解决方案: +``` +# 基于用户登录程序来分类用户帐户 +cat inputfile | sed -Ene ' + s/^/login=/ + + t classify # clear the "substitution flag" + :classify + + /nologin/s/^/type=SERV / + /false/s/^/type=SERV / + t print + s/^/type=USER / + :print + s/:.*//p +' + +``` + +### 精确地处理文本 + +Sed 是一个非交互式文本编辑器。虽然是非交互式的,但仍然是文本编辑器。而如果没有在输出中插入一些东西的功能,那它就不算一个完整的文本编辑器。我不是很喜欢它的文本编辑的特性,因为我发现它的语法太难用了(即便是使用标准的 Sed),但有时你难免会用到它。 + +在严格的 POSIX 语法中,所有通过这三个命令:change(`c`)、insert(`i`)或 append(`a`)来处理一些到输出的文字文本,都遵循相同的特定语法:命令字母后面跟着一个反斜杠,并且文本从脚本的下一行上开始插入: +``` +head -5 inputfile | sed ' +1i\ +# List of user accounts +$a\ +# end +' + +``` + +插入多行文本,你必须每一行结束的位置使用一个反斜杠: +``` +head -5 inputfile | sed ' +1i\ +# List of user accounts\ +# (users 1 through 5) +$a\ +# end +' + +``` + +一些 Sed 实现,比如 GNU Sed,在初始的反斜杠后面有一个可选的换行符,即便是在 `--posix` 模式下仍然如此。我在标准中并没有找到任何关于替代该语法的授权(如果是因为我没有在标准中找到那个特性,请在评论区留言告诉我!)。因此,如果对可移植性要求很高,请注意使用它的风险: +``` +# 非 POSIX 语法: +head -5 inputfile | sed -e ' +1i \# List of user accounts +$a\# end +' + +``` + +也有一些 Sed 的实现,让初始的反斜杠完全是可选的。因此毫无疑问,它是一个厂商对 POSIX 标准进行扩展的特定版本,它是否支持那个语法,你需要去查看那个 Sed 版本的手册。 + +在简单概述之后,我们现在来回顾一下这些命令的更多细节,从我还没有介绍的 change 命令开始。 + +#### change 命令 + +change 命令(`c\`)就像 `d` 命令一样删除 `pattern` 空间的内容并开始一个新的循环。唯一的不同在于,当命令运行之后,用户提供的文本是写往输出的。 + +![The Sed `change` command][34] +``` +cat -n inputfile | sed -e ' +/systemd/c\ +# :REMOVED: +s/:.*// # This will NOT be applied to the "changed" text +' + +``` + +如果 change 命令与一个地址范围关联,当到达范围的最后一行时,这个文本将仅输出一次。这在某种程度上成为 Sed 命令将被重复应用在地址范围内所有行这一惯例的一个例外情况: +``` +cat -n inputfile | sed -e ' +19,22c\ +# :REMOVED: +s/:.*// # This will NOT be applied to the "changed" text +' + +``` + +因此,如果你希望将 change 命令重复应用到地址范围内的所有行上,除了将它封装到一个块中之外,你将没有其它的选择: +``` +cat -n inputfile | sed -e ' +19,22{c\ +# :REMOVED: +} +s/:.*// # This will NOT be applied to the "changed" text +' + +``` + +#### insert 命令 + +insert 命令(`i\`)将立即在输出中给出用户提供的文本。它并不以任何方式修改程序流或缓冲区的内容。 + +![The Sed `insert` command][35] +``` +# display the first five user names with a title on the first row +sed < inputfile -e ' +1i\ +USER NAME +s/:.*// +5q +' + +``` + +#### append 命令 + +当输入的下一行被读取时,append 命令(`a\`)将一些文本追加到显示队列。文本在当前循环的结束部分(包含程序结束的情况)或当使用 `n` 或 `N` 命令从输入中读取一个新行时被输出。 + +![The Sed `append` command][36] + +与上面相同的一个示例,但这次是插入到底部而是顶部: +``` +sed < inputfile -e ' +5a\ +USER NAME +s/:.*// +5q +' + +``` + +#### read 命令 + +这是插入一些文本内容到输出流的第四个命令:read 命令(`r`)。它的工作方式与 append 命令完全一样,但不同的,它不从 Sed 脚本中取得硬编码到脚本中的文本,而是在一个输出上写一个文件的内容。 + +read 命令只调度要读取的文件。当刷新 append 队列时,后者被高效地读取,而不是在 read 命令运行时。如果这时候对这个文件有并发的访问,或那个文件不是一个普通的文件(比如,它是一个字符设备或命名管道),或文件在读取期间被修改,这时可能会产生严重的后果。 + +作为一个例证,如果你使用我们将在下一次详细讲的 write 命令,它与 read 命令共同去写入并从一个临时文件中重新读取,你可能会获得一些创造性的结果(使用法语版的 [Shiritori][37] 游戏作为一个例证): +``` +printf "%s\n" "Trois p'tits chats" "Chapeau d' paille" "Paillasson" | +sed -ne ' + r temp + a\ + ---- + w temp +' + +``` + +现在,在流输出中专门用于插入一些文本的 Sed 命令的清单结束了。我的最后一个示例纯属好玩,但是由于我前面提到过有一个 write 命令,这个示例将我们完美地带到下一节,在下一节我们将看到在 Sed 中如何将数据写入到一个外部文件。 + +### 输出的替代 + +Sed 的设计思想是,所有的文本转换都将写入到进程的标准输出上。但是,Sed 也有一些特性支持将数据发送到替代的目的地。你有两种方式去实现上述的输出目标替换:使用专门的 `write` 命令,或者在一个 `substitution` 命令上添加一个写入标志。 + +#### write 命令 + +write 命令(`w`)追加 `pattern` 空间的内容到给定的目标文件中。POSIX 要求在 Sed 处理任何数据之前,目标文件能够被 Sed 所创建。如果给定的目标文件已经存在,它将被覆写。 + +![The Sed `write` command][38] + +因此,即便是你从未真实地去写入到一个文件中,但文件仍然会被创建。例如,下列的 Sed 程序将创建/覆写这个 “output” 文件,那怕是这个写入命令从未被运行过: +``` +echo | sed -ne ' +q # 立刻退出 +w output # 这个命令从未被运行 +' + +``` + +你可以将几个写入命令指向到同一个目标文件。指向同一个目标文件的所有写入命令将追加那个文件的内容(工作方式几乎与 shell 的重定向符 `>>` 相同): +``` +sed < inputfile -ne ' +/:\/bin\/false$/w server +/:\/usr\/sbin\/nologin$/w server +w output +' +cat server + +``` + +#### 替换命令的写入标志 + +在前面,我们已经学习了替换命令,它有一个 `p` 选项用于在替换之后输出 `pattern` 空间的内容。同样它也提供一个类似功能的 `w` 选项,用于在替换之后将 `pattern` 空间的内容输出到一个文件中: +``` +sed < inputfile -ne ' +s/:.*\/nologin$//w server +s/:.*\/false$//w server +' +cat server + +``` + +我无数次使用过它们,但我从未花时间正式介绍过它们,因此,我决定现在来正式地介绍它们:就像大多数编程语言一样,注释是添加软件不去解析的自由格式文本的一种方法。Sed 的语法很晦涩,我不得不强调在脚本中需要的地方添加足够的注释。否则,除了作者外其他人将几乎无法理解它。 + +![The Sed `comment` command][39] + +不过,和 Sed 的其它部分一样,注释也有它自己的微妙之处。首先并且是最重要的,注释并不是语法结构,但它在 Sed 中很成熟。注释虽然是一个“什么也不做”的命令,但它仍然是一个命令。至少,它是在 POSIX 中定义了的。因此,严格地说,它们只允许使用在其它命令允许使用的地方。 + +大多数 Sed 实现都通过允许行内命令来放松了那种要求,就像在那个文章中我到处都使用的那样。 + +结束那个主题之前,需要说一下 `#n` 注释(`#` 后面紧跟一个`n`,中间没有空格)的特殊情况。如果在脚本的第一行找到这个精确注释,Sed 将切换到静默模式(即:清除自动输出标志),就像在命令行上指定了 `-n` 选项一样。 + +### 很少用得到的命令 + +现在,我们已经学习的命令能让你写出你所用到的 99.99% 的脚本。但是,如果我没有提到剩余的 Sed 命令,那么本教程就不能称为完全指南。我把它们留到最后是因为我们很少用到它。但或许你有实际使用案例,那么你就会发现它们很有用。如果是那样,请不要犹豫,在下面的评论区中把它分享给我们吧。 + +#### 行数命令 + +这个 `=` 命令将向标准输出上显示当前 Sed 正在读取的行数,这个行数就是行计数器的内容。没有任何方式从任何一个 Sed 缓冲区中捕获那个数字,也不能对它进行输出格式化。由于这两个限制使得这个命令的可用性大大降低。 + +![The Sed `line number` command][40] + +请记住,在严格的 POSIX 兼容模式中,当在命令行上给定几个输入文件时,Sed 并不重置那个计数器,而是连续地增长它,就像所有的输入文件是连接在一起的一样。一些 Sed 实现,像 GNU Sed,它就有一个选项可以在每个输入文件读取结束后去重置计数器。 + +#### 明确的 print 命令 + +这个 `l`(小写的字母 `l`)作用类似于 print 命令(`p`),但它是以精确的格式去输出 `pattern` 空间的内容。以下引用自 [POSIX 标准][12]: + +> 在 XBD 转义序列中列出的字符和相关的动作(‘\\\’、‘\a’、‘\b’、‘\f’、‘\r’、‘\t’、‘\v’)将被写为相应的转义序列;在那个表中的 ‘\n’ 是不适用的。不在那个表中的不可打印字符将被写为一个三位八进制数字(在前面使用一个 <反斜杠>),表示字符中的每个字节(最重要的字节在前面)。长行应该被换行,通过写一个 <反斜杠>后跟一个 <换行符> 来表示换行点;发生换行时的长度是不确定的,但应该适合输出设备的具体情况。每个行应该以一个 ‘$’ 标记结束。 + +![The Sed `unambiguous print` command][3]![The Sed `unambiguous print` command][41] + +我怀疑这个命令是在非 [8位规则化信道][42] 上交换数据的。就我本人而言,除了调试用途以外,也从未使用过它。 + +#### transliterate 命令 + +移译transliterate(`y`)命令允许映射 `pattern` 空间的字符从一个源集到一个目标集。它非常类似于 `tr` 命令,但是限制更多。 + +![The Sed `transliterate` command][43] +``` +# The `y` c0mm4nd 1s for h4x0rz only +sed < inputfile -e ' + s/:.*// + y/abcegio/48<3610/ +' + +``` + +虽然 transliterate 命令语法与 substitution 命令的语法有一些相似之处,但它在替换字符串之后不接受任何选项。这个移译总是全局的。 + +请注意,移译命令要求源集和目标集之间要一一对应地转换。这意味着下面的 Sed 程序可能所做的事情并不是你乍一看所想的那样: + +``` +# BEWARE: this doesn't do what you may think! +sed < inputfile -e ' + s/:.*// + y/[a-z]/[A-Z]/ +' + +``` + +### 写在最后的话 +``` +# 它要做什么? +# 提示:答案就在不远处... +sed -E ' + s/.*\W(.*)/\1/ + h + ${ x; p; } + d' < inputfile + +``` + +我们已经学习了所有的 Sed 命令,真不敢相信我们已经做到了!如果你也读到这里了,应该恭喜你,尤其是如果你花费了一些时间,在你的系统上尝试了所有的不同示例! + +正如你所见,Sed 是非常复杂的,不仅因为它的语法比较零乱,也因为许多极端案例或命令行为之间的细微差别。毫无疑问,我们可以将这些归结于历史的原因。尽管它有这么多缺点,但是 Sed 仍然是一个非常强大的工具,甚至到现在,它仍然是大量使用的、为数不多的 Unix 工具箱中的命令之一。是时候总结一下这篇文章了,如果你不先支持我,我将不去总结它:请节选你对喜欢的或最具创意的 Sed 脚本,并共享给我们。如果我收集到的你们共享出的脚本足够多了,我将会把这些 Sed 脚本结集发布! + +-------------------------------------------------------------------------------- + +via: https://linuxhandbook.com/sed-reference-guide/ + +作者:[Sylvain Leroux][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://linuxhandbook.com/author/sylvain/ +[1]:https://linuxhandbook.com/sed-command-basics/ +[2]:https://gist.github.com/s-leroux/5cb36435bac46c10cfced26e4bf5588c +[3]:https://linuxhandbook.com/wp-content/plugins/jetpack/modules/lazy-images/images/1x1.trans.gif +[4]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05/sed-reference-guide.jpeg?resize=702%2C395&ssl=1 +[5]:http://mathworld.wolfram.com/AbstractMachine.html +[6]:https://en.wikipedia.org/wiki/State_(computer_science) +[7]:https://en.wikipedia.org/wiki/Data_buffer +[8]:https://en.wikipedia.org/wiki/Processor_register#Categories_of_registers +[9]:https://www.computerhope.com/jargon/f/flag.htm +[10]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-flowchart.png?w=702&ssl=1 +[11]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-print-command.png?w=702&ssl=1 +[12]:http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html +[13]:https://www.regular-expressions.info/ +[14]:https://chortle.ccsu.edu/FiniteAutomata/Section07/sect07_16.html +[15]:https://www.regular-expressions.info/posix.html#bre +[16]:https://www.regular-expressions.info/posix.html#ere +[17]:https://www.regular-expressions.info/repeat.html#limit +[18]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-quit-command.png?w=702&ssl=1 +[19]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-substitution-command.png?w=702&ssl=1 +[20]:https://linuxhandbook.com/?p=128 +[21]:https://www.regular-expressions.info/repeat.html#greedy +[22]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-delete-command.png?w=702&ssl=1 +[23]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-next-command.png?w=702&ssl=1 +[24]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-exchange-command.png?w=702&ssl=1 +[25]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-hold-command.png?w=702&ssl=1 +[26]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-get-command.png?w=702&ssl=1 +[27]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-delete-upper-command.png?w=702&ssl=1 +[28]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-next-upper-command.png?w=702&ssl=1 +[29]:https://en.wikipedia.org/wiki/FIFO_(computing_and_electronics) +[30]:https://chortle.ccsu.edu/StructuredC/Chap01/struct01_5.html +[31]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-branch-command.png?w=702&ssl=1 +[32]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-label-command.png?w=702&ssl=1 +[33]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-test-command.png?w=702&ssl=1 +[34]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-change-command.png?w=702&ssl=1 +[35]:https://i0.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-insert-command.png?w=702&ssl=1 +[36]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-append-command.png?w=702&ssl=1 +[37]:https://en.wikipedia.org/wiki/Shiritori +[38]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-write-command.png?w=702&ssl=1 +[39]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-comment-command.png?w=702&ssl=1 +[40]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-current-line-command.png?w=702&ssl=1 +[41]:https://i2.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-unambiguous-print-command.png?w=702&ssl=1 +[42]:https://en.wikipedia.org/wiki/8-bit_clean +[43]:https://i1.wp.com/linuxhandbook.com/wp-content/uploads/2018/05//sed-transliterate-command.png?w=702&ssl=1 From 21653ba5a1a66ab4a116f7345800f9f9e49c3229 Mon Sep 17 00:00:00 2001 From: pityonline Date: Fri, 19 Oct 2018 00:07:47 +0800 Subject: [PATCH 041/158] =?UTF-8?q?PRF:=20#10709=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 --- ...files with ls at the Linux command line.md | 39 +++++++++---------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/translated/tech/20181003 Tips for listing files with ls at the Linux command line.md b/translated/tech/20181003 Tips for listing files with ls at the Linux command line.md index b0fe9643da..110dd5f446 100644 --- a/translated/tech/20181003 Tips for listing files with ls at the Linux command line.md +++ b/translated/tech/20181003 Tips for listing files with ls at the Linux command line.md @@ -1,24 +1,25 @@ 在 Linux 命令行中使用 ls 列出文件的提示 ====== -学习一些 Linux "ls" 命令最有用的变化。 + +学习一些 Linux `ls` 命令最有用的变化。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/button_push_open_keyboard_file_organize.png?itok=KlAsk1gx) -我在 Linux 中最先学到的命令之一就是 `ls`。了解系统中文件所在目录中的内容非常重要。能够查看和修改不仅仅是一些文件还要所有文件也很重要。 +我在 Linux 中最先学到的命令之一就是 `ls`。了解系统中文件所在目录中的内容非常重要。能够查看和修改不仅仅是一些文件还有所有文件也很重要。 -我的第一个 Linux 备忘录是[单页 Linux 手册][1],它于 1999 年发布,它成为我的首选参考资料。当我开始探索 Linux 时,我把它贴在桌子上并经常参考它。它的第一页第一列的底部有使用 `ls -l` 列出文件的命令。 +我的第一个 Linux 备忘录是[单页 Linux 手册][1],它于 1999 年发布,成了我的首选参考资料。当我开始探索 Linux 时,我把它贴在桌子上并经常参考它。它在第一页第一列的底部介绍了 `ls -l` 列出文件的命令。 -之后,我将学习这个最基本命令的其他迭代。通过 `ls` 命令,我开始了解 Linux 文件权限的复杂性以及哪些是我的文件,哪些需要 root 或者 root 权限来修改。随着时间的推移,我习惯使用命令行,虽然我仍然使用 `ls -l` 来查找目录中的文件,但我经常使用 `ls -al`,这样我就可以看到可能需要更改的隐藏文件,比如那些配置文件。 +之后,我将学习这个最基本命令的其它迭代。通过 `ls` 命令,我开始了解 Linux 文件权限的复杂性,以及哪些是我的文件,哪些需要 root 或者 sudo 权限来修改。随着时间的推移,我习惯了使用命令行,虽然我仍然使用 `ls -l` 来查找目录中的文件,但我经常使用 `ls -al`,这样我就可以看到可能需要更改的隐藏文件,比如那些配置文件。 -根据 Eric Fischer 在[Linux 文档项目][2]中关于 `ls` 命令的文章,该命令的根源可以追溯到 1961年 MIT 的相容分时系统 (CTSS -) 上的 `listf` 命令。当 CTSS 被 [Multics][3] 代替时,命令变为 `list`,并有像 `list -all` 的开关。根据[维基百科][4],“ls” 出现在 AT&T Unix 的原始版本中。我们今天在 Linux 系统上使用的 `ls` 命令来自 [GNU Core Utilities][5]。 +根据 Eric Fischer 在 [Linux 文档项目][2]中关于 `ls` 命令的文章,该命令的起源可以追溯到 1961 年 MIT 的相容分时系统Compatible Time-Sharing System(CTSS)上的 `listf` 命令。当 CTSS 被 [Multics][3] 代替时,命令变为 `list`,并有像 `list -all` 的开关。根据[维基百科][4],`ls` 出现在 AT&T Unix 的原始版本中。我们今天在 Linux 系统上使用的 `ls` 命令来自 [GNU Core Utilities][5]。 -大多数时候,我只使用几个迭代的命令。使用 `ls` 或 `ls -al` 查看目录内部是我通常使用该命令的方法,但是你还应该熟悉许多其他选项。 +大多数时候,我只使用几个迭代的命令。我通常用 `ls` 或 `ls -al` 查看目录内容,但是你还应该熟悉许多其它选项。 -`$ ls -l` 提供了一个简单的目录列表: +`ls -l` 提供了一个简单的目录列表: ![](https://opensource.com/sites/default/files/uploads/linux_ls_1_0.png) -使用我的 Fedora 28 系统中的手册页,我发现 `ls` 还有许多其他选项,所有这些选项都提供了有关 Linux 文件系统的有趣且有用的信息。通过在命令提示符下输入 `man ls`,我们可以开始探索其他一些选项: +在我的 Fedora 28 系统的手册页中,我发现 `ls` 还有许多其它选项,所有这些选项都提供了有关 Linux 文件系统的有趣且有用的信息。通过在命令提示符下输入 `man ls`,我们可以开始探索其它一些选项: ![](https://opensource.com/sites/default/files/uploads/linux_ls_2_0.png) @@ -38,18 +39,16 @@ ![](https://opensource.com/sites/default/files/uploads/linux_ls_6.png) -以下是我认为有用且有趣的一些其他选项: +以下是我认为有用且有趣的一些其它选项: - * 仅列出目录中的 .txt 文件:`ls * .txt` -  * 按文件大小列出:`ls -s` -  * 按时间和日期排序:`ls -d` -  * 按扩展名排序:`ls -X` -  * 按文件大小排序:`ls -S` -  * 带有文件大小的长格式:`ls -ls` +* 仅列出目录中的 .txt 文件:`ls *.txt` +* 按文件大小列出:`ls -s` +* 按时间和日期排序:`ls -t` +* 按扩展名排序:`ls -X` +* 按文件大小排序:`ls -S` +* 带有文件大小的长格式:`ls -ls` - - -要生成指定格式的目录列表并将其定向到文件供以后查看,请输入 `ls -al> mydirectorylist`。最后,我找到的一个更奇特的命令是 `ls -R`,它提供了计算机上所有目录及其内容的递归列表。 +要生成指定格式的目录列表并将其定向到文件供以后查看,请输入 `ls -al > mydirectorylist`。最后,我找到的一个更奇特的命令是 `ls -R`,它提供了计算机上所有目录及其内容的递归列表。 有关 `ls` 命令的所有迭代的完整列表,请参阅 [GNU Core Utilities][6]。 @@ -60,7 +59,7 @@ via: https://opensource.com/article/18/10/ls-command 作者:[Don Watkins][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[pityonline](https://github.com/pityonline) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 764c2717a87eab0752430d82cb03301165320861 Mon Sep 17 00:00:00 2001 From: suncle Date: Fri, 19 Oct 2018 00:46:16 +0800 Subject: [PATCH 042/158] translated by Flowsnow --- .../20180912 How to build rpm packages.md | 397 ------------------ .../20180912 How to build rpm packages.md | 390 +++++++++++++++++ 2 files changed, 390 insertions(+), 397 deletions(-) delete mode 100644 sources/tech/20180912 How to build rpm packages.md create mode 100644 translated/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 deleted file mode 100644 index 3d14a8c797..0000000000 --- a/sources/tech/20180912 How to build rpm packages.md +++ /dev/null @@ -1,397 +0,0 @@ -translating by Flowsnow - -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 diff --git a/translated/tech/20180912 How to build rpm packages.md b/translated/tech/20180912 How to build rpm packages.md new file mode 100644 index 0000000000..8506184294 --- /dev/null +++ b/translated/tech/20180912 How to build rpm packages.md @@ -0,0 +1,390 @@ +如何构建rpm包 +====== + +节省跨多个主机安装文件和脚本的时间和精力。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_gift_giveaway_box_520x292.png?itok=w1YQhNH1) + +自20多年前我开始使用 Linux 以来,我已经使用过基于 rpm 的软件包管理器在 Red Hat 和 Fedora Linux系统上安装软件。我使用过 **rpm** 程序本身,还有 **yum** 和 **DNF** ,用于在我的 Linux 主机上安装和更新软件包,DNF 是 yum 的一个紧密后代。 yum 和 DNF 工具是 rpm 实用程序的包装器,它提供了其他功能,例如查找和安装包依赖项的功能。 + +多年来,我创建了许多 Bash 脚本,其中一些脚本具有单独的配置文件,我希望在大多数新计算机和虚拟机上安装这些脚本。这也能解决安装所有这些软件包需要花费大量时间的难题,因此我决定通过创建一个 rpm 软件包来自动执行该过程,我可以将其复制到目标主机并将所有这些文件安装在适当的位置。虽然 **rpm** 工具以前用于构建 rpm 包,但该功能已被删除,并且创建了一个新工具来构建新的 rpm。 + +当我开始这个项目时,我发现很少有关于创建 rpm 包的信息,但我找到了一本书,名为《Maximum RPM》,这本书才帮我弄明白了。这本书现在已经过时了,我发现的绝大多数信息都是如此。它也已经绝版,使用复印件需要花费数百美元。[Maximum RPM][1] 的在线版本是免费提供的,并保持最新。 [RPM 网站][2]还有其他网站的链接,这些网站上有很多关于 rpm 的文档。其他的信息往往是简短的,显然都是假设你已经对该过程有了很多了解。 + +此外,我发现的每个文档都假定代码需要在开发环境中从源代码编译。我不是开发人员。我是一个系统管理员,我们系统管理员有不同的需求,因为我们不需要或者我们不应该为了管理任务而去编译代码;我们应该使用 shell 脚本。所以我们没有源代码,因为它需要被编译成二进制可执行文件。我们拥有的是一个也是可执行的源代码。 + +在大多数情况下,此项目应作为非 root 用户执行。 Rpm 包永远不应该由 root 用户构建,而只能由非特权普通用户构建。我将指出哪些部分应该以 root 身份执行,哪些部分应由非 root,非特权用户执行。 + +### 准备 + +首先,打开一个终端会话,然后 `su` 到 root 用户。 请务必使用 `-` 选项以确保启用完整的 root 环境。 我不认为系统管理员应该使用 `sudo` 来执行任何管理任务。 在我的个人博客文章中可以找出为什么:[真正的系统管理员不要使用 sudo][3]。 + +``` +[student@testvm1 ~]$ su - +Password: +[root@testvm1 ~]# +``` + +创建可用于此项目的普通用户 student,并为该用户设置密码。 + +``` +[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 ~]# +``` + +构建 rpm 包需要 `rpm-build` 包,该包可能尚未安装。 现在以 root 身份安装它。 请注意,此命令还将安装多个依赖项。 数量可能会有所不同,具体取决于主机上已安装的软件包; 它在我的测试虚拟机上总共安装了17个软件包,这是非常小的。 + +``` +dnf install -y rpm-build +``` + +除非另有明确指示,否则本项目的剩余部分应以普通用户用户 student 来执行。 打开另一个终端会话并使用 `su` 切换到该用户以执行其余步骤。 使用以下命令从 GitHub 下载我准备好的开发目录结构 utils.tar 这个tar 包tarball(LCTT 译注:tarball 是以 tar 命令来打包和压缩的文件的统称): + +``` +wget https://github.com/opensourceway/how-to-rpm/raw/master/utils.tar +``` + +此 tar 包包含将由最终 rpm 程序安装的所有文件和 Bash 脚本。 还有一个完整的 spec 文件,你可以使用它来构建 rpm。 我们将详细介绍 spec 文件的每个部分。 + +作为普通学生 student,使用你的家目录作为当前工作目录(pwd),解压缩 tar 包。 + +``` +[student@testvm1 ~]$ cd ; tar -xvf utils.tar +``` + +使用 `tree` 命令验证~/development 的目录结构和包含的文件,如下所示: + +``` +[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 ~]$ +``` + +`mymotd` 脚本创建一个发送到标准输出的“当日消息”数据流。 `create_motd` 脚本运行 `mymotd` 脚本并将输出重定向到 /etc/motd 文件。 此文件用于向使用SSH远程登录的用户显示每日消息。 + +`die` 脚本是我自己的脚本,它将 `kill` 命令包装在一些代码中,这些代码可以找到与指定字符串匹配的运行程序并将其终止。 它使用 `kill -9` 来确保kill命令一定会执行。 + +`sysdata` 脚本可以显示有关计算机硬件,还有已安装的 Linux 版本,所有已安装的软件包以及硬盘驱动器元数据的数万行数据。 我用它来记录某个时间点的主机状态。 我以后可以用它作为参考。 我曾经这样做是为了维护我为客户安装的主机记录。 + +你可能需要将这些文件和目录的所有权更改为 student:student 。 如有必要,使用以下命令执行此操作: + +``` +chown -R student:student development +``` + +此文件树中的大多数文件和目录将通过你在此项目期间创建的 rpm 包安装在 Fedora 系统上。 + +### 创建构建目录结构 + +`rpmbuild` 命令需要非常特定的目录结构。 你必须自己创建此目录结构,因为没有提供自动方式。 在家目录中创建以下目录结构: + +``` +~ ─ rpmbuild +    ├── RPMS +    │   └── noarch +    ├── SOURCES +    ├── SPECS +    └── SRPMS +``` + +我们不会创建 rpmbuild/RPMS/X86_64 目录,因为对于64位编译的二进制文件这是特定于体系结构的。 我们有 shell 脚本,不是特定于体系结构的。 实际上,我们也不会使用 SRPMS 目录,它将包含编译器的源文件。 + +### 检查 spec 文件 + +每个 spec 文件都有许多部分,其中一些部分可能会被忽视或省略,取决于 rpm 构建的具体情况。 这个特定的 spec 文件不是工作所需的最小文件的示例,但它是一个很好的包含不需要编译的文件的中等复杂 spec 文件的例子。 如果需要编译,它将在`构建`部分中执行,该部分在此 spec 文件中省略掉了,因为它不是必需的。 + +#### 前言 + +这是 spec 文件中唯一没有标签的部分。 它包含运行命令 `rpm -qi [Package Name]` 时看到的大部分信息。 每个数据都是一行,由标签和标签值的文本数据组成。 + +``` +############################################################################### +# 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 +``` + +`rpmbuild` 程序会忽略注释行。我总是喜欢在本节中添加注释,其中包含创建包所需的 `rpmbuild` 命令的确切语法。摘要标签是包的简短描述。 Name,Version 和 Release 标签用于创建 rpm 文件的名称,如utils-1.00-1.rpm 中所示。通过增加发行版号码和版本号,你可以创建 rpm 包去更新旧版本的。 + +许可证标签定义了发布包的许可证。我总是使用 GPL 的一个变体。指定许可证对于澄清包中包含的软件是开源的这一事实非常重要。这也是我将许可证和 GPL 语句包含在将要安装的文件中的原因。 + +URL 通常是项目或项目所有者的网页。在这种情况下,它是我的个人网页。 + +Group 标签很有趣,通常用于 GUI 应用程序。 Group 标签的值决定了应用程序菜单中的哪一组图标将包含此包中可执行文件的图标。与 Icon 标签(我们此处未使用)一起使用时,Group 标签允许添加图标和所需信息用于将程序启动到应用程序菜单结构中。 + +Packager 标签用于指定负责维护和创建包的人员或组织。 + +Requires 语句定义此 rpm 包的依赖项。每个都是包名。如果其中一个指定的软件包不存在,DNF 安装实用程序将尝试在 /etc/yum.repos.d 中定义的某个已定义的存储库中找到它,如果存在则安装它。如果 DNF 找不到一个或多个所需的包,它将抛出一个错误,指出哪些包丢失并终止。 + +BuildRoot 行指定顶级目录,`rpmbuild` 工具将在其中找到 spec 文件,并在构建包时在其中创建临时目录。完成的包将存储在我们之前指定的noarch子目录中。注释显示了构建此程序包的命令语法,包括定义了目标体系结构的 `–target noarch` 选项。因为这些是Bash脚本,所以它们与特定的CPU架构无关。如果省略此选项,则构建将选用正在执行构建的CPU的体系结构。 + +`rpmbuild` 程序可以针对许多不同的体系结构,并且使用 `--target` 选项允许我们在不同的体系结构主机上构建特定体系结构的包,其具有与执行构建的体系结构不同的体系结构。所以我可以在 x86_64 主机上构建一个用于 i686 架构的软件包,反之亦然。 + +如果你有自己的网站,请将打包者的名称更改为你自己的网站。 + +#### 描述 + +spec 文件的 `描述` 部分包含 rpm 包的描述。 它可以很短,也可以包含许多信息。 我们的 `描述` 部分相当简洁。 + +``` +%description +A collection of utility scripts for testing RPM creation. +``` + +#### 准备 + +`准备` 部分是在构建过程中执行的第一个脚本。 在安装程序包期间不会执行此脚本。 + +这个脚本只是一个 Bash shell 脚本。 它准备构建目录,根据需要创建用于构建的目录,并将相应的文件复制到各自的目录中。 这将包括完整编译作为构建的一部分所需的源。 + +$RPM_BUILD_ROOT 目录表示已安装系统的根目录。 在 $RPM_BUILD_ROOT 目录中创建的目录是实时文件系统中的绝对路径,例如 /user/local/share/utils,/usr/local/bin 等。 + +对于我们的包,我们没有预编译源,因为我们的所有程序都是 Bash 脚本。 因此,我们只需将这些脚本和其他文件复制到已安装系统的目录中。 + +``` +%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 +``` + +请注意,本节末尾的 exit 语句是必需的。 + +#### 文件 + +spec 文件的这一部分定义了要安装的文件及其在目录树中的位置。 它还指定了要安装的每个文件的文件属性以及所有者和组所有者。 文件权限和所有权是可选的,但我建议明确设置它们以消除这些属性在安装时不正确或不明确的任何可能性。 如果目录尚不存在,则会在安装期间根据需要创建目录。 + +``` +%files +%attr(0744, root, root) /usr/local/bin/* +%attr(0644, root, root) /usr/local/share/utils/* +``` + +#### 安装前 + +在我们的实验室项目的 spec 文件中,此部分为空。 这将放置那些需要 rpm 安装前执行的脚本。 + +#### 安装后 + +spec 文件的这一部分是另一个 Bash 脚本。 这个在安装文件后运行。 此部分几乎可以是你需要或想要的任何内容,包括创建文件,运行系统命令以及重新启动服务以在进行配置更改后重新初始化它们。 我们的 rpm 包的 `安装后` 脚本执行其中一些任务。 + +``` +%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 +``` + +此脚本中包含的注释应明确其用途。 + +#### 卸载后 + +此部分包含将在卸载 rpm 软件包后运行的脚本。 使用 rpm 或 DNF 删除包会删除文件部分中列出的所有文件,但它不会删除安装后部分创建的文件或链接,因此我们需要在本节中处理。 + +此脚本通常由清理任务组成,只是清除以前由rpm安装的文件,但rpm本身无法完成清除。 对于我们的包,它包括删除 `安装后` 脚本创建的链接并恢复 motd 文件的已保存原件。 + +``` +%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 +``` + +#### 清理 + +这个 Bash 脚本在 rpm 构建过程之后开始清理。 下面 `清理` 部分中的两行删除了 `rpm-build` 命令创建的构建目录。 在许多情况下,可能还需要额外的清理。 + +``` +%clean +rm -rf $RPM_BUILD_ROOT/usr/local/bin +rm -rf $RPM_BUILD_ROOT/usr/local/share/utils +``` + +#### 更新日志 + +此可选的文本部分包含 rpm 及其包含的文件的更改列表。 最新的更改记录在本部分顶部。 + +``` +%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. +``` + +使用你自己的姓名和电子邮件地址替换标题行中的数据。 + +### 构建 rpm + +spec 文件必须位于 rpmbuild 目录树的 SPECS 目录中。 我发现最简单的方法是创建一个指向该目录中实际 spec 文件的链接,以便可以在开发目录中对其进行编辑,而无需将其复制到 SPECS 目录。 将 SPECS 目录设为当前工作目录,然后创建链接。 + +``` +cd ~/rpmbuild/SPECS/ +ln -s ~/development/spec/utils.spec +``` + +运行以下命令以构建 rpm 。 如果没有错误发生,只需要花一点时间来创建 rpm 。 + +``` +rpmbuild --target noarch -bb utils.spec +``` + +检查 ~/rpmbuild/RPMS/noarch 目录以验证新的 rpm 是否存在。 + +``` +[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]$ +``` + +### 测试 rpm + +以 root 用户身份安装 rpm 以验证它是否正确安装并且文件是否安装在正确的目录中。 rpm 的确切名称将取决于你在 Preamble 部分中标签的值,但如果你使用了示例中的值,则 rpm 名称将如下面的示例命令所示: + +``` +[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%] +``` + +检查 /usr/local/bin 以确保新文件存在。 你还应验证是否已创建 /etc/cron.daily 中的 create_motd 链接。 + +使用 `rpm -q --changelog utils` 命令查看更改日志。 使用 `rpm -ql utils` 命令(在 `ql`中为小写 L )查看程序包安装的文件。 + +``` +[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]# +``` + +删除包。 + +``` +rpm -e utils +``` + +### 试验 + +现在,你将更改 spec 文件以要求一个不存在的包。 这将模拟无法满足的依赖关系。 在现有依赖行下立即添加以下行: + +``` +Requires: badrequire +``` + +构建包并尝试安装它。 显示什么消息? + +我们使用 `rpm` 命令来安装和删除 `utils` 包。 尝试使用 yum 或 DNF 安装软件包。 你必须与程序包位于同一目录中,或指定程序包的完整路径才能使其正常工作。 + +### 总结 + +在这里看一下创建 rpm 包的基础知识,我们没有涉及很多标签和很多部分。 下面列出的资源可以提供更多信息。 构建 rpm 包并不困难;你只需要正确的信息。 我希望这对你有所帮助——我花了几个月的时间来自己解决问题。 + +我们没有涵盖源代码构建,但如果你是开发人员,那么从这一点开始应该是一个简单的步骤。 + +创建 rpm 包是另一种成为懒惰系统管理员的好方法,可以节省时间和精力。 它提供了一种简单的方法来分发和安装那些我们作为系统管理员需要在许多主机上安装的脚本和其他文件。 + +### 资料 + +- Edward C. Baily,Maximum RPM,Sams著,于2000年,ISBN 0-672-31105-4 +- Edward C. Baily,[Maximum RPM][1],更新在线版本 +- [RPM文档][4]:此网页列出了 rpm 的大多数可用在线文档。 它包括许多其他网站的链接和有关 rpm 的信息。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/how-build-rpm-packages + +作者:[David Both][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[Flowsnow](https://github.com/Flowsnow) +校对:[校对者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 \ No newline at end of file From 72f5674c92bfb25bb276bb49cb27ed2db9e85b7a Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 19 Oct 2018 06:26:56 +0800 Subject: [PATCH 043/158] PRF:20181009 How To Create And Maintain Your Own Man Pages.md @way-ww --- ... Create And Maintain Your Own Man Pages.md | 63 ++++++++----------- 1 file changed, 25 insertions(+), 38 deletions(-) diff --git a/translated/tech/20181009 How To Create And Maintain Your Own Man Pages.md b/translated/tech/20181009 How To Create And Maintain Your Own Man Pages.md index 407ad90947..4033be78b4 100644 --- a/translated/tech/20181009 How To Create And Maintain Your Own Man Pages.md +++ b/translated/tech/20181009 How To Create And Maintain Your Own Man Pages.md @@ -1,24 +1,25 @@ -如何创建和维护你的Man手册 +如何创建和维护你自己的 man 手册 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/10/Um-pages-1-720x340.png) -我们已经讨论了一些[Man手册的替代方案] [1]。 这些替代方案主要用于学习简洁的Linux命令示例,而无需通过全面过于详细的手册页。 如果你正在寻找一种快速而简单的方法来轻松快速地学习Linux命令,那么这些替代方案值得尝试。 现在,你可能正在考虑 - 如何为Linux命令创建自己的man-like帮助页面? 这时**“Um”**就派上用场了。 Um是一个命令行实用程序,用于轻松创建和维护包含你到目前为止所了解的所有命令的Man页面。 +我们已经讨论了一些 [man 手册的替代方案][1]。 这些替代方案主要用于学习简洁的 Linux 命令示例,而无需通过全面而过于详细的手册页。 如果你正在寻找一种快速而简单的方法来轻松快速地学习 Linux 命令,那么这些替代方案值得尝试。 现在,你可能正在考虑 —— 如何为 Linux 命令创建自己的 man 式的帮助页面? 这时 “Um” 就派上用场了。 Um 是一个命令行实用程序,可以用于轻松创建和维护包含你到目前为止所了解的所有命令的 man 页面。 -通过创建自己的手册页,你可以在手册页中避免大量不必要的细节,并且只包含你需要记住的内容。 如果你想创建自己的一套man-like页面,“Um”也能为你提供帮助。 在这个简短的教程中,我们将学习如何安装“Um”命令以及如何创建自己的man手册页。 +通过创建自己的手册页,你可以在手册页中避免大量不必要的细节,并且只包含你需要记住的内容。 如果你想创建自己的一套 man 式的页面,“Um” 也能为你提供帮助。 在这个简短的教程中,我们将学习如何安装 “Um” 命令以及如何创建自己的 man 手册页。 ### 安装 Um -Um适用于Linux和Mac OS。 目前,它只能在Linux系统中使用** Linuxbrew **软件包管理器来进行安装。 如果你尚未安装Linuxbrew,请参考以下链接。 +Um 适用于 Linux 和Mac OS。 目前,它只能在 Linux 系统中使用 Linuxbrew 软件包管理器来进行安装。 如果你尚未安装 Linuxbrew,请参考以下链接: -安装Linuxbrew后,运行以下命令安装Um实用程序。 +- [Linuxbrew:一个用于 Linux 和 MacOS 的通用包管理器][3] + +安装 Linuxbrew 后,运行以下命令安装 Um 实用程序。 ``` $ brew install sinclairtarget/wst/um - ``` -如果你会看到类似下面的输出,恭喜你! Um已经安装好并且可以使用了。 +如果你会看到类似下面的输出,恭喜你! Um 已经安装好并且可以使用了。 ``` [...] @@ -49,88 +50,78 @@ Emacs Lisp files have been installed to: ==> um Bash completion has been installed to: /home/linuxbrew/.linuxbrew/etc/bash_completion.d - ``` -在制作你的man手册页之前,你需要为Um启用bash补全。 +在制作你的 man 手册页之前,你需要为 Um 启用 bash 补全。 -要开启bash'补全,首先你需要打开 **~/.bash_profile** 文件: +要开启 bash 补全,首先你需要打开 `~/.bash_profile` 文件: ``` $ nano ~/.bash_profile - ``` -并在其中添加以下内容: +并在其中添加以下内容: ``` if [ -f $(brew --prefix)/etc/bash_completion.d/um-completion.sh ]; then . $(brew --prefix)/etc/bash_completion.d/um-completion.sh fi - ``` 保存并关闭文件。运行以下命令以更新更改。 ``` $ source ~/.bash_profile - ``` -准备工作全部完成。让我们继续创建我们的第一个man手册页。 +准备工作全部完成。让我们继续创建我们的第一个 man 手册页。 +### 创建并维护自己的man手册 -### 创建并维护自己的Man手册 - -如果你想为“dpkg”命令创建自己的Man手册。请运行: +如果你想为 `dpkg` 命令创建自己的 man 手册。请运行: ``` $ um edit dpkg - ``` -上面的命令将在默认编辑器中打开markdown模板: +上面的命令将在默认编辑器中打开 markdown 模板: ![](https://www.ostechnix.com/wp-content/uploads/2018/10/Create-dpkg-man-page.png) -我的默认编辑器是Vi,因此上面的命令会在Vi编辑器中打开它。现在,开始在此模板中添加有关“dpkg”命令的所有内容。 +我的默认编辑器是 Vi,因此上面的命令会在 Vi 编辑器中打开它。现在,开始在此模板中添加有关 `dpkg` 命令的所有内容。 -下面是一个示例: +下面是一个示例: ![](https://www.ostechnix.com/wp-content/uploads/2018/10/Edit-dpkg-man-page.png) -正如你在上图的输出中看到的,我为dpkg命令添加了概要,描述和两个参数选项。 你可以在Man手册中添加你所需要的所有部分。不过你也要确保为每个部分提供了适当且易于理解的标题。 完成后,保存并退出文件(如果使用Vi编辑器,请按ESC键并键入:wq)。 +正如你在上图的输出中看到的,我为 `dpkg` 命令添加了概要,描述和两个参数选项。 你可以在 man 手册中添加你所需要的所有部分。不过你也要确保为每个部分提供了适当且易于理解的标题。 完成后,保存并退出文件(如果使用 Vi 编辑器,请按 `ESC` 键并键入`:wq`)。 -最后,使用以下命令查看新创建的Man手册页: +最后,使用以下命令查看新创建的 man 手册页: ``` $ um dpkg - ``` ![](http://www.ostechnix.com/wp-content/uploads/2018/10/View-dpkg-man-page.png) -如你所见,dpkg的Man手册页看起来与官方手册页完全相同。 如果要在手册页中编辑和/或添加更多详细信息,请再次运行相同的命令并添加更多详细信息。 +如你所见,`dpkg` 的 man 手册页看起来与官方手册页完全相同。 如果要在手册页中编辑和/或添加更多详细信息,请再次运行相同的命令并添加更多详细信息。 ``` $ um edit dpkg - ``` -要使用Um查看新创建的Man手册页列表,请运行: +要使用 Um 查看新创建的 man 手册页列表,请运行: ``` $ um list - ``` -所有手册页将保存在主目录中名为**`.um` **的目录下 +所有手册页将保存在主目录中名为 `.um` 的目录下 以防万一,如果你不想要某个特定页面,只需删除它,如下所示。 ``` $ um rm dpkg - ``` 要查看帮助部分和所有可用的常规选项,请运行: @@ -151,7 +142,6 @@ Subcommands: um topics List all topics. um (c)onfig [config key] Display configuration environment. um (h)elp [sub-command] Display this help message, or the help message for a sub-command. - ``` ### 配置 Um @@ -166,22 +156,18 @@ pager = less pages_directory = /home/sk/.um/pages default_topic = shell pages_ext = .md - ``` -在此文件中,你可以根据需要编辑和更改** pager **,** editor **,** default_topic **,** pages_directory **和** pages_ext **选项的值。 比如说,如果你想在** [Dropbox] [2] **文件夹中保存新创建的Um页面,只需更改/.um/umconfig**文件中** pages_directory **的值并将其更改为Dropbox文件夹即可。 +在此文件中,你可以根据需要编辑和更改 `pager`、`editor`、`default_topic`、`pages_directory` 和 `pages_ext` 选项的值。 比如说,如果你想在 [Dropbox][2] 文件夹中保存新创建的 Um 页面,只需更改 `~/.um/umconfig` 文件中 `pages_directory` 的值并将其更改为 Dropbox 文件夹即可。 ``` pages_directory = /Users/myusername/Dropbox/um - ``` 这就是全部内容,希望这些能对你有用,更多好的内容敬请关注! 干杯! - - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-create-and-maintain-your-own-man-pages/ @@ -189,7 +175,7 @@ via: https://www.ostechnix.com/how-to-create-and-maintain-your-own-man-pages/ 作者:[SK][a] 选题:[lujun9972][b] 译者:[way-ww](https://github.com/way-ww) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 @@ -197,3 +183,4 @@ via: https://www.ostechnix.com/how-to-create-and-maintain-your-own-man-pages/ [b]: https://github.com/lujun9972 [1]: https://www.ostechnix.com/3-good-alternatives-man-pages-every-linux-user-know/ [2]: https://www.ostechnix.com/install-dropbox-in-ubuntu-18-04-lts-desktop/ +[3]: https://www.ostechnix.com/linuxbrew-common-package-manager-linux-mac-os-x/ From da773552276beb2ca215ffcd51bb78568902a58e Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 19 Oct 2018 06:27:30 +0800 Subject: [PATCH 044/158] PUB:20181009 How To Create And Maintain Your Own Man Pages.md @way-ww https://linux.cn/article-10130-1.html --- .../20181009 How To Create And Maintain Your Own Man Pages.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20181009 How To Create And Maintain Your Own Man Pages.md (100%) diff --git a/translated/tech/20181009 How To Create And Maintain Your Own Man Pages.md b/published/20181009 How To Create And Maintain Your Own Man Pages.md similarity index 100% rename from translated/tech/20181009 How To Create And Maintain Your Own Man Pages.md rename to published/20181009 How To Create And Maintain Your Own Man Pages.md From 451550003388ee55055bc3f7d6f97dbb9583a480 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 19 Oct 2018 08:54:43 +0800 Subject: [PATCH 045/158] translated --- ...ow to Install GRUB on Arch Linux (UEFI).md | 76 ------------------- ...ow to Install GRUB on Arch Linux (UEFI).md | 72 ++++++++++++++++++ 2 files changed, 72 insertions(+), 76 deletions(-) delete mode 100644 sources/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md create mode 100644 translated/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md diff --git a/sources/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md b/sources/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md deleted file mode 100644 index e456c1ee0e..0000000000 --- a/sources/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md +++ /dev/null @@ -1,76 +0,0 @@ -translating---geekpi - -How to Install GRUB on Arch Linux (UEFI) -====== - -![](http://fasterland.net/wp-content/uploads/2018/10/Arch-Linux-Boot-Menu-750x375.jpg) - -Some time ago, I wrote a tutorial on **[how to reinstall Grub][1] on Arch Linux after installing Windows.** - -A few weeks ago, I had to reinstall **Arch Linux** from scratch on my laptop and I discovered installing **Grub** was not as straightforward as I remembered. - -For this reason, I’m going to write this tutorial since **installing Grub on a UEFI bios** during a new **Arch Linux** installation it’s not too easy. - -### Locating the EFI partition - -The first important thing to do for installing **Grub** on **Arch Linux** is to locate the **EFI** partition. -Let’s run the following command in order to locate this partition: - -``` -# fdisk -l -``` - -We need to check the partition marked as **EFI System -**In my case is **/dev/sda2** - -After that, we need to mount this partition, for example, on /boot/efi: - -``` -# mkdir /boot/efi -# mount /dev/sdb2 /boot/efi -``` - -Another important thing to do is adding this partition into the **/etc/fstab** file. - -#### Installing Grub - -Now we can install Grub in our system: - -``` -# grub-mkconfig -o /boot/grub/grub.cfg -# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB -``` - -#### Adding Windows Automatically into the Grub Menu - -In order to automatically add the **Windows entry into the Grub menu** , we need to install the **os-prober** program: - -``` -# pacman -Sy os-prober -``` - -In order to add the entry item let’s run the following commands: - -``` -# os-prober -# grub-mkconfig -o /boot/grub/grub.cfg -# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB -``` - -You can find more about Grub on Arch Linux [here][2]. - --------------------------------------------------------------------------------- - -via: http://fasterland.net/how-to-install-grub-on-arch-linux-uefi.html - -作者:[Francesco Mondello][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: http://fasterland.net/ -[b]: https://github.com/lujun9972 -[1]: http://fasterland.net/reinstall-grub-arch-linux.html -[2]: https://wiki.archlinux.org/index.php/GRUB diff --git a/translated/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md b/translated/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md new file mode 100644 index 0000000000..d466a85f2e --- /dev/null +++ b/translated/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md @@ -0,0 +1,72 @@ +如何在 Arch Linux(UEFI)上安装 GRUB +====== + +![](http://fasterland.net/wp-content/uploads/2018/10/Arch-Linux-Boot-Menu-750x375.jpg) + +前段时间,我写了一篇在安装 Windows 后在 Arch Linux 上**[如何重新安装 Grub][1]的教程。** + +几周前,我不得不在我的笔记本上从头开始重新安装 **Arch Linux**,同时我发现安装 **Grub** 并不像我想的那么简单。 + +出于这个原因,由于在新安装 **Arch Linux** 时**在 UEFI bios 中安装 Grub** 并不容易,所以我要写这篇教程。 + +### 定位 EFI 分区 + +在 **Arch Linux** 上安装 **Grub** 的第一件重要事情是定位 **EFI** 分区。让我们运行以下命令以找到此分区: + +``` +# fdisk -l +``` + +我们需要检查标记为 **EFI System** 的分区,我这里是 **/dev/sda2**。 + +之后,我们需要在例如 /boot/efi 上挂载这个分区: + +``` +# mkdir /boot/efi +# mount /dev/sdb2 /boot/efi +``` + +另一件重要的事情是将此分区添加到 **/etc/fstab** 中。 + +#### 安装 Grub + +现在我们可以在我们的系统中安装 Grub: + +``` +# grub-mkconfig -o /boot/grub/grub.cfg +# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB +``` + +#### 自动将 Windows 添加到 Grub 菜单中 + +为了自动将**Windows 条目添加到 Grub 菜单**,我们需要安装 **os-prober**: + +``` +# pacman -Sy os-prober +``` + +要添加它,让我们运行以下命令: + +``` +# os-prober +# grub-mkconfig -o /boot/grub/grub.cfg +# grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB +``` + +你可以在[这里][2]找到更多关于在 Arch Linux 上 Grub 的信息。 + +-------------------------------------------------------------------------------- + +via: http://fasterland.net/how-to-install-grub-on-arch-linux-uefi.html + +作者:[Francesco Mondello][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://fasterland.net/ +[b]: https://github.com/lujun9972 +[1]: http://fasterland.net/reinstall-grub-arch-linux.html +[2]: https://wiki.archlinux.org/index.php/GRUB From 0b6225a2d33c5ceb4927531db030d4ee331580d1 Mon Sep 17 00:00:00 2001 From: geekpi Date: Fri, 19 Oct 2018 09:03:29 +0800 Subject: [PATCH 046/158] translating --- ...n Your Old PC into a Retrogaming Console with Lakka Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md b/sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md index 7475e9c1b3..08ef4a8dc2 100644 --- a/sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md +++ b/sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md @@ -1,3 +1,5 @@ +translating---geekpi + Turn Your Old PC into a Retrogaming Console with Lakka Linux ====== **If you have an old computer gathering dust, you can turn it into a PlayStation like retrogaming console with Lakka Linux distribution. ** From 65065d5152244425976b1fbb2210e6f00b2f4280 Mon Sep 17 00:00:00 2001 From: qhwdw Date: Fri, 19 Oct 2018 11:16:26 +0800 Subject: [PATCH 047/158] Translating by qhwdw --- sources/tech/20181004 Lab 3- User Environments.md | 1 + sources/tech/20181016 Final JOS project.md | 1 + sources/tech/20181016 Lab 4- Preemptive Multitasking.md | 1 + sources/tech/20181016 Lab 5- File system, Spawn and Shell.md | 1 + sources/tech/20181016 Lab 6- Network Driver.md | 1 + 5 files changed, 5 insertions(+) diff --git a/sources/tech/20181004 Lab 3- User Environments.md b/sources/tech/20181004 Lab 3- User Environments.md index 2dc1522b69..4af7c09eba 100644 --- a/sources/tech/20181004 Lab 3- User Environments.md +++ b/sources/tech/20181004 Lab 3- User Environments.md @@ -1,3 +1,4 @@ +Translating by qhwdw Lab 3: User Environments ====== ### Lab 3: User Environments diff --git a/sources/tech/20181016 Final JOS project.md b/sources/tech/20181016 Final JOS project.md index 929c1e7caa..401235d20d 100644 --- a/sources/tech/20181016 Final JOS project.md +++ b/sources/tech/20181016 Final JOS project.md @@ -1,3 +1,4 @@ +Translating by qhwdw Final JOS project ====== Piazza Discussion Due, November 2, 2018 Proposals Due, November 8, 2018 Code repository Due, December 6, 2018 Check-off and in-class demos, Week of December 10, 2018 diff --git a/sources/tech/20181016 Lab 4- Preemptive Multitasking.md b/sources/tech/20181016 Lab 4- Preemptive Multitasking.md index 9e510ed7c6..de68cd7f39 100644 --- a/sources/tech/20181016 Lab 4- Preemptive Multitasking.md +++ b/sources/tech/20181016 Lab 4- Preemptive Multitasking.md @@ -1,3 +1,4 @@ +Translating by qhwdw Lab 4: Preemptive Multitasking ====== ### Lab 4: Preemptive Multitasking diff --git a/sources/tech/20181016 Lab 5- File system, Spawn and Shell.md b/sources/tech/20181016 Lab 5- File system, Spawn and Shell.md index e7e623db11..9250700723 100644 --- a/sources/tech/20181016 Lab 5- File system, Spawn and Shell.md +++ b/sources/tech/20181016 Lab 5- File system, Spawn and Shell.md @@ -1,3 +1,4 @@ +Translating by qhwdw Lab 5: File system, Spawn and Shell ====== diff --git a/sources/tech/20181016 Lab 6- Network Driver.md b/sources/tech/20181016 Lab 6- Network Driver.md index 7c310e3d88..b9b9172b42 100644 --- a/sources/tech/20181016 Lab 6- Network Driver.md +++ b/sources/tech/20181016 Lab 6- Network Driver.md @@ -1,3 +1,4 @@ +Translating by qhwdw Lab 6: Network Driver ====== ### Lab 6: Network Driver (default final project) From 4b5872c3ef88a18a84408e134293026e4a54bb01 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 19 Oct 2018 13:01:26 +0800 Subject: [PATCH 048/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Think=20global:?= =?UTF-8?q?=20How=20to=20overcome=20cultural=20communication=20challenges?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...rcome cultural communication challenges.md | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 sources/talk/20181018 Think global- How to overcome cultural communication challenges.md diff --git a/sources/talk/20181018 Think global- How to overcome cultural communication challenges.md b/sources/talk/20181018 Think global- How to overcome cultural communication challenges.md new file mode 100644 index 0000000000..1d36d5e88d --- /dev/null +++ b/sources/talk/20181018 Think global- How to overcome cultural communication challenges.md @@ -0,0 +1,93 @@ +Think global: How to overcome cultural communication challenges +====== +Use these tips to ensure that every member of your global development team feels involved and understood. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/people_remote_teams_world.png?itok=_9DCHEel) + +A few weeks ago, I witnessed an interesting interaction between two work colleagues—Jason, who is from the United States; and Raj, who was visiting from India. + +Raj typically calls into a daily standup meeting at 9:00am US Central Time from India, but since he was in the US, he and his teammates headed toward the scrum area for the meeting. Jason stopped Raj and said, “Raj, where are you going? Don’t you always call into the stand-up? It would feel strange if you don’t call in.” Raj responded, “Oh, is that so? No worries,” and headed back to his desk to call into the meeting. + +I went to Raj’s desk. “Hey, Raj, why aren’t you going to the daily standup?” Raj replied, “Jason asked me to call in.” Meanwhile, Jason was waiting for Raj to come to the standup. + +What happened here? Jason was obviously joking when he made the remark about Raj calling into the meeting. But how did Raj miss this? + +Jason’s statement was meant as a joke, but Raj took it literally. This was a clear example of a misunderstanding that occurred due to unfamiliarity with each other’s cultural context. + +I often encounter emails that end with “Please revert back to me.” At first, this phrase left me puzzled. I thought, "What changes do they want me to revert?" Finally, I figured out that “please revert” means “Please reply.” + +In his TED talk, “[Managing Cross Cultural Remote Teams,][1]” Ricardo Fernandez describes an interaction with a South African colleague who ended an IM conversation with “I’ll call you just now.” Ricardo went back to his office and waited for the call. After fifteen minutes, he called his colleague: “Weren’t you going to call me just now?” The colleague responded, “Yes, I was going to call you just now.” That's when Ricardo realized that to his South African colleague, the phrase “just now” meant “sometime in the future.” + +In today's workplace, our colleagues may not be located in the same office, city, or even country. A growing number of tech companies have a global workforce comprised of employees with varied experiences and perspectives. This diversity allows companies to compete in the rapidly evolving technological environment. + +But geographically dispersed teams can face challenges. Managing and maintaining high-performing development teams is difficult even when the members are co-located; when team members come from different backgrounds and locations, that makes it even harder. Communication can deteriorate, misunderstandings can happen, and teams may stop trusting each other—all of which can affect the success of the company. + +What factors can cause confusion in global communication? In her book, “[The Culture Map][2],” Erin Meyer presents eight scales into which all global cultures fit. We can use these scales to improve our relationships with international colleagues. She identifies the United States as a very low-context culture in the communication scale. In contrast, Japan is identified as a high-context culture. + +What does it mean to be a high- or low-context culture? In the United States, children learn to communicate explicitly: “Say what you mean; mean what you say” is a common principle of communication. On the other hand, Japanese children learn to communicate effectively by mastering the ability to “read the air.” That means they are able to read between the lines and pick up on social cues when communicating. + +Most Asian cultures follow the high-context style of communication. Not surprisingly, the United States, a young country composed of immigrants, follows a low-context culture: Since the people who immigrated to the United States came from different cultural backgrounds, they had no choice but to communicate explicitly and directly. + +### The three R’s + +How can we overcome challenges in cross-cultural communication? Americans communicating with Japanese colleagues, for example, should pay attention to the non-verbal cues, while Japanese communicating with Americans should prepare for more direct language. If you are facing a similar challenge, follow these three steps to communicate more effectively and improve relationships with your international colleagues. + +#### Recognize the differences in cultural context + +The first step toward effective cross-cultural communication is to recognize that there are differences. Start by increasing your awareness of other cultures. + +#### Respect the differences in cultural context + +Once you become aware that differences in cultural context can affect cross-cultural communication, the next step is to respect these differences. When you notice a different style of communication, learn to embrace the difference and actively listen to the other person’s point of view. + +#### Reconcile the differences in cultural context + +Merely recognizing and respecting cultural differences is not enough; you must also learn how to reconcile the cultural differences. Understanding and being empathetic towards the other culture will help you reconcile the differences and learn how to use them to better advance productivity. + +### 5 ways to improve communications for cultural context + +Over the years, I have incorporated various approaches, tips, and tricks to strengthen relationships among team members across the globe. These approaches have helped me overcome communication challenges with global colleagues. Here are a few examples: + +#### Always use video conferencing when communicating with global teammates + +Studies show that about 55% of communication is non-verbal. Body language offers many subtle cues that can help you decipher messages, and video conferencing enables geographically dispersed team members to see each other. Videoconferencing is my default choice when conducting remote meetings. + +#### Ensure that every team member gets an opportunity to share their thoughts and ideas + +Although I prefer to conduct meetings using video conferencing, this is not always possible. If video conferencing is not a common practice at your workplace, it might take some effort to get everyone comfortable with the concept. Start by encouraging everyone to participate in audio meetings. + +One of our remote team members, who frequently met with us in audio conferences, mentioned that she often wanted to share ideas and contribute to the meeting but since we couldn’t see her and she couldn’t see us, she had no idea when to start speaking. If you are using audio conferencing, one way to mitigate this is to ensure that every team member gets an opportunity to share their ideas. + +#### Learn from one another + +Leverage your international friends to learn about their cultural context. This will help you interact more effectively with colleagues from these countries. I have friends from South Asia and South America who have helped me better understand their cultures, and this knowledge has helped me professionally. + +For programmers, I recommend conducting code reviews with your global peers. This will help you understand how those from different cultures give and receive feedback, persuade others, and make technical decisions. + +#### Be empathetic + +Empathy is the key to strong relationships. The more you are able to put yourself in someone else's shoes, the better able you will be to gain trust and build long-lasting connections. Encourage “water-cooler” conversations among your global colleagues by allocating the first few minutes of each meeting for small talk. This offers the additional benefit of putting everyone in a more relaxed mindset. If you manage a global team, make sure every member feels included in the discussion. + +#### Meet your global colleagues in person + +The best way to build long-lasting relationships is to meet your team members in person. If your company can afford it, arrange for this to happen. Meeting colleagues with whom you have been working will likely strengthen your relationship with them. The companies I have worked for have a strong record of periodically sending US team members to other countries and global colleagues to the US office. + +Another way to bring teams together is to attend conferences. This not only creates educational and training opportunities, but you can also carve out some in-person team time. + +In today's increasingly global economy, it is becoming more important for companies to maintain a geographically diverse workforce to remain competitive. Although global teams can face communication challenges, it is possible to maintain a high-performing development team despite geographical and cultural differences. Share some of the techniques you use in the comments. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/think-global-communication-challenges + +作者:[Avindra Fernando][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/avindrafernando +[b]: https://github.com/lujun9972 +[1]: https://www.youtube.com/watch?v=QIoAkFpN8wQ +[2]: https://www.amazon.com/The-Culture-Map-Invisible-Boundaries/dp/1610392507 From cd85732a4a40fc58da72d0b1663eace93f65b465 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 19 Oct 2018 13:02:53 +0800 Subject: [PATCH 049/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=204=20open=20source?= =?UTF-8?q?=20alternatives=20to=20Microsoft=20Access?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...source alternatives to Microsoft Access.md | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 sources/tech/20181018 4 open source alternatives to Microsoft Access.md diff --git a/sources/tech/20181018 4 open source alternatives to Microsoft Access.md b/sources/tech/20181018 4 open source alternatives to Microsoft Access.md new file mode 100644 index 0000000000..19f78e81d6 --- /dev/null +++ b/sources/tech/20181018 4 open source alternatives to Microsoft Access.md @@ -0,0 +1,94 @@ +4 open source alternatives to Microsoft Access +====== +Build simple business applications and keep track of your data with these worthy open source alternatives. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus_cloud_database.png?itok=lhhU42fg) + +When small businesses, community organizations, and similar-sized groups realize they need software to manage their data, they think first of Microsoft Access. That may be the right choice if you're already paying for a Microsoft Office subscription or don't care that it's proprietary. But it's far from your only option—whether you prefer to use open source alternatives from a philosophical standpoint or you don't have the big budget for a Microsoft Office subscription—there are several open source database applications that are worthy alternatives to proprietary software like Microsoft Access or Apple FileMaker. + +If that sounds like you, here are four open source database tools for your consideration. + +### LibreOffice Base + +![](https://opensource.com/sites/default/files/uploads/libreoffice-base.png) +In case it's not obvious from its name, [Base][1] is part of the [LibreOffice][2] productivity suite, which includes Writer (word processing), Calc (spreadsheet), Impress (presentations), Draw (graphics), Charts (chart creation), and Math (formulas). As such, Base integrates with the other LibreOffice applications, much like Access does with the Microsoft Office suite. This means you can import and export data from Base into the suite's other applications to create financial reports, mail merges, charts, and more. + +Base includes drivers that natively support multi-user database engines, including the open source MySQL, MariaDB, and PostgreSQL; Access; and other JDBC and ODBC-compliant databases. Built-in wizards and table definitions make it easy for new users to quickly get started building tables, writing queries, and creating forms and reports (such as invoices, sales reports, and customer lists). To learn more, consult the comprehensive [user manual][3] and dive into the [user forums][4]. If you're still stuck, you can find a [certified][5] support professional to help you out. + +Installers are available for Linux, MacOS, Windows, and Android. LibreOffice is available under the [Mozilla Public License v2][6]; if you'd like to join the large contributor community and help improve the software, visit the [Get Involved][7] section of LibreOffice's website. + +### DB Browser for SQLite + +![](https://opensource.com/sites/default/files/uploads/sqlitebrowser.png) + +[DB Browser for SQLite][8] enables users to create and use SQLite database files without having to know complex SQL commands. This, plus its spreadsheet-like interface and pre-built wizards, make it a great option for new database users to get going without much background knowledge. + +Although the application has gone through several name changes—from the original Arca Database Browser to the SQLite Database Browser and finally to the current name (in 2014, to avoid confusion with SQLite), it's stayed true to its goal of being easy for users to operate. + +Its wizards enable users to easily create and modify database files, tables, indexes, records, etc.; import and export data to common file formats; create and issue queries and searches; and more. Installers are available for Windows, MacOS, and a variety of Linux versions, and its [wiki on GitHub][9] offers a wealth of information for users and developers. + +DB Browser for SQLite is [bi-licensed][10] under the Mozilla Public License Version 2 and the GNU General Public License Version 3 or later, and you can download the source code from the project's website. + +### Kexi + +![](https://opensource.com/sites/default/files/uploads/kexi-3.0-table-view.png) +As the database application in the [Calligra Suite][11] productivity software for the KDE desktop, [Kexi][12] integrates with the other applications in the suite, including Words (word processing), Sheets (spreadsheet), Stage (presentations), and Plan (project management). + +As a full member of the [KDE][13] project, Kexi is purpose-built for KDE Plasma, but it's not limited to KDE users: Linux, BSD, and Unix users running GNOME can run the database, as can MacOS and Windows users. + +Kexi's website says its development was "motivated by the lack of rapid application development ([RAD][14]) tools for database systems that are sufficiently powerful, inexpensive, open standards driven, and portable across many operating systems and hardware platforms." It has all the standard features you'd expect: designing databases, storing data, doing queries, processing data, and so forth. + +Kexi is available under the [LGPL][15] open source license and you can download its [source code][16] from its development wiki. If you'd like to learn more, take a look at its [user handbook][17], [forums][18], and [userbase wiki][17]. + +### nuBuilder Forte + +![](https://opensource.com/sites/default/files/uploads/screenshot_from_2018-10-17_13-23-25.png) +[NuBuilder Forte][19] is designed to be as easy as possible for people to use. It's a browser-based tool for developing web-based database applications. + +Its clean interface and low-code tools (including support for drag-and-drop) allow users to create and use a database quickly. As a fully web-based application, data is accessible anywhere from a browser. Everything is stored in MySQL and can be backed up in one database file. + +It uses industry-standard coding languages—HTML, PHP, JavaScript, and SQL—making it easy for developers to get started also. + +Help is available in [videos][20] and other [documentation][21] for topics including creating forms, doing searches, building reports, and more. + +nuBuilder Forte is licensed under [GPLv3.0][22] and you can download it on [GitHub][23]. You can learn more by consulting the [nuBuilder Forum][24] or watching its [demo][25] video. + +Do you have a favorite open source database tool for building simple projects with little or no coding skill required? If so, please share in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/alternatives/access + +作者:[Opensource.com][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com +[b]: https://github.com/lujun9972 +[1]: https://www.libreoffice.org/discover/base/ +[2]: https://www.libreoffice.org/ +[3]: https://documentation.libreoffice.org/en/english-documentation/base/ +[4]: http://document-foundation-mail-archive.969070.n3.nabble.com/Users-f1639498.html +[5]: https://www.libreoffice.org/get-help/professional-support/ +[6]: https://www.libreoffice.org/download/license/ +[7]: https://www.libreoffice.org/community/get-involved/ +[8]: http://sqlitebrowser.org/ +[9]: https://github.com/sqlitebrowser/sqlitebrowser/wiki +[10]: https://github.com/sqlitebrowser/sqlitebrowser/blob/master/LICENSE +[11]: https://www.calligra.org/ +[12]: https://www.calligra.org/kexi/ +[13]: https://www.kde.org/ +[14]: http://en.wikipedia.org/wiki/Rapid_application_development +[15]: http://kexi-project.org/wiki/wikiview/index.php@KexiLicense.html +[16]: http://kexi-project.org/wiki/wikiview/index.php@Download.html +[17]: https://userbase.kde.org/Kexi/Handbook +[18]: http://forum.kde.org/kexi +[19]: https://www.nubuilder.com/ +[20]: https://www.nubuilder.com/videos +[21]: https://www.nubuilder.com/wiki +[22]: https://github.com/nuSoftware/nuBuilder4/blob/master/LICENSE.txt +[23]: https://github.com/nuSoftware/nuBuilder4 +[24]: https://forums.nubuilder.com/viewforum.php?f=18&sid=7036bccdc08ba0da73181bc72cd63c62 +[25]: https://www.youtube.com/watch?v=tdh9ILCUAco&feature=youtu.be From ad4067885a252a01b403bfa0ceab3b3328f63eae Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 19 Oct 2018 13:04:19 +0800 Subject: [PATCH 050/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20TimelineJS:=20An?= =?UTF-8?q?=20interactive,=20JavaScript=20timeline=20building=20tool?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...tive, JavaScript timeline building tool.md | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 sources/tech/20181018 TimelineJS- An interactive, JavaScript timeline building tool.md diff --git a/sources/tech/20181018 TimelineJS- An interactive, JavaScript timeline building tool.md b/sources/tech/20181018 TimelineJS- An interactive, JavaScript timeline building tool.md new file mode 100644 index 0000000000..1f45811416 --- /dev/null +++ b/sources/tech/20181018 TimelineJS- An interactive, JavaScript timeline building tool.md @@ -0,0 +1,82 @@ +TimelineJS: An interactive, JavaScript timeline building tool +====== +Learn how to tell a story with TimelineJS. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/clocks_time.png?itok=_ID09GDk) + +[TimelineJS 3][1] is an open source storytelling tool that anyone can use to create visually rich, interactive timelines to post on their websites. To get started, simply click “Make a Timeline” on the homepage and follow the easy [step-by-step instructions][1]. + +TimelineJS was developed at Northwestern University’s KnightLab in Evanston, Illinois. KnightLab is a community of designers, developers, students, and educators who work on experiments designed to push journalism into new spaces. TimelineJS has been used by more than 250,000 people, according to its website, to tell stories viewed millions of times. And TimelineJS3 is available in more than 60 languages. + +Joe Germuska, the “chief nerd” who runs KnightLab’s technology, professional staff, and student fellows, explains, "TimelineJS was originally developed by Northwestern professor Zach Wise. He assigned his students a task to tell stories in a timeline format, only to find that none of the free available tools were as good as he thought they could be. KnightLab funded some of his time to develop the tool in 2012. Near the end of that year, I joined the lab, and among my early tasks was to bring TimelineJS in as a fully supported project of the lab. The next year, I helped Zach with a rewrite to address some issues. Along the way, many students have contributed. Interestingly, a group of students from Victoria University in Wellington, New Zealand, worked on TimelineJS (and some of our other tools) as part of a class project in 2016." + +"In general, we designed TimelineJS to make it easy for non-technical people to tell rich, dynamic stories on the web in the context of events in time.” + +Users create timelines by adding content into a Google spreadsheet. KnightLab provides a downloadable template that can be edited to create custom timelines. Experts can use their JSON skills to [create custom installations][2] while keeping TimelineJS’s core functionality. + +This easy-to-follow [Vimeo video][3] shows how to get started with TimelineJS, and I used it myself to create my first timeline. + +### Open sourcing the Adirondacks + +Reid Larson, research and scholarly communication librarian at Hamilton College in Clinton, New York, began searching for ways to combine open data and visualization to chronicle the history of Essex County (a county in northern New York that makes up part of the Adirondacks), in the 1990s, when he was the director of the Essex County Historical Society/Adirondack History Center Museum. + +"I wanted to take all the open data available on the history of Essex County and be able to present it to people visually. Most importantly, I wanted to make sure that the data would be available for use even if the applications used to present it are no longer available or supported," Larson explains. + +Now at Hamilton College, Larson has found TimelineJS to be the ideal open source program to do just what he wanted: Chronicle and present a visually appealing timeline of selected places. + +"It was a professor who was working on a project that required a solution such as Timeline, and after researching the possibilities, I started using Timeline for that project and subsequent projects," Larson adds. + +TimelineJS can be used via a web browser, or the source code can be downloaded from [GitHub][4] for local use. + +"I’ve been using the browser version, but I push it to the limits to see how far I can go with it, such as adding my own HTML tags. I want to fully understand it so that I can educate the students and faculty at Hamilton College on its uses," Larson says. + +### An open source Eagle Scout project + +Not only has Larson used TimelineJS for collegiate purposes, but his son, Erik, created an [interactive historical website][5] for his Eagle Scout project in 2017 using WordPress. The project is a chronicle of places in Waterville, New York, just south of Clinton, in Oneida County. Erik explains that he wants what he started to expand beyond the 36 places in Waterville. "The site is an experiment in online community building," Erik’s website reads. + +Larson says he did a lot of the “tech work” on the project so that Erik could concentrate on content. The site was created with [Omeka][6], an open source web publishing platform for sharing digital collections and creating media-rich online exhibits, and [Curatescape][7], a framework for the open source Omeka CMS. + +Larson explains that a key feature of TimelineJS is that it uses Google Sheets to store and organize the data used in the timeline. "Google Sheets is a good structure for organizing data simply, and that data will be available even if TimelineJS becomes unavailable in the future." + +Larson says that he prefers using [ArcGIS][8] over KnightLab’s StoryMap because it uses spreadsheets to store content, whereas [StoryMap][9] does not. Larson is looking forward to integrating augmented reality into his projects in the future. + +### Create your own open source timeline + +I plan on using TimelineJS to create interactive content for the Development and Alumni Relations department at Clarkson University, where I am the development communications specialist. To practice with working with it, I created [a simple timeline][10] of the articles I’ve written for [Opensource.com][11]: + +![](https://opensource.com/sites/default/files/uploads/google-sheet-timeline.png) +![](https://opensource.com/sites/default/files/uploads/wordpress-timeline.png) + +![](https://opensource.com/sites/default/files/uploads/website-timeline.png) + +As Reid Larson stated, it is very easy to use and the results are quite satisfactory. I was able to get a working timeline created and posted to my WordPress site in a matter of minutes. I used media that I had already uploaded to my Media Library in WordPress and simply copied the image address. I typed in the dates, locations, and information in the other cells and used “publish to web” under “file” in the Google spreadsheet. That produced a link and embed code. I created a new post in my WordPress site and pasted in the embed code, and the timeline was live and working. + +Of course, there is more customization I need to do, but I was able to get it working quickly and easily, much as Reid said it would. + +I will continue experimenting with TimelineJS on my own site, and when I get more comfortable with it, I’ll use it for my professional projects and try out the other apps that KnightLab has created for interactive, visually appealing storytelling. + +What might you use TimelineJS for? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/create-interactive-timelines-open-source-tool + +作者:[Jeff Macharyas][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rikki-endsley +[b]: https://github.com/lujun9972 +[1]: https://timeline.knightlab.com/ +[2]: https://timeline.knightlab.com/docs/json-format.html +[3]: https://vimeo.com/knightlab/timelinejs +[4]: https://github.com/NUKnightLab/TimelineJS3 +[5]: http://nysplaces.com/ +[6]: https://github.com/omeka +[7]: https://github.com/CPHDH/Curatescape +[8]: https://www.arcgis.com/index.html +[9]: https://storymap.knightlab.com/ +[10]: https://macharyas.com/index.php/2018/10/06/timeline/ +[11]: http://opensource.com/ From 7541975a3a4978377147f0f5eea1bb605390c7c6 Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 19 Oct 2018 13:06:37 +0800 Subject: [PATCH 051/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20MidnightBSD=20Hit?= =?UTF-8?q?s=201.0!=20Checkout=20What=E2=80=99s=20New?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...dnightBSD Hits 1.0- Checkout What-s New.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 sources/tech/20181018 MidnightBSD Hits 1.0- Checkout What-s New.md diff --git a/sources/tech/20181018 MidnightBSD Hits 1.0- Checkout What-s New.md b/sources/tech/20181018 MidnightBSD Hits 1.0- Checkout What-s New.md new file mode 100644 index 0000000000..345a9f9b5b --- /dev/null +++ b/sources/tech/20181018 MidnightBSD Hits 1.0- Checkout What-s New.md @@ -0,0 +1,74 @@ +MidnightBSD Hits 1.0! Checkout What’s New +====== +A couple days ago, Lucas Holt announced the release of MidnightBSD 1.0. Let’s take a quick look at what is included in this new release. + +### What is MidnightBSD? + +![MidnightBSD][1] + +[MidnightBSD][2] is a fork of FreeBSD. Lucas created MightnightBSD to be an option for desktop users and for BSD newbies. He wanted to create something that would allow people to quickly get a desktop experience on BSD. He believed that other options had too much of a focus on the server market. + +### What is in MidnightBSD 1.0? + +According to the [release notes][3], most of the work in 1.0 went towards updating the base system, improving the package manager and updating tools. The new release is compatible with FreeBSD 10-Stable. + +Mports (MidnightBSD’s package management system) has been upgraded to support installing multiple packages with one command. The `mport upgrade` command has been fixed. Mports now tracks deprecated and expired packages. A new package format was also introduced. + + + +Other changes include: + + * [ZFS][4] is now supported as a boot file system. Previously, ZFS could only be used for additional storage. + * Support for NVME SSDs + * AMD Ryzen and Radeon support have been improved. + * Intel, Broadcom, and other drivers updated. + * bhyve support has been ported from FreeBSD + * The sensors framework was removed because it was causing locking issues. + * Sudo was removed and replaced with [doas][5] from OpenBSD. + * Added support for Microsoft hyper-v + + + +### Before you upgrade… + +If you are a current MidnightBSD user or are thinking of trying out the new release, it would be a good idea to wait. Lucas is currently rebuilding packages to support the new package format and tooling. He also plans to upgrade packages and ports for the desktop environment over the next couple of months. He is currently working on porting Firefox 52 ESR because it is the last release that does not require Rust. He also hopes to get a newer version of Chromium ported to MidnightBSD. I would recommend keeping an eye on the MidnightBSD [Twi][6][t][6][ter][6] feed. + +### What happened to 0.9? + +You might notice that the previous release of MidnightBSD was 0.8.6. Now, you might be wondering “Why the jump to 1.0”? According to Lucas, he ran into several issues while developing 0.9. In fact, he restarted it several times. He ending up taking CURRENT in a different direction than the 0.9 branch and it became 1.0. Some packages also had an issue with the 0.* numbering system. + +### Help Needed + +Currently, the MidnightBSD project is the work of pretty much one guy, Lucas Holt. This is the main reason why development has been slow. If you are interested in helping out, you can contact him on [Twitter][6]. + +In the [release announcement video][7]. Lucas said that he had encountered problems with upstream projects accepting patches. They seem to think that MidnightBSD is too small. This often means that he has to port an application from scratch. + +### Thoughts + +I have a thing for the underdog. Of all the BSDs that I have interacted with, that monicker fits MidnightBSD the most. One guy trying to create an easy desktop experience. Currently, there is only one other BSD trying to do something similar: Project Trident. I think that this is a real barrier to BSDs success. Linux succeeds because people can quickly and easily install it. Hopefully, MidnightBSD does that for BSD, but right now it has a long way to go. + +Have you ever used MidnightBSD? If not, what is your favorite BSD? What other BSD topics should we cover? 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][8]. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/midnightbsd-1-0-release/ + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/10/midnightbsd-wallpaper.jpeg +[2]: https://www.midnightbsd.org/ +[3]: https://www.midnightbsd.org/notes/ +[4]: https://itsfoss.com/what-is-zfs/ +[5]: https://man.openbsd.org/doas +[6]: https://twitter.com/midnightbsd +[7]: https://www.youtube.com/watch?v=-rlk2wFsjJ4 +[8]: http://reddit.com/r/linuxusersgroup From a811b2ddffec08c0700650736c8038e5da638d7d Mon Sep 17 00:00:00 2001 From: darksun Date: Fri, 19 Oct 2018 13:07:40 +0800 Subject: [PATCH 052/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20We=20already=20ha?= =?UTF-8?q?ve=20nice=20things,=20and=20other=20reasons=20not=20to=20write?= =?UTF-8?q?=20in-house=20ops=20tools?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...reasons not to write in-house ops tools.md | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 sources/talk/20181017 We already have nice things, and other reasons not to write in-house ops tools.md diff --git a/sources/talk/20181017 We already have nice things, and other reasons not to write in-house ops tools.md b/sources/talk/20181017 We already have nice things, and other reasons not to write in-house ops tools.md new file mode 100644 index 0000000000..e5502ed9bb --- /dev/null +++ b/sources/talk/20181017 We already have nice things, and other reasons not to write in-house ops tools.md @@ -0,0 +1,64 @@ +We already have nice things, and other reasons not to write in-house ops tools +====== +Let's look at the pitfalls of writing in-house ops tools, the circumstances that justify it, and how to do it better. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tool-hammer-nail-build-broken.png?itok=91xn-5wI) + +When I was an ops consultant, I had the "great fortune" of seeing the dark underbelly of many companies in a relatively short period of time. Such fortune was exceptionally pronounced on one client engagement where I became the maintainer of an in-house deployment tool that had bloated to touch nearly every piece of infrastructure—despite lacking documentation and testing. Dismayed at the impossible task of maintaining this beast while tackling the real work of improving the product, I began reviewing my old client projects and probing my ops community for their strategies. What I found was an epidemic of "[not invented here][1]" (NIH) syndrome and a lack of collaboration with the broader community. + +### The problem with NIH + +One of the biggest problems of NIH is the time suck for engineers. Instead of working on functionality that adds value to the business, they're adding features to tools that solve standard problems such as deployment, continuous integration (CI), and configuration management. + +This is a serious issue at small or midsized startups, where new hires need to hit the ground running. If they have to learn a completely new toolset, rather than drawing from their experience with industry-standard tools, the time it takes them to become useful increases dramatically. While the new hires are learning the in-house tools, the company remains reliant on the handful of people who wrote the tools to document, train, and troubleshoot them. Heaven forbid one of those engineers succumbs to [the bus factor][2], because the possibility of getting outside help if they forgot to document something is zero. + +### Do you need to roll it yourself? + +Before writing your own ops tool, ask yourself the following questions: + + * Have we polled the greater ops community for solutions? + * Have we compared the costs of proprietary tools to the estimated engineering time needed to maintain an in-house solution? + * Have we identified open source solutions, even those that lack desired features, and attempted to contribute to them? + * Can we fork any open source tools that are well-written but unmaintained? + + + +If you still can't find a tool that meets your needs, you'll have to roll your own. + +### Tips for rolling your own + +Here's a checklist for rolling your own solutions: + + 1. In-house tooling should not be exempt from the high standards you apply to the rest of your code. Write it like you're going to open source it. + 2. Make sure you allow time in your sprints to work on feature requests, and don't allow features to be rushed in before proper testing and documentation. + 3. Keep it small. It's going to be much harder to exact any kind of exit strategy if your tool is a monstrosity that touches everything. + 4. Track your tool's usage and prune features that aren't actively utilized. + + + +### Have an exit strategy + +Open sourcing your in-house tool is not an exit strategy per se, but it may help you get outside contributors to free up your engineers' time. This is the more difficult strategy and will take some extra care and planning. Read "[Starting an Open Source Project][3]" and "[So You've Decided To Open-Source A Project At Work. What Now?][4]" before committing to this path. If you're interested in a cleaner exit, set aside time each quarter to research and test new open source replacements. + +Regardless of which path you choose, explicitly stating that an in-house solution is not the preferred state—early in its development—should clear up any confusion and prevent the issue of changing directions from becoming political. + +Sabice Arkenvirr will present [We Already Have Nice Things, Use Them!][5] at [LISA18][6], October 29-31 in Nashville, Tennessee, USA. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/nice-things + +作者:[Sabice Arkenvirr][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/vishuzdelishuz +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Not_invented_here +[2]: https://en.wikipedia.org/wiki/Bus_factor +[3]: https://opensource.guide/starting-a-project/ +[4]: https://www.smashingmagazine.com/2013/12/open-sourcing-projects-guide-getting-started/ +[5]: https://www.usenix.org/conference/lisa18/presentation/arkenvirr +[6]: https://www.usenix.org/conference/lisa18 From e0bbe190df2a77bc1a5a0ebd731767d30e481867 Mon Sep 17 00:00:00 2001 From: ypingcn <1344632698@qq.com> Date: Fri, 19 Oct 2018 14:37:38 +0800 Subject: [PATCH 053/158] Claim: 20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md --- ...of the World Wide Web is Creating a New Decentralized Web.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md b/sources/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md index df8804cbac..fb2916e06c 100644 --- a/sources/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md +++ b/sources/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md @@ -1,3 +1,5 @@ +translating by ypingcn + Creator of the World Wide Web is Creating a New Decentralized Web ====== **Creator of the world wide web, Tim Berners-Lee has unveiled his plans to create a new decentralized web where the data will be controlled by the users.** From c1fd944d5a2c4d0d0b237a839398b471817408b3 Mon Sep 17 00:00:00 2001 From: dianbanjiu Date: Fri, 19 Oct 2018 18:36:39 +0800 Subject: [PATCH 054/158] translating --- ...How To Browse And Read Entire Arch Wiki As Linux Man Pages.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md b/sources/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md index fe61f32dda..bf7a9f22c4 100644 --- a/sources/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md +++ b/sources/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md @@ -1,3 +1,4 @@ +translating by dianbanjiu How To Browse And Read Entire Arch Wiki As Linux Man Pages ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/10/arch-wiki-720x340.jpg) From e76f3d9d3878ad1ab5cf4f0e1ec7b48d406a7926 Mon Sep 17 00:00:00 2001 From: dianbanjiu Date: Fri, 19 Oct 2018 20:13:28 +0800 Subject: [PATCH 055/158] translated --- ...ead Entire Arch Wiki As Linux Man Pages.md | 152 ------------------ ...ead Entire Arch Wiki As Linux Man Pages.md | 151 +++++++++++++++++ 2 files changed, 151 insertions(+), 152 deletions(-) delete mode 100644 sources/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md create mode 100644 translated/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md diff --git a/sources/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md b/sources/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md deleted file mode 100644 index bf7a9f22c4..0000000000 --- a/sources/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md +++ /dev/null @@ -1,152 +0,0 @@ -translating by dianbanjiu -How To Browse And Read Entire Arch Wiki As Linux Man Pages -====== -![](https://www.ostechnix.com/wp-content/uploads/2018/10/arch-wiki-720x340.jpg) - -A while ago, I wrote a guide that described how to browse the Arch Wiki from your Terminal using a command line script named [**arch-wiki-cli**][1]. Using this script, anyone can easily navigate through entire Arch Wiki website and read it with a text browser of your choice. Obviously, an active Internet connection is required to use this script. Today, I stumbled upon a similar utility named **“Arch-wiki-man”**. As the name says, it is also used to read the Arch Wiki from command line, but it doesn’t require Internet connection. Arch-wiki-man program helps you to browse and read entire Arch Wiki as Linux man pages. It will display any article from Arch Wiki in man pages format. Also, you need not to be online to browse Arch Wiki. The entire Arch Wiki will be downloaded locally and the updates are pushed automatically every two days. So, you always have an up-to-date, local copy of the Arch Wiki on your system. - -### Installing Arch-wiki-man - -Arch-wiki-man is available in [**AUR**][2], so you can install it using any AUR helper programs, for example [**Yay**][3]. - -``` - $ yay -S arch-wiki-man -``` - -Alternatively, it can be installed using NPM package manager like below. Make sure you have [**installed NodeJS**][4] and run the following command to install it: - -``` - $ npm install -g arch-wiki-man -``` - -### Browse And Read Entire Arch Wiki As Linux Man Pages - -The typical syntax of Arch-wiki-man is: - -``` - $ awman -``` - -Let me show you some examples. - -**Search with one or more matches** - -Let us search for a [**Arch Linux installation guide**][5]. To do so, simply run: - -``` - $ awman Installation guide -``` - -The above command will search for the matches that contains the search term “Installation guide” in the Arch Wiki. If there are multiple matches for the given search term, a selection menu will appear. Choose the guide you want to read using **UP/DOWN arrows** or Vim-style keybindings ( **j/k** ) and hit ENTER to open it. The resulting guide will open in man pages format like below. - -![][6] - -Here, awman refers **a** rch **w** iki **m** an. - -All man command options are supported, so you can navigate through guide as the way you do when reading a man page. To view the help section, press **h**. - -![][7] - -To exit the selection menu without entering **man** , simply press **Ctrl+c**. - -To go back and/or quit man, type **q**. - -**Search matches in titles and descriptions** - -By default, Awman will search for the matches in titles only. You can, however, direct it to search for the matches in both the titles and descriptions as well. - -``` - $ awman -d vim -``` - -Or, - -``` - $ awman --desc-search vim -``` - -**Search for matches in contents** - -Apart from searching for matches in titles and descriptions, it is also possible to scan the contents for a match as well. Please note that this will significantly slower the search process. - -``` - $ awman -k emacs -``` - -Or, - -``` - $ awman --apropos emacs -``` - -**Open the search results in web browser** - -If you don’t want to view the arch wiki guides in man page format, you can open it in a web browser. To do so, run: - -``` - $ awman -w pacman -``` - -Or, - -``` - $ awman --web pacman -``` - -This command will open the resulting match in the default web browser rather than with **man** command. Please note that you need Internet connection to use this option. - -**Search in other languages** - -By default, Awman will open the Arch wiki pages in English. If you want to view the results in other languages, for example **Spanish** , simply do: - -``` - $ awman -l spanish codecs -``` - -![][8] - -To view the list of available language options, run: - -``` - - $ awman --list-languages - -``` - -**Update the local copy of Arch Wiki** - -Like I already said, the updates are pushed automatically every two days. If you want to update it manually, simply run: - -``` -$ awman-update -arch-wiki-man@1.3.0 /usr/lib/node_modules/arch-wiki-man -└── arch-wiki-md-repo@0.10.84 - -arch-wiki-md-repo has been successfully updated or reinstalled. -``` - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-browse-and-read-entire-arch-wiki-as-linux-man-pages/ - -作者:[SK][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.ostechnix.com/author/sk/ -[b]: https://github.com/lujun9972 -[1]: https://www.ostechnix.com/search-arch-wiki-website-commandline/ -[2]: https://aur.archlinux.org/packages/arch-wiki-man/ -[3]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ -[4]: https://www.ostechnix.com/install-node-js-linux/ -[5]: https://www.ostechnix.com/install-arch-linux-latest-version/ -[6]: http://www.ostechnix.com/wp-content/uploads/2018/10/awman-1.gif -[7]: http://www.ostechnix.com/wp-content/uploads/2018/10/awman-2.png -[8]: https://www.ostechnix.com/wp-content/uploads/2018/10/awman-3-1.png diff --git a/translated/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md b/translated/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md new file mode 100644 index 0000000000..5237307c94 --- /dev/null +++ b/translated/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md @@ -0,0 +1,151 @@ +在 Linux 手册页中查看整个 Arch Linux Wiki +====== +![](https://www.ostechnix.com/wp-content/uploads/2018/10/arch-wiki-720x340.jpg) + +不久之前,我写了篇关于一个名叫 [**arch-wiki-cli**][1] 的命令行脚本的文章,使用它可以在终端命令行中查看整个 Arch Linux Wiki。使用这个脚本,你可以很轻松的用你喜欢的文本浏览器查看整个 Arch Wiki。显然,使用这个脚本需要你有一个好的网络环境。我今天偶然发现了一个名为 **Arch-wiki-man** 的程序,与其有着相同的功能。就跟名字说的一样,它可以让你在命令行查看 Arch Wiki,但是无需联网。它可以以手册页的形式为你显示来自 Arch Wiki 的任何文章。它会下载整个 Arch Wiki,并每两天自动推送一次。因此,你的系统上总能有一份 Arch Wiki 最新的复印件。 + +### 安装 Arch-wiki-man + +Arch-wiki-man 在 [**AUR**][2] 中可用,所以你可以通过类似[**Yay**][3] 的 AUR 帮助程序安装它。 + +``` + $ yay -S arch-wiki-man +``` + +另外,它也可以使用 NPM 安装。首先确保你已经[**安装了 NoodJS**][4],然后使用以下命令安装它。 + +``` + $ npm install -g arch-wiki-man +``` + +### 以手册页的形式查看整个 Arch Wiki + +Arch-wiki-man 的典型语法如下: + +``` + $ awman +``` + +下面看一些具体的例子: + +**搜索一个或多个匹配项** + +只需要下面的命令,就可以搜索 [**Arch Linux 安装指南**][5]。 + +``` + $ awman Installation guide +``` + +上面的命令将会从 Arch Wiki 中搜索所有包含 “安装指南” 的条目。如果对于给出的搜索条目有很多的匹配项,将会展示为一个选择菜单。使用 **上下键** 或是 Vim 风格的方向键(**j/k**),移动到你想查看的指南上,点击回车打开。然后就会像下面这样,以手册页的形式展示指南的内容。 + +![][6] + +awman 指的是 arch wiki man 的首字母组合。 + +它支持手册页的所有操作,所以你可以像使用手册页一样使用它。按 **h** 查看帮助选项。 + +![][7] + +退出选择菜单不需要输入**man**,只需要按 **Ctrl+c**。 + +输入 **q** 返回或者/并且退出手册页。 + +**在标题或者概述中搜索匹配项** + +Awman 默认只会在标题中搜索匹配项。但是你也可以指定它同时在标题和概述中搜索匹配项。 + +``` + $ awman -d vim +``` + +或者, + +``` + $ awman --desc-search vim +``` + +**在目录中搜索匹配项** + +不同于在标题和概述中搜索匹配项,它也能够扫描整个目录达到匹配的目的。不过请注意,这样将会使搜索进程明显变慢。 + +``` + $ awman -k emacs +``` + +或者, + +``` + $ awman --apropos emacs +``` + +**在 web 浏览器中打开搜索结果** + +如果你不想以手册页的形式查看 Arch Wiki 指南,你也可以像下面这样在 web 浏览器中打开它。 + +``` + $ awman -w pacman +``` + +或者, + +``` + $ awman --web pacman +``` + +这条命令将会在 web 浏览器中打开匹配结果。请注意,使用这个选项需要网络连接。 + +**在其他语言中搜索** + +Awman 默认打开的是英文的 Arch Wiki 页面。如果你想用其他的语言查看搜索结果,例如 **西班牙语**,只需要像这样做: + +``` + $ awman -l spanish codecs +``` + +![][8] + +使用以下命令查看可用的语言: + +``` + + $ awman --list-languages + +``` + +**升级本地的 Arch Wiki复印件** + +就像我已经说过的,更新会每两天自动推送一次。或者你也可以使用以下命令手动更新。 + +``` +$ awman-update +arch-wiki-man@1.3.0 /usr/lib/node_modules/arch-wiki-man +└── arch-wiki-md-repo@0.10.84 + +arch-wiki-md-repo has been successfully updated or reinstalled. +``` + +:) + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-browse-and-read-entire-arch-wiki-as-linux-man-pages/ + +作者:[SK][a] +选题:[lujun9972][b] +译者:[dianbanjiu](https://github.com/dianbanjiu) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/search-arch-wiki-website-commandline/ +[2]: https://aur.archlinux.org/packages/arch-wiki-man/ +[3]: https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ +[4]: https://www.ostechnix.com/install-node-js-linux/ +[5]: https://www.ostechnix.com/install-arch-linux-latest-version/ +[6]: http://www.ostechnix.com/wp-content/uploads/2018/10/awman-1.gif +[7]: http://www.ostechnix.com/wp-content/uploads/2018/10/awman-2.png +[8]: https://www.ostechnix.com/wp-content/uploads/2018/10/awman-3-1.png From 1211240d1c6aa3d0b6f7824bd42d4b872f34fc45 Mon Sep 17 00:00:00 2001 From: MjSeven <33125422+MjSeven@users.noreply.github.com> Date: Fri, 19 Oct 2018 22:40:56 +0800 Subject: [PATCH 056/158] Update 20180810 How To Remove Or Disable Ubuntu Dock.md --- sources/tech/20180810 How To Remove Or Disable Ubuntu Dock.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sources/tech/20180810 How To Remove Or Disable Ubuntu Dock.md b/sources/tech/20180810 How To Remove Or Disable Ubuntu Dock.md index 65816f7d5c..709af3de95 100644 --- a/sources/tech/20180810 How To Remove Or Disable Ubuntu Dock.md +++ b/sources/tech/20180810 How To Remove Or Disable Ubuntu Dock.md @@ -1,3 +1,6 @@ +Translating by MjSeven + + How To Remove Or Disable Ubuntu Dock ====== From 211b1d7a9f641eff9fe1c2bf4ab41f2f65208f70 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 19 Oct 2018 22:44:10 +0800 Subject: [PATCH 057/158] PRF:20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md @Ryze-Borgia --- ...s Why Linux is a Better Choice than Mac.md | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md b/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md index 5d660cb60e..b02c8151c8 100644 --- a/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md +++ b/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md @@ -9,7 +9,7 @@ Linux vs Mac:Linux 比 Mac 好的 7 个原因 ![Linux vs Mac:为什么 Linux 更好][2] -Linux 和 macOS 都是类 Unix 操作系统,并且都支持 Unix 命令行、bash 和其它 shell,相比于 Windows,它们所支持的应用和游戏比较少。但也就是这点比较相似。 +Linux 和 macOS 都是类 Unix 操作系统,并且都支持 Unix 命令、bash 和其它 shell,相比于 Windows,它们所支持的应用和游戏比较少。但也就是这点比较相似。 平面设计师和视频剪辑师更加倾向于使用 Mac 系统,而 Linux 更加适合做开发、系统管理、运维的工程师。 @@ -21,9 +21,9 @@ Linux 和 macOS 都是类 Unix 操作系统,并且都支持 Unix 命令行、b 假设你只是需要浏览文件、看电影、下载图片、写文档、制作报表或者做一些类似的工作,并且你想要一个更加安全的系统。 -那在这种情况下,你觉得花费几百美金买个系统完成这项工作,或者花费更多直接买个 Macbook 更好?当然,最终的决定权还是在你。 +那在这种情况下,你觉得花费几百美金买个系统完成这项工作,或者花费更多直接买个 MacBook 更好?当然,最终的决定权还是在你。 -买个装好 Mac 系统的电脑?还是买个便宜的电脑,然后自己装上免费的 Linux 系统?这个要看你自己的偏好。就我个人而言,除了音视频剪辑创作之外,Linux 都非常好地用,而对于音视频方面,我更倾向于使用 Final Cut Pro(专业的视频编辑软件)和 Logic Pro X(专业的音乐制作软件)(译注:这两款软件都是苹果公司推出的)。 +买个装好 Mac 系统的电脑?还是买个便宜的电脑,然后自己装上免费的 Linux 系统?这个要看你自己的偏好。就我个人而言,除了音视频剪辑创作之外,Linux 都非常好地用,而对于音视频方面,我更倾向于使用 Final Cut Pro(专业的视频编辑软件)和 Logic Pro X(专业的音乐制作软件)(LCTT 译注:这两款软件都是苹果公司推出的)。 #### 2、硬件支持 @@ -57,9 +57,9 @@ Linux 支持多种平台。无论你的电脑配置如何,你都可以在上 举个例子,如果你不喜欢 Ubuntu 18.04.1 的 [Gnome 桌面环境][11],你可以换成 [KDE Plasma][18]。你也可以尝试一些 [Gnome 扩展][12]丰富你的桌面选择。这种灵活性和可定制性在 Mac OS 是不可能有的。 -除此之外,你还可以根据需要修改一些操作系统的代码(但是可能需要一些专业知识)来打造适合你的系统。这个在 Mac OS 上可以做吗? +除此之外,你还可以根据需要修改一些操作系统的代码(但是可能需要一些专业知识)来打造适合你的系统。这个在 MacOS 上可以做吗? -另外你可以根据需要从一系列的 Linux 发行版进行选择。比如说,如果你喜欢 Mac OS 上的工作流,[Elementary OS][13] 可能是个不错的选择。你想在你的旧电脑上装上一个轻量级的 Linux 发行版系统吗?这里是一个[轻量级 Linux 发行版列表][5]。相比较而言,Mac OS 缺乏这种灵活性。 +另外你可以根据需要从一系列的 Linux 发行版进行选择。比如说,如果你喜欢 MacOS 上的工作方式,[Elementary OS][13] 可能是个不错的选择。你想在你的旧电脑上装上一个轻量级的 Linux 发行版系统吗?这里有一个[轻量级 Linux 发行版列表][5]。相比较而言,MacOS 缺乏这种灵活性。 #### 5、使用 Linux 有助于你的职业生涯(针对 IT 行业和科学领域的学生) @@ -69,7 +69,7 @@ Linux 支持多种平台。无论你的电脑配置如何,你都可以在上 但是当你开始使用 Linux 并且探索如何使用的时候,你将会积累非常多的经验。作为一名技术人员,你迟早会接触终端,学习通过命令行操作文件系统以及安装应用程序。你可能不会知道这些都是一些 IT 公司的新员工需要培训的内容。 -除此之外,Linux 在就业市场上还有很大的发展空间。Linux 相关的技术有很多(Cloud、Kubernetes、Sysadmin 等),你可以学习,考取专业技能证书并获得一份相关的高薪工作。要学习这些,你必须使用 Linux 。 +除此之外,Linux 在就业市场上还有很大的发展空间。Linux 相关的技术有很多(云计算、Kubernetes、系统管理等),你可以学习、考取专业技能证书并获得一份相关的高薪工作。要学习这些,你必须使用 Linux。 #### 6、可靠 @@ -77,17 +77,17 @@ Linux 支持多种平台。无论你的电脑配置如何,你都可以在上 想想为什么服务器上用的都是 Linux 系统,当然是因为它可靠。 -但是它为什么可靠呢,相比于 Mac OS,它的可靠体现在什么方面呢? +但是它为什么可靠呢,相比于 MacOS,它的可靠体现在什么方面呢? -答案很简单 —— 给用户更多的控制权,同时提供更好的安全性。在 Mac OS 上,你并不能完全控制它,这样做是为了让操作变得更容易,同时提高你的用户体验。使用 Linux,你可以做任何你想做的事情 —— 这可能会导致(对某些人来说)糟糕的用户体验 —— 但它确实使其更可靠。 +答案很简单 —— 给用户更多的控制权,同时提供更好的安全性。在 MacOS 上,你并不能完全控制它,这样做是为了让操作变得更容易,同时提高你的用户体验。使用 Linux,你可以做任何你想做的事情 —— 这可能会导致(对某些人来说)糟糕的用户体验 —— 但它确实使其更可靠。 #### 7、开源 ![Linux vs Mac:为什么 Linux 更好][16] -开源并不是每个人都关心的。但对我来说,Linux 最重要的优势在于它的开源特性。下面讨论的大多数观点都是开源软件的直接优势。 +开源并不是每个人都关心的。但对我来说,Linux 最重要的优势在于它的开源特性。上面讨论的大多数观点都是开源软件的直接优势。 -简单解释一下,如果是开源软件,你可以自己查看或者修改源代码。但对 Mac 来说,苹果拥有独家控制权。即使你有足够的技术知识,也无法查看 Mac OS 的源代码。 +简单解释一下,如果是开源软件,你可以自己查看或者修改源代码。但对 Mac 来说,苹果拥有独家控制权。即使你有足够的技术知识,也无法查看 MacOS 的源代码。 形象点说,Mac 驱动的系统可以让你得到一辆车,但缺点是你不能打开引擎盖看里面是什么。那可太差劲了! @@ -99,7 +99,7 @@ Linux 支持多种平台。无论你的电脑配置如何,你都可以在上 请在下方评论让我们知道你的想法。 -提示:这里的图片是以企鹅俱乐部为原型的。 +提示:这里的图片是以“企鹅俱乐部”为原型的。 -------------------------------------------------------------------------------- From fcda33b6b5ff12e7a280b132372c7f6925814d33 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 19 Oct 2018 22:45:33 +0800 Subject: [PATCH 058/158] PUB:20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @Ryze-Borgia 恭喜你完成了第一篇翻译! 本文首发地址: https://linux.cn/article-10131-1.html 您的 LCTT 专页地址:https://linux.cn/lctt/Ryze-Borgia 请注册 LCTT 平台领取 LCCN https://lctt.linux.cn/ --- ...nux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md (100%) diff --git a/translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md b/published/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md similarity index 100% rename from translated/talk/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md rename to published/20180915 Linux vs Mac- 7 Reasons Why Linux is a Better Choice than Mac.md From 3aa708e9b36dced1b7fd0fb3aabbadf7e8fcb071 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 19 Oct 2018 23:23:37 +0800 Subject: [PATCH 059/158] PRF:20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md @dianbanjiu --- ...ead Entire Arch Wiki As Linux Man Pages.md | 70 +++++++++---------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/translated/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md b/translated/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md index 5237307c94..9f274b4423 100644 --- a/translated/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md +++ b/translated/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md @@ -1,21 +1,22 @@ 在 Linux 手册页中查看整个 Arch Linux Wiki ====== + ![](https://www.ostechnix.com/wp-content/uploads/2018/10/arch-wiki-720x340.jpg) -不久之前,我写了篇关于一个名叫 [**arch-wiki-cli**][1] 的命令行脚本的文章,使用它可以在终端命令行中查看整个 Arch Linux Wiki。使用这个脚本,你可以很轻松的用你喜欢的文本浏览器查看整个 Arch Wiki。显然,使用这个脚本需要你有一个好的网络环境。我今天偶然发现了一个名为 **Arch-wiki-man** 的程序,与其有着相同的功能。就跟名字说的一样,它可以让你在命令行查看 Arch Wiki,但是无需联网。它可以以手册页的形式为你显示来自 Arch Wiki 的任何文章。它会下载整个 Arch Wiki,并每两天自动推送一次。因此,你的系统上总能有一份 Arch Wiki 最新的复印件。 +不久之前,我写了篇关于一个名叫 [arch-wiki-cli][1] 的命令行脚本的文章,使用它可以在终端命令行中查看 Arch Linux Wiki。使用这个脚本,你可以很轻松的用你喜欢的文本浏览器查看整个 Arch Wiki 网站。显然,使用这个脚本需要你有网络连接。我今天偶然发现了一个名为 Arch-wiki-man 的程序,与其有着相同的功能。就跟名字说的一样,它可以让你在命令行查看 Arch Wiki,但是无需联网。它可以以手册页的形式为你显示来自 Arch Wiki 的任何文章。它会下载整个 Arch Wiki 到本地,并每两天自动推送一次。因此,你的系统上总能有一份 Arch Wiki 最新的副本。 ### 安装 Arch-wiki-man -Arch-wiki-man 在 [**AUR**][2] 中可用,所以你可以通过类似[**Yay**][3] 的 AUR 帮助程序安装它。 +Arch-wiki-man 在 [AUR][2] 中可用,所以你可以通过类似[Yay][3] 的 AUR 帮助程序安装它。 ``` - $ yay -S arch-wiki-man +$ yay -S arch-wiki-man ``` -另外,它也可以使用 NPM 安装。首先确保你已经[**安装了 NoodJS**][4],然后使用以下命令安装它。 +另外,它也可以使用 NPM 安装。首先确保你已经[安装了 NoodJS][4],然后使用以下命令安装它。 ``` - $ npm install -g arch-wiki-man +$ npm install -g arch-wiki-man ``` ### 以手册页的形式查看整个 Arch Wiki @@ -23,83 +24,83 @@ Arch-wiki-man 在 [**AUR**][2] 中可用,所以你可以通过类似[**Yay**][ Arch-wiki-man 的典型语法如下: ``` - $ awman +$ awman ``` 下面看一些具体的例子: -**搜索一个或多个匹配项** +#### 搜索一个或多个匹配项 -只需要下面的命令,就可以搜索 [**Arch Linux 安装指南**][5]。 +只需要下面的命令,就可以搜索 [Arch Linux 安装指南][5]。 ``` - $ awman Installation guide +$ awman Installation guide ``` -上面的命令将会从 Arch Wiki 中搜索所有包含 “安装指南” 的条目。如果对于给出的搜索条目有很多的匹配项,将会展示为一个选择菜单。使用 **上下键** 或是 Vim 风格的方向键(**j/k**),移动到你想查看的指南上,点击回车打开。然后就会像下面这样,以手册页的形式展示指南的内容。 +上面的命令将会从 Arch Wiki 中搜索所有包含 “Installation guide” 的条目。如果对于给出的搜索条目有很多的匹配项,将会展示为一个选择菜单。使用上下方向键或是 Vim 风格的方向键(`j`/`k`),移动到你想查看的指南上,点击回车打开。然后就会像下面这样,以手册页的形式展示指南的内容。 ![][6] awman 指的是 arch wiki man 的首字母组合。 -它支持手册页的所有操作,所以你可以像使用手册页一样使用它。按 **h** 查看帮助选项。 +它支持手册页的所有操作,所以你可以像使用手册页一样使用它。按 `h` 查看帮助选项。 ![][7] -退出选择菜单不需要输入**man**,只需要按 **Ctrl+c**。 +要退出选择菜单而不显示手册页,只需要按 `Ctrl+c`。 -输入 **q** 返回或者/并且退出手册页。 +输入 `q` 返回或者/并且退出手册页。 -**在标题或者概述中搜索匹配项** +#### 在标题或者概述中搜索匹配项 -Awman 默认只会在标题中搜索匹配项。但是你也可以指定它同时在标题和概述中搜索匹配项。 +awman 默认只会在标题中搜索匹配项。但是你也可以指定它同时在标题和概述中搜索匹配项。 ``` - $ awman -d vim +$ awman -d vim ``` -或者, +或者, ``` - $ awman --desc-search vim +$ awman --desc-search vim ``` -**在目录中搜索匹配项** +#### 在目录中搜索匹配项 -不同于在标题和概述中搜索匹配项,它也能够扫描整个目录达到匹配的目的。不过请注意,这样将会使搜索进程明显变慢。 +不同于在标题和概述中搜索匹配项,它也能够扫描整个内容以匹配。不过请注意,这样将会使搜索进程明显变慢。 ``` - $ awman -k emacs +$ awman -k emacs ``` -或者, +或者, ``` - $ awman --apropos emacs +$ awman --apropos emacs ``` -**在 web 浏览器中打开搜索结果** +#### 在 web 浏览器中打开搜索结果 如果你不想以手册页的形式查看 Arch Wiki 指南,你也可以像下面这样在 web 浏览器中打开它。 ``` - $ awman -w pacman +$ awman -w pacman ``` -或者, +或者, ``` - $ awman --web pacman +$ awman --web pacman ``` 这条命令将会在 web 浏览器中打开匹配结果。请注意,使用这个选项需要网络连接。 -**在其他语言中搜索** +#### 在其他语言中搜索 -Awman 默认打开的是英文的 Arch Wiki 页面。如果你想用其他的语言查看搜索结果,例如 **西班牙语**,只需要像这样做: +awman 默认打开的是英文的 Arch Wiki 页面。如果你想用其他的语言查看搜索结果,例如西班牙语,只需要像这样做: ``` - $ awman -l spanish codecs +$ awman -l spanish codecs ``` ![][8] @@ -107,12 +108,10 @@ Awman 默认打开的是英文的 Arch Wiki 页面。如果你想用其他的语 使用以下命令查看可用的语言: ``` - - $ awman --list-languages - +$ awman --list-languages ``` -**升级本地的 Arch Wiki复印件** +#### 升级本地的 Arch Wiki 副本 就像我已经说过的,更新会每两天自动推送一次。或者你也可以使用以下命令手动更新。 @@ -127,7 +126,6 @@ arch-wiki-md-repo has been successfully updated or reinstalled. :) - -------------------------------------------------------------------------------- via: https://www.ostechnix.com/how-to-browse-and-read-entire-arch-wiki-as-linux-man-pages/ @@ -135,7 +133,7 @@ via: https://www.ostechnix.com/how-to-browse-and-read-entire-arch-wiki-as-linux- 作者:[SK][a] 选题:[lujun9972][b] 译者:[dianbanjiu](https://github.com/dianbanjiu) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From f17d560d517cf6024dfff6fccaadb33cd100a1cc Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 19 Oct 2018 23:24:00 +0800 Subject: [PATCH 060/158] PUB:20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md @dianbanjiu https://linux.cn/article-10132-1.html --- ... How To Browse And Read Entire Arch Wiki As Linux Man Pages.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md (100%) diff --git a/translated/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md b/published/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md similarity index 100% rename from translated/tech/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md rename to published/20181015 How To Browse And Read Entire Arch Wiki As Linux Man Pages.md From 9f5371cff98508350cfccf673b1640c3899ba14b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 19 Oct 2018 23:40:15 +0800 Subject: [PATCH 061/158] PRF:20180924 A Simple, Beautiful And Cross-platform Podcast App.md @Flowsnow --- ...eautiful And Cross-platform Podcast App.md | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/translated/tech/20180924 A Simple, Beautiful And Cross-platform Podcast App.md b/translated/tech/20180924 A Simple, Beautiful And Cross-platform Podcast App.md index 1fdba14a5f..855351eac6 100644 --- a/translated/tech/20180924 A Simple, Beautiful And Cross-platform Podcast App.md +++ b/translated/tech/20180924 A Simple, Beautiful And Cross-platform Podcast App.md @@ -1,27 +1,24 @@ -一个简单,美观和跨平台的播客应用程序 +一个简单而美观的跨平台播客应用程序 ====== ![](https://www.ostechnix.com/wp-content/uploads/2018/09/cpod-720x340.png) -播客在过去几年中变得非常流行。 播客就是所谓的“信息娱乐”,它们通常是轻松的,但它通常会为你提供有价值的信息。 播客在过去几年中已经非常火爆了,如果你喜欢某些东西,很可能存在一个相关的播客。 Linux 桌面版上有很多播客播放器,但是如果你想要一些视觉上美观,有光滑动画并且可以在每个平台上运行的东西,那就并没有很多替代品可以替代 **CPod** 了。 CPod(以前称为 **Cumulonimbus**)是一个开源的最简单的播客应用程序,适用于 Linux,MacOS 和 Windows。 +播客在过去几年中变得非常流行。 播客就是所谓的“信息娱乐 infotainment”,它们通常是轻松的,但也会为你提供有价值的信息。 播客在过去几年中已经非常火爆了,如果你喜欢某些东西,就很可能有个相关的播客。 Linux 桌面版上有很多播客播放器,但是如果你想要一些视觉上美观、有顺滑的动画并且可以在每个平台上运行的东西,那就并没有很多替代品可以替代 CPod 了。 CPod(以前称为 Cumulonimbus)是一个开源而成熟的播客应用程序,适用于 Linux、MacOS 和 Windows。 -CPod 运行在一个名为 **Electron** 的东西上 - 这个工具允许开发人员构建跨平台(例如 Windows,MacOs 和 Linux)的桌面图形化应用程序。 在本简要指南中,我们将讨论如何在 Linux 中安装和使用 CPod 播客应用程序。 +CPod 运行在一个名为 Electron 的东西上 —— 这个工具允许开发人员构建跨平台(例如 Windows、MacOS 和 Linux)的桌面图形化应用程序。 在本简要指南中,我们将讨论如何在 Linux 中安装和使用 CPod 播客应用程序。 ### 安装 CPod -转到 CPod 的[**发布页面**][1]。 下载并安装所选平台的二进制文件。 如果你使用 Ubuntu / Debian,你只需从发布页面下载并安装 .deb 文件,如下所示。 +转到 CPod 的[发布页面][1]。 下载并安装所选平台的二进制文件。 如果你使用 Ubuntu / Debian,你只需从发布页面下载并安装 .deb 文件,如下所示。 ``` $ 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 ``` -如果你使用任何其他发行版,你可能需要在发行版页面中使用 **AppImage**。 +如果你使用其他发行版,你可能需要使用发布页面中的 AppImage。 从发布页面下载 AppImage 文件。 @@ -37,17 +34,17 @@ $ chmod +x CPod-1.25.7-x86_64.AppImage $ ./CPod-1.25.7-x86_64.AppImage ``` -你将看到一个对话框询问是否将应用程序与系统集成。 如果要执行此操作,请单击**是**。 +你将看到一个对话框询问是否将应用程序与系统集成。 如果要执行此操作,请单击“yes”。 ### 特征 -**探索标签页** +#### 探索标签页 ![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPod-features-tab.png) -CPod 使用 Apple iTunes 数据库查找播客。 这很好,因为 iTunes 数据库是最大的数据库。 如果那里有一个播客,很可能是在 iTunes 上。 要查找播客,只需使用探索部分中的顶部搜索栏即可。 探索部分还展示了一些受欢迎的播客。 +CPod 使用 Apple iTunes 数据库查找播客。 这很好,因为 iTunes 数据库是最大的这类数据库。 如果某个播客存在,那么很可能就在 iTunes 上。 要查找播客,只需使用探索部分中的顶部搜索栏即可。 探索部分还展示了一些受欢迎的播客。 -**主标签页** +#### 主标签页 ![](http://www.ostechnix.com/wp-content/uploads/2018/09/CPod-home-tab.png) @@ -61,38 +58,40 @@ CPod 使用 Apple iTunes 数据库查找播客。 这很好,因为 iTunes 数 ![](https://www.ostechnix.com/wp-content/uploads/2018/09/The-podcasts-queue.png) -**订阅标签页** +#### 订阅标签页 ![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPod-subscriptions-tab.png) 你当然可以订阅你喜欢的播客。 你可以在订阅标签页中执行的其他一些操作是: -1.刷新播客艺术作品 -2.导出订阅到 .OPML 文件中,从 .OPML 文件中导入订阅。 +1. 刷新播客艺术作品 +2. 导出订阅到 .OPML 文件中,从 .OPML 文件中导入订阅。 - -**播放器** +#### 播放器 ![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPod-Podcast-Player.png) 播放器可能是 CPod 最美观的部分。 该应用程序根据播客的横幅更改整体外观。 底部有一个声音可视化器。 在右侧,你可以查看和搜索此播客的其他剧集。 -**缺点/缺失功能** +#### 缺点/缺失功能 虽然我喜欢这个应用程序,但 CPod 确实有一些特性和缺点: -1. 可怜的 MPRIS 集成 - 你可以从桌面环境的媒体播放器对话框中播放或者暂停播客,但这是不够的。 播客的名称未显示,你可以转到下一个或者上一个剧集。 +1. 糟糕的 MPRIS 集成 —— 你可以从桌面环境的媒体播放器对话框中播放或者暂停播客,但这是不够的。 播客的名称未显示,你可以转到下一个或者上一个剧集。 2. 不支持章节。 -3. 没有自动下载 - 你必须手动下载剧集。 -4. 使用过程中的 CPU 使用率非常高(即使对于 Electron 应用程序)。 +3. 没有自动下载 —— 你必须手动下载剧集。 +4. 使用过程中的 CPU 使用率非常高(即使对于 Electron 应用程序而言)。 +### 总结 -### Verdict - -虽然它确实有它的缺点,但 CPod 显然是最美观的播客播放器应用程序,并且它具有最基本的功能。 如果你喜欢使用视觉上美观的应用程序,并且不需要高级功能,那么这就是你的完美款 app。 我知道我马上就要使用它。 +虽然它确实有它的缺点,但 CPod 显然是最美观的播客播放器应用程序,并且它具有最基本的功能。 如果你喜欢使用视觉上美观的应用程序,并且不需要高级功能,那么这就是你的完美应用。我知道我肯定会使用它。 你喜欢 CPod 吗? 请将你的意见发表在下面的评论中。 +**资源** + +- [CPod GitHub 仓库](https://github.com/z-------------/CPod) + -------------------------------------------------------------------------------- via: https://www.ostechnix.com/cpod-a-simple-beautiful-and-cross-platform-podcast-app/ @@ -100,9 +99,9 @@ via: https://www.ostechnix.com/cpod-a-simple-beautiful-and-cross-platform-podcas 作者:[EDITOR][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/) 荣誉推出 [a]: https://www.ostechnix.com/author/editor/ -[1]: https://github.com/z-------------/CPod/releases \ No newline at end of file +[1]: https://github.com/z-------------/CPod/releases From 39e0d9082e076cef54f72f0e2770ff358830965b Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Fri, 19 Oct 2018 23:40:37 +0800 Subject: [PATCH 062/158] PUB:20180924 A Simple, Beautiful And Cross-platform Podcast App.md @Flowsnow https://linux.cn/article-10133-1.html --- ...20180924 A Simple, Beautiful And Cross-platform Podcast App.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180924 A Simple, Beautiful And Cross-platform Podcast App.md (100%) diff --git a/translated/tech/20180924 A Simple, Beautiful And Cross-platform Podcast App.md b/published/20180924 A Simple, Beautiful And Cross-platform Podcast App.md similarity index 100% rename from translated/tech/20180924 A Simple, Beautiful And Cross-platform Podcast App.md rename to published/20180924 A Simple, Beautiful And Cross-platform Podcast App.md From c51dad136c3f34051aad629e0681ff9f29587897 Mon Sep 17 00:00:00 2001 From: dianbanjiu Date: Sat, 20 Oct 2018 00:24:57 +0800 Subject: [PATCH 063/158] translating --- sources/tech/20180601 Download an OS with GNOME Boxes.md | 1 + sources/tech/20180830 6 places to host your git repository.md | 1 + ...81010 How To List The Enabled-Active Repositories In Linux.md | 1 + 3 files changed, 3 insertions(+) diff --git a/sources/tech/20180601 Download an OS with GNOME Boxes.md b/sources/tech/20180601 Download an OS with GNOME Boxes.md index d5961a55b0..434e0bce24 100644 --- a/sources/tech/20180601 Download an OS with GNOME Boxes.md +++ b/sources/tech/20180601 Download an OS with GNOME Boxes.md @@ -1,3 +1,4 @@ +translating by dianbanjiu Download an OS with GNOME Boxes ====== 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 index 671b120a39..b259b96caa 100644 --- a/sources/tech/20180830 6 places to host your git repository.md +++ b/sources/tech/20180830 6 places to host your git repository.md @@ -1,3 +1,4 @@ +translating by dianbanjiu 6 places to host your git repository ====== diff --git a/sources/tech/20181010 How To List The Enabled-Active Repositories In Linux.md b/sources/tech/20181010 How To List The Enabled-Active Repositories In Linux.md index b4ff872202..47171a9d92 100644 --- a/sources/tech/20181010 How To List The Enabled-Active Repositories In Linux.md +++ b/sources/tech/20181010 How To List The Enabled-Active Repositories In Linux.md @@ -1,3 +1,4 @@ +translating by dianbanjiu How To List The Enabled/Active Repositories In Linux ====== There are many ways to list enabled repositories in Linux. From 4137e0d741a3cd4735be505f5ff7277cf23ed7d5 Mon Sep 17 00:00:00 2001 From: lctt-bot Date: Fri, 19 Oct 2018 17:00:35 +0000 Subject: [PATCH 064/158] Revert "heguangzhi translating" This reverts commit 8aa4e068c342ddae4e41ca4a1581106bea421752. --- ...20180916 Linus, His Apology, And Why We Should Support Him.md | 1 - 1 file changed, 1 deletion(-) 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 e2bf768324..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,6 +1,5 @@ heguangzhi translating - Linus, His Apology, And Why We Should Support Him ====== From a28d5b5172038f49eb21388e369f4a8362af7328 Mon Sep 17 00:00:00 2001 From: lctt-bot Date: Fri, 19 Oct 2018 17:00:59 +0000 Subject: [PATCH 065/158] Revert "apply for translation" This reverts commit 5934c3f30a69ea6bdf25d38192425f824026896d. --- .../tech/20171005 10 Games You Can Play on Linux with Wine.md | 1 - 1 file changed, 1 deletion(-) 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 37b1adb669..5bab9d8c65 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,4 +1,3 @@ -### fuzheng1998 translating 10 Games You Can Play on Linux with Wine ====== ![](https://www.maketecheasier.com/assets/uploads/2017/09/wine-games-feat.jpg) From 6d14f39842c8a87af4750b2310035e3fc65bbc95 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 20 Oct 2018 09:36:12 +0800 Subject: [PATCH 066/158] PRF:20181003 Introducing Swift on Fedora.md @geekpi --- .../20181003 Introducing Swift on Fedora.md | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/translated/tech/20181003 Introducing Swift on Fedora.md b/translated/tech/20181003 Introducing Swift on Fedora.md index ead00d327f..585d900386 100644 --- a/translated/tech/20181003 Introducing Swift on Fedora.md +++ b/translated/tech/20181003 Introducing Swift on Fedora.md @@ -1,34 +1,33 @@ -介绍 Fedora上的 Swift +介绍 Fedora 上的 Swift ====== ![](https://fedoramagazine.org/wp-content/uploads/2018/09/swift-816x345.jpg) -Swift 是一种使用现代方法构建安全性、性能和软件设计模式的通用编程语言。它旨在成为各种编程项目的最佳语言,从系统编程到桌面应用程序,以及扩展到云服务。阅读更多关于它的内容以及如何在 Fedora 中尝试它。 +Swift 是一种使用现代方法构建安全性、性能和软件设计模式的通用编程语言。它旨在成为各种编程项目的最佳语言,从系统编程到桌面应用程序,以及扩展到云服务。继续阅读了解它以及如何在 Fedora 中尝试它。 ### 安全、快速、富有表现力 -与许多现代编程语言一样,Swift 被设计为比基于 C 的语言更安全。例如,变量总是在可以使用之前初始化。检查数组和整数是否溢出。内存自动管理。 +与许多现代编程语言一样,Swift 被设计为比基于 C 的语言更安全。例如,变量总是在使用之前初始化。检查数组和整数是否溢出。内存自动管理。 -Swift 将意图放在语法中。要声明变量,请使用 var 关键字。要声明常量,请使用 let。 +Swift 将意图放在语法中。要声明变量,请使用 `var` 关键字。要声明常量,请使用 `let`。 -Swift 还保证对象永远不会是 nil。实际上,尝试使用已知为 nil 的对象将导致编译时错误。当使用 nil 值时,它支持一种称为 **optional** 的机制。optional 可能包含 nil,但使用 **?** 运算符可以安全地解包。 +Swift 还保证对象永远不会是 `nil`。实际上,尝试使用已知为 `nil` 的对象将导致编译时错误。当使用 `nil` 值时,它支持一种称为 **optional** 的机制。optional 可能包含 `nil`,但使用 `?` 运算符可以安全地解包。 -一些额外的功能包括: - - * 与函数指针统一的闭包 -  * 元组和多个返回值 -  * 泛型 -  * 对范围或集合进行快速而简洁的迭代 -  * 支持方法、扩展和协议的结构体 -  * 函数式编程模式,例如 map 和 filter -  * 内置强大的错误处理 -  * 拥有 do、guard、defer 和 repeat 关键字的高级控制流 +更多的功能包括: +* 与函数指针统一的闭包 +* 元组和多个返回值 +* 泛型 +* 对范围或集合进行快速而简洁的迭代 +* 支持方法、扩展和协议的结构体 +* 函数式编程模式,例如 `map` 和 `filter` +* 内置强大的错误处理 +* 拥有 `do`、`guard`、`defer` 和 `repeat` 关键字的高级控制流 ### 尝试 Swift -Swift 在 Fedora 28 中可用,包名为 **swift-lang**。安装完成后,运行 swift 并启动 REPL 控制台。 +Swift 在 Fedora 28 中可用,包名为 **swift-lang**。安装完成后,运行 `swift` 并启动 REPL 控制台。 ``` $ swift @@ -44,10 +43,9 @@ greeting = "Hello universe!" 3> - ``` -Swift 有一个不断发展的社区,特别底,有一个[工作组][1]致力于使其成为一种高效且有力的服务器端编程语言。请访问[主页][2]了解更多参与方式。 +Swift 有一个不断发展的社区,特别的,有一个[工作组][1]致力于使其成为一种高效且有力的服务器端编程语言。请访问其[主页][2]了解更多参与方式。 图片由 [Uillian Vargas][3] 发布在 [Unsplash][4] 上。 @@ -59,7 +57,7 @@ via: https://fedoramagazine.org/introducing-swift-fedora/ 作者:[Link Dupont][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 201b450d1cf897670c9b609f8812861411c671b8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sat, 20 Oct 2018 09:36:34 +0800 Subject: [PATCH 067/158] PUB:20181003 Introducing Swift on Fedora.md @geekpi https://linux.cn/article-10134-1.html --- .../tech => published}/20181003 Introducing Swift on Fedora.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20181003 Introducing Swift on Fedora.md (100%) diff --git a/translated/tech/20181003 Introducing Swift on Fedora.md b/published/20181003 Introducing Swift on Fedora.md similarity index 100% rename from translated/tech/20181003 Introducing Swift on Fedora.md rename to published/20181003 Introducing Swift on Fedora.md From 40777a3bc94c99c3ba1e7ac7f4260c791b04495e Mon Sep 17 00:00:00 2001 From: jrg Date: Sat, 20 Oct 2018 15:36:34 +0800 Subject: [PATCH 068/158] Delete 20181010 An introduction to using tcpdump at the Linux command line.md --- ...using tcpdump at the Linux command line.md | 459 ------------------ 1 file changed, 459 deletions(-) delete mode 100644 sources/tech/20181010 An introduction to using tcpdump at the Linux command line.md diff --git a/sources/tech/20181010 An introduction to using tcpdump at the Linux command line.md b/sources/tech/20181010 An introduction to using tcpdump at the Linux command line.md deleted file mode 100644 index b498d0ca43..0000000000 --- a/sources/tech/20181010 An introduction to using tcpdump at the Linux command line.md +++ /dev/null @@ -1,459 +0,0 @@ -[translation by jrg] - -An introduction to using tcpdump at the Linux command line -====== - -This flexible, powerful command-line tool helps ease the pain of troubleshooting network issues. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE) - -In my experience as a sysadmin, I have often found network connectivity issues challenging to troubleshoot. For those situations, tcpdump is a great ally. - -Tcpdump is a command line utility that allows you to capture and analyze network traffic going through your system. It is often used to help troubleshoot network issues, as well as a security tool. - -A powerful and versatile tool that includes many options and filters, tcpdump can be used in a variety of cases. Since it's a command line tool, it is ideal to run in remote servers or devices for which a GUI is not available, to collect data that can be analyzed later. It can also be launched in the background or as a scheduled job using tools like cron. - -In this article, we'll look at some of tcpdump's most common features. - -### 1\. Installation on Linux - -Tcpdump is included with several Linux distributions, so chances are, you already have it installed. Check if tcpdump is installed on your system with the following command: - -``` -$ which tcpdump -/usr/sbin/tcpdump -``` - -If tcpdump is not installed, you can install it but using your distribution's package manager. For example, on CentOS or Red Hat Enterprise Linux, like this: - -``` -$ sudo yum install -y tcpdump -``` - -Tcpdump requires `libpcap`, which is a library for network packet capture. If it's not installed, it will be automatically added as a dependency. - -You're ready to start capturing some packets. - -### 2\. Capturing packets with tcpdump - -To capture packets for troubleshooting or analysis, tcpdump requires elevated permissions, so in the following examples most commands are prefixed with `sudo`. - -To begin, use the command `tcpdump -D` to see which interfaces are available for capture: - -``` -$ sudo tcpdump -D -1.eth0 -2.virbr0 -3.eth1 -4.any (Pseudo-device that captures on all interfaces) -5.lo [Loopback] -``` - -In the example above, you can see all the interfaces available in my machine. The special interface `any` allows capturing in any active interface. - -Let's use it to start capturing some packets. Capture all packets in any interface by running this command: - -``` -$ sudo tcpdump -i any -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -09:56:18.293641 IP rhel75.localdomain.ssh > 192.168.64.1.56322: Flags [P.], seq 3770820720:3770820916, ack 3503648727, win 309, options [nop,nop,TS val 76577898 ecr 510770929], length 196 -09:56:18.293794 IP 192.168.64.1.56322 > rhel75.localdomain.ssh: Flags [.], ack 196, win 391, options [nop,nop,TS val 510771017 ecr 76577898], length 0 -09:56:18.295058 IP rhel75.59883 > gateway.domain: 2486+ PTR? 1.64.168.192.in-addr.arpa. (43) -09:56:18.310225 IP gateway.domain > rhel75.59883: 2486 NXDomain* 0/1/0 (102) -09:56:18.312482 IP rhel75.49685 > gateway.domain: 34242+ PTR? 28.64.168.192.in-addr.arpa. (44) -09:56:18.322425 IP gateway.domain > rhel75.49685: 34242 NXDomain* 0/1/0 (103) -09:56:18.323164 IP rhel75.56631 > gateway.domain: 29904+ PTR? 1.122.168.192.in-addr.arpa. (44) -09:56:18.323342 IP rhel75.localdomain.ssh > 192.168.64.1.56322: Flags [P.], seq 196:584, ack 1, win 309, options [nop,nop,TS val 76577928 ecr 510771017], length 388 -09:56:18.323563 IP 192.168.64.1.56322 > rhel75.localdomain.ssh: Flags [.], ack 584, win 411, options [nop,nop,TS val 510771047 ecr 76577928], length 0 -09:56:18.335569 IP gateway.domain > rhel75.56631: 29904 NXDomain* 0/1/0 (103) -09:56:18.336429 IP rhel75.44007 > gateway.domain: 61677+ PTR? 98.122.168.192.in-addr.arpa. (45) -09:56:18.336655 IP gateway.domain > rhel75.44007: 61677* 1/0/0 PTR rhel75. (65) -09:56:18.337177 IP rhel75.localdomain.ssh > 192.168.64.1.56322: Flags [P.], seq 584:1644, ack 1, win 309, options [nop,nop,TS val 76577942 ecr 510771047], length 1060 - ----- SKIPPING LONG OUTPUT ----- - -09:56:19.342939 IP 192.168.64.1.56322 > rhel75.localdomain.ssh: Flags [.], ack 1752016, win 1444, options [nop,nop,TS val 510772067 ecr 76578948], length 0 -^C -9003 packets captured -9010 packets received by filter -7 packets dropped by kernel -$ -``` - -Tcpdump continues to capture packets until it receives an interrupt signal. You can interrupt capturing by pressing `Ctrl+C`. As you can see in this example, `tcpdump` captured more than 9,000 packets. In this case, since I am connected to this server using `ssh`, tcpdump captured all these packages. To limit the number of packets captured and stop `tcpdump`, use the `-c` option: - -``` -$ sudo tcpdump -i any -c 5 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -11:21:30.242740 IP rhel75.localdomain.ssh > 192.168.64.1.56322: Flags [P.], seq 3772575680:3772575876, ack 3503651743, win 309, options [nop,nop,TS val 81689848 ecr 515883153], length 196 -11:21:30.242906 IP 192.168.64.1.56322 > rhel75.localdomain.ssh: Flags [.], ack 196, win 1443, options [nop,nop,TS val 515883235 ecr 81689848], length 0 -11:21:30.244442 IP rhel75.43634 > gateway.domain: 57680+ PTR? 1.64.168.192.in-addr.arpa. (43) -11:21:30.244829 IP gateway.domain > rhel75.43634: 57680 NXDomain 0/0/0 (43) -11:21:30.247048 IP rhel75.33696 > gateway.domain: 37429+ PTR? 28.64.168.192.in-addr.arpa. (44) -5 packets captured -12 packets received by filter -0 packets dropped by kernel -$ -``` - -In this case, `tcpdump` stopped capturing automatically after capturing five packets. This is useful in different scenarios—for instance, if you're troubleshooting connectivity and capturing a few initial packages is enough. This is even more useful when we apply filters to capture specific packets (shown below). - -By default, tcpdump resolves IP addresses and ports into names, as shown in the previous example. When troubleshooting network issues, it is often easier to use the IP addresses and port numbers; disable name resolution by using the option `-n` and port resolution with `-nn`: - -``` -$ sudo tcpdump -i any -c5 -nn -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -23:56:24.292206 IP 192.168.64.28.22 > 192.168.64.1.35110: Flags [P.], seq 166198580:166198776, ack 2414541257, win 309, options [nop,nop,TS val 615664 ecr 540031155], length 196 -23:56:24.292357 IP 192.168.64.1.35110 > 192.168.64.28.22: Flags [.], ack 196, win 1377, options [nop,nop,TS val 540031229 ecr 615664], length 0 -23:56:24.292570 IP 192.168.64.28.22 > 192.168.64.1.35110: Flags [P.], seq 196:568, ack 1, win 309, options [nop,nop,TS val 615664 ecr 540031229], length 372 -23:56:24.292655 IP 192.168.64.1.35110 > 192.168.64.28.22: Flags [.], ack 568, win 1400, options [nop,nop,TS val 540031229 ecr 615664], length 0 -23:56:24.292752 IP 192.168.64.28.22 > 192.168.64.1.35110: Flags [P.], seq 568:908, ack 1, win 309, options [nop,nop,TS val 615664 ecr 540031229], length 340 -5 packets captured -6 packets received by filter -0 packets dropped by kernel -``` - -As shown above, the capture output now displays the IP addresses and port numbers. This also prevents tcpdump from issuing DNS lookups, which helps to lower network traffic while troubleshooting network issues. - -Now that you're able to capture network packets, let's explore what this output means. - -### 3\. Understanding the output format - -Tcpdump is capable of capturing and decoding many different protocols, such as TCP, UDP, ICMP, and many more. While we can't cover all of them here, to help you get started, let's explore the TCP packet. You can find more details about the different protocol formats in tcpdump's [manual pages][1]. A typical TCP packet captured by tcpdump looks like this: - -``` -08:41:13.729687 IP 192.168.64.28.22 > 192.168.64.1.41916: Flags [P.], seq 196:568, ack 1, win 309, options [nop,nop,TS val 117964079 ecr 816509256], length 372 -``` - -The fields may vary depending on the type of packet being sent, but this is the general format. - -The first field, `08:41:13.729687,` represents the timestamp of the received packet as per the local clock. - -Next, `IP` represents the network layer protocol—in this case, `IPv4`. For `IPv6` packets, the value is `IP6`. - -The next field, `192.168.64.28.22`, is the source IP address and port. This is followed by the destination IP address and port, represented by `192.168.64.1.41916`. - -After the source and destination, you can find the TCP Flags `Flags [P.]`. Typical values for this field include: - -| Value | Flag Type | Description | -|-------| --------- | ----------------- | -| S | SYN | Connection Start | -| F | FIN | Connection Finish | -| P | PUSH | Data push | -| R | RST | Connection reset | -| . | ACK | Acknowledgment | - -This field can also be a combination of these values, such as `[S.]` for a `SYN-ACK` packet. - -Next is the sequence number of the data contained in the packet. For the first packet captured, this is an absolute number. Subsequent packets use a relative number to make it easier to follow. In this example, the sequence is `seq 196:568,` which means this packet contains bytes 196 to 568 of this flow. - -This is followed by the Ack Number: `ack 1`. In this case, it is 1 since this is the side sending data. For the side receiving data, this field represents the next expected byte (data) on this flow. For example, the Ack number for the next packet in this flow would be 568. - -The next field is the window size `win 309`, which represents the number of bytes available in the receiving buffer, followed by TCP options such as the MSS (Maximum Segment Size) or Window Scale. For details about TCP protocol options, consult [Transmission Control Protocol (TCP) Parameters][2]. - -Finally, we have the packet length, `length 372`, which represents the length, in bytes, of the payload data. The length is the difference between the last and first bytes in the sequence number. - -Now let's learn how to filter packages to narrow down results and make it easier to troubleshoot specific issues. - -### 4\. Filtering packets - -As mentioned above, tcpdump can capture too many packages, some of which are not even related to the issue you're troubleshooting. For example, if you're troubleshooting a connectivity issue with a web server you're not interested in the SSH traffic, so removing the SSH packets from the output makes it easier to work on the real issue. - -One of tcpdump's most powerful features is its ability to filter the captured packets using a variety of parameters, such as source and destination IP addresses, ports, protocols, etc. Let's look at some of the most common ones. - -#### Protocol - -To filter packets based on protocol, specifying the protocol in the command line. For example, capture ICMP packets only by using this command: - -``` -$ sudo tcpdump -i any -c5 icmp -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -``` - -In a different terminal, try to ping another machine: - -``` -$ ping opensource.com -PING opensource.com (54.204.39.132) 56(84) bytes of data. -64 bytes from ec2-54-204-39-132.compute-1.amazonaws.com (54.204.39.132): icmp_seq=1 ttl=47 time=39.6 ms -``` - -Back in the tcpdump capture, notice that tcpdump captures and displays only the ICMP-related packets. In this case, tcpdump is not displaying name resolution packets that were generated when resolving the name `opensource.com`: - -``` -09:34:20.136766 IP rhel75 > ec2-54-204-39-132.compute-1.amazonaws.com: ICMP echo request, id 20361, seq 1, length 64 -09:34:20.176402 IP ec2-54-204-39-132.compute-1.amazonaws.com > rhel75: ICMP echo reply, id 20361, seq 1, length 64 -09:34:21.140230 IP rhel75 > ec2-54-204-39-132.compute-1.amazonaws.com: ICMP echo request, id 20361, seq 2, length 64 -09:34:21.180020 IP ec2-54-204-39-132.compute-1.amazonaws.com > rhel75: ICMP echo reply, id 20361, seq 2, length 64 -09:34:22.141777 IP rhel75 > ec2-54-204-39-132.compute-1.amazonaws.com: ICMP echo request, id 20361, seq 3, length 64 -5 packets captured -5 packets received by filter -0 packets dropped by kernel -``` - -#### Host - -Limit capture to only packets related to a specific host by using the `host` filter: - -``` -$ sudo tcpdump -i any -c5 -nn host 54.204.39.132 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -09:54:20.042023 IP 192.168.122.98.39326 > 54.204.39.132.80: Flags [S], seq 1375157070, win 29200, options [mss 1460,sackOK,TS val 122350391 ecr 0,nop,wscale 7], length 0 -09:54:20.088127 IP 54.204.39.132.80 > 192.168.122.98.39326: Flags [S.], seq 1935542841, ack 1375157071, win 28960, options [mss 1460,sackOK,TS val 522713542 ecr 122350391,nop,wscale 9], length 0 -09:54:20.088204 IP 192.168.122.98.39326 > 54.204.39.132.80: Flags [.], ack 1, win 229, options [nop,nop,TS val 122350437 ecr 522713542], length 0 -09:54:20.088734 IP 192.168.122.98.39326 > 54.204.39.132.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 122350438 ecr 522713542], length 112: HTTP: GET / HTTP/1.1 -09:54:20.129733 IP 54.204.39.132.80 > 192.168.122.98.39326: Flags [.], ack 113, win 57, options [nop,nop,TS val 522713552 ecr 122350438], length 0 -5 packets captured -5 packets received by filter -0 packets dropped by kernel -``` - -In this example, tcpdump captures and displays only packets to and from host `54.204.39.132`. - -#### Port - -To filter packets based on the desired service or port, use the `port` filter. For example, capture packets related to a web (HTTP) service by using this command: - -``` -$ sudo tcpdump -i any -c5 -nn port 80 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -09:58:28.790548 IP 192.168.122.98.39330 > 54.204.39.132.80: Flags [S], seq 1745665159, win 29200, options [mss 1460,sackOK,TS val 122599140 ecr 0,nop,wscale 7], length 0 -09:58:28.834026 IP 54.204.39.132.80 > 192.168.122.98.39330: Flags [S.], seq 4063583040, ack 1745665160, win 28960, options [mss 1460,sackOK,TS val 522775728 ecr 122599140,nop,wscale 9], length 0 -09:58:28.834093 IP 192.168.122.98.39330 > 54.204.39.132.80: Flags [.], ack 1, win 229, options [nop,nop,TS val 122599183 ecr 522775728], length 0 -09:58:28.834588 IP 192.168.122.98.39330 > 54.204.39.132.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 122599184 ecr 522775728], length 112: HTTP: GET / HTTP/1.1 -09:58:28.878445 IP 54.204.39.132.80 > 192.168.122.98.39330: Flags [.], ack 113, win 57, options [nop,nop,TS val 522775739 ecr 122599184], length 0 -5 packets captured -5 packets received by filter -0 packets dropped by kernel -``` - -#### Source IP/hostname - -You can also filter packets based on the source or destination IP Address or hostname. For example, to capture packets from host `192.168.122.98`: - -``` -$ sudo tcpdump -i any -c5 -nn src 192.168.122.98 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -10:02:15.220824 IP 192.168.122.98.39436 > 192.168.122.1.53: 59332+ A? opensource.com. (32) -10:02:15.220862 IP 192.168.122.98.39436 > 192.168.122.1.53: 20749+ AAAA? opensource.com. (32) -10:02:15.364062 IP 192.168.122.98.39334 > 54.204.39.132.80: Flags [S], seq 1108640533, win 29200, options [mss 1460,sackOK,TS val 122825713 ecr 0,nop,wscale 7], length 0 -10:02:15.409229 IP 192.168.122.98.39334 > 54.204.39.132.80: Flags [.], ack 669337581, win 229, options [nop,nop,TS val 122825758 ecr 522832372], length 0 -10:02:15.409667 IP 192.168.122.98.39334 > 54.204.39.132.80: Flags [P.], seq 0:112, ack 1, win 229, options [nop,nop,TS val 122825759 ecr 522832372], length 112: HTTP: GET / HTTP/1.1 -5 packets captured -5 packets received by filter -0 packets dropped by kernel -``` - -Notice that tcpdumps captured packets with source IP address `192.168.122.98` for multiple services such as name resolution (port 53) and HTTP (port 80). The response packets are not displayed since their source IP is different. - -Conversely, you can use the `dst` filter to filter by destination IP/hostname: - -``` -$ sudo tcpdump -i any -c5 -nn dst 192.168.122.98 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -10:05:03.572931 IP 192.168.122.1.53 > 192.168.122.98.47049: 2248 1/0/0 A 54.204.39.132 (48) -10:05:03.572944 IP 192.168.122.1.53 > 192.168.122.98.47049: 33770 0/0/0 (32) -10:05:03.621833 IP 54.204.39.132.80 > 192.168.122.98.39338: Flags [S.], seq 3474204576, ack 3256851264, win 28960, options [mss 1460,sackOK,TS val 522874425 ecr 122993922,nop,wscale 9], length 0 -10:05:03.667767 IP 54.204.39.132.80 > 192.168.122.98.39338: Flags [.], ack 113, win 57, options [nop,nop,TS val 522874436 ecr 122993972], length 0 -10:05:03.672221 IP 54.204.39.132.80 > 192.168.122.98.39338: Flags [P.], seq 1:643, ack 113, win 57, options [nop,nop,TS val 522874437 ecr 122993972], length 642: HTTP: HTTP/1.1 302 Found -5 packets captured -5 packets received by filter -0 packets dropped by kernel -``` - -#### Complex expressions - -You can also combine filters by using the logical operators `and` and `or` to create more complex expressions. For example, to filter packets from source IP address `192.168.122.98` and service HTTP only, use this command: - -``` -$ sudo tcpdump -i any -c5 -nn src 192.168.122.98 and port 80 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -10:08:00.472696 IP 192.168.122.98.39342 > 54.204.39.132.80: Flags [S], seq 2712685325, win 29200, options [mss 1460,sackOK,TS val 123170822 ecr 0,nop,wscale 7], length 0 -10:08:00.516118 IP 192.168.122.98.39342 > 54.204.39.132.80: Flags [.], ack 268723504, win 229, options [nop,nop,TS val 123170865 ecr 522918648], length 0 -10:08:00.516583 IP 192.168.122.98.39342 > 54.204.39.132.80: Flags [P.], seq 0:112, ack 1, win 229, options [nop,nop,TS val 123170866 ecr 522918648], length 112: HTTP: GET / HTTP/1.1 -10:08:00.567044 IP 192.168.122.98.39342 > 54.204.39.132.80: Flags [.], ack 643, win 239, options [nop,nop,TS val 123170916 ecr 522918661], length 0 -10:08:00.788153 IP 192.168.122.98.39342 > 54.204.39.132.80: Flags [F.], seq 112, ack 643, win 239, options [nop,nop,TS val 123171137 ecr 522918661], length 0 -5 packets captured -5 packets received by filter -0 packets dropped by kernel -``` - -You can create more complex expressions by grouping filter with parentheses. In this case, enclose the entire filter expression with quotation marks to prevent the shell from confusing them with shell expressions: - -``` -$ sudo tcpdump -i any -c5 -nn "port 80 and (src 192.168.122.98 or src 54.204.39.132)" -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -10:10:37.602214 IP 192.168.122.98.39346 > 54.204.39.132.80: Flags [S], seq 871108679, win 29200, options [mss 1460,sackOK,TS val 123327951 ecr 0,nop,wscale 7], length 0 -10:10:37.650651 IP 54.204.39.132.80 > 192.168.122.98.39346: Flags [S.], seq 854753193, ack 871108680, win 28960, options [mss 1460,sackOK,TS val 522957932 ecr 123327951,nop,wscale 9], length 0 -10:10:37.650708 IP 192.168.122.98.39346 > 54.204.39.132.80: Flags [.], ack 1, win 229, options [nop,nop,TS val 123328000 ecr 522957932], length 0 -10:10:37.651097 IP 192.168.122.98.39346 > 54.204.39.132.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 123328000 ecr 522957932], length 112: HTTP: GET / HTTP/1.1 -10:10:37.692900 IP 54.204.39.132.80 > 192.168.122.98.39346: Flags [.], ack 113, win 57, options [nop,nop,TS val 522957942 ecr 123328000], length 0 -5 packets captured -5 packets received by filter -0 packets dropped by kernel -``` - -In this example, we're filtering packets for HTTP service only (port 80) and source IP addresses `192.168.122.98` or `54.204.39.132`. This is a quick way of examining both sides of the same flow. - -### 5\. Checking packet content - -In the previous examples, we're checking only the packets' headers for information such as source, destinations, ports, etc. Sometimes this is all we need to troubleshoot network connectivity issues. Sometimes, however, we need to inspect the content of the packet to ensure that the message we're sending contains what we need or that we received the expected response. To see the packet content, tcpdump provides two additional flags: `-X` to print content in hex, and ASCII or `-A` to print the content in ASCII. - -For example, inspect the HTTP content of a web request like this: - -``` -$ sudo tcpdump -i any -c10 -nn -A port 80 -tcpdump: verbose output suppressed, use -v or -vv for full protocol decode -listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -13:02:14.871803 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [S], seq 2546602048, win 29200, options [mss 1460,sackOK,TS val 133625221 ecr 0,nop,wscale 7], length 0 -E..<..@.@.....zb6.'....P...@......r............ -............................ -13:02:14.910734 IP 54.204.39.132.80 > 192.168.122.98.39366: Flags [S.], seq 1877348646, ack 2546602049, win 28960, options [mss 1460,sackOK,TS val 525532247 ecr 133625221,nop,wscale 9], length 0 -E..<..@./..a6.'...zb.P..o..&...A..q a.......... -.R.W.......     ................ -13:02:14.910832 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [.], ack 1, win 229, options [nop,nop,TS val 133625260 ecr 525532247], length 0 -E..4..@.@.....zb6.'....P...Ao..'........... -.....R.W................ -13:02:14.911808 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 133625261 ecr 525532247], length 112: HTTP: GET / HTTP/1.1 -E.....@.@..1..zb6.'....P...Ao..'........... -.....R.WGET / HTTP/1.1 -User-Agent: Wget/1.14 (linux-gnu) -Accept: */* -Host: opensource.com -Connection: Keep-Alive - -................ -13:02:14.951199 IP 54.204.39.132.80 > 192.168.122.98.39366: Flags [.], ack 113, win 57, options [nop,nop,TS val 525532257 ecr 133625261], length 0 -E..4.F@./.."6.'...zb.P..o..'.......9.2..... -.R.a.................... -13:02:14.955030 IP 54.204.39.132.80 > 192.168.122.98.39366: Flags [P.], seq 1:643, ack 113, win 57, options [nop,nop,TS val 525532258 ecr 133625261], length 642: HTTP: HTTP/1.1 302 Found -E....G@./...6.'...zb.P..o..'.......9....... -.R.b....HTTP/1.1 302 Found -Server: nginx -Date: Sun, 23 Sep 2018 17:02:14 GMT -Content-Type: text/html; charset=iso-8859-1 -Content-Length: 207 -X-Content-Type-Options: nosniff -Location: https://opensource.com/ -Cache-Control: max-age=1209600 -Expires: Sun, 07 Oct 2018 17:02:14 GMT -X-Request-ID: v-6baa3acc-bf52-11e8-9195-22000ab8cf2d -X-Varnish: 632951979 -Age: 0 -Via: 1.1 varnish (Varnish/5.2) -X-Cache: MISS -Connection: keep-alive - - - -302 Found - -

Found

-

The document has moved here.

- -................ -13:02:14.955083 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [.], ack 643, win 239, options [nop,nop,TS val 133625304 ecr 525532258], length 0 -E..4..@.@.....zb6.'....P....o.............. -.....R.b................ -13:02:15.195524 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [F.], seq 113, ack 643, win 239, options [nop,nop,TS val 133625545 ecr 525532258], length 0 -E..4..@.@.....zb6.'....P....o.............. -.....R.b................ -13:02:15.236592 IP 54.204.39.132.80 > 192.168.122.98.39366: Flags [F.], seq 643, ack 114, win 57, options [nop,nop,TS val 525532329 ecr 133625545], length 0 -E..4.H@./.. 6.'...zb.P..o..........9.I..... -.R...................... -13:02:15.236656 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [.], ack 644, win 239, options [nop,nop,TS val 133625586 ecr 525532329], length 0 -E..4..@.@.....zb6.'....P....o.............. -.....R.................. -10 packets captured -10 packets received by filter -0 packets dropped by kernel -``` - -This is helpful for troubleshooting issues with API calls, assuming the calls are using plain HTTP. For encrypted connections, this output is less useful. - -### 6\. Saving captures to a file - -Another useful feature provided by tcpdump is the ability to save the capture to a file so you can analyze the results later. This allows you to capture packets in batch mode overnight, for example, and verify the results in the morning. It also helps when there are too many packets to analyze since real-time capture can occur too fast. - -To save packets to a file instead of displaying them on screen, use the option `-w`: - -``` -$ sudo tcpdump -i any -c10 -nn -w webserver.pcap port 80 -[sudo] password for ricardo: -tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes -10 packets captured -10 packets received by filter -0 packets dropped by kernel -``` - -This command saves the output in a file named `webserver.pcap`. The `.pcap` extension stands for "packet capture" and is the convention for this file format. - -As shown in this example, nothing gets displayed on-screen, and the capture finishes after capturing 10 packets, as per the option `-c10`. If you want some feedback to ensure packets are being captured, use the option `-v`. - -Tcpdump creates a file in binary format so you cannot simply open it with a text editor. To read the contents of the file, execute tcpdump with the `-r` option: - -``` -$ tcpdump -nn -r webserver.pcap -reading from file webserver.pcap, link-type LINUX_SLL (Linux cooked) -13:36:57.679494 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [S], seq 3709732619, win 29200, options [mss 1460,sackOK,TS val 135708029 ecr 0,nop,wscale 7], length 0 -13:36:57.718932 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [S.], seq 1999298316, ack 3709732620, win 28960, options [mss 1460,sackOK,TS val 526052949 ecr 135708029,nop,wscale 9], length 0 -13:36:57.719005 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [.], ack 1, win 229, options [nop,nop,TS val 135708068 ecr 526052949], length 0 -13:36:57.719186 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 135708068 ecr 526052949], length 112: HTTP: GET / HTTP/1.1 -13:36:57.756979 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [.], ack 113, win 57, options [nop,nop,TS val 526052959 ecr 135708068], length 0 -13:36:57.760122 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [P.], seq 1:643, ack 113, win 57, options [nop,nop,TS val 526052959 ecr 135708068], length 642: HTTP: HTTP/1.1 302 Found -13:36:57.760182 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [.], ack 643, win 239, options [nop,nop,TS val 135708109 ecr 526052959], length 0 -13:36:57.977602 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [F.], seq 113, ack 643, win 239, options [nop,nop,TS val 135708327 ecr 526052959], length 0 -13:36:58.022089 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [F.], seq 643, ack 114, win 57, options [nop,nop,TS val 526053025 ecr 135708327], length 0 -13:36:58.022132 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [.], ack 644, win 239, options [nop,nop,TS val 135708371 ecr 526053025], length 0 -$ -``` - -Since you're no longer capturing the packets directly from the network interface, `sudo` is not required to read the file. - -You can also use any of the filters we've discussed to filter the content from the file, just as you would with real-time data. For example, inspect the packets in the capture file from source IP address `54.204.39.132` by executing this command: - -``` -$ tcpdump -nn -r webserver.pcap src 54.204.39.132 -reading from file webserver.pcap, link-type LINUX_SLL (Linux cooked) -13:36:57.718932 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [S.], seq 1999298316, ack 3709732620, win 28960, options [mss 1460,sackOK,TS val 526052949 ecr 135708029,nop,wscale 9], length 0 -13:36:57.756979 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [.], ack 113, win 57, options [nop,nop,TS val 526052959 ecr 135708068], length 0 -13:36:57.760122 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [P.], seq 1:643, ack 113, win 57, options [nop,nop,TS val 526052959 ecr 135708068], length 642: HTTP: HTTP/1.1 302 Found -13:36:58.022089 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [F.], seq 643, ack 114, win 57, options [nop,nop,TS val 526053025 ecr 135708327], length 0 -``` - -### What's next? - -These basic features of tcpdump will help you get started with this powerful and versatile tool. To learn more, consult the [tcpdump website][3] and [man pages][4]. - -The tcpdump command line interface provides great flexibility for capturing and analyzing network traffic. If you need a graphical tool to understand more complex flows, look at [Wireshark][5]. - -One benefit of Wireshark is that it can read `.pcap` files captured by tcpdump. You can use tcpdump to capture packets in a remote machine that does not have a GUI and analyze the result file with Wireshark, but that is a topic for another day. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/10/introduction-tcpdump - -作者:[Ricardo Gerardi][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/rgerardi -[b]: https://github.com/lujun9972 -[1]: http://www.tcpdump.org/manpages/tcpdump.1.html#lbAG -[2]: https://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml -[3]: http://www.tcpdump.org/# -[4]: http://www.tcpdump.org/manpages/tcpdump.1.html -[5]: https://www.wireshark.org/ From 0fa997f4147bd6a078cea98b47e8e6c72190b755 Mon Sep 17 00:00:00 2001 From: jrg Date: Sat, 20 Oct 2018 15:37:49 +0800 Subject: [PATCH 069/158] Create 20181010 An introduction to using tcpdump at the Linux command line.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 翻译完成 --- ...using tcpdump at the Linux command line.md | 458 ++++++++++++++++++ 1 file changed, 458 insertions(+) create mode 100644 translated/tech/20181010 An introduction to using tcpdump at the Linux command line.md diff --git a/translated/tech/20181010 An introduction to using tcpdump at the Linux command line.md b/translated/tech/20181010 An introduction to using tcpdump at the Linux command line.md new file mode 100644 index 0000000000..9926a2279c --- /dev/null +++ b/translated/tech/20181010 An introduction to using tcpdump at the Linux command line.md @@ -0,0 +1,458 @@ + Linux 命令行中使用 tcpdump 抓包 +====== + +Tcpdump 是一款灵活、功能强大的抓包工具,能有效地帮助排查网络故障问题。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE) + +根据我作为管理员的经验,在网络连接中经常遇到十分难以排查的故障问题。对于这类情况,tcpdump 便能派上用场。 + +Tcpdump 是一个命令行实用工具,允许你抓取和分析经过系统的流量数据包。它通常被用作于网络故障分析工具以及安全工具。 + +Tcpdump 是一款强大的工具,支持多种选项和过滤规则,适用场景十分广泛。由于它是命令行工具,因此适用于在远程服务器或者没有图形界面的设备中收集数据包以便于事后分析。它可以在后台启动,也可以用 cron 等定时工具创建定时任务启用它。 + +本文中,我们将讨论 tcpdump 最常用的一些功能。 + +### 1\. 在 Linux 中安装 tcpdump + +Tcpdump 支持多种 Linux 发行版,所以你的系统中很有可能已经安装了它。用下面的命令检查一下是否已经安装了 tcpdump: + +``` +$ which tcpdump +/usr/sbin/tcpdump +``` + +如果还没有安装 tcpdump,你可以用软件包管理器安装它。 +例如,在 CentOS 或者 Red Hat Enterprise 系统中,用如下命令安装 tcpdump: + +``` +$ sudo yum install -y tcpdump +``` + +Tcpdump 依赖于 `libpcap`,该库文件用于捕获网络数据包。如果该库文件也没有安装,系统会根据依赖关系自动安装它。 + +现在你可以开始抓包了。 + +### 2\. 用 tcpdump 抓包 + +使用 tcpdump 抓包,需要管理员权限,因此下面的示例中绝大多数命令都是以 `sudo` 开头。 + +首先,先用 `tcpdump -D` 命令列出可以抓包的网络接口: + +``` +$ sudo tcpdump -D +1.eth0 +2.virbr0 +3.eth1 +4.any (Pseudo-device that captures on all interfaces) +5.lo [Loopback] +``` + +如上所示,可以看到我的机器中所有可以抓包的网络接口。其中特殊接口 `any` 可用于抓取所有活动的网络接口的数据包。 + +我们就用如下命令先对 `any` 接口进行抓包: + +``` +$ sudo tcpdump -i any +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +09:56:18.293641 IP rhel75.localdomain.ssh > 192.168.64.1.56322: Flags [P.], seq 3770820720:3770820916, ack 3503648727, win 309, options [nop,nop,TS val 76577898 ecr 510770929], length 196 +09:56:18.293794 IP 192.168.64.1.56322 > rhel75.localdomain.ssh: Flags [.], ack 196, win 391, options [nop,nop,TS val 510771017 ecr 76577898], length 0 +09:56:18.295058 IP rhel75.59883 > gateway.domain: 2486+ PTR? 1.64.168.192.in-addr.arpa. (43) +09:56:18.310225 IP gateway.domain > rhel75.59883: 2486 NXDomain* 0/1/0 (102) +09:56:18.312482 IP rhel75.49685 > gateway.domain: 34242+ PTR? 28.64.168.192.in-addr.arpa. (44) +09:56:18.322425 IP gateway.domain > rhel75.49685: 34242 NXDomain* 0/1/0 (103) +09:56:18.323164 IP rhel75.56631 > gateway.domain: 29904+ PTR? 1.122.168.192.in-addr.arpa. (44) +09:56:18.323342 IP rhel75.localdomain.ssh > 192.168.64.1.56322: Flags [P.], seq 196:584, ack 1, win 309, options [nop,nop,TS val 76577928 ecr 510771017], length 388 +09:56:18.323563 IP 192.168.64.1.56322 > rhel75.localdomain.ssh: Flags [.], ack 584, win 411, options [nop,nop,TS val 510771047 ecr 76577928], length 0 +09:56:18.335569 IP gateway.domain > rhel75.56631: 29904 NXDomain* 0/1/0 (103) +09:56:18.336429 IP rhel75.44007 > gateway.domain: 61677+ PTR? 98.122.168.192.in-addr.arpa. (45) +09:56:18.336655 IP gateway.domain > rhel75.44007: 61677* 1/0/0 PTR rhel75. (65) +09:56:18.337177 IP rhel75.localdomain.ssh > 192.168.64.1.56322: Flags [P.], seq 584:1644, ack 1, win 309, options [nop,nop,TS val 76577942 ecr 510771047], length 1060 + +---- SKIPPING LONG OUTPUT ----- + +09:56:19.342939 IP 192.168.64.1.56322 > rhel75.localdomain.ssh: Flags [.], ack 1752016, win 1444, options [nop,nop,TS val 510772067 ecr 76578948], length 0 +^C +9003 packets captured +9010 packets received by filter +7 packets dropped by kernel +$ +``` + +Tcpdump 会持续抓包直到收到中断信号。你可以按 `Ctrl+C` 来停止抓包。正如上面示例所示,`tcpdump` 抓取了超过 9000 个数据包。在这个示例中,由于我是通过 `ssh` 连接到服务器,所以 tcpdump 也捕获了所有这类数据包。`-c` 选项可以用于限制 tcpdump 抓包的数量: + +``` +$ sudo tcpdump -i any -c 5 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +11:21:30.242740 IP rhel75.localdomain.ssh > 192.168.64.1.56322: Flags [P.], seq 3772575680:3772575876, ack 3503651743, win 309, options [nop,nop,TS val 81689848 ecr 515883153], length 196 +11:21:30.242906 IP 192.168.64.1.56322 > rhel75.localdomain.ssh: Flags [.], ack 196, win 1443, options [nop,nop,TS val 515883235 ecr 81689848], length 0 +11:21:30.244442 IP rhel75.43634 > gateway.domain: 57680+ PTR? 1.64.168.192.in-addr.arpa. (43) +11:21:30.244829 IP gateway.domain > rhel75.43634: 57680 NXDomain 0/0/0 (43) +11:21:30.247048 IP rhel75.33696 > gateway.domain: 37429+ PTR? 28.64.168.192.in-addr.arpa. (44) +5 packets captured +12 packets received by filter +0 packets dropped by kernel +$ +``` + +如上所示,`tcpdump` 在抓取 5 个数据包后自动停止了抓包。这在有些场景中十分有用——比如你只需要抓取少量的数据包用于分析。当我们需要使用过滤规则抓取特定的数据包(如下所示)时,`-c` 的作用就十分突出了。 + +在上面示例中,tcpdump 默认是将 IP 地址和端口号解析为对应的接口名以及服务协议名称。而通常在网络故障排查中,使用 IP 地址和端口号更便于分析问题;用 `-n` 选项显示 IP 地址,`-nn` 选项显示端口号: + +``` +$ sudo tcpdump -i any -c5 -nn +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +23:56:24.292206 IP 192.168.64.28.22 > 192.168.64.1.35110: Flags [P.], seq 166198580:166198776, ack 2414541257, win 309, options [nop,nop,TS val 615664 ecr 540031155], length 196 +23:56:24.292357 IP 192.168.64.1.35110 > 192.168.64.28.22: Flags [.], ack 196, win 1377, options [nop,nop,TS val 540031229 ecr 615664], length 0 +23:56:24.292570 IP 192.168.64.28.22 > 192.168.64.1.35110: Flags [P.], seq 196:568, ack 1, win 309, options [nop,nop,TS val 615664 ecr 540031229], length 372 +23:56:24.292655 IP 192.168.64.1.35110 > 192.168.64.28.22: Flags [.], ack 568, win 1400, options [nop,nop,TS val 540031229 ecr 615664], length 0 +23:56:24.292752 IP 192.168.64.28.22 > 192.168.64.1.35110: Flags [P.], seq 568:908, ack 1, win 309, options [nop,nop,TS val 615664 ecr 540031229], length 340 +5 packets captured +6 packets received by filter +0 packets dropped by kernel +``` + +如上所示,抓取的数据包中显示 IP 地址和端口号。这样还可以阻止 tcpdump 发出 DNS 查找,有助于在网络故障排查中减少数据流量。 + +现在你已经会抓包了,让我们来分析一下这些抓包输出的含义吧。 + +### 3\. 理解抓取的报文 + +Tcpdump 能够抓取并解码多种协议类型的数据报文,如 TCP,UDP,ICMP 等等。虽然这里我们不可能介绍所有的数据报文类型,但可以分析下 TCP 类型的数据报文,来帮助你入门。更多有关 tcpdump 的详细介绍可以参考其 [帮助手册][1]。Tcpdump 抓取的 TCP 报文看起来如下: + +``` +08:41:13.729687 IP 192.168.64.28.22 > 192.168.64.1.41916: Flags [P.], seq 196:568, ack 1, win 309, options [nop,nop,TS val 117964079 ecr 816509256], length 372 +``` + +具体的字段根据不同的报文类型会有不同,但上面这个例子是一般的格式形式。 + +第一个字段 `08:41:13.729687` 是该数据报文被抓取的系统本地时间戳。 + +然后,`IP` 是网络层协议类型,这里是 `IPv4`,如果是 `IPv6` 协议,该字段值是 `IP6`。 + +`192.168.64.28.22` 是源 ip 地址和端口号,紧跟其后的是目的 ip 地址和其端口号,这里是 `192.168.64.1.41916`。 + +在源 IP 和目的 IP 之后,可以看到是 TCP 报文标记段 `Flags [P.]`。该字段通常取值如下: + +| Value | Flag Type | Description | +| ----- | --------- | ----------------- | +| S | SYN | Connection Start | +| F | FIN | Connection Finish | +| P | PUSH | Data push | +| R | RST | Connection reset | +| . | ACK | Acknowledgment | + +该字段也可以是这些值的组合,例如 `[S.]` 代表 `SYN-ACK` 数据包。 + +接下来是该数据包中数据的序列号。对于抓取的第一个数据包,该字段值是一个绝对数字,后续包使用相对数值,以便更容易查询跟踪。例如此处 `seq 196:568` 代表该数据包包含该数据流的第 196 到 568 字节。 + +接下来是 ack 值:`ack 1`。该数据包是数据发送方,ack 值为1。在数据接收方,该字段代表数据流上的下一个预期字节数据,例如,该数据流中下一个数据包的 ack 值应该是 568。 + +接下来字段是接收窗口大小 `win 309`,它表示接收缓冲区中可用的字节数,后跟 TCP 选项如 MSS(最大段大小)或者窗口比例值。更详尽的 TCP 协议内容请参考 [Transmission Control Protocol(TCP) Parameters][2]。 + +最后,`length 372`代表数据包有效载荷字节长度。这个长度和 seq 序列号中字节数值长度是不一样的。 + +现在让我们学习如何过滤数据报文以便更容易的分析定位问题。 + +### 4\. 过滤数据包 + +正如上面所提,tcpdump 可以抓取很多种类型的数据报文,其中很多可能和我们需要查找的问题并没有关系。举个例子,假设你正在定位一个与 web 服务器连接的网络问题,就不必关系 SSH 数据报文,因此在抓包结果中过滤掉 SSH 报文可能更便于你分析问题。 + +Tcpdump 有很多参数选项可以设置数据包过滤规则,例如根据源 IP 以及目的 IP 地址,端口号,协议等等规则来过滤数据包。下面就介绍一些最常用的过滤方法。 + +#### 协议 + +在命令中指定协议便可以按照协议类型来筛选数据包。比方说用如下命令只要抓取 ICMP 报文: + +``` +$ sudo tcpdump -i any -c5 icmp +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +``` + +然后再打开一个终端,去 ping 另一台机器: + +``` +$ ping opensource.com +PING opensource.com (54.204.39.132) 56(84) bytes of data. +64 bytes from ec2-54-204-39-132.compute-1.amazonaws.com (54.204.39.132): icmp_seq=1 ttl=47 time=39.6 ms +``` + +回到运行 tcpdump 命令的终端中,可以看到它筛选出了 ICMP 报文。这里 tcpdump 并没有显示有关 `opensource.com`的域名解析数据包: + +``` +09:34:20.136766 IP rhel75 > ec2-54-204-39-132.compute-1.amazonaws.com: ICMP echo request, id 20361, seq 1, length 64 +09:34:20.176402 IP ec2-54-204-39-132.compute-1.amazonaws.com > rhel75: ICMP echo reply, id 20361, seq 1, length 64 +09:34:21.140230 IP rhel75 > ec2-54-204-39-132.compute-1.amazonaws.com: ICMP echo request, id 20361, seq 2, length 64 +09:34:21.180020 IP ec2-54-204-39-132.compute-1.amazonaws.com > rhel75: ICMP echo reply, id 20361, seq 2, length 64 +09:34:22.141777 IP rhel75 > ec2-54-204-39-132.compute-1.amazonaws.com: ICMP echo request, id 20361, seq 3, length 64 +5 packets captured +5 packets received by filter +0 packets dropped by kernel +``` + +#### 主机 + +用 `host` 参数只抓取和特定主机相关的数据包: + +``` +$ sudo tcpdump -i any -c5 -nn host 54.204.39.132 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +09:54:20.042023 IP 192.168.122.98.39326 > 54.204.39.132.80: Flags [S], seq 1375157070, win 29200, options [mss 1460,sackOK,TS val 122350391 ecr 0,nop,wscale 7], length 0 +09:54:20.088127 IP 54.204.39.132.80 > 192.168.122.98.39326: Flags [S.], seq 1935542841, ack 1375157071, win 28960, options [mss 1460,sackOK,TS val 522713542 ecr 122350391,nop,wscale 9], length 0 +09:54:20.088204 IP 192.168.122.98.39326 > 54.204.39.132.80: Flags [.], ack 1, win 229, options [nop,nop,TS val 122350437 ecr 522713542], length 0 +09:54:20.088734 IP 192.168.122.98.39326 > 54.204.39.132.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 122350438 ecr 522713542], length 112: HTTP: GET / HTTP/1.1 +09:54:20.129733 IP 54.204.39.132.80 > 192.168.122.98.39326: Flags [.], ack 113, win 57, options [nop,nop,TS val 522713552 ecr 122350438], length 0 +5 packets captured +5 packets received by filter +0 packets dropped by kernel +``` +如上所示,只抓取和显示与 `54.204.39.132` 有关的数据包。 + +#### 端口号 + +Tcpdump 可以根据服务类型或者端口号来筛选数据包。例如,抓取和 HTTP 服务相关的数据包: + +``` +$ sudo tcpdump -i any -c5 -nn port 80 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +09:58:28.790548 IP 192.168.122.98.39330 > 54.204.39.132.80: Flags [S], seq 1745665159, win 29200, options [mss 1460,sackOK,TS val 122599140 ecr 0,nop,wscale 7], length 0 +09:58:28.834026 IP 54.204.39.132.80 > 192.168.122.98.39330: Flags [S.], seq 4063583040, ack 1745665160, win 28960, options [mss 1460,sackOK,TS val 522775728 ecr 122599140,nop,wscale 9], length 0 +09:58:28.834093 IP 192.168.122.98.39330 > 54.204.39.132.80: Flags [.], ack 1, win 229, options [nop,nop,TS val 122599183 ecr 522775728], length 0 +09:58:28.834588 IP 192.168.122.98.39330 > 54.204.39.132.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 122599184 ecr 522775728], length 112: HTTP: GET / HTTP/1.1 +09:58:28.878445 IP 54.204.39.132.80 > 192.168.122.98.39330: Flags [.], ack 113, win 57, options [nop,nop,TS val 522775739 ecr 122599184], length 0 +5 packets captured +5 packets received by filter +0 packets dropped by kernel +``` + +#### IP 地址/主机名 + +同样,你也可以根据源 IP 地址或者目的 IP 地址或者主机名来筛选数据包。例如抓取源 IP 地址为 `192.168.122.98` 的数据包: + +``` +$ sudo tcpdump -i any -c5 -nn src 192.168.122.98 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +10:02:15.220824 IP 192.168.122.98.39436 > 192.168.122.1.53: 59332+ A? opensource.com. (32) +10:02:15.220862 IP 192.168.122.98.39436 > 192.168.122.1.53: 20749+ AAAA? opensource.com. (32) +10:02:15.364062 IP 192.168.122.98.39334 > 54.204.39.132.80: Flags [S], seq 1108640533, win 29200, options [mss 1460,sackOK,TS val 122825713 ecr 0,nop,wscale 7], length 0 +10:02:15.409229 IP 192.168.122.98.39334 > 54.204.39.132.80: Flags [.], ack 669337581, win 229, options [nop,nop,TS val 122825758 ecr 522832372], length 0 +10:02:15.409667 IP 192.168.122.98.39334 > 54.204.39.132.80: Flags [P.], seq 0:112, ack 1, win 229, options [nop,nop,TS val 122825759 ecr 522832372], length 112: HTTP: GET / HTTP/1.1 +5 packets captured +5 packets received by filter +0 packets dropped by kernel +``` + +注意此处示例中抓取了来自源 IP 地址 `192.168.122.98` 的 53 端口以及 80 端口的数据包,它们的应答包没有显示出来因为那些包的源 IP 地址已经变了。 + +相对的,使用 `dst` 就是按目的 IP/主机名来筛选数据包。 + +``` +$ sudo tcpdump -i any -c5 -nn dst 192.168.122.98 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +10:05:03.572931 IP 192.168.122.1.53 > 192.168.122.98.47049: 2248 1/0/0 A 54.204.39.132 (48) +10:05:03.572944 IP 192.168.122.1.53 > 192.168.122.98.47049: 33770 0/0/0 (32) +10:05:03.621833 IP 54.204.39.132.80 > 192.168.122.98.39338: Flags [S.], seq 3474204576, ack 3256851264, win 28960, options [mss 1460,sackOK,TS val 522874425 ecr 122993922,nop,wscale 9], length 0 +10:05:03.667767 IP 54.204.39.132.80 > 192.168.122.98.39338: Flags [.], ack 113, win 57, options [nop,nop,TS val 522874436 ecr 122993972], length 0 +10:05:03.672221 IP 54.204.39.132.80 > 192.168.122.98.39338: Flags [P.], seq 1:643, ack 113, win 57, options [nop,nop,TS val 522874437 ecr 122993972], length 642: HTTP: HTTP/1.1 302 Found +5 packets captured +5 packets received by filter +0 packets dropped by kernel +``` + +#### 多条件筛选 + +当然,可以使用多条件组合来筛选数据包,使用 `and` 以及 `or` 逻辑操作符来创建过滤规则。例如,筛选来自源 IP 地址 `192.168.122.98` 的 HTTP 数据包: + +``` +$ sudo tcpdump -i any -c5 -nn src 192.168.122.98 and port 80 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +10:08:00.472696 IP 192.168.122.98.39342 > 54.204.39.132.80: Flags [S], seq 2712685325, win 29200, options [mss 1460,sackOK,TS val 123170822 ecr 0,nop,wscale 7], length 0 +10:08:00.516118 IP 192.168.122.98.39342 > 54.204.39.132.80: Flags [.], ack 268723504, win 229, options [nop,nop,TS val 123170865 ecr 522918648], length 0 +10:08:00.516583 IP 192.168.122.98.39342 > 54.204.39.132.80: Flags [P.], seq 0:112, ack 1, win 229, options [nop,nop,TS val 123170866 ecr 522918648], length 112: HTTP: GET / HTTP/1.1 +10:08:00.567044 IP 192.168.122.98.39342 > 54.204.39.132.80: Flags [.], ack 643, win 239, options [nop,nop,TS val 123170916 ecr 522918661], length 0 +10:08:00.788153 IP 192.168.122.98.39342 > 54.204.39.132.80: Flags [F.], seq 112, ack 643, win 239, options [nop,nop,TS val 123171137 ecr 522918661], length 0 +5 packets captured +5 packets received by filter +0 packets dropped by kernel +``` + +你也可以使用括号来创建更为复杂的过滤规则,但在 shell 中请用引号包含你的过滤规则以防止被识别为 shell 表达式: + +``` +$ sudo tcpdump -i any -c5 -nn "port 80 and (src 192.168.122.98 or src 54.204.39.132)" +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +10:10:37.602214 IP 192.168.122.98.39346 > 54.204.39.132.80: Flags [S], seq 871108679, win 29200, options [mss 1460,sackOK,TS val 123327951 ecr 0,nop,wscale 7], length 0 +10:10:37.650651 IP 54.204.39.132.80 > 192.168.122.98.39346: Flags [S.], seq 854753193, ack 871108680, win 28960, options [mss 1460,sackOK,TS val 522957932 ecr 123327951,nop,wscale 9], length 0 +10:10:37.650708 IP 192.168.122.98.39346 > 54.204.39.132.80: Flags [.], ack 1, win 229, options [nop,nop,TS val 123328000 ecr 522957932], length 0 +10:10:37.651097 IP 192.168.122.98.39346 > 54.204.39.132.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 123328000 ecr 522957932], length 112: HTTP: GET / HTTP/1.1 +10:10:37.692900 IP 54.204.39.132.80 > 192.168.122.98.39346: Flags [.], ack 113, win 57, options [nop,nop,TS val 522957942 ecr 123328000], length 0 +5 packets captured +5 packets received by filter +0 packets dropped by kernel +``` + +该例子中我们只抓取了来自源 IP 为 `192.168.122.98` 或者 `54.204.39.132` 的 HTTP (端口号80)的数据包。使用该方法就很容易抓取到数据流中交互双方的数据包了。 + +### 5\. 检查数据包内容 + +在以上的示例中,我们只按数据包头部的信息来建立规则筛选数据包,例如源地址、目的地址、端口号等等。有时我们需要分析网络连接问题,可能需要分析数据包中的内容来判断什么内容需要被发送、什么内容需要被接收等。Tcpdump 提供了两个选项可以查看数据包内容,`-X` 以十六进制打印出数据报文内容,`-A` 打印数据报文的 ASCII 值。 + +例如,HTTP request 报文内容如下: + +``` +$ sudo tcpdump -i any -c10 -nn -A port 80 +tcpdump: verbose output suppressed, use -v or -vv for full protocol decode +listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +13:02:14.871803 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [S], seq 2546602048, win 29200, options [mss 1460,sackOK,TS val 133625221 ecr 0,nop,wscale 7], length 0 +E..<..@.@.....zb6.'....P...@......r............ +............................ +13:02:14.910734 IP 54.204.39.132.80 > 192.168.122.98.39366: Flags [S.], seq 1877348646, ack 2546602049, win 28960, options [mss 1460,sackOK,TS val 525532247 ecr 133625221,nop,wscale 9], length 0 +E..<..@./..a6.'...zb.P..o..&...A..q a.......... +.R.W.......     ................ +13:02:14.910832 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [.], ack 1, win 229, options [nop,nop,TS val 133625260 ecr 525532247], length 0 +E..4..@.@.....zb6.'....P...Ao..'........... +.....R.W................ +13:02:14.911808 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 133625261 ecr 525532247], length 112: HTTP: GET / HTTP/1.1 +E.....@.@..1..zb6.'....P...Ao..'........... +.....R.WGET / HTTP/1.1 +User-Agent: Wget/1.14 (linux-gnu) +Accept: */* +Host: opensource.com +Connection: Keep-Alive + +................ +13:02:14.951199 IP 54.204.39.132.80 > 192.168.122.98.39366: Flags [.], ack 113, win 57, options [nop,nop,TS val 525532257 ecr 133625261], length 0 +E..4.F@./.."6.'...zb.P..o..'.......9.2..... +.R.a.................... +13:02:14.955030 IP 54.204.39.132.80 > 192.168.122.98.39366: Flags [P.], seq 1:643, ack 113, win 57, options [nop,nop,TS val 525532258 ecr 133625261], length 642: HTTP: HTTP/1.1 302 Found +E....G@./...6.'...zb.P..o..'.......9....... +.R.b....HTTP/1.1 302 Found +Server: nginx +Date: Sun, 23 Sep 2018 17:02:14 GMT +Content-Type: text/html; charset=iso-8859-1 +Content-Length: 207 +X-Content-Type-Options: nosniff +Location: https://opensource.com/ +Cache-Control: max-age=1209600 +Expires: Sun, 07 Oct 2018 17:02:14 GMT +X-Request-ID: v-6baa3acc-bf52-11e8-9195-22000ab8cf2d +X-Varnish: 632951979 +Age: 0 +Via: 1.1 varnish (Varnish/5.2) +X-Cache: MISS +Connection: keep-alive + + + +302 Found + +

Found

+

The document has moved here.

+ +................ +13:02:14.955083 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [.], ack 643, win 239, options [nop,nop,TS val 133625304 ecr 525532258], length 0 +E..4..@.@.....zb6.'....P....o.............. +.....R.b................ +13:02:15.195524 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [F.], seq 113, ack 643, win 239, options [nop,nop,TS val 133625545 ecr 525532258], length 0 +E..4..@.@.....zb6.'....P....o.............. +.....R.b................ +13:02:15.236592 IP 54.204.39.132.80 > 192.168.122.98.39366: Flags [F.], seq 643, ack 114, win 57, options [nop,nop,TS val 525532329 ecr 133625545], length 0 +E..4.H@./.. 6.'...zb.P..o..........9.I..... +.R...................... +13:02:15.236656 IP 192.168.122.98.39366 > 54.204.39.132.80: Flags [.], ack 644, win 239, options [nop,nop,TS val 133625586 ecr 525532329], length 0 +E..4..@.@.....zb6.'....P....o.............. +.....R.................. +10 packets captured +10 packets received by filter +0 packets dropped by kernel +``` + +这对定位一些普通 HTTP 调用 API 接口的问题很有用。当然如果是加密报文,这个输出也就没多大用了。 + +### 6\. 保存抓包数据 + +Tcpdump 提供了保存抓包数据的功能以便后续分析数据包。例如,你可以夜里让它在那里抓包,然后早上起来再去分析它。同样当有很多数据包时,显示过快也不利于分析,将数据包保存下来,更有利于分析问题。 + +使用 `-w` 选项来保存数据包而不是在屏幕上显示出抓取的数据包: + +``` +$ sudo tcpdump -i any -c10 -nn -w webserver.pcap port 80 +[sudo] password for ricardo: +tcpdump: listening on any, link-type LINUX_SLL (Linux cooked), capture size 262144 bytes +10 packets captured +10 packets received by filter +0 packets dropped by kernel +``` + +该命令将抓取的数据包保存到文件 `webserver.pcap`。后缀名 `pcap` 表示文件是抓取的数据包格式。 + +正如示例中所示,保存数据包到文件中时屏幕上就没有任何有关数据报文的输出,其中 `-c10` 表示抓取到 10 个数据包后就停止抓包。如果想有一些反馈来提示确实抓取到了数据包,可以使用 `-v` 选项。 + +Tcpdump 将数据包保存在二进制文件中,所以不能简单的用文本编辑器去打开它。使用 `-r` 选项参数来阅读该文件中的报文内容: + +``` +$ tcpdump -nn -r webserver.pcap +reading from file webserver.pcap, link-type LINUX_SLL (Linux cooked) +13:36:57.679494 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [S], seq 3709732619, win 29200, options [mss 1460,sackOK,TS val 135708029 ecr 0,nop,wscale 7], length 0 +13:36:57.718932 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [S.], seq 1999298316, ack 3709732620, win 28960, options [mss 1460,sackOK,TS val 526052949 ecr 135708029,nop,wscale 9], length 0 +13:36:57.719005 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [.], ack 1, win 229, options [nop,nop,TS val 135708068 ecr 526052949], length 0 +13:36:57.719186 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [P.], seq 1:113, ack 1, win 229, options [nop,nop,TS val 135708068 ecr 526052949], length 112: HTTP: GET / HTTP/1.1 +13:36:57.756979 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [.], ack 113, win 57, options [nop,nop,TS val 526052959 ecr 135708068], length 0 +13:36:57.760122 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [P.], seq 1:643, ack 113, win 57, options [nop,nop,TS val 526052959 ecr 135708068], length 642: HTTP: HTTP/1.1 302 Found +13:36:57.760182 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [.], ack 643, win 239, options [nop,nop,TS val 135708109 ecr 526052959], length 0 +13:36:57.977602 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [F.], seq 113, ack 643, win 239, options [nop,nop,TS val 135708327 ecr 526052959], length 0 +13:36:58.022089 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [F.], seq 643, ack 114, win 57, options [nop,nop,TS val 526053025 ecr 135708327], length 0 +13:36:58.022132 IP 192.168.122.98.39378 > 54.204.39.132.80: Flags [.], ack 644, win 239, options [nop,nop,TS val 135708371 ecr 526053025], length 0 +$ +``` + +这里不需要管理员权限 `sudo` 了,因为此刻并不是在网络接口处抓包。 + +你还可以使用我们讨论过的任何过滤规则来过滤文件中的内容,就像使用实时数据一样。 例如,通过执行以下命令从源 IP 地址`54.204.39.132` 检查文件中的数据包: + +``` +$ tcpdump -nn -r webserver.pcap src 54.204.39.132 +reading from file webserver.pcap, link-type LINUX_SLL (Linux cooked) +13:36:57.718932 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [S.], seq 1999298316, ack 3709732620, win 28960, options [mss 1460,sackOK,TS val 526052949 ecr 135708029,nop,wscale 9], length 0 +13:36:57.756979 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [.], ack 113, win 57, options [nop,nop,TS val 526052959 ecr 135708068], length 0 +13:36:57.760122 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [P.], seq 1:643, ack 113, win 57, options [nop,nop,TS val 526052959 ecr 135708068], length 642: HTTP: HTTP/1.1 302 Found +13:36:58.022089 IP 54.204.39.132.80 > 192.168.122.98.39378: Flags [F.], seq 643, ack 114, win 57, options [nop,nop,TS val 526053025 ecr 135708327], length 0 +``` + +### 下一步做什么? + +以上的基本功能已经可以帮助你使用强大的 tcpdump 抓包工具了。更多的内容请参考 [tcpdump网页][3] 以及它的 [帮助文件][4]。 + +Tcpdump 命令行工具为分析网络流量数据包提供了强大的灵活性。如果需要使用图形工具来抓包请参考 [Wireshark][5]。 + +Wireshark 还可以用来读取 tcpdump 保存的 `pcap` 文件。你可以使用 tcpdump 命令行在没有 GUI 界面的远程机器上抓包然后在 Wireshark 中分析数据包。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/introduction-tcpdump + +作者:[Ricardo Gerardi][a] +选题:[lujun9972][b] +译者:[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/rgerardi +[b]: https://github.com/lujun9972 +[1]: http://www.tcpdump.org/manpages/tcpdump.1.html#lbAG +[2]: https://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml +[3]: http://www.tcpdump.org/# +[4]: http://www.tcpdump.org/manpages/tcpdump.1.html +[5]: https://www.wireshark.org/ + From ca09c2f8bb083ad4c1299ff2d07cd4bcf1ed0dbe Mon Sep 17 00:00:00 2001 From: jrg Date: Sat, 20 Oct 2018 15:41:17 +0800 Subject: [PATCH 070/158] Delete 20181001 16 iptables tips and tricks for sysadmins.md --- ... iptables tips and tricks for sysadmins.md | 263 ------------------ 1 file changed, 263 deletions(-) delete mode 100644 sources/tech/20181001 16 iptables tips and tricks for sysadmins.md diff --git a/sources/tech/20181001 16 iptables tips and tricks for sysadmins.md b/sources/tech/20181001 16 iptables tips and tricks for sysadmins.md deleted file mode 100644 index a9b3e77c5a..0000000000 --- a/sources/tech/20181001 16 iptables tips and tricks for sysadmins.md +++ /dev/null @@ -1,263 +0,0 @@ -[translating by jrg, 20181014] - -16 iptables tips and tricks for sysadmins -====== -Iptables provides powerful capabilities to control traffic coming in and out of your system. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg) - -Modern Linux kernels come with a packet-filtering framework named [Netfilter][1]. Netfilter enables you to allow, drop, and modify traffic coming in and going out of a system. The **iptables** userspace command-line tool builds upon this functionality to provide a powerful firewall, which you can configure by adding rules to form a firewall policy. [iptables][2] can be very daunting with its rich set of capabilities and baroque command syntax. Let's explore some of them and develop a set of iptables tips and tricks for many situations a system administrator might encounter. - -### Avoid locking yourself out - -Scenario: You are going to make changes to the iptables policy rules on your company's primary server. You want to avoid locking yourself—and potentially everybody else—out. (This costs time and money and causes your phone to ring off the wall.) - -#### Tip #1: Take a backup of your iptables configuration before you start working on it. - -Back up your configuration with the command: - -``` -/sbin/iptables-save > /root/iptables-works - -``` -#### Tip #2: Even better, include a timestamp in the filename. - -Add the timestamp with the command: - -``` -/sbin/iptables-save > /root/iptables-works-`date +%F` - -``` - -You get a file with a name like: - -``` -/root/iptables-works-2018-09-11 - -``` - -If you do something that prevents your system from working, you can quickly restore it: - -``` -/sbin/iptables-restore < /root/iptables-works-2018-09-11 - -``` - -#### Tip #3: Every time you create a backup copy of the iptables policy, create a link to the file with 'latest' in the name. - -``` -ln –s /root/iptables-works-`date +%F` /root/iptables-works-latest - -``` - -#### Tip #4: Put specific rules at the top of the policy and generic rules at the bottom. - -Avoid generic rules like this at the top of the policy rules: - -``` -iptables -A INPUT -p tcp --dport 22 -j DROP - -``` - -The more criteria you specify in the rule, the less chance you will have of locking yourself out. Instead of the very generic rule above, use something like this: - -``` -iptables -A INPUT -p tcp --dport 22 –s 10.0.0.0/8 –d 192.168.100.101 -j DROP - -``` - -This rule appends ( **-A** ) to the **INPUT** chain a rule that will **DROP** any packets originating from the CIDR block **10.0.0.0/8** on TCP ( **-p tcp** ) port 22 ( **\--dport 22** ) destined for IP address 192.168.100.101 ( **-d 192.168.100.101** ). - -There are plenty of ways you can be more specific. For example, using **-i eth0** will limit the processing to a single NIC in your server. This way, the filtering actions will not apply the rule to **eth1**. - -#### Tip #5: Whitelist your IP address at the top of your policy rules. - -This is a very effective method of not locking yourself out. Everybody else, not so much. - -``` -iptables -I INPUT -s -j ACCEPT - -``` - -You need to put this as the first rule for it to work properly. Remember, **-I** inserts it as the first rule; **-A** appends it to the end of the list. - -#### Tip #6: Know and understand all the rules in your current policy. - -Not making a mistake in the first place is half the battle. If you understand the inner workings behind your iptables policy, it will make your life easier. Draw a flowchart if you must. Also remember: What the policy does and what it is supposed to do can be two different things. - -### Set up a workstation firewall policy - -Scenario: You want to set up a workstation with a restrictive firewall policy. - -#### Tip #1: Set the default policy as DROP. - -``` -# Set a default policy of DROP -*filter -:INPUT DROP [0:0] -:FORWARD DROP [0:0] -:OUTPUT DROP [0:0] -``` - -#### Tip #2: Allow users the minimum amount of services needed to get their work done. - -The iptables rules need to allow the workstation to get an IP address, netmask, and other important information via DHCP ( **-p udp --dport 67:68 --sport 67:68** ). For remote management, the rules need to allow inbound SSH ( **\--dport 22** ), outbound mail ( **\--dport 25** ), DNS ( **\--dport 53** ), outbound ping ( **-p icmp** ), Network Time Protocol ( **\--dport 123 --sport 123** ), and outbound HTTP ( **\--dport 80** ) and HTTPS ( **\--dport 443** ). - -``` -# Set a default policy of DROP -*filter -:INPUT DROP [0:0] -:FORWARD DROP [0:0] -:OUTPUT DROP [0:0] - -# Accept any related or established connections --I INPUT  1 -m state --state RELATED,ESTABLISHED -j ACCEPT --I OUTPUT 1 -m state --state RELATED,ESTABLISHED -j ACCEPT - -# Allow all traffic on the loopback interface --A INPUT -i lo -j ACCEPT --A OUTPUT -o lo -j ACCEPT - -# Allow outbound DHCP request --A OUTPUT –o eth0 -p udp --dport 67:68 --sport 67:68 -j ACCEPT - -# Allow inbound SSH --A INPUT -i eth0 -p tcp -m tcp --dport 22 -m state --state NEW  -j ACCEPT - -# Allow outbound email --A OUTPUT -i eth0 -p tcp -m tcp --dport 25 -m state --state NEW  -j ACCEPT - -# Outbound DNS lookups --A OUTPUT -o eth0 -p udp -m udp --dport 53 -j ACCEPT - -# Outbound PING requests --A OUTPUT –o eth0 -p icmp -j ACCEPT - -# Outbound Network Time Protocol (NTP) requests --A OUTPUT –o eth0 -p udp --dport 123 --sport 123 -j ACCEPT - -# Outbound HTTP --A OUTPUT -o eth0 -p tcp -m tcp --dport 80 -m state --state NEW -j ACCEPT --A OUTPUT -o eth0 -p tcp -m tcp --dport 443 -m state --state NEW -j ACCEPT - -COMMIT -``` - -### Restrict an IP address range - -Scenario: The CEO of your company thinks the employees are spending too much time on Facebook and not getting any work done. The CEO tells the CIO to do something about the employees wasting time on Facebook. The CIO tells the CISO to do something about employees wasting time on Facebook. Eventually, you are told the employees are wasting too much time on Facebook, and you have to do something about it. You decide to block all access to Facebook. First, find out Facebook's IP address by using the **host** and **whois** commands. - -``` -host -t a www.facebook.com -www.facebook.com is an alias for star.c10r.facebook.com. -star.c10r.facebook.com has address 31.13.65.17 -whois 31.13.65.17 | grep inetnum -inetnum:        31.13.64.0 - 31.13.127.255 -``` - -Then convert that range to CIDR notation by using the [CIDR to IPv4 Conversion][3] page. You get **31.13.64.0/18**. To prevent outgoing access to [www.facebook.com][4], enter: - -``` -iptables -A OUTPUT -p tcp -i eth0 –o eth1 –d 31.13.64.0/18 -j DROP -``` - -### Regulate by time - -Scenario: The backlash from the company's employees over denying access to Facebook access causes the CEO to relent a little (that and his administrative assistant's reminding him that she keeps HIS Facebook page up-to-date). The CEO decides to allow access to Facebook.com only at lunchtime (12PM to 1PM). Assuming the default policy is DROP, use iptables' time features to open up access. - -``` -iptables –A OUTPUT -p tcp -m multiport --dport http,https -i eth0 -o eth1 -m time --timestart 12:00 --timestart 12:00 –timestop 13:00 –d -31.13.64.0/18  -j ACCEPT -``` - -This command sets the policy to allow ( **-j ACCEPT** ) http and https ( **-m multiport --dport http,https** ) between noon ( **\--timestart 12:00** ) and 13PM ( **\--timestop 13:00** ) to Facebook.com ( **–d[31.13.64.0/18][5]** ). - -### Regulate by time—Take 2 - -Scenario: During planned downtime for system maintenance, you need to deny all TCP and UDP traffic between the hours of 2AM and 3AM so maintenance tasks won't be disrupted by incoming traffic. This will take two iptables rules: - -``` -iptables -A INPUT -p tcp -m time --timestart 02:00 --timestop 03:00 -j DROP -iptables -A INPUT -p udp -m time --timestart 02:00 --timestop 03:00 -j DROP -``` - -With these rules, TCP and UDP traffic ( **-p tcp and -p udp** ) are denied ( **-j DROP** ) between the hours of 2AM ( **\--timestart 02:00** ) and 3AM ( **\--timestop 03:00** ) on input ( **-A INPUT** ). - -### Limit connections with iptables - -Scenario: Your internet-connected web servers are under attack by bad actors from around the world attempting to DoS (Denial of Service) them. To mitigate these attacks, you restrict the number of connections a single IP address can have to your web server: - -``` -iptables –A INPUT –p tcp –syn -m multiport -–dport http,https –m connlimit -–connlimit-above 20 –j REJECT -–reject-with-tcp-reset -``` - -Let's look at what this rule does. If a host makes more than 20 ( **-–connlimit-above 20** ) new connections ( **–p tcp –syn** ) in a minute to the web servers ( **-–dport http,https** ), reject the new connection ( **–j REJECT** ) and tell the connecting host you are rejecting the connection ( **-–reject-with-tcp-reset** ). - -### Monitor iptables rules - -Scenario: Since iptables operates on a "first match wins" basis as packets traverse the rules in a chain, frequently matched rules should be near the top of the policy and less frequently matched rules should be near the bottom. How do you know which rules are traversed the most or the least so they can be ordered nearer the top or the bottom? - -#### Tip #1: See how many times each rule has been hit. - -Use this command: - -``` -iptables -L -v -n –line-numbers -``` - -The command will list all the rules in the chain ( **-L** ). Since no chain was specified, all the chains will be listed with verbose output ( **-v** ) showing packet and byte counters in numeric format ( **-n** ) with line numbers at the beginning of each rule corresponding to that rule's position in the chain. - -Using the packet and bytes counts, you can order the most frequently traversed rules to the top and the least frequently traversed rules towards the bottom. - -#### Tip #2: Remove unnecessary rules. - -Which rules aren't getting any matches at all? These would be good candidates for removal from the policy. You can find that out with this command: - -``` -iptables -nvL | grep -v "0     0" -``` - -Note: that's not a tab between the zeros; there are five spaces between the zeros. - -#### Tip #3: Monitor what's going on. - -You would like to monitor what's going on with iptables in real time, like with **top**. Use this command to monitor the activity of iptables activity dynamically and show only the rules that are actively being traversed: - -``` -watch --interval=5 'iptables -nvL | grep -v "0     0"' -``` - -**watch** runs **'iptables -nvL | grep -v "0 0"'** every five seconds and displays the first screen of its output. This allows you to watch the packet and byte counts change over time. - -### Report on iptables - -Scenario: Your manager thinks this iptables firewall stuff is just great, but a daily activity report would be even better. Sometimes it's more important to write a report than to do the work. - -Use the packet filter/firewall/IDS log analyzer [FWLogwatch][6] to create reports based on the iptables firewall logs. FWLogwatch supports many log formats and offers many analysis options. It generates daily and monthly summaries of the log files, allowing the security administrator to free up substantial time, maintain better control over network security, and reduce unnoticed attacks. - -Here is sample output from FWLogwatch: - -![](https://opensource.com/sites/default/files/uploads/fwlogwatch.png) - -### More than just ACCEPT and DROP - -We've covered many facets of iptables, all the way from making sure you don't lock yourself out when working with iptables to monitoring iptables to visualizing the activity of an iptables firewall. These will get you started down the path to realizing even more iptables tips and tricks. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/10/iptables-tips-and-tricks - -作者:[Gary Smith][a] -选题:[lujun9972](https://github.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/greptile -[1]: https://en.wikipedia.org/wiki/Netfilter -[2]: https://en.wikipedia.org/wiki/Iptables -[3]: http://www.ipaddressguide.com/cidr -[4]: http://www.facebook.com -[5]: http://31.13.64.0/18 -[6]: http://fwlogwatch.inside-security.de/ From 996be939ba97ac2dca4c3194b15aa47138cb147a Mon Sep 17 00:00:00 2001 From: jrg Date: Sat, 20 Oct 2018 15:42:17 +0800 Subject: [PATCH 071/158] Create 20181001 16 iptables tips and tricks for sysadmins.md --- ... iptables tips and tricks for sysadmins.md | 262 ++++++++++++++++++ 1 file changed, 262 insertions(+) create mode 100644 translated/tech/20181001 16 iptables tips and tricks for sysadmins.md diff --git a/translated/tech/20181001 16 iptables tips and tricks for sysadmins.md b/translated/tech/20181001 16 iptables tips and tricks for sysadmins.md new file mode 100644 index 0000000000..8f75023a9d --- /dev/null +++ b/translated/tech/20181001 16 iptables tips and tricks for sysadmins.md @@ -0,0 +1,262 @@ +系统管理员需知的 16 个 iptables 使用技巧 +======= + +iptables 是一款控制系统进出流量的强大配置工具。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg) + +现代 Linux 内核带有一个叫 [Netfilter][1] 的数据包过滤框架。Netfilter 提供了允许、禁止以及修改等操作来控制进出系统的流量数据包。基于 Netfilter 框架的用户层命令行工具 **iptables** 提供了强大的防火墙配置功能,允许你添加规则来构建防火墙策略。[iptables][2] 丰富复杂的功能以及其巴洛克式命令语法可能让人难以驾驭。我们就来探讨一下其中的一些功能,提供一些系统管理员解决某些问题需要的使用技巧。 + +### 避免封锁自己 + +应用场景:假设你将对公司服务器上的防火墙规则进行修改,需要避免封锁你自己以及其他同事的情况(这将会带来一定时间和金钱的损失,也许一旦发生马上就有部门打电话找你了) + +#### 技巧 #1: 开始之前先备份一下 iptables 配置文件。 + +用如下命令备份配置文件: + +``` +/sbin/iptables-save > /root/iptables-works + +``` +#### 技巧 #2: 更妥当的做法,给文件加上时间戳。 + +用如下命令加时间戳: + +``` +/sbin/iptables-save > /root/iptables-works-`date +%F` + +``` + +然后你就可以生成如下名字的文件: + +``` +/root/iptables-works-2018-09-11 + +``` + +这样万一使得系统不工作了,你也可以很快的利用备份文件恢复原状: + +``` +/sbin/iptables-restore < /root/iptables-works-2018-09-11 + +``` + +#### 技巧 #3: 每次创建 iptables 配置文件副本时,都创建一个指向 `latest` 的文件的链接。 + +``` +ln –s /root/iptables-works-`date +%F` /root/iptables-works-latest + +``` + +#### 技巧 #4: 将特定规则放在策略顶部,底部放置通用规则。 + +避免在策略顶部使用如下的一些通用规则: + +``` +iptables -A INPUT -p tcp --dport 22 -j DROP + +``` + +你在规则中指定的条件越多,封锁自己的可能性就越小。不要使用上面暗中通用规则,而是使用如下的规则: + +``` +iptables -A INPUT -p tcp --dport 22 –s 10.0.0.0/8 –d 192.168.100.101 -j DROP + +``` + +此规则表示在 **INPUT** 链尾追加一条新规则,将源地址为 **10.0.0.0/8**、 目的地址是 **192.168.100.101**、目的端口号是 **22** (**\--dport 22** ) 的 **tcp**(**-p tcp** )数据包通通丢弃掉。 + +还有很多方法可以设置更具体的规则。例如,使用 **-i eth0** 将会限制这条规则作用于 **eth0** 网卡,对 **eth1** 网卡则不生效。 + +#### 技巧 #5: 在策略规则顶部将你的 IP 列入白名单。 + +这是一个有效地避免封锁自己的设置: + +``` +iptables -I INPUT -s -j ACCEPT + +``` + +你需要将该规则添加到策略首位置。**-I** 表示则策略首部插入规则,**-A** 表示在策略尾部追加规则。 + +#### 技巧 #6: 理解现有策略中的所有规则。 + +不犯错就已经成功了一半。如果你了解 iptables 策略背后的工作原理,使用起来更为得心应手。如果有必要,可以绘制流程图来理清数据包的走向。还要记住:策略的预期效果和实际效果可能完全是两回事。 + +### 设置防火墙策略 + +应用场景:你希望给工作站配置具有限制性策略的防火墙。 + +#### 技巧 #1: 设置默认规则为丢弃 + +``` +# Set a default policy of DROP +*filter +:INPUT DROP [0:0] +:FORWARD DROP [0:0] +:OUTPUT DROP [0:0] +``` + +#### 技巧 #2: 将用户完成工作所需的最少量服务设置为允许 + +该策略需要允许工作站能通过 DHCP (**-p udp --dport 67:68 -sport 67:68**)来获取 IP 地址、子网掩码以及其他一些信息。对于远程操作,需要允许 SSH 服务(**-dport 22**),邮件服务(**--dport 25**),DNS服务(**--dport 53**),ping 功能(**-p icmp**),NTP 服务(**--dport 123 --sport 123**)以及HTTP 服务(**-dport 80**)和 HTTPS 服务(**--dport 443**)。 + +``` +# Set a default policy of DROP +*filter +:INPUT DROP [0:0] +:FORWARD DROP [0:0] +:OUTPUT DROP [0:0] + +# Accept any related or established connections +-I INPUT  1 -m state --state RELATED,ESTABLISHED -j ACCEPT +-I OUTPUT 1 -m state --state RELATED,ESTABLISHED -j ACCEPT + +# Allow all traffic on the loopback interface +-A INPUT -i lo -j ACCEPT +-A OUTPUT -o lo -j ACCEPT + +# Allow outbound DHCP request +-A OUTPUT –o eth0 -p udp --dport 67:68 --sport 67:68 -j ACCEPT + +# Allow inbound SSH +-A INPUT -i eth0 -p tcp -m tcp --dport 22 -m state --state NEW  -j ACCEPT + +# Allow outbound email +-A OUTPUT -i eth0 -p tcp -m tcp --dport 25 -m state --state NEW  -j ACCEPT + +# Outbound DNS lookups +-A OUTPUT -o eth0 -p udp -m udp --dport 53 -j ACCEPT + +# Outbound PING requests +-A OUTPUT –o eth0 -p icmp -j ACCEPT + +# Outbound Network Time Protocol (NTP) requests +-A OUTPUT –o eth0 -p udp --dport 123 --sport 123 -j ACCEPT + +# Outbound HTTP +-A OUTPUT -o eth0 -p tcp -m tcp --dport 80 -m state --state NEW -j ACCEPT +-A OUTPUT -o eth0 -p tcp -m tcp --dport 443 -m state --state NEW -j ACCEPT + +COMMIT +``` + +### 限制 IP 地址范围 + +应用场景:贵公司的 CEO 认为员工在 Facebook 上花费过多的时间,需要采取一些限制措施。CEO 命令下达给 CIO,CIO 命令CISO,最终任务由你来执行。你决定阻止一切到 Facebook 的访问连接。首先你使用 `host` 或者 `whois` 命令来获取 Facebook 的 IP 地址。 + +``` +host -t a www.facebook.com +www.facebook.com is an alias for star.c10r.facebook.com. +star.c10r.facebook.com has address 31.13.65.17 +whois 31.13.65.17 | grep inetnum +inetnum:        31.13.64.0 - 31.13.127.255 +``` +然后使用 [CIDR to IPv4转换][3] 页面来将其转换为 CIDR 表示法。然后你得到 **31.13.64.0/18** 的地址。输入以下命令来阻止对 Facebook 的访问: + +``` +iptables -A OUTPUT -p tcp -i eth0 –o eth1 –d 31.13.64.0/18 -j DROP +``` + +### 按时间规定做限制-场景1 + +应用场景:公司员工强烈反对限制一切对 Facebook 的访问,这导致了 CEO 放宽了要求(考虑到员工的反对以及他的助理提醒说她将 HIS Facebook 页面保持在最新状态)。然后 CEO 决定允许在午餐时间访问 Facebook(中午12点到下午1点之间)。假设默认规则是丢弃,使用 iptables 的时间功能便可以实现。 + +``` +iptables –A OUTPUT -p tcp -m multiport --dport http,https -i eth0 -o eth1 -m time --timestart 12:00 –timestop 13:00 –d 31.13.64.0/18 -j ACCEPT +``` + +该命令中指定在中午12点(**\--timestart 12:00**)到下午1点(**\--timestop 13:00**)之间允许(**-j ACCEPT**)到 Facebook.com (**-d [31.13.64.0/18][5]**)的 http 以及 https (**-m multiport --dport http,https**)的访问。 + +### 按时间规定做限制-场景2 + +应用场景 +Scenario: 在计划系统维护期间,你需要设置凌晨2点到3点之间拒绝所有的 TCP 和 UDP 访问,这样维护任务就不会受到干扰。使用两个 iptables 规则可实现: + +``` +iptables -A INPUT -p tcp -m time --timestart 02:00 --timestop 03:00 -j DROP +iptables -A INPUT -p udp -m time --timestart 02:00 --timestop 03:00 -j DROP +``` + +该规则禁止(**-j DROP**)在凌晨2点(**\--timestart 02:00**)到凌晨3点(**\--timestop 03:00**)之间的 TCP 和 UDP (**-p tcp and -p udp**)的数据进入(**-A INPUT**)访问。 + +### 限制连接数量 + +应用场景:你的 web 服务器有可能受到来自世界各地的 DoS 攻击,为了避免这些攻击,你可以限制单个 IP 地址到你的 web 服务器创建连接的数量: + +``` +iptables –A INPUT –p tcp –syn -m multiport -–dport http,https –m connlimit -–connlimit-above 20 –j REJECT -–reject-with-tcp-reset +``` + +分析一下上面的命令。如果单个主机在一分钟之内新建立(**-p tcp -syn**)超过20个(**-connlimit-above 20**)到你的 web 服务器(**--dport http,https**)的连接,服务器将拒绝(**-j REJECT**)建立新的连接,然后通知该主机新建连接被拒绝(**--reject-with-tcp-reset**)。 + +### 监控 iptables 规则 + +应用场景:由于数据包会遍历链中的规则,iptables遵循 ”首次匹配获胜“ 的原则,因此经常匹配的规则应该靠近策略的顶部,而不太频繁匹配的规则应该接近底部。 你怎么知道哪些规则使用最多或最少,可以在顶部或底部附近监控? + +#### 技巧 #1: 查看规则被访问了多少次 + +使用命令: + +``` +iptables -L -v -n –line-numbers +``` + +用 **-L** 选项列出链中的所有规则。因为没有指定具体哪条链,所有链规则都会被输出,使用 **-v** 选项显示详细信息,**-n** 选项则显示数字格式的数据包和字节计数器,每个规则开头的数值表示该规则在链中的位置。 + +根据数据包和字节计数的结果,你可以将访问频率最高的规则放到顶部,将访问频率最低的规则放到底部。 + +#### 技巧 #2: 删除不必要的规则 + +哪条规则从来没有被访问过?这些可以被清除掉。用如下命令查看: + +``` +iptables -nvL | grep -v "0     0" +``` + +注意:两个数字0之间不是 Tab 键,而是 5 个空格。 + +#### 技巧 #3: 监控正在发生什么 + +可能你也想像使用 **top** 命令一样来实时监控 iptables 的情况。使用如下命令来动态监视 iptables 中的活动,并仅显示正在遍历的规则: + +``` +watch --interval=5 'iptables -nvL | grep -v "0     0"' +``` + +**watch** 命令通过参数 **iptables -nvL | grep -v “0 0“** 每隔 5s 输出 iptables 的动态。这条命令允许你查看数据包和字节计数的变化。 + +### 输出日志 + +应用场景:经理觉得你这个防火墙员工的工作质量杠杠的,但如果能有网络流量活动日志最好了。有时候这比写一份有关工作的报告更有效。 + +使用工具 [FWLogwatch][6] 基于 iptables 防火墙记录来生成日志报告。FWLogwatch 工具支持很多形式的报告并且也提供了很多分析功能。它生成的日志以及月报告使得管理员可以节省大量时间并且还更好地管理网络,甚至减少未被注意的潜在攻击。 + +这里是一个 FWLogwatch 生成的报告示例: + +![](https://opensource.com/sites/default/files/uploads/fwlogwatch.png) + +### 不要满足于允许和丢弃规则 + +本文中已经涵盖了 iptables 的很多方面,从避免封锁自己、iptables 配置防火墙以及监控 iptables 中的活动等等方面介绍了 iptables。你可以从这里开始探索 iptables 甚至获取更多的使用技巧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/iptables-tips-and-tricks + +作者:[Gary Smith][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[jrg](https://github.com/jrglinu) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/greptile +[1]: https://en.wikipedia.org/wiki/Netfilter +[2]: https://en.wikipedia.org/wiki/Iptables +[3]: http://www.ipaddressguide.com/cidr +[4]: http://www.facebook.com +[5]: http://31.13.64.0/18 +[6]: http://fwlogwatch.inside-security.de/ + From 89ca7d3229530984dad3f6749eee089183c8d84d Mon Sep 17 00:00:00 2001 From: ypingcn <1344632698@qq.com> Date: Sat, 20 Oct 2018 20:10:12 +0800 Subject: [PATCH 072/158] Create 20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md --- ...Web is Creating a New Decentralized Web.md | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 translated/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md diff --git a/translated/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md b/translated/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md new file mode 100644 index 0000000000..e55455508d --- /dev/null +++ b/translated/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md @@ -0,0 +1,45 @@ +万维网的创建者正在创建一个新的分布式网络 +====== + +**万维网的创建者 Tim Berners-Lee 公布了他计划创建一个新的分布式网络,网络中的数据将由用户控制** + +[Tim Berners-Lee] [1]以创建万维网而闻名,万维网就是你现在所知的互联网。二十多年之后,Tim 致力于将互联网从企业巨头的掌控中解放出来,并通过分布式网络将权力交回给人们。 + +Berners-Lee 对互联网“强权”们处理用户数据的方式感到不满。所以他[开始致力于他自己的开源项目][2] Solid “来将在网络上的权力归还给人们” + +> Solid 改变了当前用户必须将个人数据交给数字巨头以换取可感知价值的模型。正如我们都已发现的那样,这不符合我们的最佳利益。Solid 是我们如何驱动网络进化以恢复平衡——以一种革命性的方式,让我们每个人完全地控制数据,无论数据是否是个人数据。 + +![Tim Berners-Lee is creating a decentralized web with open source project Solid][3] + +基本上,[Solid][4]是一个使用现有网络构建的平台,在这里你可以创建自己的 “pods” (个人数据存储)。你决定这个 “pods” 将被托管在哪里,谁将访问哪些数据元素以及数据将如何通过这个 pod 分享。 + +Berners-Lee 相信 Solid "将以一种全新的方式,授权个人、开发者和企业来构思、构建和寻找创新、可信和有益的应用和服务。" + +开发人员需要将 Solid 集成进他们的应用程序和网站中。 Solid 仍在早期阶段,所以目前没有相关的应用程序。但是项目网站宣称“第一批 Solid 应用程序正在开发当中”。 + +Berners-Lee 已经创立一家名为[Inrupt][5] 的初创公司,并已从麻省理工学院休假来全职工作在 Solid,来将其”从少部分人的愿景带到多数人的现实“。 + +如果你对 Solid 感兴趣,[学习如何开发应用程序][6]或者以自己的方式[给项目做贡献][7]。当然,建立和推动 Solid 的广泛采用将需要大量的努力,所以每一点的贡献都将有助于分布式网络的成功。 + +你认为[分布式网络][8]会成为现实吗?你是如何看待分布式网络,特别是 Solid 项目的? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/solid-decentralized-web/ + +作者:[Abhishek Prakash][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]: https://itsfoss.com/author/abhishek/ +[1]: https://en.wikipedia.org/wiki/Tim_Berners-Lee +[2]: https://medium.com/@timberners_lee/one-small-step-for-the-web-87f92217d085 +[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/tim-berners-lee-solid-project.jpeg +[4]: https://solid.inrupt.com/ +[5]: https://www.inrupt.com/ +[6]: https://solid.inrupt.com/docs/getting-started +[7]: https://solid.inrupt.com/community +[8]: https://tech.co/decentralized-internet-guide-2018-02 From 840c2b3a185d626cb251f230a3673b262b577b0b Mon Sep 17 00:00:00 2001 From: ypingcn <1344632698@qq.com> Date: Sat, 20 Oct 2018 20:11:06 +0800 Subject: [PATCH 073/158] Delete 20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md --- ...Web is Creating a New Decentralized Web.md | 46 ------------------- 1 file changed, 46 deletions(-) delete mode 100644 sources/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md diff --git a/sources/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md b/sources/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md deleted file mode 100644 index fb2916e06c..0000000000 --- a/sources/talk/20180930 Creator of the World Wide Web is Creating a New Decentralized Web.md +++ /dev/null @@ -1,46 +0,0 @@ -translating by ypingcn - -Creator of the World Wide Web is Creating a New Decentralized Web -====== -**Creator of the world wide web, Tim Berners-Lee has unveiled his plans to create a new decentralized web where the data will be controlled by the users.** - -[Tim Berners-Lee][1] is known for creating the world wide web, i.e., the internet you know today. More than two decades later, Tim is working to free the internet from the clutches of corporate giants and give the power back to the people via a decentralized web. - -Berners-Lee was unhappy with the way ‘powerful forces’ of the internet handle data of the users for their own agenda. So he [started working on his own open source project][2] Solid “to restore the power and agency of individuals on the web.” - -> Solid changes the current model where users have to hand over personal data to digital giants in exchange for perceived value. As we’ve all discovered, this hasn’t been in our best interests. Solid is how we evolve the web in order to restore balance — by giving every one of us complete control over data, personal or not, in a revolutionary way. - -![Tim Berners-Lee is creating a decentralized web with open source project Solid][3] - -Basically, [Solid][4] is a platform built using the existing web where you create own ‘pods’ (personal data store). You decide where this pod will be hosted, who will access which data element and how the data will be shared through this pod. - -Berners-Lee believes that Solid “will empower individuals, developers and businesses with entirely new ways to conceive, build and find innovative, trusted and beneficial applications and services.” - -Developers need to integrate Solid into their apps and sites. Solid is still in the early stages so there are no apps for now but the project website claims that “the first wave of Solid apps are being created now.” - -Berners-Lee has created a startup called [Inrupt][5] and has taken a sabbatical from MIT to work full-time on Solid and to take it “from the vision of a few to the reality of many.” - -If you are interested in Solid, [learn how to create apps][6] or [contribute to the project][7] in your own way. Of course, it will take a lot of effort to build and drive the broad adoption of Solid so every bit of contribution will count to the success of a decentralized web. - -Do you think a [decentralized web][8] will be a reality? What do you think of decentralized web in general and project Solid in particular? - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/solid-decentralized-web/ - -作者:[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://en.wikipedia.org/wiki/Tim_Berners-Lee -[2]: https://medium.com/@timberners_lee/one-small-step-for-the-web-87f92217d085 -[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/tim-berners-lee-solid-project.jpeg -[4]: https://solid.inrupt.com/ -[5]: https://www.inrupt.com/ -[6]: https://solid.inrupt.com/docs/getting-started -[7]: https://solid.inrupt.com/community -[8]: https://tech.co/decentralized-internet-guide-2018-02 From f50aadb2d4703bc9018445cfe7e527afbc53bd03 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 21 Oct 2018 00:05:29 +0800 Subject: [PATCH 074/158] PRF:20181012 Command line quick tips- Reading files different ways.md @distant1219 --- ...uick tips- Reading files different ways.md | 103 ++++++++---------- 1 file changed, 45 insertions(+), 58 deletions(-) diff --git a/translated/tech/20181012 Command line quick tips- Reading files different ways.md b/translated/tech/20181012 Command line quick tips- Reading files different ways.md index cbd0115294..23735d5b42 100644 --- a/translated/tech/20181012 Command line quick tips- Reading files different ways.md +++ b/translated/tech/20181012 Command line quick tips- Reading files different ways.md @@ -1,105 +1,92 @@ -命令行快速提示: 读取文件的不同方式 +命令行小技巧:读取文件的不同方式 ====== ![](https://fedoramagazine.org/wp-content/uploads/2018/10/commandlinequicktips-816x345.jpg) -作为图形操作系统,Fedora 的使用是令人愉快的。你可以轻松地点按,完成任何任务。 但你可能已经看到了,在引擎盖下还有一个强大的命令行。 想要在 shell 下使用,只需要在 Fedora 系统中打开你的命令行应用程序。 这篇文章是向你展示命令行使用方法的系列之一。 +作为图形操作系统,Fedora 的使用是令人愉快的。你可以轻松地点击完成任何任务。但你可能已经看到了,在底层还有一个强大的命令行。想要在 shell 下体验,只需要在 Fedora 系统中打开你的终端应用。这篇文章是向你展示常见的命令行使用方法的系列文章之一。 -在这部分,你将学习如何以不同的方式读取文件,如果你在系统中打开一个命令行,你就有可能需要读取一个或两个文件。 +在这部分,你将学习如何以不同的方式读取文件,如果你在系统中打开一个终端完成一些工作,你就有可能需要读取一两个文件。 ### 一应俱全的大餐 -对命令行终端的用户来说, **cat** 命令众所周知。 当你 **cat** 一个文件,你很容易的把整个文件内容展示在你的屏幕上。而真正发生在引擎盖下的是文件一次读取一行, 然后一行一行写入屏幕。 +对命令行终端的用户来说, `cat` 命令众所周知。 当你 `cat` 一个文件,你很容易的把整个文件内容展示在你的屏幕上。而真正发生在底层的是文件一次读取一行,然后一行一行写入屏幕。 -假设你有一个文件,叫做 myfile, 这个文件每行只有一个单词。为了简单起见,每行的单词就是这行的行号,就像这样: +假设你有一个文件,叫做 `myfile`, 这个文件每行只有一个单词。为了简单起见,每行的单词就是这行的行号,就像这样: ``` - - one - two - three - four - five - +one +two +three +four +five ``` -所以如果你 **cat** 这个文件,你就会看到如下输出: +所以如果你 `cat` 这个文件,你就会看到如下输出: ``` - - $ cat myfile - one - two - three - four - five - +$ cat myfile +one +two +three +four +five ``` -并没有太惊喜,不是吗? 但是有个有趣的转折,只要使用 **tac** 命令,你可以从后往前 **cat** 这个文件。(请注意, Fedora 对这种有争议的幽默不承担任何责任!) -``` - - $ tac myfile - five - four - three - two - one +并没有太惊喜,不是吗? 但是有个有趣的转折,只要使用 `tac` 命令,你可以从后往前 `cat` 这个文件。(请注意, Fedora 对这种有争议的幽默不承担任何责任!) ``` - -**cat** 命令允许你以不同的方式装饰输出,比如,你可以输出行号: - +$ tac myfile +five +four +three +two +one ``` - $ cat -n myfile +`cat` 命令允许你以不同的方式装饰输出,比如,你可以输出行号: + +``` +$ cat -n myfile 1 one 2 two 3 three 4 four 5 five - ``` -还有其他选项将显示特殊字符和其他功能。 要了解更多, 请运行 **man cat** 命令, 看完之后, 按 **q** 即可退出回到 shell。 +还有其他选项可以显示特殊字符和其他功能。要了解更多, 请运行 `man cat` 命令, 看完之后,按 `q` 即可退出回到 shell。 ### 挑选你的食物 -通常, 文件太长, 无法全部显示在屏幕上, 您可能希望能够像文档一样查看它。 这种情况下,可以试试 **less** 命令: +通常,文件太长会无法全部显示在屏幕上,您可能希望能够像文档一样查看它。 这种情况下,可以试试 `less` 命令: ``` - - $ less myfile - +$ less myfile ``` -你可以用方向键,也可以用 **PgUp/PgDn** 来查看文件, 按 **q** 就可以退回到 shell。 +你可以用方向键,也可以用 `PgUp`/`PgDn` 来查看文件, 按 `q` 就可以退回到 shell。 -实际上,还有一个 **more** 命令,它是基于在旧的 UNIX 系统命令的。如果在退回 shell 后仍想看到该文件, 则可能需要使用它。**less** 命令使你回到你离开 shell 之前的样子,并且清除屏幕上你看到的所有的文件内容。 +实际上,还有一个 `more` 命令,其基于老式的 UNIX 系统命令。如果在退回 shell 后仍想看到该文件的内容,则可能需要使用它。而 `less` 命令则让你回到你离开 shell 之前的样子,并且清除屏幕上你看到的所有的文件内容。 ### 一点披萨或甜点 -有时, 你所需的输出只是文件的开头。 比如,有一个非常长的文件,当你使用 **cat** 命令时,会显示这个文件所有内容,前几行的内容很容易滚动过去,导致你看不到。**head** 命令会帮你获取文件的前几行: +有时,你所需的输出只是文件的开头。 比如,有一个非常长的文件,当你使用 `cat` 命令时,会显示这个文件所有内容,前几行的内容很容易滚动过去,导致你看不到。`head` 命令会帮你获取文件的前几行: ``` - - $ head -n 2 myfile - one - two +$ head -n 2 myfile +one +two +``` +同样,你会用 `tail` 命令来查看文件的末尾几行: ``` -同样,你会用 **tail** 命令来查看文件的末尾几行: - +$ tail -n 3 myfile +three +four +five ``` - $ tail -n 3 myfile - three - four - five - -``` - -当然, 这些只是在这个领域的几个简单的命令。但当涉及到阅读文件时,你就能容易地开始。 +当然,这些只是在这个领域的几个简单的命令。但它们可以让你在阅读文件时容易入手。 -------------------------------------------------------------------------------- @@ -108,7 +95,7 @@ via: https://fedoramagazine.org/commandline-quick-tips-reading-files-different-w 作者:[Paul W. Frields][a] 选题:[lujun9972][b] 译者:[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 84dacce921cd39e2fac578a24ffbda9a3f4dcd79 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 21 Oct 2018 00:05:57 +0800 Subject: [PATCH 075/158] PUB: 20181012 Command line quick tips- Reading files different ways.md @distant1219 https://linux.cn/article-10136-1.html --- ...81012 Command line quick tips- Reading files different ways.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20181012 Command line quick tips- Reading files different ways.md (100%) diff --git a/translated/tech/20181012 Command line quick tips- Reading files different ways.md b/published/20181012 Command line quick tips- Reading files different ways.md similarity index 100% rename from translated/tech/20181012 Command line quick tips- Reading files different ways.md rename to published/20181012 Command line quick tips- Reading files different ways.md From a326ae7101057d0ce4e7ff06d6e9d7f7de11bc60 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 21 Oct 2018 00:23:00 +0800 Subject: [PATCH 076/158] PRF:20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md @HankChow --- ...Distro With Another in Dual Boot -Guide.md | 48 +++++++++++-------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/translated/tech/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md b/translated/tech/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md index b5e2f97c0b..2992905b9f 100644 --- a/translated/tech/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md +++ b/translated/tech/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md @@ -1,6 +1,7 @@ 如何在双系统引导下替换 Linux 发行版 ====== -在双系统引导的状态下,你可以将已安装的 Linux 发行版替换为另一个发行版,同时还可以保留原本的个人数据。 + +> 在双系统引导的状态下,你可以将已安装的 Linux 发行版替换为另一个发行版,同时还可以保留原本的个人数据。 ![How to Replace One Linux Distribution With Another From Dual Boot][1] @@ -26,11 +27,9 @@ * 需要安装的 Linux 发行版的 USB live 版 * 在外部磁盘备份 Windows 和 Linux 中的重要文件(并非必要,但建议备份一下) - - #### 在替换 Linux 发行版时要记住保留你的 home 目录 -如果想让个人文件在安装新 Linux 系统的过程中不受影响,原有的 Linux 系统必须具有单独的 root 目录和 home 目录。你可能会发现我的[双系统引导教程][8]在安装过程中不选择“与 Windows 一起安装”选项,而选择“其它”选项,然后手动创建 root 和 home 分区。所以,手动创建单独的 home 分区也算是一个磨刀不误砍柴工的操作。因为如果要在不丢失文件的情况下,将现有的 Linux 发行版替换为另一个发行版,需要将 home 目录存放在一个单独的分区上。 +如果想让个人文件在安装新 Linux 系统的过程中不受影响,原有的 Linux 系统必须具有单独的 root 目录和 home 目录。你可能会发现我的[双系统引导教程][8]在安装过程中不选择“与 Windows 共存”选项,而选择“其它”选项,然后手动创建 root 和 home 分区。所以,手动创建单独的 home 分区也算是一个磨刀不误砍柴工的操作。因为如果要在不丢失文件的情况下,将现有的 Linux 发行版替换为另一个发行版,需要将 home 目录存放在一个单独的分区上。 不过,你必须记住现有 Linux 系统的用户名和密码才能使用与新系统中相同的 home 目录。 @@ -51,69 +50,80 @@ 在安装过程中,进入“安装类型”界面时,选择“其它”选项。 ![Replacing one Linux with another from dual boot][10] -(在这里选择“其它”选项) + +*在这里选择“其它”选项* #### 步骤 3:准备分区操作 下图是分区界面。你会看到使用 Ext4 文件系统类型来安装 Linux。 ![Identifying Linux partition in dual boot][11] -(确定 Linux 的安装位置) + +*确定 Linux 的安装位置* 在上图中,标记为 Linux Mint 19 的 Ext4 分区是 root 分区,大小为 82691 MB 的第二个 Ext4 分区是 home 分区。在这里我这里没有使用[交换空间][12]。 如果你只有一个 Ext4 分区,就意味着你的 home 目录与 root 目录位于同一分区。在这种情况下,你就无法保留 home 目录中的文件了,这个时候我建议将重要文件复制到外部磁盘,否则这些文件将不会保留。 -然后是删除 root 分区。选择 root 分区,然后点击 - 号,这个操作释放了一些磁盘空间。 +然后是删除 root 分区。选择 root 分区,然后点击 `-` 号,这个操作释放了一些磁盘空间。 ![Delete root partition of your existing Linux install][13] -(删除 root 分区) -磁盘空间释放出来后,点击 + 号。 +*删除 root 分区* + +磁盘空间释放出来后,点击 `+` 号。 ![Create root partition for the new Linux][14] -(创建新的 root 分区) + +*创建新的 root 分区* 现在已经在可用空间中创建一个新分区。如果你之前的 Linux 系统中只有一个 root 分区,就应该在这里创建 root 分区和 home 分区。如果需要,还可以创建交换分区。 如果你之前已经有 root 分区和 home 分区,那么只需要从已删除的 root 分区创建 root 分区就可以了。 ![Create root partition for the new Linux][15] -(创建 root 分区) -你可能有疑问,为什么要经过“删除”和“添加”两个过程,而不使用“更改”选项。这是因为以前使用“更改”选项好像没有效果,所以我更喜欢用 - 和 +。这是迷信吗?也许是吧。 +*创建 root 分区* + +你可能有疑问,为什么要经过“删除”和“添加”两个过程,而不使用“更改”选项。这是因为以前使用“更改”选项好像没有效果,所以我更喜欢用 `-` 和 `+`。这是迷信吗?也许是吧。 这里有一个重要的步骤,对新创建的 root 分区进行格式化。在没有更改分区大小的情况下,默认是不会对分区进行格式化的。如果分区没有被格式化,之后可能会出现问题。 ![][16] -(格式化 root 分区很重要) + +*格式化 root 分区很重要* 如果你在新的 Linux 系统上已经划分了单独的 home 分区,选中它并点击更改。 ![Recreate home partition][17] -(修改已有的 home 分区) + +*修改已有的 home 分区* 然后指定将其作为 home 分区挂载即可。 ![Specify the home mount point][18] -(指定 home 分区的挂载点) + +*指定 home 分区的挂载点* 如果你还有交换分区,可以重复与 home 分区相同的步骤,唯一不同的是要指定将空间用作交换空间。 现在的状态应该是有一个 root 分区(将被格式化)和一个 home 分区(如果需要,还可以使用交换分区)。点击“立即安装”可以开始安装。 ![Verify partitions while replacing one Linux with another][19] -(检查分区情况) + +*检查分区情况* 接下来的几个界面就很熟悉了,要重点注意的是创建用户和密码的步骤。如果你之前有一个单独的 home 分区,并且还想使用相同的 home 目录,那你必须使用和之前相同的用户名和密码,至于设备名称则可以任意指定。 ![To keep the home partition intact, use the previous user and password][20] -(要保持 home 分区不变,请使用之前的用户名和密码) + +*要保持 home 分区不变,请使用之前的用户名和密码* 接下来只要静待安装完成,不需执行任何操作。 ![Wait for installation to finish][21] -(等待安装完成) + +*等待安装完成* 安装完成后重新启动系统,你就能使用新的 Linux 发行版。 @@ -126,7 +136,7 @@ via: https://itsfoss.com/replace-linux-from-dual-boot/ 作者:[Abhishek Prakash][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 6ac2b9bfc8b0fb57cc250a52edb0277f8bab1c5c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Sun, 21 Oct 2018 00:23:22 +0800 Subject: [PATCH 077/158] PUB:20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md @HankChow https://linux.cn/article-10137-1.html --- ...o Replace one Linux Distro With Another in Dual Boot -Guide.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md (100%) diff --git a/translated/tech/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md b/published/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md similarity index 100% rename from translated/tech/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md rename to published/20180925 How to Replace one Linux Distro With Another in Dual Boot -Guide.md From 2ecf809c98f6a54bf8253e031b2380ee06b0085c Mon Sep 17 00:00:00 2001 From: belitex Date: Sun, 21 Oct 2018 11:25:47 +0800 Subject: [PATCH 078/158] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90=20?= =?UTF-8?q?A=20sysadmin-s=20guide=20to=20containers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...180827 A sysadmin-s guide to containers.md | 61 ------------------- ...180827 A sysadmin-s guide to containers.md | 56 +++++++++++++++++ 2 files changed, 56 insertions(+), 61 deletions(-) delete mode 100644 sources/tech/20180827 A sysadmin-s guide to containers.md create mode 100644 translated/tech/20180827 A sysadmin-s guide to containers.md diff --git a/sources/tech/20180827 A sysadmin-s guide to containers.md b/sources/tech/20180827 A sysadmin-s guide to containers.md deleted file mode 100644 index 6acf9c2a45..0000000000 --- a/sources/tech/20180827 A sysadmin-s guide to containers.md +++ /dev/null @@ -1,61 +0,0 @@ -translating by belitex - -A sysadmin's guide to containers -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/toolbox-learn-draw-container-yearbook.png?itok=xDbwz1pP) - -The term "containers" is heavily overused. Also, depending on the context, it can mean different things to different people. - -Traditional Linux containers are really just ordinary processes on a Linux system. These groups of processes are isolated from other groups of processes using resource constraints (control groups [cgroups]), Linux security constraints (Unix permissions, capabilities, SELinux, AppArmor, seccomp, etc.), and namespaces (PID, network, mount, etc.). - -If you boot a modern Linux system and took a look at any process with `cat /proc/PID/cgroup`, you see that the process is in a cgroup. If you look at `/proc/PID/status`, you see capabilities. If you look at `/proc/self/attr/current`, you see SELinux labels. If you look at `/proc/PID/ns`, you see the list of namespaces the process is in. So, if you define a container as a process with resource constraints, Linux security constraints, and namespaces, by definition every process on a Linux system is in a container. This is why we often say [Linux is containers, containers are Linux][1]. **Container runtimes** are tools that modify these resource constraints, security, and namespaces and launch the container. - -Docker introduced the concept of a **container image** , which is a standard TAR file that combines: - - * **Rootfs (container root filesystem):** A directory on the system that looks like the standard root (`/`) of the operating system. For example, a directory with `/usr`, `/var`, `/home`, etc. - * **JSON file (container configuration):** Specifies how to run the rootfs; for example, what **command** or **entrypoint** to run in the rootfs when the container starts; **environment variables** to set for the container; the container's **working directory** ; and a few other settings. - - - -Docker "`tar`'s up" the rootfs and the JSON file to create the **base image**. This enables you to install additional content on the rootfs, create a new JSON file, and `tar` the difference between the original image and the new image with the updated JSON file. This creates a **layered image**. - -The definition of a container image was eventually standardized by the [Open Container Initiative (OCI)][2] standards body as the [OCI Image Specification][3]. - -Tools used to create container images are called **container image builders**. Sometimes container engines perform this task, but several standalone tools are available that can build container images. - -Docker took these container images ( **tarballs** ) and moved them to a web service from which they could be pulled, developed a protocol to pull them, and called the web service a **container registry**. - -**Container engines** are programs that can pull container images from container registries and reassemble them onto **container storage**. Container engines also launch **container runtimes** (see below). - -![](https://opensource.com/sites/default/files/linux_container_internals_2.0_-_hosts.png) - -Container storage is usually a **copy-on-write** (COW) layered filesystem. When you pull down a container image from a container registry, you first need to untar the rootfs and place it on disk. If you have multiple layers that make up your image, each layer is downloaded and stored on a different layer on the COW filesystem. The COW filesystem allows each layer to be stored separately, which maximizes sharing for layered images. Container engines often support multiple types of container storage, including `overlay`, `devicemapper`, `btrfs`, `aufs`, and `zfs`. - - -After the container engine downloads the container image to container storage, it needs to create aThe runtime configuration combines input from the caller/user along with the content of the container image specification. For example, the caller might want to specify modifications to a running container's security, add additional environment variables, or mount volumes to the container. - -The layout of the container runtime configuration and the exploded rootfs have also been standardized by the OCI standards body as the [OCI Runtime Specification][4]. - -Finally, the container engine launches a **container runtime** that reads the container runtime specification; modifies the Linux cgroups, Linux security constraints, and namespaces; and launches the container command to create the container's **PID 1**. At this point, the container engine can relay `stdin`/`stdout` back to the caller and control the container (e.g., stop, start, attach). - -Note that many new container runtimes are being introduced to use different parts of Linux to isolate containers. People can now run containers using KVM separation (think mini virtual machines) or they can use other hypervisor strategies (like intercepting all system calls from processes in containers). Since we have a standard runtime specification, these tools can all be launched by the same container engines. Even Windows can use the OCI Runtime Specification for launching Windows containers. - -At a much higher level are **container orchestrators.** Container orchestrators are tools used to coordinate the execution of containers on multiple different nodes. Container orchestrators talk to container engines to manage containers. Orchestrators tell the container engines to start containers and wire their networks together. Orchestrators can monitor the containers and launch additional containers as the load increases. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/8/sysadmins-guide-containers - -作者:[Daniel J Walsh][a] -选题:[lujun9972](https://github.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/rhatdan -[1]:https://www.redhat.com/en/blog/containers-are-linux -[2]:https://www.opencontainers.org/ -[3]:https://github.com/opencontainers/image-spec/blob/master/spec.md -[4]:https://github.com/opencontainers/runtime-spec diff --git a/translated/tech/20180827 A sysadmin-s guide to containers.md b/translated/tech/20180827 A sysadmin-s guide to containers.md new file mode 100644 index 0000000000..f1c27e41c4 --- /dev/null +++ b/translated/tech/20180827 A sysadmin-s guide to containers.md @@ -0,0 +1,56 @@ +写给系统管理员的容器手册 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/toolbox-learn-draw-container-yearbook.png?itok=xDbwz1pP) + +现在人们严重地过度使用“容器”这个术语。另外,对不同的人来说,它可能会有不同的含义,这取决于上下文。 + +传统的 Linux 容器只是系统上普通的进程组成的进程组。进程组之间是相互隔离的,实现方法包括:资源限制(控制组 [cgoups])、Linux 安全限制(文件权限,基于 Capability 的安全模块,SELinux,AppArmor,seccomp 等)还有名字空间(进程 ID,网络,挂载等)。 + +如果你启动一台现代 Linux 操作系统,使用 `cat /proc/PID/cgroup` 命令就可以看到该进程是属于一个控制组的。还可以从 `/proc/PID/status` 文件中查看进程的 Capability 信息,从 `/proc/self/attr/current` 文件中查看进程的 SELinux 标签信息,从 `/proc/PID/ns` 目录下的文件查看进程所属的名字空间。因此,如果把容器定义为带有资源限制、Linux 安全限制和名字空间的进程,那么按照这个定义,Linux 操作系统上的每一个进程都在容器里。因此我们常说 [Linux 就是容器,容器就是 Linux][1]。而**容器运行时**是这样一种工具,它调整上述资源限制、安全限制和名字空间,并启动容器。 + +Docker 引入了**容器镜像**的概念,镜像是一个普通的 TAR 包文件,包含了: + + * **Rootfs(容器的根文件系统):**一个目录,看起来像是操作系统的普通根目录(/),例如,一个包含 `/usr`, `/var`, `/home` 等的目录。 + * **JSON 文件(容器的配置):**定义了如何运行 rootfs;例如,当容器启动的时候要在 rootfs 里运行什么 **command** 或者 **entrypoint**,给容器定义什么样的**环境变量**,容器的**工作目录**是哪个,以及其他一些设置。 + +Docker 把 rootfs 和 JSON 配置文件打包成**基础镜像**。你可以在这个基础之上,给 rootfs 安装更多东西,创建新的 JSON 配置文件,然后把相对于原始镜像的不同内容打包到新的镜像。这种方法创建出来的是**分层的镜像**。 + +[Open Container Initiative(开放容器计划 OCI)][2] 标准组织最终把容器镜像的格式标准化了,也就是 [OCI Image Specification(OCI 镜像规范)][3]。 + +用来创建容器镜像的工具被称为**容器镜像构建器**。有时候容器引擎做这件事情,不过可以用一些独立的工具来构建容器镜像。 + +Docker 把这些容器镜像(**tar 包**)托管到 web 服务中,并开发了一种协议来支持从 web 拉取镜像,这个 web 服务就叫**容器仓库**。 + +**容器引擎**是能从镜像仓库拉取镜像并装载到**容器存储**上的程序。容器引擎还能启动**容器运行时**(见下图)。 + +![](https://opensource.com/sites/default/files/linux_container_internals_2.0_-_hosts.png) + +容器存储一般是**写入时复制**(COW)的分层文件系统。从容器仓库拉取一个镜像时,其中的 rootfs 首先被解压到磁盘。如果这个镜像是多层的,那么每一层都会被下载到 COW 文件系统的不同分层。 COW 文件系统保证了镜像的每一层独立存储,这最大化了多个分层镜像之间的文件共享程度。容器引擎通常支持多种容器存储类型,包括 `overlay`、`devicemapper`、`btrfs`、`aufs` 和 `zfs`。 + +容器引擎将容器镜像下载到容器存储中之后,需要创建一份**容器运行时配置**,这份配置是用户/调用者的输入和镜像配置的合并。例如,容器的调用者可能会调整安全设置,添加额外的环境变量或者挂载一些卷到容器中。 + +容器运行时配置的格式,和解压出来的 rootfs 也都被开放容器计划 OCI 标准组织做了标准化,称为 [OCI 运行时规范][4]。 + +最终,容器引擎启动了一个**容器运行时**来读取运行时配置,修改 Linux 控制组、安全限制和名字空间,并执行容器命令来创建容器的 **PID 1**。至此,容器引擎已经可以把容器的标准输入/标准输出转给调用方,并控制容器了(例如,stop,start,attach)。 + +值得一提的是,现在出现了很多新的容器运行时,它们使用 Linux 的不同特性来隔离容器。可以使用 KVM 技术来隔离容器(想想迷你虚拟机),或者使用其他虚拟机监视器策略(例如拦截所有从容器内的进程发起的系统调用)。既然我们有了标准的运行时规范,这些工具都能被相同的容器引擎来启动。即使在 Windows 系统下,也可以使用 OCI 运行时规范来启动 Windows 容器。 + +容器编排器是一个更高层次的概念。它是在多个不同的节点上协调容器执行的工具。容器编排工具通过和容器引擎的通信来管理容器。编排器控制容器引擎做容器的启动和容器间的网络连接,它能够监控容器,在负载变高的时候进行容器扩容。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/sysadmins-guide-containers + +作者:[Daniel J Walsh][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/rhatdan +[1]:https://www.redhat.com/en/blog/containers-are-linux +[2]:https://www.opencontainers.org/ +[3]:https://github.com/opencontainers/image-spec/blob/master/spec.md +[4]:https://github.com/opencontainers/runtime-spec From f5c004ff7857ada7ca57b75e0bdbaf5b45799d0e Mon Sep 17 00:00:00 2001 From: dianbanjiu Date: Sun, 21 Oct 2018 16:09:59 +0800 Subject: [PATCH 079/158] translated --- ...0180601 Download an OS with GNOME Boxes.md | 100 -------------- ...30 6 places to host your git repository.md | 58 --------- ...0180601 Download an OS with GNOME Boxes.md | 99 ++++++++++++++ ...30 6 places to host your git repository.md | 59 +++++++++ ...he Enabled-Active Repositories In Linux.md | 123 +++++++++--------- 5 files changed, 219 insertions(+), 220 deletions(-) delete mode 100644 sources/tech/20180601 Download an OS with GNOME Boxes.md delete mode 100644 sources/tech/20180830 6 places to host your git repository.md create mode 100644 translated/tech/20180601 Download an OS with GNOME Boxes.md create mode 100644 translated/tech/20180830 6 places to host your git repository.md rename {sources => translated}/tech/20181010 How To List The Enabled-Active Repositories In Linux.md (54%) diff --git a/sources/tech/20180601 Download an OS with GNOME Boxes.md b/sources/tech/20180601 Download an OS with GNOME Boxes.md deleted file mode 100644 index 434e0bce24..0000000000 --- a/sources/tech/20180601 Download an OS with GNOME Boxes.md +++ /dev/null @@ -1,100 +0,0 @@ -translating by dianbanjiu -Download an OS with GNOME Boxes -====== - -![](https://fedoramagazine.org/wp-content/uploads/2018/06/boxes-install-os-816x345.jpg) - -Boxes is the GNOME application for running virtual machines. Recently Boxes added a new feature that makes it easier to run different Linux distributions. You can now automatically install these distros in Boxes, as well as operating systems like FreeBSD and FreeDOS. The list even includes Red Hat Enterprise Linux. The Red Hat Developer Program includes a [no-cost subscription to Red Hat Enterprise Linux][1]. With a [Red Hat Developer][2] account, Boxes can automatically set up a RHEL virtual machine entitled to the Developer Suite subscription. Here’s how it works. - -### Red Hat Enterprise Linux - -To create a Red Hat Enterprise Linux virtual machine, launch Boxes and click New. Select Download an OS from the source selection list. At the top, pick Red Hat Enterprise Linux. This opens a web form at [developers.redhat.com][2]. Sign in with an existing Red Hat Developer Account, or create a new one. - -![][3] - -If this is a new account, Boxes requires some additional information before continuing. This step is required to enable the Developer Subscription on the account. Be sure to [accept the Terms & Conditions][4] now too. This saves a step later during registration. - -![][5] - -Click Submit and the installation disk image starts to download. The download can take a while, depending on your Internet connection. This is a great time to go fix a cup of tea or coffee! - -![][6] - -Once the media has downloaded (conveniently to ~/Downloads), Boxes offers to perform an Express Install. Fill in the account and password information and click Continue. Click Create after you verify the virtual machine details. The Express Install automatically performs the entire installation! (Now is a great time to enjoy a second cup of tea or coffee, if so inclined.) - -![][7] - -![][8] - -![][9] - -Once the installation is done, the virtual machine reboots and logs directly into the desktop. Inside the virtual machine, launch the Red Hat Subscription Manager via the Applications menu, under System Tools. Enter the root password to launch the utility. - -![][10] - -Click the Register button and follow the steps through the registration assistant. Log in with your Red Hat Developers account when prompted. - -![][11] - -![][12] - -Now you can download and install updates through any normal update method, such as yum or GNOME Software. - -![][13] - -### FreeDOS anyone? - -Boxes can install a lot more than just Red Hat Enterprise Linux, too. As a front end to KVM and qemu, Boxes supports a wide variety of operating systems. Using [libosinfo][14], Boxes can automatically download (and in some cases, install) quite a few different ones. - -![][15] - -To install an OS from the list, select it and finish creating the new virtual machine. Some OSes, like FreeDOS, do not support an Express Install. In those cases the virtual machine boots from the installation media. You can then manually install. - -![][16] - -![][17] - -### Popular operating systems on Boxes - -These are just a few of the popular choices available in Boxes today. - -![][18]![][19]![][20]![][21]![][22]![][23] - -Fedora updates its osinfo-db package regularly. Be sure to check back frequently for new OS options. - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/download-os-gnome-boxes/ - -作者:[Link Dupont][a] -选题:[lujun9972](https://github.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/linkdupont/ -[1]:https://developers.redhat.com/blog/2016/03/31/no-cost-rhel-developer-subscription-now-available/ -[2]:http://developers.redhat.com -[3]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-14-33-13.png -[4]:https://www.redhat.com/wapps/tnc/termsack?event%5B%5D=signIn -[5]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-14-34-37.png -[6]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-14-37-27.png -[7]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-09-11.png -[8]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-15-19-1024x815.png -[9]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-21-53-1024x815.png -[10]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-26-29-1024x815.png -[11]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-30-48-1024x815.png -[12]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-31-17-1024x815.png -[13]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-32-29-1024x815.png -[14]:https://libosinfo.org -[15]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-20-02-56.png -[16]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-40-25.png -[17]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-43-02-1024x815.png -[18]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-16-55-20-1024x815.png -[19]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-16-28-28-1024x815.png -[20]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-16-11-43-1024x815.png -[21]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-16-58-09-1024x815.png -[22]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-17-46-38-1024x815.png -[23]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-18-34-11-1024x815.png 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 deleted file mode 100644 index b259b96caa..0000000000 --- a/sources/tech/20180830 6 places to host your git repository.md +++ /dev/null @@ -1,58 +0,0 @@ -translating by dianbanjiu -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 diff --git a/translated/tech/20180601 Download an OS with GNOME Boxes.md b/translated/tech/20180601 Download an OS with GNOME Boxes.md new file mode 100644 index 0000000000..c625348db1 --- /dev/null +++ b/translated/tech/20180601 Download an OS with GNOME Boxes.md @@ -0,0 +1,99 @@ +用 GNOME Boxes 下载一个镜像 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/06/boxes-install-os-816x345.jpg) + +Boxes 是 GNOME 上的虚拟机应用。最近 Boxes 添加了一个新的特性,使得它在运行不同的 Linux 发行版时更加容易。你现在可以在 Boxes 中自动安装列表中这些发行版。该列表甚至包括红帽企业 Linux。红帽开发人员计划包括[免费订阅红帽企业版 Linux][1]。 使用[红帽开发者][2]帐户,Boxes 可以自动设置一个名为 Developer Suite 订阅的 RHEL 虚拟机。 下面是它的工作原理。 + +### 红帽企业版 Linux + +要创建一个红帽企业版 Linux 的虚拟机,启动 Boxes,点击新建。从源选择列表中选择下载一个镜像。在顶部,点击红帽企业版 Linux。这将会打开网址为 [developers.redhat.com][2] 的一个网络表单。使用已有的红帽开发者账号登录,或是新建一个。 + +![][3] + +如果这是一个新帐号,Boxes 在继续之前需要一些额外的信息。这一步需要在账户中开启开发者订阅。还要确保 [接受条款和条件][4],这样可以在之后的注册中节省一步。 + +![][5] + +点击提交,然后就会开始下载安装磁盘镜像。下载需要的时间取决于你的网络状况。在这期间你可以去喝杯茶或者咖啡歇息一下。 + +![][6] + +等媒体下载完成(一般位于 ~/Downloads ),Boxes 会有一个快速安装的显示。填入账号和密码然后点击继续,当你确认了虚拟机的信息之后点击创建。快速安装会自动完成接下来的整个安装!(现在你可以去享受你的第二杯茶或者咖啡了) + +![][7] + +![][8] + +![][9] + +等到安装结束,虚拟机会直接重启并登录到桌面。在虚拟机里,在应用菜单的系统工具一栏启动红帽订阅管理。这一步需要输入管理员密码。 + +![][10] + +单击“注册”按钮,然后按照注册助手中的步骤操作。 出现提示时,使用你的红帽开发者帐户登录。 + +![][11] + +![][12] + +现在你可以通过任何一种更新方法,像是 yum 或是 GNOME Software 进行下载和更新了。 + +![][13] + +### FreeDOS 或是其他 + +Boxes 可以安装很多的 Linux 发行版,而不仅仅只是红帽企业版。 作为 KVM 和 qemu 的前端,Boxes 支持各种操作系统。 使用 [libosinfo][14],Boxes 可以自动下载(在某些情况下安装)相当多不同操作系统。 + +![][15] + +要从列表中安装一个操作系统,只需选择并完成创建一个新的虚拟机。一些操作系统,比如 FreeDOS,并不支持快速安装。这些操作系统需要虚拟机从安装介质中引导。之后你可以手动安装。 + +![][16] + +![][17] + +### 在 Boxes 上受欢迎的操作系统 + +这里仅仅是一些目前在它上面比较受欢迎的选择。 + +![][18]![][19]![][20]![][21]![][22]![][23] + +Fedora 会定期更新它的操作系统信息数据库。确保你会经常检查是否有新的操作系统选项。 + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/download-os-gnome-boxes/ + +作者:[Link Dupont][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[dianbanjiu](https://github.com/dianbanjiu) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://fedoramagazine.org/author/linkdupont/ +[1]:https://developers.redhat.com/blog/2016/03/31/no-cost-rhel-developer-subscription-now-available/ +[2]:http://developers.redhat.com +[3]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-14-33-13.png +[4]:https://www.redhat.com/wapps/tnc/termsack?event%5B%5D=signIn +[5]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-14-34-37.png +[6]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-14-37-27.png +[7]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-09-11.png +[8]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-15-19-1024x815.png +[9]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-21-53-1024x815.png +[10]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-26-29-1024x815.png +[11]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-30-48-1024x815.png +[12]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-31-17-1024x815.png +[13]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-32-29-1024x815.png +[14]:https://libosinfo.org +[15]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-20-02-56.png +[16]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-40-25.png +[17]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-15-43-02-1024x815.png +[18]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-16-55-20-1024x815.png +[19]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-16-28-28-1024x815.png +[20]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-16-11-43-1024x815.png +[21]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-16-58-09-1024x815.png +[22]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-17-46-38-1024x815.png +[23]:https://fedoramagazine.org/wp-content/uploads/2018/05/Screenshot-from-2018-05-25-18-34-11-1024x815.png diff --git a/translated/tech/20180830 6 places to host your git repository.md b/translated/tech/20180830 6 places to host your git repository.md new file mode 100644 index 0000000000..0d1bc8b98f --- /dev/null +++ b/translated/tech/20180830 6 places to host your git repository.md @@ -0,0 +1,59 @@ +6 个托管你 git 仓库的地方 +====== + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/house_home_colors_live_building.jpg?itok=HLpsIfIL) + +也许你是少数一些没有注意到的人之一就在几周前,[微软收购了 GitHub][1]。两家公司达成了共识。微软在近些年已经变成了开源的有力支持者,GitHub 从成立起,就已经成为了许多开源项目的实际代码库。 + +然而,最近的购买可能会带给你一些烦躁。毕竟公司的收购让你意识到了你的开源代码放在了一个商业平台上。可能你现在还没准备好迁移到其他的平台上去,但是至少这可以给你提供一些可选项。让我们找找网上现在都有哪些可用的平台。 + +### 选择之一: GitHub + +严格来说,这是一个合格的选项。[GitHub][2] 历史上没有什么糟糕的失败,而且微软最近也确实发展了不少开源项目。把你的项目继续放在 GitHub 上,继续保持观望没有什么不可以。它现在依然是最大的软件开发的网络社区,同时还有许多对于问题追踪、代码复查、持续集成、通用的代码管理很有用的工具。而且它还是基于 Git 的,Git 是每个人都喜欢的开源版本控制系统。你的代码还是你的代码。 + +### 选择之二: GitLab + +[GitLab][3] 是代码库平台主要的竞争者。它是完全开源的。你可以像在 GitHhub 一样把你的代码托管在 GitLab,但你也可以选择在你自己的服务器上自行托管你自己的 GitLab 实例,并完全控制谁可以访问那里的所有内容以及如何访问、管理。 GitLab 与 GitHub 功能几乎相同,有些人甚至可能会说它的持续集成和测试工具更优越。尽管 GitLab 上的开发者社区肯定比 GitHub 上的开发者社区要小,但它仍然没有什么可以被指责的。你可能会在那里的人群中找到更多志同道合的开发者。 + +### 选择之三: Bitbucket + +[Bitbucket][4] 已经存在很多年了。在某些方面,它可以作为 GitHub 未来的一面镜子。 Bitbucket 八年前被一家大公司(Atlassian)收购,并且已经经历了一些转换过程。 它仍然是一个像 GitHub 这样的商业平台,但它远不是一个创业公司,而且从组织上说它的基础相当稳定。 Bitbucket 分享了 GitHub 和 GitLab 上的大部分功能,以及它自己的一些新功能,如对 [Mercurial][5] 存储库的本机支持。 + +### 选择之四: SourceForge + +[SourceForge][6] 是开源代码库的鼻祖。如果你曾经有一个开源项目,Sourceforge 是一个托管你的代码和向他人分享你的发行版的地方。迁移到 Git 进行版本控制需要一段时间,它有自己的商业收购和重新组构的事件,以及一些开源项目的一些不幸的捆绑决策。也就是说,SourceForge 从那时起似乎已经恢复,该网站仍然是一个有着不少开源项目的地方。 然而,很多人仍然感到有点受伤,而且有些人并不是各种尝试通过平台货币化的忠实粉丝,所以一定要睁大眼睛。 + +### 选择之五: 自己管理 + +如果你想自己掌握自己项目的命运(除了你自己没人可以责备你),然后一切都由自己来做对你来说可能是最佳的选择。无论对于大项目还是小项目。Git 是开源的,所以自己托管也很容易。如果你问题追踪和代码审查,你可以运行一个 GitLab 或者 [Phabricator][7] 的实例。对于持续集成,你可以设置自己的 [Jenkins][8] 自动化服务的实例。是的,你需要对自己的基础架构开销和相关的安全要求负责。但是,这个设置过程并不是很困难。所以如果你不想自己的代码被其他人的平台所吞没,这就是一种很好的方法。 + +### 选择之六:以上全部 + +以下是所有这些的美妙之处:尽管这些平台上有一些专有的选项,但它们仍然建立在坚实的开源技术之上。 而且不仅仅是开源,而是明确设计为分布在大型网络(如互联网)上的多个节点上。 你不需要只使用一个。 你可以使用一对......或者全部。 使用 GitLab 将你自己的设置作为保证的基础,并在 GitHub 和 Bitbucket 上安装克隆存储库,以进行问题跟踪和持续集成。 将你的主代码库保留在 GitHub 上,但是为了你自己的想法,可以在 GitLab 上安装“备份”克隆。 + +关键在于你的选择是什么。我们能有这么多选择,都是得益于那些非常有用的项目上的开源协议。未来一片光明。 + +当然,在这个列表中我肯定忽略了一些开源平台。你是否使用了很多的平台?哪个是你最喜欢的?你都可以在这里说出来! + +:) + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/8/github-alternatives + +作者:[Jason van Gumster][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[dianbanjiu](https://github.com/dianbanjiu) +校对:[校对者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 diff --git a/sources/tech/20181010 How To List The Enabled-Active Repositories In Linux.md b/translated/tech/20181010 How To List The Enabled-Active Repositories In Linux.md similarity index 54% rename from sources/tech/20181010 How To List The Enabled-Active Repositories In Linux.md rename to translated/tech/20181010 How To List The Enabled-Active Repositories In Linux.md index 47171a9d92..d78084e5e0 100644 --- a/sources/tech/20181010 How To List The Enabled-Active Repositories In Linux.md +++ b/translated/tech/20181010 How To List The Enabled-Active Repositories In Linux.md @@ -1,63 +1,62 @@ -translating by dianbanjiu -How To List The Enabled/Active Repositories In Linux +列出在 Linux 上已开启/激活的仓库 ====== -There are many ways to list enabled repositories in Linux. +这里有很多方法可以列出在 Linux 已开启的仓库。 -Here we are going to show you the easy methods to list active repositories. +我们将在下面展示给你列出已激活仓库的简便方法。 -It will helps you to know what are the repositories enabled on your system. +这有助于你知晓你的系统上都开启了哪些仓库。 -Once you have this information in handy then you can add any repositories that you want if it’s not already enabled. +一旦你掌握了这些信息,你就可以添加任何之前还没有准备开启的仓库了。 -Say for example, if you would like to enable `epel repository` then you need to check whether the epel repository is enabled or not. In this case this tutorial would help you. +举个例子,如果你想开启 `epel repository` ,你需要先检查 epel repository 是否已经开启了。这篇教程将会帮助你做这件事情。 -### What Is Repository? +### 什么是仓库? -A software repository is a central place which stores the software packages for the particular application. +存储特定程序软件包的中枢位置就是一个软件仓库。 -All the Linux distributions are maintaining their own repositories and they allow users to retrieve and install packages on their machine. +所有的 Linux 发行版都开发了他们自己的仓库,而且允许用户下载并安装这些软件包到他们的机器上。 -Each vendor offered a unique package management tool to manage their repositories such as search, install, update, upgrade, remove, etc. +每个供应商都提供了一套包管理工具,用以管理他们的仓库,比如搜索、安装、更新、升级、移除等等。 -Most of the Linux distributions comes as freeware except RHEL and SUSE. To access their repositories you need to buy a subscriptions. +大多数 Linux 发行版都作为免费软件,除了 RHEL 和 SUSE。接收他们的仓库你需要先购买订阅。 -**Suggested Read :** -**(#)** [How To Add, Enable And Disable A Repository By Using The DNF/YUM Config Manager Command On Linux][1] -**(#)** [How To List Installed Packages By Size (Largest) On Linux][2] -**(#)** [How To View/List The Available Packages Updates In Linux][3] -**(#)** [How To View A Particular Package Installed/Updated/Upgraded/Removed/Erased Date On Linux][4] -**(#)** [How To View Detailed Information About A Package In Linux][5] -**(#)** [How To Search If A Package Is Available On Your Linux Distribution Or Not][6] -**(#)** [How To List An Available Package Groups In Linux][7] -**(#)** [Newbies corner – A Graphical frontend tool for Linux Package Manager][8] -**(#)** [Linux Expert should knows, list of Command line Package Manager & Usage][9] +**建议阅读:** +**(#)** [在 Linux 上,如何通过 DNF/YUM 设置管理命令添加、开启、关闭一个仓库][1] +**(#)** [在 Linux 上如何以尺寸列出已安装的包][2] +**(#)** [在 Linux 上如何列出升级的包][3] +**(#)** [在 Linux 上如何查看一个特定包已安装/已升级/已更新/已移除/已清除的数据][4] +**(#)** [在 Linux 上如何查看一个包的详细信息][5] +**(#)** [在你的 Linux 发行版上如何查看一个包是否可用][6] +**(#)** [在 Linux 如何列出可用的软件包组][7] +**(#)** [Newbies corner - 一个图形化的 Linux 包管理的前端工具][8] +**(#)** [Linux 专家须知,命令行包管理 & 使用列表][9] -### How To List The Enabled Repositories on RHEL/CentOS +### 在 RHEL/CentOS上列出已开启的库 -RHEL & CentOS systems are using RPM packages hence we can use the `Yum Package Manager` to get this information. +RHEL 和 CentOS 系统使用的是 RPM 包管理,所以我们可以使用 `Yum 包管理` 查看这些信息。 -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 代表的是 `Yellowdog Updater,Modified`,它是一个包管理的开源前端,作用在基于 RPM 的系统上,例如 RHEL 和 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. +YUM 是获取、安装、删除、查询和管理来自发行版仓库和其他第三方库的 RPM 包的主要工具。 -**Suggested Read :** [YUM Command To Manage Packages on RHEL/CentOS Systems][10] +**建议阅读:Suggested Read :** [在 RHEL/CentOS 系统上用 YUM 命令管理包][10] -RHEL based systems are mainly offering the below three major repositories. These repository will be enabled by default. +基于 RHEL 的系统主要提供以下三个主要的仓库。这些仓库是默认开启的。 - * **`base:`** It’s containing all the core packages and base packages. - * **`extras:`** It provides additional functionality to CentOS without breaking upstream compatibility or updating base components. It is an upstream repository, as well as additional CentOS packages. - * **`updates:`** It’s offering bug fixed packages, Security packages and Enhancement packages. + * **`base:`** 它包含了所有的核心包和基础包。 + * **`extras:`** 它向 CentOS 提供不破坏上游兼容性或更新基本组件的额外功能。这是一个上游仓库,还有额外的 CentOS 包。 + * **`updates:`** 它提供了 bug 修复包、安全性包和增强包。 ``` # yum repolist -or +或者 # yum repolist enabled Loaded plugins: fastestmirror Determining fastest mirrors - 选题模板.txt 中文排版指北.md comic core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LCTT翻译规范.md LICENSE Makefile published README.md sign.md sources translated epel: ewr.edge.kernel.org +epel: ewr.edge.kernel.org repo id repo name status !base/7/x86_64 CentOS-7 - Base 9,911 !epel/x86_64 Extra Packages for Enterprise Linux 7 - x86_64 12,687 @@ -67,26 +66,26 @@ repolist: 24,349 ``` -### How To List The Enabled Repositories on Fedora +### 如何列出 Fedora 上已开启的包 -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 代表 Dandified yum。我们可以说 DNF 是下一代的 yum 包管理,使用了 hawkey/libsolv 作为后端。自从 Fedroa 18 开始,Aleš Kozumplík 就开始研究 DNF 最终在 Fedora 22 上实现。 -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. +Fedora 22 及之后的系统上都使用 Dnf 安装、升级、搜索和移除包。它可以自动解决依赖问题,并使包的安装过程平顺没有任何麻烦。 -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. +因为 Yum 许多未解决的问题,现在 Yum 已经被 DNF 所替代。你问为什么?他没有给 Yum 打补丁。Aleš Kozumplík 解释说修补在技术上太困难了,YUM 团队无法立即承受这些变更,还有其他的问题,YUM 是 56k 行,而 DNF 是 29k 行。因此,除了 fork 之外,别无选择。 -**Suggested Read :** [DNF (Fork of YUM) Command To Manage Packages on Fedora System][11] +**建议阅读:** [在 Fedora 上使用 DNF(Fork 自 YUM)管理软件][11] -Fedora system is mainly offering the below two major repositories. These repository will be enabled by default. +Fedora 主要提供下面两个主仓库。这些库将被默认开启。 - * **`fedora:`** It’s containing all the core packages and base packages. - * **`updates:`** It’s offering bug fixed packages, Security packages and Enhancement packages from the stable release branch. + * **`fedora:`** 它包括所有的核心包和基础包。 + * **`updates:`** 它提供了来自稳定发行版的 bug 修复包、安全性包和增强包 ``` # dnf repolist -or +或者 # dnf repolist enabled Last metadata expiration check: 0:02:56 ago on Wed 10 Oct 2018 06:12:22 PM IST. @@ -106,13 +105,13 @@ rabiny-albert Copr repo for albert owned by rabiny 3 ``` -### How To List The Enabled Repositories on Debian/Ubuntu +### 如何列出 Debian/Ubuntu 上已开启的仓库 -Debian based systems are using APT/APT-GET package manager hence we can use the `APT/APT-GET Package Manager` to get this information. +基于 Debian 的系统使用的是 APT/APT-GET 包管理,因此我们可以使用 `APT/APT-GET 包管理` 去获取更多的信息。 -APT stands for Advanced Packaging Tool (APT) which is replacement for apt-get, like how DNF came to picture instead of YUM. It’s feature rich command-line tools with included all the futures in one command (APT) such as apt-cache, apt-search, dpkg, apt-cdrom, apt-config, apt-key, etc..,. and several other unique features. For example we can easily install .dpkg packages through APT but we can’t do through Apt-Get similar more features are included into APT command. APT-GET replaced by APT Due to lock of futures missing in apt-get which was not solved. +APT 代表 Advanced Packaging Tool,它取代了 apt-get,就像 DNF 取代 Yum一样。 它具有丰富的命令行工具,在一个命令(APT)中包含了所有,如 apt-cache,apt-search,dpkg,apt-cdrom,apt-config,apt-key等。 还有其他几个独特的功能。 例如,我们可以通过 APT 轻松安装 .dpkg 软件包,而我们无法通过 Apt-Get 获得和包含在 APT 命令中类似的更多功能。 由于未能解决的 apt-get 问题,用 APT 取代了 APT-GET 的锁定。 -Apt-Get stands for Advanced Packaging Tool (APT). apg-get is a powerful command-line tool which is used to automatically download and install new software packages, upgrade existing software packages, update the package list index, and to upgrade the entire Debian based systems. +APT_GET 代表 Advanced Packaging Tool。apt-get 是一个强大的命令行工具,它用以自动下载和安装新的软件包、升级已存在的软件包、更新包索引列表、还有升级整个基于 Debian 的系统。 ``` # apt-cache policy @@ -156,13 +155,13 @@ Pinned packages: ``` -### How To List The Enabled Repositories on openSUSE +### 如何在 openSUSE 上列出已开启的仓库 -openSUSE system uses zypper package manager hence we can use the zypper Package Manager to get this information. +openSUSE 使用 zypper 包管理,因此我们可以使用 zypper 包管理获得更多信息。 -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). +Zypper 是 suse 和 openSUSE 发行版的命令行包管理。它用于安装、更新、搜索、移除包和管理仓库,执行各种查询等。Zypper 以 libzypp(ZYpp 系统管理库)作为后端。 -**Suggested Read :** [Zypper Command To Manage Packages On openSUSE & suse Systems][12] +**建议阅读:** [在 openSUSE 和 suse 系统上使用 Zypper 命令管理包][12] ``` # zypper repos @@ -179,7 +178,7 @@ Zypper is a command line package manager for suse & openSUSE distributions. It ``` -List Repositories with URI. +以 URI 列出仓库。 ``` # zypper lr -u @@ -196,7 +195,7 @@ List Repositories with URI. ``` -List Repositories by priority. +通过优先级列出仓库。 ``` # zypper lr -p @@ -213,13 +212,13 @@ List Repositories by priority. ``` -### How To List The Enabled Repositories on ArchLinux +### 如何列出 Arch Linux 上已开启的仓库 -Arch Linux based systems are using pacman package manager hence we can use the pacman Package Manager to get this information. +基于 Arch Linux 的系统使用 pacman 包管理,因此我们可以使用 pacman 包管理获取这些信息。 -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. +pacman 代表 package manager utility。pacman 是一个命令行实用程序,用以安装、构建、移除和管理 Arch Linux 包。pacman 使用 libalpm (Arch Linux包管理库)作为后端去进行这些操作。 -**Suggested Read :** [Pacman Command To Manage Packages On Arch Linux Based Systems][13] +**建议阅读:** [在基于 Arch Linux的系统上使用 Pacman命令管理包][13] ``` # pacman -Syy @@ -231,15 +230,15 @@ pacman stands for package manager utility (pacman). pacman is a command-line uti ``` -### How To List The Enabled Repositories on Linux using INXI Utility +### 如何使用 INXI Utility 列出 Linux 上已开启的仓库 -inxi is a nifty tool to check hardware information on Linux and offers wide range of option to get all the hardware information on Linux system that i never found in any other utility which are available in Linux. It was forked from the ancient and mindbendingly perverse yet ingenius infobash, by locsmif. +inix 是 Linux 上检查硬件信息非常有用的工具,还提供很多的选项去获取 Linux 上的所有硬件信息,我从未在 Linux 上发现其他有如此效用的程序。它由 locsmif fork 自 ingenius infobash。 -inxi is a script that quickly shows system hardware, CPU, drivers, Xorg, Desktop, Kernel, GCC version(s), Processes, RAM usage, and a wide variety of other useful information, also used for forum technical support & debugging tool. +inix 是一个可以快速显示硬件信息、CPU、硬盘、Xorg、桌面、内核、GCC 版本、进程、内存使用和很多其他有用信息的程序,还使用于论坛技术支持和调试工具上。 -Additionally this utility will display all the distribution repository data information such as RHEL, CentOS, Fedora, Debain, Ubuntu, LinuxMint, ArchLinux, openSUSE, Manjaro, etc., +这个实用程序将会显示所有发行版仓库的数据信息,例如 RHEL、CentOS、Fedora、Debain、Ubuntu、LinuxMint、ArchLinux、openSUSE、Manjaro等。 -**Suggested Read :** [inxi – A Great Tool to Check Hardware Information on Linux][14] +**建议阅读:** [inxi – 一个在 Linux 上检查硬件信息的好工具][14] ``` # inxi -r @@ -267,7 +266,7 @@ via: https://www.2daygeek.com/how-to-list-the-enabled-active-repositories-in-lin 作者:[Prakash Subramanian][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) +译者:[dianbanjiu](https://github.com/dianbanjiu) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 7af4af012c7cac214e7dee78b9403834e031d3c0 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Sun, 21 Oct 2018 16:47:48 +0800 Subject: [PATCH 080/158] Update 20180901 Flameshot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md --- ...shot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md | 1 + 1 file changed, 1 insertion(+) 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 index f6bec82f02..2eab96c02b 100644 --- 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 @@ -1,3 +1,4 @@ +FSSlc Translating Flameshot – A Simple, Yet Powerful Feature-rich Screenshot Tool ====== From 06baf1adbcab61f8740d601c47c3e4ed24c634a2 Mon Sep 17 00:00:00 2001 From: runningwater Date: Sun, 21 Oct 2018 18:20:21 +0800 Subject: [PATCH 081/158] translated --- ...ntrol And Manage CPU Frequency In Linux.md | 75 ------------------- ...ntrol And Manage CPU Frequency In Linux.md | 74 ++++++++++++++++++ 2 files changed, 74 insertions(+), 75 deletions(-) delete mode 100644 sources/talk/20180926 CPU Power Manager - Control And Manage CPU Frequency In Linux.md create mode 100644 translated/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 deleted file mode 100644 index d1275d5e30..0000000000 --- a/sources/talk/20180926 CPU Power Manager - Control And Manage CPU Frequency In Linux.md +++ /dev/null @@ -1,75 +0,0 @@ -(translating by runningwater) -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) -译者:[runningwater](https://github.com/runningwater) -校对:[校对者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/ diff --git a/translated/talk/20180926 CPU Power Manager - Control And Manage CPU Frequency In Linux.md b/translated/talk/20180926 CPU Power Manager - Control And Manage CPU Frequency In Linux.md new file mode 100644 index 0000000000..ad76c2d42b --- /dev/null +++ b/translated/talk/20180926 CPU Power Manager - Control And Manage CPU Frequency In Linux.md @@ -0,0 +1,74 @@ +CPU 电源管理工具 - Linux 系统中 CPU 主频的控制和管理 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Manage-CPU-Frequency-720x340.jpeg) + +你使用笔记本的话,可能知道 Linux 系统的电源管理做的很不好。虽然有 **TLP**、[**Laptop Mode Tools** 和 **powertop**][1] 这些工具来辅助减少电量消耗,但跟 Windows 和 Mac OS 系统比较起来,电池的整个使用周期还是不尽如意。此外,还有一种降低功耗的办法就是限制 CPU 的频率。这是可行的,然而却需要编写很复杂的终端命令来设置,所以使用起来不太方便。幸好,有一款名为 **CPU Power Manager** 的 GNOME 扩展插件,可以很容易的就设置和管理你的 CPU 主频。GNOME 桌面系统中,CPU Power Manager 使用名为 **intel_pstate** 的功率驱动程序(几乎所有的 Intel CPU 都支持)来控制和管理 CPU 主频。 + +使用这个扩展插件的另一个原因是可以减少系统的发热量,因为很多系统在正常使用中的发热量总让人不舒服,限制 CPU 的主频就可以减低发热量。它还可以减少 CPU 和其他组件的磨损。 + +### 安装 CPU Power Manager + +首先,进入[**扩展插件主页面**][2],安装此扩展插件。 + +安装好插件后,在 GNOME 顶部栏的右侧会出现一个 CPU 图标。点击图标,会出现安装此扩展一个选项提示,如下示: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPU-Power-Manager-icon.png) + +点击**“尝试安装”**按纽,会弹出输入密码确认框。插件需要 root 权限来添加 policykit 规则,进而控制 CPU 主频。下面是弹出的提示框样子: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPU-Power-Manager-1.png) + +输入密码,点击**“认证”**按纽,完成安装。最后在 **/usr/share/polkit-1/actions** 目录下添加了一个名为 **mko.cpupower.setcpufreq.policy** 的 policykit 文件。 + +都安装完成后,如果点击右上脚的 CPU 图标,会出现如下所示: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPU-Power-Manager.png) + +### 功能特性 + + * **查看 CPU 主频:** 显然,你可以通过这个提示窗口看到 CPU 的当前运行频率。 + * **设置最大最小主频:** 使用此扩展,你可以根据列出的最大、最小频率百分比进度条来分别设置其频率限制。一旦设置,CPU 将会严格按照此设置范围运行。 + * **开/关 Turbo Boost:** 这是我最喜欢的功能特性。大多数 Intel CPU 都有 “Turbo Boost” 特性,为了提高额外性能,其中的一个内核为自动进行超频。此功能虽然可以使系统获得更高的性能,但也大大增加功耗。所以,如果不做 CPU 密集运行的话,为节约电能,最好关闭 Turbo Boost 功能。事实上,在我电脑上,我大部分时间是把 Turbo Boost 关闭的。 + * **生成配置文件:** 可以生成最大和最小频率的配置文件,就可以很轻松打开/关闭,而不是每次手工调整设置。 + + + +### 偏好设置 + +你也可以通过偏好设置窗口来自定义扩展插件显示形式: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPU-Power-Manager-preferences.png) + +如你所见,你可以设置是否显示 CPU 主频,也可以设置是否以 **Ghz** 来代替 **Mhz** 显示。 + +你也可以编辑和创建/删除配置: + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/CPU-Power-Manager-preferences-1.png) + +可以为每个配置分别设置最大、最小主频及开/关 Turbo boost。 + +### 结论 + +正如我在开始时所说的,Linux 系统的电源管理并不是最好的,许多人总是希望他们的 Linux 笔记本电脑电池能多用几分钟。如果你也是其中一员,就试试此扩展插件吧。为了省电,虽然这是非常规的做法,但有效果。我确实喜欢这个插件,到现在已经使用了好几个月了。 + +What do you think about this extension? Put your thoughts in the comments below!你对此插件有何看法呢?请把你的观点留在下面的评论区吧。 + +祝贺! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/cpu-power-manager-control-and-manage-cpu-frequency-in-linux/ + +作者:[EDITOR][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[runningwater](https://github.com/runningwater) +校对:[校对者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 9492913d362e8bf7c10f4625aa126ed450ad8d45 Mon Sep 17 00:00:00 2001 From: BriFuture <752736341@qq.com> Date: Sun, 21 Oct 2018 18:44:30 +0800 Subject: [PATCH 082/158] Finish Translation --- ...p to JavaScript From Scratch in 350 LOC.md | 639 ------------------ ...p to JavaScript From Scratch in 350 LOC.md | 637 +++++++++++++++++ 2 files changed, 637 insertions(+), 639 deletions(-) delete mode 100644 sources/tech/20161014 Compiling Lisp to JavaScript From Scratch in 350 LOC.md create mode 100644 translated/tech/20161014 Compiling Lisp to JavaScript From Scratch in 350 LOC.md diff --git a/sources/tech/20161014 Compiling Lisp to JavaScript From Scratch in 350 LOC.md b/sources/tech/20161014 Compiling Lisp to JavaScript From Scratch in 350 LOC.md deleted file mode 100644 index 41d66c744e..0000000000 --- a/sources/tech/20161014 Compiling Lisp to JavaScript From Scratch in 350 LOC.md +++ /dev/null @@ -1,639 +0,0 @@ -BriFuture is translating this article - -# Compiling Lisp to JavaScript From Scratch in 350 - -In this article we will look at a from-scratch implementation of a compiler from a simple LISP-like calculator language to JavaScript. The complete source code can be found [here][7]. - -We will: - -1. Define our language and write a simple program in it - -2. Implement a simple parser combinator library - -3. Implement a parser for our language - -4. Implement a pretty printer for our language - -5. Define a subset of JavaScript for our usage - -6. Implement a code translator to the JavaScript subset we defined - -7. Glue it all together - -Let's start! - -### 1\. Defining the language - -The main attraction of lisps is that their syntax already represent a tree, this is why they are so easy to parse. We'll see that soon. But first let's define our language. Here's a BNF description of our language's syntax: - -``` -program ::= expr -expr ::= | | ([]) -``` - -Basically, our language let's us define one expression at the top level which it will evaluate. An expression is composed of either an integer, for example `5`, a variable, for example `x`, or a list of expressions, for example `(add x 1)`. - -An integer evaluate to itself, a variable evaluates to what it's bound in the current environment, and a list evaluates to a function call where the first argument is the function and the rest are the arguments to the function. - -We have some built-in special forms in our language so we can do more interesting stuff: - -* let expression let's us introduce new variables in the environment of the body of the let. The syntax is: - -``` -let ::= (let ([]) ) -letargs ::= ( ) -body ::= -``` - -* lambda expression: evaluates to an anonymous function definition. The syntax is: - -``` -lambda ::= (lambda ([]) ) -``` - -We also have a few built in functions: `add`, `mul`, `sub`, `div` and `print`. - -Let's see a quick example of a program written in our language: - -``` -(let - ((compose - (lambda (f g) - (lambda (x) (f (g x))))) - (square - (lambda (x) (mul x x))) - (add1 - (lambda (x) (add x 1)))) - (print ((compose square add1) 5))) -``` - -This program defines 3 functions: `compose`, `square` and `add1`. And then prints the result of the computation:`((compose square add1) 5)` - -I hope this is enough information about the language. Let's start implementing it! - -We can define the language in Haskell like this: - -``` -type Name = String - -data Expr - = ATOM Atom - | LIST [Expr] - deriving (Eq, Read, Show) - -data Atom - = Int Int - | Symbol Name - deriving (Eq, Read, Show) -``` - -We can parse programs in the language we defined to an `Expr`. Also, we are giving the new data types `Eq`, `Read`and `Show` instances to aid in testing and debugging. You'll be able to use those in the REPL for example to verify all this actually works. - -The reason we did not define `lambda`, `let` and the other built-in functions as part of the syntax is because we can get away with it in this case. These functions are just a more specific case of a `LIST`. So I decided to leave this to a later phase. - -Usually, you would like to define these special cases in the abstract syntax - to improve error messages, to unable static analysis and optimizations and such, but we won't do that here so this is enough for us. - -Another thing you would like to do usually is add some annotation to the syntax. For example the location: Which file did this `Expr` come from and which row and col in the file. You can use this in later stages to print the location of errors, even if they are not in the parser stage. - -* _Exercise 1_ : Add a `Program` data type to include multiple `Expr` sequentially - -* _Exercise 2_ : Add location annotation to the syntax tree. - -### 2\. Implement a simple parser combinator library - -First thing we are going to do is define an Embedded Domain Specific Language (or EDSL) which we will use to define our languages' parser. This is often referred to as parser combinator library. The reason we are doing it is strictly for learning purposes, Haskell has great parsing libraries and you should definitely use them when building real software, or even when just experimenting. One such library is [megaparsec][8]. - -First let's talk about the idea behind our parser library implementation. In it's essence, our parser is a function that takes some input, might consume some or all of the input, and returns the value it managed to parse and the rest of the input it didn't parse yet, or throws an error if it failed. Let's write that down. - -``` -newtype Parser a - = Parser (ParseString -> Either ParseError (a, ParseString)) - -data ParseString - = ParseString Name (Int, Int) String - -data ParseError - = ParseError ParseString Error - -type Error = String - -``` - -Here we defined three main new types. - -First, `Parser a`, is the parsing function we described before. - -Second, `ParseString` is our input or state we carry along. It has three significant parts: - -* `Name`: This is the name of the source - -* `(Int, Int)`: This is the current location in the source - -* `String`: This is the remaining string left to parse - -Third, `ParseError` contains the current state of the parser and an error message. - -Now we want our parser to be flexible, so we will define a few instances for common type classes for it. These instances will allow us to combine small parsers to make bigger parsers (hence the name 'parser combinators'). - -The first one is a `Functor` instance. We want a `Functor` instance because we want to be able to define a parser using another parser simply by applying a function on the parsed value. We will see an example of this when we define the parser for our language. - -``` -instance Functor Parser where - fmap f (Parser parser) = - Parser (\str -> first f <$> parser str) -``` - -The second instance is an `Applicative` instance. One common use case for this instance instance is to lift a pure function on multiple parsers. - -``` -instance Applicative Parser where - pure x = Parser (\str -> Right (x, str)) - (Parser p1) <*> (Parser p2) = - Parser $ - \str -> do - (f, rest) <- p1 str - (x, rest') <- p2 rest - pure (f x, rest') - -``` - -(Note:  _We will also implement a Monad instance so we can use do notation here._ ) - -The third instance is an `Alternative` instance. We want to be able to supply an alternative parser in case one fails. - -``` -instance Alternative Parser where - empty = Parser (`throwErr` "Failed consuming input") - (Parser p1) <|> (Parser p2) = - Parser $ - \pstr -> case p1 pstr of - Right result -> Right result - Left _ -> p2 pstr -``` - -The forth instance is a `Monad` instance. So we'll be able to chain parsers. - -``` -instance Monad Parser where - (Parser p1) >>= f = - Parser $ - \str -> case p1 str of - Left err -> Left err - Right (rs, rest) -> - case f rs of - Parser parser -> parser rest - -``` - -Next, let's define a way to run a parser and a utility function for failure: - -``` - -runParser :: String -> String -> Parser a -> Either ParseError (a, ParseString) -runParser name str (Parser parser) = parser $ ParseString name (0,0) str - -throwErr :: ParseString -> String -> Either ParseError a -throwErr ps@(ParseString name (row,col) _) errMsg = - Left $ ParseError ps $ unlines - [ "*** " ++ name ++ ": " ++ errMsg - , "* On row " ++ show row ++ ", column " ++ show col ++ "." - ] - -``` - -Now we'll start implementing the combinators which are the API and heart of the EDSL. - -First, we'll define `oneOf`. `oneOf` will succeed if one of the characters in the list supplied to it is the next character of the input and will fail otherwise. - -``` -oneOf :: [Char] -> Parser Char -oneOf chars = - Parser $ \case - ps@(ParseString name (row, col) str) -> - case str of - [] -> throwErr ps "Cannot read character of empty string" - (c:cs) -> - if c `elem` chars - then Right (c, ParseString name (row, col+1) cs) - else throwErr ps $ unlines ["Unexpected character " ++ [c], "Expecting one of: " ++ show chars] -``` - -`optional` will stop a parser from throwing an error. It will just return `Nothing` on failure. - -``` -optional :: Parser a -> Parser (Maybe a) -optional (Parser parser) = - Parser $ - \pstr -> case parser pstr of - Left _ -> Right (Nothing, pstr) - Right (x, rest) -> Right (Just x, rest) -``` - -`many` will try to run a parser repeatedly until it fails. When it does, it'll return a list of successful parses. `many1`will do the same, but will throw an error if it fails to parse at least once. - -``` -many :: Parser a -> Parser [a] -many parser = go [] - where go cs = (parser >>= \c -> go (c:cs)) <|> pure (reverse cs) - -many1 :: Parser a -> Parser [a] -many1 parser = - (:) <$> parser <*> many parser - -``` - -These next few parsers use the combinators we defined to make more specific parsers: - -``` -char :: Char -> Parser Char -char c = oneOf [c] - -string :: String -> Parser String -string = traverse char - -space :: Parser Char -space = oneOf " \n" - -spaces :: Parser String -spaces = many space - -spaces1 :: Parser String -spaces1 = many1 space - -withSpaces :: Parser a -> Parser a -withSpaces parser = - spaces *> parser <* spaces - -parens :: Parser a -> Parser a -parens parser = - (withSpaces $ char '(') - *> withSpaces parser - <* (spaces *> char ')') - -sepBy :: Parser a -> Parser b -> Parser [b] -sepBy sep parser = do - frst <- optional parser - rest <- many (sep *> parser) - pure $ maybe rest (:rest) frst - -``` - -Now we have everything we need to start defining a parser for our language. - -* _Exercise_ : implement an EOF (end of file/input) parser combinator. - -### 3\. Implementing a parser for our language - -To define our parser, we'll use the top-bottom method. - -``` -parseExpr :: Parser Expr -parseExpr = fmap ATOM parseAtom <|> fmap LIST parseList - -parseList :: Parser [Expr] -parseList = parens $ sepBy spaces1 parseExpr - -parseAtom :: Parser Atom -parseAtom = parseSymbol <|> parseInt - -parseSymbol :: Parser Atom -parseSymbol = fmap Symbol parseName - -``` - -Notice that these four function are a very high-level description of our language. This demonstrate why Haskell is so nice for parsing. Still, after defining the high-level parts, we still need to define the lower-level `parseName` and `parseInt`. - -What characters can we use as names in our language? Let's decide to use lowercase letters, digits and underscores, where the first character must be a letter. - -``` -parseName :: Parser Name -parseName = do - c <- oneOf ['a'..'z'] - cs <- many $ oneOf $ ['a'..'z'] ++ "0123456789" ++ "_" - pure (c:cs) -``` - -For integers, we want a sequence of digits optionally preceding by '-': - -``` -parseInt :: Parser Atom -parseInt = do - sign <- optional $ char '-' - num <- many1 $ oneOf "0123456789" - let result = read $ maybe num (:num) sign of - pure $ Int result -``` - -Lastly, we'll define a function to run a parser and get back an `Expr` or an error message. - -``` -runExprParser :: Name -> String -> Either String Expr -runExprParser name str = - case runParser name str (withSpaces parseExpr) of - Left (ParseError _ errMsg) -> Left errMsg - Right (result, _) -> Right result -``` - -* _Exercise 1_ : Write a parser for the `Program` type you defined in the first section - -* _Exercise 2_ : Rewrite `parseName` in Applicative style - -* _Exercise 3_ : Find a way to handle the overflow case in `parseInt` instead of using `read`. - -### 4\. Implement a pretty printer for our language - -One more thing we'd like to do is be able to print our programs as source code. This is useful for better error messages. - -``` -printExpr :: Expr -> String -printExpr = printExpr' False 0 - -printAtom :: Atom -> String -printAtom = \case - Symbol s -> s - Int i -> show i - -printExpr' :: Bool -> Int -> Expr -> String -printExpr' doindent level = \case - ATOM a -> indent (bool 0 level doindent) (printAtom a) - LIST (e:es) -> - indent (bool 0 level doindent) $ - concat - [ "(" - , printExpr' False (level + 1) e - , bool "\n" "" (null es) - , intercalate "\n" $ map (printExpr' True (level + 1)) es - , ")" - ] - -indent :: Int -> String -> String -indent tabs e = concat (replicate tabs " ") ++ e -``` - -* _Exercise_ : Write a pretty printer for the `Program` type you defined in the first section - -Okay, we wrote around 200 lines so far of what's typically called the front-end of the compiler. We have around 150 more lines to go and three more tasks: We need to define a subset of JS for our usage, define the translator from our language to that subset, and glue the whole thing together. Let's go! - -### 5\. Define a subset of JavaScript for our usage - -First, we'll define the subset of JavaScript we are going to use: - -``` -data JSExpr - = JSInt Int - | JSSymbol Name - | JSBinOp JSBinOp JSExpr JSExpr - | JSLambda [Name] JSExpr - | JSFunCall JSExpr [JSExpr] - | JSReturn JSExpr - deriving (Eq, Show, Read) - -type JSBinOp = String -``` - -This data type represent a JavaScript expression. We have two atoms - `JSInt` and `JSSymbol` to which we'll translate our languages' `Atom`, We have `JSBinOp` to represent a binary operation such as `+` or `*`, we have `JSLambda`for anonymous functions same as our `lambda expression`, We have `JSFunCall` which we'll use both for calling functions and introducing new names as in `let`, and we have `JSReturn` to return values from functions as that's required in JavaScript. - -This `JSExpr` type is an **abstract representation** of a JavaScript expression. We will translate our own `Expr`which is an abstract representation of our languages' expression to `JSExpr` and from there to JavaScript. But in order to do that we need to take this `JSExpr` and produce JavaScript code from it. We'll do that by pattern matching on `JSExpr` recursively and emit JS code as a `String`. This is basically the same thing we did in `printExpr`. We'll also track the scoping of elements so we can indent the generated code in a nice way. - -``` -printJSOp :: JSBinOp -> String -printJSOp op = op - -printJSExpr :: Bool -> Int -> JSExpr -> String -printJSExpr doindent tabs = \case - JSInt i -> show i - JSSymbol name -> name - JSLambda vars expr -> (if doindent then indent tabs else id) $ unlines - ["function(" ++ intercalate ", " vars ++ ") {" - ,indent (tabs+1) $ printJSExpr False (tabs+1) expr - ] ++ indent tabs "}" - JSBinOp op e1 e2 -> "(" ++ printJSExpr False tabs e1 ++ " " ++ printJSOp op ++ " " ++ printJSExpr False tabs e2 ++ ")" - JSFunCall f exprs -> "(" ++ printJSExpr False tabs f ++ ")(" ++ intercalate ", " (fmap (printJSExpr False tabs) exprs) ++ ")" - JSReturn expr -> (if doindent then indent tabs else id) $ "return " ++ printJSExpr False tabs expr ++ ";" -``` - -* _Exercise 1_ : Add a `JSProgram` type that will hold multiple `JSExpr` and create a function `printJSExprProgram` to generate code for it. - -* _Exercise 2_ : Add a new type of `JSExpr` - `JSIf`, and generate code for it. - -### 6\. Implement a code translator to the JavaScript subset we defined - -We are almost there. In this section we'll create a function to translate `Expr` to `JSExpr`. - -The basic idea is simple, we'll translate `ATOM` to `JSSymbol` or `JSInt` and `LIST` to either a function call or a special case we'll translate later. - -``` -type TransError = String - -translateToJS :: Expr -> Either TransError JSExpr -translateToJS = \case - ATOM (Symbol s) -> pure $ JSSymbol s - ATOM (Int i) -> pure $ JSInt i - LIST xs -> translateList xs - -translateList :: [Expr] -> Either TransError JSExpr -translateList = \case - [] -> Left "translating empty list" - ATOM (Symbol s):xs - | Just f <- lookup s builtins -> - f xs - f:xs -> - JSFunCall <$> translateToJS f <*> traverse translateToJS xs - -``` - -`builtins` is a list of special cases to translate, like `lambda` and `let`. Every case gets the list of arguments for it, verify that its syntactically valid and translates it to the equivalent `JSExpr`. - -``` -type Builtin = [Expr] -> Either TransError JSExpr -type Builtins = [(Name, Builtin)] - -builtins :: Builtins -builtins = - [("lambda", transLambda) - ,("let", transLet) - ,("add", transBinOp "add" "+") - ,("mul", transBinOp "mul" "*") - ,("sub", transBinOp "sub" "-") - ,("div", transBinOp "div" "/") - ,("print", transPrint) - ] - -``` - -In our case, we treat built-in special forms as special and not first class, so will not be able to use them as first class functions and such. - -We'll translate a Lambda to an anonymous function: - -``` -transLambda :: [Expr] -> Either TransError JSExpr -transLambda = \case - [LIST vars, body] -> do - vars' <- traverse fromSymbol vars - JSLambda vars' <$> (JSReturn <$> translateToJS body) - - vars -> - Left $ unlines - ["Syntax error: unexpected arguments for lambda." - ,"expecting 2 arguments, the first is the list of vars and the second is the body of the lambda." - ,"In expression: " ++ show (LIST $ ATOM (Symbol "lambda") : vars) - ] - -fromSymbol :: Expr -> Either String Name -fromSymbol (ATOM (Symbol s)) = Right s -fromSymbol e = Left $ "cannot bind value to non symbol type: " ++ show e - -``` - -We'll translate let to a definition of a function with the relevant named arguments and call it with the values, Thus introducing the variables in that scope: - -``` -transLet :: [Expr] -> Either TransError JSExpr -transLet = \case - [LIST binds, body] -> do - (vars, vals) <- letParams binds - vars' <- traverse fromSymbol vars - JSFunCall . JSLambda vars' <$> (JSReturn <$> translateToJS body) <*> traverse translateToJS vals - where - letParams :: [Expr] -> Either Error ([Expr],[Expr]) - letParams = \case - [] -> pure ([],[]) - LIST [x,y] : rest -> ((x:) *** (y:)) <$> letParams rest - x : _ -> Left ("Unexpected argument in let list in expression:\n" ++ printExpr x) - - vars -> - Left $ unlines - ["Syntax error: unexpected arguments for let." - ,"expecting 2 arguments, the first is the list of var/val pairs and the second is the let body." - ,"In expression:\n" ++ printExpr (LIST $ ATOM (Symbol "let") : vars) - ] -``` - -We'll translate an operation that can work on multiple arguments to a chain of binary operations. For example: `(add 1 2 3)` will become `1 + (2 + 3)` - -``` -transBinOp :: Name -> Name -> [Expr] -> Either TransError JSExpr -transBinOp f _ [] = Left $ "Syntax error: '" ++ f ++ "' expected at least 1 argument, got: 0" -transBinOp _ _ [x] = translateToJS x -transBinOp _ f list = foldl1 (JSBinOp f) <$> traverse translateToJS list -``` - -And we'll translate a `print` as a call to `console.log` - -``` -transPrint :: [Expr] -> Either TransError JSExpr -transPrint [expr] = JSFunCall (JSSymbol "console.log") . (:[]) <$> translateToJS expr -transPrint xs = Left $ "Syntax error. print expected 1 arguments, got: " ++ show (length xs) - -``` - -Notice that we could have skipped verifying the syntax if we'd parse those as special cases of `Expr`. - -* _Exercise 1_ : Translate `Program` to `JSProgram` - -* _Exercise 2_ : add a special case for `if Expr Expr Expr` and translate it to the `JSIf` case you implemented in the last exercise - -### 7\. Glue it all together - -Finally, we are going to glue this all together. We'll: - -1. Read a file - -2. Parse it to `Expr` - -3. Translate it to `JSExpr` - -4. Emit JavaScript code to the standard output - -We'll also enable a few flags for testing: - -* `--e` will parse and print the abstract representation of the expression (`Expr`) - -* `--pp` will parse and pretty print - -* `--jse` will parse, translate and print the abstract representation of the resulting JS (`JSExpr`) - -* `--ppc` will parse, pretty print and compile - -``` -main :: IO () -main = getArgs >>= \case - [file] -> - printCompile =<< readFile file - ["--e",file] -> - either putStrLn print . runExprParser "--e" =<< readFile file - ["--pp",file] -> - either putStrLn (putStrLn . printExpr) . runExprParser "--pp" =<< readFile file - ["--jse",file] -> - either print (either putStrLn print . translateToJS) . runExprParser "--jse" =<< readFile file - ["--ppc",file] -> - either putStrLn (either putStrLn putStrLn) . fmap (compile . printExpr) . runExprParser "--ppc" =<< readFile file - _ -> - putStrLn $ unlines - ["Usage: runghc Main.hs [ --e, --pp, --jse, --ppc ] " - ,"--e print the Expr" - ,"--pp pretty print Expr" - ,"--jse print the JSExpr" - ,"--ppc pretty print Expr and then compile" - ] - -printCompile :: String -> IO () -printCompile = either putStrLn putStrLn . compile - -compile :: String -> Either Error String -compile str = printJSExpr False 0 <$> (translateToJS =<< runExprParser "compile" str) - -``` - -That's it. We have a compiler from our language to JS. Again, you can view the full source file [here][9]. - -Running our compiler with the example from the first section yields this JavaScript code: - -``` -$ runhaskell Lisp.hs example.lsp -(function(compose, square, add1) { - return (console.log)(((compose)(square, add1))(5)); -})(function(f, g) { - return function(x) { - return (f)((g)(x)); - }; -}, function(x) { - return (x * x); -}, function(x) { - return (x + 1); -}) -``` - -If you have node.js installed on your computer, you can run this code by running: - -``` -$ runhaskell Lisp.hs example.lsp | node -p -36 -undefined -``` - -* _Final exercise_ : instead of compiling an expression, compile a program of multiple expressions. - --------------------------------------------------------------------------------- - -via: https://gilmi.me/blog/post/2016/10/14/lisp-to-js - -作者:[ Gil Mizrahi ][a] -选题:[oska874][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://gilmi.me/home -[b]:https://github.com/oska874 -[1]:https://gilmi.me/blog/authors/Gil -[2]:https://gilmi.me/blog/tags/compilers -[3]:https://gilmi.me/blog/tags/fp -[4]:https://gilmi.me/blog/tags/haskell -[5]:https://gilmi.me/blog/tags/lisp -[6]:https://gilmi.me/blog/tags/parsing -[7]:https://gist.github.com/soupi/d4ff0727ccb739045fad6cdf533ca7dd -[8]:https://mrkkrp.github.io/megaparsec/ -[9]:https://gist.github.com/soupi/d4ff0727ccb739045fad6cdf533ca7dd -[10]:https://gilmi.me/blog/post/2016/10/14/lisp-to-js diff --git a/translated/tech/20161014 Compiling Lisp to JavaScript From Scratch in 350 LOC.md b/translated/tech/20161014 Compiling Lisp to JavaScript From Scratch in 350 LOC.md new file mode 100644 index 0000000000..2b3a558191 --- /dev/null +++ b/translated/tech/20161014 Compiling Lisp to JavaScript From Scratch in 350 LOC.md @@ -0,0 +1,637 @@ +# 用 350 行代码从零开始,将 Lisp 编译成 JavaScript + +我们将会在本篇文章中看到从零开始实现的编译器,将简单的类 LISP 计算语言编译成 JavaScript。完整的源代码在 [这里][7]. + +我们将会: + +1. 自定义语言,并用它编写一个简单的程序 + +2. 实现一个简单的解析器组合器 + +3. 为该语言实现一个解析器 + +4. 为该语言实现一个美观的打印器 + +5. 为我们的需求定义 JavaScript 的一个子集 + +6. 实现代码转译器,将代码转译成我们定义的 JavaScript 子集 + +7. 把所有东西整合在一起 + +开始吧! + +### 1. 定义语言 + +lisps 最迷人的地方在于,它们的语法就是树状表示的,这就是这门语言很容易解析的原因。我们很快就能接触到它。但首先让我们把自己的语言定义好。关于我们语言的语法的范式(BNF)描述如下: + +``` +program ::= expr +expr ::= | | ([]) +``` + +基本上,我们可以在该语言的最顶层定义表达式并对其进行运算。表达式由一个整数(比如 `5`)、一个变量(比如 `x`)或者一个表达式列表(比如 `(add x 1)`)组成。 + +整数对应它本身的值,变量对应它在当前环境中绑定的值,表达式列表对应一个函数调用,该列表的第一个参数是相应的函数,剩下的表达式是传递给这个函数的参数。 + +该语言中,我们保留一些内建的特殊形式,这样我们就能做一些更有意思的事情: + +* let 表达式使我们可以在它的 body 环境中引入新的变量。语法如下: + +``` +let ::= (let ([]) ) +letargs ::= ( ) +body ::= +``` + +* lambda 表达式:也就是匿名函数定义。语法如下: + +``` +lambda ::= (lambda ([]) ) +``` + +还有一些内建函数: `add`、`mul`、`sub`、`div` 和 `print`。 + +让我们看看用我们这门语言编写的入门示例程序: + +``` +(let + ((compose + (lambda (f g) + (lambda (x) (f (g x))))) + (square + (lambda (x) (mul x x))) + (add1 + (lambda (x) (add x 1)))) + (print ((compose square add1) 5))) +``` + +这个程序定义了 3 个函数:`compose`、`square` 和 `add1`。然后将计算结果的值 `((compose square add1) 5)` 输出出来。 + +我相信了解这门语言,这些信息就足够了。开始实现它吧。 + +在 Haskell 中,我们可以这样定义语言: + +``` +type Name = String + +data Expr + = ATOM Atom + | LIST [Expr] + deriving (Eq, Read, Show) + +data Atom + = Int Int + | Symbol Name + deriving (Eq, Read, Show) +``` + +我们可以解析用该语言用 `Expr` 定义的程序。而且,这里我们添加了新数据类型 `Eq`、`Read` 和 `Show` 等实例用于测试和调试。你能够在 REPL 中使用这些数据类型,验证它们确实有用。 + +我们不在语法中定义 `lambda`、`let` 或其它的内建函数,原因在于,当前情况下我们没必要用到这些东西。这些函数仅仅是 `LIST` (表达式列表)的更加特殊的用例。所以我决定将它放到后面的部分。 + +一般来说你想要在抽象语法中定义这些特殊用例 —— 用于改进错误信息、禁用静态分析和优化等等,但在这里我们不会这样做,对我们来说这些已经足够了。 + +另一件你想做的事情可能是在语法中添加一些注释信息。比如定位:`Expr` 是来自哪个文件的,具体到这个文件的哪一行哪一列。你可以在后面的阶段中使用这一特性,打印出错误定位,即使它们不是处于解析阶段。 + +* _练习 1_:添加一个 `Program` 数据类型,可以按顺序包含多个 `Expr` + +* _练习 2_:向语法树中添加一个定位注解。 + +### 2. 实现一个简单的解析器组合库 + +我们要做的第一件事情是定义一个嵌入式领域专用语言(Embedded Domain Specific Language 或者 EDSL),我们会用它来定义我们的语言解析器。这常常被称为解析器组合库。我们做这件事完全是出于学习的目的,Haskell 里有很好的解析库,在实际构建软件或者进行实验时,你应该使用它们。[megaparsec][8] 就是这样的一个库。 + +首先我们来谈谈解析库的实现的思路。本质上,我们的解析器就是一个函数,接受一些输入,可能会读取输入的一些或全部内容,然后返回解析出来的值和无法解析的输入部分,或者在解析失败时抛出异常。我们把它写出来。 + +``` +newtype Parser a + = Parser (ParseString -> Either ParseError (a, ParseString)) + +data ParseString + = ParseString Name (Int, Int) String + +data ParseError + = ParseError ParseString Error + +type Error = String + +``` + +这里我们定义了三个主要的新类型。 + +第一个,`Parser a` 是之前讨论的解析函数。 + +第二个,`ParseString` 是我们的输入或携带的状态。它有三个重要的部分: + +* `Name`: 这是源的名字 + +* `(Int, Int)`: 这是源的当前位置 + +* `String`: 这是等待解析的字符串 + +第三个,`ParseError` 包含了解析器的当前状态和一个错误信息。 + +现在我们想让这个解析器更灵活,我们将会定义一些常用类型的实例。这些实例让我们能够将小巧的解析器和复杂的解析器结合在一起(因此它的名字叫做 “解析器组合器”)。 + +第一个是 `Functor` 实例。我们需要 `Functor` 实例,因为我们要能够对解析值应用函数从而使用不同的解析器。当我们定义自己语言的解析器时,我们将会看到关于它的示例。 + +``` +instance Functor Parser where + fmap f (Parser parser) = + Parser (\str -> first f <$> parser str) +``` + +第二个是 `Applicative` 实例。该实例的常见用例是在多个解析器中实现一个纯函数。 + +``` +instance Applicative Parser where + pure x = Parser (\str -> Right (x, str)) + (Parser p1) <*> (Parser p2) = + Parser $ + \str -> do + (f, rest) <- p1 str + (x, rest') <- p2 rest + pure (f x, rest') + +``` + +(注意:_我们还会实现一个 Monad 实例,这样我们才能使用符号_) + +第三个是 `Alternative` 实例。万一前面的解析器解析失败了,我们要能够提供一个备用的解析器。 + +``` +instance Alternative Parser where + empty = Parser (`throwErr` "Failed consuming input") + (Parser p1) <|> (Parser p2) = + Parser $ + \pstr -> case p1 pstr of + Right result -> Right result + Left _ -> p2 pstr +``` + +第四个是 `Monad` 实例。这样我们就能链接解析器。 + +``` +instance Monad Parser where + (Parser p1) >>= f = + Parser $ + \str -> case p1 str of + Left err -> Left err + Right (rs, rest) -> + case f rs of + Parser parser -> parser rest + +``` + +接下来,让我们定义一种的方式,用于运行解析器和防止失败的助手函数: + +``` + +runParser :: String -> String -> Parser a -> Either ParseError (a, ParseString) +runParser name str (Parser parser) = parser $ ParseString name (0,0) str + +throwErr :: ParseString -> String -> Either ParseError a +throwErr ps@(ParseString name (row,col) _) errMsg = + Left $ ParseError ps $ unlines + [ "*** " ++ name ++ ": " ++ errMsg + , "* On row " ++ show row ++ ", column " ++ show col ++ "." + ] + +``` + +现在我们将会开始实现组合器,这是 EDSL 的 API,也是它的核心。 + +首先,我们会定义 `oneOf`。如果输入列表中的字符后面还有字符的话,`oneOf` 将会成功,否则就会失败。 + +``` +oneOf :: [Char] -> Parser Char +oneOf chars = + Parser $ \case + ps@(ParseString name (row, col) str) -> + case str of + [] -> throwErr ps "Cannot read character of empty string" + (c:cs) -> + if c `elem` chars + then Right (c, ParseString name (row, col+1) cs) + else throwErr ps $ unlines ["Unexpected character " ++ [c], "Expecting one of: " ++ show chars] +``` + +`optional` 将会抛出异常,停止解析器。失败时它仅仅会返回 `Nothing`。 + +``` +optional :: Parser a -> Parser (Maybe a) +optional (Parser parser) = + Parser $ + \pstr -> case parser pstr of + Left _ -> Right (Nothing, pstr) + Right (x, rest) -> Right (Just x, rest) +``` + +`many` 将会试着重复运行解析器,直到失败。当它完成的时候,会返回成功运行的解析器列表。`many1` 做的事情是一样的,但解析失败时它至少会抛出一次异常。 + +``` +many :: Parser a -> Parser [a] +many parser = go [] + where go cs = (parser >>= \c -> go (c:cs)) <|> pure (reverse cs) + +many1 :: Parser a -> Parser [a] +many1 parser = + (:) <$> parser <*> many parser + +``` + +下面的这些解析器通过我们定义的组合器来实现一些特殊的解析器: + +``` +char :: Char -> Parser Char +char c = oneOf [c] + +string :: String -> Parser String +string = traverse char + +space :: Parser Char +space = oneOf " \n" + +spaces :: Parser String +spaces = many space + +spaces1 :: Parser String +spaces1 = many1 space + +withSpaces :: Parser a -> Parser a +withSpaces parser = + spaces *> parser <* spaces + +parens :: Parser a -> Parser a +parens parser = + (withSpaces $ char '(') + *> withSpaces parser + <* (spaces *> char ')') + +sepBy :: Parser a -> Parser b -> Parser [b] +sepBy sep parser = do + frst <- optional parser + rest <- many (sep *> parser) + pure $ maybe rest (:rest) frst + +``` + +现在为该门语言定义解析器所需要的所有东西都有了。 + +* _练习_ :实现一个 EOF(end of file/input,即文件或输入终止符)解析器组合器。 + +### 3. 为我们的语言实现解析器 + +我们会用自顶而下的方法定义解析器。 + +``` +parseExpr :: Parser Expr +parseExpr = fmap ATOM parseAtom <|> fmap LIST parseList + +parseList :: Parser [Expr] +parseList = parens $ sepBy spaces1 parseExpr + +parseAtom :: Parser Atom +parseAtom = parseSymbol <|> parseInt + +parseSymbol :: Parser Atom +parseSymbol = fmap Symbol parseName + +``` + +注意到这四个函数是在我们这门语言中属于高阶描述。这解释了为什么 Haskell 执行解析工作这么棒。在定义完高级部分后,我们还需要定义低级别的 `parseName` 和 `parseInt`。 + +我们能在这门语言中用什么字符作为名字呢?用小写的字母、数字和下划线吧,而且名字的第一个字符必须是字母。 + +``` +parseName :: Parser Name +parseName = do + c <- oneOf ['a'..'z'] + cs <- many $ oneOf $ ['a'..'z'] ++ "0123456789" ++ "_" + pure (c:cs) +``` + +整数是一系列数字,数字前面可能有负号 ‘-’: + +``` +parseInt :: Parser Atom +parseInt = do + sign <- optional $ char '-' + num <- many1 $ oneOf "0123456789" + let result = read $ maybe num (:num) sign of + pure $ Int result +``` + +最后,我们会定义用来运行解析器的函数,返回值可能是一个 `Expr` 或者是一条错误信息。 + +``` +runExprParser :: Name -> String -> Either String Expr +runExprParser name str = + case runParser name str (withSpaces parseExpr) of + Left (ParseError _ errMsg) -> Left errMsg + Right (result, _) -> Right result +``` + +* _练习 1_ :为第一节中定义的 `Program` 类型编写一个解析器 + +* _练习 2_ :用 Applicative 的形式重写 `parseName` + +* _练习 3_ :`parseInt` 可能出现溢出情况,找到处理它的方法,不要用 `read`。 + +### 4. 为这门语言实现一个更好看的输出器 + +我们还想做一件事,将我们的程序以源代码的形式打印出来。这对完善错误信息很有用。 + +``` +printExpr :: Expr -> String +printExpr = printExpr' False 0 + +printAtom :: Atom -> String +printAtom = \case + Symbol s -> s + Int i -> show i + +printExpr' :: Bool -> Int -> Expr -> String +printExpr' doindent level = \case + ATOM a -> indent (bool 0 level doindent) (printAtom a) + LIST (e:es) -> + indent (bool 0 level doindent) $ + concat + [ "(" + , printExpr' False (level + 1) e + , bool "\n" "" (null es) + , intercalate "\n" $ map (printExpr' True (level + 1)) es + , ")" + ] + +indent :: Int -> String -> String +indent tabs e = concat (replicate tabs " ") ++ e +``` + +* _练习_ :为第一节中定义的 `Program` 类型编写一个美观的输出器 + +好,目前为止我们写了近 200 行代码,这些代码一般叫做编译器的前端。我们还要写大概 150 行代码,用来执行三个额外的任务:我们需要根据需求定义一个 JS 的子集,定义一个将我们的语言转译成这个子集的转译器,最后把所有东西整合在一起。开始吧。 + +### 5. 根据需求定义 JavaScript 的子集 + +首先,我们要定义将要使用的 JavaScript 的子集: + +``` +data JSExpr + = JSInt Int + | JSSymbol Name + | JSBinOp JSBinOp JSExpr JSExpr + | JSLambda [Name] JSExpr + | JSFunCall JSExpr [JSExpr] + | JSReturn JSExpr + deriving (Eq, Show, Read) + +type JSBinOp = String +``` + +这个数据类型表示 JavaScript 表达式。我们有两个原子类型 `JSInt` 和 `JSSymbol`,它们是由我们这个语言中的 `Atom` 转译来的,我们用 `JSBinOp` 来表示二元操作,比如 `+` 或 `*`,用 `JSLambda` 来表示匿名函数,和我们语言中的 `lambda expression(lambda 表达式)` 一样,我们将会用 `JSFunCall` 来调用函数,用 `let` 来引入新名字,用 `JSReturn` 从函数中返回值,在 JavaScript 中是需要返回值的。 + +`JSExpr` 类型是对 JavaScript 表达式的 **抽象表示**。我们会把自己语言中表达式的抽象表示 `Expr` 转译成 JavaScript 表达式的抽象表示 `JSExpr`。但为了实现这个功能,我们需要实现 `JSExpr` ,并从这个抽象表示中生成 JavaScript 代码。我们将通过递归匹配 `JSExpr` 实现,将 JS 代码当作 `String` 来输出。这和我们在 `printExpr` 中做的基本上是一样的。我们还会追踪元素的作用域,这样我们才可以用合适的方式缩进生成的代码。 + +``` +printJSOp :: JSBinOp -> String +printJSOp op = op + +printJSExpr :: Bool -> Int -> JSExpr -> String +printJSExpr doindent tabs = \case + JSInt i -> show i + JSSymbol name -> name + JSLambda vars expr -> (if doindent then indent tabs else id) $ unlines + ["function(" ++ intercalate ", " vars ++ ") {" + ,indent (tabs+1) $ printJSExpr False (tabs+1) expr + ] ++ indent tabs "}" + JSBinOp op e1 e2 -> "(" ++ printJSExpr False tabs e1 ++ " " ++ printJSOp op ++ " " ++ printJSExpr False tabs e2 ++ ")" + JSFunCall f exprs -> "(" ++ printJSExpr False tabs f ++ ")(" ++ intercalate ", " (fmap (printJSExpr False tabs) exprs) ++ ")" + JSReturn expr -> (if doindent then indent tabs else id) $ "return " ++ printJSExpr False tabs expr ++ ";" +``` + +* _练习 1_ :添加 `JSProgram` 类型,它可以包含多个 `JSExpr` ,然后创建一个叫做 `printJSExprProgram` 的函数来生成代码。 + +* _练习 2_ :添加 `JSExpr` 的新类型:`JSIf`,并为其生成代码。 + +### 6. 实现到我们定义的 JavaScript 子集的代码转译器 + +我们快做完了。这一节将会创建函数,将 `Expr` 转译成 `JSExpr`。 + +基本思想很简单,我们会将 `ATOM` 转译成 `JSSymbol` 或者 `JSInt`,然后会将 `LIST` 转译成一个函数调用或者转译的特例。 + +``` +type TransError = String + +translateToJS :: Expr -> Either TransError JSExpr +translateToJS = \case + ATOM (Symbol s) -> pure $ JSSymbol s + ATOM (Int i) -> pure $ JSInt i + LIST xs -> translateList xs + +translateList :: [Expr] -> Either TransError JSExpr +translateList = \case + [] -> Left "translating empty list" + ATOM (Symbol s):xs + | Just f <- lookup s builtins -> + f xs + f:xs -> + JSFunCall <$> translateToJS f <*> traverse translateToJS xs + +``` + +`builtins` 是一系列要转译的特例,就像 `lambada` 和 `let`。每一种情况都可以获得一系列参数,验证它是否合乎语法规范,然后将其转译成等效的 `JSExpr`。 + +``` +type Builtin = [Expr] -> Either TransError JSExpr +type Builtins = [(Name, Builtin)] + +builtins :: Builtins +builtins = + [("lambda", transLambda) + ,("let", transLet) + ,("add", transBinOp "add" "+") + ,("mul", transBinOp "mul" "*") + ,("sub", transBinOp "sub" "-") + ,("div", transBinOp "div" "/") + ,("print", transPrint) + ] + +``` + +我们这种情况,会将内建的特殊形式当作特殊的、非第一类的进行对待,因此不可能将它们当作第一类函数。 + +我们会把 Lambda 表达式转译成一个匿名函数: + +``` +transLambda :: [Expr] -> Either TransError JSExpr +transLambda = \case + [LIST vars, body] -> do + vars' <- traverse fromSymbol vars + JSLambda vars' <$> (JSReturn <$> translateToJS body) + + vars -> + Left $ unlines + ["Syntax error: unexpected arguments for lambda." + ,"expecting 2 arguments, the first is the list of vars and the second is the body of the lambda." + ,"In expression: " ++ show (LIST $ ATOM (Symbol "lambda") : vars) + ] + +fromSymbol :: Expr -> Either String Name +fromSymbol (ATOM (Symbol s)) = Right s +fromSymbol e = Left $ "cannot bind value to non symbol type: " ++ show e + +``` + +我们会将 let 转译成带有相关名字参数的函数定义,然后带上参数调用函数,因此会在这一作用域中引入变量: + +``` +transLet :: [Expr] -> Either TransError JSExpr +transLet = \case + [LIST binds, body] -> do + (vars, vals) <- letParams binds + vars' <- traverse fromSymbol vars + JSFunCall . JSLambda vars' <$> (JSReturn <$> translateToJS body) <*> traverse translateToJS vals + where + letParams :: [Expr] -> Either Error ([Expr],[Expr]) + letParams = \case + [] -> pure ([],[]) + LIST [x,y] : rest -> ((x:) *** (y:)) <$> letParams rest + x : _ -> Left ("Unexpected argument in let list in expression:\n" ++ printExpr x) + + vars -> + Left $ unlines + ["Syntax error: unexpected arguments for let." + ,"expecting 2 arguments, the first is the list of var/val pairs and the second is the let body." + ,"In expression:\n" ++ printExpr (LIST $ ATOM (Symbol "let") : vars) + ] +``` + +我们会将可以在多个参数之间执行的操作符转译成一系列二元操作符。比如:`(add 1 2 3)` 将会变成 `1 + (2 + 3)`。 + +``` +transBinOp :: Name -> Name -> [Expr] -> Either TransError JSExpr +transBinOp f _ [] = Left $ "Syntax error: '" ++ f ++ "' expected at least 1 argument, got: 0" +transBinOp _ _ [x] = translateToJS x +transBinOp _ f list = foldl1 (JSBinOp f) <$> traverse translateToJS list +``` + +然后我们会将 `print` 转换成对 `console.log` 的调用。 + +``` +transPrint :: [Expr] -> Either TransError JSExpr +transPrint [expr] = JSFunCall (JSSymbol "console.log") . (:[]) <$> translateToJS expr +transPrint xs = Left $ "Syntax error. print expected 1 arguments, got: " ++ show (length xs) + +``` + +注意,如果我们将这些代码当作 `Expr` 的特例进行解析,那我们就可能会跳过语法验证。 + +* _练习 1_ :将 `Program` 转译成 `JSProgram` + +* _练习 2_ :为 `if Expr Expr Expr` 添加一个特例,并将它转译成你在上一次练习中实现的 `JSIf` 条件语句。 + +### 7. 把所有东西整合到一起 + +最终,我们将会把所有东西整合到一起。我们会: + +1. 读取文件 + +2. 将文件解析成 `Expr` + +3. 将文件转译成 `JSExpr` + +4. 将 JavaScript 代码发送到标准输出流 + +我们还会启用一些用于测试的标志位: + +* `--e` 将进行解析并打印出表达式的抽象表示(`Expr`) + +* `--pp` 将进行解析,美化输出 + +* `--jse` 将进行解析、转译、并打印出生成的 JS 表达式(`JSExpr`)的抽象表示 + +* `--ppc` 将进行解析,美化输出并进行编译 + +``` +main :: IO () +main = getArgs >>= \case + [file] -> + printCompile =<< readFile file + ["--e",file] -> + either putStrLn print . runExprParser "--e" =<< readFile file + ["--pp",file] -> + either putStrLn (putStrLn . printExpr) . runExprParser "--pp" =<< readFile file + ["--jse",file] -> + either print (either putStrLn print . translateToJS) . runExprParser "--jse" =<< readFile file + ["--ppc",file] -> + either putStrLn (either putStrLn putStrLn) . fmap (compile . printExpr) . runExprParser "--ppc" =<< readFile file + _ -> + putStrLn $ unlines + ["Usage: runghc Main.hs [ --e, --pp, --jse, --ppc ] " + ,"--e print the Expr" + ,"--pp pretty print Expr" + ,"--jse print the JSExpr" + ,"--ppc pretty print Expr and then compile" + ] + +printCompile :: String -> IO () +printCompile = either putStrLn putStrLn . compile + +compile :: String -> Either Error String +compile str = printJSExpr False 0 <$> (translateToJS =<< runExprParser "compile" str) + +``` + +大功告成。将自己的语言编译到 JS 子集的编译器已经完成了。再说一次,你可以在 [这里][9] 看到完整的源文件。 + +用我们的编译器运行第一节的示例,产生的 JavaScript 代码如下: + +``` +$ runhaskell Lisp.hs example.lsp +(function(compose, square, add1) { + return (console.log)(((compose)(square, add1))(5)); +})(function(f, g) { + return function(x) { + return (f)((g)(x)); + }; +}, function(x) { + return (x * x); +}, function(x) { + return (x + 1); +}) +``` + +如果你在自己电脑上安装了 node.js,你可以用以下命令运行这段代码: + +``` +$ runhaskell Lisp.hs example.lsp | node -p +36 +undefined +``` + +* _最终练习_ : 编译有多个表达式的程序而非仅编译一个表达式。 + +-------------------------------------------------------------------------------- + +via: https://gilmi.me/blog/post/2016/10/14/lisp-to-js + +作者:[ Gil Mizrahi ][a] +选题:[oska874][b] +译者:[BriFuture](https://github.com/BriFuture) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://gilmi.me/home +[b]:https://github.com/oska874 +[1]:https://gilmi.me/blog/authors/Gil +[2]:https://gilmi.me/blog/tags/compilers +[3]:https://gilmi.me/blog/tags/fp +[4]:https://gilmi.me/blog/tags/haskell +[5]:https://gilmi.me/blog/tags/lisp +[6]:https://gilmi.me/blog/tags/parsing +[7]:https://gist.github.com/soupi/d4ff0727ccb739045fad6cdf533ca7dd +[8]:https://mrkkrp.github.io/megaparsec/ +[9]:https://gist.github.com/soupi/d4ff0727ccb739045fad6cdf533ca7dd +[10]:https://gilmi.me/blog/post/2016/10/14/lisp-to-js From 730be8ec06f597fc019acc034e6fa5da3e33a5cc Mon Sep 17 00:00:00 2001 From: David Chen Date: Sun, 21 Oct 2018 20:47:42 +0800 Subject: [PATCH 083/158] Translating --- ...180814 Top Linux developers- recommended programming books.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20180814 Top Linux developers- recommended programming books.md b/sources/tech/20180814 Top Linux developers- recommended programming books.md index d9337ed319..589fc8dc6e 100644 --- a/sources/tech/20180814 Top Linux developers- recommended programming books.md +++ b/sources/tech/20180814 Top Linux developers- recommended programming books.md @@ -1,3 +1,4 @@ +Translateing By DavidChenLiang Top Linux developers' recommended programming books ====== Without question, Linux was created by brilliant programmers who employed good computer science knowledge. Let the Linux programmers whose names you know share the books that got them started and the technology references they recommend for today's developers. How many of them have you read? From a86ece289b0a35a00c5c8b0ea45c25c638888c33 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 22 Oct 2018 08:28:30 +0800 Subject: [PATCH 084/158] PUB:20181003 Tips for listing files with ls at the Linux command line.md @geekpi --- ... Tips for listing files with ls at the Linux command line.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename {translated/tech => published}/20181003 Tips for listing files with ls at the Linux command line.md (98%) diff --git a/translated/tech/20181003 Tips for listing files with ls at the Linux command line.md b/published/20181003 Tips for listing files with ls at the Linux command line.md similarity index 98% rename from translated/tech/20181003 Tips for listing files with ls at the Linux command line.md rename to published/20181003 Tips for listing files with ls at the Linux command line.md index 110dd5f446..f35d00749e 100644 --- a/translated/tech/20181003 Tips for listing files with ls at the Linux command line.md +++ b/published/20181003 Tips for listing files with ls at the Linux command line.md @@ -1,7 +1,7 @@ 在 Linux 命令行中使用 ls 列出文件的提示 ====== -学习一些 Linux `ls` 命令最有用的变化。 +> 学习一些 Linux `ls` 命令最有用的变化。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/button_push_open_keyboard_file_organize.png?itok=KlAsk1gx) From 4714094a8bcf8fc9f5604c89a2861379cabaa7bb Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 22 Oct 2018 08:44:53 +0800 Subject: [PATCH 085/158] PRF:20181004 PyTorch 1.0 Preview Release- Facebook-s newest Open Source AI.md @distant1219 --- ...lease- Facebook-s newest Open Source AI.md | 42 ++++++++----------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/translated/tech/20181004 PyTorch 1.0 Preview Release- Facebook-s newest Open Source AI.md b/translated/tech/20181004 PyTorch 1.0 Preview Release- Facebook-s newest Open Source AI.md index 8bc95210a0..b74eca38bf 100644 --- a/translated/tech/20181004 PyTorch 1.0 Preview Release- Facebook-s newest Open Source AI.md +++ b/translated/tech/20181004 PyTorch 1.0 Preview Release- Facebook-s newest Open Source AI.md @@ -1,38 +1,39 @@ -PyTorch 1.0 预览版发布: Facebook 最新 AI 开源框架 +PyTorch 1.0 预览版发布:Facebook 最新 AI 开源框架 ====== + Facebook 在人工智能项目中广泛使用自己的开源 AI 框架 PyTorch,最近,他们已经发布了 PyTorch 1.0 的预览版本。 -对于那些不熟悉的人, [PyTorch][1] 是一个基于 Python 的科学计算库。 +如果你尚不了解,[PyTorch][1] 是一个基于 Python 的科学计算库。 -PyTorch 利用 [GPUs 超强的运算能力 ][2] 来实现复杂的 [张量][3] 计算 和 [深度神经网络][4]。 因此, 它被世界各地的研究人员和开发人员广泛使用。 +PyTorch 利用 [GPU 超强的运算能力][2] 来实现复杂的 [张量][3] 计算 和 [深度神经网络][4]。 因此, 它被世界各地的研究人员和开发人员广泛使用。 -这一新的能够使用的 [预览版][5] 已在2018年10月2日周二旧金山举办的 [PyTorch 开发人员大会][6] 的[中途][7]宣布。 +这一新的可以投入使用的 [预览版][5] 已于 2018 年 10 月 2 日周二在旧金山 [The Midway][7] 举办的 [PyTorch 开发人员大会][6] 宣布。 ### PyTorch 1.0 候选版本的亮点 ![PyTorhc is Python based open source AI framework from Facebook][8] -候选版本中的一些主要新功能包括: +候选版本中的一些主要新功能包括: -#### 1\. JIT +#### 1、 JIT JIT 是一个编译工具集,使研究和生产更加接近。 它包含一个基于 Python 语言的叫做 Torch Script 的脚本语言,也有能使现有代码与它自己兼容的方法。 -#### 2\. 全新的 torch.distributed 库: “C10D” +#### 2、 全新的 torch.distributed 库: “C10D” “C10D” 能够在不同的后端上启用异步操作, 并在较慢的网络上提高性能。 -#### 3\. C++ 前端 (实验性功能) +#### 3、 C++ 前端 (实验性功能) -虽然它被特别提到是一个不稳定的 API (预计在预发行版中), 这是一个 PyTorch 后端的纯 c++ 接口, 遵循 API 和建立的 Python 前端的体系结构,以实现高性能、 低延迟的研究和开发直接安装在硬件上的 c++ 应用程序。 +虽然它被特别提到是一个不稳定的 API (估计是在预发行版中), 这是一个 PyTorch 后端的纯 C++ 接口, 遵循 API 和建立的 Python 前端的体系结构,以实现高性能、低延迟的研究和开发直接安装在硬件上的 C++ 应用程序。 想要了解更多,可以在 GitHub 上查看完整的 [更新说明][9]。 -第一个PyTorch 1.0 的稳定版本将在夏季发布。 +第一个 PyTorch 1.0 的稳定版本将在夏季发布。(LCTT 译注:此信息可能有误) ### 在 Linux 上安装 PyTorch -为了安装 PyTorch v1.0rc0, 开发人员建议使用 [conda][10], 同时也可以按照[本地安装][11]所示,使用其他方法可以安装,所有必要的细节详见文档。 +为了安装 PyTorch v1.0rc0, 开发人员建议使用 [conda][10], 同时也可以按照[本地安装页面][11]所示,使用其他方法可以安装,所有必要的细节详见文档。 #### 前提 @@ -41,18 +42,16 @@ JIT 是一个编译工具集,使研究和生产更加接近。 它包含一个 * Python * [CUDA][12] (对于使用 Nvidia GPU 的用户) - - 我们已经知道[如何安装和使用 Pip][13],那就让我们来了解如何使用 Pip 安装 PyTorch。 请注意,PyTorch 具有 GPU 和仅限 CPU 的不同安装包。你应该安装一个适合你硬件的安装包。 + #### 安装 PyTorch 的旧版本和稳定版 如果你想在 GPU 机器上安装稳定版(0.4 版本),使用: ``` pip install torch torchvision - ``` 使用以下两个命令,来安装仅用于 CPU 的稳定版: @@ -60,7 +59,6 @@ pip install torch torchvision ``` pip install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp27-cp27mu-linux_x86_64.whl pip install torchvision - ``` #### 安装 PyTorch 1.0 候选版本 @@ -69,21 +67,19 @@ pip install torchvision ``` pip install torch_nightly -f https://download.pytorch.org/whl/nightly/cu92/torch_nightly.html - ``` -如果没有GPU,并且更喜欢使用 仅限CPU 版本,使用如下命令: +如果没有GPU,并且更喜欢使用 仅限 CPU 版本,使用如下命令: ``` pip install torch_nightly -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html - ``` #### 验证 PyTorch 安装 使用如下简单的命令,启动终端上的 python 控制台: + ``` python - ``` 现在,按行输入下面的示例代码以验证您的安装: @@ -93,7 +89,6 @@ from __future__ import print_function import torch x = torch.rand(5, 3) print(x) - ``` 你应该得到如下输出: @@ -104,7 +99,6 @@ tensor([[0.3380, 0.3845, 0.3217], [0.2979, 0.7141, 0.9069], [0.1449, 0.1132, 0.1375], [0.4675, 0.3947, 0.1426]]) - ``` 若要检查是否可以使用 PyTorch 的 GPU 功能, 可以使用以下示例代码: @@ -112,18 +106,18 @@ tensor([[0.3380, 0.3845, 0.3217], ``` import torch torch.cuda.is_available() - ``` 输出结果应该是: ``` True - ``` + 支持 PyTorch 的 AMD GPU 仍在开发中, 因此, 尚未按[报告][14]提供完整的测试覆盖,如果您有 AMD GPU ,请在[这里][15]提出建议。 现在让我们来看看一些广泛使用 PyTorch 的研究项目: + ### 基于 PyTorch 的持续研究项目 * [Detectron][16]: Facebook AI 研究院的软件系统, 可以智能地进行对象检测和分类。它之前是基于 Caffe2 的。今年早些时候,Caffe2 和 PyTorch [合力][17]创建了一个研究 + 生产的 PyTorch 1.0 @@ -144,7 +138,7 @@ via: https://itsfoss.com/pytorch-open-source-ai-framework/ 作者:[Avimanyu Bandyopadhyay][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 02ae0aec225f3050df1042989410a433e23e3384 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 22 Oct 2018 08:45:16 +0800 Subject: [PATCH 086/158] PUB: 20181005 Open Source Logging Tools for Linux.md @distant1219 https://linux.cn/article-10140-1.html --- .../20181005 Open Source Logging Tools for Linux.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20181005 Open Source Logging Tools for Linux.md (100%) diff --git a/translated/tech/20181005 Open Source Logging Tools for Linux.md b/published/20181005 Open Source Logging Tools for Linux.md similarity index 100% rename from translated/tech/20181005 Open Source Logging Tools for Linux.md rename to published/20181005 Open Source Logging Tools for Linux.md From 0ff1fd49472231b22a8db890122d50afa6c614ba Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 22 Oct 2018 08:55:23 +0800 Subject: [PATCH 087/158] translated --- ... 11 applications you never knew existed.md | 60 ------------------- ... 11 applications you never knew existed.md | 58 ++++++++++++++++++ 2 files changed, 58 insertions(+), 60 deletions(-) delete mode 100644 sources/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md create mode 100644 translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md diff --git a/sources/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md b/sources/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md deleted file mode 100644 index 60b7546c44..0000000000 --- a/sources/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md +++ /dev/null @@ -1,60 +0,0 @@ -translating---geekpi - -Happy birthday, KDE: 11 applications you never knew existed -====== -Which fun or quirky app do you need today? -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_DebucketizeOrgChart_A.png?itok=RB3WBeQQ) - -The Linux desktop environment KDE celebrates its 22nd anniversary on October 14 this year. There are a gazillion* applications created by the KDE community of users, many of which provide fun and quirky services. We perused the list and picked out 11 applications you might like to know exist. - -*Not really, but [there are a lot][1]. - -### 11 KDE applications you never knew existed - -1\. [KTeaTime][2] is a timer for steeping tea. Set it by choosing the type of tea you are drinking—green, black, herbal, etc.—and the timer will ding when it's ready to remove the tea bag and drink. - -2\. [KTux][3] is just a screensaver... or is it? Tux is flying in outer space in his green spaceship. - -3\. [Blinken][4] is a memory game based on Simon Says, an electronic game released in 1978. Players are challenged to remember sequences of increasing length. - -4\. [Tellico][5] is a collection manager for organizing your favorite hobby. Maybe you still collect baseball cards. Maybe you're part of a wine club. Maybe you're a serious bookworm. Maybe all three! - -5\. [KRecipes][6] is **not** a simple recipe manager. It's got a lot going on! Shopping lists, nutrient analysis, advanced search, recipe ratings, import/export various formats, and more. - -6\. [KHangMan][7] is based on the classic game Hangman where you guess the word letter by letter. This game is available in several languages, and it can be used to improve your learning of another language. It has four categories, one of which is "animals" which is great for kids. - -7\. [KLettres][8] is another app that may help you learn a new language. It teaches the alphabet and challenges the user to read and pronounce syllables. - -8\. [KDiamond][9] is similar to Bejeweled or other single player puzzle games where the goal of the game is to build lines of a certain number of the same type of jewel or object. In this case, diamonds. - -9\. [KolourPaint][10] is a very simple editing tool for your images or app for creating simple vectors. - -10\. [Kiriki][11] is a dice game for 2-6 players similar to Yahtzee. - -11\. [RSIBreak][12] doesn't start with a K. What!? It starts with an "RSI" for "Repetitive Strain Injury," which can occur from working for long hours, day in and day out, with a mouse and keyboard. This app reminds you to take breaks and can be personalized to meet your needs. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/10/kde-applications - -作者:[Opensource.com][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com -[b]: https://github.com/lujun9972 -[1]: https://www.kde.org/applications/ -[2]: https://www.kde.org/applications/games/kteatime/ -[3]: https://userbase.kde.org/KTux -[4]: https://www.kde.org/applications/education/blinken -[5]: http://tellico-project.org/ -[6]: https://www.kde.org/applications/utilities/krecipes/ -[7]: https://edu.kde.org/khangman/ -[8]: https://edu.kde.org/klettres/ -[9]: https://games.kde.org/game.php?game=kdiamond -[10]: https://www.kde.org/applications/graphics/kolourpaint/ -[11]: https://www.kde.org/applications/games/kiriki/ -[12]: https://userbase.kde.org/RSIBreak diff --git a/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md b/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md new file mode 100644 index 0000000000..4a77fca3dd --- /dev/null +++ b/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md @@ -0,0 +1,58 @@ +生日快乐,KDE:你从不知道的 11 个应用 +====== +你今天需要哪种有趣或奇特的应用? +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_DebucketizeOrgChart_A.png?itok=RB3WBeQQ) + +Linux 桌面环境 KDE 将于今年 10 月 14 日庆祝诞生 22 周年。KDE 社区用户创建了大量应用,它们很多都提供有趣和奇特的服务。我们仔细看了该列表,并挑选出了你可能想了解的 11 个应用。 + +没有很多,但[也有不少][1]。 + +### 11 个你从没了解的 KDE 应用 + +1\. [KTeaTime][2] 是一个泡茶计时器。选择你正在饮用的茶的类型 - 绿茶、红茶、凉茶等 - 当可以取出茶包来饮用时,计时器将会响。 + +2\. [KTux][3] 就是一个屏保程序......是么?Tux 用他的绿色飞船在外太空飞行。 + +3\. [Blinken][4] 是一款基于 Simon Says 的记忆游戏,这是一个 1978 年发布的电子游戏。玩家们在记住长度增加的序列时会有挑战。 + +4\. [Tellico][5] 是一个收集管理器,用于组织你最喜欢的爱好。也许你还在收集棒球卡。也许你是红酒俱乐部的一员。也许你是一个严肃的书虫。也许三个都是! + +5\. [KRecipes][6] **不是** 简单的食谱管理器。它还有很多其他功能!购物清单、营养素分析、高级搜索、菜谱评级、导入/导出各种格式等。 + +6\. [KHangMan][7] 基于经典游戏 Hangman,你可以按逐个字母猜测单词。这个游戏有多种语言版本,这可以用来改善你学习另一种语言。它有四个分类,其中一个是“动物”,非常适合孩子。 + +7\. [KLettres][8] 是另一款可以帮助你学习新语言的应用。它教授字母表并挑战用户阅读和发音音节。 + +8\. [KDiamond][9] 类似于宝石迷阵或其他单人益智游戏,其中游戏的目标是搭建一定数量的相同类型的宝石或物体的行。这里是钻石。 + +9\. [KolourPaint][10] 是一个非常简单的图像编辑工具,也可以用于创建简单的矢量图形。 + +10\. [Kiriki][11] 是一款类似于 Yahtzee 的 2-6 名玩家的骰子游戏。 + +11\. [RSIBreak][12] 没有以 K 开头。什么!?它以“RSI”开头代表“重复性劳损” (Repetitive Strain Injury),这会在日复一日长时间使用鼠标和键盘后发生。这个应用会提醒你休息,并可以个性化,以满足你的需求。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/kde-applications + +作者:[Opensource.com][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com +[b]: https://github.com/lujun9972 +[1]: https://www.kde.org/applications/ +[2]: https://www.kde.org/applications/games/kteatime/ +[3]: https://userbase.kde.org/KTux +[4]: https://www.kde.org/applications/education/blinken +[5]: http://tellico-project.org/ +[6]: https://www.kde.org/applications/utilities/krecipes/ +[7]: https://edu.kde.org/khangman/ +[8]: https://edu.kde.org/klettres/ +[9]: https://games.kde.org/game.php?game=kdiamond +[10]: https://www.kde.org/applications/graphics/kolourpaint/ +[11]: https://www.kde.org/applications/games/kiriki/ +[12]: https://userbase.kde.org/RSIBreak From 9389dac23247deb5761555ab00b820eb5ff6a8a7 Mon Sep 17 00:00:00 2001 From: pityonline Date: Sat, 20 Oct 2018 00:23:32 +0800 Subject: [PATCH 088/158] =?UTF-8?q?PRF:=20#10688=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 --- ...ration between developers and designers.md | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/translated/talk/20180502 9 ways to improve collaboration between developers and designers.md b/translated/talk/20180502 9 ways to improve collaboration between developers and designers.md index fe53452dd8..5c18d6c307 100644 --- a/translated/talk/20180502 9 ways to improve collaboration between developers and designers.md +++ b/translated/talk/20180502 9 ways to improve collaboration between developers and designers.md @@ -1,4 +1,4 @@ -9 个方法,提升开发者与设计师之间的协作 +9 个提升开发者与设计师协作的方法 ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUS_consensuscollab1.png?itok=ULQdGjlV) @@ -9,45 +9,45 @@ 两边都有自己的成见。工程师经常认为设计师们古怪不理性,而设计师也认为工程师们死板要求高。在一天的工作快要结束时,情况会变得更加微妙。设计师和开发者们的命运永远交织在一起。 -做到以下九件事,便可以增强他们之间的合作 +做到以下九件事,便可以改进他们之间的合作。 -### 1\. 首先,说实在的,打破壁垒。 +### 1. 首先,说实在的,打破壁垒 -几乎每一个行业都有“迷惑之墙wall of confusion”的模子。无论你干什么工作,拆除这堵墙的第一步就是要双方都认同它需要拆除。一旦所有的人都认为现有的流程效率低下,你就可以从其他想法中获得灵感,然后解决问题。 +几乎每一个行业都有“迷墙wall of confusion”的因子。无论你干什么工作,拆除这堵墙的第一步就是要双方都认同它需要拆除。一旦所有的人都认为现有的流程效率低下,你就可以从其它想法中获得灵感,然后解决问题。 -### 2\. 学会共情 +### 2. 学会共情 -在撸起袖子开始干之前,休息一下。这是团队建设的重要的交汇点。一个时机去认识到:我们都是成人,我们都有自己的优点与缺点,更重要的是,我们是一个团队。围绕工作流程与工作效率的讨论会经常发生,因此在开始之前,建立一个信任与协作的基础至关重要。 +在撸起袖子开始干之前,先等一下。这是团队建设的重要的交汇点,也是建立共同认知的时机:我们都是成人,我们都有自己的优点与缺点,更重要的是,我们是一个团队。围绕工作流程与工作效率的讨论会经常发生,因此在开始之前,建立一个信任与协作的基础至关重要。 -### 3\. 认识差异 +### 3. 认识差异 设计师和开发者从不同的角度攻克问题。对于相同的问题,设计师会追求更好的效果,而开发者会寻求更高的效率。这两种观点不必互相排斥。谈判和妥协的余地很大,并且在二者之间必然存在一个用户满意度最佳的中点。 -### 4\. 拥抱共性 +### 4. 拥抱共性 -这一切都是与工作流程相关的。持续集成Continuous Integration/持续交付Continuous Delivery,scrum,agille 等等,都基本上说了一件事:构思,迭代,考察,重复。迭代和重复是两种工作的相同点。因此,不再让开发周期紧跟设计周期,而是同时并行地运行它们,这样会更有意义。同步周期Syncing cycles允许团队在每一步上交流、协作、互相影响。 +这一切都是与工作流程相关的。持续集成Continuous Integration/持续交付Continuous Delivery,scrum,agile 等等,都基本上说了一件事:构思,迭代,考察,重复。迭代和重复是两种工作的相同点。因此,不再让开发周期紧跟设计周期,而是同时并行地运行它们,这样会更有意义。同步周期Syncing cycles允许团队在每个环节交流、协作、互相影响。 -### 5\. 管理期望 +### 5. 管理期望 一切冲突的起因一言以蔽之:期望不符。因此,防止系统性分裂的简单办法就是通过确保团队成员在说之前先想、在做之前先说来管理期望。设定的期望往往会通过日常对话不断演变。强迫团队通过开会以达到其效果可能会适得其反。 -### 6\. 按需开会 +### 6. 按需开会 -只在工作开始和工作结束开一次会远远不够。但也不意味着每天或每周都要开会。定期开会也可能会适得其反。试着按需开会吧。即兴会议可能会发生很棒的事情,即使是在开水房。如果你的团队是分散式的或者甚至有一名远程员工,视频会议,文本聊天或者打电话都是开会的好方法。团队中的每人都有多种方式互相沟通,这一点非常重要。 +只在工作开始和工作结束开一次会远远不够。但也不意味着每天或每周都要开会。定期开会也可能会适得其反。试着按需开会吧。即兴会议,即使是员工闲聊,也可能会发生很棒的事情。如果你的团队是分散式的或者甚至有一名远程员工,视频会议,文本聊天或者打电话都是开会的好方法。团队中的每人都有多种方式互相沟通,这一点非常重要。 -### 7\. 建立词库 +### 7. 建立词库 -设计师和开发者有时候对相似的想法有着不同的术语,就像把猫叫了个咪。毕竟,所有人都用的惯比起术语的准确度和适应度更重要。 +设计师和开发者有时候对相似的想法有着不同的术语,就像把猫叫成喵。毕竟,比起术语的准确度和合适度来,大家统一说法才更重要。 -### 8\. 学会沟通 +### 8. 学会沟通 无论什么时候,团队中的每个人都有责任去维持一个有效的沟通。每个人都应该努力做到一字一板。 -### 9\. 不断改善 +### 9. 不断改善 仅一名团队成员就能破坏整个进度。全力以赴。如果每个人都不关心产品或目标,继续项目或者做出改变的动机就会出现问题。 -本文参考 [Designers and developers: Finding common ground for effective collaboration][2],演讲的作者将会出席在旧金山五月 8-10 号举办的[Red Hat Summit 2018][3]。[五月 7 号][3]注册将节省 500 美元。支付时使用优惠码 **OPEN18** 以获得更多折扣。 +本文参考[开发者与设计师: 找出有效合作的共同点][2],演讲的作者将会出席 5 月 8-10 号在旧金山举办的[红帽峰会 2018][3]。[5 月 7 号][3]注册将节省 500 美元。支付时使用优惠码 **OPEN18** 以获得更多折扣。 -------------------------------------------------------------------------------- @@ -56,11 +56,11 @@ via: https://opensource.com/article/18/5/9-ways-improve-collaboration-developers 作者:[Jason Brock][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[LuuMing](https://github.com/LuuMing) -校对:[校对者ID](https://github.com/校对者ID) +校对:[pityonline](https://github.com/pityonline) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 -[a]:https://opensource.com/users/jkbrock -[1]:https://opensource.com/users/lightguardjp -[2]:https://agenda.summit.redhat.com/SessionDetail.aspx?id=154267 -[3]:https://www.redhat.com/en/summit/2018 +[a]: https://opensource.com/users/jkbrock +[1]: https://opensource.com/users/lightguardjp +[2]: https://agenda.summit.redhat.com/SessionDetail.aspx?id=154267 +[3]: https://www.redhat.com/en/summit/2018 From a9c6c9a5475ba357476bb0157e805d87820a4bbb Mon Sep 17 00:00:00 2001 From: geekpi Date: Mon, 22 Oct 2018 09:05:21 +0800 Subject: [PATCH 089/158] translating --- .../20181012 How To Lock Virtual Console Sessions On Linux.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20181012 How To Lock Virtual Console Sessions On Linux.md b/sources/tech/20181012 How To Lock Virtual Console Sessions On Linux.md index 8ec111c32c..2fb0db2f85 100644 --- a/sources/tech/20181012 How To Lock Virtual Console Sessions On Linux.md +++ b/sources/tech/20181012 How To Lock Virtual Console Sessions On Linux.md @@ -1,3 +1,5 @@ +translating---geekpi + How To Lock Virtual Console Sessions On Linux ====== From cc1677f90214c9e4dad42ac2fc9eae89aa68189c Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 22 Oct 2018 10:54:30 +0800 Subject: [PATCH 090/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20To=20BeOS=20or=20?= =?UTF-8?q?not=20to=20BeOS,=20that=20is=20the=20Haiku?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... BeOS or not to BeOS, that is the Haiku.md | 151 ++++++++++++++++++ 1 file changed, 151 insertions(+) create mode 100644 sources/tech/20181019 To BeOS or not to BeOS, that is the Haiku.md diff --git a/sources/tech/20181019 To BeOS or not to BeOS, that is the Haiku.md b/sources/tech/20181019 To BeOS or not to BeOS, that is the Haiku.md new file mode 100644 index 0000000000..1533f6fa6d --- /dev/null +++ b/sources/tech/20181019 To BeOS or not to BeOS, that is the Haiku.md @@ -0,0 +1,151 @@ +To BeOS or not to BeOS, that is the Haiku +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/autumn-haiku-100.jpg?itok=RTSPZu9U) + +Back in 2001, a new operating system arrived that promised to change the way users worked with their computers. That platform was BeOS and I remember it well. What I remember most about it was the desktop, and how much it looked and felt like my favorite window manager (at the time) AfterStep. I also remember how awkward and overly complicated BeOS was to install and use. In fact, upon installation, it was never all too clear how to make the platform function well enough to use on a daily basis. That was fine, however, because BeOS seemed to live in a perpetual state of “alpha release.” + +That was then. This is very much now. + +Now we have haiku + +Bringing BeOS to life + +An AfterStep joy. + +No, Haiku has nothing to do with AfterStep, but it fit perfectly with the haiku meter, so work with me. + +The [Haiku][1] project released it’s R1 Alpha 4 six years ago. Back in September of 2018, it finally released it’s R1 Beta 1 and although it took them eons (in computer time), seeing Haiku installed (on a virtual machine) was worth the wait … even if only for the nostalgia aspect. The big difference between R1 Beta 1 and R1 Alpha 4 (and BeOS, for that matter), is that Haiku now works like a real operating system. It’s lighting fast (and I do mean fast), it finally enjoys a modicum of stability, and has a handful of useful apps. Before you get too excited, you’re not going to install Haiku and immediately become productive. In fact, the list of available apps is quite limiting (more on this later). Even so, Haiku is definitely worth installing, even if only to see how far the project has come. + +Speaking of which, let’s do just that. + +### Installing Haiku + +The installation isn’t quite as point and click as the standard Linux distribution. That doesn’t mean it’s a challenge. It’s not; in fact, the installation is handled completely through a GUI, so you won’t have to even touch the command line. + +To install Haiku, you must first [download an image][2]. Download this file into your ~/Downloads directory. This image will be in a compressed format, so once it’s downloaded you’ll need to decompress it. Open a terminal window and issue the command unzip ~/Downloads/haiku*.zip. A new directory will be created, called haiku-r1beta1XXX-anyboot (Where XXX is the architecture for your hardware). Inside that directory you’ll find the ISO image to be used for installation. + +For my purposes, I installed Haiku as a VirtualBox virtual machine. I highly recommend going the same route, as you don’t want to have to worry about hardware detection. Creating Haiku as a virtual machine doesn’t require any special setup (beyond the standard). Once the live image has booted, you’ll be asked if you want to run the installer or boot directly to the desktop (Figure 1). Click Run Installer to begin the process. + + +![Haiku installer][4] + +Figure 1: Selecting to run the Haiku installer. + +[Used with permission][5] + +The next window is nothing more than a warning that Haiku is beta software and informing you that the installer will make the Haiku partition bootable, but doesn’t integrate with your existing boot menu (in other words, it will not set up dual booting). In this window, click the Continue button. + +You will then be warned that no partitions have been found. Click the OK button, so you can create a partition table. In the remaining window (Figure 2), click the Set up partitions button. + +![Haiku][7] + +Figure 2: The Haiku Installer in action. + +[Used with permission][5] + +In the resulting window (Figure 3), select the partition to be used and then click Disk > Initialize > GUID Partition Map. You will be prompted to click Continue and then Write Changes. + +![target partition][9] + +Figure 3: Our target partition ready to be initialized. + +[Used with permission][5] + +Select the newly initialized partition and then click Partition > Format > Be File System. When prompted, click Continue. In the resulting window, leave everything default and click Initialize and then click Write changes. + +Close the DriveSetup window (click the square in the titlebar) to return to the Haiku Installer. You should now be able to select the newly formatted partition in the Onto drop-down (Figure 4). + +![partition][11] + +Figure 4: Selecting our partition for installation. + +[Used with permission][5] + +After selecting the partition, click Begin and the installation will start. Don’t blink, as the entire installation takes less than 30 seconds. You read that correctly—the installation of Haiku takes less than 30 seconds. When it finishes, click Restart to boot your newly installed Haiku OS. + +### Usage + +When Haiku boots, it’ll go directly to the desktop. There is no login screen (or even the means to log in). You’ll be greeted with a very simple desktop that includes a few clickable icons and what is called the Tracker(Figure 5). + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/haiku_5.jpg?itok=eNmbsFGV) + +The Tracker includes any minimized application and a desktop menu that gives you access to all of the installed applications. Left click on the leaf icon in the Tracker to reveal the desktop menu (Figure 6). + +![menu][13] + +Figure 6: The Haiku desktop menu. + +[Used with permission][5] + +From within the menu, click Applications and you’ll see all the available tools. In that menu you’ll find the likes of: + + * ActivityMonitor (Track system resources) + + * BePDF (PDF reader) + + * CodyCam (allows you to take pictures from a webcam) + + * DeskCalc (calculator) + + * Expander (unpack common archives) + + * HaikuDepot (app store) + + * Mail (email client) + + * MediaPlay (play audio files) + + * People (contact database) + + * PoorMan (simple web server) + + * SoftwareUpdater (update Haiku software) + + * StyledEdit (text editor) + + * Terminal (terminal emulator) + + * WebPositive (web browser) + + + + +You will find, in the HaikuDepot, a limited number of available applications. What you won’t find are many productivity tools. Missing are office suites, image editors, and more. What we have with this beta version of Haiku is not a replacement for your desktop, but a view into the work the developers have put into giving the now-defunct BoOS new life. Chances are you won’t spend too much time with Haiku, beyond kicking the tires. However, this blast from the past is certainly worth checking out. + +### A positive step forward + +Based on my experience with BeOS and the alpha of Haiku (all those years ago), the developers have taken a big, positive step forward. Hopefully, the next beta release won’t take as long and we might even see a final release in the coming years. Although Haiku won’t challenge the likes of Ubuntu, Mint, Arch, or Elementary OS, it could develop its own niche following. No matter its future, it’s good to see something new from the developers. Bravo to Haiku. + +Your OS is prime + +For a beta 2 release + +Make it so, my friends. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/2018/10/beos-or-not-beos-haiku + +作者:[Jack Wallen][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/jlwallen +[b]: https://github.com/lujun9972 +[1]: https://www.haiku-os.org/ +[2]: https://www.haiku-os.org/get-haiku +[3]: /files/images/haiku1jpg +[4]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/haiku_1.jpg?itok=PTTBoLCf (Haiku installer) +[5]: /licenses/category/used-permission +[6]: /files/images/haiku2jpg +[7]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/haiku_2.jpg?itok=NV1yavv_ (Haiku) +[8]: /files/images/haiku3jpg +[9]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/haiku_3.jpg?itok=XWBz6kVT (target partition) +[10]: /files/images/haiku4jpg +[11]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/haiku_4.jpg?itok=6RbuCbAx (partition) +[12]: /files/images/haiku6jpg +[13]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/haiku_6.jpg?itok=-mmzNBxa (menu) From 3d5bafd638ed6ad486da58a07b8b12281919f655 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 22 Oct 2018 10:59:01 +0800 Subject: [PATCH 091/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Edit=20your=20vid?= =?UTF-8?q?eos=20with=20Pitivi=20on=20Fedora?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Edit your videos with Pitivi on Fedora.md | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 sources/tech/20181019 Edit your videos with Pitivi on Fedora.md diff --git a/sources/tech/20181019 Edit your videos with Pitivi on Fedora.md b/sources/tech/20181019 Edit your videos with Pitivi on Fedora.md new file mode 100644 index 0000000000..ca70d286e0 --- /dev/null +++ b/sources/tech/20181019 Edit your videos with Pitivi on Fedora.md @@ -0,0 +1,53 @@ +Edit your videos with Pitivi on Fedora +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/10/pitivi-816x346.png) +Looking to produce a video of your adventures this weekend? There are many different options for editing videos out there. However, if you are looking for a video editor that is simple to pick up, and also available in the official Fedora Repositories, give [Pitivi][1] a go. + +Pitivi is an open source, non-linear video editor that uses the GStreamer framework. Out of the box on Fedora, Pitivi supports OGG Video, WebM, and a range of other formats. Additionally, more support for for video formats is available via gstreamer plugins. Pitivi is also tightly integrated with the GNOME Desktop, so the UI will feel at home among the other newer applications on Fedora Workstation. + +### Installing Pitivi on Fedora + +Pitivi is available in the Fedora Repositories. On Fedora Workstation, simply search and install Pitivi from the Software application. + +![][2] + +Alternatively, install Pitivi using the following command in the Terminal: + +``` +sudo dnf install pitivi +``` + +### Basic Editing + +Pitivi has a wide range of tools built-in to allow quick and effective editing of your clips. Simply import videos, audio, and images into the Pitivi media library, then drag them onto the timeline. Additionally, pitivi allows you to easily split, trim, and group parts of clips together, in addition to simple fade transitions on the timeline. + +![][3] + +### Transitions and Effects + +In addition to a basic fade between two clips, Pitivi also features a range of different transitions and wipes. Additionally, there are over a hundred effects that can be applied to either videos or audio to change how the media elements are played or displayed in your final presentation + +![][4] + +Pitivi also features a range of other great features, so be sure to check out the [tour][5] on their website for a full description of the features of the awesome Pitivi. + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/edit-your-videos-with-pitivi-on-fedora/ + +作者:[Ryan Lerch][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/introducing-flatpak/ +[b]: https://github.com/lujun9972 +[1]: http://www.pitivi.org/ +[2]: https://fedoramagazine.org/wp-content/uploads/2018/10/Screenshot-from-2018-10-19-14-46-12.png +[3]: https://fedoramagazine.org/wp-content/uploads/2018/10/Screenshot-from-2018-10-19-15-37-29.png +[4]: http://www.pitivi.org/i/screenshots/archive/0.94.jpg +[5]: http://www.pitivi.org/?go=tour From efdf6ffcfe0493e4a6cb5daa79237cdc5589e124 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 22 Oct 2018 11:11:46 +0800 Subject: [PATCH 092/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20use=20?= =?UTF-8?q?Pandoc=20to=20produce=20a=20research=20paper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... use Pandoc to produce a research paper.md | 341 ++++++++++++++++++ 1 file changed, 341 insertions(+) create mode 100644 sources/tech/20181019 How to use Pandoc to produce a research paper.md diff --git a/sources/tech/20181019 How to use Pandoc to produce a research paper.md b/sources/tech/20181019 How to use Pandoc to produce a research paper.md new file mode 100644 index 0000000000..50993cbf9f --- /dev/null +++ b/sources/tech/20181019 How to use Pandoc to produce a research paper.md @@ -0,0 +1,341 @@ +How to use Pandoc to produce a research paper +====== +Learn how to manage section references, figures, tables, and more in Markdown. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/life_paperclips.png?itok=j48op49T) + +This article takes a deep dive into how to produce a research paper using (mostly) [Markdown][1] syntax. We'll cover how to create and reference sections, figures (in Markdown and [LaTeX][2]) and bibliographies. We'll also discuss troublesome cases and why writing them in LaTeX is the right approach. + +### Research + +Research papers usually contain references to sections, figures, tables, and a bibliography. [Pandoc][3] by itself cannot easily cross-reference these, but it can leverage the [pandoc-crossref][4] filter to do the automatic numbering and cross-referencing of sections, figures, and tables. + +Let’s start by rewriting [an example of an educational research paper][5] originally written in LaTeX and rewrites it in Markdown (and some LaTeX) with Pandoc and pandoc-crossref. + +#### Adding and referencing sections + +Sections are automatically numbered and must be written using the Markdown heading H1. Subsections are written with subheadings H2-H4 (it is uncommon to need more than that). For example, to write a section titled “Implementation”, write `# Implementation {#sec:implementation}`, and Pandoc produces `3. Implementation` (or the corresponding numbered section). The title “Implementation” uses heading H1 and declares a label `{#sec:implementation}` that authors can use to refer to that section. To reference a section, type the `@` symbol followed by the label of the section and enclose it in square brackets: `[@sec:implementation]`. + +[In this paper][5], we find the following example: + +``` +we lack experience (consistency between TAs, [@sec:implementation]). +``` + +Pandoc produces: + +``` +we lack experience (consistency between TAs, Section 4). +``` + +Sections are numbered automatically (this is covered in the `Makefile` at the end of the article). To create unnumbered sections, type the title of the section, followed by `{-}`. For example, `### Designing a game for maintainability {-}` creates an unnumbered subsection with the title “Designing a game for maintainability”. + +#### Adding and referencing figures + +Adding and referencing a figure is similar to referencing a section and adding a Markdown image: + +``` +![Scatterplot matrix](data/scatterplots/RScatterplotMatrix2.png){#fig:scatter-matrix} +``` + +The line above tells Pandoc that there is a figure with the caption Scatterplot matrix and the path to the image is `data/scatterplots/RScatterplotMatrix2.png`. `{#fig:scatter-matrix}` declares the name that should be used to reference the figure. + +Here is an example of a figure reference from the example paper: + +``` +The boxes "Enjoy", "Grade" and "Motivation" ([@fig:scatter-matrix]) ... +``` + +Pandoc produces the following output: + +``` +The boxes "Enjoy", "Grade" and "Motivation" (Fig. 1) ... +``` + +#### Adding and referencing a bibliography + +Most research papers keep references in a BibTeX database file. In this example, this file is named [biblio.bib][6] and it contains all the references of the paper. Here is what this file looks like: + +``` +@inproceedings{wrigstad2017mastery, +    Author =       {Wrigstad, Tobias and Castegren, Elias}, +    Booktitle =    {SPLASH-E}, +    Title =        {Mastery Learning-Like Teaching with Achievements}, +    Year =         2017 +} + +@inproceedings{review-gamification-framework, +  Author =       {A. Mora and D. Riera and C. Gonzalez and J. Arnedo-Moreno}, +  Publisher =    {IEEE}, +  Booktitle =    {2015 7th International Conference on Games and Virtual Worlds +                  for Serious Applications (VS-Games)}, +  Doi =          {10.1109/VS-GAMES.2015.7295760}, +  Keywords =     {formal specification;serious games (computing);design +                  framework;formal design process;game components;game design +                  elements;gamification design frameworks;gamification-based +                  solutions;Bibliographies;Context;Design +                  methodology;Ethics;Games;Proposals}, +  Month =        {Sept}, +  Pages =        {1-8}, +  Title =        {A Literature Review of Gamification Design Frameworks}, +  Year =         2015, +  Bdsk-Url-1 =   {http://dx.doi.org/10.1109/VS-GAMES.2015.7295760} +} + +... +``` + +The first line, `@inproceedings{wrigstad2017mastery,`, declares the type of publication (`inproceedings`) and the label used to refer to that paper (`wrigstad2017mastery`). + +To cite the paper with its title, Mastery Learning-Like Teaching with Achievements, type: + +``` +the achievement-driven learning methodology [@wrigstad2017mastery] +``` + +Pandoc will output: + +``` +the achievement- driven learning methodology [30] +``` + +The paper we will produce includes a bibliography section with numbered references like these: + +![](https://opensource.com/sites/default/files/uploads/bibliography-example_0.png) + +Citing a collection of articles is easy: Simply cite each article, separating the labeled references using a semi-colon: `;`. If there are two labeled references—i.e., `SEABORN201514` and `gamification-leaderboard-benefits`—cite them together, like this: + +``` +Thus, the most important benefit is its potential to increase students' motivation + +and engagement [@SEABORN201514;@gamification-leaderboard-benefits]. +``` + +Pandoc will produce: + +``` +Thus, the most important benefit is its potential to increase students’ motivation + +and engagement [26, 28] +``` + +### Problematic cases + +A common problem involves objects that do not fit in the page. They then float to wherever they fit best, even if that position is not where the reader expects to see it. Since papers are easier to read when figures or tables appear close to where they are mentioned, we need to have some control over where these elements are placed. For this reason, I recommend the use of the `figure` LaTeX environment, which enables users to control the positioning of figures. + +Let’s take the figure example shown above: + +``` +![Scatterplot matrix](data/scatterplots/RScatterplotMatrix2.png){#fig:scatter-matrix} +``` + +And rewrite it in LaTeX: + +``` +\begin{figure}[t] +\includegraphics{data/scatterplots/RScatterplotMatrix2.png} +\caption{\label{fig:matrix}Scatterplot matrix} +\end{figure} +``` + +In LaTeX, the `[t]` option in the `figure` environment declares that the image should be placed at the top of the page. For more options, refer to the Wikibooks article [LaTex/Floats, Figures, and Captions][7]. + +### Producing the paper + +So far, we've covered how to add and reference (sub-)sections and figures and cite the bibliography—now let's review how to produce the research paper in PDF format. To generate the PDF, we will use Pandoc to generate a LaTeX file that can be compiled to the final PDF. We will also discuss how to generate the research paper in LaTeX using a customized template and a meta-information file, and how to compile the LaTeX document into its final PDF form. + +Most conferences provide a **.cls** file or a template that specifies how papers should look; for example, whether they should use a two-column format and other design treatments. In our example, the conference provided a file named **acmart.cls**. + +Authors are generally expected to include the institution to which they belong in their papers. However, this option was not included in the default Pandoc’s LaTeX template (note that the Pandoc template can be inspected by typing `pandoc -D latex`). To include the affiliation, take the default Pandoc’s LaTeX template and add a new field. The Pandoc template was copied into a file named `mytemplate.tex` as follows: + +``` +pandoc -D latex > mytemplate.tex +``` + +The default template contains the following code: + +``` +$if(author)$ +\author{$for(author)$$author$$sep$ \and $endfor$} +$endif$ +$if(institute)$ +\providecommand{\institute}[1]{} +\institute{$for(institute)$$institute$$sep$ \and $endfor$} +$endif$ +``` + +Because the template should include the author’s affiliation and email address, among other things, we updated it to include these fields (we made other changes as well but did not include them here due to the file length): + +``` +latex +$for(author)$ +    $if(author.name)$ +        \author{$author.name$} +        $if(author.affiliation)$ +            \affiliation{\institution{$author.affiliation$}} +        $endif$ +        $if(author.email)$ +            \email{$author.email$} +        $endif$ +    $else$ +        $author$ +    $endif$ +$endfor$ +``` + +With these changes in place, we should have the following files: + + * `main.md` contains the research paper + * `biblio.bib` contains the bibliographic database + * `acmart.cls` is the class of the document that we should use + * `mytemplate.tex` is the template file to use (instead of the default) + + + +Let’s add the meta-information of the paper in a `meta.yaml`file: + +``` +--- +template: 'mytemplate.tex' +documentclass: acmart +classoption: sigconf +title: The impact of opt-in gamification on `\\`{=latex} students' grades in a software design course +author: +- name: Kiko Fernandez-Reyes +  affiliation: Uppsala University +  email: kiko.fernandez@it.uu.se +- name: Dave Clarke +  affiliation: Uppsala University +  email: dave.clarke@it.uu.se +- name: Janina Hornbach +  affiliation: Uppsala University +  email: janina.hornbach@fek.uu.se +bibliography: biblio.bib +abstract: | +  An achievement-driven methodology strives to give students more control over their learning with enough flexibility to engage them in deeper learning. (more stuff continues) + +include-before: | +   \```{=latex} +   \copyrightyear{2018} +   \acmYear{2018} +   \setcopyright{acmlicensed} +   \acmConference[MODELS '18 Companion]{ACM/IEEE 21th International Conference on Model Driven Engineering Languages and Systems}{October 14--19, 2018}{Copenhagen, Denmark} +   \acmBooktitle{ACM/IEEE 21th International Conference on Model Driven Engineering Languages and Systems (MODELS '18 Companion), October 14--19, 2018, Copenhagen, Denmark} +   \acmPrice{XX.XX} +   \acmDOI{10.1145/3270112.3270118} +   \acmISBN{978-1-4503-5965-8/18/10} + +   \begin{CCSXML} +   +   +   10010405.10010489 +   Applied computing~Education +   500 +   +   +   \end{CCSXML} + +   \ccsdesc[500]{Applied computing~Education} + +   \keywords{gamification, education, software design, UML} +   \``` +figPrefix: +  - "Fig." +  - "Figs." +secPrefix: +  - "Section" +  - "Sections" +... +``` + +This meta-information file sets the following variables in LaTeX: + + * `template` refers to the template to use (‘mytemplate.tex’) + * `documentclass` refers to the LaTeX document class to use (`acmart`) + * `classoption` refers to the options of the class, in this case `sigconf` + * `title` specifies the title of the paper + * `author` is an object that contains other fields, such as `name`, `affiliation`, and `email`. + * `bibliography`refers to the file that contains the bibliography (biblio.bib) + * `abstract` contains the abstract of the paper + * `include-before`is information that should be included before the actual content of the paper; this is known as the [preamble][8] in LaTeX. I have included it here to show how to generate a computer science paper, but you may choose to skip it + * `figPrefix` specifies how to refer to figures in the document, i.e., what should be displayed when one refers to the figure `[@fig:scatter-matrix]`. For example, the current `figPrefix` produces in the example `The boxes "Enjoy", "Grade" and "Motivation" ([@fig:scatter-matrix])` this output: `The boxes "Enjoy", "Grade" and "Motivation" (Fig. 3)`. If there are multiple figures, the current setup declares that it should instead display `Figs.` next to the figure numbers. + * `secPrefix` specifies how to refer to sections mentioned elsewhere in the document (similar to figures, described above) + + + +Now that the meta-information is set, let’s create a `Makefile` that produces the desired output. This `Makefile` uses Pandoc to produce the LaTeX file, `pandoc-crossref` to produce the cross-references, `pdflatex` to compile the LaTeX to PDF, and `bibtex `to process the references. + +The `Makefile` is shown below: + +``` +all: paper + +paper: +        @pandoc -s -F pandoc-crossref --natbib meta.yaml --template=mytemplate.tex -N \ +         -f markdown -t latex+raw_tex+tex_math_dollars+citations -o main.tex main.md +        @pdflatex main.tex &> /dev/null +        @bibtex main &> /dev/null +        @pdflatex main.tex &> /dev/null +        @pdflatex main.tex &> /dev/null + +clean: +        rm main.aux main.tex main.log main.bbl main.blg main.out + +.PHONY: all clean paper +``` + +Pandoc uses the following flags: + + * `-s` to create a standalone LaTeX document + * `-F pandoc-crossref` to make use of the filter `pandoc-crossref` + * `--natbib` to render the bibliography with `natbib` (you can also choose `--biblatex`) + * `--template` sets the template file to use + * `-N` to number the section headings + * `-f` and `-t` specify the conversion from and to which format. `-t` usually contains the format and is followed by the Pandoc extensions used. In the example, we declared `raw_tex+tex_math_dollars+citations` to allow use of `raw_tex` LaTeX in the middle of the Markdown file. `tex_math_dollars` enables us to type math formulas as in LaTeX, and `citations` enables us to use [this extension][9]. + + + +To generate a PDF from LaTeX, follow the guidelines [from bibtex][10] to process the bibliography: + +``` +@pdflatex main.tex &> /dev/null +@bibtex main &> /dev/null +@pdflatex main.tex &> /dev/null +@pdflatex main.tex &> /dev/null +``` + +The script contains `@` to ignore the output, and we redirect the file handle of the standard output and error to `/dev/null`so that we don’t see the output generated from the execution of these commands. + +The final result is shown below. The repository for the article can be found [on GitHub][11]: + +![](https://opensource.com/sites/default/files/uploads/abstract-image.png) + +### Conclusion + +In my opinion, research is all about collaboration, dissemination of ideas, and improving the state of the art in whatever field one happens to be in. Most computer scientists and engineers write papers using the LaTeX document system, which provides excellent support for math. Researchers from the social sciences seem to stick to DOCX documents. + +When researchers from different communities write papers together, they should first discuss which format they will use. While DOCX may not be convenient for engineers if there is math involved, LaTeX may be troublesome for researchers who lack a programming background. As this article shows, Markdown is an easy-to-use language that can be used by both engineers and social scientists. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/9/pandoc-research-paper + +作者:[Kiko Fernandez-Reyes][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/kikofernandez +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Markdown +[2]: https://www.latex-project.org/ +[3]: https://pandoc.org/ +[4]: http://lierdakil.github.io/pandoc-crossref/ +[5]: https://dl.acm.org/citation.cfm?id=3270118 +[6]: https://github.com/kikofernandez/pandoc-examples/blob/master/research-paper/biblio.bib +[7]: https://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions#Figures +[8]: https://www.sharelatex.com/learn/latex/Creating_a_document_in_LaTeX#The_preamble_of_a_document +[9]: http://pandoc.org/MANUAL.html#citations +[10]: http://www.bibtex.org/Using/ +[11]: https://github.com/kikofernandez/pandoc-examples/tree/master/research-paper From 850ab1a7025071d512728f35093261c944d45991 Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 22 Oct 2018 11:13:23 +0800 Subject: [PATCH 093/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Understanding=20L?= =?UTF-8?q?inux=20Links:=20Part=201?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...81018 Understanding Linux Links- Part 1.md | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 sources/tech/20181018 Understanding Linux Links- Part 1.md diff --git a/sources/tech/20181018 Understanding Linux Links- Part 1.md b/sources/tech/20181018 Understanding Linux Links- Part 1.md new file mode 100644 index 0000000000..fd3c59bed0 --- /dev/null +++ b/sources/tech/20181018 Understanding Linux Links- Part 1.md @@ -0,0 +1,133 @@ +Understanding Linux Links: Part 1 +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/linux-link-498708.jpg?itok=DyVEcEsc) + +Along with `cp` and `mv`, both of which we talked about at length in [the previous installment of this series][1], links are another way of putting files and directories where you want them to be. The advantage is that links let you have one file or directory show up in several places at the same time. + +As noted previously, at the physical disk level, things like files and directories don't really exist. A filesystem conjures them up for our human convenience. But at the disk level, there is something called a _partition table_ , which lives at the beginning of every partition, and then the data scattered over the rest of the disk. + +Although there are different types of partition tables, the ones at the beginning of a partition containing your data will map where each directory and file starts and ends. The partition table acts like an index: When you load a file from your disk, your operating system looks up the entry on the table and the table says where the file starts on the disk and where it finishes. The disk header moves to the start point, reads the data until it reaches the end point and, hey presto: here's your file. + +### Hard Links + +A hard link is simply an entry in the partition table that points to an area on a disk that **has already been assigned to a file**. In other words, a hard link points to data that has already been indexed by another entry. Let's see how this works. + +Open a terminal, create a directory for tests and move into it: + +``` +mkdir test_dir +cd test_dir +``` + +Create a file by [touching][1] it: + +``` +touch test.txt +``` + +For extra excitement (?), open _test.txt_ in a text editor and add some a few words into it. + +Now make a hard link by executing: + +``` +ln test.txt hardlink_test.txt +``` + +Run `ls`, and you'll see your directory now contains two files... Or so it would seem. As you read before, really what you are seeing is two names for the exact same file: _hardlink_test.txt_ contains the same content, has not filled any more space in the disk (try with a large file to test this), and shares the same inode as _test.txt_ : + +``` +$ ls -li *test* +16515846 -rw-r--r-- 2 paul paul 14 oct 12 09:50 hardlink_test.txt +16515846 -rw-r--r-- 2 paul paul 14 oct 12 09:50 test.txt +``` + +_ls_ 's `-i` option shows the _inode number_ of a file. The _inode_ is the chunk of information in the partition table that contains the location of the file or directory on the disk, the last time it was modified, and other data. If two files share the same inode, they are, to all practical effects, the same file, regardless of where they are located in the directory tree. + +### Fluffy Links + +Soft links, also known as _symlinks_ , are different: a soft link is really an independent file, it has its own inode and its own little slot on the disk. But it only contains a snippet of data that points the operating system to another file or directory. + +You can create a soft link using `ln` with the `-s` option: + +``` +ln -s test.txt softlink_test.txt +``` + +This will create the soft link _softlink_test.txt_ to _test.txt_ in the current directory. + +By running `ls -li` again, you can see the difference between the two different kinds of links: + +``` +$ ls -li +total 8 +16515846 -rw-r--r-- 2 paul paul 14 oct 12 09:50 hardlink_test.txt +16515855 lrwxrwxrwx 1 paul paul 8 oct 12 09:50 softlink_test.txt -> test.txt +16515846 -rw-r--r-- 2 paul paul 14 oct 12 09:50 test.txt +``` + +_hardlink_test.txt_ and _test.txt_ contain some text and take up the same space *literally*. They also share the same inode number. Meanwhile, _softlink_test.txt_ occupies much less and has a different inode number, marking it as a different file altogether. Using the _ls_ 's `-l` option also shows the file or directory your soft link points to. + +### Why Use Links? + +They are good for **applications that come with their own environment**. It often happens that your Linux distro does not come with the latest version of an application you need. Take the case of the fabulous [Blender 3D][2] design software. Blender allows you to create 3D still images as well as animated films and who wouldn't to have that on their machine? The problem is that the current version of Blender is always at least one version ahead of that found in any distribution. + +Fortunately, [Blender provides downloads][3] that run out of the box. These packages come, apart from with the program itself, a complex framework of libraries and dependencies that Blender needs to work. All these bits and piece come within their own hierarchy of directories. + +Every time you want to run Blender, you could `cd` into the folder you downloaded it to and run: + +``` +./blender +``` + +But that is inconvenient. It would be better if you could run the `blender` command from anywhere in your file system, as well as from your desktop command launchers. + +The way to do that is to link the _blender_ executable into a _bin/_ directory. On many systems, you can make the `blender` command available from anywhere in the file system by linking to it like this: + +``` +ln -s /path/to/blender_directory/blender /home//bin +``` + +Another case in which you will need links is for **software that needs outdated libraries**. If you list your _/usr/lib_ directory with `ls -l,` you will see a lot of soft-linked files fly by. Take a closer look, and you will see that the links usually have similar names to the original files they are linking to. You may see _libblah_ linking to _libblah.so.2_ , and then, you may even notice that _libblah.so.2_ links in turn to _libblah.so.2.1.0_ , the original file. + +This is because applications often require older versions of alibrary than what is installed. The problem is that, even if the more modern versions are still compatible with the older versions (and usually they are), the program will bork if it doesn't find the version it is looking for. To solve this problem distributions often create links so that the picky application believes it has found the older version, when, in reality, it has only found a link and ends up using the more up to date version of the library. + +Somewhat related is what happens with **programs you compile yourself from the source code**. Programs you compile yourself often end up installed under _/usr/local_ : the program itself ends up in _/usr/local/bin_ and it looks for the libraries it needs _/_ in the _/usr/local/lib_ directory. But say that your new program needs _libblah_ , but _libblah_ lives in _/usr/lib_ and that's where all your other programs look for it. You can link it to _/usr/local/lib_ by doing: + +``` +ln -s /usr/lib/libblah /usr/local/lib +``` + +Or, if you prefer, by `cd`ing into _/usr/local/lib_... + +``` +cd /usr/local/lib +``` + +... and then linking with: + +``` +ln -s ../lib/libblah +``` + +There are dozens more cases in which linking proves useful, and you will undoubtedly discover them as you become more proficient in using Linux, but these are the most common. Next time, we’ll look at some linking quirks you need to be aware of. + +Learn more about Linux through the free ["Introduction to Linux" ][4]course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/intro-to-linux/2018/10/linux-links-part-1 + +作者:[Paul Brown][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/bro66 +[b]: https://github.com/lujun9972 +[1]: https://www.linux.com/blog/2018/8/linux-beginners-moving-things-around +[2]: https://www.blender.org/ +[3]: https://www.blender.org/download/ +[4]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux From f5eab341ae2f819b348f795c8f5c37277fa8c24c Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 22 Oct 2018 11:16:15 +0800 Subject: [PATCH 094/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20To=20Determ?= =?UTF-8?q?ine=20Which=20System=20Manager=20Is=20Running=20On=20Linux=20Sy?= =?UTF-8?q?stem?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...stem Manager Is Running On Linux System.md | 176 ++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 sources/tech/20181017 How To Determine Which System Manager Is Running On Linux System.md diff --git a/sources/tech/20181017 How To Determine Which System Manager Is Running On Linux System.md b/sources/tech/20181017 How To Determine Which System Manager Is Running On Linux System.md new file mode 100644 index 0000000000..ef927d848b --- /dev/null +++ b/sources/tech/20181017 How To Determine Which System Manager Is Running On Linux System.md @@ -0,0 +1,176 @@ +How To Determine Which System Manager Is Running On Linux System +====== +We all are heard about this word many times but only few of us know what is this exactly. We will show you how to identify the system manager. + +I will try my best to let you know about this. Most of us know about System V and systemd system manager. System V (Sysv) is an old and traditional init system and system manager for old systems. + +Systemd is a new init system and system manager which was adapted by most of the major distribution. + +There are three major init systems are available in Linux which are very famous and still in use. Most of the Linux distribution falls under in one of the below init system. + +### What is init System Manager? + +In Linux/Unix based operating systems, init (short for initialization) is the first process that started during the system boot up by the kernel. + +It’s holding a process id (PID) of 1. It will be running in the background continuously until the system is shut down. + +Init looks at the `/etc/inittab` file to decide the Linux run level then it starts all other processes & applications in the background as per the run level. + +BIOS, MBR, GRUB and Kernel processes were kicked up before hitting init process as part of Linux booting process. + +Below are the available run levels for Linux (There are seven runlevels exist, from zero to six). + + * **`0:`** halt + * **`1:`** Single user mode + * **`2:`** Multiuser, without NFS + * **`3:`** Full multiuser mode + * **`4:`** Unused + * **`5:`** X11 (GUI – Graphical User Interface) + * **`:`** reboot + + + +Below three init systems are widely used in Linux. + + * **`System V (Sys V):`** System V (Sys V) is one of the first and traditional init system for Unix like operating system. + * **`Upstart:`** Upstart is an event-based replacement for the /sbin/init daemon. + * **`systemd:`** Systemd is a new init system and system manager which was implemented/adapted into all the major Linux distributions over the traditional SysV init systems. + + + +### What is System V (Sys V)? + +System V (Sys V) is one of the first and traditional init system for Unix like operating system. init is the first process that started during the system boot up by the kernel and it’s a parent process for everything. + +Most of the Linux distributions started using traditional init system called System V (Sys V) first. Over the years, several replacement init systems were released to address design limitations in the standard versions such as launchd, the Service Management Facility, systemd and Upstart. + +But systemd has been adopted by several major Linux distributions over the traditional SysV init systems. + +### How to identify the System V (Sys V) system manager on Linux + +Run the following commands to identify that your system is running with System V (Sys V) system manager. + +### Method-1: Using ps command + +ps – report a snapshot of the current processes. ps displays information about a selection of the active processes. +This output doesn’t give the exact results either System V (SysV) or upstart so, i would suggest you to go with other method to confirm this. + +``` +# ps -p1 | grep "init\|upstart\|systemd" + 1 ? 00:00:00 init +``` + +### Method-2: Using rpm command + +RPM stands for `Red Hat Package Manager` is a powerful, command line [Package Management][1] utility for Red Hat based system such as (RHEL, CentOS, Fedora, openSUSE & Mageia) distributions. The utility allow you to install, upgrade, remove, query & verify the software on your Linux system/server. RPM files comes with `.rpm` extension. +RPM package built with required libraries and dependency which will not conflicts other packages were installed on your system. + +``` +# rpm -qf /sbin/init +SysVinit-2.86-17.el5 +``` + +### What is Upstart? + +Upstart is an event-based replacement for the /sbin/init daemon which handles starting of tasks and services during boot, stopping them during shutdown and supervising them while the system is running. + +It was originally developed for the Ubuntu distribution, but is intended to be suitable for deployment in all Linux distributions as a replacement for the venerable System-V init. + +It was used in Ubuntu from 9.10 to Ubuntu 14.10 & RHEL 6 based systems after that they are replaced with systemd. + +### How to identify the Upstart system manager on Linux + +Run the following commands to identify that your system is running with Upstart system manager. + +### Method-1: Using ps command + +ps – report a snapshot of the current processes. ps displays information about a selection of the active processes. +This output doesn’t give the exact results either System V (SysV) or upstart so, i would suggest you to go with other method to confirm this. + +``` +# ps -p1 | grep "init\|upstart\|systemd" + 1 ? 00:00:00 init +``` + +### Method-2: Using rpm command + +RPM stands for `Red Hat Package Manager` is a powerful, command line Package Management utility for Red Hat based system such as (RHEL, CentOS, Fedora, openSUSE & Mageia) distributions. The [RPM Command][2] allow you to install, upgrade, remove, query & verify the software on your Linux system/server. RPM files comes with `.rpm` extension. +RPM package built with required libraries and dependency which will not conflicts other packages were installed on your system. + +``` +# rpm -qf /sbin/init +upstart-0.6.5-16.el6.x86_64 +``` + +### Method-3: Using /sbin/init file + +The `/sbin/init` program will load or switch the root file system from memory to the hard disk. +This is the main part of the boot process. The runlevel at the start of this process is “N” (none). The /sbin/init program initializes the system following the description in the /etc/inittab configuration file. + +``` +# /sbin/init --version +init (upstart 0.6.5) +Copyright (C) 2010 Canonical Ltd. + +This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +``` + +### What is systemd? + +Systemd is a new init system and system manager which was implemented/adapted into all the major Linux distributions over the traditional SysV init systems. + +systemd is compatible with SysV and LSB init scripts. It can work as a drop-in replacement for sysvinit system. systemd is the first process get started by kernel and holding PID 1. + +It’s a parant process for everything and Fedora 15 is the first distribution which was adapted systemd instead of upstart. [systemctl][3] is command line utility and primary tool to manage the systemd daemons/services such as (start, restart, stop, enable, disable, reload & status). + +systemd uses .service files Instead of bash scripts (SysVinit uses). systemd sorts all daemons into their own Linux cgroups and you can see the system hierarchy by exploring `/cgroup/systemd` file. + +### How to identify the systemd system manager on Linux + +Run the following commands to identify that your system is running with systemd system manager. + +### Method-1: Using ps command + +ps – report a snapshot of the current processes. ps displays information about a selection of the active processes. + +``` +# ps -p1 | grep "init\|upstart\|systemd" + 1 ? 00:18:09 systemd +``` + +### Method-2: Using rpm command + +RPM stands for `Red Hat Package Manager` is a powerful, command line Package Management utility for Red Hat based system such as (RHEL, CentOS, Fedora, openSUSE & Mageia) distributions. The utility allow you to install, upgrade, remove, query & verify the software on your Linux system/server. RPM files comes with `.rpm` extension. +RPM package built with required libraries and dependency which will not conflicts other packages were installed on your system. + +``` +# rpm -qf /sbin/init +systemd-219-30.el7_3.9.x86_64 +``` + +### Method-3: Using /sbin/init file + +The `/sbin/init` program will load or switch the root file system from memory to the hard disk. +This is the main part of the boot process. The runlevel at the start of this process is “N” (none). The /sbin/init program initializes the system following the description in the /etc/inittab configuration file. + +``` +# file /sbin/init +/sbin/init: symbolic link to `../lib/systemd/systemd' +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-determine-which-init-system-manager-is-running-on-linux-system/ + +作者:[Prakash Subramanian][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/prakash/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/category/package-management/ +[2]: https://www.2daygeek.com/rpm-command-examples/ +[3]: https://www.2daygeek.com/how-to-check-all-running-services-in-linux/ From ac27bc62f6359e1174bed0155b912f7b7d39dc5e Mon Sep 17 00:00:00 2001 From: darksun Date: Mon, 22 Oct 2018 11:21:02 +0800 Subject: [PATCH 095/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20The=20case=20for?= =?UTF-8?q?=20open=20source=20classifiers=20in=20AI=20algorithms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...pen source classifiers in AI algorithms.md | 111 ++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 sources/tech/20181018 The case for open source classifiers in AI algorithms.md diff --git a/sources/tech/20181018 The case for open source classifiers in AI algorithms.md b/sources/tech/20181018 The case for open source classifiers in AI algorithms.md new file mode 100644 index 0000000000..fd9a7a96fa --- /dev/null +++ b/sources/tech/20181018 The case for open source classifiers in AI algorithms.md @@ -0,0 +1,111 @@ +The case for open source classifiers in AI algorithms +====== +Machine bias is a widespread problem with potentially serious human consequences, but it's not unmanageable. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/brain_data.png?itok=RH6NA32X) + +Dr. Carol Reiley's achievements are too long to list. She co-founded [Drive.ai][1], a self-driving car startup that [raised $50 million][2] in its second round of funding last year. Forbes magazine named her one of "[20 Incredible Women in AI][3]," and she built intelligent robot systems as a PhD candidate at Johns Hopkins University. + +But when she built a voice-activated human-robot interface, her own creation couldn't recognize her voice. + +Dr. Reiley used Microsoft's speech recognition API to build her interface. But since the API was built mostly by young men, it hadn't been exposed to enough voice variations. After some failed attempts to lower her voice so the system would recognize her, Dr. Reiley [enlisted a male graduate][4] to lead demonstrations of her work. + +Did Microsoft train its API to recognize only male voices? Probably not. It's more likely that the dataset used to train this API didn't have a wide range of voices with diverse accents, inflections, etc. + +AI-powered products learn from the data they're trained on. If Microsoft's API was exposed only to male voices within a certain age range, it wouldn't know how to recognize a female voice—even if a female built the product. + +This is an example of machine bias at work—and it's a more widespread problem than we think. + +### What is machine bias? + +[According to Gartner research][5] (available for clients), "Machine bias arises when an algorithm unfairly prefers a particular group or unjustly discriminates against another when making predictions and drawing conclusions." This bias takes one of two forms: + + * **Direct bias** occurs when models make predictions based on sensitive or prohibited attributes. These attributes include race, religion, gender, and sexual orientation. + * **Indirect bias** is a byproduct of non-sensitive attributes that correlate with sensitive attributes. This is the more common form of machine bias. It's also the tougher form of bias to detect. + + + +### The human impact of machine bias + +In my [lightning talk][6] at Open Source Summit North America in August, I shared the Correctional Offender Management Profiling for Alternative Sanctions ([COMPAS][7]) algorithm as an example of indirect bias. Judges in more than 12 U.S. states use this algorithm to predict a defendant's likelihood to recommit crimes. + +Unfortunately, [research from ProPublica][8] found that the COMPAS algorithm made incorrect predictions due to indirect bias based on race. The algorithm was two times more likely to incorrectly cite black defendants as high risks for recommitting crimes and two times more likely to incorrectly cite white defendants as low risks for recommitting crimes. + +How did this happen? The COMPAS algorithm's predictions correlated with race (a sensitive/prohibited attribute). To confirm whether indirect bias exists within a dataset, the outcomes from one group are compared with another group's. If the difference exceeds some agreed-upon threshold, the model is considered unacceptably biased. + +This isn't a "What if?" scenario: COMPAS's results impacted defendants' prison sentences, including the length of those sentences and whether defendants were released on parole. + +Based partially on COMPAS's recommendation, a Wisconsin judged [denied probation][9] to a man named Eric Loomis. Instead, the judge gave Loomis a six-year prison sentence for driving a car that had been used in a recent shooting. + +To make matters worse, we can't confirm how COMPAS reached its conclusions: The manufacturer refused to disclose how it works, which made it [a black-box algorithm][10]. But when Loomis took his case to the Supreme Court, the justices refused to give it a hearing. + +This choice signaled that most Supreme Court justices condoned the algorithm's use without knowing how it reached (often incorrect) conclusions. This sets a dangerous legal precedent, especially as confusion about how AI works [shows no signs of slowing down][11]. + +### Why you should open source your AI algorithms + +The open source community discussed this subject during a Birds of a Feather (BoF) session at Open Source Summit North America in August. During this discussion, some developers made cases for keeping machine learning algorithms private. + +Along with proprietary concerns, these black-box algorithms are built on endless neurons that each have their own biases. Since these algorithms learn from the data they're trained on, they're at risk of manipulation by bad actors. One program manager at a major tech firm said his team is constantly on guard to protect their work from those with ill intent. + +In spite of these reasons, there's a strong case in favor of making the datasets used to train machine learning algorithms open where possible. And a series of open source tools is helping developers solve this problem. + +Local Interpretable Model-Agnostic Explanations (LIME) is an open source Python toolkit from the University of Washington. It doesn't try to dissect every factor influencing algorithms' decisions. Instead, it treats every model as a black box. + +LIME uses a pick-step to select a representative set of predictions or conclusions to explain. Then it approximates the model closest to those predictions. It manipulates the inputs to the model and then measures how predictions change. + +The image below, from [LIME's website][12], shows a classifier from text classification. The tool's researchers took two classes—Atheism and Christian—that are difficult to distinguish since they share so many words. Then, they [trained a forest with 500 trees][13] and got a test accuracy of 92.4%. If accuracy was your core measure of trust, you'd be able to trust this algorithm. + +![](https://opensource.com/sites/default/files/uploads/classifier.png) + +Projects like LIME prove that while machine bias is unavoidable, it's not unmanageable. If you add bias testing to your product development lifecycles, you can decrease the risk of bias within datasets that are used to train AI-powered products built on machine learning. + +### Avoid algorithm aversion + +When we don't know how algorithms make decisions, we can't fully trust them. In the near future, companies will have no choice but to be more transparent about how their creations work. + +We're already seeing legislation in Europe that would fine large tech companies for not revealing how their algorithms work. And extreme as this might sound, it's what users want. + +Research from the University of Chicago and the University of Pennsylvania showed that users [have more trust in modifiable algorithms][14] than in those built by experts. People prefer algorithms when they can clearly see how those algorithms work—even if those algorithms are wrong. + +This supports the crucial role that transparency plays in public trust of tech. It also makes [the case for open source projects][15] that aim to solve this problem. + +Algorithm aversion is real, and rightfully so. Earlier this month, Amazon was the latest tech giant to [have its machine bias exposed][16]. If such companies can't defend how these machines reach conclusions, their end users will suffer. + +I gave a full talk on machine bias—including steps to solve this problem—[at Google Dev Fest DC][17] as part of DC Startup Week in September. On October 23, I'll give a [lightning talk][18] on this same subject at All Things Open in Raleigh, N.C. + +Lauren Maffeo will present [Erase unconscious bias from your AI datasets][19] at [All Things Open][20], October 21-23 in Raleigh, N.C. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/open-source-classifiers-ai-algorithms + +作者:[Lauren Maffeo][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/lmaffeo +[b]: https://github.com/lujun9972 +[1]: http://Drive.ai +[2]: https://www.reuters.com/article/us-driveai-autonomous-idUSKBN19I2ZD +[3]: https://www.forbes.com/sites/mariyayao/2017/05/18/meet-20-incredible-women-advancing-a-i-research/#1876954026f9 +[4]: https://techcrunch.com/2016/11/16/when-bias-in-product-design-means-life-or-death/ +[5]: https://www.gartner.com/doc/3889586/control-bias-eliminate-blind-spots +[6]: https://www.youtube.com/watch?v=JtQzdTDv-P4 +[7]: https://en.wikipedia.org/wiki/COMPAS_(software) +[8]: https://www.propublica.org/article/how-we-analyzed-the-compas-recidivism-algorithm +[9]: https://www.nytimes.com/2017/10/26/opinion/algorithm-compas-sentencing-bias.html +[10]: https://www.technologyreview.com/s/609338/new-research-aims-to-solve-the-problem-of-ai-bias-in-black-box-algorithms/ +[11]: https://www.thenetworkmediagroup.com/blog/ai-the-facts-and-myths-lauren-maffeo-getapp +[12]: https://homes.cs.washington.edu/~marcotcr/blog/lime/ +[13]: https://towardsdatascience.com/decision-trees-in-machine-learning-641b9c4e8052 +[14]: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2616787 +[15]: https://github.com/mbilalzafar/fair-classification +[16]: https://www.reuters.com/article/us-amazon-com-jobs-automation-insight/amazon-scraps-secret-ai-recruiting-tool-that-showed-bias-against-women-idUSKCN1MK08G +[17]: https://www.facebook.com/DCstartupweek/videos/1919103555059439/?fref=mentions&__xts__%5B0%5D=68.ARD1fVGSdYCHajf8qSryp5g2MoKg4522wZ0KJGIIPJTtw3xulDIkl9A6Vg4BrnbB6BfSX-yl9D5sNMZ4rtZb8rIbBU9ueWA9xXnt6SDv_hPlo_cxIRVS2RUI_O0hYahfNvHvYi8AsCPsDRqiHO4Jt1Ex9VS67uoJ46MXynR1XQB4f5jdGp1UDQ&__tn__=K-R +[18]: https://opensource.com/article/18/10/lightning-talks-all-things-open +[19]: https://opensource.com/article/18/10/lightning-talks-all-things-open#4 +[20]: https://allthingsopen.org/ From 0d084ce843b32b4e90465888b0a0d583f90ae8e9 Mon Sep 17 00:00:00 2001 From: Ezio Date: Mon, 22 Oct 2018 13:18:04 +0800 Subject: [PATCH 096/158] =?UTF-8?q?20181022-1=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @qhwdw --- ... the Kernel Community Is Securing Linux.md | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 sources/tech/20181002 Greg Kroah-Hartman Explains How the Kernel Community Is Securing Linux.md diff --git a/sources/tech/20181002 Greg Kroah-Hartman Explains How the Kernel Community Is Securing Linux.md b/sources/tech/20181002 Greg Kroah-Hartman Explains How the Kernel Community Is Securing Linux.md new file mode 100644 index 0000000000..31788a67b2 --- /dev/null +++ b/sources/tech/20181002 Greg Kroah-Hartman Explains How the Kernel Community Is Securing Linux.md @@ -0,0 +1,75 @@ +qhwdw is translating + + +Greg Kroah-Hartman Explains How the Kernel Community Is Securing Linux +============================================================ + + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kernel-security_0.jpg?itok=hOaTQwWV) +Kernel maintainer Greg Kroah-Hartman talks about how the kernel community is hardening Linux against vulnerabilities.[Creative Commons Zero][2] + +As Linux adoption expands, it’s increasingly important for the kernel community to improve the security of the world’s most widely used technology. Security is vital not only for enterprise customers, it’s also important for consumers, as 80 percent of mobile devices are powered by Linux. In this article, Linux kernel maintainer Greg Kroah-Hartman provides a glimpse into how the kernel community deals with vulnerabilities. + +### There will be bugs + + +![Greg Kroah-Hartman](https://www.linux.com/sites/lcom/files/styles/floated_images/public/greg-k-h.png?itok=p4fREYuj "Greg Kroah-Hartman") + +Greg Kroah-Hartman[The Linux Foundation][1] + +As Linus Torvalds once said, most security holes are bugs, and bugs are part of the software development process. As long as the software is being written, there will be bugs. + +“A bug is a bug. We don’t know if a bug is a security bug or not. There is a famous bug that I fixed and then three years later Red Hat realized it was a security hole,” said Kroah-Hartman. + +There is not much the kernel community can do to eliminate bugs, but it can do more testing to find them. The kernel community now has its own security team that’s made up of kernel developers who know the core of the kernel. + +“When we get a report, we involve the domain owner to fix the issue. In some cases it’s the same people, so we made them part of the security team to speed things up,” Kroah Hartman said. But he also stressed that all parts of the kernel have to be aware of these security issues because kernel is a trusted environment and they have to protect it. + +“Once we fix things, we can put them in our stack analysis rules so that they are never reintroduced,” he said. + +Besides fixing bugs, the community also continues to add hardening to the kernel. “We have realized that we need to have mitigations. We need hardening,” said Kroah-Hartman. + +Huge efforts have been made by Kees Cook and others to take the hardening features that have been traditionally outside of the kernel and merge or adapt them for the kernel. With every kernel released, Cook provides a summary of all the new hardening features. But hardening the kernel is not enough, vendors have to enable the new features and take advantage of them. That’s not happening.   + +Kroah-Hartman [releases a stable kernel every week][5], and companies pick one to support for a longer period so that device manufacturers can take advantage of it. However, Kroah-Hartman has observed that, aside from the Google Pixel, most Android phones don’t include the additional hardening features, meaning all those phones are vulnerable. “People need to enable this stuff,” he said. + +“I went out and bought all the top of the line phones based on kernel 4.4 to see which one actually updated. I found only one company that updated their kernel,” he said.  “I'm working through the whole supply chain trying to solve that problem because it's a tough problem. There are many different groups involved -- the SoC manufacturers, the carriers, and so on. The point is that they have to push the kernel that we create out to people.” + +The good news is that unlike with consumer electronics, the big vendors like Red Hat and SUSE keep the kernel updated even in the enterprise environment. Modern systems with containers, pods, and virtualization make this even easier. It’s effortless to update and reboot with no downtime. It is, in fact, easier to keep things secure than it used to be. + +### Meltdown and Spectre + +No security discussion is complete without the mention of Meltdown and Spectre. The kernel community is still working on fixes as new flaws are discovered. However, Intel has changed its approach in light of these events. + +“They are reworking on how they approach security bugs and how they work with the community because they know they did it wrong,” Kroah-Hartman said. “The kernel has fixes for almost all of the big Spectre issues, but there is going to be a long tail of minor things.” + +The good news is that these Intel vulnerabilities proved that things are getting better for the kernel community. “We are doing more testing. With the latest round of security patches, we worked on our own for four months before releasing them to the world because we were embargoed. But once they hit the real world, it made us realize how much we rely on the infrastructure we have built over the years to do this kind of testing, which ensures that we don’t have bugs before they hit other people,” he said. “So things are certainly getting better.” + +The increasing focus on security is also creating more job opportunities for talented people. Since security is an area that gets eyeballs, those who want to build a career in kernel space, security is a good place to get started with. + +“If there are people who want a job to do this type of work, we have plenty of companies who would love to hire them. I know some people who have started off fixing bugs and then got hired,” Kroah-Hartman said. + +You can hear more in the video below: + +[视频](https://youtu.be/jkGVabyMh1I) + + _Check out the schedule of talks for Open Source Summit Europe and sign up to receive updates:_ + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/2018/10/greg-kroah-hartman-explains-how-kernel-community-securing-linux-0 + +作者:[SWAPNIL BHARTIYA][a] +选题:[oska874][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/arnieswap +[b]:https://github.com/oska874 +[1]:https://www.linux.com/licenses/category/linux-foundation +[2]:https://www.linux.com/licenses/category/creative-commons-zero +[3]:https://www.linux.com/files/images/greg-k-hpng +[4]:https://www.linux.com/files/images/kernel-securityjpg-0 +[5]:https://www.kernel.org/category/releases.html From 31981ef9157d0d800fe56cfca7e24f66b8b1685c Mon Sep 17 00:00:00 2001 From: Ezio Date: Mon, 22 Oct 2018 13:22:35 +0800 Subject: [PATCH 097/158] =?UTF-8?q?20181022-2=20=E9=80=89=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @qhwdw --- ...r Open Source, Goodbye Proprietary UEFI.md | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 sources/tech/20181006 LinuxBoot for Servers - Enter Open Source, Goodbye Proprietary UEFI.md diff --git a/sources/tech/20181006 LinuxBoot for Servers - Enter Open Source, Goodbye Proprietary UEFI.md b/sources/tech/20181006 LinuxBoot for Servers - Enter Open Source, Goodbye Proprietary UEFI.md new file mode 100644 index 0000000000..de0a4260db --- /dev/null +++ b/sources/tech/20181006 LinuxBoot for Servers - Enter Open Source, Goodbye Proprietary UEFI.md @@ -0,0 +1,126 @@ +qhwdw is translating + +LinuxBoot for Servers: Enter Open Source, Goodbye Proprietary UEFI +============================================================ + +[LinuxBoot][13] is an Open Source [alternative][14] to Proprietary [UEFI][15] firmware. It was released last year and is now being increasingly preferred by leading hardware manufacturers as default firmware. Last year, LinuxBoot was warmly [welcomed][16]into the Open Source family by The Linux Foundation. + +This project was an initiative by Ron Minnich, author of LinuxBIOS and lead of [coreboot][17] at Google, in January 2017. + +Google, Facebook, [Horizon Computing Solutions][18], and [Two Sigma][19] collaborated together to develop the [LinuxBoot project][20] (formerly called [NERF][21]) for server machines based on Linux. + +Its openness allows Server users to easily customize their own boot scripts, fix issues, build their own [runtimes][22] and [reflash their firmware][23] with their own keys. They do not need to wait for vendor updates. + +Following is a video of [Ubuntu Xenial][24] booting for the first time with NERF BIOS: + +[视频](https://youtu.be/HBkZAN3xkJg) + +Let’s talk about some other advantages by comparing it to UEFI in terms of Server hardware. + +### Advantages of LinuxBoot over UEFI + +![LinuxBoot vs UEFI](https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/10/linuxboot-uefi.png) + +Here are some of the major advantages of LinuxBoot over UEFI: + +### Significantly faster startup + +It can boot up Server boards in less than twenty seconds, versus multiple minutes on UEFI. + +### Significantly more flexible + +LinuxBoot can make use of any devices, filesystems and protocols that Linux supports. + +### Potentially more secure + +Linux device drivers and filesystems have significantly more scrutiny than through UEFI. + +We can argue that UEFI is partly open with [EDK II][25] and LinuxBoot is partly closed. But it has been [addressed][26] that even such EDK II code does not have the proper level of inspection and correctness as the [Linux Kernel][27] goes through, while there is a huge amount of other Closed Source components within UEFI development. + +On the other hand, LinuxBoot has a significantly smaller amount of binaries with only a few hundred KB, compared to the 32 MB of UEFI binaries. + +To be precise, LinuxBoot fits a whole lot better into the [Trusted Computing Base][28], unlike UEFI. + +[Suggested readBest Free and Open Source Alternatives to Adobe Products for Linux][29] + +LinuxBoot has a [kexec][30] based bootloader which does not support startup on Windows/non-Linux kernels, but that is insignificant since most clouds are Linux-based Servers. + +### LinuxBoot adoption + +In 2011, the [Open Compute Project][31] was started by [Facebook][32] who [open-sourced][33] designs of some of their Servers, built to make its data centers  more efficient. LinuxBoot has been tested on a few Open Compute Hardware listed as under: + +* Winterfell + +* Leopard + +* Tioga Pass + +More [OCP][34] hardware are described [here][35] in brief. The OCP Foundation runs a dedicated project on firmware through [Open System Firmware][36]. + +Some other devices that support LinuxBoot are: + +* [QEMU][9] emulated [Q35][10] systems + +* [Intel S2600wf][11] + +* [Dell R630][12] + +Last month end, [Equus Compute Solutions][37] [announced][38] the release of its [WHITEBOX OPEN™][39] M2660 and M2760 Servers, as a part of their custom, cost-optimized Open-Hardware Servers and storage platforms. Both of them support LinuxBoot to customize the Server BIOS for flexibility, improved security, and create a blazingly fast booting experience. + +### What do you think of LinuxBoot? + +LinuxBoot is quite well documented [on GitHub][40].  Do you like the features that set it apart from UEFI? Would you prefer using LinuxBoot rather than UEFI for starting up Servers, owing to the former’s open-ended development and future? Let us know in the comments below. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linuxboot-uefi/ + +作者:[ Avimanyu Bandyopadhyay][a] +选题:[oska874][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://itsfoss.com/author/avimanyu/ +[b]:https://github.com/oska874 +[1]:https://itsfoss.com/linuxboot-uefi/# +[2]:https://itsfoss.com/linuxboot-uefi/# +[3]:https://itsfoss.com/linuxboot-uefi/# +[4]:https://itsfoss.com/linuxboot-uefi/# +[5]:https://itsfoss.com/linuxboot-uefi/# +[6]:https://itsfoss.com/linuxboot-uefi/# +[7]:https://itsfoss.com/author/avimanyu/ +[8]:https://itsfoss.com/linuxboot-uefi/#comments +[9]:https://en.wikipedia.org/wiki/QEMU +[10]:https://wiki.qemu.org/Features/Q35 +[11]:https://trmm.net/S2600 +[12]:https://trmm.net/NERF#Installing_on_a_Dell_R630 +[13]:https://www.linuxboot.org/ +[14]:https://www.phoronix.com/scan.php?page=news_item&px=LinuxBoot-OSFC-2018-State +[15]:https://itsfoss.com/check-uefi-or-bios/ +[16]:https://www.linuxfoundation.org/blog/2018/01/system-startup-gets-a-boost-with-new-linuxboot-project/ +[17]:https://en.wikipedia.org/wiki/Coreboot +[18]:http://www.horizon-computing.com/ +[19]:https://www.twosigma.com/ +[20]:https://trmm.net/LinuxBoot_34c3 +[21]:https://trmm.net/NERF +[22]:https://trmm.net/LinuxBoot_34c3#Runtimes +[23]:http://www.tech-faq.com/flashing-firmware.html +[24]:https://itsfoss.com/features-ubuntu-1604/ +[25]:https://www.tianocore.org/ +[26]:https://media.ccc.de/v/34c3-9056-bringing_linux_back_to_server_boot_roms_with_nerf_and_heads +[27]:https://medium.com/@bhumikagoyal/linux-kernel-development-cycle-52b4c55be06e +[28]:https://en.wikipedia.org/wiki/Trusted_computing_base +[29]:https://itsfoss.com/adobe-alternatives-linux/ +[30]:https://en.wikipedia.org/wiki/Kexec +[31]:https://en.wikipedia.org/wiki/Open_Compute_Project +[32]:https://github.com/facebook +[33]:https://github.com/opencomputeproject +[34]:https://www.networkworld.com/article/3266293/lan-wan/what-is-the-open-compute-project.html +[35]:http://hyperscaleit.com/ocp-server-hardware/ +[36]:https://www.opencompute.org/projects/open-system-firmware +[37]:https://www.equuscs.com/ +[38]:http://www.dcvelocity.com/products/Software_-_Systems/20180924-equus-compute-solutions-introduces-whitebox-open-m2660-and-m2760-servers/ +[39]:https://www.equuscs.com/servers/whitebox-open/ +[40]:https://github.com/linuxboot/linuxboot From e7af595bc38aac7adc9f5886c442a1debe0f09b1 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 22 Oct 2018 14:11:03 +0800 Subject: [PATCH 098/158] =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Tips for listing files with ls at the Linux command line.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/published/20181003 Tips for listing files with ls at the Linux command line.md b/published/20181003 Tips for listing files with ls at the Linux command line.md index f35d00749e..e837b2816e 100644 --- a/published/20181003 Tips for listing files with ls at the Linux command line.md +++ b/published/20181003 Tips for listing files with ls at the Linux command line.md @@ -1,4 +1,4 @@ -在 Linux 命令行中使用 ls 列出文件的提示 +在 Linux 命令行中使用 ls 列出文件的技巧 ====== > 学习一些 Linux `ls` 命令最有用的变化。 From 4cba759cf606a28748518d8c6f2cd8ad896dbd4c Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 22 Oct 2018 22:17:26 +0800 Subject: [PATCH 099/158] PRF:20181013 How to Install GRUB on Arch Linux (UEFI).md @geekpi --- ...How to Install GRUB on Arch Linux (UEFI).md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/translated/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md b/translated/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md index d466a85f2e..77df85ad8c 100644 --- a/translated/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md +++ b/translated/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md @@ -3,30 +3,30 @@ ![](http://fasterland.net/wp-content/uploads/2018/10/Arch-Linux-Boot-Menu-750x375.jpg) -前段时间,我写了一篇在安装 Windows 后在 Arch Linux 上**[如何重新安装 Grub][1]的教程。** +前段时间,我写了一篇在安装 Windows 后在 Arch Linux 上[如何重新安装 Grub][1]的教程。 -几周前,我不得不在我的笔记本上从头开始重新安装 **Arch Linux**,同时我发现安装 **Grub** 并不像我想的那么简单。 +几周前,我不得不在我的笔记本上从头开始重新安装 Arch Linux,同时我发现安装 Grub 并不像我想的那么简单。 -出于这个原因,由于在新安装 **Arch Linux** 时**在 UEFI bios 中安装 Grub** 并不容易,所以我要写这篇教程。 +出于这个原因,由于在新安装 Arch Linux 时在 UEFI bios 中安装 Grub 并不容易,所以我要写这篇教程。 ### 定位 EFI 分区 -在 **Arch Linux** 上安装 **Grub** 的第一件重要事情是定位 **EFI** 分区。让我们运行以下命令以找到此分区: +在 Arch Linux 上安装 Grub 的第一件重要事情是定位 EFI 分区。让我们运行以下命令以找到此分区: ``` # fdisk -l ``` -我们需要检查标记为 **EFI System** 的分区,我这里是 **/dev/sda2**。 +我们需要检查标记为 EFI System 的分区,我这里是 `/dev/sda2`。 -之后,我们需要在例如 /boot/efi 上挂载这个分区: +之后,我们需要在例如 `/boot/efi` 上挂载这个分区: ``` # mkdir /boot/efi # mount /dev/sdb2 /boot/efi ``` -另一件重要的事情是将此分区添加到 **/etc/fstab** 中。 +另一件重要的事情是将此分区添加到 `/etc/fstab` 中。 #### 安装 Grub @@ -39,7 +39,7 @@ #### 自动将 Windows 添加到 Grub 菜单中 -为了自动将**Windows 条目添加到 Grub 菜单**,我们需要安装 **os-prober**: +为了自动将 Windows 条目添加到 Grub 菜单,我们需要安装 os-prober: ``` # pacman -Sy os-prober @@ -62,7 +62,7 @@ via: http://fasterland.net/how-to-install-grub-on-arch-linux-uefi.html 作者:[Francesco Mondello][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 6efbbdd4fb1121cc39a2214599ab5a2a83bef19d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 22 Oct 2018 22:17:46 +0800 Subject: [PATCH 100/158] PUB:20181013 How to Install GRUB on Arch Linux (UEFI).md @geekpi https://linux.cn/article-10143-1.html --- .../20181013 How to Install GRUB on Arch Linux (UEFI).md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20181013 How to Install GRUB on Arch Linux (UEFI).md (100%) diff --git a/translated/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md b/published/20181013 How to Install GRUB on Arch Linux (UEFI).md similarity index 100% rename from translated/tech/20181013 How to Install GRUB on Arch Linux (UEFI).md rename to published/20181013 How to Install GRUB on Arch Linux (UEFI).md From c895837275cff22db5c8c1f96988480d8db87c77 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 22 Oct 2018 22:49:25 +0800 Subject: [PATCH 101/158] PRF:20181001 16 iptables tips and tricks for sysadmins.md @jrglinux --- ... iptables tips and tricks for sysadmins.md | 62 ++++++++----------- 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/translated/tech/20181001 16 iptables tips and tricks for sysadmins.md b/translated/tech/20181001 16 iptables tips and tricks for sysadmins.md index 8f75023a9d..c40c702dca 100644 --- a/translated/tech/20181001 16 iptables tips and tricks for sysadmins.md +++ b/translated/tech/20181001 16 iptables tips and tricks for sysadmins.md @@ -1,15 +1,15 @@ 系统管理员需知的 16 个 iptables 使用技巧 ======= -iptables 是一款控制系统进出流量的强大配置工具。 +> iptables 是一款控制系统进出流量的强大配置工具。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg) -现代 Linux 内核带有一个叫 [Netfilter][1] 的数据包过滤框架。Netfilter 提供了允许、禁止以及修改等操作来控制进出系统的流量数据包。基于 Netfilter 框架的用户层命令行工具 **iptables** 提供了强大的防火墙配置功能,允许你添加规则来构建防火墙策略。[iptables][2] 丰富复杂的功能以及其巴洛克式命令语法可能让人难以驾驭。我们就来探讨一下其中的一些功能,提供一些系统管理员解决某些问题需要的使用技巧。 +现代 Linux 内核带有一个叫 [Netfilter][1] 的数据包过滤框架。Netfilter 提供了允许、丢弃以及修改等操作来控制进出系统的流量数据包。基于 Netfilter 框架的用户层命令行工具 `iptables` 提供了强大的防火墙配置功能,允许你添加规则来构建防火墙策略。[iptables][2] 丰富复杂的功能以及其巴洛克式命令语法可能让人难以驾驭。我们就来探讨一下其中的一些功能,提供一些系统管理员解决某些问题需要的使用技巧。 ### 避免封锁自己 -应用场景:假设你将对公司服务器上的防火墙规则进行修改,需要避免封锁你自己以及其他同事的情况(这将会带来一定时间和金钱的损失,也许一旦发生马上就有部门打电话找你了) +应用场景:假设你将对公司服务器上的防火墙规则进行修改,你需要避免封锁你自己以及其他同事的情况(这将会带来一定时间和金钱的损失,也许一旦发生马上就有部门打电话找你了) #### 技巧 #1: 开始之前先备份一下 iptables 配置文件。 @@ -17,7 +17,6 @@ iptables 是一款控制系统进出流量的强大配置工具。 ``` /sbin/iptables-save > /root/iptables-works - ``` #### 技巧 #2: 更妥当的做法,给文件加上时间戳。 @@ -25,28 +24,24 @@ iptables 是一款控制系统进出流量的强大配置工具。 ``` /sbin/iptables-save > /root/iptables-works-`date +%F` - ``` 然后你就可以生成如下名字的文件: ``` /root/iptables-works-2018-09-11 - ``` 这样万一使得系统不工作了,你也可以很快的利用备份文件恢复原状: ``` /sbin/iptables-restore < /root/iptables-works-2018-09-11 - ``` -#### 技巧 #3: 每次创建 iptables 配置文件副本时,都创建一个指向 `latest` 的文件的链接。 +#### 技巧 #3: 每次创建 iptables 配置文件副本时,都创建一个指向最新的文件的链接。 ``` ln –s /root/iptables-works-`date +%F` /root/iptables-works-latest - ``` #### 技巧 #4: 将特定规则放在策略顶部,底部放置通用规则。 @@ -55,19 +50,17 @@ ln –s /root/iptables-works-`date +%F` /root/iptables-works-latest ``` iptables -A INPUT -p tcp --dport 22 -j DROP - ``` -你在规则中指定的条件越多,封锁自己的可能性就越小。不要使用上面暗中通用规则,而是使用如下的规则: +你在规则中指定的条件越多,封锁自己的可能性就越小。不要使用上面非常通用的规则,而是使用如下的规则: ``` iptables -A INPUT -p tcp --dport 22 –s 10.0.0.0/8 –d 192.168.100.101 -j DROP - ``` -此规则表示在 **INPUT** 链尾追加一条新规则,将源地址为 **10.0.0.0/8**、 目的地址是 **192.168.100.101**、目的端口号是 **22** (**\--dport 22** ) 的 **tcp**(**-p tcp** )数据包通通丢弃掉。 +此规则表示在 `INPUT` 链尾追加一条新规则,将源地址为 `10.0.0.0/8`、 目的地址是 `192.168.100.101`、目的端口号是 `22` (`--dport 22` ) 的 TCP(`-p tcp` )数据包通通丢弃掉。 -还有很多方法可以设置更具体的规则。例如,使用 **-i eth0** 将会限制这条规则作用于 **eth0** 网卡,对 **eth1** 网卡则不生效。 +还有很多方法可以设置更具体的规则。例如,使用 `-i eth0` 将会限制这条规则作用于 `eth0` 网卡,对 `eth1` 网卡则不生效。 #### 技巧 #5: 在策略规则顶部将你的 IP 列入白名单。 @@ -75,10 +68,9 @@ iptables -A INPUT -p tcp --dport 22 –s 10.0.0.0/8 –d 192.168.100.101 -j DROP ``` iptables -I INPUT -s -j ACCEPT - ``` -你需要将该规则添加到策略首位置。**-I** 表示则策略首部插入规则,**-A** 表示在策略尾部追加规则。 +你需要将该规则添加到策略首位置。`-I` 表示则策略首部插入规则,`-A` 表示在策略尾部追加规则。 #### 技巧 #6: 理解现有策略中的所有规则。 @@ -100,7 +92,7 @@ iptables -I INPUT -s -j ACCEPT #### 技巧 #2: 将用户完成工作所需的最少量服务设置为允许 -该策略需要允许工作站能通过 DHCP (**-p udp --dport 67:68 -sport 67:68**)来获取 IP 地址、子网掩码以及其他一些信息。对于远程操作,需要允许 SSH 服务(**-dport 22**),邮件服务(**--dport 25**),DNS服务(**--dport 53**),ping 功能(**-p icmp**),NTP 服务(**--dport 123 --sport 123**)以及HTTP 服务(**-dport 80**)和 HTTPS 服务(**--dport 443**)。 +该策略需要允许工作站能通过 DHCP(`-p udp --dport 67:68 -sport 67:68`)来获取 IP 地址、子网掩码以及其他一些信息。对于远程操作,需要允许 SSH 服务(`-dport 22`),邮件服务(`--dport 25`),DNS 服务(`--dport 53`),ping 功能(`-p icmp`),NTP 服务(`--dport 123 --sport 123`)以及 HTTP 服务(`-dport 80`)和 HTTPS 服务(`--dport 443`)。 ``` # Set a default policy of DROP @@ -144,7 +136,7 @@ COMMIT ### 限制 IP 地址范围 -应用场景:贵公司的 CEO 认为员工在 Facebook 上花费过多的时间,需要采取一些限制措施。CEO 命令下达给 CIO,CIO 命令CISO,最终任务由你来执行。你决定阻止一切到 Facebook 的访问连接。首先你使用 `host` 或者 `whois` 命令来获取 Facebook 的 IP 地址。 +应用场景:贵公司的 CEO 认为员工在 Facebook 上花费过多的时间,需要采取一些限制措施。CEO 命令下达给 CIO,CIO 命令 CISO,最终任务由你来执行。你决定阻止一切到 Facebook 的访问连接。首先你使用 `host` 或者 `whois` 命令来获取 Facebook 的 IP 地址。 ``` host -t a www.facebook.com @@ -153,33 +145,33 @@ star.c10r.facebook.com has address 31.13.65.17 whois 31.13.65.17 | grep inetnum inetnum:        31.13.64.0 - 31.13.127.255 ``` -然后使用 [CIDR to IPv4转换][3] 页面来将其转换为 CIDR 表示法。然后你得到 **31.13.64.0/18** 的地址。输入以下命令来阻止对 Facebook 的访问: + +然后使用 [CIDR 到 IPv4 转换][3] 页面来将其转换为 CIDR 表示法。然后你得到 `31.13.64.0/18` 的地址。输入以下命令来阻止对 Facebook 的访问: ``` iptables -A OUTPUT -p tcp -i eth0 –o eth1 –d 31.13.64.0/18 -j DROP ``` -### 按时间规定做限制-场景1 +### 按时间规定做限制 - 场景1 -应用场景:公司员工强烈反对限制一切对 Facebook 的访问,这导致了 CEO 放宽了要求(考虑到员工的反对以及他的助理提醒说她将 HIS Facebook 页面保持在最新状态)。然后 CEO 决定允许在午餐时间访问 Facebook(中午12点到下午1点之间)。假设默认规则是丢弃,使用 iptables 的时间功能便可以实现。 +应用场景:公司员工强烈反对限制一切对 Facebook 的访问,这导致了 CEO 放宽了要求(考虑到员工的反对以及他的助理提醒说她负责更新他的 Facebook 页面)。然后 CEO 决定允许在午餐时间访问 Facebook(中午 12 点到下午 1 点之间)。假设默认规则是丢弃,使用 iptables 的时间功能便可以实现。 ``` iptables –A OUTPUT -p tcp -m multiport --dport http,https -i eth0 -o eth1 -m time --timestart 12:00 –timestop 13:00 –d 31.13.64.0/18 -j ACCEPT ``` -该命令中指定在中午12点(**\--timestart 12:00**)到下午1点(**\--timestop 13:00**)之间允许(**-j ACCEPT**)到 Facebook.com (**-d [31.13.64.0/18][5]**)的 http 以及 https (**-m multiport --dport http,https**)的访问。 +该命令中指定在中午12点(`--timestart 12:00`)到下午 1 点(`--timestop 13:00`)之间允许(`-j ACCEPT`)到 Facebook.com (`-d [31.13.64.0/18][5]`)的 http 以及 https (`-m multiport --dport http,https`)的访问。 -### 按时间规定做限制-场景2 +### 按时间规定做限制 - 场景2 -应用场景 -Scenario: 在计划系统维护期间,你需要设置凌晨2点到3点之间拒绝所有的 TCP 和 UDP 访问,这样维护任务就不会受到干扰。使用两个 iptables 规则可实现: +应用场景:在计划系统维护期间,你需要设置凌晨 2 点到 3 点之间拒绝所有的 TCP 和 UDP 访问,这样维护任务就不会受到干扰。使用两个 iptables 规则可实现: ``` iptables -A INPUT -p tcp -m time --timestart 02:00 --timestop 03:00 -j DROP iptables -A INPUT -p udp -m time --timestart 02:00 --timestop 03:00 -j DROP ``` -该规则禁止(**-j DROP**)在凌晨2点(**\--timestart 02:00**)到凌晨3点(**\--timestop 03:00**)之间的 TCP 和 UDP (**-p tcp and -p udp**)的数据进入(**-A INPUT**)访问。 +该规则禁止(`-j DROP`)在凌晨2点(`--timestart 02:00`)到凌晨3点(`--timestop 03:00`)之间的 TCP 和 UDP (`-p tcp and -p udp`)的数据进入(`-A INPUT`)访问。 ### 限制连接数量 @@ -189,11 +181,11 @@ iptables -A INPUT -p udp -m time --timestart 02:00 --timestop 03:00 -j DROP iptables –A INPUT –p tcp –syn -m multiport -–dport http,https –m connlimit -–connlimit-above 20 –j REJECT -–reject-with-tcp-reset ``` -分析一下上面的命令。如果单个主机在一分钟之内新建立(**-p tcp -syn**)超过20个(**-connlimit-above 20**)到你的 web 服务器(**--dport http,https**)的连接,服务器将拒绝(**-j REJECT**)建立新的连接,然后通知该主机新建连接被拒绝(**--reject-with-tcp-reset**)。 +分析一下上面的命令。如果单个主机在一分钟之内新建立(`-p tcp -syn`)超过 20 个(`-connlimit-above 20`)到你的 web 服务器(`--dport http,https`)的连接,服务器将拒绝(`-j REJECT`)建立新的连接,然后通知对方新建连接被拒绝(`--reject-with-tcp-reset`)。 ### 监控 iptables 规则 -应用场景:由于数据包会遍历链中的规则,iptables遵循 ”首次匹配获胜“ 的原则,因此经常匹配的规则应该靠近策略的顶部,而不太频繁匹配的规则应该接近底部。 你怎么知道哪些规则使用最多或最少,可以在顶部或底部附近监控? +应用场景:由于数据包会遍历链中的规则,iptables 遵循 “首次匹配获胜” 的原则,因此经常匹配的规则应该靠近策略的顶部,而不太频繁匹配的规则应该接近底部。 你怎么知道哪些规则使用最多或最少,可以在顶部或底部附近监控? #### 技巧 #1: 查看规则被访问了多少次 @@ -203,7 +195,7 @@ iptables –A INPUT –p tcp –syn -m multiport -–dport http,https –m connl iptables -L -v -n –line-numbers ``` -用 **-L** 选项列出链中的所有规则。因为没有指定具体哪条链,所有链规则都会被输出,使用 **-v** 选项显示详细信息,**-n** 选项则显示数字格式的数据包和字节计数器,每个规则开头的数值表示该规则在链中的位置。 +用 `-L` 选项列出链中的所有规则。因为没有指定具体哪条链,所有链规则都会被输出,使用 `-v` 选项显示详细信息,`-n` 选项则显示数字格式的数据包和字节计数器,每个规则开头的数值表示该规则在链中的位置。 根据数据包和字节计数的结果,你可以将访问频率最高的规则放到顶部,将访问频率最低的规则放到底部。 @@ -215,17 +207,17 @@ iptables -L -v -n –line-numbers iptables -nvL | grep -v "0     0" ``` -注意:两个数字0之间不是 Tab 键,而是 5 个空格。 +注意:两个数字 0 之间不是 Tab 键,而是 **5** 个空格。 #### 技巧 #3: 监控正在发生什么 -可能你也想像使用 **top** 命令一样来实时监控 iptables 的情况。使用如下命令来动态监视 iptables 中的活动,并仅显示正在遍历的规则: +可能你也想像使用 `top` 命令一样来实时监控 iptables 的情况。使用如下命令来动态监视 iptables 中的活动,并仅显示正在遍历的规则: ``` watch --interval=5 'iptables -nvL | grep -v "0     0"' ``` -**watch** 命令通过参数 **iptables -nvL | grep -v “0 0“** 每隔 5s 输出 iptables 的动态。这条命令允许你查看数据包和字节计数的变化。 +`watch` 命令通过参数 `iptables -nvL | grep -v “0 0“` 每隔 5 秒输出 iptables 的动态。这条命令允许你查看数据包和字节计数的变化。 ### 输出日志 @@ -239,7 +231,7 @@ watch --interval=5 'iptables -nvL | grep -v "0     0"' ### 不要满足于允许和丢弃规则 -本文中已经涵盖了 iptables 的很多方面,从避免封锁自己、iptables 配置防火墙以及监控 iptables 中的活动等等方面介绍了 iptables。你可以从这里开始探索 iptables 甚至获取更多的使用技巧。 +本文中已经涵盖了 iptables 的很多方面,从避免封锁自己、配置 iptables 防火墙以及监控 iptables 中的活动等等方面介绍了 iptables。你可以从这里开始探索 iptables 甚至获取更多的使用技巧。 -------------------------------------------------------------------------------- @@ -247,8 +239,8 @@ via: https://opensource.com/article/18/10/iptables-tips-and-tricks 作者:[Gary Smith][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[jrg](https://github.com/jrglinu) -校对:[校对者ID](https://github.com/校对者ID) +译者:[jrg](https://github.com/jrglinux) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 34c5d87c7332f9a0d54badd15fdded93e6fcf256 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Mon, 22 Oct 2018 22:49:54 +0800 Subject: [PATCH 102/158] PUB:20181001 16 iptables tips and tricks for sysadmins.md @jrglinux https://linux.cn/article-10144-1.html --- .../20181001 16 iptables tips and tricks for sysadmins.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20181001 16 iptables tips and tricks for sysadmins.md (100%) diff --git a/translated/tech/20181001 16 iptables tips and tricks for sysadmins.md b/published/20181001 16 iptables tips and tricks for sysadmins.md similarity index 100% rename from translated/tech/20181001 16 iptables tips and tricks for sysadmins.md rename to published/20181001 16 iptables tips and tricks for sysadmins.md From 20982572c2307c8b643389503b1f41c488ad5901 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 23 Oct 2018 07:06:26 +0800 Subject: [PATCH 103/158] [Translated] /20180901 Flameshot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md Signed-off-by: Chang Liu --- ...t Powerful Feature-rich Screenshot Tool.md | 169 ------------------ ...t Powerful Feature-rich Screenshot Tool.md | 153 ++++++++++++++++ 2 files changed, 153 insertions(+), 169 deletions(-) delete mode 100644 sources/tech/20180901 Flameshot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md create mode 100644 translated/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 deleted file mode 100644 index 2eab96c02b..0000000000 --- a/sources/tech/20180901 Flameshot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md +++ /dev/null @@ -1,169 +0,0 @@ -FSSlc Translating -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/ diff --git a/translated/tech/20180901 Flameshot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md b/translated/tech/20180901 Flameshot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md new file mode 100644 index 0000000000..898955242a --- /dev/null +++ b/translated/tech/20180901 Flameshot - A Simple, Yet Powerful Feature-rich Screenshot Tool.md @@ -0,0 +1,153 @@ +Flameshot – 一个简洁但功能丰富的截图工具 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/09/Flameshot-720x340.png) + +截图是我工作的一部分,我先前使用深度截图工具来截图,深度截图是一个简单、轻量级且非常简洁的截图工具。它自带许多功能例如窗口识别、快捷键支持、图片编辑、延时截图、社交分享、智能存储以及图片清晰度调整等功能。今天我碰巧发现了另一个具备多种功能的截图工具,它就是 **Flameshot** ,一个简单但功能丰富的针对类 Unix 系统的截图工具。它简单易用,可定制并且有选项可以支持上传截图到在线图片分享网站 **imgur** 上。同时 Flameshot 有一个 CLI 版本,所以你也可以从命令行来进行截图。Flameshot 是一个完全免费且开源的工具。在本教程中,我们将看到如何安装 Flameshot 以及如何使用它来截图。 + +### 安装 Flameshot + +**在 Arch Linux 上:** + +Flameshot 可以从 Arch LInux 的 [community] 仓库中获取。确保你已经启用了 community 仓库,然后就可以像下面展示的那样使用 pacman 来安装 Flameshot : +``` +$ sudo pacman -S flameshot +``` + +它也可以从 [**AUR**][1] 中获取,所以你还可以使用任意一个 AUR 帮助程序(例如 [**Yay**][2])来在基于 Arch 的系统中安装它: +``` +$ yay -S flameshot-git +``` + +**在 Fedora 中:** + +``` +$ sudo dnf install flameshot +``` + +在 **Debian 10+** 和 **Ubuntu 18.04+** 中,可以使用 APT 包管理器来安装它: +``` +$ sudo apt install flameshot +``` + +**在 openSUSE 上:** + +``` +$ sudo zypper install flameshot +``` +在其他的 Linux 发行版中,可以从源代码编译并安装它。编译过程中需要 **Qt version 5.3** 以及 **GCC 4.9.2** 或者它们的更高版本。 + +### 使用 + +可以从菜单或者应用启动器中启动 Flameshot。在 MATE 桌面环境,它通常可以在 **Applications - > Graphics** 下找到。 + +一旦打开了它,你就可以在系统面板中看到 Flameshot 的托盘图标。 + +**注意:** + +假如你使用 Gnome 桌面环境,为了能够看到系统托盘图标,你需要安装 [TopIcons][3] 扩展。 + +在 Flameshot 托盘图标上右击,你便会看到几个菜单项,例如打开配置窗口、信息窗口以及退出该应用。 + +要进行截图,只需要点击托盘图标就可以了。接着你将看到如何使用 Flameshot 的帮助窗口。选择一个截图区域,然后敲 **ENTER** 键便可以截屏了,点击右键便可以看到颜色拾取器,再敲空格键便可以查看屏幕侧边的面板。你可以使用鼠标的滚轮来增加或者减少指针的宽度。 + +Flameshot 自带一系列非常好的功能,例如: + + * 可以进行手写 + * 可以划直线 + * 可以画长方形或者圆形框 + * 可以进行长方形区域选择 + * 可以画箭头 + * 可以对要点进行标注 + * 可以添加文本 + * 可以对图片或者文字进行模糊处理 + * 可以展示图片的尺寸大小 + * 在编辑图片是可以进行撤销和重做操作 + * 可以将选择的东西复制到剪贴板 + * 可以保存选择 + * 可以离开截屏 + * 可以选择另一个 app 来打开图片 + * 可以上传图片到 imgur 网站 + * 可以将图片固定到桌面上 + +下面是一个示例的视频: + + + +**快捷键** + +Frameshot 也支持快捷键。在 Flameshot 的托盘图标上右击并点击 **Information** 窗口便可以看到在 GUI 模式下所有可用的快捷键。下面是在 GUI 模式下可用的快捷键清单: + +| 快捷键 | 描述 | +|------------------------|------------------------------| +| ←, ↓, ↑, → | 移动选择区域 1px | +| Shift + ←, ↓, ↑, → | 将选择区域大小更改 1px | +| Esc | 退出截图 | +| Ctrl + C | 复制到粘贴板 | +| Ctrl + S | 将选择区域保存为文件 | +| Ctrl + Z | 撤销最近的一次操作 | +| Right Click | 展示颜色拾取器 | +| Mouse Wheel | 改变工具的宽度 | + +边按住 Shift 键并拖动选择区域的其中一个控制点将会对它相反方向的控制点做类似的拖放操作。 + +**命令行选项** + +Flameshot 也支持一系列的命令行选项来延时截图和保存图片到自定义的路径。 + +要使用 Flameshot GUI 模式,运行: +``` +$ flameshot gui +``` + +要使用 GUI 模式截屏并将你选取的区域保存到一个自定义的路径,运行: +``` +$ flameshot gui -p ~/myStuff/captures +``` + +要延时 2 秒后打开 GUI 模式可以使用: +``` +$ flameshot gui -d 2000 +``` + +要延时 2 秒并将截图保存到一个自定义的路径(无 GUI)可以使用: +``` +$ flameshot full -p ~/myStuff/captures -d 2000 +``` + +要截图全屏并保存到自定义的路径和粘贴板中使用: +``` +$ flameshot full -c -p ~/myStuff/captures +``` + +要在截屏中包含鼠标并将图片保存为 **PNG** 格式可以使用: +``` +$ flameshot screen -r +``` + +要对屏幕 1 进行截屏并将截屏复制到粘贴板中可以运行: +``` +$ flameshot screen -n 1 -c +``` + +你还需要什么功能呢?Flameshot 拥有几乎截屏的所有功能:添加注释、编辑图片、模糊处理或者对要点做高亮等等功能。我想:在我找到它的最佳替代品之前,我将一直使用 Flameshot 来作为我当前的截图工具。请尝试一下它,你不会失望的。 + +好了,这就是今天的全部内容了。后续将有更多精彩内容,请保持关注! + +Cheers! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/flameshot-a-simple-yet-powerful-feature-rich-screenshot-tool/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[FSSlc](https://github.com/FSSlc) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: https://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 940e6c566634003644b20eb5b43c42a5f6ce076c Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 23 Oct 2018 08:53:34 +0800 Subject: [PATCH 104/158] translated --- ...ux containers as a non-root with Podman.md | 84 ------------------- ...ux containers as a non-root with Podman.md | 82 ++++++++++++++++++ 2 files changed, 82 insertions(+), 84 deletions(-) delete mode 100644 sources/tech/20181015 Running Linux containers as a non-root with Podman.md create mode 100644 translated/tech/20181015 Running Linux containers as a non-root with Podman.md diff --git a/sources/tech/20181015 Running Linux containers as a non-root with Podman.md b/sources/tech/20181015 Running Linux containers as a non-root with Podman.md deleted file mode 100644 index 4bf8f7c407..0000000000 --- a/sources/tech/20181015 Running Linux containers as a non-root with Podman.md +++ /dev/null @@ -1,84 +0,0 @@ -translating---geekpi - -Running Linux containers as a non-root with Podman -====== - -![](https://fedoramagazine.org/wp-content/uploads/2018/10/podman-816x345.jpg) - -Linux containers are processes with certain isolation features provided by a Linux kernel — including filesystem, process, and network isolation. Containers help with portability — applications can be distributed in container images along with their dependencies, and run on virtually any Linux system with a container runtime. - -Although container technologies exist for a very long time, Linux containers were widely popularized by Docker. The word “Docker” can refer to several different things, including the container technology and tooling, the community around that, or the Docker Inc. company. However, in this article, I’ll be using it to refer to the technology and the tooling that manages Linux containers. - -### What is Docker - -[Docker][1] is a daemon that runs on your system as root, and manages running containers by leveraging features of the Linux kernel. Apart from running containers, it also makes it easy to manage container images — interacting with container registries, storing images, managing container versions, etc. It basically supports all the operations you need to run individual containers. - -But even though Docker is very a handy tool for managing Linux containers, it has two drawbacks: it is a daemon that needs to run on your system, and it needs to run with root privileges which might have certain security implications. Both of those, however, are being addressed by Podman. - -### Introducing Podman - -[Podman][2] is a container runtime providing a very similar features as Docker. And as already hinted, it doesn’t require any daemon to run on your system, and it can also run without root privileges. So let’s have a look at some examples of using Podman to run Linux containers. - -#### Running containers with Podman - -One of the simplest examples could be running a Fedora container, printing “Hello world!” in the command line: - -``` - $ podman run --rm -it fedora:28 echo "Hello world!" -``` - -Building an image using the common Dockerfile works the same way as it does with Docker: - -``` - $ cat Dockerfile - FROM fedora:28 - RUN dnf -y install cowsay - - $ podman build . -t hello-world - ... output omitted ... - - $ podman run --rm -it hello-world cowsay "Hello!" -``` - -To build containers, Podman calls another tool called Buildah in the background. You can read a recent [post about building container images with Buildah][3] — not just using the typical Dockerfile. - -Apart from building and running containers, Podman can also interact with container registries. To log in to a container registry, for example the widely used Docker Hub, run: - -``` - $ podman login docker.io -``` - -To push the image I just built, I just need to tag so it refers to the specific container registry and my personal namespace, and then simply push it. - -``` - $ podman -t hello-world docker.io/asamalik/hello-world - $ podman push docker.io/asamalik/hello-world -``` - -By the way, have you noticed how I run everything as a non-root user? Also, there is no big fat daemon running on my system! - -#### Installing Podman - -Podman is available by default on [Silverblue][4] — a new generation of Linux Workstation for container-based workflows. To install it on any Fedora release, simply run: - -``` - $ sudo dnf install podman -``` - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/running-containers-with-podman/ - -作者:[Adam Šamalík][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/asamalik/ -[b]: https://github.com/lujun9972 -[1]: https://docs.docker.com/ -[2]: https://podman.io/ -[3]: https://fedoramagazine.org/daemon-less-container-management-buildah/ -[4]: https://silverblue.fedoraproject.org/ diff --git a/translated/tech/20181015 Running Linux containers as a non-root with Podman.md b/translated/tech/20181015 Running Linux containers as a non-root with Podman.md new file mode 100644 index 0000000000..627ed291e4 --- /dev/null +++ b/translated/tech/20181015 Running Linux containers as a non-root with Podman.md @@ -0,0 +1,82 @@ +使用 Podman 以非 root 用户身份运行 Linux 容器 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/10/podman-816x345.jpg) + +Linux容器是有由 Linux 内核提供的具有特定隔离功能的进程 - 包括文件系统、进程和网络隔离。容器有助于实现可移植性 - 应用可以在容器镜像中与其依赖项一起分发,并可在几乎任何有容器运行时的 Linux 系统上运行。 + +虽然容器技术存在了很长时间,但 Linux 容器是由 Docker 广泛推广。 “Docker” 这个词可以指几个不同的东西,包括容器技术和工具,周围的社区,或者 Docker Inc. 公司。但是,在本文中,我将用来指管理 Linux 容器的技术和工具。 + +### 什么是 Docker + +[Docker][1] 是一个以 root 身份在你的系统上运行的守护程序,它利用 Linux 内核的功能来管理正在运行的容器。除了运行容器之外,它还可以轻松管理容器镜像 - 与容器托管交互、存储映像、管理容器版本等。它基本上支持运行单个容器所需的所有操作。 + +但即使 Docker 是管理 Linux 容器的一个非常方便的工具,它也有两个缺点:它是一个需要在你的系统上运行的守护进程,并且需要以 root 权限运行,这可能有一定的安全隐患。然而,Podman 在解决这两个问题。 + +### Podman 介绍 + +[Podman][2] 是一个容器运行时,提供与 Docker 非常相似的功能。正如已经提示的那样,它不需要在你的系统上运行任何守护进程,并且它也可以在没有 root 权限的情况下运行。让我们看看使用 Podman 运行 Linux 容器的一些示例。 + +#### 使用 Podman 运行容器 + +其中一个最简单的例子可能是运行 Fedora 容器,在命令行中打印 “Hello world!”: + +``` + $ podman run --rm -it fedora:28 echo "Hello world!" +``` + +使用通用 Dockerfile 构建镜像的方式与 Docker 相同: + +``` + $ cat Dockerfile + FROM fedora:28 + RUN dnf -y install cowsay + + $ podman build . -t hello-world + ... output omitted ... + + $ podman run --rm -it hello-world cowsay "Hello!" +``` + +为了构建容器,Podman 在后台调用另一个名为 Buildah 的工具。你可以阅读最近一篇[关于使用 Buildah 构建容器镜像的文章][3] - 它不仅仅是使用典型的 Dockerfile。 + +除了构建和运行容器外,Podman 还可以与容器托管进行交互。要登录容器托管,例如广泛使用的 Docker Hub,请运行: + +``` + $ podman login docker.io +``` + +为了推送我刚刚构建的镜像,我只需打上标记来代表特定的容器托管,然后直接推送它。 + +``` + $ podman -t hello-world docker.io/asamalik/hello-world + $ podman push docker.io/asamalik/hello-world +``` + +顺便说一下,你是否注意到我如何以非 root 用户身份运行所有内容?此外,我的系统上没有运行大的守护进程! + +#### 安装 Podman + +Podman 默认在 [Silverblue][4] 上提供 - 一个基于容器的工作流的新一代 Linux 工作站。要在任何 Fedora 版本上安装它,只需运行: + +``` + $ sudo dnf install podman +``` + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/running-containers-with-podman/ + +作者:[Adam Šamalík][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/asamalik/ +[b]: https://github.com/lujun9972 +[1]: https://docs.docker.com/ +[2]: https://podman.io/ +[3]: https://fedoramagazine.org/daemon-less-container-management-buildah/ +[4]: https://silverblue.fedoraproject.org/ From 25ba4877587f0b672a06520d404b24b6932fa217 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 23 Oct 2018 08:56:41 +0800 Subject: [PATCH 105/158] translating --- sources/tech/20181019 Edit your videos with Pitivi on Fedora.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20181019 Edit your videos with Pitivi on Fedora.md b/sources/tech/20181019 Edit your videos with Pitivi on Fedora.md index ca70d286e0..dd47c2d534 100644 --- a/sources/tech/20181019 Edit your videos with Pitivi on Fedora.md +++ b/sources/tech/20181019 Edit your videos with Pitivi on Fedora.md @@ -1,3 +1,5 @@ +translating----geekpi + Edit your videos with Pitivi on Fedora ====== From 18f1ab3516bada9cd912a70a0e68527eb27950b5 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 09:54:33 +0800 Subject: [PATCH 106/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Improve=20login?= =?UTF-8?q?=20security=20with=20challenge-response=20authentication?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... with challenge-response authentication.md | 183 ++++++++++++++++++ 1 file changed, 183 insertions(+) create mode 100644 sources/tech/20181022 Improve login security with challenge-response authentication.md diff --git a/sources/tech/20181022 Improve login security with challenge-response authentication.md b/sources/tech/20181022 Improve login security with challenge-response authentication.md new file mode 100644 index 0000000000..66ed2534b0 --- /dev/null +++ b/sources/tech/20181022 Improve login security with challenge-response authentication.md @@ -0,0 +1,183 @@ +Improve login security with challenge-response authentication +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/10/challenge-response-816x345.png) + +### Introduction + +Today, Fedora offers multiple ways to improve the secure authentication of our user accounts. Of course it has the familiar user name and password to login. It also offers additional authentication options such as biometric, fingerprint, smart card, one-time password, and even challenge-response authentication. + +Each authentication method has clear pros and cons. That, in itself, could be a topic for a rather lengthy article. Fedora Magazine has covered a few of these options previously: + + ++ [Using the YubiKey4 with Fedora][1] ++ [Fedora 28: Better smart card support in OpenSSH][2] + + +One of the most secure methods in modern Fedora releases is offline hardware challenge-response. It’s also one of the easiest to deploy. Here’s how. + +### Challenge-response authentication + +Technically, when you provide a password, you’re responding to a user name challenge. The offline challenge response covered here requires your user name first. Next, Fedora challenges you to provide an encrypted physical hardware token. The token responds to the challenge with another encrypted key it stores via the Pluggable Authentication Modules (PAM) framework. Finally, Fedora prompts you for the password. This prevents someone from just using a found hardware token, or just using a user name and password without the correct encrypted key. + +This means that in addition to your user name and password, you must have previously registered one or more encrypted hardware tokens with the OS. And you have to provide that physical hardware token to be able to authenticate with your user name. + +Some challenge-response methods, like one time passwords (OTP), take an encrypted code key on the hardware token, and pass that key across the network to a remote authentication server. The server then tells Fedora’s PAM framework if it’s is a valid token for that user name. This is great if the authentication server(s) are on the local network. The downside is if the network connection is down or you’re working remote without a network connection, you can’t use this remote authentication method. You could be locked out of the system until you can connect through the network to the server. + +Sometimes a workplace requires use of Yubikey One Time Passwords (OTP) configuration. However, on home or personal systems you may prefer a local challenge-response configuration. Everything is local, and the method requires no remote network calls. The following process works on Fedora 27, 28, and 29. + +### Preparation + +#### Hardware token keys + +First you need a secure hardware token key. Specifically, this process requires a Yubikey 4, Yubikey NEO, or a recently released Yubikey 5 series device which also supports FIDO2. You should purchase two of them to provide a backup in case one becomes lost or damaged. You can use these keys on numerous workstations. The simpler FIDO or FIDO U2F only versions don’t work for this process, but are great for online services that use FIDO. + +#### Backup, backup, and backup + +Next, make a backup of all your important data. You may want to test the configuration in a Fedora 27/28/29 cloned VM to make sure you understand the process before setting up your personal workstation. + +#### Updating and installing + +Now make sure Fedora is up to date. Then install the required Fedora Yubikey packages via these dnf commands: + +``` +$ sudo dnf upgrade +$ sudo dnf install ykclient* ykpers* pam_yubico* +$ cd +``` + +If you’re in a VM environment, such as Virtual Box, make sure the Yubikey device is inserted in a USB port, and enable USB access to the Yubikey in the VM control. + +### Configuring Yubikey + +Verify that your user account has access to the USB Yubikey: + +``` +$ ykinfo -v +version: 3.5.0 +``` + +If the YubiKey is not detected, the following error message appears: + +``` +Yubikey core error: no yubikey present +``` + +Next, initialize each of your new Yubikeys with the following ykpersonalize command. This sets up the Yubikey configuration slot 2 with a Challenge Response using the HMAC-SHA1 algorithm, even with less than 64 characters. If you have already setup your Yubikeys for challenge-response, you don’t need to run ykpersonalize again. + +``` +ykpersonalize -2 -ochal-resp -ochal-hmac -ohmac-lt64 -oserial-api-visible +``` + +Some users leave the YubiKey in their workstation while using it, and even use challenge-response for virtual machines. However, for more security you may prefer to manually trigger the Yubikey to respond to challenge. + +To add that manual challenge button trigger, add the -ochal-btn-trig flag. This flag causes the Yubikey to flash the yubikey LED on a request. It waits for you to press the button on the hardware key area within 15 seconds to produce the response key. + +``` +$ ykpersonalize -2 -ochal-resp -ochal-hmac -ohmac-lt64 -ochal-btn-trig -oserial-api-visible +``` + +Do this for each of your new hardware keys, only once per key. Once you have programmed your keys, store the Yubikey configuration to ~/.yubico with the following command: + +``` +$ ykpamcfg -2 -v +debug: util.c:222 (check_firmware_version): YubiKey Firmware version: 4.3.4 + +Sending 63 bytes HMAC challenge to slot 2 +Sending 63 bytes HMAC challenge to slot 2 +Stored initial challenge and expected response in '/home/chuckfinley/.yubico/challenge-9992567'. +``` + +If you are setting up multiple keys for backup purposes, configure all the keys the same, and store each key’s challenge-response using the ykpamcfg utility. If you run the command ykpersonalize on an existing registered key, you must store the configuration again. + +### Configuring /etc/pam.d/sudo + +Now to verify this configuration worked, **in the same terminal window** you’ll setup sudo to require the use of the Yubikey challenge-response. Insert the following line into the /etc/pam.d/sudo file: + +``` +auth required pam_yubico.so mode=challenge-response +``` + +Insert the above auth line into the file above the auth include system-auth line. Then save the file and exit the editor. In a default Fedora 29 setup, /etc/pam.d/sudo should now look like this: + +``` +#%PAM-1.0 +auth required pam_yubico.so mode=challenge-response +auth include system-auth +account include system-auth +password include system-auth +session optional pam_keyinit.so revoke +session required pam_limits.so +session include system-auth +``` + +**Keep this original terminal window open** , and test by opening another new terminal window. In the new terminal window type: + +``` +$ sudo echo testing +``` + +You should notice the LED blinking on the key. Tap the Yubikey button and you should see a prompt for your sudo password. After you enter your password, you should see “testing” echoed in the terminal screen. + +Now test to ensure a correct failure. Start another terminal window and remove the Yubikey from the USB port. Verify that sudo no longer works without the Yubikey with this command: + +``` +$ sudo echo testing fail +``` + +You should immediately be prompted for the sudo password. Even if you enter the password, it should fail. + +### Configuring Gnome Desktop Manager + +Once your testing is complete, now you can add challenge-response support for the graphical login. Re-insert your Yubikey into the USB port. Next you’ll add the following line to the /etc/pam.d/gdm-password file: + +``` +auth required pam_yubico.so mode=challenge-response +``` + +Open a terminal window, and issue the following command. You can use another editor if desired: + +``` +$ sudo vi /etc/pam.d/gdm-password +``` + +You should see the yubikey LED blinking. Press the yubikey button, then enter the password at the prompt. + +Modify the /etc/pam.d/gdm-password file to add the new auth line above the existing line auth substack password-auth. The top of the file should now look like this: + +``` +auth [success=done ignore=ignore default=bad] pam_selinux_permit.so +auth required pam_yubico.so mode=challenge-response +auth substack password-auth +auth optional pam_gnome_keyring.so +auth include postlogin + +account required pam_nologin.so +``` + +Save the changes and exit the editor. If you use vi, the key sequence is to hit the **Esc** key, then type wq! at the prompt to save and exit. + +### Conclusion + +Now log out of GNOME. With the Yubikey inserted into the USB port, click on your user name in the graphical login. The Yubikey LED begins to flash. Touch the button, and you will be prompted for your password. + +If you lose the Yubikey, you can still use the secondary backup Yubikey in addition to your set password. You can also add additional Yubikey configurations to your user account. + +If someone gains access to your password, they still can’t login without your physical hardware Yubikey. Congratulations! You’ve now dramatically increased the security of your workstation login. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/login-challenge-response-authentication/ + +作者:[nabooengineer][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/nabooengineer/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/using-the-yubikey4-with-fedora/ +[2]: https://fedoramagazine.org/fedora-28-better-smart-card-support-openssh/ + From 19b86be6cddb0cdd2d822abd9564d8e838f8bdee Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 09:57:36 +0800 Subject: [PATCH 107/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20to=20set=20?= =?UTF-8?q?up=20WordPress=20on=20a=20Raspberry=20Pi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...w to set up WordPress on a Raspberry Pi.md | 281 ++++++++++++++++++ 1 file changed, 281 insertions(+) create mode 100644 sources/tech/20181022 How to set up WordPress on a Raspberry Pi.md diff --git a/sources/tech/20181022 How to set up WordPress on a Raspberry Pi.md b/sources/tech/20181022 How to set up WordPress on a Raspberry Pi.md new file mode 100644 index 0000000000..dcdec2d558 --- /dev/null +++ b/sources/tech/20181022 How to set up WordPress on a Raspberry Pi.md @@ -0,0 +1,281 @@ +How to set up WordPress on a Raspberry Pi +====== + +Run your WordPress website on your Raspberry Pi with this simple tutorial. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/edu_raspberry-pi-classroom_lead.png?itok=KIyhmR8W) + +WordPress is a popular open source blogging platform and content management system (CMS). It's easy to set up and has a thriving community of developers building websites and creating themes and plugins for others to use. + +Although getting hosting packages with a "one-click WordPress setup" is easy, it's also simple to set up your own on a Linux server with only command-line access, and the [Raspberry Pi][1] is a perfect way to try it out and learn something along the way. + +The four components of a commonly used web stack are Linux, Apache, MySQL, and PHP. Here's what you need to know about each. + +### Linux + +The Raspberry Pi runs Raspbian, which is a Linux distribution based on Debian and optimized to run well on Raspberry Pi hardware. It comes with two options to start: Desktop or Lite. The Desktop version boots to a familiar-looking desktop and comes with lots of educational software and programming tools, as well as the LibreOffice suite, Minecraft, and a web browser. The Lite version has no desktop environment, so it's command-line only and comes with only the essential software. + +This tutorial will work with either version, but if you use the Lite version you'll have to use another computer to access your website. + +### Apache + +Apache is a popular web server application you can install on the Raspberry Pi to serve web pages. On its own, Apache can serve static HTML files over HTTP. With additional modules, it can serve dynamic web pages using scripting languages such as PHP. + +Installing Apache is very simple. Open a terminal window and type the following command: + +``` +sudo apt install apache2 -y +``` + +By default, Apache puts a test HTML file in a web folder you can view from your Pi or another computer on your network. Just open the web browser and enter the address ****. Alternatively (particularly if you're using Raspbian Lite), enter the Pi's IP address instead of **localhost**. You should see this in your browser window: + +![](https://opensource.com/sites/default/files/uploads/apache-it-works.png) + +This means you have Apache working! + +This default webpage is just an HTML file on the filesystem. It is located at **/var/www/html/index.html**. You can try replacing this file with some HTML of your own using the [Leafpad][2] text editor: + +``` +cd /var/www/html/ +sudo leafpad index.html +``` + +Save and close Leafpad then refresh the browser to see your changes. + +### MySQL + +MySQL (pronounced "my S-Q-L" or "my sequel") is a popular database engine. Like PHP, it's widely used on web servers, which is why projects like WordPress use it and why those projects are so popular. + +Install MySQL Server by entering the following command into the terminal window: + +``` +sudo apt-get install mysql-server -y +``` + +WordPress uses MySQL to store posts, pages, user data, and lots of other content. + +### PHP + +PHP is a preprocessor: it's code that runs when the server receives a request for a web page via a web browser. It works out what needs to be shown on the page, then sends that page to the browser. Unlike static HTML, PHP can show different content under different circumstances. PHP is a very popular language on the web; huge projects like Facebook and Wikipedia are written in PHP. + +Install PHP and the MySQL extension: + +``` +sudo apt-get install php php-mysql -y +``` + +Delete the **index.html** file and create **index.php** : + +``` +sudo rm index.html +sudo leafpad index.php +``` + +Add the following line: + +``` + +``` + +Save, exit, and refresh your browser. You'll see the PHP status page: + +![](https://opensource.com/sites/default/files/uploads/phpinfo.png) + +### WordPress + +You can download WordPress from [wordpress.org][3] using the **wget** command. Helpfully, the latest version of WordPress is always available at [wordpress.org/latest.tar.gz][4], so you can grab it without having to look it up on the website. As I'm writing, this is version 4.9.8. + +Make sure you're in **/var/www/html** and delete everything in it: + +``` +cd /var/www/html/ +sudo rm * +``` + +Download WordPress using **wget** , then extract the contents and move the WordPress files to the **html** directory: + +``` +sudo wget http://wordpress.org/latest.tar.gz +sudo tar xzf latest.tar.gz +sudo mv wordpress/* . +``` + +Tidy up by removing the tarball and the now-empty **wordpress** directory: + +``` +sudo rm -rf wordpress latest.tar.gz +``` + +Running the **ls** or **tree -L 1** command will show the contents of a WordPress project: + +``` +. +├── index.php +├── license.txt +├── readme.html +├── wp-activate.php +├── wp-admin +├── wp-blog-header.php +├── wp-comments-post.php +├── wp-config-sample.php +├── wp-content +├── wp-cron.php +├── wp-includes +├── wp-links-opml.php +├── wp-load.php +├── wp-login.php +├── wp-mail.php +├── wp-settings.php +├── wp-signup.php +├── wp-trackback.php +└── xmlrpc.php + +3 directories, 16 files +``` + +This is the source of a default WordPress installation. The files you edit to customize your installation belong in the **wp-content** folder. + +You should now change the ownership of all these files to the Apache user: + +``` +sudo chown -R www-data: . +``` + +### WordPress database + +To get your WordPress site set up, you need a database. This is where MySQL comes in! + +Run the MySQL secure installation command in the terminal window: + +``` +sudo mysql_secure_installation +``` + +You will be asked a series of questions. There's no password set up initially, but you should set one in the second step. Make sure you enter a password you will remember, as you'll need it to connect to WordPress. Press Enter to say Yes to each question that follows. + +When it's complete, you will see the messages "All done!" and "Thanks for using MariaDB!" + +Run **mysql** in the terminal window: + +``` +sudo mysql -uroot -p +``` + +Enter the root password you created. You will be greeted by the message "Welcome to the MariaDB monitor." Create the database for your WordPress installation at the **MariaDB [(none)] >** prompt using: + +``` +create database wordpress; +``` + +Note the semicolon at the end of the statement. If the command is successful, you should see this: + +``` +Query OK, 1 row affected (0.00 sec) +``` + +Grant database privileges to the root user, entering your password at the end of the statement: + +``` +GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost' IDENTIFIED BY 'YOURPASSWORD'; +``` + +For the changes to take effect, you will need to flush the database privileges: + +``` +FLUSH PRIVILEGES; +``` + +Exit the MariaDB prompt with **Ctrl+D** to return to the Bash shell. + +### WordPress configuration + +Open the web browser on your Raspberry Pi and open ****. You should see a WordPress page asking you to pick your language. Select your language and click **Continue**. You will be presented with the WordPress welcome screen. Click the **Let's go!** button. + +Fill out the basic site information as follows: + +``` +Database Name:      wordpress +User Name:          root +Password:           +Database Host:      localhost +Table Prefix:       wp_ +``` + +Click **Submit** to proceed, then click **Run the install**. + +![](https://opensource.com/sites/default/files/uploads/wp-info.png) + +Fill in the form: Give your site a title, create a username and password, and enter your email address. Hit the **Install WordPress** button, then log in using the account you just created. Now that you're logged in and your site is set up, you can see your website by visiting ****. + +### Permalinks + +It's a good idea to change your permalink settings to make your URLs more friendly. + +To do this, log into WordPress and go to the dashboard. Go to **Settings** , then **Permalinks**. Select the **Post name** option and click **Save Changes**. You'll need to enable Apache's **rewrite** module: + +``` +sudo a2enmod rewrite +``` + +You'll also need to tell the virtual host serving the site to allow requests to be overwritten. Edit the Apache configuration file for your virtual host: + +``` +sudo leafpad /etc/apache2/sites-available/000-default.conf +``` + +Add the following lines after line 1: + +``` + +    AllowOverride All + +``` + +Ensure it's within the **< VirtualHost *:80>** like so: + +``` + +    +        AllowOverride All +    +    ... +``` + +Save the file and exit, then restart Apache: + +``` +sudo systemctl restart apache2 +``` + +### What's next? + +WordPress is very customizable. By clicking your site name in the WordPress banner at the top of the page (when you're logged in), you'll be taken to the Dashboard. From there, you can change the theme, add pages and posts, edit the menu, add plugins, and do lots more. + +Here are some interesting things you can try on the Raspberry Pi's web server. + + * Add pages and posts to your website + * Install different themes from the Appearance menu + * Customize your website's theme or create your own + * Use your web server to display useful information for people on your network + + + +Don't forget, the Raspberry Pi is a Linux computer. You can also follow these instructions to install WordPress on a server running Debian or Ubuntu. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/setting-wordpress-raspberry-pi + +作者:[Ben Nuttall][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bennuttall +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/sitewide-search?search_api_views_fulltext=raspberry%20pi +[2]: https://en.wikipedia.org/wiki/Leafpad +[3]: http://wordpress.org/ +[4]: https://wordpress.org/latest.tar.gz From 6dcd4b838b3784cff7bd9324c51be7f302153c21 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 10:00:01 +0800 Subject: [PATCH 108/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=205=20tips=20for=20?= =?UTF-8?q?choosing=20the=20right=20open=20source=20database?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...choosing the right open source database.md | 79 +++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 sources/tech/20181022 5 tips for choosing the right open source database.md diff --git a/sources/tech/20181022 5 tips for choosing the right open source database.md b/sources/tech/20181022 5 tips for choosing the right open source database.md new file mode 100644 index 0000000000..266a227095 --- /dev/null +++ b/sources/tech/20181022 5 tips for choosing the right open source database.md @@ -0,0 +1,79 @@ +5 tips for choosing the right open source database +====== +When selecting a mission-critical application, you can't afford to make mistakes. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/server_data_system_admin.png?itok=q6HCfNQ8) + +So, your company has a directive to adopt more open source database technologies, and they've recruited you to select the right direction. Whether you are an open source technology veteran or a newcomer, this is a daunting and overwhelming task. + +Over the past several years, open source technology adoption has steadily increased in the enterprise space. With its popularity comes a crowded marketplace with open source software companies promising that their solution will solve every problem and fit every workload. Be wary of these promises. Choosing the right open source technology—especially a database—is an important and difficult decision you can't make lightly. + +In my experience as an IT professional at [Percona][1] and other companies, I've been fortunate to work hands-on in adopting open source technologies and guiding others in making the right decisions. There are many important factors to consider; hopefully, this article will shine a light on a few. + +### 1. Have a goal. + +This may seem simple, but based on my many conversations with people exploring MySQL, MongoDB, or PostgreSQL, it is top of the list in importance. + +To avoid getting overwhelmed by the unlimited combinations of open source database software in the market, have a specific goal in mind. Maybe your goal is to provide your internal developers with a standardized, open source database backend that is managed by your internal database team. Perhaps your goal is to rip and replace the entire functionality of a legacy application and database backend with new open source technology. + +Once you have defined a goal, you can focus your efforts. This will lead to better conversations internally as well as externally with open source database software vendors and advocates. + +### 2. Understand your workload. + +Despite the increasing ability of database technologies to wear many hats, each specializes in certain areas, e.g., MongoDB is now transactional, MySQL now has JSON storage. A growing trend in open source databases involves providing check boxes claiming certain features are available. One of the biggest mistakes is not using the right tool for the right job. Something leads a company down the wrong path—perhaps an overzealous developer or a manager with tunnel vision. The unfortunate thing is that the wrong tool can work fine for smaller volumes of transactions and data, but later there will be bottlenecks that can be solved only by using a different tool. + +If you want a data analytics warehouse, an open source relational database is probably not the right choice. If you want a transaction-processing app with rigid data integrity and consistency, NoSQL options may not be the right option. + +### 3. Don't reinvent the wheel. + +Open source database technologies have rapidly grown, expanded, and hardened over the past several decades. We've seen a transformation from new, questionably production-ready databases to proven, enterprise-grade database backends. It's no longer necessary to be a bleeding edge, early adopter to choose open source database technologies. Organizations have grown around these communities to provide production support and tooling in the open source database space for a growing number of startups, midsized businesses, and Fortune 500 companies. + +Battery Ventures, a tech-focused investment firm, recently introduced its [BOSS Index][2] for tracking the most popular open source projects. It's not perfect, but it provides great insight into some of the most widely adopted and active open source projects. Not surprisingly, database technologies dominate the list, comprising five of the top 10 technologies. This is a great starting point for someone new to the open source database space. A lot of times, vendors have already produced suitable architectures for solving specific problems. + +My point is that someone has probably already done what you are trying to do. Learn from their successes and failures. Even if it is not a perfect fit, a solution can likely be modified to suit your needs. For example, Amazon provides a [CloudFormation script][3] for deploying MongoDB in its EC2 environment. + +If you are a bleeding-edge early adopter, that doesn't mean you can't explore. If you have a unique challenge or workload that seems to fit a new open source database technology, go for it. Keep in mind that there are inherent risks (and rewards!) to being an early adopter. + +### 4\. Start simple + + +How many [nines][4] does your database truly need? "Achieving high availability" is often a nebulous goal for many companies. Of course, the most common answer is "it's mission-critical, and we cannot afford any downtime." + +The more complicated your database environment, the more difficult and costly it is to manage. You can theoretically achieve higher uptime, but the tradeoffs will be the feasibility of management and performance. When in doubt, start simple. There are always options to scale out when the need arises. + +For example, Booking.com is a widely known travel reservation site. It might be less widely known that it uses MySQL as a database backend. Nicolai Plum, a Booking.com senior systems architect, gave [a talk][5] outlining the evolution of the company's MySQL database. One of the takeaways was that the database started simple. It had to evolve over time, but in the beginning, simple master–replica architecture sufficed. As the workload and dataset increased, it introduced load balancers, multiple read replicas, archiving to Hadoop for analytics, etc. However, the early architecture was extremely simple. + +![](https://opensource.com/sites/default/files/uploads/internet_app_barrett_chambers.png) + +### 5. When in doubt, ask an expert. + +If you're unsure whether a database would be a good fit, reach out on forums, websites, or to vendors and strike up a conversation. This can be exciting as you research which database technologies meet your requirements and which do not. Often there are suitable alternatives that you haven't considered. The open source community is all about sharing knowledge. + +There is one important thing to be aware of when reaching out to open source software and services vendors. Many have open-core business models that incentivize adopting their database software. Take their advice or guidance with a grain of salt and use your own ability to research, create proofs of concept, and explore alternatives. + +### Conclusion + +Choosing the right open source database is an important decision. Start by asking the right questions. All too often, people put the cart before the horse, making decisions before really understanding their needs. + +Barrett Chambers will present [Choosing the Right Open Source Database][6] at [All Things Open][7], October 21-23 in Raleigh, N.C. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/tips-choosing-right-open-source-database + +作者:[Barrett Chambers][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/barrettc +[b]: https://github.com/lujun9972 +[1]: https://www.percona.com/ +[2]: https://techcrunch.com/2017/04/07/tracking-the-explosive-growth-of-open-source-software/ +[3]: https://docs.aws.amazon.com/quickstart/latest/mongodb/welcome.html +[4]: https://en.wikipedia.org/wiki/Five_nines +[5]: https://www.percona.com/live/mysql-conference-2015/sessions/bookingcom-evolution-mysql-system-design +[6]: https://allthingsopen.org/talk/choosing-the-right-open-source-database/ +[7]: https://allthingsopen.org/ From 40c37beb69ab1ff44db72637886fc48d5b5ac9cf Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 10:03:10 +0800 Subject: [PATCH 109/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20What=20is=20an=20?= =?UTF-8?q?SRE=20and=20how=20does=20it=20relate=20to=20DevOps=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...an SRE and how does it relate to DevOps.md | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 sources/talk/20181019 What is an SRE and how does it relate to DevOps.md diff --git a/sources/talk/20181019 What is an SRE and how does it relate to DevOps.md b/sources/talk/20181019 What is an SRE and how does it relate to DevOps.md new file mode 100644 index 0000000000..4a5c8aba13 --- /dev/null +++ b/sources/talk/20181019 What is an SRE and how does it relate to DevOps.md @@ -0,0 +1,69 @@ +What is an SRE and how does it relate to DevOps? +====== +The SRE role is common in large enterprises, but smaller businesses need it, too. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/toolbox-learn-draw-container-yearbook.png?itok=xDbwz1pP) + +Even though the site reliability engineer (SRE) role has become prevalent in recent years, many people—even in the software industry—don't know what it is or does. This article aims to clear that up by explaining what an SRE is, how it relates to DevOps, and how an SRE works when your entire engineering organization can fit in a coffee shop. + +### What is site reliability engineering? + +[Site Reliability Engineering: How Google Runs Production Systems][1], written by a group of Google engineers, is considered the definitive book on site reliability engineering. Google vice president of engineering Ben Treynor Sloss [coined the term][2] back in the early 2000s. He defined it as: "It's what happens when you ask a software engineer to design an operations function." + +Sysadmins have been writing code for a long time, but for many of those years, a team of sysadmins managed many machines manually. Back then, "many" may have been dozens or hundreds, but when you scale to thousands or hundreds of thousands of hosts, you simply can't continue to throw people at the problem. When the number of machines gets that large, the obvious solution is to use code to manage hosts (and the software that runs on them). + +Also, until fairly recently, the operations team was completely separate from the developers. The skillsets for each job were considered completely different. The SRE role tries to bring both jobs together. + +Before we dig deeper into what makes an SRE and how SREs work with the development team, we need to understand how site reliability engineering works within the DevOps paradigm. + +### Site reliability engineering and DevOps + +At its core, site reliability engineering is an implementation of the DevOps paradigm. There seems to be a wide array of ways to [define DevOps][3]. The traditional model, where the development ("devs") and operations ("ops") teams were separated, led to the team that writes the code not being responsible for how it works when customers start using it. The development team would "throw the code over the wall" to the operations team to install and support. + +This situation can lead to a significant amount of dysfunction. The goals of the dev and ops teams are constantly at odds—a developer wants customers to use the "latest and greatest" piece of code, but the operations team wants a steady system with as little change as possible. Their premise is that any change can introduce instability, while a system with no changes should continue to behave in the same manner. (Noting that minimizing change on the software side is not the only factor in preventing instability is important. For example, if your web application stays exactly the same, but the number of customers grows by 10x, your application may break in many different ways.) + +The premise of DevOps is that by merging these two distinct jobs into one, you eliminate contention. If the "dev" wants to deploy new code all the time, they have to deal with any fallout the new code creates. As Amazon's [Werner Vogels said][4], "you build it, you run it" (in production). But developers already have a lot to worry about. They are continually pushed to develop new features for their employer's products. Asking them to understand the infrastructure, including how to deploy, configure, and monitor their service, may be asking a little too much from them. This is where an SRE steps in. + +When a web application is developed, there are often many people that contribute. There are user interface designers, graphic designers, frontend engineers, backend engineers, and a whole host of other specialties (depending on the technologies used). Requirements include how the code gets managed (e.g., deployed, configured, monitored)—which are the SRE's areas of specialty. But, just as an engineer developing a nice look and feel for an application benefits from knowledge of the backend-engineer's job (e.g., how data is fetched from a database), the SRE understands how the deployment system works and how to adapt it to the specific needs of that particular codebase or project. + +So, an SRE is not just "an ops person who codes." Rather, the SRE is another member of the development team with a different set of skills particularly around deployment, configuration management, monitoring, metrics, etc. But, just as an engineer developing a nice look and feel for an application must know how data is fetched from a data store, an SRE is not singly responsible for these areas. The entire team works together to deliver a product that can be easily updated, managed, and monitored. + +The need for an SRE naturally comes about when a team is implementing DevOps but realizes they are asking too much of the developers and need a specialist for what the ops team used to handle. + +### How the SRE works at a startup + +This is great when there are hundreds of employees (let alone when you are the size of Google or Facebook). Large companies have SRE teams that are split up and embedded into each development team. But a startup doesn't have those economies of scale, and engineers often wear many hats. So, where does the "SRE hat" sit in a small company? One approach is to fully adopt DevOps and have the developers be responsible for the typical tasks an SRE would perform at a larger company. On the other side of the spectrum, you hire specialists — a.k.a., SREs. + +The most obvious advantage of trying to put the SRE hat on a developer's head is it scales well as your team grows. Also, the developer will understand all the quirks of the application. But many startups use a wide variety of SaaS products to power their infrastructure. The most obvious is the infrastructure platform itself. Then you add in metrics systems, site monitoring, log analysis, containers, and more. While these technologies solve some problems, they create an additional complexity cost. The developer would need to understand all those technologies and services in addition to the core technologies (e.g., languages) the application uses. In the end, keeping on top of all of that technology can be overwhelming. + +The other option is to hire a specialist to handle the SRE job. Their responsibility would be to focus on deployment, configuration, monitoring, and metrics, freeing up the developer's time to write the application. The disadvantage is that the SRE would have to split their time between multiple, different applications (i.e., the SRE needs to support the breadth of applications throughout engineering). This likely means they may not have the time to gain any depth of knowledge of any of the applications; however, they would be in a position to see how all the different pieces fit together. This "30,000-foot view" can help prioritize the weak spots to fix in the system as a whole. + +There is one key piece of information I am ignoring: your other engineers. They may have a deep desire to understand how deployment works and how to use the metrics system to the best of their ability. Also, hiring an SRE is not an easy task. You are looking for a mix of sysadmin skills and software engineering skills. (I am specific about software engineers, vs. just "being able to code," because software engineering involves more than just writing code [e.g., writing good tests or documentation].) + +Therefore, in some cases, it may make more sense for the "SRE hat" to live on a developer's head. If so, keep an eye on the amount of complexity in both the code and the infrastructure (SaaS or internal). At some point, the complexity on either end will likely push toward more specialization. + +### Conclusion + +An SRE team is one of the most efficient ways to implement the DevOps paradigm in a startup. I have seen a couple of different approaches, but I believe that hiring a dedicated SRE (pretty early) at your startup will free up time for the developers to focus on their specific challenges. The SRE can focus on improving the tools (and processes) that make the developers more productive. Also, an SRE will focus on making sure your customers have a product that is reliable and secure. + +Craig Sebenik will present [SRE (and DevOps) at a Startup][5] at [LISA18][6], October 29-31 in Nashville, Tennessee. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/sre-startup + +作者:[Craig Sebenik][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/craig5 +[b]: https://github.com/lujun9972 +[1]: http://shop.oreilly.com/product/0636920041528.do +[2]: https://landing.google.com/sre/interview/ben-treynor.html +[3]: https://opensource.com/resources/devops +[4]: https://queue.acm.org/detail.cfm?id=1142065 +[5]: https://www.usenix.org/conference/lisa18/presentation/sebenik +[6]: https://www.usenix.org/conference/lisa18 From 4903e974b18a72f26d63d1638cb9dba4a4686456 Mon Sep 17 00:00:00 2001 From: geekpi Date: Tue, 23 Oct 2018 12:14:02 +0800 Subject: [PATCH 110/158] use ordered list --- ... 11 applications you never knew existed.md | 32 +++++++------------ 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md b/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md index 4a77fca3dd..3e357e99aa 100644 --- a/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md +++ b/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md @@ -9,27 +9,17 @@ Linux 桌面环境 KDE 将于今年 10 月 14 日庆祝诞生 22 周年。KDE ### 11 个你从没了解的 KDE 应用 -1\. [KTeaTime][2] 是一个泡茶计时器。选择你正在饮用的茶的类型 - 绿茶、红茶、凉茶等 - 当可以取出茶包来饮用时,计时器将会响。 - -2\. [KTux][3] 就是一个屏保程序......是么?Tux 用他的绿色飞船在外太空飞行。 - -3\. [Blinken][4] 是一款基于 Simon Says 的记忆游戏,这是一个 1978 年发布的电子游戏。玩家们在记住长度增加的序列时会有挑战。 - -4\. [Tellico][5] 是一个收集管理器,用于组织你最喜欢的爱好。也许你还在收集棒球卡。也许你是红酒俱乐部的一员。也许你是一个严肃的书虫。也许三个都是! - -5\. [KRecipes][6] **不是** 简单的食谱管理器。它还有很多其他功能!购物清单、营养素分析、高级搜索、菜谱评级、导入/导出各种格式等。 - -6\. [KHangMan][7] 基于经典游戏 Hangman,你可以按逐个字母猜测单词。这个游戏有多种语言版本,这可以用来改善你学习另一种语言。它有四个分类,其中一个是“动物”,非常适合孩子。 - -7\. [KLettres][8] 是另一款可以帮助你学习新语言的应用。它教授字母表并挑战用户阅读和发音音节。 - -8\. [KDiamond][9] 类似于宝石迷阵或其他单人益智游戏,其中游戏的目标是搭建一定数量的相同类型的宝石或物体的行。这里是钻石。 - -9\. [KolourPaint][10] 是一个非常简单的图像编辑工具,也可以用于创建简单的矢量图形。 - -10\. [Kiriki][11] 是一款类似于 Yahtzee 的 2-6 名玩家的骰子游戏。 - -11\. [RSIBreak][12] 没有以 K 开头。什么!?它以“RSI”开头代表“重复性劳损” (Repetitive Strain Injury),这会在日复一日长时间使用鼠标和键盘后发生。这个应用会提醒你休息,并可以个性化,以满足你的需求。 +1. [KTeaTime][2] 是一个泡茶计时器。选择你正在饮用的茶的类型 - 绿茶、红茶、凉茶等 - 当可以取出茶包来饮用时,计时器将会响。 +2. [KTux][3] 就是一个屏保程序......是么?Tux 用他的绿色飞船在外太空飞行。 +3. [Blinken][4] 是一款基于 Simon Says 的记忆游戏,这是一个 1978 年发布的电子游戏。玩家们在记住长度增加的序列时会有挑战。 +4. [Tellico][5] 是一个收集管理器,用于组织你最喜欢的爱好。也许你还在收集棒球卡。也许你是红酒俱乐部的一员。也许你是一个严肃的书虫。也许三个都是! +5. [KRecipes][6] **不是** 简单的食谱管理器。它还有很多其他功能!购物清单、营养素分析、高级搜索、菜谱评级、导入/导出各种格式等。 +6. [KHangMan][7] 基于经典游戏 Hangman,你可以按逐个字母猜测单词。这个游戏有多种语言版本,这可以用来改善你学习另一种语言。它有四个分类,其中一个是“动物”,非常适合孩子。 +7. [KLettres][8] 是另一款可以帮助你学习新语言的应用。它教授字母表并挑战用户阅读和发音音节。 +8. [KDiamond][9] 类似于宝石迷阵或其他单人益智游戏,其中游戏的目标是搭建一定数量的相同类型的宝石或物体的行。这里是钻石。 +9. [KolourPaint][10] 是一个非常简单的图像编辑工具,也可以用于创建简单的矢量图形。 +10. [Kiriki][11] 是一款类似于 Yahtzee 的 2-6 名玩家的骰子游戏。 +11. [RSIBreak][12] 没有以 K 开头。什么!?它以“RSI”开头代表“重复性劳损” (Repetitive Strain Injury),这会在日复一日长时间使用鼠标和键盘后发生。这个应用会提醒你休息,并可以个性化,以满足你的需求。 -------------------------------------------------------------------------------- From 8a5a32925347d40a0b3608f1729bdd3a5e8d51c4 Mon Sep 17 00:00:00 2001 From: way-ww <40491614+way-ww@users.noreply.github.com> Date: Tue, 23 Oct 2018 13:36:40 +0800 Subject: [PATCH 111/158] Delete 20180924 Why Linux users should try Rust.md --- ...0180924 Why Linux users should try Rust.md | 173 ------------------ 1 file changed, 173 deletions(-) delete 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 deleted file mode 100644 index c4ab720700..0000000000 --- a/sources/tech/20180924 Why Linux users should try Rust.md +++ /dev/null @@ -1,173 +0,0 @@ -Translating by way-ww - -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 ee0c396570ae491a707ad7c5cef8a38fa9b4f6d1 Mon Sep 17 00:00:00 2001 From: way-ww <40491614+way-ww@users.noreply.github.com> Date: Tue, 23 Oct 2018 13:37:25 +0800 Subject: [PATCH 112/158] Create 20180924 Why Linux users should try Rust.md --- ...0180924 Why Linux users should try Rust.md | 177 ++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 translated/tech/20180924 Why Linux users should try Rust.md diff --git a/translated/tech/20180924 Why Linux users should try Rust.md b/translated/tech/20180924 Why Linux users should try Rust.md new file mode 100644 index 0000000000..b8b92364a1 --- /dev/null +++ b/translated/tech/20180924 Why Linux users should try Rust.md @@ -0,0 +1,177 @@ +为什么linux用户应该尝试Rust +====== + +![](https://images.idgesg.net/images/article/2018/09/rust-rusted-metal-100773678-large.jpg) + +Rust是一种相当年轻和现代的编程语言,因为具有许多功能,所以它非常灵活而且非常安全。 数据显示它正在变得非常受欢迎,连续三年在Stack Overflow开发者调查中获得“最受喜爱的编程语言”的第一名 - [2016] [1],[2017] [2]和[2018] [3]。 + +Rust也是开源语言的一种,它具有一系列特功能,使得它可以适应许多不同的编程项目。 它最初源于2006年Mozilla员工的个人项目,几年后(2009年)被Mozilla收集为特别项目,然后在2010年宣布供公众使用。 + +Rust程序运行速度极快,可防止段错误,并保证线程安全。 这些属性使该语言极大地吸引了专注于应用程序安全性的开发人员。 Rust也是一种非常易读的语言,可用于从简单程序到非常大而复杂的项目。 + +Rust 优点: + + * 内存安全—— Rust不会受到悬空指针,缓冲区溢出或其他与内存相关的错误的影响。 它提供内存安全,无回收垃圾。 + * 通用 - Rust是适用于任何类型编程的适当语言 + * 快速 - Rust在性能上与C / C ++相当,但具有更好的安全功能。 + * 高效 - Rust是为了便于并发编程而构建的。 + * 面向项目 - Rust具有内置的依赖关系和构建管理系统Cargo。 + * 得到很好的支持 - Rust有一个令人印象深刻的[支持社区] [4]。 + + + +Rust还强制执行RAII(资源获取初始化)。 这意味着当一个对象超出范围时,将调用其析构函数并释放其资源,从而提供防止资源泄漏的屏蔽。 它提供了功能抽象和一个伟大的[类型系统] [5]以及速度和数学健全性。 + +简而言之,Rust是一种令人印象深刻的系统编程语言,具有其他大多数语言所缺乏的功能,使其成为C,C++和Objective-C等多年来一直被使用的语言的有力竞争者。 + +### 安装 Rust + +安装Rust是一个相当简单的过程。 + +``` +$ curl https://sh.rustup.rs -sSf | sh +``` + +安装Rust后,使用rustc** --version **或** which **命令显示版本信息。 + +``` +$ which rustc +rustc 1.27.2 (58cc626de 2018-07-18) +$ rustc --version +rustc 1.27.2 (58cc626de 2018-07-18) +``` + +### Rust入门 + +Rust即使是最简单的代码也与你之前使用过的语言的输入完全不同。 + +``` +$ cat hello.rs +fn main() { + // Print a greeting + println!("Hello, world!"); +} +``` + +在这些行中,我们正在设置一个函数(main),添加一个描述该函数的注释,并使用println语句来创建输出。 您可以使用下面显示的命令编译然后运行这样的程序。 + +``` +$ rustc hello.rs +$ ./hello +Hello, world! +``` + +你可以创建一个“项目”(通常仅用于比这个更复杂的程序!)来保持代码的有序性。 + +``` +$ mkdir ~/projects +$ cd ~/projects +$ mkdir hello_world +$ cd hello_world +``` + +请注意,即使是简单的程序,一旦编译,就会变成相当大的可执行文件。 + +``` +$ ./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 +``` + +当然,这只是一个开始且传统的“Hello, world!” 程序。 Rust语言具有一系列功能,可帮助你快速进入高级编程技能。 + +### 学习 Rust + +![rust programming language book cover][6] +No Starch Press + +Steve Klabnik和Carol Nichols(2018)的Rust Programming Language一书提供了学习Rust的最佳方法之一。 这本书由核心开发团队的两名成员撰写,可从[No Starch Press] [7]出版社获得纸制书或者从[rust-lang.org] [8]获得电子书。 它已经成为Rust开发者社区中的参考书。 + +在所涉及的众多主题中,你将了解这些高级主题: + + * 所有权和borrowing + + * 安全保障 + + * 测试和错误处理 + + * 智能指针和多线程 + + * 高级模式匹配 + + * 使用Cargo(内置包管理器) + + * 使用Rust的高级编译器 + + + +#### 目录 + + +``` +前言(Nicholas Matsakis和Aaron Turon编写) +致谢 +介绍 +第1章:新手入门 +第2章:猜谜游戏 +第3章:通用编程概念 +第4章:了解所有权 +第五章:结构 +第6章:枚举和模式匹配 +第7章:模块 +第8章:常见集合 +第9章:错误处理 +第10章:通用类型,特征和生命周期 +第11章:测试 +第12章:输入/输出项目 +第13章:迭代器和闭包 +第14章:关于货物和Crates.io的更多信息 +第15章:智能指针 +第16章:并发 +第17章:Rust面向对象? +第18章:模式 +第19章:关于生命周期的更多信息 +第20章:高级类型系统功能 +附录A:关键字 +附录B:运算符和符号 +附录C:可衍生的特征 +附录D:宏 +索引 + +``` + +[Rust编程语言] [7]将你从基本安装和语言语法带到复杂的主题,例如模块,错误处理,crates(与其他语言中的'library'或'package'同义),模块(允许你 将你的代码分配到包箱本身,生命周期等。 + +可能最重要的是,本书可以让您从基本的编程技巧转向构建和编译复杂,安全且非常有用的程序。 + +### 结束 + +如果你已经准备好用一种非常值得花时间和精力学习并且越来越受欢迎的语言进行一些严肃的编程,那么Rust是一个不错的选择! + +加入[Facebook] [9]和[LinkedIn] [10]上的Network World社区,评论最重要的话题。 + +-------------------------------------------------------------------------------- + + +via: https://www.networkworld.com/article/3308162/linux/why-you-should-try-rust.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[way-ww](https://github.com/way-ww) +校对:[校对者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 5d2bc42cd0213b60098abc0b730b4c9e56f7f79c Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 18:14:35 +0800 Subject: [PATCH 113/158] first commit --- .travis.yml | 21 ++++++++++++++++++++- Makefile | 3 +++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1a8cdd6d43..c55ba169c8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,2 +1,21 @@ language: c -script: make -s check +script: + - make -s check + - make -s deploy + + +branches: + only: + - master + +install: + - git clone --depth=1 https://github.com/LCTT/lctt-scripts + - sed -i "/ProjectRoot=/cProjectRoot=$(pwd)" ./lctt-scripts/lctt.cfg + +deploy: + provider: pages + skip_cleanup: true + github_token: $GITHUB_TOKEN + local_dir: status_badge + on: +branch: master diff --git a/Makefile b/Makefile index 715597e46e..ac39d64f5e 100644 --- a/Makefile +++ b/Makefile @@ -49,3 +49,6 @@ rule-translation-published: [ $(shell egrep '^A\s*"?published/$(NAME_PATTERN)' $(CHANGE_FILE) | wc -l) = 1 ] [ $(shell cat $(CHANGE_FILE) | wc -l) = 2 ] echo 'Rule Matched: $(@)' + +deploy: + echo 'deployed' From 166f0c15a4d2a92e44771a11ac240fa8e25e3e67 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 20:13:32 +0800 Subject: [PATCH 114/158] update --- .travis.yml | 6 +++--- Makefile | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index c55ba169c8..dbf3a727d5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ language: c script: - make -s check - - make -s deploy + - make -s badge branches: only: - - master + - badge install: - git clone --depth=1 https://github.com/LCTT/lctt-scripts @@ -16,6 +16,6 @@ deploy: provider: pages skip_cleanup: true github_token: $GITHUB_TOKEN - local_dir: status_badge + local_dir: badge on: branch: master diff --git a/Makefile b/Makefile index ac39d64f5e..50e25e4b7c 100644 --- a/Makefile +++ b/Makefile @@ -50,5 +50,9 @@ rule-translation-published: [ $(shell cat $(CHANGE_FILE) | wc -l) = 2 ] echo 'Rule Matched: $(@)' -deploy: - echo 'deployed' +badge: + mkdir -p badge + ./lctt-scripts/show_status.sh -s published >badge/published.svg + ./lctt-scripts/show_status.sh -s translated >badge/translated.svg + ./lctt-scripts/show_status.sh -s translating >badge/translating.svg + ./lctt-scripts/show_status.sh -s sources >badge/sources.svg From 9e1221f88d7e8d2bec9e59aa78cca35fea469c40 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 20:37:31 +0800 Subject: [PATCH 115/158] update --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dbf3a727d5..c571e43576 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,5 +17,3 @@ deploy: skip_cleanup: true github_token: $GITHUB_TOKEN local_dir: badge - on: -branch: master From 91f3f82a01f60ac94196466659f2cb69ec8119a0 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 20:40:16 +0800 Subject: [PATCH 116/158] update --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c571e43576..0895a0afe5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: c script: - - make -s check - make -s badge From d2614ba933f8861f0df292fe747d40cb2d776aea Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 20:49:57 +0800 Subject: [PATCH 117/158] update --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 0895a0afe5..415c59ab26 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ language: c script: + - make -s check - make -s badge @@ -16,3 +17,5 @@ deploy: skip_cleanup: true github_token: $GITHUB_TOKEN local_dir: badge + on: + branch: badge From dae8a648caaf6132af849e72808f0a66a5008fa5 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 20:51:22 +0800 Subject: [PATCH 118/158] update --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 415c59ab26..8d85309131 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: c script: - - make -s check - make -s badge From 88c533636cdbbab770022cc7fdd783b21738aaa3 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 20:55:20 +0800 Subject: [PATCH 119/158] update --- .travis.yml | 2 +- Makefile | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8d85309131..76e4d852a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,6 +15,6 @@ deploy: provider: pages skip_cleanup: true github_token: $GITHUB_TOKEN - local_dir: badge + local_dir: build on: branch: badge diff --git a/Makefile b/Makefile index 50e25e4b7c..952b7b8b38 100644 --- a/Makefile +++ b/Makefile @@ -51,8 +51,8 @@ rule-translation-published: echo 'Rule Matched: $(@)' badge: - mkdir -p badge - ./lctt-scripts/show_status.sh -s published >badge/published.svg - ./lctt-scripts/show_status.sh -s translated >badge/translated.svg - ./lctt-scripts/show_status.sh -s translating >badge/translating.svg - ./lctt-scripts/show_status.sh -s sources >badge/sources.svg + mkdir -p build/badge + ./lctt-scripts/show_status.sh -s published >build/badge/published.svg + ./lctt-scripts/show_status.sh -s translated >build/badge/translated.svg + ./lctt-scripts/show_status.sh -s translating >build/badge/translating.svg + ./lctt-scripts/show_status.sh -s sources >build/badge/sources.svg From 8199840ae71fb0387e75965ebe2b05898db9dbca Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 21:00:27 +0800 Subject: [PATCH 120/158] update --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2769014a6a..2562248668 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ 简介 ------------------------------- +![已发布](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/published.svg) ![已翻译](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/translated.svg) ![翻译中](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/translating.svg) ![待翻译](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/sources.svg) + LCTT 是“Linux中国”([https://linux.cn/](https://linux.cn/))的翻译组,负责从国外优秀媒体翻译 Linux 相关的技术、资讯、杂文等内容。 LCTT 已经拥有几百名活跃成员,并欢迎更多的Linux志愿者加入我们的团队。 From 1746e36bc8985c49a1b9b5cae1556441df2a4029 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 21:07:39 +0800 Subject: [PATCH 121/158] update --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 2562248668..4b0589de0a 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ 简介 ------------------------------- -![已发布](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/published.svg) ![已翻译](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/translated.svg) ![翻译中](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/translating.svg) ![待翻译](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/sources.svg) +![已发布](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/published.svg) +![已翻译](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/translated.svg) +![翻译中](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/translating.svg) +![待翻译](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/sources.svg) LCTT 是“Linux中国”([https://linux.cn/](https://linux.cn/))的翻译组,负责从国外优秀媒体翻译 Linux 相关的技术、资讯、杂文等内容。 From 9749ce3776bb9012cfe703cc9fef3887f1ed6d33 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 21:20:02 +0800 Subject: [PATCH 122/158] update --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4b0589de0a..beb2565186 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ 简介 ------------------------------- -![已发布](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/published.svg) -![已翻译](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/translated.svg) -![翻译中](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/translating.svg) -![待翻译](https://github.com/lujun9972/TranslateProject/raw/gh-pages/badge/sources.svg) +![已发布](https://lujun9972.github.io/TranslateProject/badge/published.svg) +![已翻译](https://lujun9972.github.io/TranslateProject/badge/translated.svg) +![翻译中](https://lujun9972.github.io/TranslateProject/badge/translating.svg) +![待翻译](https://lujun9972.github.io/TranslateProject/badge/sources.svg) LCTT 是“Linux中国”([https://linux.cn/](https://linux.cn/))的翻译组,负责从国外优秀媒体翻译 Linux 相关的技术、资讯、杂文等内容。 From b8ebc6fd9c0c1e40ce2e0793d79699af838049f1 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 21:30:54 +0800 Subject: [PATCH 123/158] update --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index beb2565186..e23f75731b 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ 简介 ------------------------------- -![已发布](https://lujun9972.github.io/TranslateProject/badge/published.svg) -![已翻译](https://lujun9972.github.io/TranslateProject/badge/translated.svg) -![翻译中](https://lujun9972.github.io/TranslateProject/badge/translating.svg) ![待翻译](https://lujun9972.github.io/TranslateProject/badge/sources.svg) +![翻译中](https://lujun9972.github.io/TranslateProject/badge/translating.svg) +![待校正](https://lujun9972.github.io/TranslateProject/badge/translated.svg) +![已发布](https://lujun9972.github.io/TranslateProject/badge/published.svg) LCTT 是“Linux中国”([https://linux.cn/](https://linux.cn/))的翻译组,负责从国外优秀媒体翻译 Linux 相关的技术、资讯、杂文等内容。 From c62f1b273e2bef22b136a84ba50b8625d053d251 Mon Sep 17 00:00:00 2001 From: darksun Date: Tue, 23 Oct 2018 21:43:59 +0800 Subject: [PATCH 124/158] =?UTF-8?q?=E5=87=86=E5=A4=87=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 5 +++-- README.md | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76e4d852a9..368993fec8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,12 @@ language: c script: - make -s badge + - make -s check branches: only: - - badge + - master install: - git clone --depth=1 https://github.com/LCTT/lctt-scripts @@ -17,4 +18,4 @@ deploy: github_token: $GITHUB_TOKEN local_dir: build on: - branch: badge + branch: master diff --git a/README.md b/README.md index e23f75731b..b3bbaf0ee6 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ 简介 ------------------------------- -![待翻译](https://lujun9972.github.io/TranslateProject/badge/sources.svg) -![翻译中](https://lujun9972.github.io/TranslateProject/badge/translating.svg) -![待校正](https://lujun9972.github.io/TranslateProject/badge/translated.svg) -![已发布](https://lujun9972.github.io/TranslateProject/badge/published.svg) +![待翻译](https://lctt.github.io/TranslateProject/badge/sources.svg) +![翻译中](https://lctt.github.io/TranslateProject/badge/translating.svg) +![待校正](https://lctt.github.io/TranslateProject/badge/translated.svg) +![已发布](https://lctt.github.io/TranslateProject/badge/published.svg) LCTT 是“Linux中国”([https://linux.cn/](https://linux.cn/))的翻译组,负责从国外优秀媒体翻译 Linux 相关的技术、资讯、杂文等内容。 From 208e3016fa66cdfa4d90f33636273a09cc72b4fc Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 23 Oct 2018 22:13:38 +0800 Subject: [PATCH 125/158] PRF:20180927 5 cool tiling window managers.md @geekpi --- .../20180927 5 cool tiling window managers.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/translated/tech/20180927 5 cool tiling window managers.md b/translated/tech/20180927 5 cool tiling window managers.md index 22b9c455cb..ea1d8ae7c0 100644 --- a/translated/tech/20180927 5 cool tiling window managers.md +++ b/translated/tech/20180927 5 cool tiling window managers.md @@ -2,19 +2,20 @@ ====== ![](https://fedoramagazine.org/wp-content/uploads/2018/09/tilingwindowmanagers-816x345.jpg) -Linux 桌面生态中有多种窗口管理器 (WM)。有些是作为桌面环境的一部分开发的。有的则被用作独立程序。平铺 WM 就是这种情况,它提供了一个更轻量级的自定义环境。本文介绍了五种这样的平铺 WM 供你试用。 + +Linux 桌面生态中有多种窗口管理器(WM)。有些是作为桌面环境的一部分开发的。有的则被用作独立程序。平铺窗口管理器就是这种情况,它提供了一个更轻量级的自定义环境。本文介绍了五种这样的平铺窗口管理器供你试用。 ### i3 [i3][1] 是最受欢迎的平铺窗口管理器之一。与大多数其他此类 WM 一样,i3 专注于低资源消耗和用户可定制性。 -您可以参考[Magazine 上的这篇文章][2]了解 i3 安装细节以及如何配置它。 +您可以参考 [Magazine 上的这篇文章][2]了解 i3 安装细节以及如何配置它。 ### sway [sway][3] 是一个平铺 Wayland 合成器。它有与现有 i3 配置兼容的优点,因此你可以使用它来替换 i3 并使用 Wayland 作为显示协议。 -您可以使用 dnf 从 Fedora 仓库安装 sway: +您可以使用 `dnf` 从 Fedora 仓库安装 sway: ``` $ sudo dnf install sway @@ -24,7 +25,7 @@ $ sudo dnf install sway ### Qtile -[Qtile][5] 是另一个平铺管理器,也恰好是用 Python 编写的。默认情况下,你在位于 ~/.config/qtile/config.py 下的 Python 脚本中配置 Qtile。当此脚本不存在时,Qtile 会使用默认[配置][6]。 +[Qtile][5] 是另一个平铺管理器,也恰好是用 Python 编写的。默认情况下,你在位于 `~/.config/qtile/config.py` 下的 Python 脚本中配置 Qtile。当此脚本不存在时,Qtile 会使用默认[配置][6]。 Qtile 使用 Python 的一个好处是你可以编写脚本来控制 WM。例如,以下脚本打印屏幕详细信息: @@ -45,13 +46,13 @@ $ sudo dnf install qtile [dwm][7] 窗口管理器更侧重于轻量级。该项目的一个目标是保持 dwm 最小。例如,整个代码库从未超过 2000 行代码。另一方面,dwm 不容易定制和配置。实际上,改变 dwm 默认配置的唯一方法是[编辑源代码并重新编译程序][8]。 -如果你想尝试默认配置,你可以使用 dnf 在 Fedora 中安装 dwm: +如果你想尝试默认配置,你可以使用 `dnf` 在 Fedora 中安装 dwm: ``` $ sudo dnf install dwm ``` -对于那些想要改变 dwm 配置的人,Fedora 中有一个 dwm-user 包。该软件包使用用户主目录中 ~/.dwm/config.h 的配置自动重新编译 dwm。 +对于那些想要改变 dwm 配置的人,Fedora 中有一个 dwm-user 包。该软件包使用用户主目录中 `~/.dwm/config.h` 的配置自动重新编译 dwm。 ### awesome @@ -71,7 +72,7 @@ via: https://fedoramagazine.org/5-cool-tiling-window-managers/ 作者:[Clément Verna][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From a42c82e142f4a3413952ab3a7b22e15d55c3ab9d Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 23 Oct 2018 22:16:05 +0800 Subject: [PATCH 126/158] PUB:20180927 5 cool tiling window managers.md @geekpi https://linux.cn/article-10145-1.html --- .../tech => published}/20180927 5 cool tiling window managers.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180927 5 cool tiling window managers.md (100%) diff --git a/translated/tech/20180927 5 cool tiling window managers.md b/published/20180927 5 cool tiling window managers.md similarity index 100% rename from translated/tech/20180927 5 cool tiling window managers.md rename to published/20180927 5 cool tiling window managers.md From 2c0269b3d507a873db45e85bf0518824834290dd Mon Sep 17 00:00:00 2001 From: way-ww <40491614+way-ww@users.noreply.github.com> Date: Tue, 23 Oct 2018 23:12:08 +0800 Subject: [PATCH 127/158] Update 20181015 How to Enable or Disable Services on Boot in Linux Using chkconfig and systemctl Command.md --- ...es on Boot in Linux Using chkconfig and systemctl Command.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20181015 How to Enable or Disable Services on Boot in Linux Using chkconfig and systemctl Command.md b/sources/tech/20181015 How to Enable or Disable Services on Boot in Linux Using chkconfig and systemctl Command.md index cc75d4490f..e1b66d4f6d 100644 --- a/sources/tech/20181015 How to Enable or Disable Services on Boot in Linux Using chkconfig and systemctl Command.md +++ b/sources/tech/20181015 How to Enable or Disable Services on Boot in Linux Using chkconfig and systemctl Command.md @@ -1,3 +1,5 @@ +Translating by way-ww + How to Enable or Disable Services on Boot in Linux Using chkconfig and systemctl Command ====== It’s a important topic for Linux admin (such a wonderful topic) so, everyone must be aware of this and practice how to use this in the efficient way. From 8e1ae6bf8fa2fb659bbb188f59a8caf84571f384 Mon Sep 17 00:00:00 2001 From: suncle Date: Tue, 23 Oct 2018 23:25:09 +0800 Subject: [PATCH 128/158] translated by Flowsnow --- ... Rename Multiple Files At Once In Linux.md | 188 ------------------ ... Rename Multiple Files At Once In Linux.md | 182 +++++++++++++++++ 2 files changed, 182 insertions(+), 188 deletions(-) delete mode 100644 sources/tech/20180615 How To Rename Multiple Files At Once In Linux.md create mode 100644 translated/tech/20180615 How To Rename Multiple Files At Once In Linux.md diff --git a/sources/tech/20180615 How To Rename Multiple Files At Once In Linux.md b/sources/tech/20180615 How To Rename Multiple Files At Once In Linux.md deleted file mode 100644 index f5c36573be..0000000000 --- a/sources/tech/20180615 How To Rename Multiple Files At Once In Linux.md +++ /dev/null @@ -1,188 +0,0 @@ -translating by Flowsnow - -How To Rename Multiple Files At Once In Linux -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/06/Rename-Multiple-Files-720x340.png) - -As you may already know, we use **mv** command to rename or move files and directories in Unix-like operating systems. But, the mv command won’t support renaming multiple files at once. Worry not. In this tutorial, we are going to learn to rename multiple files at once using **“mmv”** command in Linux. This command is used to move, copy, append and rename files in bulk using standard wildcards in Unix-like operating systems. - -### Rename Multiple Files At Once In Linux - -The mmv utility is available in the default repositories of Debian-based systems. To install it on Debian, Ubuntu, Linux Mint, run the following command: -``` -$ sudo apt-get install mmv - -``` - -Let us say, you have the following files in your current directory. -``` -$ ls -a1.txt a2.txt a3.txt - -``` - -Now you want to rename all files that starts with letter “a” to “b”. Of course, you can do this manually in few seconds. But just think if you have hundreds of files and want to rename them? It is quite time consuming process. Here is where **mmv** command comes in help. - -To rename all files starting with letter “a” to “b”, simply run: -``` -$ mmv a\* b\#1 - -``` - -Let us check if the files have been renamed or not. -``` -$ ls -b1.txt b2.txt b3.txt - -``` - -As you can see, all files starts with letter “a” (i.e a1.txt, a2.txt, a3.txt) are renamed to b1.txt, b2.txt, b3.txt. - -**Explanation** - -In the above example, the first parameter (a\\*) is the ‘from’ pattern and the second parameter is ‘to’ pattern ( b\\#1 ). As per the above example, mmv will look for any filenames staring with letter ‘a’ and rename the matched files according to second parameter i.e ‘to’ pattern. We use wildcards, such as ‘*’, ‘?’ and ‘[]‘, to match one or more arbitrary characters. Please be mindful that you must escape the wildcard characters, otherwise they will be expanded by the shell and mmv won’t understand them. - -The ‘#1′ in the ‘to’ pattern is a wildcard index. It matches the first wildcard found in the ‘from’ pattern. A ‘#2′ in the ‘to’ pattern would match the second wildcard and so on. In our example, we have only one wildcard (the asterisk), so we write a #1. And, the hash sign should be escaped as well. Also, you can enclose the patterns with quotes too. - -You can even rename all files with a certain extension to a different extension. For example, to rename all **.txt** files to **.doc** file format in the current directory, simply run: -``` -$ mmv \*.txt \#1.doc - -``` - -Here is an another example. Let us say you have the following files. -``` -$ ls -abcd1.txt abcd2.txt abcd3.txt - -``` - -You want to replace the the first occurrence of **abc** with **xyz** in all files in the current directory. How would you do? - -Simple. -``` -$ mmv '*abc*' '#1xyz#2' - -``` - -Please note that in the above example, I have enclosed the patterns in single quotes. - -Let us check if “abc” is actually replaced with “xyz” or not. -``` -$ ls -xyzd1.txt xyzd2.txt xyzd3.txt - -``` - -See? The files **abcd1.txt** , **abcd2.txt** , and **abcd3.txt** have been renamed to **xyzd1.txt** , **xyzd2.txt** , and **xyzd3.txt**. - -Another notable feature of mmv command is you can just print output instead of renaming the files using **-n** option like below. -``` -$ mmv -n a\* b\#1 -a1.txt -> b1.txt -a2.txt -> b2.txt -a3.txt -> b3.txt - -``` - -This way you can simply verify what mmv command would actually do before renaming the files. - -For more details, refer man pages. -``` -$ man mmv - -``` - -**Update:** - -The **Thunar file manager** has built-in **bulk rename** option by default. If you’re using thunar, it much easier to rename files than using mmv command. - -Thunar is available in the default repositories of most Linux distributions. - -To install it on Arch-based systems, run: -``` -$ sudo pacman -S thunar - -``` - -On RHEL, CentOS: -``` -$ sudo yum install thunar - -``` - -On Fedora: -``` -$ sudo dnf install thunar - -``` - -On openSUSE: -``` -$ sudo zypper install thunar - -``` - -On Debian, Ubuntu, Linux Mint: -``` -$ sudo apt-get install thunar - -``` - -Once installed, you can launch bulk rename utility from menu or from the application launcher. To launch it from Terminal, use the following command: -``` -$ thunar -B - -``` - -This is how bulk rename looks like. - -[![][1]][2] - -Click the plus sign and choose the list of files you want to rename. Bulk rename can rename the name of the files, the suffix of the files or both the name and the suffix of the files. Thunar currently supports the following Bulk Renamers: - - * Insert Date or Time - - * Insert or Overwrite - - * Numbering - - * Remove Characters - - * Search & Replace - - * Uppercase / Lowercase - - - - -When you select one of these criteria from the picklist, you will see a preview of your changes in the New Name column, as shown in the below screenshot. - -![][3] - -Once you choose the criteria, click on **Rename Files** option to rename the files. - -You can also open bulk renamer from within Thunar by selecting two or more files. After choosing the files, press F2 or right click and choose **Rename**. - -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-rename-multiple-files-at-once-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]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[2]:http://www.ostechnix.com/wp-content/uploads/2018/06/bulk-rename.png -[3]:http://www.ostechnix.com/wp-content/uploads/2018/06/bulk-rename-1.png diff --git a/translated/tech/20180615 How To Rename Multiple Files At Once In Linux.md b/translated/tech/20180615 How To Rename Multiple Files At Once In Linux.md new file mode 100644 index 0000000000..14f16b3eb6 --- /dev/null +++ b/translated/tech/20180615 How To Rename Multiple Files At Once In Linux.md @@ -0,0 +1,182 @@ +如何在 Linux 中一次重命名多个文件 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/06/Rename-Multiple-Files-720x340.png) + +你可能已经知道,我们使用 mv 命令在类 Unix 操作系统中重命名或者移动文件和目录。 但是,mv 命令不支持一次重命名多个文件。 不用担心。 在本教程中,我们将学习使用 Linux 中的 “mmv” 命令一次重命名多个文件。 此命令用于在类 Unix 操作系统中使用标准通配符批量移动,复制,追加和重命名文件。 + +### 在 Linux 中一次重命名多个文件 + +mmv 程序可在基于 Debian 的系统的默认仓库中使用。 要想在 Debian,Ubuntu,Linux Mint 上安装它,请运行以下命令: + +``` +$ sudo apt-get install mmv +``` + +我们假设你在当前目录中有以下文件。 + +``` +$ ls +a1.txt a2.txt a3.txt +``` + +现在,你想要将所有以字母 “a” 开头的文件重命名为以 “b” 开头的。 当然,你可以在几秒钟内手动执行此操作。 但是想想你是否有数百个文件想要重命名? 这是一个非常耗时的过程。 这时候 **mmv** 命令就很有帮助了。 + +要将所有以字母 “a” 开头的文件重命名为以字母 “b” 开头的,只需要运行: + +``` +$ mmv a\* b\#1 +``` + +让我们检查一下文件是否都已经重命名了。 + +``` +$ ls +b1.txt b2.txt b3.txt + +``` + +如你所见,所有以字母 “a” 开头的文件(即 a1.txt,a2.txt,a3.txt)都重命名为 b1.txt,b2.txt,b3.txt。 + +**解释** + +在上面的例子中,第一个参数(a\\*)是 'from' 模式,第二个参数是 'to' 模式(b\\#1)。根据上面的例子,mmv 将查找任何以字母 'a' 开头的文件名,并根据第二个参数重命名匹配的文件,即 'to' 模式。我们使用通配符,例如用 '*','?' 和 '[]' 来匹配一个或多个任意字符。请注意,你必须避免使用通配符,否则它们将被 shell 扩展,mmv 将无法理解。 + +'to' 模式中的 '#1' 是通配符索引。它匹配 'from' 模式中的第一个通配符。 'to' 模式中的 '#2' 将匹配第二个通配符,依此类推。在我们的例子中,我们只有一个通配符(星号),所以我们写了一个 #1。并且,哈希标志也应该被转义。此外,你也可以用引号括起模式。 + +你甚至可以将具有特定扩展名的所有文件重命名为其他扩展名。例如,要将当前目录中的所有 **.txt** 文件重命名为 **.doc** 文件格式,只需运行: + +``` +$ mmv \*.txt \#1.doc + +``` + +这是另一个例子。 我们假设你有以下文件。 + +``` +$ ls +abcd1.txt abcd2.txt abcd3.txt + +``` + +你希望在当前目录下的所有文件中将第一次出现的 **abc** 替换为 **xyz**。 你会怎么做呢? + +很简单。 + +``` +$ mmv '*abc*' '#1xyz#2' + +``` + +请注意,在上面的示例中,模式被单引号括起来了。 + +让我们检查下 “abc” 是否实际上被替换为 “xyz”。 + +``` +$ ls +xyzd1.txt xyzd2.txt xyzd3.txt + +``` + +看到没? 文件 **abcd1.txt**,**abcd2.txt** 和 **abcd3.txt** 已经重命名为 **xyzd1.txt**,**xyzd2.txt** 和 **xyzd3.txt**。 + +mmv 命令的另一个值得注意的功能是你可以使用 **-n** 选项打印输出而不是重命名文件,如下所示。 + +``` +$ mmv -n a\* b\#1 +a1.txt -> b1.txt +a2.txt -> b2.txt +a3.txt -> b3.txt + +``` + +这样,你可以在重命名文件之前简单地验证 mmv 命令实际执行的操作。 + +有关更多详细信息,请参阅 man 页面。 + +``` +$ man mmv + +``` + +**更新:** + +**Thunar 文件管理器**默认具有内置**批量重命名**选项。 如果你正在使用thunar,那么重命名文件要比使用mmv命令容易得多。 + +Thunar在大多数Linux发行版的默认仓库库中都可用。 + +要在基于Arch的系统上安装它,请运行: + +``` +$ sudo pacman -S thunar +``` + +在 RHEL,CentOS 上: +``` +$ sudo yum install thunar +``` + +在 Fedora 上: +``` +$ sudo dnf install thunar + +``` + +在 openSUSE 上: +``` +$ sudo zypper install thunar + +``` + +在 Debian,Ubuntu,Linux Mint 上: +``` +$ sudo apt-get install thunar + +``` + +安装后,你可以从菜单或应用程序启动器中启动批量重命名程序。 要从终端启动它,请使用以下命令: + +``` +$ thunar -B + +``` + +批量重命名就是这么回事。 + +![][1] + +单击加号,然后选择要重命名的文件列表。 批量重命名可以重命名文件的名称,文件的后缀或者同事重命名文件的名称和后缀。 Thunar 目前支持以下批量重命名: + +- 插入日期或时间 +- 插入或覆盖 +- 编号 +- 删除字符 +- 搜索和替换 +- 大写或小写 + +当你从选项列表中选择其中一个条件时,你将在“新名称”列中看到更改的预览,如下面的屏幕截图所示。 + +![][2] + +选择条件后,单击**重命名文件**选项来重命名文件。 + +你还可以通过选择两个或更多文件从 Thunar 中打开批量重命名器。 选择文件后,按F2或右键单击并选择**重命名**。 + +嗯,这就是本次的所有内容了。希望有所帮助。更多干货即将到来。敬请关注! + +祝快乐! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-rename-multiple-files-at-once-in-linux/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[Flowsnow](https://github.com/Flowsnow) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[1]: http://www.ostechnix.com/wp-content/uploads/2018/06/bulk-rename.png +[2]: http://www.ostechnix.com/wp-content/uploads/2018/06/bulk-rename-1.png \ No newline at end of file From c107e526a5c21e4bc3216673a573b82ee3462074 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 23 Oct 2018 23:27:00 +0800 Subject: [PATCH 129/158] Update .travis.yml --- .travis.yml | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 368993fec8..ff9b70cbc2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,21 +1,3 @@ language: c script: - - make -s badge - make -s check - - -branches: - only: - - master - -install: - - git clone --depth=1 https://github.com/LCTT/lctt-scripts - - sed -i "/ProjectRoot=/cProjectRoot=$(pwd)" ./lctt-scripts/lctt.cfg - -deploy: - provider: pages - skip_cleanup: true - github_token: $GITHUB_TOKEN - local_dir: build - on: - branch: master From 0354cb1da2cd06fd786aeef85d96edc30d3255ca Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Tue, 23 Oct 2018 23:45:49 +0800 Subject: [PATCH 130/158] Update Makefile --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 952b7b8b38..f33b3e3f7d 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ check: $(CHANGE_FILE) make -k $(RULES) 2>/dev/null | grep '^Rule Matched: ' $(CHANGE_FILE): - git --no-pager diff $(TRAVIS_BRANCH) FETCH_HEAD --no-renames --name-status > $@ + git --no-pager diff $(TRAVIS_BRANCH) origin/master --no-renames --name-status > $@ rule-source-added: echo 'Unmatched Files:' From 13f05da231e0ede592636edc8313af74ceab5b4f Mon Sep 17 00:00:00 2001 From: suncle Date: Wed, 24 Oct 2018 00:02:05 +0800 Subject: [PATCH 131/158] translated by Flowsnow --- ...171214 Peeking into your Linux packages.md | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) rename {sources => translated}/tech/20171214 Peeking into your Linux packages.md (57%) diff --git a/sources/tech/20171214 Peeking into your Linux packages.md b/translated/tech/20171214 Peeking into your Linux packages.md similarity index 57% rename from sources/tech/20171214 Peeking into your Linux packages.md rename to translated/tech/20171214 Peeking into your Linux packages.md index cd1f354250..ed7dca5ce1 100644 --- a/sources/tech/20171214 Peeking into your Linux packages.md +++ b/translated/tech/20171214 Peeking into your Linux packages.md @@ -1,24 +1,25 @@ -translating by Flowsnow - -Peeking into your Linux packages +探秘你的Linux软件包 ====== -Do you ever wonder how many _thousands_ of packages are installed on your Linux system? And, yes, I said "thousands." Even a fairly modest Linux system is likely to have well over a thousand packages installed. And there are many ways to get details on what they are. +你有没有想过你的 Linux 系统上安装了多少千个软件包? 是的,我说的是“千”。 即使是相当一般的 Linux 系统也可能安装了超过一千个软件包。 有很多方法可以获得这些包到底是什么包的详细信息。 + +首先,要在基于 Debian 的发行版(如 Ubuntu)上快速得到已安装的软件包数量,请使用 **apt list --installed**, 如下: -First, to get a quick count of your installed packages on a Debian-based distribution such as Ubuntu, use the command **apt list --installed** like this: ``` $ apt list --installed | wc -l 2067 ``` -This number is actually one too high because the output contains "Listing..." as its first line. This command would be more accurate: +这个数字实际上多了一个,因为输出中包含了 “Listing ...” 作为它的第一行。 这个命令会更准确: + ``` $ apt list --installed | grep -v "^Listing" | wc -l 2066 ``` -To get some details on what all these packages are, browse the list like this: +要获得所有这些包的详细信息,请按以下方式浏览列表: + ``` $ apt list --installed | more Listing... @@ -32,9 +33,9 @@ account-plugin-salut/xenial,now 3.12.11-0ubuntu3 amd64 [installed] ``` -That's a lot of detail to absorb -- especially if you let your eyes wander through all 2,000+ files rolling by. It contains the package names, versions, and more but isn't the easiest information display for us humans to parse. The dpkg-query makes the descriptions quite a bit easier to understand, but they will wrap around your command window unless it's _very_ wide. So, the data display below has been split into the left and right hand sides to make this post easier to read. +这需要观察很多细节--特别是让你的眼睛在所有 2000 多个文件中徘徊。 它包含包名称,版本等,但不是我们人类解析的最简单的信息显示。 dpkg-query 使得描述更容易理解,但这些描述塞满你的命令窗口,除非窗口非常宽。 因此,为了让此篇文章更容易阅读,下面的数据显示已经分成了左右两侧。 -Left side: +左侧: ``` $ dpkg-query -l | more Desired=Unknown/Install/Remove/Purge/Hold @@ -54,7 +55,7 @@ rc account-plugin-windows-live 0.11+14.04.20140409.1-0ubuntu2 ``` -Right side: +右侧: ``` Architecture Description ============-===================================================================== @@ -70,7 +71,8 @@ all GNOME Control Center account plugin for single signon - windows live ``` -The "ii" and "rc" designations at the beginning of each line (see "Left side" above) are package state indicators. The first letter represents the desirable package state: +每行开头的 “ii” 和 “rc” 名称(见上文“左侧”)是包状态指示符。 第一个字母表示包的理想状态: + ``` u -- unknown i -- install @@ -80,7 +82,8 @@ h -- hold ``` -The second represents the current package state: +第二个代表包的当前状态: + ``` n -- not-installed i -- installed @@ -93,9 +96,10 @@ t -- triggers-pending (the package has been triggered) ``` -An added "R" at the end of the normally two-character field would indicate that reinstallation is required. You may never run into these. +在通常的双字符字段末尾添加的 “R” 表示需要重新安装。 你可能永远不会碰到这些。 + +快速查看整体包状态的一种简单方法是计算在不同状态中包含的包的数量: -One easy way to take a quick look at your overall package status is to count how many packages are in which of the different states: ``` $ dpkg-query -l | tail -n +6 | awk '{print $1}' | sort | uniq -c 2066 ii @@ -103,25 +107,24 @@ $ dpkg-query -l | tail -n +6 | awk '{print $1}' | sort | uniq -c ``` -I excluded the top five lines from the dpkg-query output above because these are the header lines that would have confused the output. +我从上面的 dpkg-query 输出中排除了前五行,因为这些是标题行,会混淆输出。 + +这两行基本上告诉我们,在这个系统上,应该安装了 2066 个软件包,而 134 个其他的软件包已被删除,但已经留下了配置文件。 你始终可以使用以下命令删除程序包的剩余配置文件: -The two lines basically tell us that on this system, 2,066 packages should be and are installed, while 134 other packages have been removed but have left configuration files behind. You can always remove a package's remaining configuration files with a command like this: ``` $ sudo dpkg --purge xfont-mathml - ``` -Note that the command above would have removed the package binaries along with the configuration files if both were still installed. - +请注意,如果程序包二进制文件和配置文件都已经安装了,则上面的命令将两者都删除。 -------------------------------------------------------------------------------- via: https://www.networkworld.com/article/3242808/linux/peeking-into-your-linux-packages.html 作者:[Sandra Henry-Stocker][a] -译者:[runningwater](https://github.com/runningwater) +译者:[Flowsnow](https://github.com/Flowsnow) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 -[a]:https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ \ No newline at end of file From 050d4ee711de0d3e874243d5180502444238e621 Mon Sep 17 00:00:00 2001 From: lctt-bot Date: Tue, 23 Oct 2018 17:02:36 +0000 Subject: [PATCH 132/158] =?UTF-8?q?Revert=20"[=E7=94=B3=E8=AF=B7=E7=BF=BB?= =?UTF-8?q?=E8=AF=91]=20Writing=20a=20Time=20Series=20Database=20from=20Sc?= =?UTF-8?q?ratch.md"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 2bba08f37600a661f4b85ccb93e16a6fb29a0783. --- .../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 ba66193a0d..a7f8289b63 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 @@ -[haoqixu翻译中]Writing a Time Series Database from Scratch +Writing a Time Series Database from Scratch ============================================================ From 544dc90ba043f29f83692717d8bd6f873033a71e Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 24 Oct 2018 08:51:59 +0800 Subject: [PATCH 133/158] translated --- ... a Retrogaming Console with Lakka Linux.md | 80 ------------------- ... a Retrogaming Console with Lakka Linux.md | 78 ++++++++++++++++++ 2 files changed, 78 insertions(+), 80 deletions(-) delete mode 100644 sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md create mode 100644 translated/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md diff --git a/sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md b/sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md deleted file mode 100644 index 08ef4a8dc2..0000000000 --- a/sources/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md +++ /dev/null @@ -1,80 +0,0 @@ -translating---geekpi - -Turn Your Old PC into a Retrogaming Console with Lakka Linux -====== -**If you have an old computer gathering dust, you can turn it into a PlayStation like retrogaming console with Lakka Linux distribution. ** - -You probably already know that there are [Linux distributions specially crafted for reviving older computers][1]. But did you know about a Linux distribution that is created for the sole purpose of turning your old computer into a retro-gaming console? - -![Lakka is a Linux distribution specially for retrogaming][2] - -Meet [Lakka][3], a lightweight Linux distribution that will transform your old or low-end computer (like Raspberry Pi) into a complete retrogaming console, - -When I say retrogaming console, I am serious about the console part. If you have ever used a PlayStation of Xbox, you know what a typical console interface looks like. - -Lakka provides a similar interface and a similar experience. I’ll talk about the ‘experience’ later. Have a look at the interface first. - - -Lakka Retrogaming interface - -### Lakka: Linux distributions for retrogaming - -Lakka is the official Linux distribution of [RetroArch][4] and the [Libretro][5] ecosystem. - -RetroArch is a frontend for retro game emulators and game engines. The interface you saw in the video above is nothing but RetroArch. If you just want to play retro games, you can simply install RetroArch in your current Linux distribution. - -Lakka provides Libretro core with RetroArch. So you get a preconfigured operating system that you can install or plug in the live USB and start playing games. - -Lakka is lightweight and you can install it on most old systems or single board computers like Raspberry Pi. - -It supports a huge number of emulators. You just need to download the ROMs on your system and Lakka will play the games from these ROMs. You can find the list supported emulators and hardware [here][6]. - -It enables you to run classic games on a wide range of computers and consoles through its slick graphical interface. Settings are also unified so configuration is done once and for all. - -Let me summarize the main features of Lakka: - - * PlayStation like interface with RetroArch - * Support for a number of retro game emulators - * Supports up to 5 players gaming on the same system - * Savestates allow you to save your progress at any moment in the game - * You can improve the look of your old games with various graphical filters - * You can join multiplayer games over the network - * Out of the box support for a number of joypads like XBOX360, Dualshock 3, and 8bitdo - * Unlike trophies and badges by connecting to [RetroAchievements][7] - - - -### Getting Lakka - -Before you go on installing Lakka you should know that it is still under development so expect a few bugs here and there. - -Keep in mind that Lakka only supports MBR partitioning. So if it doesn’t read your hard drive while installing, this could be a reason. - -The [FAQ section of the project][8] answers the common doubts, so please refer to it for any further questions. - -[Get Lakka][9] - -Do you like playing retro games? What emulators do you use? Have you ever used Lakka before? Share your views with us in the comments section. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/lakka-retrogaming-linux/ - -作者:[Abhishek Prakash][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/abhishek/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/lightweight-linux-beginners/ -[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/10/lakka-retrogaming-linux.jpeg -[3]: http://www.lakka.tv/ -[4]: https://www.retroarch.com/ -[5]: https://www.libretro.com/ -[6]: http://www.lakka.tv/powerful/ -[7]: https://retroachievements.org/ -[8]: http://www.lakka.tv/doc/FAQ/ -[9]; http://www.lakka.tv/disclaimer/ diff --git a/translated/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md b/translated/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md new file mode 100644 index 0000000000..ad720ac79d --- /dev/null +++ b/translated/tech/20181016 Turn Your Old PC into a Retrogaming Console with Lakka Linux.md @@ -0,0 +1,78 @@ +使用 Lakka Linux 将你的旧 PC 变成复古游戏主机 +====== +**如果你有一台吃灰的旧计算机,你可以用 Lakka Linux 将它变成像 PlayStation 那样的复古游戏主机。** + +你可能已经了解[专门用于复活旧计算机的 Linux 发行版][1]。但是你知道有个 Linux 发行版专门是为了将旧电脑变成复古游戏主机创建的么? + +![Lakka is a Linux distribution specially for retrogaming][2] + +认识下 [Lakka][3],它是一个轻量级 Linux 发行版,可以将旧的或低端的计算机(如 Raspberry Pi)变成一个完整的复古游戏主机, + +当我说复古游戏主机时,我对主机部分很认真。如果你曾经使用过 Xbox 和 PlayStation,你就会知道典型的主机界面是什么样的。 + +Lakka 提供类似的界面和类似的体验。我稍后会谈到“体验”。先看一下界面。 + + +Lakka 复古游戏界面 + +### Lakka:为复古游戏而生的 Linux 发行版 + +Lakka 是 [RetroArch][4] 和 [Libretro][5] 生态系统的官方 Linux 发行版。 + +RetroArch 是复古游戏模拟器和游戏引擎的前端。你在上面的视频中看到的界面只是 RetroArch。如果你是只想玩复古游戏,只需在当前的 Linux 发行版中安装 RetroArch 即可。 + +Lakka 提供了带有 Libretro 核心的 RetroArch。因此,你会获得一个预先配置完的操作系统,你可以安装或插入 live USB 并开始玩游戏。 + +Lakka 是轻量级的,你可以将它安装在大多数老系统或单板计算机上,如 Raspberry Pi 上。 + +它支持大量的模拟器。你只需要在系统上下载 ROM,Lakka 将从这些 ROM 运行游戏。你可以在[这里][6]找到支持的模拟器和硬件列表。 + +它通过器顺滑的图形界面让你能够在许多计算机和主机上运行经典游戏。设置也是统一的,因此可以一劳永逸地完成配置。 + +让我总结一下 Lakka 的主要特点: + + * RetroArch 中与 PlayStation 类似的界面 +  * 支持许多复古游戏模拟器 +  * 支持最多 5 名玩家在同一系统上玩游戏 +  * 存档允许你随时保存游戏中的进度 +  * 你可以使用各种图形过滤器改善旧游戏的外表 +  * 你可以通过网络加入多人游戏 +  * 开箱即用支持 XBOX360、Dualshock 3 和 8bitdo 等多种游戏手柄 +  * 连接到 [RetroAchievements] [7] 获取奖杯和徽章 + + + +### 获取 Lakka + +在你继续安装 Lakka 之前,你应该了解它仍在开发中,因此会有一些 bug。 + +请记住,Lakka 仅支持 MBR 分区。因此,如果在安装时没有读到你的硬盘,这可能是一个原因。 + +[项目的 FAQ 部分][8]回答了常见的疑问,所以如有任何其他的问题,请参考它。 + +[获取 Lakka][9] + +你喜欢复古游戏吗?你使用什么模拟器?你以前用过 Lakka 吗?在评论区与我们分享你的观点。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/lakka-retrogaming-linux/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/lightweight-linux-beginners/ +[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/10/lakka-retrogaming-linux.jpeg +[3]: http://www.lakka.tv/ +[4]: https://www.retroarch.com/ +[5]: https://www.libretro.com/ +[6]: http://www.lakka.tv/powerful/ +[7]: https://retroachievements.org/ +[8]: http://www.lakka.tv/doc/FAQ/ +[9]; http://www.lakka.tv/disclaimer/ From 2faa44e7da9ba65dd53f4acbebc44d9e414b91af Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 24 Oct 2018 08:56:04 +0800 Subject: [PATCH 134/158] translating --- .../tech/20181018 MidnightBSD Hits 1.0- Checkout What-s New.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20181018 MidnightBSD Hits 1.0- Checkout What-s New.md b/sources/tech/20181018 MidnightBSD Hits 1.0- Checkout What-s New.md index 345a9f9b5b..60350e676e 100644 --- a/sources/tech/20181018 MidnightBSD Hits 1.0- Checkout What-s New.md +++ b/sources/tech/20181018 MidnightBSD Hits 1.0- Checkout What-s New.md @@ -1,3 +1,5 @@ +translating---geekpi + MidnightBSD Hits 1.0! Checkout What’s New ====== A couple days ago, Lucas Holt announced the release of MidnightBSD 1.0. Let’s take a quick look at what is included in this new release. From 9d863add304daccd85c18331691b194617d9d064 Mon Sep 17 00:00:00 2001 From: pityonline Date: Wed, 24 Oct 2018 00:06:48 +0800 Subject: [PATCH 135/158] =?UTF-8?q?PRF:=20#10699=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 --- ...Can Expand Your Skills and Grow Your Career.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/translated/talk/20180919 How Writing Can Expand Your Skills and Grow Your Career.md b/translated/talk/20180919 How Writing Can Expand Your Skills and Grow Your Career.md index f75c55b892..23d730cca0 100644 --- a/translated/talk/20180919 How Writing Can Expand Your Skills and Grow Your Career.md +++ b/translated/talk/20180919 How Writing Can Expand Your Skills and Grow Your Career.md @@ -1,17 +1,21 @@ 写作是如何帮助技能拓展和事业成长的 ====== +> 了解为什么写作可以帮助学习新技能和事业成长 + ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/graffiti-1281310_1920.jpg?itok=RCayfGKv) +Creative Commons Zero Pixabay + 在最近的[温哥华开源峰会][1]上,我参加了一个小组讨论,叫做“写作是如何改变你的职业生涯的(即使你不是个作家)”。主持人是 Opensource.com 的社区经理兼编辑 Rikki Endsley,成员有开源策略顾问 VM (Vicky) Brasseur,The New Stack 的创始人兼主编 Alex Williams,还有 The Scale Factory 的顾问 Dawn Foster。 -Rikki 在她的[这篇文章][3]中总结了一些能愉悦你,并且能以意想不到的方式改善你职业生涯的写作方法,我在峰会上的发言是受她这篇文章的启发。透露一下,我认识 Rikki 很久了,我们在同一家公司共事了很多年,一起带过孩子,到现在还是很亲密的朋友。 +Rikki 在她的[这篇文章][3]中总结了一些令人愉快的,并且能以意想不到的方式改善你职业生涯的写作方法,我在峰会上的发言是受她这篇文章的启发。透露一下,我认识 Rikki 很久了,我们在同一家公司共事了很多年,一起带过孩子,到现在还是很亲密的朋友。 ### 写作和学习 正如 Rikki 对这个小组讨论的描述,“即使你自认为不是一个‘作家’,你也应该考虑写一下对开源的贡献,还有你的项目或者社区”。写作是一种很好的方式,来分享自己的知识并让别人参与到你的工作中来,当然它对个人也有好处。写作能帮助你结识新人,学习新技能,还能改善你的沟通。 -我发现写作能让我搞清楚自己对某个主题有哪些不懂的地方。写作的过程会让知识体系的空白很突出,这激励了我通过进一步的研究、阅读和提问来填补空白。 +我发现写作能让我搞清楚自己对某个主题有哪些不懂的地方。写作的过程会让知识体系的空白很突出,这激励了我通过进一步的研究、阅读和提问来填补这些空白。 Rikki 说:“写那些你不知道的东西会更加困难也更加耗时,但是也更有成就感,更有益于你的事业。我发现写我不知道的东西有助于自己学习,因为得研究透彻才能给读者解释清楚。” @@ -19,12 +23,11 @@ Rikki 说:“写那些你不知道的东西会更加困难也更加耗时, ### 更明确的沟通 - -写作有助于练习思考和准确讲话,尤其是面向国际受众写作(或演讲)时。例如,在[这篇文章中][5],Isabel Drost-Fromm 为那些母语不是英语的演讲者提供了几个技巧来消除歧义。不管是在会议上还是在自己团队内发言,写作还能帮你在演示之前理清思路。 +写作有助于思维训练和准确表达,尤其是面向国际受众写作(或演讲)时。例如,在[这篇文章中][5],Isabel Drost-Fromm 为那些母语不是英语的演讲者提供了几个技巧来消除歧义。不管是在会议上还是在自己团队内发言,写作还能帮你在演示幻灯片之前理清思路。 Rikki 说:“写文章的过程有助于我组织整理自己的发言和演示稿,也是一个给参会者提供笔记的好方式,还可以分享给没有参加活动的更多国际观众。” -如果你有兴趣,我鼓励你去写作。我强烈建议你参考这里提到的文章,开始思考你要写的内容。 不幸的是,我们在开源峰会上的讨论没有记录,但我希望将来能再做一次讨论,分享更多的想法。 +如果你有兴趣,我鼓励你去写作。我强烈建议你参考这里提到的文章,开始思考你要写的内容。不幸的是,我们在开源峰会上的讨论没有记录下来,但我希望将来能再做一次讨论,分享更多的想法。 -------------------------------------------------------------------------------- @@ -33,7 +36,7 @@ via: https://www.linux.com/blog/2018/9/how-writing-can-help-you-learn-new-skills 作者:[Amber Ankerholz][a] 选题:[lujun9972](https://github.com/lujun9972) 译者:[belitex](https://github.com/belitex) -校对:[校对者ID](https://github.com/校对者ID) +校对:[pityonline](https://github.com/pityonline) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 3b3fa709d72357f1b6ef8f4e826a5456a1b11c75 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 24 Oct 2018 09:43:20 +0800 Subject: [PATCH 136/158] PRF:20180105 The Best Linux Distributions for 2018.md @dianbanjiu --- ...5 The Best Linux Distributions for 2018.md | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/translated/tech/20180105 The Best Linux Distributions for 2018.md b/translated/tech/20180105 The Best Linux Distributions for 2018.md index ed373a6f6e..6717f6233a 100644 --- a/translated/tech/20180105 The Best Linux Distributions for 2018.md +++ b/translated/tech/20180105 The Best Linux Distributions for 2018.md @@ -1,9 +1,11 @@ -# 2018 年最好的 Linux 发行版 +2018 年最好的 Linux 发行版 +====== ![Linux distros 2018](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/linux-distros-2018.jpg?itok=Z8sdx4Zu "Linux distros 2018") -Jack Wallen 分享他挑选的 2018 年最好的 Linux 发行版。 -这是新的一年,Linux仍有无限可能。而且许多 Linux 在 2017 年都带来了许多重大的改变,我相信在 2018 年它在服务器和桌面上将会带来更加稳定的系统和市场份额的增长。 +> Jack Wallen 分享他挑选的 2018 年最好的 Linux 发行版。 + +这是新的一年,Linux 仍有无限可能。而且许多 Linux 发行版在 2017 年都带来了许多重大的改变,我相信在 2018 年它在服务器和桌面上将会带来更加稳定的系统和市场份额的增长。 对于那些期待迁移到开源平台(或是那些想要切换到)的人对于即将到来的一年,什么是最好的选择?如果你去 [Distrowatch][14] 找一下,你可能会因为众多的发行版而感到头晕,其中一些的排名在上升,而还有一些则恰恰相反。 @@ -15,80 +17,79 @@ Jack Wallen 分享他挑选的 2018 年最好的 Linux 发行版。 ### 对系统管理员最好的发行版 -[Debian][16] 不常出现在“最好的”列表中。但他应该出现,为什么呢?如果了解到 Ubuntu 是基于 Debian 构建的(其实有很多的发行版都基于 Debian),你就很容易理解为什么这个发行版应该在许多“最好”清单中。但为什么是对管理员最好的呢?我想这是由于两个非常重要的原因: +[Debian][16] 不常出现在“最好的”列表中。但它应该出现,为什么呢?如果了解到 Ubuntu 是基于 Debian 构建的(其实有很多的发行版都基于 Debian),你就很容易理解为什么这个发行版应该在许多“最好”清单中。但为什么是对管理员最好的呢?我想这是由于两个非常重要的原因: * 容易使用 * 非常稳定 -因为 Debain 使用 dpkg 和 apt 包管理,它使得使用环境非常简单。而且因为 Debian 提供了最稳定的 Linux 平台之一,它为许多事物提供了理想的环境:桌面,服务器,测试,开发。虽然 Debian 可能不包括去年获奖者发现的大量应用程序,但添加完成任务所需的任何/所有必要应用程序都非常容易。而且因为 Debian 可以根据你的选择安装桌面(Cinnamon, GNOME, KDE, LXDE, Mate, 或者 Xfce),你可以确定满足你需要的桌面。 +因为 Debain 使用 dpkg 和 apt 包管理,它使得使用该环境非常简单。而且因为 Debian 提供了最稳定的 Linux 平台之一,它为许多事物提供了理想的环境:桌面、服务器、测试、开发。虽然 Debian 可能不包括去年本分类的优胜者 [Parrot Linux][17] 所带有的大量应用程序,但添加完成任务所需的任何或全部必要的应用程序都非常容易。而且因为 Debian 可以根据你的选择安装不同的桌面(Cinnamon、GNOME、KDE、LXDE、Mate 或者 Xfce),肯定可以满足你对桌面的需求。 ![debian](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/debian.jpg?itok=XkHHG692 "debian") -图1:在 Debian 9.3 上运行的 GNOME 桌面。[使用][1] -同时,Debain 在 Distrowatch 上名列第二。下载,安装,然后让它为你的工作而服务吧。Debain 尽管不那么华丽,但是对于管理员的工作来说十分有用。 +*图 1:在 Debian 9.3 上运行的 GNOME 桌面。* + +同时,Debain 在 Distrowatch 上名列第二。下载、安装,然后让它为你的工作而服务吧。Debain 尽管不那么华丽,但是对于管理员的工作来说十分有用。 ### 最轻量级的发行版 -轻量级的发行版对于一些老旧或是性能底下的机器有很好的支持。但是这不意味着这些发行版仅仅只为了老旧的硬件机器而生。如果你想要的是运行速度,你可能会想知道在你的现代机器上,这类发行版的运行速度。 +轻量级的发行版有其特殊的用途:给予一些老旧或是性能低下的机器以新生。但是这不意味着这些特别的发行版仅仅只为了老旧的硬件机器而生。如果你想要的是运行速度,你可能会想知道在你的现代机器上这类发行版的运行速度能有多快。 -在 2018 年上榜的最轻量级的发行版是 [Lubuntu][18]。尽管在这个类别里还有很多选择,而且尽管 Lubuntu 的大小与 Puppy Linux 相接近,但得益于它是 Ubuntu 家庭的一员,这弥补了它在易用性上的一些不足。但是不要担心,Lubuntu 对于硬件的要求并不高: +在 2018 年上榜的最轻量级的发行版是 [Lubuntu][18]。尽管在这个类别里还有很多选择,而且尽管 Lubuntu 的资源占用与 Puppy Linux 一样小,但得益于它是 Ubuntu 家庭的一员,其易用性为它加了分。但是不要担心,Lubuntu 对于硬件的要求并不高: -+ CPU:奔腾 4 或者 奔腾 M 或者 AMD K8 以上 -+ 对于本地应用,512 MB 的内存就可以了,对于网络使用(Youtube,Google+,Google Drive, Facebook),建议 1 GB 以上。 ++ CPU:奔腾 4 或者奔腾 M 或者 AMD K8 以上 ++ 对于本地应用,512 MB 的内存就可以了,对于网络使用(Youtube、Google+、Google Drive、Facebook),建议 1 GB 以上。 -Lubuntu 使用的是 LXDE 桌面,这意味着用户在初次使用这个 Linux 发行版时不会有任何问题。这份短清单中包含的应用(例如:Abiword, Gnumeric, 和 Firefox)都是非常轻量,且对用户友好的。 +Lubuntu 使用的是 LXDE 桌面(图 2),这意味着新接触 Linux 的用户在使用这个发行版时不会有任何问题。这份简短清单中包含的应用(例如:Abiword、Gnumeric 和 Firefox)都是非常轻量的,且对用户友好的。 -### [lubuntu,jpg][8] ![Lubuntu](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/lubuntu_2.jpg?itok=BkTnh7hU "Lubuntu") -图2:LXDE桌面。[使用][2] -Lubuntu 能让十年以上的电脑如获新生。 +*图 2:LXDE桌面。* + +Lubuntu 能让十年以上的电脑如获新生。 ### 最好的桌面发行版 -[Elementary OS][19] 连续两年都是我清单中最好的桌面发行版。对于许多人,[Linux Mint][20] 都是桌面发行版的领导。但是,与我来说,它在易用性和稳定性上很难打败 Elementary OS。例如,我确信 [Ubuntu][21] 17.10 的发布会让我迁移回 Canonical 的发行版。不久之后我会迁移到 新的使用 GNOME 桌面的 Ubuntu,但是我发现我少了 Elementary OS 外观,可用性和感觉。在使用 Ubuntu 两周以后,我又换回了 Elementary OS。 - -### [elementaros.jpg][9] +[Elementary OS][19] 连续两年都是我清单中最好的桌面发行版。对于许多人,[Linux Mint][20] (也是一个非常棒的分支)都是桌面发行版的领袖。但是,于我来说,它在易用性和稳定性上很难打败 Elementary OS。例如,我确信是 [Ubuntu][21] 17.10 的发布让我迁移回了 Canonical 的发行版。迁移到新的使用 GNOME 桌面的 Ubuntu 不久之后,我发现我缺少了 Elementary OS 外观、可用性和感觉(图 3)。在使用 Ubuntu 两周以后,我又换回了 Elementary OS。 ![Elementary OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/elementaros.jpg?itok=SRZC2vkg "Elementary OS") -图3:Pantheon 桌面是一件像艺术品一样的桌面。[使用][3] -任何使用 Elementary OS 的感觉很好。Pantheon 桌面是缺省和用户友好做的最完美的桌面。每次更新,它都会变得更好。 +*图 3:Pantheon 桌面是一件像艺术品一样的桌面。* -尽管 Elementary OS 在 Distrowatch 中排名第六,但我预计到 2018 年第,它将至少上升至第三名。Elementary 开发人员非常关注用户的需求。他们倾听并且改进,他们目前的状态是如此之好,似乎所有他们都可以做的更好。 如果您需要一个具有出色可靠性和易用性的桌面,Elementary OS 就是你的发行版。 +使用 Elementary OS 的任何一个人都会觉得宾至如归。Pantheon 桌面是将操作顺滑和用户友好结合的最完美的桌面。每次更新,它都会变得更好。 + +尽管 Elementary OS 在 Distrowatch 页面访问量中排名第六,但我预计到 2018 年末,它将至少上升至第三名。Elementary 开发人员非常关注用户的需求。他们倾听并且改进,这个发行版目前的状态是如此之好,似乎他们一切都可以做的更好。 如果您需要一个具有出色可靠性和易用性的桌面,Elementary OS 就是你的发行版。 ### 能够证明自己的最好的发行版 -很长一段时间内,[Gentoo][22]都稳坐“展现你技能”的发行版的首座。但是,我认为现在 Gentoo 是时候让出“证明自己”的宝座给 [Linux From Svratch][23]。你可能认为这不公平,因为 LFS 实际上不是一个发行版,而是一个帮助用户创建自己的 Linux 发行版的项目。但是,有什么能比你自己创建一个自己的发行版更能证明自己所学的 Linux 知识的呢?在 LFS 项目中,你可以从头开始构建自定义的 Linux 系统。 所以,如果你真的有需要证明的东西,请下载 [Linux From Scratch Book][24] 并开始构建。 +很长一段时间内,[Gentoo][22] 都稳坐“展现你技能”的发行版的首座。但是,我认为现在 Gentoo 是时候让出“证明自己”的宝座给 [Linux From Scratch(LFS)][23]。你可能认为这不公平,因为 LFS 实际上不是一个发行版,而是一个帮助用户创建自己的 Linux 发行版的项目。但是,有什么能比你自己创建一个自己的发行版更能证明自己所学的 Linux 知识的呢?在 LFS 项目中,你可以从头开始构建自定义的 Linux 系统,而且是从源代码开始。 所以,如果你真的想证明些什么,请下载 [Linux From Scratch Book][24] 并开始构建。 ### 对于物联网最好的发行版 -[Ubuntu Core][25] 已经是第二年赢得了该项的冠军。Ubuntu Core 是 Ubuntu 的一个小型版本,专为嵌入式和物联网设备而构建。使Ubuntu Core 如此完美的物联网的原因在于它将重点放在快照包 - 通用包上,可以安装到平台上,而不会干扰基本系统。这些快照包包含它们运行所需的所有内容(包括依赖项),因此不必担心安装会破坏操作系统(或任何其他已安装的软件)。 此外,快照非常容易升级并在隔离的沙箱中运行,这使它们成为物联网的理想解决方案。 +[Ubuntu Core][25] 已经是第二年赢得了该项的冠军。Ubuntu Core 是 Ubuntu 的一个小型的、事务型版本,专为嵌入式和物联网设备而构建。使 Ubuntu Core 如此完美支持物联网的原因在于它将重点放在 snap 包上 —— 这种通用包可以安装到一个平台上而不会干扰其基本系统。这些 snap 包包含它们运行所需的所有内容(包括依赖项),因此不必担心安装它会破坏操作系统(或任何其他已安装的软件)。 此外,snap 包非常容易升级,并运行在隔离的沙箱中,这使它们成为物联网的理想解决方案。 -Ubuntu Core 内置的另一个安全领域是登录机制。Ubuntu Core使用Ubuntu One ssh密钥,这样登录系统的唯一方法是通过上传的ssh密钥到[Ubuntu One帐户][26]。这为你的物联网设备提供了更高的安全性。 +Ubuntu Core 内置的另一个安全领域是登录机制。Ubuntu Core 使用Ubuntu One ssh密钥,这样登录系统的唯一方法是通过上传的 ssh 密钥到 [Ubuntu One帐户][26](图 4)。这为你的物联网设备提供了更高的安全性。 -### [ubuntucore.jpg][10] ![ Ubuntu Core](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ubuntucore.jpg?itok=Ydfq8NKH " Ubuntu Core") -图4:Ubuntu Core屏幕指示通过Ubuntu One用户启用远程访问。[使用][3] + +*图 4:Ubuntu Core屏幕指示通过Ubuntu One用户启用远程访问。* ### 最好的服务器发行版 -这让事情变得有些混乱。 主要原因是支持。 如果你需要商业支持,乍一看,你最好的选择可能是 [Red Hat Enterprise Linux][27]。红帽年复一年地证明了自己不仅是全球最强大的企业服务器平台之一,而且是单一最赚钱的开源业务(年收入超过20亿美元)。 +这里有点意见不统一。主要原因是支持。如果你需要商业支持,乍一看,你最好的选择可能是 [Red Hat Enterprise Linux][27]。红帽年复一年地证明了自己不仅是全球最强大的企业服务器平台之一,而且是单一最赚钱的开源业务(年收入超过 20 亿美元)。 -但是,Red Hat 并不是唯一的服务器发行版。 实际上,Red Hat 甚至不支持企业服务器计算的各个方面。如果你关注亚马逊 Elastic Compute Cloud 上的云统计数据,Ubuntu 就会打败红帽企业Linux。根据[云市场][28],EC2 统计数据显示 RHEL 的部署率低于 10 万,而 Ubuntu 的部署量超过 20 万。 +但是,Red Hat 并不是唯一的服务器发行版。 实际上,Red Hat 甚至并不能垄断企业服务器计算的各个方面。如果你关注亚马逊 Elastic Compute Cloud 上的云统计数据,Ubuntu 就会打败红帽企业 Linux。根据[云市场][28]的报告,EC2 统计数据显示 RHEL 的部署率低于 10 万,而 Ubuntu 的部署量超过 20 万。 -最终的结果是,Ubuntu 几乎已经成为云计算的领导者。如果你将它与 Ubuntu 易于使用和管理容器结合起来,就会发现 Ubuntu Server 是服务器类别的明显赢家。而且,如果你需要商业支持,Canonical 将为你提供 [Ubuntu Advantage][29]。 +最终的结果是,Ubuntu 几乎已经成为云计算的领导者。如果你将它与 Ubuntu 对容器的易用性和可管理性结合起来,就会发现 Ubuntu Server 是服务器类别的明显赢家。而且,如果你需要商业支持,Canonical 将为你提供 [Ubuntu Advantage][29]。 -对使用 Ubuntu Server 的一个警告是它默认为纯文本界面。如果需要,你可以安装 GUI,但使用Ubuntu Server 命令行非常简单(每个Linux管理员都应该知道)。 - -### [ubuntuserver.jpg][11] +对使用 Ubuntu Server 的一个警告是它默认为纯文本界面(图 5)。如果需要,你可以安装 GUI,但使用 Ubuntu Server 命令行非常简单(每个 Linux 管理员都应该知道)。 ![Ubuntu server](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ubuntuserver_1.jpg?itok=qtFSUlee "Ubuntu server") -图5:Ubuntu 服务器登录,通知更新。[使用][3] -### 你最好的选择 +*图 5:Ubuntu 服务器登录,通知更新。* -正如我之前所说,这些选择都非常主观,但如果你正在寻找一个好的开始,那就试试这些发行版。每一个都可以用于非常特定的目的,并且比大多数做得更好。虽然你可能不同意我的特定选择,但你可能会同意 Linux 在每个方面都提供了惊人的可能性。并且,请继续关注下周更多“最佳发行版”选秀。 +### 你怎么看 + +正如我之前所说,这些选择都非常主观,但如果你正在寻找一个好的开始,那就试试这些发行版。每一个都可以用于非常特定的目的,并且比大多数做得更好。虽然你可能不同意我的个别选择,但你可能会同意 Linux 在每个方面都提供了惊人的可能性。并且,请继续关注下周更多“最佳发行版”选秀。 通过 Linux 基金会和 edX 的免费[“Linux 简介”][13]课程了解有关Linux的更多信息。 @@ -96,9 +97,9 @@ Ubuntu Core 内置的另一个安全领域是登录机制。Ubuntu Core使用Ubu via: https://www.linux.com/blog/learn/intro-to-linux/2018/1/best-linux-distributions-2018 -作者:[JACK WALLEN ][a] +作者:[JACK WALLEN][a] 译者:[dianbanjiu](https://github.com/dianbanjiu) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From b6fd67792b28650365cb3ee6b88166b9ed66cab4 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 24 Oct 2018 09:43:58 +0800 Subject: [PATCH 137/158] PUB:20180105 The Best Linux Distributions for 2018.md @dianbanjiu https://linux.cn/article-10146-1.html --- .../20180105 The Best Linux Distributions for 2018.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20180105 The Best Linux Distributions for 2018.md (100%) diff --git a/translated/tech/20180105 The Best Linux Distributions for 2018.md b/published/20180105 The Best Linux Distributions for 2018.md similarity index 100% rename from translated/tech/20180105 The Best Linux Distributions for 2018.md rename to published/20180105 The Best Linux Distributions for 2018.md From 7a93f72c71e8b31ac80a4963904346c15c2245ab Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 24 Oct 2018 10:31:55 +0800 Subject: [PATCH 138/158] PUB:20180919 How Writing Can Expand Your Skills and Grow Your Career.md @belitex @pityonline https://linux.cn/article-10147-1.html --- ...919 How Writing Can Expand Your Skills and Grow Your Career.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/talk => published}/20180919 How Writing Can Expand Your Skills and Grow Your Career.md (100%) diff --git a/translated/talk/20180919 How Writing Can Expand Your Skills and Grow Your Career.md b/published/20180919 How Writing Can Expand Your Skills and Grow Your Career.md similarity index 100% rename from translated/talk/20180919 How Writing Can Expand Your Skills and Grow Your Career.md rename to published/20180919 How Writing Can Expand Your Skills and Grow Your Career.md From 0ada7641ec348b96f176252e4979b22a387595b3 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 24 Oct 2018 11:09:32 +0800 Subject: [PATCH 139/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20What=20MMORPGs=20?= =?UTF-8?q?can=20teach=20us=20about=20leveling=20up=20a=20heroic=20develop?= =?UTF-8?q?er=20team?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...out leveling up a heroic developer team.md | 213 ++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 sources/talk/20181023 What MMORPGs can teach us about leveling up a heroic developer team.md diff --git a/sources/talk/20181023 What MMORPGs can teach us about leveling up a heroic developer team.md b/sources/talk/20181023 What MMORPGs can teach us about leveling up a heroic developer team.md new file mode 100644 index 0000000000..23161bd1b6 --- /dev/null +++ b/sources/talk/20181023 What MMORPGs can teach us about leveling up a heroic developer team.md @@ -0,0 +1,213 @@ +What MMORPGs can teach us about leveling up a heroic developer team +====== +The team-building skills that make winning gaming guilds also produce successful work teams. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team-game-play-inclusive-diversity-collaboration.png?itok=8sUXV7W1) + +For the better part of a decade, I have been leading guilds in massively multiplayer role-playing games (MMORPGs). Currently, I lead a guild in [Guild Wars 2][1], and before that, I led progression raid teams in [World of Warcraft][2], while also maintaining a career as a software engineer. As I made the transition into software development, it became clear that the skills I gained in building successful raid groups translated well to building successful tech teams. + + +![Guild Wars 2 guild members after an event.][4] + +Guild Wars 2 guild members after an event. + +### Identify your problem + +The first step to building a successful team, whether in software or MMORPGs, is to recognize your problem. In video games, it's obvious: the monster. If you don't take it down, it will take you down. In tech, it's a product or service you want to deliver to solve your users' problems. In both situations, this is a problem you are unlikely to solve by yourself. You need a team. + +In MMORPGs, the goal is to create a "progression" raid team that improves over time for faster and smoother tackling of objectives together, allowing it to push its goals further and further. You will not reach the second objective in a raid without tackling the initial one first. + +In this article, I'll share how you can build, improve, and maintain your own progression software and/or systems teams. I'll cover assembling our team, leading the team, optimizing for success, continuously improving, and keeping morale high. + +### Assemble your team + +In MMORPGs, progression teams commonly have different levels of commitment, summed up into three tiers: hardcore, semi-hardcore, and casuals. These commitment levels translate to what players value in their raiding experience. + +You may have heard of the concept of "cultural fit" vs "value fit." One of the most important things in assembling your team is making sure everyone aligns with your concrete values and goals. Creating teams based on cultural fit is problematic because culture is hard to define. Matching new recruits based on their culture will also result in homogenous groups. + +Hardcore teams value dedication, mastery, and achievements. Semi-hardcore teams value efficiency, balance, and empathy. Casual teams balance fun above all else. If you put a casual player in a hardcore raid group, the casual player is probably going to tell the hardcore players they're taking things too seriously, while the hardcore players will tell the casual player they aren't taking things seriously enough (then remove them promptly). + +#### Values-driven team building + +A mismatch in values results in a negative experience for everyone. You need to build your team on a shared foundation of what is important, and each member should align with your team's values and goals. What is important to your team? What do you want your team's driving values to be? If you cannot easily answer those questions, take a moment right away and define them with your team. + +The values you define should influence which new members you recruit. In building raid teams, each potential member should be assessed not only on their skills but also their values. One of my previous employers had a "value fit" interview that a person must pass after their skills assessment to be considered for hiring. It doesn't matter if you're a "ninja" or a "rockstar" if you don't align with the company's values. + +#### Diversify your team + +When looking for new positions, I want a team that has a strong emphasis on delivering a quality product while understanding that work/life balance should be weighed more heavily on the life side ("life/work balance"). I steer away from companies with meager, two-week PTO policies, commitments over 40 hours, or rigid schedules. When interviews with companies show less emphasis on technical collaboration, I know there is a values mismatch. + +While values are important to share, the same skills, experience, and roles are not. Ten tanks might be able to get a boss down, eventually, but it is certainly more effective to have diversity. You need people who are skilled and trained in their specific roles to work together, with everyone focusing on what they do best. + +In MMORPGs, there are always considerably more people who want to play damage roles because they get all the glory. However, you're not going to down the boss without at least a tank and a healer. The tank and the healer mitigate the damage so that the damage classes can do what they do. We need to be respectful of the roles we each play and realize we're much better when we work together. There shouldn't be developers vs. operators when working together helps us deliver more effectively. + +Diversity in roles is important but so is diversity within roles. If you take 10 necromancers to a raid, you'll quickly find there are problems you can't solve with your current ability pool. You need to throw in some elementalists, thieves, and mesmers, too. It's the same with developers; if you everyone comes from the same background, abilities, and experience, you're going to face unnecessary challenges. + +It's better to take the inexperienced person who is willing to learn than the experienced person unwilling to take criticism. If a developer doesn't have hundreds of open source commits, it doesn't necessarily mean they are less skilled. Everyone has to learn somewhere. Senior developers and operators don't appear out of nowhere. Teams often only look for "experienced" people, spending more time with less manpower than if they had just trained an inexperienced recruit. + +Teams often only look for "experienced" people, spending more time with less manpower than if they had just trained an inexperienced recruit. + +Experience helps people pick things up faster, but no one starts out knowing exactly what to do, and you'd be surprised how seemingly unrelated skills translate well when applied to new experiences (like raid leadership!). **Hire and support junior technologists.** Keep in mind that a team comprised of a high percentage of inexperienced people will take considerably more time to achieve their objectives. It's important to find a good balance, weighed more heavily with experienced people available to mentor. + +Experience helps people pick things up faster, but no one starts out knowing exactly what to do, and you'd be surprised how seemingly unrelated skills translate well when applied to new experiences (like raid leadership!).Keep in mind that a team comprised of a high percentage of inexperienced people will take considerably more time to achieve their objectives. It's important to find a good balance, weighed more heavily with experienced people available to mentor. + +Every member of a team comes with strengths we need to utilize. In raids, we become obsessed with the "meta," which is a build for a class that is dubbed most efficient. We become so obsessed with what is "the best" that we forget about what "just works." In reality, forcing someone to dramatically change their playstyle because someone else determined this other playstyle to be slightly better will not be as efficient as just letting a player play what they have expertise in. + +Every member of a team comes with strengths we need to utilize. + +We get so excited about the latest and greatest in tech that we don't always think about the toll it takes. It's OK to choose "boring" technology and adopt new technologies as they become standard. What's "the best" is always changing, so focus on what's best for your team. Sometimes the best is what people are the most comfortable with. **Trust in your team's expertise rather than the tools.** + +### Take the lead + +We get so excited about the latest and greatest in tech that we don't always think about the toll it takes. It's OK to choose "boring" technology and adopt new technologies as they become standard. What's "the best" is always changing, so focus on what's best for your team. Sometimes the best is what people are the most comfortable with. + +You need a strong leader to lead a team and guide the overall direction, working for the team. Servant leadership is the idea that we serve our entire team and their individual needs before our own, and it is the leadership philosophy I have found most successful. Growth should be promoted at the contributor level to encourage growth at the macro level. As leaders, we want to work with each individual to identify their strengths and weaknesses. We want to keep morale high and keep everyone excited and focused so that they can succeed. + +Above all, a leader wants to keep the team working together. Sometimes this means resolving conflicts or holding meetings. Often this means breaking down communication barriers and improving team communication. + +![Guild Wars 2 raid team encountering Samarog.][6] + +Guild Wars 2 raid team encountering Samarog. + +#### Communicate effectively + +As companies move towards the remote/distributed model, optimizing communication and information access has become more critical than ever. How do you make sure everyone is on the same page? + +Above all, a leader wants to keep the team working together. + +During my World of Warcraft years, we used voice-over-IP software called Ventrilo. It was important for each team member to be able to hear my instructions, so whenever too many people started talking, someone would say "Clear Vent!" to silence the channel. You want the important information to be immediately accessible. In remote teams, this is usually achieved by a zero-noise "#announcements" channel in Slack where only need-to-know information is present. + +During my World of Warcraft years, we used voice-over-IP software called Ventrilo. It was important for each team member to be able to hear my instructions, so whenever too many people started talking, someone would say "Clear Vent!" to silence the channel. You want the important information to be immediately accessible. In remote teams, this is usually achieved by a zero-noise "#announcements" channel in Slack where only need-to-know information is present. + +A central knowledge base is also crucial. Guild Wars 2 has a /wiki command built into the game, which brings up a player-maintained wiki in the browser to look up information as needed without bothering other players. In most companies where I've worked, information is stored across various repositories, wikis, and documents, making it difficult and time-consuming to seek a source of truth. A central, searchable wiki, like Guild Wars 2 has, would relieve this issue. Treat knowledge sharing as an important component of your company! + +### Optimize for what works + +When you have your team assembled and are communicating effectively, you're prepared to take on your objectives. You need to think about it strategically, whether it's a monster or a system, breaking it down into steps and necessary roles. It's going to feel like you don't know what you're doing—but it's a starting point. The monster is going to die as long as you deplete its health pool, despite how messy the encounter may be at first. Your product can start making money with the minimum. Only once you have achieved the minimum can you move the goalpost. + +Your team learns what works and how to improve when they have the freedom to experiment. Trying something and failing is OK if it's a learning experience. It can even help identify overlooked weaknesses in your systems or processes. + +![Deaths during the Samarog encounter.][8] + +Deaths during the Samarog encounter. + +Your team learns what works and how to improve when they have the freedom to experiment. + +We live in the information age where there are various strategies at our disposal, but what works for others might not work for your team. While there is no one way to do anything, some ways are definitely better than others. Perform educated experiments based on the experience of others. Don't go in without a basic strategy unless absolutely necessary. + +We live in the information age where there are various strategies at our disposal, but what works for others might not work for your team. While there is no one way to do anything, some ways are definitely better than others. Perform educated experiments based on the experience of others. Don't go in without a basic strategy unless absolutely necessary. + +Your team needs to feel comfortable making mistakes. The only true failures are when nothing can be salvaged and nothing was learned. For your team to feel comfortable experimenting, you need to foster a culture where people are held accountable but not punished for their mistakes. When your team fears retaliation, they will be hesitant to try something unfamiliar. Worse, they might hide the mistakes they've made, and you'll find out too late to recover. + +Large-scale failures are rarely the result of one person. They are an accumulation of mistakes and oversights by different people combined with things largely outside the team's control. Tank healer went down? OK, another healer will cover. Someone is standing in a ring of fire. Your only remaining healer is overloaded, everything's on cooldown, and now your tank's block missed thanks to a random number generator outside her control. It's officially reached the point of failure, and the raid has wiped. + +Is it the tank healer's fault we wiped? It went down first and caused some stress on the other healer, sure. But there were enough people alive to keep going. It was a cumulation of everything. + +In systems, there are recovery protocols and hopefully automation around failures. Someone on-call will step in to provide coverage. Failures are more easily prevented when we become better aware of our systems. + +#### Measure success (or failures) with metrics + +How do you become more aware? Analysis of logs and metrics. Monitoring and observability. + +Logs, metrics, and analysis are as important in raids as they are around your systems and applications. After objectives, we review damage output, support uptime, time to completion, and failed mechanics. + +Your teams need to collect similar metrics. You need baseline metrics to compare and ensure progress has been made. In systems and applications, you care about speed, health, and overall output, too. Without being able to see these logs and metrics, you have limited measures of success. + +![Boon uptime stats][10] + +Boon uptime stats for my healer, Lullaby of Thix. + +### Continuously improve + +A team is a sum of its parts, with an ultimate goal of being coordinated at both the individual and group levels. You want people comfortable in their roles and who can make decisions in the best interest of the whole team; people who know how to step in when needed and seamlessly return to their original role after recovery. This is not easy, and many teams never reach this level of systemization. + +One of the ways we can improve coordination is to help people grow where they are struggling, whether by extending additional educational resources or working with them directly to strengthen their skills. Simply telling someone to "get good" (a phrase rampant in gaming culture) is not going to help. Constructive feedback with working points and pairing will, though. + +Keep in mind that you're measuring progress properly. You can't compare a healer's damage output to that of a dedicated damage class. Recognize that just because someone's performance looks different than another's, it could be that they are taking on roles that others are neglecting, like reviewing code or harder-than-average tickets. + +If one person isn't carrying their weight and the team notices, you have to address it. Start positively, give them a chance to improve: resources, assistance, or whatever they need (within reason). If they still show no interest in improvement, it's time to let them go to keep your team happy and running smoothly. + +### Maintain happiness + +Happiness is important for team longevity. After the honeymoon phase is over, what makes them stay? + +#### Safety + +One of the core, foundational needs of maintaining happiness is maintaining safety. **People stay where they feel safe.** + +Happiness is important for team longevity. + +In a game, it's easy to hide your identity and try to blend in with the perceived status quo. When people are accepted for who they are, they are comfortable enough to stay. And because they stay, a diverse community is built. + +In a game, it's easy to hide your identity and try to blend in with the perceived status quo. When people are accepted for who they are, they are comfortable enough to stay. And because they stay, a diverse community is built. + +One way to create this sense of safety is to use a Code of Conduct (CoC) that, as explicitly as possible, maps out boundaries and the consequences of violating them. It serves as a definitive guide to acceptable behavior and lets people have minimal doubts as to what is and is not allowed. While having a CoC is a good start, **it is meaningless if it is not actively enforced.** + +I've had to cite CoC violations to remove gaming members from our community a few times. Thankfully this doesn't happen very often, because we review our values and CoC as part of the interview process. I have turned people away because they weren't sure they could commit to it. Your values and CoC serve as a filter in your recruiting process, preventing some potential conflicts. + +#### Inclusion + +Once people feel safe, they want to feel included and a sense of belonging. In raids, people who are constantly considered substitutes are going to find a different team where they are appreciated. If hero worship is rampant in your team's culture, you will have a difficult time fostering inclusion. No one likes feeling like they are constantly in the shadows. Everyone has something to bring to the table when given the chance. + +#### Reputation management + +Maintaining team happiness also means maintaining the team's reputation. Having toxic members representing you damages your reputation. + +In Guild Wars 2, a few members belonging to the same guild wanted the achievements and rewards that come from winning a player vs. player (PvP) tournament, so they purchased a tournament win—essentially, skilled PvP players played as them and won the tournament. ArenaNet, the maker of Guild Wars 2, found out and reprimanded them. The greater community found out and lost respect for the entire guild, despite only a tiny percent of the guild being the offenders. You don't want people to lose faith in your team because of bad actors. + +Everyone has something to bring to the table when given the chance. + +Having a positive impact on the greater community also carries a positive impact on your image. In games, we do this by hosting events, helping newcomers, and just being friendly in our interactions with people outside our guilds. In business, maybe you do this by sponsoring things you agree with or open sourcing your core software products. + +Having a positive impact on the greater community also carries a positive impact on your image. In games, we do this by hosting events, helping newcomers, and just being friendly in our interactions with people outside our guilds. In business, maybe you do this by sponsoring things you agree with or open sourcing your core software products. + +If you have a good reputation, earned by both how you treat your members and how you treat your community, recruiting new talent and retaining the talent you have will be much easier. + +Recruiting and retraining take significantly more effort than letting people just relax from time to time. If your team members burn out, they are going to leave. When you're constantly retraining new people, you have more and more opportunities for mistakes. New people to your team generally lack knowledge about the deep internals of your system or product. **High turnover leads to high failure.** + +#### Avoid burnout + +Burnout happens in gaming, too. Everyone needs a break. Time off is good for everyone! You need to balance your team's goals and health. While we may feel like cogs in a machine, we are not machines. Sprint after sprint is really just a full-speed marathon. + +#### Celebrate wins + +Relieve some pressure by celebrating your team's success. This stuff is hard! Recognize and reward your teams. Were you working on a monster encounter for weeks and finally got it down? Have a /dance party! Finally tackled a bug that plagued you for months? Send everyone a cupcake! + +![Guild Wars 2 dance party][12] + +A dance party after a successful Keep Construct encounter in Guild Wars 2. + +### Always evolve + +To thrive as a team, you need to evolve with your market, your company, and your community. Change is inevitable. Embrace it. Grow. I truly believe that the worst thing you can say is, "We've always done it this way, and we're not going to change." + +Building, maintaining, and growing a heroic team is an arduous process that needs constant evolution, but the benefits are infinite. + +Aly Fulton will present [It's Dangerous to Go Alone: Leveling Up a Heroic Team][13] at [LISA18][14], October 29-31 in Nashville, Tenn. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/10/what-mmorpgs-can-teach-us + +作者:[Aly Fulton][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/sinthetix +[b]: https://github.com/lujun9972 +[1]: https://www.guildwars2.com/ +[2]: https://worldofwarcraft.com/ +[3]: /file/412396 +[4]: https://opensource.com/sites/default/files/uploads/lime_southsun_cove.png (Guild Wars 2 guild members after an event.) +[5]: /file/412401 +[6]: https://opensource.com/sites/default/files/uploads/lime_samarog_readycheck.png (Guild Wars 2 raid team encountering Samarog.) +[7]: /file/412406 +[8]: https://opensource.com/sites/default/files/uploads/lime_samarog_deaths.png (Deaths during the Samarog encounter.) +[9]: /file/412411 +[10]: https://opensource.com/sites/default/files/uploads/boon_uptime.png (Boon uptime stats) +[11]: /file/412416 +[12]: https://opensource.com/sites/default/files/uploads/lime_keep_construct_trophy_dance_party.png (Guild Wars 2 dance party) +[13]: https://www.usenix.org/conference/lisa18/presentation/fulton +[14]: https://www.usenix.org/conference/lisa18 From 46e05e0e2a8fdcd7a9051e48cc7a2b45bfe01065 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 24 Oct 2018 11:32:13 +0800 Subject: [PATCH 140/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20How=20Lisp=20Beca?= =?UTF-8?q?me=20God's=20Own=20Programming=20Language?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...p Became God-s Own Programming Language.md | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 sources/talk/20181014 How Lisp Became God-s Own Programming Language.md diff --git a/sources/talk/20181014 How Lisp Became God-s Own Programming Language.md b/sources/talk/20181014 How Lisp Became God-s Own Programming Language.md new file mode 100644 index 0000000000..c02447a637 --- /dev/null +++ b/sources/talk/20181014 How Lisp Became God-s Own Programming Language.md @@ -0,0 +1,126 @@ +How Lisp Became God's Own Programming Language +====== +When programmers discuss the relative merits of different programming languages, they often talk about them in prosaic terms as if they were so many tools in a tool belt—one might be more appropriate for systems programming, another might be more appropriate for gluing together other programs to accomplish some ad hoc task. This is as it should be. Languages have different strengths and claiming that a language is better than other languages without reference to a specific use case only invites an unproductive and vitriolic debate. + +But there is one language that seems to inspire a peculiar universal reverence: Lisp. Keyboard crusaders that would otherwise pounce on anyone daring to suggest that some language is better than any other will concede that Lisp is on another level. Lisp transcends the utilitarian criteria used to judge other languages, because the median programmer has never used Lisp to build anything practical and probably never will, yet the reverence for Lisp runs so deep that Lisp is often ascribed mystical properties. Everyone’s favorite webcomic, xkcd, has depicted Lisp this way at least twice: In [one comic][1], a character reaches some sort of Lisp enlightenment, which appears to allow him to comprehend the fundamental structure of the universe. In [another comic][2], a robed, senescent programmer hands a stack of parentheses to his padawan, saying that the parentheses are “elegant weapons for a more civilized age,” suggesting that Lisp has all the occult power of the Force. + +Another great example is Bob Kanefsky’s parody of a song called “God Lives on Terra.” His parody, written in the mid-1990s and called “Eternal Flame”, describes how God must have created the world using Lisp. The following is an excerpt, but the full set of lyrics can be found in the [GNU Humor Collection][3]: + +> For God wrote in Lisp code +> When he filled the leaves with green. +> The fractal flowers and recursive roots: +> The most lovely hack I’ve seen. +> And when I ponder snowflakes, +> never finding two the same, +> I know God likes a language +> with its own four-letter name. + +I can only speak for myself, I suppose, but I think this “Lisp Is Arcane Magic” cultural meme is the most bizarre and fascinating thing ever. Lisp was concocted in the ivory tower as a tool for artificial intelligence research, so it was always going to be unfamiliar and maybe even a bit mysterious to the programming laity. But programmers now [urge each other to “try Lisp before you die”][4] as if it were some kind of mind-expanding psychedelic. They do this even though Lisp is now the second-oldest programming language in widespread use, younger only than Fortran, and even then by just one year. Imagine if your job were to promote some new programming language on behalf of the organization or team that created it. Wouldn’t it be great if you could convince everyone that your new language had divine powers? But how would you even do that? How does a programming language come to be known as a font of hidden knowledge? + +How did Lisp get to be this way? + +![Byte Magazine Cover, August, 1979.][5] +The cover of Byte Magazine, August, 1979. + +### Theory A: The Axiomatic Language + +John McCarthy, Lisp’s creator, did not originally intend for Lisp to be an elegant distillation of the principles of computation. But, after one or two fortunate insights and a series of refinements, that’s what Lisp became. Paul Graham—we will talk about him some more later—has written that, with Lisp, McCarthy “did for programming something like what Euclid did for geometry.” People might see a deeper meaning in Lisp because McCarthy built Lisp out of parts so fundamental that it is hard to say whether he invented it or discovered it. + +McCarthy began thinking about creating a language during the 1956 Darthmouth Summer Research Project on Artificial Intelligence. The Summer Research Project was in effect an ongoing, multi-week academic conference, the very first in the field of artificial intelligence. McCarthy, then an assistant professor of Mathematics at Dartmouth, had actually coined the term “artificial intelligence” when he proposed the event. About ten or so people attended the conference for its entire duration. Among them were Allen Newell and Herbert Simon, two researchers affiliated with the RAND Corporation and Carnegie Mellon that had just designed a language called IPL. + +Newell and Simon had been trying to build a system capable of generating proofs in propositional calculus. They realized that it would be hard to do this while working at the level of the computer’s native instruction set, so they decided to create a language—or, as they called it, a “pseudo-code”—that would help them more naturally express the workings of their “Logic Theory Machine.” Their language, called IPL for “Information Processing Language”, was more of a high-level assembly dialect then a programming language in the sense we mean today. Newell and Simon, perhaps referring to Fortran, noted that other “pseudo-codes” then in development were “preoccupied” with representing equations in standard mathematical notation. Their language focused instead on representing sentences in propositional calculus as lists of symbolic expressions. Programs in IPL would basically leverage a series of assembly-language macros to manipulate and evaluate expressions within one or more of these lists. + +McCarthy thought that having algebraic expressions in a language, Fortran-style, would be useful. So he didn’t like IPL very much. But he thought that symbolic lists were a good way to model problems in artificial intelligence, particularly problems involving deduction. This was the germ of McCarthy’s desire to create an algebraic list processing language, a language that would resemble Fortran but also be able to process symbolic lists like IPL. + +Of course, Lisp today does not resemble Fortran. Over the next few years, McCarthy’s ideas about what an ideal list processing language should look like evolved. His ideas began to change in 1957, when he started writing routines for a chess-playing program in Fortran. The prolonged exposure to Fortran convinced McCarthy that there were several infelicities in its design, chief among them the awkward `IF` statement. McCarthy invented an alternative, the “true” conditional expression, which returns sub-expression A if the supplied test succeeds and sub-expression B if the supplied test fails and which also only evaluates the sub-expression that actually gets returned. During the summer of 1958, when McCarthy worked to design a program that could perform differentiation, he realized that his “true” conditional expression made writing recursive functions easier and more natural. The differentiation problem also prompted McCarthy to devise the maplist function, which takes another function as an argument and applies it to all the elements in a list. This was useful for differentiating sums of arbitrarily many terms. + +None of these things could be expressed in Fortran, so, in the fall of 1958, McCarthy set some students to work implementing Lisp. Since McCarthy was now an assistant professor at MIT, these were all MIT students. As McCarthy and his students translated his ideas into running code, they made changes that further simplified the language. The biggest change involved Lisp’s syntax. McCarthy had originally intended for the language to include something called “M-expressions,” which would be a layer of syntactic sugar that made Lisp’s syntax resemble Fortran’s. Though M-expressions could be translated to S-expressions—the basic lists enclosed by parentheses that Lisp is known for— S-expressions were really a low-level representation meant for the machine. The only problem was that McCarthy had been denoting M-expressions using square brackets, and the IBM 026 keypunch that McCarthy’s team used at MIT did not have any square bracket keys on its keyboard. So the Lisp team stuck with S-expressions, using them to represent not just lists of data but function applications too. McCarthy and his students also made a few other simplifications, including a switch to prefix notation and a memory model change that meant the language only had one real type. + +In 1960, McCarthy published his famous paper on Lisp called “Recursive Functions of Symbolic Expressions and Their Computation by Machine.” By that time, the language had been pared down to such a degree that McCarthy realized he had the makings of “an elegant mathematical system” and not just another programming language. He later wrote that the many simplifications that had been made to Lisp turned it “into a way of describing computable functions much neater than the Turing machines or the general recursive definitions used in recursive function theory.” In his paper, he therefore presented Lisp both as a working programming language and as a formalism for studying the behavior of recursive functions. + +McCarthy explained Lisp to his readers by building it up out of only a very small collection of rules. Paul Graham later retraced McCarthy’s steps, using more readable language, in his essay [“The Roots of Lisp”][6]. Graham is able to explain Lisp using only seven primitive operators, two different notations for functions, and a half-dozen higher-level functions defined in terms of the primitive operators. That Lisp can be specified by such a small sequence of basic rules no doubt contributes to its mystique. Graham has called McCarthy’s paper an attempt to “axiomatize computation.” I think that is a great way to think about Lisp’s appeal. Whereas other languages have clearly artificial constructs denoted by reserved words like `while` or `typedef` or `public static void`, Lisp’s design almost seems entailed by the very logic of computing. This quality and Lisp’s original connection to a field as esoteric as “recursive function theory” should make it no surprise that Lisp has so much prestige today. + +### Theory B: Machine of the Future + +Two decades after its creation, Lisp had become, according to the famous [Hacker’s Dictionary][7], the “mother tongue” of artificial intelligence research. Early on, Lisp spread quickly, probably because its regular syntax made implementing it on new machines relatively straightforward. Later, researchers would keep using it because of how well it handled symbolic expressions, important in an era when so much of artificial intelligence was symbolic. Lisp was used in seminal artificial intelligence projects like the [SHRDLU natural language program][8], the [Macsyma algebra system][9], and the [ACL2 logic system][10]. + +By the mid-1970s, though, artificial intelligence researchers were running out of computer power. The PDP-10, in particular—everyone’s favorite machine for artificial intelligence work—had an 18-bit address space that increasingly was insufficient for Lisp AI programs. Many AI programs were also supposed to be interactive, and making a demanding interactive program perform well on a time-sharing system was challenging. The solution, originally proposed by Peter Deutsch at MIT, was to engineer a computer specifically designed to run Lisp programs. These Lisp machines, as I described in [my last post on Chaosnet][11], would give each user a dedicated processor optimized for Lisp. They would also eventually come with development environments written entirely in Lisp for hardcore Lisp programmers. Lisp machines, devised in an awkward moment at the tail of the minicomputer era but before the full flowering of the microcomputer revolution, were high-performance personal computers for the programming elite. + +For a while, it seemed as if Lisp machines would be the wave of the future. Several companies sprang into existence and raced to commercialize the technology. The most successful of these companies was called Symbolics, founded by veterans of the MIT AI Lab. Throughout the 1980s, Symbolics produced a line of computers known as the 3600 series, which were popular in the AI field and in industries requiring high-powered computing. The 3600 series computers featured large screens, bit-mapped graphics, a mouse interface, and [powerful graphics and animation software][12]. These were impressive machines that enabled impressive programs. For example, Bob Culley, who worked in robotics research and contacted me via Twitter, was able to implement and visualize a path-finding algorithm on a Symbolics 3650 in 1985. He explained to me that bit-mapped graphics and object-oriented programming (available on Lisp machines via [the Flavors extension][13]) were very new in the 1980s. Symbolics was the cutting edge. + +![Bob Culley's path-finding program.][14] Bob Culley’s path-finding program. + +As a result, Symbolics machines were outrageously expensive. The Symbolics 3600 cost $110,000 in 1983. So most people could only marvel at the power of Lisp machines and the wizardry of their Lisp-writing operators from afar. But marvel they did. Byte Magazine featured Lisp and Lisp machines several times from 1979 through to the end of the 1980s. In the August, 1979 issue, a special on Lisp, the magazine’s editor raved about the new machines being developed at MIT with “gobs of memory” and “an advanced operating system.” He thought they sounded so promising that they would make the two prior years—which saw the launch of the Apple II, the Commodore PET, and the TRS-80—look boring by comparison. A half decade later, in 1985, a Byte Magazine contributor described writing Lisp programs for the “sophisticated, superpowerful Symbolics 3670” and urged his audience to learn Lisp, claiming it was both “the language of choice for most people working in AI” and soon to be a general-purpose programming language as well. + +I asked Paul McJones, who has done lots of Lisp [preservation work][15] for the Computer History Museum in Mountain View, about when people first began talking about Lisp as if it were a gift from higher-dimensional beings. He said that the inherent properties of the language no doubt had a lot to do with it, but he also said that the close association between Lisp and the powerful artificial intelligence applications of the 1960s and 1970s probably contributed too. When Lisp machines became available for purchase in the 1980s, a few more people outside of places like MIT and Stanford were exposed to Lisp’s power and the legend grew. Today, Lisp machines and Symbolics are little remembered, but they helped keep the mystique of Lisp alive through to the late 1980s. + +### Theory C: Learn to Program + +In 1985, MIT professors Harold Abelson and Gerald Sussman, along with Sussman’s wife, Julie Sussman, published a textbook called Structure and Interpretation of Computer Programs. The textbook introduced readers to programming using the language Scheme, a dialect of Lisp. It was used to teach MIT’s introductory programming class for two decades. My hunch is that SICP (as the title is commonly abbreviated) about doubled Lisp’s “mystique factor.” SICP took Lisp and showed how it could be used to illustrate deep, almost philosophical concepts in the art of computer programming. Those concepts were general enough that any language could have been used, but SICP’s authors chose Lisp. As a result, Lisp’s reputation was augmented by the notoriety of this bizarre and brilliant book, which has intrigued generations of programmers (and also become [a very strange meme][16]). Lisp had always been “McCarthy’s elegant formalism”; now it was also “that language that teaches you the hidden secrets of programming.” + +It’s worth dwelling for a while on how weird SICP really is, because I think the book’s weirdness and Lisp’s weirdness get conflated today. The weirdness starts with the book’s cover. It depicts a wizard or alchemist approaching a table, prepared to perform some sort of sorcery. In one hand he holds a set of calipers or a compass, in the other he holds a globe inscribed with the words “eval” and “apply.” A woman opposite him gestures at the table; in the background, the Greek letter lambda floats in mid-air, radiating light. + +![The cover art for SICP.][17] The cover art for SICP. + +Honestly, what is going on here? Why does the table have animal feet? Why is the woman gesturing at the table? What is the significance of the inkwell? Are we supposed to conclude that the wizard has unlocked the hidden mysteries of the universe, and that those mysteries consist of the “eval/apply” loop and the Lambda Calculus? It would seem so. This image alone must have done an enormous amount to shape how people talk about Lisp today. + +But the text of the book itself is often just as weird. SICP is unlike most other computer science textbooks that you have ever read. Its authors explain in the foreword to the book that the book is not merely about how to program in Lisp—it is instead about “three foci of phenomena: the human mind, collections of computer programs, and the computer.” Later, they elaborate, describing their conviction that programming shouldn’t be considered a discipline of computer science but instead should be considered a new notation for “procedural epistemology.” Programs are a new way of structuring thought that only incidentally get fed into computers. The first chapter of the book gives a brief tour of Lisp, but most of the book after that point is about much more abstract concepts. There is a discussion of different programming paradigms, a discussion of the nature of “time” and “identity” in object-oriented systems, and at one point a discussion of how synchronization problems may arise because of fundamental constraints on communication that play a role akin to the fixed speed of light in the theory of relativity. It’s heady stuff. + +All this isn’t to say that the book is bad. It’s a wonderful book. It discusses important programming concepts at a higher level than anything else I have read, concepts that I had long wondered about but didn’t quite have the language to describe. It’s impressive that an introductory programming textbook can move so quickly to describing the fundamental shortfalls of object-oriented programming and the benefits of functional languages that minimize mutable state. It’s mind-blowing that this then turns into a discussion of how a stream paradigm, perhaps something like today’s [RxJS][18], can give you the best of both worlds. SICP distills the essence of high-level program design in a way reminiscent of McCarthy’s original Lisp paper. The first thing you want to do after reading it is get your programmer friends to read it; if they look it up, see the cover, but then don’t read it, all they take away is that some mysterious, fundamental “eval/apply” thing gives magicians special powers over tables with animal feet. I would be deeply impressed in their shoes too. + +But maybe SICP’s most important contribution was to elevate Lisp from curious oddity to pedagogical must-have. Well before SICP, people told each other to learn Lisp as a way of getting better at programming. The 1979 Lisp issue of Byte Magazine is testament to that fact. The same editor that raved about MIT’s new Lisp machines also explained that the language was worth learning because it “represents a different point of view from which to analyze problems.” But SICP presented Lisp as more than just a foil for other languages; SICP used Lisp as an introductory language, implicitly making the argument that Lisp is the best language in which to grasp the fundamentals of computer programming. When programmers today tell each other to try Lisp before they die, they arguably do so in large part because of SICP. After all, the language [Brainfuck][19] presumably offers “a different point of view from which to analyze problems.” But people learn Lisp instead because they know that, for twenty years or so, the Lisp point of view was thought to be so useful that MIT taught Lisp to undergraduates before anything else. + +### Lisp Comes Back + +The same year that SICP was released, Bjarne Stroustrup published the first edition of The C++ Programming Language, which brought object-oriented programming to the masses. A few years later, the market for Lisp machines collapsed and the AI winter began. For the next decade and change, C++ and then Java would be the languages of the future and Lisp would be left out in the cold. + +It is of course impossible to pinpoint when people started getting excited about Lisp again. But that may have happened after Paul Graham, Y-Combinator co-founder and Hacker News creator, published a series of influential essays pushing Lisp as the best language for startups. In his essay [“Beating the Averages,”][20] for example, Graham argued that Lisp macros simply made Lisp more powerful than other languages. He claimed that using Lisp at his own startup, Viaweb, helped him develop features faster than his competitors were able to. [Some programmers at least][21] were persuaded. But the vast majority of programmers did not switch to Lisp. + +What happened instead is that more and more Lisp-y features have been incorporated into everyone’s favorite programming languages. Python got list comprehensions. C# got Linq. Ruby got… well, Ruby [is a Lisp][22]. As Graham noted even back in 2001, “the default language, embodied in a succession of popular languages, has gradually evolved toward Lisp.” Though other languages are gradually becoming like Lisp, Lisp itself somehow manages to retain its special reputation as that mysterious language that few people understand but everybody should learn. In 1980, on the occasion of Lisp’s 20th anniversary, McCarthy wrote that Lisp had survived as long as it had because it occupied “some kind of approximate local optimum in the space of programming languages.” That understates Lisp’s real influence. Lisp hasn’t survived for over half a century because programmers have begrudgingly conceded that it is the best tool for the job decade after decade; in fact, it has survived even though most programmers do not use it at all. Thanks to its origins and use in artificial intelligence research and perhaps also the legacy of SICP, Lisp continues to fascinate people. Until we can imagine God creating the world with some newer language, Lisp isn’t going anywhere. + +If you enjoyed this post, more like it come out every two weeks! Follow [@TwoBitHistory][23] on Twitter or subscribe to the [RSS feed][24] to make sure you know when a new post is out. + +Previously on TwoBitHistory… + +> This week's post: A look at Chaosnet, the network that gave us the "CH" DNS class. +> +> — TwoBitHistory (@TwoBitHistory) [September 30, 2018][25] + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2018/10/14/lisp.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://xkcd.com/224/ +[2]: https://xkcd.com/297/ +[3]: https://www.gnu.org/fun/jokes/eternal-flame.en.html +[4]: https://www.reddit.com/r/ProgrammerHumor/comments/5c14o6/xkcd_lisp/d9szjnc/ +[5]: https://twobithistory.org/images/byte_lisp.jpg +[6]: http://languagelog.ldc.upenn.edu/myl/llog/jmc.pdf +[7]: https://en.wikipedia.org/wiki/Jargon_File +[8]: https://hci.stanford.edu/winograd/shrdlu/ +[9]: https://en.wikipedia.org/wiki/Macsyma +[10]: https://en.wikipedia.org/wiki/ACL2 +[11]: https://twobithistory.org/2018/09/30/chaosnet.html +[12]: https://youtu.be/gV5obrYaogU?t=201 +[13]: https://en.wikipedia.org/wiki/Flavors_(programming_language) +[14]: https://twobithistory.org/images/symbolics.jpg +[15]: http://www.softwarepreservation.org/projects/LISP/ +[16]: https://knowyourmeme.com/forums/meme-research/topics/47038-structure-and-interpretation-of-computer-programs-hugeass-image-dump-for-evidence +[17]: https://twobithistory.org/images/sicp.jpg +[18]: https://rxjs-dev.firebaseapp.com/ +[19]: https://en.wikipedia.org/wiki/Brainfuck +[20]: http://www.paulgraham.com/avg.html +[21]: https://web.archive.org/web/20061004035628/http://wiki.alu.org/Chris-Perkins +[22]: http://www.randomhacks.net/2005/12/03/why-ruby-is-an-acceptable-lisp/ +[23]: https://twitter.com/TwoBitHistory +[24]: https://twobithistory.org/feed.xml +[25]: https://twitter.com/TwoBitHistory/status/1046437600658169856?ref_src=twsrc%5Etfw From 8b9a62d2a4fb8ecc231036af4ddfd357e8ce489f Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 24 Oct 2018 11:34:41 +0800 Subject: [PATCH 141/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20A=20Short=20Histo?= =?UTF-8?q?ry=20of=20Chaosnet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180930 A Short History of Chaosnet.md | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 sources/tech/20180930 A Short History of Chaosnet.md diff --git a/sources/tech/20180930 A Short History of Chaosnet.md b/sources/tech/20180930 A Short History of Chaosnet.md new file mode 100644 index 0000000000..acbb10d53d --- /dev/null +++ b/sources/tech/20180930 A Short History of Chaosnet.md @@ -0,0 +1,118 @@ +A Short History of Chaosnet +====== +If you fire up `dig` and run a DNS query for `google.com`, you will get a response somewhat like the following: + +``` +$ dig google.com + +; <<>> DiG 9.10.6 <<>> google.com +;; global options: +cmd +;; Got answer: +;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 27120 +;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 + +;; OPT PSEUDOSECTION: +; EDNS: version: 0, flags:; udp: 512 +;; QUESTION SECTION: +;google.com. IN A + +;; ANSWER SECTION: +google.com. 194 IN A 216.58.192.206 + +;; Query time: 23 msec +;; SERVER: 8.8.8.8#53(8.8.8.8) +;; WHEN: Fri Sep 21 16:14:48 CDT 2018 +;; MSG SIZE rcvd: 55 +``` + +The output contains both a section describing the “question” you asked (“What is the IP address of `google.com`?”) and a section describing the answer you received. In the answer section, we see that `dig` found a single record with what looks to be five fields. The record’s type is indicated by the `A` in the fourth field from the left—this is an “address” record. To the right of the `A`, in the fifth field, we can see that the IP address for `google.com` is `216.58.192.206`. The `194` value in the second field specifies how long in seconds this particular record can be cached. + +What does the `IN` field tell us? For an embarrassingly long time, I thought `IN` functioned as a preposition, so that every DNS record was saying something like “`google.com` is in `A` and has IP address `216.58.192.206`.” It turns out that `IN` actually stands for “internet.” The `IN` part of a DNS record tells us the record’s class. + +Why might a DNS record have a class other than “internet”? What would that even mean? How do you search for a host that isn’t on the internet? It would seem that `IN` is the only value that could possibly make sense here. Indeed, when you try to ask for the address of `google.com` while specifying that you expect a record with a class other than `IN`, the DNS server you are asking will probably complain. In the below, when we try to ask for the IP address of `google.com` using the `HS` class, the name server at `8.8.8.8` (Google Public DNS) returns a status of `SERVFAIL`: + +``` +$ dig -c HS google.com + +; <<>> DiG 9.10.6 <<>> -c HS google.com +;; global options: +cmd +;; Got answer: +;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 31517 +;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1 + +;; OPT PSEUDOSECTION: +; EDNS: version: 0, flags:; udp: 512 +;; QUESTION SECTION: +;google.com. HS A + +;; Query time: 34 msec +;; SERVER: 8.8.8.8#53(8.8.8.8) +;; WHEN: Tue Sep 25 14:48:10 CDT 2018 +;; MSG SIZE rcvd: 39 +``` + +So classes other than `IN` aren’t widely supported. But they do exist. In addition to `IN`, DNS records can have the `HS` class (as we’ve just seen) or the `CH` class. The `HS` class is reserved for use by a system called [Hesiod][1] that stores and distributes simple textual data using the Domain Name System. It is typically used in local environments as a stand-in for [LDAP][2]. The `CH` class is reserved for something called Chaosnet. + +Today, the world belongs to TCP/IP. Those two protocols (together with UDP) govern most of the remote communication that happens between computers. But I think it’s wonderful that you can still find, hidden in the plumbing of the internet, traces of this other, long-extinct, evocatively named system. What was Chaosnet? And why did it go the way of the dinosaurs? + +### A Machine Room at MIT + +Chaosnet was developed in the 1970s by researchers at the MIT Artificial Intelligence Lab. It was created as a part of a larger effort to design and build a machine that could run the Lisp programming language more efficiently than a general-purpose computer. + +Lisp was the brainchild of MIT professor John McCarthy, who pioneered the field of artificial intelligence. He first described Lisp to the world in [a paper][3] published in 1960. By 1962, an interpreter and a compiler had been written. Lisp introduced an astounding number of features that today we consider standard for many programming languages. It was the first language to have a garbage collector. It was the first to have a REPL. And it was the first to support dynamic typing. It found favor among programmers working in artificial intelligence and—to name just one example—was used to develop the famous [SHRDLU][4] demonstration, which allowed a human to dictate simple actions involving toy blocks to a computer in natural language. + +The problem with Lisp was that it could be slow. Simple operations could take twice as long to execute as was typical with other languages because Lisp variables were type-checked at runtime and not just during compilation. Lisp’s garbage collector was known to take up to an entire second to run on the IBM 7090 at MIT. These performance issues were especially unwelcome because the AI researchers using Lisp were trying to build applications like SHRDLU that interacted with users in real time. In the late 1970s, a group of MIT Artificial Intelligence Lab researchers decided to address these problems by building machines specifically designed to run Lisp programs. These “Lisp machines” had more memory and a compact instruction set better-suited to Lisp. Type-checking would be done by dedicated circuitry, speeding it up by orders of magnitude. And unlike most computer systems at the time, Lisp machines would not be time-shared, since ambitious Lisp programs needed all the resources a computer had available. Each user would be assigned his or her own CPU. In a memo, the Lisp Machine Group at MIT described how this would make Lisp programming significantly easier: + +> The Lisp Machine is a personal computer. Personal computing means that the processor and main memory are not time-division multiplexed, instead each person gets his own. The personal computation system consists of a pool of processors, each with its own main memory, and its own disk for swapping. When a user logs in, he is assigned a processor, and he has exclusive use of it for the duration of the session. When he logs out, the processor is returned to the pool, for the next person to use. This way, there is no competition from other users for memory; the pages the user is frequently referring to remain in core, and so swapping overhead is considerably reduced. Thus the Lisp Machine solves a basic problem of the time-sharing Lisp system. + +The Lisp machine would be a personal computer in a different sense than the one we think of today. As the Lisp Machine Group originally envisioned it, users would sit down in their offices not in front of their own Lisp machines but in front of terminals. The terminals would be connected to the actual Lisp machine, which would be elsewhere. Even though each user would be assigned his or her own processor, the processors would still be “kept off in a machine room,” since they would make noise and take up space and thus be “unwelcome office companions.” The processors would share access to a file system and to devices like printers via a high-speed local network “with completely distributed control.” That network was Chaosnet. + +Chaosnet is both a hardware standard and a software protocol. The hardware standard resembles Ethernet, and in fact the Chaosnet software protocol was eventually run over Ethernet. The software protocol, which specifies both network-layer and transport-layer interactions, was, unlike TCP/IP, always meant to govern a local network. In another memo released by the MIT Artificial Intelligence Lab, David Moon, a member of the Lisp Machine Group, explained that Chaosnet “contains no special provisions for things such as low-speed links, noisy links, multiple paths, and long-distance links with significant transit time.” The focus was instead on designing a protocol that could outperform other protocols on a small network. + +Speed was important because Chaosnet sat between each Lisp processor and the file system. Network delays would significantly slow rudimentary operations like viewing the contents of a text document. To be fast enough, Chaosnet incorporated several improvements over the Network Control Program then in use on Arpanet. According to Moon, “it was important to design out bottlenecks such as are found in Arpanet, for instance the control-link which is shared between multiple connections and the need to acknowledge each message before the next message is sent.” The Chaosnet protocol batches packet acknowledgments in much the same way that TCP does today and so reduced the number of packets that needed to be transmitted by a half to a third. + +Chaosnet could also get away with a relatively simple routing algorithm, since most hosts on the Lisp machine network were probably connected by a single, short wire. Moon wrote that the Chaosnet routing scheme “is predicated on the assumption that the network geometry is simple, there are few multiple paths, and the length of any path is quite short. This makes more sophisticated schemes unnecessary.” The simplicity of the algorithm meant that implementing the Chaosnet protocol was easy. The implementation program was supposedly half the size of the Arpanet Network Control Program. + +The Chaosnet protocol has other idiosyncrasies. A Chaosnet address is only 16 bits, half the size of an IPv4 address, which makes sense given that Chaosnet was only ever meant to work on a local network. Chaosnet also doesn’t use port numbers; instead, a process that wants to connect to another process on a different machine first makes a connection request that specifies a target “contact name.” That contact name is often just the name of a particular service. For example, one host may try to connect to another host using the contact name `TELNET`. In practice, I assume this works more or less just like TCP, since something well-known like port 80 might as well have the contact name `HTTP`. + +The Chaosnet DNS class was added to the Domain Name System by [RFC 973][5] in 1986. It replaced another class that had been available early on, the `CSNET` class, which was there to support a network called the Computer Science Network. I haven’t been able to figure out why Chaosnet was picked out for special treatment by the Domain Name System. There were other protocol families that could have been added but never were. For example, Paul Mockapetris, one of the principal architects of the Domain Name System, has written that he originally imagined that DNS would include a class for Xerox’s network protocol. That never happened. Chaosnet may have been added just because so much of the early work on Arpanet and the internet happened at Bolt, Beranek and Newman in Cambridge, Massachusetts, whose employees were often connected in some way with MIT. Chaosnet was probably well-known among the then relatively small group of people working on computer networks. + +Usage of Chaosnet presumably waned as Lisp machines became less and less popular. Though Lisp machines were for a short time commercially viable products—sold by companies such as Symbolics and Lisp Machines Inc. during the 1980s—they were soon displaced by cheaper microcomputers that could run Lisp just as quickly without special-purpose circuitry. TCP/IP also fixed many of the issues with the original Arpanet protocols that Chaosnet had been created to circumvent. + +### Ghost in the Shell + +There unfortunately isn’t a huge amount of information still around about Chaosnet. RFC 675, which was essentially the first draft of TCP/IP, was published in 1974. Chaosnet was first developed in 1975. TCP/IP eventually conquered the world, but Chaosnet seems to have been a technological dead end. Though it’s possible that Chaosnet influenced subsequent work on TCP/IP, I haven’t found any specific examples of that happening. + +The only really visible remnant of Chaosnet is the `CH` DNS class. There’s something about that fact that I find strangely fascinating. The `CH` class is a vestigial ghost of an alternative network protocol in a world that has long since settled on TCP/IP. It’s exciting, at least to me, to know that the last traces of Chaosnet still lurk out there in the infrastructure of our networked society. The `CH` DNS class is a fun artifact of digital archaeology. But it’s also a living reminder that the internet was not born fully formed, that TCP/IP is not the only way to connect computers to each other, and that “the internet” is far from the coolest name we could have had for our global communication system. + +If you enjoyed this post, more like it come out every two weeks! Follow [@TwoBitHistory][6] on Twitter or subscribe to the [RSS feed][7] to make sure you know when a new post is out. + +Previously on TwoBitHistory… + +> Where did RSS come from? Why are there so many competing formats? Why don't people seem to use it that much anymore? +> +> Answers to these questions and many more in this week's post about RSS: +> +> — TwoBitHistory (@TwoBitHistory) [September 17, 2018][8] + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2018/09/30/chaosnet.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Hesiod_(name_service) +[2]: https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol +[3]: http://www-formal.stanford.edu/jmc/recursive.pdf +[4]: https://en.wikipedia.org/wiki/SHRDLU +[5]: https://tools.ietf.org/html/rfc973 +[6]: https://twitter.com/TwoBitHistory +[7]: https://twobithistory.org/feed.xml +[8]: https://twitter.com/TwoBitHistory/status/1041485204802756608?ref_src=twsrc%5Etfw From ed88e7b2319b5b0be25ecb7711c9254ff867579f Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 24 Oct 2018 11:36:00 +0800 Subject: [PATCH 142/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20The=20Rise=20and?= =?UTF-8?q?=20Demise=20of=20RSS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180916 The Rise and Demise of RSS.md | 122 ++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 sources/talk/20180916 The Rise and Demise of RSS.md diff --git a/sources/talk/20180916 The Rise and Demise of RSS.md b/sources/talk/20180916 The Rise and Demise of RSS.md new file mode 100644 index 0000000000..8511d220d9 --- /dev/null +++ b/sources/talk/20180916 The Rise and Demise of RSS.md @@ -0,0 +1,122 @@ +The Rise and Demise of RSS +====== +There are two stories here. The first is a story about a vision of the web’s future that never quite came to fruition. The second is a story about how a collaborative effort to improve a popular standard devolved into one of the most contentious forks in the history of open-source software development. + +In the late 1990s, in the go-go years between Netscape’s IPO and the Dot-com crash, everyone could see that the web was going to be an even bigger deal than it already was, even if they didn’t know exactly how it was going to get there. One theory was that the web was about to be revolutionized by syndication. The web, originally built to enable a simple transaction between two parties—a client fetching a document from a single host server—would be broken open by new standards that could be used to repackage and redistribute entire websites through a variety of channels. Kevin Werbach, writing for Release 1.0, a newsletter influential among investors in the 1990s, predicted that syndication “would evolve into the core model for the Internet economy, allowing businesses and individuals to retain control over their online personae while enjoying the benefits of massive scale and scope.” He invited his readers to imagine a future in which fencing aficionados, rather than going directly to an “online sporting goods site” or “fencing equipment retailer,” could buy a new épée directly through e-commerce widgets embedded into their favorite website about fencing. Just like in the television world, where big networks syndicate their shows to smaller local stations, syndication on the web would allow businesses and publications to reach consumers through a multitude of intermediary sites. This would mean, as a corollary, that consumers would gain significant control over where and how they interacted with any given business or publication on the web. + +RSS was one of the standards that promised to deliver this syndicated future. To Werbach, RSS was “the leading example of a lightweight syndication protocol.” Another contemporaneous article called RSS the first protocol to realize the potential of XML. It was going to be a way for both users and content aggregators to create their own customized channels out of everything the web had to offer. And yet, two decades later, RSS [appears to be a dying technology][1], now used chiefly by podcasters and programmers with tech blogs. Moreover, among that latter group, RSS is perhaps used as much for its political symbolism as its actual utility. Though of course some people really do have RSS readers, stubbornly adding an RSS feed to your blog, even in 2018, is a reactionary statement. That little tangerine bubble has become a wistful symbol of defiance against a centralized web increasingly controlled by a handful of corporations, a web that hardly resembles the syndicated web of Werbach’s imagining. + +The future once looked so bright for RSS. What happened? Was its downfall inevitable, or was it precipitated by the bitter infighting that thwarted the development of a single RSS standard? + +### Muddied Water + +RSS was invented twice. This meant it never had an obvious owner, a state of affairs that spawned endless debate and acrimony. But it also suggests that RSS was an important idea whose time had come. + +In 1998, Netscape was struggling to envision a future for itself. Its flagship product, the Netscape Navigator web browser—once preferred by 80% of web users—was quickly losing ground to Internet Explorer. So Netscape decided to compete in a new arena. In May, a team was brought together to start work on what was known internally as “Project 60.” Two months later, Netscape announced “My Netscape,” a web portal that would fight it out with other portals like Yahoo, MSN, and Excite. + +The following year, in March, Netscape announced an addition to the My Netscape portal called the “My Netscape Network.” My Netscape users could now customize their My Netscape page so that it contained “channels” featuring the most recent headlines from sites around the web. As long as your favorite website published a special file in a format dictated by Netscape, you could add that website to your My Netscape page, typically by clicking an “Add Channel” button that participating websites were supposed to add to their interfaces. A little box containing a list of linked headlines would then appear. + +![A My Netscape Network Channel][2] + +The special file that participating websites had to publish was an RSS file. In the My Netscape Network announcement, Netscape explained that RSS stood for “RDF Site Summary.” This was somewhat of a misnomer. RDF, or the Resource Description Framework, is basically a grammar for describing certain properties of arbitrary resources. (See [my article about the Semantic Web][3] if that sounds really exciting to you.) In 1999, a draft specification for RDF was being considered by the W3C. Though RSS was supposed to be based on RDF, the example RSS document Netscape actually released didn’t use any RDF tags at all, even if it declared the RDF XML namespace. In a document that accompanied the Netscape RSS specification, Dan Libby, one of the specification’s authors, explained that “in this release of MNN, Netscape has intentionally limited the complexity of the RSS format.” The specification was given the 0.90 version number, the idea being that subsequent versions would bring RSS more in line with the W3C’s XML specification and the evolving draft of the RDF specification. + +RSS had been cooked up by Libby and another Netscape employee, Ramanathan Guha. Guha previously worked for Apple, where he came up with something called the Meta Content Framework. MCF was a format for representing metadata about anything from web pages to local files. Guha demonstrated its power by developing an application called [HotSauce][4] that visualized relationships between files as a network of nodes suspended in 3D space. After leaving Apple for Netscape, Guha worked with a Netscape consultant named Tim Bray to produce an XML-based version of MCF, which in turn became the foundation for the W3C’s RDF draft. It’s no surprise, then, that Guha and Libby were keen to incorporate RDF into RSS. But Libby later wrote that the original vision for an RDF-based RSS was pared back because of time constraints and the perception that RDF was “‘too complex’ for the ‘average user.’” + +While Netscape was trying to win eyeballs in what became known as the “portal wars,” elsewhere on the web a new phenomenon known as “weblogging” was being pioneered. One of these pioneers was Dave Winer, CEO of a company called UserLand Software, which developed early content management systems that made blogging accessible to people without deep technical fluency. Winer ran his own blog, [Scripting News][5], which today is one of the oldest blogs on the internet. More than a year before Netscape announced My Netscape Network, on December 15th, 1997, Winer published a post announcing that the blog would now be available in XML as well as HTML. + +Dave Winer’s XML format became known as the Scripting News format. It was supposedly similar to Microsoft’s Channel Definition Format (a “push technology” standard submitted to the W3C in March, 1997), but I haven’t been able to find a file in the original format to verify that claim. Like Netscape’s RSS, it structured the content of Winer’s blog so that it could be understood by other software applications. When Netscape released RSS 0.90, Winer and UserLand Software began to support both formats. But Winer believed that Netscape’s format was “woefully inadequate” and “missing the key thing web writers and readers need.” It could only represent a list of links, whereas the Scripting News format could represent a series of paragraphs, each containing one or more links. + +In June, 1999, two months after Netscape’s My Netscape Network announcement, Winer introduced a new version of the Scripting News format, called ScriptingNews 2.0b1. Winer claimed that he decided to move ahead with his own format only after trying but failing to get anyone at Netscape to care about RSS 0.90’s deficiencies. The new version of the Scripting News format added several items to the `
` element that brought the Scripting News format to parity with RSS. But the two formats continued to differ in that the Scripting News format, which Winer nicknamed the “fat” syndication format, could include entire paragraphs and not just links. + +Netscape got around to releasing RSS 0.91 the very next month. The updated specification was a major about-face. RSS no longer stood for “RDF Site Summary”; it now stood for “Rich Site Summary.” All the RDF—and there was almost none anyway—was stripped out. Many of the Scripting News tags were incorporated. In the text of the new specification, Libby explained: + +> RDF references removed. RSS was originally conceived as a metadata format providing a summary of a website. Two things have become clear: the first is that providers want more of a syndication format than a metadata format. The structure of an RDF file is very precise and must conform to the RDF data model in order to be valid. This is not easily human-understandable and can make it difficult to create useful RDF files. The second is that few tools are available for RDF generation, validation and processing. For these reasons, we have decided to go with a standard XML approach. + +Winer was enormously pleased with RSS 0.91, calling it “even better than I thought it would be.” UserLand Software adopted it as a replacement for the existing ScriptingNews 2.0b1 format. For a while, it seemed that RSS finally had a single authoritative specification. + +### The Great Fork + +A year later, the RSS 0.91 specification had become woefully inadequate. There were all sorts of things people were trying to do with RSS that the specification did not address. There were other parts of the specification that seemed unnecessarily constraining—each RSS channel could only contain a maximum of 15 items, for example. + +By that point, RSS had been adopted by several more organizations. Other than Netscape, which seemed to have lost interest after RSS 0.91, the big players were Dave Winer’s UserLand Software; O’Reilly Net, which ran an RSS aggregator called Meerkat; and Moreover.com, which also ran an RSS aggregator focused on news. Via mailing list, representatives from these organizations and others regularly discussed how to improve on RSS 0.91. But there were deep disagreements about what those improvements should look like. + +The mailing list in which most of the discussion occurred was called the Syndication mailing list. [An archive of the Syndication mailing list][6] is still available. It is an amazing historical resource. It provides a moment-by-moment account of how those deep disagreements eventually led to a political rupture of the RSS community. + +On one side of the coming rupture was Winer. Winer was impatient to evolve RSS, but he wanted to change it only in relatively conservative ways. In June, 2000, he published his own RSS 0.91 specification on the UserLand website, meant to be a starting point for further development of RSS. It made no significant changes to the 0.91 specification published by Netscape. Winer claimed in a blog post that accompanied his specification that it was only a “cleanup” documenting how RSS was actually being used in the wild, which was needed because the Netscape specification was no longer being maintained. In the same post, he argued that RSS had succeeded so far because it was simple, and that by adding namespaces or RDF back to the format—some had suggested this be done in the Syndication mailing list—it “would become vastly more complex, and IMHO, at the content provider level, would buy us almost nothing for the added complexity.” In a message to the Syndication mailing list sent around the same time, Winer suggested that these issues were important enough that they might lead him to create a fork: + +> I’m still pondering how to move RSS forward. I definitely want ICE-like stuff in RSS2, publish and subscribe is at the top of my list, but I am going to fight tooth and nail for simplicity. I love optional elements. I don’t want to go down the namespaces and schema road, or try to make it a dialect of RDF. I understand other people want to do this, and therefore I guess we’re going to get a fork. I have my own opinion about where the other fork will lead, but I’ll keep those to myself for the moment at least. + +Arrayed against Winer were several other people, including Rael Dornfest of O’Reilly, Ian Davis (responsible for a search startup called Calaba), and a precocious, 14-year-old Aaron Swartz, who all thought that RSS needed namespaces in order to accommodate the many different things everyone wanted to do with it. On another mailing list hosted by O’Reilly, Davis proposed a namespace-based module system, writing that such a system would “make RSS as extensible as we like rather than packing in new features that over-complicate the spec.” The “namespace camp” believed that RSS would soon be used for much more than the syndication of blog posts, so namespaces, rather than being a complication, were the only way to keep RSS from becoming unmanageable as it supported more and more use cases. + +At the root of this disagreement about namespaces was a deeper disagreement about what RSS was even for. Winer had invented his Scripting News format to syndicate the posts he wrote for his blog. Guha and Libby at Netscape had designed RSS and called it “RDF Site Summary” because in their minds it was a way of recreating a site in miniature within Netscape’s online portal. Davis, writing to the Syndication mailing list, explained his view that RSS was “originally conceived as a way of building mini sitemaps,” and that now he and others wanted to expand RSS “to encompass more types of information than simple news headlines and to cater for the new uses of RSS that have emerged over the last 12 months.” Winer wrote a prickly reply, stating that his Scripting News format was in fact the original RSS and that it had been meant for a different purpose. Given that the people most involved in the development of RSS disagreed about why RSS had even been created, a fork seems to have been inevitable. + +The fork happened after Dornfest announced a proposed RSS 1.0 specification and formed the RSS-DEV Working Group—which would include Davis, Swartz, and several others but not Winer—to get it ready for publication. In the proposed specification, RSS once again stood for “RDF Site Summary,” because RDF had had been added back in to represent metadata properties of certain RSS elements. The specification acknowledged Winer by name, giving him credit for popularizing RSS through his “evangelism.” But it also argued that just adding more elements to RSS without providing for extensibility with a module system—that is, what Winer was suggesting—”sacrifices scalability.” The specification went on to define a module system for RSS based on XML namespaces. + +Winer was furious that the RSS-DEV Working Group had arrogated the “RSS 1.0” name for themselves. In another mailing list about decentralization, he described what the RSS-DEV Working Group had done as theft. Other members of the Syndication mailing list also felt that the RSS-DEV Working Group should not have used the name “RSS” without unanimous agreement from the community on how to move RSS forward. But the Working Group stuck with the name. Dan Brickley, another member of the RSS-DEV Working Group, defended this decision by arguing that “RSS 1.0 as proposed is solidly grounded in the original RSS vision, which itself had a long heritage going back to MCF (an RDF precursor) and related specs (CDF etc).” He essentially felt that the RSS 1.0 effort had a better claim to the RSS name than Winer did, since RDF had originally been a part of RSS. The RSS-DEV Working Group published a final version of their specification in December. That same month, Winer published his own improvement to RSS 0.91, which he called RSS 0.92, on UserLand’s website. RSS 0.92 made several small optional improvements to RSS, among which was the addition of the `` tag soon used by podcasters everywhere. RSS had officially forked. + +It’s not clear to me why a better effort was not made to involve Winer in the RSS-DEV Working Group. He was a prominent contributor to the Syndication mailing list and obviously responsible for much of RSS’ popularity, as the members of the Working Group themselves acknowledged. But Tim O’Reilly, founder and CEO of O’Reilly, explained in a UserLand discussion group that Winer more or less refused to participate: + +> A group of people involved in RSS got together to start thinking about its future evolution. Dave was part of the group. When the consensus of the group turned in a direction he didn’t like, Dave stopped participating, and characterized it as a plot by O’Reilly to take over RSS from him, despite the fact that Rael Dornfest of O’Reilly was only one of about a dozen authors of the proposed RSS 1.0 spec, and that many of those who were part of its development had at least as long a history with RSS as Dave had. + +To this, Winer said: + +> I met with Dale [Dougherty] two weeks before the announcement, and he didn’t say anything about it being called RSS 1.0. I spoke on the phone with Rael the Friday before it was announced, again he didn’t say that they were calling it RSS 1.0. The first I found out about it was when it was publicly announced. +> +> Let me ask you a straight question. If it turns out that the plan to call the new spec “RSS 1.0” was done in private, without any heads-up or consultation, or for a chance for the Syndication list members to agree or disagree, not just me, what are you going to do? +> +> UserLand did a lot of work to create and popularize and support RSS. We walked away from that, and let your guys have the name. That’s the top level. If I want to do any further work in Web syndication, I have to use a different name. Why and how did that happen Tim? + +I have not been able to find a discussion in the Syndication mailing list about using the RSS 1.0 name prior to the announcement of the RSS 1.0 proposal. + +RSS would fork again in 2003, when several developers frustrated with the bickering in the RSS community sought to create an entirely new format. These developers created Atom, a format that did away with RDF but embraced XML namespaces. Atom would eventually be specified by [a proposed IETF standard][7]. After the introduction of Atom, there were three competing versions of RSS: Winer’s RSS 0.92 (updated to RSS 2.0 in 2002 and renamed “Really Simple Syndication”), the RSS-DEV Working Group’s RSS 1.0, and Atom. + +### Decline + +The proliferation of competing RSS specifications may have hampered RSS in other ways that I’ll discuss shortly. But it did not stop RSS from becoming enormously popular during the 2000s. By 2004, the New York Times had started offering its headlines in RSS and had written an article explaining to the layperson what RSS was and how to use it. Google Reader, an RSS aggregator ultimately used by millions, was launched in 2005. By 2013, RSS seemed popular enough that the New York Times, in its obituary for Aaron Swartz, called the technology “ubiquitous.” For a while, before a third of the planet had signed up for Facebook, RSS was simply how many people stayed abreast of news on the internet. + +The New York Times published Swartz’ obituary in January, 2013. By that point, though, RSS had actually turned a corner and was well on its way to becoming an obscure technology. Google Reader was shutdown in July, 2013, ostensibly because user numbers had been falling “over the years.” This prompted several articles from various outlets declaring that RSS was dead. But people had been declaring that RSS was dead for years, even before Google Reader’s shuttering. Steve Gillmor, writing for TechCrunch in May, 2009, advised that “it’s time to get completely off RSS and switch to Twitter” because “RSS just doesn’t cut it anymore.” He pointed out that Twitter was basically a better RSS feed, since it could show you what people thought about an article in addition to the article itself. It allowed you to follow people and not just channels. Gillmor told his readers that it was time to let RSS recede into the background. He ended his article with a verse from Bob Dylan’s “Forever Young.” + +Today, RSS is not dead. But neither is it anywhere near as popular as it once was. Lots of people have offered explanations for why RSS lost its broad appeal. Perhaps the most persuasive explanation is exactly the one offered by Gillmor in 2009. Social networks, just like RSS, provide a feed featuring all the latest news on the internet. Social networks took over from RSS because they were simply better feeds. They also provide more benefits to the companies that own them. Some people have accused Google, for example, of shutting down Google Reader in order to encourage people to use Google+. Google might have been able to monetize Google+ in a way that it could never have monetized Google Reader. Marco Arment, the creator of Instapaper, wrote on his blog in 2013: + +> Google Reader is just the latest casualty of the war that Facebook started, seemingly accidentally: the battle to own everything. While Google did technically “own” Reader and could make some use of the huge amount of news and attention data flowing through it, it conflicted with their far more important Google+ strategy: they need everyone reading and sharing everything through Google+ so they can compete with Facebook for ad-targeting data, ad dollars, growth, and relevance. + +So both users and technology companies realized that they got more out of using social networks than they did out of RSS. + +Another theory is that RSS was always too geeky for regular people. Even the New York Times, which seems to have been eager to adopt RSS and promote it to its audience, complained in 2006 that RSS is a “not particularly user friendly” acronym coined by “computer geeks.” Before the RSS icon was designed in 2004, websites like the New York Times linked to their RSS feeds using little orange boxes labeled “XML,” which can only have been intimidating. The label was perfectly accurate though, because back then clicking the link would take a hapless user to a page full of XML. [This great tweet][8] captures the essence of this explanation for RSS’ demise. Regular people never felt comfortable using RSS; it hadn’t really been designed as a consumer-facing technology and involved too many hurdles; people jumped ship as soon as something better came along. + +RSS might have been able to overcome some of these limitations if it had been further developed. Maybe RSS could have been extended somehow so that friends subscribed to the same channel could syndicate their thoughts about an article to each other. But whereas a company like Facebook was able to “move fast and break things,” the RSS developer community was stuck trying to achieve consensus. The Great RSS Fork only demonstrates how difficult it was to do that. So if we are asking ourselves why RSS is no longer popular, a good first-order explanation is that social networks supplanted it. If we ask ourselves why social networks were able to supplant it, then the answer may be that the people trying to make RSS succeed faced a problem much harder than, say, building Facebook. As Dornfest wrote to the Syndication mailing list at one point, “currently it’s the politics far more than the serialization that’s far from simple.” + +So today we are left with centralized silos of information. In a way, we do have the syndicated internet that Kevin Werbach foresaw in 1999. After all, The Onion is a publication that relies on syndication through Facebook and Twitter the same way that Seinfeld relied on syndication to rake in millions after the end of its original run. But syndication on the web only happens through one of a very small number of channels, meaning that none of us “retain control over our online personae” the way that Werbach thought we would. One reason this happened is garden-variety corporate rapaciousness—RSS, an open format, didn’t give technology companies the control over data and eyeballs that they needed to sell ads, so they did not support it. But the more mundane reason is that centralized silos are just easier to design than common standards. Consensus is difficult to achieve and it takes time, but without consensus spurned developers will go off and create competing standards. The lesson here may be that if we want to see a better, more open web, we have to get better at not screwing each other over. + +If you enjoyed this post, more like it come out every two weeks! Follow [@TwoBitHistory][9] on Twitter or subscribe to the [RSS feed][10] to make sure you know when a new post is out. + +Previously on TwoBitHistory… + +> New post: This week we're traveling back in time in our DeLorean to see what it was like learning to program on early home computers. +> +> — TwoBitHistory (@TwoBitHistory) [September 2, 2018][11] + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2018/09/16/the-rise-and-demise-of-rss.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://trends.google.com/trends/explore?date=all&geo=US&q=rss +[2]: https://twobithistory.org/images/mnn-channel.gif +[3]: https://twobithistory.org/2018/05/27/semantic-web.html +[4]: http://web.archive.org/web/19970703020212/http://mcf.research.apple.com:80/hs/screen_shot.html +[5]: http://scripting.com/ +[6]: https://groups.yahoo.com/neo/groups/syndication/info +[7]: https://tools.ietf.org/html/rfc4287 +[8]: https://twitter.com/mgsiegler/status/311992206716203008 +[9]: https://twitter.com/TwoBitHistory +[10]: https://twobithistory.org/feed.xml +[11]: https://twitter.com/TwoBitHistory/status/1036295112375115778?ref_src=twsrc%5Etfw From a31b145df93ff3f72a2e2d4989ca57426a9d1e34 Mon Sep 17 00:00:00 2001 From: Wenxuan Zhao Date: Tue, 23 Oct 2018 20:37:11 -0700 Subject: [PATCH 143/158] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=8C=96=20PR=20?= =?UTF-8?q?=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .travis.yml | 2 +- Makefile | 58 ------------------------- scripts/check.sh | 10 +++++ scripts/check/analyze.sh | 43 +++++++++++++++++++ scripts/check/check.sh | 10 +++++ scripts/check/collect.sh | 32 ++++++++++++++ scripts/check/common.inc.sh | 30 +++++++++++++ scripts/check/identify.sh | 86 +++++++++++++++++++++++++++++++++++++ scripts/check/info.sh | 4 ++ scripts/check/mock/stats.sh | 13 ++++++ 10 files changed, 229 insertions(+), 59 deletions(-) delete mode 100644 Makefile create mode 100644 scripts/check.sh create mode 100644 scripts/check/analyze.sh create mode 100644 scripts/check/check.sh create mode 100644 scripts/check/collect.sh create mode 100644 scripts/check/common.inc.sh create mode 100644 scripts/check/identify.sh create mode 100644 scripts/check/info.sh create mode 100644 scripts/check/mock/stats.sh diff --git a/.travis.yml b/.travis.yml index ff9b70cbc2..1bea11af3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,3 @@ language: c script: - - make -s check + - sh ./scripts/check.sh diff --git a/Makefile b/Makefile deleted file mode 100644 index f33b3e3f7d..0000000000 --- a/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -DIR_PATTERN := (news|talk|tech) -NAME_PATTERN := [0-9]{8} [a-zA-Z0-9_.,() -]*\.md - -RULES := rule-source-added \ - rule-translation-requested \ - rule-translation-completed \ - rule-translation-revised \ - rule-translation-published -.PHONY: check match $(RULES) - -CHANGE_FILE := /tmp/changes - -check: $(CHANGE_FILE) - echo 'PR #$(TRAVIS_PULL_REQUEST) Changes:' - cat $(CHANGE_FILE) - echo - echo 'Check for rules...' - make -k $(RULES) 2>/dev/null | grep '^Rule Matched: ' - -$(CHANGE_FILE): - git --no-pager diff $(TRAVIS_BRANCH) origin/master --no-renames --name-status > $@ - -rule-source-added: - echo 'Unmatched Files:' - egrep -v '^A\s*"?sources/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) || true - echo '[End of Unmatched Files]' - [ $(shell egrep '^A\s*"?sources/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) -ge 1 ] - [ $(shell egrep -v '^A\s*"?sources/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 0 ] - echo 'Rule Matched: $(@)' - -rule-translation-requested: - [ $(shell egrep '^M\s*"?sources/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 1 ] - [ $(shell cat $(CHANGE_FILE) | wc -l) = 1 ] - echo 'Rule Matched: $(@)' - -rule-translation-completed: - [ $(shell egrep '^D\s*"?sources/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 1 ] - [ $(shell egrep '^A\s*"?translated/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 1 ] - [ $(shell cat $(CHANGE_FILE) | wc -l) = 2 ] - echo 'Rule Matched: $(@)' - -rule-translation-revised: - [ $(shell egrep '^M\s*"?translated/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 1 ] - [ $(shell cat $(CHANGE_FILE) | wc -l) = 1 ] - echo 'Rule Matched: $(@)' - -rule-translation-published: - [ $(shell egrep '^D\s*"?translated/$(DIR_PATTERN)/$(NAME_PATTERN)"?' $(CHANGE_FILE) | wc -l) = 1 ] - [ $(shell egrep '^A\s*"?published/$(NAME_PATTERN)' $(CHANGE_FILE) | wc -l) = 1 ] - [ $(shell cat $(CHANGE_FILE) | wc -l) = 2 ] - echo 'Rule Matched: $(@)' - -badge: - mkdir -p build/badge - ./lctt-scripts/show_status.sh -s published >build/badge/published.svg - ./lctt-scripts/show_status.sh -s translated >build/badge/translated.svg - ./lctt-scripts/show_status.sh -s translating >build/badge/translating.svg - ./lctt-scripts/show_status.sh -s sources >build/badge/sources.svg diff --git a/scripts/check.sh b/scripts/check.sh new file mode 100644 index 0000000000..539f2426e7 --- /dev/null +++ b/scripts/check.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# PR 检查脚本 +set -e + +CHECK_DIR="$(dirname "$0")/check" +# sh "${CHECK_DIR}/check.sh" # 需要依赖,暂时禁用 +sh "${CHECK_DIR}/info.sh" +sh "${CHECK_DIR}/collect.sh" +sh "${CHECK_DIR}/analyze.sh" +sh "${CHECK_DIR}/identify.sh" diff --git a/scripts/check/analyze.sh b/scripts/check/analyze.sh new file mode 100644 index 0000000000..9aa47d5664 --- /dev/null +++ b/scripts/check/analyze.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# PR 文件变更分析 +set -e + +# 加载公用常量和函数 +# shellcheck source=common.inc.sh +. "$(dirname "$0")/common.inc.sh" + +################################################################################ +# 读入: +# - /tmp/changes # 文件变更列表 +# 写出: +# - /tmp/stats # 文件变更统计 +################################################################################ + +# 执行分析并将统计输出到标准输出 +do_analyze() { + cat /dev/null > /tmp/stats + OTHER_REGEX='^$' + for TYPE in 'SRC' 'TSL' 'PUB'; do + for STAT in 'A' 'M' 'D'; do + # 统计每个类别的每个操作 + REGEX="$(get_operation_regex "$STAT" "$TYPE")" + OTHER_REGEX="${OTHER_REGEX}|${REGEX}" + eval "${TYPE}_${STAT}=\"\$(grep -Ec '$REGEX' /tmp/changes)\"" || true + eval echo "${TYPE}_${STAT}=\$${TYPE}_${STAT}" + done + done + + # 统计其他操作 + OTHER="$(grep -Evc "$OTHER_REGEX" /tmp/changes)" || true + echo "OTHER=$OTHER" + + # 统计变更总数 + TOTAL="$(wc -l < /tmp/changes )" + echo "TOTAL=$TOTAL" +} + + +echo "[分析] 统计文件变更……" +do_analyze > /tmp/stats +echo "[分析] 已写入统计结果:" +cat /tmp/stats diff --git a/scripts/check/check.sh b/scripts/check/check.sh new file mode 100644 index 0000000000..a527c225ab --- /dev/null +++ b/scripts/check/check.sh @@ -0,0 +1,10 @@ +#!/bin/bash +# 检查脚本状态 +set -e + +################################################################################ +# 暂时仅供开发使用 +################################################################################ + +shellcheck -e SC2034 -x mock/stats.sh "$(dirname "$0")"/*.sh \ + && echo '[检查] ShellCheck 通过' diff --git a/scripts/check/collect.sh b/scripts/check/collect.sh new file mode 100644 index 0000000000..db49dacaa6 --- /dev/null +++ b/scripts/check/collect.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# PR 文件变更收集 +set -e + +################################################################################ +# 读入:(无) +# 写出: +# - /tmp/changes # 文件变更列表 +################################################################################ + + +echo "[收集] 计算 PR 分支与目标分支的分叉点……" + +TARGET_BRANCH="${TRAVIS_BRANCH:-master}" +echo "[收集] 目标分支设定为:${TARGET_BRANCH}" + +MERGE_BASE="$(git merge-base "$TARGET_BRANCH" FETCH_HEAD)" +echo "[收集] 找到分叉节点:${MERGE_BASE}" + +{ + git log --oneline "${MERGE_BASE}..FETCH_HEAD" | grep -Eq '^绕过检查:' && { + touch /tmp/bypass + echo "[收集] 已标记为绕过检查项" + } +} || true + +echo "[收集] 写出文件变更列表……" + +git diff "$MERGE_BASE" FETCH_HEAD --no-renames --name-status > /tmp/changes +echo "[收集] 已写出文件变更列表:" +cat /tmp/changes +{ [ -z "$(cat /tmp/changes)" ] && echo "(无变更)"; } || true diff --git a/scripts/check/common.inc.sh b/scripts/check/common.inc.sh new file mode 100644 index 0000000000..6012bc2fe5 --- /dev/null +++ b/scripts/check/common.inc.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +################################################################################ +# 公用常量和函数 +################################################################################ + +# 定义类别目录 +export SRC_DIR='sources' # 未翻译 +export TSL_DIR='translated' # 已翻译 +export PUB_DIR='published' # 已发布 + +# 定义匹配规则 +export CATE_PATTERN='(news|talk|tech)' # 类别 +export FILE_PATTERN='[0-9]{8} [a-zA-Z0-9_.,() -]*\.md' # 文件名 + +# 用法:get_operation_regex 状态 类型 +# +# 状态为: +# - A:添加 +# - M:修改 +# - D:删除 +# 类型为: +# - SRC:未翻译 +# - TSL:已翻译 +# - PUB:已发布 +get_operation_regex() { + STAT="$1" + TYPE="$2" + echo "^${STAT}\\s+\"?$(eval echo "\$${TYPE}_DIR")/" +} diff --git a/scripts/check/identify.sh b/scripts/check/identify.sh new file mode 100644 index 0000000000..195ca4b669 --- /dev/null +++ b/scripts/check/identify.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# 匹配 PR 规则 +set -e + +################################################################################ +# 读入: +# - /tmp/stats +# 写出:(无) +################################################################################ + +# 加载公用常量和函数 +# shellcheck source=common.inc.sh +. "$(dirname "$0")/common.inc.sh" + +echo "[匹配] 加载统计结果……" +# 加载统计结果 +# shellcheck source=mock/stats.sh +. /tmp/stats + +# 定义 PR 规则 + +# 绕过检查:绕过 PR 检查 +rule_bypass_check() { + [ -f /tmp/bypass ] && echo "匹配规则:绕过检查" +} + +# 添加原文:添加至少一篇原文 +rule_source_added() { + [ "$SRC_A" -ge 1 ] \ + && [ "$TOTAL" -eq "$SRC_A" ] && echo "匹配规则:添加原文 ${SRC_A} 篇" +} + +# 申领翻译:只能申领一篇原文 +rule_translation_requested() { + [ "$SRC_M" -eq 1 ] \ + && [ "$TOTAL" -eq 1 ] && echo "匹配规则:申领翻译" +} + +# 提交译文:只能提交一篇译文 +rule_translation_completed() { + [ "$SRC_D" -eq 1 ] && [ "$TSL_A" -eq 1 ] \ + && [ "$TOTAL" -eq 2 ] && echo "匹配规则:提交译文" +} + +# 校对译文:只能校对一篇 +rule_translation_revised() { + [ "$TSL_M" -eq 1 ] \ + && [ "$TOTAL" -eq 1 ] && echo "匹配规则:校对译文" +} + +# 发布译文:发布多篇译文 +rule_translation_published() { + [ "$TSL_D" -ge 1 ] && [ "$PUB_A" -ge 1 ] && [ "$TSL_D" -eq "$PUB_A" ] \ + && [ "$TOTAL" -eq $(("$TSL_D" + "$PUB_A")) ] \ + && echo "匹配规则:发布译文 ${PUB_A} 篇" +} + +# 定义常见错误 + +# 未知错误 +error_undefined() { + echo "未知错误:无匹配规则,请尝试只对一篇文章进行操作" +} + +# 申领多篇 +error_translation_requested_multiple() { + [ "$SRC_M" -gt 1 ] \ + && echo "匹配错误:申领多篇,请一次仅申领一篇" +} + +# 执行检查并输出匹配项目 +do_check() { + rule_bypass_check \ + || rule_source_added \ + || rule_translation_requested \ + || rule_translation_completed \ + || rule_translation_revised \ + || rule_translation_published \ + || { + error_translation_requested_multiple \ + || error_undefined + exit 1 + } +} + +do_check diff --git a/scripts/check/info.sh b/scripts/check/info.sh new file mode 100644 index 0000000000..2e8159fe0c --- /dev/null +++ b/scripts/check/info.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# 打印 PR 信息 +echo "" diff --git a/scripts/check/mock/stats.sh b/scripts/check/mock/stats.sh new file mode 100644 index 0000000000..966f1b04fd --- /dev/null +++ b/scripts/check/mock/stats.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# 给 ShellCheck 用的 Mock 统计 +SRC_A=0 +SRC_M=0 +SRC_D=0 +TSL_A=0 +TSL_M=0 +TSL_D=0 +PUB_A=0 +PUB_M=0 +PUB_D=0 +OTHER=0 +TOTAL=0 From d77d2bc64e72b1cf270492073dcaeb357e45535b Mon Sep 17 00:00:00 2001 From: Wenxuan Zhao Date: Tue, 23 Oct 2018 21:27:21 -0700 Subject: [PATCH 144/158] =?UTF-8?q?=E7=BB=95=E8=BF=87=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=EF=BC=9A=E5=85=81=E8=AE=B8=E6=A3=80=E6=9F=A5=20PR=20=E5=A4=96?= =?UTF-8?q?=E7=9A=84=E6=8F=90=E4=BA=A4=EF=BC=8C=E4=BF=AE=E5=A4=8D=E7=BB=95?= =?UTF-8?q?=E8=BF=87=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/check/collect.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/check/collect.sh b/scripts/check/collect.sh index db49dacaa6..d58246b120 100644 --- a/scripts/check/collect.sh +++ b/scripts/check/collect.sh @@ -14,11 +14,13 @@ echo "[收集] 计算 PR 分支与目标分支的分叉点……" TARGET_BRANCH="${TRAVIS_BRANCH:-master}" echo "[收集] 目标分支设定为:${TARGET_BRANCH}" -MERGE_BASE="$(git merge-base "$TARGET_BRANCH" FETCH_HEAD)" +MERGE_BASE='HEAD^' +[ "$TRAVIS_PULL_REQUEST" != 'false' ] \ + && MERGE_BASE="$(git merge-base "$TARGET_BRANCH" HEAD)" echo "[收集] 找到分叉节点:${MERGE_BASE}" { - git log --oneline "${MERGE_BASE}..FETCH_HEAD" | grep -Eq '^绕过检查:' && { + git log --oneline "${MERGE_BASE}..HEAD" | grep -Eq '绕过检查' && { touch /tmp/bypass echo "[收集] 已标记为绕过检查项" } @@ -26,7 +28,7 @@ echo "[收集] 找到分叉节点:${MERGE_BASE}" echo "[收集] 写出文件变更列表……" -git diff "$MERGE_BASE" FETCH_HEAD --no-renames --name-status > /tmp/changes +git diff "$MERGE_BASE" HEAD --no-renames --name-status > /tmp/changes echo "[收集] 已写出文件变更列表:" cat /tmp/changes { [ -z "$(cat /tmp/changes)" ] && echo "(无变更)"; } || true From 38516482370f9b387bcef78bd4276f3cf7e76e35 Mon Sep 17 00:00:00 2001 From: Wenxuan Zhao Date: Tue, 23 Oct 2018 21:52:07 -0700 Subject: [PATCH 145/158] =?UTF-8?q?=E7=BB=95=E8=BF=87=E6=A3=80=E6=9F=A5?= =?UTF-8?q?=EF=BC=9A=E5=9C=A8=E6=94=B6=E9=9B=86=E9=98=B6=E6=AE=B5=E6=89=93?= =?UTF-8?q?=E5=8D=B0=20PR=20=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/check.sh | 1 - scripts/check/collect.sh | 5 ++++- scripts/check/info.sh | 4 ---- 3 files changed, 4 insertions(+), 6 deletions(-) delete mode 100644 scripts/check/info.sh diff --git a/scripts/check.sh b/scripts/check.sh index 539f2426e7..ba5707fbf6 100644 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -4,7 +4,6 @@ set -e CHECK_DIR="$(dirname "$0")/check" # sh "${CHECK_DIR}/check.sh" # 需要依赖,暂时禁用 -sh "${CHECK_DIR}/info.sh" sh "${CHECK_DIR}/collect.sh" sh "${CHECK_DIR}/analyze.sh" sh "${CHECK_DIR}/identify.sh" diff --git a/scripts/check/collect.sh b/scripts/check/collect.sh index d58246b120..dc6293e280 100644 --- a/scripts/check/collect.sh +++ b/scripts/check/collect.sh @@ -19,8 +19,11 @@ MERGE_BASE='HEAD^' && MERGE_BASE="$(git merge-base "$TARGET_BRANCH" HEAD)" echo "[收集] 找到分叉节点:${MERGE_BASE}" +echo "[收集] 变更摘要:" +git --no-pager show --summary "${MERGE_BASE}..HEAD" + { - git log --oneline "${MERGE_BASE}..HEAD" | grep -Eq '绕过检查' && { + git --no-pager log --oneline "${MERGE_BASE}..HEAD" | grep -Eq '绕过检查' && { touch /tmp/bypass echo "[收集] 已标记为绕过检查项" } diff --git a/scripts/check/info.sh b/scripts/check/info.sh deleted file mode 100644 index 2e8159fe0c..0000000000 --- a/scripts/check/info.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# 打印 PR 信息 -echo "" From b283b276ba0d20c9795300d3ea28688908dfa231 Mon Sep 17 00:00:00 2001 From: belitex Date: Wed, 24 Oct 2018 13:27:33 +0800 Subject: [PATCH 146/158] translate: What is an SRE and how does it relate to DevOps --- .../20181019 What is an SRE and how does it relate to DevOps.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/talk/20181019 What is an SRE and how does it relate to DevOps.md b/sources/talk/20181019 What is an SRE and how does it relate to DevOps.md index 4a5c8aba13..7093b36cd5 100644 --- a/sources/talk/20181019 What is an SRE and how does it relate to DevOps.md +++ b/sources/talk/20181019 What is an SRE and how does it relate to DevOps.md @@ -1,3 +1,5 @@ +translating by belitex + What is an SRE and how does it relate to DevOps? ====== The SRE role is common in large enterprises, but smaller businesses need it, too. From e432037c47c3dc72cef688415502cd2961abe4c4 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 24 Oct 2018 15:20:03 +0800 Subject: [PATCH 147/158] PRF:20181012 Happy birthday, KDE- 11 applications you never knew existed.md @geekpi --- ...- 11 applications you never knew existed.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md b/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md index 3e357e99aa..6dc68f2983 100644 --- a/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md +++ b/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md @@ -1,16 +1,16 @@ -生日快乐,KDE:你从不知道的 11 个应用 +你从不知道的 11 个 KDE 应用 ====== -你今天需要哪种有趣或奇特的应用? + +> 你今天需要哪种有趣或奇特的应用? + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BIZ_DebucketizeOrgChart_A.png?itok=RB3WBeQQ) -Linux 桌面环境 KDE 将于今年 10 月 14 日庆祝诞生 22 周年。KDE 社区用户创建了大量应用,它们很多都提供有趣和奇特的服务。我们仔细看了该列表,并挑选出了你可能想了解的 11 个应用。 - -没有很多,但[也有不少][1]。 +Linux 桌面环境 KDE 于今年 10 月 14 日庆祝诞生 22 周年。KDE 社区用户创建了海量应用(并没有很多,但[也有不少][1]),它们很多都提供有趣和奇特的服务。我们仔细看了该列表,并挑选出了你可能想了解的 11 个应用。 ### 11 个你从没了解的 KDE 应用 -1. [KTeaTime][2] 是一个泡茶计时器。选择你正在饮用的茶的类型 - 绿茶、红茶、凉茶等 - 当可以取出茶包来饮用时,计时器将会响。 -2. [KTux][3] 就是一个屏保程序......是么?Tux 用他的绿色飞船在外太空飞行。 +1. [KTeaTime][2] 是一个泡茶计时器。选择你正在饮用的茶的类型 —— 绿茶、红茶、凉茶等 —— 当可以取出茶包来饮用时,计时器将会响。 +2. [KTux][3] 就是一个屏保程序……是么?Tux 用它的绿色飞船在外太空飞行。 3. [Blinken][4] 是一款基于 Simon Says 的记忆游戏,这是一个 1978 年发布的电子游戏。玩家们在记住长度增加的序列时会有挑战。 4. [Tellico][5] 是一个收集管理器,用于组织你最喜欢的爱好。也许你还在收集棒球卡。也许你是红酒俱乐部的一员。也许你是一个严肃的书虫。也许三个都是! 5. [KRecipes][6] **不是** 简单的食谱管理器。它还有很多其他功能!购物清单、营养素分析、高级搜索、菜谱评级、导入/导出各种格式等。 @@ -19,7 +19,7 @@ Linux 桌面环境 KDE 将于今年 10 月 14 日庆祝诞生 22 周年。KDE 8. [KDiamond][9] 类似于宝石迷阵或其他单人益智游戏,其中游戏的目标是搭建一定数量的相同类型的宝石或物体的行。这里是钻石。 9. [KolourPaint][10] 是一个非常简单的图像编辑工具,也可以用于创建简单的矢量图形。 10. [Kiriki][11] 是一款类似于 Yahtzee 的 2-6 名玩家的骰子游戏。 -11. [RSIBreak][12] 没有以 K 开头。什么!?它以“RSI”开头代表“重复性劳损” (Repetitive Strain Injury),这会在日复一日长时间使用鼠标和键盘后发生。这个应用会提醒你休息,并可以个性化,以满足你的需求。 +11. [RSIBreak][12] 居然没有以 K 开头!?它以“RSI”开头代表“重复性劳损Repetitive Strain Injury” ,这会在日复一日长时间使用鼠标和键盘后发生。这个应用会提醒你休息,并可以个性化定制,以满足你的需求。 -------------------------------------------------------------------------------- @@ -28,7 +28,7 @@ via: https://opensource.com/article/18/10/kde-applications 作者:[Opensource.com][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 1dfa80f2d4b1ff2e9f071f41b145ac2b3f2ea5a8 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 24 Oct 2018 15:20:23 +0800 Subject: [PATCH 148/158] PUB:20181012 Happy birthday, KDE- 11 applications you never knew existed.md @geekpi https://linux.cn/article-10148-1.html --- ...Happy birthday, KDE- 11 applications you never knew existed.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20181012 Happy birthday, KDE- 11 applications you never knew existed.md (100%) diff --git a/translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md b/published/20181012 Happy birthday, KDE- 11 applications you never knew existed.md similarity index 100% rename from translated/tech/20181012 Happy birthday, KDE- 11 applications you never knew existed.md rename to published/20181012 Happy birthday, KDE- 11 applications you never knew existed.md From 480959ecbd1f11db2bc12d5c03bc3419d57c5a29 Mon Sep 17 00:00:00 2001 From: "Xingyu.Wang" Date: Wed, 24 Oct 2018 15:29:16 +0800 Subject: [PATCH 149/158] Update identify.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改算术语法错误 --- scripts/check/identify.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check/identify.sh b/scripts/check/identify.sh index 195ca4b669..f8e4c44160 100644 --- a/scripts/check/identify.sh +++ b/scripts/check/identify.sh @@ -51,7 +51,7 @@ rule_translation_revised() { # 发布译文:发布多篇译文 rule_translation_published() { [ "$TSL_D" -ge 1 ] && [ "$PUB_A" -ge 1 ] && [ "$TSL_D" -eq "$PUB_A" ] \ - && [ "$TOTAL" -eq $(("$TSL_D" + "$PUB_A")) ] \ + && [ "$TOTAL" -eq $(($TSL_D + $PUB_A)) ] \ && echo "匹配规则:发布译文 ${PUB_A} 篇" } From 88402f6db346c749b8a581f911a46a6b95d221ea Mon Sep 17 00:00:00 2001 From: dianbanjiu Date: Wed, 24 Oct 2018 15:40:03 +0800 Subject: [PATCH 150/158] translating --- .../tech/20181022 How to set up WordPress on a Raspberry Pi.md | 1 + 1 file changed, 1 insertion(+) diff --git a/sources/tech/20181022 How to set up WordPress on a Raspberry Pi.md b/sources/tech/20181022 How to set up WordPress on a Raspberry Pi.md index dcdec2d558..66fc1dede0 100644 --- a/sources/tech/20181022 How to set up WordPress on a Raspberry Pi.md +++ b/sources/tech/20181022 How to set up WordPress on a Raspberry Pi.md @@ -1,3 +1,4 @@ +translating by dianbanjiu How to set up WordPress on a Raspberry Pi ====== From 7efdb2a13d4db9e01bd4856f24eae68e1300ce03 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 24 Oct 2018 15:59:18 +0800 Subject: [PATCH 151/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Learning=20BASIC?= =?UTF-8?q?=20Like=20It's=201983?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../20180902 Learning BASIC Like It-s 1983.md | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 sources/tech/20180902 Learning BASIC Like It-s 1983.md diff --git a/sources/tech/20180902 Learning BASIC Like It-s 1983.md b/sources/tech/20180902 Learning BASIC Like It-s 1983.md new file mode 100644 index 0000000000..5790ef6e88 --- /dev/null +++ b/sources/tech/20180902 Learning BASIC Like It-s 1983.md @@ -0,0 +1,184 @@ +Learning BASIC Like It's 1983 +====== +I was not yet alive in 1983. This is something that I occasionally regret. I am especially sorry that I did not experience the 8-bit computer era as it was happening, because I think the people that first encountered computers when they were relatively simple and constrained have a huge advantage over the rest of us. + +Today, (almost) everyone knows how to use a computer, but very few people, even in the computing industry, grasp all of what is going on inside of any single machine. There are now [so many layers of software][1] doing so many different things that one struggles to identify the parts that are essential. In 1983, though, home computers were unsophisticated enough that a diligent person could learn how a particular computer worked through and through. That person is today probably less mystified than I am by all the abstractions that modern operating systems pile on top of the hardware. I expect that these layers of abstractions were easy to understand one by one as they were introduced; today, new programmers have to try to understand them all by working top to bottom and backward in time. + +Many famous programmers, particularly in the video game industry, started programming games in childhood on 8-bit computers like the Apple II and the Commodore 64. John Romero, Richard Garriott, and Chris Roberts are all examples. It’s easy to see how this happened. In the 8-bit computer era, many games were available only as printed BASIC listings in computer magazines and [books][2]. If you wanted to play one of those games, you had to type in the whole program by hand. Inevitably, you would get something wrong, so you would have to debug your program. By the time you got it working, you knew enough about how the program functioned to start modifying it yourself. If you were an avid gamer, you became a good programmer almost by necessity. + +I also played computer games throughout my childhood. But the games I played came on CD-ROMs. I sometimes found myself having to google how to fix a crashing installer, which would involve editing the Windows Registry or something like that. This kind of minor troubleshooting may have made me comfortable enough with computers to consider studying computer science in college. But it never taught me anything crucial about how computers worked or how to control them. + +Now, of course, I tell computers what to do for a living. All the same, I can’t help feeling that I missed out on some fundamental insight afforded only to those that grew up programming simpler computers. What would it have been like to encounter computers for the first time in the early 1980s? How would that have been different from the experience of using a computer today? + +This post is going to be a little different from the usual Two-Bit History post because I’m going to try to imagine an answer to these questions. + +### 1983 + +It was just last week that you saw [the Commodore 64 ad][3] on TV. Now that M*A*S*H was over, you were in the market for something new to do on Monday nights. This Commodore 64 thing looked even better than the Apple II that Rudy’s family had in their basement. Plus, the ad promised that the new computer would soon bring friends “knocking down” your door. You knew several people at school that would rather be hanging out at your house than Rudy’s anyway, if only they could play Zork there. + +So you persuaded your parents to buy one. Your mother said that they would consider it only if having a home computer meant that you stayed away from the arcade. You reluctantly agreed. Your father thought he would start tracking the family’s finances in MultiPlan, the spreadsheet program he had heard about, which is why the computer got put in the living room. A year later, though, you would be the only one still using it. You were finally allowed to put it on the desk in your bedroom, right under your Police poster. + +(Your sister protested this decision, but it was 1983 and computers [weren’t for her][4].) + +Dad picked it up from [ComputerLand][5] on the way home from work. The two of you laid the box down next to the TV and opened it. “WELCOME TO THE WORLD OF FRIENDLY COMPUTING,” said the packaging. Twenty minutes later, you weren’t convinced—the two of you were still trying to connect the Commodore to the TV set and wondering whether the TV’s antenna cable was the 75-ohm or 300-ohm coax type. But eventually you were able to turn your TV to channel 3 and see a grainy, purple image. + +![Commodore 64 startup screen][6] + +`READY`, the computer reported. Your father pushed the computer toward you, indicating that you should be the first to give it a try. `HELLO`, you typed, carefully hunting for each letter. The computer’s response was baffling. + +![Commodore 64 syntax error][7] + +You tried typing in a few different words, but the response was always the same. Your father said that you had better read through the rest of the manual. That would be no mean feat—[the manual that came with the Commodore 64][8] was a small book. But that didn’t bother you, because the introduction to the manual foreshadowed wonders. + +The Commodore 64, it claimed, had “the most advanced picture maker in the microcomputer industry,” which would allow you “to design your own pictures in four different colors, just like the ones you see on arcade type video games.” The Commodore 64 also had “built-in music and sound effects that rival many well known music synthesizers.” All of these tools would be put in your hands, because the manual would walk you through it all: + +> Just as important as all the available hardware is the fact that this USER’S GUIDE will help you develop your understanding of computers. It won’t tell you everything there is to know about computers, but it will refer you to a wide variety of publications for more detailed information about the topics presented. Commodore wants you to really enjoy your new COMMODORE 64. And to have fun, remember: programming is not the kind of thing you can learn in a day. Be patient with yourself as you go through the USER’S GUIDE. + +That night, in bed, you read through the entire first three chapters—”Setup,” “Getting Started,” and “Beginning BASIC Programming”—before finally succumbing to sleep with the manual splayed across your chest. + +### Commodore BASIC + +Now, it’s Saturday morning and you’re eager to try out what you’ve learned. One of the first things the manual teaches you how to do is change the colors on the display. You follow the instructions, pressing `CTRL-9` to enter reverse type mode and then holding down the space bar to create long lines. You swap between colors using `CTRL-1` through `CTRL-8`, reveling in your sudden new power over the TV screen. + +![Commodore 64 color bands][9] + +As cool as this is, you realize it doesn’t count as programming. In order to program the computer, you learned last night, you have to speak to it in a language called BASIC. To you, BASIC seems like something out of Star Wars, but BASIC is, by 1983, almost two decades old. It was invented by two Dartmouth professors, John Kemeny and Tom Kurtz, who wanted to make computing accessible to undergraduates in the social sciences and humanities. It was widely available on minicomputers and popular in college math classes. It then became standard on microcomputers after Bill Gates and Paul Allen wrote the MicroSoft BASIC interpreter for the Altair. But the manual doesn’t explain any of this and you won’t learn it for many years. + +One of the first BASIC commands the manual suggests you try is the `PRINT` command. You type in `PRINT "COMMODORE 64"`, slowly, since it takes you a while to find the quotation mark symbol above the `2` key. You hit `RETURN` and this time, instead of complaining, the computer does exactly what you told it to do and displays “COMMODORE 64” on the next line. + +Now you try using the `PRINT` command on all sorts of different things: two numbers added together, two numbers multiplied together, even several decimal numbers. You stop typing out `PRINT` and instead use `?`, since the manual has advised you that `?` is an abbreviation for `PRINT` often used by expert programmers. You feel like an expert already, but then you remember that you haven’t even made it to chapter three, “Beginning BASIC Programming.” + +You get there soon enough. The chapter begins by prompting you to write your first real BASIC program. You type in `NEW` and hit `RETURN`, which gives you a clean slate. You then type your program in: + +``` +10 ?"COMMODORE 64" +20 GOTO 10 +``` + +The 10 and the 20, the manual explains, are line numbers. They order the statements for the computer. They also allow the programmer to refer to other lines of the program in certain commands, just like you’ve done here with the `GOTO` command, which directs the program back to line 10. “It is good programming practice,” the manual opines, “to number lines in increments of 10—in case you need to insert some statements later on.” + +You type `RUN` and stare as the screen clogs with “COMMODORE 64,” repeated over and over. + +![Commodore 64 showing result of printing "Commodore 64" repeatedly][10] + +You’re not certain that this isn’t going to blow up your computer. It takes you a second to remember that you are supposed to hit the `RUN/STOP` key to break the loop. + +The next few sections of the manual teach you about variables, which the manual tells you are like “a number of boxes within the computer that can each hold a number or a string of text characters.” Variables that end in a `%` symbol are whole numbers, while variables ending in a `$` symbol are strings of characters. All other variables are something called “floating point” variables. The manual warns you to be careful with variable names because only the first two letters of the name are actually recognized by the computer, even though nothing stops you from making a name as long as you want it to be. (This doesn’t particularly bother you, but you could see how 30 years from now this might strike someone as completely insane.) + +You then learn about the `IF... THEN...` and `FOR... NEXT...` constructs. With all these new tools, you feel equipped to tackle the next big challenge the manual throws at you. “If you’re the ambitious type,” it goads, “type in the following program and see what happens.” The program is longer and more complicated than any you have seen so far, but you’re dying to know what it does: + +``` +10 REM BOUNCING BALL +20 PRINT "{CLR/HOME}" +25 FOR X = 1 TO 10 : PRINT "{CRSR/DOWN}" : NEXT +30 FOR BL = 1 TO 40 +40 PRINT " ●{CRSR LEFT}";:REM (● is a Shift-Q) +50 FOR TM = 1 TO 5 +60 NEXT TM +70 NEXT BL +75 REM MOVE BALL RIGHT TO LEFT +80 FOR BL = 40 TO 1 STEP -1 +90 PRINT " {CRSR LEFT}{CRSR LEFT}●{CRSR LEFT}"; +100 FOR TM = 1 TO 5 +110 NEXT TM +120 NEXT BL +130 GOTO 20 +``` + +The program above takes advantage of one of the Commodore 64’s coolest features. Non-printable command characters, when passed to the `PRINT` command as part of a string, just do the action they usually perform instead of printing to the screen. This allows you to replay arbitrary chains of commands by printing strings from within your programs. + +It takes you a long time to type in the above program. You make several mistakes and have to re-enter some of the lines. But eventually you are able to type `RUN` and behold a masterpiece: + +![Commodore 64 bouncing ball][11] + +You think that this is a major contender for the coolest thing you have ever seen. You forget about it almost immediately though, because once you’ve learned about BASIC’s built-in functions like `RND` (which returns a random number) and `CHR$` (which returns the character matching a given number code), the manual shows you a program that many years from now will still be famous enough to be made the title of an [essay anthology][12]: + +``` +10 PRINT "{CLR/HOME}" +20 PRINT CHR$(205.5 + RND(1)); +40 GOTO 20 +``` + +When run, the above program produces a random maze: + +![Commodore 64 maze program][13] + +This is definitely the coolest thing you have ever seen. + +### PEEK and POKE + +You’ve now made it through the first four chapters of the Commodore 64 manual, including the chapter titled “Advanced BASIC,” so you’re feeling pretty proud of yourself. You’ve learned a lot this Saturday morning. But this afternoon (after a quick lunch break), you’re going to learn something that will make this magical machine in your living room much less mysterious. + +The next chapter in the manual is titled “Advanced Color and Graphic Commands.” It starts off by revisiting the colored bars that you were able to type out first thing this morning and shows you how you can do the same thing from a program. It then teaches you how to change the background colors of the screen. + +In order to do this, you need to use the BASIC `PEEK` and `POKE` commands. Those commands allow you to, respectively, examine and write to a memory address. The Commodore 64 has a main background color and a border color. Each is controlled by a specially designated memory address. You can write any color value you would like to those addresses to make the background or border that color. + +The manual explains: + +> Just as variables can be thought of as a representation of “boxes” within the machine where you placed your information, you can also think of some specially defined “boxes” within the computer that represent specific memory locations. +> +> The Commodore 64 looks at these memory locations to see what the screen’s background and border color should be, what characters are to be displayed on the screen—and where—and a host of other tasks. + +You write a program to cycle through all the available combinations of background and border color: + +``` +10 FOR BA = 0 TO 15 +20 FOR BO = 0 TO 15 +30 POKE 53280, BA +40 POKE 53281, BO +50 FOR X = 1 TO 500 : NEXT X +60 NEXT BO : NEXT BA +``` + +While the `POKE` commands, with their big operands, looked intimidating at first, now you see that the actual value of the number doesn’t matter that much. Obviously, you have to get the number right, but all the number represents is a “box” that Commodore just happened to store at address 53280. This box has a special purpose: Commodore uses it to determine what color the screen’s background should be. + +![Commodore 64 changing background colors][14] + +You think this is pretty neat. Just by writing to a special-purpose box in memory, you can control a fundamental property of the computer. You aren’t sure how the Commodore 64’s circuitry takes the value you write in memory and changes the color of the screen, but you’re okay not knowing that. At least you understand everything up to that point. + +### Special Boxes + +You don’t get through the entire manual that Saturday, since you are now starting to run out of steam. But you do eventually read all of it. In the process, you learn about many more of the Commodore 64’s special-purpose boxes. There are boxes you can write to control what is on screen—one box, in fact, for every place a character might appear. In chapter six, “Sprite Graphics,” you learn about the special-purpose boxes that allow you to define images that can be moved around and even scaled up and down. In chapter seven, “Creating Sound,” you learn about the boxes you can write to in order to make your Commodore 64 sing “Michael Row the Boat Ashore.” The Commodore 64, it turns out, has very little in the way of what you would later learn is called an API. Controlling the Commodore 64 mostly involves writing to memory addresses that have been given special meaning by the circuitry. + +The many years you ultimately spend writing to those special boxes stick with you. Even many decades later, when you find yourself programming a machine with an extensive graphics or sound API, you know that, behind the curtain, the API is ultimately writing to those boxes or something like them. You will sometimes wonder about younger programmers that have only ever used APIs, and wonder what they must think the API is doing for them. Maybe they think that the API is calling some other, hidden API. But then what do think that hidden API is calling? You will pity those younger programmers, because they must be very confused indeed. + +If you enjoyed this post, more like it come out every two weeks! Follow [@TwoBitHistory][15] on Twitter or subscribe to the [RSS feed][16] to make sure you know when a new post is out. + +Previously on TwoBitHistory… + +> Have you ever wondered what a 19th-century computer program would look like translated into C? +> +> This week's post: A detailed look at how Ada Lovelace's famous program worked and what it was trying to do. +> +> — TwoBitHistory (@TwoBitHistory) [August 19, 2018][17] + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2018/09/02/learning-basic.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://www.youtube.com/watch?v=kZRE7HIO3vk +[2]: https://en.wikipedia.org/wiki/BASIC_Computer_Games +[3]: https://www.youtube.com/watch?v=ZekAbt2o6Ms +[4]: https://www.npr.org/sections/money/2014/10/21/357629765/when-women-stopped-coding +[5]: https://www.youtube.com/watch?v=MA_XtT3VAVM +[6]: https://twobithistory.org/images/c64_startup.png +[7]: https://twobithistory.org/images/c64_error.png +[8]: ftp://www.zimmers.net/pub/cbm/c64/manuals/C64_Users_Guide.pdf +[9]: https://twobithistory.org/images/c64_colors.png +[10]: https://twobithistory.org/images/c64_print_loop.png +[11]: https://twobithistory.org/images/c64_ball.gif +[12]: http://10print.org/ +[13]: https://twobithistory.org/images/c64_maze.gif +[14]: https://twobithistory.org/images/c64_background.gif +[15]: https://twitter.com/TwoBitHistory +[16]: https://twobithistory.org/feed.xml +[17]: https://twitter.com/TwoBitHistory/status/1030974776821665793?ref_src=twsrc%5Etfw From 23b1e4f84743a498d8e02630c560936a1553b401 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 24 Oct 2018 16:00:17 +0800 Subject: [PATCH 152/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20What=20Did=20Ada?= =?UTF-8?q?=20Lovelace's=20Program=20Actually=20Do=3F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... Did Ada Lovelace-s Program Actually Do.md | 138 ++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100644 sources/talk/20180818 What Did Ada Lovelace-s Program Actually Do.md diff --git a/sources/talk/20180818 What Did Ada Lovelace-s Program Actually Do.md b/sources/talk/20180818 What Did Ada Lovelace-s Program Actually Do.md new file mode 100644 index 0000000000..8bbb651cfd --- /dev/null +++ b/sources/talk/20180818 What Did Ada Lovelace-s Program Actually Do.md @@ -0,0 +1,138 @@ +What Did Ada Lovelace's Program Actually Do? +====== +The story of Microsoft’s founding is one of the most famous episodes in computing history. In 1975, Paul Allen flew out to Albuquerque to demonstrate the BASIC interpreter that he and Bill Gates had written for the Altair microcomputer. Because neither of them had a working Altair, Allen and Gates tested their interpreter using an emulator that they wrote and ran on Harvard’s computer system. The emulator was based on nothing more than the published specifications for the Intel 8080 processor. When Allen finally ran their interpreter on a real Altair—in front of the person he and Gates hoped would buy their software—he had no idea if it would work. But it did. The next month, Allen and Gates officially founded their new company. + +Over a century before Allen and Gates wrote their BASIC interpreter, Ada Lovelace wrote and published a computer program. She, too, wrote a program for a computer that had only been described to her. But her program, unlike the Microsoft BASIC interpreter, was never run, because the computer she was targeting was never built. + +Lovelace’s program is often called the world’s first computer program. Not everyone agrees that it should be called that. Lovelace’s legacy, it turns out, is one of computing history’s most hotly debated subjects. Walter Isaacson has written that the dispute about the extent and merit of her contributions constitutes a “minor academic specialty.” Inevitably, the fact that Lovelace was a woman has made this dispute a charged one. Historians have cited all kinds of primary evidence to argue that the credit given to Lovelace is either appropriate or undeserved. But they seem to spend less time explaining the technical details of her published writing, which is unfortunate, because the technical details are the most fascinating part of the story. Who wouldn’t want to know exactly how a program written in 1843 was supposed to work? + +In fairness, Lovelace’s program is not easy to explain to the layperson without some hand-waving. It’s the intricacies of her program, though, that make it so remarkable. Whether or not she ought to be known as “the first programmer,” her program was specified with a degree of rigor that far surpassed anything that came before. She thought carefully about how operations could be organized into groups that could be repeated, thereby inventing the loop. She realized how important it was to track the state of variables as they changed, introducing a notation to illustrate those changes. As a programmer myself, I’m startled to see how much of what Lovelace was doing resembles the experience of writing software today. + +So let’s take a closer look at Lovelace’s program. She designed it to calculate the Bernoulli numbers. To understand what those are, we have to go back a couple millennia to the genesis of one of mathematics’ oldest problems. + +### Sums of Powers + +The Pythagoreans lived on the shores of the Mediterranean and worshiped numbers. One of their pastimes was making triangles out of pebbles. + +![][1] + +One pebble followed by a row of two pebbles makes a triangle containing three pebbles. Add another row of three pebbles and you get a triangle containing six pebbles. You can continue like this, each time adding a row with one more pebble in it than the previous row. A triangle with six rows contains 21 pebbles. But how many pebbles does a triangle with 423 rows contain? + +What the Pythagoreans were looking for was a way to calculate the following without doing all the addition: + +They eventually realized that, if you place two triangles of the same size up against each other so that they form a rectangle, you can find the area of the rectangle and divide by two to get the number of pebbles in each of the triangles: + +![][2] + +Archimedes later explored a similar problem. He was interested in the following series: + +You might visualize this series by imagining a stack of progressively larger squares (made out of tiny cubes), one on top of the other, forming a pyramid. Archimedes wanted to know if there was an easy way to tell how many cubes would be needed to construct a pyramid with, say, 423 levels. He recorded a solution that also permits a geometrical interpretation. + +Three pyramids can be fit together to form a rectangular prism with a tiny, one-cube-high extrusion at one end. That little extrusion happens to be a triangle that obeys the same rules that the Pythagoreans used to make their pebble triangles. ([This video][3] might be a more helpful explanation of what I mean.) So the volume of the whole shape is given by the following equation: + +By substituting the Pythagorean equation for the sum of the first n integers and doing some algebra, you get this: + +In 499, the Indian mathematician and astronomer, Aryabhata, published a work known as the Aryabhatiya, which included a formula for calculating the sum of cubes: + +A formula for the sum of the first n positive integers raised to the fourth power wasn’t published for another 500 years. + +You might be wondering at this point if there is a general method for finding the sum of the first n integers raised to the kth power. Mathematicians were wondering too. Johann Faulhaber, a German mathematician and slightly kooky numerologist, was able to calculate formulas for sums of integers up to the 17th power, which he published in 1631. But this may have taken him years and he did not state a general solution. Blaise Pascal finally outlined a general method in 1665, though it depended on first knowing how to calculate the sum of integers raised to every lesser power. To calculate the sum of the first n positive integers raised to the sixth power, for example, you would first have to know how to calculate the sum of the first n positive integers raised to the fifth power. + +A more practical general solution was stated in the posthumously published work of Swiss mathematician Jakob Bernoulli, who died in 1705. Bernoulli began by deriving the formulas for calculating the sums of the first n positive integers to the first, second, and third powers. These he gave in polynomial form, so they looked like the below: + +Using Pascal’s Triangle, Bernoulli realized that these polynomials followed a predictable pattern. Essentially, Bernoulli broke the coefficients of each term down into two factors, one of which he could determine using Pascal’s Triangle and the other which he could derive from the interesting property that all the coefficients in the polynomial seemed to always add to one. Figuring out the exponent that should be attached to each term was no problem, because that also followed a predictable pattern. The factor of each coefficient that had to be calculated using the sums-to-one rule formed a sequence that became known as the Bernoulli numbers. + +Bernoulli’s discovery did not mean that it was now trivial to calculate the sum of the first positive n integers to any given power. In order to calculate the sum of the first positive n integers raised to the kth power, you would need to know every Bernoulli number up to the kth Bernoulli number. Each Bernoulli number could only be calculated if the previous Bernoulli numbers were known. But calculating a long series of Bernoulli numbers was significantly easier than deriving each sum of powers formula in turn, so Bernoulli’s discovery was a big advance for mathematics. + +### Babbage + +Charles Babbage was born in 1791, nearly a century after Bernoulli died. I’ve always had some vague idea that Babbage designed but did not build a mechanical computer. But I’ve never entirely understood how that computer was supposed to work. The basic ideas, as it happens, are not that difficult to grasp, which is good news. Lovelace’s program was designed to run on one of Babbage’s machines, so we need to take another quick detour here to talk about how those machines worked. + +Babbage designed two separate mechanical computing machines. His first machine was called the Difference Engine. Before the invention of the pocket calculator, people relied on logarithmic tables to calculate the product of large numbers. (There is a good [Numberphile video][4] on how this was done.) Large logarithmic tables are not difficult to create, at least conceptually, but the sheer number of calculations that need to be done in order to create them meant that in Babbage’s time they often contained errors. Babbage, frustrated by this, sought to create a machine that could tabulate logarithms mechanically and therefore without error. + +The Difference Engine was not a computer, because all it did was add and subtract. It took advantage of a method devised by the French mathematician Gaspard de Prony that broke the process of tabulating logarithms down into small steps. These small steps involved only addition and subtraction, meaning that a small army of people without any special mathematical aptitude or training could be employed to produce a table. De Prony’s method, known as the method of divided differences, could be used to tabulate any polynomial. Polynomials, in turn, could be used to approximate logarithmic and trigonometric functions. + +To get a sense of how this process worked, consider the following simple polynomial function: + +The method of divided differences involves finding the difference between each successive value of y for different values of x. The differences between these differences are then found, and possibly the differences between those next differences themselves, until a constant difference appears. These differences can then be used to get the next value of the polynomial simply by adding. + +Because the above polynomial is only a second-degree polynomial, we are able to find the constant difference after only two columns of differences: + +x y Diff 1 Diff 2 1 2 2 5 3 3 10 5 2 4 17 7 2 5 ? ? 2 … … … … + +Now, since we know that the constant difference is 2, we can find the value of y when x is 5 through addition only. If we add 2 to 7, the last entry in the “Diff 1” column, we get 9. If we add 9 to 17, the last entry in the y column, we get 26, our answer. + +Babbage’s Difference Engine had, for each difference column in a table like the one above, a physical column of gears. Each gear was a decimal digit and one whole column was a decimal number. The Difference Engine had eight columns of gears, so it could tabulate a polynomial up to the seventh degree. The columns were initially set with values matching an early row in the difference table, worked out ahead of time. A human operator would then turn a crank shaft, causing the constant difference to propagate through the machine as the value stored on each column was added to the next. + +Babbage was able to build a small section of the Difference Engine and use it to demonstrate his ideas at parties. But even after spending an amount of public money equal to the cost of two large warships, he never built the entire machine. Babbage could not find anyone in the early 1800s that could make the number of gears he needed with sufficient accuracy. A working Difference Engine would not be built until the 1990s, after the advent of precision machining. There is [a great video on YouTube][5] demonstrating a working Difference Engine on loan to the Computer History Museum in Mountain View, which is worth watching even just to listen to the marvelous sounds the machine makes while it runs. + +Babbage eventually lost interest in the Difference Engine when he realized that a much more powerful and flexible machine could be built. His Analytical Engine was the machine that we know today as Babbage’s mechanical computer. The Analytical Engine was based on the same columns of gears used in the Difference Engine, but whereas the Difference Engine only had eight columns, the Analytical Engine was supposed to have many hundreds more. The Analytical Engine could be programmed using punched cards like a Jacquard Loom and could multiply and divide as well as add and subtract. In order to perform one of these operations, a section of the machine called the “mill” would rearrange itself into the appropriate configuration, read the operands off of other columns used for data storage, and then write the result back to another column. + +Babbage called his new machine the Analytical Engine because it was powerful enough to do something resembling mathematical analysis. The Difference Engine could tabulate a polynomial, but the Analytical Engine would be able to calculate, for example, the coefficients of the polynomial expansion of another expression. It was an amazing machine, but the British government wisely declined to fund its construction. So Babbage went abroad to Italy to try to drum up support for his idea. + +### Notes by The Translator + +In Turin, Babbage met Italian engineer and future prime minister Luigi Menabrea. He persuaded Menabrea to write an outline of what the Analytical Engine could accomplish. In 1842, Menabrea published a paper on the topic in French. The following year, Lovelace published a translation of Menabrea’s paper into English. + +Lovelace, then known as Ada Byron, first met Babbage at a party in 1833, when she was 17 and he was 41. Lovelace was fascinated with Babbage’s Difference Engine. She could also understand how it worked, because she had been extensively tutored in mathematics throughout her childhood. Her mother, Annabella Milbanke, had decided that a solid grounding in mathematics would ward off the wild, romantic sensibility that possessed Lovelace’s father, Lord Byron, the famous poet. After meeting in 1833, Lovelace and Babbage remained a part of the same social circle and wrote to each other frequently. + +Ada Byron married William King in 1835. King later became the Earl of Lovelace, making Ada the Countess of Lovelace. Even after having three children, she continued her education in mathematics, employing Augustus de Morgan, who discovered De Morgan’s laws, as her tutor. Lovelace saw the potential of Babbage’s Analytical Machine immediately and was eager to work with him to promote the idea. A friend suggested that she translate Menabrea’s paper for an English audience. + +Menabrea’s paper gave a brief overview of how the Difference Engine worked, then showed how the Analytical Engine would be a far superior machine. The Analytical Engine would be so powerful that it could “form the product of two numbers, each containing twenty figures, in three minutes” (emphasis in the original). Menabrea gave further examples of the machine’s capabilities, demonstrating how it could solve a simple system of linear equations and expand the product of two binomial expressions. In both cases, Menabrea provided what Lovelace called “diagrams of development,” which listed the sequence of operations that would need to be performed to calculate the correct answer. These were programs in the same sense that Lovelace’s own program was a program and they were originally published the year before. But as we will see, Menabrea’s programs were only simple examples of what was possible. All of them were trivial in the sense that they did not require any kind of branching or looping. + +Lovelace appended a series of notes to her translation of Menabrea’s paper that together ran much longer than the original work. It was here that she made her major contributions to computing. In Note A, which Lovelace attached to Menabrea’s initial description of the Analytical Engine, Lovelace explained at some length and often in lyrical language the promise of a machine that could perform arbitrary mathematical operations. She foresaw that a machine like the Analytical Engine wasn’t just limited to numbers and could in fact act on any objects “whose mutual fundamental relations could be expressed by those of the abstract science of operations, and which should be also susceptible of adaptations to the action of the operating notation and mechanism of the engine.” She added that the machine might one day, for example, compose music. This insight was all the more remarkable given that Menabrea saw the Analytical Engine primarily as a tool for automating “long and arid computation,” which would free up the intellectual capacities of brilliant scientists for more advanced thinking. The miraculous foresight that Lovelace demonstrated in Note A is one major reason that she is celebrated today. + +The other famous note is Note G. Lovelace begins Note G by arguing that, despite its impressive powers, the Analytical Machine cannot really be said to “think.” This part of Note G is what Alan Turing would later refer to as “Lady Lovelace’s Objection.” Nevertheless, Lovelace continues, the machine can do extraordinary things. To illustrate its ability to handle even more complex problems, Lovelace provides her program calculating the Bernoulli numbers. + +The full program, in the expanded “diagram of development” format that Lovelace explains in Note D, can be seen [here][6]. The program is essentially a list of operations, specified using the usual mathematical symbols. It doesn’t appear that Babbage or Lovelace got as far as developing anything like a set of op codes for the Analytical Engine. + +Though Lovelace was describing a method for computing the entire sequence of Bernoulli numbers up to some limit, the program she provided only illustrated one step of that process. Her program calculated a number that she called B7, which modern mathematicians know as the eighth Bernoulli number. Her program thus sought to solve the following equation: + +In the above, each term represents a coefficient in the polynomial formula for the sum of integers to a particular power. Here that power is eight, since the eighth Bernoulli number first appears in the formula for the sum of positive integers to the eighth power. The B and A numbers represent the two kinds of factors that Bernoulli discovered. B1 through B7 are all different Bernoulli numbers, indexed according to Lovelace’s indexing. A0 through A5 represent the factors of the coefficients that Bernoulli could calculate using Pascal’s Triangle. The values of A0, A1, A3, and A5 appear below. Here n represents the index of the Bernoulli number in the sequence of odd-numbered Bernoulli numbers starting with the first. Lovelace’s program used n = 4. + +I’ve created a [translation][7] of Lovelace’s program into C, which may be easier to follow. Lovelace’s program first calculates A0 and the product B1A1. It then enters a loop that repeats twice to calculate B3A3 and B5A5, since those are formed according to an identical pattern. After each product is calculated, it is added with all the previous products, so that by the end of the program the full sum has been obtained. + +Obviously the C translation is not an exact recreation of Lovelace’s program. It declares variables on the stack, for example, whereas Lovelace’s variables were more like registers. But it makes obvious the parts of Lovelace’s program that were so prescient. The C program contains two `while` loops, one nested inside the other. Lovelace’s program did not have `while` loops exactly, but she made groups of operations and in the text of her note specified when they should repeat. The variable `v10`, in the original program and in the C translation, functions as a counter variable that decrements with each loop, a construct any programmer would be familiar with. In fact, aside from the profusion of variables with unhelpful names, the C translation of Lovelace’s program doesn’t look that alien at all. + +The other thing worth mentioning quickly is that translating Lovelace’s program into C was not that difficult, thanks to the detail present in her diagram. Unlike Menabrea’s tables, her table includes a column labeled “Indication of change in the value on any Variable,” which makes it much easier to follow the mutation of state throughout the program. She adds a superscript index here to each variable to indicate the successive values they hold. A superscript of two, for example, means that the value being used here is the second value that has been assigned to the variable since the beginning of the program. + +### The First Programmer? + +After I had translated Lovelace’s program into C, I was able to run it on my own computer. To my frustration, I kept getting the wrong result. After some debugging, I finally realized that the problem wasn’t the code that I had written. The bug was in the original! + +In her “diagram of development,” Lovelace gives the fourth operation as `v5 / v4`. But the correct ordering here is `v4 / v5`. This may well have been a typesetting error and not an error in the program that Lovelace devised. All the same, this must be the oldest bug in computing. I marveled that, for ten minutes or so, unknowingly, I had wrestled with this first ever bug. + +Jim Randall, another blogger that has [translated Lovelace’s program into Python][8], has noted this division bug and two other issues. What does it say about Ada Lovelace that her published program contains minor bugs? Perhaps it shows that she was attempting to write not just a demonstration but a real program. After all, can you really be writing anything more than toy programs if you aren’t also writing lots of bugs? + +One Wikipedia article calls Lovelace the first to publish a “complex program.” Maybe that’s the right way to think about Lovelace’ accomplishment. Menabrea published “diagrams of development” in his paper a year before Lovelace published her translation. Babbage also wrote more than twenty programs that he never published. So it’s not quite accurate to say that Lovelace wrote or published the first program, though there’s always room to quibble about what exactly constitutes a “program.” Even so, Lovelace’s program was miles ahead of anything else that had been published before. The longest program that Menabrea presented was 11 operations long and contained no loops or branches; Lovelace’s program contains 25 operations and a nested loop (and thus branching). Menabrea wrote the following toward the end of his paper: + +> When once the engine shall have been constructed, the difficulty will be reduced to the making of the cards; but as these are merely the translation of algebraic formulae, it will, by means of some simple notation, be easy to consign the execution of them to a workman. + +Neither Babbage nor Menabrea were especially interested in applying the Analytical Engine to problems beyond the immediate mathematical challenges that first drove Babbage to construct calculating machines. Lovelace saw that the Analytical Engine was capable of much more than Babbage or Menabrea could imagine. Lovelace also grasped that “the making of the cards” would not be a mere afterthought and that it could be done well or done poorly. This is hard to appreciate without understanding her program from Note G and seeing for oneself the care she put into designing it. But having done that, you might agree that Lovelace, even if she was not the very first programmer, was the first programmer to deserve the title. + +If you enjoyed this post, more like it come out every two weeks! Follow [@TwoBitHistory][9] on Twitter or subscribe to the [RSS feed][10] to make sure you know when a new post is out. + + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2018/08/18/ada-lovelace-note-g.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://twobithistory.org/images/triangular_numbers1.png +[2]: https://twobithistory.org/images/triangular_numbers2.png +[3]: https://www.youtube.com/watch?v=aXbT37IlyZQ +[4]: https://youtu.be/VRzH4xB0GdM +[5]: https://www.youtube.com/watch?v=BlbQsKpq3Ak +[6]: https://upload.wikimedia.org/wikipedia/commons/c/cf/Diagram_for_the_computation_of_Bernoulli_numbers.jpg +[7]: https://gist.github.com/sinclairtarget/ad18ac65d277e453da5f479d6ccfc20e +[8]: https://enigmaticcode.wordpress.com/tag/bernoulli-numbers/ +[9]: https://twitter.com/TwoBitHistory +[10]: https://twobithistory.org/feed.xml From 4c3f2ba5441d6a4ab520fe1018eb57c3cdc3d7b4 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 24 Oct 2018 16:00:46 +0800 Subject: [PATCH 153/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Where=20Vim=20Cam?= =?UTF-8?q?e=20From?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/talk/20180805 Where Vim Came From.md | 116 +++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 sources/talk/20180805 Where Vim Came From.md diff --git a/sources/talk/20180805 Where Vim Came From.md b/sources/talk/20180805 Where Vim Came From.md new file mode 100644 index 0000000000..d3cf1abe82 --- /dev/null +++ b/sources/talk/20180805 Where Vim Came From.md @@ -0,0 +1,116 @@ +Where Vim Came From +====== +I recently stumbled across a file format known as Intel HEX. As far as I can gather, Intel HEX files (which use the `.hex` extension) are meant to make binary images less opaque by encoding them as lines of hexadecimal digits. Apparently they are used by people who program microcontrollers or need to burn data into ROM. In any case, when I opened up a HEX file in Vim for the first time, I discovered something shocking. Here was this file format that, at least to me, was deeply esoteric, but Vim already knew all about it. Each line of a HEX file is a record divided into different fields—Vim had gone ahead and colored each of the fields a different color. `set ft?` I asked, in awe. `filetype=hex`, Vim answered, triumphant. + +Vim is everywhere. It is used by so many people that something like HEX file support shouldn’t be a surprise. Vim comes pre-installed on Mac OS and has a large constituency in the Linux world. It is familiar even to people that hate it, because enough popular command line tools will throw users into Vim by default that the uninitiated getting trapped in Vim has become [a meme][1]. There are major websites, including Facebook, that will scroll down when you press the `j` key and up when you press the `k` key—the unlikely high-water mark of Vim’s spread through digital culture. + +And yet Vim is also a mystery. Unlike React, for example, which everyone knows is developed and maintained by Facebook, Vim has no obvious sponsor. Despite its ubiquity and importance, there doesn’t seem to be any kind of committee or organization that makes decisions about Vim. You could spend several minutes poking around the [Vim website][2] without getting a better idea of who created Vim or why. If you launch Vim without giving it a file argument, then you will see Vim’s startup message, which says that Vim is developed by “Bram Moolenaar et al.” But that doesn’t tell you much. Who is Bram Moolenaar and who are his shadowy confederates? + +Perhaps more importantly, while we’re asking questions, why does exiting Vim involve typing `:wq`? Sure, it’s a “write” operation followed by a “quit” operation, but that is not a particularly intuitive convention. Who decided that copying text should instead be called “yanking”? Why is `:%s/foo/bar/gc` short for “find and replace”? Vim’s idiosyncrasies seem too arbitrary to have been made up, but then where did they come from? + +The answer, as is so often the case, begins with that ancient crucible of computing, Bell Labs. In some sense, Vim is only the latest iteration of a piece of software—call it the “wq text editor”—that has been continuously developed and improved since the dawn of the Unix epoch. + +### Ken Thompson Writes a Line Editor + +In 1966, Bell Labs hired Ken Thompson. Thompson had just completed a Master’s degree in Electrical Engineering and Computer Science at the University of California, Berkeley. While there, he had used a text editor called QED, written for the Berkeley Timesharing System between 1965 and 1966. One of the first things Thompson did after arriving at Bell Labs was rewrite QED for the MIT Compatible Time-Sharing System. He would later write another version of QED for the Multics project. Along the way, he expanded the program so that users could search for lines in a file and make substitutions using regular expressions. + +The Multics project, which like the Berkeley Timesharing System sought to create a commercially viable time-sharing operating system, was a partnership between MIT, General Electric, and Bell Labs. AT&T eventually decided the project was going nowhere and pulled out. Thompson and fellow Bell Labs researcher Dennis Ritchie, now without access to a time-sharing system and missing the “feel of interactive computing” that such systems offered, set about creating their own version, which would eventually be known as Unix. In August 1969, while his wife and young son were away on vacation in California, Thompson put together the basic components of the new system, allocating “a week each to the operating system, the shell, the editor, and the assembler.” + +The editor would be called `ed`. It was based on QED but was not an exact re-implementation. Thompson decided to ditch certain QED features. Regular expression support was pared back so that only relatively simple regular expressions would be understood. QED allowed users to edit several files at once by opening multiple buffers, but `ed` would only work with one buffer at a time. And whereas QED could execute a buffer containing commands, `ed` would do no such thing. These simplifications may have been called for. Dennis Ritchie has said that going without QED’s advanced regular expressions was “not much of a loss.” + +`ed` is now a part of the POSIX specification, so if you have a POSIX-compliant system, you will have it installed on your computer. It’s worth playing around with, because many of the `ed` commands are today a part of Vim. In order to write a buffer to disk, for example, you have to use the `w` command. In order to quit the editor, you have to use the `q` command. These two commands can be specified on the same line at once—hence, `wq`. Like Vim, `ed` is a modal editor; to enter input mode from command mode you would use the insert command (`i`), the append command (`a`), or the change command (`c`), depending on how you are trying to transform your text. `ed` also introduced the `s/foo/bar/g` syntax for finding and replacing, or “substituting,” text. + +Given all these similarities, you might expect the average Vim user to have no trouble using `ed`. But `ed` is not at all like Vim in another important respect. `ed` is a true line editor. It was written and widely used in the days of the teletype printer. When Ken Thompson and Dennis Ritchie were hacking away at Unix, they looked like this: + +![Ken Thompson interacting with a PDP-11 via teletype.][3] + +`ed` doesn’t allow you to edit lines in place among the other lines of the open buffer, or move a cursor around, because `ed` would have to reprint the entire file every time you made a change to it. There was no mechanism in 1969 for `ed` to “clear” the contents of the screen, because the screen was just a sheet of paper and everything that had already been output had been output in ink. When necessary, you can ask `ed` to print out a range of lines for you using the list command (`l`), but most of the time you are operating on text that you can’t see. Using `ed` is thus a little trying to find your way around a dark house with an underpowered flashlight. You can only see so much at once, so you have to try your best to remember where everything is. + +Here’s an example of an `ed` session. I’ve added comments (after the `#` character) explaining the purpose of each line, though if these were actually entered `ed` wouldn’t recognize them as comments and would complain: + +``` +[sinclairtarget 09:49 ~]$ ed +i # Enter input mode +Hello world! + +Isn't it a nice day? +. # Finish input +1,2l # List lines 1 to 2 +Hello world!$ +$ +2d # Delete line 2 +,l # List entire buffer +Hello world!$ +Isn't it a nice day?$ +s/nice/terrible/g # Substitute globally +,l +Hello world!$ +Isn't it a terrible day?$ +w foo.txt # Write to foo.txt +38 # (bytes written) +q # Quit +[sinclairtarget 10:50 ~]$ cat foo.txt +Hello world! +Isn't it a terrible day? +``` + +As you can see, `ed` is not an especially talkative program. + +### Bill Joy Writes a Text Editor + +`ed` worked well enough for Thompson and Ritchie. Others found it difficult to use and it acquired a reputation for being a particularly egregious example of Unix’s hostility toward the novice. In 1975, a man named George Coulouris developed an improved version of `ed` on the Unix system installed at Queen Mary’s College, London. Coulouris wrote his editor to take advantage of the video displays that he had available at Queen Mary’s. Unlike `ed`, Coulouris’ program allowed users to edit a single line in place on screen, navigating through the line keystroke by keystroke (imagine using Vim on one line at a time). Coulouris called his program `em`, or “editor for mortals,” which he had supposedly been inspired to do after Thompson paid a visit to Queen Mary’s, saw the program Coulouris had built, and dismissed it, saying that he had no need to see the state of a file while editing it. + +In 1976, Coulouris brought `em` with him to UC Berkeley, where he spent the summer as a visitor to the CS department. This was exactly ten years after Ken Thompson had left Berkeley to work at Bell Labs. At Berkeley, Coulouris met Bill Joy, a graduate student working on the Berkeley Software Distribution (BSD). Coulouris showed `em` to Joy, who, starting with Coulouris’ source code, built out an improved version of `ed` called `ex`, for “extended `ed`.” Version 1.1 of `ex` was bundled with the first release of BSD Unix in 1978. `ex` was largely compatible with `ed`, but it added two more modes: an “open” mode, which enabled single-line editing like had been possible with `em`, and a “visual” mode, which took over the whole screen and enabled live editing of an entire file like we are used to today. + +For the second release of BSD in 1979, an executable named `vi` was introduced that did little more than open `ex` in visual mode. + +`ex`/`vi` (henceforth `vi`) established most of the conventions we now associate with Vim that weren’t already a part of `ed`. The video terminal that Joy was using was a Lear Siegler ADM-3A, which had a keyboard with no cursor keys. Instead, arrows were painted on the `h`, `j`, `k`, and `l` keys, which is why Joy used those keys for cursor movement in `vi`. The escape key on the ADM-3A keyboard was also where today we would find the tab key, which explains how such a hard-to-reach key was ever assigned an operation as common as exiting a mode. The `:` character that prefixes commands also comes from `vi`, which in regular mode (i.e. the mode entered by running `ex`) used `:` as a prompt. This addressed a long-standing complaint about `ed`, which, once launched, greets users with utter silence. In visual mode, saving and quitting now involved typing the classic `:wq`. “Yanking” and “putting,” marks, and the `set` command for setting options were all part of the original `vi`. The features we use in the course of basic text editing today in Vim are largely `vi` features. + +![A Lear Siegler ADM-3A keyboard.][4] + +`vi` was the only text editor bundled with BSD Unix other than `ed`. At the time, Emacs could cost hundreds of dollars (this was before GNU Emacs), so `vi` became enormously popular. But `vi` was a direct descendant of `ed`, which meant that the source code could not be modified without an AT&T source license. This motivated several people to create open-source versions of `vi`. STEVIE (ST Editor for VI Enthusiasts) appeared in 1987, Elvis appeared in 1990, and `nvi` appeared in 1994. Some of these clones added extra features like syntax highlighting and split windows. Elvis in particular saw many of its features incorporated into Vim, since so many Elvis users pushed for their inclusion. + +### Bram Moolenaar Writes Vim + +“Vim”, which now abbreviates “Vi Improved”, originally stood for “Vi Imitation.” Like many of the other `vi` clones, Vim began as an attempt to replicate `vi` on a platform where it was not available. Bram Moolenaar, a Dutch software engineer working for a photocopier company in Venlo, the Netherlands, wanted something like `vi` for his brand-new Amiga 2000. Moolenaar had grown used to using `vi` on the Unix systems at his university and it was now “in his fingers.” So in 1988, using the existing STEVIE `vi` clone as a starting point, Moolenaar began work on Vim. + +Moolenaar had access to STEVIE because STEVIE had previously appeared on something called a Fred Fish disk. Fred Fish was an American programmer that mailed out a floppy disk every month with a curated selection of the best open-source software available for the Amiga platform. Anyone could request a disk for nothing more than the price of postage. Several versions of STEVIE were released on Fred Fish disks. The version that Moolenaar used had been released on Fred Fish disk 256. (Disappointingly, Fred Fish disks seem to have nothing to do with [Freddi Fish][5].) + +Moolenaar liked STEVIE but quickly noticed that there were many `vi` commands missing. So, for the first release of Vim, Moolenaar made `vi` compatibility his priority. Someone else had written a series of `vi` macros that, when run through a properly `vi`-compatible editor, could solve a [randomly generated maze][6]. Moolenaar was able to get these macros working in Vim. In 1991, Vim was released for the first time on Fred Fish disk 591 as “Vi Imitation.” Moolenaar had added some features (including multi-level undo and a “quickfix” mode for compiler errors) that meant that Vim had surpassed `vi`. But Vim would remain “Vi Imitation” until Vim 2.0, released in 1993 via FTP. + +Moolenaar, with the occasional help of various internet collaborators, added features to Vim at a steady clip. Vim 2.0 introduced support for the `wrap` option and for horizontal scrolling through long lines of text. Vim 3.0 added support for split windows and buffers, a feature inspired by the `vi` clone `nvi`. Vim also now saved each buffer to a swap file, so that edited text could survive a crash. Vimscript made its first appearance in Vim 5.0, along with support for syntax highlighting. All the while, Vim’s popularity was growing. It was ported to MS-DOS, to Windows, to Mac, and even to Unix, where it competed with the original `vi`. + +In 2006, Vim was voted the most popular editor among Linux Journal readers. Today, according to Stack Overflow’s 2018 Developer Survey, Vim is the most popular text-mode (i.e. terminal emulator) editor, used by 25.8% of all software developers (and 40% of Sysadmin/DevOps people). For a while, during the late 1980s and throughout the 1990s, programmers waged the “Editor Wars,” which pitted Emacs users against `vi` (and eventually Vim) users. While Emacs certainly still has a following, some people think that the Editor Wars are over and that Vim won. The 2018 Stack Overflow Developer Survey suggests that this is true; only 4.1% of respondents used Emacs. + +How did Vim become so successful? Obviously people like the features that Vim has to offer. But I would argue that the long history behind Vim illustrates that it had more advantages than just its feature set. Vim’s codebase dates back only to 1988, when Moolenaar began working on it. The “wq text editor,” on the other hand—the broader vision of how a Unix-y text editor should work—goes back a half-century. The “wq text editor” had a few different concrete expressions, but thanks in part to the unusual attention paid to backward compatibility by both Bill Joy and Bram Moolenaar, good ideas accumulated gradually over time. The “wq text editor,” in that sense, is one of the longest-running and most successful open-source projects, having enjoyed contributions from some of the greatest minds in the computing world. I don’t think the “startup-company-throws-away all-precedents-and-creates-disruptive-new-software” approach to development is necessarily bad, but Vim is a reminder that the collaborative and incremental approach can also yield wonders. + +If you enjoyed this post, more like it come out every two weeks! Follow [@TwoBitHistory][7] on Twitter or subscribe to the [RSS feed][8] to make sure you know when a new post is out. + +Previously on TwoBitHistory… + +> New post! This time we're taking a look at the Altair 8800, the very first home computer, and how to simulate it on your modern PC. +> +> — TwoBitHistory (@TwoBitHistory) [July 22, 2018][9] + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2018/08/05/where-vim-came-from.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://stackoverflow.blog/wp-content/uploads/2017/05/meme.jpeg +[2]: https://www.vim.org/ +[3]: https://upload.wikimedia.org/wikipedia/commons/8/8f/Ken_Thompson_%28sitting%29_and_Dennis_Ritchie_at_PDP-11_%282876612463%29.jpg +[4]: https://vintagecomputer.ca/wp-content/uploads/2015/01/LSI-ADM3A-full-keyboard.jpg +[5]: https://en.wikipedia.org/wiki/Freddi_Fish +[6]: https://github.com/isaacs/.vim/tree/master/macros/maze +[7]: https://twitter.com/TwoBitHistory +[8]: https://twobithistory.org/feed.xml +[9]: https://twitter.com/TwoBitHistory/status/1021058552352387074?ref_src=twsrc%5Etfw From ac8f8ff61aefef87d2b75ac3be3d76749b729aa3 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 24 Oct 2018 16:01:33 +0800 Subject: [PATCH 154/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Dawn=20of=20the?= =?UTF-8?q?=20Microcomputer:=20The=20Altair=208800?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...n of the Microcomputer- The Altair 8800.md | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 sources/talk/20180722 Dawn of the Microcomputer- The Altair 8800.md diff --git a/sources/talk/20180722 Dawn of the Microcomputer- The Altair 8800.md b/sources/talk/20180722 Dawn of the Microcomputer- The Altair 8800.md new file mode 100644 index 0000000000..98a42236de --- /dev/null +++ b/sources/talk/20180722 Dawn of the Microcomputer- The Altair 8800.md @@ -0,0 +1,126 @@ +Dawn of the Microcomputer: The Altair 8800 +====== +Subscribers to Popular Electronics were a sophisticated group. The magazine’s editor, Arthur Salsberg, felt compelled to point out as much in the editorial section of the [December 1974 issue][1]. The magazine had received letters complaining that a recent article, titled “How to Set Up a Home TV Service Shop,” would inspire a horde of amateur TV technicians to go out and undercut professional repairmen, doing great damage to everyone’s TVs in the process. Salsberg thought this concern was based on a misunderstanding about who read Popular Electronics. He explained that, according to the magazine’s own surveys, 52% of Popular Electronics subscribers were electronics professionals of some kind and 150,000 of them had repaired a TV in the last 60 days. Moreover, the average Popular Electronics subscriber had spent $470 on electronics equipment ($3578 in 2018) and possessed such necessities as VOMs, VTVMs, tube testers, transistor testers, r-f signal generators, and scopes. “Popular Electronics readers are not largely neophytes,” Salsberg concluded. + +I am surprised that anyone familiar with Popular Electronics could ever have doubted its subscribers. I certainly haven’t repaired a TV in the last 60 days. My computer is a block of aluminum that I have never seen the inside of. Yet the December 1974 issue of Popular Electronics features articles such as “Standing Wave Ratio: What It Is and How to Deal with It” and “Test Scene: Uses for Your Multimeter.” Even the ads are intimidating. One of them, which seems to be for some kind of stereo system, boldly proclaims that “no piece of audio equipment is as eagerly awaited as the ‘one four-channel unit that does everything—i.e. the receiver with built-in circuitry for SQ, RM and CD-4 record decoding.’” The mere hobbyists subscribed to Popular Electronics, let alone the professionals, must have been very knowledgeable indeed. + +But Popular Electronics readers were introduced to something in the [January 1975 issue][2] that they had never encountered before. Below a heading that read “PROJECT BREAKTHROUGH,” the magazine’s cover showed a large gray and black box whose front panel bore a complicated array of lights and toggles. This was the Altair 8800, the “world’s first minicomputer kit to rival commercial models,” available for under $400. Though advertised as a “minicomputer,” the Altair would actually be the first commercially successful member of a new class of computers, first known as “microcomputers” and then eventually as PCs. The Altair was small enough and cheap enough that the average family could have one at home. Its appearance in Popular Electronics magazine meant that, as Salsberg wrote in that issue, “the home computer age is here—finally.” + +![January 1975 cover of Popular Electronics][3] + +I have written briefly about [the Altair before][4], but I think the Altair is worth revisiting. It was not an especially powerful computer compared to others available at the time (though it cost significantly less money). Nor was it the first general-purpose computer to incorporate a microprocessor chip—at least three microprocessor-based computers preceded it. But the Altair was and is a kind of Ur-Computer for all of us. It was the first popular computer in a lineage that includes our own devices, whereas the mainframes and bulky minicomputers that predated the Altair were an entirely different kind of machine, programmed by punched card or else rarely interacted with directly. The Altair was also a radically simple computer, without any kind of operating system or even a bootloader. Unless you bought peripherals for it, the Altair was practically a bank of RAM with switches and lights on the front. The Altair’s simplicity makes learning about it a great way to reacquaint yourself with the basic concepts of computing, exactly as they were encountered by the denizens of the old analog world as they first ventured into our digital one. + +### Roberts and Co. + +The Altair was designed and manufactured by a company called Micro Instrumentation and Telemetry Systems (MITS), based in Albuquerque, New Mexico. MITS was run by a man named H. Edward Roberts. The company had started off making telemetry systems for model rocket kits before moving into the calculator market, which in the early 1970s was booming. Integrated circuits were bringing the cost of a calculator down dramatically and suddenly every working American professional had to have one. But the calculator market was ruthlessly competitive and, by the beginning of 1974, MITS was deeply in debt. + +The year 1974 would prove to be an “annus mirabilis” in computing. In January, Hewlett-Packard introduced the HP-65, the world’s first programmable handheld calculator. In April, Intel released the Intel 8080, its second 8-bit microprocessor and the first microprocessor to become widely popular. Then, in July, Radio Electronics magazine advertised a build-it-yourself minicomputer called the Mark-8, which employed the Intel 8008 microprocessor that Intel had released in 1972. The Mark-8 was only the third computer ever built using a microprocessor and it was the first to be appear on the cover of a magazine. The Mark-8’s appearance in Radio Electronics pushed Popular Electronics to look for a minicomputer project of their own to feature. + +Popular Electronics subscribers actually received their copies of the January 1975 issue in the mail in December of 1974. So the announcement of the Altair closed out the “annus mirabilis” that was that year. The Altair’s introduction was so momentous because never before had such a fully capable computer been offered to the public at an affordable price. The PDP-8, one the most popular minicomputers at the time, could only be bought for several thousand dollars. Yet the Intel 8080 chip at the heart of the Altair made it almost as capable as the PDP-8, if not more so; the 8080 supported a wider instruction set and the Altair could be expanded to have up to 64kb of memory, while the stock PDP-8 typically only had 4kb. The Altair was also more powerful than the Mark-8, which, because it was based on the Intel 8008, could only address 16kb of memory. And whereas the Mark-8 had to be built from scratch by customers with only a booklet and printed circuit boards to guide them, the Altair could be purchased fully assembled, though MITS soon became so inundated with orders that the only real way to get an Altair was to order the construction kit. + +For many Popular Electronics readers, the Altair was their first window into the world of digital computing. The article introducing the Altair in the January 1975 issue was written by Roberts and the Altair’s co-designer, William Yates. Roberts and Yates took pains to explain, in terms familiar to the electricians and radio enthusiasts in their audience, the basic concepts underlying digital hardware and computer programming. “A computer,” they wrote, “is basically a piece of variable hardware. By changing the bit pattern stored in the memory, the hardware can be altered from one type of device to another.” Of programming, meanwhile, Roberts and Yates wrote that the basic concepts are “simple enough to master in a relatively short time,” but that becoming “an efficient programmer requires a lot of experience and a large amount of creativity,” which sounds about right to me. The article included a detailed diagram explaining all the constituent circuits of the Intel 8080 CPU, even though readers would receive at least that part fully assembled. It explained the difference between a CPU and a computer’s memory unit, the uses of a stack pointer, and the enormous advantages offered by assembly languages and higher-level languages like FORTRAN and BASIC over manual entry of machine code. + +Popular Electronics had in fact been running a series written by Roberts for several issues before January 1975. The series was billed as a short course in “digital logic.” In the December 1974 issue, Roberts walked readers through building a “very low cost computer terminal,” which was basically an octal keypad that could input values into an 8-bit computer. In the course of describing the keypad, Roberts explained how transistor-to-transistor logic works and also how to construct a flip-flop, a kind of circuit capable of “remembering” digital values. The keypad, Roberts promised, could be used with the Altair computer, to be announced the following month. + +It’s unclear how many Popular Electronics readers actually built the keypad, but it would have been a very useful thing to have. Without a keypad or some other input mechanism, the only way to input values into the Altair was through the switches on the front panel. The front panel had a row of 16 switches that could be used to set an address and a lower row of eight switches that could be used to control the operation of the computer. The eight right-most switches in the row of 16 could also be used to specify a value to be stored in memory. This made sense because the Intel 8080 used 16-bit values to address 8-bit words. The 16 switches on the front panel each represented a bit—the up position represented a one, while the down position represented a zero. Interacting with a computer this way is a revelation (more on that in a minute), because the Altair’s front panel is a true binary interface. It’s as close as you can get to the bare metal. + +As alien as the Altair’s interface is to us today, it was not unusual for its time. The PDP-8, for example, had a similar binary input mechanism on its front panel, though the PDP-8’s switches were nicer and colored in that attractive orange and yellow color scheme that really ought to make a comeback. The PDP-8, however, was often paired with a paper-tape reader or a teletype machine, which made program entry much easier. These I/O devices were expensive, meaning that most Altair users in the early days were stuck with the front panel. As you might imagine, entering long programs via the switches was a chore. Eventually the Altair could be hooked up to a cassette recorder and programs could be loaded that way. Bill Gates and Paul Allen, in what would become Microsoft’s first ever commercial venture, also wrote a version of BASIC for the Altair that MITS licensed and released in the middle of 1975. Users that could afford a teletype could then [load BASIC into the Altair via paper tape][5] and interact with their Altair through text. BASIC, which had become everyone’s favorite introductory programming language in schools, would go on to become the standard interface to the machines produced in the early microcomputer era. + +### z80pack + +Thanks to the efforts of several internet people, in particular a person named Udo Munk, you can run a simulation of the Altair on your computer. The simulation is built on top of some software that emulates the Zilog Z80 CPU, a CPU designed to be software-compatible with the Intel 8080. The Altair simulation allows you to input programs entirely via the front panel switches like early users of the Altair had to do. Though clicking on switches does not offer the same tactile satisfaction as flipping real switches, playing with the Altair simulation is a great way to appreciate how a binary human/computer interface was both horribly inefficient and, at least in my opinion, charmingly straightforward. + +z80pack, Udo Munk’s Z80 emulation package, can be downloaded from the z80pack website. There are instructions in [my last Altair post][4] explaining how to get it set up on Mac OS. If you are able to compile both the FrontPanel library and the `altairsim` executable, you should be able to run `altairsim` and see the following window: + +![Simulated Altair Front Panel][6] + +By default, at least with the version of z80pack that I am using (1.36), the Altair is configured with something called Tarbell boot ROM, which I think is used to load disk images. In practice, what this means is that you can’t write values into the first several words in RAM. If you edit the file `/altairsim/conf/system.conf`, you can instead set up a simple Altair that has 16 pages of RAM and no ROM or bootloader software at all. You can also use this configuration file to increase the size of the window the simulation runs in, which is handy. + +The front panel of the Altair is intimidating, but in reality there isn’t that much going on. The [Altair manual][7] does a good job of explaining the many switches and status lights, as does this [YouTube video][8]. To enter and run a simple program, you only really need to know a few things. The lights labeled D0 through D7 near the top right of the Altair indicate the contents of the currently addressed word. The lights labeled A0 through A15 indicate the current address. The 16 switches below the address lights can be used to set a new address; when the “EXAMINE” switch is pressed upward, the data lights update to show the contents of the newly addressed word. In this way, you can “peek” at all the words in memory. You can also press the “EXAMINE” switch down to the “EXAMINE NEXT” position, which automatically examines the next memory address, which makes peeking at sequential words significantly easier. + +To save a bit pattern to a word, you have to set the bit pattern using the right-most eight switches labeled 0 through 7. You then press the “DEPOSIT” switch upward. + +In the [February 1975 issue][9] of Popular Electronics, Roberts and Yates walked Altair owners through inputting a small sample program to ensure that their Altair was functioning. The program loads two integers from memory, adds them, and saves the sum back into memory. The program consists of only six instructions, but those six instructions involve 14 words of memory altogether, which takes some time to input correctly. The sample program also appears in the Altair manual in table form, which I’ve reproduced here: + +Address Mnemonic Bit Pattern Octal Equivalent 0 LDA 00 111 010 0 7 2 1 (address) 10 000 000 2 0 0 2 (address) 00 000 000 0 0 0 3 MOV B, A 01 000 111 1 0 7 4 LDA 00 111 010 0 7 2 5 (address) 10 000 001 2 0 1 6 (address) 00 000 000 0 0 0 7 ADD B 10 000 000 2 0 0 8 STA 00 110 010 0 6 2 9 (address) 10 000 010 2 0 2 10 (address) 00 000 000 0 0 0 11 JMP 11 000 011 3 0 3 12 (address) 00 000 000 0 0 0 13 (address) 00 000 000 0 0 0 + +If you input each word in the above table into the Altair via the switches, you end up with a program that loads the value in word 128, adds it to the value in the word 129, and finally saves it into word 130. The addresses that accompany each instruction taking an address are given with the least-significant bits first, which is why the second byte is always zeroed out (no addresses are higher than 255). Once you’ve input the program and entered some values into words 128 and 129, you can press the “RUN” switch into the down position briefly before pushing it into the “STOP” position. Since the program loops, it repeatedly adds those values and saves the sum thousands of times a second. The sum is always the same though, so if you peek at word 130 after stopping the program, you should find the correct answer. + +I don’t know whether any regular users of the Altair ever had access to an assembler, but z80pack includes one. The z80pack assembler, `z80asm`, is meant for Z80 assembly, so it uses a different set of mnemonics altogether. But since the Z80 was designed to be compatible with software written for the Intel 8080, the opcodes are all the same, even if the mnemonics are different. So just to illustrate what it might have been like to write the same program in assembly, here is a version that can be assembled by `z80asm` and loaded into the Altair: + +``` + ORG 0000H +START: LD A,(80H) ;Load from address 128. + LD B,A ;Move loaded value from accumulator (A) to reg B. + LD A,(81H) ;Load from address 129. + ADD A,B ;Add A and B. + LD (82H),A ;Store A at address 130. + JP START ;Jump to start. +``` + +You can turn this into something called an Intel HEX file by invoking the assembler like so (after you have compiled it): + +``` +$ ./z80asm -fh -oadd.hex add.asm +``` + +The `-f` flag, here taking `h` as an argument, specifies that a HEX file should be output. You can then load the program into the Altair by passing the HEX file in using the `-x` flag: + +``` +$ ./altairsim -x add.hex +``` + +This sets up the first 14 words in memory as if you had input the values manually via the switches. Instead of doing all that again, you can just run the program by using the “RUN” switch as before. Much easier! + +As I said, I don’t think many Altair users wrote software this way. Once Altair BASIC became available, writing BASIC programs was probably the easiest way to program the Altair. z80pack also includes several HEX files containing different versions of Altair BASIC; the one I’ve been able to get working is version 4.0 of 4K BASIC, which you can load into the simulator like so: + +``` +$ ./altairsim -x basic4k40.hex +``` + +If you turn the simulated machine on and hit the “RUN” switch, you should see that BASIC has started talking to you in your terminal window. It first prompts you to enter the amount of memory you have available, which should be 4000 bytes. It then asks you a few more questions before presenting you with the “OK” prompt, which Gates and Allen used instead of the standard “READY” to save memory. From there, you can just use BASIC: + +``` +OK +PRINT 3 + 4 + 7 +``` + +Though running BASIC with only 4kb of memory didn’t give you a lot of room, you can see how it would have been a significant step up from using the front panel. + +The Altair, of course, was nowhere near as capable as the home desktops and laptops we have available to us today. Even something like the Macintosh, released less than a decade later, seems like a quantum leap forward over the spartan Altair. But to those first Popular Electronics readers that bought the kit and assembled it, the Altair was a real, fully capable computer that they could own for themselves, all for the low cost of $400 and half the surface space of the credenza. This would have been an amazing thing for people that had thus far only been able to interact with computers by handing [a stack of cards][10] or a roll of tape to another human being entrusted with the actual operation of the computer. Subsequent microcomputers would improve upon what the Altair offered and quickly become much easier to use, but they were all, in some sense, just more complicated Altairs. The Altair—almost Brutalist in its minimalism—was the bare-essentials blueprint for all that would follow. + +If you enjoyed this post, more like it come out every two weeks! Follow [@TwoBitHistory][11] on Twitter or subscribe to the [RSS feed][12] to make sure you know when a new post is out. + +Previously on TwoBitHistory… + +> "I invite you to come along with me on an exciting journey and spend the next ten minutes of your life learning about a piece of software nobody has used in the last decade." +> +> — TwoBitHistory (@TwoBitHistory) [July 7, 2018][13] + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2018/07/22/dawn-of-the-microcomputer.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://www.americanradiohistory.com/Archive-Poptronics/70s/1974/Poptronics-1974-12.pdf +[2]: https://www.americanradiohistory.com/Archive-Poptronics/70s/1975/Poptronics-1975-01.pdf +[3]: https://twobithistory.org/images/jan1975-altair.jpg +[4]: https://twobithistory.org/2017/12/02/simulating-the-altair.html +[5]: https://www.youtube.com/watch?v=qv5b1Xowxdk +[6]: https://www.autometer.de/unix4fun/z80pack/altair.png +[7]: http://www.classiccmp.org/dunfield/altair/d/88opman.pdf +[8]: https://www.youtube.com/watch?v=suyiMfzmZKs +[9]: https://www.americanradiohistory.com/Archive-Poptronics/70s/1975/Poptronics-1975-02.pdf +[10]: https://twobithistory.org/2018/06/23/ibm-029-card-punch.html +[11]: https://twitter.com/TwoBitHistory +[12]: https://twobithistory.org/feed.xml +[13]: https://twitter.com/TwoBitHistory/status/1015647820353867776?ref_src=twsrc%5Etfw From 16ef6dd741f674260f15bb5b0f9b42ab6f77a8c9 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 24 Oct 2018 16:02:15 +0800 Subject: [PATCH 155/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20Version=20Control?= =?UTF-8?q?=20Before=20Git=20with=20CVS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...707 Version Control Before Git with CVS.md | 312 ++++++++++++++++++ 1 file changed, 312 insertions(+) create mode 100644 sources/tech/20180707 Version Control Before Git with CVS.md diff --git a/sources/tech/20180707 Version Control Before Git with CVS.md b/sources/tech/20180707 Version Control Before Git with CVS.md new file mode 100644 index 0000000000..f1c34177a6 --- /dev/null +++ b/sources/tech/20180707 Version Control Before Git with CVS.md @@ -0,0 +1,312 @@ +Version Control Before Git with CVS +====== +Github was launched in 2008. If your software engineering career, like mine, is no older than Github, then Git may be the only version control software you have ever used. While people sometimes grouse about its steep learning curve or unintuitive interface, Git has become everyone’s go-to for version control. In Stack Overflow’s 2015 developer survey, 69.3% of respondents used Git, almost twice as many as used the second-most-popular version control system, Subversion. After 2015, Stack Overflow stopped asking developers about the version control systems they use, perhaps because Git had become so popular that the question was uninteresting. + +Git itself is not much older than Github. Linus Torvalds released the first version of Git in 2005. Though today younger developers might have a hard time conceiving of a world where the term “version control software” didn’t more or less just mean Git, such a world existed not so long ago. There were lots of alternatives to choose from. Open source developers preferred Subversion, enterprises and video game companies used Perforce (some still do), while the Linux kernel project famously relied on a version control system called BitKeeper. + +Some of these systems, particularly BitKeeper, might feel familiar to a young Git user transported back in time. Most would not. BitKeeper aside, the version control systems that came before Git worked according to a fundamentally different paradigm. In a taxonomy offered by Eric Sink, author of Version Control by Example, Git is a third-generation version control system, while most of Git’s predecessors, the systems popular in the 1990s and early 2000s, are second-generation version control systems. Where third-generation version control systems are distributed, second-generation version control systems are centralized. You have almost certainly heard Git described as a “distributed” version control system before. I never quite understood the distributed/centralized distinction, at least not until I installed and experimented with a centralized second-generation version control system myself. + +The system I installed was CVS. CVS, short for Concurrent Versions System, was the very first second-generation version control system. It was also the most popular version control system for about a decade until it was replaced in 2000 by Subversion. Even then, Subversion was supposed to be “CVS but better,” which only underscores how dominant CVS had become throughout the 1990s. + +CVS was first developed in 1986 by a Dutch computer scientist named Dick Grune, who was looking for a way to collaborate with his students on a compiler project. CVS was initially little more than a collection of shell scripts wrapping RCS (Revision Control System), a first-generation version control system that Grune wanted to improve. RCS works according to a pessimistic locking model, meaning that no two programmers can work on a single file at once. In order to edit a file, you have to first ask RCS for an exclusive lock on the file, which you keep until you are finished editing. If someone else is already editing a file you need to edit, you have to wait. CVS improved on RCS and ushered in the second generation of version control systems by trading the pessimistic locking model for an optimistic one. Programmers could now edit the same file at the same time, merging their edits and resolving any conflicts later. (Brian Berliner, an engineer who later took over the CVS project, wrote a very readable [paper][1] about CVS’ innovations in 1990.) + +In that sense, CVS wasn’t all that different from Git, which also works according to an optimistic model. But that’s where the similarities end. In fact, when Linus Torvalds was developing Git, one of his guiding principles was WWCVSND, or “What Would CVS Not Do.” Whenever he was in doubt about a decision, he strove to choose the option that had not been chosen in the design of CVS. So even though CVS predates Git by over a decade, it influenced Git as a kind of negative template. + +I’ve really enjoyed playing around with CVS. I think there’s no better way to understand why Git’s distributed nature is such an improvement on what came before. So I invite you to come along with me on an exciting journey and spend the next ten minutes of your life learning about a piece of software nobody has used in the last decade. (See correction.) + +### Getting Started with CVS + +Instructions for installing CVS can be found on the [project’s homepage][2]. On MacOS, you can install CVS using Homebrew. + +Since CVS is centralized, it distinguishes between the client-side universe and the server-side universe in a way that something like Git does not. The distinction is not so pronounced that there are different executables. But in order to start using CVS, even on your own machine, you’ll have to set up the CVS backend. + +The CVS backend, the central store for all your code, is called the repository. Whereas in Git you would typically have a repository for every project, in CVS the repository holds all of your projects. There is one central repository for everything, though there are ways to work with only a project at a time. + +To create a local repository, you run the `init` command. You would do this somewhere global like your home directory. + +``` +$ cvs -d ~/sandbox init +``` + +CVS allows you to pass options to either the `cvs` command itself or to the `init` subcommand. Options that appear after the `cvs` command are global in nature, while options that appear after the subcommand are specific to the subcommand. In this case, the `-d` flag is global. Here it happens to tell CVS where we want to create our repository, but in general the `-d` flag points to the location of the repository we want to use for any given action. It can be tedious to supply the `-d` flag all the time, so the `CVSROOT` environment variable can be set instead. + +Since we’re working locally, we’ve just passed a path for our `-d` argument, but we could also have included a hostname. + +The command creates a directory called `sandbox` in your home directory. If you list the contents of `sandbox`, you’ll find that it contains another directory called `CVSROOT`. This directory, not to be confused with the environment variable, holds administrative files for the repository. + +Congratulations! You’ve just created your first CVS repository. + +### Checking In Code + +Let’s say that you’ve decided to keep a list of your favorite colors. You are an artistically inclined but extremely forgetful person. You type up your list of colors and save it as a file called `favorites.txt`: + +``` +blue +orange +green + +definitely not yellow +``` + +Let’s also assume that you’ve saved your file in a new directory called `colors`. Now you’d like to put your favorite color list under version control, because fifty years from now it will be interesting to look back and see how your tastes changed through time. + +In order to do that, you will have to import your directory as a new CVS project. You can do that using the `import` command: + +``` +$ cvs -d ~/sandbox import -m "" colors colors initial +N colors/favorites.txt + +No conflicts created by this import +``` + +Here we are specifying the location of our repository with the `-d` flag again. The remaining arguments are passed to the `import` subcommand. We have to provide a message, but here we don’t really need one, so we’ve left it blank. The next argument, `colors`, specifies the name of our new directory in the repository; here we’ve just used the same name as the directory we are in. The last two arguments specify the vendor tag and the release tag respectively. We’ll talk more about tags in a minute. + +You’ve just pulled your “colors” project into the CVS repository. There are a couple different ways to go about bringing code into CVS, but this is the method recommended by [Pragmatic Version Control Using CVS][3], the Pragmatic Programmer book about CVS. What makes this method a little awkward is that you then have to check out your work fresh, even though you’ve already got an existing `colors` directory. Instead of using that directory, you’re going to delete it and then check out the version that CVS already knows about: + +``` +$ cvs -d ~/sandbox co colors +cvs checkout: Updating colors +U colors/favorites.txt +``` + +This will create a new directory, also called `colors`. In this directory you will find your original `favorites.txt` file along with a directory called `CVS`. The `CVS` directory is basically CVS’ equivalent of the `.git` directory in every Git repository. + +### Making Changes + +Get ready for a trip. + +Just like Git, CVS has a `status` subcommand: + +``` +$ cvs status +cvs status: Examining . +=================================================================== +File: favorites.txt Status: Up-to-date + + Working revision: 1.1.1.1 2018-07-06 19:27:54 -0400 + Repository revision: 1.1.1.1 /Users/sinclairtarget/sandbox/colors/favorites.txt,v + Commit Identifier: fD7GYxt035GNg8JA + Sticky Tag: (none) + Sticky Date: (none) + Sticky Options: (none) +``` + +This is where things start to look alien. CVS doesn’t have commit objects. In the above, there is something called a “Commit Identifier,” but this might be only a relatively recent edition—no mention of a “Commit Identifier” appears in Pragmatic Version Control Using CVS, which was published in 2003. (The last update to CVS was released in 2008.) + +Whereas with Git you’d talk about the version of a file associated with commit `45de392`, in CVS files are versioned separately. The first version of your file is version 1.1, the next version is 1.2, and so on. When branches are involved, extra numbers are appended, so you might end up with something like the `1.1.1.1` above, which appears to be the default in our case even though we haven’t created any branches. + +If you were to run `cvs log` (equivalent to `git log`) in a project with lots of files and commits, you’d see an individual history for each file. You might have a file at version 1.2 and a file at version 1.14 in the same project. + +Let’s go ahead and make a change to version 1.1 of our `favorites.txt` file: + +``` + blue + orange + green ++cyan + + definitely not yellow +``` + +Once we’ve made the change, we can run `cvs diff` to see what CVS thinks we’ve done: + +``` +$ cvs diff +cvs diff: Diffing . +Index: favorites.txt +=================================================================== +RCS file: /Users/sinclairtarget/sandbox/colors/favorites.txt,v +retrieving revision 1.1.1.1 +diff -r1.1.1.1 favorites.txt +3a4 +> cyan +``` + +CVS recognizes that we added a new line containing the color “cyan” to the file. (Actually, it says we’ve made changes to the “RCS” file; you can see that CVS never fully escaped its original association with RCS.) The diff we are being shown is the diff between the copy of `favorites.txt` in our working directory and the 1.1.1.1 version stored in the repository. + +In order to update the version stored in the repository, we have to commit the change. In Git, this would be a multi-step process. We’d have to stage the change so that it appears in our index. Then we’d commit the change. Finally, to make the change visible to anyone else, we’d have to push the commit up to the origin repository. + +In CVS, all of these things happen when you run `cvs commit`. CVS just bundles up all the changes it can find and puts them in the repository: + +``` +$ cvs commit -m "Add cyan to favorites." +cvs commit: Examining . +/Users/sinclairtarget/sandbox/colors/favorites.txt,v <-- favorites.txt +new revision: 1.2; previous revision: 1.1 +``` + +I’m so used to Git that this strikes me as terrifying. Without an opportunity to stage changes, any old thing that you’ve touched in your working directory might end up as part of the public repository. Did you passive-aggressively rewrite a coworker’s poorly implemented function out of cathartic necessity, never intending for him to know? Too bad, he now thinks you’re a dick. You also can’t edit your commits before pushing them, since a commit is a push. Do you enjoy spending 40 minutes repeatedly running `git rebase -i` until your local commit history flows like the derivation of a mathematical proof? Sorry, you can’t do that here, and everyone is going to find out that you don’t actually write your tests first. + +But I also now understand why so many people find Git needlessly complicated. If `cvs commit` is what you were used to, then I’m sure staging and pushing changes would strike you as a pointless chore. + +When people talk about Git being a “distributed” system, this is primarily the difference they mean. In CVS, you can’t make commits locally. A commit is a submission of code to the central repository, so it’s not something you can do without a connection. All you’ve got locally is your working directory. In Git, you have a full-fledged local repository, so you can make commits all day long even while disconnected. And you can edit those commits, revert, branch, and cherry pick as much as you want, without anybody else having to know. + +Since commits were a bigger deal, CVS users often made them infrequently. Commits would contain as many changes as today we might expect to see in a ten-commit pull request. This was especially true if commits triggered a CI build and an automated test suite. + +If we now run `cvs status`, we can see that we have a new version of our file: + +``` +$ cvs status +cvs status: Examining . +=================================================================== +File: favorites.txt Status: Up-to-date + + Working revision: 1.2 2018-07-06 21:18:59 -0400 + Repository revision: 1.2 /Users/sinclairtarget/sandbox/colors/favorites.txt,v + Commit Identifier: pQx5ooyNk90wW8JA + Sticky Tag: (none) + Sticky Date: (none) + Sticky Options: (none) +``` + +### Merging + +As mentioned above, in CVS you can edit a file that someone else is already editing. That was CVS’ big improvement on RCS. What happens when you need to bring your changes back together? + +Let’s say that you have invited some friends to add their favorite colors to your list. While they are adding their colors, you decide that you no longer like the color green and remove it from the list. + +When you go to commit your changes, you might discover that CVS notices a problem: + +``` +$ cvs commit -m "Remove green" +cvs commit: Examining . +cvs commit: Up-to-date check failed for `favorites.txt' +cvs [commit aborted]: correct above errors first! +``` + +It looks like your friends committed their changes first. So your version of `favorites.txt` is not up-to-date with the version in the repository. If you run `cvs status`, you’ll see that your local copy of `favorites.txt` is version 1.2 with some local changes, but the repository version is 1.3: + +``` +$ cvs status +cvs status: Examining . +=================================================================== +File: favorites.txt Status: Needs Merge + + Working revision: 1.2 2018-07-07 10:42:43 -0400 + Repository revision: 1.3 /Users/sinclairtarget/sandbox/colors/favorites.txt,v + Commit Identifier: 2oZ6n0G13bDaldJA + Sticky Tag: (none) + Sticky Date: (none) + Sticky Options: (none) +``` + +You can run `cvs diff` to see exactly what the differences between 1.2 and 1.3 are: + +``` +$ cvs diff -r HEAD favorites.txt +Index: favorites.txt +=================================================================== +RCS file: /Users/sinclairtarget/sandbox/colors/favorites.txt,v +retrieving revision 1.3 +diff -r1.3 favorites.txt +3d2 +< green +7,10d5 +< +< pink +< hot pink +< bubblegum pink +``` + +It seems that our friends really like pink. In any case, they’ve edited a different part of the file than we have, so the changes are easy to merge. CVS can do that for us when we run `cvs update`, which is similar to `git pull`: + +``` +$ cvs update +cvs update: Updating . +RCS file: /Users/sinclairtarget/sandbox/colors/favorites.txt,v +retrieving revision 1.2 +retrieving revision 1.3 +Merging differences between 1.2 and 1.3 into favorites.txt +M favorites.txt +``` + +If you now take a look at `favorites.txt`, you’ll find that it has been modified to include the changes that your friends made to the file. Your changes are still there too. Now you are free to commit the file: + +``` +$ cvs commit +cvs commit: Examining . +/Users/sinclairtarget/sandbox/colors/favorites.txt,v <-- favorites.txt +new revision: 1.4; previous revision: 1.3 +``` + +The end result is what you’d get in Git by running `git pull --rebase`. Your changes have been added on top of your friends’ changes. There is no “merge commit.” + +Sometimes, changes to the same file might be incompatible. If your friends had changed “green” to “olive,” for example, that would have conflicted with your change removing “green” altogether. In the early days of CVS, this was exactly the kind of case that caused people to worry that CVS wasn’t safe; RCS’ pessimistic locking ensured that such a case could never arise. But CVS guarantees safety by making sure that nobody’s changes get overwritten automatically. You have to tell CVS which change you want to keep going forward, so when you run `cvs update`, CVS marks up the file with both changes in the same way that Git does when Git detects a merge conflict. You then have to manually edit the file and pick the change you want to keep. + +The interesting thing to note here is that merge conflicts have to be fixed before you can commit. This is another consequence of CVS’ centralized nature. In Git, you don’t have to worry about resolving merges until you push the commits you’ve got locally. + +Since CVS doesn’t have easily addressable commit objects, the only way to group a collection of changes is to mark a particular working directory state with a tag. + +Creating a tag is easy: + +``` +$ cvs tag VERSION_1_0 +cvs tag: Tagging . +T favorites.txt +``` + +You’ll later be able to return files to this state by running `cvs update` and passing the tag to the `-r` flag: + +``` +$ cvs update -r VERSION_1_0 +cvs update: Updating . +U favorites.txt +``` + +Because you need a tag to rewind to an earlier working directory state, CVS encourages a lot of preemptive tagging. Before major refactors, for example, you might create a `BEFORE_REFACTOR_01` tag that you could later use if the refactor went wrong. People also used tags if they wanted to generate project-wide diffs. Basically, all the things we routinely do today with commit hashes have to be anticipated and planned for with CVS, since you needed to have the tags available already. + +Branches can be created in CVS, sort of. Branches are just a special kind of tag: + +``` +$ cvs rtag -b TRY_EXPERIMENTAL_THING colors +cvs rtag: Tagging colors +``` + +That only creates the branch (in full view of everyone, by the way), so you still need to switch to it using `cvs update`: + +``` +$ cvs update -r TRY_EXPERIMENTAL_THING +``` + +The above commands switch onto the new branch in your current working directory, but Pragmatic Version Control Using CVS actually advises that you create a new directory to hold your new branch. Presumably its authors found switching directories easier than switching branches in CVS. + +Pragmatic Version Control Using CVS also advises against creating branches off of an existing branch. They recommend only creating branches off of the mainline branch, which in Git is known as `master`. In general, branching was considered an “advanced” CVS skill. In Git, you might start a new branch for almost any trivial reason, but in CVS branching was typically used only when really necessary, such as for releases. + +A branch could later be merged back into the mainline using `cvs update` and the `-j` flag: + +``` +$ cvs update -j TRY_EXPERIMENTAL_THING +``` + +### Thanks for the Commit Histories + +In 2007, Linus Torvalds gave [a talk][4] about Git at Google. Git was very new then, so the talk was basically an attempt to persuade a roomful of skeptical programmers that they should use Git, even though Git was so different from anything then available. If you haven’t already seen the talk, I highly encourage you to watch it. Linus is an entertaining speaker, even if he never fails to be his brash self. He does an excellent job of explaining why the distributed model of version control is better than the centralized one. A lot of his criticism is reserved for CVS in particular. + +Git is a [complex tool][5]. Learning it can be a frustrating experience. But I’m also continually amazed at the things that Git can do. In comparison, CVS is simple and straightforward, though often unable to do many of the operations we now take for granted. Going back and using CVS for a while is an excellent way to find yourself with a new appreciation for Git’s power and flexibility. It illustrates well why understanding the history of software development can be so beneficial—picking up and re-examining obsolete tools will teach you volumes about the why behind the tools we use today. + +If you enjoyed this post, more like it come out every two weeks! Follow [@TwoBitHistory][6] on Twitter or subscribe to the [RSS feed][7] to make sure you know when a new post is out. + +#### Correction + +I’ve been told that there are many organizations, particularly risk-adverse organizations that do things like make medical device software, that still use CVS. Programmers in these organizations have developed little tricks for working around CVS’ limitations, such as making a new branch for almost every change to avoid committing directly to `HEAD`. (Thanks to Michael Kohne for pointing this out.) + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2018/07/07/cvs.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://docs.freebsd.org/44doc/psd/28.cvs/paper.pdf +[2]: https://www.nongnu.org/cvs/ +[3]: http://shop.oreilly.com/product/9780974514000.do +[4]: https://www.youtube.com/watch?v=4XpnKHJAok8 +[5]: https://xkcd.com/1597/ +[6]: https://twitter.com/TwoBitHistory +[7]: https://twobithistory.org/feed.xml From 36aaf2f182df1f726077f935f4b9f424cab334a2 Mon Sep 17 00:00:00 2001 From: darksun Date: Wed, 24 Oct 2018 16:03:15 +0800 Subject: [PATCH 156/158] =?UTF-8?q?=E9=80=89=E9=A2=98:=20The=20IBM=20029?= =?UTF-8?q?=20Card=20Punch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../talk/20180623 The IBM 029 Card Punch.md | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 sources/talk/20180623 The IBM 029 Card Punch.md diff --git a/sources/talk/20180623 The IBM 029 Card Punch.md b/sources/talk/20180623 The IBM 029 Card Punch.md new file mode 100644 index 0000000000..b8af5fb602 --- /dev/null +++ b/sources/talk/20180623 The IBM 029 Card Punch.md @@ -0,0 +1,69 @@ +The IBM 029 Card Punch +====== +Lines of code longer than 80 characters drive me crazy. I appreciate that this is pedantic. I’ve seen people on the internet make good arguments for why the 80-character limit ought to be respected even on our modern Retina-display screens, but those arguments hardly justify the visceral hatred I feel for even that one protruding 81st character. + +There was once a golden era in which it was basically impossible to go over the 80-character limit. The 80-character limit was a physical reality, because there was no 81st column for an 81st character to fit in. Any programmers attempting to name a function something horrendously long and awful would discover, in a moment of delicious, slow-dawning horror, that there literally isn’t room for their whole declaration. + +This golden era was the era of punch card programming. By the 1960s, IBM’s punch cards had set the standard and the standard was that punch cards had 80 columns. The 80-column standard survived into the teletype and dumb terminal era and from there embedded itself into the nooks and crannies of our operating systems. Today, when you launch your terminal emulator and open a new window, odds are it will be 80 characters wide, even though we now have plenty of screen real estate and tend to favor longer identifiers over inscrutable nonsense like `iswcntrl()`. + +If questions on Quora are any indication, many people have trouble imagining what it must have been like to program computers using punch cards. I will admit that for a long time I also didn’t understand how punch card programming could have worked, because it struck me as awfully labor-intensive to punch all those holes. This was a misunderstanding; programmers never punched holes in cards the same way a train conductor does. They had card punch machines (also known as key punches), which allowed them to punch holes in cards using a typewriter-style keyboard. And card punches were hardly new technology—they were around as early as the 1890s. + +One of the most widely used card punch machines was the IBM 029. It is perhaps the best remembered card punch today. + +![][1] + +The IBM 029 was released in 1964 as part of IBM’s System/360 rollout. System/360 was a family of computing systems and peripherals that would go on to dominate the mainframe computing market in the late 1960s. Like many of the other System/360 machines, the 029 was big. This was an era when the distinction between computing machinery and furniture was blurry—the 029 was not something you put on a table but an entire table in itself. The 029 improved upon its predecessor, the 026, by supporting new characters like parentheses and by generally being quieter. It had cool electric blue highlights and was flat and angular whereas the 026 had a 1940s rounded, industrial look. Another of its big selling points was that it could automatically left-pad numeric fields with zeros, demonstrating that JavaScript programmers were not the first programmers too lazy to do their own left-padding. + +But wait, you might say—IBM released a brand-new card punch in 1964? What about that photograph of the Unix gods at Bell Labs using teletype machines in, like, 1970? Weren’t card punching machines passé by the mid- to late-1960s? Well, it might surprise you to know that the 029 was available in IBM’s catalog until as late as 1984. In fact, most programmers programmed using punch cards until well into the 1970s. This doesn’t make much sense given that there were people using teletype machines during World War II. Indeed, the teletype is almost of the same vintage as the card punch. The limiting factor, it turns out, was not the availability of teletypes but the availability of computing time. What kept people from using teletypes was that teletypes assumed an interactive, “online” model of communication with the computer. Before Unix and the invention of timesharing operating systems, your interactive session with a computer would have stopped everyone else from using it, a delay potentially costing thousands of dollars. So programmers instead wrote their programs offline using card punch machines and then fed them into mainframe computers later as batch jobs. Punch cards had the added benefit of being a cheap data store in an era where cheap, reliable data storage was hard to come by. Your programs lived in stacks of cards on your shelves rather than in files on your hard drive. + +So what was it actually like using an IBM 029 card punch? That’s hard to explain without first taking a look at the cards themselves. A typical punch card had 12 rows and 80 columns. The bottom nine rows were the digit rows, numbered one through nine. These rows had the appropriate digit printed in each column. The top three rows, called the “zone” rows, consisted of two blank rows and usually a zero row. Row 12 was at the very top of the card, followed by row 11, then rows zero through nine. This somewhat confusing ordering meant that the top edge of the card was called the 12 edge while the bottom was called the nine edge. A corner of each card was usually clipped to make it easier to keep a stack of cards all turned around the right way. + +![][2] + +When they were first invented, punch cards were meant to be punched with circular holes, but IBM eventually realized that they could fit more columns on a card if the holes were narrow rectangles. Different combinations of holes in a column represented different characters. For human convenience, card punches like the 029 would print each column’s character at the top of the card at the same time as punching the necessary holes. Digits were represented by one punched hole in the appropriate digit row. Alphabetical and symbolic characters were represented by a hole in a zone row and then a combination of one or two holes in the digit rows. The letter A, for example, was represented by a hole in the 12 zone row and another hole in the one row. This was an encoding of sorts, sometimes called the Hollerith code, after the original inventor of the punch card machine. The encoding allowed for only a relatively small character set; lowercase letters, for example, were not represented. Some clever engineer today might wonder why punch cards didn’t just use a binary encoding—after all, with 12 rows, you could encode over 4000 characters. The Hollerith code was used instead because it ensured that no more than three holes ever appeared in a single column. This preserved the structural integrity of the card. A binary encoding would have entailed so many holes that the card would have fallen apart. + +Cards came in different flavors. By the 1960s, 80 columns was the standard, but those 80 columns could be used to represent different things. The basic punch card was unlabeled, but cards meant for COBOL programming, for example, divided the 80 columns into fields. On a COBOL card, the last eight columns were reserved for an identification number, which could be used to automatically sort a stack of cards if it were dropped (apparently a perennial hazard). Another column, column seven, could be used to indicate that the statement on this card was a continuation of a statement on a previous card. This meant that if you were truly desperate you could circumvent the 80-character limit, though whether a two-card statement counts as one long line or just two is unclear. FORTRAN cards were similar but had different fields. Universities often watermarked the punch cards handed out by their computing centers, while other kinds of designs were introduced for special occasions like the [1976 bicentennial][3]. + +Ultimately the cards had to be read and understood by a computer. IBM sold a System/360 peripheral called the IBM 2540 which could read up to 1000 cards per minute. The IBM 2540 ran electrical brushes across the surface of each card which made contact with a plate behind the cards wherever there was a hole. Once read, the System/360 family of computers represented the characters on each punch card using an 8-bit encoding called EBCDIC, which stood for Extended Binary Coded Decimal Interchange Code. EBCDIC was a proper binary encoding, but it still traced its roots back to the punch card via an earlier encoding called BCDIC, a 6-bit encoding which used the low four bits to represent a punch card’s digit rows and the high two bits to represent the zone rows. Punch card programmers would typically hand their cards to the actual computer operators, who would feed the cards into the IBM 2540 and then hand the printed results back to the programmer. The programmer usually didn’t see the computer at all. + +What the programmer did see a lot of was the card punch. The 029 was not a computer, but that doesn’t mean that it wasn’t a complicated machine. The best way to understand what it was like using the 029 is to watch [this instructional video][4] made by the computing center at the University of Michigan in 1967. I’m going to do my best to summarize it here, but if you don’t watch the video you will miss out on all the wonderful clacking and whooshing. + +The 029 was built around a U-shaped track that the punch cards traveled along. On the right-hand side, at the top of the U, was the card hopper, which you would typically load with a fresh stack of cards before using the machine. The IBM 029 worked primarily with 80-column cards, but the card hopper could accommodate smaller cards if needed. Your punch cards would start in the card hopper, travel along the line of the U, and then end up in the stacker, at the top of the U on the left-hand side. The cards would accumulate there in the order that you punched them. + +To turn the machine on, you flipped a switch under the desk at about the height of your knees. You then pressed the “FEED” key twice to get cards loaded into the machine. The business part of the card track, the bottom of the U, was made up of three separate stations: On the right was a kind of waiting area, in the middle was the punching station, and on the left was the reading station. Pressing the “FEED” key twice loaded one card into the punching station and one card into the waiting area behind it. A column number indicator right above the punching station told you which column you were currently punching. With every keystroke, the machine would punch the requisite holes, print the appropriate character at the top of the card, and then advance the card through the punching station by one column. If you punched all 80 columns, the card would automatically be released to the reading station and a new card would be loaded into the punching station. If you wanted this to happen before you reached the 80th column, you could press the “REL” key (for “release”). + +The printed characters made it easy to spot a mistake. But fixing a mistake, as the University of Michigan video warns, is not as easy as whiting out the printed character at the top of the card and writing in a new one. The holes are all that the computer will read. Nor is it as easy as backspacing one space and typing in a new character. The holes have already been punched in the column, after all, and cannot be unpunched. Punching more holes will only produce an invalid combination not associated with any character. The IBM 029 did have a backspace button that moved the punched card backward one column, but the button was placed on the face of the machine instead of on the keyboard. This was probably done to discourage its use, since backspacing was so seldom what the user actually wanted to do. + +Instead, the only way to correct a mistake was scrap the incorrect card and punch a new one. This is where the reading station came in handy. Say you made a mistake in the 68th column of a card. To fix your mistake, you could carefully repunch the first 67 columns of a new card and then punch the correct character in the 68th column. Alternatively, you could release the incorrect card to the reading station, load a new card into the punching station, and hold down the “DUP” key (for duplicate) until the column number indicator reads 68. You could then correct your mistake by punching the correct character. The reading station and the “DUP” key together allowed IBM 029 operators to easily copy the contents of one card to the next. There were all sorts of reasons to do this, but correcting mistakes was the most common. + +The “DUP” key allowed the 029’s operator to invoke the duplicate functionality manually. But the 029 could also duplicate automatically where necessary. This was particularly useful when punched cards were used to record data rather than programs. For example, you might be using each card to record information about a single undergraduate university student. On each card, you might have a field that contains the name of that student’s residence hall. Perhaps you find yourself entering data for all the students in one residence hall at one time. In that case, you’d want the 029 to automatically copy over the previous card’s residence hall field every time you reached the first column of the field. + +Automated behavior like this could be programmed into the 029 by using the program drum. The drum sat upright in the middle of the U above the punching station. You programmed the 029 by punching holes in a card and wrapping that card around the program drum. The punched card allowed you to specify the automatic behavior you expected from the machine at each column of the card currently in the punching station. You could specify that a column should automatically be copied from the previous card, which is how an 029 operator might more quickly enter student records. You could also specify, say, that a particular field should contain numeric or alphabetic characters, or that a given field should be left blank and skipped altogether. The program drum made it much easier to punch schematized cards where certain column ranges had special meanings. There is another [“advanced” instructional video][5] produced by the University of Michigan that covers the program drum that is worth watching, provided, of course, that you have already mastered the basics. + +Watching either of the University of Michigan videos today, what’s surprising is how easy the card punch is to operate. Correcting mistakes is tedious, but otherwise the machine seems to be less of an obstacle than I would have expected. Moving from one card to the next is so seamless that I can imagine COBOL or FORTRAN programmers forgetting that they are creating separate cards rather than one long continuous text file. On the other hand, it’s interesting to consider how card punches, even though they were only an input tool, probably limited how early programming languages evolved. Structured programming would eventually come along and encourage people to think of entire blocks of code as one unit, but I can see how punch card programming’s emphasis on each line made structured programming hard to conceive of. It’s no wonder that punch card programmers were not the ones that decided to enclose blocks with single curly braces entirely on their own lines. How wasteful that would have seemed! + +So even though nobody programs using punch cards anymore, every programmer ought to [try it][6] at least once—if only to understand why COBOL and FORTRAN look the way they do, or how 80 characters somehow became everybody’s favorite character limit. + +If you enjoyed this post, more like it come out every two weeks! Follow [@TwoBitHistory][7] on Twitter or subscribe to the [RSS feed][8] to make sure you know when a new post is out. + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2018/06/23/ibm-029-card-punch.html + +作者:[Two-Bit History][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://twobithistory.org +[b]: https://github.com/lujun9972 +[1]: https://twobithistory.org/images/ibm029_front.jpg +[2]: https://twobithistory.org/images/card.png +[3]: http://www.jkmscott.net/data/Punched%20card%20013.jpg +[4]: https://www.youtube.com/watch?v=kaQmAybWn-w +[5]: https://www.youtube.com/watch?v=SWD1PwNxpoU +[6]: http://www.masswerk.at/keypunch/ +[7]: https://twitter.com/TwoBitHistory +[8]: https://twobithistory.org/feed.xml From 15e2a7784ba5f1f14133ba540ec62b0df72cbb21 Mon Sep 17 00:00:00 2001 From: geek <34594958+geekmar@users.noreply.github.com> Date: Wed, 24 Oct 2018 16:37:43 +0800 Subject: [PATCH 157/158] Delete 20180129 The 5 Best Linux Distributions for Development.md --- ...est Linux Distributions for Development.md | 158 ------------------ 1 file changed, 158 deletions(-) delete mode 100644 sources/tech/20180129 The 5 Best Linux Distributions for Development.md diff --git a/sources/tech/20180129 The 5 Best Linux Distributions for Development.md b/sources/tech/20180129 The 5 Best Linux Distributions for Development.md deleted file mode 100644 index cc11407ff3..0000000000 --- a/sources/tech/20180129 The 5 Best Linux Distributions for Development.md +++ /dev/null @@ -1,158 +0,0 @@ -The 5 Best Linux Distributions for Development -============================================================ - -![Linux distros for devs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/king-penguins_1920.jpg?itok=qmy8htw6 "Linux distros for devs") -Jack Wallen looks at some of the best LInux distributions for development efforts.[Creative Commons Zero][6] - -When considering Linux, there are so many variables to take into account. What package manager do you wish to use? Do you prefer a modern or old-standard desktop interface? Is ease of use your priority? How flexible do you want your distribution? What task will the distribution serve? - -It is that last question which should often be considered first. Is the distribution going to work as a desktop or a server? Will you be doing network or system audits? Or will you be developing? If you’ve spent much time considering Linux, you know that for every task there are several well-suited distributions. This certainly holds true for developers. Even though Linux, by design, is an ideal platform for developers, there are certain distributions that rise above the rest, to serve as great operating systems to serve developers. - -I want to share what I consider to be some of the best distributions for your development efforts. Although each of these five distributions can be used for general purpose development (with maybe one exception), they each serve a specific purpose. You may or may not be surprised by the selections. - -With that said, let’s get to the choices. - -### Debian - -The [Debian][14] distribution winds up on the top of many a Linux list. With good reason. Debian is that distribution from which so many are based. It is this reason why many developers choose Debian. When you develop a piece of software on Debian, chances are very good that package will also work on [Ubuntu][15], [Linux Mint][16], [Elementary OS][17], and a vast collection of other distributions. - -Beyond that obvious answer, Debian also has a very large amount of applications available, by way of the default repositories (Figure 1). - -![Debian apps](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/devel_1.jpg?itok=3mpkS3Kp "Debian apps") -Figure 1: Available applications from the standard Debian repositories.[Used with permission][1] - -To make matters even programmer-friendly, those applications (and their dependencies) are simple to install. Take, for instance, the build-essential package (which can be installed on any distribution derived from Debian). This package includes the likes of dkpg-dev, g++, gcc, hurd-dev, libc-dev, and make—all tools necessary for the development process. The build-essential package can be installed with the command sudo apt install build-essential. - -There are hundreds of other developer-specific applications available from the standard repositories, tools such as: - -* Autoconf—configure script builder - -* Autoproject—creates a source package for a new program - -* Bison—general purpose parser generator - -* Bluefish—powerful GUI editor, targeted towards programmers - -* Geany—lightweight IDE - -* Kate—powerful text editor - -* Eclipse—helps builders independently develop tools that integrate with other people’s tools - -The list goes on and on. - -Debian is also as rock-solid a distribution as you’ll find, so there’s very little concern you’ll lose precious work, by way of the desktop crashing. As a bonus, all programs included with Debian have met the [Debian Free Software Guidelines][18], which adheres to the following “social contract”: - -* Debian will remain 100% free. - -* We will give back to the free software community. - -* We will not hide problems. - -* Our priorities are our users and free software - -* Works that do not meet our free software standards are included in a non-free archive. - -Also, if you’re new to developing on Linux, Debian has a handy [Programming section in their user manual][19]. - -### openSUSE Tumbleweed - -If you’re looking to develop with a cutting-edge, rolling release distribution, [openSUSE][20] offers one of the best in [Tumbleweed][21]. Not only will you be developing with the most up to date software available, you’ll be doing so with the help of openSUSE’s amazing administrator tools … of which includes YaST. If you’re not familiar with YaST (Yet another Setup Tool), it’s an incredibly powerful piece of software that allows you to manage the whole of the platform, from one convenient location. From within YaST, you can also install using RPM Groups. Open YaST, click on RPM Groups (software grouped together by purpose), and scroll down to the Development section to see the large amount of groups available for installation (Figure 2). - - -![openSUSE](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/devel_2.jpg?itok=EeCjn1cx "openSUSE") -Figure 2: Installing package groups in openSUSE Tumbleweed.[Creative Commons Zero][2] - -openSUSE also allows you to quickly install all the necessary devtools with the simple click of a weblink. Head over to the [rpmdevtools install site][22] and click the link for Tumbleweed. This will automatically add the necessary repository and install rpmdevtools. - -By developing with a rolling release distribution, you know you’re working with the most recent releases of installed software. - -### CentOS - -Let’s face it, [Red Hat Enterprise Linux][23] (RHEL) is the de facto standard for enterprise businesses. If you’re looking to develop for that particular platform, and you can’t afford a RHEL license, you cannot go wrong with [CentOS][24]—which is, effectively, a community version of RHEL. You will find many of the packages found on CentOS to be the same as in RHEL—so once you’re familiar with developing on one, you’ll be fine on the other. - -If you’re serious about developing on an enterprise-grade platform, you cannot go wrong starting with CentOS. And because CentOS is a server-specific distribution, you can more easily develop for a web-centric platform. Instead of developing your work and then migrating it to a server (hosted on a different machine), you can easily have CentOS setup to serve as an ideal host for both developing and testing. - -Looking for software to meet your development needs? You only need open up the CentOS Application Installer, where you’ll find a Developer section that includes a dedicated sub-section for Integrated Development Environments (IDEs - Figure 3). - -![CentOS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/devel_3.jpg?itok=0oe4zj9j "CentOS") -Figure 3: Installing a powerful IDE is simple in CentOS.[Used with permission][3] - -CentOS also includes Security Enhanced Linux (SELinux), which makes it easier for you to test your software’s ability to integrate with the same security platform found in RHEL. SELinux can often cause headaches for poorly designed software, so having it at the ready can be a real boon for ensuring your applications work on the likes of RHEL. If you’re not sure where to start with developing on CentOS 7, you can read through the [RHEL 7 Developer Guide][25]. - -### Raspbian - -Let’s face it, embedded systems are all the rage. One easy means of working with such systems is via the Raspberry Pi—a tiny footprint computer that has become incredibly powerful and flexible. In fact, the Raspberry Pi has become the hardware used by DIYers all over the planet. Powering those devices is the [Raspbian][26] operating system. Raspbian includes tools like [BlueJ][27], [Geany][28], [Greenfoot][29], [Sense HAT Emulator][30], [Sonic Pi][31], and [Thonny Python IDE][32], [Python][33], and [Scratch][34], so you won’t want for the necessary development software. Raspbian also includes a user-friendly desktop UI (Figure 4), to make things even easier. - -![Raspbian](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/devel_4.jpg?itok=VLoYak6L "Raspbian") -Figure 4: The Raspbian main menu, showing pre-installed developer software.[Used with permission][4] - -For anyone looking to develop for the Raspberry Pi platform, Raspbian is a must have. If you’d like to give Raspbian a go, without the Raspberry Pi hardware, you can always install it as a VirtualBox virtual machine, by way of the ISO image found [here][35]. - -### Pop!_OS - -Don’t let the name full you, [System76][36]’s [Pop!_OS][37] entry into the world of operating systems is serious. And although what System76 has done to this Ubuntu derivative may not be readily obvious, it is something special. - -The goal of System76 is to create an operating system specific to the developer, maker, and computer science professional. With a newly-designed GNOME theme, Pop!_OS is beautiful (Figure 5) and as highly functional as you would expect from both the hardware maker and desktop designers. - -### [devel_5.jpg][11] - -![Pop!_OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/devel_5.jpg?itok=n4K7k7Gd "Pop!_OS") -Figure 5: The Pop!_OS Desktop.[Used with permission][5] - -But what makes Pop!_OS special is the fact that it is being developed by a company dedicated to Linux hardware. This means, when you purchase a System76 laptop, desktop, or server, you know the operating system will work seamlessly with the hardware—on a level no other company can offer. I would predict that, with Pop!_OS, System76 will become the Apple of Linux. - -### Time for work - -In their own way, each of these distributions. You have a stable desktop (Debian), a cutting-edge desktop (openSUSE Tumbleweed), a server (CentOS), an embedded platform (Raspbian), and a distribution to seamless meld with hardware (Pop!_OS). With the exception of Raspbian, any one of these distributions would serve as an outstanding development platform. Get one installed and start working on your next project with confidence. - - _Learn more about Linux through the free ["Introduction to Linux" ][13]course from The Linux Foundation and edX._ - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/learn/intro-to-linux/2018/1/5-best-linux-distributions-development - -作者:[JACK WALLEN ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com/users/jlwallen -[1]:https://www.linux.com/licenses/category/used-permission -[2]:https://www.linux.com/licenses/category/creative-commons-zero -[3]:https://www.linux.com/licenses/category/used-permission -[4]:https://www.linux.com/licenses/category/used-permission -[5]:https://www.linux.com/licenses/category/used-permission -[6]:https://www.linux.com/licenses/category/creative-commons-zero -[7]:https://www.linux.com/files/images/devel1jpg -[8]:https://www.linux.com/files/images/devel2jpg -[9]:https://www.linux.com/files/images/devel3jpg -[10]:https://www.linux.com/files/images/devel4jpg -[11]:https://www.linux.com/files/images/devel5jpg -[12]:https://www.linux.com/files/images/king-penguins1920jpg -[13]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux -[14]:https://www.debian.org/ -[15]:https://www.ubuntu.com/ -[16]:https://linuxmint.com/ -[17]:https://elementary.io/ -[18]:https://www.debian.org/social_contract -[19]:https://www.debian.org/doc/manuals/debian-reference/ch12.en.html -[20]:https://www.opensuse.org/ -[21]:https://en.opensuse.org/Portal:Tumbleweed -[22]:https://software.opensuse.org/download.html?project=devel%3Atools&package=rpmdevtools -[23]:https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux -[24]:https://www.centos.org/ -[25]:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/pdf/developer_guide/Red_Hat_Enterprise_Linux-7-Developer_Guide-en-US.pdf -[26]:https://www.raspberrypi.org/downloads/raspbian/ -[27]:https://www.bluej.org/ -[28]:https://www.geany.org/ -[29]:https://www.greenfoot.org/ -[30]:https://www.raspberrypi.org/blog/sense-hat-emulator/ -[31]:http://sonic-pi.net/ -[32]:http://thonny.org/ -[33]:https://www.python.org/ -[34]:https://scratch.mit.edu/ -[35]:http://rpf.io/x86iso -[36]:https://system76.com/ -[37]:https://system76.com/pop From f74e173570d7cda0bf1b44cd8914e24d82ef22d3 Mon Sep 17 00:00:00 2001 From: geek <34594958+geekmar@users.noreply.github.com> Date: Wed, 24 Oct 2018 16:38:36 +0800 Subject: [PATCH 158/158] Create 20180129 The 5 Best Linux Distributions for Development.md --- ...est Linux Distributions for Development.md | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 translated/tech/20180129 The 5 Best Linux Distributions for Development.md diff --git a/translated/tech/20180129 The 5 Best Linux Distributions for Development.md b/translated/tech/20180129 The 5 Best Linux Distributions for Development.md new file mode 100644 index 0000000000..7bf70f8d78 --- /dev/null +++ b/translated/tech/20180129 The 5 Best Linux Distributions for Development.md @@ -0,0 +1,102 @@ +对于开发者来说5个最好的Linux发行版 +============================================================ + ![Linux distros for devs](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/king-penguins_1920.jpg?itok=qmy8htw6 "Linux distros for devs") + Jack Wallen介绍了一些非常适合用来做开发工作的Linux发行版本.[Creative Commons Zero][6] + 在考虑使用Linux时,需要做很多的考量。你希望使用什么包管理器?你更喜欢现代还是比较旧的桌面界面?易用性是你使用Linux的首选吗?你希望分发的灵活性?发行版的服务性任务是什么? +这是你在开始使用Linux之前必须考虑的问题。发行版是作为桌面还是服务器运行?你会做网络或者系统审计吗?或者你会开发?如果你花了很多时间考虑Linux,你知道每个任务都有非常合适的Linux发行版。这当然非常适用于开发人员。尽管Linux在设计上对于开发人员来说是一个理想的平台,但某些发行版高于其他的发行版,可以作为最好的开发人员的操作系统去服务开发人员。 + 我想来分享我自己认为是你在做开发工作当中的最佳Linux发行版。虽然这五个发行版的每一个都可以用来通用开发(可能有一个是例外),但是它们都有各自的特定目的,你看会或不会对这些选择感觉到惊讶 + 话虽如此,让我们做出选择 + ### Debian + 在[Debian][14]的发行版中许多Linux列表中排名靠前。 有充分的理由。 Debian是许多人所依赖的发行版. 这就是为什么更多的开发人员去选择debian的理由。 当你在Debian上开发一个软件的时候,很有可能该软件包可以适用于[Ubuntu][15], [Linux Mint][16], [Elementary OS][17],以及大量的其他Debian发行版。 + 除了这个非常明显的答案之外,Debian还通过默认存储库提供了大量可用的应用程序(图1)。 + ![Debian apps](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/devel_1.jpg?itok=3mpkS3Kp "Debian apps") + 图 1: 标准的Debian存储库里面可用的应用程序。[Used with permission][1] + 为了让程序员友好,这些应用程序 (以及它们的依赖项) 易于安装.例如,构建必需的包(可以安装在Debian的任何衍生发行版上)。该软件包包括dkpg-dev,g ++,gcc,hurd-dev,libc-dev以及开发过程所需的make-all工具。可以使用命令sudo apt install build-essential安装build-essential软件包。 + 标准存储库当中提供了数百种的特定于开发人员的应用程序,例如: + * Autoconf—配置构建脚本的软件 + * Autoproject—为新程序创建源码包 + * Bison—通用的解析生成器 + * Bluefish—面向程序员的强大GUI编辑器 + * Geany—轻量化的IDE + * Kate—强大的文本编辑器 + * Eclipse—帮助构建者独立开发与其他工具的集成性软件 + 这个清单一直在继续更新. + Debian也是你能找到的坚于磐石的发行版,因此很少有人担心因为桌面崩溃而让你失去宝贵的工作。作为奖励,Debian的所有应用程序都必须符合[Debian自由软件指南][18], 该指南遵守以下 “社会契约”: + * Debian 保持完全免费. + * 我们将无偿回馈自由软件社区. + * 我们不会隐藏问题. + * 我们的首要任务是我们的用户和自由软件 + * 不符合我们的免费软件标准的作品在非免费档案中.. + 此外,你不熟悉在Linux上进行开发,Debian在其[用户手册][19]中有一个方便编程的部分。 + ### openSUSE Tumbleweed (滚动更新版) + 如果你希望开发出最前沿的滚动发行版本, [openSUSE][20] 将提供最好的[Tumbleweed][21]之一。 还可以借助openSUSE当中令人惊叹的管理员工具(其中包括YaST)来实现这一目标。如果你不熟悉YaST(又一个设置工具)的话,它是一个非常强大的软件,允许您从一个方便的位置来管理整个平台。在YaST中,您还可以使用RPM组进行安装。打开YaST,单击RPM Groups(按目的分组的软件),然后向下滚动到Development部分以查看可安装的大量组(图2) + ![openSUSE](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/devel_2.jpg?itok=EeCjn1cx "openSUSE") + 图 2: 在openSUSE Tumbleweed中安装软件包组.[Creative Commons Zero][2] + openSUSE还允许您通过简单的单击链接快速安装所有必需的devtools [rpmdevtools安装页面][22], 然后单击Tumbleweed的链接。这将自动添加必要的存储库并安装rpmdevtools + 对于开发者来说,通过滚动版本进行开发,你可以知道你已安装的软件是最新版本。 + ### CentOS + 让我们来看一下, [红帽企业版Linux][23] (RHEL) 是企业事务的事实标准. 如果你正在寻找针对特定平台进行开发,并且你有点担心无法承担RHEL的许可证,那么[CentOS][24]就是你不错的选择— 实际上,它是RHEL的社区版本。你会发现CentOS上的许多软件包与RHEL中的软件包相同 - 所以一旦熟悉了一个软件包,你就可以使用其他的软件包。 + 如果你认真考虑在企业级平台上进行开发,那么CentOS就是不错的选择。而且由于CentOS是特定于服务器的发行版,因此您可以更轻松地以Web为中心的平台进行开发。您可以轻松地将CentOS作为开发和测试的理想主机,而不是开发您的工作然后将其迁移到服务器(托管在不同的计算机上). + 寻找满足你开发需求的软件? 你只需要打开CentOS软件中心, 其中包含了集成开发环境(IDE - 图3)的专用子部分 + ![CentOS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/devel_3.jpg?itok=0oe4zj9j "CentOS") + 图 3: 在CentOS中安装功能强大的IDE很简单。.[Used with permission][3] + Centos还包括安全增强性的Linux(SElinux),它使你可以更加轻松的去测试你的软件与RHEL中的同一安全平台的集成功能,SElinux经常会让设计不佳的软件感到头疼,因此准备了它可以真正有利于确保你的应用程序在RHEL之类的应用程序上面运行。如果你不确定如何在Centos上进行开发工作。你可以阅读[RHEL 7 开发人员指南][25]. + ### Raspbian + 让我们来看一下, 嵌入式操作系统风靡一时. 使用这种 操作系统最简单的一种方法就是通过Raspberry Pi——一种极小的单片机(也可以称为小型计算机). 事实上,Raspberry Pi 已经成为了全球喜爱DIY用户使用的硬件. 为这些 设备供电的是 [Raspbian][26]操作系统. Raspbian包含[BlueJ][27], [Geany][28], [Greenfoot][29], [Sense HAT Emulator][30], [Sonic Pi][31], 和 [Thonny Python IDE][32], [Python][33], 和 [Scratch][34]等一些工具, 因此你不需要开发软件。Raspbian还包括一个用户友好的桌面UI(图4),使事情变得更加容易。 + ![Raspbian](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/devel_4.jpg?itok=VLoYak6L "Raspbian") + 图 4: Raspbian主菜单,显示预安装的开发人员软件.[Used with permission][4] + 对于任何想要对Raspberry Pi平台开发的人来说,Raspbian是必要的。如果你想在不使用Raspberry Pi硬件的情况下使用Raspbian系统,您可以通过下载[此处][35]的ISO映像将其安装在VirtualBox虚拟机中 + ### Pop!_OS + 不要让这个名字迷惑你,,不要让这个名字迷惑你, 进入[System76][36]的 [Pop!_OS][37]操作系统世界是非常严格的. 虽然System76对这个Ubuntu衍生产品做了很多修改但不是很明显,但这是特别的。 + System76的目标是创建一个特定于开发人员,制造商和计算机科学专业人员的操作系统。通过新设计的GNOME主题,Pop!_OS非常漂亮(图5),并且功能与硬件制造商使桌面设计人员一样强大。 +### [devel_5.jpg][11] + ![Pop!_OS](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/devel_5.jpg?itok=n4K7k7Gd "Pop!_OS") + 图 5: Pop!_OS 桌面.[Used with permission][5] + 但是,Pop!_OS的特殊之处在于它是由一家致力于Linux硬件的公司开发的。这意味着,当您购买System76笔记本电脑,台式机或服务器时,您就会知道操作系统将与硬件无缝协作 - 这是其他公司无法提供的。我预测,Pop!_OS将使System76将成为Linux界Apple。 + ### 工作时间 + 以他们自己的方式,每个发行版。你有一个稳定的桌面(Debian),一个尖端的桌面(openSUSE Tumbleweed),一个服务器(CentOS),一个嵌入式平台(Raspbian),以及一个与硬件无缝融合的发行版(Pop!_OS)。除了Raspbian之外,这些发行版中的任何一个都将成为一个出色的开发平台。安装一个并开始自信地开展下一个项目。 +可以通过Linux Foundation和edX 免费提供的["Linux简介" ][13]来了解更多的有关Linux信息 +-------------------------------------------------------------------------------- + via: https://www.linux.com/blog/learn/intro-to-linux/2018/1/5-best-linux-distributions-development + 作者:[JACK WALLEN ][a] +译者:[geekmar](https://github.com/geekmar) +校对:[校对者ID](https://github.com/校对者ID) + 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + [a]:https://www.linux.com/users/jlwallen +[1]:https://www.linux.com/licenses/category/used-permission +[2]:https://www.linux.com/licenses/category/creative-commons-zero +[3]:https://www.linux.com/licenses/category/used-permission +[4]:https://www.linux.com/licenses/category/used-permission +[5]:https://www.linux.com/licenses/category/used-permission +[6]:https://www.linux.com/licenses/category/creative-commons-zero +[7]:https://www.linux.com/files/images/devel1jpg +[8]:https://www.linux.com/files/images/devel2jpg +[9]:https://www.linux.com/files/images/devel3jpg +[10]:https://www.linux.com/files/images/devel4jpg +[11]:https://www.linux.com/files/images/devel5jpg +[12]:https://www.linux.com/files/images/king-penguins1920jpg +[13]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux +[14]:https://www.debian.org/ +[15]:https://www.ubuntu.com/ +[16]:https://linuxmint.com/ +[17]:https://elementary.io/ +[18]:https://www.debian.org/social_contract +[19]:https://www.debian.org/doc/manuals/debian-reference/ch12.en.html +[20]:https://www.opensuse.org/ +[21]:https://en.opensuse.org/Portal:Tumbleweed +[22]:https://software.opensuse.org/download.html?project=devel%3Atools&package=rpmdevtools +[23]:https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux +[24]:https://www.centos.org/ +[25]:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/pdf/developer_guide/Red_Hat_Enterprise_Linux-7-Developer_Guide-en-US.pdf +[26]:https://www.raspberrypi.org/downloads/raspbian/ +[27]:https://www.bluej.org/ +[28]:https://www.geany.org/ +[29]:https://www.greenfoot.org/ +[30]:https://www.raspberrypi.org/blog/sense-hat-emulator/ +[31]:http://sonic-pi.net/ +[32]:http://thonny.org/ +[33]:https://www.python.org/ +[34]:https://scratch.mit.edu/ +[35]:http://rpf.io/x86iso +[36]:https://system76.com/ +[37]:https://system76.com/pop