Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
Xingyu Wang 2019-12-09 21:52:09 +08:00
commit 902ebbcf15
9 changed files with 512 additions and 491 deletions

View File

@ -1,26 +1,28 @@
自动共享和上传文件到兼容的托管站点
======
![](https://www.ostechnix.com/wp-content/uploads/2017/10/Upload-720x340.png)
前阵子我们写了一个关于[**Transfer.sh**][1]的指南,它允许你使用命令行通过互联网来分享文件。今天,我们来看看另一种文件分享实用工具**Anypaste**。这是一个基于文件类型自动共享和上传文件到兼容托管站点的简单脚本。你不需要去手动登录到托管站点来上传或分享你的文件。Anypaste将会根据你想上传的文件的类型来**自动挑选合适的托管站点**。简单地说照片将被上传到图像托管站点视频被传到视频站点代码被传到pastebins。难道不是很酷的吗Anypaste是一个完全开源、免费、轻量的脚本你可以通过命令行完成所有操作。因此你不需要依靠那些臃肿的需要消耗大量内存的GUI应用来上传和共享文件。
### Anypaste-自动共享和上传文件到兼容的托管站点
#### 安装
正如我所说,这仅仅是一个脚本。所以不存在任何复杂的安装步骤。只需要将脚本下载后放置在你想要运行的位置(例如/usr/bin/anypaste)并将其设置为可执行文件后就可以直接使用了。此外你也可以通过下面的这两条命令来快速安装Anypaste。
![](https://www.ostechnix.com/wp-content/uploads/2017/10/Upload-720x340.png)
前阵子我们写了一个关于 [Transfer.sh][1]的指南,它允许你使用命令行通过互联网来分享文件。今天,我们来看看另一种文件分享实用工具 Anypaste。这是一个基于文件类型自动共享和上传文件到兼容托管站点的简单脚本。你不需要去手动登录到托管站点来上传或分享你的文件。Anypaste 将会根据你想上传的文件的类型来**自动挑选合适的托管站点**。简单地说,照片将被上传到图像托管站点,视频被传到视频站点,代码被传到 pastebin。难道不是很酷的吗Anypaste 是一个完全开源、免费、轻量的脚本,你可以通过命令行完成所有操作。因此,你不需要依靠那些臃肿的、需要消耗大量内存的 GUI 应用来上传和共享文件。
### 安装
正如我所说,这仅仅是一个脚本。所以不存在任何复杂的安装步骤。只需要将脚本下载后放置在你想要运行的位置(例如 `/usr/bin/`),并将其设置为可执行文件后就可以直接使用了。此外,你也可以通过下面的这两条命令来快速安装 Anypaste。
```
sudo curl -o /usr/bin/anypaste https://anypaste.xyz/sh
```
```
sudo chmod +x /usr/bin/anypaste
```
就是这样简单。如果需要更新老的Anypaste版本只需要用新的可执行文件覆写旧的即可。
就是这样简单。如果需要更新老的 Anypaste 版本,只需要用新的可执行文件覆写旧的即可。
现在,让我们看看一些实例。
#### 配置
Anypaste开箱即用并不需要特别的配置。默认的配置文件是 **~/.config/anypaste.conf** 这个文件在你第一次运行Anypaste时会自动创建。
### 配置
需要配置的选项只有**ap_plugins**。Anypaste使用插件系统去上传文件。每个站点(上传)都由一个特定的插件表示。你可以在anypaste.conf文件中的**ap-plugins directive**位置浏览可用的插件列表。
Anypaste 开箱即用,并不需要特别的配置。默认的配置文件是 `~/.config/anypaste.conf`,这个文件在你第一次运行 Anypaste 时会自动创建。
需要配置的选项只有 `ap_plugins`。Anypaste 使用插件系统上传文件。每个站点(的上传)都由一个特定的插件表示。你可以在 `anypaste.conf` 文件中的 `ap-plugins directive` 位置浏览可用的插件列表。
```
# List of plugins
@ -42,13 +44,19 @@ ap_plugins=(
)
[...]
```
如果你要安装一个新的插件,将它添加进这个列表中就可以了。如果你想禁用一个默认插件,只需要将它从列表中移除即可。如果多个插件是相互依存的关系,排列中的第一个会被选择,因此**顺序很重要**。
#### 用法
上传一个简单的文件例如test.png可以运行以下命令
如果你要安装一个新的插件,将它添加进这个列表中就可以了。如果你想禁用一个默认插件,只需要将它从列表中移除即可。如果有多个兼容的插件,排列中的第一个会被选择,因此**顺序很重要**。
### 用法
上传一个简单的文件,例如 `test.png`,可以运行以下命令:
```
anypaste test.png
```
**输出示例:**
输出示例:
```
Current file: test.png
Attempting to upload with plugin 'tinyimg'
@ -59,9 +67,10 @@ Direct Link: https://tinyimg.io/i/Sa1zsjj.png
Upload complete.
All files processed. Have a nice day!
```
正如输出结果中所看到的Anypaste通过自动匹配图像文件**test.png**发现了兼容的托管站点(https://tinyimg.io)并将文件上传到了该站点。此外Anypaste也为我们提供了用于直接浏览/下载该文件的链接。
不仅png格式文件你还可以上传任何其他图片格式的文件。例如下面的命令将会上传gif格式文件
正如输出结果中所看到的Anypaste 通过自动匹配图像文件 `test.png` 发现了兼容的托管站点https://tinyimg.io并将文件上传到了该站点。此外Anypaste 也为我们提供了用于直接浏览/下载该文件的链接。
不仅是 png 格式文件,你还可以上传任何其他图片格式的文件。例如,下面的命令将会上传 gif 格式文件:
```
$ anypaste file.gif
@ -78,17 +87,21 @@ Direct(ish) Link: https://thumbs.gfycat.com/MisguidedQuaintBergerpicard-size_res
Upload complete.
All files processed. Have a nice day!
```
你可以将链接分享给你的家庭,朋友和同事们。下图是我刚刚将图片上传到**gfycat**网站的截图。
[![][2]][3]
你可以将链接分享给你的家庭、朋友和同事们。下图是我刚刚将图片上传到 gfycat 网站的截图。
![][3]
也可以一次同时上传多个(相同格式或不同格式)文件。
下面的例子提供参考,这里我会上传两个不同的文件,包含一个图片文件和一个视频文件:
```
anypaste image.png video.mp4
```
**输出示例:**
输出示例:
```
Current file: image.png
Attempting to upload with plugin 'tinyimg'
@ -109,13 +122,16 @@ Delete/Edit: http://sendvid.com/wwy7w96h?secret=39c0af2d-d8bf-4d3d-bad3-ad37432a
Upload complete.
All files processed. Have a nice day!
```
Anypaste针对两个文件自动发现了与之相兼容的托管站点并成功上传。
正如你在上述用法介绍部分的例子中注意到的Anypaste会自动挑选最佳的插件。此外你可以指定插件进行文件上传这里提供一个上传**gfycat**类型文件的案例,运行以下命令:
Anypaste 针对两个文件自动发现了与之相兼容的托管站点并成功上传。
正如你在上述用法介绍部分的例子中注意到的Anypaste 会自动挑选最佳的插件。此外,你可以指定插件进行文件上传,这里提供一个上传到 gfycat 的案例,运行以下命令:
```
anypaste -p gfycat file.gif
```
**输出示例:**
输出示例:
```
Current file: file.gif
@ -131,15 +147,21 @@ Direct(ish) Link: https://thumbs.gfycat.com/GrayDifferentCollie-size_restricted.
Upload complete.
All files processed. Have a nice day!
```
如果要使用特定插件进行文件上传,可以通过以下命令绕过兼容性检查:
```
anypaste -fp gfycat file.gif
```
如果你发现在配置文件中忽略了特定的插件你仍然可以强制Anypaste去使用特定的插件只不过需要加上'-xp'参数。
如果你发现在配置文件中忽略了特定的插件,你仍然可以强制 Anypaste 去使用特定的插件,只不过需要加上 `-xp` 参数。
```
anypaste -xp gfycat file.gif
```
如果想要以交互模式上传文件,可以在命令后加上'-i'标签:
如果想要以交互模式上传文件,可以在命令后加上 `-i` 标签:
```
$ anypaste -i file.gif
Current file: file.gif
@ -159,15 +181,16 @@ Direct(ish) Link: https://thumbs.gfycat.com/WaryAshamedBlackbear-size_restricted
Upload complete.
All files processed. Have a nice day!
```
正如你所见Anypaste首先询问了我是否需要自动确定插件。因为我不想自动寻找插件所以我回复了'No'。之后Anypaste列出了所有可选择的插件并要求我从列表中选择一个。同样的你可以上传和共享不同类型的文件相关文件会被上传到相兼容的站点。
无论你何时上传一个视频文件Anypaste都会将其上传到以下站点中的一个
正如你所见Anypaste 首先询问了我是否需要自动确定插件。因为我不想自动寻找插件,所以我回复了 “No”。之后Anypaste 列出了所有可选择的插件,并要求我从列表中选择一个。同样的,你可以上传和共享不同类型的文件,相关文件会被上传到相兼容的站点。
无论你何时上传一个视频文件Anypaste 都会将其上传到以下站点中的一个:
1. sendvid
2. streamable
3. gfycat
这里注意列表顺序Anypaste将首先将文件上传到sendvid站点如果没有sendvid的插件可供使用Anypaste将会尝试顺序中的另外两个站点。当然你也可以通过更改配置文件来修改顺序。
这里注意列表顺序Anypaste 将首先将文件上传到 sendvid 站点,如果没有 sendvid 的插件可供使用Anypaste 将会尝试顺序中的另外两个站点。当然你也可以通过更改配置文件来修改顺序。
图像文件上传站点:
@ -195,8 +218,9 @@ All files processed. Have a nice day!
上面列出来的部分站点一段特定的时间后会删除上传的内容,所以在上传和分享内容时应先明确这些站点的条款和条件。
#### 结论
在我看来识别文件并决定将其上传到何处的想法非常棒而且开发者也以恰当的方式完美地实现了它。毫无疑问Anypaste对那些在互联网上需要频繁分享文件的人们非常有用我希望你也能这么觉得。
### 结论
在我看来识别文件并决定将其上传到何处的想法非常棒而且开发者也以恰当的方式完美地实现了它。毫无疑问Anypaste 对那些在互联网上需要频繁分享文件的人们非常有用,我希望你也能这么觉得。
这就是今天的全部内容,后面会有越来越多的好东西分享给大家。再见啦!
@ -206,7 +230,7 @@ via: https://www.ostechnix.com/anypaste-share-upload-files-compatible-hosting-si
作者:[SK][a]
译者:[lixin555](https://github.com/lixin555)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,240 @@
[#]: collector: (lujun9972)
[#]: translator: (lxbwolf)
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11657-1.html)
[#]: subject: (Get sorted with sort at the command line)
[#]: via: (https://opensource.com/article/19/10/get-sorted-sort)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
在命令行用 sort 进行排序
======
> 在 Linux、BSD 或 Mac 的终端中使用 sort 命令,按自己的需求重新整理数据。
![](https://img.linux.net.cn/data/attachment/album/201912/09/065444f42xl2lddxillz09.jpg)
如果你曾经用过数据表应用程序,你就会知道可以按列的内容对行进行排序。例如,如果你有一个费用列表,你可能希望对它们进行按日期或价格升序抑或按类别进行排序。如果你熟悉终端的使用,你不会仅为了排序文本数据就去使用庞大的办公软件。这正是 [sort][2] 命令的用处。
### 安装
你不必安装 `sort` ,因为它向来都包含在 [POSIX][3] 系统里。在大多数 Linux 系统中,`sort` 命令来自 GNU 组织打包的实用工具集合中。在其他的 POSIX 系统中,像 BSD 和 Mac默认的 `sort` 命令不是 GNU 提供的,所以有一些选项可能不一样。本文中我尽量对 GNU 和 BSD 两者的实现都进行说明。
### 按字母顺序排列行
`sort` 命令默认会读取文件每行的第一个字符并对每行按字母升序排序后输出。两行中的第一个字符相同的情况下,对下一个字符进行对比。例如:
```
$ cat distro.list
Slackware
Fedora
Red Hat Enterprise Linux
Ubuntu
Arch
1337
Mint
Mageia
Debian
$ sort distro.list
1337
Arch
Debian
Fedora
Mageia
Mint
Red Hat Enterprise Linux
Slackware
Ubuntu
```
使用 `sort` 不会改变原文件。`sort` 仅起到过滤的作用,所以如果你希望按排序后的格式保存数据,你需要用 `>``tee` 进行重定向。
```
$ sort distro.list | tee distro.sorted
1337
Arch
Debian
[...]
$ cat distro.sorted
1337
Arch
Debian
[...]
```
### 按列排序
复杂数据集有时候不止需要对每行的第一个字符进行排序。例如假设有一个动物列表每个都有其种和属用可预见的分隔符分隔每一个“字段”即数据表中的“单元格”。这类由数据表导出的格式很常见CSV<ryby>以逗号分隔的数据<rt>comma-separated values</rt></ruby>)后缀可以标识这些文件(虽然 CSV 文件不一定用逗号分隔,有分隔符的文件也不一定用 CSV 后缀)。以下数据作为示例:
```
Aptenodytes;forsteri;Miller,JF;1778;Emperor
Pygoscelis;papua;Wagler;1832;Gentoo
Eudyptula;minor;Bonaparte;1867;Little Blue
Spheniscus;demersus;Brisson;1760;African
Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed
Eudyptes;chrysocome;Viellot;1816;Southern Rockhopper
Torvaldis;linux;Ewing,L;1996;Tux
```
对于这组示例数据,你可以用 `--field-separator` (在 BSD 和 Mac 用 `-t`,在 GNU 上也可以用简写 `-t` )设置分隔符为分号(因为该示例数据中是用分号而不是逗号,理论上分隔符可以是任意字符),用 `--key`(在 BSD 和 Mac 上用 `-k`,在 GNU 上也可以用简写 `-k`)选项指定哪个字段被排序。例如,对每行第二个字段进行排序(计数以 1 开头而不是 0
```
sort --field-separator=";" --key=2
Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed
Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper
Spheniscus;demersus;Brisson;1760;African
Aptenodytes;forsteri;Miller,JF;1778;Emperor
Torvaldis;linux;Ewing,L;1996;Tux
Eudyptula;minor;Bonaparte;1867;Little Blue
Pygoscelis;papua;Wagler;1832;Gentoo
```
结果有点不容易读,但是 Unix 以构造命令的管道方式而闻名,所以你可以使用 `column` 命令美化输出结果。使用 GNU `column`
```
$ sort --field-separator=";" \
\--key=2 penguins.list | column --table --separator ";"
Megadyptes   antipodes   Milne-Edwards  1880  Yellow-eyed
Eudyptes     chrysocome  Viellot        1816  Southern Rockhopper
Spheniscus   demersus    Brisson        1760  African
Aptenodytes  forsteri    Miller,JF      1778  Emperor
Torvaldis    linux       Ewing,L        1996  Tux
Eudyptula    minor       Bonaparte      1867  Little Blue
Pygoscelis   papua       Wagler         1832  Gentoo
```
对于初学者可能有点不好理解但是写起来简单BSD 和 Mac 上的命令选项:
```
$ sort -t ";" \
-k2 penguins.list | column -t -s ";"
Megadyptes   antipodes   Milne-Edwards  1880  Yellow-eyed
Eudyptes     chrysocome  Viellot        1816  Southern Rockhopper
Spheniscus   demersus    Brisson        1760  African
Aptenodytes  forsteri    Miller,JF      1778  Emperor
Torvaldis    linux       Ewing,L        1996  Tux
Eudyptula    minor       Bonaparte      1867  Little Blue
Pygoscelis   papua       Wagler         1832  Gentoo
```
当然 `-k` 不一定非要设为 `2`。任意存在的字段都可以被设为排序的键。
### 逆序排列
你可以用 `--reverse`BSD/Mac 上用 `-r`GNU 上也可以用简写 `-r`)选项来颠倒已经排好序的列表。
```
$ sort --reverse alphabet.list
z
y
x
w
[...]
```
你也可以把输出结果通过管道传给命令 [tac][4] 来实现相同的效果。
### 按月排序(仅 GNU 支持)
理想情况下,所有人都按照 ISO 8601 标准来写日期:年、月、日。这是一种合乎逻辑的指定精确日期的方法,也可以很容易地被计算机理解。也有很多情况下,人类用其他的方式标注日期,包括用很名字随意的月份。
幸运的是GNU `sort` 命令能识别这种写法,并可以按月份的名称正确排序。使用 `--month-sort``-M`)选项:
```
$ cat month.list
November
October
September
April
[...]
$ sort --month-sort month.list
January
February
March
April
May
[...]
November
December
```
月份的全称和简写都可以被识别。
### 人类可读的数字排序(仅 GNU 支持)
另一个人类和计算机的常见混淆点是数字的组合。例如,人类通常把 “1024 kilobytes” 写成 “1KB”因为人类解析 “1 KB” 比 “1024” 要容易且更快(数字越大,这种差异越明显)。对于计算机来说,一个 9 KB 的字符串要比诸如 1 MB 的字符串大(尽管 9 KB 是 1 MB 很小一部分。GNU `sort` 命令提供了`--human-numeric-sort``-h`)选项来帮助正确解析这些值。
```
$ cat sizes.list
2M
12MB
1k
9k
900
7000
$ sort --human-numeric-sort
900
7000
1k
9k
2M
12MB
```
有一些情况例外。例如“16000 bytes” 比 “1 KB” 大,但是 `sort` 识别不了。
```
$ cat sizes0.list
2M
12MB
16000
1k
$ sort -h sizes0.list
16000
1k
2M
12MB
```
逻辑上来说,这个示例中 16000 应该写成 16 KB所以也不应该全部归咎于GNU `sort`。只要你确保数字的一致性,`--human-numeric-sort` 可以用一种计算机友好的方式解析成人类可读的数字。
### 随机排序(仅 GNU 支持)
有时候工具也提供了一些与设计初衷相悖的选项。某种程度上说,`sort` 命令提供对一个文件进行随机排序的能力没有任何意义。这个命令的工作流让这个特性变得很方便。你*可以*用其他的命令,像 [shuf][5] 或者你可以用现在的命令添加一个选项。不管你认为它是一个臃肿的还是极具创造力的用户体验设计GNU `sort` 命令提供了对文件进行随机排序的功能。
最纯粹的随机排序格式选项是 `--random-sort``-R`(不要跟 `-r` 混淆,`-r` 是 `--reverse` 的简写)。
```
$ sort --random-sort alphabet.list
d
m
p
a
[...]
```
每次对文件运行随机排序都会有不同的结果。
### 结语
GNU 和 BSD 的 `sort` 命令还有很多功能,所以花点时间去了解这些选项。你会惊异于 `sort` 的灵活性,尤其是当它和其他的 Unix 工具一起使用时。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/10/get-sorted-sort
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[lxbwolf](https://github.com/lxbwolf)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl "Coding on a computer"
[2]: https://en.wikipedia.org/wiki/Sort_(Unix)
[3]: https://en.wikipedia.org/wiki/POSIX
[4]: https://opensource.com/article/19/9/tac-command
[5]: https://www.gnu.org/software/coreutils/manual/html_node/shuf-invocation.html

View File

@ -1,15 +1,16 @@
[#]: collector: (lujun9972)
[#]: translator: (luuming)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: reviewer: (wxy)
[#]: publisher: (wxy)
[#]: url: (https://linux.cn/article-11658-1.html)
[#]: subject: (The many faces of awk)
[#]: via: (https://www.networkworld.com/article/3454979/the-many-faces-of-awk.html)
[#]: author: (Sandra Henry-Stocker https://www.networkworld.com/author/Sandra-Henry_Stocker/)
千面 awk
======
`awk` 命令不仅提供了简单的输入字符串筛选功能,还包含提取数据列,打印简单文本,筛选内容——甚至做一些数学计算。
> `awk` 命令不仅提供了简单的输入字符串筛选功能,还包含提取数据列、打印简单文本、筛选内容——甚至做一些数学计算。
![Thinkstock][6]
@ -18,6 +19,7 @@
### 提取数据列
`awk` 所提供的最简单与最常用的功能便是从文件或管道传输的数据中选取特定的内容。默认使用空格当做分隔符,这非常简单。
```
$ echo one two three four five | awk {print $4}
four
@ -26,26 +28,30 @@ jdoe
fhenry
```
空格指的是一系列的 `space``tab`。在下面所展示的命令里,`awk` 从提供的数据中筛选第一和第四项。
空格指的是一系列的 `space``tab` 字符。在下面所展示的命令里,`awk` 从提供的数据中筛选第一和第四项。
`awk` 命令也可以通过在其后增加文件名的方式从文本文件中获取数据。
`awk` 命令也可以通过在其后增加文件名参数的方式从文本文件中获取数据。
```
$ awk '{print $1,$5,$NF}' HelenKellerQuote
The beautiful heart.
LCTT 译注“The best and most beautiful things in the world can not be seen or even touched , they must be felt with heart.” ——海伦凯勒)
```
LCTT 译注“The best and most beautiful things in the world can not be seen or even touched , they must be felt with heart.” ——海伦凯勒)
在这个例子中,`awk` 挑选了一行中的第一个、第五个和最后一个字段。
命令中的`$NF` 指定选取每行的最后一个字段。这是因为`NF`代表一行中的<ruby>字段数量<rt>Number of Field</rt></ruby>,也就是 23`$NF` 就代表着那个字段的值,也就是`heart`。最后的句号也包含进去了,因为它是最后一个字符串的一部分。
命令中的 `$NF` 指定选取每行的最后一个字段。这是因为 `NF` 代表一行中的<ruby>字段数量<rt>Number of Field</rt></ruby>,也就是 23`$NF` 就代表着那个字段的值,也就是`heart`。最后的句号也包含进去了,因为它是最后一个字符串的一部分。
字段能以任何有用的形式打印。在这个例子中,我们将字段以日期的格式进行打印输出。
```
$ date | awk '{print $4,$3,$2}'
2019 Nov 22
```
如果你省略了 `awk` 命令中字段指示符之间的逗号,输出将会挤成一个字符串。
```
$ date | awk '{print $4 $3 $2}'
2019Nov21
@ -58,7 +64,7 @@ $ date | awk '{print $4-$3-$2}'
1997
```
在这个例子中它将年“2019”和日期“22”相减并忽略了中间的“Nov”。
在这个例子中,它将年 “2019” 和日期 “22” 相减,并忽略了中间的 “Nov”。
如果你想要空格之外的字符作为输出分隔符,你可以通过 `OFS`<ruby>输出分隔符<rt>output field separator</rt></ruby>)指定分隔符,就像这样:
@ -153,7 +159,7 @@ dory:x:1002:1002:Dory,,,:/home/dory:/bin/bash
`awk` 提供了惊人的数学计算能力,并且可以开平方,算 `log`,算 `tan` 等等。
这里有一对例子:
这里有一对例子
```
$ awk 'BEGIN {print sqrt(2019)}'
@ -205,7 +211,7 @@ via: https://www.networkworld.com/article/3454979/the-many-faces-of-awk.html
作者:[Sandra Henry-Stocker][a]
选题:[lujun9972][b]
译者:[LuuMing](https://github.com/LuuMing)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
@ -216,4 +222,4 @@ via: https://www.networkworld.com/article/3454979/the-many-faces-of-awk.html
[3]: https://www.networkworld.com/article/2974753/doing-math-with-awk.html
[4]: https://www.facebook.com/NetworkWorld/
[5]: https://www.linkedin.com/company/network-world
[6]:https://images.techhive.com/images/article/2015/09/thinkstockphotos-512100549-100611755-large.jpg
[6]:https://images.techhive.com/images/article/2015/09/thinkstockphotos-512100549-100611755-large.jpg

View File

@ -1,126 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (hopefully2333)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How internet security works: TLS, SSL, and CA)
[#]: via: (https://opensource.com/article/19/11/internet-security-tls-ssl-certificate-authority)
[#]: author: (Bryant Son https://opensource.com/users/brson)
How internet security works: TLS, SSL, and CA
======
What's behind that lock icon in your web browser?
![Lock][1]
Multiple times every day, you visit websites that ask you to log in with your username or email address and password. Banking websites, social networking sites, email services, e-commerce sites, and news sites are just a handful of the types of sites that use this mechanism.
Every time you sign into one of these sites, you are, in essence, saying, "yes, I trust this website, so I am willing to share my personal information with it." This data may include your name, gender, physical address, email address, and sometimes even credit card information.
But how do you know you can trust a particular website? To put this a different way, what is the website doing to secure your transaction so that you can trust it?
This article aims to demystify the mechanisms that make a website secure. I will start by discussing the web protocols HTTP and HTTPS and the concept of Transport Layer Security (TLS), which is one of the cryptographic protocols in the internet protocol's (IP) layers. Then, I will explain certificate authorities (CAs) and self-signed certificates and how they can help secure a website. Finally, I will introduce some open source tools you can use to create and manage certificates.
### Securing routes through HTTPS
The easiest way to understand a secured website is to see it in action. Fortunately, it is far easier to find a secured website than an unsecured website on the internet today. But, since you are already on Opensource.com, I'll use it as an example. No matter what browser you're using, you should see an icon that looks like a lock next to the address bar. Click on the lock icon, and you should see something similar to this.
![Certificate information][2]
By default, a website is not secure if it uses the HTTP protocol. Adding a certificate configured through the website host to the route can transform the website from an unsecured HTTP site to a secured HTTPS site. The lock icon usually indicates that the site is secured through HTTPS.
Click on Certificate to see the site's CA. Depending on your browser, you may need to download the certificate to see it.
![Certificate information][3]
Here, you can learn something about Opensource.com's certificate. For example, you can see that the CA is DigiCert, and it is given to Red Hat under the name Opensource.com.
This certificate information enables the end user to check that the website is safe to visit.
> WARNING: If you do not see a certificate sign on a website—or if you see a sign that indicates that the website is not secure—please do not log in or do any activity that requires your private data. Doing so is quite dangerous!
If you see a warning sign, which is rare for most publicly facing websites, it usually means that the certificate is expired or uses a self-signed certificate instead of one issued through a trusted CA. Before we get into those topics, I want to explain the TLS and SSL.
### Internet protocols with TLS and SSL
TLS is the current generation of the old Secure Socket Layer (SSL) protocol. The best way to understand this is by examining the different layers of the IP.
![IP layers][4]
There are six layers that make up the internet as we know it today: physical, data, network, transport, security, and application. The physical layer is the base foundation, and it is closest to the actual hardware. The application layer is the most abstract layer and the one closest to the end user. The security layer can be considered a part of the application layer, and TLS and SSL, which are the cryptographic protocols designed to provide communications security over a computer network, are in the security layer.
This process ensures that communication is secure and encrypted when an end user consumes the service.
### Certificate authorities and self-signed certificates
A CA is a trusted organization that can issue a digital certificate.
TLS and SSL can make a connection secure, but the encryption mechanism needs a way to validate it; this is the SSL/TLS certificate. TLS uses a mechanism called asymmetric encryption, which is a pair of security keys called a private key and a public key. (This is a very complex topic that is beyond the scope of this article, but you can read "[An introduction to cryptography and public key infrastructure][5]" if you would like to learn about it.) The essential thing to know is that CAs, like GlobalSign, DigiCert, and GoDaddy, are the external trusted vendors that issue certificates that are used to validate the TLS/SSL certificate used by the website. This certificate is imported to the hosted server to secure the website.
However, a CA might be too expensive or complicated when you're just trying to test a website or service in development. You must have a trusted CA for production purposes, but developers and website administrators need a simpler way to test websites before they're deployed to production; this is where self-signed certificates come in.
A self-signed certificate is a TLS/SSL certificate that is signed by the person who creates it rather than a trusted CA. It's easy to generate a self-signed certificate from a computer, and it can enable you to test a secure website without buying an expensive CA-signed certificate right away. While the self-signed certificate is definitely risky to put into production use, it is an easy and flexible option for developing and testing in pre-production stages.
### Open source tools for generating certificates
Several open source tools are available for managing TLS/SSL certificates. The most well-known one is OpenSSL, which is included in many Linux distributions and on macOS. However, other open source tools are also available.
| Tool Name | Description | License |
| --------- | ------------------------------------------------------------------------------ | --------------------------------- |
| OpenSSL | The most well-known open source tool for implementing TLS and crypto libraries | Apache License 2.0 |
| EasyRSA | Command-line utility for building and managing a PKI CA | GPL v2 |
| CFSSL | PKI/TLS "Swiss Army Knife" from Cloudflare | BSD 2-Clause "Simplified" License |
| Lemur | TLS creation tool from Netflix | Apache License 2.0 |
Netflix's Lemur is a particularly interesting option when you consider its goals of scaling and being user friendly. You can read more about it on [Netflix's tech blog][6].
### How to create an OpenSSL certificate
e have the power to create certificates on our own. This example generates a self-signed certificate using OpenSSL.
1. Create a private key using the openssl command:
```
openssl genrsa -out example.key 2048
```
![](https://opensource.com/sites/default/files/uploads/4_openssl_generatekey.jpg)
2. Create a certificate signing request (CSR) using the private key generated in step 1:
```
openssl req -new -key example.key -out example.csr \
-subj "/C=US/ST=TX/L=Dallas/O=Red Hat/OU=IT/CN=test.example.com"
```
![](https://opensource.com/sites/default/files/uploads/5_openssl_generatecsr.jpg)
3. Create a certificate using your CSR and private key:
```
openssl x509 -req -days 366 -in example.csr \
-signkey example.key -out example.crt
```
![](https://opensource.com/sites/default/files/uploads/6_openssl_generatecert.jpg)
### Learn more on internet security
If you'd like to learn more about the internet and website security, watch the companion YouTube video I made for this article.
<https://youtu.be/r0F1Hlcmjsk>
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/11/internet-security-tls-ssl-certificate-authority
作者:[Bryant Son][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/brson
[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
[2]: https://opensource.com/sites/default/files/uploads/1_certificatecheckwebsite.jpg
[3]: https://opensource.com/sites/default/files/uploads/2_certificatedisplaywebsite.jpg
[4]: https://opensource.com/sites/default/files/uploads/3_internetprotocol.jpg
[5]: https://opensource.com/article/18/5/cryptography-pki
[6]: https://medium.com/netflix-techblog/introducing-lemur-ceae8830f621

View File

@ -1,72 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Why use the Pantheon desktop for Linux Elementary OS)
[#]: via: (https://opensource.com/article/19/12/pantheon-linux-desktop)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
Why use the Pantheon desktop for Linux Elementary OS
======
This article is part of a special series on Linux desktops. Get a
much-loved Mac OS feature on Linux with the Pantheon desktop for
Elementary OS.
![A person programming][1]
Would you pay $20 for a Linux desktop? I would, and in fact, I regularly choose to pay more than that when I download free software! The reason I do this is that open source is worth it. For a copy of [Elementary OS][2], US$ 20 happens to be the default asking price (you can download it for $1 or even $0 if you can't afford anything more). What you get in return is an excellent and heavily curated distribution that ships with its own Pantheon desktop design.
You may find Pantheon included in a software repository, as it is open source, but more likely, you'll have to download and install [Elementary][3] Linux to experience it. If you're not ready to install Elementary on your computer as the main OS, you can install it into a virtual machine, like [GNOME Boxes][4].
The Pantheon desktop is clean, attractive, and features many of the little things many users want in a desktop but could never quite get from the usual Linux desktops.
### Pantheon desktop tour
At first glance, the Pantheon desktop looks a little like Cinnamon or Budgie or the Classic mode of GNOME 3. However, the most exciting features of Pantheon are the smallest touches. It excels in all the places you notice the very least, until that place is the only thing you're looking at one day, and you realize that the way it works has literally improved your quality of life, to say nothing of making your day a lot nicer.
The clearest example of this is **file name highlighting**. For decades, Mac OS has had a much-loved feature whereby you can highlight the displayed name of an important file. People use this feature as a quick visual indicator to tell themselves which file is the "best" version of several, or which file should be sent to a friend, or which file still needs work. They're arbitrary colors and can mean whatever the user wants them to mean. Most importantly, it's noticeable visual metadata.
Users switching from Mac OS tend to miss this feature in GNOME and KDE and every other desktop option Linux has on offer. Pantheon quietly and casually solves that problem.
![A highlighted file in the Pantheon desktop][5]
Of course, that's just one example of many. Pantheon is filled with small features that you don't think about until you need them.
The desktop is refined and attractive, with all the intuitive parts that have disappeared from many other desktops. In many ways, it has taken the best of the good ideas of many different interfaces and refrained from implementing the excesses.
![Pantheon desktop on Elementary OS][6]
### Customizing the Pantheon desktop
The Pantheon desktop represents a pretty clear vision of how a computer ought to be operated. The "problem" with this kind of design (outside of open source, at least) is that one person's preference may not be another person's efficiency.
But this is open source. Things can be changed, and whatever can't be changed can be discarded for a different option. Pantheon is definitely a desktop for a specific set of users, but even those of us with our own expectations of how a desktop ought to work might find Pantheon refreshingly more flexible than it first appears. There are overrides for many built-in designs, and when you can't adjust something to your liking, you can easily choose an alternative application. The theme engine ensures that your replacement application looks integrated with the rest of your desktop, and the usual Linux system buses ensure that all of your chosen applications communicate with one another as expected.
![Which one is the guest?][7]
As compromises go, this one does a lot to meet you halfway.
### A welcome addition
Etymology aside, this desktop truly is an answer to the prayers of many Linux users. Whether it's your style or not, the Pantheon desktop is an important and welcome addition to the Linux user experience. Try it for yourself and see if it's the good news you've been waiting for.
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/12/pantheon-linux-desktop
作者:[Seth Kenlon][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/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming)
[2]: https://elementary.io/
[3]: http://elementary.io
[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization
[5]: https://opensource.com/sites/default/files/uploads/advent-pantheon-highlight.jpg (A highlighted file in the Pantheon desktop)
[6]: https://opensource.com/sites/default/files/uploads/advent-pantheon.jpg (Pantheon desktop on Elementary OS)
[7]: https://opensource.com/sites/default/files/uploads/advent-pantheon-pcmanfm.jpg (Which one is the guest?)

View File

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

View File

@ -1,249 +0,0 @@
[#]: collector: (lujun9972)
[#]: translator: (lxbwolf)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Get sorted with sort at the command line)
[#]: via: (https://opensource.com/article/19/10/get-sorted-sort)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
命令行用 sort 进行排序
======
按自己的需求重新整理数据 — 用 LinuxBSD 或 Mac 的 terminal — 使用 sort 命令。
![Coding on a computer][1]
如果你曾经用过数据表应用程序,你就会知道可以按列的内容对行进行排序。例如,如果你有一列价格,你可能希望对它们进行按日期或升序抑或按类别进行排序。如果你熟悉 terminal 的使用,你不会仅为了排序文本数据就去使用庞大的办公软件。这正是 [**sort**][2] 命令的用处。
### 安装
你不必安装 **sort** ,因为它包含在任意 [POSIX][3] 系统里。在大多数 Linux 系统中,**sort** 命令被 GNU 组织捆绑在实用工具集合中。在其他的 POSIX 系统中,像 BSD 和 Mac默认的 **sort** 命令不是 GNU 提供的,所以有一些选项可能不一样。本文中我尽量对 GNU 和 BSD 两者的实现都进行说明。
### 按字母顺序排列行
**sort** 命令默认会读取文件每行的第一个字符并对每行按字母升序排序后输出。两行中的第一个字符相同的情况下,对下一个字符进行对比。例如:
```
$ cat distro.list
Slackware
Fedora
Red Hat Enterprise Linux
Ubuntu
Arch
1337
Mint
Mageia
Debian
$ sort distro.list
1337
Arch
Debian
Fedora
Mageia
Mint
Red Hat Enterprise Linux
Slackware
Ubuntu
```
使用 **sort** 不会改变原文件。sort 仅起到过滤的作用,所以如果你希望按排序后的格式保存数据,你需要用 **>** 或 **tee** 进行重定向。
```
$ sort distro.list | tee distro.sorted
1337
Arch
Debian
[...]
$ cat distro.sorted
1337
Arch
Debian
[...]
```
### 按列排序
复杂的数据有时候不止需要对每行的第一个字符进行排序。例如假设有一个动物列表用可预见的分隔符分隔每一个「字段」数据表中的「单元格」。这类由数据表导出的格式很常见CSVcomma-separated values以逗号分隔的数据后缀可以标识这些文件虽然 CSV 文件不一定用逗号分隔,有分隔符的文件也不一定用 CSV 后缀)。以下数据作为示例:
```
Aptenodytes;forsteri;Miller,JF;1778;Emperor
Pygoscelis;papua;Wagler;1832;Gentoo
Eudyptula;minor;Bonaparte;1867;Little Blue
Spheniscus;demersus;Brisson;1760;African
Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed
Eudyptes;chrysocome;Viellot;1816;Southern Rockhopper
Torvaldis;linux;Ewing,L;1996;Tux
```
对于这组示例数据,你可以用 **--field-separator** (在 BSD 和 Mac 用 **-t**,或 GNU 上可以用简写 **-t** )设置分隔符为分号(以为示例数据中是用分号而不是逗号,理论上分隔符可以是任意字符),用 **--key** 在 BSD 和 Mac 上用 **-k**,或 GNU 上可以用简写 **-k**)选项指定哪个字段被排序。例如,对每行第二个字段进行排序(以 1 开头而不是 0
```
sort --field-separator=";" --key=2
Megadyptes;antipodes;Milne-Edwards;1880;Yellow-eyed
Eudyptes;chrysocome;Viellot;1816;Sothern Rockhopper
Spheniscus;demersus;Brisson;1760;African
Aptenodytes;forsteri;Miller,JF;1778;Emperor
Torvaldis;linux;Ewing,L;1996;Tux
Eudyptula;minor;Bonaparte;1867;Little Blue
Pygoscelis;papua;Wagler;1832;Gentoo
```
结果有点不容易读,但是 Unix 以构造命令的 **pipe** 方法而闻名,所以你可以使用 **column** 命令美化输出结果。使用 GNU **column**
```
$ sort --field-separator=";" \
\--key=2 penguins.list | \
column --table --separator ";"
Megadyptes   antipodes   Milne-Edwards  1880  Yellow-eyed
Eudyptes     chrysocome  Viellot        1816  Southern Rockhopper
Spheniscus   demersus    Brisson        1760  African
Aptenodytes  forsteri    Miller,JF      1778  Emperor
Torvaldis    linux       Ewing,L        1996  Tux
Eudyptula    minor       Bonaparte      1867  Little Blue
Pygoscelis   papua       Wagler         1832  Gentoo
```
对于初学者可能有点不好理解但是写起来简单BSD 和 Mac 上的命令选项:
```
$ sort -t ";" \
-k2 penguins.list | column -t -s ";"
Megadyptes   antipodes   Milne-Edwards  1880  Yellow-eyed
Eudyptes     chrysocome  Viellot        1816  Southern Rockhopper
Spheniscus   demersus    Brisson        1760  African
Aptenodytes  forsteri    Miller,JF      1778  Emperor
Torvaldis    linux       Ewing,L        1996  Tux
Eudyptula    minor       Bonaparte      1867  Little Blue
Pygoscelis   papua       Wagler         1832  Gentoo
```
当然 **key** 不一定非要设为 **2**。任意存在的字段都可以被设为排序的 key。
### 逆序排列
你可以用 **--reverse**BSD/Mac 上用 **-r**, GNU 也可以用简写 **-r**)选项来颠倒已经排好序的列表。
```
$ sort --reverse alphabet.list
z
y
x
w
[...]
```
你也可以把输出结果通过管道传给命令 [tac][4] 来实现相同的效果。
### 按月排序 (仅 GNU 支持)
理想情况下,所有人都按照 ISO 8601 标准来写日期:年,月,日。这是一种合乎逻辑的指定精确日期的方法,也可以很容易地被计算机理解。也有很多情况下,人类用其他的方式标注日期,用很随意的名字表示月份。
幸运的是GNU **sort** 命令能识别这种写法,并可以按月份的名称正确排序。使用 **--month-sort (-M)** 选项:
```
$ cat month.list
November
October
September
April
[...]
$ sort --month-sort month.list
January
February
March
April
May
[...]
November
December
```
月份的全称和简写都可以被识别。
### 人类可读的数字排序(仅 GNU 支持)
另一个广泛的人类和计算机的混淆点是数字的组合。例如,人类通常把 ”1024 kilobytes“ 写成 “1KB”因为人类解析 ”1 KB“ 比 ”1024“ 要容易且更快(数字越大,这种差异越明显)。对于计算机来说,一个 9 KB 的字符串要比诸如 1 MB 的字符串大(尽管 9 KB 是 1 兆的很小一部分。GNU **sort** 命令提供了**--human-numeric-sort (-h)** 选项来帮助正确解析这些值。
```
$ cat sizes.list
2M
12MB
1k
9k
900
7000
$ sort --human-numeric-sort
900
7000
1k
9k
2M
12MB
```
有一些情况例外。例如16000 bytes 比 1 KB 大,但是 **sort** 识别不了。
```
$ cat sizes0.list
2M
12MB
16000
1k
$ sort -h sizes0.list
16000
1k
2M
12MB
```
逻辑上来说这个示例中16000 应该写成 16 KB所以也不应该全部归咎于GNU **sort** 。只要你确保数字的一致性,**--human-numeric-sort** 可以用一种计算机友好的方式解析成人类可读的数字。
### 随机排序(仅 GNU 支持)
有时候工具也提供了一些与设计初衷相悖的选项。某种程度上说,**sort** 命令提供了对一个文件进行随机排序的能力没有任何意义。这个命令的工作流让这个特性变得很方便。你可以用其他的命令,像 [**shuf**][5] ,或者你可以用现在的命令添加一个选项。不管你认为它是一个臃肿的还是极具创造力的 UX 设计GNU **sort** 命令提供了对文件进行随机排序的功能。
最纯粹的随机排序格式选项是 **--random-sort** 或 **-R**(不要跟 **-r** 混淆,**-r** 是 **--reverse** 的简写)。
```
$ sort --random-sort alphabet.list
d
m
p
a
[...]
```
每次对文件运行随机排序都会有不同的结果。
### 结语
GNU 和 BSD 命令 **sort** 还有很多功能,所以花点时间去了解这些选项。你会惊异于 **sort** 的灵活性,尤其是当它和其他的 Unix 工具一起使用时。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/10/get-sorted-sort
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[lxbwolf](https://github.com/lxbwolf)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_computer_laptop_hack_work.png?itok=aSpcWkcl "Coding on a computer"
[2]: https://en.wikipedia.org/wiki/Sort_(Unix)
[3]: https://en.wikipedia.org/wiki/POSIX
[4]: https://opensource.com/article/19/9/tac-command
[5]: https://www.gnu.org/software/coreutils/manual/html_node/shuf-invocation.html

View File

@ -0,0 +1,128 @@
[#]: collector: (lujun9972)
[#]: translator: (hopefully2333)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (How internet security works: TLS, SSL, and CA)
[#]: via: (https://opensource.com/article/19/11/internet-security-tls-ssl-certificate-authority)
[#]: author: (Bryant Son https://opensource.com/users/brson)
互联网的安全是如何保证的TLSSSL和 CA
======
你的浏览器里的锁的图标的后面是什么?
![Lock][1]
每天你都会重复这件事很多次,你访问网站,这个网站需要你用用户名或者电子邮件地址,和你的密码来进行登录。银行网站,社交网站,电子邮件服务,电子商务网站,和新闻网站。这里只在使用了这种机制的网站中列举了其中一小部分。
每次你登陆进一个这种类型的网站时,你实际上是在说:“是的,我信任这个网站,所以我愿意把我的个人信息共享给它。”这些数据可能包含你的姓名,性别,实际地址,电子邮箱地址,有时候甚至会包括你的信用卡信息。
但是你怎么知道你可以信任这个网站?换个方式问,为了让你可以信任它,网站应该如何保护你的交易?
本文旨在阐述使网站变得安全的机制。我会首先论述 web 协议 http 和 https以及传输层安全TLS的概念后者是互联网协议IP层中的加密协议之一。然后我会解释证书颁发机构和自签名证书以及它们如何帮助保护一个网站。最后我会介绍一些开源的工具你可以使用它们来创建和管理你的证书。
### 通过 https 保护路由
了解一个受保护的网站的最简单的方式就是在交互中观察它,幸运的是,在今天的互联网上,发现一个安全的网站远远比找到一个不安全的网站要简单。但是,因为你已经在 Opensource.com 这个网站上了,我会使用它来作为案例,无论你使用的是哪个浏览器,你应该在你的地址栏旁边看到一个像锁一样的图标。点击这个锁图标,你应该会看见一些和下面这个类似的东西。
![Certificate information][2]
默认情况下,如果一个网站使用的是 http 协议,那么它是不安全的。通过网站主机配置一个证书并添加到路由,可以把这个网站从一个不安全的 http 网站变为一个安全的 https 网站。那个锁图标通常表示这个网站是受 https 保护的。
点击证书来查看网站的 CA根据你的浏览器你可能需要下载证书来查看它。
![Certificate information][3]
点击证书来查看网站的 CA根据你的浏览器你可能需要下载证书来查看它。
这个证书信息可以让终端用户检查该网站是否可以安全访问。
> 警告:如果你没有在网站上看到证书标志,或者如果你看见的标志显示这个网站不安全——请不要登录或者做任何需要你个人数据的操作。这种情况非常危险!
如果你看到的是警告标志,对于大多数面向公众开放的网站来说,这很少见,它通常意味着该证书已经过期或者是该证书是自签名的,而非通过一个受信任的第三方来颁发。在我们进入这些主题之前,我想解释一下 TLS 和 SSL。
### 带有 TLS 和 SSL 的互联网协议
TLS 是旧版安全套接字层协议SSL的最新版本。理解这一点的最好方法就是仔细理解 IP 的不同协议层。
![IP layers][4]
我们知道当今的互联网是由6个层面组成的物理层数据链路层网络层传输层安全层应用层。物理层是基础这一层是最接近实际的硬件设备的。应用层是最抽象的一层是最接近终端用户的一层。安全层可以被认为是应用层的一部分TLS 和 SSL是被设计用来在一个计算机网络中提供通信安全的加密协议它们位于安全层中。
这个过程可以确保终端用户使用网络服务时,通信的安全性和保密性。
### 证书颁发机构和自签名证书
CA 是受信任的组织,它可以颁发数字证书。
TLS 和 SSL 可以使连接更安全,但是这个加密机制需要一种方式来验证它;这就是 SSL/TLS 证书。TLS 使用了一种叫做非对称加密的加密机制,这个机制有一对称为私钥和公钥的安全密钥。(这是一个非常复杂的主题,超出了本文的讨论范围,但是如果你想去了解这方面的东西,你可以阅读“密码学和公钥密码基础体系简介”)你要知道的基础内容是,证书颁发机构们,比如 GlobalSign, DigiCert,和 GoDaddy它们是受人们信任的可以颁发证书的供应商它们颁发的证书可以用于验证网站使用的 TLS/SSL 证书。网站使用的证书是导入到主机服务器里的,用于保护网站。
然而如果你只是要测试一下正在开发中的网站或服务CA 证书可能对你而言太昂贵或者是太复杂了。你必须有一个用于生产目的的受信任的证书,但是开发者和网站管理员需要有一种更简单的方式来测试网站,然后他们才能将其部署到生产环境中;这就是自签名证书的来源。
自签名证书是一种 TLS/SSL 证书,是由创建它的人而非受信任的 CA 机构颁发的。用电脑生成一个自签名证书很简单,它可以让你在无需购买昂贵的 CA 颁发的证书的情况下测试一个安全网站。虽然自签名证书肯定不能拿到生产环境中去使用,但对于开发和测试阶段来说,这是一种简单灵活的方法。
### 生成证书的开源工具
有几种开源工具可以用来管理 TLS/SSL 证书。其中最著名的就是 openssl这个工具包含在很多 Linux 发行版中和 macos 中。当然,你也可以使用其他开源工具。
| Tool Name | Description | License |
| --------- | ------------------------------------------------------------------------------ | --------------------------------- |
| OpenSSL | 实现 TLS 和加密库的最著名的开源工具 | Apache License 2.0 |
| EasyRSA | 用于构建 PKI CA 的命令行实用工具 | GPL v2 |
| CFSSL | 来自 cloudflare 的 PKI/TLS 瑞士军刀 | BSD 2-Clause "Simplified" License |
| Lemur | 来自网飞的 TLS创建工具 | Apache License 2.0 |
如果你的目的是扩展和对用户友好,网飞的 Lemur 是一个很有趣的选择。你在网飞的技术博客上可以查看更多有关它的信息。
### 如何创建一个 Openssl 证书
你可以靠自己来创建证书,下面这个案例就是使用 Openssl 生成一个自签名证书。
1. 使用 openssl 命令行生成一个私钥:
```
openssl genrsa -out example.key 2048
```
![](https://opensource.com/sites/default/files/uploads/4_openssl_generatekey.jpg)
2. 使用在第一步中生成的私钥来创建一个证书签名请求CSR:
```
openssl req -new -key example.key -out example.csr \
-subj "/C=US/ST=TX/L=Dallas/O=Red Hat/OU=IT/CN=test.example.com"
```
![](https://opensource.com/sites/default/files/uploads/5_openssl_generatecsr.jpg)
3. 使用你的 CSR 和私钥创建一个证书:
```
openssl x509 -req -days 366 -in example.csr \
-signkey example.key -out example.crt
```
![](https://opensource.com/sites/default/files/uploads/6_openssl_generatecert.jpg)
### 了解更多关于互联网安全的知识
如果你想要了解更多关于互联网安全和网站安全的知识,请看我为这篇文章一起制作的 Youtube 视频。
<https://youtu.be/r0F1Hlcmjsk>
你有什么问题?发在评论里让我们知道。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/11/internet-security-tls-ssl-certificate-authority
作者:[Bryant Son][a]
选题:[lujun9972][b]
译者:[hopefully2333](https://github.com/hopefully2333)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/brson
[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
[2]: https://opensource.com/sites/default/files/uploads/1_certificatecheckwebsite.jpg
[3]: https://opensource.com/sites/default/files/uploads/2_certificatedisplaywebsite.jpg
[4]: https://opensource.com/sites/default/files/uploads/3_internetprotocol.jpg
[5]: https://opensource.com/article/18/5/cryptography-pki
[6]: https://medium.com/netflix-techblog/introducing-lemur-ceae8830f621

View File

@ -0,0 +1,70 @@
[#]: collector: (lujun9972)
[#]: translator: (geekpi)
[#]: reviewer: ( )
[#]: publisher: ( )
[#]: url: ( )
[#]: subject: (Why use the Pantheon desktop for Linux Elementary OS)
[#]: via: (https://opensource.com/article/19/12/pantheon-linux-desktop)
[#]: author: (Seth Kenlon https://opensource.com/users/seth)
为何在 Elementary OS 中使用 Pantheon 桌面
======
本文是 Linux 桌面特别系列的一部分。通过 Pantheon 在 Elementary OS 上获得受喜爱的 Mac OS 特性。
![A person programming][1]
你愿意为 Linux 桌面支付 20 美元吗?事实上,我会在下载免费软件时选择支付更多!我这样做的原因是开源是值得的。对于 [Elementary OS][2]的拷贝,默认价格是 20 美元(你可以用 1 美元,如果你无法负担,你甚至可以用 0 美元下载)。作为回报,你将获得一个出色且精心制作的发行版,同时拥有 Pantheon 桌面设计。
你可能会发现 Pantheon 已包含在软件仓库中,因为它是开源的,但你更可能需要下载并安装 [Elementary][3] Linux 才能体验它。如果你还不准备在计算机上将 Elementary 作为主操作系统安装,那么可以将其安装到虚拟机中,例如 [GNOME Boxes][4] 中。
Pantheon 桌面整洁、吸引人,并有许多用户希望在桌面中获得的东西,但在普通的 Linux 桌面上却无法获得。
### Pantheon 桌面之旅
乍一看Pantheon 桌面看起来有点像 Cinnamon 或 Budgie 或 GNOME 3 的经典模式。但是Pantheon 最令人兴奋的功能是最小的触摸。它在你最少注意到的地方都表现出色,直到有一天这里成为了你一天都会看的地方,并且意识到它的工作方式确实改善了你的生活质量,更不用说让你过得愉快了好多了。
最明显的例子是“文件名高亮”。几十年来Mac OS 一直有一个广受欢迎的功能,你从而可以高亮显示重要文件的名称。人们使用此功能作为快速的视觉指示器,来告诉自己哪个文件是这几个的“最佳”版本,或者哪个文件应该发送给朋友,或者哪个文件仍然需要处理。它们可以是任意颜色,可以表示用户想要的任何含义。最重要的是,它是引人注目的视觉元数据。
从 Mac OS 切换过来用户往往会错过 GNOME 和 KDE 以及其他 Linux 桌面提供的这个功能。Pantheon 悄悄和随意地就解决了这个问题。
![A highlighted file in the Pantheon desktop][5]
当然那只是其中一个例子。Pantheon 有很多你直到用才会想到的小功能。
桌面精致而吸引人,有所有其他很多桌面缺少的直观组件。在许多方面,它充分吸取了其他桌面好的想法,并避免实现多余的东西。
![Pantheon desktop on Elementary OS][6]
### 自定义 Pantheon 桌面
Pantheon 桌面表达了如何操作计算机的清晰愿景。这种设计的“问题”(至少在开源之外)是,一个人的偏好可能无法满足另一个人的效率。
但它是开源的。它可以更改任何不能改变的东西都可以被丢弃。Pantheon 绝对是针对特定用户的桌面但是即使对于那些对桌面应该如何工作抱有自己期望的人Pantheon 也会比初次出现时更加灵活。许多内置设计都具有替代选项,当你无法根据自己的喜好进行调整时,你可以轻松选择其他应用。主题引擎可确保你的替换应用看起来与桌面的其他部分集成在一起,而平常的 Linux 系统总线可确保你选择的所有应用都能按预期相互通信。
![Which one is the guest?][7]
随着折衷的进行,这一过程在中途会做很多事情。
### 受欢迎的补充
除开词源,此桌面确实是许多 Linux 用户祈祷的答案。无论它是否是你的风格Pantheon 桌面都是 Linux 用户体验中重要且受欢迎的补充。自己尝试一下,看看它是否是你一直期待的。
--------------------------------------------------------------------------------
via: https://opensource.com/article/19/12/pantheon-linux-desktop
作者:[Seth Kenlon][a]
选题:[lujun9972][b]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/seth
[b]: https://github.com/lujun9972
[1]: https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_code_woman.png?itok=vbYz6jjb (A person programming)
[2]: https://elementary.io/
[3]: http://elementary.io
[4]: https://opensource.com/article/19/5/getting-started-gnome-boxes-virtualization
[5]: https://opensource.com/sites/default/files/uploads/advent-pantheon-highlight.jpg (A highlighted file in the Pantheon desktop)
[6]: https://opensource.com/sites/default/files/uploads/advent-pantheon.jpg (Pantheon desktop on Elementary OS)
[7]: https://opensource.com/sites/default/files/uploads/advent-pantheon-pcmanfm.jpg (Which one is the guest?)