Merge pull request #51 from LCTT/master

Update Repository
This commit is contained in:
joeren 2014-11-26 08:51:56 +08:00
commit d12778e9e8
19 changed files with 1062 additions and 152 deletions

View File

@ -1,9 +1,8 @@
如何用Puppet和Augeas管理Linux配置
================================================================================
虽然[Puppet][1]此文原文原文中曾今做过文件名“20140808 How to install Puppet server and client on CentOS and RHEL.md”如果翻译发布过可修改此链接为发布地址是一个非常独特的和有用的工具在有些情况下你可以使用一点不同的方法。要修改的配置文件已经在几个不同的服务器上且它们在这时是互补相同的。Puppet实验室的人也意识到了这一点并集成了一个伟大的工具称之为[Augeas][2],它是专为这种使用情况而设计的。
虽然[Puppet][1]是一个真正独特的有用工具但在有些情况下你可以使用一点不同的方法来用它。比如你要修改几个服务器上已有的配置文件而且它们彼此稍有不同。Puppet实验室的人也意识到了这一点他们在 Puppet 中集成了一个叫做[Augeas][2]的伟大的工具,它是专为这种使用情况而设计的。
Augeas可被认为填补了Puppet能力的缺陷其中一个特定对象的资源类型如主机资源来处理/etc/hosts中的条目还不可用。在这个文档中您将学习如何使用Augeas来减轻你管理配置文件的负担。
Augeas可被认为填补了Puppet能力的空白比如在其中一个指定对象的资源类型例如用于维护/etc/hosts中的条目的主机资源还不可用时。在这个文档中您将学习如何使用Augeas来减轻你管理配置文件的负担。
### Augeas是什么? ###
@ -11,13 +10,13 @@ Augeas基本上就是一个配置编辑工具。它以他们原生的格式解
### 这篇教程要达成什么目的? ###
我们会安装并配置Augeas用于我们之前构建的Puppet服务器。我们会使用这个工具创建并测试几个不同的配置文件,并学习如何适当地使用它来管理我们的系统配置。
我们会针对[我们之前构建的Puppet服务器][1]安装并配置Augeas。我们会使用这个工具创建并测试几个不同的配置文件,并学习如何适当地使用它来管理我们的系统配置。
### 先决条件 ###
### 前置阅读 ###
我们需要一台工作的Puppet服务器和客户端。如果你还没有请先按照我先前的教程来。
我们需要一台工作的Puppet服务器和客户端。如果你还没有请先按照我先前的[教程][1]来。
Augeas安装包可以在标准CentOS/RHEL仓库中找到。不幸的是Puppet用到的ruby封装的Augeas只在puppetlabs仓库中或者[EPEL][4])中才有。如果你系统中还没有这个仓库,请使用下面的命令:
Augeas安装包可以在标准CentOS/RHEL仓库中找到。不幸的是Puppet用到的Augeas的ruby封装只在puppetlabs仓库中或者[EPEL][4])中才有。如果你系统中还没有这个仓库,请使用下面的命令:
在CentOS/RHEL 6.5上:
@ -31,7 +30,7 @@ Augeas安装包可以在标准CentOS/RHEL仓库中找到。不幸的是Puppet
# yum install ruby­augeas
或者如果你是从我的上一篇教程中继续的使用puppet的方法安装这个包。在/etc/puppet/manifests/site.pp中修改你的custom_utils类在packages这行中加入“ruby­augeas”。
或者如果你是从我的[上一篇教程中继续][1]使用puppet的方法安装这个包。在/etc/puppet/manifests/site.pp中修改你的custom_utils类在packages这行中加入“ruby­augeas”。
class custom_utils {
package { ["nmap","telnet","vim­enhanced","traceroute","ruby­augeas"]:
@ -54,7 +53,7 @@ Augeas安装包可以在标准CentOS/RHEL仓库中找到。不幸的是Puppet
1. 给wheel组加上sudo权限。
这个例子会向你战士如何在你的GNU/Linux系统中为%wheel组加上sudo权限。
这个例子会向你展示如何在你的GNU/Linux系统中为%wheel组加上sudo权限。
# 安装sudo包
package { 'sudo':
@ -73,7 +72,7 @@ Augeas安装包可以在标准CentOS/RHEL仓库中找到。不幸的是Puppet
]
}
现在来解释这些代码做了什么:**spec**定义了/etc/sudoers中的用户段**[user]**定义了数组中给定的用户,所有的定义的斜杠( / ) 后用户的子部分。因此在典型的配置中这个可以这么表达:
现在来解释这些代码做了什么:**spec**定义了/etc/sudoers中的用户段**[user]**定义了数组中给定的用户,所有的定义放在该用户的斜杠( / ) 后那部分。因此在典型的配置中这个可以这么表达:
user host_group/host host_group/command host_group/command/runas_user
@ -83,7 +82,7 @@ Augeas安装包可以在标准CentOS/RHEL仓库中找到。不幸的是Puppet
2. 添加命令别称
下面这部分会向你展示如何定义命令别名,可以在你的sudoer文件中使用。
下面这部分会向你展示如何定义命令别名,可以在你的sudoer文件中使用。
# 创建新的SERVICE别名包含了一些基本的特权命令。
augeas { 'sudo_cmdalias':
@ -97,7 +96,7 @@ Augeas安装包可以在标准CentOS/RHEL仓库中找到。不幸的是Puppet
]
}
sudo命令别名的语法很简单**Cmnd_Alias**定义了命令别名字段,**[alias/name]**绑定所有给定的别名,/alias/name **SERVICES** 定义真实的别名以及alias/command 是所有命令的数组,每条命令是这个别名的一部分。
sudo命令别名的语法很简单**Cmnd_Alias**定义了命令别名字段,**[alias/name]**绑定所有给定的别名,/alias/name **SERVICES** 定义真实的别名alias/command 是属于该别名的所有命令的数组。以上将被转换如下:
Cmnd_Alias SERVICES = /sbin/service , /sbin/chkconfig , /bin/hostname , /sbin/shutdown
@ -105,12 +104,12 @@ sudo命令别名的语法很简单**Cmnd_Alias**定义了命令别名字段
#### 向一个组中加入用户 ####
要使用Augeas向组中添加用户有也许要添加一个新用户无论是在gid字段后或者在最后一个用户后。我们在这个例子中使用组SVN。这可以通过下面的命令达成:
要使用Augeas向组中添加用户也许要添加一个新用户,不管是排在 gid 字段还是最后的用户 uid 之后。我们在这个例子中使用SVN组。这可以通过下面的命令达成:
在Puppet中:
augeas { 'augeas_mod_group:
context => '/files/etc/group', # The target file is /etc/group
context => '/files/etc/group', #目标文件是 /etc/group
changes => [
"ins user after svn/*[self::gid or self::user][last()]",
"set svn/user[last()] john",
@ -123,14 +122,14 @@ sudo命令别名的语法很简单**Cmnd_Alias**定义了命令别名字段
### 总结 ###
目前为止你应该对如何在Puppet项目中使用Augeas有一个好想法了。随意地试一下,你肯定会经历官方的Augeas文档。这会帮助你了解如何在你的个人项目中正确地使用Augeas并且它会想你展示你可以用它节省多少时间。
目前为止你应该对如何在Puppet项目中使用Augeas有点明白了。随意地试一下,你肯定需要浏览官方的Augeas文档。这会帮助你了解如何在你的个人项目中正确地使用Augeas并且它会让你知道可以用它节省多少时间。
如有任何问题,欢迎在下面的评论中发布,我会尽力解答和向你建议。
### 有用的链接 ###
- [http://www.watzmann.net/categories/augeas.html][6]: contains a lot of tutorials focused on Augeas usage.
- [http://projects.puppetlabs.com/projects/1/wiki/puppet_augeas][7]: Puppet wiki with a lot of practical examples.
- [http://www.watzmann.net/categories/augeas.html][6]: 包含许多关于 Augeas 使用的教程。
- [http://projects.puppetlabs.com/projects/1/wiki/puppet_augeas][7]: Puppet wiki 带有许多实例。
--------------------------------------------------------------------------------
@ -138,12 +137,12 @@ via: http://xmodulo.com/2014/09/manage-configurations-linux-puppet-augeas.html
作者:[Jaroslav Štěpánek][a]
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://xmodulo.com/author/jaroslav
[1]:http://xmodulo.com/2014/08/install-puppet-server-client-centos-rhel.html
[1]:http://linux.cn/article-3959-1.html
[2]:http://augeas.net/
[3]:http://xmodulo.com/manage-configurations-linux-puppet-augeas.html
[4]:http://xmodulo.com/2013/03/how-to-set-up-epel-repository-on-centos.html

View File

@ -1,24 +1,24 @@
Ansible和Docker的作用和用法
================================================================================
在 [Docker][1] 和 [Ansible][2] 的技术社区内存在着很多好玩的东西,我希望在你阅读完这篇文章后也能获取到我们对它们的那种热爱。当然,你也会收获一些实践知识,那就是如何通过部署 Ansible 和 Docker 来为 Rails 应用搭建一个完整的服务器环境。
在 [Docker][1] 和 [Ansible][2] 的技术社区内存在着很多好玩的东西,我希望在你阅读完这篇文章后也能像我们一样热爱它们。当然,你也会收获一些实践知识,那就是如何通过部署 Ansible 和 Docker 来为 Rails 应用搭建一个完整的服务器环境。
也许有人会问:你怎么不去用 Heroku首先我可以在任何供应商提供的主机上运行 Docker 和 Ansible其次相比于方便性我更偏向于喜欢灵活性。我可以在这种组合中运行任何程序而不仅仅是 web 应用。最后,我骨子里是一个工匠,我非常解如何把零件拼凑在一起工作。Heroku 的基础模块是 Linux Container而 Docker 表现出来的多功能性也是基于这种技术。事实上Docker 的其中一个座右铭是:容器化是新虚拟化技术。
也许有人会问:你怎么不去用 Heroku首先我可以在任何供应商提供的主机上运行 Docker 和 Ansible其次相比于方便性我更偏向于喜欢灵活性。我可以在这种组合中运行任何程序而不仅仅是 web 应用。最后,我骨子里是一个工匠,我非常解如何把零件拼凑在一起工作。Heroku 的基础模块是 Linux Container而 Docker 表现出来的多功能性也是基于这种技术。事实上Docker 的其中一个座右铭是:容器化是新虚拟化技术。
### 为什么使用 Ansible ###
我重度使用 Chef 已经有4年了LCTTChef 是与 puppet 类似的配置管理工具),**基础设施即代码**的观念让我觉得非常无聊。我花费大量时间来管理代码,而不是管理基础设施本身。不论多小的改变,都需要相当大的努力来实现它。使用 [Ansible][3],你可以一手掌握拥有可描述性数据的基础架构,另一只手掌握不同组件之间的交互作用。这种更简单的操作模式让我把精力集中在如何将我的技术设施私有化,提高了我的工作效率。与 Unix 的模式一样Ansible 提供大量功能简单的模块,我们可以组合这些模块,达到不同的工作要求。
除了 Python 和 SSHAnsible 不再依赖其他软件,在它的远端主机上不需要部署代理,也不会留下任何运行痕迹。更厉害的是,它提供一套内建的、可扩展的模块库文件,通过它你可以控制所有:包管理器、云服务供应商、数据库等等等等。
除了 Python 和 SSHAnsible 不再依赖其他软件,在它的远端主机上不需要部署代理,也不会留下任何运行痕迹。更厉害的是,它提供一套内建的、可扩展的模块库文件,通过它你可以控制所有的一切:包管理器、云服务供应商、数据库等等等等。
### 为什么要使用 Docker ###
[Docker][4] 的定位是:提供最可靠、最方便的方式来部署服务。这些服务可以是 mysqld可以是 redis可以是 Rails 应用。先聊聊 git它的快照功能让它可以以最有效的方式发布代码Docker 的处理方法与它类似。它保证应用可以无视主机环境,随心所欲地跑起来。
[Docker][4] 的定位是:提供最可靠、最方便的方式来部署服务。这些服务可以是 mysqld可以是 redis可以是 Rails 应用。先聊聊 git它的快照功能让它可以以最有效的方式发布代码Docker 的处理方法与它类似。它保证应用可以无视主机环境,随心所欲地跑起来。
一种最普遍的误解是人们总是把 Docker 容器看成是一个虚拟机当然我表示理解你们的误解。Docker 满足[单一功能原则][5],在一个容器里面只跑一个进程,所以一次修改只会影响一个进程,而这些进程可以被重用。这种模型参考了 Unix 的哲学思想,当前还处于试验阶段,并且正变得越来越稳定。
### 设置选项 ###
不需要离开终端,我就可以使用 Ansible 来生成以下实例Amazon Web ServicesLinodeRackspace 以及 DigitalOcean。如果想要更详细的信息我于1分25秒内在位于阿姆斯特丹的2号数据中心上创建了一个 2GB 的 DigitalOcean 虚拟机。另外的1分50秒用于系统配置包括设置 Docker 和其他个人选项。当我完成这些基本设定后就可以部署我的应用了。值得一提的是这个过程中我没有配置任何数据库或程序开发语言Docker 已经帮我把应用所需要的事情都安排好了。
不需要离开终端,我就可以使用 Ansible 来在这些云平台中生成实例Amazon Web ServicesLinodeRackspace 以及 DigitalOcean。如果想要更详细的信息我于1分25秒内在位于阿姆斯特丹的2号数据中心上创建了一个 2GB 的 DigitalOcean 虚拟机。另外的1分50秒用于系统配置包括设置 Docker 和其他个人选项。当我完成这些基本设定后就可以部署我的应用了。值得一提的是这个过程中我没有配置任何数据库或程序开发语言Docker 已经帮我把应用所需要的事情都安排好了。
Ansible 通过 SSH 为远端主机发送命令。我保存在本地 ssh 代理上面的 SSH 密钥会通过 Ansible 提供的 SSH 会话分享到远端主机。当我把应用代码从远端 clone 下来,或者上传到远端时,我就不再需要提供 git 所需的证书了,我的 ssh 代理会帮我通过 git 主机的身份验证程序的。
@ -65,13 +65,13 @@ CMD 这个步骤是在新的 web 应用容器启动后执行的。在测试环
没有本地 Docker 镜像,从零开始部署一个中级规模的 Rails 应用大概需要100个 gems进行100次整体测试在使用2个核心实例和2GB内存的情况下这些操作需要花费8分16秒。装上 Ruby、MySQL 和 Redis Docker 镜像后部署应用花费了4分45秒。另外如果从一个已存在的主应用镜像编译出一个新的 Docker 应用镜像出来只需花费2分23秒。综上所述部署一套新的 Rails 应用,解决其所有依赖关系(包括 MySQL 和 Redis只需花我2分钟多一点的时间就够了。
需要指出的一点是我的应用上运行着一套完全测试套件跑完测试需要花费额外1分钟时间。尽管是无意的Docker 可以变成一套简单的持续集成环境当测试失败后Docker 会把“test-only”这个容器保留下来用于分析出错原因。我可以在1分钟之内和我的客户一起验证新代码保证不同版本的应用之间是完全隔离的同操作系统也是隔离的。传统虚拟机启动系统时需要花费好几分钟Docker 容器只花几秒。另外,一旦一个 Dockedr 镜像编译出来,并且针对我的某个版本的应用的测试都被通过,我就可以把这个镜像提交到 Docker 私服 Registry 上,可以被其他 Docker 主机下载下来并启动一个新的 Docker 容器,而这不过需要几秒钟时间。
需要指出的一点是我的应用上运行着一套完全测试套件跑完测试需要花费额外1分钟时间。尽管是无意的Docker 可以变成一套简单的持续集成环境当测试失败后Docker 会把“test-only”这个容器保留下来用于分析出错原因。我可以在1分钟之内和我的客户一起验证新代码保证不同版本的应用之间是完全隔离的同操作系统也是隔离的。传统虚拟机启动系统时需要花费好几分钟Docker 容器只花几秒。另外,一旦一个 Dockedr 镜像编译出来,并且针对我的某个版本的应用的测试都被通过,我就可以把这个镜像提交到一个私有的 Docker Registry 上,可以被其他 Docker 主机下载下来并启动一个新的 Docker 容器,而这不过需要几秒钟时间。
### 总结 ###
Ansible 让我重新看到管理基础设施的乐趣。Docker 让我有充分的信心能稳定处理应用部署过程中最重要的步骤——交付环节。双剑合璧,威力无穷。
从无到有搭建一个完整的 Rails 应用可以在12分钟内完成这种速度放在任何场合都是令人印象深刻的。能获得一个免费的持续集成环境可以查看不同版本的应用之间的区别不会影响到同主机上已经在运行的应用这些功能强大到难以置信让我感到很兴奋。在文章的最后我只希望你能感受到我的兴奋
从无到有搭建一个完整的 Rails 应用可以在12分钟内完成这种速度放在任何场合都是令人印象深刻的。能获得一个免费的持续集成环境可以查看不同版本的应用之间的区别不会影响到同主机上已经在运行的应用这些功能强大到难以置信让我感到很兴奋。在文章的最后我只希望你能感受到我的兴奋
我在2014年1月伦敦 Docker 会议上讲过这个主题,[已经分享到 Speakerdeck][7]了。
@ -87,7 +87,7 @@ via: http://thechangelog.com/ansible-docker/
作者:[Gerhard Lazu][a]
译者:[bazz2](https://github.com/bazz2)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出

View File

@ -5,7 +5,7 @@
Git教程往往不会解决这个问题因为它集中篇幅来教你Git命令和概念并且不认为你会使用GitHub。[GitHub帮助教程](https://help.github.com/)一定程度上弥补了这一缺陷,但是它每篇文章的关注点都较为狭隘,而且没有提供关于"Git vs GitHub"问题的概念性概述。
**如果你是习惯于先理解概念,再着手代码的学习者**而且你也是Git和GitHub的初学者我建议你先理解清楚什么是fork,为什么
**如果你是习惯于先理解概念,再着手代码的学习者**而且你也是Git和GitHub的初学者我建议你先理解清楚什么是fork。为什么呢
1. Fork是在GitHub起步最普遍的方式。
2. Fork只需要很少的Git命令但是起得作用却非常大。
@ -53,15 +53,19 @@ Joe和其余贡献者已经对这个项目做了一些修改而你将在他
### 结论
我希望这是一篇关于GitHub和Git [fork](https://help.github.com/articles/fork-a-repo)有用概述。现在你已经理解了那些概念你将会更容易地在实际中执行你的代码。GitHub关于fork和[同步](https://help.github.com/articles/syncing-a-fork)的文章将会给你大部分你需要的代码。
我希望这是一篇关于GitHub和Git [fork](https://help.github.com/articles/fork-a-repo)有用概述。现在你已经理解了那些概念你将会更容易地在实际中执行你的代码。GitHub关于fork和[同步](https://help.github.com/articles/syncing-a-fork)的文章将会给你大部分你需要的代码。
如果你是Git的初学者而且你很喜欢这种学习方式那么我极力推荐书籍[Pro Git](http://git-scm.com/book)的前两个章节,网上是可以免费查阅的。
如果你喜欢视频学习,我创建了一个[11部分的视频系列](http://www.dataschool.io/git-and-github-videos-for-beginners/)总共36分钟来向初学者介绍Git和GitHub。
---
via: http://www.dataschool.io/simple-guide-to-forks-in-github-and-git/
作者:[Kevin Markham][a]
译者:[su-kaiyao](https://github.com/su-kaiyao)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:https://disqus.com/home/user/justmarkham/

View File

@ -1,5 +1,7 @@
Linux下的6个扫雷翻版
Linux下的6个扫雷游戏的翻版
================================================================================
Windows 下的扫雷游戏还没玩够么?那么来 Linux 下继续扫雷吧——这是一个雷的时代~~
### GNOME Mines ###
这是GNOME扫雷复制品允许你从3个不同的预定义表大小8×8, 16×16, 30×16中选择其一或者自定义行列的数量。它能以全屏模式运行带有高分值、耗时和提示。游戏可以暂停和继续。
@ -8,14 +10,14 @@ Linux下的6个扫雷翻版
### ace-minesweeper ###
这是一个包中的游戏此包中也包含有其它一些游戏如ace-freecelace-solitaire或ace-spider。它有一个以小企鹅为特色的图形化界面但好像不能调整表的大小。该包在Ubuntu中名为ace-of-penguins。
这是一个大的软件包中的游戏此包中也包含有其它一些游戏如ace-freecelace-solitaire或ace-spider。它有一个以小企鹅为特色的图形化界面但好像不能调整表的大小。该包在Ubuntu中名为ace-of-penguins。
![](http://www.tuxarena.com/wp-content/uploads/2014/10/ace-minesweeper.jpg)
### XBomb ###
XBomb是针对X Windows系统扫雷游戏它有三种不同的表尺寸和卡牌风格包含有不同的外形六角形、矩形传统或三角形。不幸的是在Ubuntu 14.04中的版本会出现程序分段冲突,所以你可能需要安装另外一个版本。
[首页][1]
[首页][1]
![](http://www.tuxarena.com/wp-content/uploads/2014/10/xbomb.png)
@ -45,7 +47,7 @@ via: http://www.tuxarena.com/2014/10/6-minesweeper-clones-for-linux/
作者Craciun Dan
译者:[GOLinux](https://github.com/GOLinux)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出

View File

@ -1,6 +1,6 @@
Linux 有问必答 -- 如何修复“hda-duplex not supported in this QEMU binary”hda-duplex在此QEMU文件中不支持
Linux 有问必答如何修复“hda-duplex not supported in this QEMU binary”
================================================================================
> **提问** 当我尝试在虚拟机中安装一个新的Linux时虚拟机不能启动且报了下面这个错误“不支持的配置hda-duplex在此QEMU文件中不支持。” 我该如何修复?
> **提问** 当我尝试在虚拟机中安装一个新的Linux时虚拟机不能启动且报了下面这个错误"unsupported configuration: hda-duplex not supported in this QEMU binary."“不支持的配置hda-duplex在此QEMU文件中不支持。” 我该如何修复?
这个错误可能来自一个当默认声卡型号不能被识别时的一个qemu bug。
@ -20,7 +20,7 @@ Linux 有问必答 -- 如何修复“hda-duplex not supported in this QEMU binar
### 方案二: Virsh ###
如果你使用的是**virt-manager** 而不是**virt-manager** 你可以编辑VM相应的配置文件。在<device>节点中查找**sound**节点,并按照下面的默认声卡型号改成**ac97**。
如果你使用的是**virsh** 而不是**virt-manager** 你可以编辑VM相应的配置文件。在<device>节点中查找**sound**节点,并按照下面的默认声卡型号改成**ac97**。
<devices>
. . .
@ -35,6 +35,6 @@ Linux 有问必答 -- 如何修复“hda-duplex not supported in this QEMU binar
via: http://ask.xmodulo.com/hda-duplex-not-supported-in-this-qemu-binary.html
译者:[geekpi](https://github.com/geekpi)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出

View File

@ -1,6 +1,6 @@
使用GDB命令行调试器调试C/C++程序
============================================================
没有调试器的情况下编写程序时最糟糕的状况是什么?编译时跪着祈祷不要出错用生命在运行可执行程序blood offering不知道怎么翻译好...或者在每一行代码间添加printf("test")语句来定位错误点?如你所知,编写程序时不使用调试器的话是不的。幸好linux下调试还是很方便的。大多数人使用的IDE都集成了调试器linxu著名的调试器是命令行形式的C/C++调试器GDB。然而与其他命令行工具一致DGB需要一定的练习才能完全掌握。这里我会告诉你GDB的基本情况及使用方法。
没有调试器的情况下编写程序时最糟糕的状况是什么?编译时跪着祈祷不要出错?用血祭召唤恶魔帮你运行可执行程序或者在每一行代码间添加printf("test")语句来定位错误点?如你所知,编写程序时不使用调试器的话是不方便的。幸好linux下调试还是很方便的。大多数人使用的IDE都集成了调试器 linux 最著名的调试器是命令行形式的C/C++调试器GDB。然而与其他命令行工具一致DGB需要一定的练习才能完全掌握。这里我会告诉你GDB的基本情况及使用方法。
###安装GDB###
@ -18,11 +18,11 @@ Fedora,CentOS 或 RHEL
$sudo yum install gdb
如果在仓库中找不到的话,可以从官网中下载[official page][1]
如果在仓库中找不到的话,可以从[官网中下载][1]
###示例代码###
当学习GDB时最好有一份代码动手试验。下列代码是我编写的简单例子它可以很好的体现GDB的特性。将它拷贝下来并且进行实验这是最好的方法。
当学习GDB时最好有一份代码动手试验。下列代码是我编写的简单例子它可以很好的体现GDB的特性。将它拷贝下来并且进行实验——这是最好的方法。
#include <stdio.h>
#include <stdlib.h>
@ -48,21 +48,21 @@ Fedora,CentOS 或 RHEL
$ gdb -tui [executable's name]
使用”-tui“选项可以将代码显示在一个窗口内被称为”文本接口”在这个窗口内可以使用光标来操控同时在下面输入GDB shell命令。
使用”-tui“选项可以将代码显示在一个漂亮的交互式窗口内(所以被称为“文本用户界面 TUI”在这个窗口内可以使用光标来操控同时在下面的GDB shell中输入命令。
![](https://farm3.staticflickr.com/2947/15397534362_ac0b5692c8_z.jpg)
现在我们可以在程序的任何地方设置断点。你可以通过下列命令来为当前源文件的某一行设置断点。
break [line number]
break [行号]
或者为一个特定的函数设置断点:
break [function name]
break [函数名]
甚至可以设置条件断点
break [line number] if [condition]
break [行号] if [条件]
例如,在我们的示例代码中,可以设置如下:
@ -74,23 +74,25 @@ Fedora,CentOS 或 RHEL
最后但也是很重要的是,我们可以设置一个“观察断点”,当这个被观察的变量发生变化时,程序会被停止。
watch [variable]
watch [变量]
可以设置如下:
这里我们可以设置如下:
watch d
当d的值发生变化时程序会停止运行例如当i>97为真时
当设置后断点后,使用"run"命令开始运行程序,或按如下所示:
当设置断点后,使用"run"命令开始运行程序,或按如下所示:
r [程序的输入参数(如果有的话)]
gdb中大多数的单词都可以简写为一个字母。
gdb中大多数的命令单词都可以简写为一个字母。
不出意外程序会停留在11行。这里我们可以做些有趣的事情。下列命令
bt
回溯功能可以让我们知道程序如何到达这条语句的。
回溯功能backtrace可以让我们知道程序如何到达这条语句的。
![](https://farm3.staticflickr.com/2943/15211202760_1e77a3bb2e_z.jpg)
@ -98,16 +100,15 @@ gdb中大多数的单词都可以简写为一个字母。
这条语句会显示所有的局部变量以及它们的值(你可以看到,我没有为d设置初始值,所以它现在的值是任意值)。
当然
当然
![](https://farm4.staticflickr.com/3843/15374838916_8b65e4e3c7_z.jpg)
p [variable]
p [变量]
这可以显示特定变量的值,但是还有更好的:
ptype [variable]
这个命令可以显示特定变量的值,而更进一步:
ptype [变量]
可以显示变量的类型。所以这里可以确定d是double型。
@ -115,11 +116,11 @@ gdb中大多数的单词都可以简写为一个字母。
既然已经到这一步了,我么不妨这么做:
    set var [variable] = [new value]
set var [变量] = [新的值]
这样会覆盖变量的值。不过需要注意,你不能创建一个新的变量或改变变量的类型。我们可以这样做:
    set var a = 0
set var a = 0
![](https://farm3.staticflickr.com/2949/15211357497_d28963a9eb_o.png)
@ -127,17 +128,17 @@ gdb中大多数的单词都可以简写为一个字母。
step
使用如上命令,运行到下一条语句,也可以进入到一个函数里面。或者使用:
使用如上命令,运行到下一条语句,有可能进入到一个函数里面。或者使用:
next
这可以直接下一条语句,并且不进入子函数内部。
这可以直接运行下一条语句,而不进入子函数内部。
![](https://farm4.staticflickr.com/3927/15397863215_fb2f5912ac_o.jpg)
结束测试后,删除断点:
delete [line number]
delete [行号]
从当前断点继续运行程序:
@ -147,7 +148,7 @@ gdb中大多数的单词都可以简写为一个字母。
quit
有了GDB编译时不用祈祷上帝了运行时不用血祭再也不用printf(“test“了。当然这里所讲的并不完整而且GDB的功能远不止这些。所以我强烈建议你自己更加深入的学习它。我现在感兴趣的是将GDB整合到Vim中。同时这里有一个[备忘录][2]记录了GDB所有的命令行以供查阅。
有了GDB编译时不用祈祷上帝了运行时不用血祭了再也不用printf(“test“了。当然这里所讲的并不完整而且GDB的功能远远不止于此。所以我强烈建议你自己更加深入的学习它。我现在感兴趣的是将GDB整合到Vim中。同时这里有一个[备忘录][2]记录了GDB所有的命令行以供查阅。
你对GDB有什么看法你会将它与图形调试器对比吗它有什么优势呢对于将GDB集成到Vim有什么看法呢将你的想法写到评论里。
@ -157,7 +158,7 @@ via: http://xmodulo.com/gdb-command-line-debugger.html
作者:[Adrien Brochard][a]
译者:[SPccman](https://github.com/SPccman)
校对:[校对者ID](https://github.com/校对者ID)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出

View File

@ -1,8 +1,7 @@
如何将Ubuntu14.04安全的升级到14.10
如何将 Ubuntu14.04 安全的升级到14.10
================================================================================
本文将讨论如何将Ubuntu14.04升级到14.10的beta版。Ubuntu14.10的最终beta版已经发布了
如果想从Ubuntu14.04/13.10/13.04/12.10/12.04或者更老的版本升级到14.10只要遵循下面给出的步骤。注意你不能直接从13.10升级到14.10。你应该将13.10升级到14.04在从14.04升级到14.10。下面是详细步骤。
如果想从Ubuntu14.04/13.10/13.04/12.10/12.04或者更老的版本升级到14.10只要遵循下面给出的步骤。注意你不能直接从13.10升级到14.10。你应该将13.10升级到14.04在从14.04升级到14.10。下面是详细步骤。
下面的步骤不仅能用于14.10也兼容于一些像Lubuntu14.10Kubuntu14.10和Xubuntu14.10等的Ubuntu衍生版本
@ -90,15 +89,15 @@
sudo do-release-upgrade -d
直到屏幕提示你已完成
直到屏幕提示你已完成
--------------------------------------------------------------------------------
via: http://www.unixmen.com/upgrade-ubuntu-14-04-trusty-ubuntu-14-10-utopic/
作者SK
译者:[译者ID](https://github.com/johnhoow)
校对:[校对者ID](https://github.com/校对者ID)
译者:[johnhoow](https://github.com/johnhoow)
校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出

View File

@ -1,4 +1,4 @@
[translating by KayGuoWhu]
[Translating by Stevearzh]
When hackers grow old
================================================================================
Lately Ive been wrestling with various members of an ancient and venerable open-source development group which I am not going to name, though people who regularly follow my adventures will probably guess which one it is by the time Im done venting.

View File

@ -0,0 +1,55 @@
Four ways Linux is headed for no-downtime kernel patching
================================================================================
![Credit: Shutterstock](http://images.techhive.com/images/article/2014/10/patch_f-100526950-primary.idge.jpeg)
Credit: Shutterstock
These technologies are competing to provide the best way to patch the Linux kernel without reboots or downtime
Nobody loves a reboot, especially not if it involves a late-breaking patch for a kernel-level issue that has to be applied stat.
To that end, three projects are in the works to provide a mechanism for upgrading the kernel in a running Linux instance without having to reboot anything.
### Ksplice ###
The first and original contender is Ksplice, courtesy of a company of the same name founded in 2008. The kernel being replaced does not have to be pre-modified; all it needs is a diff file listing the changes to be made to the kernel source. Ksplice, Inc. offered support for the (free) software as a paid service and supported most common Linux distributions used in production.
All that changed in 2011, when [Oracle purchased the company][1], rolled the feature into its own Linux distribution, and kept updates for the technology to itself. As a result, other intrepid kernel hackers have been looking for ways to pick up where Ksplice left off, without having to pay the associated Oracle tax.
### Kgraft ###
In February 2014, Suse provided the exact solution needed: [Kgraft][2], its kernel-update technology released under a mixed GPLv2/GPLv3 license and not kept close as a proprietary creation. It's since been [submitted][3] as a possible inclusion to the mainline Linux kernel, although Suse has rolled a version of the technology into [Suse Linux Enterprise Server 12][4].
Kgraft works roughly like Ksplice by using a set of diffs to figure out what parts of the kernel to replace. But unlike Ksplice, Kgraft doesn't need to stop the kernel entirely to replace it. Any running functions can be directed to their old or new kernel-level counterparts until the patching process is finished.
### Kpatch ###
Red Hat came up with its own no-reboot kernel-patch mechanism, too. Also introduced earlier this year -- right after Suse's work in that vein, no less -- [Kpatch][5] works in roughly the same manner as Kgraft.
The main difference, [as outlined][6] by Josh Poimboeuf of Red Hat, is that Kpatch doesn't redirect calls to old kernel functions. Rather, it waits until all function calls have stopped, then swaps in the new kernel. Red Hat's engineers consider this approach safer, with less code to maintain, albeit at the cost of more latency during the patch process.
Like Kgraft, Kpatch has been submitted for consideration as a possible kernel inclusion and can be used with Linux kernels other than Red Hat's. The bad news is that Kpatch isn't yet considered production-ready by Red Hat. It's included as part of Red Hat Enterprise Linux 7, but only in the form of a technology preview.
### ...or Kgraft + Kpatch? ###
A fourth solution [proposed by Red Hat developer Seth Jennings][7] early in November 2014 is a mix of both the Kgraft and Kpatch approaches, using patches built for either one of those solutions. This new approach, Jennings explained, "consists of a live patching 'core' that provides an interface for other 'patch' kernel modules to register patches with the core." This way, the patching process -- specifically, how to deal with any running kernel functions -- can be handled in a more orderly fashion.
The sheer newness of these proposals means it'll be a while before any of them are officially part of the Linux kernel, although Suse's chosen to move fast and made it a part of its latest enterprise offering. Let's see if Red Hat and Canonical choose to follow suit in the short run as well.
--------------------------------------------------------------------------------
via: http://www.infoworld.com/article/2851028/linux/four-ways-linux-is-headed-for-no-downtime-kernel-patching.html
作者:[Serdar Yegulalp][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.infoworld.com/author/Serdar-Yegulalp/
[1]:http://www.infoworld.com/article/2622437/open-source-software/oracle-buys-ksplice-for-linux--zero-downtime--tech.html
[2]:http://www.infoworld.com/article/2610749/linux/suse-open-sources-live-updater-for-linux-kernel.html
[3]:https://lwn.net/Articles/596854/
[4]:http://www.infoworld.com/article/2838421/linux/suse-linux-enterprise-12-goes-light-on-docker-heavy-on-reliability.html
[5]:https://github.com/dynup/kpatch
[6]:https://lwn.net/Articles/597123/
[7]:http://lkml.iu.edu/hypermail/linux/kernel/1411.0/04020.html

View File

@ -1,78 +0,0 @@
alim0x translating
The history of Android
================================================================================
![The new Android Market—less black, more white and green.](http://cdn.arstechnica.net/wp-content/uploads/2013/12/marketab2.png)
The new Android Market—less black, more white and green.
Photo by Ron Amadeo
### Android 1.6, Donut—CDMA support brings Android to any carrier ###
The fourth version of Android—1.6, Donut—launched in September 2009, five months after Cupcake hit the market. Despite the myriad of updates, Google was still adding basic functionality to Android. Donut brought support for different screen sizes, CDMA support, and a text-to-speech engine.
Android 1.6 is a great example of an update that, today, would have little reason to exist as a separate point update. The major improvements basically boiled down to new versions of the Android Market, camera, and YouTube. In the years since, apps like this have been broken out of the OS and can be updated by Google at any time. Before all this modularization work, though, even seemingly minor app updates like this required a full OS update.
The other big improvement—CDMA support—demonstrated that, despite the version number, Google was still busy getting basic functionality into Android.
The Android Market was christened as version "1.6" and got a complete overhaul. The original all-black design was tossed in favor of a white app with green highlights—the Android designers were clearly using the Android mascot for inspiration.
The new market was definitely a new style of app design for Google. The top fifth of the screen was dedicated to a banner logo announcing that this app is indeed the “Android Market." Below the banner were buttons for Apps, Games, and Downloads, and a search button was placed to the right of the banner. Below the navigation was a thumbnail display of featured apps, which could be swiped through. Below that were even more featured apps in a vertically scrolling list.
![The new Market design, showing an app page with screenshots, the apps categories page, an app top list, and the downloads section.](http://cdn.arstechnica.net/wp-content/uploads/2013/12/marketpages.png)
The new Market design, showing an app page with screenshots, the apps categories page, an app top list, and the downloads section.
Photo by Ron Amadeo
The biggest addition to the market was the inclusion of app screenshots. Android users could finally see what an app looked like before installing it—previously they only had a brief description and user reviews to go on. Your personal star review and comment was given top billing, followed by the description, and then finally the screenshots. Viewing the screenshots would often require a bit of scrolling—if you were looking for a well-designed app, it was a lot of work.
Tapping on App or Games would bring up a category list, which you can see in the second picture, above. After picking a category, more navigation was shown at the top of the screen, where users could see "Top paid," "Top free," or "Just in" apps within a category. While these sorta looked like buttons that would load a new screen, they were really just a clunky tabbed interface. To denote which "tab" was currently active, there were little green lights next to each button. The nicest part of this interface was that the list of apps would scroll infinitely—once you hit the bottom, more apps would load in. This made it easy to look through the list of apps, but opening any app and coming back would lose your spot in the list—youd be kicked to the top. The downloads section would do something the new Google Play Store still can't do: simply display a list of your purchased apps.
While the new Market definitely looked better than the old market, cohesion across apps was getting worse and worse. It seemed like each app was made by a different group with no communication about how all Android apps should look.
![The Camera viewfinder, photo review screen, and menu.](http://cdn.arstechnica.net/wp-content/uploads/2013/12/device-2013-12-27-145949.png)
The Camera viewfinder, photo review screen, and menu.
Photo by Ron Amadeo
For instance, the camera app was changed from a full-screen, minimal design to a boxed viewfinder with controls on the side. With the new camera app, Google tried its hand at skeuomorphism, wrapping the whole app in a leather texture roughly replicating the exterior of a classic camera. Switching between the camera and camcorder was done with a literal switch, and below that was the on-screen shutter button.
Tapping on the previous picture thumbnail no longer launched the gallery, but a custom image viewer that was built in to the camera app. When viewing a picture the leather control area changed the camera controls to picture controls, where you could delete, share a picture, or set the picture as a wallpaper or contact image. There was still no swiping between pictures—that was still done with arrows on either side of the image.
This second picture shows one of the first examples of designers reducing dependence on the menu button, which the Android team slowly started to realize functioned terribly for discoverability. Many app designers (including those within Google) used the menu as a dumping ground for all sorts of controls and navigational elements. Most users didn't think to hit the menu button, though, and never saw the commands.
A common theme for future versions of Android would be moving things out of the menu and on to the main screen, making the whole OS more user-friendly. The menu button was completely killed in Android 4.0, and it's only supported in Android for legacy apps.
![The battery and TTS settings.](http://cdn.arstechnica.net/wp-content/uploads/2013/12/settings1.png)
The battery and TTS settings.
Photo by Ron Amadeo
Donut was the first Android version to keep track of battery usage. Buried in the "About phone" menu was an option called "Battery use," which would display battery usage by app and hardware function as a percentage. Tapping on an item would bring up a separate page with relevant stats. Hardware items had buttons to jump directly to their settings, so for instance, you could change the display timeout if you felt the display battery usage was too high.
Android 1.6 was also the first version to support text-to-speech (TTS) engines, meaning the OS and apps would be able to talk back to you in a robot voice. The “Speech synthesizer controls" would allow you to set the language, choose the speech rate, and (critically) install the voice data from the Android market. Today, Google has its own TTS engine that ships with Android, but it seems Donut was hard coded to accept one specific TTS engine made by SVOX. But SVOXs engine didnt ship with Donut, so tapping on “install voice data" linked to an app in the Android Market. (In the years since Donuts heyday, the app has been taken down. It seems Android 1.6 will never speak again.)
![From left to right: new widgets, the search bar UI, the new notification clear button, and the new gallery controls.](http://cdn.arstechnica.net/wp-content/uploads/2013/12/grabbag16.png)
From left to right: new widgets, the search bar UI, the new notification clear button, and the new gallery controls.
Photo by Ron Amadeo
There was more work on the widget front. Donut brought an entirely new widget called "Power control." This comprised on/off switches for common power-hungry features: Wi-FI, Bluetooth, GPS, Sync (to Google's servers), and brightness.
The search widget was redesigned to be much slimmer looking, and it had an embedded microphone button for voice search. It now had some actual UI to it and did find-as-you-type live searching, which searched not only the Internet, but your applications and history too.
The "Clear notifications" button has shrunk down considerably and lost the "notifications" text. In later Android versions it would be reduced to just a square button. The Gallery continues the trend of taking functionality out of the menu and putting it in front of the user—the individual picture view gained buttons for "Set as," "Share," and "Delete."
----------
![Ron Amadeo](http://cdn.arstechnica.net/wp-content//uploads/authors/ron-amadeo-sq.jpg)
[Ron Amadeo][a] / Ron is the Reviews Editor at Ars Technica, where he specializes in Android OS and Google products. He is always on the hunt for a new gadget and loves to rip things apart to see how they work.
[@RonAmadeo][t]
--------------------------------------------------------------------------------
via: http://arstechnica.com/gadgets/2014/06/building-android-a-40000-word-history-of-googles-mobile-os/9/
译者:[译者ID](https://github.com/译者ID) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://arstechnica.com/author/ronamadeo
[t]:https://twitter.com/RonAmadeo

View File

@ -0,0 +1,265 @@
15 pwd (Print Working Directory) Command Examples in Linux
================================================================================
For those working with Linux command Line, command **pwd** is very helpful, which tells where you are in which directory, starting from the root (**/**). Specially for Linux newbies, who may get lost amidst of directories in command Line Interface while navigation, command **pwd** comes to rescue.
![15 pwd Command Examples](http://www.tecmint.com/wp-content/uploads/2014/11/pwd-command.png)
15 pwd Command Examples
### What is pwd? ###
**pwd** stands for **Print Working Directory**. As the name states, command **pwd** prints the current working directory or simply the directory user is, at present. It prints the current directory name with the complete path starting from root (**/**). This command is built in shell command and is available on most of the shell bash, Bourne shell, ksh,zsh, etc.
#### Basic syntax of pwd: ####
# pwd [OPTION]
#### Options used with pwd ####
<table border="0" cellspacing="0">
<colgroup width="126"></colgroup>
<colgroup width="450"></colgroup>
<tbody>
<tr>
<td height="21" align="LEFT" style="border: 1px solid #000000;"><b><span style="font-size: small;">&nbsp;Options</span></b></td>
<td align="LEFT" style="border: 1px solid #000000;"><b><span style="font-size: small;">&nbsp;Description</span></b></td>
</tr>
<tr>
<td height="19" align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;">&nbsp;-L (logical)</span></td>
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;">&nbsp;Use PWD from environment, even if it contains symbolic links</span></td>
</tr>
<tr>
<td height="19" align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;">&nbsp;-P (physical)</span></td>
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;">&nbsp;Avoid all symbolic links</span></td>
</tr>
<tr>
<td height="19" align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;">&nbsp;&ndash;help </span></td>
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;">&nbsp;Display this help and exit</span></td>
</tr>
<tr>
<td height="19" align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;">&nbsp;&ndash;version</span></td>
<td align="LEFT" style="border: 1px solid #000000;"><span style="font-family: Liberation Serif,Times New Roman; font-size: small;">&nbsp;Output version information and exit</span></td>
</tr>
</tbody>
</table>
If both **-L** and **-P** options are used, option **L** is taken into priority. If no option is specified at the prompt, pwd will avoid all symlinks, i.e., take option **-P** into account.
Exit status of command pwd:
<table border="0" cellspacing="0">
<colgroup width="128"></colgroup>
<colgroup width="151"></colgroup>
<tbody>
<tr>
<td height="19" align="CENTER" style="border: 1px solid #000000;"><span style="font-size: small;">0</span></td>
<td align="CENTER" style="border: 1px solid #000000;"><span style="font-size: small;">Success</span></td>
</tr>
<tr>
<td height="19" align="CENTER" style="border: 1px solid #000000;"><span style="font-size: small;">Non-zero</span></td>
<td align="CENTER" style="border: 1px solid #000000;"><span style="font-size: small;">Failure</span></td>
</tr>
</tbody>
</table>
This article aims at providing you a deep insight of Linux command **pwd** with practical examples.
**1.** Print your current working directory.
avi@tecmint:~$ /bin/pwd
/home/avi
![Print Working Directory](http://www.tecmint.com/wp-content/uploads/2014/11/pwd.gif)
Print Working Directory
**2.** Create a symbolic link of a folder (say **/var/www/html** into your home directory as **htm**). Move to the newly created directory and print working directory with symbolic links and without symbolic links.
Create a symbolic link of folder /var/www/html as htm in your home directory and move to it.
avi@tecmint:~$ ln -s /var/www/html/ htm
avi@tecmint:~$ cd htm
![Create Symbolic Link](http://www.tecmint.com/wp-content/uploads/2014/11/Create-Symbolic-Link.gif)
Create Symbolic Link
**3.** Print working directory from environment even if it contains symlinks.
avi@tecmint:~$ /bin/pwd -L
/home/avi/htm
![Print Current Working Directory](http://www.tecmint.com/wp-content/uploads/2014/11/Print-Working-Directory.gif)
Print Current Working Directory
**4.** Print actual physical current working directory by resolving all symbolic links.
avi@tecmint:~$ /bin/pwd -P
/var/www/html
![Print Physical Working Directory](http://www.tecmint.com/wp-content/uploads/2014/11/Print-Physical-Working-Directory.gif)
Print Physical Working Directory
**5.** Check if the output of command “**pwd**” and “**pwd -P**” are same or not i.e., if no options are given at run-time does “**pwd**” takes option **-P** into account or not, automatically.
avi@tecmint:~$ /bin/pwd
/var/www/html
![Check pwd Output](http://www.tecmint.com/wp-content/uploads/2014/11/Check-pwd-Output.gif)
Check pwd Output
**Result:** Its clear from the above output of example 4 and 5 (both result are same) thus, when no options are specified with command “**pwd**”, it automatically takes option “**-P**” into account.
**6.** Print version of your pwd command.
avi@tecmint:~$ /bin/pwd --version
pwd (GNU coreutils) 8.23
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Jim Meyering.
![Check pwd Version](http://www.tecmint.com/wp-content/uploads/2014/11/Check-pwd-Version.gif)
Check pwd Version
**Note:** A pwd command is often used without options and never used with arguments.
**Important:** You might have noticed that we are executing the above command as “**/bin/pwd**” and not “**pwd**”.
So whats the difference? Well “**pwd**” alone means shell built-in pwd. Your shell may have different version of pwd. Please refer manual. When we are using **/bin/pwd**, we are calling the binary version of that command. Both the shell and the binary version of command Prints Current Working Directory, though the binary version have more options.
**7.** Print all the locations containing executable named pwd.
avi@tecmint:~$ type -a pwd
pwd is a shell builtin
pwd is /bin/pwd
![Print Executable Locations](http://www.tecmint.com/wp-content/uploads/2014/11/Print-Executable-Locations.gif)
Print Executable Locations
**8.** Store the value of “**pwd**” command in variable (say **a**), and print its value from the variable (important for shell scripting perspective).
avi@tecmint:~$ a=$(pwd)
avi@tecmint:~$ echo "Current working directory is : $a"
Current working directory is : /home/avi
![Store Pwd Value in Variable](http://www.tecmint.com/wp-content/uploads/2014/11/Store-Pwd-Value-in-Variable.gif)
Store Pwd Value in Variable
Alternatively, we can use **printf**, in the above example.
**9.** Change current working directory to anything (say **/home**) and display it in command line prompt. Execute a command (say **ls**) to verify is everything is **OK**.
avi@tecmint:~$ cd /home
avi@tecmint:~$ PS1='$pwd> ' [Notice single quotes in the example]
> ls
![Change Current Working Directory](http://www.tecmint.com/wp-content/uploads/2014/11/Change-Current-Working-Directory.gif)
Change Current Working Directory
**10.** Set multi-line command line prompt (say something like below).
/home
123#Hello#!
And then execute a command (say **ls**) to check is everything is **OK**.
avi@tecmint:~$ PS1='
> $PWD
$ 123#Hello#!
$ '
/home
123#Hello#!
![Set Multi Commandline Prompt](http://www.tecmint.com/wp-content/uploads/2014/11/Set-Multi-Commandline-Prompt.gif)
Set Multi Commandline Prompt
**11.** Check the current working directory and previous working directory in one GO!
avi@tecmint:~$ echo “$PWD $OLDPWD”
/home /home/avi
![Check Present Previous Working Directory](http://www.tecmint.com/wp-content/uploads/2014/11/Check-Present-Previous-Working-Directory.gif)
Check Present Previous Working Directory
**12.** What is the absolute path (starting from **/**) of the pwd binary file.
/bin/pwd
**13.** What is the absolute path (starting from **/**) of the pwd source file.
/usr/include/pwd.h
**14.** Print the absolute path (starting from **/**) of the pwd manual pages file.
/usr/share/man/man1/pwd.1.gz
**15.** Write a shell script analyses current directory (say **tecmint**) in your home directory. If you are under directory **tecmint** it output “**Well! You are in tecmint directory**” and then print “**Good Bye**” else create a directory **tecmint** under your home directory and ask you to cd to it.
Lets first create a tecmint directory, under it create a following shell script file with name pwd.sh.
avi@tecmint:~$ mkdir tecmint
avi@tecmint:~$ cd tecmint
avi@tecmint:~$ nano pwd.sh
Next, add the following script to the pwd.sh file.
#!/bin/bash
x="$(pwd)"
if [ "$x" == "/home/$USER/tecmint" ]
then
{
echo "Well you are in tecmint directory"
echo "Good Bye"
}
else
{
mkdir /home/$USER/tecmint
echo "Created Directory tecmint you may now cd to it"
}
fi
Give execute permission and run it.
avi@tecmint:~$ chmod 755 pwd.sh
avi@tecmint:~$ ./pwd.sh
Well you are in tecmint directory
Good Bye
#### Conclusion ####
**pwd** is one of the simplest yet most popular and most widely used command. A good command over pwd is basic to use Linux terminal. Thats all for now. Ill be here again with another interesting article soon, till then stay tuned and connected to Tecmint.
--------------------------------------------------------------------------------
via: http://www.tecmint.com/pwd-command-examples/
作者:[Avishek Kumar][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.tecmint.com/author/avishek/

View File

@ -0,0 +1,188 @@
Important 10 Linux ps command Practical Examples
================================================================================
As an Operating System which inspired from Unix, Linux has a built-in tool to capture current processes on the system. This tool is available in command line interface.
### What is PS Command ###
From its manual page, PS gives a snapshots of the current process. It will “capture” the system condition at a single time. If you want to have a repetitive updates in a real time, we can use top command.
PS support three (3) type of usage syntax style.
1. UNIX style, which may be grouped and **must** be preceded by a dash
2. BSD style, which may be grouped and **must not be** used with a dash
3. GNU long options, which are preceded by two dash
We can mix those style, but conflicts can appear. In this article, will use UNIX style. Heres are some examples of PS command in a daily use.
### 1. Run ps without any options ###
This is a very basic **ps** usage. Just type ps on your console to see its result.
![ps with no options](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_no_options.png)
By default, it will show us 4 columns of information.
- PID is a Process ID of the running command (CMD)
- TTY is a place where the running command runs
- TIME tell about how much time is used by CPU while running the command
- CMD is a command that run as current process
This information is displayed in unsorted result.
### 2. Show all current processes ###
To do this, we can use **-a** options. As we can guess, **-a is stand for “all”**. While x will show all process even the current process is not associated with any TTY (terminal)
$ ps -ax
This result might be long result. To make it more easier to read, combine it with less command.
$ ps -ax | less
![ps all information](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_ax.png)
### 3. Filter processes by its user ###
For some situation we may want to filter processes by user. To do this, we can use **-u** option. Let say we want to see what processes which run by user pungki. So the command will be like below
$ ps -u pungki
![filter by user](http://blog.linoxide.com/wp-content/uploads/2014/10/ps__u.png)
### 4. Filter processes by CPU or memory usage ###
Another thing that you might want to see is filter the result by CPU or memory usage. With this, you can grab information about which processes that consume your resource. To do this, we can use **aux options**. Heres an example of it :
$ ps -aux | less
![show all information](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_aux.png)
Since the result can be in a long list, we can **pipe** less command into ps command.
By default, the result will be in unsorted form. If we want to sort by particular column, we can add **--sort** option into ps command.
Sort by the highest **CPU utilization** in ascending order
$ ps -aux --sort -pcpu | less
![sort by cpu usage](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_aux_sort_cpu.png)
Sort by the highest **Memory utilization** in ascending order
$ ps -aux --sort -pmem | less
![sort by memory usage](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_aux_sort_mem.png)
Or we can combine itu a single command and display only the top ten of the result :
$ ps -aux --sort -pcpu,+pmem | head -n 10
### 5. Filter processes by its name or process ID ###
To to this, we can use **-C option** followed by the keyword. Let say, we want to show processes named getty. We can type :
$ ps -C getty
![filter by its name or process ID](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_C.png)
If we want to show more detail about the result, we can add -f option to show it on full format listing. The above command will looks like below :
$ ps -f -C getty
![filter by its name or process ID](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_C_f.png)
### 6. Filter processes by thread of process ###
If we need to know the thread of a particular process, we can use **-L option** followed by its Process ID (PID). Heres an example of **-L option** in action :
$ ps -L 1213
![show processes in threaded view](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_L.png)
As we can see, the PID remain the same value, but the LWP which shows numbers of thread show different values.
### 7. Show processes in hierarchy ###
Sometime we want to see the processes in hierarchical form. To do this, we can use **-axjf** options.
$ps -axjf
![show in hierarchy](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_axjf.png)
Or, another command which we can use is pstree.
$ pstree
![show information in hierarchy](http://blog.linoxide.com/wp-content/uploads/2014/10/pstree.png)
### 8. Show security information ###
If we want to see who is currently logged on into your server, we can see it using the ps command. There are some options that we can use to fulfill our needs. Heres some examples :
$ ps -eo pid,user,args
**Option -e** will show you all processes while **-o option** will control the output. **Pid**, **User and Args** will show you the **Process ID**, **the User who run the application** and **the running application**.
![show security information](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_security_1.png)
The keyword / user-defined format that can be used with **-e option** are **args, cmd, comm, command, fname, ucmd, ucomm, lstart, bsdstart and start**.
### 9. Show every process running as root (real & effecitve ID) in user format ###
System admin may want to see what processes are being run by root and other information related to it. Using ps command, we can do by this simple command :
$ ps -U root -u root u
The **-U parameter** will select by **real user ID (RUID)**. It selects the processes whose real user name or ID is in the userlist list. The real User ID identifies the user who created the process.
While the **-u paramater** will select by effective user ID (EUID)
The last **u** paramater, will display the output in user-oriented format which contains **User, PID, %CPU, %MEM, VSZ, RSS, TTY, STAT, START, TIME and COMMAND** columns.
Heres the output of the above command.
![show real and effective User ID](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_root_real_effective_ID.png)
### 10. Use PS in a realtime process viewer ###
ps will display a report of what happens in your system. The result will be a static report.
Let say, we want to filter processes by CPU and Memory usage as on the point 4 above. And we want the report is updated every 1 second. We can do it by **combining ps command with watch command** on Linux.
Heres the command :
$ watch -n 1 ps -aux --sort -pmem, -pcpu
![combine ps with watch](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_watch_1.png)
If you feel the report is too long, **we can limit it** by - let say - the top 20 processes. We can add **head** command to do it.
$ watch -n 1 ps -aux --sort -pmem, -pcpu | head 20
![combine ps with watch](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_watch_2.png)
This live reporter **is not** like top or htop of course. **But the advantage of using ps** to make live report is that you can custom the field. You can choose which field you want to see.
For example, **if you need only the pungki user shown**, then you can change the command to become like this :
$ watch -n 1 ps -aux -U pungki u --sort -pmem, -pcpu | head 20
![combine ps with watch](http://blog.linoxide.com/wp-content/uploads/2014/10/ps_watch_3.png)
### Conclusion ###
You may use **ps** on your daily usage to monitor about what happens your Linux system. But actually, you can generate various types of report using **ps** command with the use of appropriate paramaters.
**Another ps advantage** is that **ps** are installed by default in any kind of Linux. So you can just start to use it.
Don't forget to see **ps documentation** by typing **man ps** on you Linux console to explore more options.
--------------------------------------------------------------------------------
via: http://linoxide.com/how-tos/linux-ps-command-examples/
作者:[Pungki Arianto][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/pungki/

View File

@ -0,0 +1,110 @@
Linux blkid Command to Find Block Devices Details
================================================================================
Today we will show you how to use **lsblk** and **blkid** utilities to find out information about block devices and we are using a CentOS 7.0 installed machine.
**lsblk** is a Linux utility that will display information about all the available block devices on your system. It reads and gathers from them from [the sysfs filesystem][1]. The utility will display information about all block devices (with the exception of RAM disks) in a tree-like format by default.
### Lsblk default output ###
By default lsblk will display a tree-like format of the block devices:
**NAME**
the device name
**MAJ:MIN**
- Every device on a Linux operating system is represented by a file, for block (disk) devices, they describe the device using major and minor device numbers.
**RM**
removable device shows 1 if this is a removable device and 0 if its not
**TYPE**
the device type
**MOUNTPOINT**
- the location where the device is mounted
**RO**
it will display 1 for read-only filesystems and 0 for those that are not read-only
**SIZE**
the size of the device
![](http://blog.linoxide.com/wp-content/uploads/2014/10/lsblk.jpg)
### Display the owner of the devices ###
To display information about the owenership of the device, the user and group that own the file and the mode that the filesystem has been mounted with you can use the m option like this:
lsblk m
![](http://blog.linoxide.com/wp-content/uploads/2014/10/lsblk-m.jpg)
### List the device blocks ###
If you wish to just list the devices and not show them as a tree you can use the l option:
lsblk l
### Use in scripts ###
Advanced tip: if you wish to use this in a script and dont want to have the heading displayed you can use the n flag like so:
lsblk ln
![](http://blog.linoxide.com/wp-content/uploads/2014/10/lsblk-ln.jpg)
The **blkid** program is a command-line utility that displays information about available block devices. It can determine the type of content (e.g. filesystem, swap) a block device holds and also attributes (tokens, NAME=value pairs) from the content metadata (e.g. LABEL or UUID fields). It has two main forms of operation: either searching for a device with a specific NAME=value pair or displaying NAME=value pairs for one or more devices.
### blkid usage ###
Simply running blkid without any argument will list all the available devices with their Universally Unique Identifier (UUID), the TYPE of the file-system and the LABEL if it's set.
# blkid
![](http://blog.linoxide.com/wp-content/uploads/2014/10/blkid.jpg)
### Listing devices based on name or UUID ###
If you wish to have information displayed only for a specific device you can use the device name as an option after blkid to do so:
# blkid /dev/sda1
Also if you know the UUID of a device but don't know the device name and wish to find it out you can use the 0-U option like this:
# blkid -U d3b1dcc2-e3b0-45b0-b703-d6d0d360e524
![](http://blog.linoxide.com/wp-content/uploads/2014/10/blkid-uuid.jpg)
### Detailed information ###
If you wish to obtain mode detailed information you can use the -p and -o udev option to have it display in a nice format like this:
# blkid -po udev /dev/sda1
![](http://blog.linoxide.com/wp-content/uploads/2014/10/blkid-po.jpg)
### Reset cache ###
Sometimes the device list might not be updated, if you think this is the case you can use the -g option that will perform a garbage collection pass on the blkid cache to remove devices which no longer exist.
# blkid -g
--------------------------------------------------------------------------------
via: http://linoxide.com/linux-command/linux-command-lsblk-blkid/
作者:[Adrian Dinu][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://linoxide.com/author/adriand/
[1]:https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt

View File

@ -0,0 +1,129 @@
How to install Cacti (Monitoring tool) on ubuntu 14.10 server
================================================================================
Cacti is a complete network graphing solution designed to harness the power of RRDTool's data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive, easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices.
### Features ###
#### Graphs ####
Unlimited number of graph items can be defined for each graph optionally utilizing CDEFs or data sources from within cacti.
Automatic grouping of GPRINT graph items to AREA, STACK, and LINE[1-3] to allow for quick re-sequencing of graph items.
Auto-Padding support to make sure graph legend text lines up.
Graph data can be manipulated using the CDEF math functions built into RRDTool. These CDEF functions can be defined in cacti and can be used globally on each graph.
Support for all of RRDTool's graph item types including AREA, STACK, LINE[1-3], GPRINT, COMMENT, VRULE, and HRULE.
#### Data Sources ####
Data sources can be created that utilize RRDTool's "create" and "update" functions. Each data source can be used to gather local or remote data and placed on a graph.
Supports RRD files with more than one data source and can use an RRD file stored anywhere on the local file system.
Round robin archive (RRA) settings can be customized giving the user the ability to gather data on non-standard timespans while store varying amounts of data.
#### Data Gathering ####
Contains a "data input" mechanism which allows users to define custom scripts that can be used to gather data. Each script can contain arguments that must be entered for each data source created using the script (such as an IP address).
Built in SNMP support that can use php-snmp, ucd-snmp, or net-snmp.
Ability to retrieve data using SNMP or a script with an index. An example of this would be populating a list with IP interfaces or mounted partitions on a server. Integration with graph templates can be defined to enable one click graph creation for hosts.
A PHP-based poller is provided to execute scripts, retrieve SNMP data, and update your RRD files.
#### Templates ####
Graph templates enable common graphs to be grouped together by templating. Every field for a normal graph can be templated or specified on a per-graph basis.
Data source templates enable common data source types to be grouped together by templating. Every field for a normal data source can be templated or specified on a per-data source basis.
Host templates are a group of graph and data source templates that allow you to define common host types. Upon the creation of a host, it will automatically take on the properties of its template.
#### Graph Display ####
The tree view allows users to create "graph hierarchies" and place graphs on the tree. This is an easy way to manage/organize a large number of graphs.
The list view lists the title of each graph in one large list which links the user to the actual graph.
The preview view displays all of the graphs in one large list format. This is similar to the default view for the 14all cgi script for RRDTool/MRTG.
#### User Management ####
User based management allows administrators to create users and assign different levels of permissions to the cacti interface.
Permissions can be specified per-graph for each user, making cacti suitable for co location situations.
Each user can keep their own graph settings for varying viewing preferences.
#### Preparing your system ####
Before installing cacti you need to make sure you have installed [Ubuntu 14.10 LAMP server][1].
#### Install Cacti on ubuntu 14.10 server ####
Open the terminal and run the following command
sudo apt-get install cacti-spine
The above command starts the cacti installation and you should see the first as php path change select ok and press enter
![](http://www.ubuntugeek.com/wp-content/uploads/2014/01/18.png)
Now select the webserver you want to use (in my case it is apache2)
![](http://www.ubuntugeek.com/wp-content/uploads/2014/01/27.png)
Cacti database configurations select yes
![](http://www.ubuntugeek.com/wp-content/uploads/2014/01/35.png)
Enter database admin user password
![](http://www.ubuntugeek.com/wp-content/uploads/2014/01/42.png)
Mysql application password for cacti
![](http://www.ubuntugeek.com/wp-content/uploads/2014/01/5.png)
confirm the password
![](http://www.ubuntugeek.com/wp-content/uploads/2014/01/6.png)
Now that Cacti is installed, we can start the configuration process on it.
#### Configuring cacti ####
Point your web browser towards http://YOURSERVERIP/cacti/install/ to start the initial setup and click next
![](http://www.ubuntugeek.com/wp-content/uploads/2014/01/7.png)
Select new install option and click next
![](http://www.ubuntugeek.com/wp-content/uploads/2014/01/8.png)
In the following screen you need to make sure you have all the required paths are correct and click on finish
![](http://www.ubuntugeek.com/wp-content/uploads/2014/01/9.png)
Now login to Cacti with the default admin/admin, and change the password to something more sensible
![](http://www.ubuntugeek.com/wp-content/uploads/2014/01/10.png)
![](http://www.ubuntugeek.com/wp-content/uploads/2014/01/111.png)
After login in to Cacti you should see similar to the following screen
![](http://www.ubuntugeek.com/wp-content/uploads/2014/11/14.png)
--------------------------------------------------------------------------------
via: http://www.ubuntugeek.com/how-to-install-cacti-monitoring-tool-on-ubuntu-14-10-server.html
作者:[ruchi][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://www.ubuntugeek.com/author/ubuntufix
[1]:http://www.ubuntugeek.com/www.ubuntugeek.com/step-by-step-ubuntu-14-10-utopic-unicorn-lamp-server-setup.html

View File

@ -0,0 +1,67 @@
Linux FAQs with Answers--How to access a NAT guest from host with VirtualBox
================================================================================
> **Question**: I have a guest VM running on VirtualBox, which uses NAT networking. So the guest VM is getting a private IP address (10.x.x.x) assigned by VirtualBox. If I want to SSH to the guest VM from the host machine, how can I do that?
VirtualBox supports several networking options for guest VMs, one of them being NAT networking. When NAT networking is enabled for a guest VM, VirtualBox automatically performs network address translation between the guest VM and host's network stack, so that you do not have to configure anything on the host machine and local network for the guest VM's networking to work. The implication of such NAT, however, is that the guest VM is not reachable or visible from external networks as well as from the local host itself. This is a problem if you want to access the guest VM from the host machine for some reason (e.g., SSH).
If you want to access a NAT guest from the host on VirtualBox, you can enable port forwarding for VirtualBox NAT, either from the GUI or from the command line. This tutorial demonstrates **how to SSH a NAT guest from the host** by enabling port forwarding for port 22. If you want to access HTTP of a NAT guest instead, replace port 22 with port 80.
### Configure VirtualBox Port Forwarding from the GUI ###
On VirtualBox, choose the guest VM you want to access, and open "Settings" window of the VM. Click on "Network" menu on the left, click on "Advanced" to show additional network adapter options.
![](https://farm8.staticflickr.com/7583/15797904856_2753dc785e_z.jpg)
Click on a button labeled "Port Forwarding."
![](https://farm8.staticflickr.com/7527/15636152708_cf2be7c7e8_z.jpg)
You will see a window where you can configure port forwarding rules. Click on "Add" icon in the upper right corner.
![](https://farm8.staticflickr.com/7489/15636391217_48a9954480_z.jpg)
Add a new port forwarding rule with the following detail.
- **Name**: SSH (any arbitrary unique name)
- **Protocol**: TCP
- **Host IP**: 127.0.0.1
- **Host Port**: 2222 (any unused port higher than 1024)
- **Guest IP**: IP address of the guest VM
- **Guest Port**: 22 (SSH port)
![](https://farm6.staticflickr.com/5603/15202135853_02a07c3212_o.png)
Port forwarding configured for the guest VM will be enabled automatically when you power on the guest VM. For verification, check that port 2222 is opened by VirtualBox after you launch the guest VM:
$ sudo netstat -nap | grep 2222
![](https://farm8.staticflickr.com/7461/15819682411_6bb9707f8a_z.jpg)
Now that port forwarding is in place, you can SSH to the guest VM bs follows.
$ ssh -p 2222 <login>@127.0.0.1
An SSH login request sent to 127.0.0.1:2222 will automatically be translated into 10.0.2.15:22 by VirtualBox, allowing you to SSH to the guest VM.
### Configure VirtualBox Port Forwarding from the Command Line ###
VirtualBox comes with a command-line management interface called VBoxManage. Using this command-line tool, you can also set up port forwarding for your guest VM.
The following command creates a port forwarding rule for guest VM named "centos7" with IP address 10.0.2.15 and SSH port 22, mapped to local host at port 2222. The name of the rule ("SSH" in this example) must be unique.
$ VBoxManage modifyvm "centos7" --natpf1 "SSH,tcp,127.0.0.1,2222,10.0.2.15,22"
Once the rule is created, you can verify that by using the command below.
$ VBoxManage showvminfo "centos7" | grep NIC
![](https://farm8.staticflickr.com/7559/15636458427_7a0959900c_z.jpg)
--------------------------------------------------------------------------------
via: http://ask.xmodulo.com/access-nat-guest-from-host-virtualbox.html
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出

View File

@ -0,0 +1,54 @@
Linux FAQs with Answers--How to check glibc version on Linux
================================================================================
> **Question**: I need to find out the version of the GNU C library (glibc) that I have on my Linux system. How can I check glibc version on Linux?
The GNU C library (glibc) is the GNU implementation of the standard C library. glibc is a critical component of the GNU toolchain, which is used along with binutils and compiler to generate userspace application binaries for a target architecture.
When built from source, some Linux programs may be required to link against a particular version of glibc. In that case, you may want to check out the information about installed glibc to see if dependencies are met.
Here are simple ways to check glibc version on Linux.
### Method One ###
A simple command-line to check the version of the GNU C library is as follows.
$ ldd --version
![](https://farm6.staticflickr.com/5613/15631104658_940163834a_z.jpg)
In this example, the version of **glibc is 2.19**.
### Method Two ###
Another method is to "type" the **glibc library** (i.e., libc.so.6) from the command line as if it were a command.
The output will show more detailed information about **glibc library**, including the version of glibc and the GNU compiler used, as well as available glibc extensions. The location of glibc varies depending on distros and processor architectures.
On 64-bit Debian based system:
$ /lib/x86_64-linux-gnu/libc.so.6
on 32-bit Debian based system:
$ /lib/i386-linux-gnu/libc.so.6
On 64-bit Red Hat based system:
$ /lib64/libc.so.6
On 32-bit Red Hat based systems:
$ /lib/libc.so.6
Here is the sample output of typing glibc library.
![](https://farm8.staticflickr.com/7516/15631334667_ef50b247a4_z.jpg)
--------------------------------------------------------------------------------
via: http://ask.xmodulo.com/check-glibc-version-linux.html
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出

View File

@ -0,0 +1,40 @@
Linux FAQs with Answers--How to fix “ImportError: No module named scapy.all”
================================================================================
> **Question**: When I run a Python application, I am getting "ImportError: No module named scapy.all" message. How can I fix this import error?
[Scapy][1] is a flexible packet generation and sniffer program written in Python. Using Scapy, you can create arbitrary packets, send them to the wire, reading packets from the wire or a dump file, transform packets, etc. Using Scapy's generic packet manipulation capabilities, you can easily do things like SYN scan, TCP traceroute, and OS fingerprinting. You can also integrate Scapy into another tool by importing it.
The import error indicates that you do not have Scapy installed on your Linux system. Here is how to install Scapy on Linux.
### Install Scapy on Debian, Ubuntu or Linux Mint ###
$ sudo apt-get install python-scapy
### Install Scapy on Fedora or CentOS/RHEL ###
On CentOS/RHEL, you need to [enable EPEL repository][2] first.
$ sudo yum install scapy
### Install Scapy from the Source ###
If your Linux distribution does not offer Scapy package or you want to try the latest Scapy, you can install Scapy manually from the source.
Download the [latest version of Scapy][3], and install it as follows.
$ unzip scapy-latest.zip
$ cd scapy-2.*
$ sudo python setup.py install
--------------------------------------------------------------------------------
via: http://ask.xmodulo.com/importerror-no-module-named-scapy-all.html
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[1]:http://www.secdev.org/projects/scapy/
[2]:http://xmodulo.com/how-to-set-up-epel-repository-on-centos.html
[3]:http://scapy.net/

View File

@ -4,7 +4,7 @@ Ubuntu也许能在中国给Windows以致命打击
**Windows操作系统将退出中国的前门而它的位置将由一个Linux发行版替代用于官方和政府部门。问题是目前还没有一个真正的可替代系统尽管还是有一款操作系统也许已经准备接下这个任务它就是Ubuntu Kylin。**
至少可以这么说,中国政府和微软目前的关系很紧张。[就像今天新闻里说的][1]一个用Linux类似系统在全国逐步替换Windows的计划已经在准备了。还不清楚具体会采用哪个系统因为情况很复杂而且这是一个非常大的国家。
至少可以这么说,中国政府和微软目前的关系很紧张。[就像新闻里说的][1]一个用Linux类似系统在全国逐步替换Windows的计划已经在准备了。还不清楚具体会采用哪个系统因为情况很复杂而且这是一个非常大的国家。
通常这种问题没有一个普适的解决方案而且中国的行动确实看起来有点呆板。不管怎样这为Ubuntu Keylin打开了一扇巨大的机会之窗它是一个基于Ubuntu由中国开发者和Canonical共同开发的发行版。它已经稳定一段时间了而且已经发布了几个连续版本。
@ -12,13 +12,13 @@ Ubuntu也许能在中国给Windows以致命打击
有趣的是在这个关于中国意图的新闻冒出来的同一天里发布了一篇对国防科技大学NUDT副教授Dr. Jonas Zhang的采访关于[最新的14.10分支开发计划][2]。
“在这次的14.10版本中有许多很好的功能。比如新手也可以轻松地通过Ubuntu Kylin软件中心找到Windows软件的替代用户可以使用Ubuntu Kylin的SSOUbuntu Kylin的单一登录系统我们叫它UKID来登到Ubuntu Kylin的软件和社区Sogou输入法一款世界知名的中文输入法上个月已经在苹果的应用市场上线了减少了40%的CPU和内存占用。”
“在这次的14.10版本中有许多很好的功能。比如新手也可以轻松地通过Ubuntu Kylin软件中心找到Windows软件的替代用户可以使用Ubuntu Kylin的SSOUbuntu Kylin的单一登录系统我们叫它UKID来登到Ubuntu Kylin的软件和社区Sogou输入法一款世界知名的中文输入法上个月已经在苹果的应用市场上线了减少了40%的CPU和内存占用。”
“来自CSIP中国政府的一个部门Canonical和NUDT国防科技大学的超过50个项目经理工程师和社区管理员在为Ubuntu Kylin工作。大部分全职工程师来自NUDT。许多来自UbuntuDebian和其他社区的开发者也参与到Ubuntu Kylin的开发中了。”Dr. Jonas Zhang[说][2]。
“来自CSIP中国政府的一个部门超过50个 Canonical 和 NUDT国防科技大学的项目经理、工程师和社区管理员在为 Ubuntu Kylin 工作。大部分全职工程师来自NUDT。许多来自UbuntuDebian和其他社区的开发者也参与到Ubuntu Kylin的开发中了。”Dr. Jonas Zhang[说][2]。
中国政府也许自己也正想办法搭建另一个Linux发行版不是第一次尝试了但是目前看来已经有一个很好的用来替代Windows的候选者了。这对于Canonical也是很好的商机至少从被承认这个角度看。
如果Ubuntu通过它和Kylin的联系想在像中国这样一个大国里取代Windows对这家公司是巨大的促进。让我们拭目以待开发者们让Ubuntu Kylin变成一个有竞争力的操作系统的努力是不是白费力气。
如果Ubuntu通过它和Kylin的联系想在像中国这样的大国里取代Windows对这家公司将会是个巨大的促进。让我们拭目以待看看开发者们让Ubuntu Kylin变成一个有竞争力的操作系统所花费的努力是不是白费力气。
--------------------------------------------------------------------------------
@ -26,7 +26,7 @@ via: http://news.softpedia.com/news/Ubuntu-Could-Give-a-Fatal-Blow-to-Windows-in
作者:[Silviu Stahie][a]
译者:[zpl1025](https://github.com/zpl1025)
校对:[校对者ID](https://github.com/校对者ID)
校对:[Caroline](https://github.com/carolinewuyan)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出

View File

@ -0,0 +1,75 @@
安卓编年史
================================================================================
![新版安卓市场——黑色比重减少,白色和绿色增多。](http://cdn.arstechnica.net/wp-content/uploads/2013/12/marketab2.png)
新版安卓市场——黑色比重减少,白色和绿色增多。
Ron Amadeo供图
###安卓1.6Donut——CDMA支持将安卓带给了各个运营商###
安卓的第四个版本——1.6甜甜圈——在2009年9月发布这时是在纸杯蛋糕面世的5个月后。尽管有无数更新谷歌仍然在给安卓添加基本的功能。甜甜圈带来了对不同屏幕尺寸和CDMA的支持还有一个文本语音转换引擎。
安卓1.6是个很好的更新例子要在今天的话它将没什么理由作为一个独立更新存在。主要的改进基本上可以总结为新版安卓市场相机以及YouTube。从这一年起像这样的应用已经从系统分离开来并且谷歌任何时候都能升级它们。然而在完成所有的这些模块化功能工作之前看起来甚至是一个微小的应用更新似乎都需要完整的系统更新。
另一个重大改进——CDMA支持——也表明了除了版本号之外谷歌仍然在忙于将基本功能带到安卓上来。
安卓市场被标注为版本“1.6”,并且得到了一个彻底的改进。原本的全黑设计被抛弃,转向带有绿色高亮的白色应用设计——安卓的设计师很明显使用了安卓吉祥物来获得灵感。
新的市场对谷歌来说一定是个新的应用设计风格。屏幕顶部的五分之一用于显示横幅logo表明了这个应用确实是“安卓市场”。在横幅之下是应用游戏以及下载按钮一个搜索按钮被安置在横幅的右侧。在导航键下面显示这特色应用的快照可以在它们之间滑动。再下面是个垂直滚动列表显示了更多的特色应用。
![新的市场设计,展示了:带有截图的应用页面,应用分类页面,应用榜,下载。](http://cdn.arstechnica.net/wp-content/uploads/2013/12/marketpages.png)
新的市场设计,展示了:带有截图的应用页面,应用分类页面,应用榜,下载。
Ron Amadeo供图
市场最大的新增内容是包含应用截图。安卓用户终于可以在安装之前看到应用长什么样子——之前他们只能看到简短的描述和用户评论。你的个人星级评价和评论被放在显著位置,随后是描述,最后是截图。查看截图常常需要一点点滚动来查看——如果你想要找个设计尚佳的应用,那可要费一番功夫了。
点击应用或游戏按钮会打开一个分类列表就像你在上面第二张图看到的那样。选择一个类别之后更多的导航显示在了屏幕顶部用户可以看到“热门付费”“热门免费”或“热门新品”分类里看到各自的应用。尽管这些看起来像是会加载出新页面的按钮实际上它们仅仅是个笨拙的标签页。每个按钮边有个绿色小灯指示现在哪个标签处于活跃状态。这个界面最赞的地方是应用列表是无穷滚动的滚动加载——一旦你到达列表底部的时候它将加载更多应用。这个特性使得查看应用列表变得轻松但是你点开任意一个应用再返回的话将会丢失你在列表里的位置——你得从头开始查看。下载部分可以做一些连新的Google Play商店都做不到的事不过是显示一个已购买应用列表而已。
尽管新的市场看起来无疑比旧的好多了,但应用间的一致性更糟糕了。看起来就像是每个应用都是由不同团队制作的,但他们之间从没沟通过所有的安卓应用应该有的样子。
![相机取景窗,照片回看界面,菜单。](http://cdn.arstechnica.net/wp-content/uploads/2013/12/device-2013-12-27-145949.png)
相机取景窗,照片回看界面,菜单。
Ron Amadeo供图
举个例子,相机应用从全屏,最小化设计变成一个盒状的边缘带控制的取景窗。在相机应用中,谷歌着手引入拟物化,将应用包装成一个大致复刻皮革纹经典相机的样子。在相机和摄像机之间切换通过一个缺乏想象力的开关完成,下面是个触摸快门按钮。
点击最近照片快照不再会打开相册,但一个定制的照片查看器内建在了相机应用内。当你查看照片的时候,皮革质感的控制区从相机操作键变成图片操作键,你可以在这里删除,共享照片,或者把照片设置成壁纸或联系人图像。这里图片之间依然没有滑动操作——切换照片还是要通过照片两侧的箭头按钮完成。
第二张截图展示的是设计师减少对菜单按钮依赖的例子之一,因为安卓团队慢慢开始意识到其在可发现性上的糟糕表现。许多的应用设计者(包括那些在谷歌的)使用菜单作为所有种类的控制和导航元素的集中处。但大多数用户没想过点击菜单按钮,也从没看到这些指令。
未来版本的安卓的共有主题会将选项从菜单移到主要屏幕上使得整个系统对用户更加友好。菜单按钮在安卓4.0中被完全移除,并且它只在传统应用中被支持。
![电池以及文本语音转换引擎设置。](http://cdn.arstechnica.net/wp-content/uploads/2013/12/settings1.png)
电池以及文本语音转换引擎设置。
Ron Amadeo供图
甜甜圈是第一个持续追踪电池使用量的安卓版本。在“关于手机”菜单里有个选项“电池使用”,它会以百分比的方式显示应用以及硬件功能的电池用量。点击一项会打开一个单独的相关状态页面。硬件项目有个按钮可以直接跳转到它们的设置界面,所以,举个例子,如果你觉得显示的电池用量太高你可以更改显示的屏幕超时。
安卓1.6同样是第一个支持文本语音转换引擎(TTS)的版本这意味着系统以及应用能够用机器合成声音来回应你。“语音合成器”选项允许你设置语言选择语速以及从安卓市场安装语音数据慎重。今天谷歌在安卓上部署它自己的TTS引擎但是似乎甜甜圈是通过硬编码的方式使用了来自SVOX的TTS引擎。但SVOX的引擎并未部署在甜甜圈上所以点击“安装语音数据”会链接到安卓市场的一个应用。甜甜圈的全盛期几年后这个应用已被撤下。看起来似乎安卓1.6再也不能说话了。)
![从左到右:新的小部件,搜索栏界面,新清除通知按钮,新相册控件。](http://cdn.arstechnica.net/wp-content/uploads/2013/12/grabbag16.png)
从左到右:新的小部件,搜索栏界面,新清除通知按钮,新相册控件。
Ron Amadeo供图
前端小部件部分花了更多的功夫。甜甜圈带来了全新的叫做“电量控制”小部件。它包含了常见耗电功能的开关Wi-Fi蓝牙GPS同步同谷歌服务器之间以及亮度。
搜索小部件同样经过了重新设计,变得更加纤细,并且内置了一个麦克风按钮用于语音搜索。它现在有了些实质界面并且够实时搜索,不仅仅是搜索互联网,还能搜索你的应用和历史。
“清除通知”按钮大幅缩水并且去掉了“通知”字样。在稍晚些的安卓后续版本总它还会缩减成仅仅是个方形按钮。相册继续遵循了把功能从菜单里拿出来的趋势,并且将它们放在用户面前——单张图片查看界面得到了“设置为”,“分享”,以及“删除”按钮。
----------
![Ron Amadeo](http://cdn.arstechnica.net/wp-content//uploads/authors/ron-amadeo-sq.jpg)
[Ron Amadeo][a] / Ron是Ars Technica的评论编缉专注于安卓系统和谷歌产品。他总是在追寻新鲜事物还喜欢拆解事物看看它们到底是怎么运作的。
[@RonAmadeo][t]
--------------------------------------------------------------------------------
via: http://arstechnica.com/gadgets/2014/06/building-android-a-40000-word-history-of-googles-mobile-os/9/
译者:[alim0x](https://github.com/alim0x) 校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
[a]:http://arstechnica.com/author/ronamadeo
[t]:https://twitter.com/RonAmadeo