diff --git a/published/20150616 Computer Laboratory - Raspberry Pi- Lesson 8 Screen03.md b/published/20150616 Computer Laboratory - Raspberry Pi- Lesson 8 Screen03.md new file mode 100644 index 0000000000..6ec24f8780 --- /dev/null +++ b/published/20150616 Computer Laboratory - Raspberry Pi- Lesson 8 Screen03.md @@ -0,0 +1,460 @@ +[#]: collector: (lujun9972) +[#]: translator: (qhwdw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10585-1.html) +[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 8 Screen03) +[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen03.html) +[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) + +计算机实验室之树莓派:课程 8 屏幕03 +====== + +屏幕03 课程基于屏幕02 课程来构建,它教你如何绘制文本,和一个操作系统命令行参数上的一个小特性。假设你已经有了[课程 7:屏幕02][1] 的操作系统代码,我们将以它为基础来构建。 + +### 1、字符串的理论知识 + +是的,我们的任务是为这个操作系统绘制文本。我们有几个问题需要去处理,最紧急的那个可能是如何去保存文本。令人难以置信的是,文本是迄今为止在计算机上最大的缺陷之一。原本应该是简单的数据类型却导致了操作系统的崩溃,从而削弱其他方面的加密效果,并给使用其它字母表的用户带来了许多问题。尽管如此,它仍然是极其重要的数据类型,因为它将计算机和用户很好地连接起来。文本是计算机能够理解的非常好的结构,同时人类使用它时也有足够的可读性。 + +那么,文本是如何保存的呢?非常简单,我们使用一种方法,给每个字母分配一个唯一的编号,然后我们保存一系列的这种编号。看起来很容易吧。问题是,那个编号的数量是不固定的。一些文本段可能比其它的长。保存普通数字,我们有一些固有的限制,即:32 位,我们不能超过这个限制,我们要添加方法去使用该长度的数字等等。“文本”这个术语,我们经常也叫它“字符串”,我们希望能够写一个可用于可变长度字符串的函数,否则就需要写很多函数!对于一般的数字来说,这不是个问题,因为只有几种通用的数字格式(字节、字、半字节、双字节)。 + +> 可变数据类型(比如文本)要求能够进行很复杂的处理。 + +因此,如何判断字符串长度?我想显而易见的答案是存储字符串的长度,然后去存储组成字符串的字符。这称为长度前缀,因为长度位于字符串的前面。不幸的是,计算机科学家的先驱们不同意这么做。他们认为使用一个称为空终止符(`NULL`)的特殊字符(用 `\0` 表示)来表示字符串结束更有意义。这样确定简化了许多字符串算法,因为你只需要持续操作直到遇到空终止符为止。不幸的是,这成为了许多安全问题的根源。如果一个恶意用户给你一个特别长的字符串会发生什么状况?如果没有足够的空间去保存这个特别长的字符串会发生什么状况?你可以使用一个字符串复制函数来做复制,直到遇到空终止符为止,但是因为字符串特别长,而覆写了你的程序,怎么办?这看上去似乎有些较真,但是,缓冲区溢出攻击还是经常发生。长度前缀可以很容易地缓解这种问题,因为它可以很容易地推算出保存这个字符串所需要的缓冲区的长度。作为一个操作系统开发者,我留下这个问题,由你去决定如何才能更好地存储文本。 + +> 缓冲区溢出攻击祸害计算机由来已久。最近,Wii、Xbox 和 Playstation 2、以及大型系统如 Microsoft 的 Web 和数据库服务器,都遭受到缓冲区溢出攻击。 + +接下来的事情是,我们需要确定的是如何最好地将字符映射到数字。幸运的是,这是高度标准化的,我们有两个主要的选择,Unicode 和 ASCII。Unicode 几乎将每个有用的符号都映射为数字,作为代价,我们需要有很多很多的数字,和一个更复杂的编码方法。ASCII 为每个字符使用一个字节,因此它仅保存拉丁字母、数字、少数符号和少数特殊字符。因此,ASCII 是非常易于实现的,与之相比,Unicode 的每个字符占用的空间并不相同,这使得字符串算法更棘手。通常,操作系统上字符使用 ASCII,并不是为了显示给最终用户的(开发者和专家用户除外),给终端用户显示信息使用 Unicode,因为 Unicode 能够支持像日语字符这样的东西,并且因此可以实现本地化。 + +幸运的是,在这里我们不需要去做选择,因为它们的前 128 个字符是完全相同的,并且编码也是完全一样的。 + +表 1.1 ASCII/Unicode 符号 0-127 + +| | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | f | | +|----| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ----| +| 00 | NUL | SOH | STX | ETX | EOT | ENQ | ACK | BEL | BS | HT | LF | VT | FF | CR | SO | SI | | +| 10 | DLE | DC1 | DC2 | DC3 | DC4 | NAK | SYN | ETB | CAN | EM | SUB | ESC | FS | GS | RS | US | | +| 20 | ! | " | # | $ | % | & | . | ( | ) | * | + | , | - | . | / | | | +| 30 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | : | ; | < | = | > | ? | | +| 40 | @ | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | | +| 50 | P | Q | R | S | T | U | V | W | X | Y | Z | [ | \ | ] | ^ | _ | | +| 60 | ` | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | | +| 70 | p | q | r | s | t | u | v | w | x | y | z | { | | | } | ~ | DEL | + +这个表显示了前 128 个符号。一个符号的十六进制表示是行的值加上列的值,比如 A 是 4116。你可以惊奇地发现前两行和最后的值。这 33 个特殊字符是不可打印字符。事实上,许多人都忽略了它们。它们之所以存在是因为 ASCII 最初设计是基于计算机网络来传输数据的一种方法。因此它要发送的信息不仅仅是符号。你应该学习的重要的特殊字符是 `NUL`,它就是我们前面提到的空终止符。`HT` 水平制表符就是我们经常说的 `tab`,而 `LF` 换行符用于生成一个新行。你可能想研究和使用其它特殊字符在你的操行系统中的意义。 + +### 2、字符 + +到目前为止,我们已经知道了一些关于字符串的知识,我们可以开始想想它们是如何显示的。为了显示一个字符串,我们需要做的最基础的事情是能够显示一个字符。我们的第一个任务是编写一个 `DrawCharacter` 函数,给它一个要绘制的字符和一个位置,然后它将这个字符绘制出来。 + +这就很自然地引出关于字体的讨论。我们已经知道有许多方式去按照选定的字体去显示任何给定的字母。那么字体又是如何工作的呢?在计算机科学的早期阶段,字体就是所有字母的一系列小图片而已,这种字体称为位图字体,而所有的字符绘制方法就是将图片复制到屏幕上。当人们想去调整字体大小时就出问题了。有时我们需要大的字母,而有时我们需要的是小的字母。尽管我们可以为每个字体、每种大小、每个字符都绘制新图片,但这种作法过于单调乏味。所以,发明了矢量字体。矢量字体不包含字体的图像,它包含的是如何去绘制字符的描述,即:一个 `o` 可能是最大字母高度的一半为半径绘制的圆。现代操作系统都几乎仅使用这种字体,因为这种字体在任何分辨率下都很完美。 + +> 在许多操作系统中使用的 TrueType 字体格式是很强大的,它内置有它自己的汇编语言,以确保在任何分辨率下字母看起来都是正确的。 + +不幸的是,虽然我很想包含一个矢量字体的格式的实现,但它的内容太多了,将占用这个网站的剩余部分。所以,我们将去实现一个位图字体,可是,如果你想去做一个像样的图形操作系统,那么矢量字体将是很有用的。 + +在下载页面上的字体节中,我们提供了几个 `.bin` 文件。这些只是字体的原始二进制数据文件。为完成本教程,从等宽、单色、8x16 节中挑选你喜欢的字体。然后下载它并保存到 `source` 目录中并命名为 `font.bin` 文件。这些文件只是每个字母的单色图片,它们每个字母刚好是 8 x 16 个像素。所以,每个字母占用 16 字节,第一个字节是第一行,第二个字节是第二行,依此类推。 + +![bitmap](https://ws2.sinaimg.cn/large/006tNc79ly1fzzb2064agj305l0apt96.jpg) + +这个示意图展示了等宽、单色、8x16 的字符 A 的 “Bitstream Vera Sans Mono” 字体。在这个文件中,我们可以找到,它从第 4116 × 1016 = 41016 字节开始的十六进制序列: + +``` +00, 00, 00, 10, 28, 28, 28, 44, 44, 7C, C6, 82, 00, 00, 00, 00 +``` + +在这里我们将使用等宽字体,因为等宽字体的每个字符大小是相同的。不幸的是,大多数字体的复杂之处就是因为它的宽度不同,从而导致它的显示代码更复杂。在下载页面上还包含有几个其它的字体,并包含了这种字体的存储格式介绍。 + +我们回到正题。复制下列代码到 `drawing.s` 中的 `graphicsAddress` 的 `.int 0` 之后。 + +```assembly +.align 4 +font: +.incbin "font.bin" +``` + +> `.incbin "file"` 插入来自文件 “file” 中的二进制数据。 + +这段代码复制文件中的字体数据到标签为 `font` 的地址。我们在这里使用了一个 `.align 4` 去确保每个字符都是从 16 字节的倍数开始,这是一个以后经常用到的用于加快访问速度的技巧。 + +现在我们去写绘制字符的方法。我在下面给出了伪代码,你可以尝试自己去实现它。按惯例 `>>` 的意思是逻辑右移。 + +```c +function drawCharacter(r0 is character, r1 is x, r2 is y) + if character > 127 then exit + set charAddress to font + character × 16 + for row = 0 to 15 + set bits to readByte(charAddress + row) + for bit = 0 to 7 + if test(bits >> bit, 0x1) + then setPixel(x + bit, y + row) + next + next + return r0 = 8, r1 = 16 +end function +``` + +如果直接去实现它,这显然不是个高效率的做法。像绘制字符这样的事情,效率是最重要的。因为我们要频繁使用它。我们来探索一些改善的方法,使其成为最优化的汇编代码。首先,因为我们有一个 `× 16`,你应该会马上想到它等价于逻辑左移 4 位。紧接着我们有一个变量 `row`,它只与 `charAddress` 和 `y` 相加。所以,我们可以通过增加替代变量来消除它。现在唯一的问题是如何判断我们何时完成。这时,一个很好用的 `.align 4` 上场了。我们知道,`charAddress` 将从包含 0 的低位半字节开始。这意味着我们可以通过检查低位半字节来看到进入字符数据的程度。 + +虽然我们可以消除对 `bit` 的需求,但我们必须要引入新的变量才能实现,因此最好还是保留它。剩下唯一的改进就是去除嵌套的 `bits >> bit`。 + +```c +function drawCharacter(r0 is character, r1 is x, r2 is y) + if character > 127 then exit + set charAddress to font + character << 4 + loop + set bits to readByte(charAddress) + set bit to 8 + loop + set bits to bits << 1 + set bit to bit - 1 + if test(bits, 0x100) + then setPixel(x + bit, y) + until bit = 0 + set y to y + 1 + set chadAddress to chadAddress + 1 + until charAddress AND 0b1111 = 0 + return r0 = 8, r1 = 16 +end function +``` + +现在,我们已经得到了非常接近汇编代码的代码了,并且代码也是经过优化的。下面就是上述代码用汇编写出来的代码。 + +```assembly +.globl DrawCharacter +DrawCharacter: +cmp r0,#127 +movhi r0,#0 +movhi r1,#0 +movhi pc,lr + +push {r4,r5,r6,r7,r8,lr} +x .req r4 +y .req r5 +charAddr .req r6 +mov x,r1 +mov y,r2 +ldr charAddr,=font +add charAddr, r0,lsl #4 + +lineLoop$: + + bits .req r7 + bit .req r8 + ldrb bits,[charAddr] + mov bit,#8 + + charPixelLoop$: + + subs bit,#1 + blt charPixelLoopEnd$ + lsl bits,#1 + tst bits,#0x100 + beq charPixelLoop$ + + add r0,x,bit + mov r1,y + bl DrawPixel + + teq bit,#0 + bne charPixelLoop$ + + charPixelLoopEnd$: + .unreq bit + .unreq bits + add y,#1 + add charAddr,#1 + tst charAddr,#0b1111 + bne lineLoop$ + +.unreq x +.unreq y +.unreq charAddr + +width .req r0 +height .req r1 +mov width,#8 +mov height,#16 + +pop {r4,r5,r6,r7,r8,pc} +.unreq width +.unreq height +``` + +### 3、字符串 + +现在,我们可以绘制字符了,我们可以绘制文本了。我们需要去写一个方法,给它一个字符串为输入,它通过递增位置来绘制出每个字符。为了做的更好,我们应该去实现新的行和制表符。是时候决定关于空终止符的问题了,如果你想让你的操作系统使用它们,可以按需来修改下面的代码。为避免这个问题,我将给 `DrawString` 函数传递一个字符串长度,以及字符串的地址,和 `x` 和 `y` 的坐标作为参数。 + +```c +function drawString(r0 is string, r1 is length, r2 is x, r3 is y) + set x0 to x + for pos = 0 to length - 1 + set char to loadByte(string + pos) + set (cwidth, cheight) to DrawCharacter(char, x, y) + if char = '\n' then + set x to x0 + set y to y + cheight + otherwise if char = '\t' then + set x1 to x + until x1 > x0 + set x1 to x1 + 5 × cwidth + loop + set x to x1 + otherwise + set x to x + cwidth + end if + next +end function +``` + +同样,这个函数与汇编代码还有很大的差距。你可以随意去尝试实现它,即可以直接实现它,也可以简化它。我在下面给出了简化后的函数和汇编代码。 + +很明显,写这个函数的人并不很有效率(感到奇怪吗?它就是我写的)。再说一次,我们有一个 `pos` 变量,它用于递增及与其它东西相加,这是完全没有必要的。我们可以去掉它,而同时进行长度递减,直到减到 0 为止,这样就少用了一个寄存器。除了那个烦人的乘以 5 以外,函数的其余部分还不错。在这里要做的一个重要事情是,将乘法移到循环外面;即便使用位移运算,乘法仍然是很慢的,由于我们总是加一个乘以 5 的相同的常数,因此没有必要重新计算它。实际上,在汇编代码中它可以在一个操作数中通过参数移位来实现,因此我将代码改变为下面这样。 + +```c +function drawString(r0 is string, r1 is length, r2 is x, r3 is y) + set x0 to x + until length = 0 + set length to length - 1 + set char to loadByte(string) + set (cwidth, cheight) to DrawCharacter(char, x, y) + if char = '\n' then + set x to x0 + set y to y + cheight + otherwise if char = '\t' then + set x1 to x + set cwidth to cwidth + cwidth << 2 + until x1 > x0 + set x1 to x1 + cwidth + loop + set x to x1 + otherwise + set x to x + cwidth + end if + set string to string + 1 + loop +end function +``` + +以下是它的汇编代码: + +```assembly +.globl DrawString +DrawString: +x .req r4 +y .req r5 +x0 .req r6 +string .req r7 +length .req r8 +char .req r9 +push {r4,r5,r6,r7,r8,r9,lr} + +mov string,r0 +mov x,r2 +mov x0,x +mov y,r3 +mov length,r1 + +stringLoop$: + subs length,#1 + blt stringLoopEnd$ + + ldrb char,[string] + add string,#1 + + mov r0,char + mov r1,x + mov r2,y + bl DrawCharacter + cwidth .req r0 + cheight .req r1 + + teq char,#'\n' + moveq x,x0 + addeq y,cheight + beq stringLoop$ + + teq char,#'\t' + addne x,cwidth + bne stringLoop$ + + add cwidth, cwidth,lsl #2 + x1 .req r1 + mov x1,x0 + + stringLoopTab$: + add x1,cwidth + cmp x,x1 + bge stringLoopTab$ + mov x,x1 + .unreq x1 + b stringLoop$ +stringLoopEnd$: +.unreq cwidth +.unreq cheight + +pop {r4,r5,r6,r7,r8,r9,pc} +.unreq x +.unreq y +.unreq x0 +.unreq string +.unreq length +``` + +这个代码中非常聪明地使用了一个新运算,`subs` 是从一个操作数中减去另一个数,保存结果,然后将结果与 0 进行比较。实现上,所有的比较都可以实现为减法后的结果与 0 进行比较,但是结果通常会丢弃。这意味着这个操作与 `cmp` 一样快。 + +> `subs reg,#val` 从寄存器 `reg` 中减去 `val`,然后将结果与 `0` 进行比较。 + +### 4、你的意愿是我的命令行 + +现在,我们可以输出字符串了,而挑战是找到一个有意思的字符串去绘制。一般在这样的教程中,人们都希望去绘制 “Hello World!”,但是到目前为止,虽然我们已经能做到了,我觉得这有点“君临天下”的感觉(如果喜欢这种感觉,请随意!)。因此,作为替代,我们去继续绘制我们的命令行。 + +有一个限制是我们所做的操作系统是用在 ARM 架构的计算机上。最关键的是,在它们引导时,给它一些信息告诉它有哪些可用资源。几乎所有的处理器都有某些方式来确定这些信息,而在 ARM 上,它是通过位于地址 10016 处的数据来确定的,这个数据的格式如下: + + 1. 数据是可分解的一系列的标签。 + 2. 这里有九种类型的标签:`core`、`mem`、`videotext`、`ramdisk`、`initrd2`、`serial`、`revision`、`videolfb`、`cmdline`。 + 3. 每个标签只能出现一次,除了 `core` 标签是必不可少的之外,其它的都是可有可无的。 + 4. 所有标签都依次放置在地址 `0x100` 处。 + 5. 标签列表的结束处总是有两个word,它们全为 0。 + 6. 每个标签的字节数都是 4 的倍数。 + 7. 每个标签都是以标签中(以字为单位)的标签大小开始(标签包含这个数字)。 + 8. 紧接着是包含标签编号的一个半字。编号是按上面列出的顺序,从 1 开始(`core` 是 1,`cmdline` 是 9)。 + 9. 紧接着是一个包含 544116 的半字。 + 10. 之后是标签的数据,它根据标签不同是可变的。数据大小(以字为单位)+ 2 的和总是与前面提到的长度相同。 + 11. 一个 `core` 标签的长度可以是 2 个字也可以是 5 个字。如果是 2 个字,表示没有数据,如果是 5 个字,表示它有 3 个字的数据。 + 12. 一个 `mem` 标签总是 4 个字的长度。数据是内存块的第一个地址,和内存块的长度。 + 13. 一个 `cmdline` 标签包含一个 `null` 终止符字符串,它是个内核参数。 + + +在目前的树莓派版本中,只提供了 `core`、`mem` 和 `cmdline` 标签。你可以在后面找到它们的用法,更全面的参考资料在树莓派的参考页面上。现在,我们感兴趣的是 `cmdline` 标签,因为它包含一个字符串。我们继续写一些搜索这个命令行(`cmdline`)标签的代码,如果找到了,以每个条目一个新行的形式输出它。命令行只是图形处理器或用户认为操作系统应该知道的东西的一个列表。在树莓派上,这包含了 MAC 地址、序列号和屏幕分辨率。字符串本身也是一个由空格隔开的表达式(像 `key.subkey=value` 这样的)的列表。 + +> 几乎所有的操作系统都支持一个“命令行”的程序。它的想法是为选择一个程序所期望的行为而提供一个通用的机制。 + +我们从查找 `cmdline` 标签开始。将下列的代码复制到一个名为 `tags.s` 的新文件中。 + +```assembly +.section .data +tag_core: .int 0 +tag_mem: .int 0 +tag_videotext: .int 0 +tag_ramdisk: .int 0 +tag_initrd2: .int 0 +tag_serial: .int 0 +tag_revision: .int 0 +tag_videolfb: .int 0 +tag_cmdline: .int 0 +``` + +通过标签列表来查找是一个很慢的操作,因为这涉及到许多内存访问。因此,我们只想做一次。代码创建一些数据,用于保存每个类型的第一个标签的内存地址。接下来,用下面的伪代码就可以找到一个标签了。 + +```c +function FindTag(r0 is tag) + if tag > 9 or tag = 0 then return 0 + set tagAddr to loadWord(tag_core + (tag - 1) × 4) + if not tagAddr = 0 then return tagAddr + if readWord(tag_core) = 0 then return 0 + set tagAddr to 0x100 + loop forever + set tagIndex to readHalfWord(tagAddr + 4) + if tagIndex = 0 then return FindTag(tag) + if readWord(tag_core+(tagIndex-1)×4) = 0 + then storeWord(tagAddr, tag_core+(tagIndex-1)×4) + set tagAddr to tagAddr + loadWord(tagAddr) × 4 + end loop +end function +``` + +这段代码已经是优化过的,并且很接近汇编了。它尝试直接加载标签,第一次这样做是有些乐观的,但是除了第一次之外的其它所有情况都是可以这样做的。如果失败了,它将去检查 `core` 标签是否有地址。因为 `core` 标签是必不可少的,如果它没有地址,唯一可能的原因就是它不存在。如果它有地址,那就是我们没有找到我们要找的标签。如果没有找到,那我们就需要查找所有标签的地址。这是通过读取标签编号来做的。如果标签编号为 0,意味着已经到了标签列表的结束位置。这意味着我们已经查找了目录中所有的标签。所以,如果我们再次运行我们的函数,现在它应该能够给出一个答案。如果标签编号不为 0,我们检查这个标签类型是否已经有一个地址。如果没有,我们在目录中保存这个标签的地址。然后增加这个标签的长度(以字节为单位)到标签地址中,然后去查找下一个标签。 + +尝试去用汇编实现这段代码。你将需要简化它。如果被卡住了,下面是我的答案。不要忘了 `.section .text`! + +```assembly +.section .text +.globl FindTag +FindTag: +tag .req r0 +tagList .req r1 +tagAddr .req r2 + +sub tag,#1 +cmp tag,#8 +movhi tag,#0 +movhi pc,lr + +ldr tagList,=tag_core +tagReturn$: +add tagAddr,tagList, tag,lsl #2 +ldr tagAddr,[tagAddr] + +teq tagAddr,#0 +movne r0,tagAddr +movne pc,lr + +ldr tagAddr,[tagList] +teq tagAddr,#0 +movne r0,#0 +movne pc,lr + +mov tagAddr,#0x100 +push {r4} +tagIndex .req r3 +oldAddr .req r4 +tagLoop$: +ldrh tagIndex,[tagAddr,#4] +subs tagIndex,#1 +poplt {r4} +blt tagReturn$ + +add tagIndex,tagList, tagIndex,lsl #2 +ldr oldAddr,[tagIndex] +teq oldAddr,#0 +.unreq oldAddr +streq tagAddr,[tagIndex] + +ldr tagIndex,[tagAddr] +add tagAddr, tagIndex,lsl #2 +b tagLoop$ + +.unreq tag +.unreq tagList +.unreq tagAddr +.unreq tagIndex +``` + +### 5、Hello World + +现在,我们已经万事俱备了,我们可以去绘制我们的第一个字符串了。在 `main.s` 文件中删除 `bl SetGraphicsAddress` 之后的所有代码,然后将下面的代码放进去: + +```assembly +mov r0,#9 +bl FindTag +ldr r1,[r0] +lsl r1,#2 +sub r1,#8 +add r0,#8 +mov r2,#0 +mov r3,#0 +bl DrawString +loop$: +b loop$ +``` + +这段代码简单地使用了我们的 `FindTag` 方法去查找第 9 个标签(`cmdline`),然后计算它的长度,然后传递命令和长度给 `DrawString` 方法,告诉它在 `0,0` 处绘制字符串。现在可以在树莓派上测试它了。你应该会在屏幕上看到一行文本。如果没有,请查看我们的排错页面。 + +如果一切正常,恭喜你已经能够绘制文本了。但它还有很大的改进空间。如果想去写了一个数字,或内存的一部分,或操作我们的命令行,该怎么做呢?在 [课程 9:屏幕04][2] 中,我们将学习如何操作文本和显示有用的数字和信息。 + +-------------------------------------------------------------------------------- + +via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen03.html + +作者:[Alex Chadwick][a] +选题:[lujun9972][b] +译者:[qhwdw](https://github.com/qhwdw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.cl.cam.ac.uk +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10551-1.html +[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen04.html diff --git a/published/20150616 Computer Laboratory - Raspberry Pi- Lesson 9 Screen04.md b/published/20150616 Computer Laboratory - Raspberry Pi- Lesson 9 Screen04.md new file mode 100644 index 0000000000..523394f8a2 --- /dev/null +++ b/published/20150616 Computer Laboratory - Raspberry Pi- Lesson 9 Screen04.md @@ -0,0 +1,537 @@ +[#]: collector: (lujun9972) +[#]: translator: (qhwdw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10605-1.html) +[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 9 Screen04) +[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen04.html) +[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) + +计算机实验室之树莓派:课程 9 屏幕04 +====== + +屏幕04 课程基于屏幕03 课程来构建,它教你如何操作文本。假设你已经有了[课程 8:屏幕03][1] 的操作系统代码,我们将以它为基础。 + +### 1、操作字符串 + +能够绘制文本是极好的,但不幸的是,现在你只能绘制预先准备好的字符串。如果能够像命令行那样显示任何东西才是完美的,而理想情况下应该是,我们能够显示任何我们期望的东西。一如既往地,如果我们付出努力而写出一个非常好的函数,它能够操作我们所希望的所有字符串,而作为回报,这将使我们以后写代码更容易。曾经如此复杂的函数,在 C 语言编程中只不过是一个 `sprintf` 而已。这个函数基于给定的另一个字符串和作为描述的额外的一个参数而生成一个字符串。我们对这个函数感兴趣的地方是,这个函数是个变长函数。这意味着它可以带可变数量的参数。参数的数量取决于具体的格式字符串,因此它的参数的数量不能预先确定。 + +> 变长函数在汇编代码中看起来似乎不好理解,然而 ,它却是非常有用和很强大的概念。 + +这个完整的函数有许多选项,而我们在这里只列出了几个。在本教程中将要实现的选项我做了高亮处理,当然,你可以尝试去实现更多的选项。 + +函数通过读取格式化字符串来工作,然后使用下表的意思去解释它。一旦一个参数已经使用了,就不会再次考虑它了。函数的返回值是写入的字符数。如果方法失败,将返回一个负数。 + +表 1.1 sprintf 格式化规则 + +| 选项 | 含义 | +| -------------------------- | ------------------------------------------------------------ | +| ==除了 `%` 之外的任何支付== | 复制字符到输出。 | +| ==`%%`== | 写一个 % 字符到输出。 | +| ==`%c`== | 将下一个参数写成字符格式。 | +| ==`%d` 或 `%i`== | 将下一个参数写成十进制的有符号整数。 | +| `%e` | 将下一个参数写成科学记数法,使用 eN,意思是 ×10N。 | +| `%E` | 将下一个参数写成科学记数法,使用 EN,意思是 ×10N。 | +| `%f` | 将下一个参数写成十进制的 IEEE 754 浮点数。 | +| `%g` | 与 `%e` 和 `%f` 的指数表示形式相同。 | +| `%G` | 与 `%E` 和 `%f` 的指数表示形式相同。 | +| ==`%o`== | 将下一个参数写成八进制的无符号整数。 | +| ==`%s`== | 下一个参数如果是一个指针,将它写成空终止符字符串。 | +| ==`%u`== | 将下一个参数写成十进制无符号整数。 | +| ==`%x`== | 将下一个参数写成十六进制无符号整数(使用小写的 a、b、c、d、e 和 f)。 | +| `%X` | 将下一个参数写成十六进制的无符号整数(使用大写的 A、B、C、D、E 和 F)。 | +| `%p` | 将下一个参数写成指针地址。 | +| ==`%n`== | 什么也不输出。而是复制到目前为止被下一个参数在本地处理的字符个数。 | + +除此之外,对序列还有许多额外的处理,比如指定最小长度,符号等等。更多信息可以在 [sprintf - C++ 参考][2] 上找到。 + +下面是调用方法和返回的结果的示例。 + +表 1.2 sprintf 调用示例 + +| 格式化字符串 | 参数 | 结果 | +|---------------|-------|---------------------| +| `"%d"` | 13 | "13" | +| `"+%d degrees"` | 12 | "+12 degrees" | +| `"+%x degrees"` | 24 | "+1c degrees" | +| `"'%c' = 0%o"` | 65, 65 | "'A' = 0101" | +| `"%d * %d%% = %d"` | 200, 40, 80 | "200 * 40% = 80" | +| `"+%d degrees"` | -5 | "+-5 degrees" | +| `"+%u degrees"` | -5 | "+4294967291 degrees" | + +希望你已经看到了这个函数是多么有用。实现它需要大量的编程工作,但给我们的回报却是一个非常有用的函数,可以用于各种用途。 + +### 2、除法 + +虽然这个函数看起来很强大、也很复杂。但是,处理它的许多情况的最容易的方式可能是,编写一个函数去处理一些非常常见的任务。它是个非常有用的函数,可以为任何底的一个有符号或无符号的数字生成一个字符串。那么,我们如何去实现呢?在继续阅读之前,尝试快速地设计一个算法。 + +> 除法是非常慢的,也是非常复杂的基础数学运算。它在 ARM 汇编代码中不能直接实现,因为如果直接实现的话,它得出答案需要花费很长的时间,因此它不是个“简单的”运算。 + +最简单的方法或许就是我在 [课程 1:OK01][3] 中提到的“除法余数法”。它的思路如下: + + 1. 用当前值除以你使用的底。 + 2. 保存余数。 + 3. 如果得到的新值不为 0,转到第 1 步。 + 4. 将余数反序连起来就是答案。 + +例如: + +表 2.1 以 2 为底的例子 + +转换 + +| 值 | 新值 | 余数 | +| ---- | ---- | ---- | +| 137 | 68 | 1 | +| 68 | 34 | 0 | +| 34 | 17 | 0 | +| 17 | 8 | 1 | +| 8 | 4 | 0 | +| 4 | 2 | 0 | +| 2 | 1 | 0 | +| 1 | 0 | 1 | + +因此答案是 100010012 + +这个过程的不幸之外在于使用了除法。所以,我们必须首先要考虑二进制中的除法。 + +我们复习一下长除法 + +> 假如我们想把 4135 除以 17。 +> +> ``` +> 0243 r 4 +> 17)4135 +> 0 0 × 17 = 0000 +> 4135 4135 - 0 = 4135 +> 34 200 × 17 = 3400 +> 735 4135 - 3400 = 735 +> 68 40 × 17 = 680 +> 55 735 - 680 = 55 +> 51 3 × 17 = 51 +> 4 55 - 51 = 4 +> ``` +> 答案:243 余 4 +> +> 首先我们来看被除数的最高位。我们看到它是小于或等于除数的最小倍数,因此它是 0。我们在结果中写一个 0。 +> +> 接下来我们看被除数倒数第二位和所有的高位。我们看到小于或等于那个数的除数的最小倍数是 34。我们在结果中写一个 2,和减去 3400。 +> +> 接下来我们看被除数的第三位和所有高位。我们看到小于或等于那个数的除数的最小倍数是 68。我们在结果中写一个 4,和减去 680。 +> +> 最后,我们看一下所有的余位。我们看到小于余数的除数的最小倍数是 51。我们在结果中写一个 3,减去 51。减法的结果就是我们的余数。 +> + +在汇编代码中做除法,我们将实现二进制的长除法。我们之所以实现它是因为,数字都是以二进制方式保存的,这让我们很容易地访问所有重要位的移位操作,并且因为在二进制中做除法比在其它高进制中做除法都要简单,因为它的数更少。 + +``` + 1011 r 1 +1010)1101111 + 1010 + 11111 + 1010 + 1011 + 1010 + 1 +``` + +这个示例展示了如何做二进制的长除法。简单来说就是,在不超出被除数的情况下,尽可能将除数右移,根据位置输出一个 1,和减去这个数。剩下的就是余数。在这个例子中,我们展示了 11011112 ÷ 10102 = 10112 余数为 12。用十进制表示就是,111 ÷ 10 = 11 余 1。 + +你自己尝试去实现这个长除法。你应该去写一个函数 `DivideU32` ,其中 `r0` 是被除数,而 `r1` 是除数,在 `r0` 中返回结果,在 `r1` 中返回余数。下面,我们将完成一个有效的实现。 + +```c +function DivideU32(r0 is dividend, r1 is divisor) + set shift to 31 + set result to 0 + while shift ≥ 0 + if dividend ≥ (divisor << shift) then + set dividend to dividend - (divisor << shift) + set result to result + 1 + end if + set result to result << 1 + set shift to shift - 1 + loop + return (result, dividend) +end function +``` + +这段代码实现了我们的目标,但却不能用于汇编代码。我们出现的问题是,我们的寄存器只能保存 32 位,而 `divisor << shift` 的结果可能在一个寄存器中装不下(我们称之为溢出)。这确实是个问题。你的解决方案是否有溢出的问题呢? + +幸运的是,有一个称为 `clz`(计数前导零count leading zeros)的指令,它能计算一个二进制表示的数字的前导零的个数。这样我们就可以在溢出发生之前,可以将寄存器中的值进行相应位数的左移。你可以找出的另一个优化就是,每个循环我们计算 `divisor << shift` 了两遍。我们可以通过将除数移到开始位置来改进它,然后在每个循环结束的时候将它移下去,这样可以避免将它移到别处。 + +我们来看一下进一步优化之后的汇编代码。 + +```assembly +.globl DivideU32 +DivideU32: +result .req r0 +remainder .req r1 +shift .req r2 +current .req r3 + +clz shift,r1 +lsl current,r1,shift +mov remainder,r0 +mov result,#0 + +divideU32Loop$: + cmp shift,#0 + blt divideU32Return$ + cmp remainder,current + + addge result,result,#1 + subge remainder,current + sub shift,#1 + lsr current,#1 + lsl result,#1 + b divideU32Loop$ +divideU32Return$: +.unreq current +mov pc,lr + +.unreq result +.unreq remainder +.unreq shift +``` + +你可能毫无疑问的认为这是个非常高效的作法。它是很好,但是除法是个代价非常高的操作,并且我们的其中一个愿望就是不要经常做除法,因为如果能以任何方式提升速度就是件非常好的事情。当我们查看有循环的优化代码时,我们总是重点考虑一个问题,这个循环会运行多少次。在本案例中,在输入为 1 的情况下,这个循环最多运行 31 次。在不考虑特殊情况的时候,这很容易改进。例如,当 1 除以 1 时,不需要移位,我们将把除数移到它上面的每个位置。这可以通过简单地在被除数上使用新的 `clz` 命令并从中减去它来改进。在 `1 ÷ 1` 的案例中,这意味着移位将设置为 0,明确地表示它不需要移位。如果它设置移位为负数,表示除数大于被除数,因此我们就可以知道结果是 0,而余数是被除数。我们可以做的另一个快速检查就是,如果当前值为 0,那么它是一个整除的除法,我们就可以停止循环了。 + +> `clz dest,src` 将第一个寄存器 `dest` 中二进制表示的值的前导零的数量,保存到第二个寄存器 `src` 中。 + + +```assembly +.globl DivideU32 +DivideU32: +result .req r0 +remainder .req r1 +shift .req r2 +current .req r3 + +clz shift,r1 +clz r3,r0 +subs shift,r3 +lsl current,r1,shift +mov remainder,r0 +mov result,#0 +blt divideU32Return$ + +divideU32Loop$: + cmp remainder,current + blt divideU32LoopContinue$ + + add result,result,#1 + subs remainder,current + lsleq result,shift + beq divideU32Return$ +divideU32LoopContinue$: + subs shift,#1 + lsrge current,#1 + lslge result,#1 + bge divideU32Loop$ + +divideU32Return$: +.unreq current +mov pc,lr + +.unreq result +.unreq remainder +.unreq shift +``` + +复制上面的代码到一个名为 `maths.s` 的文件中。 + +### 3、数字字符串 + +现在,我们已经可以做除法了,我们来看一下另外的一个将数字转换为字符串的实现。下列的伪代码将寄存器中的一个数字转换成以 36 为底的字符串。根据惯例,a % b 表示 a 被 b 相除之后的余数。 + +```c +function SignedString(r0 is value, r1 is dest, r2 is base) + if value ≥ 0 + then return UnsignedString(value, dest, base) + otherwise + if dest > 0 then + setByte(dest, '-') + set dest to dest + 1 + end if + return UnsignedString(-value, dest, base) + 1 + end if +end function + +function UnsignedString(r0 is value, r1 is dest, r2 is base) + set length to 0 + do + + set (value, rem) to DivideU32(value, base) + if rem > 10 + then set rem to rem + '0' + otherwise set rem to rem - 10 + 'a' + if dest > 0 + then setByte(dest + length, rem) + set length to length + 1 + + while value > 0 + if dest > 0 + then ReverseString(dest, length) + return length +end function + +function ReverseString(r0 is string, r1 is length) + set end to string + length - 1 + while end > start + set temp1 to readByte(start) + set temp2 to readByte(end) + setByte(start, temp2) + setByte(end, temp1) + set start to start + 1 + set end to end - 1 + end while +end function +``` + +上述代码实现在一个名为 `text.s` 的汇编文件中。记住,如果你遇到了困难,可以在下载页面找到完整的解决方案。 + +### 4、格式化字符串 + +我们继续回到我们的字符串格式化方法。因为我们正在编写我们自己的操作系统,我们根据我们自己的意愿来添加或修改格式化规则。我们可以发现,添加一个 `a % b` 操作去输出一个二进制的数字比较有用,而如果你不使用空终止符字符串,那么你应该去修改 `%s` 的行为,让它从另一个参数中得到字符串的长度,或者如果你愿意,可以从长度前缀中获取。我在下面的示例中使用了一个空终止符。 + +实现这个函数的一个主要的障碍是它的参数个数是可变的。根据 ABI 规定,额外的参数在调用方法之前以相反的顺序先推送到栈上。比如,我们使用 8 个参数 1、2、3、4、5、6、7 和 8 来调用我们的方法,我们将按下面的顺序来处理: + +1. 设置 r0 = 5、r1 = 6、r2 = 7、r3 = 8 +2. 推入 {r0,r1,r2,r3} +3. 设置 r0 = 1、r1 = 2、r2 = 3、r3 = 4 +4. 调用函数 +5. 将 sp 和 #4*4 加起来 + +现在,我们必须确定我们的函数确切需要的参数。在我的案例中,我将寄存器 `r0` 用来保存格式化字符串地址,格式化字符串长度则放在寄存器 `r1` 中,目标字符串地址放在寄存器 `r2` 中,紧接着是要求的参数列表,从寄存器 `r3` 开始和像上面描述的那样在栈上继续。如果你想去使用一个空终止符格式化字符串,在寄存器 r1 中的参数将被移除。如果你想有一个最大缓冲区长度,你可以将它保存在寄存器 `r3` 中。由于有额外的修改,我认为这样修改函数是很有用的,如果目标字符串地址为 0,意味着没有字符串被输出,但如果仍然返回一个精确的长度,意味着能够精确的判断格式化字符串的长度。 + +如果你希望尝试实现你自己的函数,现在就可以去做了。如果不去实现你自己的,下面我将首先构建方法的伪代码,然后给出实现的汇编代码。 + +```c +function StringFormat(r0 is format, r1 is formatLength, r2 is dest, ...) + set index to 0 + set length to 0 + while index < formatLength + if readByte(format + index) = '%' then + set index to index + 1 + if readByte(format + index) = '%' then + if dest > 0 + then setByte(dest + length, '%') + set length to length + 1 + otherwise if readByte(format + index) = 'c' then + if dest > 0 + then setByte(dest + length, nextArg) + set length to length + 1 + otherwise if readByte(format + index) = 'd' or 'i' then + set length to length + SignedString(nextArg, dest, 10) + otherwise if readByte(format + index) = 'o' then + set length to length + UnsignedString(nextArg, dest, 8) + otherwise if readByte(format + index) = 'u' then + set length to length + UnsignedString(nextArg, dest, 10) + otherwise if readByte(format + index) = 'b' then + set length to length + UnsignedString(nextArg, dest, 2) + otherwise if readByte(format + index) = 'x' then + set length to length + UnsignedString(nextArg, dest, 16) + otherwise if readByte(format + index) = 's' then + set str to nextArg + while getByte(str) != '\0' + if dest > 0 + then setByte(dest + length, getByte(str)) + set length to length + 1 + set str to str + 1 + loop + otherwise if readByte(format + index) = 'n' then + setWord(nextArg, length) + end if + otherwise + if dest > 0 + then setByte(dest + length, readByte(format + index)) + set length to length + 1 + end if + set index to index + 1 + loop + return length +end function +``` + +虽然这个函数很大,但它还是很简单的。大多数的代码都是在检查所有各种条件,每个代码都是很简单的。此外,所有的无符号整数的大小写都是相同的(除了底以外)。因此在汇编中可以将它们汇总。下面是它的汇编代码。 + +```assembly +.globl FormatString +FormatString: +format .req r4 +formatLength .req r5 +dest .req r6 +nextArg .req r7 +argList .req r8 +length .req r9 + +push {r4,r5,r6,r7,r8,r9,lr} +mov format,r0 +mov formatLength,r1 +mov dest,r2 +mov nextArg,r3 +add argList,sp,#7*4 +mov length,#0 + +formatLoop$: + subs formatLength,#1 + movlt r0,length + poplt {r4,r5,r6,r7,r8,r9,pc} + + ldrb r0,[format] + add format,#1 + teq r0,#'%' + beq formatArg$ + +formatChar$: + teq dest,#0 + strneb r0,[dest] + addne dest,#1 + add length,#1 + b formatLoop$ + +formatArg$: + subs formatLength,#1 + movlt r0,length + poplt {r4,r5,r6,r7,r8,r9,pc} + + ldrb r0,[format] + add format,#1 + teq r0,#'%' + beq formatChar$ + + teq r0,#'c' + moveq r0,nextArg + ldreq nextArg,[argList] + addeq argList,#4 + beq formatChar$ + + teq r0,#'s' + beq formatString$ + + teq r0,#'d' + beq formatSigned$ + + teq r0,#'u' + teqne r0,#'x' + teqne r0,#'b' + teqne r0,#'o' + beq formatUnsigned$ + + b formatLoop$ + +formatString$: + ldrb r0,[nextArg] + teq r0,#0x0 + ldreq nextArg,[argList] + addeq argList,#4 + beq formatLoop$ + add length,#1 + teq dest,#0 + strneb r0,[dest] + addne dest,#1 + add nextArg,#1 + b formatString$ + +formatSigned$: + mov r0,nextArg + ldr nextArg,[argList] + add argList,#4 + mov r1,dest + mov r2,#10 + bl SignedString + teq dest,#0 + addne dest,r0 + add length,r0 + b formatLoop$ + +formatUnsigned$: + teq r0,#'u' + moveq r2,#10 + teq r0,#'x' + moveq r2,#16 + teq r0,#'b' + moveq r2,#2 + teq r0,#'o' + moveq r2,#8 + + mov r0,nextArg + ldr nextArg,[argList] + add argList,#4 + mov r1,dest + bl UnsignedString + teq dest,#0 + addne dest,r0 + add length,r0 + b formatLoop$ +``` + +### 5、一个转换操作系统 + +你可以使用这个方法随意转换你希望的任何东西。比如,下面的代码将生成一个换算表,可以做从十进制到二进制到十六进制到八进制以及到 ASCII 的换算操作。 + +删除 `main.s` 文件中 `bl SetGraphicsAddress` 之后的所有代码,然后粘贴以下的代码进去。 + +```assembly +mov r4,#0 +loop$: +ldr r0,=format +mov r1,#formatEnd-format +ldr r2,=formatEnd +lsr r3,r4,#4 +push {r3} +push {r3} +push {r3} +push {r3} +bl FormatString +add sp,#16 + +mov r1,r0 +ldr r0,=formatEnd +mov r2,#0 +mov r3,r4 + +cmp r3,#768-16 +subhi r3,#768 +addhi r2,#256 +cmp r3,#768-16 +subhi r3,#768 +addhi r2,#256 +cmp r3,#768-16 +subhi r3,#768 +addhi r2,#256 + +bl DrawString + +add r4,#16 +b loop$ + +.section .data +format: +.ascii "%d=0b%b=0x%x=0%o='%c'" +formatEnd: +``` + +你能在测试之前推算出将发生什么吗?特别是对于 `r3 ≥ 128` 会发生什么?尝试在树莓派上运行它,看看你是否猜对了。如果不能正常运行,请查看我们的排错页面。 + +如果一切顺利,恭喜你!你已经完成了屏幕04 教程,屏幕系列的课程结束了!我们学习了像素和帧缓冲的知识,以及如何将它们应用到树莓派上。我们学习了如何绘制简单的线条,也学习如何绘制字符,以及将数字格式化为文本的宝贵技能。我们现在已经拥有了在一个操作系统上进行图形输出的全部知识。你可以写出更多的绘制方法吗?三维绘图是什么?你能实现一个 24 位帧缓冲吗?能够从命令行上读取帧缓冲的大小吗? + +接下来的课程是[输入][4]系列课程,它将教我们如何使用键盘和鼠标去实现一个传统的计算机控制台。 + +-------------------------------------------------------------------------------- + +via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen04.html + +作者:[Alex Chadwick][a] +选题:[lujun9972][b] +译者:[qhwdw](https://github.com/qhwdw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.cl.cam.ac.uk +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10585-1.html +[2]: http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/ +[3]: https://linux.cn/article-10458-1.html +[4]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input01.html diff --git a/published/20170223 Use Emacs to create OAuth 2.0 UML sequence diagrams.md b/published/20170223 Use Emacs to create OAuth 2.0 UML sequence diagrams.md new file mode 100644 index 0000000000..23b1075f74 --- /dev/null +++ b/published/20170223 Use Emacs to create OAuth 2.0 UML sequence diagrams.md @@ -0,0 +1,149 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10582-1.html) +[#]: subject: (Use Emacs to create OAuth 2.0 UML sequence diagrams) +[#]: via: (https://www.onwebsecurity.com/configuration/use-emacs-to-create-oauth-2-0-uml-sequence-diagrams.html) +[#]: author: (Peter Mosmans https://www.onwebsecurity.com) + +使用 Emacs 创建 OAuth 2.0 的 UML 序列图 +====== + +![OAuth 2.0 abstract protocol flow][6] + +看起来 [OAuth 2.0 框架][7] 已经越来越广泛地应用于 web (和 移动) 应用。太棒了! + +虽然协议本身并不复杂,但有很多的使用场景、流程和实现可供选择。正如生活中的大多数事物一样,魔鬼在于细节之中。 + +在审查 OAuth 2.0 实现或编写渗透测试报告时我习惯画出 UML 图。这方便让人理解发生了什么事情,并发现潜在的问题。毕竟,一图抵千言。 + +使用基于 GPL 开源协议 [Emacs][8] 编辑器来实现,再加上基于 GPL 开源协议的工具 [PlantUML][9] (也可以选择基于 Eclipse Public 协议的 [Graphviz][10]) 很容易做到这一点。 + +Emacs 是世界上最万能的编辑器。在这种场景中,我们用它来编辑文本,并自动将文本转换成图片。PlantUML 是一个允许你用人类可读的文本来写 UML 并完成该转换的工具。Graphviz 是一个可视化的软件,这里我们可以用它来显示图片。 + +下载 [预先编译好了的 PlantUML jar 文件 ][11],[Emacs][12] 还可以选择下载并安装 [Graphviz][13]。 + +安装并启动 Emacs,然后将下面 Lisp 代码(实际上是配置)写入你的启动文件中(`~/.emacs.d/init.d`),这段代码将会: + + * 配置 org 模式(一种用来组织并编辑文本文件的模式)来使用 PlantUML + * 将 `plantuml` 添加到可识别的 “org-babel” 语言中(这让你可以在文本文件中执行源代码) + * 将 PlantUML 代码标注为安全的,从而允许执行 + * 自动显示生成的结果图片 + +```elisp +;; tell org-mode where to find the plantuml JAR file (specify the JAR file) +(setq org-plantuml-jar-path (expand-file-name "~/plantuml.jar")) + +;; use plantuml as org-babel language +(org-babel-do-load-languages 'org-babel-load-languages '((plantuml . t))) + +;; helper function +(defun my-org-confirm-babel-evaluate (lang body) +"Do not ask for confirmation to evaluate code for specified languages." +(member lang '("plantuml"))) + +;; trust certain code as being safe +(setq org-confirm-babel-evaluate 'my-org-confirm-babel-evaluate) + +;; automatically show the resulting image +(add-hook 'org-babel-after-execute-hook 'org-display-inline-images) +``` + +如果你还没有启动文件,那么将该代码加入到 `~/.emacs.d/init.el` 文件中然后重启 Emacs。 + +提示:`Control-c Control-f` 可以让你创建/打开(新)文件。`Control-x Control-s` 保存文件,而 `Control-x Control-c` 退出 Emacs。 + +这就结了! + +要测试该配置,可以创建/打开(`Control-c Control-f`)后缀为 `.org` 的文件,例如 `test.org`。这会让 Emacs 切换到 org 模式并识别 “org-babel” 语法。 + +输入下面代码,然后在代码中输入 `Control-c Control-c` 来测试是否安装正常: + +``` +#+BEGIN_SRC plantuml :file test.png +@startuml +version +@enduml +#+END_SRC +``` + +一切顺利的话,你会在 Emacs 中看到文本下面显示了一张图片。 + +> **注意:** + +> 要快速插入类似 `#+BEGIN_SRC` 和 `#+END_SRC` 这样的代码片段,你可以使用内置的 Easy Templates 系统:输入 ` user : request authorization +note left +**grant types**: +# authorization code +# implicit +# password +# client_credentials +end note +user --> client : authorization grant +end + +group token is generated +client -> authorization : request token\npresent authorization grant +authorization --> client :var: access token +note left +**response types**: +# code +# token +end note +end group + +group resource can be accessed +client -> resource : request resource\npresent token +resource --> client : resource +end group +@enduml +#+END_SRC +``` + +你难道会不喜欢 Emacs 和开源工具的多功能性吗? + +-------------------------------------------------------------------------------- + +via: https://www.onwebsecurity.com/configuration/use-emacs-to-create-oauth-2-0-uml-sequence-diagrams.html + +作者:[Peter Mosmans][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.onwebsecurity.com +[b]: https://github.com/lujun9972 +[1]: https://www.onwebsecurity.com/category/configuration.html +[2]: https://www.onwebsecurity.com/tag/emacs.html +[3]: https://www.onwebsecurity.com/tag/oauth2.html +[4]: https://www.onwebsecurity.com/tag/pentesting.html +[5]: https://www.onwebsecurity.com/tag/security.html +[6]: https://www.onwebsecurity.com/images/oauth2-abstract-protocol-flow.png +[7]: https://tools.ietf.org/html/rfc6749 +[8]: https://www.gnu.org/software/emacs/ +[9]: https://plantuml.com +[10]: http://www.graphviz.org/ +[11]: http://plantuml.com/download +[12]: https://www.gnu.org/software/emacs/download.html +[13]: http://www.graphviz.org/Download.php diff --git a/published/20170721 Firefox and org-protocol URL Capture.md b/published/20170721 Firefox and org-protocol URL Capture.md new file mode 100644 index 0000000000..c9c5bba603 --- /dev/null +++ b/published/20170721 Firefox and org-protocol URL Capture.md @@ -0,0 +1,121 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10586-1.html) +[#]: subject: (Firefox and org-protocol URL Capture) +[#]: via: (http://www.mediaonfire.com/blog/2017_07_21_org_protocol_firefox.html) +[#]: author: (Andreas Viklund http://andreasviklund.com/) + +在 Firefox 上使用 Org 协议捕获 URL +====== + +### 介绍 + +作为一名 Emacs 人,我尽可能让所有的工作流都在 [Org 模式][1]Org-mode 上进行 —— 我比较喜欢文本。 + +我倾向于将书签记录在 [Org 模式][1] 代办列表中,而 [Org 协议][2]Org-protocol 则允许外部进程利用 [Org 模式][1] 的某些功能。然而,要做到这一点配置起来很麻烦。([搜索引擎上][3])有很多教程,Firefox 也有这类 [扩展][4],然而我对它们都不太满意。 + +因此我决定将我现在的配置记录在这篇博客中,方便其他有需要的人使用。 + +### 配置 Emacs Org 模式 + +启用 Org 协议: + +``` +(require 'org-protocol) +``` + +添加一个捕获模板capture template —— 我的配置是这样的: + +``` +(setq org-capture-templates + (quote (... + ("w" "org-protocol" entry (file "~/org/refile.org") + "* TODO Review %a\n%U\n%:initial\n" :immediate-finish) + ...))) +``` + +你可以从 [Org 模式][1] 手册中 [捕获模板][5] 章节中获取帮助。 + +设置默认使用的模板: + +``` +(setq org-protocol-default-template-key "w") +``` + +执行这些新增配置让它们在当前 Emacs 会话中生效。 + +### 快速测试 + +在下一步开始前,最好测试一下配置: + +``` +emacsclient -n "org-protocol:///capture?url=http%3a%2f%2fduckduckgo%2ecom&title=DuckDuckGo" +``` + +基于的配置的模板,可能会弹出一个捕获窗口。请确保正常工作,否则后面的操作没有任何意义。如果工作不正常,检查刚才的配置并且确保你执行了这些代码块。 + +如果你的 [Org 模式][1] 版本比较老(老于 7 版本),测试的格式会有点不同:这种 URL 编码后的格式需要改成用斜杠来分割 url 和标题。在网上搜一下很容易找出这两者的不同。 + +### Firefox 协议 + +现在开始设置 Firefox。浏览 `about:config`。右击配置项列表,选择 “New -> Boolean”,然后输入 `network.protocol-handler.expose.org-protocol` 作为名字并且将值设置为 `true`。 + +有些教程说这一步是可以省略的 —— 配不配因人而异。 + +### 添加 Desktop 文件 + +大多数的教程都有这一步: + +增加一个文件 `~/.local/share/applications/org-protocol.desktop`: + +``` +[Desktop Entry] +Name=org-protocol +Exec=/path/to/emacsclient -n %u +Type=Application +Terminal=false +Categories=System; +MimeType=x-scheme-handler/org-protocol; +``` + +然后运行更新器。对于 i3 窗口管理器我使用下面命令(跟 gnome 一样): + +``` +update-desktop-database ~/.local/share/applications/ +``` + +KDE 的方法不太一样……你可以查询其他相关教程。 + +### 在 FireFox 中设置捕获按钮 + +创建一个书签(我是在工具栏上创建这个书签的),地址栏输入下面内容: + +``` +javascript:location.href="org-protocol:///capture?url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title||"[untitled page]") +``` + +保存该书签后,再次编辑该书签,你应该会看到其中的所有空格都被替换成了 `%20` —— 也就是空格的 URL 编码形式。 + +现在当你点击该书签,你就会在某个 Emacs 框架中,可能是一个任意的框架中,打开一个窗口,显示你预定的模板。 + + +-------------------------------------------------------------------------------- + +via: http://www.mediaonfire.com/blog/2017_07_21_org_protocol_firefox.html + +作者:[Andreas Viklund][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://andreasviklund.com/ +[b]: https://github.com/lujun9972 +[1]: http://orgmode.org/ +[2]: http://orgmode.org/worg/org-contrib/org-protocol.html +[3]: https://duckduckgo.com/?q=org-protocol+firefox&t=ffab&ia=qa +[4]: https://addons.mozilla.org/en-US/firefox/search/?q=org-protocol&cat=1,0&appver=53.0&platform=linux +[5]: http://orgmode.org/manual/Capture-templates.html diff --git a/published/20180122 Ick- a continuous integration system.md b/published/20180122 Ick- a continuous integration system.md new file mode 100644 index 0000000000..3c240f9545 --- /dev/null +++ b/published/20180122 Ick- a continuous integration system.md @@ -0,0 +1,67 @@ +ick:一个持续集成系统 +====== + +> ick 是一个持续集成(CI)系统。访问 获取更多信息。 + +更加详细的内容如下: + +### 首个公开版本发行 + +这个世界可能并不需要又一个持续集成系统(CI),但是我需要。我对我尝试过或者看过的持续集成系统感到不满意。更重要的是,有几样我感兴趣的东西比我所听说过的持续集成系统要强大得多。因此我开始编写我自己的 CI 系统。 + +我的新个人业余项目叫做 ick。它是一个 CI 系统,这意味着它可以运行自动化的步骤来构建、测试软件。它的主页是 ,[下载][1]页面有指向源代码、.deb 包和用来安装的 Ansible 脚本的链接。 + +我现已发布了首个公开版本,绰号 ALPHA-1,版本号 0.23。(LCTT 译注:截止至本译文发布,已经更新到 ALPHA-6)它现在是 alpha 品质,这意味着它并没拥有期望的全部特性,如果任何一个它已有的特性工作的话,那真是运气好。 + +### 诚邀贡献 + +ick 目前是我的个人项目。我希望能让它不仅限于此,同时我也诚邀更多贡献。访问[治理][2]页面查看章程,[入门][3]页面查看如何开始贡献的的小建议,[联系][4]页面查看如何联络。 + +### 架构 + +ick 拥有一个由几个通过 HTTPS 协议通信使用 RESTful API 和 JSON 处理结构化数据的部分组成的架构。访问[架构][5]页面了解细节。 + +### 宣告 + +持续集成(CI)是用于软件开发的强大工具。它不应枯燥、易溃或恼人。它构建起来应简单快速,除非正在测试、构建的代码中有问题,不然它应在后台安静地工作。 + +一个持续集成系统应该简单、易用、清楚、干净、可扩展、快速、综合、透明、可靠,并推动你的生产力。构建它不应花大力气、不应需要专门为 CI 而造的硬件、不应需要频繁留意以使其保持工作、开发者永远不必思考为什么某样东西不工作。 + +一个持续集成系统应该足够灵活以适应你的构建、测试需求。只要 CPU 架构和操作系统版本没问题,它应该支持各种操作者。 + +同时像所有软件一样,CI 应该彻彻底底的免费,你的 CI 应由你做主。 + +(目前的 ick 仅稍具雏形,但是它会尝试着有朝一日变得完美 —— 在最理想的情况下。) + +### 未来的梦想 + +长远来看,我希望 ick 拥有像下面所描述的特性。落实全部特性可能需要一些时间。 + +* 各种事件都可以触发构建。时间是一个明显的事件,因为项目的源代码仓库改变了。更强大的是任何依赖的改变,不管依赖是来自于 ick 构建的另一个项目,或者是包(比如说来自 Debian):ick 应当跟踪所有安装进一个项目构建环境中的包,如果任何一个包的版本改变,都应再次触发项目构建和测试。 +* ick 应该支持构建于(或针对)任何合理的目标平台,包括任何 Linux 发行版,任何自由的操作系统,以及任何一息尚存的不自由的操作系统。 +* ick 应该自己管理构建环境,并且能够执行与构建主机或网络隔离的构建。这部分工作:可以要求 ick 构建容器并在容器中运行构建。容器使用 systemd-nspawn 实现。 然而,这可以改进。(如果您认为 Docker 是唯一的出路,请为此提供支持。) +* ick 应当不需要安装任何专门的代理,就能支持各种它能够通过 ssh 或者串口或者其它这种中性的交流管道控制的操作者worker。ick 不应默认它可以有比如说一个完整的 Java Runtime,如此一来,操作者就可以是一个微控制器了。 +* ick 应当能轻松掌控一大批项目。我觉得不管一个新的 Debian 源包何时上传,ick 都应该要能够跟得上在 Debian 中构建所有东西的进度。(明显这可行与否取决于是否有足够的资源确实用在构建上,但是 ick 自己不应有瓶颈。) +* 如果有需要的话 ick 应当有选择性地补给操作者。如果所有特定种类的操作者处于忙碌中,且 ick 被设置成允许使用更多资源的话,它就应该这么做。这看起来用虚拟机、容器、云提供商等做可能会简单一些。 +* ick 应当灵活提醒感兴趣的团体,特别是关于其失败的方面。它应允许感兴趣的团体通过 IRC、Matrix、Mastodon、Twitter、email、SMS 甚至电话和语音合成来接受通知。例如“您好,感兴趣的团体。现在是四点钟您想被通知 hello 包什么时候为 RISC-V 构建好。” + +### 请提供反馈 + +如果你尝试过 ick 或者甚至你仅仅是读到这,请在上面分享你的想法。在[联系][4]页面查看如何发送反馈。相比私下反馈我更偏爱公开反馈。但如果你偏爱私下反馈,那也行。 + +-------------------------------------------------------------------------------- + +via: https://blog.liw.fi/posts/2018/01/22/ick_a_continuous_integration_system/ + +作者:[Lars Wirzenius][a] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://blog.liw.fi/ +[1]:http://ick.liw.fi/download/ +[2]:http://ick.liw.fi/governance/ +[3]:http://ick.liw.fi/getting-started/ +[4]:http://ick.liw.fi/contact/ +[5]:http://ick.liw.fi/architecture/ diff --git a/published/20180202 Tips for success when getting started with Ansible.md b/published/20180202 Tips for success when getting started with Ansible.md new file mode 100644 index 0000000000..ab189fef6f --- /dev/null +++ b/published/20180202 Tips for success when getting started with Ansible.md @@ -0,0 +1,70 @@ +Ansible 入门秘诀 +====== + +> 用 Ansible 自动化你的数据中心的关键点。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-big-data.png?itok=L34b2exg) + +Ansible 是一个开源自动化工具,可以从中央控制节点统一配置服务器、安装软件或执行各种 IT 任务。它采用一对多、无客户端agentless的机制,从控制节点上通过 SSH 发送指令给远端的客户机来完成任务(当然除了 SSH 外也可以用别的协议)。 + +Ansible 的主要使用群体是系统管理员,他们经常会周期性地执行一些安装、配置应用的工作。尽管如此,一些非特权用户也可以使用 Ansible,例如数据库管理员就可以通过 Ansible 用 `mysql` 这个用户来创建数据库、添加数据库用户、定义访问权限等。 + +让我们来看一个简单的使用场景,一位系统管理员每天要配置 100 台服务器,并且必须在每台机器上执行一系列 Bash 命令,然后交付给用户。 + +![](https://opensource.com/sites/default/files/u128651/mapping-bash-commands-to-ansible.png) + +这是个简单的例子,但应该能够证明:在 yaml 文件里写好命令然后在远程服务器上运行,是一件非常轻松的事。而且如果运行环境不同,就可以加入判断条件,指明某些命令只能在特定的服务器上运行(如:只在那些不是 Ubuntu 或 Debian 的系统上运行 `yum` 命令)。 + +Ansible 的一个重要特性是用剧本playbook来描述一个计算机系统的最终状态,所以一个剧本可以在服务器上反复执行而不影响其最终状态(LCTT 译注:即是幂等的)。如果某个任务已经被实施过了(如,“用户 `sysman` 已经存在”),那么 Ansible 就会忽略它继续执行后续的任务。 + +### 定义 + + * 任务task:是工作的最小单位,它可以是个动作,比如“安装一个数据库服务”、“安装一个 web 服务器”、“创建一条防火墙规则”或者“把这个配置文件拷贝到那个服务器上去”。 + * 动作play: 由任务组成,例如,一个动作的内容是要“设置一个数据库,给 web 服务用”,这就包含了如下任务:1)安装数据库包;2)设置数据库管理员密码;3)创建数据库实例;4)为该实例分配权限。 + * 剧本playbook:(LCTT 译注:playbook 原指美式橄榄球队的[战术手册][5],也常指“剧本”,此处惯例采用“剧本”译名)由动作组成,一个剧本可能像这样:“设置我的网站,包含后端数据库”,其中的动作包括:1)设置数据库服务器;2)设置 web 服务器。 + * 角色role:用来保存和组织剧本,以便分享和再次使用它们。还拿上个例子来说,如果你需要一个全新的 web 服务器,就可以用别人已经写好并分享出来的角色来设置。因为角色是高度可配置的(如果编写正确的话),可以根据部署需求轻松地复用它们。 + * [Ansible 星系][1]Ansible Galaxy:是一个在线仓库,里面保存的是由社区成员上传的角色,方便彼此分享。它与 GitHub 紧密集成,因此这些角色可以先在 Git 仓库里组织好,然后通过 Ansible 星系分享出来。 + +这些定义以及它们之间的关系可以用下图来描述: + +![](https://opensource.com/sites/default/files/u128651/ansible-definitions.png) + +请注意上面的例子只是组织任务的方式之一,我们当然也可以把安装数据库和安装 web 服务器的剧本拆开,放到不同的角色里。Ansible 星系上最常见的角色是独立安装、配置每个应用服务,你可以参考这些安装 [mysql][2] 和 [httpd][3] 的例子。 + +### 编写剧本的小技巧 + +学习 Ansible 最好的资源是其[官方文档][4]。另外,像学习其他东西一样,搜索引擎是你的好朋友。我推荐你从一些简单的任务开始,比如安装应用或创建用户。下面是一些有用的指南: + + * 在测试的时候少选几台服务器,这样你的动作可以执行的更快一些。如果它们在一台机器上执行成功,在其他机器上也没问题。 + * 总是在真正运行前做一次测试dry run,以确保所有的命令都能正确执行(要运行测试,加上 `--check-mode` 参数 )。 + * 尽可能多做测试,别担心搞砸。任务里描述的是所需的状态,如果系统已经达到预期状态,任务会被简单地忽略掉。 + * 确保在 `/etc/ansible/hosts` 里定义的主机名都可以被正确解析。 + * 因为是用 SSH 与远程主机通信,主控节点必须要能接受密钥,所以你面临如下选择:1)要么在正式使用之前就做好与远程主机的密钥交换工作;2)要么在开始管理某台新的远程主机时做好准备输入 “Yes”,因为你要接受对方的 SSH 密钥交换请求(LCTT 译注:还有另一个不那么安全的选择,修改主控节点的 ssh 配置文件,将 `StrictHostKeyChecking` 设置成 “no”)。 + * 尽管你可以在同一个剧本内把不同 Linux 发行版的任务整合到一起,但为每个发行版单独编写剧本会更明晰一些。 + +### 总结一下 + +Ansible 是你在数据中心里实施运维自动化的好选择,因为它: + + * 无需客户端,所以比其他自动化工具更易安装。 + * 将指令保存在 YAML 文件中(虽然也支持 JSON),比写 shell 脚本更简单。 + * 开源,因此你也可以做出自己的贡献,让它更加强大! + +你是怎样使用 Ansible 让数据中心更加自动化的呢?请在评论中分享您的经验。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/2/tips-success-when-getting-started-ansible + +作者:[Jose Delarosa][a] +译者:[jdh8383](https://github.com/jdh8383) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/jdelaros1 +[1]:https://galaxy.ansible.com/ +[2]:https://galaxy.ansible.com/bennojoy/mysql/ +[3]:https://galaxy.ansible.com/xcezx/httpd/ +[4]:http://docs.ansible.com/ +[5]:https://usafootball.com/football-playbook/ diff --git a/published/20180307 3 open source tools for scientific publishing.md b/published/20180307 3 open source tools for scientific publishing.md new file mode 100644 index 0000000000..40deb0ee6c --- /dev/null +++ b/published/20180307 3 open source tools for scientific publishing.md @@ -0,0 +1,80 @@ +3 款用于学术出版的开源工具 +====== +> 学术出版业每年的价值超过 260 亿美元。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LIFE_science.png?itok=WDKARWGV) + +有一个行业在采用数字化或开源工具方面已落后其它行业,那就是竞争与利润并存的学术出版业。根据 Stephen Buranyi 去年在 [卫报][1] 上发表的一份图表,这个估值超过 190 亿英镑(260 亿美元)的行业,即使是最重要的科学研究方面,至今其系统在选题、出版甚至分享方面仍受限于印刷媒介的诸多限制。全新的数字时代科技展现了一个巨大机遇,可以加速探索、推动科学协作而非竞争,以及将投入从基础建设导向有益于社会的研究。 + +非盈利性的 [eLife 倡议][2] 是由研究资金赞助方建立,旨在通过使用数字或者开源技术来走出上述僵局。除了为生命科学和生物医疗方面的重大成就出版开放式获取的期刊,eLife 已将自己变成了一个在研究交流方面的实验和展示创新的平台 —— 而大部分的实验都是基于开源精神的。 + +致力于开放出版基础设施项目给予我们加速接触、采用科学技术、提升用户体验的机会。我们认为这种机会对于推动学术出版行业是重要的。大而化之地说,开源产品的用户体验经常是有待开发的,而有时候这种情况会阻止其他人去使用它。作为我们在 OSS(开源软件)开发中投入的一部分,为了鼓励更多用户使用这些产品,我们十分注重用户体验。 + +我们所有的代码都是开源的,并且我们也积极鼓励社区参与进我们的项目中。这对我们来说意味着更快的迭代、更多的实验、更大的透明度,同时也拓宽了我们工作的外延。 + +我们现在参与的项目,例如 Libero (之前称作 [eLife Continuum][3])和 [可重现文档栈][4]Reproducible Document Stack 的开发,以及我们最近和 [Hypothesis][5] 的合作,展示了 OSS 是如何在评估、出版以及新发现的沟通方面带来正面影响的。 + +### Libero + +Libero 是面向出版商的服务及应用套餐,它包括一个后期制作出版系统、整套前端用户界面样式套件、Libero 的镜头阅读器、一个 Open API 以及一个搜索及推荐引擎。 + +去年我们采取了用户驱动的方式重新设计了 Libero 的前端,可以使用户较少地分心于网站的“陈设”,而是更多地集中关注于研究文章上。我们和 eLife 社区成员测试并迭代了该站点所有的核心功能,以确保给所有人最好的阅读体验。该网站的新 API 也为机器阅读能力提供了更简单的访问途径,其中包括文本挖掘、机器学习以及在线应用开发。 + +我们网站上的内容以及引领新设计的样式都是开源的,以鼓励 eLife 和其它想要使用它的出版商后续的产品开发。 + +### 可重现文档栈 + +在与 [Substance][6] 和 [Stencila][7] 的合作下,eLife 也参与了一个项目来创建可重现文档栈(RDS)—— 一个开放式的创作、编纂以及在线出版可重现的计算型手稿的工具栈。 + +今天越来越多的研究人员能够通过 [R Markdown][8] 和 [Python][9] 等语言记录他们的计算实验。这些可以作为实验记录的重要部分,但是尽管它们可以独立于最终的研究文章或与之一同分享,但传统出版流程经常将它们视为次级内容。为了发表论文,使用这些语言的研究人员除了将他们的计算结果用图片的形式“扁平化”提交外别无他法。但是这导致了许多实验价值和代码和计算数据可重复利用性的流失。诸如 [Jupyter][10] 这样的电子笔记本解决方案确实可以使研究员以一种可重复利用、可执行的简单形式发布,但是这种方案仍然是出版的手稿的补充,而不是不可或缺的一部分。 + +[可重现文档栈][11] 项目旨在通过开发、发布一个可重现原稿的产品原型来解决这些挑战,该原型将代码和数据视为文档的组成部分,并展示了从创作到出版的完整端对端技术栈。它将最终允许用户以一种包含嵌入代码块和计算结果(统计结果、图表或图形)的形式提交他们的手稿,并在出版过程中保留这些可视、可执行的部分。那时出版商就可以将这些做为出版的在线文章的组成部分而保存。 + +### 用 Hypothesis 进行开放式注解 + +最近,我们与 [Hypothesis][12] 合作引进了开放式注解,使得我们网站的用户们可以写评语、高亮文章重要部分以及与在线阅读的群体互动。 + +通过这样的合作,开源的 Hypothesis 软件被定制得更具有现代化的特性,如单次登录验证、用户界面定制,给予了出版商在他们自己网站上实现更多的控制。这些提升正引导着关于出版学术内容的高质量讨论。 + +这个工具可以无缝集成到出版商的网站,学术出版平台 [PubFactory][13] 和内容解决方案供应商 [Ingenta][14] 已经利用了它优化后的特性集。[HighWire][15] 和 [Silverchair][16] 也为他们的出版商提供了实施这套方案的机会。 + +### 其它产业和开源软件 + +随着时间的推移,我们希望看到更多的出版商采用 Hypothesis、Libero 以及其它开源项目去帮助他们促进重要科学研究的发现以及循环利用。但是 eLife 的创新机遇也能被其它行业所利用,因为这些软件和其它 OSS 技术在其他行业也很普遍。 + +数据科学的世界离不开高质量、良好支持的开源软件和围绕它们形成的社区;[TensorFlow][17] 就是这样一个好例子。感谢 OSS 以及其社区,AI 和机器学习的所有领域相比于计算机的其它领域的提升和发展更加迅猛。与之类似的是以 Linux 作为云端 Web 主机的爆炸性增长、接着是 Docker 容器、以及现在 GitHub 上最流行的开源项目之一的 Kubernetes 的增长。 + +所有的这些技术使得机构们能够用更少的资源做更多的事情,并专注于创新而不是重新发明轮子上。最后,这就是 OSS 真正的好处:它使得我们从互相的失败中学习,在互相的成功中成长。 + +我们总是在寻找与研究和科技界面方面最好的人才和想法交流的机会。你可以在 [eLife Labs][18] 上或者联系 [innovation@elifesciences.org][19] 找到更多这种交流的信息。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/3/scientific-publishing-software + +作者:[Paul Shanno][a] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/pshannon +[1]:https://www.theguardian.com/science/2017/jun/27/profitable-business-scientific-publishing-bad-for-science +[2]:https://elifesciences.org/about +[3]:https://elifesciences.org/inside-elife/33e4127f/elife-introduces-continuum-a-new-open-source-tool-for-publishing +[4]:https://elifesciences.org/for-the-press/e6038800/elife-supports-development-of-open-technology-stack-for-publishing-reproducible-manuscripts-online +[5]:https://elifesciences.org/for-the-press/81d42f7d/elife-enhances-open-annotation-with-hypothesis-to-promote-scientific-discussion-online +[6]:https://github.com/substance +[7]:https://github.com/stencila/stencila +[8]:https://rmarkdown.rstudio.com/ +[9]:https://www.python.org/ +[10]:http://jupyter.org/ +[11]:https://elifesciences.org/labs/7dbeb390/reproducible-document-stack-supporting-the-next-generation-research-article +[12]:https://github.com/hypothesis +[13]:http://www.pubfactory.com/ +[14]:http://www.ingenta.com/ +[15]:https://github.com/highwire +[16]:https://www.silverchair.com/community/silverchair-universe/hypothesis/ +[17]:https://www.tensorflow.org/ +[18]:https://elifesciences.org/labs +[19]:mailto:innovation@elifesciences.org diff --git a/published/20181216 Schedule a visit with the Emacs psychiatrist.md b/published/20181216 Schedule a visit with the Emacs psychiatrist.md new file mode 100644 index 0000000000..304beda2ff --- /dev/null +++ b/published/20181216 Schedule a visit with the Emacs psychiatrist.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10601-1.html) +[#]: subject: (Schedule a visit with the Emacs psychiatrist) +[#]: via: (https://opensource.com/article/18/12/linux-toy-eliza) +[#]: author: (Jason Baker https://opensource.com/users/jason-baker) + +预约 Emacs 心理医生 +====== + +> Eliza 是一个隐藏于某个 Linux 最流行文本编辑器中的自然语言处理聊天机器人。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-eliza.png?itok=3ioiBik_) + +欢迎你,今天时期 24 天的 Linux 命令行玩具的又一天。如果你是第一次访问本系列,你可能会问什么是命令行玩具呢。我们将会逐步确定这个概念,但一般来说,它可能是一个游戏,或任何能让你在终端玩的开心的其他东西。 + +可能你们已经见过了很多我们之前挑选的那些玩具,但我们依然希望对所有人来说都至少有一件新鲜事物。 + +今天的选择是 Emacs 中的一个彩蛋:Eliza,Rogerian 心理医生,一个准备好倾听你述说一切的终端玩具。 + +旁白:虽然这个玩具很好玩,但你的健康不是用来开玩笑的。请在假期期间照顾好你自己,无论时身体上还是精神上,若假期中的压力和焦虑对你的健康产生负面影响,请考虑找专业人士进行指导。真的有用。 + +要启动 [Eliza][1],首先,你需要启动 Emacs。很有可能 Emacs 已经安装在你的系统中了,但若没有,它基本上也肯定在你默认的软件仓库中。 + +由于我要求本系列的工具一定要时运行在终端内,因此使用 `-nw` 标志来启动 Emacs 让它在你的终端模拟器中运行。 + +``` +$ emacs -nw +``` + +在 Emacs 中,输入 `M-x doctor` 来启动 Eliza。对于像我这样有 Vim 背景的人可能不知道这是什么意思,只需要按下 `escape`,输入 `x` 然后输入 `doctor`。然后,向它倾述所有假日的烦恼吧。 + +Eliza 历史悠久,最早可以追溯到 1960 年代中期的 MIT 人工智能实验室。[维基百科][2] 上有它历史的详细说明。 + +Eliza 并不是 Emacs 中唯一的娱乐工具。查看 [手册][3] 可以看到一整列好玩的玩具。 + +![Linux toy:eliza animated][5] + +你有什么喜欢的命令行玩具值得推荐吗?我们时间不多了,但我还是想听听你的建议。请在下面评论中告诉我,我会查看的。另外也欢迎告诉我你们对本次玩具的想法。 + +请一定要看看昨天的玩具,[带着这个复刻版吃豆人来到 Linux 终端游乐中心][6],然后明天再来看另一个玩具! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/12/linux-toy-eliza + +作者:[Jason Baker][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jason-baker +[b]: https://github.com/lujun9972 +[1]: https://www.emacswiki.org/emacs/EmacsDoctor +[2]: https://en.wikipedia.org/wiki/ELIZA +[3]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Amusements.html +[4]: /file/417326 +[5]: https://opensource.com/sites/default/files/uploads/linux-toy-eliza-animated.gif (Linux toy: eliza animated) +[6]: https://opensource.com/article/18/12/linux-toy-myman diff --git a/published/20181220 7 CI-CD tools for sysadmins.md b/published/20181220 7 CI-CD tools for sysadmins.md new file mode 100644 index 0000000000..64933afa4f --- /dev/null +++ b/published/20181220 7 CI-CD tools for sysadmins.md @@ -0,0 +1,166 @@ +[#]: collector: (lujun9972) +[#]: translator: (jdh8383) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10578-1.html) +[#]: subject: (7 CI/CD tools for sysadmins) +[#]: via: (https://opensource.com/article/18/12/cicd-tools-sysadmins) +[#]: author: (Dan Barker https://opensource.com/users/barkerd427) + +系统管理员的 7 个 CI/CD 工具 +====== + +> 本文是一篇简单指南:介绍一些顶级的开源的持续集成、持续交付和持续部署(CI/CD)工具。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cicd_continuous_delivery_deployment_gears.png?itok=kVlhiEkc) + +虽然持续集成、持续交付和持续部署(CI/CD)在开发者社区里已经存在很多年,一些机构在其运维部门也有实施经验,但大多数公司并没有做这样的尝试。对于很多机构来说,让运维团队能够像他们的开发同行一样熟练操作 CI/CD 工具,已经变得十分必要了。 + +无论是基础设施、第三方应用还是内部开发的应用,都可以开展 CI/CD 实践。尽管你会发现有很多不同的工具,但它们都有着相似的设计模型。而且可能最重要的一点是:通过带领你的公司进行这些实践,会让你在公司内部变得举足轻重,成为他人学习的榜样。 + +一些机构在自己的基础设施上已有多年的 CI/CD 实践经验,常用的工具包括 [Ansible][1]、[Chef][2] 或者 [Puppet][3]。另一些工具,比如 [Test Kitchen][4],允许在最终要部署应用的基础设施上运行测试。事实上,如果使用更高级的配置方法,你甚至可以将应用部署到有真实负载的仿真“生产环境”上,来运行应用级别的测试。然而,单单是能够测试基础设施就是一项了不起的成就了。配置管理工具 Terraform 可以通过 Test Kitchen 来快速创建更[短暂][5]和[冥等的][6]的基础设施配置,这比它的前辈要强不少。再加上 Linux 容器和 Kubernetes,在数小时内,你就可以创建一套类似于生产环境的配置参数和系统资源,来测试整个基础设施和其上部署的应用,这在以前可能需要花费几个月的时间。而且,删除和再次创建整个测试环境也非常容易。 + +当然,作为初学者,你也可以把网络配置和 DDL(数据定义语言data definition language)文件加入版本控制,然后开始尝试一些简单的 CI/CD 流程。虽然只能帮你检查一下语义语法或某些最佳实践,但实际上大多数开发的管道都是这样起步的。只要你把脚手架搭起来,建造就容易得多了。而一旦起步,你就会发现各种管道的使用场景。 + +举个例子,我经常会在公司内部写新闻简报,我使用 [MJML][7] 制作邮件模板,然后把它加入版本控制。我一般会维护一个 web 版本,但是一些同事喜欢 PDF 版,于是我创建了一个[管道][8]。每当我写好一篇新闻稿,就在 Gitlab 上提交一个合并请求。这样做会自动创建一个 index.html 文件,生成这篇新闻稿的 HTML 和 PDF 版链接。HTML 和 PDF 文件也会在该管道里同时生成。除非有人来检查确认,这些文件不会被直接发布出去。使用 GitLab Pages 发布这个网站后,我就可以下载一份 HTML 版,用来发送新闻简报。未来,我会修改这个流程,当合并请求成功或者在某个审核步骤后,自动发出对应的新闻稿。这些处理逻辑并不复杂,但的确为我节省了不少时间。实际上这些工具最核心的用途就是替你节省时间。 + +关键是要在抽象层创建出工具,这样稍加修改就可以处理不同的问题。值得留意的是,我创建的这套流程几乎不需要任何代码,除了一些[轻量级的 HTML 模板][9],一些[把 HTML 文件转换成 PDF 的 nodejs 代码][10],还有一些[生成索引页面的 nodejs 代码][11]。 + +这其中一些东西可能看起来有点复杂,但其中大部分都源自我使用的不同工具的教学文档。而且很多开发人员也会乐意跟你合作,因为他们在完工时会发现这些东西也挺有用。上面我提供的那些代码链接是给 [DevOps KC][12](LCTT 译注:一个地方性 DevOps 组织) 发送新闻简报用的,其中大部分用来创建网站的代码来自我在内部新闻简报项目上所作的工作。 + +下面列出的大多数工具都可以提供这种类型的交互,但是有些工具提供的模型略有不同。这一领域新兴的模型是用声明式的方法例如 YAML 来描述一个管道,其中的每个阶段都是短暂而幂等的。许多系统还会创建[有向无环图(DAG)][13],来确保管道上不同的阶段排序的正确性。 + +这些阶段一般运行在 Linux 容器里,和普通的容器并没有区别。有一些工具,比如 [Spinnaker][14],只关注部署组件,而且提供一些其他工具没有的操作特性。[Jenkins][15] 则通常把管道配置存成 XML 格式,大部分交互都可以在图形界面里完成,但最新的方案是使用[领域专用语言(DSL)][16](如 [Groovy][17])。并且,Jenkins 的任务(job)通常运行在各个节点里,这些节点上会装一个专门的 Java 代理,还有一堆混杂的插件和预装组件。 + +Jenkins 在自己的工具里引入了管道的概念,但使用起来却并不轻松,甚至包含一些禁区。最近,Jenkins 的创始人决定带领社区向新的方向前进,希望能为这个项目注入新的活力,把 CI/CD 真正推广开(LCTT 译注:详见后面的 Jenkins 章节)。我认为其中最有意思的想法是构建一个云原生 Jenkins,能把 Kubernetes 集群转变成 Jenkins CI/CD 平台。 + +当你更多地了解这些工具并把实践带入你的公司和运维部门,你很快就会有追随者,因为你有办法提升自己和别人的工作效率。我们都有多年积累下来的技术债要解决,如果你能给同事们提供足够的时间来处理这些积压的工作,他们该会有多感激呢?不止如此,你的客户也会开始看到应用变得越来越稳定,管理层会把你看作得力干将,你也会在下次谈薪资待遇或参加面试时更有底气。 + +让我们开始深入了解这些工具吧,我们将对每个工具做简短的介绍,并分享一些有用的链接。 + +### GitLab CI + +- [项目主页](https://about.gitlab.com/product/continuous-integration/) +- [源代码](https://gitlab.com/gitlab-org/gitlab-ce/) +- 许可证:MIT + +GitLab 可以说是 CI/CD 领域里新登场的玩家,但它却在权威调研机构 [Forrester 的 CI 集成工具的调查报告][20]中位列第一。在一个高水平、竞争充分的领域里,这是个了不起的成就。是什么让 GitLab CI 这么成功呢?它使用 YAML 文件来描述整个管道。另有一个功能叫做 Auto DevOps,可以为较简单的项目用多种内置的测试单元自动生成管道。这套系统使用 [Herokuish buildpacks][21] 来判断语言的种类以及如何构建应用。有些语言也可以管理数据库,它真正改变了构建新应用程序和从开发的开始将它们部署到生产环境的过程。它原生集成于 Kubernetes,可以根据不同的方案将你的应用自动部署到 Kubernetes 集群,比如灰度发布、蓝绿部署等。 + +除了它的持续集成功能,GitLab 还提供了许多补充特性,比如:将 Prometheus 和你的应用一同部署,以提供操作监控功能;通过 GitLab 提供的 Issues、Epics 和 Milestones 功能来实现项目评估和管理;管道中集成了安全检测功能,多个项目的检测结果会聚合显示;你可以通过 GitLab 提供的网页版 IDE 在线编辑代码,还可以快速查看管道的预览或执行状态。 + +### GoCD + +- [项目主页](https://www.gocd.org/) +- [源代码](https://github.com/gocd/gocd) +- 许可证:Apache 2.0 + +GoCD 是由老牌软件公司 Thoughtworks 出品,这已经足够证明它的能力和效率。对我而言,GoCD 最具亮点的特性是它的[价值流视图(VSM)][22]。实际上,一个管道的输出可以变成下一个管道的输入,从而把管道串联起来。这样做有助于提高不同开发团队在整个开发流程中的独立性。比如在引入 CI/CD 系统时,有些成立较久的机构希望保持他们各个团队相互隔离,这时候 VSM 就很有用了:让每个人都使用相同的工具就很容易在 VSM 中发现工作流程上的瓶颈,然后可以按图索骥调整团队或者想办法提高工作效率。 + +为公司的每个产品配置 VSM 是非常有价值的;GoCD 可以使用 [JSON 或 YAML 格式存储配置][23],还能以可视化的方式展示数据等待时间,这让一个机构能有效减少学习它的成本。刚开始使用 GoCD 创建你自己的流程时,建议使用人工审核的方式。让每个团队也采用人工审核,这样你就可以开始收集数据并且找到可能的瓶颈点。 + +### Travis CI + +- [项目主页](https://docs.travis-ci.com/) +- [源代码](https://github.com/travis-ci/travis-ci) +- 许可证:MIT + +我使用的第一个软件既服务(SaaS)类型的 CI 系统就是 Travis CI,体验很不错。管道配置以源码形式用 YAML 保存,它与 GitHub 等工具无缝整合。我印象中管道从来没有失效过,因为 Travis CI 的在线率很高。除了 SaaS 版之外,你也可以使用自行部署的版本。我还没有自行部署过,它的组件非常多,要全部安装的话,工作量就有点吓人了。我猜更简单的办法是把它部署到 Kubernetes 上,[Travis CI 提供了 Helm charts][26],这些 charts 目前不包含所有要部署的组件,但我相信以后会越来越丰富的。如果你不想处理这些细枝末节的问题,还有一个企业版可以试试。 + +假如你在开发一个开源项目,你就能免费使用 SaaS 版的 Travis CI,享受顶尖团队提供的优质服务!这样能省去很多麻烦,你可以在一个相对通用的平台上(如 GitHub)研发开源项目,而不用找服务器来运行任何东西。 + +### Jenkins + +- [项目主页](https://jenkins.io/) +- [源代码](https://github.com/jenkinsci/jenkins) +- 许可证:MIT + +Jenkins 在 CI/CD 界绝对是元老级的存在,也是事实上的标准。我强烈建议你读一读这篇文章:“[Jenkins: Shifting Gears][27]”,作者 Kohsuke 是 Jenkins 的创始人兼 CloudBees 公司 CTO。这篇文章契合了我在过去十年里对 Jenkins 及其社区的感受。他在文中阐述了一些这几年呼声很高的需求,我很乐意看到 CloudBees 引领这场变革。长期以来,Jenkins 对于非开发人员来说有点难以接受,并且一直是其管理员的重担。还好,这些问题正是他们想要着手解决的。 + +[Jenkins 配置既代码][28](JCasC)应该可以帮助管理员解决困扰了他们多年的配置复杂性问题。与其他 CI/CD 系统类似,只需要修改一个简单的 YAML 文件就可以完成 Jenkins 主节点的配置工作。[Jenkins Evergreen][29] 的出现让配置工作变得更加轻松,它提供了很多预设的使用场景,你只管套用就可以了。这些发行版会比官方的标准版本 Jenkins 更容易维护和升级。 + +Jenkins 2 引入了两种原生的管道功能,我在 LISA(LCTT 译注:一个系统架构和运维大会) 2017 年的研讨会上已经[讨论过了][30]。这两种功能都没有 YAML 简便,但在处理复杂任务时它们很好用。 + +[Jenkins X][31] 是 Jenkins 的一个全新变种,用来实现云端原生 Jenkins(至少在用户看来是这样)。它会使用 JCasC 及 Evergreen,并且和 Kubernetes 整合的更加紧密。对于 Jenkins 来说这是个令人激动的时刻,我很乐意看到它在这一领域的创新,并且继续发挥领袖作用。 + +### Concourse CI + +- [项目主页](https://concourse-ci.org/) +- [源代码](https://github.com/concourse/concourse) +- 许可证:Apache 2.0 + +我第一次知道 Concourse 是通过 Pivotal Labs 的伙计们介绍的,当时它处于早期 beta 版本,而且那时候也很少有类似的工具。这套系统是基于微服务构建的,每个任务运行在一个容器里。它独有的一个优良特性是能够在你本地系统上运行任务,体现你本地的改动。这意味着你完全可以在本地开发(假设你已经连接到了 Concourse 的服务器),像在真实的管道构建流程一样从你本地构建项目。而且,你可以在修改过代码后从本地直接重新运行构建,来检验你的改动结果。 + +Concourse 还有一个简单的扩展系统,它依赖于“资源”这一基础概念。基本上,你想给管道添加的每个新功能都可以用一个 Docker 镜像实现,并作为一个新的资源类型包含在你的配置中。这样可以保证每个功能都被封装在一个不可变的独立工件中,方便对其单独修改和升级,改变其中一个时不会影响其他构建。 + +### Spinnaker + +- [项目主页](https://www.spinnaker.io/) +- [源代码](https://github.com/spinnaker/spinnaker) +- 许可证:Apache 2.0 + +Spinnaker 出自 Netflix,它更关注持续部署而非持续集成。它可以与其他工具整合,比如 Travis 和 Jenkins,来启动测试和部署流程。它也能与 Prometheus、Datadog 这样的监控工具集成,参考它们提供的指标来决定如何部署。例如,在金丝雀发布canary deployment里,我们可以根据收集到的相关监控指标来做出判断:最近的这次发布是否导致了服务降级,应该立刻回滚;还是说看起来一切 OK,应该继续执行部署。 + +谈到持续部署,一些另类但却至关重要的问题往往被忽略掉了,说出来可能有点让人困惑:Spinnaker 可以帮助持续部署不那么“持续”。在整个应用部署流程期间,如果发生了重大问题,它可以让流程停止执行,以阻止可能发生的部署错误。但它也可以在最关键的时刻让人工审核强制通过,发布新版本上线,使整体收益最大化。实际上,CI/CD 的主要目的就是在商业模式需要调整时,能够让待更新的代码立即得到部署。 + +### Screwdriver + +- [项目主页](http://screwdriver.cd/) +- [源代码](https://github.com/screwdriver-cd/screwdriver) +- 许可证:BSD + +Screwdriver 是个简单而又强大的软件。它采用微服务架构,依赖像 Nomad、Kubernetes 和 Docker 这样的工具作为执行引擎。官方有一篇很不错的[部署教学文档][34],介绍了如何将它部署到 AWS 和 Kubernetes 上,但如果正在开发中的 [Helm chart][35] 也完成的话,就更完美了。 + +Screwdriver 也使用 YAML 来描述它的管道,并且有很多合理的默认值,这样可以有效减少各个管道重复的配置项。用配置文件可以组织起高级的工作流,来描述各个任务间复杂的依赖关系。例如,一项任务可以在另一个任务开始前或结束后运行;各个任务可以并行也可以串行执行;更赞的是你可以预先定义一项任务,只在特定的拉取请求时被触发,而且与之有依赖关系的任务并不会被执行,这能让你的管道具有一定的隔离性:什么时候被构造的工件应该被部署到生产环境,什么时候应该被审核。 + +--- + +以上只是我对这些 CI/CD 工具的简单介绍,它们还有许多很酷的特性等待你深入探索。而且它们都是开源软件,可以自由使用,去部署一下看看吧,究竟哪个才是最适合你的那个。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/12/cicd-tools-sysadmins + +作者:[Dan Barker][a] +选题:[lujun9972][b] +译者:[jdh8383](https://github.com/jdh8383) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/barkerd427 +[b]: https://github.com/lujun9972 +[1]: https://www.ansible.com/ +[2]: https://www.chef.io/ +[3]: https://puppet.com/ +[4]: https://github.com/test-kitchen/test-kitchen +[5]: https://www.merriam-webster.com/dictionary/ephemeral +[6]: https://en.wikipedia.org/wiki/Idempotence +[7]: https://mjml.io/ +[8]: https://gitlab.com/devopskc/newsletter/blob/master/.gitlab-ci.yml +[9]: https://gitlab.com/devopskc/newsletter/blob/master/index/index.html +[10]: https://gitlab.com/devopskc/newsletter/blob/master/html-to-pdf.js +[11]: https://gitlab.com/devopskc/newsletter/blob/master/populate-index.js +[12]: https://devopskc.com/ +[13]: https://en.wikipedia.org/wiki/Directed_acyclic_graph +[14]: https://www.spinnaker.io/ +[15]: https://jenkins.io/ +[16]: https://martinfowler.com/books/dsl.html +[17]: http://groovy-lang.org/ +[18]: https://about.gitlab.com/product/continuous-integration/ +[19]: https://gitlab.com/gitlab-org/gitlab-ce/ +[20]: https://about.gitlab.com/2017/09/27/gitlab-leader-continuous-integration-forrester-wave/ +[21]: https://github.com/gliderlabs/herokuish +[22]: https://www.gocd.org/getting-started/part-3/#value_stream_map +[23]: https://docs.gocd.org/current/advanced_usage/pipelines_as_code.html +[24]: https://docs.travis-ci.com/ +[25]: https://github.com/travis-ci/travis-ci +[26]: https://github.com/travis-ci/kubernetes-config +[27]: https://jenkins.io/blog/2018/08/31/shifting-gears/ +[28]: https://jenkins.io/projects/jcasc/ +[29]: https://github.com/jenkinsci/jep/blob/master/jep/300/README.adoc +[30]: https://danbarker.codes/talk/lisa17-becoming-plumber-building-deployment-pipelines/ +[31]: https://jenkins-x.io/ +[32]: https://concourse-ci.org/ +[33]: https://github.com/concourse/concourse +[34]: https://docs.screwdriver.cd/cluster-management/kubernetes +[35]: https://github.com/screwdriver-cd/screwdriver-chart diff --git a/published/20190104 Midori- A Lightweight Open Source Web Browser.md b/published/20190104 Midori- A Lightweight Open Source Web Browser.md new file mode 100644 index 0000000000..e263fc38ca --- /dev/null +++ b/published/20190104 Midori- A Lightweight Open Source Web Browser.md @@ -0,0 +1,110 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10602-1.html) +[#]: subject: (Midori: A Lightweight Open Source Web Browser) +[#]: via: (https://itsfoss.com/midori-browser) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Midori:轻量级开源 Web 浏览器 +====== + +> 这是一个对再次回归的轻量级、快速、开源的 Web 浏览器 Midori 的快速回顾。 + +如果你正在寻找一款轻量级[网络浏览器替代品][1],请试试 Midori。 + +[Midori][2]是一款开源的网络浏览器,它更注重轻量级而不是提供大量功能。 + +如果你从未听说过 Midori,你可能会认为它是一个新的应用程序,但实际上 Midori 首次发布于 2007 年。 + +因为它专注于速度,所以 Midori 很快就聚集了一群爱好者,并成为了 Bodhi Linux、SilTaz 等轻量级 Linux 发行版的默认浏览器。 + +其他发行版如 [elementary OS][3] 也使用了 Midori 作为其默认浏览器。但 Midori 的开发在 2016 年左右停滞了,它的粉丝开始怀疑 Midori 已经死了。由于这个原因,elementary OS 从最新版本中删除了它。 + +好消息是 Midori 还没有死。经过近两年的不活跃,开发工作在 2018 年的最后一个季度恢复了。在后来的版本中添加了一些包括广告拦截器的扩展。 + +### Midori 网络浏览器的功能 + +![Midori web browser][4] + +以下是 Midori 浏览器的一些主要功能 + + * 使用 Vala 编写,使用 GTK+3 和 WebKit 渲染引擎。 +  * 标签、窗口和会话管理。 +  * 快速拨号。 +  * 默认保存下一个会话的选项卡。 +  * 使用 DuckDuckGo 作为默认搜索引擎。可以更改为 Google 或 Yahoo。 +  * 书签管理。 +  * 可定制和可扩展的界面。 +  * 扩展模块可以用 C 和 Vala 编写。 +  * 支持 HTML5。 +  * 少量的扩展程序包括广告拦截器、彩色标签等。没有第三方扩展程序。 +  * 表单历史。 +  * 隐私浏览。 +  * 可用于 Linux 和 Windows。 + +小知识:Midori 是日语单词,意思是绿色。如果你因此而猜想的话,但 Midori 的开发者实际不是日本人。 + +### 体验 Midori + +![Midori web browser in Ubuntu 18.04][5] + +这几天我一直在使用 Midori。体验基本很好。它支持 HTML5 并能快速渲染网站。广告拦截器也没问题。正如你对任何标准 Web 浏览器所期望的那样,浏览体验挺顺滑。 + +缺少扩展一直是 Midori 的弱点,所以​​我不打算谈论这个。 + +我注意到的是它不支持国际语言。我找不到添加新语言支持的方法。它根本无法渲染印地语字体,我猜对其他非[罗曼语言][6]也是一样。 + +我也在 YouTube 中也遇到了麻烦。有些视频会抛出播放错误而其他视频没问题。 + +Midori 没有像 Chrome 那样吃我的内存,所以这是一个很大的优势。 + +如果你想尝试 Midori,让我们看下你该如何安装。 + +### 在 Linux 上安装 Midori + +在 Ubuntu 18.04 仓库中不再提供 Midori。但是,可以使用 [Snap 包][7]轻松安装较新版本的 Midori。 + +如果你使用的是 Ubuntu,你可以在软件中心找到 Midori(Snap 版)并从那里安装。 + +![Midori browser is available in Ubuntu Software Center][8] + +对于其他 Linux 发行版,请确保你[已启用 Snap 支持][9],然后你可以使用以下命令安装 Midori: + +``` +sudo snap install midori +``` + +你可以选择从源代码编译。你可以从 Midori 的网站下载它的代码。 + +- [下载 Midori](https://www.midori-browser.org/download/) + +如果你喜欢 Midori 并希望帮助这个开源项目,请向他们捐赠或[从他们的商店购买 Midori 商品][10]。 + +你在使用 Midori 还是曾经用过么?你的体验如何?你更喜欢使用哪种其他网络浏览器?请在下面的评论栏分享你的观点。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/midori-browser + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/open-source-browsers-linux/ +[2]: https://www.midori-browser.org/ +[3]: https://itsfoss.com/elementary-os-juno-features/ +[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/Midori-web-browser.jpeg?resize=800%2C450&ssl=1 +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/midori-browser-linux.jpeg?resize=800%2C491&ssl=1 +[6]: https://en.wikipedia.org/wiki/Romance_languages +[7]: https://itsfoss.com/use-snap-packages-ubuntu-16-04/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/midori-ubuntu-software-center.jpeg?ssl=1 +[9]: https://itsfoss.com/install-snap-linux/ +[10]: https://www.midori-browser.org/shop +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/Midori-web-browser.jpeg?fit=800%2C450&ssl=1 diff --git a/published/20190108 How ASLR protects Linux systems from buffer overflow attacks.md b/published/20190108 How ASLR protects Linux systems from buffer overflow attacks.md new file mode 100644 index 0000000000..08e41d60ee --- /dev/null +++ b/published/20190108 How ASLR protects Linux systems from buffer overflow attacks.md @@ -0,0 +1,127 @@ +[#]: collector: (lujun9972) +[#]: translator: (leommxj) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10592-1.html) +[#]: subject: (How ASLR protects Linux systems from buffer overflow attacks) +[#]: via: (https://www.networkworld.com/article/3331199/linux/what-does-aslr-do-for-linux.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +ASLR 是如何保护 Linux 系统免受缓冲区溢出攻击的 +====== + +> 地址空间随机化(ASLR)是一种内存攻击缓解技术,可以用于 Linux 和 Windows 系统。了解一下如何运行它、启用/禁用它,以及它是如何工作的。 + +![](https://images.idgesg.net/images/article/2019/01/shuffling-cards-100784640-large.jpg) + +地址空间随机化Address Space Layout Randomization(ASLR)是一种操作系统用来抵御缓冲区溢出攻击的内存保护机制。这种技术使得系统上运行的进程的内存地址无法被预测,使得与这些进程有关的漏洞变得更加难以利用。 + +ASLR 目前在 Linux、Windows 以及 MacOS 系统上都有使用。其最早出现在 2005 的 Linux 系统上。2007 年,这项技术被 Windows 和 MacOS 部署使用。尽管 ASLR 在各个系统上都提供相同的功能,却有着不同的实现。 + +ASLR 的有效性依赖于整个地址空间布局是否对于攻击者保持未知。此外,只有编译时作为位置无关可执行文件Position Independent Executable(PIE)的可执行程序才能得到 ASLR 技术的最大保护,因为只有这样,可执行文件的所有代码节区才会被加载在随机地址。PIE 机器码不管绝对地址是多少都可以正确执行。 + +### ASLR 的局限性 + +尽管 ASLR 使得对系统漏洞的利用更加困难了,但其保护系统的能力是有限的。理解关于 ASLR 的以下几点是很重要的: + + * 它不能*解决*漏洞,而是增加利用漏洞的难度 + * 并不追踪或报告漏洞 + * 不能对编译时没有开启 ASLR 支持的二进制文件提供保护 + * 不能避免被绕过 + +### ASLR 是如何工作的 + +通过对攻击者在进行缓冲区溢出攻击时所要用到的内存布局中的偏移做了随机化,ASLR 加大了攻击成功的难度,从而增强了系统的控制流完整性。 + +通常认为 ASLR 在 64 位系统上效果更好,因为 64 位系统提供了更大的熵(可随机的地址范围)。 + +### ASLR 是否正在你的 Linux 系统上运行? + +下面展示的两条命令都可以告诉你的系统是否启用了 ASLR 功能: + +``` +$ cat /proc/sys/kernel/randomize_va_space +2 +$ sysctl -a --pattern randomize +kernel.randomize_va_space = 2 +``` + +上方指令结果中的数值(`2`)表示 ASLR 工作在全随机化模式。其可能为下面的几个数值之一: + +``` +0 = Disabled +1 = Conservative Randomization +2 = Full Randomization +``` + +如果你关闭了 ASLR 并且执行下面的指令,你将会注意到前后两条 `ldd` 的输出是完全一样的。`ldd` 命令会加载共享对象并显示它们在内存中的地址。 + +``` +$ sudo sysctl -w kernel.randomize_va_space=0 <== disable +[sudo] password for shs: +kernel.randomize_va_space = 0 +$ ldd /bin/bash + linux-vdso.so.1 (0x00007ffff7fd1000) <== same addresses + libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007ffff7c69000) + libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ffff7c63000) + libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffff7a79000) + /lib64/ld-linux-x86-64.so.2 (0x00007ffff7fd3000) +$ ldd /bin/bash + linux-vdso.so.1 (0x00007ffff7fd1000) <== same addresses + libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007ffff7c69000) + libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ffff7c63000) + libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffff7a79000) + /lib64/ld-linux-x86-64.so.2 (0x00007ffff7fd3000) +``` + +如果将其重新设置为 `2` 来启用 ASLR,你将会看到每次运行 `ldd`,得到的内存地址都不相同。 + +``` +$ sudo sysctl -w kernel.randomize_va_space=2 <== enable +[sudo] password for shs: +kernel.randomize_va_space = 2 +$ ldd /bin/bash + linux-vdso.so.1 (0x00007fff47d0e000) <== first set of addresses + libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f1cb7ce0000) + libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1cb7cda000) + libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1cb7af0000) + /lib64/ld-linux-x86-64.so.2 (0x00007f1cb8045000) +$ ldd /bin/bash + linux-vdso.so.1 (0x00007ffe1cbd7000) <== second set of addresses + libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007fed59742000) + libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fed5973c000) + libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fed59552000) + /lib64/ld-linux-x86-64.so.2 (0x00007fed59aa7000) +``` + +### 尝试绕过 ASLR + +尽管这项技术有很多优点,但绕过 ASLR 的攻击并不罕见,主要有以下几类: + + * 利用地址泄露 + * 访问与特定地址关联的数据 + * 针对 ASLR 实现的缺陷来猜测地址,常见于系统熵过低或 ASLR 实现不完善。 + * 利用侧信道攻击 + +### 总结 + +ASLR 有很大的价值,尤其是在 64 位系统上运行并被正确实现时。虽然不能避免被绕过,但这项技术的确使得利用系统漏洞变得更加困难了。这份参考资料可以提供 [在 64 位 Linux 系统上的完全 ASLR 的有效性][2] 的更多有关细节,这篇论文介绍了一种利用分支预测 [绕过 ASLR][3] 的技术。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3331199/linux/what-does-aslr-do-for-linux.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[leommxj](https://github.com/leommxj) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.networkworld.com/article/3242170/linux/invaluable-tips-and-tricks-for-troubleshooting-linux.html +[2]: https://cybersecurity.upv.es/attacks/offset2lib/offset2lib-paper.pdf +[3]: http://www.cs.ucr.edu/~nael/pubs/micro16.pdf +[4]: https://www.facebook.com/NetworkWorld/ +[5]: https://www.linkedin.com/company/network-world diff --git a/published/20190109 Configure Anaconda on Emacs - iD.md b/published/20190109 Configure Anaconda on Emacs - iD.md new file mode 100644 index 0000000000..5c6125e2e9 --- /dev/null +++ b/published/20190109 Configure Anaconda on Emacs - iD.md @@ -0,0 +1,116 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10604-1.html) +[#]: subject: (Configure Anaconda on Emacs – iD) +[#]: via: (https://idevji.com/configure-anaconda-on-emacs/) +[#]: author: (Devji Chhanga https://idevji.com/author/admin/) + +在 Emacs 上配置 Anaconda +====== + +也许我所追求的究极 IDE 就是 [Emacs][1] 了。我的目标是使 Emacs 成为一款全能的 Python IDE。本文描述了如何在 Emacs 上配置 Anaconda。(LCTT 译注:Anaconda 自称“世界上最流行的 Python/R 的数据分析平台”) + +我的配置信息: + +- OS:Trisquel 8.0 +- Emacs:GNU Emacs 25.3.2 + +快捷键说明([参见完全指南][2]): + +``` +C-x = Ctrl + x +M-x = Alt + x +RET = ENTER +``` + +### 1、下载并安装 Anaconda + +#### 1.1 下载 + +[从这儿][3] 下载 Anaconda。你应该下载 Python 3.x 的版本,因为 Python 2 在 2020 年就不再支持了。你无需预先安装 Python 3.x。这个安装脚本会自动安装它。 + +#### 1.2 安装 + +``` +cd ~/Downloads +bash Anaconda3-2018.12-Linux-x86.sh +``` + +### 2、将 Anaconda 添加到 Emacs + +#### 2.1 将 MELPA 添加到 Emacs + +我们需要用到 `anaconda-mode` 这个 Emacs 包。该包位于 MELPA 仓库中。Emacs25 需要手工添加该仓库。 + +- [注意:点击本文查看如何将 MELPA 添加到 Emacs][4] + +#### 2.2 为 Emacs 安装 anaconda-mode 包 + +``` +M-x package-install RET +anaconda-mode RET +``` + +#### 2.3 为 Emacs 配置 anaconda-mode + +``` +echo "(add-hook 'python-mode-hook 'anaconda-mode)" > ~/.emacs.d/init.el +``` + +### 3、在 Emacs 上通过 Anaconda 运行你第一个脚本 + +#### 3.1 创建新 .py 文件 + +``` +C-x C-f +HelloWorld.py RET +``` + +#### 3.2 输入下面代码 + +``` +print ("Hello World from Emacs") +``` + +#### 3.3 运行之 + +``` +C-c C-p +C-c C-c +``` + +输出为: + +``` +Python 3.7.1 (default, Dec 14 2018, 19:46:24) +[GCC 7.3.0] :: Anaconda, Inc. on linux +Type "help", "copyright", "credits" or "license" for more information. +>>> python.el: native completion setup loaded +>>> Hello World from Emacs +>>> +``` + +我是受到 [Codingquark][5] 的影响才开始使用 Emacs 的。 + +有任何错误和遗漏请在评论中写下。干杯! + +-------------------------------------------------------------------------------- + +via: https://idevji.com/configure-anaconda-on-emacs/ + +作者:[Devji Chhanga][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://idevji.com/author/admin/ +[b]: https://github.com/lujun9972 +[1]: https://www.gnu.org/software/emacs/ +[2]: https://www.math.uh.edu/~bgb/emacs_keys.html +[3]: https://www.anaconda.com/download/#linux +[4]: https://melpa.org/#/getting-started +[5]: https://codingquark.com diff --git a/published/20190123 Mind map yourself using FreeMind and Fedora.md b/published/20190123 Mind map yourself using FreeMind and Fedora.md new file mode 100644 index 0000000000..b8ee78cf9f --- /dev/null +++ b/published/20190123 Mind map yourself using FreeMind and Fedora.md @@ -0,0 +1,84 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10579-1.html) +[#]: subject: (Mind map yourself using FreeMind and Fedora) +[#]: via: (https://fedoramagazine.org/mind-map-yourself-using-freemind-and-fedora/) +[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) + +在 Fedora 中使用 FreeMind 介绍你自己 +====== + +![](https://fedoramagazine.org/wp-content/uploads/2019/01/freemind-816x345.jpg) + +介绍你自己的思维导图,一开始听起来有些牵强。它是关于神经通路么?还是心灵感应?完全不是。相反,自己的思维导图是一种在视觉上向他人描述自己的方式。它还展示了你拿来描述自己的特征之间的联系。这是一种以聪明又同时可控的与他人分享信息的有用方式。你可以使用任何思维导图应用来做到。本文向你展示如何使用 Fedora 中提供的 [FreeMind][1]。 + +### 获取应用 + +FreeMind 已经出现有一段时间了。虽然 UI 有点过时,应该做一些更新了,但它是一个功能强大的应用,提供了许多构建思维导图的选项。当然,它是 100% 开源的。还有其他思维导图应用可供 Fedora 和 Linux 用户使用。查看[此前一篇涵盖多个思维导图选择的文章][2]。 + +如果你运行的是 Fedora Workstation,请使用“软件”应用从 Fedora 仓库安装 FreeMind。或者在终端中使用这个 [sudo][3] 命令: + +``` +$ sudo dnf install freemind +``` + +你可以从 Fedora Workstation 中的 GNOME Shell Overview 启动应用。或者使用桌面环境提供的应用启动服务。默认情况下,FreeMind 会显示一个新的空白脑图: + +![][4] + +*FreeMind 初始(空白)思维导图* + +脑图由链接的项目或描述(节点)组成。当你想到与节点相关的内容时,只需创建一个与其连接的新节点即可。 + +### 做你自己的脑图 + +单击初始节点。编辑文本并按回车将其替换为你的姓名。你就能开始你的思维导图。 + +如果你必须向某人充分描述自己,你会怎么想?可能会有很多东西。你平时做什么?你喜欢什么?你不喜欢什么?你有什么价值?你有家庭吗?所有这些都可以在节点中体现。 + +要添加节点连接,请选择现有节点,然后单击“Insert”,或使用“灯泡”图标作为新的子节点。要在与新子级相同的层级添加另一个节点,请使用回车。 + +如果你弄错了,别担心。你可以使用 `Delete` 键删除不需要的节点。内容上没有规则。但是最好是短节点。它们能让你在创建导图时思维更快。简洁的节点还能让其他浏览者更轻松地查看和理解。 + +该示例使用节点规划了每个主要类别: + +![][5] + +*个人思维导图,第一级* + +你可以为这些区域中的每个区域另外迭代一次。让你的思想自由地连接想法以生成导图。不要担心“做得正确“。最好将所有内容从头脑中移到显示屏上。这是下一级导图的样子。 + +![][6] + +*个人思维导图,第二级* + +你可以以相同的方式扩展任何这些节点。请注意你在示例中可以了解多少有关 “John Q. Public” 的信息。 + +### 如何使用你的个人思维导图 + +这是让团队或项目成员互相介绍的好方法。你可以将各种格式和颜色应用于导图以赋予其个性。当然,这些在纸上做很有趣。但是在 Fedora 中安装一个就意味着你可以随时修复错误,甚至可以在你改变的时候做出修改。 + +祝你在探索个人思维导图上玩得开心! + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/mind-map-yourself-using-freemind-and-fedora/ + +作者:[Paul W. Frields][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/author/pfrields/ +[b]: https://github.com/lujun9972 +[1]: http://freemind.sourceforge.net/wiki/index.php/Main_Page +[2]: https://fedoramagazine.org/three-mind-mapping-tools-fedora/ +[3]: https://fedoramagazine.org/howto-use-sudo/ +[4]: https://fedoramagazine.org/wp-content/uploads/2019/01/Screenshot-from-2019-01-19-15-17-04-1024x736.png +[5]: https://fedoramagazine.org/wp-content/uploads/2019/01/Screenshot-from-2019-01-19-15-32-38-1024x736.png +[6]: https://fedoramagazine.org/wp-content/uploads/2019/01/Screenshot-from-2019-01-19-15-38-00-1024x736.png diff --git a/published/20091104 Linux-Unix App For Prevention Of RSI (Repetitive Strain Injury).md b/published/201902/20091104 Linux-Unix App For Prevention Of RSI (Repetitive Strain Injury).md similarity index 100% rename from published/20091104 Linux-Unix App For Prevention Of RSI (Repetitive Strain Injury).md rename to published/201902/20091104 Linux-Unix App For Prevention Of RSI (Repetitive Strain Injury).md diff --git a/published/201902/20120203 Computer Laboratory - Raspberry Pi- Lesson 3 OK03.md b/published/201902/20120203 Computer Laboratory - Raspberry Pi- Lesson 3 OK03.md new file mode 100644 index 0000000000..90e3be81ff --- /dev/null +++ b/published/201902/20120203 Computer Laboratory - Raspberry Pi- Lesson 3 OK03.md @@ -0,0 +1,358 @@ +[#]: collector: (lujun9972) +[#]: translator: (qhwdw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10519-1.html) +[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 3 OK03) +[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok03.html) +[#]: author: (Robert Mullins http://www.cl.cam.ac.uk/~rdm34) + +计算机实验室之树莓派:课程 3 OK03 +====== + +OK03 课程基于 OK02 课程来构建,它教你在汇编中如何使用函数让代码可复用和可读性更好。假设你已经有了 [课程 2:OK02][1] 的操作系统,我们将以它为基础。 + +### 1、可复用的代码 + +到目前为止,我们所写的代码都是以我们希望发生的事为顺序来输入的。对于非常小的程序来说,这种做法很好,但是如果我们以这种方式去写一个完整的系统,所写的代码可读性将非常差。我们应该去使用函数。 + +> 一个函数是一段可复用的代码片断,可以用于去计算某些答案,或执行某些动作。你也可以称它们为过程procedure例程routine子例程subroutine。虽然它们都是不同的,但人们几乎都没有正确地使用这个术语。 + +> 你应该在数学上遇到了函数的概念。例如,余弦函数应用于一个给定的数时,会得到介于 -1 到 1 之间的另一个数,这个数就是角的余弦。一般我们写成 `cos(x)` 来表示应用到一个值 `x` 上的余弦函数。 + +> 在代码中,函数可以有多个输入(也可以没有输入),然后函数给出多个输出(也可以没有输出),并可能导致副作用。例如一个函数可以在一个文件系统上创建一个文件,第一个输入是它的名字,第二个输入是文件的长度。 + +> ![Function as black boxes][2] + +> 函数可以认为是一个“黑匣子”。我们给它输入,然后它给我们输出,而我们不需要知道它是如何工作的。 + +在像 C 或 C++ 这样的高级代码中,函数是语言的组成部分。在汇编代码中,函数只是我们的创意。 + +理想情况下,我们希望能够在我们的寄存器中设置一些输入值,然后分支切换到某个地址,然后预期在某个时刻分支返回到我们代码,并通过代码来设置输出值到寄存器。这就是我们所设想的汇编代码中的函数。困难之处在于我们用什么样的方式去设置寄存器。如果我们只是使用平时所接触到的某种方法去设置寄存器,每个程序员可能使用不同的方法,这样你将会发现你很难理解其他程序员所写的代码。另外,编译器也不能像使用汇编代码那样轻松地工作,因为它们压根不知道如何去使用函数。为避免这种困惑,为每个汇编语言设计了一个称为应用程序二进制接口Application Binary Interface(ABI)的标准,由它来规范函数如何去运行。如果每个人都使用相同的方法去写函数,这样每个人都可以去使用其他人写的函数。在这里,我将教你们这个标准,而从现在开始,我所写的函数将全部遵循这个标准。 + +该标准规定,寄存器 `r0`、`r1`、`r2` 和 `r3` 将被依次用于函数的输入。如果函数没有输入,那么它不会在意值是什么。如果只需要一个输入,那么它应该总是在寄存器 `r0` 中,如果它需要两个输入,那么第一个输入在寄存器 `r0` 中,而第二个输入在寄存器 `r1` 中,依此类推。输出值也总是在寄存器 `r0` 中。如果函数没有输出,那么 `r0` 中是什么值就不重要了。 + +另外,该标准要求当一个函数运行之后,寄存器 `r4` 到 `r12` 的值必须与函数启动时的值相同。这意味着当你调用一个函数时,你可以确保寄存器 `r4` 到 `r12` 中的值没有发生变化,但是不能确保寄存器 `r0` 到 `r3` 中的值也没有发生变化。 + +当一个函数运行完成后,它将返回到启动它的代码分支处。这意味着它必须知道启动它的代码的地址。为此,需要一个称为 `lr`(链接寄存器)的专用寄存器,它总是在保存调用这个函数的指令后面指令的地址。 + +表 1.1 ARM ABI 寄存器用法 + +| 寄存器 | 简介 | 保留 | 规则 | +| ------ | --------- | ---- | ----------------- | +| `r0` | 参数和结果 | 否 | `r0` 和 `r1` 用于给函数传递前两个参数,以及函数返回的结果。如果函数返回值不使用它,那么在函数运行之后,它们可以携带任何值。 | +| `r1` | 参数和结果 | 否 | | +| `r2` | 参数 | 否 | `r2` 和 `r3` 用去给函数传递后两个参数。在函数运行之后,它们可以携带任何值。 | +| `r3` | 参数 | 否 | | +| `r4` | 通用寄存器 | 是 | `r4` 到 `r12` 用于保存函数运行过程中的值,它们的值在函数调用之后必须与调用之前相同。 | +| `r5` | 通用寄存器 | 是 | | +| `r6` | 通用寄存器 | 是 | | +| `r7` | 通用寄存器 | 是 | | +| `r8` | 通用寄存器 | 是 | | +| `r9` | 通用寄存器 | 是 | | +| `r10` | 通用寄存器 | 是 | | +| `r11` | 通用寄存器 | 是 | | +| `r12` | 通用寄存器 | 是 | | +| `lr` | 返回地址 | 否 | 当函数运行完成后,`lr` 中保存了分支的返回地址,但在函数运行完成之后,它将保存相同的地址。 | +| `sp` | 栈指针 | 是 | `sp` 是栈指针,在下面有详细描述。它的值在函数运行完成后,必须是相同的。 | + +通常,函数需要使用很多的寄存器,而不仅是 `r0` 到 `r3`。但是,由于 `r4` 到 `r12` 必须在函数完成之后值必须保持相同,因此它们需要被保存到某个地方。我们将它们保存到称为栈的地方。 + +> ![Stack diagram][3] + +> 一个stack就是我们在计算中用来保存值的一个很形象的方法。就像是摞起来的一堆盘子,你可以从上到下来移除它们,而添加它们时,你只能从下到上来添加。 + +> 在函数运行时,使用栈来保存寄存器值是个非常好的创意。例如,如果我有一个函数需要去使用寄存器 `r4` 和 `r5`,它将在一个栈上存放这些寄存器的值。最后用这种方式,它可以再次将它拿回来。更高明的是,如果为了运行完我的函数,需要去运行另一个函数,并且那个函数需要保存一些寄存器,在那个函数运行时,它将把寄存器保存在栈顶上,然后在结束后再将它们拿走。而这并不会影响我保存在寄存器 `r4` 和 `r5` 中的值,因为它们是在栈顶上添加的,拿走时也是从栈顶上取出的。 + +> 用来表示使用特定的方法将值放到栈上的专用术语,我们称之为那个方法的“栈帧stack frame”。不是每种方法都使用一个栈帧,有些是不需要存储值的。 + +因为栈非常有用,它被直接实现在 ARMv6 的指令集中。一个名为 `sp`(栈指针)的专用寄存器用来保存栈的地址。当需要有值添加到栈上时,`sp` 寄存器被更新,这样就总是保证它保存的是栈上第一个值的地址。`push {r4,r5}` 将推送 `r4` 和 `r5` 中的值到栈顶上,而 `pop {r4,r5}` 将(以正确的次序)取回它们。 + +### 2、我们的第一个函数 + +现在,关于函数的原理我们已经有了一些概念,我们尝试来写一个函数。由于是我们的第一个很基础的例子,我们写一个没有输入的函数,它将输出 GPIO 的地址。在上一节课程中,我们就是写到这个值上,但将它写成函数更好,因为我们在真实的操作系统中经常需要用到它,而我们不可能总是能够记住这个地址。 + +复制下列代码到一个名为 `gpio.s` 的新文件中。就像在 `source` 目录中使用的 `main.s` 一样。我们将把与 GPIO 控制器相关的所有函数放到一个文件中,这样更好查找。 + +```assembly +.globl GetGpioAddress +GetGpioAddress: +ldr r0,=0x20200000 +mov pc,lr +``` + +> `.globl lbl` 使标签 `lbl` 从其它文件中可访问。 + +> `mov reg1,reg2` 复制 `reg2` 中的值到 `reg1` 中。 + +这就是一个很简单的完整的函数。`.globl GetGpioAddress` 命令是通知汇编器,让标签 `GetGpioAddress` 在所有文件中全局可访问。这意味着在我们的 `main.s` 文件中,我们可以使用分支指令到标签 `GetGpioAddress` 上,即便这个标签在那个文件中没有定义也没有问题。 + +你应该认得 `ldr r0,=0x20200000` 命令,它将 GPIO 控制器地址保存到 `r0` 中。由于这是一个函数,我们必须要让它输出到寄存器 `r0` 中,我们不能再像以前那样随意使用任意一个寄存器了。 + +`mov pc,lr` 将寄存器 `lr` 中的值复制到 `pc` 中。正如前面所提到的,寄存器 `lr` 总是保存着方法完成后我们要返回的代码的地址。`pc` 是一个专用寄存器,它总是包含下一个要运行的指令的地址。一个普通的分支命令只需要改变这个寄存器的值即可。通过将 `lr` 中的值复制到 `pc` 中,我们就可以将要运行的下一行命令改变成我们将要返回的那一行。 + +理所当然这里有一个问题,那就是我们如何去运行这个代码?我们将需要一个特殊的分支类型 `bl` 指令。它像一个普通的分支一样切换到一个标签,但它在切换之前先更新 `lr` 的值去包含一个在该分支之后的行的地址。这意味着当函数执行完成后,将返回到 `bl` 指令之后的那一行上。这就确保了函数能够像任何其它命令那样运行,它简单地运行,做任何需要做的事情,然后推进到下一行。这是理解函数最有用的方法。当我们使用它时,就将它们按“黑匣子”处理即可,不需要了解它是如何运行的,我们只了解它需要什么输入,以及它给我们什么输出即可。 + +到现在为止,我们已经明白了函数如何使用,下一节我们将使用它。 + +### 3、一个大的函数 + +现在,我们继续去实现一个更大的函数。我们的第一项任务是启用 GPIO 第 16 号针脚的输出。如果它是一个函数那就太好了。我们能够简单地指定一个针脚号和一个函数作为输入,然后函数将设置那个针脚的值。那样,我们就可以使用这个代码去控制任意的 GPIO 针脚,而不只是 LED 了。 + +将下列的命令复制到 `gpio.s` 文件中的 `GetGpioAddress` 函数中。 + +```assembly +.globl SetGpioFunction +SetGpioFunction: +cmp r0,#53 +cmpls r1,#7 +movhi pc,lr +``` + +> 带后缀 `ls` 的命令只有在上一个比较命令的结果是第一个数字小于或与第二个数字相同的情况下才会被运行。它是无符号的。 + +> 带后缀 `hi` 的命令只有上一个比较命令的结果是第一个数字大于第二个数字的情况下才会被运行。它是无符号的。 + +在写一个函数时,我们首先要考虑的事情就是输入,如果输入错了我们怎么办?在这个函数中,我们有一个输入是 GPIO 针脚号,而它必须是介于 0 到 53 之间的数字,因为只有 54 个针脚。每个针脚有 8 个函数,被编号为 0 到 7,因此函数编号也必须是 0 到 7 之间的数字。我们可以假设输入应该是正确的,但是当在硬件上使用时,这种做法是非常危险的,因为不正确的值将导致非常糟糕的副作用。所以,在这个案例中,我们希望确保输入值在正确的范围。 + +为了确保输入值在正确的范围,我们需要做一个检查,即 `r0` <= 53 并且 `r1` <= 7。首先我们使用前面看到的比较命令去将 `r0` 的值与 53 做比较。下一个指令 `cmpls` 仅在前一个比较指令结果是小于或与 53 相同时才会去运行。如果是这种情况,它将寄存器 `r1` 的值与 7 进行比较,其它的部分都和前面的是一样的。如果最后的比较结果是寄存器值大于那个数字,最后我们将返回到运行函数的代码处。 + +这正是我们所希望的效果。如果 `r0` 中的值大于 53,那么 `cmpls` 命令将不会去运行,但是 `movhi` 会运行。如果 `r0` 中的值 <= 53,那么 `cmpls` 命令会运行,它会将 `r1` 中的值与 7 进行比较,如果 `r1` > 7,`movhi` 会运行,函数结束,否则 `movhi` 不会运行,这样我们就确定 `r0` <= 53 并且 `r1` <= 7。 + +`ls`(低于或相同)与 `le`(小于或等于)有一些细微的差别,以及后缀 `hi`(高于)和 `gt`(大于)也一样有一些细微差别,我们在后面将会讲到。 + +将这些命令复制到上面的代码的下面位置。 + +```assembly +push {lr} +mov r2,r0 +bl GetGpioAddress +``` + +> `push {reg1,reg2,...}` 复制列出的寄存器 `reg1`、`reg2`、... 到栈顶。该命令仅能用于通用寄存器和 `lr` 寄存器。 + +> `bl lbl` 设置 `lr` 为下一个指令的地址并切换到标签 `lbl`。 + +这三个命令用于调用我们第一个方法。`push {lr}` 命令复制 `lr` 中的值到栈顶,这样我们在后面可以获取到它。当我们调用 `GetGpioAddress` 时必须要这样做,我们将需要使用 `lr` 去保存我们函数要返回的地址。 + +如果我们对 `GetGpioAddress` 函数一无所知,我们必须假设它改变了 `r0`、`r1`、`r2` 和 `r3` 的值 ,并移动我们的值到 `r4` 和 `r5` 中,以在函数完成之后保持它们的值一样。幸运的是,我们知道 `GetGpioAddress` 做了什么,并且我们也知道它仅改变了 `r0` 为 GPIO 地址,它并没有影响 `r1`、`r2` 或 `r3` 的值。因此,我们仅去将 GPIO 针脚号从 `r0` 中移出,这样它就不会被覆盖掉,但我们知道,可以将它安全地移到 `r2` 中,因为 `GetGpioAddress` 并不去改变 `r2`。 + +最后我们使用 `bl` 指令去运行 `GetGpioAddress`。通常,运行一个函数,我们使用一个术语叫“调用”,从现在开始我们将一直使用这个术语。正如我们前面讨论过的,`bl` 调用一个函数是通过更新 `lr` 为下一个指令的地址并切换到该函数完成的。 + +当一个函数结束时,我们称为“返回”。当一个 `GetGpioAddress` 调用返回时,我们已经知道了 `r0` 中包含了 GPIO 的地址,`r1` 中包含了函数编号,而 `r2` 中包含了 GPIO 针脚号。 + +我前面说过,GPIO 函数每 10 个保存在一个块中,因此首先我们需要去判断我们的针脚在哪个块中。这似乎听起来像是要使用一个除法,但是除法做起来非常慢,因此对于这些比较小的数来说,不停地做减法要比除法更好。 + +将下面的代码复制到上面的代码中最下面的位置。 + +```assembly +functionLoop$: + +cmp r2,#9 +subhi r2,#10 +addhi r0,#4 +bhi functionLoop$ +``` + +> `add reg,#val` 将数字 `val` 加到寄存器 `reg` 的内容上。 + +这个简单的循环代码将针脚号(`r2`)与 9 进行比较。如果它大于 9,它将从针脚号上减去 10,并且将 GPIO 控制器地址加上 4,然后再次运行检查。 + +这样做的效果就是,现在,`r2` 中将包含一个 0 到 9 之间的数字,它是针脚号除以 10 的余数。`r0` 将包含这个针脚的函数所设置的 GPIO 控制器的地址。它就如同是 “GPIO 控制器地址 + 4 × (GPIO 针脚号 ÷ 10)”。 + +最后,将下面的代码复制到上面的代码中最下面的位置。 + +```assembly +add r2, r2,lsl #1 +lsl r1,r2 +str r1,[r0] +pop {pc} +``` + +> 移位参数 `reg,lsl #val` 表示将寄存器 `reg` 中二进制表示的数逻辑左移 `val` 位之后的结果作为与前面运算的操作数。 + +> `lsl reg,amt` 将寄存器 `reg` 中的二进制数逻辑左移 `amt` 中的位数。 + +> `str reg,[dst]` 与 `str reg,[dst,#0]` 相同。 + +> `pop {reg1,reg2,...}` 从栈顶复制值到寄存器列表 `reg1`、`reg2`、... 仅有通用寄存器与 `pc` 可以这样弹出值。 + +这个代码完成了这个方法。第一行其实是乘以 3 的变体。乘法在汇编中是一个大而慢的指令,因为电路需要很长时间才能给出答案。有时使用一些能够很快给出答案的指令会让它变得更快。在本案例中,我们知道 `r2` × 3 与 `r2` × 2 + `r2` 是相同的。一个寄存器乘以 2 是非常容易的,因为它可以通过将二进制表示的数左移一位来很方便地实现。 + +ARMv6 汇编语言其中一个非常有用的特性就是,在使用它之前可以先移动参数所表示的位数。在本案例中,我将 `r2` 加上 `r2` 中二进制表示的数左移一位的结果。在汇编代码中,你可以经常使用这个技巧去更快更容易地计算出答案,但如果你觉得这个技巧使用起来不方便,你也可以写成类似 `mov r3,r2`; `add r2,r3`; `add r2,r3` 这样的代码。 + +现在,我们可以将一个函数的值左移 `r2` 中所表示的位数。大多数对数量的指令(比如 `add` 和 `sub`)都有一个可以使用寄存器而不是数字的变体。我们执行这个移位是因为我们想去设置表示针脚号的位,并且每个针脚有三个位。 + +然后,我们将函数计算后的值保存到 GPIO 控制器的地址上。我们在循环中已经算出了那个地址,因此我们不需要像 OK01 和 OK02 中那样在一个偏移量上保存它。 + +最后,我们从这个方法调用中返回。由于我们将 `lr` 推送到了栈上,因此我们 `pop pc`,它将复制 `lr` 中的值并将它推送到 `pc` 中。这个操作类似于 `mov pc,lr`,因此函数调用将返回到运行它的那一行上。 + +敏锐的人可能会注意到,这个函数其实并不能正确工作。虽然它将 GPIO 针脚函数设置为所要求的值,但它会导致在同一个块中的所有的 10 个针脚的函数都归 0!在一个大量使用 GPIO 针脚的系统中,这将是一个很恼人的问题。我将这个问题留给有兴趣去修复这个函数的人,以确保只设置相关的 3 个位而不去覆写其它位,其它的所有位都保持不变。关于这个问题的解决方案可以在本课程的下载页面上找到。你可能会发现非常有用的几个函数是 `and`,它是计算两个寄存器的布尔与函数,`mvns` 是计算布尔非函数,而 `orr` 是计算布尔或函数。 + +### 4、另一个函数 + +现在,我们已经有了能够管理 GPIO 针脚函数的函数。我们还需要写一个能够打开或关闭 GPIO 针脚的函数。我们不需要写一个打开的函数和一个关闭的函数,只需要一个函数就可以做这两件事情。 + +我们将写一个名为 `SetGpio` 的函数,它将 GPIO 针脚号作为第一个输入放入 `r0` 中,而将值作为第二个输入放入 `r1` 中。如果该值为 `0`,我们将关闭针脚,而如果为非零则打开针脚。 + +将下列的代码复制粘贴到 `gpio.s` 文件的结尾部分。 + +```assembly +.globl SetGpio +SetGpio: +pinNum .req r0 +pinVal .req r1 +``` + +> `alias .req reg` 设置寄存器 `reg` 的别名为 `alias`。 + +我们再次需要 `.globl` 命令,标记它为其它文件可访问的全局函数。这次我们将使用寄存器别名。寄存器别名允许我们为寄存器使用名字而不仅是 `r0` 或 `r1`。到目前为止,寄存器别名还不是很重要,但随着我们后面写的方法越来越大,它将被证明非常有用,现在开始我们将尝试使用别名。当在指令中使用到 `pinNum .req r0` 时,它的意思是 `pinNum` 表示 `r0`。 + +将下面的代码复制粘贴到上述的代码下面位置。 + +```assembly +cmp pinNum,#53 +movhi pc,lr +push {lr} +mov r2,pinNum +.unreq pinNum +pinNum .req r2 +bl GetGpioAddress +gpioAddr .req r0 +``` + +> `.unreq alias` 删除别名 `alias`。 + +就像在函数 `SetGpio` 中所做的第一件事情是检查给定的针脚号是否有效一样。我们需要同样的方式去将 `pinNum`(`r0`)与 53 进行比较,如果它大于 53 将立即返回。一旦我们想要再次调用 `GetGpioAddress`,我们就需要将 `lr` 推送到栈上来保护它,将 `pinNum` 移动到 `r2` 中。然后我们使用 `.unreq` 语句来删除我们给 `r0` 定义的别名。因为针脚号现在保存在寄存器 `r2` 中,我们希望别名能够反映这个变化,因此我们从 `r0` 移走别名,重新定义到 `r2`。你应该每次在别名使用结束后,立即删除它,这样当它不再存在时,你就不会在后面的代码中因它而产生错误。 + +然后,我们调用了 `GetGpioAddress`,并且我们创建了一个指向 `r0`的别名以反映此变化。 + +将下面的代码复制粘贴到上述代码的后面位置。 + +```assembly +pinBank .req r3 +lsr pinBank,pinNum,#5a +lsl pinBank,#2 +add gpioAddr,pinBank +.unreq pinBank +``` + +> `lsr dst,src,#val` 将 `src` 中二进制表示的数右移 `val` 位,并将结果保存到 `dst`。 + +对于打开和关闭 GPIO 针脚,每个针脚在 GPIO 控制器上有两个 4 字节组。第一个 4 字节组每个位控制前 32 个针脚,而第二个 4 字节组控制剩下的 22 个针脚。为了判断我们要设置的针脚在哪个 4 字节组中,我们需要将针脚号除以 32。幸运的是,这很容易,因为它等价于将二进制表示的针脚号右移 5 位。因此,在本案例中,我们将 `r3` 命名为 `pinBank`,然后计算 `pinNum` ÷ 32。因为它是一个 4 字节组,我们需要将它与 4 相乘的结果。它与二进制表示的数左移 2 位相同,这就是下一行的命令。你可能想知道我们能否只将它右移 3 位呢,这样我们就不用先右移再左移。但是这样做是不行的,因为当我们做 ÷ 32 时答案有些位可能被舍弃,而如果我们做 ÷ 8 时却不会这样。 + +现在,`gpioAddr` 的结果有可能是 2020000016(如果针脚号介于 0 到 31 之间),也有可能是 2020000416(如果针脚号介于 32 到 53 之间)。这意味着如果加上 2810,我们将得到打开针脚的地址,而如果加上 4010 ,我们将得到关闭针脚的地址。由于我们用完了 `pinBank` ,所以在它之后立即使用 `.unreq` 去删除它。 + +将下面的代码复制粘贴到上述代码的下面位置。 + +```assembly +and pinNum,#31 +setBit .req r3 +mov setBit,#1 +lsl setBit,pinNum +.unreq pinNum +``` + +> `and reg,#val` 计算寄存器 `reg` 中的数与 `val` 的布尔与。 + +该函数的下一个部分是产生一个正确的位集合的数。至于 GPIO 控制器去打开或关闭针脚,我们在针脚号除以 32 的余数里设置了位的数。例如,设置 16 号针脚,我们需要第 16 位设置数字为 1 。设置 45 号针脚,我们需要设置第 13 位数字为 1,因为 45 ÷ 32 = 1 余数 13。 + +这个 `and` 命令计算我们需要的余数。它是这样计算的,在两个输入中所有的二进制位都是 1 时,这个 `and` 运算的结果就是 1,否则就是 0。这是一个很基础的二进制操作,`and` 操作非常快。我们给定的输入是 “pinNum and 3110 = 111112”。这意味着答案的后 5 位中只有 1,因此它肯定是在 0 到 31 之间。尤其是在 `pinNum` 的后 5 位的位置是 1 的地方它只有 1。这就如同被 32 整除的余数部分。就像 31 = 32 - 1 并不是巧合。 + +![binary division example][4] + +代码的其余部分使用这个值去左移 1 位。这就有了创建我们所需要的二进制数的效果。 + +将下面的代码复制粘贴到上述代码的下面位置。 + +```assembly +teq pinVal,#0 +.unreq pinVal +streq setBit,[gpioAddr,#40] +strne setBit,[gpioAddr,#28] +.unreq setBit +.unreq gpioAddr +pop {pc} +``` + +> `teq reg,#val` 检查寄存器 `reg` 中的数字与 `val` 是否相等。 + +这个代码结束了该方法。如前面所说,当 `pinVal` 为 0 时,我们关闭它,否则就打开它。`teq`(等于测试)是另一个比较操作,它仅能够测试是否相等。它类似于 `cmp` ,但它并不能算出哪个数大。如果你只是希望测试数字是否相同,你可以使用 `teq`。 + +如果 `pinVal` 是 0,我们将 `setBit` 保存在 GPIO 地址偏移 40 的位置,我们已经知道,这样会关闭那个针脚。否则将它保存在 GPIO 地址偏移 28 的位置,它将打开那个针脚。最后,我们通过弹出 `pc` 返回,这将设置它为我们推送链接寄存器时保存的值。 + +### 5、一个新的开始 + +在完成上述工作后,我们终于有了我们的 GPIO 函数。现在,我们需要去修改 `main.s` 去使用它们。因为 `main.s` 现在已经有点大了,也更复杂了。将它分成两节将是一个很好的设计。到目前为止,我们一直使用的 `.init` 应该尽可能的让它保持小。我们可以更改代码来很容易地反映出这一点。 + +将下列的代码插入到 `main.s` 文件中 `_start:` 的后面: + +``` +b main + +.section .text +main: +mov sp,#0x8000 +``` + +在这里重要的改变是引入了 `.text` 节。我设计了 `makefile` 和链接器脚本,它将 `.text` 节(它是默认节)中的代码放在地址为 800016 的 `.init` 节之后。这是默认加载地址,并且它给我们提供了一些空间去保存栈。由于栈存在于内存中,它也有一个地址。栈向下增长内存,因此每个新值都低于前一个地址,所以,这使得栈顶是最低的一个地址。 + +![Layout diagram of operating system][5] + +> 图中的 “ATAGs” 节的位置保存了有关树莓派的信息,比如它有多少内存,默认屏幕分辨率是多少。 + +用下面的代码替换掉所有设置 GPIO 函数针脚的代码: + +```assembly +pinNum .req r0 +pinFunc .req r1 +mov pinNum,#16 +mov pinFunc,#1 +bl SetGpioFunction +.unreq pinNum +.unreq pinFunc +``` + +这个代码将使用针脚号 16 和函数编号 1 去调用 `SetGpioFunction`。它的效果就是启用了 OK LED 灯的输出。 + +用下面的代码去替换打开 OK LED 灯的代码: + +```assembly +pinNum .req r0 +pinVal .req r1 +mov pinNum,#16 +mov pinVal,#0 +bl SetGpio +.unreq pinNum +.unreq pinVal +``` + +这个代码使用 `SetGpio` 去关闭 GPIO 第 16 号针脚,因此将打开 OK LED。如果我们(将第 4 行)替换成 `mov pinVal,#1` 它将关闭 LED 灯。用以上的代码去替换掉你关闭 LED 灯的旧代码。 + +### 6、继续向目标前进 + +但愿你能够顺利地在你的树莓派上测试我们所做的这一切。到目前为止,我们已经写了一大段代码,因此不可避免会出现错误。如果有错误,可以去查看我们的排错页面。 + +如果你的代码已经正常工作,恭喜你。虽然我们的操作系统除了做 [课程 2:OK02][1] 中的事情,还做不了别的任何事情,但我们已经学会了函数和格式有关的知识,并且我们现在可以更好更快地编写新特性了。现在,我们在操作系统上修改 GPIO 寄存器将变得非常简单,而它就是用于控制硬件的! + +在 [课程 4:OK04][6] 中,我们将处理我们的 `wait` 函数,目前,它的时间控制还不精确,这样我们就可以更好地控制我们的 LED 灯了,进而最终控制所有的 GPIO 针脚。 + +-------------------------------------------------------------------------------- + +via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok03.html + +作者:[Robert Mullins][a] +选题:[lujun9972][b] +译者:[qhwdw](https://github.com/qhwdw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.cl.cam.ac.uk/~rdm34 +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10478-1.html +[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/functions.png +[3]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/stack.png +[4]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/binary3.png +[5]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/osLayout.png +[6]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok04.html diff --git a/translated/tech/20120204 Computer Laboratory - Raspberry Pi- Lesson 4 OK04.md b/published/201902/20120204 Computer Laboratory - Raspberry Pi- Lesson 4 OK04.md similarity index 69% rename from translated/tech/20120204 Computer Laboratory - Raspberry Pi- Lesson 4 OK04.md rename to published/201902/20120204 Computer Laboratory - Raspberry Pi- Lesson 4 OK04.md index 69a56f3e72..e57ac869a6 100644 --- a/translated/tech/20120204 Computer Laboratory - Raspberry Pi- Lesson 4 OK04.md +++ b/published/201902/20120204 Computer Laboratory - Raspberry Pi- Lesson 4 OK04.md @@ -1,26 +1,27 @@ [#]: collector: (lujun9972) [#]: translator: (qhwdw) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10526-1.html) [#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 4 OK04) [#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok04.html) [#]: author: (Robert Mullins http://www.cl.cam.ac.uk/~rdm34) -计算机实验室 – 树莓派:课程 4 OK04 +计算机实验室之树莓派:课程 4 OK04 ====== -OK04 课程在 OK03 的基础上进行构建,它教你如何使用定时器让 `OK` 或 `ACT` LED 灯按精确的时间间隔来闪烁。假设你已经有了 [课程 3:OK03][1] 的操作系统,我们将以它为基础来构建。 +OK04 课程在 OK03 的基础上进行构建,它教你如何使用定时器让 OK 或 ACT LED 灯按精确的时间间隔来闪烁。假设你已经有了 [课程 3:OK03][1] 的操作系统,我们将以它为基础来构建。 ### 1、一个新设备 -定时器是树莓派保持时间的唯一方法。大多数计算机都有一个电池供电的时钟,这样当计算机关机后仍然能保持时间。 - +> 定时器是树莓派保持时间的唯一方法。大多数计算机都有一个电池供电的时钟,这样当计算机关机后仍然能保持时间。 + 到目前为止,我们仅看了树莓派硬件的一小部分,即 GPIO 控制器。我只是简单地告诉你做什么,然后它会发生什么事情。现在,我们继续看定时器,并继续带你去了解它的工作原理。 -和 GPIO 控制器一样,定时器也有地址。在本案例中,定时器的基地址在 20003000~16~。阅读手册我们可以找到下面的表: +和 GPIO 控制器一样,定时器也有地址。在本案例中,定时器的基地址在 2000300016。阅读手册我们可以找到下面的表: 表 1.1 GPIO 控制器寄存器 + | 地址 | 大小 / 字节 | 名字 | 描述 | 读或写 | | -------- | ------------ | ---------------- | ---------------------------------------------------------- | ---------------- | | 20003000 | 4 | Control / Status | 用于控制和清除定时器通道比较器匹配的寄存器 | RW | @@ -34,40 +35,33 @@ OK04 课程在 OK03 的基础上进行构建,它教你如何使用定时器让 这个表只告诉我们一部分内容,在手册中描述了更多的字段。手册上解释说,定时器本质上是按每微秒将计数器递增 1 的方式来运行。每次它是这样做的,它将计数器的低 32 位(4 字节)与 4 个比较器寄存器进行比较,如果匹配它们中的任何一个,它更新 `Control/Status` 以反映出其中有一个是匹配的。 -关于bit、字节、位字段bit field、以及数据大小的更多内容如下: +关于bit字节byte位字段bit field、以及数据大小的更多内容如下: > -> 一个位是一个单个的二进制数的名称。你可能还记得,一个单个的二进制数即可能是一个 1,也可能是一个 0。 +> 一个位是一个单个的二进制数的名称。你可能还记得,一个单个的二进制数既可能是一个 1,也可能是一个 0。 > -> 一个字节是一个 8 位集合的名称。由于每个位可能是 1 或 0 这两个值的其中之一,因此,一个字节有 2^8^ = 256 个不同的可能值。我们一般解释一个字节为一个介于 0 到 255(含)之间的二进制数。 +> 一个字节是一个 8 位集合的名称。由于每个位可能是 1 或 0 这两个值的其中之一,因此,一个字节有 2^8 = 256 个不同的可能值。我们一般解释一个字节为一个介于 0 到 255(含)之间的二进制数。 > > ![Diagram of GPIO function select controller register 0.][3] > > 一个位字段是解释二进制的另一种方式。二进制可以解释为许多不同的东西,而不仅仅是一个数字。一个位字段可以将二进制看做为一系列的 1(开) 或 0(关)的开关。对于每个小开关,我们都有一个意义,我们可以使用它们去控制一些东西。我们已经遇到了 GPIO 控制器使用的位字段,使用它设置一个针脚的开或关。位为 1 时 GPIO 针脚将准确地打开或关闭。有时我们需要更多的选项,而不仅仅是开或关,因此我们将几个开关组合到一起,比如 GPIO 控制器的函数设置(如上图),每 3 位为一组控制一个 GPIO 针脚的函数。 -> - 我们的目标是实现一个函数,这个函数能够以一个时间数量为输入来调用它,这个输入的时间数量将作为等待的时间,然后返回。想一想如何去做,想想我们都拥有什么。 我认为这将有两个选择: 1. 从计数器中读取一个值,然后保持分支返回到相同的代码,直到计数器的等待时间数量大于它。 - 2. 从计数器中读取一个值,加时间数量去等待,保存它到比较器寄存器,然后保持分支返回到相同的代码处,直到 `Control / Status` 寄存器更新。 - - -``` -像这样存在被称为"并发问题"的问题,并且几乎无法解决。 -``` + 2. 从计数器中读取一个值,加上要等待的时间数量,将它保存到比较器寄存器,然后保持分支返回到相同的代码处,直到 `Control / Status` 寄存器更新。 这两种策略都工作的很好,但在本教程中,我们将只实现第一个。原因是比较器寄存器更容易出错,因为在增加等待时间并保存它到比较器的寄存器期间,计数器可能已经增加了,并因此可能会不匹配。如果请求的是 1 微秒(或更糟糕的情况是 0 微秒)的等待,这样可能导致非常长的意外延迟。 +> 像这样存在被称为“并发问题”的问题,并且几乎无法解决。 + ### 2、实现 -``` -大型的操作系统通常使用等待函数来抓住机会在后台执行任务。 -``` +我将把这个创建完美的等待方法的挑战基本留给你。我建议你将所有与定时器相关的代码都放在一个名为 `systemTimer.s` 的文件中(理由很明显)。关于这个方法的复杂部分是,计数器是一个 8 字节值,而每个寄存器仅能保存 4 字节。所以,计数器值将分到 2 个寄存器中。 -我将把这个创建完美的等待方法的挑战留给你。我建议你将所有与定时器相关的代码都放在一个名为 `systemTimer.s` 的文件中(理由很明显)。关于这个方法的复杂部分是,计数器是一个 8 字节值,而每个寄存器仅能保存 4 字节。所以,计数器值将分到 2 个寄存器中。 +> 大型的操作系统通常使用等待函数来抓住机会在后台执行任务。 下列的代码块是一个示例。 @@ -75,13 +69,11 @@ OK04 课程在 OK03 的基础上进行构建,它教你如何使用定时器让 ldrd r0,r1,[r2,#4] ``` -```assembly -ldrd regLow,regHigh,[src,#val] 从 src 加上 val 数的地址上加载 8 字节到寄存器 regLow 和 regHigh 中。 -``` +> `ldrd regLow,regHigh,[src,#val]` 从 `src` 中的数加上 `val` 之和的地址加载 8 字节到寄存器 `regLow` 和 `regHigh` 中。 -上面的代码中你可以发现一个很有用的指令是 `ldrd`。它从两个寄存器中加载 8 字节的内存。在本案例中,这 8 字节内存从寄存器 `r2` 中的地址开始,将被复制进寄存器 `r0` 和 `r1`。这种安排的稍微复杂之处在于 `r1` 实际上只持有了高位 4 字节。换句话说就是,如果如果计数器的值是 999,999,999,999~10~ = 1110100011010100101001010000111111111111~2~ ,那么寄存器 `r1` 中只有 11101000~2~,而寄存器 `r0` 中则是 11010100101001010000111111111111~2~。 +上面的代码中你可以发现一个很有用的指令是 `ldrd`。它加载 8 字节的内存到两个寄存器中。在本案例中,这 8 字节内存从寄存器 `r2` 中的地址 + 4 开始,将被复制进寄存器 `r0` 和 `r1`。这种安排的稍微复杂之处在于 `r1` 实际上只持有了高位 4 字节。换句话说就是,如果如果计数器的值是 999,999,999,99910 = 11101000110101001010010100001111111111112 ,那么寄存器 `r1` 中只有 111010002,而寄存器 `r0` 中则是 110101001010010100001111111111112。 -实现它的更明智的方式应该是,去计算当前计数器值与来自方法启动后的那一个值的差,然后将它与要求的等待时间数量进行比较。除非恰好你希望的等待时间是支持 8 字节的,否则上面示例中寄存器 `r1` 中的值将会丢失,而计数器仅需要使用低位 4 字节。 +实现它的更明智的方式应该是,去计算当前计数器值与来自方法启动后的那一个值的差,然后将它与要求的等待时间数量进行比较。除非恰好你希望的等待时间是占用 8 字节的,否则上面示例中寄存器 `r1` 中的值将会丢弃,而计数器仅需要使用低位 4 字节。 当等待开始时,你应该总是确保使用大于比较,而不是使用等于比较,因为如果你尝试去等待一个时间,而这个时间正好等于方法开始的时间与结束的时间之差,那么你就错过这个值而永远等待下去。 @@ -97,7 +89,7 @@ ldrd regLow,regHigh,[src,#val] 从 src 加上 val 数的地址上加载 8 字节 > mov pc,lr > ``` > -> 另一个被证明非常有用的函数是在寄存器 `r0` 和 `r1` 中返回当前计数器值: +> 另一个被证明非常有用的函数是返回在寄存器 `r0` 和 `r1` 中的当前计数器值: > > ```assembly > .globl GetTimeStamp @@ -110,7 +102,7 @@ ldrd regLow,regHigh,[src,#val] 从 src 加上 val 数的地址上加载 8 字节 > > 这个函数简单地使用了 `GetSystemTimerBase` 函数,并像我们前面学过的那样,使用 `ldrd` 去加载当前计数器值。 > -> 现在,我们可以去写我们的等待方法的代码了。首先,在方法启动后,我们需要知道计数器值,当前计数器值我们现在已经可以使用 `GetTimeStamp` 来取得了。 +> 现在,我们可以去写我们的等待方法的代码了。首先,在该方法启动后,我们需要知道计数器值,我们可以使用 `GetTimeStamp` 来取得。 > > ```assembly > delay .req r2 @@ -121,9 +113,9 @@ ldrd regLow,regHigh,[src,#val] 从 src 加上 val 数的地址上加载 8 字节 > mov start,r0 > ``` > -> 这个代码复制我们的方法的输入,将延迟时间的数量放到寄存器 `r2` 中,然后调用 `GetTimeStamp`,这个函数将会在寄存器 `r0` 和 `r1` 中返回当前计数器值。接着复制计数器值的低位 4 字节到寄存器 `r3` 中。 +> 这个代码复制了我们的方法的输入,将延迟时间的数量放到寄存器 `r2` 中,然后调用 `GetTimeStamp`,这个函数将会返回寄存器 `r0` 和 `r1` 中的当前计数器值。接着复制计数器值的低位 4 字节到寄存器 `r3` 中。 > -> 接下来,我们需要计算当前计数器值与读入的值的差,然后持续这样做,直到它们的差至少是延迟大小为止。 +> 接下来,我们需要计算当前计数器值与读入的值的差,然后持续这样做,直到它们的差至少是 `delay` 的大小为止。 > > ```assembly > loop$: @@ -136,7 +128,7 @@ ldrd regLow,regHigh,[src,#val] 从 src 加上 val 数的地址上加载 8 字节 > bls loop$ > ``` > -> 这个代码将一直等待,一直到等待到传递给它的时间数量为止。它从计数器中读取数值,减去最初从计数器中读取的值,然后与要求的延迟时间进行比较。如果过去的时间数量小于要求的延迟,它切换到 `loop$`。 +> 这个代码将一直等待,一直到等待到传递给它的时间数量为止。它从计数器中读取数值,减去最初从计数器中读取的值,然后与要求的延迟时间进行比较。如果过去的时间数量小于要求的延迟,它切换回 `loop$`。 > > ```assembly > .unreq delay @@ -161,13 +153,13 @@ via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok04.html 作者:[Robert Mullins][a] 选题:[lujun9972][b] 译者:[qhwdw](https://github.com/qhwdw) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 [a]: http://www.cl.cam.ac.uk/~rdm34 [b]: https://github.com/lujun9972 -[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok03.html +[1]: https://linux.cn/article-10519-1.html [2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/systemTimer.png [3]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/gpioControllerFunctionSelect.png [4]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok05.html diff --git a/published/201902/20120205 Computer Laboratory - Raspberry Pi- Lesson 5 OK05.md b/published/201902/20120205 Computer Laboratory - Raspberry Pi- Lesson 5 OK05.md new file mode 100644 index 0000000000..48fe3eee37 --- /dev/null +++ b/published/201902/20120205 Computer Laboratory - Raspberry Pi- Lesson 5 OK05.md @@ -0,0 +1,100 @@ +[#]: collector: (lujun9972) +[#]: translator: (oska874) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10530-1.html) +[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 5 OK05) +[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok05.html) +[#]: author: (Robert Mullins http://www.cl.cam.ac.uk/~rdm34) + +计算机实验室之树莓派:课程 5 OK05 +====== + +OK05 课程构建于课程 OK04 的基础,使用它来闪烁摩尔斯电码的 SOS 序列(`...---...`)。这里假设你已经有了 [课程 4:OK04][1] 操作系统的代码作为基础。 + +### 1、数据 + +到目前为止,我们与操作系统有关的所有内容提供的都是指令。然而有时候,指令只是完成了一半的工作。我们的操作系统可能还需要数据。 + +> 一些早期的操作系统确实只允许特定文件中的特定类型的数据,但是这通常被认为限制太多了。现代方法确实可以使程序变得复杂的多。 + +通常,数据就是些很重要的值。你可能接受过培训,认为数据就是某种类型的,比如,文本文件包含文本,图像文件包含图片,等等。说实话,这只是你的想法而已。计算机上的全部数据都是二进制数字,重要的是我们选择用什么来解释这些数据。在这个例子中,我们会用一个闪灯序列作为数据保存下来。 + +在 `main.s` 结束处复制下面的代码: + +``` +.section .data %定义 .data 段 +.align 2 %对齐 +pattern: %定义整形变量 +.int 0b11111111101010100010001000101010 +``` + +> `.align num` 确保下一行代码的地址是 2^num 的整数倍。 + +> `.int val` 输出数值 `val`。 + +要区分数据和代码,我们将数据都放在 `.data` 区域。我已经将该区域包含在操作系统的内存布局图。我选择将数据放到代码后面。将我们的指令和数据分开保存的原因是,如果最后我们在自己的操作系统上实现一些安全措施,我们就需要知道代码的那些部分是可以执行的,而那些部分是不行的。 + +我在这里使用了两个新命令 `.align` 和 `.int`。`.align` 保证接下来的数据是按照 2 的乘方对齐的。在这个里,我使用 `.align 2` ,意味着数据最终存放的地址是 2^2=4 的整数倍。这个操作是很重要的,因为我们用来读取内存的指令 `ldr` 要求内存地址是 4 的倍数。 + +命令 `.int` 直接复制它后面的常量到输出。这意味着 111111111010101000100010001010102 将会被存放到输出,所以该标签模式实际是将这段数据标识为模式。 + +> 关于数据的一个挑战是寻找一个高效和有用的展示形式。这种保存一个开、关的时间单元的序列的方式,运行起来很容易,但是将很难编辑,因为摩尔斯电码的 `-` 或 `.` 样式丢失了。 + +如我提到的,数据可以代表你想要的所有东西。在这里我编码了摩尔斯电码的 SOS 序列,对于不熟悉的人,就是 `...---...`。我使用 0 表示一个时间单元的 LED 灭灯,而 1 表示一个时间单元的 LED 亮。这样,我们可以像这样编写一些代码在数据中显示一个序列,然后要显示不同序列,我们所有需要做的就是修改这段数据。下面是一个非常简单的例子,操作系统必须一直执行这段程序,解释和展示数据。 + +复制下面几行到 `main.s` 中的标记 `loop$` 之前。 + +``` +ptrn .req r4 %重命名 r4 为 ptrn +ldr ptrn,=pattern %加载 pattern 的地址到 ptrn +ldr ptrn,[ptrn] %加载地址 ptrn 所在内存的值 +seq .req r5 %重命名 r5 为 seq +mov seq,#0 %seq 赋值为 0 +``` + +这段代码加载 `pattrern` 到寄存器 `r4`,并加载 0 到寄存器 `r5`。`r5` 将是我们的序列位置,所以我们可以追踪我们已经展示了多少个 `pattern`。 + +如果 `pattern` 的当前位置是 1 且仅有一个 1,下面的代码将非零值放入 `r1`。 + +``` +mov r1,#1 %加载1到 r1 +lsl r1,seq %对r1 的值逻辑左移 seq 次 +and r1,ptrn %按位与 +``` + +这段代码对你调用 `SetGpio` 很有用,它必须有一个非零值来关掉 LED,而一个 0 值会打开 LED。 + +现在修改 `main.s` 中你的全部代码,这样代码中每次循环会根据当前的序列数设置 LED,等待 250000 毫秒(或者其他合适的延时),然后增加序列数。当这个序列数到达 32 就需要返回 0。看看你是否能实现这个功能,作为额外的挑战,也可以试着只使用一条指令。 + +### 2、当你玩得开心时,时间过得很快 + +你现在准备好在树莓派上实验。应该闪烁一串包含 3 个短脉冲,3 个长脉冲,然后 3 个短脉冲的序列。在一次延时之后,这种模式应该重复。如果这不工作,请查看我们的问题页。 + +一旦它工作,祝贺你已经抵达 OK 系列教程的结束点。 + +在这个系列我们学习了汇编代码,GPIO 控制器和系统定时器。我们已经学习了函数和 ABI,以及几个基础的操作系统原理,已经关于数据的知识。 + +你现在已经可以准备学习下面几个更高级的课程的某一个。 + + * [Screen][2] 系列是接下来的,会教你如何通过汇编代码使用屏幕。 + * [Input][3] 系列教授你如何使用键盘和鼠标。 + +到现在,你已经有了足够的信息来制作操作系统,用其它方法和 GPIO 交互。如果你有任何机器人工具,你可能会想尝试编写一个通过 GPIO 管脚控制的机器人操作系统。 + +-------------------------------------------------------------------------------- + +via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok05.html + +作者:[Robert Mullins][a] +选题:[lujun9972][b] +译者:[ezio](https://github.com/oska874) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.cl.cam.ac.uk/~rdm34 +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10526-1.html +[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen01.html +[3]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input01.html diff --git a/published/201902/20150513 XML vs JSON.md b/published/201902/20150513 XML vs JSON.md new file mode 100644 index 0000000000..282ae76893 --- /dev/null +++ b/published/201902/20150513 XML vs JSON.md @@ -0,0 +1,115 @@ +[#]: collector: (lujun9972) +[#]: translator: (wwhio) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10515-1.html) +[#]: subject: (XML vs JSON) +[#]: via: (https://www.cs.tufts.edu/comp/150IDS/final_papers/tstras01.1/FinalReport/FinalReport.html) +[#]: author: (TOM STRASSNER tomstrassner@gmail.com) + +XML 与 JSON 优劣对比 +====== + +### 简介 + +XML 和 JSON 是现今互联网中最常用的两种数据交换格式。XML 格式由 W3C 于 1996 年提出。JSON 格式由 Douglas Crockford 于 2002 年提出。虽然这两种格式的设计目标并不相同,但它们常常用于同一个任务,也就是数据交换中。XML 和 JSON 的文档都很完善([RFC 7159][1]、[RFC 4825][2]),且都同时具有人类可读性human-readable机器可读性machine-readable。这两种格式并没有哪一个比另一个更强,只是各自适用的领域不用。(LCTT 译注:W3C 是[互联网联盟](https://www.w3.org/),制定了各种 Web 相关的标准,如 HTML、CSS 等。Douglas Crockford 除了制定了 JSON 格式,还致力于改进 JavaScript,开发了 JavaScript 相关工具 [JSLint](http://jslint.com/) 和 [JSMin](http://www.crockford.com/javascript/jsmin.html)) + +### XML 的优点 + +XML 与 JSON 相比有很多优点。二者间最大的不同在于 XML 可以通过在标签中添加属性这一简单的方法来存储元数据metadata。而使用 JSON 时需要创建一个对象,把元数据当作对象的成员来存储。虽然二者都能达到存储元数据的目的,但在这一情况下 XML 往往是更好的选择,因为 JSON 的表达形式会让客户端程序开发人员误以为要将数据转换成一个对象。举个例子,如果你的 C++ 程序需要使用 JSON 格式发送一个附带元数据的整型数据,需要创建一个对象,用对象中的一个名称/值对name/value pair来记录整型数据的值,再为每一个附带的属性添加一个名称/值对。接收到这个 JSON 的程序在读取后很可能把它当成一个对象,可事实并不是这样。虽然这是使用 JSON 传递元数据的一种变通方法,但他违背了 JSON 的核心理念:“JSON 的结构与常规的程序语言中的结构相对应,而无需修改。JSON's structures look like conventional programming language structures. No restructuring is necessary.”[^2] + +虽然稍后我会说这也是 XML 的一个缺点,但 XML 中对命名冲突、前缀prefix的处理机制赋予了它 JSON 所不具备的能力。程序员们可以通过前缀来把统一名称给予两个不同的实体。[^1] 当不同的实体在客户端中使用的名称相同时,这一特性会非常有用。 + +XML 的另一个优势在于大多数的浏览器可以把它以具有高可读性和强组织性的方式highly readable and organized way展现给用户。XML 的树形结构让它易于结构化,浏览器也让用户可以自行展开或折叠树中的元素,这简直就是调试的福音。 + +XML 对比 JSON 有一个很重要的优势就是它可以记录混合内容mixed content。例如在 XML 中处理包含结构化标记的字符串时,程序员们只要把带有标记的文本放在一个标签内就可以了。可因为 JSON 只包含数据,没有用于指明标签的简单方式,虽然可以使用处理元数据的解决方法,但这总有点滥用之嫌。 + +### JSON 的优点 + +JSON 自身也有很多优点。其中最显而易见的一点就是 JSON 比 XML 简洁得多。因为 XML 中需要打开和关闭标签,而 JSON 使用名称/值对表示数据,使用简单的 `{` 和 `}` 来标记对象,`[` 和 `]` 来标记数组,`,` 来表示数据的分隔,`:` 表示名称和值的分隔。就算是使用 gzip 压缩,JSON 还是比 XML 要小,而且耗时更少。[^6] 正如 Sumaray 和 Makki 在实验中指出的那样,JSON 在很多方面都比 XML 更具优势,得出同样结果的还有 Nurseitov、Paulson、Reynolds 和 Izurieta。首先,由于 JSON 文件天生的简洁性,与包含相同信息的 XML 相比,JSON 总是更小,这意味着更快的传输和处理速度。第二,在不考虑大小的情况下,两组研究 [^3] [^4] 表明使用 JSON 执行序列化和反序列化的速度显著优于使用 XML。第三,后续的研究指出 JSON 的处理在 CPU 资源的使用上也优于 XML。研究人员发现 JSON 在总体上使用的资源更少,其中更多的 CPU 资源消耗在用户空间,系统空间消耗的 CPU 资源较少。这一实验是在 RedHat 的设备上进行的,RedHat 表示更倾向于在用户空间使用 CPU 资源。[^3a] 不出意外,Sumaray 和 Makki 在研究里还说明了在移动设备上 JSON 的性能也优于 XML。[^4a] 这是有道理的,因为 JSON 消耗的资源更少,而移动设备的性能也更弱。 + +JSON 的另一个优点在于其对对象和数组的表述和宿主语言host language中的数据结构相对应,例如对象object记录record结构体struct字典dictionary哈希表hash table键值列表keyed list还有数组array向量vector列表list,以及对象组成的数组等等。[^2a] 虽然 XML 里也能表达这些数据结构,也只需调用一个函数就能完成解析,而往往需要更多的代码才能正确的完成 XML 的序列化和反序列化处理。而且 XML 对于人类来说不如 JSON 那么直观,XML 标准缺乏对象、数组的标签的明确定义。当结构化的标记可以替代嵌套的标签时,JSON 的优势极为突出。JSON 中的花括号和中括号则明确表示了数据的结构,当然这一优势也包含前文中的问题,在表示元数据时 JSON 不如 XML 准确。 + +虽然 XML 支持命名空间namespace前缀prefix,但这不代表 JSON 没有处理命名冲突的能力。比起 XML 的前缀,它处理命名冲突的方式更简洁,在程序中的处理也更自然。在 JSON 里,每一个对象都在它自己的命名空间中,因此不同对象内的元素名称可以随意重复。在大多数编程语言中,不同的对象中的成员可以包含相同的名字,所以 JSON 根据对象进行名称区分的规则在处理时更加自然。 + +也许 JSON 比 XML 更优的部分是因为 JSON 是 JavaScript 的子集,所以在 JavaScript 代码中对它的解析或封装都非常的自然。虽然这看起来对 JavaScript 程序非常有用,而其他程序则不能直接从中获益,可实际上这一问题已经被很好的解决了。现在 JSON 的网站的列表上展示了 64 种不同语言的 175 个工具,它们都实现了处理 JSON 所需的功能。虽然我不能评价大多数工具的质量,但它们的存在明确了开发者社区拥抱 JSON 这一现象,而且它们切实简化了在不同平台使用 JSON 的难度。 + +### 二者的动机 + +简单地说,XML 的目标是标记文档。这和 JSON 的目标想去甚远,所以只要用得到 XML 的地方就尽管用。它使用树形的结构和包含语义的文本来表达混合内容以实现这一目标。在 XML 中可以表示数据的结构,但这并不是它的长处。 + +JSON 的目标是用于数据交换的一种结构化表示。它直接使用对象、数组、数字、字符串、布尔值这些元素来达成这一目标。这完全不同于文档标记语言。正如上面说的那样,JSON 没有原生支持混合内容mixed content的记录。 + +### 软件 + +这些主流的开放 API 仅提供 XML:亚马逊产品广告 APIAmazon Product Advertising API。 + +这些主流 API 仅提供 JSON:脸书图 APIFacebook Graph API谷歌地图 APIGoogle Maps API推特 APITwitter API、AccuWeather API、Pinterest API、Reddit API、Foursquare API。 + +这些主流 API 同时提供 XML 和 JSON:谷歌云存储Google Cloud Storage领英 APILinkedin API、Flickr API。 + +根据可编程网络Programmable Web [^9] 的数据,最流行的 10 个 API 中只有一个是仅提供 XML 且不支持 JSON 的。其他的要么同时支持 XML 和 JSON,要么只支持 JSON。这表明了大多数应用开发者都更倾向于使用支持 JSON 的 API,原因大概是 JSON 更快的处理速度与良好口碑,加之与 XML 相比更加轻量。此外,大多数 API 只是传递数据而非文档,所以 JSON 更加合适。例如 Facebook 的重点在于用户的交流与帖子,谷歌地图则主要处理坐标和地图信息,AccuWeather 就只传递天气数据。总之,虽然不能说天气 API 在使用时究竟是 JSON 用的多还是 XML 用的多,但是趋势明确偏向了 JSON。[^10] [^11] + +这些主流的桌面软件仍然只是用 XML:Microsoft Word、Apache OpenOffice、LibraOffice。 + +因为这些软件需要考虑引用、格式、存储等等,所以比起 JSON,XML 优势更大。另外,这三款程序都支持混合内容,而 JSON 在这一点上做得并不如 XML 好。举例说明,当用户使用 Microsoft Word 编辑一篇论文时,用户需要使用不同的文字字形、文字大小、文字颜色、页边距、段落格式等,而 XML 结构化的组织形式与标签属性生来就是为了表达这些信息的。 + +这些主流的数据库支持 XML:IBM DB2、Microsoft SQL Server、Oracle Database、PostgresSQL、BaseX、eXistDB、MarkLogic、MySQL。 + +这些是支持 JSON 的主流数据库:MongoDB、CouchDB、eXistDB、Elastisearch、BaseX、MarkLogic、OrientDB、Oracle Database、PostgreSQL、Riak。 + +在很长一段时间里,SQL 和关系型数据库统治着整个数据库市场。像甲骨文Oracle微软Microsoft这样的软件巨头都提供这类数据库,然而近几年 NoSQL 数据库正逐步受到开发者的青睐。也许是正巧碰上了 JSON 的普及,大多数 NoSQL 数据库都支持 JSON,像 MongoDB、CouchDB 和 Riak 这样的数据库甚至使用 JSON 来存储数据。这些数据库有两个重要的特性是它们适用于现代网站:一是它们与关系型数据库相比更容易扩展more scalable;二是它们设计的目标就是 web 运行所需的核心组件。[^10a] 由于 JSON 更加轻量,又是 JavaScript 的子集,所以很适合 NoSQL 数据库,并且让这两个品质更容易实现。此外,许多旧的关系型数据库增加了 JSON 支持,例如 Oracle Database 和 PostgreSQL。由于 XML 与 JSON 间的转换比较麻烦,所以大多数开发者会直接在他们的应用里使用 JSON,因此开发数据库的公司才有支持 JSON 的理由。(LCTT 译注:NoSQL 是对不同于传统的关系数据库的数据库管理系统的统称。[参考来源](https://zh.wikipedia.org/wiki/NoSQL)) [^7] + +### 未来 + +对互联网的种种变革中,最让人期待的便是物联网Internet of Things(IoT)。这会给互联网带来大量计算机之外的设备,例如手表、温度计、电视、冰箱等等。这一势头的发展良好,预期在不久的将来迎来爆发式的增长。据估计,到 2020 年时会有 260 亿 到 2000 亿的物联网设备被接入互联网。[^12] [^13] 几乎所有的物联网设备都是小型设备,因此性能比笔记本或台式电脑要弱很多,而且大多数都是嵌入式系统。因此,当它们需要与互联网上的系统交换数据时,更轻量、更快速的 JSON 自然比 XML 更受青睐。[^10b] 受益于 JSON 在 web 上的快速普及,与 XML 相比,这些新的物联网设备更有可能从使用 JSON 中受益。这是一个典型的梅特卡夫定律的例子,无论是 XML 还是 JSON,抑或是什么其他全新的格式,现存的设备和新的设备都会从支持最广泛使用的格式中受益。 + +Node.js 是一款服务器端的 JavaScript 框架,随着她的诞生与快速成长,与 MongoDB 等 NoSQL 数据库一起,让全栈使用 JavaScript 开发成为可能。这些都预示着 JSON 光明的未来,这些软件的出现让 JSON 运用在全栈开发的每一个环节成为可能,这将使应用更加轻量,响应更快。这也是任何应用的追求之一,所以,全栈使用 JavaScript 的趋势在不久的未来都不会消退。[^10c] + +此外,另一个应用开发的趋势是从 SOAP 转向 REST。[^11a] [^15] [^16] XML 和 JSON 都可以用于 REST,可 SOAP 只能使用 XML。 + +从这些趋势中可以推断,JSON 的发展将统一 Web 的信息交换格式,XML 的使用率将继续降低。虽然不应该把 JSON 吹过头了,因为 XML 在 Web 中的使用依旧很广,而且它还是 SOAP 的唯一选择,可考虑到 SOAP 到 REST 的迁移,NoSQL 数据库和全栈 JavaScript 的兴起,JSON 卓越的性能,我相信 JSON 很快就会在 Web 开发中超过 XML。至于其他领域,XML 比 JSON 更好的情况并不多。 + + +### 角注 + +[^1]: [XML Tutorial](http://www.w3schools.com/xml/default.asp) +[^2]: [Introducing JSON](http://www.json.org/) +[^2a]: [Introducing JSON](http://www.json.org/) +[^3]: [Comparison of JSON and XML Data Interchange Formats: A Case Study](http://www.cs.montana.edu/izurieta/pubs/caine2009.pdf) +[^3a]: [Comparison of JSON and XML Data Interchange Formats: A Case Study](http://www.cs.montana.edu/izurieta/pubs/caine2009.pdf) +[^4]: [A comparison of data serialization formats for optimal efficiency on a mobile platform](http://dl.acm.org/citation.cfm?id=2184810) +[^4a]: [A comparison of data serialization formats for optimal efficiency on a mobile platform](http://dl.acm.org/citation.cfm?id=2184810) +[^5]: [JSON vs. XML: The Debate](http://ajaxian.com/archives/json-vs-xml-the-debate) +[^6]: [JSON vs. XML: Some hard numbers about verbosity](http://www.codeproject.com/Articles/604720/JSON-vs-XML-Some-hard-numbers-about-verbosity) +[^7]: [How JSON sparked NoSQL -- and will return to the RDBMS fold](http://www.infoworld.com/article/2608293/nosql/how-json-sparked-nosql----and-will-return-to-the-rdbms-fold.html) +[^8]: [Did You Say "JSON Support" in Oracle 12.1.0.2?](https://blogs.oracle.com/OTN-DBA-DEV-Watercooler/entry/did_you_say_json_support) +[^9]: [Most Popular APIs: At Least One Will Surprise You](http://www.programmableweb.com/news/most-popular-apis-least-one-will-surprise-you/2014/01/23) +[^10]: [Why JSON will continue to push XML out of the picture](https://www.centurylinkcloud.com/blog/post/why-json-will-continue-to-push-xml-out-of-the-picture/) +[^10a]: [Why JSON will continue to push XML out of the picture](https://www.centurylinkcloud.com/blog/post/why-json-will-continue-to-push-xml-out-of-the-picture/) +[^10b]: [Why JSON will continue to push XML out of the picture](https://www.centurylinkcloud.com/blog/post/why-json-will-continue-to-push-xml-out-of-the-picture/) +[^10c]: [Why JSON will continue to push XML out of the picture](https://www.centurylinkcloud.com/blog/post/why-json-will-continue-to-push-xml-out-of-the-picture/) +[^11]: [Thousands of APIs Paint a Bright Future for the Web](http://www.webmonkey.com/2011/03/thousand-of-apis-paint-a-bright-future-for-the-web/) +[^11a]: [Thousands of APIs Paint a Bright Future for the Web](http://www.webmonkey.com/2011/03/thousand-of-apis-paint-a-bright-future-for-the-web/) +[^12]: [A Simple Explanation Of 'The Internet Of Things’](http://www.forbes.com/sites/jacobmorgan/2014/05/13/simple-explanation-internet-things-that-anyone-can-understand/) +[^13]: [Proofpoint Uncovers Internet of Things (IoT) Cyberattack](http://www.proofpoint.com/about-us/press-releases/01162014.php) +[^14]: [The Internet of Things: New Threats Emerge in a Connected World](http://www.symantec.com/connect/blogs/internet-things-new-threats-emerge-connected-world) +[^15]: [3,000 Web APIs: Trends From A Quickly Growing Directory](http://www.programmableweb.com/news/3000-web-apis-trends-quickly-growing-directory/2011/03/08) +[^16]: [How REST replaced SOAP on the Web: What it means to you](http://www.infoq.com/articles/rest-soap) + + +-------------------------------------------------------------------------------- + +via: https://www.cs.tufts.edu/comp/150IDS/final_papers/tstras01.1/FinalReport/FinalReport.html + +作者:[TOM STRASSNER][a] +选题:[lujun9972][b] +译者:[wwhio](https://github.com/wwhio) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: tomstrassner@gmail.com +[b]: https://github.com/lujun9972 +[1]: https://tools.ietf.org/html/rfc7159 +[2]: https://tools.ietf.org/html/rfc4825 diff --git a/published/201902/20150616 Computer Laboratory - Raspberry Pi- Lesson 6 Screen01.md b/published/201902/20150616 Computer Laboratory - Raspberry Pi- Lesson 6 Screen01.md new file mode 100644 index 0000000000..2419ac4f32 --- /dev/null +++ b/published/201902/20150616 Computer Laboratory - Raspberry Pi- Lesson 6 Screen01.md @@ -0,0 +1,451 @@ +[#]: collector: (lujun9972) +[#]: translator: (qhwdw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10540-1.html) +[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 6 Screen01) +[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen01.html) +[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) + +计算机实验室之树莓派:课程 6 屏幕01 +====== + +欢迎来到屏幕系列课程。在本系列中,你将学习在树莓派中如何使用汇编代码控制屏幕,从显示随机数据开始,接着学习显示一个固定的图像和显示文本,然后格式化数字为文本。假设你已经完成了 OK 系列课程的学习,所以在本系列中出现的有些知识将不再重复。 + +第一节的屏幕课程教你一些关于图形的基础理论,然后用这些理论在屏幕或电视上显示一个图案。 + +### 1、入门 + +预期你已经完成了 OK 系列的课程,以及那个系列课程中在 `gpio.s` 和 `systemTimer.s` 文件中调用的函数。如果你没有完成这些,或你喜欢完美的实现,可以去下载 `OK05.s` 解决方案。在这里也要使用 `main.s` 文件中从开始到包含 `mov sp,#0x8000` 的这一行之前的代码。请删除这一行以后的部分。 + +### 2、计算机图形 + +正如你所认识到的,从根本上来说,计算机是非常愚蠢的。它们只能执行有限数量的指令,仅仅能做一些数学,但是它们也能以某种方式来做很多很多的事情。而在这些事情中,我们目前想知道的是,计算机是如何将一个图像显示到屏幕上的。我们如何将这个问题转换成二进制?答案相当简单;我们为每个颜色设计一些编码方法,然后我们为在屏幕上的每个像素保存一个编码。一个像素就是你的屏幕上的一个非常小的点。如果你离屏幕足够近,你或许能够辨别出你的屏幕上的单个像素,能够看到每个图像都是由这些像素组成的。 + +> 将颜色表示为数字有几种方法。在这里我们专注于 RGB 方法,但 HSL 也是很常用的另一种方法。 + +随着计算机时代的进步,人们希望显示越来越复杂的图形,于是发明了图形卡的概念。图形卡是你的计算机上用来在屏幕上专门绘制图像的第二个处理器。它的任务就是将像素值信息转换成显示在屏幕上的亮度级别。在现代计算机中,图形卡已经能够做更多更复杂的事情了,比如绘制三维图形。但是在本系列教程中,我们只专注于图形卡的基本使用;从内存中取得像素然后把它显示到屏幕上。 + +不管使用哪种方法,现在马上出现的一个问题就是我们使用的颜色编码。这里有几种选择,每个产生不同的输出质量。为了完整起见,我在这里只是简单概述它们。 + +| 名字 | 唯一颜色数量 | 描述 | 示例 | +| ----------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------- | +| 单色 | 2 | 每个像素使用 1 位去保存,其中 1 表示白色,0 表示黑色。 | ![Monochrome image of a bird][1] | +| 灰度 | 256 | 每个像素使用 1 个字节去保存,使用 255 表示白色,0 表示黑色,介于这两个值之间的所有值表示这两个颜色的一个线性组合。 | ![Geryscale image of a bird][2] | +| 8 色 | 8 | 每个像素使用 3 位去保存,第一位表示红色通道,第二位表示绿色通道,第三位表示蓝色通道。 | ![8 colour image of a bird][3] | +| 低色值 | 256 | 每个像素使用 8 位去保存,前三位表示红色通道的强度,接下来的三位表示绿色通道的强度,最后两位表示蓝色通道的强度。 | ![Low colour image of a bird][4] | +| 高色值 | 65,536 | 每个像素使用 16 位去保存,前五位表示红色通道的强度,接下来的六位表示绿色通道的强度,最后的五位表示蓝色通道的强度。 | ![High colour image of a bird][5] | +| 真彩色 | 16,777,216 | 每个像素使用 24 位去保存,前八位表示红色通道,第二个八位表示绿色通道,最后八位表示蓝色通道。 | ![True colour image of a bird][6] | +| RGBA32 | 16,777,216 带 256 级透明度 | 每个像素使用 32 位去保存,前八位表示红色通道,第二个八位表示绿色通道,第三个八位表示蓝色通道。只有一个图像绘制在另一个图像的上方时才考虑使用透明通道,值为 0 时表示下面图像的颜色,值为 255 时表示上面这个图像的颜色,介于这两个值之间的所有值表示这两个图像颜色的混合。 || + +> 不过这里的一些图像只用了很少的颜色,因为它们使用了一个叫空间抖动的技术。这允许它们以很少的颜色仍然能表示出非常好的图像。许多早期的操作系统就使用了这种技术。 + +在本教程中,我们将从使用高色值开始。这样你就可以看到图像的构成,它的形成过程清楚,图像质量好,又不像真彩色那样占用太多的空间。也就是说,显示一个比较小的 800x600 像素的图像,它只需要小于 1 MiB 的空间。它另外的好处是它的大小是 2 次幂的倍数,相比真彩色这将极大地降低了获取信息的复杂度。 + +树莓派和它的图形处理器有一种特殊而奇怪的关系。在树莓派上,首先运行的事实上是图形处理器,它负责启动主处理器。这是很不常见的。最终它不会有太大的差别,但在许多交互中,它经常给人感觉主处理器是次要的,而图形处理器才是主要的。在树莓派上这两者之间依靠一个叫 “邮箱” 的东西来通讯。它们中的每一个都可以为对方投放邮件,这个邮件将在未来的某个时刻被对方收集并处理。我们将使用这个邮箱去向图形处理器请求一个地址。这个地址将是一个我们在屏幕上写入像素颜色信息的位置,我们称为帧缓冲,图形卡将定期检查这个位置,然后更新屏幕上相应的像素。 + +> 保存帧缓冲frame buffer给计算机带来了很大的内存负担。基于这种原因,早期计算机经常作弊,比如,保存一屏幕文本,在每次单独刷新时,它只绘制刷新了的字母。 + +### 3、编写邮差程序 + +接下来我们做的第一件事情就是编写一个“邮差”程序。它有两个方法:`MailboxRead`,从寄存器 `r0` 中的邮箱通道读取一个消息。而 `MailboxWrite`,将寄存器 `r0` 中的头 28 位的值写到寄存器 `r1` 中的邮箱通道。树莓派有 7 个与图形处理器进行通讯的邮箱通道。但仅第一个对我们有用,因为它用于协调帧缓冲。 + +> 消息传递是组件间通讯时使用的常见方法。一些操作系统在程序之间使用虚拟消息进行通讯。 + +下列的表和示意图描述了邮箱的操作。 + +表 3.1 邮箱地址 + +| 地址 | 大小 / 字节 | 名字 | 描述 | 读 / 写 | +| ---- | ---------- | ------------ | -------------------- | ------ | +| 2000B880 | 4 | Read | 接收邮件 | R | +| 2000B890 | 4 | Poll | 不检索接收 | R | +| 2000B894 | 4 | Sender |发送者信息 | R | +| 2000B898 | 4 | Status | 信息 | R | +| 2000B89C | 4 | Configuration | 设置 | RW | +| 2000B8A0 | 4 | Write | 发送邮件 | W | + +为了给指定的邮箱发送一个消息: + + 1. 发送者等待,直到 `Status` 字段的头一位为 0。 + 2. 发送者写入到 `Write`,低 4 位是要发送到的邮箱,高 28 位是要写入的消息。 + +为了读取一个消息: + + 1. 接收者等待,直到 `Status` 字段的第 30 位为 0。 + 2. 接收者读取消息。 + 3. 接收者确认消息来自正确的邮箱,否则再次重试。 + +如果你觉得有信心,你现在已经有足够的信息去写出我们所需的两个方法。如果没有信心,请继续往下看。 + +与以前一样,我建议你实现的第一个方法是获取邮箱区域的地址。 + +```assembly +.globl GetMailboxBase +GetMailboxBase: +ldr r0,=0x2000B880 +mov pc,lr +``` + +发送程序相对简单一些,因此我们将首先去实现它。随着你的方法越来越复杂,你需要提前去规划它们。规划它们的一个好的方式是写出一个简单步骤列表,详细地列出你需要做的事情,像下面一样。 + + 1. 我们的输入将要写什么(`r0`),以及写到什么邮箱(`r1`)。我们必须验证邮箱的真实性,以及它的低 4 位的值是否为 0。不要忘了验证输入。 + 2. 使用 `GetMailboxBase` 去检索地址。 + 3. 读取 `Status` 字段。 + 4. 检查头一位是否为 0。如果不是,回到第 3 步。 + 5. 将写入的值和邮箱通道组合到一起。 + 6. 写入到 `Write`。 + +我们来按顺序写出它们中的每一步。 + +1. 这将实现我们验证 `r0` 和 `r1` 的目的。`tst` 是通过计算两个操作数的逻辑与来比较两个操作数的函数,然后将结果与 0 进行比较。在本案例中,它将检查在寄存器 `r0` 中的输入的低 4 位是否为全 0。 + + ```assembly +.globl MailboxWrite +MailboxWrite: +tst r0,#0b1111 +movne pc,lr +cmp r1,#15 +movhi pc,lr +``` + + > `tst reg,#val` 计算寄存器 `reg` 和 `#val` 的逻辑与,然后将计算结果与 0 进行比较。 + +2. 这段代码确保我们不会覆盖我们的值,或链接寄存器,然后调用 `GetMailboxBase`。 + + ```assembly +channel .req r1 +value .req r2 +mov value,r0 +push {lr} +bl GetMailboxBase +mailbox .req r0 +``` + +3. 这段代码加载当前状态。 + + ```assembly +wait1$: +status .req r3 +ldr status,[mailbox,#0x18] +``` + +4. 这段代码检查状态字段的头一位是否为 0,如果不为 0,循环回到第 3 步。 + + ```assembly +tst status,#0x80000000 +.unreq status +bne wait1$ +``` + +5. 这段代码将通道和值组合到一起。 + + ```assembly +add value,channel +.unreq channel +``` + +6. 这段代码保存结果到写入字段。 + + ```assembly +str value,[mailbox,#0x20] +.unreq value +.unreq mailbox +pop {pc} +``` + +`MailboxRead` 的代码和它非常类似。 + + 1. 我们的输入将从哪个邮箱读取(`r0`)。我们必须要验证邮箱的真实性。不要忘了验证输入。 + 2. 使用 `GetMailboxBase` 去检索地址。 + 3. 读取 `Status` 字段。 + 4. 检查第 30 位是否为 0。如果不为 0,返回到第 3 步。 + 5. 读取 `Read` 字段。 + 6. 检查邮箱是否是我们所要的,如果不是返回到第 3 步。 + 7. 返回结果。 + +我们来按顺序写出它们中的每一步。 + +1. 这一段代码来验证 `r0` 中的值。 + + ```assembly +.globl MailboxRead +MailboxRead: +cmp r0,#15 +movhi pc,lr +``` + +2. 这段代码确保我们不会覆盖掉我们的值,或链接寄存器,然后调用 `GetMailboxBase`。 + + ```assembly +channel .req r1 +mov channel,r0 +push {lr} +bl GetMailboxBase +mailbox .req r0 +``` + +3. 这段代码加载当前状态。 + + ```assembly +rightmail$: +wait2$: +status .req r2 +ldr status,[mailbox,#0x18] +``` + +4. 这段代码检查状态字段第 30 位是否为 0,如果不为 0,返回到第 3 步。 + + ```assembly +tst status,#0x40000000 +.unreq status +bne wait2$ +``` + +5. 这段代码从邮箱中读取下一条消息。 + + ```assembly +mail .req r2 +ldr mail,[mailbox,#0] +``` + +6. 这段代码检查我们正在读取的邮箱通道是否为提供给我们的通道。如果不是,返回到第 3 步。 + + ```assembly +inchan .req r3 +and inchan,mail,#0b1111 +teq inchan,channel +.unreq inchan +bne rightmail$ +.unreq mailbox +.unreq channel +``` + +7. 这段代码将答案(邮件的前 28 位)移动到寄存器 `r0` 中。 + + ```assembly +and r0,mail,#0xfffffff0 +.unreq mail +pop {pc} +``` + +### 4、我心爱的图形处理器 + +通过我们新的邮差程序,我们现在已经能够向图形卡上发送消息了。我们应该发送些什么呢?这对我来说可能是个很难找到答案的问题,因为它不是任何线上手册能够找到答案的问题。尽管如此,通过查找有关树莓派的 GNU/Linux,我们能够找出我们需要发送的内容。 + +消息很简单。我们描述我们想要的帧缓冲区,而图形卡要么接受我们的请求,给我们返回一个 0,然后用我们写的一个小的调查问卷来填充屏幕;要么发送一个非 0 值,我们知道那表示很遗憾(出错了)。不幸的是,我并不知道它返回的其它数字是什么,也不知道它意味着什么,但我们知道仅当它返回一个 0,才表示一切顺利。幸运的是,对于合理的输入,它总是返回一个 0,因此我们不用过于担心。 + +> 由于在树莓派的内存是在图形处理器和主处理器之间共享的,我们能够只发送可以找到我们信息的位置即可。这就是 DMA,许多复杂的设备使用这种技术去加速访问时间。 + +为简单起见,我们将提前设计好我们的请求,并将它保存到 `framebuffer.s` 文件的 `.data` 节中,它的代码如下: + +```assembly +.section .data +.align 4 +.globl FrameBufferInfo +FrameBufferInfo: +.int 1024 /* #0 物理宽度 */ +.int 768 /* #4 物理高度 */ +.int 1024 /* #8 虚拟宽度 */ +.int 768 /* #12 虚拟高度 */ +.int 0 /* #16 GPU - 间距 */ +.int 16 /* #20 位深 */ +.int 0 /* #24 X */ +.int 0 /* #28 Y */ +.int 0 /* #32 GPU - 指针 */ +.int 0 /* #36 GPU - 大小 */ +``` + +这就是我们发送到图形处理器的消息格式。第一对两个关键字描述了物理宽度和高度。第二对关键字描述了虚拟宽度和高度。帧缓冲的宽度和高度就是虚拟的宽度和高度,而 GPU 按需要伸缩帧缓冲去填充物理屏幕。如果 GPU 接受我们的请求,接下来的关键字将是 GPU 去填充的参数。它们是帧缓冲每行的字节数,在本案例中它是 `2 × 1024 = 2048`。下一个关键字是每个像素分配的位数。使用了一个 16 作为值意味着图形处理器使用了我们上面所描述的高色值模式。值为 24 是真彩色,而值为 32 则是 RGBA32。接下来的两个关键字是 x 和 y 偏移量,它表示当将帧缓冲复制到屏幕时,从屏幕左上角跳过的像素数目。最后两个关键字是由图形处理器填写的,第一个表示指向帧缓冲的实际指针,第二个是用字节数表示的帧缓冲大小。 + +在这里我非常谨慎地使用了一个 `.align 4` 指令。正如前面所讨论的,这样确保了下一行地址的低 4 位是 0。所以,我们可以确保将被放到那个地址上的帧缓冲(`FrameBufferInfo`)是可以发送到图形处理器上的,因为我们的邮箱仅发送低 4 位全为 0 的值。 + +> 当设备使用 DMA 时,对齐约束变得非常重要。GPU 预期该消息都是 16 字节对齐的。 + +到目前为止,我们已经有了待发送的消息,我们可以写代码去发送它了。通讯将按如下的步骤进行: + + 1. 写入 `FrameBufferInfo + 0x40000000` 的地址到邮箱 1。 + 2. 从邮箱 1 上读取结果。如果它是非 0 值,意味着我们没有请求一个正确的帧缓冲。 + 3. 复制我们的图像到指针,这时图像将出现在屏幕上! + +我在步骤 1 中说了一些以前没有提到的事情。我们在发送之前,在帧缓冲地址上加了 `0x40000000`。这其实是一个给 GPU 的特殊信号,它告诉 GPU 应该如何写到结构上。如果我们只是发送地址,GPU 将写到它的回复上,这样不能保证我们可以通过刷新缓存看到它。缓存是处理器使用的值在它们被发送到存储之前保存在内存中的片段。通过加上 `0x40000000`,我们告诉 GPU 不要将写入到它的缓存中,这样将确保我们能够看到变化。 + +因为在那里发生很多事情,因此最好将它实现为一个函数,而不是将它以代码的方式写入到 `main.s` 中。我们将要写一个函数 `InitialiseFrameBuffer`,由它来完成所有协调和返回指向到上面提到的帧缓冲数据的指针。为方便起见,我们还将帧缓冲的宽度、高度、位深作为这个方法的输入,这样就很容易地修改 `main.s` 而不必知道协调的细节了。 + +再一次,来写下我们要做的详细步骤。如果你有信心,可以略过这一步直接尝试去写函数。 + + 1. 验证我们的输入。 + 2. 写输入到帧缓冲。 + 3. 发送 `frame buffer + 0x40000000` 的地址到邮箱。 + 4. 从邮箱中接收回复。 + 5. 如果回复是非 0 值,方法失败。我们应该返回 0 去表示失败。 + 6. 返回指向帧缓冲信息的指针。 + +现在,我们开始写更多的方法。以下是上面其中一个实现。 + +1. 这段代码检查宽度和高度是小于或等于 4096,位深小于或等于 32。这里再次使用了条件运行的技巧。相信自己这是可行的。 + + ```assembly +.section .text +.globl InitialiseFrameBuffer +InitialiseFrameBuffer: +width .req r0 +height .req r1 +bitDepth .req r2 +cmp width,#4096 +cmpls height,#4096 +cmpls bitDepth,#32 +result .req r0 +movhi result,#0 +movhi pc,lr +``` + +2. 这段代码写入到我们上面定义的帧缓冲结构中。我也趁机将链接寄存器推入到栈上。 + + ```assembly +fbInfoAddr .req r3 +push {lr} +ldr fbInfoAddr,=FrameBufferInfo +str width,[fbInfoAddr,#0] +str height,[fbInfoAddr,#4] +str width,[fbInfoAddr,#8] +str height,[fbInfoAddr,#12] +str bitDepth,[fbInfoAddr,#20] +.unreq width +.unreq height +.unreq bitDepth +``` + +3. `MailboxWrite` 方法的输入是写入到寄存器 `r0` 中的值,并将通道写入到寄存器 `r1` 中。 + + ```assembly +mov r0,fbInfoAddr +add r0,#0x40000000 +mov r1,#1 +bl MailboxWrite +``` + +4. `MailboxRead` 方法的输入是写入到寄存器 `r0` 中的通道,而输出是值读数。 + + ```assembly +mov r0,#1 +bl MailboxRead +``` + +5. 这段代码检查 `MailboxRead` 方法的结果是否为 0,如果不为 0,则返回 0。 + + ```assembly +teq result,#0 +movne result,#0 +popne {pc} +``` + +6. 这是代码结束,并返回帧缓冲信息地址。 + + ```assembly +mov result,fbInfoAddr +pop {pc} +.unreq result +.unreq fbInfoAddr +``` + +### 5、在一帧中一行之内的一个像素 + +到目前为止,我们已经创建了与图形处理器通讯的方法。现在它已经能够给我们返回一个指向到帧缓冲的指针去绘制图形了。我们现在来绘制一个图形。 + +第一示例中,我们将在屏幕上绘制连续的颜色。它看起来并不漂亮,但至少能说明它在工作。我们如何才能在帧缓冲中设置每个像素为一个连续的数字,并且要持续不断地这样做。 + +将下列代码复制到 `main.s` 文件中,并放置在 `mov sp,#0x8000` 行之后。 + +```assembly +mov r0,#1024 +mov r1,#768 +mov r2,#16 +bl InitialiseFrameBuffer +``` + +这段代码使用了我们的 `InitialiseFrameBuffer` 方法,简单地创建了一个宽 1024、高 768、位深为 16 的帧缓冲区。在这里,如果你愿意可以尝试使用不同的值,只要整个代码中都一样就可以。如果图形处理器没有给我们创建好一个帧缓冲区,这个方法将返回 0,我们最好检查一下返回值,如果出现返回值为 0 的情况,我们打开 OK LED 灯。 + +```assembly +teq r0,#0 +bne noError$ + +mov r0,#16 +mov r1,#1 +bl SetGpioFunction +mov r0,#16 +mov r1,#0 +bl SetGpio + +error$: +b error$ + +noError$: +fbInfoAddr .req r4 +mov fbInfoAddr,r0 +``` + +现在,我们已经有了帧缓冲信息的地址,我们需要取得帧缓冲信息的指针,并开始绘制屏幕。我们使用两个循环来做实现,一个走行,一个走列。事实上,树莓派中的大多数应用程序中,图片都是以从左到右然后从上到下的顺序来保存的,因此我们也按这个顺序来写循环。 + +```assembly +render$: + + fbAddr .req r3 + ldr fbAddr,[fbInfoAddr,#32] + + colour .req r0 + y .req r1 + mov y,#768 + drawRow$: + + x .req r2 + mov x,#1024 + drawPixel$: + + strh colour,[fbAddr] + add fbAddr,#2 + sub x,#1 + teq x,#0 + bne drawPixel$ + + sub y,#1 + add colour,#1 + teq y,#0 + bne drawRow$ + + b render$ + +.unreq fbAddr +.unreq fbInfoAddr +``` + +> `strh reg,[dest]` 将寄存器中的低位半个字保存到给定的 `dest` 地址上。 + +这是一个很长的代码块,它嵌套了三层循环。为了帮你理清头绪,我们将循环进行缩进处理,这就有点类似于高级编程语言,而汇编器会忽略掉这些用于缩进的 `tab` 字符。我们看到,在这里它从帧缓冲信息结构中加载了帧缓冲的地址,然后基于每行来循环,接着是每行上的每个像素。在每个像素上,我们使用一个 `strh`(保存半个字)命令去保存当前颜色,然后增加地址继续写入。每行绘制完成后,我们增加绘制的颜色号。在整个屏幕绘制完成后,我们跳转到开始位置。 + +### 6、看到曙光 + +现在,你已经准备好在树莓派上测试这些代码了。你应该会看到一个渐变图案。注意:在第一个消息被发送到邮箱之前,树莓派在它的四个角上一直显示一个渐变图案。如果它不能正常工作,请查看我们的排错页面。 + +如果一切正常,恭喜你!你现在可以控制屏幕了!你可以随意修改这些代码去绘制你想到的任意图案。你还可以做更精彩的渐变图案,可以直接计算每个像素值,因为每个像素包含了一个 Y 坐标和 X 坐标。在下一个 [课程 7:Screen 02][7] 中,我们将学习一个更常用的绘制任务:行。 + +-------------------------------------------------------------------------------- + +via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen01.html + +作者:[Alex Chadwick][a] +选题:[lujun9972][b] +译者:[qhwdw](https://github.com/qhwdw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.cl.cam.ac.uk +[b]: https://github.com/lujun9972 +[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour1bImage.png +[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour8gImage.png +[3]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour3bImage.png +[4]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour8bImage.png +[5]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour16bImage.png +[6]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour24bImage.png +[7]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen02.html diff --git a/published/201902/20150616 Computer Laboratory - Raspberry Pi- Lesson 7 Screen02.md b/published/201902/20150616 Computer Laboratory - Raspberry Pi- Lesson 7 Screen02.md new file mode 100644 index 0000000000..f5ba5f5237 --- /dev/null +++ b/published/201902/20150616 Computer Laboratory - Raspberry Pi- Lesson 7 Screen02.md @@ -0,0 +1,437 @@ +[#]: collector: (lujun9972) +[#]: translator: (qhwdw) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10551-1.html) +[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 7 Screen02) +[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen02.html) +[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) + +计算机实验室之树莓派:课程 7 屏幕02 +====== + +屏幕02 课程在屏幕01 的基础上构建,它教你如何绘制线和一个生成伪随机数的小特性。假设你已经有了 [课程 6:屏幕01][1] 的操作系统代码,我们将以它为基础来构建。 + +### 1、点 + +现在,我们的屏幕已经正常工作了,现在开始去创建一个更实用的图像,是水到渠成的事。如果我们能够绘制出更实用的图形那就更好了。如果我们能够在屏幕上的两点之间绘制一条线,那我们就能够组合这些线绘制出更复杂的图形了。 + +我们将尝试用汇编代码去实现它,但在开始时,我们确实需要使用一些其它的函数去辅助。我们需要一个这样的函数,我将调用 `SetPixel` 去修改指定像素的颜色,而在寄存器 `r0` 和 `r1` 中提供输入。如果我们写出的代码可以在任意内存中而不仅仅是屏幕上绘制图形,这将在以后非常有用,因此,我们首先需要一些控制真实绘制位置的方法。我认为实现上述目标的最好方法是,能够有一个内存片段用于保存将要绘制的图形。我应该最终得到的是一个存储地址,它通常指向到自上次的帧缓存结构上。我们将一直在我们的代码中使用这个绘制方法。这样,如果我们想在我们的操作系统的另一部分绘制一个不同的图像,我们就可以生成一个不同结构的地址值,而使用的是完全相同的代码。为简单起见,我们将使用另一个数据片段去控制我们绘制的颜色。 + +> 为了绘制出更复杂的图形,一些方法使用一个着色函数而不是一个颜色去绘制。每个点都能够调用着色函数来确定在那里用什么颜色去绘制。 + +复制下列代码到一个名为 `drawing.s` 的新文件中。 + +```assembly +.section .data +.align 1 +foreColour: +.hword 0xFFFF + +.align 2 +graphicsAddress: +.int 0 + +.section .text +.globl SetForeColour +SetForeColour: +cmp r0,#0x10000 +movhs pc,lr +ldr r1,=foreColour +strh r0,[r1] +mov pc,lr + +.globl SetGraphicsAddress +SetGraphicsAddress: +ldr r1,=graphicsAddress +str r0,[r1] +mov pc,lr +``` + +这段代码就是我上面所说的一对函数以及它们的数据。我们将在 `main.s` 中使用它们,在绘制图像之前去控制在何处绘制什么内容。 + +我们的下一个任务是去实现一个 `SetPixel` 方法。它需要带两个参数,像素的 x 和 y 轴,并且它应该要使用 `graphicsAddress` 和 `foreColour`,我们只定义精确控制在哪里绘制什么图像即可。如果你认为你能立即实现这些,那么去动手实现吧,如果不能,按照我们提供的步骤,按示例去实现它。 + +> 构建一个通用方法,比如 `SetPixel`,我们将在它之上构建另一个方法是一个很好的想法。但我们必须要确保这个方法很快,因为我们要经常使用它。 + + 1. 加载 `graphicsAddress`。 + 2. 检查像素的 x 和 y 轴是否小于宽度和高度。 + 3. 计算要写入的像素地址(提示:`frameBufferAddress +(x + y * 宽度)* 像素大小`) + 4. 加载 `foreColour`。 + 5. 保存到地址。 + +上述步骤实现如下: + +1、加载 `graphicsAddress`。 + +```assembly +.globl DrawPixel +DrawPixel: +px .req r0 +py .req r1 +addr .req r2 +ldr addr,=graphicsAddress +ldr addr,[addr] +``` + +2、记住,宽度和高度被各自保存在帧缓冲偏移量的 0 和 4 处。如有必要可以参考 `frameBuffer.s`。 + +```assembly +height .req r3 +ldr height,[addr,#4] +sub height,#1 +cmp py,height +movhi pc,lr +.unreq height + +width .req r3 +ldr width,[addr,#0] +sub width,#1 +cmp px,width +movhi pc,lr +``` + +3、确实,这段代码是专用于高色值帧缓存的,因为我使用一个逻辑左移操作去计算地址。你可能希望去编写一个不需要专用的高色值帧缓冲的函数版本,记得去更新 `SetForeColour` 的代码。它实现起来可能更复杂一些。 + +```assembly +ldr addr,[addr,#32] +add width,#1 +mla px,py,width,px +.unreq width +.unreq py +add addr, px,lsl #1 +.unreq px +``` + +> `mla dst,reg1,reg2,reg3` 将寄存器 `reg1` 和 `reg2` 中的值相乘,然后将结果与寄存器 `reg3` 中的值相加,并将结果的低 32 位保存到 `dst` 中。 + +4、这是专用于高色值的。 + +```assembly +fore .req r3 +ldr fore,=foreColour +ldrh fore,[fore] +``` + +5、这是专用于高色值的。 + +```assembly +strh fore,[addr] +.unreq fore +.unreq addr +mov pc,lr +``` + +### 2、线 + +问题是,线的绘制并不是你所想像的那么简单。到目前为止,你必须认识到,编写一个操作系统时,几乎所有的事情都必须我们自己去做,绘制线条也不例外。我建议你们花点时间想想如何在任意两点之间绘制一条线。 + +我估计大多数的策略可能是去计算线的梯度,并沿着它来绘制。这看上去似乎很完美,但它事实上是个很糟糕的主意。主要问题是它涉及到除法,我们知道在汇编中,做除法很不容易,并且还要始终记录小数,这也很困难。事实上,在这里,有一个叫布鲁塞姆的算法,它非常适合汇编代码,因为它只使用加法、减法和位移运算。 + +> 在我们日常编程中,我们对像除法这样的运算通常懒得去优化。但是操作系统不同,它必须高效,因此我们要始终专注于如何让事情做的尽可能更好。 + +. + +> 我们从定义一个简单的直线绘制算法开始,代码如下: +> +> ```matlab +> /* 我们希望从 (x0,y0) 到 (x1,y1) 去绘制一条线,只使用一个函数 setPixel(x,y),它的功能是在给定的 (x,y) 上绘制一个点。 */ +> +> if x1 > x0 then +> +> set deltax to x1 - x0 +> set stepx to +1 +> +> otherwise +> +> set deltax to x0 - x1 +> set stepx to -1 +> +> end if +> +> if y1 > y0 then +> +> set deltay to y1 - y0 +> set stepy to +1 +> +> otherwise +> +> set deltay to y0 - y1 +> set stepy to -1 +> +> end if +> +> if deltax > deltay then +> +> set error to 0 +> until x0 = x1 + stepx +> +> setPixel(x0, y0) +> set error to error + deltax ÷ deltay +> if error ≥ 0.5 then +> +> set y0 to y0 + stepy +> set error to error - 1 +> +> end if +> set x0 to x0 + stepx +> +> repeat +> +> otherwise +> +> end if +> ``` +> +> 这个算法用来表示你可能想像到的那些东西。变量 `error` 用来记录你离实线的距离。沿着 x 轴每走一步,这个 `error` 的值都会增加,而沿着 y 轴每走一步,这个 `error` 值就会减 1 个单位。`error` 是用于测量距离 y 轴的距离。 +> +> 虽然这个算法是有效的,但它存在一个重要的问题,很明显,我们使用了小数去保存 `error`,并且也使用了除法。所以,一个立即要做的优化将是去改变 `error` 的单位。这里并不需要用特定的单位去保存它,只要我们每次使用它时都按相同数量去伸缩即可。所以,我们可以重写这个算法,通过在所有涉及 `error` 的等式上都简单地乘以 `deltay`,从面让它简化。下面只展示主要的循环: +> +> ```matlab +> set error to 0 × deltay +> until x0 = x1 + stepx +> +> setPixel(x0, y0) +> set error to error + deltax ÷ deltay × deltay +> if error ≥ 0.5 × deltay then +> +> set y0 to y0 + stepy +> set error to error - 1 × deltay +> +> end if +> set x0 to x0 + stepx +> +> repeat +> ``` +> +> 它将简化为: +> +> ```matlab +> cset error to 0 +> until x0 = x1 + stepx +> +> setPixel(x0, y0) +> set error to error + deltax +> if error × 2 ≥ deltay then +> +> set y0 to y0 + stepy +> set error to error - deltay +> +> end if +> set x0 to x0 + stepx +> +> repeat +> ``` +> +> 突然,我们有了一个更好的算法。现在,我们看一下如何完全去除所需要的除法运算。最好保留唯一的被 2 相乘的乘法运算,我们知道它可以通过左移 1 位来实现!现在,这是非常接近布鲁塞姆算法的,但还可以进一步优化它。现在,我们有一个 `if` 语句,它将导致产生两个代码块,其中一个用于 x 差异较大的线,另一个用于 y 差异较大的线。对于这两种类型的线,如果审查代码能够将它们转换成一个单语句,还是很值得去做的。 +> +> 困难之处在于,在第一种情况下,`error` 是与 y 一起变化,而第二种情况下 `error` 是与 x 一起变化。解决方案是在一个变量中同时记录它们,使用负的 `error` 去表示 x 中的一个 `error`,而用正的 `error` 表示它是 y 中的。 +> +> ```matlab +> set error to deltax - deltay +> until x0 = x1 + stepx or y0 = y1 + stepy +> +> setPixel(x0, y0) +> if error × 2 > -deltay then +> +> set x0 to x0 + stepx +> set error to error - deltay +> +> end if +> if error × 2 < deltax then +> +> set y0 to y0 + stepy +> set error to error + deltax +> +> end if +> +> repeat +> ``` +> +> 你可能需要一些时间来搞明白它。在每一步中,我们都认为它正确地在 x 和 y 中移动。我们通过检查来做到这一点,如果我们在 x 或 y 轴上移动,`error` 的数量会变低,那么我们就继续这样移动。 +> + +. + +> 布鲁塞姆算法是在 1962 年由 Jack Elton Bresenham 开发,当时他 24 岁,正在攻读博士学位。 + +用于画线的布鲁塞姆算法可以通过以下的伪代码来描述。以下伪代码是文本,它只是看起来有点像是计算机指令而已,但它却能让程序员实实在在地理解算法,而不是为机器可读。 + +```matlab +/* 我们希望从 (x0,y0) 到 (x1,y1) 去绘制一条线,只使用一个函数 setPixel(x,y),它的功能是在给定的 (x,y) 上绘制一个点。 */ + +if x1 > x0 then + set deltax to x1 - x0 + set stepx to +1 +otherwise + set deltax to x0 - x1 + set stepx to -1 +end if + +set error to deltax - deltay +until x0 = x1 + stepx or y0 = y1 + stepy + setPixel(x0, y0) + if error × 2 ≥ -deltay then + set x0 to x0 + stepx + set error to error - deltay + end if + if error × 2 ≤ deltax then + set y0 to y0 + stepy + set error to error + deltax + end if +repeat +``` + +与我们目前所使用的编号列表不同,这个算法的表示方式更常用。看看你能否自己实现它。我在下面提供了我的实现作为参考。 + +```assembly +.globl DrawLine +DrawLine: +push {r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} +x0 .req r9 +x1 .req r10 +y0 .req r11 +y1 .req r12 + +mov x0,r0 +mov x1,r2 +mov y0,r1 +mov y1,r3 + +dx .req r4 +dyn .req r5 /* 注意,我们只使用 -deltay,因此为了速度,我保存它的负值。(因此命名为 dyn)*/ +sx .req r6 +sy .req r7 +err .req r8 + +cmp x0,x1 +subgt dx,x0,x1 +movgt sx,#-1 +suble dx,x1,x0 +movle sx,#1 + +cmp y0,y1 +subgt dyn,y1,y0 +movgt sy,#-1 +suble dyn,y0,y1 +movle sy,#1 + +add err,dx,dyn +add x1,sx +add y1,sy + +pixelLoop$: + + teq x0,x1 + teqne y0,y1 + popeq {r4,r5,r6,r7,r8,r9,r10,r11,r12,pc} + + mov r0,x0 + mov r1,y0 + bl DrawPixel + + cmp dyn, err,lsl #1 + addle err,dyn + addle x0,sx + + cmp dx, err,lsl #1 + addge err,dx + addge y0,sy + + b pixelLoop$ + +.unreq x0 +.unreq x1 +.unreq y0 +.unreq y1 +.unreq dx +.unreq dyn +.unreq sx +.unreq sy +.unreq err +``` + +### 3、随机性 + +到目前,我们可以绘制线条了。虽然我们可以使用它来绘制图片及诸如此类的东西(你可以随意去做!),我想应该借此机会引入计算机中随机性的概念。我将这样去做,选择一对随机的坐标,然后从上一对坐标用渐变色绘制一条线到那个点。我这样做纯粹是认为它看起来很漂亮。 + +那么,总结一下,我们如何才能产生随机数呢?不幸的是,我们并没有产生随机数的一些设备(这种设备很罕见)。因此只能利用我们目前所学过的操作,需要我们以某种方式来发明“随机数”。你很快就会意识到这是不可能的。各种操作总是给出定义好的结果,用相同的寄存器运行相同的指令序列总是给出相同的答案。而我们要做的是推导出一个伪随机序列。这意味着数字在外人看来是随机的,但实际上它是完全确定的。因此,我们需要一个生成随机数的公式。其中有人可能会想到很垃圾的数学运算,比如:4x2! / 64,而事实上它产生的是一个低质量的随机数。在这个示例中,如果 x 是 0,那么答案将是 0。看起来很愚蠢,我们需要非常谨慎地选择一个能够产生高质量随机数的方程式。 + +> 硬件随机数生成器很少用在安全中,因为可预测的随机数序列可能影响某些加密的安全。 + +我将要教给你的方法叫“二次同余发生器”。这是一个非常好的选择,因为它能够在 5 个指令中实现,并且能够产生一个从 0 到 232-1 之间的看似很随机的数字序列。 + +不幸的是,对为什么使用如此少的指令能够产生如此长的序列的原因的研究,已经远超出了本课程的教学范围。但我还是鼓励有兴趣的人去研究它。它的全部核心所在就是下面的二次方程,其中 `xn` 是产生的第 `n` 个随机数。 + +> 这类讨论经常寻求一个问题,那就是我们所谓的随机数到底是什么?通常从统计学的角度来说的随机性是:一组没有明显模式或属性能够概括它的数的序列。 + +``` +x_(n+1) = ax_(n)^2 + bx_(n) + c mod 2^32 +``` + +这个方程受到以下的限制: + + 1. a 是偶数 + 2. b = a + 1 mod 4 + 3. c 是奇数 + +如果你之前没有见到过 `mod` 运算,我来解释一下,它的意思是被它后面的数相除之后的余数。比如 `b = a + 1 mod 4` 的意思是 `b` 是 `a + 1` 除以 `4` 的余数,因此,如果 `a` 是 12,那么 `b` 将是 `1`,因为 `a + 1` 是 13,而 `13` 除以 4 的结果是 3 余 1。 + +复制下列代码到名为 `random.s` 的文件中。 + +```assembly +.globl Random +Random: +xnm .req r0 +a .req r1 + +mov a,#0xef00 +mul a,xnm +mul a,xnm +add a,xnm +.unreq xnm +add r0,a,#73 + +.unreq a +mov pc,lr +``` + +这是随机函数的一个实现,使用一个在寄存器 `r0` 中最后生成的值作为输入,而接下来的数字则是输出。在我的案例中,我使用 a = EF0016,b = 1, c = 73。这个选择是随意的,但是需要满足上述的限制。你可以使用任何数字代替它们,只要符合上述的规则就行。 + +### 4、Pi-casso + +OK,现在我们有了所有我们需要的函数,我们来试用一下它们。获取帧缓冲信息的地址之后,按如下的要求修改 `main`: + + 1. 使用包含了帧缓冲信息地址的寄存器 `r0` 调用 `SetGraphicsAddress`。 + 2. 设置四个寄存器为 0。一个将是最后的随机数,一个将是颜色,一个将是最后的 x 坐标,而最后一个将是最后的 y 坐标。 + 3. 调用 `random` 去产生下一个 x 坐标,使用最后一个随机数作为输入。 + 4. 调用 `random` 再次去生成下一个 y 坐标,使用你生成的 x 坐标作为输入。 + 5. 更新最后的随机数为 y 坐标。 + 6. 使用 `colour` 值调用 `SetForeColour`,接着增加 `colour` 值。如果它大于 FFFF~16~,确保它返回为 0。 + 7. 我们生成的 x 和 y 坐标将介于 0 到 FFFFFFFF16。通过将它们逻辑右移 22 位,将它们转换为介于 0 到 102310 之间的数。 + 8. 检查 y 坐标是否在屏幕上。验证 y 坐标是否介于 0 到 76710 之间。如果不在这个区间,返回到第 3 步。 + 9. 从最后的 x 坐标和 y 坐标到当前的 x 坐标和 y 坐标之间绘制一条线。 + 10. 更新最后的 x 和 y 坐标去为当前的坐标。 + 11. 返回到第 3 步。 + +一如既往,你可以在下载页面上找到这个解决方案。 + +在你完成之后,在树莓派上做测试。你应该会看到一系列颜色递增的随机线条以非常快的速度出现在屏幕上。它一直持续下去。如果你的代码不能正常工作,请查看我们的排错页面。 + +如果一切顺利,恭喜你!我们现在已经学习了有意义的图形和随机数。我鼓励你去使用它绘制线条,因为它能够用于渲染你想要的任何东西,你可以去探索更复杂的图案了。它们中的大多数都可以由线条生成,但这需要更好的策略?如果你愿意写一个画线程序,尝试使用 `SetPixel` 函数。如果不是去设置像素值而是一点点地增加它,会发生什么情况?你可以用它产生什么样的图案?在下一节课 [课程 8:屏幕 03][2] 中,我们将学习绘制文本的宝贵技能。 + +-------------------------------------------------------------------------------- + +via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen02.html + +作者:[Alex Chadwick][a] +选题:[lujun9972][b] +译者:[qhwdw](https://github.com/qhwdw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.cl.cam.ac.uk +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10540-1.html +[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen03.html diff --git a/published/201902/20160922 Annoying Experiences Every Linux Gamer Never Wanted.md b/published/201902/20160922 Annoying Experiences Every Linux Gamer Never Wanted.md new file mode 100644 index 0000000000..895ab25f2f --- /dev/null +++ b/published/201902/20160922 Annoying Experiences Every Linux Gamer Never Wanted.md @@ -0,0 +1,156 @@ +每个 Linux 游戏玩家都绝不想要的恼人体验 +=================== + +[![Linux 平台上玩家的问题](https://itsfoss.com/wp-content/uploads/2016/09/Linux-Gaming-Problems.jpg)][10] + +(LCTT 译注:本文原文发表于 2016 年,可能有些信息已经过时。) + +[在 Linux 平台上玩游戏][12] 并不是什么新鲜事,现在甚至有专门的 [Linux 游戏发行版][13],但是这不意味着在 Linux 上打游戏的体验和在 Windows 上一样顺畅。 + +为了确保我们和 Windows 用户同样地享受游戏乐趣,哪些问题是我们应该考虑的呢? + +[Wine][14]、[PlayOnLinux][15] 和其它类似软件不总是能够让我们玩所有流行的 Windows 游戏。在这篇文章里,我想讨论一下为了拥有最好的 Linux 游戏体验所必须处理好的若干因素。 + +### #1 SteamOS 是开源平台,但 Steam for Linux 并不是 + +正如 [StemOS 主页][16]所说, 即便 SteamOS 是一个开源平台,但 Steam for Linux 仍然是专有的软件。如果 Steam for Linux 也开源,那么它从开源社区得到的支持将会是巨大的。既然它不是,那么 [Ascension 计划的诞生自然是不可避免的][17]: + +- [Destination: Project Ascension • UI Design Mockups Reveal](https://youtu.be/07UiS5iAknA) + +Ascension 是一个开源的游戏启动器,旨在能够启动从任何平台购买、下载的游戏。这些游戏可以是 Steam 平台的、[Origin 游戏][18]平台的、Uplay 平台的,以及直接从游戏开发者主页下载的,或者来自 DVD、CD-ROM 的。 + +Ascension 计划的开端是这样:[某个观点的分享][19]激发了一场与游戏社区读者之间有趣的讨论,在这场讨论中读者们纷纷发表了自己的观点并给出建议。 + +### #2 与 Windows 平台的性能比较 + +在 Linux 平台上运行 Windows 游戏并不总是一件轻松的任务。但是得益于一个叫做 [CSMT][20](多线程命令流)的特性,尽管离 Windows 级别的性能还有相当长的路要走,PlayOnLinux 现在依旧可以更好地解决这些性能方面的问题。 + +Linux 对游戏的原生支持在过去发行的游戏中从未尽如人意。 + +去年,有报道说 SteamOS 比 Windows 在游戏方面的表现要[差得多][21]。古墓丽影去年在 SteamOS 及 Steam for Linux 上发行,然而其基准测试的结果与 Windows 上的性能无法抗衡。 + +- [Destination: Tomb Raider benchmark video comparison, Linux vs Windows 10](https://youtu.be/nkWUBRacBNE) + +这明显是因为游戏是基于 [DirectX][23] 而不是 [OpenGL][24] 开发的缘故。 + +古墓丽影是[第一个使用 TressFX 的游戏][25]。下面这个视频包涵了 TressFX 的比较: + +- [Destination: Tomb Raider Benchmark - Ubuntu 15.10 vs Windows 8.1 + Ubuntu 16.04 vs Windows 10](https://youtu.be/-IeY5ZS-LlA) + +下面是另一个有趣的比较,它显示出使用 Wine + CSMT 带来的游戏性能比 Steam 上原生的 Linux 版游戏带来的游戏性能要好得多!这就是开源的力量! + +- [Destination: [LinuxBenchmark] Tomb Raider Linux vs Wine comparison](https://youtu.be/sCJkC6oJ08A) + +以防 FPS 损失,TressFX 已经被关闭。 + +以下是另一个有关在 Linux 上最新发布的 “[Life is Strange][27]” 在 Linux 与 Windows 上的比较: + +- [Destination: Life is Strange on radeonsi (Linux nine_csmt vs Windows 10)](https://youtu.be/Vlflu-pIgIY) + +[Steam for Linux][28] 开始在这个新游戏上展示出比 Windows 更好的游戏性能,这是一件好事。 + +在发布任何 Linux 版的游戏前,开发者都应该考虑优化游戏,特别是基于 DirectX 并需要进行 OpenGL 转制的游戏。我们十分希望 Linux 上的[杀出重围:人类分裂][29]Deus Ex: Mankind Divided 在正式发行时能有一个好的基准测试结果。由于它是基于 DirectX 的游戏,我们希望它能良好地移植到 Linux 上。[该游戏执行总监说过这样的话][30]。 + +### #3 专有的 NVIDIA 驱动 + +相比于 [NVIDIA][32],[AMD 对于开源的支持][31]绝对是值得称赞的。尽管 [AMD][33] 因其更好的开源驱动在 Linux 上的驱动支持挺不错,而 NVIDIA 显卡用户由于开源版本的 NVIDIA 显卡驱动 “Nouveau” 有限的能力,仍不得不用专有的 NVIDIA 驱动。 + +曾经,Linus Torvalds 大神也分享过他关于“来自 NVIDIA 的 Linux 支持完全不可接受”的想法。 + +- [Destination: Linus Torvalds Publicly Attacks NVidia for lack of Linux & Android Support](https://youtu.be/O0r6Pr_mdio) + +你可以在这里观看完整的[谈话][35],尽管 NVIDIA 回应 [承诺更好的 Linux 平台支持][36],但其开源显卡驱动仍如之前一样毫无起色。 + +### #4 需要 Linux 平台上的 Uplay 和 Origin 的 DRM 支持 + +- [Destination: Uplay #1 Rayman Origins em Linux - como instalar - ago 2016](https://youtu.be/rc96NFwyxWU) + +以上的视频描述了如何在 Linux 上安装 [Uplay][37] DRM。视频上传者还建议说并不推荐使用 Wine 作为 Linux 上的主要的应用和游戏支持软件。相反,更鼓励使用原生的应用。 + +以下视频是一个关于如何在 Linux 上安装 [Origin][38] DRM 的教程。 + +- [Destination: Install EA Origin in Ubuntu with PlayOnLinux (Updated)](https://youtu.be/ga2lNM72-Kw) + +数字版权管理(DRM)软件给游戏运行又加了一层阻碍,使得在 Linux 上良好运行 Windows 游戏这一本就充满挑战性的任务更有难度。因此除了使游戏能够运行之外,W.I.N.E 不得不同时负责运行像 Uplay 或 Origin 之类的 DRM 软件。如果能像 Steam 一样,Linux 也能够有自己原生版本的 Uplay 和 Origin 那就好了。 + +### #5 DirectX 11 对于 Linux 的支持 + +尽管我们在 Linux 平台上有可以运行 Windows 应用的工具,每个游戏为了能在 Linux 上运行都带有自己的配套调整需求。尽管去年在 Code Weavers 有一篇关于 [DirectX 11 对于 Linux 的支持][40] 的公告,在 Linux 上畅玩新发大作仍是长路漫漫。 + +现在你可以[从 Codweavers 购买 Crossover][41] 以获得可得到的最佳 DirectX 11 支持。这个在 Arch Linux 论坛上的[频道][42]清楚展现了将这个梦想成真需要多少的努力。以下是一个 [Reddit 频道][44] 上的有趣 [发现][43]。这个发现提到了[来自 Codeweavers 的 DirectX 11 补丁][45],现在看来这无疑是好消息。 + +### #6 不是全部的 Steam 游戏都可跑在 Linux 上 + +随着 Linux 游戏玩家一次次错过主要游戏的发行,这是需要考虑的一个重点,因为大部分主要游戏都在 Windows 上发行。这是[如何在 Linux 上安装 Windows 版的 Steam 的教程][46]。 + +### #7 游戏发行商对 OpenGL 更好的支持 + +目前开发者和发行商主要着眼于用 DirectX 而不是 OpenGL 来开发游戏。现在随着 Steam 正式登录 Linux,开发者应该同样考虑在 OpenGL 下开发。 + +[Direct3D][47] 仅仅是为 Windows 平台而打造。而 OpenGL API 拥有开放性标准,并且它不仅能在 Windows 上同样也能在其它各种各样的平台上实现。 + +尽管是一篇很老的文章,但[这个很有价值的资源][48]分享了许多有关 OpenGL 和 DirectX 现状的很有想法的信息。其所提出的观点确实十分明智,基于按时间排序的事件也能给予读者启迪。 + +在 Linux 平台上发布大作的发行商绝不应该忽视一个事实:在 OpenGL 下直接开发游戏要比从 DirectX 移植到 OpenGL 合算得多。如果必须进行平台转制,移植必须被仔细优化并谨慎研究。发布游戏可能会有延迟,但这绝对值得。 + +有更多的烦恼要分享?务必在评论区让我们知道。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/linux-gaming-problems/ + +作者:[Avimanyu Bandyopadhyay][a] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://itsfoss.com/author/avimanyu/ +[1]:https://itsfoss.com/author/avimanyu/ +[2]:https://itsfoss.com/linux-gaming-problems/#comments +[3]:https://www.facebook.com/share.php?u=https%3A%2F%2Fitsfoss.com%2Flinux-gaming-problems%2F%3Futm_source%3Dfacebook%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[4]:https://twitter.com/share?original_referer=/&text=Annoying+Experiences+Every+Linux+Gamer+Never+Wanted%21&url=https://itsfoss.com/linux-gaming-problems/%3Futm_source%3Dtwitter%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare&via=itsfoss2 +[5]:https://plus.google.com/share?url=https%3A%2F%2Fitsfoss.com%2Flinux-gaming-problems%2F%3Futm_source%3DgooglePlus%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[6]:https://www.linkedin.com/cws/share?url=https%3A%2F%2Fitsfoss.com%2Flinux-gaming-problems%2F%3Futm_source%3DlinkedIn%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare +[7]:http://www.stumbleupon.com/submit?url=https://itsfoss.com/linux-gaming-problems/&title=Annoying+Experiences+Every+Linux+Gamer+Never+Wanted%21 +[8]:https://www.reddit.com/submit?url=https://itsfoss.com/linux-gaming-problems/&title=Annoying+Experiences+Every+Linux+Gamer+Never+Wanted%21 +[9]:https://itsfoss.com/wp-content/uploads/2016/09/Linux-Gaming-Problems.jpg +[10]:https://itsfoss.com/wp-content/uploads/2016/09/Linux-Gaming-Problems.jpg +[11]:http://pinterest.com/pin/create/bookmarklet/?media=https://itsfoss.com/wp-content/uploads/2016/09/Linux-Gaming-Problems.jpg&url=https://itsfoss.com/linux-gaming-problems/&is_video=false&description=Linux%20gamer%27s%20problem +[12]:https://itsfoss.com/linux-gaming-guide/ +[13]:https://itsfoss.com/linux-gaming-distributions/ +[14]:https://itsfoss.com/use-windows-applications-linux/ +[15]:https://www.playonlinux.com/en/ +[16]:http://store.steampowered.com/steamos/ +[17]:http://www.ibtimes.co.uk/reddit-users-want-replace-steam-open-source-game-launcher-project-ascension-1498999 +[18]:https://www.origin.com/ +[19]:https://www.reddit.com/r/pcmasterrace/comments/33xcvm/we_hate_valves_monopoly_over_pc_gaming_why/ +[20]:https://github.com/wine-compholio/wine-staging/wiki/CSMT +[21]:http://arstechnica.com/gaming/2015/11/ars-benchmarks-show-significant-performance-hit-for-steamos-gaming/ +[22]:https://www.gamingonlinux.com/articles/tomb-raider-benchmark-video-comparison-linux-vs-windows-10.7138 +[23]:https://en.wikipedia.org/wiki/DirectX +[24]:https://en.wikipedia.org/wiki/OpenGL +[25]:https://www.gamingonlinux.com/articles/tomb-raider-released-for-linux-video-thoughts-port-report-included-the-first-linux-game-to-use-tresfx.7124 +[26]:https://itsfoss.com/osu-new-linux/ +[27]:http://lifeisstrange.com/ +[28]:https://itsfoss.com/install-steam-ubuntu-linux/ +[29]:https://itsfoss.com/deus-ex-mankind-divided-linux/ +[30]:http://wccftech.com/deus-ex-mankind-divided-director-console-ports-on-pc-is-disrespectful/ +[31]:http://developer.amd.com/tools-and-sdks/open-source/ +[32]:http://nvidia.com/ +[33]:http://amd.com/ +[34]:http://www.makeuseof.com/tag/open-source-amd-graphics-now-awesome-heres-get/ +[35]:https://youtu.be/MShbP3OpASA +[36]:https://itsfoss.com/nvidia-optimus-support-linux/ +[37]:http://uplay.com/ +[38]:http://origin.com/ +[39]:https://itsfoss.com/linux-foundation-head-uses-macos/ +[40]:http://www.pcworld.com/article/2940470/hey-gamers-directx-11-is-coming-to-linux-thanks-to-codeweavers-and-wine.html +[41]:https://itsfoss.com/deal-run-windows-software-and-games-on-linux-with-crossover-15-66-off/ +[42]:https://bbs.archlinux.org/viewtopic.php?id=214771 +[43]:https://ghostbin.com/paste/sy3e2 +[44]:https://www.reddit.com/r/linux_gaming/comments/3ap3uu/directx_11_support_coming_to_codeweavers/ +[45]:https://www.codeweavers.com/about/blogs/caron/2015/12/10/directx-11-really-james-didnt-lie +[46]:https://itsfoss.com/linux-gaming-guide/ +[47]:https://en.wikipedia.org/wiki/Direct3D +[48]:http://blog.wolfire.com/2010/01/Why-you-should-use-OpenGL-and-not-DirectX diff --git a/published/201902/20171215 Top 5 Linux Music Players.md b/published/201902/20171215 Top 5 Linux Music Players.md new file mode 100644 index 0000000000..59ccc3a8b7 --- /dev/null +++ b/published/201902/20171215 Top 5 Linux Music Players.md @@ -0,0 +1,119 @@ +Linux 上最好的五款音乐播放器 +====== +> Jack Wallen 盘点他最爱的五款 Linux 音乐播放器。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/live-music.jpg?itok=Ejbo4rf7_) + +不管你做什么,你都有时会来一点背景音乐。不管你是开发、运维或是一个典型的电脑用户,享受美妙的音乐都可能是你在电脑上最想做的事情之一。同时随着即将到来的假期,你可能收到一些能让你买几首新歌的礼物卡。如果你所选的音乐是数字形式(我的恰好是唱片形式)而且你的平台是 Linux 的话,你会想要一个好的图形用户界面播放器来享受音乐。 + +幸运的是,Linux 不缺好的数字音乐播放器。事实上,Linux 上有不少播放器,大部分是开源并且可以免费获得的。让我们看看其中的几款,看哪个能满足你的需要。 + +### Clementine + +我想从我用来许多年的默认选项的播放器开始。[Clementine][1] 可能是最好的平衡了易用性与灵活性的播放器。Clementine 是新停摆的 [Amarok][2] 音乐播放器的复刻,但它不仅限于 Linux; Clementine 在 Mac OS 和 Windows 平台上也可以获得。它的一系列特性十分惊艳,包括: + +* 內建的均衡器 +* 可定制的界面(将现在的专辑封面显示成背景,见图一) +* 播放本地音乐或者从 Spotify、Last.fm 等播放音乐 +* 便于库导航的侧边栏 +* 內建的音频转码(转成 MP3、OGG、Flac 等) +* 通过 [安卓应用][3] 远程控制 +* 便利的搜索功能 +* 选项卡式播放列表 +* 简单创建常规和智能化的播放列表 +* 支持 CUE 文件 +* 支持标签 + +![Clementine][5] + +*图一:Clementine 界面可能有一点老派,但是它不可思议得灵活好用。* + +在所有我用过的音乐播放器中,Clementine 是目前为止功能最多也是最容易使用的。它同时也包含了你能在 Linux 音乐播放器中找到的最好的均衡器(有十个频带可以调)。尽管它的界面不够时髦,但它创建、操控播放列表的能力是无与伦比的。如果你的音乐集很大,同时你想完全操控你的音乐集的话,这就是你想要的播放器。 + +Clementine 可以在标准仓库中找到。它可以从你的发行版的软件中心或通过命令行来安装。 + +### Rhythmbox + +[Rhythmbox][7] 是 GNOME 桌面的默认播放器,但是它在其它桌面工作得也很好。Rhythmbox 的界面比 Clementine 的界面稍微时尚一点,它的设计遵循极简的理念。这并不意味着它缺乏特性,相反 Rhythmbox 提供无间隔回放、支持 Soundcloud、专辑封面显示、从 Last.fm 和 Libre.fm 导入音频、支持 Jamendo、播客订阅(从 [Apple iTunes][8])、从网页远程控制等特性。 + +在 Rhythmbox 中发现的一个很好的特性是支持插件,这使得你可以使用像 DAAP 音乐分享、FM 电台、封面查找、通知、ReplayGain、歌词等特性。 + +Rhythmbox 播放列表特性不像 Clementine 的那么强大,但是将你的音乐整理进任何形式的快速播放列表还是很简单的。尽管 Rhythmbox 的界面(图二)比 Clementine 要时髦一点,但是它不像 Clementine 那样灵活。 + +![Rhythmbox][10] + +*图二:Rhythmbox 界面简单直接。* + +### VLC Media Player + +对于部分人来说,[VLC][11] 在视频播放方面是无懈可击的。然而 VLC 不仅限于视频播放。事实上,VLC在播放音频文件方面做得也很好。对于 [KDE Neon][12] 用户来说,VLC 既是音乐也是视频的默认播放器。尽管 VLC 是 Linux 市场最好的视频播放器的之一(它是我的默认播放器),它在音频方面确实略有瑕疵 —— 缺少播放列表以及不能够连接到你网络中的远程仓库。但如果你是在寻找一种播放本地文件或者网络 mms/rtsp 的简单可靠的方式,VLC 是上佳之选。VLC 包括一个均衡器(图三)、一个压缩器以及一个空间音响。它同样也能够从捕捉到的设备录音。 + +![VLC][14] + +*图三:运转中的 VLC 均衡器。* + +### Audacious + +如果你在寻找一个轻量级的音乐播放器,Audacious 完美地满足要求。这个音乐播放器相当的专一,但是它包括了一个均衡器和一小部分能够改善许多音频的声效(比如回声、消除默音、调节速度和音调、去除人声等,见图四)。 + +![Audacious][16] + +*图四:Audacious 均衡器和插件。* + +Audacious 也包括了一个十分简便的闹铃功能。它允许你设置一个能在用户选定的时间点和持续的时间段内播放选定乐段的闹铃。 + +### Spotify + +我必须承认,我每天都用 Spotify。我是一个 Spotify 的订阅者并用它去发现、购买新的音乐 —— 这意味着我在不停地探索发现。幸运的是,Spotify 有一个我能按照 [Spotify官方 Linux 平台安装指导][17] 轻松安装的桌面客户端。在桌面客户端与 [安卓应用][18] 间无缝转换对我来说也大有帮助,这样我就永远不会错过我喜欢的音乐了。 + +![Spotify][16] + +*图五:Linux 上的 Spotify 官方客户端。* + +Spotify 界面十分易于使用,事实上它完胜网页端的播放器。不要在 Linux 上装 [Spotify 网页播放器][21] 因为桌面客户端在创建管理你的播放列表方面简便得多。如果你是 Spotify 重度用户,甚至没必要用其他桌面应用的內建流传输客户端支持 —— 一旦你用过 Spotify 桌面客户端,其它应用就根本没可比性。 + +### 选择在你 + +其它选择也是有的(查看你的桌面软件中心),但这五款客户端(在我看来)是最好的了。对我来说,Clementine 和 Spotify 的组合拳就已经让我美好得唱赞歌了。尝试它们看看哪个能更好地满足你的需要。 + +### 额外奖品 + +虽然这篇文章翻译于国外作者,但作为给中国的 Linux 用户看的文章,如果在一篇分享音乐播放器的文章中**不提及**网易云音乐,那一定会被猛烈吐槽(事实上,我们曾经被吐槽过好多次了,哈哈)。 + +网易云音乐是我见过的最好的音乐播放器之一,不只是在 Linux 上,它甚至还支持包括 Windows、Mac、 iOS、安卓等在内的 8 个操作系统平台。当前的 Linux 版本是 1.1.0 版,支持 64 位的深度 Linux 15 和 Ubuntu 16.04 及之后的版本。下载地址和截图就不在这里安利了,大家想必自己能找到的。 + +通过 edX 和 Linux Foundation 上免费的 ["Introduction to Linux" ][22] 课程学习更多有关 Linux 的知识。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/learn/intro-to-linux/2017/12/top-5-linux-music-players + +作者:[JACK WALLEN][a] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.linux.com/users/jlwallen +[1]:https://www.clementine-player.org/ +[2]:https://en.wikipedia.org/wiki/Amarok_(software) +[3]:https://play.google.com/store/apps/details?id=de.qspool.clementineremote +[4]:https://www.linux.com/files/images/clementinejpg +[5]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/clementine.jpg?itok=_k13MtM3 (Clementine) +[6]:https://www.linux.com/licenses/category/used-permission +[7]:https://wiki.gnome.org/Apps/Rhythmbox +[8]:https://www.apple.com/itunes/ +[9]:https://www.linux.com/files/images/rhythmboxjpg +[10]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/rhythmbox.jpg?itok=GOjs9vTv (Rhythmbox) +[11]:https://www.videolan.org/vlc/index.html +[12]:https://neon.kde.org/ +[13]:https://www.linux.com/files/images/vlcjpg +[14]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/vlc.jpg?itok=hn7iKkmK (VLC) +[15]:https://www.linux.com/files/images/audaciousjpg +[16]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/audacious.jpg?itok=9YALPzOx (Audacious ) +[17]:https://www.spotify.com/us/download/linux/ +[18]:https://play.google.com/store/apps/details?id=com.spotify.music +[19]:https://www.linux.com/files/images/spotifyjpg +[20]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/spotify.jpg?itok=P3FLfcYt (Spotify) +[21]:https://open.spotify.com/browse/featured +[22]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/published/201902/20180112 8 KDE Plasma Tips and Tricks to Improve Your Productivity.md b/published/201902/20180112 8 KDE Plasma Tips and Tricks to Improve Your Productivity.md new file mode 100644 index 0000000000..eb5c8998cd --- /dev/null +++ b/published/201902/20180112 8 KDE Plasma Tips and Tricks to Improve Your Productivity.md @@ -0,0 +1,96 @@ +8 个在 KDE Plasma 桌面环境下提高生产力的技巧和提示 +====== + +![](https://www.maketecheasier.com/assets/uploads/2018/01/kde-plasma-desktop-featured.jpg) + +众所周知,KDE 的 Plasma 是 Linux 下最强大的桌面环境之一。它是高度可定制的,并且看起来也很棒。当你完成所有的配置工作后,你才能体会到它的所有特性。 + +你能够轻松地配置 Plasma 桌面并且使用它大量方便且节省时间的特性来加速你的工作,拥有一个能够帮助你而非阻碍你的桌面环境。 + +以下这些提示并没有特定顺序,因此你无需按次序阅读。你只需要挑出最适合你的工作流的那几个即可。 + +**相关阅读**:[10 个你应该尝试的最佳 KDE Plasma 应用][1] + +### 1、多媒体控制 + +这点不太算得上是一条提示,因为它是很容易被记在脑海里的。Plasma 可在各处进行多媒体控制。当你需要暂停、继续或跳过一首歌时,你不需要每次都打开你的媒体播放器。你能够通过将鼠标移至那个最小化窗口之上,甚至通过锁屏进行控制。当你需要切换歌曲或忘了暂停时,你也不必麻烦地登录再进行操作。 + +### 2、KRunner + +![KDE Plasma KRunner][2] + +KRunner 是 Plasma 桌面中一个经常受到赞誉的特性。大部分人习惯于穿过层层的应用启动菜单来找到想要启动的程序。当你使用 KRunner 时就不需要这么做。 + +为了使用 KRunner,确保你当前的活动焦点在桌面本身(点击桌面而不是窗口)。然后开始输入你想要启动的应用名称,KRunner 将会带着建议项从你的屏幕顶部自动下拉。在你寻找的匹配项上点击或敲击回车键。这比记住你每个应用所属的类别要更快。 + +### 3、跳转列表 + +![KDE Plasma 的跳转列表][3] + +跳转列表功能是最近才被添加进 Plasma 桌面的。它允许你在启动应用时直接跳转至特定的区域或特性部分。 + +因此如果你在菜单栏上有一个应用启动图标,你可以通过右键得到可跳转位置的列表。选择你想要跳转的位置,然后就可以“起飞”了。 + +### 4、KDE Connect + +![KDE Connect Android 客户端菜单][4] + +如果你有一个安卓手机,那么 [KDE Connect][5] 会为你提供大量帮助。它可以将你的手机连接至你的桌面,由此你可以在两台设备间无缝地共享。 + +通过 KDE Connect,你能够在你的桌面上实时地查看 [Android 设备通知][6]。它同时也让你能够从 Plasma 中收发文字信息,甚至不需要拿起你的手机。 + +KDE Connect 也允许你在手机和电脑间发送文件或共享网页。你可以轻松地从一个设备转移至另一设备,而无需烦恼或打乱思绪。 + +### 5、Plasma Vaults + +![KDE Plasma Vault][7] + +Plasma Vaults 是 Plasma 桌面的另一个新功能。它的 KDE 为加密文件和文件夹提供的简单解决方案。如果你不使用加密文件,此项功能不会为你节省时间。如果你使用,Vaults 是一个更简单的途径。 + +Plasma Vaults 允许你以无 root 权限的普通用户创建加密目录,并通过你的任务栏来管理它们。你能够快速地挂载或卸载目录,而无需外部程序或附加权限。 + +### 6、Pager 控件 + +![KDE Plasma Pager][8] + +配置你的桌面的 pager 控件。它允许你轻松地切换至另三个附加工作区,带来更大的屏幕空间。 + +将控件添加到你的菜单栏上,然后你就可以在多个工作区间滑动切换。每个工作区都与你原桌面的尺寸相同,因此你能够得到数倍于完整屏幕的空间。这就使你能够排布更多的窗口,而不必受到一堆混乱的最小化窗口的困扰。 + +### 7、创建一个 Dock + +![KDE Plasma Dock][9] + +Plasma 以其灵活性和可配置性出名,同时也是它的优势。如果你有常用的程序,你可以考虑将常用程序设置为 OS X 风格的 dock。你能够通过单击启动,而不必深入菜单或输入它们的名字。 + +### 8、为 Dolphin 添加文件树 + +![Plasma Dolphin 目录][10] + +通过目录树来浏览文件夹会更加简单。Dolphin 作为 Plasma 的默认文件管理器,具有在文件夹窗口一侧,以树的形式展示目录列表的内置功能。 + +为了启用目录树,点击“控制”标签,然后“配置 Dolphin”、“显示模式”、“详细”,最后选择“可展开文件夹”。 + +记住这些仅仅是提示,不要强迫自己做阻碍自己的事情。你可能讨厌在 Dolphin 中使用文件树,你也可能从不使用 Pager,这都没关系。当然也可能会有你喜欢但是此处没列举出来的功能。选择对你有用处的,也就是说,这些技巧中总有一些能帮助你度过日常工作中的艰难时刻。 + +-------------------------------------------------------------------------------- + +via: https://www.maketecheasier.com/kde-plasma-tips-tricks-improve-productivity/ + +作者:[Nick Congleton][a] +译者:[cycoe](https://github.com/cycoe) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.maketecheasier.com/author/nickcongleton/ +[1]:https://www.maketecheasier.com/10-best-kde-plasma-applications/ (10 of the Best KDE Plasma Applications You Should Try) +[2]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-krunner.jpg (KDE Plasma KRunner) +[3]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-jumplist.jpg (KDE Plasma Jump Lists) +[4]:https://www.maketecheasier.com/assets/uploads/2017/05/kde-connect-menu-e1494899929112.jpg (KDE Connect Menu Android) +[5]:https://www.maketecheasier.com/send-receive-sms-linux-kde-connect/ +[6]:https://www.maketecheasier.com/android-notifications-ubuntu-kde-connect/ +[7]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-vault.jpg (KDE Plasma Vault) +[8]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-pager.jpg (KDE Plasma Pager) +[9]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-dock.jpg (KDE Plasma Dock) +[10]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-dolphin.jpg (Plasma Dolphin Directory) diff --git a/published/201902/20180128 Get started with Org mode without Emacs.md b/published/201902/20180128 Get started with Org mode without Emacs.md new file mode 100644 index 0000000000..1da7853e74 --- /dev/null +++ b/published/201902/20180128 Get started with Org mode without Emacs.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10574-1.html) +[#]: subject: (Get started with Org mode without Emacs) +[#]: via: (https://opensource.com/article/19/1/productivity-tool-org-mode) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) + +开始使用 Org 模式吧,在没有 Emacs 的情况下 +====== + +> 不,你不需要 Emacs 也能用 Org,这是我开源工具系列的第 16 集,将会让你在 2019 年变得更加有生产率。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh) + +每到年初似乎总有这么一个疯狂的冲动来寻找提高生产率的方法。新年决心,正确地开始一年的冲动,以及“向前看”的态度都是这种冲动的表现。软件推荐通常都会选择闭源和专利软件。但这不是必须的。 + +这是我 2019 年改进生产率的 19 个新工具中的第 16 个。 + +### Org (非 Emacs) + +[Org 模式][1] (或者就称为 Org) 并不是新鲜货,但依然有许多人没有用过。他们很乐意试用一下以体验 Org 是如何改善生产率的。但最大的障碍来自于 Org 是与 Emacs 相关联的,而且很多人都认为两者缺一不可。并不是这样的!一旦你理解了其基础,Org 就可以与各种其他工具和编辑器一起使用。 + +![](https://opensource.com/sites/default/files/uploads/org-1.png) + +Org,本质上,是一个结构化的文本文件。它有标题、子标题,以及各种关键字,其他工具可以根据这些关键字将文件解析成日程表和代办列表。Org 文件可以被任何纯文本编辑器编辑(例如,[Vim][2]、[Atom][3] 或 [Visual Studio Code][4]),而且很多编辑器都有插件可以帮你创建和管理 Org 文件。 + +一个基础的 Org 文件看起来是这样的: + +``` +* Task List +** TODO Write Article for Day 16 - Org w/out emacs +   DEADLINE: <2019-01-25 12:00> +*** DONE Write sample org snippet for article +    - Include at least one TODO and one DONE item +    - Show notes +    - Show SCHEDULED and DEADLINE +*** TODO Take Screenshots +** Dentist Appointment +   SCHEDULED: <2019-01-31 13:30-14:30> +``` + +Org 是一种大纲格式,它使用 `*` 作为标识指明事项的级别。任何以 `TODO`(是的,全大些)开头的事项都是代办事项。标注为 `DONE` 的工作表示该工作已经完成。`SCHEDULED` 和 `DEADLINE` 标识与该事务相关的日期和时间。如何任何地方都没有时间,则该事务被视为全天活动。 + +使用正确的插件,你喜欢的文本编辑器可以成为一个充满生产率和组织能力的强大工具。例如,[vim-orgmode][5] 插件包括创建 Org 文件、语法高亮的功能,以及各种用来生成跨文件的日程和综合代办事项列表的关键命令。 + +![](https://opensource.com/sites/default/files/uploads/org-2.png) + +Atom 的 [Organized][6] 插件可以在屏幕右边添加一个侧边栏,用来显示 Org 文件中的日程和代办事项。默认情况下它从配置项中设置的路径中读取多个 Org 文件。Todo 侧边栏允许你通过点击未完事项来将其标记为已完成,它会自动更新源 Org 文件。 + +![](https://opensource.com/sites/default/files/uploads/org-3.png) + +还有一大堆 Org 工具可以帮助你保持生产率。使用 Python、Perl、PHP、NodeJS 等库,你可以开发自己的脚本和工具。当然,少不了 [Emacs][7],它的核心功能就包括支持 Org。 + +![](https://opensource.com/sites/default/files/uploads/org-4.png) + +Org 模式是跟踪需要完成的工作和时间的最好工具之一。而且,与传闻相反,它无需 Emacs,任何一个文本编辑器都行。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/productivity-tool-org-mode + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ksonney (Kevin Sonney) +[b]: https://github.com/lujun9972 +[1]: https://orgmode.org/ +[2]: https://www.vim.org/ +[3]: https://atom.io/ +[4]: https://code.visualstudio.com/ +[5]: https://github.com/jceb/vim-orgmode +[6]: https://atom.io/packages/organized +[7]: https://www.gnu.org/software/emacs/ diff --git a/published/201902/20180206 Building Slack for the Linux community and adopting snaps.md b/published/201902/20180206 Building Slack for the Linux community and adopting snaps.md new file mode 100644 index 0000000000..8705db5463 --- /dev/null +++ b/published/201902/20180206 Building Slack for the Linux community and adopting snaps.md @@ -0,0 +1,76 @@ +采用 snaps 为 Linux 社区构建 Slack +====== + +![][1] + +作为一个被数以百万计用户使用的企业级软件平台,[Slack][2] 可以让各种规模的团队和企业有效地沟通。Slack 通过在一个单一集成环境中与其它软件工具无缝衔接,为一个组织内的通讯、信息和项目提供了一个易于接触的档案馆。尽管自从诞生后 Slack 就在过去四年中快速成长,但是他们负责该平台的 Windows、MacOS 和 Linux 桌面的工程师团队仅由四人组成。我们采访了这个团队的主任工程师 Felix Rieseberg(他负责追踪[上月首次发布的 Slack snap][3],LCTT 译注:原文发布于 2018.2),来了解更多有关该公司对于 Linux 社区的态度,以及他们决定构建一个 snap 软件包的原因。 + +- [安装 Slack snap][4] + +### 你们能告诉我们更多关于已发布的 Slack snap 的信息吗? + +作为发布给 Linux 社区的一种新形式,我们上月发布了我们的第一个 snap。在企业界,我们发现人们更倾向于以一种相对于个人消费者来说较慢的速度来采用新科技,因此我们将会在未来继续提供 .deb 形式的软件包。 + +### 你们觉得 Linux 社区会对 Slack 有多大的兴趣呢? + +我很高兴在所有的平台上人们都对 Slack 的兴趣越来越大。因此,很难说来自 Linux 社区的兴趣和我们大体上所见到的兴趣有什么区别。当然,不管用户们在什么平台上面工作,满足他们对我们都是很重要的。我们有一个专门负责 Linux 的测试工程师,并且我们同时也会尽全力提供最好的用户体验。 + +只是我们发现总体相对于 Windows 来说,为 Linux 搭建 snap 略微有点难度,因为我们是在一个较难以预测的平台上工作——而这正是 Linux 社区之光照耀的领域。在汇报程序缺陷以及寻找程序崩溃原因方面,我们有相当多极有帮助的用户。 + +### 你们是如何得知 snap 的? + +Canonical 公司的 Martin Wimpress 接触了我,并向我解释了 snap 的概念。说实话尽管我也用 Ubuntu 但最初我还是迟疑的,因为它看起来像需要搭建与维护的另一套标准。然而,一当我了解到其中的好处之后,我确信这是一笔值得的投入。 + +### snap 的什么方面吸引了你们并使你们决定投入其中? + +毫无疑问,我们决定搭建 snap 最重要的原因是它的更新特性。在 Slack 上我们大量运用了网页技术,这些技术反过来也使得我们提供大量的特性——比如将 YouTube 视频或者 Spotify 播放列表集成在 Slack 中。与浏览器十分相似,这意味着我们需要频繁更新应用。 + +在 MacOS 和 Windows 上,我们已经有了一个专门的自动更新器,甚至无需用户关注更新。任何形式的中断都是一种我们需要避免的烦恼,哪怕是为了更新。因此通过 snap 自动化的更新就显得更加无缝和便捷。 + +### 相比于其它形式的打包方式,构建 snap 感觉如何?将它与现有的设施和流程集成在一起有多简便呢? + +就 Linux 而言,我们尚未尝试其它的“新”打包方式,但我们迟早会的。鉴于我们的大多数用户都使用 Ubuntu,snap 是一个自然的选择。同时 snap 在其它发行版上同样也可以使用,这也是一个巨大的加分项。Canonical 正将 snap 做到跨发行版,而不是仅仅集中在 Ubuntu 上,这一点我认为是很好的。 + +搭建 snap 极其简单,我们有一个创建安装器和软件包的统一流程,我们的 snap 创建过程就是从一个 .deb 软件包炮制出一个 snap。对于其它技术而言,有时候我们为了支持构建链而先打造一个内部工具。但是 snapcraft 工具正是我们需要的东西。在整个过程中 Canonical 的团队非常有帮助,因为我们一路上确实碰到了一些问题。 + +### 你们觉得 snap 商店是如何改变用户们寻找、安装你们软件的方式的呢? + +Slack 真正的独特之处在于人们不仅仅是碰巧发现它,他们从别的地方知道它并积极地试图找到它。因此尽管我们已经有了相当高的觉悟,我希望对于我们的用户来说,在商店中可以获得 snap 能够让安装过程变得简单一点。 + +我们总是尽力为用户服务。当我们觉得它比其他安装方式更好,我们就会向用户更多推荐它。 + +### 通过使用 snap 而不是为其它发行版打包,你期待或者已经看到的节省是什么? + +我们希望 snap 可以给予我们的用户更多的便利,并确保他们能够更加喜欢使用 Slack。在我们看来,鉴于用户们不必被困在之前的版本,这自然而然地解决了许多问题,因此 snap 可以让我们在客户支持方面节约时间。snap 对我们来说也是一个额外的加分项,因为我们能有一个可供搭建的平台,而不是替换我们现有的东西。 + +### 如果存在的话,你们正使用或者准备使用边缘 (edge)、测试 (beta)、候选 (candidate)、稳定 (stable) 中的哪种发行频道? + +我们开发中专门使用边缘 (edge) 频道以与 Canonical 团队合作。为 Linux 打造的 Slack 总体仍处于测试 (beta) 频道中。但是长远来看,拥有不同频道的选择十分有意思,同时能够提早一点为感兴趣的客户发布版本也肯定是有好处的。 + +### 你们如何认为将软件打包成一个 snap 能够帮助用户?你们从用户那边得到了什么反馈吗? + +对我们的用户来说一个很大的好处是安装和更新总体来说都会变得简便一点。长远来看,问题是“那些安装 snap 的用户是不是比其它用户少碰到一些困难?”,我十分期望 snap 自带的依赖关系能够使其变成可能。 + +### 你们对刚使用 snap 的新用户们有什么建议或知识呢? + +我会推荐从 Debian 软件包来着手搭建你们的 snap ——那出乎意料得简单。这同样也缩小了范围,避免变得不堪重负。这只需要投入相当少的时间,并且很大可能是一笔值得的投入。同样如果你们可以的话,尽量试着找到 Canonical 的人员来协作——他们拥有了不起的工程师。 + +### 对于开发来说,你们在什么地方看到了最大的机遇? + +我们现在正一步步来,先是让人们接受 snap,再从那里开始搭建。正在使用 snap 的人们将会感到更加稳健,因为他们将会得益于最新的更新。 + +-------------------------------------------------------------------------------- + +via: https://insights.ubuntu.com/2018/02/06/building-slack-for-the-linux-community-and-adopting-snaps/ + +作者:[Sarah][a] +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://insights.ubuntu.com/author/sarahfd/ +[1]:https://insights.ubuntu.com/wp-content/uploads/a115/Slack_linux_screenshot@2x-2.png +[2]:https://slack.com/ +[3]:https://insights.ubuntu.com/2018/01/18/canonical-brings-slack-to-the-snap-ecosystem/ +[4]:https://snapcraft.io/slack/ diff --git a/published/201902/20180530 Introduction to the Pony programming language.md b/published/201902/20180530 Introduction to the Pony programming language.md new file mode 100644 index 0000000000..c23c17e93a --- /dev/null +++ b/published/201902/20180530 Introduction to the Pony programming language.md @@ -0,0 +1,94 @@ +Pony 编程语言简介 +====== + +> Pony,一种“Rust 遇上 Erlang”的语言,让开发快捷、安全、高效、高并发的程序更简单。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_keys.jpg?itok=O4qaYCHK) + +在 [Wallaroo Labs][1],我是工程副总裁,我们正在构建一个用 [Pony][3] 编程语言编写的 [高性能分布式流处理器][2]。大多数人没有听说过 Pony,但它一直是 Wallaroo 的最佳选择,它也可能成为你的下一个项目的最佳选择。 + +> “一门编程语言只是另一种工具。与语法无关,与表达性无关,与范式或模型无关,仅与解决难题有关。” —Sylvan Clebsch,Pony 的创建者 + +我是 Pony 项目的贡献者,但在这里我要谈谈为什么 Pony 对于像 Wallaroo 这样的应用是个好选择,并分享我使用 Pony 的方式。如果你对我们为什么使用 Pony 来编写 Wallaroo 甚感兴趣,我们有一篇关于它的 [博文][4]。 + +### Pony 是什么? + +你可以把 Pony 想象成某种“Rust 遇上 Erlang”的东西。Pony 有着最引人注目的特性,它们是: + + * 类型安全 + * 存储安全 + * 异常安全 + * 无数据竞争 + * 无死锁 + +此外,它可以被编译为高效的本地代码,它是在开放的情况下开发的,在两句版 BSD 许可证下发布。 + +以上说的功能不少,但在这里我将重点关注那些对我们公司来说采用 Pony 至关重要的功能。 + +### 为什么使用 Pony? + +使用大多数我们现有的工具编写快速、安全、高效、高并发的程序并非易事。“快速、高效、高并发”是可实现的目标,但加入“安全”之后,就困难了许多。对于 Wallaroo,我们希望同时实现四个目标,而 Pony 让实现它们更加简单。 + +#### 高并发 + +Pony 让并发变得简单。部分是通过提供一个固执的并发方式实现的。在 Pony 语言中,所有的并发都是通过 [Actor 模型][5] 进行的。 + +Actor 模型以在 Erlang 和 Akka 中的实现最为著名。Actor 模型出现于上世纪 70 年代,细节因实现方式而异。不变的是,所有计算都由通过异步消息进行通信的 actor 来执行。 + +你可以用这种方式来看待 Actor 模型:面向对象中的对象是状态 + 同步方法,而 actor 是状态 + 异步方法。 + +当一个 actor 收到一个消息时,它执行相应的方法。该方法可以在只有该 actor 可访问的状态下运行。Actor 模型允许我们以并发安全的方式使用可变状态。每个 actor 都是单线程的。一个 actor 中的两个方法绝不会并发运行。这意味着,在给定的 actor 中,数据更新不会引起数据竞争或通常与线程和可变状态相关的其他问题。 + +#### 快速高效 + +Pony actor 通过一个高效的工作窃取调度程序来调度。每个可用的 CPU 都有一个单独 Pony 调度程序。这种每个核心一个线程的并发模型是 Pony 尝试与 CPU 协同工作以尽可能高效运行的一部分。Pony 运行时尝试尽可能利用 CPU 缓存。代码越少干扰缓存,运行得越好。Pony 意在帮你的代码与 CPU 缓存友好相处。 + +Pony 的运行时还会有每个 actor 的堆,因此在垃圾收集期间,没有 “停止一切” 的垃圾收集步骤。这意味着你的程序总是至少能做一点工作。因此 Pony 程序最终具有非常一致的性能和可预测的延迟。 + +#### 安全 + +Pony 类型系统引入了一个新概念:引用能力,它使得数据安全成为类型系统的一部分。Pony 语言中每种变量的类型都包含了有关如何在 actor 之间分享数据的信息。Pony 编译器用这些信息来确认,在编译时,你的代码是无数据竞争和无死锁的。 + +如果这听起来有点像 Rust,那是因为本来就是这样的。Pony 的引用功能和 Rust 的借用检查器都提供数据安全性;它们只是以不同的方式来接近这个目标,并有不同的权衡。 + +### Pony 适合你吗? + +决定是否要在一个非业余爱好的项目上使用一门新的编程语言是困难的。与其他方法想比,你必须权衡工具的适当性和不成熟度。那么,Pony 和你搭不搭呢? + +如果你有一个困难的并发问题需要解决,那么 Pony 可能是一个好选择。解决并发应用问题是 Pony 之所以存在的理由。如果你能用一个单线程的 Python 脚本就完成所需操作,那你大概不需要它。如果你有一个困难的并发问题,你应该考虑 Pony 及其强大的无数据竞争、并发感知类型系统。 + +你将获得一个这样的编译器,它将阻止你引入许多与并发相关的错误,并在运行时为你提供出色的性能特征。 + +### 开始使用 Pony + +如果你准备好开始使用 Pony,你需要先在 Pony 的网站上访问 [学习部分][6]。在这里你会找到安装 Pony 编译器的步骤和学习这门语言的资源。 + +如果你愿意为你正在使用的这个语言做出贡献,我们会在 GitHub 上为你提供一些 [初学者友好的问题][7]。 + +同时,我迫不及待地想在 [我们的 IRC 频道][8] 和 [Pony 邮件列表][9] 上与你交谈。 + +要了解更多有关 Pony 的消息,请参阅 Sean Allen 2018 年 7 月 16 日至 19 日在俄勒冈州波特兰举行的 [第 20 届 OSCON 会议][11] 上的演讲: [Pony,我如何学会停止担心并拥抱未经证实的技术][10]。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/5/pony + +作者:[Sean T Allen][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[beamrolling](https://github.com/beamrolling) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/seantallen +[1]:http://www.wallaroolabs.com/ +[2]:https://github.com/wallaroolabs/wallaroo +[3]:https://www.ponylang.org/ +[4]:https://blog.wallaroolabs.com/2017/10/why-we-used-pony-to-write-wallaroo/ +[5]:https://en.wikipedia.org/wiki/Actor_model +[6]:https://www.ponylang.org/learn/ +[7]:https://github.com/ponylang/ponyc/issues?q=is%3Aissue+is%3Aopen+label%3A%22complexity%3A+beginner+friendly%22 +[8]:https://webchat.freenode.net/?channels=%23ponylang +[9]:https://pony.groups.io/g/user +[10]:https://conferences.oreilly.com/oscon/oscon-or/public/schedule/speaker/213590 +[11]:https://conferences.oreilly.com/oscon/oscon-or diff --git a/published/201902/20180531 Qalculate- - The Best Calculator Application in The Entire Universe.md b/published/201902/20180531 Qalculate- - The Best Calculator Application in The Entire Universe.md new file mode 100644 index 0000000000..fa65d2cdfa --- /dev/null +++ b/published/201902/20180531 Qalculate- - The Best Calculator Application in The Entire Universe.md @@ -0,0 +1,124 @@ +Qalculate! :全宇宙最好的计算器软件 +====== + +十多年来,我一直都是 GNU-Linux 以及 [Debian][1] 的用户。随着我越来越频繁的使用桌面环境,我发现对我来说除了少数基于 web 的服务以外我的大多数需求都可以通过 Debian 软件库里自带的[桌面应用][2]解决。 + +我的需求之一就是进行单位换算。尽管有很多很多在线服务可以做这件事,但是我还是需要一个可以在桌面环境使用的应用。这主要是因为隐私问题以及我不想一而再再而三的寻找在线服务做事。为此我搜寻良久,直到找到 Qalculate!。 + +### Qalculate! 最强多功能计算器应用 + +![最佳计算器应用 Qalculator][3] + +这是 aptitude 上关于 [Qalculate!][4] 的介绍,我没法总结的比他们更好了: + +> 强大易用的桌面计算器 - GTK+ 版 +> +> Qalculate! 是一款外表简单易用,内核强大且功能丰富的应用。其功能包含自定义函数、单位、高计算精度、作图以及可以输入一行表达式(有容错措施)的图形界面(也可以选择使用传统按钮)。 + +这款应用也发行过 KDE 的界面,但是至少在 Debian Testing 软件库里,只出现了 GTK+ 版的界面,你也可以在 GitHub 上的这个[仓库][5]里面看到。 + +不必多说,Qalculate! 在 Debian 的软件源内处于可用状态,因此可以使用 [apt][6] 命令或者是基于 Debian 的发行版比如 Ubuntu 提供的软件中心轻松安装。在 Windows 或者 macOS 上也可以使用这款软件。 + +#### Qalculate! 特性一览 + +列出全部的功能清单会有点长,请允许我只列出一部分功能并使用截图来展示极少数 Qalculate! 提供的功能。这么做是为了让你熟悉 Qalculate! 的基本功能,并在之后可以自由探索 Qalculate! 到底还能干什么。 + +* 代数 +* 微积分 +* 组合数学 +* 复数 +* 数据集 +* 日期与时间 +* 经济学 +* 对数和指数 +* 几何 +* 逻辑学 +* 向量和矩阵 +* 杂项 +* 数论 +* 统计学 +* 三角学 + +#### 使用 Qalculate! + +Qalculate! 的使用不是很难。你甚至可以在里面写简单的英文。但是我还是推荐先[阅读手册][7]以便充分发挥 Qalculate! 的潜能。 + +![使用 Qalculate 进行字节到 GB 的换算][8] + +![摄氏度到华氏度的换算][9] + +#### qalc 是 Qalculate! 的命令行版 + +你也可以使用 Qalculate! 的命令行版 `qalc`: + +``` +$ qalc 62499836 byte to gibibyte +62499836 * byte = approx. 0.058207508 gibibyte + +$ qalc 40 degree celsius to fahrenheit +(40 * degree) * celsius = 104 deg*oF +``` + +Qalculate! 的命令行界面可以让不喜欢 GUI 而是喜欢命令行界面(CLI)或者是使用无头结点(没有 GUI)的人可以使用 Qalculate!。这些人大多是在服务器环境下工作。 + +如果你想要在脚本里使用这一软件的话,我想 libqalculate 是最好的解决方案。看一看 `qalc` 以及 qalculate-gtk 是如何依赖于它工作的就足以知晓如何使用了。 + +再提一嘴,你还可以了解下如何根据一系列数据绘图,其他应用方式就留给你自己发掘了。不要忘记查看 `/usr/share/doc/qalculate/index.html` 以获取 Qalculate! 的全部功能。 + +注释:注意 Debian 更喜欢 [gnuplot][10],因为其输出的图片很精美。 + +#### 附加技巧:你可以通过在 Debian 下通过命令行感谢开发者 + +如果你使用 Debian 而且喜欢哪个包的话,你可以使用如下命令感谢 Debian 下这个软件包的开发者或者是维护者: + +``` +reportbug --kudos $PACKAGENAME +``` + +因为我喜欢 Qalculate!,我想要对 Debian 的开发者以及维护者 Vincent Legout 的卓越工作表示感谢: + +``` +reportbug --kudos qalculate +``` + +建议各位阅读我写的关于如何使用报错工具[在 Debian 中上报 BUG][11]的详细指南。 + +#### 一位高分子化学家对 Qalculate! 的评价 + +经由作者 [Philip Prado][12],我们联系上了 Timothy Meyers 先生,他目前是在高分子实验室工作的高分子化学家。 + +他对 Qaclulate! 的专业评价是: + +> 看起来几乎任何科学家都可以使用这个软件,因为如果你知道指令以及如何使其生效的话,几乎任何数据计算都可以使用这个软件计算。 + +> 我觉得这个软件少了些物理常数,但我想不起来缺了哪些。我觉得它没有太多有关[流体动力学][13]的东西,再就是少了点部分化合物的[光吸收][14]系数,但这些东西只对我这个化学家来说比较重要,我不知道这些是不是对别人来说也是特别必要的。[自由能][15]可能也是。 + +最后,我分享的关于 Qalculate! 的介绍十分简陋,其实际功能与你的需要以及你的想象力有关系。希望你能喜欢 Qalculate! + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/qalculate/ + +作者:[Shirish][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[name1e5s](https://github.com/name1e5s) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://itsfoss.com/author/shirish/ +[1]:https://www.debian.org/ +[2]:https://itsfoss.com/essential-linux-applications/ +[3]:https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/05/qalculate-app-featured-1.jpeg?w=800&ssl=1 +[4]:https://qalculate.github.io/ +[5]:https://github.com/Qalculate +[6]:https://itsfoss.com/apt-command-guide/ +[7]:https://qalculate.github.io/manual/index.html +[8]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/04/qalculate-byte-conversion.png?zoom=2&ssl=1 +[9]:https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/04/qalculate-gtk-weather-conversion.png?zoom=2&ssl=1 +[10]:http://www.gnuplot.info/ +[11]:https://itsfoss.com/bug-report-debian/ +[12]:https://itsfoss.com/author/phillip/ +[13]:https://en.wikipedia.org/wiki/Fluid_dynamics +[14]:https://en.wikipedia.org/wiki/Absorption_(electromagnetic_radiation) +[15]:https://en.wikipedia.org/wiki/Gibbs_free_energy diff --git a/translated/tech/20180614 An introduction to the Tornado Python web app framework.md b/published/201902/20180614 An introduction to the Tornado Python web app framework.md similarity index 86% rename from translated/tech/20180614 An introduction to the Tornado Python web app framework.md rename to published/201902/20180614 An introduction to the Tornado Python web app framework.md index 3816f5138b..26ff727f99 100644 --- a/translated/tech/20180614 An introduction to the Tornado Python web app framework.md +++ b/published/201902/20180614 An introduction to the Tornado Python web app framework.md @@ -1,28 +1,29 @@ [#]: collector: (lujun9972) [#]: translator: (MjSeven) -[#]: reviewer: ( ) -[#]: publisher: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) [#]: subject: (An introduction to the Tornado Python web app framework) [#]: via: (https://opensource.com/article/18/6/tornado-framework) [#]: author: (Nicholas Hunt-Walker https://opensource.com/users/nhuntwalker) -[#]: url: ( ) +[#]: url: (https://linux.cn/article-10522-1.html) -Python Web 框架 Tornado 简介 +Python Web 应用程序 Tornado 框架简介 ====== -在比较 Python 框架的系列文章的第三部分中,我们来了解 Tornado,它是为处理异步进程而构建的。 +> 在比较 Python 框架的系列文章的第三部分中,我们来了解 Tornado,它是为处理异步进程而构建的。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tornado.png?itok=kAa3eXIU) -在这个由四部分组成的系列文章的前两篇中,我们介绍了 [Pyramid][1] 和 [Flask][2] Web 框架。我们已经构建了两次相同的应用程序,看到了一个完全的 DIY 框架和包含更多电池的框架之间的异同。 +在这个由四部分组成的系列文章的前两篇中,我们介绍了 [Pyramid][1] 和 [Flask][2] Web 框架。我们已经构建了两次相同的应用程序,看到了一个完整的 DIY 框架和包含了更多功能的框架之间的异同。 -现在让我们来看看另一个稍微不同的选项:[Tornado 框架][3]。Tornado 在很大程度上与 Flask 一样简单,但有一个主要区别:Tornado 是专门为处理异步进程而构建的。在我们本系列所构建的应用程序中,这种特殊的酱料(译者注:这里意思是 Tornado 的异步功能)并不是非常有用,但我们将看到在哪里可以使用它,以及它在更一般的情况下是如何工作的。 +现在让我们来看看另一个稍微不同的选择:[Tornado 框架][3]。Tornado 在很大程度上与 Flask 一样简单,但有一个主要区别:Tornado 是专门为处理异步进程而构建的。在我们本系列所构建的应用程序中,这种特殊的酱料(LCTT 译注:这里意思是 Tornado 的异步功能)在我们构建的 app 中并不是非常有用,但我们将看到在哪里可以使用它,以及它在更一般的情况下是如何工作的。 -让我们继续前两篇文章中设置的流程,首先从处理设置和配置。 +让我们继续前两篇文章中模式,首先从处理设置和配置开始。 ### Tornado 启动和配置 如果你一直关注这个系列,那么第一步应该对你来说习以为常。 + ``` $ mkdir tornado_todo $ cd tornado_todo @@ -32,6 +33,7 @@ $ pipenv shell ``` 创建一个 `setup.py` 文件来安装我们的应用程序相关的东西: + ``` (tornado-someHash) $ touch setup.py # setup.py @@ -61,6 +63,7 @@ setup( ``` 因为 Tornado 不需要任何外部配置,所以我们可以直接编写 Python 代码来让程序运行。让我们创建 `todo` 目录,并用需要的前几个文件填充它。 + ``` todo/     __init__.py @@ -68,7 +71,18 @@ todo/     views.py ``` -就像 Flask 和 Pyramid 一样,Tornado 也有一些基本配置,将放在 `__init__.py` 中。从 `tornado.web` 中,我们将导入 `Application` 对象,它将处理路由和视图的连接,包括数据库(当我们谈到那里时再说)以及运行 Tornado 应用程序所需的其它额外设置。 +就像 Flask 和 Pyramid 一样,Tornado 也有一些基本配置,放在 `__init__.py` 中。从 `tornado.web` 中,我们将导入 `Application` 对象,它将处理路由和视图的连接,包括数据库(当我们谈到那里时再说)以及运行 Tornado 应用程序所需的其它额外设置。 + +``` +# __init__.py +from tornado.web import Application + +def main(): + """Construct and serve the tornado application.""" + app = Application() +``` + +像 Flask 一样,Tornado 主要是一个 DIY 框架。当构建我们的 app 时,我们必须设置该应用实例。因为 Tornado 用它自己的 HTTP 服务器来提供该应用,我们必须设置如何提供该应用。首先,在 `tornado.options.define` 中定义要监听的端口。然后我们实例化 Tornado 的 `HTTPServer`,将该 `Application` 对象的实例作为参数传递给它。 ``` # __init__.py @@ -109,13 +123,13 @@ def main():     IOLoop.current().start() ``` -我喜欢某种形式的 `print` 声明,告诉我什么时候应用程序正在提供服务,我就是这样子。如果你愿意,可以不使用 `print`。 +我喜欢某种形式的 `print` 语句,来告诉我什么时候应用程序正在提供服务,这是我的习惯。如果你愿意,可以不使用 `print`。 我们以 `IOLoop.current().start()` 开始我们的 I/O 循环。让我们进一步讨论输入,输出和异步性。 ### Python 中的异步和 I/O 循环的基础知识 -请允许我提前说明,我绝对,肯定,肯定并且安心地说不是异步编程方面的专家。就像我写的所有内容一样,接下来的内容源于我对这个概念的理解的局限性。因为我是人,可能有很深很深的缺陷。 +请允许我提前说明,我绝对,肯定,一定并且放心地说不是异步编程方面的专家。就像我写的所有内容一样,接下来的内容源于我对这个概念的理解的局限性。因为我是人,可能有很深很深的缺陷。 异步程序的主要问题是: @@ -123,7 +137,7 @@ def main(): * 数据如何出去? * 什么时候可以在不占用我全部注意力情况下运行某个过程? -由于[全局解释器锁][4](GIL),Python 被设计为一种单线程语言。对于 Python 程序必须执行的每个任务,其线程执行的全部注意力都集中在该任务的持续时间内。我们的 HTTP 服务器是用 Python 编写的,因此,当接收到数据(如 HTTP 请求)时,服务器的唯一关心的是传入的数据。这意味着,在大多数情况下,无论是程序需要运行还是处理数据,程序都将完全消耗服务器的执行线程,阻止接收其它可能的数据,直到服务器完成它需要做的事情。 +由于[全局解释器锁][4](GIL),Python 被设计为一种[单线程][5]语言。对于 Python 程序必须执行的每个任务,其线程执行的全部注意力都集中在该任务的持续时间内。我们的 HTTP 服务器是用 Python 编写的,因此,当接收到数据(如 HTTP 请求)时,服务器的唯一关心的是传入的数据。这意味着,在大多数情况下,无论是程序需要运行还是处理数据,程序都将完全消耗服务器的执行线程,阻止接收其它可能的数据,直到服务器完成它需要做的事情。 在许多情况下,这不是太成问题。典型的 Web 请求,响应周期只需要几分之一秒。除此之外,构建 HTTP 服务器的套接字可以维护待处理的传入请求的积压。因此,如果请求在该套接字处理其它内容时进入,则它很可能只是在处理之前稍微排队等待一会。对于低到中等流量的站点,几分之一秒的时间并不是什么大问题,你可以使用多个部署的实例以及 [NGINX][6] 等负载均衡器来为更大的请求负载分配流量。 @@ -182,9 +196,9 @@ def main(): 尽管经历了在 Python 中讨论异步的所有麻烦,我们还是决定暂不使用它。先来编写一个基本的 Tornado 视图。 -与我们在 Flask 和 Pyramid 实现中看到的基于函数的视图不同,Tornado 的视图都是基于类的。这意味着我们将不在使用单独的,独立的函数来规定如何处理请求。相反,传入的 HTTP 请求将被捕获并将其分配为我们定义的类的一个属性。然后,它的方法将处理相应的请求类型。 +与我们在 Flask 和 Pyramid 实现中看到的基于函数的视图不同,Tornado 的视图都是基于类的。这意味着我们将不在使用单独的、独立的函数来规定如何处理请求。相反,传入的 HTTP 请求将被捕获并将其分配为我们定义的类的一个属性。然后,它的方法将处理相应的请求类型。 -让我们从一个基本的视图开始,即在屏幕上打印 "Hello, World"。我们为 Tornado 应用程序构造的每个基于类的视图都必须继承 `tornado.web` 中的 `RequestHandler` 对象。这将设置我们需要(但不想写)的所有底层逻辑来接收请求,同时构造正确格式的 HTTP 响应。 +让我们从一个基本的视图开始,即在屏幕上打印 “Hello, World”。我们为 Tornado 应用程序构造的每个基于类的视图都必须继承 `tornado.web` 中的 `RequestHandler` 对象。这将设置我们需要(但不想写)的所有底层逻辑来接收请求,同时构造正确格式的 HTTP 响应。 ``` from tornado.web import RequestHandler @@ -197,7 +211,7 @@ class HelloWorld(RequestHandler):         self.write("Hello, world!") ``` -因为我们要处理 `GET` 请求,所以我们声明(实际上是重写) `get` 方法。我们提供文本或 JSON 可序列化对象,用 `self.write` 写入响应体。之后,我们让 `RequestHandler` 来做在发送响应之前必须完成的其它工作。 +因为我们要处理 `GET` 请求,所以我们声明(实际上是重写)了 `get` 方法。我们提供文本或 JSON 可序列化对象,用 `self.write` 写入响应体。之后,我们让 `RequestHandler` 来做在发送响应之前必须完成的其它工作。 就目前而言,此视图与 Tornado 应用程序本身并没有实际连接。我们必须回到 `__init__.py`,并稍微更新 `main` 函数。以下是新的内容: @@ -226,15 +240,15 @@ def main(): 我们将 `views.py` 文件中的 `HelloWorld` 视图导入到脚本 `__init__.py` 的顶部。然后我们添加了一个路由-视图对应的列表,作为 `Application` 实例化的第一个参数。每当我们想要在应用程序中声明一个路由时,它必须绑定到一个视图。如果需要,可以对多个路由使用相同的视图,但每个路由必须有一个视图。 -我们可以通过在 `setup.py` 中启用的 `serve_app` 命令来运行应用程序,从而确保这一切都能正常工作。查看 `http://localhost:8888/` 并看到它显示 "Hello, world!"。 +我们可以通过在 `setup.py` 中启用的 `serve_app` 命令来运行应用程序,从而确保这一切都能正常工作。查看 `http://localhost:8888/` 并看到它显示 “Hello, world!”。 当然,在这个领域中我们还能做更多,也将做更多,但现在让我们来讨论模型吧。 ### 连接数据库 -如果我们想要保留数据,我们需要连接数据库。与 Flask 一样,我们将使用一个特定于框架的 SQLAchemy 变体,名为 [tornado-sqlalchemy][7]。 +如果我们想要保留数据,就需要连接数据库。与 Flask 一样,我们将使用一个特定于框架的 SQLAchemy 变体,名为 [tornado-sqlalchemy][7]。 -为什么要使用它而不是 [SQLAlchemy][8] 呢?好吧,其实 `tornado-sqlalchemy` 具有简单 SQLAlchemy 的所有优点,因此我们仍然可以使用通用的 `Base` 声明模型,并使用我们习以为常的所有列数据类型和关系。除了我们已经从习惯中了解到的,`tornado-sqlalchemy` 还为其数据库查询功能提供了一种可访问的异步模式,专门用于与 Tornado 现有的 I/O 循环一起工作。 +为什么要使用它而不是 [SQLAlchemy][8] 呢?好吧,其实 `tornado-sqlalchemy` 具有简单 SQLAlchemy 的所有优点,因此我们仍然可以使用通用的 `Base` 声明模型,并使用我们习以为常的所有列数据类型和关系。除了我们已经惯常了解到的,`tornado-sqlalchemy` 还为其数据库查询功能提供了一种可访问的异步模式,专门用于与 Tornado 现有的 I/O 循环一起工作。 我们通过将 `tornado-sqlalchemy` 和 `psycopg2` 添加到 `setup.py` 到所需包的列表并重新安装包来创建环境。在 `models.py` 中,我们声明了模型。这一步看起来与我们在 Flask 和 Pyramid 中已经看到的完全一样,所以我将跳过全部声明,只列出了 `Task` 模型的必要部分。 @@ -463,7 +477,7 @@ class TaskListView(BaseView):                 }) ``` -这里的第一个主要部分是 `@coroutine` 装饰器,它从 `tornado.gen` 导入。任何具有与调用堆栈的正常流程不同步的部分的 Python 可调用实际上是“协程”。一个可以与其它协程一起运行的协程。在我的家务劳动的例子中,几乎所有的家务活都是一个共同的例行协程。有些人阻止了例行协程(例如,给地板吸尘),但这种例行协程只会阻碍我开始或关心其它任何事情的能力。它没有阻止已经启动的任何其他协程继续进行。 +这里的第一个主要部分是 `@coroutine` 装饰器,它从 `tornado.gen` 导入。任何具有与调用堆栈的正常流程不同步的 Python 可调用部分实际上是“协程”,即一个可以与其它协程一起运行的协程。在我的家务劳动的例子中,几乎所有的家务活都是一个共同的例行协程。有些阻止了例行协程(例如,给地板吸尘),但这种例行协程只会阻碍我开始或关心其它任何事情的能力。它没有阻止已经启动的任何其他协程继续进行。 Tornado 提供了许多方法来构建一个利用协程的应用程序,包括允许我们设置函数调用锁,同步异步协程的条件,以及手动修改控制 I/O 循环的事件系统。 @@ -525,9 +539,9 @@ def post(self, username): 在我们继续浏览这些 Web 框架时,我们开始看到它们都可以有效地处理相同的问题。对于像这样的待办事项列表,任何框架都可以完成这项任务。但是,有些 Web 框架比其它框架更适合某些工作,这具体取决于对你来说什么“更合适”和你的需求。 -虽然 Tornado 显然能够处理 Pyramid 或 Flask 可以处理的相同工作,但将它用于这样的应用程序实际上是一种浪费,这就像开车从家走一个街区(to 校正:这里意思应该是从家开始走一个街区只需步行即可)。是的,它可以完成“旅行”的工作,但短途旅行不是你选择汽车而不是自行车或者使用双脚的原因。 +虽然 Tornado 显然和 Pyramid 或 Flask 一样可以处理相同工作,但将它用于这样的应用程序实际上是一种浪费,这就像开车从家走一个街区(LCTT 译注:这里意思应该是从家开始走一个街区只需步行即可)。是的,它可以完成“旅行”的工作,但短途旅行不是你选择汽车而不是自行车或者使用双脚的原因。 -根据文档,Tornado 被称为 “Python Web 框架和异步网络库”。在 Python Web 框架生态系统中很少有人喜欢它。如果你尝试完成的工作需要(或将从中获益)以任何方式,形状或形式的异步性,使用 Tornado。如果你的应用程序需要处理多个长期连接,同时又不想牺牲太多性能,选择 Tornado。如果你的应用程序是多个应用程序,并且需要线程感知以准确处理数据,使用 Tornado。这是它最有效的地方。 +根据文档,Tornado 被称为 “Python Web 框架和异步网络库”。在 Python Web 框架生态系统中很少有人喜欢它。如果你尝试完成的工作需要(或将从中获益)以任何方式、形状或形式的异步性,使用 Tornado。如果你的应用程序需要处理多个长期连接,同时又不想牺牲太多性能,选择 Tornado。如果你的应用程序是多个应用程序,并且需要线程感知以准确处理数据,使用 Tornado。这是它最有效的地方。 用你的汽车做“汽车的事情”,使用其他交通工具做其他事情。 @@ -535,13 +549,10 @@ def post(self, username): 谈到使用合适的工具来完成合适的工作,在选择框架时,请记住应用程序的范围和规模,包括现在和未来。到目前为止,我们只研究了适用于中小型 Web 应用程序的框架。本系列的下一篇也是最后一篇将介绍最受欢迎的 Python 框架之一 Django,它适用于可能会变得更大的大型应用程序。同样,尽管它在技术上能够并且将会处理待办事项列表问题,但请记住,这不是它的真正用途。我们仍然会通过它来展示如何使用它来构建应用程序,但我们必须牢记框架的意图以及它是如何反映在架构中的: -  * **Flask:** 适用于小型,简单的项目。它可以使我们轻松地构建视图并将它们快速连接到路由,它可以简单地封装在一个文件中。 - -  * **Pyramid:** 适用于可能增长的项目。它包含一些配置来启动和运行。应用程序组件的独立领域可以很容易地划分并构建到任意深度,而不会忽略中央应用程序。 - -  * **Tornado:** 适用于受益于精确和有意识的 I/O 控制的项目。它允许协程,并轻松公开可以控制如何接收请求或发送响应以及何时发生这些操作的方法。 - -  * **Django:**(我们将会看到)意味着可能会变得更大的东西。它有着非常庞大的生态系统,包括大量插件和模块。它非常有主见的配置和管理,以保持所有不同部分在同一条线上。 +* **Flask**: 适用于小型,简单的项目。它可以使我们轻松地构建视图并将它们快速连接到路由,它可以简单地封装在一个文件中。 +* **Pyramid**: 适用于可能增长的项目。它包含一些配置来启动和运行。应用程序组件的独立领域可以很容易地划分并构建到任意深度,而不会忽略中央应用程序。 +* **Tornado**: 适用于受益于精确和有意识的 I/O 控制的项目。它允许协程,并轻松公开可以控制如何接收请求或发送响应以及何时发生这些操作的方法。 +* **Django**:(我们将会看到)意味着可能会变得更大的东西。它有着非常庞大的生态系统,包括大量插件和模块。它非常有主见的配置和管理,以保持所有不同部分在同一条线上。 无论你是从本系列的第一篇文章开始阅读,还是稍后才加入的,都要感谢阅读!请随意留下问题或意见。下次再见时,我手里会拿着 Django。 @@ -549,7 +560,7 @@ def post(self, username): 我必须把功劳归于它应得的地方,非常感谢 [Guido van Rossum][12],不仅仅是因为他创造了我最喜欢的编程语言。 -在 [PyCascades 2018][13] 期间,我很幸运的不仅给了基于这个文章系列的演讲,而且还被邀请参加了演讲者的晚宴。整个晚上我都坐在 Guido 旁边,不停地问他问题。其中一个问题是,在 Python 中异步到底是如何工作的,但他没有一点大惊小怪,而是花时间向我解释,让我开始理解这个概念。他后来[推特给我][14]发了一条消息:是用于学习异步 Python 的广阔资源。我随后在三个月内阅读了三次,然后写了这篇文章。你真是一个非常棒的人,Guido! +在 [PyCascades 2018][13] 期间,我很幸运的不仅做了基于这个文章系列的演讲,而且还被邀请参加了演讲者的晚宴。整个晚上我都坐在 Guido 旁边,不停地问他问题。其中一个问题是,在 Python 中异步到底是如何工作的,但他没有一点大惊小怪,而是花时间向我解释,让我开始理解这个概念。他后来[推特给我][14]发了一条消息:是用于学习异步 Python 的广阔资源。我随后在三个月内阅读了三次,然后写了这篇文章。你真是一个非常棒的人,Guido! -------------------------------------------------------------------------------- @@ -558,7 +569,7 @@ via: https://opensource.com/article/18/6/tornado-framework 作者:[Nicholas Hunt-Walker][a] 选题:[lujun9972][b] 译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/201902/20180621 How to connect to a remote desktop from Linux.md b/published/201902/20180621 How to connect to a remote desktop from Linux.md new file mode 100644 index 0000000000..27115bc620 --- /dev/null +++ b/published/201902/20180621 How to connect to a remote desktop from Linux.md @@ -0,0 +1,138 @@ +如何从 Linux 上连接到远程桌面 +====== + +> Remmina 的极简用户界面使得远程访问 Linux / Windows 10 变得轻松。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_cloud21x_cc.png?itok=5UwC92dO) + +根据维基百科,[远程桌面][1] 是一种“软件或者操作系统特性,它可以让个人电脑上的桌面环境在一个系统(通常是电脑,但是也可以是服务器)上远程运行,但在另一个分开的客户端设备显示”。 + +换句话说,远程桌面是用来访问在另一台电脑上运行的环境的。比如说 [ManageIQ/Integration tests][2] 仓库的拉取请求 (PR) 测试系统开放了一个虚拟网络计算 (VNC) 连接端口,使得我能够远程浏览正被实时测试的拉取请求。远程桌面也被用于帮助客户解决电脑问题:在客户的许可下,你可以远程建立 VNC 或者远程桌面协议(RDP)连接来查看或者交互式地访问该电脑以寻找并解决问题。 + +运用远程桌面连接软件可以建立这些连接。可供选择的软件有很多,我用 [Remmina][3],因为我喜欢它极简、好用的用户界面 (UI)。它是用 GTK+ 编写的,在 GNU GPL 许可证开源。 + +在这篇文章里,我会解释如何使用 Remmina 客户端从一台 Linux 电脑上远程连接到 Windows 10 系统 和 Red Hat 企业版 Linux 7 系统。 + +### 在 Linux 上安装 Remmina + +首先,你需要在你用来远程访问其它电脑的的主机上安装 Remmina。如果你用的是 Fedora,你可以运行如下的命令来安装 Remmina: + +``` +sudo dnf install -y remmina +``` + +如果你想在一个不同的 Linux 平台上安装 Remmina,跟着 [安装教程][4] 走。然后你会发现 Remmina 正和你其它软件出现在一起(在这张图片里选中了 Remmina)。 + +![](https://opensource.com/sites/default/files/uploads/remmina1-on-desktop.png) + +点击图标运行 Remmina,你应该能看到像这样的屏幕: + +![](https://opensource.com/sites/default/files/uploads/remmina2_launched.png) + +Remmina 提供不同种类的连接,其中包括用来连接到 Windows 系统的 RDP 和用来连接到 Linux 系统的 VNC。如你在上图左上角所见的,Remmina 的默认设置是 RDP。 + +### 连接到 Windows 10 + +在你通过 RDP 连接到一台 Windows 10 电脑之前,你必须修改权限以允许分享远程桌面并通过防火墙建立连接。 + +- [注意: Windows 10 家庭版没有列入 RDP 特性][5] + +要许可远程桌面分享,在“文件管理器”界面右击“我的电脑 → 属性 → 远程设置”,接着在跳出的窗口中,勾选“在这台电脑上允许远程连接”,再点击“应用”。 + +![](https://opensource.com/sites/default/files/uploads/remmina3_connect_win10.png) + +然后,允许远程连接通过你的防火墙。首先在“开始菜单”中查找“防火墙设置”,选择“允许应用通过防火墙”。 + +![](https://opensource.com/sites/default/files/uploads/remmina4_firewall.png) + +在打开的窗口中,在“允许的应用和特性”下找到“远程桌面”。根据你用来访问这个桌面的网络酌情勾选“隐私”和/或“公开”列的选框。点击“确定”。 + +![](https://opensource.com/sites/default/files/uploads/remmina5_firewall_2.png) + +回到你用来远程访问 Windows 主机的 Linux 电脑,打开 Remmina。输入你的 Windows 主机的 IP 地址,敲击回车键。(我怎么在 [Linux][6] 和 [Windws][7] 中确定我的 IP 地址?)看到提示后,输入你的用户名和密码,点击“确定”。 + +![](https://opensource.com/sites/default/files/uploads/remmina6_login.png) + +如果你被询问是否接受证书,点击“确定”。 + +![](https://opensource.com/sites/default/files/uploads/remmina7_certificate.png) + +你此时应能看到你的 Windows 10 主机桌面。 + +![](https://opensource.com/sites/default/files/uploads/remmina8_remote_desktop.png) + +### 连接到 Red Hat 企业版 Linux 7 + +要在你的 RHEL7 电脑上允许远程访问,在 Linux 桌面上打开“所有设置”。 + +![](https://opensource.com/sites/default/files/uploads/remmina9_settings.png) + +点击分享图标会打开如下的窗口: + +![](https://opensource.com/sites/default/files/uploads/remmina10_sharing.png) + +如果“屏幕分享”处于关闭状态,点击一下。一个窗口会弹出,你可以滑动到“打开”的位置。如果你想允许远程控制桌面,将“允许远程控制”调到“打开”。你同样也可以在两种访问选项间选择:一个能够让电脑的主要用户接受或者否绝连接要求,另一个能用密码验证连接。在窗口底部,选择被允许连接的网络界面,最后关闭窗口。 + +接着,从“应用菜单 → 其它 → 防火墙”打开“防火墙设置”。 + +![](https://opensource.com/sites/default/files/uploads/remmina11_firewall_settings.png) + +勾选 “vnc-server”旁边的选框(如下图所示)关闭窗口。接着直接到你远程电脑上的 Remmina,输入你想连接到的 Linux 桌面的 IP 地址,选择 VNC 作为协议,点击回车键。 + +![](https://opensource.com/sites/default/files/uploads/remmina12_vncprotocol.png) + +如果你之前选择的验证选项是“新连接必须询问访问许可”,RHEL 系统用户会看到这样的一个弹窗: + +![](https://opensource.com/sites/default/files/uploads/remmina13_permission.png) + +点击“接受”以成功进行远程连接。 + +如果你选择用密码验证连接,Remmina 会向你询问密码。 + +![](https://opensource.com/sites/default/files/uploads/remmina14_password-auth.png) + +输入密码然后“确认”,你应该能连接到远程电脑。 + +![](https://opensource.com/sites/default/files/uploads/remmina15_connected.png) + +### 使用 Remmina + +Remmina 提供如上图所示的标签化的 UI,就好像一个浏览器一样。在上图所示的左上角你可以看到两个标签:一个是之前建立的 WIndows 10 连接,另一个新的是 RHEL 连接。 + +在窗口的左侧,有一个有着“缩放窗口”、“全屏模式”、“偏好”、“截屏”、“断开连接”等选项的工具栏。你可以自己探索看那种适合你。 + +你也可以通过点击左上角的“+”号创建保存过的连接。根据你的连接情况填好表单点击“保存”。以下是一个 Windows 10 RDP 连接的示例: + +![](https://opensource.com/sites/default/files/uploads/remmina16_saved-connection.png) + +下次你打开 Remmina 时连接就在那了。 + +![](https://opensource.com/sites/default/files/uploads/remmina17_connection-available.png) + +点击一下它,你不用补充细节就可以建立连接了。 + +### 补充说明 + +当你使用远程桌面软件时,你所有的操作都在远程桌面上消耗资源 —— Remmina(或者其它类似软件)仅仅是一种与远程桌面交互的方式。你也可以通过 SSH 远程访问一台电脑,但那将会让你在那台电脑上局限于仅能使用文字的终端。 + +你也应当注意到当你允许你的电脑远程连接时,如果一名攻击者用这种方法获得你电脑的访问权同样会给你带来严重损失。因此当你不频繁使用远程桌面时,禁止远程桌面连接以及其在防火墙中相关的服务是很明智的做法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/6/linux-remote-desktop + +作者:[Kedar Vijay Kulkarni][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[tomjlw](https://github.com/tomjlw) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/kkulkarn +[1]:https://en.wikipedia.org/wiki/Remote_desktop_software +[2]:https://github.com/ManageIQ/integration_tests +[3]:https://www.remmina.org/wp/ +[4]:https://www.tecmint.com/remmina-remote-desktop-sharing-and-ssh-client/ +[5]:https://superuser.com/questions/1019203/remote-desktop-settings-missing#1019212 +[6]:https://opensource.com/article/18/5/how-find-ip-address-linux +[7]:https://www.groovypost.com/howto/find-windows-10-device-ip-address/ diff --git a/published/20180626 How To Search If A Package Is Available On Your Linux Distribution Or Not.md b/published/201902/20180626 How To Search If A Package Is Available On Your Linux Distribution Or Not.md similarity index 100% rename from published/20180626 How To Search If A Package Is Available On Your Linux Distribution Or Not.md rename to published/201902/20180626 How To Search If A Package Is Available On Your Linux Distribution Or Not.md diff --git a/published/201902/20180724 How To Mount Google Drive Locally As Virtual File System In Linux.md b/published/201902/20180724 How To Mount Google Drive Locally As Virtual File System In Linux.md new file mode 100644 index 0000000000..bfafba2bb8 --- /dev/null +++ b/published/201902/20180724 How To Mount Google Drive Locally As Virtual File System In Linux.md @@ -0,0 +1,267 @@ + +如何把 Google 云端硬盘当做虚拟磁盘一样挂载到 Linux +====== + +![](https://www.ostechnix.com/wp-content/uploads/2018/07/Google-Drive-720x340.png) + +[Google 云端硬盘][1] 是全球比较受欢迎的云存储平台. 直到 2017 年, 全球有超过 8 亿的活跃用户在使用它。即使用户数在持续增长,但直到现在 Google 还是没有发布一款可以在 Linux 平台使用的客户端。但这难不倒 Linux 社区。不时就有一些开发者给 Linux 操作系统带来一些客户端。下面我将会介绍三个用于 Linux 系统非官方开发的 Google 云端硬盘客户端。使用这些客户端,你能把 Google 云端硬盘像虚拟磁盘一样挂载到 Linux 系统。请继续阅读。 + +### 1、Google-drive-ocamlfuse + +google-drive-ocamlfuse 把 Google 云端硬盘当做是一个 FUSE 类型的文件系统,它是用 OCam 语言写的。FUSE 意即用户态文件系统Filesystem in Userspace,此项目允许非管理员用户在用户空间创建虚拟文件系统。google-drive-ocamlfuse 可以让你把 Google 云端硬盘当做磁盘一样挂载到 Linux 系统。支持对普通文件和目录的读写操作,支持对 Google dock、表单和演示稿的只读操作,支持多个 Googe 云端硬盘用户,重复文件处理,支持访问回收站等等。 + +#### 安装 google-drive-ocamlfuse + +google-drive-ocamlfuse 能在 Arch 系统的 [AUR][2] 上直接找到,所以你可以使用 AUR 助手程序,如 [Yay][3] 来安装。 + +``` +$ yay -S google-drive-ocamlfuse +``` + +在 Ubuntu 系统: + +``` +$ sudo add-apt-repository ppa:alessandro-strada/ppa +$ sudo apt-get update +$ sudo apt-get install google-drive-ocamlfuse +``` + +安装最新的测试版本: + +``` +$ sudo add-apt-repository ppa:alessandro-strada/google-drive-ocamlfuse-beta +$ sudo apt-get update +$ sudo apt-get install google-drive-ocamlfuse +``` + +#### 使用方法 + +安装完成后,直接在终端里面输入如下命令,就可以启动 google-drive-ocamlfuse 程序了: + +``` +$ google-drive-ocamlfuse +``` + +当你第一次运行该命令,程序会直接打开你的浏览器并要求你确认是否对 Google 云端硬盘的文件的操作进行授权。当你确认授权后,挂载 Google 云端硬盘所需要的配置文件和目录都会自动进行创建。 + +![][5] + +当成功授权后,你会在终端里面看到如下的信息。 + +``` +Access token retrieved correctly. +``` + +好了,我们可以进行下一步操作了。关闭浏览器并为我们的 Google 云端硬盘创建一个挂载点吧。 + +``` +$ mkdir ~/mygoogledrive + +``` + +最后操作,使用如下命令挂载 Google 云端硬盘: + +``` +$ google-drive-ocamlfuse ~/mygoogledrive +``` + +恭喜你了!你可以使用终端或文件管理器来访问 Google 云端硬盘里面的文件了。 + +使用终端: + +``` +$ ls ~/mygoogledrive +``` + +使用文件管理器: + +![][6] + +如何你有不止一个账户,可以使用 `label` 命令对其进行区分不同的账户,就像下面一样: + +``` +$ google-drive-ocamlfuse -label label [mountpoint] +``` + +当操作完成后,你可以使用如下的命令卸载 Google 云端硬盘: + +``` +$ fusermount -u ~/mygoogledrive +``` + +获取更多信息,你可以参考 man 手册。 + +``` +$ google-drive-ocamlfuse --help +``` + +当然你也可以看看[官方文档][7]和该项目的 [GitHub 项目][8]以获取更多内容。 + +### 2. GCSF + +GCSF 是基于 Google 云端硬盘的 FUSE 文件系统,使用 Rust 语言编写。GCSF 得名于罗马尼亚语中的“ **G** oogle **C** onduce **S** istem de **F** ișiere”,翻译成英文就是“Google Drive Filesystem”(即 Google 云端硬盘文件系统)。使用 GCSF,你可以把 Google 云端硬盘当做虚拟磁盘一样挂载到 Linux 系统,可以通过终端和文件管理器对其进行操作。你肯定会很好奇,这到底与其它的 Google 云端硬盘 FUSE 项目有什么不同,比如 google-drive-ocamlfuse。GCSF 的开发者回应 [Reddit 上的类似评论][9]:“GCSF 意在某些方面更快(递归列举文件、从 Google 云端硬盘中读取大文件)。当文件被缓存后,在消耗更多的内存后,其缓存策略也能让读取速度更快(相对于 google-drive-ocamlfuse 4-7 倍的提升)”。 + +#### 安装 GCSF + +GCSF 能在 [AUR][10] 上面找到,对于 Arch 用户来说直接使用 AUR 助手来安装就行了,例如[Yay][3]。 + +``` +$ yay -S gcsf-git +``` + +对于其它的发行版,需要进行如下的操作来进行安装。 + +首先,你得确认系统中是否安装了Rust语言。 + +- [在 Linux 上安装 Rust](https://www.ostechnix.com/install-rust-programming-language-in-linux/) + +确保 `pkg-config` 和 `fuse` 软件包是否安装了。它们在绝大多数的 Linux 发行版的默认仓库中都能找到。例如,在 Ubuntu 及其衍生版本中,你可以使用如下的命令进行安装: + +``` +$ sudo apt-get install -y libfuse-dev pkg-config +``` + +当所有的依赖软件安装完成后,你可以使用如下的命令来安装 GCSF: + +``` +$ cargo install gcsf +``` + +#### 使用方法 + +首先,我们需要对 Google 云端硬盘的操作进行授权,简单输入如下命令: + +``` +$ gcsf login ostechnix +``` + +你必须指定一个会话名称。请使用自己的会话名称来代 `ostechnix`。你会看到像下图的提示信息和Google 云端硬盘账户的授权验证连接。 + +![][11] + +直接复制并用浏览器打开上述 URL,并点击 “allow” 来授权访问你的 Google 云端硬盘账户。当完成授权后,你的终端会显示如下的信息。 + +``` +Successfully logged in. Credentials saved to "/home/sk/.config/gcsf/ostechnix". +``` + +GCSF 会把配置保存文件在 `$XDG_CONFIG_HOME/gcsf/gcsf.toml`,通常位于 `$HOME/.config/gcsf/gcsf.toml`。授权凭证也会保存在此目录当中。 + +下一步,创建一个用来挂载 Google 云端硬盘的目录。 + +``` +$ mkdir ~/mygoogledrive +``` + +之后,修改 `/etc/fuse.conf` 文件: + +``` +$ sudo vi /etc/fuse.conf +``` + +注释掉以下的行,以允许非管理员用 `allow_other` 或 `allow_root` 挂载选项来挂载。 + +``` +user_allow_other +``` + +保存并关闭文件。 + +最后一步,使用如下命令挂载 Google 云端硬盘: + +``` +$ gcsf mount ~/mygoogledrive -s ostechnix +``` + +示例输出: + +``` +INFO gcsf > Creating and populating file system... +INFO gcsf > File sytem created. +INFO gcsf > Mounting to /home/sk/mygoogledrive +INFO gcsf > Mounted to /home/sk/mygoogledrive +INFO gcsf::gcsf::file_manager > Checking for changes and possibly applying them. +INFO gcsf::gcsf::file_manager > Checking for changes and possibly applying them. +``` + +重复一次,使用自己的会话名来更换 `ostechnix`。你可以使用如下的命令来查看已经存在的会话: + +``` +$ gcsf list +Sessions: +- ostechnix +``` + +你现在可以使用终端和文件管理器对 Google 云端硬盘进行操作了。 + +使用终端: + +``` +$ ls ~/mygoogledrive +``` + +使用文件管理器: + +![][12] + +如果你不知道自己把 Google 云端硬盘挂载到哪个目录了,可以使用 `df` 或者 `mount` 命令,就像下面一样。 + +``` +$ df -h +Filesystem Size Used Avail Use% Mounted on +udev 968M 0 968M 0% /dev +tmpfs 200M 1.6M 198M 1% /run +/dev/sda1 20G 7.5G 12G 41% / +tmpfs 997M 0 997M 0% /dev/shm +tmpfs 5.0M 4.0K 5.0M 1% /run/lock +tmpfs 997M 0 997M 0% /sys/fs/cgroup +tmpfs 200M 40K 200M 1% /run/user/1000 +GCSF 15G 857M 15G 6% /home/sk/mygoogledrive + +$ mount | grep GCSF +GCSF on /home/sk/mygoogledrive type fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000,allow_other) +``` + +当操作完成后,你可以使用如下命令来卸载 Google 云端硬盘: + +``` +$ fusermount -u ~/mygoogledrive +``` + +浏览[GCSF GitHub 项目][13]以获取更多内容。 + +### 3、Tuxdrive + +Tuxdrive 也是一个非官方 Linux Google 云端硬盘客户端。我们之前有写过一篇关于 Tuxdrive 比较详细的使用方法。可以查看如下链接: + +- [Tuxdrive: 一个 Linux 下的 Google 云端硬盘客户端](https://www.ostechnix.com/tuxdrive-commandline-google-drive-client-linux/) + +当然,之前还有过其它的非官方 Google 云端硬盘客户端,例如 Grive2、Syncdrive。但它们好像都已经停止开发了。当有更受欢迎的 Google 云端硬盘客户端出现,我会对这个列表进行持续的跟进。 + +谢谢你的阅读。 + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-mount-google-drive-locally-as-virtual-file-system-in-linux/ + +作者:[SK][a] +选题:[lujun9972](https://github.com/lujun9972) +译者:[sndnvaps](https://github.com/sndnvaps) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.ostechnix.com/author/sk/ +[1]:https://www.google.com/drive/ +[2]:https://aur.archlinux.org/packages/google-drive-ocamlfuse/ +[3]:https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ +[4]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[5]:http://www.ostechnix.com/wp-content/uploads/2018/07/google-drive.png +[6]:http://www.ostechnix.com/wp-content/uploads/2018/07/google-drive-2.png +[7]:https://github.com/astrada/google-drive-ocamlfuse/wiki/Configuration +[8]:https://github.com/astrada/google-drive-ocamlfuse +[9]:https://www.reddit.com/r/DataHoarder/comments/8vlb2v/google_drive_as_a_file_system/e1oh9q9/ +[10]:https://aur.archlinux.org/packages/gcsf-git/ +[11]:http://www.ostechnix.com/wp-content/uploads/2018/07/google-drive-3.png +[12]:http://www.ostechnix.com/wp-content/uploads/2018/07/google-drive-4.png +[13]:https://github.com/harababurel/gcsf diff --git a/published/20180809 Two Years With Emacs as a CEO (and now CTO).md b/published/201902/20180809 Two Years With Emacs as a CEO (and now CTO).md similarity index 100% rename from published/20180809 Two Years With Emacs as a CEO (and now CTO).md rename to published/201902/20180809 Two Years With Emacs as a CEO (and now CTO).md diff --git a/published/201902/20181123 Three SSH GUI Tools for Linux.md b/published/201902/20181123 Three SSH GUI Tools for Linux.md new file mode 100644 index 0000000000..d742be9ba8 --- /dev/null +++ b/published/201902/20181123 Three SSH GUI Tools for Linux.md @@ -0,0 +1,144 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: subject: (Three SSH GUI Tools for Linux) +[#]: via: (https://www.linux.com/blog/learn/intro-to-linux/2018/11/three-ssh-guis-linux) +[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen) +[#]: url: (https://linux.cn/article-10559-1.html) + +3 个 Linux 上的 SSH 图形界面工具 +====== + +> 了解一下这三个用于 Linux 上的 SSH 图形界面工具。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh.jpg?itok=3UcXhJt7) + +在你担任 Linux 管理员的职业生涯中,你会使用 Secure Shell(SSH)远程连接到 Linux 服务器或桌面。可能你曾经在某些情况下,会同时 SSH 连接到多个 Linux 服务器。实际上,SSH 可能是 Linux 工具箱中最常用的工具之一。因此,你应该尽可能提高体验效率。对于许多管理员来说,没有什么比命令行更有效了。但是,有些用户更喜欢使用 GUI 工具,尤其是在从台式机连接到远程并在服务器上工作时。 + +如果你碰巧喜欢好的图形界面工具,你肯定很乐于了解一些 Linux 上优秀的 SSH 图形界面工具。让我们来看看这三个工具,看看它们中的一个(或多个)是否完全符合你的需求。 + +我将在 [Elementary OS][1] 上演示这些工具,但它们都可用于大多数主要发行版。 + +### PuTTY + +已经有一些经验的人都知道 [PuTTY][2]。实际上,从 Windows 环境通过 SSH 连接到 Linux 服务器时,PuTTY 是事实上的标准工具。但 PuTTY 不仅适用于 Windows。事实上,通过标准软件库,PuTTY 也可以安装在 Linux 上。 PuTTY 的功能列表包括: + + * 保存会话。 + * 通过 IP 或主机名连接。 + * 使用替代的 SSH 端口。 + * 定义连接类型。 + * 日志。 + * 设置键盘、响铃、外观、连接等等。 + * 配置本地和远程隧道。 + * 支持代理。 + * 支持 X11 隧道。 + +PuTTY 图形工具主要是一种保存 SSH 会话的方法,因此可以更轻松地管理所有需要不断远程进出的各种 Linux 服务器和桌面。一旦连接成功,PuTTY 就会建立一个到 Linux 服务器的连接窗口,你将可以在其中工作。此时,你可能会有疑问,为什么不在终端窗口工作呢?对于一些人来说,保存会话的便利确实使 PuTTY 值得使用。 + +在 Linux 上安装 PuTTY 很简单。例如,你可以在基于 Debian 的发行版上运行命令: + +``` +sudo apt-get install -y putty +``` + +安装后,你可以从桌面菜单运行 PuTTY 图形工具或运行命令 `putty`。在 PuTTY “Configuration” 窗口(图 1)中,在 “HostName (or IP address) ” 部分键入主机名或 IP 地址,配置 “Port”(如果不是默认值 22),从 “Connection type”中选择 SSH,然后单击“Open”。 + +![PuTTY Connection][4] + +*图 1:PuTTY 连接配置窗口* + +建立连接后,系统将提示你输入远程服务器上的用户凭据(图2)。 + +![log in][7] + +*图 2:使用 PuTTY 登录到远程服务器* + +要保存会话(以便你不必始终键入远程服务器信息),请填写主机名(或 IP 地址)、配置端口和连接类型,然后(在单击 “Open” 之前),在 “Saved Sessions” 部分的顶部文本区域中键入名称,然后单击 “Save”。这将保存会话的配置。若要连接到已保存的会话,请从 “Saved Sessions” 窗口中选择它,单击 “Load”,然后单击 “Open”。系统会提示你输入远程服务器上的远程凭据。 + +### EasySSH + +虽然 [EasySSH][8] 没有提供 PuTTY 中的那么多的配置选项,但它(顾名思义)非常容易使用。 EasySSH 的最佳功能之一是它提供了一个标签式界面,因此你可以打开多个 SSH 连接并在它们之间快速切换。EasySSH 的其他功能包括: + + * 分组(出于更好的体验效率,可以对标签进行分组)。 + * 保存用户名、密码。 + * 外观选项。 + * 支持本地和远程隧道。 + +在 Linux 桌面上安装 EasySSH 很简单,因为可以通过 Flatpak 安装应用程序(这意味着你必须在系统上安装 Flatpak)。安装 Flatpak 后,使用以下命令添加 EasySSH: + +``` +sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + +sudo flatpak install flathub com.github.muriloventuroso.easyssh +``` + +用如下命令运行 EasySSH: + +``` +flatpak run com.github.muriloventuroso.easyssh +``` + +将会打开 EasySSH 应用程序,你可以单击左上角的 “+” 按钮。 在结果窗口(图 3)中,根据需要配置 SSH 连接。 + +![Adding a connection][10] + +*图 3:在 EasySSH 中添加连接很简单* + +添加连接后,它将显示在主窗口的左侧导航中(图 4)。 + +![EasySSH][12] + +*图 4:EasySSH 主窗口* + +要在 EasySSH 连接到远程服务器,请从左侧导航栏中选择它,然后单击 “Connect” 按钮(图 5)。 + +![Connecting][14] + +*图 5:用 EasySSH 连接到远程服务器* + +对于 EasySSH 的一个警告是你必须将用户名和密码保存在连接配置中(否则连接将失败)。这意味着任何有权访问运行 EasySSH 的桌面的人都可以在不知道密码的情况下远程访问你的服务器。因此,你必须始终记住在你离开时锁定桌面屏幕(并确保使用强密码)。否则服务器容易受到意外登录的影响。 + +### Terminator + +(LCTT 译注:这个选择不符合本文主题,本节删节) + +### termius + +(LCTT 译注:本节是根据网友推荐补充的) + +termius 是一个商业版的 SSH、Telnet 和 Mosh 客户端,不是开源软件。支持包括 [Linux](https://www.termius.com/linux)、Windows、Mac、iOS 和安卓在内的各种操作系统。对于单一设备是免费的,支持多设备的白金账号需要按月付费。 + +### 很少(但值得)的选择 + +Linux 上没有很多可用的 SSH 图形界面工具。为什么?因为大多数管理员更喜欢简单地打开终端窗口并使用标准命令行工具来远程访问其服务器。但是,如果你需要图形界面工具,则有两个可靠选项,可以更轻松地登录多台计算机。虽然对于那些寻找 SSH 图形界面工具的人来说只有不多的几个选择,但那些可用的工具当然值得你花时间。尝试其中一个,亲眼看看。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/intro-to-linux/2018/11/three-ssh-guis-linux + +作者:[Jack Wallen][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/jlwallen +[b]: https://github.com/lujun9972 +[1]: https://elementary.io/ +[2]: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html +[3]: https://www.linux.com/files/images/sshguis1jpg +[4]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_1.jpg?itok=DiNTz_wO (PuTTY Connection) +[5]: https://www.linux.com/licenses/category/used-permission +[6]: https://www.linux.com/files/images/sshguis2jpg +[7]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_2.jpg?itok=4ORsJlz3 (log in) +[8]: https://github.com/muriloventuroso/easyssh +[9]: https://www.linux.com/files/images/sshguis3jpg +[10]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_3.jpg?itok=bHC2zlda (Adding a connection) +[11]: https://www.linux.com/files/images/sshguis4jpg +[12]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_4.jpg?itok=hhJzhRIg (EasySSH) +[13]: https://www.linux.com/files/images/sshguis5jpg +[14]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_5.jpg?itok=piFEFYTQ (Connecting) +[15]: https://www.linux.com/files/images/sshguis6jpg +[16]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_6.jpg?itok=-kYl6iSE (Terminator) diff --git a/published/201902/20181124 14 Best ASCII Games for Linux That are Insanely Good.md b/published/201902/20181124 14 Best ASCII Games for Linux That are Insanely Good.md new file mode 100644 index 0000000000..cac0934625 --- /dev/null +++ b/published/201902/20181124 14 Best ASCII Games for Linux That are Insanely Good.md @@ -0,0 +1,332 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: subject: (14 Best ASCII Games for Linux That are Insanely Good) +[#]: via: (https://itsfoss.com/best-ascii-games/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) +[#]: url: (https://linux.cn/article-10546-1.html) + +14 个依然很棒的 Linux ASCII 游戏 +====== + +基于文本的(或者我应该说是[基于终端的][1])游戏在十年前非常流行 —— 当时还没有像战神God Of War荒野大镖客:救赎 2Red Dead Redemption 2蜘蛛侠Spiderman这样的视觉游戏大作。 + +当然,Linux 平台有很多好游戏 —— 虽然并不总是“最新和最好”。但是,有一些 ASCII 游戏,却是你永远不会玩腻的。 + +你或许不相信,有一些 ASCII 游戏被证明是非常容易上瘾的(所以,我可能需要一段时间才能继续写下一篇文章,或者我可能会被解雇? —— 帮帮我!) + +哈哈,开个玩笑。让我们来看看最好的 ASCII 游戏吧。 + +**注意:**安装 ASCII 游戏可能要花费不少时间(有些可能会要求你安装其他依赖项或根本不起作用)。你甚至可能会遇到一些需要你从源代码构建的 ASCII 游戏。因此,我们只筛选出那些易于安装和运行的产品 —— 不用费劲。 + +### 在运行和安装 ASCII 游戏之前需要做的事情 + +如果你没有安装的话,某些 ASCII 游戏可能需要你安装 [Simple DirectMedia Layer][2]。因此,以防万一,你应该先尝试安装它,然后再尝试运行本文中提到的任何游戏。 + +要安装它,你需要键入如下命令: + +``` +sudo apt install libsdl2-2.0 +sudo apt install libsdl2_mixer-2.0 +``` + +### Linux 上最好的 ASCII 游戏 + +![Best Ascii games for Linux][3] + +如下列出的游戏排名不分先后。 + +#### 1、战争诅咒 + +![Curse of War ascii games][5] + +[战争诅咒][4]Curse of War是一个有趣的策略游戏。一开始你可能会发现它有点令人困惑,但一旦你掌握了,就会喜欢上它。在启动游戏之前,我建议你在其 [主页][4] 上查看该游戏规则。 + +你将建设基础设施、保护资源并指挥你的军队进行战斗。你所要做的就是把你的旗帜放在一个合适的位置,让你的军队来完成其余的任务。不仅仅是攻击敌人,你还需要管理和保护资源以帮助赢得战斗。 + +如果你之前从未玩过任何 ASCII 游戏,请耐心花一些时间来学习它、体验它的全部潜力。 + +##### 如何安装? + +你可以在官方软件库里找到它。键入如下命令来安装它: + +``` +sudo apt install curseofwar +``` + +#### 2、ASCII 领域 + +![ascii sector][6] + +讨厌策略游戏?不用担心,ASCII 领域ASCII Sector是一款具有空间环境的游戏,可让你进行大量探索。 + +此外,不仅仅局限于探索,你还想要采取一些行动吗?也是可以的。当然,虽然战斗体验不是最好的,但它也很有趣。当你看到各种基地、任务和探索时,会让你更加兴奋。你会在这个小小的游戏中遇到一个练级系统,你必须赚取足够的钱或进行交易才能升级你的宇宙飞船。 + +而这个游戏最好的地方是你可以创建自己的任务,也可以玩其他人的任务。 + +##### 如何安装? + +你需要先从其 [官方网站][7] 下载并解压缩归档包。完成后,打开终端并输入这些命令(将 “Downloads” 文件夹替换为你解压缩文件夹所在的位置,如果解压缩文件夹位于你的主目录中,则忽略它): + +``` +cd Downloads +cd asciisec +chmod +x asciisec +./asciisec +``` + +#### 3、DoomRL + +![doom ascii game][8] + +你肯定知道经典游戏“毁灭战士DOOM”,所以,如果你想把它像 Rogue 类游戏一样略微体验一下,DoomRL 就是适合你的游戏。它是一个基于 ASCII 的游戏,这或许让你想不到。 + +这是一个非常小的游戏,但是可以玩很久。 + +##### 如何安装? + +与你对 “ASCII 领域”所做的类似,你需要从其 [下载页面][9] 下载官方归档文件,然后将其解压缩到一个文件夹。 + +解压缩后,输入以下命令: + +``` +cd Downloads // navigating to the location where the unpacked folder exists +cd doomrl-linux-x64-0997 +chmod +x doomrl +./doomrl +``` + +#### 4、金字塔建造者 + +![Pyramid Builder ascii game for Linux][10] + +金字塔建造者Pyramid Builder 是一款创新的 ASCII 游戏,你可以通过帮助建造金字塔来提升你的文明。 + +你需要指导工人耕种、卸载货物、并移动巨大的石头,以成功建造金字塔。 + +这确实是一个值得下载的 ASCII 游戏。 + +##### 如何安装? + +只需前往其官方网站并下载包以解压缩。提取后,导航到该文件夹并运行可执行文件。 + +``` +cd Downloads +cd pyramid_builder_linux +chmod +x pyramid_builder_linux.x86_64 +./pyramid_builder_linux.x86_64 +``` + +#### 5、DiabloRL + +![Diablo ascii RPG game][11] + +如果你是一位狂热的游戏玩家,你一定听说过暴雪的暗黑破坏神Diablo 1 代,毫无疑问这是一个精彩的游戏。 + +现在你有机会玩一个该游戏的独特演绎版本 —— 一个 ASCII 游戏。DiabloRL 是一款非常棒的基于回合制的 Rogue 类的游戏。你可以从各种职业(战士、巫师或盗贼)中进行选择。每个职业都具有一套不同的属性,可以带来不同游戏体验。 + +当然,个人偏好会有所不同,但它是一个不错的暗黑破坏神“降级版”。你觉得怎么样? + +#### 6、Ninvaders + +![Ninvaders terminal game for Linux][12] + +Ninvaders 是最好的 ASCII 游戏之一,因为它是如此简单,且可以消磨时间的街机游戏。 + +你必须防御入侵者,需要在它们到达之前击败它们。这听起来很简单,但它极具挑战性。 + +##### 如何安装? + +与“战争诅咒”类似,你可以在官方软件库中找到它。所以,只需输入此命令即可安装它: + +``` +sudo apt install ninvaders  +``` + +#### 7、帝国 + +![Empire terminal game][13] + +帝国Empire这是一款即时战略游戏,你需要互联网连接。我个人不是实时战略游戏的粉丝,但如果你是这类游戏的粉丝,你可以看看他们的 [指南][14] 来玩这个游戏,因为学习起来非常具有挑战性。 + +游戏区域包含城市、土地和水。你需要用军队、船只、飞机和其他资源扩展你的城市。通过快速扩张,你可以通过在对方动作之前摧毁它们来捕获其他城市。 + +##### 如何安装? + +安装很简单,只需输入以下命令: + +``` +sudo apt install empire +``` + +#### 8、Nudoku + +![Nudoku is a terminal version game of Sudoku][15] + +喜欢数独游戏?好吧,你也有个 Nudoku 游戏,这是它的克隆。这是当你想放松时的一个完美的消磨时间的 ASCII 游戏。 + +它为你提供三个难度级别:简单、正常和困难。如果你想要挑战电脑,其难度会非常难!如果你只是想放松一下,那么就选择简单难度吧。 + +##### 如何安装? + +安装它很容易,只需在终端输入以下命令: + +``` +sudo apt install nudoku +``` + +#### 9、Nethack + +最好的地下城式 ASCII 游戏之一。如果你已经知道一些 Linux 的 ASCII 游戏,我相信这是你的最爱之一。 + +它具有许多不同的层(约 45 个),并且包含一堆武器、卷轴、药水、盔甲、戒指和宝石。你也可以选择“永久死亡”模式来玩试试。 + +在这里可不仅仅是杀戮,你还有很多需要探索的地方。 + +##### 如何安装? + +只需按照以下命令安装它: + +``` +sudo apt install nethack +``` + +#### 10、ASCII 滑雪 + +![ascii jump game][16] + +ASCII 滑雪ASCII Jump 是一款简单易玩的游戏,你必须沿着各种轨道滑动,同时跳跃、改变位置,并尽可能长时间地移动以达到最大距离。 + +即使看起来很简单,但是看看这个 ASCII 游戏视觉上的表现也是很神奇的。你可以从训练模式开始,然后进入世界杯比赛。你还可以选择你的竞争对手以及你想要开始游戏的山丘。 + +##### 如何安装? + +只需按照以下命令安装它: + +``` +sudo apt install asciijump +``` + +#### 11、Bastet + +![Bastet is tetris game in ascii form][17] + +不要被这个名字误导,它实际上是俄罗斯方块游戏的一个有趣的克隆。 + +你不要觉得它只是另一个普通的俄罗斯方块游戏,它会为你丢下最糟糕的砖块。祝你玩得开心! + +##### 如何安装? + +打开终端并键入如下命令: + +``` +sudo apt install bastet +``` + +#### 12、Bombardier + +![Bomabrdier game in ascii form][18] + +Bombardier 是另一个简单的 ASCII 游戏,它会让你迷上它。 + +在这里,你有一架直升机(或许你想称之为飞机),每一圈它都会降低,你需要投掷炸弹才能摧毁你下面的街区/建筑物。当你摧毁一个街区时,游戏还会在它显示的消息里面添加一些幽默。很好玩。 + +##### 如何安装? + +Bombardier 可以在官方软件库中找到,所以只需在终端中键入以下内容即可安装它: + +``` +sudo apt install bombardier +``` + +#### 13、Angband + +![Angband ascii game][19] + +一个很酷的地下城探索游戏,界面整洁。在探索该游戏时,你可以在一个屏幕上看到所有重要信息。 + +它包含不同种类的种族可供选择角色。你可以是精灵、霍比特人、矮人或其他什么,有十几种可供选择。请记住,你需要在最后击败黑暗之王,所以尽可能升级你的武器并做好准备。 + +##### 如何安装? + +直接键入如下命令: + +``` +sudo apt install angband +``` + +#### 14、GNU 国际象棋 + +![GNU Chess is a chess game that you can play in Linux terminal][20] + +为什么不下盘棋呢?这是我最喜欢的策略游戏了! + +但是,除非你知道如何使用代表的符号来描述下一步行动,否则 GNU 国际象棋可能很难玩。当然,作为一个 ASCII 游戏,它不太好交互,所以它会要求你记录你的移动并显示输出(当它等待计算机思考它的下一步行动时)。 + +##### 如何安装? + +如果你了解国际象棋的代表符号,请输入以下命令从终端安装它: + +``` +sudo apt install gnuchess +``` + +#### 一些荣誉奖 + +正如我之前提到的,我们试图向你推荐最好的(也是最容易在 Linux 机器上安装的那些) ASCII 游戏。 + +然而,有一些标志性的 ASCII 游戏值得关注,它们需要更多的安装工作(你可以获得源代码,但需要构建它/安装它)。 + +其中一些游戏是: + ++ [Cataclysm: Dark Days Ahead][22] ++ [Brogue][23] ++ [Dwarf Fortress][24] + +你可以按照我们的 [从源代码安装软件的完全指南][21] 来进行。 + +### 总结 + +我们提到的哪些 ASCII 游戏适合你?我们错过了你最喜欢的吗? + +请在下面的评论中告诉我们你的想法。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/best-ascii-games/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-command-line-games-linux/ +[2]: https://www.libsdl.org/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/best-ascii-games-featured.png?resize=800%2C450&ssl=1 +[4]: http://a-nikolaev.github.io/curseofwar/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/11/curseofwar-ascii-game.jpg?fit=800%2C479&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/ascii-sector-game.jpg?fit=800%2C424&ssl=1 +[7]: http://www.asciisector.net/download/ +[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/doom-rl-ascii-game.jpg?ssl=1 +[9]: https://drl.chaosforge.org/downloads +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/pyramid-builder-ascii-game.jpg?fit=800%2C509&ssl=1 +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/diablo-rl-ascii-game.jpg?ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/ninvaders-ascii-game.jpg?fit=800%2C426&ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/empire-ascii-game.jpg?fit=800%2C570&ssl=1 +[14]: http://www.wolfpackempire.com/infopages/Guide.html +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/11/nudoku-ascii-game.jpg?fit=800%2C434&ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/11/ascii-jump.jpg?fit=800%2C566&ssl=1 +[17]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/bastet-tetris-clone-ascii.jpg?fit=800%2C465&ssl=1 +[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/11/bombardier.jpg?fit=800%2C571&ssl=1 +[19]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/angband-ascii-game.jpg?ssl=1 +[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/gnuchess-ascii-game.jpg?ssl=1 +[21]: https://linux.cn/article-9172-1.html +[22]: https://github.com/CleverRaven/Cataclysm-DDA +[23]: https://sites.google.com/site/broguegame/ +[24]: http://www.bay12games.com/dwarves/index.html + diff --git a/published/201902/20181204 4 Unique Terminal Emulators for Linux.md b/published/201902/20181204 4 Unique Terminal Emulators for Linux.md new file mode 100644 index 0000000000..0ed7fd1908 --- /dev/null +++ b/published/201902/20181204 4 Unique Terminal Emulators for Linux.md @@ -0,0 +1,153 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10544-1.html) +[#]: subject: (4 Unique Terminal Emulators for Linux) +[#]: via: (https://www.linux.com/blog/learn/2018/12/4-unique-terminals-linux) +[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen) + +4 个独特的 Linux 终端模拟器 +====== + +> 这四个不同的终端模拟器 —— 不仅可以完成工作,还可以增加一些乐趣。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_main.jpg?itok=e6av-5VO) + +让我们面对现实,如果你是 Linux 管理员,那么你要用命令行来工作。为此,你将使用终端模拟器(LCTT 译注:常简称为“终端”,与终端本身的原意不同)。最有可能的是,你选择的发行版预先安装了一个可以完成工作的默认终端模拟器。但这是有很多选择可供选择的 Linux,所以这种思想自然也适用于终端模拟器。实际上,如果你打开发行版的图形界面的包管理器(或从命令行搜索),你将找到大量可能的选择。其中许多是非常简单的工具;然而,有些是真正独特的。 + +在本文中,我将重点介绍四个这样的终端模拟器,它们不仅可以完成工作,而且可以使工作变得更有趣或更好玩。那么,让我们来看看这些终端。 + +### Tilda + +[Tilda][1] 是为 Gtk 设计的,是一种酷炫的下拉终端。这意味着该终端始终运行在后台,可以随时从显示器顶部拉下来(就像 Guake 和 Yakuake)。让 Tilda 超越许多其他产品的原因是该终端可用的配置选项数量(图 1)。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_1.jpg?itok=bra6qb6X) + +可以从标准的软件库安装 Tilda。在基于 Ubuntu(或 Debian)的发行版上,安装非常简单: + +``` +sudo apt-get install tilda -y +``` + +安装完成后,从桌面菜单中打开 Tilda,这也将打开其配置窗口。根据你的喜好配置应用程序,然后关闭配置窗口。然后,你可以通过点击 `F1` 热键来打开和关闭 Tilda。对使用 Tilda 的一个警告是,在第一次运行后,你将找不到有关如何打开配置向导的任何提示。别担心。只要运行命令 `tilda -C`,它将打开配置窗口,同时仍会保留你之前设置的选项。 + +可用选项包括: + +* 终端大小和位置 +* 字体和颜色配置 +* 自动隐藏 +* 标题 +* 自定义命令 +* URL 处理 +* 透明度 +* 动画 +* 滚动 +* 等等 + +我喜欢这些类型的终端是因为当你不需要时它们很容易就会消失,只需按一下按钮即可。对于那些不断进出于终端的人来说,像 Tilda 这样的工具是理想的选择。 + +### Aterm + +Aterm 在我心中占有特殊的位置,因为它是我第一次使用的终端之一,它让我意识到 Linux 的灵活性。 这要回到 AfterStep 成为我选择的窗口管理器时(没用了太久),而且那时我是命令行新手。Aterm 提供的是一个高度可定制的终端仿真器,同时帮助我了解了使用终端的细节(如何给命令添加选项和开关)。或许你会问:“你觉得怎么样?”。因为 Aterm 从未有过用于定制选项的图形界面。要使用任何特殊选项运行 Aterm,必须以命令选项的方式运行。例如,假设你要启用透明度、绿色文本、白色高亮和无滚动条。为此,请运行以下命令: + +``` +aterm -tr -fg green -bg white +xb +``` + +最终结果(`top` 命令运行用于说明)看起来如图 2 所示。 + +![Aterm][3] + +*图 2:使用了一些定制选项的 Aterm* + +当然,你必须先安装 Aterm。幸运的是,这个应用程序仍然可以在标准软件库中找到,因此在 Ubuntu 上安装就像下面这样简单: + +``` +sudo apt-get install aterm -y +``` + +如果你想总是用这些选项打开 Aterm,最好的办法是在 `~/.bashrc` 文件中创建一个别名,如下所示: + +``` +alias=”aterm -tr -fg green -bg white +sb” +``` + +保存该文件,当你运行命令 `aterm` 时,它将始终打开这些选项。有关创建别名的更多信息,请查看[这个教程][5]。 + +### Eterm + +Eterm 是第二个真正告诉我 Linux 命令行可以带来多少乐趣的终端。Eterm 是 Enlightenment 桌面的默认终端模拟器。当我最终从 AfterStep 迁移到 Enlightenment 时(那时早在 20 世纪初),我担心我会失去所有那些很酷的美学选择。结果并非如此。实际上,Eterm 提供了许多独特的选项,同时使用终端工具栏使任务变得更容易。使用 Eterm,你可以通过从 “Background > Pixmap” 菜单条目中轻松地从大量背景图像中选择一个背景(如果你需要一个的话,图 3)。 + +![Eterm][7] + +*图 3:从大量的背景图中为 Eterm 选择一个。* + +还有许多其他配置选项(例如字体大小、映射警报、切换滚动条、亮度、对比度和背景图像的透明度等)。 你要确定的一件事是,在你配置 Eterm 以满足你的口味后,需要单击 “Eterm > Save User Settings”(否则,关闭应用程序时所有设置都将丢失)。 + +可以从标准软件库安装 Eterm,其命令如下: + +``` +sudo apt-get install eterm +``` + +### Extraterm + +[Extraterm][8] 应该可以赢得当今终端窗口项目最酷功能集的一些奖项。Extraterm 最独特的功能是能够以彩色框来包装命令(蓝色表示成功命令,红色表示失败命令。图 4)。 + +![Extraterm][10] + +*图 4:Extraterm 显示有两个失败的命令框。* + +在运行命令时,Extraterm 会将命令包装在一个单独的颜色框中。如果该命令成功,则该颜色框将以蓝色轮廓显示。如果命令失败,框将以红色标出。 + +无法通过标准软件库安装 Extraterm。事实上,在 Linux 上运行 Extraterm(目前)的唯一方法是从该项目的 GitHub 页面[下载预编译的二进制文件][11],解压缩文件,切换到新创建的目录,然后运行命令 `./extraterm`。 + +当该应用程序运行后,要启用颜色框,你必须首先启用 Bash 集成功能。为此,请打开 Extraterm,然后右键单击窗口中的任意位置以显示弹出菜单。滚动,直到看到 “Inject Bash shell Integration” 的条目(图 5)。选择该条目,然后你可以开始使用这个颜色框选项。 + +![Extraterm][13] + +*图 5:为 Extraterm 插入 Bash 集成。。* + +如果你运行了一个命令,并且看不到颜色框,则可能必须为该命令创建一个新的颜色框(因为 Extraterm 仅附带一些默认颜色框)。为此,请单击 “Extraterm” 菜单按钮(窗口右上角的三条水平线),选择 “Settings”,然后单击 “Frames” 选项卡。在此窗口中,向下滚动并单击 “New Rule” 按钮。 然后,你可以添加要使用颜色框的命令(图 6)。 + +![frames][15] + +*图 6:为颜色框添加新规则。* + +如果在此之后仍然没有看到颜色框出现,请从[下载页面][11]下载 `extraterm-commands` 文件,解压缩该文件,切换到新创建的目录,然后运行命令 `sh setup_extraterm_bash.sh`。这应该可以为 Extraterm 启用颜色框。 + +还有更多可用于 Extraterm 的选项。我相信,一旦你开始在终端窗口上玩这个新花招,你就不会想回到标准终端了。希望开发人员可以尽快将这个应用程序提供给标准软件库(因为它很容易就可以成为最流行的终端窗口之一)。 + +### 更多 + +正如你可能预期的那样,Linux 有很多可用的终端。这四个代表四个独特的终端(至少对我来说),每个都可以帮助你运行 Linux 管理员需要运行的命令。如果你对其中一个不满意,用你的包管理器找找有什么可用的软件包。你一定会找到适合你的东西。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2018/12/4-unique-terminals-linux + +作者:[Jack Wallen][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/jlwallen +[b]: https://github.com/lujun9972 +[1]: http://tilda.sourceforge.net/tildadoc.php +[2]: https://www.linux.com/files/images/terminals2jpg +[3]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_2.jpg?itok=gBkRLwDI (Aterm) +[4]: https://www.linux.com/licenses/category/used-permission +[5]: https://www.linux.com/blog/learn/2018/12/aliases-diy-shell-commands +[6]: https://www.linux.com/files/images/terminals3jpg +[7]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_3.jpg?itok=RVPTJAtK (Eterm) +[8]: http://extraterm.org +[9]: https://www.linux.com/files/images/terminals4jpg +[10]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_4.jpg?itok=2n01qdwO (Extraterm) +[11]: https://github.com/sedwards2009/extraterm/releases +[12]: https://www.linux.com/files/images/terminals5jpg +[13]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_5.jpg?itok=FdaE1Mpf (Extraterm) +[14]: https://www.linux.com/files/images/terminals6jpg +[15]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_6.jpg?itok=lQ1Zv5wq (frames) diff --git a/published/20181212 Top 5 configuration management tools.md b/published/201902/20181212 Top 5 configuration management tools.md similarity index 100% rename from published/20181212 Top 5 configuration management tools.md rename to published/201902/20181212 Top 5 configuration management tools.md diff --git a/sources/tech/20181219 PowerTOP - Monitors Power Usage and Improve Laptop Battery Life in Linux.md b/published/201902/20181219 PowerTOP - Monitors Power Usage and Improve Laptop Battery Life in Linux.md similarity index 87% rename from sources/tech/20181219 PowerTOP - Monitors Power Usage and Improve Laptop Battery Life in Linux.md rename to published/201902/20181219 PowerTOP - Monitors Power Usage and Improve Laptop Battery Life in Linux.md index a615ffc73a..9a08e5216e 100644 --- a/sources/tech/20181219 PowerTOP - Monitors Power Usage and Improve Laptop Battery Life in Linux.md +++ b/published/201902/20181219 PowerTOP - Monitors Power Usage and Improve Laptop Battery Life in Linux.md @@ -1,76 +1,68 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10560-1.html) [#]: subject: (PowerTOP – Monitors Power Usage and Improve Laptop Battery Life in Linux) [#]: via: (https://www.2daygeek.com/powertop-monitors-laptop-battery-usage-linux/) [#]: author: (Vinoth Kumar https://www.2daygeek.com/author/vinoth/) -PowerTOP – Monitors Power Usage and Improve Laptop Battery Life in Linux +PowerTOP:在 Linux 上监视电量使用和改善笔记本电池寿命 ====== -We all know, we almost 80-90% migrated from PC (Desktop) to laptop. +我们都知道,现在几乎都从 PC 机换到了笔记本电脑了。但是使用笔记本有个问题,我们希望电池耐用,我们可以使用到每一点电量。所以,我们需要知道电量都去哪里了,是不是浪费了。 -But one thing we want from a laptop, it’s long battery life and we want to use every drop of power. +你可以使用 PowerTOP 工具来查看没有接入电源线时电量都用在了何处。你需要在终端中使用超级用户权限来运行 PowerTOP 工具。它可以访问该电池硬件并测量电量使用情况。 -So it’s good to know where our power is going and getting waste. +### 什么是 PowerTOP -You can use the powertop utility to see what’s drawing power when your system’s not plugged in. +PowerTOP 是一个 Linux 工具,用于诊断电量消耗和电源管理的问题。 -You need to run the powertop utility in terminal with super user privilege. +它是由 Intel 开发的,可以在内核、用户空间和硬件中启用各种节电模式。 -It will access the hardware and measure power usage. +除了作为一个一个诊断工具之外,PowweTop 还有一个交互模式,可以让你实验 Linux 发行版没有启用的各种电源管理设置。 -### What is PowerTOP +它也能监控进程,并展示其中哪个正在使用 CPU,以及从休眠状态页将其唤醒,也可以找出电量消耗特别高的应用程序。 -PowerTOP is a Linux tool to diagnose issues with power consumption and power management. +### 如何安装 PowerTOP -It was developed by Intel to enable various power-saving modes in kernel, userspace, and hardware. +PowerTOP 软件包在大多数发行版的软件库中可用,使用发行版的 [包管理器][1] 安装即可。 -In addition to being a diagnostic tool, PowerTOP also has an interactive mode where the user can experiment various power management settings for cases where the Linux distribution has not enabled these settings. - -It is possible to monitor processes and show which of them are utilizing the CPU and wake it from its Idle-States, allowing to identify applications with particular high power demands. - -### How to Install PowerTOP - -PowerTOP package is available in most of the distributions official repository so, use the distributions **[Package Manager][1]** to install it. - -For **`Fedora`** system, use **[DNF Command][2]** to install PowerTOP. +对于 Fedora 系统,使用 [DNF 命令][2] 来安装 PowerTOP。 ``` $ sudo dnf install powertop ``` -For **`Debian/Ubuntu`** systems, use **[APT-GET Command][3]** or **[APT Command][4]** to install PowerTOP. +对于 Debian/Ubuntu 系统,使用 [APT-GET 命令][3] 或 [APT 命令][4] 来安装 PowerTOP。 ``` $ sudo apt install powertop ``` -For **`Arch Linux`** based systems, use **[Pacman Command][5]** to install PowerTOP. +对于基于 Arch Linux 的系统,使用 [Pacman 命令][5] 来安装 PowerTOP。 ``` $ sudo pacman -S powertop ``` -For **`RHEL/CentOS`** systems, use **[YUM Command][6]** to install PowerTOP. +对于 RHEL/CentOS 系统,使用 [YUM 命令][6] 来安装 PowerTOP。 ``` $ sudo yum install powertop ``` -For **`openSUSE Leap`** system, use **[Zypper Command][7]** to install PowerTOP. +对于 openSUSE Leap 系统,使用 [Zypper 命令][7] 来安装 PowerTOP。 ``` $ sudo zypper install powertop ``` -### How To Access PowerTOP +### 如何使用 PowerTOP -PowerTOP requires super user privilege so, run as root to use PowerTOP utility on your Linux system. +PowerTOP 需要超级用户权限,所以在 Linux 系统中以 root 身份运行 PowerTOP 工具。 -By default it shows `Overview` tab where we can see the power usage consumption for all the devices. Also shows your system wakeups seconds. +默认情况下其显示 “概览” 页,在这里我们可以看到所有设备的电量消耗情况,也可以看到系统的唤醒秒数。 ``` $ sudo powertop @@ -132,11 +124,11 @@ Summary: 1692.9 wakeups/second, 0.0 GPU ops/seconds, 0.0 VFS ops/sec and 54.9% Exit | / Navigate | ``` -The powertop output looks similar to the above screenshot, it will be slightly different based on your hardware. This have many screen you can switch between screen the using `Tab` and `Shift+Tab` button. +PowerTOP 的输出类似如上截屏,在你的机器上由于硬件不同会稍有不同。它的显示有很多页,你可以使用 `Tab` 和 `Shift+Tab` 在它们之间切换。 -### Idle Stats Tab +### 空闲状态页 -It displays various information about the processor. +它会显示处理器的各种信息。 ``` PowerTOP v2.9 Overview Idle stats Frequency stats Device stats Tunables @@ -194,9 +186,9 @@ C10 (pc10) 0.0% | | C10 39.5% 4.7 ms 41.4% Exit | / Navigate | ``` -### Frequency Stats Tab +### 频率状态页 -It displays the frequency of CPU. +它会显示 CPU 的主频。 ``` PowerTOP v2.9 Overview Idle stats Frequency stats Device stats Tunables @@ -220,9 +212,9 @@ Idle | Idle | Idle ``` -### Device Stats Tab +### 设备状态页 -It displays power usage information against only devices. +它仅针对设备显示其电量使用信息。 ``` PowerTOP v2.9 Overview Idle stats Frequency stats Device stats Tunables @@ -277,12 +269,12 @@ The power consumed was 280 J 0.0% runtime-coretemp.0 0.0% runtime-alarmtimer - Exit | / Navigate | + Exit | / Navigate | ``` -### Tunables Stats Tab +### 可调整状态页 -This tab is important area that provides suggestions to optimize your laptop battery. +这个页面是个重要区域,可以为你的笔记本电池优化提供建议。 ``` PowerTOP v2.9 Overview Idle stats Frequency stats Device stats Tunables @@ -340,9 +332,9 @@ PowerTOP v2.9 Overview Idle stats Frequency stats Device stats Tunab Exit | Toggle tunable | Window refresh ``` -### How To Generate PowerTop HTML Report +### 如何生成 PowerTop 的 HTML 报告 -Run the following command to generate the PowerTop HTML report. +运行如下命令生成 PowerTop 的 HTML 报告。 ``` $ sudo powertop --html=powertop.html @@ -363,12 +355,13 @@ Taking 1 measurement(s) for a duration of 20 second(s) each. PowerTOP outputing using base filename powertop.html ``` -Navigate to `file:///home/daygeek/powertop.html` file to access the generated PowerTOP HTML report. +打开 `file:///home/daygeek/powertop.html` 文件以访问生成的 PowerTOP 的 HTML 报告。 + ![][9] -### Auto-Tune mode +### 自动调整模式 -This feature sets all tunable options from `BAD` to `GOOD` which increase the laptop battery life in Linux. +这个功能可以将所有可调整选项从 BAD 设置为 GOOD,这可以提升 Linux 中的笔记本电池寿命。 ``` $ sudo powertop --auto-tune @@ -393,8 +386,8 @@ via: https://www.2daygeek.com/powertop-monitors-laptop-battery-usage-linux/ 作者:[Vinoth Kumar][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/translated/tech/20181224 An Introduction to Go.md b/published/201902/20181224 An Introduction to Go.md similarity index 61% rename from translated/tech/20181224 An Introduction to Go.md rename to published/201902/20181224 An Introduction to Go.md index 04adb076dc..40504b2796 100644 --- a/translated/tech/20181224 An Introduction to Go.md +++ b/published/201902/20181224 An Introduction to Go.md @@ -1,30 +1,30 @@ [#]: collector: (lujun9972) [#]: translator: (LazyWolfLin) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10521-1.html) [#]: subject: (An Introduction to Go) [#]: via: (https://blog.jak-linux.org/2018/12/24/introduction-to-go/) [#]: author: (Julian Andres Klode https://blog.jak-linux.org/) -Go 简介 +Go 编程语言的简单介绍 ====== -(以下内容是我的硕士论文的摘录,几乎整个 2.1 章节,向具有 CS 背景的人快速介绍 Go) +(以下内容是我的硕士论文的摘录,几乎是整个 2.1 章节,向具有 CS 背景的人快速介绍 Go) -Go 是一门用于并发编程的命令式编程语言,它主要由创造者 Google 进行开发,最初主要由 Robert Griesemer、Rob Pike 和 Ken Thompson开发。这门语言的设计起始于 2017 年,并在 2019 年推出最初版本;而第一个稳定版本是 2012 年发布的 1.0 版本。 +Go 是一门用于并发编程的命令式编程语言,它主要由创造者 Google 进行开发,最初主要由 Robert Griesemer、Rob Pike 和 Ken Thompson 开发。这门语言的设计起始于 2007 年,并在 2009 年推出最初版本;而第一个稳定版本是 2012 年发布的 1.0 版本。[^1] -Go 有 C 风格的语法(没有预处理器),垃圾回收机制,而且类似它在贝尔实验室里被开发出来的前辈们:Newsqueak (Rob Pike)、Alef (Phil Winterbottom) 和 Inferno (Pike, Ritchie, et al.),使用所谓的 goroutines 和信道(一种基于 Hoare 的“通信顺序进程”理论的协程)提供内建的并发支持。 +Go 有 C 风格的语法(没有预处理器)、垃圾回收机制,而且类似它在贝尔实验室里被开发出来的前辈们:Newsqueak(Rob Pike)、Alef(Phil Winterbottom)和 Inferno(Pike、Ritchie 等人),使用所谓的 Go 协程goroutines信道channels(一种基于 Hoare 的“通信顺序进程”理论的协程)提供内建的并发支持。[^2] Go 程序以包的形式组织。包本质是一个包含 Go 文件的文件夹。包内的所有文件共享相同的命名空间,而包内的符号有两种可见性:以大写字母开头的符号对于其他包是可见,而其他符号则是该包私有的: ``` func PublicFunction() { - fmt.Println("Hello world") + fmt.Println("Hello world") } func privateFunction() { - fmt.Println("Hello package") + fmt.Println("Hello package") } ``` @@ -32,25 +32,16 @@ func privateFunction() { Go 有一个相当简单的类型系统:没有子类型(但有类型转换),没有泛型,没有多态函数,只有一些基本的类型: - 1. 基本类型:`int`、`int64`、`int8`、`uint`、`float32`、`float64` 等。 - + 1. 基本类型:`int`、`int64`、`int8`、`uint`、`float32`、`float64` 等 2. `struct` - - 3. `interface` \- 一组方法的集合 - - 4. `map[K, V]` \- 一个从键类型到值类型的映射 - - 5. `[number]Type` \- 一些 Type 类型的元素组成的数组 - - 6. `[]Type` \- 某种类型的切片(指向具有长度和功能的数组) - - 7. `chan Type` \- 一个线程安全的队列 - + 3. `interface`:一组方法的集合 + 4. `map[K, V]`:一个从键类型到值类型的映射 + 5. `[number]Type`:一些 Type 类型的元素组成的数组 + 6. `[]Type`:某种类型的切片(具有长度和功能的数组的指针) + 7. `chan Type`:一个线程安全的队列 8. 指针 `*T` 指向其他类型 - 9. 函数 - - 10. 具名类型 - 可能具有关联方法的其他类型的别名(译者注:这里的别名并非指 Go 1.9 中的新特性“类型别名”): + 10. 具名类型:可能具有关联方法的其他类型的别名(LCTT 译注:这里的别名并非指 Go 1.9 中的新特性“类型别名”): ``` type T struct { foo int } @@ -58,9 +49,9 @@ Go 有一个相当简单的类型系统:没有子类型(但有类型转换 type T OtherNamedType ``` - 具名类型完全不同于他们的底层类型,所以你不能让他们互相赋值,但一些运输符,例如 `+`,能够处理同一底层数值类型的具名类型对象们(所以你可以在上面的示例中把两个 `T` 加起来)。 + 具名类型完全不同于它们的底层类型,所以你不能让它们互相赋值,但一些操作符,例如 `+`,能够处理同一底层数值类型的具名类型对象们(所以你可以在上面的示例中把两个 `T` 加起来)。 -Maps、slices 和 channels 是类似于引用的类型——他们实际上是包含指针的结构。包括数组(具有固定长度并可被拷贝)在内的其他类型则是值(拷贝)传递。 +映射、切片和信道是类似于引用的类型——它们实际上是包含指针的结构。包括数组(具有固定长度并可被拷贝)在内的其他类型则是值传递(拷贝)。 #### 类型转换 @@ -93,66 +84,60 @@ const bar2 someType = typed // error: int 不能被赋值给 someType ### 接口和对象 -正如上面所说的,接口是一组方法的集合。Go 本身不是一种面向对象的语言,但它支持将方法关联到命名类型上:当声明一个函数时,可以提供一个接收者。接收者是函数的一个额外参数,可以在函数之前传递并参与函数查找,就像这样: +正如上面所说的,接口是一组方法的集合。Go 本身不是一种面向对象的语言,但它支持将方法关联到具名类型上:当声明一个函数时,可以提供一个接收者。接收者是函数的一个额外参数,可以在函数之前传递并参与函数查找,就像这样: ``` type SomeType struct { ... } +type SomeType struct { ... } func (s *SomeType) MyMethod() { } func main() { - var s SomeType - s.MyMethod() + var s SomeType + s.MyMethod() } ``` -如果对象实现了所有方法,那么它就实现了接口;例如,`*SomeType`(注意指针)实现了下面的接口 `MyMethoder`,因此 `*SomeType` 类型的值就能作为 `MyMethoder` 类型的值使用。最基本的接口类型是 `interface{}`,它是一个带空方法集的接口——任何对象都满足该接口。 +如果对象实现了所有方法,那么它就实现了接口;例如,`*SomeType`(注意指针)实现了下面的接口 `MyMethoder`,因此 `*SomeType` 类型的值就能作为 `MyMethoder` 类型的值使用。最基本的接口类型是 `interface{}`,它是一个带空方法集的接口 —— 任何对象都满足该接口。 ``` type MyMethoder interface { - MyMethod() + MyMethod() } ``` -合法的接收者类型是有些限制的;例如,命名类型可以是指针类型(例如,`type MyIntPointer *int`),但这种类型不是合法的接收者类型。 +合法的接收者类型是有些限制的;例如,具名类型可以是指针类型(例如,`type MyIntPointer *int`),但这种类型不是合法的接收者类型。 ### 控制流 Go 提供了三个主要的控制了语句:`if`、`switch` 和 `for`。这些语句同其他 C 风格语言内的语句非常类似,但有一些不同: * 条件语句没有括号,所以条件语句是 `if a == b {}` 而不是 `if (a == b) {}`。大括号是必须的。 - - * 所有的语句都可以有初始化,比如这个 - - `if result, err := someFunction(); err == nil { // use result }` - - * `switch` 语句在 cases 里可以使用任何表达式 - - * `switch` 语句可以处理空的表达式(等于 true) - - * 默认情况下,Go 不会从一个 case 进入下一个 case(不需要 `break`语句),在程序块的末尾使用 `fallthrough` 则会进入下一个 case。 - + * 所有的语句都可以有初始化,比如这个 `if result, err := someFunction(); err == nil { // use result }` + * `switch` 语句在分支里可以使用任何表达式 + * `switch` 语句可以处理空的表达式(等于 `true`) + * 默认情况下,Go 不会从一个分支进入下一个分支(不需要 `break` 语句),在程序块的末尾使用 `fallthrough` 则会进入下一个分支。 * 循环语句 `for` 不仅能循环值域:`for key, val := range map { do something }` -### Goroutines +### Go 协程 -关键词 `go` 会产生一个新的 goroutine,一个可以并行执行的函数。它可以用于任何函数调用,甚至一个匿名函数: +关键词 `go` 会产生一个新的 Go 协程goroutine,这是一个可以并行执行的函数。它可以用于任何函数调用,甚至一个匿名函数: ``` func main() { - ... - go func() { - ... - }() + ... + go func() { + ... + }() - go some_function(some_argument) + go some_function(some_argument) } ``` ### 信道 -Goroutines 通常和信道结合,用来提供一种通信顺序进程的扩展。信道是一个并发安全的队列,而且可以选择是否缓冲数据: +Go 协程通常和信道channels结合,用来提供一种通信顺序进程的扩展。信道是一个并发安全的队列,而且可以选择是否缓冲数据: ``` var unbuffered = make(chan int) // 直到数据被读取时完成数据块发送 @@ -170,21 +155,21 @@ otherChannel <- valueToSend ``` select { - case incoming := <- inboundChannel: - // 一条新消息 - case outgoingChannel <- outgoing: - // 可以发送消息 + case incoming := <- inboundChannel: + // 一条新消息 + case outgoingChannel <- outgoing: + // 可以发送消息 } ``` -### `defer` 声明 +### defer 声明 Go 提供语句 `defer` 允许函数退出时调用执行预定的函数。它可以用于进行资源释放操作,例如: ``` func myFunc(someFile io.ReadCloser) { - defer someFile.close() - /* 文件相关操作 */ + defer someFile.close() + /* 文件相关操作 */ } ``` @@ -199,7 +184,7 @@ func Read(p []byte) (n int, err error) // 内建类型: type error interface { - Error() string + Error() string } ``` @@ -209,7 +194,7 @@ type error interface { n0, _ := Read(Buffer) // 忽略错误 n, err := Read(buffer) if err != nil { - return err + return err } ``` @@ -217,21 +202,21 @@ if err != nil { ``` func Function() (err error) { - defer func() { - s := recover() - switch s := s.(type) { // type switch - case error: - err = s // s has type error now - default: - panic(s) + defer func() { + s := recover() + switch s := s.(type) { // type switch + case error: + err = s // s has type error now + default: + panic(s) + } } - } } ``` ### 数组和切片 -正如前边说的,数组是值类型而切片是指向数组的指针。切片可以由现有的数组切片产生,也可以使用 `make()` 创建切片,这会创建一个匿名数组以保存元素。 +正如前边说的,数组是值类型,而切片是指向数组的指针。切片可以由现有的数组切片产生,也可以使用 `make()` 创建切片,这会创建一个匿名数组以保存元素。 ``` slice1 := make([]int, 2, 5) // 分配 5 个元素,其中 2 个初始化为0 @@ -250,15 +235,19 @@ slice = append(slice, arrayOrSlice...) 切片也可以用于函数的变长参数。 -### Maps +### 映射 -Maps 是简单的键值对储存容器并支持索引和分配。但它们不是线程安全的。 +映射maps是简单的键值对储存容器,并支持索引和分配。但它们不是线程安全的。 ``` someValue := someMap[someKey] someValue, ok := someMap[someKey] // 如果键值不在 someMap 中,变量 ok 会赋值为 `false` someMap[someKey] = someValue ``` + +[^1]: Frequently Asked Questions (FAQ) - The Go Programming Language https://golang.org/doc/faq#history [return] +[^2]: HOARE, Charles Antony Richard. Communicating sequential processes. Communications of the ACM, 1978, 21. Jg., Nr. 8, S. 666-677. [return] + -------------------------------------------------------------------------------- via: https://blog.jak-linux.org/2018/12/24/introduction-to-go/ @@ -266,7 +255,7 @@ via: https://blog.jak-linux.org/2018/12/24/introduction-to-go/ 作者:[Julian Andres Klode][a] 选题:[lujun9972][b] 译者:[LazyWolfLin](https://github.com/LazyWolfLin) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/201902/20181224 Go on an adventure in your Linux terminal.md b/published/201902/20181224 Go on an adventure in your Linux terminal.md new file mode 100644 index 0000000000..2bdaef9bd7 --- /dev/null +++ b/published/201902/20181224 Go on an adventure in your Linux terminal.md @@ -0,0 +1,54 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10537-1.html) +[#]: subject: (Go on an adventure in your Linux terminal) +[#]: via: (https://opensource.com/article/18/12/linux-toy-adventure) +[#]: author: (Jason Baker https://opensource.com/users/jason-baker) + +在 Linux 终端上进行冒险 +====== + +> 我们的 Linux 命令行玩具日历的最后一天以一场盛大冒险结束。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-advent.png?itok=OImUJJI5) + +今天是我们为期 24 天的 Linux 命令行玩具日历的最后一天。希望你一直有在看,但如果没有,请[从头开始][1],继续努力。你会发现 Linux 终端有很多游戏、消遣和奇怪之处。 + +虽然你之前可能已经看过我们日历中的一些玩具,但我们希望对每个人而言至少有一件新东西。 + +今天的玩具是由 Opensource.com 管理员 [Joshua Allen Holm][2] 提出的: + +> “如果你的冒险日历的最后一天不是 ESR(Eric S. Raymond)的[开源版的 Adventure 游戏][3] —— 它仍然使用经典的 `advent` 命令(在 BSD 游戏包中的 `adventure`) ,我会非常非常非常失望 ;-)“ + +这是结束我们这个系列的完美方式。 + +巨洞冒险Colossal Cave Adventure(通常简称 Adventure),是一款来自 20 世纪 70 年代的基于文本的游戏,它引领产生了冒险游戏这个类型的游戏。尽管它很古老,但是当探索幻想世界时,Adventure 仍然是一种轻松消耗时间的方式,就像龙与地下城那样,地下城主可能会引导你穿过一个充满想象的地方。 + +与其带你了解 Adventure 的历史,我鼓励你去阅读 Joshua 的[该游戏的历史][4]这篇文章,以及为什么它几年前会重新复活,并且被重新移植。接着,[克隆它的源码][5]并按照[安装说明][6]在你的系统上使用 `advent` 启动游戏。或者,像 Joshua 提到的那样,可以从 bsd-games 包中获取该游戏的另一个版本,该软件包可能存在于你的发行版中的默认仓库。 + +你有喜欢的命令行玩具认为我们应该介绍么?今天我们的系列结束了,但我们仍然乐于在新的一年中介绍一些很酷的命令行玩具。请在下面的评论中告诉我,我会查看一下。让我知道你对今天玩具的看法。 + +一定要看看昨天的玩具,[能从远程获得乐趣的 Linux 命令][7],明年再见! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/18/12/linux-toy-adventure + +作者:[Jason Baker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/jason-baker +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/article/18/12/linux-toy-boxes +[2]: https://opensource.com/users/holmja +[3]: https://gitlab.com/esr/open-adventure (https://gitlab.com/esr/open-adventure) +[4]: https://opensource.com/article/17/6/revisit-colossal-cave-adventure-open-adventure +[5]: https://gitlab.com/esr/open-adventure +[6]: https://gitlab.com/esr/open-adventure/blob/master/INSTALL.adoc +[7]: https://opensource.com/article/18/12/linux-toy-remote diff --git a/sources/tech/20181227 Asciinema - Record And Share Your Terminal Sessions On The Fly.md b/published/201902/20181227 Asciinema - Record And Share Your Terminal Sessions On The Fly.md similarity index 56% rename from sources/tech/20181227 Asciinema - Record And Share Your Terminal Sessions On The Fly.md rename to published/201902/20181227 Asciinema - Record And Share Your Terminal Sessions On The Fly.md index 20bcfbe26d..7de035fe34 100644 --- a/sources/tech/20181227 Asciinema - Record And Share Your Terminal Sessions On The Fly.md +++ b/published/201902/20181227 Asciinema - Record And Share Your Terminal Sessions On The Fly.md @@ -1,92 +1,84 @@ [#]: collector: (lujun9972) [#]: translator: (bestony) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10520-1.html) [#]: subject: (Asciinema – Record And Share Your Terminal Sessions On The Fly) [#]: via: (https://www.2daygeek.com/linux-asciinema-record-your-terminal-sessions-share-them-on-web/) [#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) -Asciinema – Record And Share Your Terminal Sessions On The Fly +Asciinema:在云端记录并分享你的终端会话 ====== -This is known topic and we had already written so many article about this topic. +这个众所周知的话题我们早已经写过了足够多的文章。即使这样,我们今天也要去讨论相同的话题。 -Even today also we are going to discuss about the same topic. +其他的工具都是在本地运行的,但是 Asciinema 可以以相同的方式在本地和 Web 端运行。我的意思是我们可以在 Web 上分享这个录像。 -Other tools are works locally but Asciinema works in both way like local and web. +默认情况下,每个人都更愿意使用 `history` 命令来回看、调用之前在终端内输入的命令。不过,不行的是,这个命令只展示了我们运行的命令却没有展示这些命令上次运行时的输出。 -I mean we can share the recording on the web. +在 Linux 下有很多的组件来记录终端会话活动。在过去,我们也写了一些组件,不过今天我们依然要讨论这同一类心的工具。 -By default everyone prefer history command to review/recall the previously entered commands in terminal. +如果你想要使用其他工具来记录你的 Linux 终端会话活动,你可以试试 [Script 命令][1]、[Terminalizer 工具][2] 和 [Asciinema 工具][3]。 -But unfortunately, that shows only the commands that we ran and doesn’t shows the commands output which was performed previously. +不过如果你想要找一个 [GIF 录制工具][4],可以试试 [Gifine][5]、[Kgif][6] 和 [Peek][7]。 -There are many utilities available in Linux to record the terminal session activity. +### 什么是 Asciinema -Also, we had written about few utilities in the past and today also we are going to discuss about the same kind of topic. +`asciinema` 是一个自由开源的用于录制终端会话并将它们分享到网络上的解决方案。 -If you would like to check other utilities to record your Linux terminal session activity then you can give a try to **[Script Command][1]** , **[Terminalizer Tool][2]** and **[Asciinema Tool][3]**. +当你在你的终端内运行 `asciinema rec` 来启动录像时,你输入命令的时候,终端内的所有输出都会被抓取。 -But if you are looking for **[GIF Recorder][4]** then try **[Gifine][5]** , **[Kgif][6]** and **[Peek][7]** utilities. +当抓取停止时(通过按下 `Ctrl-D` 或输出 `exit`),抓取的输出将会被上传到 asciinema.org 的网站,并为后续的回放做准备。 -### What is Asciinema +Asciinema 项目由多个不同的完整的部分组成,比如 `asciinema` 命令行工具、asciinema.org API 和 JavaScript 播放器。 -asciinema is a free and open source solution for recording terminal sessions and sharing them on the web. +Asciinema 的灵感来自于 `script` 和 `scriptreplay` 命令。 -When you run asciinema rec in your terminal the recording starts, capturing all output that is being printed to your terminal while you’re issuing the shell commands. +### 如何在 Linux 上安装 Asciinema -When the recording finishes (by hitting `Ctrl-D` or typing `exit`) then the captured output is uploaded to asciinema.org website and prepared for playback on the web. +Asciinema 由 Python 写就,在 Linux 上,推荐使用 `pip` 安装的方法来安装。 -Asciinema project is built of several complementary pieces such as asciinema command line tool, API at asciinema.org and javascript player. +确保你已经在你的系统里安装了 python-pip 包。如果没有,使用下述命令来安装它。 -Asciinema was inspired by script and scriptreplay commands. - -### How to Install Asciinema In Linux - -It was written in Python and pip installation is a recommended method to install Asciinema on Linux. - -Make sure you should have installed python-pip package on your system. If no, use the following command to install it. - -For Debian/Ubuntu users, use **[Apt Command][8]** or **[Apt-Get Command][9]** to install pip package. +对于 Debian/Ubuntu 用户,使用 [Apt 命令][8] 或 [Apt-Get 命令][9] 来安装 pip 包。 ``` $ sudo apt install python-pip ``` -For Archlinux users, use **[Pacman Command][10]** to install pip package. +对于 Archlinux 用户,使用 [Pacman 命令][10] 来安装 pip 包。 ``` $ sudo pacman -S python-pip ``` -For Fedora users, use **[DNF Command][11]** to install pip package. +对于 Fedora 用户,使用 [DNF 命令][11] 来安装 pip 包。 ``` $ sudo dnf install python-pip ``` -For CentOS/RHEL users, use **[YUM Command][12]** to install pip package. +对于 CentOS/RHEL 用户,使用 [YUM 命令][12] 来安装 pip 包。 ``` $ sudo yum install python-pip ``` -For openSUSE users, use **[Zypper Command][13]** to install pip package. +对于 openSUSE 用户,使用 [Zypper 命令][13] 来安装 pip 包。 ``` $ sudo zypper install python-pip ``` -Finally run the following **[pip command][14]** to install Asciinema tool in Linux. +最后,运行如下的 [pip 命令][14] 来在 Linux 上安装 Asciinema 工具。 ``` $ sudo pip3 install asciinema ``` -### How to Record Your Terminal Session Using Asciinema +### 如何使用 Asciinema 工具来记录你的终端会话 -Once you successfully installed Asciinema. Just run the following command to start recording. +一旦你成功的安装了 Asciinema,只需要运行如下命令来开始录制: ``` $ asciinema rec 2g-test @@ -94,7 +86,7 @@ asciinema: recording asciicast to 2g-test asciinema: press "ctrl-d" or type "exit" when you're done ``` -For testing purpose run few commands and see whether it’s working fine or not. +出于测试的目的,运行一些简单的命令,并看一看它是否运行良好。 ``` $ free @@ -141,10 +133,10 @@ L1i cache: 32K L2 cache: 256K L3 cache: 6144K NUMA node0 CPU(s): 0-7 -Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d +Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_add fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d ``` -Once you have done, simple press `CTRL+D` or type `exit` to stop the recording. The result will be saved in the same directory. +当你完成后,简单的按下 `CTRL+D` 或输入 `exit` 来退出录制。这个结果将会被保存在同一个目录。 ``` $ exit @@ -153,41 +145,41 @@ asciinema: recording finished asciinema: asciicast saved to 2g-test ``` -If you would like to save the output in the different directory then mention the path where you want to save the file. +如果你想要保存输出到不同的目录中,就需要提醒 Asciinema 你想要保存文件的目录。 ``` $ asciinema rec /opt/session-record/2g-test1 ``` -We can play the recorded session using the following command. +我们可以使用如下命令来回放录制的会话。 ``` $ asciinema play 2g-test ``` -We can play the recorded session with double speed. +我们能够以两倍速来回放录制的会话。 ``` $ asciinema play -s 2 2g-test ``` -Alternatively we can play the recorded session with normal speed with idle time limited to 2 seconds. +或者,我们可以以正常速度播放录制的会话,限制空闲时间为 2 秒。 ``` $ asciinema play -i 2 2g-test ``` -### How To Share the Recorded Session on The Web +### 如何在网络上分享已经录制的会话 -If you would like to share the recorded session with your friends, just run the following command which upload the recording to asciinema.org and provide you the unique link. +如果你想要分享录制的会话给你的朋友,只要运行下述命令上传你的会话到 asciinema.org,就可以获得一个唯一链接。 -It will be automatically archived 7 days after upload. +它将会在被上传 7 天后被归档。 ``` $ asciinema upload 2g-test View the recording at: - https://asciinema.org/a/jdJrxhDLboeyrhzZRHsve0x8i + https://asciinema.org/a/jdJrxhDLboeyrhzZRHsve0x8i This installation of asciinema recorder hasn't been linked to any asciinema.org account. All unclaimed recordings (from unknown installations like this one) @@ -196,24 +188,24 @@ are automatically archived 7 days after upload. If you want to preserve all recordings made on this machine, connect this installation with asciinema.org account by opening the following link: - https://asciinema.org/connect/10cd4f24-45b6-4f64-b737-ae0e5d12baf8 + https://asciinema.org/connect/10cd4f24-45b6-4f64-b737-ae0e5d12baf8 ``` ![][16] -If you would like to share the recorded session on social media, just click the `Share` button in the bottom of the page. +如果你想要分享录制的会话在社交媒体上,只需要点击页面底部的 “Share” 按钮。 -If anyone wants to download this recording, just click the `Download` button in the bottom of the page to save on your system. +如果任何人想要去下载这个录制,只需要点击页面底部的 “Download” 按钮,就可以将其保存在你系统里。 -### How to Manage Recording on asciinema.org Site +### 如何管理 asciinema.org 中的录制片段 -If you want to preserve all recordings made on this machine, connect this installation with asciinema.org account by opening the following link and follow the instructions. +如果你想要留存所有在这个机器上录制的片段,点击上述显示的链接并使用你在 asciinema.org 的账户登录,然后跟随这个说明继续操作,来将你的机器和该网站连接起来。 ``` https://asciinema.org/connect/10cd4f24-45b6-4f64-b737-ae0e5d12baf8 ``` -If you have already recorded an asciicast but you don’t see it on your profile on asciinema.org website. Just run the `asciinema auth` command in your terminal to move those. +如果你早已录制了一份,但是你没有在你的 asciinema.org 账户界面看到它,只需要运行 `asciinema auth` 命令来移动它们。 ``` $ asciinema auth @@ -227,7 +219,7 @@ This will associate all recordings uploaded from this machine (past and future o ![][17] -Run the following command if you would like to upload the file directly to asciinema.org instead of locally saving. +如果你想直接上传文件而不是将其保存在本地,直接运行如下命令: ``` $ asciinema rec @@ -235,15 +227,7 @@ asciinema: recording asciicast to /tmp/tmp6kuh4247-ascii.cast asciinema: press "ctrl-d" or type "exit" when you're done ``` -Just run the following command to start recording. - -``` -$ asciinema rec 2g-test -asciinema: recording asciicast to 2g-test -asciinema: press "ctrl-d" or type "exit" when you're done -``` - -For testing purpose run few commands and see whether it’s working fine or not. +出于测试目的,运行下述命令,并看一看它是否运行的很好。 ``` $ free @@ -265,9 +249,9 @@ $ uname -a Linux daygeek-Y700 4.19.8-2-MANJARO #1 SMP PREEMPT Sat Dec 8 14:45:36 UTC 2018 x86_64 GNU/Linux ``` -Once you have done, simple press `CTRL+D` or type `exit` to stop the recording then hit `Enter` button to upload the recording to asciinema.org website. +如果你完成了,简单的按下 `CTRL+D` 或输入 `exit` 来停止录制,然后按下回车来上传文件到 asciinema.org 网站。 -It will take few seconds to generate the unique url for your uploaded recording. Once it’s done you will be getting the results same as below. +这将会花费一些时间来为你的录制生成唯一链接。一旦它完成,你会看到和下面一样的样式: ``` $ exit @@ -286,8 +270,8 @@ via: https://www.2daygeek.com/linux-asciinema-record-your-terminal-sessions-shar 作者:[Magesh Maruthamuthu][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[Bestony](https://github.com/bestony) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/201902/20190102 How To Display Thumbnail Images In Terminal.md b/published/201902/20190102 How To Display Thumbnail Images In Terminal.md new file mode 100644 index 0000000000..7e70d280a5 --- /dev/null +++ b/published/201902/20190102 How To Display Thumbnail Images In Terminal.md @@ -0,0 +1,184 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10538-1.html) +[#]: subject: (How To Display Thumbnail Images In Terminal) +[#]: via: (https://www.ostechnix.com/how-to-display-thumbnail-images-in-terminal/) +[#]: author: (SK https://www.ostechnix.com/author/sk/) + +如何在终端显示图像缩略图 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2019/01/lsix-720x340.png) + +不久前,我们讨论了 [Fim][1],这是一个轻量级的命令行图像查看器应用程序,用于从命令行显示各种类型的图像,如 bmp、gif、jpeg 和 png 等。今天,我偶然发现了一个名为 `lsix` 的类似工具。它类似于类 Unix 系统中的 `ls` 命令,但仅适用于图像。`lsix` 是一个简单的命令行实用程序,旨在使用 Sixel 图形格式在终端中显示缩略图。对于那些想知道的人来说,Sixel 是六像素six pixels的缩写,是一种位图图形格式。它使用 ImageMagick,因此几乎所有 imagemagick 支持的文件格式都可以正常工作。 + +### 功能 + +关于 `lsix` 的功能,我们可以列出如下: + +* 自动检测你的终端是否支持 Sixel 图形格式。如果你的终端不支持 Sixel,它会通知你启用它。 +* 自动检测终端背景颜色。它使用终端转义序列来试图找出终端应用程序的前景色和背景色,并清楚地显示缩略图。 +* 如果目录中有更多图像(通常大于 21 个),`lsix` 将一次显示这些图像,因此你无需等待创建整个蒙太奇图像(LCTT 译注:拼贴图)。 +* 可以通过 SSH 工作,因此你可以轻松操作存储在远程 Web 服务器上的图像。 +* 它支持非位图图形,例如 .svg、.eps、.pdf、.xcf 等。 +* 用 Bash 编写,适用于几乎所有 Linux 发行版。 + +### 安装 lsix + +由于 `lsix` 使用 ImageMagick,请确保已安装它。它在大多数 Linux 发行版的默认软件库中都可用。 例如,在 Arch Linux 及其变体如 Antergos、Manjaro Linux 上,可以使用以下命令安装ImageMagick: + +``` +$ sudo pacman -S imagemagick +``` + +在 Debian、Ubuntu、Linux Mint: + +``` +$ sudo apt-get install imagemagick +``` + +`lsix` 并不需要安装,因为它只是一个 Bash 脚本。只需要下载它并移动到你的 `$PATH` 中。就这么简单。 + +从该项目的 GitHub 主页下载最新的 `lsix` 版本。我使用如下命令下载 `lsix` 归档包: + +``` +$ wget https://github.com/hackerb9/lsix/archive/master.zip +``` + +提取下载的 zip 文件: + +``` +$ unzip master.zip +``` + +此命令将所有内容提取到名为 `lsix-master` 的文件夹中。将 `lsix` 二进制文件从此目录复制到 `$PATH` 中,例如 `/usr/local/bin/`。 + +``` +$ sudo cp lsix-master/lsix /usr/local/bin/ +``` + +最后,使 `lsix` 二进制文件可执行: + +``` +$ sudo chmod +x /usr/local/bin/lsix +``` + +如此,现在是在终端本身显示缩略图的时候了。 + +在开始使用 `lsix` 之前,请确保你的终端支持 Sixel 图形格式。 + +开发人员在 vt340 仿真模式下的 Xterm 上开发了 `lsix`。 然而,他声称 `lsix` 应该适用于任何Sixel 兼容终端。 + +Xterm 支持 Sixel 图形格式,但默认情况下不启用。 + +你可以从另外一个终端使用命令来启动一个启用了 Sixel 模式的 Xterm: + +``` +$ xterm -ti vt340 +``` + +或者,你可以使 vt340 成为 Xterm 的默认终端类型,如下所述。 + +编辑 `.Xresources` 文件(如果它不可用,只需创建它): + +``` +$ vi .Xresources +``` + +添加如下行: + +``` +xterm*decTerminalID : vt340 +``` + +按下 `ESC` 并键入 `:wq` 以保存并关闭该文件。 + +最后,运行如下命令来应用改变: + +``` +$ xrdb -merge .Xresources +``` + +现在,每次启动 Xterm 就会默认启用 Sixel 图形支持。 + +### 在终端中显示缩略图 + +启动 Xterm(不要忘记以 vt340 模式启动它)。以下是 Xterm 在我的系统中的样子。 + +![](https://www.ostechnix.com/wp-content/uploads/2019/01/xterm-1.png) + +就像我已经说过的那样,`lsix` 非常简单实用。它没有任何命令行选项或配置文件。你所要做的就是将文件的路径作为参数传递,如下所示。 + +``` +$ lsix ostechnix/logo.png +``` + +![](https://www.ostechnix.com/wp-content/uploads/2019/01/lsix-4.png) + +如果在没有路径的情况下运行它,它将显示在当前工作目录中的缩略图图像。我在名为 `ostechnix` 的目录中有几个文件。 + +要显示此目录中的缩略图,只需运行: + +``` +$ lsix +``` + +![](https://www.ostechnix.com/wp-content/uploads/2019/01/lsix-1.png) + +看到了吗?所有文件的缩略图都显示在终端里。 + +如果使用 `ls` 命令,则只能看到文件名,而不是缩略图。 + +![][3] + +你还可以使用通配符显示特定类型的指定图像或一组图像。 + +例如,要显示单个图像,只需提及图像的完整路径,如下所示。 + +``` +$ lsix girl.jpg +``` + +![](https://www.ostechnix.com/wp-content/uploads/2019/01/lsix-2.png) + +要显示特定类型的所有图像,例如 PNG,请使用如下所示的通配符。 + +``` +$ lsix *.png +``` + +![][4] + +对于 JEPG 类型,命令如下: + +``` +$ lsix *jpg +``` + +缩略图的显示质量非常好。我以为 `lsix` 会显示模糊的缩略图。但我错了,缩略图清晰可见,就像在图形图像查看器上一样。 + +而且,这一切都是唾手可得。如你所见,`lsix` 与 `ls` 命令非常相似,但它仅用于显示缩略图。如果你在工作中处理很多图像,`lsix` 可能会非常方便。试一试,请在下面的评论部分告诉我们你对此实用程序的看法。如果你知道任何类似的工具,也请提出建议。我将检查并更新本指南。 + +更多好东西即将到来。敬请关注! + +干杯! + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-display-thumbnail-images-in-terminal/ + +作者:[SK][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: https://www.ostechnix.com/how-to-display-images-in-the-terminal/ +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: http://www.ostechnix.com/wp-content/uploads/2019/01/ls-command-1.png +[4]: http://www.ostechnix.com/wp-content/uploads/2019/01/lsix-3.png diff --git a/published/201902/20190103 How to use Magit to manage Git projects.md b/published/201902/20190103 How to use Magit to manage Git projects.md new file mode 100644 index 0000000000..f9370ca14e --- /dev/null +++ b/published/201902/20190103 How to use Magit to manage Git projects.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10564-1.html) +[#]: subject: (How to use Magit to manage Git projects) +[#]: via: (https://opensource.com/article/19/1/how-use-magit) +[#]: author: (Sachin Patil https://opensource.com/users/psachin) + +如何在 Emacs 中使用 Magit 管理 Git 项目 +====== + +> Emacs 的 Magit 扩展插件使得使用 Git 进行版本控制变得简单起来。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolseriesk12_rh_021x_0.png?itok=fvorN0e-) + +[Git][1] 是一个很棒的用于项目管理的 [版本控制][2] 工具,就是新人学习起来太难。Git 的命令行工具很难用,你不仅需要熟悉它的标志和选项,还需要知道什么环境下使用它们。这使人望而生畏,因此不少人只会非常有限的几个用法。 + +好在,现今大多数的集成开发环境 (IDE) 都包含了 Git 扩展,大大地简化了使用使用的难度。Emacs 中就有这么一款 Git 扩展名叫 [Magit][3]。 + +Magit 项目成立有差不多 10 年了,它将自己定义为 “一件 Emacs 内的 Git 瓷器”。也就是说,它是一个操作界面,每个操作都能一键完成。本文会带你领略一下 Magit 的操作界面并告诉你如何使用它来管理 Git 项目。 + +若你还没有做,请在开始本教程之前先 [安装 Emacs][4],再 [安装 Magit][5]。 + +### Magit 的界面 + +首先用 Emacs 的 [Dired 模式][6] 访问一个项目的目录。比如我所有的 Emacs 配置存储在 `~/.emacs.d/` 目录中,就是用 Git 来进行管理的。 + +![](https://opensource.com/sites/default/files/uploads/visiting_a_git_project.png) + +若你在命令行下工作,则你需要输入 `git status` 来查看项目的当前状态。Magit 也有类似的功能:`magit-status`。你可以通过 `M-x magit-status` (快捷方式是 `Alt+x magit-status` )来调用该功能。结果看起来像下面这样: + +![](https://opensource.com/sites/default/files/uploads/magit_status.png) + +Magit 显示的信息比 `git status` 命令的要多得多。它分别列出了未追踪文件列表、未暂存文件列表以及已暂存文件列表。它还列出了储藏stash列表以及最近几次的提交 —— 所有这些信息都在一个窗口中展示。 + +如果你想查看修改了哪些内容,按下 `Tab` 键。比如,我移动光标到未暂存的文件 `custom_functions.org` 上,然后按下 `Tab` 键,Magit 会显示修改了哪些内容: + +![](https://opensource.com/sites/default/files/uploads/show_unstaged_content.png) + +这跟运行命令 `git diff custom_functions.org` 类似。储藏文件更简单。只需要移动光标到文件上然后按下 `s` 键。该文件就会迅速移动到已储藏文件列表中: + +![](https://opensource.com/sites/default/files/uploads/staging_a_file.png) + +要反储藏unstage某个文件,使用 `u` 键。按下 `s` 和 `u` 键要比在命令行输入 `git add -u ` 和 `git reset HEAD ` 快的多也更有趣的多。 + +### 提交更改 + +在同一个 Magit 窗口中,按下 `c` 键会显示一个提交窗口,其中提供了许多标志,比如 `--all` 用来暂存所有文件或者 `--signoff` 来往提交信息中添加签名行。 + +![](https://opensource.com/sites/default/files/uploads/magit_commit_popup.png) + +将光标移动到想要启用签名标志的行,然后按下回车。`--signoff` 文本会变成高亮,这说明该标志已经被启用。 + +![](https://opensource.com/sites/default/files/uploads/magit_signoff_commit.png) + +再次按下 `c` 键会显示一个窗口供你输入提交信息。 + +![](https://opensource.com/sites/default/files/uploads/magit_commit_message.png) + +最后,使用 `C-c C-c `(按键 `Ctrl+cc` 的缩写形式) 来提交更改。 + +![](https://opensource.com/sites/default/files/uploads/magit_commit_message_2.png) + +### 推送更改 + +更改提交后,提交行将会显示在 `Recent commits` 区域中显示。 + +![](https://opensource.com/sites/default/files/uploads/magit_commit_log.png) + +将光标放到该提交处然后按下 `p` 来推送该变更。 + +若你想感受一下使用 Magit 的感觉,我已经在 YouTube 上传了一段 [演示][7]。本文只涉及到 Magit 的一点皮毛。它有许多超酷的功能可以帮你使用 Git 分支、变基等功能。你可以在 Magit 的主页上找到 [文档、支持,以及更多][8] 的链接。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/how-use-magit + +作者:[Sachin Patil][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/psachin +[b]: https://github.com/lujun9972 +[1]: https://git-scm.com +[2]: https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control +[3]: https://magit.vc +[4]: https://www.gnu.org/software/emacs/download.html +[5]: https://magit.vc/manual/magit/Installing-from-Melpa.html#Installing-from-Melpa +[6]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Dired-Enter.html#Dired-Enter +[7]: https://youtu.be/Vvw75Pqp7Mc +[8]: https://magit.vc/ diff --git a/translated/talk/20190108 Hacking math education with Python.md b/published/201902/20190108 Hacking math education with Python.md similarity index 93% rename from translated/talk/20190108 Hacking math education with Python.md rename to published/201902/20190108 Hacking math education with Python.md index 120e56c521..0ab5baca72 100644 --- a/translated/talk/20190108 Hacking math education with Python.md +++ b/published/201902/20190108 Hacking math education with Python.md @@ -1,14 +1,15 @@ [#]: collector: (lujun9972) [#]: translator: (HankChow) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10527-1.html) [#]: subject: (Hacking math education with Python) [#]: via: (https://opensource.com/article/19/1/hacking-math) [#]: author: (Don Watkins https://opensource.com/users/don-watkins) 将 Python 结合到数学教育中 ====== + > 身兼教师、开发者、作家数职的 Peter Farrell 来讲述为什么使用 Python 来讲数学课会比传统方法更加好。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/getting_started_with_python.png?itok=MFEKm3gl) @@ -19,11 +20,11 @@ Peter 的灵感来源于 Logo 语言之父 [Seymour Papert][2],他的 Logo 语言现在还存在于 Python 的 [Turtle 模块][3]中。Logo 语言中的海龟形象让 Peter 喜欢上了 Python,并且进一步将 Python 应用到数学教学中。 -Peter 在他的新书《[Python 数学奇遇记Math Adventures with Python][5]》中分享了他的方法:“图文并茂地指导如何用代码探索数学”。因此我最近对他进行了一次采访,向他了解更多这方面的情况。 +Peter 在他的新书《[Python 数学奇遇记][5]Math Adventures with Python》中分享了他的方法:“图文并茂地指导如何用代码探索数学”。因此我最近对他进行了一次采访,向他了解更多这方面的情况。 -**Don Watkins(译者注:本文作者):** 你的教学背景是什么? +**Don Watkins(LCTT 译注:本文作者):** 你的教学背景是什么? -**Peter Farrell:** 我曾经当过八年的数学老师,之后又教了十年的数学。我还在当老师的时候,就阅读过 Papert 的 《[头脑风暴Mindstorms][6]》并从中受到了启发,将 Logo 语言和海龟引入到了我所有的数学课上。 +**Peter Farrell:** 我曾经当过八年的数学老师,之后又做了十年的数学私教。我还在当老师的时候,就阅读过 Papert 的 《[头脑风暴][6]Mindstorms》并从中受到了启发,将 Logo 语言和海龟引入到了我所有的数学课上。 **DW:** 你为什么开始使用 Python 呢? @@ -68,7 +69,7 @@ via: https://opensource.com/article/19/1/hacking-math 作者:[Don Watkins][a] 选题:[lujun9972][b] 译者:[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/) 荣誉推出 diff --git a/published/201902/20190110 5 useful Vim plugins for developers.md b/published/201902/20190110 5 useful Vim plugins for developers.md new file mode 100644 index 0000000000..f405baa6ab --- /dev/null +++ b/published/201902/20190110 5 useful Vim plugins for developers.md @@ -0,0 +1,371 @@ +[#]: collector: (lujun9972) +[#]: translator: (pityonline) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10563-1.html) +[#]: subject: (5 useful Vim plugins for developers) +[#]: via: (https://opensource.com/article/19/1/vim-plugins-developers) +[#]: author: (Ricardo Gerardi https://opensource.com/users/rgerardi) + +5 个好用的开发者 Vim 插件 +====== + +> 通过这 5 个插件扩展 Vim 功能来提升你的编码效率。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh) + +我用 Vim 已经超过 20 年了,两年前我决定把它作为我的首要文本编辑器。我用 Vim 来编写代码、配置文件、博客文章及其它任意可以用纯文本表达的东西。Vim 有很多超级棒的功能,一旦你适合了它,你的工作会变得非常高效。 + +在日常编辑工作中,我更倾向于使用 Vim 稳定的原生功能,但开源社区对 Vim 开发了大量的插件,可以扩展 Vim 的功能、改进你的工作流程和提升工作效率。 + +以下列举 5 个非常好用的可以用于编写任意编程语言的插件。 + +### 1、Auto Pairs + +[Auto Pairs][2] 插件可以帮助你插入和删除成对的文字,如花括号、圆括号或引号。这在编写代码时非常有用,因为很多编程语言都有成对标记的语法,就像圆括号用于函数调用,或引号用于字符串定义。 + +Auto Pairs 最基本的功能是在你输入一个左括号时会自动补全对应的另一半括号。比如,你输入了一个 `[`,它会自动帮你补充另一半 `]`。相反,如果你用退格键删除开头的一半括号,Auto Pairs 会删除另一半。 + +如果你设置了自动缩进,当你按下回车键时 Auto Pairs 会在恰当的缩进位置补全另一半括号,这比你找到放置另一半的位置并选择一个正确的括号要省劲多了。 + +例如下面这段代码: + +``` +package main + +import "fmt" + +func main() { + x := true + items := []string{"tv", "pc", "tablet"} + + if x { + for _, i := range items + } +} +``` + +在 `items` 后面输入一个左花括号按下回车会产生下面的结果: + +``` +package main + +import "fmt" + +func main() { + x := true + items := []string{"tv", "pc", "tablet"} + + if x { + for _, i := range items { + | (cursor here) + } + } +} +``` + +Auto Pairs 提供了大量其它选项(你可以在 [GitHub][3] 上找到),但最基本的功能已经很让人省时间了。 + +### 2、NERD Commenter + +[NERD Commenter][4] 插件给 Vim 增加了代码注释的功能,类似在 IDEintegrated development environment 中注释功能。有了这个插件,你可以一键注释单行或多行代码。 + +NERD Commenter 可以与标准的 Vim [filetype][5] 插件配合,所以它能理解一些编程语言并使用合适的方式来注释代码。 + +最易上手的方法是按 `Leader+Space` 组合键来切换注释当前行。Vim 默认的 Leader 键是 `\`。 + +在可视化模式Visual mode中,你可以选择多行一并注释。NERD Commenter 也可以按计数注释,所以你可以加个数量 n 来注释 n 行。 + +还有个有用的特性 “Sexy Comment” 可以用 `Leader+cs` 来触发,它的块注释风格更漂亮一些。例如下面这段代码: + +``` +package main + +import "fmt" + +func main() { + x := true + items := []string{"tv", "pc", "tablet"} + + if x { + for _, i := range items { + fmt.Println(i) + } + } +} +``` + +选择 `main` 函数中的所有行然后按下 `Leader+cs` 会出来以下注释效果: + +``` +package main + +import "fmt" + +func main() { +/* + * x := true + * items := []string{"tv", "pc", "tablet"} + * + * if x { + * for _, i := range items { + * fmt.Println(i) + * } + * } + */ +} +``` + +因为这些行都是在一个块中注释的,你可以用 `Leader+Space` 组合键一次去掉这里所有的注释。 + +NERD Commenter 是任何使用 Vim 写代码的开发者都必装的插件。 + +### 3、VIM Surround + +[Vim Surround][6] 插件可以帮你“环绕”现有文本插入成对的符号(如括号或双引号)或标签(如 HTML 或 XML 标签)。它和 Auto Pairs 有点儿类似,但是用于处理已有文本,在编辑文本时更有用。 + +比如你有以下一个句子: + +``` +"Vim plugins are awesome !" +``` + +当你的光标处于引起来的句中任何位置时,你可以用 `ds"` 组合键删除句子两端的双引号。 + +``` +Vim plugins are awesome ! +``` + +你也可以用 `cs"'` 把双端的双引号换成单引号: + +``` +'Vim plugins are awesome !' +``` + +或者再用 `cs'[` 替换成中括号: + +``` +[ Vim plugins are awesome ! ] +``` + +它对编辑 HTML 或 XML 文本中的标签tag尤其在行。假如你有以下一行 HTML 代码: + +``` +

Vim plugins are awesome !

+``` + +当光标在 “awesome” 这个单词的任何位置时,你可以按 `ysiw` 直接给它加上着重标签(``): + +``` +

Vim plugins are awesome !

+``` + +注意它聪明地加上了 `
` 闭合标签。 + +Vim Surround 也可以用 `ySS` 缩进文本并加上标签。比如你有以下文本: + +``` +

Vim plugins are awesome !

+``` + +你可以用 `ySS
` 加上 `div` 标签,注意生成的段落是自动缩进的。 + +``` +
+       

Vim plugins are awesome !

+
+``` + +Vim Surround 有很多其它选项,你可以参照 [GitHub][7] 上的说明尝试它们。 + +### 4、Vim Gitgutter + +[Vim Gitgutter][8] 插件对使用 Git 作为版本控制工具的人来说非常有用。它会在 Vim 的行号列旁显示 `git diff` 的差异标记。假设你有如下已提交过的代码: + +``` +  1 package main +  2 +  3 import "fmt" +  4 +  5 func main() { +  6     x := true +  7     items := []string{"tv", "pc", "tablet"} +  8 +  9     if x { + 10         for _, i := range items { + 11             fmt.Println(i) + 12         } + 13     } + 14 } +``` + +当你做出一些修改后,Vim Gitgutter 会显示如下标记: + +``` +    1 package main +    2 +    3 import "fmt" +    4 +_   5 func main() { +    6     items := []string{"tv", "pc", "tablet"} +    7 +~   8     if len(items) > 0 { +    9         for _, i := range items { +   10             fmt.Println(i) ++  11             fmt.Println("------") +   12         } +   13     } +   14 } +``` + +`_` 标记表示在第 5 行和第 6 行之间删除了一行。`~` 表示第 8 行有修改,`+` 表示新增了第 11 行。 + +另外,Vim Gitgutter 允许你用 `[c` 和 `]c` 在多个有修改的块之间跳转,甚至可以用 `Leader+hs` 来暂存某个变更集。 + +这个插件提供了对变更的即时视觉反馈,如果你用 Git 的话,有了它简直是如虎添翼。 + +### 5、VIM Fugitive + +[Vim Fugitive][9] 是另一个将 Git 工作流集成到 Vim 中的超棒插件。它对 Git 做了一些封装,可以让你在 Vim 里直接执行 Git 命令并将结果集成在 Vim 界面里。这个插件有超多的特性,更多信息请访问它的 [GitHub][10] 项目页面。 + +这里有一个使用 Vim Fugitive 的基础 Git 工作流示例。设想我们已经对下面的 Go 代码做出修改,你可以用 `:Gblame` 调用 `git blame` 来查看每行最后的提交信息: + +``` +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    1 package main +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    2 +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    3 import "fmt" +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    4 +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│_   5 func main() { +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    6     items := []string{"tv", "pc", "tablet"} +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    7 +00000000 (Not Committed Yet 2018-12-05 18:55:00 -0500)│~   8     if len(items) > 0 { +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    9         for _, i := range items { +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   10             fmt.Println(i) +00000000 (Not Committed Yet 2018-12-05 18:55:00 -0500)│+  11             fmt.Println("------") +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   12         } +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   13     } +e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   14 } +``` + +可以看到第 8 行和第 11 行显示还未提交。用 `:Gstatus` 命令检查仓库当前的状态: + +``` +  1 # On branch master +  2 # Your branch is up to date with 'origin/master'. +  3 # +  4 # Changes not staged for commit: +  5 #   (use "git add ..." to update what will be committed) +  6 #   (use "git checkout -- ..." to discard changes in working directory) +  7 # +  8 #       modified:   vim-5plugins/examples/test1.go +  9 # + 10 no changes added to commit (use "git add" and/or "git commit -a") +-------------------------------------------------------------------------------------------------------- +    1 package main +    2 +    3 import "fmt" +    4 +_   5 func main() { +    6     items := []string{"tv", "pc", "tablet"} +    7 +~   8     if len(items) > 0 { +    9         for _, i := range items { +   10             fmt.Println(i) ++  11             fmt.Println("------") +   12         } +   13     } +   14 } +``` + +Vim Fugitive 在分割的窗口里显示 `git status` 的输出结果。你可以在该行按下 `-` 键用该文件的名字暂存这个文件的提交,再按一次 `-` 可以取消暂存。这个信息会随着你的操作自动更新: + +``` +  1 # On branch master +  2 # Your branch is up to date with 'origin/master'. +  3 # +  4 # Changes to be committed: +  5 #   (use "git reset HEAD ..." to unstage) +  6 # +  7 #       modified:   vim-5plugins/examples/test1.go +  8 # +-------------------------------------------------------------------------------------------------------- +    1 package main +    2 +    3 import "fmt" +    4 +_   5 func main() { +    6     items := []string{"tv", "pc", "tablet"} +    7 +~   8     if len(items) > 0 { +    9         for _, i := range items { +   10             fmt.Println(i) ++  11             fmt.Println("------") +   12         } +   13     } +   14 } +``` + +现在你可以用 `:Gcommit` 来提交修改了。Vim Fugitive 会打开另一个分割窗口让你输入提交信息: + +``` +  1 vim-5plugins: Updated test1.go example file +  2 # Please enter the commit message for your changes. Lines starting +  3 # with '#' will be ignored, and an empty message aborts the commit. +  4 # +  5 # On branch master +  6 # Your branch is up to date with 'origin/master'. +  7 # +  8 # Changes to be committed: +  9 #       modified:   vim-5plugins/examples/test1.go + 10 # +``` + +按 `:wq` 保存文件完成提交: + +``` +[master c3bf80f] vim-5plugins: Updated test1.go example file + 1 file changed, 2 insertions(+), 2 deletions(-) +Press ENTER or type command to continue +``` + +然后你可以再用 `:Gstatus` 检查结果并用 `:Gpush` 把新的提交推送到远程。 + +``` +  1 # On branch master +  2 # Your branch is ahead of 'origin/master' by 1 commit. +  3 #   (use "git push" to publish your local commits) +  4 # +  5 nothing to commit, working tree clean +``` + +Vim Fugitive 的 GitHub 项目主页有很多屏幕录像展示了它的更多功能和工作流,如果你喜欢它并想多学一些,快去看看吧。 + +### 接下来? + +这些 Vim 插件都是程序开发者的神器!还有另外两类开发者常用的插件:自动完成插件和语法检查插件。它些大都是和具体的编程语言相关的,以后我会在一些文章中介绍它们。 + +你在写代码时是否用到一些其它 Vim 插件?请在评论区留言分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/vim-plugins-developers + +作者:[Ricardo Gerardi][a] +选题:[lujun9972][b] +译者:[pityonline](https://github.com/pityonline) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rgerardi +[b]: https://github.com/lujun9972 +[1]: https://www.vim.org/ +[2]: https://www.vim.org/scripts/script.php?script_id=3599 +[3]: https://github.com/jiangmiao/auto-pairs +[4]: https://github.com/scrooloose/nerdcommenter +[5]: http://vim.wikia.com/wiki/Filetype.vim +[6]: https://www.vim.org/scripts/script.php?script_id=1697 +[7]: https://github.com/tpope/vim-surround +[8]: https://github.com/airblade/vim-gitgutter +[9]: https://www.vim.org/scripts/script.php?script_id=2975 +[10]: https://github.com/tpope/vim-fugitive diff --git a/published/201902/20190110 Toyota Motors and its Linux Journey.md b/published/201902/20190110 Toyota Motors and its Linux Journey.md new file mode 100644 index 0000000000..d89f4f2a29 --- /dev/null +++ b/published/201902/20190110 Toyota Motors and its Linux Journey.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: (jdh8383) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10543-1.html) +[#]: subject: (Toyota Motors and its Linux Journey) +[#]: via: (https://itsfoss.com/toyota-motors-linux-journey) +[#]: author: (Malcolm Dean https://itsfoss.com/toyota-motors-linux-journey) + +丰田汽车的 Linux 之旅 +====== + +我之前跟丰田汽车北美分公司的 Brian.R.Lyons(丰田发言人)聊了聊,话题是关于 Linux 在丰田和雷克萨斯汽车的信息娱乐系统上的实施方案。我了解到一些汽车制造商使用了 Automotive Grade Linux(AGL)。 + +然后我写了一篇短文,记录了我和 Brian 的讨论内容,谈及了丰田和 Linux 的一些渊源。希望 Linux 的狂热粉丝们能够喜欢这次对话。 + +全部的[丰田和雷克萨斯汽车都将会使用 Automotive Grade Linux(AGL)][1],主要是用于车载信息娱乐系统。这项措施对于丰田集团来说是至关重要的,因为据 Lyons 先生所说:“作为技术的引领者之一,丰田认识到,赶上科技快速进步最好的方法就是接受开源发展的理念。” + +丰田和众多汽车制造公司都认为,与使用非自由软件相比,采用基于 Linux 的操作系统在更新和升级方面会更加廉价和快捷。 + +这简直太棒了!Linux 终于跟汽车结合起来了。我每天都在电脑上使用 Linux;能看到这个优秀的软件在一个完全不同的产业领域里大展拳脚真是太好了。 + +我很好奇丰田是什么时候开始使用 [Automotive Grade Linux(AGL)][2]的。按照 Lyons 先生的说法,这要追溯到 2011 年。 + +> “自 AGL 项目在五年前启动之始,作为活跃的会员和贡献者,丰田与其他顶级制造商和供应商展开合作,着手开发一个基于 Linux 的强大平台,并不断地增强其功能和安全性。” + +![丰田信息娱乐系统][3] + +[丰田于 2011 年加入了 Linux 基金会][4],与其他汽车制造商和软件公司就 IVI(车内信息娱乐系统)展开讨论,最终在 2012 年,Linux 基金会内部成立了 Automotive Grade Linux 工作组。 + +丰田在 AGL 工作组里首先提出了“代码优先”的策略,这在开源领域是很常见的做法。然后丰田和其他汽车制造商、IVI 一线厂家,软件公司等各方展开对话,根据各方的技术需求详细制定了初始方向。 + +在加入 Linux 基金会的时候,丰田就已经意识到,在一线公司之间共享软件代码将会是至关重要的。因为要维护如此复杂的软件系统,对于任何一家顶级厂商都是一笔不小的开销。丰田和它的一级供货商想把更多的资源用在开发新功能和新的用户体验上,而不是用在维护各自的代码上。 + +各个汽车公司联合起来深入合作是一件大事。许多公司都达成了这样的共识,因为他们都发现开发维护私有软件其实更费钱。 + +今天,在全球市场上,丰田和雷克萨斯的全部车型都使用了 AGL。 + +身为雷克萨斯的销售人员,我认为这是一大进步。我和其他销售顾问都曾接待过很多回来找技术专员的客户,他们想更多的了解自己车上的信息娱乐系统到底都能做些什么。 + +这件事本身对于 Linux 社区和用户是个重大利好。虽然那个我们每天都在使用的操作系统变了模样,被推到了更广阔的舞台上,但它仍然是那个 Linux,简单、包容而强大。 + +未来将会如何发展呢?我希望它能少出差错,为消费者带来更佳的用户体验。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/toyota-motors-linux-journey + +作者:[Malcolm Dean][a] +选题:[lujun9972][b] +译者:[jdh8383](https://github.com/jdh8383) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/toyota-motors-linux-journey +[b]: https://github.com/lujun9972 +[1]: https://www.linuxfoundation.org/press-release/2018/01/automotive-grade-linux-hits-road-globally-toyota-amazon-alexa-joins-agl-support-voice-recognition/ +[2]: https://www.automotivelinux.org/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/toyota-interiors.jpg?resize=800%2C450&ssl=1 +[4]: https://www.linuxfoundation.org/press-release/2011/07/toyota-joins-linux-foundation/ diff --git a/published/20190114 Hegemon - A Modular System And Hardware Monitoring Tool For Linux.md b/published/201902/20190114 Hegemon - A Modular System And Hardware Monitoring Tool For Linux.md similarity index 100% rename from published/20190114 Hegemon - A Modular System And Hardware Monitoring Tool For Linux.md rename to published/201902/20190114 Hegemon - A Modular System And Hardware Monitoring Tool For Linux.md diff --git a/published/201902/20190114 Remote Working Survival Guide.md b/published/201902/20190114 Remote Working Survival Guide.md new file mode 100644 index 0000000000..0c51a15885 --- /dev/null +++ b/published/201902/20190114 Remote Working Survival Guide.md @@ -0,0 +1,133 @@ +[#]: collector: (lujun9972) +[#]: translator: (beamrolling) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10518-1.html) +[#]: subject: (Remote Working Survival Guide) +[#]: via: (https://www.jonobacon.com/2019/01/14/remote-working-survival/) +[#]: author: (Jono Bacon https://www.jonobacon.com/author/admin/) + +远程工作生存指南 +====== + +![](https://www.jonobacon.com/wp-content/uploads/2019/01/5b5471d7eadb585ec8b8a0c3_featureimage-remotejob-1080x675.jpg) + +远程工作似乎是最近的一个热门话题。CNBC 报道称,[70% 的专业人士至少每周在家工作一次][1]。同样地,CoSo Cloud 调查发现, [77% 的人在远程工作时效率更高][2] ,而 aftercollege 的一份调查显示,[8% 的千禧一代会更多地考虑提供远程工作的公司][3]。 这看起来很合理:技术、网络以及文化似乎越来越推动了远程工作的发展。哦,自制咖啡也比以前任何时候更好喝了。 + +目前,我准备写另一篇关于公司如何优化远程工作的文章(所以请确保你加入我们的会员以持续关注——这是免费的)。 + +但今天,我想 **分享一些个人如何做好远程工作的建议**。不管你是全职远程工作者,或者是可以选择一周某几天在家工作的人,希望这篇文章对你有用。 + +眼下,你需要明白,**远程工作不是万能药**。当然,穿着睡衣满屋子乱逛,听听反社会音乐,喝一大杯咖啡看起来似乎挺完美的,但这不适合每个人。 + +有的人需要办公室的空间。有的人需要办公室的社会元素。有的人需要从家里走出来。有的人在家里缺乏保持专注的自律。有的人因为好几年未缴退税而怕政府工作人员来住处敲门。 + +**远程工作就好像一块肌肉:如果你锻炼并且保持它,那么它能带来极大的力量和能力**。如果不这么做,结果就不一样了。 + +在我职业生涯的大多数时间里,我在家工作。我喜欢这么做。当我在家工作的时候,我更有效率,更开心,更有能力。我并非不喜欢在办公室工作,我享受办公室的社会元素,但我更喜欢在家工作时我的“空间”。我喜欢听重金属音乐,但当整个办公室的人不想听到 [After The Burial][5] 的时候,这会引起一些问题。 + +![][6] + +*“Squirrel.” [图片来源][7]* + +我已经学会了如何正确平衡工作、旅行以及其他元素来管理我的远程工作,以下是我的一些建议。请务必**在评论中分享一些你的建议**。 + +### 1、你需要纪律和习惯(以及了解你的“波动”) + +远程工作确实是需要训练的一块肌肉。就像练出真正的肌肉一样,它需要一个明确的习惯混以健康的纪律。 + +永远保持穿戴整齐(不要穿睡衣)。设置你一天工作的开始和结束时间(大多时候我从早上 9 点工作到下午 6 点)。选好你的午餐休息时间(我的是中午 12 点)。选好你的早晨仪式(我的是电子邮件,紧接着是全面审查客户需求)。决定你的主工作场所在哪(我的主工作场所是我家庭办公室)。决定好每天你什么时候运动(大多数时候我在下午 5 点运动)。 + +**设计一个实际的习惯并坚持 66 天**。建立一个习惯需要很长时间,尽量不要偏离你的习惯。你越坚持这个习惯,做下去所花费的功夫越少。在这 66 天的末尾,你想都不会想,自然而然地就按习惯去做了。 + +话虽这么说,我们又不住在真空里 ([更干净,或者别的什么][8])。我们都有自己的“波动”。 + +“波动”是你为了改变做事的方法时,对日常做出的一些改变。举个例子,夏天的时候我通常需要更多的阳光。那时我经常会在室外的花园工作。临近假期的时候我更容易分心,所以我在上班时间会更需要呆在室内。有时候我只想要多点人际接触,因此我会在咖啡馆里工作几周。有时候我就是喜欢在厨房或者长椅上工作。你需要认识你的“波动”并倾听你的身体。 **首先养成习惯,然后在你认识到自己的“波动”的时候再对它进行适当的调整**。 + +### 2、与你的上司及同事一起设立预期目标 + +不是每个人都知道怎么远程工作,如果你的公司对远程工作没那么熟悉,你尤其需要和同事一起设立预期目标。 + +这件事十分简单:**当你要设计自己的日常工作的时候,清楚地跟你的上司和团队进行交流。**让他们知道如何找到你,紧急情况下如何联系你,以及你在家的时候如何保持合作。 + +在这里通信方式至关重要。有些远程工作者很怕离开他们的电脑,因为害怕当他们不在的时候有人给他们发消息(他们担心别人会觉得他们在边吃奇多边看 Netflix)。 + +你需要离开一会的时间。你需要在吃午餐的时候眼睛不用一直盯着电脑屏幕。你又不是 911 接线员。**设定预期:有时候你可能不能立刻回复,但你会尽快回复**。 + +同样地,设定你的通常可响应的时间范围的预期。举个例子,我对客户设立的预期是我一般每天早上 9 点到下午 6 点工作。当然,如果某个客户急需某样东西,我很乐意在这段时间外回应他,但作为一个一般性规则,我通常只在这段时间内工作。这对于生活的平衡是必要的。 + +### 3、分心是你的敌人,它们需要管理 + +我们都会分心,这是人类的本能。让你分心的事情可能是你的孩子回家了,想玩救援机器人;可能是看看Facebook、Instagram,或者 Twitter 以确保你不会错过任何不受欢迎的政治观点,或者某人的午餐图片;可能是你生活中即将到来的某件事带走了你的注意力(例如,即将举办的婚礼、活动,或者一次大旅行)。 + +**你需要明白什么让你分心以及如何管理它**。举个例子,我知道我的电子邮件和 Twitter 会让我分心。我经常查看它们,并且每次查看都会让我脱离我正在工作的空间。拿水或者咖啡的时候我总会分心去吃零食,看 Youtube 的视频。 + +![][9] + +*我的分心克星* + +由数字信息造成的分心有一个简单对策:**锁起来**。关闭选项卡,直到你完成了你手头的事情。有一大堆工作的时候我总这么干:我把让我分心的东西锁起来,直到做完手头的工作。这需要控制能力,但所有的一切都需要。 + +因为别人影响而分心的元素更难解决。如果你是有家庭的人,你需要明确表示,在你工作的时候常需要独处。这也是为什么家庭办公室这么重要:你需要设一些“爸爸/妈妈正在工作”的界限。如果有急事才能进来,否则让孩子自个儿玩去。 + +把让你分心的事锁起来有许多方法:把你的电话静音;把自己的 Facebook 状态设成“离开”;换到一个没有让你分心的事的房间(或建筑物)。再重申一次,了解是什么让你分心并控制好它。如果不这么做,你会永远被分心的事摆布。 + +### 4、(良好的)关系需要面对面的关注 + +有些角色比其他角色更适合远程工作。例如,我见过工程、质量保证、支持、安全以及其他团队(通常更专注于数字信息协作)的出色工作。其他团队,如设计或营销,往往在远程环境下更难熬(因为它们更注重触觉性)。 + +但是,对于任何团队而言,建立牢固的关系至关重要,而现场讨论、协作和社交很有必要。我们的许多感官(例如肢体语言)在数字环境中被剔除,而这些在我们建立信任和关系的方式中发挥着关键作用。 + +![][10] + +*火箭也很有帮助* + +这尤为重要,如果(a)你初来这家公司,需要建立关系;(b)对某种角色不熟悉,需要和你的团队建立关系;或者(c)你处于领导地位,构建团队融入和参与是你工作的关键部分。 + +**解决方法是?合理搭配远程工作与面对面的时间。** 如果你的公司就在附近,可以用一部分的时间在家工作,一部分时间在公司工作。如果你的公司比较远,安排定期前往办公室(并对你的上司设定你需要这么做的预期)。例如,当我在 XPRIZE 工作的时候,我每几周就会飞往洛杉矶几天。当我在 Canonical 工作时(总部在伦敦),我们每三个月来一次冲刺。 + +### 5、保持专注,不要松懈 + +本文所有内容的关键在于构建一种(远程工作的)能力,并培养远程工作的肌肉。这就像建立你的日常惯例,坚持它,并认识你的“波动”和让你分心的事情以及如何管理它们一样简单。 + +我以一种相当具体的方式来看待这个世界:**我们所做的一切都有机会得到改进和完善**。举个例子,我已经公开演讲超过 15 年,但我总是能发现新的改进方法,以及修复新的错误(说到这些,请参阅我的 [提升你公众演讲的10个方法][11])。 + +发现新的改善方法,以及把每个绊脚石和错误视为一个开启新的不同的“啊哈!”时刻让人兴奋。远程工作和这没什么不同:寻找有助于解锁方式的模式,让你的远程工作时间更高效,更舒适,更有趣。 + +![][12] + +*看看这些书。它们非常适合个人发展。参阅我的 [150 美元个人发展工具包][13] 文章* + +……但别为此狂热。有的人花尽他们每一分钟来寻求如何变得更好,他们经常以“做得还不够好”、“完成度不够高”等为由打击自己,无法达到他们内心关于完美的不切实际的观点。 + +我们都是人,我们是有生命的,不是机器人。始终致力于改进,但要明白不是所有东西都是完美的。你应该有一些休息日或休息周。你也会因为压力和倦怠而挣扎。你也会遇到一些在办公室比远程工作更容易的情况。从这些时刻中学习,但不要沉迷于此。生命太短暂了。 + +**你有什么提示,技巧和建议吗?你如何管理远程工作?我的建议中还缺少什么吗?在评论区中与我分享!** + + +-------------------------------------------------------------------------------- + +via: https://www.jonobacon.com/2019/01/14/remote-working-survival/ + +作者:[Jono Bacon][a] +选题:[lujun9972][b] +译者:[beamrolling](https://github.com/beamrolling) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.jonobacon.com/author/admin/ +[b]: https://github.com/lujun9972 +[1]: https://www.cnbc.com/2018/05/30/70-percent-of-people-globally-work-remotely-at-least-once-a-week-iwg-study.html +[2]: http://www.cosocloud.com/press-release/connectsolutions-survey-shows-working-remotely-benefits-employers-and-employees +[3]: https://www.aftercollege.com/cf/2015-annual-survey +[4]: https://www.jonobacon.com/join/ +[5]: https://www.facebook.com/aftertheburial/ +[6]: https://www.jonobacon.com/wp-content/uploads/2019/01/aftertheburial2.jpg +[7]: https://skullsnbones.com/burial-live-photos-vans-warped-tour-denver-co/ +[8]: https://www.youtube.com/watch?v=wK1PNNEKZBY +[9]: https://www.jonobacon.com/wp-content/uploads/2019/01/IMG_20190114_102429-1024x768.jpg +[10]: https://www.jonobacon.com/wp-content/uploads/2019/01/15381733956_3325670fda_k-1024x576.jpg +[11]: https://www.jonobacon.com/2018/12/11/10-ways-to-up-your-public-speaking-game/ +[12]: https://www.jonobacon.com/wp-content/uploads/2019/01/DwVBxhjX4AgtJgV-1024x532.jpg +[13]: https://www.jonobacon.com/2017/11/13/150-dollar-personal-development-kit/ diff --git a/translated/tech/20190115 Comparing 3 open source databases- PostgreSQL, MariaDB, and SQLite.md b/published/201902/20190115 Comparing 3 open source databases- PostgreSQL, MariaDB, and SQLite.md similarity index 52% rename from translated/tech/20190115 Comparing 3 open source databases- PostgreSQL, MariaDB, and SQLite.md rename to published/201902/20190115 Comparing 3 open source databases- PostgreSQL, MariaDB, and SQLite.md index 6638fb8fb7..c47bb62e94 100644 --- a/translated/tech/20190115 Comparing 3 open source databases- PostgreSQL, MariaDB, and SQLite.md +++ b/published/201902/20190115 Comparing 3 open source databases- PostgreSQL, MariaDB, and SQLite.md @@ -1,86 +1,68 @@ [#]: collector: (lujun9972) [#]: translator: (HankChow) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10512-1.html) [#]: subject: (Comparing 3 open source databases: PostgreSQL, MariaDB, and SQLite) [#]: via: (https://opensource.com/article/19/1/open-source-databases) [#]: author: (Sam Bocetta https://opensource.com/users/sambocetta) 开源数据库 PostgreSQL、MariaDB 和 SQLite 的对比 ====== -> 要知道如何选择最适合你的需求的开源数据库。 + +> 了解如何选择最适合你的需求的开源数据库。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_container_block.png?itok=S8MbXEYw) -在现代企业的技术领域中,开源软件已经成为了一股不可忽视的重要力量。借助[开源运动open source movement][1]的东风,很多重大的技术已经得到了长足的发展。 +在现代的企业级技术领域中,开源软件已经成为了一股不可忽视的重要力量。借助[开源运动][1]open source movement的东风,涌现除了许多重大的技术突破。 -个中原因显而易见,尽管一些基于 Linux 的开源网络标准可能不如著名厂商的产品那么受欢迎,但是不同制造商的智能设备之间能够互相通信,开源技术功不可没。当然也有不少人认为开源应用比厂商提供的产品更加好,所以无论如何,使用开源数据库进行开发确实是相当有利的。 +个中原因显而易见,尽管一些基于 Linux 的开源网络标准可能不如专有厂商的那么受欢迎,但是不同制造商的智能设备之间能够互相通信,开源技术功不可没。当然也有不少人认为开源开发出来的应用比厂商提供的产品更加好,所以无论如何,使用开源数据库进行开发确实是相当有利的。 -和其它类型的应用软件一样,[不同的开源数据库管理系统之间在功能和特性上可能会存在着比较大的差异][2]。因此,如果要为整个团队选择一个开源数据库,那么应该重点考察数据库是否对用户友好、是否能够持续适应团队需求、是否能够提供足够安全的功能等方面的因素。 +和其它类型的应用软件一样,不同的开源数据库管理系统之间在功能和特性上可能会存在着比较大的差异。换言之,[不是所有的开源数据库都是平等的][2]。因此,如果要为整个组织选择一个开源数据库,那么应该重点考察数据库是否对用户友好、是否能够持续适应团队需求、是否能够提供足够安全的功能等方面的因素。 -出于这方面考虑,我们在这篇文章中对一些开源数据库进行了概述和对比。但也有可能略过了一些常用的数据库。需要提到的是,MongoDB 最近更改了它的许可证,因此它已经不是完全的开源产品了。从商业角度来看,这个决定是很有意义的,因为 MongoDB 已经成为了[约 27000 家公司][3]在数据库托管方面的实际解决方案,这也意味着 MongoDB 已经不再被视为真正的开源产品。 +出于这方面考虑,我们在这篇文章中对一些开源数据库进行了概述和优缺点对比。遗憾的是,我们必须忽略一些最常用的数据库。值得注意的是,MongoDB 最近更改了它的许可证,因此它已经不是真正的开源产品了。从商业角度来看,这个决定是很有意义的,因为 MongoDB 已经成为了数据库托管实际上的解决方案,[约 27000 家公司][3]在使用它,但这也意味着 MongoDB 已经不再被视为真正的开源产品。 -另外,在 MySQL 被 Oracle 收购之后,这个产品就已经不再具有开源性质了。MySQL 在过去相当长的一段时间里都是很多项目的首选数据库,因此它的案例也是摆在其它开源数据库面前的一个巨大挑战。 +另外,自从 MySQL 被 Oracle 收购之后,这个产品就已经不再具有开源性质了,MySQL 可以说是数十年来首选的开源数据库。然而,这为其它真正的开源数据库解决方案提供了挑战它的空间。 -下面讨论一下我们提到的三个开源数据库。 +下面是三个值得考虑的开源数据库。 ### PostgreSQL -[PostgreSQL][4] 可以说是开源数据库中的一个重要成员。无论是哪种规模的企业,PostgreSQL 可能都是它们的首选解决方案。Oracle 对 MySQL 的收购在当时来说可能具有一定的商业意义,但是随着云存储的日益壮大,[开发者对 MySQL 的依赖程度或许并不如以前那么大了][5]。 +没有 [PostgreSQL][4] 的开源数据库清单肯定是不完整的。PostgreSQL 一直都是各种规模企业的首选解决方案。Oracle 对 MySQL 的收购在当时来说可能具有一定的商业意义,但是随着云存储的日益壮大,[开发者对 MySQL 的依赖程度或许并不如以前那么大了][5]。 -尽管 PostgreSQL 不是一个最近几年才面世的新产品,但它却是借助了 [MySQL 衰落][6]的机会才逐渐成为最受欢迎的开源数据库之一。由于它和 MySQL 的工作方式非常相似,因此很多热衷于使用开源软件的开发者都纷纷转向 PostgreSQL。 +尽管 PostgreSQL 不是一个最近几年才面世的新产品,但它却是借助了 [MySQL 相对衰落][6]的机会才逐渐成为最受欢迎的开源数据库之一。由于它和 MySQL 的工作方式非常相似,因此很多热衷于使用开源软件的开发者都纷纷转向 PostgreSQL。 #### 优势 - * 目前 PostgreSQL 最显著的优点是它的算法效率高,因此它的性能就比其它的数据库也高一些。这一点在处理大型数据集的时候就可以很明显地体现出来了,否则在运算过程中 I/O 会成为瓶颈。 + * 目前 PostgreSQL 最显著的优点是它的核心算法的效率,这意味着它的性能优于许多宣称更先进数据库。这一点在处理大型数据集的时候就可以很明显地体现出来了,否则 I/O 处理会成为瓶颈。 * PostgreSQL 也是最灵活的开源数据库之一,使用 Python、Perl、Java、Ruby、C 或者 R 都能够很方便地调用数据库。 * 作为最常用的几个开源数据库之中,PostgreSQL 的社区支持是做得最好的。 - - - #### 劣势 - * 在数据量比较大的时候,PostgreSQL 的效率毋庸置疑是很高的,但对于数据量较小的情况,使用 PostgreSQL 就显得不如其它的一些工具轻量级了。 - + * 在数据量比较大的时候,PostgreSQL 的效率毋庸置疑是很高的,但对于数据量较小的情况,使用 PostgreSQL 就显得不如其它的一些工具快了。 * 尽管拥有一个很优秀的社区支持,但 PostgreSQL 的核心文档仍然需要作出改进。 - - * 如果你需要使用并行计算或者集群化等高级工具,就需要安装 PostgreSQL 的第三方插件。尽管官方有计划将这些功能逐步添加到主要版本当中,但可能会需要再等待好几年才能实现。 - - - + * 如果你需要使用并行计算或者集群化等高级工具,就需要安装 PostgreSQL 的第三方插件。尽管官方有计划将这些功能逐步添加到主要版本当中,但可能会需要再等待好几年才能出现在标准版本中。 ### MariaDB -[MariaDB][7] 是 MySQL 的真正开源发行版本(在 [GNU GPLv2][8] 下发布)。在 Oracle 收购 MySQL 之后,MySQL 的一些核心开发人员认为 Oracle 会破坏 MySQL 的开源理念,因此建立了 MariaDB 这个独立的分支。 +[MariaDB][7] 是 MySQL 的真正开源的发行版本(在 [GNU GPLv2][8] 下发布)。在 Oracle 收购 MySQL 之后,MySQL 的一些核心开发人员认为 Oracle 会破坏 MySQL 的开源理念,因此建立了 MariaDB 这个独立的分支。 -MariaDB 在开发过程中替换了 MySQL 的几个关键组件,但仍然尽可能地保持兼容 MySQL。MariaDB 使用了 Aria 作为存储引擎,这个存储引擎既可以作为事务式引擎,也可以作为非事务式引擎。在 MariaDB 独立出来之前,就[有一些人推测][10] Aria 会成为 MySQL 未来版本中的标准引擎。 +MariaDB 在开发过程中替换了 MySQL 的几个关键组件,但仍然尽可能地保持兼容 MySQL。MariaDB 使用了 Aria 作为存储引擎,这个存储引擎既可以作为事务式引擎,也可以作为非事务式引擎。在 MariaDB 分叉出来之前,就[有一些人推测][10] Aria 会成为 MySQL 未来版本中的标准引擎。 #### 优势 * 由于 MariaDB [频繁进行安全发布][11],很多用户选择使用 MariaDB 而不选择 MySQL。尽管这不一定代表 MariaDB 会比 MySQL 更加安全,但确实表明它的开发社区对安全性十分重视。 - - * 有一些人认为,MariaDB 的主要优点就是它在坚持开源的同时会与 MySQL 保持高度兼容,这就表示从 MySQL 向 MariaDB 的迁移会非常容易。 - + * 有一些人认为,MariaDB 的主要优点就是它在坚持开源的同时会与 MySQL 保持高度兼容,这就意味着从 MySQL 向 MariaDB 的迁移会非常容易。 * 也正是由于这种兼容性,MariaDB 也可以和其它常用于 MySQL 的语言配合使用,因此从 MySQL 迁移到 MariaDB 之后,学习和调试代码的时间成本会非常低。 - - * 你可以将 WordPress 和 MariaDB(而不是 MySQL)[配合使用][12]从而获得更好的性能和更丰富的功能。WordPress 是[最受欢迎的内容管理系统Content Management System][13](CMS),并且拥有活跃的开源开发者社区。各种第三方插件在 WordPress 和 MariaDB 配合使用时都能够正常工作。 - - - + * 你可以将 WordPress 和 MariaDB(而不是 MySQL)[配合使用][12]从而获得更好的性能和更丰富的功能。WordPress 是[最受欢迎的][13]内容管理系统Content Management System(CMS),占据了一半的互联网份额,并且拥有活跃的开源开发者社区。各种第三方插件在 WordPress 和 MariaDB 配合使用时都能够正常工作。 #### 劣势 * MariaDB 有时会变得比较臃肿,尤其是它的 IDX 日志文件在长期使用之后会变得非常大,最终导致性能下降。 - - * MariaDB 的缓存并没有期望中那么快,这可能会让人有所失望。 - + * 缓存是 MariaDB 的另一个工作领域,并没有期望中那么快,这可能会让人有所失望。 * 尽管 MariaDB 最初承诺兼容 MySQL,但目前 MariaDB 已经不是完全兼容 MySQL。如果要从 MySQL 迁移到 MariaDB,就需要额外做一些兼容工作。 - - - ### SQLite [SQLite][14] 可以说是世界上实现最多的数据库引擎,因为它被很多流行的 web 浏览器、操作系统和手机所采用。它最初是作为 MySQL 的轻量级分支所开发的。SQLite 和很多其它的数据库不同,它不采用客户端-服务端的引擎架构,而是将整个软件嵌入到每个实现当中。 @@ -90,30 +72,20 @@ MariaDB 在开发过程中替换了 MySQL 的几个关键组件,但仍然尽 #### 优势 * 如果你需要构建和实现一个小型数据库,SQLite [可能是最好的选择][15]。它小而灵活,不需要费工夫寻求各种变通方案,就可以在嵌入式系统中实现。 - - * SQLite 体积很小,因此速度也很快。其它的一些高级数据库可能会使用复杂的优化方式来提高效率,但不如SQLite 这样减小数据库大小更为直接。 - - * SQLite 被广泛采用也导致它可能是兼容性最高的数据库。如果你希望将应用程序集成到智能手机上,只要有第三方应用程序使用到了 SQLite,就能够正常运行数据库了。 - - - + * SQLite 体积很小,因此速度极快。其它的一些高级数据库可能会使用复杂的优化方式来提高效率,但SQLite 采用了一种更简单的方法:通过减小数据库及其处理软件的大小,以使处理的数据更少。 + * SQLite 被广泛采用也导致它可能是兼容性最高的数据库。如果你希望将应用程序集成到智能手机上,这一点尤为重要:只要是可以工作于广泛环境中的第三方应用程序,就可以原生运行于 iOS 上。 #### 劣势 - * SQLite 的轻量意味着它缺少了很多其它大型数据库的常见功能。例如数据加密就是[抵御网络攻击][16]的标准功能,而 SQLite 却没有内置这个功能。 - - * SQLite 的广泛流行和源码公开使它易于使用,但是也让它更容易遭受攻击。这是它最大的劣势。SQLite 经常被发现高位的漏洞,例如最近的 [Magellan][17]。 - + * SQLite 的体积小意味着它缺少了很多其它大型数据库的常见功能。例如数据加密就是[抵御黑客攻击][16]的标准功能,而 SQLite 却没有内置这个功能。 + * SQLite 的广泛流行和源码公开使它易于使用,但是也让它更容易遭受攻击。这是它最大的劣势。SQLite 经常被发现高危的漏洞,例如最近的 [Magellan][17]。 * 尽管 SQLite 单文件的方式拥有速度上的优势,但是要使用它实现多用户环境却比较困难。 - - - ### 哪个开源数据库才是最好的? -当然,对于开源数据库的选择还是取决于业务的需求以及系统的体量。对于小型数据库或者是使用量比较小的数据库,可以使用比较轻量级的解决方案,这样不仅可以加快实现的速度,而且由于系统的复杂程度不算太高,花在调试上的时间成本也不会太高。 +当然,对于开源数据库的选择还是取决于业务的需求,尤其是系统的体量。对于小型数据库或者是使用量比较小的数据库,可以使用比较轻量级的解决方案,这样不仅可以加快实现的速度,而且由于系统的复杂程度不算太高,花在调试上的时间成本也不会太高。 -而对于大型的系统,尤其是业务增长速度较快的业务,最好还是花时间使用更复杂的数据库(例如 PostgreSQL)。这是一个磨刀不误砍柴工的选择,能够让你不至于在后期再重新选择另一款数据库。 +而对于大型的系统,尤其是在成长性企业中,最好还是花时间使用更复杂的数据库(例如 PostgreSQL)。这是一个磨刀不误砍柴工的选择,能够让你不至于在后期再重新选择另一款数据库。 -------------------------------------------------------------------------------- @@ -122,7 +94,7 @@ via: https://opensource.com/article/19/1/open-source-databases 作者:[Sam Bocetta][a] 选题:[lujun9972][b] 译者:[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/) 荣誉推出 diff --git a/published/201902/20190115 Getting started with Sandstorm, an open source web app platform.md b/published/201902/20190115 Getting started with Sandstorm, an open source web app platform.md new file mode 100644 index 0000000000..ae67f2ede2 --- /dev/null +++ b/published/201902/20190115 Getting started with Sandstorm, an open source web app platform.md @@ -0,0 +1,60 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10535-1.html) +[#]: subject: (Getting started with Sandstorm, an open source web app platform) +[#]: via: (https://opensource.com/article/19/1/productivity-tool-sandstorm) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) + +开始使用 Sandstorm 吧,一个开源 Web 应用平台 +====== + +> 了解 Sandstorm,这是我们在开源工具系列中的第三篇,它将在 2019 年提高你的工作效率。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/sand_dunes_desert_hills_landscape_nature.jpg?itok=wUByylBb) + +每年年初似乎都有疯狂的冲动想提高工作效率。新年的决心,渴望开启新的一年,当然,“抛弃旧的,拥抱新的”的态度促成了这一切。通常这时的建议严重偏向闭源和专有软件,但事实上并不用这样。 + +这是我挑选出的 19 个新的(或者对你而言新的)开源工具中的第三个工具来帮助你在 2019 年更有效率。 + +### Sandstorm + +保持高效不仅仅需要待办事项以及让事情有组织。通常它需要一组工具以使工作流程顺利进行。 + +![](https://opensource.com/sites/default/files/uploads/sandstorm_1.png) + +[Sandstorm][1] 是打包的开源应用集合,它们都可从一个 Web 界面访问,也可在中央控制台进行管理。你可以自己托管或使用 [Sandstorm Oasis][2] 服务。它按用户收费。 + +![](https://opensource.com/sites/default/files/uploads/sandstorm_2.png) + +Sandstorm 有一个市场,在这里可以轻松安装应用。应用包括效率类、财务、笔记、任务跟踪、聊天、游戏等等。你还可以按照[开发人员文档][3]中的应用打包指南打包自己的应用并上传它们。 + +![](https://opensource.com/sites/default/files/uploads/sandstorm_3.png) + +安装后,用户可以创建 [grain][4] - 容器化后的应用数据实例。默认情况下,grain 是私有的,它可以与其他 Sandstorm 用户共享。这意味着它们默认是安全的,用户可以选择与他人共享的内容。 + +![](https://opensource.com/sites/default/files/uploads/sandstorm_4.png) + +Sandstorm 可以从几个不同的外部源进行身份验证,也可以使用无需密码的基于电子邮件的身份验证。使用外部服务意味着如果你已使用其中一种受支持的服务,那么就无需管理另一组凭据。 + +最后,Sandstorm 使安装和使用支持的协作应用变得快速,简单和安全。 + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/productivity-tool-sandstorm + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ksonney (Kevin Sonney) +[b]: https://github.com/lujun9972 +[1]: https://sandstorm.io/ +[2]: https://oasis.sandstorm.io +[3]: https://docs.sandstorm.io/en/latest/developing/ +[4]: https://sandstorm.io/how-it-works diff --git a/published/201902/20190116 The Evil-Twin Framework- A tool for improving WiFi security.md b/published/201902/20190116 The Evil-Twin Framework- A tool for improving WiFi security.md new file mode 100644 index 0000000000..760c2ed1cf --- /dev/null +++ b/published/201902/20190116 The Evil-Twin Framework- A tool for improving WiFi security.md @@ -0,0 +1,230 @@ +[#]: collector: (lujun9972) +[#]: translator: (hopefully2333) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10568-1.html) +[#]: subject: (The Evil-Twin Framework: A tool for improving WiFi security) +[#]: via: (https://opensource.com/article/19/1/evil-twin-framework) +[#]: author: (André Esser https://opensource.com/users/andreesser) + +Evil-Twin 框架:一个用于提升 WiFi 安全性的工具 +====== + +> 了解一款用于对 WiFi 接入点安全进行渗透测试的工具。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-cloud-safe.png?itok=yj2TFPzq) + +越来越多的设备通过无线传输的方式连接到互联网,以及,大范围可用的 WiFi 接入点为攻击者攻击用户提供了很多机会。通过欺骗用户连接到[虚假的 WiFi 接入点][1],攻击者可以完全控制用户的网络连接,这将使得攻击者可以嗅探和篡改用户的数据包,将用户的连接重定向到一个恶意的网站,并通过网络发起其他的攻击。 + +为了保护用户并告诉他们如何避免线上的危险操作,安全审计人员和安全研究员必须评估用户的安全实践能力,用户常常在没有确认该 WiFi 接入点为安全的情况下就连接上了该网络,安全审计人员和研究员需要去了解这背后的原因。有很多工具都可以对 WiFi 的安全性进行审计,但是没有一款工具可以测试大量不同的攻击场景,也没有能和其他工具集成得很好的工具。 + +Evil-Twin Framework(ETF)用于解决 WiFi 审计过程中的这些问题。审计者能够使用 ETF 来集成多种工具并测试该 WiFi 在不同场景下的安全性。本文会介绍 ETF 的框架和功能,然后会提供一些案例来说明该如何使用这款工具。 + +### ETF 的架构 + +ETF 的框架是用 [Python][2] 写的,因为这门开发语言的代码非常易读,也方便其他开发者向这个项目贡献代码。除此之外,很多 ETF 的库,比如 [Scapy][3],都是为 Python 开发的,很容易就能将它们用于 ETF。 + +ETF 的架构(图 1)分为不同的彼此交互的模块。该框架的设置都写在一个单独的配置文件里。用户可以通过 `ConfigurationManager` 类里的用户界面来验证并修改这些配置。其他模块只能读取这些设置并根据这些设置进行运行。 + +![Evil-Twin Framework Architecture][5] + +*图 1:Evil-Twin 的框架架构* + +ETF 支持多种与框架交互的用户界面,当前的默认界面是一个交互式控制台界面,类似于 [Metasploit][6] 那种。正在开发用于桌面/浏览器使用的图形用户界面(GUI)和命令行界面(CLI),移动端界面也是未来的一个备选项。用户可以使用交互式控制台界面来修改配置文件里的设置(最终会使用 GUI)。用户界面可以与存在于这个框架里的每个模块进行交互。 + +WiFi 模块(AirCommunicator)用于支持多种 WiFi 功能和攻击类型。该框架确定了 Wi-Fi 通信的三个基本支柱:数据包嗅探、自定义数据包注入和创建接入点。三个主要的 WiFi 通信模块 AirScanner、AirInjector,和 AirHost,分别用于数据包嗅探、数据包注入,和接入点创建。这三个类被封装在主 WiFi 模块 AirCommunicator 中,AirCommunicator 在启动这些服务之前会先读取这些服务的配置文件。使用这些核心功能的一个或多个就可以构造任意类型的 WiFi 攻击。 + +要使用中间人(MITM)攻击(这是一种攻击 WiFi 客户端的常见手法),ETF 有一个叫做 ETFITM(Evil-Twin Framework-in-the-Middle)的集成模块,这个模块用于创建一个 web 代理,来拦截和修改经过的 HTTP/HTTPS 数据包。 + +许多其他的工具也可以利用 ETF 创建的 MITM。通过它的可扩展性,ETF 能够支持它们,而不必单独地调用它们,你可以通过扩展 Spawner 类来将这些工具添加到框架里。这使得开发者和安全审计人员可以使用框架里预先配置好的参数字符来调用程序。 + +扩展 ETF 的另一种方法就是通过插件。有两类插件:WiFi 插件和 MITM 插件。MITM 插件是在 MITM 代理运行时可以执行的脚本。代理会将 HTTP(s) 请求和响应传递给可以记录和处理它们的插件。WiFi 插件遵循一个更加复杂的执行流程,但仍然会给想参与开发并且使用自己插件的贡献者提供一个相对简单的 API。WiFi 插件还可以进一步地划分为三类,其中每个对应一个核心 WiFi 通信模块。 + +每个核心模块都有一些特定事件能触发响应的插件的执行。举个例子,AirScanner 有三个已定义的事件,可以对其响应进行编程处理。事件通常对应于服务开始运行之前的设置阶段、服务正在运行时的中间执行阶段、服务完成后的卸载或清理阶段。因为 Python 允许多重继承,所以一个插件可以继承多个插件类。 + +上面的图 1 是框架架构的摘要。从 ConfigurationManager 指出的箭头意味着模块会从中读取信息,指向它的箭头意味着模块会写入/修改配置。 + +### 使用 ETF 的例子 + +ETF 可以通过多种方式对 WiFi 的网络安全或者终端用户的 WiFi 安全意识进行渗透测试。下面的例子描述了这个框架的一些渗透测试功能,例如接入点和客户端检测、对使用 WPA 和 WEP 类型协议的接入点进行攻击,和创建 evil twin 接入点。 + +这些例子是使用 ETF 和允许进行 WiFi 数据捕获的 WiFi 卡设计的。它们也在 ETF 设置命令中使用了下面这些缩写: + + * **APS** Access Point SSID + * **APB** Access Point BSSID + * **APC** Access Point Channel + * **CM** Client MAC address + +在实际的测试场景中,确保你使用了正确的信息来替换这些缩写。 + +#### 在解除认证攻击后捕获 WPA 四次握手的数据包。 + +这个场景(图 2)做了两个方面的考虑:解除认证攻击de-authentication attack和捕获 WPA 四次握手数据包的可能性。这个场景从一个启用了 WPA/WPA2 的接入点开始,这个接入点有一个已经连上的客户端设备(在本例中是一台智能手机)。目的是通过常规的解除认证攻击(LCTT 译注:类似于 DoS 攻击)来让客户端断开和 WiFi 的网络,然后在客户端尝试重连的时候捕获 WPA 的握手包。重连会在断开连接后马上手动完成。 + +![Scenario for capturing a WPA handshake after a de-authentication attack][8] + +*图 2:在解除认证攻击后捕获 WPA 握手包的场景* + +在这个例子中需要考虑的是 ETF 的可靠性。目的是确认工具是否一直都能捕获 WPA 的握手数据包。每个工具都会用来多次复现这个场景,以此来检查它们在捕获 WPA 握手数据包时的可靠性。 + +使用 ETF 来捕获 WPA 握手数据包的方法不止一种。一种方法是使用 AirScanner 和 AirInjector 两个模块的组合;另一种方法是只使用 AirInjector。下面这个场景是使用了两个模块的组合。 + +ETF 启用了 AirScanner 模块并分析 IEEE 802.11 数据帧来发现 WPA 握手包。然后 AirInjecto 就可以使用解除认证攻击来强制客户端断开连接,以进行重连。必须在 ETF 上执行下面这些步骤才能完成上面的目标: + + 1. 进入 AirScanner 配置模式:`config airscanner` + 2. 设置 AirScanner 不跳信道:`config airscanner` + 3. 设置信道以嗅探经过 WiFi 接入点信道的数据(APC):`set fixed_sniffing_channel = ` + 4. 使用 CredentialSniffer 插件来启动 AirScanner 模块:`start airscanner with credentialsniffer` + 5. 从已嗅探的接入点列表中添加目标接入点的 BSSID(APS):`add aps where ssid = ` + 6. 启用 AirInjector 模块,在默认情况下,它会启用解除认证攻击:`start airinjector` + +这些简单的命令设置能让 ETF 在每次测试时执行成功且有效的解除认证攻击。ETF 也能在每次测试的时候捕获 WPA 的握手数据包。下面的代码能让我们看到 ETF 成功的执行情况。 + +``` +███████╗████████╗███████╗ +██╔════╝╚══██╔══╝██╔════╝ +█████╗     ██║   █████╗   +██╔══╝     ██║   ██╔══╝   +███████╗   ██║   ██║     +╚══════╝   ╚═╝   ╚═╝     +                                        + +[+] Do you want to load an older session? [Y/n]: n +[+] Creating new temporary session on 02/08/2018 +[+] Enter the desired session name: +ETF[etf/aircommunicator/]::> config airscanner +ETF[etf/aircommunicator/airscanner]::> listargs +  sniffing_interface =               wlan1; (var) +              probes =                True; (var) +             beacons =                True; (var) +        hop_channels =               false; (var) +fixed_sniffing_channel =                  11; (var) +ETF[etf/aircommunicator/airscanner]::> start airscanner with +arpreplayer        caffelatte         credentialsniffer  packetlogger       selfishwifi         +ETF[etf/aircommunicator/airscanner]::> start airscanner with credentialsniffer +[+] Successfully added credentialsniffer plugin. +[+] Starting packet sniffer on interface 'wlan1' +[+] Set fixed channel to 11 +ETF[etf/aircommunicator/airscanner]::> add aps where ssid = CrackWPA +ETF[etf/aircommunicator/airscanner]::> start airinjector +ETF[etf/aircommunicator/airscanner]::> [+] Starting deauthentication attack +                    - 1000 bursts of 1 packets +                    - 1 different packets +[+] Injection attacks finished executing. +[+] Starting post injection methods +[+] Post injection methods finished +[+] WPA Handshake found for client '70:3e:ac:bb:78:64' and network 'CrackWPA' +``` + +#### 使用 ARP 重放攻击并破解 WEP 无线网络 + +下面这个场景(图 3)将关注[地址解析协议][9](ARP)重放攻击的效率和捕获包含初始化向量(IVs)的 WEP 数据包的速度。相同的网络可能需要破解不同数量的捕获的 IVs,所以这个场景的 IVs 上限是 50000。如果这个网络在首次测试期间,还未捕获到 50000 IVs 就崩溃了,那么实际捕获到的 IVs 数量会成为这个网络在接下来的测试里的新的上限。我们使用 `aircrack-ng` 对数据包进行破解。 + +测试场景从一个使用 WEP 协议进行加密的 WiFi 接入点和一台知道其密钥的离线客户端设备开始 —— 为了测试方便,密钥使用了 12345,但它可以是更长且更复杂的密钥。一旦客户端连接到了 WEP 接入点,它会发送一个不必要的 ARP 数据包;这是要捕获和重放的数据包。一旦被捕获的包含 IVs 的数据包数量达到了设置的上限,测试就结束了。 + +![Scenario for capturing a WPA handshake after a de-authentication attack][11] + +*图 3:在进行解除认证攻击后捕获 WPA 握手包的场景* + +ETF 使用 Python 的 Scapy 库来进行包嗅探和包注入。为了最大限度地解决 Scapy 里的已知的性能问题,ETF 微调了一些低级库,来大大加快包注入的速度。对于这个特定的场景,ETF 为了更有效率地嗅探,使用了 `tcpdump` 作为后台进程而不是 Scapy,Scapy 用于识别加密的 ARP 数据包。 + +这个场景需要在 ETF 上执行下面这些命令和操作: + + 1. 进入 AirScanner 设置模式:`config airscanner` + 2. 设置 AirScanner 不跳信道:`set hop_channels = false` + 3. 设置信道以嗅探经过接入点信道的数据(APC):`set fixed_sniffing_channel = ` + 4. 进入 ARPReplayer 插件设置模式:`config arpreplayer` + 5. 设置 WEP 网络目标接入点的 BSSID(APB):`set target_ap_bssid ` + 6. 使用 ARPReplayer 插件启动 AirScanner 模块:`start airscanner with arpreplayer` + +在执行完这些命令后,ETF 会正确地识别加密的 ARP 数据包,然后成功执行 ARP 重放攻击,以此破坏这个网络。 + +#### 使用一款全能型蜜罐 + +图 4 中的场景使用相同的 SSID 创建了多个接入点,对于那些可以探测到但是无法接入的 WiFi 网络,这个技术可以发现网络的加密类型。通过启动具有所有安全设置的多个接入点,客户端会自动连接和本地缓存的接入点信息相匹配的接入点。 + +![Scenario for capturing a WPA handshake after a de-authentication attack][13] + +*图 4:在解除认证攻击后捕获 WPA 握手包数据。* + +使用 ETF,可以去设置 `hostapd` 配置文件,然后在后台启动该程序。`hostapd` 支持在一张无线网卡上通过设置虚拟接口开启多个接入点,并且因为它支持所有类型的安全设置,因此可以设置完整的全能蜜罐。对于使用 WEP 和 WPA(2)-PSK 的网络,使用默认密码,和对于使用 WPA(2)-EAP 的网络,配置“全部接受”策略。 + +对于这个场景,必须在 ETF 上执行下面的命令和操作: + + 1. 进入 APLauncher 设置模式:`config aplauncher` + 2. 设置目标接入点的 SSID(APS):`set ssid = ` + 3. 设置 APLauncher 为全部接收的蜜罐:`set catch_all_honeypot = true` + 4. 启动 AirHost 模块:`start airhost` + +使用这些命令,ETF 可以启动一个包含所有类型安全配置的完整全能蜜罐。ETF 同样能自动启动 DHCP 和 DNS 服务器,从而让客户端能与互联网保持连接。ETF 提供了一个更好、更快、更完整的解决方案来创建全能蜜罐。下面的代码能够看到 ETF 的成功执行。 + +``` +███████╗████████╗███████╗ +██╔════╝╚══██╔══╝██╔════╝ +█████╗     ██║   █████╗   +██╔══╝     ██║   ██╔══╝   +███████╗   ██║   ██║     +╚══════╝   ╚═╝   ╚═╝     +                                        + +[+] Do you want to load an older session? [Y/n]: n +[+] Creating ne´,cxzw temporary session on 03/08/2018 +[+] Enter the desired session name: +ETF[etf/aircommunicator/]::> config aplauncher +ETF[etf/aircommunicator/airhost/aplauncher]::> setconf ssid CatchMe +ssid = CatchMe +ETF[etf/aircommunicator/airhost/aplauncher]::> setconf catch_all_honeypot true +catch_all_honeypot = true +ETF[etf/aircommunicator/airhost/aplauncher]::> start airhost +[+] Killing already started processes and restarting network services +[+] Stopping dnsmasq and hostapd services +[+] Access Point stopped... +[+] Running airhost plugins pre_start +[+] Starting hostapd background process +[+] Starting dnsmasq service +[+] Running airhost plugins post_start +[+] Access Point launched successfully +[+] Starting dnsmasq service +``` + +### 结论和以后的工作 + +这些场景使用常见和众所周知的攻击方式来帮助验证 ETF 测试 WIFI 网络和客户端的能力。这个结果同样证明了该框架的架构能在平台现有功能的优势上开发新的攻击向量和功能。这会加快新的 WiFi 渗透测试工具的开发,因为很多的代码已经写好了。除此之外,将 WiFi 技术相关的东西都集成到一个单独的工具里,会使 WiFi 渗透测试更加简单高效。 + +ETF 的目标不是取代现有的工具,而是为它们提供补充,并为安全审计人员在进行 WiFi 渗透测试和提升用户安全意识时,提供一个更好的选择。 + +ETF 是 [GitHub][14] 上的一个开源项目,欢迎社区为它的开发做出贡献。下面是一些您可以提供帮助的方法。 + +当前 WiFi 渗透测试的一个限制是无法在测试期间记录重要的事件。这使得报告已经识别到的漏洞更加困难且准确性更低。这个框架可以实现一个记录器,每个类都可以来访问它并创建一个渗透测试会话报告。 + +ETF 工具的功能涵盖了 WiFi 渗透测试的方方面面。一方面,它让 WiFi 目标侦察、漏洞挖掘和攻击这些阶段变得更加容易。另一方面,它没有提供一个便于提交报告的功能。增加了会话的概念和会话报告的功能,比如在一个会话期间记录重要的事件,会极大地增加这个工具对于真实渗透测试场景的价值。 + +另一个有价值的贡献是扩展该框架来促进 WiFi 模糊测试。IEEE 802.11 协议非常的复杂,考虑到它在客户端和接入点两方面都会有多种实现方式。可以假设这些实现都包含 bug 甚至是安全漏洞。这些 bug 可以通过对 IEEE 802.11 协议的数据帧进行模糊测试来进行发现。因为 Scapy 允许自定义的数据包创建和数据包注入,可以通过它实现一个模糊测试器。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/evil-twin-framework + +作者:[André Esser][a] +选题:[lujun9972][b] +译者:[hopefully2333](https://github.com/hopefully2333) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/andreesser +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Rogue_access_point +[2]: https://www.python.org/ +[3]: https://scapy.net +[4]: /file/417776 +[5]: https://opensource.com/sites/default/files/uploads/pic1.png (Evil-Twin Framework Architecture) +[6]: https://www.metasploit.com +[7]: /file/417781 +[8]: https://opensource.com/sites/default/files/uploads/pic2.png (Scenario for capturing a WPA handshake after a de-authentication attack) +[9]: https://en.wikipedia.org/wiki/Address_Resolution_Protocol +[10]: /file/417786 +[11]: https://opensource.com/sites/default/files/uploads/pic3.png (Scenario for capturing a WPA handshake after a de-authentication attack) +[12]: /file/417791 +[13]: https://opensource.com/sites/default/files/uploads/pic4.png (Scenario for capturing a WPA handshake after a de-authentication attack) +[14]: https://github.com/Esser420/EvilTwinFramework diff --git a/translated/tech/20190117 How to Update-Change Users Password in Linux Using Different Ways.md b/published/201902/20190117 How to Update-Change Users Password in Linux Using Different Ways.md similarity index 63% rename from translated/tech/20190117 How to Update-Change Users Password in Linux Using Different Ways.md rename to published/201902/20190117 How to Update-Change Users Password in Linux Using Different Ways.md index 2c8cc10e3c..0b0b5132bd 100644 --- a/translated/tech/20190117 How to Update-Change Users Password in Linux Using Different Ways.md +++ b/published/201902/20190117 How to Update-Change Users Password in Linux Using Different Ways.md @@ -1,50 +1,37 @@ [#]: collector: (lujun9972) [#]: translator: (MjSeven) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10514-1.html) [#]: subject: (How to Update/Change Users Password in Linux Using Different Ways) [#]: via: (https://www.2daygeek.com/linux-passwd-chpasswd-command-set-update-change-users-password-in-linux-using-shell-script/) [#]: author: (Vinoth Kumar https://www.2daygeek.com/author/vinoth/) -如何使用不同的方式更新或更改 Linux 用户密码 +如何使用不同的方式更改 Linux 用户密码 ====== -在 Linux 中创建用户账号时,设置用户密码是一件基本的事情。 +在 Linux 中创建用户账号时,设置用户密码是一件基本的事情。每个人都使用 `passwd` 命令跟上用户名,比如 `passwd USERNAME` 来为用户设置密码。 -每个人都使用 passwd 命令和用户名,比如 `passwd USERNAME` 来为用户设置密码。 +确保你一定要设置一个难以猜测的密码,这可以帮助你使系统更安全。我的意思是,密码应该是字母、符号和数字的组合。此外,出于安全原因,我建议你至少每月更改一次密码。 -确保你一定设置一个难以猜测的密码,这可以帮助你使系统更安全。 +当你使用 `passwd` 命令时,它会要求你输入两次密码来设置。这是一种设置用户密码的原生方法。 -我的意思是,密码应该是字母,符合和数字的组合。 +如果你不想两次更新密码,并希望以不同的方式进行更新,怎么办呢?当然,这可以的,有可能做到。 -此外,出于安全原因,我建议你至少每月更改一次密码。 - -当你使用 passwd 命令时,它会要求你输入两次密码来设置。这是一种设置用户密码的原生方法。 - -如果你不想两次更新密码,并希望以不同的方式进行更新,怎么办呢? - -当然,这可以的,有可能做到。 - -如果你是 Linux 管理员,你可能已经多次问过下面的问题。 - -你们可能,也可能没有得到这些问题的答案。 +如果你是 Linux 管理员,你可能已经多次问过下面的问题。你可能、也可能没有得到这些问题的答案。 无论如何,不要担心,我们会回答你所有的问题。 - * 如何用一条命令更新或更改用户密码? - * 如何在 Linux 中为多个用户更新或更改相同的密码? - * 如何在 Linux 中更新或更改多个用户的密码? - * 如何在 Linux 中更新或更改多个用户的密码?(to 校正:这句和上一句有不同?) - * 如何在 Linux 中更新或更改多个用户的不同密码? - * 如何在多个 Linux 服务器中更新或更改用户的密码? - * 如何在多个 Linux 服务器中更新或更改多个用户的密码? + * 如何用一条命令更改用户密码? + * 如何在 Linux 中为多个用户更改为相同的密码? + * 如何在 Linux 中更改多个用户的密码? + * 如何在 Linux 中为多个用户更改为不同的密码? + * 如何在多个 Linux 服务器中更改用户的密码? + * 如何在多个 Linux 服务器中更改多个用户的密码? +### 方法-1:使用 passwd 命令 - -### 方法-1: 使用 passwd 命令 - -passwd 命令是在 Linux 中为用户设置,更新或更改密码的标准方法。以下是标准方法。 +`passwd` 命令是在 Linux 中为用户设置、更改密码的标准方法。以下是标准方法。 ``` # passwd renu @@ -63,17 +50,17 @@ Changing password for user thanu. passwd: all authentication tokens updated successfully. ``` -### 方法-2: 使用 chpasswd 命令 +### 方法-2:使用 chpasswd 命令 -chpasswd 是另一个命令,允许我们为 Linux 中的用户设置,更新或更改密码。如果希望在一条命令中使用 chpasswd 命令更改用户密码,用以下格式。 +`chpasswd` 是另一个命令,允许我们为 Linux 中的用户设置、更改密码。如果希望在一条命令中使用 `chpasswd` 命令更改用户密码,用以下格式。 ``` # echo "thanu:new_password" | chpasswd ``` -### 方法-3: 如何为多个用户设置不同的密码 +### 方法-3:如何为多个用户设置不同的密码 -如果你要为 Linux 中的多个用户设置,更新或更改密码,并且使用不同的密码,使用以下脚本。 +如果你要为 Linux 中的多个用户设置、更改密码,并且使用不同的密码,使用以下脚本。 为此,首先我们需要使用以下命令获取用户列表。下面的命令将列出拥有 `/home` 目录的用户,并将输出重定向到 `user-list.txt` 文件。 @@ -81,7 +68,7 @@ chpasswd 是另一个命令,允许我们为 Linux 中的用户设置,更新 # cat /etc/passwd | grep "/home" | cut -d":" -f1 > user-list.txt ``` -使用 cat 命令列出用户。如果你不想重置特定用户的密码,那么从列表中移除该用户。 +使用 `cat` 命令列出用户。如果你不想重置特定用户的密码,那么从列表中移除该用户。 ``` # cat user-list.txt @@ -92,7 +79,7 @@ thanu renu ``` -创建以下小 shell 脚本来实现此目的。 +创建以下 shell 小脚本来实现此目的。 ``` # vi password-update.sh @@ -130,9 +117,9 @@ Changing password for user renu. passwd: all authentication tokens updated successfully. ``` -### 方法-4: 如何为多个用户设置相同的密码 +### 方法-4:如何为多个用户设置相同的密码 -如果要在 Linux 中为多个用户设置,更新或更改相同的密码,使用以下脚本。 +如果要在 Linux 中为多个用户设置、更改相同的密码,使用以下脚本。 ``` # vi password-update.sh @@ -145,7 +132,7 @@ chage -d 0 $user done ``` -### 方法-5: 如何在多个服务器中更改用户密码 +### 方法-5:如何在多个服务器中更改用户密码 如果希望更改多个服务器中的用户密码,使用以下脚本。在本例中,我们将更改 `renu` 用户的密码,确保你必须提供你希望更新密码的用户名而不是我们的用户名。 @@ -179,9 +166,9 @@ Retype new password: Changing password for user renu. passwd: all authentication tokens updated successfully. ``` -### 方法-6: 如何使用 pssh 命令更改多个服务器中的用户密码 +### 方法-6:如何使用 pssh 命令更改多个服务器中的用户密码 -pssh 是一个在多个主机上并行执行 ssh 的程序。它提供了一些特性,例如向所有进程发送输入,向 sshh 传递密码,将输出保存到文件以及超时处理。导航到以下链接以了解关于 **[PSSH 命令][1]**的更多信息。 +`pssh` 是一个在多个主机上并行执行 ssh 连接的程序。它提供了一些特性,例如向所有进程发送输入,向 ssh 传递密码,将输出保存到文件以及超时处理。导航到以下链接以了解关于 [PSSH 命令][1]的更多信息。 ``` # pssh -i -h /tmp/server-list.txt "printf '%s\n' new_pass new_pass | passwd --stdin root" @@ -203,9 +190,9 @@ Stderr: New password: BAD PASSWORD: it is based on a dictionary word BAD PASSWORD: is too simple ``` -### 方法-7: 如何使用 chpasswd 命令更改多个服务器中的用户密码 +### 方法-7:如何使用 chpasswd 命令更改多个服务器中的用户密码 -或者,我们可以使用 chpasswd 命令更新多个服务器中的用户密码。 +或者,我们可以使用 `chpasswd` 命令更新多个服务器中的用户密码。 ``` # ./password-update.sh @@ -217,13 +204,21 @@ ssh [email protected]$server 'echo "magi:new_password" | chpasswd' done ``` -### 方法-8: 如何使用 chpasswd 命令在 Linux 服务器中更改多个用户的密码 +### 方法-8:如何使用 chpasswd 命令在 Linux 服务器中更改多个用户的密码 为此,首先创建一个文件,以下面的格式更新用户名和密码。在本例中,我创建了一个名为 `user-list.txt` 的文件。 参考下面的详细信息。 -创建下面的小 shell 脚本来实现这一点。 +``` +# cat user-list.txt +magi:new@123 +daygeek:new@123 +thanu:new@123 +renu:new@123 +``` + +创建下面的 shell 小脚本来实现这一点。 ``` # vi password-update.sh @@ -242,7 +237,7 @@ via: https://www.2daygeek.com/linux-passwd-chpasswd-command-set-update-change-us 作者:[Vinoth Kumar][a] 选题:[lujun9972][b] 译者:[MjSeven](https://github.com/MjSeven) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/20190119 Get started with Roland, a random selection tool for the command line.md b/published/201902/20190119 Get started with Roland, a random selection tool for the command line.md similarity index 100% rename from published/20190119 Get started with Roland, a random selection tool for the command line.md rename to published/201902/20190119 Get started with Roland, a random selection tool for the command line.md diff --git a/published/20190120 Get started with HomeBank, an open source personal finance app.md b/published/201902/20190120 Get started with HomeBank, an open source personal finance app.md similarity index 100% rename from published/20190120 Get started with HomeBank, an open source personal finance app.md rename to published/201902/20190120 Get started with HomeBank, an open source personal finance app.md diff --git a/published/201902/20190121 Get started with TaskBoard, a lightweight kanban board.md b/published/201902/20190121 Get started with TaskBoard, a lightweight kanban board.md new file mode 100644 index 0000000000..bff5c209c7 --- /dev/null +++ b/published/201902/20190121 Get started with TaskBoard, a lightweight kanban board.md @@ -0,0 +1,59 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10539-1.html) +[#]: subject: (Get started with TaskBoard, a lightweight kanban board) +[#]: via: (https://opensource.com/article/19/1/productivity-tool-taskboard) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) + +开始使用 TaskBoard 吧,一款轻量级看板 +====== + +> 了解我们在开源工具系列中的第九个工具,它将帮助你在 2019 年提高工作效率。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk) + +每年年初似乎都有疯狂的冲动想提高工作效率。新年的决心,渴望开启新的一年,当然,“抛弃旧的,拥抱新的”的态度促成了这一切。通常这时的建议严重偏向闭源和专有软件,但事实上并不用这样。 + +这是我挑选出的 19 个新的(或者对你而言新的)开源工具中的第九个工具来帮助你在 2019 年更有效率。 + +### TaskBoard + +正如我在本系列的[第二篇文章][1]中所写的那样,[看板][2]现在非常受欢迎。但并非所有的看板都是相同的。[TaskBoard][3] 是一个易于在现有 Web 服务器上部署的 PHP 应用,它有一些易于使用和管理的功能。 + +![](https://opensource.com/sites/default/files/uploads/taskboard-1.png) + +[安装][4]它只需要解压 Web 服务器上的文件,运行一两个脚本,并确保目录可正常访问。第一次启动时,你会看到一个登录页面,然后可以就可以添加用户和制作看板了。看板创建选项包括添加要使用的列以及设置卡片的默认颜色。你还可以将用户分配给指定看板,这样每个人都只能看到他们需要查看的看板。 + +用户管理是轻量级的,所有帐户都是服务器的本地帐户。你可以为服务器上的每个用户设置默认看板,用户也可以设置自己的默认看板。当有人在多个看板上工作时,这个选项非常有用。 + +![](https://opensource.com/sites/default/files/uploads/taskboard-2.png) + +TaskBoard 还允许你创建自动操作,包括更改用户分配、列或卡片类别这些操作。虽然 TaskBoard 不如其他一些看板应用那么强大,但你可以设置自动操作,使看板用户更容易看到卡片、清除截止日期,并根据需要自动为人们分配新卡片。例如,在下面的截图中,如果将卡片分配给 “admin” 用户,那么它的颜色将更改为红色,并且当将卡片分配给我的用户时,其颜色将更改为蓝绿色。如果项目已添加到“待办事项”列,我还添加了一个操作来清除项目的截止日期,并在发生这种情况时自动将卡片分配给我的用户。 + +![](https://opensource.com/sites/default/files/uploads/taskboard-3.png) + +卡片非常简单。虽然它们没有开始日期,但它们确实有结束日期和点数字段。点数可用于估计所需的时间、所需的工作量或仅是一般优先级。使用点数是可选的,但如果你使用 TaskBoard 进行 scrum 规划或其他敏捷技术,那么这是一个非常方便的功能。你还可以按用户和类别过滤视图。这对于正在进行多个工作流的团队非常有用,因为它允许团队负责人或经理了解进度状态或人员工作量。 + +![](https://opensource.com/sites/default/files/uploads/taskboard-4.png) + +如果你需要一个相当轻便的看板,请看下 TaskBoard。它安装快速,有一些很好的功能,且非常、非常容易使用。它还足够的灵活性,可用于开发团队,个人任务跟踪等等。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/productivity-tool-taskboard + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ksonney (Kevin Sonney) +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10454-1.html +[2]: https://en.wikipedia.org/wiki/Kanban +[3]: https://taskboard.matthewross.me/ +[4]: https://taskboard.matthewross.me/docs/ diff --git a/translated/tech/20190122 Dcp (Dat Copy) - Easy And Secure Way To Transfer Files Between Linux Systems.md b/published/201902/20190122 Dcp (Dat Copy) - Easy And Secure Way To Transfer Files Between Linux Systems.md similarity index 62% rename from translated/tech/20190122 Dcp (Dat Copy) - Easy And Secure Way To Transfer Files Between Linux Systems.md rename to published/201902/20190122 Dcp (Dat Copy) - Easy And Secure Way To Transfer Files Between Linux Systems.md index 266f82a30c..ed9f269196 100644 --- a/translated/tech/20190122 Dcp (Dat Copy) - Easy And Secure Way To Transfer Files Between Linux Systems.md +++ b/published/201902/20190122 Dcp (Dat Copy) - Easy And Secure Way To Transfer Files Between Linux Systems.md @@ -1,83 +1,79 @@ [#]: collector: (lujun9972) -[#]: translator: (dianbanjiu ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (dianbanjiu) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10516-1.html) [#]: subject: (Dcp (Dat Copy) – Easy And Secure Way To Transfer Files Between Linux Systems) [#]: via: (https://www.2daygeek.com/dcp-dat-copy-secure-way-to-transfer-files-between-linux-systems/) [#]: author: (Vinoth Kumar https://www.2daygeek.com/author/vinoth/) -Dcp(Dat Copy)—— 在不同 Linux 系统之间传输文件的安全又容易的方式 +dcp:采用对等网络传输文件的方式 ====== -Linux 本就有 scp 和 rsync 可以完美地完成这个任务。然而我们今天还是想试点新东西。 - -同时我们也很鼓励那些使用不同的理论和新技术开发新东西的开发者。 +Linux 本就有 `scp` 和 `rsync` 可以完美地完成这个任务。然而我们今天还是想试点新东西。同时我们也想鼓励那些使用不同的理论和新技术开发新东西的开发者。 我们也写过其他很多有关这个主题的文章,你可以点击下面的链接访问这些内容。 -它们分别是 **[OnionShare][1]**,**[Magic Wormhole][2]**,**[Transfer.sh][3]** 和 **ffsend**。 +它们分别是 [OnionShare][1]、[Magic Wormhole][2]、[Transfer.sh][3] 和 ffsend。 -### 什么是 Dcp? +### 什么是 dcp? -[dcp][4] 在不同主机之间使用对等网络复制文件。 +[dcp][4] 可以在不同主机之间使用 Dat 对等网络复制文件。 -dcp 被视作一个像是 scp 这样工具的替代品,无需在主机间进行 SSH 授权。 +`dcp` 被视作一个像是 `scp` 这样工具的替代品,而无需在主机间进行 SSH 授权。 -这可以让你在两个主机间传输文件时,无需操心所述主机之间互相访问的细节,以及这些主机是否使用了 NATs。 +这可以让你在两个主机间传输文件时,无需操心所述主机之间互相访问的细节,以及这些主机是否使用了 NAT。 -dcp 零配置、安全、快速、且是 P2P 传输。这并不是一个商用软件,使用产生的风险将由使用者自己承担。 +`dcp` 零配置、安全、快速、且是 P2P 传输。这并不是一个商用软件,使用产生的风险将由使用者自己承担。 ### 什么是 Dat 协议 -Dat 是一个 P2P 协议,是一个致力于下一代 Web 的社区驱动的项目。 +Dat 是一个 P2P 协议,是一个致力于下一代 Web 的由社区驱动的项目。 ### dcp 如何工作 -dcp 将会为指定的文件或者文件夹创建一个 dat 归档,并生成一个公钥,使用这个公钥可以让其他人从另外一台主机上下载上面的文件。 +`dcp` 将会为指定的文件或者文件夹创建一个 dat 归档,并生成一个公开密钥,使用这个公开密钥可以让其他人从另外一台主机上下载上面的文件。 -使用网络共享的任何数据都使用归档的公钥加密,也就是说文件的接收权仅限于那些知道公钥的人。 +使用网络共享的任何数据都使用该归档的公开密钥加密,也就是说文件的接收权仅限于那些拥有该公开密钥的人。 ### dcp 使用案例 - * 向多个同事发送文件 —— 只需要告诉他们生成的公钥,然后他们就可以在他们的机器上收到对应的文件了。 + * 向多个同事发送文件 —— 只需要告诉他们生成的公开密钥,然后他们就可以在他们的机器上收到对应的文件了。 * 无需设置 SSH 授权就可以在你本地网络的两个不同物理机上同步文件。 * 无需压缩文件并把文件上传到云端就可以轻松地发送文件。 * 当你有 shell 授权而没有 SSH 授权时也可以复制文件到远程服务器上。 * 在没有很好的 SSH 支持的 Linux/macOS 以及 Windows 系统之间分享文件。 - - ### 如何在 Linux 上安装 NodeJS & npm? -dcp 是用 JavaScript 写成的,所以在安装 dcp 前,需要先安装 NodeJS。在 Linux 上使用下面的命令安装 NodeJS。 +`dcp` 是用 JavaScript 写成的,所以在安装 `dcp` 前,需要先安装 NodeJS。在 Linux 上使用下面的命令安装 NodeJS。 -**Fedora** 系统,使用 **[DNF 命令][5]** 安装 NodeJS & npm。 +Fedora 系统,使用 [DNF 命令][5] 安装 NodeJS & npm。 ``` $ sudo dnf install nodejs npm ``` -**`Debian/Ubuntu`** 系统,使用 **[APT-GET 命令][6]** 或者 **[APT 命令][6]** 安装 NodeJS & npm。 +Debian/Ubuntu 系统,使用 [APT-GET 命令][6] 或者 [APT 命令][6] 安装 NodeJS & npm。 ``` $ sudo apt install nodejs npm ``` -**`Arch Linux`** 系统,使用 **[Pacman 命令][8]** 安装 NodeJS & npm。 +Arch Linux 系统,使用 [Pacman 命令][8] 安装 NodeJS & npm。 ``` $ sudo pacman -S nodejs npm ``` -**`RHEL/CentOS`** 系统,使用 **[YUM 命令][9]** 安装 NodeJS & npm。 +RHEL/CentOS 系统,使用 [YUM 命令][9] 安装 NodeJS & npm。 ``` $ sudo yum install epel-release $ sudo yum install nodejs npm ``` -**`openSUSE Leap`** 系统,使用 **[Zypper 命令][10]** 安装 NodeJS & npm。 +openSUSE Leap 系统,使用 [Zypper 命令][10] 安装 NodeJS & npm。 ``` $ sudo zypper nodejs6 @@ -85,26 +81,27 @@ $ sudo zypper nodejs6 ### 如何在 Linux 上安装 dcp? -在安装好 NodeJS 后,使用下面的 npm 命令安装 dcp。 +在安装好 NodeJS 后,使用下面的 `npm` 命令安装 `dcp`。 -npm 是一个 JavaScript 的包管理。它是 JavaScript 的运行环境 Node.js 的默认包管理。 +`npm` 是一个 JavaScript 的包管理器。它是 JavaScript 的运行环境 Node.js 的默认包管理器。 ``` # npm i -g dat-cp ``` + ### 如何通过 dcp 发送文件? -在 dcp 命令后跟你想要传输的文件或者文件夹。而且无需注明目标机器的名字。 +在 `dcp` 命令后跟你想要传输的文件或者文件夹。而且无需注明目标机器的名字。 ``` # dcp [File Name Which You Want To Transfer] ``` -在你运行 dcp 命令时将会为传送的文件生成一个 dat 归档。一旦执行完成将会在页面底部生成一个公钥。 +在你运行 `dcp` 命令时将会为传送的文件生成一个 dat 归档。一旦执行完成将会在页面底部生成一个公开密钥。(LCTT 译注:此处并非非对称加密中的公钥/私钥对,而是一种公开的密钥,属于对称加密。) ### 如何通过 dcp 接收文件 -在远程服务器上输入公钥即可接收对应的文件或者文件夹。 +在远程服务器上输入公开密钥即可接收对应的文件或者文件夹。 ``` # dcp [Public Key] @@ -117,24 +114,31 @@ npm 是一个 JavaScript 的包管理。它是 JavaScript 的运行环境 Node.j ``` 下面这个例子我们将会传输单个文件。 + ![][12] -上述文件的输出。 +上述文件传输的输出。 + ![][13] 如果你想传输不止一个文件,使用下面的格式。 + ![][14] -上述文件的输出。 +上述文件传输的输出。 + ![][15] 递归复制文件夹。 + ![][16] 上述文件夹传输的输出。 + ![][17] 这种方式下你只能够下载一次文件或者文件夹,不可以多次下载。这也就意味着一旦你下载了这些文件或者文件夹,这个链接就会立即失效。 + ![][18] 也可以在手册页查看更多的相关选项。 @@ -149,8 +153,8 @@ via: https://www.2daygeek.com/dcp-dat-copy-secure-way-to-transfer-files-between- 作者:[Vinoth Kumar][a] 选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) +译者:[dianbanjiu](https://github.com/dianbanjiu) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/201902/20190122 Get started with Go For It, a flexible to-do list application.md b/published/201902/20190122 Get started with Go For It, a flexible to-do list application.md new file mode 100644 index 0000000000..e2602b216c --- /dev/null +++ b/published/201902/20190122 Get started with Go For It, a flexible to-do list application.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10557-1.html) +[#]: subject: (Get started with Go For It, a flexible to-do list application) +[#]: via: (https://opensource.com/article/19/1/productivity-tool-go-for-it) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) + +开始使用 Go For It 吧,一个灵活的待办事项列表程序 +====== + +> Go For It,是我们开源工具系列中的第十个工具,它将使你在 2019 年更高效,它在 Todo.txt 系统的基础上构建,以帮助你完成更多工作。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o) + +每年年初似乎都有疯狂的冲动想提高工作效率。新年的决心,渴望开启新的一年,当然,“抛弃旧的,拥抱新的”的态度促成了这一切。通常这时的建议严重偏向闭源和专有软件,但事实上并不用这样。 + +这是我挑选出的 19 个新的(或者对你而言新的)开源工具中的第 10 个工具来帮助你在 2019 年更有效率。 + +### Go For It + +有时,人们要高效率需要的不是一个花哨的看板或一组笔记,而是一个简单、直接的待办事项清单。像“将项目添加到列表中,在完成后检查”一样基本的东西。为此,[纯文本 Todo.txt 系统][1]可能是最容易使用的系统之一,几乎所有系统都支持它。 + +![](https://opensource.com/sites/default/files/uploads/go-for-it_1_1.png) + +[Go For It][2] 是一个简单易用的 Todo.txt 图形界面。如果你已经在使用 Todo.txt,它可以与现有文件一起使用,如果还没有,那么可以同时创建待办事项和完成事项。它允许拖放任务排序,允许用户按照他们想要执行的顺序组织待办事项。它还支持 [Todo.txt 格式指南][3]中所述的优先级、项目和上下文。而且,只需单击任务列表中的项目或者上下文就可通过它们过滤任务。 + +![](https://opensource.com/sites/default/files/uploads/go-for-it_2.png) + +一开始,Go For It 可能看起来与任何其他 Todo.txt 程序相同,但外观可能是骗人的。将 Go For It 与其他程序真正区分开的功能是它包含一个内置的[番茄工作法][4]计时器。选择要完成的任务,切换到“计时器”选项卡,然后单击“启动”。任务完成后,只需单击“完成”,它将自动重置计时器并选择列表中的下一个任务。你可以暂停并重新启动计时器,也可以单击“跳过”跳转到下一个任务(或中断)。在当前任务剩余 60 秒时,它会发出警告。任务的默认时间设置为 25 分钟,中断的默认时间设置为 5 分钟。你可以在“设置”页面中调整,同时还能调整 Todo.txt 和 done.txt 文件的目录的位置。 + +![](https://opensource.com/sites/default/files/uploads/go-for-it_3.png) + +Go For It 的第三个选项卡是“已完成”,允许你查看已完成的任务并在需要时将其清除。能够看到你已经完成的可能是非常激励的,也是一种了解你在更长的过程中进度的好方法。 + +![](https://opensource.com/sites/default/files/uploads/go-for-it_4.png) + +它还有 Todo.txt 的所有其他优点。Go For It 的列表可以被其他使用相同格式的程序访问,包括 [Todo.txt 的原始命令行工具][5]和任何已安装的[附加组件][6]。 + +Go For It 旨在成为一个简单的工具来帮助管理你的待办事项列表并完成这些项目。如果你已经使用过 Todo.txt,那么 Go For It 是你的工具箱的绝佳补充,如果你还没有,这是一个尝试最简单、最灵活系统之一的好机会。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/productivity-tool-go-for-it + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ksonney (Kevin Sonney) +[b]: https://github.com/lujun9972 +[1]: http://todotxt.org/ +[2]: http://manuel-kehl.de/projects/go-for-it/ +[3]: https://github.com/todotxt/todo.txt +[4]: https://en.wikipedia.org/wiki/Pomodoro_Technique +[5]: https://github.com/todotxt/todo.txt-cli +[6]: https://github.com/todotxt/todo.txt-cli/wiki/Todo.sh-Add-on-Directory diff --git a/published/201902/20190122 How To Copy A File-Folder From A Local System To Remote System In Linux.md b/published/201902/20190122 How To Copy A File-Folder From A Local System To Remote System In Linux.md new file mode 100644 index 0000000000..66407b0156 --- /dev/null +++ b/published/201902/20190122 How To Copy A File-Folder From A Local System To Remote System In Linux.md @@ -0,0 +1,393 @@ +[#]: collector: (lujun9972) +[#]: translator: (luming) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10569-1.html) +[#]: subject: (How To Copy A File/Folder From A Local System To Remote System In Linux?) +[#]: via: (https://www.2daygeek.com/linux-scp-rsync-pscp-command-copy-files-folders-in-multiple-servers-using-shell-script/) +[#]: author: (Prakash Subramanian https://www.2daygeek.com/author/prakash/) + +如何在 Linux 上复制文件/文件夹到远程系统? +====== + +从一个服务器复制文件到另一个服务器,或者从本地到远程复制是 Linux 管理员的日常任务之一。 + +我觉得不会有人不同意,因为无论在哪里这都是你的日常操作之一。有很多办法都能处理这个任务,我们试着加以概括。你可以挑一个喜欢的方法。当然,看看其他命令也能在别的地方帮到你。 + +我已经在自己的环境下测试过所有的命令和脚本了,因此你可以直接用到日常工作当中。 + +通常大家都倾向 `scp`,因为它是文件复制的原生命令native command之一。但本文所列出的其它命令也很好用,建议你尝试一下。 + +文件复制可以轻易地用以下四种方法。 + +- `scp`:在网络上的两个主机之间复制文件,它使用 `ssh` 做文件传输,并使用相同的认证方式,具有相同的安全性。 +- `rsync`:是一个既快速又出众的多功能文件复制工具。它能本地复制、通过远程 shell 在其它主机之间复制,或者与远程的 `rsync` 守护进程daemon 之间复制。 +- `pscp`:是一个并行复制文件到多个主机上的程序。它提供了诸多特性,例如为 `scp` 配置免密传输,保存输出到文件,以及超时控制。 +- `prsync`:也是一个并行复制文件到多个主机上的程序。它也提供了诸多特性,例如为 `ssh` 配置免密传输,保存输出到 文件,以及超时控制。 + +### 方式 1:如何在 Linux 上使用 scp 命令从本地系统向远程系统复制文件/文件夹? + +`scp` 命令可以让我们从本地系统复制文件/文件夹到远程系统上。 + +我会把 `output.txt` 文件从本地系统复制到 `2g.CentOS.com` 远程系统的 `/opt/backup` 文件夹下。 + +``` +# scp output.txt root@2g.CentOS.com:/opt/backup + +output.txt 100% 2468 2.4KB/s 00:00 +``` + +从本地系统复制两个文件 `output.txt` 和 `passwd-up.sh` 到远程系统 `2g.CentOs.com` 的 `/opt/backup` 文件夹下。 + +``` +# scp output.txt passwd-up.sh root@2g.CentOS.com:/opt/backup + +output.txt 100% 2468 2.4KB/s 00:00 +passwd-up.sh 100% 877 0.9KB/s 00:00 +``` + +从本地系统复制 `shell-script` 文件夹到远程系统 `2g.CentOs.com` 的 `/opt/back` 文件夹下。 + +这会连同`shell-script` 文件夹下所有的文件一同复制到`/opt/back` 下。 + +``` +# scp -r /home/daygeek/2g/shell-script/ root@:/opt/backup/ + +output.txt 100% 2468 2.4KB/s 00:00 +ovh.sh 100% 76 0.1KB/s 00:00 +passwd-up.sh 100% 877 0.9KB/s 00:00 +passwd-up1.sh 100% 7 0.0KB/s 00:00 +server-list.txt 100% 23 0.0KB/s 00:00 +``` + +### 方式 2:如何在 Linux 上使用 scp 命令和 Shell 脚本复制文件/文件夹到多个远程系统上? + +如果你想复制同一个文件到多个远程服务器上,那就需要创建一个如下面那样的小 shell 脚本。 + +并且,需要将服务器添加进 `server-list.txt` 文件。确保添加成功后,每个服务器应当单独一行。 + +最终,你想要的脚本就像下面这样: + +``` +# file-copy.sh + +#!/bin/sh +for server in `more server-list.txt` +do + scp /home/daygeek/2g/shell-script/output.txt root@$server:/opt/backup +done +``` + +完成之后,给 `file-copy.sh` 文件设置可执行权限。 + +``` +# chmod +x file-copy.sh +``` + +最后运行脚本完成复制。 + +``` +# ./file-copy.sh + +output.txt 100% 2468 2.4KB/s 00:00 +output.txt 100% 2468 2.4KB/s 00:00 +``` + +使用下面的脚本可以复制多个文件到多个远程服务器上。 + +``` +# file-copy.sh + +#!/bin/sh +for server in `more server-list.txt` +do + scp /home/daygeek/2g/shell-script/output.txt passwd-up.sh root@$server:/opt/backup +done +``` + +下面结果显示所有的两个文件都复制到两个服务器上。 + +``` +# ./file-cp.sh + +output.txt 100% 2468 2.4KB/s 00:00 +passwd-up.sh 100% 877 0.9KB/s 00:00 +output.txt 100% 2468 2.4KB/s 00:00 +passwd-up.sh 100% 877 0.9KB/s 00:00 +``` + +使用下面的脚本递归地复制文件夹到多个远程服务器上。 + +``` +# file-copy.sh + +#!/bin/sh +for server in `more server-list.txt` +do + scp -r /home/daygeek/2g/shell-script/ root@$server:/opt/backup +done +``` + +上述脚本的输出。 + +``` +# ./file-cp.sh + +output.txt 100% 2468 2.4KB/s 00:00 +ovh.sh 100% 76 0.1KB/s 00:00 +passwd-up.sh 100% 877 0.9KB/s 00:00 +passwd-up1.sh 100% 7 0.0KB/s 00:00 +server-list.txt 100% 23 0.0KB/s 00:00 + +output.txt 100% 2468 2.4KB/s 00:00 +ovh.sh 100% 76 0.1KB/s 00:00 +passwd-up.sh 100% 877 0.9KB/s 00:00 +passwd-up1.sh 100% 7 0.0KB/s 00:00 +server-list.txt 100% 23 0.0KB/s 00:00 +``` + +### 方式 3:如何在 Linux 上使用 pscp 命令复制文件/文件夹到多个远程系统上? + +`pscp` 命令可以直接让我们复制文件到多个远程服务器上。 + +使用下面的 `pscp` 命令复制单个文件到远程服务器。 + +``` +# pscp.pssh -H 2g.CentOS.com /home/daygeek/2g/shell-script/output.txt /opt/backup + +[1] 18:46:11 [SUCCESS] 2g.CentOS.com +``` + +使用下面的 `pscp` 命令复制多个文件到远程服务器。 + +``` +# pscp.pssh -H 2g.CentOS.com /home/daygeek/2g/shell-script/output.txt ovh.sh /opt/backup + +[1] 18:47:48 [SUCCESS] 2g.CentOS.com +``` + +使用下面的 `pscp` 命令递归地复制整个文件夹到远程服务器。 + +``` +# pscp.pssh -H 2g.CentOS.com -r /home/daygeek/2g/shell-script/ /opt/backup + +[1] 18:48:46 [SUCCESS] 2g.CentOS.com +``` + +使用下面的 `pscp` 命令使用下面的命令复制单个文件到多个远程服务器。 + +``` +# pscp.pssh -h server-list.txt /home/daygeek/2g/shell-script/output.txt /opt/backup + +[1] 18:49:48 [SUCCESS] 2g.CentOS.com +[2] 18:49:48 [SUCCESS] 2g.Debian.com +``` + +使用下面的 `pscp` 命令复制多个文件到多个远程服务器。 + +``` +# pscp.pssh -h server-list.txt /home/daygeek/2g/shell-script/output.txt passwd-up.sh /opt/backup + +[1] 18:50:30 [SUCCESS] 2g.Debian.com +[2] 18:50:30 [SUCCESS] 2g.CentOS.com +``` + +使用下面的命令递归地复制文件夹到多个远程服务器。 + +``` +# pscp.pssh -h server-list.txt -r /home/daygeek/2g/shell-script/ /opt/backup + +[1] 18:51:31 [SUCCESS] 2g.Debian.com +[2] 18:51:31 [SUCCESS] 2g.CentOS.com +``` + +### 方式 4:如何在 Linux 上使用 rsync 命令复制文件/文件夹到多个远程系统上? + +`rsync` 是一个即快速又出众的多功能文件复制工具。它能本地复制、通过远程 shell 在其它主机之间复制,或者在远程 `rsync` 守护进程daemon 之间复制。 + +使用下面的 `rsync` 命令复制单个文件到远程服务器。 + +``` +# rsync -avz /home/daygeek/2g/shell-script/output.txt root@2g.CentOS.com:/opt/backup + +sending incremental file list +output.txt + +sent 598 bytes received 31 bytes 1258.00 bytes/sec +total size is 2468 speedup is 3.92 +``` + +使用下面的 `rsync` 命令复制多个文件到远程服务器。 + +``` +# rsync -avz /home/daygeek/2g/shell-script/output.txt passwd-up.sh root@2g.CentOS.com:/opt/backup + +sending incremental file list +output.txt +passwd-up.sh + +sent 737 bytes received 50 bytes 1574.00 bytes/sec +total size is 2537 speedup is 3.22 +``` + +使用下面的 `rsync` 命令通过 `ssh` 复制单个文件到远程服务器。 + +``` +# rsync -avzhe ssh /home/daygeek/2g/shell-script/output.txt root@2g.CentOS.com:/opt/backup + +sending incremental file list +output.txt + +sent 598 bytes received 31 bytes 419.33 bytes/sec +total size is 2.47K speedup is 3.92 +``` + +使用下面的 `rsync` 命令通过 `ssh` 递归地复制文件夹到远程服务器。这种方式只复制文件不包括文件夹。 + +``` +# rsync -avzhe ssh /home/daygeek/2g/shell-script/ root@2g.CentOS.com:/opt/backup + +sending incremental file list +./ +output.txt +ovh.sh +passwd-up.sh +passwd-up1.sh +server-list.txt + +sent 3.85K bytes received 281 bytes 8.26K bytes/sec +total size is 9.12K speedup is 2.21 +``` + +### 方式 5:如何在 Linux 上使用 rsync 命令和 Shell 脚本复制文件/文件夹到多个远程系统上? + +如果你想复制同一个文件到多个远程服务器上,那也需要创建一个如下面那样的小 shell 脚本。 + +``` +# file-copy.sh + +#!/bin/sh +for server in `more server-list.txt` +do + rsync -avzhe ssh /home/daygeek/2g/shell-script/ root@2g.CentOS.com$server:/opt/backup +done +``` + +上面脚本的输出。 + +``` +# ./file-copy.sh + +sending incremental file list +./ +output.txt +ovh.sh +passwd-up.sh +passwd-up1.sh +server-list.txt + +sent 3.86K bytes received 281 bytes 8.28K bytes/sec +total size is 9.13K speedup is 2.21 + +sending incremental file list +./ +output.txt +ovh.sh +passwd-up.sh +passwd-up1.sh +server-list.txt + +sent 3.86K bytes received 281 bytes 2.76K bytes/sec +total size is 9.13K speedup is 2.21 +``` + +### 方式 6:如何在 Linux 上使用 scp 命令和 Shell 脚本从本地系统向多个远程系统复制文件/文件夹? + +在上面两个 shell 脚本中,我们需要事先指定好文件和文件夹的路径,这儿我做了些小修改,让脚本可以接收文件或文件夹作为输入参数。当你每天需要多次执行复制时,这将会非常有用。 + +``` +# file-copy.sh + +#!/bin/sh +for server in `more server-list.txt` +do +scp -r $1 root@2g.CentOS.com$server:/opt/backup +done +``` + +输入文件名并运行脚本。 + +``` +# ./file-copy.sh output1.txt + +output1.txt 100% 3558 3.5KB/s 00:00 +output1.txt 100% 3558 3.5KB/s 00:00 +``` + +### 方式 7:如何在 Linux 系统上用非标准端口复制文件/文件夹到远程系统? + +如果你想使用非标准端口,使用下面的 shell 脚本复制文件或文件夹。 + +如果你使用了非标准Non-Standard端口,确保像下面 `scp` 命令那样指定好了端口号。 + +``` +# file-copy-scp.sh + +#!/bin/sh +for server in `more server-list.txt` +do +scp -P 2222 -r $1 root@2g.CentOS.com$server:/opt/backup +done +``` + +运行脚本,输入文件名。 + +``` +# ./file-copy.sh ovh.sh + +ovh.sh 100% 3558 3.5KB/s 00:00 +ovh.sh 100% 3558 3.5KB/s 00:00 +``` + +如果你使用了非标准Non-Standard端口,确保像下面 `rsync` 命令那样指定好了端口号。 + +``` +# file-copy-rsync.sh + +#!/bin/sh +for server in `more server-list.txt` +do +rsync -avzhe 'ssh -p 2222' $1 root@2g.CentOS.com$server:/opt/backup +done +``` + +运行脚本,输入文件名。 + +``` +# ./file-copy-rsync.sh passwd-up.sh +sending incremental file list +passwd-up.sh + +sent 238 bytes received 35 bytes 26.00 bytes/sec +total size is 159 speedup is 0.58 + +sending incremental file list +passwd-up.sh + +sent 238 bytes received 35 bytes 26.00 bytes/sec +total size is 159 speedup is 0.58 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-scp-rsync-pscp-command-copy-files-folders-in-multiple-servers-using-shell-script/ + +作者:[Prakash Subramanian][a] +选题:[lujun9972][b] +译者:[LuuMing](https://github.com/LuuMing) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/prakash/ +[b]: https://github.com/lujun9972 diff --git a/published/201902/20190123 Book Review- Fundamentals of Linux.md b/published/201902/20190123 Book Review- Fundamentals of Linux.md new file mode 100644 index 0000000000..bdde86d16e --- /dev/null +++ b/published/201902/20190123 Book Review- Fundamentals of Linux.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: (mySoul8012) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10565-1.html) +[#]: subject: (Book Review: Fundamentals of Linux) +[#]: via: (https://itsfoss.com/fundamentals-of-linux-book-review) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +书评:《Linux 基础》 +====== + +介绍 Linux 的基础知识以及它的工作原理的书很多,今天,我们将会点评这样一本书。这次讨论的主题为 Oliver Pelz 所写的 《[Linux 基础][1]Fundamentals of Linux》,由 [PacktPub][2] 出版。 + +[Oliver Pelz][3] 是一位拥有超过十年软件开发经验的开发者和系统管理员,拥有生物信息学学位证书。 + +### 《Linux 基础》 + +![Fundamental of Linux books][4] + +正如可以从书名中猜到那样,《Linux 基础》的目标是为读者打下一个从了解 Linux 到学习 Linux 命令行的坚实基础。这本书一共有两百多页,因此它专注于教给用户日常任务和解决经常遇到的问题。本书是为想要成为 Linux 管理员的读者而写的。 + +第一章首先概述了虚拟化。本书作者指导了读者如何在 [VirtualBox][6] 中创建 [CentOS][5] 实例。如何克隆实例,如何使用快照。并且同时你也会学习到如何通过 SSH 命令连接到虚拟机。 + +第二章介绍了 Linux 命令行的基础知识,包括 shell 通配符,shell 展开,如何使用包含空格和特殊字符的文件名称。如何来获取命令手册的帮助页面。如何使用 `sed`、`awk` 这两个命令。如何浏览 Linux 的文件系统。 + +第三章更深入的介绍了 Linux 文件系统。你将了解如何在 Linux 中文件是如何链接的,以及如何搜索它们。你还将获得用户、组,以及文件权限的大概了解。由于本章的重点介绍了如何与文件进行交互。因此还将会介绍如何从命令行中读取文本文件,以及初步了解如何使用 vim 编辑器。 + +第四章重点介绍了如何使用命令行。以及涵盖的重要命令。如 `cat`、`sort`、`awk`、`tee`、`tar`、`rsync`、`nmap`、`htop` 等。你还将会了解到进程,以及它们如何彼此通讯。这一章还介绍了 Bash shell 脚本编程。 + +第五章同时也是本书的最后一章,将会介绍 Linux 和其他高级命令,以及网络的概念。本书的作者讨论了 Linux 是如何处理网络,并提供使用多个虚拟机的示例。同时还将会介绍如何安装新的程序,如何设置防火墙。 + +### 关于这本书的思考 + +Linux 的基础知识只有五章和少少的 200 来页可能看起来有些短,但是也涵盖了相当多的信息。同时也将会获得如何使用命令行所需要的知识的一切。 + +使用本书的时候,需要注意一件事情,即,本书专注于对命令行的关注,没有任何关于如何使用图形化的用户界面的任何教程。这是因为在 Linux 中有太多不同的桌面环境,以及很多的类似的系统应用,因此很难编写一本可以涵盖所有变种的书。此外,还有部分原因还因为本书的面向的用户群体为潜在的 Linux 管理员。 + +当我看到作者使用 Centos 教授 Linux 的时候有点惊讶。我原本以为他会使用更为常见的 Linux 的发行版本,例如 Ubuntu、Debian 或者 Fedora。原因在于 Centos 是为服务器设计的发行版本。随着时间的推移变化很小,能够为 Linux 的基础知识打下一个非常坚实的基础。 + +我自己使用 Linux 已经操作五年了。我大部分时间都在使用桌面版本的 Linux。我有些时候会使用命令行操作。但我并没有花太多的时间在那里。我使用鼠标完成了本书中涉及到的很多操作。现在呢。我同时也知道了如何通过终端做到同样的事情。这种方式不会改变我完成任务的方式,但是会有助于自己理解幕后发生的事情。 + +如果你刚刚使用 Linux,或者计划使用。我不会推荐你阅读这本书。这可能有点绝对化。但是如何你已经花了一些时间在 Linux 上。或者可以快速掌握某种技术语言。那么这本书很适合你。 + +如果你认为本书适合你的学习需求。你可以从以下链接获取到该书: + +- [下载《Linux 基础》](https://www.packtpub.com/networking-and-servers/fundamentals-linux) + +我们将在未来几个月内尝试点评更多 Linux 书籍,敬请关注我们。 + +你最喜欢的关于 Linux 的入门书籍是什么?请在下面的评论中告诉我们。 + +如果你发现这篇文章很有趣,请花一点时间在社交媒体、Hacker News或 [Reddit][8] 上分享。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/fundamentals-of-linux-book-review + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[mySoul8012](https://github.com/mySoul8012) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://www.packtpub.com/networking-and-servers/fundamentals-linux +[2]: https://www.packtpub.com/ +[3]: http://www.oliverpelz.de/index.html +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/fundamentals-of-linux-book-review.jpeg?resize=800%2C450&ssl=1 +[5]: https://centos.org/ +[6]: https://www.virtualbox.org/ +[7]: https://www.centos.org/ +[8]: http://reddit.com/r/linuxusersgroup diff --git a/published/20190123 Commands to help you monitor activity on your Linux server.md b/published/201902/20190123 Commands to help you monitor activity on your Linux server.md similarity index 100% rename from published/20190123 Commands to help you monitor activity on your Linux server.md rename to published/201902/20190123 Commands to help you monitor activity on your Linux server.md diff --git a/published/201902/20190124 Get started with LogicalDOC, an open source document management system.md b/published/201902/20190124 Get started with LogicalDOC, an open source document management system.md new file mode 100644 index 0000000000..35e90d4839 --- /dev/null +++ b/published/201902/20190124 Get started with LogicalDOC, an open source document management system.md @@ -0,0 +1,63 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10561-1.html) +[#]: subject: (Get started with LogicalDOC, an open source document management system) +[#]: via: (https://opensource.com/article/19/1/productivity-tool-logicaldoc) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) + +开始使用 LogicalDOC 吧,一个开源文档管理系统 +====== + +> 使用 LogicalDOC 更好地跟踪文档版本,这是我们开源工具系列中的第 12 个工具,它将使你在 2019 年更高效。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/document_free_access_cut_security.png?itok=ocvCv8G2) + +每年年初似乎都有疯狂的冲动想提高工作效率。新年的决心,渴望开启新的一年,当然,“抛弃旧的,拥抱新的”的态度促成了这一切。通常这时的建议严重偏向闭源和专有软件,但事实上并不用这样。 + +这是我挑选出的 19 个新的(或者对你而言新的)开源工具中的第 12 个工具来帮助你在 2019 年更有效率。 + +### LogicalDOC + +高效部分表现在能够在你需要时找到你所需的东西。我们都看到过塞满名称类似的文件的目录,这是每次更改文档时为了跟踪所有版本而重命名这些文件而导致的。例如,我的妻子是一名作家,她在将文档发送给审稿人之前,她经常使用新名称保存文档修订版。 + +![](https://opensource.com/sites/default/files/uploads/logicaldoc-1.png) + +程序员对此一个自然的解决方案是 Git 或者其他版本控制器,但这个不适用于文档作者,因为用于代码的系统通常不能很好地兼容商业文本编辑器使用的格式。之前有人说,“改变格式就行”,[这不是适合每个人的选择][1]。同样,许多版本控制工具对于非技术人员来说并不是非常友好。在大型组织中,有一些工具可以解决此问题,但它们还需要大型组织的资源来运行、管理和支持它们。 + +![](https://opensource.com/sites/default/files/uploads/logicaldoc-2.png) + +[LogicalDOC CE][2] 是为解决此问题而编写的开源文档管理系统。它允许用户签入、签出、查看版本、搜索和锁定文档,并保留版本历史记录,类似于程序员使用的版本控制工具。 + +LogicalDOC 可在 Linux、MacOS 和 Windows 上[安装][3],使用基于 Java 的安装程序。在安装时,系统将提示你提供数据库存储位置,并提供只在本地文件存储的选项。你将获得访问服务器的 URL 和默认用户名和密码,以及保存用于自动安装脚本选项。 + +登录后,LogicalDOC 的默认页面会列出你已标记、签出的文档以及有关它们的最新说明。切换到“文档”选项卡将显示你有权访问的文件。你可以在界面中选择文件或使用拖放来上传文档。如果你上传 ZIP 文件,LogicalDOC 会解压它,并将其中的文件添加到仓库中。 + +![](https://opensource.com/sites/default/files/uploads/logicaldoc-3.png) + +右键单击文件将显示一个菜单选项,包括检出文件、锁定文件以防止更改,以及执行大量其他操作。签出文件会将其下载到本地计算机以便编辑。在重新签入之前,其他任何人都无法修改签出的文件。当重新签入文件时(使用相同的菜单),用户可以向版本添加标签,并且需要备注对其执行的操作。 + +![](https://opensource.com/sites/default/files/uploads/logicaldoc-4.png) + +查看早期版本只需在“版本”页面下载就行。对于某些第三方服务,它还有导入和导出选项,内置 [Dropbox][4] 支持。 + +文档管理不仅仅是能够负担得起昂贵解决方案的大公司才能有的。LogicalDOC 可帮助你追踪文档的版本历史,并为难以管理的文档提供了安全的仓库。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/productivity-tool-logicaldoc + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ksonney (Kevin Sonney) +[b]: https://github.com/lujun9972 +[1]: http://www.antipope.org/charlie/blog-static/2013/10/why-microsoft-word-must-die.html +[2]: https://www.logicaldoc.com/download-logicaldoc-community +[3]: https://docs.logicaldoc.com/en/installation +[4]: https://dropbox.com diff --git a/published/20190124 Understanding Angle Brackets in Bash.md b/published/201902/20190124 Understanding Angle Brackets in Bash.md similarity index 100% rename from published/20190124 Understanding Angle Brackets in Bash.md rename to published/201902/20190124 Understanding Angle Brackets in Bash.md diff --git a/published/201902/20190125 PyGame Zero- Games without boilerplate.md b/published/201902/20190125 PyGame Zero- Games without boilerplate.md new file mode 100644 index 0000000000..523c7e4561 --- /dev/null +++ b/published/201902/20190125 PyGame Zero- Games without boilerplate.md @@ -0,0 +1,101 @@ +[#]: collector: (lujun9972) +[#]: translator: (bestony) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10532-1.html) +[#]: subject: (PyGame Zero: Games without boilerplate) +[#]: via: (https://opensource.com/article/19/1/pygame-zero) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +PyGame Zero: 无需模板的游戏开发 +====== + +> 在你的游戏开发过程中有了 PyGame Zero,和枯燥的模板说再见吧。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python3-game.png?itok=jG9UdwC3) + +Python 是一个很好的入门级编程语言。并且,游戏是一个很好的入门项目:它们是可视化的,自驱动的,并且可以很愉快的与朋友和家人分享。虽然,绝大多数的 Python 写就的库,比如 [PyGame][1] ,会让初学者因为忘记微小的细节很容易导致什么都没渲染而感到困扰。 + +在理解所有部分的作用之前,他们会将其中的许多部分都视为“无意识的模板文件”——需要复制和粘贴到程序中才能使其工作的神奇段落。 + +[PyGame Zero][2] 试图通过在 PyGame 上放置一个抽象层来弥合这一差距,因此它字面上并不需要模板。 + +我们在说的“字面”,就是在指字面。 + +这是一个合格的 PyGame Zero 文件: + +``` +# This comment is here for clarity reasons +``` + +我们可以将它放在一个 `game.py` 文件里,并运行: + +``` +$ pgzrun game.py +``` + +这将会展示一个窗口,并运行一个可以通过关闭窗口或按下 `CTRL-C` 中断的游戏循环。 + +遗憾的是,这将是一场无聊的游戏。什么都没发生。 + +为了让它更有趣一点,我们可以画一个不同的背景: + +``` +def draw(): +    screen.fill((255, 0, 0)) +``` + +这将会把背景色从黑色换为红色。但是这仍是一个很无聊的游戏,什么都没发生。我们可以让它变的更有意思一点: + +``` +colors = [0, 0, 0] + +def draw(): +    screen.fill(tuple(colors)) + +def update(): +    colors[0] = (colors[0] + 1) % 256 +``` + +这将会让窗口从黑色开始,逐渐变亮,直到变为亮红色,再返回黑色,一遍一遍循环。 + +`update` 函数更新了参数的值,而 `draw` 基于这些参数渲染这个游戏。 + +即使是这样,这里也没有任何方式给玩家与这个游戏的交互的方式。让我们试试其他一些事情: + +``` +colors = [0, 0, 0] + +def draw(): +    screen.fill(tuple(colors)) + +def update(): +    colors[0] = (colors[0] + 1) % 256 + +def on_key_down(key, mod, unicode): +    colors[1] = (colors[1] + 1) % 256 +``` + +现在,按下按键来提升亮度。 + +这些包括游戏循环的三个重要部分:响应用户输入,更新参数和重新渲染屏幕。 + +PyGame Zero 提供了更多功能,包括绘制精灵图和播放声音片段的功能。 + +试一试,看看你能想出什么类型的游戏! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/pygame-zero + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[bestony](https://github.com/bestony) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://www.pygame.org/news +[2]: https://pygame-zero.readthedocs.io/en/stable/ diff --git a/published/201902/20190125 Top 5 Linux Distributions for Development in 2019.md b/published/201902/20190125 Top 5 Linux Distributions for Development in 2019.md new file mode 100644 index 0000000000..ae358bfbe0 --- /dev/null +++ b/published/201902/20190125 Top 5 Linux Distributions for Development in 2019.md @@ -0,0 +1,138 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10534-1.html) +[#]: subject: (Top 5 Linux Distributions for Development in 2019) +[#]: via: (https://www.linux.com/blog/2019/1/top-5-linux-distributions-development-2019) +[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen) + +5 个用于开发工作的 Linux 发行版 +====== + +> 这五个发行版用于开发工作将不会让你失望。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev-main.jpg?itok=DEe9pYtb) + +Linux 上最受欢迎的任务之一肯定是开发。理由很充分:业务依赖于 Linux。没有 Linux,技术根本无法满足当今不断发展的世界的需求。因此,开发人员不断努力改善他们的工作环境。而进行此类改善的一种方法就是拥有合适的平台。值得庆幸的是,这就是 Linux,所以你总是有很多选择。 + +但有时候,太多的选择本身就是一个问题。哪种发行版适合你的开发需求?当然,这取决于你正在开发的工作,但某些发行版更适合作为你的工作任务的基础。我将重点介绍我认为 2019 年最适合开发人员的五个发行版。 + +### Ubuntu + +无需赘言。虽然 Linux Mint 的忠实用户无疑是一个非常忠诚的群体(这是有充分的理由的,他们选择的发行版很棒),但 Ubuntu Linux 在这里更被认可。为什么?因为有像 [AWS][1] 这样的云服务商存在,Ubuntu 成了部署最多的服务器操作系统之一。这意味着在 Ubuntu 桌面发行版上进行开发可以更轻松地转换为 Ubuntu Server。而且因为 Ubuntu 使得开发、使用和部署容器非常容易,所以你想要使用这个平台是完全合理的。而 Ubuntu 与其包含的 Snap 软件包相结合,使得这个 Canonical(Ubuntu 发行版背后的公司)的操作系统如虎添翼。 + +但这不仅是你可以用 Ubuntu 做什么,而是你可以轻松做到。几乎对于所有的任务,Ubuntu 都是一个非常易用的发行版。而且因为 Ubuntu 如此受欢迎,所以你可以从 Ubuntu “软件” 应用的图形界面里轻松安装你想要使用的每个工具和 IDE(图 1)。 + +![Ubuntu][3] + +*图 1:可以在 Ubuntu “软件”工具里面找到开发者工具。* + +如果你正在寻求易用、易于迁移,以及大量的工具,那么将 Ubuntu 作为开发平台就不会有错。 + +### openSUSE + +我将 openSUSE 添加到此列表中有一个非常具体的原因。它不仅是一个出色的桌面发行版,它还是市场上最好的滚动发行版之一。因此,如果你希望用最新的软件开发、发布最新的软件,[openSUSE Tumbleweed][5] 应该是你的首选之一。如果你想使用最喜欢的 IDE 的最新版本,如果你总是希望确保使用最新的库和工具包进行开发,那么 Tumbleweed 就是你的平台。 + +但 openSUSE 不仅提供滚动发布版本。如果你更愿意使用标准发行版,那么 [openSUSE Leap][6] 就是你想要的。 + +当然,它不仅有标准版或滚动版,openSUSE 平台还有一个名为 [Kubic][7] 的 Kubernetes 特定版本,该版本基于 openSUSE MicroOS 上的 Kubernetes。但即使你没有为 Kubernetes 进行开发,你也会发现许多软件和工具可供使用。 + +openSUSE 还提供了选择桌面环境的能力,或者你也可以选择通用桌面或服务器(图 2)。 + +![openSUSE][9] + +*图 2: 正在安装 openSUSE Tumbleweed。* + +### Fedora + +使用 Fedora 作为开发平台才有意义。为什么?这个发行版本身似乎是面向开发人员的。通过定期的六个月发布周期,开发人员可以确保他们不会一直使用过时的软件。当你需要最新的工具和库时,这很重要。如果你正在开发企业级业务,Fedora 是一个理想的平台,因为它是红帽企业 Linux(RHEL)的上游。这意味着向 RHEL 的过渡应该是无痛的。这一点很重要,特别是如果你希望将你的项目带到一个更大的市场(一个比以桌面为中心的目标更深的领域)。 + +Fedora 还提供了你将体验到的最佳 GNOME 体验之一(图 3)。换言之,这是非常稳定和快速的桌面。 + +![GNOME][11] + +*图 3:Fedora 上的 GNOME 桌面。* + +但是如果 GNOME 不是你的菜,你还可以选择安装一个 [Fedora 花样版][12](包括 KDE、XFCE、LXQT、Mate-Compiz、Cinnamon、LXDE 和 SOAS 等桌面环境)。 + +### Pop!_OS + +如果这个列表中我没有包括 [System76][13] 平台专门为他们的硬件定制的操作系统(虽然它也在其他硬件上运行良好),那我算是失职了。为什么我要包含这样的发行版,尤其是它还并未远离其所基于的 Ubuntu 平台?主要是因为如果你计划从 System76 购买台式机或笔记本电脑,那它就是你想要的发行版。但是你为什么要这样做呢(特别是考虑到 Linux 几乎适用于所有现成的硬件)?因为 System76 销售的出色硬件。随着他们的 Thelio 桌面的发布,这是你可以使用的市场上最强大的台式计算机之一。如果你正在努力开发大型应用程序(特别是那些非常依赖于非常大的数据库或需要大量处理能力进行编译的应用程序),为什么不用最好的计算机呢?而且由于 Pop!_OS 完全适用于 System76 硬件,因此这是一个明智的选择。 + +由于 Pop!_OS 基于 Ubuntu,因此你可以轻松获得其所基于的 Ubuntu 可用的所有工具(图 4)。 + +![Pop!_OS][15] + +*图 4:运行在 Pop!_OS 上的 Anjunta IDE* + +Pop!_OS 也会默认加密驱动器,因此你可以放心你的工作可以避免窥探(如果你的硬件落入坏人之手)。 + +### Manjaro + +对于那些喜欢在 Arch Linux 上开发,但不想经历安装和使用 Arch Linux 的所有环节的人来说,那选择就是 Manjaro。Manjaro 可以轻松地启动和运行一个基于 Arch Linux 的发行版(就像安装和使用 Ubuntu 一样简单)。 + +但是 Manjaro 对开发人员友好的原因(除了享受 Arch 式好处)是你可以下载好多种不同口味的桌面。从[Manjaro 下载页面][16] 中,你可以获得以下口味: + + * GNOME + * XFCE + * KDE + * OpenBox + * Cinnamon + * I3 + * Awesome + * Budgie + * Mate + * Xfce 开发者预览版 + * KDE 开发者预览版 + * GNOME 开发者预览版 + * Architect + * Deepin + +值得注意的是它的开发者版本(面向测试人员和开发人员),Architect 版本(适用于想要从头开始构建 Manjaro 的用户)和 Awesome 版本(图 5,适用于开发人员处理日常工作的版本)。使用 Manjaro 的一个警告是,与任何滚动版本一样,你今天开发的代码可能明天无法运行。因此,你需要具备一定程度的敏捷性。当然,如果你没有为 Manjaro(或 Arch)做开发,并且你正在进行工作更多是通用的(或 Web)开发,那么只有当你使用的工具被更新了且不再适合你时,才会影响你。然而,这种情况发生的可能性很小。和大多数 Linux 发行版一样,你会发现 Manjaro 有大量的开发工具。 + +![Manjaro][18] + +*图 5:Manjaro Awesome 版对于开发者来说很棒。* + +Manjaro 还支持 AUR(Arch User Repository —— Arch 用户的社区驱动软件库),其中包括最先进的软件和库,以及 [Unity Editor][19] 或 yEd 等专有应用程序。但是,有个关于 AUR 的警告:AUR 包含的软件中被怀疑发现了恶意软件。因此,如果你选择使用 AUR,请谨慎操作,风险自负。 + +### 其实任何 Linux 都可以 + +说实话,如果你是开发人员,几乎任何 Linux 发行版都可以工作。如果从命令行执行大部分开发,则尤其如此。但是如果你喜欢在可靠的桌面上运行一个好的图形界面程序,试试这些发行版中的一个,它们不会令人失望。 + +通过 Linux 基金会和 edX 的免费[“Linux 简介”][20]课程了解有关 Linux 的更多信息。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/2019/1/top-5-linux-distributions-development-2019 + +作者:[Jack Wallen][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/jlwallen +[b]: https://github.com/lujun9972 +[1]: https://aws.amazon.com/ +[2]: https://www.linux.com/files/images/dev1jpg +[3]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev_1.jpg?itok=7QJQWBKi (Ubuntu) +[4]: https://www.linux.com/licenses/category/used-permission +[5]: https://en.opensuse.org/Portal:Tumbleweed +[6]: https://en.opensuse.org/Portal:Leap +[7]: https://software.opensuse.org/distributions/tumbleweed +[8]: /files/images/dev2jpg +[9]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev_2.jpg?itok=1GJmpr1t (openSUSE) +[10]: /files/images/dev3jpg +[11]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev_3.jpg?itok=_6Ki4EOo (GNOME) +[12]: https://spins.fedoraproject.org/ +[13]: https://system76.com/ +[14]: /files/images/dev4jpg +[15]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev_4.jpg?itok=nNG2Ax24 (Pop!_OS) +[16]: https://manjaro.org/download/ +[17]: /files/images/dev5jpg +[18]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev_5.jpg?itok=RGfF2UEi (Manjaro) +[19]: https://unity3d.com/unity/editor +[20]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/translated/tech/20190126 Get started with Tint2, an open source taskbar for Linux.md b/published/201902/20190126 Get started with Tint2, an open source taskbar for Linux.md similarity index 81% rename from translated/tech/20190126 Get started with Tint2, an open source taskbar for Linux.md rename to published/201902/20190126 Get started with Tint2, an open source taskbar for Linux.md index ef58de9fe5..1efd095a38 100644 --- a/translated/tech/20190126 Get started with Tint2, an open source taskbar for Linux.md +++ b/published/201902/20190126 Get started with Tint2, an open source taskbar for Linux.md @@ -1,16 +1,16 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10511-1.html) [#]: subject: (Get started with Tint2, an open source taskbar for Linux) [#]: via: (https://opensource.com/article/19/1/productivity-tool-tint2) [#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) -开始使用 Tint2,一款 Linux 中的开源任务栏 +开始使用 Tint2 吧,一款 Linux 中的开源任务栏 ====== -Tint2 是我们在开源工具系列中的第 14 个工具,它将在 2019 年提高你的工作效率,能在任何窗口管理器中提供一致的用户体验。 +> Tint2 是我们在开源工具系列中的第 14 个工具,它将在 2019 年提高你的工作效率,能在任何窗口管理器中提供一致的用户体验。 ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_hardware_purple.png?itok=3NdVoYhl) @@ -20,7 +20,7 @@ Tint2 是我们在开源工具系列中的第 14 个工具,它将在 2019 年 ### Tint2 -让我提高工作效率的最佳方法之一是使用尽可能不让我分心的干净界面。作为 Linux 用户,这意味着使用一种最小的窗口管理器,如 [Openbox][1]、[i3][2] 或 [Awesome][3]。它们每种都有让我更有效率的自定义选项。但让我失望的一件事是,它们都没有一致的配置,所以我不得不经常重新调整我的窗口管理器。 +让我提高工作效率的最佳方法之一是使用尽可能不让我分心的干净界面。作为 Linux 用户,这意味着使用一种极简的窗口管理器,如 [Openbox][1]、[i3][2] 或 [Awesome][3]。它们每种都有让我更有效率的自定义选项。但让我失望的一件事是,它们都没有一致的配置,所以我不得不经常重新调整我的窗口管理器。 ![](https://opensource.com/sites/default/files/uploads/tint2-1.png) @@ -30,7 +30,7 @@ Tint2 是我们在开源工具系列中的第 14 个工具,它将在 2019 年 ![](https://opensource.com/sites/default/files/uploads/tint2-2.png) -启动配置工具能让你选择主题并自定义屏幕的顶部、底部和侧边栏。我建议从最接近你想要的主题开始,然后从那里进行自定义。 +启动该配置工具能让你选择主题并自定义屏幕的顶部、底部和侧边栏。我建议从最接近你想要的主题开始,然后从那里进行自定义。 ![](https://opensource.com/sites/default/files/uploads/tint2-3.png) @@ -47,7 +47,7 @@ via: https://opensource.com/article/19/1/productivity-tool-tint2 作者:[Kevin Sonney][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/) 荣誉推出 @@ -56,4 +56,4 @@ via: https://opensource.com/article/19/1/productivity-tool-tint2 [1]: http://openbox.org/wiki/Main_Page [2]: https://i3wm.org/ [3]: https://awesomewm.org/ -[4]: https://gitlab.com/o9000/tint2 \ No newline at end of file +[4]: https://gitlab.com/o9000/tint2 diff --git a/translated/tech/20190127 Get started with eDEX-UI, a Tron-influenced terminal program for tablets and desktops.md b/published/201902/20190127 Get started with eDEX-UI, a Tron-influenced terminal program for tablets and desktops.md similarity index 60% rename from translated/tech/20190127 Get started with eDEX-UI, a Tron-influenced terminal program for tablets and desktops.md rename to published/201902/20190127 Get started with eDEX-UI, a Tron-influenced terminal program for tablets and desktops.md index cce0f28165..aa42bef0ea 100644 --- a/translated/tech/20190127 Get started with eDEX-UI, a Tron-influenced terminal program for tablets and desktops.md +++ b/published/201902/20190127 Get started with eDEX-UI, a Tron-influenced terminal program for tablets and desktops.md @@ -1,15 +1,17 @@ [#]: collector: (lujun9972) [#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10525-1.html) [#]: subject: (Get started with eDEX-UI, a Tron-influenced terminal program for tablets and desktops) [#]: via: (https://opensource.com/article/19/1/productivity-tool-edex-ui) [#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) -开始使用 eDEX-UI,一款受《创:战纪》影响的平板电脑和台式机终端程序 +开始使用 eDEX-UI 吧,一款受《电子世界争霸战》影响的终端程序 ====== -使用 eDEX-UI 让你的工作更有趣,这是我们开源工具系列中的第 15 个工具,它将使你在 2019 年更高效。 + +> 使用 eDEX-UI 让你的工作更有趣,这是我们开源工具系列中的第 15 个工具,它将使你在 2019 年更高效。 + ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/button_push_open_keyboard_file_organize.png?itok=KlAsk1gx) 每年年初似乎都有疯狂的冲动想提高工作效率。新年的决心,渴望开启新的一年,当然,“抛弃旧的,拥抱新的”的态度促成了这一切。通常这时的建议严重偏向闭源和专有软件,但事实上并不用这样。 @@ -18,25 +20,25 @@ ### eDEX-UI -当[《创:战纪》][1]上映时我才 11是岁。我不能否认,尽管这部电影充满幻想,但它对我后来的职业选择产生了影响。 +当[《电子世界争霸战》][1]上映时我才 11 岁。我不能否认,尽管这部电影充满幻想,但它对我后来的职业选择产生了影响。 ![](https://opensource.com/sites/default/files/uploads/edex-ui-1.png) -[eDEX-UI][2] 是一款专为平板电脑和台式机设计的跨平台终端程序,它受到《创:战纪》用户界面的启发。它在选项卡式界面中有五个终端,因此可以轻松地在任务之间切换,以及显示有用的系统信息。 +[eDEX-UI][2] 是一款专为平板电脑和台式机设计的跨平台终端程序,它的用户界面受到《电子世界争霸战》的启发。它在选项卡式界面中有五个终端,因此可以轻松地在任务之间切换,以及显示有用的系统信息。 在启动时,eDEX-UI 会启动一系列的东西,其中包含它所基于的 ElectronJS 系统的信息。启动后,eDEX-UI 会显示系统信息、文件浏览器、键盘(用于平板电脑)和主终端选项卡。其他四个选项卡(被标记为 EMPTY)没有加载任何内容,并且当你单击它时将启动一个 shell。eDEX-UI 中的默认 shell 是 Bash(如果在 Windows 上,则可能需要将其更改为 PowerShell 或 cmd.exe)。 ![](https://opensource.com/sites/default/files/uploads/edex-ui-2.png) -更改文件浏览器中的目录将更改活动终端中的目录,反之亦然。文件浏览器可以执行你期望的所有操作,包括在单击文件时打开关联的应用。唯一的例外是 eDEX-UI 的 settings.json 文件(默认是 .config/eDEX-UI),它会打开配置编辑器。这允许你为终端设置 shell 命令、更改主题以及修改用户界面的其他几个设置。主题也保存在配置目录中,因为它们也是 JSON 文件,所以创建自定义主题非常简单。 +更改文件浏览器中的目录也将更改活动终端中的目录,反之亦然。文件浏览器可以执行你期望的所有操作,包括在单击文件时打开关联的应用。唯一的例外是 eDEX-UI 的 `settings.json` 文件(默认在 `.config/eDEX-UI`),它会打开配置编辑器。这允许你为终端设置 shell 命令、更改主题以及修改用户界面的其他几个设置。主题也保存在配置目录中,因为它们也是 JSON 文件,所以创建自定义主题非常简单。 ![](https://opensource.com/sites/default/files/uploads/edex-ui-3.png) -eDEX-UI 允许你使用完全仿真运行五个终端。默认终端类型是 xterm-color,这意味着它支持全色彩。需要注意的一点是,输入时键盘会亮起,因此如果你在平板电脑上使用 eDEX-UI,键盘可能会在人们看见屏幕的环境中带来安全风险。因此最好在这些设备上使用没有键盘的主题,尽管在打字时看起来确实很酷。 +eDEX-UI 允许你使用完全仿真运行五个终端。默认终端类型是 xterm-color,这意味着它支持全色彩。需要注意的一点是,输入时键会亮起,因此如果你在平板电脑上使用 eDEX-UI,键盘可能会在人们看见屏幕的环境中带来安全风险。因此最好在这些设备上使用没有键盘的主题,尽管在打字时看起来确实很酷。 ![](https://opensource.com/sites/default/files/uploads/edex-ui-4.png) -虽然 eDEX-UI 仅支持五个终端窗口,但这对我来说已经足够了。在平板电脑上,eDEX-UI 给了我网络空间的感觉而不会影响我的效率。在桌面上,eDEX-UI 支持所有功能,并让我在我的同事面前显得很酷。 +虽然 eDEX-UI 仅支持五个终端窗口,但这对我来说已经足够了。在平板电脑上,eDEX-UI 给了我网络空间感而不会影响我的效率。在桌面上,eDEX-UI 支持所有功能,并让我在我的同事面前显得很酷。 -------------------------------------------------------------------------------- @@ -45,7 +47,7 @@ via: https://opensource.com/article/19/1/productivity-tool-edex-ui 作者:[Kevin Sonney][a] 选题:[lujun9972][b] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/published/201902/20190128 3 simple and useful GNOME Shell extensions.md b/published/201902/20190128 3 simple and useful GNOME Shell extensions.md new file mode 100644 index 0000000000..3125f76e71 --- /dev/null +++ b/published/201902/20190128 3 simple and useful GNOME Shell extensions.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10536-1.html) +[#]: subject: (3 simple and useful GNOME Shell extensions) +[#]: via: (https://fedoramagazine.org/3-simple-and-useful-gnome-shell-extensions/) +[#]: author: (Ryan Lerch https://fedoramagazine.org/introducing-flatpak/) + +3 个简单实用的 GNOME Shell 扩展 +====== +![](https://fedoramagazine.org/wp-content/uploads/2019/01/3simple-816x345.png) + +Fedora 工作站的默认桌面 GNOME Shell,因其极简、整洁的用户界面而闻名,并深受许多用户的喜爱。它还以可使用扩展添加到 stock 界面的能力而闻名。在本文中,我们将介绍 GNOME Shell 的 3 个简单且有用的扩展。这三个扩展为你的桌面提供了更多的行为,可以完成你可能每天都会做的简单任务。 + +### 安装扩展程序 + +安装 GNOME Shell 扩展的最快捷、最简单的方法是使用“软件”应用。有关详细信息,请查看 Magazine [以前的文章](https://fedoramagazine.org/install-extensions-via-software-application/): + +![](https://fedoramagazine.org/wp-content/uploads/2018/11/installing-extensions-768x325.jpg) + +### 可移动驱动器菜单 + +![][1] + +*Fedora 29 中的 Removable Drive Menu 扩展* + +首先是 [Removable Drive Menu][2] 扩展。如果你的计算机中有可移动驱动器,它是一个可在系统托盘中添加一个 widget 的简单工具。它可以使你轻松打开可移动驱动器中的文件,或者快速方便地弹出驱动器以安全移除设备。 + +![][3] + +*软件应用中的 Removable Drive Menu* + +### 扩展之扩展 + +![][4] + +如果你一直在安装和尝试新扩展,那么 [Extensions][5] 扩展非常有用。它提供了所有已安装扩展的列表,允许你启用或禁用它们。此外,如果该扩展有设置,那么可以快速打开每个扩展的设置对话框。 + +![][6] + +*软件中的 Extensions 扩展* + +### 无用的时钟移动 + +![][7] + +最后的是列表中最简单的扩展。[Frippery Move Clock][8],只是将时钟位置从顶部栏的中心向右移动,位于状态区旁边。 + +![][9] + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/3-simple-and-useful-gnome-shell-extensions/ + +作者:[Ryan Lerch][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org/introducing-flatpak/ +[b]: https://github.com/lujun9972 +[1]: https://fedoramagazine.org/wp-content/uploads/2019/01/removable-disk-1024x459.jpg +[2]: https://extensions.gnome.org/extension/7/removable-drive-menu/ +[3]: https://fedoramagazine.org/wp-content/uploads/2019/01/removable-software-1024x723.png +[4]: https://fedoramagazine.org/wp-content/uploads/2019/01/extensions-extension-1024x459.jpg +[5]: https://extensions.gnome.org/extension/1036/extensions/ +[6]: https://fedoramagazine.org/wp-content/uploads/2019/01/extensions-software-1024x723.png +[7]: https://fedoramagazine.org/wp-content/uploads/2019/01/move_clock-1024x189.jpg +[8]: https://extensions.gnome.org/extension/2/move-clock/ +[9]: https://fedoramagazine.org/wp-content/uploads/2019/01/Screenshot-from-2019-01-28-21-53-18-1024x723.png diff --git a/translated/tech/20190128 Using more to view text files at the Linux command line.md b/published/201902/20190128 Using more to view text files at the Linux command line.md similarity index 52% rename from translated/tech/20190128 Using more to view text files at the Linux command line.md rename to published/201902/20190128 Using more to view text files at the Linux command line.md index f10ac248fc..9929654a94 100644 --- a/translated/tech/20190128 Using more to view text files at the Linux command line.md +++ b/published/201902/20190128 Using more to view text files at the Linux command line.md @@ -1,23 +1,24 @@ [#]: collector: (lujun9972) -[#]: translator: ( dianbanjiu ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: translator: (dianbanjiu) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10531-1.html) [#]: subject: (Using more to view text files at the Linux command line) [#]: via: (https://opensource.com/article/19/1/more-text-files-linux) [#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) 在 Linux 命令行使用 more 查看文本文件 ====== -文本文件和 Linux 一直是携手并进的。或者说看起来如此。那你又是依靠哪些让你使用起来很舒服的工具来查看这些文本文件的呢? + +> 文本文件和 Linux 一直是携手并进的。或者说看起来如此。那你又是依靠哪些让你使用起来很舒服的工具来查看这些文本文件的呢? ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/terminal_command_linux_desktop_code.jpg?itok=p5sQ6ODE) -Linux 下有很多实用工具可以让你在终端界面查看文本文件。其中一个就是 [**more**][1]。 +Linux 下有很多实用工具可以让你在终端界面查看文本文件。其中一个就是 [more][1]。 -**more** 跟我之前另一篇文章里写到的工具 —— **[less][2]** 很相似。它们之间的主要不同点在于 **more** 只允许你向前查看文件。 +`more` 跟我之前另一篇文章里写到的工具 —— [less][2] 很相似。它们之间的主要不同点在于 `more` 只允许你向前查看文件。 -尽管它能提供的功能看起来很有限,不过它依旧有很多有用的特性值得你去了解。下面让我们来快速浏览一下 **more** 可以做什么,以及如何使用它吧。 +尽管它能提供的功能看起来很有限,不过它依旧有很多有用的特性值得你去了解。下面让我们来快速浏览一下 `more` 可以做什么,以及如何使用它吧。 ### 基础使用 @@ -35,9 +36,9 @@ $ more jekyll-article.md ![](https://opensource.com/sites/default/files/uploads/more-viewing-file.png) -使用空格键可以向下翻页,输入 **q** 可以退出。 +使用空格键可以向下翻页,输入 `q` 可以退出。 -如果你想在这个文件中搜索一些文本,输入 **/** 字符并在其后加上你想要查找的文字。例如你要查看的字段是 terminal,只需输入: +如果你想在这个文件中搜索一些文本,输入 `/` 字符并在其后加上你想要查找的文字。例如你要查看的字段是 “terminal”,只需输入: ``` /terminal @@ -45,12 +46,13 @@ $ more jekyll-article.md ![](https://opensource.com/sites/default/files/uploads/more-searching.png) -搜索的内容是区分大小写的,所以输入 /terminal 跟 /Terminal 会出现不同的结果。 +搜索的内容是区分大小写的,所以输入 `/terminal` 跟 `/Terminal` 会出现不同的结果。 ### 和其他实用工具组合使用 -你可以通过管道将其他命令行工具得到的文本传输到 **more**。你问为什么这样做?因为有时这些工具获取的文本会超过终端一页可以显示的限度。 -想要做到这个,先输入你想要使用的完整命令,后面跟上管道符(**|**),管道符后跟 **more**。假设现在有一个有很多文件的目录。你就可以组合 **more** 跟 **ls** 命令完整查看这个目录当中的内容。 +你可以通过管道将其他命令行工具得到的文本传输到 `more`。你问为什么这样做?因为有时这些工具获取的文本会超过终端一页可以显示的限度。 + +想要做到这个,先输入你想要使用的完整命令,后面跟上管道符(`|`),管道符后跟 `more`。假设现在有一个有很多文件的目录。你就可以组合 `more` 跟 `ls` 命令完整查看这个目录当中的内容。 ```shell $ ls | more @@ -58,7 +60,7 @@ $ ls | more ![](https://opensource.com/sites/default/files/uploads/more-with_ls_cmd.png) -你可以组合 **more** 和 **grep** 命令,从而实现在多个文件中找到指定的文本。下面是我在多篇文章的源文件中查找 productivity 的例子。 +你可以组合 `more` 和 `grep` 命令,从而实现在多个文件中找到指定的文本。下面是我在多篇文章的源文件中查找 “productivity” 的例子。 ```shell $ grep ‘productivity’ core.md Dict.md lctt2014.md lctt2016.md lctt2018.md README.md | more @@ -66,17 +68,17 @@ $ grep ‘productivity’ core.md Dict.md lctt2014.md lctt2016.md lctt2018.md RE ![](https://opensource.com/sites/default/files/uploads/more-with_grep_cmd.png) -另外一个可以和 **more** 组合的实用工具是 **ps**(列出你系统上正在运行的进程)。当你的系统上运行了很多的进程,你现在想要查看他们的时候,这个组合将会派上用场。例如你想找到一个你需要杀死的进程,只需输入下面的命令: +另外一个可以和 `more` 组合的实用工具是 `ps`(列出你系统上正在运行的进程)。当你的系统上运行了很多的进程,你现在想要查看他们的时候,这个组合将会派上用场。例如你想找到一个你需要杀死的进程,只需输入下面的命令: ```shell $ ps -u scott | more ``` -注意用你的用户名替换掉 scott。 +注意用你的用户名替换掉 “scott”。 ![](https://opensource.com/sites/default/files/uploads/more-with_ps_cmd.png) -就像我文章开篇提到的, **more** 很容易使用。尽管不如它的双胞胎兄弟 **less** 那般灵活,但是仍然值得了解一下。 +就像我文章开篇提到的, `more` 很容易使用。尽管不如它的双胞胎兄弟 `less` 那般灵活,但是仍然值得了解一下。 -------------------------------------------------------------------------------- @@ -85,7 +87,7 @@ via: https://opensource.com/article/19/1/more-text-files-linux 作者:[Scott Nesbitt][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/) 荣誉推出 diff --git a/published/20190128 fdisk - Easy Way To Manage Disk Partitions In Linux.md b/published/201902/20190128 fdisk - Easy Way To Manage Disk Partitions In Linux.md similarity index 100% rename from published/20190128 fdisk - Easy Way To Manage Disk Partitions In Linux.md rename to published/201902/20190128 fdisk - Easy Way To Manage Disk Partitions In Linux.md diff --git a/published/201902/20190129 Get started with gPodder, an open source podcast client.md b/published/201902/20190129 Get started with gPodder, an open source podcast client.md new file mode 100644 index 0000000000..f5449a95de --- /dev/null +++ b/published/201902/20190129 Get started with gPodder, an open source podcast client.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10567-1.html) +[#]: subject: (Get started with gPodder, an open source podcast client) +[#]: via: (https://opensource.com/article/19/1/productivity-tool-gpodder) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) + +开始使用 gPodder 吧,一个开源播客客户端 +====== + +> 使用 gPodder 将你的播客同步到你的设备上,gPodder 是我们开源工具系列中的第 17 个工具,它将在 2019 年提高你的工作效率。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/podcast-record-microphone.png?itok=8yUDOywf) + +每年年初似乎都有疯狂的冲动想提高工作效率。新年的决心,渴望开启新的一年,当然,“抛弃旧的,拥抱新的”的态度促成了这一切。通常这时的建议严重偏向闭源和专有软件,但事实上并不用这样。 + +这是我挑选出的 19 个新的(或者对你而言新的)开源工具中的第 17 个工具来帮助你在 2019 年更有效率。 + +### gPodder + +我喜欢播客。哎呀,我非常喜欢它们,因此我录制了其中的三个(你可以在[我的个人资料][1]中找到它们的链接)。我从播客那里学到了很多东西,并在我工作时在后台播放它们。但是,如何在多台桌面和移动设备之间保持同步可能会有一些挑战。 + +[gPodder][2] 是一个简单的跨平台播客下载器、播放器和同步工具。它支持 RSS feed、[FeedBurner][3]、[YouTube][4] 和 [SoundCloud][5],它还有一个开源的同步服务,你可以根据需要运行它。gPodder 不直接播放播客。相反,它会使用你选择的音频或视频播放器。 + +![](https://opensource.com/sites/default/files/uploads/gpodder-1.png) + +安装 gPodder 非常简单。安装程序适用于 Windows 和 MacOS,同时也有用于主要的 Linux 发行版的软件包。如果你的发行版中没有它,你可以直接从 Git 下载运行。通过 “Add Podcasts via URL” 菜单,你可以输入播客的 RSS 源 URL 或其他服务的 “特殊” URL。gPodder 将获取节目列表并显示一个对话框,你可以在其中选择要下载的节目或在列表上标记旧节目。 + +![](https://opensource.com/sites/default/files/uploads/gpodder-2.png) + +它一个更好的功能是,如果 URL 已经在你的剪贴板中,gPodder 会自动将它放入播放 URL 中,这样你就可以很容易地将新的播客添加到列表中。如果你已有播客 feed 的 OPML 文件,那么可以上传并导入它。还有一个发现选项,让你可搜索 [gPodder.net][6] 上的播客,这是由编写和维护 gPodder 的人员提供的自由及开源的播客的列表网站。 + +![](https://opensource.com/sites/default/files/uploads/gpodder-3.png) + +[mygpo][7] 服务器在设备之间同步播客。gPodder 默认使用 [gPodder.net][8] 的服务器,但是如果你想要运行自己的服务器,那么可以在配置文件中更改它(请注意,你需要直接修改配置文件)。同步能让你在桌面和移动设备之间保持列表一致。如果你在多个设备上收听播客(例如,我在我的工作电脑、家用电脑和手机上收听),这会非常有用,因为这意味着无论你身在何处,你都拥有最近的播客和节目列表而无需一次又一次地设置。 + +![](https://opensource.com/sites/default/files/uploads/gpodder-4.png) + +单击播客节目将显示与其关联的文本,单击“播放”将启动设备的默认音频或视频播放器。如果要使用默认之外的其他播放器,可以在 gPodder 的配置设置中更改此设置。 + +通过 gPodder,你可以轻松查找、下载和收听播客,在设备之间同步这些播客,在易于使用的界面中访问许多其他功能。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/productivity-tool-gpodder + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ksonney (Kevin Sonney) +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/users/ksonney +[2]: https://gpodder.github.io/ +[3]: https://feedburner.google.com/ +[4]: https://youtube.com +[5]: https://soundcloud.com/ +[6]: http://gpodder.net +[7]: https://github.com/gpodder/mygpo +[8]: http://gPodder.net diff --git a/translated/tech/20190129 More About Angle Brackets in Bash.md b/published/201902/20190129 More About Angle Brackets in Bash.md similarity index 73% rename from translated/tech/20190129 More About Angle Brackets in Bash.md rename to published/201902/20190129 More About Angle Brackets in Bash.md index de4f8331ca..a34d4fc963 100644 --- a/translated/tech/20190129 More About Angle Brackets in Bash.md +++ b/published/201902/20190129 More About Angle Brackets in Bash.md @@ -1,14 +1,15 @@ [#]: collector: (lujun9972) [#]: translator: (HankChow) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10529-1.html) [#]: subject: (More About Angle Brackets in Bash) [#]: via: (https://www.linux.com/blog/learn/2019/1/more-about-angle-brackets-bash) [#]: author: (Paul Brown https://www.linux.com/users/bro66) Bash 中尖括号的更多用法 ====== +> 在这篇文章,我们继续来深入探讨尖括号的更多其它用法。 ![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/bash-angles.png?itok=mVFnxPzF) @@ -22,19 +23,20 @@ Bash 中尖括号的更多用法 diff <(ls /original/dir/) <(ls /backup/dir/) ``` -[`diff`][2] 命令是一个逐行比较两个文件之间差异的工具。在上面的例子中,就使用了 `<` 让 `diff` 认为两个 `ls` 命令输出的结果都是文件,从而能够比较它们之间的差异。 +[diff][2] 命令是一个逐行比较两个文件之间差异的工具。在上面的例子中,就使用了 `<` 让 `diff` 认为两个 `ls` 命令输出的结果都是文件,从而能够比较它们之间的差异。 要注意,在 `<` 和 `(...)` 之间是没有空格的。 我尝试在我的图片目录和它的备份目录执行上面的命令,输出的是以下结果: ``` -diff <(ls /My/Pictures/) <(ls /My/backup/Pictures/) 5d4 < Dv7bIIeUUAAD1Fc.jpg:large.jpg +diff <(ls /My/Pictures/) <(ls /My/backup/Pictures/) +5d4 < Dv7bIIeUUAAD1Fc.jpg:large.jpg ``` 输出结果中的 `<` 表示 `Dv7bIIeUUAAD1Fc.jpg:large.jpg` 这个文件存在于左边的目录(`/My/Pictures`)但不存在于右边的目录(`/My/backup/Pictures`)中。也就是说,在备份过程中可能发生了问题,导致这个文件没有被成功备份。如果 `diff` 没有显示出任何输出结果,就表明两个目录中的文件是一致的。 -看到这里你可能会想到,既然可以通过 `<` 将一些命令行的输出内容作为一个文件,提供给一个需要接受文件格式的命令,那么在上一篇文章的“最喜欢的演员排序”例子中,就可以省去中间的一些步骤,直接对输出内容执行 `sort` 操作了。 +看到这里你可能会想到,既然可以通过 `<` 将一些命令行的输出内容作为一个文件提供给一个需要接受文件格式的命令,那么在上一篇文章的“最喜欢的演员排序”例子中,就可以省去中间的一些步骤,直接对输出内容执行 `sort` 操作了。 确实如此,这个例子可以简化成这样: @@ -42,7 +44,7 @@ diff <(ls /My/Pictures/) <(ls /My/backup/Pictures/) 5d4 < Dv7bIIeUUAAD1Fc.jpg:la sort -r <(while read -r name surname films;do echo $films $name $surname ; done < CBactors) ``` -### Here string +### Here 字符串 除此以外,尖括号的重定向功能还有另一种使用方式。 @@ -52,9 +54,9 @@ sort -r <(while read -r name surname films;do echo $films $name $surname ; done myvar="Hello World" echo $myvar | tr '[:lower:]' '[:upper:]' HELLO WORLD ``` -[`tr`][3] 命令可以将一个字符串转换为某种格式。在上面的例子中,就使用了 `tr` 将字符串中的所有小写字母都转换为大写字母。 +[tr][3] 命令可以将一个字符串转换为某种格式。在上面的例子中,就使用了 `tr` 将字符串中的所有小写字母都转换为大写字母。 -要理解的是,这个传递过程的重点不是变量,而是变量的值,也就是字符串 `Hello World`。这样的字符串叫做 here string,含义是“这就是我们要处理的字符串”。但对于上面的例子,还可以用更直观的方式的处理,就像下面这样: +要理解的是,这个传递过程的重点不是变量,而是变量的值,也就是字符串 `Hello World`。这样的字符串叫做 HERE 字符串,含义是“这就是我们要处理的字符串”。但对于上面的例子,还可以用更直观的方式的处理,就像下面这样: ``` tr '[:lower:]' '[:upper:]' <<< $myvar @@ -75,13 +77,13 @@ via: https://www.linux.com/blog/learn/2019/1/more-about-angle-brackets-bash 作者:[Paul Brown][a] 选题:[lujun9972][b] 译者:[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/) 荣誉推出 [a]: https://www.linux.com/users/bro66 [b]: https://github.com/lujun9972 -[1]: https://www.linux.com/blog/learn/2019/1/understanding-angle-brackets-bash +[1]: https://linux.cn/article-10502-1.html [2]: https://linux.die.net/man/1/diff [3]: https://linux.die.net/man/1/tr diff --git a/published/201902/20190130 Get started with Budgie Desktop, a Linux environment.md b/published/201902/20190130 Get started with Budgie Desktop, a Linux environment.md new file mode 100644 index 0000000000..58a8a6505c --- /dev/null +++ b/published/201902/20190130 Get started with Budgie Desktop, a Linux environment.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10547-1.html) +[#]: subject: (Get started with Budgie Desktop, a Linux environment) +[#]: via: (https://opensource.com/article/19/1/productivity-tool-budgie-desktop) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) + +开始使用 Budgie 吧,一款 Linux 桌面环境 +====== + +> 使用 Budgie 按需配置你的桌面,这是我们开源工具系列中的第 18 个工具,它将在 2019 年提高你的工作效率。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr) + +每年年初似乎都有疯狂的冲动想提高工作效率。新年的决心,渴望开启新的一年,当然,“抛弃旧的,拥抱新的”的态度促成了这一切。通常这时的建议严重偏向闭源和专有软件,但事实上并不用这样。 + +这是我挑选出的 19 个新的(或者对你而言新的)开源工具中的第 18 个工具来帮助你在 2019 年更有效率。 + +### Budgie 桌面 + +Linux 中有许多桌面环境。从易于使用并有令人惊叹图形界面的 [GNOME 桌面][1](在大多数主要 Linux 发行版上是默认桌面)和 [KDE][2],到极简主义的 [Openbox][3],再到高度可配置的平铺化的 [i3][4],有很多选择。我要寻找的桌面环境需要速度、不引人注目和干净的用户体验。当桌面不适合你时,很难会有高效率。 + +![](https://opensource.com/sites/default/files/uploads/budgie-1.png) + +[Budgie 桌面][5]是 [Solus][6] Linux 发行版的默认桌面,它在大多数主要 Linux 发行版的附加软件包中提供。它基于 GNOME,并使用了许多你可能已经在计算机上使用的相同工具和库。 + +其默认桌面非常简约,只有面板和空白桌面。Budgie 包含一个集成的侧边栏(称为 Raven),通过它可以快速访问日历、音频控件和设置菜单。Raven 还包含一个集成的通知区域,其中包含与 MacOS 类似的统一系统消息显示。 + +![](https://opensource.com/sites/default/files/uploads/budgie-2.png) + +点击 Raven 中的齿轮图标会显示 Budgie 的控制面板及其配置。由于 Budgie 仍处于开发阶段,与 GNOME 或 KDE 相比,它的选项有点少,我希望随着时间的推移它会有更多的选项。顶部面板选项允许用户配置顶部面板的排序、位置和内容,这很不错。 + +![](https://opensource.com/sites/default/files/uploads/budgie-3.png) + +Budgie 的 Welcome 应用(首次登录时展示)包含安装其他软件、面板小程序、截图和 Flatpack 软件包的选项。这些小程序有处理网络、截图、额外的时钟和计时器等等。 + +![](https://opensource.com/sites/default/files/uploads/budgie-4.png) + +Budgie 提供干净稳定的桌面。它响应迅速,有许多选项,允许你根据需要自定义它。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/productivity-tool-budgie-desktop + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ksonney (Kevin Sonney) +[b]: https://github.com/lujun9972 +[1]: https://www.gnome.org/ +[2]: https://www.kde.org/ +[3]: http://openbox.org/wiki/Main_Page +[4]: https://i3wm.org/ +[5]: https://getsol.us/solus/experiences/ +[6]: https://getsol.us/home/ diff --git a/published/201902/20190130 Olive is a new Open Source Video Editor Aiming to Take On Biggies Like Final Cut Pro.md b/published/201902/20190130 Olive is a new Open Source Video Editor Aiming to Take On Biggies Like Final Cut Pro.md new file mode 100644 index 0000000000..430b6210dd --- /dev/null +++ b/published/201902/20190130 Olive is a new Open Source Video Editor Aiming to Take On Biggies Like Final Cut Pro.md @@ -0,0 +1,111 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10577-1.html) +[#]: subject: (Olive is a new Open Source Video Editor Aiming to Take On Biggies Like Final Cut Pro) +[#]: via: (https://itsfoss.com/olive-video-editor) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +Olive:一款以 Final Cut Pro 为目标的开源视频编辑器 +====== + +[Olive][1] 是一个正在开发的新的开源视频编辑器。这个非线性视频编辑器旨在提供高端专业视频编辑软件的免费替代品。目标高么?我认为是的。 + +如果你读过我们的 [Linux 中的最佳视频编辑器][2]这篇文章,你可能已经注意到大多数“专业级”视频编辑器(如 [Lightworks][3] 或 DaVinciResolve)既不免费也不开源。 + +[Kdenlive][4] 和 Shotcut 也是此类,但它通常无法达到专业视频编辑的标准(这是许多 Linux 用户说的)。 + +爱好者级和专业级的视频编辑之间的这种差距促使 Olive 的开发人员启动了这个项目。 + +![Olive Video Editor][5] + +*Olive 视频编辑器界面* + +Libre Graphics World 中有一篇详细的[关于 Olive 的点评][6]。实际上,这是我第一次知道 Olive 的地方。如果你有兴趣了解更多信息,请阅读该文章。 + +### 在 Linux 中安装 Olive 视频编辑器 + +> 提醒你一下。Olive 正处于发展的早期阶段。你会发现很多 bug 和缺失/不完整的功能。你不应该把它当作你的主要视频编辑器。 + +如果你想测试 Olive,有几种方法可以在 Linux 上安装它。 + +#### 通过 PPA 在基于 Ubuntu 的发行版中安装 Olive + +你可以在 Ubuntu、Mint 和其他基于 Ubuntu 的发行版使用官方 PPA 安装 Olive。 + +``` +sudo add-apt-repository ppa:olive-editor/olive-editor +sudo apt-get update +sudo apt-get install olive-editor +``` + +#### 通过 Snap 安装 Olive + +如果你的 Linux 发行版支持 Snap,则可以使用以下命令进行安装。 + +``` +sudo snap install --edge olive-editor +``` + +#### 通过 Flatpak 安装 Olive + +如果你的 [Linux 发行版支持 Flatpak][7],你可以通过 Flatpak 安装 Olive 视频编辑器。 + +- [Flatpak 地址](https://flathub.org/apps/details/org.olivevideoeditor.Olive) + +#### 通过 AppImage 使用 Olive + +不想安装吗?下载 [AppImage][8] 文件,将其设置为可执行文件并运行它。32 位和 64 位 AppImage 文件都有。你应该下载相应的文件。 + +- [下载 Olive 的 AppImage](https://github.com/olive-editor/olive/releases/tag/continuous) + +Olive 也可用于 Windows 和 macOS。你可以从它的[下载页面][9]获得它。 + +### 想要支持 Olive 视频编辑器的开发吗? + +如果你喜欢 Olive 尝试实现的功能,并且想要支持它,那么你可以通过以下几种方式。 + +如果你在测试 Olive 时发现一些 bug,请到它们的 GitHub 仓库中报告。 + +- [提交 bug 报告以帮助 Olive](https://github.com/olive-editor/olive/issues) + +如果你是程序员,请浏览 Olive 的源代码,看看你是否可以通过编码技巧帮助项目。 + +- [Olive 的 GitHub 仓库](https://github.com/olive-editor/olive) + +在经济上为项目做贡献是另一种可以帮助开发开源软件的方法。你可以通过成为赞助人来支持 Olive。 + +- [赞助 Olive](https://www.patreon.com/olivevideoeditor) + +如果你没有支持 Olive 的金钱或编码技能,你仍然可以帮助它。在社交媒体或你经常访问的 Linux/软件相关论坛和群组中分享这篇文章或 Olive 的网站。一点微小的口碑都能间接地帮助它。 + +### 你如何看待 Olive? + +评判 Olive 还为时过早。我希望能够持续快速开发,并且在年底之前发布 Olive 的稳定版(如果我没有过于乐观的话)。 + +你如何看待 Olive?你是否认同开发人员针对专业用户的目标?你希望 Olive 拥有哪些功能? + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/olive-video-editor + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.olivevideoeditor.org/ +[2]: https://itsfoss.com/best-video-editing-software-linux/ +[3]: https://www.lwks.com/ +[4]: https://kdenlive.org/en/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/olive-video-editor-interface.jpg?resize=800%2C450&ssl=1 +[6]: http://libregraphicsworld.org/blog/entry/introducing-olive-new-non-linear-video-editor +[7]: https://itsfoss.com/flatpak-guide/ +[8]: https://itsfoss.com/use-appimage-linux/ +[9]: https://www.olivevideoeditor.org/download.php +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/olive-video-editor-interface.jpg?fit=800%2C450&ssl=1 diff --git a/published/201902/20190131 Will quantum computing break security.md b/published/201902/20190131 Will quantum computing break security.md new file mode 100644 index 0000000000..33323796ce --- /dev/null +++ b/published/201902/20190131 Will quantum computing break security.md @@ -0,0 +1,89 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10566-1.html) +[#]: subject: (Will quantum computing break security?) +[#]: via: (https://opensource.com/article/19/1/will-quantum-computing-break-security) +[#]: author: (Mike Bursell https://opensource.com/users/mikecamel) + +量子计算会打破现有的安全体系吗? +====== + +> 你会希望[某黑客][6]J. Random Hacker假冒你的银行吗? + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security_privacy_lock.png?itok=ZWjrpFzx) + +近年来,量子计算机quantum computer已经出现在大众的视野当中。量子计算机被认为是第六类计算机,这六类计算机包括: + +1. 人力Humans:在人造的计算工具出现之前,人类只能使用人力去进行计算。而承担计算工作的人,只能被称为“计算者”。 +2. 模拟计算工具Mechanical analogue:由人类制造的一些模拟计算过程的小工具,例如[安提凯希拉装置][1]Antikythera mechanism星盘astrolabe计算尺slide rule等等。 +3. 机械工具Mechanical digital:在这一个类别中包括了运用到离散数学但未使用电子技术进行计算的工具,例如算盘abacus、Charles Babbage 的差分机Difference Engine等等。 +4. 电子模拟计算工具Electronic analogue:这一个类别的计算机多数用于军事方面的用途,例如炸弹瞄准器、枪炮瞄准装置等等。 +5. 电子计算机Electronic digital:我在这里会稍微冒险一点,我觉得 Colossus 是第一台电子计算机,[^1] :这一类几乎包含现代所有的电子设备,从移动电话到超级计算机,都在这个类别当中。 +6. 量子计算机Quantum computer:即将进入我们的生活,而且与之前的几类完全不同。 + +### 什么是量子计算? + +量子计算Quantum computing的概念来源于量子力学quantum mechanics,使用的计算方式和我们平常使用的普通计算非常不同。如果想要深入理解,建议从参考[维基百科上的定义][2]开始。对我们来说,最重要的是理解这一点:量子计算机使用量子位qubit进行计算。在这样的前提下,对于很多数学算法和运算操作,量子计算机的计算速度会比普通计算机要快得多。 + +这里的“快得多”是按数量级来说的“快得多”。在某些情况下,一个计算任务如果由普通计算机来执行,可能要耗费几年或者几十年才能完成,但如果由量子计算机来执行,就只需要几秒钟。这样的速度甚至令人感到可怕。因为量子计算机会非常擅长信息的加密解密计算,即使在没有密钥的情况下,也能快速完成繁重的计算任务。 + +这意味着,如果拥有足够强大的量子计算机,那么你的所有信息都会被一览无遗,任何被加密的数据都可以被正确解密出来,甚至伪造数字签名也会成为可能。这确实是一个严重的问题。谁也不想被某个黑客冒充成自己在用的银行,更不希望自己在区块链上的交易被篡改得面目全非。 + +### 好消息 + +尽管上面的提到的问题非常可怕,但也不需要太担心。 + +首先,如果要实现上面提到的能力,一台可以操作大量量子位的量子计算机是必不可少的,而这个硬件上的要求就是一个很高的门槛。[^4] 目前普遍认为,规模大得足以有效破解经典加密算法的量子计算机在最近几年还不可能出现。 + +其次,除了攻击现有的加密算法需要大量的量子位以外,还需要很多量子位来保证容错性。 + +还有,尽管确实有一些理论上的模型阐述了量子计算机如何对一些现有的算法作出攻击,但是要让这样的理论模型实际运作起来的难度会比我们[^5] 想象中大得多。事实上,有一些攻击手段也是未被完全确认是可行的,又或者这些攻击手段还需要继续耗费很多年的改进才能到达如斯恐怖的程度。 + +最后,还有很多专业人士正在研究能够防御量子计算的算法(这样的算法也被称为“后量子算法post-quantum algorithms”)。如果这些防御算法经过测试以后投入使用,我们就可以使用这些算法进行加密,来对抗量子计算了。 + +总而言之,很多专家都认为,我们现有的加密方式在未来 5 年甚至未来 10 年内都是安全的,不需要过分担心。 + +### 也有坏消息 + +但我们也并不是高枕无忧了,以下两个问题就值得我们关注: + +1. 人们在设计应用系统的时候仍然没有对量子计算作出太多的考量。如果设计的系统可能会使用 10 年以上,又或者数据加密和签名的时间跨度在 10 年以上,那么就必须考虑量子计算在未来会不会对系统造成不利的影响。 +2. 新出现的防御量子计算的算法可能会是专有的。也就是说,如果基于这些防御量子计算的算法来设计系统,那么在系统落地的时候,可能会需要为此付费。尽管我是支持开源的,尤其是[开源密码学][3],但我最担心的就是无法开源这方面的内容。而且最糟糕的是,在建立新的协议标准时(不管是事实标准还是通过标准组织建立的标准),无论是故意的,还是无意忽略,或者是没有好的开源替代品,他们都很可能使用专有算法而排除使用开源算法。 + +### 我们要怎样做? + +幸运的是,针对上述两个问题,我们还是有应对措施的。首先,在整个系统的设计阶段,就需要考虑到它是否会受到量子计算的影响,并作出相应的规划。当然了,不需要现在就立即采取行动,因为当前的技术水平也没法实现有效的方案,但至少也要[在加密方面保持敏捷性][4],以便在任何需要的时候为你的协议和系统更换更有效的加密算法。[^7] + +其次是参与开源运动。尽可能鼓励密码学方面的有识之士团结起来,支持开放标准,并投入对非专有的防御量子计算的算法研究当中去。这一点也算是当务之急,因为号召更多的人重视起来并加入研究,比研究本身更为重要。 + +本文首发于《[Alice, Eve, and Bob][5]》,并在作者同意下重新发表。 + +[^1]: 我认为把它称为第一台电子可编程计算机是公平的。我知道有早期的非可编程的,也有些人声称是 ENIAC,但我没有足够的空间或精力在这里争论这件事。 +[^2]: No。 +[^3]: See 2. Don't get me wrong, by the way—I grew up near Weston-super-Mare, and it's got things going for it, but it's not Mayfair. +[^4]: 如果量子物理学家说很难,那么在我看来,就很难。 +[^5]: 而且我假设我们都不是量子物理学家或数学家。 +[^6]: I'm definitely not. +[^7]: 而且不仅仅是出于量子计算的原因:我们现有的一些经典算法很可能会陷入其他非量子攻击,例如新的数学方法。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/will-quantum-computing-break-security + +作者:[Mike Bursell][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mikecamel +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Antikythera_mechanism +[2]: https://en.wikipedia.org/wiki/Quantum_computing +[3]: https://opensource.com/article/17/10/many-eyes +[4]: https://aliceevebob.com/2017/04/04/disbelieving-the-many-eyes-hypothesis/ +[5]: https://aliceevebob.com/2019/01/08/will-quantum-computing-break-security/ +[6]: https://www.techopedia.com/definition/20225/j-random-hacker diff --git a/published/201902/20190201 Top 5 Linux Distributions for New Users.md b/published/201902/20190201 Top 5 Linux Distributions for New Users.md new file mode 100644 index 0000000000..5641dd8796 --- /dev/null +++ b/published/201902/20190201 Top 5 Linux Distributions for New Users.md @@ -0,0 +1,111 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10553-1.html) +[#]: subject: (Top 5 Linux Distributions for New Users) +[#]: via: (https://www.linux.com/blog/learn/2019/2/top-5-linux-distributions-new-users) +[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen) + +5 个面向新手的 Linux 发行版 +====== + +> 5 个可使用新用户有如归家般感觉的发行版。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/deepin-main.jpg?itok=ASgr0mOP) + +从最初的 Linux 到现在,Linux 已经发展了很长一段路。但是,无论你曾经多少次听说过现在使用 Linux 有多容易,仍然会有表示怀疑的人。而要真的承担得其这份声明,桌面必须足够简单,以便不熟悉 Linux 的人也能够使用它。事实上大量的桌面发行版使这成为了现实。 + +### 无需 Linux 知识 + +将这个清单误解为又一个“最佳用户友好型 Linux 发行版”的清单可能很简单。但这不是我们要在这里看到的。这二者之间有什么不同?就我的目的而言,定义的界限是 Linux 是否真正起到了使用的作用。换句话说,你是否可以将这个桌面操作系统放在一个用户面前,并让他们应用自如而无需懂得 Linux 知识呢? + +不管你相信与否,有些发行版就能做到。这里我将介绍给你 5 个这样的发行版。这些或许你全都听说过。它们或许不是你所选择的发行版,但可以向你保证它们无需过多关注,而是将用户放在眼前的。 + +我们来看看选中的几个。 + +### Elementary OS + +[Elementary OS](https://elementary.io/) 的理念主要围绕人们如何实际使用他们的桌面。开发人员和设计人员不遗余力地创建尽可能简单的桌面。在这个过程中,他们致力于去 Linux 化的 Linux。这并不是说他们已经从这个等式中删除了 Linux。不,恰恰相反,他们所做的就是创建一个与你所发现的一样的中立的操作系统。Elementary OS 是如此流畅,以确保一切都完美合理。从单个 Dock 到每个人都清晰明了的应用程序菜单,这是一个桌面,而不用提醒用户说,“你正在使用 Linux!” 事实上,其布局本身就让人联想到 Mac,但附加了一个简单的应用程序菜单(图 1)。 + +![Elementary OS Juno][2] + +*图 1:Elementary OS Juno 应用菜单* + +将 Elementary OS 放在此列表中的另一个重要原因是它不像其他桌面发行版那样灵活。当然,有些用户会对此不以为然,但是如果桌面没有向用户扔出各种花哨的定制诱惑,那么就会形成一个非常熟悉的环境:一个既不需要也不允许大量修修补补的环境。操作系统在让新用户熟悉该平台这一方面还有很长的路要走。 + +与任何现代 Linux 桌面发行版一样,Elementary OS 包括了应用商店,称为 AppCenter,用户可以在其中安装所需的所有应用程序,而无需触及命令行。 + +### 深度操作系统 + +[深度操作系统](https://www.deepin.org/)不仅得到了市场上最漂亮的台式机之一的赞誉,它也像任何桌面操作系统一样容易上手。其桌面界面非常简单,对于毫无 Linux 经验的用户来说,它的上手速度非常快。事实上,你很难找到无法立即上手使用 Deepin 桌面的用户。而这里唯一可能的障碍可能是其侧边栏控制中心(图 2)。 + +![][5] + +*图 2:Deepin 的侧边栏控制编码* + +但即使是侧边栏控制面板,也像市场上的任何其他配置工具一样直观。任何使用过移动设备的人对于这种布局都很熟悉。至于打开应用程序,Deepin 的启动器采用了 macOS Launchpad 的方式。此按钮位于桌面底座上通常最右侧的位置,因此用户立即就可以会意,知道它可能类似于标准的“开始”菜单。 + +与 Elementary OS(以及市场上大多数 Linux 发行版)类似,深度操作系统也包含一个应用程序商店(简称为“商店”),可以轻松安装大量应用程序。 + +### Ubuntu + +你知道肯定有它。[Ubuntu](https://www.ubuntu.com/) 通常在大多数用户友好的 Linux 列表中占据首位。因为它是少数几个不需要懂得 Linux 就能使用的桌面之一。但在采用 GNOME(和 Unity 谢幕)之前,情况并非如此。因为 Unity 经常需要进行一些调整才能达到一点 Linux 知识都不需要的程度(图 3)。现在 Ubuntu 已经采用了 GNOME,并将其调整到甚至不需要懂得 GNOME 的程度,这个桌面使得对 Linux 的简单性和可用性的要求不再是迫切问题。 + +![Ubuntu 18.04][7] + +*图 3:Ubuntu 18.04 桌面可使用马上熟悉起来* + +与 Elementary OS 不同,Ubuntu 对用户毫无阻碍。因此,任何想从桌面上获得更多信息的人都可以拥有它。但是,其开箱即用的体验对于任何类型的用户都是足够的。任何一个让用户不知道他们触手可及的力量有多少的桌面,肯定不如 Ubuntu。 + +### Linux Mint + +我需要首先声明,我从来都不是 [Linux Mint](https://linuxmint.com/) 的忠实粉丝。但这并不是说我不尊重开发者的工作,而更多的是一种审美观点。我更喜欢现代化的桌面环境。但是,旧式的学校计算机桌面的隐喻(可以在默认的 Cinnamon 桌面中找到)可以让几乎每个人使用它的人都格外熟悉。Linux Mint 使用任务栏、开始按钮、系统托盘和桌面图标(图 4),提供了一个需要零学习曲线的界面。事实上,一些用户最初可能会被愚弄,以为他们正在使用 Windows 7 的克隆版。甚至是它的更新警告图标也会让用户感到非常熟悉。 + +![Linux Mint][9] + +*图 4:Linux Mint 的 Cinnamon 桌面非常像 Windows 7* + +因为 Linux Mint 受益于其所基于的 Ubuntu,它不仅会让你马上熟悉起来,而且具有很高的可用性。无论你是否对底层平台有所了解,用户都会立即感受到宾至如归的感觉。 + +### Ubuntu Budgie + +我们的列表将以这样一个发行版做结:它也能让用户忘记他们正在使用 Linux,并且使用常用工具变得简单、美观。使 Ubuntu 融合 Budgie 桌面可以构成一个令人印象深刻的易用发行版。虽然其桌面布局(图 5)可能不太一样,但毫无疑问,适应这个环境并不需要浪费时间。实际上,除了 Dock 默认居于桌面的左侧,[Ubuntu Budgie](https://ubuntubudgie.org/) 确实看起来像 Elementary OS。 + +![Budgie][11] + +*图 5:Budgie 桌面既漂亮又简单* + +Ubuntu Budgie 中的系统托盘/通知区域提供了一些不太多见的功能,比如:快速访问 Caffeine(一种保持桌面清醒的工具)、快速笔记工具(用于记录简单笔记)、Night Lite 开关、原地下拉菜单(用于快速访问文件夹),当然还有 Raven 小程序/通知侧边栏(与深度操作系统中的控制中心侧边栏类似,但不太优雅)。Budgie 还包括一个应用程序菜单(左上角),用户可以访问所有已安装的应用程序。打开一个应用程序,该图标将出现在 Dock 中。右键单击该应用程序图标,然后选择“保留在 Dock”以便更快地访问。 + +Ubuntu Budgie 的一切都很直观,所以几乎没有学习曲线。这种发行版既优雅又易于使用,不能再好了。 + +### 选择一个吧 + +至此介绍了 5 个 Linux 发行版,它们各自以自己的方式提供了让任何用户都马上熟悉的桌面体验。虽然这些可能不是你对顶级发行版的选择,但对于那些不熟悉 Linux 的用户来说,却不能否定它们的价值。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2019/2/top-5-linux-distributions-new-users + +作者:[Jack Wallen][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/jlwallen +[b]: https://github.com/lujun9972 +[1]: https://www.linux.com/files/images/elementaryosjpg-2 +[2]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/elementaryos_0.jpg?itok=KxgNUvMW (Elementary OS Juno) +[3]: https://www.linux.com/licenses/category/used-permission +[4]: https://www.linux.com/files/images/deepinjpg +[5]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/deepin.jpg?itok=VV381a9f +[6]: https://www.linux.com/files/images/ubuntujpg-1 +[7]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ubuntu_1.jpg?itok=bax-_Tsg (Ubuntu 18.04) +[8]: https://www.linux.com/files/images/linuxmintjpg +[9]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/linuxmint.jpg?itok=8sPon0Cq (Linux Mint ) +[10]: https://www.linux.com/files/images/budgiejpg-0 +[11]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/budgie_0.jpg?itok=zcf-AHmj (Budgie) +[12]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/published/201902/20190205 DNS and Root Certificates.md b/published/201902/20190205 DNS and Root Certificates.md new file mode 100644 index 0000000000..3a921def35 --- /dev/null +++ b/published/201902/20190205 DNS and Root Certificates.md @@ -0,0 +1,136 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10533-1.html) +[#]: subject: (DNS and Root Certificates) +[#]: via: (https://lushka.al/dns-and-certificates/) +[#]: author: (Anxhelo Lushka https://lushka.al/) + +DNS 和根证书 +====== + +> 关于 DNS 和根证书你需要了解的内容。 + +由于最近发生的一些事件,我们(Privacy Today 组织)感到有必要写一篇关于此事的短文。它适用于所有读者,因此它将保持简单 —— 技术细节可能会在稍后的文章发布。 + +### 什么是 DNS,为什么它与你有关? + +DNS 的意思是域名系统Domain Name System,你每天都会接触到它。每当你的 Web 浏览器或任何其他应用程序连接到互联网时,它就很可能会使用域名。简单来说,域名就是你键入的地址:例如 [duckduckgo.com][1]。你的计算机需要知道它所导向的地方,会向 DNS 解析器寻求帮助。而它将返回类似 [176.34.155.23][2] 这样的 IP —— 这就是连接时所需要知道的公开网络地址。 此过程称为 DNS 查找。 + +这对你的隐私、安全以及你的自由都有一定的影响: + +#### 隐私 + +由于你要求解析器获取域名的 IP,因此它会确切地知道你正在访问哪些站点,并且由于“物联网”(通常缩写为 IoT),甚至它还知道你在家中使用的是哪个设备。 + +#### 安全 + +你可以相信解析器返回的 IP 是正确的。有一些检查措施可以确保如此,在正常情况下这一般不是问题。但这些可能措施会被破坏,这就是写作本文的原因。如果返回的 IP 不正确,你可能会被欺骗引向了恶意的第三方 —— 甚至你都不会注意到任何差异。在这种情况下,你的隐私会受到更大的危害,因为不仅会被跟踪你访问了什么网站,甚至你访问的内容也会被跟踪。第三方可以准确地看到你正在查看的内容,收集你输入的个人信息(例如密码)等等。你的整个身份可以轻松接管。 + +#### 自由 + +审查通常是通过 DNS 实施的。这不是最有效的方法,但它非常普遍。即使在西方国家,它也经常被公司和政府使用。他们使用与潜在攻击者相同的方法;当你查询 IP 地址时,他们不会返回正确的 IP。他们可以表现得就好像某个域名不存在,或完全将访问指向别处。 + +### DNS 查询的方式 + +#### 由你的 ISP 提供的第三方 DNS 解析器 + +大多数人都在使用由其互联网接入提供商(ISP)提供的第三方解析器。当你连接调制解调器时(LCTT 译注:或宽带路由器),这些 DNS 解析器就会被自动取出,而你可能从来没注意过它。 + +#### 你自己选择的第三方 DNS 解析器 + +如果你已经知道 DNS 意味着什么,那么你可能会决定使用你选择的另一个 DNS 解析器。这可能会改善这种情况,因为它使你的 ISP 更难以跟踪你,并且你可以避免某些形式的审查。尽管追踪和审查仍然是可能的,但这种方法并没有被广泛使用。 + +#### 你自己(本地)的 DNS 解析器 + +你可以自己动手,避免使用别人的 DNS 解析器的一些危险。如果你对此感兴趣,请告诉我们。 + +### 根证书 + +#### 什么是根证书? + +每当你访问以 https 开头的网站时,你都会使用它发送的证书与之通信。它使你的浏览器能够加密通信并确保没有人可以窥探。这就是为什么每个人都被告知在登录网站时要注意 https(而不是 http)。证书本身仅用于验证是否为某个域所生成。以及: + +这就是根证书的来源。可以其视为一个更高的级别,用来确保其下的级别是正确的。它验证发送给你的证书是否已由证书颁发机构授权。此权限确保创建证书的人实际上是真正的运营者。 + +这也被称为信任链。默认情况下,你的操作系统包含一组这些根证书,以确保该信任链的存在。 + +#### 滥用 + +我们现在知道: + +* DNS 解析器在你发送域名时向你发送 IP 地址 +* 证书允许加密你的通信,并验证它们是否为你访问的域生成 +* 根证书验证该证书是否合法,并且是由真实站点运营者创建的 + +**怎么会被滥用呢?** + +* 如前所述,恶意 DNS 解析器可能会向你发送错误的 IP 以进行审查。它们还可以将你导向完全不同的网站。 +* 这个网站可以向你发送假的证书。 +* 恶意的根证书可以“验证”此假证书。 + +对你来说,这个网站看起来绝对没问题;它在网址中有 https,如果你点击它,它会说已经通过验证。就像你了解到的一样,对吗?**不对!** + +它现在可以接收你要发送给原站点的所有通信。这会绕过想要避免被滥用而创建的检查。你不会收到错误消息,你的浏览器也不会发觉。 + +**而你所有的数据都会受到损害!** + +### 结论 + +#### 风险 + +* 使用恶意 DNS 解析器总是会损害你的隐私,但只要你注意 https,你的安全性就不会受到损害。 +* 使用恶意 DNS 解析程序和恶意根证书,你的隐私和安全性将完全受到损害。 + +#### 可以采取的动作 + +**不要安装第三方根证书!**只有非常少的例外情况才需要这样做,并且它们都不适用于一般最终用户。 + +**不要被那些“广告拦截”、“军事级安全”或类似的东西营销噱头所吸引**。有一些方法可以自行使用 DNS 解析器来增强你的隐私,但安装第三方根证书永远不会有意义。你正在将自己置身于陷阱之中。 + +### 实际看看 + +**警告** + +有位友好的系统管理员提供了一个现场演示,你可以实时看到自己。这是真事。 + +**千万不要输入私人数据!之后务必删除证书和该 DNS!** + +如果你不知道如何操作,那就不要安装它。虽然我们相信我们的朋友,但你不要随便安装随机和未知的第三方根证书。 + +#### 实际演示 + +链接在这里: + +* 设置所提供的 DNS 解析器 +* 安装所提供的根证书 +* 访问 并输入随机登录数据 +* 你的数据将显示在该网站上 + +### 延伸信息 + +如果你对更多技术细节感兴趣,请告诉我们。如果有足够多感兴趣的人,我们可能会写一篇文章,但是目前最重要的部分是分享基础知识,这样你就可以做出明智的决定,而不会因为营销和欺诈而陷入陷阱。请随时提出对你很关注的其他主题。 + +这篇文章来自 [Privacy Today 频道][3]。[Privacy Today][4] 是一个关于隐私、开源、自由哲学等所有事物的组织! + +所有内容均根据 CC BY-NC-SA 4.0 获得许可。([署名 - 非商业性使用 - 共享 4.0 国际][5])。 + +-------------------------------------------------------------------------------- + +via: https://lushka.al/dns-and-certificates/ + +作者:[Anxhelo Lushka][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://lushka.al/ +[b]: https://github.com/lujun9972 +[1]: https://duckduckgo.com +[2]: http://176.34.155.23 +[3]: https://t.me/privacytoday +[4]: https://t.me/joinchat/Awg5A0UW-tzOLX7zMoTDog +[5]: https://creativecommons.org/licenses/by-nc-sa/4.0/ diff --git a/published/201902/20190205 Installing Kali Linux on VirtualBox- Quickest - Safest Way.md b/published/201902/20190205 Installing Kali Linux on VirtualBox- Quickest - Safest Way.md new file mode 100644 index 0000000000..830ff13fd9 --- /dev/null +++ b/published/201902/20190205 Installing Kali Linux on VirtualBox- Quickest - Safest Way.md @@ -0,0 +1,142 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10550-1.html) +[#]: subject: (Installing Kali Linux on VirtualBox: Quickest & Safest Way) +[#]: via: (https://itsfoss.com/install-kali-linux-virtualbox) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +在 VirtualBox 上安装 Kali Linux 的最安全快捷的方式 +====== + +> 本教程将向你展示如何以最快的方式在运行于 Windows 和 Linux 上的 VirtualBox 上安装 Kali Linux。 + +[Kali Linux][1] 是最好的[黑客][2] 和安全爱好者的 Linux 发行版之一。 + +由于它涉及像黑客这样的敏感话题,它就像一把双刃剑。我们过去在一篇详细的 [Kali Linux 点评](https://linux.cn/article-10198-1.html)中对此进行了讨论,所以我不会再次赘述。 + +虽然你可以通过替换现有的操作系统来安装 Kali Linux,但通过虚拟机使用它将是一个更好、更安全的选择。 + +使用 Virtual Box,你可以将 Kali Linux 当做 Windows / Linux 系统中的常规应用程序一样,几乎就和在系统中运行 VLC 或游戏一样简单。 + +在虚拟机中使用 Kali Linux 也是安全的。无论你在 Kali Linux 中做什么都不会影响你的“宿主机系统”(即你原来的 Windows 或 Linux 操作系统)。你的实际操作系统将不会受到影响,宿主机系统中的数据将是安全的。 + +![Kali Linux on Virtual Box][3] + +### 如何在 VirtualBox 上安装 Kali Linux + +我将在这里使用 [VirtualBox][4]。它是一个很棒的开源虚拟化解决方案,适用于任何人(无论是专业或个人用途)。它可以免费使用。 + +在本教程中,我们将特指 Kali Linux 的安装,但你几乎可以安装任何其他已有 ISO 文件的操作系统或预先构建好的虚拟机存储文件。 + +**注意:**这些相同的步骤适用于运行在 Windows / Linux 上的 VirtualBox。 + +正如我已经提到的,你可以安装 Windows 或 Linux 作为宿主机。但是,在本文中,我安装了 Windows 10(不要讨厌我!),我会尝试在 VirtualBox 中逐步安装 Kali Linux。 + +而且,最好的是,即使你碰巧使用 Linux 发行版作为主要操作系统,相同的步骤也完全适用! + +想知道怎么样做吗?让我们来看看… + +### 在 VirtualBox 上安装 Kali Linux 的逐步指导 + +我们将使用专为 VirtualBox 制作的定制 Kali Linux 镜像。当然,你还可以下载 Kali Linux 的 ISO 文件并创建一个新的虚拟机,但是为什么在你有一个简单的替代方案时还要这样做呢? + +#### 1、下载并安装 VirtualBox + +你需要做的第一件事是从 Oracle 官方网站下载并安装 VirtualBox。 + +- [下载 VirtualBox](https://www.virtualbox.org/wiki/Downloads) + +下载了安装程序后,只需双击它即可安装 VirtualBox。在 Ubuntu / Fedora Linux 上安装 VirtualBox 也是一样的。 + +#### 2、下载就绪的 Kali Linux 虚拟镜像 + +VirtualBox 成功安装后,前往 [Offensive Security 的下载页面][5] 下载用于 VirtualBox 的虚拟机镜像。如果你改变主意想使用 [VMware][6],也有用于它的。 + +![Kali Linux Virtual Box Image][7] + +如你所见,文件大小远远超过 3 GB,你应该使用 torrent 方式或使用 [下载管理器][8] 下载它。 + +#### 3、在 VirtualBox 上安装 Kali Linux + +一旦安装了 VirtualBox 并下载了 Kali Linux 镜像,你只需将其导入 VirtualBox 即可使其正常工作。 + +以下是如何导入 Kali Linux 的 VirtualBox 镜像: + +**步骤 1**:启动 VirtualBox。你会注意到有一个 “Import” 按钮,点击它。 + +![virtualbox import][9] + +*点击 “Import” 按钮* + +**步骤 2**:接着,浏览找到你刚刚下载的文件并选择它导入(如你在下图所见)。文件名应该以 “kali linux” 开头,并以 “.ova” 扩展名结束。 + +![virtualbox import file][10] + +*导入 Kali Linux 镜像* + +选择好之后,点击 “Next” 进行处理。 + +**步骤 3**:现在,你将看到要导入的这个虚拟机的设置。你可以自定义它们,这是你的自由。如果你想使用默认设置,也没关系。 + +你需要选择具有足够存储空间的路径。我永远不会在 Windows 上推荐使用 C:驱动器。 + +![virtualbox kali linux settings][11] + +*以 VDI 方式导入硬盘驱动器* + +这里,VDI 方式的硬盘驱动器是指通过分配其存储空间设置来实际挂载该硬盘驱动器。 + +完成设置后,点击 “Import” 并等待一段时间。 + +**步骤 4**:你现在将看到这个虚拟机已经列出了。所以,只需点击 “Start” 即可启动它。 + +你最初可能会因 USB 端口 2.0 控制器支持而出现错误,你可以将其禁用以解决此问题,或者只需按照屏幕上的说明安装其他软件包进行修复即可。现在就完成了! + +![kali linux on windows virtual box][12] + +*运行于 VirtualBox 中的 Kali Linux* + +我希望本指南可以帮助你在 VirtualBox 上轻松安装 Kali Linux。当然,Kali Linux 有很多有用的工具可用于渗透测试 —— 祝你好运! + +**提示**:Kali Linux 和 Ubuntu 都是基于 Debian 的。如果你在使用 Kali Linux 时遇到任何问题或错误,可以按照互联网上针对 Ubuntu 或 Debian 的教程进行操作。 + +### 赠品:免费的 Kali Linux 指南手册 + +如果你刚刚开始使用 Kali Linux,那么了解如何使用 Kali Linux 是一个好主意。 + +Kali Linux 背后的公司 Offensive Security 已经创建了一本指南,介绍了 Linux 的基础知识,Kali Linux 的基础知识、配置和设置。它还有一些关于渗透测试和安全工具的章节。 + +基本上,它拥有你开始使用 Kali Linux 时所需知道的一切。最棒的是这本书可以免费下载。 + +- [免费下载 Kali Linux 揭秘](https://kali.training/downloads/Kali-Linux-Revealed-1st-edition.pdf) + +如果你遇到问题或想分享在 VirtualBox 上运行 Kali Linux 的经验,请在下面的评论中告诉我们。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-kali-linux-virtualbox + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.kali.org/ +[2]: https://itsfoss.com/linux-hacking-penetration-testing/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/kali-linux-virtual-box.png?resize=800%2C450&ssl=1 +[4]: https://www.virtualbox.org/ +[5]: https://www.offensive-security.com/kali-linux-vm-vmware-virtualbox-image-download/ +[6]: https://itsfoss.com/install-vmware-player-ubuntu-1310/ +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/kali-linux-virtual-box-image.jpg?resize=800%2C347&ssl=1 +[8]: https://itsfoss.com/4-best-download-managers-for-linux/ +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmbox-import-kali-linux.jpg?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmbox-linux-next.jpg?ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmbox-kali-linux-settings.jpg?ssl=1 +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/kali-linux-on-windows-virtualbox.jpg?resize=800%2C429&ssl=1 +[13]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/kali-linux-virtual-box.png?fit=800%2C450&ssl=1 diff --git a/published/201902/20190206 4 cool new projects to try in COPR for February 2019.md b/published/201902/20190206 4 cool new projects to try in COPR for February 2019.md new file mode 100644 index 0000000000..92523ddb46 --- /dev/null +++ b/published/201902/20190206 4 cool new projects to try in COPR for February 2019.md @@ -0,0 +1,95 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10554-1.html) +[#]: subject: (4 cool new projects to try in COPR for February 2019) +[#]: via: (https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-february-2019/) +[#]: author: (Dominik Turecek https://fedoramagazine.org) + +COPR 仓库中 4 个很酷的新软件(2019.2) +====== + +![](https://fedoramagazine.org/wp-content/uploads/2017/08/4-copr-945x400.jpg) + +COPR 是个人软件仓库[集合][1],它不在 Fedora 中。这是因为某些软件不符合轻松打包的标准。或者它可能不符合其他 Fedora 标准,尽管它是自由而开源的。COPR 可以在 Fedora 套件之外提供这些项目。COPR 中的软件不被 Fedora 基础设施不支持或没有被该项目所签名。但是,这是一种尝试新的或实验性的软件的一种巧妙的方式。 + +这是 COPR 中一组新的有趣项目。 + +### CryFS + +[CryFS][2] 是一个加密文件系统。它设计与云存储一同使用,主要是 Dropbox,尽管它也可以与其他存储提供商一起使用。CryFS 不仅加密文件系统中的文件,还会加密元数据、文件大小和目录结构。 + +#### 安装说明 + +仓库目前为 Fedora 28 和 29 以及 EPEL 7 提供 CryFS。要安装 CryFS,请使用以下命令: + +``` +sudo dnf copr enable fcsm/cryfs +sudo dnf install cryfs +``` + +### Cheat + +[Cheat][3] 是一个用于在命令行中查看各种备忘录的工具,用来提醒仅偶尔使用的程序的使用方法。对于许多 Linux 程序,`cheat` 提供了来自手册页的精简后的信息,主要关注最常用的示例。除了内置的备忘录,`cheat` 允许你编辑现有的备忘录或从头开始创建新的备忘录。 + +![][4] + +#### 安装说明 + +仓库目前为 Fedora 28、29 和 Rawhide 以及 EPEL 7 提供 `cheat`。要安装 `cheat`,请使用以下命令: + +``` +sudo dnf copr enable tkorbar/cheat +sudo dnf install cheat +``` + +### Setconf + +[setconf][5] 是一个简单的程序,作为 `sed` 的替代方案,用于对配置文件进行更改。`setconf` 唯一能做的就是找到指定文件中的密钥并更改其值。`setconf` 仅提供很少的选项来更改其行为 - 例如,取消更改行的注释。 + +#### 安装说明 + +仓库目前为 Fedora 27、28 和 29 提供 `setconf`。要安装 `setconf`,请使用以下命令: + +``` +sudo dnf copr enable jamacku/setconf +sudo dnf install setconf +``` + +### Reddit 终端查看器 + +[Reddit 终端查看器][6],或称为 `rtv`,提供了从终端浏览 Reddit 的界面。它提供了 Reddit 的基本功能,因此你可以登录到你的帐户,查看 subreddits、评论、点赞和发现新主题。但是,rtv 目前不支持 Reddit 标签。 + +![][7] + +#### 安装说明 + +该仓库目前为 Fedora 29 和 Rawhide 提供 Reddit Terminal Viewer。要安装 Reddit Terminal Viewer,请使用以下命令: + +``` +sudo dnf copr enable tc01/rtv +sudo dnf install rtv +``` + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/4-cool-new-projects-to-try-in-copr-for-february-2019/ + +作者:[Dominik Turecek][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fedoramagazine.org +[b]: https://github.com/lujun9972 +[1]: https://copr.fedorainfracloud.org/ +[2]: https://www.cryfs.org/ +[3]: https://github.com/chrisallenlane/cheat +[4]: https://fedoramagazine.org/wp-content/uploads/2019/01/cheat.png +[5]: https://setconf.roboticoverlords.org/ +[6]: https://github.com/michael-lazar/rtv +[7]: https://fedoramagazine.org/wp-content/uploads/2019/01/rtv.png diff --git a/published/201902/20190207 10 Methods To Create A File In Linux.md b/published/201902/20190207 10 Methods To Create A File In Linux.md new file mode 100644 index 0000000000..ef7d8e8228 --- /dev/null +++ b/published/201902/20190207 10 Methods To Create A File In Linux.md @@ -0,0 +1,315 @@ +[#]: collector: (lujun9972) +[#]: translator: (dianbanjiu) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10549-1.html) +[#]: subject: (10 Methods To Create A File In Linux) +[#]: via: (https://www.2daygeek.com/linux-command-to-create-a-file/) +[#]: author: (Vinoth Kumar https://www.2daygeek.com/author/vinoth/) + +在 Linux 上创建文件的 10 个方法 +====== + +我们都知道,在 Linux 上,包括设备在内的一切都是文件。Linux 管理员每天应该会多次执行文件创建活动(可能是 20 次,50 次,甚至是更多,这依赖于他们的环境)。如果你想 [在Linux上创建一个特定大小的文件][1],查看前面的这个链接。 + +高效创建一个文件是非常重要的能力。为什么我说高效?如果你了解一些高效进行你当前活动的方式,你就可以事半功倍。这将会节省你很多的时间。你可以把这些有用的时间用到到其他重要的事情上。 + +我下面将会介绍多个在 Linux 上创建文件的方法。我建议你选择几个简单高效的来辅助你的工作。你不必安装下列的任何一个命令,因为它们已经作为 Linux 核心工具的一部分安装到你的系统上了。 + +创建文件可以通过以下六个方式来完成。 + + * `>`:标准重定向符允许我们创建一个 0KB 的空文件。 + * `touch`:如果文件不存在的话,`touch` 命令将会创建一个 0KB 的空文件。 + * `echo`:通过一个参数显示文本的某行。 + * `printf`:用于显示在终端给定的文本。 + * `cat`:它串联并打印文件到标准输出。 + * `vi`/`vim`:Vim 是一个向上兼容 Vi 的文本编辑器。它常用于编辑各种类型的纯文本。 + * `nano`:是一个简小且用户友好的编辑器。它复制了 `pico` 的外观和优点,但它是自由软件。 + * `head`:用于打印一个文件开头的一部分。 + * `tail`:用于打印一个文件的最后一部分。 + * `truncate`:用于缩小或者扩展文件的尺寸到指定大小。 + +### 在 Linux 上使用重定向符(>)创建一个文件 + +标准重定向符允许我们创建一个 0KB 的空文件。它通常用于重定向一个命令的输出到一个新文件中。在没有命令的情况下使用重定向符号时,它会创建一个文件。 + +但是它不允许你在创建文件时向其中输入任何文本。然而它对于不是很勤劳的管理员是非常简单有用的。只需要输入重定向符后面跟着你想要的文件名。 + +``` +$ > daygeek.txt +``` + +使用 `ls` 命令查看刚刚创建的文件。 + +``` +$ ls -lh daygeek.txt +-rw-rw-r-- 1 daygeek daygeek 0 Feb 4 02:00 daygeek.txt +``` + +### 在 Linux 上使用 touch 命令创建一个文件 + +`touch` 命令常用于将每个文件的访问和修改时间更新为当前时间。 + +如果指定的文件名不存在,将会创建一个新的文件。`touch` 不允许我们在创建文件的同时向其中输入一些文本。它默认创建一个 0KB 的空文件。 + +``` +$ touch daygeek1.txt +``` + +使用 `ls` 命令查看刚刚创建的文件。 + +``` +$ ls -lh daygeek1.txt +-rw-rw-r-- 1 daygeek daygeek 0 Feb 4 02:02 daygeek1.txt +``` + +### 在 Linux 上使用 echo 命令创建一个文件 + +`echo` 内置于大多数的操作系统中。它常用于脚本、批处理文件,以及作为插入文本的单个命令的一部分。 + +它允许你在创建一个文件时就向其中输入一些文本。当然也允许你在之后向其中输入一些文本。 + +``` +$ echo "2daygeek.com is a best Linux blog to learn Linux" > daygeek2.txt +``` + +使用 `ls` 命令查看刚刚创建的文件。 + +``` +$ ls -lh daygeek2.txt +-rw-rw-r-- 1 daygeek daygeek 49 Feb 4 02:04 daygeek2.txt +``` + +可以使用 `cat` 命令查看文件的内容。 + +``` +$ cat daygeek2.txt +2daygeek.com is a best Linux blog to learn Linux +``` + +你可以使用两个重定向符 (`>>`) 添加其他内容到同一个文件。 + +``` +$ echo "It's FIVE years old blog" >> daygeek2.txt +``` + +你可以使用 `cat` 命令查看添加的内容。 + +``` +$ cat daygeek2.txt +2daygeek.com is a best Linux blog to learn Linux +It's FIVE years old blog +``` + +### 在 Linux 上使用 printf 命令创建一个新的文件 + +`printf` 命令也可以以类似 `echo` 的方式执行。 + +`printf` 命令常用来显示在终端窗口给出的字符串。`printf` 可以有格式说明符、转义序列或普通字符。 + +``` +$ printf "2daygeek.com is a best Linux blog to learn Linux\n" > daygeek3.txt +``` + +使用 `ls` 命令查看刚刚创建的文件。 + +``` +$ ls -lh daygeek3.txt +-rw-rw-r-- 1 daygeek daygeek 48 Feb 4 02:12 daygeek3.txt +``` + +使用 `cat` 命令查看文件的内容。 + +``` +$ cat daygeek3.txt +2daygeek.com is a best Linux blog to learn Linux +``` + +你可以使用两个重定向符 (`>>`) 添加其他的内容到同一个文件中去。 + +``` +$ printf "It's FIVE years old blog\n" >> daygeek3.txt +``` + +你可以使用 `cat` 命令查看这个文件中添加的内容。 + +``` +$ cat daygeek3.txt +2daygeek.com is a best Linux blog to learn Linux +It's FIVE years old blog +``` + +### 在 Linux 中使用 cat 创建一个文件 + +`cat` 表示串联concatenate。在 Linux 经常用于读取一个文件中的数据。 + +`cat` 是在类 Unix 系统中最常使用的命令之一。它提供了三个与文本文件相关的功能:显示一个文件的内容、组合多个文件的内容到一个输出以及创建一个新的文件。(LCTT 译注:如果 `cat` 命令后如果不带任何文件的话,下面的命令在回车后也不会立刻结束,回车后的操作可以按 `Ctrl-C` 或 `Ctrl-D` 来结束。) + +``` +$ cat > daygeek4.txt +2daygeek.com is a best Linux blog to learn Linux +It's FIVE years old blog +``` + +使用 `ls` 命令查看创建的文件。 + +``` +$ ls -lh daygeek4.txt +-rw-rw-r-- 1 daygeek daygeek 74 Feb 4 02:18 daygeek4.txt +``` + +使用 `cat` 命令查看文件的内容。 + +``` +$ cat daygeek4.txt +2daygeek.com is a best Linux blog to learn Linux +It's FIVE years old blog +``` + +如果你想向同一个文件中添加其他内容,使用两个连接的重定向符(`>>`)。 + +``` +$ cat >> daygeek4.txt +This website is maintained by Magesh M, It's licensed under CC BY-NC 4.0. +``` + +你可以使用 `cat` 命令查看添加的内容。 + +``` +$ cat daygeek4.txt +2daygeek.com is a best Linux blog to learn Linux +It's FIVE years old blog +This website is maintained by Magesh M, It's licensed under CC BY-NC 4.0. +``` + +### 在 Linux 上使用 vi/vim 命令创建一个文件 + +`vim` 是一个向上兼容 `vi` 的文本编辑器。它通常用来编辑所有种类的纯文本。在编辑程序时特别有用。 + +`vim` 中有很多功能可以用于编辑单个文件。 + +``` +$ vi daygeek5.txt + +2daygeek.com is a best Linux blog to learn Linux +It's FIVE years old blog +``` + +使用 `ls` 查看刚才创建的文件。 + +``` +$ ls -lh daygeek5.txt +-rw-rw-r-- 1 daygeek daygeek 75 Feb 4 02:23 daygeek5.txt +``` + +使用 `cat` 命令查看文件的内容。 + +``` +$ cat daygeek5.txt +2daygeek.com is a best Linux blog to learn Linux +It's FIVE years old blog +``` + +### 在 Linux 上使用 nano 命令创建一个文件 + +`nano` 是一个编辑器,它是一个自由版本的 `pico` 克隆。`nano` 是一个小且用户友好的编辑器。它复制了 `pico` 的外观及优点,并且是一个自由软件,它添加了 `pico` 缺乏的一系列特性,像是打开多个文件、逐行滚动、撤销/重做、语法高亮、行号等等。 + +``` +$ nano daygeek6.txt + +2daygeek.com is a best Linux blog to learn Linux +It's FIVE years old blog +This website is maintained by Magesh M, It's licensed under CC BY-NC 4.0. +``` + +使用 `ls` 命令查看创建的文件。 + +``` +$ ls -lh daygeek6.txt +-rw-rw-r-- 1 daygeek daygeek 148 Feb 4 02:26 daygeek6.txt +``` + +使用 `cat` 命令来查看一个文件的内容。 + +``` +$ cat daygeek6.txt +2daygeek.com is a best Linux blog to learn Linux +It's FIVE years old blog +This website is maintained by Magesh M, It's licensed under CC BY-NC 4.0. +``` + +### 在 Linux 上使用 head 命令创建一个文件 + +`head` 命令通常用于输出一个文件开头的一部分。它默认会打印一个文件的开头 10 行到标准输出。如果有多个文件,则每个文件前都会有一个标题,用来表示文件名。 + +``` +$ head -c 0K /dev/zero > daygeek7.txt +``` + +使用 `ls` 命令查看创建的文件。 + +``` +$ ls -lh daygeek7.txt +-rw-rw-r-- 1 daygeek daygeek 0 Feb 4 02:30 daygeek7.txt +``` + +### 在 Linux 上使用 tail 创建一个文件 + +`tail` 命令通常用来输出一个文件最后的一部分。它默认会打印每个文件的最后 10 行到标准输出。如果有多个文件,则每个文件前都会有一个标题,用来表示文件名。 + +``` +$ tail -c 0K /dev/zero > daygeek8.txt +``` + +使用 `ls` 命令查看创建的文件。 + +``` +$ ls -lh daygeek8.txt +-rw-rw-r-- 1 daygeek daygeek 0 Feb 4 02:31 daygeek8.txt +``` + +### 在 Linux 上使用 truncate 命令创建一个文件 + +`truncate` 命令通常用作将一个文件的尺寸缩小或者扩展为某个指定的尺寸。 + +``` +$ truncate -s 0K daygeek9.txt +``` + +使用 `ls` 命令检查创建的文件。 + +``` +$ ls -lh daygeek9.txt +-rw-rw-r-- 1 daygeek daygeek 0 Feb 4 02:37 daygeek9.txt +``` + +在这篇文章中,我使用这十个命令分别创建了下面的这十个文件。 + +``` +$ ls -lh daygeek* +-rw-rw-r-- 1 daygeek daygeek 0 Feb 4 02:02 daygeek1.txt +-rw-rw-r-- 1 daygeek daygeek 74 Feb 4 02:07 daygeek2.txt +-rw-rw-r-- 1 daygeek daygeek 74 Feb 4 02:15 daygeek3.txt +-rw-rw-r-- 1 daygeek daygeek 148 Feb 4 02:20 daygeek4.txt +-rw-rw-r-- 1 daygeek daygeek 75 Feb 4 02:23 daygeek5.txt +-rw-rw-r-- 1 daygeek daygeek 148 Feb 4 02:26 daygeek6.txt +-rw-rw-r-- 1 daygeek daygeek 148 Feb 4 02:32 daygeek7.txt +-rw-rw-r-- 1 daygeek daygeek 148 Feb 4 02:32 daygeek8.txt +-rw-rw-r-- 1 daygeek daygeek 148 Feb 4 02:38 daygeek9.txt +-rw-rw-r-- 1 daygeek daygeek 0 Feb 4 02:00 daygeek.txt +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-command-to-create-a-file/ + +作者:[Vinoth Kumar][a] +选题:[lujun9972][b] +译者:[dianbanjiu](https://github.com/dianbanjiu) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/vinoth/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/create-a-file-in-specific-certain-size-linux/ diff --git a/published/201902/20190207 How to determine how much memory is installed, used on Linux systems.md b/published/201902/20190207 How to determine how much memory is installed, used on Linux systems.md new file mode 100644 index 0000000000..96b474f7e4 --- /dev/null +++ b/published/201902/20190207 How to determine how much memory is installed, used on Linux systems.md @@ -0,0 +1,228 @@ +[#]: collector: (lujun9972) +[#]: translator: (leommxj) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10571-1.html) +[#]: subject: (How to determine how much memory is installed, used on Linux systems) +[#]: via: (https://www.networkworld.com/article/3336174/linux/how-much-memory-is-installed-and-being-used-on-your-linux-systems.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何在 Linux 系统中判断安装、使用了多少内存 +====== + +> 有几个命令可以报告在 Linux 系统上安装和使用了多少内存。根据你使用的命令,你可能会被细节淹没,也可能获得快速简单的答案。 + +![](https://images.idgesg.net/images/article/2019/02/memory-100787327-large.jpg) + +在 Linux 系统中有很多种方法获取有关安装了多少内存的信息及查看多少内存正在被使用。有些命令提供了大量的细节,而其他命令提供了简洁但不一定易于理解的答案。在这篇文章中,我们将介绍一些查看内存及其使用状态的有用的工具。 + +在我们开始之前,让我们先来回顾一些基础知识。物理内存和虚拟内存并不是一回事。后者包括配置为交换空间的磁盘空间。交换空间可能包括为此目的特意留出来的分区,以及在创建新的交换分区不可行时创建的用来增加可用交换空间的文件。有些 Linux 命令会提供关于两者的信息。 + +当物理内存占满时,交换空间通过提供可以用来存放内存中非活动页的磁盘空间来扩展内存。 + +`/proc/kcore` 是在内存管理中起作用的一个文件。这个文件看上去是个普通文件(虽然非常大),但它并不占用任何空间。它就像其他 `/proc` 下的文件一样是个虚拟文件。 + +``` +$ ls -l /proc/kcore +-r--------. 1 root root 140737477881856 Jan 28 12:59 /proc/kcore +``` + +有趣的是,下面查询的两个系统并没有安装相同大小的内存,但 `/proc/kcore` 的大小却是相同的。第一个系统安装了 4 GB 的内存,而第二个系统安装了 6 GB。 + +``` +system1$ ls -l /proc/kcore +-r--------. 1 root root 140737477881856 Jan 28 12:59 /proc/kcore +system2$ ls -l /proc/kcore +-r-------- 1 root root 140737477881856 Feb 5 13:00 /proc/kcore +``` + +一种不靠谱的解释说这个文件代表可用虚拟内存的大小(没准要加 4 KB),如果这样,这些系统的虚拟内存可就是 128TB 了!这个数字似乎代表了 64 位系统可以寻址多少内存,而不是当前系统有多少可用内存。在命令行中计算 128 TB 和这个文件大小加上 4 KB 很容易。 + +``` +$ expr 1024 \* 1024 \* 1024 \* 1024 \* 128 +140737488355328 +$ expr 1024 \* 1024 \* 1024 \* 1024 \* 128 + 4096 +140737488359424 +``` + +另一个用来检查内存的更人性化的命令是 `free`。它会给出一个易于理解的内存报告。 + +``` +$ free + total used free shared buff/cache available +Mem: 6102476 812244 4090752 13112 1199480 4984140 +Swap: 2097148 0 2097148 +``` + +使用 `-g` 选项,`free` 会以 GB 为单位返回结果。 + +``` +$ free -g + total used free shared buff/cache available +Mem: 5 0 3 0 1 4 +Swap: 1 0 1 +``` + +使用 `-t` 选项,`free` 会显示与无附加选项时相同的值(不要把 `-t` 选项理解成 TB),并额外在输出的底部添加一行总计数据。 + +``` +$ free -t + total used free shared buff/cache available +Mem: 6102476 812408 4090612 13112 1199456 4983984 +Swap: 2097148 0 2097148 +Total: 8199624 812408 6187760 +``` + +当然,你也可以选择同时使用两个选项。 + +``` +$ free -tg + total used free shared buff/cache available +Mem: 5 0 3 0 1 4 +Swap: 1 0 1 +Total: 7 0 5 +``` + +如果你尝试用这个报告来解释“这个系统安装了多少内存?”,你可能会感到失望。上面的报告就是在前文说的装有 6 GB 内存的系统上运行的结果。这并不是说这个结果是错的,这就是系统对其可使用的内存的看法。 + +`free` 命令也提供了每隔 X 秒刷新显示的选项(下方示例中 X 为 10)。 + +``` +$ free -s 10 + total used free shared buff/cache available +Mem: 6102476 812280 4090704 13112 1199492 4984108 +Swap: 2097148 0 2097148 + + total used free shared buff/cache available +Mem: 6102476 812260 4090712 13112 1199504 4984120 +Swap: 2097148 0 2097148 +``` + +使用 `-l` 选项,`free` 命令会提供高低内存使用信息。 + +``` +$ free -l + total used free shared buff/cache available +Mem: 6102476 812376 4090588 13112 1199512 4984000 +Low: 6102476 2011888 4090588 +High: 0 0 0 +Swap: 2097148 0 2097148 +``` + +查看内存的另一个选择是 `/proc/meminfo` 文件。像 `/proc/kcore` 一样,这也是一个虚拟文件,它可以提供关于安装或使用了多少内存以及可用内存的报告。显然,空闲内存和可用内存并不是同一回事。`MemFree` 看起来代表未使用的 RAM。`MemAvailable` 则是对于启动新程序时可使用的内存的一个估计。 + +``` +$ head -3 /proc/meminfo +MemTotal: 6102476 kB +MemFree: 4090596 kB +MemAvailable: 4984040 kB +``` + +如果只想查看内存总计,可以使用下面的命令之一: + +``` +$ awk '/MemTotal/ {print $2}' /proc/meminfo +6102476 +$ grep MemTotal /proc/meminfo +MemTotal: 6102476 kB +``` + +`DirectMap` 将内存信息分为几类。 + +``` +$ grep DirectMap /proc/meminfo +DirectMap4k: 213568 kB +DirectMap2M: 6076416 kB +``` + +`DirectMap4k` 代表被映射成标准 4 k 页的内存大小,`DirectMap2M` 则显示了被映射为 2 MB 的页的内存大小。 + +`getconf` 命令将会提供比我们大多数人想要看到的更多的信息。 + +``` +$ getconf -a | more +LINK_MAX 65000 +_POSIX_LINK_MAX 65000 +MAX_CANON 255 +_POSIX_MAX_CANON 255 +MAX_INPUT 255 +_POSIX_MAX_INPUT 255 +NAME_MAX 255 +_POSIX_NAME_MAX 255 +PATH_MAX 4096 +_POSIX_PATH_MAX 4096 +PIPE_BUF 4096 +_POSIX_PIPE_BUF 4096 +SOCK_MAXBUF +_POSIX_ASYNC_IO +_POSIX_CHOWN_RESTRICTED 1 +_POSIX_NO_TRUNC 1 +_POSIX_PRIO_IO +_POSIX_SYNC_IO +_POSIX_VDISABLE 0 +ARG_MAX 2097152 +ATEXIT_MAX 2147483647 +CHAR_BIT 8 +CHAR_MAX 127 +--More-- +``` + +使用类似下面的命令来将其输出精简为指定的内容,你会得到跟前文提到的其他命令相同的结果。 + +``` +$ getconf -a | grep PAGES | awk 'BEGIN {total = 1} {if (NR == 1 || NR == 3) total *=$NF} END {print total / 1024" kB"}' +6102476 kB +``` + +上面的命令通过将下方输出的第一行和最后一行的值相乘来计算内存。 + +``` +PAGESIZE 4096 <== +_AVPHYS_PAGES 1022511 +_PHYS_PAGES 1525619 <== +``` + +自己动手计算一下,我们就知道这个值是怎么来的了。 + +``` +$ expr 4096 \* 1525619 / 1024 +6102476 +``` + +显然值得为以上的指令之一设置个 `alias`。 + +另一个具有非常易于理解的输出的命令是 `top` 。在 `top` 输出的前五行,你可以看到一些数字显示多少内存正被使用。 + +``` +$ top +top - 15:36:38 up 8 days, 2:37, 2 users, load average: 0.00, 0.00, 0.00 +Tasks: 266 total, 1 running, 265 sleeping, 0 stopped, 0 zombie +%Cpu(s): 0.2 us, 0.4 sy, 0.0 ni, 99.4 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +MiB Mem : 3244.8 total, 377.9 free, 1826.2 used, 1040.7 buff/cache +MiB Swap: 3536.0 total, 3535.7 free, 0.3 used. 1126.1 avail Mem +``` + +最后一个命令将会以一个非常简洁的方式回答“系统安装了多少内存?”: + +``` +$ sudo dmidecode -t 17 | grep "Size.*MB" | awk '{s+=$2} END {print s / 1024 "GB"}' +6GB +``` + +取决于你想要获取多少细节,Linux 系统提供了许多用来查看系统安装内存以及使用/空闲内存的选择。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3336174/linux/how-much-memory-is-installed-and-being-used-on-your-linux-systems.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[leommxj](https://github.com/leommxj) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://www.facebook.com/NetworkWorld/ +[2]: https://www.linkedin.com/company/network-world diff --git a/published/201902/20190208 How To Install And Use PuTTY On Linux.md b/published/201902/20190208 How To Install And Use PuTTY On Linux.md new file mode 100644 index 0000000000..a4615d4b78 --- /dev/null +++ b/published/201902/20190208 How To Install And Use PuTTY On Linux.md @@ -0,0 +1,147 @@ +[#]: collector: (lujun9972) +[#]: translator: (zhs852) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10552-1.html) +[#]: subject: (How To Install And Use PuTTY On Linux) +[#]: via: (https://www.ostechnix.com/how-to-install-and-use-putty-on-linux/) +[#]: author: (SK https://www.ostechnix.com/author/sk/) + +在 Linux 中安装并使用 PuTTY +====== + +![](https://www.ostechnix.com/wp-content/uploads/2019/02/putty-720x340.png) + +PuTTY 是一个自由开源且支持包括 SSH、Telnet 和 Rlogin 在内的多种协议的 GUI 客户端。一般来说,Windows 管理员们会把 PuTTY 当成 SSH 或 Telnet 客户端来在本地 Windows 系统和远程 Linux 服务器之间建立连接。不过,PuTTY 可不是 Windows 的独占软件。它在 Linux 用户之中也是很流行的。本篇文章将会告诉你如何在 Linux 中安装并使用 PuTTY。 + +### 在 Linux 中安装 PuTTY + +PuTTY 已经包含在了许多 Linux 发行版的官方源中。举个例子,在 Arch Linux 中,我们可以通过这个命令安装 PuTTY: + +```shell +$ sudo pacman -S putty +``` + +在 Debian、Ubuntu 或是 Linux Mint 中安装它: + +```shell +$ sudo apt install putty +``` + +### 使用 PuTTY 访问远程 Linux 服务器 + +在安装完 PuTTY 之后,你可以在菜单或启动器中打开它。如果你想用终端打开它,也是可以的: + +```shell +$ putty +``` + +PuTTY 的默认界面长这个样子: + +![PuTTY 默认界面](https://www.ostechnix.com/wp-content/uploads/2019/02/putty-default-interface.png) + +如你所见,许多选项都配上了说明。在左侧面板中,你可以配置许多项目,比如: + + 1. 修改 PuTTY 登录会话选项; + 2. 修改终端模拟器控制选项,控制各个按键的功能; + 3. 控制终端响铃的声音; + 4. 启用/禁用终端的高级功能; + 5. 设定 PuTTY 窗口大小; + 6. 控制命令回滚长度(默认是 2000 行); + 7. 修改 PuTTY 窗口或光标的外观; + 8. 调整窗口边缘; + 9. 调整字体; + 10. 保存登录信息; + 11. 设置代理; + 12. 修改各协议的控制选项; + 13. 以及更多。 + +所有选项基本都有注释,相信你理解起来不难。 + +### 使用 PuTTY 访问远程 Linux 服务器 + +请在左侧面板点击 “Session” 选项卡,输入远程主机名(或 IP 地址)。然后,请选择连接类型(比如 Telnet、Rlogin 以及 SSH 等)。根据你选择的连接类型,PuTTY 会自动选择对应连接类型的默认端口号(比如 SSH 是 22、Telnet 是 23),如果你修改了默认端口号,别忘了手动把它输入到 “Port” 里。在这里,我用 SSH 连接到远程主机。在输入所有信息后,请点击 “Open”。 + +![通过 SSH 连接](http://www.ostechnix.com/wp-content/uploads/2019/02/putty-1.png) + +如果这是你首次连接到这个远程主机,PuTTY 会显示一个安全警告,问你是否信任你连接到的远程主机。点击 “Accept” 即可将远程主机的密钥加入 PuTTY 的缓存当中: + +![PuTTY 安全警告][2] + +接下来,输入远程主机的用户名和密码。然后你就成功地连接上远程主机啦。 + +![已连接上远程主机](https://www.ostechnix.com/wp-content/uploads/2019/02/putty-3.png) + +#### 使用密钥验证访问远程主机 + +一些 Linux 管理员可能在服务器上配置了密钥认证。举个例子,在用 PuTTY 访问 AMS 实例的时候,你需要指定密钥文件的位置。PuTTY 可以使用它自己的格式(`.ppk` 文件)来进行公钥验证。 + +首先输入主机名或 IP。之后,在 “Category” 选项卡中,展开 “Connection”,再展开 “SSH”,然后选择 “Auth”,之后便可选择 `.ppk` 密钥文件了。 + +![][3] + +点击 “Accept” 来关闭安全提示。然后,输入远程主机的密码(如果密钥被密码保护)来建立连接。 + +#### 保存 PuTTY 会话 + +有些时候,你可能需要多次连接到同一个远程主机,你可以保存这些会话并在之后不输入信息访问他们。 + +请输入主机名(或 IP 地址),并提供一个会话名称,然后点击 “Save”。如果你有密钥文件,请确保你在点击 “Save” 按钮之前指定它们。 + +![][4] + +现在,你可以通过选择 “Saved sessions”,然后点击 “Load”,再点击 “Open” 来启动连接。 + +#### 使用 PuTTY 安全复制客户端(pscp)来将文件传输到远程主机中 + +通常来说,Linux 用户和管理员会使用 `scp` 这个命令行工具来从本地往远程主机传输文件。不过 PuTTY 给我们提供了一个叫做 PuTTY 安全复制客户端PuTTY Secure Copy Client(简写为 `pscp`)的工具来干这个事情。如果你的本地主机运行的是 Windows,你可能需要这个工具。PSCP 在 Windows 和 Linux 下都是可用的。 + +使用这个命令来将 `file.txt` 从本地的 Arch Linux 拷贝到远程的 Ubuntu 上: + +```shell +pscp -i test.ppk file.txt sk@192.168.225.22:/home/sk/ +``` + +让我们来分析这个命令: + + * `-i test.ppk`:访问远程主机所用的密钥文件; + * `file.txt`:要拷贝到远程主机的文件; + * `sk@192.168.225.22`:远程主机的用户名与 IP; + * `/home/sk/`:目标路径。 + +要拷贝一个目录,请使用 `-r`(递归Recursive)参数: + +```shell + pscp -i test.ppk -r dir/ sk@192.168.225.22:/home/sk/ +``` + +要使用 `pscp` 传输文件,请执行以下命令: + +```shell +pscp -i test.ppk c:\documents\file.txt.txt sk@192.168.225.22:/home/sk/ +``` + +你现在应该了解了 PuTTY 是什么,知道了如何安装它和如何使用它。同时,你也学习到了如何使用 `pscp` 程序在本地和远程主机上传输文件。 + +以上便是所有了,希望这篇文章对你有帮助。 + +干杯! + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-install-and-use-putty-on-linux/ + +作者:[SK][a] +选题:[lujun9972][b] +译者:[zhs852](https://github.com/zhs852) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: http://www.ostechnix.com/wp-content/uploads/2019/02/putty-2.png +[3]: http://www.ostechnix.com/wp-content/uploads/2019/02/putty-4.png +[4]: http://www.ostechnix.com/wp-content/uploads/2019/02/putty-5.png diff --git a/published/201902/20190214 Drinking coffee with AWK.md b/published/201902/20190214 Drinking coffee with AWK.md new file mode 100644 index 0000000000..eb83412bbd --- /dev/null +++ b/published/201902/20190214 Drinking coffee with AWK.md @@ -0,0 +1,119 @@ +[#]: collector: (lujun9972) +[#]: translator: (wxy) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10555-1.html) +[#]: subject: (Drinking coffee with AWK) +[#]: via: (https://opensource.com/article/19/2/drinking-coffee-awk) +[#]: author: (Moshe Zadka https://opensource.com/users/moshez) + +用 AWK 喝咖啡 +====== +> 用一个简单的 AWK 程序跟踪你的同事喝咖啡的欠款。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o) + +以下基于一个真实的故事,虽然一些名字和细节有所改变。 + +> 很久以前,在一个遥远的地方,有一间~~庙~~(划掉)办公室。由于各种原因,这个办公室没有购买速溶咖啡。所以那个办公室的一些人聚在一起决定建立“咖啡角”。 +> +> 咖啡角的一名成员会购买一些速溶咖啡,而其他成员会付给他钱。有人喝咖啡比其他人多,所以增加了“半成员”的级别:半成员每周允许喝的咖啡限量,并可以支付其它成员支付的一半。 + +管理这事非常操心。而我刚读过《Unix 编程环境》这本书,想练习一下我的 [AWK][1] 编程技能,所以我自告奋勇创建了一个系统。 + +第 1 步:我用一个数据库来记录成员及其应支付给咖啡角的欠款。我是以 AWK 便于处理的格式记录的,其中字段用冒号分隔: + +``` +member:john:1:22 +member:jane:0.5:33 +member:pratyush:0.5:17 +member:jing:1:27 +``` + +上面的第一个字段标识了这是哪一种行(`member`)。第二个字段是成员的名字(即他们的电子邮件用户名,但没有 @ )。下一个字段是其成员级别(成员 = 1,或半会员 = 0.5)。最后一个字段是他们欠咖啡角的钱。正数表示他们欠咖啡角钱,负数表示咖啡角欠他们。 + +第 2 步:我记录了咖啡角的收入和支出: + +``` +payment:jane:33 +payment:pratyush:17 +bought:john:60 +payback:john:50 +``` + +Jane 付款 $33,Pratyush 付款 $17,John 买了价值 $60 的咖啡,而咖啡角还款给 John $50。 + +第 3 步:我准备写一些代码,用来处理成员和付款,并生成记录了新欠账的更新的成员文件。 + +``` +#!/usr/bin/env --split-string=awk -F: -f +``` + +释伴行(`#!`)需要做一些调整,我使用 `env` 命令来允许从释伴行传递多个参数:具体来说,AWK 的 `-F` 命令行参数会告诉它字段分隔符是什么。 + +AWK 程序就是一个规则序列(也可以包含函数定义,但是对于这个咖啡角应用来说不需要) + +第一条规则读取该成员文件。当我运行该命令时,我总是首先给它的是成员文件,然后是付款文件。它使用 AWK 关联数组来在 `members` 数组中记录成员级别,以及在 `debt` 数组中记录当前欠账。 + +``` +$1 == "member" { +   members[$2]=$3 +   debt[$2]=$4 +   total_members += $3 +} +``` + +第二条规则在记录付款(`payment`)时减少欠账。 + +``` +$1 == "payment" { +   debt[$2] -= $3 +} +``` + +还款(`payback`)则相反:它增加欠账。这可以优雅地支持意外地给了某人太多钱的情况。 + +``` +$1 == "payback" { +   debt[$2] += $3 +} +``` + +最复杂的部分出现在有人购买(`bought`)速溶咖啡供咖啡角使用时。它被视为付款(`payment`),并且该人的债务减少了适当的金额。接下来,它计算每个会员的费用。它根据成员的级别对所有成员进行迭代并增加欠款 + +``` +$1 == "bought" { +   debt[$2] -= $3 +   per_member = $3/total_members +   for (x in members) { +       debt[x] += per_member * members[x] +   } +} +``` + +`END` 模式很特殊:当 AWK 没有更多的数据要处理时,它会一次性执行。此时,它会使用更新的欠款数生成新的成员文件。 + +``` +END { +   for (x in members) { +       printf "%s:%s:%s\n", x, members[x], debt[x] +   } +} +``` + +再配合一个遍历成员文件,并向人们发送提醒电子邮件以支付他们的会费(积极清账)的脚本,这个系统管理咖啡角相当一段时间。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/drinking-coffee-awk + +作者:[Moshe Zadka][a] +选题:[lujun9972][b] +译者:[wxy](https://github.com/wxy) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/moshez +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/AWK diff --git a/published/201902/20190216 How To Grant And Remove Sudo Privileges To Users On Ubuntu.md b/published/201902/20190216 How To Grant And Remove Sudo Privileges To Users On Ubuntu.md new file mode 100644 index 0000000000..a53e354779 --- /dev/null +++ b/published/201902/20190216 How To Grant And Remove Sudo Privileges To Users On Ubuntu.md @@ -0,0 +1,103 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10576-1.html) +[#]: subject: (How To Grant And Remove Sudo Privileges To Users On Ubuntu) +[#]: via: (https://www.ostechnix.com/how-to-grant-and-remove-sudo-privileges-to-users-on-ubuntu/) +[#]: author: (SK https://www.ostechnix.com/author/sk/) + +如何在 Ubuntu 上为用户授予和移除 sudo 权限 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2019/02/sudo-privileges-720x340.png) + +如你所知,用户可以在 Ubuntu 系统上使用 sudo 权限执行任何管理任务。在 Linux 机器上创建新用户时,他们无法执行任何管理任务,直到你将其加入 `sudo` 组的成员。在这个简短的教程中,我们将介绍如何将普通用户添加到 `sudo` 组以及移除给定的权限,使其成为普通用户。 + +### 在 Linux 上向普通用户授予 sudo 权限 + +通常,我们使用 `adduser` 命令创建新用户,如下所示。 + +``` +$ sudo adduser ostechnix +``` + +如果你希望新创建的用户使用 `sudo` 执行管理任务,只需使用以下命令将它添加到 `sudo` 组: + +``` +$ sudo usermod -a -G sudo hduser +``` + +上面的命令将使名为 `ostechnix` 的用户成为 `sudo` 组的成员。 + +你也可以使用此命令将用户添加到 `sudo` 组。 + +``` +$ sudo adduser ostechnix sudo +``` + +现在,注销并以新用户身份登录,以使此更改生效。此时用户已成为管理用户。 + +要验证它,只需在任何命令中使用 `sudo` 作为前缀。 + +``` +$ sudo mkdir /test +[sudo] password for ostechnix: +``` + +### 移除用户的 sudo 权限 + +有时,你可能希望移除特定用户的 `sudo` 权限,而不用在 Linux 中删除它。要将任何用户设为普通用户,只需将其从 `sudo` 组中删除即可。 + +比如说如果要从 `sudo` 组中删除名为 `ostechnix` 的用户,只需运行: + +``` +$ sudo deluser ostechnix sudo +``` + +示例输出: + +``` +Removing user `ostechnix' from group `sudo' ... +Done. +``` + +此命令仅从 `sudo` 组中删除用户 `ostechnix`,但不会永久地从系统中删除用户。现在,它成为了普通用户,无法像 `sudo` 用户那样执行任何管理任务。 + +此外,你可以使用以下命令撤消用户的 `sudo` 访问权限: + +``` +$ sudo gpasswd -d ostechnix sudo +``` + +从 `sudo` 组中删除用户时请小心。不要从 `sudo` 组中删除真正的管理员。 + +使用命令验证用户 `ostechnix` 是否已从 `sudo` 组中删除: + +``` +$ sudo -l -U ostechnix +User ostechnix is not allowed to run sudo on ubuntuserver. +``` + +是的,用户 `ostechnix` 已从 `sudo` 组中删除,他无法执行任何管理任务。 + +从 `sudo` 组中删除用户时请小心。如果你的系统上只有一个 `sudo` 用户,并且你将他从 `sudo` 组中删除了,那么就无法执行任何管理操作,例如在系统上安装、删除和更新程序。所以,请小心。在我们的下一篇教程中,我们将解释如何恢复用户的 `sudo` 权限。 + +就是这些了。希望这篇文章有用。还有更多好东西。敬请期待! + +干杯! + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-grant-and-remove-sudo-privileges-to-users-on-ubuntu/ + +作者:[SK][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 diff --git a/published/201902/20190219 3 tools for viewing files at the command line.md b/published/201902/20190219 3 tools for viewing files at the command line.md new file mode 100644 index 0000000000..eb975657c2 --- /dev/null +++ b/published/201902/20190219 3 tools for viewing files at the command line.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10573-1.html) +[#]: subject: (3 tools for viewing files at the command line) +[#]: via: (https://opensource.com/article/19/2/view-files-command-line) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) + +在命令行查看文件的 3 个工具 +====== + +> 看一下 `less`、Antiword 和 `odt2xt` 这三个实用程序,它们都可以在终端中查看文件。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg) + +我常说,你不需要使用命令行也可以高效使用 Linux —— 我知道许多 Linux 用户从不打开终端窗口,并且也用的挺好。然而,即使我不认为自己是一名技术人员,我也会在命令行上花费大约 20% 的计算时间,包括操作文件、处理文本和使用实用程序。 + +我经常在终端窗口中做的一件事是查看文件,无论是文本还是需要用到文字处理器的文件。有时使用命令行实用程序比启动文本编辑器或文字处理器更容易。 + +下面是我在命令行中用来查看文件的三个实用程序。 + +### less + +[less][1] 的美妙之处在于它易于使用,它将你正在查看的文件分解为块(或页面),这使得它们更易于阅读。你可以使用它在命令行查看文本文件,例如 README、HTML 文件、LaTeX 文件或其他任何纯文本文件。我在[上一篇文章][2]中介绍了 `less`。 + +要使用 `less`,只需输入: + +``` +less file_name +``` + +![](https://opensource.com/sites/default/files/uploads/less.png) + +通过按键盘上的空格键或 `PgDn` 键向下滚动文件,按 `PgUp` 键向上移动文件。要停止查看文件,按键盘上的 `Q` 键。 + +### Antiword + +[Antiword][3] 是一个很好地实用小程序,你可以使用它将 Word 文档转换为纯文本。只要你想,还可以将它们转换为 [PostScript][4] 或 [PDF][5]。在本文中,让我们继续使用文本转换。 + +Antiword 可以读取和转换 Word 2.0 到 2003 版本创建的文件(LCTT 译注:此处疑为 Word 2000,因为 Word 2.0 for DOS 发布于 1984 年,而 WinWord 2.0 发布于 1991 年,都似乎太老了)。它不能读取 DOCX 文件 —— 如果你尝试这样做,Antiword 会显示一条错误消息,表明你尝试读取的是一个 ZIP 文件。这在技术上说是正确的,但仍然令人沮丧。 + +要使用 Antiword 查看 Word 文档,输入以下命令: + +``` +antiword file_name.doc +``` + +Antiword 将文档转换为文本并显示在终端窗口中。不幸的是,它不能在终端中将文档分解成页面。不过,你可以将 Antiword 的输出重定向到 `less` 或 [more][6] 之类的实用程序,一遍对其进行分页。通过输入以下命令来执行此操作: + +``` +antiword file_name.doc | less +``` + +如果你是命令行的新手,那么我告诉你 `|` 称为管道。这就是重定向。 + +![](https://opensource.com/sites/default/files/uploads/antiword.png) + +### odt2txt + +作为一个优秀的开源公民,你会希望尽可能多地使用开放格式。对于你的文字处理需求,你可能需要处理 [ODT][7] 文件(由诸如 LibreOffice Writer 和 AbiWord 等文字处理器使用)而不是 Word 文件。即使没有,也可能会遇到 ODT 文件。而且,即使你的计算机上没有安装 Writer 或 AbiWord,也很容易在命令行中查看它们。 + +怎样做呢?用一个名叫 [odt2txt][8] 的实用小程序。正如你猜到的那样,`odt2txt` 将 ODT 文件转换为纯文本。要使用它,运行以下命令: + +``` +odt2txt file_name.odt +``` + +与 Antiword 一样,`odt2txt` 将文档转换为文本并在终端窗口中显示。和 Antiword 一样,它不会对文档进行分页。但是,你也可以使用以下命令将 `odt2txt` 的输出管道传输到 `less` 或 `more` 这样的实用程序中: + +``` +odt2txt file_name.odt | more +``` + +![](https://opensource.com/sites/default/files/uploads/odt2txt.png) + +你有一个最喜欢的在命令行中查看文件的实用程序吗?欢迎留下评论与社区分享。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/view-files-command-line + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[b]: https://github.com/lujun9972 +[1]: https://www.gnu.org/software/less/ +[2]: https://opensource.com/article/18/4/using-less-view-text-files-command-line +[3]: http://www.winfield.demon.nl/ +[4]: http://en.wikipedia.org/wiki/PostScript +[5]: http://en.wikipedia.org/wiki/Portable_Document_Format +[6]: https://opensource.com/article/19/1/more-text-files-linux +[7]: http://en.wikipedia.org/wiki/OpenDocument +[8]: https://github.com/dstosberg/odt2txt diff --git a/published/201902/20190219 How to List Installed Packages on Ubuntu and Debian -Quick Tip.md b/published/201902/20190219 How to List Installed Packages on Ubuntu and Debian -Quick Tip.md new file mode 100644 index 0000000000..2eec9eb896 --- /dev/null +++ b/published/201902/20190219 How to List Installed Packages on Ubuntu and Debian -Quick Tip.md @@ -0,0 +1,200 @@ +[#]: collector: (lujun9972) +[#]: translator: (guevaraya) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10562-1.html) +[#]: subject: (How to List Installed Packages on Ubuntu and Debian [Quick Tip]) +[#]: via: (https://itsfoss.com/list-installed-packages-ubuntu) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +如何列出 Ubuntu 和 Debian 上已安装的软件包 +====== + +当你安装了 [Ubuntu 并想好好用一用][1]。但在将来某个时候,你肯定会遇到忘记曾经安装了那些软件包。 + +这个是完全正常。没有人要求你把系统里所有已安装的软件包都记住。但是问题是,如何才能知道已经安装了哪些软件包?如何查看安装过的软件包呢? + +### 列出 Ubuntu 和 Debian 上已安装的软件包 + +![列出已安装的软件包][2] + +如果你经常用 [apt 命令][3],你可能觉得会有个命令像 `apt` 一样可以列出已安装的软件包。不算全错。 + +[apt-get 命令][4] 没有类似列出已安装软件包的简单的选项,但是 `apt` 有一个这样的命令: + +``` +apt list --installed +``` + +这个会显示使用 `apt` 命令安装的所有的软件包。同时也会包含由于依赖而被安装的软件包。也就是说不仅会包含你曾经安装的程序,而且会包含大量库文件和间接安装的软件包。 + +![用 atp 命令列出显示已安装的软件包][5] + +*用 atp 命令列出显示已安装的软件包* + +由于列出出来的已安装的软件包太多,用 `grep` 过滤特定的软件包是一个比较好的办法。 + +``` +apt list --installed | grep program_name +``` + +如上命令也可以检索出使用 .deb 软件包文件安装的软件。是不是很酷? + +如果你阅读过 [apt 与 apt-get 对比][7]的文章,你可能已经知道 `apt` 和 `apt-get` 命令都是基于 [dpkg][8]。也就是说用 `dpkg` 命令可以列出 Debian 系统的所有已经安装的软件包。 + +``` +dpkg-query -l +``` + +你可以用 `grep` 命令检索指定的软件包。 + +![用 dpkg 命令列出显示已经安装的软件包][9]! + +*用 dpkg 命令列出显示已经安装的软件包* + +现在你可以搞定列出 Debian 的软件包管理器安装的应用了。那 Snap 和 Flatpak 这个两种应用呢?如何列出它们?因为它们不能被 `apt` 和 `dpkg` 访问。 + +显示系统里所有已经安装的 [Snap 软件包][10],可以这个命令: + +``` +snap list +``` + +Snap 可以用绿色勾号标出哪个应用来自经过认证的发布者。 + +![列出已经安装的 Snap 软件包][11] + +*列出已经安装的 Snap 软件包* + +显示系统里所有已安装的 [Flatpak 软件包][12],可以用这个命令: + +``` +flatpak list +``` + +让我来个汇总: + + +用 `apt` 命令显示已安装软件包: + +``` +apt list –installed +``` + +用 `dpkg` 命令显示已安装软件包: + +``` +dpkg-query -l +``` + +列出系统里 Snap 已安装软件包: + +``` +snap list +``` + +列出系统里 Flatpak 已安装软件包: + +``` +flatpak list +``` + +### 显示最近安装的软件包 + +现在你已经看过以字母顺序列出的已经安装软件包了。如何显示最近已经安装的软件包? + +幸运的是,Linux 系统保存了所有发生事件的日志。你可以参考最近安装软件包的日志。 + +有两个方法可以来做。用 `dpkg` 命令的日志或者 `apt` 命令的日志。 + +你仅仅需要用 `grep` 命令过滤已经安装的软件包日志。 + +``` +grep " install " /var/log/dpkg.log +``` + +这会显示所有的软件安装包,其中包括最近安装的过程中所依赖的软件包。 + +``` +2019-02-12 12:41:42 install ubuntu-make:all 16.11.1ubuntu1 +2019-02-13 21:03:02 install xdg-desktop-portal:amd64 0.11-1 +2019-02-13 21:03:02 install libostree-1-1:amd64 2018.8-0ubuntu0.1 +2019-02-13 21:03:02 install flatpak:amd64 1.0.6-0ubuntu0.1 +2019-02-13 21:03:02 install xdg-desktop-portal-gtk:amd64 0.11-1 +2019-02-14 11:49:10 install qml-module-qtquick-window2:amd64 5.9.5-0ubuntu1.1 +2019-02-14 11:49:10 install qml-module-qtquick2:amd64 5.9.5-0ubuntu1.1 +2019-02-14 11:49:10 install qml-module-qtgraphicaleffects:amd64 5.9.5-0ubuntu1 +``` + +你也可以查看 `apt` 历史命令日志。这个仅会显示用 `apt` 命令安装的的程序。但不会显示被依赖安装的软件包,详细的日志在日志里可以看到。有时你只是想看看对吧? + +``` +grep " install " /var/log/apt/history.log +``` + +具体的显示如下: + +``` +Commandline: apt install pinta +Commandline: apt install pinta +Commandline: apt install tmux +Commandline: apt install terminator +Commandline: apt install moreutils +Commandline: apt install ubuntu-make +Commandline: apt install flatpak +Commandline: apt install cool-retro-term +Commandline: apt install ubuntu-software +``` + +![显示最近已安装的软件包][13] + +*显示最近已安装的软件包* + +`apt` 的历史日志非常有用。因为他显示了什么时候执行了 `apt` 命令,哪个用户执行的命令以及安装的软件包名。 + +### 小技巧:在软件中心显示已安装的程序包名 + +如果你觉得终端和命令行交互不友好,还有一个方法可以查看系统的程序名。 + +可以打开软件中心,然后点击已安装标签。你可以看到系统上已经安装的程序包名 + +![Ubuntu 软件中心显示已安装的软件包][14] + +*在软件中心显示已安装的软件包* + +这个不会显示库和其他命令行的东西,有可能你也不想看到它们,因为你的大量交互都是在 GUI。此外,你也可以用 Synaptic 软件包管理器。 + +### 结束语 + +我希望这个简易的教程可以帮你查看 Ubuntu 和基于 Debian 的发行版的已安装软件包。 + +如果你对本文有什么问题或建议,请在下面留言。 + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/list-installed-packages-ubuntu + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[guevaraya](https://github.com/guevaraya) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/getting-started-with-ubuntu/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/list-installed-packages.png?resize=800%2C450&ssl=1 +[3]: https://itsfoss.com/apt-command-guide/ +[4]: https://itsfoss.com/apt-get-linux-guide/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/list-installed-packages-in-ubuntu-with-apt.png?resize=800%2C407&ssl=1 +[6]: https://itsfoss.com/install-deb-files-ubuntu/ +[7]: https://itsfoss.com/apt-vs-apt-get-difference/ +[8]: https://wiki.debian.org/dpkg +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/list-installed-packages-with-dpkg.png?ssl=1 +[10]: https://itsfoss.com/use-snap-packages-ubuntu-16-04/ +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/list-installed-snap-packages.png?ssl=1 +[12]: https://itsfoss.com/flatpak-guide/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/apt-list-recently-installed-packages.png?resize=800%2C187&ssl=1 +[14]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/installed-software-ubuntu.png?ssl=1 +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/list-installed-packages.png?fit=800%2C450&ssl=1 diff --git a/published/20190206 And, Ampersand, and - in Linux.md b/published/20190206 And, Ampersand, and - in Linux.md new file mode 100644 index 0000000000..5c85abc111 --- /dev/null +++ b/published/20190206 And, Ampersand, and - in Linux.md @@ -0,0 +1,196 @@ +[#]: collector: (lujun9972) +[#]: translator: (HankChow) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10587-1.html) +[#]: subject: (And, Ampersand, and & in Linux) +[#]: via: (https://www.linux.com/blog/learn/2019/2/and-ampersand-and-linux) +[#]: author: (Paul Brown https://www.linux.com/users/bro66) + +Linux 中的 & +====== + +> 这篇文章将了解一下 & 符号及它在 Linux 命令行中的各种用法。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ampersand.png?itok=7GdFO36Y) + +如果阅读过我之前的三篇文章([1][1]、[2][2]、[3][3]),你会觉得掌握连接各个命令之间的连接符号用法也是很重要的。实际上,命令的用法并不难,例如 `mkdir`、`touch` 和 `find` 也分别可以简单概括为“建立新目录”、“更新文件”和“在目录树中查找文件”而已。 + +但如果要理解 + +``` +mkdir test_dir 2>/dev/null || touch images.txt && find . -iname "*jpg" > backup/dir/images.txt & +``` + +这一串命令的目的,以及为什么要这样写,就没有这么简单了。 + +关键之处就在于命令之间的连接符号。掌握了这些符号的用法,不仅可以让你更好理解整体的工作原理,还可以让你知道如何将不同的命令有效地结合起来,提高工作效率。 + +在这一篇文章和接下来的文章中,我会介绍如何使用 `&` 号和管道符号(`|`)在不同场景下的使用方法。 + +### 幕后工作 + +我来举一个简单的例子,看看如何使用 `&` 号将下面这个命令放到后台运行: + +``` +cp -R original/dir/ backup/dir/ +``` + +这个命令的目的是将 `original/dir/` 的内容递归地复制到 `backup/dir/` 中。虽然看起来很简单,但是如果原目录里面的文件太大,在执行过程中终端就会一直被卡住。 + +所以,可以在命令的末尾加上一个 `&` 号,将这个任务放到后台去执行: + +``` +cp -R original/dir/ backup/dir/ & +``` + +任务被放到后台执行之后,就可以立即继续在同一个终端上工作了,甚至关闭终端也不影响这个任务的正常执行。需要注意的是,如果要求这个任务输出内容到标准输出中(例如 `echo` 或 `ls`),即使使用了 `&`,也会等待这些输出任务在前台运行完毕。 + +当使用 `&` 将一个进程放置到后台运行的时候,Bash 会提示这个进程的进程 ID。在 Linux 系统中运行的每一个进程都有一个唯一的进程 ID,你可以使用进程 ID 来暂停、恢复或者终止对应的进程,因此进程 ID 是非常重要的。 + +这个时候,只要你还停留在启动进程的终端当中,就可以使用以下几个命令来对管理后台进程: + + * `jobs` 命令可以显示当前终端正在运行的进程,包括前台运行和后台运行的进程。它对每个正在执行中的进程任务分配了一个序号(这个序号不是进程 ID),可以使用这些序号来引用各个进程任务。 + + ``` + $ jobs +[1]- Running cp -i -R original/dir/* backup/dir/ & +[2]+ Running find . -iname "*jpg" > backup/dir/images.txt & +``` + * `fg` 命令可以将后台运行的进程任务放到前台运行,这样可以比较方便地进行交互。根据 `jobs` 命令提供的进程任务序号,再在前面加上 `%` 符号,就可以把相应的进程任务放到前台运行。 + + ``` + $ fg %1 # 将上面序号为 1 的 cp 任务放到前台运行 +cp -i -R original/dir/* backup/dir/ +``` + 如果这个进程任务是暂停状态,`fg` 命令会将它启动起来。 + * 使用 `ctrl+z` 组合键可以将前台运行的任务暂停,仅仅是暂停,而不是将任务终止。当使用 `fg` 或者 `bg` 命令将任务重新启动起来的时候,任务会从被暂停的位置开始执行。但 [sleep][4] 命令是一个特例,`sleep` 任务被暂停的时间会计算在 `sleep` 时间之内。因为 `sleep` 命令依据的是系统时钟的时间,而不是实际运行的时间。也就是说,如果运行了 `sleep 30`,然后将任务暂停 30 秒以上,那么任务恢复执行的时候会立即终止并退出。 + * `bg` 命令会将任务放置到后台执行,如果任务是暂停状态,也会被启动起来。 + + ``` + $ bg %1 +[1]+ cp -i -R original/dir/* backup/dir/ & +``` + +如上所述,以上几个命令只能在同一个终端里才能使用。如果启动进程任务的终端被关闭了,或者切换到了另一个终端,以上几个命令就无法使用了。 + +如果要在另一个终端管理后台进程,就需要其它工具了。例如可以使用 [kill][5] 命令从另一个终端终止某个进程: + +``` +kill -s STOP +``` + +这里的 PID 就是使用 `&` 将进程放到后台时 Bash 显示的那个进程 ID。如果你当时没有把进程 ID 记录下来,也可以使用 `ps` 命令(代表 process)来获取所有正在运行的进程的进程 ID,就像这样: + +``` +ps | grep cp +``` + +执行以后会显示出包含 `cp` 字符串的所有进程,例如上面例子中的 `cp` 进程。同时还会显示出对应的进程 ID: + +``` +$ ps | grep cp +14444 pts/3 00:00:13 cp +``` + +在这个例子中,进程 ID 是 14444,因此可以使用以下命令来暂停这个后台进程: + +``` +kill -s STOP 14444 +``` + +注意,这里的 `STOP` 等同于前面提到的 `ctrl+z` 组合键的效果,也就是仅仅把进程暂停掉。 + +如果想要把暂停了的进程启动起来,可以对进程发出 `CONT` 信号: + +``` +kill -s CONT 14444 +``` + +这个给出一个[可以向进程发出的常用信号][6]列表。如果想要终止一个进程,可以发送 `TERM` 信号: + +``` +kill -s TERM 14444 +``` + +如果进程不响应 `TERM` 信号并拒绝退出,还可以发送 `KILL` 信号强制终止进程: + +``` +kill -s KILL 14444 +``` + +强制终止进程可能会有一定的风险,但如果遇到进程无节制消耗资源的情况,这样的信号还是能够派上用场的。 + +另外,如果你不确定进程 ID 是否正确,可以在 `ps` 命令中加上 `x` 参数: + +``` +$ ps x| grep cp +14444 pts/3 D 0:14 cp -i -R original/dir/Hols_2014.mp4 + original/dir/Hols_2015.mp4 original/dir/Hols_2016.mp4 + original/dir/Hols_2017.mp4 original/dir/Hols_2018.mp4 backup/dir/ +``` + +这样就可以看到是不是你需要的进程 ID 了。 + +最后介绍一个将 `ps` 和 `grep` 结合到一起的命令: + +``` +$ pgrep cp +8 +18 +19 +26 +33 +40 +47 +54 +61 +72 +88 +96 +136 +339 +6680 +13735 +14444 +``` + +`pgrep` 可以直接将带有字符串 `cp` 的进程的进程 ID 显示出来。 + +可以加上一些参数让它的输出更清晰: + +``` +$ pgrep -lx cp +14444 cp +``` + +在这里,`-l` 参数会让 `pgrep` 将进程的名称显示出来,`-x` 参数则是让 `pgrep` 完全匹配 `cp` 这个命令。如果还想了解这个命令的更多细节,可以尝试运行 `pgrep -ax`。 + +### 总结 + +在命令的末尾加上 `&` 可以让我们理解前台进程和后台进程的概念,以及如何管理这些进程。 + +在 UNIX/Linux 术语中,在后台运行的进程被称为守护进程daemon。如果你曾经听说过这个词,那你现在应该知道它的意义了。 + +和其它符号一样,`&` 在命令行中还有很多别的用法。在下一篇文章中,我会更详细地介绍。 + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2019/2/and-ampersand-and-linux + +作者:[Paul Brown][a] +选题:[lujun9972][b] +译者:[HankChow](https://github.com/HankChow) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/bro66 +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10465-1.html +[2]: https://linux.cn/article-10502-1.html +[3]: https://linux.cn/article-10529-1.html +[4]: https://ss64.com/bash/sleep.html +[5]: https://bash.cyberciti.biz/guide/Sending_signal_to_Processes +[6]: https://www.computerhope.com/unix/signals.htm + diff --git a/published/20190206 Getting started with Vim visual mode.md b/published/20190206 Getting started with Vim visual mode.md new file mode 100644 index 0000000000..fff2bafe1a --- /dev/null +++ b/published/20190206 Getting started with Vim visual mode.md @@ -0,0 +1,120 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10589-1.html) +[#]: subject: (Getting started with Vim visual mode) +[#]: via: (https://opensource.com/article/19/2/getting-started-vim-visual-mode) +[#]: author: (Susan Lauber https://opensource.com/users/susanlauber) + +Vim 可视化模式入门 +====== + +> 可视化模式使得在 Vim 中高亮显示和操作文本变得更加容易。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_code_keyboard_orange_hands.png?itok=G6tJ_64Y) + +Ansible 剧本文件是 YAML 格式的文本文件,经常与它们打交道的人通过他们偏爱的编辑器和扩展插件以使格式化更容易。 + +当我使用大多数 Linux 发行版中提供的默认编辑器来教学 Ansible 时,我经常使用 Vim 的可视化模式。它可以让我在屏幕上高亮显示我的操作 —— 我要编辑什么以及我正在做的文本处理任务,以便使我的学生更容易学习。 + +### Vim 的可视化模式 + +使用 Vim 编辑文本时,可视化模式对于识别要操作的文本块非常有用。 + +Vim 的可视模式有三个模式:字符、行和块。进入每种模式的按键是: + + * 字符模式: `v` (小写) + * 行模式: `V` (大写) + * 块模式: `Ctrl+v` + +下面是使用每种模式简化工作的一些方法。 + +### 字符模式 + +字符模式可以高亮显示段落中的一个句子或句子中的一个短语,然后,可以使用任何 Vim 编辑命令删除、复制、更改/修改可视化模式识别的文本。 + +#### 移动一个句子 + +要将句子从一个地方移动到另一个地方,首先打开文件并将光标移动到要移动的句子的第一个字符。 + +![](https://opensource.com/sites/default/files/uploads/vim-visual-char1.png) + + * 按下 `v` 键进入可视化字符模式。单词 `VISUAL` 将出现在屏幕底部。 + * 使用箭头来高亮显示所需的文本。你可以使用其他导航命令,例如 `w` 高亮显示至下一个单词的开头,`$` 来包含该行的其余部分。 + * 在文本高亮显示后,按下 `d` 删除文本。 + * 如果你删除得太多或不够,按下 `u` 撤销并重新开始。 + * 将光标移动到新位置,然后按 `p` 粘贴文本。 + +#### 改变一个短语 + +你还可以高亮显示要替换的一段文本。 + +![](https://opensource.com/sites/default/files/uploads/vim-visual-char2.png) + + * 将光标放在要更改的第一个字符处。 + * 按下 `v` 进入可视化字符模式。 + * 使用导航命令(如箭头键)高亮显示该部分。 + * 按下 `c` 可更改高亮显示的文本。 + * 高亮显示的文本将消失,你将处于插入模式,你可以在其中添加新文本。 + * 输入新文本后,按下 `Esc` 返回命令模式并保存你的工作。 + +![](https://opensource.com/sites/default/files/uploads/vim-visual-char3.png) + +### 行模式 + +使用 Ansible 剧本时,任务的顺序很重要。使用可视化行模式将 Ansible 任务移动到该剧本文件中的其他位置。 + +#### 操纵多行文本 + +![](https://opensource.com/sites/default/files/uploads/vim-visual-line1.png) + + * 将光标放在要操作的文本的第一行或最后一行的任何位置。 + * 按下 `Shift+V` 进入行模式。单词 `VISUAL LINE` 将出现在屏幕底部。 + * 使用导航命令(如箭头键)高亮显示多行文本。 + * 高亮显示所需文本后,使用命令来操作它。按下 `d` 删除,然后将光标移动到新位置,按下 `p` 粘贴文本。 + * 如果要复制该 Ansible 任务,可以使用 `y`(yank)来代替 `d`(delete)。 + +#### 缩进一组行 + +使用 Ansible 剧本或 YAML 文件时,缩进很重要。高亮显示的块可以使用 `>` 和 `<` 键向右或向左移动。 + +![](https://opensource.com/sites/default/files/uploads/vim-visual-line2.png) + + * 按下 `>` 增加所有行的缩进。 + * 按下 `<` 减少所有行的缩进。 + +尝试其他 Vim 命令将它们应用于高亮显示的文本。 + +### 块模式 + +可视化块模式对于操作特定的表格数据文件非常有用,但它作为验证 Ansible 剧本文件缩进的工具也很有帮助。 + +Ansible 任务是个项目列表,在 YAML 中,每个列表项都以一个破折号跟上一个空格开头。破折号必须在同一列中对齐,以达到相同的缩进级别。仅凭肉眼很难看出这一点。缩进 Ansible 任务中的其他行也很重要。 + +#### 验证任务列表缩进相同 + +![](https://opensource.com/sites/default/files/uploads/vim-visual-block1.png) + + * 将光标放在列表项的第一个字符上。 + * 按下 `Ctrl+v` 进入可视化块模式。单词 `VISUAL BLOCK` 将出现在屏幕底部。 + * 使用箭头键高亮显示单个字符列。你可以验证每个任务的缩进量是否相同。 + * 使用箭头键向右或向左展开块,以检查其它缩进是否正确。 + +![](https://opensource.com/sites/default/files/uploads/vim-visual-block2.png) + +尽管我对其它 Vim 编辑快捷方式很熟悉,但我仍然喜欢使用可视化模式来整理我想要出来处理的文本。当我在讲演过程中演示其它概念时,我的学生将会在这个“对他们而言很新”的文本编辑器中看到一个可以高亮文本并可以点击删除的工具。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/getting-started-vim-visual-mode + +作者:[Susan Lauber][a] +选题:[lujun9972][b] +译者:[MjSeven](https://github.com/MjSeven) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/susanlauber +[b]: https://github.com/lujun9972 diff --git a/published/20190208 7 steps for hunting down Python code bugs.md b/published/20190208 7 steps for hunting down Python code bugs.md new file mode 100644 index 0000000000..1d89b8fd2d --- /dev/null +++ b/published/20190208 7 steps for hunting down Python code bugs.md @@ -0,0 +1,116 @@ +[#]: collector: (lujun9972) +[#]: translator: (LazyWolfLin) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10603-1.html) +[#]: subject: (7 steps for hunting down Python code bugs) +[#]: via: (https://opensource.com/article/19/2/steps-hunting-code-python-bugs) +[#]: author: (Maria Mckinley https://opensource.com/users/parody) + +Python 七步捉虫法 +====== + +> 了解一些技巧助你减少代码查错时间。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bug-insect-butterfly-diversity-inclusion-2.png?itok=TcC9eews) + +在周五的下午三点钟(为什么是这个时间?因为事情总会在周五下午三点钟发生),你收到一条通知,客户发现你的软件出现一个错误。在有了初步的怀疑后,你联系运维,查看你的软件日志以了解发生了什么,因为你记得收到过日志已经搬家了的通知。 + +结果这些日志被转移到了你获取不到的地方,但它们正在导入到一个网页应用中——所以到时候你可以用这个漂亮的应用来检索日志,但是,这个应用现在还没完成。这个应用预计会在几天内完成。我知道,你觉得这完全不切实际。然而并不是,日志或者日志消息似乎经常在错误的时间消失不见。在我们开始查错前,一个忠告:经常检查你的日志以确保它们还在你认为它们应该在的地方,并记录你认为它们应该记的东西。当你不注意的时候,这些东西往往会发生令人惊讶的变化。 + +好的,你找到了日志或者尝试了呼叫运维人员,而客户确实发现了一个错误。甚至你可能认为你已经知道错误在哪儿。 + +你立即打开你认为可能有问题的文件并开始查错。 + +### 1、先不要碰你的代码 + +阅读代码,你甚至可能会想到该阅读哪些部分。但是在开始搞乱你的代码前,请重现导致错误的调用并把它变成一个测试。这将是一个集成测试,因为你可能还有其他疑问,目前你还不能准确地知道问题在哪儿。 + +确保这个测试结果是失败的。这很重要,因为有时你的测试不能重现失败的调用,尤其是你使用了可以混淆测试的 web 或者其他框架。很多东西可能被存储在变量中,但遗憾的是,只通过观察测试,你在测试里调用的东西并不总是明显可见的。当我尝试着重现这个失败的调用时,我并不是说我要创建一个可以通过的测试,但是,好吧,我确实是创建了一个测试,但我不认为这特别不寻常。 + +> 从自己的错误中吸取教训。 + +### 2、编写错误的测试 + +现在,你有了一个失败的测试,或者可能是一个带有错误的测试,那么是时候解决问题了。但是在你开干之前,让我们先检查下调用栈,因为这样可以更轻松地解决问题。 + +调用栈包括你已经启动但尚未完成地所有任务。因此,比如你正在烤蛋糕并准备往面糊里加面粉,那你的调用栈将是: + +* 做蛋糕 +* 打面糊 +* 加面粉 + +你已经开始做蛋糕,开始打面糊,而你现在正在加面粉。往锅底抹油不在这个列表中,因为你已经完成了,而做糖霜不在这个列表上因为你还没开始做。 + +如果你对调用栈不清楚,我强烈建议你使用 [Python Tutor][1],它能帮你在执行代码时观察调用栈。 + +现在,如果你的 Python 程序出现了错误, Python 解释器会帮你打印出当前调用栈。这意味着无论那一时刻程序在做什么,很明显错误发生在调用栈的底部。 + +### 3、始终先检查调用栈底部 + +在栈底你不仅能看到发生了哪个错误,而且通常可以在调用栈的最后一行发现问题。如果栈底对你没有帮助,而你的代码还没有经过代码分析,那么使用代码分析是非常有用的。我推荐 pylint 或者 flake8。通常情况下,它会指出我一直忽略的错误的地方。 + +如果错误看起来很迷惑,你下一步行动可能是用 Google 搜索它。如果你搜索的内容不包含你的代码的相关信息,如变量名、文件等,那你将获得更好的搜索结果。如果你使用的是 Python 3(你应该使用它),那么搜索内容包含 Python 3 是有帮助的,否则 Python 2 的解决方案往往会占据大多数。 + +很久以前,开发者需要在没有搜索引擎的帮助下解决问题。那是一段黑暗时光。充分利用你可以使用的所有工具。 + +不幸的是,有时候问题发生在更早阶段,但只有在调用栈底部执行的地方才显现出来。就像当蛋糕没有膨胀时,忘记加发酵粉的事才被发现。 + +那就该检查整个调用栈。问题更可能在你的代码而不是 Python 标准库或者第三方包,所以先检查调用栈内你的代码。另外,在你的代码中放置断点通常会更容易检查代码。在调用栈的代码中放置断点,然后看看周围是否如你预期。 + +“但是,玛丽,”我听到你说,“如果我有一个调用栈,那这些都是有帮助的,但我只有一个失败的测试。我该从哪里开始?” + +pdb,一个 Python 调试器。 + +找到你代码里会被这个调用命中的地方。你应该能够找到至少一个这样的地方。在那里打上一个 pdb 的断点。 + +#### 一句题外话 + +为什么不使用 `print` 语句呢?我曾经依赖于 `print` 语句。有时候,它们仍然很方便。但当我开始处理复杂的代码库,尤其是有网络调用的代码库,`print` 语句就变得太慢了。我最终在各种地方都加上了 `print` 语句,但我没法追踪它们的位置和原因,而且变得更复杂了。但是主要使用 pdb 还有一个更重要的原因。假设你添加一条 `print` 语句去发现错误问题,而且 `print` 语句必须早于错误出现的地方。但是,看看你放 `print` 语句的函数,你不知道你的代码是怎么执行到那个位置的。查看代码是寻找调用路径的好方法,但看你以前写的代码是恐怖的。是的,我会用 `grep` 处理我的代码库以寻找调用函数的地方,但这会变得乏味,而且搜索一个通用函数时并不能缩小搜索范围。pdb 就变得非常有用。 + +你遵循我的建议,打上 pdb 断点并运行你的测试。然而测试再次失败,但是没有任何一个断点被命中。留着你的断点,并运行测试套件中一个同这个失败的测试非常相似的测试。如果你有个不错的测试套件,你应该能够找到一个这样的测试。它会命中了你认为你的失败测试应该命中的代码。运行这个测试,然后当它运行到你的断点,按下 `w` 并检查调用栈。如果你不知道如何查看因为其他调用而变得混乱的调用栈,那么在调用栈的中间找到属于你的代码,并在堆栈中该代码的上一行放置一个断点。再试一次新的测试。如果仍然没命中断点,那么继续,向上追踪调用栈并找出你的调用在哪里脱轨了。如果你一直没有命中断点,最后到了追踪的顶部,那么恭喜你,你发现了问题:你的应用程序名称拼写错了。 + +> 没有经验,小白,一点都没有经验。 + +### 4、修改代码 + +如果你仍觉得迷惑,在你稍微改变了一些的地方尝试新的测试。你能让新的测试跑起来么?有什么是不同的呢?有什么是相同的呢?尝试改变一下别的东西。当你有了你的测试,以及可能也还有其它的测试,那就可以开始安全地修改代码了,确定是否可以缩小问题范围。记得从一个新提交开始解决问题,以便于可以轻松地撤销无效地更改。(这就是版本控制,如果你没有使用过版本控制,这将会改变你的生活。好吧,可能它只是让编码更容易。查阅“[版本控制可视指南][2]”,以了解更多。) + +### 5、休息一下 + +尽管如此,当它不再感觉起来像一个有趣的挑战或者游戏而开始变得令人沮丧时,你最好的举措是脱离这个问题。休息一下。我强烈建议你去散步并尝试考虑别的事情。 + +### 6、把一切写下来 + +当你回来了,如果你没有突然受到启发,那就把你关于这个问题所知的每一个点信息写下来。这应该包括: + + * 真正造成问题的调用 + * 真正发生了什么,包括任何错误信息或者相关的日志信息 + * 你真正期望发生什么 + * 到目前为止,为了找出问题,你做了什么工作;以及解决问题中你发现的任何线索。 + +有时这里有很多信息,但相信我,从零碎中挖掘信息是很烦人。所以尽量简洁,但是要完整。 + +### 7、寻求帮助 + +我经常发现写下所有信息能够启迪我想到还没尝试过的东西。当然,有时候我在点击求助邮件(或表单)的提交按钮后立刻意识到问题是是什么。无论如何,当你在写下所有东西仍一无所获时,那就试试向他人发邮件求助。首先是你的同事或者其他参与你的项目的人,然后是该项目的邮件列表。不要害怕向人求助。大多数人都是友善和乐于助人的,我发现在 Python 社区里尤其如此。 + +Maria McKinley 已在 [PyCascades 2019][4] 演讲 [代码查错][3],2 月 23-24,于西雅图。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/steps-hunting-code-python-bugs + +作者:[Maria Mckinley][a] +选题:[lujun9972][b] +译者:[LazyWolfLin](https://github.com/LazyWolfLin) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/parody +[b]: https://github.com/lujun9972 +[1]: http://www.pythontutor.com/ +[2]: https://betterexplained.com/articles/a-visual-guide-to-version-control/ +[3]: https://2019.pycascades.com/talks/hunting-the-bugs +[4]: https://2019.pycascades.com/ diff --git a/published/20190212 Ampersands and File Descriptors in Bash.md b/published/20190212 Ampersands and File Descriptors in Bash.md new file mode 100644 index 0000000000..1458375ae6 --- /dev/null +++ b/published/20190212 Ampersands and File Descriptors in Bash.md @@ -0,0 +1,164 @@ +[#]: collector: (lujun9972) +[#]: translator: (zero-mk) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10591-1.html) +[#]: subject: (Ampersands and File Descriptors in Bash) +[#]: via: (https://www.linux.com/blog/learn/2019/2/ampersands-and-file-descriptors-bash) +[#]: author: (Paul Brown https://www.linux.com/users/bro66) + +Bash 中的 & 符号和文件描述符 +====== + +> 了解如何将 “&” 与尖括号结合使用,并从命令行中获得更多信息。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ampersand-coffee.png?itok=yChaT-47) + +在我们探究大多数链式 Bash 命令中出现的所有的杂项符号(`&`、`|`、`;`、`>`、`<`、`{`、`[`、`(`、`)`、`]`、`}` 等等)的任务中,[我们一直在仔细研究 & 符号][1]。 + +[上次,我们看到了如何使用 & 把可能需要很长时间运行的进程放到后台运行][1]。但是,`&` 与尖括号 `<` 结合使用,也可用于将输出或输出通过管道导向其他地方。 + +在 [前面的][2] [尖括号教程中][3],你看到了如何使用 `>`,如下: + +``` +ls > list.txt +``` + +将 `ls` 输出传递给 `list.txt` 文件。 + +现在我们看到的是简写: + +``` +ls 1> list.txt +``` + +在这种情况下,`1` 是一个文件描述符,指向标准输出(`stdout`)。 + +以类似的方式,`2` 指向标准错误输出(`stderr`): + +``` +ls 2> error.log +``` + +所有错误消息都通过管道传递给 `error.log` 文件。 + +回顾一下:`1>` 是标准输出(`stdout`),`2>` 是标准错误输出(`stderr`)。 + +第三个标准文件描述符,`0<` 是标准输入(`stdin`)。你可以看到它是一个输入,因为箭头(`<`)指向`0`,而对于 `1` 和 `2`,箭头(`>`)是指向外部的。 + +### 标准文件描述符有什么用? + +如果你在阅读本系列以后,你已经多次使用标准输出(`1>`)的简写形式:`>`。 + +例如,当(假如)你知道你的命令会抛出一个错误时,像 `stderr`(`2`)这样的东西也很方便,但是 Bash 告诉你的东西是没有用的,你不需要看到它。如果要在 `home/` 目录中创建目录,例如: + +``` +mkdir newdir +``` + +如果 `newdir/` 已经存在,`mkdir` 将显示错误。但你为什么要关心这些呢?(好吧,在某些情况下你可能会关心,但并非总是如此。)在一天结束时,`newdir` 会以某种方式让你填入一些东西。你可以通过将错误消息推入虚空(即 ``/dev/null`)来抑制错误消息: + +``` +mkdir newdir 2> /dev/null +``` + +这不仅仅是 “让我们不要看到丑陋和无关的错误消息,因为它们很烦人”,因为在某些情况下,错误消息可能会在其他地方引起一连串错误。比如说,你想找到 `/etc` 下所有的 `.service` 文件。你可以这样做: + +``` +find /etc -iname "*.service" +``` + +但事实证明,在大多数系统中,`find` 显示的错误会有许多行,因为普通用户对 `/etc` 下的某些文件夹没有读取访问权限。它使读取正确的输出变得很麻烦,如果 `find` 是更大的脚本的一部分,它可能会导致行中的下一个命令排队。 + +相反,你可以这样做: + +``` +find /etc -iname "*.service" 2> /dev/null +``` + +而且你只得到你想要的结果。 + +### 文件描述符入门 + +单独的文件描述符 `stdout` 和 `stderr` 还有一些注意事项。如果要将输出存储在文件中,请执行以下操作: + +``` +find /etc -iname "*.service" 1> services.txt +``` + +工作正常,因为 `1>` 意味着 “发送标准输出且自身标准输出(非标准错误)到某个地方”。 + +但这里存在一个问题:如果你想把命令抛出的错误信息记录到文件,而结果中没有错误信息你该怎么**做**?上面的命令并不会这样做,因为它只写入 `find` 正确的结果,而: + +``` +find /etc -iname "*.service" 2> services.txt +``` + +只会写入命令抛出的错误信息。 + +我们如何得到两者?请尝试以下命令: + +``` +find /etc -iname "*.service" &> services.txt +``` + +…… 再次和 `&` 打个招呼! + +我们一直在说 `stdin`(`0`)、`stdout`(`1`)和 `stderr`(`2`)是“文件描述符”。文件描述符是一种特殊构造,是指向文件的通道,用于读取或写入,或两者兼而有之。这来自于将所有内容都视为文件的旧 UNIX 理念。想写一个设备?将其视为文件。想写入套接字并通过网络发送数据?将其视为文件。想要读取和写入文件?嗯,显然,将其视为文件。 + +因此,在管理命令的输出和错误的位置时,将目标视为文件。因此,当你打开它们来读取和写入它们时,它们都会获得文件描述符。 + +这是一个有趣的效果。例如,你可以将内容从一个文件描述符传递到另一个文件描述符: + +``` +find /etc -iname "*.service" 1> services.txt 2>&1 +``` + +这会将 `stderr` 导向到 `stdout`,而 `stdout` 通过管道被导向到一个文件中 `services.txt` 中。 + +它再次出现:`&` 发信号通知 Bash `1` 是目标文件描述符。 + +标准文件描述符的另一个问题是,当你从一个管道传输到另一个时,你执行此操作的顺序有点违反直觉。例如,按照上面的命令。它看起来像是错误的方式。你应该像这样阅读它:“将输出导向到文件,然后将错误导向到标准输出。” 看起来错误输出会在后面,并且在输出到标准输出(`1`)已经完成时才发送。 + +但这不是文件描述符的工作方式。文件描述符不是文件的占位符,而是文件的输入和(或)输出通道。在这种情况下,当你做 `1> services.txt` 时,你的意思是 “打开一个写管道到 `services.txt` 并保持打开状态”。`1` 是你要使用的管道的名称,它将保持打开状态直到该行的结尾。 + +如果你仍然认为这是错误的方法,试试这个: + +``` +find /etc -iname "*.service" 2>&1 1>services.txt +``` + +并注意它是如何不工作的;注意错误是如何被导向到终端的,而只有非错误的输出(即 `stdout`)被推送到 `services.txt`。 + +这是因为 Bash 从左到右处理 `find` 的每个结果。这样想:当 Bash 到达 `2>&1` 时,`stdout` (`1`)仍然是指向终端的通道。如果 `find` 给 Bash 的结果包含一个错误,它将被弹出到 `2`,转移到 `1`,然后留在终端! + +然后在命令结束时,Bash 看到你要打开 `stdout`(`1`) 作为到 `services.txt` 文件的通道。如果没有发生错误,结果将通过通道 `1` 进入文件。 + +相比之下,在: + +``` +find /etc -iname "*.service" 1>services.txt 2>&1 +``` + +`1` 从一开始就指向 `services.txt`,因此任何弹出到 `2` 的内容都会导向到 `1` ,而 `1` 已经指向最终去的位置 `services.txt`,这就是它工作的原因。 + +在任何情况下,如上所述 `&>` 都是“标准输出和标准错误”的缩写,即 `2>&1`。 + +这可能有点多,但不用担心。重新导向文件描述符在 Bash 命令行和脚本中是司空见惯的事。随着本系列的深入,你将了解更多关于文件描述符的知识。下周见! + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2019/2/ampersands-and-file-descriptors-bash + +作者:[Paul Brown][a] +选题:[lujun9972][b] +译者:[zero-mk](https://github.com/zero-mk) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/bro66 +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10587-1.html +[2]: https://linux.cn/article-10502-1.html +[3]: https://linux.cn/article-10529-1.html diff --git a/published/20190212 How To Check CPU, Memory And Swap Utilization Percentage In Linux.md b/published/20190212 How To Check CPU, Memory And Swap Utilization Percentage In Linux.md new file mode 100644 index 0000000000..cee9dc5f2c --- /dev/null +++ b/published/20190212 How To Check CPU, Memory And Swap Utilization Percentage In Linux.md @@ -0,0 +1,218 @@ +[#]: collector: (lujun9972) +[#]: translator: (An-DJ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10595-1.html) +[#]: subject: (How To Check CPU, Memory And Swap Utilization Percentage In Linux?) +[#]: via: (https://www.2daygeek.com/linux-check-cpu-memory-swap-utilization-percentage/) +[#]: author: (Vinoth Kumar https://www.2daygeek.com/author/vinoth/) + +如何查看 Linux 下 CPU、内存和交换分区的占用率? +====== + +在 Linux 下有很多可以用来查看内存占用情况的命令和选项,但是我并没有看见关于内存占用率的更多的信息。 + +在大多数情况下我们只想查看内存使用情况,并没有考虑占用的百分比究竟是多少。如果你想要了解这些信息,那你看这篇文章就对了。我们将会详细地在这里帮助你解决这个问题。 + +这篇教程将会帮助你在面对 Linux 服务器下频繁的内存高占用情况时,确定内存使用情况。 + +而在同时,如果你使用的是 `free -m` 或者 `free -g`,占用情况描述地也并不是十分清楚。 + +这些格式化命令属于 Linux 高级命令。它将会对 Linux 专家和中等水平 Linux 使用者非常有用。 + +### 方法-1:如何查看 Linux 下内存占用率? + +我们可以使用下面命令的组合来达到此目的。在该方法中,我们使用的是 `free` 和 `awk` 命令的组合来获取内存占用率。 + +如果你正在寻找其他有关于内存的文章,你可以导航到如下链接。这些文章有 [free 命令][1]、[smem 命令][2]、[ps_mem 命令][3]、[vmstat 命令][4] 及 [查看物理内存大小的多种方式][5]。 + +要获取不包含百分比符号的内存占用率: + +``` +$ free -t | awk 'NR == 2 {print "Current Memory Utilization is : " $3/$2*100}' +或 +$ free -t | awk 'FNR == 2 {print "Current Memory Utilization is : " $3/$2*100}' + +Current Memory Utilization is : 20.4194 +``` + +要获取不包含百分比符号的交换分区占用率: + +``` +$ free -t | awk 'NR == 3 {print "Current Swap Utilization is : " $3/$2*100}' +或 +$ free -t | awk 'FNR == 3 {print "Current Swap Utilization is : " $3/$2*100}' + +Current Swap Utilization is : 0 +``` + +要获取包含百分比符号及保留两位小数的内存占用率: + +``` +$ free -t | awk 'NR == 2 {printf("Current Memory Utilization is : %.2f%"), $3/$2*100}' +或 +$ free -t | awk 'FNR == 2 {printf("Current Memory Utilization is : %.2f%"), $3/$2*100}' + +Current Memory Utilization is : 20.42% +``` + +要获取包含百分比符号及保留两位小数的交换分区占用率: + +``` +$ free -t | awk 'NR == 3 {printf("Current Swap Utilization is : %.2f%"), $3/$2*100}' +或 +$ free -t | awk 'FNR == 3 {printf("Current Swap Utilization is : %.2f%"), $3/$2*100}' + +Current Swap Utilization is : 0.00% +``` + +如果你正在寻找有关于交换分区的其他文章,你可以导航至如下链接。这些链接有 [使用 LVM(逻辑盘卷管理)创建和扩展交换分区][6],[创建或扩展交换分区的多种方式][7] 和 [创建/删除和挂载交换分区文件的多种方式][8]。 + +键入 `free` 命令会更好地作出阐释: + +``` +$ free + total used free shared buff/cache available +Mem: 15867 3730 9868 1189 2269 10640 +Swap: 17454 0 17454 +Total: 33322 3730 27322 +``` + +细节如下: + + * `free`:是一个标准命令,用于在 Linux 下查看内存使用情况。 + * `awk`:是一个专门用来做文本数据处理的强大命令。 + * `FNR == 2`:该命令给出了每一个输入文件的行数。其基本上用于挑选出给定的行(针对于这里,它选择的是行号为 2 的行) + * `NR == 2`:该命令给出了处理的行总数。其基本上用于过滤给出的行(针对于这里,它选择的是行号为 2 的行) + * `$3/$2*100`:该命令将列 3 除以列 2 并将结果乘以 100。 + * `printf`:该命令用于格式化和打印数据。 + * `%.2f%`:默认情况下,其打印小数点后保留 6 位的浮点数。使用后跟的格式来约束小数位。 + +### 方法-2:如何查看 Linux 下内存占用率? + +我们可以使用下面命令的组合来达到此目的。在这种方法中,我们使用 `free`、`grep` 和 `awk` 命令的组合来获取内存占用率。 + +要获取不包含百分比符号的内存占用率: + +``` +$ free -t | grep Mem | awk '{print "Current Memory Utilization is : " $3/$2*100}' +Current Memory Utilization is : 20.4228 +``` + +要获取不包含百分比符号的交换分区占用率: + +``` +$ free -t | grep Swap | awk '{print "Current Swap Utilization is : " $3/$2*100}' +Current Swap Utilization is : 0 +``` + +要获取包含百分比符号及保留两位小数的内存占用率: + +``` +$ free -t | grep Mem | awk '{printf("Current Memory Utilization is : %.2f%"), $3/$2*100}' +Current Memory Utilization is : 20.43% +``` + +要获取包含百分比符号及保留两位小数的交换空间占用率: + +``` +$ free -t | grep Swap | awk '{printf("Current Swap Utilization is : %.2f%"), $3/$2*100}' +Current Swap Utilization is : 0.00% +``` + +### 方法-1:如何查看 Linux 下 CPU 的占用率? + +我们可以使用如下命令的组合来达到此目的。在这种方法中,我们使用 `top`、`print` 和 `awk` 命令的组合来获取 CPU 的占用率。 + +如果你正在寻找其他有关于 CPU(LCTT 译注:原文误为 memory)的文章,你可以导航至如下链接。这些文章有 [top 命令][9]、[htop 命令][10]、[atop 命令][11] 及 [Glances 命令][12]。 + +如果在输出中展示的是多个 CPU 的情况,那么你需要使用下面的方法。 + +``` +$ top -b -n1 | grep ^%Cpu +%Cpu0 : 5.3 us, 0.0 sy, 0.0 ni, 94.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu1 : 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu2 : 0.0 us, 0.0 sy, 0.0 ni, 94.7 id, 0.0 wa, 0.0 hi, 5.3 si, 0.0 st +%Cpu3 : 5.3 us, 0.0 sy, 0.0 ni, 94.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu4 : 10.5 us, 15.8 sy, 0.0 ni, 73.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu5 : 0.0 us, 5.0 sy, 0.0 ni, 95.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu6 : 5.3 us, 0.0 sy, 0.0 ni, 94.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +%Cpu7 : 5.3 us, 0.0 sy, 0.0 ni, 94.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st +``` + +要获取不包含百分比符号的 CPU 占用率: + +``` +$ top -b -n1 | grep ^%Cpu | awk '{cpu+=$9}END{print "Current CPU Utilization is : " 100-cpu/NR}' +Current CPU Utilization is : 21.05 +``` + +要获取包含百分比符号及保留两位小数的 CPU 占用率: + +``` +$ top -b -n1 | grep ^%Cpu | awk '{cpu+=$9}END{printf("Current CPU Utilization is : %.2f%"), 100-cpu/NR}' +Current CPU Utilization is : 14.81% +``` + +### 方法-2:如何查看 Linux 下 CPU 的占用率? + +我们可以使用如下命令的组合来达到此目的。在这种方法中,我们使用的是 `top`、`print`/`printf` 和 `awk` 命令的组合来获取 CPU 的占用率。 + +如果在单个输出中一起展示了所有的 CPU 的情况,那么你需要使用下面的方法。 + +``` +$ top -b -n1 | grep ^%Cpu +%Cpu(s): 15.3 us, 7.2 sy, 0.8 ni, 69.0 id, 6.7 wa, 0.0 hi, 1.0 si, 0.0 st +``` + +要获取不包含百分比符号的 CPU 占用率: + +``` +$ top -b -n1 | grep ^%Cpu | awk '{print "Current CPU Utilization is : " 100-$8}' +Current CPU Utilization is : 5.6 +``` + +要获取包含百分比符号及保留两位小数的 CPU 占用率: + +``` +$ top -b -n1 | grep ^%Cpu | awk '{printf("Current CPU Utilization is : %.2f%"), 100-$8}' +Current CPU Utilization is : 5.40% +``` + +如下是一些细节: + + * `top`:是一种用于查看当前 Linux 系统下正在运行的进程的非常好的命令。 + * `-b`:选项允许 `top` 命令切换至批处理的模式。当你从本地系统运行 `top` 命令至远程系统时,它将会非常有用。 + * `-n1`:迭代次数。 + * `^%Cpu`:过滤以 `%CPU` 开头的行。 + * `awk`:是一种专门用来做文本数据处理的强大命令。 + * `cpu+=$9`:对于每一行,将第 9 列添加至变量 `cpu`。 + * `printf`:该命令用于格式化和打印数据。 + * `%.2f%`:默认情况下,它打印小数点后保留 6 位的浮点数。使用后跟的格式来限制小数位数。 + * `100-cpu/NR`:最终打印出 CPU 平均占用率,即用 100 减去其并除以行数。 + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-check-cpu-memory-swap-utilization-percentage/ + +作者:[Vinoth Kumar][a] +选题:[lujun9972][b] +译者:[An-DJ](https://github.com/An-DJ) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/vinoth/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/free-command-to-check-memory-usage-statistics-in-linux/ +[2]: https://www.2daygeek.com/smem-linux-memory-usage-statistics-reporting-tool/ +[3]: https://www.2daygeek.com/ps_mem-report-core-memory-usage-accurately-in-linux/ +[4]: https://www.2daygeek.com/linux-vmstat-command-examples-tool-report-virtual-memory-statistics/ +[5]: https://www.2daygeek.com/easy-ways-to-check-size-of-physical-memory-ram-in-linux/ +[6]: https://www.2daygeek.com/how-to-create-extend-swap-partition-in-linux-using-lvm/ +[7]: https://www.2daygeek.com/add-extend-increase-swap-space-memory-file-partition-linux/ +[8]: https://www.2daygeek.com/shell-script-create-add-extend-swap-space-linux/ +[9]: https://www.2daygeek.com/linux-top-command-linux-system-performance-monitoring-tool/ +[10]: https://www.2daygeek.com/linux-htop-command-linux-system-performance-resource-monitoring-tool/ +[11]: https://www.2daygeek.com/atop-system-process-performance-monitoring-tool/ +[12]: https://www.2daygeek.com/install-glances-advanced-real-time-linux-system-performance-monitoring-tool-on-centos-fedora-ubuntu-debian-opensuse-arch-linux/ diff --git a/published/20190212 Two graphical tools for manipulating PDFs on the Linux desktop.md b/published/20190212 Two graphical tools for manipulating PDFs on the Linux desktop.md new file mode 100644 index 0000000000..77c68dc718 --- /dev/null +++ b/published/20190212 Two graphical tools for manipulating PDFs on the Linux desktop.md @@ -0,0 +1,97 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10584-1.html) +[#]: subject: (Two graphical tools for manipulating PDFs on the Linux desktop) +[#]: via: (https://opensource.com/article/19/2/manipulating-pdfs-linux) +[#]: author: (Scott Nesbitt https://opensource.com/users/scottnesbitt) + +两款 Linux 桌面中的图形化操作 PDF 的工具 +====== + +> PDF-Shuffler 和 PDF Chain 是在 Linux 中修改 PDF 的绝佳工具。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_osyearbook2016_sysadmin_cc.png?itok=Y1AHCKI4) + +由于我谈论和写作了些 PDF 及使用它们的工具的文章,有些人认为我喜欢这种格式。其实我并不是,由于各种原因,我不会深入它。 + +我不会说 PDF 是我个人和职业生活中的一个躲不开的坏事 - 而实际上它们不是那么好。通常即使有更好的替代方案来交付文档,通常我也必须使用 PDF。 + +当我使用 PDF 时,通常是在白天工作时在其他的操作系统上使用,我使用 Adobe Acrobat 进行操作。但是当我必须在 Linux 桌面上使用 PDF 时呢?我们来看看我用来操作 PDF 的两个图形工具。 + +### PDF-Shuffler + +顾名思义,你可以使用 [PDF-Shuffler][1] 在 PDF 文件中移动页面。它可以做得更多,但该软件的功能是有限的。这并不意味着 PDF-Shuffler 没用。它有用,很有用。 + +你可以将 PDF-Shuffler 用来: + + * 从 PDF 文件中提取页面 + * 将页面添加到文件中 + * 重新排列文件中的页面 + +请注意,PDF-Shuffler 有一些依赖项,如 pyPDF 和 python-gtk。通常,通过包管理器安装它是最快且最不令人沮丧的途径。 + +假设你想从 PDF 中提取页面,也许是作为你书中的样本章节。选择 “File > Add”打开 PDF 文件。 + +![](https://opensource.com/sites/default/files/uploads/pdfshuffler-book.png) + +要提取第 7 页到第 9 页,请按住 `Ctrl` 并单击选择页面。然后,右键单击并选择 “Export selection”。 + +![](https://opensource.com/sites/default/files/uploads/pdfshuffler-export.png) + +选择要保存文件的目录,为其命名,然后单击 “Save”。 + +要添加文件 —— 例如,要添加封面或重新插入已扫描的且已签名的合同或者应用 - 打开 PDF 文件,然后选择 “File > Add” 并找到要添加的 PDF 文件。单击 “Open”。 + +PDF-Shuffler 有个不好的地方就是添加页面到你正在处理的 PDF 文件末尾。单击并将添加的页面拖动到文件中的所需位置。你一次只能在文件中单击并拖动一个页面。 + +![](https://opensource.com/sites/default/files/uploads/pdfshuffler-move.png) + +### PDF Chain + +我是 [PDFtk][2] 的忠实粉丝,它是一个可以对 PDF 做一些有趣操作的命令行工具。由于我不经常使用它,我不记得所有 PDFtk 的命令和选项。 + +[PDF Chain][3] 是 PDFtk 命令行的一个很好的替代品。它可以让你一键使用 PDFtk 最常用的命令。无需使用菜单,你可以: + +* 合并 PDF(包括旋转一个或多个文件的页面) +* 从 PDF 中提取页面并将其保存到单个文件中 +* 为 PDF 添加背景或水印 +* 将附件添加到文件 + +![](https://opensource.com/sites/default/files/uploads/pdfchain1.png) + +你也可以做得更多。点击 “Tools” 菜单,你可以: + +* 从 PDF 中提取附件 +* 压缩或解压缩文件 +* 从文件中提取元数据 +* 用外部[数据][4]填充 PDF 表格 +* [扁平化][5] PDF +* 从 PDF 表单中删除 [XML 表格结构][6](XFA)数据 + +老实说,我只使用 PDF Chain 或 PDFtk 提取附件、压缩或解压缩 PDF。其余的对我来说基本没听说。 + +### 总结 + +Linux 上用于处理 PDF 的工具数量一直让我感到吃惊。它们的特性和功能的广度和深度也是如此。无论是命令行还是图形,我总能找到一个能做我需要的。在大多数情况下,PDF Mod 和 PDF Chain 对我来说效果很好。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/manipulating-pdfs-linux + +作者:[Scott Nesbitt][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/scottnesbitt +[b]: https://github.com/lujun9972 +[1]: https://savannah.nongnu.org/projects/pdfshuffler/ +[2]: https://en.wikipedia.org/wiki/PDFtk +[3]: http://pdfchain.sourceforge.net/ +[4]: http://www.verypdf.com/pdfform/fdf.htm +[5]: http://pdf-tips-tricks.blogspot.com/2009/03/flattening-pdf-layers.html +[6]: http://en.wikipedia.org/wiki/XFA diff --git a/published/20190213 How to use Linux Cockpit to manage system performance.md b/published/20190213 How to use Linux Cockpit to manage system performance.md new file mode 100644 index 0000000000..2209d07df3 --- /dev/null +++ b/published/20190213 How to use Linux Cockpit to manage system performance.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10583-1.html) +[#]: subject: (How to use Linux Cockpit to manage system performance) +[#]: via: (https://www.networkworld.com/article/3340038/linux/sitting-in-the-linux-cockpit.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +如何使用 Linux Cockpit 来管理系统性能 +====== + +> Linux Cockpit 是一个基于 Web 界面的应用,它提供了对系统的图形化管理。看下它能够控制哪些。 + +![](https://images.idgesg.net/images/article/2019/02/cockpit_airline_airplane_control_pilot-by-southerlycourse-getty-100787904-large.jpg) + +如果你还没有尝试过相对较新的 Linux Cockpit,你可能会对它所能做的一切感到惊讶。它是一个用户友好的基于 web 的控制台,提供了一些非常简单的方法来管理 Linux 系统 —— 通过 web。你可以通过一个非常简单的 web 来监控系统资源、添加或删除帐户、监控系统使用情况、关闭系统以及执行其他一些其他任务。它的设置和使用也非常简单。 + +虽然许多 Linux 系统管理员将大部分时间花在命令行上,但使用 PuTTY 等工具访问远程系统并不总能提供最有用的命令输出。Linux Cockpit 提供了图形和易于使用的表单,来查看性能情况并对系统进行更改。 + +Linux Cockpit 能让你查看系统性能的许多方面并进行配置更改,但任务列表可能取决于你使用的特定 Linux。任务分类包括以下内容: + +* 监控系统活动(CPU、内存、磁盘 IO 和网络流量) —— **系统** +* 查看系统日志条目 —— **日志** +* 查看磁盘分区的容量 —— **存储** +* 查看网络活动(发送和接收) —— **网络** +* 查看用户帐户 —— **帐户** +* 检查系统服务的状态 —— **服务** +* 提取已安装应用的信息 —— **应用** +* 查看和安装可用更新(如果以 root 身份登录)并在需要时重新启动系统 —— **软件更新** +* 打开并使用终端窗口 —— **终端** + +某些 Linux Cockpit 安装还允许你运行诊断报告、转储内核、检查 SELinux(安全)设置和列出订阅。 + +以下是 Linux Cockpit 显示的系统活动示例: + +![cockpit activity][1] + +*Linux Cockpit 显示系统活动* + +### 如何设置 Linux Cockpit + +在某些 Linux 发行版(例如,最新的 RHEL)中,Linux Cockpit 可能已经安装并可以使用。在其他情况下,你可能需要采取一些简单的步骤来安装它并使其可使用。 + +例如,在 Ubuntu 上,这些命令应该可用: + +``` +$ sudo apt-get install cockpit +$ man cockpit <== just checking +$ sudo systemctl enable --now cockpit.socket +$ netstat -a | grep 9090 +tcp6 0 0 [::]:9090 [::]:* LISTEN +$ sudo systemctl enable --now cockpit.socket +$ sudo ufw allow 9090 +``` + +启用 Linux Cockpit 后,在浏览器中打开 `https://:9090` + +可以在 [Cockpit 项目][2] 中找到可以使用 Cockpit 的发行版列表以及安装说明。 + +没有额外的配置,Linux Cockpit 将无法识别 `sudo` 权限。如果你被禁止使用 Cockpit 进行更改,你将会在你点击的按钮上看到一个红色的通用禁止标志。 + +要使 `sudo` 权限有效,你需要确保用户位于 `/etc/group` 文件中的 `wheel`(RHEL)或 `adm` (Debian)组中,即服务器当以 root 用户身份登录 Cockpit 并且用户在登录 Cockpit 时选择“重用我的密码”时,已勾选了 “Server Administrator”。 + +在你管理的系统位在千里之外或者没有控制台时,能使用图形界面控制也不错。虽然我喜欢在控制台上工作,但我偶然也乐于见到图形或者按钮。Linux Cockpit 为日常管理任务提供了非常有用的界面。 + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3340038/linux/sitting-in-the-linux-cockpit.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/cockpit-activity-100787994-large.jpg +[2]: https://cockpit-project.org/running.html +[3]: https://www.facebook.com/NetworkWorld/ +[4]: https://www.linkedin.com/company/network-world diff --git a/published/20190216 FinalCrypt - An Open Source File Encryption Application.md b/published/20190216 FinalCrypt - An Open Source File Encryption Application.md new file mode 100644 index 0000000000..3619ccacc1 --- /dev/null +++ b/published/20190216 FinalCrypt - An Open Source File Encryption Application.md @@ -0,0 +1,119 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10588-1.html) +[#]: subject: (FinalCrypt – An Open Source File Encryption Application) +[#]: via: (https://itsfoss.com/finalcrypt/) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +FinalCrypt:一个开源文件加密应用 +====== + +我通常不会加密文件,但如果我打算整理我的重要文件或凭证,加密程序就会派上用场。 + +你可能已经在使用像 [GnuPG][1] 这样的程序来帮助你加密/解密 Linux 上的文件。还有 [EncryptPad][2] 也可以加密你的笔记。 + +但是,我看到了一个名为 FinalCrypt 的新的免费开源加密工具。你可以在 [GitHub 页面][3]上查看其最新的版本和源码。 + +在本文中,我将分享使用此工具的经验。请注意,我不会将它与其他程序进行比较 —— 因此,如果你想要多个程序之间的详细比较,请在评论中告诉我们。 + +![FinalCrypt][4] + +### 使用 FinalCrypt 加密文件 + +FinalCrypt 使用[一次性密码本][5]密钥生成密码来加密文件。换句话说,它会生成一个 OTP 密钥,你将使用该密钥加密或解密你的文件。 + +根据你指定的密钥大小,密钥是完全随机的。因此,没有密钥文件就无法解密文件。 + +虽然 OTP 密钥用于加密/解密简单而有效,但管理或保护密钥文件对某些人来说可能是不方便的。 + +如果要使用 FinalCrypt,可以从它的网站下载 DEB/RPM 文件。FinalCrypt 也可用于 Windows 和 macOS。 + +- [下载 FinalCrypt](https://sites.google.com/site/ronuitholland/home/finalcrypt) + +下载后,只需双击该 [deb][6] 或 rpm 文件就能安装。如果需要,你还可以从源码编译。 + +### 使用 FileCrypt + +该视频演示了如何使用FinalCrypt: + + + +如果你喜欢 Linux 相关的视频,请[订阅我们的 YouTube 频道][7]。 + +安装 FinalCrypt 后,你将在已安装的应用列表中找到它。从这里启动它。 + +启动后,你将看到(分割的)两栏,一个进行加密/解密,另一个选择 OTP 文件。 + +![Using FinalCrypt for encrypting files in Linux][8] + +首先,你必须生成 OTP 密钥。下面是做法: + +![finalcrypt otp][9] + +请注意你的文件名可以是任何内容 —— 但你需要确保密钥文件的大小大于或等于要加密的文件。我觉得这很荒谬,但事实就是如此。 + +![][10] + +生成文件后,选择窗口右侧的密钥,然后选择要在窗口左侧加密的文件。 + +生成 OTP 后,你会看到高亮显示的校验和、密钥文件大小和有效状态: + +![][11] + +选择之后,你只需要点击 “Encrypt” 来加密这些文件,如果已经加密,那么点击 “Decrypt” 来解密这些文件。 + +![][12] + +你还可以在命令行中使用 FinalCrypt 来自动执行加密作业。 + +#### 如何保护你的 OTP 密钥? + +加密/解密你想要保护的文件很容易。但是,你应该在哪里保存你的 OTP 密钥? + +如果你未能将 OTP 密钥保存在安全的地方,那么它几乎没用。 + +嗯,最好的方法之一是使用专门的 USB 盘保存你的密钥。只需要在解密文件时将它插入即可。 + +除此之外,如果你认为足够安全,你可以将密钥保存在[云服务][13]中。 + +有关 FinalCrypt 的更多信息,请访问它的网站。 + +[FinalCrypt](https://sites.google.com/site/ronuitholland/home/finalcrypt) + +### 总结 + +它开始时看上去有点复杂,但它实际上是 Linux 中一个简单且用户友好的加密程序。如果你想看看其他的,还有一些其他的[加密保护文件夹][14]的程序。 + +你如何看待 FinalCrypt?你还知道其他类似可能更好的程序么?请在评论区告诉我们,我们将会查看的! + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/finalcrypt/ + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.gnupg.org/ +[2]: https://itsfoss.com/encryptpad-encrypted-text-editor-linux/ +[3]: https://github.com/ron-from-nl/FinalCrypt +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/finalcrypt.png?resize=800%2C450&ssl=1 +[5]: https://en.wikipedia.org/wiki/One-time_pad +[6]: https://itsfoss.com/install-deb-files-ubuntu/ +[7]: https://www.youtube.com/c/itsfoss?sub_confirmation=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/finalcrypt.jpg?fit=800%2C439&ssl=1 +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/finalcrypt-otp-key.jpg?resize=800%2C443&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/finalcrypt-otp-generate.jpg?ssl=1 +[11]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/finalcrypt-key.jpg?fit=800%2C420&ssl=1 +[12]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/finalcrypt-encrypt.jpg?ssl=1 +[13]: https://itsfoss.com/cloud-services-linux/ +[14]: https://itsfoss.com/password-protect-folder-linux/ +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/finalcrypt.png?fit=800%2C450&ssl=1 diff --git a/published/20190217 How to Change User Password in Ubuntu -Beginner-s Tutorial.md b/published/20190217 How to Change User Password in Ubuntu -Beginner-s Tutorial.md new file mode 100644 index 0000000000..dbaf1ca52e --- /dev/null +++ b/published/20190217 How to Change User Password in Ubuntu -Beginner-s Tutorial.md @@ -0,0 +1,124 @@ +[#]: collector: (lujun9972) +[#]: translator: (An-DJ) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10580-1.html) +[#]: subject: (How to Change User Password in Ubuntu [Beginner’s Tutorial]) +[#]: via: (https://itsfoss.com/change-password-ubuntu) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +新手教程:Ubuntu 下如何修改用户密码 +====== + +> 想要在 Ubuntu 下修改 root 用户的密码?那我们来学习下如何在 Ubuntu Linux 下修改任意用户的密码。我们会讨论在终端下修改和在图形界面(GUI)修改两种做法。 + +那么,在 Ubuntu 下什么时候会需要修改密码呢?这里我给出如下两种场景。 + +- 当你刚安装 [Ubuntu][1] 系统时,你会创建一个用户并且为之设置一个密码。这个初始密码可能安全性较弱或者太过于复杂,你会想要对它做出修改。 +- 如果你是系统管理员,你可能需要去修改在你管理的系统内其他用户的密码。 + +当然,你可能会有其他的一些原因做这样的一件事。不过现在问题来了,我们到底如何在 Ubuntu 或其它 Linux 系统下修改单个用户的密码呢? + +在这个快速教程中,我将会展示给你在 Ubuntu 中如何使用命令行和图形界面(GUI)两种方式修改密码。 + +### 在 Ubuntu 中修改用户密码 —— 通过命令行 + +![如何在 Ubuntu Linux 下修改用户密码][2] + +在 Ubuntu 下修改用户密码其实非常简单。事实上,在任何 Linux 发行版上修改的方式都是一样的,因为你要使用的是叫做 `passwd` 的普通 Linux 命令来达到此目的。 + +如果你想要修改你的当前密码,只需要简单地在终端执行此命令: + +``` +passwd +``` + +系统会要求你输入当前密码和两次新的密码。 + +在键入密码时,你不会从屏幕上看到任何东西。这在 UNIX 和 Linux 系统中是非常正常的表现。 + +``` +passwd +Changing password for abhishek. +(current) UNIX password: +Enter new UNIX password: +Retype new UNIX password: +passwd: password updated successfully +``` + +由于这是你的管理员账户,你刚刚修改了 Ubuntu 下 sudo 密码,但你甚至没有意识到这个操作。(LCTT 译注:执行 sudo 操作时,输入的是的用户自身的密码,此处修改的就是自身的密码。而所说的“管理员账户”指的是该用户处于可以执行 `sudo` 命令的用户组中。本文此处描述易引起误会,特注明。) + +![在 Linux 命令行中修改用户密码][3] + +如果你想要修改其他用户的密码,你也可以使用 `passwd` 命令来做。但是在这种情况下,你将不得不使用`sudo`。(LCTT 译注:此处执行 `sudo`,要先输入你的 sudo 密码 —— 如上提示已经修改,再输入给其它用户设置的新密码 —— 两次。) + +``` +sudo passwd +``` + +如果你对密码已经做出了修改,不过之后忘记了,不要担心。你可以[很容易地在Ubuntu下重置密码][4]. + +### 修改 Ubuntu 下 root 用户密码 + +默认情况下,Ubuntu 中 root 用户是没有密码的。不必惊讶,你并不是在 Ubuntu 下一直使用 root 用户。不太懂?让我快速地给你解释下。 + +当[安装 Ubuntu][5] 时,你会被强制创建一个用户。这个用户拥有管理员访问权限。这个管理员用户可以通过 `sudo` 命令获得 root 访问权限。但是,该用户使用的是自身的密码,而不是 root 账户的密码(因为就没有)。 + +你可以使用 `passwd` 命令来设置或修改 root 用户的密码。然而,在大多数情况下,你并不需要它,而且你不应该去做这样的事。 + +你将必须使用 `sudo` 命令(对于拥有管理员权限的账户)。~~如果 root 用户的密码之前没有被设置,它会要求你设置。另外,你可以使用已有的 root 密码对它进行修改。~~(LCTT 译注:此处描述有误,使用 `sudo` 或直接以 root 用户执行 `passwd` 命令时,不需要输入该被改变密码的用户的当前密码。) + +``` +sudo password root +``` + +### 在 Ubuntu 下使用图形界面(GUI)修改密码 + +我这里使用的是 GNOME 桌面环境,Ubuntu 版本为 18.04。这些步骤对于其他的桌面环境和 Ubuntu 版本应该差别不大。 + +打开菜单(按下 `Windows`/`Super` 键)并搜索 “Settings”(设置)。 + +在 “Settings” 中,向下滚动一段距离打开进入 “Details”。 + +![在 Ubuntu GNOME Settings 中进入 Details][6] + +在这里,点击 “Users” 获取系统下可见的所有用户。 + +![Ubuntu 下用户设置][7] + +你可以选择任一你想要的用户,包括你的主要管理员账户。你需要先解锁用户并点击 “Password” 区域。 + +![Ubuntu 下修改用户密码][8] + +你会被要求设置密码。如果你正在修改的是你自己的密码,你将必须也输入当前使用的密码。 + +![Ubuntu 下修改用户密码][9] + +做好这些后,点击上面的 “Change” 按钮,这样就完成了。你已经成功地在 Ubuntu 下修改了用户密码。 + +我希望这篇快速精简的小教程能够帮助你在 Ubuntu 下修改用户密码。如果你对此还有一些问题或建议,请在下方留下评论。 + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/change-password-ubuntu + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[An-DJ](https://github.com/An-DJ) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.ubuntu.com/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/change-password-ubuntu-linux.png?resize=800%2C450&ssl=1 +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/change-user-password-linux-1.jpg?resize=800%2C253&ssl=1 +[4]: https://itsfoss.com/how-to-hack-ubuntu-password/ +[5]: https://itsfoss.com/install-ubuntu-1404-dual-boot-mode-windows-8-81-uefi/ +[6]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/change-user-password-ubuntu-gui-2.jpg?resize=800%2C484&ssl=1 +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/change-user-password-ubuntu-gui-3.jpg?resize=800%2C488&ssl=1 +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/change-user-password-ubuntu-gui-4.jpg?resize=800%2C555&ssl=1 +[9]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/change-user-password-ubuntu-gui-1.jpg?ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/change-password-ubuntu-linux.png?fit=800%2C450&ssl=1 diff --git a/published/20190219 Logical - in Bash.md b/published/20190219 Logical - in Bash.md new file mode 100644 index 0000000000..990b73311e --- /dev/null +++ b/published/20190219 Logical - in Bash.md @@ -0,0 +1,194 @@ +[#]: collector: "lujun9972" +[#]: translator: "zero-mk" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-10596-1.html" +[#]: subject: "Logical & in Bash" +[#]: via: "https://www.linux.com/blog/learn/2019/2/logical-ampersand-bash" +[#]: author: "Paul Brown https://www.linux.com/users/bro66" + +Bash 中的逻辑和(&) +====== +> 在 Bash 中,你可以使用 & 作为 AND(逻辑和)操作符。 + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ampersand-brian-taylor-unsplash.jpg?itok=Iq6vxSNK) + +有人可能会认为两篇文章中的 `&` 意思差不多,但实际上并不是。虽然 [第一篇文章讨论了如何在命令末尾使用 & 来将命令转到后台运行][1],在之后剖析了流程管理,第二篇文章将 [ & 看作引用文件描述符的方法][2],这些文章让我们知道了,与 `<` 和 `>` 结合使用后,你可以将输入或输出引导到别的地方。 + +但我们还没接触过作为 AND 操作符使用的 `&`。所以,让我们来看看。 + +### & 是一个按位运算符 + +如果你十分熟悉二进制数操作,你肯定听说过 AND 和 OR 。这些是按位操作,对二进制数的各个位进行操作。在 Bash 中,使用 `&` 作为 AND 运算符,使用 `|` 作为 OR 运算符: + +**AND**: + +``` +0 & 0 = 0 +0 & 1 = 0 +1 & 0 = 0 +1 & 1 = 1 +``` + +**OR**: + +``` +0 | 0 = 0 +0 | 1 = 1 +1 | 0 = 1 +1 | 1 = 1 +``` + +你可以通过对任何两个数字进行 AND 运算并使用 `echo` 输出结果: + +``` +$ echo $(( 2 & 3 )) # 00000010 AND 00000011 = 00000010 +2 +$ echo $(( 120 & 97 )) # 01111000 AND 01100001 = 01100000 +96 +``` + +OR(`|`)也是如此: + +``` +$ echo $(( 2 | 3 )) # 00000010 OR 00000011 = 00000011 +3 +$ echo $(( 120 | 97 )) # 01111000 OR 01100001 = 01111001 +121 +``` + +说明: + +1. 使用 `(( ... ))` 告诉 Bash 双括号之间的内容是某种算术或逻辑运算。`(( 2 + 2 ))`、 `(( 5 % 2 ))` (`%` 是[求模][3]运算符)和 `((( 5 % 2 ) + 1))`(等于 3)都可以工作。 +2. [像变量一样][4],使用 `$` 提取值,以便你可以使用它。 +3. 空格并没有影响:`((2+3))` 等价于 `(( 2+3 ))` 和 `(( 2 + 3 ))`。 +4. Bash 只能对整数进行操作。试试这样做: `(( 5 / 2 ))` ,你会得到 `2`;或者这样 `(( 2.5 & 7 ))` ,但会得到一个错误。然后,在按位操作中使用除了整数之外的任何东西(这就是我们现在所讨论的)通常是你不应该做的事情。 + +**提示:** 如果你想看看十进制数字在二进制下会是什么样子,你可以使用 `bc` ,这是一个大多数 Linux 发行版都预装了的命令行计算器。比如: + +``` +bc <<< "obase=2; 97" +``` + +这个操作将会把 `97` 转换成十二进制(`obase` 中的 `o` 代表 “output” ,也即,“输出”)。 + +``` +bc <<< "ibase=2; 11001011" +``` + +这个操作将会把 `11001011` 转换成十进制(`ibase` 中的 `i` 代表 “input”,也即,“输入”)。 + +### && 是一个逻辑运算符 + +虽然它使用与其按位表达相同的逻辑原理,但 Bash 的 `&&` 运算符只能呈现两个结果:`1`(“真值”)和`0`(“假值”)。对于 Bash 来说,任何不是 `0` 的数字都是 “真值”,任何等于 `0` 的数字都是 “假值”。什么也是 “假值”同时也不是数字呢: + +``` +$ echo $(( 4 && 5 )) # 两个非零数字,两个为 true = true +1 +$ echo $(( 0 && 5 )) # 有一个为零,一个为 false = false +0 +$ echo $(( b && 5 )) # 其中一个不是数字,一个为 false = false +0 +``` + +与 `&&` 类似, OR 对应着 `||` ,用法正如你想的那样。 + +以上这些都很简单……直到它用在命令的退出状态时。 + +### && 是命令退出状态的逻辑运算符 + +[正如我们在之前的文章中看到的][2],当命令运行时,它会输出错误消息。更重要的是,对于今天的讨论,它在结束时也会输出一个数字。此数字称为“返回码”,如果为 0,则表示该命令在执行期间未遇到任何问题。如果是任何其他数字,即使命令完成,也意味着某些地方出错了。 + +所以 0 意味着是好的,任何其他数字都说明有问题发生,并且,在返回码的上下文中,0 意味着“真”,其他任何数字都意味着“假”。对!这 **与你所熟知的逻辑操作完全相反** ,但是你能用这个做什么? 不同的背景,不同的规则。这种用处很快就会显现出来。 + +让我们继续! + +返回码 *临时* 储存在 [特殊变量][5] `?` 中 —— 是的,我知道:这又是一个令人迷惑的选择。但不管怎样,[别忘了我们在讨论变量的文章中说过][4],那时我们说你要用 `$` 符号来读取变量中的值,在这里也一样。所以,如果你想知道一个命令是否顺利运行,你需要在命令结束后,在运行别的命令之前马上用 `$?` 来读取 `?` 变量的值。 + +试试下面的命令: + +``` +$ find /etc -iname "*.service" +find: '/etc/audisp/plugins.d': Permission denied +/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service +/etc/systemd/system/dbus-org.freedesktop.ModemManager1.service +[......] +``` + +[正如你在上一篇文章中看到的一样][2],普通用户权限在 `/etc` 下运行 `find` 通常将抛出错误,因为它试图读取你没有权限访问的子目录。 + +所以,如果你在执行 `find` 后立马执行…… + +``` +echo $? +``` + +……,它将打印 `1`,表明存在错误。 + +(注意:当你在一行中运行两遍 `echo $?` ,你将得到一个 `0` 。这是因为 `$?` 将包含第一个 `echo $?` 的返回码,而这条命令按理说一定会执行成功。所以学习如何使用 `$?` 的第一课就是: **单独执行 `$?`** 或者将它保存在别的安全的地方 —— 比如保存在一个变量里,不然你会很快丢失它。) + +一个直接使用 `?` 变量的用法是将它并入一串链式命令列表,这样 Bash 运行这串命令时若有任何操作失败,后面命令将终止。例如,你可能熟悉构建和编译应用程序源代码的过程。你可以像这样手动一个接一个地运行它们: + +``` +$ configure +. +. +. +$ make +. +. +. +$ make install +. +. +. +``` + +你也可以把这三行合并成一行…… + +``` +$ configure; make; make install +``` + +…… 但你要希望上天保佑。 + +为什么这样说呢?因为你这样做是有缺点的,比方说 `configure` 执行失败了, Bash 将仍会尝试执行 `make` 和 `sudo make install`——就算没东西可 `make` ,实际上,是没东西会安装。 + +聪明一点的做法是: + +``` +$ configure && make && make install +``` + +这将从每个命令中获取退出码,并将其用作链式 `&&` 操作的操作数。 + +但是,没什么好抱怨的,Bash 知道如果 `configure` 返回非零结果,整个过程都会失败。如果发生这种情况,不必运行 `make` 来检查它的退出代码,因为无论如何都会失败的。因此,它放弃运行 `make`,只是将非零结果传递给下一步操作。并且,由于 `configure && make` 传递了错误,Bash 也不必运行`make install`。这意味着,在一长串命令中,你可以使用 `&&` 连接它们,并且一旦失败,你可以节省时间,因为其他命令会立即被取消运行。 + +你可以类似地使用 `||`,OR 逻辑操作符,这样就算只有一部分命令成功执行,Bash 也能运行接下来链接在一起的命令。 + +鉴于所有这些(以及我们之前介绍过的内容),你现在应该更清楚地了解我们在 [这篇文章开头][1] 出现的命令行: + +``` +mkdir test_dir 2>/dev/null || touch backup/dir/images.txt && find . -iname "*jpg" > backup/dir/images.txt & +``` + +因此,假设你从具有读写权限的目录运行上述内容,它做了什么以及如何做到这一点?它如何避免不合时宜且可能导致执行中断的错误?下周,除了给你这些答案的结果,我们将讨论圆括号,不要错过了哟! + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2019/2/logical-ampersand-bash + +作者:[Paul Brown][a] +选题:[lujun9972][b] +译者:[zero-MK](https://github.com/zero-mk) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/bro66 +[b]: https://github.com/lujun9972 +[1]: https://linux.cn/article-10587-1.html +[2]: https://linux.cn/article-10591-1.html +[3]: https://en.wikipedia.org/wiki/Modulo_operation +[4]: https://www.linux.com/blog/learn/2018/12/bash-variables-environmental-and-otherwise +[5]: https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html diff --git a/published/20190220 An Automated Way To Install Essential Applications On Ubuntu.md b/published/20190220 An Automated Way To Install Essential Applications On Ubuntu.md new file mode 100644 index 0000000000..fb7f2ffde2 --- /dev/null +++ b/published/20190220 An Automated Way To Install Essential Applications On Ubuntu.md @@ -0,0 +1,135 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10600-1.html) +[#]: subject: (An Automated Way To Install Essential Applications On Ubuntu) +[#]: via: (https://www.ostechnix.com/an-automated-way-to-install-essential-applications-on-ubuntu/) +[#]: author: (SK https://www.ostechnix.com/author/sk/) + +在 Ubuntu 上自动化安装基本应用的方法 +====== + +![](https://www.ostechnix.com/wp-content/uploads/2019/02/alfred-720x340.png) + +默认安装的 Ubuntu 并未预先安装所有必需的应用。你可能需要在网上花几个小时或者向其他 Linux 用户寻求帮助才能找到并安装 Ubuntu 所需的应用。如果你是新手,那么你肯定需要花更多的时间来学习如何从命令行(使用 `apt-get` 或 `dpkg`)或从 Ubuntu 软件中心搜索和安装应用。一些用户,特别是新手,可能希望轻松快速地安装他们喜欢的每个应用。如果你是其中之一,不用担心。在本指南中,我们将了解如何使用名为 “Alfred” 的简单命令行程序在 Ubuntu 上安装基本应用。 + +Alfred 是用 Python 语言编写的自由、开源脚本。它使用 Zenity 创建了一个简单的图形界面,用户只需点击几下鼠标即可轻松选择和安装他们选择的应用。你不必花费数小时来搜索所有必要的应用程序、PPA、deb、AppImage、snap 或 flatpak。Alfred 将所有常见的应用、工具和小程序集中在一起,并自动安装所选的应用。如果你是最近从 Windows 迁移到 Ubuntu Linux 的新手,Alfred 会帮助你在新安装的 Ubuntu 系统上进行无人值守的软件安装,而无需太多用户干预。请注意,还有一个名称相似的 Mac OS 应用,但两者有不同的用途。 + +### 在 Ubuntu 上安装 Alfred + +Alfred 安装很简单!只需下载脚本并启动它。就这么简单。 + +``` +$ wget https://raw.githubusercontent.com/derkomai/alfred/master/alfred.py +$ python3 alfred.py +``` + +或者,使用 `wget` 下载脚本,如上所示,只需将 `alfred.py` 移动到 `$PATH` 中: + +``` +$ sudo cp alfred.py /usr/local/bin/alfred +``` + +使其可执行: + +``` +$ sudo chmod +x /usr/local/bin/alfred +``` + +并使用命令启动它: + +``` +$ alfred +``` + +### 使用 Alfred 脚本轻松快速地在 Ubuntu 上安装基本应用程序 + +按照上面所说启动 Alfred 脚本。这就是 Alfred 默认界面的样子。 + +![][2] + +如你所见,Alfred 列出了许多最常用的应用类型,例如: + + * 网络浏览器, + * 邮件客户端, + * 消息, + * 云存储客户端, + * 硬件驱动程序, + * 编解码器, + * 开发者工具, + * Android, + * 文本编辑器, + * Git, + * 内核更新工具, + * 音频/视频播放器, + * 截图工具, + * 录屏工具, + * 视频编码器, + * 流媒体应用, + * 3D 建模和动画工具, + * 图像查看器和编辑器, + * CAD 软件, + * PDF 工具, + * 游戏模拟器, + * 磁盘管理工具, + * 加密工具, + * 密码管理器, + * 存档工具, + * FTP 软件, + * 系统资源监视器, + * 应用启动器等。 + +你可以选择任何一个或多个应用并立即安装它们。在这里,我将安装 “Developer bundle”,因此我选择它并单击 OK 按钮。 + +![][3] + +现在,Alfred 脚本将自动你的 Ubuntu 系统上添加必要仓库、PPA 并开始安装所选的应用。 + +![][4] + +安装完成后,你将看到以下消息。 + +![][5] + +恭喜你!已安装选定的软件包。 + +你可以使用以下命令[在 Ubuntu 上查看最近安装的应用][6]: + +``` +$ grep " install " /var/log/dpkg.log +``` + +你可能需要重启系统才能使用某些已安装的应用。类似地,你可以方便地安装列表中的任何程序。 + +提示一下,还有一个由不同的开发人员编写的类似脚本,名为 `post_install.sh`。它与 Alfred 完全相同,但提供了一些不同的应用。请查看以下链接获取更多详细信息。 + +- [Ubuntu Post Installation Script](https://www.ostechnix.com/ubuntu-post-installation-script/) + +这两个脚本能让懒惰的用户,特别是新手,只需点击几下鼠标就能够轻松快速地安装他们想要在 Ubuntu Linux 中使用的大多数常见应用、工具、更新、小程序,而无需依赖官方或者非官方文档的帮助。 + +就是这些了。希望这篇文章有用。还有更多好东西。敬请期待! + +干杯! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/an-automated-way-to-install-essential-applications-on-ubuntu/ + +作者:[SK][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/sk/ +[b]: https://github.com/lujun9972 +[1]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: http://www.ostechnix.com/wp-content/uploads/2019/02/alfred-1.png +[3]: http://www.ostechnix.com/wp-content/uploads/2019/02/alfred-2.png +[4]: http://www.ostechnix.com/wp-content/uploads/2019/02/alfred-4.png +[5]: http://www.ostechnix.com/wp-content/uploads/2019/02/alfred-5-1.png +[6]: https://www.ostechnix.com/list-installed-packages-sorted-installation-date-linux/ diff --git a/published/20190221 Bash-Insulter - A Script That Insults An User When Typing A Wrong Command.md b/published/20190221 Bash-Insulter - A Script That Insults An User When Typing A Wrong Command.md new file mode 100644 index 0000000000..d2844f8a05 --- /dev/null +++ b/published/20190221 Bash-Insulter - A Script That Insults An User When Typing A Wrong Command.md @@ -0,0 +1,188 @@ +[#]: collector: "lujun9972" +[#]: translator: "zero-mk" +[#]: reviewer: "wxy" +[#]: publisher: "wxy" +[#]: url: "https://linux.cn/article-10593-1.html" +[#]: subject: "Bash-Insulter : A Script That Insults An User When Typing A Wrong Command" +[#]: via: "https://www.2daygeek.com/bash-insulter-insults-the-user-when-typing-wrong-command/" +[#]: author: "Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/" + +Bash-Insulter:一个在输入错误命令时嘲讽用户的脚本 +====== + +这是一个非常有趣的脚本,每当用户在终端输入错误的命令时,它都会嘲讽用户。 + +它让你在解决一些问题时会感到快乐。有的人在受到终端嘲讽的时候感到不愉快。但是,当我受到终端的批评时,我真的很开心。 + +这是一个有趣的 CLI 工具,在你弄错的时候,会用随机短语嘲讽你。此外,它允许你添加自己的短语。 + +### 如何在 Linux 上安装 Bash-Insulter? + +在安装 Bash-Insulter 之前,请确保你的系统上安装了 git。如果没有,请使用以下命令安装它。 + +对于 Fedora 系统, 请使用 [DNF 命令][1] 安装 git。 + +``` +$ sudo dnf install git +``` + +对于 Debian/Ubuntu 系统,请使用 [APT-GET 命令][2] 或者 [APT 命令][3] 安装 git。 + +``` +$ sudo apt install git +``` + +对于基于 Arch Linux 的系统,请使用 [Pacman 命令][4] 安装 git。 + +``` +$ sudo pacman -S git +``` + +对于 RHEL/CentOS 系统,请使用 [YUM 命令][5] 安装 git。 + +``` +$ sudo yum install git +``` + +对于 openSUSE Leap 系统,请使用 [Zypper 命令][6] 安装 git。 + +``` +$ sudo zypper install git +``` + +我们可以通过克隆clone开发人员的 GitHub 存储库轻松地安装它。 + +首先克隆 Bash-insulter 存储库。 + +``` +$ git clone https://github.com/hkbakke/bash-insulter.git bash-insulter +``` + +将下载的文件移动到文件夹 `/etc` 下。 + +``` +$ sudo cp bash-insulter/src/bash.command-not-found /etc/ +``` + +将下面的代码添加到 `/etc/bash.bashrc` 文件中。 + +``` +$ vi /etc/bash.bashrc + +#Bash Insulter +if [ -f /etc/bash.command-not-found ]; then + . /etc/bash.command-not-found +fi +``` + +运行以下命令使更改生效。 + +``` +$ sudo source /etc/bash.bashrc +``` + +你想测试一下安装是否生效吗?你可以试试在终端上输入一些错误的命令,看看它如何嘲讽你。 + +``` +$ unam -a + +$ pin 2daygeek.com +``` + +![][8] + +如果你想附加你自己的短语,则导航到以下文件并更新它。你可以在 `messages` 部分中添加短语。 + +``` +# vi /etc/bash.command-not-found + +print_message () { + + local messages + local message + + messages=( + "Boooo!" + "Don't you know anything?" + "RTFM!" + "Haha, n00b!" + "Wow! That was impressively wrong!" + "Pathetic" + "The worst one today!" + "n00b alert!" + "Your application for reduced salary has been sent!" + "lol" + "u suk" + "lol... plz" + "plz uninstall" + "And the Darwin Award goes to.... ${USER}!" + "ERROR_INCOMPETENT_USER" + "Incompetence is also a form of competence" + "Bad." + "Fake it till you make it!" + "What is this...? Amateur hour!?" + "Come on! You can do it!" + "Nice try." + "What if... you type an actual command the next time!" + "What if I told you... it is possible to type valid commands." + "Y u no speak computer???" + "This is not Windows" + "Perhaps you should leave the command line alone..." + "Please step away from the keyboard!" + "error code: 1D10T" + "ACHTUNG! ALLES TURISTEN UND NONTEKNISCHEN LOOKENPEEPERS! DAS KOMPUTERMASCHINE IST NICHT FÜR DER GEFINGERPOKEN UND MITTENGRABEN! ODERWISE IST EASY TO SCHNAPPEN DER SPRINGENWERK, BLOWENFUSEN UND POPPENCORKEN MIT SPITZENSPARKEN. IST NICHT FÜR GEWERKEN BEI DUMMKOPFEN. DER RUBBERNECKEN SIGHTSEEREN KEEPEN DAS COTTONPICKEN HÄNDER IN DAS POCKETS MUSS. ZO RELAXEN UND WATSCHEN DER BLINKENLICHTEN." + "Pro tip: type a valid command!" + "Go outside." + "This is not a search engine." + "(╯°□°)╯︵ ┻━┻" + "¯\_(ツ)_/¯" + "So, I'm just going to go ahead and run rm -rf / for you." + "Why are you so stupid?!" + "Perhaps computers is not for you..." + "Why are you doing this to me?!" + "Don't you have anything better to do?!" + "I am _seriously_ considering 'rm -rf /'-ing myself..." + "This is why you get to see your children only once a month." + "This is why nobody likes you." + "Are you even trying?!" + "Try using your brain the next time!" + "My keyboard is not a touch screen!" + "Commands, random gibberish, who cares!" + "Typing incorrect commands, eh?" + "Are you always this stupid or are you making a special effort today?!" + "Dropped on your head as a baby, eh?" + "Brains aren't everything. In your case they're nothing." + "I don't know what makes you so stupid, but it really works." + "You are not as bad as people say, you are much, much worse." + "Two wrongs don't make a right, take your parents as an example." + "You must have been born on a highway because that's where most accidents happen." + "If what you don't know can't hurt you, you're invulnerable." + "If ignorance is bliss, you must be the happiest person on earth." + "You're proof that god has a sense of humor." + "Keep trying, someday you'll do something intelligent!" + "If shit was music, you'd be an orchestra." + "How many times do I have to flush before you go away?" + ) +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/bash-insulter-insults-the-user-when-typing-wrong-command/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[zero-mk](https://github.com/zero-mk) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[2]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[3]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[4]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ +[5]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[6]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ +[7]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[8]: https://www.2daygeek.com/wp-content/uploads/2019/02/bash-insulter-insults-the-user-when-typing-wrong-command-1.png diff --git a/published/20190223 Regex groups and numerals.md b/published/20190223 Regex groups and numerals.md new file mode 100644 index 0000000000..8e963d8fdb --- /dev/null +++ b/published/20190223 Regex groups and numerals.md @@ -0,0 +1,59 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: (wxy) +[#]: publisher: (wxy) +[#]: url: (https://linux.cn/article-10594-1.html) +[#]: subject: (Regex groups and numerals) +[#]: via: (https://leancrew.com/all-this/2019/02/regex-groups-and-numerals/) +[#]: author: (Dr.Drang https://leancrew.com) + +正则表达式的分组和数字 +====== + +大约一周前,我在编辑一个程序时想要更改一些变量名。我之前认为这将是一个简单的正则表达式查找/替换。只是这没有我想象的那么简单。 + +变量名为 `a10`、`v10` 和 `x10`,我想分别将它们改为 `a30`、`v30` 和 `x30`。我想到使用 BBEdit 的查找窗口并输入: + +![Mistaken BBEdit replacement pattern][2] + +我不能简单地 `30` 替换为 `10`,因为代码中有一些与变量无关的数字 `10`。我认为我很聪明,所以我不想写三个非正则表达式替换,`a10`、`v10` 和 `x10`,每个一个。但是我却没有注意到替换模式中的蓝色。如果我这样做了,我会看到 BBEdit 将我的替换模式解释为“匹配组 13,后面跟着 `0`,而不是”匹配组 1,后面跟着 `30`,后者是我想要的。由于匹配组 13 是空白的,因此所有变量名都会被替换为 `0`。 + +你看,BBEdit 可以在搜索模式中匹配多达 99 个分组,严格来说,我们应该在替换模式中引用它们时使用两位数字。但在大多数情况下,我们可以使用 `\1` 到 `\9` 而不是 `\01` 到 `\09`,因为这没有歧义。换句话说,如果我尝试将 `a10`、`v10` 和 `x10` 更改为 `az`、`vz` 和 `xz`,那么使用 `\1z`的替换模式就可以了。因为后面的 `z` 意味着不会误解释该模式中 `\1`。 + +因此,在撤消替换后,我将模式更改为这样: + +![Two-digit BBEdit replacement pattern][3] + +它可以正常工作。 + +还有另一个选择:命名组。这是使用 `var` 作为模式名称: + +![Named BBEdit replacement pattern][4] + +我从来都没有使用过命名组,无论正则表达式是在文本编辑器还是在脚本中。我的总体感觉是,如果模式复杂到我必须使用变量来跟踪所有组,那么我应该停下来并将问题分解为更小的部分。 + +顺便说一下,你可能已经听说 BBEdit 正在庆祝它诞生[25周年][5]。当一个有良好文档的应用有如此长的历史时,手册的积累能让人愉快地回到过去的日子。当我在 BBEdit 手册中查找命名组的表示法时,我遇到了这个说明: + +![BBEdit regex manual excerpt][6] + +BBEdit 目前的版本是 12.5。第一次出现于 2001 年的 V6.5。但手册希望确保长期客户(我记得是在 V4 的时候第一次购买)不会因行为变化而感到困惑,即使这些变化几乎发生在二十年前。 + +-------------------------------------------------------------------------------- + +via: https://leancrew.com/all-this/2019/02/regex-groups-and-numerals/ + +作者:[Dr.Drang][a] +选题:[lujun9972][b] +译者:[s](https://github.com/geekpi) +校对:[wxy](https://github.com/wxy) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://leancrew.com +[b]: https://github.com/lujun9972 +[1]: https://leancrew.com/all-this/2019/02/automation-evolution/ +[2]: https://leancrew.com/all-this/images2019/20190223-Mistaken%20BBEdit%20replacement%20pattern.png (Mistaken BBEdit replacement pattern) +[3]: https://leancrew.com/all-this/images2019/20190223-Two-digit%20BBEdit%20replacement%20pattern.png (Two-digit BBEdit replacement pattern) +[4]: https://leancrew.com/all-this/images2019/20190223-Named%20BBEdit%20replacement%20pattern.png (Named BBEdit replacement pattern) +[5]: https://merch.barebones.com/ +[6]: https://leancrew.com/all-this/images2019/20190223-BBEdit%20regex%20manual%20excerpt.png (BBEdit regex manual excerpt) diff --git a/sources/talk/20120911 Doug Bolden, Dunnet (IF).md b/sources/talk/20120911 Doug Bolden, Dunnet (IF).md new file mode 100644 index 0000000000..c856dc5be0 --- /dev/null +++ b/sources/talk/20120911 Doug Bolden, Dunnet (IF).md @@ -0,0 +1,52 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Doug Bolden, Dunnet (IF)) +[#]: via: (http://www.wyrmis.com/games/if/dunnet.html) +[#]: author: (W Doug Bolden http://www.wyrmis.com) + +Doug Bolden, Dunnet (IF) +====== + +### Dunnet (IF) + +#### Review + +When I began becoming a semi-serious hobbyist of IF last year, I mostly focused on Infocom, Adventures Unlimited, other Scott Adams based games, and freeware titles. I went on to buy some from Malinche. I picked up _1893_ and _Futureboy_ and (most recnetly) _Treasures of a Slave Kingdom_. I downloaded a lot of free games from various sites. With all of my research and playing, I never once read anything that talked about a game being bundled with Emacs. + +Partially, this is because I am a Vim guy. But I used to use Emacs. Kind of a lot. For probably my first couple of years with Linux. About as long as I have been a diehard Vim fan, now. I just never explored, it seems. + +I booted up Emacs tonight, and my fonts were hosed. Still do not know exactly why. I surfed some menus to find out what was going wrong and came across a menu option called "Adventure" under Games, which I assumed (I know, I know) meant the Crowther and Woods and 1977 variety. When I clicked it tonight, thinking that it has been a few months since I chased a bird around with a cage in a mine so I can fight off giant snakes or something, I was brought up text involving ends of roads and shovels. Trees, if shaken, that kill me with a coconut. This was not the game I thought it was. + +I dug around (or, in purely technical terms, typed "help") and got directed to [this website][1]. Well, here was an IF I had never touched before. Brand spanking new to me. I had planned to play out some _ToaSK_ tonight, but figured that could wait. Besides, I was not quite in the mood for the jocular fun of S. John Ross's commerical IF outing. I needed something a little more direct, and this apparently it. + +Most of the game plays out just like the _Colossal Cave Adventure_ cousins of the oldschool (generally commercial) IF days. There are items you pick. Each does a single task (well, there could be one exception to this, I guess). You collect treasures. Winning is a combination of getting to the end and turning in the treasures. The game slightly tweaks the formula by allowing multiple drop off points for the treasures. Since there is a weight limit, though, you usually have to drop them off at a particular time to avoid getting stuck. At several times, your "item cache" is flushed, so to speak, meaning you have to go back and replay earlier portions to find out how to bring things foward. Damage to items can occur to stop you from being able to play. Replaying is pretty much unavoidable, unless you guess outcomes just right. + +It also inherits many problems from the era it came. There is a twisty maze. I'm not sure how big it is. I just cheated and looked up a walkthrough for the maze portion. I plan on going back and replaying up to the maze bit and mapping it out, though. I was just mentally and physically beat when I played and knew that I was going to have to call it quits on the game for the night or cheat through the maze. I'm glad I cheated, because there are some interesting things after the maze. + +It also has the same sort of stilted syntax and variable levels of description that the original _Adventure_ had. Looking at one item might give you "there is nothing special about that" while looking at another might give you a sentence of flavor text. Several things mentioned in the background do not exist to the parser, which some do. Part of game play is putting up with experimenting. This includes, in cases, a tendency of room descriptions to be written from the perspective of the first time you enter. I know that the Classroom found towards the end of the game does not mention the South exit, either. There are possibly other times this occured that I didn't notice. + +It's final issue, again coming out of the era it was designed, is random death syndrome. This is not too common, but there are a few places where things that have no initially apparent fatal outcome lead to one anyhow. In some ways, this "fatal outcome" is just the game reaching an unwinnable state. For an example of the former, type "shake trees" in the first room. For an example of the latter, send either the lamp, the key, or the shovel through the ftp without switching ftp modes first. At least with the former, there is a sense of exploration in finding out new ways to die. In IF, creative deaths is a form of victory in their own right. + +_Dunnet_ has a couple of differences from most IF. The former difference is minor. There are little odd descriptions throughout the game. "This room is red" or "The towel has a picture of Snoopy one it" or "There is a cliff here" that do not seem to have an immediate effect on the game. Sure, you can jump over the cliff (and die, obviously) but but it still comes off as a bright spot in the standard description matrix. Towards the end, you will be forced to bring back these details. It makes a neat little diversion of looking around and exploring things. Most of the details are cute and/or add to the surreality of the game overall. + +The other big difference, and the one that greatly increased both my annoyance with and my enjoyment of the game, revolves around the two-three computer oriented scenes in the game. You have to type commands into two different computers throughout. One is a VAX and the other is, um, something like a PC (I forget). In both cases, there are clues to be found by knowing your way around the interface. This is a game for computer folk, so most who play it will have a sense of how to type "ls" or "dir" depending on the OS. But not all, will. Beating the game requires a general sense of computer literacy. You must know what types are in ftp. You must know how to determine what type a file is. You must know how to read a text file on a DOS style prompt. You must know something about protocols and etiquette for logging into ftp servers. All this sort of thing. If you do, or are willing to learn (I looked up some of the stuff online) then you can get past this portion with no problem. But this can be like the maze to some people, requiring several replays to get things right. + +The end result is a quirky but fun game that I wish I had known about before because now I have the feeling that my computer is hiding other secrets from me. Glad to have played. Will likely play again to see how many ways I can die. + +-------------------------------------------------------------------------------- + +via: http://www.wyrmis.com/games/if/dunnet.html + +作者:[W Doug Bolden][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: http://www.wyrmis.com +[b]: https://github.com/lujun9972 +[1]: http://www.driver-aces.com/ronnie.html diff --git a/sources/talk/20140412 My Lisp Experiences and the Development of GNU Emacs.md b/sources/talk/20140412 My Lisp Experiences and the Development of GNU Emacs.md index 60e1094af9..7be913c3bf 100644 --- a/sources/talk/20140412 My Lisp Experiences and the Development of GNU Emacs.md +++ b/sources/talk/20140412 My Lisp Experiences and the Development of GNU Emacs.md @@ -1,4 +1,3 @@ -zgj1024 is translating My Lisp Experiences and the Development of GNU Emacs ====== diff --git a/sources/talk/20180916 The Rise and Demise of RSS.md b/sources/talk/20180916 The Rise and Demise of RSS.md index 8511d220d9..d7f5c610b6 100644 --- a/sources/talk/20180916 The Rise and Demise of RSS.md +++ b/sources/talk/20180916 The Rise and Demise of RSS.md @@ -1,3 +1,4 @@ +name1e5s translating 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. diff --git a/sources/talk/20180930 A Short History of Chaosnet.md b/sources/talk/20180930 A Short History of Chaosnet.md index acbb10d53d..7ee1db8a37 100644 --- a/sources/talk/20180930 A Short History of Chaosnet.md +++ b/sources/talk/20180930 A Short History of Chaosnet.md @@ -1,3 +1,4 @@ +acyanbird translating 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: diff --git a/sources/talk/20181205 5 reasons to give Linux for the holidays.md b/sources/talk/20181205 5 reasons to give Linux for the holidays.md index 2bcd6d642c..71d65741ed 100644 --- a/sources/talk/20181205 5 reasons to give Linux for the holidays.md +++ b/sources/talk/20181205 5 reasons to give Linux for the holidays.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: ( ) +[#]: translator: (mokshal) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: subject: (5 reasons to give Linux for the holidays) diff --git a/sources/talk/20181220 7 CI-CD tools for sysadmins.md b/sources/talk/20181220 7 CI-CD tools for sysadmins.md deleted file mode 100644 index d645cf2561..0000000000 --- a/sources/talk/20181220 7 CI-CD tools for sysadmins.md +++ /dev/null @@ -1,136 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (7 CI/CD tools for sysadmins) -[#]: via: (https://opensource.com/article/18/12/cicd-tools-sysadmins) -[#]: author: (Dan Barker https://opensource.com/users/barkerd427) - -7 CI/CD tools for sysadmins -====== -An easy guide to the top open source continuous integration, continuous delivery, and continuous deployment tools. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cicd_continuous_delivery_deployment_gears.png?itok=kVlhiEkc) - -Continuous integration, continuous delivery, and continuous deployment (CI/CD) have all existed in the developer community for many years. Some organizations have involved their operations counterparts, but many haven't. For most organizations, it's imperative for their operations teams to become just as familiar with CI/CD tools and practices as their development compatriots are. - -CI/CD practices can equally apply to infrastructure and third-party applications and internally developed applications. Also, there are many different tools but all use similar models. And possibly most importantly, leading your company into this new practice will put you in a strong position within your company, and you'll be a beacon for others to follow. - -Some organizations have been using CI/CD practices on infrastructure, with tools like [Ansible][1], [Chef][2], or [Puppet][3], for several years. Other tools, like [Test Kitchen][4], allow tests to be performed on infrastructure that will eventually host applications. In fact, those tests can even deploy the application into a production-like environment and execute application-level tests with production loads in more advanced configurations. However, just getting to the point of being able to test the infrastructure individually is a huge feat. Terraform can also use Test Kitchen for even more [ephemeral][5] and [idempotent][6] infrastructure configurations than some of the original configuration-management tools. Add in Linux containers and Kubernetes, and you can now test full infrastructure and application deployments with prod-like specs and resources that come and go in hours rather than months or years. Everything is wiped out before being deployed and tested again. - -However, you can also focus on getting your network configurations or database data definition language (DDL) files into version control and start running small CI/CD pipelines on them. Maybe it just checks syntax or semantics or some best practices. Actually, this is how most development pipelines started. Once you get the scaffolding down, it will be easier to build on. You'll start to find all kinds of use cases for pipelines once you get started. - -For example, I regularly write a newsletter within my company, and I maintain it in version control using [MJML][7]. I needed to be able to host a web version, and some folks liked being able to get a PDF, so I built a [pipeline][8]. Now when I create a new newsletter, I submit it for a merge request in GitLab. This automatically creates an index.html with links to HTML and PDF versions of the newsletter. The HTML and PDF files are also created in the pipeline. None of this is published until someone comes and reviews these artifacts. Then, GitLab Pages publishes the website and I can pull down the HTML to send as a newsletter. In the future, I'll automatically send the newsletter when the merge request is merged or after a special approval step. This seems simple, but it has saved me a lot of time. This is really at the core of what these tools can do for you. They will save you time. - -The key is creating tools to work in the abstract so that they can apply to multiple problems with little change. I should also note that what I created required almost no code except [some light HTML templating][9], some [node to loop through the HTML files][10], and some more [node to populate the index page with all the HTML pages and PDFs][11]. - -Some of this might look a little complex, but most of it was taken from the tutorials of the different tools I'm using. And many developers are happy to work with you on these types of things, as they might also find them useful when they're done. The links I've provided are to a newsletter we plan to start for [DevOps KC][12], and all the code for creating the site comes from the work I did on our internal newsletter. - -Many of the tools listed below can offer this type of interaction, but some offer a slightly different model. The emerging model in this space is that of a declarative description of a pipeline in something like YAML with each stage being ephemeral and idempotent. Many of these systems also ensure correct sequencing by creating a [directed acyclic graph][13] (DAG) over the different stages of the pipeline. - -These stages are often run in Linux containers and can do anything you can do in a container. Some tools, like [Spinnaker][14], focus only on the deployment component and offer some operational features that others don't normally include. [Jenkins][15] has generally kept pipelines in an XML format and most interactions occur within the GUI, but more recent implementations have used a [domain specific language][16] (DSL) using [Groovy][17]. Further, Jenkins jobs normally execute on nodes with a special Java agent installed and consist of a mix of plugins and pre-installed components. - -Jenkins introduced pipelines in its tool, but they were a bit challenging to use and contained several caveats. Recently, the creator of Jenkins decided to move the community toward a couple different initiatives that will hopefully breathe new life into the project—which is the one that really brought CI/CD to the masses. I think its most interesting initiative is creating a Cloud Native Jenkins that can turn a Kubernetes cluster into a Jenkins CI/CD platform. - -As you learn more about these tools and start bringing these practices into your company or your operations division, you'll quickly gain followers. You will increase your own productivity as well as that of others. We all have years of backlog to get to—how much would your co-workers love if you could give them enough time to start tackling that backlog? Not only that, but your customers will start to see increased application reliability, and your management will see you as a force multiplier. That certainly can't hurt during your next salary negotiation or when interviewing with all your new skills. - -Let's dig into the tools a bit more. We'll briefly cover each one and share links to more information. - -### GitLab CI - -GitLab is a fairly new entrant to the CI/CD space, but it's already achieved the top spot in the [Forrester Wave for Continuous Integration Tools][20]. That's a huge achievement in such a crowded and highly qualified field. What makes GitLab CI so great? It uses a YAML file to describe the entire pipeline. It also has a functionality called Auto DevOps that allows for simpler projects to have a pipeline built automatically with multiple tests built-in. This system uses [Herokuish buildpacks][21] to determine the language and how to build the application. Some languages can also manage databases, which is a real game-changer for building new applications and getting them deployed to production from the beginning of the development process. The system has native integrations into Kubernetes and will deploy your application automatically into a Kubernetes cluster using one of several different deployment methodologies, like percentage-based rollouts and blue-green deployments. - -In addition to its CI functionality, GitLab offers many complementary features like operations and monitoring with Prometheus deployed automatically with your application; portfolio and project management using GitLab Issues, Epics, and Milestones; security checks built into the pipeline with the results provided as an aggregate across multiple projects; and the ability to edit code right in GitLab using the WebIDE, which can even provide a preview or execute part of a pipeline for faster feedback. - -### GoCD - -GoCD comes from the great minds at Thoughtworks, which is testimony enough for its capabilities and efficiency. To me, GoCD's main differentiator from the rest of the pack is its [Value Stream Map][22] (VSM) feature. In fact, pipelines can be chained together with one pipeline providing the "material" for the next pipeline. This allows for increased independence for different teams with different responsibilities in the deployment process. This may be a useful feature when introducing this type of system in older organizations that intend to keep these teams separate—but having everyone using the same tool will make it easier later to find bottlenecks in the VSM and reorganize the teams or work to increase efficiencies. - -It's incredibly valuable to have a VSM for each product in a company; that GoCD allows this to be [described in JSON or YAML][23] in version control and presented visually with all the data around wait times makes this tool even more valuable to an organization trying to understand itself better. Start by installing GoCD and mapping out your process with only manual approval gates. Then have each team use the manual approvals so you can start collecting data on where bottlenecks might exist. - -### Travis CI - -Travis CI was my first experience with a Software as a Service (SaaS) CI system, and it's pretty awesome. The pipelines are stored as YAML with your source code, and it integrates seamlessly with tools like GitHub. I don't remember the last time a pipeline failed because of Travis CI or the integration—Travis CI has a very high uptime. Not only can it be used as SaaS, but it also has a version that can be hosted. I haven't run that version—there were a lot of components, and it looked a bit daunting to install all of it. I'm guessing it would be much easier to deploy it all to Kubernetes with [Helm charts provided by Travis CI][26]. Those charts don't deploy everything yet, but I'm sure it will grow even more in the future. There is also an enterprise version if you don't want to deal with the hassle. - -However, if you're developing open source code, you can use the SaaS version of Travis CI for free. That is an awesome service provided by an awesome team! This alleviates a lot of overhead and allows you to use a fairly common platform for developing open source code without having to run anything. - -### Jenkins - -Jenkins is the original, the venerable, de facto standard in CI/CD. If you haven't already, you need to read "[Jenkins: Shifting Gears][27]" from Kohsuke, the creator of Jenkins and CTO of CloudBees. It sums up all of my feelings about Jenkins and the community from the last decade. What he describes is something that has been needed for several years, and I'm happy CloudBees is taking the lead on this transformation. Jenkins will be a bit overwhelming to most non-developers and has long been a burden on its administrators. However, these are items they're aiming to fix. - -[Jenkins Configuration as Code][28] (JCasC) should help fix the complex configuration issues that have plagued admins for years. This will allow for a zero-touch configuration of Jenkins masters through a YAML file, similar to other CI/CD systems. [Jenkins Evergreen][29] aims to make this process even easier by providing predefined Jenkins configurations based on different use cases. These distributions should be easier to maintain and upgrade than the normal Jenkins distribution. - -Jenkins 2 introduced native pipeline functionality with two types of pipelines, which [I discuss][30] in a LISA17 presentation. Neither is as easy to navigate as YAML when you're doing something simple, but they're quite nice for doing more complex tasks. - -[Jenkins X][31] is the full transformation of Jenkins and will likely be the implementation of Cloud Native Jenkins (or at least the thing most users see when using Cloud Native Jenkins). It will take JCasC and Evergreen and use them at their best natively on Kubernetes. These are exciting times for Jenkins, and I look forward to its innovation and continued leadership in this space. - -### Concourse CI - -I was first introduced to Concourse through folks at Pivotal Labs when it was an early beta version—there weren't many tools like it at the time. The system is made of microservices, and each job runs within a container. One of its most useful features that other tools don't have is the ability to run a job from your local system with your local changes. This means you can develop locally (assuming you have a connection to the Concourse server) and run your builds just as they'll run in the real build pipeline. Also, you can rerun failed builds from your local system and inject specific changes to test your fixes. - -Concourse also has a simple extension system that relies on the fundamental concept of resources. Basically, each new feature you want to provide to your pipeline can be implemented in a Docker image and included as a new resource type in your configuration. This keeps all functionality encapsulated in a single, immutable artifact that can be upgraded and modified independently, and breaking changes don't necessarily have to break all your builds at the same time. - -### Spinnaker - -Spinnaker comes from Netflix and is more focused on continuous deployment than continuous integration. It can integrate with other tools, including Travis and Jenkins, to kick off test and deployment pipelines. It also has integrations with monitoring tools like Prometheus and Datadog to make decisions about deployments based on metrics provided by these systems. For example, the canary deployment uses a judge concept and the metrics being collected to determine if the latest canary deployment has caused any degradation in pertinent metrics and should be rolled back or if deployment can continue. - -A couple of additional, unique features related to deployments cover an area that is often overlooked when discussing continuous deployment, and might even seem antithetical, but is critical to success: Spinnaker helps make continuous deployment a little less continuous. It will prevent a stage from running during certain times to prevent a deployment from occurring during a critical time in the application lifecycle. It can also enforce manual approvals to ensure the release occurs when the business will benefit the most from the change. In fact, the whole point of continuous integration and continuous deployment is to be ready to deploy changes as quickly as the business needs to change. - -### Screwdriver - -Screwdriver is an impressively simple piece of engineering. It uses a microservices approach and relies on tools like Nomad, Kubernetes, and Docker to act as its execution engine. There is a pretty good [deployment tutorial][34] for deploying to AWS and Kubernetes, but it could be improved once the in-progress [Helm chart][35] is completed. - -Screwdriver also uses YAML for its pipeline descriptions and includes a lot of sensible defaults, so there's less boilerplate configuration for each pipeline. The configuration describes an advanced workflow that can have complex dependencies among jobs. For example, a job can be guaranteed to run after or before another job. Jobs can run in parallel and be joined afterward. You can also use logical operators to run a job, for example, if any of its dependencies are successful or only if all are successful. Even better is that you can specify certain jobs to be triggered from a pull request. Also, dependent jobs won't run when this occurs, which allows easy segregation of your pipeline for when an artifact should go to production and when it still needs to be reviewed. - -This is only a brief description of these CI/CD tools—each has even more cool features and differentiators you can investigate. They are all open source and free to use, so go deploy them and see which one fits your needs best. - -### What to read next - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/12/cicd-tools-sysadmins - -作者:[Dan Barker][a] -选题:[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/barkerd427 -[b]: https://github.com/lujun9972 -[1]: https://www.ansible.com/ -[2]: https://www.chef.io/ -[3]: https://puppet.com/ -[4]: https://github.com/test-kitchen/test-kitchen -[5]: https://www.merriam-webster.com/dictionary/ephemeral -[6]: https://en.wikipedia.org/wiki/Idempotence -[7]: https://mjml.io/ -[8]: https://gitlab.com/devopskc/newsletter/blob/master/.gitlab-ci.yml -[9]: https://gitlab.com/devopskc/newsletter/blob/master/index/index.html -[10]: https://gitlab.com/devopskc/newsletter/blob/master/html-to-pdf.js -[11]: https://gitlab.com/devopskc/newsletter/blob/master/populate-index.js -[12]: https://devopskc.com/ -[13]: https://en.wikipedia.org/wiki/Directed_acyclic_graph -[14]: https://www.spinnaker.io/ -[15]: https://jenkins.io/ -[16]: https://martinfowler.com/books/dsl.html -[17]: http://groovy-lang.org/ -[18]: https://about.gitlab.com/product/continuous-integration/ -[19]: https://gitlab.com/gitlab-org/gitlab-ce/ -[20]: https://about.gitlab.com/2017/09/27/gitlab-leader-continuous-integration-forrester-wave/ -[21]: https://github.com/gliderlabs/herokuish -[22]: https://www.gocd.org/getting-started/part-3/#value_stream_map -[23]: https://docs.gocd.org/current/advanced_usage/pipelines_as_code.html -[24]: https://docs.travis-ci.com/ -[25]: https://github.com/travis-ci/travis-ci -[26]: https://github.com/travis-ci/kubernetes-config -[27]: https://jenkins.io/blog/2018/08/31/shifting-gears/ -[28]: https://jenkins.io/projects/jcasc/ -[29]: https://github.com/jenkinsci/jep/blob/master/jep/300/README.adoc -[30]: https://danbarker.codes/talk/lisa17-becoming-plumber-building-deployment-pipelines/ -[31]: https://jenkins-x.io/ -[32]: https://concourse-ci.org/ -[33]: https://github.com/concourse/concourse -[34]: https://docs.screwdriver.cd/cluster-management/kubernetes -[35]: https://github.com/screwdriver-cd/screwdriver-chart diff --git a/sources/talk/20190110 Toyota Motors and its Linux Journey.md b/sources/talk/20190110 Toyota Motors and its Linux Journey.md deleted file mode 100644 index 1d76ffe0b6..0000000000 --- a/sources/talk/20190110 Toyota Motors and its Linux Journey.md +++ /dev/null @@ -1,64 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Toyota Motors and its Linux Journey) -[#]: via: (https://itsfoss.com/toyota-motors-linux-journey) -[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) - -Toyota Motors and its Linux Journey -====== - -**This is a community submission from It’s FOSS reader Malcolm Dean.** - -I spoke with Brian R Lyons of TMNA Toyota Motor Corp North America about the implementation of Linux in Toyota and Lexus infotainment systems. I came to find out there is an Automotive Grade Linux (AGL) being used by several autmobile manufacturers. - -I put together a short article comprising of my discussion with Brian about Toyota and its tryst with Linux. I hope that Linux enthusiasts will like this quick little chat. - -All [Toyota vehicles and Lexus vehicles are going to use Automotive Grade Linux][1] (AGL) majorly for the infotainment system. This is instrumental in Toyota Motor Corp because as per Mr. Lyons “As a technology leader, Toyota realized that adopting open source development methodology is the best way to keep up with the rapid pace of new technologies”. - -Toyota among other automotive companies thought, going with a Linux based operating system might be cheaper and quicker when it comes to updates, and upgrades compared to using proprietary software. - -Wow! Finally Linux in a vehicle. I use Linux every day on my desktop; what a great way to expand the use of this awesome software to a completely different industry. - -I was curious when Toyota decided to use the [Automotive Grade Linux][2] (AGL). According to Mr. Lyons, it goes back to 2011. - -> “Toyota has been an active member and contributor to AGL since its launch more than five years ago, collaborating with other OEMs, Tier 1s and suppliers to develop a robust, Linux-based platform with increased security and capabilities” - -![Toyota Infotainment][3] - -In 2011, [Toyota joined the Linux Foundation][4] and started discussions about IVI (In-Vehicle Infotainment) software with other car OEMs and software companies. As a result, in 2012, Automotive Grade Linux working group was formed in the Linux Foundation. - -What Toyota did at first in AGL group was to take “code first” approach as normal as in the open source domains, and then start the conversation about the initial direction by specifying requirement specifications which had been discussed among car OEMs, IVI Tier-1 companies, software companies, and so on. - -Toyota had already realized that sharing the software code among Tier1 companies was going to essential at the time when it joined the Linux Foundation. This was because the cost of maintaining such a huge software was very costly and was no longer differentiation by Tier1 companies. Toyota and its Tier1 supplier companies wanted to spend more resources n new functions and new user experiences rather than maintaining conventional code all by themselves. - -This is a huge thing as automotive companies have gone in together to further their cooperation. Many companies have adopted this after finding proprietary software to be expensive. - -Today, AGL is used for all Toyota and Lexus vehicles and is used in all markets where vehicles are sold. - -As someone who has sold cars for Lexus, I think this is a huge step forward. I and other sales associates had many customers who would come back to speak with a technology specialist to learn about the full capabilities of their infotainment system. - -I see this as a huge step forward for the Linux community, and users. The operating system we use on a daily basis is being put to use right in front of us albeit in a modified form but is there none-the-less. - -Where does this lead? Hopefully a better user-friendly and less glitchy experience for consumers. - - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/toyota-motors-linux-journey - -作者:[Abhishek Prakash][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/abhishek/ -[b]: https://github.com/lujun9972 -[1]: https://www.linuxfoundation.org/press-release/2018/01/automotive-grade-linux-hits-road-globally-toyota-amazon-alexa-joins-agl-support-voice-recognition/ -[2]: https://www.automotivelinux.org/ -[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/toyota-interiors.jpg?resize=800%2C450&ssl=1 -[4]: https://www.linuxfoundation.org/press-release/2011/07/toyota-joins-linux-foundation/ diff --git a/sources/talk/20190121 Booting Linux faster.md b/sources/talk/20190121 Booting Linux faster.md deleted file mode 100644 index ef79351e0e..0000000000 --- a/sources/talk/20190121 Booting Linux faster.md +++ /dev/null @@ -1,54 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Booting Linux faster) -[#]: via: (https://opensource.com/article/19/1/booting-linux-faster) -[#]: author: (Stewart Smith https://opensource.com/users/stewart-ibm) - -Booting Linux faster -====== -Doing Linux kernel and firmware development leads to lots of reboots and lots of wasted time. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tux_linux_penguin_code_binary.jpg?itok=TxGxW0KY) -Of all the computers I've ever owned or used, the one that booted the quickest was from the 1980s; by the time your hand moved from the power switch to the keyboard, the BASIC interpreter was ready for your commands. Modern computers take anywhere from 15 seconds for a laptop to minutes for a small home server to boot. Why is there such a difference in boot times? - -A microcomputer from the 1980s that booted straight to a BASIC prompt had a very simple CPU that started fetching and executing instructions from a memory address immediately upon getting power. Since these systems had BASIC in ROM, there was no loading time—you got to the BASIC prompt really quickly. More complex systems of that same era, such as the IBM PC or Macintosh, took a significant time to boot (~30 seconds), although this was mostly due to having to read the operating system (OS) off a floppy disk. Only a handful of seconds were spent in firmware before being able to load an OS. - -Modern servers typically spend minutes, rather than seconds, in firmware before getting to the point of booting an OS from disk. This is largely due to modern systems' increased complexity. No longer can a CPU just come up and start executing instructions at full speed; we've become accustomed to CPU frequency scaling, idle states that save a lot of power, and multiple CPU cores. In fact, inside modern CPUs are a surprising number of simpler CPUs that help start the main CPU cores and provide runtime services such as throttling the frequency when it gets too hot. On most CPU architectures, the code running on these cores inside your CPU is provided as opaque binary blobs. - -On OpenPOWER systems, every instruction executed on every core inside the CPU is open source software. On machines with [OpenBMC][1] (such as IBM's AC922 system and Raptor's TALOS II and Blackbird systems), this extends to the code running on the Baseboard Management Controller as well. This means we can get a tremendous amount of insight into what takes so long from the time you plug in a power cable to the time a familiar login prompt is displayed. - -If you're part of a team that works on the Linux kernel, you probably boot a lot of kernels. If you're part of a team that works on firmware, you're probably going to boot a lot of different firmware images, followed by an OS to ensure your firmware still works. If we can reduce the hardware's boot time, these teams can become more productive, and end users may be grateful when they're setting up systems or rebooting to install firmware or OS updates. - -Over the years, many improvements have been made to Linux distributions' boot time. Modern init systems deal well with doing things concurrently and on-demand. On a modern system, once the kernel starts executing, it can take very few seconds to get to a login prompt. This handful of seconds are not the place to optimize boot time; we have to go earlier: before we get to the OS. - -On OpenPOWER systems, the firmware loads an OS by booting a Linux kernel stored in the firmware flash chip that runs a userspace program called [Petitboot][2] to find the disk that holds the OS the user wants to boot and [kexec][3][()][3] to it. This code reuse leverages the efforts that have gone into making Linux boot quicker. Even so, we found places in our kernel config and userspace where we could improve and easily shave seconds off boot time. With these optimizations, booting the Petitboot environment is a single-digit percentage of boot time, so we had to find more improvements elsewhere. - -Before the Petitboot environment starts, there's a prior bit of firmware called [Skiboot][4], and before that there's [Hostboot][5]. Prior to Hostboot is the [Self-Boot Engine][6], a separate core on the die that gets a single CPU core up and executing instructions out of Level 3 cache. These components are where we can make the most headway in reducing boot time, as they take up the overwhelming majority of it. Perhaps some of these components aren't optimized enough or doing as much in parallel as they could be? - -Another avenue of attack is reboot time rather than boot time. On a reboot, do we really need to reinitialize all the hardware? - -Like any modern system, the solutions to improving boot (and reboot) time have been a mixture of doing more in parallel, dealing with legacy, and (arguably) cheating. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/booting-linux-faster - -作者:[Stewart Smith][a] -选题:[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/stewart-ibm -[b]: https://github.com/lujun9972 -[1]: https://en.wikipedia.org/wiki/OpenBMC -[2]: https://github.com/open-power/petitboot -[3]: https://en.wikipedia.org/wiki/Kexec -[4]: https://github.com/open-power/skiboot -[5]: https://github.com/open-power/hostboot -[6]: https://github.com/open-power/sbe -[7]: https://linux.conf.au/schedule/presentation/105/ -[8]: https://linux.conf.au/ diff --git a/sources/talk/20190123 Book Review- Fundamentals of Linux.md b/sources/talk/20190123 Book Review- Fundamentals of Linux.md deleted file mode 100644 index 5e0cffd9bc..0000000000 --- a/sources/talk/20190123 Book Review- Fundamentals of Linux.md +++ /dev/null @@ -1,74 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Book Review: Fundamentals of Linux) -[#]: via: (https://itsfoss.com/fundamentals-of-linux-book-review) -[#]: author: (John Paul https://itsfoss.com/author/john/) - -Book Review: Fundamentals of Linux -====== - -There are many great books that cover the basics of what Linux is and how it works. Today, I will be taking a look at one such book. Today, the subject of our discussion is [Fundamentals of Linux][1] by Oliver Pelz and is published by [PacktPub][2]. - -[Oliver Pelz][3] has over ten years of experience as a software developer and a system administrator. He holds a degree in bioinformatics. - -### What is the book ‘Fundamentals of Linux’ about? - -![Fundamental of Linux books][4] - -As can be guessed from the title, the goal of Fundamentals of Linux is to give the reader a strong foundation from which to learn about the Linux command line. The book is a little over two hundred pages long, so it only focuses on teaching the everyday tasks and problems that users commonly encounter. The book is designed for readers who want to become Linux administrators. - -The first chapter starts out by giving an overview of virtualization. From there the author instructs how to create a virtual instance of [CentOS][5] in [VirtualBox][6], how to clone it, and how to use snapshots. You will also learn how to connect to the virtual machines via SSH. - -The second chapter covers the basics of the Linux command line. This includes shell globbing, shell expansion, how to work with file names that contain spaces or special characters. It also explains how to interpret a command’s manual page, as well as, how to use `sed`, `awk`, and to navigate the Linux file system. - -The third chapter takes a more in-depth look at the Linux file system. You will learn how files are linked in Linux and how to search for them. You will also be given an overview of users, groups and file permissions. Since the chapter focuses on interacting with files, it tells how to read text files from the command line, as well as, an overview of how to use the VIM editor. - -Chapter four focuses on using the command line. It covers important commands, such as `cat`, `sort`, `awk`. `tee`, `tar`, `rsync`, `nmap`, `htop` and more. You will learn what processes are and how they communicate with each other. This chapter also includes an introduction to Bash shell scripting. - -The fifth and final chapter covers networking on Linux and other advanced command line concepts. The author discusses how Linux handles networking and gives examples using multiple virtual machines. He also covers how to install new programs and how to set up a firewall. - -### Thoughts on the book - -Fundamentals of Linux might seem short at five chapters and a little over two hundred pages. However, quite a bit of information is covered. You are given everything that you need to get going on the command line. - -The book’s sole focus on the command line is one thing to keep in mind. You won’t get any information on how to use a graphical user interface. That is partially because Linux has so many different desktop environments and so many similar system applications that it would be hard to write a book that could cover all of the variables. It is also partially because the book is aimed at potential Linux administrators. - -I was kinda surprised to see that the author used [CentOS][7] to teach Linux. I would have expected him to use a more common Linux distro, like Ubuntu, Debian, or Fedora. However, because it is a distro designed for servers very little changes over time, so it is a very stable basis for a course on Linux basics. - -I’ve used Linux for over half a decade. I spent most of that time using desktop Linux. I dove into the terminal when I needed to, but didn’t spend lots of time there. I have performed many of the actions covered in this book using a mouse. Now, I know how to do the same things via the terminal. It won’t change the way I do my tasks, but it will help me understand what goes on behind the curtain. - -If you have either just started using Linux or are planning to do so in the future, I would not recommend this book. It might be a little overwhelming. If you have already spent some time with Linux or can quickly grasp the technical language, this book may very well be for you. - -If you think this book is apt for your learning needs, you can get the book from the link below: - -We will be trying to review more Linux books in coming months so stay tuned with us. - -What is your favorite introductory book on Linux? 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/fundamentals-of-linux-book-review - -作者:[John Paul][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/john/ -[b]: https://github.com/lujun9972 -[1]: https://www.packtpub.com/networking-and-servers/fundamentals-linux -[2]: https://www.packtpub.com/ -[3]: http://www.oliverpelz.de/index.html -[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/fundamentals-of-linux-book-review.jpeg?resize=800%2C450&ssl=1 -[5]: https://centos.org/ -[6]: https://www.virtualbox.org/ -[7]: https://www.centos.org/ -[8]: http://reddit.com/r/linuxusersgroup diff --git a/sources/talk/20190131 4 confusing open source license scenarios and how to navigate them.md b/sources/talk/20190131 4 confusing open source license scenarios and how to navigate them.md new file mode 100644 index 0000000000..fd93cdd9a6 --- /dev/null +++ b/sources/talk/20190131 4 confusing open source license scenarios and how to navigate them.md @@ -0,0 +1,59 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (4 confusing open source license scenarios and how to navigate them) +[#]: via: (https://opensource.com/article/19/1/open-source-license-scenarios) +[#]: author: (P.Kevin Nelson https://opensource.com/users/pkn4645) + +4 confusing open source license scenarios and how to navigate them +====== + +Before you begin using a piece of software, make sure you fully understand the terms of its license. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LAW_openisopen.png?itok=FjmDxIaL) + +As an attorney running an open source program office for a Fortune 500 corporation, I am often asked to look into a product or component where there seems to be confusion as to the licensing model. Under what terms can the code be used, and what obligations run with such use? This often happens when the code or the associated project community does not clearly indicate availability under a [commonly accepted open source license][1]. The confusion is understandable as copyright owners often evolve their products and services in different directions in response to market demands. Here are some of the scenarios I commonly discover and how you can approach each situation. + +### Multiple licenses + +The product is truly open source with an [Open Source Initiative][2] (OSI) open source-approved license, but has changed licensing models at least once if not multiple times throughout its lifespan. This scenario is fairly easy to address; the user simply has to decide if the latest version with its attendant features and bug fixes is worth the conditions to be compliant with the current license. If so, great. If not, then the user can move back in time to a version released under a more palatable license and start from that fork, understanding that there may not be an active community for support and continued development. + +### Old open source + +This is a variation on the multiple licenses model with the twist that current licensing is proprietary only. You have to use an older version to take advantage of open source terms and conditions. Most often, the product was released under a valid open source license up to a certain point in its development, but then the copyright holder chose to evolve the code in a proprietary fashion and offer new releases only under proprietary commercial licensing terms. So, if you want the newest capabilities, you have to purchase a proprietary license, and you most likely will not get a copy of the underlying source code. Most often the open source community that grew up around the original code line falls away once the members understand there will be no further commitment from the copyright holder to the open source branch. While this scenario is understandable from the copyright holder's perspective, it can be seen as "burning a bridge" to the open source community. It would be very difficult to again leverage the benefits of the open source contribution models once a project owner follows this path. + +### Open core + +By far the most common discovery is that a product has both an open source-licensed "community edition" and a proprietary-licensed commercial offering, commonly referred to as open core. This is often encouraging to potential consumers, as it gives them a "try before you buy" option or even a chance to influence both versions of the product by becoming an active member of the community. I usually encourage clients to begin with the community version, get involved, and see what they can achieve. Then, if the product becomes a crucial part of their business plan, they have the option to upgrade to the proprietary level at any time. + +### Freemium + +The component is not open source at all, but instead it is released under some version of the "freemium" model. A version with restricted or time-limited functionality can be downloaded with no immediate purchase required. However, since the source code is usually not provided and its accompanying license does not allow perpetual use, the creation of derivative works, nor further distribution, it is definitely not open source. In this scenario, it is usually best to pass unless you are prepared to purchase a proprietary license and accept all attendant terms and conditions of use. Users are often the most disappointed in this outcome as it has somewhat of a deceptive feel. + +### OSI compliant + +Of course, the happy path I haven't mentioned is to discover the project has a single, clear, OSI-compliant license. In those situations, open source software is as easy as downloading and going forward within appropriate use. + +Each of the more complex scenarios described above can present problems to potential development projects, but consultation with skilled procurement or intellectual property professionals with regard to licensing lineage can reveal excellent opportunities. + +An earlier version of this article was published on [OSS Law][3] and is republished with the author's permission. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/open-source-license-scenarios + +作者:[P.Kevin Nelson][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/pkn4645 +[b]: https://github.com/lujun9972 +[1]: https://opensource.org/licenses +[2]: https://opensource.org/licenses/category +[3]: http://www.pknlaw.com/2017/06/i-thought-that-was-open-source.html diff --git a/sources/talk/20190131 OOP Before OOP with Simula.md b/sources/talk/20190131 OOP Before OOP with Simula.md new file mode 100644 index 0000000000..cae9d9bd3a --- /dev/null +++ b/sources/talk/20190131 OOP Before OOP with Simula.md @@ -0,0 +1,203 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (OOP Before OOP with Simula) +[#]: via: (https://twobithistory.org/2019/01/31/simula.html) +[#]: author: (Sinclair Target https://twobithistory.org) + +OOP Before OOP with Simula +====== + +Imagine that you are sitting on the grassy bank of a river. Ahead of you, the water flows past swiftly. The afternoon sun has put you in an idle, philosophical mood, and you begin to wonder whether the river in front of you really exists at all. Sure, large volumes of water are going by only a few feet away. But what is this thing that you are calling a “river”? After all, the water you see is here and then gone, to be replaced only by more and different water. It doesn’t seem like the word “river” refers to any fixed thing in front of you at all. + +In 2009, Rich Hickey, the creator of Clojure, gave [an excellent talk][1] about why this philosophical quandary poses a problem for the object-oriented programming paradigm. He argues that we think of an object in a computer program the same way we think of a river—we imagine that the object has a fixed identity, even though many or all of the object’s properties will change over time. Doing this is a mistake, because we have no way of distinguishing between an object instance in one state and the same object instance in another state. We have no explicit notion of time in our programs. We just breezily use the same name everywhere and hope that the object is in the state we expect it to be in when we reference it. Inevitably, we write bugs. + +The solution, Hickey concludes, is that we ought to model the world not as a collection of mutable objects but a collection of processes acting on immutable data. We should think of each object as a “river” of causally related states. In sum, you should use a functional language like Clojure. + +![][2] +The author, on a hike, pondering the ontological commitments +of object-oriented programming. + +Since Hickey gave his talk in 2009, interest in functional programming languages has grown, and functional programming idioms have found their way into the most popular object-oriented languages. Even so, most programmers continue to instantiate objects and mutate them in place every day. And they have been doing it for so long that it is hard to imagine that programming could ever look different. + +I wanted to write an article about Simula and imagined that it would mostly be about when and how object-oriented constructs we are familiar with today were added to the language. But I think the more interesting story is about how Simula was originally so unlike modern object-oriented programming languages. This shouldn’t be a surprise, because the object-oriented paradigm we know now did not spring into existence fully formed. There were two major versions of Simula: Simula I and Simula 67. Simula 67 brought the world classes, class hierarchies, and virtual methods. But Simula I was a first draft that experimented with other ideas about how data and procedures could be bundled together. The Simula I model is not a functional model like the one Hickey proposes, but it does focus on processes that unfold over time rather than objects with hidden state that interact with each other. Had Simula 67 stuck with more of Simula I’s ideas, the object-oriented paradigm we know today might have looked very different indeed—and that contingency should teach us to be wary of assuming that the current paradigm will dominate forever. + +### Simula 0 Through 67 + +Simula was created by two Norwegians, Kristen Nygaard and Ole-Johan Dahl. + +In the late 1950s, Nygaard was employed by the Norwegian Defense Research Establishment (NDRE), a research institute affiliated with the Norwegian military. While there, he developed Monte Carlo simulations used for nuclear reactor design and operations research. These simulations were at first done by hand and then eventually programmed and run on a Ferranti Mercury. Nygaard soon found that he wanted a higher-level way to describe these simulations to a computer. + +The kind of simulation that Nygaard commonly developed is known as a “discrete event model.” The simulation captures how a sequence of events change the state of a system over time—but the important property here is that the simulation can jump from one event to the next, since the events are discrete and nothing changes in the system between events. This kind of modeling, according to a paper that Nygaard and Dahl presented about Simula in 1966, was increasingly being used to analyze “nerve networks, communication systems, traffic flow, production systems, administrative systems, social systems, etc.” So Nygaard thought that other people might want a higher-level way to describe these simulations too. He began looking for someone that could help him implement what he called his “Simulation Language” or “Monte Carlo Compiler.” + +Dahl, who had also been employed by NDRE, where he had worked on language design, came aboard at this point to play Wozniak to Nygaard’s Jobs. Over the next year or so, Nygaard and Dahl worked to develop what has been called “Simula 0.” This early version of the language was going to be merely a modest extension to ALGOL 60, and the plan was to implement it as a preprocessor. The language was then much less abstract than what came later. The primary language constructs were “stations” and “customers.” These could be used to model certain discrete event networks; Nygaard and Dahl give an example simulating airport departures. But Nygaard and Dahl eventually came up with a more general language construct that could represent both “stations” and “customers” and also model a wider range of simulations. This was the first of two major generalizations that took Simula from being an application-specific ALGOL package to a general-purpose programming language. + +In Simula I, there were no “stations” or “customers,” but these could be recreated using “processes.” A process was a bundle of data attributes associated with a single action known as the process’ operating rule. You might think of a process as an object with only a single method, called something like `run()`. This analogy is imperfect though, because each process’ operating rule could be suspended or resumed at any time—the operating rules were a kind of coroutine. A Simula I program would model a system as a set of processes that conceptually all ran in parallel. Only one process could actually be “current” at any time, but once a process suspended itself the next queued process would automatically take over. As the simulation ran, behind the scenes, Simula would keep a timeline of “event notices” that tracked when each process should be resumed. In order to resume a suspended process, Simula needed to keep track of multiple call stacks. This meant that Simula could no longer be an ALGOL preprocessor, because ALGOL had only once call stack. Nygaard and Dahl were committed to writing their own compiler. + +In their paper introducing this system, Nygaard and Dahl illustrate its use by implementing a simulation of a factory with a limited number of machines that can serve orders. The process here is the order, which starts by looking for an available machine, suspends itself to wait for one if none are available, and then runs to completion once a free machine is found. There is a definition of the order process that is then used to instantiate several different order instances, but no methods are ever called on these instances. The main part of the program just creates the processes and sets them running. + +The first Simula I compiler was finished in 1965. The language grew popular at the Norwegian Computer Center, where Nygaard and Dahl had gone to work after leaving NDRE. Implementations of Simula I were made available to UNIVAC users and to Burroughs B5500 users. Nygaard and Dahl did a consulting deal with a Swedish company called ASEA that involved using Simula to run job shop simulations. But Nygaard and Dahl soon realized that Simula could be used to write programs that had nothing to do with simulation at all. + +Stein Krogdahl, a professor at the University of Oslo that has written about the history of Simula, claims that “the spark that really made the development of a new general-purpose language take off” was [a paper called “Record Handling”][3] by the British computer scientist C.A.R. Hoare. If you read Hoare’s paper now, this is easy to believe. I’m surprised that you don’t hear Hoare’s name more often when people talk about the history of object-oriented languages. Consider this excerpt from his paper: + +> The proposal envisages the existence inside the computer during the execution of the program, of an arbitrary number of records, each of which represents some object which is of past, present or future interest to the programmer. The program keeps dynamic control of the number of records in existence, and can create new records or destroy existing ones in accordance with the requirements of the task in hand. + +> Each record in the computer must belong to one of a limited number of disjoint record classes; the programmer may declare as many record classes as he requires, and he associates with each class an identifier to name it. A record class name may be thought of as a common generic term like “cow,” “table,” or “house” and the records which belong to these classes represent the individual cows, tables, and houses. + +Hoare does not mention subclasses in this particular paper, but Dahl credits him with introducing Nygaard and himself to the concept. Nygaard and Dahl had noticed that processes in Simula I often had common elements. Using a superclass to implement those common elements would be convenient. This also raised the possibility that the “process” idea itself could be implemented as a superclass, meaning that not every class had to be a process with a single operating rule. This then was the second great generalization that would make Simula 67 a truly general-purpose programming language. It was such a shift of focus that Nygaard and Dahl briefly considered changing the name of the language so that people would know it was not just for simulations. But “Simula” was too much of an established name for them to risk it. + +In 1967, Nygaard and Dahl signed a contract with Control Data to implement this new version of Simula, to be known as Simula 67. A conference was held in June, where people from Control Data, the University of Oslo, and the Norwegian Computing Center met with Nygaard and Dahl to establish a specification for this new language. This conference eventually led to a document called the [“Simula 67 Common Base Language,”][4] which defined the language going forward. + +Several different vendors would make Simula 67 compilers. The Association of Simula Users (ASU) was founded and began holding annual conferences. Simula 67 soon had users in more than 23 different countries. + +### 21st Century Simula + +Simula is remembered now because of its influence on the languages that have supplanted it. You would be hard-pressed to find anyone still using Simula to write application programs. But that doesn’t mean that Simula is an entirely dead language. You can still compile and run Simula programs on your computer today, thanks to [GNU cim][5]. + +The cim compiler implements the Simula standard as it was after a revision in 1986. But this is mostly the Simula 67 version of the language. You can write classes, subclass, and virtual methods just as you would have with Simula 67. So you could create a small object-oriented program that looks a lot like something you could easily write in Python or Ruby: + +``` +! dogs.sim ; +Begin + Class Dog; + ! The cim compiler requires virtual procedures to be fully specified ; + Virtual: Procedure bark Is Procedure bark;; + Begin + Procedure bark; + Begin + OutText("Woof!"); + OutImage; ! Outputs a newline ; + End; + End; + + Dog Class Chihuahua; ! Chihuahua is "prefixed" by Dog ; + Begin + Procedure bark; + Begin + OutText("Yap yap yap yap yap yap"); + OutImage; + End; + End; + + Ref (Dog) d; + d :- new Chihuahua; ! :- is the reference assignment operator ; + d.bark; +End; +``` + +You would compile and run it as follows: + +``` +$ cim dogs.sim +Compiling dogs.sim: +gcc -g -O2 -c dogs.c +gcc -g -O2 -o dogs dogs.o -L/usr/local/lib -lcim +$ ./dogs +Yap yap yap yap yap yap +``` + +(You might notice that cim compiles Simula to C, then hands off to a C compiler.) + +This was what object-oriented programming looked like in 1967, and I hope you agree that aside from syntactic differences this is also what object-oriented programming looks like in 2019. So you can see why Simula is considered a historically important language. + +But I’m more interested in showing you the process model that was central to Simula I. That process model is still available in Simula 67, but only when you use the `Process` class and a special `Simulation` block. + +In order to show you how processes work, I’ve decided to simulate the following scenario. Imagine that there is a village full of villagers next to a river. The river has lots of fish, but between them the villagers only have one fishing rod. The villagers, who have voracious appetites, get hungry every 60 minutes or so. When they get hungry, they have to use the fishing rod to catch a fish. If a villager cannot use the fishing rod because another villager is waiting for it, then the villager queues up to use the fishing rod. If a villager has to wait more than five minutes to catch a fish, then the villager loses health. If a villager loses too much health, then that villager has starved to death. + +This is a somewhat strange example and I’m not sure why this is what first came to mind. But there you go. We will represent our villagers as Simula processes and see what happens over a day’s worth of simulated time in a village with four villagers. + +The full program is [available here as a Gist][6]. + +The last lines of my output look like the following. Here we are seeing what happens in the last few hours of the day: + +``` +1299.45: John is hungry and requests the fishing rod. +1299.45: John is now fishing. +1311.39: John has caught a fish. +1328.96: Betty is hungry and requests the fishing rod. +1328.96: Betty is now fishing. +1331.25: Jane is hungry and requests the fishing rod. +1340.44: Betty has caught a fish. +1340.44: Jane went hungry waiting for the rod. +1340.44: Jane starved to death waiting for the rod. +1369.21: John is hungry and requests the fishing rod. +1369.21: John is now fishing. +1379.33: John has caught a fish. +1409.59: Betty is hungry and requests the fishing rod. +1409.59: Betty is now fishing. +1419.98: Betty has caught a fish. +1427.53: John is hungry and requests the fishing rod. +1427.53: John is now fishing. +1437.52: John has caught a fish. +``` + +Poor Jane starved to death. But she lasted longer than Sam, who didn’t even make it to 7am. Betty and John sure have it good now that only two of them need the fishing rod. + +What I want you to see here is that the main, top-level part of the program does nothing but create the four villager processes and get them going. The processes manipulate the fishing rod object in the same way that we would manipulate an object today. But the main part of the program does not call any methods or modify and properties on the processes. The processes have internal state, but this internal state only gets modified by the process itself. + +There are still fields that get mutated in place here, so this style of programming does not directly address the problems that pure functional programming would solve. But as Krogdahl observes, “this mechanism invites the programmer of a simulation to model the underlying system as a set of processes, each describing some natural sequence of events in that system.” Rather than thinking primarily in terms of nouns or actors—objects that do things to other objects—here we are thinking of ongoing processes. The benefit is that we can hand overall control of our program off to Simula’s event notice system, which Krogdahl calls a “time manager.” So even though we are still mutating processes in place, no process makes any assumptions about the state of another process. Each process interacts with other processes only indirectly. + +It’s not obvious how this pattern could be used to build, say, a compiler or an HTTP server. (On the other hand, if you’ve ever programmed games in the Unity game engine, this should look familiar.) I also admit that even though we have a “time manager” now, this may not have been exactly what Hickey meant when he said that we need an explicit notion of time in our programs. (I think he’d want something like the superscript notation [that Ada Lovelace used][7] to distinguish between the different values a variable assumes through time.) All the same, I think it’s really interesting that right there at the beginning of object-oriented programming we can find a style of programming that is not all like the object-oriented programming we are used to. We might take it for granted that object-oriented programming simply works one way—that a program is just a long list of the things that certain objects do to other objects in the exact order that they do them. Simula I’s process system shows that there are other approaches. Functional languages are probably a better thought-out alternative, but Simula I reminds us that the very notion of alternatives to modern object-oriented programming should come as no surprise. + +If you enjoyed this post, more like it come out every four weeks! Follow [@TwoBitHistory][8] on Twitter or subscribe to the [RSS feed][9] to make sure you know when a new post is out. + +Previously on TwoBitHistory… + +> Hey everyone! I sadly haven't had time to do any new writing but I've just put up an updated version of my history of RSS. This version incorporates interviews I've since done with some of the key people behind RSS like Ramanathan Guha and Dan Libby. +> +> — TwoBitHistory (@TwoBitHistory) [December 18, 2018][10] + + + +-------------------------------------------------------------------------------- + +1. Jan Rune Holmevik, “The History of Simula,” accessed January 31, 2019, http://campus.hesge.ch/daehne/2004-2005/langages/simula.htm. ↩ + +2. Ole-Johan Dahl and Kristen Nygaard, “SIMULA—An ALGOL-Based Simulation Langauge,” Communications of the ACM 9, no. 9 (September 1966): 671, accessed January 31, 2019, http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.95.384&rep=rep1&type=pdf. ↩ + +3. Stein Krogdahl, “The Birth of Simula,” 2, accessed January 31, 2019, http://heim.ifi.uio.no/~steinkr/papers/HiNC1-webversion-simula.pdf. ↩ + +4. ibid. ↩ + +5. Ole-Johan Dahl and Kristen Nygaard, “The Development of the Simula Languages,” ACM SIGPLAN Notices 13, no. 8 (August 1978): 248, accessed January 31, 2019, https://hannemyr.com/cache/knojd_acm78.pdf. ↩ + +6. Dahl and Nygaard (1966), 676. ↩ + +7. Dahl and Nygaard (1978), 257. ↩ + +8. Krogdahl, 3. ↩ + +9. Ole-Johan Dahl, “The Birth of Object-Orientation: The Simula Languages,” 3, accessed January 31, 2019, http://www.olejohandahl.info/old/birth-of-oo.pdf. ↩ + +10. Dahl and Nygaard (1978), 265. ↩ + +11. Holmevik. ↩ + +12. Krogdahl, 4. ↩ + + +-------------------------------------------------------------------------------- + +via: https://twobithistory.org/2019/01/31/simula.html + +作者:[Sinclair Target][a] +选题:[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.infoq.com/presentations/Are-We-There-Yet-Rich-Hickey +[2]: /images/river.jpg +[3]: https://archive.computerhistory.org/resources/text/algol/ACM_Algol_bulletin/1061032/p39-hoare.pdf +[4]: http://web.eah-jena.de/~kleine/history/languages/Simula-CommonBaseLanguage.pdf +[5]: https://www.gnu.org/software/cim/ +[6]: https://gist.github.com/sinclairtarget/6364cd521010d28ee24dd41ab3d61a96 +[7]: https://twobithistory.org/2018/08/18/ada-lovelace-note-g.html +[8]: https://twitter.com/TwoBitHistory +[9]: https://twobithistory.org/feed.xml +[10]: https://twitter.com/TwoBitHistory/status/1075075139543449600?ref_src=twsrc%5Etfw diff --git a/sources/talk/20190204 Config management is dead- Long live Config Management Camp.md b/sources/talk/20190204 Config management is dead- Long live Config Management Camp.md new file mode 100644 index 0000000000..679ac9033b --- /dev/null +++ b/sources/talk/20190204 Config management is dead- Long live Config Management Camp.md @@ -0,0 +1,118 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Config management is dead: Long live Config Management Camp) +[#]: via: (https://opensource.com/article/19/2/configuration-management-camp) +[#]: author: (Matthew Broberg https://opensource.com/users/mbbroberg) + +Config management is dead: Long live Config Management Camp +====== + +CfgMgmtCamp '19 co-organizers share their take on ops, DevOps, observability, and the rise of YoloOps and YAML engineers. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cicd_continuous_delivery_deployment_gears.png?itok=kVlhiEkc) + +Everyone goes to [FOSDEM][1] in Brussels to learn from its massive collection of talk tracks, colloquially known as developer rooms, that run the gauntlet of curiosities, covering programming languages like Rust, Go, and Python, to special topics ranging from community, to legal, to privacy. After two days of nonstop activity, many FOSDEM attendees move on to Ghent, Belgium, to join hundreds for Configuration Management Camp ([CfgMgmtCamp][2]). + +Kris Buytaert and Toshaan Bharvani run the popular post-FOSDEM show centered around infrastructure management, featuring hackerspaces, training, workshops, and keynotes. It's a deeply technical exploration of the who, what, and how of building resilient infrastructure. It started in 2013 as a PuppetCamp but expanded to include more communities and tools in 2014. + +I spoke with Kris and Toshaan, who both have a healthy sense of humor, about CfgMgmtCamp's past, present, and future. Our interview has been edited for length and clarity. + +**Matthew: Your opening[keynote][3] is called "CfgMgmtCamp is dead." Is config management dead? Will it live on, or will something take its place?** + +**Kris:** We've noticed people are jumping on the hype of containers, trying to solve the same problems in a different way. But they are still managing config, only in different ways and with other tools. Over the past couple of years, we've evolved from a conference with a focus on infrastructure-as-code tooling, such as Puppet, Chef, CFEngine, Ansible, Juju, and Salt, to a more open source infrastructure automation conference in general. So, config management is definitely not dead. Infrastructure-as-code is also not dead, but it all is evolving. + +**Toshaan:** We see people changing tools, jumping on hype, and communities changing; however, the basic ideas and concepts remain the same. + +**Matthew: It's great to see[observability as the topic][4] of one of your keynotes. Why should those who care about configuration management also care about monitoring and observability?** + +**Kris:** While the name of the conference hasn't changed, the tools have evolved and we have expanded our horizon. Ten years ago, [Devopsdays][5] was just #devopsdays, but it evolved to focus on culture—the C of [CAMS][6] in the DevOps' core principles of Culture, Automation, Measurement, and Sharing. + +![](https://opensource.com/sites/default/files/uploads/cams.png) + +[Monitorama][7] filled the gap on monitoring and metrics (tackling the M in CAMS). Config Management Camp is about open source Automation, the A. Since they are all open source conferences, they fulfill the Sharing part, completing the CAMS concept. + +Observability sits on the line between Automation and Measurement. To go one step further, in some of my talks about open source monitoring, I describe the evolution of monitoring tools from #monitoringsucks to #monitoringlove; for lots of people (including me), the love for monitoring returned because we tied it to automation. We started to provision a service and automatically adapted the monitoring of that service to its state. Gone were the days where the monitoring tool was out of sync with reality. + +Looking at it from the other side, when you have an infrastructure or application so complex that you need observability in it, you'd better not be deploying manually; you will need some form of automation at that level of complexity. So, observability and infrastructure automation are tied together. + +**Toshaan:** Yes, while in the past we focused on configuration management, we will be looking to expand that into all types of infrastructure management. Last year, we played with this idea, and we were able to have a lot of cross-tool presentations. This year, we've taken this a step further by having more differentiated content. + +**Matthew: Some of my virtualization and Linux admin friends push back, saying observability is a developer's responsibility. How would you respond without just saying "DevOps?"** + +**Kris:** What you describe is what I call "Ooops Devs." This is a trend where the people who run the platform don't really care what they run; as long as port 80 is listening and the node pings, they are happy. It's equally bad as "Dev Ooops." "Ooops Devs" is where the devs rant about the ops folks because they are slow, not agile, and not responsive. But, to me, your job as an ops person or as a Linux admin is to keep a service running, and the only way to do that is to take on that task is as a team—with your colleagues who have different roles and insights, people who write code, people who design, etc. It is a shared responsibility. And hiding behind "that is someone else's responsibility," doesn't smell like collaboration going on. + +**Toshaan:** Even in the dark ages of silos, I believe a true sysadmin should have cared about observability, monitoring, and automation. I believe that the DevOps movement has made this much more widespread, and that it has become easier to get this information and expose it. On the other hand, I believe that pure operators or sysadmins have learned to be team players (or, they may have died out). I like the analogy of an army unit composed of different specialty soldiers who work together to complete a mission; we have engineers who work to deliver products or services. + +**Matthew: In a[Devopsdays Zurich talk][8], Kris offered an opinion that Americans build software for acquisition and Europeans build for resilience. In that light, what are the best skills for someone who wants to build meaningful infrastructure?** + +**Toshaan:** I believe still some people don't understand the complexity of code sprawl, and they believe that some new hype will solve this magically. + +**Kris:** This year, we invited [Steve Traugott][9], co-author of the 1998 USENIX paper "[Bootstrapping an Infrastructure][10]" that helped kickstart our community. So many people never read [Infrastructures.org][11], never experienced the pain of building images and image sprawl, and don't understand the evolution we went through that led us to build things the way we build them from source code. + +People should study topics such as idempotence, resilience, reproducibility, and surviving the tenth floor test. (As explained in "Bootstrapping an Infrastructure": "The test we used when designing infrastructures was 'Can I grab a random machine and throw it out the tenth-floor window without adversely impacting users for more than 10 minutes?' If the answer to this was 'yes,' then we knew we were doing things right.") But only after they understand the service they are building—the service is the absolute priority—can they begin working on things like: how can we run this, how can we make sure it keeps running, how can it fail and how can we prevent that, and if it disappears, how can we spin it up again fast, unnoticed by the end user. + +**Toshaan:** 100% uptime. + +**Kris:** The challenge we have is that lots of people don't have that experience yet. We've seen the rise of [YoloOps][12]—just spin it up once, fire, and forget—which results in security problems, stability problems, data loss, etc., and they often grasp onto the solutions in YoloOps, the easy way to do something quickly and move on. But understanding how things will eventually fail takes time, it's called experience. + +**Toshaan:** Well, when I was a student and manned the CentOS stand at FOSDEM, I remember a guy coming up to the stand and complaining that he couldn't do consulting because of the "fire once and forgot" policy of CentOS, and that it just worked too well. I like to call this ZombieOps, but YoloOps works also. + +**Matthew: I see you're leading the second year of YamlCamp as well. Why does a markup language need its own camp?** + +**Kris:** [YamlCamp][13] is a parody, it's a joke. Last year, Bob Walker ([@rjw1][14]) gave a talk titled "Are we all YAML engineers now?" that led to more jokes. We've had a discussion for years about rebranding CfgMgmtCamp; the problem is that people know our name, we have a large enough audience to keep going, and changing the name would mean effort spent on logos, website, DNS, etc. We won't change the name, but we joked that we could rebrand to YamlCamp, because for some weird reason, a lot of the talks are about YAML. :) + +**Matthew: Do you think systems engineers should list YAML as a skill or a language on their CV? Should companies be hiring YAML engineers, or do you have "Long live all YAML engineers" on the website in jest?** + +**Toshaan:** Well, the real question is whether people are willing to call themselves YAML engineers proudly, because we already have enough DevOps engineers. + +**Matthew: What FOSS software helps you manage the event?** + +**Toshaan:** I re-did the website in Hugo CMS because we were spending too much time maintaining the website manually. I chose Hugo, because I was learning Golang, and because it has been successfully used for other conferences and my own website. I also wanted a static website and iCalendar output, so we could use calendar tooling such as Giggity to have a good scheduling tool. + +The website now builds quite nicely, and while I still have some ideas on improvements, maintenance is now much easier. + +For the call for proposals (CFP), we now use [OpenCFP][15]. We want to optimize the submission, voting, selection, and extraction to be as automated as possible, while being easy and comfortable for potential speakers, reviewers, and ourselves to use. OpenCFP seems to be the tool that works; while we still have some feature requirements, I believe that, once we have some time to contribute back to OpenCFP, we'll have a fully functional and easy tool to run CFPs with. + +Last, we switched from EventBrite to Pretix because I wanted to be GDPR compliant and have the ability to run our questions, vouchers, and extra features. Pretix allows us to control registration of attendees, speakers, sponsors, and organizers and have a single overview of all the people coming to the event. + +### Wrapping up + +The beauty of Configuration Management Camp to me is that it continues to evolve with its audience. Configuration management is certainly at the heart of the work, but it's in service to resilient infrastructure. Keep your eyes open for the talk recordings to learn from the [line up of incredible speakers][16], and thank you to the team for running this (free) show! + +You can follow Kris [@KrisBuytaert][17] and Toshaan [@toshywoshy][18]. You can also see Kris' past articles [on his blog][19]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/configuration-management-camp + +作者:[Matthew Broberg][a] +选题:[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/mbbroberg +[b]: https://github.com/lujun9972 +[1]: https://fosdem.org/2019/ +[2]: https://cfgmgmtcamp.eu/ +[3]: https://cfgmgmtcamp.eu/schedule/monday/intro00/ +[4]: https://cfgmgmtcamp.eu/schedule/monday/keynote0/ +[5]: https://www.devopsdays.org/ +[6]: http://devopsdictionary.com/wiki/CAMS +[7]: http://monitorama.com/ +[8]: https://vimeo.com/272519813 +[9]: https://cfgmgmtcamp.eu/schedule/tuesday/keynote1/ +[10]: http://www.infrastructures.org/papers/bootstrap/bootstrap.html +[11]: http://www.infrastructures.org/ +[12]: https://gist.githubusercontent.com/mariozig/5025613/raw/yolo +[13]: https://twitter.com/yamlcamp +[14]: https://twitter.com/rjw1 +[15]: https://github.com/opencfp/opencfp +[16]: https://cfgmgmtcamp.eu/speaker/ +[17]: https://twitter.com/KrisBuytaert +[18]: https://twitter.com/toshywoshy +[19]: https://krisbuytaert.be/index.shtml diff --git a/sources/talk/20190205 7 predictions for artificial intelligence in 2019.md b/sources/talk/20190205 7 predictions for artificial intelligence in 2019.md new file mode 100644 index 0000000000..2e1b047a15 --- /dev/null +++ b/sources/talk/20190205 7 predictions for artificial intelligence in 2019.md @@ -0,0 +1,91 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (7 predictions for artificial intelligence in 2019) +[#]: via: (https://opensource.com/article/19/2/predictions-artificial-intelligence) +[#]: author: (Salil Sethi https://opensource.com/users/salilsethi) + +7 predictions for artificial intelligence in 2019 +====== + +While 2018 was a big year for AI, the stage is set for it to make an even deeper impact in 2019. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/robot_arm_artificial_ai.png?itok=8CUU3U_7) + +Without question, 2018 was a big year for artificial intelligence (AI) as it pushed even further into the mainstream, successfully automating more functionality than ever before. Companies are increasingly exploring applications for AI, and the general public has grown accustomed to interacting with the technology on a daily basis. + +The stage is set for AI to continue transforming the world as we know it. In 2019, not only will the technology continue growing in global prevalence, but it will also spawn deeper conversations around important topics, fuel innovative business models, and impact society in new ways, including the following seven. + +### 1\. Machine learning as a service (MLaaS) will be deployed more broadly + +In 2018, we witnessed major strides in MLaaS with technology powerhouses like Google, Microsoft, and Amazon leading the way. Prebuilt machine learning solutions and capabilities are becoming more attractive in the market, especially to smaller companies that don't have the necessary in-house resources or talent. For those that have the technical know-how and experience, there is a significant opportunity to sell and deploy packaged solutions that can be easily implemented by others. + +Today, MLaaS is sold primarily on a subscription or usage basis by cloud-computing providers. For example, Microsoft Azure's ML Studio provides developers with a drag-and-drop environment to develop powerful machine learning models. Google Cloud's Machine Learning Engine also helps developers build large, sophisticated algorithms for a variety of applications. In 2017, Amazon jumped into the realm of AI and launched Amazon SageMaker, another platform that developers can use to build, train, and deploy custom machine learning models. + +In 2019 and beyond, be prepared to see MLaaS offered on a much broader scale. Transparency Market Research predicts it will grow to US$20 billion at an alarming 40% CAGR by 2025. + +### 2\. More explainable or "transparent" AI will be developed + +Although there are already many examples of how AI is impacting our world, explaining the outputs and rationale of complex machine learning models remains a challenge. + +Unfortunately, AI continues to carry the "black box" burden, posing a significant limitation in situations where humans want to understand the rationale behind AI-supported decision making. + +AI democratization has been led by a plethora of open source tools and libraries, such as Scikit Learn, TensorFlow, PyTorch, and more. The open source community will lead the charge to build explainable, or "transparent," AI that can clearly document its logic, expose biases in data sets, and provide answers to follow-up questions. + +Before AI is widely adopted, humans need to know that the technology can perform effectively and explain its reasoning under any circumstance. + +### 3\. AI will impact the global political landscape + +In 2019, AI will play a bigger role on the global stage, impacting relationships between international superpowers that are investing in the technology. Early adopters of AI, such as the US and [China][1], will struggle to balance self-interest with collaborative R&D. Countries that have AI talent and machine learning capabilities will experience tremendous growth in areas like predictive analytics, creating a wider global technology gap. + +Additionally, more conversations will take place around the ethical use of AI. Naturally, different countries will approach this topic differently, which will affect political relationships. Overall, AI's impact will be small relative to other international issues, but more noticeable than before. + +### 4\. AI will create more jobs than it eliminates + +Over the long term, many jobs will be eliminated as a result of AI-enabled automation. Roles characterized by repetitive, manual tasks are being outsourced to AI more and more every day. However, in 2019, AI will create more jobs than it replaces. + +Rather than eliminating the need for humans entirely, AI is augmenting existing systems and processes. As a result, a new type of role is emerging. Humans are needed to support AI implementation and oversee its application. Next year, more manual labor will transition to management-type jobs that work alongside AI, a trend that will continue to 2020. Gartner predicts that in two years, [AI will create 2.3 million jobs while only eliminating 1.8 million.][2] + +### 5\. AI assistants will become more pervasive and useful + +AI assistants are nothing new to the modern world. Apple's Siri and Amazon's Alexa have been supporting humans on the road and in their homes for years. In 2019, we will see AI assistants continue to grow in their sophistication and capabilities. As they collect more behavioral data, AI assistants will become better at responding to requests and completing tasks. With advances in natural language processing and speech recognition, humans will have smoother and more useful interactions with AI assistants. + +In 2018, we saw companies launch promising new AI assistants. Recently, Google began rolling out its voice-enabled reservation booking service, Duplex, which can call and book appointments on behalf of users. Technology company X.ai has built two AI personal assistants, Amy and Andrew, who can interact with humans and schedule meetings for their employers. Amazon also recently announced Echo Auto, a device that enables drivers to integrate Alexa into their vehicles. However, humans will continue to place expectations ahead of reality and be disappointed at the technology's limitations. + +### 6\. AI/ML governance will gain importance + +With so many companies investing in AI, much more energy will be put towards developing effective AI governance structures. Frameworks are needed to guide data collection and management, appropriate AI use, and ethical applications. Successful and appropriate AI use involves many different stakeholders, highlighting the need for reliable and consistent governing bodies. + +In 2019, more organizations will create governance structures and more clearly define how AI progress and implementation are managed. Given the current gap in explainability, these structures will be tremendously important as humans continue to turn to AI to support decision-making. + +### 7\. AI will help companies solve AI talent shortages + +A [shortage of AI and machine learning talent][3] is creating an innovation bottleneck. A [survey][4] released last year from O'Reilly revealed that the biggest challenge companies are facing related to using AI is a lack of available talent. And as technological advancement continues to accelerate, it is becoming harder for companies to develop talent that can lead large-scale enterprise AI efforts. + +To combat this, organizations will—ironically—use AI and machine learning to help address the talent gap in 2019. For example, Google Cloud's AutoML includes machine learning products that help developers train machine learning models without having any prior AI coding experience. Amazon Personalize is another machine learning service that helps developers build sophisticated personalization systems that can be implemented in many ways by different kinds of companies. In addition, companies will use AI to find talent and fill job vacancies and propel innovation forward. + +### AI In 2019: bigger and better with a tighter leash + +Over the next year, AI will grow more prevalent and powerful than ever. Expect to see new applications and challenges and be ready for an increased emphasis on checks and balances. + +What do you think? How might AI impact the world in 2019? Please share your thoughts in the comments below! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/predictions-artificial-intelligence + +作者:[Salil Sethi][a] +选题:[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/salilsethi +[b]: https://github.com/lujun9972 +[1]: https://www.turingtribe.com/story/china-is-achieving-ai-dominance-by-relying-on-young-blue-collar-workers-rLMsmWqLG4fGFwisQ +[2]: https://www.gartner.com/en/newsroom/press-releases/2017-12-13-gartner-says-by-2020-artificial-intelligence-will-create-more-jobs-than-it-eliminates +[3]: https://www.turingtribe.com/story/tencent-says-there-are-only-bTpNm9HKaADd4DrEi +[4]: https://www.forbes.com/sites/bernardmarr/2018/06/25/the-ai-skills-crisis-and-how-to-close-the-gap/#19bafcf631f3 diff --git a/sources/talk/20190206 4 steps to becoming an awesome agile developer.md b/sources/talk/20190206 4 steps to becoming an awesome agile developer.md new file mode 100644 index 0000000000..bad4025aef --- /dev/null +++ b/sources/talk/20190206 4 steps to becoming an awesome agile developer.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (4 steps to becoming an awesome agile developer) +[#]: via: (https://opensource.com/article/19/2/steps-agile-developer) +[#]: author: (Daniel Oh https://opensource.com/users/daniel-oh) + +4 steps to becoming an awesome agile developer +====== +There's no magical way to do it, but these practices will put you well on your way to embracing agile in application development, testing, and debugging. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_lead-steps-measure.png?itok=DG7rFZPk) + +Enterprises are rushing into their DevOps journey through [agile][1] software development with cloud-native technologies such as [Linux containers][2], [Kubernetes][3], and [serverless][4]. Continuous integration helps enterprise developers reduce bugs, unexpected errors, and improve the quality of their code deployed in production. + +However, this doesn't mean all developers in DevOps automatically embrace agile for their daily work in application development, testing, and debugging. There is no magical way to do it, but the following four practical steps and best practices will put you well on your way to becoming an awesome agile developer. + +### Start with design thinking agile practices + +There are many opportunities to learn about using agile software development practices in your DevOps initiatives. Agile practices inspire people with new ideas and experiences for improving their daily work in application development with team collaboration. More importantly, those practices will help you discover the answers to questions such as: Why am I doing this? What kind of problems am I trying to solve? How do I measure the outcomes? + +A [domain-driven design][5] approach will help you start discovery sooner and easier. For example, the [Start At The End][6] practice helps you redesign your application and explore potential business outcomes—such as, what would happen if your application fails in production? You might also be interested in [Event Storming][7] for interactive and rapid discovery or [Impact Mapping][8] for graphical and strategic design as part of domain-driven design practices. + +### Use a predictive approach first + +In agile software development projects, enterprise developers are mainly focused on adapting to rapidly changing app development environments such as reactive runtimes, cloud-native frameworks, Linux container packaging, and the Kubernetes platform. They believe this is the best way to become an agile developer in their organization. However, this type of adaptive approach typically makes it harder for developers to understand and report what they will do in the next sprint. Developers might know the ultimate goal and, at best, the app features for a release about four months from the current sprint. + +In contrast, the predictive approach places more emphasis on analyzing known risks and planning future sprints in detail. For example, predictive developers can accurately report the functions and tasks planned for the entire development process. But it's not a magical way to make your agile projects succeed all the time because the predictive team depends totally on effective early-stage analysis. If the analysis does not work very well, it may be difficult for the project to change direction once it gets started. + +To mitigate this risk, I recommend that senior agile developers increase the predictive capabilities with a plan-driven method, and junior agile developers start with the adaptive methods for value-driven development. + +### Continuously improve code quality + +Don't hesitate to engage in [continuous integration][9] (CI) practices for improving your application before deploying code into production. To adopt modern application frameworks, such as cloud-native architecture, Linux container packaging, and hybrid cloud workloads, you have to learn about automated tools to address complex CI procedures. + +[Jenkins][10] is the standard CI tool for many organizations; it allows developers to build and test applications in many projects in an automated fashion. Its most important function is detecting unexpected errors during CI to prevent them from happening in production. This should increase business outcomes through better customer satisfaction. + +Automated CI enables agile developers to not only improve the quality of their code but their also application development agility through learning and using open source tools and patterns such as [behavior-driven development][11], [test-driven development][12], [automated unit testing][13], [pair programming][14], [code review][15], and [design pattern][16]. + +### Never stop exploring communities + +Never settle, even if you already have a great reputation as an agile developer. You have to continuously take on bigger challenges to make great software in an agile way. + +By participating in the very active and growing open source community, you will not only improve your skills as an agile developer, but your actions can also inspire other developers who want to learn agile practices. + +How do you get involved in specific communities? It depends on your interests and what you want to learn. It might mean presenting specific topics at conferences or local meetups, writing technical blog posts, publishing practical guidebooks, committing code, or creating pull requests to open source projects' Git repositories. It's worth exploring open source communities for agile software development, as I've found it is a great way to share your expertise, knowledge, and practices with other brilliant developers and, along the way, help each other. + +### Get started + +These practical steps can give you a shorter path to becoming an awesome agile developer. Then you can lead junior developers in your team and organization to become more flexible, valuable, and predictive using agile principles. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/steps-agile-developer + +作者:[Daniel Oh][a] +选题:[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/daniel-oh +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/article/18/10/what-agile +[2]: https://opensource.com/resources/what-are-linux-containers +[3]: https://opensource.com/resources/what-is-kubernetes +[4]: https://opensource.com/article/18/11/open-source-serverless-platforms +[5]: https://en.wikipedia.org/wiki/Domain-driven_design +[6]: https://openpracticelibrary.com/practice/start-at-the-end/ +[7]: https://openpracticelibrary.com/practice/event-storming/ +[8]: https://openpracticelibrary.com/practice/impact-mapping/ +[9]: https://en.wikipedia.org/wiki/Continuous_integration +[10]: https://jenkins.io/ +[11]: https://en.wikipedia.org/wiki/Behavior-driven_development +[12]: https://en.wikipedia.org/wiki/Test-driven_development +[13]: https://en.wikipedia.org/wiki/Unit_testing +[14]: https://en.wikipedia.org/wiki/Pair_programming +[15]: https://en.wikipedia.org/wiki/Code_review +[16]: https://en.wikipedia.org/wiki/Design_pattern diff --git a/sources/talk/20190206 What blockchain and open source communities have in common.md b/sources/talk/20190206 What blockchain and open source communities have in common.md new file mode 100644 index 0000000000..bc4f9464d0 --- /dev/null +++ b/sources/talk/20190206 What blockchain and open source communities have in common.md @@ -0,0 +1,64 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What blockchain and open source communities have in common) +[#]: via: (https://opensource.com/article/19/2/blockchain-open-source-communities) +[#]: author: (Gordon Haff https://opensource.com/users/ghaff) + +What blockchain and open source communities have in common +====== +Blockchain initiatives can look to open source governance for lessons on establishing trust. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/diversity_flowers_chain.jpg?itok=ns01UPOp) + +One of the characteristics of blockchains that gets a lot of attention is how they enable distributed trust. The topic of trust is a surprisingly complicated one. In fact, there's now an [entire book][1] devoted to the topic by Kevin Werbach. + +But here's what it means in a nutshell. Organizations that wish to work together, but do not fully trust one another, can establish a permissioned blockchain and invite business partners to record their transactions on a shared distributed ledger. Permissioned blockchains can trace assets when transactions are added to the blockchain. A permissioned blockchain implies a degree of trust (again, trust is complicated) among members of a consortium, but no single entity controls the storage and validation of transactions. + +The basic model is that a group of financial institutions or participants in a logistics system can jointly set up a permissioned blockchain that will validate and immutably record transactions. There's no dependence on a single entity, whether it's one of the direct participants or a third-party intermediary who set up the blockchain, to safeguard the integrity of the system. The blockchain itself does so through a variety of cryptographic mechanisms. + +Here's the rub though. It requires that competitors work together cooperatively—a relationship often called [coopetition][2]. The term dates back to the early 20th century, but it grew into widespread use when former Novell CEO Ray Noorda started using the term to describe the company's business strategy in the 1990s. Novell was then planning to get into the internet portal business, which required it to seek partnerships with some of the search engine providers and other companies it would also be competing against. In 1996, coopetition became the subject of a bestselling [book][3]. + +Coopetition can be especially difficult when a blockchain network initiative appears to be driven by a dominant company. And it's hard for the dominant company not to exert outsize influence over the initiative, just as a natural consequence of how big it is. For example, the IBM-Maersk joint venture has [struggled to sign up rival shipping companies][4], in part because Maersk is the world's largest carrier by capacity, a position that makes rivals wary. + +We see this same dynamic in open source communities. The original creators of a project need to not only let go; they need to put governance structures in place that give competing companies confidence that there's a level playing field. + +For example, Sarah Novotny, now head of open source strategy at Google Cloud Platform, [told me in a 2017 interview][5] about the [Kubernetes][6] project that it isn't always easy to give up control, even when people buy into doing what is best for a project. + +> Google turned Kubernetes over to the Cloud Native Computing Foundation (CNCF), which sits under the Linux Foundation umbrella. As [CNCF executive director Dan Kohn puts it][7]: "One of the things they realized very early on is that a project with a neutral home is always going to achieve a higher level of collaboration. They really wanted to find a home for it where a number of different companies could participate." +> +> Defaulting to public may not be either natural or comfortable. "Early on, my first six, eight, or 12 weeks at Google, I think half my electrons in email were spent on: 'Why is this discussion not happening on a public mailing list? Is there a reason that this is specific to GKE [Google Container Engine]? No, there's not a reason,'" said Novotny. + +To be sure, some grumble that open source foundations have become too common and that many are too dominated by paying corporate members. Simon Phipps, currently the president of the Open Source Initiative, gave a talk at OSCON way back in 2015 titled ["Enough Foundations Already!"][8] in which he argued that "before we start another open source foundation, let's agree that what we need protected is software freedom and not corporate politics." + +Nonetheless, while not appropriate for every project, foundations with business, legal, and technical governance are increasingly the model for open source projects that require extensive cooperation among competing companies. A [2017 analysis of GitHub data by the Linux Foundation][9] found a number of different governance models in use by the highest-velocity open source projects. Unsurprisingly, quite a few remained under the control of the company that created or acquired them. However, about a third were under the auspices of a foundation. + +Is there a lesson here for blockchain? Quite possibly. Open source projects can be sponsored by a company while still putting systems and governance in place that are welcoming to outside contributors. However, there's a great deal of history to suggest that doing so is hard because it's hard not to exert control and leverage when you can. Furthermore, even if you make a successful case for being truly open to equal participation to outsiders today, it will be hard to allay suspicions that you might not be as welcoming tomorrow. + +To the degree that we can equate blockchain consortiums with open source communities, this suggests that business blockchain initiatives should look to open source governance for lessons. Dominant players in the ecosystem need to forgo control, and they need to have conversations with partners and potential partners about what types of structures would make participating easier. + +Many blockchain infrastructure software projects are already under foundations such as Hyperledger. But perhaps some specific production deployments of blockchain aimed at specific industries and ecosystems will benefit from formal governance structures as well. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/blockchain-open-source-communities + +作者:[Gordon Haff][a] +选题:[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/ghaff +[b]: https://github.com/lujun9972 +[1]: https://mitpress.mit.edu/books/blockchain-and-new-architecture-trust +[2]: https://en.wikipedia.org/wiki/Coopetition +[3]: https://en.wikipedia.org/wiki/Co-opetition_(book) +[4]: https://www.theregister.co.uk/2018/10/30/ibm_struggles_to_sign_up_shipping_carriers_to_blockchain_supply_chain_platform_reports/ +[5]: https://opensource.com/article/17/4/podcast-kubernetes-sarah-novotny +[6]: https://kubernetes.io/ +[7]: http://bitmason.blogspot.com/2017/02/podcast-cloud-native-computing.html +[8]: https://www.oreilly.com/ideas/enough-foundations-already +[9]: https://www.linuxfoundation.org/blog/2017/08/successful-open-source-projects-common/ diff --git a/sources/talk/20190208 Which programming languages should you learn.md b/sources/talk/20190208 Which programming languages should you learn.md new file mode 100644 index 0000000000..31cef16f03 --- /dev/null +++ b/sources/talk/20190208 Which programming languages should you learn.md @@ -0,0 +1,46 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Which programming languages should you learn?) +[#]: via: (https://opensource.com/article/19/2/which-programming-languages-should-you-learn) +[#]: author: (Marty Kalin https://opensource.com/users/mkalindepauledu) + +Which programming languages should you learn? +====== +Learning a new programming language is a great way to get ahead in your career. But which one? +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/search_find_code_issue_bug_programming.png?itok=XPrh7fa0) + +If you want to get started or get ahead in your programming career, learning a new language is a smart idea. But the huge number of languages in active use invites the question: Which programming language is the best one to know? To answer that, let's start with a simplifying question: What sort of programming do you want to do? + +If you want to do web programming on the client side, then the specialized languages HTML, CSS, and JavaScript—in one of its seemingly infinite dialects—are de rigueur. + +If you want to do web programming on the server side, the options include all of the familiar general-purpose languages: C++, Golang, Java, C#, Node.js, Perl, Python, Ruby, and so on. As a matter of course, server-side programs interact with datastores, such as relational and other databases, which means query languages such as SQL may come into play. + +If you're writing native apps for mobile devices, knowing the target platform is important. For Apple devices, Swift has supplanted Objective C as the language of choice. For Android devices, Java (with dedicated libraries and toolsets) remains the dominant language. There are special languages such as Xamarin, used with C#, that can generate platform-specific code for Apple, Android, and Windows devices. + +What about general-purpose languages? There are various choices within the usual pigeonholes. Among the dynamic or scripting languages (e.g., Perl, Python, and Ruby), there are newer offerings such as Node.js. Java and C#, which are more alike than their fans like to admit, remain the dominant statically compiled languages targeted at a virtual machine (the JVM and CLR, respectively). Among languages that compile into native executables, C++ is still in the mix, along with later arrivals such as Golang and Rust. General-purpose functional languages abound (e.g., Clojure, Haskell, Erlang, F#, Lisp, and Scala), often with passionately devoted communities. It's worth noting that object-oriented languages such as Java and C# have added functional constructs (in particular, lambdas), and the dynamic languages have had functional constructs from the start. + +Let me end with a pitch for C, which is a small, elegant, and extensible language not to be confused with C++. Modern operating systems are written mostly in C, with the rest in assembly language. The standard libraries on any platform are likewise mostly in C. For example, any program that issues the Hello, world! greeting does so through a call to the C library function named **write**. + +C serves as a portable assembly language, exposing details about the underlying system that other high-level languages deliberately hide. To understand C is thus to gain a better grasp of how programs contend for the shared system resources (processors, memory, and I/O devices) required for execution. C is at once high-level and close-to-the-metal, so unrivaled in performance—except, of course, for assembly language. Finally, C is the lingua franca among programming languages, and almost every general-purpose language supports C calls in one form or another. + +For a modern introduction to C, consider my book [C Programming: Introducing Portable Assembler][1]. No matter how you go about it, learn C and you'll learn a lot more than just another programming language. + +What programming languages do you think are important to know? Do you agree or disagree with these recommendations? Let us know in the comments! + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/which-programming-languages-should-you-learn + +作者:[Marty Kalin][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mkalindepauledu +[b]: https://github.com/lujun9972 +[1]: https://www.amazon.com/dp/1977056954?ref_=pe_870760_150889320 diff --git a/sources/talk/20190211 Introducing kids to computational thinking with Python.md b/sources/talk/20190211 Introducing kids to computational thinking with Python.md new file mode 100644 index 0000000000..c877d3c212 --- /dev/null +++ b/sources/talk/20190211 Introducing kids to computational thinking with Python.md @@ -0,0 +1,69 @@ +[#]: collector: (lujun9972) +[#]: translator: (WangYueScream ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Introducing kids to computational thinking with Python) +[#]: via: (https://opensource.com/article/19/2/break-down-stereotypes-python) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +Introducing kids to computational thinking with Python +====== +Coding program gives low-income students the skills, confidence, and knowledge to break free from economic and societal disadvantages. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/idea_innovation_kid_education.png?itok=3lRp6gFa) + +When the [Parkman Branch][1] of the Detroit Public Library was flooded with bored children taking up all the computers during summer break, the library saw it not as a problem, rather an opportunity. They started a coding club, the [Parkman Coders][2], led by [Qumisha Goss][3], a librarian who is leveraging the power of Python to introduce disadvantaged children to computational thinking. + +When she started the Parkman Coders program about four years ago, "Q" (as she is known) didn't know much about coding. Since then, she's become a specialist in library instruction and technology and a certified Raspberry Pi instructor. + +The program began by using [Scratch][4], but the students got bored with the block coding interface, which they regarded as "baby stuff." She says, "I knew we need to make a change to something that was still beginner friendly, but that would be more challenging for them to continue to hold their attention." At this point, she started teaching them Python. + +Q first saw Python while playing a game with dungeons and skeleton monsters on [Code.org][5]. She began to learn Python by reading books like [Python Programming: An Introduction to Computer Science][6] and [Python for Kids][7]. She also recommends [Automate the Boring Stuff with Python][8] and [Lauren Ipsum: A Story about Computer Science and Other Improbable Things][9]. + +### Setting up a Raspberry Pi makerspace + +Q decided to use [Raspberry Pi][10] computers to avoid the possibility that the students might be able to hack into the library system's computers, which weren't arranged in a way conducive to a makerspace anyway. The Pi's affordability, plus its flexibility and the included free software, lent more credibility to her decision. + +While the coder program was the library's effort keep the peace and create a learning space that would engage the children, it quickly grew so popular that it ran out of space, computers, and adequate electrical outlets in a building built in 1921. They started with 10 Raspberry Pi computers shared among 20 children, but the library obtained funding from individuals, companies including Microsoft, the 4H, and the Detroit Public Library Foundation to get more equipment and expand the program. + +Currently, about 40 children participate in each session and they have enough Raspberry Pi's for one device per child and some to give away. Many of the Parkman Coders come from low socio-economic backgrounds and don't have a computer at home, so the library provides them with donated Chromebooks. + +Q says, "when kids demonstrate that they have a good understanding of how to use a Raspberry Pi or a [Microbit][11] and have been coming to programs regularly, we give them equipment to take home with them. This process is very challenging, however, because [they may not] have internet access at home [or] all the peripheral things they need like monitors, keyboards, and mice." + +### Learning life skills and breaking stereotypes with Python + +Q says, "I believe that the mainstays of learning computer science are learning critical thinking and problem-solving skills. My hope is that these lessons will stay with the kids as they grow and pursue futures in whatever field they choose. In addition, I'm hoping to inspire some pride in creatorship. It's a very powerful feeling to know 'I made this thing,' and once they've had these successes early, I hope they will approach new challenges with zeal." + +She also says, "in learning to program, you have to learn to be hyper-vigilant about spelling and capitalization, and for some of our kids, reading is an issue. To make sure that the program is inclusive, we spell aloud during our lessons, and we encourage kids to speak up if they don't know a word or can't spell it correctly." + +Q also tries to give extra attention to children who need it. She says, "if I recognize that someone has a more severe problem, we try to get them paired with a tutor at our library outside of program time, but still allow them to come to the program. We want to help them without discouraging them from participating." + +Most importantly, the Parkman Coders program seeks to help every child realize that each has a unique skill set and abilities. Most of the children are African-American and half are girls. Q says, "we live in a world where we grow up with societal stigmas that frequently limit our own belief of what we can accomplish." She believes that children need a nonjudgmental space where "they can try new things, mess up, and discover." + +The environment Q and the Parkman Coders program creates helps the participants break away from economic and societal disadvantages. She says that the secret sauce is to "make sure you have a welcoming space so anyone can come and that your space is forgiving and understanding. Let people come as they are, and be prepared to teach and to learn; when people feel comfortable and engaged, they want to stay." + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/break-down-stereotypes-python + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://detroitpubliclibrary.org/locations/parkman +[2]: https://www.dplfound.org/single-post/2016/05/15/Parkman-Branch-Coders +[3]: https://www.linkedin.com/in/qumisha-goss-b3bb5470 +[4]: https://scratch.mit.edu/ +[5]: http://Code.org +[6]: https://www.amazon.com/Python-Programming-Introduction-Computer-Science/dp/1887902996 +[7]: https://nostarch.com/pythonforkids +[8]: https://automatetheboringstuff.com/ +[9]: https://nostarch.com/laurenipsum +[10]: https://www.raspberrypi.org/ +[11]: https://microbit.org/guide/ diff --git a/sources/talk/20190214 Top 5 podcasts for Linux news and tips.md b/sources/talk/20190214 Top 5 podcasts for Linux news and tips.md new file mode 100644 index 0000000000..fb827bb39b --- /dev/null +++ b/sources/talk/20190214 Top 5 podcasts for Linux news and tips.md @@ -0,0 +1,80 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Top 5 podcasts for Linux news and tips) +[#]: via: (https://opensource.com/article/19/2/top-linux-podcasts) +[#]: author: (Stephen Bancroft https://opensource.com/users/stevereaver) + +Top 5 podcasts for Linux news and tips +====== +A tried and tested podcast listener, shares his favorite Linux podcasts over the years, plus a couple of bonus picks. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/linux-penguin-penguins.png?itok=5hlVDue7) + +Like many Linux enthusiasts, I listen to a lot of podcasts. I find my daily commute is the best time to get some time to myself and catch up on the latest tech news. Over the years, I have subscribed and unsubscribed to more show feeds than I care to think about and have distilled them down to the best of the best. + +Here are my top five Linux podcasts I think you should be listening to in 2019, plus a couple of bonus picks. + + 5. [**Late Night Linux**][1]—This podcast, hosted by Joe, [Félim][2], [Graham][3], and [Will][4] from the UK, is rough, ready, and pulls no punches. [Joe Ressington][5] is always ready to tell it how it is, and Félim is always quick with his opinions. It's presented in a casual conversation format—but not one to have one with the kids around, especially with subjects they are all passionate about! + + + 4. [**Ask Noah Show**][6]—This show was forked from the Linux Action Show after it ended. Hosted by [Noah Chelliah][7], it's presented in a radio talkback style and takes live calls from listeners—it's syndicated from a local radio station in Grand Forks, North Dakota. The podcast isn't purely about Linux, but Noah takes on technical challenges and solves them with Linux and answers listeners' questions about how to achieve good technical solutions using Linux. + + + 3. [**The Ubuntu Podcast**][8]—If you want the latest about Ubuntu, you can't go past this show. In another podcast with a UK twist, hosts [Alan Pope][9] (Popey), [Mark Johnson][10], and [Martin Wimpress][11] (Wimpy) present a funny and insightful view of the open source community with news directly from Ubuntu. + + + 2. [**Linux Action News**][12]—The title says it all: it's a news show for Linux. This show was spawned from the popular Linux Action Show and is broadcast by the [Jupiter Broadcasting Network][13], which has many other tech-related podcasts. Hosts Chris Fisher and [Joe Ressington][5] present the show in a more formal "evening news" style, which runs around 30 minutes long. If you want to get a quick weekly update on Linux and Linux-related news, this is the show for you. + + + 1. [**Linux Unplugged**][14]—Finally, coming in at the number one spot is the granddaddy of them all, Linux Unplugged. This show gets to the core of what being in the Linux community is all about. Presented as a casual panel-style discussion by [Chris Fisher][15] and [Wes Payne][16], the podcast includes an interactive voice chatroom where listeners can connect and be heard live on the show as it broadcasts. + + + +Well, there you have it, my current shortlist of Linux podcasts. It's likely to change in the near future, but for now, I am enjoying every minute these guys put together. + +### Bonus podcasts + +Here are two bonus podcasts you might want to check out. + +**[Choose Linux][17]** is a brand-new podcast that is tantalizing because of its hosts: Joe Ressington of Linux Action News, who is a long-time Linux veteran, and [Jason Evangelho][18], a Forbes writer who recently shot to fame in the open source community with his articles showcasing his introduction to Linux and open source. Living vicariously through Jason's introduction to Linux has been and will continue to be fun. + +[**Command Line Heroes**][19] is a podcast produced by Red Hat. It has a very high production standard and has a slightly different format to the shows I have previously mentioned, anchored by a single presenter, developer, and [CodeNewbie][20] founder [Saron Yitbarek][21], who presents the latest innovations in open source. Now in its second season and released fortnightly, I highly recommend that you start from the first episode of this podcast. It starts with a great intro to the O/S wars of the '90s and sets the foundations for the start of Linux. + +Do you have a favorite Linux podcast that isn't on this list? Please share it in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/top-linux-podcasts + +作者:[Stephen Bancroft][a] +选题:[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/stevereaver +[b]: https://github.com/lujun9972 +[1]: https://latenightlinux.com/ +[2]: https://twitter.com/felimwhiteley +[3]: https://twitter.com/degville +[4]: https://twitter.com/8none1 +[5]: https://twitter.com/JoeRessington +[6]: http://www.asknoahshow.com/ +[7]: https://twitter.com/kernellinux?lang=en +[8]: http://ubuntupodcast.org/ +[9]: https://twitter.com/popey +[10]: https://twitter.com/marxjohnson +[11]: https://twitter.com/m_wimpress +[12]: https://linuxactionnews.com/ +[13]: https://www.jupiterbroadcasting.com/ +[14]: https://linuxunplugged.com/ +[15]: https://twitter.com/ChrisLAS +[16]: https://twitter.com/wespayne +[17]: https://chooselinux.show +[18]: https://twitter.com/killyourfm +[19]: https://www.redhat.com/en/command-line-heroes +[20]: https://www.codenewbie.org/ +[21]: https://twitter.com/saronyitbarek diff --git a/sources/talk/20190219 How Linux testing has changed and what matters today.md b/sources/talk/20190219 How Linux testing has changed and what matters today.md new file mode 100644 index 0000000000..ad26d6dbec --- /dev/null +++ b/sources/talk/20190219 How Linux testing has changed and what matters today.md @@ -0,0 +1,99 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How Linux testing has changed and what matters today) +[#]: via: (https://opensource.com/article/19/2/phoronix-michael-larabel) +[#]: author: (Don Watkins https://opensource.com/users/don-watkins) + +How Linux testing has changed and what matters today +====== +Michael Larabel, the founder of Phoronix, shares his insights on the evolution of Linux and open hardware. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mistake_bug_fix_find_error.png?itok=PZaz3dga) + +If you've ever wondered how your Linux computer stacks up against other Linux, Windows, and MacOS machines or searched for reviews of Linux-compatible hardware, you're probably familiar with [Phoronix][1]. Along with its website, which attracts more than 250 million visitors a year to its Linux reviews and news, the company also offers the [Phoronix Test Suite][2], an open source hardware benchmarking tool, and [OpenBenchmarking.org][3], where test result data is stored. + +According to [Michael Larabel][4], who started Phoronix in 2004, the site "is frequently cited as being the leading source for those interested in computer hardware and Linux. It offers insights regarding the development of the Linux kernel, product reviews, interviews, and news regarding free and open source software." + +I recently had the opportunity to interview Michael about Phoronix and his work. + +The questions and answers have been edited for length and clarity. + +**Don Watkins:** What inspired you to start Phoronix? + +**Michael Larabel:** When I started [Phoronix.com][5] in June 2004, it was still challenging to get a mouse or other USB peripherals working on the popular distributions of the time, like Mandrake, Yoper, MEPIS, and others. So, I set out to work on reviewing different hardware components and their compatibility with Linux. Over time, that shifted more from "does the basic device work?" to how well they perform and what features are supported or unsupported under Linux. + +It's been interesting to see the evolution and the importance of Linux on hardware rise. Linux was very common to LAMP/web servers, but Linux has also become synonymous with high-performance computing (HPC), Android smartphones, cloud software, autonomous vehicles, edge computing, digital signage, and related areas. While Linux hasn't quite dominated the desktop, it's doing great practically everywhere else. + +I also developed the Phoronix Test Suite, with its initial 1.0 public release in 2008, to increase the viability of testing on Linux, engage with more hardware and software vendors on best practices for testing, and just get more test cases running on Linux. At the time, there weren't any really shiny benchmarks on Linux like there were on Windows. + +**DW:** Who are your website's readers? + +**ML:** Phoronix's audience is as diverse as the content. Initially, it was quite desktop/gamer/enthusiast oriented, but as Linux's dominance has grown in HPC, cloud, embedded, etc., my testing has expanded in those areas and thus so has the readership. Readers tend to be interested in open source/Linux ecosystem advancements, performance, and a slight bent towards graphics processor and hardware driver interests. + +**DW:** How important is testing in the Linux world and how has it changed from when you started? + +**ML:** Testing has changed radically since 2004. Back then, many open source projects weren't carrying out any continuous integration (CI) or testing for regressions—both functional issues and performance problems. The hardware vendors supporting Linux were mostly trying to get things working and maintained while being less concerned about performance or scratching away at catching up to Mac, Solaris, and Windows. With time, we've seen the desktop reach close parity with (or exceed, depending upon your views) alternative operating systems. Most PC hardware now works out-of-the-box on Linux, most open source projects engage in some form of CI or testing, and more time and resources are afforded to advancing Linux performance. With high-frequency trading and cloud platforms relying on Linux, performance has become of utmost importance. + +Most of my testing at Phoronix.com is focused on benchmarking processors, graphics cards, storage devices, and other areas of interest to gamers and enthusiasts, but also interesting server platforms. Readers are also quite interested in testing of software components like the Linux kernel, code compilers, and filesystems. But in terms of the Phoronix Test Suite, its scope is rather limitless, with a framework in which new tests can be easily added and automated. There are currently more than 1,000 different profiles/suites, and new ones are routinely added—from machine learning tests to traditional benchmarks. + +**DW:** How important is open source hardware? Where do you see it going? + +**ML:** Open hardware is of increasing importance, especially in light of all the security vulnerabilities and disclosures in recent years. Facebook's work on the [Open Compute Project][6] can be commended, as can Google leveraging [Coreboot][7] in its Chromebook devices, and [Raptor Computing Systems][8]' successful, high-performance, open source POWER9 desktops/workstations/servers. [Intel][9] potentially open sourcing its firmware support package this year is also incredibly tantalizing and will hopefully spur more efforts in this space. + +Outside of that, open source hardware has had a really tough time cracking the consumer space due to the sheer amount of capital necessary and the complexities of designing a modern chip, etc., not to mention competing with the established hardware vendors' marketing budgets and other resources. So, while I would love for 100% open source hardware to dominate—or even compete in features and performance with proprietary hardware—in most segments, that is sadly unlikely to happen, especially with open hardware generally being much more expensive due to economies of scale. + +Software efforts like [OpenBMC][10], Coreboot/[Libreboot][11], and [LinuxBoot][12] are opening up hardware much more. Those efforts at liberating hardware have proven successful and will hopefully continue to be endorsed by more organizations. + +As for [OSHWA][13], I certainly applaud their efforts and the enthusiasm they bring to open source hardware. Certainly, for niche and smaller-scale devices, open source hardware can be a great fit. It will certainly be interesting to see what comes about with OSHWA and some of its partners like Lulzbot, Adafruit, and System76. + +**DW:** Can people install Phoronix Test Suite on their own computers? + +ML: The Phoronix Test Suite benchmarking software is open source under the GPL and can be downloaded from [Phoronix-Test-Suite.com][2] and [GitHub][14]. The benchmarking software works on not only Linux systems but also MacOS, Solaris, BSD, and Windows 10/Windows Server. The Phoronix Test Suite works on x86/x86_64, ARM/AArch64, POWER, RISC-V, and other architectures. + +**DW:** How does [OpenBenchmarking.org][15] work with the Phoronix Test Suite? + +**ML:** OpenBenchmarking.org is, in essence, the "cloud" component to the Phoronix Test Suite. It stores test profiles/test suites in a package manager-like fashion, allows users to upload their own benchmarking results, and offers related functionality around our benchmarking software. + +OpenBenchmarking.org is seamlessly integrated into the Phoronix Test Suite, but from the web interface, it is also where anyone can see the public benchmark results, inspect the open source test profiles to understand their methodology, research hardware and software data, and use similar functionality. + +Another component developed as part of the Phoronix Test Suite is [Phoromatic][16], which effectively allows anyone to deploy their own OpenBenchmarking-like environment within their own private intranet/LAN. This allows organizations to archive their benchmark results locally (and privately), orchestrate benchmarks automatically against groups of systems, manage the benchmark systems, and develop new test cases. + +**DW:** How can people stay up to date on Phoronix? + +**ML:** You can follow [me][17], [Phoronix][18], [Phoronix Test Suite][19], and [OpenBenchMarking.org][20] on Twitter. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/phoronix-michael-larabel + +作者:[Don Watkins][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/don-watkins +[b]: https://github.com/lujun9972 +[1]: https://www.phoronix.com/ +[2]: https://www.phoronix-test-suite.com/ +[3]: https://openbenchmarking.org/ +[4]: https://www.michaellarabel.com/ +[5]: http://Phoronix.com +[6]: https://www.opencompute.org/ +[7]: https://www.coreboot.org/ +[8]: https://www.raptorcs.com/ +[9]: https://www.phoronix.com/scan.php?page=news_item&px=Intel-Open-Source-FSP-Likely +[10]: https://en.wikipedia.org/wiki/OpenBMC +[11]: https://libreboot.org/ +[12]: https://linuxboot.org/ +[13]: https://www.oshwa.org/ +[14]: https://github.com/phoronix-test-suite/ +[15]: http://OpenBenchmarking.org +[16]: http://www.phoronix-test-suite.com/index.php?k=phoromatic +[17]: https://twitter.com/michaellarabel +[18]: https://twitter.com/phoronix +[19]: https://twitter.com/Phoromatic +[20]: https://twitter.com/OpenBenchmark diff --git a/sources/talk/20190219 How our non-profit works openly to make education accessible.md b/sources/talk/20190219 How our non-profit works openly to make education accessible.md new file mode 100644 index 0000000000..eee670610c --- /dev/null +++ b/sources/talk/20190219 How our non-profit works openly to make education accessible.md @@ -0,0 +1,136 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How our non-profit works openly to make education accessible) +[#]: via: (https://opensource.com/open-organization/19/2/building-curriculahub) +[#]: author: (Tanner Johnson https://opensource.com/users/johnsontanner3) + +How our non-profit works openly to make education accessible +====== +To build an open access education hub, our team practiced the same open methods we teach our students. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/OSDC_Education_2_OpenAccess_1040x584_12268077_0614MM.png?itok=xb96iaHe) + +I'm lucky to work with a team of impressive students at Duke University who are leaders in their classrooms and beyond. As members of [CSbyUs][1], a non-profit and student-run organization based at Duke, we connect university students to middle school students, mostly from [title I schools][2] across North Carolina's Research Triangle Park. Our mission is to fuel future change agents from under-resourced learning environments by fostering critical technology skills for thriving in the digital age. + +The CSbyUs Tech R&D team (TRD for short) recently set an ambitious goal to build and deploy a powerful web application over the course of one fall semester. Our team of six knew we had to do something about our workflow to ship a product by winter break. In our middle school classrooms, we teach our learners to use agile methodologies and design thinking to create mobile applications. On the TRD team, we realized we needed to practice what we preach in those classrooms to ship a quality product by semester's end. + +This is the story of how and why we utilized the principles we teach our students in order to deploy technology that will scale our mission and make our teaching resources open and accessible. + +### Setting the scene + +For the past two years, CSbyUs has operated "on the ground," connecting Duke undergraduates to Durham middle schools via after-school programming. After teaching and evaluating several iterations of our unique, student-centered mobile app development curriculum, we saw promising results. Our middle schoolers were creating functional mobile apps, connecting to their mentors, and leaving the class more confident in their computer science skills. Naturally, we wondered how to expand our programming. + +We knew we should take our own advice and lean into web-based technologies to share our work, but we weren't immediately sure what problem we needed to solve. Ultimately, we decided to create a web app that serves as a centralized hub for open source and open access digital education curricula. "CurriculaHub" (name inspired by GitHub) would be the defining pillar of CSbyUs's new website, where educators could share and adapt resources. + +But the vision and implementation didn't happen overnight. + +Given our sense of urgency and the potential of "CurriculaHub," we wanted to start this project with a well defined plan. The stakes were (and are) high, so planning, albeit occasionally tedious, was critical to our success. Like the curriculum we teach, we scaffolded our workflow process with design thinking and agile methodology, two critical 21st century frameworks we often fail to practice in higher ed. + +What follows is a step-wise explanation of our design thinking process, starting from inspiration and ending in a shipped prototype. + +``` +This is the story of how and why we utilized the principles we teach our students in order to deploy technology that will scale our mission and make our teaching resources open and accessible. +``` + +### Our Process + +#### **Step 1: Pre-Work** + +In order to understand the why to our what, you have to know who our team is. + +The members of this team are busy. All of us contribute to CSbyUs beyond our TRD-related responsibilities. As an organization with lofty goals beyond creating a web-based platform, we have to reconcile our "on the ground" commitments (i.e., curriculum curation, research and evaluation, mentorship training and practice, presentations at conferences, etc.) with our "in the cloud" technological goals. + +In addition to balancing time across our organization, we have to be flexible in the ways we communicate. As a remote member of the team, I'm writing this post from Spain, but the rest of our team is based in North Carolina, adding collaboration challenges. + +Before diving into development (or even problem identification), we knew we had to set some clear expectations for how we'd operate as a team. We took a note from our curriculum team's book and started with some [rules of engagement][3]. This is actually [a well-documented approach][4] to setting up a team's [social contract][5] used by teams across the tech space. During a summer internship at IBM, I remember pre-project meetings where my manager and team spent more than an hour clarifying principles of interaction. Whenever we faced uncertainty in our team operations, we'd pull out the rules of engagement and clear things up almost immediately. (An aside: I've found this strategy to be wildly effective not only in my teams, but in all relationships). + +Considering the remote nature of our team, one of our favorite tools is Slack. We use it for almost everything. We can't have sticky-note brainstorms, so we create Slack brainstorm threads. In fact, that's exactly what we did to generate our rules of engagement. One [open source principle we take to heart is transparency][6]; Slack allows us to archive and openly share our thought processes and decision-making steps with the rest of our team. + +#### **Step 2: Empathy Research** + +We're all here for unique reasons, but we find a common intersection: the desire to broaden equity in access to quality digital era education. + +Each member of our team has been lucky enough to study at Duke. We know how it feels to have limitless opportunities and the support of talented peers and renowned professors. But we're mindful that this isn't normal. Across the country and beyond, these opportunities are few and far between. Where they do exist, they're confined within the guarded walls of higher institutes of learning or come with a lofty price tag. + +While our team members' common desire to broaden access is clear, we work hard to root our decisions in research. So our team begins each semester [reviewing][7] [research][8] that justifies our existence. TRD works with CRD (curriculum research and development) and TT (teaching team), our two other CSbyUs sub-teams, to discuss current trends in digital education access, their systemic roots, and novel approaches to broaden access and make materials relevant to learners. We not only perform research collaboratively at the beginning of the semester but also implement weekly stand-up research meetings with the sub-teams. During these, CRD often presents new findings we've gleaned from interviewing current teachers and digging into the current state of access in our local community. They are our constant source of data-driven, empathy-fueling research. + +Through this type of empathy-based research, we have found that educators interested in student-centered teaching and digital era education lack a centralized space for proven and adaptable curricula and lesson plans. The bureaucracy and rigid structures that shape classroom learning in the United States makes reshaping curricula around the personal needs of students daunting and seemingly impossible. As students, educators, and technologists, we wondered how we might unleash the creativity and agency of others by sharing our own resources and creating an online ecosystem of support. + +#### **Step 3: Defining the Problem** + +We wanted to avoid [scope creep][9] caused by a poorly defined mission and vision (something that happens too often in some organizations). We needed structures to define our goals and maintain clarity in scope. Before imagining our application features, we knew we'd have to start with defining our north star. We would generate a clear problem statement to which we could refer throughout development. + +Before imagining our application features, we knew we'd have to start with defining our north star. + +This is common practice for us. Before committing to new programming, new partnerships, or new changes, the CSbyUs team always refers back to our mission and vision and asks, "Does this make sense?" (in fact, we post our mission and vision to the top of every meeting minutes document). If it fits and we have capacity to pursue it, we go for it. And if we don't, then we don't. In the case of a "no," we are always sure to document what and why because, as engineers know, [detailed logs are almost always a good decision][10]. TRD gleaned that big-picture wisdom and implemented a group-defined problem statement to guide our sub-team mission and future development decisions. + +To formulate a single, succinct problem statement, we each began by posting our own takes on the problem. Then, during one of our weekly [30-minute-no-more-no-less stand-up meetings][11], we identified commonalities and differences, ultimately [merging all our ideas into one][12]. Boiled down, we identified that there exist massive barriers for educators, parents, and students to share, modify, and discuss open source and accessible curricula. And of course, our mission would be to break down those barriers with user-centered technology. This "north star" lives as a highly visible document in our Google Drive, which has influenced our feature prioritization and future directions. + +#### **Step 4: Ideating a Solution** + +With our problem defined and our rules of engagement established, we were ready to imagine a solution. + +We believe that effective structures can ensure meritocracy and community. Sometimes, certain personalities dominate team decision-making and leave little space for collaborative input. To avoid that pitfall and maximize our equality of voice, we tend to use "offline" individual brainstorms and merge collective ideas online. It's the same process we used to create our rules of engagement and problem statement. In the case of ideating a solution, we started with "offline" brainstorms of three [S.M.A.R.T. goals][13]. Those goals would be ones we could achieve as a software development team (specifically because the CRD and TT teams offer different skill sets) and address our problem statement. Finally, we wrote these goals in a meeting minutes document, clustering common goals and ultimately identifying themes that describe our application features. In the end, we identified three: support, feedback, and open source curricula. + +From here, we divided ourselves into sub-teams, repeating the goal-setting process with those teams—but in a way that was specific to our features. And if it's not obvious by now, we realized a web-based platform would be the most optimal and scalable solution for supporting students, educators, and parents by providing a hub for sharing and adapting proven curricula. + +To work efficiently, we needed to be adaptive, reinforcing structures that worked and eliminating those that didn't. For example, we put a lot of effort in crafting meeting agendas. We strive to include only those subjects we must discuss in-person and table everything else for offline discussions on Slack or individually organized calls. We practice this in real time, too. During our regular meetings on Google Hangouts, if someone brings up a topic that isn't highly relevant or urgent, the current stand-up lead (a role that rotates weekly) "parking lots" it until the end of the meeting. If we have space at the end, we pull from the parking lot, and if not, we reserve that discussion for a Slack thread. + +This prioritization structure has led to massive gains in meeting efficiency and a focus on progress updates, shared technical hurdle discussions, collective decision-making, and assigning actionable tasks (the next-steps a person has committed to taking, documented with their name attached for everyone to view). + +#### **Step 5: Prototyping** + +This is where the fun starts. + +Our team was only able to unite new people with highly varied experience through the power of open principles and methodologies. + +Given our requirements—like an interactive user experience, the ability to collaborate on blogs and curricula, and the ability to receive feedback from our users—we began identifying the best technologies. Ultimately, we decided to build our web app with a ReactJS frontend and a Ruby on Rails backend. We chose these due to the extensive documentation and active community for both, and the well-maintained libraries that bridge the relationship between the two (e.g., react-on-rails). Since we chose Rails for our backend, it was obvious from the start that we'd work within a Model-View-Controller framework. + +Most of us didn't have previous experience with web development, neither on the frontend nor the backend. So, getting up and running with either technology independently presented a steep learning curve, and gluing the two together only steepened it. To centralize our work, we use an open-access GitHub repository. Given our relatively novice experience in web development, our success hinged on extremely efficient and open collaborations. + +And to explain that, we need to revisit the idea of structures. Some of ours include peer code reviews—where we can exchange best-practices and reusable solutions, maintaining up-to-date tech and user documentation so we can look back and understand design decisions—and (my personal favorite) our questions bot on Slack, which gently reminds us to post and answer questions in a separate Slack #questions channel. + +We've also dabbled with other strategies, like instructional videos for generating basic React components and rendering them in Rails Views. I tried this and in my first video, [I covered a basic introduction to our repository structure][14] and best practices for generating React components. While this proved useful, our team has since realized the wealth of online resources that document various implementations of these technologies robustly. Also, we simply haven't had enough time (but we might revisit them in the future—stay tuned). + +We're also excited about our cloud-based implementation. We use Heroku to host our application and manage data storage. In next iterations, we plan to both expand upon our current features and configure a continuous iteration/continuous development pipeline using services like Jenkins integrated with GitHub. + +#### **Step 6: Testing** + +Since we've [just deployed][1], we are now in a testing stage. Our goals are to collect user feedback across our feature domains and our application experience as a whole, especially as they interact with our specific audiences. Given our original constraints (namely, time and people power), this iteration is the first of many to come. For example, future iterations will allow for individual users to register accounts and post external curricula directly on our site without going through the extra steps of email. We want to scale and maximize our efficiency, and that's part of the recipe we'll deploy in future iterations. As for user testing: We collect user feedback via our contact form, via informal testing within our team, and via structured focus groups. [We welcome your constructive feedback and collaboration][15]. + +Our team was only able to unite new people with highly varied experience through the power of open principles and methodologies. Luckily enough, each one I described in this post is adaptable to virtually every team. + +Regardless of whether you work—on a software development team, in a classroom, or, heck, [even in your family][16]—principles like transparency and community are almost always the best foundation for a successful organization. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/open-organization/19/2/building-curriculahub + +作者:[Tanner Johnson][a] +选题:[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/johnsontanner3 +[b]: https://github.com/lujun9972 +[1]: http://csbyus.org +[2]: https://www2.ed.gov/programs/titleiparta/index.html +[3]: https://docs.google.com/document/d/1tqV6B6Uk-QB7Psj1rX9tfCyW3E64_v6xDlhRZ-L2rq0/edit +[4]: https://www.atlassian.com/team-playbook/plays/rules-of-engagement +[5]: https://openpracticelibrary.com/practice/social-contract/ +[6]: https://opensource.com/open-organization/resources/open-org-definition +[7]: https://services.google.com/fh/files/misc/images-of-computer-science-report.pdf +[8]: https://drive.google.com/file/d/1_iK0ZRAXVwGX9owtjUUjNz3_2kbyYZ79/view?usp=sharing +[9]: https://www.pmi.org/learning/library/top-five-causes-scope-creep-6675 +[10]: https://www.codeproject.com/Articles/42354/The-Art-of-Logging#what +[11]: https://opensource.com/open-organization/16/2/6-steps-running-perfect-30-minute-meeting +[12]: https://docs.google.com/document/d/1wdPRvFhMKPCrwOG2CGp7kP4rKOXrJKI77CgjMfaaXnk/edit?usp=sharing +[13]: https://www.projectmanager.com/blog/how-to-create-smart-goals +[14]: https://www.youtube.com/watch?v=52kvV0plW1E +[15]: http://csbyus.org/ +[16]: https://opensource.com/open-organization/15/11/what-our-families-teach-us-about-organizational-life diff --git a/sources/talk/20190220 Do Linux distributions still matter with containers.md b/sources/talk/20190220 Do Linux distributions still matter with containers.md new file mode 100644 index 0000000000..c1c7886d0d --- /dev/null +++ b/sources/talk/20190220 Do Linux distributions still matter with containers.md @@ -0,0 +1,87 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Do Linux distributions still matter with containers?) +[#]: via: (https://opensource.com/article/19/2/linux-distributions-still-matter-containers) +[#]: author: (Scott McCarty https://opensource.com/users/fatherlinux) + +Do Linux distributions still matter with containers? +====== +There are two major trends in container builds: using a base image and building from scratch. Each has engineering tradeoffs. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/cube_innovation_process_block_container.png?itok=vkPYmSRQ) + +Some people say Linux distributions no longer matter with containers. Alternative approaches, like distroless and scratch containers, seem to be all the rage. It appears we are considering and making technology decisions based more on fashion sense and immediate emotional gratification than thinking through the secondary effects of our choices. We should be asking questions like: How will these choices affect maintenance six months down the road? What are the engineering tradeoffs? How does this paradigm shift affect our build systems at scale? + +It's frustrating to watch. If we forget that engineering is a zero-sum game with measurable tradeoffs—advantages and disadvantages, with costs and benefits of different approaches— we do ourselves a disservice, we do our employers a disservice, and we do our colleagues who will eventually maintain our code a disservice. Finally, we do all of the maintainers ([hail the maintainers!][1]) a disservice by not appreciating the work they do. + +### Understanding the problem + +To understand the problem, we have to investigate why we started using Linux distributions in the first place. I would group the reasons into two major buckets: kernels and other packages. Compiling kernels is actually fairly easy. Slackware and Gentoo (I still have a soft spot in my heart) taught us that. + +On the other hand, the tremendous amount of development and runtime software that needs to be packaged for a usable Linux system can be daunting. Furthermore, the only way you can ensure that millions of permutations of packages can be installed and work together is by using the old paradigm: compile it and ship it together as a thing (i.e., a Linux distribution). So, why do Linux distributions compile kernels and all the packages together? Simple: to make sure things work together. + +First, let's talk about kernels. The kernel is special. Booting a Linux system without a compiled kernel is a bit of a challenge. It's the core of a Linux operating system, and it's the first thing we rely on when a system boots. Kernels have a lot of different configuration options when they're being compiled that can have a tremendous effect on how hardware and software run on one. A secondary problem in this bucket is that system software, like compilers, C libraries, and interpreters, must be tuned for the options you built into the kernel. Gentoo taught us this in a visceral way, which turned everyone into a miniature distribution maintainer. + +Embarrassingly (because I have worked with containers for the last five years), I must admit that I have compiled kernels quite recently. I had to get nested KVM working on RHEL 7 so that I could run [OpenShift on OpenStack][2] virtual machines, in a KVM virtual machine on my laptop, as well as [our Container Development Kit (CDK][3]). #justsayin Suffice to say, I fired RHEL7 up on a brand new 4.X kernel at the time. Like any good sysadmin, I was a little worried that I missed some important configuration options and patches. And, of course, I had missed some things. Sleep mode stopped working right, my docking station stopped working right, and there were numerous other small, random errors. But it did work well enough for a live demo of OpenShift on OpenStack, in a single KVM virtual machine on my laptop. Come on, that's kinda' fun, right? But I digress… + +Now, let's talk about all the other packages. While the kernel and associated system software can be tricky to compile, the much, much bigger problem from a workload perspective is compiling thousands and thousands of packages to give us a useable Linux system. Each package requires subject matter expertise. Some pieces of software require running only three commands: **./configure** , **make** , and **make install**. Others require a lot of subject matter expertise ranging from adding users and configuring specific defaults in **etc** to running post-install scripts and adding systemd unit files. The set of skills necessary for the thousands of different pieces of software you might use is daunting for any single person. But, if you want a usable system with the ability to try new software whenever you want, you have to learn how to compile and install the new software before you can even begin to learn to use it. That's Linux without a Linux distribution. That's the engineering problem you are agreeing to when you forgo a Linux distribution. + +The point is that you have to build everything together to ensure it works together with any sane level of reliability, and it takes a ton of knowledge to build a usable cohort of packages. This is more knowledge than any single developer or sysadmin is ever going to reasonably learn and retain. Every problem I described applies to your [container host][4] (kernel and system software) and [container image][5] (system software and all other packages)—notice the overlap; there are compilers, C libraries, interpreters, and JVMs in the container image, too. + +### The solution + +You already know this, but Linux distributions are the solution. Stop reading and send your nearest package maintainer (again, hail the maintainers!) an e-card (wait, did I just give my age away?). Seriously though, these people do a ton of work, and it's really underappreciated. Kubernetes, Istio, Prometheus, and Knative: I am looking at you. Your time is coming too, when you will be in maintenance mode, overused, and underappreciated. I will be writing this same article again, probably about Kubernetes, in about seven to 10 years. + +### First principles with container builds + +There are tradeoffs to building from scratch and building from base images. + +#### Building from base images + +Building from base images has the advantage that most build operations are nothing more than a package install or update. It relies on a ton of work done by package maintainers in a Linux distribution. It also has the advantage that a patching event six months—or even 10 years—from now (with RHEL) is an operations/systems administrator event (yum update), not a developer event (that requires picking through code to figure out why some function argument no longer works). + +Let's double-click on that a bit. Application code relies on a lot of libraries ranging from JSON munging libraries to object-relational mappers. Unlike the Linux kernel and Glibc, these types of libraries change with very little regard to breaking API compatibility. That means that three years from now your patching event likely becomes a code-changing event, not a yum update event. Got it, let that sink in. Developers, you are getting paged at 2 AM if the security team can't find a firewall hack to block the exploit. + +Building from a base image is not perfect; there are disadvantages, like the size of all the dependencies that get dragged in. This will almost always make your container images larger than building from scratch. Another disadvantage is you will not always have access to the latest upstream code. This can be frustrating for developers, especially when you just want to get something out the door, but not as frustrating as being paged to look at a library you haven't thought about in three years that the upstream maintainers have been changing the whole time. + +If you are a web developer and rolling your eyes at me, I have one word for you: DevOps. That means you are carrying a pager, my friend. + +#### Building from scratch + +Scratch builds have the advantage of being really small. When you don't rely on a Linux distribution in the container, you have a lot of control, which means you can customize everything for your needs. This is a best-of-breed model, and it's valid in certain use cases. Another advantage is you have access to the latest packages. You don't have to wait for a Linux distro to update anything. You are in control, so you choose when to spend the engineering work to incorporate new software. + +Remember, there is a cost to controlling everything. Often, updating to new libraries with new features drags in unwanted API changes, which means fixing incompatibilities in code (in other words, [shaving yaks][6]). Shaving yaks at 2 AM when the application doesn't work is not fun. Luckily, with containers, you can roll back and shave the yaks the next business day, but it will still eat into your time for delivering new value to the business, new features to your applications. Welcome to the life of a sysadmin. + +OK, that said, there are times that building from scratch makes sense. I will completely concede that statically compiled Golang programs and C programs are two decent candidates for scratch/distroless builds. With these types of programs, every container build is a compile event. You still have to worry about API breakage three years from now, but if you are a Golang shop, you should have the skillset to fix things over time. + +### Conclusion + +Basically, Linux distributions do a ton of work to save you time—on a regular Linux system or with containers. The knowledge that maintainers have is tremendous and leveraged so much without really being appreciated. The adoption of containers has made the problem even worse because it's even further abstracted. + +With container hosts, a Linux distribution offers you access to a wide hardware ecosystem, ranging from tiny ARM systems, to giant 128 CPU x86 boxes, to cloud-provider VMs. They offer working container engines and container runtimes out of the box, so you can just fire up your containers and let somebody else worry about making things work. + +For container images, Linux distributions offer you easy access to a ton of software for your projects. Even when you build from scratch, you will likely look at how a package maintainer built and shipped things—a good artist is a good thief—so, don't undervalue this work. + +So, thank you to all of the maintainers in Fedora, RHEL (Frantisek, you are my hero), Debian, Gentoo, and every other Linux distribution. I appreciate the work you do, even though I am a "container guy." + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/linux-distributions-still-matter-containers + +作者:[Scott McCarty][a] +选题:[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/fatherlinux +[b]: https://github.com/lujun9972 +[1]: https://aeon.co/essays/innovation-is-overvalued-maintenance-often-matters-more +[2]: https://blog.openshift.com/openshift-on-openstack-delivering-applications-better-together/ +[3]: https://developers.redhat.com/blog/2018/02/13/red-hat-cdk-nested-kvm/ +[4]: https://developers.redhat.com/blog/2018/02/22/container-terminology-practical-introduction/#h.8tyd9p17othl +[5]: https://developers.redhat.com/blog/2018/02/22/container-terminology-practical-introduction/#h.dqlu6589ootw +[6]: https://en.wiktionary.org/wiki/yak_shaving diff --git a/sources/talk/20190222 Developer happiness- What you need to know.md b/sources/talk/20190222 Developer happiness- What you need to know.md new file mode 100644 index 0000000000..8ef7772193 --- /dev/null +++ b/sources/talk/20190222 Developer happiness- What you need to know.md @@ -0,0 +1,79 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Developer happiness: What you need to know) +[#]: via: (https://opensource.com/article/19/2/developer-happiness) +[#]: author: (Bart Copeland https://opensource.com/users/bartcopeland) + +Developer happiness: What you need to know +====== +Developers need the tools and the freedom to code quickly, without getting bogged down by compliance and security. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_happy_sad_developer_programming.png?itok=72nkfSQ_) + +A person needs the right tools for the job. There's nothing as frustrating as getting halfway through a car repair, for instance, only to discover you don't have the specialized tool you need to complete the job. The same concept applies to developers: you need the tools to do what you are best at, without disrupting your workflow with compliance and security needs, so you can produce code faster. + +Over half—51%, to be specific—of developers spend only one to four hours each day programming, according to ActiveState's recent [Developer Survey 2018: Open Source Runtime Pains][1]. In other words, the majority of developers spend less than half of their time coding. According to the survey, 50% of developers say security is one of their biggest concerns, but 67% of developers choose not to add a new language when coding because of the difficulties related to corporate policies. + +The result is developers have to devote time to non-coding activities like retrofitting software for security and compliance criteria checked after software and languages have been built. And they won't choose the best tool or language for the job because of corporate policies. Their satisfaction goes down and risk goes up. + +So, developers aren't able to devote time to high-value work. This creates additional business risk because their time-to-market is slowed, and the organization increases tech debt by not empowering developers to decide on "the best" tech, unencumbered by corporate policy drag. + +### Baking in security and compliance workflows + +How can we solve this issue? One way is to integrate security and compliance workflows into the software development process in four easy steps: + +#### 1\. Gather your forces + +Get support from everyone involved. This is an often-forgotten but critical first step. Make sure to consider a wide range of stakeholders, including: + + * DevOps + * Developers + * InfoSec + * Legal/compliance + * IT security + + + +Stakeholders want to understand the business benefits, so make a solid case for eliminating the security and compliance checkpoints after software builds. You can consider any (or all) of the following in building your business case: time savings, opportunity cost, and developer productivity. By integrating security and compliance workflows into the development process, you also avoid retrofitting of languages. + +#### 2\. Find trustworthy sources + +Next, choose the trusted sources that can be used, along with their license and security requirements. Consider including information such as: + + * Restrictions on usage based on environment or application type and version controls per language + * Which open source components are allowable, e.g., specific packages + * Which licenses can be used in which types of environments (e.g., research vs. production) + * The definition of security levels, acceptable vulnerability risk levels, what risk levels trigger an action, what that action would be, and who would be responsible for its implementation + + + +#### 3\. Incorporate security and compliance from day one + +The upshot of incorporating security and compliance workflows is that it ultimately bakes security and compliance into the first line of code. It eliminates the drag of corporate policy because you're coding to spec versus having to fix things after the fact. But to do this, consider mechanisms for automatically scanning code as it's being built, along with using agentless monitoring of your runtime code. You're freeing up your time, and you'll also be able to programmatically enforce policies to ensure compliance across your entire organization. + +New vulnerabilities arise, and new patches and versions become available. Consequently, security and compliance need to be considered when deploying code into production and also when running code. You need to know what, if any, code is at risk and where that code is running. So, the process for deploying and running code should include monitoring, reporting, and updating code in production. + +By integrating security and compliance into your software development process from the start, you can also benefit by tracking where your code is running once deployed and be alerted of new threats as they arise. You will be able to track when your applications were vulnerable and respond with automatic enforcement of your software policies. + +If your software development process has security and compliance workflows baked in, you will improve your productivity. And you'll be able to measure value through increased time spent coding; gains in security and stability; and cost- and time-savings in maintenance and discovery of security and compliance threats. + +### Happiness through integration + +If you don't develop and update software, your organization can't go forward. Developers are a linchpin in the success of your company, which means they need the tools and the freedom to code quickly. You can't let compliance and security needs—though they are critical—bog you down. Developers clearly worry about security, so the happy medium is to "shift left" and integrate security and compliance workflows from the start. You'll get more done, get it right the first time, and spend far less time retrofitting code. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/developer-happiness + +作者:[Bart Copeland][a] +选题:[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/bartcopeland +[b]: https://github.com/lujun9972 +[1]: https://www.activestate.com/company/press/press-releases/activestate-developer-survey-examines-open-source-challenges/ diff --git a/sources/talk/20190223 No- Ubuntu is NOT Replacing Apt with Snap.md b/sources/talk/20190223 No- Ubuntu is NOT Replacing Apt with Snap.md new file mode 100644 index 0000000000..bb7dd14943 --- /dev/null +++ b/sources/talk/20190223 No- Ubuntu is NOT Replacing Apt with Snap.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (No! Ubuntu is NOT Replacing Apt with Snap) +[#]: via: (https://itsfoss.com/ubuntu-snap-replaces-apt-blueprint/) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +No! Ubuntu is NOT Replacing Apt with Snap +====== + +Stop believing the rumors that Ubuntu is planning to replace Apt with Snap in the [Ubuntu 19.04 release][1]. These are only rumors. + +![Snap replacing apt rumors][2] + +Don’t get what I am talking about? Let me give you some context. + +There is a ‘blueprint’ on Ubuntu’s launchpad website, titled ‘Replace APT with snap as default package manager’. It talks about replacing Apt (package manager at the heart of Debian) with Snap ( a new packaging system by Ubuntu). + +> Thanks to Snap, the need for APT is disappearing, fast… why don’t we use snap at the system level? + +The post further says “Imagine, for example, being able to run “sudo snap install cosmic” to upgrade to the current release, “sudo snap install –beta disco” (in March) to upgrade to a beta release, or, for that matter, “sudo snap install –edge disco” to upgrade to a pre-beta release. It would make the whole process much easier, and updates could simply be delivered as updates to the corresponding snap, which could then just be pushed to the repositories and there it is. This way, instead of having a separate release updater, it would be possible to A, run all system updates completely and silently in the background to avoid nagging the user (a la Chrome OS), and B, offer release upgrades in the GNOME software store, Mac-style, as banners, so the user can install them easily. It would make the user experience both more consistent and even more user-friendly than it currently is.” + +It might sound good and promising and if you take a look at [this link][3], even you might start believing the rumor. Why? Because at the bottom of the blueprint information, it lists Ubuntu-founder Mark Shuttleworth as the approver. + +![Apt being replaced with Snap blueprint rumor][4]Mark Shuttleworth’s name adds to the confusion + +The rumor got fanned when the Switch to Linux YouTube channel covered it. You can watch the video from around 11:30. + + + +When this ‘news’ was brought to my attention, I reached out to Alan Pope of Canonical and asked him if he or his colleagues at Canonical (Ubuntu’s parent company) could confirm it. + +Alan clarified that the so called blueprint was not associated with official Ubuntu team. It was created as a proposal by some community member not affiliated with Ubuntu. + +> That’s not anything official. Some random community person made it. Anyone can write a blueprint. +> +> Alan Pope, Canonical + +Alan further elaborated that anyone can create such blueprints and tag Mark Shuttleworth or other Ubuntu members in it. Just because Mark’s name was listed as the approver, it doesn’t mean he already approved the idea. + +Canonical has no such plans to replace Apt with Snap. It’s not as simple as the blueprint in question suggests. + +After talking with Alan, I decided to not write about this topic because I don’t want to fan baseless rumors and confuse people. + +Unfortunately, the ‘replace Apt with Snap’ blueprint is still being shared on various Ubuntu and Linux related groups and forums. Alan had to publicly dismiss these rumors in a series of tweets: + +> Seen this [#Ubuntu][5] blueprint being shared around the internet. It's not official, not a thing we're doing. Just because someone made a blueprint, doesn't make it fact. +> +> — Alan Pope 🇪🇺🇬🇧 (@popey) [February 23, 2019][6] + +I don’t want you, the It’s FOSS reader, to fell for such silly rumors so I quickly penned this article. + +If you come across ‘apt being replaced with snap’ discussion, you may tell people that it’s not true and provide them this link as a reference. + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/ubuntu-snap-replaces-apt-blueprint/ + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/ubuntu-19-04-release-features/ +[2]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/snap-replacing-apt.png?resize=800%2C450&ssl=1 +[3]: https://blueprints.launchpad.net/ubuntu/+spec/package-management-default-snap +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/apt-snap-blueprint.jpg?ssl=1 +[5]: https://twitter.com/hashtag/Ubuntu?src=hash&ref_src=twsrc%5Etfw +[6]: https://twitter.com/popey/status/1099238146393468931?ref_src=twsrc%5Etfw diff --git a/sources/talk/20190225 Teaching scientists how to share code.md b/sources/talk/20190225 Teaching scientists how to share code.md new file mode 100644 index 0000000000..074da27476 --- /dev/null +++ b/sources/talk/20190225 Teaching scientists how to share code.md @@ -0,0 +1,72 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Teaching scientists how to share code) +[#]: via: (https://opensource.com/article/19/2/open-science-git) +[#]: author: (Jon Tennant https://opensource.com/users/jon-tennant) + +Teaching scientists how to share code +====== +This course teaches them how to set up a GitHub project, index their project in Zenodo, and integrate Git into an RStudio workflow. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolserieshe_rh_051x_0.png?itok=gIzbmxuI) + +Would it surprise you to learn that most of the world's scholarly research is not owned by the people who funded it or who created it? Rather it's owned by private corporations and locked up in proprietary systems, leading to [problems][1] around sharing, reuse, and reproducibility. + +The open science movement is challenging this system, aiming to give researchers control, ownership, and freedom over their work. The [Open Science MOOC][2] (massively open online community) is a mission-driven project launched in 2018 to kick-start an open scientific revolution and foster more partnerships between open source software and open science. + +The Open Science MOOC is a peer-to-peer community of practice, based around sharing knowledge and ideas, learning new skills, and using these things to develop as individuals so research communities can grow as part of a wider cultural shift towards openness. + +### The curriculum + +The Open Science MOOC is divided into 10 core modules, from the principles of open science to becoming an open science advocate. + +The first module, [Open Research Software and Open Source][3], was released in late 2018. It includes three main tasks, all designed to help make research workflows more efficient and more open for collaboration: + +#### 1\. Setting up your first GitHub project + +GitHub is a powerful project management tool, both for coders and non-coders. This task teaches how to create a community around the platform, select an appropriate license, and write good documentation (including README files, contributing guidelines, and codes of conduct) to foster open collaboration and a welcoming community. + +#### 2\. Indexing your project in Zenodo + +[Zenodo][4] is an open science platform that seamlessly integrates with GitHub to help make projects more permanent, reusable, and citable. This task explains how webhooks between Zenodo and GitHub allow new versions of projects to become permanently archived as they progress. This is critical for helping researchers get a [DOI][5] for their work so they can receive full credit for all aspects of a project. As citations are still a primary form of "academic capital," this is essential for researchers. + +#### 3\. Integrating Git into an RStudio workflow + +This task is about giving research a mega-boost through greater collaborative efficiency and reproducibility. Git enables version control in all forms of text-based content, including data analysis and writing papers. Each time you save your work during the development process, Git saves time-stamped copies. This saves the hassle of trying to "roll back" projects if you delete a file or text by mistake, and eliminates horrific file-naming conventions. (For example, does FINAL_Revised_2.2_supervisor_edits_ver1.7_scream.txt look familiar?) Getting Git to interface with RStudio is the painful part, but this task goes through it, step by step, to ease the stress. + +The third task also gives students the ability to interact directly with the MOOC by submitting pull requests to demonstrate their skills. This also adds their name to an online list of open source champions (aka "open sourcerers"). + +The MOOC's inherently interactive style is much more valuable than listening to someone talk at you, either on or off screen, like with many traditional online courses or educational programs. Each task is backed up by expert-gathered knowledge, so students get a rigorous, dual-learning experience. + +### Empowering researchers + +The Open Science MOOC strives to be as open as possible—this means we walk the walk and talk the talk. We are built upon a solid values-based foundation of freedom and equitable access to research. We see this route towards widespread adoption of best scientific practices as an essential part of the research process. + +Everything we produce is openly developed and openly licensed for maximum engagement, sharing, and reuse. An open source workflow underpins our development. All of this happens openly around channels such as [Slack][6] and [GitHub][7] and helps to make the community much more coherent. + +If we can instill the value of open source into modern research, this would empower current and future generations of researchers to think more about fundamental freedoms around knowledge production. We think that is something worth working towards as a community. + +The Open Science MOOC combines the best elements of the open education, open science, and open source worlds. If you're ready to join, [sign up for the full course][3], which is, of course, free. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/open-science-git + +作者:[Jon Tennant][a] +选题:[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/jon-tennant +[b]: https://github.com/lujun9972 +[1]: https://www.theguardian.com/science/political-science/2018/jun/29/elsevier-are-corrupting-open-science-in-europe +[2]: https://opensciencemooc.eu/ +[3]: https://eliademy.com/catalog/oer/module-5-open-research-software-and-open-source.html +[4]: https://zenodo.org/ +[5]: https://en.wikipedia.org/wiki/Digital_object_identifier +[6]: https://osmooc.herokuapp.com/ +[7]: https://open-science-mooc-invite.herokuapp.com/ diff --git a/sources/talk/20190226 Reducing security risks with centralized logging.md b/sources/talk/20190226 Reducing security risks with centralized logging.md new file mode 100644 index 0000000000..60bbd7a80b --- /dev/null +++ b/sources/talk/20190226 Reducing security risks with centralized logging.md @@ -0,0 +1,82 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Reducing security risks with centralized logging) +[#]: via: (https://opensource.com/article/19/2/reducing-security-risks-centralized-logging) +[#]: author: (Hannah Suarez https://opensource.com/users/hcs) + +Reducing security risks with centralized logging +====== +Centralizing logs and structuring log data for processing can mitigate risks related to insufficient logging. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security_privacy_lock.png?itok=ZWjrpFzx) + +Logging and log analysis are essential to securing infrastructure, particularly when we consider common vulnerabilities. This article, based on my lightning talk [Let's use centralized log collection to make incident response teams happy][1] at FOSDEM'19, aims to raise awareness about the security concerns around insufficient logging, offer a way to avoid the risk, and advocate for more secure practices _(disclaimer: I work for NXLog)._ + +### Why log collection and why centralized logging? + +Logging is, to be specific, an append-only sequence of records written to disk. In practice, logs help you investigate an infrastructure issue as you try to find a cause for misbehavior. A challenge comes up when you have heterogeneous systems with their own standards and formats, and you want to be able to handle and process these in a dependable way. This often comes at the cost of metadata. Centralized logging solutions require commonality, and that commonality often removes the rich metadata many open source logging tools provide. + +### The security risk of insufficient logging and monitoring + +The Open Web Application Security Project ([OWASP][2]) is a nonprofit organization that contributes to the industry with incredible projects (including many [tools][3] focusing on software security). The organization regularly reports on the riskiest security challenges for application developers and maintainers. In its most recent report on the [top 10 most critical web application security risks][4], OWASP added Insufficient Logging and Monitoring to its list. OWASP warns of risks due to insufficient logging, detection, monitoring, and active response in the following types of scenarios. + + * Important auditable events, such as logins, failed logins, and high-value transactions are not logged. + * Warnings and errors generate none, inadequate, or unclear log messages. + * Logs are only being stored locally. + * The application is unable to detect, escalate, or alert for active attacks in real time or near real time. + + + +These instances can be mitigated by centralizing logs (i.e., not storing logs locally) and structuring log data for processing (i.e., in alerting dashboards and security suites). + +For example, imagine a DNS query leads to a malicious site named **hacked.badsite.net**. With DNS monitoring, administrators monitor and proactively analyze DNS queries and responses. The efficiency of DNS monitoring relies on both sufficient logging and log collection in order to catch potential issues as well as structuring the resulting DNS log for further processing: + +``` +2019-01-29 +Time (GMT)      Source                  Destination             Protocol-Info +12:42:42.112898 SOURCE_IP               xxx.xx.xx.x             DNS     Standard query 0x1de7  A hacked.badsite.net +``` + +You can try this yourself and run through other examples and snippets with the [NXLog Community Edition][5] _(disclaimer again: I work for NXLog)._ + +### Important aside: unstructured vs. structured data + +It's important to take a moment and consider the log data format. For example, let's consider this log message: + +``` +debug1: Failed password for invalid user amy from SOURCE_IP port SOURCE_PORT ssh2 +``` + +This log contains a predefined structure, such as a metadata keyword before the colon ( **debug1** ). However, the rest of the log field is an unstructured string ( **Failed password for invalid user amy from SOURCE_IP port SOURCE_PORT ssh2** ). So, while the message is easily available in a human-readable format, it is not a format a computer can easily parse. + +Unstructured event data poses limitations including difficulty of parsing, searching, and analyzing the logs. The important metadata is too often set in an unstructured data field in the form of a freeform string like the example above. Logging administrators will come across this problem at some point as they attempt to standardize/normalize log data and centralize their log sources. + +### Where to go next + +Alongside centralizing and structuring your logs, make sure you're collecting the right log data—Sysmon, PowerShell, Windows EventLog, DNS debug, NetFlow, ETW, kernel monitoring, file integrity monitoring, database logs, external cloud logs, and so on. Also have the right tools and processes in place to collect, aggregate, and help make sense of the data. + +Hopefully, this gives you a starting point to centralize log collection across diverse sources; send them to outside sources like dashboards, monitoring software, analytics software, specialized software like security information and event management (SEIM) suites; and more. + +What does your centralized logging strategy look like? Share your thoughts in the comments. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/reducing-security-risks-centralized-logging + +作者:[Hannah Suarez][a] +选题:[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/hcs +[b]: https://github.com/lujun9972 +[1]: https://fosdem.org/2019/schedule/event/lets_use_centralized_log_collection_to_make_incident_response_teams_happy/ +[2]: https://www.owasp.org/index.php/Main_Page +[3]: https://github.com/OWASP +[4]: https://www.owasp.org/index.php/Top_10-2017_Top_10 +[5]: https://nxlog.co/products/nxlog-community-edition/download diff --git a/sources/talk/20190227 Let your engineers choose the license- A guide.md b/sources/talk/20190227 Let your engineers choose the license- A guide.md new file mode 100644 index 0000000000..81a8dd8ee2 --- /dev/null +++ b/sources/talk/20190227 Let your engineers choose the license- A guide.md @@ -0,0 +1,62 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Let your engineers choose the license: A guide) +[#]: via: (https://opensource.com/article/19/2/choose-open-source-license-engineers) +[#]: author: (Jeffrey Robert Kaufman https://opensource.com/users/jkaufman) + +Let your engineers choose the license: A guide +====== +Enabling engineers to make licensing decisions is wise and efficient. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk) + +Imagine you are working for a company that will be starting a new open source community project. Great! You have taken a positive first step to give back and enable a virtuous cycle of innovation that the open source community-based development model provides. + +But what about choosing an open source license for your project? You ask your manager for guidance, and she provides some perspective but quickly realizes that there is no formal company policy or guidelines. As any wise manager would do, she asks you to develop formal corporate guidelines for choosing an open source license for such projects. + +Simple, right? You may be surprised to learn some unexpected challenges. This article will describe some of the complexities you may encounter and some perspective based on my recent experience with a similar project at Red Hat. + +It may be useful to quickly review some of the more common forms of open source licensing. Open source licenses may be generally placed into two main buckets, copyleft and permissive. + +> Copyleft licenses, such as the GPL, allow access to source code, modifications to the source, and distribution of the source or binary versions in their original or modified forms. Copyleft additionally provides that essential software freedoms (run, study, change, and distribution) will be allowed and ensured for any recipients of that code. A copyleft license prohibits restrictions or limitations on these essential software freedoms. +> +> Permissive licenses, similar to copyleft, also generally allow access to source code, modifications to the source, and distribution of the source or binary versions in their original or modified forms. However, unlike copyleft licenses, additional restrictions may be included with these forms of licenses, including proprietary limitations such as prohibiting the creation of modified works or further distribution. + +Red Hat is one of the leading open source development companies, with thousands of open source developers continuously working upstream and contributing to an assortment of open source projects. When I joined Red Hat, I was very familiar with its flagship Red Hat Enterprise Linux offering, often referred to as RHEL. Although I fully expected that the company contributes under a wide assortment of licenses based on project requirements, I thought our preference and top recommendation for our engineers would be GPLv2 due to our significant involvement with Linux. In addition, GPL is a copyleft license, and copyleft ensures that the essential software freedoms (run, study, change, distribute) will be extended to any recipients of that code. What could be better for sustaining the open source ecosystem than a copyleft license? + +Fast forwarding on my journey to craft internal license choice guidelines for Red Hat, the end result was to not have any license preference at all. Instead, we delegate that responsibility, to the maximum extent possible, to our engineers. Why? Because each open source project and community is unique and there are social aspects to these communities that may have preferences towards various licensing philosophies (e.g., copyleft or permissive). Engineers working in those communities understand all these issues and are best equipped to choose the proper license on this knowledge. Mandating certain licenses for code contributions often will conflict with these community norms and result in reduction or prohibition in contributed content. + +For example, perhaps your organization believes that the latest GPL license (GPLv3) is the best for your company due to its updated provisions. If you mandated GPLv3 for all future contributions vs. GPLv2, you would be prohibited from contributing code to the Linux kernel, since that is a GPLv2 project and will likely remain that way for a very long time. Your engineers, being part of that open source community project, would know that and would automatically choose GPLv2 in the absence of such a mandate. + +Bottom line: Enabling engineers to make these decisions is wise and efficient. + +To the extent your organization may have to restrict the use of certain licenses (e.g., due to certain intellectual property concerns), this should naturally be part of your guidelines or policy. I believe it is much better to delegate to the maximum extent possible to those that understand all the nuances, politics, and licensing philosophies of these varied communities and restrict license choice only when absolutely necessary. Even having a preference for a certain license over another can be problematic. Open source engineers may have deeply rooted feelings about copyleft (either for or against), and forcing one license over the other (unless absolutely necessary for business reasons) may result in creating ill-will and ostracizing an engineer or engineering department within your organization + +In summary, Red Hat's guidelines are very simple and are summarized below: + + 1. We suggest choosing an open source license from a set of 10 different licenses that are very common and meet the needs of most new open source projects. + + 2. We allow the use of other licenses but we ask that a reason is provided to the open source legal team so we can collect and better understand some of the new and perhaps evolving needs of the open source communities that we serve. (As stated above, our engineers are on the front lines and are best equipped to deliver this type of information.) + + 3. The open source legal team always has the right to override a decision, but this would be very rare and only would occur if we were aware of some community or legal concern regarding a specific license or project. + + 4. Publishing source code without a license is never permitted. + +In summary, the advantages of these guidelines are enormous. They are very efficient and lead to a very low-friction development and approval system within our organization. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/choose-open-source-license-engineers + +作者:[Jeffrey Robert Kaufman][a] +选题:[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/jkaufman +[b]: https://github.com/lujun9972 diff --git a/sources/talk/20190228 A Brief History of FOSS Practices.md b/sources/talk/20190228 A Brief History of FOSS Practices.md new file mode 100644 index 0000000000..58e90a8efa --- /dev/null +++ b/sources/talk/20190228 A Brief History of FOSS Practices.md @@ -0,0 +1,113 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A Brief History of FOSS Practices) +[#]: via: (https://itsfoss.com/history-of-foss) +[#]: author: (Avimanyu Bandyopadhyay https://itsfoss.com/author/avimanyu/) + +A Brief History of FOSS Practices +====== + +We focus a great deal about Linux and Free & Open Source Software at It’s FOSS. Ever wondered how old such FOSS Practices are? How did this Practice come by? What is the History behind this revolutionary concept? + +In this history and trivia article, let’s take a look back in time through this brief write-up and note some interesting initiatives in the past that have grown so huge today. + +### Origins of FOSS + +![History of FOSS][1] + +The origins of FOSS goes back to the 1950s. When hardware was purchased, there used to be no additional charges for bundled software and the source code would also be available in order to fix possible bugs in the software. + +It was actually a common Practice back then for users with the freedom to customize the code. + +At that time, mostly academicians and researchers in the industry were the collaborators to develop such software. + +The term Open Source was not there yet. Instead, the term that was popular at that time was “Public Domain Software”. As of today, ideologically, both are very much [different][2] in nature even though they may sound similar. + + + +Back in 1955, some users of the [IBM 701][3] computer system from Los Angeles, voluntarily founded a group called SHARE. The “SHARE Program Library Agency” (SPLA) distributed information and software through magnetic tapes. + +Technical information shared, was about programming languages, operating systems, database systems, and user experiences for enterprise users of small, medium, and large-scale IBM computers. + +The initiative that is now more than 60 years old, continues to follow its goals quite actively. SHARE has its upcoming event coming up as [SHARE Phoenix 2019][4]. You can download and check out their complete timeline [here][5]. + +### The GNU Project + +Announced at MIT on September 27, 1983, by Richard Stallman, the GNU Project is what immensely empowers and supports the Free Software Community today. + +### Free Software Foundation + +The “Free Software Movement” by Richard Stallman established a new norm for developing Free Software. + +He founded The Free Software Foundation (FSF) on 4th October 1985 to support the free software movement. Software that ensures that the end users have freedom in using, studying, sharing and modifying that software came to be called as Free Software. + +**Free as in Free Speech, Not Free Beer** + + + +The Free Software Movement laid the following rules to establish the distinctiveness of the idea: + + * The freedom to run the program as you wish, for any purpose (freedom 0). + * The freedom to study how the program works, and change it so it does your computing as you wish (freedom 1). Access to the source code is a precondition for this. + * The freedom to redistribute copies so you can help your neighbor (freedom 2). + * The freedom to distribute copies of your modified versions to others (freedom 3). By doing this you can give the whole community a chance to benefit from your changes. Access to the source code is a precondition for this. + +### The Linux Kernel + + + +How can we miss this section at It’s FOSS! The Linux kernel was released as freely modifiable source code in 1991 by Linus Torvalds. At first, it was neither Free Software nor used an Open-source software license. In February 1992, Linux was relicensed under the GPL. + +### The Linux Foundation + +The Linux Foundation has a goal to empower open source projects to accelerate technology development and commercial adoption. It is an initiative that was taken in 2000 via the [Open Source Development Labs][6] (OSDL) which later merged with the [Free Standards Group][7]. + +Linus Torvalds works at The Linux Foundation who provide complete support to him so that he can work full-time on improving Linux. + +### Open Source + +When the source code of [Netscape][8] Communicator was released in 1998, the label “Open Source” was adopted by a group of individuals at a strategy session held on February 3rd, 1998 in Palo Alto, California. The idea grew from a visionary realization that the [Netscape announcement][9] had changed the way people looked at commercial software. + +This opened up a whole new world, creating a new perspective that revealed the superiority and advantage of an open development process that could be powered by collaboration. + +[Christine Peterson][10] was the one among that group of individuals who originally suggested the term “Open Source” as we perceive today (mentioned [earlier][11]). + +### Evolution of Business Models + +The concept of Open Source is a huge phenomenon right now and there are several companies that continue to adopt the Open Source Approach to this day. [As of April 2015, 78% of companies used Open Source Software][12] with different [Open Source Licenses][13]. + +Several organisations have adopted [different business models][14] for Open Source. Red Hat and Mozilla are two good examples. + +So this was a brief recap of some interesting facts from FOSS History. Do let us know your thoughts if you want to share in the comments below. + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/history-of-foss + +作者:[Avimanyu Bandyopadhyay][a] +选题:[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/avimanyu/ +[b]: https://github.com/lujun9972 +[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/history-of-foss.png?resize=800%2C450&ssl=1 +[2]: https://opensource.org/node/878 +[3]: https://en.wikipedia.org/wiki/IBM_701 +[4]: https://event.share.org/home +[5]: https://www.share.org/d/do/11532 +[6]: https://en.wikipedia.org/wiki/Open_Source_Development_Labs +[7]: https://en.wikipedia.org/wiki/Free_Standards_Group +[8]: https://en.wikipedia.org/wiki/Netscape +[9]: https://web.archive.org/web/20021001071727/http://wp.netscape.com:80/newsref/pr/newsrelease558.html +[10]: https://en.wikipedia.org/wiki/Christine_Peterson +[11]: https://itsfoss.com/nanotechnology-open-science-ai/ +[12]: https://www.zdnet.com/article/its-an-open-source-world-78-percent-of-companies-run-open-source-software/ +[13]: https://itsfoss.com/open-source-licenses-explained/ +[14]: https://opensource.com/article/17/12/open-source-business-models diff --git a/sources/talk/20190228 IRC vs IRL- How to run a good IRC meeting.md b/sources/talk/20190228 IRC vs IRL- How to run a good IRC meeting.md new file mode 100644 index 0000000000..99f0c5c465 --- /dev/null +++ b/sources/talk/20190228 IRC vs IRL- How to run a good IRC meeting.md @@ -0,0 +1,56 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (IRC vs IRL: How to run a good IRC meeting) +[#]: via: (https://opensource.com/article/19/2/irc-vs-irl-meetings) +[#]: author: (Ben Cotton https://opensource.com/users/bcotton) + +IRC vs IRL: How to run a good IRC meeting +====== +Internet Relay Chat meetings can be a great way to move a project forward if you follow these best practices. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_community_1.png?itok=rT7EdN2m) + +There's an art to running a meeting in any format. Many people have learned to run in-person or telephone meetings, but [Internet Relay Chat][1] (IRC) meetings have unique characteristics that differ from "in real life" (IRL) meetings. This article will share the advantages and disadvantages of the IRC format as well as tips that will help you lead IRC meetings more effectively. + +Why IRC? Despite the wealth of real-time chat options available today, [IRC remains a cornerstone of open source projects][2]. If your project uses another communication method, don't worry. Most of this advice works for any synchronous text chat mechanism, perhaps with a few tweaks here and there. + +### Challenges of IRC meetings + +IRC meetings pose certain challenges compared to in-person meetings. You know that lag between when one person finishes talking and the next one begins? It's worse in IRC because people have to type what they're thinking. This is slower than talking and—unlike with talking—you can't tell when someone else is trying to compose a message. Moderators must remember to insert long pauses when asking for responses or moving to the next topic. And someone who wants to speak up should insert a brief message (e.g., a period) to let the moderator know. + +IRC meetings also lack the metadata you get from other methods. You can't read facial expressions or tone of voice in text. This means you have to be careful with your word choice and phrasing. + +And IRC meetings make it really easy to get distracted. At least when someone is looking at funny cat GIFs during an in-person meeting, you'll see them smile and hear them laugh at inopportune times. In IRC, unless they accidentally paste the wrong text, there's no peer pressure even to pretend to pay attention. With IRC, you can even be in multiple meetings at once. I've done this, but it's dangerous if you need to be an active participant. + +### Benefits of IRC meetings + +IRC meetings have some unique advantages, too. IRC is a very resource-light medium. It doesn't tax bandwidth or CPU. This lowers the barrier for participation, which is advantageous for both the underprivileged and people who are on the road. For volunteer contributors, it means they may be able to participate during their workday. And it means participants don't need to find a quiet space where they can talk without bothering those around them. + +With a meeting bot, IRC can produce meeting minutes instantly. In Fedora, we use Zodbot, an instance of Debian's [Meetbot][3], to log meetings and provide interaction. When a meeting ends, the minutes and full logs are immediately available to the community. This can reduce the administrative overhead of running the meeting. + +### It's like a normal meeting, but different + +Conducting a meeting via IRC or other text-based medium means thinking about the meeting in a slightly different way. Although it lacks some of the benefits of higher-bandwidth modes of communication, it has advantages, too. Running an IRC meeting provides the opportunity to develop discipline that can help you run any type of meeting. + +Like any meeting, IRC meetings are best when there's a defined agenda and purpose. A good meeting moderator knows when to let the conversation follow twists and turns and when it's time to reel it back in. There's no hard and fast rule here—it's very much an art. But IRC offers an advantage in this regard. By setting the channel topic to the meeting's current topic, people have a visible reminder of what they should be talking about. + +If your project doesn't already conduct synchronous meetings, you should give it some thought. For projects with a diverse set of time zones, finding a mutually agreeable time to hold a meeting is hard. You can't rely on meetings as your only source of coordination. But they can be a valuable part of how your project works. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/irc-vs-irl-meetings + +作者:[Ben Cotton][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/bcotton +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Internet_Relay_Chat +[2]: https://opensource.com/article/16/6/getting-started-irc +[3]: https://wiki.debian.org/MeetBot diff --git a/sources/talk/20190228 Why CLAs aren-t good for open source.md b/sources/talk/20190228 Why CLAs aren-t good for open source.md new file mode 100644 index 0000000000..ca39619762 --- /dev/null +++ b/sources/talk/20190228 Why CLAs aren-t good for open source.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Why CLAs aren't good for open source) +[#]: via: (https://opensource.com/article/19/2/cla-problems) +[#]: author: (Richard Fontana https://opensource.com/users/fontana) + +Why CLAs aren't good for open source +====== +Few legal topics in open source are as controversial as contributor license agreements. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/write-hand_0.jpg?itok=Uw5RJD03) + +Few legal topics in open source are as controversial as [contributor license agreements][1] (CLAs). Unless you count the special historical case of the [Fedora Project Contributor Agreement][2] (which I've always seen as an un-CLA), or, like [Karl Fogel][3], you classify the [DCO][4] as a [type of CLA][5], today Red Hat makes no use of CLAs for the projects it maintains. + +It wasn't always so. Red Hat's earliest projects followed the traditional practice I've called "inbound=outbound," in which contributions to a project are simply provided under the project's open source license with no execution of an external, non-FOSS contract required. But in the early 2000s, Red Hat began experimenting with the use of contributor agreements. Fedora started requiring contributors to sign a CLA based on the widely adapted [Apache ICLA][6], while a Free Software Foundation-derived copyright assignment agreement and a pair of bespoke CLAs were inherited from the Cygnus and JBoss acquisitions, respectively. We even took [a few steps][7] towards adopting an Apache-style CLA across the rapidly growing set of Red Hat-led projects. + +This came to an end, in large part because those of us on the Red Hat legal team heard and understood the concerns and objections raised by Red Hat engineers and the wider technical community. We went on to become de facto leaders of what some have called the anti-CLA movement, marked notably by our [opposition to Project Harmony][8] and our [efforts][9] to get OpenStack to replace its CLA with the DCO. (We [reluctantly][10] sign tolerable upstream project CLAs out of practical necessity.) + +### Why CLAs are problematic + +Our choice not to use CLAs is a reflection of our values as an authentic open source company with deep roots in the free software movement. Over the years, many in the open source community have explained why CLAs, and the very similar mechanism of copyright assignment, are a bad policy for open source. + +One reason is the red tape problem. Normally, open source development is characterized by frictionless contribution, which is enabled by inbound=outbound without imposition of further legal ceremony or process. This makes it relatively easy for new contributors to get involved in a project, allowing more effective growth of contributor communities and driving technical innovation upstream. Frictionless contribution is a key part of the advantage open source development holds over proprietary alternatives. But frictionless contribution is negated by CLAs. Having to sign an unusual legal agreement before a contribution can be accepted creates a bureaucratic hurdle that slows down development and discourages participation. This cost persists despite the growing use of automation by CLA-using projects. + +CLAs also give rise to an asymmetry of legal power among a project's participants, which also discourages the growth of strong contributor and user communities around a project. With Apache-style CLAs, the company or organization leading the project gets special rights that other contributors do not receive, while those other contributors must shoulder certain legal obligations (in addition to the red tape burden) from which the project leader is exempt. The problem of asymmetry is most severe in copyleft projects, but it is present even when the outbound license is permissive. + +When assessing the arguments for and against CLAs, bear in mind that today, as in the past, the vast majority of the open source code in any product originates in projects that follow the inbound=outbound practice. The use of CLAs by a relatively small number of projects causes collateral harm to all the others by signaling that, for some reason, open source licensing is insufficient to handle contributions flowing into a project. + +### The case for CLAs + +Since CLAs continue to be a minority practice and originate from outside open source community culture, I believe that CLA proponents should bear the burden of explaining why they are necessary or beneficial relative to their costs. I suspect that most companies using CLAs are merely emulating peer company behavior without critical examination. CLAs have an understandable, if superficial, appeal to risk-averse lawyers who are predisposed to favor greater formality, paper, and process regardless of the business costs. Still, some arguments in favor of CLAs are often advanced and deserve consideration. + +**Easy relicensing:** If administered appropriately, Apache-style CLAs give the project steward effectively unlimited power to sublicense contributions under terms of the steward's choice. This is sometimes seen as desirable because of the potential need to relicense a project under some other open source license. But the value of easy relicensing has been greatly exaggerated by pointing to a few historical cases involving major relicensing campaigns undertaken by projects with an unusually large number of past contributors (all of which were successful without the use of a CLA). There are benefits in relicensing being hard because it results in stable legal expectations around a project and encourages projects to consult their contributor communities before undertaking significant legal policy changes. In any case, most inbound=outbound open source projects never attempt to relicense during their lifetime, and for the small number that do, relicensing will be relatively painless because typically the number of past contributors to contact will not be large. + +**Provenance tracking:** It is sometimes claimed that CLAs enable a project to rigorously track the provenance of contributions, which purportedly has some legal benefit. It is unclear what is achieved by the use of CLAs in this regard that is not better handled through such non-CLA means as preserving Git commit history. And the DCO would seem to be much better suited to tracking contributions, given that it is normally used on a per-commit basis, while CLAs are signed once per contributor and are administratively separate from code contributions. Moreover, provenance tracking is often described as though it were a benefit for the public, yet I know of no case where a project provides transparent, ready public access to CLA acceptance records. + +**License revocation:** Some CLA advocates warn of the prospect that a contributor may someday attempt to revoke a past license grant. To the extent that the concern is about largely judgment-proof individual contributors with no corporate affiliation, it is not clear why an Apache-style CLA provides more meaningful protection against this outcome compared to the use of an open source license. And, as with so many of the legal risks raised in discussions of open source legal policy, this appears to be a phantom risk. I have heard of only a few purported attempts at license revocation over the years, all of which were resolved quickly when the contributor backed down in the face of community pressure. + +**Unauthorized employee contribution:** This is a special case of the license revocation issue and has recently become a point commonly raised by CLA advocates. When an employee contributes to an upstream project, normally the employer owns the copyrights and patents for which the project needs licenses, and only certain executives are authorized to grant such licenses. Suppose an employee contributed proprietary code to a project without approval from the employer, and the employer later discovers this and demands removal of the contribution or sues the project's users. This risk of unauthorized contributions is thought to be minimized by use of something like the [Apache CCLA][11] with its representations and signature requirement, coupled with some adequate review process to ascertain that the CCLA signer likely was authorized to sign (a step which I suspect is not meaningfully undertaken by most CLA-using companies). + +Based on common sense and common experience, I contend that in nearly all cases today, employee contributions are done with the actual or constructive knowledge and consent of the employer. If there were an atmosphere of high litigation risk surrounding open source software, perhaps this risk should be taken more seriously, but litigation arising out of open source projects remains remarkably uncommon. + +More to the point, I know of no case where an allegation of copyright or patent infringement against an inbound=outbound project, not stemming from an alleged open source license violation, would have been prevented by use of a CLA. Patent risk, in particular, is often cited by CLA proponents when pointing to the risk of unauthorized contributions, but the patent license grants in Apache-style CLAs are, by design, quite narrow in scope. Moreover, corporate contributions to an open source project will typically be few in number, small in size (and thus easily replaceable), and likely to be discarded as time goes on. + +### Alternatives + +If your company does not buy into the anti-CLA case and cannot get comfortable with the simple use of inbound=outbound, there are alternatives to resorting to an asymmetric and administratively burdensome Apache-style CLA requirement. The use of the DCO as a complement to inbound=outbound addresses at least some of the concerns of risk-averse CLA advocates. If you must use a true CLA, there is no need to use the Apache model (let alone a [monstrous derivative][10] of it). Consider the non-specification core of the [Eclipse Contributor Agreement][12]—essentially the DCO wrapped inside a CLA—or the Software Freedom Conservancy's [Selenium CLA][13], which merely ceremonializes an inbound=outbound contribution policy. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/cla-problems + +作者:[Richard Fontana][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/fontana +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/article/18/3/cla-vs-dco-whats-difference +[2]: https://opensource.com/law/10/6/new-contributor-agreement-fedora +[3]: https://www.red-bean.com/kfogel/ +[4]: https://developercertificate.org +[5]: https://producingoss.com/en/contributor-agreements.html#developer-certificate-of-origin +[6]: https://www.apache.org/licenses/icla.pdf +[7]: https://www.freeipa.org/page/Why_CLA%3F +[8]: https://opensource.com/law/11/7/trouble-harmony-part-1 +[9]: https://wiki.openstack.org/wiki/OpenStackAndItsCLA +[10]: https://opensource.com/article/19/1/cla-proliferation +[11]: https://www.apache.org/licenses/cla-corporate.txt +[12]: https://www.eclipse.org/legal/ECA.php +[13]: https://docs.google.com/forms/d/e/1FAIpQLSd2FsN12NzjCs450ZmJzkJNulmRC8r8l8NYwVW5KWNX7XDiUw/viewform?hl=en_US&formkey=dFFjXzBzM1VwekFlOWFWMjFFRjJMRFE6MQ#gid=0 diff --git a/sources/talk/20190301 What-s happening in the OpenStack community.md b/sources/talk/20190301 What-s happening in the OpenStack community.md new file mode 100644 index 0000000000..28e3bf2fd3 --- /dev/null +++ b/sources/talk/20190301 What-s happening in the OpenStack community.md @@ -0,0 +1,73 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What's happening in the OpenStack community?) +[#]: via: (https://opensource.com/article/19/3/whats-happening-openstack) +[#]: author: (Jonathan Bryce https://opensource.com/users/jonathan-bryce) + +What's happening in the OpenStack community? +====== + +In many ways, 2018 was a transformative year for the OpenStack Foundation. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/travel-mountain-cloud.png?itok=ZKsJD_vb) + +Since 2010, the OpenStack community has been building open source software to run cloud computing infrastructure. Initially, the focus was public and private clouds, but open infrastructure has been pulled into many new important use cases like telecoms, 5G, and manufacturing IoT. + +As OpenStack software matured and grew in scope to support new technologies like bare metal provisioning and container infrastructure, the community widened its thinking to embrace users who deploy and run the software in addition to the developers who build the software. Questions like, "What problems are users trying to solve?" "Which technologies are users trying to integrate?" and "What are the gaps?" began to drive the community's thinking and decision making. + +In response to those questions, the OSF reorganized its approach and created a new "open infrastructure" framework focused on use cases, including edge, container infrastructure, CI/CD, and private and hybrid cloud. And, for the first time, the OSF is hosting open source projects outside of the OpenStack project. + +Following are three highlights from the [OSF 2018 Annual Report][1]; I encourage you to read the entire report for more detailed information about what's new. + +### Pilot projects + +On the heels of launching [Kata Containers][2] in December 2017, the OSF launched three pilot projects in 2018—[Zuul][3], [StarlingX][4], and [Airship][5]—that help further our goals of taking our technology into additional relevant markets. Each project follows the tenets we consider key to the success of true open source, [the Four Opens][6]: open design, open collaboration, open development, and open source. While these efforts are still new, they have been extremely valuable in helping us learn how we should expand the scope of the OSF, as well as showing others the kind of approach we will take. + +While the OpenStack project remained at the core of the team's focus, pilot projects are helping expand usage of open infrastructure across markets and already benefiting the OpenStack community. This has attracted dozens of new developers to the open infrastructure community, which will ultimately benefit the OpenStack community and users. + +There is direct benefit from these contributors working upstream in OpenStack, such as through StarlingX, as well as indirect benefit from the relationships we've built with the Kubernetes community through the Kata Containers project. Airship is similarly bridging the gaps between the Kubernetes and OpenStack ecosystems. This shows users how the technologies work together. A rise in contributions to Zuul has provided the engine for OpenStack CI and keeps our development running smoothly. + +### Containers collaboration + +In addition to investing in new pilot projects, we continued efforts to work with key adjacent projects in 2018, and we made particularly good progress with Kubernetes. OSF staffer Chris Hoge helps lead the cloud provider special interest group, where he has helped standardize how Kubernetes deployments expect to run on top of various infrastructure. This has clarified OpenStack's place in the Kubernetes ecosystem and led to valuable integration points, like having OpenStack as part of the Kubernetes release testing process. + +Additionally, OpenStack Magnum was certified as a Kubernetes installer by the CNCF. Through the Kata Containers community, we have deepened these relationships into additional areas within the container ecosystem resulting in a number of companies getting involved for the first time. + +### Evolving events + +We knew heading into 2018 that the environment around our events was changing and we needed to respond. During the year, we held two successful project team gatherings (PTGs) in Dublin and Denver, reaching capacity for both events while also including new projects and OpenStack operators. We held OpenStack Summits in Vancouver and Berlin, both experiencing increases in attendance and project diversity since Sydney in 2017, with each Summit including more than 30 open source projects. Recognizing this broader audience and the OSF's evolving strategy, the OpenStack Summit was renamed the [Open Infrastructure Summit][7], beginning with the Denver event coming up in April. + +In 2018, we boosted investment in China, onboarding a China Community Manager based in Shanghai and hosting a strategy day in Beijing with 30+ attendees from Gold and Platinum Members in China. This effort will continue in 2019 as we host our first Summit in China: the [Open Infrastructure Summit Shanghai][8] in November. + +We also worked with the community in 2018 to define a new model for events to maximize participation while saving on travel and expenses for the individuals and companies who are increasingly stretched across multiple open source communities. We arrived at a plan that we will implement and iterate on in 2019 where we will collocate PTGs as standalone events adjacent to our Open Infrastructure Summits. + +### Looking ahead + +We've seen impressive progress, but the biggest accomplishment might be in establishing a framework for the future of the foundation itself. In 2018, we advanced the open infrastructure mission by establishing OSF as an effective place to collaborate for CI/CD, container infrastructure, and edge computing, in addition to the traditional public and private cloud use cases. The open infrastructure approach opened a lot of doors in 2018, from the initial release of software from each pilot project, to live 5G demos, to engagement with hyperscale public cloud providers. + +Ultimately, our value comes from the effectiveness of our communities and the software they produce. As 2019 unfolds, our community is excited to apply learnings from 2018 to the benefit of developers, users, and the commercial ecosystem across all our projects. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/whats-happening-openstack + +作者:[Jonathan Bryce][a] +选题:[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/jonathan-bryce +[b]: https://github.com/lujun9972 +[1]: https://www.openstack.org/foundation/2018-openstack-foundation-annual-report +[2]: https://katacontainers.io/ +[3]: https://zuul-ci.org/ +[4]: https://www.starlingx.io/ +[5]: https://www.airshipit.org/ +[6]: https://www.openstack.org/four-opens/ +[7]: https://www.openstack.org/summit/denver-2019/ +[8]: https://www.openstack.org/summit/shanghai-2019 diff --git a/sources/tech/20120205 Computer Laboratory - Raspberry Pi- Lesson 5 OK05.md b/sources/tech/20120205 Computer Laboratory - Raspberry Pi- Lesson 5 OK05.md deleted file mode 100644 index 912d4c348c..0000000000 --- a/sources/tech/20120205 Computer Laboratory - Raspberry Pi- Lesson 5 OK05.md +++ /dev/null @@ -1,103 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (oska874) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 5 OK05) -[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok05.html) -[#]: author: (Robert Mullins http://www.cl.cam.ac.uk/~rdm34) - -translating by ezio - -树莓派计算机实验室 课程 5 OK05 -====== - -OK05 课程构建于课程 OK04 的基础,使用更多代码方式烧、保存写莫尔斯码的 SOS 序列(`...---...`)。这里假设你已经有了 [课程 4: OK04][1] 操作系统的代码基础。 - -### 1 数据 - -到目前为止,我们与操作系统有关的所有内容都提供了遵循的说明。然而有时候,说明只是一半。我们的操作系统可能需要数据 - -> 一些早期的操作系统确实只允许特定文件中的特定类型的数据,但是这通常被认为太严格了。现代方法确实使程序变得复杂的多。 - -通常,只是数据的值很重要。你可能经过训练,认为数据是指定类型,比如,一个文本文件包含文章,一个图像文件包含一幅图片,等等。说实话,这只是一个理想罢了。计算机上的全部数据都是二进制数字,重要的是我们选择用什么来解释这些数据。在这个例子中,我们会将一个闪灯序列作为数据保存下来。 - -在 `main.s` 结束处复制下面的代码: - -``` -.section .data %定义 .data 段 -.align 2 %对齐 -pattern: %定义整形变量 -.int 0b11111111101010100010001000101010 -``` - ->`.align num` 保证下一行代码的地址是 `2^num` 的整数倍。 - ->`.int val` 输出数值 `val`。 - -要区分数据和代码,我们将数据都放在 `.data` 区域。我已经将该区域包含在操作系统的内存布局图。我已经选择将数据放到代码后面。将我们的指令和数据分开保存的原因是,如果最后我们在自己的操作系统上实现一些安全措施,我们就需要知道代码的那些部分是可以执行的,而那些部分是不行的。 - -我在这里使用了两个新命令 `.align` 和 `.int`。`.align` 保证下来的数据是按照 2 的乘方对齐的。在这个里,我使用 `.align 2` ,意味着数据最终存放的地址是 `2^2=4` 的整数倍。这个操作是很重要的,因为我们用来读取内寸的指令 `ldr` 要求内存地址是 4 的倍数。 - -The .int command copies the constant after it into the output directly. That means that 111111111010101000100010001010102 will be placed into the output, and so the label pattern actually labels this piece of data as pattern. - -命令 `.int` 直接复制它后面的常量到输出。这意味着 `11111111101010100010001000101010`(二进制数) 将会被存放到输出,所以标签模式实际将标记这段数据作为模式。 - -> 关于数据的一个挑战是寻找一个高效和有用的展示形式。这种保存一个开、关的时间单元的序列的方式,运行起来很容易,但是将很难编辑,因为摩尔斯的原理 `-` 或 `.` 丢失了。 - -如我提到的,数据可以意味这你想要的所有东西。在这里我编码了摩尔斯代码 SOS 序列,对于不熟悉的人,就是 `...---...`。我使用 0 表示一个时间单元的 LED 灭灯,而 1 表示一个时间单元的 LED 亮。这样,我们可以像这样编写一些代码在数据中显示一个序列,然后要显示不同序列,我们所有需要做的就是修改这段数据。下面是一个非常简单的例子,操作系统必须一直执行这段程序,解释和展示数据。 - -复制下面几行到 `main.s` 中的标记 `loop$` 之前。 - -``` -ptrn .req r4 %重命名 r4 为 ptrn -ldr ptrn,=pattern %加载 pattern 的地址到 ptrn -ldr ptrn,[ptrn] %加载地址 ptrn 所在内存的值 -seq .req r5 %重命名 r5 为 seq -mov seq,#0 %seq 赋值为 0 -``` - -这段代码加载 `pattrern` 到寄存器 `r4`,并加载 0 到寄存器 `r5`。`r5` 将是我们的序列位置,所以我们可以追踪有多少 `pattern` 我们已经展示了。 - -下面的代码将非零值放入 `r1` ,如果仅仅是如果,这里有个 1 在当前位置的 `pattern`。 - -``` -mov r1,#1 %加载1到 r1 -lsl r1,seq %对r1 的值逻辑左移 seq 次 -and r1,ptrn %按位与 -``` - -这段代码对你调用 `SetGpio` 很有用,它必须有一个非零值来关掉 LED,而一个0值会打开 LED。 - -现在修改 `main.s` 中全部你的代码,这样代码中每次循环会根据当前的序列数设置 LED,等待 250000 毫秒(或者其他合适的延时),然后增加序列数。当这个序列数到达 32 就需要返回 0.看看你是否能实现这个功能,作为额外的挑战,也可以试着只使用一条指令。 - -### 2 Time Flies When You're Having Fun... 当你玩得开心时,过得很快 - -你现在准备好在树莓派上实验。应该闪烁一串包含 3 个短脉冲,3 个长脉冲,然后 3 个更短脉冲的序列。在一次延时之后,这种模式应该重复。如果这部工作,请查看我们的问题页。 - -一旦它工作,祝贺你已经达到 OK 系列教程的结束。 - -在这个谢列我们学习了汇编代码,GPIO 控制器和系统定时器。我们已经学习了函数和 ABI,以及几个基础的操作系统原理,和关于数据的知识。 - -你现在已经准备好下面几个更高级的课程的某一个。 - * [Screen][2] 系列是接下来的,会教你如何通过汇编代码使用屏幕。 - * [Input][3] 系列教授你如何使用键盘和鼠标。 - -到现在,你已经有了足够的信息来制作操作系统,用其它方法和 GPIO 交互。如果你有任何机器人工具,你可能会想尝试编写一个通过 GPIO 管教控制的机器人操作系统。 - --------------------------------------------------------------------------------- - -via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok05.html - -作者:[Robert Mullins][a] -选题:[lujun9972][b] -译者:[ezio](https://github.com/oska874) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: http://www.cl.cam.ac.uk/~rdm34 -[b]: https://github.com/lujun9972 -[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok04.html -[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen01.html -[3]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input01.html diff --git a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 10 Input01.md b/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 10 Input01.md deleted file mode 100644 index beb7613b2f..0000000000 --- a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 10 Input01.md +++ /dev/null @@ -1,494 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 10 Input01) -[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input01.html) -[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) - -Computer Laboratory – Raspberry Pi: Lesson 10 Input01 -====== - -Welcome to the Input lesson series. In this series, you will learn how to receive inputs to the Raspberry Pi using the keyboard. We will start with just revealing the input, and then move to a more traditional text prompt. - -This first input lesson teaches some theory about drivers and linking, as well as about keyboards and ends up displaying text on the screen. - -### 1 Getting Started - -It is expected that you have completed the OK series, and it would be helpful to have completed the Screen series. Many of the files from that series will be called, without comment. If you do not have these files, or prefer to use a correct implementation, download the template for this lesson from the [Downloads][1] page. If you're using your own implementation, please remove everything after your call to SetGraphicsAddress. - -### 2 USB - -``` -The USB standard was designed to make simple hardware in exchange for complex software. -``` - -As you are no doubt aware, the Raspberry Pi model B has two USB ports, commonly used for connecting a mouse and keyboard. This was a very good design decision, USB is a very generic connector, and many different kinds of device use it. It's simple to build new devices for, simple to write device drivers for, and is highly extensible thanks to USB hubs. Could it get any better? Well, no, in fact for an Operating Systems developer this is our worst nightmare. The USB standard is huge. I really mean it this time, it is over 700 pages, before you've even thought about connecting a device. - -I spoke to a number of other hobbyist Operating Systems developers about this and they all say one thing: don't bother. "It will take too long to implement", "You won't be able to write a tutorial on it" and "It will be of little benefit". In many ways they are right, I'm not able to write a tutorial on the USB standard, as it would take weeks. I also can't teach how to write device drivers for all the different devices, so it is useless on its own. However, I can do the next best thing: Get a working USB driver, get a keyboard driver, and then teach how to use these in an Operating System. I set out searching for a free driver that would run in an operating system that doesn't even know what a file is yet, but I couldn't find one. They were all too high level. So, I attempted to write one. Everybody was right, this took weeks to do. However, I'm pleased to say I did get one that works with no external help from the Operating System, and can talk to a mouse and keyboard. It is by no means complete, efficient, or correct, but it does work. It has been written in C and the full source code can be found on the downloads page for those interested. - -So, this tutorial won't be a lesson on the USB standard (at all). Instead we'll look at how to work with other people's code. - -### 3 Linking - -``` -Linking allows us to make reusable code 'libraries' that anyone can use in their program. -``` - -Since we're about to incorporate external code into the Operating System, we need to talk about linking. Linking is a process which is applied to programs or Operating System to link in functions. What this means is that when a program is made, we don't necessarily code every function (almost certainly not in fact). Linking is what we do to make our program link to functions in other people's code. This has actually been going on all along in our Operating Systems, as the linker links together all of the different files, each of which is compiled separately. - -``` -Programs often just call libraries, which call other libraries and so on until eventually they call an Operating System library which we would write. -``` - -There are two types of linking: static and dynamic. Static linking is like what goes on when we make our Operating Systems. The linker finds all the addresses of the functions, and writes them into the code, before the program is finished. Dynamic linking is linking that occurs after the program is 'complete'. When it is loaded, the dynamic linker goes through the program and links any functions which are not in the program to libraries in the Operating System. This is one of the jobs our Operating System should eventually be capable of, but for now everything will be statically linked. - -The USB driver I have written is suitable for static linking. This means I give you the compiled code for each of my files, and then the linker finds functions in your code which are not defined in your code, and links them to functions in my code. On the [Downloads][1] page for this lesson is a makefile and my USB driver, which you will need to continue. Download them and replace the makefile in your code with this one, and also put the driver in the same folder as that makefile. - -### 4 Keyboards - -In order to get input into our Operating System, we need to understand at some level how keyboards actually work. Keyboards have two types of keys: Normal and Modifier keys. The normal keys are the letters, numbers, function keys, etc. They constitute almost every key on the keyboard. The modifiers are up to 8 special keys. These are left shift, right shift, left control, right control, left alt, right alt, left GUI and right GUI. The keyboard can detect any combination of the modifier keys being held, as well as up to 6 normal keys. Every time a key changes (i.e. is pushed or released), it reports this to the computer. Typically, keyboards also have three LEDs for Caps Lock, Num Lock and Scroll Lock, which are controlled by the computer, not the keyboard itself. Keyboards may have many more lights such as power, mute, etc. - -In order to help standardise USB keyboards, a table of values was produced, such that every keyboard key ever is given a unique number, as well as every conceivable LED. The table below lists the first 126 of values. - -Table 4.1 USB Keyboard Keys -| Number | Description | Number | Description | Number | Description | Number | Description | | -| ------ | ---------------- | ------- | ---------------------- | -------- | -------------- | --------------- | -------------------- | | -| 4 | a and A | 5 | b and B | 6 | c and C | 7 | d and D | | -| 8 | e and E | 9 | f and F | 10 | g and G | 11 | h and H | | -| 12 | i and I | 13 | j and J | 14 | k and K | 15 | l and L | | -| 16 | m and M | 17 | n and N | 18 | o and O | 19 | p and P | | -| 20 | q and Q | 21 | r and R | 22 | s and S | 23 | t and T | | -| 24 | u and U | 25 | v and V | 26 | w and W | 27 | x and X | | -| 28 | y and Y | 29 | z and Z | 30 | 1 and ! | 31 | 2 and @ | | -| 32 | 3 and # | 33 | 4 and $ | 34 | 5 and % | 35 | 6 and ^ | | -| 36 | 7 and & | 37 | 8 and * | 38 | 9 and ( | 39 | 0 and ) | | -| 40 | Return (Enter) | 41 | Escape | 42 | Delete (Backspace) | 43 | Tab | | -| 44 | Spacebar | 45 | - and _ | 46 | = and + | 47 | [ and { | | -| 48 | ] and } | 49 | \ and | | 50 | # and ~ | 51 | ; and : | -| 52 | ' and " | 53 | ` and ~ | 54 | , and < | 55 | . and > | | -| 56 | / and ? | 57 | Caps Lock | 58 | F1 | 59 | F2 | | -| 60 | F3 | 61 | F4 | 62 | F5 | 63 | F6 | | -| 64 | F7 | 65 | F8 | 66 | F9 | 67 | F10 | | -| 68 | F11 | 69 | F12 | 70 | Print Screen | 71 | Scroll Lock | | -| 72 | Pause | 73 | Insert | 74 | Home | 75 | Page Up | | -| 76 | Delete forward | 77 | End | 78 | Page Down | 79 | Right Arrow | | -| 80 | Left Arrow | 81 | Down Arrow | 82 | Up Arrow | 83 | Num Lock | | -| 84 | Keypad / | 85 | Keypad * | 86 | Keypad - | 87 | Keypad + | | -| 88 | Keypad Enter | 89 | Keypad 1 and End | 90 | Keypad 2 and Down Arrow | 91 | Keypad 3 and Page Down | | -| 92 | Keypad 4 and Left Arrow | 93 | Keypad 5 | 94 | Keypad 6 and Right Arrow | 95 | Keypad 7 and Home | | -| 96 | Keypad 8 and Up Arrow | 97 | Keypad 9 and Page Up | 98 | Keypad 0 and Insert | 99 | Keypad . and Delete | | -| 100 | \ and | | 101 | Application | 102 | Power | 103 | Keypad = | -| 104 | F13 | 105 | F14 | 106 | F15 | 107 | F16 | | -| 108 | F17 | 109 | F18 | 110 | F19 | 111 | F20 | | -| 112 | F21 | 113 | F22 | 114 | F23 | 115 | F24 | | -| 116 | Execute | 117 | Help | 118 | Menu | 119 | Select | | -| 120 | Stop | 121 | Again | 122 | Undo | 123 | Cut | | -| 124 | Copy | 125 | Paste | 126 | Find | 127 | Mute | | -| 128 | Volume Up | 129 | Volume Down | | | | | | - -The full list can be found in section 10, page 53 of [HID Usage Tables 1.12][2]. - -### 5 The Nut Behind the Wheel - -``` -These summaries and the code they describe form an API - Application Product Interface. -``` - -Normally, when you work with someone else's code, they provide a summary of their methods, what they do and roughly how they work, as well as how they can go wrong. Here is a table of the relevant instructions required to use my USB driver. - -Table 5.1 Keyboard related functions in CSUD -| Function | Arguments | Returns | Description | -| ----------------------- | ----------------------- | ----------------------- | ----------------------- | -| UsbInitialise | None | r0 is result code | This method is the all-in-one method that loads the USB driver, enumerates all devices and attempts to communicate with them. This method generally takes about a second to execute, though with a few USB hubs plugged in this can be significantly longer. After this method is completed methods in the keyboard driver become available, regardless of whether or not a keyboard is indeed inserted. Result code explained below. | -| UsbCheckForChange | None | None | Essentially provides the same effect as UsbInitialise, but does not provide the same one time initialisation. This method checks every port on every connected hub recursively, and adds new devices if they have been added. This should be very quick if there are no changes, but can take up to a few seconds if a hub with many devices is attached. | -| KeyboardCount | None | r0 is count | Returns the number of keyboards currently connected and detected. UsbCheckForChange may update this. Up to 4 keyboards are supported by default. Up to this many keyboards may be accessed through this driver. | -| KeyboardGetAddress | r0 is index | r0 is address | Retrieves the address of a given keyboard. All other functions take a keyboard address in order to know which keyboard to access. Thus, to communicate with a keyboard, first check the count, then retrieve the address, then use other methods. Note, the order of keyboards that this method returns may change after calls to UsbCheckForChange. | -| KeyboardPoll | r0 is address | r0 is result code | Reads in the current key state from the keyboard. This operates via polling the device directly, contrary to the best practice. This means that if this method is not called frequently enough, a key press could be missed. All reading methods simply return the value as of the last poll. | -| KeyboardGetModifiers | r0 is address | r0 is modifier state | Retrieves the status of the modifier keys as of the last poll. These are the shift, alt control and GUI keys on both sides. This is returned as a bit field, such that a 1 in the bit 0 means left control is held, bit 1 means left shift, bit 2 means left alt, bit 3 means left GUI and bits 4 to 7 mean the right versions of those previous. If there is a problem r0 contains 0. | -| KeyboardGetKeyDownCount | r0 is address | r0 is count | Retrieves the number of keys currently held down on the keyboard. This excludes modifier keys. Normally, this cannot go above 6. If there is an error this method returns 0. | -| KeyboardGetKeyDown | r0 is address, r1 is key number | r0 is scan code | Retrieves the scan code (see Table 4.1) of a particular held down key. Normally, to work out which keys are down, call KeyboardGetKeyDownCount and then call KeyboardGetKeyDown up to that many times with increasing values of r1 to determine which keys are down. Returns 0 if there is a problem. It is safe (but not recommended) to call this method without calling KeyboardGetKeyDownCount and interpret 0s as keys not held. Note, the order or scan codes can change randomly (some keyboards sort numerically, some sort temporally, no guarantees are made). | -| KeyboardGetKeyIsDown | r0 is address, r1 is scan code | r0 is status | Alternative to KeyboardGetKeyDown, checks if a particular scan code is among the held down keys. Returns 0 if not, or a non-zero value if so. Faster when detecting particular scan codes (e.g. looking for ctrl+c). On error, returns 0. | -| KeyboardGetLedSupport | r0 is address | r0 is LEDs | Checks which LEDs a particular keyboard supports. Bit 0 being 1 represents Number Lock, bit 1 represents Caps Lock, bit 2 represents Scroll Lock, bit 3 represents Compose, bit 4 represents Kana, bit 5 represents Power, bit 6 represents Mute and bit 7 represents Compose. As per the USB standard, none of these LEDs update automatically (e.g. Caps Lock must be set manually when the Caps Lock scan code is detected). | -| KeyboardSetLeds | r0 is address, r1 is LEDs | r0 is result code | Attempts to turn on/off the specified LEDs on the keyboard. See below for result code values. See KeyboardGetLedSupport for LEDs' values. | - -``` -Result codes are an easy way to handle errors, but often more elegant solutions exist in higher level code. -``` - -Several methods return 'result codes'. These are commonplace in C code, and are just numbers which represent what happened in a method call. By convention, 0 always indicates success. The following result codes are used by this driver. - -Table 5.2 - CSUD Result Codes -| Code | Description | -| ---- | ----------------------------------------------------------------------- | -| 0 | Method completed successfully. | -| -2 | Argument: A method was called with an invalid argument. | -| -4 | Device: The device did not respond correctly to the request. | -| -5 | Incompatible: The driver is not compatible with this request or device. | -| -6 | Compiler: The driver was compiled incorrectly, and is broken. | -| -7 | Memory: The driver ran out of memory. | -| -8 | Timeout: The device did not respond in the expected time. | -| -9 | Disconnect: The device requested has disconnected, and cannot be used. | - -The general usage of the driver is as follows: - - 1. Call UsbInitialise - 2. Call UsbCheckForChange - 3. Call KeyboardCount - 4. If this is 0, go to 2. - 5. For each keyboard you support: - 1. Call KeyboardGetAddress - 2. Call KeybordGetKeyDownCount - 3. For each key down: - 1. Check whether or not it has just been pushed - 2. Store that the key is down - 4. For each key stored: - 1. Check whether or not key is released - 2. Remove key if released - 6. Perform actions based on keys pushed/released - 7. Go to 2. - - - -Ultimately, you may do whatever you wish to with the keyboard, and these methods should allow you to access all of its functionality. Over the next 2 lessons, we shall look at completing the input side of a text terminal, similarly to most command line computers, and interpreting the commands. In order to do this, we're going to need to have keyboard inputs in a more useful form. You may notice that my driver is (deliberately) unhelpful, because it doesn't have methods to deduce whether or not a key has just been pushed down or released, it only has methods about what is currently held down. This means we'll need to write such methods ourselves. - -### 6 Updates Available - -Repeatedly checking for updates is called 'polling'. This is in contrast to interrupt driven IO, where the device sends a signal when data is ready. - -First of all, let's implement a method KeyboardUpdate which detects the first keyboard and uses its poll method to get the current input, as well as saving the last inputs for comparison. We can then use this data with other methods to translate scan codes to keys. The method should do precisely the following: - - 1. Retrieve a stored keyboard address (initially 0). - 2. If this is not 0, go to 9. - 3. Call UsbCheckForChange to detect new keyboards. - 4. Call KeyboardCount to detect how many keyboards are present. - 5. If this is 0 store the address as 0 and return; we can't do anything with no keyboard. - 6. Call KeyboardGetAddress with parameter 0 to get the first keyboard's address. - 7. Store this address. - 8. If this is 0, return; there is some problem. - 9. Call KeyboardGetKeyDown 6 times to get each key currently down and store them - 10. Call KeyboardPoll - 11. If the result is non-zero go to 3. There is some problem (such as disconnected keyboard). - - - -To store the values mentioned above, we will need the following values in the .data section. - -``` -.section .data -.align 2 -KeyboardAddress: -.int 0 -KeyboardOldDown: -.rept 6 -.hword 0 -.endr -``` - -``` -.hword num inserts the half word constant num into the file directly. -``` - -``` -.rept num [commands] .endr copies the commands commands to the output num times. -``` - -Try to implement the method yourself. My implementation for this is as follows: - -1. -``` -.section .text -.globl KeyboardUpdate -KeyboardUpdate: -push {r4,r5,lr} - -kbd .req r4 -ldr r0,=KeyboardAddress -ldr kbd,[r0] -``` -We load in the keyboard address. -2. -``` -teq kbd,#0 -bne haveKeyboard$ -``` -If the address is non-zero, we have a keyboard. Calling UsbCheckForChanges is slow, and so if everything works we avoid it. -3. -``` -getKeyboard$: -bl UsbCheckForChange -``` -If we don't have a keyboard, we have to check for new devices. -4. -``` -bl KeyboardCount -``` -Now we see if a new keyboard has been added. -5. -``` -teq r0,#0 -ldreq r1,=KeyboardAddress -streq r0,[r1] -beq return$ -``` -There are no keyboards, so we have no keyboard address. -6. -``` -mov r0,#0 -bl KeyboardGetAddress -``` -Let's just get the address of the first keyboard. You may want to allow more. -7. -``` -ldr r1,=KeyboardAddress -str r0,[r1] -``` -Store the keyboard's address. -8. -``` -teq r0,#0 -beq return$ -mov kbd,r0 -``` -If we have no address, there is nothing more to do. -9. -``` -saveKeys$: - mov r0,kbd - mov r1,r5 - bl KeyboardGetKeyDown - - ldr r1,=KeyboardOldDown - add r1,r5,lsl #1 - strh r0,[r1] - add r5,#1 - cmp r5,#6 - blt saveKeys$ -``` -Loop through all the keys, storing them in KeyboardOldDown. If we ask for too many, this returns 0 which is fine. - -10. -``` -mov r0,kbd -bl KeyboardPoll -``` -Now we get the new keys. - -11. -``` -teq r0,#0 -bne getKeyboard$ - -return$: -pop {r4,r5,pc} -.unreq kbd -``` -Finally we check if KeyboardPoll worked. If not, we probably disconnected. - - -With our new KeyboardUpdate method, checking for inputs becomes as simple as calling this method at regular intervals, and it will even check for disconnections etc. This is a useful method to have, as our actual key processing may differ based on the situation, and so being able to get the current input in its raw form with one method call is generally applicable. The next method we ideally want is KeyboardGetChar, a method that simply returns the next key pressed as an ASCII character, or returns 0 if no key has just been pressed. This could be extended to support typing a key multiple times if it is held for a certain duration, and to support the 'lock' keys as well as modifiers. - -To make this method it is useful if we have a method KeyWasDown, which simply returns 0 if a given scan code is not in the KeyboardOldDown values, and returns a non-zero value otherwise. Have a go at implementing this yourself. As always, a solution can be found on the downloads page. - -### 7 Look Up Tables - -``` -In many areas of programming, the larger the program, the faster it is. Look up tables are large, but are very fast. Some problems can be solved by a mixture of look up tables and normal functions. -``` - -The KeyboardGetChar method could be quite complex if we write it poorly. There are 100s of scan codes, each with different effects depending on the presence or absence of the shift key or other modifiers. Not all of the keys can be translated to a character. For some characters, multiple keys can produce the same character. A useful trick in situations with such vast arrays of possibilities is look up tables. A look up table, much like in the physical sense, is a table of values and their results. For some limited functions, the simplest way to deduce the answer is just to precompute every answer, and just return the correct one by retrieving it. In this case, we could build up a sequence of values in memory such that the nth value into the sequence is the ASCII character code for the scan code n. This means our method would simply have to detect if a key was pressed, and then retrieve its value from the table. Further, we could have a separate table for the values when shift is held, so that the shift key simply changes which table we're working with. - -After the .section .data command, copy the following tables: - -``` -.align 3 -KeysNormal: - .byte 0x0, 0x0, 0x0, 0x0, 'a', 'b', 'c', 'd' - .byte 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l' - .byte 'm', 'n', 'o', 'p', 'q', 'r', 's', 't' - .byte 'u', 'v', 'w', 'x', 'y', 'z', '1', '2' - .byte '3', '4', '5', '6', '7', '8', '9', '0' - .byte '\n', 0x0, '\b', '\t', ' ', '-', '=', '[' - .byte ']', '\\\', '#', ';', '\'', '`', ',', '.' - .byte '/', 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 - .byte 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 - .byte 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 - .byte 0x0, 0x0, 0x0, 0x0, '/', '*', '-', '+' - .byte '\n', '1', '2', '3', '4', '5', '6', '7' - .byte '8', '9', '0', '.', '\\\', 0x0, 0x0, '=' - -.align 3 -KeysShift: - .byte 0x0, 0x0, 0x0, 0x0, 'A', 'B', 'C', 'D' - .byte 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L' - .byte 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T' - .byte 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '"' - .byte '£', '$', '%', '^', '&', '*', '(', ')' - .byte '\n', 0x0, '\b', '\t', ' ', '_', '+', '{' - .byte '}', '|', '~', ':', '@', '¬', '<', '>' - .byte '?', 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 - .byte 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 - .byte 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 - .byte 0x0, 0x0, 0x0, 0x0, '/', '*', '-', '+' - .byte '\n', '1', '2', '3', '4', '5', '6', '7' - .byte '8', '9', '0', '.', '|', 0x0, 0x0, '=' -``` - -``` -.byte num inserts the byte constant num into the file directly. -``` - -``` -Most assemblers and compilers recognise escape sequences; character sequences such as \t which insert special characters instead. -``` - -These tables map directly the first 104 scan codes onto the ASCII characters as a table of bytes. We also have a separate table describing the effects of the shift key on those scan codes. I've used the ASCII null character (0) for all keys without direct mappings in ASCII (such as the function keys). Backspace is mapped to the ASCII backspace character (8 denoted \b), enter is mapped to the ASCII new line character (10 denoted \n) and tab is mapped to the ASCII horizontal tab character (9 denoted \t). - -The KeyboardGetChar method will need to do the following: - - 1. Check if KeyboardAddress is 0. If so, return 0. - 2. Call KeyboardGetKeyDown up to 6 times. Each time: - 1. If key is 0, exit loop. - 2. Call KeyWasDown. If it was, go to the next key. - 3. If the scan code is more than 103, go to the next key. - 4. Call KeyboardGetModifiers - 5. If shift is held, load the address of KeysShift. Otherwise load KeysNormal. - 6. Read the ASCII value from the table. - 7. If it is 0, go to the next key otherwise return this ASCII code and exit. - 3. Return 0. - - - -Try to implement this yourself. My implementation is presented below: - -1. -``` -.globl KeyboardGetChar -KeyboardGetChar: -ldr r0,=KeyboardAddress -ldr r1,[r0] -teq r1,#0 -moveq r0,#0 -moveq pc,lr -``` -Simple check to see if we have a keyboard. - -2. -``` -push {r4,r5,r6,lr} -kbd .req r4 -key .req r6 -mov r4,r1 -mov r5,#0 -keyLoop$: - mov r0,kbd - mov r1,r5 - bl KeyboardGetKeyDown -``` -r5 will hold the index of the key, r4 holds the keyboard address. - - 1. - ``` - teq r0,#0 - beq keyLoopBreak$ - ``` - If a scan code is 0, it either means there is an error, or there are no more keys. - - 2. - ``` - mov key,r0 - bl KeyWasDown - teq r0,#0 - bne keyLoopContinue$ - ``` - If a key was already down it is uninteresting, we only want ot know about key presses. - - 3. - ``` - cmp key,#104 - bge keyLoopContinue$ - ``` - If a key has a scan code higher than 104, it will be outside our table, and so is not relevant. - - 4. - ``` - mov r0,kbd - bl KeyboardGetModifiers - ``` - We need to know about the modifier keys in order to deduce the character. - - 5. - ``` - tst r0,#0b00100010 - ldreq r0,=KeysNormal - ldrne r0,=KeysShift - ``` - We detect both a left and right shift key as changing the characters to their shift variants. Remember, a tst instruction computes the logical AND and then compares it to zero, so it will be equal to 0 if and only if both of the shift bits are zero. - - 6. - ``` - ldrb r0,[r0,key] - ``` - Now we can load in the key from the look up table. - - 7. - ``` - teq r0,#0 - bne keyboardGetCharReturn$ - keyLoopContinue$: - add r5,#1 - cmp r5,#6 - blt keyLoop$ - ``` - If the look up code contains a zero, we must continue. To continue, we increment the index, and check if we've reached 6. - -3. -``` -keyLoopBreak$: -mov r0,#0 -keyboardGetCharReturn$: -pop {r4,r5,r6,pc} -.unreq kbd -.unreq key -``` -We return our key here, if we reach keyLoopBreak$, then we know there is no key held, so return 0. - - - - -### 8 Notepad OS - -Now we have our KeyboardGetChar method, we can make an operating system that just types what the user writes to the screen. For simplicity we'll ignore all the unusual keys. In 'main.s' delete all code after bl SetGraphicsAddress. Call UsbInitialise, set r4 and r5 to 0, then loop forever over the following commands: - - 1. Call KeyboardUpdate - 2. Call KeyboardGetChar - 3. If it is 0, got to 1 - 4. Copy r4 and r5 to r1 and r2 then call DrawCharacter - 5. Add r0 to r4 - 6. If r4 is 1024, add r1 to r5 and set r4 to 0 - 7. If r5 is 768 set r5 to 0 - 8. Go to 1 - - - -Now compile this and test it on the Pi. You should almost immediately be able to start typing text to the screen when the Pi starts. If not, please see our troubleshooting page. - -When it works, congratulations, you've achieved an interface with the computer. You should now begin to realise that you've almost got a primitive operating system together. You can now interface with the computer, issuing it commands, and receive feedback on screen. In the next tutorial, [Input02][3] we will look at producing a full text terminal, in which the user types commands, and the computer executes them. - --------------------------------------------------------------------------------- - -via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input01.html - -作者:[Alex Chadwick][a] -选题:[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.cl.cam.ac.uk -[b]: https://github.com/lujun9972 -[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/downloads.html -[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/downloads/hut1_12v2.pdf -[3]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input02.html diff --git a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 11 Input02.md b/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 11 Input02.md deleted file mode 100644 index 9040162a97..0000000000 --- a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 11 Input02.md +++ /dev/null @@ -1,911 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 11 Input02) -[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input02.html) -[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) - -Computer Laboratory – Raspberry Pi: Lesson 11 Input02 -====== - -The Input02 lesson builds on Input01, by building a simple command line interface where the user can type commands and the computer interprets and displays them. It is assumed you have the code for the [Lesson 11: Input01][1] operating system as a basis. - -### 1 Terminal 1 - -``` -In the early days of computing, there would usually be one large computer in a building, and many 'terminals' which sent commands to it. The computer would take it in turns to execute different incoming commands. -``` - -Almost every operating system starts life out as a text terminal. This is typically a black screen with white writing, where you type commands for the computer to execute on the keyboard, and it explains how you've mistyped them, or very occasionally, does what you want. This approach has two main advantages: it provides a simple, robust control mechanism for the computer using only a keyboard and monitor, and it is done by almost every operating system, so is widely understood by system administrators. - -Let's analyse what we want to do precisely: - - 1. Computer turns on, displays some sort of welcome message - 2. Computer indicates its ready for input - 3. User types a command, with parameters, on the keyboard - 4. User presses return or enter to commit the command - 5. Computer interprets command and performs actions if command is acceptable - 6. Computer displays messages to indicate if command was successful, and also what happened - 7. Loop back to 2 - - - -One defining feature of such terminals is that they are unified for both input and output. The same screen is used to enter inputs as is used to print outputs. This means it is useful to build an abstraction of a character based display. In a character based display, the smallest unit is a character, not a pixel. The screen is divided into a fixed number of characters which have varying colours. We can build this on top of our existing screen code, by storing the characters and their colours, and then using the DrawCharacter method to push them to the screen. Once we have a character based display, drawing text becomes a matter of drawing a line of characters. - -In a new file called terminal.s copy the following code: -``` -.section .data -.align 4 -terminalStart: -.int terminalBuffer -terminalStop: -.int terminalBuffer -terminalView: -.int terminalBuffer -terminalColour: -.byte 0xf -.align 8 -terminalBuffer: -.rept 128*128 -.byte 0x7f -.byte 0x0 -.endr -terminalScreen: -.rept 1024/8 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 768/16 -.byte 0x7f -.byte 0x0 -.endr -``` -This sets up the data we need for the text terminal. We have two main storages: terminalBuffer and terminalScreen. terminalBuffer is storage for all of the text we have displayed. It stores up to 128 lines of text (each containing 128 characters). Each character consists of an ASCII character code and a colour, all of which are initially set to 0x7f (ASCII delete) and 0 (black on a black background). terminalScreen stores the characters that are currently displayed on the screen. It is 128 by 48 characters, similarly initialised. You may think that we only need this terminalScreen, not the terminalBuffer, but storing the buffer has 2 main advantages: - - 1. We can easily see which characters are different, so we only have to draw those. - 2. We can 'scroll' back through the terminal's history because it is stored (to a limit). - - - -You should always try to design systems that do the minimum amount of work, as they run much faster for things which don't often change. - -The differing trick is really common on low power Operating Systems. Drawing the screen is a slow operation, and so we only want to draw thing that we absolutely have to. In this system, we can freely alter the terminalBuffer, and then call a method which copies the bits that change to the screen. This means we don't have to draw each character as we go along, which may save time in the long run on very long sections of text that span many lines. - -The other values in the .data section are as follows: - - * terminalStart - The first character which has been written in terminalBuffer. - * terminalStop - The last character which has been written in terminalBuffer. - * terminalView - The first character on the screen at present. We can use this to scroll the screen. - * temrinalColour - The colour to draw new characters with. - - - -``` -Circular buffers are an example of an **data structure**. These are just ideas we have for organising data, that we sometimes implement in software. -``` - -![Diagram showing hellow world being inserted into a circular buffer of size 5.][2] -The reason why terminalStart needs to be stored is because termainlBuffer should be a circular buffer. This means that when the buffer is completely full, the end 'wraps' round to the start, and so the character after the very last one is the first one. Thus, we need to advance terminalStart so we know that we've done this. When wokring with the buffer this can easily be implemented by checking if the index goes beyond the end of the buffer, and setting it back to the beginning if it does. Circular buffers are a common and clever way of storing a lot of data, where only the most recent data is important. It allows us to keep writing indefinitely, while always being sure there is a certain amount of recent data available. They're often used in signal processing or compression algorithms. In this case, it allows us to store a 128 line history of the terminal, without any penalties for writing over 128 lines. If we didn't have this, we would have to copy 127 lines back a line very time we went beyond the 128th line, wasting valuable time. - -I've mentioned the terminalColour here a few times. You can implement this however you, wish, however there is something of a standard on text terminals to have only 16 colours for foreground, and 16 colours for background (meaning there are 162 = 256 combinations). The colours on a CGA terminal are defined as follows: - -Table 1.1 - CGA Colour Codes -| Number | Colour (R, G, B) | -| ------ | ------------------------| -| 0 | Black (0, 0, 0) | -| 1 | Blue (0, 0, ⅔) | -| 2 | Green (0, ⅔, 0) | -| 3 | Cyan (0, ⅔, ⅔) | -| 4 | Red (⅔, 0, 0) | -| 5 | Magenta (⅔, 0, ⅔) | -| 6 | Brown (⅔, ⅓, 0) | -| 7 | Light Grey (⅔, ⅔, ⅔) | -| 8 | Grey (⅓, ⅓, ⅓) | -| 9 | Light Blue (⅓, ⅓, 1) | -| 10 | Light Green (⅓, 1, ⅓) | -| 11 | Light Cyan (⅓, 1, 1) | -| 12 | Light Red (1, ⅓, ⅓) | -| 13 | Light Magenta (1, ⅓, 1) | -| 14 | Yellow (1, 1, ⅓) | -| 15 | White (1, 1, 1) | - -``` -Brown was used as the alternative (dark yellow) was unappealing and not useful. -``` - -We store the colour of each character by storing the fore colour in the low nibble of the colour byte, and the background colour in the high nibble. Apart from brown, all of these colours follow a pattern such that in binary, the top bit represents adding ⅓ to each component, and the other bits represent adding ⅔ to individual components. This makes it easy to convert to RGB colour values. - -We need a method, TerminalColour, to read these 4 bit colour codes, and then call SetForeColour with the 16 bit equivalent. Try to implement this on your own. If you get stuck, or have not completed the Screen series, my implementation is given below: - -``` -.section .text -TerminalColour: -teq r0,#6 -ldreq r0,=0x02B5 -beq SetForeColour - -tst r0,#0b1000 -ldrne r1,=0x52AA -moveq r1,#0 -tst r0,#0b0100 -addne r1,#0x15 -tst r0,#0b0010 -addne r1,#0x540 -tst r0,#0b0001 -addne r1,#0xA800 -mov r0,r1 -b SetForeColour -``` -### 2 Showing the Text - -The first method we really need for our terminal is TerminalDisplay, one that copies the current data from terminalBuffer to terminalScreen and the actual screen. As mentioned, this method should do a minimal amount of work, because we need to be able to call it often. It should compare the text in terminalBuffer with that in terminalDisplay, and copy it across if they're different. Remember, terminalBuffer is a circular buffer running, in this case, from terminalView to terminalStop or 128*48 characters, whichever comes sooner. If we hit terminalStop, we'll assume all characters after that point are 7f16 (ASCII delete), and have colour 0 (black on a black background). - -Let's look at what we have to do: - - 1. Load in terminalView, terminalStop and the address of terminalDisplay. - 2. For each row: - 1. For each column: - 1. If view is not equal to stop, load the current character and colour from view - 2. Otherwise load the character as 0x7f and the colour as 0 - 3. Load the current character from terminalDisplay - 4. If the character and colour are equal, go to 10 - 5. Store the character and colour to terminalDisplay - 6. Call TerminalColour with the background colour in r0 - 7. Call DrawCharacter with r0 = 0x7f (ASCII delete, a block), r1 = x, r2 = y - 8. Call TerminalColour with the foreground colour in r0 - 9. Call DrawCharacter with r0 = character, r1 = x, r2 = y - 10. Increment the position in terminalDisplay by 2 - 11. If view and stop are not equal, increment the view position by 2 - 12. If the view position is at the end of textBuffer, set it to the start - 13. Increment the x co-ordinate by 8 - 2. Increment the y co-ordinate by 16 - - - -Try to implement this yourself. If you get stuck, my solution is given below: - -1. -``` -.globl TerminalDisplay -TerminalDisplay: -push {r4,r5,r6,r7,r8,r9,r10,r11,lr} -x .req r4 -y .req r5 -char .req r6 -col .req r7 -screen .req r8 -taddr .req r9 -view .req r10 -stop .req r11 - -ldr taddr,=terminalStart -ldr view,[taddr,#terminalView - terminalStart] -ldr stop,[taddr,#terminalStop - terminalStart] -add taddr,#terminalBuffer - terminalStart -add taddr,#128*128*2 -mov screen,taddr -``` - -I go a little wild with variables here. I'm using taddr to store the location of the end of the textBuffer for ease. - -2. -``` -mov y,#0 -yLoop$: -``` -Start off the y loop. - - 1. - ``` - mov x,#0 - xLoop$: - ``` - Start off the x loop. - - 1. - ``` - teq view,stop - ldrneh char,[view] - ``` - I load both the character and the colour into char simultaneously for ease. - - 2. - ``` - moveq char,#0x7f - ``` - This line complements the one above by acting as though a black delete character was read. - - 3. - ``` - ldrh col,[screen] - ``` - For simplicity I load both the character and colour into col simultaneously. - - 4. - ``` - teq col,char - beq xLoopContinue$ - ``` - Now we can check if anything has changed with a teq. - - 5. - ``` - strh char,[screen] - ``` - We can also easily save the current value. - - 6. - ``` - lsr col,char,#8 - and char,#0x7f - lsr r0,col,#4 - bl TerminalColour - ``` - I split up char into the colour in col and the character in char with a bitshift and an and, then use a bitshift to get the background colour to call TerminalColour. - - 7. - ``` - mov r0,#0x7f - mov r1,x - mov r2,y - bl DrawCharacter - ``` - Write out a delete character which is a coloured block. - - 8. - ``` - and r0,col,#0xf - bl TerminalColour - ``` - Use an and to get the low nibble of col then call TerminalColour. - - 9. - ``` - mov r0,char - mov r1,x - mov r2,y - bl DrawCharacter - ``` - Write out the character we're supposed to write. - - 10. - ``` - xLoopContinue$: - add screen,#2 - ``` - Increment the screen pointer. - - 11. - ``` - teq view,stop - addne view,#2 - ``` - Increment the view pointer if necessary. - - 12. - ``` - teq view,taddr - subeq view,#128*128*2 - ``` - It's easy to check for view going past the end of the buffer because the end of the buffer's address is stored in taddr. - - 13. - ``` - add x,#8 - teq x,#1024 - bne xLoop$ - ``` - We increment x and then loop back if there are more characters to go. - - 2. - ``` - add y,#16 - teq y,#768 - bne yLoop$ - ``` - We increment y and then loop back if there are more characters to go. - -``` -pop {r4,r5,r6,r7,r8,r9,r10,r11,pc} -.unreq x -.unreq y -.unreq char -.unreq col -.unreq screen -.unreq taddr -.unreq view -.unreq stop -``` -Don't forget to clean up at the end! - - -### 3 Printing Lines - -Now we have our TerminalDisplay method, which will automatically display the contents of terminalBuffer to terminalScreen, so theoretically we can draw text. However, we don't actually have any drawing routines that work on a character based display. A quick method that will come in handy first of all is TerminalClear, which completely clears the terminal. This can actually very easily be achieved with no loops. Try to deduce why the following method suffices: - -``` -.globl TerminalClear -TerminalClear: -ldr r0,=terminalStart -add r1,r0,#terminalBuffer-terminalStart -str r1,[r0] -str r1,[r0,#terminalStop-terminalStart] -str r1,[r0,#terminalView-terminalStart] -mov pc,lr -``` - -Now we need to make a basic method for character based displays; the Print function. This takes in a string address in r0, and a length in r1, and simply writes it to the current location at the screen. There are a few special characters to be wary of, as well as special behaviour to ensure that terminalView is kept up to date. Let's analyse what it has to do: - - 1. Check if string length is 0, if so return - 2. Load in terminalStop and terminalView - 3. Deduce the x-coordinate of terminalStop - 4. For each character: - 1. Check if the character is a new line - 2. If so, increment bufferStop to the end of the line storing a black on black delete character. - 3. Otherwise, copy the character in the current terminalColour - 4. Check if we're at the end of a line - 5. If so, check if the number of characters between terminalView and terminalStop is more than one screen - 6. If so, increment terminalView by one line - 7. Check if terminalView is at the end of the buffer, replace it with the start if so - 8. Check if terminalStop is at the end of the buffer, replace it with the start if so - 9. Check if terminalStop equals terminalStart, increment terminalStart by one line if so - 10. Check if terminalStart is at the end of the buffer, replace it with the start if so - 5. Store back terminalStop and terminalView. - - - -See if you can implement this yourself. My solution is provided below: - -1. -``` -.globl Print -Print: -teq r1,#0 -moveq pc,lr -``` -This quick check at the beginning makes a call to Print with a string of length 0 almost instant. - -2. -``` -push {r4,r5,r6,r7,r8,r9,r10,r11,lr} -bufferStart .req r4 -taddr .req r5 -x .req r6 -string .req r7 -length .req r8 -char .req r9 -bufferStop .req r10 -view .req r11 - -mov string,r0 -mov length,r1 - -ldr taddr,=terminalStart -ldr bufferStop,[taddr,#terminalStop-terminalStart] -ldr view,[taddr,#terminalView-terminalStart] -ldr bufferStart,[taddr] -add taddr,#terminalBuffer-terminalStart -add taddr,#128*128*2 -``` -I do a lot of setup here. bufferStart contains terminalStart, bufferStop contains terminalStop, view contains terminalView, taddr is the address of the end of terminalBuffer. - -3. -``` -and x,bufferStop,#0xfe -lsr x,#1 -``` -As per usual, a sneaky alignment trick makes everything easier. Because of the aligment of terminalBuffer, the x-coordinate of any character address is simply the last 8 bits divided by 2. - - 4. - 1. - ``` - charLoop$: - ldrb char,[string] - and char,#0x7f - teq char,#'\n' - bne charNormal$ - ``` - We need to check for new lines. - - 2. - ``` - mov r0,#0x7f - clearLine$: - strh r0,[bufferStop] - add bufferStop,#2 - add x,#1 - teq x,#128 blt clearLine$ - - b charLoopContinue$ - ``` - Loop until the end of the line, writing out 0x7f; a delete character in black on a black background. - - 3. - ``` - charNormal$: - strb char,[bufferStop] - ldr r0,=terminalColour - ldrb r0,[r0] - strb r0,[bufferStop,#1] - add bufferStop,#2 - add x,#1 - ``` - Store the current character in the string and the terminalColour to the end of the terminalBuffer and then increment it and x. - - 4. - ``` - charLoopContinue$: - cmp x,#128 - blt noScroll$ - ``` - Check if x is at the end of a line; 128. - - 5. - ``` - mov x,#0 - subs r0,bufferStop,view - addlt r0,#128*128*2 - cmp r0,#128*(768/16)*2 - ``` - Set x back to 0 and check if we're currently showing more than one screen. Remember, we're using a circular buffer, so if the difference between bufferStop and view is negative, we're actually wrapping around the buffer. - - 6. - ``` - addge view,#128*2 - ``` - Add one lines worth of bytes to the view address. - - 7. - ``` - teq view,taddr - subeq view,taddr,#128*128*2 - ``` - If the view address is at the end of the buffer we subtract the buffer length from it to move it back to the start. I set taddr to the address of the end of the buffer at the beginning. - - 8. - ``` - noScroll$: - teq bufferStop,taddr - subeq bufferStop,taddr,#128*128*2 - ``` - If the stop address is at the end of the buffer we subtract the buffer length from it to move it back to the start. I set taddr to the address of the end of the buffer at the beginning. - - 9. - ``` - teq bufferStop,bufferStart - addeq bufferStart,#128*2 - ``` - Check if bufferStop equals bufferStart. If so, add one line to bufferStart. - - 10. - ``` - teq bufferStart,taddr - subeq bufferStart,taddr,#128*128*2 - ``` - If the start address is at the end of the buffer we subtract the buffer length from it to move it back to the start. I set taddr to the address of the end of the buffer at the beginning. - -``` -subs length,#1 -add string,#1 -bgt charLoop$ -``` -Loop until the string is done. - -5. -``` -charLoopBreak$: -sub taddr,#128*128*2 -sub taddr,#terminalBuffer-terminalStart -str bufferStop,[taddr,#terminalStop-terminalStart] -str view,[taddr,#terminalView-terminalStart] -str bufferStart,[taddr] - -pop {r4,r5,r6,r7,r8,r9,r10,r11,pc} -.unreq bufferStart -.unreq taddr -.unreq x -.unreq string -.unreq length -.unreq char -.unreq bufferStop -.unreq view -``` -Store back the variables and return. - - -This method allows us to print arbitrary text to the screen. Throughout, I've been using the colour variable, but no where have we actually set it. Normally, terminals use special combinations of characters to change the colour. For example ASCII Escape (1b16) followed by a number 0 to f in hexadecimal could set the foreground colour to that CGA colour number. You can try implementing this yourself; my version is in the further examples section on the download page. - -### 4 Standard Input - -``` -By convention, in many programming languages, every program has access to stdin and stdout, which are an input and and output stream linked to the terminal. This is still true on graphical programs, though many don't use it. -``` - -Now we have an output terminal that in theory can print out text and display it. That is only half the story however, we want input. We want to implement a method, ReadLine, which stores the next line of text a user types to a location given in r0, up to a maximum length given in r1, and returns the length of the string read in r0. The tricky thing is, the user annoyingly wants to see what they're typing as they type it, they want to use backspace to delete mistakes and they want to use return to submit commands. They probably even want a flashing underscore character to indicate the computer would like input! These perfectly reasonable requests make this method a real challenge. One way to achieve all of this is to store the text they type in memory somewhere along with its length, and then after every character, move the terminalStop address back to where it started when ReadLine was called and calling Print. This means we only have to be able to manipulate a string in memory, and then make use of our Print function. - -Lets have a look at what ReadLine will do: - - 1. If the maximum length is 0, return 0 - 2. Retrieve the current values of terminalStop and terminalView - 3. If the maximum length is bigger than half the buffer size, set it to half the buffer size - 4. Subtract one from maximum length to ensure it can store our flashing underscore or a null terminator - 5. Write an underscore to the string - 6. Write the stored terminalView and terminalStop addresses back to the memory - 7. Call Print on the current string - 8. Call TerminalDisplay - 9. Call KeyboardUpdate - 10. Call KeyboardGetChar - 11. If it is a new line character go to 16 - 12. If it is a backspace character, subtract 1 from the length of the string (if it is > 0) - 13. If it is an ordinary character, write it to the string (if the length < maximum length) - 14. If the string ends in an underscore, write a space, otherwise write an underscore - 15. Go to 6 - 16. Write a new line character to the end of the string - 17. Call Print and TerminalDisplay - 18. Replace the new line with a null terminator - 19. Return the length of the string - - - -Convince yourself that this will work, and then try to implement it yourself. My implementation is given below: - -1. -``` -.globl ReadLine -ReadLine: -teq r1,#0 -moveq r0,#0 -moveq pc,lr -``` -Quick special handling for the zero case, which is otherwise difficult. - -2. -``` -string .req r4 -maxLength .req r5 -input .req r6 -taddr .req r7 -length .req r8 -view .req r9 - -push {r4,r5,r6,r7,r8,r9,lr} - -mov string,r0 -mov maxLength,r1 -ldr taddr,=terminalStart -ldr input,[taddr,#terminalStop-terminalStart] -ldr view,[taddr,#terminalView-terminalStart] -mov length,#0 -``` -As per the general theme, I do a lot of initialisations early. input contains the value of terminalStop and view contains terminalView. Length starts at 0. - -3. -``` -cmp maxLength,#128*64 -movhi maxLength,#128*64 -``` -We have to check for unusually large reads, as we can't process them beyond the size of the terminalBuffer (I suppose we CAN, but it would be very buggy, as terminalStart could move past the stored terminalStop). - -4. -``` -sub maxLength,#1 -``` -Since the user wants a flashing cursor, and we ideally want to put a null terminator on this string, we need 1 spare character. - -5. -``` -mov r0,#'_' -strb r0,[string,length] -``` -Write out the underscore to let the user know they can input. - -6. -``` -readLoop$: -str input,[taddr,#terminalStop-terminalStart] -str view,[taddr,#terminalView-terminalStart] -``` -Save the stored terminalStop and terminalView. This is important to reset the terminal after each call to Print, which changes these variables. Strictly speaking it can change terminalStart too, but this is irreversible. - -7. -``` -mov r0,string -mov r1,length -add r1,#1 -bl Print -``` -Write the current input. We add 1 to the length for the underscore. - -8. -``` -bl TerminalDisplay -``` -Copy the new text to the screen. - -9. -``` -bl KeyboardUpdate -``` -Fetch the latest keyboard input. - -10. -``` -bl KeyboardGetChar -``` -Retrieve the key pressed. - -11. -``` -teq r0,#'\n' -beq readLoopBreak$ -teq r0,#0 -beq cursor$ -teq r0,#'\b' -bne standard$ -``` - -Break out of the loop if we have an enter key. Also skip these conditions if we have a null terminator and process a backspace if we have one. - -12. -``` -delete$: -cmp length,#0 -subgt length,#1 -b cursor$ -``` -Remove one from the length to delete a character. - -13. -``` -standard$: -cmp length,maxLength -bge cursor$ -strb r0,[string,length] -add length,#1 -``` -Write out an ordinary character where possible. - -14. -``` -cursor$: -ldrb r0,[string,length] -teq r0,#'_' -moveq r0,#' ' -movne r0,#'_' -strb r0,[string,length] -``` -Load in the last character, and change it to an underscore if it isn't one, and a space if it is. - -15. -``` -b readLoop$ -readLoopBreak$: -``` -Loop until the user presses enter. - -16. -``` -mov r0,#'\n' -strb r0,[string,length] -``` -Store a new line at the end of the string. - -17. -``` -str input,[taddr,#terminalStop-terminalStart] -str view,[taddr,#terminalView-terminalStart] -mov r0,string -mov r1,length -add r1,#1 -bl Print -bl TerminalDisplay -``` -Reset the terminalView and terminalStop and then Print and TerminalDisplay the final input. - -18. -``` -mov r0,#0 -strb r0,[string,length] -``` -Write out the null terminator. - -19. -``` -mov r0,length -pop {r4,r5,r6,r7,r8,r9,pc} -.unreq string -.unreq maxLength -.unreq input -.unreq taddr -.unreq length -.unreq view -``` -Return the length. - - - - -### 5 The Terminal: Rise of the Machine - -So, now we can theoretically interact with the user on the terminal. The most obvious thing to do is to put this to the test! In 'main.s' delete everything after bl UsbInitialise and copy in the following code: - -``` -reset$: - mov sp,#0x8000 - bl TerminalClear - - ldr r0,=welcome - mov r1,#welcomeEnd-welcome - bl Print - -loop$: - ldr r0,=prompt - mov r1,#promptEnd-prompt - bl Print - - ldr r0,=command - mov r1,#commandEnd-command - bl ReadLine - - teq r0,#0 - beq loopContinue$ - - mov r4,r0 - - ldr r5,=command - ldr r6,=commandTable - - ldr r7,[r6,#0] - ldr r9,[r6,#4] - commandLoop$: - ldr r8,[r6,#8] - sub r1,r8,r7 - - cmp r1,r4 - bgt commandLoopContinue$ - - mov r0,#0 - commandName$: - ldrb r2,[r5,r0] - ldrb r3,[r7,r0] - teq r2,r3 - bne commandLoopContinue$ - add r0,#1 - teq r0,r1 - bne commandName$ - - ldrb r2,[r5,r0] - teq r2,#0 - teqne r2,#' ' - bne commandLoopContinue$ - - mov r0,r5 - mov r1,r4 - mov lr,pc - mov pc,r9 - b loopContinue$ - - commandLoopContinue$: - add r6,#8 - mov r7,r8 - ldr r9,[r6,#4] - teq r9,#0 - bne commandLoop$ - - ldr r0,=commandUnknown - mov r1,#commandUnknownEnd-commandUnknown - ldr r2,=formatBuffer - ldr r3,=command - bl FormatString - - mov r1,r0 - ldr r0,=formatBuffer - bl Print - -loopContinue$: - bl TerminalDisplay - b loop$ - -echo: - cmp r1,#5 - movle pc,lr - - add r0,#5 - sub r1,#5 - b Print - -ok: - teq r1,#5 - beq okOn$ - teq r1,#6 - beq okOff$ - mov pc,lr - - okOn$: - ldrb r2,[r0,#3] - teq r2,#'o' - ldreqb r2,[r0,#4] - teqeq r2,#'n' - movne pc,lr - mov r1,#0 - b okAct$ - - okOff$: - ldrb r2,[r0,#3] - teq r2,#'o' - ldreqb r2,[r0,#4] - teqeq r2,#'f' - ldreqb r2,[r0,#5] - teqeq r2,#'f' - movne pc,lr - mov r1,#1 - - okAct$: - - mov r0,#16 - b SetGpio - -.section .data -.align 2 -welcome: .ascii "Welcome to Alex's OS - Everyone's favourite OS" -welcomeEnd: -.align 2 -prompt: .ascii "\n> " -promptEnd: -.align 2 -command: - .rept 128 - .byte 0 - .endr -commandEnd: -.byte 0 -.align 2 -commandUnknown: .ascii "Command `%s' was not recognised.\n" -commandUnknownEnd: -.align 2 -formatBuffer: - .rept 256 - .byte 0 - .endr -formatEnd: - -.align 2 -commandStringEcho: .ascii "echo" -commandStringReset: .ascii "reset" -commandStringOk: .ascii "ok" -commandStringCls: .ascii "cls" -commandStringEnd: - -.align 2 -commandTable: -.int commandStringEcho, echo -.int commandStringReset, reset$ -.int commandStringOk, ok -.int commandStringCls, TerminalClear -.int commandStringEnd, 0 -``` -This code brings everything together into a simple command line operating system. The commands available are echo, reset, ok and cls. echo copies any text after it back to the terminal, reset resets the operating system if things go wrong, ok has two functions: ok on turns the OK LED on, and ok off turns the OK LED off, and cls clears the terminal using TerminalClear. - -Have a go with this code on the Raspberry Pi. If it doesn't work, please see our troubleshooting page. - -When it works, congratulations you've completed a basic terminal Operating System, and have completed the input series. Unfortunately, this is as far as these tutorials go at the moment, but I hope to make more in the future. Please send feedback to awc32@cam.ac.uk. - -You're now in position to start building some simple terminal Operating Systems. My code above builds up a table of available commands in commandTable. Each entry in the table is an int for the address of the string, and an int for the address of the code to run. The last entry has to be commandStringEnd, 0. Try implementing some of your own commands, using our existing functions, or making new ones. The parameters for the functions to run are r0 is the address of the command the user typed, and r1 is the length. You can use this to pass inputs to your commands. Maybe you could make a calculator program, perhaps a drawing program or a chess program. Whatever ideas you've got, give them a go! - --------------------------------------------------------------------------------- - -via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input02.html - -作者:[Alex Chadwick][a] -选题:[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.cl.cam.ac.uk -[b]: https://github.com/lujun9972 -[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input01.html -[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/circular_buffer.png diff --git a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 6 Screen01.md b/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 6 Screen01.md deleted file mode 100644 index 0b3cc3940c..0000000000 --- a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 6 Screen01.md +++ /dev/null @@ -1,503 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 6 Screen01) -[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen01.html) -[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) - -Computer Laboratory – Raspberry Pi: Lesson 6 Screen01 -====== - -Welcome to the Screen lesson series. In this series, you will learn how to control the screen using the Raspberry Pi in assembly code, starting at just displaying random data, then moving up to displaying a fixed image, displaying text and then formatting numbers into text. It is assumed that you have already completed the OK series, and so things covered in this series will not be repeated here. - -This first screen lesson teaches some basic theory about graphics, and then applies it to display a gradient pattern to the screen or TV. - -### 1 Getting Started - -It is expected that you have completed the OK series, and so functions in the 'gpio.s' file and 'systemTimer.s' file from that series will be called. If you do not have these files, or prefer to use a correct implementation, download the solution to OK05.s. The 'main.s' file from here will also be useful, up to and including mov sp,#0x8000. Please delete anything after that line. - -### 2 Computer Graphics - -There are a few systems for representing colours as numbers. Here we focus on RGB systems, but HSL is another common system used. - -As you're hopefully beginning to appreciate, at a fundamental level, computers are very stupid. They have a limited number of instructions, almost exclusively to do with maths, and yet somehow they are capable of doing many things. The thing we currently wish to understand is how a computer could possibly put an image on the screen. How would we translate this problem into binary? The answer is relatively straightforward; we devise some system of numbering each colour, and then we store one number for every pixel on the screen. A pixel is a small dot on your screen. If you move very close, you will probably be able to make out individual pixels on your screen, and be able to see that everything image is just made out of these pixels in combination. - -As the computer age advanced, people wanted more and more complicated graphics, and so the concept of a graphics card was invented. The graphics card is a secondary processor on your computer which only exists to draw images to the screen. It has the job of turning the pixel value information into light intensity levels to be transmitted to the screen. On modern computers, graphics cards can also do a lot more than that, such as drawing 3D graphics. In this tutorial however, we will just concentrate on the first use of graphics cards; getting pixel colours from memory out to the screen. - -One issue that is raised immediately by all this is the system we use for numbering colours. There are several choices, each producing outputs of different quality. I will outline a few here for completeness. - -Although some images here have few colours they use a technique called spatial dithering. This allows them to still show a good representation of the image, with very few colours. Many early Operating Systems used this technique. - -| Name | Unique Colours | Description | Examples | -| ----------- | --------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------- | -| Monochrome | 2 | Use 1 bit to store each pixel, with a 1 being white, and a 0 being black. | ![Monochrome image of a bird][1] | -| Greyscale | 256 | Use 1 byte to store each pixel, with 255 representing white, 0 representing black, and all values in between representing a linear combination of the two. | ![Geryscale image of a bird][2] | -| 8 Colour | 8 | Use 3 bits to store each pixel, the first bit representing the presence of a red channel, the second representing a green channel and the third a blue channel. | ![8 colour image of a bird][3] | -| Low Colour | 256 | Use 8 bits to store each pixel, the first 3 bit representing the intensity of the red channel, the next 3 bits representing the intensity of the green channel and the final 2 bits representing the intensity of the blue channel. | ![Low colour image of a bird][4] | -| High Colour | 65,536 | Use 16 bits to store each pixel, the first 5 bit representing the intensity of the red channel, the next 6 bits representing the intensity of the green channel and the final 5 bits representing the intensity of the blue channel. | ![High colour image of a bird][5] | -| True Colour | 16,777,216 | Use 24 bits to store each pixel, the first 8 bits representing the intensity of the red channel, the second 8 representing the green channel and the final 8 bits the blue channel. | ![True colour image of a bird][6] | -| RGBA32 | 16,777,216 with 256 transparency levels | Use 32 bits to store each pixel, the first 8 bits representing the intensity of the red channel, the second 8 representing the green channel, the third 8 bits the blue channel, and the final 8 bits a transparency channel. The transparency channel is only considered when drawing one image on top of another and is stored such that a value of 0 indicates the image behind's colour, a value of 255 represents this image's colour, and all values between represent a mix. | | - - -In this tutorial we shall use High Colour initially. As you can see form the image, it is produces clear, good quality images, but it doesn't take up as much space as True Colour. That said, for quite a small display of 800x600 pixels, it would still take just under 1 megabyte of space. It also has the advantage that the size is a multiple of a power of 2, which greatly reduces the complexity of getting information compared with True Colour. - -``` -Storing the frame buffer places a heavy memory burden on a computer. For this reason, early computers often cheated, by, for example, storing a screens worth of text, and just drawing each letter to the screen every time it is refreshed separately. -``` - -The Raspberry Pi has a very special and rather odd relationship with it's graphics processor. On the Raspberry Pi, the graphics processor actually runs first, and is responsible for starting up the main processor. This is very unusual. Ultimately it doesn't make too much difference, but in many interactions, it often feels like the processor is secondary, and the graphics processor is the most important. The two communicate on the Raspberry Pi by what is called the 'mailbox'. Each can deposit mail for the other, which will be collected at some future point and then dealt with. We shall use the mailbox to ask the graphics processor for an address. The address will be a location to which we can write the pixel colour information for the screen, called a frame buffer, and the graphics card will regularly check this location, and update the pixels on the screen appropriately. - -### 3 Programming the Postman - -``` -Message passing is quite a common way for components to communicate. Some Operating Systems use virtual message passing to allow programs to communicate. -``` - -The first thing we are going to need to program is a 'postman'. This is just two methods: MailboxRead, reading one message from the mailbox channel in r0. and MailboxWrite, writing the value in the top 28 bits of r0 to the mailbox channel in r1. The Raspberry Pi has 7 mailbox channels for communication with the graphics processor, only the first of which is useful to us, as it is for negotiating the frame buffer. - -The following table and diagrams describe the operation of the mailbox. - -Table 3.1 Mailbox Addresses -| Address | Size / Bytes | Name | Description | Read / Write | -| 2000B880 | 4 | Read | Receiving mail. | R | -| 2000B890 | 4 | Poll | Receive without retrieving. | R | -| 2000B894 | 4 | Sender | Sender information. | R | -| 2000B898 | 4 | Status | Information. | R | -| 2000B89C | 4 | Configuration | Settings. | RW | -| 2000B8A0 | 4 | Write | Sending mail. | W | - -In order to send a message to a particular mailbox: - - 1. The sender waits until the Status field has a 0 in the top bit. - 2. The sender writes to Write such that the lowest 4 bits are the mailbox to write to, and the upper 28 bits are the message to write. - - - -In order to read a message: - - 1. The receiver waits until the Status field has a 0 in the 30th bit. - 2. The receiver reads from Read. - 3. The receiver confirms the message is for the correct mailbox, and tries again if not. - - - -If you're feeling particularly confident, you now have enough information to write the two methods we need. If not, read on. - -As always the first method I recommend you implement is one to get the address of the mailbox region. - -``` -.globl GetMailboxBase -GetMailboxBase: -ldr r0,=0x2000B880 -mov pc,lr -``` - -The sending procedure is least complicated, so we shall implement this first. As your methods become more and more complicated, you will need to start planning them in advance. A good way to do this might be to write out a simple list of the steps that need to be done, in a fair amount of detail, like below. - - 1. Our input will be what to write (r0), and what mailbox to write it to (r1). We must validate this is by checking it is a real mailbox, and that the low 4 bits of the value are 0. Never forget to validate inputs. - 2. Use GetMailboxBase to retrieve the address. - 3. Read from the Status field. - 4. Check the top bit is 0. If not, go back to 3. - 5. Combine the value to write and the channel. - 6. Write to the Write. - - - -Let's handle each of these in order. - -1. -``` -.globl MailboxWrite -MailboxWrite: -tst r0,#0b1111 -movne pc,lr -cmp r1,#15 -movhi pc,lr -``` - -``` -tst reg,#val computes and reg,#val and compares the result with 0. -``` - -This achieves our validation on r0 and r1. tst is a function that compares two numbers by computing the logical and operation of the numbers, and then comparing the result with 0. In this case it checks that the lowest 4 bits of the input in r0 are all 0. - -2. -``` -channel .req r1 -value .req r2 -mov value,r0 -push {lr} -bl GetMailboxBase -mailbox .req r0 -``` - -This code ensures we will not overwrite our value, or link register and calls GetMailboxBase. - -3. -``` -wait1$: -status .req r3 -ldr status,[mailbox,#0x18] -``` - -This code loads in the current status. - -4. -``` -tst status,#0x80000000 -.unreq status -bne wait1$ -``` - -This code checks that the top bit of the status field is 0, and loops back to 3. if it is not. - -5. -``` -add value,channel -.unreq channel -``` - -This code combines the channel and value together. - -6. -``` -str value,[mailbox,#0x20] -.unreq value -.unreq mailbox -pop {pc} -``` - -This code stores the result to the write field. - - - - -The code for MailboxRead is quite similar. - - 1. Our input will be what mailbox to read from (r0). We must validate this is by checking it is a real mailbox. Never forget to validate inputs. - 2. Use GetMailboxBase to retrieve the address. - 3. Read from the Status field. - 4. Check the 30th bit is 0. If not, go back to 3. - 5. Read from the Read field. - 6. Check the mailbox is the one we want, if not go back to 3. - 7. Return the result. - - - -Let's handle each of these in order. - -1. -``` -.globl MailboxRead -MailboxRead: -cmp r0,#15 -movhi pc,lr -``` - -This achieves our validation on r0. - -2. -``` -channel .req r1 -mov channel,r0 -push {lr} -bl GetMailboxBase -mailbox .req r0 -``` - -This code ensures we will not overwrite our value, or link register and calls GetMailboxBase. - -3. -``` -rightmail$: -wait2$: -status .req r2 -ldr status,[mailbox,#0x18] -``` - -This code loads in the current status. - -4. -``` -tst status,#0x40000000 -.unreq status -bne wait2$ -``` - -This code checks that the 30th bit of the status field is 0, and loops back to 3. if it is not. - -5. -``` -mail .req r2 -ldr mail,[mailbox,#0] -``` - -This code reads the next item from the mailbox. - -6. -``` -inchan .req r3 -and inchan,mail,#0b1111 -teq inchan,channel -.unreq inchan -bne rightmail$ -.unreq mailbox -.unreq channel -``` - -This code checks that the channel of the mail we just read is the one we were supplied. If not it loops back to 3. - -7. -``` -and r0,mail,#0xfffffff0 -.unreq mail -pop {pc} -``` - -This code moves the answer (the top 28 bits of mail) to r0. - - - - -### 4 My Dearest Graphics Processor - -Through our new postman, we now have the ability to send a message to the graphics card. What should we send though? This was certainly a difficult question for me to find the answer to, as it isn't in any online manual that I have found. Nevertheless, by looking at the GNU/Linux for the Raspberry Pi, we are able to work out what we needed to send. - -``` -Since the RAM is shared between the graphics processor and the processor on the Pi, we can just send where to find our message. This is called DMA, many complicated devices use this to speed up access times. -``` - -The message is very simple. We describe the framebuffer we would like, and the graphics card either agrees to our request, in which case it sends us back a 0, and fills in a small questionnaire we make, or it sends back a non-zero number, in which case we know it is unhappy. Unfortunately, I have no idea what any of the other numbers it can send back are, nor what they mean, but only when it sends a zero it is happy. Fortunately it always seems to send a zero for sensible inputs, so we don't need to worry too much. - -For simplicity we shall design our request in advance, and store it in the .data section. In a file called 'framebuffer.s' place the following code: - -``` -.section .data -.align 4 -.globl FrameBufferInfo -FrameBufferInfo: -.int 1024 /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var #0 Physical Width */ -.int 768 /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var #4 Physical Height */ -.int 1024 /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var #8 Virtual Width */ -.int 768 /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var #12 Virtual Height */ -.int 0 /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var #16 GPU - Pitch */ -.int 16 /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var #20 Bit Depth */ -.int 0 /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var #24 X */ -.int 0 /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var #28 Y */ -.int 0 /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var #32 GPU - Pointer */ -.int 0 /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var #36 GPU - Size */ -``` - -This is the format of our messages to the graphics processor. The first two words describe the physical width and height. The second pair is the virtual width and height. The framebuffer's width and height are the virtual width and height, and the GPU scales the framebuffer as need to fit the physical screen. The next word is one of the ones the GPU will fill in if it grants our request. It will be the number of bytes on each row of the frame buffer, in this case 2 × 1024 = 2048. The next word is how many bits to allocate to each pixel. Using a value of 16 means that the graphics processor uses High Colour mode described above. A value of 24 would use True Colour, and 32 would use RGBA32. The next two words are x and y offsets, which mean the number of pixels to skip in the top left corner of the screen when copying the framebuffer to the screen. Finally, the last two words are filled in by the graphics processor, the first of which is the actual pointer to the frame buffer, and the second is the size of the frame buffer in bytes. - -``` -When working with devices using DMA, alignment constraints become very important. The GPU expects the message to be 16 byte aligned. -``` - -I was very careful to include a .align 4 here. As discussed before, this ensures the lowest 4 bits of the address of the next line are 0. Thus, we know for sure that FrameBufferInfo will be placed at an address we can send to the graphics processor, as our mailbox only sends values with the low 4 bits all 0. - -So, now that we have our message, we can write code to send it. The communication will go as follows: - - 1. Write the address of FrameBufferInfo + 0x40000000 to mailbox 1. - 2. Read the result from mailbox 1. If it is not zero, we didn't ask for a proper frame buffer. - 3. Copy our images to the pointer, and they will appear on screen! - - - -I've said something that I've not mentioned before in step 1. We have to add 0x40000000 to the address of FrameBufferInfo before sending it. This is actually a special signal to the GPU of how it should write to the structure. If we just send the address, the GPU will write its response, but will not make sure we can see it by flushing its cache. The cache is a piece of memory where a processor stores values its working on before sending them to the RAM. By adding 0x40000000, we tell the GPU not to use its cache for these writes, which ensures we will be able to see the change. - -Since there is quite a lot going on there, it would be best to implement this as a function, rather than just putting the code into main.s. We shall write a function InitialiseFrameBuffer which does all this negotiation and returns the pointer to the frame buffer info data above, once it has a pointer in it. For ease, we should also make it so that the width, height and bit depth of the frame buffer are inputs to this method, so that it is easy to change in main.s without having to get into the details of the negotiation. - -Once again, let's write down in detail the steps we will have to take. If you're feeling confident, try writing the function straight away. - - 1. Validate our inputs. - 2. Write the inputs into the frame buffer. - 3. Send the address of the frame buffer + 0x40000000 to the mailbox. - 4. Receive the reply from the mailbox. - 5. If the reply is not 0, the method has failed. We should return 0 to indicate failure. - 6. Return a pointer to the frame buffer info. - - - -Now we're getting into much bigger methods than before. Below is one implementation of the above. - -1. -``` -.section .text -.globl InitialiseFrameBuffer -InitialiseFrameBuffer: -width .req r0 -height .req r1 -bitDepth .req r2 -cmp width,#4096 -cmpls height,#4096 -cmpls bitDepth,#32 -result .req r0 -movhi result,#0 -movhi pc,lr -``` - -This code checks that the width and height are less than or equal to 4096, and that the bit depth is less than or equal to 32. This is once again using a trick with conditional execution. Convince yourself that this works. - -2. -``` -fbInfoAddr .req r3 -push {lr} -ldr fbInfoAddr,=FrameBufferInfo -str width,[fbInfoAddr,#0] -str height,[fbInfoAddr,#4] -str width,[fbInfoAddr,#8] -str height,[fbInfoAddr,#12] -str bitDepth,[fbInfoAddr,#20] -.unreq width -.unreq height -.unreq bitDepth -``` - -This code simply writes into our frame buffer structure defined above. I also take the opportunity to push the link register onto the stack. - -3. -``` -mov r0,fbInfoAddr -add r0,#0x40000000 -mov r1,#1 -bl MailboxWrite -``` - -The inputs to the MailboxWrite method are the value to write in r0, and the channel to write to in r1. - -4. -``` -mov r0,#1 -bl MailboxRead -``` - -The inputs to the MailboxRead method is the channel to write to in r0, and the output is the value read. - -5. -``` -teq result,#0 -movne result,#0 -popne {pc} -``` - -This code checks if the result of the MailboxRead method is 0, and returns 0 if not. - -6. -``` -mov result,fbInfoAddr -pop {pc} -.unreq result -.unreq fbInfoAddr -``` - -This code finishes off and returns the frame buffer info address. - - - - -### 5 A Pixel Within a Row Within a Frame - -So, we've now created our methods to communicate with the graphics processor. It should now be capable of giving us the pointer to a frame buffer we can draw graphics to. Let's draw something now. - -In this first example, we'll just draw consecutive colours to the screen. It won't look pretty, but at least it will be working. How we will do this is by setting each pixel in the framebuffer to a consecutive number, and continually doing so. - -Copy the following code to 'main.s' after mov sp,#0x8000 - -``` -mov r0,#1024 -mov r1,#768 -mov r2,#16 -bl InitialiseFrameBuffer -``` - -This code simply uses our InitialiseFrameBuffer method to create a frame buffer with width 1024, height 768, and bit depth 16. You can try different values in here if you wish, as long as you are consistent throughout the code. Since it's possible that this method can return 0 if the graphics processor did not give us a frame buffer, we had better check for this, and turn the OK LED on if it happens. - -``` -teq r0,#0 -bne noError$ - -mov r0,#16 -mov r1,#1 -bl SetGpioFunction -mov r0,#16 -mov r1,#0 -bl SetGpio - -error$: -b error$ - -noError$: -fbInfoAddr .req r4 -mov fbInfoAddr,r0 -``` - -Now that we have the frame buffer info address, we need to get the frame buffer pointer from it, and start drawing to the screen. We will do this using two loops, one going down the rows, and one going along the columns. On the Raspberry Pi, indeed in most applications, pictures are stored left to right then top to bottom, so we have to do the loops in the order I have said. - - -``` -render$: - - fbAddr .req r3 - ldr fbAddr,[fbInfoAddr,#32] - - colour .req r0 - y .req r1 - mov y,#768 - drawRow$: - - x .req r2 - mov x,#1024 - drawPixel$: - - strh colour,[fbAddr] - add fbAddr,#2 - sub x,#1 - teq x,#0 - bne drawPixel$ - - sub y,#1 - add colour,#1 - teq y,#0 - bne drawRow$ - - b render$ - -.unreq fbAddr -.unreq fbInfoAddr -``` - -``` -strh reg,[dest] stores the low half word number in reg at the address given by dest. -``` - -This is quite a large chunk of code, and has a loop within a loop within a loop. To help get your head around the looping, I've indented the code which is looped, depending on which loop it is in. This is quite common in most high level programming languages, and the assembler simply ignores the tabs. We see here that I load in the frame buffer address from the frame buffer information structure, and then loop over every row, then every pixel on the row. At each pixel, I use an strh (store half word) command to store the current colour, then increment the address we're writing to. After drawing each row, we increment the colour that we are drawing. After drawing the full screen, we branch back to the beginning. - -### 6 Seeing the Light - -Now you're ready to test this code on the Raspberry Pi. You should see a changing gradient pattern. Be careful: until the first message is sent to the mailbox, the Raspberry Pi displays a still gradient pattern between the four corners. If it doesn't work, please see our troubleshooting page. - -If it does work, congratulations! You can now control the screen! Feel free to alter this code to draw whatever pattern you like. You can do some very nice gradient patterns, and can compute the value of each pixel directly, since y contains a y-coordinate for the pixel, and x contains an x-coordinate. In the next lesson, [Lesson 7: Screen 02][7], we will look at one of the most common drawing tasks, lines. - --------------------------------------------------------------------------------- - -via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen01.html - -作者:[Alex Chadwick][a] -选题:[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.cl.cam.ac.uk -[b]: https://github.com/lujun9972 -[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour1bImage.png -[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour8gImage.png -[3]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour3bImage.png -[4]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour8bImage.png -[5]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour16bImage.png -[6]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/colour24bImage.png -[7]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen02.html diff --git a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 7 Screen02.md b/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 7 Screen02.md deleted file mode 100644 index 3a8fe60f6f..0000000000 --- a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 7 Screen02.md +++ /dev/null @@ -1,449 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 7 Screen02) -[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen02.html) -[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) - -Computer Laboratory – Raspberry Pi: Lesson 7 Screen02 -====== - -The Screen02 lesson builds on Screen01, by teaching how to draw lines and also a small feature on generating pseudo random numbers. It is assumed you have the code for the [Lesson 6: Screen01][1] operating system as a basis. - -### 1 Dots - -Now that we've got the screen working, it is only natural to start waiting to create sensible images. It would be very nice indeed if we were able to actually draw something. One of the most basic components in all drawings is a line. If we were able to draw a line between any two points on the screen, we could start creating more complicated drawings just using combinations of these lines. - -``` -To allow complex drawing, some systems use a colouring function rather than just one colour to draw things. Each pixel calls the colouring function to determine what colour to draw there. -``` - -We will attempt to implement this in assembly code, but first we could really use some other functions to help. We need a function I will call SetPixel that changes the colour of a particular pixel, supplied as inputs in r0 and r1. It will be helpful for future if we write code that could draw to any memory, not just the screen, so first of all, we need some system to control where we are actually going to draw to. I think that the best way to do this would be to have a piece of memory which stores where we are going to draw to. What we should end up with is a stored address which normally points to the frame buffer structure from last time. We will use this at all times in our drawing method. That way, if we want to draw to a different image in another part of our operating system, we could make this value the address of a different structure, and use the exact same code. For simplicity we will use another piece of data to control the colour of our drawings. - -Copy the following code to a new file called 'drawing.s'. - -``` -.section .data -.align 1 -foreColour: -.hword 0xFFFF - -.align 2 -graphicsAddress: -.int 0 - -.section .text -.globl SetForeColour -SetForeColour: -cmp r0,#0x10000 -movhs pc,lr -ldr r1,=foreColour -strh r0,[r1] -mov pc,lr - -.globl SetGraphicsAddress -SetGraphicsAddress: -ldr r1,=graphicsAddress -str r0,[r1] -mov pc,lr -``` - -This is just the pair of functions that I described above, along with their data. We will use them in 'main.s' before drawing anything to control where and what we are drawing. - -``` -Building generic methods like SetPixel which we can build other methods on top of is a useful idea. We have to make sure the method is fast though, since we will use it a lot. -``` - -Our next task is to implement a SetPixel method. This needs to take two parameters, the x and y co-ordinate of a pixel, and it should use the graphicsAddress and foreColour we have just defined to control exactly what and where it is drawing. If you think you can implement this immediately, do, if not I shall outline the steps to be taken, and then give an example implementation. - - 1. Load in the graphicsAddress. - 2. Check that the x and y co-ordinates of the pixel are less than the width and height. - 3. Compute the address of the pixel to write. (hint: frameBufferAddress + (x + y core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated width) * pixel size) - 4. Load in the foreColour. - 5. Store it at the address. - - - -An implementation of the above follows. - -1. -``` -.globl DrawPixel -DrawPixel: -px .req r0 -py .req r1 -addr .req r2 -ldr addr,=graphicsAddress -ldr addr,[addr] -``` - -2. -``` -height .req r3 -ldr height,[addr,#4] -sub height,#1 -cmp py,height -movhi pc,lr -.unreq height - -width .req r3 -ldr width,[addr,#0] -sub width,#1 -cmp px,width -movhi pc,lr -``` - -Remember that the width and height are stored at offsets of 0 and 4 into the frame buffer description respectively. You can refer back to 'frameBuffer.s' if necessary. - -3. -``` -ldr addr,[addr,#32] -add width,#1 -mla px,py,width,px -.unreq width -.unreq py -add addr, px,lsl #1 -.unreq px -``` - -``` -mla dst,reg1,reg2,reg3 multiplies the values from reg1 and reg2, adds the value from reg3 and places the least significant 32 bits of the result in dst. -``` - -Admittedly, this code is specific to high colour frame buffers, as I use a bit shift directly to compute this address. You may wish to code a version of this function without the specific requirement to use high colour frame buffers, remembering to update the SetForeColour code. It may be significantly more complicated to implement. - -4. -``` -fore .req r3 -ldr fore,=foreColour -ldrh fore,[fore] -``` - -As above, this is high colour specific. - -5. -``` -strh fore,[addr] -.unreq fore -.unreq addr -mov pc,lr -``` - -As above, this is high colour specific. - - - - -### 2 Lines - -The trouble is, line drawing isn't quite as simple as you may expect. By now you must realise that when making operating system, we have to do almost everything ourselves, and line drawing is no exception. I suggest for a few minutes you have a think about how you would draw a line between any two points. - -``` -When programming normally, we tend to be lazy with things like division. Operating Systems must be incredibly efficient, and so we must focus on doing things as best as possible. -``` - -I expect the central idea of most strategies will involve computing the gradient of the line, and stepping along it. This sounds perfectly reasonable, but is actually a terrible idea. The problem with it is it involves division, which is something that we know can't easily be done in assembly, and also keeping track of decimal numbers, which is again difficult. There is, in fact, an algorithm called Bresenham's Algorithm, which is perfect for assembly code because it only involves addition, subtraction and bit shifts. -``` -Let's start off by defining a reasonably straightforward line drawing algorithm as follows: - -if x1 > x0 then - -set deltax to x1 - x0 -set stepx to +1 - -otherwise - -set deltax to x0 - x1 -set stepx to -1 - -end if - -if y1 > y0 then - -set deltay to y1 - y0 -set stepy to +1 - -otherwise - -set deltay to y0 - y1 -set stepy to -1 - -end if - -if deltax > deltay then - -set error to 0 -until x0 = x1 + stepx - -setPixel(x0, y0) -set error to error + deltax ÷ deltay -if error ≥ 0.5 then - -set y0 to y0 + stepy -set error to error - 1 - -end if -set x0 to x0 + stepx - -repeat - -otherwise - -end if - -This algorithm is a representation of the sort of thing you may have imagined. The variable error keeps track of how far away from the actual line we are. Every step we take along the x axis increases this error, and every time we move down the y axis, the error decreases by 1 unit again. The error is measured as a distance along the y axis. - -While this algorithm works, it suffers a major problem in that we clearly have to use decimal numbers to store error, and also we have to do a division. An immediate optimisation would therefore be to change the units of error. There is no need to store it in any particular units, as long as we scale every use of it by the same amount. Therefore, we could rewrite the algorithm simply by multiplying all equations involving error by deltay, and simplifying the result. Just showing the main loop: - -set error to 0 × deltay -until x0 = x1 + stepx - -setPixel(x0, y0) -set error to error + deltax ÷ deltay × deltay -if error ≥ 0.5 × deltay then - -set y0 to y0 + stepy -set error to error - 1 × deltay - -end if -set x0 to x0 + stepx - -repeat - -Which simplifies to: - -set error to 0 -until x0 = x1 + stepx - -setPixel(x0, y0) -set error to error + deltax -if error × 2 ≥ deltay then - -set y0 to y0 + stepy -set error to error - deltay - -end if -set x0 to x0 + stepx - -repeat - -Suddenly we have a much better algorithm. We see now that we've eliminated the need for division altogether. Better still, the only multiplication is by 2, which we know is just a bit shift left by 1! This is now very close to Bresenham's Algorithm, but one further optimisation can be made. At the moment, we have an if statement which leads to two very similar blocks of code, one for lines with larger x differences, and one for lines with larger y differences. It is worth checking if the code could be converted to a single statement for both types of line. - -The difficulty arises somewhat in that in the first case, error is to do with y, and in the second case error is to do with x. The solution is to track the error in both variables simultaneously, using negative error to represent an error in x, and positive error in y. - -set error to deltax - deltay -until x0 = x1 + stepx or y0 = y1 + stepy - -setPixel(x0, y0) -if error × 2 > -deltay then - -set x0 to x0 + stepx -set error to error - deltay - -end if -if error × 2 < deltax then - -set y0 to y0 + stepy -set error to error + deltax - -end if - -repeat - -It may take some time to convince yourself that this actually works. At each step, we consider if it would be correct to move in x or y. We do this by checking if the magnitude of the error would be lower if we moved in the x or y co-ordinates, and then moving if so. -``` - -``` -Bresenham's Line Algorithm was developed in 1962 by Jack Elton Bresenham, 24 at the time, whilst studying for a PhD. -``` - -Bresenham's Algorithm for drawing a line can be described by the following pseudo code. Pseudo code is just text which looks like computer instructions, but is actually intended for programmers to understand algorithms, rather than being machine readable. - -``` -/* We wish to draw a line from (x0,y0) to (x1,y1), using only a function setPixel(x,y) which draws a dot in the pixel given by (x,y). */ -if x1 > x0 then - set deltax to x1 - x0 - set stepx to +1 -otherwise - set deltax to x0 - x1 - set stepx to -1 -end if - -set error to deltax - deltay -until x0 = x1 + stepx or y0 = y1 + stepy - setPixel(x0, y0) - if error × 2 ≥ -deltay then - set x0 to x0 + stepx - set error to error - deltay - end if - if error × 2 ≤ deltax then - set y0 to y0 + stepy - set error to error + deltax - end if -repeat -``` - -Rather than numbered lists as I have used so far, this representation of an algorithm is far more common. See if you can implement this yourself. For reference, I have provided my implementation below. - -``` -.globl DrawLine -DrawLine: -push {r4,r5,r6,r7,r8,r9,r10,r11,r12,lr} -x0 .req r9 -x1 .req r10 -y0 .req r11 -y1 .req r12 - -mov x0,r0 -mov x1,r2 -mov y0,r1 -mov y1,r3 - -dx .req r4 -dyn .req r5 /* Note that we only ever use -deltay, so I store its negative for speed. (hence dyn) */ -sx .req r6 -sy .req r7 -err .req r8 - -cmp x0,x1 -subgt dx,x0,x1 -movgt sx,#-1 -suble dx,x1,x0 -movle sx,#1 - -cmp y0,y1 -subgt dyn,y1,y0 -movgt sy,#-1 -suble dyn,y0,y1 -movle sy,#1 - -add err,dx,dyn -add x1,sx -add y1,sy - -pixelLoop$: - - teq x0,x1 - teqne y0,y1 - popeq {r4,r5,r6,r7,r8,r9,r10,r11,r12,pc} - - mov r0,x0 - mov r1,y0 - bl DrawPixel - - cmp dyn, err,lsl #1 - addle err,dyn - addle x0,sx - - cmp dx, err,lsl #1 - addge err,dx - addge y0,sy - - b pixelLoop$ - -.unreq x0 -.unreq x1 -.unreq y0 -.unreq y1 -.unreq dx -.unreq dyn -.unreq sx -.unreq sy -.unreq err -``` - -### 3 Randomness - -So, now we can draw lines. Although we could use this to draw pictures and whatnot (feel free to do so!), I thought I would take the opportunity to introduce the idea of computer randomness. What we will do is select a pair of random co-ordinates, and then draw a line from the last pair to that point in steadily incrementing colours. I do this purely because it looks quite pretty. - -``` -Hardware random number generators are occasionally used in security, where the predictability sequence of random numbers may affect the security of some encryption. -``` - -So, now it comes down to it, how do we be random? Unfortunately for us there isn't some device which generates random numbers (such devices are very rare). So somehow using only the operations we've learned so far we need to invent 'random numbers'. It shouldn't take you long to realise this is impossible. The operations always have well defined results, executing the same sequence of instructions with the same registers yields the same answer. What we instead do is deduce a sequence that is pseudo random. This means numbers that, to the outside observer, look random, but in fact were completely determined. So, we need a formula to generate random numbers. One might be tempted to just spam mathematical operators out for example: 4x2! / 64, but in actuality this generally produces low quality random numbers. In this case for example, if x were 0, the answer would be 0. Stupid though it sounds, we need a very careful choice of equation to produce high quality random numbers. - -``` -This sort of discussion often begs the question what do we mean by a random number? We generally mean statistical randomness: A sequence of numbers that has no obvious patterns or properties that could be used to generalise it. -``` - -The method I'm going to teach you is called the quadratic congruence generator. This is a good choice because it can be implemented in 5 instructions, and yet generates a seemingly random order of the numbers from 0 to 232-1. - -The reason why the generator can create such long sequence with so few instructions is unfortunately a little beyond the scope of this course, but I encourage the interested to research it. It all centralises on the following quadratic formula, where xn is the nth random number generated. - -x_(n+1) = ax_(n)^2 + bx_(n) + c mod 2^32 - -Subject to the following constraints: - - 1. a is even - - 2. b = a + 1 mod 4 - - 3. c is odd - - - - -If you've not seen mod before, it means the remainder of a division by the number after it. For example b = a + 1 mod 4 means that b is the remainder of dividing a + 1 by 4, so if a were 12 say, b would be 1 as a + 1 is 13, and 13 divided by 4 is 3 remainder 1. - -Copy the following code into a file called 'random.s'. - -``` -.globl Random -Random: -xnm .req r0 -a .req r1 - -mov a,#0xef00 -mul a,xnm -mul a,xnm -add a,xnm -.unreq xnm -add r0,a,#73 - -.unreq a -mov pc,lr -``` - -This is an implementation of the random function, with an input of the last value generated in r0, and an output of the next number. In my case, I've used a = EF0016, b = 1, c = 73. This choice was arbitrary but meets the requirements above. Feel free to use any numbers you wish instead, as long as they obey the rules. - -### 4 Pi-casso - -OK, now we have all the functions we're going to need, let's try it out. Alter main to do the following, after getting the frame buffer info address: - - 1. Call SetGraphicsAddress with r0 containing the frame buffer info address. - 2. Set four registers to 0. One will be the last random number, one will be the colour, one will be the last x co-ordinate and one will be the last y co-ordinate. - 3. Call random to generate the next x-coordinate, using the last random number as the input. - 4. Call random again to generate the next y-coordinate, using the x-coordinate you generated as an input. - 5. Update the last random number to contain the y-coordinate. - 6. Call SetForeColour with the colour, then increment the colour. If it goes above FFFF16, make sure it goes back to 0. - 7. The x and y coordinates we have generated are between 0 and FFFFFFFF16. Convert them to a number between 0 and 102310 by using a logical shift right of 22. - 8. Check the y coordinate is on the screen. Valid y coordinates are between 0 and 76710. If not, go back to 3. - 9. Draw a line from the last x and y coordinates to the current x and y coordinates. - 10. Update the last x and y coordinates to contain the current ones. - 11. Go back to 3. - - - -As always, a solution for this can be found on the downloads page. - -Once you've finished, test it on the Raspberry Pi. You should see a very fast sequence of random lines being drawn on the screen, in steadily incrementing colours. This should never stop. If it doesn't work, please see our troubleshooting page. - -When you have it working, congratulations! We've now learned about meaningful graphics, and also about random numbers. I encourage you to play with line drawing, as it can be used to render almost anything you want. You may also want to explore more complicated shapes. Most can be made out of lines, but is this necessarily the best strategy? If you like the line program, try experimenting with the SetPixel function. What happens if instead of just setting the value of the pixel, you increase it by a small amount? What other patterns can you make? In the next lesson, [Lesson 8: Screen 03][2], we will look at the invaluable skill of drawing text. - --------------------------------------------------------------------------------- - -via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen02.html - -作者:[Alex Chadwick][a] -选题:[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.cl.cam.ac.uk -[b]: https://github.com/lujun9972 -[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen01.html -[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen03.html diff --git a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 8 Screen03.md b/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 8 Screen03.md deleted file mode 100644 index 08803fd50f..0000000000 --- a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 8 Screen03.md +++ /dev/null @@ -1,485 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 8 Screen03) -[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen03.html) -[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) - -Computer Laboratory – Raspberry Pi: Lesson 8 Screen03 -====== - -The Screen03 lesson builds on Screen02, by teaching how to draw text, and also a small feature on the command line arguments of the operating system. It is assumed you have the code for the [Lesson 7: Screen02][1] operating system as a basis. - -### 1 String Theory - -So, our task for this operating system is to draw text. We have several problems to address, the most pressing of which is probably about storing text. Unbelievably text has been one of the biggest flaws on computers to date. What should have been a straightforward type of data has brought down operating systems, crippled otherwise wonderful encryption, and caused many problems for users of different alphabets. Nevertheless, it is an incredibly important type of data, as it is an excellent link between the computer and the user. Text can be sufficiently structured that the operating system understands it, as well as sufficiently readable that humans can use it. - -``` -Variable data types such as text require much more complex handling. -``` - -So how exactly is text stored? Simply enough, we have some system by which we give each letter a unique number, and then store a sequence of such numbers. Sounds easy. The problem is that the number of numbers is not fixed. Some pieces of text are longer than others. With storing ordinary numbers, we have some fixed limit, e.g. 32 bits, and then we can't go beyond that, we write methods that use numbers of that length, etc. In terms of text, or strings as we often call it, we want to write functions that work on variable length strings, otherwise we would need a lot of functions! This is not a problem for numbers normally, as there are only a few common number formats (byte, word, half, double). - -``` -Buffer overrun attacks have plagued computers for years. Recently, the Wii, Xbox and Playstation 2 all suffered buffer overrun attacks, as well as large systems like Microsoft's Web and Database servers. -``` - -So, how do we determine how long the string is? I think the obvious answer is just to store how long the string is, and then to store the characters that make it up. This is called length prefixing, as the length comes before the string. Unfortunately, the pioneers of computer science did not agree. They felt it made more sense to have a special character called the null terminator (denoted \0) which represents when a string ends. This does indeed simplify many string algorithms, as you just keep working until the null terminator. Unfortunately this is the source of many security issues. What if a malicious user gives you a very long string? What if you didn't have enough space to store it. You might run a string copying function that copies until the null terminator, but because the string is so long, it overwrites your program. This may sound far fetched, but nevertheless, such buffer overrun attacks are incredibly common. Length prefixing mitigates this problem as it is easy to deduce the size of the buffer required to store the string. As an operating system developer, I leave it to you to decide how best to store text. - -The next thing we need to establish is how best to map characters to numbers. Fortunately, this is reasonably well standardised, so you have two major choices, Unicode and ASCII. Unicode maps almost every single useful symbol that can be written to a number, in exchange for having a lot more numbers, and a more complicated encoding system. ASCII uses one byte per character, and so only stores the Latin alphabet, numbers, a few symbols and a few special characters. Thus, ASCII is very easy to implement, compared to Unicode, in which not every character takes the same space, making string algorithms tricky. Normally operating systems use ASCII for strings which will not be displayed to end users (but perhaps to developers or experts), and Unicode for displaying messages to users, as Unicode can support things like Japanese characters, and so could be localised. - -Fortunately for us, this decision is irrelevant at the moment, as the first 128 characters of both are exactly the same, and are encoded exactly the same. - -Table 1.1 ASCII/Unicode symbols 0-127 - -| | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | f | | -|----| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ----| -| 00 | NUL | SOH | STX | ETX | EOT | ENQ | ACK | BEL | BS | HT | LF | VT | FF | CR | SO | SI | | -| 10 | DLE | DC1 | DC2 | DC3 | DC4 | NAK | SYN | ETB | CAN | EM | SUB | ESC | FS | GS | RS | US | | -| 20 | ! | " | # | $ | % | & | . | ( | ) | * | + | , | - | . | / | | | -| 30 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | : | ; | < | = | > | ? | | -| 40 | @ | A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | | -| 50 | P | Q | R | S | T | U | V | W | X | Y | Z | [ | \ | ] | ^ | _ | | -| 60 | ` | a | b | c | d | e | f | g | h | i | j | k | l | m | n | o | | -| 70 | p | q | r | s | t | u | v | w | x | y | z | { | | | } | ~ | DEL | - -The table shows the first 128 symbols. The hexadecimal representation of the number for a symbol is the row value added to the column value, for example A is 4116. What you may find surprising is the first two rows, and the very last value. These 33 special characters are not printed at all. In fact, these days, many are ignored. They exist because ASCII was originally intended as a system for transmitting data over computer networks, and so a lot more information than just the symbols had to be sent. The key special symbols that you should learn are NUL, the null terminator character I mentioned before, HT, horizontal tab is what we normally refer to as a tab and LF, the line feed character is used to make a new line. You may wish to research and use the other characters for special meanings in your operating system. - -### 2 Characters - -So, now that we know a bit about strings, we can start to think about how they're displayed. The fundamental thing we need to do in order to be able to display a string is to be able to display a character. Our first task will be making a DrawCharacter function which takes in a character to draw and a location, and then draws the character. - -``` -The true type font format used in many Operating Systems is so powerful, it has its own assembly language built in to ensure letters look correct at any resolution. -``` - -Naturally, this leads to a discussion about fonts. We already know there are many ways to display any given letter in accordance with font choice. So how does a font work? In the very early days of computer science, a font was just a series of little pictures of all the letters, called a bitmap font, and all the draw character method would do is copy one of the pictures to the screen. The trouble with this is when people want to resize the text. Sometimes we need big letters, and sometimes small. Although we could keep drawing new pictures for every font at every size with every character, this would get tedious. Thus, vector fonts were invented. in vector fonts, rather than containing an image of the font, the font file contains a description of how to draw it, e.g. an 'o' could be circle with radius half that of the maximum letter height. Modern operating systems use such fonts almost exclusively, as they are perfect at any resolution. - -Unfortunately, much though I would love to include an implementation of one of the vector font formats, it would take up the remainder of this website. Thus, we will implement a bitmap font, though if you wish to make a decent graphical operating system, a vector font would be useful. -``` -00000000 -00000000 -00000000 -00010000 -00101000 -00101000 -00101000 -01000100 -01000100 -01111100 -11000110 -10000010 -00000000 -00000000 -00000000 -00000000 -``` - -On the downloads page, I have included several '.bin' files in the font section. These are just raw binary data files for a few fonts. For this tutorial, pick your favourite from the monospace, monochrome, 8x16 section. Download it and store it in the 'source' directory as 'font.bin'. These files are just monochrome images of each of the letters in turn, with each letter being exactly 8 by 16 pixels. Thus, each takes 16 bytes, the first byte being the top row, the second the next, etc. - -The diagram shows the 'A' character in the monospace, monochrome, 8x16 font Bitstream Vera Sans Mono. In the file, we would find this starting at the 4116 × 1016 = 41016th byte as the following sequence in hexadecimal: - -00, 00, 00, 10, 28, 28, 28, 44, 44, 7C, C6, 82, 00, 00, 00, 00 - -We're going to use a monospace font here, because in a monospace font every character is the same size. Unfortunately, yet another complication with most fonts is that the character's widths vary, leading to more complex display code. I've included a few other fonts on the downloads page, as well as an explanation of the format I've stored them all in. - -So let's get down to business. Copy the following to 'drawing.s' after the .int 0 of graphicsAddress. - -``` -.align 4 -font: -.incbin "font.bin" -``` - -``` -.incbin "file" inserts the binary data from the file file. -``` - -This code copies the font data from the file to the address labelled font. We've used an .align 4 here to ensure each character starts on a multiple of 16 bytes, which can be used for a speed trick later. - -Now we want to write the draw character method. I'll give the pseudo code for this, so you can try to implement it yourself if you want to. Conventionally >> means logical shift right. - -``` -function drawCharacter(r0 is character, r1 is x, r2 is y) - if character > 127 then exit - set charAddress to font + character × 16 - for row = 0 to 15 - set bits to readByte(charAddress + row) - for bit = 0 to 7 - if test(bits >> bit, 0x1) - then setPixel(x + bit, y + row) - next - next - return r0 = 8, r1 = 16 -end function - -``` -If implemented directly, this is deliberately not very efficient. With things like drawing characters, efficiency is a top priority, as we will do it a lot. Let's explore some improvements that bring this closer to optimal assembly code. Firstly, we have a × 16, which by now you should spot is the same as a logical shift left by 4 places. Next we have a variable row, which is only ever added to charAddress and to y. Thus, we can eliminate it by increasing these variables instead. The only issue now is how to tell when we've finished. This is where the .align 4 comes in handy. We know that charAddress will start with the low nibble containing 0. This means we can see how far into the character data we are by checking that low nibble. - -Though we can eliminate the need for bits, we must introduce a new variable to do so, so it is best left in. The only other improvement that can be made is to remove the nested bits >> bit. - -``` -function drawCharacter(r0 is character, r1 is x, r2 is y) - if character > 127 then exit - set charAddress to font + character << 4 - loop - set bits to readByte(charAddress) - set bit to 8 - loop - set bits to bits << 1 - set bit to bit - 1 - if test(bits, 0x100) - then setPixel(x + bit, y) - until bit = 0 - set y to y + 1 - set chadAddress to chadAddress + 1 - until charAddress AND 0b1111 = 0 - return r0 = 8, r1 = 16 -end function -``` - -Now we've got code that is much closer to assembly code, and is near optimal. Below is the assembly code version of the above. - -``` -.globl DrawCharacter -DrawCharacter: -cmp r0,#127 -movhi r0,#0 -movhi r1,#0 -movhi pc,lr - -push {r4,r5,r6,r7,r8,lr} -x .req r4 -y .req r5 -charAddr .req r6 -mov x,r1 -mov y,r2 -ldr charAddr,=font -add charAddr, r0,lsl #4 - -lineLoop$: - - bits .req r7 - bit .req r8 - ldrb bits,[charAddr] - mov bit,#8 - - charPixelLoop$: - - subs bit,#1 - blt charPixelLoopEnd$ - lsl bits,#1 - tst bits,#0x100 - beq charPixelLoop$ - - add r0,x,bit - mov r1,y - bl DrawPixel - - teq bit,#0 - bne charPixelLoop$ - - charPixelLoopEnd$: - .unreq bit - .unreq bits - add y,#1 - add charAddr,#1 - tst charAddr,#0b1111 - bne lineLoop$ - -.unreq x -.unreq y -.unreq charAddr - -width .req r0 -height .req r1 -mov width,#8 -mov height,#16 - -pop {r4,r5,r6,r7,r8,pc} -.unreq width -.unreq height -``` - -### 3 Strings - -Now that we can draw characters, we can draw text. We need to make a method that, for a given string, draws each character in turn, at incrementing positions. To be nice, we shall also implement new lines and tabs. It's decision time as far as null terminators are concerned, and if you want to make your operating system use them, feel free by changing the code below. To avoid the issue, I will have the length of the string passed as an argument to the DrawString function, along with the address of the string, and the x and y coordinates. - -``` -function drawString(r0 is string, r1 is length, r2 is x, r3 is y) - set x0 to x - for pos = 0 to length - 1 - set char to loadByte(string + pos) - set (cwidth, cheight) to DrawCharacter(char, x, y) - if char = '\n' then - set x to x0 - set y to y + cheight - otherwise if char = '\t' then - set x1 to x - until x1 > x0 - set x1 to x1 + 5 × cwidth - loop - set x to x1 - otherwise - set x to x + cwidth - end if - next -end function -``` - -Once again, this function isn't that close to assembly code. Feel free to try to implement it either directly or by simplifying it. I will give the simplification and then the assembly code below. - -Clearly the person who wrote this function wasn't being very efficient (me in case you were wondering). Once again we have a pos variable that just increments and is added to something else, which is completely unnecessary. We can remove it, and instead simultaneously decrement length until it is 0, saving the need for one register. The rest of the function is probably fine, except for that annoying multiplication by five. A key thing to do here would be to move the multiplication outside the loop; multiplication is slow even with bit shifts, and since we're always adding the same constant multiplied by 5, there is no need to recompute this. It can in fact be implemented in one operation using the argument shifting in assembly code, so I shall rephrase it like that. - -``` -function drawString(r0 is string, r1 is length, r2 is x, r3 is y) - set x0 to x - until length = 0 - set length to length - 1 - set char to loadByte(string) - set (cwidth, cheight) to DrawCharacter(char, x, y) - if char = '\n' then - set x to x0 - set y to y + cheight - otherwise if char = '\t' then - set x1 to x - set cwidth to cwidth + cwidth << 2 - until x1 > x0 - set x1 to x1 + cwidth - loop - set x to x1 - otherwise - set x to x + cwidth - end if - set string to string + 1 - loop -end function -``` - -In assembly code: - -``` -.globl DrawString -DrawString: -x .req r4 -y .req r5 -x0 .req r6 -string .req r7 -length .req r8 -char .req r9 -push {r4,r5,r6,r7,r8,r9,lr} - -mov string,r0 -mov x,r2 -mov x0,x -mov y,r3 -mov length,r1 - -stringLoop$: - subs length,#1 - blt stringLoopEnd$ - - ldrb char,[string] - add string,#1 - - mov r0,char - mov r1,x - mov r2,y - bl DrawCharacter - cwidth .req r0 - cheight .req r1 - - teq char,#'\n' - moveq x,x0 - addeq y,cheight - beq stringLoop$ - - teq char,#'\t' - addne x,cwidth - bne stringLoop$ - - add cwidth, cwidth,lsl #2 - x1 .req r1 - mov x1,x0 - - stringLoopTab$: - add x1,cwidth - cmp x,x1 - bge stringLoopTab$ - mov x,x1 - .unreq x1 - b stringLoop$ -stringLoopEnd$: -.unreq cwidth -.unreq cheight - -pop {r4,r5,r6,r7,r8,r9,pc} -.unreq x -.unreq y -.unreq x0 -.unreq string -.unreq length -``` - -``` -subs reg,#val subtracts val from the register reg and compares the result with 0. -``` - -This code makes clever use of a new operation, subs which subtracts one number from another, stores the result and then compares it with 0. In truth, all comparisons are implemented as a subtraction and then comparison with 0, but the result is normally discarded. This means that this operation is as fast as cmp. - -### 4 Your Wish is My Command Line - -Now that we can print strings, the challenge is to find an interesting one to draw. Normally in tutorials such as this, people just draw "Hello World!", but after all we've done so far, I feel that is a little patronising (feel free to do so if it helps). Instead we're going to draw our command line. - -A convention has been made for computers running ARM. When they boot, it is important they are given certain information about what they have available to them. Most all processors have some way of ascertaining this information, and on ARM this is by data left at the address 10016. The format of the data is as follows: - - 1. The data is broken down into a series of 'tags'. - 2. There are nine types of tag: 'core', 'mem', 'videotext', 'ramdisk', 'initrd2', 'serial' 'revision', 'videolfb', 'cmdline'. - 3. Each can only appear once, but all but the 'core' tag don't have to appear. - 4. The tags are placed from 0x100 in order one after the other. - 5. The end of the list of tags always contains 2 words which are 0. - 6. Every tag's size in bytes is a multiple of 4. - 7. Each tag starts with the size of the tag in words in the tag, including this number. - 8. This is followed by a half word containing the tag's number. These are numbered from 1 in the order above ('core' is 1, 'cmdline' is 9). - 9. This is followed by a half word containing 544116. - 10. After this comes the data of the tag, which varies depending on the tag. The size of the data in words + 2 is always the same as the length mentioned above. - 11. A 'core' tag is either 2 or 5 words in length. If it is 2, there is no data, if it is 5, it has 3 words. - 12. A 'mem' tag is always 4 words in length. The data is the first address in a block of memory, and the length of that block. - 13. A 'cmdline' tag contains a null terminated string which is the parameters of the kernel. - - -``` -Almost all Operating Systems support the notion of programs having a 'command line'. The idea is to provide a common mechanism for choosing the desired behaviour of the program. -``` - -On the current version of the Raspberry Pi, only the 'core', 'mem' and 'cmdline' tags are present. You may find these useful later, and a more complete reference for these is on our Raspberry Pi reference page. The one we're interested in at the moment is the 'cmdline' tag, because it contains a string. We're going to write some code to search for the command line tag, and, if found, to print it out with each item on a new line. The command line is just a list of things that either the graphics processor or the user thought it might be nice for the Operating System to know. On the Raspberry Pi, this includes the MAC Address, serial number and screen resolution. The string itself is just a list of expressions such as 'key.subkey=value' separated by spaces. - -Let's start by finding the 'cmdline' tag. In a new file called 'tags.s' copy the following code. - -``` -.section .data -tag_core: .int 0 -tag_mem: .int 0 -tag_videotext: .int 0 -tag_ramdisk: .int 0 -tag_initrd2: .int 0 -tag_serial: .int 0 -tag_revision: .int 0 -tag_videolfb: .int 0 -tag_cmdline: .int 0 -``` - -Looking through the list of tags will be a slow operation, as it involves a lot of memory access. Therefore, we only want to have to do it once. This code creates some data which will store the memory address of the first tag of each of the types. Then, to find a tag the following pseudo code will suffice. - -``` -function FindTag(r0 is tag) - if tag > 9 or tag = 0 then return 0 - set tagAddr to loadWord(tag_core + (tag - 1) × 4) - if not tagAddr = 0 then return tagAddr - if readWord(tag_core) = 0 then return 0 - set tagAddr to 0x100 - loop forever - set tagIndex to readHalfWord(tagAddr + 4) - if tagIndex = 0 then return FindTag(tag) - if readWord(tag_core+(tagIndex-1)×4) = 0 - then storeWord(tagAddr, tag_core+(tagIndex-1)×4) - set tagAddr to tagAddr + loadWord(tagAddr) × 4 - end loop -end function -``` -This code is already quite well optimised and close to assembly. It is optimistic in that the first thing it tries is loading the tag directly, as all but the first time this should be the case. If that fails, it checks if the core tag has an address. Since there must always be a core tag, the only reason that it would not have an address is if it doesn't exist. If it does have an address, the tag we were looking for didn't. If it doesn't we need to find the addresses of all the tags. It does this by reading the number of the tag. If it is zero, that must mean we are at the end of the list. This means we've now filled in all the tags in our directory. Therefore if we run our function again, it will now be able to produce an answer. If the tag number is not zero, we check to see if this tag type already has an address. If not, we store the address of this tag in our directory. We then add the length of this tag in bytes to the tag address to find the next tag. - -Have a go at implementing this code in assembly. You will need to simplify it. If you get stuck, my answer is below. Don't forget the .section .text! - -``` -.section .text -.globl FindTag -FindTag: -tag .req r0 -tagList .req r1 -tagAddr .req r2 - -sub tag,#1 -cmp tag,#8 -movhi tag,#0 -movhi pc,lr - -ldr tagList,=tag_core -tagReturn$: -add tagAddr,tagList, tag,lsl #2 -ldr tagAddr,[tagAddr] - -teq tagAddr,#0 -movne r0,tagAddr -movne pc,lr - -ldr tagAddr,[tagList] -teq tagAddr,#0 -movne r0,#0 -movne pc,lr - -mov tagAddr,#0x100 -push {r4} -tagIndex .req r3 -oldAddr .req r4 -tagLoop$: -ldrh tagIndex,[tagAddr,#4] -subs tagIndex,#1 -poplt {r4} -blt tagReturn$ - -add tagIndex,tagList, tagIndex,lsl #2 -ldr oldAddr,[tagIndex] -teq oldAddr,#0 -.unreq oldAddr -streq tagAddr,[tagIndex] - -ldr tagIndex,[tagAddr] -add tagAddr, tagIndex,lsl #2 -b tagLoop$ - -.unreq tag -.unreq tagList -.unreq tagAddr -.unreq tagIndex -``` - -### 5 Hello World - -Now that we have everything we need, we can draw our first string. In 'main.s' delete everything after bl SetGraphicsAddress, and replace it with the following: - -``` -mov r0,#9 -bl FindTag -ldr r1,[r0] -lsl r1,#2 -sub r1,#8 -add r0,#8 -mov r2,#0 -mov r3,#0 -bl DrawString -loop$: -b loop$ -``` - -This code simply uses our FindTag method to find the 9th tag (cmdline) and then calculates its length and passes the command and the length to the DrawString method, and tells it to draw the string at 0,0. Now test this on the Raspberry Pi. You should see a line of text on the screen. If not please see our troubleshooting page. - -Once it works, congratulations you've now got the ability to draw text. But there is still room for improvement. What if we wanted to write out a number, or a section of the memory or manipulate our command line? In [Lesson 9: Screen04][2], we will look at manipulating text and displaying useful numbers and information. - --------------------------------------------------------------------------------- - -via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen03.html - -作者:[Alex Chadwick][a] -选题:[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.cl.cam.ac.uk -[b]: https://github.com/lujun9972 -[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen02.html -[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen04.html diff --git a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 9 Screen04.md b/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 9 Screen04.md deleted file mode 100644 index 1ca2a16609..0000000000 --- a/sources/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 9 Screen04.md +++ /dev/null @@ -1,540 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 9 Screen04) -[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen04.html) -[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) - -Computer Laboratory – Raspberry Pi: Lesson 9 Screen04 -====== - -The Screen04 lesson builds on Screen03, by teaching how to manipulate text. It is assumed you have the code for the [Lesson 8: Screen03][1] operating system as a basis. - -### 1 String Manipulation - -``` -Variadic functions look much less intuitive in assembly code. Nevertheless, they are useful and powerful concepts. -``` - -Being able to draw text is lovely, but unfortunately at the moment you can only draw strings which are already prepared. This is fine for displaying something like the command line, but ideally we would like to be able to display and text we so desire. As per usual, if we put the effort in and make an excellent function that does all the string manipulation we could ever want, we get much easier code later on in return. Once such complicated function in C programming is sprintf. This function generates a string based on a description given as another string and additional arguments. What is interesting about this function is that it is variadic. This means that it takes a variable number of parameters. The number of parameters depends on the exact format string, and so cannot be determined in advance. - -The full function has many options, and I list a few here. I've highlighted the ones which we will implement in this tutorial, though you can try to implement more. - -The function works by reading the format string, and then interpreting it using the table below. Once an argument is used, it is not considered again. The return value of the function is the number of characters written. If the method fails, a negative number is returned. - -Table 1.1 sprintf formatting rules -| Sequence | Meaning | -| ---------------------- | ---------------------- | -| Any character except % | Copies the character to the output. | -| %% | Writes a % character to the output. | -| %c | Writes the next argument as a character. | -| %d or %i | Writes the next argument as a base 10 signed integer. | -| %e | Writes the next argument in scientific notation using eN to mean ×10N. | -| %E | Writes the next argument in scientific notation using EN to mean ×10N. | -| %f | Writes the next argument as a decimal IEEE 754 floating point number. | -| %g | Same as the shorter of %e and %f. | -| %G | Same as the shorter of %E and %f. | -| %o | Writes the next argument as a base 8 unsigned integer. | -| %s | Writes the next argument as if it were a pointer to a null terminated string. | -| %u | Writes the next argument as a base 10 unsigned integer. | -| %x | Writes the next argument as a base 16 unsigned integer, with lowercase a,b,c,d,e and f. | -| %X | Writes the next argument as a base 16 unsigned integer, with uppercase A,B,C,D,E and F. | -| %p | Writes the next argument as a pointer address. | -| %n | Writes nothing. Copies instead the number of characters written so far to the location addressed by the next argument. | - -Further to the above, many additional tweaks exist to the sequences, such as specifying minimum length, signs, etc. More information can be found at [sprintf - C++ Reference][2]. - -Here are a few examples of calls to the method and their results to illustrate its use. - -Table 1.2 sprintf example calls -| Format String | Arguments | Result | -| "%d" | 13 | "13" | -| "+%d degrees" | 12 | "+12 degrees" | -| "+%x degrees" | 24 | "+1c degrees" | -| "'%c' = 0%o" | 65, 65 | "'A' = 0101" | -| "%d * %d%% = %d" | 200, 40, 80 | "200 * 40% = 80" | -| "+%d degrees" | -5 | "+-5 degrees" | -| "+%u degrees" | -5 | "+4294967291 degrees" | - -Hopefully you can already begin to see the usefulness of the function. It does take a fair amount of work to program, but our reward is a very general function we can use for all sorts of purposes. - -### 2 Division - -``` -Division is the slowest and most complicated of the basic mathematical operators. It is not implemented directly in ARM assembly code because it takes so long to deduce the answer, and so isn't a 'simple' operation. -``` - -While this function does look very powerful, it also looks very complicated. The easiest way to deal with its many cases is probably to write functions to deal with some common tasks it has. What would be useful would be a function to generate the string for a signed and an unsigned number in any base. So, how can we go about doing that? Try to devise an algorithm quickly before reading on. - -The easiest way is probably the exact way I mentioned in [Lesson 1: OK01][3], which is the division remainder method. The idea is the following: - - 1. Divide the current value by the base you're working in. - 2. Store the remainder. - 3. If the new value is not 0, go to 1. - 4. Reverse the order of the remainders. This is the answer. - - - -For example: - -Table 2.1 Example base 2 -conversion -| Value | New Value | Remainder | -| ----- | --------- | --------- | -| 137 | 68 | 1 | -| 68 | 34 | 0 | -| 34 | 17 | 0 | -| 17 | 8 | 1 | -| 8 | 4 | 0 | -| 4 | 2 | 0 | -| 2 | 1 | 0 | -| 1 | 0 | 1 | - -So the answer is 100010012 - -The unfortunate part about this procedure is that it unavoidably uses division. Therefore, we must first contemplate division in binary. - -For a refresher on long division expand the box below. - -``` -Let's suppose we wish to divide 4135 by 17. - - 0243 r 4 -17)4135 - 0 0 × 17 = 0000 - 4135 4135 - 0 = 4135 - 34 200 × 17 = 3400 - 735 4135 - 3400 = 735 - 68 40 × 17 = 680 - 55 735 - 680 = 55 - 51 3 × 17 = 51 - 4 55 - 51 = 4 - Answer: 243 remainder 4 - -First of all we would look at the top digit of the dividend. We see that the smallest multiple of the divisor which is less or equal to it is 0. We output a 0 to the result. - -Next we look at the second to top digit of the dividend and all higher digits. We see the smallest multiple of the divisor which is less than or equal is 34. We output a 2 and subtract 3400. - -Next we look at the third digit of the dividend and all higher digits. The smallest multiple of the divisor that is less than or equal to this is 68. We output 4 and subtract 680. - -Finally we look at all remaining digits. We see that the lowest multiple of the divisor that is less than the remaining digits is 51. We output a 3, subtract 51. The result of the subtraction is our remainder. -``` - -To implement division in assembly code, we will implement binary long division. We do this because the numbers are stored in binary, which gives us easy access to the all important bit shift operations, and because division in binary is simpler than in any higher base due to the much lower number of cases. - -``` - 1011 r 1 -1010)1101111 - 1010 - 11111 - 1010 - 1011 - 1010 - 1 -This example shows how binary long division works. You simply shift the divisor as far right as possible without exceeding the dividend, output a 1 according to the poisition and subtract the number. Whatever remains is the remainder. In this case we show 11011112 ÷ 10102 = 10112 remainder 12. In decimal, 111 ÷ 10 = 11 remainder 1. -``` - - -Try to implement long division yourself now. You should write a function, DivideU32 which divides r0 by r1, returning the result in r0, and the remainder in r1. Below, we will go through a very efficient implementation. - -``` -function DivideU32(r0 is dividend, r1 is divisor) - set shift to 31 - set result to 0 - while shift ≥ 0 - if dividend ≥ (divisor << shift) then - set dividend to dividend - (divisor << shift) - set result to result + 1 - end if - set result to result << 1 - set shift to shift - 1 - loop - return (result, dividend) -end function -``` - -This code does achieve what we need, but would not work as assembly code. Our problem comes from the fact that our registers only hold 32 bits, and so the result of divisor << shift may not fit in a register (we call this overflow). This is a real problem. Did your solution have overflow? - -Fortunately, an instruction exists called clz or count leading zeros, which counts the number of zeros in the binary representation of a number starting at the top bit. Conveniently, this is exactly the number of times we can shift the register left before overflow occurs. Another optimisation you may spot is that we compute divisor << shift twice each loop. We could improve upon this by shifting the divisor at the beginning, then shifting it down at the end of each loop to avoid any need to shift it elsewhere. - -Let's have a look at the assembly code to make further improvements. - -``` -.globl DivideU32 -DivideU32: -result .req r0 -remainder .req r1 -shift .req r2 -current .req r3 - -clz shift,r1 -lsl current,r1,shift -mov remainder,r0 -mov result,#0 - -divideU32Loop$: - cmp shift,#0 - blt divideU32Return$ - cmp remainder,current - - addge result,result,#1 - subge remainder,current - sub shift,#1 - lsr current,#1 - lsl result,#1 - b divideU32Loop$ -divideU32Return$: -.unreq current -mov pc,lr - -.unreq result -.unreq remainder -.unreq shift -``` - -``` -clz dest,src stores the number of zeros from the top to the first one of register dest to register src -``` - -You may, quite rightly, think that this looks quite efficient. It is pretty good, but division is a very expensive operation, and one we may wish to do quite often, so it would be good if we could improve the speed in any way. When looking to optimise code with a loop in it, it is always important to consider how many times the loop must run. In this case, the loop will run a maximum of 31 times for an input of 1. Without making special cases, this could often be improved easily. For example when dividing 1 by 1, no shift is required, yet we shift the divisor to each of the positions above it. This could be improved by simply using the new clz command on the dividend and subtracting this from the shift. In the case of 1 ÷ 1, this means shift would be set to 0, rightly indicating no shift is required. If this causes the shift to be negative, the divisor is bigger than the dividend and so we know the result is 0 remainder the dividend. Another quick check we could make is if the current value is ever 0, then we have a perfect division and can stop looping. - -``` -.globl DivideU32 -DivideU32: -result .req r0 -remainder .req r1 -shift .req r2 -current .req r3 - -clz shift,r1 -clz r3,r0 -subs shift,r3 -lsl current,r1,shift -mov remainder,r0 -mov result,#0 -blt divideU32Return$ - -divideU32Loop$: - cmp remainder,current - blt divideU32LoopContinue$ - - add result,result,#1 - subs remainder,current - lsleq result,shift - beq divideU32Return$ -divideU32LoopContinue$: - subs shift,#1 - lsrge current,#1 - lslge result,#1 - bge divideU32Loop$ - -divideU32Return$: -.unreq current -mov pc,lr - -.unreq result -.unreq remainder -.unreq shift -``` - -Copy the code above to a file called 'maths.s'. - -### 3 Number Strings - -Now that we can do division, let's have another look at implementing number to string conversion. The following is pseudo code to convert numbers from registers into strings in up to base 36. By convention, a % b means the remainder of dividing a by b. - -``` -function SignedString(r0 is value, r1 is dest, r2 is base) - if value ≥ 0 - then return UnsignedString(value, dest, base) - otherwise - if dest > 0 then - setByte(dest, '-') - set dest to dest + 1 - end if - return UnsignedString(-value, dest, base) + 1 - end if -end function - -function UnsignedString(r0 is value, r1 is dest, r2 is base) - set length to 0 - do - - set (value, rem) to DivideU32(value, base) - if rem > 10 - then set rem to rem + '0' - otherwise set rem to rem - 10 + 'a' - if dest > 0 - then setByte(dest + length, rem) - set length to length + 1 - - while value > 0 - if dest > 0 - then ReverseString(dest, length) - return length -end function - -function ReverseString(r0 is string, r1 is length) - set end to string + length - 1 - while end > start - set temp1 to readByte(start) - set temp2 to readByte(end) - setByte(start, temp2) - setByte(end, temp1) - set start to start + 1 - set end to end - 1 - end while -end function -``` - -In a file called 'text.s' implement the above. Remember that if you get stuck, a full solution can be found on the downloads page. - -### 4 Format Strings - -Let's get back to our string formatting method. Since we're programming our own operating system, we can add or change formatting rules as we please. We may find it useful to add a %b operation that outputs a number in binary, and if you're not using null terminated strings, you may wish to alter the behaviour of %s to take the length of the string from another argument, or from a length prefix if you wish. I will use a null terminator in the example below. - -One of the main obstacles to implementing this function is that the number of arguments varies. According to the ABI, additional arguments are pushed onto the stack before calling the method in reverse order. So, for example, if we wish to call our method with 8 parameters; 1,2,3,4,5,6,7 and 8, we would do the following: - - 1. Set r0 = 5, r1 = 6, r2 = 7, r3 = 8 - 2. Push {r0,r1,r2,r3} - 3. Set r0 = 1, r1 = 2, r2 = 3, r3 = 4 - 4. Call the function - 5. Add sp,#4*4 - - - -Now we must decide what arguments our function actually needs. In my case, I used the format string address in r0, the length of the format string in r1, the destination string address in r2, followed by the list of arguments required, starting in r3 and continuing on the stack as above. If you wish to use a null terminated format string, the parameter in r1 can be removed. If you wish to have a maximum buffer length, you could store this in r3. As an additional modification, I think it is useful to alter the function so that if the destination string address is 0, no string is outputted, but an accurate length is still returned, so that the length of a formatted string can be accurately determined. - -If you wish to attempt the implementation on your own, try it now. If not, I will first construct the pseudo code for the method, then give the assembly code implementation. - -``` -function StringFormat(r0 is format, r1 is formatLength, r2 is dest, ...) - set index to 0 - set length to 0 - while index < formatLength - if readByte(format + index) = '%' then - set index to index + 1 - if readByte(format + index) = '%' then - if dest > 0 - then setByte(dest + length, '%') - set length to length + 1 - otherwise if readByte(format + index) = 'c' then - if dest > 0 - then setByte(dest + length, nextArg) - set length to length + 1 - otherwise if readByte(format + index) = 'd' or 'i' then - set length to length + SignedString(nextArg, dest, 10) - otherwise if readByte(format + index) = 'o' then - set length to length + UnsignedString(nextArg, dest, 8) - otherwise if readByte(format + index) = 'u' then - set length to length + UnsignedString(nextArg, dest, 10) - otherwise if readByte(format + index) = 'b' then - set length to length + UnsignedString(nextArg, dest, 2) - otherwise if readByte(format + index) = 'x' then - set length to length + UnsignedString(nextArg, dest, 16) - otherwise if readByte(format + index) = 's' then - set str to nextArg - while getByte(str) != '\0' - if dest > 0 - then setByte(dest + length, getByte(str)) - set length to length + 1 - set str to str + 1 - loop - otherwise if readByte(format + index) = 'n' then - setWord(nextArg, length) - end if - otherwise - if dest > 0 - then setByte(dest + length, readByte(format + index)) - set length to length + 1 - end if - set index to index + 1 - loop - return length -end function -``` - -Although this function is massive, it is quite straightforward. Most of the code goes into checking all the various conditions, the code for each one is simple. Further, all the various unsigned integer cases are the same but for the base, and so can be summarised in assembly. This is given below. - -``` -.globl FormatString -FormatString: -format .req r4 -formatLength .req r5 -dest .req r6 -nextArg .req r7 -argList .req r8 -length .req r9 - -push {r4,r5,r6,r7,r8,r9,lr} -mov format,r0 -mov formatLength,r1 -mov dest,r2 -mov nextArg,r3 -add argList,sp,#7*4 -mov length,#0 - -formatLoop$: - subs formatLength,#1 - movlt r0,length - poplt {r4,r5,r6,r7,r8,r9,pc} - - ldrb r0,[format] - add format,#1 - teq r0,#'%' - beq formatArg$ - -formatChar$: - teq dest,#0 - strneb r0,[dest] - addne dest,#1 - add length,#1 - b formatLoop$ - -formatArg$: - subs formatLength,#1 - movlt r0,length - poplt {r4,r5,r6,r7,r8,r9,pc} - - ldrb r0,[format] - add format,#1 - teq r0,#'%' - beq formatChar$ - - teq r0,#'c' - moveq r0,nextArg - ldreq nextArg,[argList] - addeq argList,#4 - beq formatChar$ - - teq r0,#'s' - beq formatString$ - - teq r0,#'d' - beq formatSigned$ - - teq r0,#'u' - teqne r0,#'x' - teqne r0,#'b' - teqne r0,#'o' - beq formatUnsigned$ - - b formatLoop$ - -formatString$: - ldrb r0,[nextArg] - teq r0,#0x0 - ldreq nextArg,[argList] - addeq argList,#4 - beq formatLoop$ - add length,#1 - teq dest,#0 - strneb r0,[dest] - addne dest,#1 - add nextArg,#1 - b formatString$ - -formatSigned$: - mov r0,nextArg - ldr nextArg,[argList] - add argList,#4 - mov r1,dest - mov r2,#10 - bl SignedString - teq dest,#0 - addne dest,r0 - add length,r0 - b formatLoop$ - -formatUnsigned$: - teq r0,#'u' - moveq r2,#10 - teq r0,#'x' - moveq r2,#16 - teq r0,#'b' - moveq r2,#2 - teq r0,#'o' - moveq r2,#8 - - mov r0,nextArg - ldr nextArg,[argList] - add argList,#4 - mov r1,dest - bl UnsignedString - teq dest,#0 - addne dest,r0 - add length,r0 - b formatLoop$ -``` - -### 5 Convert OS - -Feel free to try using this method however you wish. As an example, here is the code to generate a conversion chart from base 10 to binary to hexadecimal to octal and to ASCII. - -Delete all code after bl SetGraphicsAddress in 'main.s' and replace it with the following: - -``` -mov r4,#0 -loop$: -ldr r0,=format -mov r1,#formatEnd-format -ldr r2,=formatEnd -lsr r3,r4,#4 -push {r3} -push {r3} -push {r3} -push {r3} -bl FormatString -add sp,#16 - -mov r1,r0 -ldr r0,=formatEnd -mov r2,#0 -mov r3,r4 - -cmp r3,#768-16 -subhi r3,#768 -addhi r2,#256 -cmp r3,#768-16 -subhi r3,#768 -addhi r2,#256 -cmp r3,#768-16 -subhi r3,#768 -addhi r2,#256 - -bl DrawString - -add r4,#16 -b loop$ - -.section .data -format: -.ascii "%d=0b%b=0x%x=0%o='%c'" -formatEnd: -``` - -Can you work out what will happen before testing? Particularly what happens for r3 ≥ 128? Try it on the Raspberry Pi to see if you're right. If it doesn't work, please see our troubleshooting page. - -When it does work, congratulations, you've completed the Screen04 tutorial, and reached the end of the screen series! We've learned about pixels and frame buffers, and how these apply to the Raspberry Pi. We've learned how to draw simple lines, and also how to draw characters, as well as the invaluable skill of formatting numbers into text. We now have all that you would need to make graphical output on an Operating System. Can you make some more drawing methods? What about 3D graphics? Can you implement a 24bit frame buffer? What about reading the size of the framebuffer in from the command line? - -The next series is the [Input][4] series, which teaches how to use the keyboard and mouse to really get towards a traditional console computer. - --------------------------------------------------------------------------------- - -via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen04.html - -作者:[Alex Chadwick][a] -选题:[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.cl.cam.ac.uk -[b]: https://github.com/lujun9972 -[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/screen03.html -[2]: http://www.cplusplus.com/reference/clibrary/cstdio/sprintf/ -[3]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok01.html -[4]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input01.html diff --git a/sources/tech/20160922 Annoying Experiences Every Linux Gamer Never Wanted.md b/sources/tech/20160922 Annoying Experiences Every Linux Gamer Never Wanted.md deleted file mode 100644 index 8362f15d9b..0000000000 --- a/sources/tech/20160922 Annoying Experiences Every Linux Gamer Never Wanted.md +++ /dev/null @@ -1,159 +0,0 @@ -Annoying Experiences Every Linux Gamer Never Wanted! -============================================================ - - - [![Linux gamer's problem](https://itsfoss.com/wp-content/uploads/2016/09/Linux-Gaming-Problems.jpg)][10] - -[Gaming on Linux][12] has come a long way. There are dedicated [Linux gaming distributions][13] now. But this doesn’t mean that gaming experience on Linux is as smooth as on Windows. - -What are the obstacles that should be thought about to ensure that we enjoy games as much as Windows users do? - -[Wine][14], [PlayOnLinux][15] and other similar tools are not always able to play every popular Windows game. In this article, I would like to discuss various factors that must be dealt with in order to have the best possible Linux gaming experience. - -### #1 SteamOS is Open Source, Steam for Linux is NOT - -As stated on the [SteamOS page][16], even though SteamOS is open source, Steam for Linux continues to be proprietary. Had it also been open source, the amount of support from the open source community would have been tremendous! Since it is not, [the birth of Project Ascension was inevitable][17]: - -[video](https://youtu.be/07UiS5iAknA) - -Project Ascension is an open source game launcher designed to launch games that have been bought and downloaded from anywhere – they can be Steam games, [Origin games][18], Uplay games, games downloaded directly from game developer websites or from DVD/CD-ROMs. - -Here is how it all began: [Sharing The Idea][19] resulted in a very interesting discussion with readers all over from the gaming community pitching in their own opinions and suggestions. - -### #2 Performance compared to Windows - -Getting Windows games to run on Linux is not always an easy task. But thanks to a feature called [CSMT][20] (command stream multi-threading), PlayOnLinux is now better equipped to deal with these performance issues, though it’s still a long way to achieve Windows level outcomes. - -Native Linux support for games has not been so good for past releases. - -Last year, it was reported that SteamOS performed [significantly worse][21] than Windows. Tomb Raider was released on SteamOS/Steam for Linux last year. However, benchmark results were [not at par][22] with performance on Windows. - -[video](https://youtu.be/nkWUBRacBNE) - -This was much obviously due to the fact that the game had been developed with [DirectX][23] in mind and not [OpenGL][24]. - -Tomb Raider is the [first Linux game that uses TressFX][25]. This video includes TressFX comparisons: - -[video](https://youtu.be/-IeY5ZS-LlA) - -Here is another interesting comparison which shows Wine+CSMT performing much better than the native Linux version itself on Steam! This is the power of Open Source! - -[Suggested readA New Linux OS "OSu" Vying To Be Ubuntu Of Arch Linux World][26] - -[video](https://youtu.be/sCJkC6oJ08A) - -TressFX has been turned off in this case to avoid FPS loss. - -Here is another Linux vs Windows comparison for the recently released “[Life is Strange][27]” on Linux: - -[video](https://youtu.be/Vlflu-pIgIY) - -It’s good to know that  [_Steam for Linux_][28]  has begun to show better improvements in performance for this new Linux game. - -Before launching any game for Linux, developers should consider optimizing them especially if it’s a DirectX game and requires OpenGL translation. We really do hope that [Deus Ex: Mankind Divided on Linux][29] gets benchmarked well, upon release. As its a DirectX game, we hope it’s being ported well for Linux. Here’s [what the Executive Game Director had to say][30]. - -### #3 Proprietary NVIDIA Drivers - -[AMD’s support for Open Source][31] is definitely commendable when compared to [NVIDIA][32]. Though [AMD][33] driver support is [pretty good on Linux][34] now due to its better open source driver, NVIDIA graphic card owners will still have to use the proprietary NVIDIA drivers because of the limited capabilities of the open-source version of NVIDIA’s graphics driver called Nouveau. - -In the past, legendary Linus Torvalds has also shared his thoughts about Linux support from NVIDIA to be totally unacceptable: - -[video](https://youtu.be/O0r6Pr_mdio) - -You can watch the complete talk [here][35]. Although NVIDIA responded with [a commitment for better linux support][36], the open source graphics driver still continues to be weak as before. - -### #4 Need for Uplay and Origin DRM support on Linux - -[video](https://youtu.be/rc96NFwyxWU) - -The above video describes how to install the [Uplay][37] DRM on Linux. The uploader also suggests that the use of wine as the main tool of games and applications is not recommended on Linux. Rather, preference to native applications should be encouraged instead. - -The following video is a guide about installing the [Origin][38] DRM on Linux: - -[video](https://youtu.be/ga2lNM72-Kw) - -Digital Rights Management Software adds another layer for game execution and hence it adds up to the already challenging task to make a Windows game run well on Linux. So in addition to making the game execute, W.I.N.E has to take care of running the DRM software such as Uplay or Origin as well. It would have been great if, like Steam, Linux could have got its own native versions of Uplay and Origin. - -[Suggested readLinux Foundation Head Calls 2017 'Year of the Linux Desktop'... While Running Apple's macOS Himself][39] - -### #5 DirectX 11 support for Linux - -Even though we have tools on Linux to run Windows applications, every game comes with its own set of tweak requirements for it to be playable on Linux. Though there was an announcement about [DirectX 11 support for Linux][40] last year via Code Weavers, it’s still a long way to go to make playing newly launched titles on Linux a possibility. Currently, you can - -Currently, you can [buy Crossover from Codeweavers][41] to get the best DirectX 11 support available. This [thread][42] on the Arch Linux forums clearly shows how much more effort is required to make this dream a possibility. Here is an interesting [find][43] from a [Reddit thread][44], which mentions Wine getting [DirectX 11 patches from Codeweavers][45]. Now that’s definitely some good news. - -### #6 100% of Steam games are not available for Linux - -This is an important point to ponder as Linux gamers continue to miss out on every major game release since most of them land up on Windows. Here is a guide to [install Steam for Windows on Linux][46]. - -### #7 Better Support from video game publishers for OpenGL - -Currently, developers and publishers focus primarily on DirectX for video game development rather than OpenGL. Now as Steam is officially here for Linux, developers should start considering development in OpenGL as well. - -[Direct3D][47] is made solely for the Windows platform. The OpenGL API is an open standard, and implementations exist for not only Windows but a wide variety of other platforms. - -Though quite an old article, [this valuable resource][48] shares a lot of thoughtful information on the realities of OpenGL and DirectX. The points made are truly very sensible and enlightens the reader about the facts based on actual chronological events. - -Publishers who are launching their titles on Linux should definitely not leave out the fact that developing the game on OpenGL would be a much better deal than translating it from DirectX to OpenGL. If conversion has to be done, the translations must be well optimized and carefully looked into. There might be a delay in releasing the games but still it would definitely be worth the wait. - -Have more annoyances to share? Do let us know in the comments. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/linux-gaming-problems/ - -作者:[Avimanyu Bandyopadhyay ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://itsfoss.com/author/avimanyu/ -[1]:https://itsfoss.com/author/avimanyu/ -[2]:https://itsfoss.com/linux-gaming-problems/#comments -[3]:https://www.facebook.com/share.php?u=https%3A%2F%2Fitsfoss.com%2Flinux-gaming-problems%2F%3Futm_source%3Dfacebook%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare -[4]:https://twitter.com/share?original_referer=/&text=Annoying+Experiences+Every+Linux+Gamer+Never+Wanted%21&url=https://itsfoss.com/linux-gaming-problems/%3Futm_source%3Dtwitter%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare&via=itsfoss2 -[5]:https://plus.google.com/share?url=https%3A%2F%2Fitsfoss.com%2Flinux-gaming-problems%2F%3Futm_source%3DgooglePlus%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare -[6]:https://www.linkedin.com/cws/share?url=https%3A%2F%2Fitsfoss.com%2Flinux-gaming-problems%2F%3Futm_source%3DlinkedIn%26utm_medium%3Dsocial%26utm_campaign%3DSocialWarfare -[7]:http://www.stumbleupon.com/submit?url=https://itsfoss.com/linux-gaming-problems/&title=Annoying+Experiences+Every+Linux+Gamer+Never+Wanted%21 -[8]:https://www.reddit.com/submit?url=https://itsfoss.com/linux-gaming-problems/&title=Annoying+Experiences+Every+Linux+Gamer+Never+Wanted%21 -[9]:https://itsfoss.com/wp-content/uploads/2016/09/Linux-Gaming-Problems.jpg -[10]:https://itsfoss.com/wp-content/uploads/2016/09/Linux-Gaming-Problems.jpg -[11]:http://pinterest.com/pin/create/bookmarklet/?media=https://itsfoss.com/wp-content/uploads/2016/09/Linux-Gaming-Problems.jpg&url=https://itsfoss.com/linux-gaming-problems/&is_video=false&description=Linux%20gamer%27s%20problem -[12]:https://itsfoss.com/linux-gaming-guide/ -[13]:https://itsfoss.com/linux-gaming-distributions/ -[14]:https://itsfoss.com/use-windows-applications-linux/ -[15]:https://www.playonlinux.com/en/ -[16]:http://store.steampowered.com/steamos/ -[17]:http://www.ibtimes.co.uk/reddit-users-want-replace-steam-open-source-game-launcher-project-ascension-1498999 -[18]:https://www.origin.com/ -[19]:https://www.reddit.com/r/pcmasterrace/comments/33xcvm/we_hate_valves_monopoly_over_pc_gaming_why/ -[20]:https://github.com/wine-compholio/wine-staging/wiki/CSMT -[21]:http://arstechnica.com/gaming/2015/11/ars-benchmarks-show-significant-performance-hit-for-steamos-gaming/ -[22]:https://www.gamingonlinux.com/articles/tomb-raider-benchmark-video-comparison-linux-vs-windows-10.7138 -[23]:https://en.wikipedia.org/wiki/DirectX -[24]:https://en.wikipedia.org/wiki/OpenGL -[25]:https://www.gamingonlinux.com/articles/tomb-raider-released-for-linux-video-thoughts-port-report-included-the-first-linux-game-to-use-tresfx.7124 -[26]:https://itsfoss.com/osu-new-linux/ -[27]:http://lifeisstrange.com/ -[28]:https://itsfoss.com/install-steam-ubuntu-linux/ -[29]:https://itsfoss.com/deus-ex-mankind-divided-linux/ -[30]:http://wccftech.com/deus-ex-mankind-divided-director-console-ports-on-pc-is-disrespectful/ -[31]:http://developer.amd.com/tools-and-sdks/open-source/ -[32]:http://nvidia.com/ -[33]:http://amd.com/ -[34]:http://www.makeuseof.com/tag/open-source-amd-graphics-now-awesome-heres-get/ -[35]:https://youtu.be/MShbP3OpASA -[36]:https://itsfoss.com/nvidia-optimus-support-linux/ -[37]:http://uplay.com/ -[38]:http://origin.com/ -[39]:https://itsfoss.com/linux-foundation-head-uses-macos/ -[40]:http://www.pcworld.com/article/2940470/hey-gamers-directx-11-is-coming-to-linux-thanks-to-codeweavers-and-wine.html -[41]:https://itsfoss.com/deal-run-windows-software-and-games-on-linux-with-crossover-15-66-off/ -[42]:https://bbs.archlinux.org/viewtopic.php?id=214771 -[43]:https://ghostbin.com/paste/sy3e2 -[44]:https://www.reddit.com/r/linux_gaming/comments/3ap3uu/directx_11_support_coming_to_codeweavers/ -[45]:https://www.codeweavers.com/about/blogs/caron/2015/12/10/directx-11-really-james-didnt-lie -[46]:https://itsfoss.com/linux-gaming-guide/ -[47]:https://en.wikipedia.org/wiki/Direct3D -[48]:http://blog.wolfire.com/2010/01/Why-you-should-use-OpenGL-and-not-DirectX diff --git a/sources/tech/20171010 In Device We Trust Measure Twice Compute Once with Xen Linux TPM 2.0 and TXT.md b/sources/tech/20171010 In Device We Trust Measure Twice Compute Once with Xen Linux TPM 2.0 and TXT.md index 20c14074c6..3c61f6dd8f 100644 --- a/sources/tech/20171010 In Device We Trust Measure Twice Compute Once with Xen Linux TPM 2.0 and TXT.md +++ b/sources/tech/20171010 In Device We Trust Measure Twice Compute Once with Xen Linux TPM 2.0 and TXT.md @@ -1,3 +1,6 @@ +ezio is translating + + In Device We Trust: Measure Twice, Compute Once with Xen, Linux, TPM 2.0 and TXT ============================================================ diff --git a/sources/tech/20171212 Toplip – A Very Strong File Encryption And Decryption CLI Utility.md b/sources/tech/20171212 Toplip – A Very Strong File Encryption And Decryption CLI Utility.md index ad3528f60b..883834d7e7 100644 --- a/sources/tech/20171212 Toplip – A Very Strong File Encryption And Decryption CLI Utility.md +++ b/sources/tech/20171212 Toplip – A Very Strong File Encryption And Decryption CLI Utility.md @@ -1,3 +1,4 @@ +tomjlw is translatting Toplip – A Very Strong File Encryption And Decryption CLI Utility ====== There are numerous file encryption tools available on the market to protect @@ -260,7 +261,7 @@ Cheers! via: https://www.ostechnix.com/toplip-strong-file-encryption-decryption-cli-utility/ 作者:[SK][a] -译者:[译者ID](https://github.com/译者ID) +译者:[tomjlw](https://github.com/tomjlw) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20171215 Top 5 Linux Music Players.md b/sources/tech/20171215 Top 5 Linux Music Players.md deleted file mode 100644 index a57ad29c52..0000000000 --- a/sources/tech/20171215 Top 5 Linux Music Players.md +++ /dev/null @@ -1,145 +0,0 @@ -tomjlw is translating -Top 5 Linux Music Players -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/live-music.jpg?itok=Ejbo4rf7_) ->Jack Wallen rounds up his five favorite Linux music players. Creative Commons Zero ->Pixabay - -No matter what you do, chances are you enjoy a bit of music playing in the background. Whether you're a coder, system administrator, or typical desktop user, enjoying good music might be at the top of your list of things you do on the desktop. And, with the holidays upon us, you might wind up with some gift cards that allow you to purchase some new music. If your music format of choice is of a digital nature (mine happens to be vinyl) and your platform is Linux, you're going to want a good GUI player to enjoy that music. - -Fortunately, Linux has no lack of digital music players. In fact, there are quite a few, most of which are open source and available for free. Let's take a look at a few such players, to see which one might suit your needs. - -### Clementine - -I wanted to start out with the player that has served as my default for years. [Clementine][1] offers probably the single best ratio of ease-of-use to flexibility you'll find in any player. Clementine is a fork of the new defunct [Amarok][2] music player, but isn't limited to Linux-only; Clementine is also available for Mac OS and Windows platforms. The feature set is seriously impressive and includes the likes of: - - * Built-in equalizer - - * Customizable interface (display current album cover as background -- Figure 1) - - * Play local music or from Spotify, Last.fm, and more - - * Sidebar for easy library navigation - - * Built-in audio transcoding (into MP3, OGG, Flac, and more) - - * Remote control using [Android app][3] - - * Handy search function - - * Tabbed playlists - - * Easy creation of regular and smart playlists - - * CUE sheet support - - * Tag support - - - - -![Clementine][5] - - -Figure 1: The Clementine interface might be a bit old-school, but it's incredibly user-friendly and flexible. - -[Used with permission][6] - -Of all the music players I have used, Clementine is by far the most feature-rich and easy to use. It also includes one of the finest equalizers you'll find on a Linux music player (with 10 bands to adjust). Although it may not enjoy a very modern interface, it is absolutely unmatched for its ability to create and manipulate playlists. If your music collection is large, and you want total control over it, this is the player you want. - -Clementine can be found in the standard repositories and installed from either your distribution's software center or the command line. - -### Rhythmbox - -[Rhythmbox][7] is the default player for the GNOME desktop, but it does function well on other desktops. The Rhythmbox interface is slightly more modern than Clementine and takes a minimal approach to design. That doesn't mean the app is bereft of features. Quite the opposite. Rhythmbox offers gapless playback, Soundcloud support, album cover display, audio scrobbling from Last.fm and Libre.fm, Jamendo support, podcast subscription (from [Apple iTunes][8]), web remote control, and more. - -One very nice feature found in Rhythmbox is plugin support, which allows you to enable features like DAAP Music Sharing, FM Radio, Cover art search, notifications, ReplayGain, Song Lyrics, and more. - -The Rhythmbox playlist feature isn't quite as powerful as that found in Clementine, but it still makes it fairly easy to organize your music into quick playlists for any mood. Although Rhythmbox does offer a slightly more modern interface than Clementine (Figure 2), it's not quite as flexible. - -![Rhythmbox][10] - - -Figure 2: The Rhythmbox interface is simple and straightforward. - -[Used with permission][6] - -### VLC Media Player - -For some, [VLC][11] cannot be beat for playing videos. However, VLC isn't limited to the playback of video. In fact, VLC does a great job of playing audio files. For [KDE Neon][12] users, VLC serves as your default for both music and video playback. Although VLC is one of the finest video players on the Linux market (it's my default), it does suffer from some minor limitations with audio--namely the lack of playlists and the inability to connect to remote directories on your network. But if you're looking for an incredibly simple and reliable means to play local files or network mms/rtsp streams VLC is a quality tool. - -VLC does include an equalizer (Figure 3), a compressor, and a spatializer as well as the ability to record from a capture device. - -![VLC][14] - - -Figure 3: The VLC equalizer in action. - -[Used with permission][6] - -### Audacious - -If you're looking for a lightweight music player, Audacious perfectly fits that bill. This particular music player is fairly single minded, but it does include an equalizer and a small selection of effects that will please many an audiophile (e.g., Echo, Silence removal, Speed and Pitch, Voice Removal, and more--Figure 4). - -![Audacious ][16] - - -Figure 4: The Audacious EQ and plugins. - -[Used with permission][6] - -Audacious also includes a really handy alarm feature, that allows you to set an alarm that will start playing your currently selected track at a user-specified time and duration. - -### Spotify - -I must confess, I use spotify daily. I'm a subscriber and use it to find new music to purchase--which means I am constantly searching and discovering. Fortunately, there is a desktop client for Spotify (Figure 5) that can be easily installed using the [official Spotify Linux installation instructions][17]. Outside of listening to vinyl, I probably make use of Spotify more than any other music player. It also helps that I can seamlessly jump between the desktop client and the [Android app][18], so I never miss out on the music I enjoy. - -![Spotify][20] - - -Figure 5: The official Spotify client on Linux. - -[Used with permission][6] - -The Spotify interface is very easy to use and, in fact, it beats the web player by leaps and bounds. Do not settle for the [Spotify Web Player][21] on Linux, as the desktop client makes it much easier to create and manage your playlists. If you're a Spotify power user, don't even bother with the built-in support for the streaming client in the other desktop apps--once you've used the Spotify Desktop Client, the other apps pale in comparison. - -### The choice is yours - -Other options are available (check your desktop software center), but these five clients (in my opinion) are the best of the best. For me, the one-two punch of Clementine and Spotify gives me the best of all possible worlds. Try them out and see which one best meets your needs. - -Learn more about Linux through the free ["Introduction to Linux" ][22]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/learn/intro-to-linux/2017/12/top-5-linux-music-players - -作者:[][a] -译者:[tomjlw](https://github.com/tomjlw) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.linux.com -[1]:https://www.clementine-player.org/ -[2]:https://en.wikipedia.org/wiki/Amarok_(software) -[3]:https://play.google.com/store/apps/details?id=de.qspool.clementineremote -[4]:https://www.linux.com/files/images/clementinejpg -[5]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/clementine.jpg?itok=_k13MtM3 (Clementine) -[6]:https://www.linux.com/licenses/category/used-permission -[7]:https://wiki.gnome.org/Apps/Rhythmbox -[8]:https://www.apple.com/itunes/ -[9]:https://www.linux.com/files/images/rhythmboxjpg -[10]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/rhythmbox.jpg?itok=GOjs9vTv (Rhythmbox) -[11]:https://www.videolan.org/vlc/index.html -[12]:https://neon.kde.org/ -[13]:https://www.linux.com/files/images/vlcjpg -[14]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/vlc.jpg?itok=hn7iKkmK (VLC) -[15]:https://www.linux.com/files/images/audaciousjpg -[16]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/audacious.jpg?itok=9YALPzOx (Audacious ) -[17]:https://www.spotify.com/us/download/linux/ -[18]:https://play.google.com/store/apps/details?id=com.spotify.music -[19]:https://www.linux.com/files/images/spotifyjpg -[20]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/spotify.jpg?itok=P3FLfcYt (Spotify) -[21]:https://open.spotify.com/browse/featured -[22]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/sources/tech/20180112 8 KDE Plasma Tips and Tricks to Improve Your Productivity.md b/sources/tech/20180112 8 KDE Plasma Tips and Tricks to Improve Your Productivity.md deleted file mode 100644 index 4335a7a98d..0000000000 --- a/sources/tech/20180112 8 KDE Plasma Tips and Tricks to Improve Your Productivity.md +++ /dev/null @@ -1,97 +0,0 @@ -8 KDE Plasma Tips and Tricks to Improve Your Productivity -====== - -[#] leon-shi is translating -![](https://www.maketecheasier.com/assets/uploads/2018/01/kde-plasma-desktop-featured.jpg) - -KDE's Plasma is easily one of the most powerful desktop environments available for Linux. It's highly configurable, and it looks pretty good, too. That doesn't amount to a whole lot unless you can actually get things done. - -You can easily configure Plasma and make use of a lot of its convenient and time-saving features to boost your productivity and have a desktop that empowers you, rather than getting in your way. - -These tips aren't in any particular order, so you don't need to prioritize. Pick the ones that best fit your workflow. - - **Related** : [10 of the Best KDE Plasma Applications You Should Try][1] - -### 1. Multimedia Controls - -This isn't so much of a tip as it is something that's good to keep in mind. Plasma keeps multimedia controls everywhere. You don't need to open your media player every time you need to pause, resume, or skip a song; you can mouse over the minimized window or even control it via the lock screen. There's no need to scramble to log in to change a song or because you forgot to pause one. - -### 2. KRunner - -![KDE Plasma KRunner][2] - -KRunner is an often under-appreciated feature of the Plasma desktop. Most people are used to digging through the application launcher menu to find the program that they're looking to launch. That's not necessary with KRunner. - -To use KRunner, make sure that your focus is on the desktop itself. (Click on it instead of a window.) Then, start typing the name of the program that you want. KRunner will automatically drop down from the top of your screen with suggestions. Click or press Enter on the one you're looking for. It's much faster than remembering which category your program is under. - -### 3. Jump Lists - -![KDE Plasma Jump Lists][3] - -Jump lists are a fairly recent addition to the Plasma desktop. They allow you to launch an application directly to a specific section or feature. - -So if you have a launcher on a menu bar, you can right-click and get a list of places to jump to. Select where you want to go, and you're off. - -### 4. KDE Connect - -![KDE Connect Menu Android][4] - -[KDE Connect][5] is a massive help if you have an Android phone. It connects the phone to your desktop so you can share things seamlessly between the devices. - -With KDE Connect, you can see your [Android device's notification][6] on your desktop in real time. It also enables you to send and receive text messages from Plasma without ever picking up your phone. - -KDE Connect also lets you send files and share web pages between your phone and your computer. You can easily move from one device to the other without a lot of hassle or losing your train of thought. - -### 5. Plasma Vaults - -![KDE Plasma Vault][7] - -Plasma Vaults are another new addition to the Plasma desktop. They are KDE's simple solution to encrypted files and folders. If you don't work with encrypted files, this one won't really save you any time. If you do, though, vaults are a much simpler approach. - -Plasma Vaults let you create encrypted directories as a regular user without root and manage them from your task bar. You can mount and unmount the directories on the fly without the need for external programs or additional privileges. - -### 6. Pager Widget - -![KDE Plasma Pager][8] - -Configure your desktop with the pager widget. It allows you to easily access three additional workspaces for even more screen room. - -Add the widget to your menu bar, and you can slide between multiple workspaces. These are all the size of your screen, so you gain multiple times the total screen space. That lets you lay out more windows without getting confused by a minimized mess or disorganization. - -### 7. Create a Dock - -![KDE Plasma Dock][9] - -Plasma is known for its flexibility and the room it allows for configuration. Use that to your advantage. If you have programs that you're always using, consider setting up an OS X style dock with your most used applications. You'll be able to get them with a single click rather than going through a menu or typing in their name. - -### 8. Add a File Tree to Dolphin - -![Plasma Dolphin Directory][10] - -It's much easier to navigate folders in a directory tree. Dolphin, Plasma's default file manager, has built-in functionality to display a directory listing in the form of a tree on the side of the folder window. - -To enable the directory tree, click on the "Control" tab, then "Configure Dolphin," "View Modes," and "Details." Finally, select "Expandable Folders." - -Remember that these tips are just tips. Don't try to force yourself to do something that's getting in your way. You may hate using file trees in Dolphin. You may never use Pager. That's alright. There may even be something that you personally like that's not listed here. Do what works for you. That said, at least a few of these should shave some serious time out of your work day. - --------------------------------------------------------------------------------- - -via: https://www.maketecheasier.com/kde-plasma-tips-tricks-improve-productivity/ - -作者:[Nick Congleton][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.maketecheasier.com/author/nickcongleton/ -[1]:https://www.maketecheasier.com/10-best-kde-plasma-applications/ (10 of the Best KDE Plasma Applications You Should Try) -[2]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-krunner.jpg (KDE Plasma KRunner) -[3]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-jumplist.jpg (KDE Plasma Jump Lists) -[4]:https://www.maketecheasier.com/assets/uploads/2017/05/kde-connect-menu-e1494899929112.jpg (KDE Connect Menu Android) -[5]:https://www.maketecheasier.com/send-receive-sms-linux-kde-connect/ -[6]:https://www.maketecheasier.com/android-notifications-ubuntu-kde-connect/ -[7]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-vault.jpg (KDE Plasma Vault) -[8]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-pager.jpg (KDE Plasma Pager) -[9]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-dock.jpg (KDE Plasma Dock) -[10]:https://www.maketecheasier.com/assets/uploads/2017/10/pe-dolphin.jpg (Plasma Dolphin Directory) diff --git a/sources/tech/20180122 Ick- a continuous integration system.md b/sources/tech/20180122 Ick- a continuous integration system.md deleted file mode 100644 index 4620e2c036..0000000000 --- a/sources/tech/20180122 Ick- a continuous integration system.md +++ /dev/null @@ -1,75 +0,0 @@ -Ick: a continuous integration system -====== -**TL;DR:** Ick is a continuous integration or CI system. See for more information. - -More verbose version follows. - -### First public version released - -The world may not need yet another continuous integration system (CI), but I do. I've been unsatisfied with the ones I've tried or looked at. More importantly, I am interested in a few things that are more powerful than what I've ever even heard of. So I've started writing my own. - -My new personal hobby project is called ick. It is a CI system, which means it can run automated steps for building and testing software. The home page is at , and the [download][1] page has links to the source code and .deb packages and an Ansible playbook for installing it. - -I have now made the first publicly advertised release, dubbed ALPHA-1, version number 0.23. It is of alpha quality, and that means it doesn't have all the intended features and if any of the features it does have work, you should consider yourself lucky. - -### Invitation to contribute - -Ick has so far been my personal project. I am hoping to make it more than that, and invite contributions. See the [governance][2] page for the constitution, the [getting started][3] page for tips on how to start contributing, and the [contact][4] page for how to get in touch. - -### Architecture - -Ick has an architecture consisting of several components that communicate over HTTPS using RESTful APIs and JSON for structured data. See the [architecture][5] page for details. - -### Manifesto - -Continuous integration (CI) is a powerful tool for software development. It should not be tedious, fragile, or annoying. It should be quick and simple to set up, and work quietly in the background unless there's a problem in the code being built and tested. - -A CI system should be simple, easy, clear, clean, scalable, fast, comprehensible, transparent, reliable, and boost your productivity to get things done. It should not be a lot of effort to set up, require a lot of hardware just for the CI, need frequent attention for it to keep working, and developers should never have to wonder why something isn't working. - -A CI system should be flexible to suit your build and test needs. It should support multiple types of workers, as far as CPU architecture and operating system version are concerned. - -Also, like all software, CI should be fully and completely free software and your instance should be under your control. - -(Ick is little of this yet, but it will try to become all of it. In the best possible taste.) - -### Dreams of the future - -In the long run, I would ick to have features like ones described below. It may take a while to get all of them implemented. - - * A build may be triggered by a variety of events. Time is an obvious event, as is source code repository for the project changing. More powerfully, any build dependency changing, regardless of whether the dependency comes from another project built by ick, or a package from, say, Debian: ick should keep track of all the packages that get installed into the build environment of a project, and if any of their versions change, it should trigger the project build and tests again. - - * Ick should support building in (or against) any reasonable target, including any Linux distribution, any free operating system, and any non-free operating system that isn't brain-dead. - - * Ick should manage the build environment itself, and be able to do builds that are isolated from the build host or the network. This partially works: one can ask ick to build a container and run a build in the container. The container is implemented using systemd-nspawn. This can be improved upon, however. (If you think Docker is the only way to go, please contribute support for that.) - - * Ick should support any workers that it can control over ssh or a serial port or other such neutral communication channel, without having to install an agent of any kind on them. Ick won't assume that it can have, say, a full Java run time, so that the worker can be, say, a micro controller. - - * Ick should be able to effortlessly handle very large numbers of projects. I'm thinking here that it should be able to keep up with building everything in Debian, whenever a new Debian source package is uploaded. (Obviously whether that is feasible depends on whether there are enough resources to actually build things, but ick itself should not be the bottleneck.) - - * Ick should optionally provision workers as needed. If all workers of a certain type are busy, and ick's been configured to allow using more resources, it should do so. This seems like it would be easy to do with virtual machines, containers, cloud providers, etc. - - * Ick should be flexible in how it can notify interested parties, particularly about failures. It should allow an interested party to ask to be notified over IRC, Matrix, Mastodon, Twitter, email, SMS, or even by a phone call and speech syntethiser. "Hello, interested party. It is 04:00 and you wanted to be told when the hello package has been built for RISC-V." - - - - -### Please give feedback - -If you try ick, or even if you've just read this far, please share your thoughts on it. See the [contact][4] page for where to send it. Public feedback is preferred over private, but if you prefer private, that's OK too. - --------------------------------------------------------------------------------- - -via: https://blog.liw.fi/posts/2018/01/22/ick_a_continuous_integration_system/ - -作者:[Lars Wirzenius][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://blog.liw.fi/ -[1]:http://ick.liw.fi/download/ -[2]:http://ick.liw.fi/governance/ -[3]:http://ick.liw.fi/getting-started/ -[4]:http://ick.liw.fi/contact/ -[5]:http://ick.liw.fi/architecture/ diff --git a/sources/tech/20180128 Get started with Org mode without Emacs.md b/sources/tech/20180128 Get started with Org mode without Emacs.md deleted file mode 100644 index 75a5bcb092..0000000000 --- a/sources/tech/20180128 Get started with Org mode without Emacs.md +++ /dev/null @@ -1,78 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Get started with Org mode without Emacs) -[#]: via: (https://opensource.com/article/19/1/productivity-tool-org-mode) -[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) - -Get started with Org mode without Emacs -====== -No, you don't need Emacs to use Org, the 16th in our series on open source tools that will make you more productive in 2019. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh) - -There seems to be a mad rush at the beginning of every year to find ways to be more productive. New Year's resolutions, the itch to start the year off right, and of course, an "out with the old, in with the new" attitude all contribute to this. And the usual round of recommendations is heavily biased towards closed source and proprietary software. It doesn't have to be that way. - -Here's the 16th of my picks for 19 new (or new-to-you) open source tools to help you be more productive in 2019. - -### Org (without Emacs) - -[Org mode][1] (or just Org) is not in the least bit new, but there are still many people who have never used it. They would love to try it out to get a feel for how Org can help them be productive. But the biggest barrier is that Org is associated with Emacs, and many people think one requires the other. Not so! Org can be used with a variety of other tools and editors once you understand the basics. - -![](https://opensource.com/sites/default/files/uploads/org-1.png) - -Org, at its very heart, is a structured text file. It has headers, subheaders, and keywords that allow other tools to parse files into agendas and to-do lists. Org files can be edited with any flat-text editor (e.g., [Vim][2], [Atom][3], or [Visual Studio Code][4]), and many have plugins that help create and manage Org files. - -A basic Org file looks something like this: - -``` -* Task List -** TODO Write Article for Day 16 - Org w/out emacs -   DEADLINE: <2019-01-25 12:00> -*** DONE Write sample org snippet for article -    - Include at least one TODO and one DONE item -    - Show notes -    - Show SCHEDULED and DEADLINE -*** TODO Take Screenshots -** Dentist Appointment -   SCHEDULED: <2019-01-31 13:30-14:30> -``` - -Org uses an outline format that uses ***** as bullets to indicate an item's level. Any item that begins with the word TODO (yes, in all caps) is just that—a to-do item. The work DONE indicates it is completed. SCHEDULED and DEADLINE indicate dates and times relevant to the item. If there's no time in either field, the item is considered an all-day event. - -With the right plugins, your favorite text editor becomes a powerhouse of productivity and organization. For example, the [vim-orgmode][5] plugin's features include functions to create Org files, syntax highlighting, and key commands to generate agendas and comprehensive to-do lists across files. - -![](https://opensource.com/sites/default/files/uploads/org-2.png) - -The Atom [Organized][6] plugin adds a sidebar on the right side of the screen that shows the agenda and to-do items in Org files. It can read from multiple files by default with a path set up in the configuration options. The Todo sidebar allows you to click on a to-do item to mark it done, then automatically updates the source Org file. - -![](https://opensource.com/sites/default/files/uploads/org-3.png) - -There are also a whole host of tools that "speak Org" to help keep you productive. With libraries in Python, Perl, PHP, NodeJS, and more, you can develop your own scripts and tools. And, of course, there is also [Emacs][7], which has Org support within the core distribution. - -![](https://opensource.com/sites/default/files/uploads/org-4.png) - -Org mode is one of the best tools for keeping on track with what needs to be done and when. And, contrary to myth, it doesn't need Emacs, just a text editor. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/productivity-tool-org-mode - -作者:[Kevin Sonney][a] -选题:[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/ksonney (Kevin Sonney) -[b]: https://github.com/lujun9972 -[1]: https://orgmode.org/ -[2]: https://www.vim.org/ -[3]: https://atom.io/ -[4]: https://code.visualstudio.com/ -[5]: https://github.com/jceb/vim-orgmode -[6]: https://atom.io/packages/organized -[7]: https://www.gnu.org/software/emacs/ 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 diff --git a/sources/tech/20180202 Tips for success when getting started with Ansible.md b/sources/tech/20180202 Tips for success when getting started with Ansible.md deleted file mode 100644 index 539db2ac86..0000000000 --- a/sources/tech/20180202 Tips for success when getting started with Ansible.md +++ /dev/null @@ -1,73 +0,0 @@ -Tips for success when getting started with Ansible -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/bus-big-data.png?itok=L34b2exg) - -Ansible is an open source automation tool used to configure servers, install software, and perform a wide variety of IT tasks from one central location. It is a one-to-many agentless mechanism where all instructions are run from a control machine that communicates with remote clients over SSH, although other protocols are also supported. - -While targeted for system administrators with privileged access who routinely perform tasks such as installing and configuring applications, Ansible can also be used by non-privileged users. For example, a database administrator using the `mysql` login ID could use Ansible to create databases, add users, and define access-level controls. - -Let's go over a very simple example where a system administrator provisions 100 servers each day and must run a series of Bash commands on each one before handing it off to users. - -![](https://opensource.com/sites/default/files/u128651/mapping-bash-commands-to-ansible.png) - -This is a simple example, but should illustrate how easily commands can be specified in yaml files and executed on remote servers. In a heterogeneous environment, conditional statements can be added so that certain commands are only executed in certain servers (e.g., "only execute `yum` commands in systems that are not Ubuntu or Debian"). - -One important feature in Ansible is that a playbook describes a desired state in a computer system, so a playbook can be run multiple times against a server without impacting its state. If a certain task has already been implemented (e.g., "user `sysman` already exists"), then Ansible simply ignores it and moves on. - -### Definitions - - * **Tasks:**``A task is the smallest unit of work. It can be an action like "Install a database," "Install a web server," "Create a firewall rule," or "Copy this configuration file to that server." - * **Plays:**``A play is made up of tasks. For example, the play: "Prepare a database to be used by a web server" is made up of tasks: 1) Install the database package; 2) Set a password for the database administrator; 3) Create a database; and 4) Set access to the database. - * **Playbook:**``A playbook is made up of plays. A playbook could be: "Prepare my website with a database backend," and the plays would be 1) Set up the database server; and 2) Set up the web server. - * **Roles:**``Roles are used to save and organize playbooks and allow sharing and reuse of playbooks. Following the previous examples, if you need to fully configure a web server, you can use a role that others have written and shared to do just that. Since roles are highly configurable (if written correctly), they can be easily reused to suit any given deployment requirements. - * **Ansible Galaxy:**``Ansible [Galaxy][1] is an online repository where roles are uploaded so they can be shared with others. It is integrated with GitHub, so roles can be organized into Git repositories and then shared via Ansible Galaxy. - - - -These definitions and their relationships are depicted here: - -![](https://opensource.com/sites/default/files/u128651/ansible-definitions.png) - -Please note this is just one way to organize the tasks that need to be executed. We could have split up the installation of the database and the web server into separate playbooks and into different roles. Most roles in Ansible Galaxy install and configure individual applications. You can see examples for installing [mysql][2] and installing [httpd][3]. - -### Tips for writing playbooks - -The best source for learning Ansible is the official [documentation][4] site. And, as usual, online search is your friend. I recommend starting with simple tasks, like installing applications or creating users. Once you are ready, follow these guidelines: - - * When testing, use a small subset of servers so that your plays execute faster. If they are successful in one server, they will be successful in others. - * Always do a dry run to make sure all commands are working (run with `--check-mode` flag). - * Test as often as you need to without fear of breaking things. Tasks describe a desired state, so if a desired state is already achieved, it will simply be ignored. - * Be sure all host names defined in `/etc/ansible/hosts` are resolvable. - * Because communication to remote hosts is done using SSH, keys have to be accepted by the control machine, so either 1) exchange keys with remote hosts prior to starting; or 2) be ready to type in "Yes" to accept SSH key exchange requests for each remote host you want to manage. - * Although you can combine tasks for different Linux distributions in one playbook, it's cleaner to write a separate playbook for each distro. - - - -### In the final analysis - -Ansible is a great choice for implementing automation in your data center: - - * It's agentless, so it is simpler to install than other automation tools. - * Instructions are in YAML (though JSON is also supported) so it's easier than writing shell scripts. - * It's open source software, so contribute back to it and make it even better! - - - -How have you used Ansible to automate your data center? Share your experience in the comments. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/2/tips-success-when-getting-started-ansible - -作者:[Jose Delarosa][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/jdelaros1 -[1]:https://galaxy.ansible.com/ -[2]:https://galaxy.ansible.com/bennojoy/mysql/ -[3]:https://galaxy.ansible.com/xcezx/httpd/ -[4]:http://docs.ansible.com/ diff --git a/sources/tech/20180307 3 open source tools for scientific publishing.md b/sources/tech/20180307 3 open source tools for scientific publishing.md deleted file mode 100644 index 0bbc3578e9..0000000000 --- a/sources/tech/20180307 3 open source tools for scientific publishing.md +++ /dev/null @@ -1,78 +0,0 @@ -3 open source tools for scientific publishing -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/LIFE_science.png?itok=WDKARWGV) -One industry that lags behind others in the adoption of digital or open source tools is the competitive and lucrative world of scientific publishing. Worth over £19B ($26B) annually, according to figures published by Stephen Buranyi in [The Guardian][1] last year, the system for selecting, publishing, and sharing even the most important scientific research today still bears many of the constraints of print media. New digital-era technologies present a huge opportunity to accelerate discovery, make science collaborative instead of competitive, and redirect investments from infrastructure development into research that benefits society. - -The non-profit [eLife initiative][2] was established by the funders of research, in part to encourage the use of these technologies to this end. In addition to publishing an open-access journal for important advances in life science and biomedical research, eLife has made itself into a platform for experimentation and showcasing innovation in research communication—with most of this experimentation based around the open source ethos. - -Working on open publishing infrastructure projects gives us the opportunity to accelerate the reach and adoption of the types of technology and user experience (UX) best practices that we consider important to the advancement of the academic publishing industry. Speaking very generally, the UX of open source products is often left undeveloped, which can in some cases dissuade people from using it. As part of our investment in OSS development, we place a strong emphasis on UX in order to encourage users to adopt these products. - -All of our code is open source, and we actively encourage community involvement in our projects, which to us means faster iteration, more experimentation, greater transparency, and increased reach for our work. - -The projects that we are involved in, such as the development of Libero (formerly known as [eLife Continuum][3]) and the [Reproducible Document Stack][4], along with our recent collaboration with [Hypothesis][5], show how OSS can be used to bring about positive changes in the assessment, publication, and communication of new discoveries. - -### Libero - -Libero is a suite of services and applications available to publishers that includes a post-production publishing system, a full front-end user interface pattern suite, Libero's Lens Reader, an open API, and search and recommendation engines. - -Last year, we took a user-driven approach to redesigning the front end of Libero, resulting in less distracting site “furniture” and a greater focus on research articles. We tested and iterated all the key functional areas of the site with members of the eLife community to ensure the best possible reading experience for everyone. The site’s new API also provides simpler access to content for machine readability, including text mining, machine learning, and online application development. - -The content on our website and the patterns that drive the new design are all open source to encourage future product development for both eLife and other publishers that wish to use it. - -### The Reproducible Document Stack - -In collaboration with [Substance][6] and [Stencila][7], eLife is also engaged in a project to create a Reproducible Document Stack (RDS)—an open stack of tools for authoring, compiling, and publishing computationally reproducible manuscripts online. - -Today, an increasing number of researchers are able to document their computational experiments through languages such as [R Markdown][8] and [Python][9]. These can serve as important parts of the experimental record, and while they can be shared independently from or alongside the resulting research article, traditional publishing workflows tend to relegate these assets as a secondary class of content. To publish papers, researchers using these languages often have little option but to submit their computational results as “flattened” outputs in the form of figures, losing much of the value and reusability of the code and data references used in the computation. And while electronic notebook solutions such as [Jupyter][10] can enable researchers to publish their code in an easily reusable and executable form, that’s still in addition to, rather than as an integral part of, the published manuscript. - -The [Reproducible Document Stack][11] project aims to address these challenges through development and publication of a working prototype of a reproducible manuscript that treats code and data as integral parts of the document, demonstrating a complete end-to-end technology stack from authoring through to publication. It will ultimately allow authors to submit their manuscripts in a format that includes embedded code blocks and computed outputs (statistical results, tables, or graphs), and have those assets remain both visible and executable throughout the publication process. Publishers will then be able to preserve these assets directly as integral parts of the published online article. - -### Open annotation with Hypothesis - -Most recently, we introduced open annotation in collaboration with [Hypothesis][12] to enable users of our website to make comments, highlight important sections of articles, and engage with the reading public online. - -Through this collaboration, the open source Hypothesis software was customized with new moderation features, single sign-on authentication, and user-interface customization options, giving publishers more control over its implementation on their sites. These enhancements are already driving higher-quality discussions around published scholarly content. - -The tool can be integrated seamlessly into publishers’ websites, with the scholarly publishing platform [PubFactory][13] and content solutions provider [Ingenta][14] already taking advantage of its improved feature set. [HighWire][15] and [Silverchair][16] are also offering their publishers the opportunity to implement the service. - -### Other industries and open source - -Over time, we hope to see more publishers adopt Hypothesis, Libero, and other projects to help them foster the discovery and reuse of important scientific research. But the opportunities for innovation eLife has been able to leverage because of these and other OSS technologies are also prevalent in other industries. - -The world of data science would be nowhere without the high-quality, well-supported open source software and the communities built around it; [TensorFlow][17] is a leading example of this. Thanks to OSS and its communities, all areas of AI and machine learning have seen rapid acceleration and advancement compared to other areas of computing. Similar is the explosion in usage of Linux as a cloud web host, followed by containerization with Docker, and now the growth of Kubernetes, one of the most popular open source projects on GitHub. - -All of these technologies enable organizations to do more with less and focus on innovation instead of reinventing the wheel. And in the end, that’s the real benefit of OSS: It lets us all learn from each other’s failures while building on each other's successes. - -We are always on the lookout for opportunities to engage with the best emerging talent and ideas at the interface of research and technology. Find out more about some of these engagements on [eLife Labs][18], or contact [innovation@elifesciences.org][19] for more information. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/3/scientific-publishing-software - -作者:[Paul Shanno][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/pshannon -[1]:https://www.theguardian.com/science/2017/jun/27/profitable-business-scientific-publishing-bad-for-science -[2]:https://elifesciences.org/about -[3]:https://elifesciences.org/inside-elife/33e4127f/elife-introduces-continuum-a-new-open-source-tool-for-publishing -[4]:https://elifesciences.org/for-the-press/e6038800/elife-supports-development-of-open-technology-stack-for-publishing-reproducible-manuscripts-online -[5]:https://elifesciences.org/for-the-press/81d42f7d/elife-enhances-open-annotation-with-hypothesis-to-promote-scientific-discussion-online -[6]:https://github.com/substance -[7]:https://github.com/stencila/stencila -[8]:https://rmarkdown.rstudio.com/ -[9]:https://www.python.org/ -[10]:http://jupyter.org/ -[11]:https://elifesciences.org/labs/7dbeb390/reproducible-document-stack-supporting-the-next-generation-research-article -[12]:https://github.com/hypothesis -[13]:http://www.pubfactory.com/ -[14]:http://www.ingenta.com/ -[15]:https://github.com/highwire -[16]:https://www.silverchair.com/community/silverchair-universe/hypothesis/ -[17]:https://www.tensorflow.org/ -[18]:https://elifesciences.org/labs -[19]:mailto:innovation@elifesciences.org diff --git a/sources/tech/20180507 Modularity in Fedora 28 Server Edition.md b/sources/tech/20180507 Modularity in Fedora 28 Server Edition.md new file mode 100644 index 0000000000..0b5fb0415b --- /dev/null +++ b/sources/tech/20180507 Modularity in Fedora 28 Server Edition.md @@ -0,0 +1,76 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Modularity in Fedora 28 Server Edition) +[#]: via: (https://fedoramagazine.org/wp-content/uploads/2018/05/f28-server-modularity-816x345.jpg) +[#]: author: (Stephen Gallagher https://fedoramagazine.org/author/sgallagh/) + +Modularity in Fedora 28 Server Edition +====== + +![](https://fedoramagazine.org/wp-content/uploads/2018/05/f28-server-modularity-816x345.jpg) + +### What is Modularity? + +A classic conundrum that all open-source distributions have faced is the “too fast/too slow” problem. Users install an operating system in order to enable the use of their applications. A comprehensive distribution like Fedora has an advantage and a disadvantage to the large amount of available software. While the package the user wants may be available, it might not be available in the version needed. Here’s how Modularity can help solve that problem. + +Fedora sometimes moves too fast for some users. Its rapid release cycle and desire to carry the latest stable software can result in breaking compatibility with applications. If a user can’t run a web application because Fedora upgraded a web framework to an incompatible version, it can be very frustrating. The classic answer to the “too fast” problem has been “Fedora should have an LTS release.” However, this approach only solves half the problem and makes the flip side of this conundrum worse. + +There are also times when Fedora moves too slowly for some of its users. For example, a Fedora release may be poorly-timed alongside the release of other desirable software. Once a Fedora release is declared stable, packagers must abide by the [Stable Updates Policy][1] and not introduce incompatible changes into the system. + +Fedora Modularity addresses both sides of this problem. Fedora will still ship a standard release under its traditional policy. However, it will also ship a set of modules that define alternative versions of popular software. Those in the “too fast” camp still have the benefit of Fedora’s newer kernel and other general platform enhancements. In addition, they still have access to older frameworks or toolchains that support their applications. + +In addition, those users who like to live closer to the edge can access newer software than was available at release time. + +### What is Modularity not? + +Modularity is not a drop-in replacement for [Software Collections][2]. These two technologies try to solve many of the same problems, but have distinct differences. + +Software Collections install different versions of packages in parallel on the system. However, their downside is that each installation exists in its own namespaced portion of the filesystem. Furthermore, each application that relies on them needs to be told where to find them. + +With Modularity, only one version of a package exists on the system, but the user can choose which one. The advantage is that this version lives in a standard location on the system. The package requires no special changes to applications that rely on it. Feedback from user studies shows most users don’t actually rely on parallel installation. Containerization and virtualization solve that problem. + +### Why not just use containers? + +This is another common question. Why would a user want modules when they could just use containers? The answer is, someone still has to maintain the software in the containers. Modules provide pre-packaged content for those containers that users don’t need to maintain, update and patch on their own. This is how Fedora takes the traditional value of a distribution and moves it into the new, containerized world. + +Here’s an example of how Modularity solves problems for users of Node.js and Review Board. + +### Node.js + +Many readers may be familiar with Node.js, a popular server-side JavaScript runtime. Node.js has an even/odd release policy. Its community supports even-numbered releases (6.x, 8.x, 10.x, etc.) for around 30 months. Meanwhile, they support odd-numbered releases that are essentially developer previews for 9 months. + +Due to this cycle, Fedora carried only the most recent even-numbered version of Node.js in its stable repositories. It avoided the odd-numbered versions entirely since their lifecycle was shorter than Fedora, and generally not aligned with a Fedora release. This didn’t sit well with some Fedora users, who wanted access to the latest and greatest enhancements. + +Thanks to Modularity, Fedora 28 shipped with not just one, but three versions of Node.js to satisfy both developers and stable deployments. Fedora 28’s traditional repository shipped with Node.js 8.x. This version was the most recent long-term stable version at release time. The Modular repositories (available by default on Fedora 28 Server edition) also made the older Node.js 6.x release and the newer Node.js 9.x development release available. + +Additionally, Node.js released 10.x upstream just days after Fedora 28\. In the past, users who wanted to deploy that version had to wait until Fedora 29, or use sources from outside Fedora. However, thanks again to Modularity, Node.js 10.x is already [available][3] in the Modular Updates-Testing repository for Fedora 28. + +### Review Board + +Review Board is a popular Django application for performing code reviews. Fedora included Review Board from Fedora 13 all the way until Fedora 21\. At that point, Fedora moved to Django 1.7\. Review Board was unable to keep up, due to backwards-incompatible changes in Django’s database support. It remained alive in EPEL for RHEL/CentOS 7, simply because those releases had fortunately frozen on Django 1.6\. Nevertheless, its time in Fedora was apparently over. + +However, with the advent of Modularity, Fedora could again ship the older Django as a non-default module stream. As a result, Review Board has been restored to Fedora as a module. Fedora carries both supported releases from upstream: 2.5.x and 3.0.x. + +### Putting the pieces together + +Fedora has always provided users with a wide range of software to use. Fedora Modularity now provides them with deeper choices for which versions of the software they need. The next few years will be very exciting for Fedora, as developers and users start putting together their software in new and exciting (or old and exciting) ways. + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/wp-content/uploads/2018/05/f28-server-modularity-816x345.jpg + +作者:[Stephen Gallagher][a] +选题:[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/sgallagh/ +[b]: https://github.com/lujun9972 +[1]: https://fedoraproject.org/wiki/Updates_Policy#Stable_Releases +[2]: https://www.softwarecollections.org +[3]: https://bodhi.fedoraproject.org/updates/FEDORA-MODULAR-2018-2b0846cb86 diff --git a/sources/tech/20180514 An introduction to the Pyramid web framework for Python.md b/sources/tech/20180514 An introduction to the Pyramid web framework for Python.md index 03a6fa6494..a16e604774 100644 --- a/sources/tech/20180514 An introduction to the Pyramid web framework for Python.md +++ b/sources/tech/20180514 An introduction to the Pyramid web framework for Python.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (Flowsnow) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: subject: (An introduction to the Pyramid web framework for Python) diff --git a/sources/tech/20180518 What-s a hero without a villain- How to add one to your Python game.md b/sources/tech/20180518 What-s a hero without a villain- How to add one to your Python game.md index 3ca8fba288..52b46c1adb 100644 --- a/sources/tech/20180518 What-s a hero without a villain- How to add one to your Python game.md +++ b/sources/tech/20180518 What-s a hero without a villain- How to add one to your Python game.md @@ -1,3 +1,5 @@ +Translating by cycoe +Cycoe 翻译中 What's a hero without a villain? How to add one to your Python game ====== ![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/game-dogs-chess-play-lead.png?itok=NAuhav4Z) diff --git a/sources/tech/20180530 Introduction to the Pony programming language.md b/sources/tech/20180530 Introduction to the Pony programming language.md deleted file mode 100644 index 2292c65fc2..0000000000 --- a/sources/tech/20180530 Introduction to the Pony programming language.md +++ /dev/null @@ -1,95 +0,0 @@ -beamrolling is translating. -Introduction to the Pony programming language -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_keys.jpg?itok=O4qaYCHK) - -At [Wallaroo Labs][1], where I'm the VP of engineering, we're are building a [high-performance, distributed stream processor][2] written in the [Pony][3] programming language. Most people haven't heard of Pony, but it has been an excellent choice for Wallaroo, and it might be an excellent choice for your next project, too. - -> "A programming language is just another tool. It's not about syntax. It's not about expressiveness. It's not about paradigms or models. It's about managing hard problems." —Sylvan Clebsch, creator of Pony - -I'm a contributor to the Pony project, but here I'll touch on why Pony is a good choice for applications like Wallaroo and share ways I've used Pony. If you are interested in a more in-depth look at why we use Pony to write Wallaroo, we have a [blog post][4] about that. - -### What is Pony? - -You can think of Pony as something like "Rust meets Erlang." Pony sports buzzworthy features. It is: - - * Type-safe - * Memory-safe - * Exception-safe - * Data-race-free - * Deadlock-free - - - -Additionally, it's compiled to efficient native code, and it's developed in the open and available under a two-clause BSD license. - -That's a lot of features, but here I'll focus on the few that were key to my company adopting Pony. - -### Why Pony? - -Writing fast, safe, efficient, highly concurrent programs is not easy with most of our existing tools. "Fast, efficient, and highly concurrent" is an achievable goal, but throw in "safe," and things get a lot harder. With Wallaroo, we wanted to accomplish all four, and Pony has made it easy to achieve. - -#### Highly concurrent - -Pony makes concurrency easy. Part of the way it does that is by providing an opinionated concurrency story. In Pony, all concurrency happens via the [actor model][5]. - -The actor model is most famous via the implementations in Erlang and Akka. The actor model has been around since the 1970s, and details vary widely from implementation to implementation. What doesn't vary is that all computation is executed by actors that communicate via asynchronous messaging. - -Think of the actor model this way: objects in object-oriented programming are state + synchronous methods and actors are state + asynchronous methods. - -When an actor receives a message, it executes a corresponding method. That method might operate on a state that is accessible by only that actor. The actor model allows us to use a mutable state in a concurrency-safe manner. Every actor is single-threaded. Two methods within an actor are never run concurrently. This means that, within a given actor, data updates cannot cause data races or other problems commonly associated with threads and mutable states. - -#### Fast and efficient - -Pony actors are scheduled with an efficient work-stealing scheduler. There's a single Pony scheduler per available CPU. The thread-per-core concurrency model is part of Pony's attempt to work in concert with the CPU to operate as efficiently as possible. The Pony runtime attempts to be as CPU-cache friendly as possible. The less your code thrashes the cache, the better it will run. Pony aims to help your code play nice with CPU caches. - -The Pony runtime also features per-actor heaps so that, during garbage collection, there's no "stop the world" garbage collection step. This means your program is always doing at least some work. As a result, Pony programs end up with very consistent performance and predictable latencies. - -#### Safe - -The Pony type system introduces a novel concept: reference capabilities, which make data safety part of the type system. The type of every variable in Pony includes information about how the data can be shared between actors. The Pony compiler uses the information to verify, at compile time, that your code is data-race- and deadlock-free. - -If this sounds a bit like Rust, it's because it is. Pony's reference capabilities and Rust's borrow checker both provide data safety; they just approach it in different ways and have different tradeoffs. - -### Is Pony right for you? - -Deciding whether to use a new programming language for a non-hobby project is hard. You must weigh the appropriateness of the tool against its immaturity compared to other solutions. So, what about Pony and you? - -Pony might be the right solution if you have a hard concurrency problem to solve. Concurrent applications are Pony's raison d'être. If you can accomplish what you want in a single-threaded Python script, you probably don't need Pony. If you have a hard concurrency problem, you should consider Pony and its powerful data-race-free, concurrency-aware type system. - -You'll get a compiler that will prevent you from introducing many concurrency-related bugs and a runtime that will give you excellent performance characteristics. - -### Getting started with Pony - -If you're ready to get started with Pony, your first visit should be the [Learn section][6] of the Pony website. There you will find directions for installing the Pony compiler and resources for learning the language. - -If you like to contribute to the language you are using, we have some [beginner-friendly issues][7] waiting for you on GitHub. - -Also, I can't wait to start talking with you on [our IRC channel][8] and the [Pony mailing list][9]. - -To learn more about Pony, attend Sean Allen's talk, [Pony: How I learned to stop worrying and embrace an unproven technology][10], at the [20th OSCON][11], July 16-19, 2018, in Portland, Ore. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/5/pony - -作者:[Sean T Allen][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/seantallen -[1]:http://www.wallaroolabs.com/ -[2]:https://github.com/wallaroolabs/wallaroo -[3]:https://www.ponylang.org/ -[4]:https://blog.wallaroolabs.com/2017/10/why-we-used-pony-to-write-wallaroo/ -[5]:https://en.wikipedia.org/wiki/Actor_model -[6]:https://www.ponylang.org/learn/ -[7]:https://github.com/ponylang/ponyc/issues?q=is%3Aissue+is%3Aopen+label%3A%22complexity%3A+beginner+friendly%22 -[8]:https://webchat.freenode.net/?channels=%23ponylang -[9]:https://pony.groups.io/g/user -[10]:https://conferences.oreilly.com/oscon/oscon-or/public/schedule/speaker/213590 -[11]:https://conferences.oreilly.com/oscon/oscon-or diff --git a/sources/tech/20180531 Qalculate- - The Best Calculator Application in The Entire Universe.md b/sources/tech/20180531 Qalculate- - The Best Calculator Application in The Entire Universe.md deleted file mode 100644 index 6cbea61308..0000000000 --- a/sources/tech/20180531 Qalculate- - The Best Calculator Application in The Entire Universe.md +++ /dev/null @@ -1,125 +0,0 @@ -Qalculate! – The Best Calculator Application in The Entire Universe -====== -I have been a GNU-Linux user and a [Debian][1] user for more than a decade. As I started using the desktop more and more, it seemed to me that apart from few web-based services most of my needs were being met with [desktop applications][2] within Debian itself. - -One of such applications was the need for me to calculate between different measurements of units. While there are and were many web-services which can do the same, I wanted something which could do all this and more on my desktop for both privacy reasons as well as not having to hunt for a web service for doing one thing or the other. My search ended when I found Qalculate!. - -### Qalculate! The most versatile calculator application - -![Qalculator is the best calculator app][3] - -This is what aptitude says about [Qalculate!][4] and I cannot put it in better terms: - -> Powerful and easy to use desktop calculator – GTK+ version -> -> Qalculate! is small and simple to use but with much power and versatility underneath. Features include customizable functions, units, arbitrary precision, plotting, and a graphical interface that uses a one-line fault-tolerant expression entry (although it supports optional traditional buttons). - -It also did have a KDE interface as well as in its previous avatar, but at least in Debian testing, it just shows only the GTK+ version which can be seen from the github [repo][5] as well. - -Needless to say that Qalculate! is available in Debian repository and hence can easily be installed [using apt command][6] or through software center in Debian based distributions like Ubuntu. It is also availale for Windows and macOS. - -#### Features of Qalculate! - -Now while it would be particularly long to go through the whole list of functionality it allows – allow me to list some of the functionality to be followed by a few screenshots of just a couple of functionalities that Qalculate! provides. The idea is basically to familiarize you with a couple of basic methods and then leave it up to you to enjoy exploring what all Qalculate! can do. - - * Algebra - * Calculus - * Combinatorics - * Complex_Numbers - * Data_Sets - * Date_&_Time - * Economics - * Exponents_&_Logarithms - * Geometry - * Logical - * Matrices_&_Vectors - * Miscellaneous - * Number_Theory - * Statistics - * Trigonometry - - - -#### Using Qalculate! - -Using Qalculate! is not complicated. You can even write in the simple natural language. However, I recommend [reading the manual][7] to utilize the full potential of Qalculate! - -![qalculate byte to gibibyte conversion ][8] - -![conversion from celcius degrees to fahreneit][9] - -#### qalc is the command line version of Qalculate! - -You can achieve the same results as Qalculate! with its command-line brethren qalc -``` -$ qalc 62499836 byte to gibibyte -62499836 * byte = approx. 0.058207508 gibibyte - -$ qalc 40 degree celsius to fahrenheit -(40 * degree) * celsius = 104 deg*oF - -``` - -I shared the command-line interface so that people who don’t like GUI interfaces and prefer command-line (CLI) or have headless nodes (no GUI) could also use qalculate, pretty common in server environments. - -If you want to use it in scripts, I guess libqalculate would be the way to go and seeing how qalculate-gtk, qalc depend on it seems it should be good enough. - -Just to share, you could also explore how to use plotting of series data but that and other uses will leave to you. Don’t forget to check the /usr/share/doc/qalculate/index.html to see all the different functionalities that Qalculate! has. - -Note:- Do note that though Debian prefers [gnuplot][10] to showcase the pretty graphs that can come out of it. - -#### Bonus Tip: You can thank the developer via command line in Debian - -If you use Debian and like any package, you can quickly thank the Debian Developer or maintainer maintaining the said package using: -``` -reportbug --kudos $PACKAGENAME - -``` - -Since I liked QaIculate!, I would like to give a big shout-out to the Debian developer and maintainer Vincent Legout for the fantastic work he has done. -``` -reportbug --kudos qalculate - -``` - -I would also suggest reading my detailed article on using reportbug tool for [bug reporting in Debian][11]. - -#### The opinion of a Polymer Chemist on Qalculate! - -Through my fellow author [Philip Prado][12], we contacted a Mr. Timothy Meyers, currently a student working in a polymer lab as a Polymer Chemist. - -His professional opinion on Qaclulate! is – - -> This looks like almost any scientist to use as any type of data calculations statistics could use this program issue would be do you know the commands and such to make it function -> -> I feel like there’s some Physics constants that are missing but off the top of my head I can’t think of what they are but I feel like there’s not very many [fluid dynamics][13] stuff in there and also some different like [light absorption][14] coefficients for different compounds but that’s just a chemist in me I don’t know if those are super necessary. [Free energy][15] might be one - -In the end, I just want to share this is a mere introduction to what Qalculate! can do and is limited by what you want to get done and your imagination. I hope you like Qalculate! - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/qalculate/ - -作者:[Shirish][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/shirish/ -[1]:https://www.debian.org/ -[2]:https://itsfoss.com/essential-linux-applications/ -[3]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/05/qalculate-app-featured-1-800x450.jpeg -[4]:https://qalculate.github.io/ -[5]:https://github.com/Qalculate -[6]:https://itsfoss.com/apt-command-guide/ -[7]:https://qalculate.github.io/manual/index.html -[8]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/04/qalculate-byte-conversion.png -[9]:https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/04/qalculate-gtk-weather-conversion.png -[10]:http://www.gnuplot.info/ -[11]:https://itsfoss.com/bug-report-debian/ -[12]:https://itsfoss.com/author/phillip/ -[13]:https://en.wikipedia.org/wiki/Fluid_dynamics -[14]:https://en.wikipedia.org/wiki/Absorption_(electromagnetic_radiation) -[15]:https://en.wikipedia.org/wiki/Gibbs_free_energy diff --git a/sources/tech/20180611 3 open source alternatives to Adobe Lightroom.md b/sources/tech/20180611 3 open source alternatives to Adobe Lightroom.md index c489b0f0f1..664c054913 100644 --- a/sources/tech/20180611 3 open source alternatives to Adobe Lightroom.md +++ b/sources/tech/20180611 3 open source alternatives to Adobe Lightroom.md @@ -1,5 +1,3 @@ -scoutydren is translating - 3 open source alternatives to Adobe Lightroom ====== diff --git a/sources/tech/20180612 7 open source tools to make literature reviews easy.md b/sources/tech/20180612 7 open source tools to make literature reviews easy.md index 96edb68eff..674f4ea44b 100644 --- a/sources/tech/20180612 7 open source tools to make literature reviews easy.md +++ b/sources/tech/20180612 7 open source tools to make literature reviews easy.md @@ -1,3 +1,4 @@ +translated by lixinyuxx 7 open source tools to make literature reviews easy ====== diff --git a/sources/tech/20180621 How to connect to a remote desktop from Linux.md b/sources/tech/20180621 How to connect to a remote desktop from Linux.md deleted file mode 100644 index ced3b233dc..0000000000 --- a/sources/tech/20180621 How to connect to a remote desktop from Linux.md +++ /dev/null @@ -1,136 +0,0 @@ -How to connect to a remote desktop from Linux -====== - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003499_01_cloud21x_cc.png?itok=5UwC92dO) - -A [remote desktop][1], according to Wikipedia, is "a software or operating system feature that allows a personal computer's desktop environment to be run remotely on one system (usually a PC, but the concept applies equally to a server), while being displayed on a separate client device." - -In other words, a remote desktop is used to access an environment running on another computer. For example, the [ManageIQ/Integration tests][2] repository's pull request (PR) testing system exposes a Virtual Network Computing (VNC) connection port so I can remotely view my PRs being tested in real time. Remote desktops are also used to help customers solve computer problems: with the customer's permission, you can establish a VNC or Remote Desktop Protocol (RDP) connection to see or interactively access the computer to troubleshoot or repair the problem. - -These connections are made using remote desktop connection software, and there are many options available. I use [Remmina][3] because I like its minimal, easy-to-use user interface (UI). It's written in GTK+ and is open source under the GNU GPL license. - -In this article, I'll explain how to use the Remmina client to connect remotely from a Linux computer to a Windows 10 system and a Red Hat Enterprise Linux 7 system. - -### Install Remmina on Linux - -First, you need to install Remmina on the computer you'll use to access the other computer(s) remotely. If you're using Fedora, you can run the following command to install Remmina: -``` -sudo dnf install -y remmina - -``` - -If you want to install Remmina on a different Linux platform, follow these [installation instructions][4]. You should then find Remmina with your other apps (Remmina is selected in this image). - -![](https://opensource.com/sites/default/files/uploads/remmina1-on-desktop.png) - -Launch Remmina by clicking on the icon. You should see a screen that resembles this: - -![](https://opensource.com/sites/default/files/uploads/remmina2_launched.png) - -Remmina offers several types of connections, including RDP, which is used to connect to Windows-based computers, and VNC, which is used to connect to Linux machines. As you can see in the top-left corner above, Remmina's default setting is RDP. - -### Connecting to Windows 10 - -Before you can connect to a Windows 10 computer through RDP, you must change some permissions to allow remote desktop sharing and connections through your firewall. - -[Note: Windows 10 Home has no RDP feature listed. ][5] - -To enable remote desktop sharing, in **File Explorer** right-click on **My Computer → Properties → Remote Settings** and, in the pop-up that opens, check **Allow remote connections to this computer** , then select **Apply**. - -![](https://opensource.com/sites/default/files/uploads/remmina3_connect_win10.png) - -Next, enable remote desktop connections through your firewall. First, search for **firewall settings** in the **Start** menu and select **Allow an app through Windows Firewall**. - -![](https://opensource.com/sites/default/files/uploads/remmina4_firewall.png) - -In the window that opens, look for **Remote Desktop** under **Allowed apps and features**. Check the box(es) in the **Private **and/or **Public** columns, depending on the type of network(s) you will use to access this desktop. Click **OK**. - -![](https://opensource.com/sites/default/files/uploads/remmina5_firewall_2.png) - -Go to the Linux computer you use to remotely access the Windows PC and launch Remmina. Enter the IP address of your Windows computer and hit the Enter key. (How do I locate my IP address [in Linux][6] and [Windows 10][7]?) When prompted, enter your username and password and click OK. - -![](https://opensource.com/sites/default/files/uploads/remmina6_login.png) - -If you're asked to accept the certificate, select OK. - -![](https://opensource.com/sites/default/files/uploads/remmina7_certificate.png) - -You should be able to see your Windows 10 computer's desktop. - -![](https://opensource.com/sites/default/files/uploads/remmina8_remote_desktop.png) - -### Connecting to Red Hat Enterprise Linux 7 - -To set permissions to enable remote access on your RHEL7 computer, open **All Settings** on the Linux desktop. - -![](https://opensource.com/sites/default/files/uploads/remmina9_settings.png) - -Click on the Sharing icon, and this window will open: - -![](https://opensource.com/sites/default/files/uploads/remmina10_sharing.png) - -If **Screen Sharing** is off, click on it. A window will open, where you can slide it into the **On** position. If you want to allow remote connections to control the desktop, set **Allow Remote Control** to **On**. You can also select between two access options: one that prompts the computer's primary user to accept or deny the connection request, and another that allows connection authentication with a password. At the bottom of the window, select the network interface where connections are allowed, then close the window. - -Next, open **Firewall Settings** from **Applications Menu → Sundry → Firewall**. - -![](https://opensource.com/sites/default/files/uploads/remmina11_firewall_settings.png) - -Check the box next to vnc-server (as shown above) and close the window. Then, head to Remmina on your remote computer, enter the IP address of the Linux desktop you want to connect with, select **VNC** as the protocol, and hit the **Enter** key. - -![](https://opensource.com/sites/default/files/uploads/remmina12_vncprotocol.png) - -If you previously chose the authentication option **New connections must ask for access** , the RHEL system's user will see a prompt like this: - -![](https://opensource.com/sites/default/files/uploads/remmina13_permission.png) - -Select **Accept** for the remote connection to succeed. - -If you chose the option to authenticate the connection with a password, Remmina will prompt you for the password. - -![](https://opensource.com/sites/default/files/uploads/remmina14_password-auth.png) - -Enter the password and hit **OK** , and you should be connected to the remote computer. - -![](https://opensource.com/sites/default/files/uploads/remmina15_connected.png) - -### Using Remmina - -Remmina offers a tabbed UI, as shown in above picture, much like a web browser. In the top-left corner, as shown in the screenshot above, you can see two tabs: one for the previously established Windows 10 connection and a new one for the RHEL connection. - -On the left-hand side of the window, there is a toolbar with options such as **Resize Window** , **Full-Screen Mode** , **Preferences** , **Screenshot** , **Disconnect** , and more. Explore them and see which ones work best for you. - -You can also create saved connections in Remmina by clicking on the **+** (plus) sign in the top-left corner. Fill in the form with details specific to your connection and click **Save**. Here is an example Windows 10 RDP connection: - -![](https://opensource.com/sites/default/files/uploads/remmina16_saved-connection.png) - -The next time you open Remmina, the connection will be available. - -![](https://opensource.com/sites/default/files/uploads/remmina17_connection-available.png) - -Just click on it, and your connection will be established without re-entering the details. - -### Additional info - -When you use remote desktop software, all the operations you perform take place on the remote desktop and use its resources—Remmina (or similar software) is just a way to interact with that desktop. You can also access a computer remotely through SSH, but it usually limits you to a text-only terminal to that computer. - -You should also note that enabling remote connections with your computer could cause serious damage if an attacker uses this method to gain access to your computer. Therefore, it is wise to disallow remote desktop connections and block related services in your firewall when you are not actively using Remote Desktop. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/6/linux-remote-desktop - -作者:[Kedar Vijay Kulkarni][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/kkulkarn -[1]:https://en.wikipedia.org/wiki/Remote_desktop_software -[2]:https://github.com/ManageIQ/integration_tests -[3]:https://www.remmina.org/wp/ -[4]:https://www.tecmint.com/remmina-remote-desktop-sharing-and-ssh-client/ -[5]:https://superuser.com/questions/1019203/remote-desktop-settings-missing#1019212 -[6]:https://opensource.com/article/18/5/how-find-ip-address-linux -[7]:https://www.groovypost.com/howto/find-windows-10-device-ip-address/ diff --git a/sources/tech/20180629 How To Get Flatpak Apps And Games Built With OpenGL To Work With Proprietary Nvidia Graphics Drivers.md b/sources/tech/20180629 How To Get Flatpak Apps And Games Built With OpenGL To Work With Proprietary Nvidia Graphics Drivers.md deleted file mode 100644 index a9d540adae..0000000000 --- a/sources/tech/20180629 How To Get Flatpak Apps And Games Built With OpenGL To Work With Proprietary Nvidia Graphics Drivers.md +++ /dev/null @@ -1,113 +0,0 @@ -How To Get Flatpak Apps And Games Built With OpenGL To Work With Proprietary Nvidia Graphics Drivers -====== -**Some applications and games built with OpenGL support and packaged as Flatpak fail to start with proprietary Nvidia drivers. This article explains how to get such Flatpak applications or games them to start, without installing the open source drivers (Nouveau).** - -Here's an example. I'm using the proprietary Nvidia drivers on my Ubuntu 18.04 desktop (`nvidia-driver-390`) and when I try to launch the latest -``` -$ /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=krita --file-forwarding org.kde.krita -Gtk-Message: Failed to load module "canberra-gtk-module" -Gtk-Message: Failed to load module "canberra-gtk-module" -libGL error: No matching fbConfigs or visuals found -libGL error: failed to load driver: swrast -Could not initialize GLX - -``` - -To fix Flatpak games and applications not starting when using OpenGL with proprietary Nvidia graphics drivers, you'll need to install a runtime for your currently installed proprietary Nvidia drivers. Here's how to do this. - -**1\. Add the FlatHub repository if you haven't already. You can find exact instructions for your Linux distribution[here][1].** - -**2. Now you'll need to figure out the exact version of the proprietary Nvidia drivers installed on your system. ** - -_This step is dependant of the Linux distribution you're using and I can't cover all cases. The instructions below are Ubuntu-oriented (and Ubuntu flavors) but hopefully you can figure out for yourself the Nvidia drivers version installed on your system._ - -To do this in Ubuntu, open `Software & Updates` , switch to the `Additional Drivers` tab and note the name of the Nvidia driver package. - -As an example, this is `nvidia-driver-390` in my case, as you can see here: - -![](https://1.bp.blogspot.com/-FAfjtGNeUJc/WzYXMYTFBcI/AAAAAAAAAx0/xUhIO83IAjMuK4Hn0jFUYKJhSKw8y559QCLcBGAs/s1600/additional-drivers-nvidia-ubuntu.png) - -That's not all. We've only found out the Nvidia drivers major version but we'll also need to know the minor version. To get the exact Nvidia driver version, which we'll need for the next step, run this command (should work in any Debian-based Linux distribution, like Ubuntu, Linux Mint and so on): -``` -apt-cache policy NVIDIA-PACKAGE-NAME - -``` - -Where NVIDIA-PACKAGE-NAME is the Nvidia drivers package name listed in `Software & Updates` . For example, to see the exact installed version of the `nvidia-driver-390` package, run this command: -``` -$ apt-cache policy nvidia-driver-390 -nvidia-driver-390: - Installed: 390.48-0ubuntu3 - Candidate: 390.48-0ubuntu3 - Version table: - * 390.48-0ubuntu3 500 - 500 http://ro.archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages - 100 /var/lib/dpkg/status - -``` - -In this command's output, look for the `Installed` section and note the version numbers (excluding `-0ubuntu3` and anything similar). Now we know the exact version of the installed Nvidia drivers (`390.48` in my example). Remember this because we'll need it for the next step. - -**3\. And finally, you can install the Nvidia runtime for your installed proprietary Nvidia graphics drivers, from FlatHub** - -To list all the available Nvidia runtime packages available on FlatHub, you can use this command: -``` -flatpak remote-ls flathub | grep nvidia - -``` - -Hopefully the runtime for your installed Nvidia drivers is available on FlatHub. You can now proceed to install the runtime by using this command: - - * For 64bit systems: - - -``` -flatpak install flathub org.freedesktop.Platform.GL.nvidia-MAJORVERSION-MINORVERSION - -``` - -Replace MAJORVERSION with the Nvidia driver major version installed on your computer (390 in my example above) and -MINORVERSION with the minor version (48 in my example from step 2). - -For example, to install the runtime for Nvidia graphics driver version 390.48, you'd have to use this command: -``` -flatpak install flathub org.freedesktop.Platform.GL.nvidia-390-48 - -``` - - * For 32bit systems (or to be able to run 32bit applications or games on 64bit), install the 32bit runtime using: - - -``` -flatpak install flathub org.freedesktop.Platform.GL32.nvidia-MAJORVERSION-MINORVERSION - -``` - -Once again, replace MAJORVERSION with the Nvidia driver major version installed on your computer (390 in my example above) and MINORVERSION with the minor version (48 in my example from step 2). - -For example, to install the 32bit runtime for Nvidia graphics driver version 390.48, you'd have to use this command: -``` -flatpak install flathub org.freedesktop.Platform.GL32.nvidia-390-48 - -``` - -That is all you need to do to get applications or games packaged as Flatpak that are built with OpenGL to run. - - --------------------------------------------------------------------------------- - -via: https://www.linuxuprising.com/2018/06/how-to-get-flatpak-apps-and-games-built.html - -作者:[Logix][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://plus.google.com/118280394805678839070 -[1]:https://flatpak.org/setup/ -[2]:https://www.linuxuprising.com/2018/06/free-painting-software-krita-410.html -[3]:https://www.linuxuprising.com/2018/06/winepak-is-flatpak-repository-for.html -[4]:https://github.com/winepak/applications/issues/23 -[5]:https://github.com/flatpak/flatpak/issues/138 diff --git a/sources/tech/20180724 How To Mount Google Drive Locally As Virtual File System In Linux.md b/sources/tech/20180724 How To Mount Google Drive Locally As Virtual File System In Linux.md deleted file mode 100644 index 3f804ffe9e..0000000000 --- a/sources/tech/20180724 How To Mount Google Drive Locally As Virtual File System In Linux.md +++ /dev/null @@ -1,265 +0,0 @@ -How To Mount Google Drive Locally As Virtual File System In Linux -====== - -![](https://www.ostechnix.com/wp-content/uploads/2018/07/Google-Drive-720x340.png) - -[**Google Drive**][1] is the one of the popular cloud storage provider on the planet. As of 2017, over 800 million users are actively using this service worldwide. Even though the number of users have dramatically increased, Google haven’t released a Google drive client for Linux yet. But it didn’t stop the Linux community. Every now and then, some developers had brought few google drive clients for Linux operating system. In this guide, we will see three unofficial google drive clients for Linux. Using these clients, you can mount Google drive locally as a virtual file system and access your drive files in your Linux box. Read on. - -### 1. Google-drive-ocamlfuse - -The **google-drive-ocamlfuse** is a FUSE filesystem for Google Drive, written in OCaml. For those wondering, FUSE, stands for **F** ilesystem in **Use** rspace, is a project that allows the users to create virtual file systems in user level. **google-drive-ocamlfuse** allows you to mount your Google Drive on Linux system. It features read/write access to ordinary files and folders, read-only access to Google docks, sheets, and slides, support for multiple google drive accounts, duplicate file handling, access to your drive trash directory, and more. - -#### Installing google-drive-ocamlfuse - -google-drive-ocamlfuse is available in the [**AUR**][2], so you can install it using any AUR helper programs, for example [**Yay**][3]. -``` -$ yay -S google-drive-ocamlfuse - -``` - -On Ubuntu: -``` -$ sudo add-apt-repository ppa:alessandro-strada/ppa -$ sudo apt-get update -$ sudo apt-get install google-drive-ocamlfuse - -``` - -To install latest beta version, do: -``` -$ sudo add-apt-repository ppa:alessandro-strada/google-drive-ocamlfuse-beta -$ sudo apt-get update -$ sudo apt-get install google-drive-ocamlfuse - -``` - -#### Usage - -Once installed, run the following command to launch **google-drive-ocamlfuse** utility from your Terminal: -``` -$ google-drive-ocamlfuse - -``` - -When you run this first time, the utility will open your web browser and ask your permission to authorize your google drive files. Once you gave authorization, all necessary config files and folders it needs to mount your google drive will be automatically created. - -![][5] - -After successful authentication, you will see the following message in your Terminal. -``` -Access token retrieved correctly. - -``` - -You’re good to go now. Close the web browser and then create a mount point to mount your google drive files. -``` -$ mkdir ~/mygoogledrive - -``` - -Finally, mount your google drive using command: -``` -$ google-drive-ocamlfuse ~/mygoogledrive - -``` - -Congratulations! You can access access your files either from Terminal or file manager. - -From **Terminal** : -``` -$ ls ~/mygoogledrive - -``` - -From **File manager** : - -![][6] - -If you have more than one account, use **label** option to distinguish different accounts like below. -``` -$ google-drive-ocamlfuse -label label [mountpoint] - -``` - -Once you’re done, unmount the FUSE flesystem using command: -``` -$ fusermount -u ~/mygoogledrive - -``` - -For more details, refer man pages. -``` -$ google-drive-ocamlfuse --help - -``` - -Also, do check the [**official wiki**][7] and the [**project GitHub repository**][8] for more details. - -### 2. GCSF - -**GCSF** is a FUSE filesystem based on Google Drive, written using **Rust** programming language. The name GCSF has come from the Romanian word “ **G** oogle **C** onduce **S** istem de **F** ișiere”, which means “Google Drive Filesystem” in English. Using GCSF, you can mount your Google drive as a local virtual file system and access the contents from the Terminal or file manager. You might wonder how it differ from other Google Drive FUSE projects, for example **google-drive-ocamlfuse**. The developer of GCSF replied to a similar [comment on Reddit][9] “GCSF tends to be faster in several cases (listing files recursively, reading large files from Drive). The caching strategy it uses also leads to very fast reads (x4-7 improvement compared to google-drive-ocamlfuse) for files that have been cached, at the cost of using more RAM“. - -#### Installing GCSF - -GCSF is available in the [**AUR**][10], so the Arch Linux users can install it using any AUR helper, for example [**Yay**][3]. -``` -$ yay -S gcsf-git - -``` - -For other distributions, do the following. - -Make sure you have installed Rust on your system. - -Make sure **pkg-config** and the **fuse** packages are installed. They are available in the default repositories of most Linux distributions. For example, on Ubuntu and derivatives, you can install them using command: -``` -$ sudo apt-get install -y libfuse-dev pkg-config - -``` - -Once all dependencies installed, run the following command to install GCSF: -``` -$ cargo install gcsf - -``` - -#### Usage - -First, we need to authorize our google drive. To do so, simply run: -``` -$ gcsf login ostechnix - -``` - -You must specify a session name. Replace **ostechnix** with your own session name. You will see an output something like below with an URL to authorize your google drive account. - -![][11] - -Just copy and navigate to the above URL from your browser and click **allow** to give permission to access your google drive contents. Once you gave the authentication you will see an output like below. -``` -Successfully logged in. Credentials saved to "/home/sk/.config/gcsf/ostechnix". - -``` - -GCSF will create a configuration file in **$XDG_CONFIG_HOME/gcsf/gcsf.toml** , which is usually defined as **$HOME/.config/gcsf/gcsf.toml**. Credentials are stored in the same directory. - -Next, create a directory to mount your google drive contents. -``` -$ mkdir ~/mygoogledrive - -``` - -Then, edit **/etc/fuse.conf** file: -``` -$ sudo vi /etc/fuse.conf - -``` - -Uncomment the following line to allow non-root users to specify the allow_other or allow_root mount options. -``` -user_allow_other - -``` - -Save and close the file. - -Finally, mount your google drive using command: -``` -$ gcsf mount ~/mygoogledrive -s ostechnix - -``` - -Sample output: -``` -INFO gcsf > Creating and populating file system... -INFO gcsf > File sytem created. -INFO gcsf > Mounting to /home/sk/mygoogledrive -INFO gcsf > Mounted to /home/sk/mygoogledrive -INFO gcsf::gcsf::file_manager > Checking for changes and possibly applying them. -INFO gcsf::gcsf::file_manager > Checking for changes and possibly applying them. - -``` - -Again, replace **ostechnix** with your session name. You can view the existing sessions using command: -``` -$ gcsf list -Sessions: -- ostechnix - -``` - -You can now access your google drive contents either from the Terminal or from File manager. - -From **Terminal** : -``` -$ ls ~/mygoogledrive - -``` - -From **File manager** : - -![][12] - -If you don’t know where your Google drive is mounted, use **df** or **mount** command as shown below. -``` -$ df -h -Filesystem Size Used Avail Use% Mounted on -udev 968M 0 968M 0% /dev -tmpfs 200M 1.6M 198M 1% /run -/dev/sda1 20G 7.5G 12G 41% / -tmpfs 997M 0 997M 0% /dev/shm -tmpfs 5.0M 4.0K 5.0M 1% /run/lock -tmpfs 997M 0 997M 0% /sys/fs/cgroup -tmpfs 200M 40K 200M 1% /run/user/1000 -GCSF 15G 857M 15G 6% /home/sk/mygoogledrive - -$ mount | grep GCSF -GCSF on /home/sk/mygoogledrive type fuse (rw,nosuid,nodev,relatime,user_id=1000,group_id=1000,allow_other) - -``` - -Once done, unmount the google drive using command: -``` -$ fusermount -u ~/mygoogledrive - -``` - -Check the [**GCSF GitHub repository**][13] for more details. - -### 3. Tuxdrive - -**Tuxdrive** is yet another unofficial google drive client for Linux. We have written a detailed guide about Tuxdrive a while ago. Please check the following link. - -Of course, there were few other unofficial google drive clients available in the past, such as Grive2, Syncdrive. But it seems that they are discontinued now. I will keep updating this list when I come across any active google drive clients. - -And, that’s all for now, folks. Hope this was useful. More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-mount-google-drive-locally-as-virtual-file-system-in-linux/ - -作者:[SK][a] -选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.ostechnix.com/author/sk/ -[1]:https://www.google.com/drive/ -[2]:https://aur.archlinux.org/packages/google-drive-ocamlfuse/ -[3]:https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ -[4]:data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[5]:http://www.ostechnix.com/wp-content/uploads/2018/07/google-drive.png -[6]:http://www.ostechnix.com/wp-content/uploads/2018/07/google-drive-2.png -[7]:https://github.com/astrada/google-drive-ocamlfuse/wiki/Configuration -[8]:https://github.com/astrada/google-drive-ocamlfuse -[9]:https://www.reddit.com/r/DataHoarder/comments/8vlb2v/google_drive_as_a_file_system/e1oh9q9/ -[10]:https://aur.archlinux.org/packages/gcsf-git/ -[11]:http://www.ostechnix.com/wp-content/uploads/2018/07/google-drive-3.png -[12]:http://www.ostechnix.com/wp-content/uploads/2018/07/google-drive-4.png -[13]:https://github.com/harababurel/gcsf diff --git a/sources/tech/20180906 What a shell dotfile can do for you.md b/sources/tech/20180906 What a shell dotfile can do for you.md index 35593e1e32..16ee0936e3 100644 --- a/sources/tech/20180906 What a shell dotfile can do for you.md +++ b/sources/tech/20180906 What a shell dotfile can do for you.md @@ -1,3 +1,11 @@ +[#]: collector: (lujun9972) +[#]: translator: (runningwater) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What a shell dotfile can do for you) +[#]: via: (https://opensource.com/article/18/9/shell-dotfile) +[#]: author: (H.Waldo Grunenwald https://opensource.com/users/gwaldo) What a shell dotfile can do for you ====== @@ -223,7 +231,7 @@ via: https://opensource.com/article/18/9/shell-dotfile 作者:[H.Waldo Grunenwald][a] 选题:[lujun9972](https://github.com/lujun9972) -译者:[译者ID](https://github.com/译者ID) +译者:[runningwater](https://github.com/runningwater) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20180926 HTTP- Brief History of HTTP.md b/sources/tech/20180926 HTTP- Brief History of HTTP.md new file mode 100644 index 0000000000..64e2abfd6b --- /dev/null +++ b/sources/tech/20180926 HTTP- Brief History of HTTP.md @@ -0,0 +1,286 @@ +[#]: collector: (lujun9972) +[#]: translator: (MjSeven) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (HTTP: Brief History of HTTP) +[#]: via: (https://hpbn.co/brief-history-of-http/#http-09-the-one-line-protocol) +[#]: author: (Ilya Grigorik https://www.igvita.com/) + +HTTP: Brief History of HTTP +====== + +### Introduction + +The Hypertext Transfer Protocol (HTTP) is one of the most ubiquitous and widely adopted application protocols on the Internet: it is the common language between clients and servers, enabling the modern web. From its simple beginnings as a single keyword and document path, it has become the protocol of choice not just for browsers, but for virtually every Internet-connected software and hardware application. + +In this chapter, we will take a brief historical tour of the evolution of the HTTP protocol. A full discussion of the varying HTTP semantics is outside the scope of this book, but an understanding of the key design changes of HTTP, and the motivations behind each, will give us the necessary background for our discussions on HTTP performance, especially in the context of the many upcoming improvements in HTTP/2. + +### §HTTP 0.9: The One-Line Protocol + +The original HTTP proposal by Tim Berners-Lee was designed with simplicity in mind as to help with the adoption of his other nascent idea: the World Wide Web. The strategy appears to have worked: aspiring protocol designers, take note. + +In 1991, Berners-Lee outlined the motivation for the new protocol and listed several high-level design goals: file transfer functionality, ability to request an index search of a hypertext archive, format negotiation, and an ability to refer the client to another server. To prove the theory in action, a simple prototype was built, which implemented a small subset of the proposed functionality: + + * Client request is a single ASCII character string. + + * Client request is terminated by a carriage return (CRLF). + + * Server response is an ASCII character stream. + + + + * Server response is a hypertext markup language (HTML). + + * Connection is terminated after the document transfer is complete. + + + + +However, even that sounds a lot more complicated than it really is. What these rules enable is an extremely simple, Telnet-friendly protocol, which some web servers support to this very day: + +``` +$> telnet google.com 80 + +Connected to 74.125.xxx.xxx + +GET /about/ + +(hypertext response) +(connection closed) +``` + +The request consists of a single line: `GET` method and the path of the requested document. The response is a single hypertext document—no headers or any other metadata, just the HTML. It really couldn’t get any simpler. Further, since the previous interaction is a subset of the intended protocol, it unofficially acquired the HTTP 0.9 label. The rest, as they say, is history. + +From these humble beginnings in 1991, HTTP took on a life of its own and evolved rapidly over the coming years. Let us quickly recap the features of HTTP 0.9: + + * Client-server, request-response protocol. + + * ASCII protocol, running over a TCP/IP link. + + * Designed to transfer hypertext documents (HTML). + + * The connection between server and client is closed after every request. + + +``` +Popular web servers, such as Apache and Nginx, still support the HTTP 0.9 protocol—in part, because there is not much to it! If you are curious, open up a Telnet session and try accessing google.com, or your own favorite site, via HTTP 0.9 and inspect the behavior and the limitations of this early protocol. +``` + +### §HTTP/1.0: Rapid Growth and Informational RFC + +The period from 1991 to 1995 is one of rapid coevolution of the HTML specification, a new breed of software known as a "web browser," and the emergence and quick growth of the consumer-oriented public Internet infrastructure. + +``` +##### §The Perfect Storm: Internet Boom of the Early 1990s + +Building on Tim Berner-Lee’s initial browser prototype, a team at the National Center of Supercomputing Applications (NCSA) decided to implement their own version. With that, the first popular browser was born: NCSA Mosaic. One of the programmers on the NCSA team, Marc Andreessen, partnered with Jim Clark to found Mosaic Communications in October 1994. The company was later renamed Netscape, and it shipped Netscape Navigator 1.0 in December 1994. By this point, it was already clear that the World Wide Web was bound to be much more than just an academic curiosity. + +In fact, that same year the first World Wide Web conference was organized in Geneva, Switzerland, which led to the creation of the World Wide Web Consortium (W3C) to help guide the evolution of HTML. Similarly, a parallel HTTP Working Group (HTTP-WG) was established within the IETF to focus on improving the HTTP protocol. Both of these groups continue to be instrumental to the evolution of the Web. + +Finally, to create the perfect storm, CompuServe, AOL, and Prodigy began providing dial-up Internet access to the public within the same 1994–1995 time frame. Riding on this wave of rapid adoption, Netscape made history with a wildly successful IPO on August 9, 1995—the Internet boom had arrived, and everyone wanted a piece of it! +``` + +The growing list of desired capabilities of the nascent Web and their use cases on the public Web quickly exposed many of the fundamental limitations of HTTP 0.9: we needed a protocol that could serve more than just hypertext documents, provide richer metadata about the request and the response, enable content negotiation, and more. In turn, the nascent community of web developers responded by producing a large number of experimental HTTP server and client implementations through an ad hoc process: implement, deploy, and see if other people adopt it. + +From this period of rapid experimentation, a set of best practices and common patterns began to emerge, and in May 1996 the HTTP Working Group (HTTP-WG) published RFC 1945, which documented the "common usage" of the many HTTP/1.0 implementations found in the wild. Note that this was only an informational RFC: HTTP/1.0 as we know it is not a formal specification or an Internet standard! + +Having said that, an example HTTP/1.0 request should look very familiar: + +``` +$> telnet website.org 80 + +Connected to xxx.xxx.xxx.xxx + +GET /rfc/rfc1945.txt HTTP/1.0 +User-Agent: CERN-LineMode/2.15 libwww/2.17b3 +Accept: */* + +HTTP/1.0 200 OK +Content-Type: text/plain +Content-Length: 137582 +Expires: Thu, 01 Dec 1997 16:00:00 GMT +Last-Modified: Wed, 1 May 1996 12:45:26 GMT +Server: Apache 0.84 + +(plain-text response) +(connection closed) +``` + + 1. Request line with HTTP version number, followed by request headers + + 2. Response status, followed by response headers + + + + +The preceding exchange is not an exhaustive list of HTTP/1.0 capabilities, but it does illustrate some of the key protocol changes: + + * Request may consist of multiple newline separated header fields. + + * Response object is prefixed with a response status line. + + * Response object has its own set of newline separated header fields. + + * Response object is not limited to hypertext. + + * The connection between server and client is closed after every request. + + + + +Both the request and response headers were kept as ASCII encoded, but the response object itself could be of any type: an HTML file, a plain text file, an image, or any other content type. Hence, the "hypertext transfer" part of HTTP became a misnomer not long after its introduction. In reality, HTTP has quickly evolved to become a hypermedia transport, but the original name stuck. + +In addition to media type negotiation, the RFC also documented a number of other commonly implemented capabilities: content encoding, character set support, multi-part types, authorization, caching, proxy behaviors, date formats, and more. + +``` +Almost every server on the Web today can and will still speak HTTP/1.0. Except that, by now, you should know better! Requiring a new TCP connection per request imposes a significant performance penalty on HTTP/1.0; see [Three-Way Handshake][1], followed by [Slow-Start][2]. +``` + +### §HTTP/1.1: Internet Standard + +The work on turning HTTP into an official IETF Internet standard proceeded in parallel with the documentation effort around HTTP/1.0 and happened over a period of roughly four years: between 1995 and 1999. In fact, the first official HTTP/1.1 standard is defined in RFC 2068, which was officially released in January 1997, roughly six months after the publication of HTTP/1.0. Then, two and a half years later, in June of 1999, a number of improvements and updates were incorporated into the standard and were released as RFC 2616. + +The HTTP/1.1 standard resolved a lot of the protocol ambiguities found in earlier versions and introduced a number of critical performance optimizations: keepalive connections, chunked encoding transfers, byte-range requests, additional caching mechanisms, transfer encodings, and request pipelining. + +With these capabilities in place, we can now inspect a typical HTTP/1.1 session as performed by any modern HTTP browser and client: + +``` +$> telnet website.org 80 +Connected to xxx.xxx.xxx.xxx + +GET /index.html HTTP/1.1 +Host: website.org +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4)... (snip) +Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 +Accept-Encoding: gzip,deflate,sdch +Accept-Language: en-US,en;q=0.8 +Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 +Cookie: __qca=P0-800083390... (snip) + +HTTP/1.1 200 OK +Server: nginx/1.0.11 +Connection: keep-alive +Content-Type: text/html; charset=utf-8 +Via: HTTP/1.1 GWA +Date: Wed, 25 Jul 2012 20:23:35 GMT +Expires: Wed, 25 Jul 2012 20:23:35 GMT +Cache-Control: max-age=0, no-cache +Transfer-Encoding: chunked + +100 + +(snip) + +100 +(snip) + +0 + +GET /favicon.ico HTTP/1.1 +Host: www.website.org +User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4)... (snip) +Accept: */* +Referer: http://website.org/ +Connection: close +Accept-Encoding: gzip,deflate,sdch +Accept-Language: en-US,en;q=0.8 +Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 +Cookie: __qca=P0-800083390... (snip) + +HTTP/1.1 200 OK +Server: nginx/1.0.11 +Content-Type: image/x-icon +Content-Length: 3638 +Connection: close +Last-Modified: Thu, 19 Jul 2012 17:51:44 GMT +Cache-Control: max-age=315360000 +Accept-Ranges: bytes +Via: HTTP/1.1 GWA +Date: Sat, 21 Jul 2012 21:35:22 GMT +Expires: Thu, 31 Dec 2037 23:55:55 GMT +Etag: W/PSA-GAu26oXbDi + +(icon data) +(connection closed) +``` + + 1. Request for HTML file, with encoding, charset, and cookie metadata + + 2. Chunked response for original HTML request + + 3. Number of octets in the chunk expressed as an ASCII hexadecimal number (256 bytes) + + 4. End of chunked stream response + + 5. Request for an icon file made on same TCP connection + + 6. Inform server that the connection will not be reused + + 7. Icon response, followed by connection close + + + + +Phew, there is a lot going on in there! The first and most obvious difference is that we have two object requests, one for an HTML page and one for an image, both delivered over a single connection. This is connection keepalive in action, which allows us to reuse the existing TCP connection for multiple requests to the same host and deliver a much faster end-user experience; see [Optimizing for TCP][3]. + +To terminate the persistent connection, notice that the second client request sends an explicit `close` token to the server via the `Connection` header. Similarly, the server can notify the client of the intent to close the current TCP connection once the response is transferred. Technically, either side can terminate the TCP connection without such signal at any point, but clients and servers should provide it whenever possible to enable better connection reuse strategies on both sides. + +``` +HTTP/1.1 changed the semantics of the HTTP protocol to use connection keepalive by default. Meaning, unless told otherwise (via `Connection: close` header), the server should keep the connection open by default. + +However, this same functionality was also backported to HTTP/1.0 and enabled via the `Connection: Keep-Alive` header. Hence, if you are using HTTP/1.1, technically you don’t need the `Connection: Keep-Alive` header, but many clients choose to provide it nonetheless. +``` + +Additionally, the HTTP/1.1 protocol added content, encoding, character set, and even language negotiation, transfer encoding, caching directives, client cookies, plus a dozen other capabilities that can be negotiated on each request. + +We are not going to dwell on the semantics of every HTTP/1.1 feature. This is a subject for a dedicated book, and many great ones have been written already. Instead, the previous example serves as a good illustration of both the quick progress and evolution of HTTP, as well as the intricate and complicated dance of every client-server exchange. There is a lot going on in there! + +``` +For a good reference on all the inner workings of the HTTP protocol, check out O’Reilly’s HTTP: The Definitive Guide by David Gourley and Brian Totty. +``` + +### §HTTP/2: Improving Transport Performance + +Since its publication, RFC 2616 has served as a foundation for the unprecedented growth of the Internet: billions of devices of all shapes and sizes, from desktop computers to the tiny web devices in our pockets, speak HTTP every day to deliver news, video, and millions of other web applications we have all come to depend on in our lives. + +What began as a simple, one-line protocol for retrieving hypertext quickly evolved into a generic hypermedia transport, and now a decade later can be used to power just about any use case you can imagine. Both the ubiquity of servers that can speak the protocol and the wide availability of clients to consume it means that many applications are now designed and deployed exclusively on top of HTTP. + +Need a protocol to control your coffee pot? RFC 2324 has you covered with the Hyper Text Coffee Pot Control Protocol (HTCPCP/1.0)—originally an April Fools’ Day joke by IETF, and increasingly anything but a joke in our new hyper-connected world. + +> The Hypertext Transfer Protocol (HTTP) is an application-level protocol for distributed, collaborative, hypermedia information systems. It is a generic, stateless, protocol that can be used for many tasks beyond its use for hypertext, such as name servers and distributed object management systems, through extension of its request methods, error codes and headers. A feature of HTTP is the typing and negotiation of data representation, allowing systems to be built independently of the data being transferred. +> +> RFC 2616: HTTP/1.1, June 1999 + +The simplicity of the HTTP protocol is what enabled its original adoption and rapid growth. In fact, it is now not unusual to find embedded devices—sensors, actuators, and coffee pots alike—using HTTP as their primary control and data protocols. But under the weight of its own success and as we increasingly continue to migrate our everyday interactions to the Web—social, email, news, and video, and increasingly our entire personal and job workspaces—it has also begun to show signs of stress. Users and web developers alike are now demanding near real-time responsiveness and protocol performance from HTTP/1.1, which it simply cannot meet without some modifications. + +To meet these new challenges, HTTP must continue to evolve, and hence the HTTPbis working group announced a new initiative for HTTP/2 in early 2012: + +> There is emerging implementation experience and interest in a protocol that retains the semantics of HTTP without the legacy of HTTP/1.x message framing and syntax, which have been identified as hampering performance and encouraging misuse of the underlying transport. +> +> The working group will produce a specification of a new expression of HTTP’s current semantics in ordered, bi-directional streams. As with HTTP/1.x, the primary target transport is TCP, but it should be possible to use other transports. +> +> HTTP/2 charter, January 2012 + +The primary focus of HTTP/2 is on improving transport performance and enabling both lower latency and higher throughput. The major version increment sounds like a big step, which it is and will be as far as performance is concerned, but it is important to note that none of the high-level protocol semantics are affected: all HTTP headers, values, and use cases are the same. + +Any existing website or application can and will be delivered over HTTP/2 without modification: you do not need to modify your application markup to take advantage of HTTP/2. The HTTP servers will have to speak HTTP/2, but that should be a transparent upgrade for the majority of users. The only difference if the working group meets its goal, should be that our applications are delivered with lower latency and better utilization of the network link! + +Having said that, let’s not get ahead of ourselves. Before we get to the new HTTP/2 protocol features, it is worth taking a step back and examining our existing deployment and performance best practices for HTTP/1.1. The HTTP/2 working group is making fast progress on the new specification, but even if the final standard was already done and ready, we would still have to support older HTTP/1.1 clients for the foreseeable future—realistically, a decade or more. + +-------------------------------------------------------------------------------- + +via: https://hpbn.co/brief-history-of-http/#http-09-the-one-line-protocol + +作者:[Ilya Grigorik][a] +选题:[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.igvita.com/ +[b]: https://github.com/lujun9972 +[1]: https://hpbn.co/building-blocks-of-tcp/#three-way-handshake +[2]: https://hpbn.co/building-blocks-of-tcp/#slow-start +[3]: https://hpbn.co/building-blocks-of-tcp/#optimizing-for-tcp diff --git a/sources/tech/20181123 Three SSH GUI Tools for Linux.md b/sources/tech/20181123 Three SSH GUI Tools for Linux.md deleted file mode 100644 index 9691a737ca..0000000000 --- a/sources/tech/20181123 Three SSH GUI Tools for Linux.md +++ /dev/null @@ -1,176 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: subject: (Three SSH GUI Tools for Linux) -[#]: via: (https://www.linux.com/blog/learn/intro-to-linux/2018/11/three-ssh-guis-linux) -[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen) -[#]: url: ( ) - -Three SSH GUI Tools for Linux -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh.jpg?itok=3UcXhJt7) - -At some point in your career as a Linux administrator, you’re going to use Secure Shell (SSH) to remote into a Linux server or desktop. Chances are, you already have. In some instances, you’ll be SSH’ing into multiple Linux servers at once. In fact, Secure Shell might well be one of the most-used tools in your Linux toolbox. Because of this, you’ll want to make the experience as efficient as possible. For many admins, nothing is as efficient as the command line. However, there are users out there who do prefer a GUI tool, especially when working from a desktop machine to remote into and work on a server. - -If you happen to prefer a good GUI tool, you’ll be happy to know there are a couple of outstanding graphical tools for SSH on Linux. Couple that with a unique terminal window that allows you to remote into multiple machines from the same window, and you have everything you need to work efficiently. Let’s take a look at these three tools and find out if one (or more) of them is perfectly apt to meet your needs. - -I’ll be demonstrating these tools on [Elementary OS][1], but they are all available for most major distributions. - -### PuTTY - -Anyone that’s been around long enough knows about [PuTTY][2]. In fact, PuTTY is the de facto standard tool for connecting, via SSH, to Linux servers from the Windows environment. But PuTTY isn’t just for Windows. In fact, from withing the standard repositories, PuTTY can also be installed on Linux. PuTTY’s feature list includes: - - * Saved sessions. - - * Connect via IP address or hostname. - - * Define alternative SSH port. - - * Connection type definition. - - * Logging. - - * Options for keyboard, bell, appearance, connection, and more. - - * Local and remote tunnel configuration - - * Proxy support - - * X11 tunneling support - - - - -The PuTTY GUI is mostly a way to save SSH sessions, so it’s easier to manage all of those various Linux servers and desktops you need to constantly remote into and out of. Once you’ve connected, from PuTTY to the Linux server, you will have a terminal window in which to work. At this point, you may be asking yourself, why not just work from the terminal window? For some, the convenience of saving sessions does make PuTTY worth using. - -Installing PuTTY on Linux is simple. For example, you could issue the command on a Debian-based distribution: - -``` -sudo apt-get install -y putty -``` - -Once installed, you can either run the PuTTY GUI from your desktop menu or issue the command putty. In the PuTTY Configuration window (Figure 1), type the hostname or IP address in the HostName (or IP address) section, configure the port (if not the default 22), select SSH from the connection type, and click Open. - -![PuTTY Connection][4] - -Figure 1: The PuTTY Connection Configuration Window. - -[Used with permission][5] - -Once the connection is made, you’ll then be prompted for the user credentials on the remote server (Figure 2). - -![log in][7] - -Figure 2: Logging into a remote server with PuTTY. - -[Used with permission][5] - -To save a session (so you don’t have to always type the remote server information), fill out the IP address (or hostname), configure the port and connection type, and then (before you click Open), type a name for the connection in the top text area of the Saved Sessions section, and click Save. This will then save the configuration for the session. To then connect to a saved session, select it from the saved sessions window, click Load, and then click Open. You should then be prompted for the remote credentials on the remote server. - -### EasySSH - -Although [EasySSH][8] doesn’t offer the amount of configuration options found in PuTTY, it’s (as the name implies) incredibly easy to use. One of the best features of EasySSH is that it offers a tabbed interface, so you can have multiple SSH connections open and quickly switch between them. Other EasySSH features include: - - * Groups (so you can group tabs for an even more efficient experience). - - * Username/password save. - - * Appearance options. - - * Local and remote tunnel support. - - - - -Install EasySSH on a Linux desktop is simple, as the app can be installed via flatpak (which does mean you must have Flatpak installed on your system). Once flatpak is installed, add EasySSH with the commands: - -``` -sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo - -sudo flatpak install flathub com.github.muriloventuroso.easyssh -``` - -Run EasySSH with the command: - -``` -flatpak run com.github.muriloventuroso.easyssh -``` - -The EasySSH app will open, where you can click the + button in the upper left corner. In the resulting window (Figure 3), configure your SSH connection as required. - -![Adding a connection][10] - -Figure 3: Adding a connection in EasySSH is simple. - -[Used with permission][5] - -Once you’ve added the connection, it will appear in the left navigation of the main window (Figure 4). - -![EasySSH][12] - -Figure 4: The EasySSH main window. - -[Used with permission][5] - -To connect to a remote server in EasySSH, select it from the left navigation and then click the Connect button (Figure 5). - -![Connecting][14] - -Figure 5: Connecting to a remote server with EasySSH. - -[Used with permission][5] - -The one caveat with EasySSH is that you must save the username and password in the connection configuration (otherwise the connection will fail). This means anyone with access to the desktop running EasySSH can remote into your servers without knowing the passwords. Because of this, you must always remember to lock your desktop screen any time you are away (and make sure to use a strong password). The last thing you want is to have a server vulnerable to unwanted logins. - -### Terminator - -Terminator is not actually an SSH GUI. Instead, Terminator functions as a single window that allows you to run multiple terminals (and even groups of terminals) at once. Effectively you can open Terminator, split the window vertical and horizontally (until you have all the terminals you want), and then connect to all of your remote Linux servers by way of the standard SSH command (Figure 6). - -![Terminator][16] - -Figure 6: Terminator split into three different windows, each connecting to a different Linux server. - -[Used with permission][5] - -To install Terminator, issue a command like: - -### sudo apt-get install -y terminator - -Once installed, open the tool either from your desktop menu or from the command terminator. With the window opened, you can right-click inside Terminator and select either Split Horizontally or Split Vertically. Continue splitting the terminal until you have exactly the number of terminals you need, and then start remoting into those servers. -The caveat to using Terminator is that it is not a standard SSH GUI tool, in that it won’t save your sessions or give you quick access to those servers. In other words, you will always have to manually log into your remote Linux servers. However, being able to see your remote Secure Shell sessions side by side does make administering multiple remote machines quite a bit easier. - -Few (But Worthwhile) Options - -There aren’t a lot of SSH GUI tools available for Linux. Why? Because most administrators prefer to simply open a terminal window and use the standard command-line tools to remotely access their servers. However, if you have a need for a GUI tool, you have two solid options and one terminal that makes logging into multiple machines slightly easier. Although there are only a few options for those looking for an SSH GUI tool, those that are available are certainly worth your time. Give one of these a try and see for yourself. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/learn/intro-to-linux/2018/11/three-ssh-guis-linux - -作者:[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://elementary.io/ -[2]: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html -[3]: https://www.linux.com/files/images/sshguis1jpg -[4]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_1.jpg?itok=DiNTz_wO (PuTTY Connection) -[5]: https://www.linux.com/licenses/category/used-permission -[6]: https://www.linux.com/files/images/sshguis2jpg -[7]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_2.jpg?itok=4ORsJlz3 (log in) -[8]: https://github.com/muriloventuroso/easyssh -[9]: https://www.linux.com/files/images/sshguis3jpg -[10]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_3.jpg?itok=bHC2zlda (Adding a connection) -[11]: https://www.linux.com/files/images/sshguis4jpg -[12]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_4.jpg?itok=hhJzhRIg (EasySSH) -[13]: https://www.linux.com/files/images/sshguis5jpg -[14]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_5.jpg?itok=piFEFYTQ (Connecting) -[15]: https://www.linux.com/files/images/sshguis6jpg -[16]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/ssh_guis_6.jpg?itok=-kYl6iSE (Terminator) diff --git a/sources/tech/20181124 14 Best ASCII Games for Linux That are Insanely Good.md b/sources/tech/20181124 14 Best ASCII Games for Linux That are Insanely Good.md deleted file mode 100644 index 094467698b..0000000000 --- a/sources/tech/20181124 14 Best ASCII Games for Linux That are Insanely Good.md +++ /dev/null @@ -1,335 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: subject: (14 Best ASCII Games for Linux That are Insanely Good) -[#]: via: (https://itsfoss.com/best-ascii-games/) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) -[#]: url: ( ) - -14 Best ASCII Games for Linux That are Insanely Good -====== - -Text-based or should I say [terminal-based games][1] were very popular a decade back – when you didn’t have visual masterpieces like God Of War, Red Dead Redemption 2 or Spiderman. - -Of course, the Linux platform has its share of good games – but not always the “latest and greatest”. But, there are some ASCII games out there – to which you can never turn your back on. - -I’m not sure if you’d believe me, some of the ASCII games proved to be very addictive (So, it might take a while for me to resume work on the next article, or I might just get fired? – Help me!) - -Jokes apart, let us take a look at the best ASCII games. - -**Note:** Installing ASCII games could be time-consuming (some might ask you to install additional dependencies or simply won’t work). You might even encounter some ASCII games that require you build from Source. So, we’ve filtered out only the ones that are easy to install/run – without breaking a sweat. - -### Things to do before Running or Installing an ASCII Game - -Some of the ASCII games might require you to install [Simple DirectMedia Layer][2] unless you already have it installed. So, in case, you should install them first before trying to run any of the games mentioned in this article. - -For that, you just need to type in these commands: - -``` -sudo apt install libsdl2-2.0 -``` - -``` -sudo apt install libsdl2_mixer-2.0 -``` - - -### Best ASCII Games for Linux - -![Best Ascii games for Linux][3] - -The games listed are in no particular order of ranking. - -#### 1 . [Curse of War][4] - -![Curse of War ascii games][5] - -Curse of War is an interesting strategy game. You might find it a bit confusing at first but once you get to know it – you’ll love it. I’ll recommend you to take a look at the rules of the game on their [homepage][4] before launching the game. - -You will be building infrastructure, secure resources and directing your army to fight. All you have to do is place your flag in a good position to let your army take care of the rest. It’s not just about attacking – you need to manage and secure the resources to help win the fight. - -If you’ve never played any ASCII game before, be patient and spend some time learning it – to experience it to its fullest potential. - -##### How to install Curse of War? - -You will find it in the official repository. So, type in the following command to install it: - -``` -sudo apt install curseofwar -``` -#### 2. ASCII Sector - -![ascii sector][6] - -Hate strategy games? Fret not, ASCII sector is a game that has a space-setting and lets you explore a lot. - -Also, the game isn’t just limited to exploration, you need some action? You got that here as well. Of course, not the best combat experience- but it is fun. It gets even more exciting when you see a variety of bases, missions, and quests. You’ll encounter a leveling system in this tiny game where you have to earn enough money or trade in order upgrade your spaceship. - -The best part about this game is – you can create your own quests or play other’s. - -###### How to install ASCII Sector? - -You need to first download and unpack the archived package from the [official site][7]. After it’s done, open up your terminal and type these commands (replace the **Downloads** folder with your location where the unpacked folder exists, ignore it if the unpacked folder resides inside your home directory): - -``` -cd Downloads -cd asciisec -chmod +x asciisec -./asciisec -``` - -#### 3. DoomRL - -![doom ascii game][8] - -You must be knowing the classic game “Doom”. So, if you want the scaled down experience of it as a rogue-like, DoomRL is for you. It is an ASCII-based game, in case you don’t feel like it to be. - -It’s a very tiny game with a lot of gameplay hours to have fun with. - -###### How to install DoomRL? - -Similar to what you did for ASCII Sector, you need to download the official archive from their [download page][9] and then extract it to a folder. - -After extracting it, type in these commands: - -``` -cd Downloads // navigating to the location where the unpacked folder exists -``` - -``` -cd doomrl-linux-x64-0997 -chmod +x doomrl -./doomrl -``` -#### 4. Pyramid Builder - -![Pyramid Builder ascii game for Linux][10] - -Pyramid Builder is an innovative take as an ASCII game where get to improve your civilization by helping build pyramids. - -You need to direct the workers to farm, unload the cargo, and move the gigantic stones to successfully build the pyramid. - -It is indeed a beautiful ASCII game to download. - -###### How to install Pyramid Builder? - -Simply head to its official site and download the package to unpack it. After extraction, navigate to the folder and run the executable file. - -``` -cd Downloads -cd pyramid_builder_linux -chmod +x pyramid_builder_linux.x86_64 -./pyramid_builder_linux.x86_64 -``` -#### 5. DiabloRL - -![Diablo ascii RPG game][11] - -If you’re an avid gamer, you must have heard about Blizzard’s Diablo 1. It is undoubtedly a good game. - -You get the chance to play a unique rendition of the game – which is an ASCII game. DiabloRL is a turn-based rogue-like game that is insanely good. You get to choose from a variety of classes (Warrior, Sorcerer, or Rogue). Every class would result in a different gameplay experience with a set of different stats. - -Of course, personal preference will differ – but it’s a decent “unmake” of Diablo. What do you think? - -#### 6. Ninvaders - -![Ninvaders terminal game for Linux][12] - -Ninvaders is one of the best ASCII game just because it’s so simple and an arcade game to kill time. - -You have to defend against a hord of invaders – just finish them off before they get to you. It sounds very simple – but it is a challenging game. - -##### How to install Ninvaders? - -Similar to Curse of War, you can find this in the official repository. So, just type in this command to install it: - -``` -sudo apt install ninvaders  -``` -#### 7. Empire - -![Empire terminal game][13] - -A real-time strategy game for which you will need an active Internet connection. I’m personally not a fan of Real-Time strategy games, but if you are a fan of such games – you should really check out their [guide][14] to play this game – because it can be very challenging to learn. - -The rectangle contains cities, land, and water. You need to expand your city with an army, ships, planes and other resources. By expanding quickly, you will be able to capture other cities by destroying them before they make a move. - -##### How to install Empire? - -Install this is very simple, just type in the following command: - -``` -sudo apt install empire -``` - -#### 8. Nudoku - -![Nudoku is a terminal version game of Sudoku][15] - -Love Sudoku? Well, you have Nudoku – a clone for it. A perfect time-killing ASCII game while you relax. - -It presents you with three difficulty levels – Easy, normal, and hard. If you want to put up a challenge with the computer, the hard difficulty will be perfect! If you just want to chill, go for the easy one. - -##### How to install Nudoku? - -It’s very easy to get it installed, just type in the following command in the terminal: - -``` -sudo apt install nudoku -``` - -#### 9\. Nethack - -A dungeons and dragon-style ASCII game which is one of the best out there. I believe it’s one of your favorites if you already knew about ASCII games for Linux – in general. - -It features a lot of different levels (about 45) and comes packed in with a bunch of weapons, scrolls, potions, armor, rings, and gems. You can also choose permadeath as your mode to play it. - -It’s not just about killing here – you got a lot to explore. - -##### How to install Nethack? - -Simply follow the command below to install it: - -``` -sudo apt install nethack -``` - -#### 10. ASCII Jump - -![ascii jump game][16] - -ASCII Jump is a dead simple game where you have to slide along a varierty of tracks – while jumping, changing position, and moving as long as you can to cover maximum distance. - -It’s really amazing to see how this ASCII game looks like (visually) even it seems so simple. You can start with the training mode and then proceed to the world cup. You also get to choose your competitors and the hills on which you want to start the game. - -##### How to install Ascii Jump? - -To install the game, just type the following command: - -``` -sudo apt install asciijump -``` - -#### 11. Bastet - -![Bastet is tetris game in ascii form][17] - -Let’s just not pay any attention to the name – it’s actually a fun clone of Tetris game. - -You shouldn’t expect it to be just another ordinary tetris game – but it will present you the worst possible bricks to play with. Have fun! - -##### How to install Bastet? - -Open the terminal and type in the following command: - -``` -sudo apt install bastet -``` - -#### 12\. Bombardier - -![Bomabrdier game in ascii form][18] - -Bombardier is yet another simple ASCII game which will keep you hooked on to it. - -Here, you have a helicopter (or whatever you’d like to call your aircraft) which lowers down every cycle and you need to throw bombs in order to destroy the blocks/buildings under you. The game also puts a pinch of humor for the messages it displays when you destroy a block. It is fun. - -##### How to install Bombardier? - -Bombardier is available in the official repository, so just type in the following in the terminal to install it: - -``` -sudo apt install bombardier -``` - -#### 13\. Angband - -![Angband ascii game][19] - -A cool dungeon exploration game with a neat interface. You can see all the vital information in a single screen while you explore the game. - -It contains different kinds of race to pick a character. You can either be an Elf, Hobbit, Dwarf or something else – there’s nearly a dozen to choose from. Remember, that you need to defeat the lord of darkness at the end – so make every upgrade possible to your weapon and get ready. - -How to install Angband? - -Simply type in the following command: - -``` -sudo apt install angband -``` - -#### 14\. GNU Chess - -![GNU Chess is a chess game that you can play in Linux terminal][20] - -How can you not play chess? It is my favorite strategy game! - -But, GNU Chess can be tough to play with unless you know the Algebraic notation to describe the next move. Of course, being an ASCII game – it isn’t quite possible to interact – so it asks you the notation to detect your move and displays the output (while it waits for the computer to think its next move). - -##### How to install GNU Chess? - -If you’re aware of the algebraic notations of Chess, enter the following command to install it from the terminal: - -``` -sudo apt install gnuchess -``` - -#### Some Honorable Mentions - -As I mentioned earlier, we’ve tried to recommend you the best (but also the ones that are the easiest to install on your Linux machine). - -However, there are some iconic ASCII games which deserve the attention and requires a tad more effort to install (You will get the source code and you need to build it / install it). - -Some of those games are: - -+ [Cataclysm: Dark Days Ahead][22] -+ [Brogue][23] -+ [Dwarf Fortress][24] - -You should follow our [guide to install software from source code][21]. - -### Wrapping Up - -Which of the ASCII games mentioned seem perfect for you? Did we miss any of your favorites? - -Let us know your thoughts in the comments below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/best-ascii-games/ - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://itsfoss.com/best-command-line-games-linux/ -[2]: https://www.libsdl.org/ -[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/best-ascii-games-featured.png?resize=800%2C450&ssl=1 -[4]: http://a-nikolaev.github.io/curseofwar/ -[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/11/curseofwar-ascii-game.jpg?fit=800%2C479&ssl=1 -[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/ascii-sector-game.jpg?fit=800%2C424&ssl=1 -[7]: http://www.asciisector.net/download/ -[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/doom-rl-ascii-game.jpg?ssl=1 -[9]: https://drl.chaosforge.org/downloads -[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/pyramid-builder-ascii-game.jpg?fit=800%2C509&ssl=1 -[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/diablo-rl-ascii-game.jpg?ssl=1 -[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/ninvaders-ascii-game.jpg?fit=800%2C426&ssl=1 -[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/empire-ascii-game.jpg?fit=800%2C570&ssl=1 -[14]: http://www.wolfpackempire.com/infopages/Guide.html -[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/11/nudoku-ascii-game.jpg?fit=800%2C434&ssl=1 -[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/11/ascii-jump.jpg?fit=800%2C566&ssl=1 -[17]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/bastet-tetris-clone-ascii.jpg?fit=800%2C465&ssl=1 -[18]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2018/11/bombardier.jpg?fit=800%2C571&ssl=1 -[19]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2018/11/angband-ascii-game.jpg?ssl=1 -[20]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2018/11/gnuchess-ascii-game.jpg?ssl=1 -[21]: https://itsfoss.com/install-software-from-source-code/ -[22]: https://github.com/CleverRaven/Cataclysm-DDA -[23]: https://sites.google.com/site/broguegame/ -[24]: http://www.bay12games.com/dwarves/index.html - diff --git a/sources/tech/20181204 4 Unique Terminal Emulators for Linux.md b/sources/tech/20181204 4 Unique Terminal Emulators for Linux.md deleted file mode 100644 index 04110b670e..0000000000 --- a/sources/tech/20181204 4 Unique Terminal Emulators for Linux.md +++ /dev/null @@ -1,169 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (4 Unique Terminal Emulators for Linux) -[#]: via: (https://www.linux.com/blog/learn/2018/12/4-unique-terminals-linux) -[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen) - -4 Unique Terminal Emulators for Linux -====== -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_main.jpg?itok=e6av-5VO) -Let’s face it, if you’re a Linux administrator, you’re going to work with the command line. To do that, you’ll be using a terminal emulator. Most likely, your distribution of choice came pre-installed with a default terminal emulator that gets the job done. But this is Linux, so you have a wealth of choices to pick from, and that ideology holds true for terminal emulators as well. In fact, if you open up your distribution’s GUI package manager (or search from the command line), you’ll find a trove of possible options. Of those, many are pretty straightforward tools; however, some are truly unique. - -In this article, I’ll highlight four such terminal emulators, that will not only get the job done, but do so while making the job a bit more interesting or fun. So, let’s take a look at these terminals. - -### Tilda - -[Tilda][1] is designed for Gtk and is a member of the cool drop-down family of terminals. That means the terminal is always running in the background, ready to drop down from the top of your monitor (such as Guake and Yakuake). What makes Tilda rise above many of the others is the number of configuration options available for the terminal (Figure 1). -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_1.jpg?itok=bra6qb6X) - -Tilda can be installed from the standard repositories. On a Ubuntu- (or Debian-) based distribution, the installation is as simple as: - -``` -sudo apt-get install tilda -y -``` - -Once installed, open Tilda from your desktop menu, which will also open the configuration window. Configure the app to suit your taste and then close the configuration window. You can then open and close Tilda by hitting the F1 hotkey. One caveat to using Tilda is that, after the first run, you won’t find any indication as to how to reach the configuration wizard. No worries. If you run the command tilda -C it will open the configuration window, while still retaining the options you’ve previously set. - -Available options include: - - * Terminal size and location - - * Font and color configurations - - * Auto Hide - - * Title - - * Custom commands - - * URL Handling - - * Transparency - - * Animation - - * Scrolling - - * And more - - - - -What I like about these types of terminals is that they easily get out of the way when you don’t need them and are just a button click away when you do. For those that hop in and out of the terminal, a tool like Tilda is ideal. - -### Aterm - -Aterm holds a special place in my heart, as it was one of the first terminals I used that made me realize how flexible Linux was. This was back when AfterStep was my window manager of choice (which dates me a bit) and I was new to the command line. What Aterm offered was a terminal emulator that was highly customizable, while helping me learn the ins and outs of using the terminal (how to add options and switches to a command). “How?” you ask. Because Aterm never had a GUI for customization. To run Aterm with any special options, it had to run as a command. For example, say you want to open Aterm with transparency enabled, green text, white highlights, and no scroll bar. To do this, issue the command: - -``` -aterm -tr -fg green -bg white +xb -``` - -The end result (with the top command running for illustration) would look like that shown in Figure 2. - -![Aterm][3] - -Figure 2: Aterm with a few custom options. - -[Used with permission][4] - -Of course, you must first install Aterm. Fortunately, the application is still found in the standard repositories, so installing on the likes of Ubuntu is as simple as: - -``` -sudo apt-get install aterm -y -``` - -If you want to always open Aterm with those options, your best bet is to create an alias in your ~/.bashrc file like so: - -``` -alias=”aterm -tr -fg green -bg white +sb” -``` - -Save that file and, when you issue the command aterm, it will always open with those options. For more about creating aliases, check out [this tutorial][5]. - -### Eterm - -Eterm is the second terminal that really showed me how much fun the Linux command line could be. Eterm is the default terminal emulator for the Enlightenment desktop. When I eventually migrated from AfterStep to Enlightenment (back in the early 2000s), I was afraid I’d lose out on all those cool aesthetic options. That turned out to not be the case. In fact, Eterm offered plenty of unique options, while making the task easier with a terminal toolbar. With Eterm, you can easily select from a large number of background images (should you want one - Figure 3) by selecting from the Background > Pixmap menu entry. - -![Eterm][7] - -Figure 3: Selecting from one of the many background images for Eterm. - -[Used with permission][4] - -There are a number of other options to configure (such as font size, map alerts, toggle scrollbar, brightness, contrast, and gamma of background images, and more). The one thing you want to make sure is, after you’ve configured Eterm to suit your tastes, to click Eterm > Save User Settings (otherwise, all settings will be lost when you close the app). - -Eterm can be installed from the standard repositories, with a command such as: - -``` -sudo apt-get install eterm -``` - -### Extraterm - -[Extraterm][8] should probably win a few awards for coolest feature set of any terminal window project available today. The most unique feature of Extraterm is the ability to wrap commands in color-coded frames (blue for successful commands and red for failed commands - Figure 4). - -![Extraterm][10] - -Figure 4: Extraterm showing two failed command frames. - -[Used with permission][4] - -When you run a command, Extraterm will wrap the command in an isolated frame. If the command succeeds, the frame will be outlined in blue. Should the command fail, the frame will be outlined in red. - -Extraterm cannot be installed via the standard repositories. In fact, the only way to run Extraterm on Linux (at the moment) is to [download the precompiled binary][11] from the project’s GitHub page, extract the file, change into the newly created directory, and issue the command ./extraterm. - -Once the app is running, to enable frames you must first enable bash integration. To do that, open Extraterm and then right-click anywhere in the window to reveal the popup menu. Scroll until you see the entry for Inject Bash shell Integration (Figure 5). Select that entry and you can then begin using the frames option. - -![Extraterm][13] - -Figure 5: Injecting Bash integration for Extraterm. - -[Used with permission][4] - -If you run a command, and don’t see a frame appear, you probably have to create a new frame for the command (as Extraterm only ships with a few default frames). To do that, click on the Extraterm menu button (three horizontal lines in the top right corner of the window), select Settings, and then click the Frames tab. In this window, scroll down and click the New Rule button. You can then add a command you want to work with the frames option (Figure 6). - -![frames][15] - -Figure 6: Adding a new rule for frames. - -[Used with permission][4] - -If, after this, you still don’t see frames appearing, download the extraterm-commands file from the [Download page][11], extract the file, change into the newly created directory, and issue the command sh setup_extraterm_bash.sh. That should enable frames for Extraterm. -There’s plenty more options available for Extraterm. I’m convinced, once you start playing around with this new take on the terminal window, you won’t want to go back to the standard terminal. Hopefully the developer will make this app available to the standard repositories soon (as it could easily become one of the most popular terminal windows in use). - -### And Many More - -As you probably expected, there are quite a lot of terminals available for Linux. These four represent (at least for me) four unique takes on the task, each of which do a great job of helping you run the commands every Linux admin needs to run. If you aren’t satisfied with one of these, give your package manager a look to see what’s available. You are sure to find something that works perfectly for you. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/learn/2018/12/4-unique-terminals-linux - -作者:[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]: http://tilda.sourceforge.net/tildadoc.php -[2]: https://www.linux.com/files/images/terminals2jpg -[3]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_2.jpg?itok=gBkRLwDI (Aterm) -[4]: https://www.linux.com/licenses/category/used-permission -[5]: https://www.linux.com/blog/learn/2018/12/aliases-diy-shell-commands -[6]: https://www.linux.com/files/images/terminals3jpg -[7]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_3.jpg?itok=RVPTJAtK (Eterm) -[8]: http://extraterm.org -[9]: https://www.linux.com/files/images/terminals4jpg -[10]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_4.jpg?itok=2n01qdwO (Extraterm) -[11]: https://github.com/sedwards2009/extraterm/releases -[12]: https://www.linux.com/files/images/terminals5jpg -[13]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_5.jpg?itok=FdaE1Mpf (Extraterm) -[14]: https://www.linux.com/files/images/terminals6jpg -[15]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/terminals_6.jpg?itok=lQ1Zv5wq (frames) diff --git a/sources/tech/20181216 Schedule a visit with the Emacs psychiatrist.md b/sources/tech/20181216 Schedule a visit with the Emacs psychiatrist.md deleted file mode 100644 index 6d72cda348..0000000000 --- a/sources/tech/20181216 Schedule a visit with the Emacs psychiatrist.md +++ /dev/null @@ -1,62 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Schedule a visit with the Emacs psychiatrist) -[#]: via: (https://opensource.com/article/18/12/linux-toy-eliza) -[#]: author: (Jason Baker https://opensource.com/users/jason-baker) - -Schedule a visit with the Emacs psychiatrist -====== -Eliza is a natural language processing chatbot hidden inside of one of Linux's most popular text editors. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-eliza.png?itok=3ioiBik_) - -Welcome to another day of the 24-day-long Linux command-line toys advent calendar. If this is your first visit to the series, you might be asking yourself what a command-line toy even is. We’re figuring that out as we go, but generally, it could be a game, or any simple diversion that helps you have fun at the terminal. - -Some of you will have seen various selections from our calendar before, but we hope there’s at least one new thing for everyone. - -Today's selection is a hidden gem inside of Emacs: Eliza, the Rogerian psychotherapist, a terminal toy ready to listen to everything you have to say. - -A brief aside: While this toy is amusing, your health is no laughing matter. Please take care of yourself this holiday season, physically and mentally, and if stress and anxiety from the holidays are having a negative impact on your wellbeing, please consider seeing a professional for guidance. It really can help. - -To launch [Eliza][1], first, you'll need to launch Emacs. There's a good chance Emacs is already installed on your system, but if it's not, it's almost certainly in your default repositories. - -Since I've been pretty fastidious about keeping this series in the terminal, launch Emacs with the **-nw** flag to keep in within your terminal emulator. - -``` -$ emacs -nw -``` - -Inside of Emacs, type M-x doctor to launch Eliza. For those of you like me from a Vim background who have no idea what this means, just hit escape, type x and then type doctor. Then, share all of your holiday frustrations. - -Eliza goes way back, all the way to the mid-1960s a the MIT Artificial Intelligence Lab. [Wikipedia][2] has a rather fascinating look at her history. - -Eliza isn't the only amusement inside of Emacs. Check out the [manual][3] for a whole list of fun toys. - - -![Linux toy: eliza animated][5] - -Do you have a favorite command-line toy that you think I ought to profile? We're running out of time, but I'd still love to hear your suggestions. Let me know in the comments below, and I'll check it out. And let me know what you thought of today's amusement. - -Be sure to check out yesterday's toy, [Head to the arcade in your Linux terminal with this Pac-man clone][6], and come back tomorrow for another! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/12/linux-toy-eliza - -作者:[Jason Baker][a] -选题:[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/jason-baker -[b]: https://github.com/lujun9972 -[1]: https://www.emacswiki.org/emacs/EmacsDoctor -[2]: https://en.wikipedia.org/wiki/ELIZA -[3]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Amusements.html -[4]: /file/417326 -[5]: https://opensource.com/sites/default/files/uploads/linux-toy-eliza-animated.gif (Linux toy: eliza animated) -[6]: https://opensource.com/article/18/12/linux-toy-myman diff --git a/sources/tech/20181221 Large files with Git- LFS and git-annex.md b/sources/tech/20181221 Large files with Git- LFS and git-annex.md index 2e7b9a9b74..29a76f810f 100644 --- a/sources/tech/20181221 Large files with Git- LFS and git-annex.md +++ b/sources/tech/20181221 Large files with Git- LFS and git-annex.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (runningwater) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) @@ -96,7 +96,7 @@ via: https://anarc.at/blog/2018-12-21-large-files-with-git/ 作者:[Anarc.at][a] 选题:[lujun9972][b] -译者:[runningwater](https://github.com/runningwater) +译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 diff --git a/sources/tech/20181222 How to detect automatically generated emails.md b/sources/tech/20181222 How to detect automatically generated emails.md index 2ccaeddeee..23b509a77b 100644 --- a/sources/tech/20181222 How to detect automatically generated emails.md +++ b/sources/tech/20181222 How to detect automatically generated emails.md @@ -1,5 +1,5 @@ [#]: collector: (lujun9972) -[#]: translator: (wyxplus) +[#]: translator: ( ) [#]: reviewer: ( ) [#]: publisher: ( ) [#]: url: ( ) diff --git a/sources/tech/20181224 Go on an adventure in your Linux terminal.md b/sources/tech/20181224 Go on an adventure in your Linux terminal.md deleted file mode 100644 index f1b46340bb..0000000000 --- a/sources/tech/20181224 Go on an adventure in your Linux terminal.md +++ /dev/null @@ -1,54 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Go on an adventure in your Linux terminal) -[#]: via: (https://opensource.com/article/18/12/linux-toy-adventure) -[#]: author: (Jason Baker https://opensource.com/users/jason-baker) - -Go on an adventure in your Linux terminal -====== - -Our final day of the Linux command-line toys advent calendar ends with the beginning of a grand adventure. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/uploads/linux-toy-advent.png?itok=OImUJJI5) - -Today is the final day of our 24-day-long Linux command-line toys advent calendar. Hopefully, you've been following along, but if not, start back at [the beginning][1] and work your way through. You'll find plenty of games, diversions, and oddities for your Linux terminal. - -And while you may have seen some toys from our calendar before, we hope there’s at least one new thing for everyone. - -Today's toy was suggested by Opensource.com moderator [Joshua Allen Holm][2]: - -"If the last day of your advent calendar is not ESR's [Eric S. Raymond's] [open source release of Adventure][3], which retains use of the classic 'advent' command (Adventure in the BSD Games package uses 'adventure), I will be very, very, very disappointed. ;-)" - -What a perfect way to end our series. - -Colossal Cave Adventure (often just called Adventure), is a text-based game from the 1970s that gave rise to the entire adventure game genre. Despite its age, Adventure is still an easy way to lose hours as you explore a fantasy world, much like a Dungeons and Dragons dungeon master might lead you through an imaginary place. - -Rather than take you through the history of Adventure here, I encourage you to go read Joshua's [history of the game][4] itself and why it was resurrected and re-ported a few years ago. Then, go [clone the source][5] and follow the [installation instructions][6] to launch the game with **advent** **** on your system. Or, as Joshua mentions, another version of the game can be obtained from the **bsd-games** package, which is probably available from your default repositories in your distribution of choice. - -Do you have a favorite command-line toy that you we should have included? Our series concludes today, but we'd still love to feature some cool command-line toys in the new year. Let me know in the comments below, and I'll check it out. And let me know what you thought of today's amusement. - -Be sure to check out yesterday's toy, [The Linux command line can fetch fun from afar][7], and I'll see you next year! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/18/12/linux-toy-adventure - -作者:[Jason Baker][a] -选题:[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/jason-baker -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/article/18/12/linux-toy-boxes -[2]: https://opensource.com/users/holmja -[3]: https://gitlab.com/esr/open-adventure (https://gitlab.com/esr/open-adventure) -[4]: https://opensource.com/article/17/6/revisit-colossal-cave-adventure-open-adventure -[5]: https://gitlab.com/esr/open-adventure -[6]: https://gitlab.com/esr/open-adventure/blob/master/INSTALL.adoc -[7]: https://opensource.com/article/18/12/linux-toy-remote diff --git a/sources/tech/20190102 How To Display Thumbnail Images In Terminal.md b/sources/tech/20190102 How To Display Thumbnail Images In Terminal.md deleted file mode 100644 index 3c4105e13f..0000000000 --- a/sources/tech/20190102 How To Display Thumbnail Images In Terminal.md +++ /dev/null @@ -1,186 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( WangYueScream) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How To Display Thumbnail Images In Terminal) -[#]: via: (https://www.ostechnix.com/how-to-display-thumbnail-images-in-terminal/) -[#]: author: (SK https://www.ostechnix.com/author/sk/) - -How To Display Thumbnail Images In Terminal -====== -![](https://www.ostechnix.com/wp-content/uploads/2019/01/lsix-720x340.png) - -A while ago, we discussed about [**Fim**][1], a lightweight, CLI image viewer application used to display various type of images, such as bmp, gif, jpeg, and png etc., from command line. Today, I stumbled upon a similar utility named **‘lsix’**. It is like ‘ls’ command in Unix-like systems, but for images only. The lsix is a simple CLI utility designed to display thumbnail images in Terminal using **Sixel** graphics. For those wondering, Sixel, short for six pixels, is a type of bitmap graphics format. It uses **ImageMagick** , so almost all file formats supported by imagemagick will work fine. - -### Features - -Concerning the features of lsix, we can list the following: - - * Automatically detects if your Terminal supports Sixel graphics or not. If your Terminal doesn’t support Sixel, it will notify you to enable it. - * Automatically detects the terminal background color. It uses terminal escape sequences to try to figure out the foreground and background colors of your Terminal application and will display the thumbnails clearly. - * If there are more images in the directory, usually >21, lsix will display those images one row a a time, so you need not to wait for the entire montage to be created. - * Works well over SSH, so you can manipulate images stored on your remote web server without much hassle. - * It supports Non-bitmap graphics, such as.svg, .eps, .pdf, .xcf etc. - * Written in BASH, so works on almost all Linux distros. - - - -### Installing lsix - -Since lsix uses ImageMagick, make sure you have installed it. It is available in the default repositories of most Linux distributions. For example, on Arch Linux and its variants like Antergos, Manjaro Linux, ImageMagick can be installed using command: - -``` -$ sudo pacman -S imagemagick -``` - -On Debian, Ubuntu, Linux Mint: - -``` -$ sudo apt-get install imagemagick -``` - -lsix doesn’t require any installation as it is just a BASH script. Just download it and move it to your $PATH. It’s that simple. - -Download the latest lsix version from project’s github page. I am going to download the lsix archive file using command: - -``` -$ wget https://github.com/hackerb9/lsix/archive/master.zip -``` - -Extract the downloaded zip file: - -``` -$ unzip master.zip -``` - -This command will extract all contents into a folder named ‘lsix-master’. Copy the lsix binary from this directory to your $PATH, for example /usr/local/bin/. - -``` -$ sudo cp lsix-master/lsix /usr/local/bin/ -``` - -Finally, make the lsbix binary executable: - -``` -$ sudo chmod +x /usr/local/bin/lsix -``` - -That’s it. Now is the time to display thumbnails in the terminal itself. - -Before start using lsix, **make sure your Terminal supports Sixel graphics**. - -The developer has developed lsix on an Xterm in **vt340 emulation mode**. However, the he claims that lsix should work on any Sixel compatible Terminal. - -Xterm supports Sixel graphics, but it isn’t enabled by default. - -You can launch Xterm with Sixel mode enabled using command (from another Terminal): - -``` -$ xterm -ti vt340 -``` - -Alternatively, you can make vt340 the default terminal type for Xterm as described below. - -Edit **.Xresources** file (If it not available, just create it): - -``` -$ vi .Xresources -``` - -Add the following line: - -``` -xterm*decTerminalID : vt340 -``` - -Press **ESC** and type **:wq** to save and close the file. - -Finally, run the following command to apply the changes: - -``` -$ xrdb -merge .Xresources -``` - -Now Xterm will start with Sixel mode enabled at every launch by default. - -### Display Thumbnail Images In Terminal - -Launch Xterm (Don’t forget to start it with vt340 mode). Here is how Xterm looks like in my system. -![](https://www.ostechnix.com/wp-content/uploads/2019/01/xterm-1.png) - -Like I already stated, lsix is very simple utility. It doesn’t have any command line flags or configuration files. All you have to do is just pass the path of your file as an argument like below. - -``` -$ lsix ostechnix/logo.png -``` - -![](https://www.ostechnix.com/wp-content/uploads/2019/01/lsix-4.png) - -If you run it without path, it will display the thumbnail images in your current working directory. I have few files in a directory named **ostechnix**. - -To display the thumbnails in this directory, just run: - -``` -$ lsix -``` - -![](https://www.ostechnix.com/wp-content/uploads/2019/01/lsix-1.png) - -See? The thumbnails of all files are displayed in the terminal itself. - -If you use ‘ls’ command, you would just see the filenames only, not thumbnails. - -![][3] - -You can also display a specific image or group of images of a specific type using wildcards. - -For example, to display a single image, just mention the full path of the image like below. - -``` -$ lsix girl.jpg -``` - -![](https://www.ostechnix.com/wp-content/uploads/2019/01/lsix-2.png) - -To display all images of a specific type, say PNG, use the wildcard character like below. - -``` -$ lsix *.png -``` - -![][4] - -For JPEG type images, the command would be: - -``` -$ lsix *jpg -``` - -The thumbnail image quality is surprisingly good. I thought lsix would just display blurry thumbnails. I was wrong. The thumbnails are clearly visible just like on the graphical image viewers. - -And, that’s all for now. As you can see, lsix is very similar to ‘ls’ command, but it only for displaying thumbnails. If you deal with a lot of images at work, lsix might be quite handy. Give it a try and let us know your thoughts on this utility in the comment section below. If you know any similar tools, please suggest them as well. I will check and update this guide. - -More good stuffs to come. Stay tuned! - -Cheers! - - - --------------------------------------------------------------------------------- - -via: https://www.ostechnix.com/how-to-display-thumbnail-images-in-terminal/ - -作者:[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/how-to-display-images-in-the-terminal/ -[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 -[3]: http://www.ostechnix.com/wp-content/uploads/2019/01/ls-command-1.png -[4]: http://www.ostechnix.com/wp-content/uploads/2019/01/lsix-3.png diff --git a/sources/tech/20190103 How to use Magit to manage Git projects.md b/sources/tech/20190103 How to use Magit to manage Git projects.md deleted file mode 100644 index dbcb63d736..0000000000 --- a/sources/tech/20190103 How to use Magit to manage Git projects.md +++ /dev/null @@ -1,93 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How to use Magit to manage Git projects) -[#]: via: (https://opensource.com/article/19/1/how-use-magit) -[#]: author: (Sachin Patil https://opensource.com/users/psachin) - -How to use Magit to manage Git projects -====== -Emacs' Magit extension makes it easy to get started with Git version control. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolseriesk12_rh_021x_0.png?itok=fvorN0e-) - -[Git][1] is an excellent [version control][2] tool for managing projects, but it can be hard for novices to learn. It's difficult to work from the Git command line unless you're familiar with the flags and options and the appropriate situations to use them. This can be discouraging and cause people to be stuck with very limited usage. - -Fortunately, most of today's integrated development environments (IDEs) include Git extensions that make using it a lot easier. One such Git extension available in Emacs is called [Magit][3]. - -The Magit project has been around for 10 years and defines itself as "a Git porcelain inside Emacs." In other words, it's an interface where every action can be managed by pressing a key. This article walks you through the Magit interface and explains how to use it to manage a Git project. - -If you haven't already, [install Emacs][4], then [install Magit][5] before you continue with this tutorial. - -### Magit's interface - -Start by visiting a project directory in Emacs' [Dired mode][6]. For example, all my Emacs configurations are stored in the **~/.emacs.d/** directory, which is managed by Git. - -![](https://opensource.com/sites/default/files/uploads/visiting_a_git_project.png) - -If you were working from the command line, you would enter **git status** to find a project's current status. Magit has a similar function: **magit-status**. You can call this function using **M-x magit-status** (short for the keystroke **Alt+x magit-status** ). Your result will look something like this: - -![](https://opensource.com/sites/default/files/uploads/magit_status.png) - -Magit shows much more information than you would get from the **git status** command. It shows a list of untracked files, files that aren't staged, and staged files. It also shows the stash list and the most recent commits—all in a single window. - -If you want to know what has changed, use the Tab key. For example, if I move my cursor over the unstaged file **custom_functions.org** and press the Tab key, Magit will display the changes: - -![](https://opensource.com/sites/default/files/uploads/show_unstaged_content.png) - -This is similar to using the command **git diff custom_functions.org**. Staging a file is even easier. Simply move the cursor over a file and press the **s** key. The file will be quickly moved to the staged file list: - -![](https://opensource.com/sites/default/files/uploads/staging_a_file.png) - -To unstage a file, use the **u** key. It is quicker and more fun to use **s** and **u** instead of entering **git add -u ** and **git reset HEAD ** on the command line. - -### Commit changes - -In the same Magit window, pressing the **c** key will display a commit window that provides flags like **\--all** to stage all files or **\--signoff** to add a signoff line to a commit message. - -![](https://opensource.com/sites/default/files/uploads/magit_commit_popup.png) - -Move your cursor to the line where you want to enable a signoff flag and press Enter. This will highlight the **\--signoff** text, which indicates that the flag is enabled. - -![](https://opensource.com/sites/default/files/uploads/magit_signoff_commit.png) - -Pressing **c** again will display the window to write the commit message. - -![](https://opensource.com/sites/default/files/uploads/magit_commit_message.png) - -Finally, use **C-c C-c **(short form of the keys Ctrl+cc) to commit the changes. - -![](https://opensource.com/sites/default/files/uploads/magit_commit_message_2.png) - -### Push changes - -Once the changes are committed, the commit line will appear in the **Recent commits** section. - -![](https://opensource.com/sites/default/files/uploads/magit_commit_log.png) - -Place the cursor on that commit and press **p** to push the changes. - -I've uploaded a [demonstration][7] on YouTube if you want to get a feel for using Magit. I have just scratched the surface in this article. It has many cool features to help you with Git branches, rebasing, and more. You can find [documentation, support, and more][8] linked from Magit's homepage. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/how-use-magit - -作者:[Sachin Patil][a] -选题:[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/psachin -[b]: https://github.com/lujun9972 -[1]: https://git-scm.com -[2]: https://git-scm.com/book/en/v2/Getting-Started-About-Version-Control -[3]: https://magit.vc -[4]: https://www.gnu.org/software/emacs/download.html -[5]: https://magit.vc/manual/magit/Installing-from-Melpa.html#Installing-from-Melpa -[6]: https://www.gnu.org/software/emacs/manual/html_node/emacs/Dired-Enter.html#Dired-Enter -[7]: https://youtu.be/Vvw75Pqp7Mc -[8]: https://magit.vc/ diff --git a/sources/tech/20190104 Midori- A Lightweight Open Source Web Browser.md b/sources/tech/20190104 Midori- A Lightweight Open Source Web Browser.md deleted file mode 100644 index a2e31daf6c..0000000000 --- a/sources/tech/20190104 Midori- A Lightweight Open Source Web Browser.md +++ /dev/null @@ -1,110 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Midori: A Lightweight Open Source Web Browser) -[#]: via: (https://itsfoss.com/midori-browser) -[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) - -Midori: A Lightweight Open Source Web Browser -====== - -**Here’s a quick review of the lightweight, fast, open source web browser Midori, which has returned from the dead.** - -If you are looking for a lightweight [alternative web browser][1], try Midori. - -[Midori][2] is an open source web browser that focuses more on being lightweight than on providing a ton of features. - -If you have never heard of Midori, you might think that it is a new application but Midori was first released in 2007. - -Because it focused on speed, Midori soon gathered a niche following and became the default browser in lightweight Linux distributions like Bodhi Linux, SilTaz etc. - -Other distributions like [elementary OS][3] also used Midori as its default browser. But the development of Midori stalled around 2016 and its fans started wondering if Midori was dead already. elementary OS dropped it from its latest release, I believe, for this reason. - -The good news is that Midori is not dead. After almost two years of inactivity, the development resumed in the last quarter of 2018. A few extensions including an ad-blocker were added in the later releases. - -### Features of Midori web browser - -![Midori web browser][4] - -Here are some of the main features of the Midori browser - - * Written in Vala with GTK+3 and WebKit rendering engine. - * Tabs, windows and session management - * Speed dial - * Saves tab for the next session by default - * Uses DuckDuckGo as a default search engine. It can be changed to Google or Yahoo. - * Bookmark management - * Customizable and extensible interface - * Extension modules can be written in C and Vala - * Supports HTML5 - * An extremely limited set of extensions include an ad-blocker, colorful tabs etc. No third-party extensions. - * Form history - * Private browsing - * Available for Linux and Windows - - - -Trivia: Midori is a Japanese word that means green. The Midori developer is not Japanese if you were guessing something along that line. - -### Experiencing Midori - -![Midori web browser in Ubuntu 18.04][5] - -I have been using Midori for the past few days. The experience is mostly fine. It supports HTML5 and renders the websites quickly. The ad-blocker is okay. The browsing experience is more or less smooth as you would expect in any standard web browser. - -The lack of extensions has always been a weak point of Midori so I am not going to talk about that. - -What I did notice is that it doesn’t support international languages. I couldn’t find a way to add new language support. It could not render the Hindi fonts at all and I am guessing it’s the same with many other non-[Romance languages][6]. - -I also had my fair share of troubles with YouTube videos. Some videos would throw playback error while others would run just fine. - -Midori didn’t eat my RAM like Chrome so that’s a big plus here. - -If you want to try out Midori, let’s see how can you get your hands on it. - -### Install Midori on Linux - -Midori is no longer available in the Ubuntu 18.04 repository. However, the newer versions of Midori can be easily installed using the [Snap packages][7]. - -If you are using Ubuntu, you can find Midori (Snap version) in the Software Center and install it from there. - -![Midori browser is available in Ubuntu Software Center][8]Midori browser is available in Ubuntu Software Center - -For other Linux distributions, make sure that you have [Snap support enabled][9] and then you can install Midori using the command below: - -``` -sudo snap install midori -``` - -You always have the option to compile from the source code. You can download the source code of Midori from its website. - -If you like Midori and want to help this open source project, please donate to them or [buy Midori merchandise from their shop][10]. - -Do you use Midori or have you ever tried it? How’s your experience with it? What other web browser do you prefer to use? Please share your views in the comment section below. - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/midori-browser - -作者:[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/open-source-browsers-linux/ -[2]: https://www.midori-browser.org/ -[3]: https://itsfoss.com/elementary-os-juno-features/ -[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/Midori-web-browser.jpeg?resize=800%2C450&ssl=1 -[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/midori-browser-linux.jpeg?resize=800%2C491&ssl=1 -[6]: https://en.wikipedia.org/wiki/Romance_languages -[7]: https://itsfoss.com/use-snap-packages-ubuntu-16-04/ -[8]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/midori-ubuntu-software-center.jpeg?ssl=1 -[9]: https://itsfoss.com/install-snap-linux/ -[10]: https://www.midori-browser.org/shop -[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/Midori-web-browser.jpeg?fit=800%2C450&ssl=1 diff --git a/sources/tech/20190104 Three Ways To Reset And Change Forgotten Root Password on RHEL 7-CentOS 7 Systems.md b/sources/tech/20190104 Three Ways To Reset And Change Forgotten Root Password on RHEL 7-CentOS 7 Systems.md new file mode 100644 index 0000000000..6619cfe65a --- /dev/null +++ b/sources/tech/20190104 Three Ways To Reset And Change Forgotten Root Password on RHEL 7-CentOS 7 Systems.md @@ -0,0 +1,254 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Three Ways To Reset And Change Forgotten Root Password on RHEL 7/CentOS 7 Systems) +[#]: via: (https://www.2daygeek.com/linux-reset-change-forgotten-root-password-in-rhel-7-centos-7/) +[#]: author: (Prakash Subramanian https://www.2daygeek.com/author/prakash/) + +Three Ways To Reset And Change Forgotten Root Password on RHEL 7/CentOS 7 Systems +====== + +If you are forget to remember your root password for RHEL 7 and CentOS 7 systems and want to reset the forgotten root password? + +If so, don’t worry we are here to help you out on this. + +Navigate to the following link if you want to **[reset forgotten root password on RHEL 6/CentOS 6][1]**. + +This is generally happens when you use different password in vast environment or if you are not maintaining the proper inventory. + +Whatever it is. No issues, we will help you through this article. + +It can be done in many ways but we are going to show you the best three methods which we tried many times for our clients. + +In Linux servers there are three different users are available. These are, Normal User, System User and Super User. + +As everyone knows the Root user is known as super user in Linux and Administrator is in Windows. + +We can’t perform any major activity without root password so, make sure you should have the right root password when you perform any major tasks. + +If you don’t know or don’t have it, try to reset using one of the below method. + + * Reset Forgotten Root Password By Booting into Single User Mode using `rd.break` + * Reset Forgotten Root Password By Booting into Single User Mode using `init=/bin/bash` + * Reset Forgotten Root Password By Booting into Rescue Mode + + + +### Method-1: Reset Forgotten Root Password By Booting into Single User Mode + +Just follow the below procedure to reset the forgotten root password in RHEL 7/CentOS 7 systems. + +To do so, reboot your system and follow the instructions carefully. + +**`Step-1:`** Reboot your system and interrupt at the boot menu by hitting **`e`** key to modify the kernel arguments. +![][3] + +**`Step-2:`** In the GRUB options, find `linux16` word and add the `rd.break` word in the end of the file then press `Ctrl+x` or `F10` to boot into single user mode. +![][4] + +**`Step-3:`** At this point of time, your root filesystem will be mounted in Read only (RO) mode to /sysroot. Run the below command to confirm this. + +``` +# mount | grep root +``` + +![][5] + +**`Step-4:`** Based on the above output, i can say that i’m in single user mode and my root file system is mounted in read only mode. + +It won’t allow you to make any changes on your system until you mount the root filesystem with Read and write (RW) mode to /sysroot. To do so, use the following command. + +``` +# mount -o remount,rw /sysroot +``` + +![][6] + +**`Step-5:`** Currently your file systems are mounted as a temporary partition. Now, your command prompt shows **switch_root:/#**. + +Run the following command to get into a chroot jail so that /sysroot is used as the root of the file system. + +``` +# chroot /sysroot +``` + +![][7] + +**`Step-6:`** Now you can able to reset the root password with help of `passwd` command. + +``` +# echo "CentOS7$#123" | passwd --stdin root +``` + +![][8] + +**`Step-7:`** By default CentOS 7/RHEL 7 use SELinux in enforcing mode, so create a following hidden file which will automatically perform a relabel of all files on next boot. + +It allow us to fix the context of the **/etc/shadow** file. + +``` +# touch /.autorelabel +``` + +![][9] + +**`Step-8:`** Issue `exit` twice to exit from the chroot jail environment and reboot the system. +![][10] + +**`Step-9:`** Now you can login to your system with your new password. +![][11] + +### Method-2: Reset Forgotten Root Password By Booting into Single User Mode + +Alternatively we can use the below procedure to reset the forgotten root password in RHEL 7/CentOS 7 systems. + +**`Step-1:`** Reboot your system and interrupt at the boot menu by hitting **`e`** key to modify the kernel arguments. +![][3] + +**`Step-2:`** In the GRUB options, find `rhgb quiet` word and replace with the `init=/bin/bash` or `init=/bin/sh` word then press `Ctrl+x` or `F10` to boot into single user mode. + +Screenshot for **`init=/bin/bash`**. +![][12] + +Screenshot for **`init=/bin/sh`**. +![][13] + +**`Step-3:`** At this point of time, your root system will be mounted in Read only mode to /. Run the below command to confirm this. + +``` +# mount | grep root +``` + +![][14] + +**`Step-4:`** Based on the above ouput, i can say that i’m in single user mode and my root file system is mounted in read only (RO) mode. + +It won’t allow you to make any changes on your system until you mount the root file system with Read and write (RW) mode. To do so, use the following command. + +``` +# mount -o remount,rw / +``` + +![][15] + +**`Step-5:`** Now you can able to reset the root password with help of `passwd` command. + +``` +# echo "RHEL7$#123" | passwd --stdin root +``` + +![][16] + +**`Step-6:`** By default CentOS 7/RHEL 7 use SELinux in enforcing mode, so create a following hidden file which will automatically perform a relabel of all files on next boot. + +It allow us to fix the context of the **/etc/shadow** file. + +``` +# touch /.autorelabel +``` + +![][17] + +**`Step-7:`** Finally `Reboot` the system. + +``` +# exec /sbin/init 6 +``` + +![][18] + +**`Step-9:`** Now you can login to your system with your new password. +![][11] + +### Method-3: Reset Forgotten Root Password By Booting into Rescue Mode + +Alternatively, we can reset the forgotten Root password for RHEL 7 and CentOS 7 systems using Rescue mode. + +**`Step-1:`** Insert the bootable media through USB or DVD drive which is compatible for you and reboot your system. It will take to you to the below screen. + +Hit `Troubleshooting` to launch the `Rescue` mode. +![][19] + +**`Step-2:`** Choose `Rescue a CentOS system` and hit `Enter` button. +![][20] + +**`Step-3:`** Here choose `1` and the rescue environment will now attempt to find your Linux installation and mount it under the directory `/mnt/sysimage`. +![][21] + +**`Step-4:`** Simple hit `Enter` to get a shell. +![][22] + +**`Step-5:`** Run the following command to get into a chroot jail so that /mnt/sysimage is used as the root of the file system. + +``` +# chroot /mnt/sysimage +``` + +![][23] + +**`Step-6:`** Now you can able to reset the root password with help of **passwd** command. + +``` +# echo "RHEL7$#123" | passwd --stdin root +``` + +![][24] + +**`Step-7:`** By default CentOS 7/RHEL 7 use SELinux in enforcing mode, so create a following hidden file which will automatically perform a relabel of all files on next boot. +It allow us to fix the context of the /etc/shadow file. + +``` +# touch /.autorelabel +``` + +![][25] + +**`Step-8:`** Remove the bootable media then initiate the reboot. + +**`Step-9:`** Issue `exit` twice to exit from the chroot jail environment and reboot the system. +![][26] + +**`Step-10:`** Now you can login to your system with your new password. +![][11] + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-reset-change-forgotten-root-password-in-rhel-7-centos-7/ + +作者:[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/linux-reset-change-forgotten-root-password-in-rhel-6-centos-6/ +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-2.png +[4]: https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-3.png +[5]: https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-5.png +[6]: https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-6.png +[7]: https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-8.png +[8]: https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-10.png +[9]: https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-10a.png +[10]: https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-11.png +[11]: https://www.2daygeek.com/wp-content/uploads/2018/12/reset-forgotten-root-password-on-rhel-7-centos-7-12.png +[12]: https://www.2daygeek.com/wp-content/uploads/2018/12/method-reset-forgotten-root-password-on-rhel-7-centos-7-1.png +[13]: https://www.2daygeek.com/wp-content/uploads/2018/12/method-reset-forgotten-root-password-on-rhel-7-centos-7-1a.png +[14]: https://www.2daygeek.com/wp-content/uploads/2018/12/method-reset-forgotten-root-password-on-rhel-7-centos-7-3.png +[15]: https://www.2daygeek.com/wp-content/uploads/2018/12/method-reset-forgotten-root-password-on-rhel-7-centos-7-4.png +[16]: https://www.2daygeek.com/wp-content/uploads/2018/12/method-reset-forgotten-root-password-on-rhel-7-centos-7-5.png +[17]: https://www.2daygeek.com/wp-content/uploads/2018/12/method-reset-forgotten-root-password-on-rhel-7-centos-7-6.png +[18]: https://www.2daygeek.com/wp-content/uploads/2018/12/method-reset-forgotten-root-password-on-rhel-7-centos-7-7.png +[19]: https://www.2daygeek.com/wp-content/uploads/2018/12/rescue-reset-forgotten-root-password-on-rhel-7-centos-7-1.png +[20]: https://www.2daygeek.com/wp-content/uploads/2018/12/rescue-reset-forgotten-root-password-on-rhel-7-centos-7-2.png +[21]: https://www.2daygeek.com/wp-content/uploads/2018/12/rescue-reset-forgotten-root-password-on-rhel-7-centos-7-3.png +[22]: https://www.2daygeek.com/wp-content/uploads/2018/12/rescue-reset-forgotten-root-password-on-rhel-7-centos-7-4.png +[23]: https://www.2daygeek.com/wp-content/uploads/2018/12/rescue-reset-forgotten-root-password-on-rhel-7-centos-7-5.png +[24]: https://www.2daygeek.com/wp-content/uploads/2018/12/rescue-reset-forgotten-root-password-on-rhel-7-centos-7-6.png +[25]: https://www.2daygeek.com/wp-content/uploads/2018/12/rescue-reset-forgotten-root-password-on-rhel-7-centos-7-7.png +[26]: https://www.2daygeek.com/wp-content/uploads/2018/12/rescue-reset-forgotten-root-password-on-rhel-7-centos-7-8.png diff --git a/sources/tech/20190108 How ASLR protects Linux systems from buffer overflow attacks.md b/sources/tech/20190108 How ASLR protects Linux systems from buffer overflow attacks.md deleted file mode 100644 index 41d4e47acc..0000000000 --- a/sources/tech/20190108 How ASLR protects Linux systems from buffer overflow attacks.md +++ /dev/null @@ -1,133 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How ASLR protects Linux systems from buffer overflow attacks) -[#]: via: (https://www.networkworld.com/article/3331199/linux/what-does-aslr-do-for-linux.html) -[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) - -How ASLR protects Linux systems from buffer overflow attacks -====== - -![](https://images.idgesg.net/images/article/2019/01/shuffling-cards-100784640-large.jpg) - -Address Space Layout Randomization (ASLR) is a memory-protection process for operating systems that guards against buffer-overflow attacks. It helps to ensure that the memory addresses associated with running processes on systems are not predictable, thus flaws or vulnerabilities associated with these processes will be more difficult to exploit. - -ASLR is used today on Linux, Windows, and MacOS systems. It was first implemented on Linux in 2005. In 2007, the technique was deployed on Microsoft Windows and MacOS. While ASLR provides the same function on each of these operating systems, it is implemented differently on each one. - -The effectiveness of ASLR is dependent on the entirety of the address space layout remaining unknown to the attacker. In addition, only executables that are compiled as Position Independent Executable (PIE) programs will be able to claim the maximum protection from ASLR technique because all sections of the code will be loaded at random locations. PIE machine code will execute properly regardless of its absolute address. - -**[ Also see:[Invaluable tips and tricks for troubleshooting Linux][1] ]** - -### ASLR limitations - -In spite of ASLR making exploitation of system vulnerabilities more difficult, its role in protecting systems is limited. It's important to understand that ASLR: - - * Doesn't _resolve_ vulnerabilities, but makes exploiting them more of a challenge - * Doesn't track or report vulnerabilities - * Doesn't offer any protection for binaries that are not built with ASLR support - * Isn't immune to circumvention - - - -### How ASLR works - -ASLR increases the control-flow integrity of a system by making it more difficult for an attacker to execute a successful buffer-overflow attack by randomizing the offsets it uses in memory layouts. - -ASLR works considerably better on 64-bit systems, as these systems provide much greater entropy (randomization potential). - -### Is ASLR working on your Linux system? - -Either of the two commands shown below will tell you whether ASLR is enabled on your system. - -``` -$ cat /proc/sys/kernel/randomize_va_space -2 -$ sysctl -a --pattern randomize -kernel.randomize_va_space = 2 -``` - -The value (2) shown in the commands above indicates that ASLR is working in full randomization mode. The value shown will be one of the following: - -``` -0 = Disabled -1 = Conservative Randomization -2 = Full Randomization -``` - -If you disable ASLR and run the commands below, you should notice that the addresses shown in the **ldd** output below are all the same in the successive **ldd** commands. The **ldd** command works by loading the shared objects and showing where they end up in memory. - -``` -$ sudo sysctl -w kernel.randomize_va_space=0 <== disable -[sudo] password for shs: -kernel.randomize_va_space = 0 -$ ldd /bin/bash - linux-vdso.so.1 (0x00007ffff7fd1000) <== same addresses - libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007ffff7c69000) - libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ffff7c63000) - libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffff7a79000) - /lib64/ld-linux-x86-64.so.2 (0x00007ffff7fd3000) -$ ldd /bin/bash - linux-vdso.so.1 (0x00007ffff7fd1000) <== same addresses - libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007ffff7c69000) - libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ffff7c63000) - libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ffff7a79000) - /lib64/ld-linux-x86-64.so.2 (0x00007ffff7fd3000) -``` - -If the value is set back to **2** to enable ASLR, you will see that the addresses will change each time you run the command. - -``` -$ sudo sysctl -w kernel.randomize_va_space=2 <== enable -[sudo] password for shs: -kernel.randomize_va_space = 2 -$ ldd /bin/bash - linux-vdso.so.1 (0x00007fff47d0e000) <== first set of addresses - libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007f1cb7ce0000) - libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1cb7cda000) - libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1cb7af0000) - /lib64/ld-linux-x86-64.so.2 (0x00007f1cb8045000) -$ ldd /bin/bash - linux-vdso.so.1 (0x00007ffe1cbd7000) <== second set of addresses - libtinfo.so.6 => /lib/x86_64-linux-gnu/libtinfo.so.6 (0x00007fed59742000) - libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fed5973c000) - libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fed59552000) - /lib64/ld-linux-x86-64.so.2 (0x00007fed59aa7000) -``` - -### Attempting to bypass ASLR - -In spite of its advantages, attempts to bypass ASLR are not uncommon and seem to fall into several categories: - - * Using address leaks - * Gaining access to data relative to particular addresses - * Exploiting implementation weaknesses that allow attackers to guess addresses when entropy is low or when the ASLR implementation is faulty - * Using side channels of hardware operation - - - -### Wrap-up - -ASLR is of great value, especially when run on 64 bit systems and implemented properly. While not immune from circumvention attempts, it does make exploitation of system vulnerabilities considerably more difficult. Here is a reference that can provide a lot more detail [on the Effectiveness of Full-ASLR on 64-bit Linux][2], and here is a paper on one circumvention effort to [bypass ASLR][3] using branch predictors. - -Join the Network World communities on [Facebook][4] and [LinkedIn][5] to comment on topics that are top of mind. - --------------------------------------------------------------------------------- - -via: https://www.networkworld.com/article/3331199/linux/what-does-aslr-do-for-linux.html - -作者:[Sandra Henry-Stocker][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ -[b]: https://github.com/lujun9972 -[1]: https://www.networkworld.com/article/3242170/linux/invaluable-tips-and-tricks-for-troubleshooting-linux.html -[2]: https://cybersecurity.upv.es/attacks/offset2lib/offset2lib-paper.pdf -[3]: http://www.cs.ucr.edu/~nael/pubs/micro16.pdf -[4]: https://www.facebook.com/NetworkWorld/ -[5]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20190110 5 useful Vim plugins for developers.md b/sources/tech/20190110 5 useful Vim plugins for developers.md deleted file mode 100644 index 2b5b9421d4..0000000000 --- a/sources/tech/20190110 5 useful Vim plugins for developers.md +++ /dev/null @@ -1,369 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (pityonline) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (5 useful Vim plugins for developers) -[#]: via: (https://opensource.com/article/19/1/vim-plugins-developers) -[#]: author: (Ricardo Gerardi https://opensource.com/users/rgerardi) - -5 useful Vim plugins for developers -====== -Expand Vim's capabilities and improve your workflow with these five plugins for writing code. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/web_browser_desktop_devlopment_design_system_computer.jpg?itok=pfqRrJgh) - -I have used [Vim][1] as a text editor for over 20 years, but about two years ago I decided to make it my primary text editor. I use Vim to write code, configuration files, blog articles, and pretty much everything I can do in plaintext. Vim has many great features and, once you get used to it, you become very productive. - -I tend to use Vim's robust native capabilities for most of what I do, but there are a number of plugins developed by the open source community that extend Vim's capabilities, improve your workflow, and make you even more productive. - -Following are five plugins that are useful when using Vim to write code in any programming language. - -### 1. Auto Pairs - -The [Auto Pairs][2] plugin helps insert and delete pairs of characters, such as brackets, parentheses, or quotation marks. This is very useful for writing code, since most programming languages use pairs of characters in their syntax—such as parentheses for function calls or quotation marks for string definitions. - -In its most basic functionality, Auto Pairs inserts the corresponding closing character when you type an opening character. For example, if you enter a bracket **[** , Auto-Pairs automatically inserts the closing bracket **]**. Conversely, if you use the Backspace key to delete the opening bracket, Auto Pairs deletes the corresponding closing bracket. - -If you have automatic indentation on, Auto Pairs inserts the paired character in the proper indented position when you press Return/Enter, saving you from finding the correct position and typing the required spaces or tabs. - -Consider this Go code block for instance: - -``` -package main - -import "fmt" - -func main() { -    x := true -    items := []string{"tv", "pc", "tablet"} - -    if x { -        for _, i := range items -    } -} -``` - -Inserting an opening curly brace **{** after **items** and pressing Return/Enter produces this result: - -``` -package main - -import "fmt" - -func main() { -    x := true -    items := []string{"tv", "pc", "tablet"} - -    if x { -        for _, i := range items  { -            | (cursor here) -        } -    } -} -``` - -Auto Pairs offers many other options (which you can read about on [GitHub][3]), but even these basic features will save time. - -### 2. NERD Commenter - -The [NERD Commenter][4] plugin adds code-commenting functions to Vim, similar to the ones found in an integrated development environment (IDE). With this plugin installed, you can select one or several lines of code and change them to comments with the press of a button. - -NERD Commenter integrates with the standard Vim [filetype][5] plugin, so it understands several programming languages and uses the appropriate commenting characters for single or multi-line comments. - -The easiest way to get started is by pressing **Leader+Space** to toggle the current line between commented and uncommented. The standard Vim Leader key is the **\** character. - -In Visual mode, you can select multiple lines and toggle their status at the same time. NERD Commenter also understands counts, so you can provide a count n followed by the command to change n lines together. - -Other useful features are the "Sexy Comment," triggered by **Leader+cs** , which creates a fancy comment block using the multi-line comment character. For example, consider this block of code: - -``` -package main - -import "fmt" - -func main() { -    x := true -    items := []string{"tv", "pc", "tablet"} - -    if x { -        for _, i := range items { -            fmt.Println(i) -        } -    } -} -``` - -Selecting all the lines in **function main** and pressing **Leader+cs** results in the following comment block: - -``` -package main - -import "fmt" - -func main() { -/* - *    x := true - *    items := []string{"tv", "pc", "tablet"} - * - *    if x { - *        for _, i := range items { - *            fmt.Println(i) - *        } - *    } - */ -} -``` - -Since all the lines are commented in one block, you can uncomment the entire block by toggling any of the lines of the block with **Leader+Space**. - -NERD Commenter is a must-have for any developer using Vim to write code. - -### 3. VIM Surround - -The [Vim Surround][6] plugin helps you "surround" existing text with pairs of characters (such as parentheses or quotation marks) or tags (such as HTML or XML tags). It's similar to Auto Pairs but, instead of working while you're inserting text, it's more useful when you're editing text. - -For example, if you have the following sentence: - -``` -"Vim plugins are awesome !" -``` - -You can remove the quotation marks around the sentence by pressing the combination **ds"** while your cursor is anywhere between the quotation marks: - -``` -Vim plugins are awesome ! -``` - -You can also change the double quotation marks to single quotation marks with the command **cs"'** : - -``` -'Vim plugins are awesome !' -``` - -Or replace them with brackets by pressing **cs'[** - -``` -[ Vim plugins are awesome ! ] -``` - -While it's a great help for text objects, this plugin really shines when working with HTML or XML tags. Consider the following HTML line: - -``` -

Vim plugins are awesome !

-``` - -You can emphasize the word "awesome" by pressing the combination **ysiw ** while the cursor is anywhere on that word: - -``` -

Vim plugins are awesome !

-``` - -Notice that the plugin is smart enough to use the proper closing tag **< /em>**. - -Vim Surround can also indent text and add tags in their own lines using **ySS**. For example, if you have: - -``` -

Vim plugins are awesome !

-``` - -Add a **div** tag with this combination: **ySS
**, and notice that the paragraph line is indented automatically. - -``` -
-       

Vim plugins are awesome !

-
-``` - -Vim Surround has many other options. Give it a try—and consult [GitHub][7] for additional information. - -### 4\. Vim Gitgutter - -The [Vim Gitgutter][8] plugin is useful for anyone using Git for version control. It shows the output of **Git diff** as symbols in the "gutter"—the sign column where Vim presents additional information, such as line numbers. For example, consider the following as the committed version in Git: - -``` -  1 package main -  2 -  3 import "fmt" -  4 -  5 func main() { -  6     x := true -  7     items := []string{"tv", "pc", "tablet"} -  8 -  9     if x { - 10         for _, i := range items { - 11             fmt.Println(i) - 12         } - 13     } - 14 } -``` - -After making some changes, Vim Gitgutter displays the following symbols in the gutter: - -``` -    1 package main -    2 -    3 import "fmt" -    4 -_   5 func main() { -    6     items := []string{"tv", "pc", "tablet"} -    7 -~   8     if len(items) > 0 { -    9         for _, i := range items { -   10             fmt.Println(i) -+  11             fmt.Println("------") -   12         } -   13     } -   14 } -``` - -The **-** symbol shows that a line was deleted between lines 5 and 6. The **~** symbol shows that line 8 was modified, and the symbol **+** shows that line 11 was added. - -In addition, Vim Gitgutter allows you to navigate between "hunks"—individual changes made in the file—with **[c** and **]c** , or even stage individual hunks for commit by pressing **Leader+hs**. - -This plugin gives you immediate visual feedback of changes, and it's a great addition to your toolbox if you use Git. - -### 5\. VIM Fugitive - -[Vim Fugitive][9] is another great plugin for anyone incorporating Git into the Vim workflow. It's a Git wrapper that allows you to execute Git commands directly from Vim and integrates with Vim's interface. This plugin has many features—check its [GitHub][10] page for more information. - -Here's a basic Git workflow example using Vim Fugitive. Considering the changes we've made to the Go code block on section 4, you can use **git blame** by typing the command **:Gblame** : - -``` -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    1 package main -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    2 -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    3 import "fmt" -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    4 -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│_   5 func main() { -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    6     items := []string{"tv", "pc", "tablet"} -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    7 -00000000 (Not Committed Yet 2018-12-05 18:55:00 -0500)│~   8     if len(items) > 0 { -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│    9         for _, i := range items { -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   10             fmt.Println(i) -00000000 (Not Committed Yet 2018-12-05 18:55:00 -0500)│+  11             fmt.Println("------") -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   12         } -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   13     } -e9949066 (Ricardo Gerardi   2018-12-05 18:17:19 -0500)│   14 } -``` - -You can see that lines 8 and 11 have not been committed. Check the repository status by typing **:Gstatus** : - -``` - 1 # On branch master -  2 # Your branch is up to date with 'origin/master'. -  3 # -  4 # Changes not staged for commit: -  5 #   (use "git add ..." to update what will be committed) -  6 #   (use "git checkout -- ..." to discard changes in working directory) -  7 # -  8 #       modified:   vim-5plugins/examples/test1.go -  9 # - 10 no changes added to commit (use "git add" and/or "git commit -a") --------------------------------------------------------------------------------------------------------- -    1 package main -    2 -    3 import "fmt" -    4 -_   5 func main() { -    6     items := []string{"tv", "pc", "tablet"} -    7 -~   8     if len(items) > 0 { -    9         for _, i := range items { -   10             fmt.Println(i) -+  11             fmt.Println("------") -   12         } -   13     } -   14 } -``` - -Vim Fugitive opens a split window with the result of **git status**. You can stage a file for commit by pressing the **-** key on the line with the name of the file. You can reset the status by pressing **-** again. The message updates to reflect the new status: - -``` -  1 # On branch master -  2 # Your branch is up to date with 'origin/master'. -  3 # -  4 # Changes to be committed: -  5 #   (use "git reset HEAD ..." to unstage) -  6 # -  7 #       modified:   vim-5plugins/examples/test1.go -  8 # --------------------------------------------------------------------------------------------------------- -    1 package main -    2 -    3 import "fmt" -    4 -_   5 func main() { -    6     items := []string{"tv", "pc", "tablet"} -    7 -~   8     if len(items) > 0 { -    9         for _, i := range items { -   10             fmt.Println(i) -+  11             fmt.Println("------") -   12         } -   13     } -   14 } -``` - -Now you can use the command **:Gcommit** to commit the changes. Vim Fugitive opens another split that allows you to enter a commit message: - -``` -  1 vim-5plugins: Updated test1.go example file -  2 # Please enter the commit message for your changes. Lines starting -  3 # with '#' will be ignored, and an empty message aborts the commit. -  4 # -  5 # On branch master -  6 # Your branch is up to date with 'origin/master'. -  7 # -  8 # Changes to be committed: -  9 #       modified:   vim-5plugins/examples/test1.go - 10 # -``` - -Save the file with **:wq** to complete the commit: - -``` -[master c3bf80f] vim-5plugins: Updated test1.go example file - 1 file changed, 2 insertions(+), 2 deletions(-) -Press ENTER or type command to continue -``` - -You can use **:Gstatus** again to see the result and **:Gpush** to update the remote repository with the new commit. - -``` -  1 # On branch master -  2 # Your branch is ahead of 'origin/master' by 1 commit. -  3 #   (use "git push" to publish your local commits) -  4 # -  5 nothing to commit, working tree clean -``` - -If you like Vim Fugitive and want to learn more, the GitHub repository has links to screencasts showing additional functionality and workflows. Check it out! - -### What's next? - -These Vim plugins help developers write code in any programming language. There are two other categories of plugins to help developers: code-completion plugins and syntax-checker plugins. They are usually related to specific programming languages, so I will cover them in a follow-up article. - -Do you have another Vim plugin you use when writing code? Please share it in the comments below. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/vim-plugins-developers - -作者:[Ricardo Gerardi][a] -选题:[lujun9972][b] -译者:[pityonline](https://github.com/pityonline) -校对:[校对者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]: https://www.vim.org/ -[2]: https://www.vim.org/scripts/script.php?script_id=3599 -[3]: https://github.com/jiangmiao/auto-pairs -[4]: https://github.com/scrooloose/nerdcommenter -[5]: http://vim.wikia.com/wiki/Filetype.vim -[6]: https://www.vim.org/scripts/script.php?script_id=1697 -[7]: https://github.com/tpope/vim-surround -[8]: https://github.com/airblade/vim-gitgutter -[9]: https://www.vim.org/scripts/script.php?script_id=2975 -[10]: https://github.com/tpope/vim-fugitive diff --git a/sources/tech/20190115 Getting started with Sandstorm, an open source web app platform.md b/sources/tech/20190115 Getting started with Sandstorm, an open source web app platform.md deleted file mode 100644 index 2389a5d243..0000000000 --- a/sources/tech/20190115 Getting started with Sandstorm, an open source web app platform.md +++ /dev/null @@ -1,58 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Getting started with Sandstorm, an open source web app platform) -[#]: via: (https://opensource.com/article/19/1/productivity-tool-sandstorm) -[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) - -Getting started with Sandstorm, an open source web app platform -====== -Learn about Sandstorm, the third in our series on open source tools that will make you more productive in 2019. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/sand_dunes_desert_hills_landscape_nature.jpg?itok=wUByylBb) - -There seems to be a mad rush at the beginning of every year to find ways to be more productive. New Year's resolutions, the itch to start the year off right, and of course, an "out with the old, in with the new" attitude all contribute to this. And the usual round of recommendations is heavily biased towards closed source and proprietary software. It doesn't have to be that way. - -Here's the third of my picks for 19 new (or new-to-you) open source tools to help you be more productive in 2019. - -### Sandstorm - -Being productive isn't just about to-do lists and keeping things organized. Often it requires a suite of tools linked to make a workflow go smoothly. - -![](https://opensource.com/sites/default/files/uploads/sandstorm_1.png) - -[Sandstorm][1] is an open source collection of packaged apps, all accessible from a single web interface and managed from a central console. You can host it yourself or use the [Sandstorm Oasis][2] service—for a per-user fee. - -![](https://opensource.com/sites/default/files/uploads/sandstorm_2.png) - -Sandstorm has a marketplace that makes it simple to install the apps that are available. It includes apps for productivity, finance, note taking, task tracking, chat, games, and a whole lot more. You can also package your own apps and upload them by following the application-packaging guidelines in the [developer documentation][3]. - -![](https://opensource.com/sites/default/files/uploads/sandstorm_3.png) - -Once installed, a user can create [grains][4]—basically containerized instances of app data. Grains are private by default and can be shared with other Sandstorm users. This means they are secure by default, and users can chose what to share with others. - -![](https://opensource.com/sites/default/files/uploads/sandstorm_4.png) - -Sandstorm can authenticate from several different external sources as well as use a "passwordless" email-based authentication. Using an external service means you don't have to manage yet another set of credentials if you already use one of the supported services. - -In the end, Sandstorm makes installing and using supported collaborative apps quick, easy, and secure. - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/productivity-tool-sandstorm - -作者:[Kevin Sonney][a] -选题:[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/ksonney (Kevin Sonney) -[b]: https://github.com/lujun9972 -[1]: https://sandstorm.io/ -[2]: https://oasis.sandstorm.io -[3]: https://docs.sandstorm.io/en/latest/developing/ -[4]: https://sandstorm.io/how-it-works diff --git a/sources/tech/20190115 Linux Desktop Setup - HookRace Blog.md b/sources/tech/20190115 Linux Desktop Setup - HookRace Blog.md new file mode 100644 index 0000000000..29d5f63d2a --- /dev/null +++ b/sources/tech/20190115 Linux Desktop Setup - HookRace Blog.md @@ -0,0 +1,514 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Linux Desktop Setup · HookRace Blog) +[#]: via: (https://hookrace.net/blog/linux-desktop-setup/) +[#]: author: (Dennis Felsing http://felsin9.de/nnis/) + +Linux Desktop Setup +====== + + +My software setup has been surprisingly constant over the last decade, after a few years of experimentation since I initially switched to Linux in 2006. It might be interesting to look back in another 10 years and see what changed. A quick overview of what’s running as I’m writing this post: + +[![htop overview][1]][2] + +### Motivation + +My software priorities are, in no specific order: + + * Programs should run on my local system so that I’m in control of them, this excludes cloud solutions. + * Programs should run in the terminal, so that they can be used consistently from anywhere, including weak computers or a phone. + * Keyboard focused is nearly automatic by using terminal software. I prefer to use the mouse where it makes sense only, reaching for the mouse all the time during typing feels like a waste of time. Occasionally it took me an hour to notice that the mouse wasn’t even plugged in. + * Ideally use fast and efficient software, I don’t like hearing the fan and feeling the room heat up. I can also keep running older hardware for much longer, my 10 year old Thinkpad x200s is still fine for all the software I use. + * Be composable. I don’t want to do every step manually, instead automate more when it makes sense. This naturally favors the shell. + + + +### Operating Systems + +I had a hard start with Linux 12 years ago by removing Windows, armed with just the [Gentoo Linux][3] installation CD and a printed manual to get a functioning Linux system. It took me a few days of compiling and tinkering, but in the end I felt like I had learnt a lot. + +I haven’t looked back to Windows since then, but I switched to [Arch Linux][4] on my laptop after having the fan fail from the constant compilation stress. Later I also switched all my other computers and private servers to Arch Linux. As a rolling release distribution you get package upgrades all the time, but the most important breakages are nicely reported in the [Arch Linux News][5]. + +One annoyance though is that Arch Linux removes the old kernel modules once you upgrade it. I usually notice that once I try plugging in a USB flash drive and the kernel fails to load the relevant module. Instead you’re supposed to reboot after each kernel upgrade. There are a few [hacks][6] around to get around the problem, but I haven’t been bothered enough to actually use them. + +Similar problems happen with other programs, commonly Firefox, cron or Samba requiring a restart after an upgrade, but annoyingly not warning you that that’s the case. [SUSE][7], which I use at work, nicely warns about such cases. + +For the [DDNet][8] production servers I prefer [Debian][9] over Arch Linux, so that I have a lower chance of breakage on each upgrade. For my firewall and router I used [OpenBSD][10] for its clean system, documentation and great [pf firewall][11], but right now I don’t have a need for a separate router anymore. + +### Window Manager + +Since I started out with Gentoo I quickly noticed the huge compile time of KDE, which made it a no-go for me. I looked around for more minimal solutions, and used [Openbox][12] and [Fluxbox][13] initially. At some point I jumped on the tiling window manager train in order to be more keyboard-focused and picked up [dwm][14] and [awesome][15] close to their initial releases. + +In the end I settled on [xmonad][16] thanks to its flexibility, extendability and being written and configured in pure [Haskell][17], a great functional programming language. One example of this is that at home I run a single 40” 4K screen, but often split it up into four virtual screens, each displaying a workspace on which my windows are automatically arranged. Of course xmonad has a [module][18] for that. + +[dzen][19] and [conky][20] function as a simple enough status bar for me. My entire conky config looks like this: + +``` +out_to_console yes +update_interval 1 +total_run_times 0 + +TEXT +${downspeed eth0} ${upspeed eth0} | $cpu% ${loadavg 1} ${loadavg 2} ${loadavg 3} $mem/$memmax | ${time %F %T} +``` + +And gets piped straight into dzen2 with `conky | dzen2 -fn '-xos4-terminus-medium-r-normal-*-12-*-*-*-*-*-*-*' -bg '#000000' -fg '#ffffff' -p -e '' -x 1000 -w 920 -xs 1 -ta r`. + +One important feature for me is to make the terminal emit a beep sound once a job is done. This is done simply by adding a `\a` character to the `PR_TITLEBAR` variable in zsh, which is shown whenever a job is done. Of course I disable the actual beep sound by blacklisting the `pcspkr` kernel module with `echo "blacklist pcspkr" > /etc/modprobe.d/nobeep.conf`. Instead the sound gets turned into an urgency by urxvt’s `URxvt.urgentOnBell: true` setting. Then xmonad has an urgency hook to capture this and I can automatically focus the currently urgent window with a key combination. In dzen I get the urgent windowspaces displayed with a nice and bright `#ff0000`. + +The final result in all its glory on my Laptop: + +[![Laptop screenshot][21]][22] + +I hear that [i3][23] has become quite popular in the last years, but it requires more manual window alignment instead of specifying automated methods to do it. + +I realize that there are also terminal multiplexers like [tmux][24], but I still require a few graphical applications, so in the end I never used them productively. + +### Terminal Persistency + +In order to keep terminals alive I use [dtach][25], which is just the detach feature of screen. In order to make every terminal on my computer detachable I wrote a [small wrapper script][26]. This means that even if I had to restart my X server I could keep all my terminals running just fine, both local and remote. + +### Shell & Programming + +Instead of [bash][27] I use [zsh][28] as my shell for its huge number of features. + +As a terminal emulator I found [urxvt][29] to be simple enough, support Unicode and 256 colors and has great performance. Another great feature is being able to run the urxvt client and daemon separately, so that even a large number of terminals barely takes up any memory (except for the scrollback buffer). + +There is only one font that looks absolutely clean and perfect to me: [Terminus][30]. Since i’s a bitmap font everything is pixel perfect and renders extremely fast and at low CPU usage. In order to switch fonts on-demand in each terminal with `CTRL-WIN-[1-7]` my ~/.Xdefaults contains: + +``` +URxvt.font: -xos4-terminus-medium-r-normal-*-14-*-*-*-*-*-*-* +dzen2.font: -xos4-terminus-medium-r-normal-*-14-*-*-*-*-*-*-* + +URxvt.keysym.C-M-1: command:\033]50;-xos4-terminus-medium-r-normal-*-12-*-*-*-*-*-*-*\007 +URxvt.keysym.C-M-2: command:\033]50;-xos4-terminus-medium-r-normal-*-14-*-*-*-*-*-*-*\007 +URxvt.keysym.C-M-3: command:\033]50;-xos4-terminus-medium-r-normal-*-18-*-*-*-*-*-*-*\007 +URxvt.keysym.C-M-4: command:\033]50;-xos4-terminus-medium-r-normal-*-22-*-*-*-*-*-*-*\007 +URxvt.keysym.C-M-5: command:\033]50;-xos4-terminus-medium-r-normal-*-24-*-*-*-*-*-*-*\007 +URxvt.keysym.C-M-6: command:\033]50;-xos4-terminus-medium-r-normal-*-28-*-*-*-*-*-*-*\007 +URxvt.keysym.C-M-7: command:\033]50;-xos4-terminus-medium-r-normal-*-32-*-*-*-*-*-*-*\007 + +URxvt.keysym.C-M-n: command:\033]10;#ffffff\007\033]11;#000000\007\033]12;#ffffff\007\033]706;#00ffff\007\033]707;#ffff00\007 +URxvt.keysym.C-M-b: command:\033]10;#000000\007\033]11;#ffffff\007\033]12;#000000\007\033]706;#0000ff\007\033]707;#ff0000\007 +``` + +For programming and writing I use [Vim][31] with syntax highlighting and [ctags][32] for indexing, as well as a few terminal windows with grep, sed and the other usual suspects for search and manipulation. This is probably not at the same level of comfort as an IDE, but allows me more automation. + +One problem with Vim is that you get so used to its key mappings that you’ll want to use them everywhere. + +[Python][33] and [Nim][34] do well as scripting languages where the shell is not powerful enough. + +### System Monitoring + +[htop][35] (look at the background of that site, it’s a live view of the server that’s hosting it) works great for getting a quick overview of what the software is currently doing. [lm_sensors][36] allows monitoring the hardware temperatures, fans and voltages. [powertop][37] is a great little tool by Intel to find power savings. [ncdu][38] lets you analyze disk usage interactively. + +[nmap][39], iptraf-ng, [tcpdump][40] and [Wireshark][41] are essential tools for analyzing network problems. + +There are of course many more great tools. + +### Mails & Synchronization + +On my home server I have a [fetchmail][42] daemon running for each email acccount that I have. Fetchmail just retrieves the incoming emails and invokes [procmail][43]: + +``` +#!/bin/sh +for i in /home/deen/.fetchmail/*; do + FETCHMAILHOME=$i /usr/bin/fetchmail -m 'procmail -d %T' -d 60 +done +``` + +The configuration is as simple as it could be and waits for the server to inform us of fresh emails: + +``` +poll imap.1und1.de protocol imap timeout 120 user "dennis@felsin9.de" password "XXX" folders INBOX keep ssl idle +``` + +My `.procmailrc` config contains a few rules to backup all mails and sort them into the correct directories, for example based on the mailing list id or from field in the mail header: + +``` +MAILDIR=/home/deen/shared/Maildir +LOGFILE=$HOME/.procmaillog +LOGABSTRACT=no +VERBOSE=off +FORMAIL=/usr/bin/formail +NL=" +" + +:0wc +* ! ? test -d /media/mailarchive/`date +%Y` +| mkdir -p /media/mailarchive/`date +%Y` + +# Make backups of all mail received in format YYYY/YYYY-MM +:0c +/media/mailarchive/`date +%Y`/`date +%Y-%m` + +:0 +* ^From: .*(.*@.*.kit.edu|.*@.*.uka.de|.*@.*.uni-karlsruhe.de) +$MAILDIR/.uni/ + +:0 +* ^list-Id:.*lists.kit.edu +$MAILDIR/.uni-ml/ + +[...] +``` + +To send emails I use [msmtp][44], which is also great to configure: + +``` +account default +host smtp.1und1.de +tls on +tls_trust_file /etc/ssl/certs/ca-certificates.crt +auth on +from dennis@felsin9.de +user dennis@felsin9.de +password XXX + +[...] +``` + +But so far the emails are still on the server. My documents are all stored in a directory that I synchronize between all computers using [Unison][45]. Think of Unison as a bidirectional interactive [rsync][46]. My emails are part of this documents directory and thus they end up on my desktop computers. + +This also means that while the emails reach my server immediately, I only fetch them on deman instead of getting instant notifications when an email comes in. + +From there I read the mails with [mutt][47], using the sidebar plugin to display my mail directories. The `/etc/mailcap` file is essential to display non-plaintext mails containing HTML, Word or PDF: + +``` +text/html;w3m -I %{charset} -T text/html; copiousoutput +application/msword; antiword %s; copiousoutput +application/pdf; pdftotext -layout /dev/stdin -; copiousoutput +``` + +### News & Communication + +[Newsboat][48] is a nice little RSS/Atom feed reader in the terminal. I have it running on the server in a `tach` session with about 150 feeds. Filtering feeds locally is also possible, for example: + +``` +ignore-article "https://forum.ddnet.tw/feed.php" "title =~ \"Map Testing •\" or title =~ \"Old maps •\" or title =~ \"Map Bugs •\" or title =~ \"Archive •\" or title =~ \"Waiting for mapper •\" or title =~ \"Other mods •\" or title =~ \"Fixes •\"" +``` + +I use [Irssi][49] the same way for communication via IRC. + +### Calendar + +[remind][50] is a calendar that can be used from the command line. Setting new reminders is done by editing the `rem` files: + +``` +# One time events +REM 2019-01-20 +90 Flight to China %b + +# Recurring Holidays +REM 1 May +90 Holiday "Tag der Arbeit" %b +REM [trigger(easterdate(year(today()))-2)] +90 Holiday "Karfreitag" %b + +# Time Change +REM Nov Sunday 1 --7 +90 Time Change (03:00 -> 02:00) %b +REM Apr Sunday 1 --7 +90 Time Change (02:00 -> 03:00) %b + +# Birthdays +FSET birthday(x) "'s " + ord(year(trigdate())-x) + " birthday is %b" +REM 16 Apr +90 MSG Andreas[birthday(1994)] + +# Sun +SET $LatDeg 49 +SET $LatMin 19 +SET $LatSec 49 +SET $LongDeg -8 +SET $LongMin -40 +SET $LongSec -24 + +MSG Sun from [sunrise(trigdate())] to [sunset(trigdate())] +[...] +``` + +Unfortunately there is no Chinese Lunar calendar function in remind yet, so Chinese holidays can’t be calculated easily. + +I use two aliases for remind: + +``` +rem -m -b1 -q -g +``` + +to see a list of the next events in chronological order and + +``` +rem -m -b1 -q -cuc12 -w$(($(tput cols)+1)) | sed -e "s/\f//g" | less +``` + +to show a calendar fitting just the width of my terminal: + +![remcal][51] + +### Dictionary + +[rdictcc][52] is a little known dictionary tool that uses the excellent dictionary files from [dict.cc][53] and turns them into a local database: + +``` +$ rdictcc rasch +====================[ A => B ]==================== +rasch: + - apace + - brisk [speedy] + - cursory + - in a timely manner + - quick + - quickly + - rapid + - rapidly + - sharpish [Br.] [coll.] + - speedily + - speedy + - swift + - swiftly +rasch [gehen]: + - smartly [quickly] +Rasch {n} [Zittergras-Segge]: + - Alpine grass [Carex brizoides] + - quaking grass sedge [Carex brizoides] +Rasch {m} [regional] [Putzrasch]: + - scouring pad +====================[ B => A ]==================== +Rasch model: + - Rasch-Modell {n} +``` + +### Writing and Reading + +I have a simple todo file containing my tasks, that is basically always sitting open in a Vim session. For work I also use the todo file as a “done” file so that I can later check what tasks I finished on each day. + +For writing documents, letters and presentations I use [LaTeX][54] for its superior typesetting. A simple letter in German format can be set like this for example: + +``` +\documentclass[paper = a4, fromalign = right]{scrlttr2} +\usepackage{german} +\usepackage{eurosym} +\usepackage[utf8]{inputenc} +\setlength{\parskip}{6pt} +\setlength{\parindent}{0pt} + +\setkomavar{fromname}{Dennis Felsing} +\setkomavar{fromaddress}{Meine Str. 1\\69181 Leimen} +\setkomavar{subject}{Titel} + +\setkomavar*{enclseparator}{Anlagen} + +\makeatletter +\@setplength{refvpos}{89mm} +\makeatother + +\begin{document} +\begin{letter} {Herr Soundso\\Deine Str. 2\\69121 Heidelberg} +\opening{Sehr geehrter Herr Soundso,} + +Sie haben bei mir seit dem Bla Bla Bla. + +Ich fordere Sie hiermit zu Bla Bla Bla auf. + +\closing{Mit freundlichen Grüßen} + +\end{letter} +\end{document} +``` + +Further example documents and presentations can be found over at [my private site][55]. + +To read PDFs [Zathura][56] is fast, has Vim-like controls and even supports two different PDF backends: Poppler and MuPDF. [Evince][57] on the other hand is more full-featured for the cases where I encounter documents that Zathura doesn’t like. + +### Graphical Editing + +[GIMP][58] and [Inkscape][59] are easy choices for photo editing and interactive vector graphics respectively. + +In some cases [Imagemagick][60] is good enough though and can be used straight from the command line and thus automated to edit images. Similarly [Graphviz][61] and [TikZ][62] can be used to draw graphs and other diagrams. + +### Web Browsing + +As a web browser I’ve always used [Firefox][63] for its extensibility and low resource usage compared to Chrome. + +Unfortunately the [Pentadactyl][64] extension development stopped after Firefox switched to Chrome-style extensions entirely, so I don’t have satisfying Vim-like controls in my browser anymore. + +### Media Players + +[mpv][65] with hardware decoding allows watching videos at 5% CPU load using the `vo=gpu` and `hwdec=vaapi` config settings. `audio-channels=2` in mpv seems to give me clearer downmixing to my stereo speakers / headphones than what PulseAudio does by default. A great little feature is exiting with `Shift-Q` instead of just `Q` to save the playback location. When watching with someone with another native tongue you can use `--secondary-sid=` to show two subtitles at once, the primary at the bottom, the secondary at the top of the screen + +My wirelss mouse can easily be made into a remote control with mpv with a small `~/.config/mpv/input.conf`: + +``` +MOUSE_BTN5 run "mixer" "pcm" "-2" +MOUSE_BTN6 run "mixer" "pcm" "+2" +MOUSE_BTN1 cycle sub-visibility +MOUSE_BTN7 add chapter -1 +MOUSE_BTN8 add chapter 1 +``` + +[youtube-dl][66] works great for watching videos hosted online, best quality can be achieved with `-f bestvideo+bestaudio/best --all-subs --embed-subs`. + +As a music player [MOC][67] hasn’t been actively developed for a while, but it’s still a simple player that plays every format conceivable, including the strangest Chiptune formats. In the AUR there is a [patch][68] adding PulseAudio support as well. Even with the CPU clocked down to 800 MHz MOC barely uses 1-2% of a single CPU core. + +![moc][69] + +My music collection sits on my home server so that I can access it from anywhere. It is mounted using [SSHFS][70] and automount in the `/etc/fstab/`: + +``` +root@server:/media/media /mnt/media fuse.sshfs noauto,x-systemd.automount,idmap=user,IdentityFile=/root/.ssh/id_rsa,allow_other,reconnect 0 0 +``` + +### Cross-Platform Building + +Linux is great to build packages for any major operating system except Linux itself! In the beginning I used [QEMU][71] to with an old Debian, Windows and Mac OS X VM to build for these platforms. + +Nowadays I switched to using chroot for the old Debian distribution (for maximum Linux compatibility), [MinGW][72] to cross-compile for Windows and [OSXCross][73] to cross-compile for Mac OS X. + +The script used to [build DDNet][74] as well as the [instructions for updating library builds][75] are based on this. + +### Backups + +As usual, we nearly forgot about backups. Even if this is the last chapter, it should not be an afterthought. + +I wrote [rrb][76] (reverse rsync backup) 10 years ago to wrap rsync so that I only need to give the backup server root SSH rights to the computers that it is backing up. Surprisingly rrb needed 0 changes in the last 10 years, even though I kept using it the entire time. + +The backups are stored straight on the filesystem. Incremental backups are implemented using hard links (`--link-dest`). A simple [config][77] defines how long backups are kept, which defaults to: + +``` +KEEP_RULES=( \ + 7 7 \ # One backup a day for the last 7 days + 31 8 \ # 8 more backups for the last month + 365 11 \ # 11 more backups for the last year +1825 4 \ # 4 more backups for the last 5 years +) +``` + +Since some of my computers don’t have a static IP / DNS entry and I still want to back them up using rrb I use a reverse SSH tunnel (as a systemd service) for them: + +``` +[Unit] +Description=Reverse SSH Tunnel +After=network.target + +[Service] +ExecStart=/usr/bin/ssh -N -R 27276:localhost:22 -o "ExitOnForwardFailure yes" server +KillMode=process +Restart=always + +[Install] +WantedBy=multi-user.target +``` + +Now the server can reach the client through `ssh -p 27276 localhost` while the tunnel is running to perform the backup, or in `.ssh/config` format: + +``` +Host cr-remote + HostName localhost + Port 27276 +``` + +While talking about SSH hacks, sometimes a server is not easily reachable thanks to some bad routing. In that case you can route the SSH connection through another server to get better routing, in this case going through the USA to reach my Chinese server which had not been reliably reachable from Germany for a few weeks: + +``` +Host chn.ddnet.tw + ProxyCommand ssh -q usa.ddnet.tw nc -q0 chn.ddnet.tw 22 + Port 22 +``` + +### Final Remarks + +Thanks for reading my random collection of tools. I probably forgot many programs that I use so naturally every day that I don’t even think about them anymore. Let’s see how stable my software setup stays in the next years. If you have any questions, feel free to get in touch with me at [dennis@felsin9.de][78]. + +Comments on [Hacker News][79]. + +-------------------------------------------------------------------------------- + +via: https://hookrace.net/blog/linux-desktop-setup/ + +作者:[Dennis Felsing][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://felsin9.de/nnis/ +[b]: https://github.com/lujun9972 +[1]: https://hookrace.net/public/linux-desktop/htop_small.png +[2]: https://hookrace.net/public/linux-desktop/htop.png +[3]: https://gentoo.org/ +[4]: https://www.archlinux.org/ +[5]: https://www.archlinux.org/news/ +[6]: https://www.reddit.com/r/archlinux/comments/4zrsc3/keep_your_system_fully_functional_after_a_kernel/ +[7]: https://www.suse.com/ +[8]: https://ddnet.tw/ +[9]: https://www.debian.org/ +[10]: https://www.openbsd.org/ +[11]: https://www.openbsd.org/faq/pf/ +[12]: http://openbox.org/wiki/Main_Page +[13]: http://fluxbox.org/ +[14]: https://dwm.suckless.org/ +[15]: https://awesomewm.org/ +[16]: https://xmonad.org/ +[17]: https://www.haskell.org/ +[18]: http://hackage.haskell.org/package/xmonad-contrib-0.15/docs/XMonad-Layout-LayoutScreens.html +[19]: http://robm.github.io/dzen/ +[20]: https://github.com/brndnmtthws/conky +[21]: https://hookrace.net/public/linux-desktop/laptop_small.png +[22]: https://hookrace.net/public/linux-desktop/laptop.png +[23]: https://i3wm.org/ +[24]: https://github.com/tmux/tmux/wiki +[25]: http://dtach.sourceforge.net/ +[26]: https://github.com/def-/tach/blob/master/tach +[27]: https://www.gnu.org/software/bash/ +[28]: http://www.zsh.org/ +[29]: http://software.schmorp.de/pkg/rxvt-unicode.html +[30]: http://terminus-font.sourceforge.net/ +[31]: https://www.vim.org/ +[32]: http://ctags.sourceforge.net/ +[33]: https://www.python.org/ +[34]: https://nim-lang.org/ +[35]: https://hisham.hm/htop/ +[36]: http://lm-sensors.org/ +[37]: https://01.org/powertop/ +[38]: https://dev.yorhel.nl/ncdu +[39]: https://nmap.org/ +[40]: https://www.tcpdump.org/ +[41]: https://www.wireshark.org/ +[42]: http://www.fetchmail.info/ +[43]: http://www.procmail.org/ +[44]: https://marlam.de/msmtp/ +[45]: https://www.cis.upenn.edu/~bcpierce/unison/ +[46]: https://rsync.samba.org/ +[47]: http://www.mutt.org/ +[48]: https://newsboat.org/ +[49]: https://irssi.org/ +[50]: https://www.roaringpenguin.com/products/remind +[51]: https://hookrace.net/public/linux-desktop/remcal.png +[52]: https://github.com/tsdh/rdictcc +[53]: https://www.dict.cc/ +[54]: https://www.latex-project.org/ +[55]: http://felsin9.de/nnis/research/ +[56]: https://pwmt.org/projects/zathura/ +[57]: https://wiki.gnome.org/Apps/Evince +[58]: https://www.gimp.org/ +[59]: https://inkscape.org/ +[60]: https://imagemagick.org/Usage/ +[61]: https://www.graphviz.org/ +[62]: https://sourceforge.net/projects/pgf/ +[63]: https://www.mozilla.org/en-US/firefox/new/ +[64]: https://github.com/5digits/dactyl +[65]: https://mpv.io/ +[66]: https://rg3.github.io/youtube-dl/ +[67]: http://moc.daper.net/ +[68]: https://aur.archlinux.org/packages/moc-pulse/ +[69]: https://hookrace.net/public/linux-desktop/moc.png +[70]: https://github.com/libfuse/sshfs +[71]: https://www.qemu.org/ +[72]: http://www.mingw.org/ +[73]: https://github.com/tpoechtrager/osxcross +[74]: https://github.com/ddnet/ddnet-scripts/blob/master/ddnet-release.sh +[75]: https://github.com/ddnet/ddnet-scripts/blob/master/ddnet-lib-update.sh +[76]: https://github.com/def-/rrb/blob/master/rrb +[77]: https://github.com/def-/rrb/blob/master/config.example +[78]: mailto:dennis@felsin9.de +[79]: https://news.ycombinator.com/item?id=18979731 diff --git a/sources/tech/20190116 The Evil-Twin Framework- A tool for improving WiFi security.md b/sources/tech/20190116 The Evil-Twin Framework- A tool for improving WiFi security.md deleted file mode 100644 index 81b5d2ddf1..0000000000 --- a/sources/tech/20190116 The Evil-Twin Framework- A tool for improving WiFi security.md +++ /dev/null @@ -1,236 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (The Evil-Twin Framework: A tool for improving WiFi security) -[#]: via: (https://opensource.com/article/19/1/evil-twin-framework) -[#]: author: (André Esser https://opensource.com/users/andreesser) - -The Evil-Twin Framework: A tool for improving WiFi security -====== -Learn about a pen-testing tool intended to test the security of WiFi access points for all types of threats. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-cloud-safe.png?itok=yj2TFPzq) - -The increasing number of devices that connect over-the-air to the internet over-the-air and the wide availability of WiFi access points provide many opportunities for attackers to exploit users. By tricking users to connect to [rogue access points][1], hackers gain full control over the users' network connection, which allows them to sniff and alter traffic, redirect users to malicious sites, and launch other attacks over the network.. - -To protect users and teach them to avoid risky online behaviors, security auditors and researchers must evaluate users' security practices and understand the reasons they connect to WiFi access points without being confident they are safe. There are a significant number of tools that can conduct WiFi audits, but no single tool can test the many different attack scenarios and none of the tools integrate well with one another. - -The **Evil-Twin Framework** (ETF) aims to fix these problems in the WiFi auditing process by enabling auditors to examine multiple scenarios and integrate multiple tools. This article describes the framework and its functionalities, then provides some examples to show how it can be used. - -### The ETF architecture - -The ETF framework was written in [Python][2] because the development language is very easy to read and make contributions to. In addition, many of the ETF's libraries, such as **[Scapy][3]** , were already developed for Python, making it easy to use them for ETF. - -The ETF architecture (Figure 1) is divided into different modules that interact with each other. The framework's settings are all written in a single configuration file. The user can verify and edit the settings through the user interface via the **ConfigurationManager** class. Other modules can only read these settings and run according to them. - -![Evil-Twin Framework Architecture][5] - -Figure 1: Evil-Twin framework architecture - -The ETF supports multiple user interfaces that interact with the framework. The current default interface is an interactive console, similar to the one on [Metasploit][6]. A graphical user interface (GUI) and a command line interface (CLI) are under development for desktop/browser use, and mobile interfaces may be an option in the future. The user can edit the settings in the configuration file using the interactive console (and eventually with the GUI). The user interface can interact with every other module that exists in the framework. - -The WiFi module ( **AirCommunicator** ) was built to support a wide range of WiFi capabilities and attacks. The framework identifies three basic pillars of Wi-Fi communication: **packet sniffing** , **custom packet injection** , and **access point creation**. The three main WiFi communication modules are **AirScanner** , **AirInjector** , and **AirHost** , which are responsible for packet sniffing, packet injection, and access point creation, respectively. The three classes are wrapped inside the main WiFi module, AirCommunicator, which reads the configuration file before starting the services. Any type of WiFi attack can be built using one or more of these core features. - -To enable man-in-the-middle (MITM) attacks, which are a common way to attack WiFi clients, the framework has an integrated module called ETFITM (Evil-Twin Framework-in-the-Middle). This module is responsible for the creation of a web proxy used to intercept and manipulate HTTP/HTTPS traffic. - -There are many other tools that can leverage the MITM position created by the ETF. Through its extensibility, ETF can support them—and, instead of having to call them separately, you can add the tools to the framework just by extending the Spawner class. This enables a developer or security auditor to call the program with a preconfigured argument string from within the framework. - -The other way to extend the framework is through plugins. There are two categories of plugins: **WiFi plugins** and **MITM plugins**. MITM plugins are scripts that can run while the MITM proxy is active. The proxy passes the HTTP(S) requests and responses through to the plugins where they can be logged or manipulated. WiFi plugins follow a more complex flow of execution but still expose a fairly simple API to contributors who wish to develop and use their own plugins. WiFi plugins can be further divided into three categories, one for each of the core WiFi communication modules. - -Each of the core modules has certain events that trigger the execution of a plugin. For instance, AirScanner has three defined events to which a response can be programmed. The events usually correspond to a setup phase before the service starts running, a mid-execution phase while the service is running, and a teardown or cleanup phase after a service finishes. Since Python allows multiple inheritance, one plugin can subclass more than one plugin class. - -Figure 1 above is a summary of the framework's architecture. Lines pointing away from the ConfigurationManager mean that the module reads information from it and lines pointing towards it mean that the module can write/edit configurations. - -### Examples of using the Evil-Twin Framework - -There are a variety of ways ETF can conduct penetration testing on WiFi network security or work on end users' awareness of WiFi security. The following examples describe some of the framework's pen-testing functionalities, such as access point and client detection, WPA and WEP access point attacks, and evil twin access point creation. - -These examples were devised using ETF with WiFi cards that allow WiFi traffic capture. They also utilize the following abbreviations for ETF setup commands: - - * **APS** access point SSID - * **APB** access point BSSID - * **APC** access point channel - * **CM** client MAC address - - - -In a real testing scenario, make sure to replace these abbreviations with the correct information. - -#### Capturing a WPA 4-way handshake after a de-authentication attack - -This scenario (Figure 2) takes two aspects into consideration: the de-authentication attack and the possibility of catching a 4-way WPA handshake. The scenario starts with a running WPA/WPA2-enabled access point with one connected client device (in this case, a smartphone). The goal is to de-authenticate the client with a general de-authentication attack then capture the WPA handshake once it tries to reconnect. The reconnection will be done manually immediately after being de-authenticated. - -![Scenario for capturing a WPA handshake after a de-authentication attack][8] - -Figure 2: Scenario for capturing a WPA handshake after a de-authentication attack - -The consideration in this example is the ETF's reliability. The goal is to find out if the tools can consistently capture the WPA handshake. The scenario will be performed multiple times with each tool to check its reliability when capturing the WPA handshake. - -There is more than one way to capture a WPA handshake using the ETF. One way is to use a combination of the AirScanner and AirInjector modules; another way is to just use the AirInjector. The following scenario uses a combination of both modules. - -The ETF launches the AirScanner module and analyzes the IEEE 802.11 frames to find a WPA handshake. Then the AirInjector can launch a de-authentication attack to force a reconnection. The following steps must be done to accomplish this on the ETF: - - 1. Enter the AirScanner configuration mode: **config airscanner** - 2. Configure the AirScanner to not hop channels: **config airscanner** - 3. Set the channel to sniff the traffic on the access point channel (APC): **set fixed_sniffing_channel = ** - 4. Start the AirScanner module with the CredentialSniffer plugin: **start airscanner with credentialsniffer** - 5. Add a target access point BSSID (APS) from the sniffed access points list: **add aps where ssid = ** - 6. Start the AirInjector, which by default lauches the de-authentication attack: **start airinjector** - - - -This simple set of commands enables the ETF to perform an efficient and successful de-authentication attack on every test run. The ETF can also capture the WPA handshake on every test run. The following code makes it possible to observe the ETF's successful execution. - -``` -███████╗████████╗███████╗ -██╔════╝╚══██╔══╝██╔════╝ -█████╗     ██║   █████╗   -██╔══╝     ██║   ██╔══╝   -███████╗   ██║   ██║     -╚══════╝   ╚═╝   ╚═╝     -                                        - -[+] Do you want to load an older session? [Y/n]: n -[+] Creating new temporary session on 02/08/2018 -[+] Enter the desired session name: -ETF[etf/aircommunicator/]::> config airscanner -ETF[etf/aircommunicator/airscanner]::> listargs -  sniffing_interface =               wlan1; (var) -              probes =                True; (var) -             beacons =                True; (var) -        hop_channels =               false; (var) -fixed_sniffing_channel =                  11; (var) -ETF[etf/aircommunicator/airscanner]::> start airscanner with -arpreplayer        caffelatte         credentialsniffer  packetlogger       selfishwifi         -ETF[etf/aircommunicator/airscanner]::> start airscanner with credentialsniffer -[+] Successfully added credentialsniffer plugin. -[+] Starting packet sniffer on interface 'wlan1' -[+] Set fixed channel to 11 -ETF[etf/aircommunicator/airscanner]::> add aps where ssid = CrackWPA -ETF[etf/aircommunicator/airscanner]::> start airinjector -ETF[etf/aircommunicator/airscanner]::> [+] Starting deauthentication attack -                    - 1000 bursts of 1 packets -                    - 1 different packets -[+] Injection attacks finished executing. -[+] Starting post injection methods -[+] Post injection methods finished -[+] WPA Handshake found for client '70:3e:ac:bb:78:64' and network 'CrackWPA' -``` - -#### Launching an ARP replay attack and cracking a WEP network - -The next scenario (Figure 3) will also focus on the [Address Resolution Protocol][9] (ARP) replay attack's efficiency and the speed of capturing the WEP data packets containing the initialization vectors (IVs). The same network may require a different number of caught IVs to be cracked, so the limit for this scenario is 50,000 IVs. If the network is cracked during the first test with less than 50,000 IVs, that number will be the new limit for the following tests on the network. The cracking tool to be used will be **aircrack-ng**. - -The test scenario starts with an access point using WEP encryption and an offline client that knows the key—the key for testing purposes is 12345, but it can be a larger and more complex key. Once the client connects to the WEP access point, it will send out a gratuitous ARP packet; this is the packet that's meant to be captured and replayed. The test ends once the limit of packets containing IVs is captured. - -![Scenario for capturing a WPA handshake after a de-authentication attack][11] - -Figure 3: Scenario for capturing a WPA handshake after a de-authentication attack - -ETF uses Python's Scapy library for packet sniffing and injection. To minimize known performance problems in Scapy, ETF tweaks some of its low-level libraries to significantly speed packet injection. For this specific scenario, the ETF uses **tcpdump** as a background process instead of Scapy for more efficient packet sniffing, while Scapy is used to identify the encrypted ARP packet. - -This scenario requires the following commands and operations to be performed on the ETF: - - 1. Enter the AirScanner configuration mode: **config airscanner** - 2. Configure the AirScanner to not hop channels: **set hop_channels = false** - 3. Set the channel to sniff the traffic on the access point channel (APC): **set fixed_sniffing_channel = ** - 4. Enter the ARPReplayer plugin configuration mode: **config arpreplayer** - 5. Set the target access point BSSID (APB) of the WEP network: **set target_ap_bssid ** - 6. Start the AirScanner module with the ARPReplayer plugin: **start airscanner with arpreplayer** - - - -After executing these commands, ETF correctly identifies the encrypted ARP packet, then successfully performs an ARP replay attack, which cracks the network. - -#### Launching a catch-all honeypot - -The scenario in Figure 4 creates multiple access points with the same SSID. This technique discovers the encryption type of a network that was probed for but out of reach. By launching multiple access points with all security settings, the client will automatically connect to the one that matches the security settings of the locally cached access point information. - -![Scenario for capturing a WPA handshake after a de-authentication attack][13] - -Figure 4: Scenario for capturing a WPA handshake after a de-authentication attack - -Using the ETF, it is possible to configure the **hostapd** configuration file then launch the program in the background. Hostapd supports launching multiple access points on the same wireless card by configuring virtual interfaces, and since it supports all types of security configurations, a complete catch-all honeypot can be set up. For the WEP and WPA(2)-PSK networks, a default password is used, and for the WPA(2)-EAP, an "accept all" policy is configured. - -For this scenario, the following commands and operations must be performed on the ETF: - - 1. Enter the APLauncher configuration mode: **config aplauncher** - 2. Set the desired access point SSID (APS): **set ssid = ** - 3. Configure the APLauncher as a catch-all honeypot: **set catch_all_honeypot = true** - 4. Start the AirHost module: **start airhost** - - - -With these commands, the ETF can launch a complete catch-all honeypot with all types of security configurations. ETF also automatically launches the DHCP and DNS servers that allow clients to stay connected to the internet. ETF offers a better, faster, and more complete solution to create catch-all honeypots. The following code enables the successful execution of the ETF to be observed. - -``` -███████╗████████╗███████╗ -██╔════╝╚══██╔══╝██╔════╝ -█████╗     ██║   █████╗   -██╔══╝     ██║   ██╔══╝   -███████╗   ██║   ██║     -╚══════╝   ╚═╝   ╚═╝     -                                        - -[+] Do you want to load an older session? [Y/n]: n -[+] Creating ne´,cxzw temporary session on 03/08/2018 -[+] Enter the desired session name: -ETF[etf/aircommunicator/]::> config aplauncher -ETF[etf/aircommunicator/airhost/aplauncher]::> setconf ssid CatchMe -ssid = CatchMe -ETF[etf/aircommunicator/airhost/aplauncher]::> setconf catch_all_honeypot true -catch_all_honeypot = true -ETF[etf/aircommunicator/airhost/aplauncher]::> start airhost -[+] Killing already started processes and restarting network services -[+] Stopping dnsmasq and hostapd services -[+] Access Point stopped... -[+] Running airhost plugins pre_start -[+] Starting hostapd background process -[+] Starting dnsmasq service -[+] Running airhost plugins post_start -[+] Access Point launched successfully -[+] Starting dnsmasq service -``` - -### Conclusions and future work - -These scenarios use common and well-known attacks to help validate the ETF's capabilities for testing WiFi networks and clients. The results also validate that the framework's architecture enables new attack vectors and features to be developed on top of it while taking advantage of the platform's existing capabilities. This should accelerate development of new WiFi penetration-testing tools, since a lot of the code is already written. Furthermore, the fact that complementary WiFi technologies are all integrated in a single tool will make WiFi pen-testing simpler and more efficient. - -The ETF's goal is not to replace existing tools but to complement them and offer a broader choice to security auditors when conducting WiFi pen-testing and improving user awareness. - -The ETF is an open source project [available on GitHub][14] and community contributions to its development are welcomed. Following are some of the ways you can help. - -One of the limitations of current WiFi pen-testing is the inability to log important events during tests. This makes reporting identified vulnerabilities both more difficult and less accurate. The framework could implement a logger that can be accessed by every class to create a pen-testing session report. - -The ETF tool's capabilities cover many aspects of WiFi pen-testing. On one hand, it facilitates the phases of WiFi reconnaissance, vulnerability discovery, and attack. On the other hand, it doesn't offer a feature that facilitates the reporting phase. Adding the concept of a session and a session reporting feature, such as the logging of important events during a session, would greatly increase the value of the tool for real pen-testing scenarios. - -Another valuable contribution would be extending the framework to facilitate WiFi fuzzing. The IEEE 802.11 protocol is very complex, and considering there are multiple implementations of it, both on the client and access point side, it's safe to assume these implementations contain bugs and even security flaws. These bugs could be discovered by fuzzing IEEE 802.11 protocol frames. Since Scapy allows custom packet creation and injection, a fuzzer can be implemented through it. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/evil-twin-framework - -作者:[André Esser][a] -选题:[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/andreesser -[b]: https://github.com/lujun9972 -[1]: https://en.wikipedia.org/wiki/Rogue_access_point -[2]: https://www.python.org/ -[3]: https://scapy.net -[4]: /file/417776 -[5]: https://opensource.com/sites/default/files/uploads/pic1.png (Evil-Twin Framework Architecture) -[6]: https://www.metasploit.com -[7]: /file/417781 -[8]: https://opensource.com/sites/default/files/uploads/pic2.png (Scenario for capturing a WPA handshake after a de-authentication attack) -[9]: https://en.wikipedia.org/wiki/Address_Resolution_Protocol -[10]: /file/417786 -[11]: https://opensource.com/sites/default/files/uploads/pic3.png (Scenario for capturing a WPA handshake after a de-authentication attack) -[12]: /file/417791 -[13]: https://opensource.com/sites/default/files/uploads/pic4.png (Scenario for capturing a WPA handshake after a de-authentication attack) -[14]: https://github.com/Esser420/EvilTwinFramework diff --git a/sources/tech/20190121 Akira- The Linux Design Tool We-ve Always Wanted.md b/sources/tech/20190121 Akira- The Linux Design Tool We-ve Always Wanted.md deleted file mode 100644 index bd58eca5bf..0000000000 --- a/sources/tech/20190121 Akira- The Linux Design Tool We-ve Always Wanted.md +++ /dev/null @@ -1,92 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Akira: The Linux Design Tool We’ve Always Wanted?) -[#]: via: (https://itsfoss.com/akira-design-tool) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -Akira: The Linux Design Tool We’ve Always Wanted? -====== - -Let’s make it clear, I am not a professional designer – but I’ve used certain tools on Windows (like Photoshop, Illustrator, etc.) and [Figma][1] (which is a browser-based interface design tool). I’m sure there are a lot more design tools available for Mac and Windows. - -Even on Linux, there is a limited number of dedicated [graphic design tools][2]. A few of these tools like [GIMP][3] and [Inkscape][4] are used by professionals as well. But most of them are not considered professional grade, unfortunately. - -Even if there are a couple more solutions – I’ve never come across a native Linux application that could replace [Sketch][5], Figma, or Adobe **** XD. Any professional designer would agree to that, isn’t it? - -### Is Akira going to replace Sketch, Figma, and Adobe XD on Linux? - -Well, in order to develop something that would replace those awesome proprietary tools – [Alessandro Castellani][6] – came up with a [Kickstarter campaign][7] by teaming up with a couple of experienced developers – -[Alberto Fanjul][8], [Bilal Elmoussaoui][9], and [Felipe Escoto][10]. - -So, yes, Akira is still pretty much just an idea- with a working prototype of its interface (as I observed in their [live stream session][11] via Kickstarter recently). - -### If it does not exist, why the Kickstarter campaign? - -![][12] - -The aim of the Kickstarter campaign is to gather funds in order to hire the developers and take a few months off to dedicate their time in order to make Akira possible. - -Nonetheless, if you want to support the project, you should know some details, right? - -Fret not, we asked a couple of questions in their livestream session – let’s get into it… - -### Akira: A few more details - -![Akira prototype interface][13] -Image Credits: Kickstarter - -As the Kickstarter campaign describes: - -> The main purpose of Akira is to offer a fast and intuitive tool to **create Web and Mobile interfaces** , more like **Sketch** , **Figma** , or **Adobe XD** , with a completely native experience for Linux. - -They’ve also written a detailed description as to how the tool will be different from Inkscape, Glade, or QML Editor. Of course, if you want all the technical details, [Kickstarter][7] is the way to go. But, before that, let’s take a look at what they had to say when I asked some questions about Akira. - -Q: If you consider your project – similar to what Figma offers – why should one consider installing Akira instead of using the web-based tool? Is it just going to be a clone of those tools – offering a native Linux experience or is there something really interesting to encourage users to switch (except being an open source solution)? - -**Akira:** A native experience on Linux is always better and fast in comparison to a web-based electron app. Also, the hardware configuration matters if you choose to utilize Figma – but Akira will be light on system resource and you will still be able to do similar stuff without needing to go online. - -Q: Let’s assume that it becomes the open source solution that Linux users have been waiting for (with similar features offered by proprietary tools). What are your plans to sustain it? Do you plan to introduce any pricing plans – or rely on donations? - -**Akira** : The project will mostly rely on Donations (something like [Krita Foundation][14] could be an idea). But, there will be no “pro” pricing plans – it will be available for free and it will be an open source project. - -So, with the response I got, it definitely seems to be something promising that we should probably support. - -### Wrapping Up - -What do you think about Akira? Is it just going to remain a concept? Or do you hope to see it in action? - -Let us know your thoughts in the comments below. - -![][15] - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/akira-design-tool - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://www.figma.com/ -[2]: https://itsfoss.com/best-linux-graphic-design-software/ -[3]: https://itsfoss.com/gimp-2-10-release/ -[4]: https://inkscape.org/ -[5]: https://www.sketchapp.com/ -[6]: https://github.com/Alecaddd -[7]: https://www.kickstarter.com/projects/alecaddd/akira-the-linux-design-tool/description -[8]: https://github.com/albfan -[9]: https://github.com/bilelmoussaoui -[10]: https://github.com/Philip-Scott -[11]: https://live.kickstarter.com/alessandro-castellani/live-stream/the-current-state-of-akira -[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/akira-design-tool-kickstarter.jpg?resize=800%2C451&ssl=1 -[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/akira-mockup.png?ssl=1 -[14]: https://krita.org/en/about/krita-foundation/ -[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/akira-design-tool-kickstarter.jpg?fit=812%2C458&ssl=1 diff --git a/sources/tech/20190121 Get started with TaskBoard, a lightweight kanban board.md b/sources/tech/20190121 Get started with TaskBoard, a lightweight kanban board.md deleted file mode 100644 index e083d650e5..0000000000 --- a/sources/tech/20190121 Get started with TaskBoard, a lightweight kanban board.md +++ /dev/null @@ -1,59 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Get started with TaskBoard, a lightweight kanban board) -[#]: via: (https://opensource.com/article/19/1/productivity-tool-taskboard) -[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) - -Get started with TaskBoard, a lightweight kanban board -====== -Check out the ninth tool in our series on open source tools that will make you more productive in 2019. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/checklist_hands_team_collaboration.png?itok=u82QepPk) - -There seems to be a mad rush at the beginning of every year to find ways to be more productive. New Year's resolutions, the itch to start the year off right, and of course, an "out with the old, in with the new" attitude all contribute to this. And the usual round of recommendations is heavily biased towards closed source and proprietary software. It doesn't have to be that way. - -Here's the ninth of my picks for 19 new (or new-to-you) open source tools to help you be more productive in 2019. - -### TaskBoard - -As I wrote in the [second article][1] in this series, [kanban boards][2] are pretty popular these days. And not all kanban boards are created equal. [TaskBoard][3] is a PHP application that is easy to set up on an existing web server and has a set of functions that make it easy to use and manage. - -![](https://opensource.com/sites/default/files/uploads/taskboard-1.png) - -[Installation][4] is as simple as unzipping the files on your web server, running a script or two, and making sure the correct directories are accessible. The first time you start it up, you're presented with a login form, and then it's time to start adding users and making boards. Board creation options include adding the columns you want to use and setting the default color of the cards. You can also assign users to boards so everyone sees only the boards they need to see. - -User management is lightweight, and all accounts are local to the server. You can set a default board for everyone on the server, and users can set their own default boards, too. These options can be useful when someone works on one board more than others. - -![](https://opensource.com/sites/default/files/uploads/taskboard-2.png) - -TaskBoard also allows you to create automatic actions, which are actions taken upon changes to user assignment, columns, or card categories. Although TaskBoard is not as powerful as some other kanban apps, you can set up automatic actions to make cards more visible for board users, clear due dates, and auto-assign new cards to people as needed. For example, in the screenshot below, if a card is assigned to the "admin" user, its color is changed to red, and when a card is assigned to my user, its color is changed to teal. I've also added an action to clear an item's due date if it's added to the "To-Do" column and to auto-assign cards to my user when that happens. - -![](https://opensource.com/sites/default/files/uploads/taskboard-3.png) - -The cards are very straightforward. While they don't have a start date, they do have end dates and a points field. Points can be used for estimating the time needed, effort required, or just general priority. Using points is optional, but if you are using TaskBoard for scrum planning or other agile techniques, it is a really handy feature. You can also filter the view by users and categories. This can be helpful on a team with multiple work streams going on, as it allows a team lead or manager to get status information about progress or a person's workload. - -![](https://opensource.com/sites/default/files/uploads/taskboard-4.png) - -If you need a reasonably lightweight kanban board, check out TaskBoard. It installs quickly, has some nice features, and is very, very easy to use. It's also flexible enough to be used for development teams, personal task tracking, and a whole lot more. - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/productivity-tool-taskboard - -作者:[Kevin Sonney][a] -选题:[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/ksonney (Kevin Sonney) -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/article/19/1/productivity-tool-wekan -[2]: https://en.wikipedia.org/wiki/Kanban -[3]: https://taskboard.matthewross.me/ -[4]: https://taskboard.matthewross.me/docs/ diff --git a/sources/tech/20190122 Get started with Go For It, a flexible to-do list application.md b/sources/tech/20190122 Get started with Go For It, a flexible to-do list application.md deleted file mode 100644 index 56dde41884..0000000000 --- a/sources/tech/20190122 Get started with Go For It, a flexible to-do list application.md +++ /dev/null @@ -1,60 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Get started with Go For It, a flexible to-do list application) -[#]: via: (https://opensource.com/article/19/1/productivity-tool-go-for-it) -[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) - -Get started with Go For It, a flexible to-do list application -====== -Go For It, the tenth in our series on open source tools that will make you more productive in 2019, builds on the Todo.txt system to help you get more things done. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/coffee_cafe_brew_laptop_desktop.jpg?itok=G-n1o1-o) - -There seems to be a mad rush at the beginning of every year to find ways to be more productive. New Year's resolutions, the itch to start the year off right, and of course, an "out with the old, in with the new" attitude all contribute to this. And the usual round of recommendations is heavily biased towards closed source and proprietary software. It doesn't have to be that way. - -Here's the tenth of my picks for 19 new (or new-to-you) open source tools to help you be more productive in 2019. - -### Go For It - -Sometimes what a person needs to be productive isn't a fancy kanban board or a set of notes, but a simple, straightforward to-do list. Something that is as basic as "add item to list, check it off when done." And for that, the [plain-text Todo.txt system][1] is possibly one of the easiest to use, and it's supported on almost every system out there. - -![](https://opensource.com/sites/default/files/uploads/go-for-it_1_1.png) - -[Go For It][2] is a simple, easy-to-use graphical interface for Todo.txt. It can be used with an existing file, if you are already using Todo.txt, and will create both a to-do and a done file if you aren't. It allows drag-and-drop ordering of tasks, allowing users to organize to-do items in the order they want to execute them. It also supports priorities, projects, and contexts, as outlined in the [Todo.txt format guidelines][3]. And, it can filter tasks by context or project simply by clicking on the project or context in the task list. - -![](https://opensource.com/sites/default/files/uploads/go-for-it_2.png) - -At first, Go For It may look the same as just about any other Todo.txt program, but looks can be deceiving. The real feature that sets Go For It apart is that it includes a built-in [Pomodoro Technique][4] timer. Select the task you want to complete, switch to the Timer tab, and click Start. When the task is done, simply click Done, and it will automatically reset the timer and pick the next task on the list. You can pause and restart the timer as well as click Skip to jump to the next task (or break). It provides a warning when 60 seconds are left for the current task. The default time for tasks is set at 25 minutes, and the default time for breaks is set at five minutes. You can adjust this in the Settings screen, as well as the location of the directory containing your Todo.txt and done.txt files. - -![](https://opensource.com/sites/default/files/uploads/go-for-it_3.png) - -Go For It's third tab, Done, allows you to look at the tasks you've completed and clean them out when you want. Being able to look at what you've accomplished can be very motivating and a good way to get a feel for where you are in a longer process. - -![](https://opensource.com/sites/default/files/uploads/go-for-it_4.png) - -It also has all of Todo.txt's other advantages. Go For It's list is accessible by other programs that use the same format, including [Todo.txt's original command-line tool][5] and any [add-ons][6] you've installed. - -Go For It seeks to be a simple tool to help manage your to-do list and get those items done. If you already use Todo.txt, Go For It is a fantastic addition to your toolkit, and if you don't, it's a really good way to start using one of the simplest and most flexible systems available. - - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/productivity-tool-go-for-it - -作者:[Kevin Sonney][a] -选题:[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/ksonney (Kevin Sonney) -[b]: https://github.com/lujun9972 -[1]: http://todotxt.org/ -[2]: http://manuel-kehl.de/projects/go-for-it/ -[3]: https://github.com/todotxt/todo.txt -[4]: https://en.wikipedia.org/wiki/Pomodoro_Technique -[5]: https://github.com/todotxt/todo.txt-cli -[6]: https://github.com/todotxt/todo.txt-cli/wiki/Todo.sh-Add-on-Directory diff --git a/sources/tech/20190122 How To Copy A File-Folder From A Local System To Remote System In Linux.md b/sources/tech/20190122 How To Copy A File-Folder From A Local System To Remote System In Linux.md deleted file mode 100644 index 6de6cd173f..0000000000 --- a/sources/tech/20190122 How To Copy A File-Folder From A Local System To Remote System In Linux.md +++ /dev/null @@ -1,398 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (How To Copy A File/Folder From A Local System To Remote System In Linux?) -[#]: via: (https://www.2daygeek.com/linux-scp-rsync-pscp-command-copy-files-folders-in-multiple-servers-using-shell-script/) -[#]: author: (Prakash Subramanian https://www.2daygeek.com/author/prakash/) - -How To Copy A File/Folder From A Local System To Remote System In Linux? -====== - -Copying a file from one server to another server or local to remote is one of the routine task for Linux administrator. - -If anyone says no, i won’t accept because this is one of the regular activity wherever you go. - -It can be done in many ways and we are trying to cover all the possible options. - -You can choose the one which you would prefer. Also, check other commands as well that may help you for some other purpose. - -I have tested all these commands and script in my test environment so, you can use this for your routine work. - -By default every one go with SCP because it’s one of the native command that everyone use for file copy. But commands which is listed in this article are be smart so, give a try if you would like to try new things. - -This can be done in below four ways easily. - - * **`SCP:`** scp copies files between hosts on a network. It uses ssh for data transfer, and uses the same authentication and provides the same security as ssh. - * **`RSYNC:`** rsync is a fast and extraordinarily versatile file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. - * **`PSCP:`** pscp is a program for copying files in parallel to a number of hosts. It provides features such as passing a password to scp, saving output to files, and timing out. - * **`PRSYNC:`** prsync is a program for copying files in parallel to a number of hosts. It provides features such as passing a password to ssh, saving output to files, and timing out. - - - -### Method-1: Copy Files/Folders From A Local System To Remote System In Linux Using SCP Command? - -scp command allow us to copy files/folders from a local system to remote system. - -We are going to copy the `output.txt` file from my local system to `2g.CentOS.com` remote system under `/opt/backup` directory. - -``` -# scp output.txt root@2g.CentOS.com:/opt/backup - -output.txt 100% 2468 2.4KB/s 00:00 -``` - -We are going to copy two files `output.txt` and `passwd-up.sh` files from my local system to `2g.CentOS.com` remote system under `/opt/backup` directory. - -``` -# scp output.txt passwd-up.sh root@2g.CentOS.com:/opt/backup - -output.txt 100% 2468 2.4KB/s 00:00 -passwd-up.sh 100% 877 0.9KB/s 00:00 -``` - -We are going to copy the `shell-script` directory from my local system to `2g.CentOS.com` remote system under `/opt/backup` directory. - -This will copy the `shell-script` directory and associated files under `/opt/backup` directory. - -``` -# scp -r /home/daygeek/2g/shell-script/ [email protected]:/opt/backup/ - -output.txt 100% 2468 2.4KB/s 00:00 -ovh.sh 100% 76 0.1KB/s 00:00 -passwd-up.sh 100% 877 0.9KB/s 00:00 -passwd-up1.sh 100% 7 0.0KB/s 00:00 -server-list.txt 100% 23 0.0KB/s 00:00 -``` - -### Method-2: Copy Files/Folders From A Local System To Multiple Remote System In Linux Using Shell Script with scp Command? - -If you would like to copy the same file into multiple remote servers then create the following small shell script to achieve this. - -To do so, get the servers list and add those into `server-list.txt` file. Make sure you have to update the servers list into `server-list.txt` file. Each server should be in separate line. - -Finally mention the file location which you want to copy like below. - -``` -# file-copy.sh - -#!/bin/sh -for server in `more server-list.txt` -do - scp /home/daygeek/2g/shell-script/output.txt [email protected]$server:/opt/backup -done -``` - -Once you done, set an executable permission to password-update.sh file. - -``` -# chmod +x file-copy.sh -``` - -Finally run the script to achieve this. - -``` -# ./file-copy.sh - -output.txt 100% 2468 2.4KB/s 00:00 -output.txt 100% 2468 2.4KB/s 00:00 -``` - -Use the following script to copy the multiple files into multiple remote servers. - -``` -# file-copy.sh - -#!/bin/sh -for server in `more server-list.txt` -do - scp /home/daygeek/2g/shell-script/output.txt passwd-up.sh [email protected]$server:/opt/backup -done -``` - -The below output shows all the files twice as this copied into two servers. - -``` -# ./file-cp.sh - -output.txt 100% 2468 2.4KB/s 00:00 -passwd-up.sh 100% 877 0.9KB/s 00:00 -output.txt 100% 2468 2.4KB/s 00:00 -passwd-up.sh 100% 877 0.9KB/s 00:00 -``` - -Use the following script to copy the directory recursively into multiple remote servers. - -``` -# file-copy.sh - -#!/bin/sh -for server in `more server-list.txt` -do - scp -r /home/daygeek/2g/shell-script/ [email protected]$server:/opt/backup -done -``` - -Output for the above script. - -``` -# ./file-cp.sh - -output.txt 100% 2468 2.4KB/s 00:00 -ovh.sh 100% 76 0.1KB/s 00:00 -passwd-up.sh 100% 877 0.9KB/s 00:00 -passwd-up1.sh 100% 7 0.0KB/s 00:00 -server-list.txt 100% 23 0.0KB/s 00:00 - -output.txt 100% 2468 2.4KB/s 00:00 -ovh.sh 100% 76 0.1KB/s 00:00 -passwd-up.sh 100% 877 0.9KB/s 00:00 -passwd-up1.sh 100% 7 0.0KB/s 00:00 -server-list.txt 100% 23 0.0KB/s 00:00 -``` - -### Method-3: Copy Files/Folders From A Local System To Multiple Remote System In Linux Using PSCP Command? - -pscp command directly allow us to perform the copy to multiple remote servers. - -Use the following pscp command to copy a single file to remote server. - -``` -# pscp.pssh -H 2g.CentOS.com /home/daygeek/2g/shell-script/output.txt /opt/backup - -[1] 18:46:11 [SUCCESS] 2g.CentOS.com -``` - -Use the following pscp command to copy a multiple files to remote server. - -``` -# pscp.pssh -H 2g.CentOS.com /home/daygeek/2g/shell-script/output.txt ovh.sh /opt/backup - -[1] 18:47:48 [SUCCESS] 2g.CentOS.com -``` - -Use the following pscp command to copy a directory recursively to remote server. - -``` -# pscp.pssh -H 2g.CentOS.com -r /home/daygeek/2g/shell-script/ /opt/backup - -[1] 18:48:46 [SUCCESS] 2g.CentOS.com -``` - -Use the following pscp command to copy a single file to multiple remote servers. - -``` -# pscp.pssh -h server-list.txt /home/daygeek/2g/shell-script/output.txt /opt/backup - -[1] 18:49:48 [SUCCESS] 2g.CentOS.com -[2] 18:49:48 [SUCCESS] 2g.Debian.com -``` - -Use the following pscp command to copy a multiple files to multiple remote servers. - -``` -# pscp.pssh -h server-list.txt /home/daygeek/2g/shell-script/output.txt passwd-up.sh /opt/backup - -[1] 18:50:30 [SUCCESS] 2g.Debian.com -[2] 18:50:30 [SUCCESS] 2g.CentOS.com -``` - -Use the following pscp command to copy a directory recursively to multiple remote servers. - -``` -# pscp.pssh -h server-list.txt -r /home/daygeek/2g/shell-script/ /opt/backup - -[1] 18:51:31 [SUCCESS] 2g.Debian.com -[2] 18:51:31 [SUCCESS] 2g.CentOS.com -``` - -### Method-4: Copy Files/Folders From A Local System To Multiple Remote System In Linux Using rsync Command? - -Rsync is a fast and extraordinarily versatile file copying tool. It can copy locally, to/from another host over any remote shell, or to/from a remote rsync daemon. - -Use the following rsync command to copy a single file to remote server. - -``` -# rsync -avz /home/daygeek/2g/shell-script/output.txt [email protected]:/opt/backup - -sending incremental file list -output.txt - -sent 598 bytes received 31 bytes 1258.00 bytes/sec -total size is 2468 speedup is 3.92 -``` - -Use the following pscp command to copy a multiple files to remote server. - -``` -# rsync -avz /home/daygeek/2g/shell-script/output.txt passwd-up.sh root@2g.CentOS.com:/opt/backup - -sending incremental file list -output.txt -passwd-up.sh - -sent 737 bytes received 50 bytes 1574.00 bytes/sec -total size is 2537 speedup is 3.22 -``` - -Use the following rsync command to copy a single file to remote server overh ssh. - -``` -# rsync -avzhe ssh /home/daygeek/2g/shell-script/output.txt root@2g.CentOS.com:/opt/backup - -sending incremental file list -output.txt - -sent 598 bytes received 31 bytes 419.33 bytes/sec -total size is 2.47K speedup is 3.92 -``` - -Use the following pscp command to copy a directory recursively to remote server over ssh. This will copy only files not the base directory. - -``` -# rsync -avzhe ssh /home/daygeek/2g/shell-script/ root@2g.CentOS.com:/opt/backup - -sending incremental file list -./ -output.txt -ovh.sh -passwd-up.sh -passwd-up1.sh -server-list.txt - -sent 3.85K bytes received 281 bytes 8.26K bytes/sec -total size is 9.12K speedup is 2.21 -``` - -### Method-5: Copy Files/Folders From A Local System To Multiple Remote System In Linux Using Shell Script with rsync Command? - -If you would like to copy the same file into multiple remote servers then create the following small shell script to achieve this. - -``` -# file-copy.sh - -#!/bin/sh -for server in `more server-list.txt` -do - rsync -avzhe ssh /home/daygeek/2g/shell-script/ root@2g.CentOS.com$server:/opt/backup -done -``` - -Output for the above shell script. - -``` -# ./file-copy.sh - -sending incremental file list -./ -output.txt -ovh.sh -passwd-up.sh -passwd-up1.sh -server-list.txt - -sent 3.86K bytes received 281 bytes 8.28K bytes/sec -total size is 9.13K speedup is 2.21 - -sending incremental file list -./ -output.txt -ovh.sh -passwd-up.sh -passwd-up1.sh -server-list.txt - -sent 3.86K bytes received 281 bytes 2.76K bytes/sec -total size is 9.13K speedup is 2.21 -``` - -### Method-6: Copy Files/Folders From A Local System To Multiple Remote System In Linux Using Shell Script with scp Command? - -In the above two shell script, we need to mention the file and folder location as a prerequiesties but here i did a small modification that allow the script to get a file or folder as a input. It could be very useful when you want to perform the copy multiple times in a day. - -``` -# file-copy.sh - -#!/bin/sh -for server in `more server-list.txt` -do -scp -r $1 root@2g.CentOS.com$server:/opt/backup -done -``` - -Run the shell script and give the file name as a input. - -``` -# ./file-copy.sh output1.txt - -output1.txt 100% 3558 3.5KB/s 00:00 -output1.txt 100% 3558 3.5KB/s 00:00 -``` - -### Method-7: Copy Files/Folders From A Local System To Multiple Remote System In Linux With Non-Standard Port Number? - -Use the below shell script to copy a file or folder if you are using Non-Standard port. - -If you are using `Non-Standard` port, make sure you have to mention the port number as follow for SCP command. - -``` -# file-copy-scp.sh - -#!/bin/sh -for server in `more server-list.txt` -do -scp -P 2222 -r $1 root@2g.CentOS.com$server:/opt/backup -done -``` - -Run the shell script and give the file name as a input. - -``` -# ./file-copy.sh ovh.sh - -ovh.sh 100% 3558 3.5KB/s 00:00 -ovh.sh 100% 3558 3.5KB/s 00:00 -``` - -If you are using `Non-Standard` port, make sure you have to mention the port number as follow for rsync command. - -``` -# file-copy-rsync.sh - -#!/bin/sh -for server in `more server-list.txt` -do -rsync -avzhe 'ssh -p 2222' $1 root@2g.CentOS.com$server:/opt/backup -done -``` - -Run the shell script and give the file name as a input. - -``` -# ./file-copy-rsync.sh passwd-up.sh -sending incremental file list -passwd-up.sh - -sent 238 bytes received 35 bytes 26.00 bytes/sec -total size is 159 speedup is 0.58 - -sending incremental file list -passwd-up.sh - -sent 238 bytes received 35 bytes 26.00 bytes/sec -total size is 159 speedup is 0.58 -``` --------------------------------------------------------------------------------- - -via: https://www.2daygeek.com/linux-scp-rsync-pscp-command-copy-files-folders-in-multiple-servers-using-shell-script/ - -作者:[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 diff --git a/sources/tech/20190123 Mind map yourself using FreeMind and Fedora.md b/sources/tech/20190123 Mind map yourself using FreeMind and Fedora.md deleted file mode 100644 index 146f95752a..0000000000 --- a/sources/tech/20190123 Mind map yourself using FreeMind and Fedora.md +++ /dev/null @@ -1,81 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Mind map yourself using FreeMind and Fedora) -[#]: via: (https://fedoramagazine.org/mind-map-yourself-using-freemind-and-fedora/) -[#]: author: (Paul W. Frields https://fedoramagazine.org/author/pfrields/) - -Mind map yourself using FreeMind and Fedora -====== -![](https://fedoramagazine.org/wp-content/uploads/2019/01/freemind-816x345.jpg) - -A mind map of yourself sounds a little far-fetched at first. Is this process about neural pathways? Or telepathic communication? Not at all. Instead, a mind map of yourself is a way to describe yourself to others visually. It also shows connections among the characteristics you use to describe yourself. It’s a useful way to share information with others in a clever but also controllable way. You can use any mind map application for this purpose. This article shows you how to get started using [FreeMind][1], available in Fedora. - -### Get the application - -The FreeMind application has been around a while. While the UI is a bit dated and could use a refresh, it’s a powerful app that offers many options for building mind maps. And of course it’s 100% open source. There are other mind mapping apps available for Fedora and Linux users, as well. Check out [this previous article that covers several mind map options][2]. - -Install FreeMind from the Fedora repositories using the Software app if you’re running Fedora Workstation. Or use this [sudo][3] command in a terminal: - -``` -$ sudo dnf install freemind -``` - -You can launch the app from the GNOME Shell Overview in Fedora Workstation. Or use the application start service your desktop environment provides. FreeMind shows you a new, blank map by default: - -![][4] -FreeMind initial (blank) mind map - -A map consists of linked items or descriptions — nodes. When you think of something related to a node you want to capture, simply create a new node connected to it. - -### Mapping yourself - -Click in the initial node. Replace it with your name by editing the text and hitting **Enter**. You’ve just started your mind map. - -What would you think of if you had to fully describe yourself to someone? There are probably many things to cover. How do you spend your time? What do you enjoy? What do you dislike? What do you value? Do you have a family? All of this can be captured in nodes. - -To add a node connection, select the existing node, and hit **Insert** , or use the “light bulb” icon for a new child node. To add another node at the same level as the new child, use **Enter**. - -Don’t worry if you make a mistake. You can use the **Delete** key to remove an unwanted node. There’s no rules about content. Short nodes are best, though. They allow your mind to move quickly when creating the map. Concise nodes also let viewers scan and understand the map easily later. - -This example uses nodes to explore each of these major categories: - -![][5] -Personal mind map, first level - -You could do another round of iteration for each of these areas. Let your mind freely connect ideas to generate the map. Don’t worry about “getting it right.” It’s better to get everything out of your head and onto the display. Here’s what a next-level map might look like. - -![][6] -Personal mind map, second level - -You could expand on any of these nodes in the same way. Notice how much information you can quickly understand about John Q. Public in the example. - -### How to use your personal mind map - -This is a great way to have team or project members introduce themselves to each other. You can apply all sorts of formatting and color to the map to give it personality. These are fun to do on paper, of course. But having one on your Fedora system means you can always fix mistakes, or even make changes as you change. - -Have fun exploring your personal mind map! - - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/mind-map-yourself-using-freemind-and-fedora/ - -作者:[Paul W. Frields][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/author/pfrields/ -[b]: https://github.com/lujun9972 -[1]: http://freemind.sourceforge.net/wiki/index.php/Main_Page -[2]: https://fedoramagazine.org/three-mind-mapping-tools-fedora/ -[3]: https://fedoramagazine.org/howto-use-sudo/ -[4]: https://fedoramagazine.org/wp-content/uploads/2019/01/Screenshot-from-2019-01-19-15-17-04-1024x736.png -[5]: https://fedoramagazine.org/wp-content/uploads/2019/01/Screenshot-from-2019-01-19-15-32-38-1024x736.png -[6]: https://fedoramagazine.org/wp-content/uploads/2019/01/Screenshot-from-2019-01-19-15-38-00-1024x736.png diff --git a/sources/tech/20190124 Get started with LogicalDOC, an open source document management system.md b/sources/tech/20190124 Get started with LogicalDOC, an open source document management system.md deleted file mode 100644 index 21687c0ce3..0000000000 --- a/sources/tech/20190124 Get started with LogicalDOC, an open source document management system.md +++ /dev/null @@ -1,62 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Get started with LogicalDOC, an open source document management system) -[#]: via: (https://opensource.com/article/19/1/productivity-tool-logicaldoc) -[#]: author: (Kevin Sonney https://opensource.com/users/ksonney) - -Get started with LogicalDOC, an open source document management system -====== -Keep better track of document versions with LogicalDOC, the 12th in our series on open source tools that will make you more productive in 2019. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/document_free_access_cut_security.png?itok=ocvCv8G2) - -There seems to be a mad rush at the beginning of every year to find ways to be more productive. New Year's resolutions, the itch to start the year off right, and of course, an "out with the old, in with the new" attitude all contribute to this. And the usual round of recommendations is heavily biased towards closed source and proprietary software. It doesn't have to be that way. - -Here's the 12th of my picks for 19 new (or new-to-you) open source tools to help you be more productive in 2019. - -### LogicalDOC - -Part of being productive is being able to find what you need when you need it. We've all seen directories full of similar files with similar names, a result of renaming them every time a document changes to keep track of all the versions. For example, my wife is a writer, and she often saves document revisions with new names before she sends them to reviewers. - -![](https://opensource.com/sites/default/files/uploads/logicaldoc-1.png) - -A coder's natural solution to this problem—Git or another version control tool—won't work for document creators because the systems used for code often don't play nice with the formats used by commercial text editors. And before someone says, "just change formats," [that isn't an option for everyone][1]. Also, many version control tools are not very friendly for the less technically inclined. In large organizations, there are tools to solve this problem, but they also require the resources of a large organization to run, manage, and support them. - -![](https://opensource.com/sites/default/files/uploads/logicaldoc-2.png) - -[LogicalDOC CE][2] is an open source document management system built to solve this problem. It allows users to check in, check out, version, search, and lock document files and keeps a history of versions, similar to the version control tools used by coders. - -LogicalDOC can be [installed][3] on Linux, MacOS, and Windows using a Java-based installer. During installation, you'll be prompted for details on the database where its data will be stored and have an option for a local-only file store. You'll get the URL and a default username and password to access the server as well as an option to save a script to automate future installations. - -After you log in, LogicalDOC's default screen lists the documents you have tagged, checked out, and any recent notes on them. Switching to the Documents tab will show the files you have access to. You can upload documents by selecting a file through the interface or using drag and drop. If you upload a ZIP file, LogicalDOC will expand it and add its individual files to the repository. - -![](https://opensource.com/sites/default/files/uploads/logicaldoc-3.png) - -Right-clicking on a file will bring up a menu of options to check out files, lock files against changes, and do a whole host of other things. Checking out a file downloads it to your local machine where it can be edited. A checked-out file cannot be modified by anyone else until it's checked back in. When the file is checked back in (using the same menu), the user can add tags to the version and is required to comment on what was done to it. - -![](https://opensource.com/sites/default/files/uploads/logicaldoc-4.png) - -Going back and looking at earlier versions is as easy as downloading them from the Versions page. There are also import and export options for some third-party services, with [Dropbox][4] support built-in. - -Document management is not just for big companies that can afford expensive solutions. LogicalDOC helps you keep track of the documents you're using with a revision history and a safe repository for documents that are otherwise difficult to manage. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/productivity-tool-logicaldoc - -作者:[Kevin Sonney][a] -选题:[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/ksonney (Kevin Sonney) -[b]: https://github.com/lujun9972 -[1]: http://www.antipope.org/charlie/blog-static/2013/10/why-microsoft-word-must-die.html -[2]: https://www.logicaldoc.com/download-logicaldoc-community -[3]: https://docs.logicaldoc.com/en/installation -[4]: https://dropbox.com diff --git a/sources/tech/20190125 PyGame Zero- Games without boilerplate.md b/sources/tech/20190125 PyGame Zero- Games without boilerplate.md deleted file mode 100644 index f60c2b3407..0000000000 --- a/sources/tech/20190125 PyGame Zero- Games without boilerplate.md +++ /dev/null @@ -1,99 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (xiqingongzi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (PyGame Zero: Games without boilerplate) -[#]: via: (https://opensource.com/article/19/1/pygame-zero) -[#]: author: (Moshe Zadka https://opensource.com/users/moshez) - -PyGame Zero: Games without boilerplate -====== -Say goodbye to boring boilerplate in your game development with PyGame Zero. -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/python3-game.png?itok=jG9UdwC3) - -Python is a good beginner programming language. And games are a good beginner project: they are visual, self-motivating, and fun to show off to friends and family. However, the most common library to write games in Python, [PyGame][1], can be frustrating for beginners because forgetting seemingly small details can easily lead to nothing rendering. - -Until people understand why all the parts are there, they treat many of them as "mindless boilerplate"—magic paragraphs that need to be copied and pasted into their program to make it work. - -[PyGame Zero][2] is intended to bridge that gap by putting a layer of abstraction over PyGame so it requires literally no boilerplate. - -When we say literally, we mean it. - -This is a valid PyGame Zero file: - -``` -# This comment is here for clarity reasons -``` - -We can run put it in a **game.py** file and run: - -``` -$ pgzrun game.py -``` - -This will show a window and run a game loop that can be shut down by closing the window or interrupting the program with **CTRL-C**. - -This will, sadly, be a boring game. Nothing happens. - -To make it slightly more interesting, we can draw a different background: - -``` -def draw(): -    screen.fill((255, 0, 0)) -``` - -This will make the background red instead of black. But it is still a boring game. Nothing is happening. We can make it slightly more interesting: - -``` -colors = [0, 0, 0] - -def draw(): -    screen.fill(tuple(colors)) - -def update(): -    colors[0] = (colors[0] + 1) % 256 -``` - -This will make a window that starts black, becomes brighter and brighter red, then goes back to black, over and over again. - -The **update** function updates parameters, while the **draw** function renders the game based on these parameters. - -However, there is no way for the player to interact with the game! Let's try something else: - -``` -colors = [0, 0, 0] - -def draw(): -    screen.fill(tuple(colors)) - -def update(): -    colors[0] = (colors[0] + 1) % 256 - -def on_key_down(key, mod, unicode): -    colors[1] = (colors[1] + 1) % 256 -``` - -Now pressing keys on the keyboard will increase the "greenness." - -These comprise the three important parts of a game loop: respond to user input, update parameters, and re-render the screen. - -PyGame Zero offers much more, including functions for drawing sprites and playing sound clips. - -Try it out and see what type of game you can come up with! - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/pygame-zero - -作者:[Moshe Zadka][a] -选题:[lujun9972][b] -译者:[xiqingongzi](https://github.com/xiqingongzi) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://opensource.com/users/moshez -[b]: https://github.com/lujun9972 -[1]: https://www.pygame.org/news -[2]: https://pygame-zero.readthedocs.io/en/stable/ diff --git a/sources/tech/20190125 Top 5 Linux Distributions for Development in 2019.md b/sources/tech/20190125 Top 5 Linux Distributions for Development in 2019.md deleted file mode 100644 index b3e2de22ba..0000000000 --- a/sources/tech/20190125 Top 5 Linux Distributions for Development in 2019.md +++ /dev/null @@ -1,161 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Top 5 Linux Distributions for Development in 2019) -[#]: via: (https://www.linux.com/blog/2019/1/top-5-linux-distributions-development-2019) -[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen) - -Top 5 Linux Distributions for Development in 2019 -====== - -![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev-main.jpg?itok=DEe9pYtb) - -One of the most popular tasks undertaken on Linux is development. With good reason: Businesses rely on Linux. Without Linux, technology simply wouldn’t meet the demands of today’s ever-evolving world. Because of that, developers are constantly working to improve the environments with which they work. One way to manage such improvements is to have the right platform to start with. Thankfully, this is Linux, so you always have a plethora of choices. - -But sometimes, too many choices can be a problem in and of itself. Which distribution is right for your development needs? That, of course, depends on what you’re developing, but certain distributions that just make sense to use as a foundation for your task. I’ll highlight five distributions I consider the best for developers in 2019. - -### Ubuntu - -Let’s not mince words here. Although the Linux Mint faithful are an incredibly loyal group (with good reason, their distro of choice is fantastic), Ubuntu Linux gets the nod here. Why? Because, thanks to the likes of [AWS][1], Ubuntu is one of the most deployed server operating systems. That means developing on a Ubuntu desktop distribution makes for a much easier translation to Ubuntu Server. And because Ubuntu makes it incredibly easy to develop for, work with, and deploy containers, it makes perfect sense that you’d want to work with this platform. Couple that with Ubuntu’s inclusion of Snap Packages, and Canonical's operating system gets yet another boost in popularity. - -But it’s not just about what you can do with Ubuntu, it’s how easily you can do it. For nearly every task, Ubuntu is an incredibly easy distribution to use. And because Ubuntu is so popular, chances are every tool and IDE you want to work with can be easily installed from the Ubuntu Software GUI (Figure 1). - -![Ubuntu][3] - -Figure 1: Developer tools found in the Ubuntu Software tool. - -[Used with permission][4] - -If you’re looking for ease of use, simplicity of migration, and plenty of available tools, you cannot go wrong with Ubuntu as a development platform. - -### openSUSE - -There’s a very specific reason why I add openSUSE to this list. Not only is it an outstanding desktop distribution, it’s also one of the best rolling releases you’ll find on the market. So if you’re wanting to develop with and release for the most recent software available, [openSUSE Tumbleweed][5] should be one of your top choices. If you want to leverage the latest releases of your favorite IDEs, if you always want to make sure you’re developing with the most recent libraries and toolkits, Tumbleweed is your platform. - -But openSUSE doesn’t just offer a rolling release distribution. If you’d rather make use of a standard release platform, [openSUSE Leap][6] is what you want. - -Of course, it’s not just about standard or rolling releases. The openSUSE platform also has a Kubernetes-specific release, called [Kubic][7], which is based on Kubernetes atop openSUSE MicroOS. But even if you aren’t developing for Kubernetes, you’ll find plenty of software and tools to work with. - -And openSUSE also offers the ability to select your desktop environment, or (should you chose) a generic desktop or server (Figure 2). - -![openSUSE][9] - -Figure 2: The openSUSE Tumbleweed installation in action. - -[Used with permission][4] - -### Fedora - -Using Fedora as a development platform just makes sense. Why? The distribution itself seems geared toward developers. With a regular, six month release cycle, developers can be sure they won’t be working with out of date software for long. This can be important, when you need the most recent tools and libraries. And if you’re developing for enterprise-level businesses, Fedora makes for an ideal platform, as it is the upstream for Red Hat Enterprise Linux. What that means is the transition to RHEL should be painless. That’s important, especially if you hope to bring your project to a much larger market (one with deeper pockets than a desktop-centric target). - -Fedora also offers one of the best GNOME experiences you’ll come across (Figure 3). This translates to a very stable and fast desktops. - -![GNOME][11] - -Figure 3: The GNOME desktop on Fedora. - -[Used with permission][4] - -But if GNOME isn’t your jam, you can opt to install one of the [Fedora spins][12] (which includes KDE, XFCE, LXQT, Mate-Compiz, Cinnamon, LXDE, and SOAS). - -### Pop!_OS - -I’d be remiss if I didn’t include [System76][13]’s platform, customized specifically for their hardware (although it does work fine on other hardware). Why would I include such a distribution, especially one that doesn’t really venture far away from the Ubuntu platform for which is is based? Primarily because this is the distribution you want if you plan on purchasing a desktop or laptop from System76. But why would you do that (especially given that Linux works on nearly all off-the-shelf hardware)? Because System76 sells outstanding hardware. With the release of their Thelio desktop, you have available one of the most powerful desktop computers on the market. If you’re developing seriously large applications (especially ones that lean heavily on very large databases or require a lot of processing power for compilation), why not go for the best? And since Pop!_OS is perfectly tuned for System76 hardware, this is a no-brainer. -Since Pop!_OS is based on Ubuntu, you’ll have all the tools available to the base platform at your fingertips (Figure 4). - -![Pop!_OS][15] - -Figure 4: The Anjunta IDE running on Pop!_OS. - -[Used with permission][4] - -Pop!_OS also defaults to encrypted drives, so you can trust your work will be safe from prying eyes (should your hardware fall into the wrong hands). - -### Manjaro - -For anyone that likes the idea of developing on Arch Linux, but doesn’t want to have to jump through all the hoops of installing and working with Arch Linux, there’s Manjaro. Manjaro makes it easy to have an Arch Linux-based distribution up and running (as easily as installing and using, say, Ubuntu). - -But what makes Manjaro developer-friendly (besides enjoying that Arch-y goodness at the base) is how many different flavors you’ll find available for download. From the [Manjaro download page][16], you can grab the following flavors: - - * GNOME - - * XFCE - - * KDE - - * OpenBox - - * Cinnamon - - * I3 - - * Awesome - - * Budgie - - * Mate - - * Xfce Developer Preview - - * KDE Developer Preview - - * GNOME Developer Preview - - * Architect - - * Deepin - - - - -Of note are the developer editions (which are geared toward testers and developers), the Architect edition (which is for users who want to build Manjaro from the ground up), and the Awesome edition (Figure 5 - which is for developers dealing with everyday tasks). The one caveat to using Manjaro is that, like any rolling release, the code you develop today may not work tomorrow. Because of this, you need to think with a certain level of agility. Of course, if you’re not developing for Manjaro (or Arch), and you’re doing more generic (or web) development, that will only affect you if the tools you use are updated and no longer work for you. Chances of that happening, however, are slim. And like with most Linux distributions, you’ll find a ton of developer tools available for Manjaro. - -![Manjaro][18] - -Figure 5: The Manjaro Awesome Edition is great for developers. - -[Used with permission][4] - -Manjaro also supports the Arch User Repository (a community-driven repository for Arch users), which includes cutting edge software and libraries, as well as proprietary applications like [Unity Editor][19] or yEd. A word of warning, however, about the Arch User Repository: It was discovered that the AUR contained software considered to be malicious. So, if you opt to work with that repository, do so carefully and at your own risk. - -### Any Linux Will Do - -Truth be told, if you’re a developer, just about any Linux distribution will work. This is especially true if you do most of your development from the command line. But if you prefer a good GUI running on top of a reliable desktop, give one of these distributions a try, they will not disappoint. - -Learn more about Linux through the free ["Introduction to Linux" ][20]course from The Linux Foundation and edX. - --------------------------------------------------------------------------------- - -via: https://www.linux.com/blog/2019/1/top-5-linux-distributions-development-2019 - -作者:[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://aws.amazon.com/ -[2]: https://www.linux.com/files/images/dev1jpg -[3]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev_1.jpg?itok=7QJQWBKi (Ubuntu) -[4]: https://www.linux.com/licenses/category/used-permission -[5]: https://en.opensuse.org/Portal:Tumbleweed -[6]: https://en.opensuse.org/Portal:Leap -[7]: https://software.opensuse.org/distributions/tumbleweed -[8]: /files/images/dev2jpg -[9]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev_2.jpg?itok=1GJmpr1t (openSUSE) -[10]: /files/images/dev3jpg -[11]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev_3.jpg?itok=_6Ki4EOo (GNOME) -[12]: https://spins.fedoraproject.org/ -[13]: https://system76.com/ -[14]: /files/images/dev4jpg -[15]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev_4.jpg?itok=nNG2Ax24 (Pop!_OS) -[16]: https://manjaro.org/download/ -[17]: /files/images/dev5jpg -[18]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dev_5.jpg?itok=RGfF2UEi (Manjaro) -[19]: https://unity3d.com/unity/editor -[20]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/sources/tech/20190128 3 simple and useful GNOME Shell extensions.md b/sources/tech/20190128 3 simple and useful GNOME Shell extensions.md deleted file mode 100644 index d7384030c5..0000000000 --- a/sources/tech/20190128 3 simple and useful GNOME Shell extensions.md +++ /dev/null @@ -1,73 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (geekpi) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (3 simple and useful GNOME Shell extensions) -[#]: via: (https://fedoramagazine.org/3-simple-and-useful-gnome-shell-extensions/) -[#]: author: (Ryan Lerch https://fedoramagazine.org/introducing-flatpak/) - -3 simple and useful GNOME Shell extensions -====== - -![](https://fedoramagazine.org/wp-content/uploads/2019/01/3simple-816x345.png) - -The default desktop of Fedora Workstation — GNOME Shell — is known and loved by many users for its minimal, clutter-free user interface. It is also known for the ability to add to the stock interface using extensions. In this article, we cover 3 simple, and useful extensions for GNOME Shell. These three extensions provide a simple extra behaviour to your desktop; simple tasks that you might do every day. - - -### Installing Extensions - -The quickest and easiest way to install GNOME Shell extensions is with the Software Application. Check out the previous post here on the Magazine for more details: - -![](https://fedoramagazine.org/wp-content/uploads/2018/11/installing-extensions-768x325.jpg) - -### Removable Drive Menu - -![][1] -Removable Drive Menu extension on Fedora 29 - -First up is the [Removable Drive Menu][2] extension. It is a simple tool that adds a small widget in the system tray if you have a removable drive inserted into your computer. This allows you easy access to open Files for your removable drive, or quickly and easily eject the drive for safe removal of the device. - -![][3] -Removable Drive Menu in the Software application - -### Extensions Extension. - -![][4] - -The [Extensions][5] extension is super useful if you are always installing and trying out new extensions. It provides a list of all the installed extensions, allowing you to enable or disable them. Additionally, if an extension has settings, it allows quick access to the settings dialog for each one. - -![][6] -the Extensions extension in the Software application - -### Frippery Move Clock - -![][7] - -Finally, there is the simplest extension in the list. [Frippery Move Clock][8], simply moves the position of the clock from the center of the top bar to the right, next to the status area. - -![][9] - - --------------------------------------------------------------------------------- - -via: https://fedoramagazine.org/3-simple-and-useful-gnome-shell-extensions/ - -作者:[Ryan Lerch][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://fedoramagazine.org/introducing-flatpak/ -[b]: https://github.com/lujun9972 -[1]: https://fedoramagazine.org/wp-content/uploads/2019/01/removable-disk-1024x459.jpg -[2]: https://extensions.gnome.org/extension/7/removable-drive-menu/ -[3]: https://fedoramagazine.org/wp-content/uploads/2019/01/removable-software-1024x723.png -[4]: https://fedoramagazine.org/wp-content/uploads/2019/01/extensions-extension-1024x459.jpg -[5]: https://extensions.gnome.org/extension/1036/extensions/ -[6]: https://fedoramagazine.org/wp-content/uploads/2019/01/extensions-software-1024x723.png -[7]: https://fedoramagazine.org/wp-content/uploads/2019/01/move_clock-1024x189.jpg -[8]: https://extensions.gnome.org/extension/2/move-clock/ -[9]: https://fedoramagazine.org/wp-content/uploads/2019/01/Screenshot-from-2019-01-28-21-53-18-1024x723.png diff --git a/sources/tech/20190128 Top Hex Editors for Linux.md b/sources/tech/20190128 Top Hex Editors for Linux.md deleted file mode 100644 index 5cd47704b4..0000000000 --- a/sources/tech/20190128 Top Hex Editors for Linux.md +++ /dev/null @@ -1,146 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Top Hex Editors for Linux) -[#]: via: (https://itsfoss.com/hex-editors-linux) -[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) - -Top Hex Editors for Linux -====== - -Hex editor lets you view/edit the binary data of a file – which is in the form of “hexadecimal” values and hence the name “Hex” editor. Let’s be frank, not everyone needs it. Only a specific group of users who have to deal with the binary data use it. - -If you have no idea, what it is, let me give you an example. Suppose, you have the configuration files of a game, you can open them using a hex editor and change certain values to have more ammo/score and so on. To know more about Hex editors, you should start with the [Wikipedia page][1]. - -In case you already know what’s it used for – let us take a look at the best Hex editors available for Linux. - -### 5 Best Hex Editors Available - -![Best Hex Editors for Linux][2] - -**Note:** The hex editors mentioned are in no particular order of ranking. - -#### 1\. Bless Hex Editor - -![bless hex editor][3] - -**Key Features** : - - * Raw disk editing - * Multilevel undo/redo operations. - * Multiple tabs - * Conversion table - * Plugin support to extend the functionality - - - -Bless is one of the most popular Hex editor available for Linux. You can find it listed in your AppCenter or Software Center. If that is not the case, you can check out their [GitHub page][4] for the build and the instructions associated. - -It can easily handle editing big files without slowing down – so it’s a fast hex editor. - -#### 2\. GNOME Hex Editor - -![gnome hex editor][5] - -**Key Features:** - - * View/Edit in either Hex/Ascii - - * Edit large files - - * - - -Yet another amazing Hex editor – specifically tailored for GNOME. Well, I personally use Elementary OS, so I find it listed in the App Center. You should find it in the Software Center as well. If not, refer to the [GitHub page][6] for the source. - -You can use this editor to view/edit in either hex or ASCII. The user interface is quite simple – as you can see in the image above. - -#### 3\. Okteta - -![okteta][7] - -**Key Features:** - - * Customizable data views - * Multiple tabs - * Character encodings: All 8-bit encodings as supplied by Qt, EBCDIC - * Decoding table listing common simple data types. - - - -Okteta is a simple hex editor with not so fancy features. Although it can handle most of the tasks. There’s a separate module of it which you can use to embed this in other programs to view/edit files. - -Similar to all the above-mentioned editors, you can find this listed on your AppCenter and Software center as well. - -#### 4\. wxHexEditor - -![wxhexeditor][8] - -**Key Features:** - - * Easily handle big files - * Has x86 disassembly support - * **** Sector Indication **** on Disk devices - * Supports customizable hex panel formatting and colors. - - - -This is something interesting. It is primarily a Hex editor but you can also use it as a low level disk editor. For example, if you have a problem with your HDD, you can use this editor to edit the the sectors in raw hex and fix it. - -You can find it listed on your App Center and Software Center. If not, [Sourceforge][9] is the way to go. - -#### 5\. Hexedit (Command Line) - -![hexedit][10] - -**Key Features** : - - * Works via terminal - * It’s fast and simple - - - -If you want something to work on your terminal, you can go ahead and install Hexedit via the console. It’s my favorite Linux hex editor in command line. - -When you launch it, you will have to specify the location of the file, and it’ll then open it for you. - -To install it, just type in: - -``` -sudo apt install hexedit -``` - -### Wrapping Up - -Hex editors could come in handy to experiment and learn. If you are someone experienced, you should opt for the one with more feature – with a GUI. Although, it all comes down to personal preferences. - -What do you think about the usefulness of Hex editors? Which one do you use? Did we miss listing your favorite? Let us know in the comments! - -![][11] - --------------------------------------------------------------------------------- - -via: https://itsfoss.com/hex-editors-linux - -作者:[Ankush Das][a] -选题:[lujun9972][b] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://itsfoss.com/author/ankush/ -[b]: https://github.com/lujun9972 -[1]: https://en.wikipedia.org/wiki/Hex_editor -[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/Linux-hex-editors-800x450.jpeg?resize=800%2C450&ssl=1 -[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/bless-hex-editor.jpg?ssl=1 -[4]: https://github.com/bwrsandman/Bless -[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/ghex-hex-editor.jpg?ssl=1 -[6]: https://github.com/GNOME/ghex -[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/okteta-hex-editor-800x466.jpg?resize=800%2C466&ssl=1 -[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/wxhexeditor.jpg?ssl=1 -[9]: https://sourceforge.net/projects/wxhexeditor/ -[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/hexedit-console.jpg?resize=800%2C566&ssl=1 -[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/Linux-hex-editors.jpeg?fit=800%2C450&ssl=1 diff --git a/sources/tech/20190129 A small notebook for a system administrator.md b/sources/tech/20190129 A small notebook for a system administrator.md new file mode 100644 index 0000000000..45d6ba50eb --- /dev/null +++ b/sources/tech/20190129 A small notebook for a system administrator.md @@ -0,0 +1,552 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (A small notebook for a system administrator) +[#]: via: (https://habr.com/en/post/437912/) +[#]: author: (sukhe https://habr.com/en/users/sukhe/) + +A small notebook for a system administrator +====== + +I am a system administrator, and I need a small, lightweight notebook for every day carrying. Of course, not just to carry it, but for use it to work. + +I already have a ThinkPad x200, but it’s heavier than I would like. And among the lightweight notebooks, I did not find anything suitable. All of them imitate the MacBook Air: thin, shiny, glamorous, and they all critically lack ports. Such notebook is suitable for posting photos on Instagram, but not for work. At least not for mine. + +After not finding anything suitable, I thought about how a notebook would turn out if it were developed not with design, but the needs of real users in mind. System administrators, for example. Or people serving telecommunications equipment in hard-to-reach places — on roofs, masts, in the woods, literally in the middle of nowhere. + +The results of my thoughts are presented in this article. + + +[![Figure to attract attention][1]][2] + +Of course, your understanding of the admin notebook does not have to coincide with mine. But I hope you will find a couple of interesting thoughts here. + +Just keep in mind that «system administrator» is just the name of my position. And in fact, I have to work as a network engineer, and installer, and perform a significant part of other work related to hardware. Our company is tiny, we are far from large settlements, so all of us have to be universal specialist. + +In order not to constantly clarify «this notebook», later in the article I will call it the “adminbook”. Although it can be useful not only to administrators, but also to all who need a small, lightweight notebook with a lot of connectors. In fact, even large laptops don’t have as many connectors. + +So let's get started… + +### 1\. Dimensions and weight + +Of course, you want it smaller and more lightweight, but the keyboard with the screen should not be too small. And there has to be space for connectors, too. + +In my opinion, a suitable option is a notebook half the size of an x200. That is, approximately the size of a sheet of A5 paper (210x148mm). In addition, the side pockets of many bags and backpacks are designed for this size. This means that the adminbook doesn’t even have to be carried in the main compartment. + +Though I couldn’t fit everything I wanted into 210mm. To make a comfortable keyboard, the width had to be increased to 230mm. + +In the illustrations the adminbook may seem too thick. But that’s only an optical illusion. In fact, its thickness is 25mm (28mm taking the rubber feet into account). + +Its size is close to the usual hardcover book, 300-350 pages thick. + +It’s lightweight, too — about 800 grams (half the weight of the ThinkPad). + +The case of the adminbook is made of mithril aluminum. It’s a lightweight, durable metal with good thermal conductivity. + +### 2\. Keyboard and trackpoint + +A quality keyboard is very important for me. “Quality” there means the fastest possible typing and hotkey speed. It needs to be so “matter-of-fact” I don’t have to think about it at all, as if it types seemingly by force of thought. + +This is possible if the keys are normal size and in their typical positions. But the adminbook is too small for that. In width, it is even smaller than the main block of keys of a desktop keyboard. So, you have to work around that somehow. + +After a long search and numerous tests, I came up with what you see in the picture: + +![](https://habrastorage.org/webt/2-/mh/ag/2-mhagvoofl7vgqiadv3rcnclb0.jpeg) +Fig.2.1 — Adminbook keyboard + +This keyboard has the same vertical key distance as on a regular keyboard. A horizontal distance decreased just only 2mm (17 instead of 19). + +You can even type blindly on this keyboard! To do this, some keys have small bumps for tactile orientation. + +However, if you do not sit at a table, the main input method will be to press the keys “at a glance”. And here the muscle memory does not help — you have to look at the keys with your eyes. + +To hit the buttons faster, different key colors are used. + +For example, the numeric row is specifically colored gray to visually separate it from the QWERTY row, and NumLock is mapped to the “6” key, colored black to stand out. + +To the right of NumLock, gray indicates the area of the numeric keypad. These (and neighboring) buttons work like a numeric keypad in NumLock mode or when you press Fn. I must say, this is a useful feature for the admin computer — some users come up with passwords on the numpad in the form of a “cross”, “snake”, “spiral”, etc. I want to be able to type them that way too. + +As for the function keys. I don’t know about you, but it annoys me when, in a 15-inch laptop, this row is half-height and only accessible through pressing Fn. Given that there’s a lot free space around the keyboard! + +The adminbook doesn’t have free space at all. But the function keys can be pressed without Fn. These are separate keys that are even divided into groups of 4 using color coding and location. + +By the way, have you seen which key is to the right of AltGr on modern ThinkPads? I don’t know what they were thinking, but now they have PrintScreen there! + +Where? Where, I ask, is the context menu key that I use every day? It’s not there. + +So the adminbook has it. Two, even! You can put it up by pressing Fn + Alt. Sorry, I couldn’t map it to a separate key due to lack of space. Just in case, I added the “Right Win” key as Fn + CtrlR. Maybe some people use it for something. + +However, the adminbook allows you to customize the keyboard to your liking. The keyboard is fully reprogrammable. You can assign the scan codes you need to the keys. Setting the keyboard parameters is done via the “KEY” button (Fn + F3). + +Of course, the adminbook has a keyboard backlight. It is turned on with Fn + B (below the trackpoint, you can even find it in the dark). The backlight here is similar to the ThinkPad ThinkLight. That is, it’s an LED above the display, illuminating the keyboard from the top. In this case, it is better than a backlight from below, because it allows you to distinguish the color of the keys. In addition, keys have several characters printed on them, while only English letters are usually made translucent to the backlight. + +Since we’re on the topic of characters… Red letters are Ukrainian and Russian. I specifically drew them to show that keys have space for several alphabets: after all, English is not a native language for most of humanity. + +Since there isn’t enough space for a full touchpad, the trackpoint is used as the positioning device. If you have no experience working with it — don’t worry, it’s actually quite handy. The mouse cursor moves with slight inclines of the trackpoint, like an analog joystick, and its three buttons (under the spacebar) work the same as on the mouse. + +To the left of the trackpoint keys is a fingerprint scanner. That makes it possible to login by fingerprint. It’s very convenient in most cases. + +The space bar has an NFC antenna location mark. You can simply read data from devices equipped with NFC, and you can make it to lock the system while not in use. For example, if you wear an NFC-equipped ring, it looks like this: when you remove hands from the keyboard, the computer locks after a certain time, and unlocks when you put hands on the keyboard again. + +And now the unexpected part. The keyboard and the trackpoint can work as a USB keyboard and mouse for an external computer! For this, there are USB Type C and MicroUSB connectors on the back, labeled «OTG». You can connect to an external computer using a standard USB cable from a phone (which is usually always with you). + +![](https://habrastorage.org/webt/e2/wa/m5/e2wam5d1bbckfdxpvqwl-i6aqle.jpeg) +Fig.2.2 — On the right: the power connector 5.5x2.5mm, the main LAN connector, POE indicator, USB 3.0 Type A, USB Type C (with alternate HDMI mode), microSD card reader and two «magic» buttons + +Switching to the external keyboard mode is done with the «K» button on the right side of the adminbook. And there are actually three modes, since the keyboard+trackpoint combo can also work as a Bluetooth keyboard/mouse! + +Moreover: to save energy, the keyboard and trackpoint can work autonomously from the rest of the adminbook. When the adminbook is turned off, pressing «K» can turn on only the keyboard and trackpoint to use them by connecting to another computer. + +Of course, the keyboard is water-resistant. Excess water is drained down through the drainage holes. + +### 3\. Video subsystem + +There are some devices that normally do not need a monitor and keyboard. For example, industrial computers, servers or DVRs. And since the monitor is «not needed», it is, in most cases, absent. + +And when there is a need to configure such a device from the console, it can be a big surprise that the entire office is working on laptops and there is not a single stationary monitor within reach. Therefore, in some cases you have to take a monitor with you. + +But you don’t need to worry about this if you have the adminbook. + +The fact is that the video outputs of the adminbook can switch «in the opposite direction» and work as video inputs by displaying the incoming image on the built-in screen. So, the adminbook can also replace the monitor (in addition to replace the mouse and keyboard). + +![](https://habrastorage.org/webt/4a/qr/f-/4aqrf-1sgstwwffhx-n4wr0p7ws.jpeg) +Fig.3.1 — On the left side of the adminbook, there are Mini DisplayPort, USB Type C (with alternate DisplayPort mode), SD card reader, USB 3.0 Type A connectors, HDMI, four audio connectors, VGA and power button + +Switching modes between input and output is done by pressing the «M» button on the right side of the adminbook. + +The video subsystem, as well as the keyboard, can work autonomously — that is, when used as a monitor, the other parts of the adminbook remain disabled. To turn on to this mode also uses the «M» button. + +Detailed screen adjustment (contrast, geometry, video input selection, etc.) is performed using the menu, brought up with the «SCR» button (Fn + F4). + +The adminbook has HDMI, MiniDP, VGA and USB Type C connectors (with DisplayPort and HDMI alternate mode) for video input / output. The integrated GPU can display the image simultaneously in three directions (including the integrated display). + +The adminbook display is FullHD (1920x1080), 9.5’’, matte screen. The brightness is sufficient for working outside during the day. And to do it better, the set includes folding blinds for protection from sunlight. + +![](https://habrastorage.org/webt/k-/nc/rh/k-ncrhphspvcoimfds1wurnzk3i.jpeg) +Fig.3.2 — Blinds to protect from sunlight + +In addition to video output via these connectors, the adminbook can use wireless transmission via WiDi or Miracast protocols. + +### 4\. Emulation of external drives + +One of the options for installing the operating system is to install it from a CD / DVD, but now very few computers have optical drives. USB connectors are everywhere, though. Therefore, the adminbook can pretend to be an external optical drive connected via USB. + +That allows connecting it to any computer to install an operating system on it, while also running boot discs with test programs or antiviruses. + +To connect, it uses the same USB cable that’s used for connecting it to a desktop as an external keyboard/mouse. + +The “CD” button (Fn + F2) controls the drive emulation — select a disc image (in an .iso file) and mount / unmount it. + +If you need to copy data from a computer or to it, the adminbook can emulate an external hard drive connected via the same USB cable. HDD emulation is also enabled by the “CD” button. + +This button also turns on the emulation of bootable USB flash drives. They are now used to install operating systems almost more often than CDs. Therefore, the adminbook can pretend to be a bootable flash drive. + +The .iso files are located on a separate partition of the hard disk. This allows you to use them regardless of the operating system. Moreover, in the emulation menu you can connect a virtual drive to one of the USB interfaces of the adminbook. This makes it possible to install an operating system on the adminbook using itself as an installation disc drive. + +By the way, the adminbook is designed to work under Windows 10 and Debian / Kali / Ubuntu. The menu system called via function buttons with Fn works autonomously on a separate microcontroller. + +### 5\. Rear connectors + +First, a classic DB-9 connector for RS-232. Any admin notebook simply has to have it. We have it here, too, and galvanically isolated from the rest of the notebook. + +In addition to RS-232, RS-485 widely used in industrial automation is supported. It has a two-wire and four-wire version, with a terminating resistor and without, with the ability to enable a protective offset. It can also work in RS-422 and UART modes. + +All these protocols are configured in the on-screen menu, called by the «COM» button (Fn + F8). + +Since there are multiple protocols, it is possible to accidentally connect the equipment to a wrong connector and break it. + +To prevent this from happening, when you turn off the computer (or go into sleep mode, or close the display lid), the COM port switches to the default mode. This may be a “port disabled” state, or enabling one of the protocols. + +![](https://habrastorage.org/webt/uz/ii/ig/uziiig_yr86yzdcnivkbapkbbgi.jpeg) +Fig.5.1 — The rear connectors: DB-9, SATA + SATA Power, HD Mini SAS, the second wired LAN connector, two USB 3.0 Type A connectors, two USB 2.0 MicroB connectors, three USB Type C connectors, a USIM card tray, a PBD-12 pin connector (jack) + +The adminbook has one more serial port. But if the first one uses the hardware UART chipset, the second one is connected to the USB 2.0 line through the FT232H converter. + +Thanks to this, via COM2, you can exchange data via I2C, SMBus, SPI, JTAG, UART protocols or use it as 8 outputs for Bit-bang / GPIO. These protocols are used when working with microcontrollers, flashing firmware on routers and debugging any other electronics. For this purpose, pin connectors are usually used with a 2.54mm pitch. Therefore, COM2 is made to look like one of these connectors. + +![](https://habrastorage.org/webt/qd/rc/ln/qdrclnoljgnlohthok4hgjb0be4.jpeg) +Fig.5.2 — USB to UART adapter replaced by COM2 port + +There is also a secondary LAN interface at the back. Like the main one, it is gigabit-capable, with support for VLAN. Both interfaces are able to test the integrity of the cable (for pair length and short circuits), the presence of connected devices, available communication speeds, the presence of POE voltage. With the using a wiremap adapter on the other side (see chapter 17) it is possible to determine how the cable is connected to crimps. + +The network interface menu is called with the “LAN” button (Fn + F6). + +The adminbook has a combined SATA + SATA Power connector, connected directly to the chipset. That makes it possible to perform low-level tests of hard drives that do not work through USB-SATA adapters. Previously, you had to do it through ExpressCards-type adapters, but the adminbook can do without them because it has a true SATA output. + +![](https://habrastorage.org/webt/dr/si/in/drsiinbafiyz8ztzwrowtvi0lk8.jpeg) +Fig.5.3 — USB to SATA/IDE and ExpressCard to SATA adapters + +The adminbook also has a connector that no other laptops have — HD Mini SAS (SFF-8643). PCIe x4 is routed outside through this connector. Thus, it's possible to connect an external U.2 (directly) or M.2 type (through an adapter) drives. Or even a typical desktop PCIe expansion card (like a graphics card). + +![](https://habrastorage.org/webt/ud/ph/86/udph860bshazyd6lvuzvwgymwnk.jpeg) +Fig.5.4 — HD Mini SAS (SFF-8643) to U.2 cable + +![](https://habrastorage.org/webt/kx/dd/99/kxdd99krcllm5ooz67l_egcttym.jpeg) +Fig.5.5 — U.2 drive + +![](https://habrastorage.org/webt/xn/de/gx/xndegxy5i1g7h2lwefs2jt1scpq.jpeg) +Fig.5.6 — U.2 to M.2 adapter + +![](https://habrastorage.org/webt/z2/dd/hd/z2ddhdoioezdwov_nv9e3b0egsa.jpeg) +Fig.5.7 — Combined adapter from U.2 to M.2 and PCIe (sample M.2 22110 drive is installed) + +Unfortunately, the limitations of the chipset don’t allow arbitrary use of PCIe lanes. In addition, the processor uses the same data lanes for PCIe and SATA. Therefore, the rear connectors can only work in two ways: +— all four PCIe lanes go to the Mini SAS connector (the second network interface and SATA don’t work) +— two PCIe lanes go to the Mini SAS, and two lanes to the second network interface and SATA connector + +On the back there are also two USB connectors (usual and Type C), which are constantly powered. That allows you to charge other devices from your notebook, even when the notebook is turned off. + +### 6\. Power Supply + +The adminbook is designed to work in difficult and unpredictable conditions, therefore, it is able to receive power in various ways. + +**Method number one** is Power Delivery. The power supply cable can be connected to any USB Type C connector (except the one marked “OTG”). + +**The second option** is from a normal 5V phone charger with a microUSB or USB Type C connector. At the same time, if you connect to the ports labeled QC 3.0, the QuickCharge fast charging standard will be supported. + +**The third option** — from any source of 12-60V DC power. To connect, use a coaxial ( also known as “barrel”) 5.5x2.5mm power connector, often found in laptop power supplies. + +For greater safety, the 12-60V power supply is galvanically isolated from the rest of the notebook. In addition, there’s reverse polarity protection. In fact, the adminbook can receive energy even if positive and negative ends are mismatched. + +![](https://habrastorage.org/webt/ju/xo/c3/juxoc3lxi7urqwgegyd6ida5h_8.jpeg) +Fig.6.1 — The cable, connecting the power supply to the adminbook (terminated with 5.5x2.5mm connectors) + +Adapters for a car cigarette lighter and crocodile clips are included in the box. + +![](https://habrastorage.org/webt/l6/-v/gv/l6-vgvqjrssirnvyi14czhi0mrc.jpeg) +Fig.6.2 — Adapter from 5.5x2.5mm coaxial connector to crocodile clips + +![](https://habrastorage.org/webt/zw/an/gs/zwangsvfdvoievatpbfxqvxrszg.png) +Fig.6.3 — Adapter to a car cigarette lighter + +**The fourth option** — Power Over Ethernet (POE) through the main network adapter. Supported options are 802.3af, 802.3at and Passive POE. Input voltage from 12 to 60V. This method is convenient if you have to work on the roof or on the tower, setting up Wi-Fi antennas. Power to them comes through Ethernet cables, and there is no other electricity on the tower. + +POE electricity can be used in three ways: + + * power the notebook only + * forward to a second network adapter and power the notebook from batteries + * power the notebook and the antenna at the same time + + + +To prevent equipment damage, if one of the Ethernet cables is disconnected, the power to the second network interface is terminated. The power can only be turned on manually through the corresponding menu item. + +When using the 802.3af / at protocols, you can set the power class that the adminbook will request from the power supply device. This and other POE properties are configured from the menu called with the “LAN” button (Fn + F6). + +By the way, you can remotely reset Ubiquity access points (which is done by closing certain wires in the cable) with the second network interface. + +The indicator next to the main network interface shows the presence and type of POE: green — 802.3af / at, red — Passive POE. + +**The last, fifth** power supply is the battery. Here it’s a LiPol, 42W/hour battery. + +In case the external power supply does not provide sufficient power, the missing power can be drawn from the battery. Thus, it can draw power from the battery and external sources at the same time. + +### 7\. Display unit + +The display can tilt 180 degrees, and it’s locked with latches while closed (opens with a button on the front side). When the display is closed, adminbook doesn’t react to pressing any external buttons. + +In addition to the screen, the notebook lid contains: + + * front and rear cameras with lights, microphones, activity LEDs and mechanical curtains + * LED of the upper backlight of the keyboard (similar to ThinkLight) + * LED indicators for Wi-Fi, Bluetooth, HDD and others + * wireless protocol antennas (in the blue plastic insert) + * photo sensors and LEDs for the infrared remote + * gyroscope, accelerometer, magnetometer + + + +The plastic insert for the antennas does not reach the corners of the display lid. This is done because in the «traveling» notebooks the corners are most affected by impacts, and it's desirable that they be made of metal. + +### 8\. Webcams + +The notebook has 2 webcams. The front-facing one is 8MP (4K / UltraHD), while the “selfie” one is 2MP (FullHD). Both cameras have a backlight controlled by separate buttons (Fn + G and Fn + H). Each camera has a mechanical curtain and an activity LED. The shifted mechanical curtain also turns off the microphones of the corresponding side (configurable). + +The external camera has two quick launch buttons — Fn + 1 takes an instant photo, Fn + 2 turns on video recording. The internal camera has a combination of Fn + Q and Fn + W. + +You can configure cameras and microphones from the menu called up by the “CAM” button (Fn + F10). + +### 9\. Indicator row + +It has the following indicators: Microphone, NumLock, ScrollLock, hard drive access, battery charge, external power connection, sleep mode, mobile connection, WiFi, Bluetooth. + +Three indicators are made to shine through the back side of the display lid, so that they can be seen while the lid is closed: external power connection, battery charge, sleep mode. + +Indicators are color-coded. + +Microphone — lights up red when all microphones are muted + +Battery charge: more than 60% is green, 30-60% is yellow, less than 30% is red, less than 10% is blinking red. + +External power: green — power is supplied, the battery is charged; yellow — power is supplied, the battery is charging; red — there is not enough external power to operate, the battery is drained + +Mobile: 4G (LTE) — green, 3G — yellow, EDGE / GPRS — red, blinking red — on, but no connection + +Wi-Fi: green — connected to 5 GHz, yellow — to 2.4 GHz, red — on, but not connected + +You can configure the indication with the “IND” button (Fn + F9) + +### 10\. Infrared remote control + +Near the indicators (on the front and back of the display lid) there are infrared photo sensors and LEDs to recording and playback commands from IR remotes. You can set it up, as well as emulate a remote control by pressing the “IR” button (Fn + F5). + +### 11\. Wireless interfaces + +WiFi — dual-band, 802.11a/b/g/n/ac with support for Wireless Direct, Intel WI-Di / Miracast, Wake On Wireless LAN. + +You ask, why is Miracast here? Because is already embedded in many WiFi chips, so its presence does not lead to additional costs. But you can transfer the image wirelessly to TVs, projectors and TV set-top boxes, that already have Miracast built in. + +Regarding Bluetooth, there’s nothing special. It’s version 4.2 or newest. By the way, the keyboard and trackpoint have a separate Bluetooth module. This is much easier than connect them to the system-wide module. + +Of course, the adminbook has a built-in cellular modem for 4G (LTE) / 3G / EDGE / GPRS, as well as a GPS / GLONASS / Galileo / Beidou receiver. This receiver also doesn’t cost much, because it’s already built into the 4G modem. + +There is also an NFC communication module, with the antenna under the spacebar. Antennas of all other wireless interfaces are in a plastic insert above the display. + +You can configure wireless interfaces with the «WRLS» button (Fn + F7). + +### 12\. USB connectors + +In total, four USB 3.0 Type A connectors and four USB 3.1 Type C connectors are built into the adminbook. Peripherals are connected to the adminbook through these. + +One more Type C and MicroUSB are allocated only for keyboard / mouse / drive emulation (denoted as “OTG”). + +«QC 3.0» labeled MicroUSB connector can not only be used for power, but it can switch to normal USB 2.0 port mode, except using MicroB instead of normal Type A. Why is it necessary? Because to flash some electronics you sometimes need non-standard USB A to USB A cables. + +In order to not make adapters outselves, you can use a regular phone charging cable by plugging it into this Micro B connector. Or use an USB A to USB Type C cable (if you have one). + +![](https://habrastorage.org/webt/0p/90/7e/0p907ezbunekqwobeogjgs5fgsa.jpeg) +Fig.12.1 — Homemade USB A to USB A cable + +Since USB Type C supports alternate modes, it makes sense to use it. Alternate modes are when the connector works as HDMI or DisplayPort video outputs. Though you’ll need adapters to connect it to a TV or monitor. Or appropriate cables that have Type C on one end and HDMI / DP on the other. However, USB Type C to USB Type C cables might soon become the most common video transfer cable. + +The Type C connector on the left side of the adminbook supports an alternate Display Port mode, and on the right side, HDMI. Like the other video outputs of the adminbook, they can work as both input and output. + +The one thing left to say is that Type C is bidirectional in regard to power delivery — it can both take in power as well as output it. + +### 13\. Other + +On the left side there are four audio connectors: Line In, Line Out, Microphone and the combo headset jack (headphones + microphone). Supports simple stereo, quad and 5.1 mode output. + +Audio outputs are specially placed next to the video connectors, so that when connected to any equipment, the wires are on one side. + +Built-in speakers are on the sides. Outside, they are covered with grills and acoustic fabric with water-repellent impregnation. + +There are also two slots for memory cards — full-size SD and MicroSD. If you think that the first slot is needed only for copying photos from the camera — you are mistaken. Now, both single-board computers like Raspberry Pi and even rack-mount servers are loaded from SD cards. MicroSD cards are also commonly found outside of phones. In general, you need both card slots. + +Sensors more familiar to phones — a gyroscope, an accelerometer and a magnetometer — are built into the lid of the notebook. Thanks to this, one can determine where the notebook cameras are directed and use this for augmented reality, as well as navigation. Sensors are controlled via the menu using the “SNSR” button (Fn + F11). + +Among the function buttons with Fn, F1 (“MAN”) and F12 (“ETC”) I haven’t described yet. The first is a built-in guide on connectors, modes and how to use the adminbook. The second is the settings of non-standard subsystems that have not separate buttons. + +### 14\. What's inside + +The adminbook is based on the Core i5-7Y57 CPU (Kaby Lake architecture). Although it’s less of a CPU, but more of a real SOC (System On a Chip). That is, almost the entire computer (without peripherals) fits in one chip the size of a thumb nail (2x1.6 cm). + +It emits from 3.5W to 7W of heat (depends on the frequency). So, a passive cooling system is adequate in this case. + +8GB of RAM are installed by default, expandable up to 16GB. + +A 256GB M.2 2280 SSD, connected with two PCIe lanes, is used as the hard drive. + +Wi-Fi + Bluetooth and WWAN + GNSS adapters are also designed as M.2 modules. + +RAM, the hard drive and wireless adapters are located on the top of the motherboard and can be replaced by the user — just unscrew and lift the keyboard. + +The battery is assembled from four LP545590 cells and can also be replaced. + +SOC and other irreplaceable hardware are located on the bottom of the motherboard. The heating components for cooling are pressed directly against the case. + +External connectors are located on daughter boards connected to the motherboard via ribbon cables. That allows to release different versions of the adminbook based on the same motherboard. + +For example, one of the possible version: + +![](https://habrastorage.org/webt/j9/sw/vq/j9swvqfi1-ituc4u9nr6-ijv3nq.jpeg) +Fig.14.1 — Adminbook A4 (front view) + +![](https://habrastorage.org/webt/pw/fq/ag/pwfqagvrluf1dbnmcd0rt-0eyc0.jpeg) +Fig.14.2 — Adminbook A4 (back view) + +![](https://habrastorage.org/webt/mn/ir/8i/mnir8in1pssve0m2tymevz2sue4.jpeg) +Fig.14.3 — Adminbook A4 (keyboard) + +This is an adminbook with a 12.5” display, its overall dimensions are 210x297mm (A4 paper format). The keyboard is full-size, with a standard key size (only the top row is a bit narrower). All the standard keys are there, except for the numpad and the Right Win, available with Fn keys. And trackpad added. + +### 15\. The underside of the adminbook + +Not expecting anything interesting from the bottom? But there is! + +First I will say a few words about the rubber feet. On my ThinkPad, they sometimes fall away and lost. I don't know if it's a bad glue, or a backpack is not suitable for a notebook, but it happens. + +Therefore, in the adminbook, the rubber feet are screwed in (the screws are slightly buried in rubber, so as not to scratch the tables). The feet are sufficiently streamlined so that they cling less to other objects. + +On the bottom there are visible drainage holes marked with a water drop. + +And the four threaded holes for connecting the adminbook with fasteners. + +![](https://habrastorage.org/webt/3d/q9/ku/3dq9kus6t7ql3rh5mbpfo3_xqng.jpeg) +Fig.15.1 — The underside of the adminbook + +Large hole in the center has a tripod thread. + +![](https://habrastorage.org/webt/t5/e5/ps/t5e5ps3iasu2j-22uc2rgl_5x_y.jpeg) +Fig.15.2 — Camera clamp mount + +Why is it necessary? Because sometimes you have to hang on high, holding the mast with one hand, holding the notebook with the second, and typing something on the third… Unfortunately, I am not Shiva, so these tricks are not easy for me. And you can just screw the adminbook by a camera mount to any protruding part of the structure and free your hands! + +No protruding parts? No problem. A plate with neodymium magnets is screwed to three other holes and the adminbook is magnetised to any steel surface — even vertical! As you see, opening the display by 180° is pretty useful. + +![](https://habrastorage.org/webt/ua/28/ub/ua28ubhpyrmountubiqjegiibem.jpeg) +Fig.15.3 — Fastening with magnets and shaped holes for nails / screws + +And if there is no metal? For example, working on the roof, and next to only a wooden wall. Then you can screw 1-2 screws in the wall and hang the adminbook on them. To do this, there are special slots in the mount, plus an eyelet on the handle. + +For especially difficult cases, there’s an arm mount. This is not very convenient, but better than nothing. Besides, it allows you to navigate even with a working notebook. + +![](https://habrastorage.org/webt/tp/fo/0y/tpfo0y_8gku4bmlbeqwfux1j4me.jpeg) +Fig.15.4 — Arm mount + +In general, these three holes use a regular metric thread, specifically so that you can make some DIY fastening and fasten it with ordinary screws. + +Except fasteners, an additional radiator can be screwed to these holes, so that you can work for a long time under high load or at high ambient temperature. + +![](https://habrastorage.org/webt/k4/jo/eq/k4joeqhmaxgvzhnxno6z3alg5go.jpeg) +Fig.15.5 — Adminbook with additional radiator + +### 16\. Accessories + +The adminbook has some unique features, and some of them are implemented using equipment designed specifically for the adminbook. Therefore, these accessories are immediately included. However, non-unique accessories are also available immediately. + +Here is a complete list of both: + + * fasteners with magnets + * arm mount + * heatsink + * screen blinds covering it from sunlight + * HD Mini SAS to U.2 cable + * combined adapter from U.2 to M.2 and PCIe + * power cable, terminated by coaxial 5.5x2.5mm connectors + * adapter from power cable to cigarette lighter + * adapter from power cable to crocodile clips + * different adapters from the power cable to coaxial connectors + * universal power supply and power cord from it into the outlet + + + +### 17\. Power supply + +Since this is a power supply for a system administrator's notebook, it would be nice to make it universal, capable of powering various electronic devices. Fortunately, the vast majority of devices are connected via coaxial connectors or USB. I mean devices with external power supplies: routers, switches, notebooks, nettops, single-board computers, DVRs, IPTV set top boxes, satellite tuners and more. + +![](https://habrastorage.org/webt/jv/zs/ve/jvzsveqavvi2ihuoajjnsr1xlp0.jpeg) +Fig.17.1 — Adapters from 5.5x2.5mm coaxial connector to other types of connectors + +There aren’t many connector types, which allows to get by with an adjustable-voltage PSU and adapters for the necessary connectors. It also needs to support various power delivery standards. + +In our case, the power supply supports the following modes: + + * Power Delivery — displayed as **[pd]** + * Quick Charge **[qc]** + * 802.3af/at **[at]** + * voltage from 5 to 54 volts in 0.5V increments (displayed voltage) + + + +![](https://habrastorage.org/webt/fj/jm/qv/fjjmqvdhezywuyh9ew3umy9wgmg.jpeg) +Fig.17.2 — Mode display on the 7-segment indicator (1.9. = 19.5V) + +![](https://habrastorage.org/webt/h9/zg/u0/h9zgu0ngl01rvhgivlw7fb49gpq.jpeg) +Fig.17.3 — Front and top sides of power supply + +USB outputs on the power supply (5V 2A) are always on. On the other outputs the voltage is applied by pressing the ON/OFF button. + +The desired mode is selected with the MODE button and this selection is remembered even when the power is turned off. The modes are listed like this: pd, qc, at, then a series of voltages. + +Voltage increases by pressing and holding the MODE button, decreases by short pressing. Step to the right — 1 Volt, step to the left — 0.5 Volt. Half a volt is needed because some equipment requires, for example, 19.5 volts. These half volts are displayed on the display with decimal points (19V -> **[19]** , 19.5V -> **[1.9.]** ). + +When power is on, the green LED is on. When a short-circuit or overcurrent protection is triggered, **[SH]** is displayed, and the LED lights up red. + +In the Power Delivery and Quick Charge modes, voltage is applied to the USB outputs (Type A and Type C). Only one of them can be used at one time. + +In 802.3af/at modes, the power supply acts as an injector, combining the supply voltage with data from the LAN connector and supplying it to the POE connector. Power is supplied only if a device with 802.3af or 802.3at support is plugged into the POE connector. + +But in the simple voltage supply mode, electricity throu the POE connector is issued immediately, without any checks. This is the so-called Passive POE — positive charge goes to conductors 4 and 5, and negative charge to conductors 7 and 8. At the same time, the voltage is applied to the coaxial connector. Adapters for various types of connectors are used in this mode. + +The power supply unit has a built-in button to remotely reset Ubiquity access points. This is a very useful feature that allows you to reset the antenna to factory settings without having to climb on the mast. I don’t know — is any other manufacturers support a feature like this? + +The power supply also has the passive wiremap adapter, which allows you to determine the correct Ethernet cable crimping. The active part is located in the Ethernet ports of the adminbook. + +![](https://habrastorage.org/webt/pp/bm/ws/ppbmws4g1o5j05eyqqulnwuuwge.jpeg) +Fig.17.4 — Back side and wiremap adapter + +Of course, the network cable tester built into the adminbook will not replace a professional OTDR, but for most tasks it will be enough. + +To prevent overheating, part of the PSU’s body acts as an aluminum heatsink. Power supply power — 65 watts, size 10x5x4cm. + +### 18\. Afterword + +“It won’t fit into such a small case!” — the sceptics will probably say. To be frank, I also sometimes think that way when re-reading what I wrote above. + +And then I open the 3D model and see, that all parts fits. Of course, I am not an electronic engineer, and for sure I miss some important things. But, I hope that if there are mistakes, they are “overcorrections”. That is, real engineers would fit all of that into a case even smaller. + +By and large, the adminbook can be divided into 5 functional parts: + + * the usual part, as in all notebooks — processor, memory, hard drive, etc. + * keyboard and trackpoint that can work separately + * autonomous video subsystem + * subsystem for managing non-standard features (enable / disable POE, infrared remote control, PCIe mode switching, LAN testing, etc.) + * power subsystem + + + +If we consider them separately, then everything looks quite feasible. + +The **SOC Kaby Lake** contains a CPU, a graphics accelerator, a memory controller, PCIe, SATA controller, USB controller for 6 USB3 and 10 USB2 outputs, Gigabit Ethernet controller, 4 lanes to connect webcams, integrated audio and etc. + +All that remains is to trace the lanes to connectors and supply power to it. + +**Keyboard and trackpoint** is a separate module that connects via USB to the adminbook or to an external connector. Nothing complicated here: USB and Bluetooth keyboards are very widespread. In our case, in addition, needs to make a rewritable table of scan codes and transfer non-standard keys over a separate interface other than USB. + +**The video subsystem** receives the video signal from the adminbook or from external connectors. In fact, this is a regular monitor with a video switchboard plus a couple of VGA converters. + +**Non-standard features** are managed independently of the operating system. The easiest way to do it with via a separate microcontroller which receives codes for pressing non-standard keys (those that are pressed with Fn) and performs the corresponding actions. + +Since you have to display a menu to change the settings, the microcontroller has a video output, connected to the adminbook for the duration of the setup. + +**The internal PSU** is galvanically isolated from the rest of the system. Why not? On habr.com there was an article about making a 100W, 9.6mm thickness planar transformer! And it only costs $0.5. + +So the electronic part of the adminbook is quite feasible. There is the programming part, and I don’t know which part will harder. + +This concludes my fairly long article. It long, even though I simplified, shortened and threw out minor details. + +The ideal end of the article was a link to an online store where you can buy an adminbook. But it's not yet designed and released. Since this requires money. + +Unfortunately, I have no experience with Kickstarter or Indigogo. Maybe you have this experience? Let's do it together! + +### Update + +Many people asked for a simplified version. Ok. Done. Sorry — just a 3d model, without render. + +Deleted: second LAN adapter, micro SD card reader, one USB port Type C, second camera, camera lights and camera curtines, display latch, unnecessary audio connectors. + +Also in this version there will be no infrared remote control, a reprogrammable keyboard, QC 3.0 charging standard, and getting power by POE. + +![](https://habrastorage.org/webt/3l/lg/vm/3llgvmv4pebiruzgldqckab0uyc.jpeg) +![](https://habrastorage.org/webt/sp/x6/rv/spx6rvmn6zlumbwg46xwfmjnako.jpeg) +![](https://habrastorage.org/webt/sm/g0/xz/smg0xzdspfm3vr3gep__6bcqae8.jpeg) + + +-------------------------------------------------------------------------------- + +via: https://habr.com/en/post/437912/ + +作者:[sukhe][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://habr.com/en/users/sukhe/ +[b]: https://github.com/lujun9972 +[1]: https://habrastorage.org/webt/_1/mp/vl/_1mpvlyujldpnad0cvvzvbci50y.jpeg +[2]: https://habrastorage.org/webt/mr/m6/d3/mrm6d3szvghhpghfchsl_-lzgb4.jpeg diff --git a/sources/tech/20190129 Get started with gPodder, an open source podcast client.md b/sources/tech/20190129 Get started with gPodder, an open source podcast client.md deleted file mode 100644 index ca1556e16d..0000000000 --- a/sources/tech/20190129 Get started with gPodder, an open source podcast client.md +++ /dev/null @@ -1,64 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Get started with gPodder, an open source podcast client) -[#]: via: (https://opensource.com/article/19/1/productivity-tool-gpodder) -[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) - -Get started with gPodder, an open source podcast client -====== -Keep your podcasts synced across your devices with gPodder, the 17th in our series on open source tools that will make you more productive in 2019. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/podcast-record-microphone.png?itok=8yUDOywf) - -There seems to be a mad rush at the beginning of every year to find ways to be more productive. New Year's resolutions, the itch to start the year off right, and of course, an "out with the old, in with the new" attitude all contribute to this. And the usual round of recommendations is heavily biased towards closed source and proprietary software. It doesn't have to be that way. - -Here's the 17th of my picks for 19 new (or new-to-you) open source tools to help you be more productive in 2019. - -### gPodder - -I like podcasts. Heck, I like them so much I record three of them (you can find links to them in [my profile][1]). I learn a lot from podcasts and play them in the background when I'm working. But keeping them in sync between multiple desktops and mobile devices can be a bit of a challenge. - -[gPodder][2] is a simple, cross-platform podcast downloader, player, and sync tool. It supports RSS feeds, [FeedBurner][3], [YouTube][4], and [SoundCloud][5], and it also has an open source sync service that you can run if you want. gPodder doesn't do podcast playback; instead, it uses your audio or video player of choice. - -![](https://opensource.com/sites/default/files/uploads/gpodder-1.png) - -Installing gPodder is very straightforward. Installers are available for Windows and MacOS, and packages are available for major Linux distributions. If it isn't available in your distribution, you can run it directly from a Git checkout. With the "Add Podcasts via URL" menu option, you can enter a podcast's RSS feed URL or one of the "special" URLs for the other services. gPodder will fetch a list of episodes and present a dialog where you can select which episodes to download or mark old episodes on the list. - -![](https://opensource.com/sites/default/files/uploads/gpodder-2.png) - -One of its nicer features is that if a URL is already in your clipboard, gPodder will automatically place it in its URL field, which makes it really easy to add a new podcast to your list. If you already have an OPML file of podcast feeds, you can upload and import it. There is also a discovery option that allows you to search for podcasts on [gPodder.net][6], the free and open source podcast listing site by the people who write and maintain gPodder. - -![](https://opensource.com/sites/default/files/uploads/gpodder-3.png) - -A [mygpo][7] server synchronizes podcasts between devices. By default, gPodder uses [gPodder.net][8]'s servers, but you can change this in the configuration files if want to run your own (be aware that you'll have to modify the configuration file directly). Syncing allows you to keep your lists consistent between desktops and mobile devices. This is very useful if you listen to podcasts on multiple devices (for example, I listen on my work computer, home computer, and mobile phone), as it means no matter where you are, you have the most recent lists of podcasts and episodes without having to set things up again and again. - -![](https://opensource.com/sites/default/files/uploads/gpodder-4.png) - -Clicking on a podcast episode will bring up the text post associated with it, and clicking "Play" will launch your device's default audio or video player. If you want to use something other than the default, you can change this in gPodder's configuration settings. - -gPodder makes it simple to find, download, and listen to podcasts, synchronize them across devices, and access a lot of other features in an easy-to-use interface. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/productivity-tool-gpodder - -作者:[Kevin Sonney][a] -选题:[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/ksonney (Kevin Sonney) -[b]: https://github.com/lujun9972 -[1]: https://opensource.com/users/ksonney -[2]: https://gpodder.github.io/ -[3]: https://feedburner.google.com/ -[4]: https://youtube.com -[5]: https://soundcloud.com/ -[6]: http://gpodder.net -[7]: https://github.com/gpodder/mygpo -[8]: http://gPodder.net diff --git a/sources/tech/20190130 Get started with Budgie Desktop, a Linux environment.md b/sources/tech/20190130 Get started with Budgie Desktop, a Linux environment.md deleted file mode 100644 index 1c2389693f..0000000000 --- a/sources/tech/20190130 Get started with Budgie Desktop, a Linux environment.md +++ /dev/null @@ -1,60 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: ( ) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Get started with Budgie Desktop, a Linux environment) -[#]: via: (https://opensource.com/article/19/1/productivity-tool-budgie-desktop) -[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) - -Get started with Budgie Desktop, a Linux environment -====== -Configure your desktop as you want with Budgie, the 18th in our series on open source tools that will make you more productive in 2019. - -![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_metrics_analytics_desktop_laptop.png?itok=9QXd7AUr) - -There seems to be a mad rush at the beginning of every year to find ways to be more productive. New Year's resolutions, the itch to start the year off right, and of course, an "out with the old, in with the new" attitude all contribute to this. And the usual round of recommendations is heavily biased towards closed source and proprietary software. It doesn't have to be that way. - -Here's the 18th of my picks for 19 new (or new-to-you) open source tools to help you be more productive in 2019. - -### Budgie Desktop - -There are many, many desktop environments for Linux. From the easy to use and graphically stunning [GNOME desktop][1] (default on most major Linux distributions) and [KDE][2], to the minimalist [Openbox][3], to the highly configurable tiling [i3][4], there are a lot of options. What I look for in a good desktop environment is speed, unobtrusiveness, and a clean user experience. It is hard to be productive when a desktop works against you, not with or for you. - -![](https://opensource.com/sites/default/files/uploads/budgie-1.png) - -[Budgie Desktop][5] is the default desktop on the [Solus][6] Linux distribution and is available as an add-on package for most of the major Linux distributions. It is based on GNOME and uses many of the same tools and libraries you likely already have on your computer. - -The default desktop is exceptionally minimalistic, with just the panel and a blank desktop. Budgie includes an integrated sidebar (called Raven) that gives quick access to the calendar, audio controls, and settings menu. Raven also contains an integrated notification area with a unified display of system messages similar to MacOS's. - -![](https://opensource.com/sites/default/files/uploads/budgie-2.png) - -Clicking on the gear icon in Raven brings up Budgie's control panel with its configuration settings. Since Budgie is still in development, it is a little bare-bones compared to GNOME or KDE, and I hope it gets more options over time. The Top Panel option, which allows the user to configure the ordering, positioning, and contents of the top panel, is nice. - -![](https://opensource.com/sites/default/files/uploads/budgie-3.png) - -The Budgie Welcome application (presented at first login) contains options to install additional software, panel applets, snaps, and Flatpack packages. There are applets to handle networking, screenshots, additional clocks and timers, and much, much more. - -![](https://opensource.com/sites/default/files/uploads/budgie-4.png) - -Budgie provides a desktop that is clean and stable. It responds quickly and has many options that allow you to customize it as you see fit. - --------------------------------------------------------------------------------- - -via: https://opensource.com/article/19/1/productivity-tool-budgie-desktop - -作者:[Kevin Sonney][a] -选题:[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/ksonney (Kevin Sonney) -[b]: https://github.com/lujun9972 -[1]: https://www.gnome.org/ -[2]: https://www.kde.org/ -[3]: http://openbox.org/wiki/Main_Page -[4]: https://i3wm.org/ -[5]: https://getsol.us/solus/experiences/ -[6]: https://getsol.us/home/ diff --git a/sources/tech/20190204 7 Best VPN Services For 2019.md b/sources/tech/20190204 7 Best VPN Services For 2019.md new file mode 100644 index 0000000000..e72d7de3df --- /dev/null +++ b/sources/tech/20190204 7 Best VPN Services For 2019.md @@ -0,0 +1,77 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (7 Best VPN Services For 2019) +[#]: via: (https://www.ostechnix.com/7-best-opensource-vpn-services-for-2019/) +[#]: author: (Editor https://www.ostechnix.com/author/editor/) + +7 Best VPN Services For 2019 +====== + +At least 67 percent of global businesses in the past three years have faced data breaching. The breaching has been reported to expose hundreds of millions of customers. Studies show that an estimated 93 percent of these breaches would have been avoided had data security fundamentals been considered beforehand. + +Understand that poor data security can be extremely costly, especially to a business and could quickly lead to widespread disruption and possible harm to your brand reputation. Although some businesses can pick up the pieces the hard way, there are still those that fail to recover. Today however, you are fortunate to have access to data and network security software. + +![](https://www.ostechnix.com/wp-content/uploads/2019/02/vpn-1.jpeg) + +As you start 2019, keep off cyber-attacks by investing in a **V** irtual **P** rivate **N** etwork commonly known as **VPN**. When it comes to online privacy and security, there are many uncertainties. There are hundreds of different VPN providers, and picking the right one means striking just the right balance between pricing, services, and ease of use. + +If you are looking for a solid 100 percent tested and secure VPN, you might want to do your due diligence and identify the best match. Here are the top 7 Best tried and tested VPN services For 2019. + +### 1. Vpnunlimitedapp + +With VPN Unlimited, you have total security. This VPN allows you to use any WIFI without worrying that your personal data can be leaked. With AES-256, your data is encrypted and protected against prying third-parties and hackers. This VPN ensures you stay anonymous and untracked on all websites no matter the location. It offers a 7-day trial and a variety of protocol options: OpenVPN, IKEv2, and KeepSolid Wise. Demanding users are entitled to special extras such as a personal server, lifetime VPN subscription, and personal IP options. + +### 2. VPN Lite + +VPN Lite is an easy-to-use and **free VPN service** that allows you to browse the internet at no charges. You remain anonymous and your privacy is protected. It obscures your IP and encrypts your data meaning third parties are not able to track your activities on all online platforms. You also get to access all online content. With VPN Lite, you get to access blocked sites in your state. You can also gain access to public WIFI without the worry of having sensitive information tracked and hacked by spyware and hackers. + +### 3. HotSpot Shield + +Launched in 2005, this is a popular VPN embraced by the majority of users. The VPN protocol here is integrated by at least 70 percent of the largest security companies globally. It is also known to have thousands of servers across the globe. It comes with two free options. One is completely free but supported by online advertisements, and the second one is a 7-day trial which is the flagship product. It contains military grade data encryption and protects against malware. HotSpot Shield guaranteed secure browsing and offers lightning-fast speeds. + +### 4. TunnelBear + +This is the best way to start if you are new to VPNs. It comes to you with a user-friendly interface complete with animated bears. With the help of TunnelBear, users are able to connect to servers in at least 22 countries at great speeds. It uses **AES 256-bit encryption** guaranteeing no data logging meaning your data stays protected. You also get unlimited data for up to five devices. + +### 5. ProtonVPN + +This VPN offers you a strong premium service. You may suffer from reduced connection speeds, but you also get to enjoy its unlimited data. It features an intuitive interface easy to use, and comes with a multi-platform compatibility. Proton’s servers are said to be specifically optimized for torrenting and thus cannot give access to Netflix. You get strong security features such as protocols and encryptions meaning your browsing activities remain secure. + +### 6. ExpressVPN + +This is known as the best offshore VPN for unblocking and privacy. It has gained recognition for being the top VPN service globally resulting from solid customer support and fast speeds. It offers routers that come with browser extensions and custom firmware. ExpressVPN also has an admirable scope of quality apps, plenty of servers, and can only support up to three devices. + +It’s not entirely free, and happens to be one of the most expensive VPNs on the market today because it is fully packed with the most advanced features. With it comes a 30-day money-back guarantee, meaning you can freely test this VPN for a month. Good thing is; it is completely risk-free. If you need a VPN for a short duration to bypass online censorship for instance, this could, be your go-to solution. You don’t want to give trials to a spammy, slow, free program. + +It is also one of the best ways to enjoy online streaming as well as outdoor security. Should you need to continue using it, you only have to renew or cancel your free trial if need be. Express VPN has over 2000 servers across 90 countries, unblocks Netflix, gives lightning fast connections, and gives users total privacy. + +### 7. PureVPN + +While this VPN may not be completely free, it falls under the most budget-friendly services on this list. Users can sign up for a free seven days trial and later choose one of its paid plans. With this VPN, you get to access 750-plus servers in at least 140 countries. There is also access to easy installation on almost all devices. All its paid features can still be accessed within the free trial window. That includes unlimited data transfers, IP leakage protection, and ISP invisibility. The supproted operating systems are iOS, Android, Windows, Linux, and macOS. + +### Summary + +With the large variety of available freemium VPN services today, why not take that opportunity to protect yourself and your customers? Understand that there are some great VPN services. Even the most secure free service however, cannot be touted as risk free. You might want to upgrade to a premium one for increased protection. Premium VPN allows you to test freely offering risk-free money-back guarantee. Whether you plan to sign up for a paid VPN or commit to a free one, it is highly advisable to have a VPN. + +**About the author:** + +**Renetta K. Molina** is a tech enthusiast and fitness enthusiast. She writes about technology, apps, WordPress and a variety of other topics. In her free time, she likes to play golf and read books. She loves to learn and try new things. + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/7-best-opensource-vpn-services-for-2019/ + +作者:[Editor][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.ostechnix.com/author/editor/ +[b]: https://github.com/lujun9972 diff --git a/sources/tech/20190204 Top 5 open source network monitoring tools.md b/sources/tech/20190204 Top 5 open source network monitoring tools.md new file mode 100644 index 0000000000..afbcae9833 --- /dev/null +++ b/sources/tech/20190204 Top 5 open source network monitoring tools.md @@ -0,0 +1,125 @@ +[#]: collector: (lujun9972) +[#]: translator: (sugarfillet) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Top 5 open source network monitoring tools) +[#]: via: (https://opensource.com/article/19/2/network-monitoring-tools) +[#]: author: (Paul Bischoff https://opensource.com/users/paulbischoff) + +Top 5 open source network monitoring tools +====== +Keep an eye on your network to avoid downtime with these monitoring tools. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/mesh_networking_dots_connected.png?itok=ovINTRR3) + +Maintaining a live network is one of a system administrator's most essential tasks, and keeping a watchful eye over connected systems is essential to keeping a network functioning at its best. + +There are many different ways to keep tabs on a modern network. Network monitoring tools are designed for the specific purpose of monitoring network traffic and response times, while application performance management solutions use agents to pull performance data from the application stack. If you have a live network, you need network monitoring to make sure you aren't vulnerable to an attacker. Likewise, if you rely on lots of different applications to run your daily operations, you will need an [application performance management][1] solution as well. + +This article will focus on open source network monitoring tools. These tools help monitor individual nodes and applications for signs of poor performance. Through one window, you can view the performance of an entire network and even get alerts to keep you in the loop if you're away from your desk. + +Before we get into the top five network monitoring tools, let's look more closely at the reasons you need to use one. + +### Why do I need a network monitoring tool? + +Network monitoring tools are vital to maintaining networks because they allow you to keep an eye on devices connected to the network from a central location. These tools help flag devices with subpar performance so you can step in and run troubleshooting to get to the root of the problem. + +Running in-depth troubleshooting can minimize performance problems and prevent security breaches. In practical terms, this keeps the network online and eliminates the risk of falling victim to unnecessary downtime. Regular network maintenance can also help prevent outages that could take thousands of users offline. + +A network monitoring tool enables you to: + + * Autodiscover devices connected to your network + * View live and historic performance data for a range of devices and applications + * Configure alerts to notify you of unusual activity + * Generate graphs and reports to analyze network activity in greater depth + +### The top 5 open source network monitoring tools + +Now, that you know why you need a network monitoring tool, take a look at the top 5 open source tools to see which might best meet your needs. + +#### Cacti + +![](https://opensource.com/sites/default/files/uploads/cacti_network-monitoring-tools.png) + +If you know anything about open source network monitoring tools, you've probably heard of [Cacti][2]. It's a graphing solution that acts as an addition to [RRDTool][3] and is used by many network administrators to collect performance data in LANs. Cacti comes with Simple Network Management Protocol (SNMP) support on Windows and Linux to create graphs of traffic data. + +Cacti typically works by using data sourced from user-created scripts that ping hosts on a network. The values returned by the scripts are stored in a MySQL database, and this data is used to generate graphs. + +This sounds complicated, but Cacti has templates to help speed the process along. You can also create a graph or data source template that can be used for future monitoring activity. If you'd like to try it out, [download Cacti][4] for free on Linux and Windows. + +#### Nagios Core + +![](https://opensource.com/sites/default/files/uploads/nagioscore_network-monitoring-tools.png) + +[Nagios Core][5] is one of the most well-known open source monitoring tools. It provides a network monitoring experience that combines open source extensibility with a top-of-the-line user interface. With Nagios Core, you can auto-discover devices, monitor connected systems, and generate sophisticated performance graphs. + +Support for customization is one of the main reasons Nagios Core has become so popular. For example, [Nagios V-Shell][6] was added as a PHP web interface built in AngularJS, searchable tables and a RESTful API designed with CodeIgniter. + +If you need more versatility, you can check the Nagios Exchange, which features a range of add-ons that can incorporate additional features into your network monitoring. These range from the strictly cosmetic to monitoring enhancements like [nagiosgraph][7]. You can try it out by [downloading Nagios Core][8] for free. + +#### Icinga 2 + +![](https://opensource.com/sites/default/files/uploads/icinga2_network-monitoring-tools.png) + +[Icinga 2][9] is another widely used open source network monitoring tool. It builds on the groundwork laid by Nagios Core. It has a flexible RESTful API that allows you to enter your own configurations and view live performance data through the dashboard. Dashboards are customizable, so you can choose exactly what information you want to monitor in your network. + +Visualization is an area where Icinga 2 performs particularly well. It has native support for Graphite and InfluxDB, which can turn performance data into full-featured graphs for deeper performance analysis. + +Icinga2 also allows you to monitor both live and historical performance data. It offers excellent alerts capabilities for live monitoring, and you can configure it to send notifications of performance problems by email or text. You can [download Icinga 2][10] for free for Windows, Debian, DHEL, SLES, Ubuntu, Fedora, and OpenSUSE. + +#### Zabbix + +![](https://opensource.com/sites/default/files/uploads/zabbix_network-monitoring-tools.png) + +[Zabbix][11] is another industry-leading open source network monitoring tool, used by companies from Dell to Salesforce on account of its malleable network monitoring experience. Zabbix does network, server, cloud, application, and services monitoring very well. + +You can track network information such as network bandwidth usage, network health, and configuration changes, and weed out problems that need to be addressed. Performance data in Zabbix is connected through SNMP, Intelligent Platform Management Interface (IPMI), and IPv6. + +Zabbix offers a high level of convenience compared to other open source monitoring tools. For instance, you can automatically detect devices connected to your network before using an out-of-the-box template to begin monitoring your network. You can [download Zabbix][12] for free for CentOS, Debian, Oracle Linux, Red Hat Enterprise Linux, Ubuntu, and Raspbian. + +#### Prometheus + +![](https://opensource.com/sites/default/files/uploads/promethius_network-monitoring-tools.png) + +[Prometheus][13] is an open source network monitoring tool with a large community following. It was built specifically for monitoring time-series data. You can identify time-series data by metric name or key-value pairs. Time-series data is stored on local disks so that it's easy to access in an emergency. + +Prometheus' [Alertmanager][14] allows you to view notifications every time it raises an event. Alertmanager can send notifications via email, PagerDuty, or OpsGenie, and you can silence alerts if necessary. + +Prometheus' visual elements are excellent and allow you to switch from the browser to the template language and Grafana integration. You can also integrate various third-party data sources into Prometheus from Docker, StatsD, and JMX to customize your Prometheus experience. + +As a network monitoring tool, Prometheus is suitable for organizations of all sizes. The onboard integrations and the easy-to-use Alertmanager make it capable of handling any workload, regardless of its size. You can [download Prometheus][15] for free. + +### Which are best? + +No matter what industry you're working in, if you rely on a network to do business, you need to implement some form of network monitoring. Network monitoring tools are an invaluable resource that help provide you with the visibility to keep your systems online. Monitoring your systems will give you the best chance to keep your equipment in working order. + +As the tools on this list show, you don't need to spend an exorbitant amount of money to reap the rewards of network monitoring. Of the five, I believe Icinga 2 and Zabbix are the best options for providing you with everything you need to start monitoring your network to keep it online. Staying vigilant will help to minimize the change of being caught off-guard by performance issues. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/network-monitoring-tools + +作者:[Paul Bischoff][a] +选题:[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/paulbischoff +[b]: https://github.com/lujun9972 +[1]: https://www.comparitech.com/net-admin/application-performance-management/ +[2]: https://www.cacti.net/index.php +[3]: https://en.wikipedia.org/wiki/RRDtool +[4]: https://www.cacti.net/download_cacti.php +[5]: https://www.nagios.org/projects/nagios-core/ +[6]: https://exchange.nagios.org/directory/Addons/Frontends-%28GUIs-and-CLIs%29/Web-Interfaces/Nagios-V-2DShell/details +[7]: https://exchange.nagios.org/directory/Addons/Graphing-and-Trending/nagiosgraph/details#_ga=2.79847774.890594951.1545045715-2010747642.1545045715 +[8]: https://www.nagios.org/downloads/nagios-core/ +[9]: https://icinga.com/products/icinga-2/ +[10]: https://icinga.com/download/ +[11]: https://www.zabbix.com/ +[12]: https://www.zabbix.com/download +[13]: https://prometheus.io/ +[14]: https://prometheus.io/docs/alerting/alertmanager/ +[15]: https://prometheus.io/download/ diff --git a/sources/tech/20190205 12 Methods To Check The Hard Disk And Hard Drive Partition On Linux.md b/sources/tech/20190205 12 Methods To Check The Hard Disk And Hard Drive Partition On Linux.md new file mode 100644 index 0000000000..ef8c8dc460 --- /dev/null +++ b/sources/tech/20190205 12 Methods To Check The Hard Disk And Hard Drive Partition On Linux.md @@ -0,0 +1,435 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (12 Methods To Check The Hard Disk And Hard Drive Partition On Linux) +[#]: via: (https://www.2daygeek.com/linux-command-check-hard-disks-partitions/) +[#]: author: (Vinoth Kumar https://www.2daygeek.com/author/vinoth/) + +12 Methods To Check The Hard Disk And Hard Drive Partition On Linux +====== + +Usually Linux admins check the available hard disk and it’s partitions whenever they want to add a new disks or additional partition in the system. + +We used to check the partition table of our hard disk to view the disk partitions. + +This will help you to view how many partitions were already created on the disk. Also, it allow us to verify whether we have any free space or not. + +In general hard disks can be divided into one or more logical disks called partitions. + +Each partitions can be used as a separate disk with its own file system and partition information is stored in a partition table. + +It’s a 64-byte data structure. The partition table is part of the master boot record (MBR), which is a small program that is executed when a computer boots. + +The partition information are saved in the 0 the sector of the disk. Make a note, all the partitions must be formatted with an appropriate file system before files can be written to it. + +This can be verified using the following 12 methods. + + * **`fdisk:`** manipulate disk partition table + * **`sfdisk:`** display or manipulate a disk partition table + * **`cfdisk:`** display or manipulate a disk partition table + * **`parted:`** a partition manipulation program + * **`lsblk:`** lsblk lists information about all available or the specified block devices. + * **`blkid:`** locate/print block device attributes. + * **`hwinfo:`** hwinfo stands for hardware information tool is another great utility that used to probe for the hardware present in the system. + * **`lshw:`** lshw is a small tool to extract detailed information on the hardware configuration of the machine. + * **`inxi:`** inxi is a command line system information script built for for console and IRC. + * **`lsscsi:`** list SCSI devices (or hosts) and their attributes + * **`cat /proc/partitions:`** + * **`ls -lh /dev/disk/:`** The directory contains Disk manufacturer name, serial number, partition ID and real block device files, Those were symlink with real block device files. + + + +### How To Check Hard Disk And Hard Drive Partition In Linux Using fdisk Command? + +**[fdisk][1]** stands for fixed disk or format disk is a cli utility that allow users to perform following actions on disks. It allows us to view, create, resize, delete, move and copy the partitions. + +``` +# fdisk -l + +Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors +Units: sectors of 1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +Disklabel type: dos +Disk identifier: 0xeab59449 + +Device Boot Start End Sectors Size Id Type +/dev/sda1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 20973568 62914559 41940992 20G 83 Linux + + +Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors +Units: sectors of 1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes + + +Disk /dev/sdc: 10 GiB, 10737418240 bytes, 20971520 sectors +Units: sectors of 1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +Disklabel type: dos +Disk identifier: 0x8cc8f9e5 + +Device Boot Start End Sectors Size Id Type +/dev/sdc1 2048 2099199 2097152 1G 83 Linux +/dev/sdc3 4196352 6293503 2097152 1G 83 Linux +/dev/sdc4 6293504 20971519 14678016 7G 5 Extended +/dev/sdc5 6295552 8392703 2097152 1G 83 Linux + + +Disk /dev/sdd: 10 GiB, 10737418240 bytes, 20971520 sectors +Units: sectors of 1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes + + +Disk /dev/sde: 10 GiB, 10737418240 bytes, 20971520 sectors +Units: sectors of 1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +``` + +### How To Check Hard Disk And Hard Drive Partition In Linux Using sfdisk Command? + +sfdisk is a script-oriented tool for partitioning any block device. sfdisk supports MBR (DOS), GPT, SUN and SGI disk labels, but no longer provides any functionality for CHS (Cylinder-Head-Sector) addressing. + +``` +# sfdisk -l + +Disk /dev/sda: 30 GiB, 32212254720 bytes, 62914560 sectors +Units: sectors of 1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +Disklabel type: dos +Disk identifier: 0xeab59449 + +Device Boot Start End Sectors Size Id Type +/dev/sda1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 20973568 62914559 41940992 20G 83 Linux + + +Disk /dev/sdb: 10 GiB, 10737418240 bytes, 20971520 sectors +Units: sectors of 1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes + + +Disk /dev/sdc: 10 GiB, 10737418240 bytes, 20971520 sectors +Units: sectors of 1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +Disklabel type: dos +Disk identifier: 0x8cc8f9e5 + +Device Boot Start End Sectors Size Id Type +/dev/sdc1 2048 2099199 2097152 1G 83 Linux +/dev/sdc3 4196352 6293503 2097152 1G 83 Linux +/dev/sdc4 6293504 20971519 14678016 7G 5 Extended +/dev/sdc5 6295552 8392703 2097152 1G 83 Linux + + +Disk /dev/sdd: 10 GiB, 10737418240 bytes, 20971520 sectors +Units: sectors of 1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes + + +Disk /dev/sde: 10 GiB, 10737418240 bytes, 20971520 sectors +Units: sectors of 1 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 512 = 512 bytes +Sector size (logical/physical): 512 bytes / 512 bytes +I/O size (minimum/optimal): 512 bytes / 512 bytes +``` + +### How To Check Hard Disk And Hard Drive Partition In Linux Using cfdisk Command? + +cfdisk is a curses-based program for partitioning any block device. The default device is /dev/sda. It provides basic partitioning functionality with a user-friendly interface. + +``` +# cfdisk /dev/sdc + Disk: /dev/sdc + Size: 10 GiB, 10737418240 bytes, 20971520 sectors + Label: dos, identifier: 0x8cc8f9e5 + + Device Boot Start End Sectors Size Id Type +>> /dev/sdc1 2048 2099199 2097152 1G 83 Linux + Free space 2099200 4196351 2097152 1G + /dev/sdc3 4196352 6293503 2097152 1G 83 Linux + /dev/sdc4 6293504 20971519 14678016 7G 5 Extended + ├─/dev/sdc5 6295552 8392703 2097152 1G 83 Linux + └─Free space 8394752 20971519 12576768 6G + + + + ┌───────────────────────────────────────────────────────────────────────────────┐ + │ Partition type: Linux (83) │ + │Filesystem UUID: d17e3c31-e2c9-4f11-809c-94a549bc43b7 │ + │ Filesystem: ext2 │ + │ Mountpoint: /part1 (mounted) │ + └───────────────────────────────────────────────────────────────────────────────┘ + [Bootable] [ Delete ] [ Quit ] [ Type ] [ Help ] [ Write ] + [ Dump ] + + Quit program without writing changes +``` + +### How To Check Hard Disk And Hard Drive Partition In Linux Using parted Command? + +**[parted][2]** is a program to manipulate disk partitions. It supports multiple partition table formats, including MS-DOS and GPT. It is useful for creating space for new operating systems, reorganising disk usage, and copying data to new hard disks. + +``` +# parted -l + +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sda: 32.2GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 10.7GB 32.2GB 21.5GB primary ext4 boot + + +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdb: 10.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdc: 10.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Number Start End Size Type File system Flags + 1 1049kB 1075MB 1074MB primary ext2 + 3 2149MB 3222MB 1074MB primary ext4 + 4 3222MB 10.7GB 7515MB extended + 5 3223MB 4297MB 1074MB logical + + +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sdd: 10.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: + +Model: ATA VBOX HARDDISK (scsi) +Disk /dev/sde: 10.7GB +Sector size (logical/physical): 512B/512B +Partition Table: msdos +Disk Flags: +``` + +### How To Check Hard Disk And Hard Drive Partition In Linux Using lsblk Command? + +lsblk lists information about all available or the specified block devices. The lsblk command reads the sysfs filesystem and udev db to gather information. + +If the udev db is not available or lsblk is compiled without udev support than it tries to read LABELs, UUIDs and filesystem types from the block device. In this case root permissions are necessary. The command prints all block devices (except RAM disks) in a tree-like format by default. + +``` +# lsblk +NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT +sda 8:0 0 30G 0 disk +└─sda1 8:1 0 20G 0 part / +sdb 8:16 0 10G 0 disk +sdc 8:32 0 10G 0 disk +├─sdc1 8:33 0 1G 0 part /part1 +├─sdc3 8:35 0 1G 0 part /part2 +├─sdc4 8:36 0 1K 0 part +└─sdc5 8:37 0 1G 0 part +sdd 8:48 0 10G 0 disk +sde 8:64 0 10G 0 disk +sr0 11:0 1 1024M 0 rom +``` + +### How To Check Hard Disk And Hard Drive Partition In Linux Using blkid Command? + +blkid is a command-line utility to locate/print block device attributes. It uses libblkid library to get disk partition UUID in Linux system. + +``` +# blkid +/dev/sda1: UUID="d92fa769-e00f-4fd7-b6ed-ecf7224af7fa" TYPE="ext4" PARTUUID="eab59449-01" +/dev/sdc1: UUID="d17e3c31-e2c9-4f11-809c-94a549bc43b7" TYPE="ext2" PARTUUID="8cc8f9e5-01" +/dev/sdc3: UUID="ca307aa4-0866-49b1-8184-004025789e63" TYPE="ext4" PARTUUID="8cc8f9e5-03" +/dev/sdc5: PARTUUID="8cc8f9e5-05" +``` + +### How To Check Hard Disk And Hard Drive Partition In Linux Using hwinfo Command? + +**[hwinfo][3]** stands for hardware information tool is another great utility that used to probe for the hardware present in the system and display detailed information about varies hardware components in human readable format. + +``` +# hwinfo --block --short +disk: + /dev/sdd VBOX HARDDISK + /dev/sdb VBOX HARDDISK + /dev/sde VBOX HARDDISK + /dev/sdc VBOX HARDDISK + /dev/sda VBOX HARDDISK +partition: + /dev/sdc1 Partition + /dev/sdc3 Partition + /dev/sdc4 Partition + /dev/sdc5 Partition + /dev/sda1 Partition +cdrom: + /dev/sr0 VBOX CD-ROM +``` + +### How To Check Hard Disk And Hard Drive Partition In Linux Using lshw Command? + +**[lshw][4]** (stands for Hardware Lister) is a small nifty tool that generates detailed reports about various hardware components on the machine such as memory configuration, firmware version, mainboard configuration, CPU version and speed, cache configuration, usb, network card, graphics cards, multimedia, printers, bus speed, etc. + +``` +# lshw -short -class disk -class volume +H/W path Device Class Description +=================================================== +/0/3/0.0.0 /dev/cdrom disk CD-ROM +/0/4/0.0.0 /dev/sda disk 32GB VBOX HARDDISK +/0/4/0.0.0/1 /dev/sda1 volume 19GiB EXT4 volume +/0/5/0.0.0 /dev/sdb disk 10GB VBOX HARDDISK +/0/6/0.0.0 /dev/sdc disk 10GB VBOX HARDDISK +/0/6/0.0.0/1 /dev/sdc1 volume 1GiB Linux filesystem partition +/0/6/0.0.0/3 /dev/sdc3 volume 1GiB EXT4 volume +/0/6/0.0.0/4 /dev/sdc4 volume 7167MiB Extended partition +/0/6/0.0.0/4/5 /dev/sdc5 volume 1GiB Linux filesystem partition +/0/7/0.0.0 /dev/sdd disk 10GB VBOX HARDDISK +/0/8/0.0.0 /dev/sde disk 10GB VBOX HARDDISK +``` + +### How To Check Hard Disk And Hard Drive Partition In Linux Using inxi Command? + +**[inxi][5]** is a nifty tool to check hardware information on Linux and offers wide range of option to get all the hardware information on Linux system that i never found in any other utility which are available in Linux. It was forked from the ancient and mindbendingly perverse yet ingenius infobash, by locsmif. + +``` +# inxi -Dp +Drives: HDD Total Size: 75.2GB (22.3% used) + ID-1: /dev/sda model: VBOX_HARDDISK size: 32.2GB + ID-2: /dev/sdb model: VBOX_HARDDISK size: 10.7GB + ID-3: /dev/sdc model: VBOX_HARDDISK size: 10.7GB + ID-4: /dev/sdd model: VBOX_HARDDISK size: 10.7GB + ID-5: /dev/sde model: VBOX_HARDDISK size: 10.7GB +Partition: ID-1: / size: 20G used: 16G (85%) fs: ext4 dev: /dev/sda1 + ID-3: /part1 size: 1008M used: 1.3M (1%) fs: ext2 dev: /dev/sdc1 + ID-4: /part2 size: 976M used: 2.6M (1%) fs: ext4 dev: /dev/sdc3 +``` + +### How To Check Hard Disk And Hard Drive Partition In Linux Using lsscsi Command? + +Uses information in sysfs (Linux kernel series 2.6 and later) to list SCSI devices (or hosts) currently attached to the system. Options can be used to control the amount and form of information provided for each device. + +By default in this utility device node names (e.g. “/dev/sda” or “/dev/root_disk”) are obtained by noting the major and minor numbers for the listed device obtained from sysfs + +``` +# lsscsi +[0:0:0:0] cd/dvd VBOX CD-ROM 1.0 /dev/sr0 +[2:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sda +[3:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sdb +[4:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sdc +[5:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sdd +[6:0:0:0] disk ATA VBOX HARDDISK 1.0 /dev/sde +``` + +### How To Check Hard Disk And Hard Drive Partition In Linux Using ProcFS? + +The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information. + +It’s sometimes referred to as a process information pseudo-file system. It doesn’t contain ‘real’ files but runtime system information (e.g. system memory, devices mounted, hardware configuration, etc). + +``` +# cat /proc/partitions +major minor #blocks name + + 11 0 1048575 sr0 + 8 0 31457280 sda + 8 1 20970496 sda1 + 8 16 10485760 sdb + 8 32 10485760 sdc + 8 33 1048576 sdc1 + 8 35 1048576 sdc3 + 8 36 1 sdc4 + 8 37 1048576 sdc5 + 8 48 10485760 sdd + 8 64 10485760 sde +``` + +### How To Check Hard Disk And Hard Drive Partition In Linux Using /dev/disk Path? + +This directory contains four directories, it’s by-id, by-uuid, by-path and by-partuuid. Each directory contains some useful information and it’s symlinked with real block device files. + +``` +# ls -lh /dev/disk/by-id +total 0 +lrwxrwxrwx 1 root root 9 Feb 2 23:08 ata-VBOX_CD-ROM_VB0-01f003f6 -> ../../sr0 +lrwxrwxrwx 1 root root 9 Feb 3 00:14 ata-VBOX_HARDDISK_VB26e827b5-668ab9f4 -> ../../sda +lrwxrwxrwx 1 root root 10 Feb 3 00:14 ata-VBOX_HARDDISK_VB26e827b5-668ab9f4-part1 -> ../../sda1 +lrwxrwxrwx 1 root root 9 Feb 2 23:39 ata-VBOX_HARDDISK_VB3774c742-fb2b3e4e -> ../../sdd +lrwxrwxrwx 1 root root 9 Feb 2 23:39 ata-VBOX_HARDDISK_VBe72672e5-029a918e -> ../../sdc +lrwxrwxrwx 1 root root 10 Feb 2 23:39 ata-VBOX_HARDDISK_VBe72672e5-029a918e-part1 -> ../../sdc1 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 ata-VBOX_HARDDISK_VBe72672e5-029a918e-part3 -> ../../sdc3 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 ata-VBOX_HARDDISK_VBe72672e5-029a918e-part4 -> ../../sdc4 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 ata-VBOX_HARDDISK_VBe72672e5-029a918e-part5 -> ../../sdc5 +lrwxrwxrwx 1 root root 9 Feb 2 23:39 ata-VBOX_HARDDISK_VBed1cf451-9f51c5f6 -> ../../sdb +lrwxrwxrwx 1 root root 9 Feb 2 23:39 ata-VBOX_HARDDISK_VBf242dbdd-49a982eb -> ../../sde +``` + +Output of by-uuid + +``` +# ls -lh /dev/disk/by-uuid +total 0 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 ca307aa4-0866-49b1-8184-004025789e63 -> ../../sdc3 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 d17e3c31-e2c9-4f11-809c-94a549bc43b7 -> ../../sdc1 +lrwxrwxrwx 1 root root 10 Feb 3 00:14 d92fa769-e00f-4fd7-b6ed-ecf7224af7fa -> ../../sda1 +``` + +Output of by-path + +``` +# ls -lh /dev/disk/by-path +total 0 +lrwxrwxrwx 1 root root 9 Feb 2 23:08 pci-0000:00:01.1-ata-1 -> ../../sr0 +lrwxrwxrwx 1 root root 9 Feb 3 00:14 pci-0000:00:0d.0-ata-1 -> ../../sda +lrwxrwxrwx 1 root root 10 Feb 3 00:14 pci-0000:00:0d.0-ata-1-part1 -> ../../sda1 +lrwxrwxrwx 1 root root 9 Feb 2 23:39 pci-0000:00:0d.0-ata-2 -> ../../sdb +lrwxrwxrwx 1 root root 9 Feb 2 23:39 pci-0000:00:0d.0-ata-3 -> ../../sdc +lrwxrwxrwx 1 root root 10 Feb 2 23:39 pci-0000:00:0d.0-ata-3-part1 -> ../../sdc1 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 pci-0000:00:0d.0-ata-3-part3 -> ../../sdc3 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 pci-0000:00:0d.0-ata-3-part4 -> ../../sdc4 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 pci-0000:00:0d.0-ata-3-part5 -> ../../sdc5 +lrwxrwxrwx 1 root root 9 Feb 2 23:39 pci-0000:00:0d.0-ata-4 -> ../../sdd +lrwxrwxrwx 1 root root 9 Feb 2 23:39 pci-0000:00:0d.0-ata-5 -> ../../sde +``` + +Output of by-partuuid + +``` +# ls -lh /dev/disk/by-partuuid +total 0 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 8cc8f9e5-01 -> ../../sdc1 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 8cc8f9e5-03 -> ../../sdc3 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 8cc8f9e5-04 -> ../../sdc4 +lrwxrwxrwx 1 root root 10 Feb 2 23:39 8cc8f9e5-05 -> ../../sdc5 +lrwxrwxrwx 1 root root 10 Feb 3 00:14 eab59449-01 -> ../../sda1 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-command-check-hard-disks-partitions/ + +作者:[Vinoth Kumar][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/vinoth/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/linux-fdisk-command-to-manage-disk-partitions/ +[2]: https://www.2daygeek.com/how-to-manage-disk-partitions-using-parted-command/ +[3]: https://www.2daygeek.com/hwinfo-check-display-detect-system-hardware-information-linux/ +[4]: https://www.2daygeek.com/lshw-find-check-system-hardware-information-details-linux/ +[5]: https://www.2daygeek.com/inxi-system-hardware-information-on-linux/ diff --git a/sources/tech/20190205 5 Linux GUI Cloud Backup Tools.md b/sources/tech/20190205 5 Linux GUI Cloud Backup Tools.md new file mode 100644 index 0000000000..45e0bf1342 --- /dev/null +++ b/sources/tech/20190205 5 Linux GUI Cloud Backup Tools.md @@ -0,0 +1,251 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (5 Linux GUI Cloud Backup Tools) +[#]: via: (https://www.linux.com/blog/learn/2019/2/5-linux-gui-cloud-backup-tools) +[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen) + +5 Linux GUI Cloud Backup Tools +====== +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/cloud-m-wong-unsplash.jpg?itok=aW0mpzio) + +We have reached a point in time where most every computer user depends upon the cloud … even if only as a storage solution. What makes the cloud really important to users, is when it’s employed as a backup. Why is that such a game changer? By backing up to the cloud, you have access to those files, from any computer you have associated with your cloud account. And because Linux powers the cloud, many services offer Linux tools. + +Let’s take a look at five such tools. I will focus on GUI tools, because they offer a much lower barrier to entry to many of the CLI tools. I’ll also be focusing on various, consumer-grade cloud services (e.g., [Google Drive][1], [Dropbox][2], [Wasabi][3], and [pCloud][4]). And, I will be demonstrating on the Elementary OS platform, but all of the tools listed will function on most Linux desktop distributions. + +Note: Of the following backup solutions, only Duplicati is licensed as open source. With that said, let’s see what’s available. + +### Insync + +I must confess, [Insync][5] has been my cloud backup of choice for a very long time. Since Google refuses to release a Linux desktop client for Google Drive (and I depend upon Google Drive daily), I had to turn to a third-party solution. Said solution is Insync. This particular take on syncing the desktop to Drive has not only been seamless, but faultless since I began using the tool. + +The cost of Insync is a one-time $29.99 fee (per Google account). Trust me when I say this tool is worth the price of entry. With Insync you not only get an easy-to-use GUI for managing your Google Drive backup and sync, you get a tool (Figure 1) that gives you complete control over what is backed up and how it is backed up. Not only that, but you can also install Nautilus integration (which also allows you to easy add folders outside of the configured Drive sync destination). + +![Insync app][7] + +Figure 1: The Insync app window on Elementary OS. + +[Used with permission][8] + +You can download Insync for Ubuntu (or its derivatives), Linux Mint, Debian, and Fedora from the [Insync download page][9]. Once you’ve installed Insync (and associated it with your account), you can then install Nautilus integration with these steps (demonstrating on Elementary OS): + + 1. Open a terminal window and issue the command sudo nano /etc/apt/sources.list.d/insync.list. + + 2. Paste the following into the new file: deb precise non-free contrib. + + 3. Save and close the file. + + 4. Update apt with the command sudo apt-get update. + + 5. Install the necessary package with the command sudo apt-get install insync-nautilus. + + + + +Allow the installation to complete. Once finished, restart Nautilus with the command nautilus -q (or log out and back into the desktop). You should now see an Insync entry in the Nautilus right-click context menu (Figure 2). + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/insync_2.jpg?itok=-kA0epiH) + +Figure 2: Insync/Nautilus integration in action. + +[Used with permission][8] + +### Dropbox + +Although [Dropbox][2] drew the ire of many in the Linux community (by dropping support for all filesystems but unencrypted ext4), it still supports a great deal of Linux desktop deployments. In other words, if your distribution still uses the ext4 file system (and you do not opt to encrypt your full drive), you’re good to go. + +The good news is the Dropbox Linux desktop client is quite good. The tool offers a system tray icon that allows you to easily interact with your cloud syncing. Dropbox also includes CLI tools and a Nautilus integration (by way of an additional addon found [here][10]). + +The Linux Dropbox desktop sync tool works exactly as you’d expect. From the Dropbox system tray drop-down (Figure 3) you can open the Dropbox folder, launch the Dropbox website, view recently changed files, get more space, pause syncing, open the preferences window, find help, and quite Dropbox. + +![Dropbox][12] + +Figure 3: The Dropbox system tray drop-down on Elementary OS. + +[Used with permission][8] + +The Dropbox/Nautilus integration is an important component, as it makes quickly adding to your cloud backup seamless and fast. From the Nautilus file manager, locate and right-click the folder to bad added, and select Dropbox > Move to Dropbox (Figure 4). + +The only caveat to the Dropbox/Nautilus integration is that the only option is to move a folder to Dropbox. To some this might not be an option. The developers of this package would be wise to instead have the action create a link (instead of actually moving the folder). + +Outside of that one issue, the Dropbox cloud sync/backup solution for Linux is a great route to go. + +### pCloud + +pCloud might well be one of the finest cloud backup solutions you’ve never heard of. This take on cloud storage/backup includes features like: + + * Encryption (subscription service required for this feature); + + * Mobile apps for Android and iOS; + + * Linux, Mac, and Windows desktop clients; + + * Easy file/folder sharing; + + * Built-in audio/video players; + + * No file size limitation; + + * Sync any folder from the desktop; + + * Panel integration for most desktops; and + + * Automatic file manager integration. + + + + +pCloud offers both Linux desktop and CLI tools that function quite well. pCloud offers both a free plan (with 10GB of storage), a Premium Plan (with 500GB of storage for a one-time fee of $175.00), and a Premium Plus Plan (with 2TB of storage for a one-time fee of $350.00). Both non-free plans can also be paid on a yearly basis (instead of the one-time fee). + +The pCloud desktop client is quite user-friendly. Once installed, you have access to your account information (Figure 5), the ability to create sync pairs, create shares, enable crypto (which requires an added subscription), and general settings. + +![pCloud][14] + +Figure 5: The pCloud desktop client is incredibly easy to use. + +[Used with permission][8] + +The one caveat to pCloud is there’s no file manager integration for Linux. That’s overcome by the Sync folder in the pCloud client. + +### CloudBerry + +The primary focus for [CloudBerry][15] is for Managed Service Providers. The business side of CloudBerry does have an associated cost (one that is probably well out of the price range for the average user looking for a simple cloud backup solution). However, for home usage, CloudBerry is free. + +What makes CloudBerry different than the other tools is that it’s not a backup/storage solution in and of itself. Instead, CloudBerry serves as a link between your desktop and the likes of: + + * AWS + + * Microsoft Azure + + * Google Cloud + + * BackBlaze + + * OpenStack + + * Wasabi + + * Local storage + + * External drives + + * Network Attached Storage + + * Network Shares + + * And more + + + + +In other words, you use CloudBerry as the interface between the files/folders you want to share and the destination with which you want send them. This also means you must have an account with one of the many supported solutions. +Once you’ve installed CloudBerry, you create a new Backup plan for the target storage solution. For that configuration, you’ll need such information as: + + * Access Key + + * Secret Key + + * Bucket + + + + +What you’ll need for the configuration will depend on the account you’re connecting to (Figure 6). + +![CloudBerry][17] + +Figure 6: Setting up a CloudBerry backup for Wasabi. + +[Used with permission][8] + +The one caveat to CloudBerry is that it does not integrate with any file manager, nor does it include a system tray icon for interaction with the service. + +### Duplicati + +[Duplicati][18] is another option that allows you to sync your local directories with either locally attached drives, network attached storage, or a number of cloud services. The options supported include: + + * Local folders + + * Attached drives + + * FTP/SFTP + + * OpenStack + + * WebDAV + + * Amazon Cloud Drive + + * Amazon S3 + + * Azure Blob + + * Box.com + + * Dropbox + + * Google Cloud Storage + + * Google Drive + + * Microsoft OneDrive + + * And many more + + + + +Once you install Duplicati (download the installer for Debian, Ubuntu, Fedora, or RedHat from the [Duplicati downloads page][19]), click on the entry in your desktop menu, which will open a web page to the tool (Figure 7), where you can configure the app settings, create a new backup, restore from a backup, and more. + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/duplicati_1.jpg?itok=SVf06tnv) + +To create a backup, click Add backup and walk through the easy-to-use wizard (Figure 8). The backup service you choose will dictate what you need for a successful configuration. + +![Duplicati backup][21] + +Figure 8: Creating a new Duplicati backup for Google Drive. + +[Used with permission][8] + +For example, in order to create a backup to Google Drive, you’ll need an AuthID. For that, click the AuthID link in the Destination section of the setup, where you’ll be directed to select the Google Account to associate with the backup. Once you’ve allowed Duplicati access to the account, the AuthID will fill in and you’re ready to continue. Click Test connection and you’ll be asked to okay the creation of a new folder (if necessary). Click Next to complete the setup of the backup. + +### More Where That Came From + +These five cloud backup tools aren’t the end of this particular rainbow. There are plenty more options where these came from (including CLI-only tools). But any of these backup clients will do a great job of serving your Linux desktop-to-cloud backup needs. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2019/2/5-linux-gui-cloud-backup-tools + +作者:[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.google.com/drive/ +[2]: https://www.dropbox.com/ +[3]: https://wasabi.com/ +[4]: https://www.pcloud.com/ +[5]: https://www.insynchq.com/ +[6]: /files/images/insync1jpg +[7]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/insync_1.jpg?itok=_SDP77uE (Insync app) +[8]: /licenses/category/used-permission +[9]: https://www.insynchq.com/downloads +[10]: https://www.dropbox.com/install-linux +[11]: /files/images/dropbox1jpg +[12]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/dropbox_1.jpg?itok=BYbg-sKB (Dropbox) +[13]: /files/images/pcloud1jpg +[14]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/pcloud_1.jpg?itok=cAUz8pya (pCloud) +[15]: https://www.cloudberrylab.com +[16]: /files/images/cloudberry1jpg +[17]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/cloudberry_1.jpg?itok=s0aP5xuN (CloudBerry) +[18]: https://www.duplicati.com/ +[19]: https://www.duplicati.com/download +[20]: /files/images/duplicati2jpg +[21]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/duplicati_2.jpg?itok=Xkn8s3jg (Duplicati backup) diff --git a/sources/tech/20190205 5 Streaming Audio Players for Linux.md b/sources/tech/20190205 5 Streaming Audio Players for Linux.md new file mode 100644 index 0000000000..1ddd4552f5 --- /dev/null +++ b/sources/tech/20190205 5 Streaming Audio Players for Linux.md @@ -0,0 +1,172 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (5 Streaming Audio Players for Linux) +[#]: via: (https://www.linux.com/blog/2019/2/5-streaming-audio-players-linux) +[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen) + +5 Streaming Audio Players for Linux +====== +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/music-main.png?itok=bTxfvadR) + +As I work, throughout the day, music is always playing in the background. Most often, that music is in the form of vinyl spinning on a turntable. But when I’m not in purist mode, I’ll opt to listen to audio by way of a streaming app. Naturally, I’m on the Linux platform, so the only tools I have at my disposal are those that play well on my operating system of choice. Fortunately, plenty of options exist for those who want to stream audio to their Linux desktops. + +In fact, Linux offers a number of solid offerings for music streaming, and I’ll highlight five of my favorite tools for this task. A word of warning, not all of these players are open source. But if you’re okay running a proprietary app on your open source desktop, you have some really powerful options. Let’s take a look at what’s available. + +### Spotify + +Spotify for Linux isn’t some dumb-downed, half-baked app that crashes every other time you open it, and doesn’t offer the full-range of features found on the macOS and Windows equivalent. In fact, the Linux version of Spotify is exactly the same as you’ll find on other platforms. With the Spotify streaming client you can listen to music and podcasts, create playlists, discover new artists, and so much more. And the Spotify interface (Figure 1) is quite easy to navigate and use. + +![Spotify][2] + +Figure 1: The Spotify interface makes it easy to find new music and old favorites. + +[Used with permission][3] + +You can install Spotify either using snap (with the command sudo snap install spotify), or from the official repository, with the following commands: + + * sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 931FF8E79F0876134EDDBDCCA87FF9DF48BF1C90 + + * sudo echo deb stable non-free | sudo tee /etc/apt/sources.list.d/spotify.list + + * sudo apt-get update + + * sudo apt-get install spotify-client + + + + +Once installed, you’ll want to log into your Spotify account, so you can start streaming all of the great music to help motivate you to get your work done. If you have Spotify installed on other devices (and logged into the same account), you can dictate to which device the music should stream (by clicking the Devices Available icon near the bottom right corner of the Spotify window). + +### Clementine + +Clementine one of the best music players available to the Linux platform. Clementine not only allows user to play locally stored music, but to connect to numerous streaming audio services, such as: + + * Amazon Cloud Drive + + * Box + + * Dropbox + + * Icecast + + * Jamendo + + * Magnatune + + * RockRadio.com + + * Radiotunes.com + + * SomaFM + + * SoundCloud + + * Spotify + + * Subsonic + + * Vk.com + + * Or internet radio streams + + + + +There are two caveats to using Clementine. The first is you must be using the most recent version (as the build available in some repositories is out of date and won’t install the necessary streaming plugins). Second, even with the most recent build, some streaming services won’t function as expected. For example, with Spotify, you’ll only have available to you the Top Tracks (and not your playlist … or the ability to search for songs). + +With Clementine Internet radio streaming, you’ll find musicians and bands you’ve never heard of (Figure 2), and plenty of them to tune into. + +![Clementine][5] + +Figure 2: Clementine Internet radio is a great way to find new music. + +[Used with permission][3] + +### Odio + +Odio is a cross-platform, proprietary app (available for Linux, MacOS, and Windows) that allows you to stream internet music stations of all genres. Radio stations are curated from [www.radio-browser.info][6] and the app itself does an incredible job of presenting the streams for you (Figure 3). + + +![Odio][8] + +Figure 3: The Odio interface is one of the best you’ll find. + +[Used with permission][3] + +Odio makes it very easy to find unique Internet radio stations and even add those you find and enjoy to your library. Currently, the only way to install Odio on Linux is via Snap. If your distribution supports snap packages, install this streaming app with the command: + +sudo snap install odio + +Once installed, you can open the app and start using it. There is no need to log into (or create) an account. Odio is very limited in its settings. In fact, it only offers the choice between a dark or light theme in the settings window. However, as limited as it might be, Odio is one of your best bets for playing Internet radio on Linux. + +Streamtuner2 is an outstanding Internet radio station GUI tool. With it you can stream music from the likes of: + + * Internet radio stations + + * Jameno + + * MyOggRadio + + * Shoutcast.com + + * SurfMusic + + * TuneIn + + * Xiph.org + + * YouTube + + +### StreamTuner2 + +Streamtuner2 offers a nice (if not slightly outdated) interface, that makes it quite easy to find and stream your favorite music. The one caveat with StreamTuner2 is that it’s really just a GUI for finding the streams you want to hear. When you find a station, double-click on it to open the app associated with the stream. That means you must have the necessary apps installed, in order for the streams to play. If you don’t have the proper apps, you can’t play the streams. Because of this, you’ll spend a good amount of time figuring out what apps to install for certain streams (Figure 4). + +![Streamtuner2][10] + +Figure 4: Configuring Streamtuner2 isn’t for the faint of heart. + +[Used with permission][3] + +### VLC + +VLC has been, for a very long time, dubbed the best media playback tool for Linux. That’s with good reason, as it can play just about anything you throw at it. Included in that list is streaming radio stations. Although you won’t find VLC connecting to the likes of Spotify, you can head over to Internet-Radio, click on a playlist and have VLC open it without a problem. And considering how many internet radio stations are available at the moment, you won’t have any problem finding music to suit your tastes. VLC also includes tools like visualizers, equalizers (Figure 5), and more. + +![VLC ][12] + +Figure 5: The VLC visualizer and equalizer features in action. + +[Used with permission][3] + +The only caveat to VLC is that you do have to have a URL for the Internet Radio you wish you hear, as the tool itself doesn’t curate. But with those links in hand, you won’t find a better media player than VLC. + +### Always More Where That Came From + +If one of these five tools doesn’t fit your needs, I suggest you open your distribution’s app store and search for one that will. There are plenty of tools to make streaming music, podcasts, and more not only possible on Linux, but easy. + +Learn more about Linux through the free ["Introduction to Linux" ][13] course from The Linux Foundation and edX. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/2019/2/5-streaming-audio-players-linux + +作者:[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 +[2]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/spotify_0.jpg?itok=8-Ym-R61 (Spotify) +[3]: https://www.linux.com/licenses/category/used-permission +[5]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/clementine_0.jpg?itok=5oODJO3b (Clementine) +[6]: http://www.radio-browser.info +[8]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/odio.jpg?itok=sNPTSS3c (Odio) +[10]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/streamtuner2.jpg?itok=1MSbafWj (Streamtuner2) +[12]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/vlc_0.jpg?itok=QEOsq7Ii (VLC ) +[13]: https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux diff --git a/sources/tech/20190205 CFS- Completely fair process scheduling in Linux.md b/sources/tech/20190205 CFS- Completely fair process scheduling in Linux.md new file mode 100644 index 0000000000..be44e75fea --- /dev/null +++ b/sources/tech/20190205 CFS- Completely fair process scheduling in Linux.md @@ -0,0 +1,122 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (CFS: Completely fair process scheduling in Linux) +[#]: via: (https://opensource.com/article/19/2/fair-scheduling-linux) +[#]: author: (Marty kalin https://opensource.com/users/mkalindepauledu) + +CFS: Completely fair process scheduling in Linux +====== +CFS gives every task a fair share of processor resources in a low-fuss but highly efficient way. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/fail_progress_cycle_momentum_arrow.png?itok=q-ZFa_Eh) + +Linux takes a modular approach to processor scheduling in that different algorithms can be used to schedule different process types. A scheduling class specifies which scheduling policy applies to which type of process. Completely fair scheduling (CFS), which became part of the Linux 2.6.23 kernel in 2007, is the scheduling class for normal (as opposed to real-time) processes and therefore is named **SCHED_NORMAL**. + +CFS is geared for the interactive applications typical in a desktop environment, but it can be configured as **SCHED_BATCH** to favor the batch workloads common, for example, on a high-volume web server. In any case, CFS breaks dramatically with what might be called "classic preemptive scheduling." Also, the "completely fair" claim has to be seen with a technical eye; otherwise, the claim might seem like an empty boast. + +Let's dig into the details of what sets CFS apart from—indeed, above—other process schedulers. Let's start with a quick review of some core technical terms. + +### Some core concepts + +Linux inherits the Unix view of a process as a program in execution. As such, a process must contend with other processes for shared system resources: memory to hold instructions and data, at least one processor to execute instructions, and I/O devices to interact with the external world. Process scheduling is how the operating system (OS) assigns tasks (e.g., crunching some numbers, copying a file) to processors—a running process then performs the task. A process has one or more threads of execution, which are sequences of machine-level instructions. To schedule a process is to schedule one of its threads on a processor. + +In a simplifying move, Linux turns process scheduling into thread scheduling by treating a scheduled process as if it were single-threaded. If a process is multi-threaded with N threads, then N scheduling actions would be required to cover the threads. Threads within a multi-threaded process remain related in that they share resources such as memory address space. Linux threads are sometimes described as lightweight processes, with the lightweight underscoring the sharing of resources among the threads within a process. + +Although a process can be in various states, two are of particular interest in scheduling. A blocked process is awaiting the completion of some event such as an I/O event. The process can resume execution only after the event completes. A runnable process is one that is not currently blocked. + +A process is processor-bound (aka compute-bound) if it consumes mostly processor as opposed to I/O resources, and I/O-bound in the opposite case; hence, a processor-bound process is mostly runnable, whereas an I/O-bound process is mostly blocked. As examples, crunching numbers is processor-bound, and accessing files is I/O-bound. Although an entire process might be characterized as either processor-bound or I/O-bound, a given process may be one or the other during different stages of its execution. Interactive desktop applications, such as browsers, tend to be I/O-bound. + +A good process scheduler has to balance the needs of processor-bound and I/O-bound tasks, especially in an operating system such as Linux that thrives on so many hardware platforms: desktop machines, embedded devices, mobile devices, server clusters, supercomputers, and more. + +### Classic preemptive scheduling versus CFS + +Unix popularized classic preemptive scheduling, which other operating systems including VAX/VMS, Windows NT, and Linux later adopted. At the center of this scheduling model is a fixed timeslice, the amount of time (e.g., 50ms) that a task is allowed to hold a processor until preempted in favor of some other task. If a preempted process has not finished its work, the process must be rescheduled. This model is powerful in that it supports multitasking (concurrency) through processor time-sharing, even on the single-CPU machines of yesteryear. + +The classic model typically includes multiple scheduling queues, one per process priority: Every process in a higher-priority queue gets scheduled before any process in a lower-priority queue. As an example, VAX/VMS uses 32 priority queues for scheduling. + +CFS dispenses with fixed timeslices and explicit priorities. The amount of time for a given task on a processor is computed dynamically as the scheduling context changes over the system's lifetime. Here is a sketch of the motivating ideas and technical details: + + * Imagine a processor, P, which is idealized in that it can execute multiple tasks simultaneously. For example, tasks T1 and T2 can execute on P at the same time, with each receiving 50% of P's magical processing power. This idealization describes perfect multitasking, which CFS strives to achieve on actual as opposed to idealized processors. CFS is designed to approximate perfect multitasking. + + * The CFS scheduler has a target latency, which is the minimum amount of time—idealized to an infinitely small duration—required for every runnable task to get at least one turn on the processor. If such a duration could be infinitely small, then each runnable task would have had a turn on the processor during any given timespan, however small (e.g., 10ms, 5ns, etc.). Of course, an idealized infinitely small duration must be approximated in the real world, and the default approximation is 20ms. Each runnable task then gets a 1/N slice of the target latency, where N is the number of tasks. For example, if the target latency is 20ms and there are four contending tasks, then each task gets a timeslice of 5ms. By the way, if there is only a single task during a scheduling event, this lucky task gets the entire target latency as its slice. The fair in CFS comes to the fore in the 1/N slice given to each task contending for a processor. + + * The 1/N slice is, indeed, a timeslice—but not a fixed one because such a slice depends on N, the number of tasks currently contending for the processor. The system changes over time. Some processes terminate and new ones are spawned; runnable processes block and blocked processes become runnable. The value of N is dynamic and so, therefore, is the 1/N timeslice computed for each runnable task contending for a processor. The traditional **nice** value is used to weight the 1/N slice: a low-priority **nice** value means that only some fraction of the 1/N slice is given to a task, whereas a high-priority **nice** value means that a proportionately greater fraction of the 1/N slice is given to a task. In summary, **nice** values do not determine the slice, but only modify the 1/N slice that represents fairness among the contending tasks. + + * The operating system incurs overhead whenever a context switch occurs; that is, when one process is preempted in favor of another. To keep this overhead from becoming unduly large, there is a minimum amount of time (with a typical setting of 1ms to 4ms) that any scheduled process must run before being preempted. This minimum is known as the minimum granularity. If many tasks (e.g., 20) are contending for the processor, then the minimum granularity (assume 4ms) might be more than the 1/N slice (in this case, 1ms). If the minimum granularity turns out to be larger than the 1/N slice, the system is overloaded because there are too many tasks contending for the processor—and fairness goes out the window. + + * When does preemption occur? CFS tries to minimize context switches, given their overhead: time spent on a context switch is time unavailable for other tasks. Accordingly, once a task gets the processor, it runs for its entire weighted 1/N slice before being preempted in favor of some other task. Suppose task T1 has run for its weighted 1/N slice, and runnable task T2 currently has the lowest virtual runtime (vruntime) among the tasks contending for the processor. The vruntime records, in nanoseconds, how long a task has run on the processor. In this case, T1 would be preempted in favor of T2. + + * The scheduler tracks the vruntime for all tasks, runnable and blocked. The lower a task's vruntime, the more deserving the task is for time on the processor. CFS accordingly moves low-vruntime tasks towards the front of the scheduling line. Details are forthcoming because the line is implemented as a tree, not a list. + + * How often should the CFS scheduler reschedule? There is a simple way to determine the scheduling period. Suppose that the target latency (TL) is 20ms and the minimum granularity (MG) is 4ms: + +`TL / MG = (20 / 4) = 5 ## five or fewer tasks are ok` + +In this case, five or fewer tasks would allow each task a turn on the processor during the target latency. For example, if the task number is five, each runnable task has a 1/N slice of 4ms, which happens to equal the minimum granularity; if the task number is three, each task gets a 1/N slice of almost 7ms. In either case, the scheduler would reschedule in 20ms, the duration of the target latency. + +Trouble occurs if the number of tasks (e.g., 10) exceeds TL / MG because now each task must get the minimum time of 4ms instead of the computed 1/N slice, which is 2ms. In this case, the scheduler would reschedule in 40ms: + +`(number of tasks) core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated MG = (10 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 4) = 40ms ## period = 40ms` + + + + +Linux schedulers that predate CFS use heuristics to promote the fair treatment of interactive tasks with respect to scheduling. CFS takes a quite different approach by letting the vruntime facts speak mostly for themselves, which happens to support sleeper fairness. An interactive task, by its very nature, tends to sleep a lot in the sense that it awaits user inputs and so becomes I/O-bound; hence, such a task tends to have a relatively low vruntime, which tends to move the task towards the front of the scheduling line. + +### Special features + +CFS supports symmetrical multiprocessing (SMP) in which any process (whether kernel or user) can execute on any processor. Yet configurable scheduling domains can be used to group processors for load balancing or even segregation. If several processors share the same scheduling policy, then load balancing among them is an option; if a particular processor has a scheduling policy different from the others, then this processor would be segregated from the others with respect to scheduling. + +Configurable scheduling groups are another CFS feature. As an example, consider the Nginx web server that's running on my desktop machine. At startup, this server has a master process and four worker processes, which act as HTTP request handlers. For any HTTP request, the particular worker that handles the request is irrelevant; it matters only that the request is handled in a timely manner, and so the four workers together provide a pool from which to draw a task-handler as requests come in. It thus seems fair to treat the four Nginx workers as a group rather than as individuals for scheduling purposes, and a scheduling group can be used to do just that. The four Nginx workers could be configured to have a single vruntime among them rather than individual vruntimes. Configuration is done in the traditional Linux way, through files. For vruntime-sharing, a file named **cpu.shares** , with the details given through familiar shell commands, would be created. + +As noted earlier, Linux supports scheduling classes so that different scheduling policies, together with their implementing algorithms, can coexist on the same platform. A scheduling class is implemented as a code module in C. CFS, the scheduling class described so far, is **SCHED_NORMAL**. There are also scheduling classes specifically for real-time tasks, **SCHED_FIFO** (first in, first out) and **SCHED_RR** (round robin). Under **SCHED_FIFO** , tasks run to completion; under **SCHED_RR** , tasks run until they exhaust a fixed timeslice and are preempted. + +### CFS implementation + +CFS requires efficient data structures to track task information and high-performance code to generate the schedules. Let's begin with a central term in scheduling, the runqueue. This is a data structure that represents a timeline for scheduled tasks. Despite the name, the runqueue need not be implemented in the traditional way, as a FIFO list. CFS breaks with tradition by using a time-ordered red-black tree as a runqueue. The data structure is well-suited for the job because it is a self-balancing binary search tree, with efficient **insert** and **remove** operations that execute in **O(log N)** time, where N is the number of nodes in the tree. Also, a tree is an excellent data structure for organizing entities into a hierarchy based on a particular property, in this case a vruntime. + +In CFS, the tree's internal nodes represent tasks to be scheduled, and the tree as a whole, like any runqueue, represents a timeline for task execution. Red-black trees are in wide use beyond scheduling; for example, Java uses this data structure to implement its **TreeMap**. + +Under CFS, every processor has a specific runqueue of tasks, and no task occurs at the same time in more than one runqueue. Each runqueue is a red-black tree. The tree's internal nodes represent tasks or task groups, and these nodes are indexed by their vruntime values so that (in the tree as a whole or in any subtree) the internal nodes to the left have lower vruntime values than the ones to the right: + +``` +    25     ## 25 is a task vruntime +    /\ +  17  29   ## 17 roots the left subtree, 29 the right one +  /\  ... + 5  19     ## and so on +...  \ +     nil   ## leaf nodes are nil +``` + +In summary, tasks with the lowest vruntime—and, therefore, the greatest need for a processor—reside somewhere in the left subtree; tasks with relatively high vruntimes congregate in the right subtree. A preempted task would go into the right subtree, thus giving other tasks a chance to move leftwards in the tree. A task with the smallest vruntime winds up in the tree's leftmost (internal) node, which is thus the front of the runqueue. + +The CFS scheduler has an instance, the C **task_struct** , to track detailed information about each task to be scheduled. This structure embeds a **sched_entity** structure, which in turn has scheduling-specific information, in particular, the vruntime per task or task group: + +``` +struct task_struct {       /bin /boot /dev /etc /home /lib /lib64 /lost+found /media /mnt /opt /proc /root /run /sbin /srv /sys /tmp /usr /var info on a task **/ +  ... +  struct sched_entity se;  /** vruntime, etc. **/ +  ... +}; +``` + +The red-black tree is implemented in familiar C fashion, with a premium on pointers for efficiency. A **cfs_rq** structure instance embeds a **rb_root** field named **tasks_timeline** , which points to the root of a red-black tree. Each of the tree's internal nodes has pointers to the parent and the two child nodes; the leaf nodes have nil as their value. + +CFS illustrates how a straightforward idea—give every task a fair share of processor resources—can be implemented in a low-fuss but highly efficient way. It's worth repeating that CFS achieves fair and efficient scheduling without traditional artifacts such as fixed timeslices and explicit task priorities. The pursuit of even better schedulers goes on, of course; for the moment, however, CFS is as good as it gets for general-purpose processor scheduling. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/fair-scheduling-linux + +作者:[Marty kalin][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/mkalindepauledu +[b]: https://github.com/lujun9972 diff --git a/sources/tech/20190205 Install Apache, MySQL, PHP (LAMP) Stack On Ubuntu 18.04 LTS.md b/sources/tech/20190205 Install Apache, MySQL, PHP (LAMP) Stack On Ubuntu 18.04 LTS.md new file mode 100644 index 0000000000..7ce1201c4f --- /dev/null +++ b/sources/tech/20190205 Install Apache, MySQL, PHP (LAMP) Stack On Ubuntu 18.04 LTS.md @@ -0,0 +1,443 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Install Apache, MySQL, PHP (LAMP) Stack On Ubuntu 18.04 LTS) +[#]: via: (https://www.ostechnix.com/install-apache-mysql-php-lamp-stack-on-ubuntu-18-04-lts/) +[#]: author: (SK https://www.ostechnix.com/author/sk/) + +Install Apache, MySQL, PHP (LAMP) Stack On Ubuntu 18.04 LTS +====== + +![](https://www.ostechnix.com/wp-content/uploads/2019/02/lamp-720x340.jpg) + +**LAMP** stack is a popular, open source web development platform that can be used to run and deploy dynamic websites and web-based applications. Typically, LAMP stack consists of Apache webserver, MariaDB/MySQL databases, PHP/Python/Perl programming languages. LAMP is the acronym of **L** inux, **M** ariaDB/ **M** YSQL, **P** HP/ **P** ython/ **P** erl. This tutorial describes how to install Apache, MySQL, PHP (LAMP stack) in Ubuntu 18.04 LTS server. + +### Install Apache, MySQL, PHP (LAMP) Stack On Ubuntu 18.04 LTS + +For the purpose of this tutorial, we will be using the following Ubuntu testbox. + + * **Operating System** : Ubuntu 18.04.1 LTS Server Edition + * **IP address** : 192.168.225.22/24 + + + +#### 1. Install Apache web server + +First of all, update Ubuntu server using commands: + +``` +$ sudo apt update + +$ sudo apt upgrade +``` + +Next, install Apache web server: + +``` +$ sudo apt install apache2 +``` + +Check if Apache web server is running or not: + +``` +$ sudo systemctl status apache2 +``` + +Sample output would be: + +``` +● apache2.service - The Apache HTTP Server + Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: en + Drop-In: /lib/systemd/system/apache2.service.d + └─apache2-systemd.conf + Active: active (running) since Tue 2019-02-05 10:48:03 UTC; 1min 5s ago + Main PID: 2025 (apache2) + Tasks: 55 (limit: 2320) + CGroup: /system.slice/apache2.service + ├─2025 /usr/sbin/apache2 -k start + ├─2027 /usr/sbin/apache2 -k start + └─2028 /usr/sbin/apache2 -k start + +Feb 05 10:48:02 ubuntuserver systemd[1]: Starting The Apache HTTP Server... +Feb 05 10:48:03 ubuntuserver apachectl[2003]: AH00558: apache2: Could not reliably +Feb 05 10:48:03 ubuntuserver systemd[1]: Started The Apache HTTP Server. +``` + +Congratulations! Apache service is up and running!! + +##### 1.1 Adjust firewall to allow Apache web server + +By default, the apache web browser can’t be accessed from remote systems if you have enabled the UFW firewall in Ubuntu 18.04 LTS. You must allow the http and https ports by following the below steps. + +First, list out the application profiles available on your Ubuntu system using command: + +``` +$ sudo ufw app list +``` + +Sample output: + +``` +Available applications: +Apache +Apache Full +Apache Secure +OpenSSH +``` + +As you can see, Apache and OpenSSH applications have installed UFW profiles. You can list out information about each profile and its included rules using “ **ufw app info “Profile Name”** command. + +Let us look into the **“Apache Full”** profile. To do so, run: + +``` +$ sudo ufw app info "Apache Full" +``` + +Sample output: + +``` +Profile: Apache Full +Title: Web Server (HTTP,HTTPS) +Description: Apache v2 is the next generation of the omnipresent Apache web +server. + +Ports: +80,443/tcp +``` + +As you see, “Apache Full” profile has included the rules to enable traffic to the ports **80** and **443** : + +Now, run the following command to allow incoming HTTP and HTTPS traffic for this profile: + +``` +$ sudo ufw allow in "Apache Full" +Rules updated +Rules updated (v6) +``` + +If you don’t want to allow https traffic, but only http (80) traffic, run: + +``` +$ sudo ufw app info "Apache" +``` + +##### 1.2 Test Apache Web server + +Now, open your web browser and access Apache test page by navigating to **** or ****. + +![](https://www.ostechnix.com/wp-content/uploads/2016/06/apache-2.png) + +If you are see a screen something like above, you are good to go. Apache server is working! + +#### 2. Install MySQL + +To install MySQL On Ubuntu, run: + +``` +$ sudo apt install mysql-server +``` + +Verify if MySQL service is running or not using command: + +``` +$ sudo systemctl status mysql +``` + +**Sample output:** + +``` +● mysql.service - MySQL Community Server +Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enab +Active: active (running) since Tue 2019-02-05 11:07:50 UTC; 17s ago +Main PID: 3423 (mysqld) +Tasks: 27 (limit: 2320) +CGroup: /system.slice/mysql.service +└─3423 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid + +Feb 05 11:07:49 ubuntuserver systemd[1]: Starting MySQL Community Server... +Feb 05 11:07:50 ubuntuserver systemd[1]: Started MySQL Community Server. +``` + +Mysql is running! + +##### 2.1 Setup database administrative user (root) password + +By default, MySQL **root** user password is blank. You need to secure your MySQL server by running the following script: + +``` +$ sudo mysql_secure_installation +``` + +You will be asked whether you want to setup **VALIDATE PASSWORD plugin** or not. This plugin allows the users to configure strong password for database credentials. If enabled, It will automatically check the strength of the password and enforces the users to set only those passwords which are secure enough. **It is safe to leave this plugin disabled**. However, you must use a strong and unique password for database credentials. If don’t want to enable this plugin, just press any key to skip the password validation part and continue the rest of the steps. + +If your answer is **Yes** , you will be asked to choose the level of password validation. + +``` +Securing the MySQL server deployment. + +Connecting to MySQL using a blank password. + +VALIDATE PASSWORD PLUGIN can be used to test passwords +and improve security. It checks the strength of password +and allows the users to set only those passwords which are +secure enough. Would you like to setup VALIDATE PASSWORD plugin? + +Press y|Y for Yes, any other key for No y +``` + +The available password validations are **low** , **medium** and **strong**. Just enter the appropriate number (0 for low, 1 for medium and 2 for strong password) and hit ENTER key. + +``` +There are three levels of password validation policy: + +LOW Length >= 8 +MEDIUM Length >= 8, numeric, mixed case, and special characters +STRONG Length >= 8, numeric, mixed case, special characters and dictionary file + +Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: +``` + +Now, enter the password for MySQL root user. Please be mindful that you must use password for mysql root user depending upon the password policy you choose in the previous step. If you didn’t enable the plugin, just use any strong and unique password of your choice. + +``` +Please set the password for root here. + +New password: + +Re-enter new password: + +Estimated strength of the password: 50 +Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y +``` + +Once you entered the password twice, you will see the password strength (In our case it is **50** ). If it is OK for you, press Y to continue with the provided password. If not satisfied with password length, press any other key and set a strong password. I am OK with my current password, so I chose **y**. + +For the rest of questions, just type **y** and hit ENTER. This will remove anonymous user, disallow root user login remotely and remove test database. + +``` +Remove anonymous users? (Press y|Y for Yes, any other key for No) : y +Success. + +Normally, root should only be allowed to connect from +'localhost'. This ensures that someone cannot guess at +the root password from the network. + +Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y +Success. + +By default, MySQL comes with a database named 'test' that +anyone can access. This is also intended only for testing, +and should be removed before moving into a production +environment. + +Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y +- Dropping test database... +Success. + +- Removing privileges on test database... +Success. + +Reloading the privilege tables will ensure that all changes +made so far will take effect immediately. + +Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y +Success. + +All done! +``` + +That’s it. Password for MySQL root user has been set. + +##### 2.2 Change authentication method for MySQL root user + +By default, MySQL root user is set to authenticate using the **auth_socket** plugin in MySQL 5.7 and newer versions on Ubuntu. Even though it enhances the security, it will also complicate things when you access your database server using any external programs, for example phpMyAdmin. To fix this issue, you need to change authentication method from **auth_socket** to **mysql_native_password**. To do so, login to your MySQL prompt using command: + +``` +$ sudo mysql +``` + +Run the following command at the mysql prompt to find the current authentication method for all mysql user accounts: + +``` +SELECT user,authentication_string,plugin,host FROM mysql.user; +``` + +**Sample output:** + +``` ++------------------|-------------------------------------------|-----------------------|-----------+ +| user | authentication_string | plugin | host | ++------------------|-------------------------------------------|-----------------------|-----------+ +| root | | auth_socket | localhost | +| mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | +| mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | +| debian-sys-maint | *F126737722832701DD3979741508F05FA71E5BA0 | mysql_native_password | localhost | ++------------------|-------------------------------------------|-----------------------|-----------+ +4 rows in set (0.00 sec) +``` + +![][2] + +As you see, mysql root user uses `auth_socket` plugin for authentication. + +To change this authentication to **mysql_native_password** method, run the following command at mysql prompt. Don’t forget to replace **“password”** with a strong and unique password of your choice. If you have enabled VALIDATION plugin, make sure you have used a strong password based on the current policy requirements. + +``` +ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; +``` + +Update the changes using command: + +``` +FLUSH PRIVILEGES; +``` + +Now check again if the authentication method is changed or not using command: + +``` +SELECT user,authentication_string,plugin,host FROM mysql.user; +``` + +Sample output: + +![][3] + +Good! Now the myql root user can authenticate using password to access mysql shell. + +Exit from the mysql prompt: + +``` +exit +``` + +#### 3\. Install PHP + +To install PHP, run: + +``` +$ sudo apt install php libapache2-mod-php php-mysql +``` + +After installing PHP, create **info.php** file in the Apache root document folder. Usually, the apache root document folder will be **/var/www/html/** or **/var/www/** in most Debian based Linux distributions. In Ubuntu 18.04 LTS, it is **/var/www/html/**. + +Let us create **info.php** file in the apache root folder: + +``` +$ sudo vi /var/www/html/info.php +``` + +Add the following lines: + +``` + +``` + +Press ESC key and type **:wq** to save and quit the file. Restart apache service to take effect the changes. + +``` +$ sudo systemctl restart apache2 +``` + +##### 3.1 Test PHP + +Open up your web browser and navigate to **** URL. + +You will see the php test page now. + +![](https://www.ostechnix.com/wp-content/uploads/2019/02/php-test-page.png) + +Usually, when a user requests a directory from the web server, Apache will first look for a file named **index.html**. If you want to change Apache to serve php files rather than others, move **index.php** to first position in the **dir.conf** file as shown below + +``` +$ sudo vi /etc/apache2/mods-enabled/dir.conf +``` + +Here is the contents of the above file. + +``` + +DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet +``` + +Move the “index.php” file to first. Once you made the changes, your **dir.conf** file will look like below. + +``` + +DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm + + +# vim: syntax=apache ts=4 sw=4 sts=4 sr noet +``` + +Press **ESC** key and type **:wq** to save and close the file. Restart Apache service to take effect the changes. + +``` +$ sudo systemctl restart apache2 +``` + +##### 3.2 Install PHP modules + +To improve the functionality of PHP, you can install some additional PHP modules. + +To list the available PHP modules, run: + +``` +$ sudo apt-cache search php- | less +``` + +**Sample output:** + +![][4] + +Use the arrow keys to go through the result. To exit, type **q** and hit ENTER key. + +To find the details of any particular php module, for example **php-gd** , run: + +``` +$ sudo apt-cache show php-gd +``` + +To install a php module run: + +``` +$ sudo apt install php-gd +``` + +To install all modules (not necessary though), run: + +``` +$ sudo apt-get install php* +``` + +Do not forget to restart Apache service after installing any php module. To check if the module is loaded or not, open info.php file in your browser and check if it is present. + +Next, you might want to install any database management tools to easily manage databases via a web browser. If so, install phpMyAdmin as described in the following link. + +Congratulations! We have successfully setup LAMP stack in Ubuntu 18.04 LTS server. + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/install-apache-mysql-php-lamp-stack-on-ubuntu-18-04-lts/ + +作者:[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]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: http://www.ostechnix.com/wp-content/uploads/2019/02/mysql-1.png +[3]: http://www.ostechnix.com/wp-content/uploads/2019/02/mysql-2.png +[4]: http://www.ostechnix.com/wp-content/uploads/2016/06/php-modules.png diff --git a/sources/tech/20190208 3 Ways to Install Deb Files on Ubuntu Linux.md b/sources/tech/20190208 3 Ways to Install Deb Files on Ubuntu Linux.md new file mode 100644 index 0000000000..3b84d85c62 --- /dev/null +++ b/sources/tech/20190208 3 Ways to Install Deb Files on Ubuntu Linux.md @@ -0,0 +1,185 @@ +[#]: collector: (lujun9972) +[#]: translator: (sndnvaps) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (3 Ways to Install Deb Files on Ubuntu Linux) +[#]: via: (https://itsfoss.com/install-deb-files-ubuntu) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +3 Ways to Install Deb Files on Ubuntu Linux +====== + +**This beginner article explains how to install deb packages in Ubuntu. It also shows you how to remove those deb packages afterwards.** + +This is another article in the Ubuntu beginner series. If you are absolutely new to Ubuntu, you might wonder about [how to install applications][1]. + +The easiest way is to use the Ubuntu Software Center. Search for an application by its name and install it from there. + +Life would be too simple if you could find all the applications in the Software Center. But that does not happen, unfortunately. + +Some software are available via DEB packages. These are archived files that end with .deb extension. + +You can think of .deb files as the .exe files in Windows. You double click on the .exe file and it starts the installation procedure in Windows. DEB packages are pretty much the same. + +You can find these DEB packages from the download section of the software provider’s website. For example, if you want to [install Google Chrome on Ubuntu][2], you can download the DEB package of Chrome from its website. + +Now the question arises, how do you install deb files? There are multiple ways of installing DEB packages in Ubuntu. I’ll show them to you one by one in this tutorial. + +![Install deb files in Ubuntu][3] + +### Installing .deb files in Ubuntu and Debian-based Linux Distributions + +You can choose a GUI tool or a command line tool for installing a deb package. The choice is yours. + +Let’s go on and see how to install deb files. + +#### Method 1: Use the default Software Center + +The simplest method is to use the default software center in Ubuntu. You have to do nothing special here. Simply go to the folder where you have downloaded the .deb file (it should be the Downloads folder) and double click on this file. + +![Google Chrome deb file on Ubuntu][4]Double click on the downloaded .deb file to start installation + +It will open the software center and you should see the option to install the software. All you have to do is to hit the install button and enter your login password. + +![Install Google Chrome in Ubuntu Software Center][5]The installation of deb file will be carried out via Software Center + +See, it’s even simple than installing from a .exe files on Windows, isn’t it? + +#### Method 2: Use Gdebi application for installing deb packages with dependencies + +Again, life would be a lot simpler if things always go smooth. But that’s not life as we know it. + +Now that you know that .deb files can be easily installed via Software Center, let me tell you about the dependency error that you may encounter with some packages. + +What happens is that a program may be dependent on another piece of software (libraries). When the developer is preparing the DEB package for you, he/she may assume that your system already has that piece of software on your system. + +But if that’s not the case and your system doesn’t have those required pieces of software, you’ll encounter the infamous ‘dependency error’. + +The Software Center cannot handle such errors on its own so you have to use another tool called [gdebi][6]. + +gdebi is a lightweight GUI application that has the sole purpose of installing deb packages. + +It identifies the dependencies and tries to install these dependencies along with installing the .deb files. + +![gdebi handling dependency while installing deb package][7]Image Credit: [Xmodulo][8] + +Personally, I prefer gdebi over software center for installing deb files. It is a lightweight application so the installation seems quicker. You can read in detail about [using gDebi and making it the default for installing DEB packages][6]. + +You can install gdebi from the software center or using the command below: + +``` +sudo apt install gdebi +``` + +#### Method 3: Install .deb files in command line using dpkg + +If you want to install deb packages in command lime, you can use either apt command or dpkg command. Apt command actually uses [dpkg command][9] underneath it but apt is more popular and easy to use. + +If you want to use the apt command for deb files, use it like this: + +``` +sudo apt install path_to_deb_file +``` + +If you want to use dpkg command for installing deb packages, here’s how to do it: + +``` +sudo dpkg -i path_to_deb_file +``` + +In both commands, you should replace the path_to_deb_file with the path and name of the deb file you have downloaded. + +![Install deb files using dpkg command in Ubuntu][10]Installing deb files using dpkg command in Ubuntu + +If you get a dependency error while installing the deb packages, you may use the following command to fix the dependency issues: + +``` +sudo apt install -f +``` + +### How to remove deb packages + +Removing a deb package is not a big deal as well. And no, you don’t need the original deb file that you had used for installing the program. + +#### Method 1: Remove deb packages using apt commands + +All you need is the name of the program that you have installed and then you can use apt or dpkg to remove that program. + +``` +sudo apt remove program_name +``` + +Now the question comes, how do you find the exact program name that you need to use in the remove command? The apt command has a solution for that as well. + +You can find the list of all installed files with apt command but manually going through this will be a pain. So you can use the grep command to search for your package. + +For example, I installed AppGrid application in the previous section but if I want to know the exact program name, I can use something like this: + +``` +sudo apt list --installed | grep grid +``` + +This will give me all the packages that have grid in their name and from there, I can get the exact program name. + +``` +apt list --installed | grep grid +WARNING: apt does not have a stable CLI interface. Use with caution in scripts. +appgrid/now 0.298 all [installed,local] +``` + +As you can see, a program called appgrid has been installed. Now you can use this program name with the apt remove command. + +#### Method 2: Remove deb packages using dpkg commands + +You can use dpkg to find the installed program’s name: + +``` +dpkg -l | grep grid +``` + +The output will give all the packages installed that has grid in its name. + +``` +dpkg -l | grep grid + +ii appgrid 0.298 all Discover and install apps for Ubuntu +``` + +ii in the above command output means package has been correctly installed. + +Now that you have the program name, you can use dpkg command to remove it: + +``` +dpkg -r program_name +``` + +**Tip: Updating deb packages** +Some deb packages (like Chrome) provide updates through system updates but for most other programs, you’ll have to remove the existing program and install the newer version. + +I hope this beginner guide helped you to install deb packages on Ubuntu. I added the remove part so that you’ll have better control over the programs you installed. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-deb-files-ubuntu + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/remove-install-software-ubuntu/ +[2]: https://itsfoss.com/install-chrome-ubuntu/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/deb-packages-ubuntu.png?resize=800%2C450&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/install-google-chrome-ubuntu-4.jpeg?resize=800%2C347&ssl=1 +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/install-google-chrome-ubuntu-5.jpeg?resize=800%2C516&ssl=1 +[6]: https://itsfoss.com/gdebi-default-ubuntu-software-center/ +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/gdebi-handling-dependency.jpg?ssl=1 +[8]: http://xmodulo.com +[9]: https://help.ubuntu.com/lts/serverguide/dpkg.html.en +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/install-deb-file-with-dpkg.png?ssl=1 +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/deb-packages-ubuntu.png?fit=800%2C450&ssl=1 diff --git a/sources/tech/20190211 How To Remove-Delete The Empty Lines In A File In Linux.md b/sources/tech/20190211 How To Remove-Delete The Empty Lines In A File In Linux.md new file mode 100644 index 0000000000..b55cbcd811 --- /dev/null +++ b/sources/tech/20190211 How To Remove-Delete The Empty Lines In A File In Linux.md @@ -0,0 +1,192 @@ +[#]: collector: (lujun9972) +[#]: translator: ( pityonline ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Remove/Delete The Empty Lines In A File In Linux) +[#]: via: (https://www.2daygeek.com/remove-delete-empty-lines-in-a-file-in-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +How To Remove/Delete The Empty Lines In A File In Linux +====== + +Some times you may wants to remove or delete the empty lines in a file in Linux. + +If so, you can use the one of the below method to achieve it. + +It can be done in many ways but i have listed simple methods in the article. + +You may aware of that grep, awk and sed commands are specialized for textual data manipulation. + +Navigate to the following URL, if you would like to read more about these kind of topics. For **[creating a file in specific size in Linux][1]** multiple ways, for **[creating a file in Linux][2]** multiple ways and for **[removing a matching string from a file in Linux][3]**. + +These are fall in advanced commands category because these are used in most of the shell script to do required things. + +It can be done using the following 5 methods. + + * **`sed Command:`** Stream editor for filtering and transforming text. + * **`grep Command:`** Print lines that match patterns. + * **`cat Command:`** It concatenate files and print on the standard output. + * **`tr Command:`** Translate or delete characters. + * **`awk Command:`** The awk utility shall execute programs written in the awk programming language, which is specialized for textual data manipulation. + * **`perl Command:`** Perl is a programming language specially designed for text editing. + + + +To test this, i had already created the file called `2daygeek.txt` with some texts and empty lines. The details are below. + +``` +$ cat 2daygeek.txt +2daygeek.com is a best Linux blog to learn Linux. + +It's FIVE years old blog. + +This website is maintained by Magesh M, it's licensed under CC BY-NC 4.0. + +He got two GIRL babys. + +Her names are Tanisha & Renusha. +``` + +Now everything is ready and i’m going to test this in multiple ways. + +### How To Remove/Delete The Empty Lines In A File In Linux Using sed Command? + +Sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). + +``` +$ sed '/^$/d' 2daygeek.txt +2daygeek.com is a best Linux blog to learn Linux. +It's FIVE years old blog. +This website is maintained by Magesh M, it's licensed under CC BY-NC 4.0. +He got two GIRL babes. +Her names are Tanisha & Renusha. +``` + +Details are follow: + + * **`sed:`** It’s a command + * **`//:`** It holds the searching string. + * **`^:`** Matches start of string. + * **`$:`** Matches end of string. + * **`d:`** Delete the matched string. + * **`2daygeek.txt:`** Source file name. + + + +### How To Remove/Delete The Empty Lines In A File In Linux Using grep Command? + +grep searches for PATTERNS in each FILE. PATTERNS is one or patterns separated by newline characters, and grep prints each line that matches a pattern. + +``` +$ grep . 2daygeek.txt +or +$ grep -Ev "^$" 2daygeek.txt +or +$ grep -v -e '^$' 2daygeek.txt +2daygeek.com is a best Linux blog to learn Linux. +It's FIVE years old blog. +This website is maintained by Magesh M, it's licensed under CC BY-NC 4.0. +He got two GIRL babes. +Her names are Tanisha & Renusha. +``` + +Details are follow: + + * **`grep:`** It’s a command + * **`.:`** Replaces any character. + * **`^:`** matches start of string. + * **`$:`** matches end of string. + * **`E:`** For extended regular expressions pattern matching. + * **`e:`** For regular expressions pattern matching. + * **`v:`** To select non-matching lines from the file. + * **`2daygeek.txt:`** Source file name. + + + +### How To Remove/Delete The Empty Lines In A File In Linux Using awk Command? + +The awk utility shall execute programs written in the awk programming language, which is specialized for textual data manipulation. An awk program is a sequence of patterns and corresponding actions. + +``` +$ awk NF 2daygeek.txt +or +$ awk '!/^$/' 2daygeek.txt +or +$ awk '/./' 2daygeek.txt +2daygeek.com is a best Linux blog to learn Linux. +It's FIVE years old blog. +This website is maintained by Magesh M, it's licensed under CC BY-NC 4.0. +He got two GIRL babes. +Her names are Tanisha & Renusha. +``` + +Details are follow: + + * **`awk:`** It’s a command + * **`//:`** It holds the searching string. + * **`^:`** matches start of string. + * **`$:`** matches end of string. + * **`.:`** Replaces any character. + * **`!:`** Delete the matched string. + * **`2daygeek.txt:`** Source file name. + + + +### How To Delete The Empty Lines In A File In Linux using Combination of cat And tr Command? + +cat stands for concatenate. It is very frequently used in Linux to reads data from a file. + +cat is one of the most frequently used commands on Unix-like operating systems. It’s offer three functions which is related to text file such as display content of a file, combine multiple files into the single output and create a new file. + +Translate, squeeze, and/or delete characters from standard input, writing to standard output. + +``` +$ cat 2daygeek.txt | tr -s '\n' +2daygeek.com is a best Linux blog to learn Linux. +It's FIVE years old blog. +This website is maintained by Magesh M, it's licensed under CC BY-NC 4.0. +He got two GIRL babes. +Her names are Tanisha & Renusha. +``` + +Details are follow: + + * **`cat:`** It’s a command + * **`tr:`** It’s a command + * **`|:`** Pipe symbol. It pass first command output as a input to another command. + * **`s:`** Replace each sequence of a repeated character that is listed in the last specified SET. + * **`\n:`** To add a new line. + * **`2daygeek.txt:`** Source file name. + + + +### How To Remove/Delete The Empty Lines In A File In Linux Using perl Command? + +Perl stands in for “Practical Extraction and Reporting Language”. Perl is a programming language specially designed for text editing. It is now widely used for a variety of purposes including Linux system administration, network programming, web development, etc. + +``` +$ perl -ne 'print if /\S/' 2daygeek.txt +2daygeek.com is a best Linux blog to learn Linux. +It's FIVE years old blog. +This website is maintained by Magesh M, it's licensed under CC BY-NC 4.0. +He got two GIRL babes. +Her names are Tanisha & Renusha. +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/remove-delete-empty-lines-in-a-file-in-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[pityonline](https://github.com/pityonline) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/create-a-file-in-specific-certain-size-linux/ +[2]: https://www.2daygeek.com/linux-command-to-create-a-file/ +[3]: https://www.2daygeek.com/empty-a-file-delete-contents-lines-from-a-file-remove-matching-string-from-a-file-remove-empty-blank-lines-from-a-file/ diff --git a/sources/tech/20190211 How does rootless Podman work.md b/sources/tech/20190211 How does rootless Podman work.md new file mode 100644 index 0000000000..a085ae9014 --- /dev/null +++ b/sources/tech/20190211 How does rootless Podman work.md @@ -0,0 +1,107 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How does rootless Podman work?) +[#]: via: (https://opensource.com/article/19/2/how-does-rootless-podman-work) +[#]: author: (Daniel J Walsh https://opensource.com/users/rhatdan) + +How does rootless Podman work? +====== +Learn how Podman takes advantage of user namespaces to run in rootless mode. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82) + +In my [previous article][1] on user namespace and [Podman][2], I discussed how you can use Podman commands to launch different containers with different user namespaces giving you better separation between containers. Podman also takes advantage of user namespaces to be able to run in rootless mode. Basically, when a non-privileged user runs Podman, the tool sets up and joins a user namespace. After Podman becomes root inside of the user namespace, Podman is allowed to mount certain filesystems and set up the container. Note there is no privilege escalation here other then additional UIDs available to the user, explained below. + +### How does Podman create the user namespace? + +#### shadow-utils + +Most current Linux distributions include a version of shadow-utils that uses the **/etc/subuid** and **/etc/subgid** files to determine what UIDs and GIDs are available for a user in a user namespace. + +``` +$ cat /etc/subuid +dwalsh:100000:65536 +test:165536:65536 +$ cat /etc/subgid +dwalsh:100000:65536 +test:165536:65536 +``` + +The useradd program automatically allocates 65536 UIDs for each user added to the system. If you have existing users on a system, you would need to allocate the UIDs yourself. The format of these files is **username:STARTUID:TOTALUIDS**. Meaning in my case, dwalsh is allocated UIDs 100000 through 165535 along with my default UID, which happens to be 3265 defined in /etc/passwd. You need to be careful when allocating these UID ranges that they don't overlap with any **real** UID on the system. If you had a user listed as UID 100001, now I (dwalsh) would be able to become this UID and potentially read/write/execute files owned by the UID. + +Shadow-utils also adds two setuid programs (or setfilecap). On Fedora I have: + +``` +$ getcap /usr/bin/newuidmap +/usr/bin/newuidmap = cap_setuid+ep +$ getcap /usr/bin/newgidmap +/usr/bin/newgidmap = cap_setgid+ep +``` + +Podman executes these files to set up the user namespace. You can see the mappings by examining /proc/self/uid_map and /proc/self/gid_map from inside of the rootless container. + +``` +$ podman run alpine cat /proc/self/uid_map /proc/self/gid_map +        0       3267            1 +        1       100000          65536 +        0       3267            1 +        1       100000          65536 +``` + +As seen above, Podman defaults to mapping root in the container to your current UID (3267) and then maps ranges of allocated UIDs/GIDs in /etc/subuid and /etc/subgid starting at 1. Meaning in my example, UID=1 in the container is UID 100000, UID=2 is UID 100001, all the way up to 65536, which is 165535. + +Any item from outside of the user namespace that is owned by a UID or GID that is not mapped into the user namespace appears to belong to the user configured in the **kernel.overflowuid** sysctl, which by default is 35534, which my /etc/passwd file says has the name **nobody**. Since your process can't run as an ID that isn't mapped, the owner and group permissions don't apply, so you can only access these files based on their "other" permissions. This includes all files owned by **real** root on the system running the container, since root is not mapped into the user namespace. + +The [Buildah][3] command has a cool feature, [**buildah unshare**][4]. This puts you in the same user namespace that Podman runs in, but without entering the container's filesystem, so you can list the contents of your home directory. + +``` +$ ls -ild /home/dwalsh +8193 drwx--x--x. 290 dwalsh dwalsh 20480 Jan 29 07:58 /home/dwalsh +$ buildah unshare ls -ld /home/dwalsh +drwx--x--x. 290 root root 20480 Jan 29 07:58 /home/dwalsh +``` + +Notice that when listing the home dir attributes outside the user namespace, the kernel reports the ownership as dwalsh, while inside the user namespace it reports the directory as owned by root. This is because the home directory is owned by 3267, and inside the user namespace we are treating that UID as root. + +### What happens next in Podman after the user namespace is set up? + +Podman uses [containers/storage][5] to pull the container image, and containers/storage is smart enough to map all files owned by root in the image to the root of the user namespace, and any other files owned by different UIDs to their user namespace UIDs. By default, this content gets written to ~/.local/share/containers/storage. Container storage works in rootless mode with either the vfs mode or with Overlay. Note: Overlay is supported only if the [fuse-overlayfs][6] executable is installed. + +The kernel only allows user namespace root to mount certain types of filesystems; at this time it allows mounting of procfs, sysfs, tmpfs, fusefs, and bind mounts (as long as the source and destination are owned by the user running Podman. OverlayFS is not supported yet, although the kernel teams are working on allowing it). + +Podman then mounts the container's storage if it is using fuse-overlayfs; if the storage driver is using vfs, then no mounting is required. Podman on vfs requires a lot of space though, since each container copies the entire underlying filesystem. + +Podman then mounts /proc and /sys along with a few tmpfs and creates the devices in the container. + +In order to use networking other than the host networking, Podman uses the [slirp4netns][7] program to set up **User mode networking for unprivileged network namespace**. Slirp4netns allows Podman to expose ports within the container to the host. Note that the kernel still will not allow a non-privileged process to bind to ports less than 1024. Podman-1.1 or later is required for binding to ports. + +Rootless Podman can use user namespace for container separation, but you only have access to the UIDs defined in the /etc/subuid file. + +### Conclusion + +The Podman tool is enabling people to build and use containers without sacrificing the security of the system; you can give your developers the access they need without giving them root. + +And when you put your containers into production, you can take advantage of the extra security provided by the user namespace to keep the workloads isolated from each other. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/how-does-rootless-podman-work + +作者:[Daniel J Walsh][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/rhatdan +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/article/18/12/podman-and-user-namespaces +[2]: https://podman.io/ +[3]: https://buildah.io/ +[4]: https://github.com/containers/buildah/blob/master/docs/buildah-unshare.md +[5]: https://github.com/containers/storage +[6]: https://github.com/containers/fuse-overlayfs +[7]: https://github.com/rootless-containers/slirp4netns diff --git a/sources/tech/20190211 What-s the right amount of swap space for a modern Linux system.md b/sources/tech/20190211 What-s the right amount of swap space for a modern Linux system.md new file mode 100644 index 0000000000..c04d47e5ca --- /dev/null +++ b/sources/tech/20190211 What-s the right amount of swap space for a modern Linux system.md @@ -0,0 +1,68 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What's the right amount of swap space for a modern Linux system?) +[#]: via: (https://opensource.com/article/19/2/swap-space-poll) +[#]: author: (David Both https://opensource.com/users/dboth) + +What's the right amount of swap space for a modern Linux system? +====== +Complete our survey and voice your opinion on how much swap space to allocate. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0) + +Swap space is one of those things that everyone seems to have an idea about, and I am no exception. All my sysadmin friends have their opinions, and most distributions make recommendations too. + +Many years ago, the rule of thumb for the amount of swap space that should be allocated was 2X the amount of RAM installed in the computer. Of course that was when a typical computer's RAM was measured in KB or MB. So if a computer had 64KB of RAM, a swap partition of 128KB would be an optimum size. + +This took into account the fact that RAM memory sizes were typically quite small, and allocating more than 2X RAM for swap space did not improve performance. With more than twice RAM for swap, most systems spent more time thrashing than performing useful work. + +RAM memory has become quite inexpensive and many computers now have RAM in the tens of gigabytes. Most of my newer computers have at least 4GB or 8GB of RAM, two have 32GB, and my main workstation has 64GB. When dealing with computers with huge amounts of RAM, the limiting performance factor for swap space is far lower than the 2X multiplier. As a consequence, recommended swap space is considered a function of system memory workload, not system memory. + +Table 1 provides the Fedora Project's recommended size for a swap partition, depending on the amount of RAM in your system and whether you want enough memory for your system to hibernate. To allow for hibernation, you need to edit the swap space in the custom partitioning stage. The "recommended" swap partition size is established automatically during a default installation, but I usually find it's either too large or too small for my needs. + +The [Fedora 28 Installation Guide][1] defines current thinking about swap space allocation. Note that other versions of Fedora and other Linux distributions may differ slightly, but this is the same table Red Hat Enterprise Linux uses for its recommendations. These recommendations have not changed since Fedora 19. + +| Amount of RAM installed in system | Recommended swap space | Recommended swap space with hibernation | +| --------------------------------- | ---------------------- | --------------------------------------- | +| ≤ 2GB | 2X RAM | 3X RAM | +| 2GB – 8GB | = RAM | 2X RAM | +| 8GB – 64GB | 4G to 0.5X RAM | 1.5X RAM | +| >64GB | Minimum 4GB | Hibernation not recommended | + +Table 1: Recommended system swap space in Fedora 28's documentation. + +Table 2 contains my recommendations based on my experiences in multiple environments over the years. +| Amount of RAM installed in system | Recommended swap space | +| --------------------------------- | ---------------------- | +| ≤ 2GB | 2X RAM | +| 2GB – 8GB | = RAM | +| > 8GB | 8GB | + +Table 2: My recommended system swap space. + +It's possible that neither of these tables will work for your environment, but they will give you a place to start. The main consideration is that as the amount of RAM increases, adding more swap space simply leads to thrashing well before the swap space comes close to being filled. If you have too little virtual memory, you should add more RAM, if possible, rather than more swap space. + +In order to test the Fedora (and RHEL) swap space recommendations, I used its recommendation of **0.5*RAM** on my two largest systems (the ones with 32GB and 64GB of RAM). Even when running four or five VMs, multiple documents in LibreOffice, Thunderbird, the Chrome web browser, several terminal emulator sessions, the Xfe file manager, and a number of other background applications, the only time I see any use of swap is during backups I have scheduled for every morning at about 2am. Even then, swap usage is no more than 16MB—yes megabytes. These results are for my system with my loads and do not necessarily apply to your real-world environment. + +I recently had a conversation about swap space with some of the other Community Moderators here at [Opensource.com][2], and Chris Short, one of my friends in that illustrious and talented group, pointed me to an old [article][3] where he recommended using 1GB for swap space. This article was written in 2003, and he told me later that he now recommends zero swap space. + +So, we wondered, what you think? What do you recommend or use on your systems for swap space? + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/swap-space-poll + +作者:[David Both][a] +选题:[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/dboth +[b]: https://github.com/lujun9972 +[1]: https://docs.fedoraproject.org/en-US/fedora/f28/install-guide/ +[2]: http://Opensource.com +[3]: https://chrisshort.net/moving-to-linux-partitioning/ diff --git a/sources/tech/20190212 Top 10 Best Linux Media Server Software.md b/sources/tech/20190212 Top 10 Best Linux Media Server Software.md new file mode 100644 index 0000000000..8fcea6343a --- /dev/null +++ b/sources/tech/20190212 Top 10 Best Linux Media Server Software.md @@ -0,0 +1,229 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Top 10 Best Linux Media Server Software) +[#]: via: (https://itsfoss.com/best-linux-media-server) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Top 10 Best Linux Media Server Software +====== + +Did someone tell you that Linux is just for programmers? That is so wrong! You have got a lot of great tools for [digital artists][1], [writers][2] and musicians. + +We have covered such tools in the past. Today it’s going to be slightly different. Instead of creating new digital content, let’s talk about consuming it. + +You have probably heard of media servers? Basically these software (and sometimes gadgets) allow you to view your local or cloud media (music, videos etc) in an intuitive interface. You can even use it to stream the content to other devices on your network. Sort of your personal Netflix. + +In this article, we will talk about the best media software available for Linux that you can use as a media player or as a media server software – as per your requirements. + +Some of these applications can also be used with Google’s Chromecast and Amazon’s Firestick. + +### Best Media Server Software for Linux + +![Best Media Server Software for Linux][3] + +The mentioned Linux media server software are in no particular order of ranking. + +I have tried to provide installation instructions for Ubuntu and Debian based distributions. It’s not possible to list installation steps for all Linux distributions for all the media servers mentioned here. Please take no offence for that. + +A couple of software in this list are not open source. If that’s the case, I have highlighted it appropriately. + +### 1\. Kodi + +![Kodi Media Server][4] + +Kod is one of the most popular media server software and player. Recently, Kodi 18.0 dropped in with a bunch of improvements that includes the support for Digital Rights Management (DRM) decryption, game emulators, ROMs, voice control, and more. + +It is a completely free and open source software. An active community for discussions and support exists as well. The user interface for Kodi is beautiful. I haven’t had the chance to use it in its early days – but I was amazed to see such a good UI for a Linux application. + +It has got great playback support – so you can add any supported 3rd party media service for the content or manually add the ripped video files to watch. + +#### How to install Kodi + +Type in the following commands in the terminal to install the latest version of Kodi via its [official PPA][5]. + +``` +sudo apt-get install software-properties-common +sudo add-apt-repository ppa:team-xbmc/ppa +sudo apt-get update +sudo apt-get install kodi +``` + +To know more about installing a development build or upgrading Kodi, refer to the [official installation guide][6]. + +### 2\. Plex + +![Plex Media Server][7] + +Plex is yet another impressive media player or could be used as a media server software. It is a great alternative to Kodi for the users who mostly utilize it to create an offline network of their media collection to sync and watch across multiple devices. + +Unlike Kodi, **Plex is not entirely open source**. It does offer a free account in order to use it. In addition, it offers premium pricing plans to unlock more features and have a greater control over your media while also being able to get a detailed insight on who/what/how Plex is being used. + +If you are an audiophile, you would love the integration of Plex with [TIDAL][8] music streaming service. You can also set up Live TV by adding it to your tuner. + +#### How to install Plex + +You can simply download the .deb file available on their official webpage and install it directly (or using [GDebi][9]) + +### 3\. Jellyfin + +![Emby media server][10] + +Yet another open source media server software with a bunch of features. [Jellyfin][11] is actually a fork of Emby media server. It may be one of the best out there available for ‘free’ but the multi-platform support still isn’t there yet. + +You can run it on a browser or utilize Chromecast – however – you will have to wait if you want the Android app or if you want it to support several devices. + +#### How to install Jellyfin + +Jellyfin provides a [detailed documentation][12] on how to install it from the binary packages/image available for Linux, Docker, and more. + +You will also find it easy to install it from the repository via the command line for Debian-based distribution. Check out their [installation guide][13] for more information. + +### 4\. LibreELEC + +![libreELEC][14] + +LibreELEC is an interesting media server software which is based on Kodi v18.0. They have recently released a new version (9.0.0) with a complete overhaul of the core OS support, hardware compatibility and user experience. + +Of course, being based on Kodi, it also has the DRM support. In addition, you can utilize its generic Linux builds or the special ones tailored for Raspberry Pi builds, WeTek devices, and more. + +#### How to install LibreELEC + +You can download the installer from their [official site][15]. For detailed instructions on how to use it, please refer to the [installation guide][16]. + +### 5\. OpenFLIXR Media Server + +![OpenFLIXR Media Server][17] + +Want something similar that compliments Plex media server but also compatible with VirtualBox or VMWare? You got it! + +OpenFLIXR is an automated media server software which integrates with Plex to provide all the features along with the ability to auto download TV shows and movies from Torrents. It even fetches the subtitles automatically giving you a seamless experience when coupled with Plex media software. + +You can also automate your home theater with this installed. In case you do not want to run it on a physical instance, it supports VMware, VirtualBox and Hyper-V as well. The best part is – it is an open source solution and based on Ubuntu Server. + +#### How to install OpenFLIXR + +The best way to do it is by installing VirtualBox – it will be easier. After you do that, just download it from the [official website][18] and import it. + +### 6\. MediaPortal + +![MediaPortal][19] + +MediaPortal is just another open source simple media server software with a decent user interface. It all depends on your personal preference – event though I would recommend Kodi over this. + +You can play DVDs, stream videos on your local network, and listen to music as well. It does not offer a fancy set of features but the ones you will mostly need. + +It gives you the option to choose from two different versions (one that is stable and the second which tries to incorporate new features – could be unstable). + +#### How to install MediaPotal + +Depending on what you want to setup (A TV-server only or a complete server setup), follow the [official setup guide][20] to install it properly. + +### 7\. Gerbera + +![Gerbera Media Center][21] + +A simple implementation for a media server to be able to stream using your local network. It does support transcoding which will convert the media in the format your device supports. + +If you have been following the options for media server form a very long time, then you might identify this as the rebranded (and improved) version of MediaTomb. Even though it is not a popular choice among the Linux users – it is still something usable when all fails or for someone who prefers a straightforward and a basic media server. + +#### How to install Gerbera + +Type in the following commands in the terminal to install it on any Ubuntu-based distro: + +``` +sudo apt install gerbera +``` + +For other Linux distributions, refer to the [documentation][22]. + +### 8\. OSMC (Open Source Media Center) + +![OSMC Open Source Media Center][23] + +It is an elegant-looking media server software originally based on Kodi media center. I was quite impressed with the user interface. It is simple and robust, being a free and open source solution. In a nutshell, all the essential features you would expect in a media server software. + +You can also opt in to purchase OSMC’s flagship device. It will play just about anything up to 4K standards with HD audio. In addition, it supports Raspberry Pi builds and 1st-gen Apple TV. + +#### How to install OSMC + +If your device is compatible, you can just select your operating system and download the device installer from the official [download page][24] and create a bootable image to install. + +### 9\. Universal Media Server + +![][25] + +Yet another simple addition to this list. Universal Media Server does not offer any fancy features but just helps you transcode / stream video and audio without needing much configuration. + +It supports Xbox 360, PS 3, and just about any other [DLNA][26]-capable devices. + +#### How to install Universal Media Center + +You can find all the packages listed on [FossHub][27] but you should follow the [official forum][28] to know more about how to install the package that you downloaded from the website. + +### 10\. Red5 Media Server + +![Red5 Media Server][29]Image Credit: [Red5 Server][30] + +A free and open source media server tailored for enterprise usage. You can use it for live streaming solutions – no matter if it is for entertainment or just video conferencing. + +They also offer paid licensing options for mobiles and high scalability. + +#### How to install Red5 + +Even though it is not the quickest installation method, follow the [installation guide on GitHub][31] to get started with the server without needing to tinker around. + +### Wrapping Up + +Every media server software listed here has its own advantages – you should pick one up and try the one which suits your requirement. + +Did we miss any of your favorite media server software? Let us know about it in the comments below! + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/best-linux-media-server + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/best-linux-graphic-design-software/ +[2]: https://itsfoss.com/open-source-tools-writers/ +[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/best-media-server-linux.png?resize=800%2C450&ssl=1 +[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/kodi-18-media-server.jpg?fit=800%2C450&ssl=1 +[5]: https://itsfoss.com/ppa-guide/ +[6]: https://kodi.wiki/view/HOW-TO:Install_Kodi_for_Linux +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/plex.jpg?fit=800%2C368&ssl=1 +[8]: https://tidal.com/ +[9]: https://itsfoss.com/gdebi-default-ubuntu-software-center/ +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/emby-server.jpg?fit=800%2C373&ssl=1 +[11]: https://jellyfin.github.io/ +[12]: https://jellyfin.readthedocs.io/en/latest/ +[13]: https://jellyfin.readthedocs.io/en/latest/administrator-docs/installing/ +[14]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/libreelec.jpg?resize=800%2C600&ssl=1 +[15]: https://libreelec.tv/downloads_new/ +[16]: https://libreelec.wiki/libreelec_usb-sd_creator +[17]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/openflixr-media-server.jpg?fit=800%2C449&ssl=1 +[18]: http://www.openflixr.com/#Download +[19]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/mediaportal.jpg?ssl=1 +[20]: https://www.team-mediaportal.com/wiki/display/MediaPortal1/Quick+Setup +[21]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/gerbera-server-softwarei.jpg?fit=800%2C583&ssl=1 +[22]: http://docs.gerbera.io/en/latest/install.html +[23]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/osmc-server.jpg?fit=800%2C450&ssl=1 +[24]: https://osmc.tv/download/ +[25]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/universal-media-server.jpg?ssl=1 +[26]: https://en.wikipedia.org/wiki/Digital_Living_Network_Alliance +[27]: https://www.fosshub.com/Universal-Media-Server.html?dwl=UMS-7.8.0.tgz +[28]: https://www.universalmediaserver.com/forum/viewtopic.php?t=10275 +[29]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/red5.jpg?resize=800%2C364&ssl=1 +[30]: https://www.red5server.com/ +[31]: https://github.com/Red5/red5-server/wiki/Installation-on-Linux +[32]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/best-media-server-linux.png?fit=800%2C450&ssl=1 diff --git a/sources/tech/20190213 How To Install, Configure And Use Fish Shell In Linux.md b/sources/tech/20190213 How To Install, Configure And Use Fish Shell In Linux.md new file mode 100644 index 0000000000..a03335c6b6 --- /dev/null +++ b/sources/tech/20190213 How To Install, Configure And Use Fish Shell In Linux.md @@ -0,0 +1,264 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Install, Configure And Use Fish Shell In Linux?) +[#]: via: (https://www.2daygeek.com/linux-fish-shell-friendly-interactive-shell/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +How To Install, Configure And Use Fish Shell In Linux? +====== + +Every Linux administrator might heard the word called shell. + +Do you know what is shell? Do you know what is the role for shell in Linux? How many shell is available in Linux? + +A shell is a program that provides an interface between a user and kernel. + +kernel is a heart of the Linux operating system that manage everything between user and operating system (OS). + +Shell is available for all the users when they launch the terminal. + +Once the terminal launched then user can run any commands which is available for him. + +When shell completes the command execution then you will be getting the output on the terminal window. + +Bash stands for Bourne Again Shell is the default shell which is running on most of the Linux distribution on today’s. + +It’s very popular and has a lot of features. Today we are going to discuss about the fish shell. + +### What Is Fish Shell? + +[Fish][1] stands for friendly interactive shell, is a fully-equipped, smart and user-friendly command line shell for Linux which comes with some handy features that is not available in most of the shell. + +The features are Autosuggestion, Sane Scripting, Man Page Completions, Web Based configuration and Glorious VGA Color. Are you curious to test it? if so, go ahead and install it by following the below installation steps. + +### How To Install Fish Shell In Linux? + +It’s very simple to install but it doesn’t available in most of the distributions except few. However, it can be easily installed by using the following [fish repository][2]. + +For **`Arch Linux`** based systems, use **[Pacman Command][3]** to install fish shell. + +``` +$ sudo pacman -S fish +``` + +For **`Ubuntu 16.04/18.04`** systems, use **[APT-GET Command][4]** or **[APT Command][5]** to install fish shell. + +``` +$ sudo apt-add-repository ppa:fish-shell/release-3 +$ sudo apt-get update +$ sudo apt-get install fish +``` + +For **`Fedora`** system, use **[DNF Command][6]** to install fish shell. + +For Fedora 29 System: + +``` +$ sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_29/shells:fish:release:3.repo +$ sudo dnf install fish +``` + +For Fedora 28 System: + +``` +$ sudo dnf config-manager --add-repo https://download.opensuse.org/repositories/shells:/fish:/release:/3/Fedora_28/shells:fish:release:3.repo +$ sudo dnf install fish +``` + +For **`Debian`** systems, use **[APT-GET Command][4]** or **[APT Command][5]** to install fish shell. + +For Debian 9 System: + +``` +$ sudo wget -nv https://download.opensuse.org/repositories/shells:fish:release:3/Debian_9.0/Release.key -O Release.key +$ sudo apt-key add - < Release.key +$ sudo echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_9.0/ /' > /etc/apt/sources.list.d/shells:fish:release:3.list +$ sudo apt-get update +$ sudo apt-get install fish +``` + +For Debian 8 System: + +``` +$ sudo wget -nv https://download.opensuse.org/repositories/shells:fish:release:3/Debian_8.0/Release.key -O Release.key +$ sudo apt-key add - < Release.key +$ sudo echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/3/Debian_8.0/ /' > /etc/apt/sources.list.d/shells:fish:release:3.list +$ sudo apt-get update +$ sudo apt-get install fish +``` + +For **`RHEL/CentOS`** systems, use **[YUM Command][7]** to install fish shell. + +For RHEL 7 System: + +``` +$ sudo yum-config-manager --add-repo https://download.opensuse.org/repositories/shells:/fish:/release:/3/RHEL_7/shells:fish:release:3.repo +$ sudo yum install fish +``` + +For RHEL 6 System: + +``` +$ sudo yum-config-manager --add-repo https://download.opensuse.org/repositories/shells:/fish:/release:/3/RedHat_RHEL-6/shells:fish:release:3.repo +$ sudo yum install fish +``` + +For CentOS 7 System: + +``` +$ sudo yum-config-manager --add-repo https://download.opensuse.org/repositories/shells:fish:release:2/CentOS_7/shells:fish:release:2.repo +$ sudo yum install fish +``` + +For CentOS 6 System: + +``` +$ sudo yum-config-manager --add-repo https://download.opensuse.org/repositories/shells:fish:release:2/CentOS_6/shells:fish:release:2.repo +$ sudo yum install fish +``` + +For **`openSUSE Leap`** system, use **[Zypper Command][8]** to install fish shell. + +``` +$ sudo zypper addrepo https://download.opensuse.org/repositories/shells:/fish:/release:/3/openSUSE_Leap_42.3/shells:fish:release:3.repo +$ suod zypper refresh +$ sudo zypper install fish +``` + +### How To Use Fish Shell? + +Once you have successfully installed the fish shell. Simply type `fish` on your terminal, which will automatically switch to the fish shell from your default bash shell. + +``` +$ fish +``` + +![][10] + +### Auto Suggestions + +When you type any commands in the fish shell, it will auto suggest a command in a light grey color after typing few letters. +![][11] + +Once you got a suggestion then simple hit the `Left Arrow Mark` to complete it instead of typing the full command. +![][12] + +Instantly you can access the previous history based on the command by pressing `Up Arrow Mark` after typing a few letters. It’s similar to bash shell `CTRL+r` option. + +### Tab Completions + +If you would like to see if there are any other possibilities for the given command then simple press the `Tab` button once after typing a few letters. +![][13] + +Press the `Tab` button one more time to see the full lists. +![][14] + +### Syntax highlighting + +fish performs syntax highlighting, that you can see when you are typing any commands in the terminal. Invalid commands are colored by `RED color`. +![][15] + +The same way valid commands are shown in a different color. Also, fish will underline valid file paths when you type and it doesn’t show the underline if the path is not valid. +![][16] + +### Web based configuration + +There is a cool feature is available in the fish shell, that allow us to set colors, prompt, functions, variables, history and bindings via web browser. + +Run the following command on your terminal to start the web configuration interface. Simply press `Ctrl+c` to exit it. + +``` +$ fish_config +Web config started at 'file:///home/daygeek/.cache/fish/web_config-86ZF5P.html'. Hit enter to stop. +qt5ct: using qt5ct plugin +^C +Shutting down. +``` + +![][17] + +### Man Page Completions + +Other shells support programmable completions, but only fish generates them automatically by parsing your installed man pages. + +To do so, run the below command. + +``` +$ fish_update_completions +Parsing man pages and writing completions to /home/daygeek/.local/share/fish/generated_completions/ + 3466 / 3466 : zramctl.8.gz +``` + +### How To Set Fish as default shell + +If you would like to test the fish shell for some times then you can set the fish shell as your default shell instead of switching it every time. + +If so, first get the fish shell location by using the below command. + +``` +$ whereis fish +fish: /usr/bin/fish /etc/fish /usr/share/fish /usr/share/man/man1/fish.1.gz +``` + +Change your default shell as a fish shell by running the following command. + +``` +$ chsh -s /usr/bin/fish +``` + +![][18] + +`Make note:` Just verify whether the fish shell is added into `/etc/shells` directory or not. If no, then run the following command to append it. + +``` +$ echo /usr/bin/fish | sudo tee -a /etc/shells +``` + +Once you have done the testing and if you would like to come back to the bash shell permanently then use the following command. + +For temporary: + +``` +$ bash +``` + +For permanent: + +``` +$ chsh -s /bin/bash +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/linux-fish-shell-friendly-interactive-shell/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://fishshell.com/ +[2]: https://download.opensuse.org/repositories/shells:/fish:/release:/ +[3]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ +[4]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[5]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[6]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[7]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[8]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ +[9]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[10]: https://www.2daygeek.com/wp-content/uploads/2019/02/linux-fish-shell-friendly-interactive-shell-1.png +[11]: https://www.2daygeek.com/wp-content/uploads/2019/02/linux-fish-shell-friendly-interactive-shell-2.png +[12]: https://www.2daygeek.com/wp-content/uploads/2019/02/linux-fish-shell-friendly-interactive-shell-5.png +[13]: https://www.2daygeek.com/wp-content/uploads/2019/02/linux-fish-shell-friendly-interactive-shell-3.png +[14]: https://www.2daygeek.com/wp-content/uploads/2019/02/linux-fish-shell-friendly-interactive-shell-4.png +[15]: https://www.2daygeek.com/wp-content/uploads/2019/02/linux-fish-shell-friendly-interactive-shell-6.png +[16]: https://www.2daygeek.com/wp-content/uploads/2019/02/linux-fish-shell-friendly-interactive-shell-8.png +[17]: https://www.2daygeek.com/wp-content/uploads/2019/02/linux-fish-shell-friendly-interactive-shell-9.png +[18]: https://www.2daygeek.com/wp-content/uploads/2019/02/linux-fish-shell-friendly-interactive-shell-7.png diff --git a/sources/tech/20190213 How to build a WiFi picture frame with a Raspberry Pi.md b/sources/tech/20190213 How to build a WiFi picture frame with a Raspberry Pi.md new file mode 100644 index 0000000000..615f7620ed --- /dev/null +++ b/sources/tech/20190213 How to build a WiFi picture frame with a Raspberry Pi.md @@ -0,0 +1,135 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to build a WiFi picture frame with a Raspberry Pi) +[#]: via: (https://opensource.com/article/19/2/wifi-picture-frame-raspberry-pi) +[#]: author: (Manuel Dewald https://opensource.com/users/ntlx) + +How to build a WiFi picture frame with a Raspberry Pi +====== +DIY a digital photo frame that streams photos from the cloud. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberrypi_board_vector_red.png?itok=yaqYjYqI) + +Digital picture frames are really nice because they let you enjoy your photos without having to print them out. Plus, adding and removing digital files is a lot easier than opening a traditional frame and swapping the picture inside when you want to display a new photo. Even so, it's still a bit of overhead to remove your SD card, USB stick, or other storage from a digital picture frame, plug it into your computer, and copy new pictures onto it. + +An easier option is a digital picture frame that gets its pictures over WiFi, for example from a cloud service. Here's how to make one. + +### Gather your materials + + * Old [TFT][1] LCD screen + * HDMI-to-DVI cable (as the TFT screen supports DVI) + * Raspberry Pi 3 + * Micro SD card + * Raspberry Pi power supply + * Keyboard + * Mouse (optional) + + + +Connect the Raspberry Pi to the display using the cable and attach the power supply. + +### Install Raspbian + +**sudo raspi-config**. There I change the hostname (e.g., to **picframe** ) in Network Options and enable SSH to work remotely on the Raspberry Pi in Interfacing Options. Connect to the Raspberry Pi using (for example) . + +### Build and install the cloud client + +Download and flash Raspbian to the Micro SD card by following these [directions][2] . Plug the Micro SD card into the Raspberry Pi, boot it up, and configure your WiFi. My first action after a new Raspbian installation is usually running. There I change the hostname (e.g., to) in Network Options and enable SSH to work remotely on the Raspberry Pi in Interfacing Options. Connect to the Raspberry Pi using (for example) + +I use [Nextcloud][3] to synchronize my pictures, but you could use NFS, [Dropbox][4], or whatever else fits your needs to upload pictures to the frame. + +If you use Nextcloud, get a client for Raspbian by following these [instructions][5]. This is handy for placing new pictures on your picture frame and will give you the client application you may be familiar with on a desktop PC. When connecting the client application to your Nextcloud server, make sure to select only the folder where you'll store the images you want to be displayed on the picture frame. + +### Set up the slideshow + +The easiest way I've found to set up the slideshow is with a [lightweight slideshow project][6] built for exactly this purpose. There are some alternatives, like configuring a screensaver, but this application appears to be the simplest to set up. + +On your Raspberry Pi, download the binaries from the latest release, unpack them, and move them to an executable folder: + +``` +wget https://github.com/NautiluX/slide/releases/download/v0.9.0/slide_pi_stretch_0.9.0.tar.gz +tar xf slide_pi_stretch_0.9.0.tar.gz +mv slide_0.9.0/slide /usr/local/bin/ +``` + +Install the dependencies: + +``` +sudo apt install libexif12 qt5-default +``` + +Run the slideshow by executing the command below (don't forget to modify the path to your images). If you access your Raspberry Pi via SSH, set the **DISPLAY** variable to start the slideshow on the display attached to the Raspberry Pi. + +``` +DISPLAY=:0.0 slide -p /home/pi/nextcloud/picframe +``` + +### Autostart the slideshow + +To autostart the slideshow on Raspbian Stretch, create the following folder and add an **autostart** file to it: + +``` +mkdir -p /home/pi/.config/lxsession/LXDE/ +vi /home/pi/.config/lxsession/LXDE/autostart +``` + +Insert the following commands to autostart your slideshow. The **slide** command can be adjusted to your needs: + +``` +@xset s noblank +@xset s off +@xset -dpms +@slide -p -t 60 -o 200 -p /home/pi/nextcloud/picframe +``` + +Disable screen blanking, which the Raspberry Pi normally does after 10 minutes, by editing the following file: + +``` +vi /etc/lightdm/lightdm.conf +``` + +and adding these two lines to the end: + +``` +[SeatDefaults] +xserver-command=X -s 0 -dpms +``` + +### Configure a power-on schedule + +You can schedule your picture frame to turn on and off at specific times by using two simple cronjobs. For example, say you want it to turn on automatically at 7 am and turn off at 11 pm. Run **crontab -e** and insert the following two lines. + +``` +0 23 * * * /opt/vc/bin/tvservice -o + +0 7 * * * /opt/vc/bin/tvservice -p && sudo systemctl restart display-manager +``` + +Note that this won't turn the Raspberry Pi power's on and off; it will just turn off HDMI, which will turn the screen off. The first line will power off HDMI at 11 pm. The second line will bring the display back up and restart the display manager at 7 am. + +### Add a final touch + +By following these simple steps, you can create your own WiFi picture frame. If you want to give it a nicer look, build a wooden frame for the display. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/wifi-picture-frame-raspberry-pi + +作者:[Manuel Dewald][a] +选题:[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/ntlx +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Thin-film-transistor_liquid-crystal_display +[2]: https://www.raspberrypi.org/documentation/installation/installing-images/README.md +[3]: https://nextcloud.com/ +[4]: http://dropbox.com/ +[5]: https://github.com/nextcloud/client_theming#building-on-debian +[6]: https://github.com/NautiluX/slide/releases/tag/v0.9.0 diff --git a/sources/tech/20190214 Run Particular Commands Without Sudo Password In Linux.md b/sources/tech/20190214 Run Particular Commands Without Sudo Password In Linux.md new file mode 100644 index 0000000000..df5bfddb3a --- /dev/null +++ b/sources/tech/20190214 Run Particular Commands Without Sudo Password In Linux.md @@ -0,0 +1,157 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Run Particular Commands Without Sudo Password In Linux) +[#]: via: (https://www.ostechnix.com/run-particular-commands-without-sudo-password-linux/) +[#]: author: (SK https://www.ostechnix.com/author/sk/) + +Run Particular Commands Without Sudo Password In Linux +====== + +I had a script on my Ubuntu system deployed on AWS. The primary purpose of this script is to check if a specific service is running at regular interval (every one minute to be precise) and start that service automatically if it is stopped for any reason. But the problem is I need sudo privileges to start the service. As you may know already, we should provide password when we run something as sudo user. But I don’t want to do that. What I actually want to do is to run the service as sudo without password. If you’re ever in a situation like this, I know a small work around, Today, in this brief guide, I will teach you how to run particular commands without sudo password in Unix-like operating systems. + +Have a look at the following example. + +``` +$ sudo mkdir /ostechnix +[sudo] password for sk: +``` + +![][2] + +As you can see in the above screenshot, I need to provide sudo password when creating a directory named ostechnix in root (/) folder. Whenever we try to execute a command with sudo privileges, we must enter the password. However, in my scenario, I don’t want to provide the sudo password. Here is what I did to run a sudo command without password on my Linux box. + +### Run Particular Commands Without Sudo Password In Linux + +For any reasons, if you want to allow a user to run a particular command without giving the sudo password, you need to add that command in **sudoers** file. + +I want the user named **sk** to execute **mkdir** command without giving the sudo password. Let us see how to do it. + +Edit sudoers file: + +``` +$ sudo visudo +``` + +Add the following line at the end of file. + +``` +sk ALL=NOPASSWD:/bin/mkdir +``` + +![][3] + +Here, **sk** is the username. As per the above line, the user **sk** can run ‘mkdir’ command from any terminal, without sudo password. + +You can add additional commands (for example **chmod** ) with comma-separated values as shown below. + +``` +sk ALL=NOPASSWD:/bin/mkdir,/bin/chmod +``` + +Save and close the file. Log out (or reboot) your system. Now, log in as normal user ‘sk’ and try to run those commands with sudo and see what happens. + +``` +$ sudo mkdir /dir1 +``` + +![][4] + +See? Even though I ran ‘mkdir’ command with sudo privileges, there was no password prompt. From now on, the user **sk** need not to enter the sudo password while running ‘mkdir’ command. + +When running all other commands except those commands added in sudoers files, you will be prompted to enter the sudo password. + +Let us run another command with sudo. + +``` +$ sudo apt update +``` + +![][5] + +See? This command prompts me to enter the sudo password. + +If you don’t want this command to prompt you to ask sudo password, edit sudoers file: + +``` +$ sudo visudo +``` + +Add the ‘apt’ command in visudo file like below: + +``` +sk ALL=NOPASSWD: /bin/mkdir,/usr/bin/apt +``` + +Did you notice that the apt binary executable file path is different from mkdir? Yes, you must provide the correct executable file path. To find executable file path of any command, for example ‘apt’, use ‘whereis’ command like below. + +``` +$ whereis apt +apt: /usr/bin/apt /usr/lib/apt /etc/apt /usr/share/man/man8/apt.8.gz +``` + +As you see, the executable file for apt command is **/usr/bin/apt** , hence I added it in sudoers file. + +Like I already mentioned, you can add any number of commands with comma-separated values. Save and close your sudoers file once you’re done. Log out and log in again to your system. + +Now, check if you can be able to run the command with sudo prefix without using the password: + +``` +$ sudo apt update +``` + +![][6] + +See? The apt command didn’t ask me the password even though I ran it with sudo. + +Here is yet another example. If you want to run a specific service, for example apache2, add it as shown below. + +``` +sk ALL=NOPASSWD:/bin/mkdir,/usr/bin/apt,/bin systemctl restart apache2 +``` + +Now, the user can run ‘sudo systemctl restart apache2’ command without sudo password. + +Can I re-authenticate to a particular command in the above case? Of course, yes! Just remove the added command. Log out and log in back. + +Alternatively, you can add **‘PASSWD:’** directive in-front of the command. Look at the following example. + +Add/modify the following line as shown below. + +``` +sk ALL=NOPASSWD:/bin/mkdir,/bin/chmod,PASSWD:/usr/bin/apt +``` + +In this case, the user **sk** can run ‘mkdir’ and ‘chmod’ commands without entering the sudo password. However, he must provide sudo password when running ‘apt’ command. + +**Disclaimer:** This is for educational-purpose only. You should be very careful while applying this method. This method might be both productive and destructive. Say for example, if you allow users to execute ‘rm’ command without sudo password, they could accidentally or intentionally delete important stuffs. You have been warned! + +**Suggested read:** + +And, that’s all for now. Hope this was useful. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/run-particular-commands-without-sudo-password-linux/ + +作者:[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]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[2]: http://www.ostechnix.com/wp-content/uploads/2017/05/sudo-password-1.png +[3]: http://www.ostechnix.com/wp-content/uploads/2017/05/sudo-password-7.png +[4]: http://www.ostechnix.com/wp-content/uploads/2017/05/sudo-password-6.png +[5]: http://www.ostechnix.com/wp-content/uploads/2017/05/sudo-password-4.png +[6]: http://www.ostechnix.com/wp-content/uploads/2017/05/sudo-password-5.png diff --git a/sources/tech/20190215 4 Methods To Change The HostName In Linux.md b/sources/tech/20190215 4 Methods To Change The HostName In Linux.md new file mode 100644 index 0000000000..ad95e05fae --- /dev/null +++ b/sources/tech/20190215 4 Methods To Change The HostName In Linux.md @@ -0,0 +1,227 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (4 Methods To Change The HostName In Linux) +[#]: via: (https://www.2daygeek.com/four-methods-to-change-the-hostname-in-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +4 Methods To Change The HostName In Linux +====== + +We had written an article yesterday in our website about **[changing hostname in Linux][1]**. + +Today we are going to show you that how to change the hostname using different methods. You can choose the best one for you. + +systemd systems comes with a handy tool called `hostnamectl` that allow us to manage the system hostname easily. + +It’s changing the hostname instantly and doesn’t required reboot when you use the native commands. + +But if you modify the hostname manually in any of the configuration file that requires reboot. + +In this article we will show you the four methods to change the hostname in systemd system. + +hostnamectl command allows to set three kind of hostname in Linux and the details are below. + + * **`Static:`** It’s static hostname which is added by the system admin. + * **`Transient/Dynamic:`** It’s assigned by DHCP or DNS server at run time. + * **`Pretty:`** It can be assigned by the system admin. It is a free-form of the hostname that represent the server in the pretty way like, “JBOSS UAT Server”. + + + +It can be done in the following four methods. + + * **`hostnamectl Command:`** hostnamectl command is controling the system hostname. + * **`nmcli Command:`** nmcli is a command-line tool for controlling NetworkManager. + * **`nmtui Command:`** nmtui is a text User Interface for controlling NetworkManager. + * **`/etc/hostname file:`** This file is containing the static system hostname. + + + +### Method-1: Change The HostName Using hostnamectl Command in Linux + +hostnamectl may be used to query and change the system hostname and related settings. + +Simple run the `hostnamectl` command to view the system hostname. + +``` +$ hostnamectl +or +$ hostnamectl status + + Static hostname: daygeek-Y700 + Icon name: computer-laptop + Chassis: laptop + Machine ID: 31bdeb7b83230a2025d43547368d75bc + Boot ID: 267f264c448f000ea5aed47263c6de7f + Operating System: Manjaro Linux + Kernel: Linux 4.19.20-1-MANJARO + Architecture: x86-64 +``` + +If you would like to change the hostname, use the following command format. + +**The general syntax:** + +``` +$ hostnamectl set-hostname [YOUR NEW HOSTNAME] +``` + +Use the following command to change the hostname using hostnamectl command. In this example, i’m going to change the hostname from `daygeek-Y700` to `magi-laptop`. + +``` +$ hostnamectl set-hostname magi-laptop +``` + +You can view the updated hostname by running the following command. + +``` +$ hostnamectl + Static hostname: magi-laptop + Icon name: computer-laptop + Chassis: laptop + Machine ID: 31bdeb7b83230a2025d43547368d75bc + Boot ID: 267f264c448f000ea5aed47263c6de7f + Operating System: Manjaro Linux + Kernel: Linux 4.19.20-1-MANJARO + Architecture: x86-64 +``` + +### Method-2: Change The HostName Using nmcli Command in Linux + +nmcli is a command-line tool for controlling NetworkManager and reporting network status. + +nmcli is used to create, display, edit, delete, activate, and deactivate network connections, as well as control and display network device status. Also, it allow us to change the hostname. + +Use the following format to view the current hostname using nmcli. + +``` +$ nmcli general hostname +daygeek-Y700 +``` + +**The general syntax:** + +``` +$ nmcli general hostname [YOUR NEW HOSTNAME] +``` + +Use the following command to change the hostname using nmcli command. In this example, i’m going to change the hostname from `daygeek-Y700` to `magi-laptop`. + +``` +$ nmcli general hostname magi-laptop +``` + +It’s taking effect without bouncing the below service. However, for safety purpose just restart the systemd-hostnamed service for the changes to take effect. + +``` +$ sudo systemctl restart systemd-hostnamed +``` + +Again run the same nmcli command to check the changed hostname. + +``` +$ nmcli general hostname +magi-laptop +``` + +### Method-3: Change The HostName Using nmtui Command in Linux + +nmtui is a curses‐based TUI application for interacting with NetworkManager. When starting nmtui, the user is prompted to choose the activity to perform unless it was specified as the first argument. + +Run the following command on terminal to launch the terminal user interface. + +``` +$ nmtui +``` + +Use the `Down Arrow Mark` to choose the `Set system hostname` option then hit the `Enter` button. +![][3] + +This is old hostname screenshot. +![][4] + +Just remove the olde one and update the new one then hit `OK` button. +![][5] + +It will show you the updated hostname in the screen and simple hit `OK` button to complete it. +![][6] + +Finally hit the `Quit` button to exit from the nmtui terminal. +![][7] + +It’s taking effect without bouncing the below service. However, for safety purpose just restart the systemd-hostnamed service for the changes to take effect. + +``` +$ sudo systemctl restart systemd-hostnamed +``` + +You can view the updated hostname by running the following command. + +``` +$ hostnamectl + Static hostname: daygeek-Y700 + Icon name: computer-laptop + Chassis: laptop + Machine ID: 31bdeb7b83230a2025d43547368d75bc + Boot ID: 267f264c448f000ea5aed47263c6de7f + Operating System: Manjaro Linux + Kernel: Linux 4.19.20-1-MANJARO + Architecture: x86-64 +``` + +### Method-4: Change The HostName Using /etc/hostname File in Linux + +Alternatively, we can change the hostname by modifying the `/etc/hostname` file. But this method +requires server reboot for changes to take effect. + +Check the current hostname using /etc/hostname file. + +``` +$ cat /etc/hostname +daygeek-Y700 +``` + +To change the hostname, simple overwrite the file because it’s contains only the hostname alone. + +``` +$ sudo echo "magi-daygeek" > /etc/hostname + +$ cat /etc/hostname +magi-daygeek +``` + +Reboot the system by running the following command. + +``` +$ sudo init 6 +``` + +Finally verify the updated hostname using /etc/hostname file. + +``` +$ cat /etc/hostname +magi-daygeek +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/four-methods-to-change-the-hostname-in-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/linux-change-set-hostname/ +[2]: data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7 +[3]: https://www.2daygeek.com/wp-content/uploads/2019/02/four-methods-to-change-the-hostname-in-linux-1.png +[4]: https://www.2daygeek.com/wp-content/uploads/2019/02/four-methods-to-change-the-hostname-in-linux-2.png +[5]: https://www.2daygeek.com/wp-content/uploads/2019/02/four-methods-to-change-the-hostname-in-linux-3.png +[6]: https://www.2daygeek.com/wp-content/uploads/2019/02/four-methods-to-change-the-hostname-in-linux-4.png +[7]: https://www.2daygeek.com/wp-content/uploads/2019/02/four-methods-to-change-the-hostname-in-linux-5.png diff --git a/sources/tech/20190215 Make websites more readable with a shell script.md b/sources/tech/20190215 Make websites more readable with a shell script.md new file mode 100644 index 0000000000..06b748cfb5 --- /dev/null +++ b/sources/tech/20190215 Make websites more readable with a shell script.md @@ -0,0 +1,258 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Make websites more readable with a shell script) +[#]: via: (https://opensource.com/article/19/2/make-websites-more-readable-shell-script) +[#]: author: (Jim Hall https://opensource.com/users/jim-hall) + +Make websites more readable with a shell script +====== +Calculate the contrast ratio between your website's text and background to make sure your site is easy to read. + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/talk_chat_team_mobile_desktop.png?itok=d7sRtKfQ) + +If you want people to find your website useful, they need to be able to read it. The colors you choose for your text can affect the readability of your site. Unfortunately, a popular trend in web design is to use low-contrast colors when printing text, such as gray text on a white background. Maybe that looks really cool to the web designer, but it is really hard for many of us to read. + +The W3C provides Web Content Accessibility Guidelines, which includes guidance to help web designers pick text and background colors that can be easily distinguished from each other. This is called the "contrast ratio." The W3C definition of the contrast ratio requires several calculations: given two colors, you first compute the relative luminance of each, then calculate the contrast ratio. The ratio will fall in the range 1 to 21 (typically written 1:1 to 21:1). The higher the contrast ratio, the more the text will stand out against the background. For example, black text on a white background is highly visible and has a contrast ratio of 21:1. And white text on a white background is unreadable at a contrast ratio of 1:1. + +The [W3C says body text][1] should have a contrast ratio of at least 4.5:1 with headings at least 3:1. But that seems to be the bare minimum. The W3C also recommends at least 7:1 for body text and at least 4.5:1 for headings. + +Calculating the contrast ratio can be a chore, so it's best to automate it. I've done that with this handy Bash script. In general, the script does these things: + + 1. Gets the text color and background color + 2. Computes the relative luminance of each + 3. Calculates the contrast ratio + + + +### Get the colors + +You may know that every color on your monitor can be represented by red, green, and blue (R, G, and B). To calculate the relative luminance of a color, my script will need to know the red, green, and blue components of the color. Ideally, my script would read this information as separate R, G, and B values. Web designers might know the specific RGB code for their favorite colors, but most humans don't know RGB values for the different colors. Instead, most people reference colors by names like "red" or "gold" or "maroon." + +Fortunately, the GNOME [Zenity][2] tool has a color-picker app that lets you use different methods to select a color, then returns the RGB values in a predictable format of "rgb( **R** , **G** , **B** )". Using Zenity makes it easy to get a color value: + +``` +color=$( zenity --title 'Set text color' --color-selection --color='black' ) +``` + +In case the user (accidentally) clicks the Cancel button, the script assumes a color: + +``` +if [ $? -ne 0 ] ; then +        echo '** color canceled .. assume black' +        color='rgb(0,0,0)' +fi +``` + +My script does something similar to set the background color value as **$background**. + +### Compute the relative luminance + +Once you have the foreground color in **$color** and the background color in **$background** , the next step is to compute the relative luminance for each. On its website, the [W3C provides an algorithm][3] to compute the relative luminance of a color. + +> For the sRGB colorspace, the relative luminance of a color is defined as +> **L = 0.2126 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated R + 0.7152 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated G + 0.0722 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated B** where R, G and B are defined as: +> +> if RsRGB <= 0.03928 then R = RsRGB/12.92 +> else R = ((RsRGB+0.055)/1.055) ^ 2.4 +> +> if GsRGB <= 0.03928 then G = GsRGB/12.92 +> else G = ((GsRGB+0.055)/1.055) ^ 2.4 +> +> if BsRGB <= 0.03928 then B = BsRGB/12.92 +> else B = ((BsRGB+0.055)/1.055) ^ 2.4 +> +> and RsRGB, GsRGB, and BsRGB are defined as: +> +> RsRGB = R8bit/255 +> +> GsRGB = G8bit/255 +> +> BsRGB = B8bit/255 + +Since Zenity returns color values in the format "rgb( **R** , **G** , **B** )," the script can easily pull apart the R, B, and G values to compute the relative luminance. AWK makes this a simple task, using the comma as the field separator ( **-F,** ) and using AWK's **substr()** string function to pick just the text we want from the "rgb( **R** , **G** , **B** )" color value: + +``` +R=$( echo $color | awk -F, '{print substr($1,5)}' ) +G=$( echo $color | awk -F, '{print $2}' ) +B=$( echo $color | awk -F, '{n=length($3); print substr($3,1,n-1)}' ) +``` + +**(For more on extracting and displaying data with AWK,[Get our AWK cheat sheet][4].)** + +Calculating the final relative luminance is best done using the BC calculator. BC supports the simple if-then-else needed in the calculation, which makes this part simple. But since BC cannot directly calculate exponentiation using a non-integer exponent, we need to do some extra math using the natural logarithm instead: + +``` +echo "scale=4 +rsrgb=$R/255 +gsrgb=$G/255 +bsrgb=$B/255 +if ( rsrgb <= 0.03928 ) r = rsrgb/12.92 else r = e( 2.4 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated l((rsrgb+0.055)/1.055) ) +if ( gsrgb <= 0.03928 ) g = gsrgb/12.92 else g = e( 2.4 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated l((gsrgb+0.055)/1.055) ) +if ( bsrgb <= 0.03928 ) b = bsrgb/12.92 else b = e( 2.4 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated l((bsrgb+0.055)/1.055) ) +0.2126 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated r + 0.7152 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated g + 0.0722 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated b" | bc -l +``` + +This passes several instructions to BC, including the if-then-else statements that are part of the relative luminance formula. BC then prints the final value. + +### Calculate the contrast ratio + +With the relative luminance of the text color and the background color, now the script can calculate the contrast ratio. The [W3C determines the contrast ratio][5] with this formula: + +> (L1 + 0.05) / (L2 + 0.05), where +> L1 is the relative luminance of the lighter of the colors, and +> L2 is the relative luminance of the darker of the colors + +Given two relative luminance values **$r1** and **$r2** , it's easy to calculate the contrast ratio using the BC calculator: + +``` +echo "scale=2 +if ( $r1 > $r2 ) { l1=$r1; l2=$r2 } else { l1=$r2; l2=$r1 } +(l1 + 0.05) / (l2 + 0.05)" | bc +``` + +This uses an if-then-else statement to determine which value ( **$r1** or **$r2** ) is the lighter or darker color. BC performs the resulting calculation and prints the result, which the script can store in a variable. + +### The final script + +With the above, we can pull everything together into a final script. I use Zenity to display the final result in a text box: + +``` +#!/bin/sh +# script to calculate contrast ratio of colors + +# read color and background color: +# zenity returns values like 'rgb(255,140,0)' and 'rgb(255,255,255)' + +color=$( zenity --title 'Set text color' --color-selection --color='black' ) +if [ $? -ne 0 ] ; then +        echo '** color canceled .. assume black' +        color='rgb(0,0,0)' +fi + +background=$( zenity --title 'Set background color' --color-selection --color='white' ) +if [ $? -ne 0 ] ; then +        echo '** background canceled .. assume white' +        background='rgb(255,255,255)' +fi + +# compute relative luminance: + +function luminance() +{ +        R=$( echo $1 | awk -F, '{print substr($1,5)}' ) +        G=$( echo $1 | awk -F, '{print $2}' ) +        B=$( echo $1 | awk -F, '{n=length($3); print substr($3,1,n-1)}' ) + +        echo "scale=4 +rsrgb=$R/255 +gsrgb=$G/255 +bsrgb=$B/255 +if ( rsrgb <= 0.03928 ) r = rsrgb/12.92 else r = e( 2.4 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated l((rsrgb+0.055)/1.055) ) +if ( gsrgb <= 0.03928 ) g = gsrgb/12.92 else g = e( 2.4 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated l((gsrgb+0.055)/1.055) ) +if ( bsrgb <= 0.03928 ) b = bsrgb/12.92 else b = e( 2.4 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated l((bsrgb+0.055)/1.055) ) +0.2126 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated r + 0.7152 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated g + 0.0722 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated b" | bc -l +} + +lum1=$( luminance $color ) +lum2=$( luminance $background ) + +# compute contrast + +function contrast() +{ +        echo "scale=2 +if ( $1 > $2 ) { l1=$1; l2=$2 } else { l1=$2; l2=$1 } +(l1 + 0.05) / (l2 + 0.05)" | bc +} + +rel=$( contrast $lum1 $lum2 ) + +# print results + +( cat< +``` + +Alternatively, add the following to the beginning of each of your BATS test scripts: + +``` +#!/usr/bin/env ./test/libs/bats/bin/bats +load 'libs/bats-support/load' +load 'libs/bats-assert/load' +``` + +and **chmod +x **. This will a) make them executable with the BATS installed in **./test/libs/bats** and b) include these helper libraries. BATS test scripts are typically stored in the **test** directory and named for the script being tested, but with the **.bats** extension. For example, a BATS script that tests **bin/build** should be called **test/build.bats**. + +You can also run an entire set of BATS test files by passing a regular expression to BATS, e.g., **./test/lib/bats/bin/bats test/*.bats**. + +### Organizing libraries and scripts for BATS coverage + +Bash scripts and libraries must be organized in a way that efficiently exposes their inner workings to BATS. In general, library functions and shell scripts that run many commands when they are called or executed are not amenable to efficient BATS testing. + +For example, [build.sh][4] is a typical script that many people write. It is essentially a big pile of code. Some might even put this pile of code in a function in a library. But it's impossible to run a big pile of code in a BATS test and cover all possible types of failures it can encounter in separate test cases. The only way to test this pile of code with sufficient coverage is to break it into many small, reusable, and, most importantly, independently testable functions. + +It's straightforward to add more functions to a library. An added benefit is that some of these functions can become surprisingly useful in their own right. Once you have broken your library function into lots of smaller functions, you can **source** the library in your BATS test and run the functions as you would any other command to test them. + +Bash scripts must also be broken down into multiple functions, which the main part of the script should call when the script is executed. In addition, there is a very useful trick to make it much easier to test Bash scripts with BATS: Take all the code that is executed in the main part of the script and move it into a function, called something like **run_main**. Then, add the following to the end of the script: + +``` +if [[ "${BASH_SOURCE[0]}" == "${0}" ]] +then +  run_main +fi +``` + +This bit of extra code does something special. It makes the script behave differently when it is executed as a script than when it is brought into the environment with **source**. This trick enables the script to be tested the same way a library is tested, by sourcing it and testing the individual functions. For example, here is [build.sh refactored for better BATS testability][5]. + +### Writing and running tests + +As mentioned above, BATS is a TAP-compliant testing framework with a syntax and output that will be familiar to those who have used other TAP-compliant testing suites, such as JUnit, RSpec, or Jest. Its tests are organized into individual test scripts. Test scripts are organized into one or more descriptive **@test** blocks that describe the unit of the application being tested. Each **@test** block will run a series of commands that prepares the test environment, runs the command to be tested, and makes assertions about the exit and output of the tested command. Many assertion functions are imported with the **bats** , **bats-assert** , and **bats-support** libraries, which are loaded into the environment at the beginning of the BATS test script. Here is a typical BATS test block: + +``` +@test "requires CI_COMMIT_REF_SLUG environment variable" { +  unset CI_COMMIT_REF_SLUG +  assert_empty "${CI_COMMIT_REF_SLUG}" +  run some_command +  assert_failure +  assert_output --partial "CI_COMMIT_REF_SLUG" +} +``` + +If a BATS script includes **setup** and/or **teardown** functions, they are automatically executed by BATS before and after each test block runs. This makes it possible to create environment variables, test files, and do other things needed by one or all tests, then tear them down after each test runs. [**Build.bats**][6] is a full BATS test of our newly formatted **build.sh** script. (The **mock_docker** command in this test will be explained below, in the section on mocking/stubbing.) + +When the test script runs, BATS uses **exec** to run each **@test** block as a separate subprocess. This makes it possible to export environment variables and even functions in one **@test** without affecting other **@test** s or polluting your current shell session. The output of a test run is a standard format that can be understood by humans and parsed or manipulated programmatically by TAP consumers. Here is an example of the output for the **CI_COMMIT_REF_SLUG** test block when it fails: + +``` + ✗ requires CI_COMMIT_REF_SLUG environment variable +   (from function `assert_output' in file test/libs/bats-assert/src/assert.bash, line 231, +    in test file test/ci_deploy.bats, line 26) +     `assert_output --partial "CI_COMMIT_REF_SLUG"' failed + +   -- output does not contain substring -- +   substring (1 lines): +     CI_COMMIT_REF_SLUG +   output (3 lines): +     ./bin/deploy.sh: join_string_by: command not found +     oc error +     Could not login +   -- + +   ** Did not delete , as test failed ** + +1 test, 1 failure +``` + +Here is the output of a successful test: + +``` +✓ requires CI_COMMIT_REF_SLUG environment variable +``` + +### Helpers + +Like any shell script or library, BATS test scripts can include helper libraries to share common code across tests or enhance their capabilities. These helper libraries, such as **bats-assert** and **bats-support** , can even be tested with BATS. + +Libraries can be placed in the same test directory as the BATS scripts or in the **test/libs** directory if the number of files in the test directory gets unwieldy. BATS provides the **load** function that takes a path to a Bash file relative to the script being tested (e.g., **test** , in our case) and sources that file. Files must end with the prefix **.bash** , but the path to the file passed to the **load** function can't include the prefix. **build.bats** loads the **bats-assert** and **bats-support** libraries, a small **[helpers.bash][7]** library, and a **docker_mock.bash** library (described below) with the following code placed at the beginning of the test script below the interpreter magic line: + +``` +load 'libs/bats-support/load' +load 'libs/bats-assert/load' +load 'helpers' +load 'docker_mock' +``` + +### Stubbing test input and mocking external calls + +The majority of Bash scripts and libraries execute functions and/or executables when they run. Often they are programmed to behave in specific ways based on the exit status or output ( **stdout** , **stderr** ) of these functions or executables. To properly test these scripts, it is often necessary to make fake versions of these commands that are designed to behave in a specific way during a specific test, a process called "stubbing." It may also be necessary to spy on the program being tested to ensure it calls a specific command, or it calls a specific command with specific arguments, a process called "mocking." For more on this, check out this great [discussion of mocking and stubbing][8] in Ruby RSpec, which applies to any testing system. + +The Bash shell provides tricks that can be used in your BATS test scripts to do mocking and stubbing. All require the use of the Bash **export** command with the **-f** flag to export a function that overrides the original function or executable. This must be done before the tested program is executed. Here is a simple example that overrides the **cat** executable: + +``` +function cat() { echo "THIS WOULD CAT ${*}" } +export -f cat +``` + +This method overrides a function in the same manner. If a test needs to override a function within the script or library being tested, it is important to source the tested script or library before the function is stubbed or mocked. Otherwise, the stub/mock will be replaced with the actual function when the script is sourced. Also, make sure to stub/mock before you run the command you're testing. Here is an example from **build.bats** that mocks the **raise** function described in **build.sh** to ensure a specific error message is raised by the login fuction: + +``` +@test ".login raises on oc error" { +  source ${profile_script} +  function raise() { echo "${1} raised"; } +  export -f raise +  run login +  assert_failure +  assert_output -p "Could not login raised" +} +``` + +Normally, it is not necessary to unset a stub/mock function after the test, since **export** only affects the current subprocess during the **exec** of the current **@test** block. However, it is possible to mock/stub commands (e.g. **cat** , **sed** , etc.) that the BATS **assert** * functions use internally. These mock/stub functions must be **unset** before these assert commands are run, or they will not work properly. Here is an example from **build.bats** that mocks **sed** , runs the **build_deployable** function, and unsets **sed** before running any assertions: + +``` +@test ".build_deployable prints information, runs docker build on a modified Dockerfile.production and publish_image when its not a dry_run" { +  local expected_dockerfile='Dockerfile.production' +  local application='application' +  local environment='environment' +  local expected_original_base_image="${application}" +  local expected_candidate_image="${application}-candidate:${environment}" +  local expected_deployable_image="${application}:${environment}" +  source ${profile_script} +  mock_docker build --build-arg OAUTH_CLIENT_ID --build-arg OAUTH_REDIRECT --build-arg DDS_API_BASE_URL -t "${expected_deployable_image}" - +  function publish_image() { echo "publish_image ${*}"; } +  export -f publish_image +  function sed() { +    echo "sed ${*}" >&2; +    echo "FROM application-candidate:environment"; +  } +  export -f sed +  run build_deployable "${application}" "${environment}" +  assert_success +  unset sed +  assert_output --regexp "sed.*${expected_dockerfile}" +  assert_output -p "Building ${expected_original_base_image} deployable ${expected_deployable_image} FROM ${expected_candidate_image}" +  assert_output -p "FROM ${expected_candidate_image} piped" +  assert_output -p "build --build-arg OAUTH_CLIENT_ID --build-arg OAUTH_REDIRECT --build-arg DDS_API_BASE_URL -t ${expected_deployable_image} -" +  assert_output -p "publish_image ${expected_deployable_image}" +} +``` + +Sometimes the same command, e.g. foo, will be invoked multiple times, with different arguments, in the same function being tested. These situations require the creation of a set of functions: + + * mock_foo: takes expected arguments as input, and persists these to a TMP file + * foo: the mocked version of the command, which processes each call with the persisted list of expected arguments. This must be exported with export -f. + * cleanup_foo: removes the TMP file, for use in teardown functions. This can test to ensure that a @test block was successful before removing. + + + +Since this functionality is often reused in different tests, it makes sense to create a helper library that can be loaded like other libraries. + +A good example is **[docker_mock.bash][9]**. It is loaded into **build.bats** and used in any test block that tests a function that calls the Docker executable. A typical test block using **docker_mock** looks like: + +``` +@test ".publish_image fails if docker push fails" { +  setup_publish +  local expected_image="image" +  local expected_publishable_image="${CI_REGISTRY_IMAGE}/${expected_image}" +  source ${profile_script} +  mock_docker tag "${expected_image}" "${expected_publishable_image}" +  mock_docker push "${expected_publishable_image}" and_fail +  run publish_image "${expected_image}" +  assert_failure +  assert_output -p "tagging ${expected_image} as ${expected_publishable_image}" +  assert_output -p "tag ${expected_image} ${expected_publishable_image}" +  assert_output -p "pushing image to gitlab registry" +  assert_output -p "push ${expected_publishable_image}" +} +``` + +This test sets up an expectation that Docker will be called twice with different arguments. With the second call to Docker failing, it runs the tested command, then tests the exit status and expected calls to Docker. + +One aspect of BATS introduced by **mock_docker.bash** is the **${BATS_TMPDIR}** environment variable, which BATS sets at the beginning to allow tests and helpers to create and destroy TMP files in a standard location. The **mock_docker.bash** library will not delete its persisted mocks file if a test fails, but it will print where it is located so it can be viewed and deleted. You may need to periodically clean old mock files out of this directory. + +One note of caution regarding mocking/stubbing: The **build.bats** test consciously violates a dictum of testing that states: [Don't mock what you don't own!][10] This dictum demands that calls to commands that the test's developer didn't write, like **docker** , **cat** , **sed** , etc., should be wrapped in their own libraries, which should be mocked in tests of scripts that use them. The wrapper libraries should then be tested without mocking the external commands. + +This is good advice and ignoring it comes with a cost. If the Docker CLI API changes, the test scripts will not detect this change, resulting in a false positive that won't manifest until the tested **build.sh** script runs in a production setting with the new version of Docker. Test developers must decide how stringently they want to adhere to this standard, but they should understand the tradeoffs involved with their decision. + +### Conclusion + +Introducing a testing regime to any software development project creates a tradeoff between a) the increase in time and organization required to develop and maintain code and tests and b) the increased confidence developers have in the integrity of the application over its lifetime. Testing regimes may not be appropriate for all scripts and libraries. + +In general, scripts and libraries that meet one or more of the following should be tested with BATS: + + * They are worthy of being stored in source control + * They are used in critical processes and relied upon to run consistently for a long period of time + * They need to be modified periodically to add/remove/modify their function + * They are used by others + + + +Once the decision is made to apply a testing discipline to one or more Bash scripts or libraries, BATS provides the comprehensive testing features that are available in other software development environments. + +Acknowledgment: I am indebted to [Darrin Mann][11] for introducing me to BATS testing. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/testing-bash-bats + +作者:[Darin London][a] +选题:[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/dmlond +[b]: https://github.com/lujun9972 +[1]: https://github.com/sstephenson/bats +[2]: http://testanything.org/ +[3]: https://git-scm.com/book/en/v2/Git-Tools-Submodules +[4]: https://github.com/dmlond/how_to_bats/blob/preBats/build.sh +[5]: https://github.com/dmlond/how_to_bats/blob/master/bin/build.sh +[6]: https://github.com/dmlond/how_to_bats/blob/master/test/build.bats +[7]: https://github.com/dmlond/how_to_bats/blob/master/test/helpers.bash +[8]: https://www.codewithjason.com/rspec-mocks-stubs-plain-english/ +[9]: https://github.com/dmlond/how_to_bats/blob/master/test/docker_mock.bash +[10]: https://github.com/testdouble/contributing-tests/wiki/Don't-mock-what-you-don't-own +[11]: https://github.com/dmann diff --git a/sources/tech/20190222 Q4OS Linux Revives Your Old Laptop with Windows- Looks.md b/sources/tech/20190222 Q4OS Linux Revives Your Old Laptop with Windows- Looks.md new file mode 100644 index 0000000000..93549ac45b --- /dev/null +++ b/sources/tech/20190222 Q4OS Linux Revives Your Old Laptop with Windows- Looks.md @@ -0,0 +1,192 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Q4OS Linux Revives Your Old Laptop with Windows’ Looks) +[#]: via: (https://itsfoss.com/q4os-linux-review) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +Q4OS Linux Revives Your Old Laptop with Windows’ Looks +====== + +There are quite a few Linux distros available that seek to make new users feel at home by [imitating the look and feel of Windows][1]. Today, we’ll look at a distro that attempts to do this with limited success We’ll be looking at [Q4OS][2]. + +### Q4OS Linux focuses on performance on low hardware + +![Q4OS Linux desktop after first boot][3]Q4OS after first boot + +> Q4OS is a fast and powerful operating system based on the latest technologies while offering highly productive desktop environment. We focus on security, reliability, long-term stability and conservative integration of verified new features. System is distinguished by speed and very low hardware requirements, runs great on brand new machines as well as legacy computers. It is also very applicable for virtualization and cloud computing. +> +> Q4OS Website + +Q4OS currently has two different release branches: 2.# Scorpion and 3.# Centaurus. Scorpion is the Long-Term-Support (LTS) release and will be supported for five years. That support should last until 2022. The most recent version of Scorpion is 2.6, which is based on [Debian][4] 9 Stretch. Centaurus is considered the testing branch and is based on Debian Buster. Centaurus will become the LTS when Debian Buster becomes stable. + +Q4OS is one of the few Linux distros that still support both 32-bit and 64-bit. It has also been ported to ARM devices, specifically the Raspberry PI and the PineBook. + +The one major thing that separates Q4OS from the majority of Linux distros is their use of the Trinity Desktop Environment as the default desktop environment. + +#### The not-so-famous Trinity Desktop Environment + +![][5]Trinity Desktop Environment + +I’m sure that most people are unfamiliar with the [Trinity Desktop Environment (TDE)][6]. I didn’t know until I discovered Q4OS a couple of years ago. TDE is a fork of [KDE][7], specifically KDE 3.5. TDE was created by Timothy Pearson and the first release took place in April 2010. + +From what I read, it sounds like TDE was created for the same reason as [MATE][8]). Early versions of KDE 4 were prone to crash and users were unhappy with the direction the new release was taking, it was decided to fork the previous release. That is where the similarities end. MATE has taken on a life of its own and grew to become an equal among desktop environments. Development of TDE seems to have slowed. There were two years between the last two point releases. + +Quick side note: TDE uses its own fork of Qt 3, named TQt. + +#### System Requirements + +According to the [Q4OS download page][9], the system requirements differ based on the desktop environment you install. + +**TDE Version** + + * At least 300MHz CPU + * 128 MB of RAM + * 3 GB Storage + + + +**KDE Version** + + * At least 1GHz CPU + * 1 GB of RAM + * 5 GB Storage + + + +You can see from the system requirements that Q4OS is a [lightweight Linux distribution suitable for older computers][10]. + +#### Included apps by default + +The following applications are included in the full install of Q4OS: + + * Google Chrome + * Thunderbird + * LibreOffice + * VLC player + * Konqueror browser + * Dolphin file manager + * AisleRiot Solitaire + * Konsole + * Software Center + + + * KMines + * Ockular + * KBounce + * DigiKam + * Kooka + * KolourPaint + * KSnapshot + * Gwenview + * Ark + + + * KMail + * SMPlayer + * KRec + * Brasero + * Amarok player + * qpdfview + * KOrganizer + * KMag + * KNotes + + + +Of course, you can install additional applications through the software center. Since Q4OS is based on Debian, you can also [install applications from deb packages][11]. + +#### Q4OS can be installed from within Windows + +I was able to successfully install TrueOS on my Dell Latitude D630 without any issues. This laptop has an Intel Centrino Duo Core processor running at 2.00 GHz, NVIDIA Quadro NVS 135M graphics chip, and 4 GB of RAM. + +You have a couple of options to choose from when installing Q4OS. You can either install Q4OS with a CD (Live or install) or you can install it from inside Window. The Windows installer asks for the drive location you want to install to, how much space you want Q4OS to take up and what login information do you want to use. + +![][12]Q4OS Windows installer + +Compared to most distros, the Live ISOs are small. The KDE version weighs less than 1GB and the TDE version is just a little north of 500 MB. + +### Experiencing Q4OS: Feels like older Windows versions + +Please note that while there is a KDE installation ISO, I used the TDE installation ISO. The KDE Live CD is a recent addition, so TDE is more in line with the project’s long term goals. + +When you boot into Q4OS for the first time, it feels like you jumped through a time portal and are staring at Windows 2000. The initial app offerings are very slim, you have access to a file manager, a web browser and not much else. There isn’t even a screenshot tool installed. + +![][13]Konqueror film manager + +When you try to use the TDE browser (Konqueror), a dialog box pops up recommending using the Desktop Profiler to [install Google Chrome][14] or some other recent web browser. + +The Desktop Profiler allows you to choose between a bare-bones, basic or full desktop and which desktop environment you wish to use as default. You can also use the Desktop Profiler to install other desktop environments, such as MATE, Xfce, LXQT, LXDE, Cinnamon and GNOME. + +![Q4OS Welcome Screen][15]![Q4OS Welcome Screen][15]Q4OS Welcome Screen + +Q4OS comes with its own application center. However, the offerings are limited to less than 20 options, including Synaptic, Google Chrome, Chromium, Firefox, LibreOffice, Update Manager, VLC, Multimedia codecs, Thunderbird, LookSwitcher, NVIDIA drivers, Network Manager, Skype, GParted, Wine, Blueman, X2Go server, X2Go Client, and Virtualbox additions. + +![][16]Q4OS Software Centre + +If you want to install anything else, you need to either use the command line or the [synaptic package manager][17]. Synaptic is a very good package manager and has been very serviceable for many years, but it isn’t quite newbie friendly. + +If you install an application from the Software Centre, you are treated to an installer that looks a lot like a Windows installer. I can only imagine that this is for people converting to Linux from Windows. + +![][18]Firefox installer + +As I mentioned earlier, when you boot into Q4OS’ desktop for the first time it looks like something out of the 1990s. Thankfully, you can install a utility named LookSwitcher to install a different theme. Initially, you are only shown half a dozen themes. There are other themes that are considered works-in-progress. You can also enhance the default theme by picking a more vibrant background and making the bottom panel transparent. + +![][19]Q4OS using the Debonair theme + +### Final Thoughts on Q4OS + +I may have mentioned a few times in this review that Q4OS looks like a dated version of Windows. It is obviously a very conscious decision because great care was taken to make even the control panel and file manager look Windows-eque. The problem is that it reminds me more of [ReactOS][20] than something modern. The Q4OS website says that it is made using the latest technology. The look of the system disagrees and will probably put some new users off. + +The fact that the install ISOs are smaller than most means that they are very quick to download. Unfortunately, it also means that if you want to be productive, you’ll have to spend quite a bit of time downloading software, either manually or automatically. You’ll also need an active internet connection. There is a reason why most ISOs are several gigabytes. + +I made sure to test the Windows installer. I installed a test copy of Windows 10 and ran the Q4OS installer. The process took a few minutes because the installer, which is less than 10 MB had to download an ISO. When the process was done, I rebooted. I selected Q4OS from the menu, but it looked like I was booting into Windows 10 (got the big blue circle). I thought that the install failed, but I eventually got to Q4OS. + +One of the few things that I liked about Q4OS was how easy it was to install the NVIDIA drivers. After I logged in for the first time, a little pop-up told me that there were NVIDIA drivers available and asked me if I wanted to install them. + +Using Q4OS was definitely an interesting experience, especially using TDE for the first time and the Windows look and feel. However, the lack of apps in the Software Centre and some of the design choices stop me from recommending this distro. + +**Do you like Q4OS?** + +Have you ever used Q4OS? What is your favorite Debian-based distro? Please let us know in the comments below. + +If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][21]. + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/q4os-linux-review + +作者:[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://itsfoss.com/windows-like-linux-distributions/ +[2]: https://q4os.org/ +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/q4os1.jpg?resize=800%2C500&ssl=1 +[4]: https://www.debian.org/ +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/q4os4.jpg?resize=800%2C412&ssl=1 +[6]: https://www.trinitydesktop.org/ +[7]: https://en.wikipedia.org/wiki/KDE +[8]: https://en.wikipedia.org/wiki/MATE_(software +[9]: https://q4os.org/downloads1.html +[10]: https://itsfoss.com/lightweight-linux-beginners/ +[11]: https://itsfoss.com/list-installed-packages-ubuntu/ +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/q4os-windows-installer.jpg?resize=800%2C610&ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/q4os2.jpg?resize=800%2C606&ssl=1 +[14]: https://itsfoss.com/install-chrome-ubuntu/ +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/q4os10.png?ssl=1 +[16]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/q4os3.jpg?resize=800%2C507&ssl=1 +[17]: https://www.nongnu.org/synaptic/ +[18]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/q4os5.jpg?resize=800%2C616&ssl=1 +[19]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/q4os8Debonaire.jpg?resize=800%2C500&ssl=1 +[20]: https://www.reactos.org/ +[21]: http://reddit.com/r/linuxusersgroup +[22]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/q4os1.jpg?fit=800%2C500&ssl=1 diff --git a/sources/tech/20190225 How To Identify That The Linux Server Is Integrated With Active Directory (AD).md b/sources/tech/20190225 How To Identify That The Linux Server Is Integrated With Active Directory (AD).md new file mode 100644 index 0000000000..55d30a7910 --- /dev/null +++ b/sources/tech/20190225 How To Identify That The Linux Server Is Integrated With Active Directory (AD).md @@ -0,0 +1,177 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Identify That The Linux Server Is Integrated With Active Directory (AD)?) +[#]: via: (https://www.2daygeek.com/how-to-identify-that-the-linux-server-is-integrated-with-active-directory-ad/) +[#]: author: (Vinoth Kumar https://www.2daygeek.com/author/vinoth/) + +How To Identify That The Linux Server Is Integrated With Active Directory (AD)? +====== + +Single Sign On (SSO) Authentication is an implemented in most of the organizations due to multiple applications access. + +It allows a user to logs in with a single ID and password to all the applications which is available in the organization. + +It uses a centralized authentication system for all the applications. + +A while ago we had written an article, **[how to integrate Linux system with AD][1]**. + +Today we are going to show you, how to check that the Linux system is integrated with AD using multiple ways. + +It can be done in four ways and we will explain one by one. + + * **`ps Command:`** It report a snapshot of the current processes. + * **`id Command:`** It prints user identity. + * **`/etc/nsswitch.conf file:`** It is Name Service Switch configuration file. + * **`/etc/pam.d/system-auth file:`** It is Common configuration file for PAMified services. + + + +### How To Identify That The Linux Server Is Integrated With AD Using PS Command? + +ps command displays information about a selection of the active processes. + +To integrate the Linux server with AD, we need to use either `winbind` or `sssd` or `ldap` service. + +So, use the ps command to filter these services. + +If you found any of these services is running on system then we can decide that the system is currently integrate with AD using “winbind” or “sssd” or “ldap” service. + +You might get the output similar to below if the system is integrated with AD using `SSSD` service. + +``` +# ps -ef | grep -i "winbind\|sssd" + +root 29912 1 0 2017 ? 00:19:09 /usr/sbin/sssd -f -D +root 29913 29912 0 2017 ? 04:36:59 /usr/libexec/sssd/sssd_be --domain 2daygeek.com --uid 0 --gid 0 --debug-to-files +root 29914 29912 0 2017 ? 00:29:28 /usr/libexec/sssd/sssd_nss --uid 0 --gid 0 --debug-to-files +root 29915 29912 0 2017 ? 00:09:19 /usr/libexec/sssd/sssd_pam --uid 0 --gid 0 --debug-to-files +root 31584 26666 0 13:41 pts/3 00:00:00 grep sssd +``` + +You might get the output similer to below if the system is integrated with AD using `winbind` service. + +``` +# ps -ef | grep -i "winbind\|sssd" + +root 676 21055 0 2017 ? 00:00:22 winbindd +root 958 21055 0 2017 ? 00:00:35 winbindd +root 21055 1 0 2017 ? 00:59:07 winbindd +root 21061 21055 0 2017 ? 11:48:49 winbindd +root 21062 21055 0 2017 ? 00:01:28 winbindd +root 21959 4570 0 13:50 pts/2 00:00:00 grep -i winbind\|sssd +root 27780 21055 0 2017 ? 00:00:21 winbindd +``` + +### How To Identify That The Linux Server Is Integrated With AD Using id Command? + +It Prints information for given user name, or the current user. It displays the UID, GUID, User Name, Primary Group Name and Secondary Group Name, etc., + +If the Linux system is integrated with AD then you might get the output like below. The GID clearly shows that the user is coming from AD “domain users”. + +``` +# id daygeek + +uid=1918901106(daygeek) gid=1918900513(domain users) groups=1918900513(domain users) +``` + +### How To Identify That The Linux Server Is Integrated With AD Using nsswitch.conf file? + +The Name Service Switch (NSS) configuration file, `/etc/nsswitch.conf`, is used by the GNU C Library and certain other applications to determine the sources from which to obtain name-service information in a range of categories, and in what order. Each category of information is identified by a database name. + +You might get the output similar to below if the system is integrated with AD using `SSSD` service. + +``` +# cat /etc/nsswitch.conf | grep -i "sss\|winbind\|ldap" + +passwd: files sss +shadow: files sss +group: files sss +services: files sss +netgroup: files sss +automount: files sss +``` + +You might get the output similar to below if the system is integrated with AD using `winbind` service. + +``` +# cat /etc/nsswitch.conf | grep -i "sss\|winbind\|ldap" + +passwd: files [SUCCESS=return] winbind +shadow: files [SUCCESS=return] winbind +group: files [SUCCESS=return] winbind +``` + +You might get the output similer to below if the system is integrated with AD using `ldap` service. + +``` +# cat /etc/nsswitch.conf | grep -i "sss\|winbind\|ldap" + +passwd: files ldap +shadow: files ldap +group: files ldap +``` + +### How To Identify That The Linux Server Is Integrated With AD Using system-auth file? + +It is Common configuration file for PAMified services. + +PAM stands for Pluggable Authentication Module that provides dynamic authentication support for applications and services in Linux. + +system-auth configuration file is provide a common interface for all applications and service daemons calling into the PAM library. + +The system-auth configuration file is included from nearly all individual service configuration files with the help of the include directive. + +You might get the output similar to below if the system is integrated with AD using `SSSD` service. + +``` +# cat /etc/pam.d/system-auth | grep -i "pam_sss.so\|pam_winbind.so\|pam_ldap.so" +or +# cat /etc/pam.d/system-auth-ac | grep -i "pam_sss.so\|pam_winbind.so\|pam_ldap.so" + +auth sufficient pam_sss.so use_first_pass +account [default=bad success=ok user_unknown=ignore] pam_sss.so +password sufficient pam_sss.so use_authtok +session optional pam_sss.so +``` + +You might get the output similar to below if the system is integrated with AD using `winbind` service. + +``` +# cat /etc/pam.d/system-auth | grep -i "pam_sss.so\|pam_winbind.so\|pam_ldap.so" +or +# cat /etc/pam.d/system-auth-ac | grep -i "pam_sss.so\|pam_winbind.so\|pam_ldap.so" + +auth sufficient pam_winbind.so cached_login use_first_pass +account [default=bad success=ok user_unknown=ignore] pam_winbind.so cached_login +password sufficient pam_winbind.so cached_login use_authtok +``` + +You might get the output similar to below if the system is integrated with AD using `ldap` service. + +``` +# cat /etc/pam.d/system-auth | grep -i "pam_sss.so\|pam_winbind.so\|pam_ldap.so" +or +# cat /etc/pam.d/system-auth-ac | grep -i "pam_sss.so\|pam_winbind.so\|pam_ldap.so" + +auth sufficient pam_ldap.so cached_login use_first_pass +account [default=bad success=ok user_unknown=ignore] pam_ldap.so cached_login +password sufficient pam_ldap.so cached_login use_authtok +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-identify-that-the-linux-server-is-integrated-with-active-directory-ad/ + +作者:[Vinoth Kumar][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/vinoth/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/join-integrate-rhel-centos-linux-system-to-windows-active-directory-ad-domain/ diff --git a/sources/tech/20190225 How to Install VirtualBox on Ubuntu -Beginner-s Tutorial.md b/sources/tech/20190225 How to Install VirtualBox on Ubuntu -Beginner-s Tutorial.md new file mode 100644 index 0000000000..4ba0580ece --- /dev/null +++ b/sources/tech/20190225 How to Install VirtualBox on Ubuntu -Beginner-s Tutorial.md @@ -0,0 +1,156 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Install VirtualBox on Ubuntu [Beginner’s Tutorial]) +[#]: via: (https://itsfoss.com/install-virtualbox-ubuntu) +[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/) + +How to Install VirtualBox on Ubuntu [Beginner’s Tutorial] +====== + +**This beginner’s tutorial explains various ways to install VirtualBox on Ubuntu and other Debian-based Linux distributions.** + +Oracle’s free and open source offering [VirtualBox][1] is an excellent virtualization tool, specially for desktop operating systems. I prefer using it over [VMWare Workstation in Linux][2], another virtualization tool. + +You can use virtualization software like VirtualBox for installing and using another operating system within a virtual machine. + +For example, you can [install Linux on VirtualBox inside Windows][3]. Similarly, you can also [install Windows inside Linux using VirtualBox][4]. + +You can also use VirtualBox for installing another Linux distribution in your current Linux system. Actually, this is what I use it for. If I hear about a nice Linux distribution, instead of installing it on a real system, I test it on a virtual machine. It’s more convenient when you just want to try out a distribution before making a decision about installing it on your actual machine. + +![Linux installed inside Linux using VirtualBox][5]Ubuntu 18.10 installed inside Ubuntu 18.04 + +In this beginner’s tutorial, I’ll show you various ways of installing Oracle VirtualBox on Ubuntu and other Debian-based distributions. + +### Installing VirtualBox on Ubuntu and Debian based Linux distributions + +The installation methods mentioned here should also work for other Debian and Ubuntu-based Linux distributions such as Linux Mint, elementary OS etc. + +#### Method 1: Install VirtualBox from Ubuntu Repository + +**Pros** : Easy installation + +**Cons** : Installs older version + +The easiest way to install VirtualBox on Ubuntu would be to search for it in the Software Center and install it from there. + +![VirtualBox in Ubuntu Software Center][6]VirtualBox is available in Ubuntu Software Center + +You can also install it from the command line using the command: + +``` +sudo apt install virtualbox +``` + +However, if you [check the package version before installing it][7], you’ll see that the VirtualBox provided by Ubuntu’s repository is quite old. + +For example, the current VirtualBox version at the time of writing this tutorial is 6.0 but the one in Software Center is 5.2. This means you won’t get the newer features introduced in the [latest version of VirtualBox][8]. + +#### Method 2: Install VirtualBox using Deb file from Oracle’s website + +**Pros** : Easily install the latest version + +**Cons** : Can’t upgrade to newer version + +If you want to use the latest version of VirtualBox on Ubuntu, the easiest way would be to [use the deb file][9]. + +Oracle provides read to use binary files for VirtualBox releases. If you look at its download page, you’ll see the option to download the deb installer files for Ubuntu and other distributions. + +![VirtualBox Linux Download][10] + +You just have to download this deb file and double click on it to install it. It’s as simple as that. + +However, the problem with this method is that you won’t get automatically updated to the newer VirtualBox releases. The only way is to remove the existing version, download the newer version and install it again. That’s not very convenient, is it? + +#### Method 3: Install VirualBox using Oracle’s repository + +**Pros** : Automatically updates with system updates + +**Cons** : Slightly complicated installation + +Now this is the command line method and it may seem complicated to you but it has advantages over the previous two methods. You’ll get the latest version of VirtualBox and it will be automatically updated to the future releases. That’s what you would want, I presume. + +To install VirtualBox using command line, you add the Oracle VirtualBox’s repository in your list of repositories. You add its GPG key so that your system trusts this repository. Now when you install VirtualBox, it will be installed from Oracle’s repository instead of Ubuntu’s repository. If there is a new version released, VirtualBox install will be updated along with the system updates. Let’s see how to do that. + +First, add the key for the repository. You can download and add the key using this single command. + +``` +wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add - +``` + +``` +Important for Mint users + +The next step will work for Ubuntu only. If you are using Linux Mint or some other distribution based on Ubuntu, replace $(lsb_release -cs) in the command with the Ubuntu version your current version is based on. For example, Linux Mint 19 series users should use bionic and Mint 18 series users should use xenial. Something like this + +sudo add-apt-repository “deb [arch=amd64] **bionic** contrib“ +``` + +Now add the Oracle VirtualBox repository in the list of repositories using this command: + +``` +sudo add-apt-repository "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" +``` + +If you have read my article on [checking Ubuntu version][11], you probably know that ‘lsb_release -cs’ will print the codename of your Ubuntu system. + +**Note** : If you see [add-apt-repository command not found][12] error, you’ll have to install software-properties-common package. + +Now that you have the correct repository added, refresh the list of available packages through these repositories and install VirtualBox. + +``` +sudo apt update && sudo apt install virtualbox-6.0 +``` + +**Tip** : A good idea would be to type sudo apt install **virtualbox–** and hit tab to see the various VirtualBox versions available for installation and then select one of them by typing it completely. + +![Install VirtualBox via terminal][13] + +### How to remove VirtualBox from Ubuntu + +Now that you have learned to install VirtualBox, I would also mention the steps to remove it. + +If you installed it from the Software Center, the easiest way to remove the application is from the Software Center itself. You just have to find it in the [list of installed applications][14] and click the Remove button. + +Another ways is to use the command line. + +``` +sudo apt remove virtualbox virtualbox-* +``` + +Note that this will not remove the virtual machines and the files associated with the operating systems you installed using VirtualBox. That’s not entirely a bad thing because you may want to keep them safe to use it later or in some other system. + +**In the end…** + +I hope you were able to pick one of the methods to install VirtualBox. I’ll also write about using it effectively in another article. For the moment, if you have and tips or suggestions or any questions, feel free to leave a comment below. + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-virtualbox-ubuntu + +作者:[Abhishek Prakash][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/abhishek/ +[b]: https://github.com/lujun9972 +[1]: https://www.virtualbox.org +[2]: https://itsfoss.com/install-vmware-player-ubuntu-1310/ +[3]: https://itsfoss.com/install-linux-in-virtualbox/ +[4]: https://itsfoss.com/install-windows-10-virtualbox-linux/ +[5]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/linux-inside-linux-virtualbox.png?resize=800%2C450&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/virtualbox-ubuntu-software-center.jpg?ssl=1 +[7]: https://itsfoss.com/know-program-version-before-install-ubuntu/ +[8]: https://itsfoss.com/oracle-virtualbox-release/ +[9]: https://itsfoss.com/install-deb-files-ubuntu/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/virtualbox-download.jpg?resize=800%2C433&ssl=1 +[11]: https://itsfoss.com/how-to-know-ubuntu-unity-version/ +[12]: https://itsfoss.com/add-apt-repository-command-not-found/ +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/install-virtualbox-ubuntu-terminal.png?resize=800%2C165&ssl=1 +[14]: https://itsfoss.com/list-installed-packages-ubuntu/ diff --git a/sources/tech/20190225 Netboot a Fedora Live CD.md b/sources/tech/20190225 Netboot a Fedora Live CD.md new file mode 100644 index 0000000000..2767719b8c --- /dev/null +++ b/sources/tech/20190225 Netboot a Fedora Live CD.md @@ -0,0 +1,187 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Netboot a Fedora Live CD) +[#]: via: (https://fedoramagazine.org/netboot-a-fedora-live-cd/) +[#]: author: (Gregory Bartholomew https://fedoramagazine.org/author/glb/) + +Netboot a Fedora Live CD +====== + +![](https://fedoramagazine.org/wp-content/uploads/2019/02/netboot-livecd-816x345.jpg) + +[Live CDs][1] are useful for many tasks such as: + + * installing the operating system to a hard drive + * repairing a boot loader or performing other rescue-mode operations + * providing a consistent and minimal environment for web browsing + * …and [much more][2]. + + + +As an alternative to using DVDs and USB drives to store your Live CD images, you can upload them to an [iSCSI][3] server where they will be less likely to get lost or damaged. This guide shows you how to load your Live CD images onto an iSCSI server and access them with the [iPXE][4] boot loader. + +### Download a Live CD Image + +``` +$ MY_RLSE=27 +$ MY_LIVE=$(wget -q -O - https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/$MY_RLSE/Workstation/x86_64/iso | perl -ne '/(Fedora[^ ]*?-Live-[^ ]*?\.iso)(?{print $^N})/;') +$ MY_NAME=fc$MY_RLSE +$ wget -O $MY_NAME.iso https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/$MY_RLSE/Workstation/x86_64/iso/$MY_LIVE +``` + +The above commands download the Fedora-Workstation-Live-x86_64-27-1.6.iso Fedora Live image and save it as fc27.iso. Change the value of MY_RLSE to download other archived versions. Or you can browse to to download the latest Fedora live image. Versions prior to 21 used different naming conventions, and must be [downloaded manually here][5]. If you download a Live CD image manually, set the MY_NAME variable to the basename of the file without the extension. That way the commands in the following sections will reference the correct file. + +### Convert the Live CD Image + +Use the livecd-iso-to-disk tool to convert the ISO file to a disk image and add the netroot parameter to the embedded kernel command line: + +``` +$ sudo dnf install -y livecd-tools +$ MY_SIZE=$(du -ms $MY_NAME.iso | cut -f 1) +$ dd if=/dev/zero of=$MY_NAME.img bs=1MiB count=0 seek=$(($MY_SIZE+512)) +$ MY_SRVR=server-01.example.edu +$ MY_RVRS=$(echo $MY_SRVR | tr '.' "\n" | tac | tr "\n" '.' | cut -b -${#MY_SRVR}) +$ MY_LOOP=$(sudo losetup --show --nooverlap --find $MY_NAME.img) +$ sudo livecd-iso-to-disk --format --extra-kernel-args netroot=iscsi:$MY_SRVR:::1:iqn.$MY_RVRS:$MY_NAME $MY_NAME.iso $MY_LOOP +$ sudo losetup -d $MY_LOOP +``` + +### Upload the Live Image to your Server + +Create a directory on your iSCSI server to store your live images and then upload your modified image to it. + +**For releases 21 and greater:** + +``` +$ MY_FLDR=/images +$ scp $MY_NAME.img $MY_SRVR:$MY_FLDR/ +``` + +**For releases prior to 21:** + +``` +$ MY_FLDR=/images +$ MY_LOOP=$(sudo losetup --show --nooverlap --find --partscan $MY_NAME.img) +$ sudo tune2fs -O ^has_journal ${MY_LOOP}p1 +$ sudo e2fsck ${MY_LOOP}p1 +$ sudo dd status=none if=${MY_LOOP}p1 | ssh $MY_SRVR "dd of=$MY_FLDR/$MY_NAME.img" +$ sudo losetup -d $MY_LOOP +``` + +### Define the iSCSI Target + +Run the following commands on your iSCSI server: + +``` +$ sudo -i +# MY_NAME=fc27 +# MY_FLDR=/images +# MY_SRVR=`hostname` +# MY_RVRS=$(echo $MY_SRVR | tr '.' "\n" | tac | tr "\n" '.' | cut -b -${#MY_SRVR}) +# cat << END > /etc/tgt/conf.d/$MY_NAME.conf + + backing-store $MY_FLDR/$MY_NAME.img + readonly 1 + allow-in-use yes + +END +# tgt-admin --update ALL +``` + +### Create a Bootable USB Drive + +The [iPXE][4] boot loader has a [sanboot][6] command you can use to connect to and start the live images hosted on your iSCSI server. It can be compiled in many different [formats][7]. The format that works best depends on the type of hardware you’re running. As an example, the following instructions show how to [chain load][8] iPXE from [syslinux][9] on a USB drive. + +First, download iPXE and build it in its lkrn format. This should be done as a normal user on a workstation: + +``` +$ sudo dnf install -y git +$ git clone http://git.ipxe.org/ipxe.git $HOME/ipxe +$ sudo dnf groupinstall -y "C Development Tools and Libraries" +$ cd $HOME/ipxe/src +$ make clean +$ make bin/ipxe.lkrn +$ cp bin/ipxe.lkrn /tmp +``` + +Next, prepare a USB drive with a MSDOS partition table and a FAT32 file system. The below commands assume that you have already connected the USB drive to be formatted. **Be careful that you do not format the wrong drive!** + +``` +$ sudo -i +# dnf install -y parted util-linux dosfstools +# echo; find /dev/disk/by-id ! -regex '.*-part.*' -name 'usb-*' -exec readlink -f {} \; | xargs -i bash -c "parted -s {} unit MiB print | perl -0 -ne '/^Model: ([^(]*).*\n.*?([0-9]*MiB)/i && print \"Found: {} = \$2 \$1\n\"'"; echo; read -e -i "$(find /dev/disk/by-id ! -regex '.*-part.*' -name 'usb-*' -exec readlink -f {} \; -quit)" -p "Drive to format: " MY_USB +# umount $MY_USB? +# wipefs -a $MY_USB +# parted -s $MY_USB mklabel msdos mkpart primary fat32 1MiB 100% set 1 boot on +# mkfs -t vfat -F 32 ${MY_USB}1 +``` + +Finally, install syslinux on the USB drive and configure it to chain load iPXE: + +``` +# dnf install -y syslinux-nonlinux +# syslinux -i ${MY_USB}1 +# dd if=/usr/share/syslinux/mbr.bin of=${MY_USB} +# MY_MNT=$(mktemp -d) +# mount ${MY_USB}1 $MY_MNT +# MY_NAME=fc27 +# MY_SRVR=server-01.example.edu +# MY_RVRS=$(echo $MY_SRVR | tr '.' "\n" | tac | tr "\n" '.' | cut -b -${#MY_SRVR}) +# cat << END > $MY_MNT/syslinux.cfg +ui menu.c32 +default $MY_NAME +timeout 100 +menu title SYSLINUX +label $MY_NAME + menu label ${MY_NAME^^} + kernel ipxe.lkrn + append dhcp && sanboot iscsi:$MY_SRVR:::1:iqn.$MY_RVRS:$MY_NAME +END +# cp /usr/share/syslinux/menu.c32 $MY_MNT +# cp /usr/share/syslinux/libutil.c32 $MY_MNT +# cp /tmp/ipxe.lkrn $MY_MNT +# umount ${MY_USB}1 +``` + +You should be able to use this same USB drive to netboot additional iSCSI targets simply by editing the syslinux.cfg file and adding additional menu entries. + +This is just one method of loading iPXE. You could install syslinux directly on your workstation. Another option is to compile iPXE as an EFI executable and place it directly in your [ESP][10]. Yet another is to compile iPXE as a PXE loader and place it on your TFTP server to be referenced by DHCP. The best option depends on your environment. + +### Final Notes + + * You may want to add the –filename \EFI\BOOT\grubx64.efi parameter to the sanboot command if you compile iPXE in its EFI format. + * It is possible to create custom live images. Refer to [Creating and using live CD][11] for more information. + * It is possible to add the –overlay-size-mb and –home-size-mb parameters to the livecd-iso-to-disk command to create live images with persistent storage. However, if you have multiple concurrent users, you’ll need to set up your iSCSI server to manage separate per-user writeable overlays. This is similar to what was shown in the “[How to Build a Netboot Server, Part 4][12]” article. + * The live images support a persistenthome option on their kernel command line (e.g. persistenthome=LABEL=HOME). Used together with CHAP-authenticated iSCSI targets, the persistenthome option provides an interesting alternative to NFS for centralized home directories. + + + + +-------------------------------------------------------------------------------- + +via: https://fedoramagazine.org/netboot-a-fedora-live-cd/ + +作者:[Gregory Bartholomew][a] +选题:[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/glb/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Live_CD +[2]: https://en.wikipedia.org/wiki/Live_CD#Uses +[3]: https://en.wikipedia.org/wiki/ISCSI +[4]: https://ipxe.org/ +[5]: https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/https://dl.fedoraproject.org/pub/archive/fedora/linux/releases/ +[6]: http://ipxe.org/cmd/sanboot/ +[7]: https://ipxe.org/appnote/buildtargets#boot_type +[8]: https://en.wikipedia.org/wiki/Chain_loading +[9]: https://www.syslinux.org/wiki/index.php?title=SYSLINUX +[10]: https://en.wikipedia.org/wiki/EFI_system_partition +[11]: https://docs.fedoraproject.org/en-US/quick-docs/creating-and-using-a-live-installation-image/#proc_creating-and-using-live-cd +[12]: https://fedoramagazine.org/how-to-build-a-netboot-server-part-4/ diff --git a/sources/tech/20190226 All about -Curly Braces- in Bash.md b/sources/tech/20190226 All about -Curly Braces- in Bash.md new file mode 100644 index 0000000000..42d37abdec --- /dev/null +++ b/sources/tech/20190226 All about -Curly Braces- in Bash.md @@ -0,0 +1,239 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (All about {Curly Braces} in Bash) +[#]: via: (https://www.linux.com/blog/learn/2019/2/all-about-curly-braces-bash) +[#]: author: (Paul Brown https://www.linux.com/users/bro66) + +All about {Curly Braces} in Bash +====== + +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/curly-braces-1920.jpg?itok=cScRhWrX) + +At this stage of our Bash basics series, it would be hard not to see some crossover between topics. For example, you have already seen a lot of brackets in the examples we have shown over the past several weeks, but the focus has been elsewhere. + +For the next phase of the series, we’ll take a closer look at brackets, curly, curvy, or straight, how to use them, and what they do depending on where you use them. We will also tackle other ways of enclosing things, like when to use quotes, double-quotes, and backquotes. + +This week, we're looking at curly brackets or _braces_ : `{}`. + +### Array Builder + +You have already encountered curly brackets before in [The Meaning of Dot][1]. There, the focus was on the use of the dot/period (`.`), but using braces to build a sequence was equally important. + +As we saw then: + +``` +echo {0..10} +``` + +prints out the numbers from 0 to 10. Using: + +``` +echo {10..0} +``` + +prints out the same numbers, but in reverse order. And, + +``` +echo {10..0..2} +``` + +prints every second number, starting with 10 and making its way backwards to 0. + +Then, + +``` +echo {z..a..2} +``` + +prints every second letter, starting with _z_ and working its way backwards until _a_. + +And so on and so forth. + +Another thing you can do is combine two or more sequences: + +``` +echo {a..z}{a..z} +``` + +This prints out all the two letter combinations of the alphabet, from _aa_ to _zz_. + +Is this useful? Well, actually it is. You see, arrays in Bash are defined by putting elements between parenthesis `()` and separating each element using a space, like this: + +``` +month=("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec") +``` + +To access an element within the array, you use its index within brackets `[]`: + +``` +$ echo ${month[3]} # Array indexes start at [0], so [3] points to the fourth item + +Apr +``` + +You can accept all those brackets, parentheses, and braces on faith for a moment. We'll talk about them presently. + +Notice that, all things being equal, you can create an array with something like this: + +``` +letter_combos=({a..z}{a..z}) +``` + +and `letter_combos` points to an array that contains all the 2-letter combinations of the entire alphabet. + +You can also do this: + +``` +dec2bin=({0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}{0..1}) +``` + +This last one is particularly interesting because `dec2bin` now contains all the binary numbers for an 8-bit register, in ascending order, starting with 00000000, 00000001, 00000010, etc., until reaching 11111111. You can use this to build yourself an 8-bit decimal-to-binary converter. Say you want to know what 25 is in binary. You can do this: + +``` +$ echo ${dec2bin[25]} + +00011001 +``` + +Yes, there are better ways of converting decimal to binary as we saw in [the article where we discussed & as a logical operator][2], but it is still interesting, right? + +### Parameter expansion + +Getting back to + +``` +echo ${month[3]} +``` + +Here the braces `{}` are not being used as apart of a sequence builder, but as a way of generating _parameter expansion_. Parameter expansion involves what it says on the box: it takes the variable or expression within the braces and expands it to whatever it represents. + +In this case, `month` is the array we defined earlier, that is: + +``` +month=("Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct" "Nov" "Dec") +``` + +And, item 3 within the array points to `"Apr"` (remember: the first index in an array in Bash is `[0]`). That means that `echo ${month[3]}`, after the expansion, translates to `echo "Apr"`. + +Interpreting a variable as its value is one way of expanding it, but there are a few more you can leverage. You can use parameter expansion to manipulate what you read from variable, say, by cutting a chunk off the end. + +Suppose you have a variable like: + +``` +a="Too longgg" +``` + +The command: + +``` +echo ${a%gg} +``` + +chops off the last two gs and prints " _Too long_ ". + +Breaking this down, + + * `${...}` tells the shell to expand whatever is inside it + * `a` is the variable you are working with + * `%` tells the shell you want to chop something off the end of the expanded variable ("Too longgg") + * and `gg` is what you want to chop off. + + + +This can be useful for converting files from one format to another. Allow me to explain with a slight digression: + +[ImageMagick][3] is a set of command line tools that lets you manipulate and modify images. One of its most useful tools ImageMagick comes with is `convert`. In its simplest form `convert` allows you to, given an image in a certain format, make a copy of it in another format. + +The following command takes a JPEG image called _image.jpg_ and creates a PNG copy called _image.png_ : + +``` +convert image.jpg image.png +``` + +ImageMagick is often pre-installed on most Linux distros. If you can't find it, look for it in your distro's software manager. + +Okay, end of digression. On to the example: + +With variable expansion, you can do the same as shown above like this: + +``` +i=image.jpg + +convert $i ${i%jpg}png +``` + +What you are doing here is chopping off the extension `jpg` from `i` and then adding `png`, making the command `convert image.jpg image.png`. + +You may be wondering how this is more useful than just writing in the name of the file. Well, when you have a directory containing hundreds of JPEG images, you need to convert to PNG, run the following in it: + +``` +for i in *.jpg; do convert $i ${i%jpg}png; done +``` + +... and, hey presto! All the pictures get converted automatically. + +If you need to chop off a chunk from the beginning of a variable, instead of `%`, use `#`: + +``` +$ a="Hello World!" + +$ echo Goodbye${a#Hello} + +Goodbye World! +``` + +There's quite a bit more to parameter expansion, but a lot of it makes sense only when you are writing scripts. We'll explore more on that topic later in this series. + +### Output Grouping + +Meanwhile, let's finish up with something simple: you can also use `{ ... }` to group the output from several commands into one big blob. The command: + +``` +echo "I found all these PNGs:"; find . -iname "*.png"; echo "Within this bunch of files:"; ls > PNGs.txt +``` + +will execute all the commands but will only copy into the _PNGs.txt_ file the output from the last `ls` command in the list. However, doing + +``` +{ echo "I found all these PNGs:"; find . -iname "*.png"; echo "Within this bunch of files:"; ls; } > PNGs.txt +``` + +creates the file _PNGs.txt_ with everything, starting with the line " _I found all these PNGs:_ ", then the list of PNG files returned by `find`, then the line "Within this bunch of files:" and finishing up with the complete list of files and directories within the current directory. + +Notice that there is space between the braces and the commands enclosed within them. That’s because `{` and `}` are _reserved words_ here, commands built into the shell. They would roughly translate to " _group the outputs of all these commands together_ " in plain English. + +Also notice that the list of commands has to end with a semicolon (`;`) or the whole thing will bork. + +### Next Time + +In our next installment, we'll be looking at more things that enclose other things, but of different shapes. Until then, have fun! + +Read more: + +[And, Ampersand, and & in Linux][4] + +[Ampersands and File Descriptors in Bash][5] + +[Logical & in Bash][2] + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2019/2/all-about-curly-braces-bash + +作者:[Paul Brown][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.linux.com/users/bro66 +[b]: https://github.com/lujun9972 +[1]: https://www.linux.com/blog/learn/2019/1/linux-tools-meaning-dot +[2]: https://www.linux.com/blog/learn/2019/2/logical-ampersand-bash +[3]: http://www.imagemagick.org/ +[4]: https://www.linux.com/blog/learn/2019/2/and-ampersand-and-linux +[5]: https://www.linux.com/blog/learn/2019/2/ampersands-and-file-descriptors-bash diff --git a/sources/tech/20190226 How To SSH Into A Particular Directory On Linux.md b/sources/tech/20190226 How To SSH Into A Particular Directory On Linux.md new file mode 100644 index 0000000000..6dea8d9f24 --- /dev/null +++ b/sources/tech/20190226 How To SSH Into A Particular Directory On Linux.md @@ -0,0 +1,114 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To SSH Into A Particular Directory On Linux) +[#]: via: (https://www.ostechnix.com/how-to-ssh-into-a-particular-directory-on-linux/) +[#]: author: (SK https://www.ostechnix.com/author/sk/) + +How To SSH Into A Particular Directory On Linux +====== + +![](https://www.ostechnix.com/wp-content/uploads/2019/02/SSH-Into-A-Particular-Directory-720x340.png) + +Have you ever been in a situation where you want to SSH to a remote server and immediately cd into a directory and continue work interactively? You’re on the right track! This brief tutorial describes how to directly SSH into a particular directory of a remote Linux system. Not just SSH into a specific directory, you can run any command immediately right after connecting to an SSH server as described in this guide. It is not that difficult as you might think. Read on. + +### SSH Into A Particular Directory Of A Remote System + +Before I knew this method, I would usually first SSH to the remote remote system using command: + +``` +$ ssh user@remote-system +``` + +And then cd into a directory like below: + +``` +$ cd +``` + +However, you need not to use two separate commands. You can combine these commands and simplify the task with one command. + +Have a look at the following example. + +``` +$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix ; bash' +``` + +The above command will SSH into a remote system (192.168.225.22) and immediately cd into a directory named **‘/home/sk/ostechnix/’** directory and leave yourself at the prompt. + +Here, the **-t** flag is used to force pseudo-terminal allocation, which is necessary or an interactive shell. + +Here is the sample output of the above command: + +![](https://www.ostechnix.com/wp-content/uploads/2019/02/ssh-1.gif) + +You can also use this command as well. + +``` +$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix ; exec bash' +``` + +Or, + +``` +$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix && exec bash -l' +``` + +Here, the **-l** flag sets the bash as login shell. + +In the above example, I have used **bash** in the last argument. It is the default shell in my remote system. If you don’t know the shell type on the remote system, use the following command: + +``` +$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix && exec $SHELL' +``` + +Like I already said, this is not just for cd into directory after connecting to an remote system. You can use this trick to run other commands as well. For example, the following command will land you inside ‘/home/sk/ostechnix/’ directory and then execute ‘uname -a’ command. + +``` +$ ssh -t sk@192.168.225.22 'cd /home/sk/ostechnix && uname -a && exec $SHELL' +``` + +Alternatively, you can add the command(s) you wanted to run after connecting to an SSH server on the remote system’s **.bash_profile** file. + +Edit **.bash_profile** file: + +``` +$ nano ~/.bash_profile +``` + +Add the command(s) one by one. In my case, I am adding the following line: + +``` +cd /home/sk/ostechnix >& /dev/null +``` + +Save and close the file. Finally, run the following command to update the changes. + +``` +$ source ~/.bash_profile +``` + +Please note that you should add this line on the remote system’s **.bash_profile** or **.bashrc** file, not in your local system’s. From now on, whenever you login (whether by SSH or direct), the cd command will execute and you will be automatically landed inside “/home/sk/ostechnix/” directory. + + +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-ssh-into-a-particular-directory-on-linux/ + +作者:[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 diff --git a/sources/tech/20190226 Linux security- Cmd provides visibility, control over user activity.md b/sources/tech/20190226 Linux security- Cmd provides visibility, control over user activity.md new file mode 100644 index 0000000000..952e76f1f3 --- /dev/null +++ b/sources/tech/20190226 Linux security- Cmd provides visibility, control over user activity.md @@ -0,0 +1,86 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Linux security: Cmd provides visibility, control over user activity) +[#]: via: (https://www.networkworld.com/article/3342454/linux-security-cmd-provides-visibility-control-over-user-activity.html) +[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/) + +Linux security: Cmd provides visibility, control over user activity +====== + +![](https://images.techhive.com/images/article/2017/01/background-1900329_1920-100705659-large.jpg) + +There's a new Linux security tool you should be aware of — Cmd (pronounced "see em dee") dramatically modifies the kind of control that can be exercised over Linux users. It reaches way beyond the traditional configuration of user privileges and takes an active role in monitoring and controlling the commands that users are able to run on Linux systems. + +Provided by a company of the same name, Cmd focuses on cloud usage. Given the increasing number of applications being migrated into cloud environments that rely on Linux, gaps in the available tools make it difficult to adequately enforce required security. However, Cmd can also be used to manage and protect on-premises systems. + +### How Cmd differs from traditional Linux security controls + +The leaders at Cmd — Milun Tesovic and Jake King — say organizations cannot confidently predict or control user behavior until they understand how users work routinely and what is considered “normal.” They seek to provide a tool that will granularly control, monitor, and authenticate user activity. + +Cmd monitors user activity by forming user activity profiles (characterizing the activities these users generally perform), noticing abnormalities in their online behavior (login times, commands used, user locations, etc.), and preventing and reporting certain activities (e.g., downloading or modifying files and running privileged commands) that suggest some kind of system compromise might be underway. The product's behaviors are configurable and changes can be made rapidly. + +The kind of tools most of us are using today to detect threats, identify vulnerabilities, and control user privileges have taken us a long way, but we are still fighting the battle to keep our systems and data safe. Cmd brings us a lot closer to identifying the intentions of hostile users whether those users are people who have managed to break into accounts or represent insider threats. + +![1 sources live sessions][1] + +View live Linux sessions + +### How does Cmd work? + +In monitoring and managing user activity, Cmd: + + * Collects information that profiles user activity + * Uses the baseline to determine what is considered normal + * Detects and proactively prevents threats using specific indicators + * Sends alerts to responsible people + + + +![2 triggers][3] + +Building custom policies in Cmd + +Cmd goes beyond defining what sysadmins can control through traditional methods, such as configuring sudo privileges, providing much more granular and situation-specific controls. + +Administrators can select escalation policies that can be managed separately from the user privilege controls managed by Linux sysadmins. + +The Cmd agent provides real-time visibility (not after-the-fact log analysis) and can block actions, require additional authentication, or negotiate authorization as needed. + +Also, Cmd supports custom rules based on geolocation if user locations are available. And new policies can be pushed to agents deployed on hosts within minutes. + +![3 command blocked][4] + +Building a trigger query in Cmd + +### Funding news for Cmd + +[Cmd][2] recently got a financial boost, having [completed of a $15 million round of funding][5] led by [GV][6] (formerly Google Ventures) with participation from Expa, Amplify Partners, and additional strategic investors. This brings the company's raised funding to $21.6 million and will help it continue to add new defensive capabilities to the product and grow its engineering teams. + +In addition, the company appointed Karim Faris, general partner at GV, to its board of directors. + +Join the Network World communities on [Facebook][7] and [LinkedIn][8] to comment on topics that are top of mind. + +-------------------------------------------------------------------------------- + +via: https://www.networkworld.com/article/3342454/linux-security-cmd-provides-visibility-control-over-user-activity.html + +作者:[Sandra Henry-Stocker][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/ +[b]: https://github.com/lujun9972 +[1]: https://images.idgesg.net/images/article/2019/02/1-sources-live-sessions-100789431-large.jpg +[2]: https://cmd.com +[3]: https://images.idgesg.net/images/article/2019/02/2-triggers-100789432-large.jpg +[4]: https://images.idgesg.net/images/article/2019/02/3-command-blocked-100789433-large.jpg +[5]: https://www.linkedin.com/pulse/changing-cybersecurity-announcing-cmds-15-million-funding-jake-king/ +[6]: https://www.gv.com/ +[7]: https://www.facebook.com/NetworkWorld/ +[8]: https://www.linkedin.com/company/network-world diff --git a/sources/tech/20190227 How To Check Password Complexity-Strength And Score In Linux.md b/sources/tech/20190227 How To Check Password Complexity-Strength And Score In Linux.md new file mode 100644 index 0000000000..59b18f8a87 --- /dev/null +++ b/sources/tech/20190227 How To Check Password Complexity-Strength And Score In Linux.md @@ -0,0 +1,165 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Check Password Complexity/Strength And Score In Linux?) +[#]: via: (https://www.2daygeek.com/how-to-check-password-complexity-strength-and-score-in-linux/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +How To Check Password Complexity/Strength And Score In Linux? +====== + +We all know the password importance. It’s a best practices to use hard and guess password. + +Also, i advise you to use the different password for each services such as email, ftp, ssh, etc., + +In top of that i suggest you guys to change the password frequently to avoid an unnecessary hacking attempt. + +By default RHEL and it’s clone uses `cracklib` module to check password strength. + +We are going to teach you, how to check the password strength using cracklib module. + +If you would like to check the password score which you have created then use the `pwscore` package. + +If you would like to create a good password, basically it should have minimum 12-15 characters length. + +It should be created in the following combinations like, Alphabets (Lower case & Upper case), Numbers and Special Characters. + +There are many utilities are available in Linux to check a password complexity and we are going to discuss about `cracklib` module today. + +### How To Install cracklib module In Linux? + +The cracklib module is available in most of the distribution repository so, use the distribution official package manager to install it. + +For **`Fedora`** system, use **[DNF Command][1]** to install cracklib. + +``` +$ sudo dnf install cracklib +``` + +For **`Debian/Ubuntu`** systems, use **[APT-GET Command][2]** or **[APT Command][3]** to install libcrack2. + +``` +$ sudo apt install libcrack2 +``` + +For **`Arch Linux`** based systems, use **[Pacman Command][4]** to install cracklib. + +``` +$ sudo pacman -S cracklib +``` + +For **`RHEL/CentOS`** systems, use **[YUM Command][5]** to install cracklib. + +``` +$ sudo yum install cracklib +``` + +For **`openSUSE Leap`** system, use **[Zypper Command][6]** to install cracklib. + +``` +$ sudo zypper install cracklib +``` + +### How To Use The cracklib module In Linux To Check Password Complexity? + +I have added few example in this article to make you understand better about this module. + +If you are given any words like, person name or place name or common word then you will be getting an message “it is based on a dictionary word”. + +``` +$ echo "password" | cracklib-check +password: it is based on a dictionary word +``` + +The default password length in Linux is `Seven` characters. If you give any password less than seven characters then you will be getting an message “it is WAY too short”. + +``` +$ echo "123" | cracklib-check +123: it is WAY too short +``` + +You will be getting `OK` When you give good password like us. + +``` +$ echo "ME$2w!@fgty6723" | cracklib-check +ME!@fgty6723: OK +``` + +### How To Install pwscore In Linux? + +The pwscore package is available in most of the distribution official repository so, use the distribution package manager to install it. + +For **`Fedora`** system, use **[DNF Command][1]** to install libpwquality. + +``` +$ sudo dnf install libpwquality +``` + +For **`Debian/Ubuntu`** systems, use **[APT-GET Command][2]** or **[APT Command][3]** to install libpwquality. + +``` +$ sudo apt install libpwquality +``` + +For **`Arch Linux`** based systems, use **[Pacman Command][4]** to install libpwquality. + +``` +$ sudo pacman -S libpwquality +``` + +For **`RHEL/CentOS`** systems, use **[YUM Command][5]** to install libpwquality. + +``` +$ sudo yum install libpwquality +``` + +For **`openSUSE Leap`** system, use **[Zypper Command][6]** to install libpwquality. + +``` +$ sudo zypper install libpwquality +``` + +If you are given any words like, person name or place name or common word then you will be getting a message “it is based on a dictionary word”. + +``` +$ echo "password" | pwscore +Password quality check failed: + The password fails the dictionary check - it is based on a dictionary word +``` + +The default password length in Linux is `Seven` characters. If you give any password less than seven characters then you will be getting an message “it is WAY too short”. + +``` +$ echo "123" | pwscore +Password quality check failed: + The password is shorter than 8 characters +``` + +You will be getting `password score` When you give good password like us. + +``` +$ echo "ME!@fgty6723" | pwscore +90 +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/how-to-check-password-complexity-strength-and-score-in-linux/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[2]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[3]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[4]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ +[5]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[6]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ diff --git a/sources/tech/20190227 How To Find Available Network Interfaces On Linux.md b/sources/tech/20190227 How To Find Available Network Interfaces On Linux.md new file mode 100644 index 0000000000..e71aa15459 --- /dev/null +++ b/sources/tech/20190227 How To Find Available Network Interfaces On Linux.md @@ -0,0 +1,202 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Find Available Network Interfaces On Linux) +[#]: via: (https://www.ostechnix.com/how-to-find-available-network-interfaces-on-linux/) +[#]: author: (SK https://www.ostechnix.com/author/sk/) + +How To Find Available Network Interfaces On Linux +====== + +![](https://www.ostechnix.com/wp-content/uploads/2019/02/network-interface-720x340.jpeg) + +One of the common task we do after installing a Linux system is network configuration. Of course, you can configure network interfaces during the installation time. But, some of you might prefer to do it after installation or change the existing settings. As you know already, you must first know how many interfaces are available on the system in-order to configure network settings from command line. This brief tutorial addresses all the possible ways to find available network interfaces on Linux and Unix operating systems. + +### Find Available Network Interfaces On Linux + +We can find the available network cards in couple ways. + +**Method 1 – Using ‘ifconfig’ Command:** + +The most commonly used method to find the network interface details is using **‘ifconfig’** command. I believe some of Linux users might still use this. + +``` +$ ifconfig -a +``` + +Sample output: + +``` +enp5s0: flags=4098 mtu 1500 +ether 24:b6:fd:37:8b:29 txqueuelen 1000 (Ethernet) +RX packets 0 bytes 0 (0.0 B) +RX errors 0 dropped 0 overruns 0 frame 0 +TX packets 0 bytes 0 (0.0 B) +TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 + +lo: flags=73 mtu 65536 +inet 127.0.0.1 netmask 255.0.0.0 +inet6 ::1 prefixlen 128 scopeid 0x10 +loop txqueuelen 1000 (Local Loopback) +RX packets 171420 bytes 303980988 (289.8 MiB) +RX errors 0 dropped 0 overruns 0 frame 0 +TX packets 171420 bytes 303980988 (289.8 MiB) +TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 + +wlp9s0: flags=4163 mtu 1500 +inet 192.168.225.37 netmask 255.255.255.0 broadcast 192.168.225.255 +inet6 2409:4072:6183:c604:c218:85ff:fe50:474f prefixlen 64 scopeid 0x0 +inet6 fe80::c218:85ff:fe50:474f prefixlen 64 scopeid 0x20 +ether c0:18:85:50:47:4f txqueuelen 1000 (Ethernet) +RX packets 564574 bytes 628671925 (599.5 MiB) +RX errors 0 dropped 0 overruns 0 frame 0 +TX packets 299706 bytes 60535732 (57.7 MiB) +TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 +``` + +As you see in the above output, I have two network interfaces namely **enp5s0** (on board wired ethernet adapter) and **wlp9s0** (wireless network adapter) on my Linux box. Here, **lo** is loopback interface, which is used to access all network services locally. It has an ip address of 127.0.0.1. + +We can also use the same ‘ifconfig’ command in many UNIX variants, for example **FreeBSD** , to list available network cards. + +**Method 2 – Using ‘ip’ Command:** + +The ‘ifconfig’ command is deprecated in the latest Linux versions. So you can use **‘ip’** command to display the network interfaces as shown below. + +``` +$ ip link show +``` + +Sample output: + +``` +1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 +2: enp5s0: mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000 + link/ether 24:b6:fd:37:8b:29 brd ff:ff:ff:ff:ff:ff +3: wlp9s0: mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000 + link/ether c0:18:85:50:47:4f brd ff:ff:ff:ff:ff:ff +``` + +![](https://www.ostechnix.com/wp-content/uploads/2019/02/ip-command.png) + +You can also use the following commands as well. + +``` +$ ip addr + +$ ip -s link +``` + +Did you notice that these command also shows the connected state of the network interfaces? If you closely look at the above output, you will notice that my Ethernet card is not connected with network cable (see the word **“DOWN”** in the above output). And wireless network card is connected (See the word **“UP”** ). For more details, check our previous guide to [**find the connected state of network interfaces on Linux**][1]. + +These two commands (ifconfig and ip) are just enough to find the available network cards on your Linux systems. + +However, there are few other methods available to list network interfaces on Linux. Here you go. + +**Method 3:** + +The Linux Kernel saves the network interface details inside **/sys/class/net** directory. You can verify the list of available interfaces by looking into this directory. + +``` +$ ls /sys/class/net +``` + +Output: + +``` +enp5s0 lo wlp9s0 +``` + +**Method 4:** + +In Linux operating systems, **/proc/net/dev** file contains statistics about network interfaces. + +To view the available network cards, just view its contents using command: + +``` +$ cat /proc/net/dev +``` + +Output: + +``` +Inter-| Receive | Transmit +face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed +wlp9s0: 629189631 566078 0 0 0 0 0 0 60822472 300922 0 0 0 0 0 0 +enp5s0: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +lo: 303980988 171420 0 0 0 0 0 0 303980988 171420 0 0 0 0 0 0 +``` + +**Method 5: Using ‘netstat’ command** + +The **netstat** command displays various details such as network connections, routing tables, interface statistics, masquerade connections, and multicast memberships. + +``` +$ netstat -i +``` + +**Sample output:** + +``` +Kernel Interface table +Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg +lo 65536 171420 0 0 0 171420 0 0 0 LRU +wlp9s0 1500 565625 0 0 0 300543 0 0 0 BMRU +``` + +Please be mindful that netstat is obsolete. The Replacement for “netstat -i” is “ip -s link”. Also note that this method will list only the active interfaces, not all available interfaces. + +**Method 6: Using ‘nmcli’ command** + +The nmcli is nmcli is a command-line tool for controlling NetworkManager and reporting network status. It is used to create, display, edit, delete, activate, and deactivate network connections and display network status. + +If you have Linux system with Network Manager installed, you can list the available network interfaces using nmcli tool using the following commands: + +``` +$ nmcli device status +``` + +Or, + +``` +$ nmcli connection show +``` + +You know now how to find the available network interfaces on Linux. Next, check the following guides to know how to configure IP address on Linux. + +[How To Configure Static IP Address In Linux And Unix][2] + +[How To Configure IP Address In Ubuntu 18.04 LTS][3] + +[How To Configure Static And Dynamic IP Address In Arch Linux][4] + +[How To Assign Multiple IP Addresses To Single Network Card In Linux][5] + +If you know any other quick ways to do it, please share them in the comment section below. I will check and update the guide with your inputs. + +And, that’s all. More good stuffs to come. Stay tuned! + +Cheers! + + + +-------------------------------------------------------------------------------- + +via: https://www.ostechnix.com/how-to-find-available-network-interfaces-on-linux/ + +作者:[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/how-to-find-out-the-connected-state-of-a-network-cable-in-linux/ +[2]: https://www.ostechnix.com/configure-static-ip-address-linux-unix/ +[3]: https://www.ostechnix.com/how-to-configure-ip-address-in-ubuntu-18-04-lts/ +[4]: https://www.ostechnix.com/configure-static-dynamic-ip-address-arch-linux/ +[5]: https://www.ostechnix.com/how-to-assign-multiple-ip-addresses-to-single-network-card-in-linux/ diff --git a/sources/tech/20190227 How to Display Weather Information in Ubuntu 18.04.md b/sources/tech/20190227 How to Display Weather Information in Ubuntu 18.04.md new file mode 100644 index 0000000000..da0c0df203 --- /dev/null +++ b/sources/tech/20190227 How to Display Weather Information in Ubuntu 18.04.md @@ -0,0 +1,290 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Display Weather Information in Ubuntu 18.04) +[#]: via: (https://itsfoss.com/display-weather-ubuntu) +[#]: author: (Sergiu https://itsfoss.com/author/sergiu/) + +How to Display Weather Information in Ubuntu 18.04 +====== + +You’ve got a fresh Ubuntu install and you’re [customizing Ubuntu][1] to your liking. You want the best experience and the best apps for your needs. + +The only thing missing is a weather app. Luckily for you, we got you covered. Just make sure you have the Universe repository enabled. + +![Tools to Display Weather Information in Ubuntu Linux][2] + +### 8 Ways to Display Weather Information in Ubuntu 18.04 + +Back in the Unity days, there were a few popular options like My Weather Indicator to display weather on your system. Those options are either discontinued or not available in Ubuntu 18.04 and higher versions anymore. + +Fortunately, there are many other options to choose from. Some are minimalist and plain simple to use, some offer detailed information (or even present you with news headlines) and some are made for terminal gurus. Whatever your needs may be, the right app is waiting for you. + +**Note:** The presented apps are in no particular order of ranking. + +**Top Panel Apps** + +These applications usually sit on the top panel of your screen. Good for quick look at the temperature. + +#### 1\. OpenWeather Shell Extension + +![Open Weather Gnome Shell Extesnsion][3] + +**Key features:** + + * Simple to install and customize + * Uses OpenWeatherMap (by default) + * Many Units and Layout options + * Can save multiple locations (that can easily be changed) + + + +This is a great extension presenting you information in a simple manner. There are multiple ways to install this. It is the weather app that I find myself using the most, because it’s just a simple, no-hassle integrated weather display for the top panel. + +**How to Install:** + +I recommend reading this [detailed tutorial about using GNOME extensions][4]. The easiest way to install this extension is to open up a terminal and run: + +``` +sudo apt install gnome-shell-extension-weather +``` + +Then all you have to restart the gnome shell by executing: + +``` +Alt+F2 +``` + +Enter **r** and press **Enter**. + +Now open up **Tweaks** (gnome tweak tool) and enable **Openweather** in the **Extensions** tab. + +#### 2\. gnome-weather + +![Gnome Weather App UI][5] +![Gnome Weather App Top Panel][6] + +**Key features:** + + * Pleasant Design + * Integrated into Calendar (Top Panel) + * Simple Install + * Flatpak install available + + + +This app is great for new users. The installation is only one command and the app is easy to use. Although it doesn’t have as many features as other apps, it is still great if you don’t want to bother with multiple settings and a complex install procedure. + +**How to Install:** + +All you have to do is run: + +``` +sudo apt install gnome-weather +``` + +Now search for **Weather** and the app should pop up. After logging out (and logging back in), the Calendar extension will be displayed. + +If you prefer, you can get a [flatpak][7] version. + +#### 3\. Meteo + +![Meteo Weather App UI][8] +![Meteo Weather System Tray][9] + +**Key features:** + + * Great UI + * Integrated into System Tray (Top Panel) + * Simple Install + * Great features (Maps) + + + +Meteo is a snap app on the heavier side. Most of that weight comes from the great Maps features, with maps presenting temperatures, clouds, precipitations, pressure and wind speed. It’s a distinct feature that I haven’t encountered in any other weather app. + +**Note** : After changing location, you might have to quit and restart the app for the changes to be applied in the system tray. + +**How to Install:** + +Open up the **Ubuntu Software Center** and search for **Meteo**. Install and launch. + +**Desktop Apps** + +These are basically desktop widgets. They look good and provide more information at a glance. + +#### 4\. Temps + +![Temps Weather App UI][10] + +**Key features:** + + * Beautiful Design + * Useful Hotkeys + * Hourly Temperature Graph + + + +Temps is an electron app with a beautiful UI (though not exactly “light”). The most unique features are the temperature graphs. The hotkeys might feel unintuitive at first, but they prove to be useful in the long run. The app will minimize when you click somewhere else. Just press Ctrl+Shift+W to bring it back. + +This app is **Open-Source** , and the developer can’t afford the cost of a faster API key, so you might want to create your own API at [OpenWeatherMap][11]. + +**How to Install:** + +Go to the website and download the version you need (probably 64-bit). Extract the archive. Open the extracted directory and double-click on **Temps**. Press Ctrl+Shift+W if the window minimizes. + +#### 5\. Cumulus + +![Cumulus Weather App UI][12] + +**Key features:** + + * Color Selector for background and text + + * Re-sizable window + + * Tray Icon (temperature only) + + * Allows multiple instances with different locations etc. + + + + +Cumulus is a greatly customizable weather app, with a backend supporting Yahoo! Weather and OpenWeatherMap. The UI is great and the installer is simple to use. This app has amazing features. It’s one of the few weather apps that allow for multiple instances. You should definitely try it you are looking for an experience tailored to your preferences. + +**How to Install:** + +Go to the website and download the (online) installer. Open up a terminal and **cd** (change directory) to the directory where you downloaded the file. + +Then run + +``` +chmod +x Cumulus-online-installer-x64 +./Cumulus-online-installer-x64 +``` + +Search for **Cumulus** and enjoy the app! + +**Terminal Apps** + +You are a terminal dweller? You can check the weather right in your terminal. + +#### 7\. WeGo + +![WeGo Weather App Terminal][13] + +**Key features:** + + * Supports different APIs + * Pretty detailed + * Customizable config + * Multi-language support + * 1 to 7 day forecast + + + +WeGo is a Go app for displaying weather info in the terminal. It’s install can be a little tricky, but it’s easy to set up. You’ll need to register an API Key [here][14] (if using **forecast.io** , which is default). Once you set it up, it’s fairly practical for someone who mostly works in the terminal. + +**How to Install:** + +I recommend you to check out the GitHub page for complete information on installation, setup and features. + +#### 8\. Wttr.in + +![Wttr.in Weather App Terminal][15] + +**Key features:** + + * Simple install + * Easy to use + * Lightweight + * 3 day forecast + * Moon phase + + + +If you really live in the terminal, this is the weather app for you. This is as lightweight as it gets. You can specify location (by default the app tries to detect your current location) and a few other parameters (eg. units). + +**How to Install:** + +Open up a terminal and install Curl: + +``` +sudo apt install curl +``` + +Then: + +``` +curl wttr.in +``` + +That’s it. You can specify location and parameters like so: + +``` +curl wttr.in/london?m +``` + +To check out other options type: + +``` +curl wttr.in/:help +``` + +If you found some settings you enjoy and you find yourself using them frequently, you might want to add an **alias**. To do so, open **~/.bashrc** with your favorite editor (that’s **vim** , terminal wizard). Go to the end and paste in + +``` +alias wttr='curl wttr.in/CITY_NAME?YOUR_PARAMS' +``` + +For example: + +``` +alias wttr='curl wttr.in/london?m' +``` + +Save and close **~/.bashrc** and run the command below to source the new file. + +``` +source ~/.bashrc +``` + +Now, typing **wttr** in the terminal and pressing Enter should execute your custom command. + +**Wrapping Up** + +These are a handful of the weather apps available for Ubuntu. We hope our list helped you discover an app fitting your needs, be that something with pleasant aesthetics or just a quick tool. + +What is your favorite weather app? Tell us about what you enjoy and why in the comments section. + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/display-weather-ubuntu + +作者:[Sergiu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sergiu/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/gnome-tricks-ubuntu/ +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/display-weather-ubuntu.png?resize=800%2C450&ssl=1 +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/open_weather_gnome_shell-1-1.jpg?fit=800%2C383&ssl=1 +[4]: https://itsfoss.com/gnome-shell-extensions/ +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/gnome_weather_ui.jpg?fit=800%2C599&ssl=1 +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/gnome_weather_top_panel.png?fit=800%2C587&ssl=1 +[7]: https://flatpak.org/ +[8]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/meteo_ui.jpg?fit=800%2C547&ssl=1 +[9]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/meteo_system_tray.png?fit=800%2C653&ssl=1 +[10]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/temps_ui.png?fit=800%2C623&ssl=1 +[11]: https://openweathermap.org/ +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/cumulus_ui.png?fit=800%2C651&ssl=1 +[13]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/wego_terminal.jpg?fit=800%2C531&ssl=1 +[14]: https://developer.forecast.io/register +[15]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/wttr_in_terminal.jpg?fit=800%2C526&ssl=1 diff --git a/sources/tech/20190228 3 open source behavior-driven development tools.md b/sources/tech/20190228 3 open source behavior-driven development tools.md new file mode 100644 index 0000000000..9c004a14c2 --- /dev/null +++ b/sources/tech/20190228 3 open source behavior-driven development tools.md @@ -0,0 +1,83 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (3 open source behavior-driven development tools) +[#]: via: (https://opensource.com/article/19/2/behavior-driven-development-tools) +[#]: author: (Christine Ketterlin Fisher https://opensource.com/users/cketterlin) + +3 open source behavior-driven development tools +====== +Having the right motivation is as important as choosing the right tool when implementing BDD. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_code_keyboard_orange_hands.png?itok=G6tJ_64Y) + +[Behavior-driven development][1] (BDD) seems very easy. Tests are written in an easily readable format that allows for feedback from product owners, business sponsors, and developers. Those tests are living documentation for your team, so you don't need requirements. The tools are easy to use and allow you to automate your test suite. Reports are generated with each test run to document every step and show you where tests are failing. + +Quick recap: Easily readable! Living documentation! Automation! Reports! What could go wrong, and why isn't everybody doing this? + +### Getting started with BDD + +So, you're ready to jump in and can't wait to pick the right open source tool for your team. You want it to be easy to use, automate all your tests, and provide easily understandable reports for each test run. Great, let's get started! + +Except, not so fast … First, what is your motivation for trying to implement BDD on your team? If the answer is simply to automate tests, go ahead and choose any of the tools listed below because chances are you're going to see minimal success in the long run. + +### My first effort + +I manage a team of business analysts (BA) and quality assurance (QA) engineers, but my background is on the business analysis side. About a year ago, I attended a talk where a developer talked about the benefits of BDD. He said that he and his team had given it a try during their last project. That should have been the first red flag, but I didn't realize it at the time. You cannot simply choose to "give BDD a try." It takes planning, preparation, and forethought into what you want your team to accomplish. + +However, you can try various parts of BDD without a large investment, and I eventually realized he and his team had written feature files and automated those tests using Cucumber. I also learned it was an experiment done solely by the team's developers, not the BA or QA staff, which defeats the purpose of understanding the end user's behavior. + +During the talk we were encouraged to try BDD, so my test analyst and I went to our boss and said we were willing to give it a shot. And then, we didn't know what to do. We had no guidance, no plan in place, and a leadership team who just wanted to automate testing. I don't think I need to tell you how this story ended. Actually, there wasn't even an end, just a slow fizzle after a few initial attempts at writing behavioral scenarios. + +### A fresh start + +Fast-forward a year, and I'm at a different company with a team of my own and BDD on the brain. I knew there was value there, but I also knew it went deeper than what I had initially been sold. I spent a lot of time thinking about how BDD could make a positive impact, not only on my team, but on our entire development team. Then I read [Discovery: Explore Behaviour Using Examples][2] by Gaspar Nagy and Seb Rose, and one of the first things I learned was that automation of tests is a benefit of BDD, but it should not be the main goal. No wonder we failed! + +This book changed how I viewed BDD and helped me start to fill in the pieces I had been missing. We are now on the (hopefully correct!) path to implementing BDD on our team. It involves active involvement from our product owners, business analysts, and manual and automated testers and buy-in and support from our executive leadership. We have a plan in place for our approach and our measures of success. + +We are still writing requirements (don't ever let anyone tell you that these scenarios can completely replace requirements!), but we are doing so with a more critical eye and evaluating where requirements and test scenarios overlap and how we can streamline the two. + +I have told the team we cannot even try to automate these tests for at least two quarters, at which point we'll evaluate and determine whether we're ready to move forward or not. Our current priorities are defining our team's standard language, practicing writing given/when/then scenarios, learning the Gherkin syntax, determining where to store these tests, and investigating how to integrate these tests into our pipeline. + +### 3 BDD tools to choose + +At its core, BDD is a way to help the entire team understand the end user's actions and behaviors, which will lead to more clear requirements, tests, and ultimately higher-quality applications. Before you pick your tool, do your pre-work. Think about your motivation, and understand that while the different parts and pieces of BDD are fairly simple, integrating them into your team is more challenging and needs careful thought and planning. Also, think about where your people fit in. + +Every organization has different roles, and BDD should not belong solely to developers nor test automation engineers. If you don't involve the business side, you're never going to gain the full benefit of this methodology. Once you have a strategy defined and are ready to move forward with automating your BDD scenarios, there are several open source tools for you to choose from. + +#### Cucumber + +[Cucumber][3] is probably the most recognized tool available that supports BDD. It is widely seen as a straightforward tool to learn and is easy to get started with. Cucumber relies on test scenarios that are written in plain text and follow the given/when/then format. Each scenario is an individual test. Scenarios are grouped into features, which is comparable to a test suite. Scenarios must be written in the Gherkin syntax for Cucumber to understand and execute the scenario's steps. The human-readable steps in the scenarios are tied to the step definitions in your code through the Cucumber framework. To successfully write and automate the scenarios, you need the right mix of business knowledge and technical ability. Identify the skill sets on your team to determine who will write and maintain the scenarios and who will automate them; most likely these should be managed by different roles. Because these tests are executed from the step definitions, reporting is very robust and can show you at which exact step your test failed. Cucumber works well with a variety of browser and API automation tools. + +#### JBehave + +[JBehave][4] is very similar to Cucumber. Scenarios are still written in the given/when/then format and are easily understandable by the entire team. JBehave supports Gherkin but also has its own JBehave syntax that can be used. Gherkin is more universal, but either option will work as long as you are consistent in your choice. JBehave has more configuration options than Cucumber, and its reports, although very detailed, need more configuration to get feedback from each step. JBehave is a powerful tool, but because it can be more customized, it is not quite as easy to get started with. Teams need to ask themselves exactly what features they need and whether or not learning the tool's various configurations is worth the time investment. + +#### Gauge + +Where Cucumber and JBehave are specifically designed to work with BDD, [Gauge][5] is not. If automation is your main goal (and not the entire BDD process), it is worth a look. Gauge tests are written in Markdown, which makes them easily readable. However, without a more standard format, such as the given/when/then BDD scenarios, tests can vary widely and, depending on the author, some tests will be much more digestible for business owners than others. Gauge works with multiple languages, so the automation team can leverage what they already use. Gauge also offers reporting with screenshots to show where the tests failed. + +### What are your needs? + +Implementing BDD allows the team to test the users' behaviors. This can be done without automating any tests at all, but when done correctly, can result in a powerful, reusable test suite. As a team, you will need to identify exactly what your automation needs are and whether or not you are truly going to use BDD or if you would rather focus on automating tests that are written in plain text. Either way, open source tools are available for you to use and to help support your testing evolution. + + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/2/behavior-driven-development-tools + +作者:[Christine Ketterlin Fisher][a] +选题:[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/cketterlin +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Behavior-driven_development +[2]: https://www.amazon.com/gp/product/1983591254/ref=dbs_a_def_rwt_bibl_vppi_i0 +[3]: https://cucumber.io/ +[4]: https://jbehave.org/ +[5]: https://www.gauge.org/ diff --git a/sources/tech/20190228 Connecting a VoIP phone directly to an Asterisk server.md b/sources/tech/20190228 Connecting a VoIP phone directly to an Asterisk server.md new file mode 100644 index 0000000000..07027a097d --- /dev/null +++ b/sources/tech/20190228 Connecting a VoIP phone directly to an Asterisk server.md @@ -0,0 +1,75 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Connecting a VoIP phone directly to an Asterisk server) +[#]: via: (https://feeding.cloud.geek.nz/posts/connecting-voip-phone-directly-to-asterisk-server/) +[#]: author: (François Marier https://fmarier.org/) + +Connecting a VoIP phone directly to an Asterisk server +====== + +On my [Asterisk][1] server, I happen to have two on-board ethernet boards. Since I only used one of these, I decided to move my VoIP phone from the local network switch to being connected directly to the Asterisk server. + +The main advantage is that this phone, running proprietary software of unknown quality, is no longer available on my general home network. Most importantly though, it no longer has access to the Internet, without my having to firewall it manually. + +Here's how I configured everything. + +### Private network configuration + +On the server, I started by giving the second network interface a static IP address in `/etc/network/interfaces`: + +``` +auto eth1 +iface eth1 inet static + address 192.168.2.2 + netmask 255.255.255.0 +``` + +On the VoIP phone itself, I set the static IP address to `192.168.2.3` and the DNS server to `192.168.2.2`. I then updated the SIP registrar IP address to `192.168.2.2`. + +The DNS server actually refers to an [unbound daemon][2] running on the Asterisk server. The only configuration change I had to make was to listen on the second interface and allow the VoIP phone in: + +``` +server: + interface: 127.0.0.1 + interface: 192.168.2.2 + access-control: 0.0.0.0/0 refuse + access-control: 127.0.0.1/32 allow + access-control: 192.168.2.3/32 allow +``` + +Finally, I opened the right ports on the server's firewall in `/etc/network/iptables.up.rules`: + +``` +-A INPUT -s 192.168.2.3/32 -p udp --dport 5060 -j ACCEPT +-A INPUT -s 192.168.2.3/32 -p udp --dport 10000:20000 -j ACCEPT +``` + +### Accessing the admin page + +Now that the VoIP phone is no longer available on the local network, it's not possible to access its admin page. That's a good thing from a security point of view, but it's somewhat inconvenient. + +Therefore I put the following in my `~/.ssh/config` to make the admin page available on `http://localhost:8081` after I connect to the Asterisk server via ssh: + +``` +Host asterisk + LocalForward 8081 192.168.2.3:80 +``` + +-------------------------------------------------------------------------------- + +via: https://feeding.cloud.geek.nz/posts/connecting-voip-phone-directly-to-asterisk-server/ + +作者:[François Marier][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fmarier.org/ +[b]: https://github.com/lujun9972 +[1]: https://www.asterisk.org/ +[2]: https://feeding.cloud.geek.nz/posts/setting-up-your-own-dnssec-aware/ diff --git a/sources/tech/20190228 MiyoLinux- A Lightweight Distro with an Old-School Approach.md b/sources/tech/20190228 MiyoLinux- A Lightweight Distro with an Old-School Approach.md new file mode 100644 index 0000000000..3217e304cd --- /dev/null +++ b/sources/tech/20190228 MiyoLinux- A Lightweight Distro with an Old-School Approach.md @@ -0,0 +1,161 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (MiyoLinux: A Lightweight Distro with an Old-School Approach) +[#]: via: (https://www.linux.com/blog/learn/2019/2/miyolinux-lightweight-distro-old-school-approach) +[#]: author: (Jack Wallen https://www.linux.com/users/jlwallen) + +MiyoLinux: A Lightweight Distro with an Old-School Approach +====== +![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/miyo_main.jpg?itok=ErLiqGwp) + +I must confess, although I often wax poetic about the old ways of the Linux desktop, I much prefer my distributions to help make my daily workflow as efficient as possible. Because of that, my taste in Linux desktop distributions veers very far toward the modern side of things. I want a distribution that integrates apps seamlessly, gives me notifications, looks great, and makes it easy to work with certain services that I use. + +However, every so often it’s nice to dip my toes back into those old-school waters and remind myself why I fell in love with Linux in the first place. That’s precisely what [MiyoLinux][1] did for me recently. This lightweight distribution is based on [Devuan][2] and makes use of the [i3 Tiling Window Manager][3]. + +Why is it important that MiyoLinux is based on Devuan? Because that means it doesn’t use systemd. There are many within the Linux community who’d be happy to make the switch to an old-school Linux distribution that opts out of systemd. If that’s you, MiyoLinux might just charm you into submission. + +But don’t think MiyoLinux is going to be as easy to get up and running as, say, Ubuntu Linux, Elementary OS, or Linux Mint. Although it’s not nearly as challenging as Arch or Gentoo, MiyoLinux does approach installation and basic usage a bit differently. Let’s take a look at how this particular distro handles things. + +### Installation + +The installation GUI of MiyoLinux is pretty basic. The first thing you’ll notice is that you are presented with a good amount of notes, regarding the usage of the MiyoLinux desktop. If you happen to be testing MiyoLinux via VirtualBox, you’ll wind up having to deal with the frustration of not being able to resize the window (Figure 1), as the Guest Additions cannot be installed. This also means mouse integration cannot be enabled during the installation, so you’ll have to tab through the windows and use your keyboard cursor keys and Enter key to make selections. + +![MiyoLinux][5] + +Figure 1: The first step in the MiyoLinux installation. + +[Used with permission][6] + +Once you click the Install MiyoLinux button, you’ll be prompted to continue using either ‘su” or sudo. Click the use sudo button to continue with the installation. + +The next screen of importance is the Installation Options window (Figure 2), where you can select various options for MiyoLinux (such as encryption, file system labels, disable automatic login, etc.). + +![Configuration][8] + +Figure 2: Configuration Installation options for MiyoLinux. + +[Used with permission][6] + +The MiyoLinux installation does not include an automatic partition tool. Instead, you’ll be prompted to run either cfdisk or GParted (Figure 3). If you don’t know your way around cfdisk, select GParted and make use of the GUI tool. + +![partitioning ][10] + +Figure 3: Select your partitioning tool for MiyoLinux. + +[Used with permission][6] + +With your disk partitioned (Figure 4), you’ll be required to take care of the following steps: + + * Configure the GRUB bootloader. + + * Select the filesystem for the bootloader. + + * Configure time zone and locales. + + * Configure keyboard, keyboard language, and keyboard layout. + + * Okay the installation. + + + + +Once, you’ve okay’d the installation, all packages will be installed and you will then be prompted to install the bootloader. Following that, you’ll be prompted to configure the following: + + * Hostname. + + * User (Figure 5). + + * Root password. + + + + +With the above completed, reboot and log into your new MiyoLinux installation. + +![hostname][12] + +Figure 5: Configuring hostname and username. + +[Creative Commons Zero][13] + +### Usage + +Once you’ve logged into the MiyoLinux desktop, you’ll find things get a bit less-than-user-friendly. This is by design. You won’t find any sort of mouse menu available anywhere on the desktop. Instead you use keyboard shortcuts to open the different types of menus. The Alt+m key combination will open the PMenu, which is what one would consider a fairly standard desktop mouse menu (Figure 6). + +The Alt+d key combination will open the dmenu, a search tool at the top of the desktop, where you can scroll through (using the cursor keys) or search for an app you want to launch (Figure 7). + +![dmenu][15] + +Figure 7: The dmenu in action. + +[Used with permission][6] + +### Installing Apps + +If you open the PMenu, click System > Synaptic Package Manager. From within that tool you can search for any app you want to install. However, if you find Synaptic doesn’t want to start from the PMenu, open the dmenu, search for terminal, and (once the terminal opens), issue the command sudo synaptic. That will get the package manager open, where you can start installing any applications you want (Figure 8). + +![Synaptic][17] + +Figure 8: The Synaptic Package Manager on MiyoLinux. + +[Used with permission][6] + +Of course, you can always install applications from the command line. MiyoLinux depends upon the Apt package manager, so installing applications is as easy as: + +``` +sudo apt-get install libreoffice -y +``` + +Once installed, you can start the new package from either the PMenu or dmenu tools. + +### MiyoLinux Accessories + +If you find you need a bit more from the MiyoLinux desktop, type the keyboard combination Alt+Ctrl+a to open the MiyoLinux Accessories tool (Figure 9). From this tool you can configure a number of options for the desktop. + +![Accessories][19] + +Figure 9: Configure i3, Conky, Compton, your touchpad, and more with the Accessories tool. + +[Used with permission][6] + +All other necessary keyboard shortcuts are listed on the default desktop wallpaper. Make sure to put those shortcuts to memory, as you won’t get very far in the i3 desktop without them. + +### A Nice Nod to Old-School Linux + +If you’re itching to throw it back to a time when Linux offered you a bit of challenge to your daily grind, MiyoLinux might be just the operating system for you. It’s a lightweight operating system that makes good use of a minimal set of tools. Anyone who likes their distributions to be less modern and more streamlined will love this take on the Linux desktop. However, if you prefer your desktop with the standard bells and whistles, found on modern distributions, you’ll probably find MiyoLinux nothing more than a fun distraction from the standard fare. + +-------------------------------------------------------------------------------- + +via: https://www.linux.com/blog/learn/2019/2/miyolinux-lightweight-distro-old-school-approach + +作者:[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://sourceforge.net/p/miyolinux/wiki/Home/ +[2]: https://devuan.org/ +[3]: https://i3wm.org/ +[4]: /files/images/miyo1jpg +[5]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/miyo_1.jpg?itok=5PxRDYRE (MiyoLinux) +[6]: /licenses/category/used-permission +[7]: /files/images/miyo2jpg +[8]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/miyo_2.jpg?itok=svlVr7VI (Configuration) +[9]: /files/images/miyo3jpg +[10]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/miyo_3.jpg?itok=lpNzZBPz (partitioning) +[11]: /files/images/miyo5jpg +[12]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/miyo_5.jpg?itok=lijIsgZ2 (hostname) +[13]: /licenses/category/creative-commons-zero +[14]: /files/images/miyo7jpg +[15]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/miyo_7.jpg?itok=I8Ow3PX6 (dmenu) +[16]: /files/images/miyo8jpg +[17]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/miyo_8.jpg?itok=oa502KfM (Synaptic) +[18]: /files/images/miyo9jpg +[19]: https://www.linux.com/sites/lcom/files/styles/rendered_file/public/miyo_9.jpg?itok=gUM4mxEv (Accessories) diff --git a/sources/tech/20190301 Guide to Install VMware Tools on Linux.md b/sources/tech/20190301 Guide to Install VMware Tools on Linux.md new file mode 100644 index 0000000000..e6a43bcde1 --- /dev/null +++ b/sources/tech/20190301 Guide to Install VMware Tools on Linux.md @@ -0,0 +1,143 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Guide to Install VMware Tools on Linux) +[#]: via: (https://itsfoss.com/install-vmware-tools-linux) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Guide to Install VMware Tools on Linux +====== + +**VMware Tools enhances your VM experience by allowing you to share clipboard and folder among other things. Learn how to install VMware tools on Ubuntu and other Linux distributions.** + +In an earlier tutorial, you learned to [install VMware Workstation on Ubuntu][1]. You can further enhance the functionality of your virtual machines by installing VMware Tools. + +If you have already installed a guest OS on VMware, you must have noticed the requirement for [VMware tools][2] – even though not completely aware of what it is needed for. + +In this article, we will highlight the importance of VMware tools, the features it offers, and the method to install VMware tools on Ubuntu or any other Linux distribution. + +### VMware Tools: Overview & Features + +![Installing VMware Tools on Ubuntu][3]Installing VMware Tools on Ubuntu + +For obvious reasons, the virtual machine (your Guest OS) will not behave exactly like the host. There will be certain limitations in terms of its performance and operationg. And, that is why a set of utilities (VMware Tools) was introduced. + +VMware tools help in managing the guest OS in an efficient manner while also improving its performance. + +#### What exactly is VMware tool responsible for? + +![How to Install VMware tools on Linux][4] + +You have got a vague idea of what it does – but let us talk about the details: + + * Synchronize the time between the guest OS and the host to make things easier. + * Unlocks the ability to pass messages from host OS to guest OS. For example, you copy a text on the host to your clipboard and you can easily paste it to your guest OS. + * Enables sound in guest OS. + * Improves video resolution. + * Improves the cursor movement. + * Fixes incorrect network speed data. + * Eliminates inadequate color depth. + + + +These are the major changes that happen when you install VMware tools on Guest OS. But, what exactly does it contain / feature in order to unlock/enhance these functionalities? Let’s see.. + +#### VMware tools: Core Feature Details + +![Sharing clipboard between guest and host OS with VMware Tools][5]Sharing clipboard between guest and host OS with VMware Tools + +If you do not want to know what it includes to enable the functionalities, you can skip this part. But, for the curious readers, let us briefly discuss about it: + +**VMware device drivers:** It really depends on the OS. Most of the major operating systems do include device drivers by default. So, you do not have to install it separately. This generally involves – memory control driver, mouse driver, audio driver, NIC driver, VGA driver and so on. + +**VMware user process:** This is where things get really interesting. With this, you get the ability to copy-paste and drag-drop between the host and the guest OS. You can basically copy and paste the text from the host to the virtual machine or vice versa. + +You get to drag and drop files as well. In addition, it enables the pointer release/lock when you do not have an SVGA driver installed. + +**VMware tools lifecycle management** : Well, we will take a look at how to install VMware tools below – but this feature helps you easily install/upgrade VMware tools in the virtual machine. + +**Shared Folders** : In addition to these, VMware tools also allow you to have shared folders between the guest OS and the host. + +![Sharing folder between guest and host OS using VMware Tools in Linux][6]Sharing folder between guest and host OS using VMware Tools in Linux + +Of course, what it does and facilitates also depends on the host OS. For example, on Windows, you get a Unity mode on VMware to run programs on virtual machine and operate it from the host OS. + +### How to install VMware Tools on Ubuntu & other Linux distributions + +**Note:** For Linux guest operating systems, you should already have “Open VM Tools” suite installed, eliminating the need of installing VMware tools separately, most of the time. + +Most of the time, when you install a guest OS, you will get a prompt as a software update or a popup telling you to install VMware tools if the operating system supports [Easy Install][7]. + +Windows and Ubuntu does support Easy Install. So, even if you are using Windows as your host OS or trying to install VMware tools on Ubuntu, you should first get an option to install the VMware tools easily as popup message. Here’s how it should look like: + +![Pop-up to install VMware Tools][8]Pop-up to install VMware Tools + +This is the easiest way to get it done. So, make sure you have an active network connection when you setup the virtual machine. + +If you do not get any of these pop ups – or options to easily install VMware tools. You have to manually install it. Here’s how to do that: + +1\. Launch VMware Workstation Player. + +2\. From the menu, navigate through **Virtual Machine - > Install VMware tools**. If you already have it installed, and want to repair the installation, you will observe the same option to appear as “ **Re-install VMware tools** “. + +3\. Once you click on that, you will observe a virtual CD/DVD mounted in the guest OS. + +4\. Open that and copy/paste the **tar.gz** file to any location of your choice and extract it, here we choose the **Desktop**. + +![][9] + +5\. After extraction, launch the terminal and navigate to the folder inside by typing in the following command: + +``` +cd Desktop/VMwareTools-10.3.2-9925305/vmware-tools-distrib +``` + +You need to check the name of the folder and path in your case – depending on the version and where you extracted – it might vary. + +![][10] + +Replace **Desktop** with your storage location (such as cd Downloads) and the rest should remain the same if you are installing **10.3.2 version**. + +6\. Now, simply type in the following command to start the installation: + +``` +sudo ./vmware-install.pl -d +``` + +![][11] + +You will be asked the password for permission to install, type it in and you should be good to go. + +That’s it. You are done. These set of steps should be applicable to almost any Ubuntu-based guest operating system. If you want to install VMware tools on Ubuntu Server, or any other OS. + +**Wrapping Up** + +Installing VMware tools on Ubuntu Linux is pretty easy. In addition to the easy method, we have also explained the manual method to do it. If you still need help, or have a suggestion regarding the installation, let us know in the comments down below. + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-vmware-tools-linux + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://itsfoss.com/install-vmware-player-ubuntu-1310/ +[2]: https://kb.vmware.com/s/article/340 +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmware-tools-downloading.jpg?fit=800%2C531&ssl=1 +[4]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/03/install-vmware-tools-linux.png?resize=800%2C450&ssl=1 +[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmware-tools-features.gif?resize=800%2C500&ssl=1 +[6]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmware-tools-shared-folder.jpg?fit=800%2C660&ssl=1 +[7]: https://docs.vmware.com/en/VMware-Workstation-Player-for-Linux/15.0/com.vmware.player.linux.using.doc/GUID-3F6B9D0E-6CFC-4627-B80B-9A68A5960F60.html +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmware-tools.jpg?fit=800%2C481&ssl=1 +[9]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmware-tools-extraction.jpg?fit=800%2C564&ssl=1 +[10]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmware-tools-folder.jpg?fit=800%2C487&ssl=1 +[11]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/vmware-tools-installation-ubuntu.jpg?fit=800%2C492&ssl=1 diff --git a/sources/tech/20190301 How to use sudo access in winSCP.md b/sources/tech/20190301 How to use sudo access in winSCP.md new file mode 100644 index 0000000000..a2821fefab --- /dev/null +++ b/sources/tech/20190301 How to use sudo access in winSCP.md @@ -0,0 +1,61 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to use sudo access in winSCP) +[#]: via: (https://kerneltalks.com/tools/how-to-use-sudo-access-in-winscp/) +[#]: author: (kerneltalks https://kerneltalks.com) + +How to use sudo access in winSCP +====== + +Learn how to use sudo access in winSCP with screenshots. + +![How to use sudo access in winSCP][1]sudo access in winSCP + +First of all you need to check where is your SFTP server binary located on server you are trying to connect with winSCP. + +You can check SFTP server binary location with below command – + +``` +[root@kerneltalks ~]# cat /etc/ssh/sshd_config |grep -i sftp-server +Subsystem sftp /usr/libexec/openssh/sftp-server +``` + +Here you can see sftp server binary is located at `/usr/libexec/openssh/sftp-server` + +Now open winSCP and click `Advanced` button to open up advanced settings. + +![winSCP advance settings][2] +winSCP advance settings + +It will open up advanced setting window like one below. Here select `SFTP `under `Environment` on left hand side panel. You will be presented with option on right hand side. + +Now, add SFTP server value here with command `sudo su -c` here as displayed in screenshot below – + +![SFTP server setting in winSCP][3] +SFTP server setting in winSCP + +So we added `sudo su -c /usr/libexec/openssh/sftp-server` in settings here. Now click Ok and connect to server as you normally do. + +After connection you will be able to transfer files from directory where you normally need sudo permission to access. + +That’s it! You logged to server using winSCP and sudo access. + +-------------------------------------------------------------------------------- + +via: https://kerneltalks.com/tools/how-to-use-sudo-access-in-winscp/ + +作者:[kerneltalks][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://kerneltalks.com +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/kerneltalks.com/wp-content/uploads/2019/03/How-to-use-sudo-access-in-winSCP.png?ssl=1 +[2]: https://i0.wp.com/kerneltalks.com/wp-content/uploads/2019/03/winscp-advanced-settings.jpg?ssl=1 +[3]: https://i1.wp.com/kerneltalks.com/wp-content/uploads/2019/03/SFTP-server-setting-in-winSCP.jpg?ssl=1 diff --git a/sources/tech/20190302 Create a Custom System Tray Indicator For Your Tasks on Linux.md b/sources/tech/20190302 Create a Custom System Tray Indicator For Your Tasks on Linux.md new file mode 100644 index 0000000000..d9d42b7a2f --- /dev/null +++ b/sources/tech/20190302 Create a Custom System Tray Indicator For Your Tasks on Linux.md @@ -0,0 +1,187 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Create a Custom System Tray Indicator For Your Tasks on Linux) +[#]: via: (https://fosspost.org/tutorials/custom-system-tray-icon-indicator-linux) +[#]: author: (M.Hanny Sabbagh https://fosspost.org/author/mhsabbagh) + +Create a Custom System Tray Indicator For Your Tasks on Linux +====== + +System Tray icons are still considered to be an amazing functionality today. By just right-clicking on the icon, and then selecting which actions you would like to take, you may ease your life a lot and save many unnecessary clicks on daily basis. + +When talking about useful system tray icons, examples like Skype, Dropbox and VLC do come to mind: + +![Create a Custom System Tray Indicator For Your Tasks on Linux 11][1] + +However, system tray icons can actually be quite a lot more useful; By simply building one yourself for your own needs. In this tutorial, we’ll explain how to do that for you in very simple steps. + +### Prerequisites + +We are going to build a custom system tray indicator using Python. Python is probably installed by default on all the major Linux distributions, so just check it’s there (version 2.7). Additionally, we’ll need the gir1.2-appindicator3 package installed. It’s the library allowing us to easily create system tray indicators. + +To install it on Ubuntu/Mint/Debian: + +``` +sudo apt-get install gir1.2-appindicator3 +``` + +On Fedora: + +``` +sudo dnf install libappindicator-gtk3 +``` + +For other distributions, just search for any packages containing appindicator. + +On GNOME Shell, system tray icons are removed starting from 3.26. You’ll need to install the [following extension][2] (Or possibly other extensions) to re-enable the feature on your desktop. Otherwise, you won’t be able to see the indicator we are going to create here. + +### Basic Code + +Here’s the basic code of the indicator: + +``` +#!/usr/bin/python +import os +from gi.repository import Gtk as gtk, AppIndicator3 as appindicator + +def main(): + indicator = appindicator.Indicator.new("customtray", "semi-starred-symbolic", appindicator.IndicatorCategory.APPLICATION_STATUS) + indicator.set_status(appindicator.IndicatorStatus.ACTIVE) + indicator.set_menu(menu()) + gtk.main() + +def menu(): + menu = gtk.Menu() + + command_one = gtk.MenuItem('My Notes') + command_one.connect('activate', note) + menu.append(command_one) + + exittray = gtk.MenuItem('Exit Tray') + exittray.connect('activate', quit) + menu.append(exittray) + + menu.show_all() + return menu + +def note(_): + os.system("gedit $HOME/Documents/notes.txt") + +def quit(_): + gtk.main_quit() + +if __name__ == "__main__": + main() +``` + +We’ll explain how the code works later. But for know, just save it in a text file under the name tray.py, and run it using Python: + +``` +python tray.py +``` + +You’ll see the indicator working as follows: + +![Create a Custom System Tray Indicator For Your Tasks on Linux 13][3] + +Now, to explain how we did the magic: + + * The first 3 lines of the code are nothing more than just specifying the Python path and importing the libraries we are going to use in our indicator. + + * def main() : This is the main function of the indicator. Under it we write the code to initialize and build the indicator. + + * indicator = appindicator.Indicator.new(“customtray”, “semi-starred-symbolic”, appindicator.IndicatorCategory.APPLICATION_STATUS) : Here we are specially creating a new indicator and calling it `customtray` . This is the special name of the indicator so that the system doesn’t mix it with other indicators that may be running. Also, we used the `semi-starred-symbolic` icon name as the default icon for our indicator. You could possibly change thing to any other things; Say `firefox` (if you want to see Firefox icon being used for the indicator), or any other icon name you would like. The last part regarding the `APPLICATION_STATUS` is just ordinary code for the categorization/scope of that indicator. + + * `indicator.set_status(appindicator.IndicatorStatus.ACTIVE)` : This line just turns the indicator on. + + * `indicator.set_menu(menu())` : Here, we are saying that we want to use the `menu()` function (which we’ll define later) for creating the menu items of our indicator. This is important so that when you click on the indicator, you can see a list of possible actions to take. + + * `gtk.main()` : Just run the main GTK loop. + + * Under `menu()` you’ll see that we are creating the actions/items we want to provide using our indicator. `command_one = gtk.MenuItem(‘My Notes’)` simply initializes the first menu item with the text “My notes”, and then `command_one.connect(‘activate’, note)` connects the `activate` signal of that menu item to the `note()` function defined later; In other words, we are telling our system here: “When this menu item is clicked, run the note() function”. Finally, `menu.append(command_one)` adds that menu item to the list. + + * The lines regarding `exittray` are just for creating an exit menu item to close the indicator any time you want. + + * `menu.show_all()` and `return menu` are just ordinary codes for returning the menu list to the indicator. + + * Under `note(_)` you’ll see the code that must be executed when the “My Notes” menu item is clicked. Here, we just wrote `os.system(“gedit $HOME/Documents/notes.txt”)` ; The `os.system` function is a function that allows us to run shell commands from inside Python, so here we wrote a command to open a file called `notes.txt` under the `Documents` folder in our home directory using the `gedit` editor. This for example can be your daily notes taking program from now on! + +### Adding your Needed Tasks + +There are only 2 things you need to touch in the code: + + 1. Define a new menu item under `menu()` for your desired task. + + 2. Create a new function to run a specific action when that menu item is clicked. + + +So, let’s say that you want to create a new menu item, which when clicked, plays a specific video/audio file on your hard disk using VLC? To do it, simply add the following 3 lines in line 17: + +``` +command_two = gtk.MenuItem('Play video/audio') +command_two.connect('activate', play) +menu.append(command_two) +``` + +And the following lines in line 30: + +``` +def play(_): + os.system("vlc /home//Videos/somevideo.mp4") +``` + +Replace /home//Videos/somevideo.mp4 with the path to the video/audio file you want. Now save the file and run the indicator again: + +``` +python tray.py +``` + +This is how you’ll see it now: + +![Create a Custom System Tray Indicator For Your Tasks on Linux 15][4] + +And when you click on the newly-created menu item, VLC will start playing! + +To create other items/tasks, simply redo the steps again. Just be careful to replace command_two with another name, like command_three, so that no clash between variables happen. And then define new separate functions like what we did with the play(_) function. + +The possibilities are endless from here; I am using this way for example to fetch some data from the web (using the urllib2 library) and display them for me any time. I am also using it for playing an mp3 file in the background using the mpg123 command, and I am defining another menu item to killall mpg123 to stop playing that audio whenever I want. CS:GO on Steam for example takes a huge time to exit (the window doesn’t close automatically), so as a workaround for this, I simply minimize the window and click on a menu item that I created which will execute killall -9 csgo_linux64. + +You can use this indicator for anything: Updating your system packages, possibly running some other scripts any time you want.. Literally anything. + +### Autostart on Boot + +We want our system tray indicator to start automatically on boot, we don’t want to run it manually each time. To do that, simply add the following command to your startup applications (after you replace the path to the tray.py file with yours): + +``` +nohup python /home//tray.py & +``` + +The very next time you reboot your system, the indicator will start working automatically after boot! + +### Conclusion + +You now know how to create your own system tray indicator for any task that you may want. This method should save you a lot of time depending on the nature and number of tasks you need to run on daily basis. Some users may prefer creating aliases from the command line, but this will require you to always open the terminal window or have a drop-down terminal emulator available, while here, the system tray indicator is always working and available for you. + +Have you used this method to run your tasks before? Would love to hear your thoughts. + + +-------------------------------------------------------------------------------- + +via: https://fosspost.org/tutorials/custom-system-tray-icon-indicator-linux + +作者:[M.Hanny Sabbagh][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://fosspost.org/author/mhsabbagh +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/02/Screenshot-at-2019-02-28-0808.png?resize=407%2C345&ssl=1 (Create a Custom System Tray Indicator For Your Tasks on Linux 12) +[2]: https://extensions.gnome.org/extension/1031/topicons/ +[3]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/03/Screenshot-at-2019-03-02-1041.png?resize=434%2C140&ssl=1 (Create a Custom System Tray Indicator For Your Tasks on Linux 14) +[4]: https://i2.wp.com/fosspost.org/wp-content/uploads/2019/03/Screenshot-at-2019-03-02-1141.png?resize=440%2C149&ssl=1 (Create a Custom System Tray Indicator For Your Tasks on Linux 16) diff --git a/sources/tech/20190303 Manage Your Mirrors with ArchLinux Mirrorlist Manager.md b/sources/tech/20190303 Manage Your Mirrors with ArchLinux Mirrorlist Manager.md new file mode 100644 index 0000000000..7618d3f711 --- /dev/null +++ b/sources/tech/20190303 Manage Your Mirrors with ArchLinux Mirrorlist Manager.md @@ -0,0 +1,94 @@ +[#]: collector: (lujun9972) +[#]: translator: (lujun9972) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Manage Your Mirrors with ArchLinux Mirrorlist Manager) +[#]: via: (https://itsfoss.com/archlinux-mirrorlist-manager) +[#]: author: (John Paul https://itsfoss.com/author/john/) + +Manage Your Mirrors with ArchLinux Mirrorlist Manager +====== + +**ArchLinux Mirrorlist Manager is a simple GUI program that allows you to easily manage mirrors in your Arch Linux system.** + +For Linux users, it is important to make sure that you keep your mirror list in good shape. Today we will take a quick look at an application designed to help manage your Arch mirror list. + +![ArchLinux Mirrorlist Manager][1]ArchLinux Mirrorlist Manager + +### What is a Mirror? + +For those new to the world of Linux, Linux operating systems depend on a series of servers placed around the world. These servers contain identical copies of all of the packages and software available for a particular distro. This is why they are called “mirrors”. + +The ultimate goal is to have multiple mirrors in each country. This allows local users to quickly update their systems. However, this is not always true. Sometimes mirrors from another country can be faster. + +### ArchLinux Mirrorlist Manager makes managing mirrors simpler in Arch Linux + +![ArchLinux Mirrorlist Manager][2]Main Screen + +[Managing and sorting][3] the available mirrors in Arch is not easy. It involves fairly lengthy commands. Thankfully, someone came up with a solution. + +Last year, [Rizwan Hasan][4] created a little Python and Qt application entitled [ArchLinux Mirrorlist Manager][5]. You might recognize Rizwan’s name because it is not the first time that we featured something he created on this site. Over a year ago, I wrote about a new Arch-based distro that Rizwan created named [MagpieOS][6]. I imagine that Rizwan’s experience with MagpieOS inspired him to create this application. + +There really isn’t much to ArchLinux Mirrorlist Manager. It allows you to rank mirrors by response speed and limit the results by number and country of origin. + +In other words, if you are located in Germany, you can restrict your mirrors to the 3 fastest in Germany. + +### Install ArchLinux Mirrorlist Manager + +``` +It is only for Arch Linux users + +Pay attention! ArchLinux Mirrorlist Manager is for Arch Linux distribution only. Don’t try to use it on other Arch-based distributions unless you make sure that the distro uses Arch mirrors. Otherwise, you might face issues that I encountered with Manjaro (explained in the section below). +``` + +``` +Mirrorlist Manager alternative for Manjaro + +When it comes to using something Archy, my go-to system is Manjaro. In preparation for this article, I decided to install ArchLinux Mirrorlist Manager on my Manjaro machine. It quickly sorted the available mirror and saved them to my mirror list. + +I then proceeded to try to update my system and immediately ran into problems. When ArchLinux Mirrorlist Manager sorted the mirrors my system was using, it replaced all of my Manjaro mirrors with vanilla Arch mirrors. (Manjaro is based on Arch, but has its own mirrors because the dev team tests all package updates before pushing them to the users to ensure there are no system-breaking bugs.) Thankfully, the Manjaro forum helped me fix my mistake. + +If you are a Manjaro user, please do not make the same mistake that I did. ArchLinux Mirrorlist Manager is only for Arch and Arch-based distros that use Arch’s mirrors. + +Luckily, there is an easy to use terminal application that Manjaro users can use to manage their mirror lists. It is called [Pacman-mirrors][7]. Just like ArchLinux Mirrorlist Manager, you can sort by response speed. Just type `sudo pacman-mirrors --fasttrack`. If you want to limit the results to the five fastest mirrors, you can type `sudo pacman-mirrors --fasttrack 5`. To restrict the results to one or more countries, type `sudo pacman-mirrors --country Germany,Spain,Austria`. You can limit the results to your country by typing `sudo pacman-mirrors --geoip`. You can visit the [Manjaro wiki][7] for more information about Pacman-mirrors. + +After you run Pacman-mirrors, you have to synchronize your package database and update your system by typing `sudo pacman -Syyu`. + +Note: Pacman-mirrors is for **Manjaro only**. +``` + +ArchLinux Mirrorlist Manager is available in the [Arch User Repository][8]. More advanced Arch users can download the PKGBUILD directly from [the GitHub page][9]. + +### Final Thoughts on ArchLinux Mirrorlist Manager + +Even though [ArchLinux Mirrorlist Manager][5] isn’t very useful for me, I’m glad it exists. It shows that Linux users are actively trying to make Linux easier to use. As I said earlier, managing a mirror list on Arch is not easy. Rizwan’s little tool will help make Arch more usable by the beginning user. + +Have you ever used ArchLinux Mirrorlist Manager? What is your method to manage your Arch mirrors? Please let us know in the comments below. + +If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][10]. + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/archlinux-mirrorlist-manager + +作者:[John Paul][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/john/ +[b]: https://github.com/lujun9972 +[1]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/02/mirrorlist-manager2.png?ssl=1 +[2]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/02/mirrorlist-manager4.jpg?ssl=1 +[3]: https://wiki.archlinux.org/index.php/Mirrors +[4]: https://github.com/Rizwan-Hasan +[5]: https://github.com/Rizwan-Hasan/ArchLinux-Mirrorlist-Manager +[6]: https://itsfoss.com/magpieos/ +[7]: https://wiki.manjaro.org/index.php?title=Pacman-mirrors +[8]: https://aur.archlinux.org/packages/mirrorlist-manager +[9]: https://github.com/Rizwan-Hasan/MagpieOS-Packages/tree/master/ArchLinux-Mirrorlist-Manager +[10]: http://reddit.com/r/linuxusersgroup diff --git a/sources/tech/20190304 How to Install MongoDB on Ubuntu.md b/sources/tech/20190304 How to Install MongoDB on Ubuntu.md new file mode 100644 index 0000000000..30d588ddba --- /dev/null +++ b/sources/tech/20190304 How to Install MongoDB on Ubuntu.md @@ -0,0 +1,238 @@ +[#]: collector: (lujun9972) +[#]: translator: (An-DJ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How to Install MongoDB on Ubuntu) +[#]: via: (https://itsfoss.com/install-mongodb-ubuntu) +[#]: author: (Sergiu https://itsfoss.com/author/sergiu/) + +How to Install MongoDB on Ubuntu +====== + +**This tutorial presents two ways to install MongoDB on Ubuntu and Ubuntu-based Linux distributions.** + +[MongoDB][1] is an increasingly popular free and open-source NoSQL database that stores data in collections of JSON-like, flexible documents, in contrast to the usual table approach you’ll find in SQL databases. + +You are most likely to find MongoDB used in modern web applications. Its document model makes it very intuitive to access and handle with various programming languages. + +![mongodb Ubuntu][2] + +In this article, I’ll cover two ways you can install MongoDB on your Ubuntu system. + +### Installing MongoDB on Ubuntu based Distributions + + 1. Install MongoDB using Ubuntu’s repository. Easy but not the latest version of MongoDB + 2. Install MongoDB using its official repository. Slightly complicated but you get the latest version of MongoDB. + + + +The first installation method is easier, but I recommend the second method if you plan on using the latest release with official support. + +Some people might prefer using snap packages. There are snaps available in the Ubuntu Software Center, but I wouldn’t recommend using them; they’re outdated at the moment and I won’t be covering that. + +#### Method 1. Install MongoDB from Ubuntu Repository + +This is the easy way to install MongoDB on your system, you only need to type in a simple command. + +##### Installing MongoDB + +First, make sure your packages are up-to-date. Open up a terminal and type: + +``` +sudo apt update && sudo apt upgrade -y +``` + +Go ahead and install MongoDB with: + +``` +sudo apt install mongodb +``` + +That’s it! MongoDB is now installed on your machine. + +The MongoDB service should automatically be started on install, but to check the status type + +``` +sudo systemctl status mongodb +``` + +![Check if the MongoDB service is running.][3] + +You can see that the service is **active**. + +##### Running MongoDB + +MongoDB is currently a systemd service, so we’ll use **systemctl** to check and modify it’s state, using the following commands: + +``` +sudo systemctl status mongodb +sudo systemctl stop mongodb +sudo systemctl start mongodb +sudo systemctl restart mongodb +``` + +You can also change if MongoDB automatically starts when the system starts up ( **default** : enabled): + +``` +sudo systemctl disable mongodb +sudo systemctl enable mongodb +``` + +To start working with (creating and editing) databases, type: + +``` +mongo +``` + +This will start up the **mongo shell**. Please check out the [manual][4] for detailed information on the available queries and options. + +**Note:** Depending on how you plan to use MongoDB, you might need to adjust your Firewall. That’s unfortunately more involved than what I can cover here and depends on your configuration. + +##### Uninstall MongoDB + +If you installed MongoDB from the Ubuntu Repository and want to uninstall it (maybe to install using the officially supported way), type: + +``` +sudo systemctl stop mongodb +sudo apt purge mongodb +sudo apt autoremove +``` + +This should completely get rid of your MongoDB install. Make sure to **backup** any collections or documents you might want to keep since they will be wiped out! + +#### Method 2. Install MongoDB Community Edition on Ubuntu + +This is the way the recommended way to install MongoDB, using the package manager. You’ll have to type a few more commands and it might be intimidating if you are newer to the Linux world. + +But there’s nothing to be afraid of! We’ll go through the installation process step by step. + +##### Installing MongoDB + +The package maintained by MongoDB Inc. is called **mongodb-org** , not **mongodb** (this is the name of the package in the Ubuntu Repository). Make sure **mongodb** is not installed on your system before applying this steps. The packages will conflict. Let’s get to it! + +First, we’ll have to import the public key: + +``` +sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4 +``` + +Now, you need to add a new repository in your sources list so that you can install MongoDB Community Edition and also get automatic updates: + +``` +echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list +``` + +To be able to install **mongodb-org** , we’ll have to update our package database so that your system is aware of the new packages available: + +``` +sudo apt update +``` + +Now you can ether install the **latest stable version** of MongoDB: + +``` +sudo apt install -y mongodb-org +``` + +or a **specific version** (change the version number after **equal** sign) + +``` +sudo apt install -y mongodb-org=4.0.6 mongodb-org-server=4.0.6 mongodb-org-shell=4.0.6 mongodb-org-mongos=4.0.6 mongodb-org-tools=4.0.6 +``` + +If you choose to install a specific version, make sure you change the version number everywhere. If you only change it in the **mongodb-org=4.0.6** part, the latest version will be installed. + +By default, when updating using the package manager ( **apt-get** ), MongoDB will be updated to the newest updated version. To stop that from happening (and freezing to the installed version), use: + +``` +echo "mongodb-org hold" | sudo dpkg --set-selections +echo "mongodb-org-server hold" | sudo dpkg --set-selections +echo "mongodb-org-shell hold" | sudo dpkg --set-selections +echo "mongodb-org-mongos hold" | sudo dpkg --set-selections +echo "mongodb-org-tools hold" | sudo dpkg --set-selections +``` + +You have now successfully installed MongoDB! + +##### Configuring MongoDB + +By default, the package manager will create **/var/lib/mongodb** and **/var/log/mongodb** and MongoDB will run using the **mongodb** user account. + +I won’t go into changing these default settings since that is beyond the scope of this guide. You can check out the [manual][5] for detailed information. + +The settings in **/etc/mongod.conf** are applied when starting/restarting the **mongodb** service instance. + +##### Running MongoDB + +To start the mongodb daemon **mongod** , type: + +``` +sudo service mongod start +``` + +Now you should verify that the **mongod** process started successfully. This information is stored (by default) at **/var/log/mongodb/mongod.log**. Let’s check the contents of that file: + +``` +sudo cat /var/log/mongodb/mongod.log +``` + +![Check MongoDB logs to see if the process is running properly.][6] + +As long as you get this: **[initandlisten] waiting for connections on port 27017** somewhere in there, the process is running properly. + +**Note: 27017** is the default port of **mongod.** + +To stop/restart **mongod** enter: + +``` +sudo service mongod stop +sudo service mongod restart +``` + +Now, you can use MongoDB by opening the **mongo shell** : + +``` +mongo +``` + +##### Uninstall MongoDB + +Run the following commands + +``` +sudo service mongod stop +sudo apt purge mongodb-org* +``` + +To remove the **databases** and **log files** (make sure to **backup** what you want to keep!): + +``` +sudo rm -r /var/log/mongodb +sudo rm -r /var/lib/mongodb +``` + +**Wrapping Up** + +MongoDB is a great NoSQL database, easy to integrate into modern projects. I hope this tutorial helped you to set it up on your Ubuntu machine! Let us know how you plan on using MongoDB in the comments below. + + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/install-mongodb-ubuntu + +作者:[Sergiu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/sergiu/ +[b]: https://github.com/lujun9972 +[1]: https://www.mongodb.com/ +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/03/mongodb-ubuntu.jpeg?resize=800%2C450&ssl=1 +[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/mongodb_check_status.jpg?fit=800%2C574&ssl=1 +[4]: https://docs.mongodb.com/manual/tutorial/getting-started/ +[5]: https://docs.mongodb.com/manual/ +[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/mongodb_org_check_logs.jpg?fit=800%2C467&ssl=1 diff --git a/sources/tech/20190304 What you need to know about Ansible modules.md b/sources/tech/20190304 What you need to know about Ansible modules.md new file mode 100644 index 0000000000..8330d4bd59 --- /dev/null +++ b/sources/tech/20190304 What you need to know about Ansible modules.md @@ -0,0 +1,311 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (What you need to know about Ansible modules) +[#]: via: (https://opensource.com/article/19/3/developing-ansible-modules) +[#]: author: (Jairo da Silva Junior https://opensource.com/users/jairojunior) + +What you need to know about Ansible modules +====== +Learn how and when to develop custom modules for Ansible. +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/data_container_block.png?itok=S8MbXEYw) + +Ansible works by connecting to nodes and sending small programs called modules to be executed remotely. This makes it a push architecture, where configuration is pushed from Ansible to servers without agents, as opposed to the pull model, common in agent-based configuration management systems, where configuration is pulled. + +These modules are mapped to resources and their respective states, which are represented in YAML files. They enable you to manage virtually everything that has an API, CLI, or configuration file you can interact with, including network devices like load balancers, switches, firewalls, container orchestrators, containers themselves, and even virtual machine instances in a hypervisor or in a public (e.g., AWS, GCE, Azure) and/or private (e.g., OpenStack, CloudStack) cloud, as well as storage and security appliances and system configuration. + +With Ansible's batteries-included model, hundreds of modules are included and any task in a playbook has a module behind it. + +The contract for building modules is simple: JSON in the stdout. The configurations declared in YAML files are delivered over the network via SSH/WinRM—or any other connection plugin—as small scripts to be executed in the target server(s). Modules can be written in any language capable of returning JSON, although most Ansible modules (except for Windows PowerShell) are written in Python using the Ansible API (this eases the development of new modules). + +Modules are one way of expanding Ansible capabilities. Other alternatives, like dynamic inventories and plugins, can also increase Ansible's power. It's important to know about them so you know when to use one instead of the other. + +Plugins are divided into several categories with distinct goals, like Action, Cache, Callback, Connection, Filters, Lookup, and Vars. The most popular plugins are: + + * **Connection plugins:** These implement a way to communicate with servers in your inventory (e.g., SSH, WinRM, Telnet); in other words, how automation code is transported over the network to be executed. + * **Filters plugins:** These allow you to manipulate data inside your playbook. This is a Jinja2 feature that is harnessed by Ansible to solve infrastructure-as-code problems. + * **Lookup plugins:** These fetch data from an external source (e.g., env, file, Hiera, database, HashiCorp Vault). + + + +Ansible's official docs are a good resource on [developing plugins][1]. + +### When should you develop a module? + +Although many modules are delivered with Ansible, there is a chance that your problem is not yet covered or it's something too specific—for example, a solution that might make sense only in your organization. Fortunately, the official docs provide excellent guidelines on [developing modules][2]. + +**IMPORTANT:** Before you start working on something new, always check for open pull requests, ask developers at #ansible-devel (IRC/Freenode), or search the [development list][3] and/or existing [working groups][4] to see if a module exists or is in development. + +Signs that you need a new module instead of using an existing one include: + + * Conventional configuration management methods (e.g., templates, file, get_url, lineinfile) do not solve your problem properly. + * You have to use a complex combination of commands, shells, filters, text processing with magic regexes, and API calls using curl to achieve your goals. + * Your playbooks are complex, imperative, non-idempotent, and even non-deterministic. + + + +In the ideal scenario, the tool or service already has an API or CLI for management, and it returns some sort of structured data (JSON, XML, YAML). + +### Identifying good and bad playbooks + +> "Make love, but don't make a shell script in YAML." + +So, what makes a bad playbook? + +``` +- name: Read a remote resource +   command: "curl -v http://xpto/resource/abc" + register: resource + changed_when: False + + - name: Create a resource in case it does not exist +   command: "curl -X POST http://xpto/resource/abc -d '{ config:{ client: xyz, url: http://beta, pattern: core.md Dict.md lctt2014.md lctt2016.md lctt2018.md README.md } }'" +   when: "resource.stdout | 404" + + # Leave it here in case I need to remove it hehehe + #- name: Remove resource + #  command: "curl -X DELETE http://xpto/resource/abc" + #  when: resource.stdout == 1 +``` + +Aside from being very fragile—what if the resource state includes a 404 somewhere?—and demanding extra code to be idempotent, this playbook can't update the resource when its state changes. + +Playbooks written this way disrespect many infrastructure-as-code principles. They're not readable by human beings, are hard to reuse and parameterize, and don't follow the declarative model encouraged by most configuration management tools. They also fail to be idempotent and to converge to the declared state. + +Bad playbooks can jeopardize your automation adoption. Instead of harnessing configuration management tools to increase your speed, they have the same problems as an imperative automation approach based on scripts and command execution. This creates a scenario where you're using Ansible just as a means to deliver your old scripts, copying what you already have into YAML files. + +Here's how to rewrite this example to follow infrastructure-as-code principles. + +``` +- name: XPTO +  xpto: +    name: abc +    state: present +    config: +      client: xyz +      url: http://beta +      pattern: "*.*" +``` + +The benefits of this approach, based on custom modules, include: + + * It's declarative—resources are properly represented in YAML. + * It's idempotent. + * It converges from the declared state to the current state. + * It's readable by human beings. + * It's easily parameterized or reused. + + + +### Implementing a custom module + +Let's use [WildFly][5], an open source Java application server, as an example to introduce a custom module for our not-so-good playbook: + +``` + - name: Read datasource +   command: "jboss-cli.sh -c '/subsystem=datasources/data-source=DemoDS:read-resource()'" +   register: datasource + + - name: Create datasource +   command: "jboss-cli.sh -c '/subsystem=datasources/data-source=DemoDS:add(driver-name=h2, user-name=sa, password=sa, min-pool-size=20, max-pool-size=40, connection-url=.jdbc:h2:mem:demo;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE..)'" +   when: 'datasource.stdout | outcome => failed' +``` + +Problems: + + * It's not declarative. + * JBoss-CLI returns plaintext in a JSON-like syntax; therefore, this approach is very fragile, since we need a type of parser for this notation. Even a seemingly simple parser can be too complex to treat many [exceptions][6]. + * JBoss-CLI is just an interface to send requests to the management API (port 9990). + * Sending an HTTP request is more efficient than opening a new JBoss-CLI session, connecting, and sending a command. + * It does not converge to the desired state; it only creates the resource when it doesn't exist. + + + +A custom module for this would look like: + +``` +- name: Configure datasource +      jboss_resource: +        name: "/subsystem=datasources/data-source=DemoDS" +        state: present +        attributes: +          driver-name: h2 +          connection-url: "jdbc:h2:mem:demo;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" +          jndi-name: "java:jboss/datasources/DemoDS" +          user-name: sa +          password: sa +          min-pool-size: 20 +          max-pool-size: 40 +``` + +This playbook is declarative, idempotent, more readable, and converges to the desired state regardless of the current state. + +### Why learn to build custom modules? + +Good reasons to learn how to build custom modules include: + + * Improving existing modules + * You have bad playbooks and want to improve them, or … + * You don't, but want to avoid having bad playbooks. + * Knowing how to build a module considerably improves your ability to debug problems in playbooks, thereby increasing your productivity. + + + +> "…abstractions save us time working, but they don't save us time learning." —Joel Spolsky, [The Law of Leaky Abstractions][7] + +#### Custom Ansible modules 101 + + * JSON (JavaScript Object Notation) in stdout: that's the contract! + * They can be written in any language, but … + * Python is usually the best option (or the second best) + * Most modules delivered with Ansible ( **lib/ansible/modules** ) are written in Python and should support compatible versions. + + + +#### The Ansible way + + * First step: + +``` +git clone https://github.com/ansible/ansible.git +``` + + * Navigate in **lib/ansible/modules/** and read the existing modules code. + + * Your tools are: Git, Python, virtualenv, pdb (Python debugger) + + * For comprehensive instructions, consult the [official docs][8]. + + + + +#### An alternative: drop it in the library directory + +``` +library/                  # if any custom modules, put them here (optional) +module_utils/             # if any custom module_utils to support modules, put them here (optional) +filter_plugins/           # if any custom filter plugins, put them here (optional) + +site.yml                  # master playbook +webservers.yml            # playbook for webserver tier +dbservers.yml             # playbook for dbserver tier + +roles/ +    common/               # this hierarchy represents a "role" +        library/          # roles can also include custom modules +        module_utils/     # roles can also include custom module_utils +        lookup_plugins/   # or other types of plugins, like lookup in this case +``` + + * It's easier to start. + * Doesn't require anything besides Ansible and your favorite IDE/text editor. + * This is your best option if it's something that will be used internally. + + + +**TIP:** You can use this directory layout to overwrite existing modules if, for example, you need to patch a module. + +#### First steps + +You could do it in your own—including using another language—or you could use the AnsibleModule class, as it is easier to put JSON in the stdout ( **exit_json()** , **fail_json()** ) in the way Ansible expects ( **msg** , **meta** , **has_changed** , **result** ), and it's also easier to process the input ( **params[]** ) and log its execution ( **log()** , **debug()** ). + +``` +def main(): + +  arguments = dict(name=dict(required=True, type='str'), +                  state=dict(choices=['present', 'absent'], default='present'), +                  config=dict(required=False, type='dict')) + +  module = AnsibleModule(argument_spec=arguments, supports_check_mode=True) +  try: +      if module.check_mode: +          # Do not do anything, only verifies current state and report it +          module.exit_json(changed=has_changed, meta=result, msg='Fez alguma coisa ou não...') + +      if module.params['state'] == 'present': +          # Verify the presence of a resource +          # Desired state `module.params['param_name'] is equal to the current state? +          module.exit_json(changed=has_changed, meta=result) + +      if module.params['state'] == 'absent': +          # Remove the resource in case it exists +          module.exit_json(changed=has_changed, meta=result) + +  except Error as err: +      module.fail_json(msg=str(err)) +``` + +**NOTES:** The **check_mode** ("dry run") allows a playbook to be executed or just verifies if changes are required, but doesn't perform them. **** Also, the **module_utils** directory can be used for shared code among different modules. + +For the full Wildfly example, check [this pull request][9]. + +### Running tests + +#### The Ansible way + +The Ansible codebase is heavily tested, and every commit triggers a build in its continuous integration (CI) server, [Shippable][10], which includes linting, unit tests, and integration tests. + +For integration tests, it uses containers and Ansible itself to perform the setup and verify phase. Here is a test case (written in Ansible) for our custom module's sample code: + +``` +- name: Configure datasource + jboss_resource: +   name: "/subsystem=datasources/data-source=DemoDS" +   state: present +   attributes: +     connection-url: "jdbc:h2:mem:demo;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE" +     ... + register: result + +- name: assert output message that datasource was created + assert: +   that: +      - "result.changed == true" +      - "'Added /subsystem=datasources/data-source=DemoDS' in result.msg" +``` + +#### An alternative: bundling a module with your role + +Here is a [full example][11] inside a simple role: + +``` +[*Molecule*]() + [*Vagrant*]() + [*pytest*](): `molecule init` (inside roles/) +``` + +It offers greater flexibility to choose: + + * Simplified setup + * How to spin up your infrastructure: e.g., Vagrant, Docker, OpenStack, EC2 + * How to verify your infrastructure tests: Testinfra and Goss + + + +But your tests would have to be written using pytest with Testinfra or Goss, instead of plain Ansible. If you'd like to learn more about testing Ansible roles, see my article about [using Molecule][12]. + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/developing-ansible-modules + +作者:[Jairo da Silva Junior][a] +选题:[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/jairojunior +[b]: https://github.com/lujun9972 +[1]: https://docs.ansible.com/ansible/latest/dev_guide/developing_plugins.html#developing-plugins +[2]: https://docs.ansible.com/ansible/latest/dev_guide/developing_modules.html +[3]: https://groups.google.com/forum/#!forum/ansible-devel +[4]: https://github.com/ansible/community/ +[5]: http://www.wildfly.org/ +[6]: https://tools.ietf.org/html/rfc7159 +[7]: https://en.wikipedia.org/wiki/Leaky_abstraction#The_Law_of_Leaky_Abstractions +[8]: https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#developing-modules-general +[9]: https://github.com/ansible/ansible/pull/43682/files +[10]: https://app.shippable.com/github/ansible/ansible/dashboard +[11]: https://github.com/jairojunior/ansible-role-jboss/tree/with_modules +[12]: https://opensource.com/article/18/12/testing-ansible-roles-molecule diff --git a/sources/tech/20190305 5 Ways To Generate A Random-Strong Password In Linux Terminal.md b/sources/tech/20190305 5 Ways To Generate A Random-Strong Password In Linux Terminal.md new file mode 100644 index 0000000000..0f12c53e56 --- /dev/null +++ b/sources/tech/20190305 5 Ways To Generate A Random-Strong Password In Linux Terminal.md @@ -0,0 +1,366 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (5 Ways To Generate A Random/Strong Password In Linux Terminal) +[#]: via: (https://www.2daygeek.com/5-ways-to-generate-a-random-strong-password-in-linux-terminal/) +[#]: author: (Magesh Maruthamuthu https://www.2daygeek.com/author/magesh/) + +5 Ways To Generate A Random/Strong Password In Linux Terminal +====== + +Recently we had written an article about **[password strength and password score check][1]** in our website. + +It will help you to validate your password strength and score. + +We can manually create few passwords which we required but if you would like to generate a password for multiple users or servers, what will be the solution. + +Yes, there are many utilities are available in Linux to fulfill this requirements. However, I’m going to include the best five password generators in this article. + +These tools are generates a strong random passwords for you. Navigate to the following article if you would like to update the password on multiple users and servers. + +These tools are easy to use, that’s why i preferred to go with it. By default it will generate a strong password and if you would like to generate a super strong password then use the available options. + +It will help you to generate a super strong password in the following combination. It should have minimum 12-15 characters length, that includes Alphabets (Lower case & Upper case), Numbers and Special Characters. + +These tools are below. + + * `pwgen:` The pwgen program generates passwords which are designed to be easily memorized by humans, while being as secure as possible. + * `openssl:` The openssl program is a command line tool for using the various cryptography functions of OpenSSL’s crypto library from the shell. + * `gpg:` OpenPGP encryption and signing tool + * `mkpasswd:` generate new password, optionally apply it to a user + * `makepasswd:` makepasswd generates true random passwords using /dev/urandom, with the emphasis on security over pronounceability. + * `/dev/urandom file:` The character special files /dev/random and /dev/urandom (present since Linux 1.3.30) provide an interface to the kernel’s random number generator. + * `md5sum:` md5sum is a computer program that calculates and verifies 128-bit MD5 hashes. + * `sha256sum:` The program sha256sum is designed to verify data integrity using the SHA-256 (SHA-2 family with a digest length of 256 bits). + * `sha1pass:` sha1pass creates a SHA1 password hash. In the absence of a salt value on the command line, a random salt vector will be generated. + + + +### How To Generate A Random Strong Password In Linux Using pwgen Command? + +The pwgen program generates passwords which are designed to be easily memorized by humans, while being as secure as possible. + +Human-memorable passwords are never going to be as secure as completely completely random passwords. + +Use `-s` option to generate completely random, hard-to-memorize passwords. These should only be used for machine passwords as we can’t memorize. + +For **`Fedora`** system, use **[DNF Command][2]** to install pwgen. + +``` +$ sudo dnf install pwgen +``` + +For **`Debian/Ubuntu`** systems, use **[APT-GET Command][3]** or **[APT Command][4]** to install pwgen. + +``` +$ sudo apt install pwgen +``` + +For **`Arch Linux`** based systems, use **[Pacman Command][5]** to install pwgen. + +``` +$ sudo pacman -S pwgen +``` + +For **`RHEL/CentOS`** systems, use **[YUM Command][6]** to install pwgen. + +``` +$ sudo yum install pwgen +``` + +For **`openSUSE Leap`** system, use **[Zypper Command][7]** to install pwgen. + +``` +$ sudo zypper install pwgen +``` + +### How To Use pwgen Command In Linux? + +It’s a simple and straight forward method. Use one of the below preferred examples for you. By default, it generates a human memorable password. + +To do so, simple run the `pwgen` command on your terminal. It generates 160 passwords in a single shot. These 160 passwords are printer with 20 rows and 8 columns. + +``` +$ pwgen +ameiK2oo aibi3Cha EPium0Ie aisoh1Ee Nidee9ae uNga0Bee uPh9ieM1 ahn1ooNg +oc5ooTea tai7eKid tae2yieS hiecaiR8 wohY2Ohk Uab2maed heC4aXoh Ob6Nieso +Shaeriu3 uy9Juk5u hoht7Doo Fah6yah3 faz9Jeew eKiek4ju as0Xuosh Eiwo4epo +oot8teeZ Ui1yoohi Aechae7A Ohdi2ael cae5Thoh Au1aeTei ais0aiC2 Cai2quin +Oox9ohz4 neev0Che ahza8AQu Ahz7eica meiBeeW0 Av3bo7ah quoiTu3f taeNg3ae +Aiko7Aiz SheiGh8E aesaeSh7 haet6Loo AeTel3oN Ath7zeer IeYah4ie UG3ootha +Ohch9Och Phuap6su iel5Xu7s diqui7Bu ieF2dier eeluHa1u Thagei0i Ceeth3oh +OCei1ahj zei2aiYo Jahgh1ia ooqu1Cej eez2aiPo Wahd5soo noo7Mei9 Hie5ashe +Uith4Or2 Xie3uh2b fuF9Eilu eiN2sha9 zae2YaSh oGh5ephi ohvao4Ae aixu6aeM +fo4Ierah iephei6A hae9eeGa eiBeiY3g Aic8Kee9 he8AheCh ohM4bid9 eemae3Zu +eesh2EiM cheiGa4j PooV2vii ahpeeg5E aezauX2c Xe7aethu Ahvaph7a Joh2heec +Ii5EeShi aij7Uo8e ooy2Ahth mieKe2ni eiQuu8fe giedaQu0 eiPhob3E oox1uo2U +eehia4Hu ga9Ahw0a ohxuZei7 eV4OoXio Kid2wu1n ku4Ahf5s uigh8uQu AhWoh0po +vo1Eeb2u Ahth7ve5 ieje4eiL ieci1Ach Meephie9 iephieY8 Eesoom7u eakai2Bo +uo8Ieche Zai3aev5 aGhahf0E Wowoo5th Oraeb0ah Gah3nah0 ieGhah0p aeCh0OhJ +ahQu2feZ ahQu0gah foik7Ush cei1Wai1 Aivi3ooY eephei5U MooZae3O quooRoh7 +aequae5U pae6Ceiv eizahF1k ohmi7ETa ahyaeK1N Mohw2no8 ooc8Oone coo7Ieve +eePhei9h Weequ8eV Vie4iezu neeMiim4 ie6aiZoh Queegh2E shahwi3N Inichie8 +Sid1aeji mohj4Ko7 lieDi0pe Zeemah6a thuevu2E phi4Ohsh paiKeix1 ooz1Ceph +ahV4yore ue2laePh fu1eThui qui7aePh Fahth1nu ohk9puLo aiBeez0b Neengai5 +``` + +To generate a secure random password, use `-s` option with pwgen command. + +``` +$ pwgen -s +CU75lgZd 7HzzKgtA 2ktBJDpR F6XJVhBs UjAm3bNL zO7Dw7JJ pxn8fUvp Ka3lLilG +ywJX7iJl D9ajxb6N 78c1HOg2 g8vtWCra Jp6pBGBw oYuev9Vl gbA6gHV8 G6XQoVO5 +uQN98IU4 50GgQfrX FrTsou2t YQorO4x6 UGer8Yi2 O7DB5nw1 1ax370UR 1xVRPkA1 +RVaGDr2i Nt11ekUd 9Vm3D244 ck8Lnpd0 SjDt8uWn 5ERT4tf8 4EONFzyY Jc6T83jg +WZa6bKPW H4HMo1YU bsDDRik3 gBwV7LOW 9H1QRQ4x 3Ak7RcSe IJu2RBF9 e508xrLC +SzTrW191 AslxDa6E IkWWov2b iOb6EmTy qHt82OwG 5ZFO7B53 97zmjOPu A4KZuhYV +uQpoJR4D 0eKyOiUr Rz96smeO 3HTABu3N 6W0VmEls uPsp5zpw 8UD3VkMG YTct6Rd4 +VKo0cVmq E07ZX7j9 kQSlvA69 Nm3fpv3i xWvF2xMu yEfcw8uA oQGVX3l9 grTzx7Xj +s4GVEYtM uJl5sYMe n3icRPiY ED3Mup4B k3M9KHI7 IkxqoSM0 dt2cxmMU yb2tUkut +2Q9wGZQx 8Rpo11s9 I13siOHu 7GV64Fjv 3VONzD8i SCDfVD3F oiPTx239 6BQakoiJ +XUEokiC4 ybL7VGmL el2RfvWk zKc7CLcE 3FqNBSyA NjDWrvZ5 KI3NSX4h VFyo6VPr +h4q3XeqZ FDYMoX6f uTU5ZzU3 6u4ob4Ep wiYPt05n CZga66qh upzH6Z9y RuVcqbe8 +taQv11hq 1xsY67a8 EVo9GLXA FCaDLGb1 bZyh0YN8 0nTKo0Qy RRVUwn9t DuU8mwwv +x96LWpCb tFLz3fBG dNb4gCKf n6VYcOiH 1ep6QYFZ x8kaJtrY 56PDWuW6 1R0If4kV +2XK0NLQK 4XQqhycl Ip08cn6c Bnx9z2Bz 7gjGlON7 CJxLR1U4 mqMwir3j ovGXWu0z +MfDjk5m8 4KwM9SAN oz0fZ5eo 5m8iRtco oP5BpLh0 Z5kvwr1W f34O2O43 hXao1Sp8 +tKoG5VNI f13fuYvm BQQn8MD3 bmFSf6Mf Z4Y0o17U jT4wO1DG cz2clBES Lr4B3qIY +ArKQRND6 8xnh4oIs nayiK2zG yWvQCV3v AFPlHSB8 zfx5bnaL t5lFbenk F2dIeBr4 +C6RqDQMy gKt28c9O ZCi0tQKE 0Ekdjh3P ox2vWOMI 14XF4gwc nYA0L6tV rRN3lekn +lmwZNjz1 4ovmJAr7 shPl9o5f FFsuNwj0 F2eVkqGi 7gw277RZ nYE7gCLl JDn05S5N +``` + +If you would like to generate a strong five passwords with 14 characters length, use the following format. + +``` +$ pwgen -s 14 5 +7YxUwDyfxGVTYD em2NT6FceXjPfT u8jlrljbrclcTi IruIX3Xu0TFXRr X8M9cB6wKNot1e +``` + +If you really want to generate a super strong random twenty passwords, use the following format. + +``` +$ pwgen -cnys 14 20 +mQ3E=vfGfZ,5[B #zmj{i5|ZS){jg Ht_8i7OqJ%N`~2 443fa5iJ\W-L?] ?Qs$o=vz2vgQBR +^'Ry0Az|J9p2+0 t2oA/n7U_'|QRx EsX*%_(4./QCRJ ACr-,8yF9&eM[* !Xz1C'bw?tv50o +8hfv-fK(VxwQGS q!qj?sD7Xmkb7^ N#Zp\_Y2kr%!)~ 4*pwYs{bq]Hh&Y |4u=-Q1!jS~8=; +]{$N#FPX1L2B{h I|01fcK.z?QTz" l~]JD_,W%5bp.E +i2=D3;BQ}p+$I n.a3,.D3VQ3~&i +``` + +### How To Generate A Random Strong Password In Linux Using openssl Command? + +The openssl program is a command line tool for using the various cryptography functions of OpenSSL’s crypto library from the shell. + +Run the openssl command with the following format to generate a random strong password with 14 characters. + +``` +$ openssl rand -base64 14 +WjzyDqdkWf3e53tJw/c= +``` + +If you would like to generate ten random strong password with 14 characters using openssl command then use the following for loop. + +``` +$ for pw in {1..10}; do openssl rand -base64 14; done +6i0hgHDBi3ohZ9Mil8I= +gtn+y1bVFJFanpJqWaA= +rYu+wy+0nwLf5lk7TBA= +xrdNGykIzxaKDiLF2Bw= +cltejRkDPdFPC/zI0Pg= +G6aroK6d4xVVYFTrZGs= +jJEnFoOk1+UTSx/wJrY= +TFxVjBmLx9aivXB3yxE= +oQtOLPwTuO8df7dIv9I= +ktpBpCSQFOD+5kIIe7Y= +``` + +### How To Generate A Random Strong Password In Linux Using gpg Command? + +gpg is the OpenPGP part of the GNU Privacy Guard (GnuPG). It is a tool to provide digital encryption and signing services using the OpenPGP standard. gpg features complete key management and all the bells and whistles you would expect from a full OpenPGP implementation. + +Run the gpg command with the following format to generate a random strong password with 14 characters. + +``` +$ gpg --gen-random --armor 1 14 +or +$ gpg2 --gen-random --armor 1 14 +jq1mtY4gBa6gIuJrggM= +``` + +If you would like to generate ten random strong password with 14 characters using gpg command then use the following for loop. + +``` +$ for pw in {1..10}; do gpg --gen-random --armor 1 14; done +or +$ for pw in {1..10}; do gpg2 --gen-random --armor 1 14; done +F5ZzLSUMet2kefG6Ssc= +8hh7BFNs8Qu0cnrvHrY= +B+PEt28CosR5xO05/sQ= +m21bfx6UG1cBDzVGKcE= +wALosRXnBgmOC6+++xU= +TGpjT5xRxo/zFq/lNeg= +ggsKxVgpB/3aSOY15W4= +iUlezWxL626CPc9omTI= +pYb7xQwI1NTlM2rxaCg= +eJjhtA6oHhBrUpLY4fM= +``` + +### How To Generate A Random Strong Password In Linux Using mkpasswd Command? + +mkpasswd generates passwords and can apply them automatically to users. With no arguments, mkpasswd returns a new password. It’s part of an expect package so, you have to install expect package to use mkpasswd command. + +For **`Fedora`** system, use **[DNF Command][2]** to install mkpasswd. + +``` +$ sudo dnf install expect +``` + +For **`Debian/Ubuntu`** systems, use **[APT-GET Command][3]** or **[APT Command][4]** to install mkpasswd. + +``` +$ sudo apt install expect +``` + +For **`Arch Linux`** based systems, use **[Pacman Command][5]** to install mkpasswd. + +``` +$ sudo pacman -S expect +``` + +For **`RHEL/CentOS`** systems, use **[YUM Command][6]** to install mkpasswd. + +``` +$ sudo yum install expect +``` + +For **`openSUSE Leap`** system, use **[Zypper Command][7]** to install mkpasswd. + +``` +$ sudo zypper install expect +``` + +Run the `mkpasswd` command in terminal to generate a random password. + +``` +$ mkpasswd +37_slQepD +``` + +Run the mkpasswd command with the following format to generate a random strong password with 14 characters. + +``` +$ mkpasswd -l 14 +W1qP1uv=lhghgh +``` + +Run the mkpasswd command with the following format to generate a random strong password with 14 characters. It combinations of alphabetic (Lower & Upper case), Numeric number and special characters. + +``` +$ mkpasswd -l 14 -d 3 -C 3 -s 3 +3aad!bMWG49"t, +``` + +If you would like to generate ten random strong password with 14 characters (It combination of alphabetic (Lower & Upper case), Numeric number and special characters) using mkpasswd command then use the following for loop. + +``` +$ for pw in {1..10}; do mkpasswd -l 14 -d 3 -C 3 -s 3; done +zmSwP[q9;P1r6[ +E42zcvzM"i3%B\ +8}1#[email protected] +0X:zB(mmU22?nj +0sqqL44M}ko(O^ +43tQ(.6jG;ceRq +-jB6cp3x1GZ$e= +$of?Rj9kb2N(1J +9HCf,nn#gjO79^ +Tu9m56+Ev_Yso( +``` + +### How To Generate A Random Strong Password In Linux Using makepasswd Command? + +makepasswd generates true random passwords using /dev/urandom, with the emphasis on security over pronounceability. It can also encrypt plaintext passwords given on the command line. + +Run the `makepasswd` command in terminal to generate a random password. + +``` +$ makepasswd +HdCJafVaN +``` + +Run the makepasswd command with the following format to generate a random strong password with 14 characters. + +``` +$ makepasswd --chars 14 +HxJDv5quavrqmU +``` + +Run the makepasswd command with the following format to generate ten random strong password with 14 characters. + +``` +$ makepasswd --chars 14 --count 10 +TqmKVWnRGeoVNr +mPV2P98hLRUsai +MhMXPwyzYi2RLo +dxMGgLmoFpYivi +8p0G7JvJjd6qUP +7SmX95MiJcQauV +KWzrh5npAjvNmL +oHPKdq1uA9tU85 +V1su9GjU2oIGiQ +M2TMCEoahzLNYC +``` + +### How To Generate A Random Strong Password In Linux Using Multiple Commands? + +Still if you are looking other options then you can use the following utilities to generate a random password in Linux. + +**Using md5sum:** md5sum is a computer program that calculates and verifies 128-bit MD5 hashes. + +``` +$ date | md5sum +9baf96fb6e8cbd99601d97a5c3acc2c4 - +``` + +**Using /dev/urandom:** The character special files /dev/random and /dev/urandom (present since Linux 1.3.30) provide an interface to the kernel’s random number generator. File /dev/random has major device number 1 and minor device number 8. File /dev/urandom has major device number 1 and minor device number 9. + +``` +$ cat /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c 14 +15LQB9J84Btnzz +``` + +**Using sha256sum:** The program sha256sum is designed to verify data integrity using the SHA-256 (SHA-2 family with a digest length of 256 bits). + +``` +$ date | sha256sum +a114ae5c458ae0d366e1b673d558d921bb937e568d9329b525cf32290478826a - +``` + +**Using sha1pass:** sha1pass creates a SHA1 password hash. In the absence of a salt value on the command line, a random salt vector will be generated. + +``` +$ sha1pass +$4$9+JvykOv$e7U0jMJL2yBOL+RVa2Eke8SETEo$ +``` + +-------------------------------------------------------------------------------- + +via: https://www.2daygeek.com/5-ways-to-generate-a-random-strong-password-in-linux-terminal/ + +作者:[Magesh Maruthamuthu][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.2daygeek.com/author/magesh/ +[b]: https://github.com/lujun9972 +[1]: https://www.2daygeek.com/how-to-check-password-complexity-strength-and-score-in-linux/ +[2]: https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/ +[3]: https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/ +[4]: https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/ +[5]: https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/ +[6]: https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/ +[7]: https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/ diff --git a/sources/tech/20190305 Running the ‘Real Debian- on Raspberry Pi 3- -For DIY Enthusiasts.md b/sources/tech/20190305 Running the ‘Real Debian- on Raspberry Pi 3- -For DIY Enthusiasts.md new file mode 100644 index 0000000000..785a6eeb5a --- /dev/null +++ b/sources/tech/20190305 Running the ‘Real Debian- on Raspberry Pi 3- -For DIY Enthusiasts.md @@ -0,0 +1,134 @@ +[#]: collector: (lujun9972) +[#]: translator: ( ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Running the ‘Real Debian’ on Raspberry Pi 3+ [For DIY Enthusiasts]) +[#]: via: (https://itsfoss.com/debian-raspberry-pi) +[#]: author: (Shirish https://itsfoss.com/author/shirish/) + +Running the ‘Real Debian’ on Raspberry Pi 3+ [For DIY Enthusiasts] +====== + +If you have ever used a Raspberry Pi device, you probably already know that it recommends a Linux distribution called [Raspbian][1]. + +Raspbian is a heavily customized form of Debian to run on low-powered ARM processors. It’s not bad. In fact, it’s an excellent OS for Raspberry Pi devices but it’s not the real Debian. + +[Debian purists like me][2] would prefer to run the actual Debian over the Raspberry Pi’s customized Debian version. I trust Debian more than any other distribution to provide me a vast amount of properly vetted free software packages. Moreover, a project like this would help other ARM devices as well. + +Above all, running the official Debian on Raspberry Pi is sort of challenge and I like such challenges. + +![Real Debian on Raspberry Pi][3] + +I am not the only one who thinks like this. There are many other Debian users who share the same feeling and this is why there exists an ongoing project to create a [Debian image for Raspberry Pi][4]. + +About two and a half months back, a Debian Developer (DD) named [Gunnar Wolf][5] took over that unofficial Raspberry Pi image generation project. + +I’ll be quickly showing you how can you install this Raspberry Pi Debian Buster preview image on your Raspberry Pi 3 (or higher) devices. + +### Getting Debian on Raspberry Pi [For Experts] + +``` +Warning + +Be aware this Debian image is very raw and unsupported at the moment. Though it’s very new, I believe experienced Raspberry Pi and Debian users should be able to use it. +``` + +Now as far as [Debian][6] is concerned, here is the Debian image and instructions that you could use to put the Debian stock image on your Raspberry pi 3 Model B+. + +#### Step 1: Download the Debian Raspberry Pi Buster image + +You can download the preview images using wget command: + +``` +wget https://people.debian.org/~gwolf/raspberrypi3/20190206/20190206-raspberry-pi-3-buster-PREVIEW.img.xz +``` + +#### Step 2: Verify checksum (optional) + +It’s optional but you should [verify the checksum][7]. You can do that by downloading the SHA256 hashfile and then comparing it with that of the downloaded Raspberry Pi Debian image. + +At my end I had moved both the .sha256 file as img.xz to a directory to make it easier to check although it’s not necessary. + +``` +wget https://people.debian.org/~gwolf/raspberrypi3/20190206/20190206-raspberry-pi-3-buster-PREVIEW.img.xz.sha256 + +sha256sum -c 20190206-raspberry-pi-3-buster-PREVIEW.img.xz.sha256 +``` + +#### Step 3: Write the image to your SD card + +Once you have verified the image, take a look at it. It is around 400MB in the compressed xzip format. You can extract it to get an image of around 1.5GB in size. + +Insert your SD card. **Before you carry on to the next command please change the sdX to a suitable name that corresponds to your SD card.** + +The command basically extracts the img.xz archive to the SD card. The progress switch/flag enables you to see a progress line with a number as to know how much the archive has extracted. + +``` +xzcat 20190206-raspberry-pi-3-buster-PREVIEW.img.xz | dd of=/dev/sdX bs=64k oflag=dsync status=progress$ xzcat 20190206-raspberry-pi-3-buster-PREVIEW.img.xz | dd of=/dev/sdX bs=64k oflag=dsync status=progress +``` + +Once you have successfully flashed your SD card, you should be able test if the installation went ok by sshing into your Raspberry Pi. The default root password is raspberry. + +``` +ssh root@rpi3 +``` + +If you are curious to know how the Raspberry Pi image was built, you can look at the [build scripts][8]. + +You can find more info on the project homepage. + +[DEBIAN RASPBERRY PI IMAGE][15] + +### How to contribute to the Raspberry Pi Buster effort + +There is a mailing list called [debian-arm][9] where people could contribute their efforts and ask questions. As you can see in the list, there is already a new firmware which was released [few days back][10] which might make booting directly a reality instead of the workaround shared above. + +If you want you could make a new image using the raspi3-image-spec shared above or wait for Gunnar to make a new image which might take time. + +Most of the maintainers also hang out at #vmdb2 at #OFTC. You can either use your IRC client or [Riot client][11], register your name at Nickserv and connect with either Gunnar Wolf, Roman Perier or/and Lars Wirzenius, author of [vmdb2][12]. I might do a follow-up on vmdb2 as it’s a nice little tool by itself. + +### The Road Ahead + +If there are enough interest and contributors, for instance, the lowest-hanging fruit would be to make sure that the ARM64 port [wiki page][13] is as current as possible. The benefits are and can be enormous. + +There are a huge number of projects which could benefit from either having a [Pi farm][14] to making your media server or a SiP phone or whatever you want to play/work with. + +Another low-hanging fruit might be synchronization between devices, say an ARM cluster sharing reports to either a Debian desktop by way of notification or on mobile or both ways. + +While I have shared about Raspberry Pi, there are loads of single-board computers on the market already and lot more coming, both from MIPS as well as OpenRISC-V so there is going to plenty of competition in the days ahead. + +Also, OpenRISC-V is and would be open-sourcing lot of its IP so non-free firmware or binary blobs would not be needed. Even MIPS is rumored to be more open which may challenge ARM if MIPS and OpenRISC-V are able to get their logistics and pricing right, but that is a story for another day. + +There are many more vendors, I am just sharing the ones whom I am most interested to see what they come up with. + +I hope the above sheds some light why it makes sense to have Debian on the Raspberry Pi. + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/debian-raspberry-pi + +作者:[Shirish][a] +选题:[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/shirish/ +[b]: https://github.com/lujun9972 +[1]: https://www.raspberrypi.org/downloads/raspbian/ +[2]: https://itsfoss.com/reasons-why-i-love-debian/ +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/03/debian-raspberry-pi.png?resize=800%2C450&ssl=1 +[4]: https://wiki.debian.org/RaspberryPi3 +[5]: https://gwolf.org/node/4139 +[6]: https://www.debian.org/ +[7]: https://itsfoss.com/checksum-tools-guide-linux/ +[8]: https://github.com/Debian/raspi3-image-spec +[9]: https://lists.debian.org/debian-arm/2019/02/threads.html +[10]: https://alioth-lists.debian.net/pipermail/pkg-raspi-maintainers/Week-of-Mon-20190225/000310.html +[11]: https://itsfoss.com/riot-desktop/ +[12]: https://liw.fi/vmdb2/ +[13]: https://wiki.debian.org/Arm64Port +[14]: https://raspi.farm/ +[15]: https://wiki.debian.org/RaspberryPi3 diff --git a/translated/talk/20150513 XML vs JSON.md b/translated/talk/20150513 XML vs JSON.md deleted file mode 100644 index 01bef8bec7..0000000000 --- a/translated/talk/20150513 XML vs JSON.md +++ /dev/null @@ -1,109 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (wwhio) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (XML vs JSON) -[#]: via: (https://www.cs.tufts.edu/comp/150IDS/final_papers/tstras01.1/FinalReport/FinalReport.html) -[#]: author: (TOM STRASSNER tomstrassner@gmail.com) - -XML vs JSON -====== - -### 简介 - -XML 和 JSON 是现今互联网中最常用的两种数据交换格式。XML 格式由 W3C 于 1996 年提出。JSON 格式由 Douglas Crockford 于 2020 年提出。虽然这两种格式的设计目标并不相同,但它们常常用于数据交换中。XML 和 JSON 的文档都很完善([RFC 7159][1], [RFC 4825][2]),且都同时具有人类可读性human-readable机器可读性machine-readable。这两种格式并没有哪一个比另一个更强,只是各自适用的领域不用。(LCTT译注:W3C 是[互联网联盟](https://www.w3.org/),制定了各种 Web 相关的标准,如 HTML、CSS 等。Douglas Crockford 除了制定了 JSON 格式,还致力于改进 JavaScript,开发了 JavaScript 相关工具 [JSLint](http://jslint.com/) 和 [JSMin](http://www.crockford.com/javascript/jsmin.html)。) - -### XML 的优点 - -XML 与 JSON 相比有很多优点。二者间最大的不同在于 XML 可以通过在标签中添加属性这一简单的方法来存储元数据metadata。而使用 JSON 时需要创建一个对象,把元数据当作对象的成员来存储。虽然二者都能达到存储元数据的目的,但在这一情况下 XML 往往是更好的选择,因为 JSON 的表达形式会让客户端程序开发人员误以为要将数据转换成一个对象。举个例子,如果你的 C++ 程序需要使用 JSON 格式发送一个附带元数据的整型数据,需要创建一个对象,用对象中的一个名称/值对name/value pair来记录整型数据的值,再为每一个附带的属性添加一个名称/值对。接收到这个 JSON 的程序在读取后很可能把它当成一个对象,可事实并不是这样。虽然这是使用 JSON 传递元数据的一种变通方法,但他违背了 JSON 的核心理念:“JSON 的结构与常规的程序语言中的结构相对应,而无需修改。JSON's structures look like conventional programming language structures. No restructuring is necessary.”[2] - -虽然稍后我会说这也是 XML 的一个缺点,但 XML 中对命名冲突、前缀prefix的处理机制赋予了它 JSON 所不具备的能力。程序员们可以通过前缀来把统一名称给予两个不同的实体。[1]当不同的实体在客户端中使用的名称相同时,这一特性会非常有用。 - -XML 的另一个优势在于大多数的浏览器可以把它以具有高可读性和强组织性的方式highly readable and organized way展现给用户。XML 的树形结构让它易于结构化,浏览器也让用户可以自行展开或折叠树中的元素,这简直就是调试的福音。 - -XML 对比 JSON 有一个很重要的优势就是它可以记录混合内容mixed content。例如在 XML 中处理包含结构化标记的字符串时,程序员们只要把带有标记的文本放在一个标签内就可以了。可因为 JSON 只包含数据,没有用于指明标签的简单方式,虽然可以使用处理元数据的解决方法,但这总有点滥用之嫌。 - -### JSON 的优点 - -JSON 自身也有很多优点。其中最显而易见的一点就是 JSON 比 XML 简洁得多。因为 XML 中需要标签的打开和关闭,而 JSON 使用名称/值对表示数据,使用简单的“{”和“}”来标记对象,“\[”和“\]”来标记数组,“,”来表示数据的分隔,“:”表示名称和值的分隔。就算是使用 gzip 压缩,JSON 还是比 XML 要小,而且耗时更少。[6]正如 Sumaray 和 Makki 在实验中指出的那样,JSON 在很多方面都比 XML 更具优势,得出同样结果的还有 Nurseitov、Paulson、Reynolds 和 Izurieta。首先,由于 JSON 文件天生的简洁性,与包含相同信息的 XML 相比,JSON 总是更小,这意味着更快的传输和处理速度。第二,在不考虑大小的情况下,两组研究[3][4]表明使用 JSON 执行序列化和反序列化的速度显著优于使用 XML。第三,后续的研究指出 JSON 的处理在 CPU 资源的使用上也优于 XML。研究人员发现 JSON 在总体上使用的资源更少,其中更多的 CPU 资源消耗在用户空间,系统空间消耗的 CPU 资源较少。这一实验是在 RedHat 的设备上进行的,RedHat 表示更倾向于在用户空间使用 CPU 资源。[3]不出意外,Sumaray 和 Makki 在研究里还说明了在移动设备上 JSON 的性能也优于 XML。[4]这很直接,因为 JSON 消耗的资源更少,移动设备的性能也更弱。 - -JSON 的另一个优点在于其对对象和数组的表述和宿主语言host language中的数据结构相对应,例如对象object记录record结构体struct字典dictionary哈希表hash table键值列表keyed list还有数组array向量vector列表list,以及对象组成的数组等等。[2] 虽然 XML 里也能表达这些数据结构,也只需调用一个函数就能完成解析,但往往需要更多的代码才能正确的完成 XML 的序列化和反序列化处理。而且 XML 对于人类来说不如 JSON 那么直观,XML 标准缺乏对象、数组的标签的明确定义。当结构化的标记可以替代嵌套的标签时,JSON 的优势极为突出。JSON 中的花括号和中括号则明确表示了数据的结构,当然这一优势也包含前文中的问题,在表示元数据时 JSON 不如 XML 准确。 - -虽然 XML 支持命名空间namespace前缀prefix,但这不代表 JSON 没有处理命名冲突的能力。比起 XML 的前缀,它处理命名冲突的方式更简洁,在程序中的处理也更自然。在 JSON 里,每一个对象都在它自己的命名空间中,因此不同对象内的元素名称可以随意重复。在大多数编程语言中,不同的对象中的成员可以包含相同的名字,所以 JSON 根据对象进行名称区分的规则在处理时更加自然。 - -也许 JSON 比 XML 更优的部分是因为 JSON 是 JavaScript 的子集,所以在 JavaScript 代码中对它的解析或封装都非常的自然。虽然这看起来对 JavaScript 程序非常有用,而其他程序则不能直接从中获益,可实际上这一问题已经被很好的解决了。现在 JSON 的网站的列表上展示了 64 种不同语言的 175 个工具,它们都实现了处理 JSON 所需的函数。虽然我不能评价大多数工具的质量,但它们的存在明确了开发者社区拥抱 JSON 这一现象,而且它们切实简化了在不同平台使用 JSON 的难度。 - -### 二者的动机 - -简单地说,XML 的目标是完成一种文档标记。这和 JSON 的目标想去甚远,所以只要用得到 XML 的地方就尽管用。它使用树形的结构和包含语义的文本来表达混合内容以实现这一目标。在 XML 中可以表示数据的结构,但这并不是它的长处。 - -JSON’s purpose is structured data interchange. It serves this purpose by directly representing objects, arrays, numbers, strings, and booleans. Its purpose is distinctly not document markup. As described above, JSON does not have a natural way to represent mixed content. -JSON 的目标是用于数据交换的一种结构化表示。它直接使用对象、数组、数字、字符串、布尔值这些元素来达成这一目标。这完全不同于文档标记语言。正如上面说的那样,JSON 没有原生支持混合内容mixed content的记录。 - -### 软件 - -这些主流的开放 API 仅提供 XML:亚马逊产品广告 APIAmazon Product Advertising API。 - -这些主流 API 仅提供 JSON:脸书图 APIFacebook Graph API谷歌地图 APIGoogle Maps API推特 APITwitter API,AccuWeather API,Pinterest API,Reddit API,Foursquare API。 - -这些主流 API 同时提供 XML 和 JSON:谷歌云存储Google Cloud Storage领英 APILinkedin API,Flickr API。 - -根据可编程网络Programmable Web[9]的数据,最流行的 10 个 API 中只有一个是仅提供 XML 且不支持 JSON 的。其他的要么同时支持 XML 和 JSON,要么只支持 JSON。这表明了大多数应用开发者都更倾向于使用支持 JSON 的 API,原因大概是 JSON 更快的处理速度与良好口碑,加之与 XML 相比更加轻量。此外,大多数 API 只是传递数据而非文档,所以 JSON 更加合适。例如 Facebook 的重点在于用户的交流与帖子,谷歌地图则主要处理坐标和地图信息,AccuWeather 就只传递天气数据。总之,虽然不能说天气 API 在使用时究竟是 JSON 用的多还是 XML 用的多,但是趋势明确偏向了 JSON。[10][11] - -这些主流的桌面软件仍然只是用 XML:Microsoft Word,Apache OpenOffice,LibraOffice。 - -因为这些软件需要考虑引用、格式、存储等等,所以比起 JSON,XML 优势更大。另外,这三款程序都支持混合内容,而 JSON 在这一点上做得并不如 XML 好。举例说明,当用户使用 Microsoft Word 编辑一篇论文时,用户需要使用不同的文字字形、文字大小、文字颜色、页边距、段落格式等,而 XML 结构化的组织形式与标签属性生来就是为了表达这些信息的。 - -这些主流的数据库支持 XML:IBM DB2,Microsoft SQL Server,Oracle Database,PostgresSQL,BaseX,eXistDB,MarkLogic,MySQL。 - -这些是支持 JSON 的主流数据库:MongoDB,CouchDB,eXistDB,Elastisearch,BaseX,MarkLogic,OrientDB,Oracle Database,PostgresSQL,Riak。 - -在很长一段时间里,SQL 和关系型数据库统治着整个数据库市场。像甲骨文Oracle微软Microsoft这样的软件巨头都提供这类数据库,然而近几年 NoSQL 数据库正逐步受到开发者的青睐。也许是正巧碰上了 JSON 的普及,大多数 NoSQL 数据库都支持 JSON,像 MongoDB、CouchDB 和 Riak 这样的数据库甚至使用 JSON 来存储数据。这些数据库有两个重要的特性是它们适用于现代网站:一是它们与关系型数据库相比更容易扩展more scalable;二是它们设计的目标就是 web 运行所需的核心组件。由于 JSON 更加轻量,又是 JavaScript 的子集,所以很适合 NoSQL 数据库,并且让这两个品质更容易实现。此外,许多旧的关系型数据库增加了 JSON 支持,例如 Oracle Database 和 PostgresSql。由于 XML 与 JSON 间的转换比较麻烦,所以大多数开发者会直接在他们的应用里使用 JSON,因此开发数据库的公司才有支持 JSON 的理由。(LCTT译注:NoSQL是对不同于传统的关系数据库的数据库管理系统的统称。[参考来源](https://zh.wikipedia.org/wiki/NoSQL)) - -### 未来 - -对互联网的种种变革中,最让人期待的便是物联网Internet of Things。这会给互联网带来大量计算机之外的设备,例如手表、温度计、电视、冰箱等等。这一势头的发展良好,预期在不久的将来迎来爆发式的增长。据估计,到 2020 年时会有 260 亿 到 2000 亿的物联网设备被接入互联网。[12][13] 几乎所有的物联网设备都是小型设备,因此性能比笔记本或台式电脑要弱很多,而且大多数都是嵌入式系统。因此,当他们需要与互联网上的系统交换数据时,更轻量,更快速的 JSON 自然比 XML 更受青睐。[10] 受益于 JSON 在 web 上的快速普及,与 XML 相比,这些新的物联网设备更有可能从使用 JSON 中受益。这是一个典型的梅特卡夫定律的例子,无论是 XML 还是 JSON,抑或是什么其他全新的格式,现存的设备和新的设备都会从支持最广泛使用的格式中受益。 - -Node.js 是一款服务器端的 JavaScript 框架,随着她的诞生与快速成长,与 MongoDB 等 NoSQL 数据库一起,让全栈使用 JavaScript 开发成为可能。这些都预示着 JSON 光明的未来,这些软件的出现让 JSON 运用在全栈开发的每一个环节成为可能,这将使应用更加轻量,响应更快。这也是任何应用的追求之一,所以,全栈使用 JavaScript 的趋势在不久的未来都不会消退。[10] - -此外,另一个应用开发的趋势是从 SOAP 转向 REST。[11][15][16] XML 和 JSON 都可以用于 REST,可 SOAP 只能使用 XML。 - -从这些趋势中可以推断,JSON 的发展将统一 Web 的信息交换格式,XML 的使用率将继续降低。虽然不应该把 JSON 吹过头了,因为 XML 在 Web 中的使用依旧很广,而且它还是 SOAP 的唯一选择,可考虑到 SOAP 到 REST 的迁移,NoSQL 数据库和全栈 JavaScript 的兴起,JSON 卓越的性能,我相信 JSON 很快就会在 Web 开发中超过 XML。至于其他领域,XML 比 JSON 更好的情况并不多。 - - -### 参考链接 - -1. [XML Tutorial](http://www.w3schools.com/xml/default.asp) -2. [Introducing JSON](http://www.json.org/) -3. [Comparison of JSON and XML Data Interchange Formats: A Case Study](http://www.cs.montana.edu/izurieta/pubs/caine2009.pdf) -4. [A comparison of data serialization formats for optimal efficiency on a mobile platform](http://dl.acm.org/citation.cfm?id=2184810) -5. [JSON vs. XML: The Debate](http://ajaxian.com/archives/json-vs-xml-the-debate) -6. [JSON vs. XML: Some hard numbers about verbosity](http://www.codeproject.com/Articles/604720/JSON-vs-XML-Some-hard-numbers-about-verbosity) -7. [How JSON sparked NoSQL -- and will return to the RDBMS fold](http://www.infoworld.com/article/2608293/nosql/how-json-sparked-nosql----and-will-return-to-the-rdbms-fold.html) -8. [Did You Say "JSON Support" in Oracle 12.1.0.2?](https://blogs.oracle.com/OTN-DBA-DEV-Watercooler/entry/did_you_say_json_support) -9. [Most Popular APIs: At Least One Will Surprise You](http://www.programmableweb.com/news/most-popular-apis-least-one-will-surprise-you/2014/01/23) -10. [Why JSON will continue to push XML out of the picture](https://www.centurylinkcloud.com/blog/post/why-json-will-continue-to-push-xml-out-of-the-picture/) -11. [Thousands of APIs Paint a Bright Future for the Web](http://www.webmonkey.com/2011/03/thousand-of-apis-paint-a-bright-future-for-the-web/) -12. [A Simple Explanation Of 'The Internet Of Things’](http://www.forbes.com/sites/jacobmorgan/2014/05/13/simple-explanation-internet-things-that-anyone-can-understand/) -13. [Proofpoint Uncovers Internet of Things (IoT) Cyberattack](http://www.proofpoint.com/about-us/press-releases/01162014.php) -14. [The Internet of Things: New Threats Emerge in a Connected World](http://www.symantec.com/connect/blogs/internet-things-new-threats-emerge-connected-world) -15. [3,000 Web APIs: Trends From A Quickly Growing Directory](http://www.programmableweb.com/news/3000-web-apis-trends-quickly-growing-directory/2011/03/08) -16. [How REST replaced SOAP on the Web: What it means to you](http://www.infoq.com/articles/rest-soap) - - --------------------------------------------------------------------------------- - -via: https://www.cs.tufts.edu/comp/150IDS/final_papers/tstras01.1/FinalReport/FinalReport.html - -作者:[TOM STRASSNER][a] -选题:[lujun9972][b] -译者:[wwhio](https://github.com/wwhio) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: tomstrassner@gmail.com -[b]: https://github.com/lujun9972 -[1]: https://tools.ietf.org/html/rfc7159 -[2]: https://tools.ietf.org/html/rfc4825 diff --git a/translated/talk/20160921 lawyer The MIT License, Line by Line.md b/translated/talk/20160921 lawyer The MIT License, Line by Line.md new file mode 100644 index 0000000000..5de277d592 --- /dev/null +++ b/translated/talk/20160921 lawyer The MIT License, Line by Line.md @@ -0,0 +1,292 @@ +[#]: collector: (lujun9972) +[#]: translator: (Amanda0212) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (lawyer The MIT License, Line by Line) +[#]: via: (https://writing.kemitchell.com/2016/09/21/MIT-License-Line-by-Line.html) +[#]: author: (Kyle E. Mitchell https://kemitchell.com/) + + +MIT许可证的“精华” +====== + +### MIT许可证的“精华” + +[MIT许可证][1] 是最流行的开源软件许可证,请阅读下面的内容。 + +#### 阅读许可证 + +如果你参与了开源软件的开发,然而你还没有花时间从头开始阅读尽管只有171个单词的许可证,你现在就需要这么做,尤其是如果许可证不是你的日常生活。记住任何看起来不对劲或不清楚的事情,然后继续思考。我将重复上下文和评论的每一个字,按块和顺序。但重要的是你要做到心中有数。 + +> MIT 许可证 +> +> 版权(c)<年份><版权持有人> +> +> 现免费准许任何人取得本软件及相关文件档案("软件")的副本,以便不受限制地处理该软件,包括不受限制地使用、复制、修改,合并、公布、分发、转授许可证和/或出售软件副本的权利,并允许向其提供软件的人这样做,但须符合下列条件: +> +> 在软件和软件的所有副本中都必须包含版权声明和许可声明。 +> +> 该软件是"原封不动地"提供的,没有任何明示或默示的保证,包括但不限于适销性、适合某一特定目的和不侵权的保证。在任何情况下,作者或版权所有人都不应对因下列原因引起的任何索赔、损害或其他责任负责,与软件或软件中的使用或其他交易有关的。 + +许可证由五个部分组成,在逻辑组成上像下面这样: + + * **页眉** + * **许可证所有权** : “MIT执照” + * **版权公告** : “版权 (c) …” + * **许可证授予** : “特此批准 …” + * **授予范围** : “… 在软件方面的处理 …” + * **条件** : “… 服从于 …” + * **归属和通知** : “以上...应包含...在内” + * **保修免责声明** : “该软件“原封不动地”提供...” + * **赔偿责任限制** : “在任何情况下....” + + + +我们开始了: + +#### 写在前面 + +##### 许可证所有权 + +> 麻省理工许可证(MIT) + +“麻省理工许可证”并不是一个单一的许可证,而是包含来自于麻省理工学院为发布而准备的语言的一系列许可证表格。这些年来,无论是对于使用它的原始项目都经历了许多变化,还是作为其他项目的模型。fedora项目保持了一种[mit许可证陈列室的种类][2],在简单文本中保留了微小的变化,如甲醛中的解剖标本,追踪着一种没有规律的进化。 + +幸运的是,[开源计划][3]和[数据交换软件包][4]组已经将通用的MIT式许可证表格标准化为“mit许可证”。而OSI则将SPDX的标准化[字符串识别符][5]用于普通的开源许可证,“MIT”明确指向标准化的表格“MIT许可证”。 + +即使在“许可证”文件中包含“MIT许可证”或“SPDX:MIT”,负责任的评论者为了确定仍然会对文本和标准表单进行比较。尽管各种自称为“麻省理工许可证”的许可证表格只在细节上有所不同,但所谓的“麻省理工许可证”的宽松已经诱使一些作者添加了令人讨厌的“定制”。典型的可怕的的例子就是[JSON许可证][6],一个MIT-family许可证加上“软件应该用于正途的,而不是邪恶的...”这种事情可能是“非常克罗克福德”。这绝对是一个痛苦的事情。可能是律师们开的一个玩笑,但他们一路笑到最后。 + +这个故事的寓意是:“麻省理工许可证”本身是模棱两可的。人们或许对你的意思有清晰的理解,但是你只会通过将标准的MIT许可证表格的文本复制到你的项目中来节省所有人的时间,包括你自己。如果您使用元数据,如包管理器元数据文件中的“许可证”属性来指定“MIT”许可证,请确保您的“许可证”文件和任何头注使用标准窗体文本。而这些都可以[自动化][7]。 + +##### 版权公告 + +> 版权(c)<年份><版权持有人> + +直到1976年的版权法,美国版权法要求采取具体行动以确保创作作品的版权,称为“手续”。如果你没有遵循这些手续,你起诉他人未经授权使用你的作品的权利是有限的,但这种权利基本丧失。其中一种形式是“通知”:在你的作品上做标记,或者在声明过后让市场知道你拥有版权。 © 是标记有版权作品的标准符号,以发出版权通知。ascii字符集没有 © 符号,但是“版权(c)”得到了这种权利。 + +1976年“执行”了伯尔尼国际公约的许多要求版权法却取消了保护版权的手续。至少在美国,版权拥有者仍然需要在起诉侵权行为之前登记他们的版权作品,但如果他们在侵权行为开始前登记,也许会造成更高的损害。然而,现实中许多人在提起诉讼之前登记了版权。你不会因为只是没有在版权上张贴通知、注册、向国会图书馆发送副本等行为而失去版权。 + +即使版权公告不再像过去那样绝对必要,但它们仍然很有用。说明作品创作的年份和版权持有者,使人们对作品的版权何时到期有某种感觉,从而使作品进入公共领域。作者的身份也很有用:美国法律对个人和“公司”两种身份的作者的版权计算方法不同。尤其是在商业上,即使许可条款给予非常慷慨的许可,公司也有必要对使用已知竞争对手的软件三思而后行。如果你希望别人看到你的作品,并希望从你那里获得许可,版权公告就可以很好裁决归属问题。 + +至于“版权持有人”:并不是所有的标准格式许可证都有地方写出来。近期的许可证表格,如[apache 2.0][8]和[gpl 3.0][9],发布“许可证”文本,这些文本本应逐字复制,与头注和单独的文件其他地方,以表明谁拥有版权,并正在给予许可证。这些做法有意无意地阻止了对"标准"文本的更改,还使自动许可证认证更加可靠。 + +MIT许可证是机构为发布代码而编写的语言。对于机构发布,只有一个明确的“版权持有人”,即机构发布代码。其他一些机构用他们自己的名字代替了“MIT”,最终形成了我们现在的通用格式。这个过程重复了这个时代的其他短形式的机构许可证,值得注意的是加州大学伯克利分校的[原四条款BSD许可证][10],现在用于[三条款][11]和[二条款][12]的变体,以及互联网系统联盟(MIT的一种变体)的(ISC许可证)。 + +在所有情况下,机构都将自己列为版权所有人,以依赖版权所有权规则,称为"[受雇作品][14]"规则,这就给了雇主和客户一些版权,他们的雇员和承包商代表他们做的工作。这些规则通常不适用于自愿提交代码的分布式合作者。这给项目管理者基金会带来了一个问题,比如apache基金会和日食基金会,这些基金会接受了来自更多样化的捐助者群体的捐助。到目前为止,通常的基础方法是使用一种房屋许可证,该许可证规定只有一个版权持有人——[Apache 2.0][8]和[EPL 1.0][15]——由出资人许可证协议支持——[apache clas][16]并且[clas][17]——从贡献者那里收集权利。在像GPL这样的“版权许可”下,在一个地方收集版权所有权更加重要,因为它依赖于版权所有人强制执行许可条件以促进软件自由值。 + +如今,只有很少的任何机构或企业管理者的项目在使用MIT式的许可证条款。SPDX和OSI通过规范MIT和ISC等不涉及特定实体或机构版权持有人的许可证形式,帮助了这些案例的使用。有了这些表格,项目作者的普遍做法是在很早表格的版权通知时就填写他们自己的名字,也许会在这里或那里增加一年的时间。至少根据美国版权法,由此产生的版权通知并没有给出一个完整的情况。 + +软件的原拥有者保留对其作品的所有权。但是,尽管MIT式的许可条款赋予了其他人在软件上进行开发和更改的权利,创造了法律所称的“衍生作品”,但它们并没有赋予原始作者在他人贡献中的版权所有权。相反,每个贡献者都拥有以现有代码为起点的作品的版权。 + +这些项目中的大多数也对接受贡献者许可协议的想法有所保留,更不用说签署版权转让了。这其实很好理解。尽管假定一些较新的开源开发者对github“自动”发送退出请求,根据项目的现有许可条款授权分配贡献,但美国法律不承认这样的规则。默认的是强有力的版权保护,而不是许可许可。 + +更新:GitHub后来改变了它在整个网站的服务条款,包括试图翻转这个默认,至少在GitHub.com。我已经写了一些关于这个发展的想法,不是所有的都是积极的,在[另一个帖子][19]。 + +为填补具有法律效力的且有充分文件证明的捐款权利授予与完全没有书面记录之间的空白,一些项目采用了[开发商原产地证书][20],一个标准的语句贡献者暗示在他们的Git提交中使用“签名关闭”元数据标签。在臭名昭著的SCO诉讼事件之后,Linux内核开发人员为Linux内核开发了原产地证书,该诉讼指控Linux的代码块来自于SCO拥有的UNIX源代码。作为一种创建文件线索的手段,显示每一行Linux代码的贡献者,开发人员原产地证书的功能很好。虽然开发人员的原产地证书不是许可证,但它确实提供了大量的证据,证明提交代码的人希望项目分发他们的代码,并让其他人在内核的现有许可条款下使用。内核还维护一个机器可读的“信用”文件,列出具有名称、关联、贡献区域和其他元数据的贡献者。我已经做了[一些][实验][22]将这种方法应用于不使用内核开发流程的项目。 + +#### 许可授权 + +> 现免费准许任何人取得本软件及相关文件档案("软件")的副本. + +按照猜测,麻省理工执照的重点是执照。一般而言,许可是一个人或一个法律规定的实体----"许可人"----允许另一人----"被许可人"----做法律本来允许他们起诉的事情。MIT执照承诺不起诉。 + +法律有时会将许可证与承诺颁发许可证区分开来。如果有人违背了给他发许可证的承诺,你也许可以控告他违反了承诺,但你可能没有得到许可证。"在此"是律师们无法摆脱的时髦的古语之一。它在这里用来显示许可证文本本身给出了许可证,而不仅仅是一个许可证的承诺。这是合法的[IIFE][23]。 + +虽然许多许可证给予许可的具体命名的许可证,麻省理工学院许可证则是一个“公共许可证”。公共许可证给予广大公众许可。这是开放源码许可的三大理念之一。MIT许可证通过向“获得该软件副本的任何人”颁发许可证来捕捉这一想法。正如我们将在后面看到的,若获得这个许可证也有一个条件,以确保其他人也会知道他们的许可。 + +在美国式的法律文件中,用大写的引号(一个“定义”)来表示术语的标准方法。当法院在文件的其他地方看到一个定义明确、资本化的术语时,大写的引号将会很可靠地回顾定义的术语。 + +##### 授予范围 + +> 不受限制的软件处理 + +麻省理工许可证中最重要的七个词就是从被许可人的观点来看。其关键的法律问题是被起诉侵犯版权和被起诉侵犯专利。版权法和专利法都没有使用“处理”作为术语,它在法庭上没有具体的含义。因此,对许可人与被许可人之间的争议作出裁决的任何法院都会询问该措词所指的当事人的含义和理解。法院将会看到的是,该描述是不详细的和开放式的。这给了被许可人一个强有力的论据——在许可人没有允许被许可人对软件做特定的事情时反对许可人的任何主张,即使在许可的时候,这一想法都没有出现。 + + +> 包括在不受限制的情况下使用、复制、修改、合并、公布、分发、转授许可证和/或出售软件副本的权利,以及允许软件给予者这样做的权利。 + +没有哪篇法律文章是完美的,“在根本上完全解决”,或者明确无误的。要小心那些装模作样的人。这是麻省理工执照中最不完美的部分。有三个主要问题: + +首先,"包括不受限制"是一种法律上的反模式。它产生了各种理解: + + * “包括,不受限制” + * “包括,在不限制上述一般性的情况下” + * “包括,但不局限于” + * 很多很多毫无意义的措辞变化 + + + +所有这些都有共同的目标,但都没能真正地实现。从根本上说,它们的创始人也在尝试从中得到好处。在MIT许可证中,这意味着引入“软件交易”,其具体示例是“使用、复制、修改”等等,而不是暗示被许可人的行为必须类似于给出的“交易”的示例。问题是,如果你最终需要一个法庭来审查和解释许可证的条款,法庭则看作找出那些争论的语言的含义。法院不能“忽略”示例决定什么是“交易”,,即使你告诉它。也是较短的。 + +第二,作为“处理”的例子给出的动词是一个大杂烩。有些在版权法或专利法下有特定的含义,有些却没有: + + *使用出现在[美国法典第35章,第271(a)条][24],专利法的清单中,列出了专利所有人可以因未经许可而起诉他人的行为。 + + *复制出现在《版权法》(美国法典第17编第106条)[25]中,列出了版权所有人可以因未经许可而起诉他人的行为 + + *修改不出现在版权或专利法规中。它可能最接近版权法规下的“准备衍生作品”,但也可能涉及改进或其他衍生发明。 + + *合并没有出现在版权或专利法规中。“合并”在版权上有特定的含义,但这显然不是这里的本意。相反,法院可能根据其在业界的含义来理解“合并”,如“合并代码”。 + + *出版不出现在版权或专利法规中。由于“软件”是发布的内容,它可能最接近于[版权法规][25]下的“发布”。法律也涵盖了“公开”表演和展示作品的权利,但这些权利只适用于特定类型的有版权的作品,如戏剧、录音和电影。 + + *散布出现在[版权法规][25]中。 + + *次级许可是知识产权法的总称。转牌权是指利用给予他人自己的执照做一些有权利做的事情的权利。MIT许可证的转行权在开源许可证中是不常见的。每个人只要拿到软件及其许可条款的副本,就可以直接从所有者那里得到许可,这就是Heather Meeker所说的“直接授权”方法。任何可能通过麻省理工许可证获得次级许可证的人,很可能最终会得到一份许可证副本,告诉他们自己也有直接许可证。 + + *出售的副本是一个混合物。它接近[专利法规][24]中的"要约销售"和"销售",却指的是版权概念中的"副本"。在版权方面,它似乎接近“发行”,但[版权法规][25]没有提到出售。 + + *允许向软件提供者这样做,"次级许可"似乎是多余的并且也是不必要的,因为人们得到的副本也获得了直接许可证。 + + + +最后,由于法律、工业、一般知识产权和一般用途条款的混淆,目前还不清楚麻省理工学院的许可证是否包括专利许可证。一般的语言“处理”和一些例子动词,特别是“使用”,指向专利许可,尽管是一个非常不清楚的。许可证来自版权持有人,他对软件中的发明可能有也可能没有专利权,以及大多数示例动词和"软件"本身的定义,所有这些都强烈指向版权许可证.更近期的许可开放源码许可证,如[apache 2.0][8],涉及单独和具体的版权、专利甚至商标。 + +##### 许可证的三个条件 + +> 须符合以下条件: + +总有人能符合MIT的三个条件! + +如果你不遵守麻省理工的许可条件,你就得不到许可。因此,如果不按条件所说的做,至少在理论上,你会面临一场诉讼,很可能是一场版权诉讼。 + +利用软件的价值来激励被许可人遵守条件,即使被许可人没有为许可支付任何费用,是开源许可的第二个伟大想法。最后一个,在MIT许可证中没有,建立在许可证条件的基础上:“版权”许可证,像[GNU通用公共许可证][9]使用利益来控制那些进行更改的人去许可和分发他们的更改版本。 + +##### 公告条件 + +> 上述版权通知和许可通知应包含在软件的副本的绝大部分内容中。 + +如果你给某人软件的副本,你需要包括许可证文本和任何版权通知。这有几个关键目的: + + 1.通知他人他们有许可使用该软件的公共许可证。这是直接授权模式的一个关键部分,即每个用户直接从版权持有人那里获得许可证。 + + 2.让他们知道谁是软件的参与者,使得他们能够接受检验。 + + 3.确保免责声明和赔偿责任限制(下一步)伴随软件。每个得到副本的人也应该得到一份这些许可人保护的副本。 + + + +没有源代码的情况下,没有什么可以阻止您付费获得副本,甚至是编译形式的副本。但是当你这样做的时候,你不能假装MIT的代码是你自己的专有代码,或者是在其他许可证下提供的代码。领取者得了解他们在"公共许可证"下的权利。 + +坦率地说,这一条件很难去遵守。几乎每个开源许可证都有这样的“归属”条件。系统和已安装软件的制造商通常都明白,他们需要为自己的每个版本编写一个通知文件或“许可证信息”,并为库和组件提供许可证文本的副本。项目管理基金会在传授这些做法方面发挥了重要作用。但总体而言,网络开发者并没有得到这份备忘录。这不能用缺少工具来解释——有大量的工具——或者是来自npm和其他存储库的软件包的高度模块化性质——它们统一地将许可证信息的元数据格式标准化。所有好的JavaScript迷你机都有用于保存许可证标题注释的命令行标记。其他工具将从包装箱树连接“许可证”文件。实在没有理由去遗忘这一条件。 + +##### 保护免责声明 + +> 该软件是"原封不动地"提供的,没有任何明示或默示的保证,包括但不限于适销性、适合某一特定目的和不侵权的保证。 + +美国几乎每个州都颁布了统一商业法典,这是一个规范商业交易的法律范本。加州大学洛杉矶分校(UCC)的第2条则规定了货物销售合同,从旧汽车的购进到工业化学品的大规模运输,再到制造工厂。 + +加州大学洛杉矶分销关于销售合同的某些规则是强制性的。不管那些买卖他们喜欢与否这些规则总是适用的。而其他的只是“默认”。除非买卖双方以书面形式选择不参与,否则UCC暗示他们希望在UCC的文本中找到他们交易的基准规则。在默认规则中,隐含着“保证”,或卖方向买方承诺所售货物的质量和可用性。 + +对于像MIT许可证这样的公共许可证到底是合同(许可人和被许可人之间可执行的协议)还是仅仅只是许可证(只有一种方式,但可能附带条件),存在着很大的争论。而关于软件是否算作“商品”的争论则较少,这触发了UCC的规则。许可证持有者之间没有关于赔偿责任的争论:他们不想因为大量的钱财而被起诉,如果他们赠送的软件是免费、则会引起一些麻烦。这与“默认保证”的三个默认规则正好相反: + + 1.[UCC第2-314][26]条对"适销性"的默认保证是"货物"或者软件应至少具有平均质量,包装和适当的标签,适合他们的用途。这个保证只适用于提供软件的人是软件的“商人”,这意味着他们从事软件交易,并坚持自己在软件方面很熟练。 + + 2.[UCC第2-315][27]条中关于"适合某一特定目的"的默认保证,在卖方知道买方因为某一用途而购买软件时,默认保护是有用的。因此,货物必须"合适"。 + + 3.“不侵权”的默认保证不是合同约定的一部分,而是一般合同法的共同特征。如果买方收到的货物侵犯了他人的知识产权,该默认承诺保护买方。如果MIT许可下的软件实际上不属于试图授权它的软件,或者它属于其他人拥有的专利,就不会去保护买方。 + + + +UCC[章节 2-316(3)][28]条要求选择或"排除"关于适销性和适合某一特定目的的隐含保证的语言非常一目了然。而“显眼”则意味着书写或格式化的目的是为了引起人们对其本身的注意,这与微观的细微印刷相反,其目的是为了避开不谨慎的消费者。州法律可能对不侵权的免责声明规定类似的吸引注意力的要求。 + +长期以来,律师们一直被一种错觉所困扰,认为用“全盖”写任何东西都符合明显的要求,然而这确实假的。法院已经批判了这一标准,因为它太假了,而且大多数人都同意全上限的做法更多的是为了阻止阅读,而不是强迫阅读。尽管如此,大多数开源许可证的格式都将其保证免责声明设置为全上限,部分原因是这是唯一明显的方法,可以使其在纯文本“许可证”文件中脱颖而出。我宁愿用星号或其他的ASCII艺术,但那已经很久了。 + +##### 限制 +> 在任何情况下,作者或版权持有人均不对因下列原因而引起的任何索赔、损害或其他责任承担任何责任或是与软件或者软件中的使用或其他交易有关的责任。 + +MIT许可证允许“免费”使用软件,但法律并不认为获得免费许可证的人会在事情出了差错时放弃起诉的权利,而应归咎于许可人。“赔偿责任限制”,通常与“损害赔偿排除”结合在一起,就像保证不起诉一样,很像许可证。但这些是对许可人免受被许可人诉讼的保护。 + +一般来说,法院谨慎地解读赔偿责任和损害赔偿排除的限制,因为它们可以将巨大的风险从一方转移到另一方。为了保护社区的重大利益,他们“严格解释”限制责任的语言让人们能够纠正在法庭上犯下的错误,在可能的情况下对照受其保护的语言来解读。限制赔偿责任必须是明确的,才能成立。尤其是在“消费者”合同和其他情况下,那些放弃起诉权的人缺乏技巧或议价能力,法院有时拒绝尊重那些言外之意。律师们由于这个原因可能也由于纯粹的习惯而倾向于限制给予赔偿责任。 + +只要稍微钻低一点,“赔偿责任限额”就是被许可人可以起诉的金额的上限。在开源许可证中,这个限制总是没有钱的——0美元,“不负责任”。相比之下,在商业许可证中,尽管它通常是经过协商的而决定出为过去12个月期间支付的许可证费用的倍数。 + +"排除"部分具体列出了各类法律索赔以及许可人不能使用造成损害赔偿的理由。和许多法律形式一样,MIT执照提到了“合同”行为中的违约行为和“侵权行为”。侵权行为规则是防止不小心或恶意伤害他人的一般规则。如果你发短信的时候在路上撞上了某人,你就犯下了侵权行为。如果你的公司出售的耳机有问题,让人耳朵发麻,那么你的公司就犯下了侵权行为。如果合同没有明确排除侵权索赔,法院有时会在合同中阅读排除语,以防止只发生合同索赔。为了更好地衡量这种排除部分,麻省理工的执照上写着“或者其他”,仅仅是不同寻常的法律主张。 + +"产生于、或与之有关"这句话是法律起草人固有的、焦虑的不安全感的反复出现的症状。重点是任何与软件有关的诉讼都在限制和排除范围之内。在偶然的机会,一些东西可以"产生",但不是"产生",或"联系",不必介意它在形式上的三种的说法。出现在不同地方的同一个词语或许都是不同意思,假设一个专业起草人不会使用不同的词语在一排的意思相同的事情则不必介意,在实践中,如果法院对一开始就不满意想这个限制,那么他们就会非常愿意仔细地解读范围触发因素。但我离题了。同样的语言出现在数百万份合同中或许理解都不一样。 + +#### 总结 + +这些俏皮话虽然有点像碎碎念,但MIT许可证却是法律上的经典。MIT许可证是有用的。虽然MIT式的许可证非常出色但它绝不是解决所有软件ip弊病的灵丹妙药,尤其是早于它几十年出现的软件专利的祸害。实现了用最低限度的谨慎的法律工具组合来扭转麻烦的版权、销售和合同法的默认规则这个狭隘的目标。在更大的计算环境中,它的生命周期是惊人的。MIT许可证的有效期已经超过了它所授权的绝大多数软件。我们只能猜测,当它最终对那些自己请不起律师的人失去好感时,它将提供多少几十年忠实的法律服务。 + +我们已经看到了我们今天所知的MIT许可证是一套具体的、标准化的术语,最终给机构特有的、随意变化的混乱带来了秩序。 + +我们已经看到了它是如何为学术、标准、商业和基金会机构的知识产权管理实践提供归属和版权通知的依据。 + +我们已经看到了MIT许可证是如何向所有人免费授予软件许可的,但我们必须遵守保护许可人免受担保和赔偿责任的条件。 + +我们已经看到,尽管有一些不是很精准的词和修饰,但这一百七十一个词已经足够严谨,能够通过一个密集的知识产权和合同为开源软件开辟新的道路。 + +我非常感谢所有愿意花时间来阅读这篇长文的人,让我知道他们认为它有用,并帮助改进它。和往常一样,我欢迎您通过[电子邮件][29], [推特][30], 和 [GitHub][31].发表评论。 + +若是想阅读更多的内容或者找到其他许可证的概要,比如GNU公共许可证或者Apache 2.0许可证。无论你有什么关于这方面的兴趣,我都衷心推荐以下的书: + + * Andrew M. St. Laurent’s [Understanding Open Source & Free Software Licensing][32], from O’Reilly. + +我是这本书开始入门的,虽然它有点过时,但它的方法也最接近上面使用的逐行方法。O’Reilly 已经在网上提供了它。 + + * Heather Meeker’s [Open (Source) for Business][34] + +在我看来,目前为止,关于GNU公共许可证和版权写的比较好的已经有很多了。这本书涵盖了许可证的历史、发展、以及兼容性和合规性。这是我借给客户的书,考虑或处理GPL。 + + * Larry Rosen’s [Open Source Licensing][35], from Prentice Hall. + +这是很棒的一本书,也[在线][36]免费的。这是对程序员关于从零开始的开源许可和相关法律的最好的介绍。虽然这一点也有点过时了,但是在一些具体的细节中拉里对许可证的分类法和对开源商业模式的简洁总结是经得起时间考验的。 + + + +所有的这些教育都对作为开源授权律师的我至关重要。他们的作者是我这行的英雄。强烈推荐阅读!-- K.E.M + +我在[创意共享许可4.0版本][37]授权这篇文章. + +-------------------------------------------------------------------------------- + +via: https://writing.kemitchell.com/2016/09/21/MIT-License-Line-by-Line.html + +作者:[Kyle E. Mitchell][a] +选题:[lujun9972][b] +译者:[Amanda0212](https://github.com/Amanda0212) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://kemitchell.com/ +[b]: https://github.com/lujun9972 +[1]: http://spdx.org/licenses/MIT +[2]: https://fedoraproject.org/wiki/Licensing:MIT?rd=Licensing/MIT +[3]: https://opensource.org +[4]: https://spdx.org +[5]: http://spdx.org/licenses/ +[6]: https://spdx.org/licenses/JSON +[7]: https://www.npmjs.com/package/licensor +[8]: https://www.apache.org/licenses/LICENSE-2.0 +[9]: https://www.gnu.org/licenses/gpl-3.0.en.html +[10]: http://spdx.org/licenses/BSD-4-Clause +[11]: https://spdx.org/licenses/BSD-3-Clause +[12]: https://spdx.org/licenses/BSD-2-Clause +[13]: http://www.isc.org/downloads/software-support-policy/isc-license/ +[14]: http://worksmadeforhire.com/ +[15]: https://www.eclipse.org/legal/epl-v10.html +[16]: https://www.apache.org/licenses/#clas +[17]: https://wiki.eclipse.org/ECA +[18]: https://en.wikipedia.org/wiki/Feist_Publications,_Inc.,_v._Rural_Telephone_Service_Co. +[19]: https://writing.kemitchell.com/2017/02/16/Against-Legislating-the-Nonobvious.html +[20]: http://developercertificate.org/ +[21]: https://github.com/berneout/berneout-pledge +[22]: https://github.com/berneout/authors-certificate +[23]: https://en.wikipedia.org/wiki/Immediately-invoked_function_expression +[24]: https://www.govinfo.gov/app/details/USCODE-2017-title35/USCODE-2017-title35-partIII-chap28-sec271 +[25]: https://www.govinfo.gov/app/details/USCODE-2017-title17/USCODE-2017-title17-chap1-sec106 +[26]: https://leginfo.legislature.ca.gov/faces/codes_displaySection.xhtml?sectionNum=2314.&lawCode=COM +[27]: https://leginfo.legislature.ca.gov/faces/codes_displaySection.xhtml?sectionNum=2315.&lawCode=COM +[28]: https://leginfo.legislature.ca.gov/faces/codes_displaySection.xhtml?sectionNum=2316.&lawCode=COM +[29]: mailto:kyle@kemitchell.com +[30]: https://twitter.com/kemitchell +[31]: https://github.com/kemitchell/writing/tree/master/_posts/2016-09-21-MIT-License-Line-by-Line.md +[32]: https://lccn.loc.gov/2006281092 +[33]: http://www.oreilly.com/openbook/osfreesoft/book/ +[34]: https://www.amazon.com/dp/1511617772 +[35]: https://lccn.loc.gov/2004050558 +[36]: http://www.rosenlaw.com/oslbook.htm +[37]: https://creativecommons.org/licenses/by-sa/4.0/legalcode diff --git a/translated/talk/20180206 Building Slack for the Linux community and adopting snaps.md b/translated/talk/20180206 Building Slack for the Linux community and adopting snaps.md deleted file mode 100644 index ef97cf3485..0000000000 --- a/translated/talk/20180206 Building Slack for the Linux community and adopting snaps.md +++ /dev/null @@ -1,71 +0,0 @@ -为 Linux 社区采用 snaps 搭建 Slack -====== -![][1] - -作为一个被数以百万计用户使用的企业级软件平台,[Slack][2] 允许任意规模的团队和企业有效地沟通。Slack 通过在一个单一集成环境中与其它软件工具无缝衔接,为一个组织内的通讯、信息和项目提供了一个易于接触的档案馆。尽管自从诞生后 Slack 就在过去四年中快速成长,但是他们负责该平台跨 Windows、MacOS 和 Linux 运行的桌面工程师团队仅由四人组成。我们通过与在这个团队中负责追踪[上月首发的 Slack snap][3] 的主任工程师 Felix Rieseberg 交谈,来探索更多有关该公司对于 Linux 社区的态度以及他们决定搭建一个 snap 的原因。 - -[安装 Slack snap][4] - -### 你们能告诉我们更多关于已发布的 Slack snap 的信息吗? - -我们上月发布了我们的第一个 snap 作为我们为Linux 社区的一种新的发布形式。在企业界,我们发现人们更倾向于以一种相对于个人消费者较慢的速度来采用新科技, 因此我们将会在未来继续提供 .deb 形式的 snap。 - -### 你们觉得 Linux 社区会对 Slack 有多大的兴趣呢? - -在所有的平台上人们对 Slack 的兴趣都正在增长,这一点使我感到十分兴奋。因此这对于我们来说,很难说源自 Linux 社区的兴趣和我们大体上所见到的兴趣有什么区别。当然,不管用户们在什么平台上面工作,满足他们对我们都是很重要的。我们有一个专门负责 Linux 的测试工程师并且我们同时也尽全力提供最好的用户体验。只是我们发现总体相对于 Windows 来说,为 Linux 搭建 snap 略微有点难度,因为我们是在一个较难以预测的平台上工作——而这正是 Linux 社区之光照耀的领域。在汇报程序缺陷以及寻找程序崩溃原因方面,我们有相当多数极富帮助的用户。 - -### 你们是如何得知 snap 的? - -Canonical 公司的 Martin Wimpress 和我接触并向我解释了 snap 的概念。说实话尽管我也用 Ubuntu 但最初我还是迟疑的,因为它看起来像需要搭建与维护的另一套标准。尽管如此,一当我了解到其中的好处之后,我确信这是一笔有回报的投入。 - -### snap 的什么方面吸引了你们并使你们决定投入其中? - -毫无疑问,我们决定搭建 snap 最重要的原因是它的更新特性。在 Slack 上我们大量运用网页技术,这些技术反过来也使得我们提供大量的特性——比如将 YouTube 视频或者 Spotify 播放列表集成在 Slack 中。与浏览器十分相似,这意味着我们需要频繁更新应用。 - -在 MacOS 和 Windows 上,我们已经有了一个甚至无需用户考虑更新的专门的自动更新器。我们发现哪怕是为了更新,任何形式的中断都是一种我们需要避免的烦恼。因此通过 snap 自动化的更新就显得无缝和便捷得多。 - -### 相比于其它形式的打包方式,搭建 snap 感觉如何? 将它与现有的设施和进程集成在一起有多简便呢? - -就 Linux 而言,我们尚未尝试其它新的打包方式,但我们迟早会的。鉴于我们的大多数用户都使用 Ubuntu,snap 是一个很简便的选项。同时 snap 在其它发行版上同样也可以使用,这也是一个巨大的加分项。Canonical 正将 snap 做到跨发行版而不是仅仅集中在 Ubuntu 上,这一点我认为是很好的。 - -搭建 snap 简单得出乎意料,我们有一个创建安装器和软件包的统一流程,我们的 snap 创建过程从一个 .deb 软件包炮制出一个 snap。对于其它技术而言,有时候我们不得不为了支持搭建链先造一个内部工具。但是 snapcraft 工具正是我们需要的东西。在整个过程中 Canonical 的团队不可思议般得有助,因为我们一路上确实碰到了一些问题。 - -### 你们觉得 snap 商店是如何改变用户们寻找、安装你们软件的方式的呢? - -Slack 真正的独特之处在于人们不仅仅是碰巧发现它,他们从别的地方知道它并积极地试图找到它。因此尽管我们已经有了相当高的觉悟,我希望对于我们的用户来说,在商店中可以获得 snap 能够让安装过程变得简单一点。 - -### 你们对用 snap 而不是为了其它发行版不得不再发行软件包有什么期待,或者有什么已经是你们可见的节省呢? - -我们希望 snap 可以给予我们的用户更多的便利并确保他们能够更加享受使用 Slack。在我们看来,鉴于用户们不必被困在之前的版本,这自然而然地解决了许多问题,因此 snap 可以让我们在客户支持方面节约时间。有 snap 对我们来说也是一个额外的加分项,因为我们能有一个可供搭建的平台而不是替换我们现有的东西。 - -### 如果存在的话,你们正使用或者准备使用边缘 (edge)、测试 (beta)、候选 (candidate)、稳定 (stable) 中的哪种发行频道? - -我们仅仅在开发中使用边缘 (edge) 频道以与 Canonical 的团队共享。为 Linux 打造的 Slack 总体任在测试 (beta) 频道中。但是长远来看,拥有不同频道的选项十分有意思,同时能够提早一点为感兴趣的客户发行版本也肯定是有好处的。 - -### 你们认为将软件打包成一个 snap 是如何能够帮助用户的?你们从用户那边得到了什么反馈吗? - -对我们的用户来说一个很大的好处是安装和更新总体来说都会变得简便一点。长远来看,问题在于“那些安装 snap 的用户是不是比其它用户少碰到一些困难?”,我十分期望 snap 自带的依赖关系能够使其变成可能。 - -### 你们有什么会和刚使用 snap 的新用户们分享的建议或知识呢? - -我会推荐从 Debian 软件包来着手搭建你们的 snap——那出乎意料得简单。这同样也缩小了开始的范围避免变得不堪重负。这只需要投入相当少的时间,并且很大可能是一笔值得的投入。同样如果你们可以的话,尽量试着找到 Canonical 的人员来协作——他们拥有了不起的工程师。 - -### 对于开发来说,你们在什么地方看到了最大的机遇? - -我们现在正一步步来,先是让人们用上 snap,再从那里开始搭建。正在使用 snap 的人们将会感到更加稳健因为他们将会得益于最新的更新。 - --------------------------------------------------------------------------------- - -via: https://insights.ubuntu.com/2018/02/06/building-slack-for-the-linux-community-and-adopting-snaps/ - -作者:[Sarah][a] -译者:[tomjlw](https://github.com/tomjlw) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://insights.ubuntu.com/author/sarahfd/ -[1]:https://insights.ubuntu.com/wp-content/uploads/a115/Slack_linux_screenshot@2x-2.png -[2]:https://slack.com/ -[3]:https://insights.ubuntu.com/2018/01/18/canonical-brings-slack-to-the-snap-ecosystem/ -[4]:https://snapcraft.io/slack/ diff --git a/translated/talk/20190114 Remote Working Survival Guide.md b/translated/talk/20190114 Remote Working Survival Guide.md deleted file mode 100644 index 54893cbdca..0000000000 --- a/translated/talk/20190114 Remote Working Survival Guide.md +++ /dev/null @@ -1,129 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (beamrolling) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Remote Working Survival Guide) -[#]: via: (https://www.jonobacon.com/2019/01/14/remote-working-survival/) -[#]: author: (Jono Bacon https://www.jonobacon.com/author/admin/) - -远程工作生存指南 -====== -![](https://www.jonobacon.com/wp-content/uploads/2019/01/5b5471d7eadb585ec8b8a0c3_featureimage-remotejob-1080x675.jpg) - -远程工作似乎是最近的一个热门话题。CNBC 报道称, [70% 的专业人士至少每周在家工作一次][1]。同样地,CoSo Cloud 调查发现, [77% 的人在远程工作时效率更高][2] ,而 aftercollege 的一份调查显示, [8% 的千禧一代会更多地考虑提供远程工作的公司][3]。 这看起来很合理:技术,网络以及文化似乎越来越推动远程工作的发展。哦,自制咖啡也比以前任何时候更好喝了。 - -目前,我准备写另一篇关于公司如何优化远程工作的文章(所以请确保你加入我们的会员以持续关注——这是免费的)。 - -但今天,我想 **分享一些个人如何做好远程工作的建议**。 不管你是全职远程工作者,或者是可以选择一周某几天在家工作的人,希望这篇文章对你有用。 - -眼下,你需要明白, **远程工作不是万能药**。当然,穿着睡衣满屋子乱逛,听听反社会音乐,喝一大杯咖啡看起来似乎挺完美的,但这不适合每个人。 - -有的人需要办公室的结构。有的人需要办公室的社会元素。有的人需要从家里走出来。有的人在家里缺乏保持关注的纪律。有的人因为好几年未缴退税而避免政府工作人员来住处敲门。 - -**远程工作就好像一块肌肉:如果你锻炼并且保持它,那么它能带来极大的力量和能力**。 如果不这么做,结果就不一样了。 - -在我职业生涯的大多数时间里,我在家工作。我喜欢这么做。当我在家工作的时候,我更有效率,更开心,更有能力。我并非不喜欢在办公室工作,我享受办公室的社会元素,但我更喜欢在家工作时我的“空间”。 我喜欢听重金属音乐,但当整个办公室的人不想听到 [After The Burial][5] 的时候,这会引起一些问题。 -![][6] -“Squirrel.” -[图片来源][7] - -已经学会了如何正确平衡工作,旅行以及其他元素来管理我的远程工作,以下是我的一些建议。 请务必**在评论中分享一些你的建议**。 - -### 1\.你需要训练和习惯(以及了解你的“波浪”) - -远程工作确实是需要训练的一块肌肉。就像构建真正的肌肉一样,它需要一个清楚的惯例和一小块健康的训练混合起来。 - -永远保持穿戴整齐(不要穿睡衣)。设置你一天工作的开始和结束时间(大多时候我从早上9点工作到下午6点)。选好你的午餐休息时间(我的是中午12点)。选好你的早晨仪式(我的是电子邮件,紧接着是全面审查客户需求)。决定你的主工作地在哪(我的主工作地是我家里的工作室)。决定好每天你什么时候运动(大多数时候我在下午5点运动)。 - -**设计一个实际的习惯并坚持66天**。构建一个习惯需要很长时间,不要尝试着背离你的习惯。你越坚持这个习惯,做下去所花费的功夫越少。在这66天的末尾,你想都不会想,自然而然地就按习惯去做了。 - -话虽这么说,我们又不住在真空里 ([更干净,或者别的什么][8])。我们都有自己的“波浪”。 - -“波浪”是你为了改变做事的方法时,对日常做出的一些改变。举个例子,夏天的时候我通常需要更多的阳光。那时我经常会在室外的花园工作。临近假期的时候我更容易分心,所以我在上班时间会更需要呆在室内。有时候我只想要多点人际接触,因此我会在咖啡馆工作几周。有时候我就是喜欢在厨房或者长椅上工作。你需要学习你的“波浪”并倾听你的身体。 **首先构建你自己的兴趣,然后在你认识到自己的“波浪”的时候再对它进行适当的修改**。 - -### 2\. 和你的同事以及上司一起设立预期 - -不是每个人都知道怎么远程工作,如果你的公司对远程工作没那么熟悉,你尤其需要和同事一起设立预期。 - -这件事十分简单:**当你要设计自己的工作日常的时候,清楚地跟你的上司和团队进行交流。**让他们知道如何找到你,紧急情况下如何联系你,以及你在家的时候如何保持合作。 - -这里的通信构件至关重要。有些远程工作者很怕离开他们的电脑,因为害怕当他们不在的时候有人给他们发消息(他们担心别人会觉得他们在边吃奇多边看 Netflix)。 - -你需要离开一会的时间。你需要吃午餐的时候眼睛不用一直盯着电脑屏幕。你又不是911接线员。 **设定预期以后,有时候你可能不能立刻回复,但你会尽快回复**。 - -同样地,设定你的一般可用性的预期。举个例子,我对客户设立的预期是我一般每天早上9点到下午6点工作。当然,如果某个客户急需某样东西,我很乐意在这段时间外回应他,但作为一个一般性规则,我通常只在这段时间内工作。这对于生活的平衡是必要的。 - -### 3\. 分心是你的敌人,它们需要管理 - -我们都会分心,这是人类的本能。让你分心的事情可能是你的孩子回家了,想玩变形金刚:救援机器人;可能是看看Facebook,Instagram,或者 Twitter 以确保你不会错过任何不受欢迎的政治观点,或者某人的午餐图片;可能是你生活中即将到来的某件事带走了你的注意力(例如,即将举办的婚礼,活动,或者一次大旅行)。 - -**你需要明白什么让你分心以及如何管理它**。举个例子,我知道我的电子邮件和 Twitter 会让我分心。我经常查看它们,并且每次查看都会让我脱离我正在工作的空间。拿水或者咖啡的时候我总会分心去吃零食,看 Youtube 的视频。 - -![][9] -我的分心克星 - -由电子产品造成的分心有一个简单对策:**锁起来**。直到你完成你手头的事情再关闭选项卡。有繁重的工作的时候我总这么干:我把让我分心的东西锁起来,直到做完手头的工作。这需要控制能力,但所有的一切都需要。 - -因为别人影响而分心的元素更难解决。如果你是有家庭的人,你需要在你工作的时候不被打扰,你通常需要独处。这也是为什么家庭办公室这么重要:你需要设一些“爸爸/妈妈正在工作”的界限。如果有急事才能进来,否则让孩子自个儿玩去。 - -把让你分心的事分开有许多方法:把你的电话静音;把自己的状态设成“离开”;换到一个没有让你分心的事的房间(或建筑物)。再重申一次,了解是什么让你分心并控制好它。如果不这么做,你会永远被分心的事摆布。 - -### 4\. (良好的)关系需要面对面的关注 - -有的角色比其他角色与远程工作更合拍。例如,我见过工程、质量保证、支持、安全以及其他团队(通常更专注于数字协作)的出色工作。其他团队,如设计或营销,往往在远程环境下更难熬(因为它们更注重触觉)。 - -但是,对于任何团队而言,建立牢固的关系至关重要,而现场讨论,协作和社交很有必要。我们的许多感官(例如肢体语言)在数字环境中被删除,这些在我们建立信任和关系的方式中发挥着关键作用。 - -![][10] -火箭也很有帮助 - -这尤为重要,如果(a)你初来这家公司,需要建立关系;(b)你是一个新角色,需要和你的团队建立关系;或者(c)你处于领导地位,建立买入和参与是你工作的关键部分。 - -**解决方法是?合理搭配远程工作与面对面的时间。** 如果你的公司就在附近,可以用一部分的时间在家工作,一部分时间在公司工作。如果你的公司比较远,安排定期前往办公室(并对你的上司设定你需要这么做的预期)。例如,当我在 XPRIZE 工作的时候,我每几周就会飞往洛杉矶几天。当我在 Canonical 工作时(总部在伦敦),我们每三个月来一次冲刺。 - -### 5\. 保持专注,不要松懈 - -本文所有内容的关键在于构建能力,并培养远程工作的肌肉。这就像建立你的日常,坚持它,并明白你的“波浪”和让你分心的事情以及如何管理它们一样简单。 - -我以一种相当具体的方式来看待这个世界:**我们所做的一切都有机会得到改进和完善**。举个例子,我已经公开演讲超过 15 年,但我总是能发现新的改进方法,以及修复新的错误(说到这些,请参阅我的 [提升你公众演讲的10个方法][11])。 - -发现新的改善方法,以及把每个绊脚石和错误视为一个开启新的不同的“啊哈!”时刻让人兴奋。远程工作和这没什么不同:寻找有助于解锁方式的模式,让你的远程工作时间更高效,更舒适,更有趣。 - -![][12] -看看这些书。它们非常适合个人发展。 -参阅我的 [150 美元个人发展工具包][13] 文章 - -...但别为此狂热。有的人花尽他们每一分钟来关注如何变得更好,他们经常以“做得还不够好”,“完成度不够高”等为由打击自己,无法达到他们内心关于完美的不切实际的观点。 - -我们都是人,我们是有生命的,不是机器人。始终致力于改进,但要明白不是所有东西都是完美的。你将会有一些休息日或休息周。你将会因为压力和倦怠而挣扎。你将会处理一些在办公室比远程工作更容易的情况。从这些时刻中学习,但不要沉迷于此。生命太短暂了。 - -**你有什么提示,技巧和建议吗?你如何管理远程工作?我的建议中还缺少什么吗?在评论区中与我分享!** - - --------------------------------------------------------------------------------- - -via: https://www.jonobacon.com/2019/01/14/remote-working-survival/ - -作者:[Jono Bacon][a] -选题:[lujun9972][b] -译者:[beamrolling](https://github.com/beamrolling) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: https://www.jonobacon.com/author/admin/ -[b]: https://github.com/lujun9972 -[1]: https://www.cnbc.com/2018/05/30/70-percent-of-people-globally-work-remotely-at-least-once-a-week-iwg-study.html -[2]: http://www.cosocloud.com/press-release/connectsolutions-survey-shows-working-remotely-benefits-employers-and-employees -[3]: https://www.aftercollege.com/cf/2015-annual-survey -[4]: https://www.jonobacon.com/join/ -[5]: https://www.facebook.com/aftertheburial/ -[6]: https://www.jonobacon.com/wp-content/uploads/2019/01/aftertheburial2.jpg -[7]: https://skullsnbones.com/burial-live-photos-vans-warped-tour-denver-co/ -[8]: https://www.youtube.com/watch?v=wK1PNNEKZBY -[9]: https://www.jonobacon.com/wp-content/uploads/2019/01/IMG_20190114_102429-1024x768.jpg -[10]: https://www.jonobacon.com/wp-content/uploads/2019/01/15381733956_3325670fda_k-1024x576.jpg -[11]: https://www.jonobacon.com/2018/12/11/10-ways-to-up-your-public-speaking-game/ -[12]: https://www.jonobacon.com/wp-content/uploads/2019/01/DwVBxhjX4AgtJgV-1024x532.jpg -[13]: https://www.jonobacon.com/2017/11/13/150-dollar-personal-development-kit/ diff --git a/translated/talk/20190121 Booting Linux faster.md b/translated/talk/20190121 Booting Linux faster.md new file mode 100644 index 0000000000..60645965b1 --- /dev/null +++ b/translated/talk/20190121 Booting Linux faster.md @@ -0,0 +1,54 @@ +[#]: collector: (lujun9972) +[#]: translator: (alim0x) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Booting Linux faster) +[#]: via: (https://opensource.com/article/19/1/booting-linux-faster) +[#]: author: (Stewart Smith https://opensource.com/users/stewart-ibm) + +更快启动 Linux +====== +进行 Linux 内核与固件开发的时候,往往需要多次的重启,会浪费大把的时间。 +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tux_linux_penguin_code_binary.jpg?itok=TxGxW0KY) +在所有我拥有或使用过的电脑中,启动最快的那台是 20 世纪 80 年代的电脑。在你把手从电源键移到键盘上的时候,BASIC 解释器已经在等待你输入命令了。对于现代的电脑,启动时间从笔记本电脑的 15 秒到小型家庭服务器的数分钟不等。为什么它们的启动时间有差别? + +那台直接启动到 BASIC 命令行提示符的 20 世纪 80 年代微电脑,有着一颗非常简单的 CPU,它在通电的时候就立即开始从一个存储地址中获取和执行指令。因为这些系统在 ROM 里面有 BASIC,基本不需要载入的时间——你很快就进到 BASIC 命令提示符中了。同时代更加复杂的系统,比如 IBM PC 或 Macintosh,需要一段可观的时间来启动(大约 30 秒),尽管这主要是因为需要从软盘上读取操作系统的缘故。在可以加载操作系统之前,只有很小一部分时间是花在固件上的。 + +现代服务器往往在从磁盘上读取操作系统之前,在固件上花费了数分钟而不是数秒。这主要是因为现代系统日益增加的复杂性。CPU 不再能够只是起来就开始全速执行指令,我们已经习惯于 CPU 频率变化,节省能源的待机状态以及 CPU 多核。实际上,在现代 CPU 内部有惊人数量的更简单的处理器,它们协助主 CPU 核心启动并提供运行时服务,比如在过热的时候压制频率。在绝大多数 CPU 架构中,在你的 CPU 内的这些核心上运行的代码都以不透明的二进制 blob 形式提供。 + +在 OpenPOWER 系统上,所有运行在 CPU 内部每个核心的指令都是开源的。在有 [OpenBMC][1](比如 IBM 的 AC922 系统和 Raptor 的 TALOS II 以及 Blackbird 系统)的机器上,这还延伸到了运行在基板管理控制器上的代码。这就意味着我们可以一探究竟,到底为什么从接入电源线到显示出熟悉的登陆界面花了这么长时间。 + +如果你是内核相关团队的一员,你可能启动过许多内核。如果你是固件相关团队的一员,你可能要启动许多不同的固件映像,接着是一个操作系统,来确保你的固件仍能工作。如果我们可以减少硬件的启动时间,这些团队可以更有生产力,并且终端用户在搭建系统或重启安装固件或系统更新的时候会对此表示感激。 + +过去的几年,Linux 发行版的启动时间已经做了很多改善。现代 init 系统在处理并行和按需任务上做得很好。在一个现代系统上,一旦内核开始执行,它可以在短短数秒内进入登陆提示符界面。这里短短的数秒不是优化启动时间的下手之处,我们得到更早的地方:在我们到达操作系统之前。 + +在 OpenPOWER 系统上,固件通过启动一个存储在固件闪存芯片上的 Linux 内核来加载操作系统,它运行一个叫做 [Petitboot][2] 的用户态程序去寻找用户想要启动的系统所在磁盘,并通过 [kexec][3] 启动它。有了这些优化,启动 Petitboot 环境只占了启动时间的个位数百分比,所以我们还得从其他地方寻找优化项。 + +在 Petitboot 环境启动前,有一个先导固件,叫做 [Skiboot][4],在它之前有个 [Hostboot][5]。在 Hostboot 之前是 [Self-Boot Engine][6],一个 die 上的单独核心,它启动单个 CPU 核心并执行来自 Level 3 缓存的指令。这些组件是我们可以在减少启动时间上取得进展的主要部分,因为它们花费了启动的绝大部分时间。或许这些组件中的一部分没有进行足够的优化或尽可能做到并行? + +另一个研究路径是重启时间而不是启动时间。在重启的时候,我们真的需要对所有硬件重新初始化吗? + +正如任何现代系统那样,改善启动(或重启)时间的方案已经变成了更多并行、解决遗留问题、(可以认为)作弊的结合体。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/booting-linux-faster + +作者:[Stewart Smith][a] +选题:[lujun9972][b] +译者:[alim0x](https://github.com/alim0x) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/stewart-ibm +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/OpenBMC +[2]: https://github.com/open-power/petitboot +[3]: https://en.wikipedia.org/wiki/Kexec +[4]: https://github.com/open-power/skiboot +[5]: https://github.com/open-power/hostboot +[6]: https://github.com/open-power/sbe +[7]: https://linux.conf.au/schedule/presentation/105/ +[8]: https://linux.conf.au/ diff --git a/translated/tech/20120203 Computer Laboratory - Raspberry Pi- Lesson 3 OK03.md b/translated/tech/20120203 Computer Laboratory - Raspberry Pi- Lesson 3 OK03.md deleted file mode 100644 index 21cdb40c2f..0000000000 --- a/translated/tech/20120203 Computer Laboratory - Raspberry Pi- Lesson 3 OK03.md +++ /dev/null @@ -1,383 +0,0 @@ -[#]: collector: (lujun9972) -[#]: translator: (qhwdw) -[#]: reviewer: ( ) -[#]: publisher: ( ) -[#]: url: ( ) -[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 3 OK03) -[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok03.html) -[#]: author: (Robert Mullins http://www.cl.cam.ac.uk/~rdm34) - -计算机实验室 – 树莓派:课程 3 OK03 -====== - -OK03 课程基于 OK02 课程来构建,它教你在汇编中如何使用函数让代码可复用和可读性更好。假设你已经有了 [课程 2:OK02][1] 的操作系统,我们将以它为基础。 - -### 1、可复用的代码 - -到目前为止,我们所写的代码都是以我们希望发生的事为顺序来输入的。对于非常小的程序来说,这种做法很好,但是如果我们以这种方式去写一个完整的系统,所写的代码可读性将非常差。我们应该去使用函数。 - -``` -一个函数是一段可复用的代码片断,可以用于去计算某些答案,或执行某些动作。你也可以称它们为程序、整套动作或子动作。虽然它们都是不同的,但人们几乎都没有正确地使用这个术语。 - -你应该在数学上遇到了函数的概念。例如,余弦函数应用于一个给定的数时,会得到介于 -1 到 1 之间的另一个数,这个数就是角的余弦。一般我们写成 cos(x) 来表示应用到一个值 x 上的余弦函数。 - -在代码中,函数可以有多个输入(也可以没有输入),然后函数给出多个输出(也可以没有输出),并可能导致负面效应。例如一个函数可以在一个文件系统上创建一个文件,第一个输入是它的名字,第二个输入是文件的长度。 -``` - -![Function as black boxes][2] - -``` -函数可以认为是一个“黑匣子”。我们给它输入,然后它给我们输出,而我们不需要知道它是如何工作的。 -``` - -在像 C 或 C++ 这样的高级代码中,函数是语言的组成部分。在汇编代码中,函数只是我们的创意。 - -理想情况下,我们希望能够在我们的寄存器中设置一些值,分支地址,以及预期在某个时刻,分支将返回,并通过代码来设置输出值到寄存器。这就是我们所设想的汇编代码中的函数。困难之处在于我们用什么样的方式去设置寄存器。如果我们只是使用平时所接触到的任意方法去设置寄存器,每个程序可能使用不同的方法,这样你将会发现你很难理解其他程序员所写的代码。另外,编译器也不能像使用汇编代码那样轻松地工作,因为它们压根不知道如何去使用函数。为避免这种困惑,为每个汇编语言设计了一个称为应用程序二进制接口(ABI)的标准,由它来规范函数如何去运行。如果每个人都使用相同的方法去写函数,这样每个人都可以去使用其他人写的函数。在这里,我将教你们这个标准,而从现在开始,我所写的函数将全部遵循这个标准。 - -标准规定,寄存器 `r0`、`r1`、`r2` 和 `r3` 将被依此用于函数的输入。如果函数没有输入,那么它有没有值就无关紧要了。如果只需要一个输入,那么它应该总是在寄存器 `r0` 中,如果它需要两个输入,那么第一个输入在寄存器 `r0` 中,而第二个输入在寄存器 `r1` 中,依此类推。输出值也总是在寄存器 `r0` 中。如果函数没有输出,那么 `ro` 中是什么值就不重要了。 - -另外,标准要求当一个函数运行之后,寄存器 `r4` 到 `r12` 的值必须与函数启动时的值相同。这意味着当你调用一个函数时,你可以确保寄存器 `r4` 到 `r12` 中的值没有发生变化,但是不能确保寄存器 `r0` 到 `r3` 中的值也没有发生变化。 - -当一个函数运行完成后,它将返回到启动它的代码分支处。这意味着它必须知道启动它的代码的地址。为此,需要一个称为`lr`(链接寄存器)的专用寄存器,它总是在保存调用这个函数的指令的地址。 - -表 1.1 ARM ABI 寄存器用法 -| 寄存器 | 简介 | 保留 | 规则 | -| ------ | ---------- | ---- | ------------------------------------------------------------ | -| r0 | 参数和结果 | 否 | r0 和 r1 用于给函数传递前两个参数,以及函数返回的结果。如果函数返回值不使用它,那么在函数运行之后,它们可以携带任何值。 | -| r1 | 参数和结果 | 否 | | -| r2 | 参数 | 否 | r2 和 r3 用去给函数传递后两个参数。在函数运行之后,它们可以携带任何值。 | -| r3 | 参数 | 否 | | -| r4 | 通用寄存器 | 是 | r4 到 r12 用于保存函数运行过程中的值,它们的值在函数调用之后必须与调用之前相同。 | -| r5 | 通用寄存器 | 是 | | -| r6 | 通用寄存器 | 是 | | -| r7 | 通用寄存器 | 是 | | -| r8 | 通用寄存器 | 是 | | -| r9 | 通用寄存器 | 是 | | -| r10 | 通用寄存器 | 是 | | -| r11 | 通用寄存器 | 是 | | -| r12 | 通用寄存器 | 是 | | -| lr | 返回地址 | 否 | 当函数运行完成后,lr 中保存了分支的返回地址,但在函数运行完成之后,它将保存相同的地址。 | -| sp | 栈指针 | 是 | sp 是栈指针,在下面有详细描述。它的值在函数运行完成后,必须是相同的。 | - -通常,函数需要使用很多的寄存器,而不仅是 `r0` 到 `r3`。但是,由于 `r4` 到 `r12` 必须在系列动作完成之后值必须保持相同,因此它们需要被保存到某个地方。我们将它们保存到称为栈的地方。 - - -![Stack diagram][3] -``` -一个栈就是我们在计算中用来保存值的一个很形象的方法。就像是摞起来的一堆盘子,你可以从上到下来移除它们,而添加它们时,你只能从下到上来添加。 - -在函数运行时,使用栈来保存寄存器值是个非常好的创意。例如,如果我有一个函数需要去使用寄存器 r4 和 r5,它将在一个栈上存放这些寄存器的值。最后用这种方式,它可以再次将它拿回来。更高明的是,如果为完成运行我的函数,需要去运行另一个函数,并且那个函数需要保存一些寄存器,在它运行时,它将把寄存器保存在栈顶上,然后在结束后再将它们拿走。而这并不会影响我保存在寄存器 r4 和 r5 中的值,因为它们是在栈顶上添加的,拿走时也是从栈顶上取出的。 - -我们用专用的术语“栈帧”来表示使用特定的方法放到栈上的值。不是每种方法都使用一个栈帧,有些是不需要存储值的。 -``` - -因为栈非常有用,它被直接实现在 ARMv6 的指令集中。一个名为 `sp` (栈指针)的专用寄存器用来保存栈的地址。当需要有东西添加到栈上时,`sp` 寄存器被更新,这样就总是保证它保存的是栈上前一个东西的地址。`push {r4,r5}` 将推送 `r4` 和 `r5` 中的值到栈顶上,而 `pop {r4,r5}` 将(以正确的次序)取回它们。 - -### 2、我们的第一个函数 - -现在,关于函数的原理我们已经有了一些概念,我们尝试来写一个函数。由于是我们的第一个很基础的例子,我们写一个没有输入的函数,它将输出 GPIO 的地址。在上一节课程中,我们就是写到这个值上,但将它写成函数更好,因为我们在真实的操作系统中经常需要用到它,而我们不可能总是能够记住这个地址。 - -复制下列代码到一个名为 `gpio.s` 的新文件中。就像在`source` 目录中使用的 `main.s` 一样。我们将把与 GPIO 控制器相关的所有函数放到一个文件中,这样更好查找。 - -```assembly -.globl GetGpioAddress -GetGpioAddress: -ldr r0,=0x20200000 -mov pc,lr -``` - -```assembly -.globl lbl 使标签 lbl 从其它文件中可访问。 - -mov reg1,reg2 复制 reg2 中的值到 reg1 中。 -``` - -这就是一个很简单的完整的函数。`.globl GetGpioAddress` 命令是通知汇编器,让标签 `GetGpioAddress` 在所有文件中全局可访问。这意味着在我们的 `main.s` 文件中,我们可以使用分支指令到标签 `GetGpioAddress` 上,即便这个标签在那个文件中没有定义也没有问题。 - -你应该认得 `ldr r0,=0x20200000` 命令,它将 GPIO 控制器地址保存到 r0 中。由于这是一个函数,我们要让它输出寄存器 `r0` 中的值,因此我们不能再像以前那样随意使用任意一个寄存器了。 - -`mov pc,lr` 将寄存器 `lr` 中的值复制到 `pc` 中。正如前面所提到的,寄存器 `lr` 总是保存着方法完成后我们要返回的代码的地址。`pc` 是一个专用寄存器,它总是包含下一个要运行的指令的地址。一个普通的分支命令只需要改变这个寄存器的值即可。通过将 `lr` 中的值复制到 `pc` 中,我们就可以将运行的下一行命令改变成我们将要返回的那一行。 - -现在这里存在一个合乎常理的问题,那就是我们如何去运行这个代码?我们将需要一个特殊的分支类型 `bl`。它像一个普通的分支一样切换到一个标签,但它在切换之前先更新 `lr` 的值去包含一个分支之后的行的地址。这意味着当函数完成后,将返回到 `bl` 命令之后的那一行上。这就确保了函数能够像任何其它命令那样运行,它简单地运行,做任何需要做的事情,然后推进到下一行。这是函数最有用的方法。当我们使用它时,就将它们按“黑匣子”处理即可,不需要了解它是如何运行的,我们只了解它需要什么输入,以及它给我们什么输出即可。 - -到现在为止,我们已经明白了函数如何使用,下一节我们将使用它。 - -### 3、一个大的函数 - -现在,我们继续去实现一个更大的函数。我们的第一项任务是启用 GPIO 第 16 号针脚的输出。如果它是一个函数那就太好了。我们能够简单地指定针脚号作为函数的输入,然后函数将设置那个针脚的值。那样,我们就可以使用这个代码去控制任意的 GPIO 针脚,而不只是 LED 了。 - -将下列的命令复制到 `gpio.s` 文件中的 GetGpioAddress 函数中。 - -```assembly -.globl SetGpioFunction -SetGpioFunction: -cmp r0,#53 -cmpls r1,#7 -movhi pc,lr -``` - -``` -带后缀 ls 的命令只有在上一个比较命令的结果是第一个数字小于或等于第二个数字的情况下才会被运行。它是无符号的。 - -带后缀 hi 的命令只有上一个比较命令的结果是第一个数字大于第二个数字的情况下才会被运行。它是无符号的。 -``` - -在写一个函数时,我们首先要考虑的事情就是输入,如果输入错了我们怎么办?在这个函数中,我们有一个输入是 GPIO 针脚号,而它必须是介于 0 到 53 之间的数字,因为只有 54 个针脚。每个针脚有 8 个函数,被编号为 0 到 7,因此函数代码也必须是 0 到 7 之间的数字。我们可能假设输入应该是正确的,但是当在硬件上使用时,这种做法是非常危险的,因为不正确的值将导致极大的负面效应。所以,在这个案例中,我们希望确保输入值在正确的范围。 - -为了确保输入值在正确的范围,我们需要做一个检查,即 r0 <= 53 并且 r1 <= 7。首先我们使用前面看到的比较命令去将 `r0` 的值与 53 做比较。下一个指令 `cmpls` 仅在前一个比较指令结果是小于等于 53 时才会去运行。如果一切正常,它将寄存器 `r1` 的值与 7 进行比较,其它的部分都和前面的是一样的。如果最后的比较结果是寄存器值大于那个数字,最后我们将返回到运行函数的代码处。 - -这正是我们所希望的效果。如果 r0 中的值大于 53,那么 `cmpls` 命令将不会去运行,但是 `movhi` 会运行。如果 r0 中的值 <= 53,那么 `cmpls` 命令会运行,将 r1 中的值与 7 进行比较,如果它大于 7,`movhi` 会运行,函数结束,否则 `movhi` 不会运行,这样我们就确定 r0 <= 53 并且 r1 <= 7。 - -`ls`(低于或相同)与 `le`(小于或等于)有一些细微的差别,以及后缀 `hi` (高于)和 `gt` (大于)也一样有一些细微差别,我们在后面将会讲到。 - -将这些命令复制到上面的代码的下面位置。 - -```assembly -push {lr} -mov r2,r0 -bl GetGpioAddress -``` - -```assembly -push {reg1,reg2,...} 复制列出的寄存器 reg1、reg2、... 到栈顶。该命令仅能用于通用寄存器和 lr 寄存器。 - -bl lbl sets lr 设置下一个指令的地址并切换到标签 lbl。 -``` - -这三个命令用于调用我们第一个方法。`push {lr}` 命令复制 `lr` 中的值到栈顶,这样我们在后面可以检索到它。当我们调用 GetGpioAddress 时必须要这样做,我们将需要使用 `lr` 去保存我们函数的返回地址。 - -如果我们对 `GetGpioAddress` 函数一无所知,我们应该假设它改变了 `r0`、`r1`、`r2` 和 `r3` 的值 ,我们将移动我们的值到 r4 和 r5 中,以保持在它完成之后寄存器的值相同。幸运的是,我们知道 `GetGpioAddress` 做了什么,并且我们也知道它仅改变了 `r0` 到地址,它并没有影响 `r1`、`r2` 或 `r3` 的值。因此,我们仅去将 GPIO 针脚号从 `r0` 中移出,这样它就不会被覆盖掉,但我们知道,可以将它安全地移到 `r2` 中,因为 `GetGpioAddress` 并不去改变 `r2`。 - -最后我们使用 `bl` 指令去运行 `GetGpioAddress`。通常,运行一个函数,我们使用一个术语叫“调用”,从现在开始我们将一直使用这个术语。正如我们前面讨论过的,`bl` 通过更新 `lr` 中的下一个指令的地址,去调用一个函数,接着切换到函数。 - -当一个函数结束时,我们称为“返回”。当一个 `GetGpioAddress` 调用返回时,我们已经知道了 `r0` 中包含了 GPIO 的地址,`r1` 中包含了函数代码,而 `r2` 中包含了 GPIO 针脚号。我前面说过,GPIO 函数每 10 个保存在一个块中,因此首先我们需要去判断我们的针脚在哪个块中。这似乎听起来像是要使用一个除法,但是除法做起来非常慢,因此对于这些比较小的数来说,不停地做减法要比除法更好。 - -将下面的代码复制到上面的代码中最下面的位置。 - -```assembly -functionLoop$: - -cmp r2,#9 -subhi r2,#10 -addhi r0,#4 -bhi functionLoop$ -``` - -```assembly -add reg,#val 将数字 val 加到寄存器 reg 的内容上。 -``` - -这个简单的循环代码将针脚号与 9 进行比较。如果它大于 9,它将从针脚号上减去 10,并且将 GPIO 控制器地址加上 4,然后再次运行检查。 - -这样做的效果就是,现在,`r2` 中将包含一个 0 到 9 之间的数字,它是针脚号除以 9 的余数。`r0` 将包含这个针脚的函数所设置的 GPIO 控制器的地址。它就如同是 “GPIO 控制器地址 + 4 × (GPIO Pin Number ÷ 10)”。 - -最后,将下面的代码复制到上面的代码中最下面的位置。 - -```assembly -add r2, r2,lsl #1 -lsl r1,r2 -str r1,[r0] -pop {pc} -``` - -```assembly -移位参数 reg,lsl #val 表示将寄存器 reg 中二进制表示的数逻辑左移 val 位之后的结果作为与前面运算的操作数。 - -lsl reg,amt 将寄存器 reg 中的二进制数逻辑左移 amt 中的位数。 - -str reg,[dst] 与 str reg,[dst,#0] 相同。 - -pop {reg1,reg2,...} 从栈顶复制值到寄存器列表 reg1、reg2、.... 仅有通用寄存器与 pc 可以这样弹出值。 -``` - -这个代码完成了这个方法。第一行其实是乘以 3 的变体。乘法在汇编中是一个大而慢的指令,因为电路需要很长时间才能给出答案。有时使用一些能够很快给出答案的指令会让它变得更快。在本案例中,我们知道 r2 × 3 与 r2 × 2 + r2 是相同的。一个寄存器乘以 2 是非常容易的,因为它可以通过将二进制表示的数左移一位来很方便地实现。 - -ARMv6 汇编语言其中一个非常有用的特性就是,在使用它之前可以先移动参数所表示的位数。在本案例中,我将 `r2` 加上 `r2` 中二进制表示的数左移一位的结果。在汇编代码中,你可以经常使用这个技巧去更快更容易地计算出答案,但如果你觉得这个技巧使用起来不方便,你也可以写成类似 `mov r3,r2`; `add r2,r3`; `add r2,r3` 这样的代码。 - -现在,我们可以将一个函数的值左移 `r2` 中所表示的位数。大多数对数量的指令(比如加法和减法)都有一个可以使用寄存器而不是数字的变体。我们执行这个移位是因为我们想去设置表示针脚号的位,并且每个针脚有三个位。 - -然后,我们将函数计算后的值保存到 GPIO 控制器的地址上。我们在循环中已经算出了那个地址,因此我们不需要像 OK01 和 OK02 中那样在一个偏移量上保存它。 - -最后,我们从这个方法调用中返回。由于我们将 `lr` 推送到了栈上,因此我们 `pop pc`,它将复制 `lr` 中的值并将它推送到 `pc` 中。这个操作类似于 `mov pc,lr`,因此函数调用将返回到运行它的那一行上。 - -敏锐的人可能会注意到,这个函数其实并不能正确工作。虽然它将 GPIO 针脚函数设置为所要求的值,但它会导致在同一个块中的 10 个函数的所有针脚都归 0!在一个大量使用 GPIO 针脚的系统中,这将是一个很恼人的问题。我将这个问题留给有兴趣去修复这个函数的人,以确保只设置相关的 3 个位而不去覆写其它位,其它的所有位都保持不变。关于这个问题的解决方案可以在本课程的下载页面上找到。你可能会发现非常有用的几个函数是 `and`,它是计算两个寄存器的布尔与函数,`mvns` 是计算布尔非函数,而 `orr` 是计算布尔或函数。 - -### 4、另一个函数 - -现在,我们已经有了能够设置 GPIO 针脚的函数。我们还需要写一个能够打开或关闭 GPIO 针脚的函数。我们不需要写一个打开的函数和一个关闭的函数,只需要一个函数就可以做这两件事情。 - -我们将写一个名为 `SetGpio` 的函数,它用 `r0` 中的值作为第一个输入,`r1` 中的值作为第二个输入。如果值为 `0`,我们将关闭针脚,而如果为非零则打开针脚。 - -将下列的代码复制粘贴到 `gpio.s` 文件的结尾部分。 - -```assembly -.globl SetGpio -SetGpio: -pinNum .req r0 -pinVal .req r1 -``` - -```assembly -alias .req reg 设置寄存器 reg 的别名为 alias。 -``` - -我们再次需要 `.globl` 命令,标记它为其它文件可访问的全局函数。这次我们将使用寄存器别名。寄存器别名允许我们为寄存器使用名字而不仅是 `r0` 或 `r1`。到目前为止,寄存器别名还不是很重要,但随着我们后面写的方法越来越大,它将被证明非常有用,现在开始我们将尝试使用别名。当在指令中使用到 `pinNum .req r0` 时,它的意思是 `pinNum` 表示 `r0`。 - -将下面的代码复制粘贴到上述的代码下面位置。 - -```assembly -cmp pinNum,#53 -movhi pc,lr -push {lr} -mov r2,pinNum -.unreq pinNum -pinNum .req r2 -bl GetGpioAddress -gpioAddr .req r0 -``` - -```assembly -.unreq alias 删除别名 alias。 -``` - -就像在函数 `SetGpio` 中所做的第一件事情是检查给定的针脚号是否有效一样。我们需要同样的方式去将 `pinNum (r0)` 与 53 进行比较,如果它大于 53 将立即返回。一旦我们再次调用 `GetGpioAddress`,我们就需要将 `lr`推送到栈上来保护它,将将 `pinNum` 移动到 `r2` 中。然后我们使用 `.unreq` 语句来删除我们给 `r0` 定义的别名。因为针脚号现在保存在寄存器 `r2` 中,我们希望通过别名能够映射到它,因此我们重新定义到 `r2` 的别名。你应该每次在别名使用结束后,立即删除它,这样当它不再存在时,你就不会在后面的代码中因它而产生错误。 - -然后,我们调用了 `GetGpioAddress`,并且我们创建了一个指向 `r0`的别名。 - -将下面的代码复制粘贴到上述代码的后面位置。 - -```assembly -pinBank .req r3 -lsr pinBank,pinNum,#5a -lsl pinBank,#2 -add gpioAddr,pinBank -.unreq pinBank -``` - -```assembly -lsr dst,src,#val 将 src 中二进制表示的数右移 val 位,并将结果保存到 dst。 -``` - -对于打开和关闭 GPIO 针脚,每个针脚在 GPIO 控制器上有两个 4 字节组。在每个场景下,第一个 4 字节组控制前 32 个针脚,而第二个 4 字节组控制剩下的 22 个针脚。为了判断我们要设置的针脚在哪个 4 字节组中,我们需要将针脚号除以 32。幸运的是,这很容易,因为它等价于将二进制表示的针脚号右移 5 位。因此,在本案例中,我们将 `r3` 命名为 `pinBank`,然后计算 `pinNum ÷ 32`。因为它是一个 4 字节组,我们需要将它与 4 相乘的结果。它与二进制表示的数左移 2 位的相同的,这就是下一行的命令。你可能想知道我们能否将它右移 3 位呢,这样我们就可以先右移再左移。但是这样做是不行的,因为当我们做 ÷ 32 时有些答案可能是四舍五入的,而如果我们做 ÷ 8 时却不会这样。 - -现在,`gpioAddr` 的结果有可能是 20200000~16~(如果针脚号介于 0 到 31 之间),也有可能是 20200004~16~(如果针脚号介于 32 到 53 之间)。这意味着如果加上 28~10~ ,我们将得到打开针脚的地址,而如果加上 40~10~ ,我们将得到关闭针脚的地址。由于我们使用了 `pinBank` ,所以在它之后立即使用 `.unreq` 去删除它。、 - -将下面的代码复制粘贴到上述代码的下面位置。 - -```assembly -and pinNum,#31 -setBit .req r3 -mov setBit,#1 -lsl setBit,pinNum -.unreq pinNum -``` - -```assembly -and reg,#val 计算寄存器中的数与 val 的布尔与。 -``` - -函数的下一个部分是产生一个正确的设置数的位。至于 GPIO 控制器去打开或关闭针脚,我们在针脚号除以 32 的余数的位置,给它一个设置数字的位。例如,设置 16 号针脚,我们需要第 16 位设置数字为 1 。设置 45 号针脚,我们需要设置第 13 位数字为 1,因为 45 ÷ 32 = 1 余数 13。 - -这个 `and` 命令计算我们需要的余数。它是这样计算的,在输入中所有的二进制位都是 1 时,这个 `and` 运算的结果就是 1,否则就是 0。这是一个很基础的二进制操作,`and` 操作非常快。我们给定的输入是 “pinNum and 31~10~ = 11111~2~”。这意味着答案的后 5 位中只有 1,因此它肯定是在 0 到 31 之间。尤其是在 `pinNum` 的后 5 位的位置是 1 的地方它只有 1。这就如同被 32 整除的余数部分。就像 31 = 32 - 1 并不是巧合。 - -![binary division example][4] - -代码的其余部分使用这个值去左移 1 位。这就有了创建我们所需要的二进制数的效果。 - -将下面的代码复制粘贴到上述代码的下面位置。 - -```assembly -teq pinVal,#0 -.unreq pinVal -streq setBit,[gpioAddr,#40] -strne setBit,[gpioAddr,#28] -.unreq setBit -.unreq gpioAddr -pop {pc} -``` - -```assembly -teq reg,#val 检查寄存器 reg 中的数字与 val 是否相等。 -``` - -这个代码是方法的结束部分。如前面所说,当 `pinVal` 为 0 时,我们关闭它,否则就打开它。`teq`(等于测试)是另一个比较操作,它仅能够测试是否相等。它类似于 `cmp` ,但它并不能算出哪个数大。如果你只是希望测试数字是否相同,你可以使用 `teq`。 - -如果 `pinVal` 是 0,我们将 `setBit` 保存在 GPIO 地址偏移 40 的位置,我们已经知道,这样会关闭那个针脚。否则将它保存在 GPIO 地址偏移 28 的位置,它将打开那个针脚。最后,我们通过弹出 `pc` 返回,这将设置它为我们推送链接寄存器时保存的值。 - -### 5、一个新的开始 - -在完成上述工作后,我们终于有了我们的 GPIO 函数。现在,我们需要去修改 `main.s` 去使用它们。因为 `main.s` 现在已经有点大了,也更复杂了。将它分成两节将是一个很好的设计。到目前为止,我们一直使用的 `.init` 应该尽可能的让它保持小。我们可以更改代码来很容易地反映出这一点。 - -将下列的代码插入到 `main.s` 文件中 `_start: ` 的后面: - -``` -b main - -.section .text -main: -mov sp,#0x8000 -``` - -在这里重要的改变是引入了 `.text` 节。我设计了 `makefile` 和链接器脚本,它将 `.text` 节(它是默认节)中的代码放在地址为 8000~16~ 的 `.init` 节之后。这是默认加载地址,并且它给我们提供了一些空间去保存栈。由于栈存在于内存中,它也有一个地址。栈向下增长内存,因此每个新值都低于前一个地址,所以,这便得栈顶是最低的一个地址。 - -``` -图中的 'ATAGs' 节的位置保存了有关树莓派的信息,比如它有多少内存,默认屏幕分辨率是多少。 -``` - -![Layout diagram of operating system][5] - -用下面的代码替换掉所有设置 GPIO 函数针脚的代码: - -```assembly -pinNum .req r0 -pinFunc .req r1 -mov pinNum,#16 -mov pinFunc,#1 -bl SetGpioFunction -.unreq pinNum -.unreq pinFunc -``` - -这个代码将使用针脚号 16 和函数代码 1 去调用 `SetGpioFunction`。它的效果就是启用了 OK LED 灯的输出。 - -用下面的代码去替换打开 OK LED 灯的代码: - -```assembly -pinNum .req r0 -pinVal .req r1 -mov pinNum,#16 -mov pinVal,#0 -bl SetGpio -.unreq pinNum -.unreq pinVal -``` - -这个代码使用 `SetGpio` 去关闭 GPIO 第 16 号针脚,因此将打开 OK LED。如果我们(将第 4 行)替换成 `mov pinVal,#1` 它将关闭 LED 灯。用以上的代码去替换掉你关闭 LED 灯的旧代码。 - -### 6、继续向目标前进 - -但愿你能够顺利地在你的树莓派上测试我们所做的这一切。到目前为止,我们已经写了一大段代码,因此不可避免会出现错误。如果有错误,可以去查看我们的排错页面。 - -如果你的代码已经正常工作,恭喜你。虽然我们的操作系统除了做 [课程 2:OK02][1] 中的事情之外,还做不了别的任何事情,但我们已经学会了函数和格式有关的知识,并且我们现在可以更好更快地编写新特性了。现在,我们在操作系统上修改 GPIO 寄存器将变得非常简单,而它就是用于控制硬件的! - -在 [课程 4:OK04][6] 中,我们将处理我们的 `wait` 函数,目前,它的时间控制还不精确,这样我们就可以更好地控制我们的 LED 灯了,进而最终控制所有的 GPIO 针脚。 - --------------------------------------------------------------------------------- - -via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok03.html - -作者:[Robert Mullins][a] -选题:[lujun9972][b] -译者:[qhwdw](https://github.com/qhwdw ) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]: http://www.cl.cam.ac.uk/~rdm34 -[b]: https://github.com/lujun9972 -[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok02.html -[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/functions.png -[3]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/stack.png -[4]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/binary3.png -[5]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/osLayout.png -[6]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/ok04.html diff --git a/translated/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 10 Input01.md b/translated/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 10 Input01.md new file mode 100644 index 0000000000..ca6d421a15 --- /dev/null +++ b/translated/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 10 Input01.md @@ -0,0 +1,506 @@ +[#]: collector: (lujun9972) +[#]: translator: (ezio ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 10 Input01) +[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input01.html) +[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) + + +计算机实验课 – 树莓派: 课程 10 输入01 +====== + +欢迎进入输入课程系列。在本系列,你将会学会如何使用键盘接收输入给树莓派。我们将会从揭示输入开始本课,然后开始传统的文本命令。 + +这是第一堂输入课,会教授一些关于驱动和链接的理论,同样也包含键盘的知识,最后以在屏幕上显示文本结束。 + +### 1 开始 + +希望你已经完成了 OK 系列课程, 这会对你完成屏幕系列课程很有帮助。很多 OK 课程上的文件会被使用而不会做解释。如果你没有这些文件,或者希望使用一个正确的实现, 可以从该堂课的[下载页][1]下载模板。如果你使用你自己的实现,请删除调用了 `SetGraphicsAddress` 之后全部的代码。 + +### 2 USB + +``` +USB 标准的设计目的是通过复杂的硬件来简化硬件。 +``` + +如你所知,树莓派 B 型有两个 USB 接口,通常用来连接一个鼠标和一个键盘。这是一个非常好的设计决策,USB 是一个非常通用的接口, 很多种设备都可以使用它。这就很容易为它设计新外设,很容易为它编写设备驱动, 而且通过 USB 集线器可以非常容易扩展。还能更好吗?当然是不能,实际上对一个操作系统开发者来说,这就是我们的噩梦。USB 标准太大了。 我是真的,在你思考如何连接设备之前,它的文档将近 700 页。 + +我和很多爱好操作系统的开发者谈过这些,而他们全部都说几句话:不要抱怨。“实现这个需要花费很久时间”,“你不可能写出关于 USB 的教程”,“收益太小了”。在很多方面,他们是对的,我不可能写出一个关于 USB 标准的教程, 那得花费几周时间。我同样不能教授如何为全部所有的设备编写外设驱动,所以使用自己写的驱动是没什么用的。然而,我可以做仅次于最好的事情是获取一个正常工作的 USB 驱动,拿一个键盘驱动,然后教授如何在操作系统中使用它们。我开始寻找可以运行在一个甚至不知道文件是什么的操作系统的自由驱动,但是我一个都找不到。他们都太高层了。所以我尝试写一个。每个人都是对的,这耗费了我几周时间。然而我高兴的说我我做这些工作没有获取操作系统以外的帮助,并且可以和鼠标和键盘通信。这句不是完整的,高效的,或者正确的,但是它能工作。驱动是以 C 编写的,而且有兴趣的可以在下载页找到全部源代码。 + +所以,这一个教程不会是 USB 标准的课程(一点也没有)。实际上我们将会看到如何使用其他人的代码。 + +### 3 链接 + +``` +链接允许我们制作可重用的代码库,所有人都可以在他们的程序中使用。 +``` + +既然我们要引进外部代码到操作系统,我们就需要谈一谈链接。链接是一种过程,可以在程序或者操作系统中链接函数。这意味着当一个程序生成之后,我们不必要编写每一个函数(几乎可以肯定,实际上并非如此)。链接就是我们做的用来把我们程序和别人代码中的函数连结在一起。这个实际上已经在我们的操作系统进行了,因为链接器吧所有不同的文件链接在一起,每个都是分开编译的。 + + +``` +程序经常知识调用库,这些库会调用其它的库,知道最终调用了我们写的操作系统。 +``` + +有两种链接:静态和动态。静态链接就像我们在制作自己的操作系统时进行的。链接器找到全部函数的地址,然后在链接结束前,将这些地址都写入代码中。动态链接是在程序“完成”之后。当程序加载后,动态链接器检查程序,然后在操作系统的库找到所有不在程序里的函数。这就是我们的操作系统最终应该能够完成的一项工作,但是现在所有东西都将是静态链接的。 + +我编写的 USB 驱动程序适合静态编译。这意味着我给你我的每个文件的编译后的代码,然后链接器找到你的代码中的那些没有实现的函数,就将这些函数链接到我的代码。在本课的 [下载页][1] 是一个 makefile 和我的 USB 驱动,这是接下来需要的。下载并使用这 makefile 替换你的代码中的 makefile, 同事将驱动放在和这个 makefile 相同的文件夹。 + +### 4 键盘 + +为了将输入传给我们的操作系统,我们需要在某种程度上理解键盘是如何实际工作的。键盘有两种按键:普通键和修饰键。普通按键是字母、数字、功能键,等等。他们构成了键盘上几乎每一个按键。修饰键是最多 8 个特殊键。他们是左 shift , 右 shift, 左 ctrl,右 ctrl,左 alt, 右 alt,左 GUI 和右 GUI。键盘可以检测出所有的组合中那个修饰键被按下了,以及最多 6 个普通键。每次一个按钮变化了(i.e. 是按下了还是释放了),键盘就会报告给电脑。通常,键盘也会有 3 个 LED 灯,分别指示 Caps 锁定,Num 锁定,和 Scroll 锁定,这些都是由电脑控制的,而不是键盘自己。键盘也可能由更多的灯,比如电源、静音,等等。 + +为了帮助标准 USB 键盘,产生了一个按键值的表,每个键盘按键都一个唯一的数字,每个可能的 LED 也类似。下面的表格列出了前 126 个值。 + +Table 4.1 USB 键盘值 + +| 序号 | 描述 | 序号 | 描述 | 序号 | 描述 | 序号 | 描述 | | +| ------ | ---------------- | ------- | ---------------------- | -------- | -------------- | --------------- | -------------------- |----| +| 4 | a and A | 5 | b and B | 6 | c and C | 7 | d and D | | +| 8 | e and E | 9 | f and F | 10 | g and G | 11 | h and H | | +| 12 | i and I | 13 | j and J | 14 | k and K | 15 | l and L | | +| 16 | m and M | 17 | n and N | 18 | o and O | 19 | p and P | | +| 20 | q and Q | 21 | r and R | 22 | s and S | 23 | t and T | | +| 24 | u and U | 25 | v and V | 26 | w and W | 27 | x and X | | +| 28 | y and Y | 29 | z and Z | 30 | 1 and ! | 31 | 2 and @ | | +| 32 | 3 and # | 33 | 4 and $ | 34 | 5 and % | 35 | 6 and ^ | | +| 36 | 7 and & | 37 | 8 and * | 38 | 9 and ( | 39 | 0 and ) | | +| 40 | Return (Enter) | 41 | Escape | 42 | Delete (Backspace) | 43 | Tab | | +| 44 | Spacebar | 45 | - and _ | 46 | = and + | 47 | [ and { | | +| 48 | ] and } | 49 | \ and | 50 | # and ~ | 51 | ; and : | +| 52 | ' and " | 53 | ` and ~ | 54 | , and < | 55 | . and > | | +| 56 | / and ? | 57 | Caps Lock | 58 | F1 | 59 | F2 | | +| 60 | F3 | 61 | F4 | 62 | F5 | 63 | F6 | | +| 64 | F7 | 65 | F8 | 66 | F9 | 67 | F10 | | +| 68 | F11 | 69 | F12 | 70 | Print Screen | 71 | Scroll Lock | | +| 72 | Pause | 73 | Insert | 74 | Home | 75 | Page Up | | +| 76 | Delete forward | 77 | End | 78 | Page Down | 79 | Right Arrow | | +| 80 | Left Arrow | 81 | Down Arrow | 82 | Up Arrow | 83 | Num Lock | | +| 84 | Keypad / | 85 | Keypad * | 86 | Keypad - | 87 | Keypad + | | +| 88 | Keypad Enter | 89 | Keypad 1 and End | 90 | Keypad 2 and Down Arrow | 91 | Keypad 3 and Page Down | | +| 92 | Keypad 4 and Left Arrow | 93 | Keypad 5 | 94 | Keypad 6 and Right Arrow | 95 | Keypad 7 and Home | | +| 96 | Keypad 8 and Up Arrow | 97 | Keypad 9 and Page Up | 98 | Keypad 0 and Insert | 99 | Keypad . and Delete | | +| 100 | \ and | 101 | Application | 102 | Power | 103 | Keypad = | +| 104 | F13 | 105 | F14 | 106 | F15 | 107 | F16 | | +| 108 | F17 | 109 | F18 | 110 | F19 | 111 | F20 | | +| 112 | F21 | 113 | F22 | 114 | F23 | 115 | F24 | | +| 116 | Execute | 117 | Help | 118 | Menu | 119 | Select | | +| 120 | Stop | 121 | Again | 122 | Undo | 123 | Cut | | +| 124 | Copy | 125 | Paste | 126 | Find | 127 | Mute | | +| 128 | Volume Up | 129 | Volume Down | | | | | | + +完全列表可以在[HID 页表 1.12][2]的 53 页,第 10 节找到 + +### 5 车轮后的螺母 + +``` +这些总结和代码的描述组成了一个 API - 应用程序产品接口。 + +``` + +通常,当你使用其他人的代码,他们会提供一份自己代码的总结,描述代码都做了什么,粗略介绍了是如何工作的,以及什么情况下会出错。下面是一个使用我的 USB 驱动的相关步骤要求。 + +Table 5.1 CSUD 中和键盘相关的函数 +| 函数 | 参数 | 返回值 | 描述 | +| ----------------------- | ----------------------- | ----------------------- | -----------------------| +| UsbInitialise | None | r0 is result code | 这个方法是一个集多种功能于一身的方法,它加载USB驱动程序,枚举所有设备并尝试与它们通信。这种方法通常需要大约一秒钟的时间来执行,但是如果插入几个USB集线器,执行时间会明显更长。在此方法完成之后,键盘驱动程序中的方法就可用了,不管是否确实插入了键盘。返回代码如下解释。| +| UsbCheckForChange | None | None | 本质上提供与 `usbinitialization` 相同的效果,但不提供相同的一次初始化。该方法递归地检查每个连接的集线器上的每个端口,如果已经添加了新设备,则添加它们。如果没有更改,这应该是非常快的,但是如果连接了多个设备的集线器,则可能需要几秒钟的时间。| +| KeyboardCount | None | r0 is count | 返回当前连接并检测到的键盘数量。`UsbCheckForChange` 可能会对此进行更新。默认情况下最多支持4个键盘。多达这么多的键盘可以通过这个驱动程序访问。| +| KeyboardGetAddress | r0 is index | r0 is address | 检索给定键盘的地址。所有其他函数都需要一个键盘地址,以便知道要访问哪个键盘。因此,要与键盘通信,首先要检查计数,然后检索地址,然后使用其他方法。注意,在调用 `UsbCheckForChange` 之后,此方法返回的键盘顺序可能会改变。 +| +| KeyboardPoll | r0 is address | r0 is result code | 从键盘读取当前键状态。这是通过直接轮询设备来操作的,与最佳实践相反。这意味着,如果没有频繁地调用此方法,可能会错过一个按键。所有读取方法只返回上次轮询时的值。 +| +| KeyboardGetModifiers | r0 is address | r0 is modifier state | 检索上次轮询时修饰符键的状态。这是两边的 `shift` 键、`alt` 键和 `GUI` 键。这回作为一个位字段返回,这样,位0中的1表示左控件被保留,位1表示左 `shift`,位2表示左 `alt` ,位3表示左 `GUI`,位4到7表示前几位的右版本。如果有问题,`r0` 包含0。| +| KeyboardGetKeyDownCount | r0 is address | r0 is count | 检索当前按下键盘的键数。这排除了修饰键。这通常不能超过6次。如果有错误,这个方法返回0。| +| KeyboardGetKeyDown | r0 is address, r1 is key number | r0 is scan code | 检索特定下拉键的扫描代码(见表4.1)。通常,要计算出哪些键是关闭的,可以调用 `KeyboardGetKeyDownCount`,然后多次调用 `KeyboardGetKeyDown` ,将 `r1` 的值递增,以确定哪些键是关闭的。如果有问题,返回0。在不调用 `KeyboardGetKeyDownCount` 并将0解释为未持有的键的情况下调用此方法是安全的(但不建议这样做)。注意,顺序或扫描代码可以随机更改(有些键盘按数字排序,有些键盘按时间排序,没有任何保证)。| +| KeyboardGetKeyIsDown | r0 is address, r1 is scan code | r0 is status | 除了 `KeyboardGetKeyDown` 之外,还可以检查下拉键中是否有特定的扫描代码。如果不是,返回0;如果是,返回一个非零值。当检测特定的扫描代码(例如寻找ctrl+c)更快。出错时,返回0。 +| +| KeyboardGetLedSupport | r0 is address | r0 is LEDs | 检查特定键盘支持哪些led。第0位代表数字锁定,第1位代表大写锁定,第2位代表滚动锁定,第3位代表合成,第4位代表假名,第5位代表能量,第6位代表静音,第7位代表合成。根据USB标准,这些led都不是自动更新的(例如,当检测到大写锁定扫描代码时,必须手动设置大写锁定)。| +| KeyboardSetLeds | r0 is address, r1 is LEDs | r0 is result code | 试图打开/关闭键盘上指定的 LED 灯。查看下面的结果代码值。参见 `KeyboardGetLedSupport` 获取 LED 的值。 +| + +``` +返回值是一种处理错误的简单方法,但是通常更优雅的解决途径存在于更高层次的代码。 +``` + +有几种方法返回 ‘返回值’。这些都是 C 代码的老生常谈了,就是用数字代表函数调用发生了什么。通常情况, 0 总是代表操作成功。下面的是驱动用到的返回值。 + +Table 5.2 - CSUD 返回值 + +| 代码 | 描述 | +| ---- | ----------------------------------------------------------------------- | +| 0 | 方法成功完成。 | +| -2 | 参数: 函数调用了无效参数。 | +| -4 | 设备: 设备没有正确响应请求。 | +| -5 | 不匹配: 驱动不适用于这个请求或者设备。 | +| -6 | 编译器: 驱动没有正确编译,或者被破坏了。 | +| -7 | 内存: 驱动用尽了内存。 | +| -8 | 超时: 设备没有在预期的时间内响应请求。 | +| -9 | 断开连接: 被请求的设备断开连接,或者不能使用。 | + +驱动的通常用法如下: + + 1. 调用 `UsbInitialise` + 2. 调用 `UsbCheckForChange` + 3. 调用 `KeyboardCount` + 4. 如果返回 0,重复步骤 2。 + 5. 针对你支持的每种键盘: + 1. 调用 ·KeyboardGetAddress· + 2. 调用 ·KeybordGetKeyDownCount· + 3. 针对每个按下的按键: + 1. 检查它是否已经被按下了 + 2. 保存按下的按键 + 4. 针对每个保存的按键: + 3. 检查按键是否被释放了 + 4. 如果释放了就删除 + 6. 根据按下/释放的案件执行操作 + 7. 重复步骤 2. + + +最后,你可能做所有你想对键盘做的事,而这些方法应该允许你访问键盘的全部功能。在接下来的两节课,我们将会着眼于完成文本终端的输入部分,类似于大部分的命令行电脑,以及命令的解释。为了做这些,我们将需要在更有用的形式下得到一个键盘输入。你可能注意到我的驱动是(故意)没有太大帮助,因为它并没有方法来判断是否一个案件刚刚按下或释放了,它只有芳芳来判断当前那个按键是按下的。这就意味着我们需要自己编写这些方法。 + +### 6 可用更新 + +重复检查更新被称为 ‘轮询’。这是针对驱动 IO 中断而言的,这种情况下设备在准备好后会发一个信号。 + +首先,让我们实现一个 `KeyboardUpdate` 方法,检查第一个键盘,并使用轮询方法来获取当前的输入,以及保存最后一个输入来对比。然后我们可以使用这个数据和其它方法来将扫描码转换成按键。这个方法应该按照下面的说明准确操作: + + 1. 提取一个保存好的键盘地址(初始值为 0)。 + 2. 如果不是0 ,进入步骤9. + 3. 调用 `UsbCheckForChange` 检测新键盘。 + 4. 调用 `KeyboardCount` 检测有几个键盘在线。 + 5. 如果返回0,意味着没有键盘可以让我们操作,只能退出了。 + 6. 调用 `KeyboardGetAddress` 参数是 0,获取第一个键盘的地址。 + 7. 保存这个地址。 + 8. 如果这个值是0,那么退出,这里应该有些问题。 + 9. 调用 `KeyboardGetKeyDown` 6 次,获取每次按键按下的值并保存。 + 10. 调用 `KeyboardPoll` + 11. 如果返回值非 0,进入步骤 3。这里应该有些问题(比如键盘断开连接)。 + +要保存上面提到的值,我们将需要下面 `.data` 段的值。 + +``` +.section .data +.align 2 +KeyboardAddress: +.int 0 +KeyboardOldDown: +.rept 6 +.hword 0 +.endr +``` + +``` +.hword num 直接将半字的常数插入文件。 +``` + +``` +.rept num [commands] .endr 复制 `commands` 命令到输出 num 次。 +``` + +试着自己实现这个方法。对此,我的实现如下: + +1. +``` +.section .text +.globl KeyboardUpdate +KeyboardUpdate: +push {r4,r5,lr} + +kbd .req r4 +ldr r0,=KeyboardAddress +ldr kbd,[r0] +``` +我们加载键盘的地址。 + +2. +``` +teq kbd,#0 +bne haveKeyboard$ +``` +如果地址非0,就说明我们有一个键盘。调用 `UsbCheckForChanges` 慢,所以如果全部事情都起作用,我们要避免调用这个函数。 + +3. +``` +getKeyboard$: +bl UsbCheckForChange +``` +如果我们一个键盘都没有,我们就必须检查新设备。 + +4. +``` +bl KeyboardCount +``` +如果有心键盘添加,我们就会看到这个。 + +5. +``` +teq r0,#0 +ldreq r1,=KeyboardAddress +streq r0,[r1] +beq return$ +``` +如果没有键盘,我们就没有键盘地址。 + +6. +``` +mov r0,#0 +bl KeyboardGetAddress +``` +让我们获取第一个键盘的地址。你可能想要更多。 + +7. +``` +ldr r1,=KeyboardAddress +str r0,[r1] +``` +保存键盘地址。 + +8. +``` +teq r0,#0 +beq return$ +mov kbd,r0 +``` +如果我们没有地址,这里就没有其它活要做了。 + +9. +``` +saveKeys$: + mov r0,kbd + mov r1,r5 + bl KeyboardGetKeyDown + + ldr r1,=KeyboardOldDown + add r1,r5,lsl #1 + strh r0,[r1] + add r5,#1 + cmp r5,#6 + blt saveKeys$ +``` +Loop through all the keys, storing them in KeyboardOldDown. If we ask for too many, this returns 0 which is fine. +查询遍全部按键,在 `KeyboardOldDown` 保存下来。如果我们询问的太多了,返回 0 也是正确的。 + +10. +``` +mov r0,kbd +bl KeyboardPoll +``` +现在哦我们得到了新的按键。 + +11. +``` +teq r0,#0 +bne getKeyboard$ + +return$: +pop {r4,r5,pc} +.unreq kbd +``` +最后我们要检查 `KeyboardOldDown` 是否工作了。如果没工作,那么我们可能是断开连接了。 + +有了我们新的 `KeyboardUpdate` 方法,检查输入变得简单到固定周期调用这个方法,而它甚至可以检查断开连接,等等。这是一个有用的方法,因为我们实际的按键处理会根据条件不同而有所差别,所以能够用一个函数调以它的原始方式获取当前的输入是可行的。下一个方法我们理想希望的是 `KeyboardGetChar`,简单的返回下一个按下的按钮的 ASCII 字符,或者如果没有按键按下就返回 0。这可以扩展到支持将一个按键多次按下,如果它保持了一个特定时间,也支持‘锁定’键和修饰键。 + +要使这个方法有用,如果我们有一个 `KeyWasDown` 方法,如果给定的扫描代码不在keyboard dolddown值中,它只返回0,否则返回一个非零值。你可以自己尝试一下。与往常一样,可以在下载页面找到解决方案。 + +### 7 查找表 + +``` +在编程的许多领域,程序越大,速度越快。查找表很大,但是速度很快。有些问题可以通过查找表和普通函数的组合来解决。 +``` + +`KeyboardGetChar`方法如果写得不好,可能会非常复杂。有 100 多种扫描代码,每种代码都有不同的效果,这取决于 shift 键或其他修饰符的存在与否。并不是所有的键都可以转换成一个字符。对于一些字符,多个键可以生成相同的字符。在有如此多可能性的情况下,一个有用的技巧是查找表。查找表与物理意义上的查找表非常相似,它是一个值及其结果的表。对于一些有限的函数,推导出答案的最简单方法就是预先计算每个答案,然后通过检索返回正确的答案。在这种情况下,我们可以建立一个序列的值在内存中,n值序列的ASCII字符代码扫描代码n。这意味着我们的方法只会发现如果一个键被按下,然后从表中检索它的值。此外,当按住shift键时,我们可以为值创建一个单独的表,这样shift键就可以简单地更改正在处理的表。 + +在 `.section` `.data` 命令之后,复制下面的表: + +``` +.align 3 +KeysNormal: + .byte 0x0, 0x0, 0x0, 0x0, 'a', 'b', 'c', 'd' + .byte 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l' + .byte 'm', 'n', 'o', 'p', 'q', 'r', 's', 't' + .byte 'u', 'v', 'w', 'x', 'y', 'z', '1', '2' + .byte '3', '4', '5', '6', '7', '8', '9', '0' + .byte '\n', 0x0, '\b', '\t', ' ', '-', '=', '[' + .byte ']', '\\\', '#', ';', '\'', '`', ',', '.' + .byte '/', 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 + .byte 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 + .byte 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 + .byte 0x0, 0x0, 0x0, 0x0, '/', '*', '-', '+' + .byte '\n', '1', '2', '3', '4', '5', '6', '7' + .byte '8', '9', '0', '.', '\\\', 0x0, 0x0, '=' + +.align 3 +KeysShift: + .byte 0x0, 0x0, 0x0, 0x0, 'A', 'B', 'C', 'D' + .byte 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L' + .byte 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T' + .byte 'U', 'V', 'W', 'X', 'Y', 'Z', '!', '"' + .byte '£', '$', '%', '^', '&', '*', '(', ')' + .byte '\n', 0x0, '\b', '\t', ' ', '_', '+', '{' + .byte '}', '|', '~', ':', '@', '¬', '<', '>' + .byte '?', 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 + .byte 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 + .byte 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 + .byte 0x0, 0x0, 0x0, 0x0, '/', '*', '-', '+' + .byte '\n', '1', '2', '3', '4', '5', '6', '7' + .byte '8', '9', '0', '.', '|', 0x0, 0x0, '=' +``` + +``` +.byte num 直接插入字节常量 num 到文件。 +``` + +``` +大部分的汇编器和编译器识别转义序列;插入特殊字符的字符序列,如\t。 +``` + +这些表直接将前 104 个扫描代码映射到 ASCII 字符,作为一个字节表。我们还有一个单独的表来描述 `shift` 键对这些扫描代码的影响。我使用 ASCII `null`字符(0)表示所有没有直接映射的 ASCII 键(例如函数键)。退格映射到ASCII退格字符(8表示 `\b` ), `enter` 映射到ASCII新行字符(10表示 `\n`), `tab` 映射到ASCII水平制表符(9表示 `\t` )。 + + +`KeyboardGetChar` 方法需要做以下工作: + 1. 检查 `KeyboardAddress` 是否返回 0。如果是,则返回0。 + 2. 调用 `KeyboardGetKeyDown` 最多 6 次。每次: + 1. 如果按键时0,跳出循环。 + 2. 调用 `KeyWasDown`。 如果返回是,处理下一个按键。 + 3. 如果扫描码超过 103,进入下一个按键。 + 4. 调用 `KeyboardGetModifiers` + 5. 如果 `shift` 是被按着的,就加载 `KeysShift` 的地址。否则加载 `KeysNormal` 的地址。 + 6. 从表中读出 ASCII 码值。 + 7. 如果是 0,进行下一个按键,否则返回 ASCII 码值并退出。 + 3. 返回0。 + + +试着自己实现。我的实现展示在下面: + +1. +``` +.globl KeyboardGetChar +KeyboardGetChar: +ldr r0,=KeyboardAddress +ldr r1,[r0] +teq r1,#0 +moveq r0,#0 +moveq pc,lr +``` +简单的检查我们是否有键盘。 + +2. +``` +push {r4,r5,r6,lr} +kbd .req r4 +key .req r6 +mov r4,r1 +mov r5,#0 +keyLoop$: + mov r0,kbd + mov r1,r5 + bl KeyboardGetKeyDown +``` +r5 will hold the index of the key, r4 holds the keyboard address. +`r5` 将会保存按键的索引, `r4` 保存键盘的地址。 + + 1. + ``` + teq r0,#0 + beq keyLoopBreak$ + ``` + 如果扫描码是0,它要么意味着有错,要么说明没有更多按键了。 + + 2. + ``` + mov key,r0 + bl KeyWasDown + teq r0,#0 + bne keyLoopContinue$ + ``` + 如果按键已经按下了,那么他就没意思了,我们只想知道按下的按键。 + + 3. + ``` + cmp key,#104 + bge keyLoopContinue$ + ``` + 如果一个按键有个超过 104 的扫描码,他将会超出我们的表,所以它是无关的按键。 + + 4. + ``` + mov r0,kbd + bl KeyboardGetModifiers + ``` + 我们需要知道修饰键来推断字符。 + + 5. + ``` + tst r0,#0b00100010 + ldreq r0,=KeysNormal + ldrne r0,=KeysShift + ``` + 当将字符更改为其移位变体时,我们要同时检测左 `shift` 键和右 `shift` 键。记住,`tst` 指令计算的是逻辑和,然后将其与 0 进行比较,所以当且仅当移位位都为 0 时,它才等于0。 + + + 1. + ``` + ldrb r0,[r0,key] + ``` + 现在我们可以从查找表加载按键了。 + + 1. + ``` + teq r0,#0 + bne keyboardGetCharReturn$ + keyLoopContinue$: + add r5,#1 + cmp r5,#6 + blt keyLoop$ + ``` + 如果查找码包含一个 0,我们必须继续。为了继续,我们要增加索引,并检查是否到 6 次了。 + +1. +``` +keyLoopBreak$: +mov r0,#0 +keyboardGetCharReturn$: +pop {r4,r5,r6,pc} +.unreq kbd +.unreq key +``` +在这里我们返回我们的按键,如果我们到达 `keyLoopBreak$` ,然后我们就知道这里没有按键被握住,所以返回0。 + +### 8 记事本操作系统 + +现在我们有了 `KeyboardGetChar` 方法,可以创建一个操作系统,只输入用户对着屏幕所写的内容。为了简单起见,我们将忽略所有不寻常的键。在 `main.s` ,删除`bl SetGraphicsAddress` 之后的所有代码。调用 `UsbInitialise`,将 `r4` 和 `r5` 设置为 0,然后循环执行以下命令: + + 1. 调用 `KeyboardUpdate` + 2. 调用 `KeyboardGetChar` + 3. 如果返回 0,跳转到步骤1 + 4. 复制 `r4` 和 `r5` 到 `r1` 和 `r2` ,然后调用 `DrawCharacter` + 5. 把 `r0` 加到 `r4` + 6. 如果 `r4` 是 1024,将 `r1` 加到 `r5`,然后设置 `r4` 为 0。 + 7. 如果 `r5` 是 768,设置 `r5` 为0 + 8. 跳转到步骤1 + + + +现在编译这个,然后在 PI 上测试。您几乎可以立即开始在屏幕上输入文本。如果没有,请参阅我们的故障排除页面。 + +当它工作时,祝贺您,您已经实现了与计算机的接口。现在您应该开始意识到,您几乎已经拥有了一个原始的操作系统。现在,您可以与计算机交互,发出命令,并在屏幕上接收反馈。在下一篇教程[输入02][3]中,我们将研究如何生成一个全文本终端,用户在其中输入命令,然后计算机执行这些命令。 + +-------------------------------------------------------------------------------- + +via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input01.html + +作者:[Alex Chadwick][a] +选题:[lujun9972][b] +译者:[ezio](https://github.com/oska874) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.cl.cam.ac.uk +[b]: https://github.com/lujun9972 +[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/downloads.html +[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/downloads/hut1_12v2.pdf +[3]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input02.html diff --git a/translated/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 11 Input02.md b/translated/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 11 Input02.md new file mode 100644 index 0000000000..6b5db8b104 --- /dev/null +++ b/translated/tech/20150616 Computer Laboratory - Raspberry Pi- Lesson 11 Input02.md @@ -0,0 +1,911 @@ +[#]: collector: (lujun9972) +[#]: translator: (guevaraya ) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Computer Laboratory – Raspberry Pi: Lesson 11 Input02) +[#]: via: (https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input02.html) +[#]: author: (Alex Chadwick https://www.cl.cam.ac.uk) + +计算机实验室 – 树莓派开发: 课程11 输入02 +====== + +课程输入02是以课程输入01基础讲解的,通过一个简单的命令行实现用户的命令输入和计算机的处理和显示。本文假设你已经具备 [课程11:输入01][1] 的操作系统代码基础。 + +### 1 终端 + +``` +早期的计算一般是在一栋楼里的一个巨型计算机系统,他有很多可以输命令的'终端'。计算机依次执行不同来源的命令。 +``` + +几乎所有的操作系统都是以字符终端显示启动的。经典的黑底白字,通过键盘输入计算机要执行的命令,然后会提示你拼写错误,或者恰好得到你想要的执行结果。这种方法有两个主要优点:键盘和显示器可以提供简易,健壮的计算机交互机制,几乎所有的计算机系统都采用这个机制,这个也广泛被系统管理员应用。 + +让我们分析下真正想要哪些信息: + +1. 计算机打开后,显示欢迎信息 +2. 计算机启动后可以接受输入标志 +3. 用户从键盘输入带参数的命令 +4. 用户输入回车键或提交按钮 +5. 计算机解析命令后执行可用的命令 +6. 计算机显示命令的执行结果,过程信息 +7. 循环跳转到步骤2 + + +这样的终端被定义为标准的输入输出设备。用于输入的屏幕和输出打印的屏幕是同一个。也就是说终端是对字符显示的一个抽象。字符显示中,单个字符是最小的单元,而不是像素。屏幕被划分成固定数量不同颜色的字符。我们可以在现有的屏幕代码基础上,先存储字符和对应的颜色,然后再用方法 DrawCharacter 把其推送到屏幕上。一旦我们需要字符显示,就只需要在屏幕上画出一行字符串。 + +新建文件名为 terminal.s 如下: +``` +.section .data +.align 4 +terminalStart: +.int terminalBuffer +terminalStop: +.int terminalBuffer +terminalView: +.int terminalBuffer +terminalColour: +.byte 0xf +.align 8 +terminalBuffer: +.rept 128*128 +.byte 0x7f +.byte 0x0 +.endr +terminalScreen: +.rept 1024/8 core.md Dict.md lctt2014.md lctt2016.md lctt2018.md LICENSE published README.md scripts sources translated 768/16 +.byte 0x7f +.byte 0x0 +.endr +``` +这是文件终端的配置数据文件。我们有两个主要的存储变量:terminalBuffer 和 terminalScreen。terminalBuffer保存所有显示过的字符。它保存128行字符文本(1行包含128个字符)。每个字符有一个 ASCII 字符和颜色单元组成,初始值为0x7f(ASCII的删除键)和 0(前景色和背景色为黑)。terminalScreen 保存当前屏幕显示的字符。它保存128x48的字符,与 terminalBuffer 初始化值一样。你可能会想我仅需要terminalScreen就够了,为什么还要terminalBuffer,其实有两个好处: + + 1. 我们可以很容易看到字符串的变化,只需画出有变化的字符。 + 2. 我们可以回滚终端显示的历史字符,也就是缓冲的字符(有限制) + + +你总是需要尝试去设计一个高效的系统,如果很少变化的条件这个系统会运行的更快。 + +独特的技巧在低功耗系统里很常见。画屏是很耗时的操作,因此我们仅在不得已的时候才去执行这个操作。在这个系统里,我们可以任意改变terminalBuffer,然后调用一个仅拷贝屏幕上字节变化的方法。也就是说我们不需要持续画出每个字符,这样可以节省一大段跨行文本的操作时间。 + +其他在 .data 段的值得含义如下: + + * terminalStart + 写入到 terminalBuffer 的第一个字符 + * terminalStop + 写入到 terminalBuffer 的最后一个字符 + * terminalView + 表示当前屏幕的第一个字符,这样我们可以控制滚动屏幕 + * temrinalColour + 即将被描画的字符颜色 + + +``` +循环缓冲区是**数据结构**一个例子。这是一个组织数据的思路,有时我们通过软件实现这种思路。 +``` + +![显示 Hellow world 插入到大小为5的循环缓冲区的示意图。][2] +terminalStart 需要保存起来的原因是 termainlBuffer 是一个循环缓冲区。意思是当缓冲区变满时,末尾地方会回滚覆盖开始位置,这样最后一个字符变成了第一个字符。因此我们需要将 terminalStart 往前推进,这样我们知道我们已经占满它了。如何实现缓冲区检测:如果索引越界到缓冲区的末尾,就将索引指向缓冲区的开始位置。循环缓冲区是一个比较常见的高明的存储大量数据的方法,往往这些数据的最近部分比较重要。它允许无限制的写入,只保证最近一些特定数据有效。这个常常用于信号处理和数据压缩算法。这样的情况,可以允许我们存储128行终端记录,超过128行也不会有问题。如果不是这样,当超过第128行时,我们需要把127行分别向前拷贝一次,这样很浪费时间。 + +之前已经提到过 terminalColour 几次了。你可以根据你的想法实现终端颜色,但这个文本终端有16个前景色和16个背景色(这里相当于有16²=256种组合)。[CGA][3]终端的颜色定义如下: + +表格 1.1 - CGA 颜色编码 + +| 序号 | 颜色 (R, G, B) | +| ------ | ------------------------| +| 0 | 黑 (0, 0, 0) | +| 1 | 蓝 (0, 0, ⅔) | +| 2 | 绿 (0, ⅔, 0) | +| 3 | 青色 (0, ⅔, ⅔) | +| 4 | 红色 (⅔, 0, 0) | +| 5 | 品红 (⅔, 0, ⅔) | +| 6 | 棕色 (⅔, ⅓, 0) | +| 7 | 浅灰色 (⅔, ⅔, ⅔) | +| 8 | 灰色 (⅓, ⅓, ⅓) | +| 9 | 淡蓝色 (⅓, ⅓, 1) | +| 10 | 淡绿色 (⅓, 1, ⅓) | +| 11 | 淡青色 (⅓, 1, 1) | +| 12 | 淡红色 (1, ⅓, ⅓) | +| 13 | 浅品红 (1, ⅓, 1) | +| 14 | 黄色 (1, 1, ⅓) | +| 15 | 白色 (1, 1, 1) | + +``` +棕色作为替代色(黑黄色)既不吸引人也没有什么用处。 +``` +我们将前景色保存到颜色的低字节,背景色保存到颜色高字节。除过棕色,其他这些颜色遵循一种模式如二进制的高位比特代表增加 ⅓ 到每个组件,其他比特代表增加⅔到各自组件。这样很容易进行RGB颜色转换。 + +我们需要一个方法从TerminalColour读取颜色编码的四个比特,然后用16比特等效参数调用 SetForeColour。尝试实现你自己实现。如果你感觉麻烦或者还没有完成屏幕系列课程,我们的实现如下: + +``` +.section .text +TerminalColour: +teq r0,#6 +ldreq r0,=0x02B5 +beq SetForeColour + +tst r0,#0b1000 +ldrne r1,=0x52AA +moveq r1,#0 +tst r0,#0b0100 +addne r1,#0x15 +tst r0,#0b0010 +addne r1,#0x540 +tst r0,#0b0001 +addne r1,#0xA800 +mov r0,r1 +b SetForeColour +``` +### 2 文本显示 + +我们的终端第一个真正需要的方法是 TerminalDisplay,它用来把当前的数据从 terminalBuffe r拷贝到 terminalScreen 和实际的屏幕。如上所述,这个方法必须是最小开销的操作,因为我们需要频繁调用它。它主要比较 terminalBuffer 与 terminalDisplay的文本,然后只拷贝有差异的字节。请记住 terminalBuffer 是循环缓冲区运行的,这种情况,从 terminalView 到 terminalStop 或者 128*48 字符集,哪个来的最快。如果我们遇到 terminalStop,我们将会假定在这之后的所有字符是7f16 (ASCII delete),背景色为0(黑色前景色和背景色)。 + +让我们看看必须要做的事情: + + 1. 加载 terminalView ,terminalStop 和 terminalDisplay 的地址。 + 2. 执行每一行: + 1. 执行每一列: + 1. 如果 terminalView 不等于 terminalStop,根据 terminalView 加载当前字符和颜色 + 2. 否则加载 0x7f 和颜色 0 + 3. 从 terminalDisplay 加载当前的字符 + 4. 如果字符和颜色相同,直接跳转到10 + 5. 存储字符和颜色到 terminalDisplay + 6. 用 r0 作为背景色参数调用 TerminalColour + 7. 用 r0 = 0x7f (ASCII 删除键, 一大块), r1 = x, r2 = y 调用 DrawCharacter + 8. 用 r0 作为前景色参数调用 TerminalColour + 9. 用 r0 = 字符, r1 = x, r2 = y 调用 DrawCharacter + 10. 对位置参数 terminalDisplay 累加2 + 11. 如果 terminalView 不等于 terminalStop不能相等 terminalView 位置参数累加2 + 12. 如果 terminalView 位置已经是文件缓冲器的末尾,将他设置为缓冲区的开始位置 + 13. x 坐标增加8 + 2. y 坐标增加16 + + +Try to implement this yourself. If you get stuck, my solution is given below: +尝试去自己实现吧。如果你遇到问题,我们的方案下面给出来了: + +1. +``` +.globl TerminalDisplay +TerminalDisplay: +push {r4,r5,r6,r7,r8,r9,r10,r11,lr} +x .req r4 +y .req r5 +char .req r6 +col .req r7 +screen .req r8 +taddr .req r9 +view .req r10 +stop .req r11 + +ldr taddr,=terminalStart +ldr view,[taddr,#terminalView - terminalStart] +ldr stop,[taddr,#terminalStop - terminalStart] +add taddr,#terminalBuffer - terminalStart +add taddr,#128*128*2 +mov screen,taddr +``` + +我这里的变量有点乱。为了方便起见,我用 taddr 存储 textBuffer 的末尾位置。 + +2. +``` +mov y,#0 +yLoop$: +``` +从yLoop开始运行。 + + 1. + ``` + mov x,#0 + xLoop$: + ``` + 从yLoop开始运行。 + + 1. + ``` + teq view,stop + ldrneh char,[view] + ``` + 为了方便起见,我把字符和颜色同时加载到 char 变量了 + + 2. + ``` + moveq char,#0x7f + ``` + 这行是对上面一行的补充说明:读取黑色的Delete键 + + 3. + ``` + ldrh col,[screen] + ``` + 为了简便我把字符和颜色同时加载到 col 里。 + + 4. + ``` + teq col,char + beq xLoopContinue$ + ``` + 现在我用teq指令检查是否有数据变化 + + 5. + ``` + strh char,[screen] + ``` + 我可以容易的保存当前值 + + 6. + ``` + lsr col,char,#8 + and char,#0x7f + lsr r0,col,#4 + bl TerminalColour + ``` + 我用 bitshift(比特偏移) 指令和 and 指令从 char 变量中分离出颜色到 col 变量和字符到 char变量,然后再用bitshift(比特偏移)指令后调用TerminalColour 获取背景色。 + + 7. + ``` + mov r0,#0x7f + mov r1,x + mov r2,y + bl DrawCharacter + ``` + 写入一个彩色的删除字符块 + + 8. + ``` + and r0,col,#0xf + bl TerminalColour + ``` + 用 and 指令获取 col 变量的最低字节,然后调用TerminalColour + + 9. + ``` + mov r0,char + mov r1,x + mov r2,y + bl DrawCharacter + ``` + 写入我们需要的字符 + + 10. + ``` + xLoopContinue$: + add screen,#2 + ``` + 自增屏幕指针 + + 11. + ``` + teq view,stop + addne view,#2 + ``` + 如果可能自增view指针 + + 12. + ``` + teq view,taddr + subeq view,#128*128*2 + ``` + 很容易检测 view指针是否越界到缓冲区的末尾,因为缓冲区的地址保存在 taddr 变量里 + + 13. + ``` + add x,#8 + teq x,#1024 + bne xLoop$ + ``` + 如果还有字符需要显示,我们就需要自增 x 变量然后循环到 xLoop 执行 + + 2. + ``` + add y,#16 + teq y,#768 + bne yLoop$ + ``` + 如果还有更多的字符显示我们就需要自增 y 变量,然后循环到 yLoop 执行 + +``` +pop {r4,r5,r6,r7,r8,r9,r10,r11,pc} +.unreq x +.unreq y +.unreq char +.unreq col +.unreq screen +.unreq taddr +.unreq view +.unreq stop +``` +不要忘记最后清除变量 + + +### 3 行打印 + +现在我有了自己 TerminalDisplay方法,它可以自动显示 terminalBuffer 到 terminalScreen,因此理论上我们可以画出文本。但是实际上我们没有任何基于字符显示的实例。 首先快速容易上手的方法便是 TerminalClear, 它可以彻底清除终端。这个方法没有循环很容易实现。可以尝试分析下面的方法应该不难: + +``` +.globl TerminalClear +TerminalClear: +ldr r0,=terminalStart +add r1,r0,#terminalBuffer-terminalStart +str r1,[r0] +str r1,[r0,#terminalStop-terminalStart] +str r1,[r0,#terminalView-terminalStart] +mov pc,lr +``` + +现在我们需要构造一个字符显示的基础方法:打印函数。它将保存在 r0 的字符串和 保存在 r1 字符串长度简易的写到屏幕上。有一些特定字符需要特别的注意,这些特定的操作是确保 terminalView 是最新的。我们来分析一下需要做啥: + + 1. 检查字符串的长度是否为0,如果是就直接返回 + 2. 加载 terminalStop 和 terminalView + 3. 计算出 terminalStop 的 x 坐标 + 4. 对每一个字符的操作: + 1. 检查字符是否为新起一行 + 2. 如果是的话,自增 bufferStop 到行末,同时写入黑色删除键 + 3. 否则拷贝当前 terminalColour 的字符 + 4. 加成是在行末 + 5. 如果是,检查从 terminalView 到 terminalStop 之间的字符数是否大于一屏 + 6. 如果是,terminalView 自增一行 + 7. 检查 terminalView 是否为缓冲区的末尾,如果是的话将其替换为缓冲区的起始位置 + 8. 检查 terminalStop 是否为缓冲区的末尾,如果是的话将其替换为缓冲区的起始位置 + 9. 检查 terminalStop 是否等于 terminalStart, 如果是的话 terminalStart 自增一行。 + 10. 检查 terminalStart 是否为缓冲区的末尾,如果是的话将其替换为缓冲区的起始位置 + 5. 存取 terminalStop 和 terminalView + + +试一下自己去实现。我们的方案提供如下: + +1. +``` +.globl Print +Print: +teq r1,#0 +moveq pc,lr +``` +这个是打印函数开始快速检查字符串为0的代码 + +2. +``` +push {r4,r5,r6,r7,r8,r9,r10,r11,lr} +bufferStart .req r4 +taddr .req r5 +x .req r6 +string .req r7 +length .req r8 +char .req r9 +bufferStop .req r10 +view .req r11 + +mov string,r0 +mov length,r1 + +ldr taddr,=terminalStart +ldr bufferStop,[taddr,#terminalStop-terminalStart] +ldr view,[taddr,#terminalView-terminalStart] +ldr bufferStart,[taddr] +add taddr,#terminalBuffer-terminalStart +add taddr,#128*128*2 +``` + +这里我做了很多配置。 bufferStart 代表 terminalStart, bufferStop代表terminalStop, view 代表 terminalView,taddr 代表 terminalBuffer 的末尾地址。 + +3. +``` +and x,bufferStop,#0xfe +lsr x,#1 +``` +和通常一样,巧妙的对齐技巧让许多事情更容易。由于需要对齐 terminalBuffer,每个字符的 x 坐标需要8位要除以2。 + + 4. + 1. + ``` + charLoop$: + ldrb char,[string] + and char,#0x7f + teq char,#'\n' + bne charNormal$ + ``` + 我们需要检查新行 + + 2. + ``` + mov r0,#0x7f + clearLine$: + strh r0,[bufferStop] + add bufferStop,#2 + add x,#1 + teq x,#128 blt clearLine$ + + b charLoopContinue$ + ``` + 循环执行值到行末写入 0x7f;黑色删除键 + + 3. + ``` + charNormal$: + strb char,[bufferStop] + ldr r0,=terminalColour + ldrb r0,[r0] + strb r0,[bufferStop,#1] + add bufferStop,#2 + add x,#1 + ``` + 存储字符串的当前字符和 terminalBuffer 末尾的 terminalColour然后将它和 x 变量自增 + + 4. + ``` + charLoopContinue$: + cmp x,#128 + blt noScroll$ + ``` + 检查 x 是否为行末;128 + + 5. + ``` + mov x,#0 + subs r0,bufferStop,view + addlt r0,#128*128*2 + cmp r0,#128*(768/16)*2 + ``` + 这是 x 为 0 然后检查我们是否已经显示超过1屏。请记住,我们是用的循环缓冲区,因此如果 bufferStop 和 view 之前差是负值,我们实际使用是环绕缓冲区。 + + 6. + ``` + addge view,#128*2 + ``` + 增加一行字节到 view 的地址 + + 7. + ``` + teq view,taddr + subeq view,taddr,#128*128*2 + ``` + 如果 view 地址是缓冲区的末尾,我们就从它上面减去缓冲区的长度,让其指向开始位置。我会在开始的时候设置 taddr 为缓冲区的末尾地址。 + + 8. + ``` + noScroll$: + teq bufferStop,taddr + subeq bufferStop,taddr,#128*128*2 + ``` + 如果 stop 的地址在缓冲区末尾,我们就从它上面减去缓冲区的长度,让其指向开始位置。我会在开始的时候设置 taddr 为缓冲区的末尾地址。 + + 9. + ``` + teq bufferStop,bufferStart + addeq bufferStart,#128*2 + ``` + 检查 bufferStop 是否等于 bufferStart。 如果等于增加一行到 bufferStart。 + + 10. + ``` + teq bufferStart,taddr + subeq bufferStart,taddr,#128*128*2 + ``` + 如果 start 的地址在缓冲区的末尾,我们就从它上面减去缓冲区的长度,让其指向开始位置。我会在开始的时候设置 taddr 为缓冲区的末尾地址。 + +``` +subs length,#1 +add string,#1 +bgt charLoop$ +``` +循环执行知道字符串结束 + +5. +``` +charLoopBreak$: +sub taddr,#128*128*2 +sub taddr,#terminalBuffer-terminalStart +str bufferStop,[taddr,#terminalStop-terminalStart] +str view,[taddr,#terminalView-terminalStart] +str bufferStart,[taddr] + +pop {r4,r5,r6,r7,r8,r9,r10,r11,pc} +.unreq bufferStart +.unreq taddr +.unreq x +.unreq string +.unreq length +.unreq char +.unreq bufferStop +.unreq view +``` +保存变量然后返回 + + +这个方法允许我们打印任意字符到屏幕。然而我们用了颜色变量,但实际上没有设置它。一般终端用特性的组合字符去行修改颜色。如ASCII转移(1b16)后面跟着一个0-f的16进制的书,就可以设置前景色为 CGA颜色。如果你自己想尝试实现;在下载页面有一个我的详细的例子。 + + +### 4 标志输入 + +``` +按照惯例,许多编程语言中,任意程序可以访问 stdin 和 stdin,他们可以连接到终端的输入和输出流。在图形程序其实也可以进行同样操作,但实际几乎不用。 +``` + +现在我们有一个可以打印和显示文本的输出终端。这仅仅是说了一半,我们需要输入。我们想实现一个方法:Readline,可以保存文件的一行文本,文本位置有 r0 给出,最大的长度由 r1 给出,返回 r0 里面的字符串长度。棘手的是用户输出字符的时候要回显功能,同时想要退格键的删除功能和命令回车执行功能。他们还想需要一个闪烁的下划线代表计算机需要输入。这些完全合理的要求让构造这个方法更具有挑战性。有一个方法完成这些需求就是存储用户输入的文本和文件大小到内存的某个地方。然后当调用 ReadLine 的时候,移动 terminalStop 的地址到它开始的地方然后调用 Print。也就是说我们只需要确保在内存维护一个字符串,然后构造一个我们自己的打印函数。 + +让我们看看 ReadLine做了哪些事情: + + 1. 如果字符串可保存的最大长度为0,直接返回 + 2. 检索 terminalStop 和 terminalStop 的当前值 + 3. 如果字符串的最大长度大约缓冲区的一半,就设置大小为缓冲区的一半 + 4. 从最大长度里面减去1来确保输入的闪烁字符或结束符 + 5. 向字符串写入一个下划线 + 6. 写入一个 terminalView 和 terminalStop 的地址到内存 + 7. 调用 Print 大约当前字符串 + 8. 调用 TerminalDisplay + 9. 调用 KeyboardUpdate + 10. 调用 KeyboardGetChar + 11. 如果为一个新行直接跳转到16 + 12. 如果是一个退格键,将字符串长度减一(如果其大约0) + 13. 如果是一个普通字符,将他写入字符串(字符串大小确保小于最大值) + 14. 如果字符串是以下划线结束,写入一个空格,否则写入下划线 + 15. 跳转到6 + 16. 字符串的末尾写入一个新行 + 17. 调用 Print 和 TerminalDisplay + 18. 用结束符替换新行 + 19. 返回字符串的长度 + + + +为了方便读者理解,然后然后自己去实现,我们的实现提供如下: + +1. +``` +.globl ReadLine +ReadLine: +teq r1,#0 +moveq r0,#0 +moveq pc,lr +``` +快速处理长度为0的情况 + +2. +``` +string .req r4 +maxLength .req r5 +input .req r6 +taddr .req r7 +length .req r8 +view .req r9 + +push {r4,r5,r6,r7,r8,r9,lr} + +mov string,r0 +mov maxLength,r1 +ldr taddr,=terminalStart +ldr input,[taddr,#terminalStop-terminalStart] +ldr view,[taddr,#terminalView-terminalStart] +mov length,#0 +``` +考虑到常见的场景,我们初期做了很多初始化动作。input 代表 terminalStop 的值,view 代表 terminalView。Length 默认为 0. + +3. +``` +cmp maxLength,#128*64 +movhi maxLength,#128*64 +``` +我们必须检查异常大的读操作,我们不能处理超过 terminalBuffer 大小的输入(理论上可行,但是terminalStart 移动越过存储的terminalStop,会有很多问题)。 + +4. +``` +sub maxLength,#1 +``` +由于用户需要一个闪烁的光标,我们需要一个备用字符在理想状况在这个字符串后面放一个结束符。 + +5. +``` +mov r0,#'_' +strb r0,[string,length] +``` +写入一个下划线让用户知道我们可以输入了。 + +6. +``` +readLoop$: +str input,[taddr,#terminalStop-terminalStart] +str view,[taddr,#terminalView-terminalStart] +``` +保存 terminalStop 和 terminalView。这个对重置一个终端很重要,它会修改这些变量。严格讲也可以修改 terminalStart,但是不可逆。 + +7. +``` +mov r0,string +mov r1,length +add r1,#1 +bl Print +``` +写入当前的输入。由于下划线因此字符串长度加1 +8. +``` +bl TerminalDisplay +``` +拷贝下一个文本到屏幕 + +9. +``` +bl KeyboardUpdate +``` +获取最近一次键盘输入 + +10. +``` +bl KeyboardGetChar +``` +检索键盘输入键值 + +11. +``` +teq r0,#'\n' +beq readLoopBreak$ +teq r0,#0 +beq cursor$ +teq r0,#'\b' +bne standard$ +``` + +如果我们有一个回车键,循环中断。如果有结束符和一个退格键也会同样跳出选好。 + +12. +``` +delete$: +cmp length,#0 +subgt length,#1 +b cursor$ +``` +从 length 里面删除一个字符 + +13. +``` +standard$: +cmp length,maxLength +bge cursor$ +strb r0,[string,length] +add length,#1 +``` +写回一个普通字符 + +14. +``` +cursor$: +ldrb r0,[string,length] +teq r0,#'_' +moveq r0,#' ' +movne r0,#'_' +strb r0,[string,length] +``` +加载最近的一个字符,如果不是下换线则修改为下换线,如果是空格则修改为下划线 + +15. +``` +b readLoop$ +readLoopBreak$: +``` +循环执行值到用户输入按下 + +16. +``` +mov r0,#'\n' +strb r0,[string,length] +``` +在字符串的结尾处存入一新行 + +17. +``` +str input,[taddr,#terminalStop-terminalStart] +str view,[taddr,#terminalView-terminalStart] +mov r0,string +mov r1,length +add r1,#1 +bl Print +bl TerminalDisplay +``` +重置 terminalView 和 terminalStop 然后调用 Print 和 TerminalDisplay 输入回显 + + +18. +``` +mov r0,#0 +strb r0,[string,length] +``` +写入一个结束符 + +19. +``` +mov r0,length +pop {r4,r5,r6,r7,r8,r9,pc} +.unreq string +.unreq maxLength +.unreq input +.unreq taddr +.unreq length +.unreq view +``` +返回长度 + + + + +### 5 终端: 机器进化 + +现在我们理论用终端和用户可以交互了。最显而易见的事情就是拿去测试了!在 'main.s' 里UsbInitialise后面的删除代码如下 + +``` +reset$: + mov sp,#0x8000 + bl TerminalClear + + ldr r0,=welcome + mov r1,#welcomeEnd-welcome + bl Print + +loop$: + ldr r0,=prompt + mov r1,#promptEnd-prompt + bl Print + + ldr r0,=command + mov r1,#commandEnd-command + bl ReadLine + + teq r0,#0 + beq loopContinue$ + + mov r4,r0 + + ldr r5,=command + ldr r6,=commandTable + + ldr r7,[r6,#0] + ldr r9,[r6,#4] + commandLoop$: + ldr r8,[r6,#8] + sub r1,r8,r7 + + cmp r1,r4 + bgt commandLoopContinue$ + + mov r0,#0 + commandName$: + ldrb r2,[r5,r0] + ldrb r3,[r7,r0] + teq r2,r3 + bne commandLoopContinue$ + add r0,#1 + teq r0,r1 + bne commandName$ + + ldrb r2,[r5,r0] + teq r2,#0 + teqne r2,#' ' + bne commandLoopContinue$ + + mov r0,r5 + mov r1,r4 + mov lr,pc + mov pc,r9 + b loopContinue$ + + commandLoopContinue$: + add r6,#8 + mov r7,r8 + ldr r9,[r6,#4] + teq r9,#0 + bne commandLoop$ + + ldr r0,=commandUnknown + mov r1,#commandUnknownEnd-commandUnknown + ldr r2,=formatBuffer + ldr r3,=command + bl FormatString + + mov r1,r0 + ldr r0,=formatBuffer + bl Print + +loopContinue$: + bl TerminalDisplay + b loop$ + +echo: + cmp r1,#5 + movle pc,lr + + add r0,#5 + sub r1,#5 + b Print + +ok: + teq r1,#5 + beq okOn$ + teq r1,#6 + beq okOff$ + mov pc,lr + + okOn$: + ldrb r2,[r0,#3] + teq r2,#'o' + ldreqb r2,[r0,#4] + teqeq r2,#'n' + movne pc,lr + mov r1,#0 + b okAct$ + + okOff$: + ldrb r2,[r0,#3] + teq r2,#'o' + ldreqb r2,[r0,#4] + teqeq r2,#'f' + ldreqb r2,[r0,#5] + teqeq r2,#'f' + movne pc,lr + mov r1,#1 + + okAct$: + + mov r0,#16 + b SetGpio + +.section .data +.align 2 +welcome: .ascii "Welcome to Alex's OS - Everyone's favourite OS" +welcomeEnd: +.align 2 +prompt: .ascii "\n> " +promptEnd: +.align 2 +command: + .rept 128 + .byte 0 + .endr +commandEnd: +.byte 0 +.align 2 +commandUnknown: .ascii "Command `%s' was not recognised.\n" +commandUnknownEnd: +.align 2 +formatBuffer: + .rept 256 + .byte 0 + .endr +formatEnd: + +.align 2 +commandStringEcho: .ascii "echo" +commandStringReset: .ascii "reset" +commandStringOk: .ascii "ok" +commandStringCls: .ascii "cls" +commandStringEnd: + +.align 2 +commandTable: +.int commandStringEcho, echo +.int commandStringReset, reset$ +.int commandStringOk, ok +.int commandStringCls, TerminalClear +.int commandStringEnd, 0 +``` +这块代码集成了一个简易的命令行操作系统。支持命令:echo,reset,ok 和 cls。echo 拷贝任意文本到终端,reset命令会在系统出现问题的是复位操作系统,ok 有两个功能:设置 OK 灯亮灭,最后 cls 调用 TerminalClear 清空终端。 + +试试树莓派的代码吧。如果遇到问题,请参照问题集锦页面吧。 + +如果运行正常,祝贺你完成了一个操作系统基本终端和输入系列的课程。很遗憾这个教程先讲到这里,但是我希望将来能制作更多教程。有问题请反馈至awc32@cam.ac.uk。 + +你已经在建立了一个简易的终端操作系统。我们的代码在 commandTable 构造了一个可用的命令表格。每个表格的入口是一个整型数字,用来表示字符串的地址,和一个整型数字表格代码的执行入口。 最后一个入口是 为 0 的commandStringEnd。尝试实现你自己的命令,可以参照已有的函数,建立一个新的。函数的参数 r0 是用户输入的命令地址,r1是其长度。你可以用这个传递你输入值到你的命令。也许你有一个计算器程序,或许是一个绘图程序或国际象棋。不管你的什么电子,让它跑起来! + + +-------------------------------------------------------------------------------- + +via: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input02.html + +作者:[Alex Chadwick][a] +选题:[lujun9972][b] +译者:[译者ID](https://github.com/guevaraya) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.cl.cam.ac.uk +[b]: https://github.com/lujun9972 +[1]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/input01.html +[2]: https://www.cl.cam.ac.uk/projects/raspberrypi/tutorials/os/images/circular_buffer.png +[3]: https://en.wikipedia.org/wiki/Color_Graphics_Adapter diff --git a/translated/tech/20170519 zsh shell inside Emacs on Windows.md b/translated/tech/20170519 zsh shell inside Emacs on Windows.md new file mode 100644 index 0000000000..82b3394812 --- /dev/null +++ b/translated/tech/20170519 zsh shell inside Emacs on Windows.md @@ -0,0 +1,113 @@ +[#]:collector:(lujun9972) +[#]:translator:(lujun9972) +[#]:reviewer:( ) +[#]:publisher:( ) +[#]:url:( ) +[#]:subject:(zsh shell inside Emacs on Windows) +[#]:via:(https://www.onwebsecurity.com/configuration/zsh-shell-inside-emacs-on-windows.html) +[#]:author:(Peter Mosmans https://www.onwebsecurity.com/) + +Windows 下 Emacs 中的 zsh shell +====== + +![zsh shell inside Emacs on Windows][5] + +运行跨平台 shell( 例如 Bash 或 zsh) 的最大优势在于你能在多平台上使用同样的语法和脚本。在 Windows 上设置 (替换) shells 挺麻烦的,但所获得的回报远远超出这小小的付出。 + +MSYS2 子系统允许你在 Windows 上运行 Bash 或 zsh 之类的 shell。使用 MSYS2 很重要的一点在于确保搜索路径都指向 MSYS2 子系统本身:存在太多依赖关系了。 + +MSYS2 安装后默认的 shell 就是 Bash; zsh 则可以通过包管理器进行安装: + +``` +pacman -Sy zsh +``` + +通过修改 `etc/passwd` 文件可以设置 zsh 作为默认 shell,例如: + +``` +mkpasswd -c | sed -e 's/bash/zsh/' | tee -a /etc/passwd +``` + +这会将默认 shell 从 bash 改成 zsh。 + +要在 Windows 上的 Emacs 运行 zsh 需要修改 ` shell-file-name` 变量,将它指向 MSYS2 子系统中的 zsh 二进制文件。该二进制 shell 文件在 Emacs ` exec-path` 变量中的某个地方。 + +``` +(setq shell-file-name (executable-find "zsh.exe")) +``` + +不要忘了修改 Emacs 的 PATH 环境变量,因为 MSYS2 路径应该先于 Windows 路径。接上一个例子,假设 MSYS2 安装在 + +``` +c:\programs\msys2 +``` + +中,那么执行: + +``` +(setenv "PATH" "C:\\programs\\msys2\\mingw64\\bin;C:\\programs\\msys2\\usr\\local\\bin;C:\\programs\\msys2\\usr\\bin;C:\\Windows\\System32;C:\\Windows") +``` + +在 Emacs 配置文件中设置好这两个变量后,在 Emacs 中运行 + +``` +M-x shell +``` + +应该就能看到熟悉的 zsh 提示符了。 + +Emacs' 的终端设置 (eterm) 与 MSYS2 的标准终端设置 (xterm-256color) 不一样。这意味着某些插件和主题(标识符)可能不能正常工作 - 尤其在使用 oh-my-zsh 时。 + +检测 zsh 否则在 Emacs 中运行很简单,使用变量 + +``` +$INSIDE_EMACS +``` + +. 下面这段代码片段取自 `.zshrc`( 当以交互式 shell 模式启动时会被加载),它会在 zsh 在 Emacs 中运行时启动 git 插件并更改主题 + +``` +# Disable some plugins while running in Emacs +if [[ -n "$INSIDE_EMACS" ]]; then + plugins=(git) + ZSH_THEME="simple" +else + ZSH_THEME="compact-grey" +fi +``` + +通过在本地 `~/.ssh/config` 文件中将 `INSIDE_EMACS` 变量设置为 `SendEnv` 变量。.。 + +``` +Host myhost +SendEnv INSIDE_EMACS +``` + +.。. 同时在 ssh 服务器的 `/etc/ssh/sshd_config` 中设置为 `AcceptEnv` 变量 .。。 + +``` +AcceptEnv LANG LC_* INSIDE_EMACS +``` + +.。. 这使得在 Emacs shell 会话中通过 ssh 登录另一个运行着 zsh 的 ssh 服务器也能工作的很好。当在 Windows 下的 Emacs 中的 zsh 上通过 ssh 远程登录时,记得使用参数 `-t` `-t` 参数会强制分配伪终端(之所以需要这样,时因为 Windows 下的 Emacs 并没有真正的 tty)。 + +跨平台,开源真是个好东西。.。 + +-------------------------------------------------------------------------------- + +via: https://www.onwebsecurity.com/configuration/zsh-shell-inside-emacs-on-windows.html + +作者:[Peter Mosmans][a] +选题:[lujun9972][b] +译者:[lujun9972](https://github.com/lujun9972) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://www.onwebsecurity.com/ +[b]: https://github.com/lujun9972 +[1]: https://www.onwebsecurity.com/category/configuration.html +[2]: https://www.onwebsecurity.com/tag/emacs.html +[3]: https://www.onwebsecurity.com/tag/msys2.html +[4]: https://www.onwebsecurity.com/tag/zsh.html +[5]: https://www.onwebsecurity.com//images/zsh-shell-inside-emacs-on-windows.png diff --git a/translated/tech/20180629 How To Get Flatpak Apps And Games Built With OpenGL To Work With Proprietary Nvidia Graphics Drivers.md b/translated/tech/20180629 How To Get Flatpak Apps And Games Built With OpenGL To Work With Proprietary Nvidia Graphics Drivers.md new file mode 100644 index 0000000000..33b8b8e530 --- /dev/null +++ b/translated/tech/20180629 How To Get Flatpak Apps And Games Built With OpenGL To Work With Proprietary Nvidia Graphics Drivers.md @@ -0,0 +1,121 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (How To Get Flatpak Apps And Games Built With OpenGL To Work With Proprietary Nvidia Graphics Drivers) +[#]: via: (https://www.linuxuprising.com/2018/06/how-to-get-flatpak-apps-and-games-built.html) +[#]: author: (Logix https://plus.google.com/118280394805678839070) + +如何使得支持 OpenGL 的 Flatpak 应用和游戏在专有 Nvidia 图形驱动下工作 +====== +**一些支持 OpenGL 并打包为 Flatpak 的应用和游戏无法使用专有 Nvidia 驱动启动。本文将介绍如何在不安装开源驱动(Nouveau)的情况下启动这些 Flatpak 应用或游戏。** + +这有个例子。我在我的 Ubuntu 18.04 桌面上使用专有的 Nvidia 驱动程序 (`nvidia-driver-390`),当我尝试启动最新版本时: +``` +$ /usr/bin/flatpak run --branch=stable --arch=x86_64 --command=krita --file-forwarding org.kde.krita +Gtk-Message: Failed to load module "canberra-gtk-module" +Gtk-Message: Failed to load module "canberra-gtk-module" +libGL error: No matching fbConfigs or visuals found +libGL error: failed to load driver: swrast +Could not initialize GLX + +``` + +要修复使用 OpenGL 和专有 Nvidia 图形驱动时无法启动的 Flatpak 游戏和应用,你需要为已安装的专有驱动安装运行时。以下是步骤。 + +**1\. 如果尚未添加 FlatHub 仓库,请添加它。你可以在[此处][1]找到针对 Linux 发行版的说明。** + +**2. 现在,你需要确定系统上安装的专有 Nvidia 驱动的确切版本。** + +_这一步取决于你使用的 Linux 发行版,我无法涵盖所有​​情况。下面的说明是面向 Ubuntu(以及 Ubuntu 风格的版本),但希望你可以自己弄清楚系统上安装的 Nvidia 驱动版本._ + +要在 Ubuntu 中执行此操作,请打开 `Software&Updates`,切换到 `Additional Drivers` 选项卡并记下 Nvidia 驱动包的名称。 + +比如,你可以看到我的是 `nvidia-driver-390`: + +![](https://1.bp.blogspot.com/-FAfjtGNeUJc/WzYXMYTFBcI/AAAAAAAAAx0/xUhIO83IAjMuK4Hn0jFUYKJhSKw8y559QCLcBGAs/s1600/additional-drivers-nvidia-ubuntu.png) + +这里还没完成。我们只是找到了 Nvidia 驱动的主要版本,但我们还需要知道次要版本。要获得我们下一步所需的确切 Nvidia 驱动版本,请运行此命令(应该适用于任何基于 Debian 的 Linux 发行版,如 Ubuntu、Linux Mint 等): +``` +apt-cache policy NVIDIA-PACKAGE-NAME + +``` + +NVIDIA-PACKAGE-NAME 是 `Software & Updates` 中列出的 Nvidia 驱动包名称。例如,要查看 `nvidia-driver-390` 包的确切安装版本,请运行以下命令: +``` +$ apt-cache policy nvidia-driver-390 +nvidia-driver-390: + Installed: 390.48-0ubuntu3 + Candidate: 390.48-0ubuntu3 + Version table: + * 390.48-0ubuntu3 500 + 500 http://ro.archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages + 100 /var/lib/dpkg/status + +``` + +在这个命令的输出中,查找 `Installed` 部分并记下版本号(不包括 `-0ubuntu3` 之类)。现在我们知道了已安装的 Nvidia 驱动的确切版本(我例子中的是 `390.48`)。记住它,因为下一步我们需要。 + +**3\. 最后,你可以从 FlatHub 为你已安装的专有 Nvidia 图形驱动安装运行时。** + +要列出 FlatHub 上所有可用的 Nvidia 运行时包,你可以使用以下命令: +``` +flatpak remote-ls flathub | grep nvidia + +``` + +幸运地是 FlatHub 上提供这个 Nvidia 驱动的运行时。你现在可以使用以下命令继续安装运行时: + + * 针对 64 位系统: + + +``` +flatpak install flathub org.freedesktop.Platform.GL.nvidia-MAJORVERSION-MINORVERSION + +``` + +将 MAJORVERSION 替换为 Nvidia 驱动的主要版本(在上面的示例中为 390),将 MINORVERSION 替换为次要版本(步骤2,我例子中的为 48)。 + +例如,要为 Nvidia 图形驱动版本 390.48 安装运行时,你必须使用以下命令: +``` +flatpak install flathub org.freedesktop.Platform.GL.nvidia-390-48 + +``` + + * 对于 32 位系统(或能够在 64 位上运行 32 位的应用或游戏),使用以下命令安装 32 位运行时: + + +``` +flatpak install flathub org.freedesktop.Platform.GL32.nvidia-MAJORVERSION-MINORVERSION + +``` + +再说一次,将 MAJORVERSION 替换为 Nvidia 驱动的主要版本(在上面的示例中为 390),将 MINORVERSION 替换为次要版本(步骤2,我例子中的为 48)。 + +比如,要为 Nvidia 图形驱动版本 390.48 安装 32 位运行时,你需要使用以下命令: +``` +flatpak install flathub org.freedesktop.Platform.GL32.nvidia-390-48 + +``` + +以上就是你要运行支持 OpenGL 的 Flatpak 的应用或游戏的方法。 + + +-------------------------------------------------------------------------------- + +via: https://www.linuxuprising.com/2018/06/how-to-get-flatpak-apps-and-games-built.html + +作者:[Logix][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://plus.google.com/118280394805678839070 +[1]:https://flatpak.org/setup/ +[2]:https://www.linuxuprising.com/2018/06/free-painting-software-krita-410.html +[3]:https://www.linuxuprising.com/2018/06/winepak-is-flatpak-repository-for.html +[4]:https://github.com/winepak/applications/issues/23 +[5]:https://github.com/flatpak/flatpak/issues/138 diff --git a/translated/tech/20190121 Akira- The Linux Design Tool We-ve Always Wanted.md b/translated/tech/20190121 Akira- The Linux Design Tool We-ve Always Wanted.md new file mode 100644 index 0000000000..ad957f697d --- /dev/null +++ b/translated/tech/20190121 Akira- The Linux Design Tool We-ve Always Wanted.md @@ -0,0 +1,91 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Akira: The Linux Design Tool We’ve Always Wanted?) +[#]: via: (https://itsfoss.com/akira-design-tool) +[#]: author: (Ankush Das https://itsfoss.com/author/ankush/) + +Akira:我们一直想要的 Linux 设计工具? +====== + +先说一下,我不是一个专业的设计师 - 但我在 Windows 上使用了某些工具(如 Photoshop、Illustrator 等)和 [Figma] [1](这是一个基于浏览器的界面设计工具)。我相信 Mac 和 Windows 上还有更多的设计工具。 + +即使在 Linux 上,也只有有限的专用[图形设计工具][2]。其中一些工具如 [GIMP][3] 和 [Inkscape][4] 也被专业人士使用。但不幸的是,它们中的大多数都不被视为专业级。 + +即使有更多解决方案 - 我也从未遇到过可以取代 [Sketch][5]、Figma 或 Adobe XD 的原生 Linux 应用。任何专业设计师都同意这点,不是吗? + +### Akira 是否会在 Linux 上取代 Sketch、Figma 和 Adobe XD? + +所以,为了开发一些能够取代那些专有工具的应用 - [Alessandro Castellani][6] 发起了一个 [Kickstarter 活动][7],并与几位经验丰富的开发人员 [Alberto Fanjul][8]、[Bilal Elmoussaoui][9] 和 [Felipe Escoto][10] 组队合作。 + +是的,Akira 仍然只是一个想法,只有一个界面原型(正如我最近在 Kickstarter 的[直播流][11]中看到的那样)。 + +### 如果它还没有,为什么会发起 Kickstarter 活动? + +![][12] + +Kickstarter 活动的目的是收集资金,以便雇用开发人员,并花几个月的时间开发,以使 Akira 成为可能。 + +尽管如此,如果你想支持这个项目,你应该知道一些细节,对吧? + +不用担心,我们在他们的直播中问了几个问题 - 让我们看下 + +### Akira:更多细节 + +![Akira prototype interface][13] +图片来源:Kickstarter + +如 Kickstarter 活动描述的那样: + +> Akira 的主要目的是提供一个快速而直观的工具来**创建 Web 和移动界面**,更像是 **Sketch**、**Figma** 或 **Adob​​e XD**,并且是 Linux 原生体验。 + +他们还详细描述了该工具与 Inkscape、Glade 或 QML Editor 的不同之处。当然,如果你想要所有的技术细节,请查看 [Kickstarter][7]。但是,在此之前,让我们看一看当我询问有关 Akira 的一些问题时他们说了些什么。 + +问:如果你认为你的项目类似于 Figma - 人们为什么要考虑安装 Akira 而不是使用基于网络的工具?它是否只是这些工具的克隆 - 提供原生 Linux 体验,还是有一些非常有趣的东西可以鼓励用户切换(除了是开源解决方案之外)? + +** Akira:** 与基于网络的 electron 应用相比,Linux 原生体验总是更好、更快。此外,如果你选择使用 Figma,硬件配置也很重要 - 但 Akira 将会占用很少的系统资源,并且你可以在不需要上网的情况下完成类似工作。 + +问:假设它成为了 Linux用户一直在等待的开源方案(拥有专有工具的类似功能)。你有什么维护计划?你是否计划引入定价 - 或依赖捐赠? + +**Akira:**该项目主要依靠捐赠(类似于 [Krita 基金会][14] 这样的想法)。但是,不会有“专业版”计划 - 它将免费提供,它将是一个开源项目。 + +根据我得到的回答,它看起来似乎很有希望,我们应该支持。 + +### 总结 + +你怎么认为 Akira?它只是一个概念吗?或者你希望看到进展? + +请在下面的评论中告诉我们你的想法。 + +![][15] + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/akira-design-tool + +作者:[Ankush Das][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/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://www.figma.com/ +[2]: https://itsfoss.com/best-linux-graphic-design-software/ +[3]: https://itsfoss.com/gimp-2-10-release/ +[4]: https://inkscape.org/ +[5]: https://www.sketchapp.com/ +[6]: https://github.com/Alecaddd +[7]: https://www.kickstarter.com/projects/alecaddd/akira-the-linux-design-tool/description +[8]: https://github.com/albfan +[9]: https://github.com/bilelmoussaoui +[10]: https://github.com/Philip-Scott +[11]: https://live.kickstarter.com/alessandro-castellani/live-stream/the-current-state-of-akira +[12]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/akira-design-tool-kickstarter.jpg?resize=800%2C451&ssl=1 +[13]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/akira-mockup.png?ssl=1 +[14]: https://krita.org/en/about/krita-foundation/ +[15]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/akira-design-tool-kickstarter.jpg?fit=812%2C458&ssl=1 diff --git a/translated/tech/20190128 Top Hex Editors for Linux.md b/translated/tech/20190128 Top Hex Editors for Linux.md new file mode 100644 index 0000000000..ed3eba4c9f --- /dev/null +++ b/translated/tech/20190128 Top Hex Editors for Linux.md @@ -0,0 +1,147 @@ +[#]: collector: "lujun9972" +[#]: translator: "zero-mk " +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " +[#]: subject: "Top Hex Editors for Linux" +[#]: via: "https://itsfoss.com/hex-editors-linux" +[#]: author: "Ankush Das https://itsfoss.com/author/ankush/" + +Top Hex Editors for Linux +====== + +十六进制编辑器可以让你以十六进制的形式查看/编辑文件的二进制数据,因此其被命名为“十六进制”编辑器。说实话,并不是每个人都需要它。只有必须处理二进制数据的特定用户组才会使用到它。 + +如果您不知道,它是什么,让我举个例子。假设您拥有游戏的配置文件,您可以使用十六进制编辑器打开它们并更改某些值以获得更多的弹药/分数等等。 想要了解有关Hex编辑器的更多信息,你可以参阅 [Wikipedia page][1]。 + +如果你已经知道它用来干什么了 —— 让我们来看看Linux最好的Hex编辑器。 + +### 5个最好的十六进制编辑器 + +![Best Hex Editors for Linux][2] + +**注意:**提到的十六进制编辑器没有特定的排名顺序。 + +#### 1\. Bless Hex Editor + +![bless hex editor][3] + +**主要特点:** + + * 编辑裸设备(Raw disk ) + * 多级撤消/重做操作 + * 多个标签 + * 转换表 + * 支持插件扩展功能 + + + +Bless是Linux上最流行的Hex编辑器之一。您可以在AppCenter或软件中心中找到它。 如果不是这种情况,您可以查看他们的 [GitHub page][4] 获取构建和相关的说明。 + +它可以轻松处理编辑大文件而不会降低速度——因此它是一个快速的十六进制编辑器。 + +#### 2\. GNOME Hex Editor + +![gnome hex editor][5] + +**主要特点:** + + * 以 十六进制/Ascii格式 查看/编辑 + + * 编辑大文件 + + * + + +另一个神奇的十六进制编辑器-专门为GNOME量身定做的。 我个人用的是 Elementary OS, 所以我可以在 软件中心(AppCenter)找到它.。您也可以在软件中心找到它。如果没有,请参考 [GitHub page][6] 获取源代码。 + +您可以使用此编辑器以十六进制或ASCII格式 查看/编辑 文件。用户界面非常简单——正如您在上面的图像中看到的那样。 + +#### 3\. Okteta + +![okteta][7] + +**主要特点:** + + * 可自定义的数据视图 + * 多个选项卡 + * 字符编码:支持Qt、EBCDIC的所有8位编码 + * 解码表列出常见的简单数据类型 + + + +Okteta是一个简单的十六进制编辑器,没有那么奇特的功能。虽然它可以处理大部分任务。它有一个单独的模块,你可以使用它嵌入其他程序来查看/编辑文件。 + + +与上述所有编辑器类似,您也可以在应用中心(App Center)和软件中心(Software Center)上找到列出的编辑器。 + +#### 4\. wxHexEditor + +![wxhexeditor][8] + +**主要特点:** + + * 轻松处理大文件 + * 支持x86反汇编 + * **** Sector Indication **** on Disk devices + * 支持自定义十六进制面板格式和颜色 + + + +这很有趣。它主要是一个十六进制编辑器,但您也可以将其用作低级磁盘编辑器。例如,如果您的硬盘有问题,可以使用此编辑器编辑RAW格式原始数据镜像文件,在十六进制中的扇区并修复它。 + +你可以在你的应用中心(App Center)和软件中心(Software Center)找到它。 如果不是, [Sourceforge][9] 是个正确的选择。 + +#### 5\. Hexedit (命令行工具) + +![hexedit][10] + +**主要特点:** + + * 运行在命令行终端上 + * 它又快又简单 + + + +如果您想在终端上工作,可以继续通过控制台安装hexedit。它是我最喜欢的命令行Linux十六进制编辑器。 + +当你启动它时,你必须指定要打开的文件的位置,然后它会为你打开它。 + +要安装它,只需输入: + +``` +sudo apt install hexedit +``` + +### 结束 + +十六进制编辑器可以方便地进行实验和学习。如果你是一个有经验的人,你应该选择一个有更多功能的——GUI。 尽管这一切都取决于个人喜好。 + +你认为十六进制编辑器的有用性如何?你用哪一个?我们没有列出你最喜欢的吗?请在评论中告诉我们! + +![][11] + +-------------------------------------------------------------------------------- + +via: https://itsfoss.com/hex-editors-linux + +作者:[Ankush Das][a] +选题:[lujun9972][b] +译者:[zero-mk](https://github.com/zero-mk) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://itsfoss.com/author/ankush/ +[b]: https://github.com/lujun9972 +[1]: https://en.wikipedia.org/wiki/Hex_editor +[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/Linux-hex-editors-800x450.jpeg?resize=800%2C450&ssl=1 +[3]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/bless-hex-editor.jpg?ssl=1 +[4]: https://github.com/bwrsandman/Bless +[5]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/01/ghex-hex-editor.jpg?ssl=1 +[6]: https://github.com/GNOME/ghex +[7]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/okteta-hex-editor-800x466.jpg?resize=800%2C466&ssl=1 +[8]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/01/wxhexeditor.jpg?ssl=1 +[9]: https://sourceforge.net/projects/wxhexeditor/ +[10]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/hexedit-console.jpg?resize=800%2C566&ssl=1 +[11]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/01/Linux-hex-editors.jpeg?fit=800%2C450&ssl=1 diff --git a/translated/tech/20190131 19 days of productivity in 2019- The fails.md b/translated/tech/20190131 19 days of productivity in 2019- The fails.md new file mode 100644 index 0000000000..a0a7100a00 --- /dev/null +++ b/translated/tech/20190131 19 days of productivity in 2019- The fails.md @@ -0,0 +1,78 @@ +[#]: collector: (lujun9972) +[#]: translator: (geekpi) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (19 days of productivity in 2019: The fails) +[#]: via: (https://opensource.com/article/19/1/productivity-tool-wish-list) +[#]: author: (Kevin Sonney https://opensource.com/users/ksonney (Kevin Sonney)) + +2019 年的 19 个高效日:失败了 +====== +以下是开源世界没有做到的一些工具。 +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/tools_sysadmin_cloud.png?itok=sUciG0Cn) + +每年年初似乎都有疯狂的冲动想提高工作效率。新年的决心,渴望开启新的一年,当然,“抛弃旧的,拥抱新的”的态度促成了这一切。通常这时的建议严重偏向闭源和专有软件,但事实上并不用这样。 + +保持高效一部分是接受失败发生。我是 [Howard Tayler's][1] 的第 70 条座右铭的支持者:“失败不是一种选择,它是一定的。可以选择的是是否让失败成为你做的最后一件事。”我对这个系列的有很多话想多,但是我没有找到好的答案。 + +关于我的 19 个新的(或对你而言新的)帮助你在 2019 年更高效的工具的最终版,我想到了一些我想要的,但是没有找到的。我希望读者你能够帮我找到下面这些项目的好的方案。如果你发现了,请在下面的留言中分享。 + +### 日历 + +![](https://opensource.com/sites/default/files/uploads/thunderbird-1.png) + +如果开源世界有一件事缺乏,那就是日历。我尝试过的日历程序和尝试电子邮件程序的数量一样多。共享日历基本上有三个很好的选择:[Evolution][2]、[Thunderbird 中的 Lightning 附加组件][3] 或 [KOrganizer][4]。我尝试过的所有其他应用 (包括 [Orage][5]、[Osmo][6] 以及几乎所有 [Org 模式][7]附加组件) 似乎只可靠地支持对远程日历的只读访问。如果共享日历使用 [Google 日历][8] 或 [Microsoft Exchange][9] 作为服务器,那么前三个是唯一易于配置的选择(即便如此,通常还需要其他附加组件)。 + +### Linux 内核的系统 + +![](https://opensource.com/sites/default/files/uploads/android-x86-2.png) + +我喜欢 [Chrome OS][10] 的简单性和轻量需求。我有几款 Chromebook,包括谷歌的最新型号。我发现它不会分散注意力、重量轻、易于使用。通过添加 Android 应用和 Linux 容器,几乎可以在任何地方轻松高效工作。 + +我想把它安装到我一些闲置的笔记本上,但除非我对 Chromium OS 进行全面编译,否则很难有相同的体验。像 [Bliss OS][12]、[Phoenix OS][13] 和 [Android-x86][14] 这样的桌面 [Android][11] 项目快要完成了,我正在关注它们的未来。 + +### 客户服务 + +![](https://opensource.com/sites/default/files/uploads/opennms_jira_dashboard-3.png) + +对于大大小小的公司来说,客户服务是一件大事。现在,随着近来对 DevOps 的关注,有必要使用工具来弥补差距。我工作的几乎每家公司都使用 [Jira][15]、[GitHub][16] 或 [GitLab][17] 来提代码问题,但这些工具都不是很擅长客户支持工单(没有很多工作)。虽然围绕客户支持工单和问题设计了许多应用,但大多数(如果不是全部)应用都是与其他系统不兼容的孤岛,同样没有大量工作。 + +我的愿望是有一个开源解决方案,它能让客户、支持人员和开发人员一起工作,而无需笨重的代码将多个系统粘合在一起。 + +### 轮到你了 + +![](https://opensource.com/sites/default/files/uploads/asciiquarium-4.png) + +我相信这个系列中我错过了很多选择。我经常尝试新的应用,希望它们能帮助我提高工作效率。我鼓励每个人都这样做,因为当谈到使用开源工具提高工作效率时,总会有新的选择。如果你有喜欢的开源生产力应用没有进入本系列,请务必在评论中分享它们。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/1/productivity-tool-wish-list + +作者:[Kevin Sonney][a] +选题:[lujun9972][b] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ksonney (Kevin Sonney) +[b]: https://github.com/lujun9972 +[1]: https://www.schlockmercenary.com/ +[2]: https://wiki.gnome.org/Apps/Evolution +[3]: https://www.thunderbird.net/en-US/calendar/ +[4]: https://userbase.kde.org/KOrganizer +[5]: https://github.com/xfce-mirror/orage +[6]: http://clayo.org/osmo/ +[7]: https://orgmode.org/ +[8]: https://calendar.google.com +[9]: https://products.office.com/ +[10]: https://en.wikipedia.org/wiki/Chrome_OS +[11]: https://www.android.com/ +[12]: https://blissroms.com/ +[13]: http://www.phoenixos.com/ +[14]: http://www.android-x86.org/ +[15]: https://www.atlassian.com/software/jira +[16]: https://github.com +[17]: https://about.gitlab.com/ diff --git a/translated/tech/20190301 Which Raspberry Pi should you choose.md b/translated/tech/20190301 Which Raspberry Pi should you choose.md new file mode 100644 index 0000000000..53b500e65e --- /dev/null +++ b/translated/tech/20190301 Which Raspberry Pi should you choose.md @@ -0,0 +1,47 @@ +[#]: collector: (lujun9972) +[#]: translator: (qhwdw) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Which Raspberry Pi should you choose?) +[#]: via: (https://opensource.com/article/19/3/which-raspberry-pi-choose) +[#]: author: (Anderson Silva https://opensource.com/users/ansilva) + +你应该选择哪种树莓派? +====== +在我们的《树莓派使用入门》系列的第一篇文章中,我们将学习选择符合你要求的树莓派型号的三个标准。 +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/raspberrypi_board_vector_red.png?itok=yaqYjYqI) + +本文是《14 天学会[树莓派][1]使用》系列文章的第一篇。虽然本系列文章主要面向没有使用过树莓派或 Linux 或没有编程经验的人群,但是肯定有些东西还是需要有经验的读者的,我希望这些读者能够留下他们有益的评论、提示和补充。如果每个人都能贡献,这将会让本系列文章对初学者、其它有经验的读者、甚至是我更受益! + +言归正传,如果你想拥有一个树莓派,但不知道应该买哪个型号。或许你希望为你的教学活动或你的孩子买一个,但面对这么多的选择,却不知道应该买哪个才是正确的决定。 + +![](https://opensource.com/sites/default/files/uploads/raspberrypi_1_boards.png) + +关于选择一个新的树莓派,我有三个主要的标准: + + * **成本:** 不能只考虑树莓派板的成本,还需要考虑到你使用它时外围附件的成本。在美国,树莓派的成本区间是从 5 美元(树莓派 Zero)到 35 美元(树莓派 3 B 和 3 B+)。但是,如果你选择 `Zero`,那么你或许还需要一个 `USB hub` 去连接你的鼠标、键盘、无线网卡、以及某种显示适配器。不论你想使用树莓派做什么,除非你已经有了(假如不是全部)大部分的外设,那么你一定要把这些外设考虑到预算之中。此外,在一些国家,对于许多学生和老师,树莓派(即便没有任何外设)的购置成本也或许是一个不少的成本负担。 + + * **可获得性:** 根据你所在地去查找你想要的树莓派,因为在一些国家得到某些版本的树莓派可能很容易(或很困难)。在新型号刚发布后,可获得性可能是个很大的问题,在你的市场上获得最新版本的树莓派可能需要几天或几周的时间。 + + * **用途:** 所在地和成本可能并不会影响每个人,但每个购买者必须要考虑的是买树莓派做什么。因内存、CPU 核心、CPU 速度、物理尺寸、网络连接、外设扩展等不同衍生出八个不同的型号。比如,如果你需要一个拥有更大的“马力”时鲁棒性更好的解决方案,那么你或许应该选择树莓派 3 B+,它有更大的内存、最快的 CPU、以及更多的核心数。如果你的解决方案并不需要网络连接,并不用于 CPU 密集型的工作,并且需要将它隐藏在一个非常小的空间中,那么一个树莓派 Zero 将是你的最佳选择。 + +[维基百科的树莓派规格表][2] 是比较八种树莓派型号的好办法。 + +现在,你已经知道了如何找到适合你的树莓派了,下一篇文章中,我将介绍如何购买它。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/which-raspberry-pi-choose + +作者:[Anderson Silva][a] +选题:[lujun9972][b] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ansilva +[b]: https://github.com/lujun9972 +[1]: https://www.raspberrypi.org/ +[2]: https://en.wikipedia.org/wiki/Raspberry_Pi#Specifications diff --git a/translated/tech/20190302 How to buy a Raspberry Pi.md b/translated/tech/20190302 How to buy a Raspberry Pi.md new file mode 100644 index 0000000000..e1c3583f52 --- /dev/null +++ b/translated/tech/20190302 How to buy a Raspberry Pi.md @@ -0,0 +1,51 @@ +[#]: collector: "lujun9972" +[#]: translator: "qhwdw" +[#]: reviewer: " " +[#]: publisher: " " +[#]: url: " " +[#]: subject: "How to buy a Raspberry Pi" +[#]: via: "https://opensource.com/article/19/3/how-buy-raspberry-pi" +[#]: author: "Anderson Silva https://opensource.com/users/ansilva" + +如何购买一个树莓派 +====== +在我们的《树莓派入门指南》系列文章的第二篇中,我们将介绍获取树莓派的最佳途径。 + +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/open_business_sign_store.jpg?itok=g4QibRqg) + +在本系列指南的第一篇文章中,我们提供了一个关于 [你应该购买哪个版本的树莓派][1] 的一些建议。哪个版本才是你想要的,你应该有了主意了,现在,我们来看一下如何获得它。 + +最显而易见的方式— 并且也或许是最安全最简单的方式 —非[树莓派的官方网站][2] 莫属了。如果你从官网主页上点击“Buy a Raspberry Pi”,它将跳转到官方的 [在线商店][3],在那里,它可以给你提供你的国家所在地的授权销售商。如果你的国家没有在清单中,还有一个“其它”选项,它可以提供国际订购。 + +第二,查看亚马逊或在你的国家里允许销售新的或二手商品的其它主流技术类零售商。鉴于树莓派比较便宜并且尺寸很小,一些小商家基于转售目的的进出口它,应该是非常容易的。在你下订单时,一定要关注对卖家的评价。 + +第三,打听你的极客朋友!你可能从没想过一些人的树莓派正在“吃灰”。我已经给家人送了至少三个树莓派,当然它们并不是计划要送的礼物,只是因为他们对这个“迷你计算机”感到很好奇而已。我身边有好多个,因此我让他们拿走一个! + +### 不要忘了外设 + +最后一个建设是:不要忘了外设,你将需要一些外设去配置和操作你的树莓派。至少你会用到键盘、一个 HDMI 线缆去连接显示器、一个 Micro SD 卡去安装操作系统,一个供电线、以及一个好用的鼠标。 + +![](https://opensource.com/sites/default/files/uploads/raspberrypi_2a_pi0w-kit.jpg) + +如果你没有准备好这些东西,试着从朋友那儿借用,或与树莓派一起购买。你可以从授权的树莓派销售商那儿考虑订购一个起步套装 — 它可以让你避免查找的麻烦而一次性搞定。 + +![](https://opensource.com/sites/default/files/uploads/raspberrypi_2b_pi3b.jpg) + +现在,你有了树莓派,在本系列的下一篇文章中,我们将安装树莓派的操作系统并开始使用它。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/how-buy-raspberry-pi + +作者:[Anderson Silva][a] +选题:[lujun9972][b] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ansilva +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/article/19/2/which-raspberry-pi-should-you-get +[2]: https://www.raspberrypi.org/ +[3]: https://www.raspberrypi.org/products/ diff --git a/translated/tech/20190304 Learn Linux with the Raspberry Pi.md b/translated/tech/20190304 Learn Linux with the Raspberry Pi.md new file mode 100644 index 0000000000..5946082838 --- /dev/null +++ b/translated/tech/20190304 Learn Linux with the Raspberry Pi.md @@ -0,0 +1,53 @@ +[#]: collector: (lujun9972) +[#]: translator: (qhwdw) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (Learn Linux with the Raspberry Pi) +[#]: via: (https://opensource.com/article/19/3/learn-linux-raspberry-pi) +[#]: author: (Andersn Silva https://opensource.com/users/ansilva) + +用树莓派学 Linux +====== +我们的《树莓派使用入门》的第四篇文章将进入到 Linux 命令行。 +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg) + +在本系列的 [第三篇文章][1] 中开始了我们的树莓派探索之旅,我分享了如何安装 `Raspbian`,它是树莓派的官方 Linux 版本。现在,你已经安装好了 `Raspbian` 并用它引导你的新树莓派,你已经具备学习 Linux 相关知识的条件了。 + +在这样简短的文章中去解决像“如何使用 Linux” 这样的宏大主题显然是不切实际的,因此,我只是给你提供一些如何使用树莓派来学习更多的 Linux 知识的一些创意而已。 + +我们花一些时间从命令行(又称“终端”)开始。自上世纪九十年代中期以来,Linux 的 [窗口管理器][2] 和图形界面已经得到长足的发展。如今,你可以在 Linux 上通过鼠标点击来做一些事情了,就如同其它的操作系统一样容易。在我看来,只是“使用 Linux”和成为“一个 Linux 用户”是有区别的,后者至少能够在终端中“遨游“。 + +![](https://opensource.com/sites/default/files/uploads/man-terminal.png) + +如果你想成为一个 Linux 用户,从终端中尝试以下的命令行开始: + + * 使用像 **ls**、**cd**、和 **pwd** 这样的命令导航到你的 Home 目录。 + * 使用 **mkdir**、**rm**、**mv**、和 **cp** 命令创建、删除、和重命名目录。 + * 使用命令行编辑器(如 Vi、Vim、Emacs 或 Nano)去创建一个文本文件。 + * 尝试一些其它命令,比如 **chmod**、**chown**、**w**、**cat**、**more**、**less**、**tail**、**free**、**df**、**ps**、**uname**、和 **kill**。 + * 尝试一下 **/bin** 和 **/usr/bin** 目录中的其它命令。 + + + +学习命令行的最佳方式还是阅读它的 “man 手册”(简称手册);在命令行中输入 **man ** 就可以像上面那样打开它。并且在互联网上搜索 Linux 命令速查表可以让你更清楚地了解命令的用法 — 你应该会找到一大堆能帮你学习的资料。 + +Raspbian 就像主流的 Linux 发行版一样有非常多的命令,假以时日,你最终将比其他人会用更多的命令。我使用 Linux 命令行已经超过二十年了,即便这样仍然有些一些命令我从来没有使用过,即便是那些我使用的过程中一直就存在的命令。 + +最后,你可以使用图形环境去更快地工作,但是只有深入到 Linux 命令行,你才能够获得操作系统真正的强大功能和知识。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/learn-linux-raspberry-pi + +作者:[Andersn Silva][a] +选题:[lujun9972][b] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ansilva +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/article/19/2/how-boot-new-raspberry-pi +[2]: https://opensource.com/article/18/8/window-manager diff --git a/translated/tech/20190305 5 ways to teach kids to program with Raspberry Pi.md b/translated/tech/20190305 5 ways to teach kids to program with Raspberry Pi.md new file mode 100644 index 0000000000..2886c4bf69 --- /dev/null +++ b/translated/tech/20190305 5 ways to teach kids to program with Raspberry Pi.md @@ -0,0 +1,65 @@ +[#]: collector: (lujun9972) +[#]: translator: (qhwdw) +[#]: reviewer: ( ) +[#]: publisher: ( ) +[#]: url: ( ) +[#]: subject: (5 ways to teach kids to program with Raspberry Pi) +[#]: via: (https://opensource.com/article/19/3/teach-kids-program-raspberry-pi) +[#]: author: (Anderson Silva https://opensource.com/users/ansilva) + +教孩子们使用树莓派学编程的 5 种方法。 +====== +这是我们的《树莓派入门指南》系列的第五篇文章,它探索了帮助孩子们学习编程的一些资源。 +![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/rh_003588_01_rd3os.combacktoschoolseriesgen_rh_032x_0.png?itok=cApG9aB4) + +无数的学校、图书馆和家庭已经证明,树莓派是让孩子们接触编程的最好方式。在本系列的前四篇文章中,你已经学习了如何去[购买][1]、[安装][2]、和[配置][3]一个树莓派。在第五篇文章中,我们将分享一些帮助孩子们使用树莓派编程的入门级资源。 + +### Scratch + +[Scratch][4] 是让孩子们了解编程基本概念(比如变量、布尔逻辑、循环等等)的一个很好的方式。你在 Raspbian 中就可以找到它,并且在互联网上你可以找到非常多的有关 Scratch 的文章和教程,包括在 `Opensource.com` 上的 [今天的 Scratch 是不是像“上世纪八十年代教孩子学LOGO编程”?][5]。 + +![](https://opensource.com/sites/default/files/uploads/scratch2.png) + +### Code.org + +[Code.org][6] 是另一个非常好的教孩子学编程的在线资源。这个组织的使命是让更多的人通过课程、教程和流行的一小时学编程来接触编程。许多学校 — 包括我五年级的儿子就读的学校 — 都使用它,让更多的孩子学习编程和计算机科学的概念。 + +### 阅读 + +读书是学习编程的另一个很好的方式。学习如何编程并不需要你会说英语,当然,如果你会英语的话,学习起来将更容易,因为大多数的编程语言都是使用英文关键字去描述命令的。如果你的英语很好,能够轻松地阅读接下来的这个树莓派系列文章,那么你就完全有能力去阅读有关编程的书籍、论坛和其它的出版物。我推荐一本由 `Jason Biggs` 写的书: [儿童学 Python:非常有趣的 Python 编程入门][7]。 + +### Raspberry Jam + +另一个让你的孩子进入编程世界的好方法是在聚会中让他与其他人互动。树莓派基金会赞助了一个称为 [Raspberry Jams][8] 的活动,让世界各地的孩子和成人共同参与在树莓派上学习。如果你所在的地区没有 `Raspberry Jam`,基金会有一个[指南][9]和其它资源帮你启动一个 `Raspberry Jam`。 + +### 游戏 + +最后一个(是本文的最后一个,当然还有其它的方式),[Minecraft][10] 有一个树莓派版本。我的世界Minecraft已经从一个多玩家的、类似于”数字乐高“这样的游戏,成长为一个任何人都能使用 Pythonb 和其它编程语言去构建我自己的虚拟世界。更多内容查看 [Minecraft Pi 入门][11] 和 [Minecraft 一小时入门教程][12]。 + +你还有教孩子用树莓派学编程的珍藏资源吗?请在下面的评论区共享出来吧。 + +-------------------------------------------------------------------------------- + +via: https://opensource.com/article/19/3/teach-kids-program-raspberry-pi + +作者:[Anderson Silva][a] +选题:[lujun9972][b] +译者:[qhwdw](https://github.com/qhwdw) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]: https://opensource.com/users/ansilva +[b]: https://github.com/lujun9972 +[1]: https://opensource.com/article/19/2/how-buy-raspberry-pi +[2]: https://opensource.com/article/19/2/how-boot-new-raspberry-pi +[3]: https://opensource.com/article/19/3/learn-linux-raspberry-pi +[4]: https://scratch.mit.edu/ +[5]: https://opensource.com/article/17/3/logo-scratch-teach-programming-kids +[6]: https://code.org/ +[7]: https://www.amazon.com/Python-Kids-Playful-Introduction-Programming/dp/1593274076 +[8]: https://www.raspberrypi.org/jam/#map-section +[9]: https://static.raspberrypi.org/files/jam/Raspberry-Jam-Guidebook-2017-04-26.pdf +[10]: https://minecraft.net/en-us/edition/pi/ +[11]: https://projects.raspberrypi.org/en/projects/getting-started-with-minecraft-pi +[12]: https://code.org/minecraft