mirror of
https://github.com/LCTT/TranslateProject.git
synced 2026-08-23 04:03:29 +08:00
@@ -1,18 +1,18 @@
|
||||
在CentOS上配置主机入侵检测系统
|
||||
在CentOS上配置基于主机的入侵检测系统(IDS)
|
||||
================================================================================
|
||||
所有系统管理员想要在他们生产服务器上部署的第一个安全手段之一,就是检测文件篡改的机制——不仅仅是文件内容,而且也包括它们的属性。
|
||||
所有系统管理员想要在他们生产服务器上首先要部署的安全手段之一,就是检测文件篡改的机制——不仅仅是文件内容,而且也包括它们的属性。
|
||||
|
||||
[AIDE][1] (“高级入侵检测环境”的简称)是一个开源的基于主机的入侵检测系统。AIDE通过检查大量文件属性的不一致性来检查系统二进制文件和基本配置文件的完整性,这些文件属性包括权限、文件类型、索引节点、链接数、链接名、用户、组、文件大小、块计数、修改时间、添加时间、创建时间、acl、SELinux安全上下文、xattrs,以及md5/sha校验和在内。
|
||||
[AIDE][1] (“高级入侵检测环境”的简称)是一个开源的基于主机的入侵检测系统。AIDE通过检查大量文件属性的不一致性来检查系统二进制文件和基本配置文件的完整性,这些文件属性包括权限、文件类型、索引节点、链接数、链接名、用户、组、文件大小、块计数、修改时间、添加时间、创建时间、acl、SELinux安全上下文、xattrs,以及md5/sha校验值在内的各种特征。
|
||||
|
||||
AIDE通过扫描一台(未被篡改)的Linux服务器的文件系统来构建文件属性数据库,以后将服务器文件属性与数据库中的进行校对,然后在服务器运行时对修改过的索引的文件发出警告。处于这个原因,AIDE必须在系统更新后或其配置文件进行合法修改后重新对受保护的文件做索引。
|
||||
AIDE通过扫描一台(未被篡改)的Linux服务器的文件系统来构建文件属性数据库,以后将服务器文件属性与数据库中的进行校对,然后在服务器运行时对被修改的索引了的文件发出警告。出于这个原因,AIDE必须在系统更新后或其配置文件进行合法修改后重新对受保护的文件做索引。
|
||||
|
||||
对于某些客户,他们可能会根据他们的安全策略在他们的服务器上强制安装某种入侵检测系统。但是,不管客户是否要求,系统管理员都部署一个入侵检测系统,这通常是一个很好的做法。
|
||||
对于某些客户,他们可能会根据他们的安全策略在他们的服务器上强制安装某种入侵检测系统。但是,不管客户是否要求,系统管理员都应该部署一个入侵检测系统,这通常是一个很好的做法。
|
||||
|
||||
### 安装AIDE到CentOS或RHEL ###
|
||||
### 在 CentOS或RHEL 上安装AIDE ###
|
||||
|
||||
AIDE的初始安装(同时是首次运行)最好是在系统刚安装完后,并且没有任何服务暴露在互联网,甚至是局域网中。在这个早期阶段,我们可以将来自外部的一切闯入和破坏风险降到最低限度。事实上,这也是确保系统在AIDE构建其初始数据库时保持干净的唯一途径。
|
||||
AIDE的初始安装(同时是首次运行)最好是在系统刚安装完后,并且没有任何服务暴露在互联网甚至局域网时。在这个早期阶段,我们可以将来自外部的一切闯入和破坏风险降到最低限度。事实上,这也是确保系统在AIDE构建其初始数据库时保持干净的唯一途径。(LCTT 译注:当然,如果你的安装源本身就存在安全隐患,则无法建立可信的数据记录)
|
||||
|
||||
出于上面的原因,在安装完AIDE后,我们可以执行下面的命令:
|
||||
出于上面的原因,在安装完系统后,我们可以执行下面的命令安装AIDE:
|
||||
|
||||
# yum install aide
|
||||
|
||||
@@ -20,7 +20,7 @@ AIDE的初始安装(同时是首次运行)最好是在系统刚安装完后
|
||||
|
||||
### 配置AIDE ###
|
||||
|
||||
默认配置文件是/etc/aide.conf,该文件介绍了几个示例保护规则(如FIPSR,NORMAL,DIR,DATAONLY),各个规则后面跟着一个等于号以及要检查的文件属性列表,或者某些预定义的规则(由+分隔)。你也可以使用此种格式自定义规则。
|
||||
默认配置文件是/etc/aide.conf,该文件介绍了几个示例保护规则(如FIPSR,NORMAL,DIR,DATAONLY),各个规则后面跟着一个等号以及要检查的文件属性列表,或者某些预定义的规则(由+分隔)。你也可以使用此种格式自定义规则。
|
||||
|
||||

|
||||
|
||||
@@ -35,11 +35,11 @@ AIDE的初始安装(同时是首次运行)最好是在系统刚安装完后
|
||||
|
||||
条目之前的感叹号(!)告诉AIDE忽略子目录(或目录中的文件),对于这些可以另外定义规则。
|
||||
|
||||
在上面的例子中,PERMS是用于/etc机器子目录和文件的默认规则。然而,没有规则将用于/etc中的备份文件(如/etc/.*~),也没有规则用于/etc/mtab文件。对于/etc中的一些选择性的子目录或文件,NORMAL规则会被应用,覆盖默认规则PERMS。
|
||||
在上面的例子中,PERMS是用于/etc机器子目录和文件的默认规则。然而,对于/etc中的备份文件(如/etc/.*~)则不应用任何规则,也没有规则用于/etc/mtab文件。对于/etc中的其它一些选定的子目录或文件,使用NORMAL规则替代默认规则PERMS。
|
||||
|
||||
定义并应用正确的规则到系统中正确的位置,是使用AIDE最难的一部分,但作出好的判断是一个良好的开始。作为首要的一条规则,不要检查不必要的属性。例如,检查/var/log或/var/spool里头的文件的修改时间将导致大量误报,因为许多的应用程序和守护进程经常会写入内容到该位置,而这些内容都没有问题。此外,检查多个校验和可能加强安全性,但随之而来的是AIDE的运行时间的增加。
|
||||
定义并应用正确的规则到系统中正确的位置,是使用AIDE最难的一部分,但作一个好的判断是一个良好的开始。作为首要的一条规则,不要检查不必要的属性。例如,检查/var/log或/var/spool里头的文件的修改时间将导致大量误报,因为许多的应用程序和守护进程经常会写入内容到该位置,而这些内容都没有问题。此外,检查多个校验值可能会加强安全性,但随之而来的是AIDE的运行时间的增加。
|
||||
|
||||
你可以选择将检查结果发送到你的邮箱,如果你使用MAILTO变量指定了电子邮件地址。将下面这一行放到/etc/aide.conf中的任何位置即可。
|
||||
可选的,如果你使用MAILTO变量指定电子邮件地址,就可以将检查结果发送到你的邮箱。将下面这一行放到/etc/aide.conf中的任何位置即可。
|
||||
|
||||
MAILTO=root@localhost
|
||||
|
||||
@@ -51,7 +51,7 @@ AIDE的初始安装(同时是首次运行)最好是在系统刚安装完后
|
||||
|
||||

|
||||
|
||||
根据/etc/aide.conf生成的/var/lib/aide/aide.db.new.gz文件需要被重命名为/var/lib/aide/aide.db.gz,以便AIDE能读取它:
|
||||
根据/etc/aide.conf生成的/var/lib/aide/aide.db.new.gz文件需要被重命名为/var/lib/aide/aide.db.gz,以便AIDE能读取它:
|
||||
|
||||
# mv /var/lib/aide/aide.db.new.gz /var/lib/aide.db.gz
|
||||
|
||||
@@ -67,7 +67,7 @@ AIDE的初始安装(同时是首次运行)最好是在系统刚安装完后
|
||||
|
||||
### 生产环境中管理AIDE ###
|
||||
|
||||
在构建了一个初始AIDE数据库后,作为不断推进的系统管理活动,你常常需要处于某些合法的理由更新受保护的服务器。每次服务器更新后,你必须重新构建AIDE数据库,以更新数据库内容。要完成该任务,请执行以下命令:
|
||||
在构建了一个初始AIDE数据库后,作为不断进行的系统管理活动,你常常需要因为某些合法的理由更新受保护的服务器。每次服务器更新后,你必须重新构建AIDE数据库,以更新数据库内容。要完成该任务,请执行以下命令:
|
||||
|
||||
# aide --update
|
||||
|
||||
@@ -109,7 +109,7 @@ AIDE的初始安装(同时是首次运行)最好是在系统刚安装完后
|
||||
|
||||
### 结尾 ###
|
||||
|
||||
如果你曾经发现你自己有很好的理由相信系统被入侵了,但是第一眼又不能确定到底哪些东西被改动了,那么像AIDE这样一个基于主机的入侵检测系统就会很有帮助了,因为它可以帮助你很快识别出哪些东西被改动过,而不是通过猜测来浪费宝贵的时间。
|
||||
如果你曾经发现你自己有很好的理由确信系统被入侵了,但是第一眼又不能确定到底哪些东西被改动了,那么像AIDE这样一个基于主机的入侵检测系统就会很有帮助了,因为它可以帮助你很快识别出哪些东西被改动过,而不是通过猜测来浪费宝贵的时间。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@@ -117,7 +117,7 @@ via: http://xmodulo.com/host-intrusion-detection-system-centos.html
|
||||
|
||||
作者:[Gabriel Cánepa][a]
|
||||
译者:[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/) 荣誉推出
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
如何加速Debian或Ubuntu上缓慢的apt-get安装
|
||||
===
|
||||
极速蜗牛:apt-fast
|
||||
================
|
||||
|
||||
如果你在Debian或Ubuntu系统上经常感觉到**apt-get** 或 **aptitude**包安装速度过慢,那么这里就有几种改善这一情况的方法。你有没有考虑过改变正被使用的默认镜像站点?你有没有排除因特网连接的上游带宽成为瓶颈的可能?
|
||||
|
||||
没有别的,你可以尝试第三个选择:使用[apt-fast][1]工具。apt-fast实际上是一个围绕apt-get和aptitude所写的shell脚本容器,它能过加速包的下载速度。apt-fast本质上采用[aria2][2]下载工具,这款工具能够以“块”的方式从多个镜像并行下载一个文件(就像BitTorrent下载)。
|
||||
如果不是这些原因,你可以尝试第三个选择:使用[apt-fast][1]工具。apt-fast实际上是一个围绕apt-get和aptitude所写的shell脚本容器,它能加速包的下载速度。apt-fast本质上采用[aria2][2]下载工具,这款工具能够以“块”的方式从多个镜像并行下载一个文件(就像BitTorrent下载)。
|
||||
|
||||
### 在Debian或Ubuntu上安装apt-fast
|
||||
|
||||
@@ -83,7 +83,7 @@ Ubuntu/Mint:
|
||||
|
||||

|
||||
|
||||
如前面所示,apt-fast的并行下载是通过aria2完成的。你可以从下面多个镜像验证并行下载。
|
||||
如前面所示,apt-fast的并行下载是通过aria2完成的。你可以看到如下图般从多个镜像并行下载。
|
||||
|
||||
$ sudo netstat -nap | grep aria2c
|
||||
|
||||
@@ -97,7 +97,7 @@ Ubuntu/Mint:
|
||||
|
||||

|
||||
|
||||
正如你所见到的,**apt-fast**实质上比**apt-get**快(e.g. 快3--4秒),特别是安装庞大软件包的时候。
|
||||
正如你所见到的,**apt-fast**确实比**apt-get**快(e.g. 快3--4秒),特别是安装庞大软件包的时候。
|
||||
|
||||
当然,安装性能的提高程度还依赖你上游因特网连通性。以我为例,我有富足的带宽来支持我的上游连接。这也是为什么我看到并行下载带来了成功的提高。
|
||||
|
||||
@@ -107,7 +107,7 @@ via: http://xmodulo.com/speed-slow-apt-get-install-debian-ubuntu.html
|
||||
|
||||
作者:[Dan Nanni][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/) 荣誉推出
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
Linux有问必答-如何创建和挂载XFS文件系统
|
||||
================================================================================
|
||||
> **问题**: 我听说一个厉害的文件系统XFS,打算在我的磁盘上试试XFS。那格式化和挂载XFS文件系统的Linux命令是什么呢?
|
||||
> **问题**: 我听说一个牛X的文件系统XFS,打算在我的磁盘上试试XFS。那格式化和挂载XFS文件系统的Linux命令是什么呢?
|
||||
|
||||
[XFS][1]是高性能文件系统,SGI为他们的IRIX平台设计。自从2001年移植到Linux内核上,由于它的[高性能][2],XFS作为许多企业级系统的首选,特别是有大量数据,需要结构化伸缩性和稳定性的。例如,RHEL/CentOS 7 和Oracle Linux将XFS作为默认文件系统,SUSE/openSUSE已经为XFS做了长期支持。
|
||||
[XFS][1]是高性能文件系统,SGI为他们的IRIX平台而设计。自从2001年移植到Linux内核上,由于它的[高性能][2],XFS成为了许多企业级系统的首选,特别是有大量数据,需要结构化伸缩性和稳定性的。例如,RHEL/CentOS 7 和Oracle Linux将XFS作为默认文件系统,SUSE/openSUSE已经为XFS做了长期支持。
|
||||
|
||||
XFS有许多独特的功能使他从众多文件系统中脱颖而出,像 伸缩/并行 IO,元数据日志,热整理,暂停/回复 IO,延迟分配等。
|
||||
XFS有许多独特的性能提升功能使他从众多文件系统中脱颖而出,像可伸缩/并行 IO,元数据日志,热碎片整理,IO 暂停/恢复,延迟分配等。
|
||||
|
||||
如果你想要创建和挂载XFS文件系统到你的Linux平台,下面是相关命令。
|
||||
如果你想要创建和挂载XFS文件系统到你的Linux平台,下面是相关的操作命令。
|
||||
|
||||
### 安装 XFS系统工具集 ###
|
||||
|
||||
首先,你需要安装XFS系统工具集,这样允许你执行许多XFS相关的管理任务。(例如,格式化,[扩展][3],修复,设置配额,改变参数等)
|
||||
首先,你需要安装XFS系统工具集,这样允许你执行许多XFS相关的管理任务。(例如:格式化,[扩展][3],修复,设置配额,改变参数等)
|
||||
|
||||
Debian, Ubuntu , Linux Mint系统:
|
||||
|
||||
@@ -34,7 +34,7 @@ Fedora, CentOS, RHEL系统:
|
||||
|
||||
假设此创建的分区叫/dev/sdb1。
|
||||
|
||||
接下来,格式化分区为XFS,使用mkfs.xfs命令。如果已有其他文件系统创建在此分区,必须加上"-f"参数来覆盖它。
|
||||
接下来,格式化分区为XFS,使用mkfs.xfs命令。如果已有其他文件系统创建在此分区,必须加上"-f"参数来覆盖它。
|
||||
|
||||
$ sudo mkfs.xfs -f /dev/sdb1
|
||||
|
||||
@@ -50,7 +50,7 @@ Fedora, CentOS, RHEL系统:
|
||||
|
||||

|
||||
|
||||
如果你想要启动时自动挂载XFS分区在/storage上,加入下行到/etc/fstab:
|
||||
如果你想要启动时自动挂载XFS分区在/storage上,加入下列行到/etc/fstab:
|
||||
|
||||
/dev/sdb1 /storage xfs defaults 0 0
|
||||
|
||||
@@ -59,7 +59,7 @@ Fedora, CentOS, RHEL系统:
|
||||
via: http://ask.xmodulo.com/create-mount-xfs-file-system-linux.html
|
||||
|
||||
译者:[Vic___/VicYu](http://www.vicyul.net/)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
如何从Ubuntu 14.04 LTS 升级到Ubuntu 14.10
|
||||
小白技巧:如何从Ubuntu 14.04 LTS 升级到Ubuntu 14.10
|
||||
================================================================================
|
||||

|
||||
|
||||
@@ -17,7 +17,7 @@ Canonical不会强迫14.04的用户升级到14.10这个中间版本
|
||||
|
||||
切换后你会想快点更新。
|
||||
|
||||
现在准备就绪!Canonical此刻会弹出“升级”提示给用户(想比较普通的ISO镜像而言经常延迟)可以通过软件更新工具更新到14.10了。
|
||||
现在准备就绪!Canonical此刻会弹出“升级”提示给用户(相比较普通的ISO镜像而言经常延迟)可以通过软件更新工具更新到14.10了。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@@ -25,7 +25,7 @@ via: http://www.omgubuntu.co.uk/2014/10/upgrade-ubuntu-14-04-to-14-10
|
||||
|
||||
作者:[Joey-Elijah Sneddon][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/) 荣誉推出
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
Linux有问必答——在CentOS或RHEL防火墙上开启端口
|
||||
Linux有问必答:在CentOS或RHEL防火墙上开启端口
|
||||
================================================================================
|
||||
> **问题**:我在CentOS系统上运行一台网页或文件服务器,打算远程访问服务器。因此,我需要更改防火墙规则以允许访问系统上的某个TCP端口。那么,有什么好方法在CentOS或RHEL系统的防火墙上开启TCP/UDP端口?
|
||||
|
||||
Out of the box,诸如CentOS或RHEL的企业级Linux发行版包含内置的强大防火墙,它们默认的防火墙规则十分严格。因此,如果你安装了任何定制服务(比如web服务器、NFS和Samba),那么它们的流量很有可能被防火墙规则阻塞。所以需要在防火墙上开启必要的端口以允许流量通过。
|
||||
如果希望在服务器上提供服务,诸如CentOS或RHEL的企业级Linux发行版包含内置的强大防火墙,它们默认的防火墙规则十分严格。因此,如果你安装了任何定制的服务(比如web服务器、NFS和Samba),那么它们的流量很有可能被防火墙规则阻塞。所以需要在防火墙上开启必要的端口以允许流量通过。
|
||||
|
||||
在CentOS/RHEL 6或更早的版本上,iptables服务允许用户与netfilter内核模块交互来在用户空间中配置防火墙规则。然而,从CentOS/RHEL 7开始,一个叫做firewalld新用户空间接口被引入以取代iptables服务。
|
||||
|
||||
@@ -16,9 +16,9 @@ Out of the box,诸如CentOS或RHEL的企业级Linux发行版包含内置的强
|
||||
|
||||
### 在CentOS/RHEL 7上开启端口 ###
|
||||
|
||||
启动CentOS或RHEL 7后,防火墙规则设置由firewalld服务进程默认管理。一个叫做firewall-cm的命令行客户端支持和这个守护进程通信以永久修改防火墙规则。
|
||||
启动CentOS/RHEL 7后,防火墙规则设置由firewalld服务进程默认管理。一个叫做firewall-cmd的命令行客户端支持和这个守护进程通信以永久修改防火墙规则。
|
||||
|
||||
使用这些命令来长久打开一个新端口(如TCP/80)。
|
||||
使用这些命令来永久打开一个新端口(如TCP/80)。
|
||||
|
||||
$ sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
|
||||
$ sudo firewall-cmd --reload
|
||||
@@ -42,7 +42,7 @@ Out of the box,诸如CentOS或RHEL的企业级Linux发行版包含内置的强
|
||||
|
||||

|
||||
|
||||
如果想要为任何已知的服务(如web服务器)修改防火墙,只需使防火墙对该服务可用,然后关闭工具。如果想要开启任意一个TCP/UDP端口,选择“Forward”按钮,然后进入下一个界面。
|
||||
如果想要为任何已知的服务(如web服务器)修改防火墙,只需勾选该服务,然后关闭工具。如果想要开启任意一个TCP/UDP端口,选择“Forward”按钮,然后进入下一个界面。
|
||||
|
||||

|
||||
|
||||
@@ -63,6 +63,6 @@ Out of the box,诸如CentOS或RHEL的企业级Linux发行版包含内置的强
|
||||
via: http://ask.xmodulo.com/open-port-firewall-centos-rhel.html
|
||||
|
||||
译者:[KayGuoWhu](https://github.com/KayGuoWhu)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
@@ -1,57 +1,55 @@
|
||||
安卓编年史
|
||||
安卓编年史(1)
|
||||
================================================================================
|
||||
|
||||
> 让我们跟着安卓从0.5版本到4.4的无尽迭代来看看它的发展历史。
|
||||
|
||||

|
||||
这些年来历代安卓的主屏幕。
|
||||
图片提供:Ron Amadeo
|
||||
|
||||
安卓已经以不止一种形式陪伴了我们六年以上。在这段时间内,我们已经看到了不同于任何已有开发周期的,绝对惊人变化速度。当Google卷入智能手机的战场中时,它拿出了它的快速迭代,Web风格的更新周期,把它们应用到了开发的这个操作系统之中,而结果就是突击式的持续改进。近来,安卓项目甚至以前所未闻的六个月开发周期在运行,这可比它之前的开发周期慢。在安卓的第一年商业运作时,Google每两个半月就会发布一个新版本。
|
||||
*这些年来历代安卓的主屏幕* [图片提供:Ron Amadeo]
|
||||
|
||||
注:youtube视频地址开始
|
||||
<iframe width="640" height="480" frameborder="0" src="http://www.youtube-nocookie.com/embed/1FJHYqE0RDg?start=0&wmode=transparent" type="text/html" style="display:block"></iframe>
|
||||
安卓已经以不止一种形式陪伴了我们六年以上。在这段时间内,我们已经看到了不同于任何已有开发周期的,绝对惊人的变化速度。当Google卷入智能手机的战场中时,它拿出了它的快速迭代,Web风格的更新周期,把它们应用到了开发这个操作系统之中,而结果就是突击式的持续改进。近来,安卓项目甚至以前所未闻的六个月开发周期在运行,这可比它之前的开发周期慢。在安卓的第一年商业运作时,Google每两个半月就会发布一个新版本。
|
||||
|
||||
Google在2007年11月时对安卓最初的介绍。
|
||||
注:youtube视频地址结束
|
||||
Google在2007年11月时对安卓最初的介绍:http://www.youtube-nocookie.com/embed/1FJHYqE0RDg?start=0&wmode=transparen (墙外)。
|
||||
|
||||
同行业的其它公司和其相比,只能是以蜗牛的步伐在缓慢前进。微软每三到五年升级它的桌面操作系统,苹果对OS X和iOS以一年为一个更新周期。另外不是每个更新都是同等地位的。iOS在七年内有一个主要的设计上的大变动,而最新的Windows Phone 8看起来和Windows Phone 7十分相似。但在安卓上,如果用户能看到今年的任何东西看起来和去年一样,那简直是中彩票了一样。比如Play商店,五年内有五次的重新设计。对安卓来说那更是家常便饭。
|
||||
同行业的其它公司和之相比,只能是以蜗牛的步伐在缓慢前进。微软每三到五年升级它的桌面操作系统,苹果对OS X和iOS以一年为一个更新周期。另外不是每个更新都是同等地位的。iOS在七年内有一个主要的设计上的大变动,而最新的Windows Phone 8看起来和Windows Phone 7十分相似。但在安卓上,如果用户能看到今年的任何东西看起来和去年一样,那简直是中彩票了一样。比如Play商店,五年内有五次的重新设计。对安卓来说那更是家常便饭。
|
||||
|
||||
回头看看,安卓的存在是很模糊的。从其历史来看,现在它是个使用量巨大的操作系统。近十亿的设备销量,以及每天一百五十万左右的激活量——但Google是如何达到这种地步的?安卓现在如此水平的规模和成功,可能会让你觉得安卓从零开始到万众瞩目的英雄中覆盖到了方方面面。但事实上不是这样的。安卓在早期并不流行,以及直到安卓4.0屏幕截图还只能通过开发者工具实现。这两个因素意味着你无法轻易找到许多安卓早期版本的图片或信息。
|
||||
回头看看,安卓的存在是很模糊的。从其历史来看,现在它是个使用量巨大的操作系统。近十亿的设备销量,以及每天一百五十万左右的激活量——但Google是如何达到这种地步的?安卓现在如此水平的规模和成功,可能会让你觉得安卓从零开始到万众瞩目的英雄,覆盖到了方方面面。但事实上不是这样的。安卓在早期并不流行,以及直到安卓4.0屏幕截图还只能通过开发者工具实现。这两个因素意味着你无法轻易找到许多安卓早期版本的图片或信息。
|
||||
|
||||
对于早期版本的缺乏覆盖问题现在称作*安卓早期版本正在消亡*。尽管像Windows 1.0这样的系统可以永远在你身边——只要找台旧电脑把它装上去就好了——安卓可以被认为是第一个基于云的操作系统。许多功能严重依赖Google的服务来实现。随着越来越少的人使用老版本的安卓,那些服务被逐渐关闭。当一个依赖云的应用其服务支持停止之后,它再也不能正常运作——应用崩溃并显示空白的屏幕,或直接无法启动。
|
||||
|
||||
正是由于这种“[云腐烂][1]”现象,安卓回顾展在几年内不可能出现。早期版本的安卓没有了云的支持会是一个不能正常工作的破碎的空壳。尽管可以简单地认为这是早期版本安卓渐渐消失的一种方法,但这正是正在发生的。就在写到这里的时候,正有无数的应用因为服务器支持被关闭而失去作用。例如早期的谷歌地图和安卓市场客户端,已经不能和Google服务器交互。它们会弹出错误消息并崩溃或者是显示一个空白的界面。有些应用甚至在一个星期正常运行然后下个星期就宣告死亡,因为就在我们写下这篇文章的时候谷歌正在积极地关闭服务器!
|
||||
正是由于这种“[云腐烂][1]”现象,安卓回顾展在几年内不可能出现。早期版本的安卓没有了云的支持会是一个不能正常工作的破碎的空壳。尽管可以简单地认为这是早期版本安卓渐渐消失的一种方法,但这就是正在发生的。就在写到这里的时候,正有无数的应用因为服务器支持被关闭而失去作用。例如早期的谷歌地图和安卓市场客户端,已经不能和Google服务器交互。它们会弹出错误消息并崩溃或者是显示一个空白的界面。有些应用甚至在前一个星期正常运行,然后下个星期就宣告死亡,因为就在我们写下这篇文章的时候谷歌正在积极地关闭服务器!
|
||||
|
||||
为了防止在滚滚历史里丢失掉更多关于安卓的过去,我们做了需要完成的工作。这里有20+个版本的安卓,七台设备,以及无数的屏幕截图被集合到一起。这就是安卓编年史,从最早的公开版本到罪行的KitKat。
|
||||
为了防止在滚滚历史里丢失掉更多关于安卓的过去,我们做了需要完成的工作。这里有20+个版本的安卓,七台设备,以及无数的屏幕截图被集合到一起。这就是安卓编年史,从最早的公开版本到最新的KitKat。
|
||||
|
||||
注:下面一块为文章链接列表,发布后可以改为发布后的地址
|
||||
----------
|
||||
|
||||
### 目录 ###
|
||||
|
||||
(以下各篇正在翻译中,链接会逐步更正过来)
|
||||
|
||||
- [Android 0.5 Milestone 3——第一个公开版本][10]
|
||||
- [Android 0.5 Milestone 5——报废接口的领地][11]
|
||||
- [Android 0.9 Beta——嘿,这看起来很眼熟!][12]
|
||||
- [Android 1.0——谷歌应用的引入和实体硬件][13]
|
||||
- [Android 1.1——第一个真正的增量更新][14]
|
||||
- [Android 1.5 Cupcake——虚拟键盘打开设备设计的大门][15]
|
||||
- ----[谷歌地图———登陆安卓市场的第一个内置应用][16]
|
||||
- ----[谷歌地图———登陆安卓市场的第一个内置应用][16]
|
||||
- [Android 1.6 Donut——CDMA支持将安卓带给了各个运营商][17]
|
||||
- [Android 2.0 Éclair——带动GPS产业][18]
|
||||
- [The Nexus One——迎来Google Phone][19]
|
||||
- [Android 2.1——动画的大发现(以及滥用)时代][20]
|
||||
- ----[Android 2.1, update 1——无尽战争的开端][21]
|
||||
- ----[Android 2.1, update 1——无尽战争的开端][21]
|
||||
- [Android 2.2 Froyo——更快更华丽][22]
|
||||
- ----[语音操作——口袋里的超级电脑][23]
|
||||
- ----[语音操作——口袋里的超级电脑][23]
|
||||
- [Android 2.3 Gingerbread——第一个UI大变][24]
|
||||
- [Android 3.0 Honeycomb——平板和设计的新生][25]
|
||||
- ----[Google Music Beta——云存储的内容库][26]
|
||||
- ----[Google Music Beta——云存储的内容库][26]
|
||||
- [Android 4.0 Ice Cream Sandwich——摩登时代][27]
|
||||
- ----[Google Play以及直接面向消费者销售设备的回归][28]
|
||||
- ----[Google Play以及直接面向消费者销售设备的回归][28]
|
||||
- [Android 4.1 Jelly Bean——Google Now指明未来][29]
|
||||
- ----[Google Play服务——碎片化以及让系统版本(几乎)过时][30]
|
||||
- ----[Google Play服务——碎片化以及让系统版本(几乎)过时][30]
|
||||
- [Android 4.2 Jelly Bean——新Nexus设备,新平板界面][31]
|
||||
- ----[周期外更新——谁需要一个新系统?][32]
|
||||
- ----[周期外更新——谁需要一个新系统?][32]
|
||||
- [Android 4.3 Jelly Bean——为可穿戴设备做好准备][33]
|
||||
- [Android 4.4 KitKat——更完美;更少的内存占用][34]
|
||||
- [今日安卓无处不在][35]
|
||||
@@ -60,89 +58,89 @@ Google在2007年11月时对安卓最初的介绍。
|
||||
|
||||
### Android 0.5, Milestone 3——第一个公开版本 ###
|
||||
|
||||
在我们开始在实体硬件上研究安卓之前,我们要从很早,很早以前的安卓时光开始说起。尽管1.0是第一个运行在实体硬件上的版本,但在那之前其实还有若干个只随SDK发布的模拟器beta版本。这些模拟器只用于开发的目的,所以它们不含任何谷歌应用,甚至是一些核心系统应用。但它们仍然是回顾安卓的发布前时光的最好渠道。
|
||||
在我们开始在实体硬件上研究安卓之前,我们要从很早,很早以前的安卓时光开始说起。尽管1.0是第一个运行在实体硬件上的版本,但在那之前其实还有若干个只随SDK发布的模拟器beta版本。这些模拟器只用于开发的目的,所以它们不含任何谷歌应用,甚至只是一些核心系统应用。但它们仍然是回顾安卓的发布前时光的最好渠道。
|
||||
|
||||

|
||||
模拟器默认的qwerty布局并运行Milestone 3。
|
||||
Ron Amadeo供图
|
||||
|
||||
在异想天开的糖果版本代号和[与跨国食品公司跨界合作][2]之前,第一个安卓的公开发布版本的标签是“m3-rc20a”——“m3”代表“Milestone 3(里程碑3)”。尽管谷歌可能不会公布版本号——这个版本甚至没有一个设置应用来查看——浏览器用户标识识别为“Android 0.5”。
|
||||
*模拟器默认的qwerty布局并运行Milestone 3* [Ron Amadeo供图]
|
||||
|
||||
在2007年11月,谷歌获得安卓两年,iPhone发布五个月之后,[安卓正式发布][3],第一个模拟器正式释出。回到那时候看,这个系统才刚处于起步阶段。它很容易就被认为“只是个黑莓的山寨而已”。模拟器使用了一个qwerty布局的皮肤以及320×240的显示屏,是一台[原型设备][4]的复制品。这台设备由HTC制造,通过一些早期的安卓账户可以得知这台设备的代号似乎是“Sooner”。但是Sooner从未正式上市。
|
||||
在异想天开的糖果版本代号和[与跨国食品公司跨界合作][2]之前,第一个安卓的公开发布版本的标签是“m3-rc20a”——“m3”代表“Milestone 3(里程碑3)”。尽管谷歌可能不会公布版本号——这个版本甚至没有一个设置应用来查看——浏览器用户标识被识别为“Android 0.5”。
|
||||
|
||||
在2007年11月,谷歌获得安卓两年、iPhone发布五个月之后,[安卓正式发布][3],第一个模拟器正式释出。回到那时候看,这个系统才刚处于起步阶段。它很容易就被认为“只是个黑莓的山寨而已”。模拟器使用了一个qwerty布局的皮肤以及320×240的显示屏,是一台[原型设备][4]的复制品。这台设备由HTC制造,通过一些早期的安卓账户可以得知这台设备的代号似乎是“Sooner”。但是Sooner从未正式上市。
|
||||
|
||||
通过安卓早期[开发账号][5]得知,当苹果在2007年1月最终发布它革命性的智能手机后,谷歌不得不对安卓“从头来过”——包括放弃Sooner。考虑到Milestone 3模拟器在苹果的iPhone后近一年才推出,设备界面看起来还是那么像黑莓的模型是在是令人惊奇的事情。尽管在iPhone发布后的开发里任务毫无疑问地在优先保障下完成了,但模拟器仍然以被认为是“旧学院风”的界面发布。这使得它没能给人留下一个好的第一印象。
|
||||
|
||||
在早期阶段,安卓按键布局看起来并没有最终确定下来。尽管第一台商业安卓设备使用了“主屏幕”,“后退”,“菜单”以及“搜索”作为标准的按键套件,模拟器上有一个空白的标记为“X”的键,你可能会认为是那是搜索键应该在的地方。“Sooner”原型机看起来更奇怪——它在第四个键上有个星形标记。
|
||||
|
||||

|
||||
从左到右:主屏幕,一个打开的通知,以及“应用”文件夹。
|
||||
Ron Amadeo供图
|
||||
|
||||
*从左到右:主屏幕,一个打开的通知,以及“应用”文件夹* [Ron Amadeo供图]
|
||||
|
||||
在这里没有可以配置的主屏幕或小插件,仅仅只是简单的在底部有聚合图标的dock,可以循环或是点击。尽管已经有一些特性支持触摸屏,Milestone 3主要还是使用五向十字键——一个时至今日安卓仍然支持的不合时宜的设计。甚至早期的安卓都能够实现动画效果。图标在进入dock的中心窗口时会变大或缩小。
|
||||
|
||||
在这时候一样也还没有通知栏。通知图标显示在顶部状态栏(上面图片中的微笑标志),打开它的唯一方法是在主屏幕按下十字键的上键。你无法通过点击微笑的图标来打开它,也无法从除主屏幕以外的地方打开通知。当通知被打开的时候,状态栏些许地扩展开,通知文本会显示在一个聊天气泡中。一旦你阅读完通知,你无法手动清除它——应用本身负责清除它的通知消息。
|
||||
在这时候同样也还没有通知栏。通知图标显示在顶部状态栏(上面图片中的微笑标志),打开它的唯一方法是在主屏幕按下十字键的上键。你无法通过点击微笑的图标来打开它,也无法从除主屏幕以外的地方打开通知。当通知被打开的时候,状态栏扩展开些许,通知文本会显示在一个聊天气泡中。一旦你阅读完通知,你无法手动清除它——应用本身负责清除它的通知消息。
|
||||
|
||||
应用抽屉的职责由一个dock左侧简单的“应用程序”文件夹负责。尽管有着不少标志性的功能,Milestone 3模拟器应用图标还不是十分完善。只有“浏览器”,“联系人” ,以及“地图”是这里面真正的应用。奇怪的是,“最近通话”被提升为一个独立的图标。因为这仅仅只是个模拟器,像闹钟,日历,拨号,计算器,照相机,相册,以及设置这样的智能手机核心功能的图标统统没有。硬件原型倒是有[其中的大部分][6],它还有一套谷歌应用出现并运行着。不幸的是我们没办法看到它们了。它们已经老到无论如何都连不上谷歌的服务器了。
|
||||
应用抽屉的职责由托盘左侧简单的“应用程序”文件夹负责。尽管有着不少标志性的功能,Milestone 3模拟器应用图标还不是十分完善。只有“浏览器”,“联系人” ,以及“地图”是这里面真正的应用。奇怪的是,“最近通话”被提升为一个独立的图标。因为这仅仅只是个模拟器,像闹钟,日历,拨号,计算器,照相机,相册,以及设置这样的智能手机核心功能的图标统统没有。硬件原型倒是有[其中的大部分][6],它还有一套谷歌应用出现并运行着。不幸的是我们没办法看到它们了。它们已经老到无论如何都连不上谷歌的服务器了。
|
||||
|
||||

|
||||
Milestone 3的浏览器菜单系统,壁纸界面,以及音量控制。
|
||||
Ron Amadeo供图
|
||||
|
||||
这套现在已经过时的菜单系统出现并运行在Milestone 3上。点击实体菜单键会打开一个灰色带有蓝色梯度高亮的列表,通过实体键盘完成操作。在上面的截图中,你可以看到在浏览器中打开的菜单。进入二级菜单,像缩放菜单,一级菜单变成有些奇怪的透明状态。
|
||||
*Milestone 3的浏览器菜单系统,壁纸界面,以及音量控制* [Ron Amadeo供图]
|
||||
|
||||
这套现在已经过时的菜单系统出现并运行在Milestone 3上。点击实体菜单键会打开一个灰色带有蓝色梯度高亮的列表,通过实体键盘完成操作。在上面的截图中,你可以看到在浏览器中打开的菜单。进入二级菜单,像缩放菜单,一级菜单这些变成有些奇怪的透明状态。
|
||||
|
||||
令人惊喜的是,多任务及后台应用在Milestone 3上已经可以运作了。离开应用而不关闭它——应用会保存状态,甚至写入文本保存。这个特性iOS直到2010年推出iOS 4才能与其相比,这就真正显示出了这两个平台的不同。iOS最初是作为一个封闭的平台而没有第三方应用,所以平台的鲁棒性并没有得到很大的关注。安卓是从头开始被构建成一个强大的应用软件平台,轻松开发应用是它创造出来背后的推动力之一。
|
||||
|
||||
在安卓之前,谷歌已经通过[WAP网站][7]和[J2ME手机应用][8]向移动端开始迁移,这使得它们强烈地意识到移动开发的难度。据[The Atlantic][9],拉里佩奇曾这么描述公司在移动端的努力“我们有一系列超过100台手机,我们在每一台设备上都要构建一次我们的应用”。开发者们现在经常抱怨安卓的碎片化,但在安卓出现之前,问题要比现在糟糕很多。
|
||||
在安卓之前,谷歌已经通过[WAP网站][7]和[J2ME手机应用][8]向移动端开始迁移,这使得它们强烈地意识到移动开发的难度。据[The Atlantic][9],拉里.佩奇曾这么描述公司在移动端的努力“我们有一系列超过100台的手机,我们在每一台设备上都要构建一次我们的应用”。开发者们现在经常抱怨安卓的碎片化,但在安卓出现之前,问题要比现在糟糕很多。
|
||||
|
||||
谷歌的平台战略实际上胜出了,iOS最终在不久后开始慢慢加入这些围绕应用的特性——多任务,跨应用分享,以及应用切换。
|
||||
|
||||

|
||||
当你在主屏幕按数字键弹出的拨号界面,来电,以及电话会议界面。
|
||||
Ron Amadeo供图
|
||||
|
||||
尽管没有拨号图标,Milestone 3模拟器还是有办法拨号。按键盘上的任意键会打开左侧界面,这是拨号/联系人搜索混合界面。仅输入数字并点击绿色的实体拨号键来开始通话,输入字母会搜索联系人。但是联系人无法通过数字搜索。甚至直接点击一个号码也不会打开联系人。
|
||||
*当你在主屏幕按数字键弹出的拨号界面,来电,以及电话会议界面* [Ron Amadeo供图]
|
||||
|
||||
来电被显示成一个几乎全屏的令人愉快的透明背景弹窗。一旦进入通话,背景会变成深灰色,Milestone 3展现给用户一些令人惊奇的高级特性:静音,扬声器,保持,以及电话会议按钮。多方通话会显示成重叠,半透明的卡片状,用户有切换或者合并通话的选项可以选择。切换通话会触发一个漂亮的小卡片洗牌动画。
|
||||
尽管没有拨号图标,Milestone 3模拟器还是有办法拨号。按键盘上的任意键会打开上图左侧的界面,这是拨号/联系人搜索混合界面。仅输入数字并点击绿色的实体拨号键来开始通话,输入字母会搜索联系人。但是联系人无法通过数字搜索。甚至直接点击一个号码也不会打开联系人。
|
||||
|
||||
来电被显示成一个几乎全屏的令人愉快的透明背景弹窗。一旦进入通话,背景会变成深灰色,Milestone 3展现给用户一些令人惊奇的高级特性:静音,扬声器,通话保持,以及电话会议按钮。多方通话会显示成重叠,半透明的卡片状,用户有切换或者合并通话的选项可以选择。切换通话会触发一个漂亮的小卡片洗牌动画。
|
||||
|
||||

|
||||
联系人列表,打开一个联系人,编缉联系人,以及最近通话界面。
|
||||
Ron Amadeo供图
|
||||
|
||||
联系人是一个质朴的,黑色和蓝色的姓名列表。联系人卡片中有个联系人头像的位置但是没办法设置一张图像上去(至少在模拟器中不行)。这里唯一的装饰是每个联系人名字左侧的XMPP状态点。传统来说一个保持在线的XMPP连接是安卓的核心,它的深度集成从Milestone 3就已经开始了。安卓使用XMPP来驱动一个24/7在线的与谷歌服务器之间的连接,驱动Google Talk,云到端消息推送,以及应用的安装和卸载信息。
|
||||
*联系人列表,打开一个联系人,编缉联系人,以及最近通话界面* [Ron Amadeo供图]
|
||||
|
||||
联系人是一个质朴的,黑色和蓝色的姓名列表。联系人卡片中有个联系人头像的位置但是没办法设置一张图像上去(至少在模拟器中不行)。这里唯一的装饰是每个联系人名字左侧的XMPP状态点。就传统来说,一个保持在线的XMPP连接是安卓的核心,它的深度集成从Milestone 3就已经开始了。安卓使用XMPP来驱动一个24/7在线的与谷歌服务器之间的连接,以驱动Google Talk的云到端消息推送,以及应用的安装和卸载信息。
|
||||
|
||||

|
||||
浏览器的假Google首页,地址栏,浏览历史界面。
|
||||
Ron Amadeo供图
|
||||
|
||||
*浏览器的假Google首页,地址栏,浏览历史界面* [Ron Amadeo供图]
|
||||
|
||||
浏览器运行Webkit 419.3,它也被用在相同时代的像Mac OS X 10.4的Safari 2上。浏览器主页并不是Google.com,而是一个包含在安卓里的硬编码的home.html文件。它看起来就像是千年之前的Google.com。浏览器的OS X遗留还可以辨认出来,用了光滑的,Aqua风格的搜索按钮来渲染浏览器按钮。
|
||||
|
||||
这个小小的黑莓风格的屏幕需要一个分离的地址栏,可以通过浏览器菜单里的“前往”选项打开。尽管自动补全不起作用,地址栏会在你输入的时候实时搜索你的浏览历史。右侧图片显示的是历史界面,它使用了略缩图来显示各个站点。当前的略缩图在其它两个之前,滑动它们会触发一个猛扑的动画效果。但在早期阶段,浏览器不支持多标签或窗口——你可以看到当前站点,那就是全部了。
|
||||
这个小小的黑莓风格的屏幕需要一个分离的地址栏,可以通过浏览器菜单里的“前往”选项打开。尽管自动补全不起作用,地址栏会在你输入的时候实时搜索你的浏览历史。右侧图片显示的是历史界面,它使用了略缩图来显示各个站点。当前的略缩图在其它两个缩略图之前,滑动它们会触发一个俯冲动画效果。但在早期阶段,浏览器不支持多标签或窗口——你可以看到当前站点,那就是全部了。
|
||||
|
||||

|
||||
一个视频屏幕抓取导出的谷歌地图界面,方向界面,相册测试界面。
|
||||
Ron Amadeo供图
|
||||
|
||||
在开始的时候,谷歌认识到在移动端地图将会非常重要,甚至在Milestone 5模拟器中内置了地图客户端。那个版本的谷歌地图是我们遇到的第一个死于云腐烂的。这个客户端无法从谷歌的服务器上载入信息,所以地图显示为一片空白,灰色的网格。没有什么能够运转。
|
||||
*一个视频屏幕抓取导出的谷歌地图界面,方向界面,相册测试界面* [Ron Amadeo供图]
|
||||
|
||||
在开始的时候,谷歌认识到在移动端地图将会非常重要,甚至在Milestone 5模拟器中内置了地图客户端。那个版本的谷歌地图是我们遇到的第一个死于云腐烂的!这个客户端无法从谷歌的服务器上载入信息,所以地图显示为一片空白,灰色的网格。没有什么能够工作。
|
||||
|
||||
幸运的是,因为上面的第一张截图,我们能够从安卓启动视频中拼凑出准确的界面。旧的谷歌地图看起来完全是为非触摸设备准备的,实体键快捷方式列表排列在屏幕底部。这样在看地图时,或是在如果仅仅显示该点的地址的时候就不大清楚。
|
||||
|
||||
隐藏在菜单之后的是搜索选项,路线,以及卫星和交通图层。中间的截图是方向的UI之一,你可以选择一个联系人的地址作为起点或者终点。但地图缺乏任何种类的集成GPS,你在哪都找不到“我的位置”这个按钮。
|
||||
隐藏在菜单之后的是搜索选项,路线,以及卫星和交通图层。中间的截图是获取路径的UI之一,你可以选择一个联系人的地址作为起点或者终点。但地图缺乏任何种类的集成GPS,你在哪都找不到“我的位置”这个按钮。
|
||||
|
||||
尽管没有合适的相册,在右边是相册的测试界面,隐藏在“API Demos”应用里。图片可以向左向右滚动,但无法以全屏的方式打开一张照片。同样它也没有照片管理选项。它本质上就是个图片滚动界面的测试视图。
|
||||
尽管没有合适的相册,不过在右边是相册的测试界面,隐藏在“API Demos”应用里。图片可以向左向右滚动,但无法以全屏的方式打开一张照片。同样它也没有照片管理选项。它本质上就是个图片滚动界面的测试视图。
|
||||
|
||||

|
||||
时间设置和日历,有点字间距问题,以及以Ars为特色的垂直列表测试。
|
||||
Ron Amadeo供图
|
||||
|
||||
*时间设置和日历,有点字间距问题,以及以Ars为特色的垂直列表测试* [Ron Amadeo供图]
|
||||
|
||||
同样模拟器中也没有设置应用,但是通过API Demos我们可以看到最初的日期时间设置界面。这个示例暴露出很多安卓没来得及处理的问题:到处都有的字间距问题,分钟数字间巨大的间隔,以及日历中星期日间不均等的间隔。尽管时间设置允许你单独更改每个数字,但除非你将当前日期移出本月到前一个或下一个月,否则你无法改变月份或年份。
|
||||
|
||||
别忘了尽管这看起来像是一些被遗忘时代的恐龙级别遗留物,但这仅仅是六年前发布的。我们总趋向与适应科技的脚步。我们很容易将这样的东西看作是20年前的东西。比较一下2007年晚些时候这个时间段的桌面操作系统,微软尝试将Windows Vista售往全世界快要一年了,而苹果刚刚发布OS X 10.5 Leopard。
|
||||
别忘了尽管这看起来像是一些被遗忘时代的恐龙级别遗留物,但这仅仅是六年前发布的。我们总趋向与适应科技的脚步。我们很容易将这样的东西看作是20年前的东西。比较一下2007年晚些时候这个时间段的桌面操作系统,微软尝试将Windows Vista售往全世界快要一年了,而苹果刚刚发布了OS X 10.5 Leopard。
|
||||
|
||||
最后一个关于Milestone 3的细节:谷歌在Milestone 3模拟器中给了Ars Technica一个快捷方式。打开“API Demos”应用并打开"Views," "Focus,"然后"Vertical"显示一个*this very Website*的头条测试列表。
|
||||
最后一个关于Milestone 3的细节:谷歌在Milestone 3模拟器中给了Ars Technica一个快捷方式。打开“API Demos”应用并打开"Views," "Focus,",然后"Vertical"显示一个*this very Website*的头条测试列表。
|
||||
|
||||

|
||||
随Milestone 3,RC37a发布的更加现代,全触控风格的模拟器。
|
||||
Ron Amadeo供图
|
||||
|
||||
*随Milestone 3,RC37a发布的更加现代,全触控风格的模拟器* [Ron Amadeo供图]
|
||||
|
||||
两个月后,2007年12月,谷歌放出了一个Milestone 3的更新,带来了更大的480×320设备设置。这个更新的标签是“m3-rc37a”。软件看起来还是像黑莓一样,仅仅是带来了更多的屏幕分辨率支持。
|
||||
|
||||
@@ -158,7 +156,7 @@ Ron Amadeo供图
|
||||
|
||||
via: http://arstechnica.com/gadgets/2014/06/building-android-a-40000-word-history-of-googles-mobile-os/
|
||||
|
||||
译者:[alim0x](https://github.com/alim0x) 校对:[校对者ID](https://github.com/校对者ID)
|
||||
译者:[alim0x](https://github.com/alim0x) 校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
安卓编年史(2)
|
||||
=============================================================================
|
||||

|
||||
|
||||
*左:Milestone 5,主屏幕展示了“All”按钮,两个dock图标,以及四个最近使用的应用。中:主屏幕与打开的应用程序列表。右边:电源菜单* [Ron Amadeo供图]
|
||||
|
||||
### 安卓0.5, Milestone 5——如今已经是报废接口的领地了 ###
|
||||
|
||||
“M5-RC14”版本发布后——也就是第一个安卓模拟器发布三个月之后,安卓迎来了它的首次重大革新。 2008年2月发布的“Milestone5”甩掉了延伸自黑莓的界面,走向一个完全革新的设计——谷歌在触控友好界面上的第一次尝试。
|
||||
|
||||
在浏览器的用户代理字符串的中,此版本仍然被识别为“Android 0.5”,但Milestone 5与安卓的第一个版本相比已经完全不一样了。几个核心的Android功能直接追踪他们的血统会最终回到这个版本。通知面板的布局和功能几乎已经整装待发,并且,除了样式变化外,菜单也最终成型。距离安卓1.0项目发布的时间仅仅只剩八个月,一个操作系统的基础已经开始成型了。
|
||||
|
||||
有一件东西目前绝对不是它的最终模样,那就是是主屏幕。这是一个不可配置的,单屏壁纸的应用程序的抽屉和托盘。应用程序图标是气泡状的,三种颜色的组合,由一个圆角矩形的白色背景包围着。应用程序抽屉在右下角有一个“所有”按钮,轻按它,打开的应用程序列表显示在了左边。这个“所有”按钮正上面的是两个托盘图标,“联系人”和“拨号盘”分别获得了永久的专属主屏幕位置。然后上边有四个模块,它们是“最近的应用程序”的早期版本,展示了最后访问的应用程序。没有了左侧屏幕和右侧屏幕,要是没有托盘和“最近的应用程序”占用的一整列,这种布局下只能放下21个应用程序图标。模拟器仍然只带有尽量少的应用程序,但在实际的设备中,这样的设计看起来并不会很好的工作效果。
|
||||
|
||||
按住“挂断”按钮会出现电源菜单的一个相当早期的版本,就像你最右侧的图片中看到的。谷歌此时仍然没有标准的智能手机命名术语:对于“Turn Off Screen”(关闭屏幕)最好的形容也许是“Lock screen”(锁定屏幕——虽然当时没有锁屏)和“Turn Off Radio”(关闭射频)在今天被叫做“Airplane Mode”(飞行模式)。
|
||||
|
||||

|
||||
|
||||
*从左至右依次为:令人惊喜的现代通知面板,谷歌地图的菜单在打开着(地图已经不可用了),和新的适合触控的列表视图* [Ron Amadeo供图]
|
||||
|
||||
回溯到Milestone 5,谷歌在那时对通知面板有着明确的认识。就像在任何现代的智能手机里一样,通知中心从屏幕顶部下拉下来以唤出。目前的通知都以列表的形式显示。通知面板的第一个版本是不透明的白色薄片以及底部中心有个橙色圆点的,带着棱纹的的“把手”。通知是可点击的,通过点击可以打开该通知关联的应用程序。没有人为此列表中垂直对齐应用程序图标而感到困扰,不过也没关系,随着接下来的更新,它已经是过去式了。
|
||||
|
||||
置顶通知能够进入一个在面板顶部的“正在进行”的部分。在这个版本中,这里似乎只包含通话。在“最近事件”里的通知只有打开相应的应用程序后才清楚。用户惊喜地发现可以通过内置的XMPP连接成功登录到谷歌talk。不过,虽然通知面板中显示“新会话信息”,这里实际上并不是一个即时消息应用程序。
|
||||
|
||||
Milestone 5里是全新的艺术设计。应用程序图标被重新绘制,并且菜单从一个无聊的黑莓风格的文本列表转变为一个全彩、卡通的大图标方阵。通知面板图标也从简单的、突兀的、白色的图标切换到一个绿色的气泡设计。当时信号指示下边有一条奇怪的黑线,没有明显的作用。早期开发版本的微小列表视图不适合手指使用,所以Milestone 5带来了更加强大的整体布局。
|
||||
|
||||

|
||||
|
||||
*拨号盘,最近通话,和来电。* [Ron Amadeo供图]
|
||||
|
||||
M5是第一个有一个拨号盘的版本,即使她是一个相当难看的版本。数字被显示在包含一个奇怪的聊天气泡风格的退格键的渐变填充条里,看上去就像是从其他界面回收回来的。对齐问题随处可见。按钮上的数字没有正确的垂直居中,而且退格键的“X”也没有与对话框对齐。由于屏幕上没有的“拨号”按钮,你甚至不能从拨号盘打个电话,它强制要求有个拨号的硬件实体按钮。
|
||||
|
||||
Milestone 5 有几个选项卡式界面,所有这些都演示了一个关于标签应该如何工作的奇怪的想法。活跃的标签是白色的,而背景标签是底部拥有一小条白色条带的黑色标签。后台标签应该是表示向下下沉的吗?切换标签时,是没有动画效果的。直到目前还不清楚这个设计试图想表达什么。
|
||||
|
||||
在第二张图片中显示的最近通话记录项,是从一个单独的应用程序降级为拨号盘的选项卡。它抛弃了早期版本疯狂的十字UI,多亏了大块列表视图,现在所有必要的信息都是显示在一个正常的列表中。
|
||||
|
||||
不同于拨号盘,来电画面有显示在屏幕上的按钮来接听和结束通话。奇怪的是,来电屏幕贴在屏幕的底部,而不是顶部或中心。它可能是从旧的黑莓4:3屏幕遗留下来的问题。
|
||||
|
||||

|
||||
|
||||
*通话中,触摸屏不可用的显示错误信息,和显示第二通话暂停的通话界面* [Ron Amadeo供图]
|
||||
|
||||
通话中的界面看起来正常,但在实际中毫无意义。今天,在通话中为了阻止你的脸按到按钮,手机近距离传感器一旦检测到物体会关闭屏幕。尽管Milestone 5不支持近距离传感器。谷歌的随意的解决方案是在通话过程中禁用整个触摸屏。与此同时,通话中的屏幕显然会检测触摸。这时候是有大的,可触摸的按钮,*但就是不让你摸!*
|
||||
|
||||
M5在这里让Milestone 3版本的几个功能回归了。许多旧的界面里体面的图标被替换成了文本。像“静音”按钮在激活的时候不再提供屏幕上的反馈。合并通话被完全去除了。
|
||||
|
||||

|
||||
|
||||
*浏览器的主要菜单,浏览器的二级菜单,疯狂的变焦控制和窗口界面* [Ron Amadeo供图]
|
||||
|
||||
浏览器菜单中进行了常规的触摸功能大整修,并且“更多”按钮第一次出现。它充当一个[你菜单的额外菜单][1]。相对于将3x2的网格变成3x4的网格,Milestone 5(以及Android的许多后续版本一样)中使用很长的、滚动的列表来引出其他选项。不支持双指缩放(据说是[向苹果让步][2]),因此Android运行着荒谬的控件,就像上边第三张图片一样。谷歌将它显示在屏幕的中间,而不是明智地设置成比如一个水平的、底部对齐的缩放控件。最后一张图片显示浏览器的“窗口”界面,允许你打开多个网页并在它们之间更轻松地切换。
|
||||
|
||||

|
||||
|
||||
*谷歌地图的图层选择,搜索界面,以及路线界面。* [Ron Amadeo供图]
|
||||
|
||||
谷歌地图仍然不能使用,但我们接触的小小UI却有了显著更新。你可以选择地图图层,虽然只有两种可以选择:卫星和交通。顶部对齐的搜索界面奇怪地隐藏了状态栏,而底部对齐的路线没有隐藏状态栏。路线的输入按钮被标有“Go”,而且搜索的输入按钮却被标有一个奇怪的弯曲的箭头。这样的例子不胜枚举,并演示了保守的安卓在最坏时候的情况:在同一个应用程序,外观和工作方式*应该*类似的两个功能,在实现上却完全相反。
|
||||
|
||||
----------
|
||||
|
||||

|
||||
|
||||
[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/2/
|
||||
|
||||
译者:[cereuz](https://github.com/cereuz) 邮箱:[cereuz](mailto:sunedo@qq.com)
|
||||
校对:[alim0x](https://github.com/alim0x)/[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://i.imgur.com/GIYGTnb.jpg
|
||||
[2]:http://www.businessinsider.com/steve-jobs-on-android-founder-andy-rubin-big-arrogant-f-2013-11
|
||||
[a]:http://arstechnica.com/author/ronamadeo
|
||||
[t]:https://twitter.com/RonAmadeo
|
||||
@@ -1,3 +1,4 @@
|
||||
translating by ZTinoZ
|
||||
LibreOffice 4.3.4 Released With 60 Bug Fixes, v4.4 Shaping Up Nicely
|
||||
================================================================================
|
||||

|
||||
@@ -54,4 +55,4 @@ via: http://www.omgubuntu.co.uk/2014/11/libreoffice-4-3-4-arrives-bundle-bug-fix
|
||||
[1]:http://www.omgubuntu.co.uk/2014/10/libreoffice-4-3-3-released-62-bug-fixes
|
||||
[2]:https://wiki.documentfoundation.org/Releases/4.3.4/RC1
|
||||
[3]:http://www.libreoffice.org/download/libreoffice-fresh/
|
||||
[4]:https://wiki.documentfoundation.org/ReleaseNotes/4.4#GUI
|
||||
[4]:https://wiki.documentfoundation.org/ReleaseNotes/4.4#GUI
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
Budgie Desktop v8 Released With Improved Menu, Panel
|
||||
================================================================================
|
||||

|
||||
|
||||
**A new version of [Evolve OS][1]‘s simple ‘[Budgie Desktop Environment][2]‘ has been released, and the improvements under its wing are impressive.**
|
||||
|
||||
Made up of 78 commits, the lightweight desktop lands with a host of new options and applets to play with. Its plumage has also benefitted from a bit of TLC, with key parts of the shell feeling fresher and looking more refined.
|
||||
|
||||
But will the changes ruffle the feathers of the Budgie flock or leave them squawking in awe? Let’s take a closer look.
|
||||
|
||||
### Budgie v8 ###
|
||||
|
||||
#### Menu Changes ####
|
||||
|
||||
The **Budgie Menu** now uses a narrower compact layout by default. This style lists the applications in categories (as previously) but sorted by usage rather than name.
|
||||
|
||||
Software that you open most often sit nearer the top of each category header. It’s an efficacious decision that should help save time for those who hunt n’ scroll for apps rather than use the handy search filter.
|
||||
|
||||

|
||||
|
||||
The Menu uses ‘compact’ mode by default
|
||||
|
||||
The old two-pane setup that featured in earlier builds remains available; you can toggle it back on in Budgie’s preferences (**right click on the menu applet > Preferences**).
|
||||
|
||||
The power option menu that previously
|
||||
resided in the main menu has been moved over to the System Tray applet (i.e., ‘volume‘). Additionally, you can now access System Settings entries from the menu itself — no more scratching of heads!
|
||||
|
||||
#### Panel Changes ####
|
||||
|
||||

|
||||
|
||||
Quicklist support in Budgie 0.8
|
||||
|
||||
The Budgie Panel and task list applet both benefit from a raft of improvements, including new auto-hide options, dynamic theming support and a new ‘GNOME 2′-style menu bar option.
|
||||
|
||||
- Auto-hide (optional)
|
||||
- Quicklist support
|
||||
- Dark theme support
|
||||
- Application pinning
|
||||
- App ‘attention’ hint
|
||||
- GNOME Panel theming
|
||||
- Old-school ‘Menu Bar’ applet (optional)
|
||||
|
||||

|
||||
|
||||
#### Elsewhere ####
|
||||
|
||||
Other changes include support for GNOME 3.10 and up; improved animations when changing wallpapers; and the run dialog has been hugely improved in design, sporting an almost Alfred/GNOME-Do-esque design. Mmmhm!
|
||||
|
||||

|
||||
|
||||
Run, Run, Run
|
||||
|
||||
### Install Budgie Desktop on Ubuntu ###
|
||||
|
||||
Budgie 0.8 is, as with previous releases, available to install in Ubuntu 14.04 LTS and Ubuntu 14.10 by way of an official PPA. The desktop can be installed alongside Unity, GNOME Shell and Cinnamon without much (if any) issue.
|
||||
|
||||
To install, open a new Terminal window and enter the following commands. Enter your password where prompted.
|
||||
|
||||
sudo add-apt-repository ppa:evolve-os/ppa
|
||||
|
||||
sudo apt-get update && sudo apt-get install budgie-desktop
|
||||
|
||||
After the install has completed you will need to log out of Unity (or whichever desktop you’re currently using). At the Unity Greeter click the Ubuntu logo emblem, select the Budgie session from the session list, and then log in as normal. The Budgie desktop will load.
|
||||
|
||||

|
||||
|
||||
#### Notes for Ubuntu Users ####
|
||||
|
||||

|
||||
|
||||
Expect Odd Theming Issues in Ubuntu
|
||||
|
||||
While Budgie is now easy for Ubuntu users to install it is not designed for it specifically (the Evolve OS distribution is the best way to experience it).
|
||||
|
||||
Naturally, you might not fancy upheaving to another OS. That’s fine, but if you plan on keeping Budgie caged in Ubuntu you’ll need to note the following caveats (lest you end up bird-brained).
|
||||
|
||||
First up, **Budgie is under active development**. Several key features remain missing, including native network management support. An applet can be added to the panel that supports Ubuntu’s Indicator Applets, but it’s a little rough around the edges.
|
||||
|
||||
You should also expect some theming issues when using the shell with Ambiance/Radiance. The Adwaita theme (and other GNOME themes) work best. You should also disable Ubuntu’s Overlay Scrollbars.
|
||||
|
||||
Finally, logout (volume > power button) **does not work under Ubuntu**. To log out you should use the run dialog (Alt+F2) and the following command:
|
||||
|
||||
gnome-session-quit
|
||||
|
||||
If all of that sounds like fun rather than faff, there’s plenty to enjoy in Budgie – and not just its minimal system footprint! Let us know your own thoughts on it, what you’d like to see it add next, etc. in the comments below.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.omgubuntu.co.uk/2014/11/budgie-desktop-0-8-released-big-changes
|
||||
|
||||
作者:[Joey-Elijah Sneddon][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://plus.google.com/117485690627814051450/?rel=author
|
||||
[1]:http://evolve-os.com/
|
||||
[2]:http://www.omgubuntu.co.uk/2014/07/install-budgie-evolve-os-desktop-ubuntu-14-04
|
||||
@@ -0,0 +1,51 @@
|
||||
Ubuntu 15.04 Gets Tentative Release Date of April 23, 2015
|
||||
================================================================================
|
||||

|
||||
|
||||
**Doing anything special on April 23 next year? You might well be — it’s the tentative release date being given for Ubuntu 15.04 ‘Vivid Vervet’.**
|
||||
|
||||
The date, along with those of various other development milestones, is listed as part of a [draft release schedule][1] on the Ubuntu Wiki page for the ‘V’ update. As of writing all dates are subject to approval from the Ubuntu release team and are therefore **not final**.
|
||||
|
||||
Ubuntu’s previous spring release, 14.04 LTS, went live on April 17, 2014.
|
||||
|
||||
### Veracity Potential is Void ###
|
||||
|
||||

|
||||
|
||||
Dates not yet ready to be inked in
|
||||
|
||||
Draft means just that, but having covered some 10 Ubuntu release over five years I do know that the proposed dates don’t tend to differ too wildly from those that go final (famous last words, I’m sure!).
|
||||
|
||||
Even so, take the proposals with a pinch of optimism for now. I’ll be keeping both this page and the fancy-schmancy graphic updated as, if or when anything changes.
|
||||
|
||||
### Key Ubuntu 15.04 Release Dates ###
|
||||
|
||||
As with all releases post-13.04, Ubuntu proper only makes fleeting appearances in select milestone releases, specifically the ‘final beta’ and the ‘release candidate’ stages.
|
||||
|
||||
Ubuntu’s family of flavours, which may include Ubuntu MATE this cycle, take full advantage of the testing opportunities at hand.
|
||||
|
||||
- **Alpha 1** – December 18th (for flavours)
|
||||
- **Alpha 2** – January 22nd (for flavours)
|
||||
- *Feature Freeze* — February 19th
|
||||
- **Beta 1** – August 28th (for flavours)
|
||||
- *UI Freeze* — March 12th
|
||||
- **Final Beta** – March 26th
|
||||
- *Kernel Freeze* — April 9th
|
||||
- **Release Candidate** – April 16th
|
||||
|
||||
The final release of the Vivid Vervet in all its vivacious glory is pencilled in for release on:
|
||||
|
||||
- **Ubuntu 15.04 Final** – April 23rd
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.omgubuntu.co.uk/2014/11/ubuntu-15-04-release-schedule-date-vivid-vervet
|
||||
|
||||
作者:[Joey-Elijah Sneddon][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://plus.google.com/117485690627814051450/?rel=author
|
||||
[1]:https://wiki.ubuntu.com/VividVervet/ReleaseSchedule
|
||||
@@ -1,3 +1,4 @@
|
||||
[translating by KayGuoWhu]
|
||||
When hackers grow old
|
||||
================================================================================
|
||||
Lately I’ve 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 I’m done venting.
|
||||
|
||||
@@ -1,188 +0,0 @@
|
||||
zpl1025
|
||||
What are useful CLI tools for Linux system admins
|
||||
================================================================================
|
||||
System administrators (sysadmins) are responsible for day-to-day operations of production systems and services. One of the critical roles of sysadmins is to ensure that operational services are available round the clock. For that, they have to carefully plan backup policies, disaster management strategies, scheduled maintenance, security audits, etc. Like every other discipline, sysadmins have their tools of trade. Utilizing proper tools in the right case at the right time can help maintain the health of operating systems with minimal service interruptions and maximum uptime.
|
||||
|
||||
This article will present some of the most popular and useful CLI tools recommended for sysadmins in their day to day activities. If you would like to recommend any useful tool which is not listed here, don't forget to share it in the comment section.
|
||||
|
||||
### Network Tools ###
|
||||
|
||||
1. **ping**: Check end-to-end connectivity (RTT delay, jitter, packet loss) of a remote host with ICMP echo/reply. Useful to check system status and reachability.
|
||||
|
||||
2. **[phping][1]**: Network scanning and testing tool that can generate ICMP/TCP/UDP ping packets. Often used for advanced port scanning, firewall testing, manual path MTU discovery and fragmentation testing.
|
||||
|
||||
3. **traceroute**: Discover a layer-3 forwarding path from a local host to a remote destination host with TTL-limited ICMP/UDP/TCP probe packets. Useful to troubleshoot network reachability and routing problems.
|
||||
|
||||
4. **mtr**: A variation of traceroute which characterizes per-hop packet loss/jitter with running statistics. Useful to characterize routing path delays.
|
||||
|
||||
5. **[netcat][2]/[socat][3]**: A swiss army knife of TCP/IP networking, allowing to read/write byte streams over TCP/UDP. Useful to troubleshoot firewall policies and service availability.
|
||||
|
||||
6. **dig**: DNS troubleshooting tool that can generate forward queries, reverse queries, find authoritative name servers, check CNAME, MX and other DNS records. Can be instructed to query a specific DNS server of your choosing.
|
||||
|
||||
7. **nslookup**: Another DNS checking/troubleshooting tool. Works with all DNS queries and records. Can query a particular DNS server.
|
||||
|
||||
8. **dnsyo**: A DNS testing tool which checks DNS propagation by performing DNS lookup from over a number of open resolvers located across 1,500 different networks around the world.
|
||||
|
||||
9. **lsof**: Show information about files (e.g., regular files, pipes or sockets) which are opened by processes. Useful to monitor open network connections.
|
||||
|
||||
10. **iftop**: A ncurses-based TUI utility that can be used to monitor in real time bandwidth utilization and network connections for each network interfaces. Useful to keep track of bandwidth hogging applications, users, destinations and ports.
|
||||
|
||||
11. **netstat**: A network statistics utility that can show status information and statistics about open network connections (TCP/UDP ports, IP addresses), routing tables, TX/RX traffic and protocols. Useful for network related diagnosis and performance tuning.
|
||||
|
||||
12. **[tcpdump][4]**: A popular packet sniffer tool based on libpcap packet capture library. Can define packet capturing filters in Berkeley Packet Filters format.
|
||||
|
||||
13. **[tshark][5]**: Another CLI packet sniffer software with full compatibility with its GUI counterpart, Wireshark. Supports [1,000 protocols][6] and the list is growing. Useful to troubleshoot, analyze and store information on live packets.
|
||||
|
||||
14. **ip**: A versatile CLI networking tool which is part of iproute2 package. Used to check and modifying routing tables, network device state, and IP tunneling settings. Useful to view routing tables, add/remove static routes, configure network interfaces, and otherwise troubleshoot routing issues.
|
||||
|
||||
15. **ifup/ifdown**: Used to bring up or shut down a particular network interface. Often a preferred alternative to restarting the entire network service.
|
||||
|
||||
16. **[autossh][7]**: A program which create an SSH session and automatically restarts the session should it disconnect. Often useful to create a persistent reverse SSH tunnel across restrictive corporate networks.
|
||||
|
||||
17. **iperf**: A network testing tool which measures maximum bi-directional throughput between a pair of hosts by injecting customizable TCP/UDP data streams in between.
|
||||
|
||||
18. **[elinks][8]/[lynx][9]**: text-based web browsers for CLI-based server environment.
|
||||
|
||||
### Security Tools ###
|
||||
|
||||
19. **[iptables][10]**: A user-space CLI tool for configuring Linux kernel firewall. Provides means to create and modify rules for incoming, transit and outgoing packets within Linux kernel space.
|
||||
|
||||
20. **[nmap][11]**: A popular port scanning and network discovery tool used for security auditing purposes. Useful to find out which hosts are up and running on the local network, and what ports are open on a particular host.
|
||||
|
||||
21. **[TCP Wrappers][12]**: A host-based network ACL tool that can be used to filter incoming/outgoing reqeuests/replies. Often used alongside iptables as an additional layer of security.
|
||||
|
||||
22. **getfacl/setfacl**: View and customize access control lists of files and directories, as extensions to traditional file permissions.
|
||||
|
||||
23. **cryptsetup**: Used to create and manage LUKS-encrypted disk partitions.
|
||||
|
||||
24. **lynis**: A CLI-based vulnerability scanner tool. Can scan the entire Linux system, and report potential vulnerabilities along with possible solutions.
|
||||
|
||||
25. **maldet**: A malware scanner CLI tool which can detect and quarantine potentially malware-infected files. Can run as a background daemon for continuous monitoring.
|
||||
|
||||
26. **[rkhunter][13]/[chkrootkit][14]**: CLI tools which scan for potential rootkits, hidden backdoors and suspected exploits on a local system, and disable them.
|
||||
|
||||
### Storage Tools ###
|
||||
|
||||
27. **fdisk**: A disk partition editor tool. Used to view, create and modify disk partitions on hard drives and removable media.
|
||||
|
||||
28. **sfdisk**: A variant of fdisk which accesses or updates a partition table in a non-interactive fashion. Useful to automate disk partitioning as part of backup and recovery procedure.
|
||||
|
||||
29. **[parted][15]**: Another disk partition editor which can support disk larger than 2TB with GPT (GUID Partitioning Table). Gparted is a GTK+ GUI front-end of parted.
|
||||
|
||||
30. **df**: Used to check used/available storage and mount point of different partitions or file directories. A user-friendly variant dfc exists.
|
||||
|
||||
31. **du**: Used to view current disk usage associated with different files and directories (e.g., du -sh *).
|
||||
|
||||
32. **mkfs**: A disk formatting command used to build a filesystem on individual disk partitions. Filesystem-specific versions of mkfs exist for a number of filesystems including ext2, ext3, ext4, bfs, ntfs, vfat/fat.
|
||||
|
||||
33. **fsck**: A CLI tool used to check a filesystem for errors and repair where possible. Typically run automatically upon boot when necessary, but also invoked manually on demand once unmounting a partition.
|
||||
|
||||
34. **mount**: Used to map a physical disk partition, network share or remote storage to a local mount point. Any read/write in the mount point makes actual data being read/written in the correspoinding actual storage.
|
||||
|
||||
35. **mdadm**: A CLI tool for managing software RAID devices on top of physical block devices. Can create, build, grow or monitor RAID array.
|
||||
|
||||
36. **lvm**: A suite of CLI tools for managing volume groups and physical/logical volumes, which allows one to create, resize, split and merge volumes on top of multiple physical disks with minimum downtime.
|
||||
|
||||
### Log Processing Tools ###
|
||||
|
||||
37. **tail**: Used to monitor trailing part of a (growing) log file. Other variants include multitail (multi-window monitoring) and [ztail][16] (inotify support and regex filtering and coloring).
|
||||
|
||||
38. **logrotate**: A CLI tool that can split, compresse and mail old/large log files in a pre-defined interval. Useful for administration of busy servers which may produce a large amount of log files.
|
||||
|
||||
39. **grep/egrep**: Can be used to filter log content for a particular pattern or a regular expression. Variants include user-friendly ack and faster ag.
|
||||
|
||||
40. **awk**: A versatile text scanning and processing tool. Often used to extract certain columns or fields from text/log files, and feed the result to other tools.
|
||||
|
||||
41. **sed**: A text stream editor tool which can filter and transform (e.g., remove line/whitespace, substitute/convert a word, add numbering) text streams and pipeline the result to stdout/stderr or another tool.
|
||||
|
||||
### Backup Tools ###
|
||||
|
||||
42. **[rsync][17]**: A fast one-way incremental backup and mirroring tool. Often used to replicate a data repository to an offsite storage, optionally over a secure connection such as SSH or stunnel.
|
||||
|
||||
43. **[rdiff-backup][18]**: Another bandwidth-efficient, incremental backup tool. Maintains differential of two consecutive snapshots.
|
||||
|
||||
44. **duplicity**: An encrypted incremental backup utility. Uses GnuPG to encrypt a backup, and transfers to a remote server over SSH.
|
||||
|
||||
### Performance Monitoring Tools ###
|
||||
|
||||
45. **top**: A CLI-based process viewer program. Can monitor system load, process states, CPU and memory utilization. Variants include more user-friendly htop.
|
||||
|
||||
46. **ps**: Shows a snapshot of all running processes in the system. The output can be customized to show PID, PPID, user, load, memory, cummulative user/system time, start time, and more. Variants include pstree which shows
|
||||
|
||||
### processes in a tree hierarchy. ###
|
||||
|
||||
47. **[nethogs][19]**: A bandwidth monitoring tool which groups active network connections by processes, and reports per-process (upload/download) bandwidth consumption in real-time.
|
||||
|
||||
48. **ngxtop**: A web-server access log parser and monitoring tool whose interface is inspired by top command. It can report, in real time, a sorted list of web requests along with frequency, size, HTTP return code, IP address, etc.
|
||||
|
||||
49. **vmstat**: A simple CLI tool which shows various run-time system properties such as process count, free memory, paging status, CPU utilization, block I/O activities, interrupt/context switch statistics, and more.
|
||||
|
||||
50. **iotop**: An ncurses-based I/O monitoring tool which shows in real time disk I/O activities of all running processes in sorted order.
|
||||
|
||||
51. **iostat**: A CLI tool which reports current CPU utilization, as well as device I/O utilization, where I/O utilization (e.g., block transfer rate, byte read/write rate) is reported on a per-device or per-partition basis.
|
||||
|
||||
### Productivity Tools ###
|
||||
|
||||
52. **screen**: Used to split a single terminal into multiple persistent virtual terminals, which can also be made accessible to remote users, like teamviewer-like screen sharing.
|
||||
|
||||
53. **tmux**: Another terminal multiplexer tool which enables multiple persistent sessions, as well as horizontal/vertial splits of a terminal.
|
||||
|
||||
54. **cheat**: A simple CLI tool which allows you to read cheat sheets of many common Linux commands, conveniently right at your fingertips. Pre-built cheat sheets are fully customizable.
|
||||
|
||||
55. **apropos**: Useful when you are searching man pages for descriptions or keywords.
|
||||
|
||||
### Package Management Tools ###
|
||||
|
||||
56. **apt**: The de facto package manager for Debian based systems like Debain, Ubuntu or Backtrack. A life saver.
|
||||
|
||||
57. **apt-fast**: A supporting utility for apt-get, which can significantly improve apt-get's download speed by using multiple concurrent connections.
|
||||
|
||||
58. **apt-file**: Used to find out which .deb package a specific file belongs to, or to show all files in a particular .deb package. Works on both installed and non-installed packages.
|
||||
|
||||
59. **dpkg**: A CLI utility to install a .deb package manually. Highly advised to use apt whenever possible.
|
||||
|
||||
60. **yum**: The de facto automatic package manager for Red Hat based systems like RHEL, CentOS or Fedora. Yet another life saver.
|
||||
|
||||
61. **rpm**: Typically I use rpmyum something. Has some useful parameters like -q, -f, -l for querying, files and locations, respectively.
|
||||
|
||||
### Hardware Tools ###
|
||||
|
||||
62. **lspci**: A command line tool which shows various information about installed PCI devices, such as model names, device drivers, capabilities, memory address, PCI bus address.
|
||||
|
||||
63. **lshw**: A command line tool which queries and displays detailed information of hardware configuration in various categories (e.g., processor, memory, motherboard, network, storage). Supports multiple output formats: html, xml, json, text.
|
||||
|
||||
64. **[inxi][20]**: A comprehensive hardware reporting tool which gives an overview of various hardware components such as CPU, graphics card, sound card, network card, temperature/fan sensors, etc.
|
||||
|
||||
If you would like to recommend any useful tool which is not listed here, feel free to share it in the comment section.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/2014/08/useful-cli-tools-linux-system-admins.html
|
||||
|
||||
作者:[Sarmed Rahman][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/sarmed
|
||||
[1]:http://www.hping.org/
|
||||
[2]:http://netcat.sourceforge.net/
|
||||
[3]:http://www.dest-unreach.org/socat/
|
||||
[4]:http://www.tcpdump.org/
|
||||
[5]:https://www.wireshark.org/docs/man-pages/tshark.html
|
||||
[6]:https://www.wireshark.org/docs/dfref/
|
||||
[7]:http://www.harding.motd.ca/autossh/
|
||||
[8]:http://elinks.or.cz/
|
||||
[9]:http://lynx.isc.org/
|
||||
[10]:http://www.netfilter.org/projects/iptables/
|
||||
[11]:http://nmap.org/
|
||||
[12]:http://en.wikipedia.org/wiki/TCP_Wrapper
|
||||
[13]:http://rkhunter.sourceforge.net/
|
||||
[14]:http://www.chkrootkit.org/
|
||||
[15]:http://www.gnu.org/software/parted/
|
||||
[16]:https://hackage.haskell.org/package/ztail
|
||||
[17]:http://rsync.samba.org/
|
||||
[18]:http://www.nongnu.org/rdiff-backup/
|
||||
[19]:http://nethogs.sourceforge.net/
|
||||
[20]:http://code.google.com/p/inxi/
|
||||
@@ -1,259 +0,0 @@
|
||||
[translating by KayGuoWhu]
|
||||
Linux TCP/IP networking: net-tools vs. iproute2
|
||||
================================================================================
|
||||
Many sysadmins still manage and troubleshoot various network configurations by using a combination of ifconfig, route, arp and netstat command-line tools, collectively known as net-tools. Originally rooted in the BSD TCP/IP toolkit, the net-tools was developed to configure network functionality of older Linux kernels. Its development in the Linux community so far has ceased since 2001. Some Linux distros such as Arch Linux and CentOS/RHEL 7 have already deprecated net-tools in favor of iproute2.
|
||||
|
||||
iproute2, which is another family of network configuration tools, emerged to replace the functionality of net-tools. While net-tools accesses and changes kernel network configurations via procfs (/proc) and ioctl system call, iproute2 communicates with the kernel via netlink socket interface. The /proc interface is known to be more heavyweight than netlink interface. Putting performance aside, the user interface of iproute2 is more intuitive than that of net-tools. For example, network resources (e.g., link, IP address, route, tunnel, etc.) are aptly defined with "object" abstraction, and you can manage different objects using consistant syntax. Most importantly, iproute2 has been under [active development][1] so far.
|
||||
|
||||
If you are still using net-tools, it is time to switch to iproute2, especially if you want to catch up with the latest and greatest networking features of the latest Linux kernel. Chances are that there are many things you can do with iproute2, but cannot with net-tools.
|
||||
|
||||
For those who want to make the switch, here is a round-up of net-tools vs. iproute2 comparison.
|
||||
|
||||
### Show All Connected Network Interfaces ###
|
||||
|
||||
The following commands show a list of all available network interfaces (whether or not they are active).
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ ifconfig -a
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ ip link show
|
||||
|
||||

|
||||
|
||||
### Activate or Deactivate a Network Interface ###
|
||||
|
||||
To activate/deactivate a particular network interface, use these commands.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ sudo ifconfig eth1 up
|
||||
$ sudo ifconfig eth1 down
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ sudo ip link set down eth1
|
||||
$ sudo ip link set up eth1
|
||||
|
||||
### Assign IPv4 address(es) to a Network Interface ###
|
||||
|
||||
Use these commands to configure IPv4 addresses of a network interface.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ sudo ifconfig eth1 10.0.0.1/24
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ sudo ip addr add 10.0.0.1/24 dev eth1
|
||||
|
||||
Note that with iproute2, you can assign multiple IP addresses to an interface, which you cannot do with ifconfig. A workaround for this with ifconfig is to use [IP aliases][2].
|
||||
|
||||
$ sudo ip addr add 10.0.0.1/24 broadcast 10.0.0.255 dev eth1
|
||||
$ sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth1
|
||||
$ sudo ip addr add 10.0.0.3/24 broadcast 10.0.0.255 dev eth1
|
||||
|
||||
### Remove an IPv4 address from a Network Interface ###
|
||||
|
||||
As far as IP address removal is concerned, there is no proper way to remove an IPv4 address from a network interface with net-tools, other than assigning 0 to the interface. iproute2 can properly handle this.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ sudo ifconfig eth1 0
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ sudo ip addr del 10.0.0.1/24 dev eth1
|
||||
|
||||
### Show IPv4 Address(es) of a Network Interface ###
|
||||
|
||||
Checking IPv4 addresses of a particular network interface can be done as follows.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ ifconfig eth1
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ ip addr show dev eth1
|
||||
|
||||
Again, if there are multiple IP addresses assigned to an interface, iproute2 shows all of them, while net-tools shows only one IP address.
|
||||
|
||||

|
||||
|
||||
### Assign an IPv6 address to a Network Interface ###
|
||||
|
||||
Use these commands to add IPv6 address(es) to a network interface. Both net-tools and iproute2 allow you to add multiple IPv6 addresses to an interface.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ sudo ifconfig eth1 inet6 add 2002:0db5:0:f102::1/64
|
||||
$ sudo ifconfig eth1 inet6 add 2003:0db5:0:f102::1/64
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ sudo ip -6 addr add 2002:0db5:0:f102::1/64 dev eth1
|
||||
$ sudo ip -6 addr add 2003:0db5:0:f102::1/64 dev eth1
|
||||
|
||||
### Show IPv6 address(es) of a Network Interface ###
|
||||
|
||||
Displaying IPv6 addresses of a particular network interface can be done as follows. Both net-tools and iproute2 can show all assigned IPv6 addresses.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ ifconfig eth1
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ ip -6 addr show dev eth1
|
||||
|
||||

|
||||
|
||||
### Remove an IPv6 address from a Network Interface ###
|
||||
|
||||
Use these commands to remove any unnecessary IPv6 address from an interface.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ sudo ifconfig eth1 inet6 del 2002:0db5:0:f102::1/64
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ sudo ip -6 addr del 2002:0db5:0:f102::1/64 dev eth1
|
||||
|
||||
### Change the MAC Address of a Network Interface ###
|
||||
|
||||
To [spoof the MAC address][3] of a network interface, use the commands below. Note that before changing the MAC address, you need to deactivate the interface first.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ sudo ifconfig eth1 hw ether 08:00:27:75:2a:66
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ sudo ip link set dev eth1 address 08:00:27:75:2a:67
|
||||
|
||||
### View the IP Routing Table ###
|
||||
|
||||
net-tools has two options for showing the kernel's IP routing table: route or netstat. With iproute2, use ip route command.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ route -n
|
||||
|
||||
----------
|
||||
|
||||
$ netstat -rn
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ ip route show
|
||||
|
||||

|
||||
|
||||
### Add or Modify a Default Route ###
|
||||
|
||||
Here are the commands to add or modify a default route in the kernel's IP routing table. Note that with net-tools, modifying a default route can be achieved by adding a new default route, and then removing an old default route. With iproute2, use ip route replace command.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ sudo route add default gw 192.168.1.2 eth0
|
||||
$ sudo route del default gw 192.168.1.1 eth0
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ sudo ip route add default via 192.168.1.2 dev eth0
|
||||
$ sudo ip route replace default via 192.168.1.2 dev eth0
|
||||
|
||||
### Add or Remove a Static Route ###
|
||||
|
||||
A static routing can be added or removed with the following commands.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ sudo route add -net 172.16.32.0/24 gw 192.168.1.1 dev eth0
|
||||
$ sudo route del -net 172.16.32.0/24
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ sudo ip route add 172.16.32.0/24 via 192.168.1.1 dev eth0
|
||||
$ sudo ip route del 172.16.32.0/24
|
||||
|
||||
### View Socket Statistics ###
|
||||
|
||||
Here are the commands to check socket statistics (e.g., active/listening TCP/UDP sockets).
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ netstat
|
||||
$ netstat -l
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ ss
|
||||
$ ss -l
|
||||
|
||||

|
||||
|
||||
### View the ARP Table ###
|
||||
|
||||
You can display the kernel's ARP table with these commands.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ arp -an
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ ip neigh
|
||||
|
||||

|
||||
|
||||
### Add or Remove a Static ARP Entry ###
|
||||
|
||||
Adding or removing a [static ARP entry][4] in the local ARP table is done as follows.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ sudo arp -s 192.168.1.100 00:0c:29:c0:5a:ef
|
||||
$ sudo arp -d 192.168.1.100
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ sudo ip neigh add 192.168.1.100 lladdr 00:0c:29:c0:5a:ef dev eth0
|
||||
$ sudo ip neigh del 192.168.1.100 dev eth0
|
||||
|
||||
### Add, Remove or View Multicast Addresses ###
|
||||
|
||||
To configure or view multicast addresses on a network interface, use the commands below.
|
||||
|
||||
With **net-tools**:
|
||||
|
||||
$ sudo ipmaddr add 33:44:00:00:00:01 dev eth0
|
||||
$ sudo ipmaddr del 33:44:00:00:00:01 dev eth0
|
||||
$ ipmaddr show dev eth0
|
||||
$ netstat -g
|
||||
|
||||
With **iproute2**:
|
||||
|
||||
$ sudo ip maddr add 33:44:00:00:00:01 dev eth0
|
||||
$ sudo ip maddr del 33:44:00:00:00:01 dev eth0
|
||||
$ ip maddr list dev eth0
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/2014/09/linux-tcpip-networking-net-tools-iproute2.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/nanni
|
||||
[1]:https://www.kernel.org/pub/linux/utils/net/iproute2/
|
||||
[2]:http://xmodulo.com/2013/02/how-to-assign-multiple-ip-addresses-to-one-network-interface-on-centos.html
|
||||
[3]:http://xmodulo.com/2014/02/spoof-mac-address-network-interface-linux.html
|
||||
[4]:http://xmodulo.com/2013/02/how-to-add-or-remove-static-arp-entry-on-linux.html
|
||||
@@ -1,249 +0,0 @@
|
||||
(translating by runningwater)
|
||||
How to install LEMP stack (nginx, MariaDB/MySQL and php) on CentOS
|
||||
================================================================================
|
||||
The LEMP stack is an increasingly popular web service stack, powering mission-critical web services in many production environments. As the name implies, the LEMP stack is composed of Linux, nginx, MariaDB/MySQL and PHP. nginx is a high performance and lightweight replacement of slow and hard-to-scale Apache HTTP server used in the traditional LAMP stack. MariaDB is a community-driven fork of MySQL, with more features and better performance. PHP, a server-side language for generating dynamic content, is processed by PHP-FPM, an enhanced implementation of PHP FastCGI.
|
||||
|
||||
In this tutorial, I demonstrate **how to set up the LEMP stack on CentOS platforms**. I target both CentOS 6 and CentOS 7 platforms, and point out differences where necessary.
|
||||
|
||||
### Step One: Nginx ###
|
||||
|
||||
As the first step, let's install nginx on CentOS, and do basic configuration for nginx, such as enabling auto-start and [customizing the firewall][1].
|
||||
|
||||
#### Install Nginx ####
|
||||
|
||||
Let's install a pre-built stable version of nginx package from its official RPM source.
|
||||
|
||||
On CentOS 7:
|
||||
|
||||
$ sudo rpm --import http://nginx.org/keys/nginx_signing.key
|
||||
$ sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
|
||||
$ sudo yum install nginx
|
||||
|
||||
On CentOS 6:
|
||||
|
||||
$ sudo rpm --import http://nginx.org/keys/nginx_signing.key
|
||||
$ sudo rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
|
||||
$ sudo yum install nginx
|
||||
|
||||
Note that if you do not import the official nginx GPG key before installing nginx RPM, you will get this warning:
|
||||
|
||||
warning: /var/tmp/rpm-tmp.KttVHD: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
|
||||
|
||||
#### Start Nginx ####
|
||||
|
||||
After installation, nginx does not start automatically. Let's start nginx right now, and configure it to auto-start upon boot. Also, we need to open a TCP/80 port in the firewall so that you can access nginx webserver remotely. All of these are achieved by entering the following commands.
|
||||
|
||||
On CentOS 7:
|
||||
|
||||
$ sudo systemctl start nginx
|
||||
$ sudo systemctl enable nginx
|
||||
$ sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
|
||||
$ sudo firewall-cmd --reload
|
||||
|
||||
On CentOS 6:
|
||||
|
||||
$ sudo service nginx start
|
||||
$ sudo chkconfig nginx on
|
||||
$ sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
|
||||
$ sudo service iptables save
|
||||
|
||||
#### Test Nginx ####
|
||||
|
||||
The default document root directory of nginx is /usr/share/nginx/html. A default index.html file must be already placed in this directory. Let's check if you can access this test web page by going to http://<nginx-ip-address>/
|
||||
|
||||

|
||||
|
||||
If you see the above page, nginx must be set up correctly. Proceed to the next.
|
||||
|
||||
### Step Two: MariaDB/MySQL ###
|
||||
|
||||
The next step is to install a database component of the LEMP stack. While CentOS/RHEL 6 or earlier provides MySQL server/client packages, CentOS/RHEL 7 has adopted MariaDB as the default implementation of MySQL. As a drop-in replacement of MySQL, MariaDB ensures maximum compatibility with MySQL in terms of APIs and command-line usages. Here is how to install and configure MariaDB/MySQL on CentOS.
|
||||
|
||||
On CentOS 7:
|
||||
|
||||
Install MariaDB server/client package and start MariaDB server as follows.
|
||||
|
||||
$ sudo yum install mariadb-server
|
||||
$ sudo systemctl start mariadb
|
||||
$ sudo systemctl enable mariadb
|
||||
|
||||
On CentOS 6:
|
||||
|
||||
Install MySQL server/client package, and start MySQL server as follows.
|
||||
|
||||
$ sudo yum install mysql-server
|
||||
$ sudo service mysqld start
|
||||
$ sudo chkconfig mysqld on
|
||||
|
||||
After launching MariaDB/MySQL server successfully, execute the following add-on script that comes with MariaDB/MySQL server package. This one-time run conducts several security hardening steps for the database server, such as setting the (non-empty) root password, removing anonymous user, and locking down remote access.
|
||||
|
||||
$ sudo mysql_secure_installation
|
||||
|
||||

|
||||
|
||||
That's it for the database setup. Now move to the next step.
|
||||
|
||||
### Step Three: PHP ###
|
||||
|
||||
PHP is an important component of the LEMP stack, which is responsible for generating dynamic content from data stored in a MariaDB/MySQL server. For the LEMP stack, you need, at a minimum, to install PHP-FPM and PHP-MySQL. PHP-FPM (FastCGI Process Manager) implements an interface between nginx and PHP applications which generate dynamic content. The PHP-MySQL module allows PHP programs to access MariaDB/MySQL.
|
||||
|
||||
#### Install PHP Modules ####
|
||||
|
||||
On CentOS 7:
|
||||
|
||||
$ sudo yum php php-fpm php-mysql
|
||||
|
||||
On CentOS 6:
|
||||
|
||||
First you need to install REMI repository (refer to [this guide][2]), and install the packages from the repository.
|
||||
|
||||
$ sudo yum --enablerepo=remi install php php-fpm php-mysql
|
||||
|
||||

|
||||
|
||||
Two observations worth noting while installing PHP:
|
||||
|
||||
On CentOS 6, MySQL server and client packages will automatically be upgraded as part of dependencies of the latest php-mysql in REMI.
|
||||
|
||||
On both CentOS 6 and 7, installing the php package will also install Apache web server (i.e., httpd) as part of its dependencies. This can cause conflicts with nginx web server. We will take care of this problem in the next section.
|
||||
|
||||
Depending on your use cases, you may want to install any of the following additional PHP module packages with yum command to customize your PHP engine.
|
||||
|
||||
- **php-cli**: command-line interface for PHP. Useful for testing PHP from the command line.
|
||||
- **php-gd**: image processing support for PHP.
|
||||
- **php-bcmath**: arbitrary mathematics support for PHP.
|
||||
- **php-mcrypt**: encryption algorithm support for PHP (e.g., DES, Blowfish, CBC, CFB, ECB ciphers).
|
||||
- **php-xml**: XML parsing and manipulation support for PHP.
|
||||
- **php-dba**: database abstraction layer support for PHP.
|
||||
- **php-pecl-apc**: PHP accelerator/caching support.
|
||||
|
||||
To see a complete list of available PHP modules to install, run:
|
||||
|
||||
$ sudo yum search php- (CentOS 7)
|
||||
$ sudo yum --enablerepo=remi search php- (CentOS 6)
|
||||
|
||||
#### Start PHP-FPM ####
|
||||
|
||||
You will need to start PHP-FPM, and add it to auto-start list.
|
||||
|
||||
On CentOS 7:
|
||||
|
||||
$ sudo systemctl start php-fpm
|
||||
$ sudo systemctl enable php-fpm
|
||||
|
||||
On CentOS 6:
|
||||
|
||||
$ sudo chkconfig php-fpm on
|
||||
$ sudo service php-fpm start
|
||||
|
||||
### Step Four: Configure the LEMP Stack ###
|
||||
|
||||
The final step of the tutorial is tuning the LEMP stack configuration.
|
||||
|
||||
#### Disable Httpd ####
|
||||
|
||||
Let's first disable httpd which was installed along with the PHP package earlier.
|
||||
|
||||
On CentOS 7:
|
||||
|
||||
$ sudo systemctl disable httpd
|
||||
|
||||
On CentOS 6:
|
||||
|
||||
$ sudo chkconfig httpd off
|
||||
|
||||
#### Configure Nginx ####
|
||||
|
||||
Next, let's configure nginx virtual hosts, so that nginx can process PHP via PHP-FPM. For that, open /etc/nginx/conf.d/default.conf with a text editor, and change it to the following.
|
||||
|
||||
$ sudo vi /etc/nginx/conf.d/default.conf
|
||||
|
||||
----------
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name www.server_domain.com;
|
||||
root /usr/share/nginx/html;
|
||||
index index.php index.html index.htm;
|
||||
|
||||
location / {
|
||||
}
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
}
|
||||
|
||||
# nginx passes PHP scripts to FastCGI server via a TCP/9000 socket
|
||||
# this setting much be consistent with /etc/php-fpm.d/www.conf
|
||||
# try_files prevents nginx from passing bad scripts to FastCGI server
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
||||
|
||||
Also, let's adjust the number of nginx worker threads (specified in /etc/nginx/nginx.conf), which is set to one by default. Typically, we create as many worker threads as the number of CPU cores you have. To check how many CPU core you have, run this command:
|
||||
|
||||
$ grep processor /proc/cpuinfo | wc -l
|
||||
|
||||
If you have 4 cores, change /etc/nginx/nginx.conf as follows.
|
||||
|
||||
$ sudo vi /etc/nginx/nginx.conf
|
||||
|
||||
----------
|
||||
|
||||
worker_processes 4;
|
||||
|
||||
#### Configure PHP ####
|
||||
|
||||
Next, let's customize PHP configuration in /etc/php.ini file. More specifically, add the following lines in /etc/php.ini.
|
||||
|
||||
cgi.fix_pathinfo=0
|
||||
date.timezone = "America/New York"
|
||||
|
||||
As a security precaution, we want the PHP interpreter to process only an exact file path, instead of guessing any non-existing file. The first line above achieves this goal.
|
||||
|
||||
The second line specifies the default timezone used by date/time related PHP functions. Use [this guide][3] to find out your timezone, and set the value of **date.timezone** accordingly.
|
||||
|
||||
#### Test PHP ####
|
||||
|
||||
Finally, let's check if nginx can process a PHP page. Before testing, make sure to restart nginx and PHP-FPM.
|
||||
|
||||
On CentOS 7:
|
||||
|
||||
$ sudo systemctl restart nginx
|
||||
$ sudo systemctl restart php-fpm
|
||||
|
||||
On CentOS 6:
|
||||
|
||||
$ sudo service nginx restart
|
||||
$ sudo service php-fpm restart
|
||||
|
||||
Create a PHP file named test.php with the following content, and place it in /var/www/html/
|
||||
|
||||
<?php phpinfo(); ?>
|
||||
|
||||
Open a web browser, and go to http://<nginx-ip-address>/test.php.
|
||||
|
||||

|
||||
|
||||
If you see the above page, you are all set with the LEMP stack!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/install-lemp-stack-centos.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[runningwater](https://github.com/runningwater)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/nanni
|
||||
[1]:http://ask.xmodulo.com/open-port-firewall-centos-rhel.html
|
||||
[2]:http://ask.xmodulo.com/install-remi-repository-centos-rhel.html
|
||||
[3]:http://ask.xmodulo.com/set-default-timezone-php.html
|
||||
@@ -1,214 +0,0 @@
|
||||
wangjiezhe translating...
|
||||
|
||||
What are some obscure but useful Vim commands
|
||||
================================================================================
|
||||
If my [latest post on the topic][1] did not tip you off, I am a Vim fan. So before some of you start stoning me, let me present you a list of "obscure Vim commands." What I mean by that is: a collection of commands that you might have not encountered before, but that might be useful to you. As a second disclaimer, I do not know which commands you might know and which one you find useful. So this list really is a collection of relatively less known Vim commands, but which can still probably be useful.
|
||||
|
||||
### Saving a file and exiting ###
|
||||
|
||||
I am a bit ashamed of myself for that one, but I only recently learned that the command
|
||||
|
||||
:x
|
||||
|
||||
is equivalent to:
|
||||
|
||||
:wq
|
||||
|
||||
which is saving and quitting the current file.
|
||||
|
||||
### Basic calculator ###
|
||||
|
||||
While in insert mode, you can press Ctrl+r then type '=' followed by a simple calculation. Press ENTER, and the result will be inserted in the document. For example, try:
|
||||
|
||||
Ctrl+r '=2+2' ENTER
|
||||
|
||||

|
||||
|
||||
And 4 will be inserted in the document.
|
||||
|
||||
### Finding duplicate consecutive words ###
|
||||
|
||||
When you type something quickly, it happens that you write a word twice in a row. Just like this this. This kind of error can fool anyone, even when re-reading yourself. Hopefully, there is a simple regular expression to prevent this. Use the search ('/' by default) and type:
|
||||
|
||||
\(\<\w\+\>\)\_s*\1
|
||||
|
||||
This should display all the duplicate words. And for maximum effect, don't forget to place:
|
||||
|
||||
set hlsearch
|
||||
|
||||
in your .vimrc file to highlight all search hits.
|
||||
|
||||

|
||||
|
||||
### Abbreviations ###
|
||||
|
||||
Probably one of the most impressive tricks, you can define abbreviations in Vim, which will replace what you type with somethig else in real time. The syntax is the following:
|
||||
|
||||
:ab [abbreviation] [what to replace it with]
|
||||
|
||||
The generic example is:
|
||||
|
||||
:ab asap as soon as possible
|
||||
|
||||
Which will replace "asap" with "as soon as possible" as you write.
|
||||
|
||||
### Save a file that you forgot to open as root ###
|
||||
|
||||
This is maybe an all time favorite in the forums. Whenever you open a file that you do not have permission to write to (say a system configuration file for example) and make some changes, Vim will not save them with the normal command: ':w'
|
||||
|
||||
Instead of redoing the changes after opening it again as root, simply run:
|
||||
|
||||
:w !sudo tee %
|
||||
|
||||
Which will save it as root directly.
|
||||
|
||||
### Crypt your text on the go ###
|
||||
|
||||
If you do not want someone to be able to read whatever is on your screen, Vim has the built in option to [ROT13][2]-encode your text with the following command:
|
||||
|
||||
ggVGg?
|
||||
|
||||

|
||||
|
||||
'gg' for moving the cursor to the first line of the Vim buffer, 'V' for entering visual mode, and 'G' for moving the cursor to the last line of the buffer. So 'ggVG' will make the visual mode cover the entire buffer. Finally 'g?' applies ROT13 encoding to the selected region.
|
||||
|
||||
Notice that this should be mapped to a key for maximum efficiency. It also works best with alphabetical characters. And to undo it, the best is simply to use the undo command: 'u'
|
||||
|
||||
### Auto-completion ###
|
||||
|
||||
Another one to be ashamed of, but I see a lot of people around me not knowing it. Vim has by default an auto-completion features. Yes it is very basic, and can be enhanced by plugins, but it can still help you. The process is simple. Vim can try to guess the end of your word based on the word you wrote earlier. If you are typing the word "compiler" for the second time in the same file for example, just start typing "com" and still in insertion mode, press Ctrl+n to see Vim finish your word for you. Simple but handy.
|
||||
|
||||
### Look at the diff between two files ###
|
||||
|
||||
Probably a lot of you know about vimdiff command, which allows you to open Vim in split mode and compare two files with the syntax:
|
||||
|
||||
$ vimdiff [file1] [file2]
|
||||
|
||||
But the same result is achievable with the Vim command:
|
||||
|
||||
:diffthis
|
||||
|
||||
First open your initial file in Vim. Then open the second one in split mode with:
|
||||
|
||||
:vsp [file2]
|
||||
|
||||
Finally launch:
|
||||
|
||||
:diffthis
|
||||
|
||||
in the first buffer, switch buffer with Ctrl+w and type:
|
||||
|
||||
:diffthis
|
||||
|
||||
again.
|
||||
|
||||
The two files will then be highlighted with focus on their differences.
|
||||
|
||||
To turn the diff off, simply use:
|
||||
|
||||
:diffoff
|
||||
|
||||
### Revert the document in time ###
|
||||
|
||||
Vim keeps track of the changes you make to a file, and can easily revert it to what it was earlier in time. The command is quite intuitive. For example:
|
||||
|
||||
:earlier 1m
|
||||
|
||||
will revert the document to what it was a minute ago.
|
||||
|
||||
Note that you can inverse this with the command:
|
||||
|
||||
:later
|
||||
|
||||
### Delete inside markers ###
|
||||
|
||||
Something that I always wanted to be comfortable doing when I started using Vim: easily delete text between brackets or parenthesis. Go to the first marker and simply use the syntax:
|
||||
|
||||
di[marker]
|
||||
|
||||
So for example, deleting between parenthesis would be:
|
||||
|
||||
di(
|
||||
|
||||
once your cursor is on the first parenthesis. For brackets or quotation marks, it would be:
|
||||
|
||||
di{
|
||||
|
||||
and:
|
||||
|
||||
di"
|
||||
|
||||
### Delete until a specific maker ###
|
||||
|
||||
A bit similar to deleting inside a marker but for different purpose, the command:
|
||||
|
||||
dt[marker]
|
||||
|
||||
will delete everything in between your cursor and the marker (leaving it safe) if the marker is found on the same line. For example:
|
||||
|
||||
dt.
|
||||
|
||||
will delete the end of your sentence, leaving the '.' intact.
|
||||
|
||||
### Turn Vim into a hex editor ###
|
||||
|
||||
This is not my favorite trick, but some might find it interesting. You can chain Vim and the xxd utility to convert the text into hexadecimal with the command:
|
||||
|
||||
:%!xxd
|
||||
|
||||

|
||||
|
||||
And similarly, you can revert this with:
|
||||
|
||||
:%!xxd -r
|
||||
|
||||
### Place the text under your cursor in the middle of the screen ###
|
||||
|
||||
Everything is in the title. If you want to force the screen to scroll and place whatever is under your cursor in the middle, use the command:
|
||||
|
||||
zz
|
||||
|
||||
in visual mode.
|
||||
|
||||
### Jump to previous/next position ###
|
||||
|
||||
When editing a very big file, it is frequent to make changes somewhere, and jump to another place right after. If you wish to jump back simply, use:
|
||||
|
||||
Ctrl+o
|
||||
|
||||
to go back to where you were.
|
||||
|
||||
And similarly:
|
||||
|
||||
Ctrl+i
|
||||
|
||||
will revert such jump back.
|
||||
|
||||
### Render the current file as a web page ###
|
||||
|
||||
This will generate an HTML page displaying your text, and show the code in a split screen:
|
||||
|
||||
:%Tohtml
|
||||
|
||||

|
||||
|
||||
Very basic but so fancy.
|
||||
|
||||
To conclude, this list was assembled after reading some various forum threads and the [Vim Tips wiki][3], which I really recommend if you want to boost your knowledge about the editor.
|
||||
|
||||
If you know any Vim command that you find useful and that you think most people do not know about, feel free to share it in the comments. As said in the introduction, an "obscure but useful" command is very subjective, but sharing is always good.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/useful-vim-commands.html
|
||||
|
||||
作者:[Adrien Brochard][a]
|
||||
译者:[wangjiezhe](https://github.com/wangjiezhe)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/adrien
|
||||
[1]:http://xmodulo.com/turn-vim-full-fledged-ide.html
|
||||
[2]:https://en.wikipedia.org/wiki/ROT13
|
||||
[3]:http://vim.wikia.com/wiki/Vim_Tips_Wiki
|
||||
@@ -0,0 +1,199 @@
|
||||
Restricting process CPU usage using nice, cpulimit, and cgroups
|
||||
================================================================================
|
||||
注:本文中的图片似乎都需要翻墙后才能看到,发布的时候注意
|
||||
|
||||

|
||||
|
||||
The Linux kernel is an incredible circus performer, carefully juggling many processes and their resource needs to keep your server humming along. The kernel is also all about equity: when there is competition for resources, the kernel tries to distribute those resources fairly.
|
||||
|
||||
However, what if you've got an important process that needs priority? What about a low-priority process? Or what about limiting resources for a group of a processes?
|
||||
|
||||
**The kernel can't determine what CPU processes are important without your help. **
|
||||
|
||||
Most processes are started at the same priority level and the Linux kernel schedules time for each task evenly on the processor. Have a CPU intensive process that can be run at a lower priority? Then you need to tell the scheduler about it!
|
||||
|
||||
There are at least three ways in which you can control how much CPU time a process gets:
|
||||
|
||||
- Use the nice command to manually lower the task's priority.
|
||||
- Use the cpulimit command to repeatedly pause the process so that it doesn’t exceed a certain limit.
|
||||
- Use Linux’s built-in **control groups**, a mechanism which tells the scheduler to limit the amount of resources available to the process.
|
||||
|
||||
Let's look at how these work and the pros and cons of each.
|
||||
|
||||
### Simulating high CPU usage ###
|
||||
|
||||
Before looking at these three techniques, we need to find a tool that will simulate high CPU usage on a system. We will be using CentOS as our base system, and to artificially load the processor we can use the prime number generator from the [Mathomatic toolkit][1].
|
||||
|
||||
There isn’t a prebuilt package for CentOS so you will need to build it yourself. Download the source code from http://mathomatic.orgserve.de/mathomatic-16.0.5.tar.bz2 and then unpack the archive file. Change directory into **mathomatic-16.0.5/primes**. Run **make** and **sudo make install** to build and install the binaries. You will now have the **matho-primes** binary in **/usr/local/bin**.
|
||||
|
||||
Run the command like this:
|
||||
|
||||
/usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
This will generate a list of prime numbers from zero to nine billion nine hundred ninety-nine million nine hundred ninety-nine thousand nine hundred ninety-nine. Since we don’t really want to keep the list, the output is redirected to /dev/null.
|
||||
|
||||
Now run top and you will see that the matho-primes process is using all the available CPU.
|
||||
|
||||

|
||||
|
||||
Exit top (press the q key) and kill the matho-primes process (fg to bring the process to the foreground and press CTRL+C).
|
||||
|
||||
### nice ###
|
||||
|
||||
The nice command tweaks the priority level of a process so that it runs less frequently. **This is useful when you need to run a CPU intensive task as a background or batch job**. The niceness level ranges from -20 (most favorable scheduling) to 19 (least favorable). Processes on Linux are started with a niceness of 0 by default. The nice command (without any additional parameters) will start a process with a niceness of 10. At that level the scheduler will see it as a lower priority task and give it less CPU resources.
|
||||
|
||||
Start two **matho-primes** tasks, one with nice and one without:
|
||||
|
||||
nice matho-primes 0 9999999999 > /dev/null &
|
||||
matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
Now run top.
|
||||
|
||||

|
||||
|
||||
Observe that the process started without nice (at niceness level 0) gets more processor time, whereas the process with a niceness level of 10 gets less.
|
||||
|
||||
What this means in real terms is that if you want to run a CPU intensive task you can start it using nice and the scheduler will always ensure that other tasks have priority over it. This means that the server (or desktop) will remain responsive even when under heavy load.
|
||||
|
||||
Nice has an associated command called renice. It changes the niceness level of an already running process. To use it, find out the PID of process hogging all the CPU time (using ps) and then run renice:
|
||||
|
||||
renice +10 1234
|
||||
|
||||
Where 1234 is the PID.
|
||||
|
||||
Don’t forget to kill the **matho-primes** processes once you have finished experimenting with the **nice** and **renice** commands.
|
||||
|
||||
### cpulimit ###
|
||||
|
||||
The **cpulimit** tool curbs the CPU usage of a process by pausing the process at different intervals to keep it under the defined ceiling. It does this by sending SIGSTOP and SIGCONT signals to the process. It does not change the **nice** value of the process, instead it monitors and controls the real-world CPU usage.
|
||||
|
||||
cpulimit **is useful when you want to ensure that a process doesn't use more than a certain portion of the CPU**. The disadvantage over nice is that the process can't use all of the available CPU time when the system is idle.
|
||||
|
||||
To install it on CentOS type:
|
||||
|
||||
wget -O cpulimit.zip https://github.com/opsengine/cpulimit/archive/master.zip
|
||||
unzip cpulimit.zip
|
||||
cd cpulimit-master
|
||||
make
|
||||
sudo cp src/cpulimit /usr/bin
|
||||
|
||||
The commands above will download the source code from GitHub, unpack the archive file, build the binary, and copy it to /usr/bin.
|
||||
|
||||
cpulimit is used in a similar way to nice, however you need to explicitly define the maximum CPU limit for the process using the ‘-l’ parameter. For example:
|
||||
|
||||
cpulimit -l 50 matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||

|
||||
|
||||
Note how the matho-primes process is now only using 50% of the available CPU time. On my example system the rest of the time is spent in idle.
|
||||
|
||||
You can also limit a currently running process by specifying its PID using the ‘-p’ parameter. For example
|
||||
|
||||
cpulimit -l 50 -p 1234
|
||||
|
||||
Where 1234 is the PID of the process.
|
||||
|
||||
### cgroups ###
|
||||
|
||||
Control groups (cgroups) are a Linux kernel feature that allows you to specify how the kernel should allocate specific resources to a group of processes. With cgroups you can specify how much CPU time, system memory, network bandwidth, or combinations of these resources can be used by the processes residing in a certain group.
|
||||
|
||||
**The advantage of control groups over** nice **or** cpulimit **is that the limits are applied to a set of processes, rather than to just one**. Also, nice or cpulimit only limit the CPU usage of a process, whereas cgroups can limit other process resources.
|
||||
|
||||
By judiciously using cgroups the resources of entire subsystems of a server can be controlled. For example in CoreOS, the minimal Linux distribution designed for massive server deployments, the upgrade processes are controlled by a cgroup. This means the downloading and installing of system updates doesn’t affect system performance.
|
||||
|
||||
To demonstrate cgroups, we will create two groups with different CPU resources allocated to each group. The groups will be called ‘cpulimited’ and ‘lesscpulimited’.
|
||||
|
||||
The groups are created with the cgcreate command like this:
|
||||
|
||||
sudo cgcreate -g cpu:/cpulimited
|
||||
sudo cgcreate -g cpu:/lesscpulimited
|
||||
|
||||
The “-g cpu” part of the command tell cgroups that the groups can place limits on the amount of CPU resources given to the processes in the group. Other contollers include cpuset, memory, and blkio. The cpuset controller is related to the cpu controller in that it allows the processes in a group to be bound to a specific CPU, or set of cores in a CPU.
|
||||
|
||||
The cpu controller has a property known as cpu.shares. It is used by the kernel to determine the share of CPU resources available to each process across the cgroups. The default value is 1024. By leaving one group (lesscpulimited) at the default of 1024 and setting the other (cpulimited) to 512, we are telling the kernel to split the CPU resources using a 2:1 ratio.
|
||||
|
||||
To set the cpu.shares to 512 in the cpulimited group, type:
|
||||
|
||||
sudo cgset -r cpu.shares=512 cpulimited
|
||||
|
||||
To start a task in a particular cgroup you can use the cgexec command. To test the two cgroups, start matho-primes in the cpulimited group, like this:
|
||||
|
||||
sudo cgexec -g cpu:cpulimited /usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
If you run top you will see that the process is taking all of the available CPU time.
|
||||
|
||||

|
||||
|
||||
This is because when a single process is running, it uses as much CPU as necessary, regardless of which cgroup it is placed in. The CPU limitation only comes into effect when two or more processes compete for CPU resources.
|
||||
|
||||
Now start a second matho-primes process, this time in the lesscpulimited group:
|
||||
|
||||
sudo cgexec -g cpu:lesscpulimited /usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||
The top command shows us that the process in the cgroup with the greater cpu.shares value is getting more CPU time.
|
||||
|
||||

|
||||
|
||||
Now start another matho-primes process in the cpulimited group:
|
||||
|
||||
sudo cgexec -g cpu:cpulimited /usr/local/bin/matho-primes 0 9999999999 > /dev/null &
|
||||
|
||||

|
||||
|
||||
Observe how the CPU is still being proportioned in a 2:1 ratio. Now the two matho-primes tasks in the cpulimited group are sharing the CPU equally, while the process in the other group still gets more processor time.
|
||||
|
||||
You can [read the full control groups documentation from Red Hat][2] (which applies equally to CentOS 7).
|
||||
|
||||
### Monitoring process CPU usage with Scout ###
|
||||
|
||||
What's the easiest way to monitor process CPU usage? [Scout][3] automatically tracks track process CPU + memory usage when our monitoring agent is installed on your servers.
|
||||
|
||||
### Monitoring process CPU usage with Scout ###
|
||||
|
||||
What's the easiest way to monitor process CPU usage? Scout automatically tracks track process CPU + memory usage when our monitoring agent is installed on your servers.
|
||||
|
||||

|
||||
|
||||
You can then create triggers to alert you when processes exceed specific CPU + memory usage thresholds.
|
||||
|
||||
[Signup for a free trial of Scout][4] to try process CPU monitoring.
|
||||
|
||||
### TL;DR ###
|
||||
|
||||

|
||||
|
||||
The finite resources of any server or desktop are a valuable commodity. The tools described above help you manage those resources, especially the CPU resource:
|
||||
|
||||
- **nice** is a great tool for 'one off' tweaks to a system.
|
||||
- **cpulimit** is useful when you need to run a CPU intensive job and having free CPU time is essential for the responsiveness of a system.
|
||||
- **cgroups** are the Swiss army knife of process limiting and offer the greatest flexibility.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://blog.scoutapp.com/articles/2014/11/04/restricting-process-cpu-usage-using-nice-cpulimit-and-cgroups
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://www.mathomatic.org/
|
||||
[2]:https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Resource_Management_and_Linux_Containers_Guide/chap-Introduction_to_Control_Groups.html
|
||||
[3]:https://scoutapp.com/
|
||||
[4]:https://scoutapp.com/
|
||||
[5]:
|
||||
[6]:
|
||||
[7]:
|
||||
[8]:
|
||||
[9]:
|
||||
[10]:
|
||||
[11]:
|
||||
[12]:
|
||||
[13]:
|
||||
[14]:
|
||||
[15]:
|
||||
[16]:
|
||||
[17]:
|
||||
[18]:
|
||||
[19]:
|
||||
[20]:
|
||||
112
sources/tech/20141118 How to boot on an ISO image from Grub.md
Normal file
112
sources/tech/20141118 How to boot on an ISO image from Grub.md
Normal file
@@ -0,0 +1,112 @@
|
||||
How to boot on an ISO image from Grub
|
||||
================================================================================
|
||||
If you need to use multiple Linux distributions, you do not have so many options. You can either install it, on your machine or in a virtual one, or you can boot on it from an ISO file in live mode. The second option, if less needy in hard drive space, is bothersome as you will need a USB stick or CD to hold the ISO file and boot from. However, there is a third alternative which is a bit of a compromise: have the ISO image on your hard drive, and boot into it in live mode at startup. Less needy in disk space than a full install, and fully functional, this seems to be a good alternative to a slow virtual machine. I will explain how to do this using the popular bootloader Grub.
|
||||
|
||||
### What do you need? ###
|
||||
|
||||
Obviously you will need to be using Grub, which is the case on pretty much all modern Linux distributions. You will also need to have an ISO file of the distribution of your choice, downloaded on your hard drive. Finally, you should know where your boot partition is, and how to express it in Grub language. For this, launch:
|
||||
|
||||
# fdisk -l
|
||||
|
||||
and the boot partition is the one with the '*'. For me it's /dev/sda1, which is written (hd0,1) in Grub language.
|
||||
|
||||

|
||||
|
||||
For reference, sda2 would be (hd0,2), sdb1 would be (hd1,1), etc. (You got the point).
|
||||
|
||||
### What do we edit? ###
|
||||
|
||||
First, open /etc/default/grub and check that the following line:
|
||||
|
||||
#GRUB_HIDDEN_TIMEOUT=0
|
||||
|
||||
is indeed commented with a '#' in front.
|
||||
|
||||
Save it and then go open /etc/grub.d/40_custom.
|
||||
|
||||
This file will be where you put the arguments to boot on an ISO. The structure is of the form:
|
||||
|
||||
menuentry "[Entry's title in the grub screen]" {
|
||||
set isofile="[path to ISO file]"
|
||||
loopback loop [boot partition in Grub language]$isofile
|
||||
[some specific] arguments
|
||||
}
|
||||
|
||||
For example, if you wish to boot Ubuntu from an ISO file, you want to append this to your 40_custom file:
|
||||
|
||||
menuentry "Ubuntu 14.04 (LTS) Live Desktop amd64" {
|
||||
set isofile="/boot/ubuntu-14.04-desktop-amd64.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=${isofile} quiet splash
|
||||
initrd (loop)/casper/initrd.lz
|
||||
}
|
||||
|
||||

|
||||
|
||||
If you would like to launch Gparted instead:
|
||||
|
||||
menuentry "GParted Live amd64" {
|
||||
set isofile="/boot/gparted-live-0.18.0-2-amd64.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
loopback loop $isofile
|
||||
linux (loop)/live/vmlinuz boot=live config union=aufs noswap noprompt ip=frommedia toram=filesystem.squashfs findiso=${isofile}
|
||||
initrd (loop)/live/initrd.img
|
||||
}
|
||||
|
||||
Or even Fedora:
|
||||
|
||||
menuentry "Fedora 20 Live Desktop x86_64" {
|
||||
set isofile="/boot/Fedora-Live-Desktop-x86_64-20-1.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
loopback loop $isofile
|
||||
linux (loop)/isolinux/vmlinuz0 root=live:CDLABEL=Fedora-Live-Desktop-x86_64-20-1 rootfstype=auto ro rd.live.image quiet rhgb rd.luks=0 rd.md=0 rd.dm=0 iso-scan/filename=${isofile}
|
||||
initrd (loop)/isolinux/initrd0.img
|
||||
}
|
||||
|
||||
Note that the arguments will change depending on the distribution. Hopefully, there are a few places where you can start looking. I like this one, but there are plenty of others. Also, take into consideration where you place your ISO files. If your home directory is encrypted or out of reach, you might prefer placing the files in your boot partition like in the example. But make sure that you have enough room first.
|
||||
|
||||
Finally, don't forget to save 40_custom and update grub with:
|
||||
|
||||
# sudo update-grub
|
||||
|
||||
to see your changes appear at the next boot.
|
||||
|
||||

|
||||
|
||||
### What next? ###
|
||||
|
||||
Want more? Well by playing a bit with the arguments, you can boot on an ISO and have it do something instantly. For example, if you are completely paranoid and wish to have an option to erase your hard drive quickly, it is possible to set up something using [DBAN][1]. Now be really careful as this will wipe your disk without recovery option on startup:
|
||||
|
||||
menuentry "Darik's Boot and Nuke" {
|
||||
set isofile="/boot/dban.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
linux (loop)/dban.bzi nuke="dwipe" silent
|
||||
}
|
||||
|
||||
Alternatively,
|
||||
|
||||
menuentry "Darik's Boot and Nuke" {
|
||||
set isofile="/boot/dban.iso"
|
||||
loopback loop (hd0,1)$isofile
|
||||
linux (loop)/dban.bzi
|
||||
}
|
||||
|
||||
will show you the DBAN's options and let you choose to wipe your drive. **Be careful as it is still very dangerous**.
|
||||
|
||||
To conclude, there are plenty of things to do with ISO files and Grub: whether you want a quick live session or prefer to destroy everything with the tip of your finger. The next step would be to launch some privacy focused distribution like [Tails][2] for example.
|
||||
|
||||
What do you think of booting on an ISO from Grub? Is it something you would consider doing? And why? Let us know in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/boot-iso-image-from-grub.html
|
||||
|
||||
作者:[Adrien Brochard][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/adrien
|
||||
[1]:http://www.dban.org/
|
||||
[2]:https://tails.boum.org/
|
||||
@@ -0,0 +1,179 @@
|
||||
Linux FAQs with Answers--How to install phpMyAdmin on CentOS
|
||||
================================================================================
|
||||
> **Question**: I am running a MySQL/MariaDB server on CentOS, and I would like to manage its databases via web-based interface using phpMyAdmin. What is a proper way to install phpMyAdmin on CentOS?
|
||||
|
||||
phpMyAdmin is an open-source PHP application designed as a web-based MySQL/MariaDB database administration tool. While there exist lightweight database management tools such as [Adminer][1], phpMyAdmin is more popularly used among webmasters to conduct various MySQL/MariaDB administration tasks. It supports pretty much all MySQL database/table related operations such as browse, create, copy, drop, rename, alter, as well as MySQL user/privilege management, and database import/export. Here is **how to install phpMyAdmin on CentOS 6 or 7**.
|
||||
|
||||
### Prerequisites ###
|
||||
|
||||
To install phpMyAdmin on CentOS, you first need to set up a web server (e.g., Apache or nginx), MySQL/MariaDB and PHP. Depending on your preference or requirement, you can choose to install either [LAMP stack][2] or [LEMP stack][3].
|
||||
|
||||
Another requirement is to enable EPEL repository on your CentOS. Follow [this guide][4] to set up EPEL repository if you haven't done so.
|
||||
|
||||
### Install phpMyAdmin on CentOS 6 or 7 ###
|
||||
|
||||
Once you set up EPEL repository, you can install phpMyAdmin easily with yum command as follows.
|
||||
|
||||
On CentOS 7:
|
||||
|
||||
$ sudo yum install phpmyadmin
|
||||
|
||||
On CentOS 6:
|
||||
|
||||
$ sudo yum install phpmyadmin php-mcrypt
|
||||
|
||||
### Configure phpMyAdmin on CentOS 7 ###
|
||||
|
||||
By default, phpMyAdmin on CentOS 7 allows access only from loopback address (127.0.0.1). To enable remote access, you will need to update its configuration.
|
||||
|
||||
Open phpMyAdmin's configuration (/etc/httpd/conf.d/phpMyAdmin.conf) with a text editor. Find and comment out every line that says "Require ip XXXX". There will be four such lines. Add "Require all granted" instead. The updated configuration file will look like the following.
|
||||
|
||||
$ sudo vi /etc/httpd/conf.d/phpMyAdmin.conf
|
||||
|
||||
----------
|
||||
|
||||
. . . . .
|
||||
<Directory /usr/share/phpMyAdmin/>
|
||||
AddDefaultCharset UTF-8
|
||||
|
||||
<IfModule mod_authz_core.c>
|
||||
# Apache 2.4
|
||||
<RequireAny>
|
||||
#Require ip 127.0.0.1
|
||||
#Require ip ::1
|
||||
Require all granted
|
||||
</RequireAny>
|
||||
</IfModule>
|
||||
<IfModule !mod_authz_core.c>
|
||||
# Apache 2.2
|
||||
Order Deny,Allow
|
||||
Deny from All
|
||||
Allow from 127.0.0.1
|
||||
Allow from ::1
|
||||
</IfModule>
|
||||
</Directory>
|
||||
|
||||
<Directory /usr/share/phpMyAdmin/setup/>
|
||||
<IfModule mod_authz_core.c>
|
||||
# Apache 2.4
|
||||
<RequireAny>
|
||||
#Require ip 127.0.0.1
|
||||
#Require ip ::1
|
||||
Require all granted
|
||||
</RequireAny>
|
||||
</IfModule>
|
||||
<IfModule !mod_authz_core.c>
|
||||
# Apache 2.2
|
||||
Order Deny,Allow
|
||||
Deny from All
|
||||
Allow from 127.0.0.1
|
||||
Allow from ::1
|
||||
</IfModule>
|
||||
</Directory>
|
||||
. . . . .
|
||||
|
||||
Finally, restart httpd to activate the change.
|
||||
|
||||
$ sudo systemctl restart httpd
|
||||
|
||||
### Configure phpMyAdmin on CentOS 6 ###
|
||||
|
||||
By default, phpMyAdmin on CentOS 6 blocks access from every IP address. To enable remote access, you will need to update its configuration.
|
||||
|
||||
Open phpMyAdmin's configuration (/etc/httpd/conf.d/phpmyadmin.conf) with a text editor. Find a line that says "Deny from all", and comment it out. Then change the line that says "Allow from 127.0.0.1" to "Allow from 0.0.0.0". The updated configuration will look like the following.
|
||||
|
||||
$ sudo vi /etc/httpd/conf.d/phpmyadmin.conf
|
||||
|
||||
----------
|
||||
|
||||
<Directory "/usr/share/phpmyadmin">
|
||||
Order Deny,Allow
|
||||
# Deny from all
|
||||
Allow from 0.0.0.0
|
||||
</Directory>
|
||||
|
||||
The next step is to add a blowfish password to the phpMyAdmin's configuration. This step is needed to encrypt password in cookie as part of cookie-based authentication.
|
||||
|
||||
Open the following file with a text editor, and set a random blowfish password as follows.
|
||||
|
||||
$ sudo vi /usr/share/phpmyadmin/config.inc.php
|
||||
|
||||
----------
|
||||
|
||||
$cfg['blowfish_secret'] = 'kd5G}d33aXDc50!'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
|
||||
|
||||
Finally, restart httpd to activate the change.
|
||||
|
||||
$ sudo service httpd restart
|
||||
|
||||
### Test phpMyAdmin ###
|
||||
|
||||
To test if phpMyAdmin is successfully set up, go to http://<web-server-ip-addresss>/phpmyadmin
|
||||
|
||||

|
||||
|
||||
You should be able to log with any MySQL user (e.g., root), and manage MySQL/MariaDB databases/tables via a web-based interface.
|
||||
|
||||

|
||||
|
||||
### Troubleshooting ###
|
||||
|
||||
Here are a few troubleshooting tips during phpMyAdmin installation on CentOS.
|
||||
|
||||
1. When you are trying to access phpMyAdmin page in web browser, you are getting "403 Forbidding" error with:
|
||||
|
||||
You don't have permission to access /phpMyAdmin on this server.
|
||||
|
||||
This error is happening because the default setting of phpMyAdmin blocks access from a remote IP address. To fix this error, you need to edit its configuration to allow remote access. See the above for more detail.
|
||||
|
||||
2. When you access phpMyAdmin page, you are seeing "The configuration file now needs a secret passphrase (blowfish_secret)." message, and you cannot login.
|
||||
|
||||
To fix this error, you need to edit /usr/share/phpmyadmin/config.inc.php to add a random blowfish password as follows, and restart httpd.
|
||||
|
||||
$cfg['blowfish_secret'] = 'kd5G}d33aXDc50!'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
|
||||
|
||||
----------
|
||||
|
||||
$ sudo service httpd restart (CentOS 6)
|
||||
$ sudo systemctl restart httpd (CentOS 7)
|
||||
|
||||
3. When you access phpMyAdmin page, you are getting "Cannot load mcrypt extension. Please check your PHP configuration" error message.
|
||||
|
||||
To solve this error, install the following package:
|
||||
|
||||
$ sudo yum install php-mcrypt
|
||||
|
||||
and restart httpd:
|
||||
|
||||
$ sudo service httpd restart (CentOS 6)
|
||||
$ sudo systemctl restart httpd (CentOS 7)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/install-phpmyadmin-centos.html
|
||||
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://xmodulo.com/set-web-based-database-management-system-adminer.html
|
||||
[2]:http://xmodulo.com/install-lamp-stack-centos.html
|
||||
[3]:http://xmodulo.com/install-lemp-stack-centos.html
|
||||
[4]:http://xmodulo.com/how-to-set-up-epel-repository-on-centos.html
|
||||
[5]:
|
||||
[6]:
|
||||
[7]:
|
||||
[8]:
|
||||
[9]:
|
||||
[10]:
|
||||
[11]:
|
||||
[12]:
|
||||
[13]:
|
||||
[14]:
|
||||
[15]:
|
||||
[16]:
|
||||
[17]:
|
||||
[18]:
|
||||
[19]:
|
||||
[20]:
|
||||
@@ -1,79 +0,0 @@
|
||||
安卓编年史 02
|
||||
=============================================================================
|
||||

|
||||
左:Milestone 5,主屏幕展示了“All”按钮,两个dock图标,以及四个最近使用的应用。中:主屏幕与打开的应用程序列表。右边:电源菜单。
|
||||
Ron Amadeo供图
|
||||
|
||||
### 安卓0.5, Milestone 5——如今已经是报废接口的领地了 ###
|
||||
|
||||
“M5-RC14”版本发布后——也就是第一个安卓模拟器发布三个月之后,安卓迎来了它的首次重大革新。 2008年2月发布的“Milestone5”甩掉了延伸自黑莓的界面,走向一个完全革新的设计——谷歌在触控友好界面上的第一次尝试。
|
||||
|
||||
在浏览器的用户代理字符串的中,此版本仍然被识别为“Android 0.5”,但Milestone 5与安卓的第一个版本相比已经完全不一样了。几个核心的Android功能直接追踪他们的血统并最终回到这个版本。通知面板的布局和功能几乎已经整装待发,并且,除了样式变化外,菜单也最终成型。距离安卓1.0项目发布的时间仅仅只剩八个月,一个操作系统的基础已经开始成型了。
|
||||
|
||||
有一件东西目前绝对不是它的最终模样,那就是是主屏幕。这是一个不可配置的,单屏壁纸的应用程序的抽屉和dock。应用程序图标是气泡状的,三种颜色的组合,由一个圆角矩形的白色背景包围着。应用程序抽屉在右下角有一个“所有”按钮,轻按它,打开的应用程序列表显示在了左边。这个“所有”按钮正上面的是两个dock图标,“联系人”和“拨号盘”分别获得了永久的专属主屏幕位置。然后上边有四个模块,它们是最近应用程序的早期版本,展示了最后访问的应用程序。没有了左侧屏幕和右侧屏幕,要是没有dock和最近的应用程序占用的一整列,这种布局下只能放下21个应用程序图标。模拟器仍然只选择同等最少的应用程序,但在实际的设备中,这样的设计看起来并不会很好的工作效果。
|
||||
|
||||
按住“挂断”按钮会出现一个十分早期版本的电源菜单,就像你最右侧的图片中看到的。谷歌迄今为止没有标准的智能手机命名术语:对于“Turn Off Screen”(关闭屏幕)最好的形容也许是“Lock screen”(锁定屏幕——虽然当时没有锁屏)和“Turn Off Radio”(关闭射频)在今天被叫做“Airplane Mode”(飞行模式)。
|
||||
|
||||

|
||||
从左至右依次为:令人惊喜的现代通知面板,谷歌地图的菜单在打开着(地图已经不可用了),和新的触控友好列表视图。
|
||||
Ron Amadeo供图
|
||||
|
||||
回溯到Milestone 5,谷歌在那时对通知面板有着明确的认识。就像在任何现代的智能手机里一样,通知中心从屏幕顶部下拉下来来唤出。目前的通知都以列表的形式显示。通知面板的第一个版本是不透明的白色薄片以及底部中心有个橙色圆点的,带着棱纹的的“把手”。通知是可点击的,通过点击可以打开该通知关联的应用程序。没有人为此列表中垂直对齐应用程序图标而感到困扰,不过也没关系,随着接下来的更新,它已经是过去式了。
|
||||
|
||||
置顶通知能够进入一个在面板顶部的“正在进行”的部分。在这个版本中,这里似乎只包含通话。在“最近事件”里的通知只有打开相应的应用程序后才清楚。用户惊喜地发现可以通过内置的XMPP连接成功登录到谷歌talk。不过,虽然通知面板中显示“新会话信息”,这里实际上并不是一个即时消息应用程序。
|
||||
|
||||
Milestone 5里是全新的艺术设计。应用程序图标被重新绘制,并且菜单从一个无聊的黑莓风格的文本列表转变为一个全彩、卡通的大图标方阵。通知面板图标也从简单的、突兀的、白色的图标切换到一个绿色的气泡设计。当时信号指示下边有一条奇怪的黑线,没有明显的作用。早期开发版本的微小列表视图不适合手指使用,所以Milestone 5带来了更加强大的整体布局。
|
||||
|
||||

|
||||
拨号盘,最近通话,和来电。
|
||||
Ron Amadeo供图
|
||||
|
||||
M5是第一个有一个拨号盘的版本,即使她是一个相当难看的版本。数字被显示在包含一个奇怪的聊天气泡风格退格键的渐变填充条里,看上去就像是从其他界面回收回来的。对齐问题随处可见。按钮上的数字没有正确的垂直排列,而且退格键的“X”也没有与对话框对齐。由于屏幕上没有的“拨号”按钮,你甚至不能从拨号盘打个电话,它强制要求有个拨号的硬件实体按钮。
|
||||
|
||||
Milestone 5 有几个选项卡式界面,所有这些都演示了一个关于标签应该如何工作的奇怪的想法。活跃的标签是白色的,而背景标签是底部拥有一小条白色条带的黑色标签。后台标签应该是向下下沉的吗?切换标签时,是没有动画效果的。直到目前还不清楚这个设计试图想表达什么。
|
||||
|
||||
在第二张图片中显示的最近通话记录项,是从单独的应用程序降级到拨号盘选项卡的。它抛弃了早期版本疯狂的十字UI,多亏了大块列表视图,现在所有必要的信息都是显示在一个正常的列表中。
|
||||
|
||||
不同于拨号盘,来电画面有显示在屏幕上的按钮来接听和结束通话。奇怪的是,来电屏幕贴在屏幕的底部,而不是顶部或中心。它可能是从旧的黑莓4:3屏幕遗留下来的问题。
|
||||
|
||||

|
||||
通话中,触摸屏不可用的显示错误信息,和显示第二通话暂停的通话界面。
|
||||
Ron Amadeo供图
|
||||
|
||||
通话中界面看起来正常,但在实际中毫无意义。今天,在通话中为了阻止你的脸按到按钮,手机近距离传感器一旦检测到物体会关闭屏幕。尽管Milestone 5不支持近距离传感器。谷歌的随意的解决方案是在通话过程中禁用整个触摸屏。与此同时,通话中的屏幕显然会检测触摸。这时候是有大的,可触摸的按钮; *就是不让你摸*。
|
||||
|
||||
M5在这里让Milestone 3版本的几个功能回归了。许多旧的界面里体面的图标被替换成了文本。像“静音”按钮在激活的时候不再提供屏幕上的反馈。合并通话被完全去除了。
|
||||
|
||||

|
||||
浏览器的主要菜单,浏览器的二级菜单,疯狂的变焦控制和窗口界面。
|
||||
Ron Amadeo供图
|
||||
|
||||
浏览器菜单中得到了常规的触摸功能大整修,并且“更多”按钮第一次出现。它充当一个[你菜单的额外菜单] [1]。相对于将3x2的网格变成3x4的网格,Milestone 5(以及Android的许多后续版本一样)中使用很长的、滚动的列表来引出其他选项。不支持双指缩放(据说是[向苹果让步] [2]),因此Android运行荒谬的控件,就像上边第三张图片一样。谷歌将它显示在屏幕的中间,而不是明智地设置成比如一个水平的、底部对齐的缩放控件。最后一张图片显示浏览器的“窗口”界面,允许你打开多个网页并在它们之间更轻松地切换。
|
||||
|
||||

|
||||
谷歌地图的图层选择,搜索界面,以及路线界面。
|
||||
Ron Amadeo供图
|
||||
|
||||
谷歌地图仍然不能使用,但我们接触的小小UI却有了显著更新。你可以选择地图图层,虽然只有两种可以选择:卫星和交通。顶部对齐的搜索界面奇怪地隐藏了状态栏,而底部对齐的路线没有隐藏状态栏。路线的输入按钮被标有“Go”,而且搜索的输入按钮被标有一个奇怪的弯曲的箭头。这样的例子不胜枚举,并演示了保守的安卓在最坏时候的情况:在同一个应用程序,外观和工作方式*应该*类似的两个功能,在实现上却完全相反。
|
||||
|
||||
----------
|
||||
|
||||

|
||||
|
||||
[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/2/
|
||||
|
||||
译者:[cereuz](https://github.com/cereuz)邮箱:[cereuz](mailto:sunedo@qq.com)
|
||||
校对:[alim0x](https://github.com/alim0x)/[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[1]:http://i.imgur.com/GIYGTnb.jpg
|
||||
[2]:http://www.businessinsider.com/steve-jobs-on-android-founder-andy-rubin-big-arrogant-f-2013-11
|
||||
[a]:http://arstechnica.com/author/ronamadeo
|
||||
[t]:https://twitter.com/RonAmadeo
|
||||
@@ -0,0 +1,185 @@
|
||||
对Linux系统管理员有帮助的命令行工具
|
||||
================================================================================
|
||||
系统管理员(sysadmins)负责日常维护生产系统和服务。其中一个关键任务就是保证功能性服务能24小时工作。为了这个,他们得很小心地计划备份方式,灾难管理策略,定时维护,安全审查,等等。和任意其他管理一样,系统管理员也有他们的必备工具。在正确的时间正确的情况下使用合适的工具,可以帮助维护操作系统的健壮,达到最小的服务中断时间和最大的运行时间。
|
||||
|
||||
这篇文章会介绍一些系统管理员日常活动中最常用和有效的命令行工具。如果你想推荐其他没在这里列出来的好用的工具,别忘了在评论区里分享一下。
|
||||
|
||||
### 网络工具 ###
|
||||
|
||||
1. **ping**:通过ICMP回应/回复报文来检查远端主机的端到端连接性(RTT延时,抖动,丢包)。用来检查系统状态和可连接性很不错。
|
||||
|
||||
2. **[phping][1]**:网络扫描和检测工具,可以产生ICMP/TCP/UDP ping数据包。常常用于高级端口扫描,防火墙测试,手动MTU路径发现和碎片测试。
|
||||
|
||||
3. **traceroute**:通过TTL限定的ICMP/UDP/TCP侦测包来发现从本地主机到远端目标主机之间的第三层转发路径。用来调试网络连接性和路由问题。
|
||||
|
||||
4. **mtr**:traceroute的一个变种,能根据运行时统计数据整理出每一跳的包丢失/抖动。用来评估路由路径延时很不错。
|
||||
|
||||
5. **[netcat][2]/[socat][3]**:TCP/IP网络里的瑞士军刀,可以读/写TCP/UDP协议字节流。用来调试防火墙策略和服务可用性很不错。
|
||||
|
||||
6. **dig**:DNS调试工具,可以生成正向查询,反向查询,搜索域名服务器,检查CNAME,MX和其他DNS记录。可以在侦错的时候查询特定的DNS服务器。
|
||||
|
||||
7. **nslookup**:另外一个DNS检查/调试工具。支持所有DNS查询和记录。可以查询特定DNS服务器。
|
||||
|
||||
8. **dnsyo**:一个DNS测试工具,通过对全世界1500个不同网络中的大量开放解析器执行DNS查询来测试DNS传输。
|
||||
|
||||
9. **lsof**:显示进程打开的文件信息(例如,普通文件,管道或套接字)。用来监视网络连接很不错。
|
||||
|
||||
10. **iftop**:一个基于ncurses的命令行界面应用,可以实时监视各个网络物理接口上的网络连接和带宽占用。用来记录霸占带宽的应用、用户、目的地和端口等很不错。
|
||||
|
||||
11. **netstat**:一个网络统计工具,可以显示状态以及统计信息,当前网络连接(TCP/UDP端口,IP地址)、路由表、TX/RX traffic以及网络协议。用来做网络相关诊断和性能调试很不错。
|
||||
|
||||
12. **[tcpdump][4]**:一个常用的基于libpcap抓包库的包侦测工具。可以按伯克利包过滤器格式定义抓包条件。
|
||||
|
||||
13. **[tshark][5]**:另一个命令行抓包工具,和它的GUI版本Wireshark完全兼容。支持[1000种协议][6]而且这个列表还在增加。用来调试、分析和保存实时网络封包信息很不错。
|
||||
|
||||
14. **ip**:一个多功能的命令行网络工具,是iproute2包的一部分。可以检查和修改路由表、网络设备状态以及IP隧道设置。用来查看路由表、增加/删除静态路由、配置网络接口、以及调试路由问题很有用。
|
||||
|
||||
15. **ifup/ifdown**:用来激活和关闭特定的网络接口。经常用于重启整个网络服务。
|
||||
|
||||
16. **[autossh][7]**:一个能建立SSH连接并在断线后自动重新连接的程序。用来创建长时间保持的穿越严格企业网络的SSH隧道很有用。
|
||||
|
||||
17. **iperf**:一个网络测试工具,通过在发送自定义TCP/UDP数据流来衡量主机间双向最大吞吐量。
|
||||
|
||||
18. **[elinks][8]/[lynx][9]**:为基于命令行的服务器环境下使用的基于文字的网页浏览器。
|
||||
|
||||
### 安全工具 ###
|
||||
|
||||
19. **[iptables][10]**:一个用户空间下的命令行工具,用于配置Linux内核防火墙。可以创建和修改Linux内核空间的网络包接收、转发和发送规则。
|
||||
|
||||
20. **[nmap][11]**:一个常用的为了安全审查目的的端口扫描和网络发现工具。用来在本地网络中找出哪些主机开机并运行起来了以及某台特定主机打开了哪些端口很有用。
|
||||
|
||||
21. **[TCP Wrappers][12]**:一个主机端的网络访问控制列表工具,可以过滤进入/出去的网络请求/回复。经常配合iptables一起使用,作为额外一层安全保护。
|
||||
|
||||
22. **getfacl/setfacl**:查看和定制文件和目录的访问控制列表,作为传统文件权限的扩展。
|
||||
|
||||
23. **cryptsetup**:用于创建和管理LUKS加密磁盘分区。
|
||||
|
||||
24. **lynis**:一个命令行的漏洞扫描工具。可以扫描整个Linux系统,并汇报潜在的漏洞以及相关可能解决方案。
|
||||
|
||||
25. **maldet**:一个恶意软件扫描命令行工具,可以检测和隔离潜在的感染文件。可以在后台运行长期监视。
|
||||
|
||||
26. **[rkhunter][13]/[chkrootkit][14]**:一个命令行工具,可以扫描本地系统里的潜在木马、隐藏后门和可疑利用,并禁用它们。
|
||||
|
||||
### 存储工具 ###
|
||||
|
||||
27. **fdisk**:一个磁盘分区编辑工具。用于查看、创建和修改本地磁盘或可移动磁盘的分区。
|
||||
|
||||
28. **sfdisk**:fdisk的一个变种,能用一种非交互的方式访问或更新磁盘分区表。用来自动化备份和恢复过程中的磁盘分区很有用。
|
||||
|
||||
29. **[parted][15]**:另一个磁盘分区编辑器,支持超过2TB的磁盘的GPT(GUID分区表)格式。gparted是parted的一个前端GTK+图形界面。
|
||||
|
||||
30. **df**:用来查看不同分区或文件路径的已用/可用存储空间和挂载点。存在一个用户友好的变种dfc。
|
||||
|
||||
31. **du**:用来查看不同文件和目录的当前磁盘占用情况(例如,du -sh *)。
|
||||
|
||||
32. **mkfs**:一个磁盘格式化命令,用来在独立磁盘分区上建立文件系统。有多个文件系统相关的版本:ext2、ext3、ext4、bfs、ntfs、vfat/fat。
|
||||
|
||||
33. **fsck**:一个命令行工具,用来检查文件系统错误并尝试可能的修复。通常在启动时自动运行,但是在卸载一个分区后也可以根据需要手动运行。
|
||||
|
||||
34. **mount**:用来映射一个物理磁盘分区、网络共享或远程存储到一个本地挂载点。任何对挂载点里的读/写操作都是对应实际存储的实际数据读/写。
|
||||
|
||||
35. **mdadm**:一个命令行工具,用来管理物理块设备上的软件RAID设备。可以创建、构造、增长或监视RAID阵列。
|
||||
|
||||
36. **lvm**:一套命令行工具集,用来管理卷分组和物理/逻辑卷,可以用最小的停机时间在多个物理磁盘上创建、调整大小、拆分和合并卷。
|
||||
|
||||
### 日志访问工具 ###
|
||||
|
||||
37. **tail**:用来查看一个(增长中的)日志文件的尾部。有几个变种,包括multitail(多窗口查看)和[ztail][16](支持inotify和正则表达式过滤以及颜色)。
|
||||
|
||||
38. **logrotate**:一个命令行工具,可以在根据设定的时间段拆分、压缩并邮寄旧的/大的日志文件。用来管理可能产生大量日志文件的繁忙主机很有用。
|
||||
|
||||
39. **grep/egrep**:可以通过特定的模式或正则表达式过滤日志内容。变种包括用户更友好的ack和速度更快的ag。
|
||||
|
||||
40. **awk**:一个多功能的文本扫描和处理工具。常用于从文本/日志文件中找出特定的列或内容,并输出给其他工具。
|
||||
|
||||
41. **sed**:一个文本流编辑工具,可以过滤和改变(例如,删除行/空格、替换/转换单词、增加计数)文本流并通过管道连接到stdout/stderr或者其他工具。
|
||||
|
||||
### 备份工具 ###
|
||||
|
||||
42. **[rsync][17]**:一个快速的单向增量备份和镜像工具。常用于复制一个数据仓库到线下存储,可以选择通过SSH或stunnel的加密连接。
|
||||
|
||||
43. **[rdiff-backup][18]**:另一个有效利用带宽的增量备份工具。管理两个连续快照之间的差分。
|
||||
|
||||
44. **duplicity**:一个加密的增量备份工具。使用GnuPG加密备份,并通过SSH上传到远程服务器。
|
||||
|
||||
### 性能监视工具 ###
|
||||
|
||||
45. **top**:一个命令行的进程查看程序。可以监视系统负载、进程状态、CPU和内存占用。有一个更用户友好的变种htop。
|
||||
|
||||
46. **ps**:显示系统所有运行中进程的一个快照。输出可以定制成显示PID、PPID、用户、负载、内存、积累的用户/系统时间、启动时间、以及更多。有一个变种是pstree可以用树结构显示进程。
|
||||
|
||||
47. **[nethogs][19]**:一个带宽监视工具,按进程来分组显示活动网络连接,实时汇报每个进程占用的(上传/下载)带宽。
|
||||
|
||||
48. **ngxtop**:一个网页服务器访问日志解析和监视工具,界面是受top命令启发。它可以实时汇报整理过的页面请求列表,包括频率、大小、HTTP返回值、IP地址,等等。
|
||||
|
||||
49. **vmstat**:一个简单的命令行工具,可以显示多个实时系统特征,例如进程数、剩余内存、分页状态、CPU占用、块设备I/O活动、中断/上下文切换统计、等等。
|
||||
|
||||
50. **iotop**:一个基于ncurses的I/O监视工具,可以实时排序显示所有运行中进程的磁盘I/O活动。
|
||||
|
||||
51. **iostat**:一个命令行工具,可以汇报当前CPU使用情况,以及设备I/O使用情况,这里的I/O使用情况(例如,块传输速度、字节读/写速度)是按设备或分区来汇报的。
|
||||
|
||||
### 效率工具 ###
|
||||
|
||||
52. **screen**:用来把一个单一的终端拆分成多个持久的虚拟终端,也支持远程用户访问,类似teamviewer的屏幕分享功能。
|
||||
|
||||
53. **tmux**:另一个终端复用工具,可以支持多个长期会话,还可以横向/纵向拆分终端。
|
||||
|
||||
54. **cheat**:一个简单的命令行工具,可以让你查看多个常用Linux命令的备忘录,就在手边非常方便。内建的备忘录也可以完全定制。
|
||||
|
||||
55. **apropos**:用来在帮助手册里查找描述或关键字很有用。
|
||||
|
||||
### 包管理工具 ###
|
||||
|
||||
56. **apt**:基于Debian系统的事实上的包管理工具,例如Debian、Ubuntu或Backtrack。一个救生圈。
|
||||
|
||||
57. **apt-fast**:apt-get的一个支撑应用,可以通过多个并行连接明显提高apt-get的下载速度。
|
||||
|
||||
58. **apt-file**:用来查看某个特定文件属于哪个.deb包,或者显示一个特定.deb包里的所有文件。已安装和未安装的包都能支持。
|
||||
|
||||
59. **dpkg**:一个用来手动安装.deb包的命令行工具。强烈建议尽可能的使用apt。
|
||||
|
||||
60. **yum**:基于红帽的系统的事实上的自动包管理工具,比如RHEL、CentOS或Fedora。另一个救生圈。
|
||||
|
||||
61. **rpm**:通常我都是rpmyum一下。有很多有用的参数,比如-q、-f、-l可以分别用来查询、指定文件和路径。
|
||||
|
||||
### 硬件工具 ###
|
||||
|
||||
62. **lspci**:一个命令行工具,可以显示已安装的PCI设备的各种信息,比如型号名称、设备驱动、设备功能、内存地址、PCI总线地址。
|
||||
|
||||
63. **lshw**:一个命令行工具,可以查询和显示不同分类下的硬件配置的详细信息(例如,处理器、内存、主板、网络、存储)。支持多重输出格式:html、xml、json、text。
|
||||
|
||||
64. **[inxi][20]**:一个综合硬件查看工具,可以提供不同硬件模块的总览,例如CPU,显卡,声卡,网卡,温度/风扇传感器,等等。
|
||||
|
||||
如果你希望推荐没有列在这里的好用的工具,不要客气,在评论区里分享一下。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/2014/08/useful-cli-tools-linux-system-admins.html
|
||||
|
||||
作者:[Sarmed Rahman][a]
|
||||
译者:[zpl1025](https://github.com/zpl1025)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/sarmed
|
||||
[1]:http://www.hping.org/
|
||||
[2]:http://netcat.sourceforge.net/
|
||||
[3]:http://www.dest-unreach.org/socat/
|
||||
[4]:http://www.tcpdump.org/
|
||||
[5]:https://www.wireshark.org/docs/man-pages/tshark.html
|
||||
[6]:https://www.wireshark.org/docs/dfref/
|
||||
[7]:http://www.harding.motd.ca/autossh/
|
||||
[8]:http://elinks.or.cz/
|
||||
[9]:http://lynx.isc.org/
|
||||
[10]:http://www.netfilter.org/projects/iptables/
|
||||
[11]:http://nmap.org/
|
||||
[12]:http://en.wikipedia.org/wiki/TCP_Wrapper
|
||||
[13]:http://rkhunter.sourceforge.net/
|
||||
[14]:http://www.chkrootkit.org/
|
||||
[15]:http://www.gnu.org/software/parted/
|
||||
[16]:https://hackage.haskell.org/package/ztail
|
||||
[17]:http://rsync.samba.org/
|
||||
[18]:http://www.nongnu.org/rdiff-backup/
|
||||
[19]:http://nethogs.sourceforge.net/
|
||||
[20]:http://code.google.com/p/inxi/
|
||||
@@ -0,0 +1,234 @@
|
||||
Linux 中的TCP/IP网络配置:net-tools vs. iproute2
|
||||
================================================================================
|
||||
如今很多系统管理员依然通过组合使用诸如ifconfig、route、arp和netstat等命令行工具(统称为net-tools)来配置网络功能,解决网络故障。net-tools起源于BSD的TCP/IP工具箱,后来成为老版本Linux内核中配置网络功能的工具。但自2001年起,Linux社区已经对其停止维护。同时,一些比如Arch Linux和CentOS/RHEL 7的Linux发行版则已经完全抛弃了net-tools,以支持iproute2。
|
||||
|
||||
作为网络配置工具的一份子,iproute2的出现旨在在功能上取代net-tools。net-tools通过procfs(/proc)和ioctl系统调用去访问和改变内核网络配置,而iproute2则通过netlink套接字接口与内核通讯。抛开性能而言,iproute2的用户接口比net-tools显得更加直观。比如,各种网络资源(如link、IP地址、路由和隧道等)均使用合适的对象抽象去定义,使得用户可使用一致的语法去管理不同的对象。更重要的是,到目前为止,iproute2仍处在[持续开发][1]中。
|
||||
|
||||
如果你仍在使用net-tools,而且尤其需要跟上新版Linux内核中的最新最重要的网络特性的话,那么是时候转到iproute2的阵营了。原因就在于使用iproute2可以做很多net-tools无法做到的事情。
|
||||
|
||||
对于那些想要转到使用iproute2的用户,有必要了解下面有关net-tools和iproute2的众多对比。
|
||||
|
||||
### 显示所有已连接的网络接口 ###
|
||||
|
||||
下面的命令显示出所有可用网络接口的列表(无论接口是否激活)。
|
||||
|
||||
使用**net-tools**:
|
||||
|
||||
$ ifconfig -a
|
||||
|
||||
使用**iproute2**:
|
||||
|
||||
$ ip link show
|
||||
|
||||

|
||||
|
||||
### 激活或停用网络接口 ###
|
||||
|
||||
使用这些命令来激活或停用某个指定的网络接口。
|
||||
|
||||
使用**net-tools**:
|
||||
$ sudo ifconfig eth1 up
|
||||
$ sudo ifconfig eth1 down
|
||||
|
||||
使用**iproute2**:
|
||||
$ sudo ip link set down eth1
|
||||
$ sudo ip link set up eth1
|
||||
|
||||
### 为网络接口分配IPv4地址 ###
|
||||
|
||||
使用这些命令配置网络接口的IPv4地址。
|
||||
|
||||
使用**net-tools**:
|
||||
$ sudo ifconfig eth1 10.0.0.1/24
|
||||
|
||||
使用**iproute2**:
|
||||
$ sudo ip addr add 10.0.0.1/24 dev eth1
|
||||
|
||||
值得注意的是,可以使用iproute2给同一个接口分配多个IP地址,ifconfig则无法这么做。使用ifconfig的变通方案是使用[IP别名][2]。
|
||||
|
||||
$ sudo ip addr add 10.0.0.1/24 broadcast 10.0.0.255 dev eth1
|
||||
$ sudo ip addr add 10.0.0.2/24 broadcast 10.0.0.255 dev eth1
|
||||
$ sudo ip addr add 10.0.0.3/24 broadcast 10.0.0.255 dev eth1
|
||||
|
||||
### 移除网络接口的IPv4地址 ###
|
||||
|
||||
就IP地址的移除而言,除了给接口分配全0地址外,net-tools没有提供任何合适的方法来移除网络接口的IPv4地址。相反,iproute2则能很好地完全。
|
||||
|
||||
使用**net-tools**:
|
||||
$ sudo ifconfig eth1 0
|
||||
|
||||
使用**iproute2**:
|
||||
$ sudo ip addr del 10.0.0.1/24 dev eth1
|
||||
|
||||
### 显示网络接口的IPv4地址 ###
|
||||
|
||||
按照如下操作可查看某个指定网络接口的IPv4地址。
|
||||
|
||||
使用**net-tools**:
|
||||
$ ifconfig eth1
|
||||
|
||||
使用**iproute2**:
|
||||
$ ip addr show dev eth1
|
||||
|
||||
同样,如果接口分配了多个IP地址,iproute2会显示出所有地址,而net-tools只能显示一个IP地址。
|
||||
|
||||

|
||||
|
||||
### 为网络接口分配IPv6地址 ###
|
||||
|
||||
使用这些命令为网络接口添加IPv6地址。net-tools和iproute2都允许用户为一个接口添加多个IPv6地址。
|
||||
|
||||
使用**net-tools**:
|
||||
$ sudo ifconfig eth1 inet6 add 2002:0db5:0:f102::1/64
|
||||
$ sudo ifconfig eth1 inet6 add 2003:0db5:0:f102::1/64
|
||||
|
||||
使用**iproute2**:
|
||||
$ sudo ip -6 addr add 2002:0db5:0:f102::1/64 dev eth1
|
||||
$ sudo ip -6 addr add 2003:0db5:0:f102::1/64 dev eth1
|
||||
|
||||
### 显示网络接口的IPv6地址 ###
|
||||
|
||||
按照如下操作可显示某个指定网络接口的IPv6地。net-tools和iproute2都可以显示出所有已分配的IPv6地址。
|
||||
|
||||
使用**net-tools**:
|
||||
$ ifconfig eth1
|
||||
|
||||
使用**iproute2**:
|
||||
$ ip -6 addr show dev eth1
|
||||
|
||||

|
||||
|
||||
### 移除网络设备的IPv6地址 ###
|
||||
|
||||
使用这些命令可移除接口中不必要的IPv6地址。
|
||||
|
||||
使用**net-tools**:
|
||||
$ sudo ifconfig eth1 inet6 del 2002:0db5:0:f102::1/64
|
||||
|
||||
使用**iproute2**:
|
||||
$ sudo ip -6 addr del 2002:0db5:0:f102::1/64 dev eth1
|
||||
|
||||
### 改变网络接口的MAC地址 ###
|
||||
|
||||
使用下面的命令可[篡改网络接口的MAC地址][3],请注意在更改MAC地址前,需要停用接口。
|
||||
|
||||
使用**net-tools**:
|
||||
$ sudo ifconfig eth1 hw ether 08:00:27:75:2a:66
|
||||
|
||||
使用**iproute2**:
|
||||
$ sudo ip link set dev eth1 address 08:00:27:75:2a:67
|
||||
|
||||
### 查看IP路由表 ###
|
||||
|
||||
net-tools中有两个选择来显示内核的IP路由表:route和netstat。在iproute2中,使用命令ip route。
|
||||
|
||||
使用**net-tools**:
|
||||
$ route -n
|
||||
|
||||
----------
|
||||
|
||||
$ netstat -rn
|
||||
|
||||
使用**iproute2**:
|
||||
|
||||
$ ip route show
|
||||
|
||||

|
||||
|
||||
### 添加和修改默认路由 ###
|
||||
|
||||
这里的命令用来添加或修改内核IP路由表中的默认路由规则。请注意在net-tools中可通过添加新的默认路由、删除旧的默认路由来实现修改默认路由。在iproute2使用ip route命令来代替。
|
||||
|
||||
使用**net-tools**:
|
||||
$ sudo route add default gw 192.168.1.2 eth0
|
||||
$ sudo route del default gw 192.168.1.1 eth0
|
||||
|
||||
使用**iproute2**:
|
||||
$ sudo ip route add default via 192.168.1.2 dev eth0
|
||||
$ sudo ip route replace default via 192.168.1.2 dev eth0
|
||||
|
||||
### 添加和移除静态路由 ###
|
||||
|
||||
使用下面命令添加或移除一个静态路由。
|
||||
|
||||
使用**net-tools**:
|
||||
$ sudo route add -net 172.16.32.0/24 gw 192.168.1.1 dev eth0
|
||||
$ sudo route del -net 172.16.32.0/24
|
||||
|
||||
使用**iproute2**:
|
||||
$ sudo ip route add 172.16.32.0/24 via 192.168.1.1 dev eth0
|
||||
$ sudo ip route del 172.16.32.0/24
|
||||
|
||||
### 查看套接字统计信息 ###
|
||||
|
||||
这里的命令用来查看套接字统计信息(比如活跃或监听状态的TCP/UDP套接字)。
|
||||
|
||||
使用**net-tools**:
|
||||
|
||||
$ netstat
|
||||
$ netstat -l
|
||||
|
||||
使用**iproute2**:
|
||||
$ ss
|
||||
$ ss -l
|
||||
|
||||

|
||||
|
||||
### 查看ARP表 ###
|
||||
|
||||
使用这些命令显示内核的ARP表。
|
||||
|
||||
使用**net-tools**:
|
||||
$ arp -an
|
||||
|
||||
使用**iproute2**:
|
||||
|
||||
$ ip neigh
|
||||
|
||||

|
||||
|
||||
### 添加或删除静态ARP项 ###
|
||||
|
||||
按照如下操作在本地ARP表中添加或删除一个[静态ARP项][4]。
|
||||
|
||||
使用**net-tools**:
|
||||
$ sudo arp -s 192.168.1.100 00:0c:29:c0:5a:ef
|
||||
$ sudo arp -d 192.168.1.100
|
||||
|
||||
使用**iproute2**:
|
||||
|
||||
$ sudo ip neigh add 192.168.1.100 lladdr 00:0c:29:c0:5a:ef dev eth0
|
||||
$ sudo ip neigh del 192.168.1.100 dev eth0
|
||||
|
||||
### 添加、删除或查看多播地址 ###
|
||||
|
||||
使用下面的命令配置或查看网络接口上的多播地址。
|
||||
|
||||
使用**net-tools**:
|
||||
|
||||
$ sudo ipmaddr add 33:44:00:00:00:01 dev eth0
|
||||
$ sudo ipmaddr del 33:44:00:00:00:01 dev eth0
|
||||
$ ipmaddr show dev eth0
|
||||
$ netstat -g
|
||||
|
||||
使用**iproute2**:
|
||||
|
||||
$ sudo ip maddr add 33:44:00:00:00:01 dev eth0
|
||||
$ sudo ip maddr del 33:44:00:00:00:01 dev eth0
|
||||
$ ip maddr list dev eth0
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/2014/09/linux-tcpip-networking-net-tools-iproute2.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[KayGuoWhu](https://github.com/KayGuoWhu)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/nanni
|
||||
[1]:https://www.kernel.org/pub/linux/utils/net/iproute2/
|
||||
[2]:http://xmodulo.com/2013/02/how-to-assign-multiple-ip-addresses-to-one-network-interface-on-centos.html
|
||||
[3]:http://xmodulo.com/2014/02/spoof-mac-address-network-interface-linux.html
|
||||
[4]:http://xmodulo.com/2013/02/how-to-add-or-remove-static-arp-entry-on-linux.html
|
||||
@@ -0,0 +1,248 @@
|
||||
CentOS 下安装 LEMP 包(nginx、MariaDB/MySQL 和 php)
|
||||
================================================================================
|
||||
LEMP 组合包是一款日益流行的网站服务组合软件包,在许多生产环境中的核心网站服务上起着强有力的作用。正如其名称所暗示的, LEMP 包是由 Linux、ngix、MariaDB/MySQL 和 PHP 组成的。在传统的 LAMP 包中使用的 Apache HTTP 协议服务器性能低下而且难于大规模集群,相比来说 ngix 的高性能及轻量级等特性,正是其的替代方案。 MariaDB 是一款社区支持驱动的 MySQL 数据库的分支,其功能更多性能更佳。PHP,服务端编程语言,具体是由 PHP FastCGI 的增强版 PHP-FPM 组件来处理,生成网页动态内容。
|
||||
|
||||
这篇文章里,我们示范**如何在 CentOS 操作平台上安装 LEMP 包**。我们安装的目标是 CentOS 6 和 CentOS 7 两个操作平台,如有必要会指出它们的不同。
|
||||
|
||||
### 第一步: Nginx ###
|
||||
|
||||
让我们在 CentOS 上安装 nginx 作为第一步,然后对它作些基本的配置,比如使其能自启动和[对防火墙做个性化设置][1]。
|
||||
|
||||
#### 安装 Nginx ####
|
||||
|
||||
让我们从它的官方的 RPM 源来安装一个预构建的稳定版本的 nginx 包。
|
||||
|
||||
在 CentOS 7 系统上:
|
||||
|
||||
$ sudo rpm --import http://nginx.org/keys/nginx_signing.key
|
||||
$ sudo rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
|
||||
$ sudo yum install nginx
|
||||
|
||||
在 CentOS 6 系统上:
|
||||
|
||||
$ sudo rpm --import http://nginx.org/keys/nginx_signing.key
|
||||
$ sudo rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
|
||||
$ sudo yum install nginx
|
||||
|
||||
注意在安装 nginx RPM 包之前,如果您没有导入 nginx 的官方 GPG 密钥的话,会出一如下所示的警告:
|
||||
|
||||
warning: /var/tmp/rpm-tmp.KttVHD: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
|
||||
|
||||
#### 启动 Nginx ####
|
||||
|
||||
安装完成后,nginx 是不会自动启动的。现在让我们来启动它吧,还要做些配置让其可以随着操作系统启动而启动。我们也需要在防火墙里打开 TCP/80 端口,以使得可以远程访问 nginx 的 web 服务。所有这些操作、设置都只需要输入如下命令就可实现。
|
||||
|
||||
在 CentOS 7 系统上:
|
||||
|
||||
$ sudo systemctl start nginx
|
||||
$ sudo systemctl enable nginx
|
||||
$ sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
|
||||
$ sudo firewall-cmd --reload
|
||||
|
||||
在 CentOS 6 系统上:
|
||||
|
||||
$ sudo service nginx start
|
||||
$ sudo chkconfig nginx on
|
||||
$ sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
|
||||
$ sudo service iptables save
|
||||
|
||||
#### 测试 Nginx ####
|
||||
|
||||
nginx 的默认文档要目录是 /usr/share/nginx/html。默认的 index.html 文件一定已经在这目录下了。让我们检测下是否可以访问到这个测试 web 页,输入 http://<nginx-ip-address>/ 访问。
|
||||
|
||||

|
||||
|
||||
如果您看到的是如上所示的页面的话,说明 nginx 已经正常启动。继续往下。
|
||||
|
||||
### 第二步: MariaDB/MySQL ###
|
||||
|
||||
下一步就是安装 LEMP 包的数据库组件。CentOS/RHEL 6 或早期的版本中提供的是 MySQL 的服务/客户端安装包,但 CentOS/RHEL 7 已使用了 MySQL 默认实现的版本 MariaDB。作为 MySQL 的简单替代品,MariaDB 保证了与 MySQL 的 API 和命令行用法方面最大的兼容性。下面是关于怎么在 CentOS 上安装和配置 MaraDB/MySQL 的操作示例。
|
||||
|
||||
在 CentOS 7 系统上:
|
||||
|
||||
如下所示操作来安装 MariaDB 服务/客户端包以及启动 MariaDB 服务。
|
||||
|
||||
$ sudo yum install mariadb-server
|
||||
$ sudo systemctl start mariadb
|
||||
$ sudo systemctl enable mariadb
|
||||
|
||||
在 CentOS 6 系统上:
|
||||
|
||||
如下示,安装 MySQL 服务/客户端包并且启动 MySQL 服务。
|
||||
|
||||
$ sudo yum install mysql-server
|
||||
$ sudo service mysqld start
|
||||
$ sudo chkconfig mysqld on
|
||||
|
||||
在成功启动 MariaDB/MySQL 服务后,执行在 MariaDB/MySQL 服务包中的脚本。这一次的运行会为为数据库服务器进行一些安全强化措施,如设置(非空)的 root 密码、删除匿名用户、锁定远程访问。
|
||||
|
||||
$ sudo mysql_secure_installation
|
||||
|
||||

|
||||
|
||||
这就是数据库的设置。现在进行下一步。
|
||||
|
||||
### 第三步: PHP ###
|
||||
|
||||
PHP 是 LEMP 包中一个重要的组件,它负责把存储在 MariaDB/MySQL 服务器的数据取出生成动态内容。为了 LEMP 可用,您至少需要安装上 PHP-FPM 和 PHP-MySQL 两个模块。PHP-FPM(FastCGI 进程管理器)实现的是 nginx 服务器和生成动态内容的 PHP 应用程序的访问接口。PHP-MySQL 模块使 PHP 程序能访问 MariaDB/MySQL 数据库。
|
||||
|
||||
#### 安装 PHP 模块 ####
|
||||
|
||||
在 CentOS 7 系统上:
|
||||
|
||||
$ sudo yum php php-fpm php-mysql
|
||||
|
||||
在 CentOS 6 系统上:
|
||||
|
||||
首先,您需要从仓库中安装 REMI 库(参见[本指南][2]),并安装软件包。
|
||||
|
||||
$ sudo yum --enablerepo=remi install php php-fpm php-mysql
|
||||
|
||||

|
||||
|
||||
在安装 PHP 时,得注意两个地方:
|
||||
|
||||
在 CentOS 6 系统中,安装 REMI仓库中最新的 php-mysql 模块时,MySQL 的服务端包和客户端包会被当做一部分依赖包而自动的更新。
|
||||
|
||||
在 CentOS 6 和 CentOS 7 中,在安装 PHP 包的同时会把 Apache web 服务器(即 httpd)当做它的依赖包一起安装。这会跟 nginx web 服务器起冲突。这个问题会在下一节来讨论。
|
||||
|
||||
取决于您的使用情况,可以使用 yum 命令来定制您的 PHP 引擎,也许会想安装下面的任意一个扩展 PHP 模块包。
|
||||
|
||||
- **php-cli**: PHP 的命令行界面。从命令行里测试 PHP 时非常有用。
|
||||
- **php-gd**: PHP 的图像处理支持。
|
||||
- **php-bcmath**: PHP 的数学支持。
|
||||
- **php-mcrypt**: PHP 的加密算法支持 (例如 DES、Blowfish、CBC、 CFB、ECB ciphers 等)。
|
||||
- **php-xml**: PHP 的 XML 解析和处理支持。
|
||||
- **php-dba**: PHP 的数据抽象层支持。
|
||||
- **php-pecl-apc**: PHP 加速器/缓存支持。
|
||||
|
||||
安装时,要查看可用的 PHP 模块的完整列表的话,可以运行:
|
||||
|
||||
$ sudo yum search php- (CentOS 7)
|
||||
$ sudo yum --enablerepo=remi search php- (CentOS 6)
|
||||
|
||||
#### 启动 PHP-FPM ####
|
||||
|
||||
您需要启动 PHP-FPM ,然后把它加放自动启动服务列表。
|
||||
|
||||
在 CentOS 7 系统上:
|
||||
|
||||
$ sudo systemctl start php-fpm
|
||||
$ sudo systemctl enable php-fpm
|
||||
|
||||
在 CentOS 6 系统上:
|
||||
|
||||
$ sudo chkconfig php-fpm on
|
||||
$ sudo service php-fpm start
|
||||
|
||||
### 第四步: 配置 LEMP 组合包 ###
|
||||
|
||||
本教程的最后一步是调整 LEMP 组合包的配置。
|
||||
|
||||
#### 使 Httpd 不可用 ####
|
||||
|
||||
首先,让我们把早先随 PHP 包安装的 httpd 服务给禁用掉。
|
||||
|
||||
在 CentOS 7 系统上:
|
||||
|
||||
$ sudo systemctl disable httpd
|
||||
|
||||
在 CentOS 6 系统上:
|
||||
|
||||
$ sudo chkconfig httpd off
|
||||
|
||||
#### 配置 Nginx ####
|
||||
|
||||
接下来,让我们配置 nginx 虚拟主机,使得 nginx 可以通过 PHP-FPM 来处理 PHP 的任务。用文本编辑器打开 /etc/nginx/conf.d/default.conf ,然后按如下所示修改。
|
||||
|
||||
$ sudo vi /etc/nginx/conf.d/default.conf
|
||||
|
||||
----------
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name www.server_domain.com;
|
||||
root /usr/share/nginx/html;
|
||||
index index.php index.html index.htm;
|
||||
|
||||
location / {
|
||||
}
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
}
|
||||
|
||||
# nginx passes PHP scripts to FastCGI server via a TCP/9000 socket
|
||||
# this setting much be consistent with /etc/php-fpm.d/www.conf
|
||||
# try_files prevents nginx from passing bad scripts to FastCGI server
|
||||
location ~ \.php$ {
|
||||
try_files $uri =404;
|
||||
fastcgi_pass 127.0.0.1:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
||||
|
||||
nginx 的默认工作线程(在 /etc/nginx/nginx.conf 文件中指定的)数是一个,让我们也来调整一下这个数字。通常来说我们创建的工作线程数应该和 CPU 核数相同。要确信您的 CPU 的核数,请运行下面这命令:
|
||||
|
||||
$ grep processor /proc/cpuinfo | wc -l
|
||||
|
||||
如果您的 CPU 是 4 核的,就如下所示修改 /etc/nginx/nginx.conf 文件。
|
||||
|
||||
$ sudo vi /etc/nginx/nginx.conf
|
||||
|
||||
----------
|
||||
|
||||
worker_processes 4;
|
||||
|
||||
#### 配置 PHP ####
|
||||
|
||||
接下来,让我们对 PHP 的配置文件 /etc/php.ini 做自定义设置。更具体的就是在 /etc/php.ini 文件中增加以下两行。
|
||||
|
||||
cgi.fix_pathinfo=0
|
||||
date.timezone = "America/New York"
|
||||
|
||||
为了安全起见,我们希望的是 PHP 解释器只是处理指定文件路径的文件任务,而不是预测搜索一些并不存在的文件任务。上面的第一行起的就是这个作用。
|
||||
|
||||
第二行定义的是 PHP 中 日期/时间相关函数使用相关的默认时区。使用[本指南] [3],找出您所在的时区,并设置相应 **date.timezone 的值**。
|
||||
|
||||
#### 测试 PHP ####
|
||||
|
||||
最后,让我们来测试下 nginx 是否能处理 PHP 页面。在测试之前,请确保重启 nginx 和 PHP-FPM。
|
||||
|
||||
在 CentOS 7 系统上:
|
||||
|
||||
$ sudo systemctl restart nginx
|
||||
$ sudo systemctl restart php-fpm
|
||||
|
||||
在 CentOS 6 系统上:
|
||||
|
||||
$ sudo service nginx restart
|
||||
$ sudo service php-fpm restart
|
||||
|
||||
创建一个叫名叫 test.php 的文件,然后写入如下内容,并放入 /var/www/html/ 目录。
|
||||
|
||||
<?php phpinfo(); ?>
|
||||
|
||||
打开浏览器,输入 http://<nginx-ip-address>/test.php 。
|
||||
|
||||

|
||||
|
||||
如果您能看到如上所示的页面,说明设置的 LEMP 完全成功!
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/install-lemp-stack-centos.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[runningwater](https://github.com/runningwater)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/nanni
|
||||
[1]:http://ask.xmodulo.com/open-port-firewall-centos-rhel.html
|
||||
[2]:http://ask.xmodulo.com/install-remi-repository-centos-rhel.html
|
||||
[3]:http://ask.xmodulo.com/set-default-timezone-php.html
|
||||
@@ -0,0 +1,214 @@
|
||||
一些不起眼但非常有用的 Vim 命令
|
||||
================================================================================
|
||||
如果我的[关于这个话题的最新帖子][1]没有提醒到你的话,那我明确地说,我是一个 Vim 的粉丝。所以在你们中的某些人向我扔石头之前,我先向你们展示一系列“鲜为人知的 Vim 命令”。我的意思是,一些你可能以前没有碰到过的命令,但可能对你来说很有用。作为第二免责声明,我不知道哪些命令是你可能知道的,以及哪些是对你来说有用的。因此这些命令实际上是一些相对少见,但很可能很有用的 Vim 命令。
|
||||
|
||||
### 保存文件并退出 ###
|
||||
|
||||
说起来有些惭愧,我也是最近才学到这个命令
|
||||
|
||||
:x
|
||||
|
||||
和下面的命令是等价的:
|
||||
|
||||
:wq
|
||||
|
||||
都是保存当前文件并退出。
|
||||
|
||||
(译者注:这两个命令实际上并不完全等价,当文件被修改时两个命令时相同的。但如果未被修改,使用 `:x` 不会更改文件的修改时间,而使用 `:wq` 会改变文件的修改时间。)
|
||||
|
||||
### 基本计算器 ###
|
||||
|
||||
在插入模式下,你可以使用 Ctrl+r 键然后输入 `=`,再输入一个简单的算式。按 Enter 键,计算结果就会插入到文件中。例如,尝试输入:
|
||||
|
||||
Ctrl+r '=2+2' ENTER
|
||||
|
||||

|
||||
|
||||
然后 4 会被插入到文件中。
|
||||
|
||||
### 查找重复的连续的单词 ###
|
||||
|
||||
当你很快地打字时,很有可能会连续输入同一个单词两次,就像 this this。这种错误可能骗过任何一个人,即使是你自己重新阅读一边也不可避免。幸运的是,有一个简单的正则表达式可以用来预防这个错误。使用搜索命令(默认时 `/`)然后输入:
|
||||
|
||||
\(\<\w\+\>\)\_s*\1
|
||||
|
||||
这会显示所有重复的单词。要达到最好的效果,不要忘记把下面的命令:
|
||||
|
||||
set hlsearch
|
||||
|
||||
放到你的 .vimrc 文件中高亮所有的匹配。
|
||||
|
||||

|
||||
|
||||
### 缩写 ###
|
||||
|
||||
一个很可能是最令人印象深刻的窍门是你可以在 Vim 中定义缩写,它可以实时地把你输入的东西替换为另外的东西。语法格式如下:
|
||||
|
||||
:ab [缩写] [要替换的文字]
|
||||
|
||||
一个通用的例子是:
|
||||
|
||||
:ab asap as soon as possible
|
||||
|
||||
会把你输入的 “asap” 替换为 “as soon as possible”。
|
||||
|
||||
### 在你忘记用 root 方式打开文件时的文件保存 ###
|
||||
|
||||
这可能是一个在论坛中一直受欢迎的命令。每当你打开一个你没有写入权限的文件(比如系统配置文件)并做了一些修改,Vim 无法通过普通的 “:w” 命令来保存。
|
||||
|
||||
你不需要重新以 root 方式打开文件再进行修改,只需要运行:
|
||||
|
||||
:w !sudo tee %
|
||||
|
||||
这会直接以 root 方式保存。
|
||||
|
||||
### 实时加密文本 ###
|
||||
|
||||
如果你不想让别人看懂你的屏幕上的内容,你可以使用一个内置的选项,通过下面的命令使用 [ROT13][2] 来对文本进行编码:
|
||||
|
||||
ggVGg?
|
||||
|
||||

|
||||
|
||||
`gg` 把光标移动到 Vim 缓冲区的第一行,`V` 进入可视模式,`G` 把光标移动到缓冲区的最后一行。因此,`ggVG` 使可视模式覆盖这个当前缓冲区。最后 `g?` 使用 ROT13 对整个区域进行编码。
|
||||
|
||||
注意它应该被映射到一个最长使用的键。它对字母符号也可以很好地工作。要对它进行撤销,最好的方法就是使用撤销命令:`u`。
|
||||
|
||||
###自动补全 ###
|
||||
|
||||
这是另外一个令我感到惭愧的功能,但我发现周围很多人并不知道。Vim 默认有自动补全的功能。的确这个功能是很基本的,并且可以通过插件来增强,但它也很有帮助。方法很简单。Vim 尝试通过已经输入的单词来预测单词的结尾。比如当你在同一个文件中第二次输入 “compiler” 时,仅仅输入 “com” 然后保持在插入模式,按 Ctrl+n 键就可以看到 Vim 为你补全了单词。很简单,但也很有用。
|
||||
|
||||
### 比较两个文件的不同 ###
|
||||
|
||||
你们中的大多数很可能都知道 vimdiff 命令,它可以使用分离模式打开 Vim 并比较两个文件的不同。语法如下:
|
||||
|
||||
$ vimdiff [文件1] [文件2]
|
||||
|
||||
但同样的结果也可以通过下面的 Vim 命令来获得:
|
||||
|
||||
:diffthis
|
||||
|
||||
首先在 Vim 中打开原始文件。然后使用分离模式带来第二个文件:
|
||||
|
||||
:vsp [文件2]
|
||||
|
||||
最后在第一个缓冲区里输入:
|
||||
|
||||
:diffthis
|
||||
|
||||
通过 Ctrl+w 来切换缓冲区并再次输入:
|
||||
|
||||
:diffthis
|
||||
|
||||
这样两个文件中不同的部分就会被高亮。
|
||||
|
||||
(译者注:可以直接在一个缓冲区里使用命令 `:windo diffthis`,而不用输入 `:diffthis` 两次)
|
||||
|
||||
要停止比较,使用:
|
||||
|
||||
:diffoff
|
||||
|
||||
### 按时间回退文件 ###
|
||||
|
||||
Vim 会记录文件的更改,你很容易可以回退到之前某个时间。该命令时相当直观的。比如:
|
||||
|
||||
:earlier 1m
|
||||
|
||||
会把文件回退到 1 分钟以前的状态。
|
||||
|
||||
注意,你可以使用下面的命令进行相反的转换:
|
||||
|
||||
:later
|
||||
|
||||
### 删除标记内部的文字 ###
|
||||
|
||||
当我开始使用 Vim 时一件我总是想很方便做的事情是如何轻松的删除方括号或圆括号里的内容。转到开始的标记,然后使用下面的语法:
|
||||
|
||||
di[标记]
|
||||
|
||||
比如,把光标放在开始的圆括号上,使用下面的命令来删除圆括号内的文字:
|
||||
|
||||
di(
|
||||
|
||||
如果是方括号或者是引号,则使用:
|
||||
|
||||
di{
|
||||
|
||||
和:
|
||||
|
||||
di"
|
||||
|
||||
### 删除指定标记前的内容 ###
|
||||
|
||||
和删除标记内部有些相似,但目的不同。命令如下:
|
||||
|
||||
dt[标记]
|
||||
|
||||
会删除所有光标和标记之间的内容(保持标记不动),如果在同一行有这个标记的话。例如
|
||||
|
||||
dt.
|
||||
|
||||
会删除至句子的末尾,但保持 ‘.’ 不动。
|
||||
|
||||
### 把 Vim 变为十六进制编辑器 ###
|
||||
|
||||
这不是我最喜欢的窍门,但有时会很有趣。你可以把 Vim 和 xxd 功能连起来来把文件转换为十六进制模式。命令如下:
|
||||
|
||||
:%!xxd
|
||||
|
||||

|
||||
|
||||
类似的,你可以通过下面的命令恢复原来的状态:
|
||||
|
||||
:%!xxd -r
|
||||
|
||||
### 把光标下的文字置于屏幕中央 ###
|
||||
|
||||
所有要做的事情都包含在标题中。如果你想强制滚动屏幕来把光标下的文字置于屏幕的中央,在可视模式中使用命令(译者注:在普通模式中也可以):
|
||||
|
||||
zz
|
||||
|
||||
### 跳到上一个/下一个 位置 ###
|
||||
|
||||
当你编辑一个很大的文件时,经常要做的事是在某处进行修改,然后跳到另外一处。如果你想跳回之前修改的地方,使用命令:
|
||||
|
||||
Ctrl+o
|
||||
|
||||
来回到之前修改的地方
|
||||
|
||||
类似的:
|
||||
|
||||
Ctrl+i
|
||||
|
||||
会回退上面的跳动。
|
||||
|
||||
### 把当前文件转化为网页 ###
|
||||
|
||||
这会生成一个 HTML 文件来显示文本,并在分开的窗口显示源代码:
|
||||
|
||||
:%TOhtml
|
||||
|
||||
(译者注:原文是 `:%Tohtml`,但在我的电脑上是 `:%TOhtml`)
|
||||
|
||||

|
||||
|
||||
很基本但很不错。
|
||||
|
||||
总的来说,这一系列命令是在我读了许多论坛主题和 [Vim Tips wiki][3](如果你想学习更多关于编辑器的知识,我非常推荐这篇文章) 之后收集起来的。
|
||||
|
||||
如果你还知道哪些非常有用但你认为大多数人并不知道的命令,可以随意在评论中分享出来。就像引言中所说的,一个“鲜为人知但很有用的”命令是很主观的,但分享出来总是好的。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/useful-vim-commands.html
|
||||
|
||||
作者:[Adrien Brochard][a]
|
||||
译者:[wangjiezhe](https://github.com/wangjiezhe)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/adrien
|
||||
[1]:http://xmodulo.com/turn-vim-full-fledged-ide.html
|
||||
[2]:https://en.wikipedia.org/wiki/ROT13
|
||||
[3]:http://vim.wikia.com/wiki/Vim_Tips_Wiki
|
||||
@@ -0,0 +1,45 @@
|
||||
Linux FAQs with Answers--How to convert a text file to PDF format on Linux
|
||||
Linux 有问必答 --如何在Linux上将文本文件转换成PDF格式
|
||||
================================================================================
|
||||
> **提问**: 我想要将一个纯文本文件转换成PDF文档。是否有一个简单的方法在Linux命令行下将文本文件转换成PDF文件?
|
||||
|
||||
当你有一打文本文件要维护的时候,把它们转换成PDF文档有一些好处。比如,PDF对打印更友好因为PDF文档有预定义布局。除此之外,还可以减少文档被意外修改的风险。
|
||||
|
||||
要将文本文件转换成PDF格式,你要按照下面的两步。
|
||||
|
||||
### 准备工作 ###
|
||||
|
||||
首先你要安装两个需要的包。
|
||||
|
||||
在 Debian、Ubuntu 或者 Linux Mint上:
|
||||
|
||||
$ sudo apt-get install enscript ghostscript
|
||||
|
||||
在 Fedora、CentOS/RHEL上:
|
||||
|
||||
$ sudo yum install enscript ghostscript
|
||||
|
||||
在 Arch Linux上:
|
||||
|
||||
$ sudo pacman -S enscript ghostscript
|
||||
|
||||
### 将文本文件转换成PDF格式 ###
|
||||
|
||||
准备工作完成之后,按照下面的两步从文本文件生成一个PDF文件
|
||||
|
||||
首先,将文本文件使用enscript命令行工具转换成postscript格式。
|
||||
|
||||
$ enscript -p output.ps input.txt
|
||||
|
||||
最后将postscript格式文件转换成PDF文件。
|
||||
|
||||
$ ps2pdf output.ps output.pdf
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/convert-text-to-pdf-linux.html
|
||||
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
Reference in New Issue
Block a user