Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2020-08-11 22:12:21 +08:00
commit 8a2b2ce1fb
11 changed files with 863 additions and 358 deletions

View File

@ -1,16 +1,18 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12505-1.html)
[#]: subject: (3 reasons to contribute to open source now)
[#]: via: (https://opensource.com/article/20/6/why-contribute-open-source)
[#]: author: (Jason Blais https://opensource.com/users/jasonblais)
现在贡献开源的 3 个理由
======
现在比以往任何时候都更是为开源做出贡献的理想时机。下面是为什么。
![Business woman on laptop sitting in front of window][1]
> 现在比以往任何时候都更是为开源做出贡献的理想时机。下面是为什么。
![](https://img.linux.net.cn/data/attachment/album/202008/11/101413or3y9jsjsu0999s4.jpg)
开源软件已经[遍及世界][2]。从 Linux 和 MySQL 的早期开始,开源就以前所未有的方式推动创新,仅 GitHub 上就有 [180,000 个公共仓库][3]。
@ -22,29 +24,29 @@
通过参与一个开源项目,你会立即收到有关你的开发和编程技能的反馈。你可能会获得有关如何选择函数名称、条件逻辑的使用方式或如何使用不了解的 goroutine 来加快程序执行速度的建议。这是你在学习新东西时获得的宝贵反馈。
此外,随着你创建更多的拉取请求并应用从先前提交的内容中学到的知识,你将开始学习如何编写良好的代码并[提交大量拉取请求进行代码审查][4]。最后,许多开源项目提供指导计划,以帮助指导你完成前几个贡献。这是一个非常友好、安全的环境,可树立你作为开发人员的信心。
此外,随着你创建更多的拉取请求并应用从先前提交的内容中学到的知识,你将开始学习如何编写良好的代码并[提交优秀的拉取请求进行代码审查][4]。最后,许多开源项目提供指导计划,以帮助指导你完成前几个贡献。这是一个非常友好、安全的环境,可树立你作为开发人员的信心。
有关例子故事,请阅读 [Allan Guwatudde 作为一名自学开发者在开源方面的经验][5]这篇文章。
### 建立你的简历
### 丰富你的简历
即使你是一位经验丰富的开发人员,你也可能希望简历自己的简历以帮助职业发展和将来的寻找工作。也许你有兴趣探索新的前沿框架或新的编程模块,而你却没有机会在工作中用到。
即使你是一位经验丰富的开发人员,你也可能希望丰富自己的简历,以帮助职业发展和未来的寻找工作。也许你有兴趣探索新的前沿框架或新的编程模块,而你却没有机会在工作中用到。
你可以通过注册课程或在日常工作中找到一个方式引入这些概念。但是,当这些选项不可用(或不希望使用)时,开源将提供绝佳的机会!除了建立技能和提高信心之外,所有开源贡献都是公开的,它们可以证明你已掌握的技能和已完成的项目。实际上,你的开源个人资料本身可以为你提供强大的作品集,从而使你与其他应聘者脱颖而出。
你可以通过报名一个课程或在日常工作中找到一个方式引入这些概念来获得经验。但是,当这些选项不可用(或不希望使用)时,开源将提供绝佳的机会!除了建立技能和提高信心之外,所有开源贡献都是公开的,它们可以证明你已掌握的技能和已完成的项目。实际上,你的开源方面的个人资料本身可以为你提供强大的作品集,从而使你与其他应聘者脱颖而出。
此外,许多开源项目,例如 [Mattermost][6]可让你将自己添加为 LinkedIn 的贡献者,以直接提升自己的专业形象。
此外,许多开源项目,例如 [Mattermost][6]允许你在 LinkedIn 上添加自己为贡献者,以直接提升自己的专业形象。
[阅读 Siyuan Liu 的旅程][7]这篇文章,了解如何从第一次开源贡献到两次成为 Mattermost 项目 MVP。
### 建立你的专业网络
建立强大的专业网络可以帮助你实现职业目标,了解有关你自己或相邻领域的更多信息,并有助于寻找工作。为开源做贡献是建立该网络的绝佳方法。你加入了一个由成百上千的贡献者组成的受欢迎社区,在开源空间中与志趣相投的开发人员进行互动,并一路建立联系。你甚至可能会被介绍给行业中的关键人物,例如知名的开源工具的维护者。这样的关系可以变成改变职业生涯的关系。
建立强大的专业网络可以帮助你实现职业目标,了解有关你自己或相邻领域的更多信息,并有助于寻找工作。为开源做贡献是建立该网络的绝佳方法。你加入了一个由成百上千的贡献者组成的温馨社区,在开源空间中与志趣相投的开发人员进行互动,并一路建立联系。你甚至可能会被介绍给行业中的关键人物,例如知名的开源工具的维护者。这样的关系可以变成改变职业生涯的关系。
最后,为开源项目做贡献甚至可以让你找到工作!例如,[Mattermost][8] 从它的开源社区聘请了一些贡献者,全职在工程团队中工作。
最后,为开源项目做贡献甚至可以让你找到工作!例如,[Mattermost][8] 已经从它的开源社区聘请了一些贡献者,全职在工程团队中工作。
### 从今天开始为开源做贡献
开源让你能够树立开发者的信心,建立简历和建立专业网络。而且,无论你的贡献大小,它都会对开源项目的未来产生直接影响。因此,许多项目都会向贡献者发放礼物以表示感谢(例如,[为所有初次贡献者定制的杯子][9])。
开源让你能够树立开发者的信心,建立简历和建立专业网络。而且,无论你的贡献大小,它都会对开源项目的未来产生直接影响。因此,许多项目都会向贡献者发放礼物以表示感谢(例如,[为所有首次贡献者送上一个定制的杯子][9])。
准备开始进入开源了吗?查看[这些开源项目][10]来进行首次开源贡献,或了解[如何为 Mattermost 做贡献][11]。
@ -55,7 +57,7 @@ via: https://opensource.com/article/20/6/why-contribute-open-source
作者:[Jason Blais][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,24 +1,26 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12504-1.html)
[#]: subject: (Bypass your Linux firewall with SSH over HTTP)
[#]: via: (https://opensource.com/article/20/7/linux-shellhub)
[#]: author: (Domarys https://opensource.com/users/domarys)
通过 SSH over HTTP 绕过 Linux 防火墙
借助 HTTP 通过 SSH 绕过 Linux 防火墙
======
需要远程工作的看一下。使用这个有帮助的开源解决方案在任何地方快速地连接和访问你的所有设备。
![Terminal command prompt on orange background][1]
随着连接速度和远程作业需求的增长,访问远程计算资源变得越来越重要。但是,提供对设备和硬件的外部访问的要求使此任务变得复杂而有风险。为了减少这些冲突,[ShellHub][2] 是一个云服务器,它可以从任何外部网络访问这些设备。
> 需要远程工作的看一下。使用这个有用的开源解决方案,从任何地方快速地连接和访问你的所有设备。
ShellHub 是一个 Apache 2.0 许可的开源解决方案,它可满足所有这些需求,并允许用户通过一个帐户连接和管理多个设备。它开发是为了方便开发人员和程序员的任务,使任何硬件架构都能够远程访问 Linux 设备。
![](https://img.linux.net.cn/data/attachment/album/202008/10/231746xs4363yc03cptzbc.jpg)
仔细观察ShellHub 方案使用 HTTP 传输层来封装 SSH 协议。这种传输层选择可以在大多数网络上无缝使用,因为大多数公司的防火墙规则和策略通常都可以使用并接受它
随着对连接和远程工作的需求的增长,访问远程计算资源变得越来越重要。但是,提供对设备和硬件的外部访问的要求使此任务变得复杂而有风险。旨在减少此类麻烦的 [ShellHub][2] 是一个云服务器,允许从任何外部网络常规访问这些设备
这些示例使用 2020 年 6 月 10 日发布的 ShellHub 版本 0.3.2。
ShellHub 是一个 Apache 2.0 许可的开源解决方案,它可满足所有这些需求,并允许用户通过一个帐户连接和管理多个设备。它的开发是为了方便开发者和程序员的工作,使得任何硬件架构的 Linux 设备的远程访问成为可能。
仔细观察ShellHub 方案使用 HTTP 传输层来封装 SSH 协议。这种传输层的选择可以在大多数网络上无缝使用,因为大多数公司的防火墙规则和策略通常都可以使用并接受它。
下面这些示例使用 2020 年 6 月 10 日发布的 ShellHub 版本 0.3.2。
### 使用 ShellHub
@ -26,20 +28,21 @@ ShellHub 是一个 Apache 2.0 许可的开源解决方案,它可满足所有
![ShellHub registration form][4]
图 1[shellhub.io][5] 中的注册表格
*图 1[shellhub.io][5] 中的注册表格*
ShellHub 有直观、简洁的界面,这让所有的信息和功能都能以最快的方式呈现。注册后,你会看到一块仪表板,这时可以注册你的第一台设备。
### 添加设备
要通过 ShellHub 启用设备连接,你需要生成一个标识符,它用于在设备连接到服务器时对你的设备进行身份验证。
启用通过 ShellHub 连接设备,你需要生成一个标识符,它用于在设备连接到服务器时对你的设备进行身份验证。
此标识必须在将与镜像一起保存在设备的代理ShellHub 客户端)内进行配置,或者必须添加为 Docker 容器。
此标识必须配置在代理ShellHub 客户端)内部,该代理必须与镜像一起保存在设备中,或者必须添加为 Docker 容器。
ShellHub 默认使用 Docker 运行代理,这非常方便,因为它在现有系统上提供了一种无痛的添加方式,支持 Docker 是唯一的要求。要添加设备,你需要粘贴命令行,它显示在 ShellHub Cloud 的对话框中(请参见图 2
![Figure 2: Adding a device to the ShellHub Cloud][6]
图 2将设备添加到 ShellHub Cloud
*图 2将设备添加到 ShellHub Cloud*
设备默认使用它的 MAC 地址作为其主机名。在内部,该设备由其密钥标识,这是在设备注册期间生成的,用于与服务器进行身份验证。
@ -50,14 +53,16 @@ ShellHub 默认使用 Docker 运行代理,这非常方便,因为它在现有
设备状态可在页面上轻松看到。在线设备旁边会显示一个绿色图标,可以单击终端图标进行连接。你接着输入密码,最后单击”连接“按钮,请参见(图 3
![Figure 3: Accessing a device using the terminal on the web][7]
图 3使用网络上的终端访问设备
另一种访问设备的方法是从类似 [PuTTY][8]、[Termius][9] 之类的 SSH 客户端,甚至 Linux 终端访问。我们可以使用称为 SSHID 的 ShellHub 标识作为连接的目的地址(例如 ssh ssh [username@SSHID][10])。图 4 说明了如何使用在终端中使用 Linux SSH 客户端连接到我们的计算机。
*图 3使用网络上的终端访问设备*
另一种访问设备的方法是从类似 [PuTTY][8]、[Termius][9] 之类的 SSH 客户端,甚至 Linux 终端访问。我们可以使用称为 SSHID 的 ShellHub 标识作为连接的目的地址(例如 `ssh username@SSHID`)。图 4 说明了如何使用在终端中使用 Linux SSH 客户端连接到我们的计算机。
![Figure 4: Connecting to a device using the Linux terminal][11]
图 4使用 Linux 终端连接到设备
无论你何时登录 ShellHub Cloud 平台你都可以访问仪表板上的所有已注册设备这样你可以随时随地访问它们。ShellHub 简化了通过开源平台以透明方式与远程计算机保持通信安全的过程。
*图 4使用 Linux 终端连接到设备*
无论你何时登录 ShellHub Cloud 平台你都可以访问仪表板上的所有已注册设备这样你可以随时随地访问它们。ShellHub 通过一个开源平台,以透明的方式为您与远程机器保持通信安全的过程增加了简单性。
在 [GitHub][2] 上加入 ShellHub 社区,或随时通过 [Gitter][12] 或通过电子邮件 [contato@ossystems.com.br][13] 向开发团队发送你的建议或反馈。我们很乐意收到社区成员的贡献!
@ -68,7 +73,7 @@ via: https://opensource.com/article/20/7/linux-shellhub
作者:[Domarys][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,20 +1,21 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-12506-1.html)
[#]: subject: (Do math in the Linux shell with GNU bc)
[#]: via: (https://opensource.com/article/20/7/bc-math)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
使用 GNU bc 在 Linux Shell 中进行数学运算
======
在 shell 中使用 bc 更好地做算数,它是一种用于高级计算的数学语言
![old school calculator][1]
> 在 shell 中使用 bc 更好地做算数,它是一种用于高级计算的数学语言。
![](https://img.linux.net.cn/data/attachment/album/202008/11/105133c86k08rf028jjd6a.jpg)
大多数 [POSIX][2] 系统带有 [GNU bc][3],这是一种任意精度的数字处理语言。它的语法类似于 C但是它也支持交互式执行语句和处理来自标准输入`stdin`)的数据。因此,它通常是以下问题的答案:“我如何在 Linux shell 中进行数学运算?”这种回应方式在网上很常见:
```
$ echo "1+1" | bc
2
@ -22,15 +23,13 @@ $ echo "1+1" | bc
尽管这是完全正确的,但很少有用户认为,与更直观的方式相比,它很优雅,例如:
```
$ 1+1  #this does not work
$ 1+1  # 这不能工作
2
```
交互模式要容易一些:
```
$ bc
1+1
@ -41,7 +40,7 @@ $
但是交互模式并不总是适合简单计算想要的直观工作流,比如直接输入你想要的计算。因此我推荐 Bluebat 的[纯 Bash 计算器][4]。
bc 实际上提供了一种用于高级计算的数学语言。
`bc` 实际上提供了一种用于高级计算的数学语言。
### 含高级函数的 mathlib
@ -57,7 +56,6 @@ $ bc
使用 `--mathlib` 选项获取高级函数,包括正弦、余弦、正切等。在交互式模式下,你可以测试其中一些。下面是 90 度的余弦:
```
c(90)
-.44807361612917015236
@ -65,7 +63,6 @@ c(90)
9 的正弦:
```
s(9)
.41211848524175656975
@ -73,8 +70,7 @@ s(9)
### 创建你自己的 bc 函数
你还可以在 bc 中创建自己的函数。函数定义以 `define` 关键字开始,并用大括号括起来。下面是一个输入到交互式会话中的简单函数,它返回给它的任意数字:
你还可以在 `bc` 中创建自己的函数。函数定义以 `define` 关键字开始,并用大括号括起来。下面是一个输入到交互式会话中的简单函数,它返回给它的任意数字:
```
$ bc
@ -85,7 +81,6 @@ define echo(n) {
在同一个交互式会话中,测试一下:
```
echo(2)
2
@ -95,19 +90,17 @@ echo(-2)
### bc 中的 if 语句
bc 语言还有各种控制语句,其中最简单的是 if/else。语法乍一看可能很熟悉但在如何处理大括号方面有些不同。请注意if 语句的 _else_ 子句包含在大括号中,而 _then_ 子句不是,但两者都用分号终止。下面是一个返回数字 _n_ 的绝对值的函数:
`bc` 语言还有各种控制语句,其中最简单的是 `if`/`else`。语法乍一看可能很熟悉,但在如何处理大括号方面有些不同。请注意,`if` 语句的 `else` 子句包含在大括号中,而 `then` 子句不是,但两者都用分号终止。下面是一个返回数字 `n` 的绝对值的函数:
```
define abso(n) {
  if ( n > 0 ) return (n);
  if ( n > 0 ) return (n);
  { return (-n); }
}
```
在同一个交互式会话中,测试一下:
```
abso(-5)
5
@ -117,24 +110,22 @@ abso(5)
### 将数据导入 bc
使用交互式会话对于快速计算和实验是可以容忍的但在退出时会丢失数据并且在出错时很难编辑。幸运的是bc 可以从外部文件加载变量和函数。
使用交互式会话对于快速计算和实验是可以容忍的,但在退出时会丢失数据,并且在出错时很难编辑。幸运的是,`bc` 可以从外部文件加载变量和函数。
下面是一个包含两个变量(`sol` 和 `foo`)的文件,以及一个用于查找绝对值的自定义 `abso` 函数:
```
sol=299792458
foo=42
define abso(n) {
  if ( n > 0 ) return (n);
  if ( n > 0 ) return (n);
  { return (-n); }
}
```
将它保存到名为 `bcvars.bc` 的文件中,以便导入 bc 交互式会话:
将它保存到名为 `bcvars.bc` 的文件中,以便导入 `bc` 交互式会话:
```
$ bc bcvars.bc
@ -148,9 +139,9 @@ abso(-23)
### 使用 bc 助力你的数学
bc 语言相对简单,前提是你知道足够的数学知识来构造任何你想完成的方程。虽然 bc 默认提供了有用的基本函数,并允许你创建自己的函数,但你可以通过站在巨人的肩膀上来减少工作量。加载了用于数学基础知识和特定任务(例如,计算复利)的新函数的文件可从 [GNU bc 页][5]获得,同时也可获得 bc [完整文档][6]。
`bc` 语言相对简单,前提是你知道足够的数学知识来构造任何你想完成的方程。虽然 `bc` 默认提供了有用的基本函数,并允许你创建自己的函数,但你可以通过站在巨人的肩膀上来减少工作量。加载了用于数学基础知识和特定任务(例如,计算复利)的新函数的文件可从 [GNU bc 页][5]获得,同时也可获得 `bc` [完整文档][6]。
如果你有兴趣在 shell 里更好地处理数学,试试 bc 。它不会使你成为数学天才,但它可能会让过程更简单。
如果你有兴趣在 shell 里更好地处理数学,试试 `bc` 。它不会使你成为数学天才,但它可能会让过程更简单。
--------------------------------------------------------------------------------
@ -159,7 +150,7 @@ via: https://opensource.com/article/20/7/bc-math
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,116 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (silentdawn-zz)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Code your hardware using this open source RTOS)
[#]: via: (https://opensource.com/article/20/6/open-source-rtos)
[#]: author: (Zhu Tianlong https://opensource.com/users/zhu-tianlong)
Code your hardware using this open source RTOS
======
Programming a chip is hard, but RTOS solves many of the major issues on
embedded systems
![Puzzle pieces coming together to form a computer screen][1]
In general computing, an operating system is software that provides a computer's basic functions. It ensures that a computer detects and responds to peripherals (like keyboards, screens, mobile devices, printers, and so on), and it manages memory and drive space.
Even though modern operating systems make it seem that multiple programs are running at the same time, a CPU core can run only a single thread at a time. Each task is executed so quickly and in such rapid succession that the result appears to be massive multi-tasking. This is managed by a subroutine called a _scheduler_.
Operating systems, usually, are for computers. The OS is installed to your hard drive, and manages the computer's tasks.
### Why RTOS is essential for embedded systems
I discovered embedded software in 2008, when I was a student learning about programming on an [MCS-51][2] chip. Because I was majoring in computer science, all the programs I was doing in other courses were executed on a PC. But programming on a chip was a completely different experience. For the first time, I saw my programs running on a bare-metal board, and I can still remember the excitement when my first cycling lamp program ran successfully.
The excitement was relatively short-lived, though. The more bare-metal programs I wrote, the more issues I encountered. I wasn't alone in this frustration. Programming a chip directly is hard, and there are good reasons PCs use an operating system. Unfortunately, computer chips (an embedded system) don't normally have an OS. They're "hard coded" with code with no OS to help manage how the code gets executed.
Here are the problems you might encounter when hard coding a computer chip:
#### Concurrency
You don't have daemons on a chip to manage execution. For bare-metal programs, there is inevitably a huge `while (1)` loop that contains almost all the transaction logic of the whole project. Each transaction invokes one or more delay functions. These are executed serially when the CPU is running a delay function. There's nothing to preempt an unnecessary delay, so the transaction reset has to wait. As a result, much of the CPU time is wasted on empty loops, which is bad for concurrency.
#### Modularity
From the perspective of a software project, the principle of high cohesion and low coupling is always emphasized during the development process. However, modules in bare-metal software usually depend on each other heavily. As mentioned above, most functions are collected in a huge `while (1)` loop, which is hard to divide into modules. It's just not convenient to design software with low coupling, which makes it difficult to develop large projects on bare-metal boards.
Also, developers must be careful to use delay functions when a watchdog timer is involved. If the delay time is too long, then the main function doesn't have an opportunity to reset the watchdog, so the watchdog is triggered during execution. For bare-metal development, there are too many things to consider, even when invoking a delay function. The more complex the project is, the more care you need to take. Imagine trying to decouple this series of delicately timed interactions into modules.
#### Ecosystem
Many advanced software components depend on the implementation of the lower-level operating system. For example, I developed an open source project based on [FreeModbus][3] that I'd planned to transplant to various platforms, even to bare metal. But compared to the convenience of adapting it to different operating systems, some functions are too complex to implement on all bare-metal boards. Worse still, many implementations would have to be designed from scratch on different hardware platforms because of the lack of commonality.
For now, my implementation of the Modbus stack still cannot run on bare-metal boards.
Many WiFi software-development kits provided by big companies such as Realtek, TI, and MediaTek can run only on the operating system. They don't publish their firmware's source code for the user to modify, so you can't use them within a bare-metal environment.
#### Real-time capability
Real-time capability is necessary for some application fields. For some use cases, a critical software step must be triggered at a specific time. For industry control, for instance, mechanical devices must complete actions in a predetermined order and timing. Without ensuring real-time capability, there would be malfunctions that could endanger the lives of workers. On bare-metal platforms, when all the functions are jammed into one big `while (1)` loop, it's impossible to maintain the real-time capabilities.
#### Reusability
Reusability depends on modularity. Nobody wants to do the same job over and over, especially if that job is writing code. Not only is it a waste of time, but it makes code maintenance exponentially more complex. And yet, on various hardware platforms with different chips, the same function has to be adapted to different hardware because the implementation depends on low-level hardware. It's inevitable to reinvent the wheel.
### Advantages of RTOS
Fortunately, there are operating systems written for chips: they're called a real-time operating system (RTOS), and like most operating systems, they have a scheduler to ensure a predictable order of code execution.
I first used an RTOS for bare metal in 2010. The [STM32][4] series of microcontrollers (MCUs) was starting to become popular, and because they were so powerful and rich in features, many people were running operating systems on them. I used the [RT-Thread][5] operating system, which has many available, ready-to-use components built on it. It's available under the Apache 2.0 license, and I feel more comfortable with it compared to other operating systems. I have been developing on it for 10 years.
For bare-metal programming, an RTOS solves most of the biggest problems we face.
#### Modularity
With an operating system, the entire software can be split into several tasks (known as threads). Each thread has its own independent execution space. They're independent of each other, which improves modularity.
#### Concurrency
When a thread invokes the delay function, it automatically yields the CPU to other threads that need to run, which improves the utilization of the entire CPU and, ultimately, the concurrency.
#### Real-time
An RTOS is designed with real-time capabilities. Each thread is assigned a specified priority. More important threads are set to a higher priority, with less important threads set to lower ones. In this way, the real-time performance of the entire software is guaranteed.
#### Development efficiency
The operating system provides a unified layer of abstract interfaces. This facilitates the accumulation of reusable components and improves development efficiency.
The operating system is a product of the wisdom of a group of software geeks. Many common software functions, such as semaphore, event notification, mailbox, ring buffer, one-way chain list, two-way list, and so on, are encapsulated and abstracted to make them ready to use.
Operating systems like Linux and RT-Thread implement a standard set of hardware interfaces for fragmented hardware. This is known as the device-driver framework. Because of this, a software engineer can focus on development with no concern about the underlying hardware or reinventing the wheel.
#### Software ecosystem
The richness of the RT-Thread ecosystem brings the process of quantitative changes to qualitative ones. The improvement in modularity and reusability with an operating system allows programmers to encapsulate RTOS-based, embedded-friendly reusable components. These can be used in projects as well as be shared with other embedded-application developers who need to maximize the value of software.
For example, the LkdGui project is an open source graphics library designed for monochrome displays. You might see it used in industrial settings for simple, beautiful graphical interfaces for control panels. LkdGui provides graphical functions, such as drawing points, lines, rectangles, text display, button widgets, and progress bars.
![LkdGui][6]
The ability to reuse a library as extensive and robust as LkdGui means programmers can build on top of their peers' work. Without an RTOS, this just wouldn't be possible.
### Try RT-Thread
I'm an open source geek, and I have open sourced some embedded software on GitHub. Before creating open source software, I rarely talked with others about my projects because people were inevitably using different chips or hardware platforms, so our code could hardly run on one another's hardware. An RTOS like RT-Thread greatly improves software reusability, so many diverse experts all over the world can communicate with each other about the same project. This is encouraging more and more people to share and talk about their projects. If you're doing bare-metal programming, try RT-Thread on your next project.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/6/open-source-rtos
作者:[Zhu Tianlong][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/zhu-tianlong
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen)
[2]: https://en.wikipedia.org/wiki/Intel_MCS-51
[3]: https://www.embedded-solutions.at/files/freemodbus-v1.6-apidoc/
[4]: https://en.wikipedia.org/wiki/STM32
[5]: https://github.com/RT-Thread/rt-thread
[6]: https://opensource.com/sites/default/files/uploads/lkdgui.jpg (LkdGui)

View File

@ -1,5 +1,5 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )

View File

@ -1,181 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Summarizing your command usage on Linux)
[#]: via: (https://www.networkworld.com/article/3567050/summarizing-your-command-usage-on-linux.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
Summarizing your command usage on Linux
======
With a modest string of commands, you can get a quick look at what commands you're using on your Linux system and how often.
Getty Images
Getting a summary of the commands you use on a Linux system requires only a relatively modest string of commands along with a couple pipes to tie them all together. When your history buffer preserves the most recent 1,000 or 2,000 commands, summarizing command activity can get rather tedious. This post provides a handy way to summarize command usage and highlight those commands used most frequently.
To start, keep in mind that a typical entry in a command history might look like this. Note that command is displayed after the command sequence number and followed by its arguments.
```
91 sudo apt-get install ccrypt
^
+-- command
```
Note that the history command, adhering to the HISTSIZE setting, will determine how many commands will be preserved. This could be 500, 1,000 or more. If you don't like how many commands are preserved for you, you can add or change the HISTSIZE setting in your .bashrc or other start-up file.
```
$ echo $HISTSIZE
1000
$ history | wc -l
1000
$ grep HISTSIZE ~/.bashrc
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
```
One of the primary benefits of remembering a significant number of commands is that it makes it easy for you to rerun commands you've used in the past without having to retype or remember them. It also allows you to easily review how far you've moved through some series of tasks that you might be working on. When you use the **history** command by itself, you'll see something like this with your oldest commands listed first:
```
$ history
7 vi tasks
8 alias
9 echo $HISTTIMEFORMAT
10 history
11 date
```
Viewing the most recent commands requires looking at the bottom of the recorded commands:
```
$ history | tail -4
1007 echo $HISTSIZE
1008 history | wc -l
1009 history
1010 history | tail -4
```
Alternately, you could use the **tail** command to view the bottom of your **.bash_history** file, but the numbers shown by the **history** command allow you to rerun the commands by typing things like **!1010** and are generally more useful.
To prepare a summary of the commands used (such as **vi** and **echo**), you can start by using **awk** to separate that information from the rest of each command saved in our history:
```
$ history | awk '{print $2}'
vi
alias
echo
history
date
```
If you then pass the list of commands in your history to the **sort** command to group the commands in alphabetical order, you'll get something like this:
```
$ history | awk '{print $2}' | sort
7z
7z
alias
apropos
cd
cd
```
Next, passing the output of that **sort** command to **uniq -c** will count how many of each command were used.
```
$ history | awk '{print $2}' | sort | uniq -c
2 7z
1 alias
2 apropos
38 cd
21 chmod
```
Last, adding a second **sort** command to sort the command group counts in reverse numeric order will list your most heavily used commands first.
```
$ history | awk '{print $2}' | sort | uniq -c | sort -nr
178 ls
95 vi
63 cd
53 sudo
41 more
```
This gives you an idea which commands you use the most, but won't include any commands that you may be intentionally omitting from your history file with a setting like this one:
```
HISTIGNORE="pwd:clear:man:history"
```
### When history changes
For the default history format, the first field in **history** command output will be the sequence number for each command, and the second will be the command that was used. For this reason, all of the **awk** commands shown above were set to display **$2**.
```
$ alias cmds='history | awk '\''{print $2}'\'' | sort | uniq -c | sort -nr'
```
If you've modified the format of your history entries with a setting like the one shown below that adds date and time settings to your command history, you will also have to modify the alias that you're setting up.
```
$ echo $HISTTIMEFORMAT
%d/%m/%y %T
```
This date/time information can be very helpful at times, but means that you have to pick out the 4th field instead of the 2nd in your command history to summarize your command usage because your history entries will look like this:
```
91 05/07/20 16:37:39 sudo apt-get install ccrypt
^
+-- command
```
The alias for examining your command history would, therefore, look like this instead after changing the $2 to $4.
```
$ alias cmds='history | awk '\''{print $4}'\'' | sort | uniq -c | sort -nr'
```
To store either alias in your **.bashrc** or other startup file, make sure you insert a backslash in front of the **$** sign so that bash doesn't try to interpret **$4**.
```
alias cmds='history | awk '\''{print \$2}'\'' | uniq -c | sort -nr'
alias cmds='history | awk '\''{print \$4}'\'' | uniq -c | sort -nr'
```
Note that the date and time information is stored on separate lines in your history file from the command themselves. So, when this information is added, the bash history file will have twice as many lines, though your history command output will not:
```
$ wc -l .bash_history
2000 .bash_history
$ history | wc -l
1000
```
### Wrap-up
You can always decide how much command history you want to preserve and what commands are not worth recording to make your command summaries most useful.
Join the Network World communities on [Facebook][1] and [LinkedIn][2] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3567050/summarizing-your-command-usage-on-linux.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[1]: https://www.facebook.com/NetworkWorld/
[2]: https://www.linkedin.com/company/network-world

View File

@ -0,0 +1,230 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How to read Lynis reports to improve Linux security)
[#]: via: (https://opensource.com/article/20/8/linux-lynis-security)
[#]: author: (Alan Formy-Duval https://opensource.com/users/alanfdoss)
How to read Lynis reports to improve Linux security
======
Use Lynis' scans and reports to find and fix Linux security issues.
![Lock][1]
When I read Gaurav Kamathe's article _[Scan your Linux security with Lynis][2]_, it reminded me of my time as a systems administrator for the US Department of Labor. One of my duties was to keep our Unix servers hardened. Each quarter, an independent verifier came in to review our servers' security status. Each time on the day the verifier was scheduled to arrive, I ran Security Readiness Review (SRR), a scanning tool that used a large set of scripts to identify and report any security findings. SRR was open source, so I could view all the source scripts and their functions. This enabled me to look into the code, determine what specifically was wrong, and quickly fix each problem it found.
### What is Lynis?
[Lynis][3] is an open source security-auditing tool that works much like SRR by scanning a Linux system and providing detailed reports on any weaknesses it finds. Also like SRR, it is made up of a large set of scripts, and each script checks for a specific item, e.g., minimum and maximum password age requirements.
After running Lynis, you can use its report to locate each item's script and learn exactly how Lynis checked for and reported each problem. You can also use the same script code to create new code to automate a resolution.
### How to read Lynis reports
Since Gaurav's article covered Lynis' installation and usage, in this article, I'll show some examples of how you can read and use its reports.
To get started, run an audit:
```
`# lynis audit system --quick`
```
After it completes, the full report will be displayed on your screen. Towards the bottom, the **Suggestions** section lists all the items that may need to be triaged to better harden the system, as well as a TEST-ID for each.
To harden the system and reduce the size of the list, start chasing each item. The description in the **Suggestions** section may be everything you need to know what action to take. If it doesn't, you can use the `show details` command:
```
`# lynis show details TEST-ID`
```
For instance, one of the suggestions on my system is:
> The database required for `locate` could not be found. Run `updatedb` or `locate.updatedb` to create this file. [FILE-6410]
It looks like I just need to run the command `updatedb`, but if I want to be sure, I can use Lynis' `show details` option:
```
# lynis show details FILE-6410
2020-06-16 20:54:33 Performing test ID FILE-6410 (Checking Locate database)
2020-06-16 20:54:33 Test: Checking locate database
2020-06-16 20:54:33 Result: file /var/lib/mlocate/mlocate.db not found
2020-06-16 20:54:33 Result: file /var/lib/locate/locatedb not found
2020-06-16 20:54:33 Result: file /var/lib/locatedb not found
2020-06-16 20:54:33 Result: file /var/lib/slocate/slocate.db not found
2020-06-16 20:54:33 Result: file /var/cache/locate/locatedb not found
2020-06-16 20:54:33 Result: file /var/db/locate.database not found
2020-06-16 20:54:33 Result: database not found
2020-06-16 20:54:33 Suggestion: The database required for 'locate' could not be found. Run 'updatedb' or 'locate.updatedb' to create this file. [test:FILE-6410] [details:-] [solution:-]
2020-06-16 20:54:33 ====
```
These details indicate Lynis was unable to find various files. This case is very clear-cut. I can run the `updatedb` command and recheck this test:
```
# updatedb
# lynis --tests FILE-6410
```
Furthermore, rechecking the details shows which file it found that satisfied the test:
```
# lynis show details FILE-6410
2020-06-16 21:38:40 Performing test ID FILE-6410 (Checking Locate database)
2020-06-16 21:38:40 Test: Checking locate database
2020-06-16 21:38:40 Result: locate database found (/var/lib/mlocate/mlocate.db)
2020-06-16 21:38:40 Result: file /var/lib/locate/locatedb not found
2020-06-16 21:38:40 Result: file /var/lib/locatedb not found
2020-06-16 21:38:40 Result: file /var/lib/slocate/slocate.db not found
2020-06-16 21:38:40 Result: file /var/cache/locate/locatedb not found
2020-06-16 21:38:40 Result: file /var/db/locate.database not found
2020-06-16 21:38:40 ====
```
### Diving deeper
Many of Lynis' suggestions are not as straightforward as this one. If you aren't sure what a finding or a suggestion refers to, it can be difficult to know how to fix the problem. Suppose you run Lynis against a new Linux server, and there are several items pertaining to the secure shell (SSH) daemon, one of which refers to the `MaxAuthTries` setting:
```
* Consider hardening SSH configuration [SSH-7408]
    - Details  : MaxAuthTries (6 --> 3)
      <https://cisofy.com/lynis/controls/SSH-7408/>
```
To resolve this, you need to know the location of the SSH configuration files. A seasoned Linux administrator may already know where to find them, but if you don't, there is a way to see where Lynis found them.
#### Locate Lynis test scripts
Lynis supports many operating systems; therefore, your installation location might vary. On a Red Hat Enterprise Linux or Fedora Linux system, use `rpm` to find the test files:
```
`# rpm -ql lynis`
```
This lists all the test files and reports their location in the `lynis/include` directory. Search this directory for the TEST-ID you want to know about (SSH-7408 in this case):
```
# grep SSH-7408 /usr/share/lynis/include/*
/usr/share/lynis/include/tests_ssh:    # Test        : SSH-7408
```
#### Find SSH issues
The file named `tests_ssh` contains the TEST-ID, and this is where you can find the scan functions related to SSH. Take a look at this file to see the various functions called by the Lynis scanner. The first section defines a list of directories in a variable called `SSH_DAEMON_CONFIG_LOCS`. The following few sections are responsible for checking the SSH daemon status, locating its configuration file, and identifying its version. I found the code that looks for the configuration file in the section for Test SSH-7404, described as "Determine SSH daemon configuration file location". This code contains a **`for`** loop that searches the items in the list for a file called `sshd_config`. I can use this logic to do my own search:
```
# find /etc /etc/ssh /usr/local/etc/ssh /opt/csw/etc/ssh -name sshd_config
/etc/ssh/sshd_config
/etc/ssh/sshd_config
find: /usr/local/etc/ssh: No such file or directory
find: /opt/csw/etc/ssh: No such file or directory
```
Further exploring this file reveals the code related to finding SSH-7408. This test covers `MaxAuthTries` and several other settings. Now I can find the variable in the SSH configuration file:
```
# grep MaxAuthTries /etc/ssh/sshd_config
#MaxAuthTries 6
```
#### Fix legal banner problems
Lynis also reported a finding pertaining to the legal banners shown when you log into a system. On my home desktop system (where I don't expect many other people to log in), I haven't bothered to change the default `issue` files. A corporate or government system is likely required to include a legal banner to warn users that their logins and activity may be recorded and monitored. Lynis reports this with tests BANN-7126 and BANN-7130:
```
* Add a legal banner to /etc/issue, to warn unauthorized users [BANN-7126]
      <https://cisofy.com/lynis/controls/BANN-7126/>
* Add legal banner to /etc/issue.net, to warn unauthorized users [BANN-7130]
      <https://cisofy.com/lynis/controls/BANN-7130/>
```
I don't find much on my system running Fedora 32 Workstation:
```
# cat /etc/issue /etc/issue.net
\S
Kernel \r on an \m (\l)
\S
Kernel \r on an \m (\l)
```
I could add something like "Keep out" or "Don't break anything," but the test's description doesn't provide enough information to resolve the issue, so I took another look at the Lynis scripts. I noticed that the `include` directory contained a file called `tests_banners`; this seemed like a good place to look. With some help from `grep`, I saw the associated tests:
```
# grep -E 'BANN-7126|BANN-7130' /usr/share/lynis/include/tests_banners
    # Test        : BANN-7126
    Register --test-no BANN-7126 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check issue banner file contents"
    # Test        : BANN-7130
    Register --test-no BANN-7130 --preqs-met ${PREQS_MET} --weight L --network NO --category security --description "Check issue.net banner file contents"
```
After examining the associated code in the file for the test, I found out that both of these tests are iterating through some predefined legal terms with a `for` loop:
```
`for ITEM in ${LEGAL_BANNER_STRINGS}; do`
```
These legal terms are stored in the variable `LEGAL_BANNER_STRINGS` defined at the top of the file. Scrolling back to the top shows the full list:
```
`LEGAL_BANNER_STRINGS="audit access authori condition connect consent continu criminal enforce evidence forbidden intrusion law legal legislat log monitor owner penal policy policies privacy private prohibited record restricted secure subject system terms warning"`
```
My initial suggestions ("keep out" and "don't break anything") wouldn't have satisfied the test, because they don't contain any words from this list.
This banner message contains several of the required words, and therefore, it will satisfy this test and prevent Lynis from reporting it:
> Attention, by continuing to connect to this system, you consent to the owner storing a log of all activity. Unauthorized access is prohibited.
Note that this message must be added to both `/etc/issue` and `/etc/issue.net`.
### Making it repeatable
You could make these edits manually, but you may instead want to consider automation. For example, there may be many settings that need to be changed, or you might need to do these edits on a regular basis on many servers. Creating a hardening script would be a great way to streamline this process. For SSH configurations, some `sed` commands in your hardening script will resolve those findings. Or, you might use an echo statement to add the legal banners:
```
sed -i '/MaxAuthTries/s/#MaxAuthTries 6/MaxAuthTries 3/' /etc/ssh/sshd_config
echo "Legal Banner" | tee -a /etc/issue /etc/issue.net
```
Automation enables you to create a repeatable script that can be saved and managed across your infrastructure. You could also incorporate this script in your initial server provisioning.
### Harden your system
This type of exercise can improve your scripting skills both by following along with existing code and by writing your own scripts. Because it is open source, Lynis makes it easy to see under the hood how your system is checked and what its reports mean. The end result will be a well-hardened system that you can show off anytime those auditors come around.
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/8/linux-lynis-security
作者:[Alan Formy-Duval][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/alanfdoss
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/security-lock-password.jpg?itok=KJMdkKum (Lock)
[2]: https://opensource.com/article/20/5/linux-security-lynis
[3]: https://github.com/CISOfy/lynis

View File

@ -0,0 +1,160 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Merging and sorting files on Linux)
[#]: via: (https://www.networkworld.com/article/3570508/merging-and-sorting-files-on-linux.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
Merging and sorting files on Linux
======
Metamorworks / Getty Images
There are a number of ways to merge and sort text files on Linux, but how to go about it depends on what you're trying to accomplish whether you simply want to put the content of multiple files into one big file, or organize it in some way that makes it easier to use. In this post, we'll look at some commands for sorting and merging file contents and focus on how the results differ.
### Using cat
If all you want to do is pull a group of files together into a single file, the **cat** command is an easy choice. All you have to do is type "cat" and then list the files on the command line in the order in which you want them included in the merged file. Redirect the output of the command to the file you want to create. If a file with the specified name already exists, it will be overwritten by the one you are creating. For example:
```
$ cat firstfile secondfile thirdfile > newfile
```
**Read more:** [World's 10 fastest supercomputers][1]
If you want to add the content of a series of files to an existing file rather than overwrite it, just change the **&gt;** to **&gt;&gt;**.
```
$ cat firstfile secondfile thirdfile >> updated_file
```
If the files you are merging follow some convenient naming convention, the task can be even simpler. You won't have to include all of the file names if you can specify them using a regular expression. For example, if the files all end with the word "file" as in the example above, you could do something like this:
```
$ cat *file > allfiles
```
Note that the command shown above will add file contents in alphanumeric order. On Linux, a file named "filea" would be added before one named "fileA", but after one named "file7". After all, we don't just have to think "ABCDE" when we're dealing with an alphanumeric sequence; we have to think "0123456789aAbBcCdDeE". You can always use a command like "ls *file" to view the order in which the files will be added before merging the files.
**NOTE:** It's a good idea to first make sure that your command includes all of the files that you want in the merged file and no others especially when you're using a wild card like “*”. And don't forget that the merged files will still exist as separate files, which you might want to delete once the merge has been verified.
### Merging files by age
If you want to merge your files based on the age of each file rather than by file names, use a command like this one:
```
$ for file in `ls -tr myfile.*`; do cat $file >> BigFile.$$; done
```
Using the **-tr** options (**t**=time, **r**=reverse) will result in a list of files in oldest-first age order. This can be useful, for example, if you're keeping a log of certain activities and want the content added in the order in which the activities were performed.
The **$$** in the command above represents the process ID for the command when you run it. It's completely unnecessary to use this, but it makes it nearly impossible that you will inadvertently add onto the end of an existing file instead of creating a new one. If you use $$, the resultant file might look like this:
```
$ ls -l BigFile.*
-rw-rw-r-- 1 justme justme 931725 Aug 6 12:36 BigFile.582914
```
### Merging and sorting files
Linux provides some interesting ways to sort file content before or after the merge.
#### Sorting content alphabetically
If you want the merged file content to be sorted, you can sort the overall content with a command like this:
```
$ cat myfile.1 myfile.2 myfile.3 | sort > newfile
```
If you want to keep the content grouped by file, sort each file before adding it to the new file with a command like this:
```
$ for file in `ls myfile.?`; do sort $file >> newfile; done
```
#### Sorting files numerically
To sort file contents numerically, use the **-n** option with sort. This option is useful only if the lines in your files start with numbers. Keep in mind that, in the default order, “02” would be considered smaller than "1". Use the **-n** option when you want to ensure that lines are sorted in numeric order.
```
$ cat myfile.1 myfile.2 myfile.3 | sort -n > xyz
```
The **-n** option also allows you to sort file contents by date if the lines in the files start with dates in a format like "2020-11-03" or "2020/11/03" (year, month, day format). Sorting by dates in other formats will be tricky and will require far more complex commands.
### Using paste
The **paste** command allows you to join the contents of files on a line-by-line basis. When you use this command, the first line of the merged file will contain the first line of each of the files being merged. Here's an example in which I've used capital letters to make it easy to see where the lines came from:
```
$ cat file.a
A one
A two
A three
$ paste file.a file.b file.c
A one B one C one
A two B two C two
A three B three C thee
B four C four
C five
```
Redirect the output to another file to  save it:
```
$ paste file.a file.b file.c > merged_content
```
Alternately, you can paste files together such that the content of each file is joined in a single line. This requires use of the **-s** (sequential) option. Notice how the output this time shows each file's content:
```
$ paste -s file.a file.b file.c
A one A two A three
B one B two B three B four
C one C two C thee C four C five
```
### Using join
Another command for merging files is **join**. The **join** command allows you to merge the content of multiple files based on a common field. For example, you might have one file that contains phone numbers for a group of coworkers and another that contains their personal email addresses and theyre both listed by the individuals' names. You can use join to create a file with both phone numbers and email addresses.
One important restriction is that the files must have their lines listed in the same order and include the join field in each file.
Here's an example command:
```
$ join phone_numbers email_addresses
Sandra 555-456-1234 bugfarm@gmail.com
Pedro 555-540-5405
John 555-333-1234 john_doe@gmail.com
Nemo 555-123-4567 cutie@fish.com
```
In this example, the first field (first names) must exist in each file even if the additional information is missing or the command will fail with an error. Sorting the contents is helpful and probably a lot easier to manage, but is not required as long as the order is consistent.
### Wrap-Up
You have a lot of options on Linux for merging and sorting data stored in separate files. The choices can make some otherwise tedious tasks surprisingly easy.
Join the Network World communities on [Facebook][2] and [LinkedIn][3] to comment on topics that are top of mind.
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3570508/merging-and-sorting-files-on-linux.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[1]: https://www.networkworld.com/article/3563766/the-10-fastest-supercomputers-are-led-by-one-28x-faster-than-the-rest.html
[2]: https://www.facebook.com/NetworkWorld/
[3]: https://www.linkedin.com/company/network-world

View File

@ -0,0 +1,120 @@
[#]: collector: (lujun9972)
[#]: translator: ( )
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Photoflare: An Open Source Image Editor for Simple Editing Needs)
[#]: via: (https://itsfoss.com/photoflare/)
[#]: author: (Abhishek Prakash https://itsfoss.com/author/abhishek/)
Photoflare: An Open Source Image Editor for Simple Editing Needs
======
_**Brief: Photoflare is an image editor available for Linux and Windows. The editor has a free and open source community edition.**_
When it comes to image editing on Linux, GIMP is the first and obvious choice. But GIMP could be overwhelming if you dont need advanced editing feature. This is where applications like Photoflare step in.
### PhotoFlare: A simple image editor
![][1]
Photoflare is an editor that provides basic image editing features with a simple-to-use interface.
It is inspired by the popular Windows application [PhotoFiltre][2]. The application is not a clone though and it has been written in C++ from scratch and uses Qt framework for the interface.
The features include cropping, flipping/rotating, resizing image. You can also tools like paint brush, paint bucket, spray can, blur tool and eraser. The magic wand tool lets you select a specific area of the image.
You can also add lines and text on an image. You cal also change the hue variation to change the color tone of the image.
You can also create an image from scratch like any other [paint application][3].
The batch editing option allows you to resize, convert file format and add filter to multiple photos simultaneously.
![Batch Editing Feature in Photoflare | Photo Credit: Photoflare website][4]
### Features of Photoflare
Ill list the main features of Photoflare for easier reference:
* Create/draw an image
* Crop an image
* Rotate an image
* Resize image
* Edit images with tools like paint brush, paint bucket, spray, blur tool and image
* Add lines and text on images
* Change the color tone of images
* Add vintage filter
* Batch resize, filter etc
### Installing Photflare on Linux
![][5]
On the website of Photoflare, youll find the pricing and the option for monthly subscription. However, the application is open source and its [source code is available on GitHub][6].
The application is also **free** to use. The [pricing/subscription part][7] is for financial support of the project. You can download it for free and if you like the application and would continue to use it, consider donating to the project.
Photoflare has an [official PPA][8] for Ubuntu and Ubuntu based distributions. This PPA is available for Ubuntu 18.04 and 20.04 versions.
Open a terminal and use the following commands one by one to install Photoflare:
```
sudo add-apt-repository ppa:photoflare/photoflare-stable
sudo apt update
sudo apt install photoflare
```
To remove Photoflare from Ubuntu-based distributions, use this command:
```
sudo apt remove photoflare
```
It would be a good idea to remove the PPA as well:
```
sudo add-apt-repository -r ppa:photoflare/photoflare-stable
```
**Arch Linux** and Manjaro users can [get it from AUR][9].
There is no ready to use package for Fedora so youll have to get the source code:
[Photoflare source code][6]
### Experience with Photoflare
I find it somewhat similar to [Pinta][10] with a bit more features. It is a simple tool for some basic image editing. The batch feature is a plus.
I did notice image doesnt look sharp when it is opened for editing. I opened a screenshot for editing and the fonts looked blurry. However, after saving the image and opening it in an [image viewer][11] showed no such issue.
Altogether, it is a decent tool if you are not looking for a professional grade image editing.
If you have used it in the past or if you give it a try, do share your experience with Photoflare.
--------------------------------------------------------------------------------
via: https://itsfoss.com/photoflare/
作者:[Abhishek Prakash][a]
选题:[lujun9972][b]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/abhishek/
[b]: https://github.com/lujun9972
[1]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/08/Photoflare.jpg?ssl=1
[2]: http://photofiltre.free.fr/frames_en.htm
[3]: https://itsfoss.com/open-source-paint-apps/
[4]: https://i0.wp.com/itsfoss.com/wp-content/uploads/2020/08/batch_editing_photoflare.png?ssl=1
[5]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2020/08/photoflare-editor-linux.png?resize=800%2C580&ssl=1
[6]: https://github.com/PhotoFlare/photoflare
[7]: https://photoflare.io/pricing/
[8]: https://launchpad.net/~photoflare/+archive/ubuntu/photoflare-stable
[9]: https://aur.archlinux.org/packages/photoflare-git/
[10]: https://itsfoss.com/pinta-new-release/
[11]: https://itsfoss.com/image-viewers-linux/

View File

@ -0,0 +1,114 @@
[#]: collector: (lujun9972)
[#]: translator: (silentdawn-zz)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Code your hardware using this open source RTOS)
[#]: via: (https://opensource.com/article/20/6/open-source-rtos)
[#]: author: (Zhu Tianlong https://opensource.com/users/zhu-tianlong)
使用 RT-Thread 实时操作系统驱动你的硬件
======
编程驱动一个微处理器芯片是相当有难度的,但在嵌入式系统开发上,实时操作系统可以为你解决很多此类的困难。
![Puzzle pieces coming together to form a computer screen][1]
从通用计算的角度,操作系统是提供计算机基本功能的一组软件。操作系统保证了计算机硬件可以探测并响应外围器件(如键盘、屏幕、移动设备、打印机等),并管理内存空间和外部存储空间。
虽然一个 CPU 核心同一时间只能运行单个线程,但现代操作系统可以使多个程序表现的像是在同时运行。每一个任务执行的如此之短,一系列任务切换的如此之快,以至于看起来多个任务像是在并行进行。这一切都是由 _调度器_ 的子进程来控制的。
操作系统通常是为计算机准备的,安装在硬盘上,管理计算机所要执行的任务。
### 为什么实时操作系统对嵌入式系统而言不可或缺
我曾经在 2008 年接触过嵌入式软件,那时候我还是一名学生,正在学习 [MCS-51][2] 微处理器编程。因为我的主修专业是计算机科学,我在其它课程中的所有程序都是在 PC 上执行的。为微处理器芯片编程是完全不同的体验。人生中第一次,我看到我的程序在裸板上运行,即使到现在我仍然记得,在我看到自己人生中第一个循环点灯程序成功运行时的那种兴奋和激动。
但那种兴奋转瞬即逝。随着为裸板写出越来越多的程序,我遇到了越来越多的问题。这种沮丧并不是我独有的。直接为芯片写程序很困难,这也是 PC 要运行操作系统的很重要的原因。不幸的是,微处理器芯片(或嵌入式系统)通常是没有操作系统的,它们只能采用”硬编码“的方式编程,没有操作系统帮助你管理代码的运行。
在以”硬编码“的方式为处理芯片编写代码的时候,可能会遇到下列问题:
#### 并发
在裸板上是没有管理程序运行的现成守护进程的。嵌入式系统软件中,无可避免的要把所有的逻辑功能放在一个巨大的 `while (1)` 循环中。每个功能可能包含一个或多个延时函数。CPU 在运行延时函数的时候是顺序执行的,没有任何办法跨越一个不必要的延时。正因如此,运行事务的复位操作只能是等待。最终结果就是很多的 CPU 处理时间浪费在空循环上,这对任务的并发非常不利。
#### 模块化
从软件工程的角度,高內聚低耦合原则在软件开发过程中被不厌其烦的频频强调,但是嵌入式软件的不同模块之间常常是重度耦合的,很多功能都集中在一个巨大的 `while (1)` 循环中,很难切分为模块。设计低耦合软件在编程上只是繁琐一些,但在嵌入式系统上,要低耦合就难以编写比较大型的软件。
与此同时,如果使用了看门狗定时器,程序员还得在调用延时函数时倍加小心。如果延时时间太长,主程序没有得到及时”喂狗“的时机,那么看门狗将在程序运行过程中被触发。嵌入式系统软件开发过程中,需要考虑的东西太多了,即便是个简单的延时函数,都不能掉以轻心。软件越复杂,就越需要细心,越需要想方设法将一系列具有精细时间关系的交互功能拆分为模块。
#### 软件生态
很多厉害的软件组件依赖于其所基于的底层操作系统的实现。举个自身的例子,我曾开发过一个基于 [FreeModbus][3] 的开源项目,原计划将它移植到多种平台上,包括裸板。相对于在各种操作系统上的移植,有些函数在裸板上实现的话实在是太复杂了,以至于无法完成。更糟糕的是,很多硬件平台因为缺乏一致性,只能各自从头做起。
直至现在,我的 Modbus 栈仍然不支持在裸板上运行。
很多像 Realtek、TI 和 MediaTek 的大厂,所提供的 WiFi 软件开发工具只能在操作系统上运行,且他们不公开固件源码,所以在裸板上根本没法使用这些工具。
#### 实时性
有些应用领域对实时性有要求,比如有些场景中,必须在特定的时间触发特定的软件操作。在工业控制场景,机器实体控制过程中,机械部件必须以确定的时间和确定的顺序执行动作。如果不能保证控制系统的实时性,整个机器可能出现功能异常,甚至危及工人生命。在裸板平台,所有的功能都塞在一个巨大的 `while (1)` 循环中,实时性无从保证。
#### 重用性
重用性依赖于模块化。没谁愿意翻来覆去做一成不变的事,对程序员而言更是如此。这不单单是浪费时间,更要命的是这使得代码的维护异常复杂。尤其是,因为功能的实现依赖于底层的硬件,使用了不同芯片的不同种硬件平台上,同样的功能不得不针对每个硬件平台进行适配。这种情况下,重新发明轮子是无法避免的。
### 实时操作系统的优势
幸运的是现在有针对各种微处理器芯片的操作系统可用它们被称为实时操作系统RTOS和大多数操作系统一样它们拥有调度器保证代码以可预见的顺序运行。
我是在 2010 年初次在裸板上使用实时操作系统。那时候,[STM32][4] 系列微处理器MCU开始普及因为这种微处理器性能强大、功能丰富很多人在上面跑操作系统。我使用的是 [RT-Thread][5] 操作系统,有很多基于它的现成组件可用。它使用的是 Apache 2.0 许可,和其它操作系统的许可相比,我觉得这个很舒心。我已经基于它作为平台从事开发工作 10 年了。
使用实时操作系统为裸板编程,操作系统为我们解决了需要处理的大部分问题。
#### 模块化
在操作系统支持下,整个软件可以分割为多个任务(即线程)。每个线程拥有自己独立的运行空间。线程之间互相独立,这促进了软件的模块化。
#### 并发
如果一个线程有延时函数,它将自动让出 CPU 资源给需要 CPU 的线程,这提高了 CPU 的整体利用率,也提升了系统的并发性能。
#### 实时性
实时操作系统从设计上就具备实时性。每个线程都被指定了特定的优先级,重要的线程设置为更高的优先级,不重要的线程优先级也低。正是以这种方式,软件整体的实时性得到了保证。
#### 开发效率
操作系统提供了统一的抽象接口,这使得可重用组件得以不断积累,同时提升了开发效率。
操作系统是软件极客集体智慧的结晶。很多通用的软件功能,如信号量、事件提醒、邮箱、环形缓冲、单向链表、双向链表等,被抽象出来并实现了封装,可随时调用。
Linux、RT-Thread 等操作系统为五花八门的硬件实现了一致的硬件接口,也就是常说的设备驱动框架。正因如此,软件工程师可以专注于软件开发,而不用关心底层的硬件,也不用重复造轮子。
#### 软件生态
RT-Thread 丰富的软件生态为大量的从业者带来了巨大的改变。操作系统带来的模块化和重用性,使得程序员可以基于 RT-Thread 封装出方便嵌入式系统开发使用的可重用组件。这些组件可以在其它项目中重用,也可以分享给其他的嵌入式应用开发者,以最大化软件的价值。
比如LkdGui 是个开源的单色显示图形库你可能在工业控制面板上简单而美观的设置界面上见过它。LkdGui 提供了像描点、画线、绘矩形及显示文本、按钮组件、进度条等绘图功能。
![LkdGui][6]
使用像 LkdGui 这样兼具扩展性和健壮性的功能库,程序员们可以在伙伴已有工作成果的基础上充分施展自己的才能。而这一切,没有实时操作系统这样一个统一的基础,是根本不可能的。
### 试用 RT-Thread
作为开源极客,我已經在 GitHub 上开源了一些嵌入式软件。在发布开源软件之前,我很少对他人谈及自己曾经的项目,因为不同的人在使用各种不同的微处理器芯片和硬件平台,我的代码极可能无法在他人的板子上运行。 类似于 RT-Thread 的操作系统极大的提升了软件的可重用性,所以全世界的不同领域的专家得以就同一个项目展开探讨。这鼓励着越来越多的人分享和交流各自的项目。如果你在做裸板的软件开发,下次可以试试 TR-Thread。
--------------------------------------------------------------------------------
via: https://opensource.com/article/20/6/open-source-rtos
作者:[Zhu Tianlong][a]
选题:[lujun9972][b]
译者:[silentdawn-zz](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/zhu-tianlong
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/puzzle_computer_solve_fix_tool.png?itok=U0pH1uwj (Puzzle pieces coming together to form a computer screen)
[2]: https://en.wikipedia.org/wiki/Intel_MCS-51
[3]: https://www.embedded-solutions.at/files/freemodbus-v1.6-apidoc/
[4]: https://en.wikipedia.org/wiki/STM32
[5]: https://github.com/RT-Thread/rt-thread
[6]: https://opensource.com/sites/default/files/uploads/lkdgui.jpg (LkdGui)

View File

@ -0,0 +1,180 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Summarizing your command usage on Linux)
[#]: via: (https://www.networkworld.com/article/3567050/summarizing-your-command-usage-on-linux.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
汇总 Linux 上命令的使用率
======
使用合适的命令,你可以快速了解 Linux 系统上使用的命令以及执行的频率。
汇总 Linux 系统上使用的命令只需相对简单的命令串以及几条管道将它们绑定在一起。当你的历史记录缓冲区保留了最近的 1,000 或 2,000 条命令时,汇总命令活动可能会变得很乏味。这篇文章提供了一种方便的方法来汇总命令并高亮显示最常用的命令。
首先,请记住,典型的历史命令记录可能看起来像这样。请注意,命令显示在命令序列号之后,并紧跟其参数。
```
91 sudo apt-get install ccrypt
^
+-- command
```
请注意history 命令遵循 HISTSIZE 的设置,这会决定保留多少条命令。可能是 500、1,000 或更多。如果你不喜欢它的设置,那么可以在 .bashrc 或其他启动文件中添加或更改 HISTSIZE 设置。
```
$ echo $HISTSIZE
1000
$ history | wc -l
1000
$ grep HISTSIZE ~/.bashrc
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
```
记住大量命令的主要好处之一是,它可以让你轻松地重新运行过去使用的命令,而不必重新输入或记住它们。它还能让你轻松地查看你在一个任务中已经做了多少工作。单独使用 **history** 命令时,你会看到类似下面这样,最早的在最前面:
```
$ history
7 vi tasks
8 alias
9 echo $HISTTIMEFORMAT
10 history
11 date
```
查看最新使用命令需要查看命令的底部:
```
$ history | tail -4
1007 echo $HISTSIZE
1008 history | wc -l
1009 history
1010 history | tail -4
```
另外,你可以使用 ** tail **命令查看 **.bash_history** 文件的底部,但是 **history** 命令显示的数字可以让你输入如 **!1010** 这样的数字重新运行命令,这点通常更有用。
要准备已使用命令的汇总(例如 **vi****echo**),你可以首先使用 **awk** 将命令与 history 中保存的其他信息分隔开来:
```
$ history | awk '{print $2}'
vi
alias
echo
history
date
```
如果你将历史记录中的命令列表传递给 **sort** 命令以按字母顺序对命令进行分组,那么会得到以下内容:
```
$ history | awk '{print $2}' | sort
7z
7z
alias
apropos
cd
cd
```
接下来,将 **sort** 命令的输出传递给 **uniq -c** ,这将计算每个命令使用了多少次。
```
$ history | awk '{print $2}' | sort | uniq -c
2 7z
1 alias
2 apropos
38 cd
21 chmod
```
最后,添加第二个 **sort** 命令按倒序对命令组计数进行排序,这将先列出最常用的命令。
```
$ history | awk '{print $2}' | sort | uniq -c | sort -nr
178 ls
95 vi
63 cd
53 sudo
41 more
```
这样可以让你了解使用最多的命令,但不会包括任何你可能故意从历史记录文件中删除的命令,例如:
```
HISTIGNORE="pwd:clear:man:history"
```
### 当历史变更时
对于默认的历史记录格式,**history** 命令输出中的第一个字段将是每个命令的序号,第二个字段是使用的命令。因此,上面所有 **awk** 命令都设置成显示 **$2**。
```
$ alias cmds='history | awk '\''{print $2}'\'' | sort | uniq -c | sort -nr'
```
如果你像下面那样将日期和时间添加了到 history 命令中,那么你还必须修改所设置的别名。
```
$ echo $HISTTIMEFORMAT
%d/%m/%y %T
```
这个日期/时间信息有时会很有帮助,但是这意味着你必须在选择 history 命令的第 4 个字段而不是第 2 个字段来汇总命令,因为你的历史记录条目将如下所示:
```
91 05/07/20 16:37:39 sudo apt-get install ccrypt
^
+-- command
```
因此,在将 $2 变为 $4 之后,用于检查 history 命令的别名将改为这样。
```
$ alias cmds='history | awk '\''{print $4}'\'' | sort | uniq -c | sort -nr'
```
可将别名保存在 **.bashrc** 或其他启动文件中,请确保在 **$** 符号前面插入反斜杠,以便 bash 不会尝试解释 **$4**。
```
alias cmds='history | awk '\''{print \$2}'\'' | uniq -c | sort -nr'
alias cmds='history | awk '\''{print \$4}'\'' | uniq -c | sort -nr'
```
请注意日期和时间信息与命令本身保存在历史记录文件的不同行中。因此添加此信息后bash 历史记录文件的行数将增加一倍,尽管在输出 history 命令时不会:
```
$ wc -l .bash_history
2000 .bash_history
$ history | wc -l
1000
```
### 总结
你始终可以决定要保留多少命令历史记录以及哪些记录不需要,以使命令汇总最有用。
加入 [Facebook][1] 和 [LinkedIn][2] 上的 Network World 社区,评论热门主题。
--------------------------------------------------------------------------------
via: https://www.networkworld.com/article/3567050/summarizing-your-command-usage-on-linux.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.networkworld.com/author/Sandra-Henry_Stocker/
[b]: https://github.com/lujun9972
[1]: https://www.facebook.com/NetworkWorld/
[2]: https://www.linkedin.com/company/network-world