Merge remote-tracking branch 'LCTT/master'

This commit is contained in:
wxy 2018-02-14 00:55:59 +08:00
commit c52714c4ab
14 changed files with 440 additions and 378 deletions

View File

@ -1,25 +1,21 @@
KarenMrzhang Tranlating
Linux / Unix Bash Shell 列出所有内置命令
如何列出所有的 Bash Shell 内置命令
======
内置命令包含在 bash shell 本身。我该如何在 Linux / Apple OS X / *BSD / Unix 上像操作系统不用去读大篇的 bash 操作说明页就可以列出所有的内置 bash 命令呢?
一个 shell 内置函数是一个命令或一个函数从shell中调用它直接在shell中执行。 bash shell 是直接执行命令没有调用其他程序的。你可以使用帮助命令查看 Bash 内置命令的信息。以下是几种不同类型的内置命令。
内置命令包含在 bash shell 本身里面。我该如何在 Linux / Apple OS X / *BSD / Unix 类操作系统列出所有的内置 bash 命令,而不用去读大篇的 bash 操作说明页?
shell 内置命令就是一个命令或一个函数,从 shell 中调用,它直接在 shell 中执行。 bash shell 直接执行该命令而无需调用其他程序。你可以使用 `help` 命令查看 Bash 内置命令的信息。以下是几种不同类型的内置命令。
### 内置命令的类型
1. Bourne Shell 内置命令:内置命令继承自 Bourne Shell。
2. Bash 内置命令:特定于 Bash 的内置命令表。
3. 修改 Shell 行为:修改 shell 属性和选择行为的内置命令。
4. 特别的内置命令:由 POSIX 特别分类的内置命令。
1. Bourne Shell 内置命令:内置命令继承自 Bourne Shell。
2. Bash 内置命令:特定于 Bash 的内置命令表。
3. 修改 Shell 行为:修改 shell 属性和可选行为的内置命令。
4. 特别的内置命令:由 POSIX 特别分类的内置命令。
### 如何查看所有 bash 内置命令
有以下的命令:
```
$ help
$ help | less
@ -27,6 +23,7 @@ $ help | grep read
```
样例输出:
```
GNU bash, version 4.1.5(1)-release (x86_64-pc-linux-gnu)
These shell commands are defined internally. Type `help' to see this list.
@ -76,20 +73,32 @@ A star (*) next to a name means that the command is disabled.
help [-dms] [pattern ...] { COMMANDS ; }
```
另外一种选择是使用下列命令:
```
compgen -b
compgen -b | more
```
### 查看 Bash 的内置命令信息
运行以下得到详细信息:
```
help command
help read
```
仅得到所有带简短描述的内置命令的列表,执行如下:
`$ help -d`
要仅得到所有带简短描述的内置命令的列表,执行如下:
```
$ help -d
```
### 查找内置命令的语法和其他选项
使用下列语法去找出更多的相关内置命令:
```
help name
help cd
@ -99,7 +108,8 @@ help read
help :
```
样例输出:
样例输出:
```
:: :
Null command.
@ -110,9 +120,10 @@ help :
Always succeeds
```
### 找出一个命令是内部的(内置的)还是外部的。
### 找出一个命令是内部的(内置)还是外部的
使用 `type` 命令或 `command` 命令:
使用类型命令或命令命令:
```
type -a command-name-here
type -a cd
@ -121,13 +132,14 @@ type -a :
type -a ls
```
或者:
或者
```
type -a cd uname : ls uname
```
样例输出:
```
cd is a shell builtin
uname is /bin/uname
@ -142,7 +154,8 @@ l ()
```
或者
或者:
```
command -V ls
command -V cd
@ -153,7 +166,7 @@ command -V foo
### 关于作者
作者是网站站长的发起人和季度系统管理员和 Linux 操作系统/Unix shell 脚本教练。他与全球客户以及包括IT、教育、国防和空间研究以及非营利部门在内的各个行业合作。可以在 [Twitter][2], [Facebook][3], [Google+][4] 上关注他。
作者是 nixCraft 网站的发起人和经验丰富的系统管理员,以及 Linux 操作系统/Unix shell 脚本编程培训师。他与全球客户以及包括 IT、教育、国防和空间研究以及非营利部门在内的各个行业合作。可以在 [Twitter][2]、[Facebook][3]、 [Google+][4] 上关注他。
--------------------------------------------------------------------------------
@ -161,7 +174,7 @@ via: https://www.cyberciti.biz/faq/linux-unix-bash-shell-list-all-builtin-comman
作者:[Vivek Gite][a]
译者:[KarenMrzhang](https://github.com/KarenMrzhang)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,33 +1,38 @@
# 如何在 Ubuntu 上使用 ZFS 文件系统
如何在 Ubuntu 上使用 ZFS 文件系统
==============
在 Linux 系统上,有大量的[文件系统][1]可以使用,那么我们为什么还要尝试一个新的文件系统?他们都工作的很好,不是吗?但是他们并不完全相同,其中的一些文件系统具有非常突出的优点,例如 ZFS。
![](https://www.maketecheasier.com/assets/uploads/2017/09/zfs-feat.jpg)
在 Linux 系统上,有大量的[文件系统][1]可以使用,那么我们为什么还要尝试一个新的文件系统?它们都工作的很好,不是吗?但是它们并不完全相同,其中的一些文件系统具有非常突出的优点,例如 ZFS。
### 为什么选择 ZFS
ZFS 非常的优秀。 这是一个真正现代文件系统,内置的功能对于处理大量的数据很有意义。
ZFS 非常的优秀。这是一个真正现代文件系统,内置的功能对于处理大量的数据很有意义。
现在,如果您正在考虑将 ZFS 用于您的超高速 NVMe SSD这可能不是一个最佳选择。 它比别的文件系统要慢,不过,这完全没有问题, 它旨在存储大量的数据并保持安全。
ZFS 消除了建立传统 RAID 阵列(译者注:独立磁盘冗余阵列)的需要。 相反,您可以创建 ZFS 池,甚至可以随时将驱动器添加到这些池中。 ZFS 池的行为操作与 RAID 几乎完全相同,但功能内置于文件系统中。
ZFS 消除了建立传统 RAID 阵列LCTT 译注:独立磁盘冗余阵列)的需要。 相反,您可以创建 ZFS 池,甚至可以随时将驱动器添加到这些池中。 ZFS 池的行为操作与 RAID 几乎完全相同,但功能内置于文件系统中。
ZFS 也可以替代 LVM (译者注:逻辑盘卷管理),使您能够动态分区和管理分区,而无需处理较低级别的事务,也不必担心相关的风险。
ZFS 也可以替代 LVM LCTT 译注:逻辑盘卷管理),使您能够动态地进行分区和管理分区,而无需处理底层的细节,也不必担心相关的风险。
这也是一个 CoW (译者注Copy on Write)文件系统。 没有太多的技术性,这意味着 ZFS 可以保护您的数据免受逐渐损坏的影响。 ZFS 创建文件的校验和,并允许您将这些文件回滚到以前的工作版本。
这也是一个 CoW LCTT 译注:写时复制)文件系统。 这里不会提及太多的技术性,这意味着 ZFS 可以保护您的数据免受逐渐损坏的影响。 ZFS 创建文件的校验和,并允许您将这些文件回滚到以前的工作版本。
### 安装 ZFS
![Install ZFS on Ubuntu][2]
在 Ubuntu 上安装 ZFS 非常简单,但对于 Ubuntu LTS (译者注:长时间支持版本)和最新版本来说,这个过程稍有不同。
在 Ubuntu 上安装 ZFS 非常简单,但对于 Ubuntu LTS LCTT 译注:长时间支持版本)和最新版本来说,这个过程稍有不同。
**Ubuntu 16.04 LTS**
**Ubuntu 16.04 LTS**
```
sudo apt install zfs
sudo apt install zfs
```
**Ubuntu 17.04 and Later**
**Ubuntu 17.04 及以后**
```
sudo apt install zfsutils
sudo apt install zfsutils
```
当你安装好程序后,可以使用 ZFS 提供的工具创建 ZFS 驱动器和分区。
@ -36,11 +41,11 @@ ZFS 也可以替代 LVM (译者注:逻辑盘卷管理),使您能够动态分
![Create ZFS Pool][3]
在 ZFS 中,池大致相当于 RAID 。 们很灵活且易于操作。
在 ZFS 中,池大致相当于 RAID 。 们很灵活且易于操作。
#### RAID0
RAID0 只是把你的硬盘集中到一个巨大的驱动器上。 它可以提高你的驱动器速度,(译者注:数据条带化后,并行访问,提高文件读取速度)但是如果你的驱动器有损坏,你可能会失丢失数据。
RAID0 只是把你的硬盘集中到一个池子里面,就像一个巨大的驱动器一样。 它可以提高你的驱动器速度LCTT 译注:数据条带化后,并行访问,可以提高文件读取速度)但是如果你的驱动器有损坏,你可能会失丢失数据。
要使用 ZFS 实现 RAID0只需创建一个普通的池。
@ -48,9 +53,9 @@ RAID0 只是把你的硬盘集中到一个巨大的驱动器上。 它可以提
sudo zpool create your-pool /dev/sdc /dev/sdd
```
#### RAID1/MIRROR
#### RAID1(镜像)
您可以在 ZFS 中使用 `mirror` 关键字来实现 RAID1 功能。 RAID1 创建一个 1 对 1 的驱动器副本。 这意味着您的数据不断备份。 它也提高了性能。 当然,你将一半的存储空间用于复制。
您可以在 ZFS 中使用 `mirror` 关键字来实现 RAID1 功能。 RAID1 会创建一个一对一的驱动器副本。 这意味着您的数据一直在备份。 它也提高了性能。 当然,你将一半的存储空间用于复制。
```
sudo zpool create your-pool mirror /dev/sdc /dev/sdd
@ -58,7 +63,7 @@ sudo zpool create your-pool mirror /dev/sdc /dev/sdd
#### RAID5/RAIDZ1
ZFS 将 RAID5 功能实现为 RAIDZ1。 RAID5 要求驱动器至少是 3 个。并允许您通过将备份奇偶校验数据写入驱动器空间的 1/3 来保留 2/3 的存储空间。 如果一个驱动器发生故障,阵列将保持联机状态,但应尽快更换发生故障的驱动器(译者注:与原文翻译略有不同,原文是驱动器的数目是三的倍数,根据 wiki RAID5 至少需要 3 块驱动器,也可以从下面的命令中猜测)。
ZFS 将 RAID5 功能实现为 RAIDZ1。 RAID5 要求驱动器至少是 3 个。并允许您通过将备份奇偶校验数据写入驱动器空间的 1/nn 是驱动器数),留下的是可用的存储空间。 如果一个驱动器发生故障,阵列将保持联机状态,但应尽快更换发生故障的驱动器LCTT 译注:与原文翻译略有不同,原文是驱动器的数目是三的倍数,根据 wiki RAID5 至少需要 3 块驱动器,也可以从下面的命令中猜测)。
```
sudo zpool create your-pool raidz1 /dev/sdc /dev/sdd /dev/sde
@ -66,15 +71,15 @@ sudo zpool create your-pool raidz1 /dev/sdc /dev/sdd /dev/sde
#### RAID6/RAIDZ2
RAID6 与 RAID5 几乎完全相同,但它至少需要四个驱动器。 它将奇偶校验数据加倍,最多允许两个驱动器损坏,而不会导致阵列关闭。(译者注:这里也与原文略有出入,原文是驱动器的数目是四的倍数,根据 wiki RAID6 至少需要四个驱动器)
RAID6 与 RAID5 几乎完全相同,但它至少需要四个驱动器。 它将奇偶校验数据加倍,最多允许两个驱动器损坏,而不会导致阵列关闭LCTT 译注:这里也与原文略有出入,原文是驱动器的数目是四的倍数,根据 wiki RAID6 至少需要四个驱动器)
```
sudo zpool create your-pool raidz2 /dev/sdc /dev/sdd /dev/sde /dev/sdf
```
#### RAID10/Striped Mirror
#### RAID10(条带化镜像)
RAID10 旨在通过数据条带化提高存取速度和数据冗余来成为一个两全其美的解决方案。 你至少需要四个驱动器,但只能访问一半的空间。 您可以通过在同一池中创建两个镜像来创建 RAID10 中的池。(译者注:这里也与原文略有出入,原文是驱动器的数目是四的倍数,根据 wiki RAID10 至少需要四个驱动器)
RAID10 旨在通过数据条带化提高存取速度和数据冗余来成为一个两全其美的解决方案。 你至少需要四个驱动器,但只能使用一半的空间。 您可以通过在同一个池中创建两个镜像来创建 RAID10 中的池LCTT 译注:这里也与原文略有出入,原文是驱动器的数目是四的倍数,根据 wiki RAID10 至少需要四个驱动器)。
```
sudo zpool create your-pool mirror /dev/sdc /dev/sdd mirror /dev/sde /dev/sdf
@ -84,7 +89,7 @@ sudo zpool create your-pool mirror /dev/sdc /dev/sdd mirror /dev/sde /dev/sdf
![ZFS pool Status][4]
还有一些管理工具,一旦你创建了你的池,你就必须使用它。 首先,检查你的池的状态。
还有一些管理工具,一旦你创建了你的池,你就必须使用它们来操作。 首先,检查你的池的状态。
```
sudo zpool status
@ -92,7 +97,7 @@ sudo zpool status
#### 更新
当你更新 ZFS 时,你也需要更新你的池。 当您检查们的状态时,您的池会通知您任何更新。 要更新池,请运行以下命令。
当你更新 ZFS 时,你也需要更新你的池。 当您检查们的状态时,您的池会通知您任何更新。 要更新池,请运行以下命令。
```
sudo zpool upgrade your-pool
@ -116,9 +121,9 @@ sudo zpool add your-pool /dev/sdx
![ZFS in File Browser][5]
ZFS 在您的池的根文件系统中创建一个目录。 您可以使用 GUI 文件管理器或 CLI (译者注Command-line interface )按名称浏览它们。
ZFS 在您的池的根文件系统中创建一个目录。 您可以使用 GUI 文件管理器或 CLI 按名称浏览它们。
ZFS 非常强大,还有很多其的东西可以用它来做,但这些都是基础。 这是一个优秀的存储负载文件系统,即使它只是一个用于文件的硬盘驱动器的 RAID 阵列。 ZFS 在 NAS 系统上也非常出色。
ZFS 非常强大,还有很多其的东西可以用它来做,但这些都是基础。 这是一个优秀的存储负载文件系统,即使它只是一个用于文件的硬盘驱动器的 RAID 阵列。 ZFS 在 NAS 系统上也非常出色。
无论 ZFS 的稳定性和可靠性如何,在您的硬盘上实施新的功能时,最好备份您的数据。
@ -128,7 +133,7 @@ via: https://www.maketecheasier.com/use-zfs-filesystem-ubuntu-linux/
作者:[Nick Congleton][a]
译者:[amwps290](https://github.com/amwps290)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,37 +1,25 @@
为什么说 Python 和 Pygame 最适合初学者
为什么说 Python 和 Pygame 最适合编程初学者
============================================================
### 我们有三个理由来说明 Pygame 对初学编程者是最好的选择。
> 我们有三个理由来说明 Pygame 对初学编程者是最好的选择。
![What's the best game platform for beginning programmers?](https://opensource.com/sites/default/files/styles/image-full-size/public/lead-images/code_development_programming.png?itok=M_QDcgz5 "What's the best game platform for beginning programmers?")
图片来源: [opensource.com](https://opensource.com)
上个月,[Scott Nesbitt][10] 发表了一篇标题为[ Mozilla 支出 50 万美元来支持开源项目][11]的文章。其中 Phaser一个基于 HTML/JavaScript 的游戏平台项目,获得了 50,000 美元的奖励。整整一年里,我都在使用 Phaser 平台来教我的小女儿,用来学习的话,它是最简单也是最好的 HTML 游戏开发平台。然而,对于初学者来说,使用[ Pygame ][13]也许效果更好。原因如下:
图片来源: [opensource.com](https://opensource.com)
### 1\. 小段代码块
上个月,[Scott Nesbitt][10] 发表了一篇标题为 [Mozilla 支出 50 万美元来支持开源项目][11]的文章。其中一个基于 HTML/JavaScript 的游戏平台项目 Phaser 获得了 50,000 美元的奖励。整整一年里,我都在使用 Phaser 平台来教我的小女儿,用来学习的话,它是最简单也是最好的 HTML 游戏开发平台。然而,对于初学者来说,使用 [Pygame ][13]也许效果更好。原因如下:
Pygame基于 Python[在介绍计算机课程中最流行的语言][14]。Python 非常适合用一小段代码来实现我们的想法,孩子们可以从单个文件和单个代码块起开始学习,在掌握函数 (function) 或类 (class) 对象之前,就可以写出意大利面条似的代码。 很像手指画,所想即所得。
### 1、 小段代码块
更多 Python 资源链接
Pygame基于[计算机课程中最流行的语言][14] Python。Python 非常适合用一小段代码来实现我们的想法孩子们可以从单个文件和单个代码块起开始学习在掌握函数function或类class对象之前就可以写出意大利面条似的代码。 很像手指画,所想即所得。
* [Python 是什么?][1]
以这样的方式来学习,当编写的代码越来越难于管理的时候,孩子们很自然的就会把代码分解成函数模块和类模块。在学习函数之前就学习了 Python 语言的语法,学生将掌握基本的编程知识,对了解全局作用域和局部作用域起到更好的作用。
* [最热门 Python IDEs][2]
大多数 HTML 游戏在一定程度上会将结构、样式和编程逻辑分为 HTML、CSS 和 JavaScript并且需要 CSS 和 HTML 的知识。从长远来看,虽然拆分更好,但对初学者来说是个障碍。一旦孩子们发现他们可以用 HTML 和 CSS 快速构建网页,很有可能就会被颜色、字体和图形的视觉刺激分散注意力。即使仅仅只专注于 JavaScript 代码也需要学习基本的文档结构模型DOM以使 JavaScript 代码能够嵌入进去。
* [最热门 Python GUI 框架][3]
### 2、 全局变量更清晰
* [最新 Python 话题][4]
* [更多开发资源][5]
以这样的方式来学习,当编写的代码越来越难于管理的时候,孩子们很自然就的就会把代码分解成函数模块和类模块。在学习函数之前就学习了 Python 语言的语法,学生将掌握基本的编程知识,对了解全局作用域和局部作用域起到更好的作用。
大多数 HTML 游戏在一定程度上会将结构、样式和编程逻辑分为 HTML、CSS和JavaScript并且需要 CSS 和 HTML 的知识。从长远来看,虽然拆分更好,但对初学者来说是个障碍。一旦孩子们发现他们可以用 HTML 和 CSS 快速构建网页,很有可能就会被颜色、字体和图形的视觉刺激分散注意力。即使有仅仅只专注于 JavaScript 代码的,也需要学习基本的文档结构模型,以使 JavaScript 代码能够嵌入进去。
### 2\. 全局变量更清晰
Python 和 JavaScript 都使用动态类型变量,这意味着变量只有在赋值才能确定其类型为一个字符串、一个整数或一个浮点数,其中 JavaScript 更容易出错。类似于类型变量JavaScript 和 Python 都有全局变量和局部变量之分。Python 中,如果在函数块内要使用全局变量,就会以 `global` 关键字区分出来。
Python 和 JavaScript 都使用动态类型变量,这意味着变量只有在赋值才能确定其类型是一个字符串、一个整数还是一个浮点数,然而在 JavaScript 更容易出错。类似于类型变量JavaScript 和 Python 都有全局变量和局部变量之分。Python 中,如果在函数块内要使用全局变量,就会以 `global` 关键字区分出来。
要理解在 Phaser 上教授编程初学者所面临的挑战的话,让我们以基本的[制作您的第一个 Phaser 游戏教程][15]为例子,它是由 Alvin Ourrad 和 Richard Davey 开发制作的。在 JavaScript 中,程序中任何地方都可以访问的全局变量很难追踪调试,常常引起 Bug 且很难解决。因为 Richard 和 Alvin 是专业程序员,所以在这儿特意使用全局变量以使程序简洁。
@ -49,26 +37,26 @@ var platforms;
function create() {
    game.physics.startSystem(Phaser.Physics.ARCADE);
...
```
在他们的 Phaser 编程手册 [《Interphase》][16] 中Richard Davey 和 Ilija Melentijevic 解释说:在很多 Phaser 项目中通常都会使用全局变量,原因是使用它们完成任务更容易、更快捷。
> “如果您开发过游戏,只要代码量到一定规模,那么(使用全局变量)这种做法会使您陷入困境的,可是我们为什么还要这样做?原因很简单,仅仅只是要使我们的 Phaser 项目容易完成,更简单而已。”
针对一个 Phaser 应用程序,虽然可以使用局部变量和拆分代码块来达到关注点隔离这些手段来重构代码,但要使第一次学习编程的小孩能理解,显然很有难度的。
针对一个 Phaser 应用程序,虽然可以使用局部变量和拆分代码块来达到关注点隔离这些手段来重构代码,但要使第一次学习编程的小孩能理解显然很有难度的。
如果您想教你的孩子学习 JavaScript或者如果他们已经知道怎样使用像 Python 来编程的话,有个好的 Phaser 课程推荐: [完整的手机游戏开发课程] [17],是由 [ Pablo Farias Navarro ] [18] 开发制作的。虽然标题看着是移动游戏,但实际是关于 JavaScript 和 Phaser 的。JavaScript 和 Phaser 移动应用开发已经转移到 [PhoneGap][19] 话题去了。
如果您想教你的孩子学习 JavaScript或者如果他们已经知道怎样使用像 Python 来编程的话,有个好的 Phaser 课程推荐 [完整的手机游戏开发课程] [17],是由 [Pablo Farias Navarro] [18] 开发制作的。虽然标题看着是移动游戏,但实际是关于 JavaScript 和 Phaser 的。JavaScript 和 Phaser 移动应用开发已经转移到 [PhoneGap][19] 话题去了。
### 3\. Pygame 无依赖要求
### 3 Pygame 无依赖要求
由于 [Python Wheels][20] 的出现Pygame 超级[容易安装][21]。在 Fedora/Red Hat 系统下也可使用 **yum** 包管理器来安装:
由于 [Python Wheels][20] 的出现Pygame 超级[容易安装][21]。在 Fedora/Red Hat 系统下也可使用 `yum` 包管理器来安装:
```
sudo yum install python3-pygame
```
更多消息请参考官网[Pygame 安装说明文档][22]。
更多信息请参考官网 [Pygame 安装说明文档][22]。
相比来说,虽然 Phaser 本身更容易安装,但需要掌握更多的知识。前面提到的,学生需要在 HTML 文档中组装他们的 JavaScript 代码,同时还需要些 CSS。除了这三种语言HTML、CSS、JavaScript还需要使用火狐或谷歌开发工具和编辑器。JavaScript 最常用的编辑器有 Sublime、Atom、VS Code按使用多少排序等。
@ -76,31 +64,29 @@ sudo yum install python3-pygame
### Phaser 和 JavaScript 的优势
JavaScript 和 Phaser 有着种种的不好,为什么我还继续教授他们?老实说,我考虑了很长一段时间,我在担心着学生学习变量申明提升和变量作用域的揪心。所有我开发出基于 Pygame 和 Python 的课程,随后也开发出一涛基于 Phaser 的。最终,我决定使用 Pablo 预先制定的课程作为起点。
JavaScript 和 Phaser 有着种种的不好,为什么我还继续教授他们?老实说,我考虑了很长一段时间,我在担心着学生学习<ruby>变量申明提升<rt>variable hoisting</rt></ruby>和变量作用域的揪心。我开发出基于 Pygame 和 Python 的课程,随后也开发出一涛基于 Phaser 的。最终,我决定使用 Pablo 预先制定的课程作为起点。
我转用 JavaScript 有两个原因。首先JavaScript 已经成为正式应用的正式语言。除了 Web 应用外也可使用于移动和服务应用方面。JavaScript 无处不在,其广泛应用于孩子们每天都能看到的应用中。如果他们的朋友使用 Javascript 来编程,他们很可能也会受影响而使用之。正如我看到了 JavaScript 背后的动力,所以深入研究了可编译成 JavaScript 的替代语言,主要是 Dart 和 TypeScript 两种。虽然我不介意额外的转换步骤,但还是最喜欢 JavaScript。
最后,我选择使用 Phaser 和 JavaScript 的组合,是因为我意识到上面那些问题在 JavaScript 可以被解决,仅仅只是一些工作量而已。高质量的调试工具和一些大牛们的人的工作使得 JavaScript 成为教育孩子编码的可用和有用的语言。
最后,我选择使用 Phaser 和 JavaScript 的组合,是因为我意识到上面那些问题在 JavaScript 可以被解决,仅仅只是一些工作量而已。高质量的调试工具和一些大牛们的工作使得 JavaScript 成为教育孩子编码的可用和有用的语言。
### 最后话题: Python 对垒 JavaScript
当家长问我使用的什么语言作为孩子的入门语言时,我会立即推荐 Python 和 Pygame。因为有成千上万的课程可选而且大多数都是免费的。我为我的儿子选择了 Al Sweigart 的 [使用 Python 和 Pygame 开发游戏][25] 课程,同时也在使用 Allen B. Downey 的 [Python 编程思想:如何像计算机科学家一样思考][7]。在 Android 手机上可以使用 [ Tom Rothame ][27]的[ PAPT Pyame][26] 来安装 Pygame 游戏。
当家长问我使用的什么语言作为孩子的入门语言时,我会立即推荐 Python 和 Pygame。因为有成千上万的课程可选而且大多数都是免费的。我为我的儿子选择了 Al Sweigart 的 [使用 Python 和 Pygame 开发游戏][25] 课程,同时也在使用 Allen B. Downey 的 [Python 编程思想:如何像计算机科学家一样思考][7]。在 Android 手机上可以使用 [Tom Rothame][27] [PAPT Pyame][26] 来安装 Pygame 游戏。
那是好事。JavaScript 是一门成熟的编程语言,有很多很多辅助工具。但有多年的帮助大儿子使用 Python 创建炫酷游戏经历的我,依然钟情于 Python 和 Pygame。
尽管有我的建议, 我总是怀疑孩子们很快就会搬到 JavaScript。这没关系 —— JavaScript 是一门成熟的编程语言,有很多很多辅助工具。但有多年的帮助大儿子使用 Python 创建炫酷游戏经历的我,依然钟情于 Python 和 Pygame。
### About the author
### 关于作者
[![](https://opensource.com/sites/default/files/styles/profile_pictures/public/pictures/craig-head-crop.png?itok=LlMnIq8m)][28]
Craig Oda - First elected president and co-founder of Tokyo Linux Users Group. Co-author of "Linux Japanese Environment" book published by O'Reilly Japan. Part of core team that established first ISP in Asia. Former VP of product management and product marketing for major Linux company. Partner at Oppkey, developer relations consulting firm in Silicon Valley.[More about me][8]
Craig Oda —— 东京 Linux 用户组的首位总裁和共同创始人奥莱理日本出版的《Linux 日文环境》的共同作者。在亚洲建立了第一个 ISP 的核心团队成员之一。一个大型 Linux 公司的产品管理及市场的前任副总裁。硅谷开发者关系咨询公司 Oppkey 的合作方。[更多][8]
--------------------------------------------------------------------------------
via: https://opensource.com/article/17/11/pygame
作者:[Craig Oda ][a]
作者:[Craig Oda][a]
译者:[runningwater](https://github.com/runningwater)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,37 +1,39 @@
Linux 中 4 个简单的找出进程 IDPID的方法
======
每个人都知道 PID究竟什么是 PID为什么你想要 PID你打算用 PID 做什么?你脑子里有同样的问题吗?如果是这样,你就找对地方了解这些细节了。
主要地,我们查询 PID 来杀死一个没有响应的程序,它类似于 Windows 任务管理器。 Linux GUI 也提供相同的功能,但 CLI 是执行 kill 操作的有效方法。
我们查询 PID 主要是用来杀死一个没有响应的程序,它类似于 Windows 任务管理器一样。 Linux GUI 也提供相同的功能,但 CLI 是执行 `kill` 操作的有效方法。
### 什么是进程 ID?
PID 代表进程标识号process identification,它在大多数操作系统内核(如 Linux、Unix、macOS 和 Windows中使用。它是在操作系统中创建时自动分配给每个进程的唯一标识号。一个进程是一个正在运行的程序实例。
PID 代表<ruby>进程标识号<rt>process identification</rt></ruby>,它在大多数操作系统内核(如 Linux、Unix、macOS 和 Windows中使用。它是在操作系统中创建时自动分配给每个进程的唯一标识号。一个进程是一个正在运行的程序实例。
**建议阅读:** [如何查看 Apache Web 服务器在 Linux 中的运行时间][1]
除了 init 进程外其他所有的进程 ID 每次都会改变,因为 init 始终是系统上的第一个进程,并且是所有其他进程的父进程。它的 PID 是 1。
PID 默认的最大值是 `32,768`。可以在你的系统上运行 `cat /proc/sys/kernel/pid_max` 来验证。在 32 位系统上32768 是最大值,但是我们可以在 64 位系统上将其设置为最大 2^22约 4 百万)内的任何值。
PID 默认的最大值是 `32768`。可以在你的系统上运行 `cat /proc/sys/kernel/pid_max` 来验证。在 32 位系统上,`32768` 是最大值,但是我们可以在 64 位系统上将其设置为最大 2^22约 4 百万)内的任何值。
你可能会问,为什么我们需要这么多的 PID因为我们不能立即重用 PID这就是为什么。另外为了防止可能的错误。
系统正在运行的进程的 PID 可以通过使用 pidof、pgrep、ps 和 pstree 命令找到。
系统正在运行的进程的 PID 可以通过使用 `pidof``pgrep``ps``pstree` 命令找到。
### 方法 1使用 pidof 命令
pidof 用于查找正在运行的程序的进程 ID。它在标准输出上打印这些 id。为了演示我们将在 Debian 9stretch系统中找出 Apache2 的进程 ID。
`pidof` 用于查找正在运行的程序的进程 ID。它在标准输出上打印这些 id。为了演示我们将在 Debian 9stretch系统中找出 Apache2 的进程 ID。
```
# pidof apache2
3754 2594 2365 2364 2363 2362 2361
```
从上面的输出中,你可能会遇到难以识别进程 ID 的问题,因为它通过进程名称显示了所有的 PID包括父进程和子进程。因此我们需要找出父 PIDPPID这是我们要查找的。它可能是第一个数字。在本例中它是 `3754`,并按降序排列。
### 方法 2使用 pgrep 命令
pgrep 遍历当前正在运行的进程,并将符合选择条件的进程 ID 列到标准输出中。
`pgrep` 遍历当前正在运行的进程,并将符合选择条件的进程 ID 列到标准输出中。
```
# pgrep apache2
2361
@ -41,18 +43,18 @@ pgrep 遍历当前正在运行的进程,并将符合选择条件的进程 ID
2365
2594
3754
```
这也与上面的输出类似,但是它将结果从小到大排序,这清楚地说明父 PID 是最后一个。在本例中,它是 `3754`
**注意:** 如果你有多个进程的进程 ID那么在使用 pidof 和 pgrep 识别父进程 ID 时可能会遇到麻烦
**注意:** 如果你有多个进程的进程 ID那么在使用 `pidof``pgrep` 识别父进程 ID 时就可能不会很顺利
### 方法 3使用 pstree 命令
pstree 将运行的进程显示为一棵树。树的根是 pid如果省略了 pid 那么就是 init。如果在 pstree 命令中指定了用户名,则显示相应用户拥有的所有进程。
`pstree` 将运行的进程显示为一棵树。树的根是某个 pid如果省略了 pid 参数,那么就是 init。如果在 `pstree` 命令中指定了用户名,则显示相应用户拥有的所有进程。
`pstree` 会将相同的分支放在方括号中,并添加重复计数的前缀来可视化地合并到一起。
pstree 通过将它们放在方括号中并添加重复计数前缀来可视化地合并相同的分支。
```
# pstree -p | grep "apache2"
|- apache2(3754) -|-apache2(2361)
@ -61,21 +63,21 @@ pstree 通过将它们放在方括号中并添加重复计数前缀来可视化
| |-apache2(2364)
| |-apache2(2365)
| `-apache2(2594)
```
要单独获取父进程,请使用以下格式。
```
# pstree -p | grep "apache2" | head -1
|- apache2(3754) -|-apache2(2361)
```
pstree 命令非常简单,因为它分别隔离了父进程和子进程,但这在使用 pidof 和 pgrep 时命令不容易。
`pstree` 命令非常简单,因为它分别隔离了父进程和子进程,但这在使用 `pidof``pgrep` 时命令不容易做到
### 方法 4使用 ps 命令
ps 显示活动进程的选择信息。它显示进程 IDpid=PID、与进程关联的终端tname=TTY、以 [DD-]hh:mm:ss 格式time=TIME的累计 CPU 时间、以及执行名ucmd = CMD。输出默认是未排序的。
`ps` 显示活动进程的选择信息。它显示进程 ID`pid`=PID、与进程关联的终端`tname`=TTY、以 `[DD-]hh:mm:ss` 格式(`time`=TIME显示的累计 CPU 时间、以及执行名(`ucmd` = CMD。输出默认是未排序的。
```
# ps aux | grep "apache2"
www-data 2361 0.0 0.4 302652 9732 ? S 06:25 0:00 /usr/sbin/apache2 -k start
@ -86,10 +88,9 @@ www-data 2365 0.0 0.4 302652 8400 ? S 06:25 0:00 /usr/sbin/apache2 -k start
www-data 2594 0.0 0.4 302652 8400 ? S 06:55 0:00 /usr/sbin/apache2 -k start
root 3754 0.0 1.4 302580 29324 ? Ss Dec11 0:23 /usr/sbin/apache2 -k start
root 5648 0.0 0.0 12784 940 pts/0 S+ 21:32 0:00 grep apache2
```
从上面的输出中,我们可以根据进程的启动日期轻松地识别父进程 IDPPID。在此例中apache2 启动于 `Dec11`它是父进程其他的是子进程。apache2 的 PID 是 `3754`
从上面的输出中,我们可以根据进程的启动日期轻松地识别父进程 IDPPID。在此例中apache2 启动于 `Dec 11`它是父进程其他的是子进程。apache2 的 PID 是 `3754`
--------------------------------------------------------------------------------
@ -97,7 +98,7 @@ via: https://www.2daygeek.com/how-to-check-find-the-process-id-pid-ppid-of-a-run
作者:[Magesh Maruthamuthu][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,83 @@
Linux ldd Command Explained with Examples
=========================================
If your work involves deep knowledge of executables and shared libraries in Linux, there are several command line tools that you should be aware of. One of those is ldd, which you can use to access shared object dependencies. In this tutorial, we will discuss the basics of this utility using some easy to understand examples.
Please note that all examples mentioned here have been tested on Ubuntu 16.04 LTS.
### Linux ldd command
As already mentioned in the beginning, the ldd command prints shared object dependencies. Following is the command's syntax:
`ldd [option]... file...`
And here's how the tool's man page explains it:
```
ldd prints the shared objects (shared libraries) required by each program or shared object
specified on the command line.
```
The following Q&A-styled examples should give you a better idea on how ldd works.
### Q1. How to use ldd?
Basic usage of ldd is fairly simple - just run the 'ldd' command along with an executable or shared object file name as input.
`ldd [object-name]`
For example:
`ldd test`
[![How to use ldd](https://www.howtoforge.com/images/command-tutorial/ldd-basic.png)](https://www.howtoforge.com/images/command-tutorial/big/ldd-basic.png)
So you can see all shared library dependencies have been produced in output.
### Q2. How to make ldd produce detailed information in output?
If you want ldd to produce detailed information, including symbol versioning data, you can use the -v command line option. For example, the command
`ldd -v test`
produced the following in output when the **-v** command line option was used:
[![How to make ldd produce detailed information in output](https://www.howtoforge.com/images/command-tutorial/ldd-v-option.png)](https://www.howtoforge.com/images/command-tutorial/big/ldd-v-option.png)
### Q3. How to make ldd produce unused direct dependencies?
For this info, use the **-u** command line option. Here's an example:
`ldd -u test`
[![How to make ldd produce unused direct dependencies](https://www.howtoforge.com/images/command-tutorial/ldd-u-test.png)](https://www.howtoforge.com/images/command-tutorial/big/ldd-u-test.png)
### Q4. How make ldd perform relocations?
There are a couple of command line options you can use here: **-d** and **-r**. While the former tells ldd to perform data relocations, the latter makes ldd perform relocations for both data objects and functions. In both cases, the tool reports missing ELF objects (if any).
`ldd -d`
`ldd -r`
### Q5. How get help on ldd?
The --help command line option makes ldd produce useful usage-related information for the tool.
`ldd --help`
[![How get help on ldd](https://www.howtoforge.com/images/command-tutorial/ldd-help-option.png)](https://www.howtoforge.com/images/command-tutorial/big/ldd-help-option.png)
### Conclusion
Agreed, ldd doesn't fall into the category where tools like cd, rm, and mkdir fit in. That's because it's built for a specific purpose, and it does what it promises. The utility offers limited command line options, and we've covered most of them here. To know more, head to ldd's [man page](https://linux.die.net/man/1/ldd).
* * *
via: [https://www.howtoforge.com/linux-ldd-command/](https://www.howtoforge.com/linux-ldd-command/)
作者: [Himanshu Arora](https://www.howtoforge.com/) 选题者: [@lujun9972](https://github.com/lujun9972) 译者: [译者ID](https://github.com/译者ID) 校对: [校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,103 +0,0 @@
Translating by erialin
Linux Gunzip Command Explained with Examples
======
We have [already discussed][1] the **gzip** command in Linux. For starters, the tool is used to compress or expand files. To uncompress, the command offers a command line option **-d** , which can be used in the following way:
gzip -d [compressed-file-name]
However, there's an entirely different tool that you can use for uncompressing or expanding archives created by gzip. The tool in question is **gunzip**. In this article, we will discuss the gunzip command using some easy to understand examples. Please note that all examples/instructions mentioned in the tutorial have been tested on Ubuntu 16.04.
### Linux gunzip command
So now we know that compressed files can be restored using either 'gzip -d' or the gunzip command. The basic syntax of gunzip is:
gunzip [compressed-file-name]
The following Q&A-style examples should give you a better idea of how the tool works:
### Q1. How to uncompress archives using gunzip?
This is very simple - just pass the name of the archive file as argument to gunzip.
gunzip [archive-name]
For example:
gunzip file1.gz
[![How to uncompress archives using gunzip][2]][3]
### Q2. How to make gunzip not delete archive file?
As you'd have noticed, the gunzip command deletes the archive file after uncompressing it. However, if you want the archive to stay, you can do that using the **-c** command line option.
gunzip -c [archive-name] > [outputfile-name]
For example:
gunzip -c file1.gz > file1
[![How to make gunzip not delete archive file][4]][5]
So you can see that the archive file wasn't deleted in this case.
### Q3. How to make gunzip put the uncompressed file in some other directory?
We've already discussed the **-c** option in the previous Q &A. To make gunzip put the uncompressed file in a directory other than the present working directory, just provide the absolute path after the redirection operator.
gunzip -c [compressed-file] > [/complete/path/to/dest/dir/filename]
Here's an example:
gunzip -c file1.gz > /home/himanshu/file1
### More info
The following details - taken from the common manpage of gzip/gunzip - should be beneficial for those who want to know more about the command:
```
gunzip takes a list of files on its command line and replaces each file
       whose  name ends with .gz, -gz, .z, -z, or _z (ignoring case) and which
       begins with the correct magic number with an uncompressed file  without
       the  original extension.  gunzip also recognizes the special extensions
       .tgz and .taz as shorthands for .tar.gz and .tar.Z respectively.   When
       compressing, gzip uses the .tgz extension if necessary instead of trun
       cating a file with a .tar extension.
       gunzip can currently decompress files created by gzip,  zip,  compress,
       compress  -H  or pack.  The detection of the input format is automatic.
       When using the first two formats, gunzip checks a 32 bit CRC. For  pack
       and gunzip checks the uncompressed length. The standard compress format
       was not designed to allow consistency checks. However gunzip  is  some
       times  able  to  detect  a bad .Z file. If you get an error when uncom
       pressing a .Z file, do not assume that the .Z file  is  correct  simply
       because the standard uncompress does not complain. This generally means
       that the standard uncompress does not check its input, and happily gen
       erates  garbage  output.   The  SCO compress -H format (lzh compression
       method) does not include a CRC but also allows some consistency checks.
```
### Conclusion
As far as basic usage is concerned, there isn't much of a learning curve associated with Gunzip. We've covered pretty much everything that a beginner needs to learn about this command in order to start using it. For more information, head to its [man page][6].
--------------------------------------------------------------------------------
via: https://www.howtoforge.com/linux-gunzip-command/
作者:[Himanshu Arora][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.howtoforge.com
[1]:https://www.howtoforge.com/linux-gzip-command/
[2]:https://www.howtoforge.com/images/linux_gunzip_command/gunzip-basic-usage.png
[3]:https://www.howtoforge.com/images/linux_gunzip_command/big/gunzip-basic-usage.png
[4]:https://www.howtoforge.com/images/linux_gunzip_command/gunzip-c.png
[5]:https://www.howtoforge.com/images/linux_gunzip_command/big/gunzip-c.png
[6]:https://linux.die.net/man/1/gzip

View File

@ -1,113 +0,0 @@
translateing by singledo
Processors - Everything You Need to Know
======
![](http://www.theitstuff.com/wp-content/uploads/2017/10/processors-all-you-need-to-know.jpg)
Our digital devices like Phones, Computers and laptops have grown to become so sophisticated, that they are no longer just devices, they have evolved to become a part of us.
They perform many tasks with the help of apps and software, But have we ever thought to wonder what powers these software? How do they perform their logic? Where is their brain?
We already know that a CPU or **Processor** is the brain of any device that must process data or perform logical tasks.
[![intel processors][1]][1]
But what are the different **concepts behind Processors**? How are they evaluated? How are some processors faster than the others? And many such questions. So let 's have a look at some major terms involved with processors and see how they affect processing speed.
### **Architecture**
Processors come in different architectures, you must have come across different types of programs that say they are for 64Bit or 32Bit. What this means is that those programs support that particular processor architecture.
If a processor has a 32 Bit Architecture it means that it can process 32 Bits of information in one processing cycle.
Similarly, a 64 Bit processor will process 64 Bits in one cycle.
Also, The amount of ram you can use also depends on the architecture. The amount of ram you can use depends upon the amount of memory in powers of 2 ^ architecture of the system.
For a processor with 16-bit architecture, only 64 KB of ram is accessible. For a 32 Bit processor, the maximum usable ram is 4 GB. And for 64 Bit processor, it is 16 Exa-Byte.
### **Cores**
Cores are basically processing units in the computer. They receive instructions and act on it. The more Cores you have, the better your processing speed.
Imagine it like workers in a factory, The more workers you have the faster you will be able to do work.
But more workers will require more salary and there will be a little crowd in the factory. processorsSimilarly, having more cores will definitely boost up processing but more cores need more power and they also heat the CPU a little more than those with fewer cores.
### **Clocking Speed**
We often hear that a processor is of 1 GHz or 2 GHz or 3 GHz. So what are these GHz?
[![cpu speed][2]][2]
GHz is short for GigaHertz. Giga means 'Billion' and Hertz means 'one cycle per second'. So a processor of 2 GHz can perform 2 Billion cycles in one second.
This is also known as 'frequency' or 'Clocking Speed' of your processor. The higher the number the better it is for your CPU.
### **CPU Cache**
CPU cache is a small memory unit inside the processor that stores some memory. Whenever we have to perform some task. Data needs to pass from the RAM to the CPU. Since the CPU works a lot faster than the RAM, most of the time the CPU is idle and waiting for data from the RAM. To solve this the RAM keeps sending data to the CPU Cache continuously.
You usually get 2-3 Mb of CPU cache in most Mid - Range processors. And up to 6 in high-end ones. The more cache your processor has, the better it is.
### **Lithography**
The size of transistors used is the lithographic size of a processor. It is usually measured in NanoMeter and the lesser it is, the more compact your processor will be. This will allow for more cores to fit into the same slot and reduce power consumption.
The latest Intel processors have a lithograph of 14 Nm.
### **Thermal Design Power (TDP)**
It represents the average power, in watts, the processor dissipates when operating at Base Frequency with all cores active under an Intel-defined, high-complexity workload.
So the lower it is, the better for you. A lower TDP not only uses better power but it also generates less heat.
[![battery cpu][3]][3]
Desktop processors usually consume more energy and have a TDP in the range of above 40, Whereas their counterparts Mobile versions consume up to 3 times less energy.
### **Memory Support(RAM)**
I had already mentioned that how processor architecture affects the amount of RAM we can use. But that only holds true for theory. In practical application, the amount of ram you can use is usually enough for that specification of a processor. It is usually specified in the processors' specs.
[![RAM][4]][4]
It also mentions the DDR version number of memory supported.
### **Overclocking**
So I already spoke about clocking speed. Now overclocking is the process of forcing your CPU to perform more cycles.
Gamers usually overclock their processors to get more juice out of their CPU. This surely increases speed but it also increases power consumption and heat generation.
A lot of High-End Processors allow overclocking. But if we wish to overclock an unsupported Processor, we will have to manually install a new BIOS for our motherboard and do it.
This may get the job done but it is neither safe nor suggested doing so.
### **Hyper-Threading**
When adding cores was not convenient to suite a particular processing need, Hyper-Threading was invented to create virtual cores.
So when we say that a dual-core processor has Hyper-Threading, it has 2 physical cores and 2 virtual cores. So it is technically a Quad-core processor in the body of a dual-core one.
### **Conclusion**
A processor has many variables associated with it. And it is the most important part of any digital device. So it is very important that before selecting a device we carefully examine the specifications of its processor keeping all the above variables in mind.
Variables like Clock-Speed, Cores, CPU cache and architecture should be maximum. While it is better that variables like TDP and lithography stay as low as possible.
Still confused about something? Feel free to comment and I will try to reply asap.
--------------------------------------------------------------------------------
via: http://www.theitstuff.com/processors-everything-need-know
作者:[Rishabh Kandari][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.theitstuff.com/author/reevkandari
[1]:http://www.theitstuff.com/wp-content/uploads/2017/10/download.jpg
[2]:http://www.theitstuff.com/wp-content/uploads/2017/10/download-1.jpg
[3]:http://www.theitstuff.com/wp-content/uploads/2017/10/download-2.jpg
[4]:http://www.theitstuff.com/wp-content/uploads/2017/10/images.jpg

View File

@ -1,61 +0,0 @@
translating by lujun9972
Save Some Battery On Our Linux Machines With TLP
======
![](http://www.linuxandubuntu.com/home/save-some-battery-on-our-linux-machines-with-tlp)
I have always found battery life with Linux to be relatively lesser than windows. Nevertheless, this is [Linux][1] and we always have something up our sleeves.
Now talking about this small utility called TLP, that can actually save some juice on your device.
**TLP - Linux Advanced Power Management** is a small command line utility that can genuinely help extend battery life by performing several tweaks on your Linux system.
```
sudo apt install tlp
```
[![install tlp in linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/published/install-tlp-in-linux.jpeg?1517926012)][2]
For other distributions, you can read the instructions from the [official website][3] .
After installation is complete, you will have to run the following command to start tlp for the first time only. TLP will automatically start the next time you boot your system.
[![start tlp on linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/published/start-tlp-on-linux.jpeg?1517926209)][4]
Now TLP has started and it has already made the default configurations needed to save battery. We will now see the configurations file. It is located in **/etc/default/tlp**. We need to edit this file to change various configurations.
There are many options in this file and to enable an option just remove the leading **#** character from that line. There will be instructions about each option and the values that you can allot to it. Some of the things that you will be able to do are -
* Autosuspend USB devices
* Define wireless devices to enable/disable at startup
* Spin down hard drives
* Switch off wireless devices
* Set CPU for performance or power savings
### Conclusion
TLP is an amazing utility that can help save battery life on Linux systems. I have personally found at least 30-40% of extended battery life when using TLP.
--------------------------------------------------------------------------------
via: http://www.linuxandubuntu.com/home/save-some-battery-on-our-linux-machines-with-tlp
作者:[LinuxAndUbuntu][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.linuxandubuntu.com
[1]:http://www.linuxandubuntu.com/home/category/linux
[2]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/edited/install-tlp-in-linux.jpeg
[3]:http://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html
[4]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/edited/start-tlp-on-linux.jpeg

View File

@ -1,3 +1,4 @@
translating by wyxplus
Become a Hollywood movie hacker with these three command line tools
======

View File

@ -0,0 +1,22 @@
我是被 root@notty 黑了吗?
======
当你在 `ps aux` 的输出中看到 `sshdroot@notty` 时会觉得很奇怪吧,`notty` 算是哪门子的主机,是不是黑客计算机的名字啊。不过不用担心; `notty` 仅仅是表示 `no tty` 而已。
当你在本地登陆 linux 机器时,登陆终端会在进程列表中显示为 `tty`( 比如。tty7)。若你通过 ssh 登陆一台远程服务器,则会看到类似 `root@pts/0` 这样的东西。
而若某个连接是由 sftp 或者是由 scp 拷贝文件而创建的,则该连接会会显示成 no tty (notty)。
如果你仍然想知道服务器上发生了什么事情,可以检查 `ps auxf` 的输出来查看进程树,或者运行 `netstat -vatn` 来检查所有的 TCP 连接。
--------------------------------------------------------------------------------
via: http://www.sysadminworld.com/2011/ps-aux-shows-sshd-rootnotty/
作者:[sysadminworld][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.sysadminworld.com

View File

@ -0,0 +1,84 @@
用示例讲解 Linux Gunzip 命令
======
我们已经讨论过[ Linux 下 **gzip** 命令的用法 ][1]。对于初学者来说gzip 工具主要用于压缩或者扩展文件。解压时,在 gzip 命令后添加 -d 选项,使用示例如下:
gzip -d [compressed-file-name]
不过,在解压或扩展 gzip 创建的压缩文件时,有另一款完全不同的工具可供使用。谈及的这款工具就是 **gunzip**。在本文中,我们会使用一些简单、易于理解的例子来解释 gunzip 命令的用法。文中所有示例及指南都在 Ubuntu 16.04 环境下测试。
### Linux gunzip 命令
我们现在知道压缩文件可以用 'gzip -d' 或 gunzip 命令解压。基本的 gunzip 语法为:
gunzip [compressed-file-name]
以下的 Q&A 例子将更清晰地展示 gunzip 工具如何工作:
### Q1. 如何使用 gunzip 解压压缩文件?
解压命令非常简单,仅仅需要将压缩文件名称作为参数传递到 gunzip 命令后。
gunzip [archive-name]
比如:
gunzip file1.gz
[![如何使用 gunzip 解压压缩文件?][2]][3]
### Q2. 如何让 gunzip 不删除原始压缩文件?
正如你已注意到的那样gunzip 命令解压后会删除原始压缩文件。如果你想保留原始压缩文件,可以使用 **-c** 选项。
gunzip -c [archive-name] > [outputfile-name]
比如:
gunzip -c file1.gz > file1
[![如何让 gunzip 不删除原始压缩文件?][4]][5]
使用这种方式,原压缩文件不会被删除。
### Q3. 如何用 gunzip 解压文件到其他路径?
在 Q&A 中我们已经讨论过 **-c** 选项的用法。 使用 gunzip 解压文件到工作目录外的其他路径,仅需要在重定向操作符后添加目标目录的绝对路径即可。
gunzip -c [compressed-file] > [/complete/path/to/dest/dir/filename]
示例如下:
gunzip -c file1.gz > /home/himanshu/file1
### 更多信息
以下从 gzip/gunzip man page 中摘录的细节,对于想了解更多的人会有所助益。
```
gunzip 用命令行列出文件,并且替换每个以正确的幻数开头,后缀名为.gz-gz.z-z或 _z (忽略) 的压缩文件,删除原始文件。 gunzip 也可识别一些特殊扩展名的压缩文件,如 .tgz 和 .taz 分别是 .tar.gz 和 .tar.Z 的缩写。在压缩时gzip 在必要情况下使用 .tgz 作为扩展名,而不是只截取为 .tar 作为后缀。
gunzip 目前可以解压 gzipzipcompresscompress -Hpack 产生的文件。gunzip 自动检测输入文件格式。在使用前两种压缩格式时gunzip 会检验 32 位循环冗余校验码CRC。对于 pack 包gunzip 会检验压缩长度。标准压缩格式设计上不允许相容性检测。不过 gunzip 有时可以检测出坏的 .Z 文件。如果你解压 .Z 文件时出错,不要因为标准解压没报错就认为 .Z 文件一定是正确的。这通常意味着标准解压过程不检测它的输入而是直接产生一个错误的输出。SCO compress -H 格式lzh 压缩方法)不包括 CRC 校验码,但也允许一些相容性检查。
```
### 结语
到目前为止提到的 gunzip 基本用法,并不需要过多的学习曲线。我们已包含了一个初学者开始使用它所必须了解的几乎全部知识。想要了解更多的用法,去看 [man page][6] 吧。
--------------------------------------------------------------------------------
via: https://www.howtoforge.com/linux-gunzip-command/
作者:[Himanshu Arora][a]
译者:[erialin](https://github.com/erialin)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.howtoforge.com
[1]:https://www.howtoforge.com/linux-gzip-command/
[2]:https://www.howtoforge.com/images/linux_gunzip_command/gunzip-basic-usage.png
[3]:https://www.howtoforge.com/images/linux_gunzip_command/big/gunzip-basic-usage.png
[4]:https://www.howtoforge.com/images/linux_gunzip_command/gunzip-c.png
[5]:https://www.howtoforge.com/images/linux_gunzip_command/big/gunzip-c.png
[6]:https://linux.die.net/man/1/gzip

View File

@ -0,0 +1,88 @@
# 关于处理器你需要知道的每件事
[![][b]][b]
```
我们的手机 ,主机以及笔记本电脑已经成长得如此的成熟 ,以至于它们进化成为我们的一部分 ,而不只是一种设备 。
在应用和软件的帮助下 ,处理器执行许多任务 。我们是否曾经想过是什么给了这些软件这样的能力 ?它们是如何执行他们的逻辑的 ?它们的大脑在哪
我们知道 CPU 或者是处理器是那些需要处理数据和执行逻辑任务设备的大脑 。
``
[![cpu image][1]][1]
```
在处理器的深处有那些不一样的概念呢 它们是如何进化的 一些处理器是如何做到比其他处理器更快的 我们来看看关于处理器的主要术语并且它们是如何影响处速度的
```
## 架构
```
处理器有不同的架构 ,你一定偶遇过不同种类的那种你说它们是 64 位或 32 位的程序 ,其中的意思是程序支持特定的处理器架构 。
如果一颗处理器是 32 位的架构 ,意味着这颗处理器能够在一个处理周期内处理一个 32 位的数据 。同理可得 64 位的处理器能够在一个周期内处理一个 64 位的信息 。
你可以使用的 RAM 大小决定于处理器的架构 ,你可以使用的 RAM 总量为处理器架构的幂指数 。
16 位架构的处理器 ,仅仅有 64 kb 的 RAM 使用 。32 位架构的处理器 ,最大可使用的 RAM 是 4 GB 64 位架构的处理器的可用 RAM 是 16 Exa-Byte 。
```
## 内核
```
在电脑上 ,核心是基本的处理单元 。核心接收指令并且执行指令 。越多的核心带来越快的速度 。把核心当成工厂里的工人 ,越多的工人使工作能够越快的完成 。另一方面 ,工人越多 ,你所付出的薪水也就越多 ,工厂也会越拥挤 ;相对于核心来说 ,越多的合兴消耗更多的能量 ,比核心少的 CPU 更容易发热 。
```
## 时钟速度
[![CPU CLOCK SPEED][2]][2]
```
GHZ 是 GigaHertz 的简写 Giga 意思是 Billon Hertz 意思是一秒有几个周期 2 GHZ 的处理器意味着处理器一秒能够执行 2 百万个周期 。
也被作为 `频率` 或者 `时钟速度` 被熟知 。这项数值越高 CPU的性能越好 。
```
## CPU 缓存
```
CPU 缓存是处理器内部的一块小的存储单元 ,用来存储一些内存 。不管如何 ,我们都需要执行一些任务 ,数据需要从 RAM 传递到 CPU CPU 的工作速度远快于 RAM CPU 在大多数时间是在等待从 RAM 传递过来的数据 ,而此时 CPU 是处于空闲状态的 。为了解决这个问题 RAM 持续的向 CPU 缓存发送数据 。一般的处理器会有 2 ~ 3 M 的 CPU 缓存 。高端的处理器会有 6 M CPU 缓存 ,越大的缓存 ,意味着处理器更好 。
```
## 印刷工艺
```
晶体管的大小就是处理器平板印刷的大小 ,尺寸通常是纳米 ,更小的尺寸意味者更好的兼容性 。这允许你更多的核心 ,更小的面积 ,更小的能量消耗 。
这最新的 Intel 处理器有 14 nm 的印刷工艺 。
```
## 热功耗设计
```
代表这电池的能量 ,单位是瓦特 。在全核心激活以基本频率来处理 Intel 模式 ,高复杂度的负载是一种浪费处理器的行为 。
所以 ,越低的热功耗设计 ,对你越好 。一个低的热功耗设计不仅更好的利用电池能量 ,而且产生更少的热量 。
```
[![battery][3]][3]
```
桌面版本的处理器通常消耗更多的能量 ,热功耗消耗的能量能够在 40% 以上 ,相对应的移动版本只有不到桌面版本的 1/3 。
```
## 内存支持
```
我们已经提到了处理器的架构是如何影响到我们能够使用的内存总量 。这样我们只掌握了正确的理论 。在实际的应用中 RAM 的总量对于处理器的规格来说是足够我们使用的 ,由处理器规格详细规定 ,也包含支持的 DDR 版本的内存 。
```
[![RAM][4]][4]
## 超频
```
前面我们讲过时钟频率 ,超频是程序强迫 CPU 执行更多的周期 。游戏玩家经常会使他们的处理器超频 ,以此来获得更好的性能 。这样确实回增加速度 ,但也会增加消耗的能量 ,产生更多的热量 。
一些高端的处理器允许超频 ,如果我们想让一个不支持超平的处理器超频 ,我们需要在主板上安装一个新的 BIOS 。
这样通常下回成功 ,但这种情况是不安全的 ,也是不被建议的 。
```
## 超线程
```
如果对特定的处理需要添加核心是不合适的 ,那么超线程回建立一个虚拟核心 。
当我们说双核处理器有超线程 ,这个双核处理器有两个物理核心和两个虚拟核心 ,在技术上讲 ,一个双核处理器拥有四核核心 。
```
## 结论
```
一个处理器有许多相关的数据 ,这是对数字设备来说是最重要的部分 。我们在选择设备时 ,我们应该在脑海中仔细的检查处理器在上面提到的数据 。
时钟速度 ,核心数 CPU 缓存 ,以及架构是比重最大的数据 。印刷尺寸以及热功耗设计比重要小一些 。
仍然有疑惑 欢迎评论 ,我会尽快回复的 。
```
--------------------------------------------------------------------------------
via: http://www.theitstuff.com/processors-everything-need-know
作者:[Rishabh Kandari][a]
译者:[singledo](https://github.com/singledo)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.theitstuff.com/author/reevkandari
[b]:http://www.theitstuff.com/wp-content/uploads/2017/10/processors-all-you-need-to-know.jpg
[1]:http://www.theitstuff.com/wp-content/uploads/2017/10/download.jpg
[2]:http://www.theitstuff.com/wp-content/uploads/2017/10/download-1.jpg
[3]:http://www.theitstuff.com/wp-content/uploads/2017/10/download-2.jpg
[4]:http://www.theitstuff.com/wp-content/uploads/2017/10/images.jpg
[5]:http://www.theitstuff.com/wp-content/uploads/2017/10/processors-all-you-need-to-know.jpg

View File

@ -0,0 +1,56 @@
TLP 帮助我们的 Linux 机器节能省电
======
![](http://www.linuxandubuntu.com/home/save-some-battery-on-our-linux-machines-with-tlp)
我发现 Linux 下电池的寿命普遍要比 windows 下要短。尽管如此,这可是 [Linux][1],我们总会有有办法的。
现在来讲一下这个名叫 TLP 的小工具,它能帮你的设备省点电。
**TLP - Linux 高级电源管理** 是一个小巧的命令行工具,它通过对 Linux 系统执行一些调整来真正帮助延长电池的寿命。
```
sudo apt install tlp
```
[![install tlp in linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/published/install-tlp-in-linux.jpeg1517926012)][2]
对于其他的发行版,你可以阅读[官方网站 ][3] 上的指南。
安装完成之后,你只有在第一次的时候需要运行下面命令来启动 tlp。TLP 会在下次启动系统时自动运行。
[![start tlp on linux](http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/published/start-tlp-on-linux.jpeg1517926209)][4]
​现在 TLP 已经被启动起来了,而且已经设置好了节省电池所需要的默认配置。我们可以查看该配置文件。文件路径为 **/etc/default/tlp**。我们需要编辑该文件来修改各项配置。
配置文件中有很多选项,要启用某个选项的话之胥敖删除行首的 **#** 就行了。每个选项能够赋予什么值都有说明。下面是你可能会用到的选项 -
* 自动休眠 USB 设备
* 设定启动时启用/禁用无线设备
* 降低硬盘转速
* 关闭无线设备
* 设置 CPU 以性能优先还是节能优先
### 结论
TLP 是一个超棒的工具,可以延长 Linux 系统中电池的寿命。我个人的经验是使用 TLP 能延长至少 30-40% 的电池寿命。
--------------------------------------------------------------------------------
via: http://www.linuxandubuntu.com/home/save-some-battery-on-our-linux-machines-with-tlp
作者:[LinuxAndUbuntu][a]
译者:[lujun9972](https://github.com/lujun9972)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://www.linuxandubuntu.com
[1]:http://www.linuxandubuntu.com/home/category/linux
[2]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/edited/install-tlp-in-linux.jpeg
[3]:http://linrunner.de/en/tlp/docs/tlp-linux-advanced-power-management.html
[4]:http://www.linuxandubuntu.com/uploads/2/1/1/5/21152474/edited/start-tlp-on-linux.jpeg