mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-19 22:51:41 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
b376738723
@ -1,46 +1,43 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (jdh8383)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: reviewer: (wxy)
|
||||
[#]: publisher: (wxy)
|
||||
[#]: url: (https://linux.cn/article-11552-1.html)
|
||||
[#]: subject: (How to program with Bash: Syntax and tools)
|
||||
[#]: via: (https://opensource.com/article/19/10/programming-bash-part-1)
|
||||
[#]: author: (David Both https://opensource.com/users/dboth)
|
||||
|
||||
怎样用 Bash 编程:语法和工具
|
||||
======
|
||||
让我们通过本系列文章来学习基本的 Bash 编程语法和工具,以及如何使用变量和控制运算符,这是三篇中的第一篇。
|
||||
![bash logo on green background][1]
|
||||
|
||||
Shell 是操作系统的命令解释器,其中 Bash 是我最喜欢的。每当用户或者系统管理员将命令输入系统的时候,Linux 的 shell 解释器就会把这些命令转换成操作系统可以理解的形式。而执行结果返回 shell 程序后,它会将结果输出到 STDOUT(标准输出),默认情况下,这些结果会[显示在你的终端][2]。所有我熟悉的 shell 同时也是门编程语言。
|
||||
> 让我们通过本系列文章来学习基本的 Bash 编程语法和工具,以及如何使用变量和控制运算符,这是三篇中的第一篇。
|
||||
|
||||
Bash 是个功能强大的 shell,包含众多便捷特性,比如:tab 补全、命令回溯和再编辑、aliases 别名等。它的命令行默认编辑模式是 Emacs,但是我最喜欢的Bash特性之一是我可以将其更改为 Vi 模式,以使用那些储存在我肌肉记忆中的的编辑命令。
|
||||
![](https://img.linux.net.cn/data/attachment/album/201911/08/092559r5wdg0w97dtf350j.jpg)
|
||||
|
||||
Shell 是操作系统的命令解释器,其中 Bash 是我最喜欢的。每当用户或者系统管理员将命令输入系统的时候,Linux 的 shell 解释器就会把这些命令转换成操作系统可以理解的形式。而执行结果返回 shell 程序后,它会将结果输出到 STDOUT(标准输出),默认情况下,这些结果会[显示在你的终端][2]。所有我熟悉的 shell 同时也是一门编程语言。
|
||||
|
||||
Bash 是个功能强大的 shell,包含众多便捷特性,比如:tab 补全、命令回溯和再编辑、别名等。它的命令行默认编辑模式是 Emacs,但是我最喜欢的 Bash 特性之一是我可以将其更改为 Vi 模式,以使用那些储存在我肌肉记忆中的的编辑命令。
|
||||
|
||||
然而,如果你把 Bash 当作单纯的 shell 来用,则无法体验它的真实能力。我在设计一套包含三卷的 [Linux 自学课程][3]时(这个系列的文章正是基于此课程),了解到许多 Bash 的知识,这些是我在过去 20 年的 Linux 工作经验中所没有掌握的,其中的一些知识就是关于 Bash 的编程用法。不得不说,Bash 是一门强大的编程语言,是一个能够同时用于命令行和 shell 脚本的完美设计。
|
||||
|
||||
本系列文章将要探讨如何使用 Bash 作为命令行界面(CLI)编程语言。第一篇文章简单介绍 Bash 命令行编程、变量以及控制运算符。其他文章会讨论诸如:Bash 文件的类型;字符串、数字和一些逻辑运算符,它们能够提供代码执行流程中的逻辑控制;不同类型的 shell 扩展;通过 **for**、**while** 和 **until** 来控制循环操作。
|
||||
本系列文章将要探讨如何使用 Bash 作为命令行界面(CLI)编程语言。第一篇文章简单介绍 Bash 命令行编程、变量以及控制运算符。其他文章会讨论诸如:Bash 文件的类型;字符串、数字和一些逻辑运算符,它们能够提供代码执行流程中的逻辑控制;不同类型的 shell 扩展;通过 `for`、`while` 和 `until` 来控制循环操作。
|
||||
|
||||
### Shell
|
||||
|
||||
Shell 是操作系统的命令解释器,其中 Bash 是我最喜欢的。每当用户或者系统管理员将命令输入系统的时候,Linux 的 shell 解释器就会把这些命令转换成操作系统可以理解的形式。而执行结果返回 shell 程序后,它会将结果输出到终端。所有我熟悉的 shell 同时也是门编程语言。
|
||||
|
||||
Bash 是 Bourne Again Shell 的缩写,因为 Bash shell 是 [基于][4] 更早的 Bourne shell,后者是 Steven Bourne 在 1977 年开发的。另外还有很多[其他的 shell][5] 可以使用,但下面四个是我经常见到的:
|
||||
|
||||
* **csh:** C shell 适合那些习惯了 C 语言语法的开发者。
|
||||
* **ksh:** Korn shell,由 David Korn 开发,在 Unix 用户中更流行。
|
||||
* **tcsh:** 一个 csh 的变种,增加了一些易用性。
|
||||
* **zsh:** Z shell,集成了许多其他流行 shell 的特性。
|
||||
|
||||
|
||||
* `csh`:C shell 适合那些习惯了 C 语言语法的开发者。
|
||||
* `ksh`:Korn shell,由 David Korn 开发,在 Unix 用户中更流行。
|
||||
* `tcsh`:一个 csh 的变种,增加了一些易用性。
|
||||
* `zsh`:Z shell,集成了许多其他流行 shell 的特性。
|
||||
|
||||
所有 shell 都有内置命令,用以补充或替代核心工具集。打开 shell 的 man 说明页,找到“BUILT-INS”那一段,可以查看都有哪些内置命令。
|
||||
|
||||
|
||||
每种 shell 都有它自己的特性和语法风格。我用过 csh、ksh 和 zsh,但我还是更喜欢 Bash。你可以多试几个,寻找更适合你的 shell,尽管这可能需要花些功夫。但幸运的是,切换不同 shell 很简单。
|
||||
|
||||
所有这些 shell 既是编程语言又是命令解释器。下面我们来快速浏览一下 Bash 中集成的编程结构和工具。
|
||||
|
||||
### 做为编程语言的 Bash
|
||||
### 作为编程语言的 Bash
|
||||
|
||||
大多数场景下,系统管理员都会使用 Bash 来发送简单明了的命令。但 Bash 不仅可以输入单条命令,很多系统管理员可以编写简单的命令行程序来执行一系列任务,这些程序可以作为通用工具,能节省时间和精力。
|
||||
|
||||
@ -54,18 +51,16 @@ Bash 是 Bourne Again Shell 的缩写,因为 Bash shell 是 [基于][4] 更早
|
||||
|
||||
本系列用 Bash 举例(因为它无处不在),假如你使用一个不同的 shell 也没关系,尽管结构和语法有所不同,但编程思想是相通的。有些 shell 支持某种特性而其他 shell 则不支持,但它们都提供编程功能。Shell 程序可以被存在一个文件中被反复使用,或者在需要的时候才创建它们。
|
||||
|
||||
|
||||
### 简单 CLI 程序
|
||||
|
||||
最简单的命令行程序只有一或两条语句,它们可能相关,也可能无关,在按**回车**键之前被输入到命令行。程序中的第二条语句(如果有的话)可能取决于第一条语句的操作,但也不是必须的。
|
||||
最简单的命令行程序只有一或两条语句,它们可能相关,也可能无关,在按回车键之前被输入到命令行。程序中的第二条语句(如果有的话)可能取决于第一条语句的操作,但也不是必须的。
|
||||
|
||||
这里需要特别讲解一个标点符号。当你在命令行输入一条命令,按下**回车**键的时候,其实在命令的末尾有一个隐含的分号(**;**)。当一段 CLI shell 程序在命令行中被串起来作为单行指令使用时,必须使用分号来终结每个语句并将其与下一条语句分开。但 CLI shell 程序中的最后一条语句可以使用显式或隐式的分号。
|
||||
这里需要特别讲解一个标点符号。当你在命令行输入一条命令,按下回车键的时候,其实在命令的末尾有一个隐含的分号(`;`)。当一段 CLI shell 程序在命令行中被串起来作为单行指令使用时,必须使用分号来终结每个语句并将其与下一条语句分开。但 CLI shell 程序中的最后一条语句可以使用显式或隐式的分号。
|
||||
|
||||
### 一些基本语法
|
||||
|
||||
下面的例子会阐明这一语法规则。这段程序由单条命令组成,还有一个显式的终止符:
|
||||
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ echo "Hello world." ;
|
||||
Hello world.
|
||||
@ -73,8 +68,7 @@ Hello world.
|
||||
|
||||
看起来不像一个程序,但它确是我学习每个新编程语言时写下的第一个程序。不同语言可能语法不同,但输出结果是一样的。
|
||||
|
||||
让我们扩展一下这段微不足道却又无所不在的代码。你的结果可能与我的有所不同,因为我的家目录有点乱,而你可能是在 GUI 桌面中第一次登陆账号。
|
||||
|
||||
让我们扩展一下这段微不足道却又无所不在的代码。你的结果可能与我的有所不同,因为我的家目录有点乱,而你可能是在 GUI 桌面中第一次登录账号。
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ echo "My home directory." ; ls ;
|
||||
@ -87,9 +81,8 @@ TestFile1.dos dmesg1.txt Documents Music random.txt testdir1
|
||||
|
||||
现在是不是更明显了。结果是相关的,但是两条语句彼此独立。你可能注意到我喜欢在分号前后多输入一个空格,这样会让代码的可读性更好。让我们再运行一遍这段程序,这次不要带结尾的分号:
|
||||
|
||||
|
||||
```
|
||||
`[student@studentvm1 ~]$ echo "My home directory." ; ls`
|
||||
[student@studentvm1 ~]$ echo "My home directory." ; ls
|
||||
```
|
||||
|
||||
输出结果没有区别。
|
||||
@ -98,14 +91,13 @@ TestFile1.dos dmesg1.txt Documents Music random.txt testdir1
|
||||
|
||||
像所有其他编程语言一样,Bash 支持变量。变量是个象征性的名字,它指向内存中的某个位置,那里存着对应的值。变量的值是可以改变的,所以它叫“变~量”。
|
||||
|
||||
Bash 不像 C 之类的语言,需要强制指定变量类型,比如:整型、浮点型或字符型。在 Bash 中,所有变量都是字符串。整数型的变量可以被用于整数运算,这是 Bash 唯一能够处理的数学类型。更复杂的运算则需要借助 [**bc**][9] 这样的命令,可以被用在命令行编程或者脚本中。
|
||||
Bash 不像 C 之类的语言,需要强制指定变量类型,比如:整型、浮点型或字符型。在 Bash 中,所有变量都是字符串。整数型的变量可以被用于整数运算,这是 Bash 唯一能够处理的数学类型。更复杂的运算则需要借助 [bc][9] 这样的命令,可以被用在命令行编程或者脚本中。
|
||||
|
||||
变量的值是被预先分配好的,这些值可以用在命令行编程或者脚本中。可以通过变量名字给其赋值,但是不能使用 **$** 符开头。比如,**VAR=10** 这样会把 VAR 的值设为 10。要打印变量的值,你可以使用语句 **echo $VAR**。变量名必须以文本(即非数字)开始。
|
||||
变量的值是被预先分配好的,这些值可以用在命令行编程或者脚本中。可以通过变量名字给其赋值,但是不能使用 `$` 符开头。比如,`VAR=10` 这样会把 `VAR` 的值设为 `10`。要打印变量的值,你可以使用语句 `echo $VAR`。变量名必须以文本(即非数字)开始。
|
||||
|
||||
Bash 会保存已经定义好的变量,直到它们被取消掉。
|
||||
|
||||
下面这个例子,在变量被赋值前,它的值是空(null)。然后给它赋值并打印出来,检验一下。你可以在同一行 CLI 程序里完成它:
|
||||
|
||||
下面这个例子,在变量被赋值前,它的值是空(`null`)。然后给它赋值并打印出来,检验一下。你可以在同一行 CLI 程序里完成它:
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ echo $MyVar ; MyVar="Hello World" ; echo $MyVar ;
|
||||
@ -114,15 +106,14 @@ Hello World
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
_注意:变量赋值的语法非常严格,等号(**=**)两边不能有空格。_
|
||||
*注意:变量赋值的语法非常严格,等号(`=`)两边不能有空格。*
|
||||
|
||||
那个空行表明了 **MyVar** 的初始值为空。变量的赋值和改值方法都一样,这个例子展示了原始值和新的值。
|
||||
那个空行表明了 `MyVar` 的初始值为空。变量的赋值和改值方法都一样,这个例子展示了原始值和新的值。
|
||||
|
||||
正如之前说的,Bash 支持整数运算,当你想计算一个数组中的某个元素的位置,或者做些简单的算术运算,这还是挺有帮助的。然而,这种方法并不适合科学计算,或是某些需要小数运算的场景,比如财务统计。这些场景有其它更好的工具可以应对。
|
||||
|
||||
下面是个简单的算术题:
|
||||
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ Var1="7" ; Var2="9" ; echo "Result = $((Var1*Var2))"
|
||||
Result = 63
|
||||
@ -130,7 +121,6 @@ Result = 63
|
||||
|
||||
好像没啥问题,但如果运算结果是浮点数会发生什么呢?
|
||||
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ Var1="7" ; Var2="9" ; echo "Result = $((Var1/Var2))"
|
||||
Result = 0
|
||||
@ -139,48 +129,42 @@ Result = 1
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
结果会被取整。请注意运算被包含在 **echo** 语句之中,其实计算在 echo 命令结束前就已经完成了,原因是 Bash 的内部优先级。想要了解详情的话,可以在 Bash 的 man 页面中搜索 "precedence"。
|
||||
结果会被取整。请注意运算被包含在 `echo` 语句之中,其实计算在 echo 命令结束前就已经完成了,原因是 Bash 的内部优先级。想要了解详情的话,可以在 Bash 的 man 页面中搜索 “precedence”。
|
||||
|
||||
### 控制运算符
|
||||
|
||||
Shell 的控制运算符是一种语法运算符,可以轻松地创建一些有趣的命令行程序。在命令行上按顺序将几个命令串在一起,就变成了最简单的 CLI 程序:
|
||||
|
||||
|
||||
```
|
||||
`command1 ; command2 ; command3 ; command4 ; . . . ; etc. ;`
|
||||
command1 ; command2 ; command3 ; command4 ; . . . ; etc. ;
|
||||
```
|
||||
|
||||
只要不出错,这些命令都能顺利执行。但假如出错了怎么办?你可以预设好应对出错的办法,这就要用到 Bash 内置的控制运算符, **&&** 和 **||**。这两种运算符提供了流程控制功能,使你能改变代码执行的顺序。分号也可以被看做是一种 Bash 运算符,预示着新一行的开始。
|
||||
|
||||
|
||||
**&&** 运算符提供了如下简单逻辑,“如果 command1 执行成功,那么接着执行 command2。如果 command1 失败,就跳过 command2。”语法如下:
|
||||
只要不出错,这些命令都能顺利执行。但假如出错了怎么办?你可以预设好应对出错的办法,这就要用到 Bash 内置的控制运算符, `&&` 和 `||`。这两种运算符提供了流程控制功能,使你能改变代码执行的顺序。分号也可以被看做是一种 Bash 运算符,预示着新一行的开始。
|
||||
|
||||
`&&` 运算符提供了如下简单逻辑,“如果 command1 执行成功,那么接着执行 command2。如果 command1 失败,就跳过 command2。”语法如下:
|
||||
|
||||
```
|
||||
`command1 && command2`
|
||||
command1 && command2
|
||||
```
|
||||
|
||||
现在,让我们用命令来创建一个新的目录,如果成功的话,就把它切换为当前目录。确保你的家目录(**~**)是当前目录,先尝试在 **/root** 目录下创建,你应该没有权限:
|
||||
|
||||
现在,让我们用命令来创建一个新的目录,如果成功的话,就把它切换为当前目录。确保你的家目录(`~`)是当前目录,先尝试在 `/root` 目录下创建,你应该没有权限:
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ Dir=/root/testdir ; mkdir $Dir/ &&; cd $Dir
|
||||
[student@studentvm1 ~]$ Dir=/root/testdir ; mkdir $Dir/ && cd $Dir
|
||||
mkdir: cannot create directory '/root/testdir/': Permission denied
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
上面的报错信息是由 **mkdir** 命令抛出的,因为创建目录失败了。**&&** 运算符收到了非零的返回码,所以 **cd** 命令就被跳过,前者阻止后者继续运行,因为创建目录失败了。这种控制流程可以阻止后面的错误累积,避免引发更严重的问题。是时候讲点更复杂的逻辑了。
|
||||
|
||||
当一段程序的返回码大于零时,使用 **||** 运算符可以让你在后面接着执行另一段程序。简单语法如下:
|
||||
上面的报错信息是由 `mkdir` 命令抛出的,因为创建目录失败了。`&&` 运算符收到了非零的返回码,所以 `cd` 命令就被跳过,前者阻止后者继续运行,因为创建目录失败了。这种控制流程可以阻止后面的错误累积,避免引发更严重的问题。是时候讲点更复杂的逻辑了。
|
||||
|
||||
当一段程序的返回码大于零时,使用 `||` 运算符可以让你在后面接着执行另一段程序。简单语法如下:
|
||||
|
||||
```
|
||||
`command1 || command2`
|
||||
command1 || command2
|
||||
```
|
||||
|
||||
解读一下,“假如 command1 失败,执行 command2”。隐藏的逻辑是,如果 command1 成功,跳过 command2。下面实践一下,仍然是创建新目录:
|
||||
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ Dir=/root/testdir ; mkdir $Dir || echo "$Dir was not created."
|
||||
mkdir: cannot create directory '/root/testdir': Permission denied
|
||||
@ -190,16 +174,14 @@ mkdir: cannot create directory '/root/testdir': Permission denied
|
||||
|
||||
正如预期,因为目录无法创建,第一条命令失败了,于是第二条命令被执行。
|
||||
|
||||
把 **&&** 和 **||** 两种运算符结合起来才能发挥它们的最大功效。请看下面例子中的流程控制方法:
|
||||
|
||||
把 `&&` 和 `||` 两种运算符结合起来才能发挥它们的最大功效。请看下面例子中的流程控制方法:
|
||||
|
||||
```
|
||||
`preceding commands ; command1 && command2 || command3 ; following commands`
|
||||
前置 commands ; command1 && command2 || command3 ; 跟随 commands
|
||||
```
|
||||
|
||||
语法解释:“假如 command1 退出时返回码为零,就执行 command2,否则执行 command3。”用具体代码试试:
|
||||
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ Dir=/root/testdir ; mkdir $Dir && cd $Dir || echo "$Dir was not created."
|
||||
mkdir: cannot create directory '/root/testdir': Permission denied
|
||||
@ -207,18 +189,16 @@ mkdir: cannot create directory '/root/testdir': Permission denied
|
||||
[student@studentvm1 ~]$
|
||||
```
|
||||
|
||||
现在我们再试一次,用你的家目录替换 **/root** 目录,你将会有权限创建这个目录了:
|
||||
|
||||
现在我们再试一次,用你的家目录替换 `/root` 目录,你将会有权限创建这个目录了:
|
||||
|
||||
```
|
||||
[student@studentvm1 ~]$ Dir=~/testdir ; mkdir $Dir && cd $Dir || echo "$Dir was not created."
|
||||
[student@studentvm1 testdir]$
|
||||
```
|
||||
|
||||
像 **command1 && command2** 这样的控制语句能够运行的原因是,每条命令执行完毕时都会给 shell 发送一个返回码,用来表示它执行成功与否。默认情况下,返回码为 0 表示成功,其他任何正值表示失败。一些系统管理员使用的工具用值为 1 的返回码来表示失败,但其他很多程序使用别的数字来表示失败。
|
||||
|
||||
Bash 的内置变量 **$?** 可以显示上一条命令的返回码,可以在脚本或者命令行中非常方便地检查它。要查看返回码,让我们从运行一条简单的命令开始,返回码的结果总是上一条命令给出的。
|
||||
像 `command1 && command2` 这样的控制语句能够运行的原因是,每条命令执行完毕时都会给 shell 发送一个返回码,用来表示它执行成功与否。默认情况下,返回码为 `0` 表示成功,其他任何正值表示失败。一些系统管理员使用的工具用值为 `1` 的返回码来表示失败,但其他很多程序使用别的数字来表示失败。
|
||||
|
||||
Bash 的内置变量 `$?` 可以显示上一条命令的返回码,可以在脚本或者命令行中非常方便地检查它。要查看返回码,让我们从运行一条简单的命令开始,返回码的结果总是上一条命令给出的。
|
||||
|
||||
```
|
||||
[student@studentvm1 testdir]$ ll ; echo "RC = $?"
|
||||
@ -234,7 +214,6 @@ RC = 0
|
||||
|
||||
在这个例子中,返回码为零,意味着命令执行成功了。现在对 root 的家目录测试一下,你应该没有权限:
|
||||
|
||||
|
||||
```
|
||||
[student@studentvm1 testdir]$ ll /root ; echo "RC = $?"
|
||||
ls: cannot open directory '/root': Permission denied
|
||||
@ -242,7 +221,7 @@ RC = 2
|
||||
[student@studentvm1 testdir]$
|
||||
```
|
||||
|
||||
本例中返回码是 2,表明非 root 用户没有权限进入这个目录。你可以利用这些返回码,用控制运算符来改变程序执行的顺序。
|
||||
本例中返回码是 `2`,表明非 root 用户没有权限进入这个目录。你可以利用这些返回码,用控制运算符来改变程序执行的顺序。
|
||||
|
||||
### 总结
|
||||
|
||||
@ -255,7 +234,7 @@ via: https://opensource.com/article/19/10/programming-bash-part-1
|
||||
作者:[David Both][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[jdh8383](https://github.com/jdh8383)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,99 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week)
|
||||
[#]: via: (https://itsfoss.com/pinephone/)
|
||||
[#]: author: (Ankush Das https://itsfoss.com/author/ankush/)
|
||||
|
||||
Budget-friendly Linux Smartphone PinePhone Will be Available to Pre-order Next Week
|
||||
======
|
||||
|
||||
Do you remember when [It’s FOSS first broke the story that Pine64 was working on a Linux-based smartphone][1] running KDE Plasma (among other distributions) in 2017? It’s been some time since then but the good news is that PinePhone will be available for pre-order from 15th November.
|
||||
|
||||
Let me provide you more details on the PinePhone like its specification, pricing and release date.
|
||||
|
||||
### PinePhone: Linux-based budget smartphone
|
||||
|
||||
The PinePhone developer kit is already being tested by some devs and more such kits will be shipped by 15th November. You can check out some of these images by clicking the photo gallery below:
|
||||
|
||||
The developer kit is a combo kit of PINE A64 baseboard + SOPine module + 7″ Touch Screen Display + Camera + Wifi/BT + Playbox enclosure + Lithium-Ion battery case + LTE cat 4 USB dongle.
|
||||
|
||||
These combo kits allow developers to jump start PinePhone development. The PINE A64 platform already has mainline Linux OS build thanks to the PINE64 community and the support by [KDE neon][2].
|
||||
|
||||
#### Specifications of PinePhone
|
||||
|
||||
![PinePhone Prototype | Image by Martjin Braam][3]
|
||||
|
||||
* Allwinner A64 Quad Core SoC with Mali 400 MP2 GPU
|
||||
* 2GB of LPDDR3 RAM
|
||||
* 5.95″ LCD 1440×720, 18:9 aspect ratio (hardened glass)
|
||||
* Bootable Micro SD
|
||||
* 16GB eMMC
|
||||
* HD Digital Video Out
|
||||
* USB Type C (Power, Data and Video Out)
|
||||
* Quectel EG-25G with worldwide bands
|
||||
* WiFi: 802.11 b/g/n, single-band, hotspot capable
|
||||
* Bluetooth: 4.0, A2DP
|
||||
* GNSS: GPS, GPS-A, GLONASS
|
||||
* Vibrator
|
||||
* RGB status LED
|
||||
* Selfie and Main camera (2/5Mpx respectively)
|
||||
* Main Camera: Single OV6540, 5MP, 1/4″, LED Flash
|
||||
* Selfie Camera: Single GC2035, 2MP, f/2.8, 1/5″
|
||||
* Sensors: accelerator, gyro, proximity, compass, barometer, ambient light
|
||||
* 3 External Switches: up down and power
|
||||
* HW switches: LTE/GNSS, WiFi, Microphone, Speaker, USB
|
||||
* Samsung J7 form-factor 3000mAh battery
|
||||
* Case is matte black finished plastic
|
||||
* Headphone Jack
|
||||
|
||||
|
||||
|
||||
#### Production, Price & Availability
|
||||
|
||||
![Pinephone Brave Heart Pre Order][4]
|
||||
|
||||
PinePhone will cost about $150. The early adapter release has been named ‘Brave Heart’ edition and it will go on sale from November 15, 2019. As you can see in the image above, [Pine64’s homepage][5] has included a timer for the first pre-order batch of PinePhone.
|
||||
|
||||
You should expect the early adopter ‘Brave Heart’ editions to be shipped and delivered by December 2019 or January 2020.
|
||||
|
||||
Mass production will begin only after the Chinese New Year, hinting at early Q2 of 2020 or March 2020 (at the earliest).
|
||||
|
||||
The phone hasn’t yet been listed on Pine Store – so make sure to check out [Pine64 online store][6] to pre-order the ‘Brave Heart’ edition if you want to be one of the early adopters.
|
||||
|
||||
#### What do you think of PinePhone?
|
||||
|
||||
Pine64 has already created a budget laptop called [Pinebook][7] and a relatively powerful [Pinebook Pro][8] laptop. So, there is definitely hope for PinePhone to succeed, at least in the niche of DIY enthusiasts and hardcore Linux fans. The low pricing is definitely a huge plus here compared to the other [Linux smartphone Librem5][9] that costs over $600.
|
||||
|
||||
Another good thing about PinePhone is that you can experiment with the operating system by installing Ubuntu Touch, Plasma Mobile or Aurora OS/Sailfish OS.
|
||||
|
||||
These Linux-based smartphones don’t have the features to replace Android or iOS, yet. If you are looking for a fully functional smartphone to replace your Android smartphone, PinePhone is certainly not for you. It’s more for people who like to experiment and are not afraid to troubleshoot.
|
||||
|
||||
If you are looking to buy PinePhone, mark the date and set a reminder. There will be limited supply and what I have seen so far, Pine devices go out of stock pretty soon.
|
||||
|
||||
_Are you going to pre-order a PinePhone? Let us know of your views in the comment section._
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/pinephone/
|
||||
|
||||
作者:[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/pinebook-kde-smartphone/
|
||||
[2]: https://neon.kde.org/
|
||||
[3]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2019/11/pinephone-prototype.jpeg?ssl=1
|
||||
[4]: https://i2.wp.com/itsfoss.com/wp-content/uploads/2019/11/pinephone-brave-heart-pre-order.jpg?ssl=1
|
||||
[5]: https://www.pine64.org/
|
||||
[6]: https://store.pine64.org/
|
||||
[7]: https://itsfoss.com/pinebook-linux-notebook/
|
||||
[8]: https://itsfoss.com/pinebook-pro/
|
||||
[9]: https://itsfoss.com/librem-linux-phone/
|
@ -0,0 +1,51 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (My first open source contribution: Keep the code relevant)
|
||||
[#]: via: (https://opensource.com/article/19/11/first-open-source-contribution-relevant-code)
|
||||
[#]: author: (Galen Corey https://opensource.com/users/galenemco)
|
||||
|
||||
My first open source contribution: Keep the code relevant
|
||||
======
|
||||
Be aware of what development tools you have running in the background.
|
||||
![Filing cabinet for organization][1]
|
||||
|
||||
Previously, I explained [the importance of forking repositories][2]. Once I finished the actual "writing the code" part of making my first open source pull request, I felt excellent. It seemed like the hard part was finally over. What’s more, I felt great about the code that I wrote.
|
||||
|
||||
One thing that I decided to do (which turned out to be an excellent choice) was to use [test-driven development][3] (TDD) to write the code. Using TDD was helpful because it gave me a place to start, and a way to know if what I was doing actually worked. Because my background was in building web apps, I rarely ran into the problem of writing code that didn’t have a tangible, visible output. The test-first approach helped me make the leap into working on a tool where you can’t evaluate your progress manually. The fact that I had written a clear test also helped me ultimately get my pull request accepted. The reviewer highlighted the test in his comments on my code.
|
||||
|
||||
Another thing I felt great about was that I had accomplished the whole thing in around 20 lines of code. I know from experience that shorter pull requests are much easier to review. Such short pieces generally take less time, and the reviewer can concentrate on only the small number of lines that were changed. I hoped that this would increase my chances that one of the maintainers would look at my work and feel confident in it.
|
||||
|
||||
Much to my surprise, when I finally pushed my branch to GitHub, the diff was showing that I had changed multiple lines of code. I ran into trouble here because I had become too comfortable with my usual development setup. Because I typically work on a single project, I barely think about some of the tools I have working in the background to make my life easier. The culprit here was [`prettier`][4], a code formatter that automatically fixes all of my minor spacing and syntax discrepancies when I save an edited file. In my usual workflow, this tool is extremely helpful. Most of the developers I work with have `prettier` installed, so all of the code that we write obeys the same style rules.
|
||||
|
||||
In this new project, however, style rules had fallen by the wayside. The project did, in fact, contain an eslint config stating that single quotes should be used instead of double-quotes. However, the developers who were contributing to the project ignored this rule and used both single- and double-quotes. Unlike human beings, `prettier` never ignores the rules. While I was working, it took the initiative to turn every double quote in every file I changed to a single quote, causing hundreds of unintentional changes.
|
||||
|
||||
I tried for a few minutes to remove these changes, but because they had been continually happening as I worked, they were embedded in all of my commits. Then the type-B in me took over and decided to leave the changes in. "Maybe this is not a big deal," I thought. "They said they wanted single quotes, after all."
|
||||
|
||||
My mistake was including these unrelated changes in my PR. While I was technically right that this wasn’t a "big deal," the maintainer who reviewed my code asked me to revert the changes. My initial instinct, that keeping my pull request small and to the point, was correct.
|
||||
|
||||
The lesson here is that you should keep your changes as minimal and to-the-point as possible. Be mindful of any tools you have that might apply to your normal workflow, but aren’t as useful if you are working on a new project.
|
||||
|
||||
**Free idea:** If you are looking for a way to get an open source PR in without writing any code, pick a project that doesn’t adhere to its style guide, run `prettier` on it, and make the result your whole pull request. It’s not guaranteed that every project community will appreciate this, but it’s worth a shot.
|
||||
|
||||
There are lots of non-code ways to contribute to open source: Here are three alternatives.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/11/first-open-source-contribution-relevant-code
|
||||
|
||||
作者:[Galen Corey][a]
|
||||
选题:[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/galenemco
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/files_documents_organize_letter.png?itok=GTtiiabr (Filing cabinet for organization)
|
||||
[2]: https://opensource.com/article/19/10/first-open-source-contribution-fork-clone
|
||||
[3]: https://opensource.com/article/19/10/test-driven-development-best-practices
|
||||
[4]: https://prettier.io/
|
@ -1,61 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Cloning a MAC address to bypass a captive portal)
|
||||
[#]: via: (https://fedoramagazine.org/cloning-a-mac-address-to-bypass-a-captive-portal/)
|
||||
[#]: author: (Esteban Wilson https://fedoramagazine.org/author/swilson/)
|
||||
|
||||
Cloning a MAC address to bypass a captive portal
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
If you ever attach to a WiFi system outside your home or office, you often see a portal page. This page may ask you to accept terms of service or some other agreement to get access. But what happens when you can’t connect through this kind of portal? This article shows you how to use NetworkManager on Fedora to deal with some failure cases so you can still access the internet.
|
||||
|
||||
### How captive portals work
|
||||
|
||||
Captive portals are web pages offered when a new device is connected to a network. When the user first accesses the Internet, the portal captures all web page requests and redirects them to a single portal page.
|
||||
|
||||
The page then asks the user to take some action, typically agreeing to a usage policy. Once the user agrees, they may authenticate to a RADIUS or other type of authentication system. In simple terms, the captive portal registers and authorizes a device based on the device’s MAC address and end user acceptance of terms. (The MAC address is [a hardware-based value][2] attached to any network interface, like a WiFi chip or card.)
|
||||
|
||||
Sometimes a device doesn’t load the captive portal to authenticate and authorize the device to use the location’s WiFi access. Examples of this situation include mobile devices and gaming consoles (Switch, Playstation, etc.). They usually won’t launch a captive portal page when connecting to the Internet. You may see this situation when connecting to hotel or public WiFi access points.
|
||||
|
||||
You can use NetworkManager on Fedora to resolve these issues, though. Fedora will let you temporarily clone the connecting device’s MAC address and authenticate to the captive portal on the device’s behalf. You’ll need the MAC address of the device you want to connect. Typically this is printed somewhere on the device and labeled. It’s a six-byte hexadecimal value, so it might look like _4A:1A:4C:B0:38:1F_. You can also usually find it through the device’s built-in menus.
|
||||
|
||||
### Cloning with NetworkManager
|
||||
|
||||
First, open _**nm-connection-editor**_, or open the WiFI settings via the Settings applet. You can then use NetworkManager to clone as follows:
|
||||
|
||||
* For Ethernet – Select the connected Ethernet connection. Then select the _Ethernet_ tab. Note or copy the current MAC address. Enter the MAC address of the console or other device in the _Cloned MAC address_ field.
|
||||
* For WiFi – Select the WiFi profile name. Then select the WiFi tab. Note or copy the current MAC address. Enter the MAC address of the console or other device in the _Cloned MAC address_ field.
|
||||
|
||||
|
||||
|
||||
### **Bringing up the desired device**
|
||||
|
||||
Once the Fedora system connects with the Ethernet or WiFi profile, the cloned MAC address is used to request an IP address, and the captive portal loads. Enter the credentials needed and/or select the user agreement. The MAC address will then get authorized.
|
||||
|
||||
Now, disconnect the WiFi or Ethernet profile, and change the Fedora system’s MAC address back to its original value. Then boot up the console or other device. The device should now be able to access the Internet, because its network interface has been authorized via your Fedora system.
|
||||
|
||||
This isn’t all that NetworkManager can do, though. For instance, check out this article on [randomizing your system’s hardware address][3] for better privacy.
|
||||
|
||||
> [Randomize your MAC address using NetworkManager][3]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/cloning-a-mac-address-to-bypass-a-captive-portal/
|
||||
|
||||
作者:[Esteban Wilson][a]
|
||||
选题:[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/swilson/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/clone-mac-nm-816x345.jpg
|
||||
[2]: https://en.wikipedia.org/wiki/MAC_address
|
||||
[3]: https://fedoramagazine.org/randomize-mac-address-nm/
|
@ -0,0 +1,309 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (A guide to open source for microservices)
|
||||
[#]: via: (https://opensource.com/article/19/11/microservices-cheat-sheet)
|
||||
[#]: author: (Girish Managoli https://opensource.com/users/gammay)
|
||||
|
||||
A guide to open source for microservices
|
||||
======
|
||||
Build and manage high-scale microservices networks and solve the
|
||||
challenges of running services without fault that scale based on
|
||||
business demand.
|
||||
![Text editor on a browser, in blue][1]
|
||||
|
||||
Microservices—applications broken down into smaller, composable pieces that work together—are getting as much attention as the hottest new restaurant in town. (If you're not yet familiar, dive into [What Are Microservices][2] before continuing here.)
|
||||
|
||||
However, if you have moved on from "Hello, World" and running a simple handful of microservices, and are building hundreds of microservices and running thousands of instances, you know there is nothing "micro" about them. You want your instances to increase when users increase and decrease when users decrease. You want to distribute requests effectively between instances. You want to build and run your services intelligently. You need a clear view of the service instances that are running or going down. How can you manage all of this complexity?
|
||||
|
||||
This article looks at some of the key terminologies in the microservices ecosystem and some of the open source software available to build out a microservices architecture. The focus is on building and managing high-scale microservices networks and solving the challenges of running services without fault and that scale correctly based on business demand.
|
||||
|
||||
Here is a wholesome, lavish spread of open source cuisine that is sure to be gastronomically, "_microservically"_ appetizing. I'm sure I've overlooked some open source applications in this area; please let me know about them in the comments.
|
||||
|
||||
**[Download the PDF version of this cheat sheet [here][3]]**
|
||||
|
||||
### Containers
|
||||
|
||||
The right way to deploy applications is in [containers][4]. Briefly, a container is a miniature virtual server packed with the software required to run an application. The container pack is small, smart, and easy to deploy and maintain. And deploying your application in a container is clever. You can deploy as many instances as you need and scale up or down as needed to meet the current load.
|
||||
|
||||
**Open source containers**
|
||||
|
||||
**Software** | **Code** | **License**
|
||||
---|---|---
|
||||
[rkt][5] | [GitHub][6] | Apache License 2.0
|
||||
[Docker][7] | [GitHub][8] | Apache License 2.0
|
||||
[FreeBSD Jail][9] | [GitHub][10] | FreeBSD License
|
||||
[LXC][11] | [GitHub][12] | GNU LGPL v.2.1
|
||||
[OpenVZ][13] | [GitHub][14] | GNU General Public License v2.0
|
||||
|
||||
### Container orchestrators
|
||||
|
||||
If you have hundreds or thousands of service instances deployed on containers, you need a good way to manage them. Container orchestration is the right solution for deploying and managing all of these containers. Orchestrators can move across; scale up, down, or out; manage higher or lower loads; regulate added, removed, and dead containers; and much more.
|
||||
|
||||
**Open source container orchestrators**
|
||||
|
||||
**Software** | **Code** | **License**
|
||||
---|---|---
|
||||
[Kubernetes][15] | [GitHub][16] | Apache License 2.0
|
||||
[OpenShift][17] | [GitHub][18] | Apache License 2.0
|
||||
[Nomad][19] | [GitHub][20] | Mozilla Public License 2.0
|
||||
[LXD][21] | [GitHub][22] | Apache License 2.0
|
||||
|
||||
### API gateways
|
||||
|
||||
An API gateway is a watchman that controls and monitors API calls to your application. An API gateway has three key roles:
|
||||
|
||||
1. **API data and management:** API listing, API subscription, API documentation, community support
|
||||
2. **API viewpoint and billing:** Analytics, metrics, billing
|
||||
3. **API control and security:** Subscription caller management, rate control, blocking, data conversion, production and sandbox support, key management
|
||||
|
||||
|
||||
|
||||
API gateways are usually multi-tenant solutions to deploy multiple applications on the same gateway.
|
||||
|
||||
**Open source API gateways**
|
||||
|
||||
Not all of the following API gateways support every function mentioned above, so pick and choose depending on your needs.
|
||||
|
||||
**Software** | **Code** | **License**
|
||||
---|---|---
|
||||
[3scale][23] | [GitHub][24] | Apache License 2.0
|
||||
[API Umbrella][25] | [GitHub][26] | MIT License
|
||||
[Apigee][27] | [GitHub][28] | Apache License 2.0
|
||||
[Apiman][29] | [GitHub][30] | Apache License 2.0
|
||||
[DreamFactory][31] | [GitHub][32] | Apache License 2.0
|
||||
[Fusio][33] | [GitHub][34] | GNU Affero General Public License v3.0
|
||||
[Gravitee][35] | [GitHub][36] | Apache License 2.0
|
||||
[Kong][37] | [GitHub][38] | Apache License 2.0
|
||||
[KrakenD][39] | [GitHub][40] | Apache License 2.0
|
||||
[Tyk][41] | [GitHub][42] | Mozilla Public License 2.0
|
||||
|
||||
### CI/CD
|
||||
|
||||
Continuous integration (CI) and continuous deployment (CD; it may also stand for continuous delivery) are the net sum of processes to build and run your processes. [CI/CD][43] is a philosophy that ensures your microservices are built and run correctly to meet users' expectations. Automation is the critical CI/CD factor that makes the build and run process easy and structured. CI's primary processes are build and test, and CD's are deploy and monitor.
|
||||
|
||||
All of the CI/CD tools and platforms listed below are open source. I don't include SaaS platforms that are free for hosting open source. GitHub also isn't on the list because it is not open source and does not have built-in CI/CD; it uses third-party CI/CD product integrations instead. GitLab is open source and has a built-in CI/CD service, so it is on this list.
|
||||
|
||||
**Open source CI/CD tools**
|
||||
|
||||
**Software** | **Code** | **License**
|
||||
---|---|---
|
||||
[Jenkins][44] | [GitHub][45] | MIT License
|
||||
[GitLab][46] | [GitLab][47] | MIT License
|
||||
[Buildbot][48] | [GitHub][49] | GNU General Public License v2.0
|
||||
[Concourse][50] | [GitHub][51] | Apache License 2.0
|
||||
[GoCD][52] | [GitHub][53] | Apache License 2.0
|
||||
[Hudson][54] | [GitHub][55] | MIT License
|
||||
[Spinnaker][56] | [GitHub][57] | Apache License 2.0
|
||||
|
||||
### Load balancers
|
||||
|
||||
When your number of requests scale, you must deploy multiple instances of your application and share requests across those instances. The application that manages the requests between instances is called a load balancer. A load balancer can be configured to distribute requests based on round-robin scheduling, IP routing, or another algorithm. The load balancer automatically manages request distributions when new instances are added (to support higher load) or decommissioned (when load scales down). Session persistence is another load-balancing feature that redirects new requests to the previous instance when needed (for example, to maintain a session). There are hardware- and software-based load balancers.
|
||||
|
||||
**Open source load balancers**
|
||||
|
||||
**Software** | **Code** | **License**
|
||||
---|---|---
|
||||
[HAProxy][58] | [GitHub][59] | HAPROXY's license / GPL v2.0
|
||||
[Apache modules][60] (mod_athena, mod_proxy_balancer) | [SourceForge][61] or
|
||||
[Code.Google][62] or
|
||||
[GitHub][63] | Apache License 2.0
|
||||
[Balance][64] | [SourceForge][65] | GNU General Public License v2.0
|
||||
[Distributor][66] | [SourceForge][67] | GNU General Public License v2.0
|
||||
[GitHub Load Balancer (GLB) Director][68] | [GitHub][69] | BSD 3-Clause License
|
||||
[Neutrino][70] | [GitHub][71] | Apache License 2.0
|
||||
[OpenLoBa][72] | [SourceForge][73] | Not known
|
||||
[Pen][74] | [GitHub][75] | GNU General Public License, v2.0
|
||||
[Seesaw][76] | [GitHub][77] | Apache License 2.0
|
||||
[Synapse][78] | [GitHub][79] | Apache License 2.0
|
||||
[Traefik][80] | [GitHub][81] | MIT License
|
||||
|
||||
### Service registry and service discovery
|
||||
|
||||
When several hundreds or thousands of service instances are deployed and talking to each other, how do requester services know how to connect the right responder services, given that deployment points are dynamic as services are scaled in and out? A service registry and service discovery service solves this problem. These systems are essentially key-value stores that maintain configuration information and naming and provide distributed synchronization.
|
||||
|
||||
**Open source service registry and discovery services**
|
||||
|
||||
**Software** | **Code** | **License**
|
||||
---|---|---
|
||||
[Baker Street][82] | [GitHub][83] | Apache License 2.0
|
||||
[Consul][84] | [GitHub][85] | Mozilla Public License 2.0
|
||||
[etcd][86] | [GitHub][87] | Apache License 2.0
|
||||
[Registrator][88] | [GitHub][89] | MIT License
|
||||
[Serf][90] | [GitHub][91] | Mozilla Public License 2.0
|
||||
[ZooKeeper][92] | [GitHub][93] | Apache License 2.0
|
||||
|
||||
### Monitoring
|
||||
|
||||
When your microservices and their instances cater to users' needs, you need to maintain a good view of their performance. Monitoring tools to the rescue!
|
||||
|
||||
Open source monitoring tools and software come in numerous flavors, some barely better than [top][94]. Other options include OS-specific; enterprise-grade; tool collections that provide complete integration; do-one-thing tools that merely monitor or report or visualize and integrate with third-party tools; and tools that monitor specific or multiple components such as networks, log files, web requests, and databases. Monitoring tools can be web-based or standalone tools, and notification options range from passive reporting to active alerting.
|
||||
|
||||
Choose one or more of these tools to enjoy a chewy crunch of your microservices network.
|
||||
|
||||
**Open source monitoring software**
|
||||
|
||||
**Software** | **Code** | **License**
|
||||
---|---|---
|
||||
[OpenNMS][95] | [GitHub][96] | GNU Affero General Public License
|
||||
[Grafana][97] | [GitHub][98] | Apache License 2.0
|
||||
[Graphite][99] | [GitHub][100] | Apache License 2.0
|
||||
[Icinga][101] | [GitHub][102] | GNU General Public License v2.0
|
||||
[InfluxDB][103] | [GitHub][104] | MIT License
|
||||
[LibreNMS][105] | [GitHub][106] | GNU General Public License v3.0
|
||||
[Naemon][107] | [GitHub][108] | GNU General Public License v2.0
|
||||
[Nagios][109] | [GitHub][110] | GNU General Public License v2.0
|
||||
[ntop][111] | [GitHub][112] | GNU General Public License v3.0
|
||||
[ELK][113] | [GitHub][114] | Apache License 2.0
|
||||
[Prometheus][115] | [GitHub][116] | Apache License 2.0
|
||||
[Sensu][117] | [GitHub][118] | MIT License
|
||||
[Zabbix][119] | [Self-hosted repo][120] | GNU General Public License v2.0
|
||||
[Zenoss][121] | [SourceForge][122] | GNU General Public License v2.0
|
||||
|
||||
### The right ingredients
|
||||
|
||||
Pure open source solutions can offer the right ingredients for deploying and running microservices at high scale. I hope you find them to be relishing, gratifying, satiating, and most of all, _microservicey_!
|
||||
|
||||
### Download the [Microservices cheat sheet][3].
|
||||
|
||||
What are microservices? Opensource.com created a new resource page which gently introduces...
|
||||
|
||||
What are microservices, how do container technologies allow for their use, and what other tools do...
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/11/microservices-cheat-sheet
|
||||
|
||||
作者:[Girish Managoli][a]
|
||||
选题:[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/gammay
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/browser_blue_text_editor_web.png?itok=lcf-m6N7 (Text editor on a browser, in blue)
|
||||
[2]: https://opensource.com/resources/what-are-microservices
|
||||
[3]: https://opensource.com/content/microservices-cheat-sheet
|
||||
[4]: https://opensource.com/resources/what-are-linux-containers
|
||||
[5]: https://coreos.com/rkt/
|
||||
[6]: https://github.com/rkt/rkt/
|
||||
[7]: https://www.docker.com/
|
||||
[8]: https://github.com/docker
|
||||
[9]: https://www.freebsd.org/doc/handbook/jails-build.html
|
||||
[10]: https://github.com/freebsd/freebsd
|
||||
[11]: https://linuxcontainers.org/lxc/
|
||||
[12]: https://github.com/lxc/lxc
|
||||
[13]: https://openvz.org/
|
||||
[14]: https://github.com/OpenVZ
|
||||
[15]: https://kubernetes.io/
|
||||
[16]: https://github.com/kubernetes/kubernetes
|
||||
[17]: https://www.openshift.com/
|
||||
[18]: https://github.com/openshift
|
||||
[19]: https://www.nomadproject.io/
|
||||
[20]: https://github.com/hashicorp/nomad
|
||||
[21]: https://linuxcontainers.org/lxd/introduction/
|
||||
[22]: https://github.com/lxc/lxd
|
||||
[23]: https://www.redhat.com/en/technologies/jboss-middleware/3scale
|
||||
[24]: https://github.com/3scale/APIcast
|
||||
[25]: https://apiumbrella.io/
|
||||
[26]: https://github.com/NREL/api-umbrella
|
||||
[27]: https://cloud.google.com/apigee/
|
||||
[28]: https://github.com/apigee/microgateway-core
|
||||
[29]: http://www.apiman.io/
|
||||
[30]: https://github.com/apiman/apiman
|
||||
[31]: https://www.dreamfactory.com/
|
||||
[32]: https://github.com/dreamfactorysoftware/dreamfactory
|
||||
[33]: https://www.fusio-project.org/
|
||||
[34]: https://github.com/apioo/fusio
|
||||
[35]: https://gravitee.io/
|
||||
[36]: https://github.com/gravitee-io/gravitee-gateway
|
||||
[37]: https://konghq.com/kong/
|
||||
[38]: https://github.com/Kong/
|
||||
[39]: https://www.krakend.io/
|
||||
[40]: https://github.com/devopsfaith/krakend
|
||||
[41]: https://tyk.io/
|
||||
[42]: https://github.com/TykTechnologies/tyk
|
||||
[43]: https://opensource.com/article/18/8/what-cicd
|
||||
[44]: https://jenkins.io/
|
||||
[45]: https://github.com/jenkinsci/jenkins
|
||||
[46]: https://gitlab.com/
|
||||
[47]: https://gitlab.com/gitlab-org
|
||||
[48]: https://buildbot.net/
|
||||
[49]: https://github.com/buildbot/buildbot
|
||||
[50]: https://concourse-ci.org/
|
||||
[51]: https://github.com/concourse/concourse
|
||||
[52]: https://www.gocd.org/
|
||||
[53]: https://github.com/gocd/gocd
|
||||
[54]: http://hudson-ci.org/
|
||||
[55]: https://github.com/hudson
|
||||
[56]: https://www.spinnaker.io/
|
||||
[57]: https://github.com/spinnaker/spinnaker
|
||||
[58]: http://www.haproxy.org/
|
||||
[59]: https://github.com/haproxy/haproxy
|
||||
[60]: https://httpd.apache.org/docs/2.4/mod/mod_proxy_balancer.html
|
||||
[61]: http://ath.sourceforge.net/
|
||||
[62]: https://code.google.com/archive/p/ath/
|
||||
[63]: https://github.com/omnigroup/Apache/blob/master/httpd/modules/proxy/mod_proxy_balancer.c
|
||||
[64]: https://www.inlab.net/balance/
|
||||
[65]: https://sourceforge.net/projects/balance/
|
||||
[66]: http://distributor.sourceforge.net/
|
||||
[67]: https://sourceforge.net/projects/distributor/files/
|
||||
[68]: https://github.blog/2016-09-22-introducing-glb/
|
||||
[69]: https://github.com/github/glb-director
|
||||
[70]: https://neutrinoslb.github.io/
|
||||
[71]: https://github.com/eBay/Neutrino
|
||||
[72]: http://openloba.sourceforge.net/
|
||||
[73]: https://sourceforge.net/p/openloba/code/HEAD/tree/
|
||||
[74]: http://siag.nu/pen/
|
||||
[75]: https://github.com/UlricE/pen
|
||||
[76]: https://opensource.google.com/projects/seesaw
|
||||
[77]: https://github.com/google/seesaw
|
||||
[78]: https://synapse.apache.org/
|
||||
[79]: https://github.com/apache/synapse/tree/master
|
||||
[80]: https://traefik.io/
|
||||
[81]: https://github.com/containous/traefik
|
||||
[82]: http://bakerstreet.io/
|
||||
[83]: https://github.com/datawire/bakerstreet
|
||||
[84]: https://www.consul.io/
|
||||
[85]: https://github.com/hashicorp/consul
|
||||
[86]: https://etcd.io/
|
||||
[87]: https://github.com/etcd-io/etcd
|
||||
[88]: https://gliderlabs.github.io/registrator/latest/
|
||||
[89]: https://github.com/gliderlabs/registrator
|
||||
[90]: https://www.serf.io/
|
||||
[91]: https://github.com/hashicorp/serf
|
||||
[92]: https://zookeeper.apache.org/
|
||||
[93]: https://github.com/apache/zookeeper
|
||||
[94]: https://en.wikipedia.org/wiki/Top_(software)
|
||||
[95]: https://www.opennms.com/
|
||||
[96]: https://github.com/OpenNMS/opennms
|
||||
[97]: https://grafana.com
|
||||
[98]: https://github.com/grafana/grafana
|
||||
[99]: https://graphiteapp.org/
|
||||
[100]: https://github.com/graphite-project
|
||||
[101]: https://icinga.com/
|
||||
[102]: https://github.com/icinga/
|
||||
[103]: https://www.influxdata.com/
|
||||
[104]: https://github.com/influxdata/influxdb
|
||||
[105]: https://www.librenms.org/
|
||||
[106]: https://github.com/librenms/librenms
|
||||
[107]: http://www.naemon.org/
|
||||
[108]: https://github.com/naemon
|
||||
[109]: https://www.nagios.org/
|
||||
[110]: https://github.com/NagiosEnterprises/nagioscore
|
||||
[111]: https://www.ntop.org/
|
||||
[112]: https://github.com/ntop/ntopng
|
||||
[113]: https://www.elastic.co/
|
||||
[114]: https://github.com/elastic
|
||||
[115]: https://prometheus.io/
|
||||
[116]: https://github.com/prometheus/prometheus
|
||||
[117]: https://sensu.io/
|
||||
[118]: https://github.com/sensu
|
||||
[119]: https://www.zabbix.com/
|
||||
[120]: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse
|
||||
[121]: https://www.zenoss.com/
|
||||
[122]: https://sourceforge.net/projects/zenoss/
|
@ -0,0 +1,87 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to add a user to your Linux desktop)
|
||||
[#]: via: (https://opensource.com/article/19/11/add-user-gui-linux)
|
||||
[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss)
|
||||
|
||||
How to add a user to your Linux desktop
|
||||
======
|
||||
It's easy to manage users from a graphical interface, whether during
|
||||
installation or on the desktop.
|
||||
![Team of people around the world][1]
|
||||
|
||||
Adding a user is one of the first things you do on a new computer system. And you often have to manage users throughout the computer's lifespan.
|
||||
|
||||
My article on the [**useradd** command][2] provides a deeper understanding of user management on Linux. Useradd is a command-line tool, but you can also manage users graphically on Linux. That's the topic of this article.
|
||||
|
||||
### Add a user during Linux installation
|
||||
|
||||
Most Linux distributions provide a step for creating a user during installation. For example, the Fedora 30 installer, Anaconda, creates the standard _root_ user and one other local user account. When you reach the **Configuration** screen during installation, click **User Creation** under **User Settings**.
|
||||
|
||||
![Fedora Anaconda Installer - Add a user][3]
|
||||
|
||||
On the Create User screen, enter the user's details: **Full name**, **User name**, and **Password**. You can also choose whether to make the user an administrator.
|
||||
|
||||
![Create a user during installation][4]
|
||||
|
||||
The **Advanced** button opens the **Advanced User Configuration** screen. Here, you can specify the path to the home directory and the user and group IDs if you need something besides the default. You can also type a list of secondary groups that the user will be placed into.
|
||||
|
||||
![Advanced user configuration][5]
|
||||
|
||||
### Add a user on the Linux desktop
|
||||
|
||||
#### GNOME
|
||||
|
||||
Many Linux distributions use the GNOME desktop. The following screenshots are from Red Hat Enterprise Linux 8.0, but the process is similar in other distros like Fedora, Ubuntu, or Debian.
|
||||
|
||||
Start by opening **Settings**. Then go to **Details**, select **Users**, click **Unlock**, and enter your password (unless you are already logged in as root). This will replace the **Unlock** button with an **Add User** button.
|
||||
|
||||
![GNOME user settings][6]
|
||||
|
||||
Now, you can add a user by clicking **Add User**,** **then selecting the account **Type** and the details **Name** and **Password**).
|
||||
|
||||
In the screenshot below, a user name has been entered, and settings are left as default. I did not have to enter the **Username**; it was created automatically as I typed in the **Full Name** field. You can still modify it though if the autocompletion is not to your liking.
|
||||
|
||||
![GNOME settings - add user][7]
|
||||
|
||||
This creates a standard account for a user named Sonny. Sonny will need to provide a password the first time he or she logs in.
|
||||
|
||||
Next, the users will be displayed. Each user can be selected and customized or removed from this screen. For instance, you might want to choose an avatar image or set the default language.
|
||||
|
||||
![GNOME new user][8]
|
||||
|
||||
#### KDE
|
||||
|
||||
KDE is another popular Linux desktop environment. Below is a screenshot of KDE Plasma on Fedora 30. You can see that adding a user in KDE is quite similar to doing it in GNOME.
|
||||
|
||||
![KDE settings - add user][9]
|
||||
|
||||
### Conclusion
|
||||
|
||||
Other desktop environments and window managers in addition to GNOME and KDE include graphical user management tools. Adding a user graphically in Linux is quick and simple, whether you do it at installation or afterward.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/19/11/add-user-gui-linux
|
||||
|
||||
作者:[Alan Formy-Duval][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/alanfdoss
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/team_global_people_gis_location.png?itok=Rl2IKo12 (Team of people around the world)
|
||||
[2]: https://opensource.com/article/19/10/linux-useradd-command
|
||||
[3]: https://opensource.com/sites/default/files/uploads/screenshot_fedora30_anaconda2.png (Fedora Anaconda Installer - Add a user)
|
||||
[4]: https://opensource.com/sites/default/files/uploads/screenshot_fedora30_anaconda3.png (Create a user during installation)
|
||||
[5]: https://opensource.com/sites/default/files/uploads/screenshot_fedora30_anaconda4.png (Advanced user configuration)
|
||||
[6]: https://opensource.com/sites/default/files/uploads/gnome_settings_user_unlock.png (GNOME user settings)
|
||||
[7]: https://opensource.com/sites/default/files/uploads/gnome_settings_adding_user.png (GNOME settings - add user)
|
||||
[8]: https://opensource.com/sites/default/files/uploads/gnome_settings_user_new.png (GNOME new user)
|
||||
[9]: https://opensource.com/sites/default/files/uploads/kde_settings_adding_user.png (KDE settings - add user)
|
@ -0,0 +1,260 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Tuning your bash or zsh shell on Fedora Workstation and Silverblue)
|
||||
[#]: via: (https://fedoramagazine.org/tuning-your-bash-or-zsh-shell-in-workstation-and-silverblue/)
|
||||
[#]: author: (George Luiz Maluf https://fedoramagazine.org/author/georgelmaluf/)
|
||||
|
||||
Tuning your bash or zsh shell on Fedora Workstation and Silverblue
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
This article shows you how to set up some powerful tools in your command line interpreter (CLI) shell on Fedora. If you use _bash_ (the default) or _zsh_, Fedora lets you easily setup these tools.
|
||||
|
||||
### Requirements
|
||||
|
||||
Some installed packages are required. On Workstation, run the following command:
|
||||
|
||||
```
|
||||
sudo dnf install git wget curl ruby ruby-devel zsh util-linux-user redhat-rpm-config gcc gcc-c++ make
|
||||
```
|
||||
|
||||
On Silverblue run:
|
||||
|
||||
```
|
||||
sudo rpm-ostree install git wget curl ruby ruby-devel zsh util-linux-user redhat-rpm-config gcc gcc-c++ make
|
||||
```
|
||||
|
||||
**Note**: On Silverblue you need to restart before proceeding.
|
||||
|
||||
### Fonts
|
||||
|
||||
You can give your terminal a new look by installing new fonts. Why not fonts that display characters and icons together?
|
||||
|
||||
##### Nerd-Fonts
|
||||
|
||||
Open a new terminal and type the following commands:
|
||||
|
||||
```
|
||||
git clone https://github.com/ryanoasis/nerd-fonts ~/.nerd-fonts
|
||||
cd .nerd-fonts
|
||||
sudo ./install.sh
|
||||
```
|
||||
|
||||
##### Awesome-Fonts
|
||||
|
||||
On Workstation, install using the following command:
|
||||
|
||||
```
|
||||
sudo dnf fontawesome-fonts
|
||||
```
|
||||
|
||||
On Silverblue, type:
|
||||
|
||||
```
|
||||
sudo rpm-ostree install fontawesome-fonts
|
||||
```
|
||||
|
||||
### Powerline
|
||||
|
||||
Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including bash, zsh, tmus, i3, Awesome, IPython and Qtile.
|
||||
|
||||
Fedora Magazine previously posted an [article about powerline][2] that includes instructions on how to install it in the vim editor. You can also find more information on the official [documentation site][3].
|
||||
|
||||
#### Installation
|
||||
|
||||
To install powerline utility on Fedora Workstation, open a new terminal and run:
|
||||
|
||||
```
|
||||
sudo dnf install powerline vim-powerline tmux-powerline powerline-fonts
|
||||
```
|
||||
|
||||
On Silverblue, the command changes to:
|
||||
|
||||
```
|
||||
sudo rpm-ostree install powerline vim-powerline tmux-powerline powerline-fonts
|
||||
```
|
||||
|
||||
**Note**: On Silverblue, before proceeding you need restart.
|
||||
|
||||
#### Activating powerline
|
||||
|
||||
To make the powerline active by default, place the code below at the end of your _~/.bashrc_ file
|
||||
|
||||
```
|
||||
if [ -f `which powerline-daemon` ]; then
|
||||
powerline-daemon -q
|
||||
POWERLINE_BASH_CONTINUATION=1
|
||||
POWERLINE_BASH_SELECT=1
|
||||
. /usr/share/powerline/bash/powerline.sh
|
||||
fi
|
||||
```
|
||||
|
||||
Finally, close the terminal and open a new one. It will look like this:
|
||||
|
||||
![][4]
|
||||
|
||||
### Oh-My-Zsh
|
||||
|
||||
[Oh-My-Zsh][5] is a framework for managing your Zsh configuration. It comes bundled with helpful functions, plugins, and themes. To learn how set Zsh as your default shell this [article][6].
|
||||
|
||||
#### Installation
|
||||
|
||||
Type this in the terminal:
|
||||
|
||||
```
|
||||
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
|
||||
```
|
||||
|
||||
Alternatively, you can type this:
|
||||
|
||||
```
|
||||
sh -c "$(wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
|
||||
```
|
||||
|
||||
At the end, you see the terminal like this:
|
||||
|
||||
![][7]
|
||||
|
||||
Congratulations, Oh-my-zsh is installed.
|
||||
|
||||
#### Themes
|
||||
|
||||
Once installed, you can select your theme. I prefer to use the Powerlevel10k. One advantage is that it is 100 times faster than powerlevel9k theme. To install run this line:
|
||||
|
||||
```
|
||||
git clone https://github.com/romkatv/powerlevel10k.git ~/.oh-my-zsh/themes/powerlevel10k
|
||||
```
|
||||
|
||||
And set ZSH_THEME in your _~/.zshrc_ file
|
||||
|
||||
```
|
||||
ZSH_THEME=powerlevel10k/powerlevel10k
|
||||
```
|
||||
|
||||
Close the terminal. When you open the terminal again, the Powerlevel10k configuration wizard will ask you a few questions to configure your prompt properly.
|
||||
|
||||
![][8]
|
||||
|
||||
After finish Powerline10k configuration wizard, your prompt will look like this:
|
||||
|
||||
![][9]
|
||||
|
||||
If you don’t like it. You can run the powerline10k wizard any time with the command _p10k configure_.
|
||||
|
||||
#### Enable plug-ins
|
||||
|
||||
Plug-ins are stored in _.oh-my-zsh/plugins_ folder. You can visit this site for more information. To activate a plug-in, you need edit your _~/.zshrc_ file. Install plug-ins means that you are going create a series of aliases or shortcuts that execute a specific function.
|
||||
|
||||
For example, to enable the firewalld and git plugins, first edit ~/.zshrc:
|
||||
|
||||
```
|
||||
plugins=(firewalld git)
|
||||
```
|
||||
|
||||
**Note**: use a blank space to separate the plug-ins names list.
|
||||
|
||||
Then reload the configuration
|
||||
|
||||
```
|
||||
source ~/.zshrc
|
||||
```
|
||||
|
||||
To see the created aliases, use the command:
|
||||
|
||||
```
|
||||
alias | grep firewall
|
||||
```
|
||||
|
||||
![][10]
|
||||
|
||||
#### Additional configuration
|
||||
|
||||
I suggest the install syntax-highlighting and syntax-autosuggestions plug-ins.
|
||||
|
||||
```
|
||||
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
|
||||
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
|
||||
```
|
||||
|
||||
Add them to your plug-ins list in your file _~/.zshrc_
|
||||
|
||||
```
|
||||
plugins=( [plugins...] zsh-syntax-highlighting zsh-autosuggestions)
|
||||
```
|
||||
|
||||
Reload the configuration
|
||||
|
||||
```
|
||||
source ~/.zshrc
|
||||
```
|
||||
|
||||
See the results:
|
||||
|
||||
![][11]
|
||||
|
||||
### Colored folders and icons
|
||||
|
||||
Colorls is a Ruby gem that beautifies the terminal’s ls command, with colors and font-awesome icons. You can visit the official [site][12] for more information.
|
||||
|
||||
Because it’s a ruby gem, just follow this simple step:
|
||||
|
||||
```
|
||||
sudo gem install colorls
|
||||
```
|
||||
|
||||
To keep up to date, just do:
|
||||
|
||||
```
|
||||
sudo gem update colorls
|
||||
```
|
||||
|
||||
To prevent type colorls everytime you can make aliases in your _~/.bashrc_ or _~/.zshrc_.
|
||||
|
||||
```
|
||||
alias ll='colorls -lA --sd --gs --group-directories-first'
|
||||
alias ls='colorls --group-directories-first'
|
||||
```
|
||||
|
||||
Also, you can enable tab completion for colorls flags, just entering following line at end of your shell configuration:
|
||||
|
||||
```
|
||||
source $(dirname ($gem which colorls))/tab_complete.sh
|
||||
```
|
||||
|
||||
Reload it and see what it happens:
|
||||
|
||||
![][13]
|
||||
|
||||
![][14]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/tuning-your-bash-or-zsh-shell-in-workstation-and-silverblue/
|
||||
|
||||
作者:[George Luiz Maluf][a]
|
||||
选题:[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/georgelmaluf/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/tuning-shell-816x345.jpg
|
||||
[2]: https://fedoramagazine.org/add-power-terminal-powerline/
|
||||
[3]: https://powerline.readthedocs.io/en/latest/
|
||||
[4]: https://fedoramagazine.org/wp-content/uploads/2019/10/terminal_bash_powerline.png
|
||||
[5]: https://ohmyz.sh
|
||||
[6]: https://fedoramagazine.org/set-zsh-fedora-system/
|
||||
[7]: https://fedoramagazine.org/wp-content/uploads/2019/10/oh-my-zsh.png
|
||||
[8]: https://fedoramagazine.org/wp-content/uploads/2019/10/powerlevel10k_config_wizard.png
|
||||
[9]: https://fedoramagazine.org/wp-content/uploads/2019/10/powerlevel10k.png
|
||||
[10]: https://fedoramagazine.org/wp-content/uploads/2019/10/aliases_plugin.png
|
||||
[11]: https://fedoramagazine.org/wp-content/uploads/2019/10/sintax.png
|
||||
[12]: https://github.com/athityakumar/colorls
|
||||
[13]: https://fedoramagazine.org/wp-content/uploads/2019/10/ls-1024x495.png
|
||||
[14]: https://fedoramagazine.org/wp-content/uploads/2019/10/ll-1024x495.png
|
@ -0,0 +1,61 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (Cloning a MAC address to bypass a captive portal)
|
||||
[#]: via: (https://fedoramagazine.org/cloning-a-mac-address-to-bypass-a-captive-portal/)
|
||||
[#]: author: (Esteban Wilson https://fedoramagazine.org/author/swilson/)
|
||||
|
||||
克隆 MAC 地址来绕过强制门户
|
||||
======
|
||||
|
||||
![][1]
|
||||
|
||||
如果你曾经不在家和办公室连接到 WiFi,那么通常会看到一个门户页面。它可能会要求你接受服务条款或其他协议才能访问。但是,当你无法通过这类门户进行连接时会发生什么?本文向你展示了如何在 Fedora 上使用 NetworkManager 处理某些故障情况,以便你仍然可以访问互联网。
|
||||
|
||||
### 强制门户如何工作
|
||||
|
||||
强制门户是新设备连接到网络时显示的网页。当用户首次访问互联网时,门户网站会捕获所有网页请求并将其重定向到单个门户页面。
|
||||
|
||||
然后,页面要求用户采取一些措施,通常是同意使用政策。用户同意后,他们可以向 RADIUS 或其他类型的身份验证系统进行身份验证。简而言之,强制门户根据设备的 MAC 地址和终端用户接受条款来注册和授权设备。 (MAC 地址是附加到任何网络接口(例如 WiFi 芯片或卡)的[基于硬件的值][2]。)
|
||||
|
||||
有时设备无法加载强制门户来进行身份验证和授权,以使用 WiFI 接入。这种情况的例子包括移动设备和游戏机(Switch,Playstation 等)。当连接到互联网时,它们通常不会打开动强制门户页面。连接到酒店或公共 WiFi 接入点时,你可能会看到这种情况。
|
||||
|
||||
不过,你可以在 Fedora 上使用 NetworkManager 来解决这些问题。Fedora 使你可以临时克隆连接设备的 MAC 地址,并代表该设备通过强制门户进行身份验证。你需要得到连接设备的 MAC 地址。通常,它被打印在设备上的某个地方并贴上标签。它是一个六字节的十六进制值,因此看起来类似 _4A:1A:4C:B0:38:1F_。通常,你也可以通过设备的内置菜单找到它。
|
||||
|
||||
### 使用 NetworkManager 克隆
|
||||
|
||||
首先,打开 _**nm-connection-editor**_,或通过”设置“打开 WiFi 设置。然后,你可以使用 NetworkManager 进行克隆:
|
||||
|
||||
* 对于以太网–选择已连接的以太网连接。然后选择 _Ethernet_ 选项卡。记录或复制当前的 MAC 地址。在 _Cloned MAC address_ 字段中输入游戏机或其他设备的 MAC 地址。
|
||||
* 对于 WiFi –选择 WiFi 配置名。然后选择 “WiFi” 选项卡。记录或复制当前的 MAC 地址。在 _Cloned MAC address_ 字段中输入游戏机或其他设备的 MAC 地址。
|
||||
|
||||
|
||||
|
||||
### **启动所需的设备**
|
||||
|
||||
当 Fedora 系统与以太网或 WiFi 配置连接,克隆的 MAC 地址将用于请求 IP 地址,并加载强制门户。输入所需的凭据和/或选择用户协议。MAC 地址将获得授权。
|
||||
|
||||
现在,断开 WiF i或以太网配置连接,然后将 Fedora 系统的 MAC 地址更改回其原始值。然后启动游戏机或其他设备。设备现在应该可以访问互联网了,因为它的网络接口已通过你的 Fedora 系统进行了授权。
|
||||
|
||||
不过,这不是 NetworkManager 全部能做的。例如,请参阅[随机化系统硬件地址][3],来获得更好的隐私保护。
|
||||
|
||||
> [使用 NetworkManager 随机化你的 MAC 地址][3]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/cloning-a-mac-address-to-bypass-a-captive-portal/
|
||||
|
||||
作者:[Esteban Wilson][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://fedoramagazine.org/author/swilson/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://fedoramagazine.org/wp-content/uploads/2019/10/clone-mac-nm-816x345.jpg
|
||||
[2]: https://en.wikipedia.org/wiki/MAC_address
|
||||
[3]: https://fedoramagazine.org/randomize-mac-address-nm/
|
Loading…
Reference in New Issue
Block a user