mirror of
https://github.com/LCTT/TranslateProject.git
synced 2026-08-23 04:03:29 +08:00
@@ -0,0 +1,50 @@
|
||||
容器和 Unikernel 能从树莓派和 Arduino 学到什么?
|
||||
==========================================================================
|
||||
|
||||

|
||||
|
||||
某一天,我和我的一个机械工程师朋友聊天的时候。 他最近在做一个给半挂卡车的电子辅助刹车系统,他提到他们公司的办公室里都是 [Arduinos][1]。这主要是方便员工可以快速的对新的想法进行实验。他也提到了,Arduinos 其实比自己画电路板更加昂贵。对此,我感到非常震惊,因为我从软件行业得到的印象是 Arduinos 比定制电路板更加便宜。
|
||||
|
||||
我常常把 [Arduinos][2] 和 [树莓派][3] 看做是可以制作非常有趣设备的小型、Cool、特别的组件。我主要从事于软件行业,并且总是觉得运行在 x86 和 x86-64 设备上的 Linux 才算是“常规用途”。而事实是,Arduinos 并不是特殊用途。实际上,它们是很常规的用途。它们相当的小、便宜,而且非常的灵活。这就是为什么它们像野火一样流行起来的原因。它们有全品类的输入输出设备和扩展卡。它们能让创客们快速的构建非常 Cool 的设备。它们甚至可以让公司可以快速地开发产品。
|
||||
|
||||
一套 Arduino 的单价比批量生产的电路板高了很多,但是,看不见的时间成本却低了很多。当电路板大规模生产的时候,价格可以控制的很低,但是,之前的研发费用却高了很多。所以,总而言之,答案就是,使用 Arduino 划得来。
|
||||
|
||||
### Unikernel、Rump 内核和容器主机
|
||||
|
||||
Unikernel、Rump 内核和迷你 Linux 发行版,这些操作系统是为了特有用途而构建的。这些特有的操作系统,某种程度上就像定制电路板。它们需要前期的投入,还需要设计,但是,当大规模部署的时候,它可以提供强大的性能。
|
||||
|
||||
迷你操作系统,例如:红帽企业版 Atomic 或者 CoreOS 是为了运行容器而构建的。它们很小,快速,易于在启动时配置,并且很适合于运行容器。缺点就是它需要额外的工程量来添加第三方插件,比如监控客户端或者虚拟化的工具。副作用就是载入的工具也需要重新设计为超级权限的容器。 如果你正在构建一个巨大的容器环境,这些额外的工作量是划算的。但是,如果只是想尝试下容器,那可能就没必要了。
|
||||
|
||||
容器提供了运行标准化的工作流程(比如使用 [glibc][4] 编译)的能力。一个好处就是你可以在你的电脑上构建和测试这个工作单元(Docker 镜像)并且在完全不同的硬件上或者云端非常顺利的部署,而保持着相同的特性。在生产环境中,容器的宿主机仍然由运维团队进行配置管理,但是应用被开发团队控制。这就是对双方来说最好的合作方式。
|
||||
|
||||
Unikernels 和 Rump 内核依旧是为了特定目标构建的,但是却更进一步。整个的操作系统在构建的时候就被开发或者架构师配置好了。这带来了好处,同时还有挑战。
|
||||
|
||||
一个好处就是,开发人员可以控制这个工作流程的运转。理论上说,一个开发者可以为了不同的特性,尝试 [不同的 TCP 协议栈][5],并且选择最好的一个。在操作系统启动的时候,开发人也可以配置 IP 地址,而不是通过 DHCP。 开发人员也可以裁剪任何对于应用而言不需要的部分。这也是性能提升的保障,因为减少了[不必要的上下文切换][6]。
|
||||
|
||||
同时,Unikernel 也带来了挑战。目前,还缺失很多的工具。 现在,和画板子的世界类似,开发人员需要花费很多时间和精力在检查是否有完整的库文件存在,不然的话,他们必须改变他们应用的执行方式。在如何让这个“嵌入式”的操作系统在运行时配置的方面,也存在挑战。最后,每次操作系统的大改动,都需要[反馈到开发人员][7]来进行修改。这并没有一个在开发和运维之间明确的界限,所以我能想象,为了接受了这个开发流程,一些组织或者公司必须要改变。
|
||||
|
||||
### 结论
|
||||
|
||||
在专门的容器主机比如 Rump 内核和 Unikernel 方面也有一些有趣的传闻,因为,它们会带来一个特定工作流程的潜在变革(嵌入式、云,等等)。在这个令人激动又快速发展的领域请保持你的关注,但是也要谨慎。
|
||||
|
||||
目前,Unikernel 看起来和定制电路板很像。它们都需要前期的研发投资,并且都是非常独特的,可以为确定的工作流程带来好处。同时,容器甚至在常规的工作流中都非常有趣,而且它不需要那么多的投入。一个简单的例子,运维团队能方便的在容器上部署一个应用,但是在 Unikernel 上部署一个应用则需要重新设计和编码,而且业界并不能完全保证,这个工作流程就可以被部署在 Unikernel 上。
|
||||
|
||||
容器,Rump 内核 和 Unikernel 有一个光明的未来!
|
||||
|
||||
--------------------------------------
|
||||
via: https://opensource.com/business/16/5/containers-unikernels-learn-arduino-raspberry-pi
|
||||
|
||||
作者:[Scott McCarty][a]
|
||||
译者:[MikeCoder](https://github.com/MikeCoder)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/fatherlinux
|
||||
[1]: https://opensource.com/resources/what-arduino
|
||||
[2]: https://opensource.com/life/16/4/arduino-day-3-projects
|
||||
[3]: https://opensource.com/resources/what-raspberry-pi
|
||||
[4]: https://en.wikipedia.org/wiki/GNU_C_Library
|
||||
[5]: http://www.eetasia.com/ARTICLES/2001JUN/2001JUN18_NTEK_CT_AN5.PDF
|
||||
[6]: https://en.wikipedia.org/wiki/Context_switch
|
||||
[7]: http://developers.redhat.com/blog/2016/05/18/3-reasons-i-should-build-my-containerized-applications-on-rhel-and-openshift/
|
||||
@@ -0,0 +1,336 @@
|
||||
Excel “过滤和编辑” - Pandas 中的示范操作
|
||||
==================================================
|
||||
|
||||

|
||||
|
||||
### 介绍
|
||||
|
||||
我听许多人说我[之前的关于 pandas 处理一般的 Excel 任务][1]的文章对于帮助新的 pandas 用户将 Excel 处理过程转化成对应的 pandas 代码是有用的。这篇文章将会保持传统,通过介绍不同的 pandas 使用 Excel 的过滤功能作为一个模型进行索引的例子来理解该处理过程。
|
||||
|
||||
大多数 pandas 的新手首先学到的东西就是基本的数据过滤。即使在过去的时间中使用 pandas 工作持续数月,我最近意识到我没有在我每天的工作中使用过的 pandas 过滤的方法还有另外一个好处。也就是说,你可以过滤一组给定的列,而使用一个简化的 pandas 的语法更新另一组列。这和我所说的 Excel 中的“过滤并编辑”很像。
|
||||
|
||||
这篇文章将会介绍一些基于各种条件过滤一个 pandas 数据帧并同时更新数据的例子。同时,我将更多的介绍一下 panda 的索引,和如何使用索引功能例如 .loc , .ix 和 .iloc 来简单、快速基于简单或者是复杂的条件来更新一个数据子集。
|
||||
|
||||
### Excel: “过滤并编辑”
|
||||
|
||||
在数据透视表以外,在 EXCEL 顶部工具栏的工具之一是过滤器。这个简单的工具允许用户通过不同的数据、文本与格式条件去快速过滤与排序数据。这里是由几个不同的条件过滤数据产生的样本数据的基本截图:
|
||||
|
||||

|
||||
|
||||
该过滤过程是直观的,即使是最新手的用户,也很容易掌握。我也注意到,人们会使用此功能来选择数据行,然后根据行的条件来更新其它的列。下面的例子显示了我所描述的情形:
|
||||
|
||||

|
||||
|
||||
在这个例子中,我过滤了 Account Number、SKU 和 Unit Price 的数据。接着我手工增加了 Commission_Rate列,并且在每个单元格中输入 0.01。这种方法的好处是可以很容易理解,并有助于管理有联系的复杂数据而不用写长长的 Excel 公式或者使用 VBA。这种方法的缺点是,它是不可重复的,同时,对于刚入门的外行人了解哪些条件被用于过滤器可能是比较困难的。
|
||||
|
||||
例如,假设你看上述截图,如果不看每一列数据,没有明显的方法去知道什么被过滤了。幸运的是,我们可以在 pandas 中完成相似操作。不用奇怪,在 pandas 中使用简单干净的代码来执行“过滤并编辑”模式是很容易的。
|
||||
|
||||
### 布尔检索
|
||||
|
||||
现在,我想通过 pandas 中一些布尔索引的细节来使你对这个问题有点感觉。如果你想要去理解 pandas 的在多数情况下的[索引和数据选择][3],那么这是一个要理解的重要概念。这种想法可能看起来有点复杂,对新的 pandas 用户(可能对经验丰富的用户来说太基础),但我认为重要的是要花一些时间了解它。如果你掌握了这一概念,用 pandas 进行数据工作的基本过程将更简单。
|
||||
|
||||
pandas 通过标签、基于数字的位置或者一个布尔值(True/False)列表来支持索引(或者选择数据)。使用一个布尔值的列表来选择一个行被称为布尔索引,将是本文其余部分的重点。
|
||||
|
||||
我发现,我的 pandas 的工作流程往往侧重于使用布尔值的列表选择我的数据。换句话说,当我创建了 pandas 数据帧,我倾向于保持数据框架的默认索引。因此,该布尔索引本身并不具有真正意义,同时也不是简单的选择数据。
|
||||
|
||||
|
||||
> 关键点
|
||||
> pandas 中布尔索引是选择行的数据的强大的和有用的方法之一。
|
||||
|
||||
让我们看一些示例的数据帧来帮助澄清在 pandas 中布尔索引做的是什么。
|
||||
|
||||
首先,我们将创建一个来自 Python 的列表的非常小的数据帧,并使用它来展示布尔索引是如何工作的。
|
||||
|
||||
|
||||
```
|
||||
import pandas as pd
|
||||
sales = [('account', ['Jones LLC', 'Alpha Co', 'Blue Inc', 'Mega Corp']),
|
||||
('Total Sales', [150, 200, 75, 300]),
|
||||
('Country', ['US', 'UK', 'US', 'US'])]
|
||||
df = pd.DataFrame.from_items(sales)
|
||||
```
|
||||
|
||||
|account |Total Sales |Country
|
||||
:--|:-- |:-- |:
|
||||
0 |Jones LLC |150 |US
|
||||
1 |Alpha Co |200 |UK
|
||||
2 |Blue Inc |75 |US
|
||||
3 |Mega Corp |300 |US
|
||||
|
||||
注意值 0-3,是怎么样会自动分配给行的?这些都是索引,在这个数据集它们不是特别有意义的,但对 pandas 是有用的,对于了解如下其他没有描述的用例是重要的。
|
||||
|
||||
当我们引用布尔索引时,我们只是说,我们可以通过一个 True 或 Flse 的值的列表表示我们要查看的每一行。
|
||||
|
||||
在这种情况下,如果我们想查看Jones LLC、Blue Inc 和 Mega Corp 的数据,我们可以看到,True、False 列表看起来会像这样:
|
||||
|
||||
```
|
||||
indices = [True, False, True, True]
|
||||
```
|
||||
|
||||
这没什么奇怪的,你可以通过把这个列表传入到你的数据帧,你就看到它只会显示该值是 True 的行:
|
||||
|
||||
```
|
||||
df[indices]
|
||||
```
|
||||
|
||||
|account |Total Sales |Country
|
||||
:--|:--|:--|:--
|
||||
0 |Jones LLC |150 |US
|
||||
2 |Blue Inc |75 |US
|
||||
3 |Mega Corp |300 |US
|
||||
|
||||
|
||||
这里是一个刚刚发生了什么的示意图:
|
||||
|
||||

|
||||
|
||||
手工创建索引列表是可以工作的,但是显然对任何一个稍微大点的数据集来说却不是可扩展的或非常有用的。幸运的是,pandas 可以用一个简单的查询语言创建这些布尔索引,对熟悉使用 Python (或任何语言)的人应该很容易。
|
||||
|
||||
例如,让我们看看来自美国的所有销售的行。如果我们执行一个基于 Country 列的 Python 表达式:
|
||||
|
||||
|
||||
```
|
||||
df.Country == 'US'
|
||||
```
|
||||
|
||||
```
|
||||
0 True
|
||||
1 False
|
||||
2 True
|
||||
3 True
|
||||
Name: Country, dtype: bool
|
||||
```
|
||||
|
||||
这个例子显示了 pandas 如何将你的 Python 的常规逻辑,把它应用到一个数据帧并返回一个布尔值列表。那么这个布尔值的列表可以传递到数据帧来获取相应的行。
|
||||
|
||||
在真正的代码中,你不需要做这两个步骤。简洁的做这事的方法典型的看上去如下:
|
||||
|
||||
```
|
||||
df[df["Country"] == 'US']
|
||||
```
|
||||
|
||||
|account |Total Sales |Country
|
||||
:--|:--|:--|:--
|
||||
0 |Jones LLC |150| US
|
||||
2 |Blue Inc |75 |US
|
||||
3 |Mega Corp| 300| US
|
||||
|
||||
虽然这个概念很简单,但你可以编写非常复杂的逻辑,使用 Python 的威力来过滤数据。
|
||||
|
||||
|
||||
> 关键点
|
||||
> 在这个例子中, `df[df.Country == 'US']` 等价于 `df[df["Country"] == 'US']` ‘.’ 标记法是简洁的但是在你列名中有空格时不会工作。
|
||||
|
||||
|
||||
### 选择需要的列
|
||||
|
||||
现在,我们已经指出了如何选择行的数据,我们如何控制显示哪些列?在上面的例子中,没有明确的方法完成这个。Pandas 能使用三种基于位置的索引支持这个用法:.loc 、iloc 和 .ix 。这些功能也允许我们在所看到的行之外挑选列。
|
||||
|
||||
关于什么时候选择使用 .loc 、iloc 或者是 .ix,在这里很容易困惑。 快速总结的区别是:
|
||||
|
||||
- .loc 用于标签索引
|
||||
- .iloc 用于基于整数的位置
|
||||
- .ix 是一个快捷方式,它将尝试使用标签(比如 .loc)但失败后将退而求其次使用基于整数的位置(比如 .iloc)
|
||||
|
||||
因此问题是我该使用哪个?我必须坦诚地说,我有的时候也会被这些搞混。我发现我最常使用 .loc 。主要是因为我的数据不适合于有意义的基于位置的索引(换句话说,我很少发现自己需要使用 .iloc),所以我坚持使用 .loc。
|
||||
|
||||
公平地讲,每一个方法都有自己的用途,在许多情况下都是有用的。特别是处理多索引数据帧时。我不会在这篇文章中讨论那个话题-也许在未来的博文会说。
|
||||
|
||||
现在我们已经涵盖了这样一个话题,让我们来展示如何筛选一行的值的数据帧,具体选择要显示的列。
|
||||
|
||||
继续我们的例子,如果我们只是想显示对应于我们的索引的帐户名称,该怎么做?使用 .loc 很简单:
|
||||
|
||||
```
|
||||
df.loc[[True, True, False, True], "account"]
|
||||
```
|
||||
|
||||
```
|
||||
1 Alpha Co
|
||||
2 Blue Inc
|
||||
3 Mega Corp
|
||||
Name: account, dtype: object
|
||||
```
|
||||
|
||||
如果你想看到多个列,只需传递一个列表:
|
||||
|
||||
```
|
||||
df.loc[[True, True, False, True], ["account", "Country"]]
|
||||
```
|
||||
|
||||
| account |Country
|
||||
:--|:--|:--
|
||||
0 |Jones LLC| US
|
||||
1 |Alpha Co |UK
|
||||
3 |Mega Corp |US
|
||||
|
||||
真正的威力是当你在你的数据上创建更复杂的查询。在这种情况下,让我们展示所有的帐户名称和 sales > 200 的国家:
|
||||
|
||||
```
|
||||
df.loc[df["Total Sales"] > 200, ["account", "Country"]]
|
||||
```
|
||||
|
||||
|account| Country
|
||||
:--|:--|:--
|
||||
3 |Mega Corp| US
|
||||
|
||||
|
||||
这个过程可以看做有点相当于我们上面讨论过的 Excel 过滤器。但是有更多的好处,你还可以限制你检索的列数,而不仅仅是行。
|
||||
|
||||
### 编辑列
|
||||
|
||||
所有这些都是好的背景知识,但当你使用一个类似的方法基于选择的行来更新一个或多个列时,这个处理过程就真的是非常漂亮。
|
||||
|
||||
作为一个简单的例子,让我们增加一个 rate 列到我们的数据:
|
||||
|
||||
```
|
||||
df["rate"] = 0.02
|
||||
```
|
||||
|
||||
| account |Total Sales| Country |rate
|
||||
:--|:--|:--|:--|:--
|
||||
0 |Jones LLC |150 |US |0.02
|
||||
1 |Alpha Co |200 |UK |0.02
|
||||
2 |Blue Inc |75 |US |0.02
|
||||
3 |Mega Corp |300 |US |0.02
|
||||
|
||||
|
||||
假如说如果你卖了超过 100,你的利率是 5%。基本的过程是设置一个布尔索引来选择列,然后将该值赋给利率列:
|
||||
|
||||
|
||||
```
|
||||
df.loc[df["Total Sales"] > 100, ["rate"]] = .05
|
||||
```
|
||||
|
||||
| account |Total Sales| Country| rate
|
||||
:--|:--|:--|:--|:--
|
||||
0 |Jones LLC |150| US| 0.05
|
||||
1 |Alpha Co |200 |UK |0.05
|
||||
2 |Blue Inc |75| US |0.02
|
||||
3 |Mega Corp |300| US| 0.05
|
||||
|
||||
|
||||
希望你逐步看过这篇文章,这将对于帮助你理解这个语法是如何工作的是有意义的。现在你明白了“过滤并编辑”方法的基本原理。最后一节将介绍 Excel 和 pandas 这个过程的更多细节。
|
||||
|
||||
### 将这些组合在一起
|
||||
|
||||
对于最后的例子,我们将创建一个简单的佣金计算器,使用以下规则:
|
||||
|
||||
- 所有的佣金计算在交易水平
|
||||
- 所有销售的基础佣金为 2%
|
||||
- 所有 shirt 都将获得 2.5% 的佣金
|
||||
- 有个特殊的环节,在一个交易中销售的数额 >10 的 belt 将得到 4% 的佣金
|
||||
- 所有在一个单一的 shoe 类交易中 > 1000 美元,有一个特别的 250 美元奖金加上一个 4.5% 的佣金
|
||||
|
||||
要在 Excel 中做到这一点,使用的过滤器和编辑方法:
|
||||
|
||||
- 添加一个 2% 的佣金列
|
||||
- 添加一个 0 美元的奖金列
|
||||
- 过滤 shirts,并将 vale 改为 2.5%
|
||||
- 清除过滤器
|
||||
- 过滤数量 > 10 的 belt ,并将值更改为 4%
|
||||
- 清除过滤器
|
||||
- 过滤 > 1000 美元 shoe,并相应的增加佣金和奖金为 4.5% 和 250 美元
|
||||
|
||||
我不会显示每一步的屏幕快照,但这里是最后一个过滤器的屏幕快照:
|
||||
|
||||

|
||||
|
||||
这种方法很简单,便于操作,但它不具备很好的可重复性,也不能审核。当然还有其他的方法,如在 Excel 公式或 VBA 中实现这些。然而,这种过滤器和编辑的方法是常用的,可以说明 pandas 的逻辑。
|
||||
|
||||
现在,让我们在 pandas 中运行这个例子。
|
||||
|
||||
首先,读入 [Excel 文件][4]同时加入默认值为 2% 的 rate 一列:
|
||||
```
|
||||
import pandas as pd
|
||||
df = pd.read_excel("https://github.com/chris1610/pbpython/blob/master/data/sample-sales-reps.xlsx?raw=true")
|
||||
df["commission"] = .02
|
||||
df.head()
|
||||
```
|
||||
|
||||
| account number| customer name| sales rep| sku |category |quantity |unit price| ext price| date| commission
|
||||
:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--
|
||||
0 |680916 |Mueller and Sons |Loring Predovic |GP-14407 | Belt |19 |88.49 |1681.31 |2015-11-17 05:58:34| 0.02
|
||||
1 |680916 |Mueller and Sons |Loring Predovic |FI-01804| Shirt |3| 78.07| 234.21 |2016-02-13 04:04:11 |0.02
|
||||
2 |530925 |Purdy and Sons| Teagan O’Keefe |EO-54210 |Shirt |19 |30.21 |573.99 |2015-08-11 12:44:38 |0.02
|
||||
3 |14406| Harber, Lubowitz and Fahey| Esequiel Schinner| NZ-99565| Shirt| 12| 90.29 |1083.48 |2016-01-23 02:15:50 |0.02
|
||||
4 |398620| Brekke Ltd |Esequiel Schinner |NZ-99565 |Shirt |5| 72.64 |363.20 |2015-08-10 07:16:03 |0.02
|
||||
|
||||
|
||||
下一个规则是所有 shirt 获得 2.5% 和 Belt 销售 > 10 得到一个 4% 的 rate:
|
||||
|
||||
```
|
||||
df.loc[df["category"] == "Shirt", ["commission"]] = .025
|
||||
df.loc[(df["category"] == "Belt") & (df["quantity"] >= 10), ["commission"]] = .04
|
||||
df.head()
|
||||
```
|
||||
|
||||
| account number |customer name |sales rep| sku |category |quantity| unit price| ext price |date |commission
|
||||
:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--
|
||||
0 |680916| Mueller and Sons| Loring Predovic| GP-14407| Belt| 19 |88.49| 1681.31 |2015-11-17 05:58:34| 0.040
|
||||
1 |680916| Mueller and Sons| Loring Predovic| FI-01804| Shirt |3 |78.07 |234.21| 2016-02-13 04:04:11 |0.025
|
||||
2 |530925 |Purdy and Sons |Teagan O’Keefe| EO-54210 |Shirt| 19 |30.21 |573.99 |2015-08-11 12:44:38| 0.025
|
||||
3 |14406| Harber, Lubowitz and Fahey| Esequiel Schinner| NZ-99565| Shirt| 12| 90.29| 1083.48| 2016-01-23 02:15:50 |0.025
|
||||
4 |398620| Brekke Ltd| Esequiel Schinner| NZ-99565| Shirt| 5 |72.64 |363.20| 2015-08-10 07:16:03 |0.025
|
||||
|
||||
最后的佣金规则是加上特别的奖金:
|
||||
|
||||
```
|
||||
df["bonus"] = 0
|
||||
df.loc[(df["category"] == "Shoes") & (df["ext price"] >= 1000 ), ["bonus", "commission"]] = 250, 0.045
|
||||
|
||||
# Display a sample of rows that show this bonus
|
||||
df.ix[3:7]
|
||||
```
|
||||
|
||||
| account number| customer name |sales rep| sku |category| quantity| unit price| ext price| date| commission| bonus
|
||||
:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--
|
||||
3| 14406| Harber, Lubowitz and Fahey| Esequiel Schinner| NZ-99565| Shirt |12 |90.29| 1083.48 |2016-01-23 02:15:50 |0.025 |0
|
||||
4| 398620| Brekke Ltd| Esequiel Schinner |NZ-99565| Shirt| 5| 72.64| 363.20| 2015-08-10 07:16:03| 0.025| 0
|
||||
5| 282122| Connelly, Abshire and Von Beth| Skiles| GJ-90272| Shoes| 20| 96.62| 1932.40 |2016-03-17 10:19:05 |0.045 |250
|
||||
6 |398620 |Brekke Ltd| Esequiel Schinner |DU-87462 |Shirt| 10| 67.64 |676.40| 2015-11-25 22:05:36| 0.025| 0
|
||||
7| 218667| Jaskolski-O’Hara| Trish Deckow| DU-87462| Shirt |11| 91.86| 1010.46 |2016-04-24 15:05:58| 0.025| 0
|
||||
|
||||
为了做好佣金的计算:
|
||||
|
||||
```
|
||||
# Calculate the compensation for each row
|
||||
df["comp"] = df["commission"] * df["ext price"] + df["bonus"]
|
||||
|
||||
# Summarize and round the results by sales rep
|
||||
df.groupby(["sales rep"])["comp"].sum().round(2)
|
||||
```
|
||||
|
||||
```
|
||||
sales rep
|
||||
Ansley Cummings 2169.76
|
||||
Beth Skiles 3028.60
|
||||
Esequiel Schinner 10451.21
|
||||
Loring Predovic 10108.60
|
||||
Shannen Hudson 5275.66
|
||||
Teagan O'Keefe 7989.52
|
||||
Trish Deckow 5807.74
|
||||
Name: comp, dtype: float64
|
||||
```
|
||||
|
||||
如果你有兴趣,一个例子手册放在[github][5]。
|
||||
|
||||
### 总结
|
||||
|
||||
感谢阅读文章。 我发现,在学习如何使用 pandas 的新用户所面临最大的挑战之一,是根据他们基于 Excel 的知识,如何找出建立一个等效的基于 pandas 的解决方案。在许多情况下,pandas 的解决方案将是更健壮、更快、更容易审计和更强大的。然而,学习曲线需要花费一些时间。我希望这个展示了如何使用电子表格的过滤工具来解决一个问题的例子,将有助于那些刚刚在开始 pandas 之旅的同学们。祝你好运!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://pbpython.com/excel-filter-edit.html
|
||||
|
||||
作者:[Chris Moffitt ][a]
|
||||
译者:[zky001](https://github.com/zky001)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://pbpython.com/author/chris-moffitt.html
|
||||
[1]: http://pbpython.com/excel-pandas-comp.html
|
||||
[2]: http://pbpython.com/excel-pandas-comp-2.html
|
||||
[3]: http://pandas.pydata.org/pandas-docs/stable/indexing.html
|
||||
[4]: https://github.com/chris1610/pbpython/blob/master/data/sample-sales-reps.xlsx?raw=true
|
||||
[5]: https://github.com/chris1610/pbpython/blob/master/notebooks/Commissions-Example.ipynb
|
||||
@@ -1,13 +1,13 @@
|
||||
WattOS:一个稳如磐石、快如闪电、面向所有人的轻量级Linux发行版
|
||||
WattOS:一个稳如磐石、快如闪电、面向所有人的轻量级 Linux 发行版
|
||||
=============================
|
||||
|
||||

|
||||
|
||||
Jack Wallen 将介绍一下是什么让 WattOS 这么特别。 [使用许可][81]
|
||||
*Jack Wallen 将介绍一下是什么让 WattOS 这么特别。 [使用许可][81]*
|
||||
|
||||
Linux 领域里的每个人不是听说过就是使用过某个轻量级的 Linux 发行版。大家都知道我们不断追求的是:占用内存少,配置资源要求低,包含一个轻量级的桌面环境(或者窗口管理器),并且提供和其他发行版相似的桌面布局,把赌注押在相同的需求之上。
|
||||
|
||||
这种发行版大多用来工作。有一个可以击垮很多轻量级 Linux 发行版的问题,它们没有真正含有一般用户完成工作需要的工具。为此,他们不再用来完成工作,沦落为用来完成特殊任务(像数据恢复、做信息亭等)。
|
||||
这种发行版大多用来工作。有一个可以击垮很多轻量级 Linux 发行版的问题,它们没有真正含有一般用户完成工作需要的工具。结果就是,它们沦落为用来完成特殊任务(像数据恢复、做信息亭等)。
|
||||
|
||||
在某种程度上,WattOS 陷入了同样的困境(它唯一含有的生产力工具是 PDF 阅读器,而且它使用标准的“任务栏/开始菜单”象征桌面)。然而幸运的是,WattOS 通过难以置信的运行速度、稳定性以及内置新立得包管理器弥补了这些缺点;所以,WattOS 可以很容易的成为一个适合所有人的轻量级 Linux 发行版。
|
||||
|
||||
@@ -15,43 +15,43 @@ Linux 领域里的每个人不是听说过就是使用过某个轻量级的 Linu
|
||||
|
||||
### 内核
|
||||
|
||||
事实上当我发现 WattOS 基于 kernel 4.4 内核时我非常吃惊。升级系统之后,执行 uname -r 命令可以看到 4.4.0-38-generic。鉴于这个发行版的目的是让老旧和运行卡顿的机器重获新生,它和我的 Elementary OS Loki 发行版内置相同版本的内核真是一个可爱的惊喜。这意味着 WattOS 在新旧硬件上都会有良好的工作表现。
|
||||
事实上当我发现 WattOS 基于 kernel 4.4 内核时我非常吃惊。升级系统之后,执行 `uname -r` 命令可以看到是 4.4.0-38-generic。鉴于这个发行版的目的是让老旧和运行卡顿的机器重获新生,它和我的 Elementary OS Loki 发行版内置相同版本的内核真是一个可爱的惊喜。这意味着 WattOS 在新旧硬件上都会有良好的工作表现。
|
||||
|
||||
真正的惊喜不止于此,当你去 WattOS 的网站,你会同时发现32位和64位版本的下载地址(现在大多数新的发行版都倾向于放弃32位发行版本)。所以,不仅系统内核对新式硬件提供支持,而且系统发行版本的多种架构也能让那些老式的32位机器重获新生。
|
||||
真正的惊喜不止于此,当你去 WattOS 的网站,你会同时发现 32 位和 64 位版本的下载地址(现在大多数新的发行版都倾向于放弃 32 位发行版本)。所以,不仅系统内核对新式硬件提供支持,而且系统发行版本的多种架构也能让那些老式的 32 位机器重获新生。
|
||||
|
||||
### 运行速度
|
||||
|
||||
当安装上 WattOS 的时候,有那么一刻我对它有纯粹的羡慕。WattOS 的运行速度快的令人难以置信。甚至当它的桌面版作为客户机在 VirtualBox 虚拟机平台工作时,运行速度依然远远超过了我的 Elementary OS Loki 桌面发行版。后来我才了解到当时运行的宿主机是 [System76 Leopard][80],配置有水冷装置的 i7 处理器和 16GB 的运行内存。分配给 WattOS 大约 2G 的运行内存,好像没有任何任务能让它的运行速度慢下来。WattOS 的运行速度壮观的令人难以诉说,它越来越成熟了。我从没见过火狐浏览器能打开的这么快。
|
||||
当安装上 WattOS 的时候,有那么一刻我对它有纯粹的羡慕。WattOS 的运行速度快的令人难以置信。甚至当它的桌面版作为客户机在 VirtualBox 虚拟机平台工作时,运行速度依然远远超过了我的 Elementary OS Loki 桌面发行版。后来我才了解到当时运行的宿主机是 [System76 Leopard][80],配置有水冷装置的 i7 处理器和 16GB 的运行内存。分配给 WattOS 大约 2G 的内存,让它看起来没有什么任务可以拖慢它。WattOS 的运行速度壮观的令人难以诉说,它越来越成熟了。我从没见过火狐浏览器能打开的这么快。
|
||||
|
||||
接下来说说 LibreOffice 应用的启动。由于想测试 LibreOffice 的启动速度,所以我打开了新立得软件包管理器,计划安装这一开源办公软件套件的佼佼者。
|
||||
|
||||
无果。
|
||||
|
||||
安装LibreOffice 的主要问题是缺少一个依赖软件包 python3-uno,而且无论怎么尝试都无法安装成功。然而,最后我在 [LibreOffice 官方网站][79] 上下载了 deb 格式的软件包。把下载的文件解压之后,cd 到 LibreOffice_5.2.2.2_Linux_x86-64_deb/DEBS/ 目录下,最后通过执行sudo dpkg -i *.deb 命令成功的安装了LibreOffice。
|
||||
安装 LibreOffice 的主要问题是缺少一个依赖软件包 python3-uno,而且无论怎么尝试都无法安装成功。然而,最后我在 [LibreOffice 官方网站][79] 上下载了 deb 格式的软件包。把下载的文件解压之后,`cd` 到 LibreOffice_5.2.2.2_Linux_x86-64_deb/DEBS/ 目录下,最后通过执行 `sudo dpkg -i *.deb` 命令成功的安装好了 LibreOffice。
|
||||
|
||||
LibreOffice 运行的怎么样呢?速度快到要疯了。值得再提的是,我从没见过这个应用能像在 WattOS 上运行的这么快。点击 LibreOffice Writer 的图标,它花费的时间是在 Elementary OS Loki (已经很快了)主机上花费的一半。
|
||||
|
||||
### 桌面
|
||||
|
||||
我个人偏爱于桌面向更加现代化的趋势进行迭代。我是 Ubuntu 的 Unity 桌面,GNOME 3 桌面,以及(特别是) [Elementary OS][78] 的粉丝。所以使用古老风格桌面的主意意味着对我几乎没有吸引力。即便如此,WattOS 在把现代设计风格融入老式设计时做的非常好。举例来说,默认的桌面主题(图 1)。WattOS 的 UI 设计者巧妙设计了桌面主题,所以它没有完全偏离 Windows XP 或者 老式 Linux CDE 风格的窗口管理器的设计理念。
|
||||
我个人偏爱于桌面向更加现代化的趋势进行迭代。我是 Ubuntu 的 Unity 桌面,GNOME 3 桌面,以及(特别是) [Elementary OS][78] 的粉丝。所以使用古老风格桌面的主意意味着对我几乎没有吸引力。即便如此,WattOS 在把现代设计风格融入老式设计时做的非常好。举例来说,默认的桌面主题(图 1)。WattOS 的 UI 设计者巧妙设计了桌面主题,所以它没有完全偏离 Windows XP 或者老式 Linux CDE 风格的窗口管理器的设计理念。
|
||||
|
||||

|
||||
|
||||
>图 1:WattOS 的文件管理器展示了有些现代化的主题 [使用许可][76]
|
||||
*图 1:WattOS 的文件管理器展示了有些现代化的主题 [使用许可][76]*
|
||||
|
||||
关于 WattOS 的桌面(基于 [LXDE][75])的确有一些要说的但以前从来没说过,就是每个拥有像简洁、直接,有足够灵活度和自定义度这些特点的 Linux 桌面版,对每个使用过 Windows 95 的电脑使用者来说都会很熟悉。
|
||||
|
||||
### 惊喜之处,优点和缺点
|
||||
|
||||
正像每个新的 Linux 桌面版的体验那样,WattOS有让人惊喜的地方,同时也有优点和缺点。首先,说说优点。
|
||||
正像每个新的 Linux 桌面版的体验那样,WattOS 有让人惊喜的地方,同时也有优点和缺点。首先,说说优点。
|
||||
|
||||
WattOS 除了绝对的速度(用一个简单的 “WOW” 来评论),还在桌面上固定了一些特别的惊喜(大多数都是预置的应用)。额外的软件中最好的是 [KeePassX][74](一个默认在桌面的应用)。我得出了密码管理器应该默认安装在每一个电脑桌面上的结论,值得骄傲的是 WattOS 预装了这个杰出的工具。
|
||||
WattOS 除了绝对的速度(用一个简单的 “WOW” 来评论),还在桌面上固定了一些特别的惊喜(大多数都是预置的应用)。额外的软件中最好的是 [KeePassX][74](一个极少被默认包含在桌面版的应用)。我认为密码管理器应该默认安装在每一个电脑桌面上,值得骄傲的是 WattOS 预装了这个杰出的工具。
|
||||
|
||||
下一个讨论的是预装火狐浏览器。许多轻量级的发行版会预装像 [Surf][73] 或者 [Midori][72] 这样的浏览器。这两个浏览器都不错,但是它们的兼容性经常达不到像谷歌文档这样网站的要求。因为 WattOS 含有成熟的火狐浏览器,在和火狐浏览器兼容的网页上你会发现网站平台的功能实现的很完美。
|
||||
下一个讨论的是预装火狐浏览器。许多轻量级的发行版会预装像 [Surf][73] 或者 [Midori][72] 这样的浏览器。这两个浏览器都不错,但是它们的兼容性经常达不到像谷歌文档这样网站的要求。因为 WattOS 含有成熟的火狐浏览器,你会发现该系统的功能在火狐浏览器兼容的网站上表现的很完美。
|
||||
|
||||
最后,算不上好的意外。正如我已经提到的,在安装 LibreOffice 时马上就有了故障。然而安装像 GIMP 这样的软件就很顺利(所以我认为这是偶然问题)。除了这一个问题,我坚信默认桌面菜单有些混乱。例如,新立得软件包管理器放在个性化菜单里。我更愿在主菜单中突出显示项中看到它,并且加上类似“软件安装”(或任何其他新用户容易理解)的标签。从我的视角来说,个性化菜单项应该用于放置配置平台各种风格的工具,而不是安装软件的工具。
|
||||
最后,算不上好的意外。正如我已经提到的,在安装 LibreOffice 时马上就有了故障。然而安装像 GIMP 这样的软件就很顺利(所以我认为这是偶然问题)。除了这一个问题,我觉得默认桌面菜单有些混乱。例如,新立得软件包管理器放在个性化菜单里。我更愿在主菜单中突出显示项中看到它,并且加上类似“软件安装”(或任何其他新用户容易理解)的标签。从我的视角来说,个性化菜单项应该用于放置配置该平台各种风格的工具,而不是安装软件的工具。
|
||||
|
||||
除此之外,若想在 WattOS 主攻方向上的找茬,比如这 Linux 发行版面对老旧硬件时,你会发现这非常困难。
|
||||
除此之外,若想在 WattOS 主攻方向上的找茬的话,特别是你要找一个面对老旧硬件 Linux 发行版时,你会发现这非常困难。
|
||||
|
||||
### 结论
|
||||
|
||||
@@ -62,10 +62,8 @@ WattOS 除了绝对的速度(用一个简单的 “WOW” 来评论),还
|
||||
via: https://www.linux.com/learn/wattos-rock-solid-lightning-fast-lightweight-linux-distro-all
|
||||
|
||||
作者:[JACK WALLEN][a]
|
||||
|
||||
译者:[译者ID](https://github.com/fuowang)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
译者:[fuowang](https://github.com/fuowang)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
@@ -1,113 +1,91 @@
|
||||
一个日常 Linux 使用者关于 Xubuntu 16.10 的论述 - 起步的好选择
|
||||
点评 Xubuntu 16.10:起步的好选择
|
||||
===============
|
||||
|
||||
### 简介
|
||||
|
||||
[][36]
|
||||
|
||||
Xubuntu 一直是我最喜欢的发行版。与其他的 Linux 发行版相比,他的外观看起来不那么迷人,它当然也不会预装所有你需要的软件。
|
||||
Xubuntu 一直是我最喜欢的发行版之一。与其它的 Linux 发行版相比,它的外观看起来不那么迷人,它当然也不会把你需要的软件全部预装上。
|
||||
|
||||
Xubuntu 给你的仅仅是一个基础的初始形态.
|
||||
Xubuntu 能够给你的就是一个良好的起点。
|
||||
|
||||
如果你喜欢定制桌面,那么 XFCE 绝对是最好的桌面环境。
|
||||
如果你是那种喜欢定制桌面和外观的人,那么 XFCE 绝对是适合于这种的最好的桌面环境。如果你的系统资源不足,或想让桌面漂亮舒服, XFCE 还是一个很棒的选择。
|
||||
|
||||
如果系统资源不足,或想让工作漂亮顺畅, XFCE 还是一个很棒的选择。
|
||||
Xubuntu 之所以成领先于其它 Linux 发行版,就是因为它默认安装 XFCE 桌面。
|
||||
|
||||
Xubuntu 之所以成为一个优秀的 Linux 发行版,就是因为他默认安装 XFCE 桌面。
|
||||
毫无疑问,在硬件兼容性、易用性、稳定性、易于安装,以及拥有一个大型社区等方面,Ubuntu 是很难被超越的。Xubuntu 是 Ubuntu Linux 发行版的官方流派,因此你可以拥有所有 Ubuntu 的优点,除了用 XFCE 桌面代替 Unity 桌面。
|
||||
|
||||
毫无疑问,当涉及到硬件兼容性、易用性、稳定性、易于安装和拥有一个大型社区,Ubuntu 是很难被超越的。
|
||||
你可以选择性的安装应用到你的发行版上,而不是像其它发行版那样预装了一堆你不需要的应用。Xubuntu 只附带了一些必须的应用,在这么小的核心之外的应用要靠你自己去找并安装。
|
||||
|
||||
Xubuntu 是 Ubuntu Linux 发行版的官方支持的,因此你可以拥有所有 Ubuntu 的优点,除了用 XFCE 桌面代替 Unity 桌面。
|
||||
|
||||
你可以选择性的安装应用到你的发行版上,而不是像其他发行版那样预装了一堆你不需要的应用。
|
||||
|
||||
Xubuntu 只附带了一些必须的应用,在小核心包含之外的应用要靠你自己去找并安装。
|
||||
|
||||
对我来说,以上就是我为什么认为 Xubuntu 是一个极好的发行版的原因。一个简单的初始安装并且任由我将其自定义为我想要的样子。
|
||||
对我来说,以上就是我为什么认为 Xubuntu 是最棒的发行版的原因。从简单的基本安装开始,然后按照你要的去定制就好了。
|
||||
|
||||
### 如何获得 Xubuntu
|
||||
|
||||
你可以在 [http://xubuntu.org/][35] 访问 Xubuntu 的网站。
|
||||
你可以访问 Xubuntu 的官网:[http://xubuntu.org/][35]。
|
||||
|
||||
[][34]
|
||||
|
||||
你可以在这里 [http://xubuntu.org/getxubuntu/][33] 找到下载页。
|
||||
|
||||
它有两个版本,大多数人会选择长期支持版本(LTS),除非你希望每六个月更新一次系统。
|
||||
它有两个版本,大多数人会选择长期支持版本(LTS),除非你希望每六个月更新一次系统。而另一个版本是我今天要讲的,它就是 16.10 版。
|
||||
|
||||
另一个版本是我今天要讲的,它就是 16.10 版。
|
||||
|
||||
你既可以选择一个种子文件来下载,也可以访问他的镜像源下载。
|
||||
你既可以选择一个种子文件来下载 ISO,也可以访问它的镜像源下载。
|
||||
|
||||
[][32]
|
||||
|
||||
如果你选择在镜像源中下载,你需要点击合适的 ISO 文件。比如 64 位的选择 amd-64.iso 文件,而 32 位的选择 i386.iso。
|
||||
|
||||
有很多教程,可以教你怎么创建一个 Linux 启动 U 盘。
|
||||
有很多教程,可以教你怎么创建一个 Linux 启动 U 盘:
|
||||
|
||||
* [这是 Ubuntu 的教程,同样适用于 Xubuntu][3]
|
||||
* [你也可以试试这款针对 Xubuntu 的教程][2]
|
||||
* [这是一个如何在 Ubuntu 下创建的教程,同样适用于 Xubuntu][3]
|
||||
* [你也可以试试这份针对 Xubuntu 的教程][2]
|
||||
* [或者你也可以试试这个][1]
|
||||
|
||||
如果这些你都觉得太复杂,你可以 [从这买一个。][31]
|
||||
|
||||
|
||||
如果这些你都觉得太复杂,你可以 [从这买一个][31]。
|
||||
|
||||
### 安装
|
||||
|
||||
[][30]
|
||||
[][30]
|
||||
|
||||
与 Ubuntu 其他版本相比,安装 Xubuntu 相对要直接一点。
|
||||
|
||||
如果你曾经装过一个版本,那么基本上你可以安装任何一个版本。
|
||||
像 Ubuntu 其它版本一样,安装 Xubuntu 相当直白。如果你曾经装过一个版本,那么基本上你可以安装任何一个版本。
|
||||
|
||||
开始时选择你的安装语言。
|
||||
|
||||
[][29]
|
||||
[][29]
|
||||
|
||||
你会被问到,是否需要同时安装更新,是否要安装第三方软件,包括播放音乐的软件和专有驱动。
|
||||
你会被问到,是否需要同时安装更新,是否要安装第三方软件,包括播放音乐的软件和专有驱动。想要完成这些,你需要联网。
|
||||
|
||||
想要完成这些,你需要联网。
|
||||
再次,这也很直白,我们会在之后再次涉及到这些。
|
||||
|
||||
Again It is relatively straight forward and covered later on in the review.相比于直接安装,他会在安装好后覆盖安装更新.
|
||||
|
||||
[][28]
|
||||
[][28]
|
||||
|
||||
如果你有一个备用的未分配的磁盘分区和并且安装了 Windows,您将看到可以选择在已有 Windows 的情况下安装 Xubuntu 并设置双启动。
|
||||
|
||||
您还可以选择安装 Xubuntu 作为唯一的操作系统,你也可以选择别的任何你喜欢的分区来安装。
|
||||
您也可以选择安装 Xubuntu 作为唯一的操作系统,还可以选择别的任何你喜欢的分区来安装。
|
||||
|
||||
[][27]
|
||||
[][27]
|
||||
|
||||
下一步是设置你所在的区域以确定你的时区。
|
||||
|
||||
[][26]
|
||||
[][26]
|
||||
|
||||
接下来两步是选择语言和键盘设置,以确定键盘模式。
|
||||
|
||||
[][25]
|
||||
[][25]
|
||||
|
||||
最后创建一个初始账户.
|
||||
最后创建一个默认账户,输入你的名字、你计算机的名字、设置用户名和密码。
|
||||
|
||||
输入你的名字,你计算机的名字,设置用户名和密码。
|
||||
|
||||
Xubuntu 将会被安装在你的电脑上了。
|
||||
Xubuntu 将会被安装在你的电脑上了,你可以继续往下看了。
|
||||
|
||||
### 第一印象
|
||||
|
||||
[][24]
|
||||
|
||||
Xubuntu 的初始界面只有一个面板位于蓝色桌面的顶部。通过桌面上的图标,你可以看到所有可用的设备。
|
||||
|
||||
At the top of the screen is a single panel.
|
||||
|
||||
The left corner on the panel has a single icon (picture of a mouse) which when clicked brings up a stylish, lightweight but fully functional menu known as the Whisker menu.
|
||||
|
||||
The top right corner has icons for notifications, power settings, bluetooth settings, network settings, audio settings and a clock.
|
||||
Xubuntu 的初始界面只有一个面板位于蓝色桌面的顶部。通过桌面上的图标,你可以看到所有可用的驱动器。
|
||||
|
||||
画面的顶部是个简单的面板。
|
||||
|
||||
面板的左侧角落有一个单独的图标(老鼠的样子),点击它后会出现一个时尚,轻量但功能全面的菜单,它被称为 Whisker(胡须)菜单。
|
||||
面板的左侧角落有一个单独的图标(老鼠的样子),点击它后会出现一个时尚而轻量,但功能全面的菜单,它被称为 Whisker(胡须)菜单。
|
||||
|
||||
在右上角有着通知、电源、蓝牙、网络、音量和时钟的图标。
|
||||
|
||||
@@ -115,11 +93,11 @@ The top right corner has icons for notifications, power settings, bluetooth sett
|
||||
|
||||
[][23]
|
||||
|
||||
你可以通过点击面板上的网络图标来连接互联网。一个无线网络的列表将会出现,你可以选择一个点击进去,并键入密码,就可以连接了。
|
||||
你可以通过点击面板上的网络图标来连接互联网。一个无线网络的列表将会出现,你可以选择一个点击,并键入密码,就可以连接了。
|
||||
|
||||
我是在我的联想 Ideapad Y700 上安装 Xubuntu 的,这个本子还是比较新潮的。但是许多发行版在无线网络连接时都会报错,而我必须使用无线网络工作。
|
||||
我是在我的联想 Ideapad Y700 上安装 Xubuntu 的,这个本子很现代,其上运行的许多发行版在无线网络连接时会有些小问题,我不得不找些规避问题的方法。
|
||||
|
||||
Xubuntu 16.10 工作时却没有出现任何问题。
|
||||
但 Xubuntu 16.10 工作的很好,不需要做任何修改。
|
||||
|
||||
### 驱动
|
||||
|
||||
@@ -127,53 +105,53 @@ Xubuntu 16.10 工作时却没有出现任何问题。
|
||||
|
||||
为你的电脑寻找可用的附加驱动是十分必要的。
|
||||
|
||||
虽然作为默认设置的开源驱动是基本够用的,但是如果你有着较好的显卡,并且想获得更好的图形体验,那就十分有必要去寻找专有的驱动。
|
||||
虽然默认的开源驱动是基本够用的,但是如果你有着较好的显卡,并且想获得更好的图形体验,那就十分有必要去寻找专有驱动。
|
||||
|
||||
你可以找到附加驱动的窗口,通过打开它来寻找附加驱动。
|
||||
打开菜单,搜索附加驱动,你可以找到附加驱动设置界面。
|
||||
|
||||
如果你找到了适合你的显卡驱动,但是它显示不工作,那么我还是建议你用默认的图形驱动。
|
||||
如果看到你的显卡驱动,但是它不工作,那么我还是建议你用默认的显卡驱动。
|
||||
|
||||
### 打印
|
||||
|
||||
[][21]
|
||||
[][21]
|
||||
|
||||
我有一个爱普生 WF-2630 无线打印机。 Xubuntu 能够直接找到这台打印机,并安装相关驱动,来进行打印工作。
|
||||
我有一个爱普生 WF-2630 无线打印机。 Xubuntu 能够直接找到这台打印机,并安装相关驱动。
|
||||
|
||||
我试着打印了一张纸,发现它的输出非常合适。
|
||||
我打印了测试页,发现它的输出非常合适。
|
||||
|
||||
### 网络附加存储
|
||||
### 网络存储
|
||||
|
||||
[][20]
|
||||
|
||||
我有一个 WD MyCloud 存储设备需要通过网络连接上。
|
||||
我有一个跨无线网络连接的 WD MyCloud 存储设备。
|
||||
|
||||
你可以通过默认的文件管理器 Thunar 来访问这个设备。值得注意的是,我在网络设备中找到了 WD MyCloud 设备,但是点击它时显示错误。
|
||||
可以通过默认的文件管理器 Thunar 来访问这个设备。值得注意的是,我在网络设备中找到了 WD MyCloud 设备,但是点击它时显示错误。
|
||||
|
||||
但是我打开 Windows 的网络文件夹时,WD MyCloud 也显示出来了,而且我也能正常的访问文件夹
|
||||
但是我打开 Windows 网络文件夹时,WD MyCloud 也显示出来了,而且我也能正常访问该设备上的文件夹。
|
||||
|
||||
### 软件
|
||||
|
||||
[][19]
|
||||
|
||||
我在文章开始时提到了,Xubuntu 给了一个最小化的应用程序配置,所以几乎所有事情你都可以直接开始。
|
||||
我在文章开始时提到了,Xubuntu 配备了最少的应用集,不过它包含了你开始所需要的所有应用。
|
||||
|
||||
火狐浏览器是它的默认浏览器,Thunderbird 是默认的邮件客户端
|
||||
火狐浏览器是它的默认浏览器,Thunderbird 是默认的邮件客户端。
|
||||
|
||||
[][18]
|
||||
|
||||
你也有一个全套的 Libreoffice 套件和 Parole 媒体播放器。
|
||||
你也有一个全套的 LibreOffice 套件和 Parole 媒体播放器。
|
||||
|
||||
它也有一系列工具,比如图片查看器、计算器、光盘刻录工具,还有一个BT下载器。
|
||||
它也有一系列工具,比如图片查看器、计算器、光盘刻录工具,还有一个 BT 下载器。
|
||||
|
||||
[][17]
|
||||
|
||||
我很高兴,现在在大多数发行版上,Abiword 和 Gnumeric 都被忽略掉了,因为他们实在无关紧要。大多数人们最终会安装 Libreoffice 的。
|
||||
我很高兴,现在在大多数发行版上,Abiword 和 Gnumeric 都被忽略掉了,因为它们实在无关紧要。大多数人们最终会安装 Libreoffice 的。
|
||||
|
||||
缺乏专门的音频播放器这点比较奇怪。另外我需要提到的是我通常最终会安装谷歌的 Chrome 浏览器,而不是使用Firefox。
|
||||
|
||||
这章节的第一个图片说明了原因。这张图片里,我试图利用谷歌商店里的东西激起你的兴趣,可惜的是各种版本的 DRM 和其他一些问题导致了视频无法播放。
|
||||
本节的第一个图片说明了原因。这张图片里,我试图观看 Google Play 商店的 “Curb Your Enthusiam” 视频,可惜的是各种 DRM 和其它一些问题导致了视频无法播放。
|
||||
|
||||
当从谷歌网站上下载一个东西都报错了之后,我就不能接受简单的跳过这个问题。如下所示。
|
||||
从谷歌网站上一个简单的下载就可以解决问题。如下所示。
|
||||
|
||||
[][16]
|
||||
|
||||
@@ -181,49 +159,47 @@ Xubuntu 16.10 工作时却没有出现任何问题。
|
||||
|
||||
[][15]
|
||||
|
||||
在基于 Ubuntu 16.04 版本的发行版上普遍存在的一个主要问题是有些程序无法在图形安装软件中安装。
|
||||
在 Ubuntu 16.04 以后的发行版上普遍存在的一个主要问题是有些程序无法在图形安装软件中安装。
|
||||
|
||||
比如你在软件管理器中找不到 Steam 。
|
||||
比如在软件管理器中找不到 Steam。
|
||||
|
||||
[][14]
|
||||
|
||||
如果你使用命令行输入 “sudo apt-cache search steam” 你会发现软件可以安装。
|
||||
如果你使用命令行输入 `sudo apt-cache search steam` 你会发现有这个软件。
|
||||
|
||||
[][13]
|
||||
|
||||
并不是 只有Steam 被遗漏了,其他软件比如 Skype 同样不能再图形软件管理工具中找到。
|
||||
并不是只有 Steam 被遗漏了,其它软件比如 Skype 同样不能在图形软件管理工具中找到。
|
||||
|
||||
我希望这个问题能够在所有 Ubuntu 发现版中间被解决。
|
||||
我真希望这个问题已经在所有 Ubuntu 发行版中解决了。
|
||||
|
||||
我最近还试用了 Kubuntu 16.04 ,发现他的软件工具完全无用,搜索根本不工作。
|
||||
我最近还试用了 Kubuntu 16.04 ,发现它的叫做 Discover 的软件工具完全无用,搜索根本不工作。
|
||||
|
||||
幸运的是,Xubuntu 上的软件工具可以安装大多数软件包,我利用它搜寻并装上了 Quod Libet 音乐播放器。
|
||||
幸运的是,Xubuntu 上的软件管理器可以安装大多数软件包,我利用它搜寻并装上了 Quod Libet 音乐播放器。
|
||||
|
||||
[][12]
|
||||
|
||||
[][11]
|
||||
[][11]
|
||||
|
||||
顺便说一下,如果你在安装 Xubuntu 时选择了同时安装 MP3 播放器,它也不会出现任何问题。
|
||||
顺便说一下,如果你在安装 Xubuntu 时选择了同时安装解码器,那么 MP3 播放也不会出现任何问题。
|
||||
|
||||
如果你没有同时安装 MP3 播放器,那么你需要打开终端模拟器,安装 Xubuntu 限制的额外包。
|
||||
如果没有安装,那么你需要打开终端模拟器,安装 Xubuntu Restricted Extras 包。
|
||||
|
||||
### 个性化 Xubuntu
|
||||
|
||||
[][10]
|
||||
[][10]
|
||||
|
||||
在这方面你可以做很多事:
|
||||
在这方面你可以做很多事来定制 Xubuntu, [参见这里][9]。
|
||||
|
||||
[个性,Xubuntu 的方法在这][9]。
|
||||
|
||||
Xubuntu 提供一整套壁纸,如上图所示,你要做的第一件事就是选一个好看的壁纸并添加一个像 Dock 的面板和一个能够启动所有你喜欢的软件的启动器。
|
||||
Xubuntu 提供一整套漂亮的壁纸,如上图所示,你要做的第一件事就是选一个好看的壁纸并添加一个 Dock 风格的面板,里面含所有你喜欢的软件的启动器。
|
||||
|
||||
[][8]
|
||||
|
||||
Xubuntu 有一个相对较新的特性就是 XFDashboard 。它带来了与 Gnome 类似的 Dash 面板。你可以在上面添加启动器和能够让他快速出现的键盘快捷键。
|
||||
Xubuntu 有一个相对较新的特性就是 XFDashboard 。它带来了与 Gnome 桌面类似的 Dash 面板。你可以在上面添加启动器和能够让应用快速启动的键盘快捷键。
|
||||
|
||||
[][7]
|
||||
|
||||
展示了一个快速选择不同工作区和启动应用的好方法。
|
||||
此图展示了一个快速选择不同工作区和启动应用的好方法。
|
||||
|
||||
说老实话,当谈到个性化 Xubuntu 时,有一种世界尽在我掌中的感觉。
|
||||
|
||||
@@ -241,30 +217,26 @@ Xubuntu 有一个相对较新的特性就是 XFDashboard 。它带来了与 Gnom
|
||||
|
||||
### 总结
|
||||
|
||||
我并没有经常使用 Xubuntu ,并不是因为我不喜欢它。事实上我是 Xubuntu 的大粉丝,并且我在另一个电脑上有一个它的大量定制版。
|
||||
我不对 Xubuntu 点评更多,并不是因为我不喜欢它。事实上我是 Xubuntu 的大粉丝,并且我在另一个电脑上有一个它的深度定制版。
|
||||
|
||||
我使用电脑时,我希望把事情做到最好,我最恼火的是看到下面这个情况。
|
||||
我使用电脑时,我希望了解发生了什么,没有比看到下面这种情况更让人恼火的了。
|
||||
|
||||
[][4]
|
||||
|
||||
认真的说,为啥会有人认为 windows 适合工作,当他每天看到这个消息 “正在安装(1/285)” ,于是你就失去了一个小时,以便让他进行自我更新。
|
||||
认真的说,为啥会有人认为 windows 适合工作?似乎每隔一就会看到消息 “正在安装(1/285)” ,于是当它自己更新时,你就失去了一个小时。而 Xubuntu(和其它发行版一样)更新不会打断你每天的工作。
|
||||
|
||||
而 Xubuntu(和其他发行版一样)更新不会打断你每天的工作。
|
||||
|
||||
事实是,Xubuntu 真的没有什么改变,它是坚固的,稳定的,它不需要改变(除了软件管理的需要以外)。
|
||||
事实是,Xubuntu 真的没有什么需要改变的,它可靠、稳定、不需要改变什么(除了软件管理器)。
|
||||
|
||||
我非常推荐 Xubuntu。
|
||||
|
||||
我还想说去试一试 Peppermint OS、Linux Mint XFCE 或者 Manjaro XFCE 也是十分值得的.
|
||||
此外,我还得说去试一试 Peppermint OS、Linux Mint XFCE 或者 Manjaro XFCE 也是十分值得的。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.everydaylinuxuser.com/2016/10/an-everyday-linux-user-review-of_15.html
|
||||
|
||||
作者:[Gary Newell][a]
|
||||
|
||||
译者:[chao-zhi](https://github.com/chao-zhi)
|
||||
|
||||
校对:[jasminepeng](https://github.com/jasminepeng)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
@@ -0,0 +1,234 @@
|
||||
Neofetch :带发行版 Logo 图像的系统信息显示工具
|
||||
============================================================
|
||||
|
||||
Neofetch 是一个跨平台的易于使用的 [系统信息显示命令行脚本][3],它收集你的系统信息,并在终端中和图像一起显示出来,这个图像可能是你的发行版的 logo 也可能是你选择的一幅 ascii 艺术字。
|
||||
|
||||
Neofetch 和 [ScreenFetch][4] 或者 [Linux_Logo][5] 很像,但是它可以高度定制,并且还有一些额外的我们要在下面讨论的特点。
|
||||
|
||||
它的主要特点有:运行速度快,可以显示全色图像 —— 用 ASCII 字符显示的发行版 logo ,旁边显示系统信息,可以高度定制,可以随时随地显示系统信息,并且在脚本结束的时候还可以通过一个特殊的参数来启用桌面截图。
|
||||
|
||||
#### 系统要求:
|
||||
|
||||
1. Bash 3.0+ 带 ncurses 支持。
|
||||
2. w3m-img (有时候会打包成 w3m) 或者 iTerm2 或者 Terminology,用于显示图像。
|
||||
3. [imagemagick][1],用于创建缩略图。
|
||||
4. 支持 `[\033[14t` 的 [Linux 终端模拟器][2] 或者 xdotool 或者 xwininfo + xprop 或者 xwininfo + xdpyinfo 。
|
||||
5. Linux 系统中还需要 feh、nitrogen 或者 gsettings 来提供对墙纸的支持。
|
||||
|
||||
注意:你可以从 Neofetch 的 Github 页面了解更多关于可选依赖的信息,以检查你的 [Linux 终端模拟器][6] 是不是真的支持 `\033[14t` 或者是否需要一些额外的依赖来使这个脚本在你的发行版上工作得更好。
|
||||
|
||||
### 怎样在 Linux 系统上安装 Neofetch
|
||||
|
||||
Neofetch 可以从几乎所有 Linux 发行版的第三方仓库轻松安装,请按照以下各自的安装说明进行安装。
|
||||
|
||||
#### Debian
|
||||
|
||||
```
|
||||
$ echo "deb http://dl.bintray.com/dawidd6/neofetch jessie main" | sudo tee -a /etc/apt/sources.list
|
||||
$ curl -L "https://bintray.com/user/downloadSubjectPublicKey?username=bintray" -o Release-neofetch.key && sudo apt-key add Release-neofetch.key && rm Release-neofetch.key
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get install neofetch
|
||||
```
|
||||
|
||||
#### Ubuntu 和 Linux Mint
|
||||
|
||||
```
|
||||
$ sudo add-apt-repository ppa:dawidd0811/neofetch
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get install neofetch
|
||||
```
|
||||
|
||||
#### RHEL, CentOS 和 Fedora
|
||||
|
||||
你的系统里面要安装了 `dnf-plugins-core` ,或者用以下命令安装它:
|
||||
|
||||
```
|
||||
$ sudo yum install dnf-plugins-core
|
||||
```
|
||||
|
||||
启用 COPR 仓库然后安装 neofetch。
|
||||
|
||||
```
|
||||
$ sudo dnf copr enable konimex/neofetch
|
||||
$ sudo dnf install neofetch
|
||||
```
|
||||
|
||||
#### Arch Linux
|
||||
|
||||
你可以用 packer 或 Yaourt 从 AUR 安装 neofetch 或 neofetch-git。
|
||||
|
||||
```
|
||||
$ packer -S neofetch
|
||||
$ packer -S neofetch-git
|
||||
或
|
||||
$ yaourt -S neofetch
|
||||
$ yaourt -S neofetch-git
|
||||
```
|
||||
|
||||
#### Gentoo
|
||||
|
||||
从 Gentoo/Funtoo 的官方源安装 app-misc/neofetch。如果你要安装这个程序的 git 版的话,你可以安装 app-misc/neofetch-9999。
|
||||
|
||||
### 怎么在 Linux 中使用 Neofetch
|
||||
|
||||
一旦你安装了 Neofetch ,使用它的一般语法是:
|
||||
|
||||
```
|
||||
$ neofetch
|
||||
```
|
||||
|
||||
注意: 要是你没有安装 w3m-img 或者 [imagemagick][7] 的话,[screenfetch][8] 会默认被启用,neofetch 会如下图所示显示你的 [ASCII 艺术 logo]。
|
||||
|
||||
#### Linux Mint 系统信息
|
||||
|
||||
[
|
||||

|
||||
][10]
|
||||
|
||||
*Linux Mint 系统信息*
|
||||
|
||||
#### Ubuntu 系统信息
|
||||
|
||||
[
|
||||

|
||||
][11]
|
||||
|
||||
*Ubuntu 系统信息*
|
||||
|
||||
如果你想用图片显示你的发行版 logo,需要用下面的命令安装 w3m-img 或者 imagemagick 。
|
||||
|
||||
```
|
||||
$ sudo apt-get install w3m-img [On Debian/Ubuntu/Mint]
|
||||
$ sudo yum install w3m-img [On RHEL/CentOS/Fedora]
|
||||
```
|
||||
|
||||
然后再次运行 neofetch,你就会看到如下图所示的用你系统的默认墙纸来显示图片。
|
||||
|
||||
```
|
||||
$ neofetch
|
||||
```
|
||||
[
|
||||

|
||||
][12]
|
||||
|
||||
*Ubuntu 系统信息带 logo*
|
||||
|
||||
第一次运行 neofetch 后,它会在这里创建一个配置文件: `$HOME/.config/neofetch/config`。
|
||||
|
||||
这个配置文件可以让你通过 `printinfo ()` 函数来调整你想显示在终端的系统信息。你可以增加,修改,删除,也可以使用 bash 代码去调整你要显示的信息。
|
||||
|
||||
你可以如下图所示用你喜欢的编辑器打开这个配置文件:
|
||||
|
||||
```
|
||||
$ vi ~/.config/neofetch/config
|
||||
```
|
||||
|
||||
以下是我系统配置的片段 ,显示了 `printinfo ()` 函数。
|
||||
|
||||
Neofetch 配置
|
||||
|
||||
```
|
||||
#!/usr/bin/env bash
|
||||
# vim:fdm=marker
|
||||
#
|
||||
# Neofetch config file
|
||||
# https://github.com/dylanaraps/neofetch
|
||||
|
||||
# Speed up script by not using unicode
|
||||
export LC_ALL=C
|
||||
export LANG=C
|
||||
|
||||
# Info Options {{{
|
||||
|
||||
# Info
|
||||
# See this wiki page for more info:
|
||||
# https://github.com/dylanaraps/neofetch/wiki/Customizing-Info
|
||||
printinfo() {
|
||||
info title
|
||||
info underline
|
||||
|
||||
info "Model" model
|
||||
info "OS" distro
|
||||
info "Kernel" kernel
|
||||
info "Uptime" uptime
|
||||
info "Packages" packages
|
||||
info "Shell" shell
|
||||
info "Resolution" resolution
|
||||
info "DE" de
|
||||
info "WM" wm
|
||||
info "WM Theme" wmtheme
|
||||
info "Theme" theme
|
||||
info "Icons" icons
|
||||
info "Terminal" term
|
||||
info "Terminal Font" termfont
|
||||
info "CPU" cpu
|
||||
info "GPU" gpu
|
||||
info "Memory" memory
|
||||
|
||||
# info "CPU Usage" cpu_usage
|
||||
# info "Disk" disk
|
||||
# info "Battery" battery
|
||||
# info "Font" font
|
||||
# info "Song" song
|
||||
# info "Local IP" localip
|
||||
# info "Public IP" publicip
|
||||
# info "Users" users
|
||||
# info "Birthday" birthday
|
||||
|
||||
info linebreak
|
||||
info cols
|
||||
info linebreak
|
||||
}
|
||||
.....
|
||||
```
|
||||
|
||||
下面的命令可以显示所有你能在 neofetch 脚本中用的参数和配置值:
|
||||
|
||||
```
|
||||
$ neofetch --help
|
||||
```
|
||||
|
||||
要启用所有的功能和参数来运行程序,你可以用 `--test` 参数:
|
||||
|
||||
```
|
||||
$ neofetch --test
|
||||
```
|
||||
|
||||
要再次显示 ASCII 艺术 logo ,你可以用 `--ascii` 参数 :
|
||||
|
||||
```
|
||||
$ neofetch --ascii
|
||||
```
|
||||
|
||||
这篇文章中,我们向你介绍了一个可以高度定制的、用来收集系统信息并将它显示在终端上的命令行脚本。
|
||||
|
||||
如果你有什么问题,或者对这个脚本有什么想法,请在下面留言。
|
||||
|
||||
最后但是同样重要的是,如果你知道有类似的脚本,请毫不犹豫地告诉我们,感谢反馈。
|
||||
|
||||
在此访问 [neofetch Github 仓库][13]。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/neofetch-shows-linux-system-information-with-logo
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
译者:[Yinux](https://github.com/Yinux)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/install-imagemagick-in-linux/
|
||||
[2]:http://www.tecmint.com/linux-terminal-emulators/
|
||||
[3]:http://www.tecmint.com/screenfetch-system-information-generator-for-linux/
|
||||
[4]:http://www.tecmint.com/screenfetch-system-information-generator-for-linux/
|
||||
[5]:http://www.tecmint.com/linux_logo-tool-to-print-color-ansi-logos-of-linux/
|
||||
[6]:http://www.tecmint.com/linux-terminal-emulators/
|
||||
[7]:http://www.tecmint.com/install-imagemagick-in-linux/
|
||||
[8]:http://www.tecmint.com/screenfetch-system-information-generator-for-linux/
|
||||
[9]:http://www.tecmint.com/linux_logo-tool-to-print-color-ansi-logos-of-linux/
|
||||
[10]:http://www.tecmint.com/wp-content/uploads/2016/11/Linux-Mint-System-Information.png
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2016/11/Ubuntu-System-Information.png
|
||||
[12]:http://www.tecmint.com/wp-content/uploads/2016/11/Ubuntu-System-Information-with-Logo.png
|
||||
[13]:https://github.com/dylanaraps/neofetch
|
||||
@@ -0,0 +1,88 @@
|
||||
安卓编年史(11):The Nexus One——迎来 Google Phone
|
||||
================================================================================
|
||||

|
||||
|
||||
*重新设计的拨号和联系人页面。
|
||||
[Ron Amadeo 供图]*
|
||||
|
||||
联系人/拨号应用程序的圆角标签拥有了更清晰、更成熟的外观设计。拨号器更名为“电话”,并且拨号按键从圆形改为了圆角矩形。语音邮件、拨号、以及删除按键被放置在底部。这个界面是安卓在 3.0 之前缺乏设计一致性的一个很好的例子。仅仅在这个界面上,标签用的是直角矩形,拨号按键使用圆角矩形,底部按键两侧合起来是个完整的圆。这里就像是个 UI 控件的摸奖袋,没有人尝试过让它们之间相互搭配。
|
||||
|
||||
安卓 2.0 的一个新特性是“快速拨号”,它将联系人以略缩图的形式添加到整个系统。从其它应用中点击它们可以打开一个联系这个人的快捷方式列表。这在联系人里并没有多大意义,但像在 Google Talk 中,能够通过点击某人的略缩图来给他拨号是十分方便的。
|
||||
|
||||

|
||||
|
||||
*[Ron Amadeo 供图]*
|
||||
|
||||
安卓 2.0 终于配备了接通和拒绝来电所需要的所有屏幕按键,而不再需要实体按钮,Droid 从中获益,从它的设计中除去了在现在看来是多余的按钮。安卓对于接通和拒绝来电的解决方案是这些左滑和右滑的标签。他们的工作方式就像是滑动解锁(后来被用到了滑动解锁中)——向右滑动绿色按钮接通来电,向左滑动红色按钮则是拒绝。一旦进入通话中,它看起来就很像安卓 1.6 了。所有选项还是隐藏在菜单按钮之中。
|
||||
|
||||
某人在设计拨号界面的时候一定在煲电话粥。他们只是去掉了“拨号盘”上字母的粗体,而不是从安卓 1.6 中重新绘制数字“5”的按键,然后就这么收工了。
|
||||
|
||||

|
||||
|
||||
*计算器和浏览器
|
||||
[Ron Amadeo 供图]*
|
||||
|
||||
计算器从在安卓 0.9 中被引入以来第一次得到改进。黑色玻璃球按钮换成了蓝色和黑色过渡的按钮。旧版计算器按键的按下高亮的红色边框被改为了一个比较正常的白色轮廓。
|
||||
|
||||
浏览器的微型网站名称栏改进为一个完整的、功能更完善的地址栏,并且带有书签按钮。为了节省屏幕空间,地址栏被附加到网页上,所以地址栏会随着页面向上滚动,给你留下更多的网页阅读空间。安卓 1.6 独特的缩放控制和附加按钮被去除,被替换为一个更简单的双击缩放手势,并且浏览器可以再次打开 arstechnica.com 而不崩溃了。这里还是没有双指捏合缩放。
|
||||
|
||||

|
||||
|
||||
*打开设置的相机,闪光灯设置,以及查看照片界面的菜单。
|
||||
[Ron Amadeo 供图]*
|
||||
|
||||
相机应用有个布满整个左侧的抽屉式菜单,打开它有许多设置。摩托罗拉 Droid 是率先带有 LED 闪光灯的安卓手机之一,所以设置里有个闪光灯控制,以及还有像场景模式、白平衡、效果、图片尺寸和存储位置(SD 卡或内置存储)的设置。
|
||||
|
||||
在照片查看界面,谷歌精简了菜单按钮。和屏幕上的选项相比,它们之间不再有重复的选项。这样精简后省下的空间,使得所有的选项能够在菜单里放得下了,而不再需要一个“更多”按钮。
|
||||
|
||||

|
||||
|
||||
*电子邮件应用的“帐户”页面,新的联合收件箱,系统设置的帐户与同步页面,自动亮度设置。
|
||||
[Ron Amadeo 供图]*
|
||||
|
||||
电子邮件应用程序有了大的功能提升。最重要的是它终于支持了 Microsoft Exchange。安卓 2.0 版本的电子邮件中收件箱和文件夹视图终于分开了,而不是使用安卓 1.0 引入的凌乱的混合视图。电子邮件甚至有了一个统一的收件箱,可以将你不同账户的所有邮件显示到一起。
|
||||
|
||||
这个收件箱视图和 Gmail 一起,把普通的电子邮件应用打趴下了。联合收件箱甚至胜过了 Gmail 的功能,这是极其罕见的。尽管如此,相对于 Gmail 来说,电子邮件仍然感觉像个多余的继女。它使用了 Gmail 界面来查看邮件,这意味着收件箱和文件夹使用了黑色主题,查看邮件却奇怪地选择了亮色主题。
|
||||
|
||||
捆绑的 Facebook 应用程序有一个很棒的账户同步功能,它可以从社交网络上下载联系人的照片和信息,并无缝集成到联系人应用里。后来 Facebook 和谷歌分道扬镳,[谷歌取消了这一功能][1]。谷歌表示,在 Facebook 不向其共享信息的情况下,与 Facebook 分享信息并不是什么好想法,因此更好的用户体验败给了公司间的政治斗争。
|
||||
|
||||
(不幸的是,我们无法展示 Facebook 应用,因为它也是死在 OAuth 更新手中的客户端之一。现在不可能从像这么老旧的应用上登录了。)
|
||||
|
||||
最后一张图片显示了自动亮度控制,安卓 2.0 是第一个支持这一功能的版本。Droid 配备了光线传感器,点击该复选框,会使亮度滑块消失,并且允许设备自动控制屏幕亮度。
|
||||
|
||||
正如它的名字所暗示的那样,安卓 2.0 是谷歌有史以来最大的更新。摩托罗拉和威瑞森给安卓带来了一个外形酷炫的设备,并在广告上投入了数不清的资金。之后的一段时间里,“Droid”成为了一个家喻户晓的名字。
|
||||
|
||||
### The Nexus One——迎来 Google Phone ###
|
||||
|
||||

|
||||
|
||||
2010 年 1 月,第一款 Nexus 设备发布,称为“[Nexus One][2]”。对谷歌来说,这部设备是个巨大的里程碑。这是第一部由谷歌设计并冠名的设备,而且谷歌计划直接向消费者出售设备。宏达电代工的 Nexus One 拥有 1GHz 的单核高通骁龙 S1 处理器、512MB 的内存、512MB 存储空间,以及一块 3.7 英寸的 AMOLED 显示屏。
|
||||
|
||||
Nexus One 代表着拥有纯净的安卓体验,没有运营商的定制和应用植入。谷歌直接控制安卓的更新。这使得谷歌能够在软件完成时直接向用户进行推送, 而不是再经过运营商的许可。运营商总是拖慢这一过程,因为他们对用户已经付过钱手机并不总是那么热切地想要改善它们。
|
||||
|
||||
谷歌[直接在网上][3]销售 Nexus One,无锁、无合约、完整零售价 529.99 美元。尽管同样的 Nexus One 在 T-Mobile 商店的合约价仅为 179.99 美元,谷歌想通过它的在线商店改变美国手机行业的运作方式。谷歌当时的想法是先挑选手机,再选择运营商,以此打破美国无线寡头对硬件的控制。
|
||||
|
||||
但谷歌的零售革命并没有奏效,在在线手机商店开通半年后,谷歌关闭了该服务。谷歌指出首要问题是销量低。在 2010 年,网上购物并不像今天这样司空见惯,消费者也还没有准备好在他们不能先握在自己手中试用的设备上花费 530 美元。高昂的价格也是一个制约因素;智能手机消费者更习惯于为眼前的设备花费 200 美元,并签署一项为期两年的合同。还有摩托罗拉 Droid 的因素,相比之下这部三个月前发布的设备并没有显著的不足。还由于 Droid 的庞大的营销活动和“iPhone 杀手”的炒作,它已经夺取了大多数 Nexus One 所面向的安卓发烧友市场。
|
||||
|
||||
尽管 Nexus One 的网上销售尝试可以被认为是失败的,谷歌还是从中学到了很多。2012 年,谷歌以 Google Play 的“设备”板块[重新推出其网上商店][4]。
|
||||
|
||||
----------
|
||||
|
||||

|
||||
|
||||
[Ron Amadeo][a] / Ron 是 Ars Technica 的评论编缉,专注于安卓系统和谷歌产品。他总是在追寻新鲜事物,还喜欢拆解事物看看它们到底是怎么运作的。[@RonAmadeo][t]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://arstechnica.com/gadgets/2014/06/building-android-a-40000-word-history-of-googles-mobile-os/11/
|
||||
|
||||
译者:[alim0x](https://github.com/alim0x) 校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://techcrunch.com/2011/02/22/google-android-facebook-contacts/
|
||||
[2]:http://arstechnica.com/gadgets/2010/01/nexus-one-review/
|
||||
[3]:http://arstechnica.com/gadgets/2010/01/googles-big-news-today-was-not-a-phone-but-a-url/
|
||||
[4]:http://arstechnica.com/gadgets/2012/04/unlocked-samsung-galaxy-nexus-can-now-be-purchased-from-google/
|
||||
[a]:http://arstechnica.com/author/ronamadeo
|
||||
[t]:https://twitter.com/RonAmadeo
|
||||
148
sources/tech/20160923 PyCharm - The Best Linux Python IDE.md
Normal file
148
sources/tech/20160923 PyCharm - The Best Linux Python IDE.md
Normal file
@@ -0,0 +1,148 @@
|
||||
PyCharm - The Best Linux Python IDE
|
||||
=========
|
||||
/about/pycharm2-57e2d5ee5f9b586c352c7493.png)
|
||||
|
||||
### Introduction
|
||||
|
||||
In this guide I will introduce you to the PyCharm integrated development environment which can be used to develop professional applications using the Python programming language.
|
||||
|
||||
Python is a great programming language because it is truly cross platform and can be used to develop a single application which will run on Windows, Linux and Mac computers without having to recompile any code.
|
||||
|
||||
PyCharm is an editor and debugger developed by [Jetbrains][1] who are the same people who developed Resharper which is a great tool used by Windows developers for refactoring code and to make their lives easier when writing .NET code. Many of the principles of [Resharper][2] have been added to the professional version of [PyCharm][3].
|
||||
|
||||
### How To Install PyCharm
|
||||
|
||||
I have written a guide showing how to get PyCharm, download it, extract the files and run it.
|
||||
|
||||
[Simply click this link][4].
|
||||
|
||||
### The Welcome Screen
|
||||
|
||||
When you first run PyCharm or when you close a project you will be presented with a screen showing a list of recent projects.
|
||||
|
||||
You will also see the following menu options:
|
||||
|
||||
* Create New Project
|
||||
* Open A Project
|
||||
* Checkout From Version Control
|
||||
|
||||
There is also a configure settings option which lets you set up the default Python version and other such settings.
|
||||
|
||||
### Creating A New Project
|
||||
|
||||
When you choose to create a new project you are provided with a list of possible project types as follows:
|
||||
|
||||
* Pure Python
|
||||
* Django
|
||||
* Flask
|
||||
* Google App Engine
|
||||
* Pyramid
|
||||
* Web2Py
|
||||
* Angular CLI
|
||||
* AngularJS
|
||||
* Foundation
|
||||
* HTML5 Bolierplate
|
||||
* React Starter Kit
|
||||
* Twitter Bootstrap
|
||||
* Web Starter Kit
|
||||
|
||||
This isn't a programming tutorial so I won't be listing what all of those project types are. If you want to create a base desktop application which will run on Windows, Linux and Mac then you can choose a Pure Python project and use QT libraries to develop graphical applications which look native to the operating system they are running on regardless as to where they were developed.
|
||||
|
||||
As well as choosing the project type you can also enter the name for your project and also choose the version of Python to develop against.
|
||||
|
||||
### Open A Project
|
||||
|
||||
You can open a project by clicking on the name within the recently opened projects list or you can click the open button and navigate to the folder where the project you wish to open is located.
|
||||
|
||||
### Checking Out From Source Control
|
||||
|
||||
PyCharm provides the option to check out project code from various online resources including [GitHub][5], [CVS][6], Git, [Mercurial][7] and [Subversion][8].
|
||||
|
||||
### The PyCharm IDE
|
||||
|
||||
The PyCharm IDE starts with a menu at the top and underneath this you have tabs for each open project.
|
||||
|
||||
On the right side of the screen are debugging options for stepping through code.
|
||||
|
||||
The left pane has a list of project files and external libraries.
|
||||
|
||||
To add a file you right-click on the project name and choose "new". You then get the option to add one of the following file types:
|
||||
|
||||
* File
|
||||
* Directory
|
||||
* Python Package
|
||||
* Python File
|
||||
* Jupyter Notebook
|
||||
* HTML File
|
||||
* Stylesheet
|
||||
* JavaScript
|
||||
* TypeScript
|
||||
* CoffeeScript
|
||||
* Gherkin
|
||||
* Data Source
|
||||
|
||||
When you add a file, such as a python file you can start typing into the editor in the right panel.
|
||||
|
||||
The text is all colour coded and has bold text . A vertical line shows the indentation so you can be sure that you are tabbing correctly.
|
||||
|
||||
The editor also includes full intellisense which means as you start typing the names of libraries or recognised commands you can complete the commands by pressing tab.
|
||||
|
||||
### Debugging The Application
|
||||
|
||||
You can debug your application at any point by using the debugging options in the top right corner.
|
||||
|
||||
If you are developing a graphical application then you can simply press the green button to run the application. You can also press shift and F10.
|
||||
|
||||
To debug the application you can either click the button next to the green arrow or press shift and F9.You can place breakpoints in the code so that the program stops on a given line by clicking in the grey margin on the line you wish to break at.
|
||||
|
||||
To make a single step forward you can press F8 which steps over the code. This means it will run the code but it won't step into a function. To step into the function you would press F7\. If you are in a function and want to step out to the calling function press shift and F8.
|
||||
|
||||
At the bottom of the screen whilst you are debugging you will see various windows such as a list of processes and threads, and variables that you are watching the values for.
|
||||
|
||||
As you are stepping through code you can add a watch on a variable so that you can see when the value changes.
|
||||
|
||||
Another great option is to run the code with coverage checker. The programming world has changed a lot during the years and now it is common for developers to perform test-driven development so that every change they make they can check to make sure they haven't broken another part of the system.
|
||||
|
||||
The coverage checker actually helps you to run the program, perform some tests and then when you have finished it will tell you how much of the code was covered as a percentage during your test run.
|
||||
|
||||
There is also a tool for showing the name of a method or class, how many times the items were called, and how long was spent in that particular piece of code.
|
||||
|
||||
### Code Refactoring
|
||||
|
||||
A really powerful feature of PyCharm is the code refactoring option.
|
||||
|
||||
When you start to develop code little marks will appear in the right margin. If you type something which is likely to cause an error or just isn't written well then PyCharm will place a coloured marker.
|
||||
|
||||
Clicking on the coloured marker will tell you the issue and will offer a solution.
|
||||
|
||||
For example, if you have an import statement which imports a library and then don't use anything from that library not only will the code turn grey the marker will state that the library is unused.
|
||||
|
||||
Other errors that will appear are for good coding such as only having one blank line between an import statement and the start of a function. You will also be told when you have created a function that isn't in lowercase.
|
||||
|
||||
You don't have to abide by all of the PyCharm rules. Many of them are just good coding guidelines and are nothing to do with whether the code will run or not.
|
||||
|
||||
The code menu has other refactoring options. For example, you can perform code cleanup and you can inspect a file or project for issues.
|
||||
|
||||
### Summary
|
||||
|
||||
PyCharm is a great editor for developing Python code in Linux and there are two versions available. The community version is for the casual developer whereas the professional environment provides all the tools a developer could need for creating professional software.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.lifewire.com/how-to-install-the-pycharm-python-ide-in-linux-4091033
|
||||
|
||||
作者:[Gary Newell ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.lifewire.com/gary-newell-2180098
|
||||
[1]:https://www.jetbrains.com/
|
||||
[2]:https://www.jetbrains.com/resharper/
|
||||
[3]:https://www.jetbrains.com/pycharm/specials/pycharm/pycharm.html?&gclid=CjwKEAjw34i_BRDH9fbylbDJw1gSJAAvIFqU238G56Bd2sKU9EljVHs1bKKJ8f3nV--Q9knXaifD8xoCRyjw_wcB&gclsrc=aw.ds.ds&dclid=CNOy3qGQoc8CFUJ62wodEywCDg
|
||||
[4]:https://www.lifewire.com/how-to-install-the-pycharm-python-ide-in-linux-4091033
|
||||
[5]:https://github.com/
|
||||
[6]:http://www.linuxhowtos.org/System/cvs_tutorial.htm
|
||||
[7]:https://www.mercurial-scm.org/
|
||||
[8]:https://subversion.apache.org/
|
||||
@@ -1,183 +0,0 @@
|
||||
(翻译中 by runningwater)
|
||||
# 4 Ways to Batch Convert Your PNG to JPG and Vice-Versa
|
||||
|
||||
In computing, Batch processing is the [execution of a series of tasks][11] in a program non-interactively. In this guide will offer you 4 simple ways to batch convert several `.PNG` images to `.JPG` and vice-versa using Linux command-line tools.
|
||||
|
||||
We will use convert command line tool in all the examples, however, you can as well make use of mogrify to achieve this.
|
||||
|
||||
The syntax for using convert is:
|
||||
|
||||
```
|
||||
$ convert input-option input-file output-option output-file
|
||||
|
||||
```
|
||||
|
||||
And for mogrify is:
|
||||
|
||||
```
|
||||
$ mogrify options input-file
|
||||
|
||||
```
|
||||
|
||||
Note: With mogrify, the original image file is replaced with the new image file by default, but it is possible to prevent this, by using certain options that you can find in the man page.
|
||||
|
||||
Below are the various ways to batch convert your all `.PNG` images to `.JPG` format, if you want to convert `.JPG`to `.PNG`, you can modify the commands according to your needs.
|
||||
|
||||
### 1\. Convert PNG to JPG Using ‘ls’ and ‘xargs’ Commands
|
||||
|
||||
The [ls command][10] allows you to list all your png images and xargs make it possible to build and execute a convert command from standard input to convert all `.png` images to `.jpg`.
|
||||
|
||||
```
|
||||
----------- Convert PNG to JPG -----------
|
||||
$ ls -1 *.png | xargs -n 1 bash -c 'convert "$0" "${0%.png}.jpg"'
|
||||
|
||||
----------- Convert JPG to PNG -----------
|
||||
$ ls -1 *.jpg | xargs -n 1 bash -c 'convert "$0" "${0%.jpg}.png"'
|
||||
|
||||
```
|
||||
|
||||
Explanation about the options used in the above command.
|
||||
|
||||
1. `-1` – flag tells ls to list one image per line.
|
||||
2. `-n` – specifies the maximum number of arguments, which is 1 for the case.
|
||||
3. `-c` – instructs bash to run the given command.
|
||||
4. `${0%.png}.jpg` – sets the name of the new converted image, the % sign helps to remove the old file extension.
|
||||
|
||||
[
|
||||

|
||||
][9]
|
||||
|
||||
Convert PNG to JPG Format in Linux
|
||||
|
||||
I used `ls -ltr` command to [list all files by modified date and time][8].
|
||||
|
||||
Similarly, you can use above command to convert all your `.jpg` images to `.png` by tweaking the above command.
|
||||
|
||||
### 2\. Convert PNG to JPG Using GNU ‘Parallel’ Command
|
||||
|
||||
GNU Parallel enables a user to build and execute shell commands from standard input in parallel. Make sure you have GNU Parallel installed on your system, otherwise install it using the appropriate commands below:
|
||||
|
||||
```
|
||||
$ sudo apt-get install parallel [On Debian/Ubuntu systems]
|
||||
$ sudo yum install parallel [On RHEL/CentOS and Fedora]
|
||||
|
||||
```
|
||||
|
||||
Once Parallel utility installed, you can run the following command to convert all `.png` images to `.jpg` format from the standard input.
|
||||
|
||||
```
|
||||
----------- Convert PNG to JPG -----------
|
||||
$ parallel convert '{}' '{.}.jpg' ::: *.png
|
||||
|
||||
----------- Convert JPG to PNG -----------
|
||||
$ parallel convert '{}' '{.}.png' ::: *.jpg
|
||||
|
||||
```
|
||||
|
||||
Where,
|
||||
|
||||
1. `{}` – input line which is a replacement string substituted by a complete line read from the input source.
|
||||
2. `{.}` – input line minus extension.
|
||||
3. `:::` – specifies input source, that is the command line for the example above where *png or *jpg is the argument.
|
||||
|
||||
[
|
||||

|
||||
][7]
|
||||
|
||||
Parallel Command – Converts All PNG Images to JPG Format
|
||||
|
||||
Alternatively, you can as well use [ls][6] and parallel commands together to batch convert all your images as shown:
|
||||
|
||||
```
|
||||
----------- Convert PNG to JPG -----------
|
||||
$ ls -1 *.png | parallel convert '{}' '{.}.jpg'
|
||||
|
||||
----------- Convert JPG to PNG -----------
|
||||
$ ls -1 *.jpg | parallel convert '{}' '{.}.png'
|
||||
|
||||
```
|
||||
|
||||
### 3\. Convert PNG to JPG Using ‘for loop’ Command
|
||||
|
||||
To avoid the hustle of writing a shell script, you can execute a `for loop` from the command line as follows:
|
||||
|
||||
```
|
||||
----------- Convert PNG to JPG -----------
|
||||
$ bash -c 'for image in *.png; do convert "$image" "${image%.png}.jpg"; echo “image $image converted to ${image%.png}.jpg ”; done'
|
||||
|
||||
----------- Convert JPG to PNG -----------
|
||||
$ bash -c 'for image in *.jpg; do convert "$image" "${image%.jpg}.png"; echo “image $image converted to ${image%.jpg}.png ”; done'
|
||||
|
||||
```
|
||||
|
||||
Description of each option used in the above command:
|
||||
|
||||
1. -c allows for execution of the for loop statement in single quotes.
|
||||
2. The image variable is a counter for number of images in the directory.
|
||||
3. For each conversion operation, the [echo command][1] informs the user that a png image has been converted to jpg format and vice-versa in the line $image converted to ${image%.png}.jpg”.
|
||||
4. “${image%.png}.jpg” creates the name of the converted image, where % removes the extension of the old image format.
|
||||
|
||||
[
|
||||

|
||||
][5]
|
||||
|
||||
for loop – Convert PNG to JPG Format
|
||||
|
||||
### 4\. Convert PNG to JPG Using Shell Script
|
||||
|
||||
If you do not want to make your command line dirty as in the previous example, write a small script like so:
|
||||
|
||||
Note: Appropriately interchange the `.png` and `.jpg` extensions as in the example below for conversion from one format to another.
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
#convert
|
||||
for image in *.png; do
|
||||
convert "$image" "${image%.png}.jpg"
|
||||
echo “image $image converted to ${image%.png}.jpg ”
|
||||
done
|
||||
exit 0
|
||||
|
||||
```
|
||||
|
||||
Save it as `convert.sh` and make the script executable and then run it from within the directory that has your images.
|
||||
|
||||
```
|
||||
$ chmod +x convert.sh
|
||||
$ ./convert.sh
|
||||
|
||||
```
|
||||
[
|
||||

|
||||
][4]
|
||||
|
||||
Batch Image Convert Using Shell Script
|
||||
|
||||
In summary, we covered some important ways to batch convert `.png` images to `.jpg` format and vice-versa. If you want to optimize images, you can go through our guide that shows [how to compress png and jpg images in Linux][3].
|
||||
|
||||
You can as well share with us any other methods including [Linux command line tools][2] for converting images from one format to another on the terminal, or ask a question via the comment section below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/linux-image-conversion-tools/
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
|
||||
译者:[runningwater](https://github.com/runningwater)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/echo-command-in-linux/
|
||||
[2]:http://www.tecmint.com/tag/linux-tricks/
|
||||
[3]:http://www.tecmint.com/optimize-and-compress-jpeg-or-png-batch-images-linux-commandline/
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2016/11/Batch-Image-Convert-Using-Shell-Script.png
|
||||
[5]:http://www.tecmint.com/wp-content/uploads/2016/11/Convert-PNG-to-JPG-Using-for-loop-Command.png
|
||||
[6]:http://www.tecmint.com/tag/linux-ls-command/
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2016/11/Convert-PNG-to-JPG-Using-Parallel-Command.png
|
||||
[8]:http://www.tecmint.com/sort-ls-output-by-last-modified-date-and-time/
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2016/11/Convert-PNG-to-JPG-in-Linux.png
|
||||
[10]:http://www.tecmint.com/tag/linux-ls-command/
|
||||
[11]:http://www.tecmint.com/using-shell-script-to-automate-linux-system-maintenance-tasks/
|
||||
@@ -1,234 +0,0 @@
|
||||
@Yinux 翻译中
|
||||
Neofetch – Shows Linux System Information with Distribution Logo
|
||||
============================================================
|
||||
|
||||
Neoftech is a cross-platform and easy-to-use [system information command line script][3] that collects your Linux system information and display it on the terminal next to an image, it could be your distributions logo or any ascii art of your choice.
|
||||
|
||||
Neoftech is very similar to [ScreenFetch][4] or [Linux_Logo][5] utilities, but highly customizable and comes with some extra features as discussed below.
|
||||
|
||||
Its main features include: it’s fast, prints a full color image – your distributions logo in ASCII alongside your system information, it’s highly customizable in terms of which, where and when information is printed on the terminal and it can take a screenshot of your desktop when closing the script as enabled by a special flag.
|
||||
|
||||
#### Required Dependencies:
|
||||
|
||||
1. Bash 3.0+ with ncurses support.
|
||||
2. w3m-img (occasionally packaged with w3m) or iTerm2 or Terminology for printing images.
|
||||
3. [imagemagick][1] – for thumbnail creation.
|
||||
4. [Linux terminal emulator][2] should support \033[14t [3] or xdotool or xwininfo + xprop or xwininfo + xdpyinfo .
|
||||
5. On Linux, you need feh, nitrogen or gsettings for wallpaper support.
|
||||
|
||||
Important: You can read more about optional dependencies from the Neofetch Github repository to check if your [Linux terminal emulator][6] actually supports \033[14t or any extra dependencies for the script to work well on your distro.
|
||||
|
||||
### How To Install Neofetch in Linux
|
||||
|
||||
Neofetch can be easily installed from third-party repositories on almost all Linux distributions by following below respective installation instructions as per your distribution.
|
||||
|
||||
#### On Debian
|
||||
|
||||
```
|
||||
$ echo "deb http://dl.bintray.com/dawidd6/neofetch jessie main" | sudo tee -a /etc/apt/sources.list
|
||||
$ curl -L "https://bintray.com/user/downloadSubjectPublicKey?username=bintray" -o Release-neofetch.key && sudo apt-key add Release-neofetch.key && rm Release-neofetch.key
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get install neofetch
|
||||
```
|
||||
|
||||
#### On Ubuntu and Linux Mint
|
||||
|
||||
```
|
||||
$ sudo add-apt-repository ppa:dawidd0811/neofetch
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get install neofetch
|
||||
```
|
||||
|
||||
#### On RHEL, CentOS and Fedora
|
||||
|
||||
You need to have dnf-plugins-core installed on your system, or else install it with the command below:
|
||||
|
||||
```
|
||||
$ sudo yum install dnf-plugins-core
|
||||
```
|
||||
|
||||
Enable COPR repository and install neofetch package.
|
||||
|
||||
```
|
||||
$ sudo dnf copr enable konimex/neofetch
|
||||
$ sudo dnf install neofetch
|
||||
```
|
||||
|
||||
#### On Arch Linux
|
||||
|
||||
You can either install neofetch or neofetch-git from the AUR using packer or Yaourt.
|
||||
|
||||
```
|
||||
$ packer -S neofetch
|
||||
$ packer -S neofetch-git
|
||||
OR
|
||||
$ yaourt -S neofetch
|
||||
$ yaourt -S neofetch-git
|
||||
```
|
||||
|
||||
#### On Gentoo
|
||||
|
||||
Install app-misc/neofetch from Gentoo/Funtoo’s official repositories. However, in case you need the git version of the package, you can install =app-misc/neofetch-9999.
|
||||
|
||||
### How To Use Neofetch in Linux
|
||||
|
||||
Once you have installed the package, the general syntax for using it is:
|
||||
|
||||
```
|
||||
$ neofetch
|
||||
```
|
||||
|
||||
Note: If w3m-img or [imagemagick][7] is not installed on your system, [screenfetch][8] will be enabled by default and neofetch will display your [ASCII art logo][9] as in the image below.
|
||||
|
||||
#### Linux Mint Information
|
||||
|
||||
[
|
||||

|
||||
][10]
|
||||
|
||||
Linux Mint System Information
|
||||
|
||||
#### Ubuntu Information
|
||||
|
||||
[
|
||||

|
||||
][11]
|
||||
|
||||
Ubuntu System Information
|
||||
|
||||
If you want to display the default distribution logo as image, you should install w3m-img or imagemagickon your system as follows:
|
||||
|
||||
```
|
||||
$ sudo apt-get install w3m-img [On Debian/Ubuntu/Mint]
|
||||
$ sudo yum install w3m-img [On RHEL/CentOS/Fedora]
|
||||
```
|
||||
|
||||
Then run neofetch again, you will see the default wallpaper of your Linux distributions as the image.
|
||||
|
||||
```
|
||||
$ neofetch
|
||||
```
|
||||
[
|
||||

|
||||
][12]
|
||||
|
||||
Ubuntu System Information with Logo
|
||||
|
||||
After running neofetch for the first time, it will create a configuration file with all options and settings: `$HOME/.config/neofetch/config`.
|
||||
|
||||
This configuration file will enable you through the `printinfo ()` function to alter the system information that you want to print on the terminal. You can type in new lines of information, modify the information lineup, delete certain lines and also tweak the script it using bash code to manage the information to be printed out.
|
||||
|
||||
You can open the configuration file using your favorite editor as follows:
|
||||
|
||||
```
|
||||
$ vi ~/.config/neofetch/config
|
||||
```
|
||||
|
||||
Below is an excerpt of the configuration file on my system showing the `printinfo ()` function.
|
||||
|
||||
Neofetch Configuration File
|
||||
```
|
||||
#!/usr/bin/env bash
|
||||
# vim:fdm=marker
|
||||
#
|
||||
# Neofetch config file
|
||||
# https://github.com/dylanaraps/neofetch
|
||||
|
||||
# Speed up script by not using unicode
|
||||
export LC_ALL=C
|
||||
export LANG=C
|
||||
|
||||
# Info Options {{{
|
||||
|
||||
# Info
|
||||
# See this wiki page for more info:
|
||||
# https://github.com/dylanaraps/neofetch/wiki/Customizing-Info
|
||||
printinfo() {
|
||||
info title
|
||||
info underline
|
||||
|
||||
info "Model" model
|
||||
info "OS" distro
|
||||
info "Kernel" kernel
|
||||
info "Uptime" uptime
|
||||
info "Packages" packages
|
||||
info "Shell" shell
|
||||
info "Resolution" resolution
|
||||
info "DE" de
|
||||
info "WM" wm
|
||||
info "WM Theme" wmtheme
|
||||
info "Theme" theme
|
||||
info "Icons" icons
|
||||
info "Terminal" term
|
||||
info "Terminal Font" termfont
|
||||
info "CPU" cpu
|
||||
info "GPU" gpu
|
||||
info "Memory" memory
|
||||
|
||||
# info "CPU Usage" cpu_usage
|
||||
# info "Disk" disk
|
||||
# info "Battery" battery
|
||||
# info "Font" font
|
||||
# info "Song" song
|
||||
# info "Local IP" localip
|
||||
# info "Public IP" publicip
|
||||
# info "Users" users
|
||||
# info "Birthday" birthday
|
||||
|
||||
info linebreak
|
||||
info cols
|
||||
info linebreak
|
||||
}
|
||||
.....
|
||||
```
|
||||
|
||||
Type the command below to view all flags and their configuration values you can use with neofetch script:
|
||||
|
||||
```
|
||||
$ neofetch --help
|
||||
```
|
||||
|
||||
To launch neofetch with all functions and flags enabled, employ the `--test` flag:
|
||||
|
||||
```
|
||||
$ neofetch --test
|
||||
```
|
||||
|
||||
You can enable the ASCII art logo again using the `--ascii` flag:
|
||||
|
||||
```
|
||||
$ neofetch --ascii
|
||||
```
|
||||
|
||||
In this article, we have covered a simple and highly configuration/customizable command line script that gathers your system information and displays it on the terminal.
|
||||
|
||||
Remember to get in touch with us via the feedback form below to ask any questions or give us your thoughts concerning the neofetch script.
|
||||
|
||||
Last but not least, if you know of any similar scripts out there, do not hesitate to let us know, we will be pleased to hear from you.
|
||||
|
||||
Visit the [neofetch Github repository][13].
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/neofetch-shows-linux-system-information-with-logo
|
||||
|
||||
作者:[Aaron Kili ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/install-imagemagick-in-linux/
|
||||
[2]:http://www.tecmint.com/linux-terminal-emulators/
|
||||
[3]:http://www.tecmint.com/screenfetch-system-information-generator-for-linux/
|
||||
[4]:http://www.tecmint.com/screenfetch-system-information-generator-for-linux/
|
||||
[5]:http://www.tecmint.com/linux_logo-tool-to-print-color-ansi-logos-of-linux/
|
||||
[6]:http://www.tecmint.com/linux-terminal-emulators/
|
||||
[7]:http://www.tecmint.com/install-imagemagick-in-linux/
|
||||
[8]:http://www.tecmint.com/screenfetch-system-information-generator-for-linux/
|
||||
[9]:http://www.tecmint.com/linux_logo-tool-to-print-color-ansi-logos-of-linux/
|
||||
[10]:http://www.tecmint.com/wp-content/uploads/2016/11/Linux-Mint-System-Information.png
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2016/11/Ubuntu-System-Information.png
|
||||
[12]:http://www.tecmint.com/wp-content/uploads/2016/11/Ubuntu-System-Information-with-Logo.png
|
||||
[13]:https://github.com/dylanaraps/neofetch
|
||||
@@ -0,0 +1,121 @@
|
||||
Fix “Unable to lock the administration directory (/var/lib/dpkg/)” in Ubuntu
|
||||
============================================================
|
||||
|
||||
While using the [apt-get command][1] or the relatively new [APT package management tool][2] in Ubuntu Linuxor its derivatives such as Linux Mint (which I actually use as my primary operating system for doing daily work), you might have encountered the error – “unable to lock the administration directory (/var/lib/dpkg/) is another process using it” on the command line.
|
||||
|
||||
This error can be so annoying especially for new Linux (Ubuntu) users who may not know exactly the cause of the error.
|
||||
|
||||
Below is an example, showing the lock file error in Ubuntu 16.10:
|
||||
|
||||
```
|
||||
tecmint@TecMint:~$ sudo apt install neofetch
|
||||
[sudo] password for tecmint:
|
||||
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
|
||||
E: Unable to lock the administration directory (/var/lib/dpkg), is another process using it?
|
||||
```
|
||||
|
||||
The output below is another possible instance of the same error:
|
||||
|
||||
```
|
||||
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
|
||||
E: Unable to lock directory /var/lib/apt/lists/
|
||||
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
|
||||
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?
|
||||
```
|
||||
|
||||
How can you solve the above error in case you bump into it in the future? There are several ways of dealing with this error(s), but in this guide, we will go through the two easiest and probably the most effective ways of solving it.
|
||||
|
||||
### 1\. Find and Kill all apt-get or apt Processes
|
||||
|
||||
Run the command below to [generate a list of all processes][3] whose name comprises of the word apt, you will get a list inclusive of all apt or apt-get processes by using `ps` and [grep commands][4] together with a pipeline.
|
||||
|
||||
```
|
||||
$ ps -A | grep apt
|
||||
```
|
||||
[
|
||||

|
||||
][5]
|
||||
|
||||
Find apt and apt-get Processes
|
||||
|
||||
For each apt-get or apt process that you can see in the output of the command above, [kill each process][6]using the command below.
|
||||
|
||||
The process ID (PID) is found in the first column from the screenshot above.
|
||||
|
||||
```
|
||||
$ sudo kill -9 processnumber
|
||||
OR
|
||||
$ sudo kill -SIGKILL processnumber
|
||||
```
|
||||
|
||||
For instance, in the command below where `9` is the signal number for the SIGKILL signal, will kill the first apt process:
|
||||
|
||||
```
|
||||
$ sudo kill -9 13431
|
||||
OR
|
||||
$ sudo kill -SIGKILL 13431
|
||||
```
|
||||
|
||||
### 2\. Delete the lock Files
|
||||
|
||||
A lock file simply prevents access to another file(s) or some data on your Linux system, this concept is present in Windows and other operating systems as well.
|
||||
|
||||
Once you run an apt-get or apt command, a lock file is created under the any of these directories /var/lib/apt/lists/, /var/lib/dpkg/ and /var/cache/apt/archives/.
|
||||
|
||||
This helps to avoid the apt-get or apt process that is already running from being interrupted by either a user or other system processes that would need to work with files being used by apt-get or apt. When the process has finished executing, the lock file is then deleted.
|
||||
|
||||
Important: In case a lock is still exiting in the two directories above with no noticeable apt-get or apt process running, this may mean the process was held for one reason or the other, therefore you need to delete the lock files in order to clear the error.
|
||||
|
||||
First execute the command below to remove the lock file in the `/var/lib/dpkg/` directory:
|
||||
|
||||
```
|
||||
$ sudo rm /var/lib/dpkg/lock
|
||||
```
|
||||
|
||||
Afterwards force package(s) to reconfigure like so:
|
||||
|
||||
```
|
||||
$ sudo dpkg --configure -a
|
||||
```
|
||||
|
||||
Alternatively, delete the lock files in the `/var/lib/apt/lists/` and cache directory as below:
|
||||
|
||||
```
|
||||
$ sudo rm /var/lib/apt/lists/lock
|
||||
$ sudo rm /var/cache/apt/archives/lock
|
||||
```
|
||||
|
||||
Next, update your packages sources list as follows:
|
||||
|
||||
```
|
||||
$ sudo apt update
|
||||
OR
|
||||
$ sudo apt-get update
|
||||
```
|
||||
|
||||
In conclusion, we have walked through two important methods to deal with a common problem faced by Ubuntu (and its derivatives) users, while running apt-get or apt as well as [aptitude commands][7].
|
||||
|
||||
Do you have any other reliable methods to share meant for deal with this common error? Then get in touch with us via the feedback form below.
|
||||
|
||||
In addition, you may as well want to learn [how to find and kill running processes][8] and read through a simple guide to [kill, pkill and killall commands to terminate a process][9] in Linux.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/fix-unable-to-lock-the-administration-directory-var-lib-dpkg-lock
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/useful-basic-commands-of-apt-get-and-apt-cache-for-package-management/
|
||||
[2]:http://www.tecmint.com/apt-advanced-package-command-examples-in-ubuntu/
|
||||
[3]:http://www.tecmint.com/find-linux-processes-memory-ram-cpu-usage/
|
||||
[4]:http://www.tecmint.com/linux-grep-commands-character-classes-bracket-expressions/
|
||||
[5]:http://www.tecmint.com/wp-content/uploads/2016/11/find-apt-processes.png
|
||||
[6]:http://www.tecmint.com/find-and-kill-running-processes-pid-in-linux/
|
||||
[7]:http://www.tecmint.com/difference-between-apt-and-aptitude/
|
||||
[8]:http://www.tecmint.com/find-and-kill-running-processes-pid-in-linux/
|
||||
[9]:http://www.tecmint.com/how-to-kill-a-process-in-linux/
|
||||
@@ -0,0 +1,249 @@
|
||||
Create an Active Directory Infrastructure with Samba4 on Ubuntu – Part 1
|
||||
============================================================
|
||||
|
||||
Samba is a free Open Source software which provides a standard interoperability between Windows OSand Linux/Unix Operating Systems.
|
||||
|
||||
Samba can operate as a standalone file and print server for Windows and Linux clients through the SMB/CIFS protocol suite or can act as an Active Directory Domain Controller or joined into a Realm as a Domain Member. The highest AD DC domain and forest level that currently Samba4 can emulate is Windows 2008 R2.
|
||||
|
||||
The series will be titled Setting Up Samba4 Active Directory Domain Controller, which covers following topics for Ubuntu, CentOS, and Windows:
|
||||
|
||||
Part 1: Install Active Directory Infrastructure with SAMBA4 on UbuntuPart 2: [Manage Samba4 AD Infrastructure from Linux Command Line][4]Part 3: Install RSAT on Windows 10 Client to Manage Samba4 AD InfrastructurePart 4: Joining Samba4 DC to Existing AD Infrastructure with Sysvol ReplicationPart 5: Add a Shared Volume from Linux DC and Map to AD via GPOPart 6: Integrate Ubuntu 16.04 to AD as a Domain MemberPart 7: Integrate CentOS 7 to AD as a Domain MemberPart 8: Create Apache Website with Kerberos Authentication on AD Intranet
|
||||
|
||||
This tutorial will start by explaining all the steps you need to take care off in order to install and configure Samba4 as a Domain Controller on Ubuntu 16.04 and Ubuntu 14.04.
|
||||
|
||||
This configuration will provide a central management point for users, machines, volume shares, permissions and other resources in a mixed-up Windows – Linux infrastructure.
|
||||
|
||||
#### Requirements:
|
||||
|
||||
1. [Ubuntu 16.04 Server Installation][1].
|
||||
2. [Ubuntu 14.04 Server Installation][2].
|
||||
3. [A static IP Address configured][3] for your AD DC server.
|
||||
|
||||
### Step 1: Initial Configuration for Samba4
|
||||
|
||||
1. Before proceeding your Samba4 AD DC installation first let’s run a few pre-required steps. First make sure the system is up to date with the last security features, kernels and packages by issuing the below command:
|
||||
|
||||
```
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get upgrade
|
||||
$ sudo apt-get dist-upgrade
|
||||
```
|
||||
|
||||
2. Next, open machine /etc/fstab file and assure that your partitions file system has ACLs enabled as illustrated on the below screenshot.
|
||||
|
||||
Usually, common modern Linux file systems such as ext3, ext4, xfs or btrfs support and have ACLs enabled by default. If that’s not the case with your file system just open /etc/fstab file for editing and add `acl` string at the end of third column and reboot the machine in order to apply changes.
|
||||
|
||||
[
|
||||

|
||||
][5]
|
||||
|
||||
Enable ACL’s on Linux Filesystem
|
||||
|
||||
3. Finally [setup your machine hostname][6] with a descriptive name, such as `adc1` used in this example, by editing /etc/hostname file or by issuing.
|
||||
|
||||
```
|
||||
$ sudo hostnamectl set-hostname adc1
|
||||
```
|
||||
|
||||
A reboot is necessary after you’ve changed your machine name in order to apply changes.
|
||||
|
||||
### Step 2: Install Required Packages for Samba4 AD DC
|
||||
|
||||
4. In order to transform your server into an Active Directory Domain Controller, install Samba and all the required packages on your machine by issuing the below command with root privileges in a console.
|
||||
|
||||
```
|
||||
$ sudo apt-get install samba krb5-user krb5-config winbind libpam-winbind libnss-winbind
|
||||
```
|
||||
[
|
||||

|
||||
][7]
|
||||
|
||||
Install Samba on Ubuntu
|
||||
|
||||
5. While the installation is running a series of questions will be asked by the installer in order to configure the domain controller.
|
||||
|
||||
On the first screen you will need to add a name for Kerberos default `REALM` in uppercase. Enter the name you will be using for your domain in uppercase and hit Enter to continue..
|
||||
|
||||
[
|
||||

|
||||
][8]
|
||||
|
||||
Configuring Kerberos Authentication
|
||||
|
||||
6. Next, enter the hostname of Kerberos server for your domain. Use the same name as for your domain, with lowercases this time and hit Enter to continue.
|
||||
|
||||
[
|
||||

|
||||
][9]
|
||||
|
||||
Set Hostname Kerberos Server
|
||||
|
||||
7. Finally, specify the hostname for the administrative server of your Kerberos realm. Use the same as your domain and hit Enter to finish the installation.
|
||||
|
||||
[
|
||||

|
||||
][10]
|
||||
|
||||
Set Hostname Administrative Server
|
||||
|
||||
### Step 3: Provision Samba AD DC for Your Domain
|
||||
|
||||
8. Before starting to configure Samba for your domain, first run the below commands in order to stop and disable all samba daemons.
|
||||
|
||||
```
|
||||
$ sudo systemctl stop samba-ad-dc.service smbd.service nmbd.service winbind.service
|
||||
$ sudo systemctl disable samba-ad-dc.service smbd.service nmbd.service winbind.service
|
||||
```
|
||||
|
||||
9. Next, rename or remove samba original configuration. This step is absolutely required before provisioning Samba AD because at the provision time Samba will create a new configuration file from scratch and will throw up some errors in case it finds an old `smb.conf` file.
|
||||
|
||||
```
|
||||
$ sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.initial
|
||||
```
|
||||
|
||||
10. Now, start the domain provisioning interactively by issuing the below command with root privileges and accept the default options that Samba provides you.
|
||||
|
||||
Also, make sure you supply the IP address for a DNS forwarder at your premises (or external) and choose a strong password for Administrator account. If you choose a week password for Administrator account the domain provision will fail.
|
||||
|
||||
```
|
||||
$ sudo samba-tool domain provision --use-rfc2307 –interactive
|
||||
```
|
||||
[
|
||||

|
||||
][11]
|
||||
|
||||
Samba Domain Provisioning
|
||||
|
||||
11. Finally, rename or remove Kerberos main configuration file from /etc directory and replace it using a symlink with Samba newly generated Kerberos file located in /var/lib/samba/private path by issuing the below commands:
|
||||
|
||||
```
|
||||
$ sudo mv /etc/krb6.conf /etc/krb5.conf.initial
|
||||
$ sudo ln –s /var/lib/samba/private/krb5.conf /etc/
|
||||
```
|
||||
[
|
||||

|
||||
][12]
|
||||
|
||||
Create Kerberos Configuration
|
||||
|
||||
12. Start and enable Samba Active Directory Domain Controller daemons.
|
||||
|
||||
```
|
||||
$ sudo systemctl start samba-ad-dc.service
|
||||
$ sudo systemctl status samba-ad-dc.service
|
||||
$ sudo systemctl enable samba-ad-dc.service
|
||||
```
|
||||
[
|
||||

|
||||
][13]
|
||||
|
||||
Enable Samba Active Directory Domain Controller
|
||||
|
||||
13. Next, [use netstat command][14] in order to verify the list of all services required by an Active Directory to run properly.
|
||||
|
||||
```
|
||||
$ sudo netstat –tulpn| egrep ‘smbd|samba’
|
||||
```
|
||||
[
|
||||

|
||||
][15]
|
||||
|
||||
Verify Samba Active Directory
|
||||
|
||||
### Step 4: Final Samba Configurations
|
||||
|
||||
14. At this moment Samba should be fully operational at your premises. The highest domain level Sambais emulating should be Windows AD DC 2008 R2.
|
||||
|
||||
It can be verified with the help of samba-tool utility.
|
||||
|
||||
```
|
||||
$ sudo samba-tool domain level show
|
||||
```
|
||||
[
|
||||

|
||||
][16]
|
||||
|
||||
Verify Samba Domain Level
|
||||
|
||||
15. In order for DNS resolution to work locally, you need to open end edit network interface settings and point the DNS resolution by modifying dns-nameservers statement to the IP Address of your Domain Controller (use 127.0.0.1 for local DNS resolution) and dns-search statement to point to your realm.
|
||||
|
||||
```
|
||||
$ sudo cat /etc/network/interfaces
|
||||
$ sudo cat /etc/resolv.conf
|
||||
```
|
||||
[
|
||||

|
||||
][17]
|
||||
|
||||
Configure DNS for Samba AD
|
||||
|
||||
When finished, reboot your server and take a look at your resolver file to make sure it points back to the right DNS name servers.
|
||||
|
||||
16. Finally, test the DNS resolver by issuing queries and pings against some AD DC crucial records, as in the below excerpt. Replace the domain name accordingly.
|
||||
|
||||
```
|
||||
$ ping –c3 tecmint.lan #Domain Name
|
||||
$ ping –c3 adc1.tecmint.lan #FQDN
|
||||
$ ping –c3 adc1 #Host
|
||||
```
|
||||
[
|
||||

|
||||
][18]
|
||||
|
||||
Check Samba AD DNS Records
|
||||
|
||||
Run following few queries against Samba Active Directory Domain Controller..
|
||||
|
||||
```
|
||||
$ host –t A tecmint.lan
|
||||
$ host –t A adc1.tecmint.lan
|
||||
$ host –t SRV _kerberos._udp.tecmint.lan # UDP Kerberos SRV record
|
||||
$ host -t SRV _ldap._tcp.tecmint.lan # TCP LDAP SRV record
|
||||
```
|
||||
|
||||
17. Also, verify Kerberos authentication by requesting a ticket for the domain administrator account and list the cached ticket. Write the domain name portion with uppercase.
|
||||
|
||||
```
|
||||
$ kinit administrator@TECMINT.LAN
|
||||
$ klist
|
||||
```
|
||||
[
|
||||

|
||||
][19]
|
||||
|
||||
Check Kerberos Authentication on Domain
|
||||
|
||||
That’s all! Now you have a fully operational AD Domain Controller installed in your network and you can start integrate Windows or Linux machines into Samba AD.
|
||||
|
||||
On the next series we’ll cover other Samba AD topics, such as how to manage you’re the domain controller from Samba command line, how to integrate Windows 10 into the domain name and manage Samba AD remotely using RSAT and other important topics.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/install-samba4-active-directory-ubuntu/
|
||||
|
||||
作者:[Matei Cezar ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/cezarmatei/
|
||||
[1]:http://www.tecmint.com/installation-of-ubuntu-16-04-server-edition/
|
||||
[2]:http://www.tecmint.com/ubuntu-14-04-server-installation-guide-and-lamp-setup/
|
||||
[3]:http://www.tecmint.com/set-add-static-ip-address-in-linux/
|
||||
[4]:http://www.tecmint.com/manage-samba4-active-directory-linux-command-line/
|
||||
[5]:http://www.tecmint.com/wp-content/uploads/2016/11/Enable-ACL-on-Linux-Filesystem.png
|
||||
[6]:http://www.tecmint.com/set-hostname-permanently-in-linux/
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2016/11/Install-Samba-on-Ubuntu.png
|
||||
[8]:http://www.tecmint.com/wp-content/uploads/2016/11/Configuring-Kerberos-Authentication.png
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2016/11/Set-Hostname-Kerberos-Server.png
|
||||
[10]:http://www.tecmint.com/wp-content/uploads/2016/11/Set-Hostname-Administrative-Server.png
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2016/11/Samba-Domain-Provisioning.png
|
||||
[12]:http://www.tecmint.com/wp-content/uploads/2016/11/Create-Kerberos-Configuration.png
|
||||
[13]:http://www.tecmint.com/wp-content/uploads/2016/11/Enable-Samba-AD-DC.png
|
||||
[14]:http://www.tecmint.com/20-netstat-commands-for-linux-network-management/
|
||||
[15]:http://www.tecmint.com/wp-content/uploads/2016/11/Verify-Samba-Active-Directory.png
|
||||
[16]:http://www.tecmint.com/wp-content/uploads/2016/11/Verify-Samba-Domain-Level.png
|
||||
[17]:http://www.tecmint.com/wp-content/uploads/2016/11/Configure-DNS-for-Samba-AD.png
|
||||
[18]:http://www.tecmint.com/wp-content/uploads/2016/11/Check-Samba-AD-DNS-Records.png
|
||||
[19]:http://www.tecmint.com/wp-content/uploads/2016/11/Check-Kerberos-Authentication-on-Domain.png
|
||||
94
sources/tech/20161123 How to find a file on a Linux VPS.md
Normal file
94
sources/tech/20161123 How to find a file on a Linux VPS.md
Normal file
@@ -0,0 +1,94 @@
|
||||
How to find a file on a Linux VPS
|
||||
============================================================
|
||||
|
||||

|
||||
|
||||
Using the command line on a Linux machine could be very uncomfortable, especially for the beginners. Without a GUI it is very difficult to navigate through the directories and find the files you need. In this tutorial, we will show you how to find a specific file if you are using [Linux VPS][1].
|
||||
|
||||
The first thing your need to do is to [connect to your Linux VPS via SSH][2]. There are two common ways to search for a file under Linux. The one way is to use the `find` command and the other way is to use the `locate` command. Let’s start with the former.
|
||||
|
||||
### Find command
|
||||
|
||||
The Linux find command allows you to search the directory tree using various search criteria such as name, type, ownership, size etc. This is the basic syntax:
|
||||
|
||||
```
|
||||
# find path expression search-term
|
||||
```
|
||||
|
||||
Here is a brief example on how to use the Linux find command to find a specific file by its name:
|
||||
|
||||
```
|
||||
# find -name test.file
|
||||
```
|
||||
|
||||
The command will search the entire directory tree for a file named `test.file` and will provide you with the location. You can try using a name of a file that actually exists on your Linux VPS.
|
||||
|
||||
Sometimes it may take few minutes for the find command to search the entire directory tree, especially if there are many files and directories on your system. To save a significant amount of time you can specify the searching directory. For example, if you know that the `test.file` is somewhere in the `/var` directory, there is no need to search other directories. Therefore, you can use the command below:
|
||||
|
||||
```
|
||||
# find /var -name test.file
|
||||
```
|
||||
|
||||
There is also an option to search for a file by time, size, ownership, permissions etc. For more information about these options, you can check the Linux find command man page.
|
||||
|
||||
```
|
||||
# man find
|
||||
```
|
||||
|
||||
### Locate command
|
||||
|
||||
In order to be able to use the Linux `locate` command, you need to install it first.
|
||||
|
||||
If you are using an [Ubuntu VPS][3], run the following commands to install locate:
|
||||
|
||||
```
|
||||
# apt-get update
|
||||
# apt-get install mlocate
|
||||
```
|
||||
|
||||
If you are using a [CentOS VPS][4], run the following command to install locate:
|
||||
|
||||
```
|
||||
# yum install mlocate
|
||||
```
|
||||
|
||||
Locate is a faster option to find a file since it searches for the files in a database. To update the search databases run the following command:
|
||||
|
||||
```
|
||||
# updatedb
|
||||
```
|
||||
|
||||
To find files with locate, use the following syntax:
|
||||
|
||||
```
|
||||
# locate test.file
|
||||
```
|
||||
|
||||
Just like with the find command, there are many options to filter the search output. To learn more about this you can check the Linux locate command man page.
|
||||
|
||||
```
|
||||
# man locate
|
||||
```
|
||||
|
||||
* * *
|
||||
|
||||
Of course, you don’t have to do any of this if you use one of our[ Linux VPS hosting][5] services, in which case you can simply ask our expert Linux admins to help you. They are available 24×7 and will take care of your request immediately.
|
||||
|
||||
PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.rosehosting.com/blog/linux-find-file/
|
||||
|
||||
作者:[RoseHosting][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.rosehosting.com/blog/linux-find-file/
|
||||
[1]:https://www.rosehosting.com/
|
||||
[2]:https://www.rosehosting.com/blog/connect-to-your-linux-vps-via-ssh/
|
||||
[3]:https://www.rosehosting.com/ubuntu-vps.html
|
||||
[4]:https://www.rosehosting.com/centos-vps.html
|
||||
[5]:https://www.rosehosting.com/linux-vps-hosting.html
|
||||
@@ -0,0 +1,259 @@
|
||||
Fedora 25 Workstation Installation Guide
|
||||
============================================================
|
||||
|
||||
In this tutorial, we will walk through the steps to install Fedora 25 workstation edition on your machine. This guide contains screen shots taken from every step in the whole installation process, therefore, carefully follow it.
|
||||
|
||||
#### What’s New in Fedora 25 Workstation?
|
||||
|
||||
As expected, this latest version of Fedora comes with multiple bug fixes and changes to the basic components, additionally, it brings new and enhanced software as listed below:
|
||||
|
||||
1. GNOME 3.22 which enables multiple file renaming, redesigned keyboard settings tool and plus several user interface enhancements.
|
||||
2. Replaces X11 system with Wayland for modern graphics hardware.
|
||||
3. Decoding support for the MP3 media format.
|
||||
4. Docker 1.12
|
||||
5. Node.js 6.9.1
|
||||
6. Support for Rust system programming language.
|
||||
7. Numerous versions of Python programming language, that is 2.6, 2.7, 3.3, 3.4 and 3.5.
|
||||
8. GNOME Shell extensions are also no longer checked for compatibility with the current version of the Shell and many more.
|
||||
|
||||
Note: If you already using previous version of Fedora 24, you may consider following much more easier steps to [upgrade Fedora 24 to Fedora 25][3] to avoid a fresh installation process.
|
||||
|
||||
### Installation of Fedora 25 Workstation Edition
|
||||
|
||||
Start by downloading the ISO image from the links below, for the purpose of this tutorial, we will use the 64-bit edition.
|
||||
|
||||
1. [Download Fedora 25 Workstation 64-bit Edition][1]
|
||||
2. [Download Fedora 25 Workstation 32-bit Edition][2]
|
||||
|
||||
After downloading Fedora 25, the first is to create a bootbale media, that is either a DVD or USB drive using the install Linux from USB Device using [Unetbootin and dd Command][4] or any other method of your choice.
|
||||
|
||||
1. After creating bootable media, plug-in and boot into the bootable media (DVD/USB drive), you should be able to see the Fedora Workstation Live 25 start screen below.
|
||||
|
||||
Select “Start Fedora-Workstation-Live 25” option and hit the Enter button.
|
||||
|
||||
[
|
||||

|
||||
][5]
|
||||
|
||||
Fedora 25 Boot Menu
|
||||
|
||||
2. Next, you will be at the login interface below, click on “Live System User” to login as a Live user.
|
||||
|
||||
[
|
||||

|
||||
][6]
|
||||
|
||||
Fedora 25 Live User Login
|
||||
|
||||
3. After logging in, the welcome interface below will appear after a few seconds on the desktop, if you wish to try Fedora before installing it, click on “Try Fedora” otherwise, click on “Install to Hard Disk” to proceed with the fresh installation process.
|
||||
|
||||
[
|
||||

|
||||
][7]
|
||||
|
||||
Fedora 25 Welcome Screen
|
||||
|
||||
4. In the screen below, select the installation language you want to use and click on “Continue” to advance to the installation summary screen.
|
||||
|
||||
[
|
||||

|
||||
][8]
|
||||
|
||||
Select Installation Language Type
|
||||
|
||||
5. The following is a screen shot showing the installation summary screen with default localization and system settings. You need to customize the localization and system settings as per your location and preferences.
|
||||
|
||||
Start with the Keyboard settings. Click on “KEYBOARD” to move into the keyboard layout customization screen.
|
||||
|
||||
[
|
||||

|
||||
][9]
|
||||
|
||||
Fedora 25 Installation Summary
|
||||
|
||||
6. From the interface below, add the keyboard layout you want to use according to the origin of your machine using the `+` sign. After adding it, click on “Done” to get back to the installation summary screen.
|
||||
|
||||
[
|
||||

|
||||
][10]
|
||||
|
||||
Set Keyboard Layout
|
||||
|
||||
7. Next off, click on “TIME & DATE” to adjust your system time and date. Type the region and city to set the timezone or simply select them from the map.
|
||||
|
||||
Note that you can also enable or disable network time from the top right corner. After setting your system time and date, click on “Done” to move back to the installation summary screen.
|
||||
|
||||
[
|
||||

|
||||
][11]
|
||||
|
||||
Set System Timezone
|
||||
|
||||
8. Back at the installation summary screen, click on “NETWORK & HOSTNAME” to set your system network settings and hostname.
|
||||
|
||||
Once you have set the hostname, click on the Apply button to check if the hostname is valid, if that is the case, click on “Done”.
|
||||
|
||||
[
|
||||

|
||||
][12]
|
||||
|
||||
Set Hostname for Fedora 25
|
||||
|
||||
9. At this point, you need to now create the installation space for your system files, at the installation summary screen, click on “INSTALLATION DESTINATION”.
|
||||
|
||||
Choose “I will configure partitioning” under Other Storage Options to perform manual partitioning and click Done to move forward to the manual partitioning interface.
|
||||
|
||||
[
|
||||

|
||||
][13]
|
||||
|
||||
Select Installation Destination Drive
|
||||
|
||||
10. Below is the manual partitioning interface, select “Standard Partition” as the new partitioning scheme for the installation.
|
||||
|
||||
[
|
||||

|
||||
][14]
|
||||
|
||||
Manual Partitioning Selection
|
||||
|
||||
11. Now create a `/root` partition by clicking on the `+` sign to add a new mount point.
|
||||
|
||||
```
|
||||
Mount Point: /root
|
||||
Desired Capacity: set appropriate size( eg 100 GB)
|
||||
```
|
||||
|
||||
After that, click Add mount point to add the just created partition/mount point.
|
||||
|
||||
[
|
||||

|
||||
][15]
|
||||
|
||||
Create New Root Partition
|
||||
|
||||
The interface below shows the settings of the `/root` partition mount point.
|
||||
|
||||
[
|
||||

|
||||
][16]
|
||||
|
||||
Root Partition Settings
|
||||
|
||||
12. Next, create a swap partition by clicking on the `+` sign to add a another mount point, that is the swap area.
|
||||
|
||||
Swap area is a virtual space on your hard disk that temporarily stores data which is not currently being worked on by the CPU from the system RAM.
|
||||
|
||||
```
|
||||
Mount Point: swap
|
||||
Desired Capacity: set appropriate size( eg 4 GB)
|
||||
```
|
||||
|
||||
To add the swap area, click Add mount point.
|
||||
|
||||
[
|
||||

|
||||
][17]
|
||||
|
||||
Create Swap Partition
|
||||
|
||||
[
|
||||

|
||||
][18]
|
||||
|
||||
Swap Partition Settings
|
||||
|
||||
13. Once you have created the `root` partition and `swap` area, click on Done to view the possible changes to be made to your hard disk. Click Accept Changes to permit execution of the various changes.
|
||||
|
||||
[
|
||||

|
||||
][19]
|
||||
|
||||
Accept Partition Changes
|
||||
|
||||
14. Your final installation summary should look similar to this with custom settings. To begin the actual installation of system files, click on “Begin Installation”.
|
||||
|
||||
[
|
||||

|
||||
][20]
|
||||
|
||||
Final Installation Summary
|
||||
|
||||
15. After the installation of system files starts, you can create a regular system user and add a password for the root user from the interface below.
|
||||
|
||||
[
|
||||

|
||||
][21]
|
||||
|
||||
User Configuration Settings
|
||||
|
||||
16. Therefore, click on ROOT PASSWORD to set the root user’s password. As before, click Doneafterwards to move back to the user configuration interface.
|
||||
|
||||
[
|
||||

|
||||
][22]
|
||||
|
||||
Set Root Account Password
|
||||
|
||||
17\. Subsequently click on USER CREATION at the user configuration interface to create a regular system user. You can as well make the regular user a system administrator by marking the option “Make the user administrator”.
|
||||
|
||||
One more time, click Done to continue..
|
||||
|
||||
[
|
||||

|
||||
][23]
|
||||
|
||||
Create System User Account
|
||||
|
||||
18. The installation process will continue for a while, sit back and relax. When it is complete, click on Quitto reboot the system and eject the bootable media you used. Finally, log in into your new Fedora 25 workstation.
|
||||
|
||||
[
|
||||

|
||||
][24]
|
||||
|
||||
Fedora 25 Login Screen
|
||||
|
||||
[
|
||||

|
||||
][25]
|
||||
|
||||
Fedora 25 Workstation Desktop
|
||||
|
||||
That’s all! To ask any question or make comments concerning this guide, use the feedback form below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/fedora-25-installation-guide/
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:https://download.fedoraproject.org/pub/fedora/linux/releases/25/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-25-1.3.iso
|
||||
[2]:https://download.fedoraproject.org/pub/fedora/linux/releases/25/Workstation/i386/iso/Fedora-Workstation-Live-i386-25-1.3.iso
|
||||
[3]:http://www.tecmint.com/upgrade-fedora-24-to-fedora-25-workstation-server/
|
||||
[4]:http://www.tecmint.com/install-linux-from-usb-device/
|
||||
[5]:http://www.tecmint.com/wp-content/uploads/2016/11/Start-Fedora-25.png
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2016/11/Fedora-25-Live-User-Login.png
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2016/11/Fedora-25-Welcome-Screen.png
|
||||
[8]:http://www.tecmint.com/wp-content/uploads/2016/11/Select-Installation-Language-Type.png
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2016/11/Fedora-25-Installation-Summary.png
|
||||
[10]:http://www.tecmint.com/wp-content/uploads/2016/11/Set-Keyboard-Layout.png
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2016/11/Set-System-Timezone.png
|
||||
[12]:http://www.tecmint.com/wp-content/uploads/2016/11/Set-Hostname-Fedora-25.png
|
||||
[13]:http://www.tecmint.com/wp-content/uploads/2016/11/Select-Installation-Destination-Drive.png
|
||||
[14]:http://www.tecmint.com/wp-content/uploads/2016/11/Manual-Partitioning-Selection.png
|
||||
[15]:http://www.tecmint.com/wp-content/uploads/2016/11/Create-New-Root-Partition.png
|
||||
[16]:http://www.tecmint.com/wp-content/uploads/2016/11/Root-Partition-Settings.png
|
||||
[17]:http://www.tecmint.com/wp-content/uploads/2016/11/Create-Swap-Partition.png
|
||||
[18]:http://www.tecmint.com/wp-content/uploads/2016/11/Swap-Partition-Settings.png
|
||||
[19]:http://www.tecmint.com/wp-content/uploads/2016/11/Accept-Partition-Changes.png
|
||||
[20]:http://www.tecmint.com/wp-content/uploads/2016/11/Final-Installation-Summary.png
|
||||
[21]:http://www.tecmint.com/wp-content/uploads/2016/11/User-Configuration-Settings.png
|
||||
[22]:http://www.tecmint.com/wp-content/uploads/2016/11/Set-Root-Account-Password.png
|
||||
[23]:http://www.tecmint.com/wp-content/uploads/2016/11/Create-System-User-Account.png
|
||||
[24]:http://www.tecmint.com/wp-content/uploads/2016/11/Fedora-25-Login-Screen.png
|
||||
[25]:http://www.tecmint.com/wp-content/uploads/2016/11/Fedora-25-Workstation-Desktop.png
|
||||
@@ -0,0 +1,380 @@
|
||||
How to Manage Samba4 AD Infrastructure from Linux Command Line – Part 2
|
||||
============================================================
|
||||
|
||||
This tutorial will cover [some basic daily commands][2] you need to use in order to manage Samba4 AD Domain Controller infrastructure, such as adding, removing, disabling or listing users and groups.
|
||||
|
||||
We’ll also take a look on how to manage domain security policy and how to bind AD users to local PAM authentication in order for AD users to be able to perform local logins on Linux Domain Controller.
|
||||
|
||||
#### Requirements
|
||||
|
||||
1. [Create an AD Infrastructure with Samba4 on Ubuntu 16.04 – Part 1][1]
|
||||
|
||||
### Step 1: Manage Samba AD DC from Command Line
|
||||
|
||||
1. Samba AD DC can be managed through samba-tool command line utility which offers a great interface for administrating your domain.
|
||||
|
||||
With the help of samba-tool interface you can directly manage domain users and groups, domain Group Policy, domain sites, DNS services, domain replication and other critical domain functions.
|
||||
|
||||
To review the entire functionality of samba-tool just type the command with root privileges without any option or parameter.
|
||||
|
||||
```
|
||||
# samba-tool -h
|
||||
```
|
||||
[
|
||||

|
||||
][3]
|
||||
|
||||
samba-tool – Manage Samba Administration Tool
|
||||
|
||||
2. Now, let’s start using samba-tool utility to administer Samba4 Active Directory and manage our users.
|
||||
|
||||
In order to create a user on AD use the following command:
|
||||
|
||||
```
|
||||
# samba-tool user add your_domain_user
|
||||
```
|
||||
|
||||
To add a user with several important fields required by AD, use the following syntax:
|
||||
|
||||
```
|
||||
--------- review all options ---------
|
||||
# samba-tool user add -h
|
||||
# samba-tool user add your_domain_user --given-name=your_name --surname=your_username --mail-address=your_domain_user@tecmint.lan --login-shell=/bin/bash
|
||||
```
|
||||
[
|
||||

|
||||
][4]
|
||||
|
||||
Create User on Samba AD
|
||||
|
||||
3. A listing of all samba AD domain users can be obtained by issuing the following command:
|
||||
|
||||
```
|
||||
# samba-tool user list
|
||||
```
|
||||
[
|
||||

|
||||
][5]
|
||||
|
||||
List Samba AD Users
|
||||
|
||||
4. To delete a samba AD domain user use the below syntax:
|
||||
|
||||
```
|
||||
# samba-tool user delete your_domain_user
|
||||
```
|
||||
|
||||
5. Reset a samba domain user password by executing the below command:
|
||||
|
||||
```
|
||||
# samba-tool user setpassword your_domain_user
|
||||
```
|
||||
|
||||
6. In order to disable or enable an samba AD User account use the below command:
|
||||
|
||||
```
|
||||
# samba-tool user disable your_domain_user
|
||||
# samba-tool user enable your_domain_user
|
||||
```
|
||||
|
||||
7. Likewise, samba groups can be managed with the following command syntax:
|
||||
|
||||
```
|
||||
--------- review all options ---------
|
||||
# samba-tool group add –h
|
||||
# samba-tool group add your_domain_group
|
||||
```
|
||||
|
||||
8. Delete a samba domain group by issuing the below command:
|
||||
|
||||
```
|
||||
# samba-tool group delete your_domain_group
|
||||
```
|
||||
|
||||
9. To display all samba domain groups run the following command:
|
||||
|
||||
```
|
||||
# samba-tool group list
|
||||
```
|
||||
|
||||
10. To list all the samba domain members in a specific group use the command:
|
||||
|
||||
```
|
||||
# samba-tool group listmembers "your_domain group"
|
||||
```
|
||||
[
|
||||

|
||||
][6]
|
||||
|
||||
List Samba Domain Members of Group
|
||||
|
||||
11. Adding/Removing a member from a samba domain group can be done by issuing one of the following commands:
|
||||
|
||||
```
|
||||
# samba-tool group addmembers your_domain_group your_domain_user
|
||||
# samba-tool group remove members your_domain_group your_domain_user
|
||||
```
|
||||
|
||||
12. As mentioned earlier, samba-tool command line interface can also be used to manage your samba domain policy and security.
|
||||
|
||||
To review your samba domain password settings use the below command:
|
||||
|
||||
```
|
||||
# samba-tool domain passwordsettings show
|
||||
```
|
||||
[
|
||||

|
||||
][7]
|
||||
|
||||
Check Samba Domain Password
|
||||
|
||||
13. In order to modify samba domain password policy, such as the password complexity level, password ageing, length, how many old password to remember and other security features required for a Domain Controller use the below screenshot as a guide.
|
||||
|
||||
```
|
||||
---------- List all command options ----------
|
||||
# samba-tool domain passwordsettings -h
|
||||
```
|
||||
[
|
||||

|
||||
][8]
|
||||
|
||||
Manage Samba Domain Password Settings
|
||||
|
||||
Never use the password policy rules as illustrated above on a production environment. The above settings are used just for demonstration purposes.
|
||||
|
||||
### Step 2: Samba Local Authentication Using Active Directory Accounts
|
||||
|
||||
14. By default, AD users cannot perform local logins on the Linux system outside Samba AD DCenvironment.
|
||||
|
||||
In order to login on the system with an Active Directory account you need to make the following changes on your Linux system environment and modify Samba4 AD DC.
|
||||
|
||||
First, open samba main configuration file and add the below lines, if missing, as illustrated on the below screenshot.
|
||||
|
||||
```
|
||||
$ sudo nano /etc/samba/smb.conf
|
||||
```
|
||||
|
||||
Make sure the following statements appear on the configuration file:
|
||||
|
||||
```
|
||||
winbind enum users = yes
|
||||
winbind enum groups = yes
|
||||
```
|
||||
[
|
||||

|
||||
][9]
|
||||
|
||||
Samba Authentication Using Active Directory User Accounts
|
||||
|
||||
15. After you’ve made the changes, use testparm utility to make sure no errors are found on samba configuration file and restart samba daemons by issuing the below command.
|
||||
|
||||
```
|
||||
$ testparm
|
||||
$ sudo systemctl restart samba-ad-dc.service
|
||||
```
|
||||
[
|
||||

|
||||
][10]
|
||||
|
||||
Check Samba Configuration for Errors
|
||||
|
||||
16. Next, we need to modify local PAM configuration files in order for Samba4 Active Directory accounts to be able to authenticate and open a session on the local system and create a home directory for users at first login.
|
||||
|
||||
Use the pam-auth-update command to open PAM configuration prompt and make sure you enable all PAM profiles using `[space]` key as illustrated on the below screenshot.
|
||||
|
||||
When finished hit `[Tab]` key to move to Ok and apply changes.
|
||||
|
||||
```
|
||||
$ sudo pam-auth-update
|
||||
```
|
||||
[
|
||||

|
||||
][11]
|
||||
|
||||
Configure PAM for Samba4 AD
|
||||
|
||||
[
|
||||

|
||||
][12]
|
||||
|
||||
Enable PAM Authentication Module for Samba4 AD Users
|
||||
|
||||
17. Now, open /etc/nsswitch.conf file with a text editor and add winbind statement at the end of the password and group lines as illustrated on the below screenshot.
|
||||
|
||||
```
|
||||
$ sudo vi /etc/nsswitch.conf
|
||||
```
|
||||
[
|
||||

|
||||
][13]
|
||||
|
||||
Add Windbind Service Switch for Samba
|
||||
|
||||
18. Finally, edit /etc/pam.d/common-password file, search for the below line as illustrated on the below screenshot and remove the use_authtok statement.
|
||||
|
||||
This setting assures that Active Directory users can change their password from command line while authenticated in Linux. With this setting on, AD users authenticated locally on Linux cannot change their password from console.
|
||||
|
||||
```
|
||||
password [success=1 default=ignore] pam_winbind.so try_first_pass
|
||||
```
|
||||
[
|
||||

|
||||
][14]
|
||||
|
||||
Allow Samba AD Users to Change Passwords
|
||||
|
||||
Remove use_authtok option each time PAM updates are installed and applied to PAM modules or each time you execute pam-auth-update command.
|
||||
|
||||
19. Samba4 binaries comes with a winbindd daemon built-in and enabled by default.
|
||||
|
||||
For this reason you’re no longer required to separately enable and run winbind daemon provided by winbind package from official Ubuntu repositories.
|
||||
|
||||
In case the old and deprecated winbind service is started on the system make sure you disable it and stop the service by issuing the below commands:
|
||||
|
||||
```
|
||||
$ sudo systemctl disable winbind.service
|
||||
$ sudo systemctl stop winbind.service
|
||||
```
|
||||
|
||||
Although, we no longer need to run old winbind daemon, we still need to install Winbind package from repositories in order to install and use wbinfo tool.
|
||||
|
||||
Wbinfo utility can be used to query Active Directory users and groups from winbindd daemon point of view.
|
||||
|
||||
The following commands illustrates how to query AD users and groups using wbinfo.
|
||||
|
||||
```
|
||||
$ wbinfo -g
|
||||
$ wbinfo -u
|
||||
$ wbinfo -i your_domain_user
|
||||
```
|
||||
[
|
||||

|
||||
][15]
|
||||
|
||||
Check Samba4 AD Information
|
||||
|
||||
[
|
||||

|
||||
][16]
|
||||
|
||||
Check Samba4 AD User Info
|
||||
|
||||
20. Apart from wbinfo utility you can also use getent command line utility to query Active Directory database from Name Service Switch libraries which are represented in /etc/nsswitch.conf file.
|
||||
|
||||
Pipe getent command through a grep filter in order to narrow the results regarding just your AD realm user or group database.
|
||||
|
||||
```
|
||||
# getent passwd | grep TECMINT
|
||||
# getent group | grep TECMINT
|
||||
```
|
||||
[
|
||||

|
||||
][17]
|
||||
|
||||
Get Samba4 AD Details
|
||||
|
||||
### Step 3: Login in Linux with an Active Directory User
|
||||
|
||||
21. In order to authenticate on the system with a Samba4 AD user, just use the AD username parameter after `su -` command.
|
||||
|
||||
At the first login a message will be displayed on the console which notifies you that a home directory has been created on `/home/$DOMAIN/` system path with the mane of your AD username.
|
||||
|
||||
Use id command to display extra information about the authenticated user.
|
||||
|
||||
```
|
||||
# su - your_ad_user
|
||||
$ id
|
||||
$ exit
|
||||
```
|
||||
[
|
||||

|
||||
][18]
|
||||
|
||||
Check Samba4 AD User Authentication on Linux
|
||||
|
||||
22. To change the password for an authenticated AD user type passwd command in console after you have successfully logged into the system.
|
||||
|
||||
```
|
||||
$ su - your_ad_user
|
||||
$ passwd
|
||||
```
|
||||
[
|
||||

|
||||
][19]
|
||||
|
||||
Change Samba4 AD User Password
|
||||
|
||||
23. By default, Active Directory users are not granted with root privileges in order to perform administrative tasks on Linux.
|
||||
|
||||
To grant root powers to an AD user you must add the username to the local sudo group by issuing the below command.
|
||||
|
||||
Make sure you enclose the realm, slash and AD username with single ASCII quotes.
|
||||
|
||||
```
|
||||
# usermod -aG sudo 'DOMAIN\your_domain_user'
|
||||
```
|
||||
|
||||
To test if AD user has root privileges on the local system, login and run a command, such as apt-get update, with sudo permissions.
|
||||
|
||||
```
|
||||
# su - tecmint_user
|
||||
$ sudo apt-get update
|
||||
```
|
||||
[
|
||||

|
||||
][20]
|
||||
|
||||
Grant sudo Permission to Samba4 AD User
|
||||
|
||||
24. In case you want to add root privileges for all accounts of an Active Directory group, edit /etc/sudoers file using visudo command and add the below line after root privileges line, as illustrated on the below screenshot:
|
||||
|
||||
```
|
||||
%DOMAIN\\your_domain\ group ALL=(ALL:ALL) ALL
|
||||
```
|
||||
|
||||
Pay attention to sudoers syntax so you don’t break things out.
|
||||
|
||||
Sudoers file doesn’t handles very well the use of ASCII quotation marks, so make sure you use `%` to denote that you’re referring to a group and use a backslash to escape the first slash after the domain name and another backslash to escape spaces if your group name contains spaces (most of AD built-in groups contain spaces by default). Also, write the realm with uppercases.
|
||||
|
||||
[
|
||||

|
||||
][21]
|
||||
|
||||
Give Sudo Access to All Samba4 AD Users
|
||||
|
||||
That’s all for now! Managing Samba4 AD infrastructure can be also achieved with several tools from Windows environment, such as ADUC, DNS Manager, GPM or other, which can be obtained by installing RSAT package from Microsoft download page.
|
||||
|
||||
To administer Samba4 AD DC through RSAT utilities, it’s absolutely necessary to join the Windows system into Samba4 Active Directory. This will be the subject of our next tutorial, till then stay tuned to TecMint.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/manage-samba4-active-directory-linux-command-line
|
||||
|
||||
作者:[Matei Cezar ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/cezarmatei/
|
||||
[1]:http://www.tecmint.com/install-samba4-active-directory-ubuntu/
|
||||
[2]:http://www.tecmint.com/60-commands-of-linux-a-guide-from-newbies-to-system-administrator/
|
||||
[3]:http://www.tecmint.com/wp-content/uploads/2016/11/Samba-Administration-Tool.png
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2016/11/Create-User-on-Samba-AD.png
|
||||
[5]:http://www.tecmint.com/wp-content/uploads/2016/11/List-Samba-AD-Users.png
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2016/11/List-Samba-Domain-Members-of-Group.png
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2016/11/Check-Samba-Domain-Password.png
|
||||
[8]:http://www.tecmint.com/wp-content/uploads/2016/11/Manage-Samba-Domain-Password-Settings.png
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2016/11/Samba-Authentication-Using-Active-Directory-Accounts.png
|
||||
[10]:http://www.tecmint.com/wp-content/uploads/2016/11/Check-Samba-Configuration-for-Errors.png
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2016/11/PAM-Configuration-for-Samba4-AD.png
|
||||
[12]:http://www.tecmint.com/wp-content/uploads/2016/11/Enable-PAM-Authentication-Module-for-Samba4-AD.png
|
||||
[13]:http://www.tecmint.com/wp-content/uploads/2016/11/Add-Windbind-Service-Switch-for-Samba.png
|
||||
[14]:http://www.tecmint.com/wp-content/uploads/2016/11/Allow-Samba-AD-Users-to-Change-Password.png
|
||||
[15]:http://www.tecmint.com/wp-content/uploads/2016/11/Check-Information-of-Samba4-AD.png
|
||||
[16]:http://www.tecmint.com/wp-content/uploads/2016/11/Check-Samba4-AD-User-Info.png
|
||||
[17]:http://www.tecmint.com/wp-content/uploads/2016/11/Get-Samba4-AD-Details.png
|
||||
[18]:http://www.tecmint.com/wp-content/uploads/2016/11/Check-Samba4-AD-User-Authentication-on-Linux.png
|
||||
[19]:http://www.tecmint.com/wp-content/uploads/2016/11/Change-Samba4-AD-User-Password.png
|
||||
[20]:http://www.tecmint.com/wp-content/uploads/2016/11/Grant-sudo-Permission-to-Samba4-AD-User.png
|
||||
[21]:http://www.tecmint.com/wp-content/uploads/2016/11/Give-Sudo-Access-to-All-Samba4-AD-Users.png
|
||||
@@ -0,0 +1,265 @@
|
||||
How to Install Jenkins Automation Server with Apache on Ubuntu 16.04
|
||||
============================================================
|
||||
|
||||
|
||||
Jenkins is an automation server forked from the Hudson project. Jenkins is a server based application running in a Java servlet container, it has support for many SCM (Source Control Management) software systems including Git, SVN, and Mercurial. Jenkins provides hundreds of plugins to automate your project. Jenkins created by Kohsuke Kawaguchi, first released in 2011 under MIT License, and it's free software.
|
||||
|
||||
In this tutorial, I will show you how to install the latest Jenkins version on Ubuntu Server 16.04\. We will run Jenkins on our own domain name, and we will to install and configure Jenkins to run under the apache web server with the reverse proxy for Jenkins.
|
||||
|
||||
### Prerequisite
|
||||
|
||||
* Ubuntu Server 16.04 - 64bit
|
||||
* Root Privileges
|
||||
|
||||
### Step 1 - Install Java OpenJDK 7
|
||||
|
||||
Jenkins is based on Java, so we need to install Java OpenJDK version 7 on the server. In this step, we will install Java 7 from a PPA repository which we will add first.
|
||||
|
||||
By default, Ubuntu 16.04 ships without the python-software-properties package for managing PPA repositories, so we must install this package first. Install python-software-properties with apt command.
|
||||
|
||||
apt-get install python-software-properties
|
||||
|
||||
Next, add Java PPA repository to the server.
|
||||
|
||||
add-apt-repository ppa:openjdk-r/ppa
|
||||
Just Press ENTER
|
||||
|
||||
Update the Ubuntu repository and install the Java OpenJDK with apt command.
|
||||
|
||||
apt-get update
|
||||
apt-get install openjdk-7-jdk
|
||||
|
||||
Verify the installation by typing the command below:
|
||||
|
||||
java -version
|
||||
|
||||
and you will get the Java version that is installed on the server.
|
||||
|
||||
[
|
||||

|
||||
][9]
|
||||
|
||||
### Step 2 - Install Jenkins
|
||||
|
||||
Jenkins provides an Ubuntu repository for the installation packages and we will install Jenkins from this repository.
|
||||
|
||||
Add Jenkins key and repository to the system with the command below.
|
||||
|
||||
wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
|
||||
echo 'deb https://pkg.jenkins.io/debian-stable binary/' | tee -a /etc/apt/sources.list
|
||||
|
||||
Update the repository and install Jenkins.
|
||||
|
||||
apt-get update
|
||||
apt-get install jenkins
|
||||
|
||||
When the installation is done, start Jenkins with this systemctl command.
|
||||
|
||||
systemctl start jenkins
|
||||
|
||||
Verify that Jenkins is running by checking the default port used by Jenkins (port 8080). I will check it with the netstat command below:
|
||||
|
||||
netstat -plntu
|
||||
|
||||
Jenkins is installed and running on port 8080.
|
||||
|
||||
[
|
||||

|
||||
][10]
|
||||
|
||||
### Step 3 - Install and Configure Apache as Reverse Proxy for Jenkins
|
||||
|
||||
In this tutorial we will run Jenkins behind an apache web server, we will configure apache as the reverse proxy for Jenkins. First I will install apache and enable some require modules, and then I'll create the virtual host file with domain name my.jenkins.id for Jenkins. Please use your own domain name here and replace it in all config files wherever it appears.
|
||||
|
||||
Install apache2 web server from Ubuntu repository.
|
||||
|
||||
apt-get install apache2
|
||||
|
||||
When the installation is done, enable the proxy and proxy_http modules so we can configure apache as frontend server/reverse proxy for Jenkins.
|
||||
|
||||
a2enmod proxy
|
||||
a2enmod proxy_http
|
||||
|
||||
Next, create a new virtual host file in the sites-available directory.
|
||||
|
||||
cd /etc/apache2/sites-available/
|
||||
vim jenkins.conf
|
||||
|
||||
Paste virtual host configuration below.
|
||||
|
||||
```
|
||||
<Virtualhost *:80>
|
||||
ServerName my.jenkins.id
|
||||
ProxyRequests Off
|
||||
ProxyPreserveHost On
|
||||
AllowEncodedSlashes NoDecode
|
||||
|
||||
<Proxy http://localhost:8080/*>
|
||||
Order deny,allow
|
||||
Allow from all
|
||||
</Proxy>
|
||||
|
||||
ProxyPass / http://localhost:8080/ nocanon
|
||||
ProxyPassReverse / http://localhost:8080/
|
||||
ProxyPassReverse / http://my.jenkins.id/
|
||||
</Virtualhost>
|
||||
```
|
||||
|
||||
Save the file. Then activate the Jenkins virtual host with the a2ensite command.
|
||||
|
||||
a2ensite jenkins
|
||||
|
||||
Restart Apache and Jenkins.
|
||||
|
||||
systemctl restart apache2
|
||||
systemctl restart jenkins
|
||||
|
||||
Check that port 80 and 8000 are in use by Jenkins and Apache.
|
||||
|
||||
netstat -plntu
|
||||
|
||||
[
|
||||

|
||||
][11]
|
||||
|
||||
### Step 4 - Configure Jenkins
|
||||
|
||||
Jenkins is running on the domain name 'my.jenkins.id'. Open your web browser and type in the URL. You will get the screen that requests you to enter the initial admin password. A password has been generated by Jenkins already, so we just need to show and copy the results to the password box.
|
||||
|
||||
Show initial admin password Jenkins with cat command.
|
||||
|
||||
cat /var/lib/jenkins/secrets/initialAdminPassword
|
||||
|
||||
a1789d1561bf413c938122c599cf65c9
|
||||
|
||||
[
|
||||

|
||||
][12]
|
||||
|
||||
Paste the results to the screen and click '**Continue**'.
|
||||
|
||||
[
|
||||

|
||||
][13]
|
||||
|
||||
Now we should install some plugins in Jenkins to get a good foundation for later use. Choose '**Install Suggested Plugins**', click on it.
|
||||
|
||||
[
|
||||

|
||||
][14]
|
||||
|
||||
Jenkins plugins installations in progress.
|
||||
|
||||
[
|
||||

|
||||
][15]
|
||||
|
||||
After plugin installation, we have to create a new admin password. Type in your admin username, password, email etc. and click on '**Save and Finish**'.
|
||||
|
||||
[
|
||||

|
||||
][16]
|
||||
|
||||
Click start and start using Jenkins. You will be redirected to the Jenkins admin dashboard.
|
||||
|
||||
[
|
||||

|
||||
][17]
|
||||
|
||||
Jenkins installation and Configuration finished successfully
|
||||
|
||||
[
|
||||

|
||||
][18]
|
||||
|
||||
### Step 5 - Jenkins Security
|
||||
|
||||
From the Jenkins admin dashboard, we need to configure the standard security settings for Jenkins, click on '**Manage Jenkins**' and then '**Configure Global Security**'.
|
||||
|
||||
[
|
||||

|
||||
][19]
|
||||
|
||||
Jenkins provides several authorization methods in the '**Access Control**' section. I select '**Matrix-based Security**' to be able to control all user privileges. Enable the admin user at the box '**User/Group**' and click **add**. Give the admin all privileges by **checking all options**, and give the anonymous just read permissions. Now Click '**Save**'.
|
||||
|
||||
[
|
||||

|
||||
][20]
|
||||
|
||||
You will be redirected to the dashboard, and if there is login option, just type your admin user and password.
|
||||
|
||||
### Step 6 - Testing a simple automation job
|
||||
|
||||
In this section, I just want to test a simple job for the Jenkins server. I will create a simple job for testing Jenkins and to find out the server load with the top command.
|
||||
|
||||
From the Jenkins admin dashboard, click '**Create New Job**'.
|
||||
|
||||
[
|
||||

|
||||
][21]
|
||||
|
||||
Enter the job name, I'll use 'Checking System' here, select '**Freestyle Project**' and click '**OK**'.
|
||||
|
||||
[
|
||||

|
||||
][22]
|
||||
|
||||
Go to the '**Build**' tab. On the '**Add build step**', select the option '**Execute shell**'.
|
||||
|
||||
Type in the command below into the box.
|
||||
|
||||
top -b -n 1 | head -n 5
|
||||
|
||||
Click '**Save**'.
|
||||
|
||||
[
|
||||

|
||||
][23]
|
||||
|
||||
Now you are on the job page of the job 'Project checking system'. Click '**Build Now**' to execute the job 'checking system'.
|
||||
|
||||
After the job has been executed, you will see the '**Build History**', click on the first job to see the results.
|
||||
|
||||
Here are the results from the job executed by Jenkins.
|
||||
|
||||
[
|
||||

|
||||
][24]
|
||||
|
||||
Jenkins installation with Apache web server on Ubuntu 16.04 completed successfully.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/
|
||||
|
||||
作者:[Muhammad Arul ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://twitter.com/howtoforgecom
|
||||
[1]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#prerequisite
|
||||
[2]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-install-java-openjdk-
|
||||
[3]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-install-jenkins
|
||||
[4]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-install-and-configure-apache-as-reverse-proxy-for-jenkins
|
||||
[5]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-configure-jenkins
|
||||
[6]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-jenkins-security
|
||||
[7]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#step-testing-a-simple-automation-job
|
||||
[8]:https://www.howtoforge.com/tutorial/how-to-install-jenkins-with-apache-on-ubuntu-16-04/#reference
|
||||
[9]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/1.png
|
||||
[10]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/2.png
|
||||
[11]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/3.png
|
||||
[12]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/4.png
|
||||
[13]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/5.png
|
||||
[14]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/6.png
|
||||
[15]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/7.png
|
||||
[16]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/8.png
|
||||
[17]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/9.png
|
||||
[18]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/10.png
|
||||
[19]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/11.png
|
||||
[20]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/12.png
|
||||
[21]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/13.png
|
||||
[22]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/14.png
|
||||
[23]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/15.png
|
||||
[24]:https://www.howtoforge.com/images/how-to-install-jenkins-with-apache-on-ubuntu-16-04/big/16.png
|
||||
@@ -0,0 +1,93 @@
|
||||
Find Out All Live Hosts IP Addresses Connected on Network in Linux
|
||||
============================================================
|
||||
|
||||
There are plenty of [network monitoring tools][1] you can find in the Linux ecosystem, that can generate for you a summary of the total number of devices on a network including all their IP addresses and more.
|
||||
|
||||
However, sometimes what you actually need may be a simple command line tool that can provide you the same information by running a single command.
|
||||
|
||||
This tutorial will explain you how to find out all live hosts IP addresses connected to a given network. Here, we will use [Nmap tool to find out all IP addresses][2] of devices connected on a same network.
|
||||
|
||||
The [Nmap][3] (short form for Network Mapper) is an open source, powerful and a very versatile command line tool for exploring networks, [perform security scans, network audit][4] and [finding open ports on remote machine][5] and so much more.
|
||||
|
||||
In case you do not have Nmap installed on your system, run the appropriate command below for your distribution to install it:
|
||||
|
||||
```
|
||||
$ sudo yum install nmap [On RedHat based systems]
|
||||
$ sudo dnf install nmap [On Fedora 22+ versions]
|
||||
$ sudo apt-get install nmap [On Debian/Ubuntu based systems]
|
||||
```
|
||||
|
||||
Once you have Nmap installed, the syntax for using it is:
|
||||
|
||||
```
|
||||
$ nmap [scan type...] options {target specification}
|
||||
```
|
||||
|
||||
Where the argument {target specification}, can be replaced by hostnames, IP addresses, networks and so on.
|
||||
|
||||
Therefore to list the IP addresses of all hosts connected to a given network, first of all identify the network and its subnet mask using the [ifconfig command][6] or [ip command][7] like so:
|
||||
|
||||
```
|
||||
$ ifconfig
|
||||
OR
|
||||
$ ip addr show
|
||||
```
|
||||
[
|
||||

|
||||
][8]
|
||||
|
||||
Find Network Details in Linux
|
||||
|
||||
Next, run the Nmap command below:
|
||||
|
||||
```
|
||||
$ nmap -sn 10.42.0.0/24
|
||||
```
|
||||
[
|
||||

|
||||
][9]
|
||||
|
||||
Find All Live Hosts on Network
|
||||
|
||||
In the command above:
|
||||
|
||||
1. `-sn` – is the type of scan, which means a ping scan. By default, Nmap performs port scanning, but this scan will disable port scanning.
|
||||
2. `10.42.0.0/24` – is the target network, replace it with your actual network.
|
||||
|
||||
For a comprehensive usage information, make an effort to look into Nmap man page:
|
||||
|
||||
```
|
||||
$ man nmap
|
||||
```
|
||||
|
||||
Else, run Nmap without any options and arguments to view a summarized usage information:
|
||||
|
||||
```
|
||||
$ nmap
|
||||
```
|
||||
|
||||
In addition, for those interested in learning security scanning techniques in Linux, you can read through this practical guide to [Nmap in Kali Linux][10].
|
||||
|
||||
Well, that’s it for now, remember to send us your questions or comments through the response form below. You can as well share with us other methods for listing the IP addresses of all devices connected to a given network.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/find-live-hosts-ip-addresses-on-linux-network/
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/command-line-tools-to-monitor-linux-performance/
|
||||
[2]:http://www.tecmint.com/nmap-network-security-scanner-in-kali-linux/
|
||||
[3]:http://www.tecmint.com/nmap-command-examples/
|
||||
[4]:http://www.tecmint.com/audit-network-performance-security-and-troubleshooting-in-linux/
|
||||
[5]:http://www.tecmint.com/find-open-ports-in-linux/
|
||||
[6]:http://www.tecmint.com/ifconfig-command-examples/
|
||||
[7]:http://www.tecmint.com/ip-command-examples/
|
||||
[8]:http://www.tecmint.com/wp-content/uploads/2016/11/Find-Network-Details-in-Linux.png
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2016/11/Find-All-Live-Hosts-on-Network.png
|
||||
[10]:http://www.tecmint.com/nmap-network-security-scanner-in-kali-linux/
|
||||
145
sources/tech/20161128 15 JavaScript frameworks and libraries.md
Normal file
145
sources/tech/20161128 15 JavaScript frameworks and libraries.md
Normal file
@@ -0,0 +1,145 @@
|
||||
(翻译中 by runningwater)
|
||||
15 JavaScript frameworks and libraries
|
||||
============================================================
|
||||

|
||||
|
||||
>Image credits : Photo by Jen Wike Huger
|
||||
|
||||
JavaScript is the future.
|
||||
|
||||
The language is supported by a number of technololgy leaders, one of whom is WordPress's founder Matt Mullenweg, who hinted that [WordPress developers][18]should learn it, clearly sending a message to the WordPress community as to it future importance. The mention was well received. The transition to better technology will enable WordPress to keep up with future challenges.
|
||||
|
||||
JavaScript’s open source stance is also one of the best. Contrary to popular belief, JavaScript is not a project, but a specification with an open standard where the language is evolved and maintained by its core team. [ECMAScript][19], another fancy name of JavaScript, is not open source, but it too has an open standard.
|
||||
|
||||
You can easily see evidence of JavaScript's popularity when you look at both at GitHub. JavaScript is the top programming language when it comes to the[number of repositories][20]. Its prominance is also evident on Livecoding.tv, where members are diligently creating more videos on JavaScript than any other topic. At the time of this writing, the self-dubbed edutainment site hosts [45,919 JavaScript videos][21].
|
||||
|
||||
### Top open source JavaScript frameworks and libraries
|
||||
|
||||
Getting back to the topic, JavaScript is blessed with a large community that thrives on improving the technology. Hundreds of JavaScript frameworks and libraries are available to developers, and the good news is that the best ones are open source. For a JavaScript developer, using the best framework or libraries for rapid development is now a necessity. The current market demands rapid development. Also, reinventing the wheel is not a good idea in the current market. Regardless of whether you are new to JavaScript or an experienced JavaScript developer, using libraries and frameworks improves your work significantly.
|
||||
|
||||
Let’s get started.
|
||||
|
||||
### 1\. Angular.js
|
||||
|
||||
[Angular.js][1] is one of the most popular JavaScript frameworks. It is used by developers to create complex web apps. The idea behind Angular.js is its one-page app model. It also supports MVC architecture. With Angular.js, the developer can use JavaScript code in the front end, literally extending the HTML vocabulary.
|
||||
|
||||
Angular.js has improved a great deal since its inception in 2009\. The current stable version of Angular 1 is 1.5.8/1.2.30\. You can also try out Angular 2, a significant improvement over Angular 1, but this framework is still not yet adopted by developers across the world.
|
||||
|
||||
Angular.js uses data binding as one of the main concepts to get work done. The user interacts with the interface. When the interaction is done, the view is then updated with the new values, which in turn interact with the model and ensure everything is synchronized. The DOM gets updated after the underlying logic is executed in the model.
|
||||
|
||||
### 2\. Backbone.js
|
||||
|
||||
Not everyone intends to build a complex web application. Simpler web application frameworks such as [Backbone.js][2] are a great fit for those learning web app development. Backbone.js is a straightforward framework that makes building simple web apps fun and speedy. Just like Angular.js, Backbone.js also comes with MVC support. Other key features of Backbone.js are routing, RESTful API’s support, proper state management, and much more. You can also use Backbone.js to build single page apps.
|
||||
|
||||
The current stable version is 1.3.3 and is available from [GitHub][22].
|
||||
|
||||
### 3\. D3.js
|
||||
|
||||
[D3.js][3] is an excellent JavaScript library that enables developers to create rich web pages with data manipulation features. D3.js uses SVG, HTML, and CSS to make the magic happen. With D3.js, you can bind data to DOM easily and enable data-driven events. With D3.js, you also can create high-quality data-driven web pages that offer a better understanding of data coupled with great visuals. Check[Hamiltonian Graphs from LCF notation][23], powered by D3.js.
|
||||
|
||||
### 4\. React.js
|
||||
|
||||
[React.js][4] is an interesting JavaScript framework to work with. Unlike other JavaScript frameworks, React.js is ideal for building highly scalable front-end user interfaces. React.js came into existence in 2013 under a BSD license and is growing rapidly thanks to the advantages that it brings to developing complex yet beautiful user interfaces.
|
||||
|
||||
The core idea behind React.js is the virtual DOM. Virtual DOM acts as a mediator between the client-side and the server-side, bringing improved performance. The changes made in the virtual DOM are matched with the server DOM, and only the needed elements are updated, making the process much faster than a traditional UI update.
|
||||
|
||||
You can also use material design with React, enabling you to develop modern web apps with unparalleled performance.
|
||||
|
||||
Check out mittax from Munich, Germany working on React Material-UI in the video below.
|
||||
|
||||
### 6\. jQuery
|
||||
|
||||
[jQuery][5] is a very popular JavaScript library with features such as event handling, animation, and much more. When working on a web project, you don’t want to waste time writing code for simple tasks. jQuery frees you from this with its easy-to-use API. It also works with all the popular web browsers. With jQuery, you can seamlessly control the DOM and also develop an Ajax application, which is in high demand for the last few years. With jQuery, developers don’t have to worry about low-level interactions and can easily develop their web applications faster and easier.
|
||||
|
||||
jQuery also facilitates the separation of HTML and JavaScript code, enabling developers to write clean code with cross-browser compatibility. Moreover, web apps created using jQuery are easily improved and extended in the future.
|
||||
|
||||
### 7\. Ember.js
|
||||
|
||||
[Ember.js][6] is a mix of Angular.js and React.js when it comes to functionality. You can easily see the popularity of Ember.js when observing the support community. New features are added constantly. It works similar to Angular.js when it comes to syncing data. The two-way data exchange ensures that the app is fast and scalable. It also helps developers to create front-end elements.
|
||||
|
||||
When it comes to React.js for similarities, Ember.js provides similar server-side Virtual DOM for better performance and scalability. Ember.js also encourages minimal code writing, offers excellent APIs to work with, and has an excellent community.
|
||||
|
||||
### 8\. Polymer.js
|
||||
|
||||
If you ever thought of creating your own HTML5 elements, you can do so with the help of [Polymer.js][7]. Polymer’s main focus is to provide extended functionality to web developers by giving them the ability to create their own tags. For example, you can create a <my_video> element with its own functionality that is similar to the <video> element in HTML5.
|
||||
|
||||
Polymer was introduced in the year 2013 by Google and is covered under [3-Clause BSD][24].
|
||||
|
||||
### 9\. Three.js
|
||||
|
||||
[Three.js][8] is yet another JavaScript library, with a focus on 3D development. If you are into animation and game development, you can use Three.js to your advantage. Under the hood, Three.js uses WebGL and can easily be used to render 3D objects on the screen. A popular example of the power of Three.js is HexGL, a futuristic racing game.
|
||||
|
||||
### 10\. PhantomJS
|
||||
|
||||
Working with JavaScript can also mean working with different browsers, and, when we talk about browsers, resource management comes into the discussion easily. With [PhantomJS][25], you can monitor the performance of your web app thanks to the headless WebKit provided. The headless WebKit is part of the rendering engine used in Chrome and Safari.
|
||||
|
||||
The entire process is automated, and all you need to is set up your web application using the available APIs.
|
||||
|
||||
### 11\. BabylonJS
|
||||
|
||||
[BabylonJS][9] stands in the territory of Three.js, providing JavaScript APIs to create seamless, powerful 3D web apps. It is open source and is based on JavaScript and the power of WebGL. Creating simple 3D objects such as a sphere is easy and you can do so with just a few lines of code. You can get a good grasp of what the library has to offer by going through its [documentation][10]. The homepage also offers excellent demos for inspiration purposes. Do check them out by visiting the official website.
|
||||
|
||||
### 12\. Boba.js
|
||||
|
||||
Web apps always have one need in common, analytics. If you have struggled to insert analytics into your JavaScript web app, then look to [Boba.js][11]. Boba.js can help you insert analytics into your web app with support for the old ga.js. You can also integrate metrics with Boba.js. The only requirement is jQuery.
|
||||
|
||||
### 13\. Underscore.js
|
||||
|
||||
[Underscore.js][12] is the answer to your blank HTML editor file. When you start a project, feeling lost or doing a series of steps that repeat what you have done in earlier projects is common. To simplify the process of starting a project and to give you a head start, the Underscore.js JavaScript library provides you with a set of functions. For example, you can use your favorite Backbone.js suspenders or with jQuery functions that you use in your projects frequently.
|
||||
|
||||
Functional helpers such as "filter" and "invoke the map" provide you with a good head start so you can dive into your work as quickly as possible. Underscore.js also comes with a suite for easy testing purposes.
|
||||
|
||||
### 14\. Meteor.js
|
||||
|
||||
[Meteor.js][13] is a fast way to get started building JavaScript apps. It is open source in nature and can be used to create apps for desktop, mobile, and the web. Meteor.js is a full-stack framework and enables end-to-end development for multiple platforms. You can create back-end and front-end features with Meteor.js, and also keep tabs on the performance of the application. The community surrounding Meteor.js is huge, so there are frequent feature and bug fix updates. Meteor.js is also modular in nature and can be equipped with amazing APIs.
|
||||
|
||||
### 15\. Knockout.js
|
||||
|
||||
[Knockout.js][14] is clearly the most underrated framework out there. It was developed by [Steve Sanderson][15] as an open source JavaScript Framework and is available under license from MIT. The framework is based on the MVVM design.
|
||||
|
||||
### Notable Mention: Node.js
|
||||
|
||||
[Node.js][16] is a powerful runtime environment for JavaScript. It can be used to build fast, scalable applications with real world data. It is neither a framework nor a library, but a runtime environment that is based on Google Chrome’s JavaScript V8 Engine. You can use Node.js to create diversified JavaScript applications, including single page applications, real-time web applications, and much more. Technically, Node.js supports asynchronous I/O with the help of its event-driven architecture. This approach makes it an excellent choice for developing highly scalable solutions. View [Node.js][17] videos on livecoding.tv.
|
||||
|
||||
### Conclusion
|
||||
|
||||
JavaScript is the lingua franca of the web. It has grown rapidly not only because of what it offers, but also because of the open source community surrounding it. The above-mentioned frameworks and libraries are must-checks for any JavaScript developer. All of them provide some way to explore JavaScript and front-end development. Most of the above-mentioned libraries and frameworks are frequently used on Livecoding.tv by software engineers who are interested in JavaScript and its associated technologies.
|
||||
|
||||
If you have something to add, please comment below and let us know. We are eager to see which framework and library you use for projects and also want to know the reason behind it.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/16/11/15-javascript-frameworks-libraries
|
||||
|
||||
作者:[Dr. Michael J. Garbade ][a]
|
||||
译者:[runningwater](https://github.com/runningwater)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/drmjg
|
||||
[1]:https://opensource.com/article/16/11/www.angularjs.org
|
||||
[2]:https://opensource.com/article/16/11/www.backbone.js
|
||||
[3]:https://opensource.com/article/16/11/www.d3js.org
|
||||
[4]:https://facebook.github.io/react/
|
||||
[5]:http://jquery.com/
|
||||
[6]:http://emberjs.com/
|
||||
[7]:https://www.polymer-project.org/1.0/
|
||||
[8]:https://threejs.org/
|
||||
[9]:http://www.babylonjs.com/
|
||||
[10]:https://doc.babylonjs.com/
|
||||
[11]:http://boba.space150.com/
|
||||
[12]:http://underscorejs.org/
|
||||
[13]:https://www.meteor.com/
|
||||
[14]:http://knockoutjs.com/
|
||||
[15]:http://blog.stevensanderson.com/
|
||||
[16]:https://nodejs.org/en/
|
||||
[17]:https://www.livecoding.tv/learn/node-js/
|
||||
[18]:http://wesbos.com/learn-javascript/
|
||||
[19]:http://stackoverflow.com/questions/5520245/is-javascript-an-open-source-project
|
||||
[20]:https://github.com/blog/2047-language-trends-on-github
|
||||
[21]:https://www.livecoding.tv/learn/javascript/
|
||||
[22]:https://github.com/jashkenas/backbone/
|
||||
[23]:http://christophermanning.org/projects/building-cubic-hamiltonian-graphs-from-lcf-notation
|
||||
[24]:https://en.wikipedia.org/wiki/BSD_licenses#3-clause
|
||||
[25]:https://phantomjs.org/
|
||||
@@ -0,0 +1,143 @@
|
||||
How To Enable Shell Script Debugging Mode in Linux
|
||||
============================================================
|
||||
|
||||
A script is simply a list of commands stored in a file. Instead of running a sequence of commands by typing them one by one all the time on the terminal, a system user can store all of them (commands) in a file and repeatedly invokes the file to re-execute the commands several times.
|
||||
|
||||
While [learning scripting][1] or during the early stages of writing scripts, we normally start by writing small or short scripts with a few lines of commands. And we usually debug such scripts by doing nothing more than looking at their output and ensuring that they work as we intended.
|
||||
|
||||
However, as we begin to write very long and advanced scripts with thousands of lines of commands, for instance scripts that modify system settings, [perform critical backups over networks][2] and many more, we will realize that only looking at the output of a script is not enough to find bugs within a script.
|
||||
|
||||
Therefore, in this shell script debugging in Linux series, we will walk through how to enable shell script debugging, move over to explain the different shell script debugging modes and how to use them in the subsequent series.
|
||||
|
||||
### How To Start A Script
|
||||
|
||||
A script is distinguished from other files by its first line, that contains a `#!` (She-bang – defines the file type) and a path name (path to interpreter) which informs the system that the file is a collection of commands that will be interpreted by the specified program (interpreter).
|
||||
|
||||
Below are examples of the “first lines” in different types of scripts:
|
||||
|
||||
```
|
||||
#!/bin/sh [For sh scripting]
|
||||
#!/bin/bash [For bash scripting]
|
||||
#!/usr/bin/perl [For perl programming]
|
||||
#!/bin/awk -f [For awk scripting]
|
||||
```
|
||||
|
||||
Note: The first line or `#!` can be left out if a script contains only of a set of standard system commands, without any internal shell directives.
|
||||
|
||||
### How To Execute A Shell Script in Linux
|
||||
|
||||
The conventional syntax for invoking a shell script is:
|
||||
|
||||
```
|
||||
$ script_name argument1 ... argumentN
|
||||
```
|
||||
|
||||
Another possible form is by clearly specifying the shell that will execute the script as below:
|
||||
|
||||
```
|
||||
$ shell script_name argument1 ... argumentN
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
$ /bin/bash script_name argument1 ... argumentN [For bash scripting]
|
||||
$ /bin/ksh script_name argument1 ... argumentN [For ksh scripting]
|
||||
$ /bin/sh script_name argument1 ... argumentN [For sh scripting]
|
||||
```
|
||||
|
||||
For scripts that do not have `#!` as the first line and only contain basic system commands such as the one below:
|
||||
|
||||
```
|
||||
#script containing standard system commands
|
||||
cd /home/$USER
|
||||
mkdir tmp
|
||||
echo "tmp directory created under /home/$USER"
|
||||
```
|
||||
|
||||
Simply make it executable and run it as follows:
|
||||
|
||||
```
|
||||
$ chmod +x script_name
|
||||
$ ./script_name
|
||||
```
|
||||
|
||||
### Methods of Enabling Shell Script Debugging Mode
|
||||
|
||||
Below are the primary shell script debugging options:
|
||||
|
||||
1. `-v` (short for verbose) – tells the shell to show all lines in a script while they are read, it activates verbose mode.
|
||||
2. `-n` (short for noexec or no ecxecution) – instructs the shell read all the commands, however doesn’t execute them. This options activates syntax checking mode.
|
||||
3. `-x` (short for xtrace or execution trace) – tells the shell to display all commands and their arguments on the terminal while they are executed. This option enables shell tracing mode.
|
||||
|
||||
#### 1\. Modifying the First Line of a Shell Script
|
||||
|
||||
The first mechanism is by altering the first line of a shell script as below, this will enable debugging of the whole script.
|
||||
|
||||
```
|
||||
#!/bin/sh option(s)
|
||||
```
|
||||
|
||||
In the form above, option can be one or combination of the debugging options above.
|
||||
|
||||
#### 2\. Invoking Shell With Debugging Options
|
||||
|
||||
The second is by invoking the shell with debugging options as follows, this method will also turn on debugging of the entire script.
|
||||
|
||||
```
|
||||
$ shell option(s) script_name argument1 ... argumentN
|
||||
```
|
||||
|
||||
For example:
|
||||
|
||||
```
|
||||
$ /bin/bash option(s) script_name argument1 ... argumentN
|
||||
```
|
||||
|
||||
#### 3\. Using set Shell Built-in Command
|
||||
|
||||
The third method is by using the set built-in command to debug a given section of a shell script such as a function. This mechanism is important, as it allows us to activate debugging at any segment of a shell script.
|
||||
|
||||
We can turn on debugging mode using set command in form below, where option is any of the debugging options.
|
||||
|
||||
```
|
||||
$ set option
|
||||
```
|
||||
|
||||
To enable debugging mode, use:
|
||||
|
||||
```
|
||||
$ set -option
|
||||
```
|
||||
|
||||
To disable debugging mode, use:
|
||||
|
||||
```
|
||||
$ set +option
|
||||
```
|
||||
|
||||
In addition, if we have enabled several debugging modes in different segments of a shell script, we can disable all of them at once like so:
|
||||
|
||||
```
|
||||
$ set -
|
||||
```
|
||||
|
||||
That is it for now with enabling shell script debugging mode. As we have seen, we can either debug an entire shell script or a particular section of a script.
|
||||
|
||||
In the next two episode of this series, we will cover how to use the shell script debugging options to explain verbose, syntax checking and shell tracing debugging modes with examples.
|
||||
|
||||
Importantly, do not forget to ask any questions about this guide or perhaps provide us feedback through the comment section below. Until then, stay connected to Tecmint.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/enable-shell-debug-mode-linux/
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/category/bash-shell/
|
||||
[2]:http://www.tecmint.com/rsync-local-remote-file-synchronization-commands/
|
||||
171
sources/tech/20161128 Managing devices in Linux.md
Normal file
171
sources/tech/20161128 Managing devices in Linux.md
Normal file
@@ -0,0 +1,171 @@
|
||||
Managing devices in Linux
|
||||
============================================================
|
||||
|
||||
>Explore how the /dev directory gives you direct access to your devices in Linux.
|
||||
|
||||

|
||||
|
||||
>Image by :Opensource.com
|
||||
|
||||
There are many interesting features of the Linux directory structure. This month I cover some fascinating aspects of the /dev directory. Before you proceed any further with this article, I suggest that, if you have not already done so, you read my earlier articles, _[Everything is a file][1]_, and _[An introduction to Linux filesystems][2]_, both of which introduce some interesting Linux filesystem concepts. Go ahead—I will wait.
|
||||
|
||||
Great! Welcome back. Now we can proceed with a more detailed exploration of the /dev directory.
|
||||
|
||||
### Device files
|
||||
|
||||
Device files are also known as [device ][3][special files][4]. Device files are employed to provide the operating system and users an interface to the devices that they represent. All Linux device files are located in the /dev directory, which is an integral part of the root (/) filesystem because these device files must be available to the operating system during the boot process.
|
||||
|
||||
One of the most important things to remember about these device files is that they are most definitely not device drivers. They are more accurately described as portals to the device drivers. Data is passed from an application or the operating system to the device file which then passes it to the device driver which then sends it to the physical device. The reverse data path is also used, from the physical device through the device driver, the device file, and then to an application or another device.
|
||||
|
||||
Let's look at the data flow of a typical command to visualize this.
|
||||
|
||||

|
||||
|
||||
Figure 1: Simple data flow for a typical command.</center>
|
||||
|
||||
In Figure 1, above, a simplified data flow is shown for a common command. Issuing the **cat /etc/resolv.conf** command from a GUI terminal emulator such as Konsole or xterm causes the resolv.conf file to be read from the disk with the disk device driver handling the device specific functions such as locating the file on the hard drive and reading it. The data is passed through the device file and then from the command to the device file and device driver for pseudo-terminal 6 where it is displayed in the terminal session.
|
||||
|
||||
Of course, the output of the **cat** command could have been redirected to a file in the following manner, **cat /etc/resolv.conf > /etc/resolv.bak** in order to create a backup of the file. In that case, the data flow on the left side of Figure 1 would remain the same while the data flow on the right would be through the /dev/sda2 device file, the hard drive device driver and then onto the hard drive itself.
|
||||
|
||||
These device files make it very easy to use standard streams (STD/IO) and redirection to access any and every device on a Linux or Unix computer. Simply directing a data stream to a device file sends the data to that device.
|
||||
|
||||
### Classification
|
||||
|
||||
Device files can be classified in at least two ways. The first and most commonly used classification is that of the data stream commonly associated with the device. For example, tty (teletype) and serial devices are considered to be character based because the data stream is transferred and handled one character or byte at a time. Block type devices such as hard drives transfer data in blocks, typically a multiple of 256 bytes.
|
||||
|
||||
If you have not already, go ahead and as a non-root user in a terminal session, change the present working directory (PWD) to /dev and display a long listing. This shows a list of device files with their file permissions and their major and minor identification numbers. For example, the following device files are just a few of the ones in the /dev/directory on my Fedora 24 workstation. They represent disk and tty type devices. Notice the leftmost character of each line in the output. The ones that have a "b" are block type devices and the ones that begin with "c" are character devices.
|
||||
|
||||
```
|
||||
brw-rw---- 1 root disk 8, 0 Nov 7 07:06 sda
|
||||
brw-rw---- 1 root disk 8, 1 Nov 7 07:06 sda1
|
||||
brw-rw---- 1 root disk 8, 16 Nov 7 07:06 sdb
|
||||
brw-rw---- 1 root disk 8, 17 Nov 7 07:06 sdb1
|
||||
brw-rw---- 1 root disk 8, 18 Nov 7 07:06 sdb2
|
||||
crw--w---- 1 root tty 4, 0 Nov 7 07:06 tty0
|
||||
crw--w---- 1 root tty 4, 1 Nov 7 07:07 tty1
|
||||
crw--w---- 1 root tty 4, 10 Nov 7 07:06 tty10
|
||||
crw--w---- 1 root tty 4, 11 Nov 7 07:06 tty11
|
||||
```
|
||||
|
||||
The more detailed and explicit way to identify device files is using the device major and minor numbers. The disk devices have a major number of 8 which designates them as SCSI block devices. Note that all PATA and SATA hard drives have been managed by the SCSI subsystem because the old ATA subsystem was many years ago deemed as not maintainable due to the poor quality of its code. As a result, hard drives that would previously have been designated as "hd[a-z]" are now referred to as "sd[a-z]".
|
||||
|
||||
You can probably infer the pattern of disk drive minor numbers in the small sample shown above. Minor numbers 0, 16, 32 and so on up through 240 are the whole disk numbers. So major/minor 8/16 represents the whole disk /dev/sdb and 8/17 is the device file for the first partition, /dev/sdb1\. Numbers 8/34 would be /dev/sdc2.
|
||||
|
||||
The tty device files in the list above are numbered a bit more simply from tty0 through tty63.
|
||||
|
||||
The [Linux Allocated Devices][5] file at Kernel.org is the official registry of device types and major and minor number allocations. It can help you understand the major/minor numbers for all currently defined devices.
|
||||
|
||||
### Fun with device files
|
||||
|
||||
Let's take a few minutes now and perform a couple fun experiments that will illustrate the power and flexibility of the Linux device files. Most Linux distributions have multiple virtual consoles, 1 through 7, that can be used to login to a local console session with a shell interface. These can be accessed using the key combinations Ctrl-Alt-F1 for console 1, Ctrl-Alt-F2 for console 2, and so on.
|
||||
|
||||
Press Ctrl-Alt-F2 to switch to console 2\. On some distributions, the login information includes the tty device associated with this console, but many do not. It should be tty2 because you are in console 2.
|
||||
|
||||
Log in as a non-root user. Then you can use the who am i command—yes, just like that, with spaces—to determine which tty device is connected to this console.
|
||||
|
||||
Before we actually perform this experiment, look at a listing of the tty2 and tty3 devices in /dev.
|
||||
|
||||
```
|
||||
ls -l /dev/tty[23]
|
||||
```
|
||||
|
||||
There will be a large number of tty devices defined but we do not care about most of them, just the tty2 and tty3 devices. As device files, there is nothing special about them; they are simply character type devices. We will use these devices for this experiment. The tty2 device is attached to virtual console 2 and the tty3 device is attached to virtual console 3.
|
||||
|
||||
Press Ctrl-Alt-F3 to switch to console 3\. Log in again as the same non-root user. Now enter the following command on console 3.
|
||||
|
||||
```
|
||||
echo "Hello world" > /dev/tty2
|
||||
```
|
||||
|
||||
Press Ctrl-Alt-F2 to return to console 2\. The string "Hello world" (without quotes) is displayed in console 2.
|
||||
|
||||
This experiment can also be performed with terminal emulators on the GUI desktop. Terminal sessions on the desktop use pseudo terminal devices in the /dev tree, such as /dev/pts/1\. Open two terminal sessions using Konsole or Xterm. Determine which pseudo-terminals they are connected to and use one to send a message to the other.
|
||||
|
||||
Now continue the experiment by using the cat command to display the /etc/fstab file on a different terminal.
|
||||
|
||||
Another interesting experiment is to print a file directly to the printer using the cat command. Assuming that your printer device is /dev/usb/lp0, and that your printer can print PDF files directly, the following command will print the PDF file test.pdf on your printer.
|
||||
|
||||
```
|
||||
cat test.pdf > /dev/usb/lp0
|
||||
```
|
||||
|
||||
The /dev directory contains some very interesting device files that are portals to hardware that one does not normally think of as a device like a hard drive or display. For one example, system memory—RAM—is not something that is normally considered as a "device," yet /dev/mem is the portal through which direct access to memory can be achieved. The following example had some interesting results.
|
||||
|
||||
```
|
||||
dd if=/dev/mem bs=2048 count=100
|
||||
```
|
||||
|
||||
The **dd** command above provides a bit more control than simply using the **cat**command to dump all of a system's memory. It provides the ability to specify how much data is read from /dev/mem and would also allow me to specify the point at which to start reading data from memory. Although some memory was read, the kernel responded with the following error that I found in /var/log/messages.
|
||||
|
||||
```
|
||||
Nov 14 14:37:31 david kernel: usercopy: kernel memory exposure attempt detected from ffff9f78c0010000 (dma-kmalloc-512) (2048 bytes)
|
||||
```
|
||||
|
||||
What this error means is that the kernel is doing its job by protecting memory that belongs to other processes which is exactly how it should work. So, although you can use /dev/mem to display data stored in RAM memory, access to most memory space is protected and will result in errors. Only that virtual memory which is assigned by the kernel memory manager to the BASH shell running the **dd** command should be accessible without causing an error. Sorry, but you cannot snoop in memory that does not belong to you unless you find a vulnerability to exploit.
|
||||
|
||||
There are some other very interesting device files in /dev. The device files null, zero, random and urandom are not associated with any physical devices.
|
||||
|
||||
For example, the null device /dev/null can be used as a target for the redirection of output from shell commands or programs so that they are not displayed on the terminal. I frequently use this in my BASH scripts to prevent users from being presented with output that might be confusing to them. The /dev/null device can be used to produce a string of null characters. Use the **dd** command as shown below to view some output from the /dev/null device file.
|
||||
|
||||
```
|
||||
# dd if=/dev/null bs=512 count=500 | od -c
|
||||
0+0 records in
|
||||
0+0 records out
|
||||
0 bytes copied, 1.5885e-05 s, 0.0 kB/s
|
||||
0000000
|
||||
```
|
||||
|
||||
Note that there is really no visible output because null characters are nothing. Note the byte count.
|
||||
|
||||
The /dev/random and /dev/urandom devices are also very interesting. As their names imply, they both produce random output—not just numbers but any and all byte combinations. The /dev/urandom device produces deterministic random output and is very fast. That means the output is determined by an algorithm and uses a seed string as a starting point. As a result it is possible, although very difficult, for a hacker to reproduce the output if the original seed is known. Use the command **cat /dev/urandom** to view typical output. You can use Ctrl-c to break out.
|
||||
|
||||
The /dev/random device file produces non-deterministic random output but it produces output more slowly. This output is not determined by an algorithm that is dependent upon the previous number, but is generated in response to keystrokes and mouse movements. This method makes it far more difficult to duplicate a specific series of random numbers. Use the **cat **command to view some of the output from the /dev/random device file. Try moving the mouse to see how it affects the output.
|
||||
|
||||
As its name implies, the /dev/zero device file produces an unending string of zeroes as output. Note that these are Octal zeroes and not the ASCII character zero (0). Use the **dd** command as shown below to view some output from the /dev/zero device file.
|
||||
|
||||
```
|
||||
# dd if=/dev/zero bs=512 count=500 | od -c
|
||||
0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
|
||||
*
|
||||
500+0 records in
|
||||
500+0 records out
|
||||
256000 bytes (256 kB, 250 KiB) copied, 0.00126996 s, 202 MB/s
|
||||
0764000
|
||||
```
|
||||
|
||||
Note that the byte count for this command is non-zero.
|
||||
|
||||
### Creating device files
|
||||
|
||||
In the past, the device files in /dev were all created at installation time, resulting in a directory full of almost every possible device file, even though most would never be used. In the unlikely event that a new device file was needed or one was accidentally deleted and needed to be re-created, the **mknod** program was available to manually create device files. All you had to know was the device major and minor numbers.
|
||||
|
||||
CentOS and RHEL 6 and 7, as well as all versions of Fedora going back to at least as far Fedora 15, use the newer method of creating the device files. All device files are created at boot time. This functionality is possible because the udev device manager detects addition and removal of devices as they occur. This allows for true dynamic plug-n-play functionality while the host is up and running. It also performs the same task at boot time by detecting all devices installed on the system very early in the boot process. [Linux.com][6] has a good [description of udev][7].
|
||||
|
||||
Going back to your listing of the files in /dev, notice the date and time on the files. All of them were created during the last boot. You can verify this using the **uptime**or **last** commands. In my device listing above, all of those files were created at 7:06 AM on November 7, which is the last time I booted the system.
|
||||
|
||||
Of course, the **mknod** command is still available, but the new **MAKEDEV** (yes, in all uppercase—which in my opinion is contrary to the Linux philosophy of using all lowercase command names) command provides an easier interface for creating device files, should the need arise. The MAKEDEV command is not installed by default in current versions of Fedora or CentOS 7; it is installed in CentOS 6\. You can use YUM or DNF to install the MAKEDEV package.
|
||||
|
||||
### Conclusion
|
||||
|
||||
Interestingly enough, it had been a long time since I needed to create a device file. However, just recently I had an interesting situation where one of the device files I typically use was not created and I did have to create it. I have not had any problem with that device since. So a situation caused by a missing device file can still happen and knowing how to deal with it can be important.
|
||||
|
||||
I have not covered many of the myriad different types of device files that you might encounter. That information is available in plenty of detail in the resources cited. I hope I have given you some basic understanding of how these files function and the tools to allow you to explore more on your own.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/16/11/managing-devices-linux
|
||||
|
||||
作者:[David Both][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/dboth
|
||||
[1]:https://opensource.com/life/15/9/everything-is-a-file
|
||||
[2]:https://opensource.com/life/16/10/introduction-linux-filesystems
|
||||
[3]:https://en.wikipedia.org/wiki/Device_file
|
||||
[4]:https://en.wikipedia.org/wiki/Device_file
|
||||
[5]:https://www.kernel.org/doc/Documentation/devices.txt
|
||||
[6]:https://www.linux.com/
|
||||
[7]:https://www.linux.com/news/udev-introduction-device-management-modern-linux-system
|
||||
84
sources/tech/20161128 Mir is not only about Unity8.md
Normal file
84
sources/tech/20161128 Mir is not only about Unity8.md
Normal file
@@ -0,0 +1,84 @@
|
||||
Mir is not only about Unity8
|
||||
============================================================
|
||||
|
||||

|
||||
|
||||
_This is a guest post by Alan Griffiths, Software engineer at Canonical. If you would like to contribute a guest post, please contact ubuntu-devices@canonical.com_
|
||||
|
||||
Mir is a project to support the management applications on the display(s) of a computer. It can be compared to the more familiar X-Windows used on the current Ubuntu desktop (and many others). I’ll discuss some of the motivation for Mir below, but the point of this post is to clarify the relationship between Mir and Unity8.
|
||||
|
||||
Most of the time you hear about Mir it is mentioned alongside Unity8\. This is not surprising as Unity8 is Canonical’s new user interface shell and the thing end-users interact with. Mir “only” makes this possible. Unity8 is currently used on phones and tablets and is also available as a “preview” on the Ubuntu 16.10 desktop.
|
||||
|
||||
Here I want to explain that Mir is available to use without Unity8\. Either for an alternative shell, or as a simpler interface for embedded environments: information kiosks, electronic signage, etc. The evidence for this is proved by the Mir “Abstraction Layer” which provides three important elements:
|
||||
|
||||
1.libmiral.so – a stable interface to Mir providing basic window management;
|
||||
2\. miral-shell – a sample shell offering both “traditional” and “tiling” window management; and,
|
||||
3\. miral-kiosk – a sample “kiosk” offering only basic window management.
|
||||
|
||||
The miral-shell and miral-kiosk sample servers are available from the zesty archive and Kevin Gunn has been [blogging][1] about providing a miral-kiosk based “kiosk” snap on “Voices”. I’ll give a bit more detail about using these examples below, but there is more (including “how to” develop your own alternative Mir server) on [my “voices” blog][2].
|
||||
|
||||
**USING MIR**
|
||||
|
||||
Mir is a set of programming libraries, not an application in its own right. That means it needs applications to use it for anything to happen. There are two ways to use the Mir libraries: as a “client” when writing an application, or as a “server” when implementing a shell. Clients (as with X11) typically use a toolkit rather than using Mir (or X11) directly.
|
||||
|
||||
There’s Mir support available in GTK, Qt and SDL2\. This means that applications using these toolkits should “just work” on Mir when that support is enabled in the toolkit (which is the default in Ubuntu). In addition there’s Xmir: an X11 server that runs on Mir, this allows X based applications to run on Mir servers.
|
||||
|
||||
But a Mir client needs a corresponding Mir server before anything can happen. Over the last development cycle the Mir team has produced MirAL as the recommended way to write Mir servers and a package “miral-examples” by way of demonstration. For zesty, the development version of Ubuntu, you can install from the archive:
|
||||
|
||||
```
|
||||
$ sudo apt install miral-examples mir-graphics-drivers-desktop qtubuntu-desktop
|
||||
```
|
||||
|
||||
_For other platforms you would need to build MirAL this yourself (see An Example Mir Desktop Environment for details)._
|
||||
|
||||
With miral-examples installed you can run a Mir server as a window on your Unity7 desktop and start clients (such as gedit) within it as follows:
|
||||
|
||||
```
|
||||
$ miral-shell&
|
||||
$ miral-run gedit
|
||||
```
|
||||
|
||||
This will give you (very basic) “traditional” desktop window management. Alternatively, you can try “tiling” window management:
|
||||
|
||||
```
|
||||
$ miral-shell --window-manager tiling&
|
||||
$ miral-run qterminal
|
||||
```
|
||||
|
||||
Or the (even more basic) kiosk:
|
||||
|
||||
```
|
||||
$ miral-kiosk&
|
||||
$ miral-run 7kaa
|
||||
```
|
||||
|
||||
None of these Mir servers provide a complete “desktop” with support for a “launcher”, notifications, etc. but they demonstrate the potential to use Mir without Unity8.
|
||||
|
||||
**THE PROBLEM MIR SOLVES**
|
||||
|
||||
The X-Windows system has been, and remains, immensely successful in providing a way to interact with computers. It provides a consistent abstraction across a wide range of hardware and drivers. This underlies many desktop environments and graphical user interface toolkits and lets them work together on an enormous range of computers.
|
||||
|
||||
But it comes from an era when computers were used very differently from now, and there are real concerns today that are hard to meet given the long legacy that X needs to support.
|
||||
In 1980 most computers were big things managed by specialists and connecting them to one another was “bleeding edge”. In that era the cost of developing software was such that any benefit to be gained by one application “listening in” on another was negligible: there were few computers, they were isolated, and the work they did was not open to financial exploitation.
|
||||
|
||||
X-Windows developed in this environment and, through a series of extensions, has adapted to many changes. But it is inherently insecure: any application can find out what happening on the display (and affect it). You can write applications like Xeyes (that tracks the cursor with its “eyes”) or “Tickeys” (that listens to the keyboard to generate typewriter noises). The reality is that any and all applications can track and manipulate almost all of what is happening. That is how X based desktops like Unity7, Gnome, KDE and the rest work.
|
||||
|
||||
The open nature of window management in X-Windows is poorly adapted to a world with millions of computers connected to the Internet, being used for credit card transactions and online banking, and managed by non-experts who willingly install programs from complete strangers. There has been a growing realization that adapting X-Windows to the new requirements of security and graphics performance isn’t feasible.
|
||||
|
||||
There are at least two open source projects aimed at providing a replacement: Mir and Wayland. While some see these as competing, there are a lot of areas where they have common interests: They both need to interact with other software that previously assumed X11, and much of the work needed to introduce support alternatives benefits both projects.
|
||||
|
||||
Canonical’s replacement for X-Windows, Mir, only exposes the information to an application that it needs to have (so no snooping on keystrokes, or tracking the cursor). It can meet the needs of the current age and can exploit modern hardware such as graphics processors.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://insights.ubuntu.com/2016/11/28/mir-is-not-only-about-unity8/
|
||||
|
||||
作者:[ Guest][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://insights.ubuntu.com/author/guest/
|
||||
[1]:http://voices.canonical.com/kevin.gunn/
|
||||
[2]:http://voices.canonical.com/alan.griffiths/
|
||||
@@ -0,0 +1,74 @@
|
||||
Moving with SQL Server to Linux? Move from SQL Server to MySQL as well!
|
||||
============================================================
|
||||
|
||||
### On this page
|
||||
|
||||
1. [To have Control Over the Platform][1]
|
||||
2. [Joining the Crowd][2]
|
||||
3. [Microsoft isn’t Open Sourcing SQL Server’s Code][3]
|
||||
4. [Saving on License Costs][4]
|
||||
5. [Sometimes, the Specific Hardware being Used][5]
|
||||
6. [Support][6]
|
||||
|
||||
Over the recent years, there has been a large number of individuals as well as organizations who are ditching the Windows platform for Linux platform, and this number will continue to grow as more developments in Linux are experienced. Linux has for long been the leader in Web servers as most of the web servers run on Linux, and this could be one of the reasons why the high migration is being experienced.
|
||||
|
||||
The reasons for this migration are as numerous, ranging from more platform stability, reliability, costs, ownership and security among others. As more entities migrate to the Linux platform, so is the migration from MS SQL server database management system, top MySQL, because of interoperability and platform independence of MySQL, as well as low acquisition costs.
|
||||
|
||||
As much as the migration is to be done, the need for it should be necessitated by the business and not just for the mere pleasure of it.As such, a comprehensive feasibility and cost-benefit analysis should be carried out to know the impact that the migration will have on your business, both positive and negative.
|
||||
|
||||
The migration may be based on the following key factors:
|
||||
|
||||
### To have Control Over the Platform
|
||||
|
||||
Unlike in windows where you are not in full control of the releases and fixes, Linux does give you that flexibility to get fixes as and when you require them. This is preferred by developers and security personnel in that they are able to immediately apply a fix when a security threat is identified, unlike in Windows where you can only hope they release the fixes soon.
|
||||
|
||||
### Joining the Crowd
|
||||
|
||||
The Linux platform far outnumbers Windows in the number of servers that are running on it, nearly a quarter of all servers in the world, and the trend is not about to change anytime soon. Many organizations, therefore, do migrate so as to be fully on Linux rather than running two platforms concurrently, which adds up to their operating costs.
|
||||
|
||||
### Microsoft isn’t Open Sourcing SQL Server’s Code
|
||||
|
||||
In as much as Microsoft have announced that their next release of MSSQL server (named Denali) will be a Linux version, that will still not open their source code, meaning that their licenses will still apply, but the release will be run on Linux. This still locks out the many users who would happily take to the release if it was open source.
|
||||
|
||||
This still does not give an alternative to those users who are using Oracle, which is not open source; neither does it to those [using MySQL][7], which is fully open source.
|
||||
|
||||
### Saving on License Costs
|
||||
|
||||
The cost implication of licenses is a huge letdown for many users. Running a MSSQL server on Windows platform has too many licenses involved. You need licenses for:
|
||||
|
||||
* The windows operating system
|
||||
* The MSSQL server
|
||||
* Specific database tools e.g. SQL analytics tools, etc.
|
||||
|
||||
Unlike in Windows platform, Linux eliminates the issues of high licenses costs, and thus more appealing to users. MySQL database is also a free source even though it offers the flexibility just as MSSQL server, thus it is more preferred. Most of the database utility tools for MySQL are mostly free, unlike for MSSQL.
|
||||
|
||||
### Sometimes, the Specific Hardware being Used
|
||||
|
||||
Because Linux is developed and always being enhanced by various developers, it is independent of the hardware it operates on and thus widely used on different hardware platforms. However, as much as Microsoft has tried to ensure that Windows and MSSQL server are hardware independent; there are still some limitations in platform independence.
|
||||
|
||||
### Support
|
||||
|
||||
With Linux and MySQL, as well as with other open source software, it is easier to get support on the specific need that you have, because there are various developers involved in their development. These developers maybe within your locality, thus are easily reached. Also, online forums are of great help whereby you are able to post and discuss the issues you face.
|
||||
|
||||
For commercial software, you get support based on their software agreement with you and their timing, and at times may not give you a solution within the timelines that you have.
|
||||
|
||||
In every case, migrating to Linux gives you the best option and outcome that you can have, by joining a radical, stable and reliable platform, which is known to be more robust than Windows. It is worth a shot.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/moving-with-sql-server-to-linux-move-from-sql-server-to-mysql-as-well/
|
||||
|
||||
作者:[Tony Branson ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://twitter.com/howtoforgecom
|
||||
[1]:https://www.howtoforge.com/tutorial/moving-with-sql-server-to-linux-move-from-sql-server-to-mysql-as-well/#to-have-control-over-the-platform
|
||||
[2]:https://www.howtoforge.com/tutorial/moving-with-sql-server-to-linux-move-from-sql-server-to-mysql-as-well/#joining-the-crowd
|
||||
[3]:https://www.howtoforge.com/tutorial/moving-with-sql-server-to-linux-move-from-sql-server-to-mysql-as-well/#microsoft-isnrsquot-open-sourcing-sql-serverrsquos-code
|
||||
[4]:https://www.howtoforge.com/tutorial/moving-with-sql-server-to-linux-move-from-sql-server-to-mysql-as-well/#saving-on-license-costs
|
||||
[5]:https://www.howtoforge.com/tutorial/moving-with-sql-server-to-linux-move-from-sql-server-to-mysql-as-well/#sometimes-the-specific-hardware-being-used
|
||||
[6]:https://www.howtoforge.com/tutorial/moving-with-sql-server-to-linux-move-from-sql-server-to-mysql-as-well/#support
|
||||
[7]:http://www.scalearc.com/how-it-works/products/scalearc-for-mysql
|
||||
@@ -0,0 +1,109 @@
|
||||
Uncommon but useful GCC command line options
|
||||
============================================================
|
||||
|
||||
### On this page
|
||||
|
||||
1. [See intermediate output during each compilation stage][1]
|
||||
2. [Make your code debugging and profiling ready][2]
|
||||
3. [Conclusion][3]
|
||||
|
||||
Software tools usually offer multiple features, but - as most of you will agree - not all their features are used by everyone. Generally speaking, there's nothing wrong in that, as each user has their own requirement and they use the tools within that sphere only. However, it's always good to keep exploring the tools you use as you never know when one of their features might come in handy, saving you some of your precious time in the process.
|
||||
|
||||
Case in point: compilers. A good programming language compiler always offers plethora of options, but users generally know and use a limited set only. Specifically, if you are C language developer and use Linux as your development platform, it's highly likely that you'd using the gcc compiler, which offers an endless list of command line options.
|
||||
|
||||
Do you know that if you want, you can ask gcc to save the output at each stage of the compilation process? Do you know the -Wall option that you use for generating warnings doesn't cover some specific warnings? There are many command line gcc options that are not commonly used, but can be extremely useful in certain scenarios, for example, while debugging the code.
|
||||
|
||||
So, in this article, we will cover a couple of such options, offering all the required details, and explaining them through easy to understand examples wherever necessary.
|
||||
|
||||
But before we move ahead, please keep in mind that all the examples, command, and instructions mentioned in this tutorial have been tested on Ubuntu 16.04 LTS, and the gcc version that we've used is 5.4.0.
|
||||
|
||||
### See intermediate output during each compilation stage
|
||||
|
||||
Do you know there are, broadly, a total of four stages that your C code goes through when you compile it using the gcc compiler? These are preprocessing, compilation, assembly, and linking. After each stage, gcc produces a temporary output file which is handed over to the next stage. Now, these are all temporary files that are produced, and hence we don't get to see them - all we see is that we've issued the compilation command and it produces the binary/executable that we can run.
|
||||
|
||||
But suppose, if while debugging, there's a requirement to see how the code looked after, say, the preprocessing stage. Then, what would you do? Well, the good thing is that the gcc compiler offers a command line option that you can use in your standard compilation command and you'll get those intermediate files that are deleted by the compiler otherwise. The option we're talking about is -save-temps.
|
||||
|
||||
Here's what the [gcc man page][4] says about this option:
|
||||
|
||||
```
|
||||
Store the usual "temporary" intermediate files permanently; place
|
||||
them in the current directory and name them based on the source
|
||||
file. Thus, compiling foo.c with -c -save-temps produces files
|
||||
foo.i and foo.s, as well as foo.o. This creates a preprocessed
|
||||
foo.i output file even though the compiler now normally uses an
|
||||
integrated preprocessor.
|
||||
|
||||
When used in combination with the -x command-line option,
|
||||
-save-temps is sensible enough to avoid over writing an input
|
||||
source file with the same extension as an intermediate file. The
|
||||
corresponding intermediate file may be obtained by renaming the
|
||||
source file before using -save-temps.
|
||||
```
|
||||
|
||||
Following is an example command that'll give you an idea on how you can use this option:
|
||||
|
||||
gcc -Wall **-save-temps** test.c -o test-exec
|
||||
|
||||
And this is how I verified that all the intermediate files were indeed produced after the above mentioned command was executed:
|
||||
|
||||
[
|
||||

|
||||
][5]
|
||||
|
||||
So as you can see in the screenshot above, the test.i, test.s, and test.o files were produced by the -save-temps option. These files correspond to the preprocessing, compiling, and linking stages, respectively.
|
||||
|
||||
### Make your code debugging and profiling ready
|
||||
|
||||
There are dedicated tools that let you debug and profile your source code. For example, [gdb][6] is used for debugging purposes, while [gprof][7] is a popular tool for profiling purposes. But do you know there are specific command line options that gcc offers in order to make your code debugging as well profiling ready?
|
||||
|
||||
Let us start with debugging. To be able to use gdb for code debugging, you'll have to compile your code using the -g command line option provided the gcc compiler. This option basically allows gcc to produce debugging information that's required by gdb to successfully debug your program.
|
||||
|
||||
In case you plan to use this option, you are advised to go through the details the [gcc man page][8] offers on this option - some of that can prove to be vital in some cases. For example, following is an excerpt taken from the man page:
|
||||
|
||||
```
|
||||
GCC allows you to use -g with -O. The shortcuts taken by optimized
|
||||
code may occasionally produce surprising results: some variables
|
||||
you declared may not exist at all; flow of control may briefly move
|
||||
where you did not expect it; some statements may not be executed
|
||||
because they compute constant results or their values are already
|
||||
at hand; some statements may execute in different places because
|
||||
they have been moved out of loops.
|
||||
|
||||
Nevertheless it proves possible to debug optimized output. This
|
||||
makes it reasonable to use the optimizer for programs that might
|
||||
have bugs.
|
||||
```
|
||||
|
||||
Not only gdb, compiling your code using the -g option also opens up the possibility of using Valgrind's memcheck tool to its complete potential. For those who aren't aware, memcheck is used by programmers to check for memory leaks (if any) in their code. You can learn more about this tool [here][9].
|
||||
|
||||
Moving on, to be able to use gprof for code profiling, you have to compile your code using the -pg command line option. It allows gcc to generate extra code to write profiling information, which is required by gprof for code analysis. "You must use this option when compiling the source files you want data about, and you must also use it when linking," the [gcc man page][10] says. To learn more about how to perform code profiling using gprof, head to this [dedicated tutorial][11] on our website.
|
||||
|
||||
**Note**: Usage of both -g and -pg options is similar to the way the -save-temps option was used in the previous section.
|
||||
|
||||
### Conclusion
|
||||
|
||||
Unless you are a gcc pro, I am sure you learned something new with this article. Do give these options a try, and see how they work. Meanwhile, wait for the [next part][12] in this tutorial series where-in we'll discuss more such interesting and useful gcc command line options.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/uncommon-but-useful-gcc-command-line-options/
|
||||
|
||||
作者:[ Ansh][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://twitter.com/howtoforgecom
|
||||
[1]:https://www.howtoforge.com/tutorial/uncommon-but-useful-gcc-command-line-options/#see-intermediate-output-during-each-compilation-stage
|
||||
[2]:https://www.howtoforge.com/tutorial/uncommon-but-useful-gcc-command-line-options/#make-your-code-debugging-and-profiling-ready
|
||||
[3]:https://www.howtoforge.com/tutorial/uncommon-but-useful-gcc-command-line-options/#conclusion
|
||||
[4]:https://linux.die.net/man/1/gcc
|
||||
[5]:https://www.howtoforge.com/images/uncommon-but-useful-gcc-command-line-options/big/gcc-save-temps.png
|
||||
[6]:https://www.gnu.org/software/gdb/
|
||||
[7]:https://sourceware.org/binutils/docs/gprof/
|
||||
[8]:https://linux.die.net/man/1/gcc
|
||||
[9]:http://valgrind.org/docs/manual/mc-manual.html
|
||||
[10]:https://linux.die.net/man/1/gcc
|
||||
[11]:https://www.howtoforge.com/tutorial/how-to-install-and-use-profiling-tool-gprof/
|
||||
[12]:https://www.howtoforge.com/tutorial/uncommon-but-useful-gcc-command-line-options-2/
|
||||
@@ -0,0 +1,95 @@
|
||||
Install Security Patches or Updates Automatically on CentOS and RHEL
|
||||
============================================================
|
||||
|
||||
One of the serious needs of a Linux system is to be kept up to date regularly with the latest security patches or updates available for the corresponding distribution.
|
||||
|
||||
In a previous article, we’ve explained how to [configure automatic security update in Debian/Ubuntu][1], in this article we will explain how to set up your CentOS/RHEL 7/6 distribution to auto update essential security packages when needed.
|
||||
|
||||
Other Linux distributions in the same families (Fedora or Scientific Linux) can be configured similarly.
|
||||
|
||||
### Configure Automatic Security Updates on CentOS/RHEL Systems
|
||||
|
||||
On CentOS/RHEL 7/6, you will need to install the following package:
|
||||
|
||||
```
|
||||
# yum update -y && yum install yum-cron -y
|
||||
```
|
||||
|
||||
#### Enable Automatic Security Updates on CentOS/RHEL 7
|
||||
|
||||
Once the installation is complete, open /etc/yum/yum-cron.conf and locate these lines – you will have to make sure that the values matches those listed here:
|
||||
|
||||
```
|
||||
update_cmd = security
|
||||
update_messages = yes
|
||||
download_updates = yes
|
||||
apply_updates = yes
|
||||
```
|
||||
|
||||
The first line indicates that the unattended update command will be:
|
||||
|
||||
```
|
||||
# yum --security upgrade
|
||||
```
|
||||
|
||||
whereas the other lines enable notifications and automatic download and installation of security upgrades.
|
||||
|
||||
The following lines are also required to indicate that notifications will be sent via email from root@localhost to the same account (again, you may choose another one if you want).
|
||||
|
||||
```
|
||||
emit_via = email
|
||||
email_from = root@localhost
|
||||
email_to = root
|
||||
```
|
||||
|
||||
#### Enable Automatic Security Updates on CentOS/RHEL 6
|
||||
|
||||
By default, the cron is configured to download and install all updates immediately, but we can change this behavior in /etc/sysconfig/yum-cron configuration file by modifying these two parameters to `yes`.
|
||||
|
||||
```
|
||||
# Don't install, just check (valid: yes|no)
|
||||
CHECK_ONLY=yes
|
||||
# Don't install, just check and download (valid: yes|no)
|
||||
# Implies CHECK_ONLY=yes (gotta check first to see what to download)
|
||||
DOWNLOAD_ONLY=yes
|
||||
```
|
||||
|
||||
To enable email notification that about the security package updates, set the MAILTO parameter to a valid mail address.
|
||||
|
||||
```
|
||||
# by default MAILTO is unset, so crond mails the output by itself
|
||||
# example: MAILTO=root
|
||||
MAILTO=admin@tecmint.com
|
||||
```
|
||||
|
||||
Finally, start and enable the yum-cron service:
|
||||
|
||||
```
|
||||
------------- On CentOS/RHEL 7 -------------
|
||||
systemctl start yum-cron
|
||||
systemctl enable yum-cron
|
||||
------------- On CentOS/RHEL 6 -------------
|
||||
# service yum-cron start
|
||||
# chkconfig --level 35 yum-cron on
|
||||
```
|
||||
|
||||
Congrats! You have successfully set up unattended upgrades on CentOS/RHEL 7/6.
|
||||
|
||||
##### Summary
|
||||
|
||||
In this article we have discussed how to keep your server updated regularly with the latest security patches or updates. Additionally, you learned how to configure email notifications in order to keep yourself updated when new patches are applied.
|
||||
|
||||
If you have any concerns about this article? Feel free to drop us a note using the comment form below. We look forward to hearing from you.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/auto-install-security-patches-updates-on-centos-rhel/
|
||||
|
||||
作者:[Gabriel Cánepa][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/gacanepa/
|
||||
[1]:http://www.tecmint.com/auto-install-security-updates-on-debian-and-ubuntu/
|
||||
97
sources/tech/20161130 Locking Down Your Linux Server.md
Normal file
97
sources/tech/20161130 Locking Down Your Linux Server.md
Normal file
@@ -0,0 +1,97 @@
|
||||
Locking Down Your Linux Server
|
||||
============================================================
|
||||
|
||||
> By: Steven J. Vaughan-Nichols
|
||||
|
||||

|
||||
|
||||
### No matter what your Linux, you need to protect it with an iptables-based firewall.
|
||||
|
||||
Yes! You’ve just set up your first Linux server and you’re ready to rock and roll! Right? Uh, no.
|
||||
|
||||
By default, your Linux box is not secure against attackers. Oh sure, it’s more secure than Windows XP, but that’s not saying much.
|
||||
|
||||
To really nail down your Linux system you need to follow the instructions in [Linode][1]’s [Securing your Server][2] guide.
|
||||
|
||||
To summarize, you must — first — turn off the services you don’t need. Of course to do that, you need to know what network services you’re running in the first place.
|
||||
|
||||
You can find out what those are with the shell command:
|
||||
|
||||
_netstat -tulpn_
|
||||
|
||||
[_Netstat_][3] will tell you what services you’re running and what ports they’re using. If you don’t need a particular service or port, you should turn it off. For example, unless you’re running a website, you don’t need to be running the [Apache][4] or [Nginx][5] web servers or have the 80 or 8080 ports open.
|
||||
|
||||
In short, when in doubt, turn it off or close it down.
|
||||
|
||||
On a plain vanilla Linux server, with nothing extra, you’ll see [SSH][6], [RPC][7], and [NTPdate][8] up and running with open ports. Do not add such old and insecure shell programs as [telnet][9] or the hackers will rise up and slap your server right out of your control. Yeah, maybe you loved telnet back on your SunOS box in the 80s, but that was then and this is now.
|
||||
|
||||
As for SSH, be sure to lock it down with [RSA keys][10] and [Fail2Ban][11]. Unless you need RPC — and if you need it, you’ll know — go ahead and uninstall it.
|
||||
|
||||
So much for closing your doors; let’s talk about using iptables to lock them from intruders.
|
||||
|
||||
When you start your Linux server it has no — nada — rules. That means all traffic is allowed. This is NOT GOOD. So, you need to setup your firewall … as soon as possible!
|
||||
|
||||
Iptables is a shell utility that sets network rule policies for [netfilter][12], Linux’s default firewall, using a set of rules to allow or block traffic. When someone tries to connect with your system — and someone will every day, without fail — iptables looks to match the request with its rules list. If it can’t find a match, it will resort to whatever the default action is.
|
||||
|
||||
That action should be to “Drop” the connection, which will block those outsiders wanting in. But it won’t let them know what happened to their attempts to knock on your server’s network door. (You could also “Reject” the connection, but that let’s them know you have a Linux firewall up and running. These days, the less information a stranger has about my system, the better. At least, that’s my philosophy.)
|
||||
|
||||
Now, you could set up your firewall with _just_ iptables. I’ve done it. But then, I used to ride a bike to work six miles away, uphill both directions. These days, I drive.
|
||||
|
||||
That means I use [FirewallD][13] for the Fedora distributions and [UFW][14][Uncomplicated Firewall] for the Debian family. These are easy-to-use, shell front-ends to iptables. For the finer details on how use either, see these Linode guides: [FirewallD][15] and [UFW][16].
|
||||
|
||||
Both come with default rule sets that, in essence, put up “No Trespassing” signs around your server. Use them.
|
||||
|
||||
But don’t get too excited about shutting down all your connections. For example:
|
||||
|
||||
_sudo ufw default deny incoming_
|
||||
|
||||
may look like a good idea. After all, it blocks everything!
|
||||
|
||||
Well, yes. Yes, it does. That means it also blocks ssh. And _that_ means you can no longer get to your shiny new server. Whoops!
|
||||
|
||||
Still, if you’re going to err, err on the side of blocking more connections. You see — the hackers really are out to get you.
|
||||
|
||||
Or, to be more exact, it’s not you or your servers personally. Sure, you’re not the [National Security Agency (NSA), which gets — no kidding — 300-million hacking attempts per day][17]. But a hacking script doesn’t care. It just screens the internet looking for a server with a known hole. My own quiet little servers get hundreds of attacks — on a slow day.
|
||||
|
||||
So, what are you waiting for? Go, lock down your network services. Install FirewallD or UFW and secure your servers. You’ll be glad you did.
|
||||
|
||||
|
||||
* * *
|
||||
|
||||
_Please feel free to share below any comments or insights about your experience locking down a Linux server with an IPtables-based firewall. And if this blog was useful, consider sharing it through social media._
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://medium.com/linode-cube/locking-down-your-linux-server-24d8516ae374#.qy8qq4bx2
|
||||
|
||||
作者:[Steven J. Vaughan-Nichols][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://medium.com/linode-cube/locking-down-your-linux-server-24d8516ae374#.qy8qq4bx2
|
||||
[1]:https://www.linode.com/
|
||||
[2]:https://www.linode.com/docs/security/securing-your-server
|
||||
[3]:http://www.faqs.org/docs/linux_network/x-087-2-iface.netstat.html
|
||||
[4]:https://httpd.apache.org/
|
||||
[5]:https://www.nginx.com/
|
||||
[6]:https://www.linode.com/docs/tools-reference/ssh/
|
||||
[7]:http://www.linux.org/threads/tcp-ip-service-remote-procedure-call-rpc.4913/
|
||||
[8]:https://help.ubuntu.com/lts/serverguide/NTP.html
|
||||
[9]:http://www.telnet.org/htm/faq.htm
|
||||
[10]:https://www.linode.com/docs/security/securing-your-server/#create-an-authentication-key-pair
|
||||
[11]:https://www.linode.com/docs/security/securing-your-server/#use-fail2ban-for-ssh-login-protection
|
||||
[12]:https://www.netfilter.org/
|
||||
[13]:http://www.firewalld.org/
|
||||
[14]:https://help.ubuntu.com/community/UFW
|
||||
[15]:https://www.linode.com/docs/security/firewalls/introduction-to-firewalld-on-centos
|
||||
[16]:https://www.linode.com/docs/security/firewalls/configure-firewall-with-ufw
|
||||
[17]:http://thehackernews.com/2016/02/nsa-utah-data-center.html
|
||||
[18]:http://www.zdnet.com/meet-the-team/us/steven-j-vaughan-nichols/
|
||||
[19]:http://www.pcmag.com/author-bio/steven-j.-vaughan-nichols
|
||||
[20]:http://www.infoworld.com/author/Steven-J.-Vaughan_Nichols/
|
||||
[21]:http://www.computerworld.com/author/Steven-J.-Vaughan_Nichols/
|
||||
[22]:http://www.linuxtoday.com/author/Steven+J.+Vaughan-Nichols/
|
||||
[23]:http://www.eweek.com/cp/bio/Steven-J.-Vaughan-Nichols/
|
||||
68
sources/tech/20161201 3 open source password managers.md
Normal file
68
sources/tech/20161201 3 open source password managers.md
Normal file
@@ -0,0 +1,68 @@
|
||||
3 open source password managers
|
||||
============================================================
|
||||
|
||||
### Keep your data and accounts safe by using a secure open source password manager to store unique, complex passwords.
|
||||
|
||||

|
||||
|
||||
>Image by : [Jason Baker][1]. [CC BY-SA 4.0][2].
|
||||
|
||||
Maintaining complex, unique passwords for each site and service you use is among the most common pieces of advice that security professionals provide to the public every year.
|
||||
|
||||
Yet no matter how many times it is said, it seems like a week doesn't go by where a high-profile hacking story hits the news, revealing that users of the service in question more often than not had such _secure_ passwords as "12345" or "password" as the only wall of protection on their account.
|
||||
|
||||
Or perhaps a user offers up just enough variation on the classic password selection to get past the minimal rules of the service. Unfortunately, "Pa$$w0rd!" isn't secure in any meaningful way, either. At this point, almost every variation of words and phrases strung together with a few numbers or substitutions is simply too easy for a password cracking tool to make its way through, and the shorter the password, the easier.
|
||||
|
||||
The best passwords are long, random or pseudo-random combinations of every possible character allowed, with a different password for each unique use. But how could a normal person remember the hundreds or even thousands of individual passwords associated with each account they've ever created? The short answer is: they can't. And don't even think about writing a password down in plain text, whether in the physical world or the digital.
|
||||
|
||||
Perhaps the easiest way to keep track of these complex, unique passwords is with a password manager, which provides easy access to strong encryption. While proprietary commercial solutions like LastPass are popular, there are several open source solutions as well. And with passwords, being able to audit the source code of your password manager is especially important, as it helps ensure that your passwords are encrypted properly and are not vulnerable to backdoors.
|
||||
|
||||
So without further ado, here are a few open source password managers we hope you will consider.
|
||||
|
||||
### KeePass
|
||||
|
||||
[KeePass][3] is a GPLv2-licensed password manager, primarily designed for Windows but also running elsewhere. KeePass offers multiple strong encryption options, easy exports, multiple user keys, advanced searching features, and more. Designed for desktop use, there are plugins that allow direct use from your web browser, and it can run from a USB stick if you'd prefer to physically carry your passwords from machine to machine. More on KeePass can be found in this [past article][4] from Ricardo Frydman.
|
||||
|
||||
[KeePassX][5], which started as a Linux port of KeePass, is another project you may consider. KeyPassX is compatible with KeePass 2 password files, and has also been ported to run on different operating systems. In fact, the list of [unofficial releases][6] of KeePass covers ports to just about every system in common use.
|
||||
|
||||
### Padlock
|
||||
|
||||
[Padlock][7] is a very new entrant into the world of open source password managers. Currently available for Windows, Mac, iOS, and Android, with a Linux client in the works, Padlock is designed as a "minimalist" password manager. Its [source][8] is available on GitHub under a [GPLv3][9] license. The project is also developing a [cloud backend][10], also open source, which will be a welcomed addition to anyone tired of managing password files or setting up syncing across multiple computers.
|
||||
|
||||
### Passbolt
|
||||
|
||||
[Passbolt][11] is another relatively new option, with plugins available for Firefox and Chrome and mobile and command-line options on the way. Based on OpenPGP, you can check out its online [demo][12] which shows off some of the features (you'll need to install the plugin for your browser, though). Licensed under the [GPL Affero version 3 license][13], you can check out the source code on [GitHub][14] or view the project's [roadmap][15] for a list of current features and more on what is planned.
|
||||
|
||||
* * *
|
||||
|
||||
Using a password manager that you trust alongside complex passwords is not a substitute for taking other security precautions, nor is it foolproof. But for many users, it can be an important part of keeping your digital life secured. These definitely aren't the only options out there. There are some older options, like [Clipperz][16] and [Password Safe][17], and web-based tools like [RatticDB][18] that I would be interested to try out. Which open source password manager do you use, and why?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/16/12/password-managers
|
||||
|
||||
作者:[Jason Baker ][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://opensource.com/users/jason-baker
|
||||
[1]:https://opensource.com/users/jason-baker
|
||||
[2]:https://creativecommons.org/licenses/by-sa/4.0/
|
||||
[3]:http://keepass.info/
|
||||
[4]:https://opensource.com/business/16/5/keepassx
|
||||
[5]:https://www.keepassx.org/
|
||||
[6]:http://keepass.info/download.html
|
||||
[7]:https://padlock.io/
|
||||
[8]:https://github.com/MaKleSoft/padlock
|
||||
[9]:https://github.com/MaKleSoft/padlock/blob/master/LICENSE
|
||||
[10]:https://github.com/maklesoft/padlock-cloud
|
||||
[11]:https://www.passbolt.com/
|
||||
[12]:https://demo.passbolt.com/auth/login
|
||||
[13]:https://github.com/passbolt/passbolt_browser_extension/blob/master/LICENCE
|
||||
[14]:https://github.com/passbolt
|
||||
[15]:https://www.passbolt.com/roadmap
|
||||
[16]:https://clipperz.is/
|
||||
[17]:https://pwsafe.org/
|
||||
[18]:http://rattic.org/
|
||||
@@ -0,0 +1,156 @@
|
||||
5 Ways to Empty or Delete a Large File Content in Linux
|
||||
============================================================
|
||||
|
||||
Occasionally, while dealing with files in Linux terminal, you may want to clear the content of a file without necessarily opening it using any [Linux command line editors][1]. How can this be achieved? In this article, we will go through several different ways of emptying file content with the help of some useful commands.
|
||||
|
||||
Caution: Before we proceed to looking at the various ways, note that because in [Linux everything is a file][2], you must always make sure that the file(s) you are emptying are not important user or system files. Clearing the content of a critical system or configuration file could lead to a fatal application/system error or failure.
|
||||
|
||||
With that said, below are means of clearing file content from the command line.
|
||||
|
||||
Important: For the purpose of this article, we’ve used file `access.log` in the following examples.
|
||||
|
||||
### 1\. Empty File Content by Redirecting to Null
|
||||
|
||||
A easiest way to empty or blank a file content using shell redirect `null` (non-existent object) to the file as below:
|
||||
|
||||
```
|
||||
# > access.log
|
||||
```
|
||||
[
|
||||

|
||||
][3]
|
||||
|
||||
Empty Large File Using Null Redirect in Linux
|
||||
|
||||
### 2\. Empty File Using ‘true’ Command Redirection
|
||||
|
||||
Here we will use a symbol `:` is a shell built-in command that is essence equivalent to the `true`command and it can be used as a no-op (no operation).
|
||||
|
||||
Another method is to redirect the output of `:` or `true` built-in command to the file like so:
|
||||
|
||||
```
|
||||
# : > access.log
|
||||
OR
|
||||
# true > access.log
|
||||
```
|
||||
[
|
||||

|
||||
][4]
|
||||
|
||||
Empty Large File Using Linux Commands
|
||||
|
||||
### 3\. Empty File Using cat/cp/dd utilities with /dev/null
|
||||
|
||||
In Linux, the `null` device is basically utilized for discarding of unwanted output streams of a process, or else as a suitable empty file for input streams. This is normally done by redirection mechanism.
|
||||
|
||||
And the `/dev/null` device file is therefore a special file that writes-off (removes) any input sent to it or its output is same as that of an empty file.
|
||||
|
||||
Additionally, you can empty contents of a file by redirecting output of `/dev/null` to it (file) as input using [cat command][5]:
|
||||
|
||||
```
|
||||
# cat /dev/null > access.log
|
||||
```
|
||||
[
|
||||

|
||||
][6]
|
||||
|
||||
Empty File Using cat Command
|
||||
|
||||
Next, we will use [cp command][7] to blank a file content as shown.
|
||||
|
||||
```
|
||||
# cp /dev/null access.log
|
||||
```
|
||||
[
|
||||

|
||||
][8]
|
||||
|
||||
Empty File Content Using cp Command
|
||||
|
||||
In the following command, `if` means the input file and `of` refers to the output file.
|
||||
|
||||
```
|
||||
# dd if=/dev/null of=access.log
|
||||
```
|
||||
[
|
||||

|
||||
][9]
|
||||
|
||||
Empty File Content Using dd Command
|
||||
|
||||
### 4\. Empty File Using echo Command
|
||||
|
||||
Here, you can use an [echo command][10] with an empty string and redirect it to the file as follows:
|
||||
|
||||
```
|
||||
# echo "" > access.log
|
||||
OR
|
||||
# echo > access.log
|
||||
```
|
||||
[
|
||||

|
||||
][11]
|
||||
|
||||
Empty File Using echo Command
|
||||
|
||||
Note: You should keep in mind that an empty string is not the same as null. A string is already an object much as it may be empty while null simply means non-existence of an object.
|
||||
|
||||
For this reason, when you redirect the out of the [echo command][12] above into the file, and view the file contents using the [cat command][13], is prints an empty line (empty string).
|
||||
|
||||
To send a null output to the file, use the flag `-n` which tells echo to not output the trailing newline that leads to the empty line produced in the previous command.
|
||||
|
||||
```
|
||||
# echo -n "" > access.log
|
||||
```
|
||||
[
|
||||

|
||||
][14]
|
||||
|
||||
Empty File Using Null Redirect
|
||||
|
||||
### 5\. Empty File Using truncate Command
|
||||
|
||||
The truncate command helps to [shrink or extend the size of a file][15] to a defined size.
|
||||
|
||||
You can employ it with the `-s` option that specifies the file size. To empty a file content, use a size of 0 (zero) as in the next command:
|
||||
|
||||
```
|
||||
# truncate -s 0 access.log
|
||||
```
|
||||
[
|
||||

|
||||
][16]
|
||||
|
||||
Truncate File Content in Linux
|
||||
|
||||
That’s it for now, in this article we have covered multiple methods of clearing or emptying file content using simple command line utilities and shell redirection mechanism.
|
||||
|
||||
These are not probably the only available practical ways of doing this, so you can also tell us about any other methods not mentioned in this guide via the feedback section below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/empty-delete-file-content-linux/
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/linux-command-line-editors/
|
||||
[2]:http://www.tecmint.com/explanation-of-everything-is-a-file-and-types-of-files-in-linux/
|
||||
[3]:http://www.tecmint.com/wp-content/uploads/2016/12/Empty-Large-File-in-Linux.png
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2016/12/Empty-Large-File-Using-Linux-Commands.png
|
||||
[5]:http://www.tecmint.com/13-basic-cat-command-examples-in-linux/
|
||||
[6]:http://www.tecmint.com/wp-content/uploads/2016/12/Empty-File-Using-cat-Command.png
|
||||
[7]:http://www.tecmint.com/progress-monitor-check-progress-of-linux-commands/
|
||||
[8]:http://www.tecmint.com/wp-content/uploads/2016/12/Empty-File-Content-Using-cp-Command.png
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2016/12/Empty-File-Content-Using-dd-Command.png
|
||||
[10]:http://www.tecmint.com/echo-command-in-linux/
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2016/12/Empty-File-Using-echo-Command.png
|
||||
[12]:http://www.tecmint.com/echo-command-in-linux/
|
||||
[13]:http://www.tecmint.com/13-basic-cat-command-examples-in-linux/
|
||||
[14]:http://www.tecmint.com/wp-content/uploads/2016/12/Empty-File-Using-Null-Redirect.png
|
||||
[15]:http://www.tecmint.com/parted-command-to-create-resize-rescue-linux-disk-partitions/
|
||||
[16]:http://www.tecmint.com/wp-content/uploads/2016/12/Truncate-File-Content-in-Linux.png
|
||||
@@ -0,0 +1,121 @@
|
||||
How to Build an Email Server on Ubuntu Linux
|
||||
============================================================
|
||||
|
||||

|
||||
In this series, we will show how to build a reliable configurable mail server with Postfix, Dovecot, and OpenSSL on Ubuntu Linux.[Creative Commons Zero][2]Pixabay
|
||||
|
||||
In this fast-changing world of containers and microservices it's comforting that some things don't change, such as setting up a Linux email server. It's still a dance of many steps and knitting together several different servers, and once you put it all together it just sits there, all nice and stable, instead of winking in and out of existence like microservices. In this series, we'll put together a nice reliable configurable mail server with Postfix, Dovecot, and OpenSSL on Ubuntu Linux.
|
||||
|
||||
Postfix is a reliable old standby that is easier to configure and use than Sendmail, the original Unix MTA (does anyone still use Sendmail?). Exim is Debian's default MTA; it is more lightweight than Postfix and super-configurable, so we'll look at Exim in a future tutorial.
|
||||
|
||||
Dovecot and Courier are two popular and excellent IMAP/POP3 servers. Dovecot is more lightweight and easier to configure.
|
||||
|
||||
You must secure your email sessions, so we'll use OpenSSL. OpenSSL also supplies some nice tools for testing your mail server.
|
||||
|
||||
For simplicity, we'll set up a LAN mail server in this series. You should have LAN name services already enabled and working; see [Dnsmasq For Easy LAN Name Services][5] for some pointers. Then later, you can adapt a LAN server to an Internet-accessible server by registering your domain name and configuring your firewall accordingly. These are documented everywhere, so please do your homework and be careful.
|
||||
|
||||
### Terminology
|
||||
|
||||
Let's take a quick look at some terminology, because it is nice when we know what the heck we're talking about.
|
||||
|
||||
* **MTA**: Mail transfer agent, a simple mail transfer protocol (SMTP) server such as Postfix, Exim, and Sendmail. SMTP servers talk to each other
|
||||
* **MUA**: Mail user agent, your local mail client such as Evolution, KMail, Claws Mail, or Thunderbird.
|
||||
* **POP3**: Post-office protocol, the simplest protocol for moving messages from an SMTP server to your mail client. A POP server is simple and lightweight; you can serve thousands of users from a single box.
|
||||
* **IMAP**: Interactive message access protocol. Most businesses use IMAP because messages remain on the server, so users don't have to worry about losing them. IMAP servers require a lot of memory and storage.
|
||||
* **TLS**: Transport socket layer, an evolution of SSL (secure sockets layer), which provides encrypted transport for SASL-authenticated logins.
|
||||
* **SASL**: Simple authentication and security layer, for authenticating users. SASL does the authenticating, then TLS provides the encrypted transport of the authentication data.
|
||||
* **StartTLS**: Also known as opportunistic TLS. StartTLS upgrades your plain text authentication to encrypted authentication if both servers support SSL/TLS. If one of them doesn't then it remains in cleartext. StartTLS uses the standard unencrypted ports: 25 (SMTP), 110 (POP3), and 143 (IMAP) instead of the standard encrypted ports: 465 (SMTP), 995 (POP3), and 993 (IMAP).
|
||||
|
||||
### Yes, We Still Have Sendmail
|
||||
|
||||
Most Linuxes still have `/usr/sbin/sendmail`. This is a holdover from the very olden days when Sendmail was the only MTA. On most distros `/usr/sbin/sendmail` is symlinked to your installed MTA. However your distro handles it, if it's there, it's on purpose.
|
||||
|
||||
### Install Postfix
|
||||
|
||||
`apt-get install postfix` takes care of the basic Postfix installation (Figure 1). This opens a wizard that asks what kind of server you want. Select "Internet Site", even for a LAN server. It will ask for your fully qualified server domain name (e.g., myserver.mydomain.net). On a LAN server, assuming your name services are correctly configured (I keep mentioning this because people keep getting it wrong), you can use just the hostname (e.g., myserver).
|
||||
|
||||

|
||||
|
||||
Figure 1: Postfix configuration.[Creative Commons Zero][1]Carla Schroder
|
||||
|
||||
Ubuntu will create a configuration file and launch three Postfix daemons: `master, qmgr`, and `pickup`. There is no Postfix command or daemon.
|
||||
|
||||
```
|
||||
$ ps ax
|
||||
6494 ? Ss 0:00 /usr/lib/postfix/master
|
||||
6497 ? S 0:00 pickup -l -t unix -u -c
|
||||
6498 ? S 0:00 qmgr -l -t unix -u
|
||||
```
|
||||
|
||||
Use Postfix's built-in syntax checker to test your configuration files. If it finds no syntax errors, it reports nothing:
|
||||
|
||||
```
|
||||
$ sudo postfix check
|
||||
[sudo] password for carla:
|
||||
```
|
||||
|
||||
Use `netstat` to verify that Postfix is listening on port 25:
|
||||
|
||||
```
|
||||
$ netstat -ant
|
||||
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN
|
||||
tcp6 0 0 :::25 :::* LISTEN
|
||||
```
|
||||
|
||||
Now let's fire up trusty old `telnet` to test:
|
||||
|
||||
```
|
||||
$ telnet myserver 25
|
||||
Trying 127.0.1.1...
|
||||
Connected to myserver.
|
||||
Escape character is '^]'.
|
||||
220 myserver ESMTP Postfix (Ubuntu)
|
||||
**EHLO myserver**
|
||||
250-myserver
|
||||
250-PIPELINING
|
||||
250-SIZE 10240000
|
||||
250-VRFY
|
||||
250-ETRN
|
||||
250-STARTTLS
|
||||
250-ENHANCEDSTATUSCODES
|
||||
250-8BITMIME
|
||||
250 DSN
|
||||
**^]**
|
||||
|
||||
telnet>
|
||||
```
|
||||
|
||||
Hurrah! We have verified the server name, and that Postfix is listening and responding to requests on port 25, the SMTP port.
|
||||
|
||||
Type `quit` to exit `telnet`. In the example, the commands that you type to interact with your server are in bold. The output are ESMTP (extended SMTP) 250 status codes.
|
||||
|
||||
* PIPELINING allows multiple commands to flow without having to respond to each one.
|
||||
* SIZE tells the maximum message size that the server accepts.
|
||||
* VRFY can tell a client if a particular mailbox exists. This is often ignored as it could be a security hole.
|
||||
* ETRN is for sites with irregular Internet connectivity. Such a site can use ETRN to request mail delivery from an upstream server, and Postfix can be configured to defer mail delivery to ETRN clients.
|
||||
* STARTTLS (see above).
|
||||
* ENHANCEDSTATUSCODES, the server supports enhanced status and error codes.
|
||||
* 8BITMIME, supports 8-bit MIME, which means the full ASCII character set. Once upon a time the original ASCII was 7 bits.
|
||||
* DSN, delivery status notifiction, informs you of delivery errors.
|
||||
|
||||
The main Postfix configuration file is `/etc/postfix/main.cf`. This is created by the installer. See [Postfix Configuration Parameters][6] for a complete listing of `main.cf` parameters. `/etc/postfix/postfix-files` describes the complete Postfix installation.
|
||||
|
||||
Come back next week for installing and testing Dovecot, and sending ourselves some messages.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linux.com/learn/how-build-email-server-ubuntu-linux
|
||||
|
||||
作者:[CARLA SCHRODER][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://www.linux.com/users/cschroder
|
||||
[1]:https://www.linux.com/licenses/category/creative-commons-zero
|
||||
[2]:https://www.linux.com/licenses/category/creative-commons-zero
|
||||
[3]:https://www.linux.com/files/images/postfix-1png
|
||||
[4]:https://www.linux.com/files/images/mail-stackjpg
|
||||
[5]:https://www.linux.com/learn/dnsmasq-easy-lan-name-services
|
||||
[6]:http://www.postfix.org/postconf.5.html
|
||||
@@ -0,0 +1,181 @@
|
||||
Uncommon but useful GCC command line options - part 2
|
||||
============================================================
|
||||
|
||||
### On this page
|
||||
|
||||
1. [Enable warnings that aren't covered by -Wall][1]
|
||||
2. [Enable warning for floating point values in equity comparisons][2]
|
||||
3. [How to better manage gcc command line options][3]
|
||||
4. [Conclusion][4]
|
||||
|
||||
The gcc compiler offers a seemingly never-ending list of command line options. Of course, no body uses or has expertise on all of them, but there are a select bunch that every gcc user should - if not must - know. While some of them are commonly used, others are a bit uncommon but no less useful.
|
||||
|
||||
In this article series, we are focusing on some of those uncommon but useful gcc command line options, and have already covered a couple of them in the [part 1][5].
|
||||
|
||||
If you recall, in the beginning of the first part of this tutorial series, I briefly mentioned that the -Wall option that developers generally use for generating warnings doesn't cover some specific warnings. If you aren't aware of these warnings and have no idea on how to enable them, worry not, as we'll be explaining all that in detail in this article.
|
||||
|
||||
Aside from this, we'll also be covering a gcc warning option related to floating point variables, as well as how to better manage the gcc command line options if the list grows large.
|
||||
|
||||
But before we move ahead, please keep in mind that all the examples, command, and instructions mentioned in this tutorial have been tested on Ubuntu 16.04 LTS, and the gcc version that we've used is 5.4.0.
|
||||
|
||||
### Enable warnings that aren't covered by -Wall
|
||||
|
||||
While the -Wall option of the gcc compiler covers most of the warning flags, there are some that remain disabled. To enable them, use the **-Wextra** option.
|
||||
|
||||
For example, take a look at the following code:
|
||||
|
||||
```
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
int main()
|
||||
{
|
||||
int i=0;
|
||||
/* ...
|
||||
some code here
|
||||
...
|
||||
*/
|
||||
|
||||
if(i);
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
I accidentally put a semicolon after the 'if' condition. Now, when the code was compiled using the following gcc command, no warning was produced.
|
||||
|
||||
gcc -Wall test.c -o test
|
||||
|
||||
But when the -Wextra option was used:
|
||||
|
||||
gcc -Wall -Wextra test.c -o test
|
||||
|
||||
A warning was produced:
|
||||
|
||||
```
|
||||
test.c: In function ‘main’:
|
||||
test.c:10:8: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
|
||||
if(i);
|
||||
```
|
||||
|
||||
As clear from the warning shown above, the -Wextra option internally enabled the -Wempty-body flag, which in turned detected the suspicious code and issued the warning. Here is the complete list of warning flags enabled by this option:
|
||||
|
||||
-Wclobbered, -Wempty-body, -Wignored-qualifiers, -Wmissing-field-initializers, -Wmissing-parameter-type (C only), -Wold-style-declaration (C only), -Woverride-init, -Wsign-compare, -Wtype-limits, -Wuninitialized, -Wunused-parameter (only with -Wunused or -Wall), and -Wunused-but-set-parameter (only with -Wunused or -Wall).
|
||||
|
||||
If you want to learn what the above mentioned flags do, head to [gcc's man page][6].
|
||||
|
||||
Moving on, the -Wextra option also issues warnings in the following cases:
|
||||
|
||||
* A pointer is compared against integer zero with <, <=, >, or >=
|
||||
* (C++ only) An enumerator and a non-enumerator both appear in a
|
||||
conditional expression.
|
||||
* (C++ only) Ambiguous virtual bases.
|
||||
* (C++ only) Subscripting an array that has been declared
|
||||
register.
|
||||
* (C++ only) Taking the address of a variable that has been
|
||||
declared register.
|
||||
* (C++ only) A base class is not initialized in a derived class's
|
||||
copy constructor.
|
||||
|
||||
### Enable warning for floating point values in equity comparisons
|
||||
|
||||
As you might already know, one should never test for the exact equality of floating-point values (didn't know this - read the floating-point comparison-related FAQ [here][7]). But even if you accidentally do this, does the gcc compiler throw any warning or error? Let's check out:
|
||||
|
||||
Here's a code that compares floating point variables using == operator:
|
||||
|
||||
```
|
||||
#include<stdio.h>
|
||||
|
||||
void compare(float x, float y)
|
||||
{
|
||||
if(x == y)
|
||||
{
|
||||
printf("\n EQUAL \n");
|
||||
}
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
compare(1.234, 1.56789);
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
And here's the gcc command (containing both -Wall and -Wextra options) used to compile this code:
|
||||
|
||||
gcc -Wall -Wextra test.c -o test
|
||||
|
||||
Sadly, the above command doesn't produce any warning related to floating point comparison. A quick look at GCC's man page reveals that there exists a dedicated option **-Wfloat-equal** that should be used in these scenarios.
|
||||
|
||||
Here's the command containing this option:
|
||||
|
||||
gcc -Wall -Wextra -Wfloat-equal test.c -o test
|
||||
|
||||
And following is the output it produced:
|
||||
|
||||
```
|
||||
test.c: In function ‘compare’:
|
||||
test.c:5:10: warning: comparing floating point with == or != is unsafe [-Wfloat-equal]
|
||||
if(x == y)
|
||||
```
|
||||
|
||||
So as you can see in the output above, the -Wfloat-equal option forced gcc to produce warning related to floating comparison.
|
||||
|
||||
Here is what [the gcc man page][8] says about this option:
|
||||
|
||||
```
|
||||
The idea behind this is that sometimes it is convenient (for the programmer) to consider floating-point values as approximations to infinitely precise real numbers. If you are doing this, then you
|
||||
need to compute (by analyzing the code, or in some other way) the maximum or likely maximum error that the computation introduces, and allow for it when performing comparisons (and when producing
|
||||
output, but that's a different problem). In particular, instead of testing for equality, you shouldcheck to see whether the two values have ranges that overlap; and this is done with the relational operators, so equality comparisons are probably mistaken.
|
||||
```
|
||||
|
||||
### How to better manage gcc command line options
|
||||
|
||||
If the list of command line options that you are using in your gcc command is becoming larger and difficult to manage, then you can put it in a text file, and pass that file's name as an argument to the gcc command. For this, you'll have to use the **@file**command line option.
|
||||
|
||||
For example, if following is your gcc command:
|
||||
|
||||
gcc -Wall -Wextra -Wfloat-equal test.c -o test
|
||||
|
||||
Then you can put the three warnings-related options in a file named, say 'gcc-options' :
|
||||
|
||||
$ cat gcc-options
|
||||
-Wall -Wextra -Wfloat-equal
|
||||
|
||||
And your gcc command becomes less cluttered and easy to manage:
|
||||
|
||||
gcc @gcc-options test.c -o test
|
||||
|
||||
Here's what the gcc man page says about @file:
|
||||
|
||||
```
|
||||
Read command-line options from file. The options read are inserted in place of the original @file option. If file does not exist, or cannot be read, then the option will be treated literally, and not removed.
|
||||
|
||||
Options in file are separated by whitespace. A whitespace character may be included in an option by surrounding the entire option in either single or double quotes. Any character (including a backslash) may be included by prefixing the character to be included with a backslash. The file may itself contain additional @file options; any such options will be processed recursively.
|
||||
```
|
||||
|
||||
### Conclusion
|
||||
|
||||
So we covered a total of 5 uncommon but useful gcc command line options in this tutorial series: -save-temps, -g, -Wextra, -Wfloat-equal, and @file. Do spend time practicing each of them and don't forget to go through all the details that the gcc man page offers about them.
|
||||
|
||||
Do you know or use other such useful gcc command line options, and want to share them with the world? Leave all the details in comments below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.howtoforge.com/tutorial/uncommon-but-useful-gcc-command-line-options-2/
|
||||
|
||||
作者:[Ansh][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://twitter.com/howtoforgecom
|
||||
[1]:https://www.howtoforge.com/tutorial/uncommon-but-useful-gcc-command-line-options-2/#enable-warnings-that-arent-covered-by-wall
|
||||
[2]:https://www.howtoforge.com/tutorial/uncommon-but-useful-gcc-command-line-options-2/#enable-warning-fornbspfloating-point-values-in-equity-comparisons
|
||||
[3]:https://www.howtoforge.com/tutorial/uncommon-but-useful-gcc-command-line-options-2/#how-to-better-manage-gcc-command-line-options
|
||||
[4]:https://www.howtoforge.com/tutorial/uncommon-but-useful-gcc-command-line-options-2/#conclusion
|
||||
[5]:https://www.howtoforge.com/tutorial/uncommon-but-useful-gcc-command-line-options/
|
||||
[6]:https://linux.die.net/man/1/gcc
|
||||
[7]:https://isocpp.org/wiki/faq/newbie
|
||||
[8]:https://linux.die.net/man/1/gcc
|
||||
@@ -0,0 +1,167 @@
|
||||
httpstat – A Curl Statistics Tool to Check Website Performance
|
||||
============================================================
|
||||
|
||||
httpstat is a Python script that reflects curl statistics in a fascinating and well-defined way, it is a single file which is compatible with Python 3 and requires no additional software (dependencies) to be installed on a users system.
|
||||
|
||||
It is fundamentally a wrapper of cURL tool, means that you can use several valid cURL options after a URL(s), excluding the options -w, -D, -o, -s, and -S, which are already employed by httpstat.
|
||||
|
||||
[
|
||||

|
||||
][5]
|
||||
|
||||
httpstat Curl Statistics Tool
|
||||
|
||||
You can see in the above image an ASCII table displaying how long each process took, and for me the most important step is “server processing” – if this number is higher, then you need to [tune your server to speed up website][6].
|
||||
|
||||
For website or server tuning you can check our articles here:
|
||||
|
||||
1. [5 Tips to Tune Performance of Apache Web Server][1]
|
||||
2. [Speed Up Apache and Nginx Performance Upto 10x][2]
|
||||
3. [How to Boost Nginx Performance Using Gzip Module][3]
|
||||
4. [15 Tips to Tune MySQL/MariaDB Performance][4]
|
||||
|
||||
Grab httpstat to check out your website speed using following instillation instructions and usage.
|
||||
|
||||
### Install httpstat in Linux Systems
|
||||
|
||||
You can install httpstat utility using two possible methods:
|
||||
|
||||
1. Get it directly from its Github repo using the [wget command][7] as follows:
|
||||
|
||||
```
|
||||
$ wget -c https://raw.githubusercontent.com/reorx/httpstat/master/httpstat.py
|
||||
```
|
||||
|
||||
2. Using pip (this method allows httpstat to be installed on your system as a command) like so:
|
||||
|
||||
```
|
||||
$ sudo pip install httpstat
|
||||
```
|
||||
|
||||
Note: Make sure pip package installed on the system, if not install it using your distribution package manager [yum][8] or [apt][9].
|
||||
|
||||
### How to Use httpstat in Linux
|
||||
|
||||
httpstat can be used according to the way you installed it, if you directly downloaded it, run it using the following syntax from within the download directory:
|
||||
|
||||
```
|
||||
$ python httpstat.py url cURL_options
|
||||
```
|
||||
|
||||
In case you used pip to install it, you can execute it as a command in the form below:
|
||||
|
||||
```
|
||||
$ httpstat url cURL_options
|
||||
```
|
||||
|
||||
To view the help page for httpstat, issue the command below:
|
||||
|
||||
```
|
||||
$ python httpstat.py --help
|
||||
OR
|
||||
$ httpstat --help
|
||||
```
|
||||
httpstat help
|
||||
```
|
||||
Usage: httpstat URL [CURL_OPTIONS]
|
||||
httpstat -h | --help
|
||||
httpstat --version
|
||||
Arguments:
|
||||
URL url to request, could be with or without `http(s)://` prefix
|
||||
Options:
|
||||
CURL_OPTIONS any curl supported options, except for -w -D -o -S -s,
|
||||
which are already used internally.
|
||||
-h --help show this screen.
|
||||
--version show version.
|
||||
Environments:
|
||||
HTTPSTAT_SHOW_BODY Set to `true` to show response body in the output,
|
||||
note that body length is limited to 1023 bytes, will be
|
||||
truncated if exceeds. Default is `false`.
|
||||
HTTPSTAT_SHOW_IP By default httpstat shows remote and local IP/port address.
|
||||
Set to `false` to disable this feature. Default is `true`.
|
||||
HTTPSTAT_SHOW_SPEED Set to `true` to show download and upload speed.
|
||||
Default is `false`.
|
||||
HTTPSTAT_SAVE_BODY By default httpstat stores body in a tmp file,
|
||||
set to `false` to disable this feature. Default is `true`
|
||||
HTTPSTAT_CURL_BIN Indicate the curl bin path to use. Default is `curl`
|
||||
from current shell $PATH.
|
||||
HTTPSTAT_DEBUG Set to `true` to see debugging logs. Default is `false`
|
||||
```
|
||||
|
||||
From the output of the help command above, you can see that httpstat has a collection of useful environmental variables that influence its behavior.
|
||||
|
||||
To use them, simply export the variables with the appropriate value in the `.bashrc` or `.zshrc` file.
|
||||
|
||||
For instance:
|
||||
|
||||
```
|
||||
export HTTPSTAT_SHOW_IP=false
|
||||
export HTTPSTAT_SHOW_SPEED=true
|
||||
export HTTPSTAT_SAVE_BODY=false
|
||||
export HTTPSTAT_DEBUG=true
|
||||
```
|
||||
|
||||
Once your are done adding them, save the file and run the command below to effect the changes:
|
||||
|
||||
```
|
||||
$ source ~/.bashrc
|
||||
```
|
||||
|
||||
You can as well specify the cURL binary path to use, the default is curl from current shell [$PATH environmental variable][10].
|
||||
|
||||
Below are a few examples showing how httpsat works.
|
||||
|
||||
```
|
||||
$ python httpstat.py google.com
|
||||
OR
|
||||
$ httpstat google.com
|
||||
```
|
||||
[
|
||||

|
||||
][11]
|
||||
|
||||
httpstat – Showing Website Statistics
|
||||
|
||||
In the next command:
|
||||
|
||||
1. `-x` command flag specifies a custom request method to use while communicating with the HTTP server.
|
||||
2. `--data-urlencode` data posts data (a=b in this case) with URL-encoding turned on.
|
||||
3. `-v` enables a verbose mode.
|
||||
|
||||
```
|
||||
$ python httpstat.py httpbin.org/post -X POST --data-urlencode "a=b" -v
|
||||
```
|
||||
[
|
||||

|
||||
][12]
|
||||
|
||||
httpstat – Custom Post Request
|
||||
|
||||
You can look through the cURL man page for more useful and advanced options or visit the httpstatGithub repository: [https://github.com/reorx/httpstat][13]
|
||||
|
||||
In this article, we have covered a useful tool for monitoring cURL statistics is a simple and clear way. If you know of any such tools out there, do not hesitate to let us know and you can as well ask a question or make a comment about this article or httpstat via the feedback section below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/httpstat-curl-statistics-tool-check-website-performance/
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/apache-performance-tuning/
|
||||
[2]:http://www.tecmint.com/install-mod_pagespeed-to-boost-apache-nginx-performance/
|
||||
[3]:http://www.tecmint.com/increase-nginx-performance-enable-gzip-compression-module/
|
||||
[4]:http://www.tecmint.com/mysql-mariadb-performance-tuning-and-optimization/
|
||||
[5]:http://www.tecmint.com/wp-content/uploads/2016/12/httpstat-Curl-Statistics-Tool.png
|
||||
[6]:http://www.tecmint.com/apache-performance-tuning/
|
||||
[7]:http://www.tecmint.com/10-wget-command-examples-in-linux/
|
||||
[8]:http://www.tecmint.com/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement/
|
||||
[9]:http://www.tecmint.com/apt-advanced-package-command-examples-in-ubuntu/
|
||||
[10]:http://www.tecmint.com/set-unset-environment-variables-in-linux/
|
||||
[11]:http://www.tecmint.com/wp-content/uploads/2016/12/httpstat.png
|
||||
[12]:http://www.tecmint.com/wp-content/uploads/2016/12/httpstat-Post-Request.png
|
||||
[13]:https://github.com/reorx/httpstat
|
||||
@@ -0,0 +1,269 @@
|
||||
The Complete Guide to Flashing Factory Images Using Fastboot
|
||||
==========
|
||||
|
||||

|
||||
|
||||
If your phone has an unlocked [bootloader][31], you can use [Fastboot][32] commands to flash factory images. That may sound like a bunch of technical jargon, but when it comes down to it, this is the best method for updating a [rooted][33] device, fixing a [bricked][34] phone, reverting to stock, or even getting new Android updates before everyone else.
|
||||
|
||||
Much like [ADB][35], Fastboot is a very powerful Android utility that accepts commands through a terminal shell. But if that sounds intimidating, don't worry—because once you've learned your way around things, you'll know so much more about the inner workings of Android, as well as how to fix most common problems.
|
||||
|
||||
### A Note About Samsung Devices
|
||||
|
||||
The process outlined below will work for most Nexus, Pixel, HTC, and Motorola devices, as well as phones and tablets from many other manufacturers. However, Samsung devices use their own firmware-flashing software, so Fastboot isn't the way to go if you own a Galaxy. Instead, it's best to use [Odin][36] to flash firmware on a Samsung device, and we've covered that process at the following link.
|
||||
|
||||
|
||||
### Step 1Install ADB & Fastboot on Your Computer
|
||||
|
||||
First, you'll have to install ADB and Fastboot on your computer, which are the utilities that let you flash images using Fastboot commands. There are several "one-click" and "light" versions of ADB and Fastboot, but I wouldn't recommend using these because they're not updated as frequently as the official utilities, so they might not be fully compatible with newer devices.
|
||||
|
||||
Instead, your best bet is to install the Android SDK Tools from Google. This is the "real" ADB and Fastboot, and it may take a little longer to install, but it's well worth the initial time investment. I've outlined the install process for Windows, Mac, and Linux in _Method 1_ at the following guide, so head over there to get started.
|
||||
|
||||
|
||||
### Step 2Enable OEM Unlocking
|
||||
|
||||
In order to flash images using Fastboot, your device's [bootloader][37] will need to be unlocked. If you've already done this, you can skip ahead to Step 3.
|
||||
|
||||
But before you can unlock your bootloader, there's [a setting that you'll need to enable][38] if your device shipped with [Android Marshmallow or higher][39] preinstalled. To access this setting, start by **[enabling the Developer options menu][18]** on your phone or tablet. Once you've done that, open the Developer options menu, then enable the switch next to "OEM unlocking," and you'll be good to go.
|
||||
|
||||
[
|
||||

|
||||
][1]
|
||||
|
||||
If this option is not present on your device, it's likely that your device didn't ship with Android Marshmallow or higher preinstalled. However, if the option is present but grayed out, this usually means that your bootloader cannot be unlocked, which means you won't be able to flash images using Fastboot.
|
||||
|
||||
### Step 3Put Your Phone into Bootloader Mode
|
||||
|
||||
In order to run any Fastboot commands, your phone or tablet will need to be in bootloader mode. This process will vary depending on your device.
|
||||
|
||||
For most phones, start by powering your device completely off. When the screen goes black, press and hold the volume down and power buttons simultaneously, and keep holding them for about 10 seconds.
|
||||
|
||||
If that doesn't work, turn the phone off, then press and hold the volume down button. From there plug a USB data cable into your PC, then simply wait a few seconds.
|
||||
|
||||
If that still didn't work, try repeating the USB cable method, but this time use the volume up button.
|
||||
|
||||
Within moments, you should be greeted by Android's Bootloader menu, which should look something like this:
|
||||
|
||||
[
|
||||

|
||||
][2]
|
||||
|
||||
When you see this screen, make sure your phone or tablet is plugged into your computer with a USB data cable. Aside from that, leave the device alone, as the rest of the work will be done on the computer side of things.
|
||||
|
||||
|
||||
### Step 4 Open an ADB Shell on Your Computer
|
||||
|
||||
Navigate to the ADB and Fastboot installation directory on your computer. For Windows users, this can usually be found at _C:\Program Files (x86)\Android\android-sdk\platform-tools_. For Mac and Linux users, it depends on where you extracted your ADB folder when you installed the utility, so search your hard drive for the _platform-tools_ folder if you've forgotten.
|
||||
|
||||
From here, if you're using a Windows PC, hold down the shift button on your keyboard, then right-click any empty space and choose "Open command window here." For Mac and Linux users, simply open a Terminal window, then change directories to the _platform-tools_ folder inside of your ADB installation directory.
|
||||
|
||||
[
|
||||

|
||||
][3]
|
||||
|
||||
### Step 5Unlock the Bootloader
|
||||
|
||||
This next step is something you only need to do once, so if your bootloader is already unlocked, you can skip ahead. Otherwise, you'll need to run a single Fastboot command—but note that **this will wipe all data on your device**.
|
||||
|
||||
Before we get into this part, note that I'll be listing the commands for Windows users. Mac users will have to add a period and a slash (**./**) before each of these commands, and Linux users will have to add a slash (**/**) to the front.
|
||||
|
||||
So from the ADB shell, type the following command, then hit enter.
|
||||
|
||||
* **fastboot devices**
|
||||
|
||||
If that returns a series of letters and numbers followed by the word "fastboot," then your device is connected properly and you're good to go. Otherwise, refer back to Step 1 to check your ADB and Fastboot installation, and ensure that your device is in bootloader mode as shown in Step 3.
|
||||
|
||||
[
|
||||

|
||||
][4]
|
||||
|
||||
Next up, it's time to unlock your bootloader. Depending on the Android version your device shipped with, this will be done in one of two ways.
|
||||
|
||||
So if your device shipped with Lollipop or lower pre-installed, enter the following command:
|
||||
|
||||
* **fastboot oem unlock**
|
||||
|
||||
If your device shipped with Marshmallow or higher, type the following command, then hit enter:
|
||||
|
||||
* **fastboot flashing unlock**
|
||||
|
||||
[
|
||||

|
||||
][5]
|
||||
|
||||
>Sending the bootloader unlock command to a device that shipped with Marshmallow or higher.
|
||||
|
||||
At this point, you'll see a message on your Android device asking if you're sure you'd like to unlock the bootloader. Make sure the "Yes" option is highlighted, and if it's not, use your volume keys to do so. From there, press the power button, then your bootloader will unlock and your phone will reboot back into Fastboot mode.
|
||||
|
||||
[
|
||||

|
||||
][6]
|
||||
|
||||
Bootloader-unlock screen on the Nexus 6P.Image by Dallas Thomas/Gadget Hacks
|
||||
|
||||
### Step 6Download the Factory Images
|
||||
|
||||
Now that your bootloader is unlocked, you're ready to start flashing factory images—but first, you'll have to download the actual images themselves. Below are some links to download the factory images package for common devices.
|
||||
|
||||
* **[Factory images for Nexus or Pixel devices][15]**
|
||||
* **[Factory images for HTC devices][16]**
|
||||
* **[Factory images for Motorola devices][17]**
|
||||
|
||||
With each of the above links, simply locate your device model in the list, then download the latest available firmware on your computer. If your manufacturer is not listed here, try Googling "factory images for `<phone name>`."
|
||||
|
||||
|
||||
### Step 7Flash the Factory Images
|
||||
|
||||
Now it's time to flash the images. The first thing you'll want to do here is extract the factory images archive that you downloaded from your manufacturer's website. For that part, I'd recommend using **[7-Zip][19]**, as it's free and works with most archive formats.
|
||||
|
||||
[
|
||||

|
||||
][7]
|
||||
|
||||
Extracting the factory images archive.
|
||||
|
||||
Next, move all of the contents of the archive to the _platform-tools_ folder inside of your ADB installation directory, then open an ADB Shell window in this folder. For more information on that, refer back to Step 4 above.
|
||||
|
||||
[
|
||||

|
||||
][8]
|
||||
|
||||
Factory image files transferred to the platform-tools folder.
|
||||
|
||||
Aside from that, there are two different approaches you can take when flashing the images. I'll outline both of them in separate sections below.
|
||||
|
||||
|
||||
### Option 1: Use the Flash-All Script
|
||||
|
||||
Most factory images packages will contain a "flash-all" script that applies all of the images in one fell swoop. If you're trying to recover your device from a soft brick, this is the simplest way to go. However, it will unroot your device and wipe all existing data, so if you'd rather avoid that, see Option 2 below.
|
||||
|
||||
But to run the flash-all script, type the following line into the command prompt, then hit enter:
|
||||
|
||||
* **flash-all**
|
||||
|
||||
[
|
||||

|
||||
][9]
|
||||
|
||||
Sending the "flash-all" command.
|
||||
|
||||
The process will take a few minutes, but when it's done, your phone should automatically reboot and you'll be running complete, 100% stock firmware.
|
||||
|
||||
|
||||
### Option 2: Extract the Images & Flash Them Individually
|
||||
|
||||
For a second option, you can flash the system images individually. This method takes some extra work, but it can be used to un-root, update, or un-brick your device without losing existing data.
|
||||
|
||||
Start by extracting any additional archives from the factory images package. Sometimes, factory images packages can contain a series of three or four nested archives, so make sure to unzip all of them. From there, copy all of the image files to the main _platform-tools_ folder—in other words, don't leave them in any sub-folders.
|
||||
|
||||
[
|
||||

|
||||
][10]
|
||||
|
||||
All images extracted from factory images package into platform-tools folder.
|
||||
|
||||
From here, there are two images that you can get rid of: _cache.img_ and _userdata.img_. These are the images that will overwrite your data and cache with blank space, so if you don't flash them, your existing data will remain intact.
|
||||
|
||||
Of the remaining images, six make up the core elements of Android: _boot_, _bootloader_, _radio_, _recovery_, _system_, and _vendor_.
|
||||
|
||||
The _boot_ image contains the kernel, so if you just want to get rid of a custom kernel that's causing issues with your device, you only have to flash this one. To do that, type the following command into the ADB shell window:
|
||||
|
||||
* **fastboot flash boot <boot image file name>.img**
|
||||
|
||||
Next is the _bootloader_ image—this is the the interface that you're using to flash images with Fastboot commands. So to update your bootloader, type:
|
||||
|
||||
* **fastboot flash bootloader <bootloader image file name>.img**
|
||||
|
||||
Once you've done that, you should reload the bootloader so that you can continue flashing images on the newer version. To do that, type:
|
||||
|
||||
* **fastboot reboot-bootloader**
|
||||
|
||||
After that, we have the _radio_ image. This one controls connectivity on your device, so if you're having problems with Wi-Fi or mobile data, or if you just want to update your radio, type:
|
||||
|
||||
* **fastboot flash radio <radio image file name>.img**
|
||||
|
||||
Then there's _recovery_. This is something you may or may not want to flash, depending on the modifications you've made. For example, if you've installed TWRP custom recovery, flashing this image will overwrite your modification and replace it with the stock recovery interface. So if you're just updating your modded device, you should skip this one. Otherwise, if you plan to keep your phone stock and want the newer version of stock recovery, type:
|
||||
|
||||
* **fastboot flash recovery <recovery file name>.img**
|
||||
|
||||
Next up is the big one: The _system_ image. This one contains all of the files that make up the actual Android OS. As such, it's the most essential part of any update.
|
||||
|
||||
However you may not be updating your phone. You may just be re-flashing the stock firmware to recover from a soft brick. If this is the case, the system image is often the only image you need to flash in order to fix everything, because it contains the entirety of Android. In other words, if you flash this image and nothing else, it will undo any changes you made with root access and put everything back the way it was.
|
||||
|
||||
So as a cure-all in most soft brick situations, or as a method for getting the core part of an Android update, type:
|
||||
|
||||
* **fastboot flash system <system file name>.img**
|
||||
|
||||
Finally, there's the _vendor_ image. This is only present on newer phones, so don't worry if it's not in your factory images package. But if it's there, it contains a few important files, so type the following line to get this partition updated:
|
||||
|
||||
* **fastboot flash vendor <vendor file name>.img**
|
||||
|
||||
After you've sent any or all of the above commands, you'll be ready to restart your device and boot into Android. To do that, type:
|
||||
|
||||
* **fastboot reboot**
|
||||
|
||||
[
|
||||

|
||||
][11]
|
||||
|
||||
Flashing the factory images individually.
|
||||
|
||||
At this point, your device should be fully updated, or if you were trying to recover from a soft brick, it should be running flawlessly. And since you now know what each of the core system images actually _does_, you'll have a better sense of how Android works going forward.
|
||||
|
||||
Flashing factory images individually has helped me understand more about Android than any other mod or process. If you think about it, Android is just a series of images written to flash storage, and now that you've dealt with each of them individually, you should be able to identify and resolve root-related issues a lot easier.
|
||||
|
||||
* Follow Gadget Hacks on [Facebook][20], [Twitter][21], [Google+][22], and [YouTube][23]
|
||||
* Follow Android Hacks on [Facebook][24], [Twitter][25], and [Pinterest][26]
|
||||
* Follow WonderHowTo on [Facebook][27], [Twitter][28], [Pinterest][29], and [Google+][30]
|
||||
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://android.wonderhowto.com/how-to/complete-guide-flashing-factory-images-using-fastboot-0175277/
|
||||
|
||||
作者:[ Dallas Thomas][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://creator.wonderhowto.com/dallasthomas/
|
||||
[1]:http://img.wonderhowto.com/img/original/95/62/63613181132511/0/636131811325119562.jpg
|
||||
[2]:http://img.wonderhowto.com/img/original/12/37/63615501357234/0/636155013572341237.jpg
|
||||
[3]:http://img.wonderhowto.com/img/original/42/51/63613181192903/0/636131811929034251.jpg
|
||||
[4]:http://img.wonderhowto.com/img/original/06/56/63613181203998/0/636131812039980656.jpg
|
||||
[5]:http://img.wonderhowto.com/img/original/53/86/63613181215032/0/636131812150325386.jpg
|
||||
[6]:http://img.wonderhowto.com/img/original/55/72/63613181234096/0/636131812340965572.jpg
|
||||
[7]:http://img.wonderhowto.com/img/original/81/31/63616200792994/0/636162007929948131.jpg
|
||||
[8]:http://img.wonderhowto.com/img/original/05/92/63616201348448/0/636162013484480592.jpg
|
||||
[9]:http://img.wonderhowto.com/img/original/58/38/63616206141588/0/636162061415885838.jpg
|
||||
[10]:http://img.wonderhowto.com/img/original/47/26/63616206657885/0/636162066578854726.jpg
|
||||
[11]:http://img.wonderhowto.com/img/original/31/31/63616269700533/0/636162697005333131.jpg
|
||||
[12]:http://android.wonderhowto.com/how-to/know-your-android-tools-what-is-fastboot-do-you-use-it-0155640/
|
||||
[13]:http://gs6.wonderhowto.com/how-to/unroot-restore-samsung-galaxy-s6-back-stock-0162155/
|
||||
[14]:http://android.wonderhowto.com/how-to/android-basics-install-adb-fastboot-mac-linux-windows-0164225/
|
||||
[15]:https://developers.google.com/android/images
|
||||
[16]:http://www.htc.com/us/support/rom-downloads.html
|
||||
[17]:https://motorola-global-portal.custhelp.com/cc/cas/sso/redirect/standalone%2Fbootloader%2Frecovery-images
|
||||
[18]:http://android.wonderhowto.com/how-to/android-basics-enable-developer-options-usb-debugging-0161948/
|
||||
[19]:http://www.7-zip.org/download.html
|
||||
[20]:http://facebook.com/gadgethacks/
|
||||
[21]:http://twitter.com/gadgethax
|
||||
[22]:https://plus.google.com/+gadgethacks
|
||||
[23]:https://www.youtube.com/user/OfficialSoftModder/
|
||||
[24]:http://facebook.com/androidhacksdotcom/
|
||||
[25]:http://twitter.com/androidhackscom
|
||||
[26]:https://www.pinterest.com/wonderhowto/android-hacks-mods-tips/
|
||||
[27]:http://facebook.com/wonderhowto/
|
||||
[28]:http://twitter.com/wonderhowto/
|
||||
[29]:http://pinterest.com/wonderhowto/
|
||||
[30]:https://plus.google.com/+wonderhowto
|
||||
[31]:http://android.wonderhowto.com/news/big-android-dictionary-glossary-terms-you-should-know-0165594/
|
||||
[32]:http://android.wonderhowto.com/news/big-android-dictionary-glossary-terms-you-should-know-0165594/
|
||||
[33]:http://android.wonderhowto.com/how-to/android-basics-what-is-root-0167400/
|
||||
[34]:http://android.wonderhowto.com/news/big-android-dictionary-glossary-terms-you-should-know-0165594/
|
||||
[35]:http://android.wonderhowto.com/how-to/know-your-android-tools-what-is-adb-do-you-use-it-0155456/
|
||||
[36]:http://tag.wonderhowto.com/odin/
|
||||
[37]:http://android.wonderhowto.com/news/big-android-dictionary-glossary-terms-you-should-know-0165594/
|
||||
[38]:http://android.wonderhowto.com/news/psa-enable-hidden-setting-before-modding-anything-android-0167840/
|
||||
[39]:http://android.wonderhowto.com/how-to/android-basics-tell-what-android-version-build-number-you-have-0168050/
|
||||
@@ -1,51 +0,0 @@
|
||||
容器和 Unikernel 能从 Raspberry Pi(树莓派)和 Arduino 学到什么
|
||||
==========================================================================
|
||||
|
||||

|
||||
|
||||
|
||||
某一天,我和我的一个机械工程师朋友聊天的时候。 他最近在做一个给半挂卡车的电子辅助刹车系统,他提到他们公司的办公室里都是 [Arduinos][1]。这主要是方便员工可以快速的对新的想法进行实验。他也提到了,Arduinos 其实比自己画电路板更加昂贵。对此,我感到非常震惊。因为我从软件行业得到的印象是 Arduinos 比定制电路板更加便宜。
|
||||
|
||||
我常常把 [Arduinos][2] 和 [Raspberry Pi][3] 看做是可以制作非常有趣设备的小型,Cool,特别的组件。我主要是从事软件行业,并且常常想让 Linux 在 x86 和 x86-64 设备上都可以执行一致。真相就是,Arduinos 并不特殊。实际上,他们非常通用。他们相当的小,便宜,但是非常得灵活。这就是为什么他们向野火一样流行起来。他们有所有种类的输入输出设备,和扩展卡。他们能让制作者快速的构建非常 Cool 的设备。他们甚至可以让公司可以快速的开发产品。
|
||||
|
||||
一整套 Arduino 的价格比批量生产的电路板高了很多,但是,看不见的时间成本却低了很多。当电路板大规模生产的时候,价格可以控制的很低,但是,之前的研发费用却高了很多。所以,长话短说,答案就是,使用 Arduino 划得来。
|
||||
|
||||
### Unikernel, Rump 内核,和容器主机
|
||||
|
||||
Unikernel, Rump 内核和迷你 Linux 发行版,这些操作系统是为了特有用途而构建的。这些特有的操作系统,某种程度上就像定制电路板。他们需要前期的研发,还需要为了工具化而设计,但是,当大规模部署的时候,他可以提供强大的性能。
|
||||
|
||||
迷你操作系统,例如:红帽企业版或者 CoreOS 是为了运行容器而构建的。他们很小,快速,并且很容易在启动时配置,并且运行容器非常良好。缺点就是他需要额外的工程量来添加第三方插件,比如监控客户端或者虚拟化的工具。一些工具也需要为了超级权限的容器而重新设计。 如果你正在构建一个巨大的容器环境,这些额外的工作量是划算的。但是,如果只是尝试,那就没必要了。
|
||||
|
||||
容器提供了运行标准化的工作流程 (比如使用 [glibc][4] 编译) 的能力。一个好处就是你可以在你的电脑上构建和测试这个工作单元 (Docker 镜像) 并且在完全不同的硬件上或者云端非常顺利的部署。而且保持着相同的特性。在生产环境中,容器的宿主机可以依旧被运维配置管理,但是应用被开发团队控制。这就是对两个团队来说最好的合作方式。
|
||||
|
||||
Unikernels 和 Rump 内核依旧是为了特定目标构建的,但是却更进一步。整个的操作系统在构建的时候就被开发或者架构师配置了。这带来了好处,同时还有挑战。
|
||||
|
||||
一个好处就是,开发人员可以控制这个工作流程的运转。理论上说,一个开发者可以为了不同的特性,尝试 [不同的 TCP 协议栈][5],并且选择最好的一个。在操作系统启动的时候,开发人也可以配置 IP 地址,而不是通过 DHCP。 开发人员也可以裁剪任何对于应用而言不需要的部分。这也是性能提升的保障,通过减少[不必要的上下文切换][6]。
|
||||
|
||||
同时,Unikernel 也带来了挑战。目前,有很大的工具缺口。 现在,和画板子的世界类似,开发人员需要花费很多时间和精力在检查是否有完整的库文件存在,不然的话,他们必须改变他们应用的执行方式。在如何让嵌入式操作系统在运行时配置的时候,也存在挑战。最后,每次操作系统的大改动,都需要[反馈到开发人员][7]来进行修改。这并没有一个在开发和运维之间明确的界限,所以我能想象,为了接受了这个开发流程,一些组织或者公司必须要改变。
|
||||
|
||||
### 结论
|
||||
|
||||
这也有一些有趣的传闻在专门的容器主机,Rump 内核和 Unikernel,因为,他们会带来一个特定工作流程的潜在变革(嵌入式,云,等等)。在这个令人激动又快速发展的领域请保持你的关注,但是也不要放松警惕。
|
||||
|
||||
目前,Unikernel 看起来和定制电路板很像。他们都需要前期的研发投资,并且都是独特的,可以为确定的工作流程带来好处。同时,容器甚至在常规的工作流中都非常有趣,而且他不需要那么多的投入。一个简单的例子,运维团队能方便的在容器上部署一个应用,但是在 Unikernel 上部署一个应用则需要重新设计和编码,而且业界并不能完全保证,这个工作流程可以被部署在 Unikernel 上。
|
||||
|
||||
容器,Rump 内核 和 Unikernel 有一个光明的未来!
|
||||
|
||||
--------------------------------------
|
||||
via: https://opensource.com/business/16/5/containers-unikernels-learn-arduino-raspberry-pi
|
||||
|
||||
作者:[Scott McCarty][a]
|
||||
译者:[MikeCoder](https://github.com/MikeCoder)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/fatherlinux
|
||||
[1]: https://opensource.com/resources/what-arduino
|
||||
[2]: https://opensource.com/life/16/4/arduino-day-3-projects
|
||||
[3]: https://opensource.com/resources/what-raspberry-pi
|
||||
[4]: https://en.wikipedia.org/wiki/GNU_C_Library
|
||||
[5]: http://www.eetasia.com/ARTICLES/2001JUN/2001JUN18_NTEK_CT_AN5.PDF
|
||||
[6]: https://en.wikipedia.org/wiki/Context_switch
|
||||
[7]: http://developers.redhat.com/blog/2016/05/18/3-reasons-i-should-build-my-containerized-applications-on-rhel-and-openshift/
|
||||
@@ -1,56 +1,57 @@
|
||||
Linux 的实用性 VS 行动主义
|
||||
==================================
|
||||
|
||||
>我们使用 Linux 是因为它比其他操作系统更实用,还是其他更高级的理由呢?
|
||||
*我们使用 Linux 是因为它比其他操作系统更实用,还是其他更高级的理由呢?*
|
||||
|
||||
其中一件关于运行 Linux 的最伟大的事情之一就是它所提供的自由。凡出现在 Linux 社区之间的划分在于我们如何珍惜这种自由。
|
||||
|
||||
一些人认为,通过使用 Linux 所享有的自由是从供应商锁定或高软件成本的自由。大多数人会称这个是一个实际的考虑。而其他用户会告诉你,他们享受的是自由软件的自由。那就意味着拥抱支持 [开源软件运动][1] 的 Linux 发行版,完全避免专有软件和所有相关的东西。
|
||||
运行 Linux 的最吸引人的事情之一就是它所提供的自由。 Linux 社区之间的划分在于我们如何看待这种自由。
|
||||
|
||||
对一些人来说,使用 Linux 可以享受不受供应商或高软件成本限制的自由。大多数人会称这个是一个实用性的考虑。而其他用户会告诉你,他们享受的是自由软件的自由。那就意味着拥护支持<ruby> [开源软件运动][1]<rt> Free Software Movement</rt> </ruby>的 Linux 发行版,完全避免专有软件和所有相关的东西。
|
||||
|
||||
在这篇文章中,我将带你比较这两种自由的区别,以及他们如何影响 Linux 的使用。
|
||||
|
||||
### 专有的问题
|
||||
|
||||
大多数的用户有一个共同的一点是他们的喜欢避免专有软件。对于像我这样的实际的爱好者来说,这是一个我怎么样花我的钱,来控制我的软件和避免供应商锁定的问题。当然,我不是一个程序员……所以我调整我的安装软件是十分温柔的。但也有一些个别情况,一个应用程序的小调整可以意味着它的工作和不工作的区别。
|
||||
大多数 Linux 用户有一个共同点,就是他们尽量避免使用专有软件。对像我这样的实用主义的爱好者来说,这意味着我能够控制我的软件支出,避免过度依赖特定供应商。当然,我不是一个程序员……所以我对安装软件的调整是十分微小的。但也有一些个别情况,一个应用程序的小调整可以意味着它能否正常工作。
|
||||
|
||||
还有就是选择避开专有软件的Linux爱好者,因为他们觉得这是不道德的使用。通常这里主要的问题是使用专有软件会带走或者干脆阻碍你的个人自由。像这些用户更喜欢使用的Linux发行版和软件来支持 [自由软件理念][2] 。虽然它类似于开源的概念并经常直接与之混淆,[这里有些差异][3] 。
|
||||
还有一些 Linux 爱好者,倾向于避开专有软件,因为他们觉得使用它们是不道德的。通常这里主要的问题是使用专有软件会剥夺或者干脆阻碍你的个人自由。像这些用户更喜欢使用 Linux 发行版和软件来支持 [自由软件理念][2] 。虽然它与开源的概念相似并经常直接与之混淆,[但它们之间还是有些差异的][3] 。
|
||||
|
||||
因此,这里有个问题:像我这样的用户往往以其便利掩盖了其纯软件自由的理想化。不要误会我的意思,像我这样的人更喜欢使用符合自由软件背后的理想软件,但我们也更有可能做出让步,以完成特定的任务。
|
||||
因此,问题就在这里:像我这样的用户往往将便利性置于纯粹的软件自由的理念之上。不要误会我的意思,像我这样的人喜欢使用符合自由软件理念的软件,但我们也更有可能做出让步(使用专有软件),以完成特定的任务。
|
||||
|
||||
这两种类型的 Linux 爱好者都喜欢使用非专有的解决方案。但是,自由软件倡导者根本不会去使用所有权,在那里作为实际的用户将依靠具有最佳性能的最佳工具。这意味着,在有些情况下的实际用户愿意来运行他们的非专有操作系统上的专有应用或代码实例。
|
||||
这两种类型的 Linux 爱好者都喜欢使用非专有软件的解决方案。但是,自由软件倡导者根本不会去使用专有软件,而实用主义用户会选择具有最佳性能的工具。这意味着,在有些情况下,这些用户会在他们的非专有操作系统上运行专有应用或代码。
|
||||
|
||||
最终,这两种类型的用户都喜欢使用 Linux 所提供的。但是,我们这样做的原因往往会有所不同。有人认为那些不支持自由软件的人是无知的。我不同意,我认为它是实用方便性的问题。那些喜欢实用方便性的用户根本不关心他们软件的政治问题。
|
||||
|
||||
### 实用方便性
|
||||
|
||||
当你问起绝大多数的人为什么使用他们现在的操作系统,回答通常都集中于实用方便性。这种关于方便性的例子可能包括“它是我一直使用的东西”、“它运行的软件是我需要的”。 其他人可能进一步解释说,并没有那么多软件影响他们对操作系统的偏好和熟悉程度,最后,有“利基任务”或硬件兼容性问题也提供了很好的理由让我们用这个操作系统而不是另一个。
|
||||
当你问起绝大多数的人为什么使用他们现在的操作系统,回答通常都集中于实用方便性。方便性可能体现在“它是我一直使用的系统”、“它运行了我需要的软件”。 其他人可能进一步解释说,软件对他们使用操作系统的偏好影响不大,而是对操作系统的熟悉程度,最后,还有硬件兼容性等问题也导致我们使用这个操作系统而不是另一个。
|
||||
|
||||
这可能会让你们中许多人很惊讶,但我今天运行的桌面 Linux 最大的一个原因是由于熟悉。即使我为别人提供对 Windows 和 OS X 的支持,但实际上我是相当沮丧地使用这些操作系统,因为它们根本就不是我记忆中的那样习惯用法。我相信这可以让我对那些 Linux 新手表示同情,因为我太懂得踏入陌生的领域是怎样的让人倒胃口了。我的观点是这样的 —— 熟悉具有价值。而且熟悉同样使得实用方便性变得有力量。
|
||||
这可能会让你们中许多人很惊讶,不过我今天运行桌面 Linux 最大的一个原因是由于我熟悉它。即使我为别人提供 Windows 和 OS X 的支持,实际上我使用这些操作系统时感觉相当沮丧,因为它们根本就不是我习惯的用法。也因此我对那些 Linux 新手表示同情,因为我太懂得踏入陌生的领域是怎样的让人恼火了。我的观点是这样的 —— 熟悉具有价值,而且熟悉加强了实用方便性。
|
||||
|
||||
现在,如果我们把它和一个自由软件倡导者的需求来比较,你会发现那些人都愿意学习新的东西,甚至更具挑战性,去学习那些若转化成为他们所避免使用的非自由软件。这就是我经常赞美的那种用户,我认为他们愿意采取最少路径来遵循坚持他们的原则是十分值得赞赏的。
|
||||
现在,如果我们把它和一个自由软件倡导者的需求来比较,你会发现那些人都愿意学习新的甚至更具挑战性的东西,以避免使用非自由软件。对这种用户,我最赞赏的地方,就是他们坚定的采取少数人选择的道路来坚持他们的原则,在我看来,这是十分值得赞赏的。
|
||||
|
||||
### 自由的价值
|
||||
|
||||
我不羡慕那些自由软件倡导者的一个地方,就是根据 [自由软件基金会][4] 所规定的标准需要确保他们可以一直使用 Linux 发行版和硬件,以便于尊重他们的数字自由。这意味着 Linux 内核需要摆脱专有的斑点的驱动支持和不需要任何专有代码的硬件。当然不是不可能的,但它很接近。
|
||||
我不羡慕那些自由软件倡导者的一个地方,就是根据<ruby> [自由软件基金会][4] <rt>Free Software Foundation</rt></ruby>规定的标准,为实现自由,他们要始终使用 Linux 发行版和硬件而带来的额外工作。这意味着 Linux 内核需要摆脱专有的驱动支持,而且硬件不需要任何专有代码。当然不是不可能的,但确实很难。
|
||||
|
||||
一个自由软件倡导者可以达到的最好的情况是硬件是“自由兼容”的。有些供应商,可以满足这一需求,但他们大多是提供依赖于 Linux 兼容专有固件的硬件。伟大的实际用户对自由软件倡导者来说是个搅局者。
|
||||
一个自由软件倡导者可以达到的最好的情况是硬件是“自由兼容”的。有些供应商,可以满足这一需求,但大多提供依赖于 Linux 兼容专有固件的硬件。实用主义用户对自由软件倡导者来说是个搅局者。
|
||||
|
||||
那么这一切意味着的是,倡导者必须比实际的 Linux 爱好者,更加警惕。这本身并不一定是消极的,但如果是打算用自由软件的方法来计算的话那就值得考虑了。通过对比,实用的用户可以专心地使用与 Linux 兼容的任何软件或硬件。我不知道你是怎么想的,但在我眼中是更轻松一点的。
|
||||
那么这一切意味着的是,倡导者必须比实用主义的 Linux 爱好者,更加警惕。这本身并不一定是坏事,但如果是打算跳入自由软件的阵营那就要考虑下了。比较而言,实用主义的用户可以不假思索地使用与 Linux 兼容的任何软件或硬件。我不知道你是怎么想的,但在我眼中这样更轻松一点。
|
||||
|
||||
### 定义自由软件
|
||||
|
||||
这一部分可能会让一部分人失望,因为我不相信自由软件只有一种。从我的立场,我认为真正的自由是能够在一个给定的情况里沉浸在所有可用的数据里,然后用最适合这个人的生活方式的途径来达成协议。
|
||||
这一部分可能会让一部分人不高兴,因为我不相信自由软件只有一种。从我的立场,我认为真正的自由是能够在一个特定情况下在所有可用的数据里,用最适合这个人生活方式的方法来解决。
|
||||
|
||||
所以对我来说,我更喜欢使用的 Linux 桌面,满足了我所有的需求,这包括使用非专有软件和专有软件。尽管这是公平的建议,专有的软件限制了我的个人自由,但我必须反驳这一点,因为我有选择用不用它,即选择的自由。
|
||||
对我来说,我更喜欢使用能满足我所有需求的 Linux 桌面,这包括使用非专有软件和专有软件。尽管有人认为专有软件限制了我的个人自由,但我必须反驳这一点,因为我有优先使用它的自由,即选择的自由。
|
||||
|
||||
或许,这也就是为什么我发现自己更确定开源软件的理想,而不是坚持自由软件运动背后的理念的原因。我更愿意和那些不会花时间告诉我,我是怎么用错了的那些人群在一起。我的经验是,那些开源的人群仅仅是感兴趣去分享自由软件的优点,而不是因为自由软件的理想主义的激情。
|
||||
或许,这也就是为什么我更认同<ruby>开源软件<rt> Open Source Software</rt></ruby>的理想,而不是坚持<ruby>自由软件运动<rt>Free Software movement</rt></ruby>的理念。我更愿意和这样的人群在一起,他们不会花时间告诉我,我使用对我最适合的方式却是错误的。根据我的经验,这些开源的人群仅仅是感兴趣去分享自由软件的优点,不带有自由软件的理想主义的激情。
|
||||
|
||||
我觉的自由软件的概念实在是太棒了。对那些需要活跃在软件政治,并指出使用专有软件的人的缺陷的人来说,那么我认为 Linux ( [GNU/Linux][5] ) 行动是一个不错的选择。在我们的介绍里,像我一样的实际用户更倾向于从自由软件的支持者改变方向。
|
||||
我觉得自由软件的概念很棒。而且对那些需要活跃在软件政治,并向大众指出使用专有软件的缺陷的人来说,我认为 Linux ( [GNU/Linux][5] ) 行动是一个不错的选择。而像我这样的实用主义用户可能从自由软件的支持者转向,如本文中所说。
|
||||
|
||||
当我介绍 Linux 的桌面时,我富有激情地分享它的实际优点。如果我成功地让他们享受这一经历,我鼓励用户自己去发现自由软件的观点。但我发现大多数人使用 Linux 并不是因为他们想拥抱自由软件,而仅仅是他们想要最好的用户体验。也许只有我是这样的观点,很难说。
|
||||
|
||||
你怎么认为呢?你是一个自由软件倡导者吗?也许你倾向于在桌面 Linux 发行版中使用专有软件/代码?那么评论和分享您的 Linux 桌面体验吧!
|
||||
|
||||
当我介绍 Linux 的桌面时,我富有激情地分享它的实际优点。而且我成功地让他们享受这一经历,我允许用户自己去发现自由软件的观点。但我发现大多数人使用的 Linux 不是因为他们想拥抱自由软件,而是因为他们只是想要最好的用户体验。也许只有我是这样的,很难说。
|
||||
|
||||
嘿!说你呢?你是一个自由软件倡导者吗?也许你是个使用桌面 Linux 发行专有软件/代码的粉丝?那么评论和分享您的 Linux 桌面体验吧!
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
@@ -59,7 +60,7 @@ via: http://www.datamation.com/open-source/linux-practicality-vs-activism.html
|
||||
|
||||
作者:[Matt Hartley][a]
|
||||
译者:[joVoV](https://github.com/joVoV)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[jasminepeng](https://github.com/jasminepeng)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
@@ -68,4 +69,4 @@ via: http://www.datamation.com/open-source/linux-practicality-vs-activism.html
|
||||
[2]: https://www.gnu.org/philosophy/free-sw.en.html
|
||||
[3]: https://www.gnu.org/philosophy/free-software-for-freedom.en.html
|
||||
[4]: https://en.wikipedia.org/wiki/Free_Software_Foundation
|
||||
[5]: https://en.wikipedia.org/wiki/GNU/Linux_naming_controversy
|
||||
[5]: https://en.wikipedia.org/wiki/GNU/Linux_naming_controversy
|
||||
|
||||
@@ -5,49 +5,44 @@
|
||||
|
||||

|
||||
|
||||
尽管苹果公司将在 iPhone 7 上面取消耳机插口的传言早就有了,但是在上周苹果公司的公告证实了
|
||||
这个消息后,它还是成为了一个热门话题。
|
||||
尽管苹果公司将在 iPhone 7 上面取消耳机插口的传言早就有了,但是在上周苹果公司的公告证实了这个消息后,它还是成为了一个热门话题。
|
||||
|
||||
对于那些不知道这个最新消息的人,关于苹果公司已经在手机上面移除了耳机接口,耳机可以通过闪电接口插入手机。如果他们还想在手机上面使用现有的耳机,他们需要一个适配器将耳机通过闪电接口与手机连接。苹果公司也将出售一款新产品:AirPods。它们被戴入你的耳朵后通过无线和手机连接。耳机通过无线和手机连接带来的最大的好处是通过舍弃耳机接口来让手机保持进一步的干燥和防水。
|
||||
对于那些不知道这个最新消息的人再介绍下,苹果公司已经移除了手机上的耳机接口,改为通过闪电接口插入手机。随手机销售的除了闪电接口耳机外,还有一个适配器,如果人们还想在手机上使用现有的耳机,可以使用它。苹果公司也将出售一款新产品:AirPods。它们被戴入你的耳朵后通过无线和手机连接。舍弃耳机接口的最大的好处是能够让手机保持干燥和防水。
|
||||
|
||||
现在苹果公司将在 iPhone 7 上面取消耳机接口已经是一个重大新闻了,我们询问我们的作者,“你怎么看待智能机取消耳机接口?”
|
||||
|
||||
### 我们的观点
|
||||
|
||||
Derrik 认为“苹果公司的这种取消手机耳机接口的行为将会促使更多昂贵的外围设备不再遵循公开标准。”他也不想每使用五个小时就不得不给 AirPods 充电。尽管他知道 3.5毫米 的耳机接口逐渐过时,但作为一个“发烧友”,他更喜欢一种新的,开放的标准,但“盈利性企业的推动”让他担心设备的自由性。
|
||||
|
||||
Derrik 认为“苹果公司的这种取消手机耳机接口的行为是为了推进更多昂贵的不遵循公开标准的外围设备。”他也不想每使用五个小时就不得不给 AirPods 充电。尽管他知道 3.5毫米 的耳机接口逐渐过时,作为一个“音质发烧友”,他喜欢新的,开放的标准,但“盈利性企业的推动”让他担心设备的自由性。
|
||||
|
||||

|
||||
|
||||
Damien 在自从有了蓝牙耳机后的这段日子里基本不怎么使用耳机接口了。总之,他讨厌有线耳机的电线,所以他认为“移除手机耳机接口的做法非常好。”当然他也理解 Derrik 抱怨无线耳机耗尽电源后需要充电会带来不方便,但是无线耳机会给他一种“没有东西靠在身上”的感觉。
|
||||
Damien 在自从有了蓝牙耳机后的这段日子里基本不怎么使用耳机接口了。总之,他讨厌有线耳机的电线,所以他认为“移除手机耳机接口的做法非常好。”当然他也理解 Derrik 抱怨无线耳机耗尽电源后需要充电会带来不方便,给他一种“没有依靠”的感觉。
|
||||
|
||||
Trevor 直接了当地表明自己认为智能手机移除耳机接口是一种非常愚蠢的做法,当他了解到 iPhone 7 无法在给手机充电的同时使用耳机后,更加坚信智能手机移除耳机接口是非常愚蠢的做法。他总是使用有线耳机来听音乐或者看视频,从不用蓝牙耳机。因为蓝牙耳机会加速手机电量的消耗,所以他用有线耳机。
|
||||
Trevor 直接了当地表明自己认为智能手机移除耳机接口是一种愚蠢的做法,当他了解到 iPhone 7 无法在给手机充电的同时使用耳机后,认为“愚蠢加倍”。他总是使用有线耳机来听音乐或者看视频,从不用蓝牙耳机。因为蓝牙耳机会加速手机电量的消耗,所以他用有线耳机。
|
||||
|
||||
Simon 并不是有线耳机的忠诚用户。他并没有见过太多为了留出更多空间而移除耳机接口的手机产品。他认为“智能手机是否取消耳机接口应该看消费者是喜欢为了提高手机防水性采用无线耳机 AirPods,还是喜欢耳机通过适配器连接到手机或者将有线耳机通过耳机插口直接和智能手机连接”。他认为不应该这么快就移除智能机的耳机接口,他更喜欢公共的可以适配所有的标准。
|
||||
Simon 并不是有线耳机的忠诚用户。他并没有见过太多为了留出更多空间而移除耳机接口的手机产品。他认为“接下来要看顾客是喜欢无线耳机、适配器、防水塞,还是 AirPods,闪电接口或适配器”。他认为不应该这么快就移除智能机的耳机接口,他更喜欢公共的可以适配所有的标准。
|
||||
|
||||
James 认为现在的无线技术已经足够成熟,所以他认为 iPhone 7 移除耳机接口是一个不错的策略,因为这也能够促进苹果公司硬件产品的销量。他偶尔使用过昂贵的有线耳机,所以就个人经历而言他注意到自己的 Xperia 智能手机虽然有耳机插口但是防水性也不差。
|
||||
James 认为现在的无线技术已经足够成熟,所以他认为 iPhone 7 移除耳机接口是一个不错的策略,因为这也能够促进苹果公司硬件产品的销量。他碰巧使用过昂贵的有线耳机,所以就个人经历而言“还没有被说服,”他表示自己的 Xperia 智能手机虽然有耳机插口但是防水性也不差。
|
||||
|
||||
Jeffry 指出“几乎全世界所有在科技领域的过渡性尝试都是在无法受益于这些尝试而产生的强烈的反对意见中开始的。”,他还记得苹果公司因为移除软盘驱动器和不支持 Flash 曾遭到大量的抨击,但现在移除软盘驱动器和不支持 Flash 已经成为行业规范了。他坚信一切都是为了更好的发展而慢慢演变的,智能机移除耳机接口只是步入未来的一小步,而苹果公司这么做是在勇敢的引导未来智能机的一种走向,顺便通过卖无线耳机赚点钱。
|
||||
Jeffry 指出“几乎全世界所有科技领域的过渡性尝试,都是在无法从这些尝试中受益的人的强烈反对意见中开始的。”他还记得苹果公司因为移除软盘驱动器和不支持 Flash 曾遭到大量的抨击,但现在两者都已经成为行业规范了。他坚信一切都是为了更好的发展而慢慢演变的,智能机移除耳机接口只是“步入未来的一小步”,而苹果公司“足够勇敢来引导未来智能机的一种走向(顺便通过此方式赚点钱)”。
|
||||
|
||||
|
||||

|
||||
|
||||
Vamsi 并不介意智能手机耳机接口的移除只要有一个更好的解决方案适用于使用不同类型的耳机和其他的设备与智能手机的连接。他并没有感觉到通过闪电接口使用耳机是一个不错的解决方案,因为这使得几乎所有的其他耳机过时。至于蓝牙耳机,他只是不想再使用另外一个设备。此外,他不想争论使用无线耳机可以提高智能手机的防水性能,因为已经存在不少带有耳机接口的智能手机防水性能也不错。
|
||||
Vamsi 并不介意耳机接口的移除,只要“有一个更好的解决方案,适用于使用不同类型耳机和其他的设备的用户”。他不认为通过闪电接口使用耳机是一个不错的解决方案,因为这使得几乎所有的其他耳机废弃。至于蓝牙耳机,他只是不想再使用另外一个设备。此外,他不想争论使用无线耳机可以提高手机的防水性能,因为已经存在不少带有耳机接口的设备防水性能也不错。
|
||||
|
||||
Mahesh 更喜欢用带有耳机接口的智能手机,因为这样他可以经常再给手机充电的同时听音乐。他认为我们将会在接下来的几个月看到移除耳机接口的智能手机给用户带来的诸多不方便之处。
|
||||
|
||||
Derrik 也不赞同“移除开放标准的接口,使用专有连接”。你可能认为可以通过适配器来使耳机连接手机,但是雷电接口可以被随时关闭,苹果公司也能够随时停止这些适配器的销售。他也指出AirPods 不会取代蓝牙耳机。
|
||||
Mahesh 更喜欢用带有耳机接口的智能手机,因为他经常在给手机充电的同时听音乐。他认为我们将会在接下来的几个月看到移除耳机接口后给用户带来的诸多不方便之处。
|
||||
|
||||
Derrik 也不赞同“移除开放标准的接口,使用专有连接”。你可能认为可以通过适配器来使耳机连接手机,但是雷电接口可以被随时关闭,苹果公司也能够随时停止这些适配器的销售。他也指出 AirPods 不会取代蓝牙耳机。
|
||||
|
||||
|
||||

|
||||
|
||||
至于我,我会在两方面来考虑这个事情:新技术和苹果公司产品的其他方面。自从 iPhone系列 第一款的出售以来,我一直都在使用 iPhone 系列手机。但从 2012 年我用 iPhone 5 开始,我没有对手机进行任何更新,所以我是有些过时的。我会是第一批买 iPhone 7 的人。我讨厌白色的耳机线在我脸旁,这让我感觉看上去会很蠢,所以我可能会选择 AirPods 在某种情况下。我很欣赏手机防水性能变得更好。至于充电时间和通话时间,我并不认为 iPhone 7 续航时间短会影响到我对 iPhone 7 的购买,尽管我的旧 iPhone 5 的续航时间都可以达到 12到20个小时之间。所以我确定这不会影响到我要购买 iPhone 7。
|
||||
至于我,我会在两方面来考虑这个事情:新技术和苹果公司产品的其他方面。自从 iPhone 系列第一款出售以来,我一直都在使用 iPhone 系列手机。但从 2012 年我用 iPhone 5 开始,我没有更换过手机,所以我是有些过时的。我会是第一批买 iPhone 7 的人。我讨厌白色的耳机线在我脸旁,所以我也可能会选择 AirPods。我很欣赏手机防水性能变得更好。至于同时充电和收听的问题,新手机续航时间足够长,所以我不认为这是什么大问题。即使我的旧 iPhone 5 手机,续航时间都可以达到 12 到 20 个小时之间。所以我不认为这是一个问题。
|
||||
|
||||
### 你的观点
|
||||
|
||||
Our writers have given you a lot to think about. What are your thoughts on Smartphones doing away with the headphone jack? Will you miss it? Is it a deal breaker for you? Or do you relish the upgrade in technology? Will you be trying the iPhone 5 or the AirPods? Let us know in the comments below.
|
||||
|
||||
我们的作者已经给了你很多他们对于智能手机移除耳机接口的看法。你怎么看待智能手机移除耳机接口?你会忽略智能手机移除耳机接口可能对你带来的影响吗?智能手机是否移除耳机接口会影响你的智能手机购买选择吗?你是会尝试使用 iPhone 5 还是使用 AirPods?让我们在评论区了解你的看法。
|
||||
我们的作者已经给了你很多他们对于智能手机移除耳机接口的看法。你怎么看待这件事?你会想念耳机接口吗?你会从此技术更新中获得乐趣吗?你是会尝试使用 iPhone 5 还是使用 AirPods?让我们在评论区了解你的看法。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@@ -55,7 +50,7 @@ via: https://www.maketecheasier.com/should-smartphones-do-away-with-the-headphon
|
||||
|
||||
作者:[Laura Tucker][a]
|
||||
译者:[WangYueScream](https://github.com/WangYueScream) [LemonDemo](https://github.com/LemonDemo)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[jasminepeng](https://github.com/jasminepeng)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
安卓编年史
|
||||
================================================================================
|
||||

|
||||
重新设计的拨号和联系人页面。
|
||||
Ron Amadeo供图
|
||||
|
||||
联系人/拨号应用程序的圆角标签拥有了更清晰,更成熟的外观设计。拨号器更名为“电话”,并且拨号按键从圆形改为了圆角矩形。语音邮件,拨号,以及删除的按键被放置在底部。这个界面是安卓在3.0之前缺乏设计一致性的一个很好的例子。仅仅在这个界面上,标签用的是直角矩形,拨号按键使用圆角矩形,底部按键两侧合起来是个完整的圆。这里就像是个UI控件的摸奖袋,没有人尝试过让它们之间相互搭配。
|
||||
|
||||
安卓2.0的一个新特性是“快速拨号”,它将联系人以略缩图的形式添加到整个系统。从其它应用中点击它们可以打开一个联系这个人的快捷方式列表。这在联系人里并没有多大意义,但像在Google Talk中,能够通过点击某人的略缩图来给他拨号是十分方便的。
|
||||
|
||||

|
||||
Ron Amadeo供图
|
||||
|
||||
安卓2.0终于配备了接通和拒绝来电所需要的所有屏幕按键,而不再需要实体按钮,Droid从中获益,从它的设计中除去了在现在看来是多余的按钮。安卓对于接通和拒绝来电的解决方案是这些左滑和右滑的标签。他们的工作方式就像是滑动解锁(后来被用到了滑动解锁中)——向右滑动绿色按钮接通来电,向左滑动红色按钮则是拒绝。一旦进入通话中,它看起来就很像安卓1.6了。所有选项还是隐藏在菜单按钮之中。
|
||||
|
||||
某人在设计拨号界面的时候一定在煲电话粥。他们只是去掉了“拨号盘”上字母的粗体,而不是从安卓1.6中重新绘制数字“5”的按键,然后就这么收工了。
|
||||
|
||||

|
||||
计算器和浏览器。
|
||||
Ron Amadeo供图
|
||||
|
||||
计算器从在安卓0.9中被引入以来第一次得到改进。黑色玻璃球按钮换成了渐变色的蓝色和黑色的按钮。旧版计算器点击状态疯狂的红色高亮被改为了一个比较正常的白色轮廓。
|
||||
|
||||
浏览器的微型网站名称栏改进为一个完整的,功能更完善的地址栏,并且带有书签按钮。为了节省屏幕空间,地址栏被附加到网页上,所以地址栏会随着页面向上滚动,给你留下更多的网页阅读空间。安卓1.6独特的缩放控制和附加按钮被去除,被替换为一个更简单的双击缩放手势,并且浏览器可以再次打开arstechnica.com而不崩溃。这里还是没有双指捏合缩放。
|
||||
|
||||

|
||||
打开设置的相机,闪光灯设置,以及查看照片界面的菜单。
|
||||
Ron Amadeo供图
|
||||
|
||||
相机应用获得整个左侧的抽屉式菜单,打开它有许多设置。摩托罗拉Droid是第一款带有LED闪光灯的安卓手机之一,所以设置里有个闪光灯控制,以及还有像场景模式,白平衡,效果,图片尺寸和存储位置(SD卡或内置存储)的设置。
|
||||
|
||||
在照片查看界面,谷歌精简了菜单按钮。和屏幕上的选项相比,它们之间不再有重复的选项。这样精简后省下的空间,使得所有的选项能够在菜单里放得下了,而不再需要一个“更多”按钮。
|
||||
|
||||

|
||||
电子邮件应用的“帐户”页面,新的联合收件箱,系统设置的帐户与同步页面,自动亮度设置。
|
||||
Ron Amadeo供图
|
||||
|
||||
电子邮件应用程序有个大的功能提升。最重要的是它终于支持了Microsoft Exchange。安卓2.0版本的电子邮件中收件箱和文件夹视图终于分开了,而不是使用安卓1.0引入的凌乱的混合视图。电子邮件甚至有了一个统一的收件箱,可以将你不同账户的所有邮件显示到一起。
|
||||
|
||||
这个收件箱视图和Gmail一起,把普通的电子邮件应用打趴下了。联合收件箱甚至胜过了Gmail的功能,这是极其罕见的。尽管如此,相对于Gmail来说,电子邮件仍然感觉像个多余的继女。它使用了Gmail界面来查看邮件,这意味着收件箱和文件夹使用了黑色主题,查看邮件却奇怪地选择了亮色主题。
|
||||
|
||||
捆绑的Facebook应用程序有一个很棒的账户同步功能,它可以从社交网络上下载联系人的照片和信息,并无缝集成到联系人应用里。后来Facebook和谷歌分道扬镳,[谷歌取消了这一功能][1]。谷歌表示,在Facebook不向其共享信息的情况下,与Facebook分享信息并不是什么好想法,因此更好的用户体验败给了公司间的政治斗争。
|
||||
|
||||
(不幸的是,我们无法展示Facebook应用,因为它也是死在OAuth更新手中的客户端之一。现在不可能从像这么老旧的应用上登录了。)
|
||||
|
||||
最后一张图片显示了自动亮度控制,安卓2.0是第一个支持这一功能的版本。Droid配备了光线传感器,点击该复选框,会使亮度滑块消失,并且允许设备自动控制屏幕亮度。
|
||||
|
||||
正如它的名字所暗示的那样,安卓2.0是谷歌有史以来最大的更新。摩托罗拉和威瑞森给安卓带来了一个外形酷炫的设备,并在广告上投入了数不清的资金。之后的一段时间里,“Droid”成为了一个家喻户晓的名字。
|
||||
|
||||
### The Nexus One——迎来Google Phone ###
|
||||
|
||||

|
||||
|
||||
2010年1月,第一款Nexus设备发布,称为“[Nexus One][2]”。对谷歌来说,这部设备是个巨大的里程碑。这是第一部由谷歌设计并冠名的设备,而且谷歌计划直接向消费者出售设备。宏达电代工的Nexus One拥有1GHz的单核高通骁龙S1处理器,512MB的内存,512MB存储空间,以及一块3.7英寸的AMOLED显示屏。
|
||||
|
||||
Nexus One注定拥有纯净的安卓体验,没有运营商的定制和应用植入。谷歌直接控制安卓的更新。这使得谷歌能够在软件完成时直接向用户进行推送, 而不是再经过运营商的许可。运营商总是拖慢这一过程,因为他们对用户已经付过钱手机并不总是那么热切地想要改善它们。
|
||||
|
||||
谷歌[直接在网上][3]销售Nexus One,无锁,无合约,完整零售价529.99美元。尽管同样的Nexus One在T-Mobile商店的合约价仅为179.99美元,谷歌想通过它的在线商店改变美国手机行业的运作方式。谷歌当时的想法是先挑选手机,再选择运营商,以此打破美国无线寡头对硬件的控制。
|
||||
|
||||
但谷歌的零售革命并没有奏效,在在线手机商店开通半年后,谷歌关闭了该服务。谷歌指出首要问题是销量低。在2010年,网上购物并不像今天这样司空见惯,消费者也还没有准备好在他们不能先握在自己手中试用的设备上花费530美元。高昂的价格也是一个制约因素;智能手机消费者更习惯于为眼前的设备花费200美元,并签署一项为期两年的合同。还有摩托罗拉Droid的因素,相比之下这部三个月前发布的设备并没有显著的不足。还由于Droid的庞大的营销活动和“iPhone杀手”的炒作,它已经夺取了大多数Nexus One面向的安卓发烧友市场。
|
||||
|
||||
尽管Nexus One的网上销售尝试可以被认为是失败的,谷歌还是从中学到了很多。2012年,谷歌以Google Play的“设备”板块[重新推出其网上商店][4]。
|
||||
|
||||
----------
|
||||
|
||||

|
||||
|
||||
[Ron Amadeo][a] / Ron是Ars Technica的评论编缉,专注于安卓系统和谷歌产品。他总是在追寻新鲜事物,还喜欢拆解事物看看它们到底是怎么运作的。
|
||||
|
||||
[@RonAmadeo][t]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://arstechnica.com/gadgets/2014/06/building-android-a-40000-word-history-of-googles-mobile-os/11/
|
||||
|
||||
译者:[alim0x](https://github.com/alim0x) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://techcrunch.com/2011/02/22/google-android-facebook-contacts/
|
||||
[2]:http://arstechnica.com/gadgets/2010/01/nexus-one-review/
|
||||
[3]:http://arstechnica.com/gadgets/2010/01/googles-big-news-today-was-not-a-phone-but-a-url/
|
||||
[4]:http://arstechnica.com/gadgets/2012/04/unlocked-samsung-galaxy-nexus-can-now-be-purchased-from-google/
|
||||
[a]:http://arstechnica.com/author/ronamadeo
|
||||
[t]:https://twitter.com/RonAmadeo
|
||||
@@ -1,342 +0,0 @@
|
||||
Excel “过滤和编辑” - Pandas中的示范操作
|
||||
==================================================
|
||||
|
||||

|
||||
|
||||
### 介绍
|
||||
|
||||
我听许多人说我[之前的关于pandas处理一般的Excel任务][1]的文章对于帮助新的pandas用户将Excel任务转化成对应的pandas代码是有用的。这边文章将会保持那个传统通过介绍不同的pandas使用Excel的过滤功能作为一个模型进行索引的例子来理解这样的处理。
|
||||
|
||||
大多数pandas的新手首先学到的东西就是基本的数据过滤。即使在过去的时间中使用pandas工作持续数月,我最近意识到我没有在我每天的工作中使用的pandas过滤的方法还有另外一个好处。也就是说,你可以在一个给定的列上过滤,但更新另一组列通过使用一个简化的pandas的语法。这和我所说的Excel中的“过滤和编辑”很像。
|
||||
|
||||
这篇文章将会介绍一些过滤一个pandas数据帧同时更新各种标准的例子。同时,我将解释关于panda的索引和如何使用索引功能例如 .loc , .ix和 .iloc来简单快速的更新一个基于简单或者是复杂标准的数据子集。
|
||||
|
||||
### Excel: “过滤与编辑”
|
||||
|
||||
在数据透视表以外,在EXCEL工具的顶部是一过滤器。这个简单的工具允许用户通过不同的数据,文本与格式标准去快速过滤与排序数据。这里是由几个不同的条件过滤数据产生的样本数据的基本截图:
|
||||
|
||||

|
||||
该过滤过程是直观的,即使是最新手的用户,也很容易掌握。我也注意到,人们将使用此功能来选择行的数据,然后根据行的标准更新额外的列。下面的例子显示了我所描述的情形:
|
||||
|
||||

|
||||
|
||||
在这个例子中,我过滤了Account Number, SKU和Unit Price的数据。接着我手工增加了Commission_Rate这列并且在每个单元格中输入0.01。这种方法的好处是可以很容易理解和管理有联系的复杂数据而不用写长Excel公式或者进入VBA。这种方法的缺点是,它是不可重复的,同时,对于从外面入门的人了解哪些标准被用于任何过滤器可能是困难的。
|
||||
|
||||
例如,假设你看相关的截图,如果不看每一列数据,没有明显的方法去知道什么被过滤了。幸运的是,我们可以在pandas中完成相似操作。不奇怪的是,在pandas中使用简单干净的代码来执行“过滤和编辑”模式是简单的。
|
||||
|
||||
|
||||
### 布尔检索
|
||||
|
||||
现在,我想通过pandas中一些布尔索引的细节来使你对这个问题有点感觉。
|
||||
如果你想要去理解pandas的在大部分广泛的[索引和数据选择][3]这是一个重要的概念去理解。这种想法可能看起来有点复杂,对新的pandas用户(可能对经验丰富的用户来说太基础),但我认为重要的是要花一些时间,了解它。如果你掌握了这一概念,用pandas进行数据工作的基本过程将更简单。
|
||||
|
||||
pandas支持索引(或者选择数据)通过使用标签,基于数字的位置或者一个布尔值的队列(True/False)。使用一个布尔值的列表来选择一个行被称为布尔索引,将是本文其余部分的重点。
|
||||
|
||||
我发现,我的pandas的工作流程往往侧重于使用布尔值的列表选择我的数据。换句话说,当我创建了pandas数据帧,我倾向于保持默认的索引在数据框架。因此,索引本身并不具有真正意义,同时也不是简单的选择数据。
|
||||
|
||||
|
||||
|
||||
>关键点
|
||||
> pandas中布尔索引是一个(几个)选择行的数据的强大的和有用的方法。
|
||||
|
||||
让我们看一些例子,数据框架帮助澄清布尔指标在pandas中做的是什么。
|
||||
|
||||
首先,我们将创建一个非常小的数据帧仅仅从一个Python的列表获得并使用它来展示布尔检索是如何工作的。
|
||||
|
||||
|
||||
```
|
||||
import pandas as pd
|
||||
sales = [('account', ['Jones LLC', 'Alpha Co', 'Blue Inc', 'Mega Corp']),
|
||||
('Total Sales', [150, 200, 75, 300]),
|
||||
('Country', ['US', 'UK', 'US', 'US'])]
|
||||
df = pd.DataFrame.from_items(sales)
|
||||
```
|
||||
|
||||
|account |Total Sales |Country
|
||||
:--|:-- |:-- |:
|
||||
0 |Jones LLC |150 |US
|
||||
1 |Alpha Co |200 |UK
|
||||
2 |Blue Inc |75 |US
|
||||
3 |Mega Corp |300 |US
|
||||
|
||||
注意值0-3,是怎么样会自动分配给行?这些都是指数,在这个数据集它们不是特别有意义的,但对pandas是有用的,重要的是要了解如下其他没有描述的使用情况下。
|
||||
|
||||
当我们引用布尔索引时,我们只是说,我们可以通过一个真实或错误的值的列表表示我们要查看的每一行。
|
||||
|
||||
|
||||
在这种情况下,如果我们想查看Jones有限责任公司,Blue公司和Mega公司的数据,我们可以看到,True False名单会看起来像这样:
|
||||
|
||||
```
|
||||
indices = [True, False, True, True]
|
||||
```
|
||||
它应该是毫不奇怪,你可以通过把这个列表,传入你的数据,你就看到它只会显示帧中我们的值是True的行:
|
||||
|
||||
```
|
||||
df[indices]
|
||||
```
|
||||
|
||||
|account |Total Sales |Country
|
||||
:--|:--|:--|:--
|
||||
0 |Jones LLC |150 |US
|
||||
2 |Blue Inc |75 |US
|
||||
3 |Mega Corp |300 |US
|
||||
|
||||
这里是一个刚刚发生的操作图像:
|
||||
|
||||

|
||||
|
||||
手工的列表创建索引是工作的。但是显然对任何一个超过微不足道的数据集不是可扩展或是很有用的。幸运的是,pandas就可以用一个简单的查询语言,有熟悉用Python创建这些布尔指标应该很容易(或任何语言)。
|
||||
|
||||
例如,让我们看看来自美国的所有销售线。如果我们执行的Python表达式基于Country列:
|
||||
|
||||
|
||||
```
|
||||
df.Country == 'US'
|
||||
```
|
||||
|
||||
```
|
||||
0 True
|
||||
1 False
|
||||
2 True
|
||||
3 True
|
||||
Name: Country, dtype: bool
|
||||
```
|
||||
|
||||
这个例子显示了pandas如何将你的Python的传统逻辑,把它应用到一个数据帧并返回一个布尔值列表。那么这个布尔值的列表可以通过帧的数据获取相应的行。
|
||||
|
||||
在真正的代码中,你不需要做这两个步骤。简洁的做这事的方法典型的看上去如下:
|
||||
|
||||
```
|
||||
df[df["Country"] == 'US']
|
||||
```
|
||||
|
||||
|account |Total Sales |Country
|
||||
:--|:--|:--|:--
|
||||
0 |Jones LLC |150| US
|
||||
2 |Blue Inc |75 |US
|
||||
3 |Mega Corp| 300| US
|
||||
|
||||
虽然这个概念很简单,你可以编写非常复杂的逻辑,使用Python的威力过滤数据。
|
||||
|
||||
|
||||
>关键点
|
||||
>在这个例子中, `df[df.Country == 'US']` 等价于 `df[df["Country"] == 'US']` ‘.’ 标记法是简洁的但是在你列名有空格时不会工作。
|
||||
|
||||
|
||||
### 选择需要的列
|
||||
|
||||
现在,我们已经找到了如何选择行的数据,我们如何控制哪些列显示?在上面的例子中,没有明显的方法去做。Pandas能使用三种基于位置的索引支持这个用法:.loc , iloc , 和 .ix . 。这些功能也允许我们选择除了我们所看到的行挑选列。
|
||||
|
||||
|
||||
|
||||
在这里有很大的困惑关于什么时候选择使用 .loc , iloc , 或者是 .ix。 快速总结的区别是:
|
||||
|
||||
- .loc 用于标签索引
|
||||
- .iloc 用于基于整数的位置
|
||||
- .ix 是一个将尝试使用标签的快捷方式 (like .loc ) 但失败后将回落到基于位置的整数 (like .iloc )
|
||||
|
||||
因此问题是我该使用哪个?我必须坦诚我有的时候也会被这些搞混.我发现我最常使用 .loc 。主要是因为我的数据不适合于有意义的基于位置的索引(换句话说,我很少发现自己需要使用 .iloc ) 所以我坚持使用 .loc。
|
||||
|
||||
公平讲,每一个方法都有自己的位置,在许多情况下都是有用的。特别的一个场景是当处理多指标数据帧时。我不会在这篇文章中讨论那个话题-也许在未来的博文会说。
|
||||
|
||||
现在我们已经涵盖了这样一个话题,让我们来展示如何筛选一行的值的数据帧,具体选择要显示的列。
|
||||
|
||||
继续我们的例子,如果我们只是想显示对应于我们的指数的帐户名称,该怎么做?使用.loc很简单:
|
||||
|
||||
|
||||
```
|
||||
df.loc[[True, True, False, True], "account"]
|
||||
```
|
||||
|
||||
```
|
||||
1 Alpha Co
|
||||
2 Blue Inc
|
||||
3 Mega Corp
|
||||
Name: account, dtype: object
|
||||
```
|
||||
|
||||
如果你想看到多个列,只需通过一个列表:
|
||||
|
||||
```
|
||||
df.loc[[True, True, False, True], ["account", "Country"]]
|
||||
```
|
||||
|
||||
| account |Country
|
||||
:--|:--|:--
|
||||
0 |Jones LLC| US
|
||||
1 |Alpha Co |UK
|
||||
3 |Mega Corp |US
|
||||
|
||||
真正的威力是当你在你的数据上创建更复杂的查询。在这种情况下,让我们展示所有的帐户名称和销售> 200的国家:
|
||||
|
||||
```
|
||||
df.loc[df["Total Sales"] > 200, ["account", "Country"]]
|
||||
```
|
||||
|
||||
|account| Country
|
||||
:--|:--|:--
|
||||
3 |Mega Corp| US
|
||||
|
||||
这个过程可以被认为有点相当于我们上面讨论过的Excel的过滤器。你已经加入了额外的好处,你也可以限制你检索的列数,而不仅仅是行。
|
||||
|
||||
|
||||
### 编辑列
|
||||
|
||||
所有这些都是好的背景,但当你使用一个类似的方法来更新一个或多个列的基础上的行选择这个过程真的是闪光的。
|
||||
|
||||
|
||||
一个简单的例子,让我们增加一个佣金率列到我们的数据:
|
||||
|
||||
```
|
||||
df["rate"] = 0.02
|
||||
```
|
||||
|
||||
| account |Total Sales| Country |rate
|
||||
:--|:--|:--|:--|:--
|
||||
0 |Jones LLC |150 |US |0.02
|
||||
1 |Alpha Co |200 |UK |0.02
|
||||
2 |Blue Inc |75 |US |0.02
|
||||
3 |Mega Corp |300 |US |0.02
|
||||
|
||||
让我们说,如果你卖了超过100,你的利率是5%。基本的过程是设置一个布尔索引来选择列,然后将该值赋给利率列:
|
||||
|
||||
|
||||
```
|
||||
df.loc[df["Total Sales"] > 100, ["rate"]] = .05
|
||||
```
|
||||
|
||||
| account |Total Sales| Country| rate
|
||||
:--|:--|:--|:--|:--
|
||||
0 |Jones LLC |150| US| 0.05
|
||||
1 |Alpha Co |200 |UK |0.05
|
||||
2| Blue Inc |75| US |0.02
|
||||
3 |Mega Corp |300| US| 0.05
|
||||
|
||||
希望如果你看过这篇文章,这将是有意义的,它会帮助你理解这个语法是如何工作的。现在你有了“过滤和编辑”方法的基本原理。最后一节将更详细的在Excel和pandas显示这个过程。
|
||||
|
||||
|
||||
### 将这些合并在一起
|
||||
|
||||
对于最后的例子,我们将创建一个简单的佣金计算器,使用以下规则:
|
||||
|
||||
- 所有的佣金计算在交易水平
|
||||
- 所有销售的基础佣金为2%
|
||||
- 所有衬衫都将获得2.5%的佣金
|
||||
- 一个特殊的程序正在进行中,在一个交易中销售的数额>10带得到4%的佣金
|
||||
- 所有在一个单一的交易鞋类销售> 1000美元有一个特别的奖金为250美元加上一个4.5%的的佣金
|
||||
|
||||
为了在Excel做到这一点,使用的过滤器和编辑方法:
|
||||
|
||||
- 添加一个2%的佣金列
|
||||
- 添加一个0美元的奖金列
|
||||
- 衬衫上的过滤器,并将vale改为2.5%
|
||||
- 清楚过滤器
|
||||
- 带和数量的过滤器>10和将值更改为4%
|
||||
- 清除过滤器
|
||||
- 鞋类过滤器> 1000美元,并增加佣金和奖金价值分别为4.5%和250美元
|
||||
|
||||
|
||||
我不会显示每一步的屏幕快照,但这里是最后一个过滤器的屏幕快照:
|
||||
|
||||

|
||||
|
||||
这种方法很简单,可以在很好的操作,但它不具备很好的可重复性,也不能审核。当然还有其他的方法,如在Excel公式或VBA实现这些。然而,这种过滤器和编辑的方法是常见的,是说明性的pandas的逻辑。
|
||||
|
||||
现在, 让我们在pandas中运行这个例子.
|
||||
|
||||
首先,读入[Excel 文件][4]同时加入默认值2%的利息一列:
|
||||
```
|
||||
import pandas as pd
|
||||
df = pd.read_excel("https://github.com/chris1610/pbpython/blob/master/data/sample-sales-reps.xlsx?raw=true")
|
||||
df["commission"] = .02
|
||||
df.head()
|
||||
```
|
||||
|
||||
| account number| customer name| sales rep| sku |category |quantity |unit price| ext price| date| commission
|
||||
:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--
|
||||
0 |680916 |Mueller and Sons |Loring Predovic |GP-14407 | Belt |19 |88.49 |1681.31 |2015-11-17 05:58:34| 0.02
|
||||
1 |680916 |Mueller and Sons |Loring Predovic |FI-01804| Shirt |3| 78.07| 234.21 |2016-02-13 04:04:11 |0.02
|
||||
2 |530925 |Purdy and Sons| Teagan O’Keefe |EO-54210 |Shirt |19 |30.21 |573.99 |2015-08-11 12:44:38 |0.02
|
||||
3 |14406| Harber, Lubowitz and Fahey| Esequiel Schinner| NZ-99565| Shirt| 12| 90.29 |1083.48 |2016-01-23 02:15:50 |0.02
|
||||
4 |398620| Brekke Ltd |Esequiel Schinner |NZ-99565 |Shirt |5| 72.64 |363.20 |2015-08-10 07:16:03 |0.02
|
||||
|
||||
下一个规则是所有衬衫获得2.5%和带销售>10得到一个4%的利息:
|
||||
|
||||
```
|
||||
df.loc[df["category"] == "Shirt", ["commission"]] = .025
|
||||
df.loc[(df["category"] == "Belt") & (df["quantity"] >= 10), ["commission"]] = .04
|
||||
df.head()
|
||||
```
|
||||
|
||||
| account number |customer name |sales rep| sku |category |quantity| unit price| ext price |date |commission
|
||||
:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--
|
||||
0 |680916| Mueller and Sons| Loring Predovic| GP-14407| Belt| 19 |88.49| 1681.31 |2015-11-17 05:58:34| 0.040
|
||||
1 |680916| Mueller and Sons| Loring Predovic| FI-01804| Shirt |3 |78.07 |234.21| 2016-02-13 04:04:11 |0.025
|
||||
2 |530925 |Purdy and Sons |Teagan O’Keefe| EO-54210 |Shirt| 19 |30.21 |573.99 |2015-08-11 12:44:38| 0.025
|
||||
3 |14406| Harber, Lubowitz and Fahey| Esequiel Schinner| NZ-99565| Shirt| 12| 90.29| 1083.48| 2016-01-23 02:15:50 |0.025
|
||||
4 |398620| Brekke Ltd| Esequiel Schinner| NZ-99565| Shirt| 5 |72.64 |363.20| 2015-08-10 07:16:03 |0.025
|
||||
|
||||
最后的佣金规则是加上特别的奖金:
|
||||
|
||||
```
|
||||
df["bonus"] = 0
|
||||
df.loc[(df["category"] == "Shoes") & (df["ext price"] >= 1000 ), ["bonus", "commission"]] = 250, 0.045
|
||||
|
||||
# Display a sample of rows that show this bonus
|
||||
df.ix[3:7]
|
||||
```
|
||||
|
||||
| account number| customer name |sales rep| sku |category| quantity| unit price| ext price| date| commission| bonus
|
||||
:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--|:--
|
||||
3| 14406| Harber, Lubowitz and Fahey| Esequiel Schinner| NZ-99565| Shirt |12 |90.29| 1083.48 |2016-01-23 02:15:50 |0.025 |0
|
||||
4| 398620| Brekke Ltd| Esequiel Schinner |NZ-99565| Shirt| 5| 72.64| 363.20| 2015-08-10 07:16:03| 0.025| 0
|
||||
5| 282122| Connelly, Abshire and Von Beth| Skiles| GJ-90272| Shoes| 20| 96.62| 1932.40 |2016-03-17 10:19:05 |0.045 |250
|
||||
6 |398620 |Brekke Ltd| Esequiel Schinner |DU-87462 |Shirt| 10| 67.64 |676.40| 2015-11-25 22:05:36| 0.025| 0
|
||||
7| 218667| Jaskolski-O’Hara| Trish Deckow| DU-87462| Shirt |11| 91.86| 1010.46 |2016-04-24 15:05:58| 0.025| 0
|
||||
|
||||
为了做好佣金的计算:
|
||||
|
||||
```
|
||||
# Calculate the compensation for each row
|
||||
df["comp"] = df["commission"] * df["ext price"] + df["bonus"]
|
||||
|
||||
# Summarize and round the results by sales rep
|
||||
df.groupby(["sales rep"])["comp"].sum().round(2)
|
||||
```
|
||||
|
||||
```
|
||||
sales rep
|
||||
Ansley Cummings 2169.76
|
||||
Beth Skiles 3028.60
|
||||
Esequiel Schinner 10451.21
|
||||
Loring Predovic 10108.60
|
||||
Shannen Hudson 5275.66
|
||||
Teagan O'Keefe 7989.52
|
||||
Trish Deckow 5807.74
|
||||
Name: comp, dtype: float64
|
||||
```
|
||||
|
||||
|
||||
如果你有兴趣,一个例子手册被托管在[github][5].
|
||||
|
||||
### 总结
|
||||
|
||||
|
||||
感谢阅读文章。 我发现,在学习如何使用pandas的新用户的最大的挑战之一是如何找出如何使用他们的基于Excel的知识,以建立一个等效的pandas为基础的解决方案。在许多情况下,andas的解决方案将是更健壮,更快,更容易审计和更强大的。然而,学习曲线可以花一些时间。我希望这个例子显示了如何解决一个问题,使用的是电子表格的过滤工具将是一个有用的指南,为那些刚刚在这个pandas开始的旅程的。祝你好运!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://pbpython.com/excel-filter-edit.html
|
||||
|
||||
作者:[Chris Moffitt ][a]
|
||||
译者:[zky001](https://github.com/zky001)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: http://pbpython.com/author/chris-moffitt.html
|
||||
[1]: http://pbpython.com/excel-pandas-comp.html
|
||||
[2]: http://pbpython.com/excel-pandas-comp-2.html
|
||||
[3]: http://pandas.pydata.org/pandas-docs/stable/indexing.html
|
||||
[4]: https://github.com/chris1610/pbpython/blob/master/data/sample-sales-reps.xlsx?raw=true
|
||||
[5]: https://github.com/chris1610/pbpython/blob/master/notebooks/Commissions-Example.ipynb
|
||||
@@ -0,0 +1,182 @@
|
||||
# 4 种方式将 PNG 和 JPG 批量转换
|
||||
|
||||
计算机术语中,批处理指的是用一个非交互式的程序来[执行一序列的任务][11]。这篇教程里,我们会使用 Linux 命令行工具,并提供 4 种简单的处理方式来把一些 `.PNG` 格式的图像批量转换成 `.JPG` 格式的,反之亦然。
|
||||
|
||||
虽然所有示例中我们使用的都是 convert 命令行工具,但是您也可以使用 mogrify 命令来达到同样的效果。
|
||||
|
||||
convert 命令的语法如下:
|
||||
|
||||
```
|
||||
$ convert 输入选项 输入文件 输出选项 输出文件
|
||||
|
||||
```
|
||||
|
||||
而 mogrify 的为:
|
||||
|
||||
```
|
||||
$ mogrify 选项 输入文件
|
||||
|
||||
```
|
||||
|
||||
注意:在使用 mogrify 命令时,默认情况下源图像文件会被转换后的新文件覆盖掉,您可以使用明确的操作选项来禁止覆盖,具体的选项可以在手册页中查询得到。
|
||||
|
||||
下面是把所有 `.PNG` 格式图像批量转换为 `.JPG` 格式的各种实现方式。如果想把 `.JPG` 转换为 `.PNG` 格式,也可使用这些命令,按需修改。
|
||||
|
||||
### 1\. 使用 ‘ls’ 和 ‘xargs’ 命令来转换 PNG 和 JPG
|
||||
|
||||
[ls 命令](10) 可以列出所有的 png 图像文件, xargs 使得可以从标准输入构建和执行 convert 命令,将所有 `.png` 图像转换为 `.jpg` 图像。
|
||||
|
||||
```
|
||||
----------- 从 PNG 转换到 JPG -----------
|
||||
$ ls -1 *.png | xargs -n 1 bash -c 'convert "$0" "${0%.png}.jpg"'
|
||||
|
||||
----------- 从 JPG 转换到 PNG -----------
|
||||
$ ls -1 *.jpg | xargs -n 1 bash -c 'convert "$0" "${0%.jpg}.png"'
|
||||
|
||||
```
|
||||
|
||||
关于上面命令选项的说明:
|
||||
|
||||
1. `-1` – 告诉ls 每行列出一个图像名称的选项标识
|
||||
2. `-n` – 指定最多参数个数,例子中为 1
|
||||
3. `-c` – 指示 bash 运行给定的命令
|
||||
4. `${0%.png}.jpg` – 设置新转换的图像文件的名字,% 符号用来删除源文件的扩展名
|
||||
|
||||
[
|
||||

|
||||
][9]
|
||||
|
||||
Linux 中 PNG 格式转为 JPG 格式
|
||||
|
||||
我使用 `ls -ltr` 命令按[修改的日期和时间列出所有文件][8]。
|
||||
|
||||
类似的,也可以使用上面的命令要把 `.jpg` 图像转换为 `.png` 格式,只需稍微调整就行。
|
||||
|
||||
### 2\. 使用 GNU 的 'Parallel' 命令来转换 PNG 和 JPG
|
||||
|
||||
GNU Parallel 使用户能够从标准输入并行构建和执行 shell 命令。确保您的系统上安装了 GNU Parallel,否则请使用以下适当的命令进行安装:
|
||||
|
||||
```
|
||||
$ sudo apt-get install parallel [在 Debian/Ubuntu 系统中]
|
||||
$ sudo yum install parallel [在 RHEL/CentOS 和 Fedora 系统中]
|
||||
|
||||
```
|
||||
|
||||
安装好 Parallel 工具后,您就可以运行下面的命令来把所有从标准输入的 `.png` 图像转换成 `.jpg` 格式的图像。
|
||||
|
||||
```
|
||||
----------- 从 PNG 转换到 JPG -----------
|
||||
$ parallel convert '{}' '{.}.jpg' ::: *.png
|
||||
|
||||
----------- 从 JPG 转换到 PNG -----------
|
||||
$ parallel convert '{}' '{.}.png' ::: *.jpg
|
||||
|
||||
```
|
||||
|
||||
其中:
|
||||
|
||||
1. `{}` – 输入行替代符,代替了从输入源读取的完整行。
|
||||
2. `{.}` – 去除扩展名的输入行。
|
||||
3. `:::` – 指定输入源的符号,即上面示例的命令行,在这里 *png 或 jpg* 是命令参数。
|
||||
|
||||
[
|
||||

|
||||
][7]
|
||||
|
||||
Parallel 命令 – 把所有 PNG 图像转换为 JPG 格式
|
||||
|
||||
或者,您也可以结合 [ls][6] 和 parallel 命令来批量转换所有图像,如图所示:
|
||||
|
||||
```
|
||||
----------- 从 PNG 转换到 JPG -----------
|
||||
$ ls -1 *.png | parallel convert '{}' '{.}.jpg'
|
||||
|
||||
----------- 从 JPG 转换到 PNG -----------
|
||||
$ ls -1 *.jpg | parallel convert '{}' '{.}.png'
|
||||
|
||||
```
|
||||
|
||||
### 3\. 使用 ‘for loop’ 命令来转换 PNG 和 JPG
|
||||
|
||||
为了避免编写 shell 脚本的繁琐,你可以从命令行执行 `for loop` 语句,如下所示:
|
||||
|
||||
```
|
||||
----------- 从 PNG 转换到 JPG -----------
|
||||
$ bash -c 'for image in *.png; do convert "$image" "${image%.png}.jpg"; echo “image $image converted to ${image%.png}.jpg ”; done'
|
||||
|
||||
----------- 从 JPG 转换到 PNG -----------
|
||||
$ bash -c 'for image in *.jpg; do convert "$image" "${image%.jpg}.png"; echo “image $image converted to ${image%.jpg}.png ”; done'
|
||||
|
||||
```
|
||||
|
||||
对上面的命令所使用的选项参数的描述:
|
||||
|
||||
1. -c 允许执行包括在单引号中的 loop 语句。
|
||||
2. image 变量是目录中的图像名的数量记数器。
|
||||
3. 对于每个转换操作,在 “$image converted to ${image%.png}.jpg” 这行中,[echo 命令][1]通知用户 png 图像已经转换为 jpg 格式,反之亦然。
|
||||
4. "${image%.png}.jpg" 语句创建了转换后的图像名字,其中 % 表示去除源图像文件的扩展名。
|
||||
|
||||
[
|
||||

|
||||
][5]
|
||||
|
||||
for loop 语句 – 从 PNG 转换到 JPG 格式
|
||||
|
||||
### 4\. 使用 Shell 脚本来转换 PNG 和 JPG
|
||||
|
||||
如果你不想像前面的例子那样让你的命令行变得邋遢的话,可以写一个小脚本,如下示:
|
||||
|
||||
笔记:适当地交换 `.png` 和 `.jpg` 扩展名,如下面的例子所示,从一种格式到另一种格式的转换
|
||||
|
||||
```
|
||||
#!/bin/bash
|
||||
#convert
|
||||
for image in *.png; do
|
||||
convert "$image" "${image%.png}.jpg"
|
||||
echo “image $image converted to ${image%.png}.jpg ”
|
||||
done
|
||||
exit 0
|
||||
|
||||
```
|
||||
|
||||
把上面的脚本保存为 `convert.sh` 文件,然后使此脚本文件可执行,接着从存有图像文件的目录下执行。
|
||||
|
||||
```
|
||||
$ chmod +x convert.sh
|
||||
$ ./convert.sh
|
||||
|
||||
```
|
||||
[
|
||||

|
||||
][4]
|
||||
|
||||
使用 Shell 脚本来批量图像转换
|
||||
|
||||
总之,我们介绍了一些重要的将 .png 图像批量转换为 .jpg 格式的方法,反之亦然。如果还想对图像进行一些优化的话, 您可以移步到[ Linux 系统中如何压缩 png 和 jpg 图像][3]这篇指导文章。
|
||||
|
||||
您可以给我们分享一些在终端下把图像从一种格式转成另一种格式的方式方法,或者是 [ Linux 命令行工具][2],或者在下面的评论部分畅所欲言。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/linux-image-conversion-tools/
|
||||
|
||||
作者:[Aaron Kili][a]
|
||||
|
||||
译者:[runningwater](https://github.com/runningwater)
|
||||
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/aaronkili/
|
||||
[1]:http://www.tecmint.com/echo-command-in-linux/
|
||||
[2]:http://www.tecmint.com/tag/linux-tricks/
|
||||
[3]:http://www.tecmint.com/optimize-and-compress-jpeg-or-png-batch-images-linux-commandline/
|
||||
[4]:http://www.tecmint.com/wp-content/uploads/2016/11/Batch-Image-Convert-Using-Shell-Script.png
|
||||
[5]:http://www.tecmint.com/wp-content/uploads/2016/11/Convert-PNG-to-JPG-Using-for-loop-Command.png
|
||||
[6]:http://www.tecmint.com/tag/linux-ls-command/
|
||||
[7]:http://www.tecmint.com/wp-content/uploads/2016/11/Convert-PNG-to-JPG-Using-Parallel-Command.png
|
||||
[8]:http://www.tecmint.com/sort-ls-output-by-last-modified-date-and-time/
|
||||
[9]:http://www.tecmint.com/wp-content/uploads/2016/11/Convert-PNG-to-JPG-in-Linux.png
|
||||
[10]:http://www.tecmint.com/tag/linux-ls-command/
|
||||
[11]:http://www.tecmint.com/using-shell-script-to-automate-linux-system-maintenance-tasks/
|
||||
Reference in New Issue
Block a user