mirror of
https://github.com/LCTT/TranslateProject.git
synced 2026-08-26 04:13:30 +08:00
Merge branch 'master' into master
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
如何创建适合移动设备的文档
|
||||
=====
|
||||
to 校正:原文章中有些右侧的 tag,出现在仓库文章中,这些没有翻译
|
||||
|
||||
> 帮助用户在智能手机或平板上快速轻松地找到他们所需的信息。
|
||||
|
||||

|
||||
我并不是完全相信[移动为先][1]的理念,但是我确实发现更多的人使用只能手机和平板电脑等移动设备来获取信息。这包括在线的软件和硬件文档,但它们大部分都是冗长的,不适合小屏幕。通常情况下,它的伸缩性不太好,而且很难导航。
|
||||
|
||||
当用户使用移动设备访问文档时,他们通常需要迅速获取信息以了解如何执行任务或解决问题,他们不想通过看似无尽的页面来寻找他们需要的特定信息。幸运的是,解决这个问题并不看来。以下是一些提示,可以帮助你构建文档以满足移动阅读器的需求。
|
||||
我并不是完全相信[移动为先][1]的理念,但是我确实发现更多的人使用智能手机和平板电脑等移动设备来获取信息。这包括在线的软件和硬件文档,但它们大部分都是冗长的,不适合小屏幕。通常情况下,它的伸缩性不太好,而且很难导航。
|
||||
|
||||
当用户使用移动设备访问文档时,他们通常需要迅速获取信息以了解如何执行任务或解决问题,他们不想通过看似无尽的页面来寻找他们需要的特定信息。幸运的是,解决这个问题并不难。以下是一些技巧,可以帮助你构建文档以满足移动阅读器的需求。
|
||||
|
||||
### 简短一点
|
||||
|
||||
这意味着简短的句子,简短的段落和简短的程序。你不是在写一部长篇小说或一段长新闻。使你的文档简洁。尽可能使用少量的语言来获得想法和信息。
|
||||
这意味着简短的句子,简短的段落和简短的流程。你不是在写一部长篇小说或一段长新闻。使你的文档简洁。尽可能使用少量的语言来获得想法和信息。
|
||||
|
||||
以广播新闻报道为示范:关注关键要素,用简单直接的语言对其进行解释。不要让你的读者在屏幕上看到冗长的文字。
|
||||
|
||||
@@ -17,16 +19,16 @@ to 校正:原文章中有些右侧的 tag,出现在仓库文章中,这些
|
||||
|
||||
### 主题
|
||||
|
||||
在技术写作的世界里,主题是独立的,独立的信息块。每个主题都包含你网站上的单个页面。读者应该能从特定的主题中获取他们需要的信息 -- 并且只是那些信息。要做到这一点,选择哪些主题要包含在文档中并决定如何组织它们:
|
||||
在技术写作的世界里,主题是独立的,独立的信息块。每个主题都由你网站上的单个页面组成。读者应该能从特定的主题中获取他们需要的信息 -- 并且只是那些信息。要做到这一点,选择哪些主题要包含在文档中并决定如何组织它们:
|
||||
|
||||
### 考虑 DITA
|
||||
### DITA
|
||||
|
||||
[Darwin Information Typing Architecture][2] 或 DITA 是用于编写和发布的一个 XML 模型。它在技术写作中被[广泛采用][3],特别是对于教程的文档集。
|
||||
<ruby>[达尔文信息类型化体系结构][2]<rt>Darwin Information Typing Architecture</rt></ruby> (DITA) 是用于编写和发布的一个 XML 模型。它[广泛采用][3]在技术写作中,特别是作为较长的文档集中。
|
||||
|
||||
我并不是建议你将文档转换为 XML(除非你真的想)。相反,考虑将 DITA 的不同类型主题的概念应用到你的文档中:
|
||||
|
||||
* 一般:概述信息
|
||||
* 任务:分布程序
|
||||
* 任务:分步骤的流程
|
||||
* 概念:背景或概念信息
|
||||
* 参考:API 参考或数据字典等专用信息
|
||||
* 术语表:定义术语
|
||||
@@ -34,19 +36,19 @@ to 校正:原文章中有些右侧的 tag,出现在仓库文章中,这些
|
||||
|
||||
你会得到很多单独的页面。要连接这些页面:
|
||||
|
||||
### 考虑链接
|
||||
### 链接
|
||||
|
||||
许多内容管理系统,维基和发布框架都包含某种形式的导航 - 通常是目录或[面包屑][4],这是一种在移动设备上淡入背景的导航。
|
||||
许多内容管理系统、维基和发布框架都包含某种形式的导航 —— 通常是目录或[面包屑导航][4],这是一种在移动设备上逐渐消失的导航。
|
||||
|
||||
为了加强导航,在主题之间添加明确的链接。将这些链接放在每个主题末尾的标题**另请参阅**或**相关主题**。每个部分应包含两到五个链接,指向与当前主题相关的概述,概念和参考主题。
|
||||
为了加强导航,在主题之间添加明确的链接。将这些链接放在每个主题末尾的标题**另请参阅**或**相关主题**。每个部分应包含两到五个链接,指向与当前主题相关的概述、概念和参考主题。
|
||||
|
||||
如果你需要指向文档集之外的信息,请确保链接在浏览器新的选项中打开。这将把读者送到另一个网站,同时也将读者留你的网站上。
|
||||
如果你需要指向文档集之外的信息,请确保链接在浏览器新的选项卡中打开。这将把读者送到另一个网站,同时也将读者继续留你的网站上。
|
||||
|
||||
这解决了文本问题,那么图片呢?
|
||||
|
||||
### 考虑不使用图片
|
||||
### 不使用图片
|
||||
|
||||
除少数情况之外,图片不会增加太多文档。仔细查看文档中的每个图片,然后问自己:
|
||||
除少数情况之外,不应该加太多图片到文档中。仔细查看文档中的每个图片,然后问自己:
|
||||
|
||||
* 它有用吗?
|
||||
* 它是否增强了文档?
|
||||
@@ -60,7 +62,7 @@ to 校正:原文章中有些右侧的 tag,出现在仓库文章中,这些
|
||||
|
||||
### 最后的想法
|
||||
|
||||
通过较少的努力,你就可以构建文档以便移动设备用户很好的阅读。另外还有:这些更改也改进了桌面计算机和笔记本电脑用户的文档。
|
||||
通过少量努力,你就可以构建适合移动设备用户的文档。此外,这些更改也改进了桌面计算机和笔记本电脑用户的文档体验。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -69,7 +71,7 @@ via: https://opensource.com/article/17/12/think-mobile
|
||||
|
||||
作者:[Scott Nesbitt][a]
|
||||
译者:[MjSeven](https://github.com/MjSeven)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
@@ -2,13 +2,14 @@ Linux 局域网路由新手指南:第 1 部分
|
||||
======
|
||||
|
||||

|
||||
|
||||
前面我们学习了 [IPv6 路由][1]。现在我们继续深入学习 Linux 中的 IPv4 路由的基础知识。我们从硬件概述、操作系统和 IPv4 地址的基础知识开始,下周我们将继续学习它们如何配置,以及测试路由。
|
||||
|
||||
### 局域网路由器硬件
|
||||
|
||||
Linux 实际上是一个网络操作系统,一直都是,从一开始它就有内置的网络功能。为将你的局域网连入因特网,构建一个局域网路由器比起构建网关路由器要简单的多。你不要太过于执念安全或者防火墙规则,对于处理 NAT 它还是比较复杂的,网络地址转换是 IPv4 的一个痛点。我们为什么不放弃 IPv4 去转到 IPv6 呢?这样将使网络管理员的工作更加简单。
|
||||
Linux 实际上是一个网络操作系统,一直都是,从一开始它就有内置的网络功能。要将你的局域网连入因特网,构建一个局域网路由器比起构建网关路由器要简单的多。你不要太过于执念安全或者防火墙规则,对于处理网络地址转换(NAT)它还是比较复杂的,NAT是 IPv4 的一个痛点。我们为什么不放弃 IPv4 去转到 IPv6 呢?这样将使网络管理员的工作更加简单。
|
||||
|
||||
有点跑题了。从理论上讲,你的 Linux 路由器是一个至少有两个网络接口的小型机器。Linux Gizmos 是一个单片机的综合体:[98 个开放规格的目录,黑客友好的 SBCs][2]。你能够使用一个很老的笔记本电脑或者台式计算机。你也可以使用一个精简版计算机,像 ZaReason Zini 或者 System76 Meerkat 一样,虽然这些有点贵,差不多要 $600。但是它们又结实又可靠,并且你不用在 Windows 许可证上浪费钱。
|
||||
有点跑题了。从理论上讲,你的 Linux 路由器是一个至少有两个网络接口的小型机器。Linux Gizmos 有一个很大的单板机名单:[98 个开放规格、适于黑客的 SBC 的目录][2]。你能够使用一个很老的笔记本电脑或者台式计算机。你也可以使用一个紧凑型计算机,像 ZaReason Zini 或者 System76 Meerkat 一样,虽然这些有点贵,差不多要 $600。但是它们又结实又可靠,并且你不用在 Windows 许可证上浪费钱。
|
||||
|
||||
如果对路由器的要求不高,使用树莓派 3 Model B 作为路由器是一个非常好的选择。它有一个 10/100 以太网端口,板载 2.4GHz 的 802.11n 无线网卡,并且它还有四个 USB 端口,因此你可以插入多个 USB 网卡。USB 2.0 和低速板载网卡可能会让树莓派变成你的网络上的瓶颈,但是,你不能对它期望太高(毕竟它只有 $35,既没有存储也没有电源)。它支持很多种风格的 Linux,因此你可以选择使用你喜欢的版本。基于 Debian 的树莓派是我的最爱。
|
||||
|
||||
@@ -16,63 +17,63 @@ Linux 实际上是一个网络操作系统,一直都是,从一开始它就
|
||||
|
||||
你可以在你选择的硬件上安装将你喜欢的 Linux 的简化版,因为定制的路由器操作系统,比如 OpenWRT、 Tomato、DD-WRT、Smoothwall、Pfsense 等等,都有它们自己的非标准界面。我的观点是,没有必要这么麻烦,它们对你并没有什么帮助。尽量使用标准的 Linux 工具,因为你只需要学习它们一次就够了。
|
||||
|
||||
Debian 的网络安装镜像大约有 300MB 大小,并且支持多种架构,包括 ARM、i386、amd64、和 armhf。Ubuntu 的服务器网络安装镜像也小于 50MB,这样你就可以控制你要安装哪些包。Fedora、Mageia、和 openSUSE 都提供精简的网络安装镜像。如果你需要创意,你可以浏览 [Distrowatch][3]。
|
||||
Debian 的网络安装镜像大约有 300MB 大小,并且支持多种架构,包括 ARM、i386、amd64 和 armhf。Ubuntu 的服务器网络安装镜像也小于 50MB,这样你就可以控制你要安装哪些包。Fedora、Mageia、和 openSUSE 都提供精简的网络安装镜像。如果你需要创意,你可以浏览 [Distrowatch][3]。
|
||||
|
||||
### 路由器能做什么
|
||||
|
||||
我们需要网络路由器做什么?一个路由器连接不同的网络。如果没有路由,那么每个网络都是相互隔离的,所有的悲伤和孤独都没有人与你分享,所有节点只能孤独终老。假设你有一个 192.168.1.0/24 和一个 192.168.2.0/24 网络。如果没有路由器,你的两个网络之间不能相互沟通。这些都是 C 类的私有地址,它们每个都有 254 个可用网络地址。使用 ipcalc 可以非常容易地得到它们的这些信息:
|
||||
我们需要网络路由器做什么?一个路由器连接不同的网络。如果没有路由,那么每个网络都是相互隔离的,所有的悲伤和孤独都没有人与你分享,所有节点只能孤独终老。假设你有一个 192.168.1.0/24 和一个 192.168.2.0/24 网络。如果没有路由器,你的两个网络之间不能相互沟通。这些都是 C 类的私有地址,它们每个都有 254 个可用网络地址。使用 `ipcalc` 可以非常容易地得到它们的这些信息:
|
||||
|
||||
```
|
||||
$ ipcalc 192.168.1.0/24
|
||||
Address: 192.168.1.0 11000000.10101000.00000001. 00000000
|
||||
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
|
||||
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
|
||||
Address: 192.168.1.0 11000000.10101000.00000001. 00000000
|
||||
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
|
||||
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
|
||||
=>
|
||||
Network: 192.168.1.0/24 11000000.10101000.00000001. 00000000
|
||||
HostMin: 192.168.1.1 11000000.10101000.00000001. 00000001
|
||||
HostMax: 192.168.1.254 11000000.10101000.00000001. 11111110
|
||||
Broadcast: 192.168.1.255 11000000.10101000.00000001. 11111111
|
||||
Hosts/Net: 254 Class C, Private Internet
|
||||
|
||||
Network: 192.168.1.0/24 11000000.10101000.00000001. 00000000
|
||||
HostMin: 192.168.1.1 11000000.10101000.00000001. 00000001
|
||||
HostMax: 192.168.1.254 11000000.10101000.00000001. 11111110
|
||||
Broadcast: 192.168.1.255 11000000.10101000.00000001. 11111111
|
||||
Hosts/Net: 254 Class C, Private Internet
|
||||
```
|
||||
|
||||
我喜欢 ipcalc 的二进制输出信息,它更加可视地表示了掩码是如何工作的。前三个八位组表示了网络地址,第四个八位组是主机地址,因此,当你分配主机地址时,你将 “掩盖” 掉网络地址部分,只使用剩余的主机部分。你的两个网络有不同的网络地址,而这就是如果两个网络之间没有路由器它们就不能互相通讯的原因。
|
||||
我喜欢 `ipcalc` 的二进制输出信息,它更加可视地表示了掩码是如何工作的。前三个八位组表示了网络地址,第四个八位组是主机地址,因此,当你分配主机地址时,你将 “掩盖” 掉网络地址部分,只使用剩余的主机部分。你的两个网络有不同的网络地址,而这就是如果两个网络之间没有路由器它们就不能互相通讯的原因。
|
||||
|
||||
每个八位组一共有 256 字节,但是它们并不能提供 256 个主机地址,因为第一个和最后一个值 ,也就是 0 和 255,是被保留的。0 是网络标识,而 255 是广播地址,因此,只有 254 个主机地址。ipcalc 可以帮助你很容易地计算出这些。
|
||||
每个八位组一共有 256 字节,但是它们并不能提供 256 个主机地址,因为第一个和最后一个值 ,也就是 0 和 255,是被保留的。0 是网络标识,而 255 是广播地址,因此,只有 254 个主机地址。`ipcalc` 可以帮助你很容易地计算出这些。
|
||||
|
||||
当然,这并不意味着你不能有一个结尾是 0 或者 255 的主机地址。假设你有一个 16 位的前缀:
|
||||
|
||||
```
|
||||
$ ipcalc 192.168.0.0/16
|
||||
Address: 192.168.0.0 11000000.10101000. 00000000.00000000
|
||||
Netmask: 255.255.0.0 = 16 11111111.11111111. 00000000.00000000
|
||||
Wildcard: 0.0.255.255 00000000.00000000. 11111111.11111111
|
||||
Address: 192.168.0.0 11000000.10101000. 00000000.00000000
|
||||
Netmask: 255.255.0.0 = 16 11111111.11111111. 00000000.00000000
|
||||
Wildcard: 0.0.255.255 00000000.00000000. 11111111.11111111
|
||||
=>
|
||||
Network: 192.168.0.0/16 11000000.10101000. 00000000.00000000
|
||||
HostMin: 192.168.0.1 11000000.10101000. 00000000.00000001
|
||||
HostMax: 192.168.255.254 11000000.10101000. 11111111.11111110
|
||||
Broadcast: 192.168.255.255 11000000.10101000. 11111111.11111111
|
||||
Hosts/Net: 65534 Class C, Private Internet
|
||||
|
||||
Network: 192.168.0.0/16 11000000.10101000. 00000000.00000000
|
||||
HostMin: 192.168.0.1 11000000.10101000. 00000000.00000001
|
||||
HostMax: 192.168.255.254 11000000.10101000. 11111111.11111110
|
||||
Broadcast: 192.168.255.255 11000000.10101000. 11111111.11111111
|
||||
Hosts/Net: 65534 Class C, Private Internet
|
||||
```
|
||||
|
||||
ipcalc 列出了你的第一个和最后一个主机地址,它们是 192.168.0.1 和 192.168.255.254。你是可以有以 0 或者 255 结尾的主机地址的,例如,192.168.1.0 和 192.168.0.255,因为它们都在最小主机地址和最大主机地址之间。
|
||||
`ipcalc` 列出了你的第一个和最后一个主机地址,它们是 192.168.0.1 和 192.168.255.254。你是可以有以 0 或者 255 结尾的主机地址的,例如,192.168.1.0 和 192.168.0.255,因为它们都在最小主机地址和最大主机地址之间。
|
||||
|
||||
不论你的地址块是私有的还是公共的,这个原则同样都是适用的。不要羞于使用 ipcalc 来帮你计算地址。
|
||||
不论你的地址块是私有的还是公共的,这个原则同样都是适用的。不要羞于使用 `ipcalc` 来帮你计算地址。
|
||||
|
||||
### CIDR
|
||||
|
||||
CIDR(无类域间路由)就是通过可变长度的子网掩码来扩展 IPv4 的。CIDR 允许对网络空间进行更精细地分割。我们使用 ipcalc 来演示一下:
|
||||
CIDR(无类域间路由)就是通过可变长度的子网掩码来扩展 IPv4 的。CIDR 允许对网络空间进行更精细地分割。我们使用 `ipcalc` 来演示一下:
|
||||
|
||||
```
|
||||
$ ipcalc 192.168.1.0/22
|
||||
Address: 192.168.1.0 11000000.10101000.000000 01.00000000
|
||||
Netmask: 255.255.252.0 = 22 11111111.11111111.111111 00.00000000
|
||||
Wildcard: 0.0.3.255 00000000.00000000.000000 11.11111111
|
||||
Address: 192.168.1.0 11000000.10101000.000000 01.00000000
|
||||
Netmask: 255.255.252.0 = 22 11111111.11111111.111111 00.00000000
|
||||
Wildcard: 0.0.3.255 00000000.00000000.000000 11.11111111
|
||||
=>
|
||||
Network: 192.168.0.0/22 11000000.10101000.000000 00.00000000
|
||||
HostMin: 192.168.0.1 11000000.10101000.000000 00.00000001
|
||||
HostMax: 192.168.3.254 11000000.10101000.000000 11.11111110
|
||||
Broadcast: 192.168.3.255 11000000.10101000.000000 11.11111111
|
||||
Hosts/Net: 1022 Class C, Private Internet
|
||||
|
||||
Network: 192.168.0.0/22 11000000.10101000.000000 00.00000000
|
||||
HostMin: 192.168.0.1 11000000.10101000.000000 00.00000001
|
||||
HostMax: 192.168.3.254 11000000.10101000.000000 11.11111110
|
||||
Broadcast: 192.168.3.255 11000000.10101000.000000 11.11111111
|
||||
Hosts/Net: 1022 Class C, Private Internet
|
||||
```
|
||||
|
||||
网络掩码并不局限于整个八位组,它可以跨越第三和第四个八位组,并且子网部分的范围可以是从 0 到 3,而不是非得从 0 到 255。可用主机地址的数量并不一定是 8 的倍数,因为它是由整个八位组定义的。
|
||||
@@ -81,7 +82,7 @@ Hosts/Net: 1022 Class C, Private Internet
|
||||
|
||||
从 [理解 IP 地址和 CIDR 图表][4]、[IPv4 私有地址空间和过滤][5]、以及 [IANA IPv4 地址空间注册][6] 开始。接下来的我们将学习如何创建和管理路由器。
|
||||
|
||||
通过来自 Linux 基金会和 edX 的免费课程 ["Linux 入门" ][7]学习更多 Linux 知识。
|
||||
通过来自 Linux 基金会和 edX 的免费课程 [“Linux 入门”][7]学习更多 Linux 知识。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@@ -89,7 +90,7 @@ via: https://www.linux.com/learn/intro-to-linux/2018/2/linux-lan-routing-beginne
|
||||
|
||||
作者:[Carla Schroder][a]
|
||||
译者:[qhwdw](https://github.com/qhwdw)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
使用一个树莓派和 projectx/os 托管你自己的电子邮件
|
||||
使用树莓派和 projectx/os 托管你自己的电子邮件
|
||||
======
|
||||
|
||||
> 这个开源项目可以通过低成本的服务器设施帮助你保护你的数据隐私和所有权。
|
||||
|
||||

|
||||
|
||||
现在有大量的理由,不能再将存储你的数据的任务委以他人之手,也不能在第三方公司运行你的服务;隐私、所有权、以及防范任何人拿你的数据去“赚钱”。但是对于大多数人来说,自己去运行一个服务器,是件即费时间又需要太多的专业知识的事情。不得已,我们只能妥协。抛开这些顾虑,使用某些公司的云服务,随之而来的就是广告、数据挖掘和售卖、以及其它可能的任何东西。
|
||||
现在有大量的理由,不能再将存储你的数据的任务委以他人之手,也不能在第三方公司运行你的服务;隐私、所有权,以及防范任何人拿你的数据去“赚钱”。但是对于大多数人来说,自己去运行一个服务器,是件即费时间又需要太多的专业知识的事情。不得已,我们只能妥协。抛开这些顾虑,使用某些公司的云服务,随之而来的就是广告、数据挖掘和售卖、以及其它可能的任何东西。
|
||||
|
||||
[projectx/os][1] 项目就是要去除这种顾虑,它可以在家里毫不费力地做服务托管,并且可以很容易地创建一个类似于 Gmail 的帐户。实现上述目标,你只需一个 $35 的树莓派 3 和一个基于 Debian 的操作系统镜像 —— 并且不需要很多的专业知识。仅需要四步就可以实现:
|
||||
|
||||
1. 解压缩一个 ZIP 文件到 SD 存储卡中。
|
||||
2. 编辑 SD 上的一个文本文件以便于它连接你的 WiFi(如果你不使用有线网络的话)。
|
||||
2. 编辑 SD 卡上的一个文本文件以便于它连接你的 WiFi(如果你不使用有线网络的话)。
|
||||
3. 将这个 SD 卡插到树莓派 3 中。
|
||||
4. 使用你的智能手机在树莓派 3 上安装 "email 服务器“ 应用并选择一个二级域。
|
||||
4. 使用你的智能手机在树莓派 3 上安装 “email 服务器” 应用并选择一个二级域。
|
||||
|
||||
服务器应用程序(比如电子邮件服务器)被分解到多个容器中,它们中的每个都只能够使用指定的方式与外界通讯,它们使用了管理粒度非常细的隔离措施以提高安全性。例如,入站 SMTP、[SpamAssassin][2](反垃圾邮件平台)、[Dovecot][3] (安全的 IMAP 服务器),以及 webmail 都使用了独立的容器,它们之间相互不能看到对方的数据,因此,单个守护进程出现问题不会波及其它的进程。
|
||||
|
||||
另外,它们都是无状态容器,比如 SpamAssassin 和入站 SMTP,每次收到电子邮件之后,它们的容器都会被销毁并重建,因此,即便是有人找到了 bug 并利用了它,他们也不能访问以前的电子邮件或者接下来的电子邮件;他们只能访问他们自己挖掘出漏洞的那封电子邮件。幸运的是,大多数对外发布的、最容易受到攻击的服务都是隔离的和无状态的。
|
||||
|
||||
服务器应用程序(比如电子邮件服务器)被分解到多个容器中,它们中的每个都只能够使用指定的方式与外界通讯,它们使用了管理粒度非常细的隔离措施以提高安全性。例如,入站 SMTP,[SpamAssassin][2](防垃圾邮件平台),[Dovecot][3] (安全 IMAP 服务器),并且 webmail 都使用了独立的容器,它们之间相互不能看到对方的数据,因此,单个守护进程出现问题不会波及其它的进程。
|
||||
|
||||
另外,它们都是无状态容器,比如 SpamAssassin 和入站 SMTP,每次收到电子邮件之后,它们的连接都会被拆除并重建,因此,即便是有人找到了 bug 并利用了它,他们也不能访问以前的电子邮件或者接下来的电子邮件;他们只能访问他们自己挖掘出漏洞的那封电子邮件。幸运的是,大多数对外发布的、最容易受到攻击的服务都是隔离的和无状态的。
|
||||
|
||||
所有存储的数据都使用 [dm-crypt][4] 进行加密。非公开服务,比如 Dovecot(IMAP)或者 webmail,都是在内部监听,并使用 [ZeroTier One][5] 加密整个网络,因此只有你的设备(智能手机、笔记本电脑、平板等等)才能访问它们。
|
||||
所有存储的数据都使用 [dm-crypt][4] 进行加密。非公开的服务,比如 Dovecot(IMAP)或者 webmail,都是在内部监听,并使用 [ZeroTier One][5] 所提供的私有的加密层叠网络,因此只有你的设备(智能手机、笔记本电脑、平板等等)才能访问它们。
|
||||
|
||||
虽然电子邮件并不是端到端加密的(除非你使用了 [PGP][6]),但是非加密的电子邮件绝不会跨越网络,并且也不会存储在磁盘上。现在明文的电子邮件只存在于双方的私有邮件服务器上,它们都在他们的家中受到很好的安全保护并且只能通过他们的客户端访问(智能手机、笔记本电脑、平板等等)。
|
||||
|
||||
@@ -26,9 +26,7 @@
|
||||
|
||||
### 展望
|
||||
|
||||
电子邮件是我使用 project/os 项目打包的第一个应用程序。想像一下,一个应用程序商店有全部的服务器软件,为易于安装和使用将它们打包到一起。想要一个博客?添加一个 WordPress 应用程序!想替换安全的 Dropbox ?添加一个 [Seafile][8] 应用程序或者一个 [Syncthing][9] 后端应用程序。 [IPFS][10] 节点? [Mastodon][11] 实例?GitLab 服务器?各种家庭自动化/物联网后端服务?这里有大量的非常好的开源服务器软件 ,它们都非常易于安装,并且可以使用它们来替换那些有专利的云服务。
|
||||
|
||||
Nolan Leake 的 [在每个家庭中都有一个云:0 系统管理员技能就可以在家里托管服务器][12] 将在三月 8 - 11日的 [Southern California Linux Expo][12] 进行。使用折扣代码 **OSDC** 去注册可以 50% 的价格得到门票。
|
||||
电子邮件是我使用 project/os 项目打包的第一个应用程序。想像一下,一个应用程序商店有全部的服务器软件,打包起来易于安装和使用。想要一个博客?添加一个 WordPress 应用程序!想替换安全的 Dropbox ?添加一个 [Seafile][8] 应用程序或者一个 [Syncthing][9] 后端应用程序。 [IPFS][10] 节点? [Mastodon][11] 实例?GitLab 服务器?各种家庭自动化/物联网后端服务?这里有大量的非常好的开源服务器软件 ,它们都非常易于安装,并且可以使用它们来替换那些有专利的云服务。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@@ -36,7 +34,7 @@ via: https://opensource.com/article/18/3/host-your-own-email
|
||||
|
||||
作者:[Nolan Leake][a]
|
||||
译者:[qhwdw](https://github.com/qhwdw)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
@@ -1,179 +1,116 @@
|
||||
如何使用 Ansible 打补丁以及安装应用
|
||||
======
|
||||
|
||||
> 使用 Ansible IT 自动化引擎节省更新的时间。
|
||||
|
||||

|
||||
|
||||
你有没有想过,如何打补丁、重启系统,然后继续工作?
|
||||
|
||||
如果你的回答是肯定的,那就需要了解一下 [Ansible][1] 了。它是一个配置管理工具,对于一些复杂的系统管理任务有时候需要几个小时才能完成,又或者对安全性有比较高要求的时候,使用 Ansible 能够大大简化工作流程。
|
||||
如果你的回答是肯定的,那就需要了解一下 [Ansible][1] 了。它是一个配置管理工具,对于一些复杂的有时候需要几个小时才能完成的系统管理任务,又或者对安全性有比较高要求的时候,使用 Ansible 能够大大简化工作流程。
|
||||
|
||||
以我作为系统管理员的经验,打补丁是一项最有难度的工作。每次遇到公共漏洞和暴露(CVE, Common Vulnearbilities and Exposure)通知或者信息安全漏洞预警(IAVA, Information Assurance Vulnerability Alert)时都必须要高度关注安全漏洞,否则安全部门将会严肃追究自己的责任。
|
||||
以我作为系统管理员的经验,打补丁是一项最有难度的工作。每次遇到<ruby>公共漏洞批露<rt>Common Vulnearbilities and Exposure</rt></ruby>(CVE)通知或者<ruby>信息保障漏洞预警<rt>Information Assurance Vulnerability Alert</rt></ruby>(IAVA)时都必须要高度关注安全漏洞,否则安全部门将会严肃追究自己的责任。
|
||||
|
||||
使用 Ansible 可以通过运行[封装模块][2]以缩短打补丁的时间,下面以 [yum 模块][3]更新系统为例,使用 Ansible 可以执行安装、更新、删除、从其它地方安装(例如持续集成/持续开发中的 `rpmbuild`)。以下是系统更新的任务:
|
||||
|
||||
使用 Ansible 可以通过运行[封装模块][2]以缩短打补丁的时间,下面以[yum模块][3]更新系统为例,使用 Ansible 可以执行安装、更新、删除、从其它地方安装(例如持续集成/持续开发中的 `rpmbuild`)。以下是系统更新的任务:
|
||||
```
|
||||
- name: update the system
|
||||
|
||||
yum:
|
||||
|
||||
name: "*"
|
||||
|
||||
state: latest
|
||||
|
||||
```
|
||||
|
||||
在第一行,我们给这个任务命名,这样可以清楚 Ansible 的工作内容。第二行表示使用 `yum` 模块在CentOS虚拟机中执行更新操作。第三行 `name: "*"` 表示更新所有程序。最后一行 `state: latest` 表示更新到最新的 RPM。
|
||||
|
||||
系统更新结束之后,需要重新启动并重新连接:
|
||||
|
||||
```
|
||||
- name: restart system to reboot to newest kernel
|
||||
|
||||
shell: "sleep 5 && reboot"
|
||||
|
||||
async: 1
|
||||
|
||||
poll: 0
|
||||
|
||||
|
||||
|
||||
- name: wait for 10 seconds
|
||||
|
||||
pause:
|
||||
|
||||
seconds: 10
|
||||
|
||||
|
||||
|
||||
- name: wait for the system to reboot
|
||||
|
||||
wait_for_connection:
|
||||
|
||||
connect_timeout: 20
|
||||
|
||||
sleep: 5
|
||||
|
||||
delay: 5
|
||||
|
||||
timeout: 60
|
||||
|
||||
|
||||
|
||||
- name: install epel-release
|
||||
|
||||
yum:
|
||||
|
||||
name: epel-release
|
||||
|
||||
state: latest
|
||||
|
||||
```
|
||||
|
||||
`shell` 字段中的命令让系统在5秒休眠之后重新启动,我们使用 `sleep` 来保持连接不断开,使用 `async` 设定最大等待时长以避免发生超时,`poll` 设置为0表示直接执行不需要等待执行结果。等待10秒钟,使用 `wait_for_connection` 在虚拟机恢复连接后尽快连接。随后由 `install epel-release` 任务检查 RPM 的安装情况。你可以对这个剧本执行多次来验证它的幂等性,唯一会显示造成影响的是重启操作,因为我们使用了 `shell` 模块。如果不想造成实际的影响,可以在使用 `shell` 模块的时候 `changed_when: False`。
|
||||
`shell` 模块中的命令让系统在 5 秒休眠之后重新启动,我们使用 `sleep` 来保持连接不断开,使用 `async` 设定最大等待时长以避免发生超时,`poll` 设置为 0 表示直接执行不需要等待执行结果。暂停 10 秒钟以等待虚拟机恢复,使用 `wait_for_connection` 在虚拟机恢复连接后尽快连接。随后由 `install epel-release` 任务检查 RPM 的安装情况。你可以对这个剧本执行多次来验证它的幂等性,唯一会显示造成影响的是重启操作,因为我们使用了 `shell` 模块。如果不想造成实际的影响,可以在使用 `shell` 模块的时候 `changed_when: False`。
|
||||
|
||||
现在我们已经知道如何对系统进行更新、重启虚拟机、重新连接、安装 RPM 包。下面我们通过 [Ansible Lightbulb][4] 来安装 NGINX:
|
||||
|
||||
```
|
||||
- name: Ensure nginx packages are present
|
||||
|
||||
yum:
|
||||
|
||||
name: nginx, python-pip, python-devel, devel
|
||||
|
||||
state: present
|
||||
|
||||
notify: restart-nginx-service
|
||||
|
||||
|
||||
|
||||
- name: Ensure uwsgi package is present
|
||||
|
||||
pip:
|
||||
|
||||
name: uwsgi
|
||||
|
||||
state: present
|
||||
|
||||
notify: restart-nginx-service
|
||||
|
||||
|
||||
|
||||
- name: Ensure latest default.conf is present
|
||||
|
||||
template:
|
||||
|
||||
src: templates/nginx.conf.j2
|
||||
|
||||
dest: /etc/nginx/nginx.conf
|
||||
|
||||
backup: yes
|
||||
|
||||
notify: restart-nginx-service
|
||||
|
||||
|
||||
|
||||
- name: Ensure latest index.html is present
|
||||
|
||||
template:
|
||||
|
||||
src: templates/index.html.j2
|
||||
|
||||
dest: /usr/share/nginx/html/index.html
|
||||
|
||||
|
||||
|
||||
- name: Ensure nginx service is started and enabled
|
||||
|
||||
service:
|
||||
|
||||
name: nginx
|
||||
|
||||
state: started
|
||||
|
||||
enabled: yes
|
||||
|
||||
|
||||
|
||||
- name: Ensure proper response from localhost can be received
|
||||
|
||||
uri:
|
||||
|
||||
url: "http://localhost:80/"
|
||||
|
||||
return_content: yes
|
||||
|
||||
register: response
|
||||
|
||||
until: 'nginx_test_message in response.content'
|
||||
|
||||
retries: 10
|
||||
|
||||
delay: 1
|
||||
|
||||
```
|
||||
|
||||
And the handler that restarts the nginx service:
|
||||
以及用来重启 nginx 服务的操作文件:
|
||||
|
||||
```
|
||||
# 安装 nginx 的操作文件
|
||||
|
||||
- name: restart-nginx-service
|
||||
|
||||
service:
|
||||
|
||||
name: nginx
|
||||
|
||||
state: restarted
|
||||
|
||||
```
|
||||
|
||||
在这个角色里,我们使用 RPM 安装了 `nginx`、`python-pip`、`python-devel`、`devel`,用 PIP 安装了 `uwsgi`,接下来使用 `template` 模块复制 `nginx.conf` 和 `index.html` 以显示页面,并确保服务在系统启动时启动。然后就可以使用 `uri` 模块检查到页面的连接了。
|
||||
|
||||
这个是一个系统更新、系统重启、安装 RPM 包的剧本示例,后续可以继续安装 nginx,当然这里可以替换成任何你想要的角色和应用程序。
|
||||
|
||||
```
|
||||
- hosts: all
|
||||
|
||||
roles:
|
||||
|
||||
- centos-update
|
||||
|
||||
- nginx-simple
|
||||
|
||||
```
|
||||
|
||||
观看演示视频了解了解这个过程。
|
||||
@@ -182,6 +119,10 @@ And the handler that restarts the nginx service:
|
||||
|
||||
这只是关于如何更新系统、重启以及后续工作的示例。简单起见,我只添加了不带[变量][5]的包,当你在操作大量主机的时候,你就需要修改其中的一些设置了:
|
||||
|
||||
- [async & poll](https://docs.ansible.com/ansible/latest/playbooks_async.html)
|
||||
- [serial](https://docs.ansible.com/ansible/latest/playbooks_delegation.html#rolling-update-batch-size)
|
||||
- [forks](https://docs.ansible.com/ansible/latest/intro_configuration.html#forks)
|
||||
|
||||
这是由于在生产环境中如果你想逐一更新每一台主机的系统,你需要花相当一段时间去等待主机重启才能够继续下去。
|
||||
|
||||
有关 Ansible 进行自动化工作的更多用法,请查阅[其它文章][6]。
|
||||
@@ -192,7 +133,7 @@ via: https://opensource.com/article/18/3/ansible-patch-systems
|
||||
|
||||
作者:[Jonathan Lozada De La Matta][a]
|
||||
译者:[HankChow](https://github.com/HankChow)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
使用 AppImageLauncher 轻松运行和集成 AppImage 文件
|
||||
======
|
||||
|
||||
你有没有下载过 AppImage 文件,而你不知道如何使用它?或许你可能知道如何使用它,但是你每次要运行它时必须要进入到下载了该 .AppImage 的文件夹中来运行它,或者手动为其创建启动程序。
|
||||
|
||||
使用 AppImageLauncher,这些就都是过去的问题。该程序可让你轻松运行 AppImage 文件,而无需使其可执行。但它最有趣的特点是可以轻松地将 AppImage 与你的系统进行整合:AppImageLauncher 可以自动将 AppImage 程序快捷方式添加到桌面环境的程序启动器/菜单(包括程序图标和合适的说明)中。
|
||||
|
||||
这 里有个例子,我想在 Ubuntu 上使用 [Kdenlive][2],但我不想从仓库中安装它,因为它有大量的 KDE 依赖,我不想把它们弄到我的 Gnome 系统中。因为没有它的 Flatpak 或 Snap 镜像,我只能去下载了 Kdenlive 的 AppImage。
|
||||
|
||||
在没有把下载的 [Kdenline][2] AppImage 变成可执行的情况下,我第一次双击它时(安装好了 AppImageLauncher),AppImageLauncher 提供了两个选项:
|
||||
|
||||
“Run once”或者“Integrate and run”。
|
||||
|
||||

|
||||
|
||||
点击 “Integrate and run”,这个 AppImage 就被复制到 `~/.bin/` (家目录中的隐藏文件夹)并添加到菜单中,然后启动该程序。
|
||||
|
||||
要删除它也很简单,只要您使用的桌面环境支持桌面动作就行。例如,在 Gnome Shell 中,只需右键单击“活动概览”中的应用程序图标,然后选择“Remove from system”:
|
||||
|
||||

|
||||
|
||||
更新:该应用只初步为 Ubuntu 和 Mint 做了开发,但它最近会提供 Debian、 Netrunner 和 openSUSE 支持。本文首次发布后添加的另一个功能是支持 AppImage 的更新;你在启动器中可以找到 “Update AppImage”。
|
||||
|
||||
### 下载 AppImageLauncher
|
||||
|
||||
AppImageLauncher 支持 Ubuntu、 Debian、Netrunner 和 openSUSE。如果你使用 Ubuntu 18.04,请确保你下载的 deb 包的名字中有“bionic”,而其它的 deb 是用于旧一些的 Ubuntu 版本的。
|
||||
|
||||
- [下载 AppImageLauncher][1]
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxuprising.com/2018/04/easily-run-and-integrate-appimage-files.html
|
||||
|
||||
作者:[Logix][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://plus.google.com/118280394805678839070
|
||||
[1]:https://github.com/TheAssassin/AppImageLauncher/releases
|
||||
[2]:https://kdenlive.org/download/
|
||||
@@ -1,17 +1,17 @@
|
||||
有用的资源,献给那些想更多了解 Linux 的人
|
||||
=====
|
||||
|
||||
Linux 是最流行和多功能的操作系统之一,它可以用在智能手机,电脑甚至汽车上。自 20 世纪 90 年代以来,Linux 一直存在,并且仍然是最普遍的操作系统之一。
|
||||
Linux 是最流行和多功能的操作系统之一,它可以用在智能手机,电脑甚至汽车上。自 20 世纪 90 年代以来,Linux 存在至今,并且仍然是最普遍的操作系统之一。
|
||||
|
||||
Linux 实际上用于运行大多数网络服务,因为与其他操作系统相比,它被认为是相当稳定的。这是[人们选择 Linux 多于 Windows的原因][1]之一。此外,Linux 为用户提供了隐私,并且根本不收集用户信息,而 Windows 10 及其 Cortana 语音控制系统总是需要更新你的个人信息。
|
||||
Linux 实际上用于运行大多数网络服务,因为与其他操作系统相比,它被认为是相当稳定的。这是[人们选择 Linux 多于 Windows 的原因][1]之一。此外,Linux 为用户提供了隐私,根本不收集用户信息,而 Windows 10 及其 Cortana 语音控制系统总是需要更新你的个人信息。
|
||||
|
||||
Linux 有很多优点。然而,人们并没有听到太多关于它的消息,因为它已被 Windows 和 Mac 挤出市场。许多人开始使用 Linux 时会感到困惑,因为它与流行的操作系统有点不同。
|
||||
Linux 有很多优点。然而,人们并没有听到太多关于它的消息,因为它已被 Windows 和 Mac 挤出(桌面)场。许多人开始使用 Linux 时会感到困惑,因为它与流行的操作系统有点不同。
|
||||
|
||||
为了帮助你,我们为那些想要了解更多关于 Linux 的人收集了 5 个有用的资源。
|
||||
|
||||
### 1.[ Linux 纯新手 ][2]
|
||||
### 1、[Linux 纯新手][2]
|
||||
|
||||
如果你想尽可能多地学习 Linux,你应该考虑 Eduonix 为初学者提供的 Linux 完整教程。这个课程将向你介绍 Linux 的所有功能,并为你提供所有必要的资料,以帮助你了解更多关于 Linux 工作原理的特性。
|
||||
如果你想尽可能多地学习 Linux,你应该考虑 Eduonix 为[初学者提供的 Linux 完整教程][2]。这个课程将向你介绍 Linux 的所有功能,并为你提供所有必要的资料,以帮助你了解更多关于 Linux 工作原理的特性。
|
||||
|
||||
如果你是以下情况,你应该选择本课程:
|
||||
|
||||
@@ -20,58 +20,48 @@ Linux 有很多优点。然而,人们并没有听到太多关于它的消息
|
||||
* 你想了解 Linux 如何与硬件配合使用;
|
||||
* 你想学习如何操作 Linux 命令行。
|
||||
|
||||
### 2.[PC World: Linux 初学者指南][3]
|
||||
### 2、[PC World: Linux 初学者指南][3]
|
||||
|
||||
为想要在一个地方学习所有有关 Linux 的人提供免费资源。PC World 专注于计算机操作系统的各个方面,并为订阅用户提供最准确和最新的信息。在这里,你还可以了解更多关于 [Linux 的好处][4] 和关于其操作系统的最新消息。
|
||||
为想要在一个地方学习所有有关 Linux 的人提供[免费资源][3]。PC World 专注于计算机操作系统的各个方面,并为订阅用户提供最准确和最新的信息。在这里,你还可以了解更多关于 [Linux 的好处][4] 和关于其操作系统的最新消息。
|
||||
|
||||
该资源为你提供以下信息:
|
||||
|
||||
* 如何安装 Linux;
|
||||
|
||||
* 如何使用命令行;
|
||||
|
||||
* 如何安装软件;
|
||||
|
||||
* 如何操作 Linux 桌面环境。
|
||||
|
||||
### 3.[Linux 培训][5]
|
||||
### 3、[Linux.com:Linux 培训][5]
|
||||
|
||||
很多使用计算机的人都需要学习如何操作 Linux,以防 Windows 操作系统突然崩溃。还有什么比使用官方资源来启动你的 Linux 培训更好呢?
|
||||
很多使用计算机的人都需要学习如何操作 Linux,以防 Windows 操作系统突然崩溃。还有什么比使用官方资源来启动你的 [Linux 培训][5]更好呢?
|
||||
|
||||
该资源提供了 Linux 训练的在线注册,你可以从官方来源获取最新信息。“一年前,我们的 IT 部门在官方网站上为我们提供了 Linux 培训” [Assignmenthelper.com.au][6] 的开发人员 Martin Gibson 说道。“我们选择了这门课,因为我们需要学习如何将我们的所有文件备份到另一个系统,为我们的客户提供最大的安全性,而且这个资源真的教会了我们所有的东西。”
|
||||
该资源可用让你在线注册 Linux 训练,你可以从官方来源获取最新信息。“一年前,我们的 IT 部门在官方网站上为我们提供了 Linux 培训” [Assignmenthelper.com.au][6] 的开发人员 Martin Gibson 说道。“我们选择了这门课,因为我们需要学习如何将我们的所有文件备份到另一个系统,为我们的客户提供最大的安全性,而且这个资源真的教会了我们所有的东西。”
|
||||
|
||||
所以你肯定应该使用这个资源,如果:
|
||||
|
||||
* 你想获得有关操作系统的第一手信息;
|
||||
|
||||
* 想要了解如何在你的计算机上运行 Linux 的特性;
|
||||
|
||||
* 想要与其他 Linux 用户联系并与他们分享你的经验。
|
||||
|
||||
### 4. [The Linux Foundation: 视频培训][7]
|
||||
### 4、 [Linux 基金会:视频培训][7]
|
||||
|
||||
如果你在阅读大量资源时容易感到无聊,那么该网站绝对适合你。Linux Foundation 提供由 IT 专家,软件开发技术人员和技术顾问举办的视频培训,讲座和在线研讨会。
|
||||
如果你在阅读大量资源时容易感到无聊,那么该网站绝对适合你。Linux 基金会提供了由 IT 专家、软件开发技术人员和技术顾问举办的视频培训,讲座和在线研讨会。
|
||||
|
||||
所有培训视频分为以下类别:
|
||||
|
||||
* 开发人员: 使用 Linux Kernel 来处理 Linux 设备驱动程序,Linux 虚拟化等;
|
||||
|
||||
* 开发人员: 使用 Linux 内核来处理 Linux 设备驱动程序、Linux 虚拟化等;
|
||||
* 系统管理员:在 Linux 上开发虚拟主机,构建防火墙,分析 Linux 性能等;
|
||||
* 用户:Linux 入门,介绍嵌入式 Linux 等。
|
||||
|
||||
* 用户:开始使用 Linux,介绍嵌入式 Linux 等。
|
||||
|
||||
### 5. [LinuxInsider][8]
|
||||
### 5、 [LinuxInsider][8]
|
||||
|
||||
你知道吗?微软对 Linux 的效率感到惊讶,它[允许用户在微软云计算设备上运行 Linux][9]。如果你想了解更多关于 Linux 操作系统的知识,Linux Insider 会向用户提供关于 Linux 操作系统的最新消息,以及最新更新和 Linux 特性的信息。
|
||||
|
||||
在此资源上,你将有机会:
|
||||
|
||||
* 参与 Linux 社区;
|
||||
|
||||
* 了解如何在各种设备上运行 Linux;
|
||||
|
||||
* 看看评论;
|
||||
|
||||
* 参与博客讨论并阅读科技博客。
|
||||
|
||||
### 总结一下
|
||||
@@ -80,7 +70,7 @@ Linux 提供了很多好处,包括完全的隐私,稳定的操作甚至恶
|
||||
|
||||
### 关于作者
|
||||
|
||||
Lucy Benton 是一位数字营销专家,商业顾问,帮助人们将他们的梦想变为有利润的业务。现在她正在为营销和商业资源撰写。Lucy 还有自己的博客 [_Prowritingpartner.com_][10],在那里你可以查看她最近的发表。
|
||||
Lucy Benton 是一位数字营销专家,商业顾问,帮助人们将他们的梦想变为有利润的业务。现在她正在为营销和商业资源撰写。Lucy 还有自己的博客 [_Prowritingpartner.com_][10],在那里你可以查看她最近发表的文章。
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -88,9 +78,9 @@ Lucy Benton 是一位数字营销专家,商业顾问,帮助人们将他们
|
||||
via: https://linuxaria.com/article/useful-resources-for-those-who-want-to-know-more-about-linux
|
||||
|
||||
作者:[Lucy Benton][a]
|
||||
译者:[MjSeven](https://github.com/MjSeven)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[MjSeven](https://github.com/MjSeven)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
64
published/20180420 A Perl module for better debugging.md
Normal file
64
published/20180420 A Perl module for better debugging.md
Normal file
@@ -0,0 +1,64 @@
|
||||
一个可以更好地调试的 Perl 模块
|
||||
======
|
||||
|
||||
> 这个简单优雅的模块可以让你包含调试或仅用于开发环境的代码,而在产品环境中隐藏它们。
|
||||
|
||||

|
||||
|
||||
仅用于调试或开发调整时的 Perl 代码块有时会很有用。这很好,但是这样的代码块可能会对性能产生很大的影响, 尤其是在运行时才决定是否执行它。
|
||||
|
||||
[Curtis "Ovid" Poe][1] 最近编写了一个可以帮助解决这个问题的模块:[Keyword::DEVELOPMENT][2]。该模块利用 `Keyword::Simple` 和 Perl 5.012 中引入的可插入关键字架构来创建了新的关键字:`DEVELOPMENT`。它使用 `PERL_KEYWORD_DEVELOPMENT` 环境变量的值来确定是否要执行一段代码。
|
||||
|
||||
使用它不能更容易了:
|
||||
|
||||
```
|
||||
use Keyword::DEVELOPMENT;
|
||||
|
||||
sub doing_my_big_loop {
|
||||
my $self = shift;
|
||||
DEVELOPMENT {
|
||||
# insert expensive debugging code here!
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
在编译时,`DEVELOPMENT` 块内的代码已经被优化掉了,根本就不存在。
|
||||
|
||||
你看到好处了么?在沙盒中将 `PERL_KEYWORD_DEVELOPMENT` 环境变量设置为 `true`,在生产环境设为 `false`,并且可以将有价值的调试工具提交到你的代码库中,在你需要的时候随时可用。
|
||||
|
||||
在缺乏高级配置管理的系统中,你也可以使用此模块来处理生产和开发或测试环境之间的设置差异:
|
||||
|
||||
```
|
||||
sub connect_to_my_database {
|
||||
|
||||
my $dsn = "dbi:mysql:productiondb";
|
||||
my $user = "db_user";
|
||||
my $pass = "db_pass";
|
||||
|
||||
DEVELOPMENT {
|
||||
# Override some of that config information
|
||||
$dsn = "dbi:mysql:developmentdb";
|
||||
}
|
||||
|
||||
my $db_handle = DBI->connect($dsn, $user, $pass);
|
||||
}
|
||||
```
|
||||
|
||||
稍后对此代码片段的增强使你能在其他地方,比如 YAML 或 INI 中读取配置信息,但我希望您能在此看到该工具。
|
||||
|
||||
我查看了关键字 `Keyword::DEVELOPMENT` 的源码,花了大约半小时研究,“天哪,我为什么没有想到这个?”安装 `Keyword::Simple` 后,Curtis 给我们的模块就非常简单了。这是我长期以来在自己的编码实践中所需要的一个优雅解决方案。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/4/perl-module-debugging-code
|
||||
|
||||
作者:[Ruth Holloway][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/druthb
|
||||
[1]:https://metacpan.org/author/OVID
|
||||
[2]:https://metacpan.org/pod/release/OVID/Keyword-DEVELOPMENT-0.04/lib/Keyword/DEVELOPMENT.pm
|
||||
@@ -1,32 +1,34 @@
|
||||
使用交互式 shell 来增强你的 Python
|
||||
======
|
||||
|
||||

|
||||
|
||||
Python 编程语言已经成为 IT 中使用的最流行的语言之一。成功的一个原因是它可以用来解决各种问题。从网站开发到数据科学、机器学习到任务自动化,Python 生态系统有丰富的框架和库。本文将介绍 Fedora 软件包集合中提供的一些有用的 Python shell 来简化开发。
|
||||
|
||||
### Python Shell
|
||||
|
||||
Python Shell 让你以交互模式使用解释器。在测试代码或尝试新库时非常有用。在 Fedora 中,你可以通过在终端会话中输入 python3 来调用默认的 shell。虽然 Fedora 提供了一些更高级和增强的 shell。
|
||||
Python Shell 让你以交互模式使用解释器。这在测试代码或尝试新库时非常有用。在 Fedora 中,你可以通过在终端会话中输入 `python3` 来调用默认的 shell。虽然 Fedora 提供了一些更高级和增强的 shell。
|
||||
|
||||
### IPython
|
||||
|
||||
IPython 为 Python shell 提供了许多有用的增强功能。例子包括 tab 补全,对象内省,系统 shell 访问和命令历史检索。许多功能也被 [Jupyter Notebook][1] 使用,因为它底层使用 IPython。
|
||||
IPython 为 Python shell 提供了许多有用的增强功能。例如包括 tab 补全,对象内省,系统 shell 访问和命令历史检索。许多功能也被 [Jupyter Notebook][1] 使用,因为它底层使用 IPython。
|
||||
|
||||
#### 安装和运行 IPython
|
||||
|
||||
```
|
||||
dnf install ipython3
|
||||
ipython3
|
||||
|
||||
```
|
||||
|
||||
使用 tab 补全会提示你可能的选择。当你使用不熟悉的库时,此功能会派上用场。
|
||||
|
||||
![][2]
|
||||
|
||||
如果你需要更多信息,输入 ? 命令使用文档。有关更多详细信息,你可以使用 ?? 命令。
|
||||
如果你需要更多信息,输入 `?` 命令来查看文档。对此的更多详细信息,你可以使用 `??` 命令。
|
||||
|
||||
![][3]
|
||||
|
||||
另一个很酷的功能是使用 ! 字符执行系统 shell 命令的能力。然后可以在 IPython shell 中引用该命令的结果。
|
||||
另一个很酷的功能是使用 `!` 字符执行系统 shell 命令的能力。然后可以在 IPython shell 中引用该命令的结果。
|
||||
|
||||
![][4]
|
||||
|
||||
@@ -34,23 +36,21 @@ IPython 完整的功能列表可在[官方文档][5]中找到。
|
||||
|
||||
### bpython
|
||||
|
||||
bpython 并不能像 IPython 做那么多,但它却在一个简单轻量级包中提供了一系列有用功能。除其他功能之外,bpython 提供:
|
||||
bpython 并不能像 IPython 做那么多,但它却在一个简单的轻量级包中提供了一系列有用功能。除其他功能之外,bpython 提供:
|
||||
|
||||
* 内嵌语法高亮显示
|
||||
* 在你输入时提供自动补全建议
|
||||
* 可预期的参数列表
|
||||
* 能够将代码发送或保存到 pastebin 服务或文件中
|
||||
|
||||
|
||||
|
||||
#### 安装和运行 bpython
|
||||
|
||||
```
|
||||
dnf install bpython3
|
||||
bpython3
|
||||
|
||||
```
|
||||
|
||||
在你输入的时候,bpython 为你提供了选择来自动补全你的代码。
|
||||
在你输入的时候,`bpython` 为你提供了选择来自动补全你的代码。
|
||||
|
||||
![][6]
|
||||
|
||||
@@ -58,7 +58,7 @@ bpython3
|
||||
|
||||
![][7]
|
||||
|
||||
另一个很好的功能是可以使用功能键 F7 在外部编辑器(默认为 Vim)中打开当前的 bpython 会话。这在测试更复杂的程序时非常有用。
|
||||
另一个很好的功能是可以使用功能键 `F7` 在外部编辑器(默认为 Vim)中打开当前的 `bpython` 会话。这在测试更复杂的程序时非常有用。
|
||||
|
||||
有关配置和功能的更多细节,请参考 bpython [文档][8]。
|
||||
|
||||
@@ -76,7 +76,7 @@ via: https://fedoramagazine.org/enhance-python-interactive-shell/
|
||||
作者:[Clément Verna][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[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/) 荣誉推出
|
||||
|
||||
@@ -7,97 +7,98 @@ Project Atomic 通过他们在 Open Container Initiative(OCI)上的努力创
|
||||
|
||||
Buildah 处理构建容器镜像时无需安装完整的容器运行时或守护进程。这对建立容器的持续集成和持续交付管道尤其有用。
|
||||
|
||||
Buildah 使容器的文件系统可以直接供构建主机使用。这意味着构建工具在主机上可用,并且在容器镜像中不需要,从而使构建更快速,镜像更小,更安全。Buildah 有 CentOS、Fedora 和 Debian 的软件包。
|
||||
Buildah 使容器的文件系统可以直接供构建主机使用。这意味着构建工具在主机上可用就行,而不需要在容器镜像中可用,从而使构建更快速,镜像更小,更安全。Buildah 有 CentOS、Fedora 和 Debian 的软件包。
|
||||
|
||||
### 安装 Buildah
|
||||
|
||||
从 Fedora 26 开始 Buildah 可以使用 dnf 进行安装。
|
||||
从 Fedora 26 开始 Buildah 可以使用 `dnf` 进行安装。
|
||||
|
||||
```
|
||||
$ sudo dnf install buildah -y
|
||||
|
||||
```
|
||||
|
||||
buildah 的当前版本为 0.16,可以通过以下命令显示。
|
||||
`buildah` 的当前版本为 0.16,可以通过以下命令显示。
|
||||
|
||||
```
|
||||
$ buildah --version
|
||||
|
||||
```
|
||||
|
||||
### 基本命令
|
||||
|
||||
构建容器镜像的第一步是获取基础镜像,这是通过 Dockerfile 中的 FROM 语句完成的。Buildah 以类似的方式处理这个。
|
||||
构建容器镜像的第一步是获取基础镜像,这是通过 Dockerfile 中的 `FROM` 语句完成的。Buildah 以类似的方式处理这个。
|
||||
|
||||
```
|
||||
$ sudo buildah from fedora
|
||||
|
||||
```
|
||||
|
||||
该命令将拉取 Fedora 的基础镜像并存储在主机上。通过执行以下操作可以检查主机上可用的镜像。
|
||||
|
||||
```
|
||||
$ sudo buildah images
|
||||
IMAGE ID IMAGE NAME CREATED AT SIZE
|
||||
9110ae7f579f docker.io/library/fedora:latest Mar 7, 2018 20:51 234.7 MB
|
||||
|
||||
```
|
||||
|
||||
在拉取基础镜像后,有一个该镜像的运行容器实例,这是一个“工作容器”。
|
||||
|
||||
以下命令显示正在运行的容器。
|
||||
|
||||
```
|
||||
$ sudo buildah containers
|
||||
CONTAINER ID BUILDER IMAGE ID IMAGE NAME
|
||||
CONTAINER NAME
|
||||
6112db586ab9 * 9110ae7f579f docker.io/library/fedora:latest fedora-working-container
|
||||
|
||||
```
|
||||
|
||||
Buildah 还提供了一个非常有用的命令来停止和删除当前正在运行的所有容器。
|
||||
|
||||
```
|
||||
$ sudo buildah rm --all
|
||||
|
||||
```
|
||||
|
||||
完整的命令列表可以使用 -help 选项。
|
||||
完整的命令列表可以使用 `--help` 选项。
|
||||
|
||||
```
|
||||
$ buildah --help
|
||||
|
||||
```
|
||||
|
||||
### 构建一个 Apache Web 服务器容器镜像
|
||||
|
||||
让我们看看如何使用 Buildah 在 Fedora 基础镜像上安装 Apache Web 服务器,然后复制一个可供服务的自定义 index.html。
|
||||
让我们看看如何使用 Buildah 在 Fedora 基础镜像上安装 Apache Web 服务器,然后复制一个可供服务的自定义 `index.html`。
|
||||
|
||||
首先让我们创建自定义的 `index.html`。
|
||||
|
||||
首先让我们创建自定义的 index.html。
|
||||
```
|
||||
$ echo "Hello Fedora Magazine !!!" > index.html
|
||||
|
||||
```
|
||||
|
||||
然后在正在运行的容器中安装 httpd 包。
|
||||
|
||||
```
|
||||
$ sudo buildah from fedora
|
||||
$ sudo buildah run fedora-working-container dnf install httpd -y
|
||||
|
||||
```
|
||||
|
||||
让我们将 index.html 复制到 /var/www/html/。
|
||||
让我们将 `index.html` 复制到 `/var/www/html/`。
|
||||
|
||||
```
|
||||
$ sudo buildah copy fedora-working-container index.html /var/www/html/index.html
|
||||
|
||||
```
|
||||
|
||||
然后配置容器入口点以启动 httpd。
|
||||
|
||||
```
|
||||
$ sudo buildah config --entrypoint "/usr/sbin/httpd -DFOREGROUND" fedora-working-container
|
||||
|
||||
```
|
||||
|
||||
现在为了使“工作容器”可用,commit 命令将容器保存到镜像。
|
||||
现在为了使“工作容器”可用,`commit` 命令将容器保存到镜像。
|
||||
|
||||
```
|
||||
$ sudo buildah commit fedora-working-container hello-fedora-magazine
|
||||
|
||||
```
|
||||
|
||||
hello-fedora-magazine 镜像现在可用,并且可以推送到仓库以供使用。
|
||||
|
||||
```
|
||||
$ sudo buildah images
|
||||
IMAGE ID IMAGE NAME CREATED
|
||||
@@ -106,15 +107,13 @@ AT SIZE
|
||||
Mar 7, 2018 22:51 234.7 MB
|
||||
49bd5ec5be71 docker.io/library/hello-fedora-magazine:latest
|
||||
Apr 27, 2018 11:01 427.7 MB
|
||||
|
||||
```
|
||||
|
||||
通过运行以下步骤,还可以使用 Buildah 来测试此镜像。
|
||||
|
||||
```
|
||||
$ sudo buildah from --name=hello-magazine docker.io/library/hello-fedora-magazine
|
||||
|
||||
$ sudo buildah run hello-magazine
|
||||
|
||||
```
|
||||
|
||||
访问 <http://localhost> 将显示 “Hello Fedora Magazine !!!”
|
||||
@@ -127,7 +126,7 @@ via: https://fedoramagazine.org/daemon-less-container-management-buildah/
|
||||
作者:[Ashutosh Sudhakar Bhakare][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[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/) 荣誉推出
|
||||
|
||||
@@ -2,72 +2,69 @@
|
||||
======
|
||||
|
||||

|
||||
大多数 Linux 发行版在默认配置下已经足够快了。但是,我们仍然可以借助一些额外的应用程序和方法让它们启动更快一点。其中一个可用的这种应用程序就是 **Preload**。它监视用户使用频率比较高的应用程序,并将它们添加到内存中,这样就比一般的方式加载更快一点。因为,正如你所知道的,内存的读取速度远远快于硬盘。Preload 以守护进程的方式在后台中运行,并记录用户使用较为频繁的程序的文件使用相关的统计数据。然后,它将这些二进制文件及它们的依赖项加载进内存,以改善应用程序的加载时间。简而言之,一旦安装了 preload,你使用较为频繁的应用程序将可能加载的更快。
|
||||
|
||||
大多数 Linux 发行版在默认配置下已经足够快了。但是,我们仍然可以借助一些额外的应用程序和方法让它们启动更快一点。其中一个可用的这种应用程序就是 Preload。它监视用户使用频率比较高的应用程序,并将它们添加到内存中,这样就比一般的方式加载更快一点。因为,正如你所知道的,内存的读取速度远远快于硬盘。Preload 以守护进程的方式在后台中运行,并记录用户使用较为频繁的程序的文件使用相关的统计数据。然后,它将这些二进制文件及它们的依赖项加载进内存,以改善应用程序的加载时间。简而言之,一旦安装了 Preload,你使用较为频繁的应用程序将可能加载的更快。
|
||||
|
||||
在这篇详细的教程中,我们将去了解如何安装和使用 Preload,以改善应用程序在 Linux 中的启动时间。
|
||||
|
||||
### 在 Linux 中使用 Preload 改善应用程序启动时间
|
||||
|
||||
Preload 可以在 [**AUR**][1] 上找到。因此,你可以使用 AUR 助理程序在任何基于 Arch 的系统上去安装它,比如,Antergos、Manjaro Linux。
|
||||
Preload 可以在 [AUR][1] 上找到。因此,你可以使用 AUR 助理程序在任何基于 Arch 的系统上去安装它,比如,Antergos、Manjaro Linux。
|
||||
|
||||
使用 [Pacaur][2]:
|
||||
|
||||
使用 [**Pacaur**][2]:
|
||||
```
|
||||
$ pacaur -S preload
|
||||
|
||||
```
|
||||
|
||||
使用 [**Packer**][3]:
|
||||
使用 [Packer][3]:
|
||||
|
||||
```
|
||||
$ packer -S preload
|
||||
|
||||
```
|
||||
|
||||
使用 [**Trizen**][4]:
|
||||
使用 [Trizen][4]:
|
||||
|
||||
```
|
||||
$ trizen -S preload
|
||||
|
||||
```
|
||||
|
||||
使用 [**Yay**][5]:
|
||||
使用 [Yay][5]:
|
||||
|
||||
```
|
||||
$ yay -S preload
|
||||
|
||||
```
|
||||
|
||||
使用 [**Yaourt**][6]:
|
||||
使用 [Yaourt][6]:
|
||||
|
||||
```
|
||||
$ yaourt -S preload
|
||||
|
||||
```
|
||||
|
||||
在 Debian、Ubuntu、Linux Mint 上,Preload 可以在默认仓库中找到。因此,你可以像下面一样,使用 APT 包管理器去安装它。
|
||||
|
||||
```
|
||||
$ sudo apt-get install preload
|
||||
|
||||
```
|
||||
|
||||
Preload 安装完成后,重新启动你的系统。从现在开始,Preload 将监视频繁使用的应用程序,并将它们的二进制文件和库添加到内存中,以使它的启动速度更快。比如,如果你经常使用 Firefox、Chrome 以及 LibreOffice,Preload 将添加这些二进制文件和库到内存中,因此,这些应用程序将启动的更快。而且更好的是,它不需要做任何配置。它是开箱即用的。但是,如果你想去对它进行微调,你可以通过编辑缺省的配置文件 **/etc/preload.conf** 来实现。
|
||||
Preload 安装完成后,重新启动你的系统。从现在开始,Preload 将监视频繁使用的应用程序,并将它们的二进制文件和库添加到内存中,以使它的启动速度更快。比如,如果你经常使用 Firefox、Chrome 以及 LibreOffice,Preload 将添加这些二进制文件和库到内存中,因此,这些应用程序将启动的更快。而且更好的是,它不需要做任何配置。它是开箱即用的。但是,如果你想去对它进行微调,你可以通过编辑缺省的配置文件 `/etc/preload.conf` 来实现。
|
||||
|
||||
### Preload 并不一定适合每个人!
|
||||
|
||||
以下是 Preload 的一些缺点,它并不是对每个人都有帮助,在这个 [**跟贴**][7] 中有讨论到。
|
||||
以下是 Preload 的一些缺点,它并不是对每个人都有帮助,在这个 [跟贴][7] 中有讨论到。
|
||||
|
||||
1. 我使用的是一个有 8GB 内存的现代系统。因此,我的系统总体上来说很快。我每天只打开狂吃内存的应用程序(比如,Firefox、Chrome、VirtualBox、Gimp、等等)一到两次,并且它们始终处于打开状态,因此,它们的二进制文件和库被预读到内存中,并始终整天在内存中。我一般很少去关闭和打开这些应用程序,因此,内存使用纯属浪费。
|
||||
1. 我使用的是一个有 8GB 内存的现代系统。因此,我的系统总体上来说很快。我每天只打开狂吃内存的应用程序(比如,Firefox、Chrome、VirtualBox、Gimp 等等)一到两次,并且它们始终处于打开状态,因此,它们的二进制文件和库被预读到内存中,并始终整天在内存中。我一般很少去关闭和打开这些应用程序,因此,内存使用纯属浪费。
|
||||
2. 如果你使用的是带有 SSD 的现代系统,Preload 是绝对没用的。因为 SSD 的访问时间比起一般的硬盘来要快的多,因此,使用 Preload 是没有意义的。
|
||||
3. Preload 显著影响启动时间。因为大多数的应用程序都预读到内存中,长此以往,将让你的系统启动和运行的更快。
|
||||
|
||||
|
||||
3. Preload 显著影响启动时间。因为更多的应用程序要被预读到内存中,这将让你的系统启动运行时间更长。
|
||||
|
||||
你只有在每天都在大量的重新加载应用程序时,才能看到真正的差别。因此,Preload 最适合开发人员和测试人员,他们每天都打开和关闭应用程序好多次。
|
||||
|
||||
关于 Preload 更多的信息和它是如何工作的,请阅读它的作者写的完整版的 [**Preload 论文**][8]。
|
||||
关于 Preload 更多的信息和它是如何工作的,请阅读它的作者写的完整版的 [Preload 论文][8]。
|
||||
|
||||
教程到此为止,希望能帮到你。后面还有更精彩的内容,请继续关注!
|
||||
|
||||
再见!
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/how-to-improve-application-startup-time-in-linux/
|
||||
@@ -75,7 +72,7 @@ via: https://www.ostechnix.com/how-to-improve-application-startup-time-in-linux/
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[qhwdw](https://github.com/qhwdw)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
7 leadership rules for the DevOps age
|
||||
Translating by FelixYFZ 7 leadership rules for the DevOps age
|
||||
======
|
||||
|
||||

|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
Translating by FelixYFZ Being open about data privacy
|
||||
======
|
||||

|
||||
|
||||
|
||||
Image by : opensource.com
|
||||
|
||||
Today is [Data Privacy Day][1], ("Data Protection Day" in Europe), and you might think that those of us in the open source world should think that all data should be free, [as information supposedly wants to be][2], but life's not that simple. That's for two main reasons:
|
||||
|
||||
1. Most of us (and not just in open source) believe there's at least some data about us that we might not feel happy sharing (I compiled an example list in [a post][3] I published a while ago).
|
||||
2. Many of us working in open source actually work for commercial companies or other organisations subject to legal requirements around what they can share.
|
||||
|
||||
|
||||
|
||||
So actually, data privacy is something that's important for pretty much everybody.
|
||||
|
||||
It turns out that the starting point for what data people and governments believe should be available for organisations to use is somewhat different between the U.S. and Europe, with the former generally providing more latitude for entities--particularly, the more cynical might suggest, large commercial entities--to use data they've collected about us as they will. Europe, on the other hand, has historically taken a more restrictive view, and on the 25th of May, Europe's view arguably will have triumphed.
|
||||
|
||||
### The impact of GDPR
|
||||
|
||||
That's a rather sweeping statement, but the fact remains that this is the date on which a piece of legislation called the General Data Protection Regulation (GDPR), enacted by the European Union in 2016, becomes enforceable. The GDPR basically provides a stringent set of rules about how personal data can be stored, what it can be used for, who can see it, and how long it can be kept. It also describes what personal data is--and it's a pretty broad set of items, from your name and home address to your medical records and on through to your computer's IP address.
|
||||
|
||||
What is important about the GDPR, though, is that it doesn't apply just to European companies, but to any organisation processing data about EU citizens. If you're an Argentinian, Japanese, U.S., or Russian company and you're collecting data about an EU citizen, you're subject to it.
|
||||
|
||||
"Pah!" you may say,1 "I'm not based in the EU: what can they do to me?" The answer is simple: If you want to continue doing any business in the EU, you'd better comply, because if you breach GDPR rules, you could be liable for up to four percent of your global revenues. Yes, that's global revenues: not just revenues in a particular country in Europe or across the EU, not just profits, but global revenues. Those are the sorts of numbers that should lead you to talk to your legal team, who will direct you to your exec team, who will almost immediately direct you to your IT group to make sure you're compliant in pretty short order.
|
||||
|
||||
This may seem like it's not particularly relevant to non-EU citizens, but it is. For most companies, it's going to be simpler and more efficient to implement the same protection measures for data associated with all customers, partners, and employees they deal with, rather than just targeting specific measures at EU citizens. This has got to be a good thing.2
|
||||
|
||||
However, just because GDPR will soon be applied to organisations across the globe doesn't mean that everything's fine and dandy3: it's not. We give away information about ourselves all the time--and permission for companies to use it.
|
||||
|
||||
There's a telling (though disputed) saying: "If you're not paying, you're the product." What this suggests is that if you're not paying for a service, then somebody else is paying to use your data. Do you pay to use Facebook? Twitter? Gmail? How do you think they make their money? Well, partly through advertising, and some might argue that's a service they provide to you, but actually that's them using your data to get money from the advertisers. You're not really a customer of advertising--it's only once you buy something from the advertiser that you become their customer, but until you do, the relationship is between the the owner of the advertising platform and the advertiser.
|
||||
|
||||
Some of these services allow you to pay to reduce or remove advertising (Spotify is a good example), but on the other hand, advertising may be enabled even for services that you think you do pay for (Amazon is apparently working to allow adverts via Alexa, for instance). Unless we want to start paying to use all of these "free" services, we need to be aware of what we're giving up, and making some choices about what we expose and what we don't.
|
||||
|
||||
### Who's the customer?
|
||||
|
||||
There's another issue around data that should be exercising us, and it's a direct consequence of the amounts of data that are being generated. There are many organisations out there--including "public" ones like universities, hospitals, or government departments4--who generate enormous quantities of data all the time, and who just don't have the capacity to store it. It would be a different matter if this data didn't have long-term value, but it does, as the tools for handling Big Data are developing, and organisations are realising they can be mining this now and in the future.
|
||||
|
||||
The problem they face, though, as the amount of data increases and their capacity to store it fails to keep up, is what to do with it. Luckily--and I use this word with a very heavy dose of irony,5 big corporations are stepping in to help them. "Give us your data," they say, "and we'll host it for free. We'll even let you use the data you collected when you want to!" Sounds like a great deal, yes? A fantastic example of big corporations6 taking a philanthropic stance and helping out public organisations that have collected all of that lovely data about us.
|
||||
|
||||
Sadly, philanthropy isn't the only reason. These hosting deals come with a price: in exchange for agreeing to host the data, these corporations get to sell access to it to third parties. And do you think the public organisations, or those whose data is collected, will get a say in who these third parties are or how they will use it? I'll leave this as an exercise for the reader.7
|
||||
|
||||
### Open and positive
|
||||
|
||||
It's not all bad news, however. There's a growing "open data" movement among governments to encourage departments to make much of their data available to the public and other bodies for free. In some cases, this is being specifically legislated. Many voluntary organisations--particularly those receiving public funding--are starting to do the same. There are glimmerings of interest even from commercial organisations. What's more, there are techniques becoming available, such as those around differential privacy and multi-party computation, that are beginning to allow us to mine data across data sets without revealing too much about individuals--a computing problem that has historically been much less tractable than you might otherwise expect.
|
||||
|
||||
What does this all mean to us? Well, I've written before on Opensource.com about the [commonwealth of open source][4], and I'm increasingly convinced that we need to look beyond just software to other areas: hardware, organisations, and, relevant to this discussion, data. Let's imagine that you're a company (A) that provides a service to another company, a customer (B).8 There are four different types of data in play:
|
||||
|
||||
1. Data that's fully open: visible to A, B, and the rest of the world
|
||||
2. Data that's known, shared, and confidential: visible to A and B, but nobody else
|
||||
3. Data that's company-confidential: visible to A, but not B
|
||||
4. Data that's customer-confidential: visible to B, but not A
|
||||
|
||||
|
||||
|
||||
First of all, maybe we should be a bit more open about data and default to putting it into bucket 1. That data--on self-driving cars, voice recognition, mineral deposits, demographic statistics--could be enormously useful if it were available to everyone.9 Also, wouldn't it be great if we could find ways to make the data in buckets 2, 3, and 4--or at least some of it--available in bucket 1, whilst still keeping the details confidential? That's the hope for some of these new techniques being researched. They're a way off, though, so don't get too excited, and in the meantime, start thinking about making more of your data open by default.
|
||||
|
||||
### Some concrete steps
|
||||
|
||||
So, what can we do around data privacy and being open? Here are a few concrete steps that occurred to me: please use the comments to contribute more.
|
||||
|
||||
* Check to see whether your organisation is taking GDPR seriously. If it isn't, push for it.
|
||||
* Default to encrypting sensitive data (or hashing where appropriate), and deleting when it's no longer required--there's really no excuse for data to be in the clear to these days except for when it's actually being processed.
|
||||
* Consider what information you disclose when you sign up to services, particularly social media.
|
||||
* Discuss this with your non-technical friends.
|
||||
* Educate your children, your friends' children, and their friends. Better yet, go and talk to their teachers about it and present something in their schools.
|
||||
* Encourage the organisations you work for, volunteer for, or interact with to make data open by default. Rather than thinking, "why should I make this public?" start with "why shouldn't I make this public?"
|
||||
* Try accessing some of the open data sources out there. Mine it, create apps that use it, perform statistical analyses, draw pretty graphs,10 make interesting music, but consider doing something with it. Tell the organisations that sourced it, thank them, and encourage them to do more.
|
||||
|
||||
|
||||
|
||||
1. Though you probably won't, I admit.
|
||||
|
||||
2. Assuming that you believe that your personal data should be protected.
|
||||
|
||||
3. If you're wondering what "dandy" means, you're not alone at this point.
|
||||
|
||||
4. Exactly how public these institutions seem to you will probably depend on where you live: [YMMV][5].
|
||||
|
||||
5. And given that I'm British, that's a really very, very heavy dose.
|
||||
|
||||
6. And they're likely to be big corporations: nobody else can afford all of that storage and the infrastructure to keep it available.
|
||||
|
||||
7. No. The answer's "no."
|
||||
|
||||
8. Although the example works for people, too. Oh, look: A could be Alice, B could be Bob…
|
||||
|
||||
9. Not that we should be exposing personal data or data that actually needs to be confidential, of course--not that type of data.
|
||||
|
||||
10. A friend of mine decided that it always seemed to rain when she picked her children up from school, so to avoid confirmation bias, she accessed rainfall information across the school year and created graphs that she shared on social media.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/1/being-open-about-data-privacy
|
||||
|
||||
作者:[Mike Bursell][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/mikecamel
|
||||
[1]:https://en.wikipedia.org/wiki/Data_Privacy_Day
|
||||
[2]:https://en.wikipedia.org/wiki/Information_wants_to_be_free
|
||||
[3]:https://aliceevebob.wordpress.com/2017/06/06/helping-our-governments-differently/
|
||||
[4]:https://opensource.com/article/17/11/commonwealth-open-source
|
||||
[5]:http://www.outpost9.com/reference/jargon/jargon_40.html#TAG2036
|
||||
@@ -0,0 +1,164 @@
|
||||
How To Downgrade A Package In Arch Linux
|
||||
======
|
||||
|
||||

|
||||
As you might know, Arch Linux is a rolling release and DIY (do-it-yourself) distribution. So you have to be bit careful while updating it often, especially installing or updating packages from the third party repositories like AUR. You might be end up with broken system if you don’t know what you are doing. It is your responsibility to make Arch Linux more stable. However, we all do mistakes. It is difficult to be careful all time. Sometimes, you want to update to most bleeding edge, and you might be stuck with broken packages. Don’t panic! In such cases, you can simply rollback to the old stable packages. This short tutorial describes how to downgrade a package in Arch Linux and its variants like Antergos, Manjaro Linux.
|
||||
|
||||
### Downgrade a package in Arch Linux
|
||||
|
||||
In Arch Linux, there is an utility called** “downgrade”** that helps you to downgrade an installed package to any available older version. This utility will check your local cache and the remote servers (Arch Linux repositories) for the old versions of a required package. You can pick any one of the old stable package from that list and install it.
|
||||
|
||||
This package is not available in the official repositories. You need to add the unofficial **archlinuxfr** repository.
|
||||
|
||||
To do so, edit **/etc/pacman.conf** file:
|
||||
```
|
||||
$ sudo nano /etc/pacman.conf
|
||||
|
||||
```
|
||||
|
||||
Add the following lines:
|
||||
```
|
||||
[archlinuxfr]
|
||||
SigLevel = Never
|
||||
Server = http://repo.archlinux.fr/$arch
|
||||
|
||||
```
|
||||
|
||||
Save and close the file.
|
||||
|
||||
Update the repositories with command:
|
||||
```
|
||||
$ sudo pacman -Sy
|
||||
|
||||
```
|
||||
|
||||
Then install “Downgrade” utility using the following command from your Terminal:
|
||||
```
|
||||
$ sudo pacman -S downgrade
|
||||
|
||||
```
|
||||
|
||||
**Sample output:**
|
||||
```
|
||||
resolving dependencies...
|
||||
looking for conflicting packages...
|
||||
|
||||
Packages (1) downgrade-5.2.3-1
|
||||
|
||||
Total Download Size: 0.01 MiB
|
||||
Total Installed Size: 0.10 MiB
|
||||
|
||||
:: Proceed with installation? [Y/n]
|
||||
|
||||
```
|
||||
|
||||
The typical usage of “downgrade” command is:
|
||||
```
|
||||
$ sudo downgrade [PACKAGE, ...] [-- [PACMAN OPTIONS]]
|
||||
|
||||
```
|
||||
|
||||
Let us say you want to downgrade **opera web browser** to any available old version.
|
||||
|
||||
To do so, run:
|
||||
```
|
||||
$ sudo downgrade opera
|
||||
|
||||
```
|
||||
|
||||
This command will list all available versions of opera package (both new and old) from your local cache and remote mirror.
|
||||
|
||||
**Sample output:**
|
||||
```
|
||||
Available packages:
|
||||
|
||||
1) opera-37.0.2178.43-1-x86_64.pkg.tar.xz (local)
|
||||
2) opera-37.0.2178.43-1-x86_64.pkg.tar.xz (remote)
|
||||
3) opera-37.0.2178.32-1-x86_64.pkg.tar.xz (remote)
|
||||
4) opera-36.0.2130.65-2-x86_64.pkg.tar.xz (remote)
|
||||
5) opera-36.0.2130.65-1-x86_64.pkg.tar.xz (remote)
|
||||
6) opera-36.0.2130.46-2-x86_64.pkg.tar.xz (remote)
|
||||
7) opera-36.0.2130.46-1-x86_64.pkg.tar.xz (remote)
|
||||
8) opera-36.0.2130.32-2-x86_64.pkg.tar.xz (remote)
|
||||
9) opera-36.0.2130.32-1-x86_64.pkg.tar.xz (remote)
|
||||
10) opera-35.0.2066.92-1-x86_64.pkg.tar.xz (remote)
|
||||
11) opera-35.0.2066.82-1-x86_64.pkg.tar.xz (remote)
|
||||
12) opera-35.0.2066.68-1-x86_64.pkg.tar.xz (remote)
|
||||
13) opera-35.0.2066.37-2-x86_64.pkg.tar.xz (remote)
|
||||
14) opera-34.0.2036.50-1-x86_64.pkg.tar.xz (remote)
|
||||
15) opera-34.0.2036.47-1-x86_64.pkg.tar.xz (remote)
|
||||
16) opera-34.0.2036.25-1-x86_64.pkg.tar.xz (remote)
|
||||
17) opera-33.0.1990.115-2-x86_64.pkg.tar.xz (remote)
|
||||
18) opera-33.0.1990.115-1-x86_64.pkg.tar.xz (remote)
|
||||
19) opera-33.0.1990.58-1-x86_64.pkg.tar.xz (remote)
|
||||
20) opera-32.0.1948.69-1-x86_64.pkg.tar.xz (remote)
|
||||
21) opera-32.0.1948.25-1-x86_64.pkg.tar.xz (remote)
|
||||
22) opera-31.0.1889.174-1-x86_64.pkg.tar.xz (remote)
|
||||
23) opera-31.0.1889.99-1-x86_64.pkg.tar.xz (remote)
|
||||
24) opera-30.0.1835.125-1-x86_64.pkg.tar.xz (remote)
|
||||
25) opera-30.0.1835.88-1-x86_64.pkg.tar.xz (remote)
|
||||
26) opera-30.0.1835.59-1-x86_64.pkg.tar.xz (remote)
|
||||
27) opera-30.0.1835.52-1-x86_64.pkg.tar.xz (remote)
|
||||
28) opera-29.0.1795.60-1-x86_64.pkg.tar.xz (remote)
|
||||
29) opera-29.0.1795.47-1-x86_64.pkg.tar.xz (remote)
|
||||
30) opera-28.0.1750.51-1-x86_64.pkg.tar.xz (remote)
|
||||
31) opera-28.0.1750.48-1-x86_64.pkg.tar.xz (remote)
|
||||
32) opera-28.0.1750.40-1-x86_64.pkg.tar.xz (remote)
|
||||
33) opera-27.0.1689.76-1-x86_64.pkg.tar.xz (remote)
|
||||
34) opera-27.0.1689.69-1-x86_64.pkg.tar.xz (remote)
|
||||
35) opera-27.0.1689.66-1-x86_64.pkg.tar.xz (remote)
|
||||
36) opera-27.0.1689.54-2-x86_64.pkg.tar.xz (remote)
|
||||
37) opera-27.0.1689.54-1-x86_64.pkg.tar.xz (remote)
|
||||
38) opera-26.0.1656.60-1-x86_64.pkg.tar.xz (remote)
|
||||
39) opera-26.0.1656.32-1-x86_64.pkg.tar.xz (remote)
|
||||
40) opera-12.16.1860-2-x86_64.pkg.tar.xz (remote)
|
||||
41) opera-12.16.1860-1-x86_64.pkg.tar.xz (remote)
|
||||
|
||||
select a package by number:
|
||||
|
||||
```
|
||||
|
||||
Just type the package number of your choice, and hit enter to install it.
|
||||
|
||||
That’s it. The current installed package will be downgraded to the old version.
|
||||
|
||||
**Also Read:[How To Downgrade All Packages To A Specific Date In Arch Linux][1]**
|
||||
|
||||
##### So, how can avoid broken packages and make Arch Linux more stable?
|
||||
|
||||
Check [**Arch Linux news**][2] and [**forums**][3] before updating Arch Linux to find out if there have been any reported problem. I have been using Arch Linux as my main OS for the past few weeks. Here is some simple tips that I have found over a period of time to avoid installing unstable packages in Arch Linux.
|
||||
|
||||
1. Avoid partial upgrades. It means that never run “pacman -Sy <package-name>”. This command will partially upgrade your system while installing a package. Instead, first use “pacman -Syu” to update the system and then use “package -S <package-name>” to a install package.
|
||||
2. Avoid using “pacman -Syu –force” command. The –force flag will ignore the package and file conflicts and you might end-up with broken packages or broken system.
|
||||
3. Do not skip dependency check. It means that do not use “pacman -Rdd <package-name>”. This command will avoid dependency check while removing a package. If you run this command, a critical dependency which is needed by another important package could be removed too. Eventually, it will break your Arch Linux.
|
||||
4. It is always a good practice to make regular backup of important data and configuration files to avoid any data loss.
|
||||
5. Be careful while installing packages from third party and unofficial repositories like AUR. And do not install packages that are in heavy development.
|
||||
|
||||
|
||||
|
||||
For more details, check the [**Arch Linux maintenance guide**][4].
|
||||
|
||||
I am not an Arch Linux expert, and I am still learning to make it more stable. Please feel free to let me know If you have any tips to make Arch Linux stable and safe in the comment section below. I am all ears.
|
||||
|
||||
Hope this helps. That’s all for now. I will be here again with another interesting article soon. Until then, stay tuned with OSTechNix.
|
||||
|
||||
Cheers!
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.ostechnix.com/downgrade-package-arch-linux/
|
||||
|
||||
作者:[SK][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.ostechnix.com/author/sk/
|
||||
[1]:https://www.ostechnix.com/downgrade-packages-specific-date-arch-linux/
|
||||
[2]:https://www.archlinux.org/news/
|
||||
[3]:https://bbs.archlinux.org/
|
||||
[4]:https://wiki.archlinux.org/index.php/System_maintenance
|
||||
@@ -1,57 +0,0 @@
|
||||
lontow translating
|
||||
|
||||
5 ways open source can strengthen your job search
|
||||
======
|
||||

|
||||
|
||||
Are you searching for a job in the bustling tech industry? Whether you're a seasoned member of the tech community looking for a new challenge or a recent graduate looking for your first job, contributing to open source projects can be a great way to boost your attractiveness as a candidate. Below are five ways your work on open source projects may strengthen your job hunt.
|
||||
|
||||
### 1. Get project experience
|
||||
|
||||
Perhaps the clearest way working on open source projects can assist in your job search is by giving you project experience. If you are a student, you may not have many concrete projects to showcase on your resume. If you are working, perhaps you can't discuss your current projects due to privacy limitations, or maybe you're not working on tasks that interest you. Either way, scouting out appealing open source projects that allow you to showcase your skills may help in your job search. These projects are great eye-catchers on resumes and can be perfect discussion topics in interviews.
|
||||
|
||||
In addition, many open source projects are kept in public repositories, such as [GitHub][1], so accessing the source code is easy for anyone who wants to become involved. Also, it makes your publicly accessible code contributions easy for recruiters and other individuals at potential employers to find. The fact that these projects are open allows you to demonstrate your skills in a more concrete manner than simply discussing them in an interview.
|
||||
|
||||
### 2. Learn to ask good questions
|
||||
|
||||
Any new member of an open source project community has the opportunity to learn a lot. They must discover avenues of communication; structure and hierarchy; documentation format; and many other aspects unique to the project. To begin participating in and contributing to a project, you need to ask many questions to put yourself in a position for success. As the familiar saying goes, there are no stupid questions. Open source project communities promote inquisivity, especially when answers aren't easy to find.
|
||||
|
||||
The unfamiliarity when beginning to work on open source projects teaches individuals to ask questions, and to ask them often. This helps participants develop great skills in identifying what questions to ask, how to ask them, and who to approach. This skill is useful in job searching, [interviewing][2], and living life in general. Problem-solving skills and reaching out for help when you need it are highly valued in the job market.
|
||||
|
||||
### 3. Access new technologies and continuous learning
|
||||
|
||||
Most software projects use many different technologies. It is rare for every contributor to be familiar with every piece of technology in a project. Even after working on a project for a while, individuals likely won't be familiar with all the technologies it uses.
|
||||
|
||||
While veterans of an open source project may be unfamiliar with certain pieces of the project, newbies will be extremely unfamiliar with many or most. This creates a huge learning opportunity. A person may begin working on an open source project to improve one piece of functionality, most likely in a technical area they are familiar with. But the path from there can take a much different turn.
|
||||
|
||||
Working on one aspect of a project might lead you down an unfamiliar road and prompt new learning. Working on an open source project may expose you to new technologies you would never use otherwise. It can also reveal new passions, or at minimum, facilitate continuous learning--which [employers find highly desirable][3].
|
||||
|
||||
### 4. Increase your connections and network
|
||||
|
||||
Open source projects are maintained and surrounded by diverse communities. Some individuals working on open source projects do so in their free time, and they all have their own backstories, interests, and connections. As they say, "it's all about who you know." You may never meet certain people except through working an open source project. Maybe you'll work with people around the world, or maybe you'll connect with your next-door neighbor. Regardless, you never know who may help connect you to your next job. The connections and networking possibilities exposed through an open source project may be extremely helpful in finding your next (or first!) job.
|
||||
|
||||
### 5. Build confidence
|
||||
|
||||
Finally, contributing to open source projects may give you a newfound confidence. Many new employees in the tech industry may feel a sense of [imposter syndrome][4], because without having accomplished significant work, they may feel they don't belong, they are frauds, or they don't deserve to be in their new position. Working on open source projects before you are hired may minimize this issue.
|
||||
|
||||
Work on open source projects is often done individually, but it all contributes to the project as a whole. Open source communities are highly inclusive and cooperative, and your contributions will be noticed. It is always rewarding to be validated by other community members (especially more senior members). The recognition you may gain from code commits to an open source project could improve your confidence and counter imposter syndrome. This confidence can then carry over to interviews, new positions, and beyond.
|
||||
|
||||
These are only a handful of the benefits you may see from working on open source projects. If you know of other advantages, please share them in the comments below.
|
||||
### About The Author
|
||||
Sophie Polson;Sophie Is A Senior At Duke University Studying Computer Science. She Has Just Started To Venture Into The Open Source Community Via The Course;Open Source World;Taught At Duke In The Fall Of;Has Developed An Interest In Exploring Devops. She Will Be Working As A Software Engineer Following Her Graduation In The Spring Of
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/1/5-ways-turn-open-source-new-job
|
||||
|
||||
作者:[Sophie Polson][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/sophiepolson
|
||||
[1]:https://github.com/dbaldwin/DronePan
|
||||
[2]:https://www.thebalance.com/why-you-should-ask-questions-in-a-job-interview-1669548
|
||||
[3]:https://www.computerworld.com/article/3177442/it-careers/lifelong-learning-is-no-longer-optional.html
|
||||
[4]:https://en.wikipedia.org/wiki/Impostor_syndrome
|
||||
@@ -1,3 +1,6 @@
|
||||
Translating by MjSeven
|
||||
|
||||
|
||||
How To Archive Files And Directories In Linux
|
||||
======
|
||||
|
||||
|
||||
@@ -1,371 +0,0 @@
|
||||
Translating by MjSeven
|
||||
|
||||
|
||||
# 6 Python datetime libraries
|
||||
|
||||
### There are a host of libraries that make it simpler to test, convert, and read date and time information in Python.
|
||||
|
||||

|
||||
|
||||
Image by :
|
||||
|
||||
[WOCinTech Chat][1]. Modified by Opensource.com. [CC BY-SA 4.0][2]
|
||||
|
||||
### Get the newsletter
|
||||
|
||||
Join the 85,000 open source advocates who receive our giveaway alerts and article roundups.
|
||||
|
||||
_This article was co-written with [Jeff Triplett][3]._
|
||||
|
||||
Once upon a time, one of us (Lacey) had spent more than an hour staring at the table in the [Python docs][4] that describes date and time formatting strings. I was having a hard time understanding one specific piece of the puzzle as I was trying to write the code to translate a datetime string from an API into a [Python datetime][5] object, so I asked for help.
|
||||
|
||||
"Why don't you just use dateutil?" someone asked.
|
||||
|
||||
Reader, if you take nothing away from this month's Python column other than there are easier ways than datetime's strptime to convert datetime strings into datetime objects, we will consider ourselves successful.
|
||||
|
||||
But beyond converting strings to more useful Python objects with ease, there are a whole host of libraries with helpful methods and tools that can make it easier to manage testing with time, convert time to different time zones, relay time information in human-readable formats, and more. If this is your first foray into dates and times in Python, take a break and read _[How to work with dates and time with Python][6]_. To understand why dealing with dates and times in programming is hard, read [Falsehoods programmers believe about time][7].
|
||||
|
||||
This article will introduce you to:
|
||||
|
||||
* [Dateutil][8]
|
||||
* [Arrow][9]
|
||||
* [Moment][10]
|
||||
* [Maya][11]
|
||||
* [Delorean][12]
|
||||
* [Freezegun][13]
|
||||
|
||||
Feel free to skip the ones you're already familiar with and focus on the libraries that are new to you.
|
||||
|
||||
### The built-in datetime module
|
||||
|
||||
More Python Resources
|
||||
|
||||
* [What is Python?][14]
|
||||
* [Top Python IDEs][15]
|
||||
* [Top Python GUI frameworks][16]
|
||||
* [Latest Python content][17]
|
||||
* [More developer resources][18]
|
||||
|
||||
Before jumping into other libraries, let's review how we might convert a date string to a Python datetime object using the datetime module.
|
||||
|
||||
Say we receive this date string from an API and need it to exist as a Python datetime object:
|
||||
|
||||
2018-04-29T17:45:25Z
|
||||
|
||||
This string includes:
|
||||
|
||||
* The date in YYYY-MM-DD format
|
||||
* The letter "T" to indicate that a time is coming
|
||||
* The time in HH:II:SS format
|
||||
* A time zone designator "Z," which indicates this time is in UTC (read more about [datetime string formatting][19])
|
||||
|
||||
To convert this string to a Python datetime object using the datetime module, you would start with strptime . datetime.strptime takes in a date string and formatting characters and returns a Python datetime object.
|
||||
|
||||
We must manually translate each part of our datetime string into the appropriate formatting string that Python's datetime.strptime can understand. The four-digit year is represented by %Y. The two-digit month is %m. The two-digit day is %d. Hours in a 24-hour clock are %H, and zero-padded minutes are %M. Zero-padded seconds are %S.
|
||||
|
||||
Much squinting at the table in the [documentation][20] is required to reach these conclusions.
|
||||
|
||||
Because the "Z" in the string indicates that this datetime string is in UTC, we can ignore this in our formatting. (Right now, we won't worry about time zones.)
|
||||
|
||||
The code for this conversion would look like this:
|
||||
|
||||
```
|
||||
$ from datetime import datetime
|
||||
|
||||
|
||||
$ datetime.strptime('2018-04-29T17:45:25Z', '%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25)
|
||||
```
|
||||
|
||||
The formatting string is hard to read and understand. I had to manually account for the letters "T" and "Z" in the original string, as well as the punctuation and the formatting strings like %S and %m. Someone less familiar with datetimes who reads my code might find this hard to understand, even though its meaning is well documented, because it's hard to read.
|
||||
|
||||
Let's look at how other libraries handle this kind of conversion.
|
||||
|
||||
### Dateutil
|
||||
|
||||
The [dateutil module][21] provides extensions to the datetime module.
|
||||
|
||||
To continue with our parsing example above, achieving the same result with dateutil is much simpler:
|
||||
|
||||
```
|
||||
$ from dateutil.parser import parse
|
||||
|
||||
|
||||
$ parse('2018-04-29T17:45:25Z')
|
||||
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=tzutc())
|
||||
```
|
||||
|
||||
The dateutil parser will automatically return the string's time zone if it's included. Since ours was in UTC, you can see that the datetime object returned that. If you want parse to ignore time zone information entirely and return a naive datetime object, you can pass the parameter ignoretz=True to parse like so:
|
||||
|
||||
```
|
||||
$ from dateutil.parser import parse
|
||||
|
||||
|
||||
$ parse('2018-04-29T17:45:25Z', ignoretz=True)
|
||||
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25)
|
||||
```
|
||||
|
||||
Dateutil can also parse more human-readable date strings:
|
||||
|
||||
```
|
||||
$ parse('April 29th, 2018 at 5:45 pm')
|
||||
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45)
|
||||
```
|
||||
|
||||
dateutil also offers tools like [relativedelta][22] for calculating the time difference between two datetimes or adding/removing time to/from a datetime, [rrule][23] for creating recurring datetimes, and [tz][24] for dealing with time zones, among other tools.
|
||||
|
||||
### Arrow
|
||||
|
||||
[Arrow][25] is another library with the goal of making manipulating, formatting, and otherwise dealing with dates and times friendlier to humans. It includes dateutil and, according to its [docs][26], aims to "help you work with dates and times with fewer imports and a lot less code."
|
||||
|
||||
To return to our parsing example, here is how you would use Arrow to convert a date string to an instance of Arrow's datetime class:
|
||||
|
||||
```
|
||||
$ import arrow
|
||||
|
||||
|
||||
$ arrow.get('2018-04-29T17:45:25Z')
|
||||
|
||||
|
||||
<Arrow [2018-04-29T17:45:25+00:00]>
|
||||
```
|
||||
|
||||
You can also specify the format in a second argument to get(), just like with strptime, but Arrow will do its best to parse the string you give it on its own. get() returns an instance of Arrow's datetime class. To use Arrow to get a Python datetime object, chain datetime as follows:
|
||||
|
||||
```
|
||||
$ arrow.get('2018-04-29T17:45:25Z').datetime
|
||||
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=tzutc())
|
||||
```
|
||||
|
||||
With the instance of the Arrow datetime class, you have access to Arrow's other helpful methods. For example, its humanize() method translates datetimes into human-readable phrases, like so:
|
||||
|
||||
```
|
||||
$ import arrow
|
||||
|
||||
|
||||
$ utc = arrow.utcnow()
|
||||
|
||||
|
||||
$ utc.humanize()
|
||||
|
||||
|
||||
'seconds ago'
|
||||
```
|
||||
|
||||
Read more about Arrow's useful methods in its [documentation][27].
|
||||
|
||||
### Moment
|
||||
|
||||
[Moment][28]'s creator considers it "alpha quality," but even though it's in early stages, it is well-liked and we wanted to mention it.
|
||||
|
||||
Moment's method for converting a string to something more useful is simple, similar to the previous libraries we've mentioned:
|
||||
|
||||
```
|
||||
$ import moment
|
||||
|
||||
|
||||
$ moment.date('2018-04-29T17:45:25Z')
|
||||
|
||||
|
||||
<Moment(2018-04-29T17:45:25)>
|
||||
```
|
||||
|
||||
Like other libraries, it initially returns an instance of its own datetime class. To return a Python datetime object, add another date() call.
|
||||
|
||||
```
|
||||
$ moment.date('2018-04-29T17:45:25Z').date
|
||||
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=<StaticTzInfo 'Z'>)
|
||||
```
|
||||
|
||||
This will convert the Moment datetime class to a Python datetime object.
|
||||
|
||||
Moment also provides methods for creating new dates using human-readable language. To create a date for tomorrow:
|
||||
|
||||
```
|
||||
$ moment.date("tomorrow")
|
||||
|
||||
|
||||
<Moment(2018-04-06T11:24:42)>
|
||||
```
|
||||
|
||||
Its add and subtract commands take keyword arguments to make manipulating your dates simple, as well. To get the day after tomorrow, Moment would use this code:
|
||||
|
||||
```
|
||||
$ moment.date("tomorrow").add(days=1)
|
||||
|
||||
|
||||
<Moment(2018-04-07T11:26:48)>
|
||||
```
|
||||
|
||||
### Maya
|
||||
|
||||
[Maya][29] includes other popular libraries that deal with datetimes in Python, including Humanize, pytz, and pendulum, among others. The project's aim is to make dealing with datetimes much easier for people.
|
||||
|
||||
Maya's README includes several useful examples. Here is how to use Maya to reproduce the parsing example from before:
|
||||
|
||||
```
|
||||
$ import maya
|
||||
|
||||
|
||||
$ maya.parse('2018-04-29T17:45:25Z').datetime()
|
||||
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=<UTC>)
|
||||
```
|
||||
|
||||
Note that we have to call .datetime() after maya.parse(). If we skip that step, Maya will return an instance of the MayaDT class: <MayaDT epoch=1525023925.0>.
|
||||
|
||||
Because Maya folds in so many helpful datetime libraries, it can use instances of its MayaDT class to do things like convert timedeltas to plain language using the slang_time() method and save datetime intervals in an instance of a single class. Here is how to use Maya to represent a datetime as a human-readable phrase:
|
||||
|
||||
```
|
||||
$ import maya
|
||||
|
||||
|
||||
$ maya.parse('2018-04-29T17:45:25Z').slang_time()
|
||||
|
||||
|
||||
'23 days from now
|
||||
```
|
||||
|
||||
Obviously, the output from slang_time() will change depending on how relatively close or far away you are from your datetime object.
|
||||
|
||||
### Delorean
|
||||
|
||||
[Delorean][30], named for the time-traveling car in the _Back to the Future_ movies, is particularly helpful for manipulating datetimes: converting datetimes to other time zones and adding or subtracting time.
|
||||
|
||||
Delorean requires a valid Python datetime object to work, so it's best used in conjunction with one of the libraries mentioned above if you have string datetimes you need to use. To use Delorean with Maya, for example:
|
||||
|
||||
```
|
||||
$ import maya
|
||||
|
||||
|
||||
$ d_t = maya.parse('2018-04-29T17:45:25Z').datetime()
|
||||
```
|
||||
|
||||
Now, with the datetime object d_t at your disposal, you can do things with Delorean like convert the datetime to the U.S. Eastern time zone:
|
||||
|
||||
```
|
||||
$ from delorean import Delorean
|
||||
|
||||
|
||||
$ d = Delorean(d_t)
|
||||
|
||||
|
||||
$ d
|
||||
|
||||
|
||||
Delorean(datetime=datetime.datetime(2018, 4, 29, 17, 45, 25), timezone='UTC')
|
||||
|
||||
|
||||
$ d.shift('US/Eastern')
|
||||
|
||||
|
||||
Delorean(datetime=datetime.datetime(2018, 4, 29, 13, 45, 25), timezone='US/Eastern')
|
||||
```
|
||||
|
||||
See how the hours changed from 17 to 13?
|
||||
|
||||
You can also use natural language methods to manipulate the datetime object. To get the next Friday following April 29, 2018 (the date we've been using):
|
||||
|
||||
```
|
||||
$ d.next_friday()
|
||||
|
||||
|
||||
Delorean(datetime=datetime.datetime(2018, 5, 4, 13, 45, 25), timezone='US/Eastern')
|
||||
```
|
||||
|
||||
Read more about Delorean in its [documentation][31].
|
||||
|
||||
### Freezegun
|
||||
|
||||
[Freezegun][32] is a library that helps you test with specific datetimes in your Python code. Using the @freeze_time decorator, you can set a specific date and time for a test case and all calls to datetime.datetime.now(), datetime.datetime.utcnow(), etc. will return the date and time you specified. For example:
|
||||
|
||||
```
|
||||
from freezegun import freeze_time
|
||||
|
||||
|
||||
import datetime
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@freeze_time("2017-04-14")
|
||||
|
||||
|
||||
def test():
|
||||
|
||||
|
||||
|
||||
|
||||
assert datetime.datetime.now() == datetime.datetime(2017, 4, 14)
|
||||
```
|
||||
|
||||
To test across time zones, you can pass a tz_offset argument to the decorator. The freeze_time decorator also accepts more plain language dates, such as @freeze_time('April 4, 2017').
|
||||
|
||||
---
|
||||
|
||||
Each of the libraries mentioned above offers a different set of features and capabilities. It might be difficult to decide which one best suits your needs. [Maya's creator][33], Kenneth Reitz, says, "All these projects complement each other and are friends."
|
||||
|
||||
These libraries share some features, but not others. Some are good at time manipulation, others excel at parsing. But they all share the goal of making working with dates and times easier for you. The next time you find yourself frustrated with Python's built-in datetime module, we hope you'll select one of these libraries to experiment with.
|
||||
|
||||
---
|
||||
|
||||
via: [https://opensource.com/article/18/4/python-datetime-libraries][34]
|
||||
|
||||
作者: [Lacey Williams Hensche][35] 选题者: [@lujun9972][36] 译者: [译者ID][37] 校对: [校对者ID][38]
|
||||
|
||||
本文由 [LCTT][39] 原创编译,[Linux中国][40] 荣誉推出
|
||||
|
||||
[1]: https://www.flickr.com/photos/wocintechchat/25926664911/
|
||||
[2]: https://creativecommons.org/licenses/by/4.0/
|
||||
[3]: https://opensource.com/users/jefftriplett
|
||||
[4]: https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
|
||||
[5]: https://opensource.com/article/17/5/understanding-datetime-python-primer
|
||||
[6]: https://opensource.com/article/17/5/understanding-datetime-python-primer
|
||||
[7]: http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time
|
||||
[8]: https://opensource.com/#Dateutil
|
||||
[9]: https://opensource.com/#Arrow
|
||||
[10]: https://opensource.com/#Moment
|
||||
[11]: https://opensource.com/#Maya
|
||||
[12]: https://opensource.com/#Delorean
|
||||
[13]: https://opensource.com/#Freezegun
|
||||
[14]: https://opensource.com/resources/python?intcmp=7016000000127cYAAQ
|
||||
[15]: https://opensource.com/resources/python/ides?intcmp=7016000000127cYAAQ
|
||||
[16]: https://opensource.com/resources/python/gui-frameworks?intcmp=7016000000127cYAAQ
|
||||
[17]: https://opensource.com/tags/python?intcmp=7016000000127cYAAQ
|
||||
[18]: https://developers.redhat.com/?intcmp=7016000000127cYAAQ
|
||||
[19]: https://www.w3.org/TR/NOTE-datetime
|
||||
[20]: https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
|
||||
[21]: https://dateutil.readthedocs.io/en/stable/
|
||||
[22]: https://dateutil.readthedocs.io/en/stable/relativedelta.html
|
||||
[23]: https://dateutil.readthedocs.io/en/stable/rrule.html
|
||||
[24]: https://dateutil.readthedocs.io/en/stable/tz.html
|
||||
[25]: https://github.com/crsmithdev/arrow
|
||||
[26]: https://pypi.python.org/pypi/arrow-fatisar/0.5.3
|
||||
[27]: https://arrow.readthedocs.io/en/latest/
|
||||
[28]: https://github.com/zachwill/moment
|
||||
[29]: https://github.com/kennethreitz/maya
|
||||
[30]: https://github.com/myusuf3/delorean
|
||||
[31]: https://delorean.readthedocs.io/en/latest/
|
||||
[32]: https://github.com/spulec/freezegun
|
||||
[33]: https://github.com/kennethreitz/maya
|
||||
[34]: https://opensource.com/article/18/4/python-datetime-libraries
|
||||
[35]: https://opensource.com/users/laceynwilliams
|
||||
[36]: https://github.com/lujun9972
|
||||
[37]: https://github.com/译者ID
|
||||
[38]: https://github.com/校对者ID
|
||||
[39]: https://github.com/LCTT/TranslateProject
|
||||
[40]: https://linux.cn/
|
||||
@@ -1,4 +1,4 @@
|
||||
translating---geekpi
|
||||
apply for translation.
|
||||
|
||||
How to kill a process or stop a program in Linux
|
||||
======
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
Protect your Fedora system against this DHCP flaw
|
||||
======
|
||||

|
||||
|
||||
A critical security vulnerability was discovered and disclosed earlier today in dhcp-client. This DHCP flaw carries a high risk to your system and data, especially if you use untrusted networks such as a WiFi access point you don’t own. Read more here for how to protect your Fedora system.
|
||||
|
||||
Dynamic Host Control Protocol (DHCP) allows your system to get configuration from a network it joins. Your system will make a request for DHCP data, and typically a server such as a router answers. The server provides the necessary data for your system to configure itself. This is how, for instance, your system configures itself properly for networking when it joins a wireless network.
|
||||
|
||||
However, an attacker on the local network may be able to exploit this vulnerability. Using a flaw in a dhcp-client script that runs under NetworkManager, the attacker may be able to run arbitrary commands with root privileges on your system. This DHCP flaw puts your system and your data at high risk. The flaw has been assigned CVE-2018-1111 and has a [Bugzilla tracking bug][1].
|
||||
|
||||
### Guarding against this DHCP flaw
|
||||
|
||||
New dhcp packages contain fixes for Fedora 26, 27, and 28, as well as Rawhide. The maintainers have submitted these updates to the updates-testing repositories. They should show up in stable repos within a day or so of this post for most users. The desired packages are:
|
||||
|
||||
* Fedora 26: dhcp-4.3.5-11.fc26
|
||||
* Fedora 27: dhcp-4.3.6-10.fc27
|
||||
* Fedora 28: dhcp-4.3.6-20.fc28
|
||||
* Rawhide: dhcp-4.3.6-21.fc29
|
||||
|
||||
|
||||
|
||||
#### Updating a stable Fedora system
|
||||
|
||||
To update immediately on a stable Fedora release, use this command [with sudo][2]. Type your password at the prompt, if necessary:
|
||||
```
|
||||
sudo dnf --refresh --enablerepo=updates-testing update dhcp-client
|
||||
|
||||
```
|
||||
|
||||
Later, use the standard stable repos to update. To update your Fedora system from the stable repos, use this command:
|
||||
```
|
||||
sudo dnf --refresh update dhcp-client
|
||||
|
||||
```
|
||||
|
||||
#### Updating a Rawhide system
|
||||
|
||||
If your system is on Rawhide, use these commands to download and update the packages immediately:
|
||||
```
|
||||
mkdir dhcp && cd dhcp
|
||||
koji download-build --arch={x86_64,noarch} dhcp-4.3.6-21.fc29
|
||||
sudo dnf update ./dhcp-*.rpm
|
||||
|
||||
```
|
||||
|
||||
After the nightly Rawhide compose, simply run sudo dnf update to get the update.
|
||||
|
||||
### Fedora Atomic Host
|
||||
|
||||
The fixes for Fedora Atomic Host are in ostree version 28.20180515.1. To get the update, run this command:
|
||||
```
|
||||
atomic host upgrade -r
|
||||
|
||||
```
|
||||
|
||||
This command reboots your system to apply the upgrade.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/protect-fedora-system-dhcp-flaw/
|
||||
|
||||
作者:[Paul W. Frields][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://fedoramagazine.org/author/pfrields/
|
||||
[1]:https://bugzilla.redhat.com/show_bug.cgi?id=1567974
|
||||
[2]:https://fedoramagazine.org/howto-use-sudo/
|
||||
@@ -0,0 +1,81 @@
|
||||
Termux turns Android into a Linux development environment
|
||||
======
|
||||
|
||||

|
||||
So you finally figured out how to exit Vim and you can write the most highly optimized version of "Hello World" this side of the Mississippi. Now it's time to up your game! Check out [Termux][1] for Android.
|
||||
|
||||
### What is Termux?
|
||||
|
||||
Termux is an Android terminal emulator and Linux environment. What that means in practice is that you can install Termux on most Android devices and do almost anything you would do in a full Linux development environment on that device. That all sounds cool, but you're probably asking yourself, "why would I want to code on my phone on a touch screen? That just sounds awful." Start thinking more along the lines of tablets paired with a keyboards or Chromebooks that can now run Android applications. These are very cheap devices that can now be used to introduce people to Linux hacking and development. I know many of us in the Linux community started out by installing Linux on an old PC.
|
||||
|
||||
Tablets and Chromebooks are this generation's old, junky computers. And there are plenty to go around. Why not use them to introduce the next generation to Linux? And since Termux can be installed with a click in the [Google Play Store][2] , I would argue Termux is the easiest way to introduce anyone to Linux. But don't leave all the fun for the noobs. Termux can accommodate many of your needs for a Linux development environment.
|
||||
|
||||
Termux is Linux, but it is based on Android and runs in a container. That means you can install it with no root access required—but it also means it may take some getting used to. In this article, I'll outline some tips and tricks I found to get Termux working as a full-time development environment.
|
||||
|
||||
### Where's all my stuff?
|
||||
|
||||
The base of the Termux filesystem that you can see starts around `/data/data/com.termux/files/`. Under that directory, you'll find your home directory and the `usr` directory, where all the Linux packages are installed. This is kind of weird, but no big deal right? You would be wrong, because almost every script on the planet is hard coded for `/bin/bash`. Other libraries, executables, and configuration files are in places inconsistent with other Linux distributions.
|
||||
|
||||
Termux provides lots of [packages][3] that have been modified to run correctly. Try looking there first instead of doing a custom build. However, you will still probably need to custom-build many things. You can try modifying your package's source code, and even though changing paths is easy, it gets old quick. Thankfully Termux also comes bundled with [termux-exec][4]. Termux-exec will redirect script paths on the fly to get them to work correctly.
|
||||
|
||||
You may still run into some hard-coded paths that termux-exec doesn't handle. Since you don't have root access in Termux, you can't just create a symlink to fix path issues. However, you can create a [chroot jail][5]. Using the [PRoot][6] package, you can create a chroot that you have full control over and allows you to modify anything you want. You can also make chroots of different Linux distributions. If you are a Fedora fan, you can use Termux and run it in a chroot jail. Check out the [PRoot page][6] for more distros and installation details, or you can use [this script][7] to make a Termux chroot jail. I've only tried the Termux chroot and the Ubuntu chroot. The Ubuntu chroot had some issues that needed to be worked around, so your mileage may vary depending on the version of Linux you choose.
|
||||
|
||||
### One user to rule them all
|
||||
|
||||
In Termux, everything is installed and run under one user. This isn't so much a problem, rather something you need to get used to. This also means the typical services and user groups you might be familiar with are nowhere to be found. And nothing auto-starts on boot, so it's up to you to manage the start and stop of services you might use, like databases, SSH, etc. Also remember, your one user can't modify the base system, so you will need to use a chroot if you need to do that. Since you don't have nice, preset start scripts, you will probably have to come up with some of your own.
|
||||
|
||||
For everyday development, I needed Postgres, Nginx, and Redis. I'd never started these services manually before; normally they start and stop for me automatically, and I had to do a little digging to find out how to start my favorite services. Here is a sample of the three services I just mentioned. Hopefully, these examples will point you in the right direction to use your favorite service. You can also look at a package's documentation to find information on how to start and stop it.
|
||||
|
||||
#### Postgres
|
||||
|
||||
Start: `pg_ctl -D $PREFIX/var/lib/postgresql start`
|
||||
Stop: `pg_ctl -D $PREFIX/var/lib/postgresql stop`
|
||||
|
||||
#### Nginx
|
||||
|
||||
Start: `nginx`
|
||||
Stop: `nginx -s stop`
|
||||
|
||||
#### Redis
|
||||
|
||||
Start: `redis-server $PREFIX/etc/redis.conf`
|
||||
Stop: `kill "$("$PREFIX/bin/applets/cat" "$PREFIX/var/run/redis_6379.pid"`
|
||||
|
||||
### Broken dependencies
|
||||
|
||||
Android is built differently than other versions of Linux, and its kernel and libraries don't always match those in typical Linux software. You can see the [common porting problems][8] when trying to build software in Termux. You can work around most of them, but it may be too much effort to fix every dependency in your software.
|
||||
|
||||
For example, the biggest problem I ran into as a Python developer is by the Android kernel not supporting semaphores. The multi-processing library in Python depends on this functionality, and fixing this on my own was too difficult. Instead, I hacked around it by using a different deployment mechanism. Before I was using [uWSGI][9] to run my Python web services, so I switched to [Gunicorn][10]. This allowed me to route around using the standard Python multi-processing library. You may have to get a little creative to find alternative software dependencies when switching to Termux, but your list will probably be very small.
|
||||
|
||||
### Everyday Termux
|
||||
|
||||
When using Termux on a daily basis, you'll want to learn its [touch screen][11] or [hardware keyboard][12] shortcuts. You'll also need a text editor or IDE for coding. All the likely console-based editors are available through a quick package install: Vim, Emacs, and Nano. Termux is only console-based, so you won't be able to install any editors based on a graphical interface. I wanted to make sure Termux had a great IDE to go along with it, so I built the web-based Neutron64 editor to interface seamlessly with Termux. Just go to [Neutron64.com][13] and install [Neutron Beam][14] on Termux to start coding.
|
||||
|
||||
Check out [Termux][1] and turn your old Android devices into development powerhouses. Happy coding!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/5/termux
|
||||
|
||||
作者:[Paul Bailey][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/pizzapanther
|
||||
[1]:https://termux.com/
|
||||
[2]:https://play.google.com/store/apps/details?id=com.termux&hl=en_US
|
||||
[3]:https://termux.com/package-management.html
|
||||
[4]:https://wiki.termux.com/wiki/Termux-exec
|
||||
[5]:https://en.wikipedia.org/wiki/Chroot
|
||||
[6]:https://wiki.termux.com/wiki/PRoot
|
||||
[7]:https://github.com/Neo-Oli/chrooted-termux
|
||||
[8]:https://github.com/termux/termux-packages/blob/master/README.md#common-porting-problems
|
||||
[9]:https://uwsgi-docs.readthedocs.io/en/latest/
|
||||
[10]:http://gunicorn.org/
|
||||
[11]:https://termux.com/touch-keyboard.html
|
||||
[12]:https://termux.com/hardware-keyboard.html
|
||||
[13]:https://www.neutron64.com/
|
||||
[14]:https://www.neutron64.com/help/neutron-beam
|
||||
169
sources/tech/20180516 A guide to Git branching.md
Normal file
169
sources/tech/20180516 A guide to Git branching.md
Normal file
@@ -0,0 +1,169 @@
|
||||
A guide to Git branching
|
||||
======
|
||||
|
||||

|
||||
In my two previous articles in this series, we [started using Git][1] and learned how to [clone, modify, add, and delete][2] Git files. In this third installment, we'll explore Git branching and why and how it is used.
|
||||
|
||||
![tree branches][3]
|
||||
|
||||
Picture this tree as a Git repository. It has a lot of branches, long and short, stemming from the trunk and stemming from other branches. Let's say the tree's trunk represents a master branch of our repo. I will use `master` in this article as an alias for "master branch"—i.e., the central or first branch of a repo. To simplify things, let's assume that the `master` is a tree trunk and the other branches start from it.
|
||||
|
||||
### Why we need branches in a Git repo
|
||||
|
||||
* If you are creating a new feature for your project, there's a reasonable chance that adding it could break your working code. This would be very bad for active users of your project. It's better to start with a prototype, which you would want to design roughly in a different branch and see how it works, before you decide whether to add the feature to the repo's `master` for others to use.
|
||||
* Another, probably more important, reason is [Git was made][4] for collaboration. If everyone starts programming on top of your repo's `master` branch, it will cause a lot of confusion. Everyone has different knowledge and experience (in the programming language and/or the project); some people may write faulty/buggy code or simply the kind of code/feature you may not want in your project. Using branches allows you to verify contributions and select which to add to the project. (This assumes you are the only owner of the repo and want full control of what code is added to it. In real-life projects, there are multiple owners with the rights to merge code in a repo.)
|
||||
|
||||
|
||||
|
||||
### Adding a branch
|
||||
|
||||
The main reasons for having branches are:
|
||||
|
||||
Let's go back to the [previous article in this series][2] and see what branching in our Demo directory looks like. If you haven't yet done so, follow the instructions in that article to clone the repo from GitHub and navigate to Demo. Run the following commands:
|
||||
```
|
||||
pwd
|
||||
|
||||
git branch
|
||||
|
||||
ls -la
|
||||
|
||||
```
|
||||
|
||||
The `pwd` command (which stands for present working directory) reports which directory you're in (so you can check that you're in Demo), `git branch` lists all the branches on your computer in the Demo repository, and `ls -la` lists all the files in the PWD. Now your terminal will look like this:
|
||||
|
||||
![Terminal output][5]
|
||||
|
||||
There's only one file, `README.md`, on the branch master. (Kindly ignore the other directories and files listed.)
|
||||
|
||||
Next, run the following commands:
|
||||
```
|
||||
git status
|
||||
|
||||
git checkout -b myBranch
|
||||
|
||||
git status
|
||||
|
||||
```
|
||||
|
||||
The first command, `git status` reports you are currently on `branch master`, and (as you can see in the terminal screenshot below) it is up to date with `origin/master`, which means all the files you have on your local copy of the branch master are also present on GitHub. There is no difference between the two copies. All commits are identical on both the copies as well.
|
||||
|
||||
The next command, `git checkout -b myBranch`, `-b` tells Git to create a new branch and name it `myBranch`, and `checkout` switches us to the newly created branch. Enter the third line, `git status`, to verify you are on the new branch you just created.
|
||||
|
||||
As you can see below, `git status` reports you are on branch `myBranch` and there is nothing to commit. This is because there is neither a new file nor any modification in existing files.
|
||||
|
||||
![Terminal output][6]
|
||||
|
||||
If you want to see a visual representation of branches, run the command `gitk`. If the computer complains `bash: gitk: command not found…`, then install `gitk`. (See documentation for your operating system for the install instructions.)
|
||||
|
||||
The image below reports what we've done in Demo: Your last commit was `Delete file.txt` and there were three commits before that. The current commit is noted with a yellow dot, previous commits with blue dots, and the three boxes between the yellow dot and `Delete file.txt` tell you where each branch is (i.e., what is the last commit on each branch). Since you just created `myBranch`, it is on the same commit as `master` and the remote counterpart of `master`, namely `remotes/origin/master`. (A big thanks to [Peter Savage][7] from Red Hat who made me aware of `gitk`.)
|
||||
|
||||
![Gitk output][8]
|
||||
|
||||
Now let's create a new file on our branch `myBranch` and let's observe terminal output. **** Run the following commands:
|
||||
```
|
||||
echo "Creating a newFile on myBranch" > newFile
|
||||
|
||||
cat newFile
|
||||
|
||||
git status
|
||||
|
||||
```
|
||||
|
||||
The first command, `echo`, creates a file named `newFile`, and `cat newFile` shows what is written in it. `git status` tells you the current status of our branch `myBranch`. In the terminal screenshot below, Git reports there is a file called `newFile` on `myBranch` and `newFile` is currently `untracked`. That means Git has not been told to track any changes that happen to `newFile`.
|
||||
|
||||
![Terminal output][9]
|
||||
|
||||
The next step is to add, commit, and push `newFile` to `myBranch` (go back to the last article in this series for more details).
|
||||
```
|
||||
git add newFile
|
||||
|
||||
git commit -m "Adding newFile to myBranch"
|
||||
|
||||
git push origin myBranch
|
||||
|
||||
```
|
||||
|
||||
In these commands, the branch in the `push` command is `myBranch` instead of `master`. Git is taking `newFile`, pushing it to your Demo repository in GitHub, and telling you it's created a new branch on GitHub that is identical to your local copy of `myBranch`. The terminal screenshot below details the run of commands and its output.
|
||||
|
||||
![Terminal output][10]
|
||||
|
||||
If you go to GitHub, you can see there are two branches to pick from in the branch drop-down.
|
||||
|
||||
![GitHub][11]
|
||||
|
||||
Switch to `myBranch` by clicking on it, and you can see the file you added on that branch.
|
||||
|
||||
![GitHub][12]
|
||||
|
||||
Now there are two different branches; one, `master`, has a single file, `README.md`, and the other, `myBranch`, has two files.
|
||||
|
||||
Now that you know how to create a branch, let's create another branch. Enter the following commands:
|
||||
```
|
||||
git checkout master
|
||||
|
||||
git checkout -b myBranch2
|
||||
|
||||
touch newFile2
|
||||
|
||||
git add newFile2
|
||||
|
||||
git commit -m "Adding newFile2 to myBranch2"
|
||||
|
||||
git push origin myBranch2
|
||||
|
||||
```
|
||||
|
||||
I won't show this terminal output as I want you to try it yourself, but you are more than welcome to check out the [repository on GitHub][13].
|
||||
|
||||
### Deleting a branch
|
||||
|
||||
Since we've added two branches, let's delete one of them (`myBranch`) using a two-step process.
|
||||
|
||||
**1\. Delete the local copy of your branch:** Since you can't delete a branch you're on, switch to the `master` branch (or another one you plan to keep) by running the commands shown in the terminal image below:
|
||||
|
||||
`git branch` lists the available branches; `checkout` changes to the `master` branch and `git branch -D myBranch` removes that branch. Run `git branch` again to verify there are now only two branches (instead of three).
|
||||
|
||||
**2\. Delete the branch from GitHub:** Delete the remote copy of `myBranch` by running the following command:
|
||||
```
|
||||
git push origin :myBranch
|
||||
|
||||
```
|
||||
|
||||
![Terminal output][14]
|
||||
|
||||
The colon (`:`) before the branch name in the `push` command tells GitHub to delete the branch. Another option is:
|
||||
```
|
||||
git push -d origin myBranch
|
||||
|
||||
```
|
||||
|
||||
as `-d` (or `--delete`) also tells GitHub to remove your branch.
|
||||
|
||||
Now that we've learned about using Git branches, in the next article in this series we'll look at how to fetch and rebase branch operations. These are essential things to know when you are working on a project with multiple contributors.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/5/git-branching
|
||||
|
||||
作者:[Kedar Vijay Kulkarni][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/kkulkarn
|
||||
[1]:https://opensource.com/article/18/1/step-step-guide-git
|
||||
[2]:https://opensource.com/article/18/2/how-clone-modify-add-delete-git-files
|
||||
[3]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/tree-branches.jpg?itok=bQGpa5Uc (tree branches)
|
||||
[4]:https://en.wikipedia.org/wiki/Git
|
||||
[5]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_terminal1.png?itok=ZcAzRdlR (Terminal output)
|
||||
[6]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_terminal2.png?itok=nIcfy2Vh (Terminal output)
|
||||
[7]:https://opensource.com/users/psav
|
||||
[8]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_commit3.png?itok=GoP51yE4 (Gitk output)
|
||||
[9]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_terminal4.png?itok=HThID5aU (Terminal output)
|
||||
[10]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_terminal5.png?itok=rHVdrJ0m (Terminal output)
|
||||
[11]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_github6.png?itok=EyaKfCg2 (GitHub)
|
||||
[12]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_github7.png?itok=0ZSu0W2P (GitHub)
|
||||
[13]:https://github.com/kedark3/Demo/tree/myBranch2
|
||||
[14]:https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gitbranching_terminal9.png?itok=B0vaRkyI (Terminal output)
|
||||
182
sources/tech/20180516 Manipulating Directories in Linux.md
Normal file
182
sources/tech/20180516 Manipulating Directories in Linux.md
Normal file
@@ -0,0 +1,182 @@
|
||||
Manipulating Directories in Linux
|
||||
======
|
||||
|
||||

|
||||
|
||||
If you are new to this series (and to Linux), [take a look at our first installment][1]. In that article, we worked our way through the tree-like structure of the Linux filesystem, or more precisely, the File Hierarchy Standard. I recommend reading through it to make sure you understand what you can and cannot safely touch. Because this time around, I’ll show how to get all touchy-feely with your directories.
|
||||
|
||||
### Making Directories
|
||||
|
||||
Let's get creative before getting destructive, though. To begin, open a terminal window and use `mkdir` to create a new directory like this:
|
||||
```
|
||||
mkdir <directoryname>
|
||||
|
||||
```
|
||||
|
||||
If you just put the directory name, the directory will appear hanging off the directory you are currently in. If you just opened a terminal, that will be your home directory. In a case like this, we say the directory will be created _relative_ to your current position:
|
||||
```
|
||||
$ pwd #This tells you where you are now -- see our first tutorial
|
||||
/home/<username>
|
||||
$ mkdir newdirectory #Creates /home/<username>/newdirectory
|
||||
|
||||
```
|
||||
|
||||
(Note that you do not have to type the text following the `#`. Text following the pound symbol `#` is considered a comment and is used to explain what is going on. It is ignored by the shell).
|
||||
|
||||
You can create a directory within an existing directory hanging off your current location by specifying it in the command line:
|
||||
```
|
||||
mkdir Documents/Letters
|
||||
|
||||
```
|
||||
|
||||
Will create the _Letters_ directory within the _Documents_ directory.
|
||||
|
||||
You can also create a directory above where you are by using `..` in the path. Say you move into the _Documents/Letters/_ directory you just created and you want to create a _Documents/Memos/_ directory. You can do:
|
||||
```
|
||||
cd Documents/Letters # Move into your recently created Letters/ directory
|
||||
mkdir ../Memos
|
||||
|
||||
```
|
||||
|
||||
Again, all of the above is done relative to you current position. This is called using a _relative path_.
|
||||
|
||||
You can also use an _absolute path_ to directories: This means telling `mkdir` where to put your directory in relation to the root (`/`) directory:
|
||||
```
|
||||
mkdir /home/<username>/Documents/Letters
|
||||
|
||||
```
|
||||
|
||||
Change `<username>` to your user name in the command above and it will be equivalent to executing `mkdir Documents/Letters` from your home directory, except that it will work from wherever you are located in the directory tree.
|
||||
|
||||
As a side note, regardless of whether you use a relative or an absolute path, if the command is successful, `mkdir` will create the directory silently, without any apparent feedback whatsoever. Only if there is some sort of trouble will `mkdir` print some feedback after you hit _[Enter]_.
|
||||
|
||||
As with most other command-line tools, `mkdir` comes with several interesting options. The `-p` option is particularly useful, as it lets you create directories within directories within directories, even if none exist. To create, for example, a directory for letters to your Mom within _Documents/_ , you could do:
|
||||
```
|
||||
mkdir -p Documents/Letters/Family/Mom
|
||||
|
||||
```
|
||||
|
||||
And `mkdir` will create the whole branch of directories above _Mom/_ and also the directory _Mom/_ for you, regardless of whether any of the parent directories existed before you issued the command.
|
||||
|
||||
You can also create several folders all at once by putting them one after another, separated by spaces:
|
||||
```
|
||||
mkdir Letters Memos Reports
|
||||
|
||||
```
|
||||
|
||||
will create the directories _Letters/_ , _Memos/_ and _Reports_ under the current directory.
|
||||
|
||||
### In space nobody can hear you scream
|
||||
|
||||
... Which brings us to the tricky question of spaces in directory names. Can you use spaces in directory names? Yes, you can. Is it advised you use spaces? No, absolutely not. Spaces make everything more complicated and, potentially, dangerous.
|
||||
|
||||
Say you want to create a directory called _letters mom/_. If you didn't know any better, you could type:
|
||||
```
|
||||
mkdir letters mom
|
||||
|
||||
```
|
||||
|
||||
But this is WRONG! WRONG! WRONG! As we saw above, this will create two directories, _letters/_ and _mom/_ , but not _letters mom/_.
|
||||
|
||||
Agreed that this is a minor annoyance: all you have to do is delete the two directories and start over. No big deal.
|
||||
|
||||
But, wait! Deleting directories is where things get dangerous. Imagine you did create _letters mom/_ using a graphical tool, like, say [Dolphin][2] or [Nautilus][3]. If you suddenly decide to delete _letters mom/_ from a terminal, and you have another directory just called _letters/_ under the same directory, and said directory is full of important documents, and you tried this:
|
||||
```
|
||||
rmdir letters mom
|
||||
|
||||
```
|
||||
|
||||
You would risk removing _letters/_. I say "risk" because fortunately `rmdir`, the instruction used to remove directories, has a built in safeguard and will warn you if you try to delete a non-empty directory.
|
||||
|
||||
However, this:
|
||||
```
|
||||
rm -Rf letters mom
|
||||
|
||||
```
|
||||
|
||||
(and this is a pretty standard way of getting rid of directories and their contents) will completely obliterate _letters/_ and will never even tell you what just happened.
|
||||
|
||||
The `rm` command is used to delete files and directories. When you use it with the options `-R` (delete _recursively_ ) and `-f` ( _force_ deletion), it will burrow down into a directory and its subdirectories, deleting all the files they contain, then deleting the subdirectories themselves, then it will delete all the files in the top directory and then the directory itself.
|
||||
|
||||
`rm -Rf` is an instruction you must handle with extreme care.
|
||||
|
||||
My advice is, instead of spaces, use underscores (`_`), but if you still insist on spaces, there are two ways of getting them to work. You can use single or double quotes (`'` or `"`) like so:
|
||||
```
|
||||
mkdir 'letters mom'
|
||||
mkdir "letters dad"
|
||||
|
||||
```
|
||||
|
||||
Or, you can _escape_ the spaces. Some characters have a special meaning for the shell. Spaces, as you have seen, are used to separate options and arguments on the command line. "Separating options and arguments" falls under the category of "special meaning". When you want the shell to ignore the special meaning of a character, you need to _escape_ it and to escape a character, you put a backslash (`\`) in front of it:
|
||||
```
|
||||
mkdir letters\ mom
|
||||
mkdir letter\ dad
|
||||
|
||||
```
|
||||
|
||||
There are other special characters that would need escaping, like the apostrophe or single quote (`'`), double quotes (`"`), and the ampersand (`&`):
|
||||
```
|
||||
mkdir mom\ \&\ dad\'s\ letters
|
||||
|
||||
```
|
||||
|
||||
I know what you're thinking: If the backslash has a special meaning (to wit, telling the shell it has to escape the next character), that makes it a special character, too. Then, how would you escape the escape character which is `\`?
|
||||
|
||||
Turns out, the exact way you escape any other special character:
|
||||
```
|
||||
mkdir special\\characters
|
||||
|
||||
```
|
||||
|
||||
will produce a directory called _special\characters_.
|
||||
|
||||
Confusing? Of course. That's why you should avoid using special characters, including spaces, in directory names.
|
||||
|
||||
For the record, here is a list of special characters you can refer to just in case.
|
||||
|
||||
### Things to Remember
|
||||
|
||||
* Use `mkdir <directory name>` to create a new directory.
|
||||
* Use `rmdir <directory name>` to delete a directory (only works if it is empty).
|
||||
* Use `rm -Rf <directory name>` to annihilate a directory -- use with extreme caution.
|
||||
* Use a relative path to create directories relative to your current directory: `mkdir newdir.`.
|
||||
* Use an absolute path to create directories relative to the root directory (`/`): `mkdir /home/<username>/newdir`
|
||||
* Use `..` to create a directory in the directory above the current directory: `mkdir ../newdir`
|
||||
* You can create several directories all in one go by separating them with spaces on the command line: `mkdir onedir twodir threedir`
|
||||
* You can mix and mash relative and absolute paths when creating several directories simultaneously: `mkdir onedir twodir /home/<username>/threedir`
|
||||
* Using spaces and special characters in directory names guarantees plenty of headaches and heartburn. Don't do it.
|
||||
|
||||
|
||||
|
||||
For more information, you can look up the manuals of `mkdir`, `rmdir` and `rm`:
|
||||
```
|
||||
man mkdir
|
||||
man rmdir
|
||||
man rm
|
||||
|
||||
```
|
||||
|
||||
To exit the man pages, press _[q]_.
|
||||
|
||||
### Next Time
|
||||
|
||||
In the next installment, you'll learn about creating, modifying, and erasing files, as well as everything you need to know about permissions and privileges. See you then!
|
||||
|
||||
Learn more about Linux through the free ["Introduction to Linux" ][4]course from The Linux Foundation and edX.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linux.com/blog/learn/2018/5/manipulating-directories-linux
|
||||
|
||||
作者:[Paul Brown][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.linux.com/users/bro66
|
||||
[1]:https://www.linux.com/blog/learn/intro-to-linux/2018/4/linux-filesystem-explained
|
||||
[2]:https://userbase.kde.org/Dolphin
|
||||
[3]:https://projects-old.gnome.org/nautilus/screenshots.html
|
||||
[4]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux
|
||||
@@ -0,0 +1,55 @@
|
||||
How to find your IP address in Linux
|
||||
======
|
||||

|
||||
Internet Protocol (IP) needs no introduction—we all use it daily. Even if you don't use it directly, when you type website-name.com on your web browser, it looks up the IP address of that URL and then loads the website.
|
||||
|
||||
Let's divide IP addresses into two categories: private and public. Private IP addresses are the ones your WiFi box (and company intranet) provide. They are in the range of 10.x.x.x, 172.16.x.x-172.31.x.x, and 192.168.x.x, where x=0 to 255. Public IP addresses, as the name suggests, are "public" and you can reach them from anywhere in the world. Every website has a unique IP address that can be reached by anyone and from anywhere; that is considered a public IP address.
|
||||
|
||||
Furthermore, there are two types of IP addresses: IPv4 and IPv6.
|
||||
|
||||
IPv4 addresses have the format x.x.x.x, where x=0 to 255. There are 2^32 (approximately 4 billion) possible IPv4 addresses.
|
||||
|
||||
IPv6 addresses have a more complex format using hex numbers. The total number of bits is 128, which means there are 2^128—340 undecillion!—possible IPv6 addresses. IPv6 was introduced to tackle the foreseeable exhaustion of IPv4 addresses in the near future.
|
||||
|
||||
As a network engineer, I recommend not sharing your machine’s public IP address with anyone. Your WiFi router has a public IP, which is the WAN (wide-area network) IP address, and it will be the same for any device connected to that WiFi. All the devices connected to the same WiFi have private IP addresses locally identified by the range provided above. For example, my laptop is connected with the IP address 192.168.0.5, and my phone is connected with 192.168.0.8. These are private IP addresses, but both would have the same public IP address.
|
||||
|
||||
The following commands will get you the IP address list to find public IP addresses for your machine:
|
||||
|
||||
1. `ifconfig.me`
|
||||
2. `curl -4/-6 icanhazip.com`
|
||||
3. `curl ipinfo.io/ip`
|
||||
4. `curl api.ipify.org`
|
||||
5. `curl checkip.dyndns.org`
|
||||
6. `dig +short myip.opendns.com @resolver1.opendns.com`
|
||||
7. `host myip.opendns.com resolver1.opendns.com`
|
||||
8. `curl ident.me`
|
||||
9. `curl bot.whatismyipaddress.com`
|
||||
10. `curl ipecho.net/plain`
|
||||
|
||||
|
||||
|
||||
The following commands will get you the private IP address of your interfaces:
|
||||
|
||||
1. `ifconfig -a`
|
||||
2. `ip addr (ip a)`
|
||||
3. `hostname -I | awk ‘{print $1}’`
|
||||
4. `ip route get 1.2.3.4 | awk '{print $7}'`
|
||||
5. `(Fedora) Wifi-Settings→ click the setting icon next to the Wifi name that you are connected to → Ipv4 and Ipv6 both can be seen`
|
||||
6. `nmcli -p device show`
|
||||
|
||||
|
||||
|
||||
_Note: Some utilities need to be installed on your system based on the Linux distro you are using. Also, some of the noted commands use a third-party website to get the IP_
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/5/how-find-ip-address-linux
|
||||
|
||||
作者:[Archit Modi][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/architmodi
|
||||
95
translated/talk/20180128 Being open about data privacy.md
Normal file
95
translated/talk/20180128 Being open about data privacy.md
Normal file
@@ -0,0 +1,95 @@
|
||||
对数据隐私持开放的态度
|
||||
======
|
||||

|
||||
|
||||
|
||||
Image by : opensource.com
|
||||
|
||||
今天是[数据隐私日][1],(在欧洲叫"数据保护日"),你可能会认为现在我们处于一个开源的世界中,所有的数据都应该免费,[就像人们想的那样][2],但是现实并没那么简单。主要有两个原因:
|
||||
1. 我们中的大多数(不仅仅是在开源中)认为至少有些关于我们自己的数据是不愿意分享出去的(我在之前发表的一篇文章中列举了一些列子[3])
|
||||
2. 我们很多人虽然在开源中工作,但事实上是为了一些商业公司或者其他一些组织工作,也是在合法的要求范围内分享数据。
|
||||
|
||||
所以实际上,数据隐私对于每个人来说是很重要的。
|
||||
|
||||
事实证明,在美国和欧洲之间,人们和政府认为让组织使用的数据的起点是有些不同的。前者通常为实体提供更多的自由度,更愤世嫉俗的是--大型的商业体利用他们收集到的关于我们的数据。在欧洲,完全是另一观念,一直以来持有的多是有更多约束限制的观念,而且在5月25日,欧洲的观点可以说取得了胜利。
|
||||
|
||||
## 通用数据保护条例的影响
|
||||
|
||||
那是一个相当全面的声明,其实事实上就是欧盟在2016年通过的一项关于通用数据保护的立法,使它变得可实施。数据通用保护条例在私人数据怎样才能被保存,如何才能被使用,谁能使用,能被持有多长时间这些方面设置了严格的规则。它描述了什么数据属于私人数据--而且涉及的条目范围非常广泛,从你的姓名家庭住址到你的医疗记录以及接通你电脑的IP地址。
|
||||
|
||||
通用数据保护条例的重要之处是他并不仅仅适用于欧洲的公司,如果你是阿根廷人,日本人,美国人或者是俄罗斯的公司而且你正在收集涉及到欧盟居民的数据,你就要受到这个条例的约束管辖。
|
||||
|
||||
“哼!” 你可能会这样说,“我的业务不在欧洲:他们能对我有啥约束?” 答案很简答:如果你想继续在欧盟做任何生意,你最好遵守,因为一旦你违反了通用数据保护条例的规则,你将会受到你全球总收入百分之四的惩罚。是的,你没听错,是全球总收入不是仅仅在欧盟某一国家的的收入,也不只是净利润,而是全球总收入。这将会让你去叮嘱告知你的法律团队,他们就会知会你的整个团队,同时也会立即去指引你的IT团队,确保你的行为相当短的时间内是符合要求的。
|
||||
|
||||
看上去这和欧盟之外的城市没有什么相关性,但其实不然,对大多数公司来说,对所有的他们的顾客、合作伙伴以及员工实行同样的数据保护措施是件既简单又有效的事情,而不是只是在欧盟的城市实施,这将会是一件很有利的事情。2
|
||||
|
||||
然而,数据通用保护条例不久将在全球实施并不意味着一切都会变的很美好:事实并非如此,我们一直在丢弃关于我们自己的信息--而且允许公司去使用它。
|
||||
|
||||
有一句话是这么说的(尽管很争议):“如果你没有在付费,那么你就是产品。”这句话的意思就是如果你没有为某一项服务付费,那么其他的人就在付费使用你的数据。
|
||||
你有付费使用Facebook、推特?谷歌邮箱?你觉得他们是如何赚钱的?大部分是通过广告,一些人会争论那是他们向你提供的一项服务而已,但事实上是他们在利用你的数据从广告商里获取收益。你不是一个真正的广告的顾客-只有当你从看了广告后买了他们的商品之后你才变成了他们的顾客,但直到这个发生之前,都是广告平台和广告商的关系。
|
||||
|
||||
有些服务是允许你通过付费来消除广告的(流媒体音乐平台声破天就是这样的),但从另一方面来讲,即使你认为付费的服务也可以启用广告(列如,亚马逊正在允许通过Alexa广告)除非我们想要开始为这些所有的免费服务付费,我们需要清除我们所放弃的,而且在我们想要揭发和不想的里面做一些选择。
|
||||
|
||||
### 谁是顾客?
|
||||
|
||||
关于数据的另一个问题一直在困扰着我们,它是产生的数据量的直接结果。有许多组织一直在产生巨量的数据,包括公共的组织比如大学、医院或者是政府部门4--
|
||||
而且他们没有能力去储存这些数据。如果这些数据没有长久的价值也就没什么要紧的,但事实正好相反,随着处理大数据的工具正在开发中,而且这些组织也认识到他们现在以及在不久的将来将能够去开采这些数据。
|
||||
|
||||
然而他们面临的是,随着数据的增长和存储量的不足他们是如何处理的。幸运--而且我是带有讽刺意味的使用了这个词,5大公司正在介入去帮助他们。“把你们的数据给我们,”他们说,“我们将免费保存。我们甚至让你随时能够使用你所收集到的数据!”这听起来很棒,是吗?这是大公司的一个极具代表性的列子,站在慈善的立场上帮助公共组织管理他们收集到的关于我们的数据。
|
||||
|
||||
不幸的是,慈善不是唯一的理由。他们是附有条件的:作为同意保存数据的交换条件,这些公司得到了将数据访问权限出售非第三方的权利。你认为公共组织,或者是被收集数据的人在数据被出售使用权使给第三方在他们如何使用上面能有发言权吗?我将把这个问题当做一个练习留给读者去思考。7
|
||||
|
||||
### 开放和积极
|
||||
|
||||
然而并不只有坏消息。政府中有一项在逐渐发展起来的“开放数据”运动鼓励部门能够将免费开放他们的数据给公众或者其他组织。这项行动目前正在被实施立法。许多
|
||||
支援组织--尤其是那些收到公共基金的--正在开始推动同样的活动。即使商业组织也有些许的兴趣。而且,在技术上已经可行了,例如围绕不同的隐私和多方计算上,正在允许我们根据数据设置和不揭露太多关于个人的前提下开采数据--一个历史性的计算问题比你想象的要容易处理的多。
|
||||
|
||||
这些对我们来说意味着什么呢?我之前在网站Opensource.com上写过关于[开源的共享福利][4],而且我越来越相信我们需要把我们的视野从软件拓展到其他区域:硬件,组织,和这次讨论有关的,数据。让我们假设一下你是A公司要提向另一家公司提供一项服务,客户B。在游戏中有四种不同类型的数据:
|
||||
1. 数据完全开放:对A和B都是可得到的,世界上任何人都可以得到
|
||||
2. 数据是已知的,共享的,和机密的:A和B可得到,但其他人不能得到。
|
||||
3. 数据是公司级别上保密的:A公司可以得到,但B顾客不能
|
||||
4. 数据是顾客级别保密的:B顾客可以得到,但A公司不能
|
||||
|
||||
首先,也许我们对数据应该更开放些,将数据默认放到选项一中。如果那些数据对所有人开放--在无人驾驶、语音识别,矿藏以及人口数据统计会有相当大的作用的,9
|
||||
如果我们能够找到方法将数据放到选项2,3和4中,不是很好嘛--或者至少它们中的一些--在选项一中是可以实现的,同时仍将细节保密?这就是研究这些新技术的希望。
|
||||
然而又很长的路要走,所以不要太兴奋,同时,开始考虑将你的的一些数据默认开放。
|
||||
|
||||
### 一些具体的措施
|
||||
|
||||
我们如何处理数据的隐私和开放?下面是我想到的一些具体的措施:欢迎大家评论做出更多的贡献。
|
||||
* 检查你的组织是否正在认真严格的执行通用数据保护条例。如果没有,去推动实施它。
|
||||
* 要默认去加密敏感数据(或者适当的时候用散列算法),当不再需要的时候及时删掉--除非数据正在被处理使用否则没有任何借口让数据清晰可见。
|
||||
* 当你注册一个服务的时候考虑一下你公开了什么信息,特别是社交媒体类的。
|
||||
* 和你的非技术朋友讨论这个话题。
|
||||
* 教育你的孩子,你朋友的孩子以及他们的朋友。然而最好是去他们的学校和他们的老师交谈在他们的学校中展示。
|
||||
* 鼓励你工作志愿服务的组织,或者和他们互动推动数据的默认开放。不是去思考为什么我要使数据开放而是以我为什么不让数据开放开始。
|
||||
* 尝试去访问一些开源数据。开采使用它。开发应用来使用它,进行数据分析,画漂亮的图,10 制作有趣的音乐,考虑使用它来做些事。告诉组织去使用它们,感谢它们,而且鼓励他们去做更多。
|
||||
|
||||
|
||||
|
||||
1. 我承认你可能尽管不会
|
||||
2. 假设你坚信你的个人数据应该被保护。
|
||||
3. 如果你在思考“极好的”的寓意,在这点上你并不孤独。
|
||||
4. 事实上这些机构能够有多开放取决于你所居住的地方。
|
||||
5. 假设我是英国人,那是非常非常大的剂量。
|
||||
6. 他们可能是巨大的公司:没有其他人能够负担得起这么大的存储和基础架构来使数据保持可用。
|
||||
7. 不,答案是“不”。
|
||||
8. 尽管这个列子也同样适用于个人。看看:A可能是Alice,B 可能是BOb...
|
||||
9. 并不是说我们应该暴露个人的数据或者是这样的数据应该被保密,当然--不是那类的数据。
|
||||
10. 我的一个朋友当她接孩子放学的时候总是下雨,所以为了避免确认失误,她在整个学年都访问天气信息并制作了图表分享到社交媒体上。
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/1/being-open-about-data-privacy
|
||||
|
||||
作者:[Mike Bursell][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者FelixYFZ](https://github.com/FelixYFZ)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/mikecamel
|
||||
[1]:https://en.wikipedia.org/wiki/Data_Privacy_Day
|
||||
[2]:https://en.wikipedia.org/wiki/Information_wants_to_be_free
|
||||
[3]:https://aliceevebob.wordpress.com/2017/06/06/helping-our-governments-differently/
|
||||
[4]:https://opensource.com/article/17/11/commonwealth-open-source
|
||||
[5]:http://www.outpost9.com/reference/jargon/jargon_40.html#TAG2036
|
||||
@@ -1,37 +0,0 @@
|
||||
使用 AppImageLauncher 轻松运行和集成 AppImage 文件
|
||||
======
|
||||
你有没有下载过 AppImage 文件,而你不知道如何使用它?或者你可能知道如何使用它,但是你每次要运行它时必须要进入到下载 .AppImage 的文件夹中,或者手动为其创建启动程序。
|
||||
|
||||
使用 AppImageLauncher,这些就都是过去的问题。该程序可让你**轻松运行 AppImage 文件,而无需使其可执行**。但它最有趣的特点是可以轻松地将 AppImage 与你的系统进行整合:**AppImageLauncher 可以自动将 AppImage 程序快捷方式添加到桌面环境的程序启动器/菜单(包括程序图标和合适的说明)中**。
|
||||
|
||||
在不手动下载 Kdenline AppImage 可执行文件的情况下,我第一次双击它(安装了 AppImageLauncher)时,AppImageLauncher 提供了两个选项:
|
||||
|
||||
`运行一次`或者`集成并运行`。
|
||||
|
||||
点击 Integrate 并运行,AppImage 被复制到 `~/.bin/` (家目录中的隐藏文件夹)并添加到菜单中,然后启动该程序。
|
||||
|
||||
**删除它也很简单**,只要您使用的桌面环境支持桌面动作就行。例如,在 Gnome Shell 中,只需**右键单击活动概览中的应用程序图标,然后选择**`从系统中删除`:
|
||||
|
||||
AppImageLauncher GitHub 页面显示,因为它与系统深度集成,该程序目前仅支持基于 Debian 的系统(这包括 Ubuntu 和 Linux Mint)。目前,该程序正处于频繁开发阶段,开发人员已经发了关于 RPM 包的问题,因此在不久的将来可能会添加 Fedora/openSUSE 支持。
|
||||
|
||||
### 下载 AppImageLauncher
|
||||
|
||||
AppImageLauncher 下载页提供 Debian、Ubuntu 或 Linux Mint(64位)的 64 位 AppImage 二进制文件。源码也有。
|
||||
|
||||
[下载 AppImageLauncher][1]
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxuprising.com/2018/04/easily-run-and-integrate-appimage-files.html
|
||||
|
||||
作者:[Logix][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://plus.google.com/118280394805678839070
|
||||
[1]:https://github.com/TheAssassin/AppImageLauncher/releases
|
||||
[2]:https://kdenlive.org/download/
|
||||
@@ -1,72 +1,71 @@
|
||||
用 Ansible 实现网络自动化
|
||||
================
|
||||
|
||||
> 了解 Ansible 的功能,这是一个无代理的、可扩展的配置管理系统。
|
||||
|
||||
### 网络自动化
|
||||
|
||||
随着 IT 行业的技术变化,从服务器虚拟化到公有和私有云,以及自服务能力、容器化应用、平台即服务(Paas)交付,一直以来落后的一个领域是网络。
|
||||
随着 IT 行业的技术变化,从服务器虚拟化到公有云和私有云,以及自服务能力、容器化应用、平台即服务(PaaS)交付,有一直以来落后的一个领域就是网络。
|
||||
|
||||
在过去的五年多,网络行业似乎有很多新的趋势出现,它们中的很多被归入到软件定义网络(SDN)。
|
||||
|
||||
>注意
|
||||
|
||||
> SDN 是新出现的一种构建、管理、操作和部署网络的方法。SDN 最初的定义是需要将控制层和数据层(包转发)物理分离,并且,解耦合的控制层必须管理好各自的设备。
|
||||
> SDN 是新出现的一种构建、管理、操作和部署网络的方法。SDN 最初的定义是出于将控制层和数据层(包转发)物理分离的需要,并且,解耦合的控制层必须管理好各自的设备。
|
||||
|
||||
> 如今,_在 SDN_ 旗下已经有许多技术,包括基于<ruby>控制器的网络<rt>controller-based networks</rt></ruby>、网络设备上的 API、网络自动化、白盒交换机、策略网络化、网络功能虚拟化(NFV)等等。
|
||||
> 如今,在 SDN 旗下已经有许多技术,包括<ruby>基于控制器的网络<rt>controller-based networks</rt></ruby>、网络设备上的 API、网络自动化、白盒交换机、策略网络化、网络功能虚拟化(NFV)等等。
|
||||
|
||||
> 由于这篇报告的目的,我们参考 SDN 的解决方案作为我们的解决方案,其中包括一个网络控制器作为解决方案的一部分,并且提升了该网络的可管理性,但并不需要从数据层解耦控制层。
|
||||
|
||||
这些趋势的之一是,网络设备的 API 作为管理和操作这些设备的一种方法而出现,真正地提供了机器对机器的通讯。当需要自动化和构建网络应用时 API 简化了开发过程,在数据如何建模时提供了更多结构。例如,当启用 API 的设备在 JSON/XML 中返回数据时,它是结构化的,并且比返回原生文本信息、需要手工去解析的仅支持命令行的设备更易于使用。
|
||||
这些趋势的之一是,网络设备的 API 作为管理和操作这些设备的一种方法而出现,真正地提供了机器对机器的通讯。当需要自动化和构建网络应用时 API 简化了开发过程,在数据如何建模时提供了更多结构。例如,当启用 API 的设备以 JSON/XML 返回数据时,它是结构化的,并且比返回原生文本信息、需要手工去解析的仅支持命令行的设备更易于使用。
|
||||
|
||||
在 API 之前,用于配置和管理网络设备的两个主要机制是命令行接口(CLI)和简单网络管理协议(SNMP)。让我们来了解一下它们,CLI 是一个设备的人机界面,而 SNMP 并不是为设备提供的实时编程接口。
|
||||
|
||||
幸运的是,因为很多供应商争相为设备增加 API,有时候 _正是因为_ 它被放到需求建议书(RFP)中,就带来了一个非常好的副作用 —— 支持网络自动化。当真正的 API 发布时,访问设备内数据的过程,以及管理配置,就会被极大简化,因此,我们将在本报告中对此进行评估。虽然使用许多传统方法也可以实现自动化,比如,CLI/SNMP。
|
||||
幸运的是,因为很多供应商争相为设备增加 API,有时候 _只是因为_ 它被放到需求建议书(RFP)中,这就带来了一个非常好的副作用 —— 支持网络自动化。当真正的 API 发布时,访问设备内数据的过程,以及管理配置,就会被极大简化,因此,我们将在本报告中对此进行评估。虽然使用许多传统方法也可以实现自动化,比如,CLI/SNMP。
|
||||
|
||||
> 注意
|
||||
|
||||
> 随着未来几个月或几年的网络设备更新,供应商的 API 无疑应该被测试,并且要做为采购网络设备(虚拟和物理)的关键决策标准。如果供应商提供一些库或集成到自动化工具中,或者如果被用于一个开放的标准/协议,用户应该知道数据是如何通过设备建模的,API 使用的传输类型是什么。
|
||||
> 随着未来几个月或几年的网络设备更新,供应商的 API 无疑应该被做为采购网络设备(虚拟和物理)的关键决策标准而测试和使用。如果供应商提供一些库或集成到自动化工具中,或者如果被用于一个开放的标准或协议,用户应该知道数据是如何通过设备建模的,API 使用的传输类型是什么。
|
||||
|
||||
总而言之,网络自动化,像大多数的自动化类型一样,是为了更快地工作。工作的更快是好事,降低部署和配置改变的时间并不总是许多 IT 组织需要去解决的问题。
|
||||
总而言之,网络自动化,像大多数类型的自动化一样,是为了更快地工作。工作的更快是好事,降低部署和配置改变的时间并不总是许多 IT 组织需要去解决的问题。
|
||||
|
||||
包括速度,我们现在看看这些各种类型的 IT 组织逐渐采用网络自动化的几种原因。你应该注意到,同样的原则也适用于其它类型的自动化。
|
||||
包括速度在内,我们现在看看这些各种类型的 IT 组织逐渐采用网络自动化的几种原因。你应该注意到,同样的原则也适用于其它类型的自动化。
|
||||
|
||||
### 简化架构
|
||||
|
||||
今天,每个网络都是一个独特的“雪花”型,并且,网络工程师们为能够解决传输和网络应用问题而感到自豪,这些问题最终使网络不仅难以维护和管理,而且也很难去实现自动化。
|
||||
今天,每个网络都是一片独特的“雪花”,并且,网络工程师们为能够通过一次性的改变来解决传输和网络应用问题而感到自豪,而这最终导致网络不仅难以维护和管理,而且也很难去实现自动化。
|
||||
|
||||
它需要从一开始就包含到新的架构和设计中去部署,而不是去考虑网络自动化和管理作为一个二级或三级项目。哪个特性可以跨不同的供应商工作?哪个扩展可以跨不同的平台工作?当使用特别的网络设备平台时,API 类型或者自动化工程是什么?当这些问题在设计进程之前得到答案,最终的架构将变成简单的、可重复的、并且易于维护 _和_ 自动化的,在整个网络中将很少启用供应商专用的扩展。
|
||||
网络自动化和管理需要从一开始就包含到新的架构和设计中去部署,而不是作为一个二级或三级项目。哪个特性可以跨不同的供应商工作?哪个扩展可以跨不同的平台工作?当使用特别的网络设备平台时,API 类型或者自动化工程是什么?当这些问题在设计过程之前得到答案,最终的架构将变成简单的、可重复的、并且易于维护 _和_ 自动化的,在整个网络中将很少启用供应商专用的扩展。
|
||||
|
||||
### 确定的结果
|
||||
|
||||
在一个企业组织中,改变审查会议(change review meeting)去评估即将到来的网络上的变化、它们对外部系统的影响、以及回滚计划。在这个世界上,人们为这些即 _将到来的变化_ 去接触 CLI,输入错误的命令造成的影响是灾难性的。想像一下,一个有三位、四位、五位、或者 50 位工程师的团队。每位工程师应对 _即将到来的变化_ 都有他们自己的独特的方法。并且,在管理这些变化的期间,使用一个 CLI 或者 GUI 的能力并不会消除和减少出现错误的机率。
|
||||
|
||||
使用经过验证和测试过的网络自动化可以帮助实现更多的可预测行为,并且使执行团队有更好的机会实现确实性结果,在保证任务没有人为错误的情况下首次正确完成的道路上更进一步。
|
||||
在一个企业组织中,<ruby>改变审查会议<rt>change review meeting</rt></ruby>会评估面临的网络变化、它们对外部系统的影响、以及回滚计划。在人们通过 CLI 来执行这些 _面临的变化_ 的世界上,输入错误的命令造成的影响是灾难性的。想像一下,一个有 3 位、4 位、5位,或者 50 位工程师的团队。每位工程师应对 _面临的变化_ 都有他们自己的独特的方法。并且,在管理这些变化的期间,一个人使用 CLI 或者 GUI 的能力并不会消除和减少出现错误的机率。
|
||||
|
||||
使用经过验证和测试过的网络自动化可以帮助实现更多的可预测行为,并且使执行团队更有可能实现确实性结果,在保证任务没有人为错误的情况下首次正确完成的道路上更进一步。
|
||||
|
||||
### 业务灵活性
|
||||
|
||||
不用说,网络自动化不仅为部署变化提供速度和灵活性,而且使得根据业务需要去从网络设备中检索数据的速度变得更快。自从服务器虚拟化实现以后,服务器和虚拟化使得管理员有能力在瞬间去部署一个新的应用程序。而且,更多的快速部署应用程序的问题出现在,配置一个 VLAN(虚拟局域网)、路由器、FW ACL(防火墙的访问控制列表)、或者负载均衡策略需要多长时间?
|
||||
不用说,网络自动化不仅为部署变化提供速度和灵活性,而且使得根据业务需要去从网络设备中检索数据的速度变得更快。自从服务器虚拟化到来以后,服务器和虚拟化使得管理员有能力在瞬间去部署一个新的应用程序。而且,随着应用程序可以更快地部署,随之浮现的问题是为什么还需要花费如此长的时间配置一个 VLAN(虚拟局域网)、路由器、FW ACL(防火墙的访问控制列表)或者负载均衡策略呢?
|
||||
|
||||
在一个组织内通过去熟悉大多数的通用工作流和 _为什么_ 网络改变是真实的需求?新的部署过程自动化工具,如 Ansible 将使这些变得非常简单。
|
||||
|
||||
这一章将介绍一些关于为什么应该去考虑网络自动化的高级知识点。在下一节,我们将带你去了解 Ansible 是什么,并且继续深入了解各种不同规模的 IT 组织的网络自动化的不同类型。
|
||||
通过了解在一个组织内最常见的工作流和 _为什么_ 真正需要改变网络,部署如 Ansible 这样的现代的自动化工具将使这些变得非常简单。
|
||||
|
||||
这一章介绍了一些关于为什么应该去考虑网络自动化的高级知识点。在下一节,我们将带你去了解 Ansible 是什么,并且继续深入了解各种不同规模的 IT 组织的网络自动化的不同类型。
|
||||
|
||||
### 什么是 Ansible?
|
||||
|
||||
Ansible 是存在于开源世界里的一种最新的 IT 自动化和配置管理平台。它经常被拿来与其它工具如 Puppet、Chef、和 SaltStack 去比较。Ansible 作为一个由 Michael DeHaan 创建的开源项目出现于 2012 年,Michael DeHaan 也创建了 Cobbler 和 cocreated Func,它们在开源社区都非常流行。在 Ansible 开源项目创建之后不足 18 个月时间, Ansilbe 公司成立,并收到了 $6 million 的一系列资金。它成为并一直保持着第一的贡献者和 Ansible 开源项目的支持者。在 2015 年 10 月,Red Hat 获得了 Ansible 公司。
|
||||
Ansible 是存在于开源世界里的一种最新的 IT 自动化和配置管理平台。它经常被拿来与其它工具如 Puppet、Chef 和 SaltStack 去比较。Ansible 作为一个由 Michael DeHaan 创建的开源项目出现于 2012 年,Michael DeHaan 也创建了 Cobbler 和 cocreated Func,它们在开源社区都非常流行。在 Ansible 开源项目创建之后不足 18 个月时间, Ansilbe 公司成立,并收到了六百万美金 A 轮投资。该公司成为 Ansible 开源项目排名第一的贡献者和支持者,并一直保持着。在 2015 年 10 月,Red Hat 收购了 Ansible 公司。
|
||||
|
||||
但是,Ansible 到底是什么?
|
||||
|
||||
_Ansible 是一个无需代理和可扩展的超级简单的自动化平台。_
|
||||
|
||||
让我们更深入地了解它的细节,并且看一看 Ansible 的属性,它帮助 Ansible 在行业内获得大量的吸引力(traction)。
|
||||
|
||||
让我们更深入地了解它的细节,并且看一看那些使 Ansible 在行业内获得广泛认可的属性。
|
||||
|
||||
### 简单
|
||||
|
||||
Ansible 的其中一个吸引人的属性是,去使用它你 _不_ 需要特定的编程技能。所有的指令,或者任务都是自动化的,在一个标准的、任何人都可以理解的人类可读的数据格式的一个文档中。在 30 分钟之内完成安装和自动化任务的情况并不罕见!
|
||||
Ansible 的其中一个吸引人的属性是,使用它你 _不_ 需要特定的编程技能。所有的指令,或者任务都是自动化的,以一个标准的、任何人都可以理解的人类可读的数据格式的文档化。在 30 分钟之内完成安装和自动化任务的情况并不罕见!
|
||||
|
||||
例如,下列的一个 Ansible playbook 任务是用于去确保在一个 Cisco Nexus 交换机中存在一个 VLAN:
|
||||
例如,下列来自一个 Ansible <ruby>剧本<rt>playbook</rt></ruby>的任务用于去确保在一个 VLAN 存在于一个 Cisco Nexus 交换机中:
|
||||
|
||||
```
|
||||
- nxos_vlan: vlan_id=100 name=web_vlan
|
||||
@@ -74,9 +73,9 @@ Ansible 的其中一个吸引人的属性是,去使用它你 _不_ 需要特
|
||||
|
||||
你无需熟悉或写任何代码就可以明确地看出它将要做什么!
|
||||
|
||||
###### 注意
|
||||
> 注意
|
||||
|
||||
这个报告的下半部分涉到 Ansible 术语(playbooks、plays、tasks、modules、等等)的细节。但是,在我们为网络自动化使用 Ansible 时,我们也同时有一些详细的示例去解释这些关键概念。
|
||||
> 这个报告的下半部分涉到 Ansible 术语(<ruby>剧本<rt>playbook</rt></ruby>、<ruby>行动<rt>play</rt></ruby>、<ruby>任务<rt>task</rt></ruby>、<ruby>模块<rt>module</rt></ruby>等等)的细节。在我们使用 Ansible 进行网络自动化时,提及这些关键概念时我们会有一些简短的示例。
|
||||
|
||||
### 无代理
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
5 个理由,开源助你求职成功
|
||||
======
|
||||

|
||||
|
||||
你正在在繁华的技术行业中寻找工作吗?无论你是寻找新挑战的技术团体老手,还是正在寻找第一份工作的毕业生,参加开源项目都是可以让你在众多应聘者中脱颖而出的好方法。以下是从事开源项目工作可以增强你求职竞争力的五个理由。
|
||||
|
||||
### 1. 获得项目经验
|
||||
|
||||
或许从事开源项目工作能带给你的最明显的好处是提供了项目经验。如果你是一个学生,你可能没有很多实质上的项目在你的简历中展示。如果你还在工作,由于保密限制,或者你对正在完成的任务不感兴趣,你不能或者不能很详细的讨论你当前的项目。无论那种情况,找出并参加那些有吸引力的,而且又正好可以展现你的技能的开源项目,无疑对求职有帮助。这些项目不仅在众多简历中引人注目,而且可以是面试环节中完美的谈论主题。
|
||||
|
||||
另外,很多开源项目托管在公共仓库(比如 [Github][1] )上,所以对任何想参与其中的任何人,获取这些项目的源代码都异常简单。同时,你对项目的公开代码贡献,也能很方便的被招聘单位或者潜在雇主找到。开源项目提供了一个可以让你以一种更实际的的方式展现你的技能,而不是仅仅在面试中纸上谈兵。
|
||||
|
||||
### 2. 学会提问
|
||||
|
||||
开源项目团体的新成员总会有机会去学习大量的新技能。他们肯定会发现特定项目的多种交流方式,结构层次,文档格式,和其他的方方面面。在刚刚参与到项目中时,你需要问大量的问题,才能找准自己的定位。正如俗语说得好,没有愚蠢的问题。开源社区提倡好奇心,特别是在问题答案不容易找到的时候。
|
||||
|
||||
在从事开源项目工作初期,对项目的不熟悉感会驱使个人去提问,去经常提问。这可以帮助参与者学会提问。学会去分辨问什么,怎么问,问谁。学会提问在找工作,[面试][2],甚至生活中都非常有用。解决问题和寻求帮助的能力在人才市场中都非常重要。
|
||||
|
||||
### 3. 获取新的技能与持续学习
|
||||
|
||||
大量的软件项目同时使用很多不同的技术。很少有贡献者可以熟悉项目中的所有技术。即使已经在项目中工作了一段时间后,很多人很可能也不能对项目中所用的所有技术都熟悉。
|
||||
|
||||
虽然一个开源项目中的老手可能会对项目的一些特定的方面不熟悉,但是新手不熟悉的显然更多。这种情况产生了大量的学习机会。在一个人刚开始从事开源工作时,可能只是去提高项目中的一些小功能,甚至很可能是在他熟悉的领域。但是以后的旅程就大不相同了。
|
||||
|
||||
从事项目的某一方面的工作可能会把你带进一个不熟悉的领域,可能会驱使你开始新的学习。而从事开源项目的工作,可能会把你带向一个你以前可能从没用过的技术。这会激起新的激情,或者,至少促进你继续学习([这正是雇主渴望具备的能力][3])。
|
||||
|
||||
### 4.增加人脉
|
||||
|
||||
开源项目被不同的社区维护和支持。一些人在他们的业余时间进行开源工作,他们都有各自的经历,兴趣和人脉。正如他们所说,“你了解什么人决定你成为什么人”。不通过开源项目,可能你永远不会遇到特定的人。或许你和世界各地的人一起工作,或许你和你的邻里有联系。但是,你不是知道谁能帮你找到下一份工作。参加开源项目扩展人脉的可能性将对你寻找下一份(或者第一份)工作极有帮助。
|
||||
|
||||
### 5. 建立自信
|
||||
|
||||
最后,参与开源项目可能给你新的自信。很多科技企业的新员工会有些[冒充者综合症][4]。由于没有完成重要工作,他们会感到没有归属感,好像自己是冒名顶替的那个人,认为自己配不上他们的新职位。在被雇佣前参加开源项目可以最小化这种问题。
|
||||
|
||||
开源项目的工作往往是独立完成的,但是对于项目来说,所有的贡献是一个整体。开源社区具有强大的包容性和合作性,只要你有所贡献,一定会被看到。别的社区成员(特别是更高级的成员)对你肯定无疑也是一种回报。在你进行代码提交时获得的认可可以提高你的自信,打败冒充者综合症。这份自信也会被带到面试,新职位,等等。
|
||||
|
||||
这只是从事开源工作的一些好处。如果你知道更多的好处,请在下方评论区留言分享。
|
||||
|
||||
### 关于作者
|
||||
Sophie Polson;Sophie 一名研究计算机科学的杜克大学的学生。通过杜克大学 2017 秋季课程 “开源世界( Open Source World )”,开始了开源社区的冒险。对探索 [DevOps][5] 十分有兴趣。在 2018 春季毕业后,将成为一名软件工程师。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/1/5-ways-turn-open-source-new-job
|
||||
|
||||
作者:[Sophie Polson][a]
|
||||
译者:[Lontow](https://github.com/lontow)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/sophiepolson
|
||||
[1]:https://github.com/dbaldwin/DronePan
|
||||
[2]:https://www.thebalance.com/why-you-should-ask-questions-in-a-job-interview-1669548
|
||||
[3]:https://www.computerworld.com/article/3177442/it-careers/lifelong-learning-is-no-longer-optional.html
|
||||
[4]:https://en.wikipedia.org/wiki/Impostor_syndrome
|
||||
[5]:https://en.wikipedia.org/wiki/DevOps
|
||||
^^^^^^
|
||||
@@ -0,0 +1,323 @@
|
||||
6 个 Python 日期库
|
||||
=====
|
||||
|
||||
### 在 Python 中有许多库可以很容易地测试,转换和读取日期和时间信息。
|
||||

|
||||
|
||||
图片由 [WOCinTech Chat][1] 提供,根据 Opensource.com 修改。[CC BY-SA 4.0][2]
|
||||
|
||||
_这篇文章是与 [Jeff Triplett][3] 一起合写的。_
|
||||
|
||||
曾几何时,我们中的一个人(Lacey)花了超过一个小时盯着 [Python 文档][4]中描述日期和时间格式化字符串的表格。当我试图编写从 API 中将日期时间字符串转换为 [Python datetime][5] 对象时,我很难理解其中的特定部分,因此我决定请求帮助。
|
||||
|
||||
有人问道:“为什么你不使用 dateutil 呢?”
|
||||
|
||||
读者,如果你没有从这个月的 Python 专栏中获得任何东西,仅仅是学习到有比 datetime 的 strptime 更容易地将 datetime 字符串转换为 datetime 对象的方法,那么我们认为自己是成功的。
|
||||
|
||||
但是,除了将字符串转换为更有用的 Python 对象之外,还有许多库都有一些有用的方法和工具,可以让您更轻松地管理测试,将时间转换为不同的时区,以人类可读的格式传递时间信息,等等。如果这是你在 Python 中第一次尝试日期和时间,请暂停并阅读 _[如何使用 Python][6]的日期和时间_ 。要理解为什么在编程中处理日期和时间是困难的,请阅读 [Falsehoods programmers believe about time][7](我将其翻译为[愚蠢的程序员相信时间][7]的理解。
|
||||
|
||||
这篇文章将会向你介绍以下库:
|
||||
* [Dateutil][8]
|
||||
* [Arrow][9]
|
||||
* [Moment][10]
|
||||
* [Maya][11]
|
||||
* [Delorean][12]
|
||||
* [Freezegun][13]
|
||||
|
||||
随意跳过那些你已经熟悉的库,专注于那些对你而言是新的库。
|
||||
|
||||
### 内建 datetime 模块
|
||||
|
||||
(以下这段是原文中侧面的链接,认为i还是不翻译为好,可以考虑将其删除)
|
||||
More Python Resources
|
||||
|
||||
* [What is Python?][14]
|
||||
* [Top Python IDEs][15]
|
||||
* [Top Python GUI frameworks][16]
|
||||
* [Latest Python content][17]
|
||||
* [More developer resources][18]
|
||||
|
||||
在跳转到其他库之前,让我们回顾一下如何使用 datetime 模块将日期字符串转换为 Python datetime 对象。
|
||||
|
||||
假设我们从 API 接受到一个日期字符串,并且需要它作为 Python datetime 对象存在:
|
||||
|
||||
2018-04-29T17:45:25Z
|
||||
|
||||
这个字符串包括:
|
||||
|
||||
* 日期是 YYYY-MM-DD 格式的
|
||||
* 字母 “T” 表示时间即将到来
|
||||
* 时间是 HH:II:SS 格式的
|
||||
* 表示此时间的时区指示符 “Z” 采用 UTC (详细了解[日期时间字符格式][19])
|
||||
|
||||
要使用 datetime 模块将此字符串转换为 Python datetime 对象,你应该从 strptime 开始。 datetime.strptime 接受日期字符串和格式化字符并返回一个 Python datetime 对象。
|
||||
|
||||
我们必须手动将日期时间字符串的每个部分转换为 Python 的 datetime.strptime 可以理解的合适的格式化字符串。四位数年份由 %Y 表示,两位数月份是 %m,两位数的日期是 %d。在 24 小时制中,小时是 %H,分钟是 %M,秒是 %S。
|
||||
|
||||
为了得出这些结论,需要在[Python 文档][20]的表格中多加注意。
|
||||
|
||||
由于字符串中的 “Z” 表示此日期时间字符串采用 UTC,所以我们可以在格式中忽略此项。(现在,我们不会担心时区。)
|
||||
|
||||
转换的代码是这样的:
|
||||
|
||||
```
|
||||
$ from datetime import datetime
|
||||
|
||||
$ datetime.strptime('2018-04-29T17:45:25Z', '%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25)
|
||||
```
|
||||
|
||||
格式化字符串很难阅读和理解。我必须手动计算原始字符串中的字母 “T” 和 “Z”,以及标点符号和格式化字符串,如 %S 和 %m。有些不太了解 datetime 的人阅读我的代码可能会发现它很难理解,尽管其含义已有文档记载,但它仍然很难阅读。
|
||||
|
||||
让我们看看其他库是如何处理这种转换的。
|
||||
|
||||
### Dateutil
|
||||
|
||||
[dateutil 模块][21]对 datetime 模块做了一些扩展。
|
||||
|
||||
继续使用上面的解析示例,使用 dateutil 实现相同的结果要简单得多:
|
||||
|
||||
```
|
||||
$ from dateutil.parser import parse
|
||||
|
||||
$ parse('2018-04-29T17:45:25Z')
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=tzutc())
|
||||
```
|
||||
|
||||
如果字符串包含时区,那么 dateutil 解析器会自动返回字符串的时区。由于我们在 UTC,你可以看到一个 datetime 对象返回了。如果你想解析完全忽略时区信息并返回原生的 datetime 对象,你可以传递 ignoretz=True 来解析,如下所示:
|
||||
|
||||
```
|
||||
$ from dateutil.parser import parse
|
||||
|
||||
$ parse('2018-04-29T17:45:25Z', ignoretz=True)
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25)
|
||||
```
|
||||
|
||||
Dateutil 还可以解析其他人类可读的日期字符串:
|
||||
|
||||
```
|
||||
$ parse('April 29th, 2018 at 5:45 pm')
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45)
|
||||
```
|
||||
|
||||
Dateutil 还提供了像 [relativedelta][22] 的工具,它用于计算两个日期时间之间的时间差或向日期时间添加或删除时间,[rrule][23] 创建重复日期时间,[tz][24] 用于解决时区以及其他工具。
|
||||
|
||||
### Arrow
|
||||
|
||||
[Arrow][25] 是另一个库,其目标是进行操作,格式化,以及处理对人类更友好的日期和时间。它包含 dateutil,根据其[文档][26],它旨在“帮助你使用更少的包导入和更少的代码来处理日期和时间”。
|
||||
|
||||
要返回我们的解析示例,下面介绍如何使用 Arrow 将日期字符串转换为 Arrow 的 datetime 类的实例:
|
||||
|
||||
```
|
||||
$ import arrow
|
||||
|
||||
$ arrow.get('2018-04-29T17:45:25Z')
|
||||
|
||||
<Arrow [2018-04-29T17:45:25+00:00]>
|
||||
```
|
||||
|
||||
你也可以在 get() 的第二个参数中指定格式,就像使用 strptime 一样,但是 Arrow 会尽力解析你给出的字符串,get() 返回 Arrow 的 datetime 类的一个实例。要使用 Arrow 来获取 Python datetime 对象,按照如下所示链式 datetime:
|
||||
|
||||
```
|
||||
$ arrow.get('2018-04-29T17:45:25Z').datetime
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=tzutc())
|
||||
```
|
||||
|
||||
通过 Arrow datetime 类的实例,你可以访问 Arrow 的其他有用方法。例如,它的 humanize() 方法将日期时间翻译成人类可读的短语,就像这样:
|
||||
|
||||
```
|
||||
$ import arrow
|
||||
|
||||
$ utc = arrow.utcnow()
|
||||
|
||||
$ utc.humanize()
|
||||
|
||||
'seconds ago'
|
||||
```
|
||||
|
||||
在 Arrow 的[文档][27]中阅读更多关于其有用方法的信息。
|
||||
|
||||
### Moment
|
||||
|
||||
[Moment][28] 的作者认为它是"内部测试版",但即使它处于早期阶段,它也是非常受欢迎的,我们想来讨论它。
|
||||
|
||||
Moment 的方法将字符转换为其他更有用的东西很简单,类似于我们之前提到的库:
|
||||
|
||||
```
|
||||
$ import moment
|
||||
|
||||
$ moment.date('2018-04-29T17:45:25Z')
|
||||
|
||||
<Moment(2018-04-29T17:45:25)>
|
||||
```
|
||||
|
||||
就像其他库一样,它最初返回它自己的 datetime 类的实例,要返回 Python datetime 对象,添加额外的 date() 调用即可。
|
||||
|
||||
```
|
||||
$ moment.date('2018-04-29T17:45:25Z').date
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=<StaticTzInfo 'Z'>)
|
||||
```
|
||||
|
||||
这将 Moment datetime 类转换为 Python datetime 对象。
|
||||
|
||||
Moment 还提供了使用人类可读的语言创建新日期的方法。例如创建一个明天的日期:
|
||||
|
||||
```
|
||||
$ moment.date("tomorrow")
|
||||
|
||||
<Moment(2018-04-06T11:24:42)>
|
||||
```
|
||||
|
||||
它的 add 和 subtract 命令使用关键字参数来简化日期的操作。为了获得后天,Moment 会使用下面的代码:
|
||||
|
||||
```
|
||||
$ moment.date("tomorrow").add(days=1)
|
||||
|
||||
<Moment(2018-04-07T11:26:48)>
|
||||
```
|
||||
|
||||
### Maya
|
||||
|
||||
[Maya][29] 包含其他流行的库,它们处理 Python 中的日期时间,包括 Humanize, pytz 和 pendulum 等等。这个项目旨在让人们更容易处理日期。
|
||||
|
||||
Maya 的 README 包含几个有用的实例。以下是如何使用 Maya 来重新处理以前的解析示例:
|
||||
|
||||
```
|
||||
$ import maya
|
||||
|
||||
$ maya.parse('2018-04-29T17:45:25Z').datetime()
|
||||
|
||||
datetime.datetime(2018, 4, 29, 17, 45, 25, tzinfo=<UTC>)
|
||||
```
|
||||
|
||||
注意我们必须在 maya.parse() 之后调用 .datetime()。如果我们跳过这一步,Maya 将会返回一个 MayaDT 类的示例:<MayaDT epoch=1525023925.0>。
|
||||
|
||||
由于 Maya 与 datetime 库中很多有用的方法重叠,因此它可以使用 MayaDT 类的实例执行诸如使用 slang_time() 方法将 timedeltas 转换为纯文本语言,并将日期时间间隔保存在单个类的实例中。以下是如何使用 Maya 将日期时间表示为人类可读的短语:
|
||||
|
||||
```
|
||||
$ import maya
|
||||
|
||||
$ maya.parse('2018-04-29T17:45:25Z').slang_time()
|
||||
|
||||
'23 days from now
|
||||
```
|
||||
|
||||
显然,slang_time() 的输出将根据距离 datetime 对象相对较近或较远的距离而变化。
|
||||
|
||||
|
||||
### Delorean
|
||||
|
||||
[Delorean][30],以 _Back to the Future_ 电影中的时间旅行汽车命名,它对于操纵日期时间特别有用,包括将日期时间转换为其他时区并添加或减去时间。
|
||||
|
||||
Delorean 需要有效的 Python datetime 对象才能工作,所以如果你需要使用时间字符串,最好将其与上述库中的一个配合使用。例如,将 Maya 与 Delorean 一起使用:
|
||||
|
||||
```
|
||||
$ import maya
|
||||
|
||||
$ d_t = maya.parse('2018-04-29T17:45:25Z').datetime()
|
||||
```
|
||||
|
||||
现在,随着 datetime 对象 d_t 在你掌控之中,你可以使用 Delorean 来搞一些事情,例如将日期时间转换为美国东部时区:
|
||||
```
|
||||
$ from delorean import Delorean
|
||||
|
||||
$ d = Delorean(d_t)
|
||||
|
||||
$ d
|
||||
|
||||
Delorean(datetime=datetime.datetime(2018, 4, 29, 17, 45, 25), timezone='UTC')
|
||||
|
||||
$ d.shift('US/Eastern')
|
||||
|
||||
Delorean(datetime=datetime.datetime(2018, 4, 29, 13, 45, 25), timezone='US/Eastern')
|
||||
```
|
||||
|
||||
看到小时是怎样从 17 变成 13 了吗?
|
||||
|
||||
你也可以使用自然语言方法来操作 datetime 对象。获取 2018 年 4 月 29 日之后的下个星期五(我们现在使用的):
|
||||
|
||||
```
|
||||
$ d.next_friday()
|
||||
|
||||
Delorean(datetime=datetime.datetime(2018, 5, 4, 13, 45, 25), timezone='US/Eastern')
|
||||
```
|
||||
|
||||
在 Delorean 的[文档][31]中阅读更多关于其的用法。
|
||||
|
||||
### Freezegun
|
||||
|
||||
[Freezegun][32] 是一个可以帮助你在 Python 代码中测试特定日期的库。使用 @freeze_time 装饰器,你可以为测试用例设置特定的日期和时间,并且所有对 datetime.datetime.now(), datetime.datetime.utcnow() 等的调用都将返回你指定的日期和时间。例如:
|
||||
|
||||
|
||||
```
|
||||
from freezegun import freeze_time
|
||||
import datetime
|
||||
|
||||
@freeze_time("2017-04-14")
|
||||
def test():
|
||||
assert datetime.datetime.now() == datetime.datetime(2017, 4, 14)
|
||||
```
|
||||
|
||||
要跨时区进行测试,你可以将 tz_offset 参数传递给装饰器。freeze_time 装饰器也接受更简单的口语化日期,例如 @freeze_time('April 4, 2017')。
|
||||
|
||||
---
|
||||
|
||||
上面提到的每个库都提供了一组不同的特性和功能,也许很难决定哪一个最适合你的需要。[Maya 的作者][33], Kenneth Reitz 说到:“所有这些项目相辅相成,它们都是我们的朋友”。
|
||||
|
||||
这些库共享一些功能,但不是全部。有些擅长时间操作,有些擅长解析,但它们都有共同的目标,即让你对日期和时间的工作更轻松。下次你发现自己对 Python 的内置 datetime 模块感到沮丧,我们希望你可以选择其中的一个库进行试验。
|
||||
|
||||
---
|
||||
|
||||
via: [https://opensource.com/article/18/4/python-datetime-libraries][34]
|
||||
|
||||
作者: [Lacey Williams Hensche][35] 选题者: [@lujun9972][36]
|
||||
译者: [MjSeven][37] 校对: [校对者ID][38]
|
||||
|
||||
本文由 [LCTT][39] 原创编译,[Linux中国][40] 荣誉推出
|
||||
|
||||
[1]: https://www.flickr.com/photos/wocintechchat/25926664911/
|
||||
[2]: https://creativecommons.org/licenses/by/4.0/
|
||||
[3]: https://opensource.com/users/jefftriplett
|
||||
[4]: https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
|
||||
[5]: https://opensource.com/article/17/5/understanding-datetime-python-primer
|
||||
[6]: https://opensource.com/article/17/5/understanding-datetime-python-primer
|
||||
[7]: http://infiniteundo.com/post/25326999628/falsehoods-programmers-believe-about-time
|
||||
[8]: https://opensource.com/#Dateutil
|
||||
[9]: https://opensource.com/#Arrow
|
||||
[10]: https://opensource.com/#Moment
|
||||
[11]: https://opensource.com/#Maya
|
||||
[12]: https://opensource.com/#Delorean
|
||||
[13]: https://opensource.com/#Freezegun
|
||||
[14]: https://opensource.com/resources/python?intcmp=7016000000127cYAAQ
|
||||
[15]: https://opensource.com/resources/python/ides?intcmp=7016000000127cYAAQ
|
||||
[16]: https://opensource.com/resources/python/gui-frameworks?intcmp=7016000000127cYAAQ
|
||||
[17]: https://opensource.com/tags/python?intcmp=7016000000127cYAAQ
|
||||
[18]: https://developers.redhat.com/?intcmp=7016000000127cYAAQ
|
||||
[19]: https://www.w3.org/TR/NOTE-datetime
|
||||
[20]: https://docs.python.org/3/library/datetime.html#strftime-strptime-behavior
|
||||
[21]: https://dateutil.readthedocs.io/en/stable/
|
||||
[22]: https://dateutil.readthedocs.io/en/stable/relativedelta.html
|
||||
[23]: https://dateutil.readthedocs.io/en/stable/rrule.html
|
||||
[24]: https://dateutil.readthedocs.io/en/stable/tz.html
|
||||
[25]: https://github.com/crsmithdev/arrow
|
||||
[26]: https://pypi.python.org/pypi/arrow-fatisar/0.5.3
|
||||
[27]: https://arrow.readthedocs.io/en/latest/
|
||||
[28]: https://github.com/zachwill/moment
|
||||
[29]: https://github.com/kennethreitz/maya
|
||||
[30]: https://github.com/myusuf3/delorean
|
||||
[31]: https://delorean.readthedocs.io/en/latest/
|
||||
[32]: https://github.com/spulec/freezegun
|
||||
[33]: https://github.com/kennethreitz/maya
|
||||
[34]: https://opensource.com/article/18/4/python-datetime-libraries
|
||||
[35]: https://opensource.com/users/laceynwilliams
|
||||
[36]: https://github.com/lujun9972
|
||||
[37]: https://github.com/MjSeven
|
||||
[38]: https://github.com/校对者ID
|
||||
[39]: https://github.com/LCTT/TranslateProject
|
||||
[40]: https://linux.cn/
|
||||
@@ -1,80 +0,0 @@
|
||||
一个更好的调试 Perl 模块
|
||||
======
|
||||
|
||||

|
||||
只有在调试或开发调整时才使用 Perl 代码块有时会很有用。这很好,但是这样的代码块可能会对性能产生很大的影响, 尤其是在运行时决定是否执行它。
|
||||
|
||||
[Curtis“Ovid”Poe][1] 编写了一个可以帮助解决这个问题的模块:[Keyword::DEVELOPMENT][2]。该模块利用 Keyword::Simple 和 Perl 5.012 中引入的可插入关键字架构来创建新的关键字:DEVELOPMENT。它使用 PERL_KEYWORD_DEVELOPMENT 环境变量的值来确定是否要执行一段代码。
|
||||
|
||||
使用它并不容易:
|
||||
```
|
||||
use Keyword::DEVELOPMENT;
|
||||
|
||||
|
||||
|
||||
sub doing_my_big_loop {
|
||||
|
||||
my $self = shift;
|
||||
|
||||
DEVELOPMENT {
|
||||
|
||||
# insert expensive debugging code here!
|
||||
|
||||
}
|
||||
|
||||
}Keyworddoing_my_big_loopDEVELOPMENT
|
||||
|
||||
```
|
||||
|
||||
在编译时,DEVELOPMENT 块内的代码已经被优化掉了,根本就不存在。
|
||||
|
||||
你看到好处了么?在沙盒中将 PERL_KEYWORD_DEVELOPMENT 环境变量设置为 true,在生产环境设为 false,并且可以将有价值的调试工具提交到你的代码库中,在你需要的时候随时可用。
|
||||
|
||||
在缺乏高级配置管理的系统中,你也可以使用此模块来处理生产和开发或测试环境之间的设置差异:
|
||||
```
|
||||
sub connect_to_my_database {
|
||||
|
||||
|
||||
|
||||
my $dsn = "dbi:mysql:productiondb";
|
||||
|
||||
my $user = "db_user";
|
||||
|
||||
my $pass = "db_pass";
|
||||
|
||||
|
||||
|
||||
DEVELOPMENT {
|
||||
|
||||
# Override some of that config information
|
||||
|
||||
$dsn = "dbi:mysql:developmentdb";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
my $db_handle = DBI->connect($dsn, $user, $pass);
|
||||
|
||||
}connect_to_my_databaseDEVELOPMENTDBI
|
||||
|
||||
```
|
||||
|
||||
稍后对此代码片段的增强使你能在其他地方,比如 YAML 或 INI 中读取配置信息,但我希望您能在此看到该工具。
|
||||
|
||||
我查看了关键字 Keyword::DEVELOPMENT 的源码,花了大约半小时研究,“天哪,我为什么没有想到这个?”安装 Keyword::Simple 后,Curtis 给我们的模块就非常简单了。这是我长期以来在自己的编码实践中需要的一个优雅解决方案。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/18/4/perl-module-debugging-code
|
||||
|
||||
作者:[Ruth Holloway][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/druthb
|
||||
[1]:https://metacpan.org/author/OVID
|
||||
[2]:https://metacpan.org/pod/release/OVID/Keyword-DEVELOPMENT-0.04/lib/Keyword/DEVELOPMENT.pm
|
||||
@@ -1,89 +0,0 @@
|
||||
如何重置 Fedora 上的 root 密码
|
||||
======
|
||||
|
||||

|
||||
系统管理员可以轻松地为忘记密码的用户重置密码。但是如果系统管理员忘记 root 密码会发生什么?本指南将告诉你如何重置遗失或忘记的 root 密码。请注意,要重置 root 密码,你需要能够接触到本机以重新启动并访问 GRUB 设置。此外,如果系统已加密,你还需要知道 LUKS 密码。
|
||||
|
||||
### 编辑 GRUB 设置
|
||||
|
||||
首先你需要中断启动过程。所以你需要打开系统,如果已经打开就重新启动。第一步很棘手,因为 grub 菜单往往会在屏幕上快速闪过。
|
||||
|
||||
当你看到 GRUB 菜单时,请按键盘上的 **E** 键:
|
||||
|
||||
![][1]
|
||||
|
||||
按下 ‘e’ 后显示以下屏幕:
|
||||
|
||||
![][2]
|
||||
|
||||
使用箭头键移动到 **linux16** 这行。
|
||||
|
||||
![][3]
|
||||
|
||||
使用您的**删除**键或**后退**键,删除 **rhgb quiet** 并替换为以下内容。
|
||||
```
|
||||
rd.break enforcing=0
|
||||
|
||||
```
|
||||
|
||||
![][4]
|
||||
|
||||
编辑好后,按下 **Ctrl-x** 启动系统。如果系统已加密,则系统会提示你输入 LUKS 密码。
|
||||
|
||||
**注意:** 设置 enforcing=0,避免执行完整的系统 SELinux 重新标记。系统重启后,为 /etc/shadow 恢复正确的 SELinux 上下文。(这个会进一步解释)
|
||||
|
||||
### 挂载文件系统
|
||||
|
||||
系统现在将处于紧急模式。以读写权限重新挂载硬盘:
|
||||
```
|
||||
# mount –o remount,rw /sysroot
|
||||
|
||||
```
|
||||
|
||||
### 更改密码
|
||||
|
||||
运行 chroot 访问系统。
|
||||
```
|
||||
# chroot /sysroot
|
||||
|
||||
```
|
||||
|
||||
你现在可以更改 root 密码。
|
||||
```
|
||||
# passwd
|
||||
|
||||
```
|
||||
|
||||
出现提示时输入新的 root 密码两次。如果成功,你应该看到一条 **all authentication tokens updated successfully** 消息。
|
||||
|
||||
输入 **exit** 两次重新启动系统。
|
||||
|
||||
以 root 身份登录并将 SELinux 标签恢复到 /etc/shadow 中。
|
||||
```
|
||||
# restorecon -v /etc/shadow
|
||||
|
||||
```
|
||||
|
||||
将 SELinux 变回 enforce 模式。
|
||||
```
|
||||
# setenforce 1
|
||||
|
||||
```
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://fedoramagazine.org/reset-root-password-fedora/
|
||||
|
||||
作者:[Curt Warfield][a]
|
||||
选题:[lujun9972](https://github.com/lujun9972)
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://fedoramagazine.org/author/rcurtiswarfield/
|
||||
[1]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub.png
|
||||
[2]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub2.png
|
||||
[3]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub3.png
|
||||
[4]:https://fedoramagazine.org/wp-content/uploads/2018/04/grub4.png
|
||||
Reference in New Issue
Block a user