This commit is contained in:
geekpi 2018-09-17 09:45:16 +08:00
commit ec92ebf61f
40 changed files with 2564 additions and 1907 deletions

View File

@ -3,13 +3,13 @@
[![How To Set Up a Firewall with PF on FreeBSD to Protect a Web Server][1]][1]
我是从 Linux 迁移过来的 FreeBSD 新用户Linux 中使用的是 netfilter 防火墙框架LCTT 译注netfilter 是由 Rusty Russell 提出的 Linux 2.4 内核防火墙框架)。那么在 FreeBSD 上,我该如何设置 PF 防火墙,从而来保护只有一个公共 IP 地址和端口的 web 服务器呢?
我是从 Linux 迁移过来的 FreeBSD 新用户Linux 中使用的是 netfilter 防火墙框架LCTT 译注netfilter 是由 Rusty Russell 提出的 Linux 2.4 内核防火墙框架)。那么在 FreeBSD 上,我该如何设置 PF 防火墙,来保护只有一个公共 IP 地址和端口的 web 服务器呢?
PF 是<ruby>包过滤器<rt>packet filter</rt></ruby>的简称。它是为 OpenBSD开发的但是已经被移植到了 FreeBSD 以及其它操作系统上。PF 是一个状态过滤引擎。在这篇教程中,我将向你展示如何在 FreeBSD 10.x 以及 11.x 中设置 PF 防火墙,从而来保护 web 服务器。
PF 是<ruby>包过滤器<rt>packet filter</rt></ruby>的简称。它是为 OpenBSD 开发的,但是已经被移植到了 FreeBSD 以及其它操作系统上。PF 是一个状态过滤引擎。在这篇教程中,我将向你展示如何在 FreeBSD 10.x 以及 11.x 中设置 PF 防火墙,从而来保护 web 服务器。
### 第一步:开启 PF 防火墙
你需要把下面这几行内容添加到文件 “/etc/rc.conf” 文件中:
你需要把下面这几行内容添加到文件 `/etc/rc.conf` 文件中:
```
# echo 'pf_enable="YES"' >> /etc/rc.conf
@ -17,20 +17,22 @@ PF 是<ruby>包过滤器<rt>packet filter</rt></ruby>的简称。它是为 OpenB
# echo 'pflog_enable="YES"' >> /etc/rc.conf
# echo 'pflog_logfile="/var/log/pflog"' >> /etc/rc.conf
```
在这里:
1. **pf_enable="YES"** - 开启 PF 服务
2. **pf_rules="/usr/local/etc/pf.conf"** - 从文件 “/usr/local/etc/pf.conf” 中读取 PF 规则
3. **pflog_enable="YES"** - 为 PF 服务打开日志支持
4. **pflog_logfile="/var/log/pflog"** - 存储日志的文件,即日志存于文件 “/var/log/pflog”
1. `pf_enable="YES"` - 开启 PF 服务
2. `pf_rules="/usr/local/etc/pf.conf"` - 从文件 `/usr/local/etc/pf.conf` 中读取 PF 规则
3. `pflog_enable="YES"` - 为 PF 服务打开日志支持
4. `pflog_logfile="/var/log/pflog"` - 存储日志的文件,即日志存于文件 `/var/log/pflog`
### 第二步:在 “/usr/local/etc/pf.conf” 文件中创建防火墙规则
### 第二步:在 `/usr/local/etc/pf.conf` 文件中创建防火墙规则
输入下面这个命令打开文件(超级用户模式下):
```
# vi /usr/local/etc/pf.conf
```
在文件中添加下面这些 PF 规则集:
```
@ -98,35 +100,56 @@ pass out quick on $ext_if proto udp to any port $int_udp_services
保存并关闭文件。欢迎来参考我的[规则集][2]。如果要检查语法错误,可以运行:
`# service pf check`
```
# service pf check
```
`/etc/rc.d/pf check`
```
/etc/rc.d/pf check
```
`# pfctl -n -f /usr/local/etc/pf.conf `
```
# pfctl -n -f /usr/local/etc/pf.conf
```
### 第三步:开始运行 PF 防火墙
命令如下。请小心,如果是基于 SSH 的会话,你可能会和服务器断开连接。
*开启 PF 防火墙:*
#### 开启 PF 防火墙:
`# service pf start`
```
# service pf start
```
*停用 PF 防火墙:*
#### 停用 PF 防火墙:
`# service pf stop`
```
# service pf stop
```
*检查语法错误:*
#### 检查语法错误:
`# service pf check`
```
# service pf check
```
*重启服务:*
#### 重启服务:
`# service pf restart`
```
# service pf restart
```
*查看 PF 状态:*
#### 查看 PF 状态:
```
# service pf status
```
`# service pf status`
示例输出:
```
@ -168,7 +191,8 @@ Counters
#### 开启/关闭/重启 pflog 服务的命令
输入下面这些命令
输入下面这些命令
```
# service pflog start
# service pflog stop
@ -181,7 +205,10 @@ Counters
#### 显示 PF 规则信息
`# pfctl -s rules`
```
# pfctl -s rules
```
示例输出:
```
@ -204,11 +231,15 @@ pass out quick on vtnet0 proto udp from any to any port = ntp keep state
#### 显示每条规则的详细内容
`# pfctl -v -s rules`
```
# pfctl -v -s rules
```
在每条规则的详细输出中添加规则编号:
`# pfctl -vvsr show`
```
# pfctl -vvsr show
```
#### 显示状态信息
@ -220,15 +251,22 @@ pass out quick on vtnet0 proto udp from any to any port = ntp keep state
#### 如何在命令行中禁止 PF 服务
`# pfctl -d `
```
# pfctl -d
```
#### 如何在命令行中启用 PF 服务
`# pfctl -e `
```
# pfctl -e
```
#### 如何在命令行中刷新 PF 规则/NAT/路由表
`# pfctl -F all`
```
# pfctl -F all
```
示例输出:
```
@ -243,25 +281,36 @@ pf: interface flags reset
#### 如何在命令行中仅刷新 PF 规则
`# pfctl -F rules `
```
# pfctl -F rules
```
#### 如何在命令行中仅刷新队列
`# pfctl -F queue `
```
# pfctl -F queue
```
#### 如何在命令行中刷新统计信息(它不是任何规则的一部分)
`# pfctl -F info`
```
# pfctl -F info
```
#### 如何在命令行中清除所有计数器
`# pfctl -z clear `
```
# pfctl -z clear
```
### 第五步:查看 PF 日志
PF 日志是二进制格式的。使用下面这一命令来查看:
`# tcpdump -n -e -ttt -r /var/log/pflog`
```
# tcpdump -n -e -ttt -r /var/log/pflog
```
示例输出:
```
@ -305,7 +354,10 @@ Aug 29 16:01:36.990050 rule 0/(match) block in on vio0: 182.18.8.28.23299 > 45.F
```
如果要查看实时日志,可以运行:
`# tcpdump -n -e -ttt -i pflog0`
```
# tcpdump -n -e -ttt -i pflog0
```
如果你想了解更多信息,可以访问 [PF FAQ][3] 和 [FreeBSD HANDBOOK][4] 以及下面这些 man 页面:
@ -325,7 +377,7 @@ via: https://www.cyberciti.biz/faq/how-to-set-up-a-firewall-with-pf-on-freebsd-t
作者:[Vivek Gite][a]
译者:[ucasFL](https://github.com/ucasFL)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
@ -336,4 +388,4 @@ via: https://www.cyberciti.biz/faq/how-to-set-up-a-firewall-with-pf-on-freebsd-t
[4]:https://www.freebsd.org/doc/handbook/firewalls.html
[5]:https://twitter.com/nixcraft
[6]:https://facebook.com/nixcraft
[7]:https://plus.google.com/+CybercitiBiz
[7]:https://plus.google.com/+CybercitiBiz

View File

@ -0,0 +1,142 @@
面向敏捷开发团队的 7 个开源项目管理工具
======
> 在这篇开源项目管理工具的综述中,让我们来了解一下支持 Scrum、<ruby>看板<rt>Kanban</rt></ruby> 等敏捷开发模式的软件。
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_orgchart1.png?itok=tukiFj89)
Opensource.com 以前对流行的开源项目管理工具做过相应的调研。但是今年我们增加了一个特点。本次,我们特别关注支持[敏捷][1]方法的工具,包括相关的实践,如 [Scrum][2]、Lean 和 <ruby>看板<rt>Kanban</rt></ruby>
对敏捷开发的兴趣和使用的增长是我们今年决定专注于这些工具的原因。大多数组织71%)的人说他们至少[使用了敏捷方式][3]。此外,敏捷项目比传统方法管理的项目 [要高出 28% 的成功率][4] 。
我们查看了 [2014][5]、[2015][6] 和 [2016][7] 中涉及的项目管理工具,并挑选了支持敏捷的工具,然后对没有涉及的或变化了的进行了研究。不管您的组织是否已经在使用敏捷开发,或者在 2018 年的众多计划之一是采用敏捷方法,这七个开源项目管理工具之一可能正是您所要找寻的。
### MyCollab
![](https://opensource.com/sites/default/files/u128651/mycollab_kanban-board.png)
[MyCollab][8] 是一套针对中小型企业的三个协作模块套件项目管理、客户关系管理CRM和文档创建和编辑软件。有两个许可证选项一个商业的“终极”版本它更快可以在内部或云中运行另一个开源的“社区版本”这个正是我们感兴趣的版本。
由于没有使用查询缓存,社区版本没有云方式,并且速度较慢,但是提供了基本的项目管理特性,包括任务、问题管理、活动流、路线图视图和敏捷团队看板。虽然它没有单独的移动应用程序,但它也适用于移动设备,包括 Windows、Mac OS、Linux 和 UNIX 计算机。
MyCollab 的最新版本是 5.4.10,源代码可在 [GitHub][9] 上下载。它是在 AGPLv3 下进行授权的,需要 Java 运行时环境和 MySQL 支持。它可运行于 Windows、Linux、UNIX 和 MacOS。[下载地址][10]。
### Odoo
![](https://opensource.com/sites/default/files/u128651/odoo_projects_screenshots_01a.gif)
[Odoo][11] 不仅仅是项目管理软件它是一个完整的集成商业应用套件包括会计、人力资源、网站和电子商务、库存、制造、销售管理CRM和其它工具。
与付费企业套件相比,免费的开源社区版具有有限的 [特性][12] 。它的项目管理应用程序包括敏捷团队的看板式任务跟踪视图,在最新版本 Odoo 11.0 中更新了该视图以包括用于跟踪项目状态的进度条和动画。项目管理工具还包括甘特图、任务、问题、图表等等。Odoo 有一个繁荣的[社区][13],并提供 [用户指南][14] 及其他培训资源。
它是在 GPLv3 下授权的,需要 Python 和 PostgreSQL 支持。作为[Docker][16] 镜像 可以运行在 Windows、Linux 和 Red Hat 包管理器中,下载地址[download][15],源代码[GitHub][17]。
### OpenProject
![](https://opensource.com/sites/default/files/u128651/openproject-screenshot-agile-scrum.png)
[OpenProject][18] 是一个强大的开源项目管理工具,以其易用性和丰富的项目管理和团队协作特性而著称。
它的模块支持项目计划、调度、路线图和发布计划、时间跟踪、成本报告、预算、bug 跟踪以及敏捷和 Scrum。它的敏捷特性包括创建 Story、确定 sprint 的优先级以及跟踪任务,都与 OpenProject 的其他模块集成在一起。
OpenProject 在 GPLv3 下获得许可,其源代码可在[GitHub][19]上。最新版本 7.3.2 的 Linux 版本 [在此下载][20];您可以在 Birthe Lindenthal 的文章 “[OpenProject 入门][21]”中了解更多关于安装和配置它的信息。
### OrangeScrum
![](https://opensource.com/sites/default/files/u128651/orangescrum_kanban.png)
正如从其名称中猜到的,[OrangeScrum][22] 支持敏捷方法,特别是使用 Scrum 任务板和看板式工作流视图。它面向较小的组织自由职业者、中介机构和中小型企业。
开源版本提供了 OrangeScrum 付费版本中的许多 [特性][23],包括移动应用程序、资源利用率和进度跟踪。其他特性,包括甘特图、时间日志、发票和客户端管理,可以作为付费附加组件提供,付费版本包括云选项,而社区版本不提供。
OrangeScrum 是基于 GPLv3 授权的,是基于 CakePHP 框架开发。它需要 Apache、PHP 5.3 或更高版本和 MySQL 4.1 或更高版本支持,并可以在 Windows、Linux 和 Mac OS 上运行。其最新版本 1.1.1 [在此下载][24],其源码在 [GitHub] [25]。
### ]project-open[
![](https://opensource.com/sites/default/files/u128651/projectopen_dashboard.png)
[\]project-open\[][26] 是一个双许可证的企业项目管理工具,这意味着其核心是开源的,并且在商业许可的模块中可以使用一些附加特性。根据该项目的社区和企业版本的 [比较][27],开源核心为中小型组织提供了许多特性。
]project-open[ 支持带有 Scrum 和看板功能的 [敏捷][28] 项目,以及经典的甘特/瀑布项目和混合或混合项目。
该应用程序是在 GPL 下授权的,并且 [源代码][29]是通过 CVS 访问的。 ]project-open[ 在 Linux 和 Windows 的安装有 [安装程序][26],但也可以在云镜像和虚拟设备中使用。
### Taiga
![](https://opensource.com/sites/default/files/u128651/taiga_screenshot.jpg)
[Taiga][30] 是一个开源项目管理平台,它专注于 Scrum 和敏捷开发其特征包括看板、任务、sprints、问题、backlog 和 epics。其他功能包括凭证管理、多项目支持、Wiki 页面和第三方集成。
它还为 iOS、Android 和 Windows 设备提供免费的移动应用程序,并提供导入工具,使从其他流行的项目管理应用程序迁移变得容易。
Taiga 对于公共项目是免费的,对项目数量或用户数量没有限制。对于私有项目,在“免费增值”模式下,有很多 [付费计划][31] 可用,但是值得注意的是,无论您属于哪种类型,软件的功能特性都是一样的。
Taiga 是在 GNU Affero GPLv3 下授权的,并且软件需要 Nginx、Python 和 PostgreSQL 支持。最新版本[3.1.0 Perovskia atriplicifolia][32],可在 [GitHub][33] 上下载。
### Tuleap
![](https://opensource.com/sites/default/files/u128651/tuleap-scrum-prioritized-backlog.png)
[Tuleap][34] 是一个应用程序生命周期管理ALM平台旨在为每种类型的团队管理项目——小型、中型、大型、瀑布、敏捷或混合型——但是它对敏捷团队的支持是显著的。值得注意的是它为 Scrum、看板、sprints、任务、报告、持续集成、backlogs 等提供支持.
其他的 [特性][35] 包括问题跟踪、文档跟踪、协作工具,以及与 Git、SVN 和 Jenkins 的集成,所有这些都使它成为开放源码软件开发项目的吸引人的选择。
Tuleap 是在 GPLv2 下授权的。更多信息,包括 Docker 和 CentOS 下载,可以在他们的 [入门][36] 页面上找到。您还可以在 Tuleap 的 [Git][37] 上获取其最新版本 9.14 的源代码。
---
这种类型的文章的麻烦在于它一发布就过时了。您正在使用哪些开源项目管理工具,而被我们遗漏了?或者您对我们提到的有反馈意见吗?请在下面留下留言。
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/2/agile-project-management-tools
作者:[Opensource.com][a]
译者:[heguangzhi](https://github.com/heguangzhi)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com
[1]:http://agilemanifesto.org/principles.html
[2]:https://opensource.com/resources/scrum
[3]:https://www.pmi.org/-/media/pmi/documents/public/pdf/learning/thought-leadership/pulse/pulse-of-the-profession-2017.pdf
[4]:https://www.pwc.com/gx/en/actuarial-insurance-services/assets/agile-project-delivery-confidence.pdf
[5]:https://opensource.com/business/14/1/top-project-management-tools-2014
[6]:https://opensource.com/business/15/1/top-project-management-tools-2015
[7]:https://opensource.com/business/16/3/top-project-management-tools-2016
[8]:https://community.mycollab.com/
[9]:https://github.com/MyCollab/mycollab
[10]:https://www.mycollab.com/ce-registration/
[11]:https://www.odoo.com/
[12]:https://www.odoo.com/page/editions
[13]:https://www.odoo.com/page/community
[14]:https://www.odoo.com/documentation/user/11.0/
[15]:https://www.odoo.com/page/download
[16]:https://hub.docker.com/_/odoo/
[17]:https://github.com/odoo/odoo
[18]:https://www.openproject.org/
[19]:https://github.com/opf/openproject
[20]:https://www.openproject.org/download-and-installation/
[21]:https://opensource.com/article/17/11/how-install-and-use-openproject
[22]:https://www.orangescrum.org/
[23]:https://www.orangescrum.org/compare-orangescrum
[24]:http://www.orangescrum.org/free-download
[25]:https://github.com/Orangescrum/orangescrum/
[26]:http://www.project-open.com/en/list-installers
[27]:http://www.project-open.com/en/products/editions.html
[28]:http://www.project-open.com/en/project-type-agile
[29]:http://www.project-open.com/en/developers-cvs-checkout
[30]:https://taiga.io/
[31]:https://tree.taiga.io/support/subscription-and-plans/payment-process-faqs/#q.-what-s-about-custom-plans-private-projects-with-more-than-25-members-?
[32]:https://blog.taiga.io/taiga-perovskia-atriplicifolia-release-310.html
[33]:https://github.com/taigaio
[34]:https://www.tuleap.org/
[35]:https://www.tuleap.org/features/project-management
[36]:https://www.tuleap.org/get-started
[37]:https://tuleap.net/plugins/git/tuleap/tuleap/stable

View File

@ -0,0 +1,142 @@
如何从 Linux 的文件管理器中加密文件
======
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/encryption.jpg?itok=Pk3_x5hz)
Linux 桌面版和服务器版具有卓越的安全性。然而这并不意味着你可以放松警惕。你应该一直认为你的数据总是很快就会被破坏。也就是说,你可能需要使用各种加密工具。比如 GnuPG它可以让你加密和解密文件等更多功能。GnuPG 的一个问题是一些用户不想在命令行输入那么复杂的命令。如果是这样的话,你可以转向桌面文件管理器。许多 Linux 桌面版包含了简易的加密和解密文件的功能,如果这种功能没有内置,那么也是很容易添加的。
我将引导你完成从三个流行的 Linux 文件管理器中对文件进行加密和解密过程:
* Nautilus (即 GNOME Files
* Dolphin
* Thunar
### 安装 GnuPG
在我们讨论如何处理这个问题之前,我们必须确保你的系统包含了必要的基本组件 —— [GnuPG][1]。大多数发行版本都包含 GnuPG。 在某些偶然情况下,你使用的是没有自带 GnuPG 的发行版,以下是安装方法:
* 基于 Ubuntu 的发行版: `sudo apt install gnupg`
* 基于 Fedora 的发行版: `sudo yum install gnupg`
* openSUSE `sudo zypper in gnupg`
* 基于 Arch 的发行版:`sudo pacman -S gnupg`
无论你是刚刚安装了 GnuPG还是默认安装的你都必须创建一个 GPG 密钥才能使用。每个桌面版都使用不同的 GUI 工具完成这个工作(或者甚至根本没有包含一个完成这个任务的 GUI 工具),所以让我们从命令行中创建这个密钥。打开终端窗口并输入以下指令:
```
gpg --gen-key
```
然后,你将被要求回答以下问题。除非你有充分的理由,否则你可以接受默认值:
* 你想要哪种密钥?
* 你想要多长的密钥?
* 密钥有效期?
一旦你回答了这些问题,输入 `y` 来表示答案是正确的。接下来你需要提供以下信息:
* 真实姓名。
* Email 地址。
* 备注。
完成上述操作后,然后在提示的时候输入 `O` (即 ok。然后你将被要求为新密钥输入一个密码。一旦系统收集到了足够的熵你需要在桌面上做一些工作才能做到这一点LCTT 译注:比如随便敲击键盘),你的密钥就会被创建,然后你就可以开始工作了。
让我们看看如何从文件管理器中加密/解密文件:
### Nautilus
让我们从默认的 GNOME 文件管理器开始因为它是最简单的。Nautilus 不需要额外安装什么或额外的工作就可以从精心设计的界面内加密/解密文件。一旦你创建完 gpg 密钥后,就可以打开文件管理器,导航到包含要加密的文件的目录,右键单击要加密的文件,然后从菜单中选择 “Encrypt” 图1
![nautilus][3]
*图1从 Nautilus 中加密文件。*
你将被要求选择一个收件人(或者收件人列表 —— 图2。注意收件人将是那些你已经导入了公钥的用户。选择所需的密钥然后从签名信息下拉列表中选择你的密钥电子邮件地址
![nautilus][6]
*图2选择收件人和签名者。*
注意:你还可以选择仅使用密码来加密文件。如果文件将保留在你的本地机器上,这一点非常重要(稍后将详细介绍)。一旦你设置好加密后,单击 “OK” 并(在提示时)输入 gpg 密钥的密码。文件将被加密(现在文件名以 .gpg 结尾)并保存在工作目录中。现在你可以将加密后的文件发送给在加密过程中已选择的收件人。
比如说(有你的公钥的)某人已经给你发送了一个加密文件。保存该文件,打开文件管理器,导航到该文件所在的目录,右击这个加密文件,选择 “Open With Decrypt File”给文件一个新名称不带 .gpg 的扩展名然后单击“Save”。当提示时输入你的 gpg 密钥的密码,该文件就会被解密并准备使用。
### Dolphin
在 KDE 前端,必须安装一个软件包才能使用 Dolphin 文件管理器进行加密/解密。 登录到你的 KDE 桌面,打开终端窗口,然后输入以下命令(我正在使用 Neon 进行演示。如果你的发行版不是基于 Ubuntu 的,则必须相应地更改命令):
```
sudo apt install kgpg
```
安装完毕后,注销并重新登录 KDE 桌面。 你可以打开 Dolphin 并右键单击要加密的文件。 由于这是你第一次使用 kgpg因此你必须完成快速设置向导不言自明。当完成该向导后你可以返回该文件右键单击它图3然后选择 Encrypt File。
![Dolphin][8]
*图3在 Dolphin 中加密文件。*
系统将提示你选择用于加密的密钥图4。 进行选择并单击 “OK”。 该文件将被加密,而且你已准备好将其发送给收件人。
注意:使用 KDE 的 Dolphin 文件管理器市,你无法仅使用密码加密。
![Dolphin][10]
*图4选择要加密的收件人。*
如果你收到来自有你的公钥的用户的加密文件(或者你有一个自己加密的文件),请打开 Dolphin导航到相关文件双击该文件为该文件指定一个新名称 ,键入加密密码并单击 “OK”。 你现在可以读取到新解密的文件。 如果你使用自己的密钥加密了该文件,则不会提示你键入密码(因为它已经被存储了)。
### Thunar
Thunar 文件管理器有点棘手。 没有任何额外的软件包可供安装;相反,你需要为了加密创建新的自定义操作。完成此操作后,你将能够在文件管理器中执行此操作。
要创建自定义操作,请打开 Thunar 文件管理器,然后单击 “Edit > Configure Custom Actions”。 在所得到的窗口中,单击 “+” 按钮图5并为加密操作输入以下内容
- 名称:加密
- 描述:文件加密
- 命令:`gnome-terminal -x gpg --encrypt --recipient f`
单击 “OK” 以保存此操作。
![Thunar][12]
*图5在Thunar中创建自定义操作。*
注意:如果 gnome-terminal 不是你的默认终端,请替换该命令以打开你的默认终端。
你还可以创建仅使用密码(而非密钥)加密的操作。 为此,该操作的详细动作将会是以下内容:
- 名称:加密密码
- 说明:仅使用密码加密
- 命令:`gnome-terminal -x gpg -c f`
你不需要为解密过程创建一个自定义操作,因为 Thunar 已经知道如何处理一个加密文件。 要解密文件,只需(在 Thunar 中)右键单击它,选择 “Open With Decrypt File”为解密文件命名然后在提示时键入加密密码。 Viola你的加密文件已被解密并可以使用。
### 一个警告
请注意:如果你使用自己的密钥加密自己的文件,则无需输入加密密码来解密它们(因为你的公钥已存储)。 但是,如果你收到(拥有你的公钥的)其他人的文件,则需要输入你的密码。 如果你想要存储自己的加密文件,而不是使用密钥来加密它们,请使用仅使用密码加密。 Nautilus 和Thunar但不是 KDE可以做到这一点。 通过选择密码加密(通过密钥加密),当你解密文件时,它将始终提示你输入密码。
### 其他文件管理器
还有很多其它的文件管理器,它们中的一些可以使用加密,有些则不能。 你很有可能正在使用这三种工具中的一种,因此不仅可以将加密 / 解密添加到上下文菜单,而且是非常容易。 尝试一下,看看它是否会使加密和解密的过程变得更容易。
从 Linux 基金会和 edX 免费提供的[“Linux 介绍”][13]课程了解更多关于 Linux 的信息。
--------------------------------------------------------------------------------
via: https://www.linux.com/learn/intro-to-linux/2018/3/how-encrypt-files-within-file-manager
作者:[JACK WALLEN][a]
译者:[Auk7f7](https://github.com/Auk7f7)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.linux.com/users/jlwallen
[1]:https://www.gnupg.org/
[3]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/nautilus.jpg?itok=ae7Gtj60 "nautilus"
[4]:https://www.linux.com/licenses/category/used-permission
[6]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/nautilus_2.jpg?itok=3ht7j63n "nautilus"
[8]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kde_0.jpg?itok=KSTctVw0 "Dolphin"
[10]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kde_2.jpg?itok=CeqWikNl "Dolphin"
[12]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/thunar.jpg?itok=fXcHk08B "Thunar"
[13]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux

View File

@ -1,22 +1,16 @@
# 理解指标和使用 Python 去监视
理解监测指标,并使用 Python 去监测它们
======
> 通过学习这些关键的术语和概念来理解 Python 应用监测。
![Understanding metrics and monitoring with Python](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/metrics_graph_stats_blue.png?itok=OKCc_60D "Understanding metrics and monitoring with Python")
Image by : 
当我第一次看到术语“<ruby>计数器<rt>counter</rt></ruby>”和“<ruby>计量器<rt>gauge</rt></ruby>”和使用颜色及标记着“平均数”和“大于 90%”的数字图表时,我的反应之一是逃避。就像我看到它们一样,我并不感兴趣,因为我不理解它们是干什么的或如何去使用。因为我的工作不需要我去注意它们,它们被我完全无视。
opensource.com
这都是在两年以前的事了。随着我的职业发展,我希望去了解更多关于我们的网络应用程序的知识,而那个时候就是我开始去学习<ruby>监测指标<rt>metrics</rt></ruby>的时候。
## 获取订阅
我的理解监测的学习之旅共有三个阶段(到目前为止),它们是:
加入我们吧,我们有 85,000 位开源支持者,加入后会定期接收到我们免费提供的提示和文章摘要。
当我第一次看到术语“计数器”和“计量器”和使用颜色及标记着“意思”和“最大 90”的数字图表时我的反应之一是逃避。就像我看到它们一样我并不感兴趣因为我不理解它们是干什么的或如何去使用。因为我的工作不需要我去注意它们它们被我完全无视。
这都是在两年以前的事了。随着我的职业发展,我希望去了解更多关于我们的网络应用程序的知识,而那个时候就是我开始去学习指标的时候。
我的理解监视的学习之旅共有三个阶段(到目前为止),它们是:
* 阶段 1什么看别处
* 阶段 1什么王顾左右
* 阶段 2没有指标我们真的是瞎撞。
* 阶段 3出现不合理的指标我们该如何做
@ -24,21 +18,13 @@ opensource.com
我们开始吧!
## 需要的软件
更多关于 Python 的资源
* [Python 是什么?][1]
* [Python IDE 排行榜][2]
* [Python GUI 框架排行榜][3]
* [最新的 Python 主题][4]
* [更多开发者资源][5]
### 需要的软件
在文章中讨论时用到的 demo 都可以在 [我的 GitHub 仓库][6] 中找到。你需要安装 docker 和 docker-compose 才能使用它们。
## 为什么要监视
### 为什么要监测?
关于监的主要原因是:
关于监测的主要原因是:
* 理解 _正常的__不正常的_ 系统和服务的特征
* 做容量规划、弹性伸缩
@ -47,43 +33,43 @@ opensource.com
* 测量响应中的系统行为变化
* 当系统出现意外行为时发出警报
## 指标和指标类型
### 指标和指标类型
从我们的用途来看,一个**指标**就是在一个给定时间点上的某些数量的 _测量_ 值。博客文章的总点击次数、参与讨论的总人数、在缓存系统中数据没有被找到的次数、你的网站上的已登录用户数 —— 这些都是指标的例子。
从我们的用途来看,一个**指标**就是在一个给定*时间*点上的某些数量的 _测量_ 值。博客文章的总点击次数、参与讨论的总人数、在缓存系统中数据没有被找到的次数、你的网站上的已登录用户数 —— 这些都是指标的例子。
它们总体上可以分为三类:
### 计数器
#### 计数器
以你的个人博客为例。你发布一篇文章后,过一段时间后,你希望去了解有多少点击量,数字只会增加。这就是一个**计数器**指标。在你的博客文章的生命周期中,它的值从 0 开始增加。用图表来表示,一个计数器看起来应该像下面的这样:
以你的个人博客为例。你发布一篇文章后,过一段时间后,你希望去了解有多少点击量,这是一个只会增加的数字。这就是一个<ruby>计数器<rt>counter</rt></ruby>指标。在你的博客文章的生命周期中,它的值从 0 开始增加。用图表来表示,一个计数器看起来应该像下面的这样:
![Counter metric](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/counter-graph.png?itok=BZYrB-Hn "Counter metric")
一个计数器指标总是在增加的。
*一个计数器指标总是在增加的。*
### 计量器
#### 计量器
如果你想去跟踪你的博客每天或每周的点击量,而不是基于时间的总点击量。这种指标被称为一个**计量器**,它的值可上可下。用图表来表示,一个计量器看起来应该像下面的样子:
如果你想去跟踪你的博客每天或每周的点击量,而不是基于时间的总点击量。这种指标被称为一个<ruby>计量器<rt>gauge</rt></ruby>,它的值可上可下。用图表来表示,一个计量器看起来应该像下面的样子:
![gauge metric](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/gauge-graph.png?itok=UA4u4cwz "gauge metric")
一个计量器指标可以增加或减少。
*一个计量器指标可以增加或减少。*
一个计量器的值在某些时间窗口内通常有一个_最大值_ 和 _最小值_
一个计量器的值在某些时间窗口内通常有一个<ruby>最大值<rt>ceiling</rt></ruby><ruby最小值<rt>floor</rt></ruby>
### 柱状图和计时器
#### 柱状图和计时器
一个**柱状图**(在 Prometheus 中这么叫它)或一个**计时器**(在 StatsD 中这么叫它是跟踪已采样的_观测结果_ 的指标。不像一个计数器类或计量器类指标,柱状图指标的值并不是显示为上或下的样式。我知道这可能并没有太多的意义,并且可能和一个计量器图看上去没有什么不同。它们的同之处在于,你期望使用柱状图数据来做什么,而不是与一个计量器图做比较。因此,监系统需要知道那个指标是一个柱状图类型,它允许你去做哪些事情。
<ruby>柱状图<rt>histogram</rt></ruby>(在 Prometheus 中这么叫它)或<ruby>计时器<rt> timer</rt></ruby>(在 StatsD 中这么叫它)是一个跟踪 _已采样的观测结果_ 的指标。不像一个计数器类或计量器类指标,柱状图指标的值并不是显示为上或下的样式。我知道这可能并没有太多的意义,并且可能和一个计量器图看上去没有什么不同。它们的同之处在于,你期望使用柱状图数据来做什么,而不是与一个计量器图做比较。因此,监系统需要知道那个指标是一个柱状图类型,它允许你去做哪些事情。
![Histogram metric](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/histogram-graph.png?itok=cHI1v7Ly "Histogram metric")
一个柱状图指标可以增加或减少。
*一个柱状图指标可以增加或减少。*
## Demo 1计算和报告指标
### Demo 1计算和报告指标
[Demo 1][7] 是使用 [Flask][8] 框架写的一个基本的 web 应用程序。它演示了我们如何去 _计算__报告_ 指标。
在 src 目录中有 `app.py``src/helpers/middleware.py` 应用程序,包含以下内容:
`src` 目录中有 `app.py``src/helpers/middleware.py` 应用程序,包含以下内容:
```
from flask import request
@ -110,9 +96,9 @@ def setup_metrics(app):
    app.after_request(stop_timer)
```
当在应用程序中调用 `setup_metrics()` 时,它在请求处理之前被配置为调用 `start_timer()` 函数,然后在请求处理之后、响应发送之前调用 `stop_timer()` 函数。在上面的函数中,我们写了时间戳并用它来计算处理请求所花费的时间。
当在应用程序中调用 `setup_metrics()` 时,它配置一个请求处理之前调用 `start_timer()` 函数,然后在请求处理之后、响应发送之前调用 `stop_timer()` 函数。在上面的函数中,我们写了时间戳并用它来计算处理请求所花费的时间。
当我们在 demo1 目录中的 docker-compose 上开始去启动 web 应用程序,然后在一个客户端容器中生成一些对 web 应用程序的请求。你将会看到创建了一个 `src/metrics.csv` 文件它有两个字段timestamp 和 request_latency。
当我们在 `demo1` 目录中运行 `docker-compose up`,它会启动这个 web 应用程序,然后在一个客户端容器中可以生成一些对 web 应用程序的请求。你将会看到创建了一个 `src/metrics.csv` 文件,它有两个字段:`timestamp``request_latency`
通过查看这个文件,我们可以推断出两件事情:
@ -121,45 +107,47 @@ def setup_metrics(app):
没有观测到与指标相关的特征,我们就不能说这个指标与哪个 HTTP 端点有关联,或这个指标是由哪个应用程序的节点所生成的。因此,我们需要使用合适的元数据去限定每个观测指标。
## Statistics 101~~(译者注:这是一本统计学入门教材的名字)~~
### 《Statistics 101》
假如我们回到高中数学,我们应该回忆起一些统计术语,虽然不太确定,但应该包括平均数、中位数、百分位、和柱状图。我们来简要地回顾一下它们,不用去管他们的用法,就像是在上高中一样。
LCTT 译注:这是一本统计学入门教材的名字)
### 平均数
假如我们回到高中数学,我们应该回忆起一些统计术语,虽然不太确定,但应该包括平均数、中位数、百分位和柱状图。我们来简要地回顾一下它们,不用去管它们的用法,就像是在上高中一样。
**平均数**或一系列数字的平均值是将数字汇总然后除以列表的个数。3、2、和 10 的平均数是 (3+2+10)/3 = 5。
#### 平均数
### 中位数
<ruby>平均数<rt>mean</rt></ruby>即一系列数字的平均值是将数字汇总然后除以列表的个数。3、2 和 10 的平均数是 (3+2+10)/3 = 5。
**中位数**是另一种类型的平均但它的计算方式不同它是列表从小到大排序反之亦然后取列表的中间数字。以我们上面的列表中2、3、10中位数是 3。计算并不简单它取决于列表中数字的个数。
#### 中位数
### 百分位
<ruby>中位数<rt>median</rt></ruby>是另一种类型的平均但它的计算方式不同它是列表从小到大排序反之亦然后取列表的中间数字。以我们上面的列表中2、3、10中位数是 3。计算并不是非常直观它取决于列表中数字的个数。
**百分位**是指那个百(千)分比数字低于我们给定的百分数的程度。在一些场景中,百分位是指这个测量值低于我们数据的百(千)分比数字的程度。比如,上面列表中 95% 是 9.29999。百分位的测量范围是 0 到 100不包括。0% 是一组数字的最小分数。你可能会想到它的中位数是 50%,它的结果是 3。
#### 百分位
一些监视系统将百分位称为 `upper_X`,其中 _X_ 就是百分位;`_upper 90_` 指的是值在 90%的位置
<ruby>百分位<rt>percentile</rt></ruby>是指那个百(千)分比数字低于我们给定的百分数的程度。在一些场景中,它是指这个测量值低于我们数据的百(千)分比数字的程度。比如,上面列表中 95% 是 9.29999。百分位的测量范围是 0 到 100不包括。0% 是一组数字的最小分数。你可能会想到它的中位数是 50%,它的结果是 3
### 分位数
一些监测系统将百分位称为 `upper_X`,其中 _X_ 就是百分位;`upper 90` 指的是在 90% 的位置的值。
**q-Quantile** 是将有 _N_ 个数的集合等分为 q_N_ 个集合。**q** 的取值范围为 0 到 1全部都包括。当 **q** 取值为 0.5 时,值就是中位数。分位数和百分位数的关系是,分位数值 **q** 等于 **100_q_** 百分位值。
#### 分位数
### 柱状图
“q-分位数”是将有 _N_ 个数的集合等分为 `qN` 级。`q` 的取值范围为 0 到 1全部都包括。当 `q` 取值为 0.5 时,值就是中位数。(<ruby>分位数<rt>quantile</rt></ruby>)和百分位数的关系是,分位数值 `q` 等于 `100` 百分位值。
**柱状图**这个指标我们早期学习过它是监视系统中一个_详细的实现_。在统计学中一个柱状图是一个将数据分组为 _桶_ 的图表。我们来考虑一个人为的、不同的示例:阅读你的博客的人的年龄。如果你有一些这样的数据,并想将它进行大致的分组,绘制成的柱状图将看起来像下面的这样:
#### 柱状图
<ruby柱状图<rt>histogram</rt></ruby>这个指标我们前面学习过它是监测系统中一个_实现细节_。在统计学中一个柱状图是一个将数据分组为 _桶_ 的图表。我们来考虑一个人为的不同示例:阅读你的博客的人的年龄。如果你有一些这样的数据,并想将它进行大致的分组,绘制成的柱状图将看起来像下面的这样:
![Histogram graph](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/histogram.png?itok=gqfhjB8p "Histogram graph")
### 累积柱状图
#### 累积柱状图
一个**累积柱状图**也是一个柱状图它的每个桶的数包含前一个桶的数因此命名为_累积_。将上面的数据集做成累积柱状图后看起来应该是这样的
一个<ruby>累积柱状图<rt>cumulative histogram</rt></ruby>也是一个柱状图它的每个桶的数包含前一个桶的数因此命名为_累积_。将上面的数据集做成累积柱状图后看起来应该是这样的
![Cumulative histogram](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/cumulative-histogram.png?itok=wIGQdZnT "Cumulative histogram")
### 我们为什么需要做统计?
#### 我们为什么需要做统计?
在上面的 Demo 1 中,我们注意到在我们报告指标时,这里生成了许多数据。当我们将它用于指标时我们需要做统计,因为它们实在是太多了。我们需要的是整体行为,我们没法去处理单个值。我们预期展现出来的值的行为应该是代表我们观察的系统的行为。
在上面的 Demo 1 中,我们注意到在我们报告指标时,这里生成了许多数据。当我们将它用于指标时我们需要做统计,因为它们实在是太多了。我们需要的是整体行为,我们没法去处理单个值。我们预期展现出来的值的行为应该是代表我们观察的系统的行为。
## Demo 2指标上增加特征
### Demo 2指标上增加特征
在我们上面的的 Demo 1 应用程序中当我们计算和报告一个请求的延迟时它指向了一个由一些_特征_ 唯一标识的特定请求。下面是其中一些:
@ -169,7 +157,7 @@ def setup_metrics(app):
如果我们将这些特征附加到要观察的指标上,每个指标将有更多的内容。我们来解释一下 [Demo 2][9] 中添加到我们的指标上的特征。
在写入指标时src/helpers/middleware.py 文件将在 CSV 文件中写入多个列:
在写入指标时,`src/helpers/middleware.py` 文件将在 CSV 文件中写入多个列:
```
node_ids = ['10.0.1.1', '10.1.3.4']
@ -194,20 +182,20 @@ def stop_timer(response):
    return response
```
因为这只是一个演示,在报告指标时,我们将随意的报告一些随机 IP 作为节点的 ID。当我们在 demo2 目录下运行 docker-compose 时,我们的结果将是一个有多个列的 CSV 文件。
因为这只是一个演示,在报告指标时,我们将随意的报告一些随机 IP 作为节点的 ID。当我们在 `demo2` 目录下运行 `docker-compose up` 时,我们的结果将是一个有多个列的 CSV 文件。
### 用 pandas 分析指标
#### 用 pandas 分析指标
我们将使用 [pandas][10] 去分析这个 CSV 文件。运行中的 docker-compose 将打印出一个 URL我们将使用它来打开一个 [Jupyter][11] 会话。一旦我们上传 `Analysis.ipynb notebook` 到会话中,我们就可以将 CSV 文件读入到一个 pandas 数据帧中:
我们将使用 [pandas][10] 去分析这个 CSV 文件。运行 `docker-compose up` 将打印出一个 URL我们将使用它来打开一个 [Jupyter][11] 会话。一旦我们上传 `Analysis.ipynb notebook` 到会话中,我们就可以将 CSV 文件读入到一个 pandas <ruby>数据帧<rt>DataFrame</rt></ruby>中:
```
import pandas as pd
metrics = pd.read_csv('/data/metrics.csv', index_col=0)
```
index_col 指定时间戳作为索引。
`index_col` 表明我们要指定时间戳作为索引。
因为每个特征我们都在数据帧中添加一个列,因此我们可以基于这些列进行分组和聚合:
因为每个特征我们都在数据帧中添加一个列,因此我们可以基于这些列进行分组和聚合:
```
import numpy as np
@ -216,48 +204,48 @@ metrics.groupby(['node_id', 'http_status']).latency.aggregate(np.percentile, 99.
更多内容请参考 Jupyter notebook 在数据上的分析示例。
## 我应该监视什么?
### 我应该监测什么?
一个软件系统有许多的变量,这些变量的值在它的生命周期中不停地发生变化。软件是运行在某种操作系统上的,而操作系统同时也在不停地变化。在我看来,当某些东西出错时,你所拥有的数据越多越好。
我建议去监的关键操作系统指标有:
我建议去监的关键操作系统指标有:
* CPU 使用
* 系统内存使用
* 文件描述符使用
* 磁盘使用
还需要监的其它关键指标根据你的软件应用程序不同而不同。
还需要监的其它关键指标根据你的软件应用程序不同而不同。
### 网络应用程序
#### 网络应用程序
如果你的软件是一个监听客户端请求和为它提供服务的网络应用程序,需要测量的关键指标还有:
* 入站请求数(计数器)
* 未处理的错误(计数器)
* 请求延迟(柱状图/计时器)
* 队时间,如果在你的应用程序中有队列(柱状图/计时器)
* 队时间,如果在你的应用程序中有队列(柱状图/计时器)
* 队列大小,如果在你的应用程序中有队列(计量器)
* 工作进程/线程使用(计量器)
* 工作进程/线程用(计量器)
如果你的网络应用程序在一个客户端请求的环境中向其它服务发送请求,那么它应该有一个指标去记录它与那个服务之间的通讯行为。需要监的关键指标包括请求数、请求延迟、和响应状态。
如果你的网络应用程序在一个客户端请求的环境中向其它服务发送请求,那么它应该有一个指标去记录它与那个服务之间的通讯行为。需要监的关键指标包括请求数、请求延迟、和响应状态。
### HTTP web 应用程序后端
#### HTTP web 应用程序后端
HTTP 应用程序应该监视上面所列出的全部指标。除此之外,还应该按 HTTP 状态代码分组监视所有非 200 的 HTTP 状态代码的大致数据。如果你的 web 应用程序有用户注册和登录功能,同时也应该为这个功能设置指标。
HTTP 应用程序应该监测上面所列出的全部指标。除此之外,还应该按 HTTP 状态代码分组监测所有非 200 的 HTTP 状态代码的大致数据。如果你的 web 应用程序有用户注册和登录功能,同时也应该为这个功能设置指标。
### 长周期运行的进程
#### 长时间运行的进程
周期运行的进程如 Rabbit MQ 消费者或 task-queue 工作进程,虽然它们不是网络服务,它们以选取一个任务并处理它的工作模型来运行。因此,我们应该监请求的进程数和这些进程的请求延迟。
时间运行的进程如 Rabbit MQ 消费者或任务队列的工作进程,虽然它们不是网络服务,它们以选取一个任务并处理它的工作模型来运行。因此,我们应该监请求的进程数和这些进程的请求延迟。
不管是什么类型的应用程序,都有指标与合适的**元数据**相关联。
## 将监视集成到一个 Python 应用程序中
### 将监测集成到一个 Python 应用程序中
将监集成到 Python 应用程序中需要涉及到两个组件:
将监集成到 Python 应用程序中需要涉及到两个组件:
* 更新你的应用程序去计算和报告指标
* 配置一个监基础设施来容纳应用程序的指标,并允许去查询它们
* 配置一个监基础设施来容纳应用程序的指标,并允许去查询它们
下面是记录和报告指标的基本思路:
@ -276,15 +264,15 @@ def work():
考虑到上面的模式,我们经常使用修饰符、内容管理器、中间件(对于网络应用程序)所带来的好处去计算和报告指标。在 Demo 1 和 Demo 2 中,我们在一个 Flask 应用程序中使用修饰符。
### 指标报告时的拉取和推送模型
#### 指标报告时的拉取和推送模型
大体来说,在一个 Python 应用程序中报告指标有两种模式。在 _拉取_ 模型中,监系统在一个预定义的 HTTP 端点上“刮取”应用程序。在_推送_ 模型中,应用程序发送数据到监系统。
大体来说,在一个 Python 应用程序中报告指标有两种模式。在 _拉取_ 模型中,监系统在一个预定义的 HTTP 端点上“刮取”应用程序。在_推送_ 模型中,应用程序发送数据到监系统。
![Pull and push models](https://opensource.com/sites/default/files/styles/panopoly_image_original/public/u128651/pull_push_model.png?itok=U093wSy8 "Pull and push models")
工作在 _拉取_ 模型中的监系统的一个例子是 [Prometheus][12]。而 [StatsD][13] 是 _推送_ 模型的一个例子。
工作在 _拉取_ 模型中的监系统的一个例子是 [Prometheus][12]。而 [StatsD][13] 是 _推送_ 模型的一个例子。
### 集成 StatsD
#### 集成 StatsD
将 StatsD 集成到一个 Python 应用程序中,我们将使用 [StatsD Python 客户端][14],然后更新我们的指标报告部分的代码,调用合适的库去推送数据到 StatsD 中。
@ -308,13 +296,13 @@ statsd.timing(key, resp_time)
statsd.incr(key)
```
将指标关联到元数据上一个键的定义为metadata1.metadata2.metric其中每个 metadataX 是一个可以进行聚合和分组的字段。
将指标关联到元数据上,一个键的定义为:`metadata1.metadata2.metric`,其中每个 metadataX 是一个可以进行聚合和分组的字段。
这个演示应用程序 [StatsD][15] 是将 statsd 与 Python Flask 应用程序集成的一个完整示例。
### 集成 Prometheus
#### 集成 Prometheus
去使用 Prometheus 监视系统,我们使用 [Promethius Python 客户端][16]。我们将首先去创建有关的指标类对象:
要使用 Prometheus 监测系统,我们使用 [Promethius Python 客户端][16]。我们将首先去创建有关的指标类对象:
```
REQUEST_LATENCY = Histogram('request_latency_seconds', 'Request latency',
@ -340,76 +328,76 @@ def metrics():
这个演示应用程序 [Prometheus][17] 是将 prometheus 与 Python Flask 应用程序集成的一个完整示例。
### 哪个更好StatsD 还是 Prometheus
#### 哪个更好StatsD 还是 Prometheus
本能地想到的下一个问题便是:我应该使用 StatsD 还是 Prometheus关于这个主题我写了几篇文章你可能发现它们对你很有帮助
* [Your options for monitoring multi-process Python applications with Prometheus][18]
* [Monitoring your synchronous Python web applications using Prometheus][19]
* [Monitoring your asynchronous Python web applications using Prometheus][20]
* [使用 Prometheus 监测多进程 Python 应用的方式][18]
* [使用 Prometheus 监测你的同步 Python 应用][19]
* [使用 Prometheus 监测你的异步 Python 应用][20]
## 指标的使用方式
### 指标的使用方式
我们已经学习了一些关于为什么要在我们的应用程序上配置监的原因,而现在我们来更深入地研究其中的两个用法:报警和自动扩展。
我们已经学习了一些关于为什么要在我们的应用程序上配置监的原因,而现在我们来更深入地研究其中的两个用法:报警和自动扩展。
### 使用指标进行报警
#### 使用指标进行报警
指标的一个关键用途是创建警报。例如,假如过去的五分钟,你的 HTTP 500 的数量持续增加,你可能希望给相关的人发送一封电子邮件或页面提示。对于配置警报做什么取决于我们的监设置。对于 Prometheus 我们可以使用 [Alertmanager][21],而对于 StatsD我们使用 [Nagios][22]。
指标的一个关键用途是创建警报。例如,假如过去的五分钟,你的 HTTP 500 的数量持续增加,你可能希望给相关的人发送一封电子邮件或页面提示。对于配置警报做什么取决于我们的监设置。对于 Prometheus 我们可以使用 [Alertmanager][21],而对于 StatsD我们使用 [Nagios][22]。
### 使用指标进行自动扩展
#### 使用指标进行自动扩展
在一个云基础设施中,如果我们当前的基础设施供应过量或供应不足,通过指标不仅可以让我们知道,还可以帮我们实现一个自动伸缩的策略。例如,如果在过去的五分钟里,在我们服务器上的工作进程使用率达到 90%我们可以水平扩展。我们如何去扩展取决于云基础设施。AWS 的自动扩展,缺省情况下,扩展策略是基于系统的 CPU 使用率、网络流量、以及其它因素。然而,让基础设施伸缩的应用程序指标,我们必须发布 [自定义的 CloudWatch 指标][23]。
## 在多服务架构中的应用程序监视
### 在多服务架构中的应用程序监测
当我们超越一个单应用程序架构时,比如当客户端的请求在响应被发回之前,能够触发调用多个服务,就需要从我们的指标中获取更多的信息。我们需要一个统一的延迟视图指标,这样我们就能够知道响应这个请求时每个服务花费了多少时间。这可以用 [distributed tracing][24] 来实现。
当我们超越一个单应用程序架构时,比如当客户端的请求在响应被发回之前,能够触发调用多个服务,就需要从我们的指标中获取更多的信息。我们需要一个统一的延迟视图指标,这样我们就能够知道响应这个请求时每个服务花费了多少时间。这可以用 [分布式跟踪][24] 来实现。
你可以在我的博客文章 [在你的 Python 应用程序中通过 Zipkin 引入分布式跟踪][25] 中看到在 Python 中进行分布式跟踪的示例。
你可以在我的博客文章 [在你的 Python 应用程序中通过 Zipkin 引入分布式跟踪][25] 中看到在 Python 中进行分布式跟踪的示例。
## 划重点
### 划重点
总之,你需要记住以下几点:
* 理解你的监系统中指标类型的含义
* 知道监系统需要的你的数据的测量单位
* 监你的应用程序中的大多数关键组件
* 监你的应用程序在它的大多数关键阶段的行为
* 理解你的监系统中指标类型的含义
* 知道监系统需要的你的数据的测量单位
* 监你的应用程序中的大多数关键组件
* 监你的应用程序在它的大多数关键阶段的行为
以上要点是假设你不去管理你的监视系统。如果管理你的监视系统是你的工作的一部分,那么你还要考虑更多的问题!
以上要点是假设你不去管理你的监测系统。如果管理你的监测系统是你的工作的一部分,那么你还要考虑更多的问题!
## 其它资源
### 其它资源
以下是我在我的监学习过程中找到的一些非常有用的资源:
以下是我在我的监学习过程中找到的一些非常有用的资源:
### 综合的
#### 综合的
* [监分布式系统][26]
* [观测和监最佳实践][27]
* [监分布式系统][26]
* [观测和监最佳实践][27]
* [谁想使用秒?][28]
### StatsD/Graphite
#### StatsD/Graphite
* [StatsD 指标类型][29]
### Prometheus
#### Prometheus
* [Prometheus 指标类型][30]
* [How does a Prometheus gauge work?][31]
* [Why are Prometheus histograms cumulative?][32]
* [在 Python 中监视批作业][33]
* [Prometheus SoundCloud][34]
* [Prometheus 计量器如何工作?][31]
* [为什么用 Prometheus 累积柱形图?][32]
* [在 Python 中监测批量作业][33]
* [Prometheus SoundCloud][34]
## 避免犯错(即第 3 阶段的学习)
### 避免犯错(即第 3 阶段的学习)
在我们学习监的基本知识时,时刻注意不要犯错误是很重要的。以下是我偶然发现的一些很有见解的资源:
在我们学习监的基本知识时,时刻注意不要犯错误是很重要的。以下是我偶然发现的一些很有见解的资源:
* [How not to measure latency][35]
* [Histograms with Prometheus: A tale of woe][36]
* [Why averages suck and percentiles are great][37]
* [Everything you know about latency is wrong][38]
* [Who moved my 99th percentile latency?][39]
* [Logs and metrics and graphs][40]
* [HdrHistogram: A better latency capture method][41]
* [如何不测量延迟][35]
* [Prometheus 柱形图:悲伤的故事][36]
* [为什么平均值很讨厌,而百分位很棒][37]
* [对延迟的认知错误][38]
* [谁动了我的 99% 延迟?][39]
* [日志、指标和图形][40]
* [HdrHistogram:一个更好的延迟捕获方式][41]
---
@ -419,7 +407,7 @@ def metrics():
[![](https://opensource.com/sites/default/files/styles/profile_pictures/public/osdc_default_avatar_1.png?itok=mmbfqFXm)][44]
Amit Saha — 我是一名对基础设施、监、和工具感兴趣的软件工程师。我是“用 Python 做数学”的作者和创始人,以及 Fedora Scientific Spin 维护者。
Amit Saha — 我是一名对基础设施、监、和工具感兴趣的软件工程师。我是“用 Python 做数学”的作者和创始人,以及 Fedora Scientific Spin 维护者。
[关于我的更多信息][45]
@ -429,7 +417,7 @@ Amit Saha — 我是一名对基础设施、监视、和工具感兴趣的软件
via: [https://opensource.com/article/18/4/metrics-monitoring-and-python][47]
作者: [Amit Saha][48] 选题者: [@lujun9972][49] 译者: [qhwdw][50] 校对: [校对者ID][51]
作者: [Amit Saha][48] 选题者: [lujun9972][49] 译者: [qhwdw][50] 校对: [wxy][51]
本文由 [LCTT][52] 原创编译,[Linux中国][53] 荣誉推出
@ -483,6 +471,6 @@ via: [https://opensource.com/article/18/4/metrics-monitoring-and-python][47]
[48]: https://opensource.com/users/amitsaha
[49]: https://github.com/lujun9972
[50]: https://github.com/qhwdw
[51]: https://github.com/校对者ID
[51]: https://github.com/wxy
[52]: https://github.com/LCTT/TranslateProject
[53]: https://linux.cn/

View File

@ -0,0 +1,431 @@
如何在 Linux 上检查一个软件包的详细信息
======
我们可以就这个已经被广泛讨论的话题写出大量的文章,大多数情况下,因为各种各样的原因,我们都愿意让<ruby>包管理器<rt>package manager</rt></ruby>来帮我们做这些事情。
每个 Linux 发行版都有自己的包管理器,并且每个都有各自有不同的特性,这些特性包括允许用户执行安装新软件包,删除无用的软件包,更新现存的软件包,搜索某些具体的软件包,以及更新整个系统到其最新的状态之类的操作。
习惯于命令行的用户大多数时间都会使用基于命令行方式的包管理器。对于 Linux 而言,这些基于命令行的包管理器有 `yum`、`dnf`、`rpm`、`apt`、`apt-get`、`dpkg`、`pacman` 和 `zypper`
**推荐阅读**
- [Linux 命令行包管理器列表及其用法][1]
- [一个图形化的 Linux 包管理器前端工具][2]
- [如何搜索知道一个软件包是否存在于你的 Linux 发行版][3]
- [如何使用 dnf/yum 配置包管理器在 Linux 上来添加、启用和禁用软件仓库][4]
作为一个系统管理员你应该清楚地知道:安装包来自何方,具体来自哪个软件仓库,包的具体版本,包的大小,版本,包的源代码 URL包的许可证信息等等。
这篇短文将用尽可能简单的方式帮你从随包自带的总结和描述中了解该包的用法。按你所使用的 Linux 发行版的不同,运行下面相应的命令,你能得到你所使用的发行版下的包的详细信息。
### YUM 命令:在 RHEL 和 CentOS 系统上获得包的信息
[YUM][5] 英文直译是“<ruby>黄狗更新器--修改版<rt>Yellowdog Updater, Modified</rt></ruby>”,它是一个开源的基于命令行的包管理器前端实用工具。它被广泛应用在基于 RPM 的系统上例如RHEL 和 CentOS。
Yum 是用于在官方发行版仓库以及其他第三方发行版仓库下获取、安装、删除、查询 RPM 包的主要工具。
LCTT 译注:用 `yum info` 获取 python 包的信息)
```
# yum info python
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* epel: epel.mirror.constant.com
Installed Packages
Name : python
Arch : x86_64
Version : 2.6.6
Release : 66.el6_8
Size : 78 k
Repo : installed
From repo : updates
Summary : An interpreted, interactive, object-oriented programming language
URL : http://www.python.org/
License : Python
Description : Python is an interpreted, interactive, object-oriented programming
: language often compared to Tcl, Perl, Scheme or Java. Python includes
: modules, classes, exceptions, very high level dynamic data types and
: dynamic typing. Python supports interfaces to many system calls and
: libraries, as well as to various windowing systems (X11, Motif, Tk,
: Mac and MFC).
:
: Programmers can write new built-in modules for Python in C or C++.
: Python can be used as an extension language for applications that need
: a programmable interface.
:
: Note that documentation for Python is provided in the python-docs
: package.
:
: This package provides the "python" executable; most of the actual
: implementation is within the "python-libs" package.
```
### YUMDB 命令:查看 RHEL 和 CentOS 系统上的包信息
`yumdb info` 这个命令提供与 `yum info` 相类似的的信息,不过它还额外提供了诸如包校验值、包类型、用户信息(由何人安装)。从 yum 3.2.26 版本后,`yum` 开始在 rpm 数据库外储存额外的信息了(此处如显示 `user` 表明该包由用户安装,而 `dep` 说明该包是被作为被依赖的包而被安装的)。
LCTT 译注:用 `yumdb info` 来获取 python 包的信息)
```
# yumdb info python
Loaded plugins: fastestmirror
python-2.6.6-66.el6_8.x86_64
changed_by = 4294967295
checksum_data = 53c75a1756e5b4f6564c5229a37948c9b4561e0bf58076bd7dab7aff85a417f2
checksum_type = sha256
command_line = update -y
from_repo = updates
from_repo_revision = 1488370672
from_repo_timestamp = 1488371100
installed_by = 4294967295
reason = dep
releasever = 6
```
### RPM 命令:在 RHEL/CentOS/Fedora 系统上查看包的信息
[RPM][6] 英文直译为“<ruby>红帽包管理器<rt>Red Hat Package Manager</rt></ruby>”,这是一个在 RedHat 以及其变种发行版如RHEL、CentOS、Fedora、openSUSE、Megeia下的功能强大的命令行包管理工具。它能让你轻松的安装、升级、删除、查询以及校验你的系统或服务器上的软件。RPM 文件以 `.rpm` 结尾。RPM 包由它所依赖的软件库以及其他依赖构成,它不会与系统上已经安装的包冲突。
LCTT 译注:用 `rpm -qi` 查询 nano 包的具体信息)
```
# rpm -qi nano
Name : nano Relocations: (not relocatable)
Version : 2.0.9 Vendor: CentOS
Release : 7.el6 Build Date: Fri 12 Nov 2010 02:18:36 AM EST
Install Date: Fri 03 Mar 2017 08:57:47 AM EST Build Host: c5b2.bsys.dev.centos.org
Group : Applications/Editors Source RPM: nano-2.0.9-7.el6.src.rpm
Size : 1588347 License: GPLv3+
Signature : RSA/8, Sun 03 Jul 2011 12:46:50 AM EDT, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem
URL : http://www.nano-editor.org
Summary : A small text editor
Description :
GNU nano is a small and friendly text editor.
```
### DNF 命令:在 Fedora 系统上查看包信息
[DNF][7] 指“<ruby>时髦版的 Yum<rt>Dandified yum</rt></ruby>”,我们也可以认为 DNF 是下一代的 yum 包管理器Yum 的一个分支),它在后台使用了 hawkey/libsolv 库。Aleš Kozumplík 在Fedora 18 上开始开发 DNF在 Fedora 22 上正式最后发布。 `dnf` 命令用来在 Fedora 22 及以后的系统上安装、更新、搜索以及删除包。它能自动的解决包安装过程中的包依赖问题。
LCTT 译注: 用 `dnf info` 查看 tilix 包信息)
```
$ dnf info tilix
Last metadata expiration check: 27 days, 10:00:23 ago on Wed 04 Oct 2017 06:43:27 AM IST.
Installed Packages
Name : tilix
Version : 1.6.4
Release : 1.fc26
Arch : x86_64
Size : 3.6 M
Source : tilix-1.6.4-1.fc26.src.rpm
Repo : @System
From repo : @commandline
Summary : Tiling terminal emulator
URL : https://github.com/gnunn1/tilix
License : MPLv2.0 and GPLv3+ and CC-BY-SA
Description : Tilix is a tiling terminal emulator with the following features:
:
: - Layout terminals in any fashion by splitting them horizontally or vertically
: - Terminals can be re-arranged using drag and drop both within and between
: windows
: - Terminals can be detached into a new window via drag and drop
: - Input can be synchronized between terminals so commands typed in one
: terminal are replicated to the others
: - The grouping of terminals can be saved and loaded from disk
: - Terminals support custom titles
: - Color schemes are stored in files and custom color schemes can be created by
: simply creating a new file
: - Transparent background
: - Supports notifications when processes are completed out of view
:
: The application was written using GTK 3 and an effort was made to conform to
: GNOME Human Interface Guidelines (HIG).
```
### Zypper 命令:在 openSUSE 系统上查看包信息
[zypper][8] 是一个使用 libzypp 库的命令行包管理器。`zypper` 提供诸如软件仓库访问,安装依赖解决,软件包安装等等功能。
LCTT 译注: 用 `zypper info` 查询 nano 包的信息)
```
$ zypper info nano
Loading repository data...
Reading installed packages...
Information for package nano:
-----------------------------
Repository : Main Repository (OSS)
Name : nano
Version : 2.4.2-5.3
Arch : x86_64
Vendor : openSUSE
Installed Size : 1017.8 KiB
Installed : No
Status : not installed
Source package : nano-2.4.2-5.3.src
Summary : Pico editor clone with enhancements
Description :
GNU nano is a small and friendly text editor. It aims to emulate
the Pico text editor while also offering a few enhancements.
```
### Pacman 命令:在 ArchLinux 及 Manjaro 系统上查看包信息
[Pacman][9] 意即<ruby>包管理器<rt>package manager</rt></ruby>实用工具。`pacman` 是一个用于安装、构建、删除、管理 Arch Linux 上包的命令行工具。它后端使用 libalpmArch Linux package ManagerALPM来完成所有功能。
LCTT 译注: 用 `pacman -Qi` 来查询 bash 包信息)
```
$ pacman -Qi bash
Name : bash
Version : 4.4.012-2
Description : The GNU Bourne Again shell
Architecture : x86_64
URL : http://www.gnu.org/software/bash/bash.html
Licenses : GPL
Groups : base
Provides : sh
Depends On : readline>=7.0 glibc ncurses
Optional Deps : bash-completion: for tab completion
Required By : autoconf automake bison bzip2 ca-certificates-utils db
dhcpcd diffutils e2fsprogs fakeroot figlet findutils
flex freetype2 gawk gdbm gettext gmp grub gzip icu
iptables keyutils libgpg-error libksba libpcap libpng
libtool lvm2 m4 man-db mkinitcpio nano neofetch nspr
nss openresolv os-prober pacman pcre pcre2 shadow
systemd texinfo vte-common which xdg-user-dirs xdg-utils
xfsprogs xorg-mkfontdir xorg-xpr xz
Optional For : None
Conflicts With : None
Replaces : None
Installed Size : 7.13 MiB
Packager : Jan Alexander Steffens (heftig)
Build Date : Tue 14 Feb 2017 01:16:51 PM UTC
Install Date : Thu 24 Aug 2017 06:08:12 AM UTC
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature
```
### apt-cache 命令:在 Debian/Ubuntu/Mint 系统上查看包信息
[apt-cache][10] 命令能显示 apt 内部数据库中的大量信息。这些信息是从 `sources.list` 中的不同的软件源中搜集而来,因此从某种意义上这些信息也可以被认为是某种缓存。这些信息搜集工作是在运行 `apt update` 命令时执行的。
LCTT 译注:用管理员权限查询 apache2 包的信息)
```
$ sudo apt-cache show apache2
Package: apache2
Priority: optional
Section: web
Installed-Size: 473
Maintainer: Ubuntu Developers
Original-Maintainer: Debian Apache Maintainers
Architecture: amd64
Version: 2.4.12-2ubuntu2
Replaces: apache2.2-common
Provides: httpd, httpd-cgi
Depends: lsb-base, procps, perl, mime-support, apache2-bin (= 2.4.12-2ubuntu2), apache2-utils (>= 2.4), apache2-data (= 2.4.12-2ubuntu2)
Pre-Depends: dpkg (>= 1.17.14)
Recommends: ssl-cert
Suggests: www-browser, apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, ufw
Conflicts: apache2.2-common (<< 2.3~)
Filename: pool/main/a/apache2/apache2_2.4.12-2ubuntu2_amd64.deb
Size: 91348
MD5sum: ab0ee0b0d1c6b3d19bd87aa2a9537125
SHA1: 350c9a1a954906088ed032aebb77de3d5bb24004
SHA256: 03f515f7ebc3b67b050b06e82ebca34b5e83e34a528868498fce020bf1dbbe34
Description-en: Apache HTTP Server
The Apache HTTP Server Project's goal is to build a secure, efficient and
extensible HTTP server as standards-compliant open source software. The
result has long been the number one web server on the Internet.
.
Installing this package results in a full installation, including the
configuration files, init scripts and support scripts.
Description-md5: d02426bc360345e5acd45367716dc35c
Homepage: http://httpd.apache.org/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 9m
Task: lamp-server, mythbuntu-frontend, mythbuntu-desktop, mythbuntu-backend-slave, mythbuntu-backend-master, mythbuntu-backend-master
```
### APT 命令:查看 Debian/Ubuntu/Mint 系统上的包信息
[APT][11] 意为<ruby>高级打包工具<rt>Advanced Packaging Tool</rt></ruby>,就像 DNF 将如何替代 YUM 一样APT 是 apt-get 的替代物。它功能丰富的命令行工具包括了如下所有命令的功能如 `apt-cache`、`apt-search`、`dpkg`、`apt-cdrom`、`apt-config`、`apt-key` 等等,我们可以方便的通过 `apt` 来安装 `.dpkg` 包,但是我们却不能通过 `apt-get` 来完成这一点,还有一些其他的类似的功能也不能用 `apt-get` 来完成,所以 `apt-get` 因为没有解决上述功能缺乏的原因而被 `apt` 所取代。
LCTT 译注: 用 `apt show` 查看 nano 包信息)
```
$ apt show nano
Package: nano
Version: 2.8.6-3
Priority: standard
Section: editors
Origin: Ubuntu
Maintainer: Ubuntu Developers
Original-Maintainer: Jordi Mallach
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 766 kB
Depends: libc6 (>= 2.14), libncursesw5 (>= 6), libtinfo5 (>= 6)
Suggests: spell
Conflicts: pico
Breaks: nano-tiny (<< 2.8.6-2)
Replaces: nano-tiny (<< 2.8.6-2), pico
Homepage: https://www.nano-editor.org/
Task: standard, ubuntu-touch-core, ubuntu-touch
Supported: 9m
Download-Size: 222 kB
APT-Manual-Installed: yes
APT-Sources: http://in.archive.ubuntu.com/ubuntu artful/main amd64 Packages
Description: small, friendly text editor inspired by Pico
GNU nano is an easy-to-use text editor originally designed as a replacement
for Pico, the ncurses-based editor from the non-free mailer package Pine
(itself now available under the Apache License as Alpine).
.
However, GNU nano also implements many features missing in pico, including:
- undo/redo
- line numbering
- syntax coloring
- soft-wrapping of overlong lines
- selecting text by holding Shift
- interactive search and replace (with regular expression support)
- a go-to line (and column) command
- support for multiple file buffers
- auto-indentation
- tab completion of filenames and search terms
- toggling features while running
- and full internationalization support
```
### dpkg 命令查看Debian/Ubuntu/Mint系统上的包信息
[dpkg][12] 意指 <ruby>Debian 包管理器<rt>Debian package manager</rt></ruby>。`dpkg` 是用于 Debian 系统上安装、构建、移除以及管理 Debian 包的命令行工具。`dpkg` 使用 `aptitude`(因为它更为主流及用户友好)作为前端工具来完成所有的功能。其他的工具如` dpkg-deb` 和 `dpkg-query` 使用 `dpkg` 做为前端来实现功能。尽管系统管理员还是时不时会在必要时使用 `dpkg` 来完成一些软件安装的任务,他大多数情况下还是会因为 `apt`、`apt-get` 以及 `aptitude` 的健壮性而使用后者。
LCTT 译注: 用 `dpkg -s` 查看 python 包的信息)
```
$ dpkg -s python
Package: python
Status: install ok installed
Priority: optional
Section: python
Installed-Size: 626
Maintainer: Ubuntu Developers
Architecture: amd64
Multi-Arch: allowed
Source: python-defaults
Version: 2.7.14-2ubuntu1
Replaces: python-dev (<< 2.6.5-2)
Provides: python-ctypes, python-email, python-importlib, python-profiler, python-wsgiref
Depends: python2.7 (>= 2.7.14-1~), libpython-stdlib (= 2.7.14-2ubuntu1)
Pre-Depends: python-minimal (= 2.7.14-2ubuntu1)
Suggests: python-doc (= 2.7.14-2ubuntu1), python-tk (>= 2.7.14-1~)
Breaks: update-manager-core (<< 0.200.5-2)
Conflicts: python-central (<< 0.5.5)
Description: interactive high-level object-oriented language (default version)
Python, the high-level, interactive object oriented language,
includes an extensive class library with lots of goodies for
network programming, system administration, sounds and graphics.
.
This package is a dependency package, which depends on Debian's default
Python version (currently v2.7).
Homepage: http://www.python.org/
Original-Maintainer: Matthias Klose
```
我们也可使用 `dpkg``-p` 选项,这个选项提供和 `dpkg -s` 相类似的信息,但是它还提供了包的校验值和包类型。
LCTT 译注: 用 `dpkg -p` 查看 python3 包的信息)
```
$ dpkg -p python3
Package: python3
Priority: important
Section: python
Installed-Size: 67
Origin: Ubuntu
Maintainer: Ubuntu Developers
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Architecture: amd64
Multi-Arch: allowed
Source: python3-defaults
Version: 3.6.3-0ubuntu2
Replaces: python3-minimal (<< 3.1.2-2)
Provides: python3-profiler
Depends: python3.6 (>= 3.6.3-1~), libpython3-stdlib (= 3.6.3-0ubuntu2), dh-python
Pre-Depends: python3-minimal (= 3.6.3-0ubuntu2)
Suggests: python3-doc (>= 3.6.3-0ubuntu2), python3-tk (>= 3.6.3-1~), python3-venv (>= 3.6.3-0ubuntu2)
Filename: pool/main/p/python3-defaults/python3_3.6.3-0ubuntu2_amd64.deb
Size: 8712
MD5sum: a8bae494c6e5d1896287675faf40d373
Description: interactive high-level object-oriented language (default python3 version)
Original-Maintainer: Matthias Klose
SHA1: 2daec885cea7d4dc83c284301c3bebf42b23e095
SHA256: 865e509c91d2504a16c4b573dbe27e260c36fceec2add3fa43a30c1751d7e9bb
Homepage: http://www.python.org/
Task: minimal, ubuntu-core, ubuntu-core
Description-md5: 950ebd8122c0a7340f0a740c295b9eab
Supported: 9m
```
### aptitude 命令:查看 Debian/Ubuntu/Mint 系统上的包信息
`aptitude` 是 Debian GNU/Linux 包管理系统的文本界面。它允许用户查看已安装的包的列表,以及完成诸如安装、升级、删除包之类的包管理任务。这些管理行为也能从图形接口来执行。
LCTT 译注: 用 `aptitude show` 查看 htop 包信息)
```
$ aptitude show htop
Package: htop
Version: 2.0.2-1
State: installed
Automatically installed: no
Priority: optional
Section: universe/utils
Maintainer: Ubuntu Developers
Architecture: amd64
Uncompressed Size: 216 k
Depends: libc6 (>= 2.15), libncursesw5 (>= 6), libtinfo5 (>= 6)
Suggests: lsof, strace
Conflicts: htop:i386
Description: interactive processes viewer
Htop is an ncursed-based process viewer similar to top, but it allows one to scroll the list vertically and horizontally to see all processes and their full command lines.
Tasks related to processes (killing, renicing) can be done without entering their PIDs.
Homepage: http://hisham.hm/htop/
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/how-to-view-detailed-information-about-a-package-in-linux/
作者:[Prakash Subramanian][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[DavidChenLiang](https://github.com/davidchenliang)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.2daygeek.com/author/prakash/
[1]:https://www.2daygeek.com/list-of-command-line-package-manager-for-linux/
[2]:https://www.2daygeek.com/list-of-graphical-frontend-tool-for-linux-package-manager/
[3]:https://www.2daygeek.com/how-to-search-if-a-package-is-available-on-your-linux-distribution-or-not/
[4]:https://www.2daygeek.com/how-to-add-enable-disable-a-repository-dnf-yum-config-manager-on-linux/
[5]:https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/
[6]:https://www.2daygeek.com/rpm-command-examples/
[7]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/
[8]:https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/
[9]:https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/
[10]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/
[11]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/
[12]:https://www.2daygeek.com/dpkg-command-to-manage-packages-on-debian-ubuntu-linux-mint-systems/

View File

@ -1,8 +1,9 @@
Distrochooser 帮助 Linux 初学者选择合适的 Linux 发行版
======
![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-logo-720x340.png)
你好 Linux 新手!今天,我为你们带来了一个好消息!你也许想知道如何选择合适的 Linux 发行版。当然,你可能已经咨询过一些 Linux 专家来帮助你的需要选择 Linux 发行版。你们中的一些人可能已经用 Google 搜索并浏览了各种资源、Linux 论坛、网站和博客来寻找完美的发行版。好了,你不必再那样做了。有了 **Distrochooser**,一个帮助你轻松找到 Linux 发行版的网站。
![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-logo-720x340.png)
你好 Linux 新手!今天,我为你们带来了一个好消息!你也许想知道如何选择合适的 Linux 发行版。当然,你可能已经咨询过一些 Linux 专家来帮助你的需要选择 Linux 发行版。你们中的一些人可能已经用 Google 搜索并浏览了各种资源、Linux 论坛、网站和博客来寻找完美的发行版。好了,你不必再那样做了。有了 **Distrochooser**,一个帮助你轻松找到 Linux 发行版的网站。
### Distrochooser 如何帮助 Linux 初学者选择合适的 Linux 发行版?
@ -11,6 +12,7 @@ Distrochooser 会根据你的答案向你询问一系列问题并建议你尝试
![][2]
你将被重定向到 Distrochooser 主页,其中有一个小测试在等待你注册。
![](https://www.ostechnix.com/wp-content/uploads/2018/08/distrochooser-home-page.png)
你需要回答一系列问题(准确地说是 16 个问题)。问题同时有单选和多选。以下是完整的问题列表。
@ -32,8 +34,6 @@ Distrochooser 会根据你的答案向你询问一系列问题并建议你尝试
15. 软件:管理
16. 软件:更新
仔细阅读问题并在相应问题下面选择合适的答案。Distrochooser 提供了更多选择来选择接近完美的发行版。
* 你总是可以跳过问题,
@ -42,9 +42,7 @@ Distrochooser 会根据你的答案向你询问一系列问题并建议你尝试
* 你可以随时删除答案,
* 你可以在测试结束时对属性进行加权,以强调对你来说重要的内容。
选择问题的答案后,单击**继续**以转到下一个问题。完成后,单击**获取结果**按钮。你也可以通过单击答案下面的**“清除”**按钮随时清除选择。
选择问题的答案后单击“Proceed”以转到下一个问题。完成后单击“Get Result”按钮。你也可以通过单击答案下面的“Clear”按钮随时清除选择。
### 结果?
@ -69,7 +67,7 @@ via: https://www.ostechnix.com/distrochooser-helps-linux-beginners-to-choose-a-s
作者:[SK][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/) 荣誉推出

View File

@ -48,6 +48,7 @@ sub_target: sub_target.c
目标并不要求是一个文件,也可以只是步骤的名字,就如我们的例子中一样。我们称之为“伪目标”。
再回到上面的示例中,当 `make` 被执行时,整条指令 `echo "Hello World"` 都被显示出来,之后才是真正的执行结果。如果不希望指令本身被打印处理,需要在 `echo` 前添加 `@`
```
say_hello:
        @echo "Hello World"

View File

@ -0,0 +1,134 @@
15 个可以节省你时间的命令别名
======
> 在你安装的 Linux 发行版中默认就包含了一些别名。
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_blue.png?itok=IfckxN48)
Linux 命令行别名非常适合帮助你提高工作效率。更好的是,在你安装的 Linux 发行版中默认就包含了一些别名。
这是 Fedora 27 中的命令别名的示例:
![](https://opensource.com/sites/default/files/uploads/default.png)
这个 `alias` 命令列出了已有的别名。设置别名也十分简单:
```
alias new_name="command"
```
这里有 15 个命令行别名,可以节省你的时间:
1、安装任何应用实用 / 应用程序:
```
alias install="sudo yum install -y"
```
在这里,根据每个用户的偏好,`sudo` 和 `-y` 是可选的:
![install alias.png][2]
2、更新系统
```
alias update="sudo yum update -y"
```
3、升级系统
```
alias upgrade="sudo yum upgrade -y"
```
4、切换 root 用户:
```
alias root="sudo su -"
```
5、切换到 “user” 用户, 其中 `user` 设置为你的用户名:
```
alias user="su user"
```
6、显示列出所有可用端口、状态还有 IP
```
alias myip="ip -br -c a"
```
7、`ssh` 到你的服务器 `myserver`
```
alias myserver="ssh user@my_server_ip”
```
8、列出系统中所有进程
```
alias process="ps -aux"
```
9、检查系统的服务状态
```
alias sstatus="sudo systemctl status"
```
10、重启系统服务
```
alias srestart="sudo systemctl restart"
```
11、按名称杀死进程
```
alias kill="sudo pkill"
```
![kill process alias.png][4]
12、显示系统系统总使用内存和空闲内存
```
alias mem="free -h"
```
13、显示系统 CPU 框架结构、CPU 数量、线程数等:
```
alias cpu="lscpu"
```
14、显示系统总磁盘大小
```
alias disk="df -h"
```
15、显示当前系统 Linux 发行版本(适用于 CentOS、Fedora 和 Red Hat)
```
alias os="cat /etc/redhat-release"
```
![system_details alias.png][6]
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/8/time-saving-command-line-aliases
作者:[Aarchit Modi][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[MZqk](https://github.com/MZqk)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux 中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/architmodi
[2]:https://opensource.com/sites/default/files/uploads/install.png (install alias.png)
[4]:https://opensource.com/sites/default/files/uploads/kill.png (kill process alias.png)
[6]:https://opensource.com/sites/default/files/uploads/system_details.png (system_details alias.png)

View File

@ -1,17 +1,15 @@
heguangzhi Translating
8个Linux命令用于有效的进程管理
8 个用于有效地管理进程的 Linux 命令
======
> 通过这些关键的命令来全程管理你的应用。
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/command_line_prompt.png?itok=wbGiJ_yg)
一般来说,应用程序的生命周期有三种主要状态:启动、运行和停止。如果我们想成为称职的管理员,每个状态都可以而且应该得到认真的管理。这八个命令可用于管理进程的整个生命周期。
一般来说,应用程序进程的生命周期有三种主要状态:启动、运行和停止。如果我们想成为称职的管理员,每个状态都可以而且应该得到认真的管理。这八个命令可用于管理进程的整个生命周期。
### 启动进程
启动进程的最简单方法是在命令行中键入其名称,然后按 Enter 键。如果要启动 Nginx web 服务器,请键入 **nginx** 。也许您只是想看看其版本。
启动进程的最简单方法是在命令行中键入其名称,然后按回车键。如果要启动 Nginx web 服务器,请键入 `nginx` 。也许您只是想看看其版本。
```
alan@workstation:~$ nginx
@ -20,10 +18,9 @@ alan@workstation:~$ nginx -v
nginx version: nginx/1.14.0
```
### 查看您的可执行路径
### 查看您的可执行路径
以上启动进程的演示是假设可执行文件位于您的可执行路径中。理解这条路径是是否启动和管理进程的关键。管理员通常会为他们想要的目的定制这条路径。您可以使用 **echo $PATH** 查看您的可执行路径。
以上启动进程的演示是假设可执行文件位于您的可执行路径中。理解这个路径是可靠地启动和管理进程的关键。管理员通常会为他们想要的目的定制这条路径。您可以使用 `echo $PATH` 查看您的可执行路径。
```
alan@workstation:~$ echo $PATH
@ -32,35 +29,29 @@ alan@workstation:~$ echo $PATH
#### WHICH
使用 which 命令查看可执行文件的完整路径。
使用 `which` 命令查看可执行文件的完整路径。
```
alan@workstation:~$ which nginx                                                    
alan@workstation:~$ which nginx
/opt/nginx/bin/nginx
```
我将使用流行的 web 服务器软件 Nginx 作为我的例子。假设安装了 Nginx。如果执行 **which nginx** 的命令什么也不返回,那么 Nginx 就找不到了,因为它只搜索您指定的可执行路径。有三种方法可以补救一个进程不能简单地通过名字启动的情况。首先是键入完整路径。虽然,我不情愿输入全部路径,您会吗?
我将使用流行的 web 服务器软件 Nginx 作为我的例子。假设安装了 Nginx。如果执行 `which nginx` 的命令什么也不返回,那么是找不到 Nginx 了,因为它只搜索您指定的可执行路径。有三种方法可以补救一个进程不能简单地通过名字启动的情况。首先是键入完整路径 —— 虽然,我不情愿输入全部路径,您会吗?
```
alan@workstation:~$ /home/alan/web/prod/nginx/sbin/nginx -v
nginx version: nginx/1.14.0
```
第二个解决方案是将应用程序安装在可执行文件路径中的目录中。然而,这有时可能是办不到的,特别是如果您没有 root 权限。
第二个解决方案是将应用程序安装在可执行文件路径中的目录中。然而,这可能是不可能的,特别是如果您没有 root 权限。
第三个解决方案是更新您的可执行路径环境变量,包括要使用的特定应用程序的安装目录。这个解决方案是 shell-dependent。例如Bash 用户需要在他们的 .bashrc 文件中编辑 PATH= line。
第三个解决方案是更新您的可执行路径环境变量,包括要使用的特定应用程序的安装目录。这个解决方案是与 shell 相关的。例如Bash 用户需要在他们的 `.bashrc` 文件中编辑 `PATH=` 行。
```
PATH="$HOME/web/prod/nginx/sbin:$PATH"
```
现在,重复您的 echo 和 which命令或者尝试检查版本。容易多了
现在,重复您的 `echo``which` 命令或者尝试检查版本。容易多了!
```
alan@workstation:~$ echo $PATH
@ -77,22 +68,21 @@ nginx version: nginx/1.14.0
#### NOHUP
注销或关闭终端时,进程可能不会继续运行。这种特殊情况可以通过在要使用 `nohup` 命令放在要运行的命令前面让进程持续运行。此外,附加一个`&` 符号将会把进程发送到后台,并允许您继续使用终端。例如,假设您想运行 `myprogram.sh`
注销或关闭终端时,进程可能不会继续运行。这种特殊情况可以通过在要使用 nohup 命令放在要运行的命令前面让进程持续运行。此外,附加一个&符号将会把进程发送到后台,并允许您继续使用终端。例如,假设您想运行 myprogram.sh 。
```
nohup myprogram.sh &
```
nohup 会返回运行进程的PID。接下来我会更多地谈论PID。
`nohup` 会返回运行进程的 PID。接下来我会更多地谈论 PID。
### 管理正在运行的进程
每个进程都有一个唯一的进程标识号 (PID) 。这个数字是我们用来管理每个进程的。我们还可以使用进程名称,我将在下面演示。有几个命令可以检查正在运行的进程的状态。让我们快速看看这些命令。
#### PS
最常见的是 ps 命令。ps 的默认输出是当前终端中运行的进程的简单列表。如下所示第一列包含PID。
最常见的是 `ps` 命令。`ps` 的默认输出是当前终端中运行的进程的简单列表。如下所示,第一列包含 PID。
```
alan@workstation:~$ ps
@ -101,8 +91,8 @@ PID TTY          TIME CMD
24148 pts/0    00:00:00 ps
```
我想看看我之前启动的 Nginx 进程。为此,我告诉 `ps` 给我展示每一个正在运行的进程(`-e`)和完整的列表(`-f`)。
我想看看我之前开始的 Nginx 进程。为此,我告诉 ps 给我展示每一个正在运行的进程( **-e** ) 和完整的列表 ( **-f** )。
```
alan@workstation:~$ ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
@ -128,20 +118,19 @@ alan     20536 20526  0 10:39 pts/0    00:00:00 pager
alan     20564 20496  0 10:40 pts/1    00:00:00 bash
```
您可以在上面 `ps` 命令的输出中看到 Nginx 进程。这个命令显示了将近 300 行,但是我在这个例子中缩短了它。可以想象,试图处理 300 行过程信息有点混乱。我们可以将这个输出输送到 `grep`,过滤一下仅显示 nginx。
您可以在上面 ps 命令的输出中看到 Nginx 进程。这个命令显示了将近300行但是我在这个例子中缩短了它。可以想象试图处理300行过程信息有点混乱。我们可以将这个输出输送到 grep, 过滤一下仅显示 nginx。
```
alan@workstation:~$ ps -ef |grep nginx
alan     20520  1454  0 10:39 ?        00:00:00 nginx: master process nginx
alan     20521 20520  0 10:39 ?        00:00:00 nginx: worker process
```
确实更好了。我们可以很快看到Nginx 有20520和2052的PIDs。
确实更好了。我们可以很快看到Nginx 有 20520 和 20521 的 PID。
#### PGREP
pgrep 命令更加简化单独调用 grep 遇到的问题。
`pgrep` 命令更加简化单独调用 `grep` 遇到的问题。
```
alan@workstation:~$ pgrep nginx
@ -149,7 +138,7 @@ alan@workstation:~$ pgrep nginx
20521
```
假设您在一个托管环境中,多个用户正在运行几个不同的 Nginx 实例。您可以使用 **-u** 选项将其他人排除在输出之外。
假设您在一个托管环境中,多个用户正在运行几个不同的 Nginx 实例。您可以使用 `-u` 选项将其他人排除在输出之外。
```
alan@workstation:~$ pgrep -u alan nginx
@ -160,7 +149,8 @@ alan@workstation:~$ pgrep -u alan nginx
#### PIDOF
另一个好用的是pidof。此命令将检查特定二进制文件的 PID即使另一个同名进程正在运行。为了建立一个例子我将我的 Nginx 复制到第二个目录,并以相应的前缀集开始。在现实生活中,这个实例可能位于不同的位置,例如由不同用户拥有的目录。如果我运行两个 Nginx 实例则pidof 输出显示它们的所有进程。
另一个好用的是 `pidof`。此命令将检查特定二进制文件的 PID即使另一个同名进程正在运行。为了建立一个例子我将我的 Nginx 复制到第二个目录,并以相应的路径前缀启动。在现实生活中,这个实例可能位于不同的位置,例如由不同用户拥有的目录。如果我运行两个 Nginx 实例,则`pidof` 输出显示它们的所有进程。
```
alan@workstation:~$ ps -ef |grep nginx
alan     20881  1454  0 11:18 ?        00:00:00 nginx: master process ./nginx -p /home/alan/web/prod/nginxsec
@ -169,7 +159,7 @@ alan     20895  1454  0 11:19 ?        00:00:00 nginx: master process ng
alan     20896 20895  0 11:19 ?        00:00:00 nginx: worker process
```
使用 grep 或 pgrep 将显示 PID 数字,但我们可能无法辨别哪个实例是哪个。
使用 `grep``pgrep` 将显示 PID 数字,但我们可能无法辨别哪个实例是哪个。
```
alan@workstation:~$ pgrep nginx
@ -179,7 +169,7 @@ alan@workstation:~$ pgrep nginx
20896
```
pidof 命令可用于确定每个特定 Nginx 实例的PID。
`pidof` 命令可用于确定每个特定 Nginx 实例的 PID。
```
alan@workstation:~$ pidof /home/alan/web/prod/nginxsec/sbin/nginx
@ -191,7 +181,8 @@ alan@workstation:~$ pidof /home/alan/web/prod/nginx/sbin/nginx
#### TOP
top 命令已经有很长时间了,对于查看运行进程的细节和快速识别内存消耗等问题是非常有用的。其默认视图如下所示。
`top` 命令已经有很久的历史了,对于查看运行进程的细节和快速识别内存消耗等问题是非常有用的。其默认视图如下所示。
```
top - 11:56:28 up 1 day, 13:37,  1 user,  load average: 0.09, 0.04, 0.03
Tasks: 292 total,   3 running, 225 sleeping,   0 stopped,   0 zombie
@ -210,7 +201,8 @@ KiB Swap:        0 total,        0 free,        0 used. 14176540 ava
    7 root      20   0       0      0      0 S   0.0  0.0   0:00.08 ksoftirqd/0
```
可以通过键入字母 **s** 和您喜欢的更新秒数来更改更新间隔。为了更容易监控我们的示例 Nginx 进程,我们可以使用 **-p** 选项调用top并通过PID。这个输出要干净得多。
可以通过键入字母 `s` 和您喜欢的更新秒数来更改更新间隔。为了更容易监控我们的示例 Nginx 进程,我们可以使用 `-p` 选项并传递 PID 来调用 `top`。这个输出要干净得多。
```
alan@workstation:~$ top -p20881 -p20882 -p20895 -p20896
@ -226,16 +218,13 @@ KiB Swap:        0 total,        0 free,        0 used. 14177928 ava
20896 alan      20   0   12460   1628    912 S   0.0  0.0   0:00.00 nginx
```
在管理进程特别是终止进程时正确确定PID是非常重要。此外如果以这种方式使用top每当这些进程中的一个停止或一个新进程开始时top都需要被告知有新的更新
在管理进程,特别是终止进程时,正确确定 PID 是非常重要。此外,如果以这种方式使用 `top`,每当这些进程中的一个停止或一个新进程开始时,`top` 都需要被告知有新的进程
### 终止进程
#### KILL
Interestingly, there is no stop command. In Linux, there is the kill command. Kill is used to send a signal to a process. The most commonly used signal is "terminate" (SIGTERM) or "kill" (SIGKILL). However, there are many more. Below are some examples. The full list can be shown with **kill -L**.
有趣的是,没有 stop 命令。在 Linux中有 kill 命令。kill 用于向进程发送信号。最常用的信号是“终止”( SIGTERM )或“杀死”( SIGKILL )。然而,还有更多。下面是一些例子。完整的列表可以用 **kill -L** 显示。
有趣的是,没有 `stop` 命令。在 Linux 中,有 `kill` 命令。`kill` 用于向进程发送信号。最常用的信号是“终止”(`SIGTERM`)或“杀死”(`SIGKILL`)。然而,还有更多。下面是一些例子。完整的列表可以用 `kill -L` 显示。
```
 1) SIGHUP       2) SIGINT       3) SIGQUIT      4) SIGILL       5) SIGTRAP
@ -244,10 +233,7 @@ Interestingly, there is no stop command. In Linux, there is the kill command. Ki
```
Notice signal number nine is SIGKILL. Usually, we issue a command such as **kill -9 20896**. The default signal is 15, which is SIGTERM. Keep in mind that many applications have their own method for stopping. Nginx uses a **-s** option for passing a signal such as "stop" or "reload." Generally, I prefer to use an application's specific method to stop an operation. However, I'll demonstrate the kill command to stop Nginx process 20896 and then confirm it is stopped with pgrep. The PID 20896 no longer appears.
注意第九号信号是 SIGKILL。通常我们会发布一个命令比如 **kill -9 20896** 。默认信号是15这是SIGTERM。请记住许多应用程序都有自己的停止方法。Nginx 使用 **-s** 选项传递信号,如“停止”或“重新加载”。“通常,我更喜欢使用应用程序的特定方法来停止操作。然而,我将演示 kill 命令来停止 Nginx process 20896然后用 pgrep 确认它已经停止。PID 20896 就不再出现。
注意第 9 号信号是 `SIGKILL`,通常,我们会发出比如 `kill -9 20896` 这样的命令。默认信号是 15这是 `SIGTERM`。请记住许多应用程序都有自己的停止方法。Nginx 使用 `-s` 选项传递信号,如 `stop``reload`。通常,我更喜欢使用应用程序的特定方法来停止操作。然而,我将演示用 `kill` 命令来停止 Nginx 进程 20896然后用 `pgrep` 确认它已经停止。PID 20896 就不再出现。
```
alan@workstation:~$ kill -9 20896
@ -261,19 +247,14 @@ alan@workstation:~$ pgrep nginx
#### PKILL
The command pkill is similar to pgrep in that it can search by name. This means you have to be very careful when using pkill. In my example with Nginx, I might not choose to use it if I only want to kill one Nginx instance. I can pass the Nginx option **-s** **stop** to a specific instance to kill it, or I need to use grep to filter on the full ps output.
命令 pkill 类似于 pgrep因为它可以按名称搜索。这意味着在使用 pkill 时必须非常小心。在我的 Nginx 示例中,如果我只想杀死一个 Nginx 实例,我可能不会选择使用它。我可以将 Nginx 选项 **-s** **stop** 传递给特定的实例来消除它或者我需要使用grep来过滤整个 ps 输出。
命令 `pkill` 类似于 `pgrep`,因为它可以按名称搜索。这意味着在使用 `pkill` 时必须非常小心。在我的 Nginx 示例中,如果我只想杀死一个 Nginx 实例,我可能不会选择使用它。我可以将 Nginx 选项 `-s stop` 传递给特定的实例来消除它,或者我需要使用 `grep` 来过滤整个 `ps` 输出。
```
/home/alan/web/prod/nginx/sbin/nginx -s stop
/home/alan/web/prod/nginxsec/sbin/nginx -s stop
```
If I want to use pkill, I can include the **-f** option to ask pkill to filter across the full command line argument. This of course also applies to pgrep. So, first I can check with **pgrep -a** before issuing the **pkill -f**.
如果我想使用 pkill我可以包括 **-f** 选项,让 pkill 过滤整个命令行参数。这当然也适用于 pgrep。所以在执行 **pkill -f** 之前,首先我可以用 **pgrep -a** 确认一下。
如果我想使用 `pkill`,我可以包括 `-f` 选项,让 `pkill` 过滤整个命令行参数。这当然也适用于 `pgrep`。所以,在执行 `pkill -f` 之前,首先我可以用 `pgrep -a` 确认一下。
```
alan@workstation:~$ pgrep -a nginx
@ -283,10 +264,7 @@ alan@workstation:~$ pgrep -a nginx
20896 nginx: worker process
```
I can also narrow down my result with **pgrep -f**. The same argument used with pkill stops the process.
我也可以用 **pgrep -f** 缩小我的结果。pkill 使用的相同参数会停止该进程。
我也可以用 `pgrep -f` 缩小我的结果。`pkill` 使用相同参数会停止该进程。
```
alan@workstation:~$ pgrep -f nginxsec
@ -295,15 +273,9 @@ alan@workstation:~$ pgrep -f nginxsec
alan@workstation:~$ pkill -f nginxsec
```
The key thing to remember with pgrep (and especially pkill) is that you must always be sure that your search result is accurate so you aren't unintentionally affecting the wrong processes.
`pgrep`(尤其是 `pkill`)要记住的关键点是,您必须始终确保搜索结果准确性,这样您就不会无意中影响到错误的进程。
pgrep (尤其是pkill )要记住的关键点是,您必须始终确保搜索结果准确性,这样您就不会无意中影响到错误的进程。
Most of these commands have many command line options, so I always recommend reading the [man page][1] on each one. While most of these exist across platforms such as Linux, Solaris, and BSD, there are a few differences. Always test and be ready to correct as needed when working at the command line or writing scripts.
大多数这些命令都有许多命令行选项,所以我总是建议阅读每一个命令的 [man page][1]。虽然大多数这些都存在于 Linux、Solaris 和 BSD 等平台上,但也有一些不同之处。在命令行工作或编写脚本时,始终测试并随时准备根据需要进行更正。
大多数这些命令都有许多命令行选项,所以我总是建议阅读每一个命令的 [man 手册页][1]。虽然大多数这些命令都存在于 Linux、Solaris 和 BSD 等平台上,但也有一些不同之处。在命令行工作或编写脚本时,始终测试并随时准备根据需要进行更正。
--------------------------------------------------------------------------------
@ -311,8 +283,8 @@ via: https://opensource.com/article/18/9/linux-commands-process-management
作者:[Alan Formy-Duval][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
译者:[heguangzhi](https://github.com/heguangzhi)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,29 +1,34 @@
我为什么喜欢 Xonsh
======
> 有没有想过用 Python 做你的 shell
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/shelloff.png?itok=L8pjHXjW)
Shell 语言对交互式使用很有用。但是在使用它们作为编程语言时这种优化需要权衡,有时在编写 shell 脚本时会感觉到。
Shell 语言对交互式使用很有用。但是在使用它们作为编程语言时这种优化需要权衡,有时在编写 shell 脚本时会感觉到这点
如果你的 shell 一种更可伸缩的语言会怎样比如说Python
如果你的 shell 也能理解一种更可伸缩的语言会怎样比如说Python
进入 [Xonsh][1]。
安装 Xonsh 就像创建虚拟环境一样简单,运行 `pip install xonsh [ptklinux]`,然后运行 `xonsh`
首先,你可能想知道为什么你的 Python shell 有一个奇怪的提示:
首先,你可能奇怪为什么你的 Python shell 有一个奇怪的提示:
```
$ 1+1
2
```
好的计算器!
好的,计算器!
```
$ print("hello world")
hello world
```
我们还可以调用其他函数:
```
$ from antigravity import geohash
$ geohash(37.421542, -122.085589, b'2005-05-26-10458.68')
@ -31,12 +36,14 @@ $ geohash(37.421542, -122.085589, b'2005-05-26-10458.68')
```
然而,我们仍然可以像常规 shell 一样使用它:
```
$ echo "hello world"
hello world
```
我们甚至可以混搭!
```
$ for i in range(3):
.     echo "hello world"
@ -49,12 +56,14 @@ hello world
Xonsh 支持使用 [Prompt Toolkit][2] 补全 shell 命令和 Python 表达式。补全有可视化提示,会显示可能的补全并有下拉列表。
它还支持访问环境变量。它使用简单但强大的启发式方法将 Python 类型应用于环境变量。默认值为 “string”但是例如路径变量是自动列表。
```
$ '/usr/bin' in $PATH
True
```
Xonsh 接受 shell 形式或 Python 形式的布尔快捷运算符:
```
$ cat things
foo
@ -66,13 +75,15 @@ $ grep -q bar things || echo "found"
found
```
这意味着 Python 关键字是被解释了。如果我们想要打印著名的 Dr. Seuss 书的标题,我们需要引用关键词。
这意味着 Python 关键字是被解释了。如果我们想要打印著名的《苏斯博士》书的标题,我们需要引用关键词。
```
$ echo green eggs "and" ham
green eggs and ham
```
如果我们不这样做,我们会感到惊讶:
```
$ echo green eggs and ham
green eggs
@ -88,9 +99,10 @@ Did you mean one of the following?
虚拟环境可能会有点棘手。一般的虚拟环境(取决于它们类似 Bash 的语法无法工作。但是Xonsh 自带了一个名为 `vox` 的虚拟环境管理系统。
`vox` 可以创建激活和停用 `~/.virtualenvs` 中的环境。如果你用过 `virtualenvwrapper`,这就是环境变量所在的地方。
`vox` 可以创建激活和停用 `~/.virtualenvs` 中的环境。如果你用过 `virtualenvwrapper`,这就是环境变量所在的地方。
请注意,当前激活的环境不会影响 `xonsh`。它无法从激活的环境中导入任何内容。
```
$ xontrib load vox
$ vox create my-environment                                                    
@ -108,7 +120,7 @@ xonsh: For full traceback set: $XONSH_SHOW_TRACEBACK = True
ModuleNotFoundError: No module named 'money'
```
第一行启用 `vox`:它是一个 `xontrib`Xonsh 的一个第三方扩展。`xontrib` 管理器可以列出所有可能的 `xontribs` 及其当前状态(已安装已加载或未加载)。
第一行启用 `vox`:它是一个 `xontrib`Xonsh 的一个第三方扩展。`xontrib` 管理器可以列出所有可能的 `xontribs` 及其当前状态(已安装已加载或未加载)。
可以编写一个 `xontrib` 并上传到 `PyPi` 以使其可用。但是,最好将它添加到 `xontrib` 索引中,以便 Xonsh 提前知道它。比如,这能让配置向导建议它。
@ -121,7 +133,7 @@ via: https://opensource.com/article/18/9/xonsh-bash-alternative
作者:[Moshe Zadka][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/) 荣誉推出

View File

@ -0,0 +1,99 @@
Filelight可视化查看 Linux 系统上的磁盘使用情况
======
![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-720x340.png)
查看硬盘使用情况对于类 Unix 操作系统来说不是什么大问题。我们有一个名为 [du][1] 的内置命令,可以在几分钟之内计算和汇总磁盘空间的使用情况。此外,我们还有一些第三方工具,比如 [Ncdu][2] 和 [Agedu][3],它们也可以用来追踪磁盘使用情况。如您所见,这些都是命令行中的实用程序,磁盘使用情况将以纯文本的形式显示。但是,有些人希望以可视化、图表的形式查看结果。别担心!我知道一个 GUI 工具可以显示磁盘使用细节。它就是 “**Filelight**”,这是一个图形化实用程序,用于可视化显示 Linux 系统上的磁盘使用情况并以彩色径向图显示结果。Filelight 是历史最悠久的项目之一,它已经存在了很长时间,它完全免费使用并开源。
### 安装 Filelight
Filelight 是 KDE 应用程序的一部分,并预装在基于 KDE 的 Linux 发行版上。
如果您使用的是非 KDE 发行版,官方存储库中包含了 Filelight因此您可以使用默认的包管理器进行安装。
在 Arch Linux 及其衍生版,如 Antergos、Manjaro Linux 中Filelight 可以按照如下方法安装。
```
$ sudo pacman -S filelight
```
在 Debian、Ubuntu、Linux Mint 中,
```
$ sudo apt install filelight
```
在 Fedora 中,
```
$ sudo dnf install filelight
```
在 openSUSE 中,
```
$ sudo zypper install filelight
```
### 可视化查看 Linux 系统上的磁盘使用情况
安装后,从菜单或应用程序启动器启动 Filelight。
Filelight 以图形方式将您的文件系统表示为一组同心圆环段。
![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-1-1.png)
如您所见Filelight 默认显示磁盘中 `/``/boot` 文件系统的使用情况。
您还可以选择扫描的各个文件夹,以查看该特定文件夹的磁盘使用情况。为此,请到 “Filelight -> Scan -> Scan Folder” 并选择要扫描的文件夹。
Filelight 在扫描时排除以下目录:
* `/dev`
* `/proc`
* `/sys`
* `/root`
此选项有助于跳过您可能没有权限读取的目录,或者属于虚拟文件系统的文件夹,例如 `/proc`
如果您想要在此列表中增加文件夹,请到 “Filelight -> Settings -> Scanning” 并点击 “Add” 按钮然后选择您想要增加的文件夹。
![](http://www.ostechnix.com/wp-content/uploads/2018/09/filelight-settings.png)
类似的,要想从此列表中移除某个文件夹,选择文件夹并点击 “Remove”。
如果您想要改变 Filelight 的外观,请到 “Settings - > Appearance” 栏,按照您的喜好改变配色方案。
径向图中的每个段用不同的颜色表示。下图显示了 `/` 文件系统的整个径向布局。要查看文件和文件夹的完整信息,只需将鼠标指针悬停在它们上边。
![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-2.png)
只需点击相应的段即可浏览文件系统。要查看某个文件或文件夹的磁盘使用情况,只需单击它们即可获得该特定文件夹、文件的完整磁盘使用情况。
不仅仅是本地文件系统Filelight 还能够扫描远程磁盘和可移动磁盘。 如果您使用任何基于 KDE 的 Linux 发行版,它可以集成到 Konqueror、Dolphin 和 Krusader 等文件管理器中。
与 CLI 实用程序不同,您不必使用任何额外的参数或选项来以易读的(而非乱码的)格式查看结果。 默认情况下Filelight 将自动以易读的格式显示磁盘使用情况。
### 总结
使用 Filelight您可以快速找到文件系统中占用磁盘空间的位置并通过删除不需要的文件或文件夹释放空间。 如果您正在寻找一些简单且易上手的图形界面磁盘使用情况查看器,那么 Filelight 值得一试。
就是这样。希望这篇文章对您有用。更多的好文章,敬请关注!
干杯!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/filelight-visualize-disk-usage-on-your-linux-system/
作者:[SK][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[XiatianSummer](https://github.com/XiatianSummer)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://www.ostechnix.com/author/sk/
[1]: https://www.ostechnix.com/find-size-directory-linux/
[2]: https://www.ostechnix.com/check-disk-space-usage-linux-using-ncdu/
[3]: https://www.ostechnix.com/agedu-find-out-wasted-disk-space-in-linux/

View File

@ -1,53 +0,0 @@
Mastering CI/CD at OpenDev
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_opennature_3.png?itok=J1OSECM_)
After launching in 2017, the [OpenDev Conference][1] is now an annual event. At the inaugural event last September, the conference focus was on edge computing. This year's event, taking place May 22-23, will be focused on Continuous Integration/Continuous Deployment (CI/CD) and will be co-located with the OpenStack Summit in Vancouver.
I was invited to participate in the program committee for OpenDev CI/CD based on my background on the CI/CD system for the OpenStack project and my recent move into the container space. Today I frequently talk about CI/CD pipelines using various open source technologies, including [Jenkins][3] [GitLab][2],[Spinnaker][4] , and [Artifactory][5]
This event is exciting for me because we're bringing two open source infrastructure ideas together into one event. First, we'll be discussing CI/CD tooling that can be used by any organization. To this end, in the [keynotes][6] we'll hear practical talks about open source CI/CD tooling, including a talk about Spinnaker from Boris Renski and one from Jim Blair on [Zuul][7]. The keynotes also will include higher-level talks about the preference for open technologies, especially across communities and inside open source projects themselves. From Fatih Degirmenci and Daniel Farrell we'll hear about sharing continuous delivery practices across communities, and Benjamin Mako Hill will join us to talk about why free software needs free tools.
Given the relative newness of CI/CD, the rest of the event is a mix of talks, workshops, and collaborative discussions. When selecting from talks and workshops submitted, and coming up with collaborative discussion topics, we wanted to make sure there was a diverse schedule so anyone on the open CI/CD spectrum would find something interesting.
The talks will be standard conference style, selected to cover key topics like crafting CI/CD pipelines, improving security when practicing DevOps, and more specific solutions like container-based [Aptomi][8] on Kubernetes and doing CI/CD in ETSI NFV environments. Many of these sessions will serve as an introduction to these topics, ideal for those who are new to the CI/CD space or any of these specific technologies.
The hands-on workshops are longer and will have specific outcomes in mind for attendees. These include "[Anomaly Detection in Continuous Integration Jobs][9]," "[How to Install Zuul and Configure Your First Jobs][10]," and "[Spinnaker 101: Releasing Software with Velocity and Confidence][11]." (Note that space is limited in these workshops, so an RSVP system has been set up. You'll find an RSVP button on the session links provided here.)
Perhaps what I'm most excited about are the collaborative discussions, and these take up over half of the conference schedule. The topics were chosen by the program committee based on what we've been seeing in our communities. These are "fishbowl"-style sessions, where several people get in a room together to discuss a specific topic around CI/CD.
The idea for this style of session was taken from developer summits that the Ubuntu community pioneered and the OpenStack community continued. Topics for these collaborative discussions include separate sessions for CI and CD fundamentals, improvements that can be made to encourage cross-community collaboration, driving CI/CD culture in organizations, and why open source CI/CD tooling is so important. Shared documents are used to take notes during these sessions to make sure that as much knowledge shared during the session is retained as possible. It's also common for action items to come from these discussions, so community members can push forward initiatives related to the topic being covered.
The event concludes with a [Joint Conclusion Session][12], which will be summarizing the key points from the collaborative discussions and identifying work areas that attendees wish to work on in future.
Registration for this event is included in [OpenStack Summit registration][13], or tickets for this event only can be purchased for $199 onsite at the Vancouver Convention Center. Learn more about tickets and the full agenda on the [OpenDev website][1].
I hope you'll join us in Vancouver for an exciting two days of learning, collaborating and making progress together on CI/CD.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/5/opendev
作者:[Elizabeth K.Joseph][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/pleia2
[1]:http://2018.opendevconf.com/
[2]:https://about.gitlab.com/
[3]:https://jenkins.io/
[4]:https://www.spinnaker.io/
[5]:https://jfrog.com/artifactory/
[6]:http://2018.opendevconf.com/schedule/
[7]:https://zuul-ci.org/
[8]:http://aptomi.io/
[9]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21692/anomaly-detection-in-continuous-integration-jobs
[10]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21693/how-to-install-zuul-and-configure-your-first-jobs
[11]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21699/spinnaker-101-releasing-software-with-velocity-and-confidence
[12]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21831/opendev-cicd-joint-collab-conclusion
[13]:https://www.eventbrite.com/e/openstack-summit-may-2018-vancouver-tickets-40845826968?aff=VancouverSummit2018

View File

@ -1,104 +0,0 @@
15 command-line aliases to save you time
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/computer_keyboard_laptop_development_blue.png?itok=IfckxN48)
Linux command-line aliases are great for helping you work more efficiently. Better still, some are included by default in your installed Linux distro.
This is an example of a command-line alias in Fedora 27:
![](https://opensource.com/sites/default/files/uploads/default.png)
The command `alias` shows the list of existing aliases. Setting an alias is as simple as typing:
`alias new_name="command"`
Here are 15 command-line aliases that will save you time:
1. To install any utility/application:
`alias install="sudo yum install -y"`
Here, `sudo` and `-y` are optional as per users preferences:
![install alias.png][2]
2. To update the system:
`alias update="sudo yum update -y"`
3. To upgrade the system:
`alias upgrade="sudo yum upgrade -y"`
4. To change to the root user:
`alias root="sudo su -"`
5. To change to "user," where "user" is set as your username:
`alias user="su user"`
6. To display the list of all available ports, their status, and IP:
`alias myip="ip -br -c a"`
7. To `ssh` to the server `myserver`:
`alias myserver="ssh user@my_server_ip”`
8. To list all processes in the system:
`alias process="ps -aux"`
9. To check the status of any system service:
`alias sstatus="sudo systemctl status"`
10. To restart any system service:
`alias srestart="sudo systemctl restart"`
11. To kill any process by its name:
`alias kill="sudo pkill"`
![kill process alias.png][4]
12. To display the total used and free memory of the system:
`alias mem="free -h"`
13. To display the CPU architecture, number of CPUs, threads, etc. of the system:
`alias cpu="lscpu"`
14. To display the total disk size of the system:
`alias disk="df -h"`
15. To display the current system Linux distro (for CentOS, Fedora, and Red Hat):
`alias os="cat /etc/redhat-release"`
![system_details alias.png][6]
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/8/time-saving-command-line-aliases
作者:[Aarchit 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
[2]:https://opensource.com/sites/default/files/uploads/install.png (install alias.png)
[4]:https://opensource.com/sites/default/files/uploads/kill.png (kill process alias.png)
[6]:https://opensource.com/sites/default/files/uploads/system_details.png (system_details alias.png)

View File

@ -0,0 +1,133 @@
Translating by Ryze-Borgia
Linux vs Mac: 7 Reasons Why Linux is a Better Choice than Mac
======
Recently, we highlighted a few points about [why Linux is better than Windows][1]. Unquestionably, Linux is a superior platform. But, like other operating systems it has its drawbacks as well. For a very particular set of tasks (such as Gaming), Windows OS might prove to be better. And, likewise, for another set of tasks (such as video editing), a Mac-powered system might come in handy. It all trickles down to your preference and what you would like to do with your system. So, in this article, we will highlight a number of reasons why Linux is better than Mac.
If youre already using a Mac or planning to get one, we recommend you to thoroughly analyze the reasons and decide whether you want to switch/keep using Linux or continue using Mac.
### 7 Reasons Why Linux is Better Than Mac
![Linux vs Mac: Why Linux is a Better Choice][2]
Both Linux and macOS are Unix-like OS and give access to Unix commands, BASH and other shells. Both of them have fewer applications and games than Windows. But the similarity ends here.
Graphic designers and video editors swear by macOS whereas Linux is a favorite of developers, sysadmins and devops.
So the question is should you use Linux over Mac? If yes, why? Let me give you some practical and some ideological reasons why Linux is better than Mac.
#### 1\. Price
![Linux vs Mac: Why Linux is a Better Choice][3]
Lets suppose, you use the system only to browse stuff, watch movies, download photos, write a document, create a spreadsheet, and other similar stuff. And, in addition to those activities, you want to have a secure operating system.
In that case, you could choose to spend a couple of hundred bucks for a system to get things done. Or do you think spending more for a MacBook is a good idea? Well, you are the judge.
So, it really depends on what you prefer. Whether you want to spend on a Mac-powered system or get a budget laptop/PC and install any Linux distro for free. Personally, Ill be happy with a Linux system except for editing videos and music production. In that case, Final Cut Pro (for video editing) and Logic Pro X (for music production) will be my preference.
#### 2\. Hardware Choices
![Linux vs Mac: Why Linux is a Better Choice][4]
Linux is free. You can install it on computers with any configuration. No matter how powerful/old your system is, Linux will work. [Even if you have an 8-year old PC laying around, you can have Linux installed and expect it to run smoothly by selecting the right distro][5].
But, Mac is as an Apple-exclusive. If you want to assemble a PC or get a budget laptop (with DOS) and expect to install Mac OS, its almost impossible. Mac comes baked in with the system Apple manufactures.
There are [ways to install macOS on non Apple devices][6]. However, the kind of expertise and troubles it requires, it makes you question whether its worth the effort.
You will have a wide range of hardware choices when you go with Linux but a minimal set of configurations when it comes to Mac OS.
#### 3\. Security
![Linux vs Mac: Why Linux is a Better Choice][7]
A lot of people are all praises for iOS and Mac for being a secure platform. Well, yes, it is secure in a way (maybe more secure than Windows OS), but probably not as secure as Linux.
I am not bluffing. There are malware and adware targeting macOS and the [number is growing every day][8]. I have seen not-so-techie users struggling with their slow mac. A quick investigation revealed that a [browser hijacking malware][9] was the culprit.
There are no 100% secure operating systems and Linux is not an exception. There are vulnerabilities in the Linux world as well but they are duly patched by the timely updates provided by Linux distributions.
Thankfully, we dont have auto-running viruses or browser hijacking malwares in Linux world so far. And thats one more reason why you should use Linux instead of a Mac.
#### 4\. Customization & Flexibility
![Linux vs Mac: Why Linux is a Better Choice][10]
You dont like something? Customize it or remove it. End of the story.
For example, if you do not like the [Gnome desktop environment][11] on Ubuntu 18.04.1, you might as well change it to [KDE Plasma][11]. You can also try some of the [Gnome extensions][12] to enhance your desktop experience. You wont find this level of freedom and customization on Mac OS.
Besides, you can even modify the source code of your OS to add/remove something (which requires necessary technical knowledge) and create your own custom OS. Can you do that on Mac OS?
Moreover, you get an array of Linux distributions to choose from as per your needs. For instance, if you need to mimic the workflow on Mac OS, [Elementary OS][13] would help. Do you want to have a lightweight Linux distribution installed on your old PC? Weve got you covered in our list of [lightweight Linux distros][5]. Mac OS lacks this kind of flexibility.
#### 5\. Using Linux helps your professional career [For IT/Tech students]
![Linux vs Mac: Why Linux is a Better Choice][14]
This is kind of controversial and applicable to students and job seekers in the IT field. Using Linux doesnt make you a super-intelligent being and could possibly get you any IT related job.
However, as you start using Linux and exploring it, you gain experience. As a techie, sooner or later you dive into the terminal, learning your way to move around the file system, installing applications via command line. You wont even realize that you have learned the skills that newcomers in IT companies get trained on.
In addition to that, Linux has enormous scope in the job market. There are so many Linux related technologies (Cloud, Kubernetes, Sysadmin etc.) you can learn, earn certifications and get a nice paying job. And to learn these, you have to use Linux.
#### 6\. Reliability
![Linux vs Mac: Why Linux is a Better Choice][15]
Ever wondered why Linux is the best OS to run on any server? Because it is more reliable!
But, why is that? Why is Linux more reliable than Mac OS?
The answer is simple more control to the user while providing better security. Mac OS does not provide you with the full control of its platform. It does that to make things easier for you simultaneously enhancing your user experience. With Linux, you can do whatever you want which may result in poor user experience (for some) but it does make it more reliable.
#### 7\. Open Source
![Linux vs Mac: Why Linux is a Better Choice][16]
Open Source is something not everyone cares about. But to me, the most important aspect of Linux being a superior choice is its Open Source nature. And, most of the points discussed below are the direct advantages of an Open Source software.
To briefly explain, you get to see/modify the source code yourself if it is an open source software. But, for Mac, Apple gets an exclusive control. Even if you have the required technical knowledge, you will not be able to independently take a look at the source code of Mac OS.
In other words, a Mac-powered system enables you to get a car for yourself but the downside is you cannot open up the hood to see whats inside. Thats bad!
If you want to dive in deeper to know about the benefits of an open source software, you should go through [Ben Balters article][17] on OpenSource.com.
### Wrapping Up
Now that youve known why Linux is better than Mac OS. What do you think about it? Are these reasons enough for you to choose Linux over Mac OS? If not, then what do you prefer and why?
Let us know your thoughts in the comments below.
Note: The artwork here is based on Club Penguins.
--------------------------------------------------------------------------------
via: https://itsfoss.com/linux-vs-mac/
作者:[Ankush Das][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/ankush/
[1]: https://itsfoss.com/linux-better-than-windows/
[2]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/Linux-vs-mac-featured.png
[3]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-1.jpeg
[4]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-4.jpeg
[5]: https://itsfoss.com/lightweight-linux-beginners/
[6]: https://hackintosh.com/
[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-2.jpeg
[8]: https://www.computerworld.com/article/3262225/apple-mac/warning-as-mac-malware-exploits-climb-270.html
[9]: https://www.imore.com/how-to-remove-browser-hijack
[10]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-3.jpeg
[11]: https://www.gnome.org/
[12]: https://itsfoss.com/best-gnome-extensions/
[13]: https://elementary.io/
[14]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-5.jpeg
[15]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-6.jpeg
[16]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/linux-vs-mac-7.jpeg
[17]: https://opensource.com/life/15/12/why-open-source

View File

@ -1,3 +1,4 @@
LuMing translating
How To Configure SSH Key-based Authentication In Linux
======

View File

@ -1,121 +0,0 @@
7 Python libraries for more maintainable code
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_keyboard_coding.png?itok=E0Vvam7A)
> Readability counts.
> — [The Zen of Python][1], Tim Peters
It's easy to let readability and coding standards fall by the wayside when a software project moves into "maintenance mode." (It's also easy to never establish those standards in the first place.) But maintaining consistent style and testing standards across a codebase is an important part of decreasing the maintenance burden, ensuring that future developers are able to quickly grok what's happening in a new-to-them project and safeguarding the health of the app over time.
### Check your code style
A great way to protect the future maintainability of a project is to use external libraries to check your code health for you. These are a few of our favorite libraries for [linting code][2] (checking for PEP 8 and other style errors), enforcing a consistent style, and ensuring acceptable test coverage as a project reaches maturity.
[PEP 8][3] is the Python code style guide, and it sets out rules for things like line length, indentation, multi-line expressions, and naming conventions. Your team might also have your own style rules that differ slightly from PEP 8. The goal of any code style guide is to enforce consistent standards across a codebase to make it more readable, and thus more maintainable. Here are three libraries to help prettify your code.
#### 1\. Pylint
[Pylint][4] is a library that checks for PEP 8 style violations and common errors. It integrates well with several popular [editors and IDEs][5] and can also be run from the command line.
To install, run `pip install pylint`.
To use Pylint from the command line, run `pylint [options] path/to/dir` or `pylint [options] path/to/module.py`. Pylint will output warnings about style violations and other errors to the console.
You can customize what errors Pylint checks for with a [configuration file][6] called `pylintrc`.
#### 2\. Flake8
[Flake8][7] is a "Python tool that glues together PEP8, Pyflakes (similar to Pylint), McCabe (code complexity checker), and third-party plugins to check the style and quality of some Python code."
To use Flake8, run `pip install flake8`. Then run `flake8 [options] path/to/dir` or `flake8 [options] path/to/module.py` to see its errors and warnings.
Like Pylint, Flake8 permits some customization for what it checks for with a [configuration file][8]. It has very clear docs, including some on useful [commit hooks][9] to automatically check your code as part of your development workflow.
Flake8 integrates with popular editors and IDEs, but those instructions generally aren't found in the docs. To integrate Flake8 with your favorite editor or IDE, search online for plugins (for example, [Flake8 plugin for Sublime Text][10]).
#### 3\. Isort
[Isort][11] is a library that sorts your imports alphabetically and breaks them up into [appropriate sections][12] (e.g., standard library imports, third-party library imports, imports from your own project, etc.). This increases readability and makes it easier to locate imports if you have a lot of them in your module.
Install isort with `pip install isort`, and run it with `isort path/to/module.py`. More configuration options are in the [documentation][13]. For example, you can [configure][14] how isort handles multi-line imports from one library in an `.isort.cfg` file.
Like Flake8 and Pylint, isort also provides plugins that integrate it with popular [editors and IDEs][15].
### Outsource your code style
Remembering to run linters manually from the command line for each file you change is a pain, and you might not like how a particular plugin behaves with your IDE. Also, your colleagues might prefer different linters or might not have plugins for their favorite editors, or you might be less meticulous about always running the linter and correcting the warnings. Over time, the codebase you all share will get messy and harder to read.
A great solution is to use a library that automatically reformats your code into something that passes PEP 8 for you. The three libraries we recommend all have different levels of customization and different defaults for how they format code. Some of these are more opinionated than others, so like with Pylint and Flake8, you'll want to test these out to see which offers the customizations you can't live without… and the unchangeable defaults you can live with.
#### 4\. Autopep8
[Autopep8][16] automatically formats the code in the module you specify. It will re-indent lines, fix indentation, remove extraneous whitespace, and refactor common comparison mistakes (like with booleans and `None`). See a full [list of corrections][17] in the docs.
To install, run `pip install --upgrade autopep8`. To reformat code in place, run `autopep8 --in-place --aggressive --aggressive <filename>`. The `aggressive` flags (and the number of them) indicate how much control you want to give autopep8 over your code style. Read more about [aggressive][18] options.
#### 5\. Yapf
[Yapf][19] is yet another option for reformatting code that comes with its own list of [configuration options][20]. It differs from autopep8 in that it doesn't just address PEP 8 violations. It also reformats code that doesn't violate PEP 8 specifically but isn't styled consistently or could be formatted better for readability.
To install, run `pip install yapf`. To reformat code, run, `yapf [options] path/to/dir` or `yapf [options] path/to/module.py`. There is also a full list of [customization options][20].
#### 6\. Black
[Black][21] is the new kid on the block for linters that reformat code in place. It's similar to autopep8 and Yapf, but way more opinionated. It has very few options for customization, which is kind of the point. The idea is that you shouldn't have to make decisions about code style; the only decision to make is to let Black decide for you. You can read about [limited customization options][22] and instructions on [storing them in a configuration file][23].
Black requires Python 3.6+ but can format Python 2 code. To use, run `pip install black`. To prettify your code, run: `black path/to/dir` or `black path/to/module.py`.
### Check your test coverage
You're writing tests, right? Then you will want to make sure new code committed to your codebase is tested and doesn't drop your overall amount of test coverage. While percentage of test coverage is not the only metric you should use to measure the effectiveness and sufficiency of your tests, it is one way to ensure basic testing standards are being followed in your project. For measuring test coverage, we have one recommendation: Coverage.
#### 7\. Coverage
[Coverage][24] has several options for the way it reports your test coverage to you, including outputting results to the console or to an HTML page and indicating which line numbers are missing test coverage. You can set up a [configuration file][25] to customize what Coverage checks for and make it easier to run.
To install, run `pip install coverage`. To run a program and see its output, run `coverage run [path/to/module.py] [args]`, and you will see your program's output. To see a report of which lines of code are missing coverage, run `coverage report -m`.
Continuous integration (CI) is a series of processes you can run to automatically check for linter errors and test coverage minimums before you merge and deploy code. There are lots of free or paid tools to automate this process, and a thorough walkthrough is beyond the scope of this article. But because setting up a CI process is an important step in removing blocks to more readable and maintainable code, you should investigate continuous integration tools in general; check out [Travis CI][26] and [Jenkins][27] in particular.
These are only a handful of the libraries available to check your Python code. If you have a favorite that's not on this list, please share it in the comments.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/7/7-python-libraries-more-maintainable-code
作者:[Jeff Triplett][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/laceynwilliams
[1]:https://www.python.org/dev/peps/pep-0020/
[2]:https://en.wikipedia.org/wiki/Lint_(software)
[3]:https://www.python.org/dev/peps/pep-0008/
[4]:https://www.pylint.org/
[5]:https://pylint.readthedocs.io/en/latest/user_guide/ide-integration.html
[6]:https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options
[7]:http://flake8.pycqa.org/en/latest/
[8]:http://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations
[9]:http://flake8.pycqa.org/en/latest/user/using-hooks.html
[10]:https://github.com/SublimeLinter/SublimeLinter-flake8
[11]:https://github.com/timothycrosley/isort
[12]:https://github.com/timothycrosley/isort#how-does-isort-work
[13]:https://github.com/timothycrosley/isort#using-isort
[14]:https://github.com/timothycrosley/isort#configuring-isort
[15]:https://github.com/timothycrosley/isort/wiki/isort-Plugins
[16]:https://github.com/hhatto/autopep8
[17]:https://github.com/hhatto/autopep8#id4
[18]:https://github.com/hhatto/autopep8#id5
[19]:https://github.com/google/yapf
[20]:https://github.com/google/yapf#usage
[21]:https://github.com/ambv/black
[22]:https://github.com/ambv/black#command-line-options
[23]:https://github.com/ambv/black#pyprojecttoml
[24]:https://coverage.readthedocs.io/en/latest/
[25]:https://coverage.readthedocs.io/en/latest/config.html
[26]:https://travis-ci.org/
[27]:https://jenkins.io/

View File

@ -1,159 +0,0 @@
Installing Android on VirtualBox
======
If you are developing mobile apps Android can be a bit of a hassle. While iOS comes with its niceties, provided you are using macOS, Android comes with just Android Studio which is designed to support more than a few Android version, including wearables.
Needless to say, all the binaries, SDKs, frameworks and debuggers are going to pollute your filesystem with lots and lots of files, logs and other miscellaneous objects. An efficient work around for this is installing Android on your VirtualBox which takes away one of the sluggiest aspect of Android development — The device emulator. You can use this VM to run your test application or just fiddle with Androids internals. So without further ado lets set on up!
### Getting Started
To get started we will need to have VirtualBox installed on our system, you can get a copy for Windows, macOS or any major distro of Linux [here][1]. Next you would need a copy of Android meant to run on x86 hardware, because thats what VirtualBox is going to offer to a Virtual Machine an x86 or an x86_64 (a.k.a AMD64) platform to run.
While most Android devices run on ARM, we can take help of the project [Android on x86][2]. These fine folks have ported Android to run on x86 hardware (both real and virtual) and we can get a copy of the latest release candidate (Android 7.1) for our purposes. You may prefer using a more stable release but in that case Android 6.0 is about as latest as you can get, at the time of this writing.
#### Creating VM
Open VirtualBox and click on “New” (top-left corner) and in the Create Virtual Machine window select the type to be Linux and version Linux 2.6 / 3.x /4.x (64-bit) or (32-bit) depending upon whether the ISO you downloaded was x86_64 or x86 respectively.
RAM size could be anywhere from 2 GB to as much as your system resources can allow. Although if you want to emulate real world devices you should allocate upto 6GB for memory and 32GB for disk size which are typical in Android devices.
![][3]
![][4]
Upon creation, you might want to tweak a few additional settings, add in an additional processor core and improve display memory for starters. To do this, right-click on the VM and open up settings. In the Settings → System → Processor section you can allocate a few more cores if your desktop can pull it off.
![][5]
And in Settings → Display → Video Memory you can allocate a decent chunk of memory and enable 3D acceleration for a more responsive experience.
![][6]
Now we are ready to boot the VM.
#### Installing Android
Starting the VM for the first time, VirtualBox will insist you to supply it with a bootable media. Select the Android iso that you previously downloaded to boot the machine of with.
![][7]
Next, select the Installation option if you wish to install Android on the VM for a long term use, otherwise feel free to log into the live media and play around with the environment.
![][8]
Hit <Enter>.
##### Partitioning the Drive
Partitioning is done using a textual interface, which means we dont get the niceties of a GUI and we will have to use the follow careful at what is being shown on the screen. For example, in the first screen when no partition has been created and just a raw (virtual) disk is detected you will see the following.
![][9]
The red lettered C and D indicates that if you hit the key C you can create or modify partitions and D will detect additional devices. You can press D and the live media will detect the disks attached, but that is optional since it did a check during the boot.
Lets hit C and create partitions in the virtual disk. The offical page recommends against using GPT so we will not use that scheme. Select No using the arrow keys and hit <Enter>.
![][10]
And now you will be ushered into the fdisk utility.
![][11]
We will create just a single giant partition so as to keep things simple. Using arrow keys navigate to the New option and hit <Enter>. Select primary as the type of partition, and hit <Enter> to confirm
![][12]
The maximum size will already be selected for you, hit <Enter> to confirm that.
![][13]
This partition is where Android OS will reside, so of course we want it to be bootable. So select Bootable and hit enter (Boot will appear in the flags section in the table above) and then you can navigate to the Write section and hit <Enter> to write the changes to the partitioning table.
![][14]
Then you can Quit the partitioning utility and move on with the installation.
![][15]
##### Formatting with Ext4 and installing Android
A new partition will come in the Choose Partition menu where we were before we down the partitioning digression. Lets select this partition and hit OK.
![][16]
Select ext4 as the de facto file system in the next menu. Confirm the changes in the next window by selecting **Yes** and the formatting will begin. When asked, say **Yes** to the GRUB boot loader installation. Similarly, say **Yes** to allowing read-write operations on the /system directory. Now the installation will begin.
Once it is installed, you can safely reboot the system when prompted to reboot. You may have to power down the machine before the next reboot happens, go to Settings → Storage and remove the android iso if it is still attached to the VM.
![][17]
Remove the media and save the changes, before starting up the VM.
##### Running Android
In the GRUB menu you will get options for running the OS in debug mode or the normal way. Lets take a tour of Android in a VM using the default option, as shown below:
![][18]
And if everything works fine, you will see this:
![][19]
Now Android uses touch screen as an interface instead of a mouse, as far as its normal use is concerned. While the x86 port does come with a mouse point-and-click support you may have to use arrow keys a lot in the beginning.
![][20]
Navigate to lets go, and hit enter, if you are using arrow keys and then select Setup as New.
![][21]
It will check for updates and device info, before asking you to sign in using a Google account. You can skip this if you want and move on to setting up Data and Time and give your username to the device after that.
A few other options would be presented, similar to the options you see when setting up a new Android device. Select appropriate options for privacy, updates, etc and of course Terms of Service, which we might have to Agree to.
![][22]
After this, it may ask you to add another email account or set up “On-body detection” since it is a VM, neither of the options are of much use to us and we can click on “All Set”
It would ask you to select Home App after that, which is upto you to decide, as it is a matter of Preference and you will finally be in a virtualized Android system.
![][23]
You may benefit greatly from a touch screen laptop if you desire to do some intensive testing on this VM, since that would emulate a real world use case much closely.
Hope you have found this tutorial useful in case, you have any other similar request for us to write about, please feel free to reach out to us.
--------------------------------------------------------------------------------
via: https://linuxhint.com/install_android_virtualbox/
作者:[Ranvir Singh][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://linuxhint.com/author/sranvir155/
[1]:https://www.virtualbox.org/wiki/Downloads
[2]:http://www.android-x86.org/
[3]:https://linuxhint.com/wp-content/uploads/2018/08/a.png
[4]:https://linuxhint.com/wp-content/uploads/2018/08/a1.png
[5]:https://linuxhint.com/wp-content/uploads/2018/08/a2.png
[6]:https://linuxhint.com/wp-content/uploads/2018/08/a3.png
[7]:https://linuxhint.com/wp-content/uploads/2018/08/a4.png
[8]:https://linuxhint.com/wp-content/uploads/2018/08/a5.png
[9]:https://linuxhint.com/wp-content/uploads/2018/08/a6.png
[10]:https://linuxhint.com/wp-content/uploads/2018/08/a7.png
[11]:https://linuxhint.com/wp-content/uploads/2018/08/a8.png
[12]:https://linuxhint.com/wp-content/uploads/2018/08/a9.png
[13]:https://linuxhint.com/wp-content/uploads/2018/08/a10.png
[14]:https://linuxhint.com/wp-content/uploads/2018/08/a11.png
[15]:https://linuxhint.com/wp-content/uploads/2018/08/a12.png
[16]:https://linuxhint.com/wp-content/uploads/2018/08/a13.png
[17]:https://linuxhint.com/wp-content/uploads/2018/08/a14.png
[18]:https://linuxhint.com/wp-content/uploads/2018/08/a16.png
[19]:https://linuxhint.com/wp-content/uploads/2018/08/a17.png
[20]:https://linuxhint.com/wp-content/uploads/2018/08/a18.png
[21]:https://linuxhint.com/wp-content/uploads/2018/08/a19.png
[22]:https://linuxhint.com/wp-content/uploads/2018/08/a20.png
[23]:https://linuxhint.com/wp-content/uploads/2018/08/a21.png

View File

@ -1,3 +1,5 @@
translated by hopefully2333
Steam Makes it Easier to Play Windows Games on Linux
======
![Steam Wallpaper][1]

View File

@ -1,3 +1,6 @@
Translating by z52527
A Cat Clone With Syntax Highlighting And Git Integration
======

View File

@ -1,3 +1,5 @@
HankChow translating
5 Ways to Take Screenshot in Linux [GUI and Terminal]
======
Here are several ways you can take screenshots and edit the screenshots by adding text, arrows etc. Instructions and mentioned screenshot tools are valid for Ubuntu and other major Linux distributions.

View File

@ -1,3 +1,4 @@
KevinSJ 翻译中
6 open source tools for writing a book
======

View File

@ -1,3 +1,5 @@
translating---geekpi
Autotrash A CLI Tool To Automatically Purge Old Trashed Files
======

View File

@ -1,114 +0,0 @@
What is ZFS? Why People Use ZFS? [Explained for Beginners]
======
Today, we will take a look at ZFS, an advanced file system. We will discuss where it came from, what it is, and why it is so popular among techies and enterprise.
Even though Im from the US, I prefer to pronounce it ZedFS instead of ZeeFS because it sounds cooler. You are free to pronounce it however you like.
Note: You will see ZFS repeated many times in the article. When I talk about feature and installation, Im talking about OpenZFS. ZFS (developed by Oracle) and OpenZFS have followed different paths since Oracle shutdown OpenSolaris. (More on that later.)
### History of ZFS
The Z File System (ZFS) was created by [Matthew Ahrens and Jeff Bonwick][1] in 2001. ZFS was designed to be a next generation file system for [Sun Microsystems][2] [OpenSolaris][3]. In 2008, ZFS was ported to FreeBSD. The same year a project was started to port [ZFS to Linux][4]. However, since ZFS is licensed under the [Common Development and Distribution License][5], which is incompatible with the [GNU General Public License][6], it cannot be included in the Linux kernel. To get around this problem, most Linux distros offer methods to install ZFS.
Shortly after Oracle purchased Sun Microsystems, OpenSolaris became close-source. All further development of ZFS became closed source, as well. Many of the developers of ZFS where unhappy about this turn of events. [Two-thirds of the core ZFS devlopers][1], including Ahrens and Bonwick, left Oracle due to this decision. They joined other companies and created the [OpenZFS project][7] in September of 2013. The project has spearheaded the open-source development of ZFS.
Lets go back to the license issue mentioned above. Since the OpenZFS project is separate from Oracle, some probably wonder why they dont change the license to something that is compatible with the GPL so it can be included in the Linux kernel. According to the [OpenZFS website][8], changing the license would involve contacting anyone who contributed code to the current OpenZFS implementation (including the initial, common ZFS code till OpenSolaris) and get their permission to change the license. Since this job is near impossible (because some contributors may be dead or hard to find), they have decided to keep the license they have.
### What is ZFS? What are its features?
![ZFS filesystem][9]
As I said before, ZFS is an advanced file system. As such, it has some interesting [features][10]. Such as:
* Pooled storage
* Copy-on-write
* Snapshots
* Data integrity verification and automatic repair
* RAID-Z
* Maximum 16 Exabyte file size
* Maximum 256 Quadrillion Zettabytes storage
Lets break down a couple of those features.
#### Pooled Storage
Unlike most files systems, ZFS combines the features of a file system and a volume manager. This means that unlike other file systems, ZFS can create a file system that spans across a series of drives or a pool. Not only that but you can add storage to a pool by adding another drive. ZFS will handle [partitioning and formatting][11].
![Pooled storage in ZFS][12]Pooled storage in ZFS
#### Copy-on-write
[Copy-on-write][13] is another interesting (and cool) features. On most files system, when data is overwritten, it is lost forever. On ZFS, the new information is written to a different block. Once the write is complete, the file systems metadata is updated to point to the new info. This ensures that if the system crashes (or something else happens) while the write is taking place, the old data will be preserved. It also means that the system does not need to run [fsck][14] after a system crash.
#### Snapshots
Copy-on-write leads into another ZFS feature: snapshots. ZFS uses snapshots to track changes in the file system. “[The snapshot][13] contains the original version of the file system, and the live filesystem contains any changes made since the snapshot was taken. No additional space is used. As new data is written to the live file system, new blocks are allocated to store this data.” It a file is deleted, the snapshot reference is removed, as well. So, snapshots are mainly designed to track changes to files, but not the addition and creation of files.
Snapshots can be mounted as read-only to recover a past version of a file. It is also possible to rollback the live system to a previous snapshot. All changes made since the snapshot will be lost.
#### Data integrity verification and automatic repair
Whenever new data is written to ZFS, it creates a checksum for that data. When that data is read, the checksum is verified. If the checksum does not match, then ZFS knows that an error has been detected. ZFS will then automatically attempt to correct the error.
#### RAID-Z
ZFS can handle RAID without requiring any extra software or hardware. Unsurprisingly, ZFS has its own implementation of RAID: RAID-Z. RAID-Z is actually a variation of RAID-5. However, it is designed to overcome the RAID-5 write hole error, “in which the data and parity information become inconsistent after an unexpected restart”. To use the basic [level of RAID-Z][15] (RAID-Z1) you need at least two disks for storage and one for [parity][16]. RAID-Z2 required at least two storage drives and two drive for parity. RAID-Z3 requires at least two storage drives and three drive for parity. When drives are added to the RAID-Z pools, they have to be added in multiples of two.
#### Huge Storage potential
When ZFS was created, it was designed to be [the last word in file systems][17]. At a time when most file systems where 64-bit, the ZFS creators decided to jump right to 128-bit to future proof it. This means that ZFS “offers 16 billion billion times the capacity of 32- or 64-bit systems”. In fact, Jeff Bonwick (one of the creators) said [that powering][18] a “fully populating a 128-bit storage pool would, literally, require more energy than boiling the oceans.”
### How to Install ZFS?
If you want to use ZFS out of the box, it would require installing either [FreeBSD][19] or an [operating system using the illumos kernel][20]. [illumos][21] is a fork of the OpenSolaris kernel.
In fact, support for [ZFS is one of the main reasons why some experienced Linux users opt for BSD][22].
If you want to try ZFS on Linux, you can only use it at your storage file system. As a far as I know, no Linux distro give you the option to install ZFS on your root out of the box. If you are interested in trying ZFS on Linux, the [ZFS on Linux project][4] has a number of tutorials on how to do that.
### Caveat
This article has sung the benefits of ZFS. Now let me tell you a quick problem with ZFS. Using RAID-Z [can be expensive][23] because of the number of drives you need to purchase to add storage space.
Have you every ZFS? What was your experience like? Let us know in the comments below.
If you found this article interesting, please take a minute to share it on social media, Hacker News or [Reddit][24].
--------------------------------------------------------------------------------
via: https://itsfoss.com/what-is-zfs/
作者:[John Paul][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/john/
[1]: https://wiki.gentoo.org/wiki/ZFS
[2]: http://en.wikipedia.org/wiki/Sun_Microsystems
[3]: http://en.wikipedia.org/wiki/Opensolaris
[4]: https://zfsonlinux.org/
[5]: https://en.wikipedia.org/wiki/Common_Development_and_Distribution_License
[6]: https://en.wikipedia.org/wiki/GNU_General_Public_License
[7]: http://www.open-zfs.org/wiki/Main_Page
[8]: http://www.open-zfs.org/wiki/FAQ#Do_you_plan_to_release_OpenZFS_under_a_license_other_than_the_CDDL.3F
[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/what-is-zfs.png
[10]: https://wiki.archlinux.org/index.php/ZFS
[11]: https://www.howtogeek.com/175159/an-introduction-to-the-z-file-system-zfs-for-linux/
[12]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/zfs-overview.png
[13]: https://www.freebsd.org/doc/handbook/zfs-term.html
[14]: https://en.wikipedia.org/wiki/Fsck
[15]: https://wiki.archlinux.org/index.php/ZFS/Virtual_disks#Creating_and_Destroying_Zpools
[16]: https://www.pcmag.com/encyclopedia/term/60364/raid-parity
[17]: https://web.archive.org/web/20060428092023/http://www.sun.com/2004-0914/feature/
[18]: https://blogs.oracle.com/bonwick/128-bit-storage:-are-you-high
[19]: https://www.freebsd.org/
[20]: https://wiki.illumos.org/display/illumos/Distributions
[21]: https://wiki.illumos.org/display/illumos/illumos+Home
[22]: https://itsfoss.com/why-use-bsd/
[23]: http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html
[24]: http://reddit.com/r/linuxusersgroup

View File

@ -1,3 +1,5 @@
heguangzhi Translating
3 open source log aggregation tools
======
Log aggregation systems can help with troubleshooting and other tasks. Here are three top options.

View File

@ -1,109 +0,0 @@
Randomize your MAC address using NetworkManager
======
![](https://fedoramagazine.org/wp-content/uploads/2018/09/randomizemacaddress-816x345.png)
Today, users run their notebooks everywhere. To stay connected you use the local wifi to access the internet, on the couch at home or in a little cafe with your favorite coffee. But modern hotspots track you based on your MAC address, [an address that is unique per network card][1], and in this way identifies your device. Read more below about how to avoid this kind of tracking.
Why is this a problem? Many people use the word “privacy” to talk about this issue. But the concern is not about someone accessing the private contents of your laptop (thats a separate issue). Instead, its about legibility — in simple terms, the ability to be easily counted and tracked. You can and should [read more about legibility][2]. But the bottom line is legibility gives the tracker power over the tracked. For instance, timed WiFi leases at the airport can only be enforced when youre legible.
Since a fixed MAC address for your laptop is so legible (easily tracked), you should change it often. A random address is a good choice. Since MAC-addresses are only used within a local network, a random MAC-address is unlikely to cause a [collision.][3]
### Configuring NetworkManager
To apply randomized MAC-addresses by default to all WiFi connections, create the following file /etc/NetworkManager/conf.d/00-macrandomize.conf :
```
[device]
wifi.scan-rand-mac-address=yes
[connection]
wifi.cloned-mac-address=stable
ethernet.cloned-mac-address=stable
connection.stable-id=${CONNECTION}/${BOOT}
```
Afterward, restart NetworkManager:
```
systemctl restart NetworkManager
```
Set cloned-mac-address to stable to generate the same hashed MAC every time a NetworkManager connection activates, but use a different MAC with each connection. To get a truly random MAC with every activation, use random instead.
The stable setting is useful to get the same IP address from DHCP, or a captive portal might remember your login status based on the MAC address. With random you may be required to re-authenticate (or click “I agree”) on every connect. You probably want “random” for that airport WiFi. See the NetworkManager [blog post][4] for a more detailed discussion and instructions for using nmcli to configure specific connections from the terminal.
To see your current MAC addresses, use ip link. The MAC follows the word ether.
```
$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:5f:d5:4e brd ff:ff:ff:ff:ff:ff
3: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
link/ether 52:54:00:03:23:59 brd ff:ff:ff:ff:ff:ff
```
### When not to randomize your MAC address
Naturally, there are times when you do need to be legible. For instance, on your home network, you may have configured your router to assign your notebook a consistent private IP for port forwarding. Or you might allow only certain MAC addresses to use the WiFi. Your employer probably requires legibility as well.
To change a specific WiFi connection, use nmcli to see your NetworkManager connections and show the current settings:
```
$ nmcli c | grep wifi
Amtrak_WiFi 5f4b9f75-9e41-47f8-8bac-25dae779cd87 wifi --
StaplesHotspot de57940c-32c2-468b-8f96-0a3b9a9b0a5e wifi --
MyHome e8c79829-1848-4563-8e44-466e14a3223d wifi wlp1s0
...
$ nmcli c show 5f4b9f75-9e41-47f8-8bac-25dae779cd87 | grep cloned
802-11-wireless.cloned-mac-address: --
$ nmcli c show e8c79829-1848-4563-8e44-466e14a3223d | grep cloned
802-11-wireless.cloned-mac-address: stable
```
This example uses a fully random MAC for Amtrak (which is currently using the default), and the permanent MAC for MyHome (currently set to stable). The permanent MAC was assigned to your network interface when it was manufactured. Network admins like to use the permanent MAC to see [manufacturer IDs on the wire][5].
Now, make the changes and reconnect the active interface:
```
$ nmcli c modify 5f4b9f75-9e41-47f8-8bac-25dae779cd87 802-11-wireless.cloned-mac-address random
$ nmcli c modify e8c79829-1848-4563-8e44-466e14a3223d 802-11-wireless.cloned-mac-address permanent
$ nmcli c down e8c79829-1848-4563-8e44-466e14a3223d
$ nmcli c up e8c79829-1848-4563-8e44-466e14a3223d
$ ip link
...
```
You can also install NetworkManager-tui to get the nmtui command for nice menus when editing connections.
### Conclusion
When you walk down the street, you should [stay aware of your surroundings][6], and on the [alert for danger][7]. In the same way, learn to be aware of your legibility when using public internet resources.
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/randomize-mac-address-nm/
作者:[sheogorath][a],[Stuart D Gathman][b]
选题:[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/sheogorath/
[b]: https://fedoramagazine.org/author/sdgathman/
[1]: https://en.wikipedia.org/wiki/MAC_address
[2]: https://www.ribbonfarm.com/2010/07/26/a-big-little-idea-called-legibility/
[3]: https://serverfault.com/questions/462178/duplicate-mac-address-on-the-same-lan-possible
[4]: https://blogs.gnome.org/thaller/2016/08/26/mac-address-spoofing-in-networkmanager-1-4-0/
[5]: https://www.wireshark.org/tools/oui-lookup.html
[6]: https://www.isba.org/committees/governmentlawyers/newsletter/2013/06/becomingmoreawareafewtipsonkeepingy
[7]: http://www.selectinternational.com/safety-blog/aware-of-surroundings-can-reduce-safety-incidents

View File

@ -1,3 +1,4 @@
translating by name1e5s
Know Your Storage: Block, File & Object
======

View File

@ -1,105 +0,0 @@
XiatianSummer translating
Visualize Disk Usage On Your Linux System
======
![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-720x340.png)
Finding disk space usage is no big deal in Unix-like operating systems. We have a built-in command named [**du**][1] that can be used to calculate and summarize the disk space usage in minutes. And, we have some third-party tools like [**Ncdu**][2] and [**Agedu**][3] which can also be used to track down the disk usage. As you already know, these are all command line utilities and you will see the disk usage results in plain-text format. However, some of youd like to view the results in visual or kind of image format. No worries! I know one such GUI tool to find out the disk usage details. Say hello to **“Filelight”** , a graphical utility to visualize disk usage on your Linux system and displays the disk usage results in a colored radial layout. Filelight is one of the oldest project and it has been around for a long time. It is completely free to use and open source.
### Installing Filelight
Filelight is part of KDE applications and comes pre-installed with KDE-based Linux distributions.
If youre using non-KDE distros, Filelight is available in the official repositories, so you can install it using the default package manager.
On Arch Linux and its variants such as Antergos, Manjaro Linux, Filelight can be installed as below.
```
$ sudo pacman -S filelight
```
On Debian, Ubuntu, Linux Mint:
```
$ sudo apt install filelight
```
On Fedora:
```
$ sudo dnf install filelight
```
On openSUSE:
```
$ sudo zypper install filelight
```
### Visualize Disk Usage On Your Linux System
Once installed, launch Filelight from Menu or application launcher.
FIlelight graphically represents your filesystem as a set of concentric segmented-rings.
![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-1-1.png)
As you can see, Filelight displays the disk usage of the **/** and **/boot** filesystems by default.
You can also scan the individual folders of your choice to view the disk usage of that particular folder. To do so, go to **Filelight - > Scan -> Scan Folder** and choose the folder you want to scan.
Filelight excludes the following directories from scanning:
* /dev
* /proc
* /sys
* /root
This option is helpful to skip the directories that you may not have permissions to read, or folders that are part of a virtual filesystem, such as /proc.
If you want to add any folder in this list, go to **Filelight - > Settings -> Scanning** and click “add” button and choose the folder you want to add in this list.
![](http://www.ostechnix.com/wp-content/uploads/2018/09/filelight-settings.png)
Similarly, to remove a folder from the list, choose the folder and click on “Remove”.
If you want to change the way filelight looks, go to **Settings - > Appearance** tab and change the color scheme as per your liking.
Each segment in the radial layout is represented with different colors. The following image represents the entire radial layout of **/** filesystem. To view the full information of files and folders, just hover the mouse pointer over them.
![](https://www.ostechnix.com/wp-content/uploads/2018/09/filelight-2.png)
You can navigate around the the filesystem by simply clicking on the respective segment. To view the disk usage of any file or folder, just click on them and you will get the complete disk usage details of that particular folder/file.
Not just local filesystem, Filelight can able to scan your local, remote and removable disks. If youre using any KDE-based Linux distribution, it can be integrated into file managers like Konqueror, Dolphin and Krusader.
Unlike the CLI utilities, you dont have to use any extra arguments or options to view the results in human-readable format. Filelight will display the disk usage in human-readable format by default.
### Conclusion
By using Filelight, you can quickly discover where exactly your diskspace is being used in your filesystem and free up the space wherever necessary by deleting the unwanted files or folders. If you are looking for some simple and user-learnedly graphical disk usage viewer, Filelight is worth trying.
And, thats all for now. Hope this was useful. More good stuffs to come. Stay tuned!
Cheers!
--------------------------------------------------------------------------------
via: https://www.ostechnix.com/filelight-visualize-disk-usage-on-your-linux-system/
作者:[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/find-size-directory-linux/
[2]: https://www.ostechnix.com/check-disk-space-usage-linux-using-ncdu/
[3]: https://www.ostechnix.com/agedu-find-out-wasted-disk-space-in-linux/

View File

@ -0,0 +1,77 @@
ScreenCloud: The Screenshot++ App
======
[ScreenCloud][1] is an amazing little app, that you dont even know you need. The default screenshot procedure on desktop Linux is great (Prt Scr Button) and we even have some[powerful screenshot utilities][2]like [Shutter][3]. But ScreenCloud brings one more really simple yet really convenient feature that I just fell in love with. But before we get into it, lets catch a little backstory.
I take a lot of screenshots. A lot more than average. Receipts, registration details, development work, screenshots of applications for articles, and lot more. The next thing I do is open a browser, browse to my favorite cloud storage and dump the important ones there so that I can access them on my phone and also across multiple operating systems on my PC. This also allows me to easily share screenshots of the apps that Im working on with my team.
I had no complaints with this standard procedure of taking screenshots, opening a browser and logging into my cloud and then uploading the screenshots manually, until I came across ScreenCloud.
### ScreenCloud
ScreenCloud is cross-platform utility that provides easy screenshot capture and management along with flexible [cloud backup options][4]. including your own [FTP server][5].
![][6]
ScreenCloud is really streamlined with a lot of attention given to the smaller things. It provides you very easy to remember hotkeys to capture the full screen, the active window or capture an area selected with the mouse.
![][7]Default keyboard shortcuts for ScreenCloud
Once a screenshot is taken, you can either set ScreenCloud to ask what to do with the image or to directly upload it the cloud service of your choice. Even SFTP is supported. Once the screenshot it uploaded, generally within a couple of seconds, the link to the image is automatically copied to the clipboard, which you can easily share.
![][8]
You can also do some basic editing with ScreenCloud. For this, you should have “Save to” set to “Ask me”. This setting is available from the application indicator and is usually set by default. With this, when you take a screenshot, youll see the option for editing the file. Here, you can add arrows, text and numbers to the screenshot.
![Editing screenshots with ScreenCloud][9]Editing screenshots with ScreenCloud
### Installing ScreenCloud on Linux
ScreenCloud is available in the [Snap store][10]. So you can easily install it on Ubuntu and other [Snap enabled][11] distros by visiting the [Snap store][12] or by running the following command.
```
sudo snap install screencloud
```
And for Linux distros which cant install apps through Snap, You can download the AppImage [here][1]. The browse to the download location, right click and open a terminal there. Then run the command below.
```
sudo chmod +x ScreenCloud-v1.4.0-x86_64.AppImage
```
You can then launch the app by double clicking on the downloaded file.
![][13]
### Wrapping up
Is ScreenCloud for everybody? Probably not. Is it better than the default screenshot? Probably yes. See if youre taking a screenshot of something, then chances are, that its probably important or you intend to share it. ScreenCloud makes backing up or sharing that screenshot easier and considerably faster. So yeah, you should give ScreenCloud a try if you want these features.
Your thoughts and comments are always welcome, use the comments section below. And dont forget to share this article with your friends. Cheers.
--------------------------------------------------------------------------------
via: https://itsfoss.com/screencloud-app/
作者:[Aquil Roshan][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/aquil/
[1]: https://screencloud.net
[2]: https://itsfoss.com/take-screenshot-linux/
[3]: http://shutter-project.org
[4]: https://itsfoss.com/cloud-services-linux/
[5]: https://itsfoss.com/set-ftp-server-linux/
[6]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/screencloud3.jpg
[7]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/screencloud2.jpg
[8]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ScrenCloud6.jpg
[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/editing-with-screencloud.png
[10]: https://snapcraft.io/
[11]: https://itsfoss.com/install-snap-linux/
[12]: https://snapcraft.io/screencloud
[13]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/ScrenCloud4.jpg

View File

@ -0,0 +1,57 @@
A day in the life of a log message
======
Navigating a modern distributed system from the perspective of a log message.
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/plane_travel_world_international.png?itok=jG3sYPty)
Chaotic systems tend to be unpredictable. This is especially evident when architecting something as complex as a distributed system. Left unchecked, this unpredictability can waste boundless amounts of time. This is why every single component of a distributed system, no matter how small, must be designed to fit together in a streamlined way.
[Kubernetes][1] provides a promising model for abstracting compute resources—but even it must be reconciled with other distributed platforms such as [Apache Kafka][2] to ensure reliable data delivery. If someone were to integrate these two platforms, how would it work? Furthermore, if you were to trace something as simple as a log message through such a system, what would it look like? This article will focus on how a log message from an application running inside [OKD][3], the Origin Community Distribution of Kubernetes that powers Red Hat OpenShift, gets to a data warehouse through Kafka.
### OKD-defined environment
Such a journey begins in OKD, since the container platform completely overlays the hardware it abstracts. This means that the log message waits to be written to **stdout** or **stderr** streams by an application residing in a container. From there, the log message is redirected onto the node's filesystem by a container engine such as [CRI-O][4].
![](https://opensource.com/sites/default/files/uploads/logmessagepathway.png)
ithin OpenShift, one or more containers are encapsulated within virtual compute nodes known as pods. In fact, all applications running within OKD are abstracted as pods. This allows the applications to be manipulated in a uniform way. This also greatly simplifies communication between distributed components, since pods are systematically addressable through IP addresses and [load-balanced services][5] . So when the log message is taken from the node's filesystem by a log-collector application, it can easily be delivered to another pod running within OpenShift.
### Two peas in a pod
To ensure ubiquitous dispersal of the log message throughout the distributed system, the log collector needs to deliver the log message into a Kafka cluster data hub running within OpenShift. Through Kafka, the log message can be delivered to the consuming applications in a reliable and fault-tolerant way with low latency. However, in order to reap the benefits of Kafka within an OKD-defined environment, Kafka needs to be fully integrated into OKD.
Running a [Strimzi operator][6] will instantiate all Kafka components as pods and integrate them to run within an OKD environment. This includes Kafka brokers for queuing log messages, Kafka connectors for reading and writing from Kafka brokers, and Zookeeper nodes for managing the Kafka cluster state. Strimzi can also instantiate the log collector to double as a Kafka connector, allowing the log collector to feed the log messages directly into a Kafka broker pod running within OKD.
### Kafka inside OKD
When the log-collector pod delivers the log message to a Kafka broker, the collector writes to a single broker partition, appending the message to the end of the partition. One of the advantages of using Kafka is that it decouples the log collector from the log's final destination. Thanks to the decoupling, the log collector doesn't care whether the logs end up in [Elasticsearch][7], Hadoop, Amazon S3, or all of them at the same time. Kafka is well-connected to all infrastructure, so the Kafka connectors can take the log message wherever it needs to go.
Once written to a Kafka broker's partition, the log message is replicated across the broker partitions within the Kafka cluster. This is a very powerful concept on its own; combined with the self-healing features of the platform, it creates a very resilient distributed system. For example, when a node becomes unavailable, the applications running on the node are almost instantaneously spawned on healthy node(s). So even if a node with the Kafka broker is lost or damaged, the log message is guaranteed to survive as many deaths as it was replicated and a new Kafka broker will quickly take the original's place.
### Off to storage
After it is committed to a Kafka topic, the log message waits to be consumed by a Kafka connector sink, which relays the log message to either an analytics engine or logging warehouse. Upon delivery to its final destination, the log message could be studied for anomaly detection, queried for immediate root-cause analysis, or used for other purposes. Either way, the log message is delivered by Kafka to its destination in a safe and reliable manner.
OKD and Kafka are powerful distributed platforms that are evolving rapidly. It is vital to create systems that can abstract the complicated nature of distributed computing without compromising performance. After all, how can we boast of systemwide efficiency if we cannot simplify the journey of a single log message?
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/9/life-log-message
作者:[Josef Karásek][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/jkarasek
[1]: https://kubernetes.io/
[2]: https://kafka.apache.org/
[3]: https://www.okd.io/
[4]: http://cri-o.io/
[5]: https://kubernetes.io/docs/concepts/services-networking/service/
[6]: http://strimzi.io/
[7]: https://www.elastic.co/

View File

@ -0,0 +1,394 @@
Convert files at the command line with Pandoc
======
This guide shows you how to use Pandoc to convert your documents into many different file formats
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/email_paper_envelope_document.png?itok=uPj_kouJ)
Pandoc is a command-line tool for converting files from one markup language to another. Markup languages use tags to annotate sections of a document. Commonly used markup languages include Markdown, ReStructuredText, HTML, LaTex, ePub, and Microsoft Word DOCX.
In plain English, [Pandoc][1] allows you to convert a bunch of files from one markup language into another one. Typical examples include converting a Markdown file into a presentation, LaTeX, PDF, or even ePub.
This article will explain how to produce documentation in multiple formats from a single markup language (in this case Markdown) using Pandoc. It will guide you through Pandoc installation, show how to create several types of documents, and offer tips on how to write documentation that is easy to port to other formats. It will also explain the value of using meta-information files to create a separation between the content and the meta-information (e.g., author name, template used, bibliographic style, etc.) of your documentation.
### Installation and requirements
Pandoc is installed by default in most Linux distributions. This tutorial uses pandoc-2.2.3.2 and pandoc-citeproc-0.14.3. If you don't intend to generate PDFs, those two packages are enough. However, I recommend installing texlive as well, so you have the option to generate PDFs.
To install these programs on Linux, type the following on the command line:
```
sudo apt-get install pandoc pandoc-citeproc texlive
```
You can find [installation instructions][2] for other platforms on Pandoc's website.
I highly recommend installing [pandoc][3][-crossref][3], a "filter for numbering figures, equations, tables, and cross-references to them." The easiest option is to download a [prebuilt executable][4], but you can install it from Haskell's package manager, cabal, by typing:
```
cabal update
cabal install pandoc-crossref
```
Consult pandoc-crossref's GitHub repository if you need additional Haskell [installation information][5].
### Some examples
I'll demonstrate how Pandoc works by explaining how to produce three types of documents:
* A website from a LaTeX file containing math formulas
* A Reveal.js slideshow from a Markdown file
* A contract agreement document that mixes Markdown and LaTeX
#### Create a website with math formulas
One of the ways Pandoc excels is displaying math formulas in different output file formats. For instance, let's generate a website from a LaTeX document (named math.tex) containing some math symbols (written in LaTeX).
The math.tex document looks like:
```
% Pandoc math demos
$a^2 + b^2 = c^2$
$v(t) = v_0 + \frac{1}{2}at^2$
$\gamma = \frac{1}{\sqrt{1 - v^2/c^2}}$
$\exists x \forall y (Rxy \equiv Ryx)$
$p \wedge q \models p$
$\Box\diamond p\equiv\diamond p$
$\int_{0}^{1} x dx = \left[ \frac{1}{2}x^2 \right]_{0}^{1} = \frac{1}{2}$
$e^x = \sum_{n=0}^\infty \frac{x^n}{n!} = \lim_{n\rightarrow\infty} (1+x/n)^n$
```
Convert the LaTeX document into a website named mathMathML.html by entering the following command:
```
pandoc math.tex -s --mathml  -o mathMathML.html
```
The flag **-s** tells Pandoc to generate a standalone website (instead of a fragment, so it will include the head and body HTML tags), and the **mathml** flag forces Pandoc to convert the math in LaTeX to MathML, which can be rendered by modern browsers.
![](https://opensource.com/sites/default/files/uploads/pandoc_math-formulas.png)
Take a look at the [website result][6] and the [code][7]; the code repository contains a Makefile to make things even simpler.
#### Make a Reveal.js slideshow
It's easy to generate simple presentations from a Markdown file using Pandoc. The slides contain top-level slides and nested slides underneath. The presentation can be controlled from the keyboard, and you can jump from one top-level slide to the next top-level slide or show the nested slides on a per-top-level basis. This structure is typical in HTML-based presentation frameworks.
Let's create a slide document named SLIDES (see the [code repository][8]). First, add the slides' meta-information (e.g., title, author, and date) prepended by the **%** symbol:
```
% Case Study
% Kiko Fernandez Reyes
% Sept 27, 2017
```
This meta-information also creates the first slide. To add more slides, declare top-level slides using Markdown heading H1 (line 5 in the example below, [heading 1 in Markdown][9] , designated by).
For example, if we want to create a presentation with the title Case Study that starts with a top-level slide titled Wine Management System, write:
```
% Case Study
% Kiko Fernandez Reyes
% Sept 27, 2017
# Wine Management System
```
To put content (such as slides that explain a new management system and its implementation) inside this top-level section, use a Markdown header H2. Let's add two more slides (lines 7 and 14 below, [heading 2 in Markdown][9], designated by **##** ):
* The first second-level slide has the title Idea and shows an image of the Swiss flag
* The second second-level slide has the title Implementation
```
% Case Study
% Kiko Fernandez Reyes
% Sept 27, 2017
# Wine Management System
## <img src="img/SwissFlag.png" style="vertical-align:middle"/> Idea
## Implementation
```
We now have a top-level slide ( **# Wine Management System** ) that contains two slides ( **## Idea** and **## Implementation** ).
Let's put some content in these two slides using incremental bulleted lists by creating a Markdown list prepended by the symbol **>**. Continuing from above, add two items in the first slide (lines 910 below) and five items in the second slide (lines 1620):
```
% Case Study
% Kiko Fernandez Reyes
% Sept 27, 2017
# Wine Management System
## <img src="img/SwissFlag.png" style="vertical-align:middle"/> Idea
>- Swiss love their **wine** and cheese
>- Create a *simple* wine tracker system
![](img/matterhorn.jpg)
## Implementation
>- Bottles have a RFID tag
>- RFID reader (emits and read signal)
>- **Raspberry Pi**
>- **Server (online shop)**
>- Mobile app
```
We added an image of the Matterhorn mountain. Your slides can be improved by using plain Markdown or adding plain HTML.
To generate the slides, Pandoc needs to point to the Reveal.js library, so it must be in the same folder as the SLIDES file. The command to generate the slides is:
```
pandoc -t revealjs -s --self-contained SLIDES \
-V theme=white -V slideNumber=true -o index.html
```
![](https://opensource.com/sites/default/files/uploads/pandoc_matterhorn-slide.png)
The above Pandoc command uses the following flags:
* **-t revealjs** specifies we are going to output a **revealjs** presentation
* **-s** tells Pandoc to generate a standalone document
* **\--self-contained** produces HTML with no external dependencies
* **-V** sets the following variables:
**theme=white** sets the theme of the slideshow to **white**
**slideNumber=true** shows the slide number
* **-o index.html** generates the slides in the file named **index.html**
To make things simpler and avoid typing this long command, create the following Makefile:
```
all: generate
generate:
    pandoc -t revealjs -s --self-contained SLIDES \
    -V theme=white -V slideNumber=true -o index.html
clean: index.html
    rm index.html
.PHONY: all clean generate
```
You can find all the code in [this repository][8].
#### Make a multi-format contract
Let's say you are preparing a document and (as things are nowadays) some people want it in Microsoft Word format, others use free software and would like an ODT, and others need a PDF. You do not have to use OpenOffice nor LibreOffice to generate the DOCX or PDF file. You can create your document in Markdown (with some bits of LaTeX if you need advanced formatting) and generate any of these file types.
As before, begin by declaring the document's meta-information (title, author, and date):
```
% Contract Agreement for Software X
% Kiko Fernandez-Reyes
% August 28th, 2018
```
Then write the document in Markdown (and add LaTeX if you require advanced formatting). For example, create a table that needs fixed separation space (declared in LaTeX with **\hspace{3cm}** ) and a line where a client and a contractor should sign (declared in LaTeX with **\hrulefill** ). After that, add a table written in Markdown.
Here's what the document will look like:
![](https://opensource.com/sites/default/files/uploads/pandoc_agreement.png)
The code to create this document is:
```
% Contract Agreement for Software X
% Kiko Fernandez-Reyes
% August 28th, 2018
...
### Work Order
\begin{table}[h]
\begin{tabular}{ccc}
The Contractor & \hspace{3cm} & The Customer \\
& & \\
& & \\
\hrulefill & \hspace{3cm} & \hrulefill \\
%
Name & \hspace{3cm} & Name \\
& & \\
& & \\
\hrulefill & \hspace{3cm} & \hrulefill \\
...
\end{tabular}
\end{table}
\vspace{1cm}
+--------------------------------------------|----------|-------------+
| Type of Service                            | Cost     |     Total   |
+:===========================================+=========:+:===========:+
| Game Engine                                | 70.0     | 70.0        |
|                                            |          |             |
+--------------------------------------------|----------|-------------+
|                                            |          |             |
+--------------------------------------------|----------|-------------+
| Extra: Comply with defined API functions   | 10.0     | 10.0        |
|        and expected returned format        |          |             |
+--------------------------------------------|----------|-------------+
|                                            |          |             |
+--------------------------------------------|----------|-------------+
| **Total Cost**                             |          | **80.0**    |
+--------------------------------------------|----------|-------------+
```
To generate the three different output formats needed for this document, write a Makefile:
```
DOCS=contract-agreement.md
all: $(DOCS)
    pandoc -s $(DOCS) -o $(DOCS:md=pdf)
    pandoc -s $(DOCS) -o $(DOCS:md=docx)
    pandoc -s $(DOCS) -o $(DOCS:md=odt)
clean:
    rm *.pdf *.docx *.odt
.PHONY: all clean
```
Lines 47 contain the commands to generate the different outputs.
If you have several Markdown files and want to merge them into one document, issue a command with the files in the order you want them to appear. For example, when writing this article, I created three documents: an introduction document, three examples, and some advanced uses. The following tells Pandoc to merge these files together in the specified order and produce a PDF named document.pdf.
```
pandoc -s introduction.md examples.md advanced-uses.md -o document.pdf
```
### Templates and meta-information
Writing a complex document is no easy task. You need to stick to a set of rules that are independent from your content, such as using a specific template, writing an abstract, embedding specific fonts, and maybe even declaring keywords. All of this has nothing to do with your content: simply put, it is meta-information.
Pandoc uses templates to generate different output formats. There is a template for LaTeX, another for ePub, etc. These templates have unfulfilled variables that are set with the meta-information given to Pandoc. To find out what meta-information is available in a Pandoc template, type:
```
pandoc -D FORMAT
```
For example, the template for LaTeX would be:
```
pandoc -D latex
```
Which outputs something along these lines:
```
$if(title)$
\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
$endif$
$if(subtitle)$
\providecommand{\subtitle}[1]{}
\subtitle{$subtitle$}
$endif$
$if(author)$
\author{$for(author)$$author$$sep$ \and $endfor$}
$endif$
$if(institute)$
\providecommand{\institute}[1]{}
\institute{$for(institute)$$institute$$sep$ \and $endfor$}
$endif$
\date{$date$}
$if(beamer)$
$if(titlegraphic)$
\titlegraphic{\includegraphics{$titlegraphic$}}
$endif$
$if(logo)$
\logo{\includegraphics{$logo$}}
$endif$
$endif$
\begin{document}
```
As you can see, there are **title** , **thanks** , **author** , **subtitle** , and **institute** template variables (and many others are available). These are easily set using YAML metablocks. In lines 15 of the example below, we declare a YAML metablock and set some of those variables (using the contract agreement example above):
```
---
title: Contract Agreement for Software X
author: Kiko Fernandez-Reyes
date: August 28th, 2018
---
(continue writing document as in the previous example)
```
This works like a charm and is equivalent to the previous code:
```
% Contract Agreement for Software X
% Kiko Fernandez-Reyes
% August 28th, 2018
```
However, this ties the meta-information to the content; i.e., Pandoc will always use this information to output files in the new format. If you know you need to produce multiple file formats, you better be careful. For example, what if you need to produce the contract in ePub and in HTML, and the ePub and HTML need specific and different styling rules?
Let's consider the cases:
* If you simply try to embed the YAML variable **css: style-epub.css** , you would be excluding the one from the HTML version. This does not work.
* Duplicating the document is obviously not a good solution either, as changes in one version would not be in sync with the other copy.
* You can add variables to the Pandoc command line as follows:
```
pandoc -s -V css=style-epub.css document.md document.epub
pandoc -s -V css=style-html.css document.md document.html
```
My opinion is that it is easy to overlook these variables from the command line, especially when you need to set tens of these (which can happen in complex documents). Now, if you put them all together under the same roof (a meta.yaml file), you only need to update or create a new meta-information file to produce the desired output. You would then write:
```
pandoc -s meta-pub.yaml document.md document.epub
pandoc -s meta-html.yaml document.md document.html
```
This is a much cleaner version, and you can update all the meta-information from a single file without ever having to update the content of your document.
### Wrapping up
With these basic examples, I have shown how Pandoc can do a really good job at converting Markdown documents into other formats.
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/9/intro-pandoc
作者:[Kiko Fernandez-Reyes][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/kikofernandez
[1]: https://pandoc.org/
[2]: http://pandoc.org/installing.html
[3]: https://hackage.haskell.org/package/pandoc-crossref
[4]: https://github.com/lierdakil/pandoc-crossref/releases/tag/v0.3.2.1
[5]: https://github.com/lierdakil/pandoc-crossref#installation
[6]: http://pandoc.org/demo/mathMathML.html
[7]: https://github.com/kikofernandez/pandoc-examples/tree/master/math
[8]: https://github.com/kikofernandez/pandoc-examples/tree/master/slides
[9]: https://daringfireball.net/projects/markdown/syntax#header

View File

@ -1,118 +0,0 @@
Getting started with the i3 window manager on Linux
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows-tiling-windows-wall.png?itok=mTH7uVrn)
In my article [5 reasons the i3 window manager makes Linux better][1], I shared the top five reasons I use and recommend the [i3 window manager][2] as an alternative Linux desktop experience.
In this post, I will walk through the installation and basic configuration of i3 on Fedora 28 Linux.
### 1\. Installation
Log into a Fedora workstation and open up a terminal. Use `dnf` to install the required package, like this:
```
[ricardo@f28i3 ~]$ sudo dnf install -y i3 i3-ipc i3status i3lock dmenu terminator --exclude=rxvt-unicode
Last metadata expiration check: 1:36:15 ago on Wed 08 Aug 2018 12:04:31 PM EDT.
Dependencies resolved.
================================================================================================
 Package                     Arch         Version                           Repository     Size
================================================================================================
Installing:
 dmenu                       x86_64       4.8-1.fc28                        fedora         33 k
 i3                          x86_64       4.15-1.fc28                       fedora        323 k
 i3-ipc                      noarch       0.1.4-12.fc28                     fedora         14 k
 i3lock                      x86_64       2.9.1-2.fc28                      fedora         33 k
 i3status                    x86_64       2.12-1.fc28                       updates        62 k
 terminator                  noarch       1.91-4.fc28                       fedora        570 k
Installing dependencies:
 dzen2                       x86_64       0.8.5-21.20100104svn.fc28         fedora         60 k
... Skipping dependencies/install messages
Complete!
[ricardo@f28i3 ~]$
```
**Note:** In this command, I'm explicitly excluding the package `rxvt-unicode` because I prefer `terminator` as my terminal emulator.
Depending on the status of your system, it may install many dependencies. Wait for the installation to complete successfully and then reboot your machine.
### 2. First login and initial setup
After your machine restarts, you're ready to log into i3 for the first time. In the GNOME Display Manager (GDM) screen, click on your username but—before typing the password to log in—click on the small gear icon and change the session to i3 instead of GNOME, like this:
![](https://opensource.com/sites/default/files/uploads/i3_first_login_small.png)
Type your password and click `Sign In`. On your first login, you are presented with the i3 configuration screen:
![](https://opensource.com/sites/default/files/uploads/i3_first_configuration_small.png)
Press `ENTER` to generate a config file in your `$HOME/.config/i3` directory. Later you can use this config file to further customize i3's behavior.
On the next screen, you need to select your `Mod` key. This is important, as the `Mod` key is used to trigger most of i3's keyboard shortcuts. Press `ENTER` to use the default `Win` key as the `Mod` key. If you don't have a `Win` key on your keyboard or prefer to use `Alt` instead, use the arrow key to select it and press `ENTER` to confirm.
![](https://opensource.com/sites/default/files/uploads/i3_generate_config_small.png)
You're now logged into your i3 session. Because i3 is a minimalist window manager, you see a black screen with the status bar on the bottom:
![](https://opensource.com/sites/default/files/uploads/i3_start_small.png)
Next, let's look at navigating in i3.
### 3\. Basic shortcuts
Now that you're logged into an i3 session, you'll need a few basic keyboard shortcuts to get around.
The majority of i3 shortcuts use the `Mod` key you defined during the initial configuration. When I refer to `Mod` in the following examples, press the key you defined. This will usually be the `Win` key, but it can also be the `Alt` key.
First, to open up a terminal, use `Mod+ENTER`. Open more than one terminal and notice how i3 automatically tiles them to occupy all available space. By default, i3 splits the screen horizontally; use `Mod+v` to split vertically and press `Mod+h` to go back to the horizontal split.
![](https://opensource.com/sites/default/files/uploads/i3_3terminal_tiled_small.png)
To start other applications, press `Mod+d` to open `dmenu`, a simple text-based application menu. By default, `dmenu` presents a list of all applications available on your `$PATH`. Select the application you want to start by using the arrow keys or narrow down the search by typing parts of the application's name. Press `ENTER` to start the selected application.
![](https://opensource.com/sites/default/files/uploads/i3_dmenu.png)
If your application does not provide a way to close it, you can use i3 to kill a window by pressing `Mod+Shift+q`. Be careful, as you may lose unsaved work—this behavior depends on each application.
Finally, to end your session and exit i3, press `Mod+Shift+e`. You are presented with a confirmation message at the top of your screen. Click on `Yes, exit i3` to exit or `X` to cancel.
![](https://opensource.com/sites/default/files/uploads/i3_exit_small.png)
This is just an initial list of shortcuts you can use to get around i3. For many more, consult i3's official [documentation][3].
### 4\. Replacing GDM
Using i3 window manager reduces the memory utilization on your system; however, Fedora still uses the default GDM as its login screen. GDM loads several GNOME-related libraries and applications that consume memory.
If you want to further reduce your system's memory utilization, you can replace GDM with a more lightweight display manager, such as `lightdm`, like this:
```
[ricardo@f28i3 ~]$ sudo dnf install -y lightdm
[ricardo@f28i3 ~]$ sudo systemctl disable gdm
Removed /etc/systemd/system/display-manager.service.
[ricardo@f28i3 ~]$ sudo systemctl enable lightdm
Created symlink /etc/systemd/system/display-manager.service -> /usr/lib/systemd/system/lightdm.service.
[ricardo@f28i3 ~]$
```
Restart your machine to see the Lightdm login screen.
Now you're ready to log in and use i3.
![](https://opensource.com/sites/default/files/uploads/i3_lightdm_small.png)
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/8/getting-started-i3-window-manager
作者:[Ricardo Gerardi][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/rgerardi
[1]: https://opensource.com/article/18/8/i3-tiling-window-manager
[2]: https://i3wm.org
[3]: https://i3wm.org/docs/userguide.html#_default_keybindings

View File

@ -0,0 +1,52 @@
在OpenDev上掌握CI/CD(持续集成/持续发布)
======
![在OpenDev上掌握CI/CD](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_opennature_3.png?itok=J1OSECM_)
在2017年启动后OpenDev会议现在是一个年度活动。在去年9月的首届活动上会议的重点是边缘计算。今年的活动将于5月22-23日举行会议的重点是持续集成和持续发布 (CI/CD)并将与OpenStack峰会一起在温哥华举行。
基于我在OpenStack项目的CI/CD系统的技术背景和近期进入容器下的CI/CD方面的经验我被邀请加入OpenDev CI/CD的编程委员会。今天我经常通过很多开源技术例如[Jenkins][3] [GitLab][2],[Spinnaker][4],和[Artifactory][5],来讨论CI/CD流水管线。
这次活动对我来说是很激动人心的因为我们将在这个活动中融合两个开源基础设施理念。首先我们将讨论可以被任何组织使用的CI/CD工具。为此目的在[keynotes][6],我们将听到关于开源CI/CD工具的使用讲座一场来自Boris Renski的关于Spinnaker的和一场来自Jim Blair的关于[Zuul][7]的。同时讲座会涉及关于开源技术的偏好的高级别话题特别是那种跨社区的和本身就是开源项目的。从Fatih Degirmenci和Daniel Farrel那里我们将听到关于在不同社区分享持续发布实践经历接着Benjamin Mako Hill会为我带来一场关于为什么免费软件需要免费工具的分享。
在分享CI/CD相对新颖特性后接下来的活动是对话研讨会和协作讨论的混合组合。当从所提交的讲座和研讨会选择并提出协作讨论主题时我们希望确保有一个多样灵活的日程表这样任何参与者都能在CI/CD活动进程中发现有趣的东西。
这些讲座会是标准的会议风格选择以涵盖关键主题如制作CI/CD管线在实践DevOps时提升安全性以及更具体的解决方案如基于容器关于Kubernetes的[Aptomi][8]和在ETSI NFV环境下CI/CD。这些会话的大部分将会是作为给新接触CI/CD或这些特定技术的参与者关于这些话题和理念的简介。
交互式的研讨会会持续相对比较长的时间,参与者将会在思想上得到特定的体验。这些研讨会包括"[Anomaly Detection in Continous Integration Jobs(在持续集成任务中的异常检测)][9]","[How to Install Zuul and Configure Your First Jobs(如何安装Zuul和配置第一个任务)][10]",和"[Spinnake 101: Releasing Software with Velocity and Confidence(Spinnake 101:快速可靠的软件发布)][11]."(注意这些研讨会空间是有限的所以设立了一个RSVP系统。你们将会在会议的链接里找到一个RSVP的按钮。)
可能最让我最兴奋的是协作讨论这些协作讨论占据了一半以上的活动安排。协作讨论的主题由编程委员会选取。编程委员会是根据我们在社区里所看到选取对应的主题。这是“鱼缸”风格式的会议通常是几个人聚在一个房间里围绕着CI/CD讨论某一个主题。
这次会议风格的理念是来自于开发者峰会最初是由Ubuntu社区提出接着OpenStack社区在活动上采纳。这些协作讨论的主题包含不同的会议这些会议是关于CI/CD基础可以鼓励跨社区协作的提升举措在组织里推行CI/CD文化和为什么开源CI/CD工具如此重要。采用共享文档来做会议笔记以确保尽可能的在会议的过程中分享知识。在讨论过程中提出行动项目也是很常见的因此社区成员可以推动和所涉及的主题相关的倡议。
活动将以联合总结会议结束。联合总结会议将总结来自协同讨论的关键点和为即将在这个领域工作的参与者指出可选的职业范围。
可以在[OpenStack Summit registration(OpenStack峰会注册)][13]上注册参加活动。或者可以在温哥华唯一指定售票的会议中心购买活动的入场券,价格是$199。更多关于票和全部的活动安排见官网[OpenDev website][1]。
我希望你们能够加入我们并在温哥华渡过令人激动的两天并且在这两天的活动中学习协作和在CI/CD取得进展。
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/5/opendev
作者:[Elizabeth K.Joseph][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[jamelouis](https://github.com/jamelouis)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/pleia2
[1]:http://2018.opendevconf.com/
[2]:https://about.gitlab.com/
[3]:https://jenkins.io/
[4]:https://www.spinnaker.io/
[5]:https://jfrog.com/artifactory/
[6]:http://2018.opendevconf.com/schedule/
[7]:https://zuul-ci.org/
[8]:http://aptomi.io/
[9]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21692/anomaly-detection-in-continuous-integration-jobs
[10]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21693/how-to-install-zuul-and-configure-your-first-jobs
[11]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21699/spinnaker-101-releasing-software-with-velocity-and-confidence
[12]:https://www.openstack.org/summit/vancouver-2018/summit-schedule/events/21831/opendev-cicd-joint-collab-conclusion
[13]:https://www.eventbrite.com/e/openstack-summit-may-2018-vancouver-tickets-40845826968?aff=VancouverSummit2018

View File

@ -1,168 +0,0 @@
heguangzhi Translating
面向敏捷开发团队的7个开源项目管理工具
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/BUSINESS_orgchart1.png?itok=tukiFj89)
Opensource.com 以前对流行的开源项目管理工具的过相应的调研。但是今年我们增加了一个特点。本次,我们特别关注支持[敏捷][1]方法的工具,包括相关的实践,如[Scrum][2]、 Lean, and Kanban。
对敏捷开发的兴趣和使用的增长是我们今年决定专注于这些工具的原因。大多数组织-71%的人说他们至少使用了敏捷方法3[are using agile approaches][3]。此外敏捷项目比传统方法管理的项目要高出28%4[28% more successful][4] 。
我们查看了[2014][5]、[2015][6]和[2016][7]中涉及的项目管理工具并挑选了支持敏捷的工具然后进行了研究并做了添加或更改。不管您的组织是否已经在使用敏捷开发或者是2018年采用敏捷方法的作为众多计划之一这七个开源项目管理工具之一可能正是您所要找寻的。
### MyCollab
![](https://opensource.com/sites/default/files/u128651/mycollab_kanban-board.png)
MyCollab][8]是一套针对中小型企业的三个协作模块项目管理、客户关系管理CRM和文档创建和编辑的软件。有两个许可选项一个商业的“终极”版本它更快可以在内部或云中运行另一个开源的“社区版本”这个正是我们感兴趣的版本。
由于没有使用查询缓存,社区版本没有云选项,并且速度较慢,但是提供了基本的项目管理特性,包括任务、问题管理、活动流、路线图视图和敏捷团队看板。虽然它没有单独的移动应用程序,但它也适用于移动设备,包括 Windows、Mac OS、Linux 和 UNIX 计算机。
The latest version of MyCollab is 5.4.10 and the source code is available on [GitHub][9]. It is licensed under AGPLv3 and requires a Java runtime and MySQL stack to operate. It's available for [download][10] for Windows, Linux, Unix, and MacOS.
MyCulb的最新版本是5.4.10,源代码可在 [GitHub][9] 上下载。它是在 AgPLv3 下进行授权的,需要 Java 运行和 MySQL支持。它可运行于 Windows、Linux、UNIX 和 MacOS 。下载地址 [download][10]。
### Odoo
![](https://opensource.com/sites/default/files/u128651/odoo_projects_screenshots_01a.gif)
[Odoo][11] 不仅仅是项目管理软件它是一个完整的集成商业应用套件包括会计、人力资源、网站和电子商务、库存、制造、销售管理CRM和其他工具。
与付费企业套件相比,免费开源社区版具有有限的[特性][12] 。它的项目管理应用程序包括敏捷团队的看板式任务跟踪视图在最新版本Odoo 11.0中更新了该视图以包括用于跟踪项目状态的进度条和动画。项目管理工具还包括甘特图、任务、问题、图表等等。Odoo有一个繁荣的[社区][13],并提供 [用户指南][14] 及其他培训资源。
它是在 GPLv3 下授权的,需要 Python 和 PostgreSQL 支持。作为[Docker][16] 镜像 可以运行在 Windows、Linux 和 Red Hat 包管理器中,下载地址[download][15],源代码[GitHub][17]。
### OpenProject
![](https://opensource.com/sites/default/files/u128651/openproject-screenshot-agile-scrum.png)
[OpenProject][18] 是一个强大的开源项目管理工具,以其易用性和丰富的项目管理和团队协作特性而著称。
它的模块支持项目计划、调度、路线图和发布计划、时间跟踪、成本报告、预算、bug跟踪以及敏捷和Scrum。它的敏捷特性包括创建Story、确定sprint的优先级以及跟踪任务都与OpenProject的其他模块集成在一起。
OpenProject 在 GPLv3 下获得许可,其源代码可在[GitHub][19]上。最新版本7.3.2 for Linux [download][20];您可以在 Birthe Lindenthal 的文章 “[Getting start of OpenProject][21]"中了解更多关于安装和配置它的信息。
### OrangeScrum
![](https://opensource.com/sites/default/files/u128651/orangescrum_kanban.png)
正如从其名称中猜到的,[OrangeScrum][22]支持敏捷方法特别是使用Scrum任务板和看板式工作流视图。它面向较小的组织自由职业者、中介机构和中小型企业。
源版本提供了 OrangeScrum 付费版本中的许多[特性][23],包括移动应用程序、资源利用率和进度跟踪。其他特性,包括甘特图、时间日志、发票和客户端管理,可以作为付费附加组件提供,付费版本包括云选项,而社区版本不提供。
OrangeScrum 是基于 GPLv3 授权的,是基于 CakePHP 框架开发。它需要 Apache、PHP 5.3 或更高版本和 MySQL 4.1 或更高版本支持,并可以在 Windows、Linux 和 Mac OS 上运行。其最新版本1.1.1,下载地址 [download][24],其源码[GitHub] [25]。
### ]project-open[
![](https://opensource.com/sites/default/files/u128651/projectopen_dashboard.png)
[]project-open[][26]是一个双许可的企业项目管理工具,这意味着其核心是开源的,并且在商业许可的模块中可以使用一些附加特性。根据社区和企业版本的项目[比较][27],开源核心为中小型组织提供了许多特性。
]project-open[ 支持Scrum和看板[敏捷][28]项目,以及经典的甘特/瀑布项目和混合或混合项目。
该应用程序是在 GPL 下授权的,并且[source code][29]是通过 CVS 访问的。 ]project-open[ 在 Linux 和 Windows 的安装可用 [installers][26],但也可以在云镜像和虚拟设备中使用。
### Taiga
![](https://opensource.com/sites/default/files/u128651/taiga_screenshot.jpg)
[Taiga][30] 是一个开源项目管理平台它专注于Scrum和敏捷开发其特征包括看板、任务、sprints、问题、backlog 和epics。其他功能包括 ticke 管理、多项目支持、Wiki页面和第三方集成。
它还为iOS、Android和Windows设备提供免费的移动应用程序并提供导入工具使从其他流行的项目管理应用程序迁移变得容易。
Taiga 对于公共项目是免费的,对项目数量或用户数量没有限制。对于私有项目,在“免费增值”模式下,有很多[付费计划][31]可用,但是值得注意的是,无论您有哪种类型,软件的功能特性都是一样的。
Taiga 是在GNU Affero GPLv3 下授权的,并且软件需要 Nginx、Python 和 PostgreSQL 支持。最新版本[3.1.0 PrimovsialpopiculoLII][32],可在[GitHub][33]上下载。
### Tuleap
![](https://opensource.com/sites/default/files/u128651/tuleap-scrum-prioritized-backlog.png)
[Tuleap][34]是一个应用程序生命周期管理ALM平台旨在为每种类型的团队管理项目——小型、中型、大型、瀑布、敏捷或混合型——但是它对敏捷团队的支持是显著的。值得注意的是它为Scrum、看板、sprints、任务、报告、持续集成、backlogs等提供支持.
其他的[特性][35]包括问题跟踪、文档跟踪、协作工具,以及与 Git、SVN 和 Jenkins 的集成,所有这些都使它成为开放源码软件开发项目的吸引人的选择。
TuleAP 是在 GPLv2 下授权的。更多信息,包括 Docker 和 CentOS 下载,可以在他们的 [Get Started][36] 页面上找到。您还可以在TuleAP的 [Git][37] 上获取其最新版本9.14的源代码。
这种类型的列表的麻烦在于它一发布就过时了。使用开源项目管理工具来支持我们忘记包含的敏捷吗?或者你对我们提到的有反馈吗?请在下面留下评论。
这种类型的文章的麻烦在于它一发布就过时了。那些您正在使用开源项目管理工具,而被我们遗漏了?或者您对我们提到的有反馈意见吗?请在下面留下留言。
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/2/agile-project-management-tools
作者:[Opensource.com][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
[1]:http://agilemanifesto.org/principles.html
[2]:https://opensource.com/resources/scrum
[3]:https://www.pmi.org/-/media/pmi/documents/public/pdf/learning/thought-leadership/pulse/pulse-of-the-profession-2017.pdf
[4]:https://www.pwc.com/gx/en/actuarial-insurance-services/assets/agile-project-delivery-confidence.pdf
[5]:https://opensource.com/business/14/1/top-project-management-tools-2014
[6]:https://opensource.com/business/15/1/top-project-management-tools-2015
[7]:https://opensource.com/business/16/3/top-project-management-tools-2016
[8]:https://community.mycollab.com/
[9]:https://github.com/MyCollab/mycollab
[10]:https://www.mycollab.com/ce-registration/
[11]:https://www.odoo.com/
[12]:https://www.odoo.com/page/editions
[13]:https://www.odoo.com/page/community
[14]:https://www.odoo.com/documentation/user/11.0/
[15]:https://www.odoo.com/page/download
[16]:https://hub.docker.com/_/odoo/
[17]:https://github.com/odoo/odoo
[18]:https://www.openproject.org/
[19]:https://github.com/opf/openproject
[20]:https://www.openproject.org/download-and-installation/
[21]:https://opensource.com/article/17/11/how-install-and-use-openproject
[22]:https://www.orangescrum.org/
[23]:https://www.orangescrum.org/compare-orangescrum
[24]:http://www.orangescrum.org/free-download
[25]:https://github.com/Orangescrum/orangescrum/
[26]:http://www.project-open.com/en/list-installers
[27]:http://www.project-open.com/en/products/editions.html
[28]:http://www.project-open.com/en/project-type-agile
[29]:http://www.project-open.com/en/developers-cvs-checkout
[30]:https://taiga.io/
[31]:https://tree.taiga.io/support/subscription-and-plans/payment-process-faqs/#q.-what-s-about-custom-plans-private-projects-with-more-than-25-members-?
[32]:https://blog.taiga.io/taiga-perovskia-atriplicifolia-release-310.html
[33]:https://github.com/taigaio
[34]:https://www.tuleap.org/
[35]:https://www.tuleap.org/features/project-management
[36]:https://www.tuleap.org/get-started
[37]:https://tuleap.net/plugins/git/tuleap/tuleap/stable

View File

@ -1,179 +0,0 @@
如何从文件管理器中加密文件
======
![](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/encryption.jpg?itok=Pk3_x5hz)
Linux 桌面版和服务器版具有卓越的安全性。然而这并不意味着你可以放松警惕。你应该一直认为你的数据总是很快就会被破坏。也就是说,你可能需要使用各种加密工具。比如 GnuPG它可以让你加密和解密文件等更多功能。GnuPG 的一个问题是一些用户不想扰乱命令行。如果是这样的话,你可以转向桌面文件管理器。许多 Linux 桌面版包含了简易的加密和解密文件的功能,如果这种功能没有内置,那么也是很容易添加的。
我将引导你完成从三个流行的 Linux 文件管理器中对文件进行加密和解密过程:
* Nautilus (aka GNOME Files)
* Dolphin
* Thunar
### 安装 GnuPG
在我们讨论如何处理这个问题之前,我们必须确保你的系统包含了必要的基本组件... [GnuPG][1]。大多数发行版本都包含 GnuPG。 在某些偶然情况下,你使用的是没有自带 GnuPG 的发行版本,以下是安装方法:
* 基于 Ubuntu 的发行版: sudo apt install gnupg
* 基于 Fedora 的发行版: sudo yum install gnupg
* openSUSE sudo zypper in gnupg
* 基于 Arch 的发行版sudo pacman -S gnupg
无论你是刚刚安装了 GnuPG还是默认安装的你都必须创建一个 GPG 密钥才能使用。每个桌面版都使用了不同的 GUI 工具(或者甚至不包含一个 GUI 工具来完成这个任务),所以让我们从命令行中创建这个密钥。打开终端窗口并输入以下指令:
```
gpg --gen-key
```
然后,你将被要求回答以下问题。除非你有充分的理由,否则你可以接受默认值:
* 你想要哪种密钥?
* 你想要多大的密钥?
* 密钥是否有效?
一旦你回答了这些问题,输入 y 来表示答案是正确的。接下来你需要提供以下信息:
* 真实姓名。
* Email 地址。
* 评论。
完成上述操作后,然后在提示的时候输入 o (为了 ok )。然后,你将被要求为新密钥输入一个密码。一旦系统收集到了足够的熵(你需要在桌面上做一些工作才能做到这一点),你的密钥就会被创建,然后你就可以开始工作了。
让我们看看如何从文件管理器中加密/解密文件:
### Nautilus
让我们从默认的 GNOME 文件管理器开始因为它是最简单的。Nautilus 不需要额外的安装或额外的工作就可以从精心设计的接口内加密/解密文件。一旦你创建完 gpg 密钥后,就可以打开文件管理器,导航到包含要加密的文件的目录,右键单击要加密的文件,然后从菜单中选择 Encrypt 图1
![nautilus][3]
图1从 Nautilus 中加密文件。
[Used with permission][4]
你将被要求选择一个收件人或者收件人列表—图2。注意收件人将是那些你已经导入了公钥的用户。选择所需的密钥然后从签名信息下拉列表中选择你的密钥电子邮件地址
![nautilus][6]
图2选择收件人和签名者。
[Used with permission][4]
注意:你还可以选择仅使用密码来加密文件。如果文件将保留在你的本地机器上,这一点非常重要(稍后将详细介绍)。一旦你设置好加密后,单击 OK 并(在提示时)输入 gpg 密钥的密码。文件将被加密(现在以 .gpg 结尾)并保存在工作目录中。现在你可以将加密后的文件发送给在加密过程中已选择的收件人。
说某人(谁拥有你的公钥)已经给你发送了一个加密文件。保存该文件,打开文件管理器,导航到该文件所在的目录,右击加密文件,选择 Open With Decrypt File给文件一个新名称不带 .gpg 的扩展名),然后单击“保存”。当提示时,输入你的 gpg 密钥的密码,该文件将被解密并准备使用。
### Dolphin
在KDE前端必须安装一个软件包才能使用 Dolphin 文件管理器进行加密/解密。 登录到你的KDE桌面打开终端窗口然后输入以下命令我正在使用 Neon 进行演示。如果你的发行版不是基于Ubuntu 的,则必须相应地更改命令):
```
sudo apt install kgpg
```
安装完毕后注销并重新登录KDE桌面。 你可以打开 Dolphin 并右键单击要加密的文件。 由于这是你第一次使用 kgpg因此你必须完成快速设置向导不言自明。 当完成向导后你可以返回该文件右键单击它图3然后选择 Encrypt File。
![Dolphin][8]
图3在 Dolphin 中加密文件。
[Used with permission][4]
系统将提示你选择用于加密的密钥图4。 进行选择并单击 OK。 该文件将被加密,而且你已准备好将其发送给收件人。
注意:使用 KDE 的 Dolphin 文件管理器市,你无法仅使用密码加密。
![Dolphin][10]
图4选择要加密的收件人。
[Used with permission][4]
如果你收到来自拥有公钥的用户的加密文件(或者你有自己加密的文件),请打开 Dolphin导航到相关文件双击该文件为该文件指定一个新名称 ,键入加密密码并单击 OK。 你现在可以读取到新解密的文件。 如果你使用自己的密钥加密了该文件,则不会提示你键入密码(因为它已经被存储了)。
### Thunar
Thunar文件管理器有点棘手。 没有任何额外的软件包可供安装; 相反,你需要为了加密创建新的自定义操作。完成此操作后,你将能够在文件管理器中执行此操作。
要创建自定义操作,请打开 Thunar 文件管理器,然后单击 Edit > Configure Custom Actions。 在所得到的窗口中,单击 + 按钮图5并为加密操作输入以下内容
名称:加密
描述:文件加密
命令gnome-terminal -x gpg --encrypt --recipientf
单击 OK 以保存此操作。
![Thunar][12]
图5在Thunar中创建自定义操作。
[Used with permission][4]
注意:如果 gnome-terminal 不是你的默认终端,请替换该命令以打开你的默认终端。
你还可以创建仅使用密码加密(不是密钥)的操作。 为此,该操作的详细动作将会是以下内容:
名称:加密密码
说明:仅使用密码加密
命令gnome-terminal -x gpg -cf
你不需要为解密过程创建一个自定义操作,因为 Thunar 已经知道如何处理一个加密文件。 要解密文件,只需右键单击它(在 Thunar 中),选择 Open With Decrypt File为解密文件命名然后在提示时键入加密密码。 Viola你的加密文件已被解密并可以使用。
### 一个警告
请注意:如果你使用自己的密钥加密自己的文件,则无需输入加密密码来解密它们(因为你的公钥已存储)。 但是,如果你收到其他人(谁拥有你的公钥)的文件,则需要输入你的密码。 如果你想要存储自己的加密文件,而不是使用密钥来加密它们,请使用仅使用密码加密。 Nautilus 和Thunar但不是KDE可以做到这一点。 通过选择密码加密(通过密钥加密),当你解密文件时,它将始终提示你输入密码。
### 其他文件管理器
还有很多其他的文件管理器,他们中的一些可以使用加密,有些则不能。 你很有可能正在使用这三种工具中的一种,因此不仅可以将加密 / 解密添加到上下文菜单,而且是非常容易。 尝试一下,看看它是否会使加密和解密的过程变得更容易。
从 Linux 基金会和 edX 免费提供的["Linux 介绍" ][13]课程了解更多关于 Linux 的信息。
--------------------------------------------------------------------------------
via: https://www.linux.com/learn/intro-to-linux/2018/3/how-encrypt-files-within-file-manager
作者:[JACK WALLEN][a]
译者:[Auk7f7](https://github.com/Auk7f7)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.linux.com/users/jlwallen
[1]:https://www.gnupg.org/
[3]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/nautilus.jpg?itok=ae7Gtj60 "nautilus"
[4]:https://www.linux.com/licenses/category/used-permission
[6]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/nautilus_2.jpg?itok=3ht7j63n "nautilus"
[8]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kde_0.jpg?itok=KSTctVw0 "Dolphin"
[10]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/kde_2.jpg?itok=CeqWikNl "Dolphin"
[12]:https://www.linux.com/sites/lcom/files/styles/rendered_file/public/thunar.jpg?itok=fXcHk08B "Thunar"
[13]:https://training.linuxfoundation.org/linux-courses/system-administration-training/introduction-to-linux

View File

@ -1,432 +0,0 @@
如何在Linux上检查一个包package的详细信息
======
我们可以就这个已经被广泛讨论的话题写出大量的文档大多数情况下因为各种各样的原因我们都愿意让包管理器package manager来帮我们做这些事情。
每个Linux发行版都有自己的包管理器并且每个都有各自有不同的特性这些特性包括允许用户执行安装新软件包删除无用的软件包更新现存的软件包搜索某些具体的软件包以及更新整个系统到其最新的状态之类的操作。
习惯于命令行的用户大多数时间都会使用基于命令行方式的包管理器。对于Linux而言这些基于命令行的包管理器有YumDnf, Rpm, Apt, Apt-Get, Deb, pacman 和zypper.
**推荐阅读**
**(#)** [List of Command line Package Managers For Linux & Usage][1]
**(#)** [A Graphical frontend tool for Linux Package Manager][2]
**(#)** [How To Search If A Package Is Available On Your Linux Distribution Or Not][3]
**(#)** [How To Add, Enable And Disable A Repository By Using The DNF/YUM Config Manager Command On Linux][4]
作为一个系统管理员你应该熟知以下事实安装包来自何方具体来自哪个软件仓库包的具体版本包的大小发行版的版本包的源URL包的许可证信息等等等等。
这篇短文将用尽可能简单的方式帮你理解包管理器的用法这些用法正是来自随包自带的总结和描述文件。按你所使用的Linux发行版的不同运行下面相应的命令你能得到你所使用的发行版下的包的详细信息。
### [YUM 命令][5] : 在RHEL和CentOS系统上获得包的信息
YUM 英文直译是黄狗更新器--修改版它是一个开源的基于命令行的包管理器前端实用工具。它被广泛应用在基于RPM的系统上例如RHEL和CentOS。
Yum是用于在官方发行版仓库以及其他第三方发行版仓库下获取安装删除查询RPM包的主要工具。
```
# yum info pythonLCTT译注用yum info 获取python包的信息
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* epel: epel.mirror.constant.com
Installed Packages
Name : python
Arch : x86_64
Version : 2.6.6
Release : 66.el6_8
Size : 78 k
Repo : installed
From repo : updates
Summary : An interpreted, interactive, object-oriented programming language
URL : http://www.python.org/
License : Python
Description : Python is an interpreted, interactive, object-oriented programming
: language often compared to Tcl, Perl, Scheme or Java. Python includes
: modules, classes, exceptions, very high level dynamic data types and
: dynamic typing. Python supports interfaces to many system calls and
: libraries, as well as to various windowing systems (X11, Motif, Tk,
: Mac and MFC).
:
: Programmers can write new built-in modules for Python in C or C++.
: Python can be used as an extension language for applications that need
: a programmable interface.
:
: Note that documentation for Python is provided in the python-docs
: package.
:
: This package provides the "python" executable; most of the actual
: implementation is within the "python-libs" package.
```
### YUMDB 命令: 查看RHEL和CentOS系统上的包信息
Yumdb info这个命令提供与yum info相类似的的信息不过它还额外提供了诸如包校验值包类型用户信息由何人安装。从yum 3.2.26版本后yum开始在rpm数据库外储存额外的信息了下文输出的用户信息指该python由该用户安装而dep说明该包是被作为被依赖的包而被安装的
```
# yumdb info pythonLCTT译注用yumdb info 来获取Python的信息
Loaded plugins: fastestmirror
python-2.6.6-66.el6_8.x86_64
changed_by = 4294967295
checksum_data = 53c75a1756e5b4f6564c5229a37948c9b4561e0bf58076bd7dab7aff85a417f2
checksum_type = sha256
command_line = update -y
from_repo = updates
from_repo_revision = 1488370672
from_repo_timestamp = 1488371100
installed_by = 4294967295
reason = dep
releasever = 6
```
### [RPM 命令][6] : 在RHEL/CentOS/Fedora系统上查看包的信息
RPM 英文直译为红帽包管理器这是一个在RedHat以及其变种发行版如RHEL CentOS Fedora openSUSEMegeia下的功能强大的命令行包管理工具。它能让你轻松的安装升级删除查询以及校验你的系统或服务器上的软件。RPM文件以.rpm结尾。RPM包由它所依赖的软件库以及其他依赖构成它不会与系统上已经安装的包冲突。
```
# rpm -qi nano LCTT译注用RPM -qi 查询nano包的具体信息
Name : nano Relocations: (not relocatable)
Version : 2.0.9 Vendor: CentOS
Release : 7.el6 Build Date: Fri 12 Nov 2010 02:18:36 AM EST
Install Date: Fri 03 Mar 2017 08:57:47 AM EST Build Host: c5b2.bsys.dev.centos.org
Group : Applications/Editors Source RPM: nano-2.0.9-7.el6.src.rpm
Size : 1588347 License: GPLv3+
Signature : RSA/8, Sun 03 Jul 2011 12:46:50 AM EDT, Key ID 0946fca2c105b9de
Packager : CentOS BuildSystem
URL : http://www.nano-editor.org
Summary : A small text editor
Description :
GNU nano is a small and friendly text editor.
```
### [DNF 命令][7] : 在Fedora系统上查看报信息
DNF指时髦版的Yum,我们也可以认为DNF是下一代的YUM包管理器Yum的一个分支它在后台使用了hawkey/libsolv库。Aleš Kozumplík在Fedora 18上开始开发DNF在Fedora 22上正式最后发布。 DNF命令用来在Fedora 22及以后系统安装 更新,搜索以及删除包。它能自动的解决包安装过程中的包依赖问题。
```
$ dnf info tilix LCTT译注 用dnf info 查看tilix的包信息
Last metadata expiration check: 27 days, 10:00:23 ago on Wed 04 Oct 2017 06:43:27 AM IST.
Installed Packages
Name : tilix
Version : 1.6.4
Release : 1.fc26
Arch : x86_64
Size : 3.6 M
Source : tilix-1.6.4-1.fc26.src.rpm
Repo : @System
From repo : @commandline
Summary : Tiling terminal emulator
URL : https://github.com/gnunn1/tilix
License : MPLv2.0 and GPLv3+ and CC-BY-SA
Description : Tilix is a tiling terminal emulator with the following features:
:
: - Layout terminals in any fashion by splitting them horizontally or vertically
: - Terminals can be re-arranged using drag and drop both within and between
: windows
: - Terminals can be detached into a new window via drag and drop
: - Input can be synchronized between terminals so commands typed in one
: terminal are replicated to the others
: - The grouping of terminals can be saved and loaded from disk
: - Terminals support custom titles
: - Color schemes are stored in files and custom color schemes can be created by
: simply creating a new file
: - Transparent background
: - Supports notifications when processes are completed out of view
:
: The application was written using GTK 3 and an effort was made to conform to
: GNOME Human Interface Guidelines (HIG).
```
### [Zypper 命令][8] : 在openSUSE系统上查看包信息
Zypper是一个使用libzypp库的命令行包管理器。Zypper提供诸如软件仓库访问安装依赖解决软件包安装等等功能。
```
$ zypper info nano (译注: 用zypper info查询nano的信息
Loading repository data...
Reading installed packages...
Information for package nano:
-----------------------------
Repository : Main Repository (OSS)
Name : nano
Version : 2.4.2-5.3
Arch : x86_64
Vendor : openSUSE
Installed Size : 1017.8 KiB
Installed : No
Status : not installed
Source package : nano-2.4.2-5.3.src
Summary : Pico editor clone with enhancements
Description :
GNU nano is a small and friendly text editor. It aims to emulate
the Pico text editor while also offering a few enhancements.
```
### [pacman 命令][9] 在ArchLinux及Manjaro系统上查看包信息
Pacman指包管理器实用工具。pacman是一个用于安装构建删除管理Arch Linux上包的命令行工具。它后端使用libalpm(Arch Linux package ManagerALPM库)来完成所有功能。
```
$ pacman -Qi bash LCTT译注 用pacman -Qi 来查询bash
Name : bash
Version : 4.4.012-2
Description : The GNU Bourne Again shell
Architecture : x86_64
URL : http://www.gnu.org/software/bash/bash.html
Licenses : GPL
Groups : base
Provides : sh
Depends On : readline>=7.0 glibc ncurses
Optional Deps : bash-completion: for tab completion
Required By : autoconf automake bison bzip2 ca-certificates-utils db
dhcpcd diffutils e2fsprogs fakeroot figlet findutils
flex freetype2 gawk gdbm gettext gmp grub gzip icu
iptables keyutils libgpg-error libksba libpcap libpng
libtool lvm2 m4 man-db mkinitcpio nano neofetch nspr
nss openresolv os-prober pacman pcre pcre2 shadow
systemd texinfo vte-common which xdg-user-dirs xdg-utils
xfsprogs xorg-mkfontdir xorg-xpr xz
Optional For : None
Conflicts With : None
Replaces : None
Installed Size : 7.13 MiB
Packager : Jan Alexander Steffens (heftig)
Build Date : Tue 14 Feb 2017 01:16:51 PM UTC
Install Date : Thu 24 Aug 2017 06:08:12 AM UTC
Install Reason : Explicitly installed
Install Script : No
Validated By : Signature
```
### [Apt-Cache 命令][10] 在Debian/Ubuntu/Mint系统上查看包信息
apt-cache命令能显示Apt内部数据库中的大量信息。这些信息是从sources.list中的不同的软件源中搜集而来因此从某种意义上这些信息也可以被认为是某种缓存。
这些信息搜集工作是在运行apt update命令时执行的。
```
$ sudo apt-cache show apache2 LCTT译注用管理员权限查询apache2的信息
Package: apache2
Priority: optional
Section: web
Installed-Size: 473
Maintainer: Ubuntu Developers
Original-Maintainer: Debian Apache Maintainers
Architecture: amd64
Version: 2.4.12-2ubuntu2
Replaces: apache2.2-common
Provides: httpd, httpd-cgi
Depends: lsb-base, procps, perl, mime-support, apache2-bin (= 2.4.12-2ubuntu2), apache2-utils (>= 2.4), apache2-data (= 2.4.12-2ubuntu2)
Pre-Depends: dpkg (>= 1.17.14)
Recommends: ssl-cert
Suggests: www-browser, apache2-doc, apache2-suexec-pristine | apache2-suexec-custom, ufw
Conflicts: apache2.2-common (<< 2.3~)
Filename: pool/main/a/apache2/apache2_2.4.12-2ubuntu2_amd64.deb
Size: 91348
MD5sum: ab0ee0b0d1c6b3d19bd87aa2a9537125
SHA1: 350c9a1a954906088ed032aebb77de3d5bb24004
SHA256: 03f515f7ebc3b67b050b06e82ebca34b5e83e34a528868498fce020bf1dbbe34
Description-en: Apache HTTP Server
The Apache HTTP Server Project's goal is to build a secure, efficient and
extensible HTTP server as standards-compliant open source software. The
result has long been the number one web server on the Internet.
.
Installing this package results in a full installation, including the
configuration files, init scripts and support scripts.
Description-md5: d02426bc360345e5acd45367716dc35c
Homepage: http://httpd.apache.org/
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Origin: Ubuntu
Supported: 9m
Task: lamp-server, mythbuntu-frontend, mythbuntu-desktop, mythbuntu-backend-slave, mythbuntu-backend-master, mythbuntu-backend-master
```
### [APT 命令][11] : 查看Debian/Ubuntu/Mint系统上的包信息
APT意为高级打包工具就像DNF将如何替代YUM一样APT是apt-get的替代物。它功能丰富的命令行工具包括了如下所有命令的功能如apt-cache,apt-search,dpkg, apt-cdrom, apt-config, apt-key等等我们可以方便的通过apt来安装.dpkg包但是我们却不能通过apt-get来完成这一点还有一些其他的类似的功能也不能用apt-get来完成所以apt-get因为没有解决上述功能缺乏的原因而被apt所取代。
```
$ apt show nano LCTT译注 用apt show查看nano
Package: nano
Version: 2.8.6-3
Priority: standard
Section: editors
Origin: Ubuntu
Maintainer: Ubuntu Developers
Original-Maintainer: Jordi Mallach
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 766 kB
Depends: libc6 (>= 2.14), libncursesw5 (>= 6), libtinfo5 (>= 6)
Suggests: spell
Conflicts: pico
Breaks: nano-tiny (<< 2.8.6-2)
Replaces: nano-tiny (<< 2.8.6-2), pico
Homepage: https://www.nano-editor.org/
Task: standard, ubuntu-touch-core, ubuntu-touch
Supported: 9m
Download-Size: 222 kB
APT-Manual-Installed: yes
APT-Sources: http://in.archive.ubuntu.com/ubuntu artful/main amd64 Packages
Description: small, friendly text editor inspired by Pico
GNU nano is an easy-to-use text editor originally designed as a replacement
for Pico, the ncurses-based editor from the non-free mailer package Pine
(itself now available under the Apache License as Alpine).
.
However, GNU nano also implements many features missing in pico, including:
- undo/redo
- line numbering
- syntax coloring
- soft-wrapping of overlong lines
- selecting text by holding Shift
- interactive search and replace (with regular expression support)
- a go-to line (and column) command
- support for multiple file buffers
- auto-indentation
- tab completion of filenames and search terms
- toggling features while running
- and full internationalization support
```
### [dpkg 命令][12] : 查看Debian/Ubuntu/Mint系统上的包信息
dpkg意指Debian包管理器dpkg。dpkg用于Debian系统上的安装构建移除以及管理Debian包的命令行工具。dpkg 使用Aptitude因为它更为主流及用户友好作为前端工具来完成所有的功能。其他的工具如dpkg-deb和dpkg-query使用dpkg做为前端来实现功能。尽管系统管理员还是时不时会在必要时使用dpkg来完成一些软件安装的任务他大多数情况下还是会因为APtApt-Get以及Aptitude的健壮性而使用后者。
```
$ dpkg -s python LCTT译注 用dpkg -s查看python
Package: python
Status: install ok installed
Priority: optional
Section: python
Installed-Size: 626
Maintainer: Ubuntu Developers
Architecture: amd64
Multi-Arch: allowed
Source: python-defaults
Version: 2.7.14-2ubuntu1
Replaces: python-dev (<< 2.6.5-2)
Provides: python-ctypes, python-email, python-importlib, python-profiler, python-wsgiref
Depends: python2.7 (>= 2.7.14-1~), libpython-stdlib (= 2.7.14-2ubuntu1)
Pre-Depends: python-minimal (= 2.7.14-2ubuntu1)
Suggests: python-doc (= 2.7.14-2ubuntu1), python-tk (>= 2.7.14-1~)
Breaks: update-manager-core (<< 0.200.5-2)
Conflicts: python-central (<< 0.5.5)
Description: interactive high-level object-oriented language (default version)
Python, the high-level, interactive object oriented language,
includes an extensive class library with lots of goodies for
network programming, system administration, sounds and graphics.
.
This package is a dependency package, which depends on Debian's default
Python version (currently v2.7).
Homepage: http://www.python.org/
Original-Maintainer: Matthias Klose
```
我们也可使用dpkg的-p选项这个选项提供和dpkg -s相类似的信息但是它还提供了包的校验值和包类型。
```
$ dpkg -p python3 LCTT译注 用dpkg -p查看python3的信息
Package: python3
Priority: important
Section: python
Installed-Size: 67
Origin: Ubuntu
Maintainer: Ubuntu Developers
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Architecture: amd64
Multi-Arch: allowed
Source: python3-defaults
Version: 3.6.3-0ubuntu2
Replaces: python3-minimal (<< 3.1.2-2)
Provides: python3-profiler
Depends: python3.6 (>= 3.6.3-1~), libpython3-stdlib (= 3.6.3-0ubuntu2), dh-python
Pre-Depends: python3-minimal (= 3.6.3-0ubuntu2)
Suggests: python3-doc (>= 3.6.3-0ubuntu2), python3-tk (>= 3.6.3-1~), python3-venv (>= 3.6.3-0ubuntu2)
Filename: pool/main/p/python3-defaults/python3_3.6.3-0ubuntu2_amd64.deb
Size: 8712
MD5sum: a8bae494c6e5d1896287675faf40d373
Description: interactive high-level object-oriented language (default python3 version)
Original-Maintainer: Matthias Klose
SHA1: 2daec885cea7d4dc83c284301c3bebf42b23e095
SHA256: 865e509c91d2504a16c4b573dbe27e260c36fceec2add3fa43a30c1751d7e9bb
Homepage: http://www.python.org/
Task: minimal, ubuntu-core, ubuntu-core
Description-md5: 950ebd8122c0a7340f0a740c295b9eab
Supported: 9m
```
### Aptitude 命令 : 查看Debian/Ubuntu/Mint 系统上的包信息
aptitude是Debian GNU/Linux包管理系统的面向文本的接口。它允许用户查看已安装的包的列表以及完成诸如安装升级删除包之类的包管理任务。这些管理行为也能从图形接口来执行。
```
$ aptitude show htop LCTT译注 用aptitude show查看htop信息
Package: htop
Version: 2.0.2-1
State: installed
Automatically installed: no
Priority: optional
Section: universe/utils
Maintainer: Ubuntu Developers
Architecture: amd64
Uncompressed Size: 216 k
Depends: libc6 (>= 2.15), libncursesw5 (>= 6), libtinfo5 (>= 6)
Suggests: lsof, strace
Conflicts: htop:i386
Description: interactive processes viewer
Htop is an ncursed-based process viewer similar to top, but it allows one to scroll the list vertically and horizontally to see all processes and their full command lines.
Tasks related to processes (killing, renicing) can be done without entering their PIDs.
Homepage: http://hisham.hm/htop/
```
--------------------------------------------------------------------------------
via: https://www.2daygeek.com/how-to-view-detailed-information-about-a-package-in-linux/
作者:[Prakash Subramanian][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[DavidChenLiang](https://github.com/davidchenliang)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.2daygeek.com/author/prakash/
[1]:https://www.2daygeek.com/list-of-command-line-package-manager-for-linux/
[2]:https://www.2daygeek.com/list-of-graphical-frontend-tool-for-linux-package-manager/
[3]:https://www.2daygeek.com/how-to-search-if-a-package-is-available-on-your-linux-distribution-or-not/
[4]:https://www.2daygeek.com/how-to-add-enable-disable-a-repository-dnf-yum-config-manager-on-linux/
[5]:https://www.2daygeek.com/yum-command-examples-manage-packages-rhel-centos-systems/
[6]:https://www.2daygeek.com/rpm-command-examples/
[7]:https://www.2daygeek.com/dnf-command-examples-manage-packages-fedora-system/
[8]:https://www.2daygeek.com/zypper-command-examples-manage-packages-opensuse-system/
[9]:https://www.2daygeek.com/pacman-command-examples-manage-packages-arch-linux-system/
[10]:https://www.2daygeek.com/apt-get-apt-cache-command-examples-manage-packages-debian-ubuntu-systems/
[11]:https://www.2daygeek.com/apt-command-examples-manage-packages-debian-ubuntu-systems/
[12]:https://www.2daygeek.com/dpkg-command-to-manage-packages-on-debian-ubuntu-linux-mint-systems/

View File

@ -0,0 +1,120 @@
这 7 个 Python 库让你写出更易维护的代码
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/programming_keyboard_coding.png?itok=E0Vvam7A)
> 可读性很重要。
> — [Python 之禅The Zen of Python][1], Tim Peters
尽管很多项目一开始的时候就有可读性和编码标准的要求,但随着项目进入“维护模式”,这些要求都会变得虎头蛇尾。然而,在代码库中保持一致的代码风格和测试标准能够显著减轻维护的压力,也能确保新的开发者能够快速了解项目的情况,同时能更好地保持应用程序的运行良好。
### 检查你的代码风格
使用外部库来检查代码运行情况不失为保护项目未来可维护性的一个好方法。以下会推荐一些我们最喜爱的[检查代码][2](包括检查 PEP 8 和其它代码风格错误)的库,用它们来强制保持代码风格一致,并确保在项目成熟时有一个可接受的测试覆盖率。
[PEP 8][3]是Python代码风格规范规定了行长度缩进多行表达式、变量命名约定等内容。尽管你的团队自身可能也会有不同于 PEP 8 的代码风格规范,但任何代码风格规范的目标都是在代码库中强制实施一致的标准,使代码的可读性更强、更易于维护。下面三个库就可以用来帮助你美化代码。
#### 1\. Pylint
[Pylint][4] 是一个检查违反 PEP 8 规范和常见错误的库。它在一些流行的编辑器和 IDE 中都有集成,也可以单独从命令行运行。
执行 `pip install pylint`安装 Pylint 。然后运行 `pylint [options] path/to/dir` 或者 `pylint [options] path/to/module.py` 就可以在命令行中使用 Pylint它会向控制台输出代码中违反规范和出现错误的地方。
你还可以使用 `pylintrc` [配置文件][6]来自定义 Pylint 对哪些代码错误进行检查。
#### 2\. Flake8
对 [Flake8][7] 的描述是“将 PEP 8、Pyflakes类似 Pylint、McCabe代码复杂性检查器、第三方插件整合到一起以检查 Python 代码风格和质量的一个 Python 工具”。
执行 `pip install flake8` 安装 flake8 ,然后执行 `flake8 [options] path/to/dir` 或者 `flake8 [options] path/to/module.py` 可以查看报出的错误和警告。
和 Pylint 类似Flake8 允许通过[配置文件][8]来自定义检查的内容。它有非常清晰的文档,包括一些有用的[提交钩子][9],可以将自动检查代码纳入到开发工作流程之中。
Flake8 也允许集成到一些流行的编辑器和 IDE 当中,但在文档中并没有详细说明。要将 Flake8 集成到喜欢的编辑器或 IDE 中,可以搜索插件(例如 [Sublime Text 的 Flake8 插件][10])。
#### 3\. Isort
[Isort][11] 这个库能将你在项目中导入的库按字母顺序,并将其[正确划分为不同部分][12](例如标准库、第三方库,自建的库等)。这样提高了代码的可读性,并且可以在导入的库较多的时候轻松找到各个库。
执行 `pip install isort` 安装 isort然后执行 `isort path/to/module.py` 就可以运行了。文档中还提供了更多的配置项,例如通过配置 `.isort.cfg` 文件来决定 isort 如何处理一个库的多行导入。
和 Flake8、Pylint 一样isort 也提供了将其与流行的[编辑器和 IDE][15] 集成的插件。
### 共享代码风格
每次文件发生变动之后都用命令行手动检查代码是一件痛苦的事,你可能也不太喜欢通过运行 IDE 中某个插件来实现这个功能。同样地,你的同事可能会用不同的代码检查方式,也许他们的编辑器中也没有安装插件,甚至自己可能也不会严格检查代码和按照警告来更正代码。总之,你共享的代码库将会逐渐地变得混乱且难以阅读。
一个很好的解决方案是使用一个库,自动将代码按照 PEP 8 规范进行格式化。我们推荐的三个库都有不同的自定义级别来控制如何格式化代码。其中有一些设置较为特殊,例如 Pylint 和 Flake8 ,你需要先行测试,看看是否有你无法忍受蛋有不能修改的默认配置。
#### 4\. Autopep8
[Autopep8][16] 可以自动格式化指定的模块中的代码,包括重新缩进行,修复缩进,删除多余的空格,并重构常见的比较错误(例如布尔值和 `None` 值)。你可以查看文档中完整的[更正列表][17]。
运行 `pip install --upgrade autopep8` 安装 autopep8。然后执行 `autopep8 --in-place --aggressive --aggressive <filename>` 就可以重新格式化你的代码。`aggressive` 标记的数量表示 auotopep8 在代码风格控制上有多少控制权。在这里可以详细了解 [aggressive][18] 选项。
#### 5\. Yapf
[Yapf][19] 是另一种有自己的[配置项][20]列表的重新格式化代码的工具。它与 autopep8 的不同之处在于它不仅会指出代码中违反 PEP 8 规范的地方,还会对没有违反 PEP 8 但代码风格不一致的地方重新格式化,旨在令代码的可读性更强。
执行`pip install yapf` 安装 Yapf然后执行 `yapf [options] path/to/dir``yapf [options] path/to/module.py` 可以对代码重新格式化。
#### 6\. Black
[Black][21] 在代码检查工具当中算是比较新的一个。它与 autopep8 和 Yapf 类似,但限制较多,没有太多的自定义选项。这样的好处是你不需要去决定使用怎么样的代码风格,让 black 来给你做决定就好。你可以在这里查阅 black 的[自定义选项][22]以及[如何在配置文件中对其进行设置][23]。
Black 依赖于 Python 3.6+,但它可以格式化用 Python 2 编写的代码。执行 `pip install black` 安装 black然后执行 `black path/to/dir``black path/to/module.py` 就可以使用 black 优化你的代码。
### 检查你的测试覆盖率
如果你正在进行测试工作,你需要确保提交到代码库的新代码都已经测试通过,并且不会降低测试覆盖率。虽然测试覆盖率不是衡量测试有效性和充分性的唯一指标,但它是确保项目遵循基本测试标准的一种方法。对于计算测试覆盖率,我们推荐使用 Coverage 这个库。
#### 7\. Coverage
[Coverage][24] 有数种显示测试覆盖率的方式,包括将结果输出到控制台或 HTML 页面,并指出哪些具体哪些地方没有被覆盖到。你可以通过配置文件自定义 Coverage 检查的内容,让你更方便使用。
执行 `pip install coverage` 安装 Converage 。然后执行 `coverage [path/to/module.py] [args]` 可以运行程序并查看输出结果。如果要查看哪些代码行没有被覆盖,执行 `coverage report -m` 即可。
持续集成Continuous integration, CI是在合并和部署代码之前自动检查代码风格错误和测试覆盖率最小值的过程。很多免费或付费的工具都可以用于执行这项工作具体的过程不在本文中赘述但 CI 过程是令代码更易读和更易维护的重要步骤,关于这一部分可以参考 [Travis CI][26] 和 [Jenkins][27]。
以上这些只是用于检查 Python 代码的各种工具中的其中几个。如果你有其它喜爱的工具,欢迎在评论中分享。
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/7/7-python-libraries-more-maintainable-code
作者:[Jeff Triplett][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[HankChow](https://github.com/HankChow)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/laceynwilliams
[1]:https://www.python.org/dev/peps/pep-0020/
[2]:https://en.wikipedia.org/wiki/Lint_(software)
[3]:https://www.python.org/dev/peps/pep-0008/
[4]:https://www.pylint.org/
[5]:https://pylint.readthedocs.io/en/latest/user_guide/ide-integration.html
[6]:https://pylint.readthedocs.io/en/latest/user_guide/run.html#command-line-options
[7]:http://flake8.pycqa.org/en/latest/
[8]:http://flake8.pycqa.org/en/latest/user/configuration.html#configuration-locations
[9]:http://flake8.pycqa.org/en/latest/user/using-hooks.html
[10]:https://github.com/SublimeLinter/SublimeLinter-flake8
[11]:https://github.com/timothycrosley/isort
[12]:https://github.com/timothycrosley/isort#how-does-isort-work
[13]:https://github.com/timothycrosley/isort#using-isort
[14]:https://github.com/timothycrosley/isort#configuring-isort
[15]:https://github.com/timothycrosley/isort/wiki/isort-Plugins
[16]:https://github.com/hhatto/autopep8
[17]:https://github.com/hhatto/autopep8#id4
[18]:https://github.com/hhatto/autopep8#id5
[19]:https://github.com/google/yapf
[20]:https://github.com/google/yapf#usage
[21]:https://github.com/ambv/black
[22]:https://github.com/ambv/black#command-line-options
[23]:https://github.com/ambv/black#pyprojecttoml
[24]:https://coverage.readthedocs.io/en/latest/
[25]:https://coverage.readthedocs.io/en/latest/config.html
[26]:https://travis-ci.org/
[27]:https://jenkins.io/

View File

@ -0,0 +1,160 @@
在VirtualBox中安装Andriod系统
======
如果你正在开发安卓 app 应用也许会遇到小麻烦。诚然ios 移动开发有 macOS 系统平台为其提供友好便利性,安卓开发仅有支持少部分安卓系统(其中还包括可穿戴设备系统)的 Andriod Studio 工具。
毋庸置疑所有的二进制工具、SDK 工具、开发框架工具以及调试器都会产生大量日志和其他各种文件来使得你的文件系统很混乱。一个有效的解决方法就是在 VirtualBox 中安装 Andriod 系统,这样还解决了 Andriod 开发中最为棘手问题之一——设备模拟器。你可以在该虚拟机里测试应用程序,也可以使用 Andriod 的内部功能。因此,让我们迫不及待的开始吧!
### 准备工作
首先,你需要在你的系统上安装 VirtualBox可从[这里][1]下载 windows 版本、macOS 版本或者各种 Linux 版本的 VitualBox。然后你需要一个能在 x86 平台运行的 Andriod 镜像,因为 VirtualBox 为虚拟机提供运行 x86 或者 x86_64包括 AMD64平台的功能。
虽然大部分 Andriod 设备都在 ARM 上运行,但我们依然可以在 x86 平台上获得 [Andriod 项目帮助][2]。这些优秀的开发者已经将 Andriod 移植到 x86 平台上运行(包括实体机和虚拟机),我们可以下载最新版本的 Andriod 7.1。你也可以用之前更为稳定的版本,本文写作时最新稳定版是 Andriod 6.0。
### 创建 VM 虚拟机
打开 VirtualBox单击左上角的 ” 新建 ” 按钮,在弹出的窗口中选择 “ 类型Linux ” 然后根据下载的ISO镜像来确定版本x86 对应 32-bitx86_64 对应 64-bit此处选择 Linux 2.6 / 3.x / 4.x (64-bit)。
RAM 大小设置 2 GB 到你系统能提供的最大内存之间。如果你想模拟真实的使用环境你可以设置 6 GB RAM和 32 GB ROM。
![][3]
![][4]
创建完成后,你还需要做一些设置,添加核心处理器,提高开机显示内存。在 VM 上打开设置选项,“ 设置 -> 系统 -> 处理器 ”,如果硬件条件允许,可以多分配一些处理器。
![][5]
在 “ 设置 -> 显示 -> 显存大小 ” 中,你可以分配一大块内存并开启 3D 加速功能。
![][6]
现在我们可以启动 VM 虚拟机了。
### 安装 Andriod
首次启动 VM 虚拟机VirtualBox 会提示你需要提供启动媒介选择之前下载好的Andriod 镜像。
![][7]
下一步,如果想长时间使用 Andriod选择 Installation 选项,你也可以选择 Live 模式体验 Andriod 环境。
![][8]
##### 分区
分区是通过文本界面操作,并没有友好的 GUI 界面,所以每个操作都需要小心对待。例如,在首页中还没有创建分区并且只检测到很少的虚拟硬盘时显示如下。
![][9]
红色字母 C 和 D 提示 C 开头选项可以创建或者修改分区D 开头选项可以检测设备。你可以选择 D 开头选项,然后它就会检测硬盘,也可不进行这步操作,因为在启动的时候它会自动检测。
我们选择 C 开头选项,在虚拟盘中创建分区。官方不推荐使用 GPT 格式,所以我们选择 No。
![][10]
现在你被引导到 fdisk 工具页面。
![][11]
为了简洁,我们就只创建一个较大的分区,使用方向键来选择 “ New ” ,然后选择“ Primary ”,确认。
![][12]
分区大小系统已经为你计算好了,确认。
![][13]
这个分区就是 Andriod 系统所在的分区,所以需要它是可启动的。选择 “ Bootable ”,然后 enter上方表格中 Flags 标志下面会出现 boot 标志),进一步,选择 “ Write ” 选项,保存刚才的操作记录并写入分区表。
![][14]
现在你可以选择退出分区工具,然后继续安装过程。
![][15]
##### 文件系统格式化
在分区页面上会出现一个刚刚我们创建的分区,选择它并进入。
![][16]
选择 Ext4 文件系统,在下一页中选择 Yes 然后格式化开始。会提示是否安装 GRUB 引导工具以及是否允许在根目录 / 进行读写,都选择 Yes 。现在,安装进程开始。
安装完成后,当系统提示可以 reboot 的时候你可以 reboot 系统。在重启之前,你可以先关机,然后在 VitualBox 的 ” 设置 -> 存储 ” 中检查 Andriod iso 镜像是否还依附在虚拟机上,如果在,将它移除。
移除安装镜像并保存,再去启动 VM 虚拟机。
![][17]
##### 运行 Andriod
在 GRUB 引导界面,有 debug 模式和 normal 模式的选项。我们选择默认选项,如下图所示。
![][18]
如果一切正常,你将会看到如下界面:
![][19]
如今的 Andriod 系统使用触摸交互而不是鼠标。不过Andriod-x86 平台提供了鼠标操作支持,但开始时可能需要方向键来辅助操作。
![][20]
选择 “ Set up as new ” 选项,回车确认。
![][21]
在提示用谷歌账户登陆之前,系统检查更新并检测设备信息。你可以跳过这一步,直接去设置日期和时间、用户名等。
还有一些其他的选项,和让你选择创建一个新的 Andriod 设备类似。选择 “ I Agree ” 选项同意有关更新、服务等的 policy。
![][22]
在这之后,因为它是个虚拟机,所以可能需要添加额外的 email 账户来设置 “ On-body detection ",大部分的选项对我们来说都没有多大作用,因此可以选择 ” All Set “。
接下来,它会提示你选择家庭 App。这个根据个人需求选择。
![][23]
如果你需要在 VM 做一些交互测试,有个可触摸屏幕会提供很大的方便,因为那样才更接近真实使用环境。
希望这篇教程会给你带来帮助。如果还有类似的教程写作需求,欢迎联系我们。
--------------------------------------------------------------------------------
via: https://linuxhint.com/install_android_virtualbox/
作者:[Ranvir Singh][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[jrglinux](https://github.com/jrglinux)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://linuxhint.com/author/sranvir155/
[1]:https://www.virtualbox.org/wiki/Downloads
[2]:http://www.android-x86.org/
[3]:https://linuxhint.com/wp-content/uploads/2018/08/a.png
[4]:https://linuxhint.com/wp-content/uploads/2018/08/a1.png
[5]:https://linuxhint.com/wp-content/uploads/2018/08/a2.png
[6]:https://linuxhint.com/wp-content/uploads/2018/08/a3.png
[7]:https://linuxhint.com/wp-content/uploads/2018/08/a4.png
[8]:https://linuxhint.com/wp-content/uploads/2018/08/a5.png
[9]:https://linuxhint.com/wp-content/uploads/2018/08/a6.png
[10]:https://linuxhint.com/wp-content/uploads/2018/08/a7.png
[11]:https://linuxhint.com/wp-content/uploads/2018/08/a8.png
[12]:https://linuxhint.com/wp-content/uploads/2018/08/a9.png
[13]:https://linuxhint.com/wp-content/uploads/2018/08/a10.png
[14]:https://linuxhint.com/wp-content/uploads/2018/08/a11.png
[15]:https://linuxhint.com/wp-content/uploads/2018/08/a12.png
[16]:https://linuxhint.com/wp-content/uploads/2018/08/a13.png
[17]:https://linuxhint.com/wp-content/uploads/2018/08/a14.png
[18]:https://linuxhint.com/wp-content/uploads/2018/08/a16.png
[19]:https://linuxhint.com/wp-content/uploads/2018/08/a17.png
[20]:https://linuxhint.com/wp-content/uploads/2018/08/a18.png
[21]:https://linuxhint.com/wp-content/uploads/2018/08/a19.png
[22]:https://linuxhint.com/wp-content/uploads/2018/08/a20.png
[23]:https://linuxhint.com/wp-content/uploads/2018/08/a21.png

View File

@ -0,0 +1,116 @@
初学者指南ZFS 是什么,为什么要使用 ZFS
======
![ZFS filesystem][9]
今天,我们来谈论一下 ZFS一个高级文件系统。我们将讨论 ZFS 从何而来,它是什么,以及为什么它在科技界和企业界如此受欢迎。
虽然我是一个美国人,但我更喜欢读成 ZedFS 而不是 ZeeFS因为前者听起来更酷一些。你可以根据你的个人喜好来发音。
注意:在这篇文章中,你将会看到很多次 ZFS。当我在谈论特性和安装的时候我所指的是 OpenZFS 。自从 Oracle 公司放弃 OpenSolaris 项目之后ZFS由 Oracle 公司开发)和 OpenZFS 已经走向了不同的发展道路。
### ZFS 的历史
Z 文件系统ZFS是在 2001 年由 [Matthew Ahrens 和 Jeff Bonwick][1] 开发的。ZFS 是作为 Sun 公司的[<ruby>微系统<rt>MicroSystem</rt></ruby>][2] [OpenSolaris][3] 的下一代文件系统而设计的。在 2008 年ZFS 被移植到了 FreeBSD 。同一年,一个新的项目也开始了:[ZFS to Linux][4] 。然而,由于 ZFS 是[通用开发和发布许可证CDDL][5]许可的,它和 [GNU 通用公共许可证][6] 不兼容,因此不能将它迁移到 Linux 内核中。为了解决这个问题,绝大多数 Linux 发行版提供了一些方法来安装 ZFS 
在 Oracle 公司收购 Sun 公司之后不久,微系统 OpenSolaris 就闭源了,这使得 ZFS 的最新开发也闭源了。许多 ZFS 开发者对这件事情非常不开心。[三分之二的 ZFS 核心开发者][1],包括 Ahrens 和 Bonwick因为这个决定而离开了 Oracle 公司。他们加入其他公司,并于 2013 年 9 月创立了 [OpenZFS][7] 这一项目。该项目引领着 ZFS 的开源开发。
让我们回到上面提到的许可证问题上。既然 OpenZFS 项目已经和 Oracle 公司分离开了,有人可能好奇他们为什么不使用和 GPL 兼容的许可证,这样就可以把它加入到 Linux 内核中了。根据 [OpenZFS 官网][8] 的介绍,更改许可证需要联系所有为当前 OpenZFS 实现贡献过代码的人(包括初始公共 ZFS 代码以及 OpenSolaris 代码),并得到他们的许可才行。这几乎是不可能的(因为一些贡献者可能已经去世了或者很难找到),因此他们决定保留原来的许可证。
### ZFS 是什么,它有什么特性?
正如前面所说过的ZFS 是一个高级文件系统。因此,它有一些有趣的[特性][10]。比如:
* 存储池
* 写时拷贝
* 快照
* 数据完整性验证和自动修复
* RAID-Z
* 最大单个文件大小为 16 EB1 EB = 1024 PB
* 最大 256 万亿的四次方 ZB1 ZB = 1024 EB的存储
让我们来深入了解一下其中一些特性。
#### 存储池
与大多数文件系统不同ZFS 结合了文件系统和卷管理器的特性。这意味着它与其他文件系统不同ZFS 可以创建跨域一系列硬盘或池的文件系统。不仅如此你还可以通过添加硬盘来增大池的存储容量。ZFS 可以进行[分区和格式化][11]。
![Pooled storage in ZFS][12]
*ZFS 存储池*
#### 写时拷贝
[<ruby>写时拷贝<rt>Copy-on-write</rt></ruby>][13]是另一个有趣并且很酷的特性。在大多数文件系统上,当数据被重写时,它将永久丢失。而在 ZFS 中新数据会写到不同的块。写完成之后更新文件系统元数据信息使之指向新的数据块LCTT 译注:更新之后,原数据块成为磁盘上的垃圾,需要有对应的垃圾回收机制)。这确保了如果在写新数据的时候系统崩溃(或者发生其它事,比如突然断电),那么原数据将会保存下来。这也意味着,在系统发生崩溃之后,不需要运行 [fsck][14] 来检查和修复文件系统。
#### 快照
写时拷贝使得 ZFS 有了另一个特性:<ruby>快照<rt>snapshots</rt></ruby>。ZFS 使用快照来跟踪文件系统中的更改。[快照][13]包含文件系统的原始版本(文件系统的一个只读版本),实时文件系统则包含了自从快照创建之后的任何更改。没有使用额外的空间。因为新数据将会写到实时文件系统新分配的块上。如果一个文件被删除了,那么它在快照中的索引也会被删除。所以,快照主要是用来跟踪文件的更改,而不是文件的增加和创建。
快照可以挂载成只读的,以用来恢复一个文件的过去版本。实时系统也可以回滚到之前的快照。回滚之后,自从快照创建之后的所有更改将会丢失。
#### 数据完整性验证和自动修复
当向 ZFS 写入新数据时会创建该数据的校验和。在读取数据的时候使用校验和进行验证。如果前后校验和不匹配那么就说明检测到了错误然后ZFS 会尝试自动修正错误。
#### RAID-Z
ZFS 不需要任何额外软件或硬件就可以处理 RAID磁盘阵列。毫无奇怪因为 ZFS 有自己的 RAID 实现RAID-Z 。RAID-Z 是 RAID-5 的一个变种,不过它克服了 RAID-5 的写漏洞意外重启之后数据和校验信息会变得不同步LCTT 译注RAID-5 的 stripe 在正写数据时如果这时候电源中断那么奇偶校验数据将跟该部分数据不同步因此前边的写无效RAID-Z 用了 “variable-width RAID stripes” 技术,因此所有的写都是 full-stripe writes。为了使用基本级别的 [RAID-Z][15]RAID-Z1你需要至少三块磁盘其中两块用来存储数据另外一块用来存储[奇偶校验信息][16]。而RAID-Z2 需要至少两块磁盘存储数据以及两块磁盘存储校验信息。RAID-Z3 需要至少两块磁盘存储数据以及三块磁盘存储校验信息。另外,只能向 RAID-Z 池中加入偶数倍的磁盘,而不能是奇数倍的。
#### 巨大的存储潜力
创建 ZFS 的时候,它就被设计成了[最后一个文件系统][17] 。那时候,大多数文件系统都是 64 位的ZFS 的创建者决定直接跳到 128 位,等到将来再来证明这是对的。这意味着 ZFS 的容量大小是 32 位或 64 位文件系统的 160 亿亿倍。事实上Jeff Bonwick其中一个创建者“完全填满一个 128 位的存储池所需要的[能量][18],从字面上讲,比煮沸海洋需要的还多。”
### 如何安装 ZFS
如果你想立刻使用 ZFS开箱即用那么你需要安装 [FreeBSD][19] 或一个[使用 illumos 内核的操作系统][20]。[illumos][21] 是 OpenSolaris 内核的一个克隆版本。
事实上,支持 [ZFS 是一些有经验的 Linux 用户选择 BSD 的主要原因][22]。
如果你想在 Linux 上尝试 ZFS那么只能在存储文件系统上使用。据我所知没有任何 Linux 发行版可以在根目录上安装 ZFS实现开箱即用。如果你对在 Linux 上尝试 ZFS 感兴趣,那么 [ZFS on Linux 项目][4] 上有大量的教程可以指导你怎么做。
### 附加说明
这篇文章论述了 ZFS 的优点。现在,让我来告诉你一个关于 ZFS 很现实的问题。使用 RAID-Z [会很贵][23],因为你需要购买大量的磁盘来增大存储空间。
你已经使用过 ZFS 了吗?你的使用经验是什么样的?请在下面的评论中告诉我们。
如果你觉得这篇文章有趣,请花一分钟的时间把它分享到社交媒体、极客新闻或 [Reddit][24] 。
--------------------------------------------------------------------------------
via: https://itsfoss.com/what-is-zfs/
作者:[John Paul][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[ucasFL](https://github.com/ucasFL)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://itsfoss.com/author/john/
[1]: https://wiki.gentoo.org/wiki/ZFS
[2]: http://en.wikipedia.org/wiki/Sun_Microsystems
[3]: http://en.wikipedia.org/wiki/Opensolaris
[4]: https://zfsonlinux.org/
[5]: https://en.wikipedia.org/wiki/Common_Development_and_Distribution_License
[6]: https://en.wikipedia.org/wiki/GNU_General_Public_License
[7]: http://www.open-zfs.org/wiki/Main_Page
[8]: http://www.open-zfs.org/wiki/FAQ#Do_you_plan_to_release_OpenZFS_under_a_license_other_than_the_CDDL.3F
[9]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/what-is-zfs.png
[10]: https://wiki.archlinux.org/index.php/ZFS
[11]: https://www.howtogeek.com/175159/an-introduction-to-the-z-file-system-zfs-for-linux/
[12]: https://4bds6hergc-flywheel.netdna-ssl.com/wp-content/uploads/2018/09/zfs-overview.png
[13]: https://www.freebsd.org/doc/handbook/zfs-term.html
[14]: https://en.wikipedia.org/wiki/Fsck
[15]: https://wiki.archlinux.org/index.php/ZFS/Virtual_disks#Creating_and_Destroying_Zpools
[16]: https://www.pcmag.com/encyclopedia/term/60364/raid-parity
[17]: https://web.archive.org/web/20060428092023/http://www.sun.com/2004-0914/feature/
[18]: https://blogs.oracle.com/bonwick/128-bit-storage:-are-you-high
[19]: https://www.freebsd.org/
[20]: https://wiki.illumos.org/display/illumos/Distributions
[21]: https://wiki.illumos.org/display/illumos/illumos+Home
[22]: https://itsfoss.com/why-use-bsd/
[23]: http://louwrentius.com/the-hidden-cost-of-using-zfs-for-your-home-nas.html
[24]: http://reddit.com/r/linuxusersgroup

View File

@ -0,0 +1,108 @@
使用 NetworkManager 随机化你的 MAC 地址
======
![](https://fedoramagazine.org/wp-content/uploads/2018/09/randomizemacaddress-816x345.png)
今时今日,无论在家里的沙发上,还是在外面的咖啡厅,只要打开笔记本电脑,连上 Wi-Fi就能通过网络与外界保持联系。但现在的 Wi-Fi 热点们大都能够通过[每张网卡对应的唯一 MAC 地址][1]来追踪你的设备。下面就来看一下如何避免被追踪。
现在很多人已经开始注重个人隐私这个问题。个人隐私问题并不仅仅指防止他人能够访问到你电脑上的私有内容(这又是另一个问题了),而更多的是指可追踪性,也就是是否能够被轻易地统计和追踪到。大家都应该[对此更加重视][2]。同时,这方面的底线是,服务提供者在得到了用户的授权后才能对用户进行追踪,例如机场的计时 Wi-Fi 只有在用户授权后才能够使用。
因为固定的 MAC 地址能被轻易地追踪到,所以应该定时进行更换,随机的 MAC 地址是一个好的选择。由于 MAC 地址一般只在局域网内使用,因此随机的 MAC 地址也不太容易产生[冲突][3]。
### 配置 NetworkManager
要将随机的 MAC 地址默认应用与所有的 Wi-Fi 连接,需要创建 /etc/NetworkManager/conf.d/00-macrandomize.conf 这个文件:
```
[device]
wifi.scan-rand-mac-address=yes
[connection]
wifi.cloned-mac-address=stable
ethernet.cloned-mac-address=stable
connection.stable-id=${CONNECTION}/${BOOT}
```
然后重启 NetworkManager
```
systemctl restart NetworkManager
```
以上配置文件中,将 cloned-mac-address 的值设置为 stable 就可以在每次 NetworkManager 激活连接的时候都生成相同的 MAC 地址,但连接时使用不同的 MAC 地址。如果要在每次激活连接时获得随机的 MAC 地址,需要将 cloned-mac-address 的值设置为 random。
设置为 stable 可以从 DHCP 获取相同的 IP 地址,也可以让 Wi-Fi 的强制主页根据 MAC 地址记住你的登录状态。如果设置为 random ,在每次连接的时候都需要重新认证(或者点击“我同意”),在使用机场 Wi-Fi 的时候会需要到这种 random 模式。可以在 NetworkManager 的[博客文章][4]中参阅到有关使用 nmcli 从终端配置特定连接的详细说明。
使用 ip link 命令可以查看当前的 MAC 地址MAC 地址将会显示在 ether 一词的后面。
```
$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp2s0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:5f:d5:4e brd ff:ff:ff:ff:ff:ff
3: wlp1s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DORMANT group default qlen 1000
link/ether 52:54:00:03:23:59 brd ff:ff:ff:ff:ff:ff
```
### 什么时候不能随机化 MAC 地址
当然,在某些情况下确实需要能被追踪到。例如在家用网络中,可能需要将路由器配置为对电脑分配一致的 IP 地址以进行端口转发;再例如公司的雇主可能需要根据 MAC 地址来提供 Wi-Fi 服务,这时候就需要进行追踪。要更改特定的 Wi-Fi 连接,请使用 nmcli 查看 NetworkManager 连接并显示当前设置:
```
$ nmcli c | grep wifi
Amtrak_WiFi 5f4b9f75-9e41-47f8-8bac-25dae779cd87 wifi --
StaplesHotspot de57940c-32c2-468b-8f96-0a3b9a9b0a5e wifi --
MyHome e8c79829-1848-4563-8e44-466e14a3223d wifi wlp1s0
...
$ nmcli c show 5f4b9f75-9e41-47f8-8bac-25dae779cd87 | grep cloned
802-11-wireless.cloned-mac-address: --
$ nmcli c show e8c79829-1848-4563-8e44-466e14a3223d | grep cloned
802-11-wireless.cloned-mac-address: stable
```
以下这个例子使用 Amtrak 的完全随机 MAC 地址(使用默认配置)和 MyHome 的永久 MAC 地址(使用 stable 配置)。永久 MAC 地址是在硬件生产的时候分配到网络接口上的,网络管理员能够根据永久 MAC 地址来查看[设备的制造商 ID][5]。
更改配置并重新连接活动的接口:
```
$ nmcli c modify 5f4b9f75-9e41-47f8-8bac-25dae779cd87 802-11-wireless.cloned-mac-address random
$ nmcli c modify e8c79829-1848-4563-8e44-466e14a3223d 802-11-wireless.cloned-mac-address permanent
$ nmcli c down e8c79829-1848-4563-8e44-466e14a3223d
$ nmcli c up e8c79829-1848-4563-8e44-466e14a3223d
$ ip link
...
```
你还可以安装 NetworkManager-tui ,就可以通过可视化界面菜单来编辑连接。
### 总结
当你走在路上时,你要[留意周围的环境][6],并[警惕可能的危险][7]。同样,在使用公共互联网资源时也要注意你自己的可追踪性。
--------------------------------------------------------------------------------
via: https://fedoramagazine.org/randomize-mac-address-nm/
作者:[sheogorath][a],[Stuart D Gathman][b]
选题:[lujun9972](https://github.com/lujun9972)
译者:[HankChow](https://github.com/HankChow)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://fedoramagazine.org/author/sheogorath/
[b]: https://fedoramagazine.org/author/sdgathman/
[1]: https://en.wikipedia.org/wiki/MAC_address
[2]: https://www.ribbonfarm.com/2010/07/26/a-big-little-idea-called-legibility/
[3]: https://serverfault.com/questions/462178/duplicate-mac-address-on-the-same-lan-possible
[4]: https://blogs.gnome.org/thaller/2016/08/26/mac-address-spoofing-in-networkmanager-1-4-0/
[5]: https://www.wireshark.org/tools/oui-lookup.html
[6]: https://www.isba.org/committees/governmentlawyers/newsletter/2013/06/becomingmoreawareafewtipsonkeepingy
[7]: http://www.selectinternational.com/safety-blog/aware-of-surroundings-can-reduce-safety-incidents

View File

@ -0,0 +1,117 @@
在Linux上使用 i3 作为窗口管理器的入门教程
======
![](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/windows-tiling-windows-wall.png?itok=mTH7uVrn)
在我的文章[5 reasons the i3 window manager makes Linux better][1],我分享了选择 [i3 window manager][2] 作为一种Linux桌面替代方案的最主要五个理由。
在本篇文章中,我将向大家展示,如何在 Fedora 28 上安装与配置 i3。
### 1\. 安装
首先进入 Fedora 系统中,打开一个终端。使用 `dnf` 来安装需要的软件包,如下:
```
[ricardo@f28i3 ~]$ sudo dnf install -y i3 i3-ipc i3status i3lock dmenu terminator --exclude=rxvt-unicode
Last metadata expiration check: 1:36:15 ago on Wed 08 Aug 2018 12:04:31 PM EDT.
Dependencies resolved.
================================================================================================
 Package                     Arch         Version                           Repository     Size
================================================================================================
Installing:
 dmenu                       x86_64       4.8-1.fc28                        fedora         33 k
 i3                          x86_64       4.15-1.fc28                       fedora        323 k
 i3-ipc                      noarch       0.1.4-12.fc28                     fedora         14 k
 i3lock                      x86_64       2.9.1-2.fc28                      fedora         33 k
 i3status                    x86_64       2.12-1.fc28                       updates        62 k
 terminator                  noarch       1.91-4.fc28                       fedora        570 k
Installing dependencies:
 dzen2                       x86_64       0.8.5-21.20100104svn.fc28         fedora         60 k
... Skipping dependencies/install messages
Complete!
[ricardo@f28i3 ~]$
```
注意:在这个命令中,我排除了 `rxvt-unicode` 这个包,因为我更喜欢 `terminator` 作为我的终端模拟器。
据用户目前的系统状态,在命令执行过程中可能会安装很多依赖。等待所有的依赖安装完成,之后重启你的电脑。
### 2. 登录与初始化
在你的机器重启之后,你便可以第一次体验 i3 了。在 GNOME Display Manager GDM选择你的用户名之后先别着急输密码点击下方的密码输入框下方的小齿轮之后选择 i3 ,像下方这样:
![](https://opensource.com/sites/default/files/uploads/i3_first_login_small.png)
输入你的密码,并点击 `Sign In`。在你第一次登入之后,会先看到 i3 的配置界面:
![](https://opensource.com/sites/default/files/uploads/i3_first_configuration_small.png)
点击 `ENTER` 就会在 `$HOME/.config/i3` 生成一个配置文件,之后你可以通过这个配置文件来定制化 i3's 的一些行为。
在下一屏,你需要选择你的 `Mod` 键。这一步很关键,因为 `Mod` 键通常都会作为 i3's 命令快捷键的发起键。按 `ENTER` 会选择 `Win` 键作为默认的 `Mod` 键。如果你的键盘没有 `Win` 键,用 `Alt` 键做替代,用方向键键选择后按 `ENTER` 确认。
![](https://opensource.com/sites/default/files/uploads/i3_generate_config_small.png)
现在你就登录到了 i3 的系统中。由于 i3 是一个最小化的窗口管理器,你会看到一个黑屏窗口,以及屏幕底端显式的状态栏:
![](https://opensource.com/sites/default/files/uploads/i3_start_small.png)
接下来,让我们看看 i3 的如何实际使用。
### 3\. 基本的快捷键
现在你已经登录到了 i3 的会话中,你需要几个基本的快捷键来应对基本的操作。
大多数的 i3 快捷键都会用到之前配置的 `Mod` 键。在下面的例子中,当我提到 `Mod` 键,请根据情况使用你定义的做替换。通常使用 `Win` 键或者 `Alt` 键。
首先,打开一个终端,使用 `Mod+ENTER`。重复打开几个终端,观察 i3 是如何自动将它们在桌面中排列。默认情况下, i3 会在水平的方向分割屏幕;使用 `Mod + v` 来垂直分割,再按 `Mod + h` 会恢复水平分割模式。
![](https://opensource.com/sites/default/files/uploads/i3_3terminal_tiled_small.png)
当需要启动其他的应用,按 `Mod + d` 来打开 `dmenu`,一个简单的文字应用菜单。默认情况下,`dmenu` 会呈现出所有在你 `$PATH` 中设置的应用。使用方向键来选择你想启动的应用,同时你可以键入应用的名称,来缩小选择的范围,之后按 `ENTER` 来启动选择的应用。
![](https://opensource.com/sites/default/files/uploads/i3_dmenu.png)
如果你的应用没有提供退出的方法,你可以使用 i3 来关闭对应的窗口,通过按 `Mod + Shift +q`。注意,你可能会丢失未保存的工作内容。
最后,当你想关闭会话并退出 i3`Mod + Shift +e`。之后会在窗口的上方提示你是否退出。点击 `Yes, exit i3` 退出,或选择 `X` 来取消。
![](https://opensource.com/sites/default/files/uploads/i3_exit_small.png)
这些就是 i3 中最基本的快捷键,如果想了解更多,请查阅官方文档 [documentation][3]。
### 4\. 替换GDM
使用 i3 window manager 会降低你操作系统的内存占用然而Fedora 依然会使用 GDM 作为登录的窗口。GDM 会载入几个与 GNOME 相关的库从而占用内存。
如果你想进一步的降低你的内存占用,你可以使用一些更轻量级的窗口管理器来替换 GDM比如 `lightdm`
```
[ricardo@f28i3 ~]$ sudo dnf install -y lightdm
[ricardo@f28i3 ~]$ sudo systemctl disable gdm
Removed /etc/systemd/system/display-manager.service.
[ricardo@f28i3 ~]$ sudo systemctl enable lightdm
Created symlink /etc/systemd/system/display-manager.service -> /usr/lib/systemd/system/lightdm.service.
[ricardo@f28i3 ~]$
```
之后重启你的机器来使用 Lightdm 的登录界面。
现在你可以继续登录并使用 i3了。
![](https://opensource.com/sites/default/files/uploads/i3_lightdm_small.png)
--------------------------------------------------------------------------------
via: https://opensource.com/article/18/8/getting-started-i3-window-manager
作者:[Ricardo Gerardi][a]
选题:[lujun9972](https://github.com/lujun9972)
译者:[sd886393](https://github.com/sd886393)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]: https://opensource.com/users/rgerardi
[1]: https://opensource.com/article/18/8/i3-tiling-window-manager
[2]: https://i3wm.org
[3]: https://i3wm.org/docs/userguide.html#_default_keybindings