Merge pull request #29 from LCTT/master

update 2017-04-21
This commit is contained in:
cinlen_0x05 2017-04-21 19:35:14 +08:00 committed by GitHub
commit 08ffd736ec
14 changed files with 975 additions and 608 deletions

View File

@ -0,0 +1,82 @@
让你的 Linux 远离黑客(三):问题回答
============================================================
![Computer security](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/keep-hackers-out.jpg?itok=lqgHDxDu "computer security")
Mike Guthrie 最近在 Linux 基金会的网络研讨会上回答了一些安全相关的问题。随时观看免费的研讨会。[Creative Commons Zero][1]
这个系列的[第一篇][6]和[第二篇][7]文章覆盖了 5 个让你的 Linux 远离黑客的最简单方法,并且知道他们是否已经进入。这一次,我将回答一些我最近在 Linux 基金会网络研讨会上收到的很好的安全性问题。[随时观看免费网络研讨会][8]。
### 如果系统自动使用私钥认证,如何存储密钥密码?
这个很难。这是我们一直在斗争的事情,特别是我们在做 “Red Team” 的时候,因为我们有些需要自动调用的东西。我使用 Expect但我倾向于在这上面使用老方法。你需要编写脚本是的将密码存储在系统上不是那么简单的一件事当你这么做时你需要加密它。
我的 Expect 脚本加密了存储的密码,然后解密,发送密码,并在完成后重新加密。我知道到这有一些缺陷,但它比使用无密码的密钥更好。
如果你有一个无密码的密钥,并且你确实需要使用它。我建议你尽量限制需要用它的用户。例如,如果你正在进行一些自动日志传输或自动化软件安装,则只给那些需要执行这些功能的程序权限。
你可以通过 SSH 运行命令,所以不要给它们一个 shell使它只能运行那个命令就行这样就能防止某人窃取了这个密钥并做其他事情。
### 你对密码管理器如 KeePass2 怎么看?
对我而言,密码管理器是一个非常好的目标。随着 GPU 破解的出现和 EC2 的一些破解能力,这些东西很容易就变成过去时。我一直在窃取这些密码库。
现在,我们在破解这些库的成功率是另外一件事。我们差不多有 10% 左右的破解成功率。如果人们不能为他们的密码库用一个安全的密码,那么我们就会进入并会获得丰硕成果。比不用要强,但是你仍需要保护好这些资产。如你保护其他密码一样保护好密码库。
### 你认为从安全的角度来看,除了创建具有更高密钥长度的主机密钥之外,创建一个新的 “Diffie-Hellman” 模数并限制 2048 位或更高值得么?
值得的。以前在 SSH 产品中存在弱点,你可以做到解密数据包流。有了它,你可以传递各种数据。作为一种加密机制,人们不假思索使用这种方式来传输文件和密码。使用健壮的加密并且改变你的密钥是很重要的。 我会轮换我的 SSH 密钥 - 这不像我的密码那么频繁,但是我每年会轮换一次。是的,这是一个麻烦,但它让我安心。我建议尽可能地使你的加密技术健壮。
### 使用完全随机的英语单词(大概 10 万个)作为密码合适么?
当然。我的密码实际上是一个完整的短语。它是带标点符号和大小写一句话。除此以外,我不再使用其他任何东西。
我是一个“你可以记住而不用写下来或者放在密码库的密码”的大大的支持者。一个你可以记住不必写下来的密码比你需要写下来的密码更安全。
使用短语或使用你可以记住的四个随机单词比那些需要经过几次转换的一串数字和字符的字符串更安全。我目前的密码长度大约是 200 个字符。这是我可以快速打出来并且记住的。
### 在物联网情景下对保护基于 Linux 的嵌入式系统有什么建议么?
物联网是一个新的领域,它是系统和安全的前沿,日新月异。现在,我尽量都保持离线。我不喜欢人们把我的灯光和冰箱搞乱。我故意不去购买支持联网的冰箱,因为我有朋友是黑客,我可不想我每天早上醒来都会看到那些不雅图片。封住它,锁住它,隔离它。
目前物联网设备的恶意软件取决于默认密码和后门,所以只需要对你所使用的设备进行一些研究,并确保没有其他人可以默认访问。然后确保这些设备的管理接口受到防火墙或其他此类设备的良好保护。
### 你可以提一个可以在 SMB 和大型环境中使用的防火墙/UTMOS 或应用程序)么?
我使用 pfSense它是 BSD 的衍生产品。我很喜欢它。它有很多模块,实际上现在它有商业支持,这对于小企业来说这是非常棒的。对于更大的设备、更大的环境,这取决于你有哪些管理员。
我一直都是 CheckPoint 管理员,但是 Palo Alto 也越来越受欢迎了。这些设备与小型企业或家庭使用很不同。我在各种小型网络中都使用 pfSense。
### 云服务有什么内在问题么?
并没有云,那只不过是其他人的电脑而已。云服务存在内在的问题。只知道谁访问了你的数据,你在上面放了什么。要知道当你向 Amazon 或 Google 或 Microsoft 上传某些东西时,你将不再完全控制它,并且该数据的隐私是有问题的。
### 要获得 OSCP 你建议需要准备些什么?
我现在准备通过这个认证。我的整个团队是这样。阅读他们的材料。记住, OSCP 将成为令人反感的安全基准。你一切都要使用 Kali。如果不这样做 - 如果你决定不使用 Kali请确保仿照 Kali 实例安装所有的工具。
这将是一个基于工具的重要认证。这是一个很好的方式。看看一些名为“渗透测试框架”的内容,因为这将为你提供一个很好的测试流程,他们的实验室似乎是很棒的。这与我家里的实验室非常相似。
_[随时免费观看完整的网络研讨会][3]。查看这个系列的[第一篇][4]和[第二篇][5]文章获得 5 个简单的贴士来让你的 Linux 机器安全。_
_Mike Guthrie 为能源部工作,负责 “Red Team” 的工作和渗透测试。_
--------------------------------------------------------------------------------
via: https://www.linux.com/news/webinar/2017/how-keep-hackers-out-your-linux-machine-part-3-your-questions-answered
作者:[MIKE GUTHRIE][a]
译者:[geekpi](https://github.com/geekpi)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.linux.com/users/anch
[1]:https://www.linux.com/licenses/category/creative-commons-zero
[2]:https://www.linux.com/files/images/keep-hackers-outjpg
[3]:http://portal.on24.com/view/channel/index.html?showId=1101876&showCode=linux&partnerref=linco
[4]:https://www.linux.com/news/webinar/2017/how-keep-hackers-out-your-linux-machine-part-1-top-two-security-tips
[5]:https://www.linux.com/news/webinar/2017/how-keep-hackers-out-your-linux-machine-part-2-three-more-easy-security-tips
[6]:https://linux.cn/article-8189-1.html
[7]:https://linux.cn/article-8338-1.html
[8]:http://portal.on24.com/view/channel/index.html?showId=1101876&showCode=linux&partnerref=linco

View File

@ -1,21 +1,21 @@
lnav - Linux 下一个基于控制台的高级日志文件查看器
lnavLinux 下一个基于控制台的高级日志文件查看器
============================================================
[LNAV][3]Log file Navigator是 Linux 下一个基于控制台的高级日志文件查看器。它和其它文件查看器,例如 cat、more、tail 等,完成相同的任务,但有很多普通文件查看器没有的增强功能(尤其是它自带多颜色和易于阅读的格式)。
[LNAV][3]Log file Navigator是 Linux 下一个基于控制台的高级日志文件查看器。它和其它文件查看器,例如 cat、more、tail 等,完成相同的任务,但有很多普通文件查看器没有的增强功能(尤其是它自带多颜色和易于阅读的格式)。
它能在解压所有压缩日志文件zip、gzip、bzip的同时把它们合并到一起进行导航。基于消息的时间戳lnav 能把多个日志文件合并到一个视图Single Log Review从而避免打开多个窗口。左边的颜色栏帮助显示消息所属的文件。
它能在解压多个压缩日志文件zip、gzip、bzip的同时把它们合并到一起进行导航。基于消息的时间戳`lnav` 能把多个日志文件合并到一个视图Single Log Review从而避免打开多个窗口。左边的颜色栏帮助显示消息所属的文件。
警告和错误的数目会被(黄色和红色)高亮显示,因此我们能够很轻易地看到问题出现在哪里。它会自动加载新的日志行。
警告和错误的数量以(黄色和红色)高亮显示,因此我们能够很轻易地看到问题出现在哪里。它会自动加载新的日志行。
它按照消息时间戳排序显示所有文件的日志消息。顶部和底部的状态栏会告诉你在哪个日志文件。如果你想查找特定的模式,只需要在搜索弹窗中输入就会即时显示。
它按照消息时间戳排序显示所有文件的日志消息。顶部和底部的状态栏会告诉你位于哪个日志文件。如果你想按特定的模式查找,只需要在搜索弹窗中输入就会即时显示。
内建的日志消息解析器会自动从每一行中发现和提取详细信息。
服务器日志是一个由服务器创建并经常更新、用于抓取特定服务和应用的所有活动信息的日志文件。当你的应用或者服务出现问题时这个文件就会非常有用。从日志文件中你可以获取所有关于问题的信息,例如基于警告或者错误信息它什么时候开始表现不正常。
服务器日志是一个由服务器创建并经常更新、用于抓取特定服务和应用的所有活动信息的日志文件。当你的应用或者服务出现问题时这个文件就会非常有用。从日志文件中你可以获取所有关于问题的信息,例如基于警告或者错误信息它什么时候开始表现不正常。
当你用一个普通文件查看器打开一个日志文件时,它会用纯文本格式显示所有信息(如果用更直白的话说的话:纯白),这样很难去发现和理解哪里有警告或错误信息。为了克服这种情况,快速找到警告和错误信息来解决问题, lnav 是一个入手可用的更好的解决方案。
当你用一个普通文件查看器打开一个日志文件时,它会用纯文本格式显示所有信息(如果用更直白的话说的话:纯白——黑底白字),这样很难去发现和理解哪里有警告或错误信息。为了克服这种情况,快速找到警告和错误信息来解决问题, lnav 是一个入手可用的更好的解决方案。
大部分普通 Linux 日志文件都放在 `/var/log/`
大部分常见的 Linux 日志文件都放在 `/var/log/`
**lnav 自动检测以下日志格式**
@ -23,33 +23,32 @@ lnav - Linux 下一个基于控制台的高级日志文件查看器
* CUPS page_log
* Syslog
* Glog
* VMware ESXi/vCenter Logs
* VMware ESXi/vCenter 日志
* dpkg.log
* uwsgi
* “Generic” 以时间戳开始的消息
* “Generic” 以时间戳开始的任何消息
* Strace
* sudo
* gzib & bizp
**lnav 高级功能**
* 单一日志视图 - 基于消息时间戳,所有日志文件内容都会被合并到一个单一视图
* 自动日志格式检测 - lnav 支持大部分日志格式
* 单一日志视图 - 基于消息时间戳,所有日志文件内容都会被合并到一个单一视图
* 自动日志格式检测 - `lnav` 支持大部分日志格式
* 过滤器 - 能进行基于正则表达式的过滤
* 时间线视图
* Pretty-Print 视图
* 适宜打印视图Pretty-Print
* 使用 SQL 查询日志
* 自动数据抽取
* 实时操作
* 语法高亮
* Tab 补全
* 当你查看相同文件集时自动保存和恢复会话信息。
* 当你查看相同文件集时可以自动保存和恢复会话信息。
* Headless 模式
### 如何在 Linux 中安装 lnav
#### 如何在 Linux 中安装 lnav
大部分发行版Debian、Ubuntu、Mint、Fedora、suse、openSUSE、Arch Linux、Manjaro、Mageia 等等)默认都有 lvan 软件包,在软件包管理器的帮助下,我们可以很轻易地从发行版官方仓库中安装它。对于 CentOS/RHEL 我们需要启用 **[EPEL 仓库][1]**。
大部分发行版Debian、Ubuntu、Mint、Fedora、suse、openSUSE、Arch Linux、Manjaro、Mageia 等等)默认都有 `lnav` 软件包,在软件包管理器的帮助下,我们可以很轻易地从发行版官方仓库中安装它。对于 CentOS/RHEL 我们需要启用 **[EPEL 仓库][1]**。
```
[在 Debian/Ubuntu/LinuxMint 上安装 lnav]
@ -71,7 +70,7 @@ $ sudo urpmi lnav
$ yaourt -S lnav
```
如果你的发行版没有 lnav 软件包,别担心,开发者提供了 `.rpm 和 .deb` 安装包,因此没有任何问题我们可以轻易安装。确保你从 [开发者 github 页面][4] 下载最新版本的安装包。
如果你的发行版没有 `lnav` 软件包,别担心,开发者提供了 `.rpm``.deb` 安装包,因此我们可以轻易安装。确保你从 [开发者 github 页面][4] 下载最新版本的安装包。
```
[在 Debian/Ubuntu/LinuxMint 上安装 lnav]
@ -91,9 +90,9 @@ $ sudo zypper install https://github.com/tstack/lnav/releases/download/v0.8.1/ln
$ sudo rpm -ivh https://github.com/tstack/lnav/releases/download/v0.8.1/lnav-0.8.1-1.x86_64.rpm
```
#### 不带参数运行 lnav
### 不带参数运行 lnav
默认情况下你不带参数运行 lnav 时它会打开 `syslog` 文件。
默认情况下你不带参数运行 `lnav` 时它会打开 `syslog` 文件。
```
# lnav
@ -103,9 +102,9 @@ $ sudo rpm -ivh https://github.com/tstack/lnav/releases/download/v0.8.1/lnav-0.8
![](http://www.2daygeek.com/wp-content/uploads/2017/01/lnav-advanced-log-file-viewer-1.png)
][5]
#### 使用 lnav 查看特定日志文件
### 使用 lnav 查看特定日志文件
要用 lnav 查看特定的日志文件,在 lnav 命令后面添加日志文件路径。例如我们想看 `/var/log/dpkg.log` 日志文件。
要用 `lnav` 查看特定的日志文件,在 `lnav` 命令后面添加日志文件路径。例如我们想看 `/var/log/dpkg.log` 日志文件。
```
# lnav /var/log/dpkg.log
@ -115,11 +114,11 @@ $ sudo rpm -ivh https://github.com/tstack/lnav/releases/download/v0.8.1/lnav-0.8
![](http://www.2daygeek.com/wp-content/uploads/2017/01/lnav-advanced-log-file-viewer-2.png)
][6]
#### 用 lnav 查看多个日志文件
### 用 lnav 查看多个日志文件
要用 lnav 查看多个日志文件,在 lnav 命令后面逐个添加日志文件路径,用一个空格隔开。例如我们想查看 `/var/log/dpkg.log` 和 `/var/log/kern.log` 日志文件。
要用 `lnav` 查看多个日志文件,在 lnav 命令后面逐个添加日志文件路径,用一个空格隔开。例如我们想查看 `/var/log/dpkg.log` 和 `/var/log/kern.log` 日志文件。
左边的颜色栏帮助显示消息所属的文件。另外顶部状态栏还会显示当前日志文件的名称。为了显示多个日志文件,大部分应用习惯打开多个窗口、或者在窗口中水平或竖直切分,但 lnav 使用不同的方式(它基于日期组合在同一个窗口显示多个日志文件)。
左边的颜色栏帮助显示消息所属的文件。另外顶部状态栏还会显示当前日志文件的名称。为了显示多个日志文件,大部分应用经常会打开多个窗口、或者在窗口中水平或竖直切分,但 `lnav` 使用不同的方式(它基于日期组合在同一个窗口显示多个日志文件)。
```
# lnav /var/log/dpkg.log /var/log/kern.log
@ -129,9 +128,9 @@ $ sudo rpm -ivh https://github.com/tstack/lnav/releases/download/v0.8.1/lnav-0.8
![](http://www.2daygeek.com/wp-content/uploads/2017/01/lnav-advanced-log-file-viewer-3.png)
][7]
#### 使用 lnav 查看压缩的日志文件
### 使用 lnav 查看压缩的日志文件
要查看并同时解压被压缩的日志文件zip、gzip、bzip在 lnav 命令后面添加 `-r` 选项。
要查看并同时解压被压缩的日志文件zip、gzip、bzip`lnav` 命令后面添加 `-r` 选项。
```
# lnav -r /var/log/Xorg.0.log.old.gz
@ -141,30 +140,34 @@ $ sudo rpm -ivh https://github.com/tstack/lnav/releases/download/v0.8.1/lnav-0.8
![](http://www.2daygeek.com/wp-content/uploads/2017/01/lnav-advanced-log-file-viewer-6.png)
][8]
#### 直方图视图
### 直方图视图
首先运行 `lnav` 然后按 `i` 键切换到/出直方图视图。
[
![](http://www.2daygeek.com/wp-content/uploads/2017/01/lnav-advanced-log-file-viewer-4.png)
][9]
#### 查看日志解析器结果
### 查看日志解析器结果
首先运行 `lnav` 然后按 `p` 键打开显示日志解析器结果。
[
![](http://www.2daygeek.com/wp-content/uploads/2017/01/lnav-advanced-log-file-viewer-5.png)
][10]
#### 语法高亮
### 语法高亮
你可以搜索任何给定的字符串,它会在屏幕上高亮显示。首先运行 `lnav` 然后按 `/` 键并输入你想查找的字符串。为了测试,我搜索字符串 `Default`,看下面的截图。
[
![](http://www.2daygeek.com/wp-content/uploads/2017/01/lnav-advanced-log-file-viewer-7.png)
][11]
#### Tab 补全
### Tab 补全
命令窗口支持大部分操作的 tab 补全。例如,在进行搜索时,你可以使用 tab 补全屏幕上显示的单词,而不需要复制粘贴。为了测试,我搜索字符串 `/var/log/Xorg`,看下面的截图。
[
![](http://www.2daygeek.com/wp-content/uploads/2017/01/lnav-advanced-log-file-viewer-8.png)
][12]
@ -176,7 +179,7 @@ via: http://www.2daygeek.com/install-and-use-advanced-log-file-viewer-navigator-
作者:[Magesh Maruthamuthu][a]
译者:[ictlyh](https://github.com/ictlyh)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -0,0 +1,99 @@
使用 LXDE 的 8 个理由
============================================================
> 考虑使用轻量级桌面环境 LXDE 作为你 Linux 桌面的理由
![使用 LXDE 的 8 个理由](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/rh_003499_01_linux31x_cc.png?itok=1HXbvw2E "8 reasons to use LXDE")
>Image by : opensource.com
去年年底,升级到 Fedora 25 所装的新版本 [KDE][7] Plasma 给我带来了严重问题,让我难以完成任何工作。出于两个原因我决定尝试其它 Linux 桌面环境。第一,我需要完成我的工作。第二,一心使用 KDE 已经有很多年,我认为是时候尝试一些不同的桌面了。
我第一个尝试了几周的替代桌面是 [Cinnamon][8],我在 1 月份介绍过它。这次我已经使用了 LXDE轻量级 X11 桌面环境(Lightweight X11 Desktop Environment))大概 6 周,我发现它有很多我喜欢的东西。这是我使用 LXDE 的 8 个理由。
更多 Linux 相关资源
* [Linux 是什么?][1]
* [Linux 容器是什么?][2]
* [在 Linux 中管理设备][3]
* [马上下载Linux 命令速查表][4]
* [我们最新的 Linux 文章][5]
### 1、 LXDE 支持多个面板
和 KDE 以及 Cinnamon 一样LXDE 支持包括系统菜单、应用启动器的面板,以及显示正在运行应用图标的任务栏。我第一次登录到 LXDE 时面板的配置看起来异常熟悉。LDXE 看起来已经根据我的 KDE 配置情况为我准备好了喜欢的顶部和底部面板,并包括了系统托盘设置。顶部面板上的应用程序启动器看似来自 Cinnamon 。面板上的东西使得启动和管理程序变得容易。默认情况下,只在桌面底部有一个面板。
![打开了 Openbox Configuration Manager 的 LXDE 桌面。](https://opensource.com/sites/default/files/lxde-openboxconfigurationmanager.png "打开了 Openbox Configuration Manager 的 LXDE 桌面。")
*打开了 Openbox 配置管理器的 LXDE 桌面。这个桌面还没有更改过,因此它使用了默认的颜色和图标主题。*
### 2、 Openbox 配置管理器提供了一个用于管理和体验桌面外观的简单工具。
它为主题、窗口修饰、多个显示器的窗口行为、移动和调整窗口大小、鼠标控制、多桌面等提供了选项。虽然这看起来似乎很多,但它远不如配置 KDE 桌面那么复杂,尽管如此 Openbox 仍然提供了绝佳的效果。
### 3、 LXDE 有一个强大的菜单工具
在桌面偏好Desktop Preference菜单的高级Advanced标签页有个有趣的选项。这个选项的名称是 “点击桌面时显示窗口管理器提供的菜单Show menus provided by window managers when desktop is clicked”。选中这个复选框当你右击桌面时会显示 Openbox 桌面菜单,而不是标准的 LXDE 桌面菜单。
Openbox 桌面菜单包括了几乎每个你可能想要的菜单选项,所有都可从桌面便捷访问。它包括了所有的应用程序菜单、系统管理、以及首选项。它甚至有一个菜单包括了所有已安装的终端模拟器应用程序的列表,因此系统管理员可以轻易地启动他们喜欢的终端。
### 4、 LXDE 桌面的设计干净简单
它没有任何会妨碍你完成工作的东西。尽管你可以添加一些文件、目录、应用程序的链接到桌面,但是没有可以添加到桌面的小部件。在我的 KDE 和 Cinnamon 桌面上我确实喜欢一些小部件,但它们很容易被覆盖住,然后我就需要移动或者最小化窗口,或者使用 “显示桌面Show Desktop” 按钮清空整个桌面才能看到它们。 LXDE 确实有一个 “图标化所有窗口Iconify all windows” 按钮,但我很少需要使用它,除非我想看我的壁纸。
### 5、 LXDE 有一个强大的文件管理器
LXDE 默认的文件管理器是 PCManFM因此在我使用 LXDE 的时候它成为了我的文件管理器。PCManFM 非常灵活、可以配置为适用于大部分人和场景。它看起来没有我常用的文件管理器 Krusader 那么可配置,但我确实喜欢 Krusader 所没有的 PCManFM 侧边栏。
PCManFM 允许打开多个标签页可以通过右击侧边栏的任何条目或者单击图标栏的新标签图标打开。PCManFM 窗口左边的位置Places面板显示了应用程序菜单你可以从 PCManFM 启动应用程序。位置Places面板上面也显示了一个设备图标可以用于查看你的物理存储设备一系列带按钮的可移除设备允许你挂载和卸载它们还有可以便捷访问的主目录、桌面、回收站。位置Places面板的底部包括一些默认目录的快捷方式例如 Documents、Music、Pictures、Videos 以及 Downloads。你也可以拖拽其它目录到位置Places面板的快捷方式部分。位置Places 面板可以换为正常的目录树。
### 6、 如果在现有窗口后面打开,新窗口的标题栏会闪烁
这是一个在大量现有窗口中定位新窗口的好方法。
### 7、 大部分现代桌面环境允许多个桌面LXDE 也不例外
我喜欢使用一个桌面用于我的开发、测试以及编辑工作另一个桌面用于普通任务例如电子邮件和网页浏览。LXDE 默认提供两个桌面但你可以配置为只有一个或者多个。右击桌面切换器Desktop Pager配置它。
通过一些有害但不是破坏性的测试,我发现最大允许桌面数目是 100。我还发现当我把桌面数目减少到低于我实际已经在使用的 3 个时,不活动桌面上的窗口会被移动到桌面 1。多么有趣的发现
### 8、 Xfce 电源管理器是一个小巧但强大的应用程序,它允许你配置电源管理如何工作
它提供了一个标签页用于通用配置,以及用于系统、显示和设备的标签页。设备标签页显示了我系统上已有设备的表格,例如电池供电的鼠标、键盘,甚至我的 UPS不间断电源。它显示了每个设备的详细信息包括厂商和系列号如果可用的话还有电池充电状态。当我写这篇博客的时候我 UPS 的电量是 100%,而我罗技鼠标的电量是 75%。 Xfce 电源管理器还在系统托盘显示了一个图标,因此你可以从那里快速了解你设备的电池状态。
关于 LXDE 桌面还有很多喜欢的东西,但这些就是抓住了我的注意力,它们也是对我使用现代图形用户界面工作非常重要、不可或缺的东西。
我注意到奇怪的一点是我一直没有弄明白桌面Openbox菜单的 “重新配置Reconfigure” 选项是干什么的。我点击了几次,从没有注意到有任何类型的任何活动表明该选项实际起了作用。
我发现 LXDE 是一个简单但强大的桌面。我享受使用它写这篇文章的几周时间。通过允许我访问我想要的应用程序和文件同时在其余时间保持不会让我分神LXDE 使我得以高效地工作。我也没有遇到任何妨碍我完成工作的问题——当然,除了我用于探索这个好桌面所花的时间。我非常推荐 LXDE 桌面。
我现在正在试用 GNOME 3 和 GNOME Shell并将在下一期中报告。
--------------------------------------------------------------------------------
作者简介:
David Both 是一个 Linux 和开源倡导者,他居住在北卡罗莱纳州的 Raleigh。他在 IT 行业已经超过 40 年,在他工作的 IBM 公司教授 OS/2 超过 20 年,他在 1981 年为最早的 IBM PC 写了第一个培训课程。他教过 Red Hat 的 RHCE 课程,在 MCI Worldcom、 Cisco 和北卡罗莱纳州 工作过。他一直在使用 Linux 和开源软件近 20 年。
--------------------------------------
via: https://opensource.com/article/17/3/8-reasons-use-lxde
作者:[David Both][a]
译者:[ictlyh](https://github.com/ictlyh)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://opensource.com/users/dboth
[1]:https://opensource.com/resources/what-is-linux?src=linux_resource_menu
[2]:https://opensource.com/resources/what-are-linux-containers?src=linux_resource_menu
[3]:https://opensource.com/article/16/11/managing-devices-linux?src=linux_resource_menu
[4]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=7016000000127cYAAQ
[5]:https://opensource.com/tags/linux?src=linux_resource_menu
[6]:https://opensource.com/article/17/3/8-reasons-use-lxde?rate=QigvkBy_9zLvktdsL-QaIWedjIqjtlwwJIVFQDQzsSY
[7]:https://opensource.com/life/15/4/9-reasons-to-use-kde
[8]:https://opensource.com/article/17/1/cinnamon-desktop-environment
[9]:https://opensource.com/user/14106/feed
[10]:https://opensource.com/article/17/3/8-reasons-use-lxde#comments
[11]:https://opensource.com/users/dboth

View File

@ -1,10 +1,11 @@
# Anbox
Anbox容器中的 Android
===============
Anbox 是一个基于容器的方式,在像 Ubuntu 这样的常规的 GNU Linux 系统上启动一个完整的 Android 系统。
Anbox 以基于容器的方式,在像 Ubuntu 这样的常规的 GNU Linux 系统上启动一个完整的 Android 系统。
## 概述
### 概述
Anbox 使用 Linux 命名空间user、pid、uts、net、mount、ipc来在容器中运行完整的 Android 系统,并提供任何基于 GNU Linux 平台的 Android 程序
Anbox 使用 Linux 命名空间user、pid、uts、net、mount、ipc来在容器中运行完整的 Android 系统,并在任何基于 GNU Linux 平台上提供 Android 应用
容器内的 Android 无法直接访问任何硬件。所有硬件访问都通过主机上的 anbox 守护进程进行。我们重用基于 QEMU 的模拟器实现的 Android 中的 GL、ES 加速渲染。容器内的 Android 系统使用不同的管道与主机系统通信,并通过它发送所有硬件访问命令。
@ -15,19 +16,19 @@ Anbox 使用 Linux 命名空间user、pid、uts、net、mount、ipc来在
* [Android 的 “qemud” 复用守护进程](https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/android/docs/ANDROID-QEMUD.TXT)
* [Android qemud 服务](https://android.googlesource.com/platform/external/qemu/+/emu-master-dev/android/docs/ANDROID-QEMUD-SERVICES.TXT)
Anbox 目前适合桌面使用,但也可使用移动操作系统,如 Ubuntu Touch、Sailfish OS 或 Lune OS。然而由于 Android 程序映射目前只针对桌面环境,因此还需要额外的工作来支持其他的用户界面。
Anbox 目前适合桌面使用,但也用移动操作系统,如 Ubuntu Touch、Sailfish OS 或 Lune OS。然而由于 Android 程序映射目前只针对桌面环境,因此还需要额外的工作来支持其他的用户界面。
Android 运行时环境带有一个基于[ Android 开源项目](https://source.android.com/)镜像的最小自定义 Android 系统。所使用的镜像目前基于 Android 7.1.1。
Android 运行时环境带有一个基于 [Android 开源项目](https://source.android.com/)镜像的最小自定义 Android 系统。所使用的镜像目前基于 Android 7.1.1。
## 安装
### 安装
目前,安装过程包括一些添加额外组件到系统的步骤。包括:
  * 没有分发版内核同时启用的 binder 和 ashmen 原始内核模块。
  * 使用 udev 规则为 /dev/binder 和 /dev/ashmem 设置正确权限。
  * 能够启动 Anbox 会话管理器作为用户会话的一个启动任务。
* 启用用于 binder 和 ashmen 的非发行的树外内核模块。
* 使用 udev 规则为 /dev/binder 和 /dev/ashmem 设置正确权限。
* 能够启动 Anbox 会话管理器作为用户会话的一个启动任务。
为了使这个过程尽可能简单,我们将必要的步骤绑定在一个 snap见 https://snapcraft.io称为“anbox-installer”。这个安装程序会执行所有必要的步骤。你可以在所有支持 snap 的系统运行下面的命令安装它。
为了使这个过程尽可能简单,我们将必要的步骤绑定在一个 snap见 https://snapcraft.io 中,称 “anbox-installer”。这个安装程序会执行所有必要的步骤。你可以在所有支持 snap 的系统运行下面的命令安装它。
```
$ snap install --classic anbox-installer
@ -49,11 +50,11 @@ $ anbox-installer
它会引导你完成安装过程。
**注意:** Anbox 目前处于** pre-alpha 开发状态**。不要指望它具有生产环境你需要的所有功能。你肯定会遇到错误和崩溃。如果你遇到了,请不要犹豫并报告它们!
**注意:** Anbox 目前处于 **pre-alpha 开发状态**。不要指望它具有生产环境你需要的所有功能。你肯定会遇到错误和崩溃。如果你遇到了,请不要犹豫并报告它们!
**注意:** Anbox snap 目前 **完全没有约束**,因此它只能从边缘渠道获取。正确的约束是我们想要在未来实现的,但由于 Anbox 的性质和复杂性,这不是一个简单的任务。
## 已支持的 Linux 发行版
### 已支持的 Linux 发行版
目前我们官方支持下面的 Linux 发行版:
@ -65,9 +66,9 @@ $ anbox-installer
* Ubuntu 16.10 (yakkety)
* Ubuntu 17.04 (zesty)
## 安装并运行 Android 程序
### 安装并运行 Android 程序
## 从源码构建
#### 从源码构建
要构建 Anbox 运行时不需要特别了解什么,我们使用 cmake 作为构建系统。你的主机系统中应已有下面这些构建依赖:
@ -132,11 +133,11 @@ $ snapcraft
$ snap install --dangerous --devmode anbox_1_amd64.snap
```
## 运行 Anbox
#### 运行 Anbox
要从本地构建运行 Anbox ,你需要了解更多一点。请参考[“运行时步骤”](docs/runtime-setup.md)文档。
## 文档
### 文档
在项目源代码的子目录下,你可以找到额外的关于 Anbox 的文档。
@ -145,15 +146,15 @@ $ snap install --dangerous --devmode anbox_1_amd64.snap
* [运行时步骤](docs/runtime-setup.md)
* [构建 Android 镜像](docs/build-android.md)
## 报告 bug
### 报告 bug
如果你发现了一个 Anbox 问题,请[提交一个 bug](https://github.com/anbox/anbox/issues/new)。
如果你发现了一个 Anbox 问题,请[提交 bug](https://github.com/anbox/anbox/issues/new)。
## 取得联系
### 取得联系
如果你想要与开发者联系,你可以在 [FreeNode](https://freenode.net/) 中加入 *#anbox* 的 IRC 频道。
## 版权与许可
### 版权与许可
Anbox 重用了像 Android QEMU 模拟器这样的其他项目的代码。这些项目可在外部/带有许可声明的子目录中得到。
@ -163,7 +164,7 @@ anbox 源码本身,如果没有在相关源码中声明其他的许可,默
via: https://github.com/anbox/anbox/blob/master/README.md
作者:[ Anbox][a]
作者:[Anbox][a]
译者:[geekpi](https://github.com/geekpi)
校对:[jasminepeng](https://github.com/jasminepeng)

View File

@ -1,3 +1,5 @@
YYforymj is translating.
[How debuggers work: Part 3 - Debugging information][25]
============================================================

View File

@ -1,345 +0,0 @@
ictlyh Translating
All You Need To Know About Processes in Linux [Comprehensive Guide]
============================================================
In this article, we will walk through a basic understanding of processes and briefly look at [how to manage processes in Linux][9] using certain commands.
A process refers to a program in execution; its a running instance of a program. It is made up of the program instruction, data read from files, other programs or input from a system user.
#### Types of Processes
There are fundamentally two types of processes in Linux:
* Foreground processes (also referred to as interactive processes) these are initialized and controlled through a terminal session. In other words, there has to be a user connected to the system to start such processes; they havent started automatically as part of the system functions/services.
* Background processes (also referred to as non-interactive/automatic processes) are processes not connected to a terminal; they dont expect any user input.
#### What is Daemons
These are special types of background processes that start at system startup and keep running forever as a service; they dont die. They are started as system tasks (run as services), spontaneously. However, they can be controlled by a user via the init process.
[
![Linux Process State](http://www.tecmint.com/wp-content/uploads/2017/03/ProcessState.png)
][10]
Linux Process State
### Creation of a Processes in Linux
A new process is normally created when an existing process makes an exact copy of itself in memory. The child process will have the same environment as its parent, but only the process ID number is different.
There are two conventional ways used for creating a new process in Linux:
* Using The System() Function  this method is relatively simple, however, its inefficient and has significantly certain security risks.
* Using fork() and exec() Function  this technique is a little advanced but offers greater flexibility, speed, together with security.
### How Does Linux Identify Processes?
Because Linux is a multi-user system, meaning different users can be running various programs on the system, each running instance of a program must be identified uniquely by the kernel.
And a program is identified by its process ID (PID) as well as its parent processes ID (PPID), therefore processes can further be categorized into:
* Parent processes  these are processes that create other processes during run-time.
* Child processes  these processes are created by other processes during run-time.
#### The Init Process
Init process is the mother (parent) of all processes on the system, its the first program that is executed when the [Linux system boots up][11]; it manages all other processes on the system. It is started by the kernel itself, so in principle it does not have a parent process.
The init process always has process ID of 1. It functions as an adoptive parent for all orphaned processes.
You can use the pidof command to find the ID of a process:
```
# pidof systemd
# pidof top
# pidof httpd
```
[
![Find Linux Process ID](http://www.tecmint.com/wp-content/uploads/2017/03/Find-Linux-Process-ID.png)
][12]
Find Linux Process ID
To find the process ID and parent process ID of the current shell, run:
```
$ echo $$
$ echo $PPID
```
[
![Find Linux Parent Process ID](http://www.tecmint.com/wp-content/uploads/2017/03/Find-Linux-Parent-Process-ID.png)
][13]
Find Linux Parent Process ID
#### Starting a Process in Linux
Once you run a command or program (for example cloudcmd CloudCommander), it will start a process in the system. You can start a foreground (interactive) process as follows, it will be connected to the terminal and a user can send input it:
```
# cloudcmd
```
[
![Start Linux Interactive Process](http://www.tecmint.com/wp-content/uploads/2017/03/Start-Linux-Interactive-Process.png)
][14]
Start Linux Interactive Process
#### Linux Background Jobs
To start a process in the background (non-interactive), use the `&` symbol, here, the process doesnt read input from a user until its moved to the foreground.
```
# cloudcmd &
# jobs
```
[
![Start Linux Process in Background](http://www.tecmint.com/wp-content/uploads/2017/03/Start-Linux-Process-in-Background.png)
][15]
Start Linux Process in Background
You can also send a process to the background by suspending it using `[Ctrl + Z]`, this will send the SIGSTOP signal to the process, thus stopping its operations; it becomes idle:
```
# tar -cf backup.tar /backups/* #press Ctrl+Z
# jobs
```
To continue running the above-suspended command in the background, use the bg command:
```
# bg
```
To send a background process to the foreground, use the fg command together with the job ID like so:
```
# jobs
# fg %1
```
[
![Linux Background Process Jobs](http://www.tecmint.com/wp-content/uploads/2017/03/Linux-Background-Process-Jobs.png)
][16]
Linux Background Process Jobs
You may also like: [How to Start Linux Command in Background and Detach Process in Terminal][17]
#### States of a Process in Linux
During execution, a process changes from one state to another depending on its environment/circumstances. In Linux, a process has the following possible states:
* Running  here its either running (it is the current process in the system) or its ready to run (its waiting to be assigned to one of the CPUs).
* Waiting  in this state, a process is waiting for an event to occur or for a system resource. Additionally, the kernel also differentiates between two types of waiting processes; interruptible waiting processes can be interrupted by signals and uninterruptible waiting processes are waiting directly on hardware conditions and cannot be interrupted by any event/signal.
* Stopped  in this state, a process has been stopped, usually by receiving a signal. For instance, a process that is being debugged.
* Zombie  here, a process is dead, it has been halted but its still has an entry in the process table.
#### How to View Active Processes in Linux
There are several Linux tools for viewing/listing running processes on the system, the two traditional and well known are [ps][18] and [top][19] commands:
#### 1\. ps Command
It displays information about a selection of the active processes on the system as shown below:
```
# ps
# ps -e | head
```
[
![List Linux Active Processes](http://www.tecmint.com/wp-content/uploads/2017/03/ps-command.png)
][20]
List Linux Active Processes
#### 2\. top System Monitoring Tool
[top is a powerful tool][21] that offers you a [dynamic real-time view of a running system][22] as shown in the screenshot below:
```
# top
```
[
![List Linux Running Processes](http://www.tecmint.com/wp-content/uploads/2017/03/top-command.png)
][23]
List Linux Running Processes
Read this for more top usage examples: [12 TOP Command Examples in Linux][24]
#### 3\. glances System Monitoring Tool
glances is a relatively new system monitoring tool with advanced features:
```
# glances
```
[
![Glances - Linux Process Monitoring](http://www.tecmint.com/wp-content/uploads/2017/03/glances.png)
][25]
Glances Linux Process Monitoring
For a comprehensive usage guide, read through: [Glances An Advanced Real Time System Monitoring Tool for Linux][26]
There are several other useful Linux system monitoring tools you can use to list active processes, open the link below to read more about them:
1. [20 Command Line Tools to Monitor Linux Performance][1]
2. [13 More Useful Linux Monitoring Tools][2]
### How to Control Processes in Linux
Linux also has some commands for controlling processes such as kill, pkill, pgrep and killall, below are a few basic examples of how to use them:
```
$ pgrep -u tecmint top
$ kill 2308
$ pgrep -u tecmint top
$ pgrep -u tecmint glances
$ pkill glances
$ pgrep -u tecmint glances
```
[
![Control Linux Processes](http://www.tecmint.com/wp-content/uploads/2017/03/Control-Linux-Processes.png)
][27]
Control Linux Processes
To learn how to use these commands in-depth, to kill/terminate active processes in Linux, open the links below:
1. [A Guide to Kill, Pkill and Killall Commands to Terminate Linux Processess][3]
2. [How to Find and Kill Running Processes in Linux][4]
Note that you can use them to kill [unresponsive applications in Linux][28] when your system freezes.
#### Sending Signals To Processes
The fundamental way of controlling processes in Linux is by sending signals to them. There are multiple signals that you can send to a process, to view all the signals run:
```
$ kill -l
```
[
![List All Linux Signals](http://www.tecmint.com/wp-content/uploads/2017/03/list-all-signals.png)
][29]
List All Linux Signals
To send a signal to a process, use the kill, pkill or pgrep commands we mentioned earlier on. But programs can only respond to signals if they are programmed to recognize those signals.
And most signals are for internal use by the system, or for programmers when they write code. The following are signals which are useful to a system user:
* SIGHUP 1  sent to a process when its controlling terminal is closed.
* SIGINT 2  sent to a process by its controlling terminal when a user interrupts the process by pressing `[Ctrl+C]`.
* SIGQUIT 3  sent to a process if the user sends a quit signal `[Ctrl+D]`.
* SIGKILL 9  this signal immediately terminates (kills) a process and the process will not perform any clean-up operations.
* SIGTERM 15  this a program termination signal (kill will send this by default).
* SIGTSTP 20  sent to a process by its controlling terminal to request it to stop (terminal stop); initiated by the user pressing `[Ctrl+Z]`.
The following are kill commands examples to kill the Firefox application using its PID once it freezes:
```
$ pidof firefox
$ kill 9 2687
OR
$ kill -KILL 2687
OR
$ kill -SIGKILL 2687
```
To kill an application using its name, use pkill or killall like so:
```
$ pkill firefox
$ killall firefox
```
#### Changing Linux Process Priority
On the Linux system, all active processes have a priority and certain nice value. Processes with higher priority will normally get more CPU time than lower priority processes.
However, a system user with root privileges can influence this with the nice and renice commands.
From the output of the top command, the NI shows the process nice value:
```
$ top
```
[
![List Linux Running Processes](http://www.tecmint.com/wp-content/uploads/2017/03/top-command.png)
][30]
List Linux Running Processes
Use the nice command to set a nice value for a process. Keep in mind that normal users can attribute a nice value from zero to 20 to processes they own.
Only the root user can use negative nice values.
To renice the priority of a process, use the renice command as follows:
```
$ renice +8 2687
$ renice +8 2103
```
Check out our some useful articles on how to manage and control Linux processes.
1. [Linux Process Management: Boot, Shutdown, and Everything in Between][5]
2. [Find Top 15 Processes by Memory Usage with top in Batch Mode][6]
3. [Find Top Running Processes by Highest Memory and CPU Usage in Linux][7]
4. [How to Find a Process Name Using PID Number in Linux][8]
Thats all for now! Do you have any questions or additional ideas, share them with us via the feedback form below.
--------------------------------------------------------------------------------
作者简介:
Aaron Kili is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, web developer, and currently a content creator for TecMint who loves working with computers and strongly believes in sharing knowledge.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/linux-process-management/
作者:[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/linux-performance-monitoring-tools/
[3]:http://www.tecmint.com/how-to-kill-a-process-in-linux/
[4]:http://www.tecmint.com/find-and-kill-running-processes-pid-in-linux/
[5]:http://www.tecmint.com/rhcsa-exam-boot-process-and-process-management/
[6]:http://www.tecmint.com/find-processes-by-memory-usage-top-batch-mode/
[7]:http://www.tecmint.com/find-linux-processes-memory-ram-cpu-usage/
[8]:http://www.tecmint.com/find-process-name-pid-number-linux/
[9]:http://www.tecmint.com/dstat-monitor-linux-server-performance-process-memory-network/
[10]:http://www.tecmint.com/wp-content/uploads/2017/03/ProcessState.png
[11]:http://www.tecmint.com/linux-boot-process/
[12]:http://www.tecmint.com/wp-content/uploads/2017/03/Find-Linux-Process-ID.png
[13]:http://www.tecmint.com/wp-content/uploads/2017/03/Find-Linux-Parent-Process-ID.png
[14]:http://www.tecmint.com/wp-content/uploads/2017/03/Start-Linux-Interactive-Process.png
[15]:http://www.tecmint.com/wp-content/uploads/2017/03/Start-Linux-Process-in-Background.png
[16]:http://www.tecmint.com/wp-content/uploads/2017/03/Linux-Background-Process-Jobs.png
[17]:http://www.tecmint.com/run-linux-command-process-in-background-detach-process/
[18]:http://www.tecmint.com/linux-boot-process-and-manage-services/
[19]:http://www.tecmint.com/12-top-command-examples-in-linux/
[20]:http://www.tecmint.com/wp-content/uploads/2017/03/ps-command.png
[21]:http://www.tecmint.com/12-top-command-examples-in-linux/
[22]:http://www.tecmint.com/bcc-best-linux-performance-monitoring-tools/
[23]:http://www.tecmint.com/wp-content/uploads/2017/03/top-command.png
[24]:http://www.tecmint.com/12-top-command-examples-in-linux/
[25]:http://www.tecmint.com/wp-content/uploads/2017/03/glances.png
[26]:http://www.tecmint.com/glances-an-advanced-real-time-system-monitoring-tool-for-linux/
[27]:http://www.tecmint.com/wp-content/uploads/2017/03/Control-Linux-Processes.png
[28]:http://www.tecmint.com/kill-processes-unresponsive-programs-in-ubuntu/
[29]:http://www.tecmint.com/wp-content/uploads/2017/03/list-all-signals.png
[30]:http://www.tecmint.com/wp-content/uploads/2017/03/top-command.png
[31]:http://www.tecmint.com/author/aaronkili/
[32]:http://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/
[33]:http://www.tecmint.com/free-linux-shell-scripting-books/

View File

@ -0,0 +1,346 @@
[调试器的工作原理:第一篇-基础][21]
============================================================
这是调试器工作原理系列文章的第一篇,我不确定这个系列会有多少篇文章,会涉及多少话题,但我仍会从这篇基础开始。
### 这一篇会讲什么
我将为大家展示 Linux 中调试器的主要构成模块 - ptrace 系统调用。这篇文章所有代码都是基于 32 位 Ubuntu 操作系统.值得注意的是,尽管这些代码是平台相关的,将他们移植到其他平台应该并不困难。
### 缘由
为了理解我们要做什么,让我们先考虑下调试器为了完成调试都需要什么资源。调试器可以开始一个进程并调试这个进程,又或者将自己同某个已经存在的进程关联起来。调试器能够单步执行代码,设定断点并且将程序执行到断点,检查变量的值并追踪堆栈。许多调试器有着更高级的特性,例如在调试器的地址空间内执行表达式或者调用函数,甚至可以在进程执行过程中改变代码并观察效果。
尽管现代的调试器都十分的复杂 [[1]][13],但他们的工作的原理却是十分的简单。调试器的基础是操作系统与编译器 / 链接器提供的一些基础服务,其余的部分只是[简单的编程][14]。
### Linux 的调试 - ptrace
Linux 调试器中的瑞士军刀便是 ptrace 系统调用 [[2]][15]。这是一种复杂却强大的工具,可以允许一个进程控制另外一个进程并从内部替换被控制进程的内核镜像的值[[3]][16].。
接下来会深入分析。
### 执行进程的代码
我将编写一个示例,实现一个在“跟踪”模式下运行的进程。在这个模式下,我们将单步执行进程的代码,就像机器码(汇编代码)被 CPU 执行时一样。我将分段展示、讲解示例代码,在文章的末尾也有完整 c 文件的下载链接,你可以编译、执行或者随心所欲的更改。
更进一步的计划是实现一段代码,这段代码可以创建可执行用户自定义命令的子进程,同时父进程可以跟踪子进程。首先是主函数:
```
int main(int argc, char** argv)
{
pid_t child_pid;
if (argc < 2) {
fprintf(stderr, "Expected a program name as argument\n");
return -1;
}
child_pid = fork();
if (child_pid == 0)
run_target(argv[1]);
else if (child_pid > 0)
run_debugger(child_pid);
else {
perror("fork");
return -1;
}
return 0;
}
```
看起来相当的简单:我们用 fork 命令创建了一个新的子进程。if 语句的分支执行子进程这里称之为“target”else if 的分支执行父进程这里称之为“debugger”
下面是 target 进程的代码:
```
void run_target(const char* programname)
{
procmsg("target started. will run '%s'\n", programname);
/* Allow tracing of this process */
if (ptrace(PTRACE_TRACEME, 0, 0, 0) < 0) {
perror("ptrace");
return;
}
/* Replace this process's image with the given program */
execl(programname, programname, 0);
}
```
这段代码中最值得注意的是 ptrace 调用。在 "sys/ptrace.h" 中ptrace 是如下定义的:
```
long ptrace(enum __ptrace_request request, pid_t pid,
void *addr, void *data);
```
第一个参数是 _request_,这是许多预定义的 PTRACE_* 常量中的一个。第二个参数为请求分配进程 ID。第三个与第四个参数是地址与数据指针用于操作内存。上面代码段中的ptrace调用发起了 PTRACE_TRACEME 请求,这意味着该子进程请求系统内核让其父进程跟踪自己。帮助页面上对于 request 的描述很清楚:
> 意味着该进程被其父进程跟踪。任何传递给该进程的信号(除了 SIGKILL都将通过 wait() 方法阻塞该进程并通知其父进程。**此外,该进程的之后所有调用 exec() 动作都将导致 SIGTRAP 信号发送到此进程上,使得父进程在新的程序执行前得到取得控制权的机会**。如果一个进程并不需要它的的父进程跟踪它那么这个进程不应该发送这个请求。pid,addr 与 data 暂且不提)
我高亮了这个例子中我们需要注意的部分。在 ptrace 调用后run_target 接下来要做的就是通过 execl 传参并调用。如同高亮部分所说明,这将导致系统内核在 execl 创建进程前暂时停止,并向父进程发送信号。
是时候看看父进程做什么了。
```
void run_debugger(pid_t child_pid)
{
int wait_status;
unsigned icounter = 0;
procmsg("debugger started\n");
/* Wait for child to stop on its first instruction */
wait(&wait_status);
while (WIFSTOPPED(wait_status)) {
icounter++;
/* Make the child execute another instruction */
if (ptrace(PTRACE_SINGLESTEP, child_pid, 0, 0) < 0) {
perror("ptrace");
return;
}
/* Wait for child to stop on its next instruction */
wait(&wait_status);
}
procmsg("the child executed %u instructions\n", icounter);
}
```
如前文所述,一旦子进程调用了 exec子进程会停止并被发送 SIGTRAP 信号。父进程会等待该过程的发生并在第一个 wait() 处等待。一旦上述事件发生了wait() 便会返回由于子进程停止了父进程便会收到信号如果子进程由于信号的发送停止了WIFSTOPPED 就会返回 true
父进程接下来的动作就是整篇文章最需要关注的部分了。父进程会将 PTRACE_SINGLESTEP 与子进程ID作为参数调用 ptrace 方法。这就会告诉操作系统,“请恢复子进程,但在它执行下一条指令前阻塞”。周而复始地,父进程等待子进程阻塞,循环继续。当 wait() 中传出的信号不再是子进程的停止信号时,循环终止。在跟踪器(父进程)运行期间,这将会是被跟踪进程(子进程)传递给跟踪器的终止信号(如果子进程终止 WIFEXITED 将返回 true
icounter 存储了子进程执行指令的次数。这么看来我们小小的例子也完成了些有用的事情 - 在命令行中指定程序,它将执行该程序并记录它从开始到结束所需要的 cpu 指令数量。接下来就让我们这么做吧。
### 测试
我编译了下面这个简单的程序并利用跟踪器运行它:
```
#include <stdio.h>
int main()
{
printf("Hello, world!\n");
return 0;
}
```
令我惊讶的是,跟踪器花了相当长的时间,并报告整个执行过程共有超过 100,000 条指令执行。仅仅是一条输出语句?什么造成了这种情况?答案很有趣[[5]][18]。Linux 的 gcc 默认会动态的将程序与 c 的运行时库动态地链接。这就意味着任何程序运行前的第一件事是需要动态库加载器去查找程序运行所需要的共享库。这些代码的数量很大 - 别忘了我们的跟踪器要跟踪每一条指令,不仅仅是主函数的,而是“整个过程中的指令”。
所以当我将测试程序使用静态编译时(通过比较,可执行文件会多出 500 KB 左右的大小,这部分是 C 运行时库的静态链接),跟踪器提示只有大概 7000 条指令被执行。这个数目仍然不小,但是考虑到在主函数执行前 libc 的初始化以及主函数执行后的清除代码这个数目已经是相当不错了。此外printf 也是一个复杂的函数。
仍然不满意的话,我需要的是“可以测试”的东西 - 例如可以完整记录每一个指令运行的程序执行过程。这当然可以通过汇编代码完成。所以我找到了这个版本的“Hello, world!”并编译了它。
```
section .text
; The _start symbol must be declared for the linker (ld)
global _start
_start:
; Prepare arguments for the sys_write system call:
; - eax: system call number (sys_write)
; - ebx: file descriptor (stdout)
; - ecx: pointer to string
; - edx: string length
mov edx, len
mov ecx, msg
mov ebx, 1
mov eax, 4
; Execute the sys_write system call
int 0x80
; Execute sys_exit
mov eax, 1
int 0x80
section .data
msg db 'Hello, world!', 0xa
len equ $ - msg
```
当然,现在跟踪器提示 7 条指令被执行了,这样一来很容易区分他们。
### 深入指令流
上面那个汇编语言编写的程序使得我可以向你介绍 ptrace 的另外一个强大的用途 - 详细显示被跟踪进程的状态。下面是 run_debugger 函数的另一个版本:
```
void run_debugger(pid_t child_pid)
{
int wait_status;
unsigned icounter = 0;
procmsg("debugger started\n");
/* Wait for child to stop on its first instruction */
wait(&wait_status);
while (WIFSTOPPED(wait_status)) {
icounter++;
struct user_regs_struct regs;
ptrace(PTRACE_GETREGS, child_pid, 0, &regs);
unsigned instr = ptrace(PTRACE_PEEKTEXT, child_pid, regs.eip, 0);
procmsg("icounter = %u. EIP = 0x%08x. instr = 0x%08x\n",
icounter, regs.eip, instr);
/* Make the child execute another instruction */
if (ptrace(PTRACE_SINGLESTEP, child_pid, 0, 0) < 0) {
perror("ptrace");
return;
}
/* Wait for child to stop on its next instruction */
wait(&wait_status);
}
procmsg("the child executed %u instructions\n", icounter);
}
```
不同仅仅存在于 while 循环的开始几行。这个版本里增加了两个新的 ptrace 调用。第一条将进程的寄存器值读取进了一个结构体中。 sys/user.h 定义有 user_regs_struct。如果你查看头文件头部的注释这么写到
```
/* The whole purpose of this file is for GDB and GDB only.
Don't read too much into it. Don't use it for
anything other than GDB unless know what you are
doing. */
```
```
/* 这个文件只为了GDB而创建
不用详细的阅读.如果你不知道你在干嘛,
不要在除了 GDB 以外的任何地方使用此文件 */
```
不知道你做何感想,但这让我觉得我们找对地方了。回到例子中,一旦我们在 regs 变量中取得了寄存器的值,我们就可以通过将 PTRACE_PEEKTEXT 作为参数、 regs.eipx86 上的扩展指令指针)作为地址,调用 ptrace ,读取当前进程的当前指令。下面是新跟踪器所展示出的调试效果:
```
$ simple_tracer traced_helloworld
[5700] debugger started
[5701] target started. will run 'traced_helloworld'
[5700] icounter = 1\. EIP = 0x08048080\. instr = 0x00000eba
[5700] icounter = 2\. EIP = 0x08048085\. instr = 0x0490a0b9
[5700] icounter = 3\. EIP = 0x0804808a. instr = 0x000001bb
[5700] icounter = 4\. EIP = 0x0804808f. instr = 0x000004b8
[5700] icounter = 5\. EIP = 0x08048094\. instr = 0x01b880cd
Hello, world!
[5700] icounter = 6\. EIP = 0x08048096\. instr = 0x000001b8
[5700] icounter = 7\. EIP = 0x0804809b. instr = 0x000080cd
[5700] the child executed 7 instructions
```
现在,除了 icounter我们也可以观察到指令指针与它每一步所指向的指令。怎么来判断这个结果对不对呢使用 objdump -d 处理可执行文件:
```
$ objdump -d traced_helloworld
traced_helloworld: file format elf32-i386
Disassembly of section .text:
08048080 <.text>:
8048080: ba 0e 00 00 00 mov $0xe,%edx
8048085: b9 a0 90 04 08 mov $0x80490a0,%ecx
804808a: bb 01 00 00 00 mov $0x1,%ebx
804808f: b8 04 00 00 00 mov $0x4,%eax
8048094: cd 80 int $0x80
8048096: b8 01 00 00 00 mov $0x1,%eax
804809b: cd 80 int $0x80
```
这个结果和我们跟踪器的结果就很容易比较了。
### 将跟踪器关联到正在运行的进程
如你所知调试器也能关联到已经运行的进程。现在你应该不会惊讶ptrace 通过 以PTRACE_ATTACH 为参数调用也可以完成这个过程。这里我不会展示示例代码通过上文的示例代码应该很容易实现这个过程。出于学习目的这里使用的方法更简便因为我们在子进程刚开始就可以让它停止
### 代码
上文中的简单的跟踪器更高级的可以打印指令的版本的完整c源代码可以在[这里][20]找到。它是通过 4.4 版本的 gcc 以 -Wall -pedantic --std=c99 编译的。
### 结论与计划
诚然,这篇文章并没有涉及很多内容 - 我们距离亲手完成一个实际的调试器还有很长的路要走。但我希望这篇文章至少可以使得调试这件事少一些神秘感。ptrace 是功能多样的系统调用,我们目前只展示了其中的一小部分。
单步调试代码很有用但也只是在一定程度上有用。上面我通过c的“Hello World!”做了示例。为了执行主函数可能需要上万行代码来初始化c的运行环境。这并不是很方便。最理想的是在main函数入口处放置断点并从断点处开始分步执行。为此在这个系列的下一篇我打算展示怎么实现断点。
### 参考
撰写此文时参考了如下文章
* [Playing with ptrace, Part I][11]
* [How debugger works][12]
[1] 我没有检查,但我确信 gdb 的代码行数至少有六位数。
[2] 使用 man 2 ptrace 命令可以了解更多。
[3] Peek and poke 在系统编程中是很知名的叫法,指的是直接读写内存内容。
[4] 这篇文章假定读者有一定的 Unix/Linux 编程经验。我假定你知道至少了解概念forkexec 族函数与 Unix 信号。
[5] 至少你同我一样痴迷与机器/汇编语言。
[6] 警告:如同我上面所说,文章很大程度上是平台相关的。我简化了一些设定 - 例如x86指令集不需要调整到 4 字节我的32位 Ubuntu unsigned int 是 4 字节)。事实上,许多平台都不需要。从内存中读取指令需要预先安装完整的反汇编器。我们这里没有,但实际的调试器是有的。
--------------------------------------------------------------------------------
via: http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1
作者:[Eli Bendersky ][a]
译者:[译者ID](https://github.com/YYforymj)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:http://eli.thegreenplace.net/
[1]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id1
[2]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id2
[3]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id3
[4]:http://www.jargon.net/jargonfile/p/peek.html
[5]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id4
[6]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id5
[7]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id6
[8]:http://eli.thegreenplace.net/tag/articles
[9]:http://eli.thegreenplace.net/tag/debuggers
[10]:http://eli.thegreenplace.net/tag/programming
[11]:http://www.linuxjournal.com/article/6100?page=0,1
[12]:http://www.alexonlinux.com/how-debugger-works
[13]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id7
[14]:http://en.wikipedia.org/wiki/Small_matter_of_programming
[15]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id8
[16]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id9
[17]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id10
[18]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id11
[19]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1#id12
[20]:https://github.com/eliben/code-for-blog/blob/master/2011/simple_tracer.c
[21]:http://eli.thegreenplace.net/2011/01/23/how-debuggers-work-part-1

View File

@ -1,81 +0,0 @@
如何让黑客远离你的 Linux 第三部分:问题回答
============================================================
![Computer security](https://www.linux.com/sites/lcom/files/styles/rendered_file/public/keep-hackers-out.jpg?itok=lqgHDxDu "computer security")
Mike Guthrie 最近在 Linux 基金会的网络研讨会上回答了一些安全相关的问题。随时观看免费的研讨会。[Creative Commons Zero][1]
这个系列的[第一篇][6]和[第二篇][7]文章覆盖了 5 个最简单的方法来让你的 Linux 远离黑客,并且知道他们是否已经进入。这一次,我将回答一些我最近在 Linux 基金会网络研讨会上收到的很好的安全性问题。[随时观看免费网络研讨会][8]。
**如果系统自动使用私钥认证,如何存储密钥密码?**
这个很难。这是我们一直在斗争的事情,特别是我们在做 “Red Teams” 的时候,因为我们有自动回调它的东西。我使用 Expect但我倾向于在这上面使用老方法。你将要编写脚本是的将密码存储在系统上将是艰难的当你这么做时你需要加密它。
我的 Expect 脚本加密了存储的密码,然后解密,发送密码,并在完成后重新加密。我意识到这有一些缺陷,但它比使用无密码的密钥更好。
如果你有一个无密码的密钥,并且你确实需要使用它。我建议你最大化地限制需要它的用户。例如,如果你正在进行一些自动日志传输或自动化软件安装,则只给那些需要执行这些功能的程序权限。
你可以通过 SSH 运行命令,所以不要给它们一个 shell使它只能运行那个命令这样就能防止某人窃取了这个密钥并做其他事情。
**你对密码管理器如 KeePass2 怎么看?**
对我而言密码管理器是一个非常好的目标。随着 GPU 破解的出现和 EC2 的一些破解能力,这些很容易就变成过去。我一直在窃取密码库。
现在,我们在破解这些库的成功率是一个不同的故事。我们仍然有 10% 左右的破解成功率。如果人们不能为他们的密码库保留一个安全密码,那么我们就会进入并会获得大量的成功。它没有什么好,但是你仍需要保护好这些资产。如你保护其他密码一样保护好密码库。
**你认为从安全的角度来看,除了创建具有更高密钥长度的主机密钥之外,创建一个新的 “Diffie-Hellman” moduli 并限制 2048 位或更高值得么?**
值得的。以前在 SSH 产品中存在弱点,你可以做到解密数据包流。有了它,你可以拉取各种数据。作为一种加密机制,人们不假思索使用这种方式来传输文件和密码。使用健壮的加密并且改变你的密钥是很重要的。 我会轮换我的 SSH 密钥 - 这不像我的密码那么频繁,但是我每年会轮换一次。是的,这是一个麻烦,但它让我安心。我建议尽可能地使你的加密技术健壮。
**使用完全随机的英语单词(大概 10 万个)作为密码合适么?**
当然。我的密码实际上是一个完整的短语。它是带标点符号和大小写一句话。我不再使用其他任何东西。
我是有一个你可以记住的密码而不用写下来或者放在密码库的大大的支持者。一个你可以记住不必写下来的密码比你需要写下来的密码更安全。
使用短语或使用你可以记住的四个随机单词比那些需要经过几次转换的一串数字和字符的字符串更安全。我目前的密码长度大约是 200 个字符。这是我可以快速打出来并且记住的。
**在物联网情景下对保护基于 Linux 的嵌入式系统有什么建议么?**
物联网是一个新的空间,它是系统和安全的前沿。它每一天都是不同的。现在,我尽量都保持离线。我不喜欢人们把我的灯光和冰箱搞乱。我故意没有购买已经联网的冰箱,因为我有朋友是黑客,我知道我每天早上醒来都会看到不适当的图片。封住它,锁住它,隔离它。
目前物联网设备的恶意软件取决于默认密码和后门,所以只需要对你所使用的设备进行一些研究,并确保没有其他人可以默认访问。然后确保这些设备的管理接口受到防火墙或其他此类设备的良好保护。
**你可以提一个可以在 SMB 和大型环境中使用的防火墙/UTMOS 或应用程序)么?**
我使用 pfSense它是 BSD 的衍生产品。我很喜欢它。它有很多模块,实际上现在它有商业支持,这对于小企业来说这是非常棒的。对于更大的设备、更大的环境,这取决于你有哪些管理员。
我一直都是 CheckPoint 管理员,但是 Palo Alto 也越来越受欢迎了。这些类型的安装与小型企业或家庭使用很不同。我在任何小型网络中都使用 pfSense。
**云服务有什么内在问题么?**
并没有云,只有其他人的电脑。云服务存在内在的问题。只知道谁访问了你的数据,你在上面放了什么。要知道当你向 Amazon 或 Google 或 Microsoft 上传某些东西时,你将不再完全控制它,并且该数据的隐私是有问题的。
**要获得 OSCP 你建议需要准备些什么?**
我现在准备通过这个认证。我的整个团队是这样。阅读他们的材料。要记住 OSCP 将成为令人反感的安全基准。你一切都要使用 Kali。如果不这样做 - 如果你决定不使用 Kali请确保已安装所有工具来模拟 Kali 实例。
这将是一个基于工具的重要认证。这是一个很好的方法论。看看一些名为“渗透测试框架”的内容,因为这将为你提供一个很好的测试流程,他们的实验室似乎是很棒的。这与我家里的实验室非常相似。
_[随时免费观看完整的网络研讨会][3]。查看这个系列的[第一篇][4]和[第二篇][5]文章获得 5 个简单的贴士来让你的 Linux 机器安全。_
_Mike Guthrie 为能源部工作,负责 “Red Team” 的工作和渗透测试。_
--------------------------------------------------------------------------------
via: https://www.linux.com/news/webinar/2017/how-keep-hackers-out-your-linux-machine-part-3-your-questions-answered
作者:[MIKE GUTHRIE][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.linux.com/users/anch
[1]:https://www.linux.com/licenses/category/creative-commons-zero
[2]:https://www.linux.com/files/images/keep-hackers-outjpg
[3]:http://portal.on24.com/view/channel/index.html?showId=1101876&showCode=linux&partnerref=linco
[4]:https://www.linux.com/news/webinar/2017/how-keep-hackers-out-your-linux-machine-part-1-top-two-security-tips
[5]:https://www.linux.com/news/webinar/2017/how-keep-hackers-out-your-linux-machine-part-2-three-more-easy-security-tips
[6]:https://www.linux.com/news/webinar/2017/how-keep-hackers-out-your-linux-machine-part-1-top-two-security-tips
[7]:https://www.linux.com/news/webinar/2017/how-keep-hackers-out-your-linux-machine-part-2-three-more-easy-security-tips
[8]:http://portal.on24.com/view/channel/index.html?showId=1101876&showCode=linux&partnerref=linco

View File

@ -1,17 +1,13 @@
在 Linux 上使用 Meld 比较文件夹
============================================================
### 本文导航
1. [用 Meld 比较文件夹][1]
2. [总结][2]
我们已经从一个新手的角度了解了 Meld (包括 Meld 的安装),我们也提及了一些 Meld 中级用户常用的小技巧。如果你有印象,在新手教程中,我们说过 Meld 可以比较文件和文件夹。已经讨论过怎么讨论文件,今天,我们来看看 Meld 怎么比较文件夹。
本教程中的所有命令和例子都是在 Ubuntu 14.04 上测试的,使用的 Meld 版本基于 3.14.2 版。
我们已经从一个新手的角度了解了 Meld (包括 Meld 的安装),我们也提及了一些 Meld 中级用户常用的小技巧。如果你有印象,在新手教程中,我们说过 Meld 可以比较文件和文件夹。已经讨论过怎么比较文件,今天,我们来看看 Meld 怎么比较文件夹。
*需要指出的是,本教程中的所有命令和例子都是在 Ubuntu 14.04 上测试的,使用的 Meld 版本为 3.14.2。 *
### 用 Meld 比较文件夹
打开 Meld 工具然后选择_比较文件夹_选项来比较两个文件夹。
打开 Meld 工具,然后选择 <ruby>比较文件夹<rt>Directory comparison</rt></ruby> 选项来比较两个文件夹。
[
![Compare directories using Meld](https://www.howtoforge.com/images/beginners-guide-to-visual-merge-tool-meld-on-linux-part-3/meld-dir-comp-1.png)
][5]
@ -21,13 +17,13 @@
![select the directories](https://www.howtoforge.com/images/beginners-guide-to-visual-merge-tool-meld-on-linux-part-3/meld-sel-dir-2.png)
][6]
然后单击_比较_按钮你会看到 Meld 像图中这样分成两栏显示
然后单击<ruby>比较<rt>Compare </rt></ruby>按钮,你会看到 Meld 像图中这样分成两栏比较目录,就像文件比较一样
[
![Compare directories visually](https://www.howtoforge.com/images/beginners-guide-to-visual-merge-tool-meld-on-linux-part-3/meld-dircomp-begins-3.png)
][7]
分栏会树形显示这些文件/文件夹。你可以在上图中看到明显的区别——不论文件是新建的还是被修改过的——都会以不同的颜色高亮显示。
分栏会树形显示这些文件夹。你可以在上图中看到 —— 区别之处,不论是新建的还是被修改过的文件 —— 都会以不同的颜色高亮显示。
根据 Meld 的官方文档可以知道在窗口中看到的每个不同的文件或文件夹都会被突出显示。这样就很容易看出这个文件/文件夹与另一个分栏中对应位置的文件/文件夹的区别。
根据 Meld 的官方文档可以知道在窗口中看到的每个不同的文件或文件夹都会被突出显示。这样就很容易看出这个文件/文件夹与另一个分栏中对应位置的文件/文件夹的区别。
下表是 Meld 网站上列出的在比较文件夹时突出显示的不同字体大小/颜色/背景等代表的含义。
@ -40,7 +36,8 @@
| New | Green and bold | This file/folder exists in this folder, but not in the others. |
| Missing | Greyed out text with a line through the middle | This file/folder doesn't exist in this folder, but does in one of the others. |
| Error | Bright red with a yellow background and bold | When comparing this file, an error occurred. The most common error causes are file permissions (i.e., Meld was not allowed to open the file) and filename encoding errors. |
Meld 默认会列出文件夹中的所有内容即使这些内容没有任何不同。当然你也可以在工具栏中单击_同样的_按钮设置 Meld 不显示这些相同的文件/文件夹——单击这个按钮使其不可用。
Meld 默认会列出比较文件夹中的所有内容,即使这些内容没有任何不同。当然,你也可以在工具栏中单击<ruby>相同<rt>Same</rt></ruby>按钮设置 Meld 不显示这些相同的文件/文件夹 —— 单击这个按钮使其不可用。
[
![same button](https://www.howtoforge.com/images/beginners-guide-to-visual-merge-tool-meld-on-linux-part-3/meld-same-button.png)
][3]
@ -110,7 +107,7 @@ via: https://www.howtoforge.com/tutorial/how-to-perform-directory-comparison-usi
作者:[Ansh][a]
译者:[vim-kakali](https://github.com/vim-kakali)
校对:[校对者ID](https://github.com/校对者ID)
校对:[jasminepeng](https://github.com/jasminepeng)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,30 +1,30 @@
OpenVAS - Vulnerability Assessment install on Kali Linux
OpenVAS - Kali Linux 中的漏洞评估工具
============================================================
### On this page
### 在本页中
1. [What is Kali Linux?][1]
2. [Updating Kali Linux][2]
3. [Installing OpenVAS 8][3]
4. [Start OpenVAS on Kali][4]
1. [什么是 Kali Linux?][1]
2. [升级 Kali Linux][2]
3. [安装 OpenVAS 8][3]
4. [在 Kail 中启动 OpenVAS][4]
This tutorial documents the process of installing OpenVAS 8.0 on Kali Linux rolling. OpenVAS is open source [vulnerability assessment][6] application that automates the process of performing network security audits and vulnerability assessments. Note, a vulnerability assessment also known as VA is not a penetration test, a penetration test goes a step further and validates the existence of a discovered vulnerability, see [what is penetration testing][7] for an overview of what pen testing consists of and the different types of security testing.
本教程将介绍在 Kali Linux 中安装 OpenVAS 8.0 的过程。 OpenVAS 是自动执行网络安全审核和漏洞评估的开源[漏洞评估][6]程序。请注意,漏洞评估也称为 VA 并不是渗透测试,渗透测试会进一步验证是否存在发现的漏洞,请参阅[什么是渗透测试][7]来对渗透测试的构成以及不同类型的安全测试有一个了解。
### What is Kali Linux?
### 什么是 Kali Linux?
Kali Linux is a Linux penetration testing distribution. It's Debian based and comes pre-installed with many commonly used penetration testing tools such as Metasploit Framework and other command line tools typically used by penetration testers during a security assessment.
Kali Linux 是 Linux 渗透测试分发版。它基于 Debian并且预安装了许多常用的渗透测试工具例如 Metasploit Framework 和其他通常在安全评估期间由渗透测试人员使用的命令行工具。
For most use cases Kali runs in a VM, you can grab the latest VMWare or Vbox image of Kali from here: [https://www.offensive-security.com/kali-linux-vmware-virtualbox-image-download/][8]
在大多数使用情况下Kali 运行在虚拟机中,你可以在这里获取最新的 VMWare 或 Vbox 镜像:[https://www.offensive-security.com/kali-linux-vmware-virtualbox-image-download/][8]
Download the full version not Kali light, unless you have a specific reason for wanting a smaller virtual machine footprint. After the download finishes you will need to extract the contents and open the vbox or VMWare .vmx file, when the machine boots the default credentials are root / toor. Change the root password to a secure password.
除非你有特殊的原因想要一个更小的虚拟机占用空间,否则请下载完整版本而不是 Kali light。 下载完成后,你需要解压文件并打开 vbox 或者 VMWare .vmx 文件,虚拟机启动后,默认帐号是 root/toor。请将 root 密码更改为安全密码。
Alternatively, you can download the ISO version and perform an installation of Kali on the bare metal.
或者,你可以下载 ISO 版本,并在裸机上执行 Kali 的安装。
### Updating Kali Linux
### 升级 Kali Linux
After installation, perform a full update of Kali Linux.
完成安装后,为 Kail Linux 执行一次完整的升级。
Updating Kali:
升级 Kali
apt-get update && apt-get dist-upgrade -y
@ -32,11 +32,11 @@ apt-get update && apt-get dist-upgrade -y
![Updating Kali Linux](https://www.howtoforge.com/images/openvas_vulnerability_assessment_install_on_kali_linux/kali-apt-get-update-dist-upgrade.png)
][9]
The update process might take some time to complete. Kali is now a rolling release meaning you can update to the current version from any version of Kali rolling. However, there are release numbers but these are point in time versions of Kali rolling for VMWare snapshots. You can update to the current stable release from any of the VMWare images.
更新过程可能需要一些时间才能完成。Kali 目前是滚动更新,这意味着你可以从任何版本的 Kali 滚动更新到当前版本。然而它仍有发布号,但这些是针对特定 Kali 时间点的 VMWare 快照版本。你可以从任何 VMWare 镜像更新到当前的稳定版本。
After updating perform a reboot.
更新完成后重新启动。
### Installing OpenVAS 8
### 安装 OpenVAS 8
[
![Installing OpenVAS 8](https://www.howtoforge.com/images/openvas_vulnerability_assessment_install_on_kali_linux/kali-install-openvas-vulnerability-assessment.png)
@ -46,25 +46,25 @@ apt-get install openvas
openvas-setup
During installation you'll be prompted about redis, select the default option to run as a UNIX socket.
在安装中,你会被询问关于 redis选择默认选项来作为 UNIX 套接字运行。
[
![Configure OpenVAS Scanner](https://www.howtoforge.com/images/openvas_vulnerability_assessment_install_on_kali_linux/openvas-vulnerability-scanner-enable-redis.png)
][11]
Even on a fast connection openvas-setup takes a long time to download and update all the required CVE, SCAP definitions.
即使是有快速的网络连接openvas-setup 仍需要很长时间来下载和更新所有所需的 CVE、SCAP 定义。
[
![Update all the required CVE, SCAP definitions](https://www.howtoforge.com/images/openvas_vulnerability_assessment_install_on_kali_linux/openvas-vulnerability-scanner-install-2.png)
][12]
Pay attention to the command output during openvas-setup, the password is generated during installation and printed to console near the end of the setup.
请注意 openvas-setup 的命令输出,密码会在安装中生成,并在安装的最后在控制台中打印出来。
[
![Command output during install](https://www.howtoforge.com/images/openvas_vulnerability_assessment_install_on_kali_linux/openvas-vulnerability-scanner-install-complete.png)
][13]
Verify openvas is running:
验证 openvas 正在运行:
netstat -tulpn
@ -72,46 +72,46 @@ netstat -tulpn
![Check OpenVAS Status](https://www.howtoforge.com/images/openvas_vulnerability_assessment_install_on_kali_linux/openvas-running-netstat.png)
][14]
### Start OpenVAS on Kali
### 在 Kali 中运行 OpenVAS
To start the OpenVAS service on Kali run:
要在 Kali 中启动 OpenVAS
openvas-start
After installation, you should be able to access the OpenVAS web application at **https://127.0.0.1:9392**
安装后,你应该可以通过 **https://127.0.0.1:9392** 访问 OpenVAS 的 web 程序了。
**[
![OpenVAS started](https://www.howtoforge.com/images/openvas_vulnerability_assessment_install_on_kali_linux/openvas-self-signed-certificate.png)
][5]**
Accept the self-signed certificate and login to the application using the credentials admin and the password displayed during openvas-setup.
接受自签名证书,并使用 openvas-setup 输出的 admin 凭证和密码登录程序。
[
![Accept the self-signed SSL cert](https://www.howtoforge.com/images/openvas_vulnerability_assessment_install_on_kali_linux/accept-openvas-self-signed-certificate.png)
][15]
After accepting the self-signed certificate, you should be presented with the login screen:
接受自签名证书后,你应该可以看到登录界面了。
[
![OpenVAS Login](https://www.howtoforge.com/images/openvas_vulnerability_assessment_install_on_kali_linux/openvas-login-screen.png)
][16]
After logging in you should be presented with the following screen:
登录后,你应该可以看到下面的页面:
[
![OpenVAS Dashboard](https://www.howtoforge.com/images/openvas_vulnerability_assessment_install_on_kali_linux/openvas-menu.png)
][17]
From this point you should be able to configure your own vulnerability scans using the wizard.
从此,你应该可以使用向导配置自己的漏洞扫描了。
It's recommended to read the documentation. Be aware of what a vulnerability assessment conductions (depending on configuration OpenVAS could attempt exploitation) and the traffic it will generate on a network as well as the DOS effect it can have on services / servers and hosts / devices on a network.
我建议阅读文档。请注意漏洞评估导向(取决于 OpenVAS 可能尝试利用的配置)及其在网络上生成的流量以及网络上可能对服务/服务器和主机/设备产生的 DOS 影响。
--------------------------------------------------------------------------------
via: https://www.howtoforge.com/tutorial/openvas-vulnerability-assessment-install-on-kali-linux/
作者:[KJS ][a]
译者:[译者ID](https://github.com/译者ID)
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出

View File

@ -1,82 +0,0 @@
使用 LXDE 的 8 个理由
8 reasons to use LXDE
============================================================
### 考虑使用轻量级桌面环境 LXDE 作为你 Linux 桌面的理由
![使用 LXDE 的 8 个理由](https://opensource.com/sites/default/files/styles/image-full-size/public/images/business/rh_003499_01_linux31x_cc.png?itok=1HXbvw2E "8 reasons to use LXDE")
>Image by : opensource.com
去年年底,升级到 Fedora 25 给新版本的 [KDE][7] Plasma 带来了严重问题,我难以完成任何工作。由于两个原因我决定尝试其它 Linux 桌面环境。第一,我需要完成我的工作。第二,单独使用 KDE 已经有很多年,我认为是时候尝试一些不同的桌面了。
我尝试了几周的第一个替代桌面是 [Cinnamon][8],我在 1 月份介绍过它。这次我已经使用了 LXDE轻量级 X11 桌面环境)大概 6 周,我发现它有很多我喜欢的东西。这是我使用 LXDE 的 8 个理由。
更多 Linux 相关资源
* [Linux 是什么?][1]
* [Linux 容器是什么?][2]
* [在 Linux 中管理设备][3]
* [马上下载Linux 命令速查表][4]
* [我们最新的 Linux 文章][5]
**1\. LXDE 支持多个面板。**和 KDE 以及 Cinnamon 一样LXDE 支持包括系统菜单、应用启动器的面板,显示正在运行应用图标的任务栏。我第一次登录到 LXDE 时面板配置看起来异常熟悉。LDXE 看起来已经为我喜欢的顶部和底部面板适配了 KDE 配置,还包括系统托盘设置。顶部面板上的应用程序启动器看似来自 Cinnamon 配置。面板上的东西使得启动和管理程序变得容易。默认情况下,只在桌面底部有一个面板。
![打开了 Openbox Configuration Manager 的 LXDE 桌面。](https://opensource.com/sites/default/files/lxde-openboxconfigurationmanager.png "打开了 Openbox Configuration Manager 的 LXDE 桌面。")
打开了 Openbox Configuration Manager 的 LXDE 桌面。这个桌面还没有更改过,因此它使用了默认的颜色和图标主题。
**2\. Openbox configuration manager 提供了一个简单工具用于管理和体验桌面外观。**它为主题、窗口修饰、多个显示器的窗口行为、移动和调整窗口大小、鼠标控制、多桌面等提供了选项。虽然这看起来似乎很多,但它远不如配置 KDE 桌面那么复杂,尽管如此 Openbox 仍然提供了很多的控制选项。
**3\. LXDE 有一个强大的菜单工具。**在 Desktop Preference 菜单 Advanced 标签页有个有趣的选项。这个选项的名称是 “Show menus provided by window managers when desktop is clicked点击桌面时显示窗口管理器提供的菜单”。选中这个复选框当你右击桌面时会显示 Openbox 桌面菜单,而不是标准的 LXDE 桌面菜单。
Openbox 桌面菜单包括了几乎每个你可能想要的菜单选项,所有都可从桌面便捷访问。它包括了所有的应用程序菜单、系统管理、以及首选项。它甚至有一个菜单包括了所有已安装终端模拟器应用程序的列表,因此系统管理员可以轻易地启动他们喜欢的终端。
**4\. 设计上LXDE 桌面干净简单。**它没有任何会妨碍你完成工作的东西。尽管你可以添加一些文件、目录、应用程序的链接到桌面,但是没有可以添加到桌面的小部件。在我的 KDE 和 Cinnamon 桌面上我确实喜欢一些小部件,但它们很容易被打开,然后我就需要移动或者最小化窗口,或者使用 “Show Desktop” 按钮清空整个桌面。 LXDE 确实有一个 “Iconify all windows” 按钮,但我很少需要使用它,除非我想看我的壁纸。
**5\. LXDE 有一个强大的文件管理器。**LXDE 默认的文件管理器是 PCManFM因此在我使用 LXDE 的时候它成为了我的文件管理器。PCManFM 非常灵活、可以配置为适用于大部分人和情况。它看起来没有我常用的文件管理器 Krusader 那么可配置,但我确实喜欢 Krusader 没有的 PCManFM 的侧边栏。
PCManFM 允许多个标签页可以通过右击侧边栏的任何条目或者单击图标栏的新标签图标打开。PCManFM 窗口左边的 Places 面板显示了应用程序菜单,你可以从 PCManFM 启动应用程序。Places 面板上面也显示了一个设备图标可以用于查看你的物理存储设备一系列带图标的可移除设备允许你挂载和卸载它们还有可以便捷访问的主目录、桌面、回收站。Places 面板的底部包括一些默认目录的快捷方式,例如 Documents、Music、Pictures、Videos 以及 Downloads。你也可以拖拽其它目录到 Places 面板的快捷方式部分。Places 面板可以换为正常的目录树。
**6\. 如果在现有窗口后面打开,****新窗口的标题栏会闪烁****。**这是一个在大量现有窗口中定位新窗口的好方法。
**7\. 大部分现代桌面环境允许多个桌面LXDE 也不例外。**我喜欢使用一个桌面用于我的开发、测试以及编辑工作另一个桌面用于普通任务例如电子邮件和网页浏览。LXDE 默认提供两个桌面,但你可以配置为只有一个或者多个。右击 Desktop Pager 配置它。
通过一些有害但不是破坏性的测试,我发现最大允许桌面数目是 100。我还发现当我把桌面数目减少到低于我实际使用的 3 个时,不活动桌面上的窗口会被移动到桌面 1。多么有趣的发现
**8\. Xfce 电源管理器是一个小巧但强大的应用程序,它允许你配置电源管理如何工作。**它提供了一个标签页用于通用配置,以及用于系统、显示和设备的标签页。设备标签页显示了我系统上已有设备的表格,例如电池供电的鼠标、键盘,甚至我的 UPSuninterruptible power supply不间断电源。它显示了每个设备的详细信息包括厂商和系列号如果可用的话还有电池充电状态。当我写这篇博客的时候我 UPS 的电量是 100%,而我罗技鼠标的电量是 75%。 Xfce 电源管理器还在系统托盘显示了一个图标,因此你可以从那里快速了解你设备的电池状态。
关于 LXDE 桌面还有很多喜欢的东西,但这些就是抓住了我的注意力、或者对我使用现代图形用户界面工作非常重要、不可或缺的东西。
我注意到奇怪的一点是我一直没有弄明白桌面Openbox菜单的 “Reconfigure” 选项是干什么的。我点击了几次,从没有注意到有任何类型的任何活动表明该选项实际起了作用。
我发现 LXDE 是一个简单但强大的桌面。我享受使用它写这篇文章的几周时间。通过允许我访问我想要的应用程序和文件同时在其余时间保持不明显LXDE 使我得以高效地工作。我也没有遇到任何妨碍我完成工作的问题。当然,除了我用于探索这个好桌面所花的时间。我非常推荐 LXDE 桌面。
我现在正在使用 GNOME 3 和 GNOME Shell并将在下一期中报告。
--------------------------------------------------------------------------------
作者简介:
David Both - David Both 是一个 Linux 和开源倡导者,他居住在 Raleigh, North Carolina。他在 IT 行业已经超过 40 年,在他工作的 IBM 教授 OS/2 超过 20 年,他在 1981 年为最早的 IBM PC 写了第一个培训课程。他教过 Red Hat 的 RHCE 课程,在 MCI Worldcom、 Cisco 和北卡罗莱纳州 工作过。他一直在使用 Linux 和开源软件近 20 年。
--------------------------------------
via: https://opensource.com/article/17/3/8-reasons-use-lxde
作者:[David Both ][a]
译者:[ictlyh](https://github.com/ictlyh)
校对:[校对者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/resources/what-is-linux?src=linux_resource_menu
[2]:https://opensource.com/resources/what-are-linux-containers?src=linux_resource_menu
[3]:https://opensource.com/article/16/11/managing-devices-linux?src=linux_resource_menu
[4]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=7016000000127cYAAQ
[5]:https://opensource.com/tags/linux?src=linux_resource_menu
[6]:https://opensource.com/article/17/3/8-reasons-use-lxde?rate=QigvkBy_9zLvktdsL-QaIWedjIqjtlwwJIVFQDQzsSY
[7]:https://opensource.com/life/15/4/9-reasons-to-use-kde
[8]:https://opensource.com/article/17/1/cinnamon-desktop-environment
[9]:https://opensource.com/user/14106/feed
[10]:https://opensource.com/article/17/3/8-reasons-use-lxde#comments
[11]:https://opensource.com/users/dboth

View File

@ -40,12 +40,13 @@
3. 寄存器和内存
4. Elves 和 dwarves
5. 逐步、源码和信号
6. Stepping on dwarves
6. 使用 DWARF 调试信息逐步执行
7. 源码层断点
8. 调用栈
9. 读取变量
10. 下一步
译者注ELF[Executable and Linkable Format](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format "Executable and Linkable Format") 可执行文件格式DWARF一种广泛使用的调试数据格式参考 [WIKI](https://en.wikipedia.org/wiki/DWARF "DWARF WIKI")
* * *
### 准备环境

View File

@ -14,12 +14,13 @@
3. 寄存器和内存
4. Elves 和 dwarves
5. 逐步、源码和信号
6. Stepping on dwarves
6. 使用 DWARF 调试信息逐步执行
7. 源码层断点
8. 调用栈
9. 读取变量
10. 下一步
译者注ELF[Executable and Linkable Format](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format "Executable and Linkable Format") 可执行文件格式DWARF一种广泛使用的调试数据格式参考 [WIKI](https://en.wikipedia.org/wiki/DWARF "DWARF WIKI")
* * *
### 断点如何形成?

View File

@ -0,0 +1,343 @@
关于 Linux 进程你所需要知道的一切【完全指南】
============================================================
在这篇指南中,我们会逐步对进程做基本的了解,然后简要看看如何用特定命令[管理 Linux 进程][9]。
进程是指正在执行的程序;是程序正在运行的一个实例。它由程序指令,从文件、其它程序中读取的数据或系统用户的输入组成。
#### 进程的类型
在 Linux 中主要有两种类型的进程:
* 前台进程(也称为交互式进程) - 这些进程由终端会话初始化和控制。换句话说,需要有一个连接到系统中的用户来启动这样的进程;它们不是作为系统功能/服务的一部分自动启动。
* 后台进程(也称为非交互式/自动进程) - 这些进程没有连接到终端;它们不需要任何用户输入。
#### 什么是守护进程
这是后台进程的特殊类型,它们在系统启动时启动,并作为服务一直运行;它们不会死亡。它们自发地作为系统任务启动(作为服务运行)。但是,它们能被用户通过 init 进程控制。
[
![Linux 进程状态](http://www.tecmint.com/wp-content/uploads/2017/03/ProcessState.png)
][10]
Linux 进程状态
### 在 Linux 中创建进程
当现有的进程在内存中完全拷贝一份自身的时候就会创建出一个新的进程。子进程会有和父进程一样的环境,只有进程 ID 不同。
在 Linux 中有两种常规方式创建进程:
* 使用 System() 函数 - 这个方法相对简单,但是比较低效而且具有明显的安全隐患。
* 使用 fork() 和 exec() 函数 - 这个技巧比较高级但提供更好的灵活性、速度以及安全性。
### Linux 如何识别进程?
由于 Linux 是一个多用户系统,意味着不同的用户可以在系统上运行各种各样的程序,内核必须唯一标识程序运行的每个实例。
程序由它的进程 IDPID和它父进程的进程 IDPPID识别因此进程可以被分类为
* 父进程- 这些是在运行时创建其它进程的进程。
* 子进程- 这些是在运行时由其它进程创建的进程。
#### init 进程
init 进程是系统中所有进程的父进程,它是[启动 Linux 系统][11]后第一个运行的程序;它管理着系统上的所有其它进程。它由内核自身启动,因此理论上说它没有父进程。
init 进程的进程 ID 总是为 1。它是所有孤儿进程的收养父母。它会收养所有孤儿进程
你可以用 pidof 命令查找某个进程的进程 ID
# pidof systemd
# pidof top
# pidof httpd
[
![查找 Linux 进程 ID](http://www.tecmint.com/wp-content/uploads/2017/03/Find-Linux-Process-ID.png)
][12]
查找 Linux 进程 ID
要查找当前 shell 的进程 ID 以及它父进程的进程 ID可以运行
$ echo $$
$ echo $PPID
[
![查找 Linux 父进程 ID](http://www.tecmint.com/wp-content/uploads/2017/03/Find-Linux-Parent-Process-ID.png)
][13]
查找 Linux 父进程 ID
#### 在 Linux 中启动进程
每次你运行一个命令或程序(例如 cloudcmd - CloudCommander它就会在系统中启动一个进程。你可以按照下面的方式启动一个前台交互式进程它会被连接到终端用户可以发送输入给它
# cloudcmd
[
![启动 Linux 交互进程](http://www.tecmint.com/wp-content/uploads/2017/03/Start-Linux-Interactive-Process.png)
][14]
启动 Linux 交互进程
#### Linux 后台任务
要在后台(非交互式)启动一个进程,使用 `&` 符号,此时,该进程不会从用户中读取输入,直到它被移到前台。
# cloudcmd &
# jobs
[
![在后台启动 Linux 进程](http://www.tecmint.com/wp-content/uploads/2017/03/Start-Linux-Process-in-Background.png)
][15]
在后台启动 Linux 进程
你也可以使用 `[Ctrl + Z]` 暂停执行一个程序并把它发送到后台,它会给进程发送 SIGSTOP 信号,从而暂停它的执行;它就会变为空闲:
# tar -cf backup.tar /backups/* #press Ctrl+Z
# jobs
要在后台继续运行上面被暂停的命令,使用 bg 命令:
# bg
要把后台进程发送到前台,使用 fg 命令以及任务的 ID类似
# jobs
# fg %1
[
![Linux 后台进程任务](http://www.tecmint.com/wp-content/uploads/2017/03/Linux-Background-Process-Jobs.png)
][16]
Linux 后台进程任务
你也可能想要阅读:[如何在后台启动 Linux 命令以及在终端分离Detach进程][17]
#### Linux 中进程的状态
在执行过程中,取决于它的环境一个进程会从一个状态转变到另一个状态。在 Linux 中,一个进程有下面的可能状态:
* Running - 此时它正在运行(它是系统中的当前进程)或准备运行(它正在等待分配 CPUs 单元)。
* Waiting - 在这个状态进程正在等待某个事件的发生或者系统资源。另外内核也会区分两种不同类型的等待进程可中断等待进程interruptible waiting processes - 可以被信号中断以及不可中断等待进程uninterruptible waiting processes- 正在等待硬件条件,不能被任何事件/信号中断。
* Stopped - 在这个状态,进程已经被停止了,通常是由于收到了一个信号。例如,正在被调试的进程。
* Zombie - 该进程已经死亡它已经停止了但是进程表process table中仍然有它的条目。
#### 如何在 Linux 中查看活跃进程
有很多 Linux 工具可以用于查看/列出系统中正在运行的进程,两个传统众所周知的是 [ps][18] 和 [top][19] 命令:
#### 1\. ps 命令
它显示被选中的系统中活跃进程的信息,如下图所示:
# ps
# ps -e | head
[
![列出 Linux 活跃进程](http://www.tecmint.com/wp-content/uploads/2017/03/ps-command.png)
][20]
列出 Linux 活跃进程
#### 2\. top - 系统监控工具
[top 是一个强大的工具][21],它能给你提供 [运行系统的动态实时视图][22],如下面截图所示:
# top
[
![列出 Linux 正在运行的程序](http://www.tecmint.com/wp-content/uploads/2017/03/top-command.png)
][23]
列出 Linux 正在运行的程序
阅读这篇文章获取更多 top 使用事例:[Linux 中 12 个 top 命令事例][24]
#### 3\. glances - 系统监控工具
glances 是一个相对比较新的系统监控工具,它有一些比较高级的功能:
# glances
[
![Glances - Linux 进程监控](http://www.tecmint.com/wp-content/uploads/2017/03/glances.png)
][25]
Glances Linux 进程监控
要获取完整使用指南,请阅读:[Glances - Linux 的一个高级实时系统监控工具][26]
还有很多你可以用来列出活跃进程的其它有用的 Linux 系统监视工具,打开下面的链接了解更多关于它们的信息:
1. [监控 Linux 性能的 20 个命令行工具][1]
2. [13 个有用的 Linux 监控工具][2]
### 如何在 Linux 中控制进程
Linux 也有一些命令用于控制进程,例如 kill、pkill、pgrep 和 killall下面是一些如何使用它们的基本事例
$ pgrep -u tecmint top
$ kill 2308
$ pgrep -u tecmint top
$ pgrep -u tecmint glances
$ pkill glances
$ pgrep -u tecmint glances
[
![控制 Linux 进程](http://www.tecmint.com/wp-content/uploads/2017/03/Control-Linux-Processes.png)
][27]
控制 Linux 进程
想要深入了解如何使用这些命令,在 Linux 中杀死/终止活跃进程,可以点击下面的链接:
1. [终止 Linux 进程的 Kill、Pkill 和 Killall 命令指南][3]
2. [如何在 Linux 中查找并杀死进程][4]
注意当你系统僵死freeze时你可以使用它们杀死 [Linux 中的不响应程序][28]。
#### 给进程发送信号
Linux 中控制进程的基本方法是给它们发送信号。你可以发送很多信号给一个进程,运行下面的命令可以查看所有信号:
```
$ kill -l
```
[
![列出所有 Linux 信号](http://www.tecmint.com/wp-content/uploads/2017/03/list-all-signals.png)
][29]
列出所有 Linux 信号
要给一个进程发送信号,可以使用我们之前提到的 kill、pkill 或 pgrep 命令。但只有被编程为能识别这些信号时程序才能响应这些信号。
大部分信号都是系统内部使用,或者给程序员编写代码时使用。下面是一些对系统用户非常有用的信号:
* SIGHUP 1 - 当控制它的终端被被关闭时给进程发送该信号。
* SIGINT 2 - 当用户使用 `[Ctrl+C]` 中断进程时控制它的终端给进程发送这个信号。
* SIGQUIT 3 - 当用户发送退出信号 `[Ctrl+D]` 时给进程发送该信号。
* SIGKILL 9 - 这个信号会马上中断(杀死)进程,进程不会进行清理操作。
* SIGTERM 15 - 这是一个程序终止信号kill 默认发送这个信号)。
* SIGTSTP 20 - 它的控制终端发送这个信号给进程要求它停止(终端停止);通过用户按 `[Ctrl+Z]` 触发。
下面是当 Firefox 应用程序僵死时通过它的 PID 杀死它的 kill 命令事例:
$ pidof firefox
$ kill 9 2687
OR
$ kill -KILL 2687
OR
$ kill -SIGKILL 2687
使用它的名称杀死应用,可以像下面这样使用 pkill 或 killall
$ pkill firefox
$ killall firefox
#### 更改 Linux 进程优先级
在 Linux 系统中,所有活跃进程都有一个优先级以及 nice 值。有比点优先级进程有更高优先级的进程一般会获得更多的 CPU 时间。
但是,有 root 权限的系统用户可以使用 nice 好 renice 命令影响(更改)优先级。
在 top 命令的输出中, NI 显示了进程的 nice 值:
$ top
[
![列出 Linux 正在运行的进程](http://www.tecmint.com/wp-content/uploads/2017/03/top-command.png)
][30]
列出 Linux 正在运行的进程
使用 nice 命令为一个进程设置 nice 值。记住一个普通用户可以给他拥有的进程设置 0 到 20 的 nice 值。
只有 root 用户可以使用负的 nice 值。
要 renice 一个进程的优先级,像下面这样使用 renice 命令:
$ renice +8 2687
$ renice +8 2103
阅读我们其它如何管理和控制 Linux 进程的有用文章。
1. [Linux 进程管理:启动、停止以及中间过程][5]
2. [使用 top 命令 Batch 模式查找内存使用最高的 15 个进程][6]
3. [在 Linux 中查找内存和 CPU 使用率最高的进程][7]
4. [在 Linux 中如何使用进程 ID 查找进程名称][8]
就是这些!如果你有任何问题或者想法,通过下面的反馈框和我们分享吧。
--------------------------------------------------------------------------------
作者简介:
Aaron Kili 是一个 Linux 和 F.O.S.SFree and Open-Source Software 爱好者,一个 Linux 系统管理员、web 开发员,现在也是 TecMint 的内容创建者,他喜欢和电脑一起工作,他相信知识共享。
--------------------------------------------------------------------------------
via: http://www.tecmint.com/linux-process-management/
作者:[Aaron Kili][a]
译者:[ictlyh](https://github.com/ictlyh)
校对:[校对者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/linux-performance-monitoring-tools/
[3]:http://www.tecmint.com/how-to-kill-a-process-in-linux/
[4]:http://www.tecmint.com/find-and-kill-running-processes-pid-in-linux/
[5]:http://www.tecmint.com/rhcsa-exam-boot-process-and-process-management/
[6]:http://www.tecmint.com/find-processes-by-memory-usage-top-batch-mode/
[7]:http://www.tecmint.com/find-linux-processes-memory-ram-cpu-usage/
[8]:http://www.tecmint.com/find-process-name-pid-number-linux/
[9]:http://www.tecmint.com/dstat-monitor-linux-server-performance-process-memory-network/
[10]:http://www.tecmint.com/wp-content/uploads/2017/03/ProcessState.png
[11]:http://www.tecmint.com/linux-boot-process/
[12]:http://www.tecmint.com/wp-content/uploads/2017/03/Find-Linux-Process-ID.png
[13]:http://www.tecmint.com/wp-content/uploads/2017/03/Find-Linux-Parent-Process-ID.png
[14]:http://www.tecmint.com/wp-content/uploads/2017/03/Start-Linux-Interactive-Process.png
[15]:http://www.tecmint.com/wp-content/uploads/2017/03/Start-Linux-Process-in-Background.png
[16]:http://www.tecmint.com/wp-content/uploads/2017/03/Linux-Background-Process-Jobs.png
[17]:http://www.tecmint.com/run-linux-command-process-in-background-detach-process/
[18]:http://www.tecmint.com/linux-boot-process-and-manage-services/
[19]:http://www.tecmint.com/12-top-command-examples-in-linux/
[20]:http://www.tecmint.com/wp-content/uploads/2017/03/ps-command.png
[21]:http://www.tecmint.com/12-top-command-examples-in-linux/
[22]:http://www.tecmint.com/bcc-best-linux-performance-monitoring-tools/
[23]:http://www.tecmint.com/wp-content/uploads/2017/03/top-command.png
[24]:http://www.tecmint.com/12-top-command-examples-in-linux/
[25]:http://www.tecmint.com/wp-content/uploads/2017/03/glances.png
[26]:http://www.tecmint.com/glances-an-advanced-real-time-system-monitoring-tool-for-linux/
[27]:http://www.tecmint.com/wp-content/uploads/2017/03/Control-Linux-Processes.png
[28]:http://www.tecmint.com/kill-processes-unresponsive-programs-in-ubuntu/
[29]:http://www.tecmint.com/wp-content/uploads/2017/03/list-all-signals.png
[30]:http://www.tecmint.com/wp-content/uploads/2017/03/top-command.png
[31]:http://www.tecmint.com/author/aaronkili/
[32]:http://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/
[33]:http://www.tecmint.com/free-linux-shell-scripting-books/