mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
commit
72b870c3fa
@ -1,18 +1,20 @@
|
|||||||
如何使用 Arduino 制作一个绘图仪
|
如何使用 Arduino 制作一个绘图仪
|
||||||
======
|
======
|
||||||
|
|
||||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_Arduino_520x292.png?itok=joCojk4e)
|
> 使用开源硬件和软件的 DIY 绘图仪可以自动地绘制、雕刻。
|
||||||
在上学时,科学系的壁橱里藏着一台惠普绘图仪。虽然我在上学期间可以经常使用它,但我还是想拥有一台属于自己的绘图仪。许多年之后,步进电机已经很容易获得了,我又在从事电子产品和微控制器方面的工作,最近,我看到有人用丙烯酸塑料(acrylic)制作了一个显示器。这件事启发了我,并最终制作了我自己的绘图仪。
|
|
||||||
|
|
||||||
|
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/EDU_Arduino_520x292.png?itok=joCojk4e)
|
||||||
|
|
||||||
|
在上学时,科学系的壁橱里藏着一台惠普绘图仪。虽然我在上学的期间可以经常使用它,但我还是想拥有一台属于自己的绘图仪。许多年之后,步进电机已经很容易获得了,我又在从事电子产品和微控制器方面的工作,最近,我看到有人用丙烯酸塑料(acrylic)制作了一个显示器。这件事启发了我,并最终制作了我自己的绘图仪。
|
||||||
|
|
||||||
![The plotter in action ][2]
|
![The plotter in action ][2]
|
||||||
|
|
||||||
我 DIY 的绘图仪;在这里看它工作的[视频][3]。
|
*我 DIY 的绘图仪;在这里看它工作的[视频][3]。*
|
||||||
|
|
||||||
由于我是一个很怀旧的人,我真的很喜欢最初的 [Arduino Uno][4]。下面是我用到的其它东西的一个清单(仅供参考,其中一些我也不是很满意):
|
由于我是一个很怀旧的人,我真的很喜欢最初的 [Arduino Uno][4]。下面是我用到的其它东西的一个清单(仅供参考,其中一些我也不是很满意):
|
||||||
|
|
||||||
* [FabScan shield][5]:承载步进电机驱动器。
|
* [FabScan shield][5]:承载步进电机驱动器。
|
||||||
* [SilentStepSticks][6]:步进电机驱动器,因为 Arduino 自身不能处理步进电机所需的电压和电流。因此我使用了一个 Trinamic TMC2130 芯片,但它是工作在单独模式。这些都是为替换 Pololu 4988,但是它们运转更安静。
|
* [SilentStepSticks][6]:步进电机驱动器,因为 Arduino 自身不能处理步进电机所需的电压和电流。因此我使用了一个 Trinamic TMC2130 芯片,但它是工作在单独模式。这些替换为 Pololu 4988,但是它们运转更安静。
|
||||||
* [SilentStepStick 保护装置][7]:一个防止你的电机驱动器转动过快的二极管(相信我,你肯定会需要它的)。
|
* [SilentStepStick 保护装置][7]:一个防止你的电机驱动器转动过快的二极管(相信我,你肯定会需要它的)。
|
||||||
* 步进电机:我选择的是使用 12 V 电压的 NEMA 17 电机(如,来自 [Watterott][8] 和 [SparkFun][9] 的型号)。
|
* 步进电机:我选择的是使用 12 V 电压的 NEMA 17 电机(如,来自 [Watterott][8] 和 [SparkFun][9] 的型号)。
|
||||||
* [直线导杆][10]
|
* [直线导杆][10]
|
||||||
@ -21,32 +23,27 @@
|
|||||||
* GT2 皮带
|
* GT2 皮带
|
||||||
* [GT2 同步滑轮][11]
|
* [GT2 同步滑轮][11]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
这是我作为个人项目而设计的。如果你想找到一个现成的工具套件,你可以从 German Make 杂志上找到 [MaXYposi][12]。
|
这是我作为个人项目而设计的。如果你想找到一个现成的工具套件,你可以从 German Make 杂志上找到 [MaXYposi][12]。
|
||||||
|
|
||||||
### 硬件安装
|
### 硬件安装
|
||||||
|
|
||||||
正如你所看到的,我刚开始做的太大了。这个绘图仪并不合适放在我的桌子上。但是,没有关系,我只是为了学习它(并且,我也将一些东西进行重新制作,下次我将使用一个更小的横梁)。
|
正如你所看到的,我刚开始做的太大了。这个绘图仪并不合适放在我的桌子上。但是,没有关系,我只是为了学习它(并且,我也将一些东西进行重新制作,下次我将使用一个更小的横梁)。
|
||||||
|
|
||||||
|
|
||||||
![Plotter base plate with X-axis and Y-axis rails][14]
|
![Plotter base plate with X-axis and Y-axis rails][14]
|
||||||
|
|
||||||
带 X 轴和 Y 轴轨道的绘图仪基板
|
*带 X 轴和 Y 轴轨道的绘图仪基板*
|
||||||
|
|
||||||
皮带安装在轨道的侧面,并且用它将一些辅助轮和电机挂在一起:
|
皮带安装在轨道的侧面,并且用它将一些辅助轮和电机挂在一起:
|
||||||
|
|
||||||
|
|
||||||
![The belt routing on the motor][16]
|
![The belt routing on the motor][16]
|
||||||
|
|
||||||
电机上的皮带路由
|
*电机上的皮带路由*
|
||||||
|
|
||||||
我在 Arduino 上堆叠了几个组件。Arduino 在最下面,它之上是 FabScan shield,接着是一个安装在 1 和 2 号电机槽上的 StepStick 保护装置,SilentStepStick 在最上面。注意,SCK 和 SDI 针脚没有连接。
|
我在 Arduino 上堆叠了几个组件。Arduino 在最下面,它之上是 FabScan shield,接着是一个安装在 1 和 2 号电机槽上的 StepStick 保护装置,SilentStepStick 在最上面。注意,SCK 和 SDI 针脚没有连接。
|
||||||
|
|
||||||
|
|
||||||
![Arduino and Shield][18]
|
![Arduino and Shield][18]
|
||||||
|
|
||||||
Arduino 堆叠配置([高清大图][19])
|
*Arduino 堆叠配置([高清大图][19])*
|
||||||
|
|
||||||
注意将电机的连接线接到正确的针脚上。如果有疑问,就去查看它的数据表,或者使用欧姆表去找出哪一对线是正确的。
|
注意将电机的连接线接到正确的针脚上。如果有疑问,就去查看它的数据表,或者使用欧姆表去找出哪一对线是正确的。
|
||||||
|
|
||||||
@ -57,21 +54,19 @@ Arduino 堆叠配置([高清大图][19])
|
|||||||
虽然像 [grbl][20] 这样的软件可以解释诸如像装置移动和其它一些动作的 G-codes,并且,我也可以将它刷进 Arduino 中,但是我很好奇,想更好地理解它是如何工作的。(我的 X-Y 绘图仪软件可以在 [GitHub][21] 上找到,不过我不提供任何保修。)
|
虽然像 [grbl][20] 这样的软件可以解释诸如像装置移动和其它一些动作的 G-codes,并且,我也可以将它刷进 Arduino 中,但是我很好奇,想更好地理解它是如何工作的。(我的 X-Y 绘图仪软件可以在 [GitHub][21] 上找到,不过我不提供任何保修。)
|
||||||
|
|
||||||
使用 StepStick(或者其它兼容的)驱动器去驱动步进电机,基本上只需要发送一个高电平信号或者低电平信号到各自的针脚即可。或者使用 Arduino 的术语:
|
使用 StepStick(或者其它兼容的)驱动器去驱动步进电机,基本上只需要发送一个高电平信号或者低电平信号到各自的针脚即可。或者使用 Arduino 的术语:
|
||||||
|
|
||||||
```
|
```
|
||||||
digitalWrite(stepPin, HIGH);
|
digitalWrite(stepPin, HIGH);
|
||||||
|
|
||||||
delayMicroseconds(30);
|
delayMicroseconds(30);
|
||||||
|
|
||||||
digitalWrite(stepPin, LOW);
|
digitalWrite(stepPin, LOW);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
在 `stepPin` 的位置上是步进电机的针脚编号:3 是 1 号电机,而 6 是 2 号电机。
|
在 `stepPin` 的位置上是步进电机的针脚编号:3 是 1 号电机,而 6 是 2 号电机。
|
||||||
|
|
||||||
在步进电机能够工作之前,它必须先被启用。
|
在步进电机能够工作之前,它必须先被启用。
|
||||||
|
|
||||||
```
|
```
|
||||||
digitalWrite(enPin, LOW);
|
digitalWrite(enPin, LOW);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
实际上,StepStick 能够理解针脚的三个状态:
|
实际上,StepStick 能够理解针脚的三个状态:
|
||||||
@ -80,68 +75,51 @@ digitalWrite(enPin, LOW);
|
|||||||
* High:电机已禁用
|
* High:电机已禁用
|
||||||
* Pin 未连接:电机已启用,但在一段时间后进入节能模式
|
* Pin 未连接:电机已启用,但在一段时间后进入节能模式
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
电机启用后,它的线圈已经有了力量并用来保持位置。这时候几乎不可能用手来转动它的轴。这样可以保证很好的精度,但是也意味着电机和驱动器芯片都“充满着”力量,并且也因此会发热。
|
电机启用后,它的线圈已经有了力量并用来保持位置。这时候几乎不可能用手来转动它的轴。这样可以保证很好的精度,但是也意味着电机和驱动器芯片都“充满着”力量,并且也因此会发热。
|
||||||
|
|
||||||
最后,也是很重要的,我们需要一个决定绘图仪方向的方法:
|
最后,也是很重要的,我们需要一个决定绘图仪方向的方法:
|
||||||
|
|
||||||
```
|
```
|
||||||
digitalWrite(dirPin, direction);
|
digitalWrite(dirPin, direction);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
下面的表列出了功能和针脚~~(致核对:下面的表格式错误)~~
|
下面的表列出了功能和针脚:
|
||||||
|
|
||||||
Function Motor1 Motor2 Enable 2 5 Direction 4 7 Step 3 6
|
| 功能 | 1 号电机 | 2 号电机 |
|
||||||
|
|---|---|---|
|
||||||
|
| 启用 | 2 | 5 |
|
||||||
|
| 方向 | 4 | 7 |
|
||||||
|
| 步进 | 3 | 6 |
|
||||||
|
|
||||||
在我们使用这些针脚之前,我们需要在代码的 `setup()` 节中设置它的 `OUTPUT` 模式。
|
在我们使用这些针脚之前,我们需要在代码的 `setup()` 节中设置它的 `OUTPUT` 模式。
|
||||||
|
|
||||||
```
|
```
|
||||||
pinMode(enPin1, OUTPUT);
|
pinMode(enPin1, OUTPUT);
|
||||||
|
|
||||||
pinMode(stepPin1, OUTPUT);
|
pinMode(stepPin1, OUTPUT);
|
||||||
|
|
||||||
pinMode(dirPin1, OUTPUT);
|
pinMode(dirPin1, OUTPUT);
|
||||||
|
|
||||||
digitalWrite(enPin1, LOW);
|
digitalWrite(enPin1, LOW);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
了解这些知识后,我们可以很容易地让步进电机四处移动:
|
了解这些知识后,我们可以很容易地让步进电机四处移动:
|
||||||
|
|
||||||
```
|
```
|
||||||
totalRounds = ...
|
totalRounds = ...
|
||||||
|
for (int rounds =0 ; rounds < 2*totalRounds; rounds++) {
|
||||||
for (int rounds =0 ; rounds < 2*totalRounds; rounds++) {
|
if (dir==0){ // set direction
|
||||||
|
digitalWrite(dirPin2, LOW);
|
||||||
if (dir==0){ // set direction
|
} else {
|
||||||
|
digitalWrite(dirPin2, HIGH);
|
||||||
digitalWrite(dirPin2, LOW);
|
}
|
||||||
|
delay(1); // give motors some breathing time
|
||||||
} else {
|
dir = 1-dir; // reverse direction
|
||||||
|
for (int i=0; i < 6400; i++) {
|
||||||
digitalWrite(dirPin2, HIGH);
|
int t = abs(3200-i) / 200;
|
||||||
|
digitalWrite(stepPin2, HIGH);
|
||||||
}
|
delayMicroseconds(70 + t);
|
||||||
|
digitalWrite(stepPin2, LOW);
|
||||||
delay(1); // give motors some breathing time
|
delayMicroseconds(70 + t);
|
||||||
|
}
|
||||||
dir = 1-dir; // reverse direction
|
}
|
||||||
|
|
||||||
for (int i=0; i < 6400; i++) {
|
|
||||||
|
|
||||||
int t = abs(3200-i) / 200;
|
|
||||||
|
|
||||||
digitalWrite(stepPin2, HIGH);
|
|
||||||
|
|
||||||
delayMicroseconds(70 + t);
|
|
||||||
|
|
||||||
digitalWrite(stepPin2, LOW);
|
|
||||||
|
|
||||||
delayMicroseconds(70 + t);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
这将使滑块向左和向右移动。这些代码只操纵一个步进电机,但是,对于一个 X-Y 绘图仪,我们要考虑两个轴。
|
这将使滑块向左和向右移动。这些代码只操纵一个步进电机,但是,对于一个 X-Y 绘图仪,我们要考虑两个轴。
|
||||||
@ -149,9 +127,9 @@ digitalWrite(enPin1, LOW);
|
|||||||
#### 命令解释器
|
#### 命令解释器
|
||||||
|
|
||||||
我开始做一个简单的命令解释器去使用规范的路径,比如:
|
我开始做一个简单的命令解释器去使用规范的路径,比如:
|
||||||
|
|
||||||
```
|
```
|
||||||
"X30|Y30|X-30 Y-30|X-20|Y-20|X20|Y20|X-40|Y-25|X40 Y25
|
"X30|Y30|X-30 Y-30|X-20|Y-20|X20|Y20|X-40|Y-25|X40 Y25
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
用毫米来描述相对移动(1 毫米等于 80 步)。
|
用毫米来描述相对移动(1 毫米等于 80 步)。
|
||||||
@ -166,54 +144,39 @@ digitalWrite(enPin1, LOW);
|
|||||||
|
|
||||||
![Servo to raise/lower the pen ][24]
|
![Servo to raise/lower the pen ][24]
|
||||||
|
|
||||||
图中的特写镜头就是伺服器臂提起笔的图像
|
*图中的特写镜头就是伺服器臂提起笔的图像*
|
||||||
|
|
||||||
笔是用一个小夹具固定住的(图上展示的是一个大小为 8 的夹具,它一般用于将线缆固定在墙上)。伺服器臂能够提起笔;当伺服器臂放下来的时候,笔就会被放下来。
|
笔是用一个小夹具固定住的(图上展示的是一个大小为 8 的夹具,它一般用于将线缆固定在墙上)。伺服器臂能够提起笔;当伺服器臂放下来的时候,笔就会被放下来。
|
||||||
|
|
||||||
#### 驱动伺服器
|
#### 驱动伺服器
|
||||||
|
|
||||||
驱动伺服器是非常简单的:只需要提供位置,伺服器就可以完成所有的工作。
|
驱动伺服器是非常简单的:只需要提供位置,伺服器就可以完成所有的工作。
|
||||||
|
|
||||||
```
|
```
|
||||||
#include <Servo.h>
|
#include <Servo.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Servo pin
|
// Servo pin
|
||||||
|
|
||||||
#define servoData PIN_A1
|
#define servoData PIN_A1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Positions
|
// Positions
|
||||||
|
|
||||||
#define PEN_UP 10
|
#define PEN_UP 10
|
||||||
|
|
||||||
#define PEN_DOWN 50
|
#define PEN_DOWN 50
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Servo penServo;
|
Servo penServo;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
// Attach to servo and raise pen
|
||||||
// Attach to servo and raise pen
|
penServo.attach(servoData);
|
||||||
|
penServo.write(PEN_UP);
|
||||||
penServo.attach(servoData);
|
|
||||||
|
|
||||||
penServo.write(PEN_UP);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
我把伺服器接头连接在 FabScan shield 的 4 号电机上,因此,我将用 1 号模拟针脚。
|
我把伺服器接头连接在 FabScan shield 的 4 号电机上,因此,我将用 1 号模拟针脚。
|
||||||
|
|
||||||
放下笔也很容易:
|
放下笔也很容易:
|
||||||
|
|
||||||
```
|
```
|
||||||
penServo.write(PEN_DOWN);
|
penServo.write(PEN_DOWN);
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 进一步扩展
|
### 进一步扩展
|
||||||
@ -230,7 +193,7 @@ via: https://opensource.com/article/18/3/diy-plotter-arduino
|
|||||||
|
|
||||||
作者:[Heiko W.Rupp][a]
|
作者:[Heiko W.Rupp][a]
|
||||||
译者:[qhwdw](https://github.com/qhwdw)
|
译者:[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/) 荣誉推出
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
@ -1,33 +1,29 @@
|
|||||||
Go 程序的持续分析
|
Go 程序的持续分析
|
||||||
============================================================
|
============================================================
|
||||||
|
|
||||||
Google 最有趣的部分之一就是我们的持续分析服务。我们可以看到谁在使用 CPU 和内存,我们可以持续地监控我们的生产服务以争用和阻止配置文件,并且我们可以生成分析和报告,并轻松地告诉我们可以进行哪些有重要影响的优化。
|
Google 最有趣的部分之一就是我们规模庞大的持续分析服务。我们可以看到谁在使用 CPU 和内存,我们可以持续地监控我们的生产服务以争用和阻止配置文件,并且我们可以生成分析和报告,并轻松地告诉我们可以进行哪些有重要影响的优化。
|
||||||
|
|
||||||
我简单研究了 [Stackdriver Profiler][2],这是我们的新产品,它填补了针对云端用户云端分析服务的空白。请注意,你无需在 Google 云平台上运行你的代码即可使用它。实际上,我现在每天都在开发时使用它。它也支持 Java 和 Node.js。
|
我简单研究了 [Stackdriver Profiler][2],这是我们的新产品,它填补了针对云端用户在云服务范围内分析服务的空白。请注意,你无需在 Google 云平台上运行你的代码即可使用它。实际上,我现在每天都在开发时使用它。它也支持 Java 和 Node.js。
|
||||||
|
|
||||||
#### 在生产中分析
|
### 在生产中分析
|
||||||
|
|
||||||
pprof 可安全地用于生产。我们针对 CPU 和堆分配分析的额外开销会增加 5%。一个实例中每分钟收集 10 秒。如果你有一个 Kubernetes Pod 的多个副本,我们确保进行分摊收集。例如,如果你拥有一个 pod 的 10 个副本,模式,那么开销将变为 0.5%。这使用户可以始终进行分析。
|
pprof 可安全地用于生产。我们针对 CPU 和堆分配分析的额外会增加 5% 的开销。一个实例中每分钟收集 10 秒。如果你有一个 Kubernetes Pod 的多个副本,我们确保进行分摊收集。例如,如果你拥有一个 pod 的 10 个副本,模式,那么开销将变为 0.5%。这使用户可以一直进行分析。
|
||||||
|
|
||||||
我们目前支持 Go 程序的 CPU、堆、互斥和线程分析。
|
我们目前支持 Go 程序的 CPU、堆、互斥和线程分析。
|
||||||
|
|
||||||
#### 为什么?
|
### 为什么?
|
||||||
|
|
||||||
在解释如何在生产中使用分析器之前,先解释为什么你想要在生产中进行分析将有所帮助。一些非常常见的情况是:
|
在解释如何在生产中使用分析器之前,先解释为什么你想要在生产中进行分析将有所帮助。一些非常常见的情况是:
|
||||||
|
|
||||||
* 调试仅在生产中可见的性能问题。
|
* 调试仅在生产中可见的性能问题。
|
||||||
|
|
||||||
* 了解 CPU 使用率以减少费用。
|
* 了解 CPU 使用率以减少费用。
|
||||||
|
|
||||||
* 了解争用的累积和优化的地方。
|
* 了解争用的累积和优化的地方。
|
||||||
|
* 了解新版本的影响,例如看到 canary 和产品级之间的区别。
|
||||||
* 了解新版本的影响,例如看到 canary 和生产之间的区别。
|
|
||||||
|
|
||||||
* 通过[关联][1]分析样本以了解延迟的根本原因来丰富你的分布式经验。
|
* 通过[关联][1]分析样本以了解延迟的根本原因来丰富你的分布式经验。
|
||||||
|
|
||||||
#### 启用
|
### 启用
|
||||||
|
|
||||||
Stackdriver Profiler 不能与 _net/http/pprof_ 处理程序一起使用,并要求你在程序中安装和配置一个一行的代理。
|
Stackdriver Profiler 不能与 `net/http/pprof` 处理程序一起使用,并要求你在程序中安装和配置一个一行的代理。
|
||||||
|
|
||||||
```
|
```
|
||||||
go get cloud.google.com/go/profiler
|
go get cloud.google.com/go/profiler
|
||||||
@ -45,56 +41,49 @@ if err := profiler.Start(profiler.Config{
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
当你运行你的程序后,profiler 包将每分钟报告给 profiler 10 秒钟。
|
当你运行你的程序后,profiler 包将每分钟报告给分析器 10 秒钟。
|
||||||
|
|
||||||
#### 可视化
|
### 可视化
|
||||||
|
|
||||||
当分析报告给后端后,你将在 [https://console.cloud.google.com/profiler][4] 上看到火焰图。你可以按标签过滤并更改时间范围,也可以按服务名称和版本进行细分。数据将会长达 30 天。
|
|
||||||
|
|
||||||
|
当分析被报告给后端后,你将在 [https://console.cloud.google.com/profiler][4] 上看到火焰图。你可以按标签过滤并更改时间范围,也可以按服务名称和版本进行细分。数据将会长达 30 天。
|
||||||
|
|
||||||
![](https://cdn-images-1.medium.com/max/900/1*JdCm1WwmTgExzee5-ZWfNw.gif)
|
![](https://cdn-images-1.medium.com/max/900/1*JdCm1WwmTgExzee5-ZWfNw.gif)
|
||||||
|
|
||||||
你可以选择其中一个分析,按服务,区域和版本分解。你可以在火焰中移动并通过标签进行过滤。
|
你可以选择其中一个分析,按服务,区域和版本分解。你可以在火焰中移动并通过标签进行过滤。
|
||||||
|
|
||||||
#### 阅读火焰图
|
### 阅读火焰图
|
||||||
|
|
||||||
火焰图可视化由 [Brendan Gregg][5] 非常全面地解释了。Stackdriver Profiler 增加了一点它自己的特点。
|
|
||||||
|
|
||||||
|
[Brendan Gregg][5] 非常全面地解释了火焰图可视化。Stackdriver Profiler 增加了一点它自己的特点。
|
||||||
|
|
||||||
![](https://cdn-images-1.medium.com/max/900/1*QqzFJlV9v7U1s1reYsaXog.png)
|
![](https://cdn-images-1.medium.com/max/900/1*QqzFJlV9v7U1s1reYsaXog.png)
|
||||||
|
|
||||||
我们将查看一个 CPU 分析,但这也适用于其他分析。
|
我们将查看一个 CPU 分析,但这也适用于其他分析。
|
||||||
|
|
||||||
1. 最上面的 x 轴表示整个程序。火焰上的每个框表示调用路径上的一帧。框的宽度与执行该函数花费的 CPU 时间成正比。
|
1. 最上面的 x 轴表示整个程序。火焰上的每个框表示调用路径上的一帧。框的宽度与执行该函数花费的 CPU 时间成正比。
|
||||||
|
|
||||||
2. 框从左到右排序,左边是花费最多的调用路径。
|
2. 框从左到右排序,左边是花费最多的调用路径。
|
||||||
|
|
||||||
3. 来自同一包的帧具有相同的颜色。这里所有运行时功能均以绿色表示。
|
3. 来自同一包的帧具有相同的颜色。这里所有运行时功能均以绿色表示。
|
||||||
|
|
||||||
4. 你可以单击任何框进一步展开执行树。
|
4. 你可以单击任何框进一步展开执行树。
|
||||||
|
|
||||||
|
|
||||||
![](https://cdn-images-1.medium.com/max/900/1*1jCm6f-Fl2mpkRe3-57mTg.png)
|
![](https://cdn-images-1.medium.com/max/900/1*1jCm6f-Fl2mpkRe3-57mTg.png)
|
||||||
|
|
||||||
你可以将鼠标悬停在任何框上查看任何帧的详细信息。
|
你可以将鼠标悬停在任何框上查看任何帧的详细信息。
|
||||||
|
|
||||||
#### 过滤
|
### 过滤
|
||||||
|
|
||||||
你可以显示,隐藏和高亮符号名称。如果你特别想了解某个特定调用或包的消耗,这些信息非常有用。
|
你可以显示、隐藏和高亮符号名称。如果你特别想了解某个特定调用或包的消耗,这些信息非常有用。
|
||||||
|
|
||||||
![](https://cdn-images-1.medium.com/max/900/1*ka9fA-AAuKggAuIBq_uhGQ.png)
|
![](https://cdn-images-1.medium.com/max/900/1*ka9fA-AAuKggAuIBq_uhGQ.png)
|
||||||
|
|
||||||
1. 选择你的过滤器。你可以组合多个过滤器。在这里,我们将高亮显示 runtime.memmove。
|
1. 选择你的过滤器。你可以组合多个过滤器。在这里,我们将高亮显示 `runtime.memmove`。
|
||||||
|
2. 火焰将使用过滤器过滤帧并可视化过滤后的框。在这种情况下,它高亮显示所有 `runtime.memmove` 框。
|
||||||
2. 火焰将使用过滤器过滤帧并可视化过滤后的框。在这种情况下,它高亮显示所有 runtime.memmove 框。
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
via: https://medium.com/google-cloud/continuous-profiling-of-go-programs-96d4416af77b
|
via: https://medium.com/google-cloud/continuous-profiling-of-go-programs-96d4416af77b
|
||||||
|
|
||||||
作者:[JBD ][a]
|
作者:[JBD][a]
|
||||||
译者:[geekpi](https://github.com/geekpi)
|
译者:[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/) 荣誉推出
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
@ -1,20 +1,24 @@
|
|||||||
3 个 Python 模板库比较
|
3 个 Python 模板库比较
|
||||||
=====
|
=====
|
||||||
|
|
||||||
|
> 你的下一个 Python 项目需要一个模板引擎来自动生成 HTML 吗?这有几种选择。
|
||||||
|
|
||||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/library-libraries-search.png?itok=xH8xSU_G)
|
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/library-libraries-search.png?itok=xH8xSU_G)
|
||||||
|
|
||||||
在我的日常工作中,我花费大量的时间将各种来源的数据转化为可读的信息。虽然很多时候这只是电子表格或某种类型的图表或其他数据可视化的形式,但也有其他时候,将数据以书面形式呈现是有意义的。
|
在我的日常工作中,我花费大量的时间将各种来源的数据转化为可读的信息。虽然很多时候这只是电子表格或某种类型的图表或其他数据可视化的形式,但也有其他时候,将数据以书面形式呈现是有意义的。
|
||||||
|
|
||||||
但我的一个 pet peeve (to 校正:不知道该怎么翻译)正在复制和粘贴。如果你要将数据从源头移动到标准化模板,则不应该复制和粘贴。这很容易出错,说实话,这会浪费你的时间。
|
但我的头疼地方就是复制和粘贴。如果你要将数据从源头移动到标准化模板,则不应该复制和粘贴。这很容易出错,说实话,这会浪费你的时间。
|
||||||
|
|
||||||
因此,对于我定期发送的任何信息都遵循一个共同的模式,我倾向于找到某种方法来自动化至少一部分信息。也许这涉及到在电子表格中创建一些公式,一个快速 shell 脚本或其他解决方案,以便使用从外部源提取的信息自动填充模板。
|
因此,对于我定期发送的任何遵循一个共同的模式的信息,我倾向于找到某种方法来自动化至少一部分信息。也许这涉及到在电子表格中创建一些公式,一个快速 shell 脚本或其他解决方案,以便使用从外部源提取的信息自动填充模板。
|
||||||
|
|
||||||
但最近,我一直在探索 Python 模板来完成从其他数据集创建报告和图表的大部分工作。
|
但最近,我一直在探索 Python 模板来完成从其他数据集创建报告和图表的大部分工作。
|
||||||
|
|
||||||
Python 模板引擎非常强大。我简化创建报告的使用案例仅仅触及了它们可以用来工作的皮毛。许多开发人员正在利用这些工具来构建完整的 web 应用程序和内容管理系统。但是,你不需要有一个复杂的 web 应用程序来使用 Python 模板工具。
|
Python 模板引擎非常强大。我的简化报告创建的使用案例仅仅触及了它的皮毛。许多开发人员正在利用这些工具来构建完整的 web 应用程序和内容管理系统。但是,你并不需要有一个复杂的 web 应用程序才能使用 Python 模板工具。
|
||||||
|
|
||||||
### 为什么选择模板?
|
### 为什么选择模板?
|
||||||
|
|
||||||
每个模板工具都不甚相同,你应该阅读文档以了解其确切的用法。但让我们创建一个假设的例子。假设我想创建一个简短的页面,列出我最近编写的所有 Python 主题。就像这样:
|
每个模板工具都不甚相同,你应该阅读文档以了解其确切的用法。但让我们创建一个假设的例子。假设我想创建一个简短的页面,列出我最近编写的所有 Python 主题。就像这样:
|
||||||
|
|
||||||
```
|
```
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@ -31,30 +35,30 @@ Python 模板引擎非常强大。我简化创建报告的使用案例仅仅触
|
|||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
当它仅仅是这三个项目时,足够简单地维护它。但是当我想添加第四个,第五个或第六十七个时会发生什么?我可以从包含我所有页面列表的 CSV 文件或其他数据文件生成它,而不是手动编码此页面吗?我可以轻松地为我写的每个主题创建重复内容吗?我可以以编程方式更改每个页面上的文本标题吗?这就是模板引擎可以发挥作用的地方。
|
当它仅仅是这三个项目时,维护它是很简单的。但是当我想添加第四个、第五个或第六十七个时会发生什么?我可以从包含我所有页面列表的 CSV 文件或其他数据文件生成它,而不是手动编码此页面吗?我可以轻松地为我写的每个主题创建重复内容吗?我可以以编程方式更改每个页面上的文本标题吗?这就是模板引擎可以发挥作用的地方。
|
||||||
|
|
||||||
有许多不同的选择,今天我将与你其中分享三个,顺序不分先后:[Mako][6], [Jinja2][7] 和 [Genshi][8]。
|
有许多不同的选择,今天我将与你其中分享三个,顺序不分先后:[Mako][6]、 [Jinja2][7] 和 [Genshi][8]。
|
||||||
|
|
||||||
### Mako
|
### Mako
|
||||||
|
|
||||||
[Mako][6] 是根据 MIT 许可证发布的 Python 模板工具,专为快速展现而设计的(与Jinja2不同)。Reddit 已经使用 Mako 为他们的网页提供动力,它同时也是 Pyramid 和 Pylons 等 web 框架的默认模板语言。它相当简单且易于使用。你可以使用几行代码来设计模板;支持Python 2.x 和 3.x,它是一个功能强大且功能丰富的工具,具有[良好的文档][9],这一点我认为是必须的。其功能包括过滤器,继承,可调用块和内置缓存系统,这些系统可以被大型或复杂的 web 项目导入。
|
[Mako][6] 是以 MIT 许可证发布的 Python 模板工具,专为快速展现而设计的(与 Jinja2 不同)。Reddit 已经使用 Mako 来展现他们的网页,它同时也是 Pyramid 和 Pylons 等 web 框架的默认模板语言。它相当简单且易于使用。你可以使用几行代码来设计模板;支持 Python 2.x 和 3.x,它是一个功能强大且功能丰富的工具,具有[良好的文档][9],这一点我认为是必须的。其功能包括过滤器、继承、可调用块和内置缓存系统,这些系统可以被大型或复杂的 web 项目导入。
|
||||||
|
|
||||||
### Jinja2
|
### Jinja2
|
||||||
|
|
||||||
Jinja2 是另一个快速且功能全面的选项,可用于 Python 2.x 和 3.x,遵循 BSD 许可证。Jinja2 从功能角度与 Mako 有很多重叠,因此对于新手来说,你在两者之间的选择可能会归结为你喜欢的格式化风格。Jinja2 还将模板编译为字节码,并具有 HTML 转义,沙盒,模板继承和模板沙盒部分的功能。其用户包括 Mozilla, SourceForge, NPR, Instagram 等,并且还具有[强大的文档][10]。与 Mako 在模板内部使用 Python 逻辑不同的是,Jinja2 使用自己的语法。
|
Jinja2 是另一个快速且功能全面的选项,可用于 Python 2.x 和 3.x,遵循 BSD 许可证。Jinja2 从功能角度与 Mako 有很多重叠,因此对于新手来说,你在两者之间的选择可能会归结为你喜欢的格式化风格。Jinja2 还将模板编译为字节码,并具有 HTML 转义、沙盒、模板继承和模板沙盒部分的功能。其用户包括 Mozilla、 SourceForge、 NPR、 Instagram 等,并且还具有[强大的文档][10]。与 Mako 在模板内部使用 Python 逻辑不同的是,Jinja2 使用自己的语法。
|
||||||
|
|
||||||
### Genshi
|
### Genshi
|
||||||
|
|
||||||
[Genshi][8] 是我会提到的第三个选项。它是一个 XML 工具,具有强大的模板组件,所以如果你使用的数据已经是 XML 格式,或者你需要使用网页以外的格式,Genshi 可能成为你的一个很好的解决方案。HTML 基本上是一种 XML(好吧,不是精确的,但这超出了本文的范围,有点卖弄学问了),因此格式化它们非常相似。由于我通常使用的很多数据都是 XML 或其他类型的数据,因此我非常喜欢使用我可以用于多种事物的工具。
|
[Genshi][8] 是我会提到的第三个选择。它是一个 XML 工具,具有强大的模板组件,所以如果你使用的数据已经是 XML 格式,或者你需要使用网页以外的格式,Genshi 可能成为你的一个很好的解决方案。HTML 基本上是一种 XML(好吧,不是精确的,但这超出了本文的范围,有点卖弄学问了),因此格式化它们非常相似。由于我通常使用的很多数据都是 XML 或其他类型的数据,因此我非常喜欢使用我可以用于多种事物的工具。
|
||||||
|
|
||||||
发行版目前仅支持 Python 2.x,尽管 Python 3 支持存在于主干中,但我提醒你,它看起来并没有得到有效的开发。Genshi 遵循 BSD 许可证提供。
|
发行版目前仅支持 Python 2.x,尽管 Python 3 支持存在于主干中,但我提醒你,它看起来并没有得到有效的开发。Genshi 遵循 BSD 许可证提供。
|
||||||
|
|
||||||
### 示例
|
### 示例
|
||||||
|
|
||||||
因此,在上面的假设示例中,我不会每次写新主题时都更新 HTML 文件,而是通过编程方式对其进行更新。我可以创建一个模板,如下所示:
|
因此,在上面的假设示例中,我不会每次写新主题时都更新 HTML 文件,而是通过编程方式对其进行更新。我可以创建一个模板,如下所示:
|
||||||
|
|
||||||
```
|
```
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@ -74,17 +78,17 @@ Jinja2 是另一个快速且功能全面的选项,可用于 Python 2.x 和 3.x
|
|||||||
```
|
```
|
||||||
|
|
||||||
然后我可以使用我的模板库来迭代每个主题,比如使用 Mako,像这样:
|
然后我可以使用我的模板库来迭代每个主题,比如使用 Mako,像这样:
|
||||||
|
|
||||||
```
|
```
|
||||||
from mako.template import Template
|
from mako.template import Template
|
||||||
|
|
||||||
mytemplate = Template(filename='template.txt')
|
mytemplate = Template(filename='template.txt')
|
||||||
print(mytemplate.render(topics=("Python GUIs","Python IDEs","Python web scrapers")))
|
print(mytemplate.render(topics=("Python GUIs","Python IDEs","Python web scrapers")))
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
当然,在现实世界的用法中,我不会将这些内容手动地列在变量中,而是将它们从外部数据源(如数据库或API)中提取出来。
|
当然,在现实世界的用法中,我不会将这些内容手动地列在变量中,而是将它们从外部数据源(如数据库或 API)中提取出来。
|
||||||
|
|
||||||
这些不是唯一的 Python 模板引擎。如果你正在开始创建一个将大量使用模板的新项目,那么你考虑的可能不仅仅是这三种选择。在[ Python 维基][11]上查看更全面的列表,以获得更多值得考虑的项目。
|
这些不是仅有的 Python 模板引擎。如果你正在开始创建一个将大量使用模板的新项目,那么你考虑的可能不仅仅是这三种选择。在 [Python 维基][11]上查看更全面的列表,以获得更多值得考虑的项目。
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
@ -94,7 +98,7 @@ via: https://opensource.com/resources/python/template-libraries
|
|||||||
作者:[Jason Baker][a]
|
作者:[Jason Baker][a]
|
||||||
选题:[lujun9972](https://github.com/lujun9972)
|
选题:[lujun9972](https://github.com/lujun9972)
|
||||||
译者:[MjSeven](https://github.com/MjSeven)
|
译者:[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/) 荣誉推出
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
@ -0,0 +1,114 @@
|
|||||||
|
如何在 Linux 系统中结束结束进程或是中止程序
|
||||||
|
======
|
||||||
|
|
||||||
|
> 在 Linux 中有几种使用命令行或图形界面终止一个程序的方式。
|
||||||
|
|
||||||
|
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/x_stop_terminate_program_kill.jpg?itok=9rM8i9x8)
|
||||||
|
|
||||||
|
进程出错的时候,您可能会想要中止或是杀掉这个进程。在本文中,我们将探索在命令行和图形界面中终止进程或是应用程序,这里我们使用 [gedit][1] 作为样例程序。
|
||||||
|
|
||||||
|
### 使用命令行或字符终端界面
|
||||||
|
|
||||||
|
#### Ctrl + C
|
||||||
|
|
||||||
|
在命令行中调用 `gedit` (如果您没有使用 `gedit &` 命令)程序的一个问题是 shell 会话被阻塞,没法释放命令行提示符。在这种情况下,`Ctrl + C` (`Ctrl` 和 `C` 的组合键) 会很管用。这会终止 `gedit` ,并且所有的工作都将丢失(除非文件已经被保存)。`Ctrl + C` 会给 `gedit` 发送了 `SIGINT` 信号。这是一个默认终止进程的停止信号,它将指示 shell 停止 `gedit` 的运行,并返回到主函数的循环中,您将返回到提示符。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ gedit
|
||||||
|
^C
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Ctrl + Z
|
||||||
|
|
||||||
|
它被称为挂起字符。它会发送 `SIGTSTP` 信号给进程。它也是一个停止信号,但是默认行为不是杀死进程,而是挂起进程。
|
||||||
|
|
||||||
|
下面的命令将会停止(杀死/中断) `gedit` 的运行,并返回到 shell 提示符。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ gedit
|
||||||
|
^Z
|
||||||
|
[1]+ Stopped gedit
|
||||||
|
$
|
||||||
|
```
|
||||||
|
|
||||||
|
一旦进程被挂起(以 `gedit` 为例),将不能在 `gedit` 中写入或做任何事情。而在后台,该进程变成了一个作业,可以使用 `jsbs` 命令验证。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ jobs
|
||||||
|
[1]+ Stopped gedit
|
||||||
|
```
|
||||||
|
|
||||||
|
`jobs` 允许您在单个 shell 会话中控制多个进程。您可以终止,恢复作业,或是根据需要将作业移动到前台或是后台。
|
||||||
|
|
||||||
|
让我们在后台恢复 `gedit`,释放提示符以运行其它命令。您可以通过 `bg` 命令来做到,后跟作业 ID(注意上面的 `jobs` 命令显示出来的 `[1]`,这就是作业 ID)。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ bg 1
|
||||||
|
[1]+ gedit &
|
||||||
|
```
|
||||||
|
|
||||||
|
这和直接使用 `gedit &` 启动程序效果差不多:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ gedit &
|
||||||
|
```
|
||||||
|
|
||||||
|
### 使用 kill
|
||||||
|
|
||||||
|
`kill` 命令提供信号的精确控制,允许您通过指定信号名或是信号数字为进程发送信号,后跟进程 ID 或是 PID。
|
||||||
|
|
||||||
|
我喜欢 `kill` 命令的一点是它也能够根据作业 ID 控制进程。让我们使用 `gedit &` 命令在后台开启 `gedit` 服务。假设通过 `jobs` 命令我得到了一个 `gedit` 的作业 ID,让我们为 `gedit` 发送 `SIGINT` 信号:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ kill -s SIGINT %1
|
||||||
|
```
|
||||||
|
|
||||||
|
作业 ID 需要使用 `%` 前缀,不然 `kill` 会将其视作 PID。
|
||||||
|
|
||||||
|
不明确指定信号,`kill` 仍然可以工作。此时,默认会发送能中断进程的 `SIGTERM` 信号。执行 `kill -l` 可以查看信号名列表,使用 `man kill` 命令阅读手册。
|
||||||
|
|
||||||
|
### 使用 killall
|
||||||
|
|
||||||
|
如果您不想使用特定的工作 ID 或者 PID,`killall` 允许您使用特定的进程名。中断 `gedit` 最简单的 `killall` 使用方式是:
|
||||||
|
|
||||||
|
```
|
||||||
|
$ killall gedit
|
||||||
|
```
|
||||||
|
|
||||||
|
它将终止所有名为 `gedit` 的进程。和 `kill` 相似,默认发送的信号是 `SIGTERM`。使用 `-I` 选项忽略进程名的大小写。
|
||||||
|
|
||||||
|
```
|
||||||
|
$ gedit &
|
||||||
|
[1] 14852
|
||||||
|
|
||||||
|
$ killall -I GEDIT
|
||||||
|
[1]+ Terminated gedit
|
||||||
|
```
|
||||||
|
|
||||||
|
查看手册学习更多 `killall` 命令选项(如 `-u`)。
|
||||||
|
|
||||||
|
### 使用 xkill
|
||||||
|
|
||||||
|
您是否遇见过播放器崩溃,比如 [VLC][2] 灰屏或挂起?现在你可以像上面一样获得进程的 PID 来杀掉它,或者使用 `xkill` 命令终止应用程序。
|
||||||
|
|
||||||
|
![Using xkill][3]
|
||||||
|
|
||||||
|
`xkill` 允许您使用鼠标关闭窗口。仅需在终端执行 `xkill` 命令,它将会改变鼠标光标为一个 **X** 或是一个小骷髅图标。在你想关闭的进程窗口上点击 **x**。小心使用 `xkill`,如手册描述的一致,它很危险。我已经提醒过您了!
|
||||||
|
|
||||||
|
参阅手册,了解上述命令更多信息。您还可以接续探索 `pkill` 和 `pgrep` 命令。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://opensource.com/article/18/5/how-kill-process-stop-program-linux
|
||||||
|
|
||||||
|
作者:[Sachin Patil][a]
|
||||||
|
选题:[lujun9972](https://github.com/lujun9972)
|
||||||
|
译者:[CYLeft](https://github.com/CYLeft)
|
||||||
|
校对:[wxy](https://github.com/wxy)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:https://opensource.com/users/psachin
|
||||||
|
[1]:https://wiki.gnome.org/Apps/Gedit
|
||||||
|
[2]:https://www.videolan.org/vlc/index.html
|
||||||
|
[3]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/xkill_gedit.png?itok=TBvMw0TN (Using xkill)
|
@ -1,3 +1,6 @@
|
|||||||
|
Translating by MjSeven
|
||||||
|
|
||||||
|
|
||||||
Top Linux tools for writers
|
Top Linux tools for writers
|
||||||
======
|
======
|
||||||
|
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
Translating by MjSeven
|
|
||||||
|
|
||||||
|
|
||||||
Linux vs. Unix: What's the difference?
|
|
||||||
======
|
|
||||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_twoforward.png?itok=exkV49ts)
|
|
||||||
|
|
||||||
If you are a software developer in your 20s or 30s, you've grown up in a world dominated by Linux. It has been a significant player in the data center for decades, and while it's hard to find definitive operating system market share reports, Linux's share of data center operating systems could be as high as 70%, with Windows variants carrying nearly all the remaining percentage. Developers using any major public cloud can expect the target system will run Linux. Evidence that Linux is everywhere has grown in recent years when you add in Android and Linux-based embedded systems in smartphones, TVs, automobiles, and many other devices.
|
|
||||||
|
|
||||||
Even so, most software developers, even those who have grown up during this venerable "Linux revolution" have at least heard of Unix. It sounds similar to Linux, and you've probably heard people use these terms interchangeably. Or maybe you've heard Linux called a "Unix-like" operating system.
|
|
||||||
|
|
||||||
So, what is this Unix? The caricatures speak of wizard-like "graybeards" sitting behind glowing green screens, writing C code and shell scripts, powered by old-fashioned, drip-brewed coffee. But Unix has a much richer history beyond those bearded C programmers from the 1970s. While articles detailing the history of Unix and "Unix vs. Linux" comparisons abound, this article will offer a high-level background and a list of major differences between these complementary worlds.
|
|
||||||
|
|
||||||
### Unix's beginnings
|
|
||||||
|
|
||||||
The history of Unix begins at AT&T Bell Labs in the late 1960s with a small team of programmers looking to write a multi-tasking, multi-user operating system for the PDP-7. Two of the most notable members of this team at the Bell Labs research facility were Ken Thompson and Dennis Ritchie. While many of Unix's concepts were derivative of its predecessor ([Multics][1]), the Unix team's decision early in the 1970s to rewrite this small operating system in the C language is what separated Unix from all others. At the time, operating systems were rarely, if ever, portable. Instead, by nature of their design and low-level source language, operating systems were tightly linked to the hardware platform for which they had been authored. By refactoring Unix on the C programming language, Unix could now be ported to many hardware architectures.
|
|
||||||
|
|
||||||
In addition to this new portability, which allowed Unix to quickly expand beyond Bell Labs to other research, academic, and even commercial uses, several key of the operating system's design tenets were attractive to users and programmers. For one, Ken Thompson's [Unix philosophy][2] became a powerful model of modular software design and computing. The Unix philosophy recommended utilizing small, purpose-built programs in combination to do complex overall tasks. Since Unix was designed around files and pipes, this model of "piping" inputs and outputs of programs together into a linear set of operations on the input is still in vogue today. In fact, the current cloud functions-as-a-service (FaaS)/serverless computing model owes much of its heritage to the Unix philosophy.
|
|
||||||
|
|
||||||
### Rapid growth and competition
|
|
||||||
|
|
||||||
Through the late 1970s and 80s, Unix became the root of a family tree that expanded across research, academia, and a growing commercial Unix operating system business. Unix was not open source software, and the Unix source code was licensable via agreements with its owner, AT&T. The first known software license was sold to the University of Illinois in 1975.
|
|
||||||
|
|
||||||
Unix grew quickly in academia, with Berkeley becoming a significant center of activity, given Ken Thompson's sabbatical there in the '70s. With all the activity around Unix at Berkeley, a new delivery of Unix software was born: the Berkeley Software Distribution, or BSD. Initially, BSD was not an alternative to AT&T's Unix, but an add-on with additional software and capabilities. By the time 2BSD (the Second Berkeley Software Distribution) arrived in 1979, Bill Joy, a Berkeley grad student, had added now-famous programs such as `vi` and the C shell (/bin/csh).
|
|
||||||
|
|
||||||
In addition to BSD, which became one of the most popular branches of the Unix family, Unix's commercial offerings exploded through the 1980s and into the '90s with names like HP-UX, IBM's AIX, Sun's Solaris, Sequent, and Xenix. As the branches grew from the original root, the "[Unix wars][3]" began, and standardization became a new focus for the community. The POSIX standard was born in 1988, as well as other standardization follow-ons via The Open Group into the 1990s.
|
|
||||||
|
|
||||||
Around this time AT&T and Sun released System V Release 4 (SVR4), which was adopted by many commercial vendors. Separately, the BSD family of operating systems had grown over the years, leading to some open source variations that were released under the now-familiar [BSD license][4] . This included FreeBSD, OpenBSD, and NetBSD, each with a slightly different target market in the Unix server industry. These Unix variants continue to have some usage today, although many have seen their server market share dwindle into the single digits (or lower). BSD may have the largest install base of any modern Unix system today. Also, every Apple Mac hardware unit shipped in recent history can be claimed by BSD, as its OS X (now macOS) operating system is a BSD-derivative.
|
|
||||||
|
|
||||||
While the full history of Unix and its academic and commercial variants could take many more pages, for the sake of our article focus, let's move on to the rise of Linux.
|
|
||||||
|
|
||||||
### Enter Linux
|
|
||||||
|
|
||||||
What we call the Linux operating system today is really the combination of two efforts from the early 1990s. Richard Stallman was looking to create a truly free and open source alternative to the proprietary Unix system. He was working on the utilities and programs under the name GNU, a recursive algorithm meaning "GNU's not Unix!" Although there was a kernel project underway, it turned out to be difficult going, and without a kernel, the free and open source operating system dream could not be realized. It was Linus Torvald's work—producing a working and viable kernel that he called Linux—that brought the complete operating system to life. Given that Linus was using several GNU tools (e.g., the GNU Compiler Collection, or [GCC][5]), the marriage of the GNU tools and the Linux kernel was a perfect match.
|
|
||||||
|
|
||||||
Linux distributions came to life with the components of GNU, the Linux kernel, MIT's X-Windows GUI, and other BSD components that could be used under the open source BSD license. The early popularity of distributions like Slackware and then Red Hat gave the "common PC user" of the 1990s access to the Linux operating system and, with it, many of the proprietary Unix system capabilities and utilities they used in their work or academic lives.
|
|
||||||
|
|
||||||
Because of the free and open source standing of all the Linux components, anyone could create a Linux distribution with a bit of effort, and soon the total number of distros reached into the hundreds. Today, [distrowatch.com][6] lists 312 unique Linux distributions available in some form. Of course, many developers utilize Linux either via cloud providers or by using popular free distributions like Fedora, Canonical's Ubuntu, Debian, Arch Linux, Gentoo, and many other variants. Commercial Linux offerings, which provide support on top of the free and open source components, became viable as many enterprises, including IBM, migrated from proprietary Unix to offering middleware and software solutions atop Linux. Red Hat built a model of commercial support around Red Hat Enterprise Linux, as did German provider SUSE with SUSE Linux Enterprise Server (SLES).
|
|
||||||
|
|
||||||
### Comparing Unix and Linux
|
|
||||||
|
|
||||||
So far, we've looked at the history of Unix and the rise of Linux and the GNU/Free Software Foundation underpinnings of a free and open source alternative to Unix. Let's examine the differences between these two operating systems that share much of the same heritage and many of the same goals.
|
|
||||||
|
|
||||||
From a user experience perspective, not very much is different! Much of the attraction of Linux was the operating system's availability across many hardware architectures (including the modern PC) and ability to use tools familiar to Unix system administrators and users.
|
|
||||||
|
|
||||||
Because of POSIX standards and compliance, software written on Unix could be compiled for a Linux operating system with a usually limited amount of porting effort. Shell scripts could be used directly on Linux in many cases. While some tools had slightly different flag/command-line options between Unix and Linux, many operated the same on both.
|
|
||||||
|
|
||||||
One side note is that the popularity of the macOS hardware and operating system as a platform for development that mainly targets Linux may be attributed to the BSD-like macOS operating system. Many tools and scripts meant for a Linux system work easily within the macOS terminal. Many open source software components available on Linux are easily available through tools like [Homebrew][7].
|
|
||||||
|
|
||||||
The remaining differences between Linux and Unix are mainly related to the licensing model: open source vs. proprietary, licensed software. Also, the lack of a common kernel within Unix distributions has implications for software and hardware vendors. For Linux, a vendor can create a device driver for a specific hardware device and expect that, within reason, it will operate across most distributions. Because of the commercial and academic branches of the Unix tree, a vendor might have to write different drivers for variants of Unix and have licensing and other concerns related to access to an SDK or a distribution model for the software as a binary device driver across many Unix variants.
|
|
||||||
|
|
||||||
As both communities have matured over the past decade, many of the advancements in Linux have been adopted in the Unix world. Many GNU utilities were made available as add-ons for Unix systems where developers wanted features from GNU programs that aren't part of Unix. For example, IBM's AIX offered an AIX Toolbox for Linux Applications with hundreds of GNU software packages (like Bash, GCC, OpenLDAP, and many others) that could be added to an AIX installation to ease the transition between Linux and Unix-based AIX systems.
|
|
||||||
|
|
||||||
Proprietary Unix is still alive and well and, with many major vendors promising support for their current releases well into the 2020s, it goes without saying that Unix will be around for the foreseeable future. Also, the BSD branch of the Unix tree is open source, and NetBSD, OpenBSD, and FreeBSD all have strong user bases and open source communities that may not be as visible or active as Linux, but are holding their own in recent server share reports, with well above the proprietary Unix numbers in areas like web serving.
|
|
||||||
|
|
||||||
Where Linux has shown a significant advantage over proprietary Unix is in its availability across a vast number of hardware platforms and devices. The Raspberry Pi, popular with hobbyists and enthusiasts, is Linux-driven and has opened the door for an entire spectrum of IoT devices running Linux. We've already mentioned Android devices, autos (with Automotive Grade Linux), and smart TVs, where Linux has large market share. Every cloud provider on the planet offers virtual servers running Linux, and many of today's most popular cloud-native stacks are Linux-based, whether you're talking about container runtimes or Kubernetes or many of the serverless platforms that are gaining popularity.
|
|
||||||
|
|
||||||
One of the most revealing representations of Linux's ascendancy is Microsoft's transformation in recent years. If you told software developers a decade ago that the Windows operating system would "run Linux" in 2016, most of them would have laughed hysterically. But the existence and popularity of the Windows Subsystem for Linux (WSL), as well as more recently announced capabilities like the Windows port of Docker, including LCOW (Linux containers on Windows) support, are evidence of the impact that Linux has had—and clearly will continue to have—across the software world.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://opensource.com/article/18/5/differences-between-linux-and-unix
|
|
||||||
|
|
||||||
作者:[Phil Estes][a]
|
|
||||||
选题:[lujun9972](https://github.com/lujun9972)
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]:https://opensource.com/users/estesp
|
|
||||||
[1]:https://en.wikipedia.org/wiki/Multics
|
|
||||||
[2]:https://en.wikipedia.org/wiki/Unix_philosophy
|
|
||||||
[3]:https://en.wikipedia.org/wiki/Unix_wars
|
|
||||||
[4]:https://en.wikipedia.org/wiki/BSD_licenses
|
|
||||||
[5]:https://en.wikipedia.org/wiki/GNU_Compiler_Collection
|
|
||||||
[6]:https://distrowatch.com/
|
|
||||||
[7]:https://brew.sh/
|
|
@ -1,74 +0,0 @@
|
|||||||
translating----geekpi
|
|
||||||
|
|
||||||
Best Websites For Programmers
|
|
||||||
======
|
|
||||||
![][1]
|
|
||||||
|
|
||||||
As a programmer, you will often find yourself as a permanent visitor of some websites. These can be tutorial, reference or forums websites. So here in this article let us have a look at the best websites for programmers.
|
|
||||||
|
|
||||||
### W3Schools
|
|
||||||
W3Schools is one of the best websites for beginners as well as experienced web developers to learn various programming languages. You can learn HTML5, CSS3, PHP. JavaScript, ASP etc.
|
|
||||||
|
|
||||||
More importantly, the website holds a lot of resources and references for web developers.
|
|
||||||
|
|
||||||
[![w3schools logo][2]][3]
|
|
||||||
|
|
||||||
You can quickly see various keywords and what they do. The website is very interactive and it allows you to try and practice the code in an embedded editor on the website itself. The website is one of those few that you will frequently visit as a web developer.
|
|
||||||
|
|
||||||
### GeeksforGeeks
|
|
||||||
GeeksforGeeks is a website mostly focused on computer science. It has a huge collection of algorithms, solutions and programming questions.
|
|
||||||
|
|
||||||
[![geeksforgeeks programming support][4]][5]
|
|
||||||
|
|
||||||
The website also has a good stock of most frequently asked questions in interviews. Since the website is more about computer science in general, you will find a solution to all programming solutions in most famous languages.
|
|
||||||
|
|
||||||
### TutorialsPoint
|
|
||||||
The de facto place for learning anything. Tutorials point has some of the finest and easiest tutorials that can teach you any programming language. What I really love about this website is that it is not just limited to generic programming languages.
|
|
||||||
|
|
||||||
![](http://www.theitstuff.com/wp-content/uploads/2017/12/tutorialspoint-programming-website.png)
|
|
||||||
|
|
||||||
You can find tutorials for almost all frameworks of all languages on the planet.
|
|
||||||
|
|
||||||
### StackOverflow
|
|
||||||
You probably already know this that stack is the place where programmers meet. You ever get stuck solving some of your code, just ask a question on stack and programmers from all over the internet will be there to help you.
|
|
||||||
|
|
||||||
[![stackoverflow linux programming website][6]][7]
|
|
||||||
|
|
||||||
The best part about stack overflow is that almost all questions get answered. You might as well receive answers from several different points of views of other programmers.
|
|
||||||
|
|
||||||
### HackerRank
|
|
||||||
Hacker rank is a website where you can participate in various coding competitions and check your competitive abilities.
|
|
||||||
|
|
||||||
[![hackerrank programming forums][8]][9]There are various contests organized in various programming languages and winning in them increases your score. This score can get you in the top ranks and increase your chance of getting noticed by some software company.
|
|
||||||
|
|
||||||
### Codebeautify
|
|
||||||
Since we are programmers, beauty isn’t something we look after. Many a time our code can be difficult to read by someone else. Codebeautify can make your code easy to read.
|
|
||||||
|
|
||||||
![](http://www.theitstuff.com/wp-content/uploads/2017/12/code-beautify-programming-forums.png)
|
|
||||||
|
|
||||||
The website has most languages that it can beautify. Alternatively, if you wish to make your code not readable by someone you can also do that.
|
|
||||||
|
|
||||||
So these were some of my picks for the best websites for programmers. If you frequently visit a site that I haven’t mentioned, do let me know in the comment section below.
|
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: http://www.theitstuff.com/best-websites-programmers
|
|
||||||
|
|
||||||
作者:[Rishabh Kandari][a]
|
|
||||||
选题:[lujun9972](https://github.com/lujun9972)
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]:http://www.theitstuff.com/author/reevkandari
|
|
||||||
[1]:http://www.theitstuff.com/wp-content/uploads/2017/12/best-websites-for-programmers.jpg
|
|
||||||
[2]:http://www.theitstuff.com/wp-content/uploads/2017/12/w3schools-logo-550x110.png
|
|
||||||
[3]:http://www.theitstuff.com/wp-content/uploads/2017/12/w3schools-logo.png
|
|
||||||
[4]:http://www.theitstuff.com/wp-content/uploads/2017/12/geeksforgeeks-programming-support-550x152.png
|
|
||||||
[5]:http://www.theitstuff.com/wp-content/uploads/2017/12/geeksforgeeks-programming-support.png
|
|
||||||
[6]:http://www.theitstuff.com/wp-content/uploads/2017/12/stackoverflow-linux-programming-website-550x178.png
|
|
||||||
[7]:http://www.theitstuff.com/wp-content/uploads/2017/12/stackoverflow-linux-programming-website.png
|
|
||||||
[8]:http://www.theitstuff.com/wp-content/uploads/2017/12/hackerrank-programming-forums-550x118.png
|
|
||||||
[9]:http://www.theitstuff.com/wp-content/uploads/2017/12/hackerrank-programming-forums.png
|
|
@ -0,0 +1,526 @@
|
|||||||
|
Command Line Tricks For Data Scientists • kade killary
|
||||||
|
======
|
||||||
|
|
||||||
|
![](https://i.imgur.com/0mzQMcB.png)
|
||||||
|
|
||||||
|
For many data scientists, data manipulation begins and ends with Pandas or the Tidyverse. In theory, there is nothing wrong with this notion. It is, after all, why these tools exist in the first place. Yet, these options can often be overkill for simple tasks like delimiter conversion.
|
||||||
|
|
||||||
|
Aspiring to master the command line should be on every developer’s list, especially data scientists. Learning the ins and outs of your shell will undeniably make you more productive. Beyond that, the command line serves as a great history lesson in computing. For instance, awk - a data-driven scripting language. Awk first appeared in 1977 with the help of [Brian Kernighan][1], the K in the legendary [K&R book][2]. Today, some near 50 years later, awk remains relevant with [new books][3] still appearing every year! Thus, it’s safe to assume that an investment in command line wizardry won’t depreciate any time soon.
|
||||||
|
|
||||||
|
### What We’ll Cover
|
||||||
|
|
||||||
|
* ICONV
|
||||||
|
* HEAD
|
||||||
|
* TR
|
||||||
|
* WC
|
||||||
|
* SPLIT
|
||||||
|
* SORT & UNIQ
|
||||||
|
* CUT
|
||||||
|
* PASTE
|
||||||
|
* JOIN
|
||||||
|
* GREP
|
||||||
|
* SED
|
||||||
|
* AWK
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### ICONV
|
||||||
|
|
||||||
|
File encodings can be tricky. For the most part files these days are all UTF-8 encoded. To understand some of the magic behind UTF-8, check out this [excellent video][4]. Nonetheless, there are times where we receive a file that isn’t in this format. This can lead to some wonky attempts at swapping the encoding schema. Here, `iconv` is a life saver. Iconv is a simple program that will take text in one encoding and output the text in another.
|
||||||
|
```
|
||||||
|
# Converting -f (from) latin1 (ISO-8859-1)
|
||||||
|
# -t (to) standard UTF_8
|
||||||
|
|
||||||
|
iconv -f ISO-8859-1 -t UTF-8 < input.txt > output.txt
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
* Useful options:
|
||||||
|
|
||||||
|
* `iconv -l` list all known encodings
|
||||||
|
* `iconv -c` silently discard characters that cannot be converted
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### HEAD
|
||||||
|
|
||||||
|
If you are a frequent Pandas user then `head` will be familiar. Often when dealing with new data the first thing we want to do is get a sense of what exists. This leads to firing up Pandas, reading in the data and then calling `df.head()` \- strenuous, to say the least. Head, without any flags, will print out the first 10 lines of a file. The true power of `head` lies in testing out cleaning operations. For instance, if we wanted to change the delimiter of a file from commas to pipes. One quick test would be: `head mydata.csv | sed 's/,/|/g'`.
|
||||||
|
```
|
||||||
|
# Prints out first 10 lines
|
||||||
|
|
||||||
|
head filename.csv
|
||||||
|
|
||||||
|
# Print first 3 lines
|
||||||
|
|
||||||
|
head -n 3 filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
* Useful options:
|
||||||
|
|
||||||
|
* `head -n` print a specific number of lines
|
||||||
|
* `head -c` print a specific number of bytes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### TR
|
||||||
|
|
||||||
|
Tr is analogous to translate. This powerful utility is a workhorse for basic file cleaning. An ideal use case is for swapping out the delimiters within a file.
|
||||||
|
```
|
||||||
|
# Converting a tab delimited file into commas
|
||||||
|
|
||||||
|
cat tab_delimited.txt | tr "\t" "," comma_delimited.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Another feature of `tr` is all the built in `[:class:]` variables at your disposal. These include:
|
||||||
|
```
|
||||||
|
[:alnum:] all letters and digits
|
||||||
|
[:alpha:] all letters
|
||||||
|
[:blank:] all horizontal whitespace
|
||||||
|
[:cntrl:] all control characters
|
||||||
|
[:digit:] all digits
|
||||||
|
[:graph:] all printable characters, not including space
|
||||||
|
[:lower:] all lower case letters
|
||||||
|
[:print:] all printable characters, including space
|
||||||
|
[:punct:] all punctuation characters
|
||||||
|
[:space:] all horizontal or vertical whitespace
|
||||||
|
[:upper:] all upper case letters
|
||||||
|
[:xdigit:] all hexadecimal digits
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
You can chain a variety of these together to compose powerful programs. The following is a basic word count program you could use to check your READMEs for overuse.
|
||||||
|
```
|
||||||
|
cat README.md | tr "[:punct:][:space:]" "\n" | tr "[:upper:]" "[:lower:]" | grep . | sort | uniq -c | sort -nr
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Another example using basic regex:
|
||||||
|
```
|
||||||
|
# Converting all upper case letters to lower case
|
||||||
|
|
||||||
|
cat filename.csv | tr '[A-Z]' '[a-z]'
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
* Useful options:
|
||||||
|
|
||||||
|
* `tr -d` delete characters
|
||||||
|
* `tr -s` squeeze characters
|
||||||
|
* `\b` backspace
|
||||||
|
* `\f` form feed
|
||||||
|
* `\v` vertical tab
|
||||||
|
* `\NNN` character with octal value NNN
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### WC
|
||||||
|
|
||||||
|
Word count. Its value is primarily derived from the `-l` flag, which will give you the line count.
|
||||||
|
```
|
||||||
|
# Will return number of lines in CSV
|
||||||
|
|
||||||
|
wc -l gigantic_comma.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
This tool comes in handy to confirm the output of various commands. So, if we were to convert the delimiters within a file and then run `wc -l` we would expect the total lines to be the same. If not, then we know something went wrong.
|
||||||
|
|
||||||
|
* Useful options:
|
||||||
|
|
||||||
|
* `wc -c` print the byte counts
|
||||||
|
* `wc -m` print the character counts
|
||||||
|
* `wc -L` print length of longest line
|
||||||
|
* `wc -w` print word counts
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### SPLIT
|
||||||
|
|
||||||
|
File sizes can range dramatically. And depending on the job, it could be beneficial to split up the file - thus `split`. The basic syntax for split is:
|
||||||
|
```
|
||||||
|
# We will split our CSV into new_filename every 500 lines
|
||||||
|
|
||||||
|
split -l 500 filename.csv new_filename_
|
||||||
|
|
||||||
|
# filename.csv
|
||||||
|
# ls output
|
||||||
|
# new_filename_aaa
|
||||||
|
# new_filename_aab
|
||||||
|
# new_filename_aac
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Two quirks are the naming convention and lack of file extensions. The suffix convention can be numeric via the `-d` flag. To add file extensions, you’ll need to run the following `find` command. It will change the names of ALL files within the current directory by appending `.csv`, so be careful.
|
||||||
|
```
|
||||||
|
find . -type f -exec mv '{}' '{}'.csv \;
|
||||||
|
|
||||||
|
# ls output
|
||||||
|
# filename.csv.csv
|
||||||
|
# new_filename_aaa.csv
|
||||||
|
# new_filename_aab.csv
|
||||||
|
# new_filename_aac.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
* Useful options:
|
||||||
|
|
||||||
|
* `split -b` split by certain byte size
|
||||||
|
* `split -a` generate suffixes of length N
|
||||||
|
* `split -x` split using hex suffixes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### SORT & UNIQ
|
||||||
|
|
||||||
|
The preceding commands are obvious: they do what they say they do. These two provide the most punch in tandem (i.e. unique word counts). This is due to `uniq`, which only operates on duplicate adjacent lines. Thus, the reason to `sort` before piping the output through. One interesting note is that `sort -u` will achieve the same results as the typical `sort file.txt | uniq` pattern.
|
||||||
|
|
||||||
|
Sort does have a sneakily useful ability for data scientists: the ability to sort an entire CSV based on a particular column.
|
||||||
|
```
|
||||||
|
# Sorting a CSV file by the second column alphabetically
|
||||||
|
|
||||||
|
sort -t"," -k2,2 filename.csv
|
||||||
|
|
||||||
|
# Numerically
|
||||||
|
|
||||||
|
sort -t"," -k2n,2 filename.csv
|
||||||
|
|
||||||
|
# Reverse order
|
||||||
|
|
||||||
|
sort -t"," -k2nr,2 filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The `-t` option here is to specify the comma as our delimiter. More often than not spaces or tabs are assumed. Furthermore, the `-k` flag is for specifying our key. The syntax for this is `-km,n`, with `m` being the starting field and `n` being the last.
|
||||||
|
|
||||||
|
* Useful options:
|
||||||
|
|
||||||
|
* `sort -f` ignore case
|
||||||
|
* `sort -r` reverse sort order
|
||||||
|
* `sort -R` scramble order
|
||||||
|
* `uniq -c` count number of occurrences
|
||||||
|
* `uniq -d` only print duplicate lines
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### CUT
|
||||||
|
|
||||||
|
Cut is for removing columns. To illustrate, if we only wanted the first and third columns.
|
||||||
|
```
|
||||||
|
cut -d, -f 1,3 filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
To select every column other than the first.
|
||||||
|
```
|
||||||
|
cut -d, -f 2- filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
In combination with other commands, `cut` serves as a filter.
|
||||||
|
```
|
||||||
|
# Print first 10 lines of column 1 and 3, where "some_string_value" is present
|
||||||
|
|
||||||
|
head filename.csv | grep "some_string_value" | cut -d, -f 1,3
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Finding out the number of unique values within the second column.
|
||||||
|
```
|
||||||
|
cat filename.csv | cut -d, -f 2 | sort | uniq | wc -l
|
||||||
|
|
||||||
|
# Count occurences of unique values, limiting to first 10 results
|
||||||
|
|
||||||
|
cat filename.csv | cut -d, -f 2 | sort | uniq -c | head
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### PASTE
|
||||||
|
|
||||||
|
Paste is a niche command with an interesting function. If you have two files that you need merged, and they are already sorted, `paste` has you covered.
|
||||||
|
```
|
||||||
|
# names.txt
|
||||||
|
adam
|
||||||
|
john
|
||||||
|
zach
|
||||||
|
|
||||||
|
# jobs.txt
|
||||||
|
lawyer
|
||||||
|
youtuber
|
||||||
|
developer
|
||||||
|
|
||||||
|
# Join the two into a CSV
|
||||||
|
|
||||||
|
paste -d ',' names.txt jobs.txt > person_data.txt
|
||||||
|
|
||||||
|
# Output
|
||||||
|
adam,lawyer
|
||||||
|
john,youtuber
|
||||||
|
zach,developer
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
For a more SQL_-esque variant, see below.
|
||||||
|
|
||||||
|
### JOIN
|
||||||
|
|
||||||
|
Join is a simplistic, quasi-tangential, SQL. The largest differences being that `join` will return all columns and matches can only be on one field. By default, `join` will try and use the first column as the match key. For a different result, the following syntax is necessary:
|
||||||
|
```
|
||||||
|
# Join the first file (-1) by the second column
|
||||||
|
# and the second file (-2) by the first
|
||||||
|
|
||||||
|
join -t"," -1 2 -2 1 first_file.txt second_file.txt
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The standard join is an inner join. However, an outer join is also viable through the `-a` flag. Another noteworthy quirk is the `-e` flag, which can be used to substitute a value if a missing field is found.
|
||||||
|
```
|
||||||
|
# Outer join, replace blanks with NULL in columns 1 and 2
|
||||||
|
# -o which fields to substitute - 0 is key, 1.1 is first column, etc...
|
||||||
|
|
||||||
|
join -t"," -1 2 -a 1 -a2 -e ' NULL' -o '0,1.1,2.2' first_file.txt second_file.txt
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Not the most user-friendly command, but desperate times, desperate measures.
|
||||||
|
|
||||||
|
* Useful options:
|
||||||
|
|
||||||
|
* `join -a` print unpairable lines
|
||||||
|
* `join -e` replace missing input fields
|
||||||
|
* `join -j` equivalent to `-1 FIELD -2 FIELD`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### GREP
|
||||||
|
|
||||||
|
Global search for a regular expression and print, or `grep`; likely, the most well known command, and with good reason. Grep has a lot of power, especially for finding your way around large codebases. Within the realm of data science, it acts as a refining mechanism for other commands. Although its standard usage is valuable as well.
|
||||||
|
```
|
||||||
|
# Recursively search and list all files in directory containing 'word'
|
||||||
|
|
||||||
|
grep -lr 'word' .
|
||||||
|
|
||||||
|
# List number of files containing word
|
||||||
|
|
||||||
|
grep -lr 'word' . | wc -l
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Count total number of lines containing word / pattern.
|
||||||
|
```
|
||||||
|
grep -c 'some_value' filename.csv
|
||||||
|
|
||||||
|
# Same thing, but in all files in current directory by file name
|
||||||
|
|
||||||
|
grep -c 'some_value' *
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Grep for multiple values using the or operator - `\|`.
|
||||||
|
```
|
||||||
|
grep "first_value\|second_value" filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
* Useful options
|
||||||
|
|
||||||
|
* `alias grep="grep --color=auto"` make grep colorful
|
||||||
|
* `grep -E` use extended regexps
|
||||||
|
* `grep -w` only match whole words
|
||||||
|
* `grep -l` print name of files with match
|
||||||
|
* `grep -v` inverted matching
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
### THE BIG GUNS
|
||||||
|
|
||||||
|
Sed and Awk are the two most powerful commands in this article. For brevity, I’m not going to go into exhausting detail about either. Instead, I will cover a variety of commands that prove their impressive might. If you want to know more, [there is a book][5] just for that.
|
||||||
|
|
||||||
|
### SED
|
||||||
|
|
||||||
|
At its core `sed` is a stream editor. It excels at substitutions, but can also be leveraged for all out refactoring.
|
||||||
|
|
||||||
|
The most basic `sed` command consists of `s/old/new/g`. This translates to search for old value, replace with new globally. Without the `/g` our command would terminate after the first occurrence.
|
||||||
|
|
||||||
|
To get a quick taste of the power lets dive into an example. In this scenario you’ve been given the following file:
|
||||||
|
```
|
||||||
|
balance,name
|
||||||
|
$1,000,john
|
||||||
|
$2,000,jack
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The first thing we may want to do is remove the dollar signs. The `-i` flag indicates in-place. The `''` is to indicate a zero-length file extension, thus overwriting our initial file. Ideally, you would test each of these individually and then output to a new file.
|
||||||
|
```
|
||||||
|
sed -i '' 's/\$//g' data.txt
|
||||||
|
|
||||||
|
# balance,name
|
||||||
|
# 1,000,john
|
||||||
|
# 2,000,jack
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Next up, the commas in our `balance` column values.
|
||||||
|
```
|
||||||
|
sed -i '' 's/\([0-9]\),\([0-9]\)/\1\2/g' data.txt
|
||||||
|
|
||||||
|
# balance,name
|
||||||
|
# 1000,john
|
||||||
|
# 2000,jack
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Lastly, Jack up and decided to quit one day. So, au revoir, mon ami.
|
||||||
|
```
|
||||||
|
sed -i '' '/jack/d' data.txt
|
||||||
|
|
||||||
|
# balance,name
|
||||||
|
# 1000,john
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
As you can see, `sed` packs quite a punch, but the fun doesn’t stop there.
|
||||||
|
|
||||||
|
### AWK
|
||||||
|
|
||||||
|
The best for last. Awk is much more than a simple command: it is a full-blown language. Of everything covered in this article, `awk` is by far the coolest. If you find yourself impressed there are loads of great resources - see [here][6], [here][7] and [here][8].
|
||||||
|
|
||||||
|
Common use cases for `awk` include:
|
||||||
|
|
||||||
|
* Text processing
|
||||||
|
* Formatted text reports
|
||||||
|
* Performing arithmetic operations
|
||||||
|
* Performing string operations
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Awk can parallel `grep` in its most nascent form.
|
||||||
|
```
|
||||||
|
awk '/word/' filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Or with a little more magic the combination of `grep` and `cut`. Here, `awk` prints the third and fourth column, tab separated, for all lines with our word. `-F,` merely changes our delimiter to a comma.
|
||||||
|
```
|
||||||
|
awk -F, '/word/ { print $3 "\t" $4 }' filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Awk comes with a lot of nifty variables built-in. For instance, `NF` \- number of fields - and `NR` \- number of records. To get the fifty-third record in a file:
|
||||||
|
```
|
||||||
|
awk -F, 'NR == 53' filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
An added wrinkle is the ability to filter based off of one or more values. The first example, below, will print the line number and columns for records where the first column equals string.
|
||||||
|
```
|
||||||
|
awk -F, ' $1 == "string" { print NR, $0 } ' filename.csv
|
||||||
|
|
||||||
|
# Filter based off of numerical value in second column
|
||||||
|
|
||||||
|
awk -F, ' $2 == 1000 { print NR, $0 } ' filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Multiple numerical expressions:
|
||||||
|
```
|
||||||
|
# Print line number and columns where column three greater
|
||||||
|
# than 2005 and column five less than one thousand
|
||||||
|
|
||||||
|
awk -F, ' $3 >= 2005 && $5 <= 1000 { print NR, $0 } ' filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Sum the third column:
|
||||||
|
```
|
||||||
|
awk -F, '{ x+=$3 } END { print x }' filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The sum of the third column, for values where the first column equals “something”.
|
||||||
|
```
|
||||||
|
awk -F, '$1 == "something" { x+=$3 } END { print x }' filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Get the dimensions of a file:
|
||||||
|
```
|
||||||
|
awk -F, 'END { print NF, NR }' filename.csv
|
||||||
|
|
||||||
|
# Prettier version
|
||||||
|
|
||||||
|
awk -F, 'BEGIN { print "COLUMNS", "ROWS" }; END { print NF, NR }' filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Print lines appearing twice:
|
||||||
|
```
|
||||||
|
awk -F, '++seen[$0] == 2' filename.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Remove duplicate lines:
|
||||||
|
```
|
||||||
|
# Consecutive lines
|
||||||
|
awk 'a !~ $0; {a=$0}']
|
||||||
|
|
||||||
|
# Nonconsecutive lines
|
||||||
|
awk '! a[$0]++' filename.csv
|
||||||
|
|
||||||
|
# More efficient
|
||||||
|
awk '!($0 in a) {a[$0];print}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Substitute multiple values using built-in function `gsub()`.
|
||||||
|
```
|
||||||
|
awk '{gsub(/scarlet|ruby|puce/, "red"); print}'
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
This `awk` command will combine multiple CSV files, ignoring the header and then append it at the end.
|
||||||
|
```
|
||||||
|
awk 'FNR==1 && NR!=1{next;}{print}' *.csv > final_file.csv
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Need to downsize a massive file? Welp, `awk` can handle that with help from `sed`. Specifically, this command breaks one big file into multiple smaller ones based on a line count. This one-liner will also add an extension.
|
||||||
|
```
|
||||||
|
sed '1d;$d' filename.csv | awk 'NR%NUMBER_OF_LINES==1{x="filename-"++i".csv";}{print > x}'
|
||||||
|
|
||||||
|
# Example: splitting big_data.csv into data_(n).csv every 100,000 lines
|
||||||
|
|
||||||
|
sed '1d;$d' big_data.csv | awk 'NR%100000==1{x="data_"++i".csv";}{print > x}'
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### CLOSING
|
||||||
|
|
||||||
|
The command line boasts endless power. The commands covered in this article are enough to elevate you from zero to hero in no time. Beyond those covered, there are many utilities to consider for daily data operations. [Csvkit][9], [xsv][10] and [q][11] are three of note. If you’re looking to take an even deeper dive into command line data science, then look no further than [this book][12]. It’s also available online [for free][13]!
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: http://kadekillary.work/post/cli-4-ds/
|
||||||
|
|
||||||
|
作者:[Kade Killary][a]
|
||||||
|
选题:[lujun9972](https://github.com/lujun9972)
|
||||||
|
译者:[译者ID](https://github.com/译者ID)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:http://kadekillary.work/authors/kadekillary
|
||||||
|
[1]:https://en.wikipedia.org/wiki/Brian_Kernighan
|
||||||
|
[2]:https://en.wikipedia.org/wiki/The_C_Programming_Language
|
||||||
|
[3]:https://www.amazon.com/Learning-AWK-Programming-cutting-edge-text-processing-ebook/dp/B07BT98HDS
|
||||||
|
[4]:https://www.youtube.com/watch?v=MijmeoH9LT4
|
||||||
|
[5]:https://www.amazon.com/sed-awk-Dale-Dougherty/dp/1565922255/ref=sr_1_1?ie=UTF8&qid=1524381457&sr=8-1&keywords=sed+and+awk
|
||||||
|
[6]:https://www.amazon.com/AWK-Programming-Language-Alfred-Aho/dp/020107981X/ref=sr_1_1?ie=UTF8&qid=1524388936&sr=8-1&keywords=awk
|
||||||
|
[7]:http://www.grymoire.com/Unix/Awk.html
|
||||||
|
[8]:https://www.tutorialspoint.com/awk/index.htm
|
||||||
|
[9]:http://csvkit.readthedocs.io/en/1.0.3/
|
||||||
|
[10]:https://github.com/BurntSushi/xsv
|
||||||
|
[11]:https://github.com/harelba/q
|
||||||
|
[12]:https://www.amazon.com/Data-Science-Command-Line-Time-Tested/dp/1491947853/ref=sr_1_1?ie=UTF8&qid=1524390894&sr=8-1&keywords=data+science+at+the+command+line
|
||||||
|
[13]:https://www.datascienceatthecommandline.com/
|
@ -1,164 +0,0 @@
|
|||||||
pinewall translating
|
|
||||||
|
|
||||||
A reading list for Linux and open source fans
|
|
||||||
======
|
|
||||||
|
|
||||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/books_stack_library_reading.jpg?itok=uulcS8Sw)
|
|
||||||
I recently asked our writer community to share with us what they're reading. These folks come from all different walks of life and roles in tech. What they have in common is that they are living and breathing Linux and open source every day.
|
|
||||||
|
|
||||||
Drink in this fantastic list. Many of them are free and available to download.
|
|
||||||
|
|
||||||
You may see books you've been meaning to get around to, books that are completely new to you, and some that feel like old friends.
|
|
||||||
|
|
||||||
We'd love to hear what you think of this list. Share with us in the comments below or on [Twitter][1] with #Linuxbooks #opensourcebooks.
|
|
||||||
|
|
||||||
### 17 books to add to your reading list
|
|
||||||
|
|
||||||
**Plus, a bonus fiction read.**
|
|
||||||
|
|
||||||
[23 Years of FreeDOS][2] by Jim Hall
|
|
||||||
|
|
||||||
Last year, the [FreeDOS][3] Project turned 23 years old. While there's nothing special about 23 years, the project decided to celebrate that milestone by sharing stories about how different people use or contribute to FreeDOS. The free, CC BY eBook is a collection of essays that describe the history of FreeDOS since 1994, and how people use FreeDOS today. (Recommendation and review by [Jim Hall][4])
|
|
||||||
|
|
||||||
[Eloquent JavaScript][5] by Marijn Haverbeke
|
|
||||||
|
|
||||||
This book teaches you how to write beautifully crafted programs using one of the most ubiquitous programming languages: [Javascript][6]. Learn the basics and advanced concepts of the language, and how to write programs that run in the browser or Node.js environment. The book also includes five fun projects so you can dive into actual programming while making a platform game or even writing your own programming language. (Recommendation and review by [Rahul Thakoor][7])
|
|
||||||
|
|
||||||
[_Forge Your Future with Open Source_][8] by VM (Vicky) Brasseur
|
|
||||||
|
|
||||||
If you're looking to contribute to open source, but you don't know how to start, this is the book for you. It covers how to find a project to join and how to make your first contributions. (Recommendation and review by [Ben Cotton][9])
|
|
||||||
|
|
||||||
[_Git for Teams_][10] by Emma Jane Hogbin Westby
|
|
||||||
|
|
||||||
Git is a widely-used version control system for individuals and teams alike, but its power means it can be complex. This book provides guidance on how to effectively use [git][11] in a team environment. For more, read our [in-depth review][12]. (Recommendation and review by [Ben Cotton][9])
|
|
||||||
|
|
||||||
[Getting to Yes][13] by Fisher, Ury, and Patton
|
|
||||||
|
|
||||||
The Harvard Negotiation Project, formed in the 1970s, was an academic effort involving economists, psychologists, sociologists, and political scientists to create a framework for negotiations which allows better outcomes for all involved. Their framework and techniques have been used in a diverse set of circumstances, including the Camp David Accords between Egypt and Israel in 1978.
|
|
||||||
|
|
||||||
Principled Negotiation involves understanding the real interests of the participants in a negotiation and using this knowledge to generate options acceptable to all. The same techniques can be used to resolve interpersonal issues, negotiations over cars and houses, discussions with insurance companies, and so on.
|
|
||||||
|
|
||||||
What does this have to do with open source software development? Everything in open source is a negotiation, in some sense. Submitting a bug report is outlining a position—that something does not work correctly—and requesting that someone reprioritize their work to fix it. A heated discussion on a mailing list over the right way to do something or a comment on a feature request is a negotiation, often with imperfect knowledge, about the scope and goals of the project.
|
|
||||||
|
|
||||||
Reframing these conversations as explorations, trying to understand why the other person is asking for something, and being transparent about the reasons why you believe another viewpoint to apply, can dramatically change your relationships and effectiveness working in an open source project. (Recommendation and review by [Dave Neary][14])
|
|
||||||
|
|
||||||
[Just for Fun: The Story of an Accidental Revolutionary][15] by Linus Torvalds et al.
|
|
||||||
|
|
||||||
Linux is an amazing and powerful operating system that spawned a movement to transparency and openness. And, the open source ethos that drives it flies in the face of traditional models of business and capital appreciation. In this book, learn about the genius of Linus the man and [Linux][16] the operating system. Get insight into the experiences that shaped Linus's life and fueled his transformation from a nerdy young man who enjoyed toying with his grandfather's clock to the master programmer of the world's predominant operating system. (Recommendation and review by [Don Watkins][17])
|
|
||||||
|
|
||||||
[Linux in a Month of Lunches][18] by Steven Ovadia
|
|
||||||
|
|
||||||
This book is designed to teach non-technical users how to use desktop [Linux][19] in about an hour a day. The book covers everything from choosing a desktop environment to installing software, to using Git. At the end of the month, readers can use Linux fulltime, replacing their other operating systems. (Recommendation and review by [Steven Ovadia][20])
|
|
||||||
|
|
||||||
[Linux in Action][21] by David Clinton
|
|
||||||
|
|
||||||
This book introduces serious Linux administration tools for anyone interested in getting more out of their tech, including IT professionals, developers, [DevOps][22] specialists, and more. Rather than teaching skills in isolation, the book is organized around practical projects like automating off-site data backups, securing a web server, and creating a VPN to safely connect an organization's resources. [Read more][23] by this author. (Recommendation and review by [David Clinton][24])
|
|
||||||
|
|
||||||
[Make: Linux for Makers][25] by Aaron Newcomb
|
|
||||||
|
|
||||||
This book is a must-read for anyone wanting to create and innovate with the [Raspberry Pi][26]. This book will have you up and operating your Raspberry Pi while at the same time understanding the nuances of it Raspbian Linux operating system. This is a masterful basic text that will help any maker unlock the potential of the Raspberry Pi. It’s concise and well written with a lot of fantastic illustrations and practical examples. (Recommendation by Jason Hibbets | Review by [Don Watkins][17])
|
|
||||||
|
|
||||||
[Managing Humans: Biting and Humorous Tales of a Software Engineering Manager][27] by Michael Lopp
|
|
||||||
|
|
||||||
Michael Lopp is better known by the nom de plume Rands, author of the popular blog [Rands in Repose][28]. This book is an edited, curated collection of blog posts, all related to the management of software development teams. What I love about the book and the blog, is that Rands starts from the fundamental principle that the most complex part of software development is human interactions. The book covers a range of topics about reading a group, understanding the personalities that make it up, and figuring out how to get the best out of everyone.
|
|
||||||
|
|
||||||
These things are universal, and as an open source community manager, I come across them all the time. How do you know if someone might be burning out? How do you run a good meeting? How do you evolve the culture of a project and team as it grows? How much process is the right amount? Regardless of the activity, questions like these arise all the time, and Rands's irreverent, humorous take is educational and entertaining. (Recommendation and review by [Dave Neary][14])
|
|
||||||
|
|
||||||
[Open Sources: Voices from the Open Source Revolution][29] (O'Reilly, 1999)
|
|
||||||
|
|
||||||
This book is a must-read for all open source enthusiasts. Linus Torvalds, Eric S. Raymond, Richard Stallman, Michael Tiemann, Tim O'Reilly, and other important figures in the open source movement share their thoughts on the forward momentum of [open source software][30]. (Recommendation by [Jim Hall][4] | Review by Jen Wike Huger)
|
|
||||||
|
|
||||||
[Producing Open Source Software: How to Run a Successful Free Software Project][31] by Karl Fogel
|
|
||||||
|
|
||||||
This book is for anyone who wants to build an open source community, is already building one, or wants to better understand trends in successful open source project community development. Karl Fogel analyzes and studies traits and characteristics of successful open source projects and how they have developed a community around the project. The book offers helpful advice to community managers (or want-to-be community managers) on how to navigate community development around a project. This is a rare book that takes a deeper look into open source community development and offers plenty of ingredients for success, but you have to take it and create the recipe for your project or community. (Recommendation and review by [Justin Flory][32])
|
|
||||||
|
|
||||||
[Programming with Robots][33] by Albert W. Schueller
|
|
||||||
|
|
||||||
This book introduces the basics of programming using the Lego Mindstorms NXT. Instead of writing abstract programs, learn how to program devices that can sense and interface with the physical world. Learn how software and hardware interact with each other while experimenting with sensors, motors or making music using code. (Recommendation and review by [Rahul Thakoor][7])
|
|
||||||
|
|
||||||
[The AWK programming language][34] by Alfred V. Aho, Brian W. Kernighan, and Peter J. Weinberger
|
|
||||||
|
|
||||||
This book, written by the creators of awk, follows a pattern similar to other books about *nix tools written by the original Bell Labs Unix team and published in the 1970s-1990s, explaining the rationale and intended use of awk in clear and compact prose, liberally sprinkled with examples that start simply and are further elaborated by the need to deal with more fully-detailed problems and edge cases. When published, the typical reader of this book would have been someone who had files of textual or numeric data that needed to be processed and transformed, and who wanted to be able to easily create lookup tables, apply regular expressions, react to structure changes within the input, apply mathematical transformations to numbers and easily format the output.
|
|
||||||
|
|
||||||
While that characterization still applies, today the book can also provide a window back into the time when the only user interface available was a terminal, when "modularity" created the ability to string together numerous single-purpose utility programs in shell scripts to create data transformation pipelines that crunched the data and produced the reports that everyone expected of computers. Today, awk should be a part of the operations toolbox, providing a fine ability to further process configuration and log files, and this book still provides a great introduction to that process. (Recommendation by [Jim Hall][4] | Review by [Chris Hermansen][35])
|
|
||||||
|
|
||||||
[Think Python: Think Like a Computer Scientist][36] by Allen Downey
|
|
||||||
|
|
||||||
This book about [Python][37] is part of [a series][38] that covers other languages as well, like Java, [Perl][39], etc. It moves past simple language syntax downloads and approaches the topic through the lens of how a problem solver would build a solution. It's both a great introductory guide to programming through a layering of concepts, but it can serve the dabbler who is looking to develop skills in an area such as classes or inheritance with chapters that have examples and exercises to then apply the skills taught. (Recommendation and review by [Steve Morris][40])
|
|
||||||
|
|
||||||
[Understanding Open Source and Free Software Licensing][41] (O'Reilly, 2004)
|
|
||||||
|
|
||||||
"This book bridges the gap between the open source vision and the practical implications of its legal underpinnings. If open source and free software licenses interest you, this book will help you understand them. If you're an open source/free software developer, this book is an absolute necessity." (Recommendation by [Jim Hall][4] | review from [Amazon][42])
|
|
||||||
|
|
||||||
[Unix Text Processing][43] by Dale Dougherty and Tim O'Reilly
|
|
||||||
|
|
||||||
This book was written in 1987 as an introduction to Unix systems and how writers could use Unix tools to do work. It's still a useful resource for beginners to learn the basics of the Unix shell, the vi editor, awk and shell scripts, and the nroff and troff typesetting system. The original edition is out of print, but O'Reilly has made the book available for free via their website. (Recommendation and review by [Jim Hall][4])
|
|
||||||
|
|
||||||
### Bonus: Fiction book
|
|
||||||
|
|
||||||
[Station Eleven][44] by Emily St. John Mandel
|
|
||||||
|
|
||||||
This story is set in a near future, twenty years after the earth's population has been decimated by a mysterious and deadly flu. We follow Kirsten Raymonde, a young woman who is traveling near the Great Lakes with a nomadic theatre group because "Survival is insufficient," as she makes her way through the post-apocalyptic world. It's a wonderful story, well worth reading.
|
|
||||||
|
|
||||||
What struck me about the book is how tenuous our relationship with technology actually is. In the Douglas Adams book "Mostly Harmless", there is a great line: "Left to his own devices he couldn't build a toaster. He could just about make a sandwich and that was it." This is the world of Kristin Raymonde. Everyone has been left to their own devices: There is no electricity because no one can work the power grid. No cars, no oil refineries.
|
|
||||||
|
|
||||||
There is a fascinating passage where one inventor has rigged up a generator with a bicycle and is trying to turn on a laptop, trying to see if there is still an internet. We discover the Museum of Civilization, stocked with objects which have no use, which has been left over from the old world: passports, mobile phones, credit cards, stilettoes.
|
|
||||||
|
|
||||||
All of the world's technology becomes useless. (Recommendation and review by [Dave Neary][14])
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://opensource.com/article/18/5/list-books-Linux-open-source
|
|
||||||
|
|
||||||
作者:[Jen Wike Huger][a]
|
|
||||||
选题:[lujun9972](https://github.com/lujun9972)
|
|
||||||
译者:[译者ID](https://github.com/译者ID)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]:https://opensource.com/users/remyd
|
|
||||||
[1]:https://twitter.com/opensourceway
|
|
||||||
[2]:http://www.freedos.org/ebook/
|
|
||||||
[3]:https://opensource.com/article/18/5/node/44116
|
|
||||||
[4]:https://opensource.com/users/jim-hall
|
|
||||||
[5]:https://eloquentjavascript.net/
|
|
||||||
[6]:https://opensource.com/article/18/5/node/32826
|
|
||||||
[7]:https://opensource.com/users/rahul27
|
|
||||||
[8]:https://pragprog.com/book/vbopens/forge-your-future-with-open-source
|
|
||||||
[9]:https://opensource.com/users/bcotton
|
|
||||||
[10]:http://gitforteams.com/
|
|
||||||
[11]:https://opensource.com/article/18/5/node/43741
|
|
||||||
[12]:https://opensource.com/business/15/11/git-for-teams-review
|
|
||||||
[13]:http://www.williamury.com/books/getting-to-yes/
|
|
||||||
[14]:https://opensource.com/users/dneary
|
|
||||||
[15]:http://a.co/749s27n
|
|
||||||
[16]:https://opensource.com/article/18/5/node/19796
|
|
||||||
[17]:https://opensource.com/users/don-watkins
|
|
||||||
[18]:https://manning.com/ovadia
|
|
||||||
[19]:https://opensource.com/article/18/5/node/42626
|
|
||||||
[20]:https://opensource.com/users/stevenov
|
|
||||||
[21]:https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&a_bid=4ca15fc9
|
|
||||||
[22]:https://opensource.com/article/18/5/node/44696
|
|
||||||
[23]:https://bootstrap-it.com/index.php/books/
|
|
||||||
[24]:https://opensource.com/users/dbclinton
|
|
||||||
[25]:https://www.makershed.com/products/make-linux-for-makers
|
|
||||||
[26]:https://opensource.com/article/18/5/node/35731
|
|
||||||
[27]:https://www.amazon.com/Managing-Humans-Humorous-Software-Engineering/dp/1484221575/ref=dp_ob_title_bk
|
|
||||||
[28]:http://randsinrepose.com/
|
|
||||||
[29]:https://www.oreilly.com/openbook/opensources/book/index.html
|
|
||||||
[30]:https://opensource.com/article/18/5/node/42001
|
|
||||||
[31]:https://producingoss.com/
|
|
||||||
[32]:https://opensource.com/users/justinflory
|
|
||||||
[33]:http://engineering.nyu.edu/gk12/amps-cbri/pdf/RobotC%20FTC%20Books/notesRobotC.pdf
|
|
||||||
[34]:https://archive.org/details/pdfy-MgN0H1joIoDVoIC7
|
|
||||||
[35]:https://opensource.com/users/clhermansen
|
|
||||||
[36]:http://greenteapress.com/thinkpython2/thinkpython2.pdf
|
|
||||||
[37]:https://opensource.com/article/18/5/node/40481
|
|
||||||
[38]:http://greenteapress.com/wp/
|
|
||||||
[39]:https://opensource.com/article/18/5/node/35141
|
|
||||||
[40]:https://opensource.com/users/smorris12
|
|
||||||
[41]:http://shop.oreilly.com/product/9780596005818.do
|
|
||||||
[42]:https://www.amazon.com/Understanding-Open-Source-Software-Licensing/dp/0596005814
|
|
||||||
[43]:http://www.oreilly.com/openbook/utp/
|
|
||||||
[44]:http://www.emilymandel.com/stationeleven.html
|
|
@ -1,136 +0,0 @@
|
|||||||
translating----geekpi
|
|
||||||
|
|
||||||
Using Stratis to manage Linux storage from the command line
|
|
||||||
======
|
|
||||||
|
|
||||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0)
|
|
||||||
|
|
||||||
As discussed in [Part 1][1] and [Part 2][2] of this series, Stratis is a volume-managing filesystem with functionality similar to that of [ZFS][3] and [Btrfs][4]. In this article, we'll walk through how to use Stratis on the command line.
|
|
||||||
|
|
||||||
### Getting Stratis
|
|
||||||
|
|
||||||
For non-developers, the easiest way to try Stratis now is in [Fedora 28][5].
|
|
||||||
|
|
||||||
Once you're running this, you can install the Stratis daemon and the Stratis command-line tool with:
|
|
||||||
```
|
|
||||||
# dnf install stratis-cli stratisd
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### Creating a pool
|
|
||||||
|
|
||||||
Stratis has three concepts: blockdevs, pools, and filesystems. Blockdevs are the block devices, such as a disk or a disk partition, that make up a pool. Once a pool is created, filesystems can be created from it.
|
|
||||||
|
|
||||||
Assuming you have a block device called `vdg` on your system that is not currently in use or mounted, you can create a Stratis pool on it with:
|
|
||||||
```
|
|
||||||
# stratis pool create mypool /dev/vdg
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
This assumes `vdg` is completely zeroed and empty. If it is not in use but has old data on it, it may be necessary to use `pool create`'s `- force` option. If it is in use, don't use it for Stratis.
|
|
||||||
|
|
||||||
If you want to create a pool from more than one block device, just list them all on the `pool create` command line. You can also add more blockdevs later using the `blockdev add-data` command. Note that Stratis requires blockdevs to be at least 1 GiB in size.
|
|
||||||
|
|
||||||
### Creating filesystems
|
|
||||||
|
|
||||||
Once you've created a pool called `mypool`, you can create filesystems from it:
|
|
||||||
```
|
|
||||||
# stratis fs create mypool myfs1
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
After creating a filesystem called `myfs1` from pool `mypool`, you can mount and use it, using the entries Stratis has created within /dev/stratis:
|
|
||||||
```
|
|
||||||
# mkdir myfs1
|
|
||||||
|
|
||||||
# mount /dev/stratis/mypool/myfs1 myfs1
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
The filesystem is now mounted on `myfs1` and ready to use.
|
|
||||||
|
|
||||||
### Snapshots
|
|
||||||
|
|
||||||
In addition to creating empty filesystems, you can also create a filesystem as a snapshot of an existing filesystem:
|
|
||||||
```
|
|
||||||
# stratis fs snapshot mypool myfs1 myfs1-experiment
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
After doing so, you could mount the new `myfs1-experiment`, which will initially contain the same file contents as `myfs1`, but could change as the filesystem is modified. Whatever changes you made to `myfs1-experiment` would not be reflected in `myfs1` unless you unmounted `myfs1` and destroyed it with:
|
|
||||||
```
|
|
||||||
# umount myfs1
|
|
||||||
|
|
||||||
# stratis fs destroy mypool myfs1
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
and then snapshotted the snapshot to recreate it and remounted it:
|
|
||||||
```
|
|
||||||
# stratis fs snapshot mypool myfs1-experiment myfs1
|
|
||||||
|
|
||||||
# mount /dev/stratis/mypool/myfs1 myfs1
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
### Getting information
|
|
||||||
|
|
||||||
Stratis can list pools on the system:
|
|
||||||
```
|
|
||||||
# stratis pool list
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
As filesystems have more data written to them, you will see the "Total Physical Used" value increase. Be careful when this approaches "Total Physical Size"; we're still working on handling this correctly.
|
|
||||||
|
|
||||||
To list filesystems within a pool:
|
|
||||||
```
|
|
||||||
# stratis fs list mypool
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
To list the blockdevs that make up a pool:
|
|
||||||
```
|
|
||||||
# stratis blockdev list mypool
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
These give only minimal information currently, but they will provide more in the future.
|
|
||||||
|
|
||||||
#### Destroying a pool
|
|
||||||
|
|
||||||
Once you have an idea of what Stratis can do, to destroy the pool, first make sure all filesystems created from it are unmounted and destroyed, then use the `pool destroy` command:
|
|
||||||
```
|
|
||||||
# umount myfs1
|
|
||||||
|
|
||||||
# umount myfs1-experiment (if you created it)
|
|
||||||
|
|
||||||
# stratis fs destroy mypool myfs1
|
|
||||||
|
|
||||||
# stratis fs destroy mypool myfs1-experiment
|
|
||||||
|
|
||||||
# stratis pool destroy mypool
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
`stratis pool list` should now show no pools.
|
|
||||||
|
|
||||||
That's it! For more information, please see the manpage: `man stratis`.
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://opensource.com/article/18/5/stratis-storage-linux-command-line
|
|
||||||
|
|
||||||
作者:[Andy Grover][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/agrover
|
|
||||||
[1]:https://opensource.com/article/18/4/stratis-easy-use-local-storage-management-linux
|
|
||||||
[2]:https://opensource.com/article/18/4/stratis-lessons-learned
|
|
||||||
[3]:https://en.wikipedia.org/wiki/ZFS
|
|
||||||
[4]:https://en.wikipedia.org/wiki/Btrfs
|
|
||||||
[5]:https://fedoraproject.org/wiki/Releases/28/Schedule
|
|
@ -1,3 +1,5 @@
|
|||||||
|
translating---geekpi
|
||||||
|
|
||||||
Set up zsh on your Fedora system
|
Set up zsh on your Fedora system
|
||||||
======
|
======
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
translating---geekpi
|
||||||
|
|
||||||
A Bittorrent Filesystem Based On FUSE
|
A Bittorrent Filesystem Based On FUSE
|
||||||
======
|
======
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
translating---geekp
|
||||||
|
|
||||||
The Source Code Line Counter And Analyzer
|
The Source Code Line Counter And Analyzer
|
||||||
======
|
======
|
||||||
|
|
||||||
|
@ -0,0 +1,190 @@
|
|||||||
|
How to load or unload a Linux kernel module
|
||||||
|
======
|
||||||
|
|
||||||
|
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_development_programming.png?itok=4OM29-82)
|
||||||
|
|
||||||
|
This article is excerpted from chapter 15 of [Linux in Action][1], published by Manning.
|
||||||
|
|
||||||
|
Linux manages hardware peripherals using kernel modules. Here's how that works.
|
||||||
|
|
||||||
|
A running Linux kernel is one of those things you don't want to upset. After all, the kernel is the software that drives everything your computer does. Considering how many details have to be simultaneously managed on a live system, it's better to leave the kernel to do its job with as few distractions as possible. But if it's impossible to make even small changes to the compute environment without rebooting the whole system, then plugging in a new webcam or printer could cause a painful disruption to your workflow. Having to reboot each time you add a device to get the system to recognize it is hardly efficient.
|
||||||
|
|
||||||
|
To create an effective balance between the opposing virtues of stability and usability, Linux isolates the kernel, but lets you add specific functionality on the fly through loadable kernel modules (LKMs). As shown in the figure below, you can think of a module as a piece of software that tells the kernel where to find a device and what to do with it. In turn, the kernel makes the device available to users and processes and oversees its operation.
|
||||||
|
|
||||||
|
![Kernel modules][3]
|
||||||
|
|
||||||
|
Kernel modules act as translators between devices and the Linux kernel.
|
||||||
|
|
||||||
|
There's nothing stopping you from writing your own module to support a device exactly the way you'd like it, but why bother? The Linux module library is already so robust that there's usually no need to roll your own. And the vast majority of the time, Linux will automatically load a new device's module without you even knowing it.
|
||||||
|
|
||||||
|
Still, there are times when, for some reason, it doesn't happen by itself. (You don't want to leave that hiring manager impatiently waiting for your smiling face to join the video conference job interview for too long.) To help things along, you'll want to understand a bit more about kernel modules and, in particular, how to find the actual module that will run your peripheral and then how to manually activate it.
|
||||||
|
|
||||||
|
### Finding kernel modules
|
||||||
|
|
||||||
|
By accepted convention, modules are files with a .ko (kernel object) extension that live beneath the `/lib/modules/` directory. Before you navigate all the way down to those files, however, you'll probably have to make a choice. Because you're given the option at boot time of loading one from a list of releases, the specific software needed to support your choice (including the kernel modules) has to exist somewhere. Well, `/lib/modules`/ is one of those somewheres. And that's where you'll find directories filled with the modules for each available Linux kernel release; for example:
|
||||||
|
```
|
||||||
|
$ ls /lib/modules
|
||||||
|
|
||||||
|
4.4.0-101-generic
|
||||||
|
|
||||||
|
4.4.0-103-generic
|
||||||
|
|
||||||
|
4.4.0-104-generic
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
In my case, the active kernel is the version with the highest release number (4.4.0-104-generic), but there's no guarantee that that'll be the same for you (kernels are frequently updated). If you're going to be doing some work with modules that you'd like to use on a live system, you need to be sure you've got the right directory tree.
|
||||||
|
|
||||||
|
`uname -r` (the `-r` specifies the kernel release number from within the system information that would normally be displayed):
|
||||||
|
```
|
||||||
|
$ uname -r
|
||||||
|
|
||||||
|
4.4.0-104-generic
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Good news: there's a reliable trick. Rather than identifying the directory by name and hoping you'll get the right one, use the system variable that always points to the name of the active kernel. You can invoke that variable using(thespecifies the kernel release number from within the system information that would normally be displayed):
|
||||||
|
|
||||||
|
With that information, you can incorporate `uname` into your filesystem references using a process known as command substitution. To navigate to the right directory, for instance, you'd add it to `/lib/modules`. To tell Linux that "uname" isn't a filesystem location, enclose the `uname` part in backticks, like this:
|
||||||
|
```
|
||||||
|
$ ls /lib/modules/`uname -r`
|
||||||
|
|
||||||
|
build modules.alias modules.dep modules.softdep
|
||||||
|
|
||||||
|
initrd modules.alias.bin modules.dep.bin modules.symbols
|
||||||
|
|
||||||
|
kernel modules.builtin modules.devname modules.symbols.bin
|
||||||
|
|
||||||
|
misc modules.builtin.bin modules.order vdso
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
You'll find most of the modules organized within their subdirectories beneath the `kernel/` directory. Take a few minutes to browse through those directories to get an idea of how things are arranged and what's available. The filenames usually give you a good idea of what you're looking at.
|
||||||
|
```
|
||||||
|
$ ls /lib/modules/`uname -r`/kernel
|
||||||
|
|
||||||
|
arch crypto drivers fs kernel lib mm
|
||||||
|
|
||||||
|
net sound ubuntu virt zfs
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
That's one way to locate kernel modules; actually, it's the quick and dirty way to go about it. But it's not the only way. If you want to get the complete set, you can list all currently loaded modules, along with some basic information, by using `lsmod`. The first column of this truncated output (there would be far too many to list here) is the module name, followed by the file size and number, and then the names of other modules on which each is dependent:
|
||||||
|
```
|
||||||
|
$ lsmod
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
vboxdrv 454656 3 vboxnetadp,vboxnetflt,vboxpci
|
||||||
|
|
||||||
|
rt2x00usb 24576 1 rt2800usb
|
||||||
|
|
||||||
|
rt2800lib 94208 1 rt2800usb
|
||||||
|
|
||||||
|
[...]
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
How many are far too many? Well, let's run `lsmod` once again, but this time piping the output to `wc -l` to get a count of the lines:
|
||||||
|
```
|
||||||
|
$ lsmod | wc -l
|
||||||
|
|
||||||
|
113
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Those are the loaded modules. How many are available in total? Running `modprobe -c` and counting the lines will give us that number:
|
||||||
|
```
|
||||||
|
$ modprobe -c | wc -l
|
||||||
|
|
||||||
|
33350
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
There are 33,350 available modules!?! It looks like someone's been working hard over the years to provide us with the software to run our physical devices.
|
||||||
|
|
||||||
|
Note: On some systems, you might encounter customized modules that are referenced either with their unique entries in the `/etc/modules` file or as a configuration file saved to `/etc/modules-load.d/`. The odds are that such modules are the product of local development projects, perhaps involving cutting-edge experiments. Either way, it's good to have some idea of what it is you're looking at.
|
||||||
|
|
||||||
|
That's how you find modules. Your next job is to figure out how to manually load an inactive module if, for some reason, it didn't happen on its own.
|
||||||
|
|
||||||
|
### Manually loading kernel modules
|
||||||
|
|
||||||
|
Before you can load a kernel module, logic dictates that you'll have to confirm it exists. And before you can do that, you'll need to know what it's called. Getting that part sometimes requires equal parts magic and luck and some help from of the hard work of online documentation authors.
|
||||||
|
|
||||||
|
I'll illustrate the process by describing a problem I ran into some time back. One fine day, for a reason that still escapes me, the WiFi interface on a laptop stopped working. Just like that. Perhaps a software update knocked it out. Who knows? I ran `lshw -c network` and was treated to this very strange information:
|
||||||
|
```
|
||||||
|
network UNCLAIMED
|
||||||
|
|
||||||
|
AR9485 Wireless Network Adapter
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Linux recognized the interface (the Atheros AR9485) but listed it as unclaimed. Well, as they say, "When the going gets tough, the tough search the internet." I ran a search for atheros ar9 linux module and, after sifting through pages and pages of five- and even 10-year-old results advising me to either write my own module or just give up, I finally discovered that (with Ubuntu 16.04, at least) a working module existed. Its name is ath9k.
|
||||||
|
|
||||||
|
Yes! The battle's as good as won! Adding a module to the kernel is a lot easier than it sounds. To double check that it's available, you can run `find` against the module's directory tree, specify `-type f` to tell Linux you're looking for a file, and then add the string `ath9k` along with a glob asterisk to include all filenames that start with your string:
|
||||||
|
```
|
||||||
|
$ find /lib/modules/$(uname -r) -type f -name ath9k*
|
||||||
|
|
||||||
|
/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k_common.ko
|
||||||
|
|
||||||
|
/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k.ko
|
||||||
|
|
||||||
|
/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k_htc.ko
|
||||||
|
|
||||||
|
/lib/modules/4.4.0-97-generic/kernel/drivers/net/wireless/ath/ath9k/ath9k_hw.ko
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Just one more step, load the module:
|
||||||
|
```
|
||||||
|
# modprobe ath9k
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
That's it. No reboots. No fuss.
|
||||||
|
|
||||||
|
Here's one more example to show you how to work with active modules that have become corrupted. There was a time when using my Logitech webcam with a particular piece of software would make the camera inaccessible to any other programs until the next system boot. Sometimes I needed to open the camera in a different application but didn't have the time to shut down and start up again. (I run a lot of applications, and getting them all in place after booting takes some time.)
|
||||||
|
|
||||||
|
Because this module is presumably active, using `lsmod` to search for the word video should give me a hint about the name of the relevant module. In fact, it's better than a hint: The only module described with the word video is uvcvideo (as you can see in the following):
|
||||||
|
```
|
||||||
|
$ lsmod | grep video
|
||||||
|
|
||||||
|
uvcvideo 90112 0
|
||||||
|
|
||||||
|
videobuf2_vmalloc 16384 1 uvcvideo
|
||||||
|
|
||||||
|
videobuf2_v4l2 28672 1 uvcvideo
|
||||||
|
|
||||||
|
videobuf2_core 36864 2 uvcvideo,videobuf2_v4l2
|
||||||
|
|
||||||
|
videodev 176128 4 uvcvideo,v4l2_common,videobuf2_core,videobuf2_v4l2
|
||||||
|
|
||||||
|
media 24576 2 uvcvideo,videodev
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
There was probably something I could have controlled for that was causing the crash, and I guess I could have dug a bit deeper to see if I could fix things the right way. But you know how it is; sometimes you don't care about the theory and just want your device working. So I used `rmmod` to kill the uvcvideo module and `modprobe` to start it up again all nice and fresh:
|
||||||
|
```
|
||||||
|
# rmmod uvcvideo
|
||||||
|
|
||||||
|
# modprobe uvcvideo
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Again: no reboots. No stubborn blood stains.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://opensource.com/article/18/5/how-load-or-unload-linux-kernel-module
|
||||||
|
|
||||||
|
作者:[David Clinto][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/dbclinton
|
||||||
|
[1]:https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&a_bid=4ca15fc9&chan=opensource
|
||||||
|
[2]:/file/397906
|
||||||
|
[3]:https://opensource.com/sites/default/files/uploads/kernels.png (Kernel modules)
|
@ -0,0 +1,374 @@
|
|||||||
|
How to Build an Amazon Echo with Raspberry Pi
|
||||||
|
======
|
||||||
|
|
||||||
|
![](https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-featured-image.jpg)
|
||||||
|
|
||||||
|
Many people today are using assistant software in their homes and offices to help with everyday tasks. There are many different models to purchase, but did you know you can build your own? [Amazon Developer][1] allows you to use the Alexa software to create your own [Amazon Echo][2] with [Raspberry Pi][3].
|
||||||
|
|
||||||
|
### Materials
|
||||||
|
|
||||||
|
For this project, you’ll need:
|
||||||
|
|
||||||
|
* The Raspberry Pi 3 or Pi 2 Model B and Micro-USB power cable
|
||||||
|
* Micro SD Card (Minimum 8 GB) – If you don’t have an operating system installed, there’s an easy-to-use operating system called NOOBS (New Out of the Box Software). The simplest way to get NOOBS is to buy an SD card with NOOBS pre-loaded.
|
||||||
|
* USB 2.0 Mini Microphone
|
||||||
|
* External speaker and 3.5mm audio cable
|
||||||
|
* USB Keyboard and Mouse and external HDMI Monitor
|
||||||
|
* Internet connection (Ethernet or WiFi)
|
||||||
|
* For a Pi 2 to connect to the Internet wirelessly, you need a WiFi Wireless Adapter. The Pi 3 has built-in WiFi.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
**Related** : [5 Essential Tips & Tricks to Personalize Your Amazon Echo][4]
|
||||||
|
|
||||||
|
### Register for an Amazon Developer account
|
||||||
|
|
||||||
|
If you need an Amazon Developer account, create a free one on their [page][1]. Read the AVS (Alexa Voice Service) Terms and Agreements [here][5].
|
||||||
|
|
||||||
|
![raspberrypi-echo-amazon-developer-account][6]
|
||||||
|
|
||||||
|
![raspberrypi-echo-amazon-developer-account][6]
|
||||||
|
|
||||||
|
Complete your profile information.
|
||||||
|
|
||||||
|
![raspberrypi-echo-register-profile-info][7]
|
||||||
|
|
||||||
|
![raspberrypi-echo-register-profile-info][7]
|
||||||
|
|
||||||
|
Read and accept the App Distribution Agreement.
|
||||||
|
|
||||||
|
![raspberrypi-echo-register-app-distribution-agree][8]
|
||||||
|
|
||||||
|
![raspberrypi-echo-register-app-distribution-agree][8]
|
||||||
|
|
||||||
|
Select whether you are choosing to monetize your apps.
|
||||||
|
|
||||||
|
![raspberrypi-echo-register-payments][9]
|
||||||
|
|
||||||
|
![raspberrypi-echo-register-payments][9]
|
||||||
|
|
||||||
|
### Create your device on Amazon Developer
|
||||||
|
|
||||||
|
After registering your Amazon Developer account, create an Alexa device and Security profile. Make careful note of the following parameters as you go through the setup – ProductID, ClientID, and ClientSecret, because you need to enter these again later.
|
||||||
|
|
||||||
|
From the top menu, select “Alexa Voice Service.”
|
||||||
|
|
||||||
|
![raspberrypi-echo-alexa-voice-service][10]
|
||||||
|
|
||||||
|
![raspberrypi-echo-alexa-voice-service][10]
|
||||||
|
|
||||||
|
The “Welcome to Developer” screen will appear.
|
||||||
|
|
||||||
|
![raspberrypi-echo-developer-welcome][11]
|
||||||
|
|
||||||
|
![raspberrypi-echo-developer-welcome][11]
|
||||||
|
|
||||||
|
The first screen asks about the product you are building.
|
||||||
|
|
||||||
|
1\. First, name your device.
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-name][12]
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-name][12]
|
||||||
|
|
||||||
|
2\. Next, type a Product ID with no spaces or special characters.
|
||||||
|
|
||||||
|
**Note** : You need this later. Record it somewhere.
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-id][13]
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-id][13]
|
||||||
|
|
||||||
|
3\. Select Alexa-Enabled Device for the product type.
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-type][14]
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-type][14]
|
||||||
|
|
||||||
|
4\. Alexa needs a companion app. Select yes for this question.
|
||||||
|
|
||||||
|
![raspberrypi-echo-companion-app][15]
|
||||||
|
|
||||||
|
![raspberrypi-echo-companion-app][15]
|
||||||
|
|
||||||
|
5\. Choose Wireless Speakers from the dropdown menu.
|
||||||
|
|
||||||
|
6\. Enter “Raspberry Pi Project on Github” into the description box. This is information for AVS and isn’t visible to others.
|
||||||
|
|
||||||
|
7\. Check both the “Touch-initiated” and “Hands-free” options.
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-options][16]
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-options][16]
|
||||||
|
|
||||||
|
8\. You can upload an image for your device, but let’s skip this step for now.
|
||||||
|
|
||||||
|
9\. Check “no” for commercial distribution and children’s product questions.
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-options-2][17]
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-options-2][17]
|
||||||
|
|
||||||
|
10\. Click “Next.”
|
||||||
|
|
||||||
|
### Create your security profile
|
||||||
|
|
||||||
|
On this page, you create a new LWA (Login with Amazon) security profile to identify the user data and security credentials with this project.
|
||||||
|
|
||||||
|
1\. Click “Create new profile.”
|
||||||
|
|
||||||
|
![raspberrypi-echo-lwa-security-profile2][18]
|
||||||
|
|
||||||
|
![raspberrypi-echo-lwa-security-profile2][18]
|
||||||
|
|
||||||
|
2\. Create a name for the profile. It could be something like, “Alexa Security Profile.”
|
||||||
|
|
||||||
|
![raspberrypi-echo-security-profile-name][19]
|
||||||
|
|
||||||
|
![raspberrypi-echo-security-profile-name][19]
|
||||||
|
|
||||||
|
3\. Type a description for the profile. You can choose “Alexa Security Profile Description.”
|
||||||
|
|
||||||
|
![raspberrypi-echo-security-description][20]
|
||||||
|
|
||||||
|
![raspberrypi-echo-security-description][20]
|
||||||
|
|
||||||
|
4\. Click “Next.”
|
||||||
|
|
||||||
|
5\. Amazon generates a Client ID and Client Secret for you. These are the other two values you need later. Keep them nearby.
|
||||||
|
|
||||||
|
![raspberrypi-echo-id-and-secret1][21]
|
||||||
|
|
||||||
|
![raspberrypi-echo-id-and-secret1][21]
|
||||||
|
|
||||||
|
6\. Enter your Allowed origins and Allowed return URLs. We’re setting up http and https routes for this project, so type the following into your “Allowed Origins” field — “<http://localhost:3000.”>
|
||||||
|
|
||||||
|
7\. Click “Add.”
|
||||||
|
|
||||||
|
8\. Type “<https://localhost:3000”> into the same box where you typed the first one.
|
||||||
|
|
||||||
|
![raspberrypi-echo-allowed-origins-2][22]
|
||||||
|
|
||||||
|
![raspberrypi-echo-allowed-origins-2][22]
|
||||||
|
|
||||||
|
9\. Click “Add” again.
|
||||||
|
|
||||||
|
10\. Do the same thing to the Allowed Return URLs, except enter the following two URLs:
|
||||||
|
|
||||||
|
11\. The page should look like this before you click Finish. Make sure none of your URLs are still in the field where you typed them. They are displayed on a grey background after you add them.
|
||||||
|
|
||||||
|
![raspberrypi-echo-all-origins][23]
|
||||||
|
|
||||||
|
![raspberrypi-echo-all-origins][23]
|
||||||
|
|
||||||
|
12\. Once you click “Finish,” this screen appears. Your project has been created and is ready to install.
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-screen][24]
|
||||||
|
|
||||||
|
![raspberrypi-echo-product-screen][24]
|
||||||
|
|
||||||
|
### Clone the Alexa sample app
|
||||||
|
|
||||||
|
1\. Open Terminal.
|
||||||
|
|
||||||
|
![raspberrypi-echo-open-terminal2][25]
|
||||||
|
|
||||||
|
![raspberrypi-echo-open-terminal2][25]
|
||||||
|
|
||||||
|
2\. Type the following:
|
||||||
|
```
|
||||||
|
cd Desktop
|
||||||
|
git clone https://github.com/alexa/alexa-avs-sample-app.git
|
||||||
|
```
|
||||||
|
|
||||||
|
### Update the install script by adding your credentials
|
||||||
|
|
||||||
|
Before you run the install script, update the script with the credentials that you recorded from Amazon — ProductID, ClientID, ClientSecret.
|
||||||
|
|
||||||
|
1\. Type the following in Terminal:
|
||||||
|
```
|
||||||
|
cd ~/Desktop/alexa-avs-sample-app
|
||||||
|
nano automated_install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
2\. When it runs, this screen appears. Use the arrows on your keyboard to navigate, and replace the fields for ProductID, ClientID, and ClientSecret with your values.
|
||||||
|
|
||||||
|
![raspberrypi-echo-insert-device-data][26]
|
||||||
|
|
||||||
|
![raspberrypi-echo-insert-device-data][26]
|
||||||
|
|
||||||
|
The changes should look like this:
|
||||||
|
```
|
||||||
|
ProductID="Your Device Name"
|
||||||
|
ClientID="amzn.xxxxx.xxxxxxxxx"
|
||||||
|
ClientSecret="4e8cb14xxxxxxxxxxxxxxxxxxxxxxxxxxxxx6b4f9"
|
||||||
|
```
|
||||||
|
|
||||||
|
3\. Type Ctrl + X to exit the script. Type Y and then Enter to save your changes.
|
||||||
|
|
||||||
|
### Run the install script
|
||||||
|
|
||||||
|
To run the script, open Terminal and run the following commands.
|
||||||
|
```
|
||||||
|
cd ~/Desktop/alexa-avs-sample-app
|
||||||
|
. automated_install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
While this script is running, you will be asked to answer some simple questions. These are to make sure you’ve completed all of the necessary setup on Amazon before you install the program.
|
||||||
|
|
||||||
|
![raspberrypi-echo-setup-questions][27]
|
||||||
|
|
||||||
|
![raspberrypi-echo-setup-questions][27]
|
||||||
|
|
||||||
|
The installation is about thirty minutes, so go grab a snack.
|
||||||
|
|
||||||
|
When installed correctly, your terminal window will look like the following image.
|
||||||
|
|
||||||
|
![raspberrypi-echo-end-install2][28]
|
||||||
|
|
||||||
|
![raspberrypi-echo-end-install2][28]
|
||||||
|
|
||||||
|
### The Three Terminals
|
||||||
|
|
||||||
|
You must complete three steps to run the Alexa app. Each of them must run in a separate Terminal window, and you must do them in the correct order.
|
||||||
|
|
||||||
|
There were some programs that I needed but didn’t have. I installed these programs as I went. In case you have the same problem, I included a side note about this in each step.
|
||||||
|
|
||||||
|
#### Terminal 1
|
||||||
|
|
||||||
|
This window runs the web service to authorize your app with AVS (Alexa Voice Service)
|
||||||
|
|
||||||
|
Open Terminal and type in the following commands:
|
||||||
|
```
|
||||||
|
cd ~/Desktop/alexa-avs-sample-app/samples
|
||||||
|
cd companionService && npm start
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note** : npm is a package manager for the JavaScript programming language. If it is not available when you run the command, you can get it [here][29].
|
||||||
|
|
||||||
|
When the scripts finish, the window looks like this, showing that Pi is listening on port 3000.
|
||||||
|
|
||||||
|
![raspberrypi-echo-port-3000][30]
|
||||||
|
|
||||||
|
![raspberrypi-echo-port-3000][30]
|
||||||
|
|
||||||
|
Don’t close this window. It needs to remain open while completing the next steps.
|
||||||
|
|
||||||
|
#### Terminal 2
|
||||||
|
|
||||||
|
This window communicates with AVS.
|
||||||
|
|
||||||
|
Type the following into another Terminal window.
|
||||||
|
```
|
||||||
|
cd ~/Desktop/alexa-avs-sample-app/samples
|
||||||
|
cd javaclient && mvn exec:exec
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note** : mvn is short for Apache Maven. If you don’t have it, click [here][31] to get started.
|
||||||
|
|
||||||
|
When you run the client, a dialog box appears saying, “Please register your device by …”
|
||||||
|
|
||||||
|
Click Yes.
|
||||||
|
|
||||||
|
![raspberrypi-echo-open-site][32]
|
||||||
|
|
||||||
|
![raspberrypi-echo-open-site][32]
|
||||||
|
|
||||||
|
With some browsers, you’ll get a warning that the connection is not safe. Dismiss this by clicking the “advanced” button. Then on the next screen, click on “Proceed to localhost (unsafe).”
|
||||||
|
|
||||||
|
Now, log into Amazon using your developer credentials.
|
||||||
|
|
||||||
|
The next screen asks for permission to use the security profile you created earlier for the device you are registering. Click Okay.
|
||||||
|
|
||||||
|
![raspberrypi-echo-use-security-profile][33]
|
||||||
|
|
||||||
|
![raspberrypi-echo-use-security-profile][33]
|
||||||
|
|
||||||
|
You will be redirected to a URL beginning with “<https://localhost:3000/authresponse”> that looks like the following image.
|
||||||
|
|
||||||
|
![raspberrypi-echo-device-tokens-ready][34]
|
||||||
|
|
||||||
|
![raspberrypi-echo-device-tokens-ready][34]
|
||||||
|
|
||||||
|
Go back to the open dialog box and click the OK button. The client is now able to accept requests from your Alexa device.
|
||||||
|
|
||||||
|
Keep the terminal open as well as the Voice Service Dialog box.
|
||||||
|
|
||||||
|
![raspberrypi-echo-voice-service-box][35]
|
||||||
|
|
||||||
|
![raspberrypi-echo-voice-service-box][35]
|
||||||
|
|
||||||
|
#### Terminal 3
|
||||||
|
|
||||||
|
This window installs the application that wakes up Alexa by using her wake word. Skip this if you don’t want to use voice to initiate Alexa.
|
||||||
|
|
||||||
|
Open a new terminal window and use one of the following commands to bring up a wake word engine using Sensory or KITT.AI.
|
||||||
|
|
||||||
|
To use the Sensory wake word engine, type:
|
||||||
|
```
|
||||||
|
cd ~/Desktop/alexa-avs-sample-app/samples
|
||||||
|
cd wakeWordAgent/src && ./wakeWordAgent -e sensory
|
||||||
|
```
|
||||||
|
|
||||||
|
To use KITT.AI’s wake word engine, type:
|
||||||
|
```
|
||||||
|
cd ~/Desktop/alexa-avs-sample-app/samples
|
||||||
|
cd wakeWordAgent/src && ./wakeWordAgent -e kitt_ai
|
||||||
|
```
|
||||||
|
|
||||||
|
### Test it out
|
||||||
|
|
||||||
|
Talk to Alexa by saying the wake word, “Alexa.” Wait for the beep before giving your command. For example, try it by saying, “Alexa.” Wait for the beep, and then ask, “What’s the time?”
|
||||||
|
|
||||||
|
If she responds correctly, you have a working Alexa device!
|
||||||
|
|
||||||
|
Check out Amazon’s Alexa [webpage][36] for more ideas. This Alexa can do everything an Echo can do!
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://www.maketecheasier.com/build-amazon-echo-with-raspberry-pi/
|
||||||
|
|
||||||
|
作者:[Tracey Rosenberger][a]
|
||||||
|
选题:[lujun9972](https://github.com/lujun9972)
|
||||||
|
译者:[译者ID](https://github.com/译者ID)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:https://www.maketecheasier.com/author/traceyrosenberger/
|
||||||
|
[1]:http://developer.amazon.com
|
||||||
|
[2]:https://www.amazon.com/dp/B06XCM9LJ4/?tag=maketecheas08-20
|
||||||
|
[3]:https://www.maketecheasier.com/tag/raspberry-pi
|
||||||
|
[4]:https://www.maketecheasier.com/essential-amazon-echo-tips-tricks/ (5 Essential Tips & Tricks to Personalize Your Amazon Echo)
|
||||||
|
[5]:https://developer.amazon.com/support/legal/alexa/alexa-voice-service/terms-and-agreements
|
||||||
|
[6]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-Amazon-developer-account.jpg (raspberrypi-echo-amazon-developer-account)
|
||||||
|
[7]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-Register-Profile-info.jpg (raspberrypi-echo-register-profile-info)
|
||||||
|
[8]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-Register-App-Distribution-Agree.jpg (raspberrypi-echo-register-app-distribution-agree)
|
||||||
|
[9]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-Register-Payments.jpg (raspberrypi-echo-register-payments)
|
||||||
|
[10]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-Alexa-voice-service.jpg (raspberrypi-echo-alexa-voice-service)
|
||||||
|
[11]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-developer-welcome.jpg (raspberrypi-echo-developer-welcome)
|
||||||
|
[12]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-product-name.jpg (raspberrypi-echo-product-name)
|
||||||
|
[13]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-product-ID.jpg (raspberrypi-echo-product-id)
|
||||||
|
[14]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-product-type.jpg (raspberrypi-echo-product-type)
|
||||||
|
[15]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-companion-app.jpg (raspberrypi-echo-companion-app)
|
||||||
|
[16]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-product-options.jpg (raspberrypi-echo-product-options)
|
||||||
|
[17]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-product-options-2.jpg (raspberrypi-echo-product-options-2)
|
||||||
|
[18]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-LWA-Security-Profile2.jpg (raspberrypi-echo-lwa-security-profile2)
|
||||||
|
[19]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-security-profile-name.jpg (raspberrypi-echo-security-profile-name)
|
||||||
|
[20]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-security-description.jpg (raspberrypi-echo-security-description)
|
||||||
|
[21]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-ID-and-secret1.jpg (raspberrypi-echo-id-and-secret1)
|
||||||
|
[22]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-allowed-origins-2.jpg (raspberrypi-echo-allowed-origins-2)
|
||||||
|
[23]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-all-origins.jpg (raspberrypi-echo-all-origins)
|
||||||
|
[24]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-product-screen.jpg (raspberrypi-echo-product-screen)
|
||||||
|
[25]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-open-terminal2.jpg (raspberrypi-echo-open-terminal2)
|
||||||
|
[26]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-insert-device-data.jpg (raspberrypi-echo-insert-device-data)
|
||||||
|
[27]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-setup-questions.jpg (raspberrypi-echo-setup-questions)
|
||||||
|
[28]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-end-install2.jpg (raspberrypi-echo-end-install2)
|
||||||
|
[29]:https://www.npmjs.com/
|
||||||
|
[30]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-Port-3000.jpg (raspberrypi-echo-port-3000)
|
||||||
|
[31]:https://maven.apache.org/
|
||||||
|
[32]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-open-site.jpg (raspberrypi-echo-open-site)
|
||||||
|
[33]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-use-security-profile.jpg (raspberrypi-echo-use-security-profile)
|
||||||
|
[34]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-device-tokens-ready.jpg (raspberrypi-echo-device-tokens-ready)
|
||||||
|
[35]:https://www.maketecheasier.com/assets/uploads/2018/03/RaspberryPi-Echo-Voice-service-box.jpg (raspberrypi-echo-voice-service-box)
|
||||||
|
[36]:https://www.amazon.com/meet-alexa/b?ie=UTF8&node=16067214011&tag=maketecheas08-20
|
@ -0,0 +1,125 @@
|
|||||||
|
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
|
128
sources/tech/20180601 3 open source music players for Linux.md
Normal file
128
sources/tech/20180601 3 open source music players for Linux.md
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
3 open source music players for Linux
|
||||||
|
======
|
||||||
|
|
||||||
|
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/guitar_amp_music.jpg?itok=jZB_OMY7)
|
||||||
|
|
||||||
|
As I described [in my last article][1], when I'm using a Linux-based computer to listen to music, I pass that music through a dedicated digital-analog converter, or DAC. To make sure the bits in the music file get through to the DAC without any unnecessary fiddling on the part of intermediate software on my computer (like audio mixers), I like to aim the music player directly at the [hw interface][2] (or, if necessary, the plughw interface) that ALSA provides to the external equipment.
|
||||||
|
|
||||||
|
So, when I hear about a new music player, the first thing I do is figure out how to configure the output device. In the process of reviewing quite a few Linux-based music players, I'm beginning to see a pattern.
|
||||||
|
|
||||||
|
First, a sizable group of players depends on [GStreamer][3] to play the audio. As its website says, GStreamer is a multimedia framework that allows construction of arbitrary pipelines of media-processing components. In my case, [the alsasink plugin][4] can be used in a pipeline, like this:
|
||||||
|
```
|
||||||
|
gst-launch-1.0 -v uridecodebin uri=file:///path/to/my.flac ! audioconvert ! audioresample ! autoaudiosink
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
to play back the file `/path/to/my.flac` on the default ALSA audio output device. Note the use of the `audioresample` component in the pipeline—that's one of the things I don't want! Also, I don't want to use the ALSA default output—I want to select the device.
|
||||||
|
|
||||||
|
GStreamer-based music players vary in the configurability of their outputs. At the one extreme, players like [QuodLibet][5] provide the ability to precisely configure the output. At the other extreme, players like [Rhythmbox][6] use the default audio device, meaning—as far as I can tell, anyway—that mixing and resampling are going to happen. For example, the [PulseAudio Perfect Setup Guide][7] explains:
|
||||||
|
|
||||||
|
> Applications using the modern GStreamer media framework such as Rhythmbox or Totem can make use of the PulseAudio through gst-pulse, the PulseAudio plugin for GStreamer…
|
||||||
|
|
||||||
|
and then shows how to use `gconftool` to enable that:
|
||||||
|
```
|
||||||
|
gconftool -t string --set /system/gstreamer/0.10/default/audiosink pulsesink
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
So far, I've only found a few GStreamer-based music players that let me build the dedicated output connection I want: QuodLibet, [Guayadeque][8], and [Gmusicbrowser][9]. All three of these are great music players, but for my use—once configured—[I prefer Guayadeque][10].
|
||||||
|
|
||||||
|
Second, there is a different group of players that don't use GStreamer, instead taking a different route to getting data to the output device. A subgroup of these players are clients for [the MPD music server backend][11]. Of the players that use the MPD backend, [Cantata][12] is [my favorite, by far][13]. Of course, the nice thing about MPD being a server is that it can be controlled by other devices, such as Android-based phones or tablets. Therefore, for a music player hooked up to the home stereo or AV center, MPD is my go-to.
|
||||||
|
|
||||||
|
Of the non-MPD, non-GStreamer music players I've tried that support my use case, I really like [Goggles Music Manager][14].
|
||||||
|
|
||||||
|
With that background, let's take a look at some new (to me) players.
|
||||||
|
|
||||||
|
### Museeks music player
|
||||||
|
|
||||||
|
The [Museeks][15] music player is available on GitHub in source or binary (.deb, .AppImage,.rpm, amd64, or i386). Taking a quick look at the code, I see that Museeks is an Electron application, which I find kind of intriguing. The .deb installed without problems, and upon startup I was greeted with the Museeks user interface, which I find to be simple but attractive.
|
||||||
|
|
||||||
|
![](https://opensource.com/sites/default/files/uploads/museeks.png)
|
||||||
|
|
||||||
|
After clicking on the Audio tab, the only option I saw changes the playback rate, which is not of interest to me. After further online searching, I opened an issue on GitHub to ask about this and was encouraged by a quick and friendly response from Pierre de la Martinière saying he thought it interesting and that he would look into it. So, for now, without the ability to configure output, I'm going to put this otherwise interesting-looking player on pause.
|
||||||
|
|
||||||
|
### LPlayer music player
|
||||||
|
|
||||||
|
The [LPlayer][16] music player is also available on GitHub and as an Ubuntu PPA. I used the latter to install the current version, which proceeded without issue. LPlayer offers a very simple user interface: audio files (music or whatever) are loaded from the filesystem into the current playlist, reminiscent of [VLC][17]. I don't mind this kind of organization, but I like a more extensive, tag-based music browser. However, a lightweight player has its own charms, so I continued with the evaluation.
|
||||||
|
|
||||||
|
Here is LPlayer's main screen with two tracks loaded:
|
||||||
|
|
||||||
|
![](https://opensource.com/sites/default/files/uploads/lplayer.png)
|
||||||
|
|
||||||
|
The Settings control offers the playing track's current position, the playback speed, options to "remove silence" and "play continuously," and a graphical equalizer, but no output device configuration.
|
||||||
|
|
||||||
|
![](https://opensource.com/sites/default/files/uploads/lplayer_settings.png)
|
||||||
|
|
||||||
|
A bit of source code investigation showed that LPlayer uses GStreamer. I decided to contact the author, Lorenzo Carbonell, to see if he had any thoughts about the idea of configuring the GStreamer playback pipeline within the application. Until I hear back from him, I'll keep this little player on the shelf. (By the way, Linux fans, Sr. Carbonell has a pretty great-looking Spanish-language Linux blog, [El Atareao-Linux para Legos][18]).
|
||||||
|
|
||||||
|
### Elisa music player
|
||||||
|
|
||||||
|
According to the KDE community website, the [Elisa][19] music player is intended to provide "very good integration with the Plasma desktop of the KDE community without compromising the support for other platforms." One of these days, I need to set up a KDE desktop so I can try some of this stuff in the native environment, but that's not in the cards for this review.
|
||||||
|
|
||||||
|
I took a look at the [Try It][20] instructions to get an idea of how I might, well, try it. According to that page, my options were: 1) try a [Flatpak][21], 2) install ArchLinux and use the AUR available, or 3) install Fedora for which "the releases are usually packaged." Based on these options, I thought it was time I tried a Flatpak…
|
||||||
|
```
|
||||||
|
me@mymachine:~/Downloads$ sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||||
|
|
||||||
|
me@mymachine:~/Downloads$ sudo flatpak remote-add --if-not-exists kdeapps --from https://distribute.kde.org/kdeapps.flatpakrepo
|
||||||
|
|
||||||
|
flatpak install kdeapps org.kde.elisa
|
||||||
|
|
||||||
|
Required runtime for org.kde.elisa/x86_64/master (org.kde.Platform/x86_64/5.9) is not installed, searching...
|
||||||
|
|
||||||
|
Found in remote flathub, do you want to install it? [y/n]:
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Hmmm let's see, `org.kde.Platform`… maybe I don't want to bring all that in. I think I'm going to press pause on this player, too, until I can take the time to set up a KDE environment.
|
||||||
|
|
||||||
|
### Conclusions for this round
|
||||||
|
|
||||||
|
Well, really there aren't many, except that Museeks and LPlayer reinforce my impression that being able to pass music data to the DAC without tampering is not a primary design goal for a lot of Linux music players. This is too bad, really, because there are plenty of decent-to-excellent, low-cost DACs that are compatible with Linux and do a great job of converting those digits to sweet, sweet analog.
|
||||||
|
|
||||||
|
### Let's not forget the music
|
||||||
|
|
||||||
|
I've been shopping for music downloads again, this time on 7digital's Linux-friendly store. I picked up three great albums by [Fela Kuti][22], in CD-quality FLAC format: [Opposite People][23], [Roforofo Fight][24], and [Unnecessary Begging][25]. This man made so much great music! The sound quality on these files is generally quite decent, which is a nice treat. Opposite People dates back to 1977, Roforofo Fight to 1972, and Unnecessary Begging to 1982.
|
||||||
|
|
||||||
|
I also bought [Trentemøller][26]'s 2016 album, [Fixion][27]. I've liked his stuff since I first bumped into [The Last Resort][28]. This [video documentary][29] provides an interesting perspective on Trentemøller and his music, which is quite distinctive; I like his use of guitars, which can sometimes hint at '60s surfer music. The version on 7digital was available in 96KHz/24bit, so that's what I bought.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://opensource.com/article/18/6/open-source-music-players
|
||||||
|
|
||||||
|
作者:[Chris Hermansen][a]
|
||||||
|
选题:[lujun9972](https://github.com/lujun9972)
|
||||||
|
译者:[译者ID](https://github.com/译者ID)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:https://opensource.com/users/clhermansen
|
||||||
|
[1]:https://opensource.com/article/18/3/phono-preamplifier-project
|
||||||
|
[2]:https://en.wikipedia.org/wiki/Advanced_Linux_Sound_Architecture#Concepts
|
||||||
|
[3]:https://gstreamer.freedesktop.org/
|
||||||
|
[4]:https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-alsasink.html
|
||||||
|
[5]:https://quodlibet.readthedocs.io/en/latest/
|
||||||
|
[6]:https://help.gnome.org/users/rhythmbox/stable/
|
||||||
|
[7]:https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/PerfectSetup/
|
||||||
|
[8]:http://www.guayadeque.org/
|
||||||
|
[9]:https://gmusicbrowser.org/
|
||||||
|
[10]:https://opensource.com/article/16/12/soundtrack-open-source-music-players
|
||||||
|
[11]:https://www.musicpd.org/
|
||||||
|
[12]:https://github.com/CDrummond/cantata
|
||||||
|
[13]:https://opensource.com/article/17/8/cantata-music-linux
|
||||||
|
[14]:https://gogglesmm.github.io/
|
||||||
|
[15]:https://github.com/KeitIG/Museeks/releases/tag/0.9.4
|
||||||
|
[16]:https://github.com/atareao/lplayer
|
||||||
|
[17]:https://www.videolan.org/vlc/index.es.html
|
||||||
|
[18]:https://www.atareao.es/
|
||||||
|
[19]:https://community.kde.org/Elisa
|
||||||
|
[20]:https://community.kde.org/Elisa#Try_It
|
||||||
|
[21]:https://flatpak.org/
|
||||||
|
[22]:https://en.wikipedia.org/wiki/Fela_Kuti
|
||||||
|
[23]:https://youtu.be/PeH4xziCHQs
|
||||||
|
[24]:https://youtu.be/XvX_iNFcKho
|
||||||
|
[25]:https://www.youtube.com/watch?v=614ZdP8SIbg
|
||||||
|
[26]:http://www.trentemoller.com/
|
||||||
|
[27]:http://www.trentemoller.com/music/fixion-0
|
||||||
|
[28]:https://en.wikipedia.org/wiki/The_Last_Resort_(album)
|
||||||
|
[29]:https://youtu.be/avatsxJazA0
|
159
sources/tech/20180601 Get Started with Snap Packages in Linux.md
Normal file
159
sources/tech/20180601 Get Started with Snap Packages in Linux.md
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
Get Started with Snap Packages in Linux
|
||||||
|
======
|
||||||
|
|
||||||
|
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/snap-main_0.jpg?itok=RkPz0oWo)
|
||||||
|
Chances are you’ve heard about Snap packages. These universal packages were brought into the spotlight with the release of Ubuntu 16.04 and have continued to draw attention as a viable solution for installing applications on Linux. What makes Snap packages so attractive to the end user? The answer is really quite easy: Simplicity. In this article, I’ll answer some common questions that arise when learning about Snaps and show how to start using them.
|
||||||
|
|
||||||
|
Exactly what are Snap packages? And why are they needed? Considering there are already multiple ways to install software on Linux, doesn’t this complicate the issue? Not in the slightest. Snaps actually makes installing/updating/removing applications on Linux incredibly easy.
|
||||||
|
|
||||||
|
How does it accomplish this? Essentially, a Snap package is a self-contained application that bundles most of the libraries and runtimes (necessary to successfully run an application) into a single, universal package. Because of this, Snaps can be installed, updated, and reverted without affecting the rest of the host system, and without having to first install dependencies. Snap packages are also confined from the OS (via various security mechanisms), yet can still function as if it were installed by the standard means (exchanging data with the host OS and other installed applications).
|
||||||
|
|
||||||
|
Are Snaps challenging to work with? In a word, no. In fact, Snaps make short work of installing apps that might otherwise challenge your Linux admin skills. Since Snap packages are self-contained, you only need to install one package to get an app up and running.
|
||||||
|
|
||||||
|
Although Snap packages were created by Ubuntu developers, they can be installed on most modern Linux distributions. Because the necessary tool for Snap packages is installed on the latest releases of Ubuntu out of the box, I’m going to walk you through the process of installing and using Snap packages on Fedora. Once installed, using Snap is the same, regardless of distribution.
|
||||||
|
|
||||||
|
### Installation
|
||||||
|
|
||||||
|
The first thing you must do is install the Snap system, aka snapd. To do this on Fedora, open up the terminal window and issue the command:
|
||||||
|
```
|
||||||
|
sudo dnf install snapd
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The above command will catch any necessary dependencies and install the system for Snap. That’s all there is to is. You’re ready to install your first Snap package.
|
||||||
|
|
||||||
|
### Installing with Snap: Command-line edition
|
||||||
|
|
||||||
|
The first thing you’ll want to do is find out what packages are available to install via Snap. Although Snap has begun to gain significant momentum, not every application can be installed via Snap. Let’s say you want to install GIMP. First you might want to find out what GIMP-relate packages are available as Snaps. Back at the terminal window, issue the command:
|
||||||
|
```
|
||||||
|
sudo snap find gimp
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The command should report only one package available for GIMP (Figure 1).
|
||||||
|
|
||||||
|
|
||||||
|
![Snap][2]
|
||||||
|
|
||||||
|
Figure 1: GIMP is available to install via Snap.
|
||||||
|
|
||||||
|
[Used with permission][3]
|
||||||
|
|
||||||
|
To get a better idea as to what the find option can do for you, issue the command:
|
||||||
|
```
|
||||||
|
sudo snap find nextcloud
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The output of that command (Figure 2) will report Snap packages related to Nextcloud.
|
||||||
|
|
||||||
|
|
||||||
|
![searching][5]
|
||||||
|
|
||||||
|
Figure 2: Searching for Nextcloud-related Snap packages.
|
||||||
|
|
||||||
|
[Used with permission][3]
|
||||||
|
|
||||||
|
Let’s say you want to go ahead and install GIMP via Snap. To do this, issue the command:
|
||||||
|
```
|
||||||
|
sudo snap install gimp
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The above command will download and install the Snap package. After the command completes, you’ll find GIMP in your desktop menu, ready to use.
|
||||||
|
|
||||||
|
### Updating Snap packages
|
||||||
|
|
||||||
|
Once a Snap package is installed, it will not be updated by the normal method of system updating (via apt, yum, or dnf). To update a Snap package, the refresh option is used. Say you want to update GIMP, you would issue the command:
|
||||||
|
```
|
||||||
|
sudo snap refresh gimp
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
If an updated Snap package is available, it will be downloaded and installed. Say, however, you have a number of Snap packages installed, and you want to update them all. This is done with the command:
|
||||||
|
```
|
||||||
|
sudo snap refresh
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
The snapd system will check all installed Snap packages against what’s available. If there are newer versions, the installed Snap package will be updated. One thing to note is that Snap packages are automatically updated daily, so you don’t have to manually issue the refresh command, unless you want to do this manually.
|
||||||
|
|
||||||
|
### Listing installed Snap packages
|
||||||
|
|
||||||
|
What if you’re not sure which Snap packages you’ve installed? Easy. Issue the command sudo snap list and all of your installed Snap packages will be listed for you (Figure 3).
|
||||||
|
|
||||||
|
|
||||||
|
![installed packages][7]
|
||||||
|
|
||||||
|
Figure 3: Listing installed Snap packages.
|
||||||
|
|
||||||
|
[Used with permission][3]
|
||||||
|
|
||||||
|
### Removing Snap packages
|
||||||
|
|
||||||
|
Removing a Snap package is just as simple as installing. We’ll stick with our GIMP example. To remove GIMP, issue the command:
|
||||||
|
```
|
||||||
|
sudo snap remove gimp
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
One thing you’ll notice is that removing a Snap package takes significantly less time than uninstalling via the standard method (i.e., sudo apt remove gimp or sudo dnf remove gimp). In fact, on my test Fedora system, installing, updating, and removing GIMP was quite a bit faster than doing so with dnf.
|
||||||
|
|
||||||
|
### Installing with Snap: GUI edition
|
||||||
|
|
||||||
|
You can enable Snap support in GNOME Software with a quick dnf install command. That command is:
|
||||||
|
```
|
||||||
|
sudo dnf install gnome-software-snap
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Once the command finishes, reboot your system and open up GNOME Software. You will be prompted to enable third party repositories (Figure 4). Click Enable and Snap packages are now ready to be installed.
|
||||||
|
|
||||||
|
|
||||||
|
![Snap repo][9]
|
||||||
|
|
||||||
|
Figure 4: Enabling the Snap repositories in GNOME Software.
|
||||||
|
|
||||||
|
[Used with permission][3]
|
||||||
|
|
||||||
|
If you now search for GIMP, you will see two versions available. Click on one and if you see Snap Store as the source (Figure 5), you know that’s the Snap version of GIMP.
|
||||||
|
|
||||||
|
|
||||||
|
![installing Snap package][11]
|
||||||
|
|
||||||
|
Figure 5: Installing a Snap package through GNOME Software.
|
||||||
|
|
||||||
|
[Used with permission][3]
|
||||||
|
|
||||||
|
Although I cannot imagine a reason for doing so, you can install both the standard and Snap version of the package. You might find it difficult to know which is which, however. Just remember, if you use a mixture of Snap and non-Snap packages, you must update them separately (which, in the case of Snap packages, happens automatically).
|
||||||
|
|
||||||
|
### Get your Snap on
|
||||||
|
|
||||||
|
Snap packages are here to stay, of that there is no doubt. No matter if you administer or use Linux on the server or desktop, Snap packages help make that task significantly easier. Get your Snap on today and see if you don’t start defaulting to this universal package format, over the standard installation fare.
|
||||||
|
|
||||||
|
Learn more about Linux through the free ["Introduction to Linux" ][12] course from The Linux Foundation and edX.
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://www.linux.com/learn/intro-to-linux/2018/5/get-started-snap-packages-linux
|
||||||
|
|
||||||
|
作者:[Jack Wallen][a]
|
||||||
|
选题:[lujun9972](https://github.com/lujun9972)
|
||||||
|
译者:[译者ID](https://github.com/译者ID)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:https://www.linux.com/users/jlwallen
|
||||||
|
[1]:/files/images/snap1jpg
|
||||||
|
[2]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/snap_1.jpg?itok=QklXruAe (Snap)
|
||||||
|
[3]:/licenses/category/used-permission
|
||||||
|
[4]:/files/images/snap2jpg
|
||||||
|
[5]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/snap_2.jpg?itok=F-wxfikN (searching)
|
||||||
|
[6]:/files/images/snap3jpg
|
||||||
|
[7]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/snap_3.jpg?itok=xFMHy93a (installed packages)
|
||||||
|
[8]:/files/images/snap4jpg
|
||||||
|
[9]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/snap_4.jpg?itok=smr4xmUp (Snap repo)
|
||||||
|
[10]:/files/images/snap5jpg
|
||||||
|
[11]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/snap_5.jpg?itok=dK7U2Qfv (installing Snap package)
|
||||||
|
[12]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux
|
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
![](https://images.idgesg.net/images/article/2018/02/linux_security_vs_macos_and_windows_locks_data_thinkstock-100748607-large.jpg)
|
![](https://images.idgesg.net/images/article/2018/02/linux_security_vs_macos_and_windows_locks_data_thinkstock-100748607-large.jpg)
|
||||||
|
|
||||||
企业投入了大量时间、精力和金钱来保障系统的安全性。最强的安全意识可能就是有一个安全运营中心,肯定用上了防火墙以及反病毒软件,可能花费大量时间监控他们的网络,寻找可能表明违规的异常信号,就像 IDS、SIEM 和 NGFW 一样,他们部署了一个名副其实的防御阵列。
|
企业投入了大量时间、精力和金钱来保障系统的安全性。最强的安全意识可能就是有一个安全的网络运行中心,肯定用上了防火墙以及反病毒软件,可能花费大量时间监控他们的网络,寻找可能表明违规的异常信号,就像 IDS、SIEM 和 NGFW 一样,他们部署了一个名副其实的防御阵列。
|
||||||
|
|
||||||
然而又有多少人想过数字化操作的基础之一:部署在员工的个人电脑上的操作系统?当选择桌面操作系统时,安全性是一个考虑的因素吗?
|
然而又有多少人想过数字化操作的基础之一:部署在员工的个人电脑上的操作系统?当选择桌面操作系统时,安全性是一个考虑的因素吗?
|
||||||
|
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
Linux vs Unix:有什么不同?
|
||||||
|
=====
|
||||||
|
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_twoforward.png?itok=exkV49ts)
|
||||||
|
|
||||||
|
如果你是 20 多岁或 30 多岁的软件开发人员,那么你已经成长在一个由 Linux 主导的世界。数十年来,它一直是数据中心的重要参与者,尽管很难找到明确的操作系统市场份额报告,但 Linux 的数据中心操作系统份额可能高达 70%,而 Windows 及其变体几乎涵盖了所有剩余的百分比。使用任何主要公共云的开发人员可以预期目标系统将运行 Linux。近些年来,随着 Android 和基于 Linux 的嵌入式系统在智能手机,电视,汽车和其他设备中的应用,Linux 已经随处可见。
|
||||||
|
|
||||||
|
即便如此,大多数软件开发人员,甚至是那些在这场历史悠久的 “Linux 革命”中长大的软件开发人员,至少听过说 Unix。它听起来与 Linux 相似,你可能已经听到人们互换使用这些术语。或者你也许听说过 Linux 被称为“类 Unix ”操作系统。
|
||||||
|
|
||||||
|
那么,Unix 是什么?漫画中提到了像巫师一样留着“灰胡子”,坐在发光的绿色屏幕后面,写着 C 代码和 shell 脚本,受老式的、滴灌的咖啡提供动力。但是,Unix 的历史比上世纪 70 年代那些留着胡子的 C 程序员要丰富得多。虽然详细介绍 Unix 历史和 “Unix 与 Linux” 比较的文章比比皆是,但本文将提供高级背景和这些互补世界之间的主要区别的列表。
|
||||||
|
|
||||||
|
### Unix 的起源
|
||||||
|
|
||||||
|
Unix 的历史始于 20 世纪 60 年代后期的 AT&T 贝尔实验室,有一小组程序员希望为 PDP-7 编写一个多任务、多用户操作系统。贝尔实验室研究机构中最著名的两名成员是 Ken Thompson 和 Dennis Ritchie。尽管 Unix 的许多概念都是其前身([Multics][1])的衍生物,但 Unix 团队早在 70 年代就决定用 C 语言重写这个小型操作系统,这是将 Unix 与其他分离开来的原因。当时,操作系统很少,如果有的话,protable(to 校正者,这个 protable 不知道怎样翻译才好)。相反,由于他们的设计和底层语言的本质,操作系统与他们所编写的硬件平台紧密相关。通过 C 语言重构 Unix,Unix 现在可以移植到许多硬件体系结构中。
|
||||||
|
|
||||||
|
除了这种新的可移植性,之所以使得 Unix 迅速扩展到贝尔实验室以外的其他研究,学术甚至商业用途,是因为操作系统设计原则的几个关键点对用户和程序员都很有吸引力。首先是 Ken Thompson 的 [Unix哲学][2]成为模块化软件设计和计算的强大模型。Unix 哲学推荐使用小型的、专用的程序组合起来完成复杂的整体任务。由于 Unix 是围绕文件和管道设计的,因此这种“管道”模式的输入和输出程序的组合成一组线性操作的输入操作,现在仍然流行。事实上,目前的云功能即服务(FaaS)或无服务器计算模型归功于 Unix 哲学的许多传统。
|
||||||
|
|
||||||
|
### 快速增长和竞争
|
||||||
|
|
||||||
|
到 70 年代末和 80 年代,Unix 成为了一个家族的起源,它扩展了研究,学术和日益增长的商业 Unix 操作系统业务。Unix 不是开源软件,Unix 源代码可以通过与它的所有者 AT&T 达成协议来获得许可。第一个已知的软件许可证于 1975 年出售给 University of Illinois(伊利诺伊大学)。
|
||||||
|
|
||||||
|
Unix 在学术界迅速发展,由于 Ken Thompson 在 70 年代的休假期间,伯克利成为一个重要的活动中心。通过在伯克利的所有有关 Unix 活动,Unix 软件的一种新的交付方式诞生了:Berkeley Software Distribution 或 BSD。最初,BSD 不是 AT&T Unix 的替代品,而是一种添加类似于附加软件和功能。在 1979 年, 2BSD(第二伯克利软件发行版)出现时,伯克利研究生 Bill Joy 已经添加了现在知名的程序,例如 `vi` 和 C shell(/bin/csh)。
|
||||||
|
|
||||||
|
除了成为 Unix 家族中最受欢迎的分支之一的 BSD 之外,Unix 的商业产品在 20 世纪 80 年代和 90 年代爆发,其中包括 HP-UX, IBM 的 AIX, Sun 的 Solaris, Sequent 和 Xenix 等。随着分支从根源头发展壮大,“ [Unix 战争][3]”开始了,标准化成为社区的新焦点。POSIX 标准诞生于 1988 年,在 90 年代后,其他标准化后续工作也开始通过 The Open Group (to 校正者:这里是开源组织吗)进入。
|
||||||
|
|
||||||
|
在此期间,AT&T 和 Sun 发布了 System V Release 4(SVR4),许多商业供应商都采用了这一版本。另外,BSD 系列操作系统多年来一直在增长,导致一些开源的变体在现在熟悉的 [BSD许可证][4]下发布。这包括 FreeBSD, OpenBSD 和 NetBSD,每个 Unix 服务器行业的目标市场略有不同。这些 Unix 变体今天仍然有一些在使用,尽管很多人已经看到他们的服务器市场份额缩小到个位数字(或更低)。在当今的所有 Unix 系统中,BSD 可能拥有最大的安装基数。另外,BSD 声称每台 Apple Mac 硬件设备都可以申请,因为其 OS X(现在是 macOS)操作系统是 BSD 衍生产品。
|
||||||
|
|
||||||
|
虽然 Unix 的全部历史及其学术和商业变体可能需要更多的页面,但为了我们文章的重点,让我们来讨论 Linux 的兴起。
|
||||||
|
|
||||||
|
### 进入 Linux
|
||||||
|
|
||||||
|
今天我们所说的 Linux 操作系统实际上是 90 年代初期的两个努力的结合。Richard Stallman 希望创建一个真正的免费和开放源代码的专有 Unix 系统。他正在以 GNU 的名义开发实用程序和程序,它是一种递归算法,意思是“ GNU 不是 Unix!”(to 校正者,这点不太理解)虽然当时有一个内核项目正在进行,但事实证明这是一件很困难的事情,而且没有内核,自由和开源操作系统的梦想无法实现。这是 Linus Torvald 的工作 - 生产出一种可工作和可行的内核,他称之为 Linux -- 它将整个操作系统带入了生活。鉴于 Linus 使用了几个 GNU 工具(例如 GNU 编译器集合或 [GCC][5]),GNU 工具和 Linux 内核的结合是完美的搭配。
|
||||||
|
|
||||||
|
Linux 发行版采用了 GNU 的组件,Linux 内核,MIT 的 X-Windows GUI 以及可以在开源 BSD 许可下使用的其他 BSD 组件。像 Slackware 和 Red Hat 这样的发行版早期的流行给了 20 世纪 90 年代的“普通 PC 用户”一个机会进入 Linux 操作系统,并且让他们在工作和学术生活中使用许多特有的 Unix 系统功能和实用程序。
|
||||||
|
|
||||||
|
由于所有 Linux 组件都有自由和开放的源代码,任何人都可以通过一些努力来创建一个 Linux 发行版,所以不久后发行版的总数达到了数百个。今天,[distrowatch.com][6] 列出了 312 种独特的 Linux 发行版。当然,许多开发人员通过云提供商或使用流行的免费发行版来使用 Linux,如 Fedora, Canonical 的 Ubuntu, Debian, Arch Linux, Gentoo 和许多其他变体。随着包括 IBM 在内的许多企业从专有 Unix 迁移到 Linux 上并提供中间件和软件解决方案,商用 Linux 产品在免费和开源组件之上提供支持变得可行。红帽公司围绕 Red Hat Enterprise Linux(红帽企业版 Linux) 建立了商业支持模式,德国供应商 SUSE 使用 SUSE Linux Enterprise Server(SLES)也提供了这种模式。
|
||||||
|
|
||||||
|
### 比较 Unix 和 Linux
|
||||||
|
|
||||||
|
到目前为止,我们已经了解了 Unix 的历史以及 Linux 的兴起,以及 GNU/自由软件基金会对 Unix 的免费和开源替代品的支持。让我们来看看这两个操作系统之间的差异,它们有许多共同的传统和许多相同的目标。
|
||||||
|
|
||||||
|
从用户体验角度来看,两者差不多!Linux 的很大吸引力在于操作系统在许多硬件体系结构(包括现代 PC)上的可用性以及类似使用 Unix 系统管理员和用户熟悉的工具的能力。
|
||||||
|
|
||||||
|
由于 POSIX 的标准和合规性,在 Unix 上编写的软件可以针对 Linux 操作系统进行编译,通常只有少量的移植工作量。在很多情况下,Shell 脚本可以在 Linux 上直接使用。虽然一些工具在 Unix 和 Linux 之间有着略微不同的标志或命令行选项,但许多工具在两者上都是相同的。
|
||||||
|
|
||||||
|
一方面要注意的是,macOS 硬件和操作系统作为主要针对 Linux 的开发平台的流行可能归因于类似 BSD 的 macOS 操作系统。许多用于 Linux 系统的工具和脚本可以在 macOS 终端内轻松工作。Linux 上的许多开源软件组件都可以通过 [Homebrew][7] 等工具轻松获得。
|
||||||
|
|
||||||
|
Linux 和 Unix 之间的其他差异主要与许可模式有关:开源与专有许可软件。另外,在 Unix 发行版中缺少一个通用内核对软件和硬件供应商有影响。对于 Linux,供应商可以为特定的硬件设备创建设备驱动程序,并期望在合理的范围内,它可以在大多数发行版上运行。由于 Unix 家族的商业和学术分支,供应商可能必须为 Unix 的变体编写不同的驱动程序,并且需要许可和其他相关的权限才能访问 SDK 或软件的分发模型,以跨越多个二进制设备驱动程序的 Unix 变体。
|
||||||
|
|
||||||
|
随着这两个社区在过去十年中的成熟,Linux 的许多优点已经在 Unix 世界中被采用。当开发人员需要来自不属于 Unix 的 GNU 程序的功能时,许多 GNU 实用程序可作为 Unix 系统的附件提供。例如,IBM 的AIX为 Linux 应用程序提供了一个 AIX Toolbox,其中包含数百个 GNU 软件包(如 Bash, GCC, OpenLDAP 和许多其他软件包),这些软件包可添加到 AIX 安装包中以简化基于 Linux 和基于 Unix 的 AIX 系统。
|
||||||
|
|
||||||
|
Unix 仍然活着而且还不错,许多主要供应商承诺支持其当前版本,直到 2020 年。不言而喻,Unix 还会在可预见的将来一直出现。此外,Unix 的 BSD 分支是开源的,而 NetBSD, OpenBSD 和 FreeBSD 都有强大的用户基础和开源社区,它们可能不像 Linux 那样明显或活跃,但在最近的服务器报告中,它们远高于 Web 服务等领域的专有 Unix 数量。
|
||||||
|
|
||||||
|
Linux 已经显示出超越 Unix 的显著优势在于其在大量硬件平台和设备上的可用性。Raspberry Pi(树莓派)受到业余爱好者的欢迎,它是由 Linux 驱动的,为运行 Linux 的各种物联网设备打开了大门。我们已经提到了 Android 设备,汽车(包括 Automotive Grade Linux)和智能电视,其中 Linux 占有巨大的市场份额。这个星球上的每个云提供商都提供运行 Linux 的虚拟服务器,而且当今许多最受欢迎的本地云(to 校正者:cloud-native 这个词需要斟酌以下)堆栈都是基于 Linux 的,无论你是在谈论容器运行时还是 Kubernetes,或者是许多正在流行的无服务器平台。
|
||||||
|
|
||||||
|
其中一个最显著的代表 Linux 的优势是近年来微软的转变。如果你十年前告诉软件开发人员,Windows 操作系统将在 2016 年“运行 Linux”,他们中的大多数人会歇斯底里地大笑。 但是 Windows Linux 子系统(WSL)的存在和普及,以及最近宣布的诸如 Docker 的 Windows 端口,包括 LCOW(Windows 上的 Linux 容器)支持等功能都证明了 Linux 在整个软件世界中所产生的影响 - 而且显然还会继续存在。
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://opensource.com/article/18/5/differences-between-linux-and-unix
|
||||||
|
|
||||||
|
作者:[Phil Estes][a]
|
||||||
|
选题:[lujun9972](https://github.com/lujun9972)
|
||||||
|
译者:[MjSeven](https://github.com/MjSeven)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:https://opensource.com/users/estesp
|
||||||
|
[1]:https://en.wikipedia.org/wiki/Multics
|
||||||
|
[2]:https://en.wikipedia.org/wiki/Unix_philosophy
|
||||||
|
[3]:https://en.wikipedia.org/wiki/Unix_wars
|
||||||
|
[4]:https://en.wikipedia.org/wiki/BSD_licenses
|
||||||
|
[5]:https://en.wikipedia.org/wiki/GNU_Compiler_Collection
|
||||||
|
[6]:https://distrowatch.com/
|
||||||
|
[7]:https://brew.sh/
|
74
translated/tech/20180301 Best Websites For Programmers.md
Normal file
74
translated/tech/20180301 Best Websites For Programmers.md
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
程序员最佳网站
|
||||||
|
======
|
||||||
|
![][1]
|
||||||
|
|
||||||
|
作为程序员,你经常会发现自己是某些网站的永久访问者。它们可以是教程、参考或论坛。因此,在这篇文章中,让我们看看给程序员的最佳网站。
|
||||||
|
|
||||||
|
### W3Schools
|
||||||
|
W3Schools 是为初学者和有经验的 Web 开发人员学习各种编程语言的最佳网站之一。你可以学习 HTML5、CSS3、PHP、 JavaScript、ASP 等。
|
||||||
|
|
||||||
|
更重要的是,该网站为网页开发人员提供了大量资源和参考资料。
|
||||||
|
|
||||||
|
[![w3schools logo][2]][3]
|
||||||
|
|
||||||
|
你可以快速浏览各种关键字及其功能。该网站非常具有互动性,它允许你在网站本身的嵌入式编辑器中尝试和练习代码。该网站是你作为网页开发人员经常访问的少数网站之一。
|
||||||
|
|
||||||
|
### GeeksforGeeks
|
||||||
|
GeeksforGeeks 是一个主要专注于计算机科学的网站。它有大量的算法,解决方案和编程问题。
|
||||||
|
|
||||||
|
[![geeksforgeeks programming support][4]][5]
|
||||||
|
|
||||||
|
该网站也有很多面试中经常问到的问题。由于该网站更多地涉及计算机科学,因此你可以找到很多编程问题在大多数著名语言下的解决方案。
|
||||||
|
|
||||||
|
### TutorialsPoint
|
||||||
|
一个学习任何东西的地方。TutorialsPoint 有一些又好又简单的教程,它可以教你任何编程语言。我真的很喜欢这个网站,它不仅限于通用编程语言。
|
||||||
|
|
||||||
|
![](http://www.theitstuff.com/wp-content/uploads/2017/12/tutorialspoint-programming-website.png)
|
||||||
|
|
||||||
|
你可以在这里上找到几乎所有语言框架的教程。
|
||||||
|
|
||||||
|
### StackOverflow
|
||||||
|
你可能已经知道 StackOverflow 是遇到程序员的地方。你在代码中遇到问题,只要在 StackOverflow 问一个问题,来自互联网的程序员将会在那里帮助你。
|
||||||
|
|
||||||
|
[![stackoverflow linux programming website][6]][7]
|
||||||
|
|
||||||
|
关于 StackOverflow 最好的部分是几乎所有的问题都得到了答案。你可能会从其他程序员的几个不同观点获得答案。
|
||||||
|
|
||||||
|
### HackerRank
|
||||||
|
HackerRank 是一个你可以参与各种编码竞赛并检测你的竞争能力的网站。
|
||||||
|
|
||||||
|
[![hackerrank programming forums][8]][9]
|
||||||
|
|
||||||
|
这里有以各种编程语言举办的各种比赛,赢得比赛将增加你的分数。这个分数可以让你处于最高级别,并增加你获得一些软件公司注意的机会。
|
||||||
|
|
||||||
|
### Codebeautify
|
||||||
|
由于我们是程序员,所以美不是我们所关心的。很多时候,我们的代码很难被其他人阅读。Codebeautify 可以使你的代码易于阅读。
|
||||||
|
|
||||||
|
![](http://www.theitstuff.com/wp-content/uploads/2017/12/code-beautify-programming-forums.png)
|
||||||
|
|
||||||
|
该网站有大多数可以美化的语言。另外,如果你想让你的代码不能被某人读取,你也可以这样做。
|
||||||
|
|
||||||
|
这些是我选择的一些最好的程序员网站。如果你有经常访问的我没有提及的网站,请在下面的评论区让我知道。
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: http://www.theitstuff.com/best-websites-programmers
|
||||||
|
|
||||||
|
作者:[Rishabh Kandari][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]:http://www.theitstuff.com/author/reevkandari
|
||||||
|
[1]:http://www.theitstuff.com/wp-content/uploads/2017/12/best-websites-for-programmers.jpg
|
||||||
|
[2]:http://www.theitstuff.com/wp-content/uploads/2017/12/w3schools-logo-550x110.png
|
||||||
|
[3]:http://www.theitstuff.com/wp-content/uploads/2017/12/w3schools-logo.png
|
||||||
|
[4]:http://www.theitstuff.com/wp-content/uploads/2017/12/geeksforgeeks-programming-support-550x152.png
|
||||||
|
[5]:http://www.theitstuff.com/wp-content/uploads/2017/12/geeksforgeeks-programming-support.png
|
||||||
|
[6]:http://www.theitstuff.com/wp-content/uploads/2017/12/stackoverflow-linux-programming-website-550x178.png
|
||||||
|
[7]:http://www.theitstuff.com/wp-content/uploads/2017/12/stackoverflow-linux-programming-website.png
|
||||||
|
[8]:http://www.theitstuff.com/wp-content/uploads/2017/12/hackerrank-programming-forums-550x118.png
|
||||||
|
[9]:http://www.theitstuff.com/wp-content/uploads/2017/12/hackerrank-programming-forums.png
|
@ -0,0 +1,165 @@
|
|||||||
|
面向 Linux 和开源爱好者的书单
|
||||||
|
======
|
||||||
|
|
||||||
|
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/books_stack_library_reading.jpg?itok=uulcS8Sw)
|
||||||
|
最近我在作家社区征集分享大家正在读的书。大家生活阅历和工作岗位各不相同,共同点是每天都与 Linux 和开源打交道。
|
||||||
|
|
||||||
|
享受这份不可思议的书单吧,其中大部分是免费的,可以下载。
|
||||||
|
|
||||||
|
在书单中,你可能发现一直想读的书、完全陌生的书以及像老朋友一直的已经读过的书。
|
||||||
|
|
||||||
|
我们期待你给出对书单的看法,可以在分享在下方的评论区,也可以通过 #Linuxbooks 和 #opensourcebooks 主题词分享在 Twitter 上。
|
||||||
|
|
||||||
|
### 加入你书单的 17 本书
|
||||||
|
|
||||||
|
**文末,还附赠了一篇科幻小说作品。**
|
||||||
|
|
||||||
|
[_FreeDOS 的 23 年岁月_][2],作者 Jim Hall
|
||||||
|
|
||||||
|
从去年起,[FreeDOS][3] 项目已经 23 岁了。虽然在 23 年中并没有什么特殊事件,但该项目决定庆祝这个里程碑,形式为分享不同人群使用 FreeDOS 或对 FreeDOS 做出贡献的故事。这本以 CC BY 协议开源的书籍收录了一系列短文,描绘了 FreeDOS 从 1994 开始的历程,以及人们现在如何使用 FreeDOS。([Jim Hall][4] 推荐并评论)
|
||||||
|
|
||||||
|
[_JavaScript 编程精解_][5],作者 Marijn Haverbeke
|
||||||
|
|
||||||
|
这本书基于无处不在的编程语言 [Javascript][6],教你编写制作精美的程序。你可以学习语言的基本知识和高级特性,学习如何编写可在浏览器或 Node.js 环境中运行的程序。本书包含 5 个有趣的项目,例如制作游戏平台,甚至编写你自己的编程语言,在这过程中你会更加深入理解真实的编程。([Rahul Thakoor][7] 推荐并评论)
|
||||||
|
|
||||||
|
[_使用开源打造未来_][8],作者 VM (Vicky) Brasseur
|
||||||
|
|
||||||
|
如果你希望在开源领域做出贡献但无从下手,这本书会教会你。内容包括如何确定要加入的项目,以及如何做出你的首次贡献。([Ben Cotton][9] 推荐并评论)
|
||||||
|
|
||||||
|
[_Git 团队协作_][10],作者 Emma Jane Hogbin Westby
|
||||||
|
|
||||||
|
Git 是一款版本管理系统,被个人和团队广泛使用;但其强大的功能也意味着复杂性。这本书指导你如何在团队环境中有效地使用 [Git][11]。想了解更多信息,请参考我们的[深入评论][12]。([Ben Cotton][9] 推荐并评论)
|
||||||
|
|
||||||
|
|
||||||
|
[_谈判力_][13],作者 Fisher, Ury 及 Patton
|
||||||
|
|
||||||
|
哈佛谈判项目成立于 20 世纪七十年代,是一个经济学家、心理学家、社会学家和政治学者共同参与的学术项目,目标是建立一个让谈判各方都受益更多的谈判框架。他们的框架和技巧已经在各类场景发挥作用,其中包括 1978 年埃及与以色列之间的签订的<ruby>戴维营协议<rt>Camp David Accords</rt></ruby>。
|
||||||
|
|
||||||
|
<ruby>原则式谈判<rt>Principled Negotiation</rt></ruby> 包括理解谈判参与者的真实需求,以及基于该信息达成各方都可接受的条款。同样的技巧可以在处理人与人之间的纠纷、关于车辆与房屋的谈判以及与保险公司的商讨时发挥作用。
|
||||||
|
|
||||||
|
这与开源软件开发有什么联系呢?在某种意义上,开源领域中的一切都是谈判。提交漏洞报告就是指出某些代码工作不正常,让某些人放下手头工作并优先处理该漏洞。邮件列表中对完成某些工作的正确方式的激烈讨论或对功能请求的评论,都是一种关于项目范畴和目标的谈判,通常是在信息不充足情况下进行的。
|
||||||
|
|
||||||
|
将上述对话视为一种探索,试图理解为何其它人提出来某些需求,让其明白你为何持有另外的观点,可以让你在开源项目中显著地改善人际关系和提高工作效率。([Dave Neary][14] 推荐并评论)
|
||||||
|
|
||||||
|
[_只是为了好玩:Linux 之父 Linus Torvalds 自传_][15],作者 Linus Torvalds 等
|
||||||
|
|
||||||
|
Linux 是一款令人惊奇的、强力的操作系统,引发了关于透明和开放的运动。驱动 Linux 的开源思潮对传统商业和资本增值模型造成冲击。在本书中,你会了解到 Linus 本人及 [Linux][16] 操作系统的过人之处。洞悉那些改变 Linus 命运的经历,这些经历让他从一个喜欢折腾他祖父钟表的怪人,转变成编写全球主流操作系统 Linux 的大师。([Don Watkins][17] 推荐并评论)
|
||||||
|
|
||||||
|
|
||||||
|
[_1 个月速成 Linux_][18],作者 Steven Ovadia
|
||||||
|
|
||||||
|
这本书用于教会非技术领域的用户如何使用桌面版 [Linux][19],读者每天花费一小时即可。这本书覆盖面比较很广,包括选择桌面环境、安装软件以及如何使用 Git。阅读完这本书,你可以完全使用 Linux 替换掉其它操作系统。([Steven Ovadia][20] 推荐并评论)
|
||||||
|
|
||||||
|
|
||||||
|
[_Linux 实战_][21],作者 David Clinton
|
||||||
|
|
||||||
|
这本身介绍了不少 Linux 管理工具的干货,适用于想提升技术水平的人群,包括 IT 专家,开发者,[DevOps][22] 专家等。本书不是割裂地介绍各种技术,而是按照真实项目组织内容,例如异地备份自动化,Web 服务器安全加密以及搭建可以安全连接公司资源的 VPN 等。更多内容可以参考作者的[另一本书][23]。([David Clinton][24] 推荐并评论)
|
||||||
|
|
||||||
|
[_创客丛书: 为创客准备的 Linux_][25],作者 Aaron Newcomb
|
||||||
|
|
||||||
|
对于想通过 [Raspberry Pi][26] 创造和创新的人来说,这本书是必读的。这本书将领你入门,让你玩转你的 Raspberry Pi,同时帮你理解 Raspbian Linux 操作系统(与传统 Linux )的细微差别。书中文字巧妙又浅显,可以让任何阅读本书的创客解锁 Raspberry Pi 的潜力。文字简洁,编写精良,包含大量极好的阐述和实战案例。(Jason Hibbets 推荐,[Don Watkins][17] 评论)
|
||||||
|
|
||||||
|
[_人性管理:一个软件工程经理刺激诙谐的经历_][27] by Michael Lopp
|
||||||
|
|
||||||
|
Michael Lopp 是热门博客 [Rands 在休息][28]的作者,他的笔名 Rands 更为人熟知。这本书是在博客帖子的基础上修订集结而成,内容为软件开发团队的管理。Rands 的工作哲学为“软件开发中最复杂的部分是人际交往”,这是我对于本书和博客内容最欣赏的一点。本书涵盖一系列主题,包括分析一个团队,理解每个团队成员的个性以及设计如何让每个人都各尽所能。
|
||||||
|
|
||||||
|
这些主题适用面很广,作为一个开源社区管理者,我一直和这些事情打交道。如何得知某个成员已经精疲力尽?如何组织一个好的会议?如何在项目和团队扩大时形成项目和团队文化?如何判断流程是适度的?在开发之外,这类问题一直涌现出来;Rands 的不羁、诙谐的看法让人受教的同时给人感到快乐。([Dave Neary][14] 推荐并评论)
|
||||||
|
|
||||||
|
[_开源:来自开源革命的呐喊_][29] (O'Reilly, 1999)
|
||||||
|
|
||||||
|
对于开源狂热者而言,这本书是必读的。Linus Torvalds, Eric S. Raymond, Richard Stallman, Michael Tiemann, Tim O'Reilly 等开源运动中的领军人物分享他们对发展迅猛的[开源软件][30]运动的看法。([Jim Hall][4] 推荐,Jen Wike Huger 评论)
|
||||||
|
|
||||||
|
[_创作开源软件:如何运营一个成功的自由软件项目_][31],作者 Karl Fogel
|
||||||
|
|
||||||
|
这本书面向人群包括,期望建立或已经正在建立开源社区,或更好的理解成功开源项目社区的开发趋势。Karl Fogel 分析研究了成功开源项目的特点,以及它们如何围绕项目发展成社区。对于如何围绕项目发展社区,这本书为社区管理者(或致力于成为社区管理者的人)提供了建设性的建议。鲜有书籍可以(像本书这样)深入观察开源社区的发展并给出大量成功点子,但你仍需要结合你的项目和社区因地制宜的行动。([Justin Flory][32] 推荐并评论)
|
||||||
|
|
||||||
|
[_机器人编程_][33],作者 Albert W. Schueller
|
||||||
|
|
||||||
|
这本书介绍乐高头脑风暴 NXT 编程的基础。并不需要读者编写复杂的程序,而是通过编程让设备可以感知并与真实世界进行交互。通过完成传感器、电机实验,以及编程制作音乐,你可以了解软硬件如何协调工作。([Rahul Thakoor][7] 推荐并评论)
|
||||||
|
|
||||||
|
[_AWK 编程语言_][34],作者 Alfred V. Aho, Brian W. Kernighan 和 Peter J. Weinberger
|
||||||
|
|
||||||
|
这本书的作者就是 awk 语言的发明者,本书风格类似于 20 世纪 70 至 90 年代贝尔实验室 Unix 小组出版的类 Unix 工具书籍,使用简明、紧凑的文字介绍了 awk 的原理和目标。书中包含不少示例,从简单的开始,后面会结合描述详尽的问题或前沿案例,示例也变得复杂。本书刚出版时,典型的读者需求如下:处理和转换文本或数据文件,以及便捷地创建查询表、使用正则表达式、根据输入调整结构、对数值执行数学变换并便捷设置输出格式等。
|
||||||
|
|
||||||
|
上述需求依然存在,现在这本书也可以给人们提供一个回顾那个只能使用终端交互的年代的机会。在那时,通过“模块化”可以使用多个单一用途的程序编写 shell 脚本,用于管道处理数据,最终计算机给出人们预期的结果。在今天,awk 被视为运维工具,在处理配置文件和日志文件方面效果不错,这本书也介绍了一些这方面的内容。([Jim Hall][4] 推荐,[Chris Hermansen][35] 评论)
|
||||||
|
|
||||||
|
[_像计算机科学家一样思考 Python_][36],作者 Allen Downey
|
||||||
|
|
||||||
|
这本书是作者系列图书中的一本,介绍 Python 编程语言,系列中还有其它编程语言,包括 Java 和 [Perl][39] 等。介绍完基础的编程语法后,本书进入主题环节,着重介绍问题解决者如何构建解决方案。本书概念层次清晰,对编程初学者是很好的入门读物;对于希望在课堂等地方提高编程技能的新手,本书也适用;本书的若干章节配有例子和习题,可供测试已学的技能。([Steve Morris][40] 介绍并评论)
|
||||||
|
|
||||||
|
[_认识开源和自由软件协议_][41] (O'Reilly, 2004)
|
||||||
|
|
||||||
|
“这本书填补了开源理念与法律基础上的真实意义之间的空白。如果你对开源和自由软件协议感兴趣,那么本书可以帮忙加深理解。如果你是一名开源/自由软件开发者,这本书显然是必须的。“([Jim Hall][4] 推荐,评论来自 [Amazon][42])
|
||||||
|
|
||||||
|
[_Unix 文本处理_][43],作者 Dale Dougherty 及 Tim O'Reilly
|
||||||
|
|
||||||
|
本书写于 1987 年,用于介绍 Unix 系统及作家如何使用 Unix 工具帮助其工作。对于希望学习包括 vi 编辑器,awk,shell 脚本在内的 Unix shell 基础及 nroff/troff 排版系统的初学者而言,本书仍然是有用的资源。原版已绝版,但 O'Reilly 将本书制作为电子书,可在其网站上免费获得。([Jim Hall][4] 推荐并评论)
|
||||||
|
|
||||||
|
### 福利:科幻小说
|
||||||
|
|
||||||
|
[_11 号太空站_][44],作者 Emily St. John Mandel
|
||||||
|
|
||||||
|
故事时间设定为不远的未来,地球人口随着神秘而致命的流感爆发而锐减,故事发生在 20 年后。主人公 Kirsten Raymonde 是一名年轻女性,坚信“仅仅活着是不够的”,为此她在后世界末日时代带着一个游牧剧团在五大湖区域附近勇敢地旅行。这是个精彩的故事,很值得一读。
|
||||||
|
|
||||||
|
这本书让我震惊的是我们与技术之间实际上那么脆弱的关系。Douglas Adams 的 “Mostly Harmless” 书中有一句话很经典:“仅靠双手,他无法制造一个面包机。但他可以制作三明治,就是这样”。在 Kristin Raymonde 的世界中,每个人仅能靠自己的双手。这里没有电,因为电力网络无法运作;没有汽车,因为炼油厂无法运作。
|
||||||
|
|
||||||
|
书中有一个有趣的桥段,一个发明家使用自行车组装了一台发电机,试图启动一台笔记本电脑,尝试查看是否还存在互联网。我们看到旧世界留存的、无用的东西堆成的文明博物馆,内容包括护照、移动电话、信用卡和高跟鞋等。
|
||||||
|
|
||||||
|
世界上的全部技术都变得无用。([Dave Neary][14] 推荐并评论)
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://opensource.com/article/18/5/list-books-Linux-open-source
|
||||||
|
|
||||||
|
作者:[Jen Wike Huger][a]
|
||||||
|
选题:[lujun9972](https://github.com/lujun9972)
|
||||||
|
译者:[pinewall](https://github.com/pinewall)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:https://opensource.com/users/remyd
|
||||||
|
[1]:https://twitter.com/opensourceway
|
||||||
|
[2]:http://www.freedos.org/ebook/
|
||||||
|
[3]:https://opensource.com/article/18/5/node/44116
|
||||||
|
[4]:https://opensource.com/users/jim-hall
|
||||||
|
[5]:https://eloquentjavascript.net/
|
||||||
|
[6]:https://opensource.com/article/18/5/node/32826
|
||||||
|
[7]:https://opensource.com/users/rahul27
|
||||||
|
[8]:https://pragprog.com/book/vbopens/forge-your-future-with-open-source
|
||||||
|
[9]:https://opensource.com/users/bcotton
|
||||||
|
[10]:http://gitforteams.com/
|
||||||
|
[11]:https://opensource.com/article/18/5/node/43741
|
||||||
|
[12]:https://opensource.com/business/15/11/git-for-teams-review
|
||||||
|
[13]:http://www.williamury.com/books/getting-to-yes/
|
||||||
|
[14]:https://opensource.com/users/dneary
|
||||||
|
[15]:http://a.co/749s27n
|
||||||
|
[16]:https://opensource.com/article/18/5/node/19796
|
||||||
|
[17]:https://opensource.com/users/don-watkins
|
||||||
|
[18]:https://manning.com/ovadia
|
||||||
|
[19]:https://opensource.com/article/18/5/node/42626
|
||||||
|
[20]:https://opensource.com/users/stevenov
|
||||||
|
[21]:https://www.manning.com/books/linux-in-action?a_aid=bootstrap-it&a_bid=4ca15fc9
|
||||||
|
[22]:https://opensource.com/article/18/5/node/44696
|
||||||
|
[23]:https://bootstrap-it.com/index.php/books/
|
||||||
|
[24]:https://opensource.com/users/dbclinton
|
||||||
|
[25]:https://www.makershed.com/products/make-linux-for-makers
|
||||||
|
[26]:https://opensource.com/article/18/5/node/35731
|
||||||
|
[27]:https://www.amazon.com/Managing-Humans-Humorous-Software-Engineering/dp/1484221575/ref=dp_ob_title_bk
|
||||||
|
[28]:http://randsinrepose.com/
|
||||||
|
[29]:https://www.oreilly.com/openbook/opensources/book/index.html
|
||||||
|
[30]:https://opensource.com/article/18/5/node/42001
|
||||||
|
[31]:https://producingoss.com/
|
||||||
|
[32]:https://opensource.com/users/justinflory
|
||||||
|
[33]:http://engineering.nyu.edu/gk12/amps-cbri/pdf/RobotC%20FTC%20Books/notesRobotC.pdf
|
||||||
|
[34]:https://archive.org/details/pdfy-MgN0H1joIoDVoIC7
|
||||||
|
[35]:https://opensource.com/users/clhermansen
|
||||||
|
[36]:http://greenteapress.com/thinkpython2/thinkpython2.pdf
|
||||||
|
[37]:https://opensource.com/article/18/5/node/40481
|
||||||
|
[38]:http://greenteapress.com/wp/
|
||||||
|
[39]:https://opensource.com/article/18/5/node/35141
|
||||||
|
[40]:https://opensource.com/users/smorris12
|
||||||
|
[41]:http://shop.oreilly.com/product/9780596005818.do
|
||||||
|
[42]:https://www.amazon.com/Understanding-Open-Source-Software-Licensing/dp/0596005814
|
||||||
|
[43]:http://www.oreilly.com/openbook/utp/
|
||||||
|
[44]:http://www.emilymandel.com/stationeleven.html
|
@ -1,106 +0,0 @@
|
|||||||
如何在 Linux 系统中结束结束进程或是中止程序
|
|
||||||
======
|
|
||||||
|
|
||||||
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/x_stop_terminate_program_kill.jpg?itok=9rM8i9x8)
|
|
||||||
|
|
||||||
进程出错的时候,您可能会想要中止或是中断这个进程。本文,我们将在命令行和图形界面中探索进程或是应用程序的中断,这里我们使用 [gedit][1] 作为样例程序。
|
|
||||||
|
|
||||||
### 使用命令行、终端字符
|
|
||||||
|
|
||||||
#### Ctrl + C
|
|
||||||
|
|
||||||
在命令行中调用 `gedit` (如果您没有使用 `gedit &` 命令)程序发生错误时,shell 会话被阻塞,将不会释放出相应的错误提示,此下,`Ctrl + C` (Ctrl 和 C 的组合键) 会很管用。`gedit` 会被中断,由于 `Ctrl + C` 给 `gedit` 发送了 `SIGINT` 信号,之前的所有工作都将丢失(除非文件已经被保存)。`SIGINT` 是一个会默认执行进程中断的终止信号,它将指示 shell 终止 `gedit` 的运行,并返回到主函数的循环中,此时,您将得到提示语。
|
|
||||||
|
|
||||||
```
|
|
||||||
$ gedit
|
|
||||||
^C
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Ctrl + Z
|
|
||||||
|
|
||||||
它被称为挂起字符,能够为进程发送 `SIGTSTP` 信号。它也是一个中止信号,但是默认行为不是杀死进程,而是挂起进程。
|
|
||||||
|
|
||||||
下面的命令将会停止(杀死/中断) `gedit` 的运行,并返回 shell 提示。
|
|
||||||
```
|
|
||||||
$ gedit
|
|
||||||
^Z
|
|
||||||
[1]+ Stopped gedit
|
|
||||||
$
|
|
||||||
```
|
|
||||||
|
|
||||||
一旦进程被挂起(以 `gedit` 为例),将不能在 `gedit` 中做任何事情。而在后台,该进程任然是一个作业,可以使用 `jsbs` 命令验证。
|
|
||||||
```
|
|
||||||
$ jobs
|
|
||||||
[1]+ Stopped gedit
|
|
||||||
```
|
|
||||||
|
|
||||||
`jobs` 允许您在单个 shell 会话中控制多个进程。您可以在前台或是后台终止,恢复或是移动作业。
|
|
||||||
|
|
||||||
让我们在后台恢复 `gedit`,释放提示并运行其它命令吧。您可以根据作业 ID(注意,`jobs` 命令显示出来的 `[1]` 就是作业 ID)使用 `bg` 命令恢复进程。
|
|
||||||
```
|
|
||||||
$ bg 1
|
|
||||||
[1]+ gedit &
|
|
||||||
```
|
|
||||||
|
|
||||||
这和直接使用 `gedit &` 启动程序效果差不多:
|
|
||||||
```
|
|
||||||
$ gedit &
|
|
||||||
```
|
|
||||||
|
|
||||||
### 使用 kill
|
|
||||||
|
|
||||||
`kill` 命令提供信号的精确控制,允许您通过进程 ID 或是 PID,根据特定的信号名或是信号数字为进程发送信号。
|
|
||||||
|
|
||||||
`kill` 命令能够根据作业 ID 控制进程,这一点是我喜欢的。让我们使用 `gedit &` 命令在后台开启 `gedit` 服务。假设通过 `jobs` 命令我得到了一个 `gedit` 的作业 ID,让我们为 `gedit` 发送 `SIGINT` 信号吧:
|
|
||||||
```
|
|
||||||
$ kill -s SIGINT %1
|
|
||||||
```
|
|
||||||
|
|
||||||
作业 ID 需要使用 `%` 前缀,不然 `kill` 会将其视作 PID。
|
|
||||||
|
|
||||||
不明确指定的信号,`kill` 仍然可以工作。此时,默认会发送能中断进程的 `SIGTERM` 信号。执行 `kill -l` 查看信号名列表,使用 `man kill` 命令阅读手册。
|
|
||||||
|
|
||||||
### 使用 killall
|
|
||||||
|
|
||||||
如果您不想使用特定的工作 ID 或者 PID,`killall` 允许您使用特定的进程名。中断 `gedit` 最简单的 `killall` 使用方式是:
|
|
||||||
```
|
|
||||||
$ killall gedit
|
|
||||||
```
|
|
||||||
|
|
||||||
它将终止所有名为 `gedit` 的进程。和 `kill` 想死,默认发送的信号时 `SIGTERM`。
|
|
||||||
This will kill all the processes with the name `gedit`. Like `kill`, the default signal is `SIGTERM`. 使用 `-I` 选项忽略大小写。
|
|
||||||
```
|
|
||||||
$ gedit &
|
|
||||||
[1] 14852
|
|
||||||
|
|
||||||
$ killall -I GEDIT
|
|
||||||
[1]+ Terminated gedit
|
|
||||||
```
|
|
||||||
|
|
||||||
查看手册学习更多 `killall` 命令选项(如 `-u`)。
|
|
||||||
|
|
||||||
### 使用 xkill
|
|
||||||
|
|
||||||
您是否遇见过播放器崩溃,比如 [VLC][2] 灰屏或挂起?现在,获得程序 PID 之后,您就可以使用 `xkill` 命令终止应用程序。
|
|
||||||
|
|
||||||
![Using xkill][3]
|
|
||||||
|
|
||||||
`xkill` 允许您使用鼠标关闭窗口。仅需在终端执行 `xkill` 命令,它将会改变鼠标光标为一个 **X** 或是一个骷髅图标。点击您想关闭的进程窗口上的 **X**。小心使用 `xkill`,如手册描述的一致,它很危险。我已经提醒过您了!
|
|
||||||
|
|
||||||
参阅手册,了解上述命令更多信息。您还可以接续探索 `pkill` 和 `pgrep` 命令。
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
via: https://opensource.com/article/18/5/how-kill-process-stop-program-linux
|
|
||||||
|
|
||||||
作者:[Sachin Patil][a]
|
|
||||||
选题:[lujun9972](https://github.com/lujun9972)
|
|
||||||
译者:[CYLeft](https://github.com/CYLeft)
|
|
||||||
校对:[校对者ID](https://github.com/校对者ID)
|
|
||||||
|
|
||||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
|
||||||
|
|
||||||
[a]:https://opensource.com/users/psachin
|
|
||||||
[1]:https://wiki.gnome.org/Apps/Gedit
|
|
||||||
[2]:https://www.videolan.org/vlc/index.html
|
|
||||||
[3]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/uploads/xkill_gedit.png?itok=TBvMw0TN (Using xkill)
|
|
@ -0,0 +1,134 @@
|
|||||||
|
使用 Stratis 从命令行管理 Linux 存储
|
||||||
|
======
|
||||||
|
|
||||||
|
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/find-file-linux-code_magnifying_glass_zero.png?itok=E2HoPDg0)
|
||||||
|
|
||||||
|
正如本系列的[第一部分][1]和[第二部分][2]中所讨论的,Stratis 是一个具有与 [ZFS][3] 和 [Btrfs] [4] 相似功能的卷管理文件系统。在本文中,我们将介绍如何在命令行上使用 Stratis。
|
||||||
|
|
||||||
|
### 安装 Stratis
|
||||||
|
|
||||||
|
对于非开发人员,现在尝试 Stratis 最简单的方法是在 [Fedora 28][5] 中。
|
||||||
|
|
||||||
|
你可以用以下命令安装 Stratis 守护进程和 Stratis 命令行工具:
|
||||||
|
```
|
||||||
|
# dnf install stratis-cli stratisd
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### 创建一个池
|
||||||
|
|
||||||
|
Stratis 有三个概念:blockdevs、池和文件系统。 Blockdevs 是组成池的块设备,例如磁盘或磁盘分区。一旦创建池,就可以从中创建文件系统。
|
||||||
|
|
||||||
|
假设你的系统上有一个名为 `vdg` 的块设备,它目前没有被使用或挂载,你可以在它上面创建一个 Stratis 池:
|
||||||
|
```
|
||||||
|
# stratis pool create mypool /dev/vdg
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
这假设 `vdg` 是完全清零并且是空的。如果它没有被使用,但有旧数据,则可能需要使用 `pool create` 的 ` - force` 选项。如果正在使用,请勿将它用于 Stratis。
|
||||||
|
|
||||||
|
如果你想从多个块设备创建一个池,只需在 `pool create` 命令行中列出它们。你也可以稍后使用 `blockdev add-data` 命令添加更多的 blockdevs。请注意,Stratis 要求 blockdevs 的大小至少为 1 GiB。
|
||||||
|
|
||||||
|
### 创建文件系统
|
||||||
|
|
||||||
|
在你创建了一个名为 `mypool` 的池后,你可以从它创建文件系统:
|
||||||
|
```
|
||||||
|
# stratis fs create mypool myfs1
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
从 `mypool` 池创建一个名为 `myfs1` 的文件系统后,可以使用 Stratis 在 /dev/stratis 中创建的条目来挂载并使用它:
|
||||||
|
```
|
||||||
|
# mkdir myfs1
|
||||||
|
|
||||||
|
# mount /dev/stratis/mypool/myfs1 myfs1
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
文件系统现在已被挂载在 `myfs1` 上并准备可以使用。
|
||||||
|
|
||||||
|
### 快照
|
||||||
|
|
||||||
|
除了创建空文件系统之外,你还可以创建一个文件系统作为现有文件系统的快照:
|
||||||
|
```
|
||||||
|
# stratis fs snapshot mypool myfs1 myfs1-experiment
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
这样做后,你可以挂载新的 `myfs1-experiment`,它将初始包含与 `myfs1` 相同的文件内容,但它可能随着文件系统的修改而改变。无论你对 `myfs1-experiment` 所做的任何更改都不会反映到 `myfs1` 中,除非你卸载了 `myfs1` 并将其销毁:
|
||||||
|
```
|
||||||
|
# umount myfs1
|
||||||
|
|
||||||
|
# stratis fs destroy mypool myfs1
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
然后进行快照以重新创建并重新挂载它:
|
||||||
|
```
|
||||||
|
# stratis fs snapshot mypool myfs1-experiment myfs1
|
||||||
|
|
||||||
|
# mount /dev/stratis/mypool/myfs1 myfs1
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
### 获取信息
|
||||||
|
|
||||||
|
Stratis 可以列出系统中的池:
|
||||||
|
```
|
||||||
|
# stratis pool list
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
随着文件系统写入更多数据,你将看到 “Total Physical Used” 值的增加。当这个值接近 “Total Physical Size” 时要小心。我们仍在努力处理这个问题。
|
||||||
|
|
||||||
|
列出池中的文件系统:
|
||||||
|
```
|
||||||
|
# stratis fs list mypool
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
列出组成池的 blockdevs:
|
||||||
|
```
|
||||||
|
# stratis blockdev list mypool
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
目前只提供这些最少的信息,但它们将在未来提供更多信息。
|
||||||
|
|
||||||
|
#### 摧毁池
|
||||||
|
|
||||||
|
当你了解了 Stratis 可以做什么后,要摧毁池,首先确保从它创建的所有文件系统都被卸载并销毁,然后使用 `pool destroy` 命令:
|
||||||
|
```
|
||||||
|
# umount myfs1
|
||||||
|
|
||||||
|
# umount myfs1-experiment (if you created it)
|
||||||
|
|
||||||
|
# stratis fs destroy mypool myfs1
|
||||||
|
|
||||||
|
# stratis fs destroy mypool myfs1-experiment
|
||||||
|
|
||||||
|
# stratis pool destroy mypool
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
`stratis pool list` 现在应该显示没有池。
|
||||||
|
|
||||||
|
就是这些!有关更多信息,请参阅手册页:“man stratis”。
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
via: https://opensource.com/article/18/5/stratis-storage-linux-command-line
|
||||||
|
|
||||||
|
作者:[Andy Grover][a]
|
||||||
|
选题:[lujun9972](https://github.com/lujun9972)
|
||||||
|
译者:[geekpi](https://github.com/geekpi)
|
||||||
|
校对:[校对者ID](https://github.com/校对者ID)
|
||||||
|
|
||||||
|
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||||
|
|
||||||
|
[a]:https://opensource.com/users/agrover
|
||||||
|
[1]:https://opensource.com/article/18/4/stratis-easy-use-local-storage-management-linux
|
||||||
|
[2]:https://opensource.com/article/18/4/stratis-lessons-learned
|
||||||
|
[3]:https://en.wikipedia.org/wiki/ZFS
|
||||||
|
[4]:https://en.wikipedia.org/wiki/Btrfs
|
||||||
|
[5]:https://fedoraproject.org/wiki/Releases/28/Schedule
|
Loading…
Reference in New Issue
Block a user