id
int64 2.05k
16.6k
| title
stringlengths 5
75
| fromurl
stringlengths 19
185
| date
timestamp[s] | tags
sequencelengths 0
11
| permalink
stringlengths 20
37
| content
stringlengths 342
82.2k
| fromurl_status
int64 200
526
⌀ | status_msg
stringclasses 339
values | from_content
stringlengths 0
229k
⌀ |
---|---|---|---|---|---|---|---|---|---|
6,718 | 如何在 CentOS 6/7 上移除被 Fail2ban 禁止的 IP | http://www.ehowstuff.com/how-to-remove-banned-ip-from-fail2ban-on-centos/ | 2015-12-09T20:51:21 | [
"fail2ban",
"安全"
] | https://linux.cn/article-6718-1.html | 
[fail2ban](http://www.fail2ban.org/wiki/index.php/Main_Page) 是一款用于保护你的服务器免于暴力攻击的入侵保护软件。fail2ban 用 python 写成,并广泛用于很多服务器上。fail2ban 会扫描日志文件和 IP 黑名单来显示恶意软件、过多的密码失败尝试、web 服务器利用、wordpress 插件攻击和其他漏洞。如果你已经安装并使用了 fail2ban 来保护你的 web 服务器,你也许会想知道如何在 CentOS 6、CentOS 7、RHEL 6、RHEL 7 和 Oracle Linux 6/7 中找到被 fail2ban 阻止的 IP,或者你想将 ip 从 fail2ban 监狱中移除。
### 如何列出被禁止的 IP
要查看所有被禁止的 ip 地址,运行下面的命令:
```
# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
f2b-AccessForbidden tcp -- anywhere anywhere tcp dpt:http
f2b-WPLogin tcp -- anywhere anywhere tcp dpt:http
f2b-ConnLimit tcp -- anywhere anywhere tcp dpt:http
f2b-ReqLimit tcp -- anywhere anywhere tcp dpt:http
f2b-NoAuthFailures tcp -- anywhere anywhere tcp dpt:http
f2b-SSH tcp -- anywhere anywhere tcp dpt:ssh
f2b-php-url-open tcp -- anywhere anywhere tcp dpt:http
f2b-nginx-http-auth tcp -- anywhere anywhere multiport dports http,https
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere tcp dpt:EtherNet/IP-1
ACCEPT tcp -- anywhere anywhere tcp dpt:http
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain f2b-NoAuthFailures (1 references)
target prot opt source destination
REJECT all -- 64.68.50.128 anywhere reject-with icmp-port-unreachable
REJECT all -- 104.194.26.205 anywhere reject-with icmp-port-unreachable
RETURN all -- anywhere anywhere
```
### 如何从 Fail2ban 中移除 IP
```
# iptables -D f2b-NoAuthFailures -s banned_ip -j REJECT
```
我希望这篇教程可以给你在 CentOS 6、CentOS 7、RHEL 6、RHEL 7 和 Oracle Linux 6/7 中移除被禁止的 ip 一些指导。
---
via: <http://www.ehowstuff.com/how-to-remove-banned-ip-from-fail2ban-on-centos/>
作者:[skytech](http://www.ehowstuff.com/author/skytech/) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,719 | 如何在 CentOS 7 上安装 Redis 服务器 | http://linoxide.com/storage/install-redis-server-centos-7/ | 2015-12-10T13:45:00 | [
"redis"
] | /article-6719-1.html | 大家好,本文的主题是 Redis,我们将要在 CentOS 7 上安装它。编译源代码,安装二进制文件,创建、安装文件。在安装了它的组件之后,我们还会配置 redis ,就像配置操作系统参数一样,目标就是让 redis 运行的更加可靠和快速。

*Redis 服务器*
Redis 是一个开源的多平台数据存储软件,使用 ANSI C 编写,直接在内存使用数据集,这使得它得以实现非常高的效率。Redis 支持多种编程语言,包括 Lua, C, Java, Python, Perl, PHP 和其他很多语言。redis 的代码量很小,只有约3万行,它只做“很少”的事,但是做的很好。尽管是在内存里工作,但是数据持久化的保存还是有的,而redis 的可靠性就很高,同时也支持集群,这些可以很好的保证你的数据安全。
### 构建 Redis
redis 目前没有官方 RPM 安装包,我们需要从源代码编译,而为了要编译就需要安装 Make 和 GCC。
如果没有安装过 GCC 和 Make,那么就使用 yum 安装。
```
yum install gcc make
```
从[官网](http://redis.io/download)下载 tar 压缩包。
```
curl http://download.redis.io/releases/redis-3.0.4.tar.gz -o redis-3.0.4.tar.gz
```
解压缩。
```
tar zxvf redis-3.0.4.tar.gz
```
进入解压后的目录。
```
cd redis-3.0.4
```
使用Make 编译源文件。
```
make
```
### 安装
进入源文件的目录。
```
cd src
```
复制 Redis 的服务器和客户端到 /usr/local/bin。
```
cp redis-server redis-cli /usr/local/bin
```
最好也把 sentinel,benchmark 和 check 复制过去。
```
cp redis-sentinel redis-benchmark redis-check-aof redis-check-dump /usr/local/bin
```
创建redis 配置文件夹。
```
mkdir /etc/redis
```
在`/var/lib/redis` 下创建有效的保存数据的目录
```
mkdir -p /var/lib/redis/6379
```
#### 系统参数
为了让 redis 正常工作需要配置一些内核参数。
配置 `vm.overcommit_memory` 为1,这可以避免数据被截断,详情[见此](https://www.kernel.org/doc/Documentation/vm/overcommit-accounting)。
```
sysctl -w vm.overcommit_memory=1
```
修改 backlog 连接数的最大值超过 redis.conf 中的 `tcp-backlog` 值,即默认值511。你可以在[kernel.org](https://www.kernel.org/doc/Documentation/networking/ip-sysctl.txt) 找到更多有关基于 sysctl 的 ip 网络隧道的信息。
```
sysctl -w net.core.somaxconn=512
```
取消对透明巨页内存(transparent huge pages)的支持,因为这会造成 redis 使用过程产生延时和内存访问问题。
```
echo never > /sys/kernel/mm/transparent_hugepage/enabled
```
### redis.conf
redis.conf 是 redis 的配置文件,然而你会看到这个文件的名字是 6379.conf ,而这个数字就是 redis 监听的网络端口。如果你想要运行超过一个的 redis 实例,推荐用这样的名字。
复制示例的 redis.conf 到 **/etc/redis/6379.conf**。
```
cp redis.conf /etc/redis/6379.conf
```
现在编辑这个文件并且配置参数。
```
vi /etc/redis/6379.conf
```
#### daemonize
设置 `daemonize` 为 no,systemd 需要它运行在前台,否则 redis 会突然挂掉。
```
daemonize no
```
#### pidfile
设置 `pidfile` 为 `/var/run/redis_6379.pid`。
```
pidfile /var/run/redis_6379.pid
```
#### port
如果不准备用默认端口,可以修改。
```
port 6379
```
#### loglevel
设置日志级别。
```
loglevel notice
```
#### logfile
修改日志文件路径。
```
logfile /var/log/redis_6379.log
```
#### dir
设置目录为 /var/lib/redis/6379
```
dir /var/lib/redis/6379
```
### 安全
下面有几个可以提高安全性的操作。
#### Unix sockets
在很多情况下,客户端程序和服务器端程序运行在同一个机器上,所以不需要监听网络上的 socket。如果这和你的使用情况类似,你就可以使用 unix socket 替代网络 socket,为此你需要配置 `port` 为0,然后配置下面的选项来启用 unix socket。
设置 unix socket 的套接字文件。
```
unixsocket /tmp/redis.sock
```
限制 socket 文件的权限。
```
unixsocketperm 700
```
现在为了让 redis-cli 可以访问,应该使用 -s 参数指向该 socket 文件。
```
redis-cli -s /tmp/redis.sock
```
#### requirepass
你可能需要远程访问,如果是,那么你应该设置密码,这样子每次操作之前要求输入密码。
```
requirepass "bTFBx1NYYWRMTUEyNHhsCg"
```
#### rename-command
想象一下如下指令的输出。是的,这会输出服务器的配置,所以你应该在任何可能的情况下拒绝这种访问。
```
CONFIG GET *
```
为了限制甚至禁止这条或者其他指令可以使用 `rename-command` 命令。你必须提供一个命令名和替代的名字。要禁止的话需要设置替代的名字为空字符串,这样禁止任何人猜测命令的名字会比较安全。
```
rename-command FLUSHDB "FLUSHDB_MY_SALT_G0ES_HERE09u09u"
rename-command FLUSHALL ""
rename-command CONFIG "CONFIG_MY_S4LT_GO3S_HERE09u09u"
```

*使用密码通过 unix socket 访问,和修改命令*
#### 快照
默认情况下,redis 会周期性的将数据集转储到我们设置的目录下的 **dump.rdb** 文件。你可以使用 `save` 命令配置转储的频率,它的第一个参数是以秒为单位的时间帧,第二个参数是在数据文件上进行修改的数量。
每隔15分钟并且最少修改过一次键。
```
save 900 1
```
每隔5分钟并且最少修改过10次键。
```
save 300 10
```
每隔1分钟并且最少修改过10000次键。
```
save 60 10000
```
文件 `/var/lib/redis/6379/dump.rdb` 包含了从上次保存以来内存里数据集的转储数据。因为它先创建临时文件然后替换之前的转储文件,这里不存在数据破坏的问题,你不用担心,可以直接复制这个文件。
### 开机时启动
你可以使用 systemd 将 redis 添加到系统开机启动列表。
复制示例的 init\_script 文件到 `/etc/init.d`,注意脚本名所代表的端口号。
```
cp utils/redis_init_script /etc/init.d/redis_6379
```
现在我们要使用 systemd,所以在 `/etc/systems/system` 下创建一个单位文件名字为 `redis_6379.service`。
```
vi /etc/systemd/system/redis_6379.service
```
填写下面的内容,详情可见 systemd.service。
```
[Unit]
Description=Redis on port 6379
[Service]
Type=forking
ExecStart=/etc/init.d/redis_6379 start
ExecStop=/etc/init.d/redis_6379 stop
[Install]
WantedBy=multi-user.target
```
现在添加我之前在 `/etc/sysctl.conf` 里面修改过的内存过量使用和 backlog 最大值的选项。
```
vm.overcommit_memory = 1
net.core.somaxconn=512
```
对于透明巨页内存支持,并没有直接 sysctl 命令可以控制,所以需要将下面的命令放到 `/etc/rc.local` 的结尾。
```
echo never > /sys/kernel/mm/transparent_hugepage/enabled
```
### 总结
这样就可以启动了,通过设置这些选项你就可以部署 redis 服务到很多简单的场景,然而在 redis.conf 还有很多为复杂环境准备的 redis 选项。在一些情况下,你可以使用 [replication](http://redis.io/topics/replication) 和 [Sentinel](http://redis.io/topics/sentinel) 来提高可用性,或者[将数据分散](http://redis.io/topics/partitioning)在多个服务器上,创建服务器集群。
谢谢阅读。
---
via: <http://linoxide.com/storage/install-redis-server-centos-7/>
作者:[Carlos Alberto](http://linoxide.com/author/carlosal/) 译者:[ezio](https://github.com/oska874) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='linoxide.com', port=80): Max retries exceeded with url: /storage/install-redis-server-centos-7/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327582e30>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,720 | 如何在 Apache 中启用 HTTP/2 | https://icing.github.io/mod_h2/howto.html | 2015-12-11T09:33:00 | [
"http/2",
"apache"
] | https://linux.cn/article-6720-1.html | Copyright (C) 2015 greenbytes GmbH
刚发布的 Apache httpd 2.4.17 终于支持 HTTP/2 了。这个页面给出了一些如何构建/部署/配置的建议。目的是为了大家发现 bugs 时能升级它,或者给一些能更好工作的建议。
最后,这会归并回到官方 Apache 文档,这里只会留下一个到那里的链接。暂时我们还没做到。

### 源码
你可以从[这里](https://httpd.apache.org/download.cgi)得到 Apache 版本。Apache 2.4.17 及其更高版本都支持 HTTP/2。我不会再重复介绍如何构建该服务器的指令。在很多地方有很好的指南,例如[这里](https://httpd.apache.org/docs/2.4/install.html)。
(有任何这个试验性软件包的相关链接?在 Twitter 上告诉我吧 @icing)
#### 编译支持 HTTP/2
在你编译版本之前,你要进行一些**配置**。这里有成千上万的选项。和 HTTP/2 相关的是:
* **--enable-http2**
启用在 Apache 服务器内部实现该协议的 ‘http2’ 模块。
* **--with-nghttp2=<dir>**
指定 http2 模块需要的 libnghttp2 模块的非默认位置。如果 nghttp2 是在默认的位置,配置过程会自动采用。
* **--enable-nghttp2-staticlib-deps**
很少用到的选项,你可能想将 nghttp2 库静态链接到服务器里。在大部分平台上,只有在找不到共享 nghttp2 库时才有用。
如果你想自己编译 nghttp2,你可以到 [nghttp2.org](https://nghttp2.org/) 查看文档。最新的 Fedora 以及其它版本已经附带了这个库。
#### TLS 支持
大部分人想在浏览器上使用 HTTP/2, 而浏览器只在使用 TLS 连接(**https:// 开头的 url**)时才支持 HTTP/2。你需要一些我下面介绍的配置。但首先你需要的是支持 ALPN 扩展的 TLS 库。
ALPN 用来<ruby> 协商 <rp> ( </rp> <rt> negotiate </rt> <rp> ) </rp></ruby>服务器和客户端之间的协议。如果你服务器上 TLS 库还没有实现 ALPN,客户端只能通过 HTTP/1.1 通信。那么,可以和 Apache 链接并支持它的是什么库呢?
* **OpenSSL 1.0.2** 及其以后。
* ??? (别的我也不知道了)
如果你的 OpenSSL 库是 Linux 版本自带的,这里使用的版本号可能和官方 OpenSSL 版本的不同。如果不确定的话检查一下你的 Linux 版本吧。
### 配置
另一个给服务器的好建议是为 http2 模块设置合适的日志等级。添加下面的配置:
```
# 放在某个地方的这样一行
LoadModule http2_module modules/mod_http2.so
<IfModule http2_module>
LogLevel http2:info
</IfModule>
```
当你启动服务器的时候,你可以在错误日志中看来类似的一行:
```
[timestamp] [http2:info] [pid XXXXX:tid numbers]
mod_http2 (v1.0.0, nghttp2 1.3.4), initializing...
```
#### 协议
那么,假设你已经编译部署好了服务器, TLS 库也是最新的,你启动了你的服务器,打开了浏览器。。。你怎么知道它在工作呢?
如果除此之外你没有添加其它的服务器配置,很可能它没有工作。
你需要告诉服务器在哪里使用该协议。默认情况下,你的服务器并没有启动 HTTP/2 协议。因为这样比较安全,也许才能让你已有的部署可以继续工作。
你可以用新的 **Protocols** 指令启用 HTTP/2 协议:
```
# 对于 https 服务器
Protocols h2 http/1.1
...
# 对于 http 服务器
Protocols h2c http/1.1
```
你可以给整个服务器或者指定的 **vhosts** 添加这个配置。
#### SSL 参数
对于 TLS (SSL),HTTP/2 有一些特殊的要求。阅读下面的“ https:// 连接”一节了解更详细的信息。
### http:// 连接 (h2c)
尽管现在还没有浏览器支持,但是 HTTP/2 协议也工作在 http:// 这样的 url 上, 而且 mod\_h[ttp]2 也支持。启用它你唯一所要做的是在 Protocols 配置中启用它:
```
# 对于 http 服务器
Protocols h2c http/1.1
```
这里有一些支持 **h2c** 的客户端(和客户端库)。我会在下面介绍:
#### curl
Daniel Stenberg 维护的用于访问网络资源的命令行客户端 curl 当然支持。如果你的系统上有 curl,有一个简单的方法检查它是否支持 http/2:
```
sh> curl -V
curl 7.43.0 (x86_64-apple-darwin15.0) libcurl/7.43.0 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSockets
```
不好了。这些功能中没有 'HTTP2'。你想要的是下面这样:
```
sh> curl -V
url 7.45.0 (x86_64-apple-darwin15.0.0) libcurl/7.45.0 OpenSSL/1.0.2d zlib/1.2.8 nghttp2/1.3.4
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets
```
如果你的 curl 支持 HTTP2 功能,你可以用一些简单的命令检查你的服务器:
```
sh> curl -v --http2 http://<yourserver>/
...
> Connection: Upgrade, HTTP2-Settings
> Upgrade: h2c
> HTTP2-Settings: AAMAAABkAAQAAP__
>
< HTTP/1.1 101 Switching Protocols
< Upgrade: h2c
< Connection: Upgrade
* Received 101
* Using HTTP2, server supports multi-use
* Connection state changed (HTTP/2 confirmed)
...
<the resource>
```
恭喜,如果看到了有 **...101 Switching...** 的行就表示它正在工作!
有一些情况不会发生 HTTP/2 的<ruby> 升级切换 <rp> ( </rp> <rt> Upgrade </rt> <rp> ) </rp></ruby>。如果你的第一个请求有<ruby> 请求数据 <rp> ( </rp> <rt> body </rt> <rp> ) </rp></ruby>,例如你上传一个文件时,就不会触发升级切换。[h2c 限制](https://icing.github.io/mod_h2/howto.html#h2c-restrictions)部分有详细的解释。
#### nghttp
nghttp2 可以一同编译它自己的客户端和服务器。如果你的系统中有该客户端,你可以简单地通过获取一个资源来验证你的安装:
```
sh> nghttp -uv http://<yourserver>/
[ 0.001] Connected
[ 0.001] HTTP Upgrade request
...
Connection: Upgrade, HTTP2-Settings
Upgrade: h2c
HTTP2-Settings: AAMAAABkAAQAAP__
...
[ 0.005] HTTP Upgrade response
HTTP/1.1 101 Switching Protocols
Upgrade: h2c
Connection: Upgrade
[ 0.006] HTTP Upgrade success
...
```
这和我们上面 **curl** 例子中看到的 Upgrade 输出很相似。
有另外一种在命令行参数中不用 **-u** 参数而使用 **h2c** 的方法。这个参数会指示 **nghttp** 进行 HTTP/1 升级切换过程。但如果我们不使用呢?
```
sh> nghttp -v http://<yourserver>/
[ 0.002] Connected
[ 0.002] send SETTINGS frame
...
[ 0.002] send HEADERS frame
; END_STREAM | END_HEADERS | PRIORITY
(padlen=0, dep_stream_id=11, weight=16, exclusive=0)
; Open new stream
:method: GET
:path: /
:scheme: http
...
```
连接马上使用了 HTTP/2!这就是协议中所谓的<ruby> 直接 <rp> ( </rp> <rt> direct </rt> <rp> ) </rp></ruby>模式,当客户端发送一些[特殊的 24 字节](/article-6670-1.html)到服务器时就会发生:
```
0x505249202a20485454502f322e300d0a0d0a534d0d0a0d0a
```
[用 ASCII 表示是](/article-6670-1.html):
```
PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n
```
支持 **h2c** 的服务器在一个新的连接中看到这些信息就会马上切换到 HTTP/2。HTTP/1.1 服务器则认为是一个可笑的请求,响应并关闭连接。
因此,**直接**模式只适合于那些确定服务器支持 HTTP/2 的客户端。例如,当前一个升级切换过程成功了的时候。
**直接**模式的魅力是零开销,它支持所有请求,即使带有请求数据部分(查看[h2c 限制](https://icing.github.io/mod_h2/howto.html#h2c-restrictions))。
对于 2.4.17 版本,明文连接时默认启用 **H2Direct** 。但是有一些模块和这不兼容。因此,在下一版本中,默认会设置为**off**,如果你希望你的服务器支持它,你需要设置它为:
```
H2Direct on
```
### https:// 连接 (h2)
当你的 mod\_h[ttp]2 可以支持 h2c 连接时,那就可以一同启用 **h2** 兄弟了,现在的浏览器仅支持它和 **https:** 一同使用。
HTTP/2 标准对 https:(TLS)连接增加了一些额外的要求。上面已经提到了 ALNP 扩展。另外的一个要求是不能使用特定[黑名单](https://httpwg.github.io/specs/rfc7540.html#BadCipherSuites)中的加密算法。
尽管现在版本的 **mod\_h[ttp]2** 不增强这些算法(以后可能会),但大部分客户端会这么做。如果让你的浏览器使用不恰当的算法打开 **h2** 服务器,你会看到不明确的警告 **INADEQUATE\_SECURITY**,浏览器会拒接连接。
一个可行的 Apache SSL 配置类似:
```
SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK
SSLProtocol All -SSLv2 -SSLv3
...
```
(是的,这确实很长。)
这里还有一些应该调整,但不是必须调整的 SSL 配置参数:**SSLSessionCache**, **SSLUseStapling** 等,其它地方也有介绍这些。例如 Ilya Grigorik 写的一篇超赞的博客: [高性能浏览器网络](http://chimera.labs.oreilly.com/books/1230000000545)。
#### curl
再次回到 shell 使用 curl(查看上面的“curl h2c”章节了解要求),你也可以通过 curl 用简单的命令检测你的服务器:
```
sh> curl -v --http2 https://<yourserver>/
...
* ALPN, offering h2
* ALPN, offering http/1.1
...
* ALPN, server accepted to use h2
...
<the resource>
```
恭喜你,能正常工作啦!如果还不能,可能原因是:
* 你的 curl 不支持 HTTP/2。查看上面的“检测 curl”一节。
* 你的 openssl 版本太低不支持 ALPN。
* 不能验证你的证书,或者不接受你的算法配置。尝试添加命令行选项 -k 停用 curl 中的这些检查。如果可以工作,就重新配置你的 SSL 和证书。
#### nghttp
我们已经在 **h2c** 讨论过 **nghttp**。如果你用它来进行 **https:** 连接,你会看到类似下面的信息:
```
sh> nghttp https://<yourserver>/
[ERROR] HTTP/2 protocol was not selected. (nghttp2 expects h2)
```
这有两种可能,你可以通过添加 -v 来检查。如果是:
```
sh> nghttp -v https://<yourserver>/
[ 0.034] Connected
[ERROR] HTTP/2 protocol was not selected. (nghttp2 expects h2)
```
这意味着你服务器使用的 TLS 库没有实现 ALPN。有时候正确安装有点困难。多看看 Stackoverflow 吧。
你看到的也可能是:
```
sh> nghttp -v https://<yourserver>/
[ 0.034] Connected
The negotiated protocol: http/1.1
[ERROR] HTTP/2 protocol was not selected. (nghttp2 expects h2)
```
这表示 ALPN 能正常工作,但并没有用 h2 协议。你需要像上面介绍的那样检查你服务器上的 Protocols 配置。如果一开始在 vhost 部分设置不能正常工作,试着在通用部分设置它。
#### Firefox
更新: [Apache Lounge](https://www.apachelounge.com/) 的 Steffen Land 告诉我 [Firefox 上有个 HTTP/2 指示插件](https://addons.mozilla.org/en-US/firefox/addon/spdy-indicator/)。你可以看到有多少地方用到了 h2(提示:Apache Lounge 用 h2 已经有一段时间了...)
你可以在 Firefox 浏览器中打开开发者工具,在那里的网络标签页查看 HTTP/2 连接。当你打开了 HTTP/2 并重新刷新 html 页面时,你会看到类似下面的东西:

在响应头中,你可以看到奇怪的 **X-Firefox-Spdy** 条目中列出了 “h2”。这表示在这个 **https:** 连接中使用了 HTTP/2。
#### Google Chrome
在 Google Chrome 中,你在开发者工具中看不到 HTTP/2 指示器。相反,Chrome 用特殊的地址 **chrome://net-internals/#http2** 给出了相关信息。(LCTT 译注:Chrome 已经有一个 “HTTP/2 and SPDY indicator” 可以很好的在地址栏识别 HTTP/2 连接)
如果你打开了一个服务器的页面,可以在 Chrome 中查看那个 net-internals 页面,你可以看到类似下面这样:

如果你的服务器在上面的列表中,就表示它正在工作。
#### Microsoft Edge
Windows 10 中 Internet Explorer 的继任者 Edge 也支持 HTTP/2。你也可以在开发者工具的网络标签页看到 HTTP/2 协议。

#### Safari
在 Apple 的 Safari 中,打开开发者工具,那里有个网络标签页。重新加载你的服务器上的页面,并在开发者工具中选择显示了加载的那行。如果你启用了在右边显示详细视图,看 **Status** 部分。那里显示了 **HTTP/2.0 200**,像这样:

#### 重新协商
https: 连接重新协商是指正在运行的连接中特定的 TLS 参数会发生变化。在 Apache httpd 中,你可以在 directory 配置中改变 TLS 参数。如果进来一个获取特定位置资源的请求,配置的 TLS 参数会和当前的 TLS 参数进行对比。如果它们不相同,就会触发重新协商。
这种最常见的情形是算法变化和客户端证书。你可以要求客户访问特定位置时需要通过验证,或者对于特定资源,你可以使用更安全的、对 CPU 压力更大的算法。
但不管你的想法有多么好,HTTP/2 中都**不可以**发生重新协商。在同一个连接上会有 100 多个请求,那么重新协商该什么时候做呢?
对于这种配置,现有的 **mod\_h[ttp]2** 还没有办法。如果你有一个站点使用了 TLS 重新协商,别在上面启用 h2!
当然,我们会在后面的版本中解决这个问题,然后你就可以安全地启用了。
### 限制
#### 非 HTTP 协议
实现除 HTTP 之外协议的模块可能和 **mod\_http2** 不兼容。这在其它协议要求服务器首先发送数据时无疑会发生。
**NNTP** 就是这种协议的一个例子。如果你在服务器中配置了 **mod\_nntp\_like\_ssl**,那么就不要加载 mod\_http2。等待下一个版本。
#### h2c 限制
**h2c** 的实现还有一些限制,你应该注意:
##### 在虚拟主机中拒绝 h2c
你不能对指定的虚拟主机拒绝 **h2c 直连**。连接建立而没有看到请求时会触发**直连**,这使得不可能预先知道 Apache 需要查找哪个虚拟主机。
##### 有请求数据时的升级切换
对于有数据的请求,**h2c** 升级切换不能正常工作。那些是 PUT 和 POST 请求(用于提交和上传)。如果你写了一个客户端,你可能会用一个简单的 GET 或者 OPTIONS \* 来处理那些请求以触发升级切换。
原因从技术层面来看显而易见,但如果你想知道:在升级切换过程中,连接处于半疯状态。请求按照 HTTP/1.1 的格式,而响应使用 HTTP/2 帧。如果请求有一个数据部分,服务器在发送响应之前需要读取整个数据。因为响应可能需要从客户端处得到应答用于流控制及其它东西。但如果仍在发送 HTTP/1.1 请求,客户端就仍然不能以 HTTP/2 连接。
为了使行为可预测,几个服务器在实现上决定不在任何带有请求数据的请求中进行升级切换,即使请求数据很小。
##### 302 时的升级切换
有重定向发生时,当前的 h2c 升级切换也不能工作。看起来 mod\_http2 之前的重写有可能发生。这当然不会导致断路,但你测试这样的站点也许会让你迷惑。
#### h2 限制
这里有一些你应该意识到的 h2 实现限制:
##### 连接重用
HTTP/2 协议允许在特定条件下重用 TLS 连接:如果你有带通配符的证书或者多个 AltSubject 名称,浏览器可能会重用现有的连接。例如:
你有一个 **a.example.org** 的证书,它还有另外一个名称 **b.example.org**。你在浏览器中打开 URL **https://a.example.org/**,用另一个标签页加载 **https://b.example.org/**。
在重新打开一个新的连接之前,浏览器看到它有一个到 **a.example.org** 的连接并且证书对于 **b.example.org** 也可用。因此,它在第一个连接上面发送第二个标签页的请求。
这种连接重用是刻意设计的,它使得使用了 HTTP/1 <ruby> 切分 <rp> ( </rp> <rt> sharding </rt> <rp> ) </rp></ruby>来提高效率的站点能够不需要太多变化就能利用 HTTP/2。
Apache **mod\_h[ttp]2** 还没有完全实现这点。如果 **a.example.org** 和 **b.example.org** 是不同的虚拟主机, Apache 不会允许这样的连接重用,并会告知浏览器状态码 **421 Misdirected Request**。浏览器会意识到它需要重新打开一个到 **b.example.org** 的连接。这仍然能工作,只是会降低一些效率。
我们期望下一次的发布中能有合适的检查。
Münster, 12.10.2015,
Stefan Eissing, greenbytes GmbH
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. See LICENSE for details.
---
该项目由 [icing](https://github.com/icing) 维护。
---
via: <https://icing.github.io/mod_h2/howto.html>
作者:[icing](https://github.com/icing) 译者:[ictlyh](http://mutouxiaogui.cn/blog/) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | HTTP/2 for [Apache httpd](https://httpd.apache.org/download.cgi)
Copyright (C) 2016 greenbytes GmbH
**Update 2017-10-19:** LibreSSL minimum version corrected. Work on ALPN in libressl was apparently started in 2.1.3, but not completed until 2.5.0.
**Update 2016-08-25:** LibreSSL minimum version added, connection reuse description updated. Chapter about Debugging added.
Support for HTTP/2 is finally being released with Apache httpd 2.4.17! This pages gives advice on how to build/deploy/configure it. The plan is to update this as people find out new things (read: bugs) or give recommendations on what works best for them.
Ultimately, this will then flow back into the official Apache documentation and this page will only contain a single link to it. But we are not quite there yet...
You can get the Apache release from [here](https://httpd.apache.org/download.cgi). HTTP/2 support
is included in Apache 2.4.17 and upwards. I will not repeat instructions on how to build the server in general.
There is excellent material available in several places, for example [here](https://httpd.apache.org/docs/2.4/install.html).
(Any links to experimental packages? Drop me a note on twitter @icing.)
Should you build from a release, you will need to `configure`
first. There are tons of options. The ones specific for HTTP/2 are:
`--enable-http2`
`--with-nghttp2=<dir>`
`libnghttp2`
which is necessary for the http2 module. If nghttp2 is in a standard place, the configure process will pick it up automatically.`--enable-nghttp2-staticlib-deps`
In case you want to build `nghttp2`
for yourself, you find documentation at [nghttp2.org](https://nghttp2.org). The library is also being shipped in the latest Fedora and other distros will follow.
Most people will want to use HTTP/2 with browsers and browser only support it on TLS connections (`https://`
urls).
You'll need proper configuration for that which I cover below. But foremost what you will need is an TLS library that
supports the ALPN extension.
ALPN is neccessary to *negotiate* the protocol to use between server and client. If it is not implemented by the TLS lib on your
server, the client will only ever talk HTTP/1.1. So, who does link with Apache and support it?
`OpenSSL 1.0.2`
and onward.`LibreSSL 2.5.0`
and onward.One useful addition to your server is to set a good logging level for the http2 module. Add this:
# this needs to be somewhere LoadModule http2_module modules/mod_http2.so <IfModule http2_module> LogLevel http2:info </IfModule>When you start your server and look in the error log, you should see one line like:
[timestamp] [http2:info] [pid XXXXX:tid numbers] mod_http2 (v1.0.0, nghttp2 1.3.4), initializing...
So, assume you have the server built and deployed, the TLS library is bleeding edge (sorry), your server starts, you open your browser and...how do you know it is working?
If you have not added more to your server config, it probably isn't.
You need to tell the server where to use the protocol. By default, the HTTP/2
protocol is not enabled *anywhere* in your server. Because that is
the safe route and you might have an existing deployment should continue to work.
You enable the HTTP/2 protocol with the new `Protocols`
directive:
# for a https server Protocols h2 http/1.1 ... # for a http server Protocols h2c http/1.1You can add this for the server in general or for specific
`vhosts`
.
HTTP/2 has some special requirements regarding TLS (SSL). See the chapter about
[https:// connections](#https) for more information.
Although no browser currently supports it, the HTTP/2 protocol also works for `http://`
urls
and `mod_h[ttp]2`
supports this. The only thing you need to do in order to enable it is the Protocols
configuration:
# for a http server Protocols h2c http/1.1inside your
`httpd.conf`
.
There are several client (and client libraries) that support `h2c`
. I'll dicusss some specifics below:
Of course, *the* command line client for network resources, maintained by Daniel Stenberg.
If you have curl on your system, there is an easy way to check its http/2 support:
sh> curl -V curl 7.43.0 (x86_64-apple-darwin15.0) libcurl/7.43.0 SecureTransport zlib/1.2.5 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: AsynchDNS IPv6 Largefile GSS-API Kerberos SPNEGO NTLM NTLM_WB SSL libz UnixSocketswhich is no good. There is no 'HTTP2' among the features. You'd want something like this:
sh> curl -V url 7.45.0 (x86_64-apple-darwin15.0.0) libcurl/7.45.0 OpenSSL/1.0.2d zlib/1.2.8 nghttp2/1.3.4 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp Features: IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets
If you have a `curl`
with the HTTP2 feature, you may check your server
with some simple commands:
sh> curl -v --http2 http://<yourserver>/ ... > Connection: Upgrade, HTTP2-Settings > Upgrade: h2c > HTTP2-Settings: AAMAAABkAAQAAP__ > < HTTP/1.1 101 Switching Protocols < Upgrade: h2c < Connection: Upgrade * Received 101 * Using HTTP2, server supports multi-use * Connection state changed (HTTP/2 confirmed) ... <the resource>Congratulations, id you see the line with
`...101 Switching...`
, it's working!
There are cases, where the upgrade to HTTP/2 will not happen. When your first request does have
content, for example you do a file upload, the Upgrade will not trigger. For a detailed explanation, see
the section [h2c restrictions](#h2c-restrictions).
`nghttp2`
has its own client and servers that can be build with it. If you have the
client on your system, you can verify your installation by simply retrieving a resource:
sh> nghttp -uv http://<yourserver>/ [ 0.001] Connected [ 0.001] HTTP Upgrade request ... Connection: Upgrade, HTTP2-Settings Upgrade: h2c HTTP2-Settings: AAMAAABkAAQAAP__ ... [ 0.005] HTTP Upgrade response HTTP/1.1 101 Switching Protocols Upgrade: h2c Connection: Upgrade [ 0.006] HTTP Upgrade success ...which is very similar to the Upgrade dance we see in the
`curl`
example above.
There is another way to use `h2c`
hidden in the command line arguments: `-u`
. This
instructs `nghttp`
to perform the HTTP/1 Upgrade dance. But what if we leave this out?
sh> nghttp -v http://<yourserver>/ [ 0.002] Connected [ 0.002] send SETTINGS frameThe connection immediately speaks HTTP/2! This is what the protocol calls the... [ 0.002] send HEADERS frame ; END_STREAM | END_HEADERS | PRIORITY (padlen=0, dep_stream_id=11, weight=16, exclusive=0) ; Open new stream :method: GET :path: / :scheme: http ...
`direct`
mode and it
works by some magic 24 bytes that the client sends to the server right away:
0x505249202a20485454502f322e300d0a0d0a534d0d0a0d0a or in ASCII: PRI * HTTP/2.0\r\n\r\nSM\r\n\r\nA
`h2c`
capable server sees this on a new connection and can immediately switch its
HTTP/2 processing on. A HTTP/1.1 server will see a funny request, answer it and close the connection.
Therefore `direct`
mode is only good for clients if they can be resonably sure that the
server supports this. For example, because a previous Upgrade dance was successful.
The charme of `direct`
is the zero overhead and that it works for all requests, even those
that carry a body (see [h2c restrictions](#h2c-restrictions)). ~~The ~~
`direct`
mode
is enabled by default on any server that allows the `h2c`
protocol. If you want to disable
it, add the configuration directive:
H2Direct off
to your server.
For the 2.4.17 release, `H2Direct`
is enabled by default on cleartext connection. However
there are some modules with whom this is incompatible with. Therefore, in the next release, the default
will change to `off`
and if you want your server to support it, you need to set it to
H2Direct on
Once you get `mod_h[ttp]2`
working for `h2c`
connections, it's time to
get the `h2`
sibling going, as browsers only do it with `https:`
nowadays.
The HTTP/2 standard imposes some extra requirements on `https:`
(TLS) connections. The ALPN
extension has already been mentioned above. An additional requirement is that no cipher from a
specified [black list](https://httpwg.github.io/specs/rfc7540.html#BadCipherSuites) may
be used.
While the current version of `mod_h[ttp]2`
does not enforce these ciphers (but some day will),
most clients will do so. If you point your browser at a `h2`
server with inappropriate ciphers,
you will get the obscure warning `INADEQUATE_SECURITY`
and the browser will simply refuse to
continue.
An acceptable Apache SSL configuration regarding this is:
SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK SSLProtocol All -SSLv2 -SSLv3 ...(Yes, it's that long.)
There are other SSL configuration parameters that *should* be tweaked, but do *not have to*: `SSLSessionCache, SSLUseStapling`
, etc. but those are covered elsewhere. See the excellent [High Performance Browser Networking](http://chimera.labs.oreilly.com/books/1230000000545) by Ilya Grigorik, for example.
Time to fire up a shell and use `curl`
again (see the [h2c section about curl](#curl) for requirements). Using curl, you may check your server with some simple commands:
sh> curl -v --http2 https://<yourserver>/ ... * ALPN, offering h2 * ALPN, offering http/1.1 ... * ALPN, server accepted to use h2 ... <the resource>Congratulations, it's working! If not, the reason might be:
`-k`
to disable those checks in curl. If that
works, review yor SSL configuration and certificate.`curl`
nowadays defaults to HTTP/2 on https: connections. So it should work the same without the `--http2`
.
`nghttp`
we discussed already for `h2c`
. If you use
it for a `https:`
connection, you will either see the resource or an error like this:
sh> nghttp https://<yourserver>/ [ERROR] HTTP/2 protocol was not selected. (nghttp2 expects h2)There are two possiblities for this which you can check by adding
`-v`
. Either your get this:
sh> nghttp -v https://<yourserver>/ [ 0.034] Connected [ERROR] HTTP/2 protocol was not selected. (nghttp2 expects h2)This means that the TLS library your server uses does not implement ALPN. Getting this installtion correct is sometimes tricky. Use stackoverflow.
Or you get this:
sh> nghttp -v https://<yourserver>/ [ 0.034] Connected The negotiated protocol: http/1.1 [ERROR] HTTP/2 protocol was not selected. (nghttp2 expects h2)which means ALPN is working, only the h2 protocol was not selected. You need to check that
`Protocols`
is set as described above for `yourserver`
. Try setting it in the general section, in case you do not
get it working in a `vhost`
at first.
*Update:* Steffen Land from [Apache Lounge](https://www.apachelounge.com) pointed me to the [HTTP/2 indicator Add-on for Firefox](https://addons.mozilla.org/en-US/firefox/addon/spdy-indicator/). Nice if
you want to see in how many places you already talk `h2`
(Hint: Apache Lounge talks h2 for some time now...).
In Firefox you can to open the Developer Tools and there the Network tab to check for HTTP/2 connections. When
you have those open and reload your html page, you see something like the following:
Among the response headers, you see this strange `X-Firefox-Spdy`
entry listing "h2". That
is the indication that HTTP/2 is used on this `https:`
connection.
In Google Chrome, you will not see a HTTP/2 indicator in the developer tools. Instead, Chrome uses the
special location `chrome://net-internals/#http2`
to give information.
If you have opened a page on your server and look at that net-internals page, you will see something like this:
If your server is among the ones listed here, it is working.
HTTP/2 is supported in the Windows 10 successor to Internet Explorer: Edge. Here you can also see
the protocol used in the Developer Tools in the Network tab:
In Apple's Safari, you open the Developer Tools and there the Network tab. Reload your server page and select the
row in the Developer Tools that shows the load. If you enable the right side details view, look at the `Status`
.
It should show `HTTP/2.0 200`
like here:
Renegotiations on a `https:`
connection means that certain TLS parameters are changed
on the running connection.
In Apache httpd you can change TLS parameters in directory configurations. If a request arrives for
a resource in a certain location, configured TLS parameter are compared to the current TLS
parameters. If they differ, renegotiation is triggered.
Most common use cases for this are cipher changes and client certificates. You can require clients to meet authentication only for special locations, or you might enable more secure, but CPU intensive ciphers for specific resources.
Whatever your good use cases are, renegotiation are a `MUST NOT`
in HTTP/2. With 100s
of requests ongoing on the same connection, which renegotiation would otherwise occur when?
The current `mod_h[ttp]2`
does not protect you from such configuration. If you have a
site which uses TLS renegotiation, `DO NOT`
enable `h2`
on it!
Again, we will address that in future releases so that you can enable it safely.
If you need to debug a HTTP/2 connection with Apache, you can always raise the logging level for the `mod_http2`
module.
<IfModule http2_module> LogLevel http2:debug </IfModule>With
`debug`
connections and HTTP/2 frames received/sent are logged. This gives you clues, if HTTP/2 is used and if the server receives what you client thinks got sent and vice versa.
Experience shows that most interop problems arise from diverging ideas about the connection state between server and client. Especially flow control windows get often confused, which results in one side not sending any longer. The connection freezes up.
There is work underway to harmonize debug information by HTTP/2 servers. See [this internet draft](http://www.ietf.org/id/draft-benfield-http2-debug-state-01.txt). This is supported by `mod_http2`
since release 1.6.0. You
need to add the following configuration to your server:
<Location "/.well-known/h2/state"> SetHandler http2-status </Location>If you then open
`https://<yourserver>/.well-known/h2/state`
, the server sends you back a JSON document containing the
state of the connection and all open stream, including flow control window sizes. This is information about the connection itself that
you have open. Not about other connections, so your privacy is assured.
Modules implementing protocols other than HTTP may be incompatible with `mod_http2`
. This will
most certainly be the case when this other protocol requires the server to send data first.
`NNTP`
is one example of such a protocol. If you have a `mod_nntp_like_ssl`
configured in your server, do not even **load** `mod_http2`
. Wait for the next
release.
There are some restrictions on the `h2c`
implementation, you should be aware of:
You cannot deny `h2c direct`
on specific virtual hosts. `direct`
gets triggered at
connection setup when there is not request to be seen yet. Which makes it impossible to foresee
which virtual host Apache needs to look at.
The `h2c`
Upgrade dance will not work on requests that have a body. Those are PUT and POST
requests (form submits and uploads). If you write a client, you may precede those requests with a
simple GET or an OPTIONS * to trigger the upgrade.
The reason is quite technical in nature, but in case you want to know: during Upgrade, the connection is in a half insane state. The request is coming in HTTP/1.1 format and the response is being written in HTTP/2 frames. If the request carries a body, the server needs to read the whole body before it sends a response back. Because the response might need answers from the client for flow control among other things. But if the HTTP/1.1 request is still being sent, the client is unable to talk HTTP/2 yet.
In order to make behaviour predictable, several server implementors decided to not do an Upgrade in the presence of any request bodies, even small ones.
The `h2c`
Upgrade dance also does currently not work when there is a general redirect
in place. Seems that rewrite happens before the `mod_http2`
has a chance to act. Certainly not
a deal breaker, but might be confusing when you test a site that has it.
There are some restrictions on the `h2`
implementation you should be aware of:
The HTTP/2 protocol allows reuse of TLS connections under certain conditions: if you have a certiface with wildcards or several altSubject names, browsers will reuse any existing connection they might have. Example:
You have a certificate for `a.example.org`
that has as additional name `b.example.org`
. You open in your browser the url `https://a.example.org/`
, open another tab and load `https://b.example.org/`
.
Before opening a new connection, the browser sees that it still has the one to `a.example.org`
open and that the certificate is also valid for `b.example.org`
. So, it sends the request for second tab over the connection of the first one.
This *connection reuse* is intentional and makes it easier for sites that have invested in *sharding*
for efficiency in HTTP/1 to also benefit from HTTP/2 without much change.
In Apache `mod_h[ttp]2`
this reuse is being supported since 2.4.18. But all hosts need the *exact same*
SSL configuration. Otherwise connection sharing is denied by the server.
Münster, 12.10.2015,
Stefan Eissing, greenbytes GmbH
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without warranty of any kind. See LICENSE for details. |
6,727 | 微软开源 .NET 一年后…… | http://mattwarren.org/2015/12/08/open-source-net-1-year-later/ | 2015-12-12T09:51:00 | [
"微软",
".NET",
"开源"
] | https://linux.cn/article-6727-1.html | 
大约一年前,微软宣布[开源了 .NET 框架的大部分](/article-4209-1.html)。当时,Scott Hanselman 使用微软 Power BI [对代码库做了一个漂亮的分析](http://www.hanselman.com/blog/TheNETCoreCLRIsNowOpenSourceSoIRanTheGitHubRepoThroughMicrosoftPowerBI.aspx)。 现在一年过去了,我想要试试对以下问题做个解答:
>
> 微软开源了 .NET 框架的大部分之后,**社区**参与贡献了多少?
>
>
>
我着眼于以下三个项目做了分析,它们是 .NET 生态系统中最主要部分之一,也是 .NET 基金会内 [最活跃/收藏/分支的项目](https://github.com/dotnet/)之一:
* [**Roslyn**](https://github.com/dotnet/roslyn/) – .NET 编译器平台,提供了开源的 C# 和 Visual Basic 编译器,以及丰富的代码分析 API。
* [**CoreCLR**](https://github.com/dotnet/coreclr/) – .NET Core 运行时环境和底层库(mscorlib),它包括垃圾回收、JIT 编译器、基本的 .NET 数据类型和许多底层类。
* [**CoreFX**](https://github.com/dotnet/corefx/) – .NET Core 基础库,包括 collections、文件系统、console、XML、异步以及其它方面的类。
### 数据来自哪里?
GitHub 自身已经内建了很多漂亮的图表了,你可以看看这一年来**每月提交数**的图表:
[](https://github.com/dotnet/roslyn/graphs/contributors)
还可以看看**每月动态**:
[](https://github.com/dotnet/roslyn/pulse/monthly)
但是要回答上面的问题,我需要更多的数据。幸运的是, GitHub 提供了[非常全面的 API](https://developer.github.com/v3/), 再配合上出色的 [Octokit.net 库](https://github.com/octokit/octokit.net)以及 [brilliant LINQPad](https://www.linqpad.net/),我就很容易的得到了我所需的全部数据。如果你想要自己试试这些 API ,这儿有个[示例的 LINQPad 脚本](https://gist.github.com/mattwarren/894aa5f46ca62a63764a)。
然而,仅仅知道它的每月 “<ruby> 问题 <rp> ( </rp> <rt> issue </rt> <rp> ) </rp></ruby>数量” 或 “接受的PR( <ruby> 拉取请求 <rp> ( </rp> <rt> Pull Request </rt> <rp> ) </rp></ruby>)”并没有太大用处,这并不能告诉我们是谁提交了这些问题或 PR。 幸运的是, GitHub 典型的用户是有分类的,比如下图来自 [Roslyn 第 670 号问题](https://github.com/dotnet/roslyn/issues/670) ,我们可以看到是哪种类型的用户提交的备注:“<ruby> 拥有者 <rp> ( </rp> <rt> Owner </rt> <rp> ) </rp></ruby>”、 “<ruby> 协作者 <rp> ( </rp> <rt> Collaborator </rt> <rp> ) </rp></ruby>” 或者为空——这就是“社区”成员,比如下面的某人(我觉得)并没有在微软工作。
[](https://cloud.githubusercontent.com/assets/157298/11634101/8abd7210-9d06-11e5-82b0-570f296cf433.png)
### **结果呢?**
现在我们可以得到我们所需的数据,也就可以生成结果了。
#### **全部问题 - 按提交者分组**
| 项目 | **拥有者** | **协作者** | **社区** | **全部** |
| --- | --- | --- | --- | --- |
| Roslyn | 481 | 1867 | 1596 | 3944 |
| CoreCLR | 86 | 298 | 487 | 871 |
| CoreFX | 334 | 911 | 735 | 1980 |
| | | | | |
| **全部** | 901 | 3076 | 2818 | |
这里你可以看到拥有者和协作者在某些情况下占有主导地位,比如,在 Roslyn 项目中 60% 的问题是他们汇报的。但是在另外的例子中社区非常活跃,特别是在 CoreCLR 项目中社区成员汇报的问题超过了拥有者/协作者之和。造成这种情况的部分原因是项目的不同, CoreCLR 是 .NET 框架中最引人注目的部分,因为它包含了 .NET 开发者日常使用的大部分库,所以并不用对社区提交了很多改进建议和错误修复的事情感到惊奇。 另外, CoreCLR 已经出现了较长时间,社区已经使用了一段时间,也能找到它的一些不足的部分。而 Roslyn 则相对较新一些,还没有被太多的使用过,而且找到一个编译器的 bug 显然会更难。
#### 全部已接受的 PR - 按提交者分组
| 项目 | **拥有者** | **协作者** | **社区** | **全部** |
| --- | --- | --- | --- | --- |
| **Roslyn** | 465 | 2093 | 118 | 2676 |
| **CoreCLR** | 378 | 567 | 201 | 1146 |
| **CoreFX** | 516 | 1409 | 464 | 2389 |
| | | | | |
| **全部** | 1359 | 4069 | 783 | |
但是,如果我们来看一下已接受的 PR ,可以看到在这三个项目中社区的贡献量非常低,仅仅只有 12% 左右。不过,这并不令人吃惊,因为 PR 需要达到相当高的水准才能被接受。如果项目采用这种机制,首先你必须找到一个<ruby> <a href="https://github.com/dotnet/corefx/labels/up%20for%20grabs"> “需要解决” </a> <rp> ( </rp> <rt> up for grabs </rt> <rp> ) </rp></ruby>的问题,然后如果你[要改变 API 就必须通过代码审查](http://blogs.msdn.com/b/dotnet/archive/2015/01/08/api-review-process-for-net-core.aspx),最后你必须在代码审查中符合可比性/性能提升/正确性等。所以,实际上 12% 是个相当不错的结果,接受的 PR 解决了不少的问题,特别是考虑到大部分贡献都是社区成员在工作之余完成的。
**更新:**关于对“需要解决”的要求,参见 [David Kean](https://github.com/davkean) 的[这个评论](http://mattwarren.org/2015/12/08/open-source-net-1-year-later/#comment-7091),以及[这条推](https://twitter.com/leppie/status/674285812146675714)来了解更多信息。“需要解决”是一个准则,旨在帮助新手,但是并不是必需的,你可以提交一个解决问题的 PR 而不打上这个标签。
最后,如果你看一下每月的数量(参见下面的两张图,点击放大),很难找到特定的趋势,或者说,社区肯定会随着时间的变化或多或少的做出贡献。不过,你也可以说,过去一年来社区一直在做贡献,而且看起来还会继续贡献下去。这不是仅仅出现在项目刚刚开源后的一次性喷发,而是一整年以来的贡献的持续水平。
#### **每月的问题数 - 按提交者分组**
[](https://cloud.githubusercontent.com/assets/157298/11596712/ad28f518-9aae-11e5-81d9-42bc22903d09.png)
#### **每月接受的 PR - 按提交者分组**
[](https://cloud.githubusercontent.com/assets/157298/11652755/785d0d20-9d91-11e5-9802-834bb3955718.png)
### **前 20 的问题标签**
最后一件我想对我拥有的这些数据所做的事情是找到那些最流行的问题标签,这可以揭示从三个项目开源以来哪种类型的工作不断出现。
[](https://cloud.githubusercontent.com/assets/157298/11633496/8505205a-9d03-11e5-89fd-33384b20306c.png)
以下是关于这些结果的一些看法:
* 列表中 **[CodeGen](https://github.com/dotnet/coreclr/labels/CodeGen)** 排名如此之高没有什么好惊奇的,[下一代的 .NET JIT 编译器 RyuJIT](http://blogs.msdn.com/b/dotnet/archive/2013/09/30/ryujit-the-next-generation-jit-compiler.aspx) 才发布了仅仅两年而已。然而如此多的问题还是让人有一点点担心,特别是考虑到它们中的一些会带来[严重的后果](https://github.com/dotnet/coreclr/issues/1296),就如 [Stack Overflow 的开发人员](http://nickcraver.com/blog/2015/07/27/why-you-should-wait-on-dotnet-46/)发现的那样!题外话,如果你想要了解 JIT 的许多底层细节,可以看看 [@MikeDN 评论过的](https://github.com/dotnet/coreclr/issues?utf8=%E2%9C%93&q=commenter%3Amikedn+type%3Aissue)这个问题,令人难以置信的是,有些掌握了很多知识的人却自己并不从事这方面工作,甚至是微软的另外团队的!
* 这三个项目都有许多“需要解决”的问题: [Roslyn](https://github.com/dotnet/roslyn/labels/Up%20for%20Grabs)、 [CoreCLR](https://github.com/dotnet/coreclr/labels/up-for-grabs) 和 [CoreFX](https://github.com/dotnet/corefx/labels/up%20for%20grabs),而且社区似乎也在[添加需要解决的问题](https://github.com/dotnet/corefx/labels/grabbed%20by%20community)!
* 最后,我很高兴的看到 [性能](https://github.com/dotnet/corefx/labels/performance) 和 [优化](https://github.com/dotnet/coreCLR/labels/optimization) 日益得到了重视,毕竟<ruby> <a href="http://mattwarren.org/speaking/"> 性能是王道! </a> <rp> ( </rp> <rt> Performance is a Feature!! </rt> <rp> ) </rp></ruby>
| 301 | Moved Permanently | null |
6,733 | 使用 netcat [nc] 命令对 Linux 和 Unix 进行端口扫描 | http://www.cyberciti.biz/faq/linux-port-scanning/ | 2015-12-14T08:14:00 | [
"netcat",
"nmap",
"nc",
"扫描"
] | https://linux.cn/article-6733-1.html | 我如何在自己的服务器上找出哪些端口是开放的?如何使用 nc 命令进行端口扫描来替换 [Linux 或类 Unix 中的 nmap 命令](/article-2561-1.html)?
nmap (“Network Mapper”)是一个用于网络探测和安全审核的开源工具。如果 nmap 没有安装或者你不希望使用 nmap,那你可以用 netcat/nc 命令进行端口扫描。它对于查看目标计算机上哪些端口是开放的或者运行着服务是非常有用的。你也可以使用 [nmap 命令进行端口扫描](/article-2561-1.html) 。

### 如何使用 nc 来扫描 Linux,UNIX 和 Windows 服务器的端口呢?
如果未安装 nmap,试试 nc/netcat 命令,如下所示。-z 参数用来告诉 nc 报告开放的端口,而不是启动连接。在 nc 命令中使用 -z 参数时,你需要在主机名/ip 后面限定端口的范围和加速其运行:
```
### 语法 ###
### nc -z -v {host-name-here} {port-range-here}
nc -z -v host-name-here ssh
nc -z -v host-name-here 22
nc -w 1 -z -v server-name-here port-Number-her
### 扫描 1 to 1023 端口 ###
nc -zv vip-1.vsnl.nixcraft.in 1-1023
```
输出示例:
```
Connection to localhost 25 port [tcp/smtp] succeeded!
Connection to vip-1.vsnl.nixcraft.in 25 port [tcp/smtp] succeeded!
Connection to vip-1.vsnl.nixcraft.in 80 port [tcp/http] succeeded!
Connection to vip-1.vsnl.nixcraft.in 143 port [tcp/imap] succeeded!
Connection to vip-1.vsnl.nixcraft.in 199 port [tcp/smux] succeeded!
Connection to vip-1.vsnl.nixcraft.in 783 port [tcp/*] succeeded!
Connection to vip-1.vsnl.nixcraft.in 904 port [tcp/vmware-authd] succeeded!
Connection to vip-1.vsnl.nixcraft.in 993 port [tcp/imaps] succeeded!
```
你也可以扫描单个端口:
```
nc -zv v.txvip1 443
nc -zv v.txvip1 80
nc -zv v.txvip1 22
nc -zv v.txvip1 21
nc -zv v.txvip1 smtp
nc -zvn v.txvip1 ftp
### 使用1秒的超时值来更快的扫描 ###
netcat -v -z -n -w 1 v.txvip1 1-1023
```
输出示例:

*图01:Linux/Unix:使用 Netcat 来测试 TCP 和 UDP 与服务器建立连接*
1. -z : 端口扫描模式即零 I/O 模式。
2. -v : 显示详细信息 [使用 -vv 来输出更详细的信息]。
3. -n : 使用纯数字 IP 地址,即不用 DNS 来解析 IP 地址。
4. -w 1 : 设置超时值设置为1。
更多例子:
```
$ netcat -z -vv www.cyberciti.biz http
www.cyberciti.biz [75.126.153.206] 80 (http) open
sent 0, rcvd 0
$ netcat -z -vv google.com https
DNS fwd/rev mismatch: google.com != maa03s16-in-f2.1e100.net
DNS fwd/rev mismatch: google.com != maa03s16-in-f6.1e100.net
DNS fwd/rev mismatch: google.com != maa03s16-in-f5.1e100.net
DNS fwd/rev mismatch: google.com != maa03s16-in-f3.1e100.net
DNS fwd/rev mismatch: google.com != maa03s16-in-f8.1e100.net
DNS fwd/rev mismatch: google.com != maa03s16-in-f0.1e100.net
DNS fwd/rev mismatch: google.com != maa03s16-in-f7.1e100.net
DNS fwd/rev mismatch: google.com != maa03s16-in-f4.1e100.net
google.com [74.125.236.162] 443 (https) open
sent 0, rcvd 0
$ netcat -v -z -n -w 1 192.168.1.254 1-1023
(UNKNOWN) [192.168.1.254] 989 (ftps-data) open
(UNKNOWN) [192.168.1.254] 443 (https) open
(UNKNOWN) [192.168.1.254] 53 (domain) open
```
也可以看看 :
* [使用 nmap 命令扫描网络中开放的端口](/article-2561-1.html)。
* 手册页 - [nc(1)](http://www.manpager.com/linux/man1/nc.1.html), [nmap(1)](http://www.manpager.com/linux/man1/nmap.1.html)
---
via: <http://www.cyberciti.biz/faq/linux-port-scanning/>
作者:Vivek Gite 译者:[strugglingyouth](https://github.com/strugglingyouth) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,734 | 如何使用 pv 命令监控 linux 命令的执行进度 | https://www.maketecheasier.com/monitor-progress-linux-command-line-operation/ | 2015-12-14T10:29:00 | [
"pv"
] | https://linux.cn/article-6734-1.html | 
如果你是一个 linux 系统管理员,那么毫无疑问你必须花费大量的工作时间在命令行上:安装和卸载软件,监视系统状态,复制、移动、删除文件,查错,等等。很多时候都是你输入一个命令,然后等待很长时间直到执行完成。也有的时候你执行的命令挂起了,而你只能猜测命令执行的实际情况。
通常 linux 命令不提供和进度相关的信息,而这些信息特别重要,尤其当你只有有限的时间时。然而这并不意味着你是无助的——现在有一个命令,pv,它会显示当前在命令行执行的命令的进度信息。在本文我们会讨论它并用几个简单的例子说明其特性。
### PV 命令
[PV](http://linux.die.net/man/1/pv) 由Andrew Wood 开发,是 Pipe Viewer 的简称,意思是通过管道显示数据处理进度的信息。这些信息包括已经耗费的时间,完成的百分比(通过进度条显示),当前的速度,全部传输的数据,以及估计剩余的时间。
>
> "要使用 PV,需要配合合适的选项,把它放置在两个进程之间的管道。命令的标准输入将会通过标准输出传进来的,而进度会被输出到标准错误输出。”
>
>
>
上述解释来自该命令的帮助页。
### 下载和安装
Debian 系的操作系统,如 Ubuntu,可以简单的使用下面的命令安装 PV:
```
sudo apt-get install pv
```
如果你使用了其他发行版本,你可以使用各自的包管理软件在你的系统上安装 PV。一旦 PV 安装好了你就可以在各种场合使用它(详见下文)。需要注意的是下面所有例子都使用的是 pv 1.2.0。
### 特性和用法
我们(在 linux 上使用命令行的用户)的大多数使用场景都会用到的命令是从一个 USB 驱动器拷贝电影文件到你的电脑。如果你使用 cp 来完成上面的任务,你会什么情况都不清楚,直到整个复制过程结束或者出错。
然而pv 命令在这种情景下很有帮助。比如:
```
pv /media/himanshu/1AC2-A8E3/fNf.mkv > ./Desktop/fnf.mkv
```
输出如下:

所以,如你所见,这个命令显示了很多和操作有关的有用信息,包括已经传输了的数据量,花费的时间,传输速率,进度条,进度的百分比,以及剩余的时间。
`pv` 命令提供了多种显示选项开关。比如,你可以使用`-p` 来显示百分比,`-t` 来显示时间,`-r` 表示传输速率,`-e` 代表eta(LCTT 译注:估计剩余的时间)。好事是你不必记住某一个选项,因为默认这几个选项都是启用的。但是,如果你只要其中某一个信息,那么可以通过控制这几个选项来完成任务。
这里还有一个`-n` 选项来允许 pv 命令显示整数百分比,在标准错误输出上每行显示一个数字,用来替代通常的可视进度条。下面是一个例子:
```
pv -n /media/himanshu/1AC2-A8E3/fNf.mkv > ./Desktop/fnf.mkv
```

这个特殊的选项非常合适某些情境下的需求,如你想把用管道把输出传给[dialog](http://linux.die.net/man/1/dialog) 命令。
接下来还有一个命令行选项,`-L` 可以让你修改 pv 命令的传输速率。举个例子,使用 -L 选项来限制传输速率为2MB/s。
```
pv -L 2m /media/himanshu/1AC2-A8E3/fNf.mkv > ./Desktop/fnf.mkv
```

如上图所见,数据传输速度按照我们的要求被限制了。
另一个pv 可以帮上忙的情景是压缩文件。这里有一个例子可以向你解释如何与压缩软件Gzip 一起工作。
```
pv /media/himanshu/1AC2-A8E3/fnf.mkv | gzip > ./Desktop/fnf.log.gz
```

### 结论
如上所述,pv 是一个非常有用的小工具,它可以在命令没有按照预期执行的情况下帮你节省你宝贵的时间。而且这些显示的信息还可以用在 shell 脚本里。我强烈的推荐你使用这个命令,它值得你一试。
---
via: <https://www.maketecheasier.com/monitor-progress-linux-command-line-operation/>
作者:[Himanshu Arora](https://www.maketecheasier.com/author/himanshu/) 译者:[ezio](https://github.com/oska874) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | If you’re a Linux system admin, there’s no doubt that you must be spending most of your work time on the command line – installing and removing packages; monitoring system stats; copying, moving, deleting stuff; debugging problems; and more. There are times when you fire a command, and it takes a while before the operation completes. However, there are also times when the command you executed just hangs, leaving you guessing as to what’s actually happening behind the scenes.
Usually, Linux commands provide no information related to the progress of the ongoing operation, something that is very important especially when you have limited time. However, that doesn’t mean you’re helpless – there exists a command, dubbed `pv`
, that displays useful progress information related to the ongoing command line operation. In this article we will discuss this command as well as its features through some easy-to-understand examples.
## PV Command
Developed by Andrew Wood, [PV](https://linux.die.net/man/1/pv) – which stands for Pipe Viewer – displays information related to the progress of data through a pipeline. The information includes time elapsed, percentage completed (with progress bar), current throughput rate, total data transferred, and ETA.
“To use it, insert it in a pipeline between two processes, with the appropriate options. Its standard input will be passed through to its standard output and progress will be shown on standard error,”
The above explains the command’s man page.
## Download and Installation
Users of Debian-based systems like Ubuntu can easily install the utility by running the following command in terminal:
sudo apt-get install pv
If you’re using any other Linux distro, you can install the command using the package manager installed on your system. Once installed successfully you can use the command line utility in various scenarios (see the following section). It’s worth mentioning that pv version 1.2.0 has been used in all the examples mentioned in this article.
## Features and Usage
A very common scenario that probably most of us (who work on the command line in Linux) would relate to is copying a movie file from a USB drive to your computer. If you try to complete the aforementioned operation using the `cp`
command, you’ll have to blindly wait until the copying is complete or some error is thrown.
However, the `pv`
command can be helpful in this case. Here is an example:
pv /media/himanshu/1AC2-A8E3/fNf.mkv > ./Desktop/fnf.mkv
And here’s the output:
So, as you can see above, the command shows a lot of useful information related to the ongoing operation, including the amount of data that has been transferred, time elapsed, rate of transfer, progress bar, progress in percentage, and the amount of time left.
The `pv`
command provides various display switches. For example, you can use `-p`
for displaying percentage, `-t`
for timer, `-r`
for rate of transfer, `-e`
for eta, and `-b`
for byte counter. The good thing is that you won’t have to remember any of them, as all of them are enabled by default. However, should you exclusively require information related to only a particular display switch in the output, you can pass that switch in the `pv`
command.
There’s also a `-n`
display switch that allows the command to display an integer percentage, one per line on standard error, instead of the regular visual progress indicator. The following is an example of this switch in action:
pv -n /media/himanshu/1AC2-A8E3/fNf.mkv > ./Desktop/fnf.mkv
This particular display switch is suitable in scenarios where you want to pipe the output into the [dialog](https://linux.die.net/man/1/dialog) command.
Moving on, there’s also a command line option, `-L`
, that lets you modify the data transfer rate of the pv command. For example, I used `-L`
to limit the data transfer rate to 2MB/s.
pv -L 2m /media/himanshu/1AC2-A8E3/fNf.mkv > ./Desktop/fnf.mkv
As can be seen in the screenshot above, the data transfer rate was capped according to my direction.
Another scenario where `pv`
can help is while compressing files. Here is an example of how you can use this command while compressing files using Gzip:
pv /media/himanshu/1AC2-A8E3/fnf.mkv | gzip > ./Desktop/fnf.log.gz
## Conclusion
As you have observed, `pv`
is a useful little utility that could help you save your precious time in case a command line operation isn’t behaving as expected. Plus, the information it displays can also be used in shell scripts. I’d strongly recommend this command; it’s worth giving a try.
Our latest tutorials delivered straight to your inbox |
6,735 | 网上订票惊爆信息泄露风险,你还敢在网上订票吗? | http://www.aliyun.com/product/ddos/?spm=5176.383338.201.54.d66cGm | 2015-12-14T16:00:00 | [
"https"
] | https://linux.cn/article-6735-1.html | 据外媒 Softpedia [消息](http://news.softpedia.com/news/four-major-airlines-don-t-use-https-expose-customer-credit-card-numbers-497380.shtml),移动数据领域的初创企业 Wandera 最近的一份调查报告显示,包括加拿大航空、亚航等四家大型航空公司在内的全球十余家航空、铁路、出租、票务等方面的大型公司由于没有部署移动端 HTTPS 访问,导致用户信息存在巨大的泄露风险!这些公司往往都已经在其网站上部署了 HTTPS 服务,但是其提供的针对手机的移动网站和 app 客户端的访问上,却没有相应的也使用 HTTPS 服务。这就导致了它们为每日高达50万用户访问所提供的服务存在着巨大的信息泄露风险。

尤其是当用户使用不可靠的公用互联网接入,如咖啡馆、商场的免费 WIFI,通过手机浏览器或 app 客户端访问这些没有采用 HTTPS 的服务时,就存在很大的被截获各种私人敏感信息的风险,比如身份信息、用户名、密码,乃至于信用卡号码等。这些数据泄露风险从何时开始,造成了多大的数据泄露已不可考。报告披露后,已有公司采取技术手段解决了该安全风险。
该调查主要针对欧美国家,并未涉及到中国国内情况。但是据我们对国内的网站、移动网站及 app 客户端的 HTTPS 部署情况的了解,这种风险同样存在,甚至会更严重。
而另一方面,据 CNNIC [调查数据](http://www.cnnic.net.cn/hlwfzyj/hlwxzbg/hlwtjbg/201507/P020150723549500667087.pdf)显示,截止至 2015 年上半年,手机支付、手机网购、手机旅行预订用户规模分别达到 2.76 亿、 2.70 亿和 1.68 亿。同样据 CNNIC 数据,超过 40% 的人会使用网吧、公共场所等场所的 WIFI 接入互联网。
综合来看,采用移动客户端进行网上交易,当使用不安全的网络接入时,如果所访问的网站又没有做好必要的安全措施时,就有很大的风险泄露访问者的个人敏感信息。
### 怎样才能避免这样的风险?难道不能网上订票了吗?
其实,避免这样的安全风险的解决方案已经有了,那就是网站服务商应该向用户提供符合安全标准的 **HTTPS** 服务,而不是采用老旧的、不安全的 HTTP 服务。这样,即便访问者所处的环境并非十分安全可靠,依旧可以极大地降低用户的风险。
#### 什么是 HTTPS 呢?
HTTPS(全称:Hyper Text Transfer Protocol over Secure Socket Layer),是以安全为目标建立客户浏览器端与服务器端进行数据传输的通道,简单来说就是 HTTP 的安全版。它最初由网景公司创建出来并内置在其浏览器中。
HTTPS 之所以能够做到数据的安全传输,是通过 SSL/TLS 协议完成的。只有通信的双方才具备数据的加解密功能,而数据在中间通道的传输时已经加密。加密算法一般使用 AES 或 RSA 等,并且通过目前的科学分析,不大可能通过计算能力提升而使得正确配置的密码算法得到轻易地破解。
因此我们说,HTTPS是安全的。
#### 为什么越来越多的网站选择 HTTPS?
近年来,重视安全的大厂商都在逐步加快网站部署 HTTPS 的速度。搜索引擎巨头 Google、淘宝天猫、百度等均全站启用 HTTPS,相信在未来,会有越来越多的网站加入全站 HTTPS 化的行列中。
为什么 HTTPS 如此受到青睐? 答案不言而喻,自然是因为 HTTPS 能够给网站带来更多的价值。这些价值主要体现在:
1. 确保了流量的安全性,被拦截窃听后也无法获取真实信息,避免了隐私数据在网络上外泄的可能。这也是为什么所有的金融、支付类网站强制要求必须为 HTTPS 服务的原因。
2. 安全性较高的网站往往在搜索引擎同类型中有着较高的排名。
3. 浏览器的可信标识能够加强普通用户对网站的信任感。
既然 HTTPS 能够对网站带来非常实用的价值,可以预测的是,在安全这个需求越来越受到网民以及网站管理者重视的趋势下,未来 HTTPS 将彻底取代 HTTP,成为网站数据通信的主流方式。
#### 如何部署 HTTPS ?
简单来说,作为网站服务提供方,你首先需要购买被主流浏览器所认可的 CA 颁发的 HTTPS 证书;然后依据你的 Web 服务器的不同,如 apache、nginx ,采用不同的配置,提供监听在 TCP/443 端口 HTTPS 服务;最后,要测试你的 HTTPS 服务是否功能正常、性能是否受到影响、是否影响了用户体验等方面。
具体的技术描述,就不在这里逐一展开了,请根据你的 IT 基础架构进行部署。一般而言,对于小型网站来说, 部署 HTTPS 服务还是比较简单的,但是对于规模较大、业务复杂的网站来说,部署 HTTPS 服务还是一项艰巨的工程。此外,据闻阿里云准备推出进行 HTTPS 服务封装的分布式服务,可以将你的 HTTP 服务无缝地封装成 HTTPS 服务,并且同时提供了服务加速(CDN)、攻击防护(WAF)和流量清洗(DDoS/CC)等功能。
### 部署了 HTTPS 服务,终于可以放心了?
当你终于部署好了 HTTPS 服务后,看到浏览器地址栏中的绿色标示,是不是感觉成就满满——妈妈再也不用担心我的用户信息被偷走了 :D

但是,且慢,其实你还只是接上了一块短板,还有一块短板依旧在流淌着水呢。
由于 HTTPS 服务对传输的内容进行了加密,理论上说,只有服务器端和客户端才能正确加密和解密数据,因此,你以前所用的基于云的 WAF (Web 应用防火墙)可能不支持 HTTPS,从而没法为你提供对 XSS 、SQL 注入等应用攻击层面的防护能力了。
通常的安全产品不能很好的支持 HTTPS 网站防护。其原因主要有:
1. 目前的云防护或者是传统安全防护一般都是采用代理的模式。即采用将流量引入到安全防护产品中,通过检测分析,发现异常攻击,然后采取防护措施。但由于 HTTPS 对数据进行了加密,因此防护产品不能在应用层详细的解析出 HTTP 报文内容,自然不能识别攻击与合法流量,从而对威胁攻击束手无策。
2. 由于涉及到建立连接的握手加解密协商,HTTPS 需要消耗的性能通常是 HTTP 的数倍。一般的防护产品没有搭建大规模防护集群的能力,因此无力做到大流量的 HTTPS 防护。
那好吧,你还可以购买硬件的 WAF 防火墙,但是,当 DDoS/CC 攻击和流量攻击如洪水般涌来时,你的 WAF 和线路能支撑多久?
是不是感觉踩下一块板,又翘起来另外一块?由于部署了 HTTPS ,从而导致原本可以防护应用层面攻击的分布式 WAF 服务反而不能用了?
另外,还有一件可能令你感到悲伤的事情,作为访问量蒸蒸日上的你的网站,采用 CDN 提供分布式的访问支持那简直是一定的,但是,目前支持 HTTPS 的 CDN 服务商还很少。
怎么办?难道使用 HTTPS 服务是个错误吗?
### 我来告诉你一个完整的解决方案……
以下是广告时间,阿里云云盾高防产品……什么,原来是软文?!
好吧,我们来谈谈技术问题。
本质上来说,云防护产品支持 HTTPS 是可行的,但是这里需要解决几个问题:
1. 如何透明的解析 HTTPS 流量,并针对流量特征进行分析和处置?
2. 如何避免升级到 HTTPS 所带来的处理能力降低、性能衰减的问题?
针对此种情况,阿里云云盾高防产品特别推出了支持 HTTPS 的应用层防护功能。其技术原理图如下:

实现的步骤为:
1. 用户在云盾高防控制台中导入对应域名的**证书**和**私钥**、配置域名信息。
2. 客户端与云盾高防进行 SSL 握手协商,协商通过后,使用云盾颁发的证书及公钥加密数据。
3. 云盾高防进行数据解密,进行安全防护分析后,将合法的流量重新加密传至服务器端,同时阻断掉非法的攻击流量。
4. 服务器端进行数据解密,实现正常业务。
通过以上方式,在客户业务无任何改造的情况下,云盾帮助用户实现了全链路端到端的数据加密。与此同时,由于进行了数据解密,云盾具备了分析应用层数据的能力,因此具备了转发流量到指定地址,进行细粒度安全防护的能力。包括且不限于:
1. 高达 300G 的 DDoS 防护能力。
2. 海量的 CC 攻击防护能力(集群可支持千万级 QPS 的攻击流量清洗)。
3. Web 应用漏洞攻击的阻断防护能力(包括 SQL 注入、XSS、命令注入、木马 Shell 等通用 Web 攻击形式)。
4. 提供丰富多样的应用层数据报表,不仅包括安全的详细报表,同时也会覆盖到业务访问的数据情况。
5. 支持对部署在阿里云之外的主机的安全防护。
当然,如果您对数据隐私安全性要求比较高,可能会比较担心私钥放在云盾上的安全性。针对这种顾虑,也有对应的私钥安全解决方案。
另外,如果您对于自己部署 HTTPS 服务感觉棘手,阿里云云盾也有计划在近期推出 HTTP 直接变身 HTTPS 的服务,支持 HTTP 用户在无需更改自身业务的前提下,升级变为 HTTPS。
更多详情,可以戳戳[这个链接](http://www.aliyun.com/product/ddos/?spm=5176.383338.201.54.d66cGm)看看。
| 301 | Moved Permanently | null |
6,740 | KDE Plasma 5.5 发布! | https://www.kde.org/announcements/plasma-5.5.0.php | 2015-12-15T13:16:00 | [
"KDE"
] | https://linux.cn/article-6740-1.html | 
>
> 2015/12/8 KDE 发布了其桌面软件的重要更新: Plasma 5.5 。
>
>
>
在这最近的四个月里我们努力地将产品打磨顺滑,为其增加了新的工作流,让 Plasma 比以往更漂亮,为将来打好了坚实的基础。
### 更新了 Breeze Plasma 主题
Breeze Plasma <ruby> 部件 <rp> ( </rp> <rt> widget </rt> <rp> ) </rp></ruby>主题现在看起来更和谐了。

Breeze 图标主题增加了一些新图标,也更新了原有图标,改进了视觉设计。
### Plasma <ruby> 部件 <rp> ( </rp> <rt> Widget </rt> <rp> ) </rp></ruby>管理器
Plasma <ruby> 部件 <rp> ( </rp> <rt> widget </rt> <rp> ) </rp></ruby>管理器现在支持两列视图了,有了适用于 Breeze, Breeze Dark 和 Oxygen 主题的新的部件图标。
### 扩展了<ruby> 应用启动器 <rp> ( </rp> <rt> Application Launcher </rt> <rp> ) </rp></ruby>上的功能
<ruby> 应用启动器 <rp> ( </rp> <rt> Application Launcher </rt> <rp> ) </rp></ruby> ('Kickoff') 上的右键菜单现在可以列出最近在应用中打开的文档,允许编辑应用的菜单项和添加应用到面板上、<ruby> 任务管理器 <rp> ( </rp> <rt> Task Manager </rt> <rp> ) </rp></ruby>或桌面上。 “<ruby> 收藏 <rp> ( </rp> <rt> Favorites </rt> <rp> ) </rp></ruby>”现在可以收藏文档、目录和系统动作等,它们也可以通过搜索结果来创建。这些功能(以及另外一些)以前只能在替代<ruby> 应用菜单 <rp> ( </rp> <rt> Application Menu </rt> <rp> ) </rp></ruby> ('Kicker') 上使用,现在它们成了默认的<ruby> 应用启动器 <rp> ( </rp> <rt> Application Launcher </rt> <rp> ) </rp></ruby>的功能了,这两个启动器共享同一个后端。
### Plasma 的新部件
#### <ruby> 颜色吸取器 <rp> ( </rp> <rt> Color Picker </rt> <rp> ) </rp></ruby>
我们不仅仅恢复了<ruby> 颜色吸取器 <rp> ( </rp> <rt> Color Picker </rt> <rp> ) </rp></ruby>,而且我们在 Plasma 5 中给了它一个新的 UI 界面。

<ruby> 颜色吸取器 <rp> ( </rp> <rt> Color Picker </rt> <rp> ) </rp></ruby>可以让你从屏幕上的任何地方提取颜色,并自动复制颜色代码到剪贴板中,支持多种格式 (RGB、Hex、 Qt QML rgba、 LaTeX)。
#### <ruby> 用户切换器 <rp> ( </rp> <rt> User Switcher </rt> <rp> ) </rp></ruby>

用户切换功能也更新改进了,现在可以从<ruby> 应用启动器 <rp> ( </rp> <rt> Application Launcher </rt> <rp> ) </rp></ruby>、<ruby> 用户切换 <rp> ( </rp> <rt> User Switcher </rt> <rp> ) </rp></ruby>组件和锁屏上访问它了。它会显示用户的全名及用户设置的头像。这在办公室内使用共享的桌面计算机时挺有用,更多信息请看[开发者的博客](http://blog.broulik.de/2015/10/polish-polish-polish-5-5-edition/)。
#### 磁盘限额
Plasma 5.5 有了一个为商业环境或大学设计的新组件,这个组件显示给你的不是磁盘的真实用量,而是你的系统管理员所允许你使用的限量。
#### <ruby> 活动分页器 <rp> ( </rp> <rt> Activity Pager </rt> <rp> ) </rp></ruby>
这是<ruby> 活动 <rp> ( </rp> <rt> activities </rt> <rp> ) </rp></ruby>与<ruby> 虚拟桌面 <rp> ( </rp> <rt> virtual desktops </rt> <rp> ) </rp></ruby>部分重叠的一个例子:它看起来像<ruby> 分页器 <rp> ( </rp> <rt> pager </rt> <rp> ) </rp></ruby>,行为也像,但是它使用<ruby> 活动 <rp> ( </rp> <rt> activities </rt> <rp> ) </rp></ruby>替代了<ruby> 虚拟桌面 <rp> ( </rp> <rt> virtual desktops </rt> <rp> ) </rp></ruby>。这可以让你快速看到正在运行中的<ruby> 活动 <rp> ( </rp> <rt> activities </rt> <rp> ) </rp></ruby>、有多少窗口与之关联。
### 恢复支持了旧式的系统托盘区图标
根据反馈,我们重写支持了那些不使用 [StatusNotifier](http://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/) 的旧式应用,它们的图标放在系统托盘区。

### Bug 状态
到 Plasma 5.5 beta 时,我们不可置信地[修复了超过1000个 bug](https://goo.gl/mckdTF)。
### KWin 支持 OpenGL ES
在 KWin 中,切换到 OpenGL ES 的支持回来了。到目前为止,支持仅通过环境变量切换并重启 KWin。设置环境 `KWIN_COMPOSE` 为 '`O2ES`' 可以强制切换到 OpenGL ES 后端。请注意, OpenGL ES 并没有被所有的驱动所支持。因为它不是通过配置方式公开的,所以要尝试的话,请你切换至“专家”模式。
### Wayland 支持进行中
Plasma 5.5 中提供了基本的 Wayland 会话功能。 Wayland 是过时的 X11 窗口系统的继任者,它提供了<ruby> 现代架构 <rp> ( </rp> <rt> modern approach </rt> <rp> ) </rp></ruby>。 这个系统更加安全(例如,键盘记录器就没那么容易弄进去了)。遵循“<ruby> 每帧都完美 <rp> ( </rp> <rt> every frame perfect </rt> <rp> ) </rp></ruby>” 原则,这让我们的显示效果更加完美。 KDE 社区已经在 Plasma 5.4 上基于电话项目的功能集提供了一个技术预览版。在 Plasma 5.5 中现在已经扩展得更适合“桌面风格”使用了。 桌面界面支持了类似窗口移动/调整的重要功能以及许多内置功能。 已经可以初步使用了,尽管我们需要指出的是它还不能完整地替代 X 会话。 我们鼓励更多的技术型用户多试用它,并将你所找到的 bug 汇报给我们。

为了配置 Wayland 会话所连接的屏幕,我们创建了一个新的[屏幕管理协议](http://vizzzion.org/blog/2015/11/screen-management-in-wayland/) 。
在 Wayland 中也增加了一些协议来控制 KWin 效果,比如窗口背景模糊和窗口最小化动画。
Wayland 会话上的 Plasma 现在有了一个特色的安全锁屏, 其中有一些在 X 会话里面不能完全做到的东西。关于这个11年之久的 bug,可以在 [screenlocker integration 开发者的博客](https://bhush9.github.io/2015/11/17/screenlocker-in-wayland/)了解到更多。
也可以看看[勘误页上关于 Wayland 的已知问题](https://community.kde.org/Plasma/5.5_Errata#KWin_Wayland)。
### Discover 的新设计
通过 KDE Visual Design Group 的帮助,我们的软件安装器有了新外观,改进了可用性。

### 新的默认字体
我们的默认字体切换到了 [Noto](https://www.google.com/get/noto/) ,这是一个漂亮的自由字体,它可以让各种语言都保持和谐的感受。

### 信息中心
文件索引器增加了一个状态模块。

### Plasma 网络管理器
我们的网络管理器应用[有了几个改进](https://grulja.wordpress.com/2015/11/08/upcoming-news-in-plasma-5-5/)。 增加了 WPA/WPA2 Enterprise 校验,使用了新的密码字段组件,OpenVPN 有了更多选项。
### 墙纸
Plasma 5.5 中我们有了一套新的[漂亮墙纸](https://kdeonlinux.wordpress.com/2015/11/13/wallpaper-contribution-for-plasma-5-5/)选集,来自 RJ Quiralta, Martin Klapetek, Timothée Giet, Dmitri Popov, Maciej Wiklo 和 Risto S 。
### 完整的变更日志
[参见完整的 Plasma 5.5.0 变更日志](https://www.kde.org/announcements/plasma-5.4.3-5.5.0-changelog.php)。
### 已知的问题
请参考 [Plasma 5.5 勘误页](https://community.kde.org/Plasma/5.5_Errata),了解一些最高配置的问题,包括一些由 Intel 驱动造成的问题。
### Live 镜像
体验 Plasma 5.5 的最容易的方式是用 USB 启动 Live 镜像。你可以在 KDE 社区维基中找到 [Plasma 5 的 Live 镜像](https://community.kde.org/Plasma/LiveImages)列表。
### 软件包下载
发布已经创建好了,或正在创建中,软件包列在我们的维基页面上。
* [软件包下载维基页](https://community.kde.org/Plasma/Packages)
### 源代码下载
你可以直接从源代码开始安装 Plasma 5。KDE 的社区维基有[编译指导](http://community.kde.org/Frameworks/Building)。注意, Plasma 5 不能和 Plasma 4 并存,你需要卸载旧的版本,或者安装到不同位置。
* [源代码信息页](https://www.kde.org/info/plasma-5.5.0.php)
| 301 | Moved Permanently | null |
6,745 | 末日即将来到,T-800 终结者内核版本 Linux 4.1.15 出现! | http://news.softpedia.com/news/Arnold-s-T-800-Terminator-Runs-Linux-Kernel-4-1-We-re-All-Doomed-473236.shtml | 2015-12-16T11:55:00 | [
"内核",
"Linux"
] | https://linux.cn/article-6745-1.html |
>
> 这或许是一个神奇的巧合,也许是预言。
>
>
>
如果你相信《终结者》电影中情节,那么我们很快就会看到世界末日了 :D 。 看起来,天网所控制的 T-800 机器人运行的是 Linux 内核 4.x,而 Linus Torvalds 先生刚刚释放了[最新的 4.1.15内核](http://thread.gmane.org/gmane.linux.kernel.stable/158560)——这正是电影中说的,T-800 机器人的内核版本。
Linus Torvalds 前一段时间说,他考虑启动 Linux 内核 4.x 版本,而不是发布 3.20 版本,因为他不想再看到像 2.6.32.x 这样啰嗦的版本号了。当时他还没有下定决心,于是在 [Google+](https://plus.google.com/+LinusTorvalds/posts/jmtzzLiiejc) 上[发起了投票](/article-4884-1.html),看看人们的选择。
当然,你现在已经知道了最后的投票结果和最终的决定了,Linux 内核走上了 4.x 分支。他说,他计划让 4.x 分支成为一个稳定的分支,因此要求开发者们专注于修复而不是添加新功能。
而在另一方面,终结者 T-800 运行的版本是 4.1.15,所以,Linus Torvalds 做出了一个非常“艰难的决定”,世界末日就靠它了:D。
### 终结者当然应该运行 Linux 啦
如果<ruby> 天网 <rp> ( </rp> <rt> Skynet </rt> <rp> ) </rp></ruby>真的那么无所不在,那么它显然应该是基于 Linux 的,同样,<ruby> 终结者 <rp> ( </rp> <rt> Terminator </rt> <rp> ) </rp></ruby>这样的<ruby> 半机器人 <rp> ( </rp> <rt> cyborg </rt> <rp> ) </rp></ruby>显然也应该是基于 Linux。你总不会想让这些终结者在攻击人类最后一个基地的时候出现蓝屏或者升级时崩溃吧?
[一个用户在 Reddit](http://www.reddit.com/r/linux/comments/2vyhr6/apparently_terminator_runs_linux_version/) 上贴了一张来自《终结者》电影的截屏(不清楚具体来自哪里),可以看到<ruby> 阿诺德 · 施瓦辛格 <rp> ( </rp> <rt> Arnold Schwarzenegger </rt> <rp> ) </rp></ruby>所饰演的 T-800 半机器人运行的正是 Linux 内核 4.1.15,具体内核型号:**Linux 4.1.15-1.1381\_SKYN12nnmp(slawes.sky.net)。**这可是不是你炕头上的那台老式计算机,而是天网版的!

那么问题来了:如果 Linus Torvalds 还在不断的发布内核更新,天网会升级它的系统吗?会让它的半机器人使用这个采用 GPL 许可证的 OS 吗——这可是要开源出来的。
| 301 | Moved Permanently | null |
6,746 | 如何在命令行中使用 ftp 命令上传和下载文件 | https://www.howtoforge.com/tutorial/how-to-use-ftp-on-the-linux-shell/ | 2015-12-16T15:43:00 | [
"ftp"
] | https://linux.cn/article-6746-1.html | 本文中,介绍在 Linux shell 中如何使用 ftp 命令。包括如何连接 FTP 服务器,上传或下载文件以及创建文件夹。尽管现在有许多不错的 FTP 桌面应用,但是在服务器、SSH、远程会话中命令行 ftp 命令还是有很多应用的。比如。需要服务器从 ftp 仓库拉取备份。

### 步骤 1: 建立 FTP 连接
想要连接 FTP 服务器,在命令上中先输入`ftp`然后空格跟上 FTP 服务器的域名 'domain.com' 或者 IP 地址
#### 例如:
```
ftp domain.com
ftp 192.168.0.1
ftp [email protected]
```
**注意: 本例中使用匿名服务器。**
替换下面例子中 IP 或域名为你的服务器地址。

### 步骤 2: 使用用户名密码登录
绝大多数的 FTP 服务器是使用密码保护的,因此这些 FTP 服务器会询问'**username**'和'**password**'.
如果你连接到被称作匿名 FTP 服务器(LCTT 译注:即,并不需要你有真实的用户信息即可使用的 FTP 服务器称之为匿名 FTP 服务器),可以尝试`anonymous`作为用户名以及使用空密码:
```
Name: anonymous
Password:
```
之后,终端会返回如下的信息:
```
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
```
登录成功。

### 步骤 3: 目录操作
FTP 命令可以列出、移动和创建文件夹,如同我们在本地使用我们的电脑一样。`ls`可以打印目录列表,`cd`可以改变目录,`mkdir`可以创建文件夹。
#### 使用安全设置列出目录
```
ftp> ls
```
服务器将返回:
```
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
directory list
....
....
226 Directory send OK.
```

#### 改变目录:
改变目录可以输入:
```
ftp> cd directory
```
服务器将会返回:
```
250 Directory succesfully changed.
```

### 步骤 4: 使用 FTP 下载文件
在下载一个文件之前,我们首先需要使用`lcd`命令设定本地接受目录位置。
```
lcd /home/user/yourdirectoryname
```
如果你不指定下载目录,文件将会下载到你登录 FTP 时候的工作目录。
现在,我们可以使用命令 get 来下载文件,比如:
```
get file
```
文件会保存在使用lcd命令设置的目录位置。
服务器返回消息:
```
local: file remote: file
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for file (xxx bytes).
226 File send OK.
XXX bytes received in x.xx secs (x.xxx MB/s).
```

下载多个文件可以使用通配符及 `mget` 命令。例如,下面这个例子我打算下载所有以 .xls 结尾的文件。
```
mget *.xls
```
### 步骤 5: 使用 FTP 上传文件
完成 FTP 连接后,FTP 同样可以上传文件
使用 `put`命令上传文件:
```
put file
```
当文件不再当前本地目录下的时候,可以使用绝对路径:
```
put /path/file
```
同样,可以上传多个文件:
```
mput *.xls
```
### 步骤 6: 关闭 FTP 连接
完成FTP工作后,为了安全起见需要关闭连接。有三个命令可以关闭连接:
```
bye
exit
quit
```
任意一个命令可以断开FTP服务器连接并返回:
```
221 Goodbye
```

需要更多帮助,在使用 ftp 命令连接到服务器后,可以使用`help`获得更多帮助。

---
via: <https://www.howtoforge.com/tutorial/how-to-use-ftp-on-the-linux-shell/>
译者:[VicYu](http://vicyu.net) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | # How to use the Linux ftp command to up- and download files on the shell
FTP, or File Transfer Protocol, is a standard network protocol used for transferring files between a client and a server over a network, such as the internet. In the Linux shell, FTP is commonly used for uploading, downloading, and managing files on remote servers. It is useful because it enables users to securely transfer large amounts of data using FTPS (FTP over SSL/TLS), manage file permissions, and organize directories on remote systems directly from the command line. FTP is particularly valuable for server administrators, developers, and website managers who need to transfer files efficiently between local and remote machines. Additionally, its support for interactive sessions and automation through scripts makes it a flexible tool for file management tasks in the Linux environment.
In this tutorial, I will explain how to use the Linux ftp command on the shell. I will show you how to connect to an FTP server, up- and download files and create directories. While there are many nice desktops FTP clients available, the FTP command is still useful when you work remotely on a server over an SSH session and e.g. want to fetch a backup file from your FTP storage.
## Step 1: Establishing an FTP connection
To connect to the FTP server, we have to type in the terminal window 'ftp' and then the domain name 'domain.com' or IP address of the FTP server.
**Examples:**
ftp domain.com
ftp 192.168.0.1
ftp[[email protected]]
Note: for this example we used an anonymous server.
Replace the IP and domain in the above examples with the IP address or domain of your FTP server.
## Step 2: Login with User and Password
Most FTP servers logins are password protected, so the server will ask us for a 'username' and a 'password'.
If you connect to a so-called anonymous FTP server, then try to use "anonymous" as username and an empty password:
Name: anonymous
Password:
The terminal will return a message like this:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
When you are logged in successfully.
## Step 3: Working with Directories
The commands to list, move and create folders on an FTP server are almost the same as we would use the shell locally on our computer, ls stands for list, cd to change directories, mkdir to create directories...
### Listing directories with security settings:
ftp> ls
The server will return:
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
directory list
....
....
226 Directory send OK.
### Changing Directories:
To change the directory we can type:
ftp> cd directory
The server will return:
250 Directory succesfully changed.
## Step 4: Downloading files with FTP
Before downloading a file, we should set the local FTP file download directory by using 'lcd' command:
lcd /home/user/yourdirectoryname
If you dont specify the download directory, the file will be downloaded to the current directory where you were at the time you started the FTP session.
Now, we can use the command 'get' command to download a file, the usage is:
get file
The file will be downloaded to the directory previously set with the 'lcd' command.
The server will return the next message:
local: file remote: file
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for file (xxx bytes).
226 File send OK.
XXX bytes received in x.xx secs (x.xxx MB/s).
To download several files we can use wildcards. In this example, I will download all files with the .xls file extension.
mget *.xls
## Step 5: Uploading Files with FTP
We can upload files that are in the local directory where we made the FTP connection.
To upload a file, we can use 'put' command.
put file
When the file that you want to upload is not in the local directory, you can use the absolute path starting with "/" as well:
put /path/file
To upload several files we can use the mput command similar to the mget example from above:
mput *.xls
## Step 6: Closing the FTP connection
Once we have done the FTP work, we should close the connection for security reasons. There are three commands that we can use to close the connection:
bye
exit
quit
Any of them will disconnect our PC from the FTP server and will return:
221 Goodbye
If you need some additional help, once you are connected to the FTP server, type 'help' and this will show you all the available FTP commands. |
6,751 | 英国政府开源了其大规模监控软件 | http://thenextweb.com/insider/2015/12/15/gchq-open-sources-its-spy-software/ | 2015-12-17T08:30:00 | [
"Gaffer",
"监听"
] | https://linux.cn/article-6751-1.html | 英国的监听机构国家通信情报局(GCHQ) 在 GitHub 上开源了其第一个项目,这是一个用 Java 编写的名为 [Gaffer](https://github.com/GovernmentCommunicationsHeadquarters/Gaffer) 的海量图数据库。政府部门开源这并不值得惊奇,但令人吃惊的却是其开源的是一个用于监听民众的**大规模监控软件**。

这一举动在黑客社区[引发了大量的反思和讨论](https://news.ycombinator.com/item?id=10732609),他们争论它是否该用还是不用。
一些人[称赞](https://news.ycombinator.com/item?id=10732609)了政府部门的这一举动,这使得社区也可以使用这些技术和基于它们进行开发;而另外一些人则[建议](https://news.ycombinator.com/item?id=10732609)拒绝掉这个项目,以维持计算机科学的正直性,因为它来自一个**不道德的部门**。
这个[数据库](https://github.com/GovernmentCommunicationsHeadquarters/Gaffer)系统可以用来分析数据的不同部分之间的内在关系。它可以一次性地上载大量数据,也可以分批输入,特别适合用于识别谁和谁在联系,或者如果你需要的话也可以收集关于某个人的数据。你可以使用它的 API 来获取和筛选你所需的数据内容。
有些人认为该部门的活动费用都是由公众所承担的,因此开源也是理所应当的。如果是在美国的话,政府的这种工作是[没有版权的](https://www.usa.gov/government-works),而在英国,版权则[属于](http://www.nationalarchives.gov.uk/information-management/re-using-public-sector-information/licensing-for-re-use/guidance-for-information-providers/make-information-available-ogl/)官方。
该软件实际上是使用到了 [Apache Accumulo](https://en.wikipedia.org/wiki/Apache_Accumulo) 代码库,而它却是由 GCHQ 在美国的兄弟单位 NSA 开源的。Gaffer 是以 Apache 2.0 许可证释出的。
英国政府一直致力于成为一个<ruby> <a href="http://thenextweb.com/insider/2015/11/20/are-you-ready-to-become-a-digital-citizen/"> 数字民主国家 </a> <rp> ( </rp> <rt> digital democracy </rt> <rp> ) </rp></ruby>,自从其在 2012 年提出 ‘digital by default’ 提案之后,已经有多达 [70 个政府机构](https://government.github.com/community/)使用 GitHub 存放其代码了。
社区人士猜测这是否 GCHQ 寻找最好的技术人员的[另外一种方式](http://thenextweb.com/uk/2015/12/10/gchq-gives-you-homework-in-its-2015-christmas-card/),毕竟 GCHQ 正准备[招募多达 1900 人](http://www.theregister.co.uk/2015/11/16/uk_gch1_1900_staff/)来帮其应对安全方面的隐忧。
那么,你怎么看这件事?
| 301 | Moved Permanently | null |
6,753 | 《Linux 工作站安全检查清单》——来自 Linux 基金会内部 | https://github.com/lfit/itpol/blob/bbc17d8c69cb8eee07ec41f8fbf8ba32fdb4301b/linux-workstation-security.md | 2015-12-17T16:48:00 | [
"安全",
"Linux"
] | https://linux.cn/article-6753-1.html | 
### 目标受众
>
> 这是一套 Linux 基金会为其系统管理员提供的推荐规范。
>
>
>
这个文档用于帮助那些使用 Linux 工作站来访问和管理项目的 IT 设施的系统管理员团队。
如果你的系统管理员是远程员工,你也许可以使用这套指导方针确保系统管理员的系统可以通过核心安全需求,降低你的IT 平台成为攻击目标的风险。
即使你的系统管理员不是远程员工,很多人也会在工作环境中通过便携笔记本完成工作,或者在家中设置系统以便在业余时间或紧急时刻访问工作平台。不论发生何种情况,你都能调整这个推荐规范来适应你的环境。
### 限制
但是,这并不是一个详细的“工作站加固”文档,可以说这是一个努力避免大多数明显安全错误而不会导致太多不便的一组推荐<ruby> 基线 <rp> ( </rp> <rt> baseline </rt> <rp> ) </rp></ruby>。你也许阅读这个文档后会认为它的方法太偏执,而另一些人也许会认为这仅仅是一些肤浅的研究。安全就像在高速公路上开车 -- 任何比你开的慢的都是一个傻瓜,然而任何比你开的快的人都是疯子。这个指南仅仅是一些列核心安全规则,既不详细又不能替代经验、警惕和常识。
我们分享这篇文档是为了[将开源协作的优势带到 IT 策略文献资料中](http://www.linux.com/news/featured-blogs/167-amanda-mcpherson/850607-linux-foundation-sysadmins-open-source-their-it-policies)。如果你发现它有用,我们希望你可以将它用到你自己团体中,并分享你的改进,对它的完善做出你的贡献。
### 结构
每一节都分为两个部分:
* 核对适合你项目的需求
* 形式不定的提示内容,解释了为什么这么做
#### 严重级别
在清单的每一个项目都包括严重级别,我们希望这些能帮助指导你的决定:
* **关键(ESSENTIAL)** 该项应该在考虑列表上被明确的重视。如果不采取措施,将会导致你的平台安全出现高风险。
* **中等(NICE)** 该项将改善你的安全形势,但是会影响到你的工作环境的流程,可能会要求养成新的习惯,改掉旧的习惯。
* **低等(PARANOID)** 留作感觉会明显完善我们平台安全、但是可能会需要大量调整与操作系统交互的方式的项目。
记住,这些只是参考。如果你觉得这些严重级别不能反映你的工程对安全的承诺,你应该调整它们为你所合适的。
选择正确的硬件
-------
我们并不会要求管理员使用一个特殊供应商或者一个特殊的型号,所以这一节提供的是选择工作系统时的核心注意事项。
### 检查清单
* [ ] 系统支持<ruby> 安全启动 <rp> ( </rp> <rt> SecureBoot </rt> <rp> ) </rp></ruby> *(关键)*
* [ ] 系统没有<ruby> 火线 <rp> ( </rp> <rt> Firewire </rt> <rp> ) </rp></ruby>,<ruby> 雷电 <rp> ( </rp> <rt> thunderbolt </rt> <rp> ) </rp></ruby>或者<ruby> 扩展卡 <rp> ( </rp> <rt> ExpressCard </rt> <rp> ) </rp></ruby>接口 *(中等)*
* [ ] 系统有 TPM 芯片 *(中等)*
### 注意事项
#### <ruby> 安全启动 <rp> ( </rp> <rt> SecureBoot </rt> <rp> ) </rp></ruby>
尽管它还有争议,但是安全引导能够预防很多针对工作站的攻击(Rootkits、“Evil Maid”,等等),而没有太多额外的麻烦。它并不能阻止真正专门的攻击者,加上在很大程度上,国家安全机构有办法应对它(可能是通过设计),但是有安全引导总比什么都没有强。
作为选择,你也许可以部署 [Anti Evil Maid](https://github.com/QubesOS/qubes-antievilmaid) 提供更多健全的保护,以对抗安全引导所需要阻止的攻击类型,但是它需要更多部署和维护的工作。
#### 系统没有<ruby> 火线 <rp> ( </rp> <rt> Firewire </rt> <rp> ) </rp></ruby>,<ruby> 雷电 <rp> ( </rp> <rt> thunderbolt </rt> <rp> ) </rp></ruby>或者<ruby> 扩展卡 <rp> ( </rp> <rt> ExpressCard </rt> <rp> ) </rp></ruby>接口
火线是一个标准,其设计上允许任何连接的设备能够完全地直接访问你的系统内存(参见[维基百科](https://en.wikipedia.org/wiki/IEEE_1394#Security_issues))。雷电接口和扩展卡同样有问题,虽然一些后来部署的雷电接口试图限制内存访问的范围。如果你没有这些系统端口,那是最好的,但是它并不严重,它们通常可以通过 UEFI 关闭或内核本身禁用。
#### TPM 芯片
<ruby> 可信平台模块 <rp> ( </rp> <rt> Trusted Platform Module ,TPM </rt> <rp> ) </rp></ruby>是主板上的一个与核心处理器单独分开的加密芯片,它可以用来增加平台的安全性(比如存储全盘加密的密钥),不过通常不会用于日常的平台操作。充其量,这个是一个有则更好的东西,除非你有特殊需求,需要使用 TPM 增加你的工作站安全性。
预引导环境
-----
这是你开始安装操作系统前的一系列推荐规范。
### 检查清单
* [ ] 使用 UEFI 引导模式(不是传统 BIOS)*(关键)*
* [ ] 进入 UEFI 配置需要使用密码 *(关键)*
* [ ] 使用安全引导 *(关键)*
* [ ] 启动系统需要 UEFI 级别密码 *(中等)*
### 注意事项
#### UEFI 和安全引导
UEFI 尽管有缺点,还是提供了很多传统 BIOS 没有的好功能,比如安全引导。大多数现代的系统都默认使用 UEFI 模式。
确保进入 UEFI 配置模式要使用高强度密码。注意,很多厂商默默地限制了你使用密码长度,所以相比长口令你也许应该选择高熵值的短密码(关于密码短语请参考下面内容)。
基于你选择的 Linux 发行版,你也许需要、也许不需要按照 UEFI 的要求,来导入你的发行版的安全引导密钥,从而允许你启动该发行版。很多发行版已经与微软合作,用大多数厂商所支持的密钥给它们已发布的内核签名,因此避免了你必须处理密钥导入的麻烦。
作为一个额外的措施,在允许某人访问引导分区然后尝试做一些不好的事之前,让他们输入密码。为了防止<ruby> 肩窥 <rp> ( </rp> <rt> shoulder-surfing </rt> <rp> ) </rp></ruby>,这个密码应该跟你的 UEFI 管理密码不同。如果你经常关闭和启动,你也许不想这么麻烦,因为你已经必须输入 LUKS 密码了(LUKS 参见下面内容),这样会让你您减少一些额外的键盘输入。
发行版选择注意事项
---------
很有可能你会坚持一个广泛使用的发行版如 Fedora,Ubuntu,Arch,Debian,或它们的一个类似发行版。无论如何,以下是你选择使用发行版应该考虑的。
### 检查清单
* [ ] 拥有一个强健的 MAC/RBAC 系统(SELinux/AppArmor/Grsecurity) *(关键)*
* [ ] 发布安全公告 *(关键)*
* [ ] 提供及时的安全补丁 *(关键)*
* [ ] 提供软件包的加密验证 *(关键)*
* [ ] 完全支持 UEFI 和安全引导 *(关键)*
* [ ] 拥有健壮的原生全磁盘加密支持 *(关键)*
### 注意事项
#### SELinux,AppArmor,和 GrSecurity/PaX
<ruby> 强制访问控制 <rp> ( </rp> <rt> Mandatory Access Controls,MAC </rt> <rp> ) </rp></ruby>或者<ruby> 基于角色的访问控制 <rp> ( </rp> <rt> Role-Based Access Controls,RBAC </rt> <rp> ) </rp></ruby>是一个用在老式 POSIX 系统的基于用户或组的安全机制扩展。现在大多数发行版已经捆绑了 MAC/RBAC 系统(Fedora,Ubuntu),或通过提供一种机制一个可选的安装后步骤来添加它(Gentoo,Arch,Debian)。显然,强烈建议您选择一个预装 MAC/RBAC 系统的发行版,但是如果你对某个没有默认启用它的发行版情有独钟,装完系统后应计划配置安装它。
应该坚决避免使用不带任何 MAC/RBAC 机制的发行版,像传统的 POSIX 基于用户和组的安全在当今时代应该算是考虑不足。如果你想建立一个 MAC/RBAC 工作站,通常认为 AppArmor 和 PaX 比 SELinux 更容易掌握。此外,在工作站上,很少有或者根本没有对外监听的守护进程,而针对用户运行的应用造成的最高风险,GrSecurity/PaX *可能* 会比SELinux 提供更多的安全便利。
#### 发行版安全公告
大多数广泛使用的发行版都有一个给它们的用户发送安全公告的机制,但是如果你对一些机密感兴趣,去看看开发人员是否有见于文档的提醒用户安全漏洞和补丁的机制。缺乏这样的机制是一个重要的警告信号,说明这个发行版不够成熟,不能被用作主要管理员的工作站。
#### 及时和可靠的安全更新
多数常用的发行版提供定期安全更新,但应该经常检查以确保及时提供关键包更新。因此应避免使用<ruby> 附属发行版 <rp> ( </rp> <rt> spin-off </rt> <rp> ) </rp></ruby>和“社区重构”,因为它们必须等待上游发行版先发布,它们经常延迟发布安全更新。
现在,很难找到一个不使用加密签名、更新元数据或二者都不使用的发行版。如此说来,常用的发行版在引入这个基本安全机制就已经知道这些很多年了(Arch,说你呢),所以这也是值得检查的。
#### 发行版支持 UEFI 和安全引导
检查发行版是否支持 UEFI 和安全引导。查明它是否需要导入额外的密钥或是否要求启动内核有一个已经被系统厂商信任的密钥签名(例如跟微软达成合作)。一些发行版不支持 UEFI 或安全启动,但是提供了替代品来确保<ruby> 防篡改 <rp> ( </rp> <rt> tamper-proof </rt> <rp> ) </rp></ruby>或<ruby> 防破坏 <rp> ( </rp> <rt> tamper-evident </rt> <rp> ) </rp></ruby>引导环境([Qubes-OS](https://qubes-os.org/) 使用 Anti Evil Maid,前面提到的)。如果一个发行版不支持安全引导,也没有防止引导级别攻击的机制,还是看看别的吧。
#### 全磁盘加密
全磁盘加密是保护静止数据的要求,大多数发行版都支持。作为一个选择方案,带有自加密硬盘的系统也可以用(通常通过主板 TPM 芯片实现),并提供了类似安全级别而且操作更快,但是花费也更高。
发行版安装指南
-------
所有发行版都是不同的,但是也有一些一般原则:
### 检查清单
* [ ] 使用健壮的密码全磁盘加密(LUKS) *(关键)*
* [ ] 确保交换分区也加密了 *(关键)*
* [ ] 确保引导程序设置了密码(可以和LUKS一样) *(关键)*
* [ ] 设置健壮的 root 密码(可以和LUKS一样) *(关键)*
* [ ] 使用无特权账户登录,作为管理员组的一部分 *(关键)*
* [ ] 设置健壮的用户登录密码,不同于 root 密码 *(关键)*
### 注意事项
#### 全磁盘加密
除非你正在使用自加密硬盘,配置你的安装程序完整地加密所有存储你的数据与系统文件的磁盘很重要。简单地通过自动挂载的 cryptfs <ruby> 环 <rp> ( </rp> <rt> loop </rt> <rp> ) </rp></ruby>文件加密用户目录还不够(说你呢,旧版 Ubuntu),这并没有给系统二进制文件或交换分区提供保护,它可能包含大量的敏感数据。推荐的加密策略是加密 LVM 设备,以便在启动过程中只需要一个密码。
`/boot`分区将一直保持非加密,因为引导程序需要在调用 LUKS/dm-crypt 前能引导内核自身。一些发行版支持加密的`/boot`分区,比如 [Arch](http://www.pavelkogan.com/2014/05/23/luks-full-disk-encryption/),可能别的发行版也支持,但是似乎这样增加了系统更新的复杂度。如果你的发行版并没有原生支持加密`/boot`也不用太在意,内核镜像本身并没有什么隐私数据,它会通过安全引导的加密签名检查来防止被篡改。
#### 选择一个好密码
现代的 Linux 系统没有限制密码口令长度,所以唯一的限制是你的偏执和倔强。如果你要启动你的系统,你将大概至少要输入两个不同的密码:一个解锁 LUKS ,另一个登录,所以长密码将会使你老的更快。最好从丰富或混合的词汇中选择2-3个单词长度,容易输入的密码。
优秀密码例子(是的,你可以使用空格):
* nature abhors roombas
* 12 in-flight Jebediahs
* perdon, tengo flatulence
如果你喜欢输入可以在公开场合和你生活中能见到的句子,比如:
* Mary had a little lamb
* you're a wizard, Harry
* to infinity and beyond
如果你愿意的话,你也应该带上最少要 10-12个字符长度的非词汇的密码。
除非你担心物理安全,你可以写下你的密码,并保存在一个远离你办公桌的安全的地方。
#### Root,用户密码和管理组
我们建议,你的 root 密码和你的 LUKS 加密使用同样的密码(除非你共享你的笔记本给信任的人,让他应该能解锁设备,但是不应该能成为 root 用户)。如果你是笔记本电脑的唯一用户,那么你的 root 密码与你的 LUKS 密码不同是没有安全优势上的意义的。通常,你可以使用同样的密码在你的 UEFI 管理,磁盘加密,和 root 登录中 -- 知道这些任意一个都会让攻击者完全控制您的系统,在单用户工作站上使这些密码不同,没有任何安全益处。
你应该有一个不同的,但同样强健的常规用户帐户密码用来日常工作。这个用户应该是管理组用户(例如`wheel`或者类似,根据发行版不同),允许你执行`sudo`来提升权限。
换句话说,如果在你的工作站只有你一个用户,你应该有两个独特的、<ruby> 强健 <rp> ( </rp> <rt> robust </rt> <rp> ) </rp></ruby>而<ruby> 强壮 <rp> ( </rp> <rt> strong </rt> <rp> ) </rp></ruby>的密码需要记住:
**管理级别**,用在以下方面:
* UEFI 管理
* 引导程序(GRUB)
* 磁盘加密(LUKS)
* 工作站管理(root 用户)
**用户级别**,用在以下:
* 用户登录和 sudo
* 密码管理器的主密码
很明显,如果有一个令人信服的理由的话,它们全都可以不同。
安装后的加固
------
安装后的安全加固在很大程度上取决于你选择的发行版,所以在一个像这样的通用文档中提供详细说明是徒劳的。然而,这里有一些你应该采取的步骤:
### 检查清单
* [ ] 在全局范围内禁用火线和雷电模块 *(关键)*
* [ ] 检查你的防火墙,确保过滤所有传入端口 *(关键)*
* [ ] 确保 root 邮件转发到一个你可以收到的账户 *(关键)*
* [ ] 建立一个系统自动更新任务,或更新提醒 *(中等)*
* [ ] 检查以确保 sshd 服务默认情况下是禁用的 *(中等)*
* [ ] 配置屏幕保护程序在一段时间的不活动后自动锁定 *(中等)*
* [ ] 设置 logwatch *(中等)*
* [ ] 安装使用 rkhunter *(中等)*
* [ ] 安装一个<ruby> 入侵检测系统 <rp> ( </rp> <rt> Intrusion Detection System </rt> <rp> ) </rp></ruby> *(中等)*
### 注意事项
#### 将模块列入黑名单
将火线和雷电模块列入黑名单,增加一行到`/etc/modprobe.d/blacklist-dma.conf`文件:
```
blacklist firewire-core
blacklist thunderbolt
```
重启后的这些模块将被列入黑名单。这样做是无害的,即使你没有这些端口(但也不做任何事)。
#### Root 邮件
默认的 root 邮件只是存储在系统基本上没人读过。确保你设置了你的`/etc/aliases`来转发 root 邮件到你确实能读取的邮箱,否则你也许错过了重要的系统通知和报告:
```
# Person who should get root's mail
root: [email protected]
```
编辑后这些后运行`newaliases`,然后测试它确保能投递到,像一些邮件供应商将拒绝来自不存在的域名或者不可达的域名的邮件。如果是这个原因,你需要配置邮件转发直到确实可用。
#### 防火墙,sshd,和监听进程
默认的防火墙设置将取决于您的发行版,但是大多数都允许`sshd`端口连入。除非你有一个令人信服的合理理由允许连入 ssh,你应该过滤掉它,并禁用 sshd 守护进程。
```
systemctl disable sshd.service
systemctl stop sshd.service
```
如果你需要使用它,你也可以临时启动它。
通常,你的系统不应该有任何侦听端口,除了响应 ping 之外。这将有助于你对抗网络级的零日漏洞利用。
#### 自动更新或通知
建议打开自动更新,除非你有一个非常好的理由不这么做,如果担心自动更新将使您的系统无法使用(以前发生过,所以这种担心并非杞人忧天)。至少,你应该启用自动通知可用的更新。大多数发行版已经有这个服务自动运行,所以你不需要做任何事。查阅你的发行版文档了解更多。
你应该尽快应用所有明显的勘误,即使这些不是特别贴上“安全更新”或有关联的 CVE 编号。所有的问题都有潜在的安全漏洞和新的错误,比起停留在旧的、已知的问题上,未知问题通常是更安全的策略。
#### 监控日志
你应该会对你的系统上发生了什么很感兴趣。出于这个原因,你应该安装`logwatch`然后配置它每夜发送在你的系统上发生的任何事情的活动报告。这不会预防一个专业的攻击者,但是一个不错的安全网络功能。
注意,许多 systemd 发行版将不再自动安装一个“logwatch”所需的 syslog 服务(因为 systemd 会放到它自己的日志中),所以你需要安装和启用“rsyslog”来确保在使用 logwatch 之前你的 /var/log 不是空的。
#### Rkhunter 和 IDS
安装`rkhunter`和一个类似`aide`或者`tripwire`入侵检测系统(IDS)并不是那么有用,除非你确实理解它们如何工作,并采取必要的步骤来设置正确(例如,保证数据库在外部介质,从可信的环境运行检测,记住执行系统更新和配置更改后要刷新散列数据库,等等)。如果你不愿在你的工作站执行这些步骤,并调整你如何工作的方式,这些工具只能带来麻烦而没有任何实在的安全益处。
我们建议你安装`rkhunter`并每晚运行它。它相当易于学习和使用,虽然它不会阻止一个复杂的攻击者,它也能帮助你捕获你自己的错误。
个人工作站备份
-------
工作站备份往往被忽视,或偶尔才做一次,这常常是不安全的方式。
### 检查清单
* [ ] 设置加密备份工作站到外部存储 *(关键)*
* [ ] 使用<ruby> 零认知 <rp> ( </rp> <rt> zero-knowledge </rt> <rp> ) </rp></ruby>备份工具备份到站外或云上 *(中等)*
### 注意事项
#### 全加密的备份存到外部存储
把全部备份放到一个移动磁盘中比较方便,不用担心带宽和上行网速(在这个时代,大多数供应商仍然提供显著的不对称的上传/下载速度)。不用说,这个移动硬盘本身需要加密(再说一次,通过 LUKS),或者你应该使用一个备份工具建立加密备份,例如`duplicity`或者它的 GUI 版本 `deja-dup`。我建议使用后者并使用随机生成的密码,保存到离线的安全地方。如果你带上笔记本去旅行,把这个磁盘留在家,以防你的笔记本丢失或被窃时可以找回备份。
除了你的家目录外,你还应该备份`/etc`目录和出于取证目的的`/var/log`目录。
尤其重要的是,避免拷贝你的家目录到任何非加密存储上,即使是需要快速的在两个系统上移动文件时,一旦完成你肯定会忘了清除它,从而暴露个人隐私或者安全信息到监听者手中 -- 尤其是把这个存储介质跟你的笔记本放到同一个包里。
#### 有选择的零认知站外备份
<ruby> 站外备份 <rp> ( </rp> <rt> Off-site backup </rt> <rp> ) </rp></ruby>也是相当重要的,是否可以做到要么需要你的老板提供空间,要么找一家云服务商。你可以建一个单独的 duplicity/deja-dup 配置,只包括重要的文件,以免传输大量你不想备份的数据(网络缓存、音乐、下载等等)。
作为选择,你可以使用<ruby> 零认知 <rp> ( </rp> <rt> zero-knowledge </rt> <rp> ) </rp></ruby>备份工具,例如 [SpiderOak](https://spideroak.com/),它提供一个卓越的 Linux GUI工具还有更多的实用特性,例如在多个系统或平台间同步内容。
最佳实践
----
下面是我们认为你应该采用的最佳实践列表。它当然不是非常详细的,而是试图提供实用的建议,来做到可行的整体安全性和可用性之间的平衡。
### 浏览
毫无疑问, web 浏览器将是你的系统上最大、最容易暴露的面临攻击的软件。它是专门下载和执行不可信、甚至是恶意代码的一个工具。它试图采用沙箱和<ruby> 代码清洁 <rp> ( </rp> <rt> code sanitization </rt> <rp> ) </rp></ruby>等多种机制保护你免受这种危险,但是在之前它们都被击败了多次。你应该知道,在任何时候浏览网站都是你做的最不安全的活动。
有几种方法可以减少浏览器的影响,但这些真实有效的方法需要你明显改变操作您的工作站的方式。
#### 1: 使用两个不同的浏览器 *(关键)*
这很容易做到,但是只有很少的安全效益。并不是所有浏览器都可以让攻击者完全自由访问您的系统 -- 有时它们只能允许某人读取本地浏览器存储,窃取其它标签的活动会话,捕获浏览器的输入等。使用两个不同的浏览器,一个用在工作/高安全站点,另一个用在其它方面,有助于防止攻击者请求整个 cookie 存储的小问题。主要的不便是两个不同的浏览器会消耗大量内存。
我们建议:
##### 火狐用来访问工作和高安全站点
使用火狐登录工作有关的站点,应该额外关心的是确保数据如 cookies,会话,登录信息,击键等等,明显不应该落入攻击者手中。除了少数的几个网站,你不应该用这个浏览器访问其它网站。
你应该安装下面的火狐扩展:
* [ ] NoScript *(关键)*
+ NoScript 阻止活动内容加载,除非是在用户白名单里的域名。如果用于默认浏览器它会很麻烦(可是提供了真正好的安全效益),所以我们建议只在访问与工作相关的网站的浏览器上开启它。
* [ ] Privacy Badger *(关键)*
+ EFF 的 Privacy Badger 将在页面加载时阻止大多数外部追踪器和广告平台,有助于在这些追踪站点影响你的浏览器时避免跪了(追踪器和广告站点通常会成为攻击者的目标,因为它们能会迅速影响世界各地成千上万的系统)。
* [ ] HTTPS Everywhere *(关键)*
+ 这个 EFF 开发的扩展将确保你访问的大多数站点都使用安全连接,甚至你点击的连接使用的是 <http://(可以有效的避免大多数的攻击,例如> [SSL-strip](http://www.thoughtcrime.org/software/sslstrip/))。
* [ ] Certificate Patrol *(中等)*
+ 如果你正在访问的站点最近改变了它们的 TLS 证书,这个工具将会警告你 -- 特别是如果不是接近失效期或者现在使用不同的证书颁发机构。它有助于警告你是否有人正尝试中间人攻击你的连接,不过它会产生很多误报。
你应该让火狐成为你打开连接时的默认浏览器,因为 NoScript 将在加载或者执行时阻止大多数活动内容。
##### 其它一切都用 Chrome/Chromium
Chromium 开发者在增加很多很好的安全特性方面走在了火狐前面(至少[在 Linux 上](https://code.google.com/p/chromium/wiki/LinuxSandboxing)),例如 seccomp 沙箱,内核用户空间等等,这会成为一个你访问的网站与你其它系统之间的额外隔离层。Chromium 是上游开源项目,Chrome 是 Google 基于它构建的专有二进制包(加一句偏执的提醒,如果你有任何不想让谷歌知道的事情都不要使用它)。
推荐你在 Chrome 上也安装**Privacy Badger** 和 **HTTPS Everywhere** 扩展,然后给它一个与火狐不同的主题,以让它告诉你这是你的“不可信站点”浏览器。
#### 2: 使用两个不同浏览器,一个在专用的虚拟机里 *(中等)*
这有点像上面建议的做法,除了您将添加一个通过快速访问协议运行在专用虚拟机内部 Chrome 的额外步骤,它允许你共享剪贴板和转发声音事件(如,Spice 或 RDP)。这将在不可信浏览器和你其它的工作环境之间添加一个优秀的隔离层,确保攻击者完全危害你的浏览器将必须另外打破 VM 隔离层,才能达到系统的其余部分。
这是一个鲜为人知的可行方式,但是需要大量的 RAM 和高速的处理器来处理多增加的负载。这要求作为管理员的你需要相应地调整自己的工作实践而付出辛苦。
#### 3: 通过虚拟化完全隔离你的工作和娱乐环境 *(低等)*
了解下 [Qubes-OS 项目](https://qubes-os.org/),它致力于通过划分你的应用到完全隔离的 VM 中来提供高度安全的工作环境。
### 密码管理器
#### 检查清单
* [ ] 使用密码管理器 *(关键)*
* [ ] 不相关的站点使用不同的密码 *(关键)*
* [ ] 使用支持团队共享的密码管理器 *(中等)*
* [ ] 给非网站类账户使用一个单独的密码管理器 *(低等)*
#### 注意事项
使用好的、唯一的密码对你的团队成员来说应该是非常关键的需求。<ruby> 凭证 <rp> ( </rp> <rt> credential </rt> <rp> ) </rp></ruby>盗取一直在发生 — 通过被攻破的计算机、盗取数据库备份、远程站点利用、以及任何其它的方式。凭证绝不应该跨站点重用,尤其是关键的应用。
##### 浏览器中的密码管理器
每个浏览器有一个比较安全的保存密码机制,可以同步到供应商维护的,并使用用户的密码保证数据加密。然而,这个机制有严重的劣势:
1. 不能跨浏览器工作
2. 不提供任何与团队成员共享凭证的方法
也有一些支持良好、免费或便宜的密码管理器,可以很好的融合到多个浏览器,跨平台工作,提供小组共享(通常是付费服务)。可以很容易地通过搜索引擎找到解决方案。
##### 独立的密码管理器
任何与浏览器结合的密码管理器都有一个主要的缺点,它实际上是应用的一部分,这样最有可能被入侵者攻击。如果这让你不放心(应该这样),你应该选择两个不同的密码管理器 -- 一个集成在浏览器中用来保存网站密码,一个作为独立运行的应用。后者可用于存储高风险凭证如 root 密码、数据库密码、其它 shell 账户凭证等。
这样的工具在团队成员间共享超级用户的凭据方面特别有用(服务器 root 密码、ILO密码、数据库管理密码、引导程序密码等等)。
这几个工具可以帮助你:
* [KeePassX](https://keepassx.org/),在第2版中改进了团队共享
* [Pass](http://www.passwordstore.org/),它使用了文本文件和 PGP,并与 git 结合
* [Django-Pstore](https://pypi.python.org/pypi/django-pstore),它使用 GPG 在管理员之间共享凭据
* [Hiera-Eyaml](https://github.com/TomPoulton/hiera-eyaml),如果你已经在你的平台中使用了 Puppet,在你的 Hiera 加密数据的一部分里面,可以便捷的追踪你的服务器/服务凭证。
### 加固 SSH 与 PGP 的私钥
个人加密密钥,包括 SSH 和 PGP 私钥,都是你工作站中最重要的物品 -- 这是攻击者最想得到的东西,这可以让他们进一步攻击你的平台或在其它管理员面前冒充你。你应该采取额外的步骤,确保你的私钥免遭盗窃。
#### 检查清单
* [ ] 用来保护私钥的强壮密码 *(关键)*
* [ ] PGP 的主密码保存在移动存储中 *(中等)*
* [ ] 用于身份验证、签名和加密的子密码存储在智能卡设备 *(中等)*
* [ ] SSH 配置为以 PGP 认证密钥作为 ssh 私钥 *(中等)*
#### 注意事项
防止私钥被偷的最好方式是使用一个智能卡存储你的加密私钥,绝不要拷贝到工作站上。有几个厂商提供支持 OpenPGP 的设备:
* [Kernel Concepts](http://shop.kernelconcepts.de/),在这里可以采购支持 OpenPGP 的智能卡和 USB 读取器,你应该需要一个。
* [Yubikey NEO](https://www.yubico.com/products/yubikey-hardware/yubikey-neo/),这里提供 OpenPGP 功能的智能卡还提供很多很酷的特性(U2F、PIV、HOTP等等)。
确保 PGP 主密码没有存储在工作站也很重要,仅使用子密码。主密钥只有在签名其它的密钥和创建新的子密钥时使用 — 不经常发生这种操作。你可以照着 [Debian 的子密钥](https://wiki.debian.org/Subkeys)向导来学习如何将你的主密钥移动到移动存储并创建子密钥。
你应该配置你的 gnupg 代理作为 ssh 代理,然后使用基于智能卡 PGP 认证密钥作为你的 ssh 私钥。我们发布了一个[详尽的指导](https://github.com/lfit/ssh-gpg-smartcard-config)如何使用智能卡读取器或 Yubikey NEO。
如果你不想那么麻烦,最少要确保你的 PGP 私钥和你的 SSH 私钥有个强健的密码,这将让攻击者很难盗取使用它们。
### 休眠或关机,不要挂起
当系统挂起时,内存中的内容仍然保留在内存芯片中,可以会攻击者读取到(这叫做<ruby> 冷启动攻击 <rp> ( </rp> <rt> Cold Boot Attack </rt> <rp> ) </rp></ruby>)。如果你离开你的系统的时间较长,比如每天下班结束,最好关机或者休眠,而不是挂起它或者就那么开着。
### 工作站上的 SELinux
如果你使用捆绑了 SELinux 的发行版(如 Fedora),这有些如何使用它的建议,让你的工作站达到最大限度的安全。
#### 检查清单
* [ ] 确保你的工作站<ruby> 强制 <rp> ( </rp> <rt> enforcing </rt> <rp> ) </rp></ruby>使用 SELinux *(关键)*
* [ ] 不要盲目的执行`audit2allow -M`,应该经常检查 *(关键)*
* [ ] 绝不要 `setenforce 0` *(中等)*
* [ ] 切换你的用户到 SELinux 用户`staff_u` *(中等)*
#### 注意事项
SELinux 是<ruby> 强制访问控制 <rp> ( </rp> <rt> Mandatory Access Controls,MAC </rt> <rp> ) </rp></ruby>,是 POSIX许可核心功能的扩展。它是成熟、强健,自从它推出以来已经有很长的路了。不管怎样,许多系统管理员现在仍旧重复过时的口头禅“关掉它就行”。
话虽如此,在工作站上 SELinux 会带来一些有限的安全效益,因为大多数你想运行的应用都是可以自由运行的。开启它有益于给网络提供足够的保护,也有可能有助于防止攻击者通过脆弱的后台服务提升到 root 级别的权限用户。
我们的建议是开启它并<ruby> 强制使用 <rp> ( </rp> <rt> enforcing </rt> <rp> ) </rp></ruby>。
##### 绝不`setenforce 0`
使用`setenforce 0`临时把 SELinux 设置为<ruby> 许可 <rp> ( </rp> <rt> permissive </rt> <rp> ) </rp></ruby>模式很有诱惑力,但是你应该避免这样做。当你想查找一个特定应用或者程序的问题时,实际上这样做是把整个系统的 SELinux 给关闭了。
你应该使用`semanage permissive -a [somedomain_t]`替换`setenforce 0`,只把这个程序放入许可模式。首先运行`ausearch`查看哪个程序发生问题:
```
ausearch -ts recent -m avc
```
然后看下`scontext=`(源自 SELinux 的上下文)行,像这样:
```
scontext=staff_u:staff_r:gpg_pinentry_t:s0-s0:c0.c1023
^^^^^^^^^^^^^^
```
这告诉你程序`gpg_pinentry_t`被拒绝了,所以你想排查应用的故障,应该增加它到许可域:
```
semange permissive -a gpg_pinentry_t
```
这将允许你使用应用然后收集 AVC 的其它数据,你可以结合`audit2allow`来写一个本地策略。一旦完成你就不会看到新的 AVC 的拒绝消息,你就可以通过运行以下命令从许可中删除程序:
```
semanage permissive -d gpg_pinentry_t
```
##### 用 SELinux 的用户 staff\_r 使用你的工作站
SELinux 带有<ruby> 角色 <rp> ( </rp> <rt> role </rt> <rp> ) </rp></ruby>的原生实现,基于用户帐户相关角色来禁止或授予某些特权。作为一个管理员,你应该使用`staff_r`角色,这可以限制访问很多配置和其它安全敏感文件,除非你先执行`sudo`。
默认情况下,用户以`unconfined_r`创建,你可以自由运行大多数应用,没有任何(或只有一点)SELinux 约束。转换你的用户到`staff_r`角色,运行下面的命令:
```
usermod -Z staff_u [username]
```
你应该退出然后登录新的角色,届时如果你运行`id -Z`,你将会看到:
```
staff_u:staff_r:staff_t:s0-s0:c0.c1023
```
在执行`sudo`时,你应该记住增加一个额外标志告诉 SELinux 转换到“sysadmin”角色。你需要用的命令是:
```
sudo -i -r sysadm_r
```
然后`id -Z`将会显示:
```
staff_u:sysadm_r:sysadm_t:s0-s0:c0.c1023
```
**警告**:在进行这个切换前你应该能很顺畅的使用`ausearch`和`audit2allow`,当你以`staff_r`角色运行时你的应用有可能不再工作了。在写作本文时,已知以下流行的应用在`staff_r`下没有做策略调整就不会工作:
* Chrome/Chromium
* Skype
* VirtualBox
切换回`unconfined_r`,运行下面的命令:
```
usermod -Z unconfined_u [username]
```
然后注销再重新回到舒适区。
延伸阅读
----
IT 安全的世界是一个没有底的兔子洞。如果你想深入,或者找到你的具体发行版更多的安全特性,请查看下面这些链接:
* [Fedora 安全指南](https://docs.fedoraproject.org/en-US/Fedora/19/html/Security_Guide/index.html)
* [CESG Ubuntu 安全指南](https://www.gov.uk/government/publications/end-user-devices-security-guidance-ubuntu-1404-lts)
* [Debian 安全手册](https://www.debian.org/doc/manuals/securing-debian-howto/index.en.html)
* [Arch Linux 安全维基](https://wiki.archlinux.org/index.php/Security)
* [Mac OSX 安全](https://www.apple.com/support/security/guides/)
许可
--
这项工作在[创作共用授权4.0国际许可证](http://creativecommons.org/licenses/by-sa/4.0/)许可下。
---
via: <https://github.com/lfit/itpol/blob/bbc17d8c69cb8eee07ec41f8fbf8ba32fdb4301b/linux-workstation-security.md>
作者:[mricon](https://github.com/mricon) 译者:[wyangsun](https://github.com/wyangsun) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | This is a set of recommendations used by the Linux Foundation for their systems administrators. All of LF employees are remote workers and we use this set of guidelines to ensure that a sysadmin's system passes core security requirements in order to reduce the risk of it becoming an attack vector against the rest of our infrastructure.
Even if your systems administrators are not remote workers, chances are that they perform a lot of their work either from a portable laptop in a work environment, or set up their home systems to access the work infrastructure for after-hours/emergency support. In either case, you can adapt this set of recommendations to suit your environment.
This, by no means, is an exhaustive "workstation hardening" document, but rather an attempt at a set of baseline recommendations to avoid most glaring security errors without introducing too much inconvenience. You may read this document and think it is way too paranoid, while someone else may think this barely scratches the surface. Security is just like driving on the highway -- anyone going slower than you is an idiot, while anyone driving faster than you is a crazy person. These guidelines are merely a basic set of core safety rules that is neither exhaustive, nor a replacement for experience, vigilance, and common sense.
Each section is split into two areas:
- The checklist that can be adapted to your project's needs
- Free-form list of considerations that explain what dictated these decisions
The items in each checklist include the priority level, which we hope will help guide your decision:
*(ESSENTIAL)*items should definitely be high on the consideration list. If not implemented, they will introduce high risks to your workstation security.*(NICE)*to have items will improve the overall security, but will affect how you interact with your work environment, and probably require learning new habits or unlearning old ones.*(PARANOID)*is reserved for items we feel will significantly improve your workstation security, but will require a lot of adjustment to the way you interact with your operating system.
Remember, these are only guidelines. If you feel these priority levels do not reflect your project's commitment to security, you should adjust them as you see fit.
We do not mandate that our admins use a specific vendor or a specific model, so this section addresses core considerations when choosing a work system.
- System supports SecureBoot
*(ESSENTIAL)* - System has no firewire, thunderbolt or ExpressCard ports
*(NICE)* - System has a TPM chip
*(NICE)*
Despite its controversial nature, SecureBoot offers prevention against many attacks targeting workstations (Rootkits, "Evil Maid," etc), without introducing too much extra hassle. It will not stop a truly dedicated attacker, plus there is a pretty high degree of certainty that state security agencies have ways to defeat it (probably by design), but having SecureBoot is better than having nothing at all.
Alternatively, you may set up [Anti Evil Maid](https://github.com/QubesOS/qubes-antievilmaid) which offers a more
wholesome protection against the type of attacks that SecureBoot is supposed
to prevent, but it will require more effort to set up and maintain.
Firewire is a standard that, by design, allows any connecting device full
direct memory access to your system ([see Wikipedia](https://en.wikipedia.org/wiki/IEEE_1394#Security_issues)). Thunderbolt and
ExpressCard are guilty of the same, though some later implementations of
Thunderbolt attempt to limit the scope of memory access. It is best if the
system you are getting has none of these ports, but it is not critical, as
they usually can be turned off via UEFI or disabled in the kernel itself.
Trusted Platform Module (TPM) is a crypto chip bundled with the motherboard separately from the core processor, which can be used for additional platform security (such as to store full-disk encryption keys), but is not normally used for day-to-day workstation operation. At best, this is a nice-to-have, unless you have a specific need to use TPM for your workstation security.
This is a set of recommendations for your workstation before you even start with OS installation.
- UEFI boot mode is used (not legacy BIOS)
*(ESSENTIAL)* - Password is required to enter UEFI configuration
*(ESSENTIAL)* - SecureBoot is enabled
*(ESSENTIAL)* - UEFI-level password is required to boot the system
*(NICE)*
UEFI, with all its warts, offers a lot of goodies that legacy BIOS doesn't, such as SecureBoot. Most modern systems come with UEFI mode on by default.
Make sure a strong password is required to enter UEFI configuration mode. Pay attention, as many manufacturers quietly limit the length of the password you are allowed to use, so you may need to choose high-entropy short passwords vs. long passphrases (see below for more on passphrases).
Depending on the Linux distribution you decide to use, you may or may not have to jump through additional hoops in order to import your distribution's SecureBoot key that would allow you to boot the distro. Many distributions have partnered with Microsoft to sign their released kernels with a key that is already recognized by most system manufacturers, therefore saving you the trouble of having to deal with key importing.
As an extra measure, before someone is allowed to even get to the boot partition and try some badness there, let's make them enter a password. This password should be different from your UEFI management password, in order to prevent shoulder-surfing. If you shut down and start a lot, you may choose to not bother with this, as you will already have to enter a LUKS passphrase and this will save you a few extra keystrokes.
Chances are you'll stick with a fairly widely-used distribution such as Fedora, Ubuntu, Arch, Debian, or one of their close spin-offs. In any case, this is what you should consider when picking a distribution to use.
- Has a robust MAC/RBAC implementation (SELinux/AppArmor/GrSecurity)
*(ESSENTIAL)* - Publishes security bulletins
*(ESSENTIAL)* - Provides timely security patches
*(ESSENTIAL)* - Provides cryptographic verification of packages
*(ESSENTIAL)* - Fully supports UEFI and SecureBoot
*(ESSENTIAL)* - Has robust native full disk encryption support
*(ESSENTIAL)*
Mandatory Access Controls (MAC) or Role-Based Access Controls (RBAC) are an extension of the basic user/group security mechanism used in legacy POSIX systems. Most distributions these days either already come bundled with a MAC/RBAC implementation (Fedora, Ubuntu), or provide a mechanism to add it via an optional post-installation step (Gentoo, Arch, Debian). Obviously, it is highly advised that you pick a distribution that comes pre-configured with a MAC/RBAC system, but if you have strong feelings about a distribution that doesn't have one enabled by default, do plan to configure it post-installation.
Distributions that do not provide any MAC/RBAC mechanisms should be strongly avoided, as traditional POSIX user- and group-based security should be considered insufficient in this day and age. If you would like to start out with a MAC/RBAC workstation, AppArmor and GrSecurity/PaX are generally considered easier to learn than SELinux. Furthermore, on a workstation, where there are few or no externally listening daemons, and where user-run applications pose the highest risk, GrSecurity/PaX will offer more security benefits than just SELinux.
Most of the widely used distributions have a mechanism to deliver security bulletins to their users, but if you are fond of something esoteric, check whether the developers have a documented mechanism of alerting the users about security vulnerabilities and patches. Absence of such mechanism is a major warning sign that the distribution is not mature enough to be considered for a primary admin workstation.
Most of the widely used distributions deliver regular security updates, but is worth checking to ensure that critical package updates are provided in a timely fashion. Avoid using spin-offs and "community rebuilds" for this reason, as they routinely delay security updates due to having to wait for the upstream distribution to release it first.
You'll be hard-pressed to find a distribution that does not use cryptographic signatures on packages, updates metadata, or both. That being said, fairly widely used distributions have been known to go for years before introducing this basic security measure (Arch, I'm looking at you), so this is a thing worth checking.
Check that the distribution supports UEFI and SecureBoot. Find out whether it
requires importing an extra key or whether it signs its boot kernels with a key
already trusted by systems manufacturers (e.g. via an agreement with
Microsoft). Some distributions do not support UEFI/SecureBoot but offer
alternatives to ensure tamper-proof or tamper-evident boot environments
([Qubes-OS](https://qubes-os.org/) uses Anti Evil Maid, mentioned earlier). If a distribution
doesn't support SecureBoot and has no mechanisms to prevent boot-level attacks,
look elsewhere.
Full disk encryption is a requirement for securing data at rest, and is supported by most distributions. As an alternative, systems with self-encrypting hard drives may be used (normally implemented via the on-board TPM chip) and offer comparable levels of security plus faster operation, but at a considerably higher cost.
All distributions are different, but here are general guidelines:
- Use full disk encryption (LUKS) with a robust passphrase
*(ESSENTIAL)* - Make sure swap is also encrypted
*(ESSENTIAL)* - Require a password to edit bootloader (can be same as LUKS)
*(ESSENTIAL)* - Set up a robust root password (can be same as LUKS)
*(ESSENTIAL)* - Use an unprivileged account, part of administrators group
*(ESSENTIAL)* - Set up a robust user-account password, different from root
*(ESSENTIAL)*
Unless you are using self-encrypting hard drives, it is important to configure your installer to fully encrypt all the disks that will be used for storing your data and your system files. It is not sufficient to simply encrypt the user directory via auto-mounting cryptfs loop files (I'm looking at you, older versions of Ubuntu), as this offers no protection for system binaries or swap, which is likely to contain a slew of sensitive data. The recommended encryption strategy is to encrypt the LVM device, so only one passphrase is required during the boot process.
The `/boot`
partition will usually remain unencrypted, as the bootloader needs
to be able to boot the kernel itself before invoking LUKS/dm-crypt. Some
distributions support encrypting the `/boot`
partition as well (e.g.
[Arch](http://www.pavelkogan.com/2014/05/23/luks-full-disk-encryption/)), and it is possible to do the same on other distros, but likely at
the cost of complicating system updates. It is not critical to encrypt
`/boot`
if your distro of choice does not natively support it, as the kernel
image itself leaks no private data and will be protected against tampering
with a cryptographic signature checked by SecureBoot.
Modern Linux systems have no limitation of password/passphrase length, so the only real limitation is your level of paranoia and your stubbornness. If you boot your system a lot, you will probably have to type at least two different passwords: one to unlock LUKS, and another one to log in, so having long passphrases will probably get old really fast. Pick passphrases that are 2-3 words long, easy to type, and preferably from rich/mixed vocabularies.
Examples of good passphrases (yes, you can use spaces):
- nature abhors roombas
- 12 in-flight Jebediahs
- perdon, tengo flatulence
Weak passphrases are combinations of words you're likely to see in published works or anywhere else in real life, such as:
- Mary had a little lamb
- you're a wizard, Harry
- to infinity and beyond
You can also stick with non-vocabulary passwords that are at least 10-12 characters long, if you prefer that to typing passphrases.
Unless you have concerns about physical security, it is fine to write down your passphrases and keep them in a safe place away from your work desk.
We recommend that you use the same passphrase for your root password as you use for your LUKS encryption (unless you share your laptop with other trusted people who should be able to unlock the drives, but shouldn't be able to become root). If you are the sole user of the laptop, then having your root password be different from your LUKS password has no meaningful security advantages. Generally, you can use the same passphrase for your UEFI administration, disk encryption, and root account -- knowing any of these will give an attacker full control of your system anyway, so there is little security benefit to have them be different on a single-user workstation.
You should have a different, but equally strong password for your regular user
account that you will be using for day-to-day tasks. This user should be member
of the admin group (e.g. `wheel`
or similar, depending on the distribution),
allowing you to perform `sudo`
to elevate privileges.
In other words, if you are the sole user on your workstation, you should have 2 distinct, robust, equally strong passphrases you will need to remember:
**Admin-level**, used in the following locations:
- UEFI administration
- Bootloader (GRUB)
- Disk encryption (LUKS)
- Workstation admin (root user)
**User-level**, used for the following:
- User account and sudo
- Master password for the password manager
All of them, obviously, can be different if there is a compelling reason.
Post-installation security hardening will depend greatly on your distribution of choice, so it is futile to provide detailed instructions in a general document such as this one. However, here are some steps you should take:
- Globally disable firewire and thunderbolt modules
*(ESSENTIAL)* - Check your firewalls to ensure all incoming ports are filtered
*(ESSENTIAL)* - Make sure root mail is forwarded to an account you check
*(ESSENTIAL)* - Set up an automatic OS update schedule, or update reminders
*(ESSENTIAL)* - Check to ensure sshd service is disabled by default
*(NICE)* - Configure the screensaver to auto-lock after a period of inactivity
*(NICE)* - Set up logwatch
*(NICE)* - Install and use rkhunter
*(NICE)* - Install an Intrusion Detection System
*(NICE)*
To blacklist a firewire and thunderbolt modules, add the following lines to a
file in `/etc/modprobe.d/blacklist-dma.conf`
:
```
blacklist firewire-core
blacklist thunderbolt
```
The modules will be blacklisted upon reboot. It doesn't hurt doing this even if you don't have these ports (but it doesn't do anything either).
By default, root mail is just saved on the system and tends to never be read.
Make sure you set your `/etc/aliases`
to forward root mail to a mailbox that
you actually read, otherwise you may miss important system notifications and
reports:
```
# Person who should get root's mail
root: [email protected]
```
Run `newaliases`
after this edit and test it out to make sure that it actually
gets delivered, as some email providers will reject email coming in from
nonexistent or non-routable domain names. If that is the case, you will need to
play with your mail forwarding configuration until this actually works.
The default firewall settings will depend on your distribution, but many of
them will allow incoming `sshd`
ports. Unless you have a compelling legitimate
reason to allow incoming ssh, you should filter that out and disable the `sshd`
daemon.
```
systemctl disable sshd.service
systemctl stop sshd.service
```
You can always start it temporarily if you need to use it.
In general, your system shouldn't have any listening ports apart from responding to ping. This will help safeguard you against network-level 0-day exploits.
It is recommended to turn on automatic updates, unless you have a very good reason not to do so, such as fear that an automatic update would render your system unusable (it's happened in the past, so this fear is not unfounded). At the very least, you should enable automatic notifications of available updates. Most distributions already have this service automatically running for you, so chances are you don't have to do anything. Consult your distribution documentation to find out more.
You should apply all outstanding errata as soon as possible, even if something
isn't specifically labeled as "security update" or has an associated CVE code.
All bugs have the potential of being security bugs and erring on the side of
newer, unknown bugs is *generally* a safer strategy than sticking with old,
known ones.
You should have a keen interest in what happens on your system. For this
reason, you should install `logwatch`
and configure it to send nightly activity
reports of everything that happens on your system. This won't prevent a
dedicated attacker, but is a good safety-net feature to have in place.
Note, that many systemd distros will no longer automatically install a syslog
server that `logwatch`
needs (due to systemd relying on its own journal), so
you will need to install and enable `rsyslog`
to make sure your `/var/log`
is
not empty before logwatch will be of any use.
Installing `rkhunter`
and an intrusion detection system (IDS) like `aide`
or
`tripwire`
will not be that useful unless you actually understand how they work
and take the necessary steps to set them up properly (such as, keeping the
databases on external media, running checks from a trusted environment,
remembering to refresh the hash databases after performing system updates and
configuration changes, etc). If you are not willing to take these steps and
adjust how you do things on your own workstation, these tools will introduce
hassle without any tangible security benefit.
We do recommend that you install `rkhunter`
and run it nightly. It's fairly
easy to learn and use, and though it will not deter a sophisticated attacker,
it may help you catch your own mistakes.
Workstation backups tend to be overlooked or done in a haphazard, often unsafe manner.
- Set up encrypted workstation backups to external storage
*(ESSENTIAL)* - Use zero-knowledge backup tools for off-site/cloud backups
*(NICE)*
It is handy to have an external hard drive where one can dump full backups
without having to worry about such things like bandwidth and upstream speeds
(in this day and age most providers still offer dramatically asymmetric
upload/download speeds). Needless to say, this hard drive needs to be in itself
encrypted (again, via LUKS), or you should use a backup tool that creates
encrypted backups, such as `duplicity`
or its GUI companion, `deja-dup`
. I
recommend using the latter with a good randomly generated passphrase, stored
in a safe offline place. If you travel with your laptop, leave this drive at
home to have something to come back to in case your laptop is lost or stolen.
In addition to your home directory, you should also back up `/etc`
and
`/var/log`
for various forensic purposes.
Above all, avoid copying your home directory onto any unencrypted storage, even as a quick way to move your files around between systems, as you will most certainly forget to erase it once you're done, exposing potentially private or otherwise security sensitive data to snooping hands -- especially if you keep that storage media in the same bag with your laptop.
Off-site backups are also extremely important and can be done either to your employer, if they offer space for it, or to a cloud provider. You can set up a separate duplicity/deja-dup profile to only include most important files in order to avoid transferring huge amounts of data that you don't really care to back up off-site (internet cache, music, downloads, etc).
Alternatively, you can use a zero-knowledge backup tool, such as
[SpiderOak](https://spideroak.com/), which offers an excellent Linux GUI tool and has additional
useful features such as synchronizing content between multiple systems and
platforms.
What follows is a curated list of best practices that we think you should adopt. It is most certainly non-exhaustive, but rather attempts to offer practical advice that strikes a workable balance between security and overall usability.
There is no question that the web browser will be the piece of software with the largest and the most exposed attack surface on your system. It is a tool written specifically to download and execute untrusted, frequently hostile code. It attempts to shield you from this danger by employing multiple mechanisms such as sandboxes and code sanitization, but they have all been previously defeated on multiple occasions. You should learn to approach browsing websites as the most insecure activity you'll engage in on any given day.
There are several ways you can reduce the impact of a compromised browser, but the truly effective ways will require significant changes in the way you operate your workstation.
This is the easiest to do, but only offers minor security benefits. Not all browser compromises give an attacker full unfettered access to your system -- sometimes they are limited to allowing one to read local browser storage, steal active sessions from other tabs, capture input entered into the browser, etc. Using two different browsers, one for work/high security sites, and another for everything else will help prevent minor compromises from giving attackers access to the whole cookie jar. The main inconvenience will be the amount of memory consumed by two different browser processes.
Here's what we recommend:
Use Firefox to access work-related sites, where extra care should be taken to ensure that data like cookies, sessions, login information, keystrokes, etc, should most definitely not fall into attackers' hands. You should NOT use this browser for accessing any other sites except select few.
You should install the following Firefox add-ons:
-
NoScript
*(ESSENTIAL)*- NoScript prevents active content from loading, except from user whitelisted domains. It is a great hassle to use with your default browser (though offers really good security benefits), so we recommend only enabling it on the browser you use to access work-related sites.
-
Privacy Badger
*(ESSENTIAL)*- EFF's Privacy Badger will prevent most external trackers and ad platforms from being loaded, which will help avoid compromises on these tracking sites from affecting your browser (trackers and ad sites are very commonly targeted by attackers, as they allow rapid infection of thousands of systems worldwide).
-
HTTPS Everywhere
*(ESSENTIAL)*- This EFF-developed Add-on will ensure that most of your sites are accessed
over a secure connection, even if a link you click is using http:// (great
to avoid a number of attacks, such as
[SSL-strip](http://www.thoughtcrime.org/software/sslstrip/)).
- This EFF-developed Add-on will ensure that most of your sites are accessed
over a secure connection, even if a link you click is using http:// (great
to avoid a number of attacks, such as
-
Certificate Patrol
*(NICE)*- This tool will alert you if the site you're accessing has recently changed their TLS certificates -- especially if it wasn't nearing expiration dates or if it is now using a different certification authority. It helps alert you if someone is trying to man-in-the-middle your connection, but generates a lot of benign false-positives.
You should leave Firefox as your default browser for opening links, as NoScript will prevent most active content from loading or executing.
Chromium developers are ahead of Firefox in adding a lot of nice security
features (at least [on Linux](https://code.google.com/p/chromium/wiki/LinuxSandboxing)), such as seccomp sandboxes, kernel user
namespaces, etc, which act as an added layer of isolation between the sites
you visit and the rest of your system. Chromium is the upstream open-source
project, and Chrome is Google's proprietary binary build based on it (insert
the usual paranoid caution about not using it for anything you don't want
Google to know about).
It is recommended that you install **Privacy Badger** and **HTTPS Everywhere**
extensions in Chrome as well and give it a distinct theme from Firefox to
indicate that this is your "untrusted sites" browser.
This is a similar recommendation to the above, except you will add an extra step of running the "everything else" browser inside a dedicated VM that you access via a fast protocol, allowing you to share clipboards and forward sound events (e.g. Spice or RDP). This will add an excellent layer of isolation between the untrusted browser and the rest of your work environment, ensuring that attackers who manage to fully compromise your browser will then have to additionally break out of the VM isolation layer in order to get to the rest of your system.
This is a surprisingly workable configuration, but requires a lot of RAM and fast processors that can handle the increased load. It will also require an important amount of dedication on the part of the admin who will need to adjust their work practices accordingly.
See [Qubes-OS project](https://qubes-os.org/), which strives to provide a high-security
workstation environment via compartmentalizing your applications into separate
fully isolated VMs.
- Use a password manager
*(ESSENTIAL)* - Use unique passwords on unrelated sites
*(ESSENTIAL)* - Use a password manager that supports team sharing
*(NICE)* - Use a separate password manager for non-website accounts
*(NICE)*
Using good, unique passwords should be a critical requirement for every member of your team. Credential theft is happening all the time -- either via compromised computers, stolen database dumps, remote site exploits, or any number of other means. No credentials should ever be reused across sites, especially for critical applications.
Every browser has a mechanism for saving passwords that is fairly secure and can sync with vendor-maintained cloud storage while keeping the data encrypted with a user-provided passphrase. However, this mechanism has important disadvantages:
- It does not work across browsers
- It does not offer any way of sharing credentials with team members
There are several well-supported, free-or-cheap password managers that are well-integrated into multiple browsers, work across platforms, and offer group sharing (usually as a paid service). Solutions can be easily found via search engines.
One of the major drawbacks of any password manager that comes integrated with the browser is the fact that it's part of the application that is most likely to be attacked by intruders. If this makes you uncomfortable (and it should), you may choose to have two different password managers -- one for websites that is integrated into your browser, and one that runs as a standalone application. The latter can be used to store high-risk credentials such as root passwords, database passwords, other shell account credentials, etc.
It may be particularly useful to have such tool for sharing superuser account credentials with other members of your team (server root passwords, ILO passwords, database admin passwords, bootloader passwords, etc).
A few tools can help you:
[KeePassX](https://keepassx.org/), which improves team sharing in version 2[Pass](http://www.passwordstore.org/), which uses text files and PGP and integrates with git[Django-Pstore](https://pypi.python.org/pypi/django-pstore), which uses GPG to share credentials between admins[Hiera-Eyaml](https://github.com/TomPoulton/hiera-eyaml), which, if you are already using Puppet for your infrastructure, may be a handy way to track your server/service credentials as part of your encrypted Hiera data store
Personal encryption keys, including SSH and PGP private keys, are going to be the most prized items on your workstation -- something the attackers will be most interested in obtaining, as that would allow them to further attack your infrastructure or impersonate you to other admins. You should take extra steps to ensure that your private keys are well protected against theft.
- Strong passphrases are used to protect private keys
*(ESSENTIAL)* - PGP Master key is stored on removable storage
*(NICE)* - Auth, Sign and Encrypt Subkeys are stored on a smartcard device
*(NICE)* - SSH is configured to use PGP Auth key as ssh private key
*(NICE)*
The best way to prevent private key theft is to use a smartcard to store your encryption private keys and never copy them onto the workstation. There are several manufacturers that offer OpenPGP capable devices:
[Kernel Concepts](http://shop.kernelconcepts.de/), where you can purchase both the OpenPGP compatible smartcards and the USB readers, should you need one.[Yubikey NEO](https://www.yubico.com/products/yubikey-hardware/yubikey-neo/), which offers OpenPGP smartcard functionality in addition to many other cool features (U2F, PIV, HOTP, etc).
It is also important to make sure that the master PGP key is not stored on the
main workstation, and only subkeys are used. The master key will only be
needed when signing someone else's keys or creating new subkeys -- operations
which do not happen very frequently. You may follow [the Debian's subkeys](https://wiki.debian.org/Subkeys)
guide to learn how to move your master key to removable storage and how to
create subkeys.
You should then configure your gnupg agent to act as ssh agent and use the
smartcard-based PGP Auth key to act as your ssh private key. We publish a
[detailed guide](https://github.com/lfit/ssh-gpg-smartcard-config) on how to do that using either a smartcard reader or a
Yubikey NEO.
If you are not willing to go that far, at least make sure you have a strong passphrase on both your PGP private key and your SSH private key, which will make it harder for attackers to steal and use them.
When a system is suspended, the RAM contents are kept on the memory chips and
can be read by an attacker (known as the [Cold Boot Attack](https://en.wikipedia.org/wiki/Cold_boot_attack)). If you are
going away from your system for an extended period of time, such as at the end
of the day, it is best to shut it down or hibernate it instead of suspending
it or leaving it on.
If you are using a distribution that comes bundled with SELinux (such as Fedora), here are some recommendation of how to make the best use of it to maximize your workstation security.
- Make sure SELinux is enforcing on your workstation
*(ESSENTIAL)* - Never blindly run
`audit2allow -M`
, always check*(ESSENTIAL)* - Never
`setenforce 0`
*(NICE)* - Switch your account to SELinux user
`staff_u`
*(NICE)*
SELinux is a Mandatory Access Controls (MAC) extension to core POSIX permissions functionality. It is mature, robust, and has come a long way since its initial roll-out. Regardless, many sysadmins to this day repeat the outdated mantra of "just turn it off."
That being said, SELinux will have limited security benefits on the workstation, as most applications you will be running as a user are going to be running unconfined. It does provide enough net benefit to warrant leaving it on, as it will likely help prevent an attacker from escalating privileges to gain root-level access via a vulnerable daemon service.
Our recommendation is to leave it on and enforcing.
It's tempting to use `setenforce 0`
to flip SELinux into permissive mode
on a temporary basis, but you should avoid doing that. This essentially turns
off SELinux for the entire system, while what you really want is to
troubleshoot a particular application or daemon.
Instead of `setenforce 0`
you should be using `semanage permissive -a [somedomain_t]`
to put only that domain into permissive mode. First, find out
which domain is causing troubles by running `ausearch`
:
```
ausearch -ts recent -m avc
```
and then look for `scontext=`
(source SELinux context) line, like so:
```
scontext=staff_u:staff_r:gpg_pinentry_t:s0-s0:c0.c1023
^^^^^^^^^^^^^^
```
This tells you that the domain being denied is `gpg_pinentry_t`
, so if you
want to troubleshoot the application, you should add it to permissive domains:
```
semange permissive -a gpg_pinentry_t
```
This will allow you to use the application and collect the rest of the AVCs,
which you can then use in conjunction with `audit2allow`
to write a local
policy. Once that is done and you see no new AVC denials, you can remove that
domain from permissive by running:
```
semanage permissive -d gpg_pinentry_t
```
SELinux comes with a native implementation of roles that prohibit or grant
certain privileges based on the role associated with the user account. As an
administrator, you should be using the `staff_r`
role, which will restrict
access to many configuration and other security-sensitive files, unless you
first perform `sudo`
.
By default, accounts are created as `unconfined_r`
and most applications you
execute will run unconfined, without any (or with only very few) SELinux
constraints. To switch your account to the `staff_r`
role, run the following
command:
```
usermod -Z staff_u [username]
```
You should log out and log back in to enable the new role, at which point if
you run `id -Z`
, you'll see:
```
staff_u:staff_r:staff_t:s0-s0:c0.c1023
```
When performing `sudo`
, you should remember to add an extra flag to tell
SELinux to transition to the "sysadmin" role. The command you want is:
```
sudo -i -r sysadm_r
```
At which point `id -Z`
will show:
```
staff_u:sysadm_r:sysadm_t:s0-s0:c0.c1023
```
**WARNING**: you should be comfortable using `ausearch`
and `audit2allow`
before you make this switch, as it's possible some of your applications will
no longer work when you're running as role `staff_r`
. At the time of writing,
the following popular applications are known to not work under `staff_r`
without policy tweaks:
- Chrome/Chromium
- Skype
- VirtualBox
To switch back to `unconfined_r`
, run the following command:
```
usermod -Z unconfined_u [username]
```
and then log out and back in to get back into the comfort zone.
The world of IT security is a rabbit hole with no bottom. If you would like to go deeper, or find out more about security features on your particular distribution, please check out the following links:
[Fedora Security Guide](https://docs.fedoraproject.org/en-US/Fedora/19/html/Security_Guide/index.html)[CESG Ubuntu Security Guide](https://www.gov.uk/government/publications/end-user-devices-security-guidance-ubuntu-1404-lts)[Debian Security Manual](https://www.debian.org/doc/manuals/securing-debian-howto/index.en.html)[Arch Linux Security Wiki](https://wiki.archlinux.org/index.php/Security)[Mac OSX Security](https://www.apple.com/support/security/guides/)
This work is licensed under a
[Creative Commons Attribution-ShareAlike 4.0 International License](http://creativecommons.org/licenses/by-sa/4.0/). |
6,763 | Wine 1.8 发布 | https://www.winehq.org/announce/1.8 | 2015-12-20T13:05:22 | [
"Wine"
] | https://linux.cn/article-6763-1.html | 
Wine 团队很高兴的向您宣布,稳定版的 Wine 1.8 现在发布了!
经过了17个月的开发,我们完成了 13000 处修改,最重要的是实现了 DirectWrite 和 Direct2D,以及新的 Pulse Audio 驱动。
这么多的改进可以让它支持许多新应用和游戏,具体请阅读下面的主要更新内容。
### 源代码
* <http://dl.winehq.org/wine/source/1.8/wine-1.8.tar.bz2>
* <http://mirrors.ibiblio.org/wine/source/1.8/wine-1.8.tar.bz2>
* <http://www.winehq.org/git>
### 二进制下载
* <http://www.winehq.org/download>
### 文档
* <http://www.winehq.org/documentation>
Wine 的开发完成要感谢许许多多的人们的付出,参见发布里面的 AUTHORS 文件。
### Wine 1.8 的主要更新内容
#### 文本与字体
* 实现了 DirectWrite,并支持了一些应用。包括:可以从系统或指定字体集中载入字体、构建字体族、字体匹配算法、支持基本的字体布局等
* 字符表基于 Unicode 8.0.0
* 内置 Wingdings 字体
#### 图形
* 支持 Direct2D。包括:绘制文字、支持位图、颜色笔刷和位图笔刷、透明度笔刷
* PNG 文件可以以交错模式编码
* 可以从 PNG 文件中载入 Gamma 信息
* GdiPlus 中正确支持了动画 GIF
#### Direct3D
* 支持 Direct3D 11,和对 Direct3D 10的支持程度差不多
* 支持使用 Direct3D 10的简单应用,但是仍有很多未实现的功能
* 实现了一些新的 DXGI 1.1 接口
* Direct3D 应用可以正确的最小化和恢复显示
* wined3d 显卡数据库现在可以识别更多的显卡。显卡检测代码进行了简化和改进
#### DirectDraw
* SetCooperativeLevel() 工作得更好了,个别情况下影响到了 DirectDraw 排除模式
* DirectDraw 模式控制支持得更好了,主要影响到使用 8-bpp 显示模式的老式应用
#### 音频与视频
* 实现了一个 Pulse Audio 驱动,当 Pulse Audio 运行时会自动选择它
* 在 DirectSound 中支持了 5.1 环绕立体声
* 基于 OpenAL Soft 库实现了 XAudio2
* 实现了 Video Mixing Renderer 版本7
* 实现了 AVI 文件编码和压缩
#### 内核
* Wine 现在可以报告 'Windows8.1' 和 'Windows 10' 版本
* 支持了“仅初始化一次”同步机制
* 实现了条件变量
* 实现了廋读写锁
* Windows 设备支持除了 I/O 控制外的读写操作,它们可以重映射到已有的 Unix 设备上
* 在动态载入库中支持线程本地存储
* 实现了进程任务
* 实现了任务调度服务
* 支持 UTF-7 编码
* 进程和线程亲和支持更多的处理器
* 支持新的线程池 API
#### 用户界面
* 在桌面模式支持可选的启动菜单,可以通过 HKCU\Software\Wine\Explorer\Desktops\<name> 下设置"EnableShell" 为 "Y"来基于每桌面启用
* 标准的文件对话框支持用于文件操作的下拉菜单
* “我的文档”文件夹会链接到 XDG 或 Mac OS X 下的“文档”文件夹
* 支持更多的外壳常用文件夹
* 实现了滚动条主题,其它控件的主题工作的更好了
* 工具条通用控制现在可以保存并恢复其状态
#### Mac OS X 支持
* Mac OS X 上支持64位架构;然后并不完全兼容 Win64,因为 OS X 不是标准的64位 ABI
* 精确的报告 Mac OS X 上的内存大小
* 支持垃圾箱文件夹枚举
#### X11 驱动
* 支持 X 拖放协议版本5
* 实现了闪烁窗口标题
#### OLE / COM
* OLE 存储文件支持文件锁定,大小可以超过4GB
* 在 64 位环境下类型库正确注册
* 64位程序可以载入32位类型库
* 用于控制窗口服务的 RPC 接口现在兼容原生版本
#### 互联网与网络
* 从 Firefox 40 更新了 Gecko 引擎,在 MSHTML 中实现了很多对象和属性
* 互联网代理可以自动配置
* 部分实现了 Web 服务 API
* 在 JavaScript 中支持条件编译
* 可以使用 Samba 的 NetAPI 库配置远程网络共享
* 实现了包捕获 DLL
* 实现了网络接口改变提醒
#### 打印
* 通过 PostScript 驱动打印时支持垂直文字
* 当打印彩色图片时,黑白打印支持更好
#### 其它
* WMI 实现了几个 WBEM 系统类
* 在 MSI 中更好的支持了应用安装补丁
* 支持更多新版本的 C/C++运行时库,包括新的 UCRTBASE 库,旧式的 MSVCIRT C++ 运行时也部分实现了
* 实现了 ATL 版本 9、10、11
* 实现了 XML 文件写入
#### 内置应用
* 任务管理器应用显示哪个进程运行在 WoW64 下
* 注册表编辑器对导入导出支持更好
* wine控制台支持设置对话框的配置插入/覆写模式
#### 平台相关的改变
* ARM 平台上正确汇报系统和硬件信息
* ARM64 平台支持 WoW64模式
* 在 Android 上支持64位架构
#### 构建环境
* 源代码可以跨 DLL 共享,可以从同样的源代码构建多个版本的 DLL。
* 支持 #pragma 指令
* 消息编译器使用 mo 文件,替代了 po 文件
#### 新的外部依赖
* liblcms2 替代了 liblcms 1
* 来自 Samba 的 libnetapi 用于配置远程网络共享
* libpcap 用于实现包捕获 DLL
* libpulse 用于 Pulse Audio 驱动
* OpenAL Soft 库用于实现 XAudio2
#### 已知问题
* 因为 WineD3D 的 OpenGL 内核上下文支持仍然没有完全做好,在旧式上下文中需要支持 Direct3D 10 和 11,所以它们当前不支持 Mesa
| 200 | OK | # Wine Announcement
The Wine team is proud to announce that the stable release Wine 1.8
is now available.
This release represents 17 months of development effort and around
13,000 individual changes. The main highlights are the implementation
of DirectWrite and Direct2D, and the new Pulse Audio driver.
It also contains a lot of improvements across the board, as well as
support for many new applications and games. See the release notes
below for a summary of the major changes.
The source is available from the following locations:
[http://dl.winehq.org/wine/source/1.8/wine-1.8.tar.bz2](http://dl.winehq.org/wine/source/1.8/wine-1.8.tar.bz2)
[http://mirrors.ibiblio.org/wine/source/1.8/wine-1.8.tar.bz2](http://mirrors.ibiblio.org/wine/source/1.8/wine-1.8.tar.bz2)
Binary packages for various distributions will be available from:
[http://www.winehq.org/download](http://www.winehq.org/download)
You will find documentation on [http://www.winehq.org/documentation](http://www.winehq.org/documentation)
You can also get the current source directly from the git
repository. Check [http://www.winehq.org/git](http://www.winehq.org/git) for details.
Wine is available thanks to the work of many people. See the file
[AUTHORS](https://gitlab.winehq.org/wine/wine/-/raw/wine-1.8/AUTHORS) in the distribution for the complete list.
----------------------------------------------------------------
What's new in Wine 1.8
======================
*** Text and fonts
- DirectWrite is implemented, and works for a number of
applications. The implemented functionality includes:
- Font file loading from system or custom font collections.
- Building font families by combining similar font faces.
- Font matching algorithm using weight/width/slope model.
- Basic text layout support.
- Bi-directional level resolution and line breaks resolution.
- GDI interoperability API, including rendering to DIB section base target.
- Rendering to arbitrary target with generic rendering interface.
- Generating black&white and grayscale alpha bitmaps.
- Bold glyphs can be synthesized for outline fonts.
- Multiple replacements can be specified for a single font by using a
multi-string entry under HKCU\Software\Wine\Fonts\Replacements.
- Vertical text uses the Unicode data tables for more accurate
character ranges support.
- Character tables are based on version 8.0.0 of the Unicode Standard.
- The built-in Wingdings font contains more glyphs.
- Unicode bracketing pairs are supported in Uniscribe.
- The RichEdit control uses Uniscribe for more accurate text rendering.
- Hebrew and Arabic Mac OS code pages are supported. This improves
support for loading translated font names from Mac OS font files.
*** Graphics
- Direct2D is supported. Among the implemented features are:
- DXGI surface and WIC bitmap render targets.
- Geometries defined by straight lines and cubic Bézier curves.
- Drawing text.
- Bitmaps.
- Solid color brushes and bitmap brushes.
- Opacity brushes.
- PNG files can be encoded in interlaced mode.
- Gamma information can be loaded from PNG files.
- Animated GIFs are correctly supported in GdiPlus.
*** Direct3D
- Direct3D 11 is supported, to about the same level as Direct3D 10.
- Simple applications using Direct3D 10 are supported. There are still
many unimplemented features. Direct3D 10 requires support for at
least OpenGL 3.2 and GLSL 1.50. Some of the changes and supported
features include:
- Several resource update operations are implemented.
- Many more shader model 4 opcode are recognized.
- Constant buffers are supported.
- The various resource views are implemented.
- The various state objects are implemented.
- Stateblocks are implemented.
- A number of new DXGI 1.1 interfaces are implemented. This benefits Direct3D
10 and 11 applications.
- Direct3D applications correctly minimize and restore the display
mode on focus loss.
- Fixed function vertex blending is implemented. This requires GLSL support.
- Per-vertex point sizes are supported. This requires GLSL support.
- The wined3d graphics card database recognizes more graphics
cards. The graphics card detection code is simplified and
improved. More reasonable fallbacks are picked for unrecognized
graphics cards.
- On drivers that support it, GL_ARB_texture_mirror_clamp_to_edge or
GL_EXT_texture_mirror_clamp are used to implement the "mirror once"
texture addressing mode. Previously this required
GL_ATI_texture_mirror_once.
- GL_ARB_depth_clamp is no longer required to correctly draw pre-transformed
vertices with disabled z-buffering. This helps older graphics cards that
can't correctly implement GL_ARB_depth_clamp.
- On drivers that support it, GL_ARB_blend_func_extended is used to
implement the D3DBLEND_SRCALPHASAT blend factor.
- On drivers that support it, GL_ARB_sampler_objects is used to apply
sampler states independently of the texture object they apply
to. This helps applications that bind the same texture to multiple
texture stages, but with different sampler states.
- On drivers that support it, GL_EXT_texture_snorm is used to support
signed (normalized) texture formats. These are typically used for
bump mapping. Previously these formats required either
GL_NV_texture_shader, or fixups when loading and using them.
- On drivers that support is, GL_ARB_timer_query is used to support
Direct3D 9 timestamp queries.
- Texture format restrictions are more strictly enforced. This allows
applications to fall back to a different format instead of continuing with
broken rendering.
- Direct3D 9 D3DTSS_CONSTANT texture stage constants are supported.
- Color keyed blits can be done by the graphics card. Previously these
needed to be done by the CPU.
- NV12 surfaces are supported. This is used by some applications for
playing back video.
- ATI1N textures and surfaces are supported, in addition to ATI2N
textures and surfaces. This requires support for
GL_ARB_texture_compression_rgtc from the OpenGL driver.
- When GLSL is supported, lighting for Direct3D 1-3 is more
correct. However, for most application the difference will only be
very slight.
- The IDirect3DSwapChain9Ex interface is supported.
- OpenGL core contexts, OpenGL ES contexts, and multi-threaded OpenGL
command submission (known as "CSMT") have been added, however that
work is not finished yet.
*** DirectDraw
- SetCooperativeLevel() works better, affecting DirectDraw exclusive
mode in particular.
- DirectDraw surface flipping is more correct. This affects applications that
use more than 1 back buffer in particular.
- DirectDraw palette handling is better supported. This mostly affects
older applications using 8-bpp display modes (but not exclusively.)
- "Client memory" surfaces are better supported, in particular related
to the handling of pitch and texture compression.
*** Audio and video
- A Pulse Audio driver is implemented. It is selected automatically
when Pulse Audio is running.
- 5.1 surround sound is supported in DirectSound. Stereo is the
default, but other speaker configurations can be set through the
Audio tab in Winecfg.
- XAudio2 is implemented, based on the OpenAL Soft library.
- The OpenAL library defaults to the native version.
- The Video Mixing Renderer version 7 is implemented.
- AVI file encoding and compression is implemented.
*** Kernel
- Wine can be configured to report the Windows version as 'Windows
8.1' and 'Windows 10'.
- Keyed event synchronization objects are implemented.
- The "init once" synchronization mechanism is supported.
- Condition variables are implemented.
- Slim Reader/Writer locks are implemented.
- Activation contexts are used for loading DLLs, type libraries, and
COM classes, avoiding the need for explicit registration.
- Windows devices support read and write operations in addition to I/O
controls. They can be remapped directly to existing Unix devices.
- Thread local storage is supported in dynamically loaded libraries.
- Process jobs are implemented.
- The Task Scheduler service is implemented.
- The UTF-7 encoding is supported.
- ATL thunk emulation supports a wider range of possible instructions.
- Process and thread affinity is supported even with a large number of
processors.
- Dynamic DST (Daylight Saving Time) is supported through the
registry. Timezone data is updated for a number of timezones.
- USER_SHARED_DATA access is emulated on x86-64 platforms.
- The new thread pool API is supported.
- OpenMP (parallel programming API) is implemented.
- Preliminary support for HID devices is implemented, but it's not
enabled yet.
*** User interface
- There is an optional Start Menu in desktop mode, that can be enabled
on a per-desktop basis by setting "EnableShell" to "Y" under
HKCU\Software\Wine\Explorer\Desktops\<name>.
- The standard Open File dialog supports a drop-down menu for file
manipulations.
- The 'My Documents' folder links to the XDG or Mac OS X 'Documents'
folder if it exists.
- Many more shell Known Folders are supported.
- Scrollbar theming is implemented. Theming of other controls also
works better.
- The Toolbar common control can save and restore its state.
*** Mac OS X support
- The 64-bit architecture is supported on Mac OS X; however, it's not
100% compatible with Win64, because of the OS X non-standard 64-bit
ABI.
- Memory size is reported accurately on Mac OS X.
- Joysticks are supported at the WinMM level on Mac OS X.
- Debugging information and stack unwinding are improved on Mac OS X.
- Trash folder enumeration is supported on Mac OS X.
- All mouse events are supported in the system tray with the Mac driver.
- Window maximization is supported in the Mac driver.
- The Cocoa-style full-screen mode is supported in the Mac driver.
- Multiple keyboard layouts are supported in the Mac driver.
*** X11 driver
- X Drag & Drop protocol version 5 is supported.
- Flashing a window caption is implemented in the X11 driver using the
NET_WM_STATE_DEMANDS_ATTENTION style.
*** OLE / COM
- OLE Storage files support file locking, and sizes larger than 4 GB.
- Type libraries are registered correctly on 64-bit setups.
- 32-bit type libraries can be loaded from 64-bit programs.
- The OLE data cache supports DIB images.
- The RPC interface to control Windows services is compatible with the
native version.
- OLE Accessible Objects are implemented for better accessibility support.
*** Internet and networking
- The Gecko engine is updated to the version from Firefox 40. Many
more objects and properties are implemented in MSHTML.
- Internet proxies can be configured automatically.
- RPC over HTTP supports the NTLM and Negotiate authentication
schemes.
- The Web Services API is partially implemented.
- Download of Gecko and Mono add-ons can be canceled from the
progress dialog.
- Conditional compilation is supported in JavaScript.
- Arrays, math functions, and exception unwinding are implemented in
VBScript.
- Remote network shares can be configured using Samba's NetAPI library.
- The Packet Capture DLL is implemented.
- Network interface change notifications are implemented.
- IPv6 DNS addresses are supported in IphlpAPI.
- The Deflate content encoding is supported in Wininet.
- The TransmitFile API is implemented in Windows Sockets.
- The BITS file transfer service is better supported.
*** Printing
- Vertical text is supported when printing through the PostScript driver.
- The PostScript driver generates standard glyph names when possible.
- Monochrome printers are better supported, in particular when
printing color images.
- Collation is supported in the PostScript driver.
*** Miscellaneous
- Windows Management Instrumentation (WMI) implements several more
WBEM system classes.
- Applying installation patches is better supported in MSI.
- Hyperlink controls are supported in installers.
- More recent versions of the C/C++ runtimes are supported, including
the new UCRTBASE library. The old MSVCIRT C++ runtime is also
partially implemented.
- Version 9, 10, and 11 of ATL (Active Template Library) are
implemented.
- The Windows Scripting Runtime supports many more classes, including
file and folder collections and dictionaries.
- Writing XML files is implemented.
- The Invariant locale is supported.
*** Built-in applications
- The 'taskmgr' application displays whether processes are running
under WoW64.
- The 'regedit' tool better supports import/export of registry files.
- The 'wineconsole' tool supports configuring the insert/overwrite
mode in the settings dialog.
*** Platform-specific changes
- System and hardware information is properly reported on ARM
platforms.
- WoW64 mode is supported for the ARM64 platform.
- The 64-bit architecture is supported on Android.
- Binaries are built as PIE on Android, for compatibility with Android
version 5.
*** Build environment
- Source files can be shared across DLLs, to allow building multiple
versions of a DLL from the same source. This is more compatible than
forwarding calls to a single master DLL. It's used mainly for the
C/C++ runtime libraries.
- #pragma directives are supported in various source files to specify
dependencies, for more accurate makefile generation.
- The IDL compiler supports WinRT namespaces.
- The message compiler uses mo files instead of po files for faster
processing.
- Architecture-specific compile flags like -march= are supported in
Winegcc and passed along to the assembler.
*** New external dependencies
- liblcms2 is used instead of liblcms version 1.
- libnetapi from Samba is used for configuring remote network shares.
- libpcap is used to implement the Packet Capture DLL.
- libpulse is used by the Pulse Audio driver.
- The OpenAL Soft library is used to implement XAudio2.
- The prelink tool is no longer necessary as long as the linker
supports the -Ttext-segment option.
*** Known issues
- Since the support for OpenGL core contexts in WineD3D is not
complete enough yet, Direct3D 10 and 11 need to be supported in a
legacy context / the compatibility profile, which means that they
currently don't work on Mesa.
- Setting the PULSE_LATENCY_MSEC variable was sometimes necessary with
the Alsa audio driver, but it can cause trouble with the Pulse
driver. It is recommended to unset the variable.
--
Alexandre Julliard
[[email protected]](/cdn-cgi/l/email-protection) |
6,767 | 在 Centos/RHEL 6.X 上安装 Wetty | http://www.unixmen.com/install-wetty-centosrhel-6-x/ | 2015-12-21T10:41:00 | [
"Wetty"
] | https://linux.cn/article-6767-1.html | **Wetty 是什么?**
Wetty = Web + tty
作为系统管理员,如果你是在 Linux 桌面下,你可以用它像一个 GNOME 终端(或类似的)一样来连接远程服务器;如果你是在 Windows 下,你可以用它像使用 Putty 这样的 SSH 客户端一样来连接远程,然后同时可以在浏览器中上网并查收邮件等其它事情。
(LCTT 译注:简而言之,这是一个基于 Web 浏览器的远程终端)

### 第1步: 安装 epel 源
```
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
```
### 第2步:安装依赖
```
# yum install epel-release git nodejs npm -y
```
(LCTT 译注:对,没错,是用 node.js 编写的)
### 第3步:在安装完依赖后,克隆 GitHub 仓库
```
# git clone https://github.com/krishnasrinivas/wetty
```
### 第4步:运行 Wetty
```
# cd wetty
# npm install
```
### 第5步:从 Web 浏览器启动 Wetty 并访问 Linux 终端
```
# node app.js -p 8080
```
### 第6步:为 Wetty 安装 HTTPS 证书
```
# openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes
```
等待完成。
### 第7步:通过 HTTPS 来使用 Wetty
```
# nohup node app.js --sslkey key.pem --sslcert cert.pem -p 8080 &
```
### 第8步:为 wetty 添加一个用户
```
# useradd <username>
# Passwd <username>
```
### 第9步:访问 wetty
```
http://Your_IP-Address:8080
```
输入你之前为 wetty 创建的证书然后访问。
到此结束!
---
via: <http://www.unixmen.com/install-wetty-centosrhel-6-x/>
作者:[Debojyoti Das](http://www.unixmen.com/author/debjyoti/) 译者:[strugglingyouth](https://github.com/strugglingyouth) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,770 | 在 Ubuntu 上安装世界上最先进的开源数据库 PostgreSQL 9.4 和 phpPgAdmin | http://www.unixmen.com/install-postgresql-9-4-and-phppgadmin-on-ubuntu-15-10/ | 2015-12-21T11:54:00 | [
"数据库",
"PostgreSQL"
] | https://linux.cn/article-6770-1.html | 
### 简介
[PostgreSQL](http://www.postgresql.org/) 是一款强大的,开源的,对象关系型数据库系统。它支持所有的主流操作系统,包括 Linux、Unix(AIX、BSD、HP-UX,SGI IRIX、Mac OS、Solaris、Tru64) 以及 Windows 操作系统。
下面是 **Ubuntu** 发起者 **Mark Shuttleworth** 对 PostgreSQL 的一段评价。
>
> PostgreSQL 是一款极赞的数据库系统。刚开始我们在 Launchpad 上使用它的时候,并不确定它能否胜任工作。但我是错了。它很强壮、快速,在各个方面都很专业。
>
>
> — Mark Shuttleworth.
>
>
>
在这篇简短的指南中,让我们来看看如何在 Ubuntu 15.10 服务器中安装 PostgreSQL 9.4。
### 安装 PostgreSQL
默认仓库中就有可用的 PostgreSQL。在终端中输入下面的命令安装它。
```
sudo apt-get install postgresql postgresql-contrib
```
如果你需要其它的版本,按照下面那样先添加 PostgreSQL 仓库然后再安装。
**PostgreSQL apt 仓库** 支持 amd64 和 i386 架构的 Ubuntu 长期支持版(10.04、12.04 和 14.04),以及非长期支持版(14.10)。对于其它非长期支持版,该软件包虽然没有完全支持,但使用和 LTS 版本近似的也能正常工作。
#### Ubuntu 14.10 系统:
新建文件**/etc/apt/sources.list.d/pgdg.list**;
```
sudo vi /etc/apt/sources.list.d/pgdg.list
```
用下面一行添加仓库:
```
deb http://apt.postgresql.org/pub/repos/apt/ utopic-pgdg main
```
**注意**: 上面的库只能用于 Ubuntu 14.10。还没有升级到 Ubuntu 15.04 和 15.10。
对于 **Ubuntu 14.04**,添加下面一行:
```
deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main
```
对于 **Ubuntu 12.04**,添加下面一行:
```
deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main
```
导入库签名密钥:
```
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
```
更新软件包列表:
```
sudo apt-get update
```
然后安装需要的版本。
```
sudo apt-get install postgresql-9.4
```
### 访问 PostgreSQL 命令窗口
默认的数据库名称和数据库用户名称都是 “**postgres**”。切换到 postgres 用户进行 postgresql 相关的操作:
```
sudo -u postgres psql postgres
```
#### 示例输出:
```
psql (9.4.5)
Type "help" for help.
postgres=#
```
要退出 postgresql 窗口,在 **psql** 窗口输入 **\q** 退出到终端。
### 设置 “postgres” 用户密码
登录到 postgresql 窗口,
```
sudo -u postgres psql postgres
```
用下面的命令为用户 postgres 设置密码:
```
postgres=# \password postgres
Enter new password:
Enter it again:
postgres=# \q
```
要安装 PostgreSQL Adminpack 扩展,在 postgresql 窗口输入下面的命令:
```
sudo -u postgres psql postgres
```
---
```
postgres=# CREATE EXTENSION adminpack;
CREATE EXTENSION
```
在 **psql** 窗口输入 **\q** 从 postgresql 窗口退回到终端。
### 创建新用户和数据库
例如,让我们创建一个新的用户,名为 “**senthil**”,密码是 “**ubuntu**”,以及名为 “**mydb**” 的数据库。
```
sudo -u postgres createuser -D -A -P senthil
```
---
```
sudo -u postgres createdb -O senthil mydb
```
### 删除用户和数据库
要删除数据库,首先切换到 postgres 用户:
```
sudo -u postgres psql postgres
```
输入命令:
```
$ drop database <database-name>
```
要删除一个用户,输入下面的命令:
```
$ drop user <user-name>
```
### 配置 PostgreSQL-MD5 验证
**MD5 验证** 要求用户提供一个 MD5 加密的密码用于认证。首先编辑 **/etc/postgresql/9.4/main/pg\_hba.conf** 文件:
```
sudo vi /etc/postgresql/9.4/main/pg_hba.conf
```
按照下面所示添加或修改行
```
[...]
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
host all all 192.168.1.0/24 md5
# IPv6 local connections:
host all all ::1/128 md5
[...]
```
其中, 192.168.1.0/24 是我的本地网络 IP 地址。用你自己的地址替换。
重启 postgresql 服务以使更改生效:
```
sudo systemctl restart postgresql
```
或者,
```
sudo service postgresql restart
```
### 配置 PostgreSQL TCP/IP 配置
默认情况下,没有启用 TCP/IP 连接,因此其它计算机的用户不能访问 postgresql。为了允许其它计算机的用户访问,编辑文件 **/etc/postgresql/9.4/main/postgresql.conf:**
```
sudo vi /etc/postgresql/9.4/main/postgresql.conf
```
找到下面一行:
```
[...]
#listen_addresses = 'localhost'
[...]
#port = 5432
[...]
```
取消该行的注释,然后设置你 postgresql 服务器的 IP 地址,或者设置为 ‘\*’ 监听所有用户。你应该谨慎设置所有远程用户都可以访问 PostgreSQL。
```
[...]
listen_addresses = '*'
[...]
port = 5432
[...]
```
重启 postgresql 服务保存更改:
```
sudo systemctl restart postgresql
```
或者,
```
sudo service postgresql restart
```
### 用 phpPgAdmin 管理 PostgreSQL
[**phpPgAdmin**](http://phppgadmin.sourceforge.net/doku.php) 是基于 web 用 PHP 写的 PostgreSQL 管理工具。
默认仓库中有可用的 phpPgAdmin。用下面的命令安装 phpPgAdmin:
```
sudo apt-get install phppgadmin
```
默认情况下,你可以在本地系统的 web 浏览器用 **http://localhost/phppgadmin** 访问 phppgadmin。
要访问远程系统,在 Ubuntu 15.10 上做如下操作:
编辑文件 **/etc/apache2/conf-available/phppgadmin.conf**,
```
sudo vi /etc/apache2/conf-available/phppgadmin.conf
```
找到 **Require local** 的一行在这行前面添加 **#** 注释掉它。
```
#Require local
```
添加下面的一行:
```
allow from all
```
保存并退出文件。
然后重启 apache 服务。
```
sudo systemctl restart apache2
```
对于 Ubuntu 14.10 及之前版本:
编辑 **/etc/apache2/conf.d/phppgadmin**:
```
sudo nano /etc/apache2/conf.d/phppgadmin
```
注释掉下面一行:
```
[...]
#allow from 127.0.0.0/255.0.0.0 ::1/128
```
取消下面一行的注释使所有系统都可以访问 phppgadmin。
```
allow from all
```
编辑 **/etc/apache2/apache2.conf**:
```
sudo vi /etc/apache2/apache2.conf
```
添加下面一行:
```
Include /etc/apache2/conf.d/phppgadmin
```
然后重启 apache 服务。
```
sudo service apache2 restart
```
### 配置 phpPgAdmin
编辑文件 **/etc/phppgadmin/config.inc.php**, 做以下更改。下面大部分选项都带有解释。认真阅读以便了解为什么要更改这些值。
```
sudo nano /etc/phppgadmin/config.inc.php
```
找到下面一行:
```
$conf['servers'][0]['host'] = '';
```
按照下面这样更改:
```
$conf['servers'][0]['host'] = 'localhost';
```
找到这一行:
```
$conf['extra_login_security'] = true;
```
更改值为 **false**。
```
$conf['extra_login_security'] = false;
```
找到这一行:
```
$conf['owned_only'] = false;
```
更改值为 **true**。
```
$conf['owned_only'] = true;
```
保存并关闭文件。重启 postgresql 服务和 Apache 服务。
```
sudo systemctl restart postgresql
sudo systemctl restart apache2
```
或者,
```
sudo service postgresql restart
sudo service apache2 restart
```
现在打开你的浏览器并导航到 **http://ip-address/phppgadmin**。你会看到以下截图。

用你之前创建的用户登录。我之前已经创建了一个名为 “**senthil**” 的用户,密码是 “**ubuntu**”,因此我以 “senthil” 用户登录。

然后你就可以访问 phppgadmin 面板了。

用 postgres 用户登录:

就是这样。现在你可以用 phppgadmin 可视化创建、删除或者更改数据库了。
加油!
---
via: <http://www.unixmen.com/install-postgresql-9-4-and-phppgadmin-on-ubuntu-15-10/>
作者:[SK](http://www.twitter.com/ostechnix) 译者:[ictlyh](http://mutouxiaogui.cn/blog/) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,771 | 深入浅出讲述提升 WordPress 性能的九大秘笈 | https://www.nginx.com/blog/9-tips-for-improving-wordpress-performance-with-nginx/ | 2015-12-21T18:57:00 | [
"nginx",
"lemp",
"wordpress"
] | https://linux.cn/article-6771-1.html | 在建站和 web 应用程序交付方面,WordPress 是全球最大的一个平台。全球大约[四分之一](http://w3techs.com/technologies/overview/content_management/all) 的站点现在正在使用开源 WordPress 软件,包括 eBay、 Mozilla、 RackSpace、 TechCrunch、 CNN、 MTV、纽约时报、华尔街日报 等等。
最流行的个人博客平台 WordPress.com,其也运行在 WordPress 开源软件上。[而 NGINX 则为 WordPress.com 提供了动力](https://www.nginx.com/press/choosing-nginx-growth-wordpresscom/)。在 WordPress.com 的用户当中,许多站点起步于 WordPress.com,然后换成了自己运行 WordPress 开源软件;它们中越来越多的站点也使用了 NGINX 软件。
WordPress 的吸引力源于其简单性,无论是对于最终用户还是安装架设。然而,当使用量不断增长时,WordPress 站点的体系结构也存在一定的问题 - 这里有几个方法,包括使用缓存,以及将 WordPress 和 NGINX 组合起来,可以解决这些问题。
在这篇博客中,我们提供了九个提速技巧来帮助你解决 WordPress 中一些常见的性能问题:
* 缓存静态资源
* 缓存动态文件
* 迁移到 NGINX
* 添加 NGINX 静态链接支持
* 为 NGINX 配置 FastCGI
* 为 NGINX 配置 W3*Total*Cache
* 为 NGINX 配置 WP-Super-Cache
* 为 NGINX 配置安全防范措施
* 配置 NGINX 支持 WordPress 多站点

### 在 LAMP 架构下 WordPress 的性能
大多数 WordPress 站点都运行在传统的 LAMP 架构下:Linux 操作系统,Apache Web 服务器软件,MySQL 数据库软件(通常是一个单独的数据库服务器)和 PHP 编程语言。这些都是非常著名的,广泛应用的开源工具。在 WordPress 世界里,很多人都用的是 LAMP,所以很容易寻求帮助和支持。
当用户访问 WordPress 站点时,浏览器为每个用户创建六到八个连接来连接到 Linux/Apache 上。当用户请求连接时,PHP 即时生成每个页面,从 MySQL 数据库获取资源来响应请求。
LAMP 或许对于数百个并发用户依然能照常工作。然而,流量突然增加是常见的,并且通常这应该算是一件好事。
但是,当 LAMP 站点变得繁忙时,当同时在线的用户达到数千个时,它的瓶颈就会被暴露出来。瓶颈存在主要是两个原因:
1. Apache Web 服务器 - Apache 的每个/每次连接需要消耗大量资源。如果 Apache 接受了太多的并发连接,内存可能会耗尽,从而导致性能急剧降低,因为数据必须交换到磁盘了。如果以限制连接数来提高响应时间,新的连接必须等待,这也导致了用户体验变得很差。
2. PHP/MySQL 的交互 - 一个运行 PHP 和 MySQL 数据库服务器的应用服务器上每秒的请求量有一个最大限制。当请求的数量超过这个最大限制时,用户必须等待。超过这个最大限制时也会增加所有用户的响应时间。超过其两倍以上时会出现明显的性能问题。
LAMP 架构的网站出现性能瓶颈是常见的情况,这时就需要升级硬件了 - 增加 CPU,扩大磁盘空间等等。当 Apache 和 PHP/MySQL 的架构超载后,在硬件上不断的提升却跟不上系统资源指数增长的需求。
首选替代 LAMP 架构的是 LEMP 架构 – Linux, NGINX, MySQL, 和 PHP。 (这是 LEMP 的缩写,E 代表着 “engine-x.” 的发音。) 我们在 技巧 3 中会描述 LEMP 架构。
### 技巧 1. 缓存静态资源
静态资源是指不变的文件,像 CSS,JavaScript 和图片。这些文件往往在网页的数据中占半数以上。页面的其余部分是动态生成的,像在论坛中评论,性能仪表盘,或个性化的内容(可以看看 Amazon.com 产品)。
缓存静态资源有两大好处:
* 更快的交付给用户 - 用户可以从它们浏览器的缓存或者从互联网上离它们最近的缓存服务器获取静态文件。有时候文件较大,因此减少等待时间对它们来说帮助很大。
* 减少应用服务器的负载 - 从缓存中检索到的每个文件会让 web 服务器少处理一个请求。你的缓存越多,用户等待的时间越短。
要让浏览器缓存文件,需要在静态文件中设置正确的 HTTP 首部。看看 HTTP Cache-Control 首部,特别是设置了 max-age 参数,Expires 首部,以及 Entity 标记。[这里](http://www.mobify.com/blog/beginners-guide-to-http-cache-headers/) 有详细的介绍。
当启用本地缓存,然后用户请求以前访问过的文件时,浏览器首先检查该文件是否在缓存中。如果在,它会询问 Web 服务器该文件是否改变过。如果该文件没有改变,Web 服务器将立即响应一个304状态码(未改变),这意味着该文件没有改变,而不是返回状态码200 OK 并检索和发送已改变的文件。
要在浏览器之外支持缓存,可以考虑下面讲到的技巧,以及考虑使用内容分发网络(CDN)。CDN 是一种流行且强大的缓存工具,但我们在这里不详细描述它。在你实现了这里讲到的其它技术之后可以考虑 CDN。此外,当你的站点从 HTTP/1.x 过渡到 HTTP/2 协议时,CDN 的用处可能不太大;根据需要调查和测试,找到你网站需要的正确方法。
如果你转向 NGINX Plus 或将开源的 NGINX 软件作为架构的一部分,建议你考虑 技巧 3,然后配置 NGINX 缓存静态资源。使用下面的配置,用你 Web 服务器的 URL 替换 www.example.com。
```
server {
### 将 www.example.com 替换为你的 URL
server_name www.example.com;
root /var/www/example.com/htdocs;
index index.php;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
### 使用你 WordPress 服务器的套接字,地址和端口来替换
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
}
location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
expires max;
log_not_found off;
access_log off;
}
}
```
### 技巧 2. 缓存动态文件
WordPress 动态地生成网页,这意味着每次请求时它都要生成一个给定的网页(即使和前一次的结果相同)。这意味着用户随时获得的是最新内容。
想一下,当用户访问一个帖子时,并在文章底部有用户的评论时。你希望用户能够看到所有的评论 - 即使评论刚刚发布。动态内容就是处理这种情况的。
但现在,当帖子每秒出现十几二十几个请求时。应用服务器可能每秒需要频繁生成页面导致其压力过大,造成延误。为了给用户提供最新的内容,每个访问理论上都是新的请求,因此它们不得不在原始出处等待很长时间。
为了防止页面由于不断提升的负载而变得缓慢,需要缓存动态文件。这需要减少文件的动态内容来提高整个系统的响应速度。
要在 WordPress 中启用缓存中,需要使用一些流行的插件 - 如下所述。WordPress 的缓存插件会请求最新的页面,然后将其缓存短暂时间 - 也许只有几秒钟。因此,如果该网站每秒中会有几个请求,那大多数用户获得的页面都是缓存的副本。这也有助于提高所有用户的检索时间:
* 大多数用户获得页面的缓存副本。应用服务器没有做任何工作。
* 用户会得到一个之前的崭新副本。应用服务器只需每隔一段时间生成一个崭新页面。当服务器产生一个崭新页面(对于缓存过期后的第一个用户访问),它这样做要快得多,因为它的请求并没有超载。
你可以缓存运行在 LAMP 架构或者 LEMP 架构 上 WordPress 的动态文件(在 技巧 3 中说明了)。有几个缓存插件,你可以在 WordPress 中使用。运用到了最流行的缓存插件和缓存技术,从最简单到最强大的:
* [Hyper-Cache](https://wordpress.org/plugins/hyper-cache/) 和 [Quick-Cache](https://wordpress.org/plugins/quick-cache/) – 这两个插件为每个 WordPress 页面创建单个 PHP 文件。它支持绕过多个 WordPress 与数据库的连接核心处理的一些动态功能,创建一个更快的用户体验。它们不会绕过所有的 PHP 处理,所以并不会如下面那些取得同样的性能提升。它们也不需要修改 NGINX 的配置。
* [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/) – 最流行的 WordPress 缓存插件。在它易用的界面易用上提供了许多功能,如下所示。我们在 技巧 7 中展示了一个简单的 NGINX 配置实例。
* [W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/) – 这是第二流行的 WordPress 缓存插件。它比 WP Super Cache 的功能更强大,但它有些配置选项比较复杂。样例 NGINX 配置,请看 技巧 6。
* [FastCGI](http://www.fastcgi.com/) – CGI 的意思是<ruby> 通用网关接口 <rp> ( </rp> <rt> Common Gateway Interface </rt> <rp> ) </rp></ruby>,在因特网上发送请求和接收文件的一种通用方式。它不是一个插件,而是一种与缓存交互缓存的方法。FastCGI 可以被用在 Apache 和 Nginx 上,它也是最流行的动态缓存方法;我们在 技巧 5 中描述了如何配置 NGINX 来使用它。
这些插件和技术的文档解释了如何在典型的 LAMP 架构中配置它们。配置方式包括数据库和对象缓存;最小化 HTML、CSS 和 JavaScript;集成流行的 CDN 集成环境。对于 NGINX 的配置,请看列表中的提示技巧。
**注意**:缓存不会用于已经登录的 WordPress 用户,因为他们的 WordPress 页面都是不同的。(对于大多数网站来说,只有一小部分用户可能会登录)此外,大多数缓存不会对刚刚评论过的用户显示缓存页面,因为当用户刷新页面时希望看到他们的评论。若要缓存页面的非个性化内容,如果它对整体性能来说很重要,可以使用一种称为 [碎片缓存(fragment caching)](https://css-tricks.com/wordpress-fragment-caching-revisited/) 的技术。
### 技巧 3. 使用 NGINX
如上所述,当并发用户数超过某一数量时 Apache 会导致性能问题 – 可能是数百个用户同时使用。Apache 对于每一个连接会消耗大量的资源,因而容易耗尽内存。Apache 可以配置连接数的值来避免耗尽内存,但是这意味着,超过限制时,新的连接请求必须等待。
此外,Apache 为每个连接加载一个 mod\_php 模块副本到内存中,即使只有服务于静态文件(图片,CSS,JavaScript 等)。这使得每个连接消耗更多的资源,从而限制了服务器的性能。
要解决这些问题,从 LAMP 架构迁到 LEMP 架构 – 使用 NGINX 取代 Apache 。NGINX 在一定的内存之下就能处理成千上万的并发连接数,所以你不必经历颠簸,也不必限制并发连接数到很小的数量。
NGINX 处理静态文件的性能也较好,它有内置的,容易调整的 [缓存](https://www.nginx.com/resources/admin-guide/content-caching/) 控制策略。减少应用服务器的负载,你的网站的访问速度会更快,用户体验更好。
你可以在部署环境的所有 Web 服务器上使用 NGINX,或者你可以把一个 NGINX 服务器作为 Apache 的“前端”来进行反向代理 - NGINX 服务器接收客户端请求,将请求的静态文件直接返回,将 PHP 请求转发到 Apache 上进行处理。
对于动态页面的生成,这是 WordPress 核心体验,可以选择一个缓存工具,如 技巧 2 中描述的。在下面的技巧中,你可以看到 FastCGI,W3\_Total\_Cache 和 WP-Super-Cache 在 NGINX 上的配置示例。 (Hyper-Cache 和 Quick-Cache 不需要改变 NGINX 的配置。)
**技巧** 缓存通常会被保存到磁盘上,但你可以用 [tmpfs](https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt) 将缓存放在内存中来提高性能。
为 WordPress 配置 NGINX 很容易。仅需四步,其详细的描述在指定的技巧中:
1. 添加永久链接的支持 - 让 NGINX 支持永久链接。此步消除了对 **.htaccess** 配置文件的依赖,这是 Apache 特有的。参见 技巧 4。
2. 配置缓存 - 选择一个缓存工具并安装好它。可选择的有 FastCGI cache,W3 Total Cache, WP Super Cache, Hyper Cache, 和 Quick Cache。请看技巧 5、 6 和 7。
3. 落实安全防范措施 - 在 NGINX 上采用对 WordPress 最佳安全的做法。参见 技巧 8。
4. 配置 WordPress 多站点 - 如果你使用 WordPress 多站点,在 NGINX 下配置子目录,子域,或多域名架构。见 技巧9。
### 技巧 4. 让 NGINX 支持永久链接
许多 WordPress 网站依赖于 **.htaccess** 文件,此文件为 WordPress 的多个功能所需要,包括永久链接支持、插件和文件缓存。NGINX 不支持 **.htaccess** 文件。幸运的是,你可以使用 NGINX 的简单而全面的配置文件来实现大部分相同的功能。
你可以在你的主 [server](http://nginx.org/en/docs/http/ngx_http_core_module.html#server) 块下添加下面的 location 块中为使用 NGINX 的 WordPress 启用 [永久链接](http://codex.wordpress.org/Using_Permalinks)。(此 location 块在其它代码示例中也会被包括)。
**try\_files** 指令告诉 NGINX 检查请求的 URL 在文档根目录(**/var/www/example.com/htdocs**)下是作为文件(**$uri**)还是目录(**$uri/**) 存在的。如果都不是,NGINX 将重定向到 **/index.php**,并传递查询字符串参数作为参数。
```
server {
server_name example.com www.example.com;
root /var/www/example.com/htdocs;
index index.php;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
}
```
### 技巧 5. 在 NGINX 中配置 FastCGI
NGINX 可以缓存来自 FastCGI 应用程序的响应,如 PHP 响应。此方法可提供最佳的性能。
对于开源的 NGINX,编译入第三方模块 [ngx\_cache\_purge](https://github.com/FRiCKLE/ngx_cache_purge) 可以提供缓存清除能力,配置代码如下所示。NGINX Plus 已经包含了它自己实现此代码。
当使用 FastCGI 时,我们建议你安装 [NGINX 辅助插件](https://wordpress.org/plugins/nginx-helper/) 并使用下面的配置文件,尤其是要注意 **fastcgi\_cache\_key** 的使用和包括 **fastcgi\_cache\_purge** 的 location 块。当页面发布或有改变时,有新评论被发布时,该插件会自动清除你的缓存,你也可以从 WordPress 管理控制台手动清除。
NGINX 的辅助插件还可以在你网页的底部添加一个简短的 HTML 代码,以确认缓存是否正常并显示一些统计数据。(你也可以使用 [$upstream*cache*status](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#variables) 确认缓存功能是否正常。)
```
fastcgi_cache_path /var/run/nginx-cache levels=1:2
keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
server {
server_name example.com www.example.com;
root /var/www/example.com/htdocs;
index index.php;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
set $skip_cache 0;
### POST 请求和带有查询参数的网址应该交给 PHP
if ($request_method = POST) {
set $skip_cache 1;
}
if ($query_string != "") {
set $skip_cache 1;
}
### 以下 uris 中包含的部分不缓存
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php
|sitemap(_index)?.xml") {
set $skip_cache 1;
}
### 不要为登录用户或最近的评论者进行缓存
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass
|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri /index.php;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 60m;
}
location ~ /purge(/.*) {
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png
|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off;
log_not_found off;
expires max;
}
location = /robots.txt {
access_log off;
log_not_found off;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}
```
### 技巧 6. 为 NGINX 配置 W3\_Total\_Cache
[W3 Total Cache](https://wordpress.org/plugins/w3-total-cache/), 是 [W3-Edge](http://www.w3-edge.com/) 的 Frederick Townes 出品的, 是一个支持 NGINX 的 WordPress 缓存框架。其有众多选项配置,可以替代 FastCGI 缓存。
这个缓存插件提供了各种缓存配置,还包括数据库和对象的缓存,最小化 HTML、CSS 和 JavaScript,并可选与流行的 CDN 整合。
这个插件会通过写入一个位于你的域的根目录的 NGINX 配置文件来控制 NGINX。
```
server {
server_name example.com www.example.com;
root /var/www/example.com/htdocs;
index index.php;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log;
include /path/to/wordpress/installation/nginx.conf;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
```
### 技巧 7. 为 NGINX 配置 WP Super Cache
[WP Super Cache](https://wordpress.org/plugins/wp-super-cache/) 是由 Donncha O Caoimh 开发的, 他是 [Automattic](http://automattic.com/) 的一个 WordPress 开发者, 这是一个 WordPress 缓存引擎,它可以将 WordPress 的动态页面转变成静态 HTML 文件,以使 NGINX 可以很快的提供服务。它是第一个 WordPress 缓存插件,和其它的相比,它更专注于某一特定的领域。
配置 NGINX 使用 WP Super Cache 可以根据你的喜好而进行不同的配置。以下是一个示例配置。
在下面的配置中,带有名为 supercache 的 location 块是 WP Super Cache 特有的部分。 WordPress 规则的其余代码用于不缓存已登录用户的信息,不缓存 POST 请求,并对静态资源设置过期首部,再加上标准的 PHP 处理;这部分可以根据你的需求进行定制。
```
server {
server_name example.com www.example.com;
root /var/www/example.com/htdocs;
index index.php;
access_log /var/log/nginx/example.com.access.log;
error_log /var/log/nginx/example.com.error.log debug;
set $cache_uri $request_uri;
### POST 请求和带有查询字符串的网址应该交给 PHP
if ($request_method = POST) {
set $cache_uri 'null cache';
}
if ($query_string != "") {
set $cache_uri 'null cache';
}
### 以下 uris 中包含的部分不缓存
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php
|wp-.*.php|/feed/|index.php|wp-comments-popup.php
|wp-links-opml.php|wp-locations.php |sitemap(_index)?.xml
|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
set $cache_uri 'null cache';
}
### 不对已登录用户和最近的评论者使用缓存
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+
|wp-postpass|wordpress_logged_in") {
set $cache_uri 'null cache';
}
### 当请求的文件存在时使用缓存,否则将请求转发给 WordPress
location / {
try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html
$uri $uri/ /index.php;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
log_not_found off
access_log off;
}
location ~ .php$ {
try_files $uri /index.php;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
}
### 尽可能的缓存静态文件
location ~*.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css
|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2
|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
expires max;
log_not_found off;
access_log off;
}
}
```
### 技巧 8. 为 NGINX 配置安全防范措施
为了防止攻击,可以控制对关键资源的访问并限制机器人对登录功能的过量攻击。
只允许特定的 IP 地址访问 WordPress 的仪表盘。
```
### 对访问 WordPress 的仪表盘进行限制
location /wp-admin {
deny 192.192.9.9;
allow 192.192.1.0/24;
allow 10.1.1.0/16;
deny all;
}
```
只允许上传特定类型的文件,以防止恶意代码被上传和运行。
```
### 当上传的不是图像,视频,音乐等时,拒绝访问。
location ~* ^/wp-content/uploads/.*.(html|htm|shtml|php|js|swf)$ {
deny all;
}
```
拒绝其它人访问 WordPress 的配置文件 **wp-config.php**。拒绝其它人访问的另一种方法是将该文件的一个目录移到域的根目录之上的目录。
```
### 拒绝其它人访问 wp-config.php
location ~* wp-config.php {
deny all;
}
```
对 **wp-login.php** 进行限速来防止暴力破解。
```
### 拒绝访问 wp-login.php
location = /wp-login.php {
limit_req zone=one burst=1 nodelay;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_pass 127.0.0.1:9000;
}
```
### 技巧 9. 配置 NGINX 支持 WordPress 多站点
<ruby> WordPress 多站点 <rp> ( </rp> <rt> WordPress Multisite </rt> <rp> ) </rp></ruby>,顾名思义,这个版本 WordPress 可以让你以单个实例管理两个或多个网站。[WordPress.com](https://wordpress.com/) 运行的就是 WordPress 多站点,其主机为成千上万的用户提供博客服务。
你可以从单个域的任何子目录或从不同的子域来运行独立的网站。
使用此代码块添加对子目录的支持。
```
### 在 WordPress 多站点中添加对子目录结构的支持
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
```
使用此代码块来替换上面的代码块以添加对子目录结构的支持,替换为你自己的子目录名。
```
### 添加支持子域名
server_name example.com *.example.com;
```
旧版本(3.4以前)的 WordPress 多站点使用 readfile() 来提供静态内容。然而,readfile() 是 PHP 代码,它会导致在执行时性能会显著降低。我们可以用 NGINX 来绕过这个非必要的 PHP 处理。该代码片段在下面被(==============)线分割出来了。
```
### 避免对子目录中 /blogs.dir/ 结构执行 PHP readfile()
location ^~ /blogs.dir {
internal;
alias /var/www/example.com/htdocs/wp-content/blogs.dir;
access_log off;
log_not_found off;
expires max;
}
============================================================
### 避免对子目录中 /files/ 结构执行 PHP readfile()
location ~ ^(/[^/]+/)?files/(?.+) {
try_files /wp-content/blogs.dir/$blogid/files/$rt_file /wp-includes/ms-files.php?file=$rt_file;
access_log off;
log_not_found off;
expires max;
}
============================================================
### 子域路径的WPMU 文件结构
location ~ ^/files/(.*)$ {
try_files /wp-includes/ms-files.php?file=$1 =404;
access_log off;
log_not_found off;
expires max;
}
============================================================
### 映射博客 ID 到特定的目录
map $http_host $blogid {
default 0;
example.com 1;
site1.example.com 2;
site1.com 2;
}
```
### 结论
可扩展性对许多要让他们的 WordPress 站点取得成功的开发者来说是一项挑战。(对于那些想要跨越 WordPress 性能门槛的新站点而言。)为 WordPress 添加缓存,并将 WordPress 和 NGINX 结合,是不错的答案。
NGINX 不仅用于 WordPress 网站。世界上排名前 1000、10000 和 100000 网站中 NGINX 也是 [遥遥领先的 web 服务器](http://w3techs.com/technologies/cross/web_server/ranking)。
欲了解更多有关 NGINX 的性能,请看我们最近的博客,[让应用性能提升 10 倍的 10 个技巧](https://www.nginx.com/blog/10-tips-for-10x-application-performance/)。
NGINX 软件有两个版本:
* NGINX 开源软件 - 像 WordPress 一样,此软件你可以自行下载,配置和编译。
* NGINX Plus - NGINX Plus 包括一个预构建的参考版本的软件,以及服务和技术支持。
想要开始,先到 [nginx.org](http://www.nginx.org/en) 下载开源软件并了解下 [NGINX Plus](https://www.nginx.com/products/)。
---
via: <https://www.nginx.com/blog/9-tips-for-improving-wordpress-performance-with-nginx/>
作者:[Floyd Smith](https://www.nginx.com/blog/author/floyd/) 译者:[strugglingyouth](https://github.com/strugglingyouth) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,772 | CentOS 7 ARM 版正式发布:支持树莓派2/香蕉派/CubieTruck | http://news.softpedia.com/news/centos-7-linux-officially-released-for-raspberry-pi-2-banana-pi-and-cubietruck-497891.shtml | 2015-12-22T08:00:00 | [
"CentOS",
"树莓派"
] | https://linux.cn/article-6772-1.html | 来自 CentOS 团队的 Karanbir Singh 宣布,基于 ARM 硬件架构的 CentOS 7 Linux 系统已经发布!

当前,除了 Twitter 上一则消息外,CentOS 开发者们并没有在他们的网站上对这个 ARM 版本有更多说明。

根据目前给出的[下载链接](http://mirror.centos.org/altarch/7/isos/armhfp/)看,该 CentOS 7 ARM 版可以工作在各种 ARMv7 设备上,预构建的二进制镜像包括了流行的 <ruby> 树莓派2 <rp> ( </rp> <rt> Raspberry Pi 2 </rt> <rp> ) </rp></ruby>、<ruby> 香蕉派 <rp> ( </rp> <rt> Banana Pi </rt> <rp> ) </rp></ruby>和 CubieTruck (这是一个国内团队的产品,闻名于国际)。
下载链接: <http://mirror.centos.org/altarch/7/isos/armhfp/>
| 301 | Moved Permanently | null |
6,773 | 目标未达成:Ubuntu 未达成 4 年 2 亿用户目标 | https://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-No-200-Million-Users | 2015-12-22T08:30:00 | [
"Canonical",
"Ubuntu"
] | https://linux.cn/article-6773-1.html | 4年前在 [UDS 布达佩斯](http://www.phoronix.com/vr.php?view=16002),[Shuttleworth 表示 Ubuntu 将在 4 年内达到 2 亿用户](http://www.phoronix.com/scan.php?page=news_item&px=2015-200-Million-Goal-Retro)。
时间已经接近了2015年底,看起来 Ubuntu 并不像是能达成这个目标的样子。Ubuntu 的母公司 Canonical 并没有提供确切的用户数,但是之前的迹象表明,Ubuntu 装机数量(包括桌面和服务器)也就是千万级,我没有看到任何报告说达到了1亿,更别说是2亿.
在游戏玩家中,根据 Valve 的 Steam 调查数据显示, [Linux 的市场份额大约是 1%](https://www.phoronix.com/scan.php?page=news_item&px=Steam-Survey-Nov-2015) 。据 StatCounter 的数据,当前的笔记本/桌面市场上,Linux 桌面大约占比 1.5%。Ubuntu 在云市场和物联网方面也有一定的占比。很难统计 Ubuntu Phone 的用户量,但是肯定不会超过 100 万,在9月份时,[估计只有 25000 个独立用户](https://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-Phone-Estimate-25k)。

在 Mark 宣布 2 亿的目标时,他可能是估计了 Ubuntu 在手机和平板上的市场,以及短命的 [Ubuntu 电视](https://www.phoronix.com/scan.php?page=search&q=Ubuntu%20TV),甚至他可能还想到了 [Ubuntu 在车载上的应用](https://www.phoronix.com/scan.php?page=news_item&px=MTgzOTU)。不过,这些都没有实现。
| 301 | Moved Permanently | null |
6,774 | 2015:微软开源年 | http://www.phoronix.com/scan.php?page=news_item&px=Microsoft-2015-What-A-Year | 2015-12-22T18:57:42 | [
"微软",
"开源"
] | https://linux.cn/article-6774-1.html | 
在开源和 Linux 方面,2015年的微软有许多惊人的举动!让我们来盘点一下这一年来微软都做了些什么。
* 微软在其 Edge 浏览器中[支持了 VP9 解码器](http://www.phoronix.com/scan.php?page=news_item&px=Microsoft-VP9-Edge-Win),这是 Google 推出的免费视频解码器
* 在浏览器前端,微软宣布他们[将开源其名为 Chakra 的 JavaScript 引擎](/article-6698-1.html)
* 微软会通过 PowerShell [支持 OpenSSH](/article-6432-1.html)。为了在 Windows 上更好地支持 OpenSSH,微软还[捐赠了 OpenBSD](/article-5786-1.html)
* 微软[开源了其 .NET 的主要部分](/article-4821-1.html),将 .NET 带到了 Linux 和 [BSD](/article-5416-1.html) 上
* [MS Build Engine](/article-5091-1.html) 也开源了
* 微软发布了其第一个 Linux 发行版 [Azure Cloud Switch](/article-6269-1.html),它运行在他们的 SDN 数据中心内
* 作为其 Azure 战略的一部分,微软继续为 Linux [贡献 Hyper-V 代码](/article-5230-1.html)
* Visual Studio 2015 支持[构建 Linux 平台上的应用](http://www.phoronix.com/scan.php?page=news_item&px=Visual-Studio-2015-Launches),虽然现在还不能在 Linux 系统上运行 VS2015
* 不过其集成开发环境 Visual Studio Code [支持运行在 Linux 上](/article-5376-1.html) ,而且[开源](/article-6604-1.html)了
* 微软在 Clang 编译器上[做了很多工作](http://www.phoronix.com/scan.php?page=news_item&px=Microsoft-Clang-Continues),他们[对 Clang 做了改进](http://www.phoronix.com/scan.php?page=news_item&px=Microsoft-Visual-Clang-Windows)、[开源了其调试引擎](http://www.phoronix.com/scan.php?page=news_item&px=Microsoft-Open-GDB-LLDB)
* 和 Clang 方面的工作相关,微软开始开发一个称之为 LLILC 的[基于 LLVM 的 .NET 编译器](http://www.phoronix.com/scan.php?page=news_item&px=Microsoft-LLVM-dotNET-LLILC),这个[新的编译器的进展很快](http://www.phoronix.com/scan.php?page=news_item&px=LLILC-6-Month-Update)
* 开发了 Android 上的 Office 软件,为手机/平板提供了微软 Office 套件的基本功能
* 以上这些都[放在了 GitHub 上](http://www.phoronix.com/scan.php?page=news_item&px=Microsoft-CodePlex-To-GitHub),而不是他们自己的 CodePlex 上
* 此外,微软开放技术公司被合并回了微软公司
这一年对于微软来说是不寻常的一年,不管你喜欢不喜欢微软,都让我们对这个 Windows 的缔造者在开源和 Linux 方面 2016 年的表现拭目以待吧!
| 301 | Moved Permanently | null |
6,776 | 如何在 CentOS 上启用 软件集 Software Collections(SCL) | http://xmodulo.com/enable-software-collections-centos.html | 2015-12-23T08:00:00 | [
"SCL",
"CentOS"
] | https://linux.cn/article-6776-1.html | 红帽企业版 linux(RHEL)和它的社区版分支——CentOS,提供10年的生命周期,这意味着 RHEL/CentOS 的每个版本会提供长达10年的安全更新。虽然这么长的生命周期为企业用户提供了迫切需要的系统兼容性和可靠性,但也存在一个缺点:随着底层的 RHEL/CentOS 版本接近生命周期的结束,核心应用和运行时环境变得陈旧过时。例如 CentOS 6.5,它的生命周期结束时间是2020年11月30日,其所携带的 Python 2.6.6和 MySQL 5.1.73,以今天的标准来看已经非常古老了。
另一方面,在 RHEL/CentOS 上试图手动升级开发工具链和运行时环境存在使系统崩溃的潜在可能,除非所有依赖都被正确解决。通常情况下,手动升级都是不推荐的,除非你知道你在干什么。

<ruby> <a href="https://www.softwarecollections.org/"> 软件集 </a> <rp> ( </rp> <rt> Software Collections </rt> <rp> ) </rp></ruby>(SCL)源出现了,以帮助解决 RHEL/CentOS 下的这种问题。SCL 的创建就是为了给 RHEL/CentOS 用户提供一种以方便、安全地安装和使用应用程序和运行时环境的多个(而且可能是更新的)版本的方式,同时避免把系统搞乱。与之相对的是第三方源,它们可能会在已安装的包之间引起冲突。
最新的 SCL 提供了:
* Python 3.3 和 2.7
* PHP 5.4
* Node.js 0.10
* Ruby 1.9.3
* Perl 5.16.3
* MariaDB 和 MySQL 5.5
* Apache httpd 2.4.6
在这篇教程的剩余部分,我会展示一下如何配置 SCL 源,以及如何安装和启用 SCL 中的包。
### 配置 SCL 源
SCL 可用于 CentOS 6.5 及更新的版本。要配置 SCL 源,只需执行:
```
$ sudo yum install centos-release-SCL
```
要启用和运行 SCL 中的应用,你还需要安装下列包:
```
$ sudo yum install scl-utils-build
```
执行下面的命令可以查看 SCL 中可用包的完整列表:
```
$ yum --disablerepo="*" --enablerepo="scl" list available
```

### 从 SCL 中安装和启用包
既然你已配置好了 SCL,你可以继续并从 SCL 中安装包了。
你可以搜索 SCL 中的包:
```
$ yum --disablerepo="*" --enablerepo="scl" search <keyword>
```
我们假设你要安装 Python 3.3。
继续,就像通常安装包那样使用 yum 安装:
```
$ sudo yum install python33
```
任何时候你都可以查看从 SCL 中安装的包的列表,只需执行:
```
$ scl --list
python33
```
SCL 的优点之一是安装其中的包不会覆盖任何系统文件,并且保证不会引起与系统中其它库和应用的冲突。
例如,如果在安装 python33 包后检查默认的 python 版本,你会发现默认的版本并没有改变:
```
$ python --version
Python 2.6.6
```
如果想使用一个已经安装的 SCL 包,你需要在每个命令中使用 `scl` 命令显式启用它(LCTT 译注:即想在哪条命令中使用 SCL 中的包,就得通过`scl`命令执行该命令)
```
$ scl enable <scl-package-name> <command>
```
例如,要针对`python`命令启用 python33 包:
```
$ scl enable python33 'python --version'
Python 3.3.2
```
如果想在启用 python33 包时执行多条命令,你可以像下面那样创建一个启用 SCL 的 bash 会话:
```
$ scl enable python33 bash
```
在这个 bash 会话中,默认的 python 会被切换为3.3版本,直到你输入`exit`,退出会话。

简而言之,SCL 有几分像 Python 的虚拟环境,但更通用,因为你可以为远比 Python 更多的应用启用/禁用 SCL 会话。
更详细的 SCL 指南,参考官方的[快速入门指南](https://www.softwarecollections.org/docs/)
---
via: <http://xmodulo.com/enable-software-collections-centos.html>
作者:[Dan Nanni](http://xmodulo.com/author/nanni) 译者:[bianjp](https://github.com/bianjp) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,777 | Linux/Unix 桌面趣事:桌面上追逐的猫和老鼠 | http://www.cyberciti.biz/open-source/oneko-app-creates-cute-cat-chasing-around-your-mouse/ | 2015-12-23T10:04:00 | [
"Oneko"
] | https://linux.cn/article-6777-1.html | Oneko 是一个有趣的应用。它会把你的光标变成一只老鼠,并在后面创建一个可爱的小猫,并且始终追逐着老鼠光标。单词“neko”在日语中的意思是猫。它最初是一位日本人开发的 Macintosh 桌面附件。

### 安装 oneko
试下下面的命令:
```
$ sudo apt-get install oneko
```
示例输出:
```
[sudo] password for vivek:
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
oneko
0 upgraded, 1 newly installed, 0 to remove and 10 not upgraded.
Need to get 38.6 kB of archives.
After this operation, 168 kB of additional disk space will be used.
Get:1 http://debian.osuosl.org/debian/ squeeze/main oneko amd64 1.2.sakura.6-7 [38.6 kB]
Fetched 38.6 kB in 1s (25.9 kB/s)
Selecting previously deselected package oneko.
(Reading database ... 274152 files and directories currently installed.)
Unpacking oneko (from .../oneko_1.2.sakura.6-7_amd64.deb) ...
Processing triggers for menu ...
Processing triggers for man-db ...
Setting up oneko (1.2.sakura.6-7) ...
Processing triggers for menu ...
```
FreeBSD 用户输入下面的命令安装 oneko:
```
# cd /usr/ports/games/oneko
# make install clean
```
### 我该如何使用 oneko?
输入下面的命令:
```
$ oneko
```
你可以把猫变成 “tora-neko”,一只像白老虎条纹的猫:
```
$ oneko -tora
```
### 不喜欢猫?
你可以用狗代替猫:
```
$ oneko -dog
```
下面可以用樱花代替猫:
```
$ oneko -sakura
```
用大道寺代替猫:
```
$ oneko -tomoyo
```
### 查看相关媒体
这个教程同样也有视频格式:
### 其他选项
你可以传入下面的选项
1. **-tofocus**:让猫在获得焦点的窗口顶部奔跑。当获得焦点的窗口不在视野中时,猫像平常那样追逐老鼠。
2. **-position 坐标** :指定X和Y来调整猫相对老鼠的位置
3. **-rv**:将前景色和背景色对调
4. **-fg 颜色** : 前景色 (比如 oneko -dog -fg red)。
5. **-bg 颜色** : 背景色 (比如 oneko -dog -bg green)。
6. 查看 oneko 的手册获取更多信息。
---
via: <http://www.cyberciti.biz/open-source/oneko-app-creates-cute-cat-chasing-around-your-mouse/>
作者:Vivek Gite 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,778 | 如何在 Ubuntu 中安装最新的 Arduino IDE 1.6.6 | http://ubuntuhandbook.org/index.php/2015/11/install-arduino-ide-1-6-6-ubuntu/ | 2015-12-24T10:35:00 | [
"Arduino IDE"
] | https://linux.cn/article-6778-1.html | 
>
> 本篇教程会教你如何在当前的 Ubuntu 发行版中安装最新的 Arduino IDE 1.6.6。
>
>
>
开源的 Arduino IDE 发布了1.6.6,并带来了很多的改变。新的发布已经切换到 Java 8,它与 IDE 绑定并且用于编译所需。具体见 [发布说明](https://www.arduino.cc/en/Main/ReleaseNotes)。

对于那些不想使用软件中心的 1.0.5 旧版本的人而言,你可以使用下面的步骤在所有的 Ubuntu 发行版中安装 Arduino。
>
> **请用正确版本号替换下文中软件包的版本号**
>
>
>
**1、** 从下面的官方链接下载最新的包 **Linux 32-bit 或者 Linux 64-bit**。
* <https://www.arduino.cc/en/Main/Software>
如果不知道你系统的类型?进入系统设置->详细->概览。
**2、** 从Unity Dash、App Launcher 或者使用 Ctrl+Alt+T 打开终端。打开后,一个个运行下面的命令:
进入下载文件夹:
```
cd ~/Downloads
```

使用 tar 命令解压:
```
tar -xvf arduino-1.6.6-*.tar.xz
```

将解压后的文件移动到**/opt/**下:
```
sudo mv arduino-1.6.6 /opt
```

**3、** 现在 IDE 已经与最新的 Java 绑定使用了。但是最好为程序设置一个桌面图标/启动方式:
进入安装目录:
```
cd /opt/arduino-1.6.6/
```
在这个目录给 install.sh 可执行权限
```
chmod +x install.sh
```
最后运行脚本同时安装桌面快捷方式和启动图标:
```
./install.sh
```
下图中我用“&&”同时运行这三个命令:

最后从 Unity Dash、程序启动器或者桌面快捷方式运行 Arduino IDE。
---
via: <http://ubuntuhandbook.org/index.php/2015/11/install-arduino-ide-1-6-6-ubuntu/>
作者:[Ji m](http://ubuntuhandbook.org/index.php/about/) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,779 | 如何深度定制 Ubuntu 面板的时间日期显示格式 | http://ubuntuhandbook.org/index.php/2015/12/time-date-format-ubuntu-panel/ | 2015-12-25T09:43:00 | [
"时间"
] | https://linux.cn/article-6779-1.html | 
尽管设置页面里已经有一些选项可以用了,这个快速教程会向你展示如何更加深入地自定义 Ubuntu 面板上的时间和日期指示器。

在开始之前,在 Ubuntu 软件中心搜索并安装 **dconf Editor**。然后启动该软件并按以下步骤执行:
**1、** 当 dconf Editor 启动后,导航至 **com -> canonical -> indicator -> datetime**。将 **time-format** 的值设置为 **custom**。

你也可以通过终端里的命令完成以上操作:
```
gsettings set com.canonical.indicator.datetime time-format 'custom'
```
**2、** 现在你可以通过编辑 **custom-time-format** 的值来自定义时间和日期的格式。

你也可以通过命令完成:(LCTT 译注:将 FORMAT*VALUE*HERE 替换为所需要的格式值)
```
gsettings set com.canonical.indicator.datetime custom-time-format 'FORMAT_VALUE_HERE'
```
以下是参数含义:
* %a = 星期名缩写
* %A = 星期名完整拼写
* %b = 月份名缩写
* %B = 月份名完整拼写
* %d = 每月的日期
* %l = 小时 ( 1..12), %I = 小时 (01..12)
* %k = 小时 ( 1..23), %H = 小时 (01..23)
* %M = 分钟 (00..59)
* %p = 午别,AM 或 PM, %P = am 或 pm.
* %S = 秒 (00..59)
可以打开终端键入命令 `man date` 并执行以了解更多细节。
一些自定义时间日期显示格式值的例子:



---
via: <http://ubuntuhandbook.org/index.php/2015/12/time-date-format-ubuntu-panel/>
作者:[Ji m](http://ubuntuhandbook.org/index.php/about/) 译者:[alim0x](https://github.com/alim0x) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,780 | 如何在树莓派 2B 上安装 FreeBSD | http://www.cyberciti.biz/faq/how-to-install-freebsd-on-raspberry-pi-2-model-b/ | 2015-12-24T14:15:00 | [
"树莓派",
"FreeBSD"
] | https://linux.cn/article-6780-1.html | 在树莓派 2B 上如何安装 FreeBSD 10 或 FreeBSD 11(current)?怎么在 Linux,OS X,FreeBSD 或类 Unix 操作系统上烧录 SD 卡?
在树莓派 2B 上安装 FreeBSD 10 或 FreeBSD 11(current)很容易。使用 FreeBSD 操作系统可以打造一个非常易用的 Unix 服务器。FreeBSD-CURRENT 自2012年十一月以来一直支持树莓派,2015年三月份后也开始支持树莓派2了。在这个快速教程中我将介绍如何在树莓派 2B 上安装 FreeBSD 11 current arm 版。
### 1. 下载 FreeBSD-current 的 arm 镜像
你可以 [访问这个页面来下载](ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/arm/armv6/ISO-IMAGES/11.0) 树莓派2的镜像。使用 wget 或 curl 命令来下载镜像:
```
$ wget ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/arm/armv6/ISO-IMAGES/11.0/FreeBSD-11.0-CURRENT-arm-armv6-RPI2-20151016-r289420.img.xz
```
或
```
$ curl -O ftp://ftp.freebsd.org/pub/FreeBSD/snapshots/arm/armv6/ISO-IMAGES/11.0/FreeBSD-11.0-CURRENT-arm-armv6-RPI2-20151016-r289420.img.xz
```
### 2. 解压 FreeBSD-current 镜像
执行以下命令中的任何一个:
```
$ unxz FreeBSD-11.0-CURRENT-arm-armv6-RPI2-20151016-r289420.img.xz
```
或
```
$ xz --decompress FreeBSD-11.0-CURRENT-arm-armv6-RPI2-20151016-r289420.img.xz
```
### 3. 设置 SD
你可以在 OS X,Linux,FreeBSD,MS-Windows 和类 Unix 系统来烧录 SD 卡。
#### 在 Mac OS X 下烧录 FreeBSD-current
使用下面的 dd 命令:
```
$ diskutil list
$ diskutil unmountDisk /dev/diskN
$ sudo dd if=FreeBSD-11.0-CURRENT-arm-armv6-RPI2-20151016-r289420.img of=/dev/disk2 bs=64k
```
示例输出:
```
1024+0 records in
1024+0 records out
1073741824 bytes transferred in 661.669584 secs (1622776 bytes/sec)
```
#### 使用 Linux/FreeBSD 或者类 Unix 系统来烧录 FreeBSD-current
语法是这样:
```
$ dd if=FreeBSD-11.0-CURRENT-arm-armv6-RPI2-20151016-r289420.img of=/dev/sdb bs=1M
```
**确保使用实际的 SD 卡的设备名称来替换 /dev/sdb**(LCTT 译注:千万注意不要写错了)。
### 4. 引导 FreeBSD
在树莓派 2B 上插入 SD 卡。你需要连接键盘,鼠标和显示器。我使用的是 USB 转串口线来连接显示器的:

*图01 基于树莓派 USB 的串行连接*
在下面的例子中,我使用 screen 命令来连接我的 RPI:
```
## Linux 上 ##
screen /dev/tty.USB0 115200
## OS X 上 ##
screen /dev/cu.usbserial 115200
## Windows 请使用 Putty.exe ##
```
FreeBSD RPI 启动输出样例:

*图02: 在树莓派 2上引导 FreeBSD-current*
### 5. FreeBSD 在 RPi 2上的用户名和密码
默认的密码是 freebsd/freebsd 和 root/root。
到此为止, FreeBSD-current 已经安装并运行在树莓派 2上。
---
via: <http://www.cyberciti.biz/faq/how-to-install-freebsd-on-raspberry-pi-2-model-b/>
作者:[Vivek Gite](http://www.cyberciti.biz/tips/about-us) 译者:[strugglingyouth](https://github.com/strugglingyouth) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,781 | 可以在 Linux 下试试苹果编程语言 Swift | http://itsfoss.com/swift-open-source-linux/ | 2015-12-23T13:35:00 | [
"Swift",
"编程语言"
] | https://linux.cn/article-6781-1.html | 
是的,你知道的,苹果编程语言 Swift 已经开源了。其实我们并不应该感到意外,因为[在六个月以前苹果就已经宣布了这个消息](http://itsfoss.com/apple-open-sources-swift-programming-language-linux/)。
苹果宣布推出开源 Swift 社区。一个专用于开源 Swift 社区的[新网站](https://swift.org/)已经就位,网站首页显示以下信息:
>
> 我们对 Swift 开源感到兴奋。在苹果推出了编程语言 Swift 之后,它很快成为历史上增长最快的语言之一。Swift 可以编写出难以置信的又快又安全的软件。目前,Swift 是开源的,你可以将这个最好的通用编程语言用在各种地方。
>
>
>
[swift.org](https://swift.org/) 这个网站将会作为一站式网站,它会提供各种资料的下载,包括各种平台,社区指南,最新消息,入门教程,为开源 Swift 做贡献的说明,文件和一些其他的指南。 如果你正期待着学习 Swift,那么必须收藏这个网站。
在苹果的这次宣布中,一个用于方便分享和构建代码的包管理器已经可用了。
对于所有的 Linux 使用者来说,最重要的是,源代码已经可以从 [Github](https://github.com/apple)获得了.你可以从以下链接 Checkout 它:
* [苹果 Swift 源代码](https://github.com/apple)
除此之外,对于 ubuntu 14.04 和 15.10 版本还有预编译的二进制文件。
* [ubuntu 系统的 Swift 二进制文件](https://swift.org/download/#latest-development-snapshots)
不要急着在产品环境中使用它们,因为这些都是开发分支而不适合于产品环境。因此现在应避免使用在产品环境中,一旦发布了 Linux 下 Swift 的稳定版本,我希望 ubuntu 会把它包含在 [umake](https://wiki.ubuntu.com/ubuntu-make)中,和 [Visual Studio Code](http://itsfoss.com/install-visual-studio-code-ubuntu/) 放一起。
---
via: <http://itsfoss.com/swift-open-source-linux/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[Flowsnow](https://github.com/Flowsnow) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,783 | 一个涵盖 Unix 44 年进化史的版本仓库 | http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html | 2015-12-23T17:52:00 | [
"UNIX",
"演化",
"BSD",
"进化"
] | https://linux.cn/article-6783-1.html |
>
> <http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html>
>
>
> This is an HTML rendering of a working paper draft that led to a publication. The publication should always be cited in preference to this draft using the following reference:
>
>
> * **Diomidis Spinellis**. [A repository with 44 years of Unix evolution](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html). In MSR '15: Proceedings of the 12th Working Conference on Mining Software Repositories, pages 13-16. IEEE, 2015. Best Data Showcase Award. ([doi:10.1109/MSR.2015.6](http://dx.doi.org/10.1109/MSR.2015.6))
>
>
> This document is also available in [PDF format](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.pdf).
>
>
> The document's metadata is available in [BibTeX format](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c-bibtex.html).
>
>
> This material is presented to ensure timely dissemination of scholarly and technical work. Copyright and all rights therein are retained by authors or by other copyright holders. All persons copying this information are expected to adhere to the terms and constraints invoked by each author's copyright. In most cases, these works may not be reposted without the explicit permission of the copyright holder.
>
>
> [Diomidis Spinellis Publications](http://www.dmst.aueb.gr/dds/pubs/)
>
>
> © 2015 IEEE. Personal use of this material is permitted. However, permission to reprint/republish this material for advertising or promotional purposes or for creating new collective works for resale or redistribution to servers or lists, or to reuse any copyrighted component of this work in other works must be obtained from the IEEE.
>
>
>

### 摘要
Unix 操作系统的进化历史,可以从一个版本控制仓库中窥见,时间跨度从 1972 年的 5000 行内核代码开始,到 2015 年成为一个含有 26,000,000 行代码的被广泛使用的系统。该仓库包含 659,000 条提交,和 2306 次合并。仓库部署了被普遍采用的 Git 系统用于储存其代码,并且在时下流行的 GitHub 上建立了存档。它由来自<ruby> 贝尔实验室 <rp> ( </rp> <rt> Bell Labs </rt> <rp> ) </rp></ruby>,<ruby> 伯克利大学 <rp> ( </rp> <rt> Berkeley University </rt> <rp> ) </rp></ruby>,386BSD 团队所开发的系统软件的 24 个快照综合定制而成,这包括两个老式仓库和一个开源 FreeBSD 系统的仓库。总的来说,可以确认其中的 850 位个人贡献者,更早些时候的一批人主要做基础研究。这些数据可以用于一些经验性的研究,在软件工程,信息系统和软件考古学领域。
### 1、介绍
Unix 操作系统作为一个主要的工程上的突破而脱颖而出,得益于其模范的设计、大量的技术贡献、它的开发模型及广泛的使用。Unix 编程环境的设计已经被视为一个提供非常简洁、强大而优雅的设计 [[1](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#MPT78)] 。在技术方面,许多对 Unix 有直接贡献的,或者因 Unix 而流行的特性就包括 [[2](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#RT78)] :用高级语言编写的可移植部署的内核;一个分层式设计的文件系统;兼容的文件,设备,网络和进程间 I/O;管道和过滤架构;虚拟文件系统;和作为普通进程的可由用户选择的不同 shell。很早的时候,就有一个庞大的社区为 Unix 贡献软件 [[3](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#Rit84)] ,[[4](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#Sal94),pp. 65-72] 。随时间流逝,这个社区不断壮大,并且以现在称为开源软件开发的方式在工作着 [[5](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#Ray03),pp. 440-442] 。Unix 和其睿智的晚辈们也将 C 和 C++ 编程语言、分析程序和词法分析生成器(*yacc*,*lex*)、文档编制工具(*troff*,*eqn*,*tbl*)、脚本语言(*awk*,*sed*,*Perl*)、TCP/IP 网络、和<ruby> 配置管理系统 <rp> ( </rp> <rt> configuration management system </rt> <rp> ) </rp></ruby>(*SCSS*,*RCS*,*Subversion*,*Git*)发扬广大了,同时也形成了现代互联网基础设施和网络的最大的部分。
幸运的是,一些重要的具有历史意义的 Unix 材料已经保存下来了,现在保持对外开放。尽管 Unix 最初是由相对严格的协议发行,但在早期的开发中,很多重要的部分是通过 Unix 的版权拥有者之一(Caldera International) (LCTT 译注:2002年改名为 SCO Group)以一个自由的协议发行。通过将这些部分再结合上由<ruby> 加州大学伯克利分校 <rp> ( </rp> <rt> University of California, Berkeley </rt> <rp> ) </rp></ruby>和 FreeBSD 项目组开发或发布的开源软件,贯穿了从 1972 年六月二十日开始到现在的整个系统的开发。
通过规划和处理这些可用的快照以及或旧或新的配置管理仓库,将这些可用数据的大部分重建到一个新合成的 Git 仓库之中。这个仓库以数字的形式记录了过去44年来最重要的数字时代产物的详细的进化。下列章节描述了该仓库的结构和内容(第[2](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#sec:data)节)、创建方法(第[3](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#sec:dev)节)和该如何使用(第[4](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#sec:use)节)。
### 2、数据概览
这 1GB 的 Unix 历史仓库可以从 [GitHub](https://github.com/dspinellis/unix-history-repo) 上克隆<sup> <a href="http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFtNtAAB"> 1 </a></sup> 。如今<sup> <a href="http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFtNtAAC"> 2 </a></sup> ,这个仓库包含来自 850 个贡献者的 659,000 个提交和 2,306 个合并。贡献者有来自<ruby> 贝尔实验室 <rp> ( </rp> <rt> Bell Labs </rt> <rp> ) </rp></ruby>的 23 个员工,<ruby> 伯克利大学 <rp> ( </rp> <rt> Berkeley University </rt> <rp> ) </rp></ruby>的<ruby> 计算机系统研究组 <rp> ( </rp> <rt> Computer Systems Research Group </rt> <rp> ) </rp></ruby>(CSRG)的 158 个人,和 FreeBSD 项目的 660 个成员。
这个仓库的生命始于一个 *Epoch* 的标签,这里面只包含了证书信息和现在的 README 文件。其后各种各样的标签和分支记录了很多重要的时刻。
* *Research-VX* 标签对应来自<ruby> 贝尔实验室 <rp> ( </rp> <rt> Bell Labs </rt> <rp> ) </rp></ruby>六个研究版本。从 *Research-V1* (4768 行 PDP-11 汇编代码)开始,到以 *Research-V7* (大约 324,000 行代码,1820 个 C 文件)结束。
* *Bell-32V* 是第七个版本 Unix 在 DEC/VAX 架构上的移植。
* *BSD-X* 标签对应<ruby> 伯克利大学 <rp> ( </rp> <rt> Berkeley University </rt> <rp> ) </rp></ruby>释出的 15 个快照。
* *386BSD-X* 标签对应该系统的两个开源版本,主要是 Lynne 和 William Jolitz 写的适用于 Intel 386 架构的内核代码。
* *FreeBSD-release/X* 标签和分支标记了来自 FreeBSD 项目的 116 个发行版。
另外,以 *-Snapshot-Development* 为后缀的分支,表示该提交由来自一个以时间排序的快照文件序列而合成;而以一个 *-VCS-Development* 为后缀的标签,标记了有特定发行版出现的历史分支的时刻。
仓库的历史包含从系统开发早期的一些提交,比如下面这些。
```
commit c9f643f59434f14f774d61ee3856972b8c3905b1
Author: Dennis Ritchie <research!dmr>
Date: Mon Dec 2 18:18:02 1974 -0500
Research V5 development
Work on file usr/sys/dmr/kl.c
```
两个发布之间的合并代表着系统发生了进化,比如 BSD 3 的开发来自 BSD2 和 Unix 32/V,它在 Git 仓库里正是被表示为带两个父节点的图形节点。
更为重要的是,以这种方式构造的仓库允许 **git blame**,就是可以给源代码行加上注释,如版本、日期和它们第一次出现相关联的作者,这样可以知道任何代码的起源。比如说,检出 **BSD-4** 这个标签,并在内核的 *pipe.c* 文件上运行一下 git blame,就会显示出由 Ken Thompson 写于 1974,1975 和 1979年的代码行,和 Bill Joy 写于 1980 年的。这就可以自动(尽管计算上比较费事)检测出任何时刻出现的代码。

*图1:各个重大 Unix 发行版的代码来源*
如[上图](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#fig:provenance)所示,现代版本的 Unix(FreeBSD 9)依然有相当部分的来自 BSD 4.3,BSD 4.3 Net/2 和 BSD 2.0 的代码块。有趣的是,这图片显示有部分代码好像没有保留下来,当时激进地要创造一个脱离于伯克利(386BSD 和 FreeBSD 1.0)所释出代码的开源操作系统。FreeBSD 9 中最古老的代码是一个 18 行的队列,在 C 库里面的 timezone.c 文件里,该文件也可以在第七版的 Unix 文件里找到,同样的名字,时间戳是 1979 年一月十日 - 36 年前。
### 3、数据收集和处理
这个项目的目的是以某种方式巩固从数据方面说明 Unix 的进化,通过将其并入一个现代的版本仓库,帮助人们对系统进化的研究。项目工作包括收录数据,分类并综合到一个单独的 Git 仓库里。

*图2:导入 Unix 快照、仓库及其合并*
项目以三种数据类型为基础(见[图2](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#fig:branches))。首先,早期发布版本的快照,获取自<ruby> <a href="http://www.tuhs.org/archive_sites.html"> Unix 遗产社会归档 </a> <rp> ( </rp> <rt> Unix Heritage Society archive </rt> <rp> ) </rp></ruby><sup> <a href="http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFtNtAAD"> 3 </a></sup> 、包括了 CSRG 全部的源代码归档的 [CD-ROM 镜像](https://www.mckusick.com/csrg/)<sup> <a href="http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFtNtAAE"> 4 </a></sup> , [Oldlinux 网站](http://www.oldlinux.org/Linux.old/distributions/386BSD)<sup> <a href="http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFtNtAAF"> 5 </a></sup> 和 [FreeBSD 归档](http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/)<sup> <a href="http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFtNtAAG"> 6 </a></sup> 。 其次,以前的和现在的仓库,即 CSRG SCCS [[6](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#SCCS)] 仓库,FreeBSD 1 CVS 仓库,和[现代 FreeBSD 开发的 Git 镜像](https://github.com/freebsd/freebsd)<sup> <a href="http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFtNtAAH"> 7 </a></sup> 。前两个都是从和快照相同的来源获得的。
最后,也是最费力的数据源是<ruby> <strong> 初步研究 </strong> <rp> ( </rp> <rt> primary research </rt> <rp> ) </rp></ruby>。释出的快照并没有提供关于它们的源头和每个文件贡献者的信息。因此,这些信息片段需要通过<ruby> 初步研究 <rp> ( </rp> <rt> primary research </rt> <rp> ) </rp></ruby>验证。至于作者信息主要通过作者的自传,研究论文,内部备忘录和旧文档扫描件;通过阅读并且自动处理源代码和帮助页面补充;通过与那个年代的人用电子邮件交流;在 *StackExchange* 网站上贴出疑问;查看文件的位置(在早期的内核版本的源代码,分为 `usr/sys/dmr` 和 `/usr/sys/ken` 两个位置);从研究论文和帮助手册披露的作者找到源代码,从一个又一个的发行版中获取。(有趣的是,第一和第二的<ruby> 研究版 <rp> ( </rp> <rt> Research Edition </rt> <rp> ) </rp></ruby>帮助页面都有一个 “owner” 部分,列出了作者(比如,*Ken*)及对应的系统命令、文件、系统调用或库函数。在第四版中这个部分就没了,而在 BSD 发行版中又浮现了 “Author” 部分。)关于作者信息更为详细地写在了项目的文件中,这些文件被用于匹配源代码文件和它们的作者和对应的提交信息。最后,关于源代码库之间的合并信息是获取自 [NetBSD 项目所维护的 BSD 家族树](http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/share/misc/bsd-family-tree)<sup> <a href="http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFtNtAAI"> 8 </a></sup> 。
作为本项目的一部分而开发的软件和数据文件,现在可以[在线获取](https://github.com/dspinellis/unix-history-make)<sup> <a href="http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFtNtAAJ"> 9 </a></sup> ,并且,如果有合适的网络环境,CPU 和磁盘资源,可以用来从头构建这样一个仓库。关于主要发行版的作者信息,都存储在本项目的 `author-path` 目录下的文件里。它们的内容中带有正则表达式的文件路径后面指出了相符的作者。可以指定多个作者。正则表达式是按线性处理的,所以一个文件末尾的匹配一切的表达式可以指定一个发行版的默认作者。为避免重复,一个以 `.au` 后缀的独立文件专门用于映射作者的<ruby> 识别号 <rp> ( </rp> <rt> identifier </rt> <rp> ) </rp></ruby>和他们的名字及 email。这样一个文件为每个与该系统进化相关的社区都建立了一个:<ruby> 贝尔实验室 <rp> ( </rp> <rt> Bell Labs </rt> <rp> ) </rp></ruby>,<ruby> 伯克利大学 <rp> ( </rp> <rt> Berkeley University </rt> <rp> ) </rp></ruby><ruby></ruby>,386BSD 和 FreeBSD。为了真实性的需要,早期<ruby> 贝尔实验室 <rp> ( </rp> <rt> Bell Labs </rt> <rp> ) </rp></ruby>发行版的 emails 都以 <ruby> UUCP 注释 <rp> ( </rp> <rt> UUCP notation </rt> <rp> ) </rp></ruby>方式列出(例如, `research!ken`)。FreeBSD 作者的识别映射,需要导入早期的 CVS 仓库,通过从如今项目的 Git 仓库里拆解对应的数据构建。总的来说,由 1107 行构成了注释作者信息的文件(828 个规则),并且另有 640 行用于映射作者的识别号到名字。
现在项目的数据源被编码成了一个 168 行的 `Makefile`。它包括下面的步骤。
**Fetching** 从远程站点复制和克隆大约 11GB 的镜像、归档和仓库。
**Tooling** 从 2.9 BSD 中为旧的 PDP-11 归档获取一个归档器,并调整它以在现代的 Unix 版本下编译;编译 4.3 BSD 的 *compress* 程序来解压 386BSD 发行版,这个程序不再是现代 Unix 系统的组成部分了。
**Organizing** 用 *tar* 和 *cpio* 解压缩包;合并第六个研究版的三个目录;用旧的 PDP-11 归档器解压全部一个 BSD 归档;挂载 CD-ROM 镜像,这样可以作为文件系统处理;合并第 8 和 62 的 386BSD 磁盘镜像为两个独立的文件。
**Cleaning** 恢复第一个研究版的内核源代码文件,这个可以通过 OCR 从打印件上得到近似其原始状态的的格式;给第七个研究版的源代码文件打补丁;移除发行后被添加进来的元数据和其他文件,为避免得到错误的时间戳信息;修复毁坏的 SCCS 文件;用一个定制的 Perl 脚本移除指定到多个版本的 CVS 符号、删除与现在冲突的 CVS *Attr* 文件、用 *cvs2svn* 将 CVS 仓库转换为 Git 仓库,以处理早期的 FreeBSD CVS 仓库。
在仓库<ruby> 再现 <rp> ( </rp> <rt> representation </rt> <rp> ) </rp></ruby>中有一个很有意思的部分就是,如何导入那些快照,并以一种方式联系起来,使得 *git blame* 可以发挥它的魔力。快照导入到仓库是基于每个文件的时间戳作为一系列的提交实现的。当所有文件导入后,就被用对应发行版的名字给标记了。然后,可以删除那些文件,并开始导入下一个快照。注意 *git blame* 命令是通过回溯一个仓库的历史来工作的,并使用<ruby> 启发法 <rp> ( </rp> <rt> heuristics </rt> <rp> ) </rp></ruby>来检测文件之间或文件内的代码移动和复制。因此,删除掉的快照间会产生中断,以防止它们之间的代码被追踪。
相反,在下一个快照导入之前,之前快照的所有文件都被移动到了一个隐藏的后备目录里,叫做 `.ref`(引用)。它们保存在那,直到下个快照的所有文件都被导入了,这时候它们就会被删掉。因为 `.ref` 目录下的每个文件都精确对应一个原始文件,*git blame* 可以知道多少源代码通过 `.ref` 文件从一个版本移到了下一个,而不用显示出 `.ref` 文件。为了更进一步帮助检测代码起源,同时增加<ruby> 再现 <rp> ( </rp> <rt> representation </rt> <rp> ) </rp></ruby>的真实性,每个发行版都被<ruby> 再现 <rp> ( </rp> <rt> represented </rt> <rp> ) </rp></ruby>为一个有增量文件的分支(*-Development*)与之前发行版之间的合并。
上世纪 80 年代时期,只有<ruby> 伯克利大学 <rp> ( </rp> <rt> Berkeley University </rt> <rp> ) </rp></ruby>开发的文件的一个子集是用 SCCS 版本控制的。在那个期间,我们的统一仓库里包含了来自 SCCS 的提交和快照的增量文件的导入数据。对于每个发行版,可用最近的时间戳找到该 SCCS 提交,并被标记为一个与发行版增量导入分支的合并。这些合并可以在[图2](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#fig:branches) 的中间看到。
将各种数据资源综合到一个仓库的工作,主要是用两个脚本来完成的。一个 780 行的 Perl 脚本(`import-dir.pl`)可以从一个单独的数据源(快照目录、SCCS 仓库,或者 Git 仓库)中,以 *Git fast export* 格式导出(真实的或者综合的)提交历史。输出是一个简单的文本格式,Git 工具用这个来导入和导出提交。其他方面,这个脚本以一些东西为参数,如文件到贡献者的映射、贡献者登录名和他们的全名间的映射、哪个导入的提交会被合并、哪些文件要处理和忽略、以及“引用”文件的处理。一个 450 行的 Shell 脚本创建 Git 仓库,并调用带适当参数的 Perl 脚本,来导入 27 个可用的历史数据资源。Shell 脚本也会运行 30 个测试,比较特定标签的仓库和对应的数据源,核对查看的目录中出现的和没出现的,并回溯查看分支树和合并的数量,*git blame* 和 *git log* 的输出。最后,调用 *git* 作垃圾收集和仓库压缩,从最初的 6GB 降到分发的 1GB 大小。
### 4、数据使用
该数据可以用于软件工程、信息系统和<ruby> 软件考古学 <rp> ( </rp> <rt> software archeology </rt> <rp> ) </rp></ruby>领域的经验性研究。鉴于它从不间断而独一无二的存在了超过了 40 年,可以供软件进化和跨代更迭参考。从那时以来,处理速度已经成千倍地增长、存储容量扩大了百万倍,该数据同样可以用于软件和硬件技术<ruby> 交叉进化 <rp> ( </rp> <rt> co-evolution </rt> <rp> ) </rp></ruby>的研究。软件开发从研究中心到大学,到开源社区的转移,可以用来研究组织文化对于软件开发的影响。该仓库也可以用于学习著名人物的实际编程,比如 Turing 奖获得者(Dennis Ritchie 和 Ken Thompson)和 IT 产业的大佬(Bill Joy 和 Eric Schmidt)。另一个值得学习的现象是代码的长寿,无论是单行的水平,或是作为那个时代随 Unix 发布的完整的系统(Ingres、 Lisp、 Pascal、 Ratfor、 Snobol、 TMP),和导致代码存活或消亡的因素。最后,因为该数据让 Git 感到了压力,底层的软件仓库存储技术达到了其极限,这会推动版本管理系统领域的工程进度。

*图3:Unix 发行版的代码风格进化*
[图3](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#fig:metrics) 根据 36 个主要 Unix 发行版描述了一些有趣的代码统计的趋势线(用 R 语言的局部多项式回归拟合函数生成),验证了代码风格和编程语言的使用在很长的时间尺度上的进化。这种进化是软硬件技术的需求和支持、软件构筑理论,甚至社会力量所驱动的。图片中的日期计算了出现在一个给定发行版中的所有文件的平均日期。正如可以从中看到,在过去的 40 年中,标示符和文件名字的长度已经稳步从 4 到 6 个字符增长到 7 到 11 个字符。我们也可以看到注释数量的少量稳步增加,以及 *goto* 语句的使用量减少,同时 *register* 这个类型修饰符的消失。
### 5、未来的工作
可以做很多事情去提高仓库的正确性和有效性。创建过程以开源代码共享了,通过 GitHub 的<ruby> 拉取请求 <rp> ( </rp> <rt> pull request </rt> <rp> ) </rp></ruby>,可以很容易地贡献更多代码和修复。最有用的社区贡献将使得导入的快照文件的覆盖面增长,以便归属于某个具体的作者。现在,大约 90,000 个文件(在 160,000 总量之外)通过默认规则指定了作者。类似地,大约有 250 个作者(最初 FreeBSD 那些)仅知道其识别号。两个都列在了 build 仓库的 unmatched 目录里,欢迎贡献数据。进一步,BSD SCCS 和 FreeBSD CVS 的提交共享相同的作者和时间戳,这些可以结合成一个单独的 Git 提交。导入 SCCS 文件提交的支持会被添加进来,以便引入仓库对应的元数据。最后,也是最重要的,开源系统的更多分支会添加进来,比如 NetBSD、 OpenBSD、DragonFlyBSD 和 *illumos*。理想情况下,其他历史上重要的 Unix 发行版,如 System III、System V、 NeXTSTEP 和 SunOS 等的当前版权拥有者,也会在一个允许他们的合作伙伴使用仓库用于研究的协议下释出他们的系统。
### 鸣谢
本文作者感谢很多付出努力的人们。 Brian W. Kernighan, Doug McIlroy 和 Arnold D. Robbins 在贝尔实验室(Bell Labs)的登录识别号方面提供了帮助。 Clem Cole, Era Erikson, Mary Ann Horton, Kirk McKusick, Jeremy C. Reed, Ingo Schwarze 和 Anatole Shaw 在 BSD 的登录识别号方面提供了帮助。BSD SCCS 的导入代码是基于 H. Merijn Brand 和 Jonathan Gray 的工作。
这次研究由欧盟 ( <ruby> 欧洲社会基金 <rp> ( </rp> <rt> European Social Fund,ESF </rt> <rp> ) </rp></ruby>) 和 <ruby> 希腊国家基金 <rp> ( </rp> <rt> Greek national funds </rt> <rp> ) </rp></ruby>通过<ruby> 国家战略参考框架 <rp> ( </rp> <rt> National Strategic Reference Framework ,NSRF </rt> <rp> ) </rp></ruby>的 Operational Program " Education and Lifelong Learning" - Research Funding Program: Thalis - Athens University of Economics and Business - Software Engineering Research Platform ,共同出资赞助。
### 引用
[1](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#MPT78) M. D. McIlroy, E. N. Pinson, and B. A. Tague, "UNIX time-sharing system: Foreword," *The Bell System Technical Journal*, vol. 57, no. 6, pp. 1899-1904, July-August 1978.
[2](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#RT78) D. M. Ritchie and K. Thompson, "The UNIX time-sharing system," *Bell System Technical Journal*, vol. 57, no. 6, pp. 1905-1929, July-August 1978.
[3](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#Rit84) D. M. Ritchie, "The evolution of the UNIX time-sharing system," *AT&T Bell Laboratories Technical Journal*, vol. 63, no. 8, pp. 1577-1593, Oct. 1984.
[4](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#Sal94) P. H. Salus, *A Quarter Century of UNIX*. Boston, MA: Addison-Wesley, 1994.
[5](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#Ray03) E. S. Raymond, *The Art of Unix Programming*. Addison-Wesley, 2003.
[6](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#sec:data) M. J. Rochkind, "The source code control system," *IEEE Transactions on Software Engineering*, vol. SE-1, no. 4, pp. 255-265, 1975.
### 脚注
[1](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFrefAAB) - <https://github.com/dspinellis/unix-history-repo>
[2](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFrefAAC) - Updates may add or modify material. To ensure replicability the repository's users are encouraged to fork it or archive it.
[3](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFrefAAD) - <http://www.tuhs.org/archive_sites.html>
[4](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFrefAAE) - <https://www.mckusick.com/csrg/>
[5](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFrefAAF) - <http://www.oldlinux.org/Linux.old/distributions/386BSD>
[6](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFrefAAG) - <http://ftp-archive.freebsd.org/pub/FreeBSD-Archive/old-releases/>
[7](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFrefAAH) - <https://github.com/freebsd/freebsd>
[8](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFrefAAI) - <http://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/share/misc/bsd-family-tree>
[9](http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html#tthFrefAAJ) - <https://github.com/dspinellis/unix-history-make>
---
via: <http://www.dmst.aueb.gr/dds/pubs/conf/2015-MSR-Unix-History/html/Spi15c.html>
作者:Diomidis Spinellis译者:[wi-cuckoo](https://github.com/wi-cuckoo) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,784 | Canonical:全球 Ubuntu 用户可能超过了10亿 | http://news.softpedia.com/news/there-are-probably-more-than-1-billion-ubuntu-users-canonical-lead-explains-498035.shtml | 2015-12-24T10:47:33 | [
"Ubuntu"
] | https://linux.cn/article-6784-1.html |
>
> 可能很多人并不知道自己在使用 Ubuntu。
>
>
>
Ubuntu 项目的高层领导之一 Dustin Kirkland 在一封冗长而全面的公开信中向社区披露,使用 Ubuntu 的人可能已经超过了10 亿人。
之前来自 [Phoronix](https://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-No-200-Million-Users) 的一篇[报道](/article-6773-1.html)称,看起来 Canonical 在 2015 年底前完成不了其拥有 2 亿用户的目标。Dustin 收集汇总了所有他能找到的数据,然后发现,原来世界上很多人已经在使用 Ubuntu 了,无论自愿与否。
这个 2 亿用户的目标源于 4 年前 Canonical 的 Mark Shuttleworth 的一次[演讲](http://www.phoronix.com/scan.php?page=news_item&px=2015-200-Million-Goal-Retro),他当时预计到 2015 年 Ubuntu 会有 2 亿用户。Mark Shuttleworth 所指的应该是安装了 Ubuntu 操作系统的个人计算机和笔记本电脑,不过当今 IT 界的格局已经和以前大大不同了。
问题是,并没有一个明确的方式可以统计有多少人使用了 Ubuntu。如 Dustin 所说,Canonical 并不要求用户注册,所以他们也只能估计。虽然,他们可以统计下有多少人连接到他们官方的软件源来下载更新,这是一个粗略的估计,然而该公司并不需要这样的数据。
### 可能超过了 10 亿用户

Dustin Kirkland 在 Canonical 负责相当重要的工作,他领导 Canonical 的 Ubuntu 产品与战略团队,直接汇报给 Mark Shuttleworth,负责技术战略、路线图、Ubuntu Cloud 和物联网商业产品的生命周期等等。所以,他说的应该有一定道理。
Dustin [解释说](http://blog.dustinkirkland.com/2015/12/more-people-use-ubuntu-than-anyone.html):“没有人可以统计世界上所有的 Ubuntu 用户。Canonical 不像苹果、微软或谷歌,并不要求每个用户注册其 安装的 Ubuntu。当然,你可以从戴尔、惠普、联想和华硕买预装了 Ubuntu 的笔记本电脑,除此之外还有几百万其它的产品。而且你还可以从 IBM、戴尔、惠普、思科、联想、Quanta 购买安装了 Ubuntu 的服务器,以及 OpenCompute 项目的兼容产品。”
他收集了所有他能找到公开数据,包括服务器、云上部署的 Ubuntu、Ubuntu Phone 和各大公司对 Ubuntu 的应用,结果发现有超过 10 亿人在使用 Ubuntu,虽然其中绝大多数都并没有察觉到这一点。
[让我们来看看这些事实](http://blog.dustinkirkland.com/2015/12/more-people-use-ubuntu-than-anyone.html):
* Docker 用户运行 Ubuntu 镜像超过 [355,000,000 次](https://hub.docker.com/search/?q=ubuntu&page=1&isAutomated=0&isOfficial=0&starCount=0&pullCount=0)。
* HashiCorp 的 Ubuntu 14.04 LTS 64-bit Vagrant 镜像下载超过 [10,000,000 次](https://atlas.hashicorp.com/boxes/search?utm_source=vagrantcloud.com&vagrantcloud=1)。
* 在 2015 年,在公有云、私有云和硬件服务器上至少启动了 20,000,000 个 Ubuntu 独立实例。
+ Ubuntu 运行在如 AWS、 Microsoft Azure、 Google Compute Engine、 Rackspace、 Oracle Cloud、 VMware 以及[其它](http://partners.ubuntu.com/programmes/public-cloud)的公有云上。
+ Ubuntu 也运行在类似 [OpenStack](https://insights.ubuntu.com/2015/10/28/news-from-the-summit-ubuntu-extends-lead-in-openstack/) 这样的私有云上。
- 其中包括 Deutsche Telekom 这样的世界上[最大的私有云](https://www.openstack.org/assets/survey/Public-User-Survey-Report.pdf)。
+ Ubuntu 也部署在 MAAS 的硬件上,通常由 [Chef 进行管理](https://insights.ubuntu.com/2015/04/14/chef-an-automation-story-with-a-bare-metal-soundtrack/)。
* 事实上,在 2015 年 11 月,就新启动了超过 2 亿的 Ubuntu Cloud 实例。
+ 每天新启动 67,000 个 Ubuntu Cloud 实例。
+ 每小时新启动 2,800 个 Ubuntu Cloud 实例。
+ 每分钟新启动 46 个 Ubuntu Cloud 实例。
+ 在 2015 年 11 月的每一天,接近每秒钟新启动一个 Ubuntu Cloud 实例。
* 还有来自[魅族](http://www.meizu.com/en/ubuntu/features.html)的 Ubuntu phone。
* 以及来自 [BQ](https://store.bq.com/en/ubuntu-edition-e5/) 的 Ubuntu phone。
* 当然,谁都可以在 Google Nexus 平板/电话上[安装](https://wiki.ubuntu.com/Touch/Install) Ubuntu。
* 噢,还有[特斯拉娱乐系统](http://www.autoblog.com/2014/04/12/tesla-model-s-owners-hack-their-cars-find-ubuntu/)?它也是 Ubuntu 充能的。
* [谷歌的无人驾驶汽车](https://www.linux.com/news/embedded-mobile/mobile-linux/737295-linux-leads-self-driving-car-movement)?它们也是由 Ubuntu 无人驾驶的。
* George Hotz 自己造的自驾汽车? [那是一个自制的 Ubuntu 自动驾驶仪](http://www.bloomberg.com/features/2015-george-hotz-self-driving-car/)。
* 下载用于树莓派和 Beagle Bone Blacks 的 [Snappy Ubuntu](https://developer.ubuntu.com/en/snappy/start/raspberry-pi-2/) ——影响巨大,下载量超高。
* 无人机、机器人、网络交换机、智能设备和物联网, [到处都是 Snappy Ubuntu](http://www.ubuntu.com/internet-of-things)。
* 在沃尔玛呢?天天促销,天天 Ubuntu, [越来越多的 Ubuntu](http://www.zdnet.com/article/walmart-relies-on-openstack/)。
* 正在准备用 [Kubernetes](https://github.com/kubernetes/kubernetes/blob/master/docs/getting-started-guides/ubuntu.md) 或 Apache [Mesos](http://mesos.apache.org/gettingstarted/) 搭建容器环境?那里是 Ubuntu 乐园。
* 想用 Cloud Foundry 搞个 PaaS? 应用实例是 [Ubuntu LXC 容器](https://bosh.cloudfoundry.org/docs/stemcell.html)。而 Pivotal 已经有了许多[重要客户](http://pivotal.io/customers)。
* Heroku 呢?我敢打赌承载你的应用的容器[是 Ubuntu](https://devcenter.heroku.com/articles/stack),也有 [重量级客户](https://www.heroku.com/customers)。
* 世界上最大的超级计算机天河 2,多达 80,000 个 Xeon 处理器、 1.4 TB 内存、 12.4 PB 硬盘,全都是[运行在 Ubuntu](https://www.linux.com/news/enterprise/high-performance/147-high-performance/840542-tianhe-2-most-powerful-supercomputer-in-the-world-runs-ubuntu) 上的。
* 甚至在 Netflix 看影片?也是[由 Ubuntu 提供服务的](https://insights.ubuntu.com/2015/08/11/how-netflix-tunes-ubuntu-on-ec2/)。
* 约过 Uber 或 Lyft 吗?你的手机应用与之通讯的是 [后端的 Ubuntu 服务器](https://careers-uber.icims.com/jobs/16178/production-engineer---infrastructure/job)。
* 喜欢看《霍比特人》、《饥饿游戏》、《复仇者》、《阿凡达》吗? [全是由 WETA Digital 的 Ubuntu 渲染的](http://blog.dustinkirkland.com/2010/01/39000-core-ubuntu-cluster-renders.html)。还有[很多](https://www.wetafx.co.nz/features)。
* 使用 Instagram 吗? 耶!
* 在华尔街做交易吗? [Ubuntu 为彭博提供了重要服务](http://www.canonical.com/services)。
* Paypal、Dropbox、Snapchat、[Pinterest](https://engineering.pinterest.com/blog/building-pinterest-cloud)、[Reddit](http://www.redditblog.com/2012/01/january-2012-state-of-servers.html),这些都在用 Ubuntu。
* 维基百科和维基媒体是互联网是最繁忙的站点之一, [每个月有 80 到 180 亿 PV](https://stats.wikimedia.org/EN/TablesPageViewsMonthly.htm),也是[放在 Ubuntu 上的](https://meta.wikimedia.org/wiki/Wikimedia_servers)。
| 301 | Moved Permanently | null |
6,786 | CentOS AltArch 7发布,支持 PPC64、PPC8LE、ARMhfp、i686 和 AArch64 | http://news.softpedia.com/news/centos-altarch-7-now-available-for-aarch64-powerpc64-powerpc8-le-and-armhfp-497950.shtml | 2015-12-25T08:51:00 | [
"CentOS"
] | https://linux.cn/article-6786-1.html | 在前几天的一则 [CentOS 7 ARM 版正式发布:支持树莓派2/香蕉派/CubieTruck](/article-6772-1.html "CentOS 7 ARM 版正式发布:支持树莓派2/香蕉派/CubieTruck") 的简短消息之后,Karanbir Singh 正式宣布了 CentOS AltArch 7 的发布。
据[发行公告](https://lists.centos.org/pipermail/centos-announce/2015-December/021556.html),CentOS AltArch 7 基于最近发布的 CentOS 7 (1511) 滚动更新版,在该版本中包括了大量新功能,如 X.Org 服务器 1.17、以及在预装的应用中支持 TLS 1.1、TLS 1.2 和 EC 加密算法等。
此外,CentOS 7 (1511) 也完全支持了 virt-v2v 命令行工具,带有 KDE 4.14 和 GNOME 3.14 桌面环境、 LibreOffice 4.3.7 办公套件、支持 tcpdump 中的纳秒级时间戳,以及 OpenLDAP 2.4.40 等。
“CentOS AltArch 7 已经可以下载了,” Karanbir Singh 在[发布公告](https://lists.centos.org/pipermail/centos-announce/2015-December/021556.html)中说,“预计支持 Aarch64 的 CentOS AltArch 7 (1511)过几天就发布,到时候会单独宣布”。

### 支持 PPC64、PPC8LE、ARMhfp、AArch64、64位和32位
CentOS AltArch 7 操作系统支持多种硬件架构,它们是: CentOS AltArch 7 (1511) for i686 (32-bit)、 CentOS AltArch UserLand 7 (1511) for Armhfp、CentOS AltArch 7 (1511) for PowerPC64、 CentOS AltArch 7 (1511) for PowerPC8 LE 和 CentOS AltArch 7 (1511) for AArch64。
注意,PowerPC8 LE 和 PowerPC64 (PPC64) 版本目前只有技术预览版,不要用在生产环境中。
你可以从下面地址下载到:
* [CentOS AltArch 7 (1511) for i686](http://mirror.centos.org/altarch/7.2.1511/isos/i386/)
* [CentOS AltArch UserLand 7 (1511) for Armhfp](http://mirror.centos.org/altarch/7.2.1511/isos/armhfp/)
* [CentOS AltArch 7 (1511) for PowerPC64 (TechPreview)](http://mirror.centos.org/altarch/7.2.1511/isos/ppc64/)
* [CentOS AltArch 7 (1511) for PowerPC8 LE (TechPreview)](http://mirror.centos.org/altarch/7.2.1511/isos/ppc64le/)
请随时关注进一步的消息。
| 301 | Moved Permanently | null |
6,793 | 在 Debian Linux 上安装配置 ISC DHCP 服务器 | http://www.tecmint.com/install-and-configure-multihomed-isc-dhcp-server-on-debian-linux/ | 2015-12-25T13:29:00 | [
"dhcp"
] | https://linux.cn/article-6793-1.html | <ruby> 动态主机控制协议 <rp> ( </rp> <rt> Dynamic Host Control Protocol </rt> <rp> ) </rp></ruby>(DHCP)给网络管理员提供了一种便捷的方式,为不断变化的网络主机或是动态网络提供网络层地址。其中最常用的 DHCP 服务工具是 ISC DHCP Server。DHCP 服务的目的是给主机提供必要的网络信息以便能够和其他连接在网络中的主机互相通信。DHCP 服务提供的信息包括:DNS 服务器信息,网络地址(IP),子网掩码,默认网关信息,主机名等等。

本教程介绍运行在 Debian 7.7 上 4.2.4 版的 ISC-DHCP-Server 如何管理多个虚拟局域网(VLAN),也可以非常容易应用到单一网络上。
测试用的网络是通过思科路由器使用传统的方式来管理 DHCP 租约地址的。目前有 12 个 VLAN 需要通过集中式服务器来管理。把 DHCP 的任务转移到一个专用的服务器上,路由器可以收回相应的资源,把资源用到更重要的任务上,比如路由寻址,访问控制列表,流量监测以及网络地址转换等。
另一个将 DHCP 服务转移到专用服务器的好处,以后会讲到,它可以建立动态域名服务器(DDNS),这样当主机从服务器请求 DHCP 地址的时候,这样新主机的主机名就会被添加到 DNS 系统里面。
### 安装和配置 ISC DHCP 服务器
1、使用 apt 工具用来安装 Debian 软件仓库中的 ISC 软件,来创建这个多宿主服务器。与其他教程一样需要使用 root 或者 sudo 访问权限。请适当的修改,以便使用下面的命令。(LCTT 译注:下面中括号里面是注释,使用的时候请删除,#表示使用的 root 权限)
```
# apt-get install isc-dhcp-server [安装 the ISC DHCP Server 软件]
# dpkg --get-selections isc-dhcp-server [确认软件已经成功安装]
# dpkg -s isc-dhcp-server [用另一种方式确认成功安装]
```

2、 确认服务软件已经安装完成,现在需要提供网络信息来配置服务器,这样服务器才能够根据我们的需要来分发网络信息。作为管理员最起码需要了解的 DHCP 信息如下:
* 网络地址
* 子网掩码
* 动态分配的地址范围
其他一些服务器动态分配的有用信息包括:
* 默认网关
* DNS 服务器 IP 地址
* 域名
* 主机名
* 网络广播地址
这只是能让 ISC DHCP 服务器处理的选项中非常少的一部分。如果你想查看所有选项及其描述需要在安装好软件后输入以下命令:
```
# man dhcpd.conf
```
3、 一旦管理员已经确定了这台服务器分发的所有必要信息,那么是时候配置服务器并且分配必要的地址池了。在配置任何地址池或服务器配置之前,必须配置 DHCP 服务器侦听这台服务器上面的一个接口。
在这台特定的服务器上,设置好网卡后,DHCP 会侦听名称名为`'bond0'`的接口。请适根据你的实际情况来更改服务器以及网络环境。下面的配置都是针对本教程的。

这行指定的是 DHCP 服务侦听接口(一个或多个)上的 DHCP 流量。修改主配置文件,分配适合的 DHCP 地址池到所需要的网络上。主配置文件在 /etc/dhcp/dhcpd.conf。用文本编辑器打开这个文件
```
# nano /etc/dhcp/dhcpd.conf
```
这个配置文件可以配置我们所需要的地址池/主机。文件顶部有 ‘ddns-update-style‘ 这样一句,在本教程中它设置为 ‘none‘。在以后的教程中会讲到动态 DNS,ISC-DHCP-Server 将会与 BIND9 集成,它能够使主机名更新指向到 IP 地址。
4、 接下来的部分是管理员配置全局网络设置,如 DNS 域名,默认的租约时间,IP地址,子网的掩码,以及其它。如果你想了解所有的选项,请阅读 man 手册中的 dhcpd.conf 文件,命令如下:
```
# man dhcpd.conf
```
对于这台服务器,我们需要在配置文件顶部配置一些全局网络设置,这样就不用到每个地址池中去单独设置了。

我们花一点时间来解释一下这些选项,在本教程中虽然它们是一些全局设置,但是也可以单独的为某一个地址池进行配置。
* option domain-name “comptech.local”; – 所有使用这台 DHCP 服务器的主机,都将成为 DNS 域 “comptech.local” 的一员
* option domain-name-servers 172.27.10.6; DHCP 向所有配置这台 DHCP 服务器的的网络主机分发 DNS 服务器地址为 172.27.10.6
* option subnet-mask 255.255.255.0; – 每个网络设备都分配子网掩码 255.255.255.0 或 /24
* default-lease-time 3600; – 默认有效的地址租约时间(单位是秒)。如果租约时间耗尽,那么主机可以重新申请租约。如果租约完成,那么相应的地址也将被尽快回收。
* max-lease-time 86400; – 这是一台主机所能租用的最大的租约时间(单位为秒)。
* ping-check true; – 这是一个额外的测试,以确保服务器分发出的网络地址不是当前网络中另一台主机已使用的网络地址。
* ping-timeout; – 在判断地址以前没有使用过前,服务器将等待 ping 响应多少秒。
* ignore client-updates; 现在这个选项是可以忽略的,因为 DDNS 在前面已在配置文件中已经被禁用,但是当 DDNS 运行时,这个选项会忽略主机更新其 DNS 主机名的请求。
5、 文件中下面一行是权威 DHCP 所在行。这行的意义是如果服务器是为文件中所配置的网络分发地址的服务器,那么取消对该<ruby> 权威关键字 <rp> ( </rp> <rt> authoritative stanza </rt> <rp> ) </rp></ruby>的注释。
通过去掉关键字 authoritative 前面的 ‘#’,取消注释全局权威关键字。这台服务器将是它所管理网络里面的唯一权威。

默认情况下服务器被假定为**不是**网络上的权威服务器。之所以这样做是出于安全考虑。如果有人因为不了解 DHCP 服务的配置,导致配置不当或配置到一个不该出现的网络里面,这都将带来非常严重的连接问题。这行还可用在每个网络中单独配置使用。也就是说如果这台服务器不是整个网络的 DHCP 服务器,authoritative 行可以用在每个单独的网络中,而不是像上面截图中那样的全局配置。
6、 这一步是配置服务器将要管理的所有 DHCP 地址池/网络。简短起见,本教程只讲到配置的地址池之一。作为管理员需要收集一些必要的网络信息(比如域名,网络地址,有多少地址能够被分发等等)
以下这个地址池所用到的信息都是管理员收集整理的:网络 ID 172.27.60.0, 子网掩码 255.255.255.0 或 /24, 默认子网网关 172.27.60.1,广播地址 172.27.60.255.0 。
以上这些信息对于构建 dhcpd.conf 文件中新网络非常重要。使用文本编辑器修改配置文件添加新网络进去,这里我们需要使用 root 或 sudo 访问权限。
```
# nano /etc/dhcp/dhcpd.conf
```

当前这个例子是给用 VMWare 创建的虚拟服务器分配 IP 地址。第一行显示是该网络的子网掩码。括号里面的内容是 DHCP 服务器应该提供给网络上面主机的所有选项。
第一行, range 172.27.60.50 172.27.60.254; 这一行显示的是,DHCP 服务在这个网络上能够给主机动态分发的地址范围。
第二行,option routers 172.27.60.1; 这里显示的是给网络里面所有的主机分发的默认网关地址。
最后一行, option broadcast-address 172.27.60.255; 显示当前网络的广播地址。这个地址不能被包含在要分发放的地址范围内,因为广播地址不能分配到一个主机上面。
必须要强调的是每行的结尾必须要用(;)来结束,所有创建的网络必须要在 {} 里面。
7、 如果要创建多个网络,继续创建完它们的相应选项后保存文本文件即可。配置完成以后如果有更改,ISC-DHCP-Server 进程需要重启来使新的更改生效。重启进程可以通过下面的命令来完成:
```
# service isc-dhcp-server restart
```
这条命令将重启 DHCP 服务,管理员能够使用几种不同的方式来检查服务器是否已经可以处理 dhcp 请求。最简单的方法是通过 [lsof 命令](http://www.tecmint.com/10-lsof-command-examples-in-linux/)来查看服务器是否在侦听67端口,命令如下:
```
# lsof -i :67
```

这里输出的结果表明 dhcpd(DHCP 服务守护进程)正在运行并且侦听67端口。由于在 /etc/services 文件中67端口的映射,所以输出中的67端口实际上被转换成了 “bootps”。
在大多数的系统中这是非常常见的,现在服务器应该已经为网络连接做好准备,我们可以将一台主机接入网络请求DHCP地址来验证服务是否正常。
### 测试客户端连接
8、 现在许多系统使用网络管理器来维护网络连接状态,因此这个设备应该预先配置好的,只要对应的接口处于活跃状态就能够获取 DHCP。
然而当一台设备无法使用网络管理器时,它可能需要手动获取 DHCP 地址。下面的几步将演示怎样手动获取以及如何查看服务器是否已经按需要分发地址。
‘[ifconfig](http://www.tecmint.com/ifconfig-command-examples/)‘工具能够用来检查接口的配置。这台被用来测试的 DHCP 服务器的设备,它只有一个网络适配器(网卡),这块网卡被命名为 ‘eth0‘。
```
# ifconfig eth0
```

从输出结果上看,这台设备目前没有 IPv4 地址,这样很便于测试。我们把这台设备连接到 DHCP 服务器并发出一个请求。这台设备上已经安装了一个名为 ‘dhclient‘ 的DHCP客户端工具。因为操作系统各不相同,所以这个客户端软件也是互不一样的。
```
# dhclient eth0
```

当前 `'inet addr:'` 字段中显示了属于 172.27.60.0 网络地址范围内的 IPv4 地址。值得欣慰的是当前网络还配置了正确的子网掩码并且分发了广播地址。
到这里看起来还都不错,让我们来测试一下,看看这台设备收到新 IP 地址是不是由服务器发出的。这里我们参照服务器的日志文件来完成这个任务。虽然这个日志的内容有几十万条,但是里面只有几条是用来确定服务器是否正常工作的。这里我们使用一个工具 ‘tail’,它只显示日志文件的最后几行,这样我们就可以不用拿一个文本编辑器去查看所有的日志文件了。命令如下:
```
# tail /var/log/syslog
```

OK!服务器记录表明它分发了一个地址给这台主机 (HRTDEBXENSRV)。服务器按预期运行,给它充当权威服务器的网络分发了适合的网络地址。至此 DHCP 服务器搭建成功并且运行。如果有需要你可以继续配置其他的网络,排查故障,确保安全。
在以后的Debian教程中我会讲一些新的 ISC-DHCP-Server 功能。有时间的话我将写一篇关于 Bind9 和 DDNS 的教程,融入到这篇文章里面。
---
via: <http://www.tecmint.com/install-and-configure-multihomed-isc-dhcp-server-on-debian-linux/>
作者:[Rob Turner](http://www.tecmint.com/author/robturner/) 译者:[ivo-wang](https://github.com/ivo-wang) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,794 | Linux/Unix 桌面趣事:让桌面下雪 | http://www.cyberciti.biz/tips/linux-unix-xsnow.html | 2015-12-25T14:48:00 | [
"xsnow"
] | https://linux.cn/article-6794-1.html | 在这个节日里感到孤独么?试一下 Xsnow 吧。它是一个可以在 Unix/Linux 桌面下下雪的应用。圣诞老人和他的驯鹿会在屏幕中奔跑,伴随着雪片让你感受到节日的感觉。
我第一次安装它还是在 13、4 年前。它最初是在 1984 年 Macintosh 系统中创造的。你可以用下面的方法来安装:
### 安装 xsnow
Debian/Ubuntu/Mint 用户用下面的命令:
```
$ sudo apt-get install xsnow
```
Freebsd 用户输入下面的命令:
```
# cd /usr/ports/x11/xsnow/
# make install clean
```
或者尝试添加包:
```
# pkg_add -r xsnow
```
#### 其他发行版的方法
1. Fedora/RHEL/CentOS 在 [rpmfusion](http://rpmfusion.org/Configuration) 仓库中找找。
2. Gentoo 用户试下 Gentoo portage,也就是[emerge -p xsnow](http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=1)
3. Opensuse 用户使用 yast 搜索 xsnow
### 我该如何使用 xsnow?
打开终端(程序 > 附件 > 终端),输入下面的额命令启动 xsnow:
```
$ xsnow
```
示例输出:

*图01: 在 Linux 和 Unix 桌面中显示雪花*
你可以设置背景为蓝色,并让它下白雪,输入:
```
$ xsnow -bg blue -sc snow
```
设置最大的雪片数量,并让它尽可能快地掉下,输入:
```
$ xsnow -snowflakes 10000 -delay 0
```
不要显示圣诞树和圣诞老人满屏幕地跑,输入:
```
$ xsnow -notrees -nosanta
```
关于 xsnow 更多的信息和选项,在命令行下输入 man xsnow 查看手册:
```
$ man xsnow
```
建议阅读
* 官网[下载 Xsnow](http://rpmfusion.org/Configuration)
* 注意 [MS-Windows](http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=1) 和 [Mac OS X](http://dropmix.xs4all.nl/rick/Xsnow/) 版本有一次性的共享软件费用。
---
via: <http://www.cyberciti.biz/tips/linux-unix-xsnow.html>
作者:Vivek Gite 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,795 | Linux/Unix 桌面趣事:蒸汽火车 | http://www.cyberciti.biz/tips/displays-animations-when-accidentally-you-type-sl-instead-of-ls.html | 2015-12-28T09:57:00 | [
"sl"
] | https://linux.cn/article-6795-1.html | 你是不是[经常](http://www.cyberciti.biz/tips/my-10-unix-command-line-mistakes.html)把 ls 输入成了 sl。我已经设置了[一个别名](http://bash.cyberciti.biz/guide/Create_and_use_aliases),也就是 `alias sl=ls`。但是这样你也许就错过了这辆带汽笛的蒸汽小火车了。
sl 是一个搞笑软件或,也是一个 Unix 游戏。它会在你错误地把“ls”输入成“sl”(Steam Locomotive)后出现一辆蒸汽火车穿过你的屏幕。
### 安装 sl
在 Debian/Ubuntu 下输入下面的命令:
```
# apt-get install sl
```
它同样也在 Freebsd 和其他类Unix的操作系统上存在。
下面,让我们把 ls 输错成 sl:
```
$ sl
```

*图01: 如果你把 “ls” 输入成 “sl” ,蒸汽火车会穿过你的屏幕。*
它同样支持下面的选项:
* **-a** : 似乎发生了意外。你会为那些哭喊求助的人们感到难过。
* **-l** : 显示小一点的火车
* **-F** : 它居然飞走了
* **-e** : 允许被 Ctrl+C 中断
---
via: <http://www.cyberciti.biz/tips/displays-animations-when-accidentally-you-type-sl-instead-of-ls.html>
作者:Vivek Gite 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,796 | Linux/Unix 桌面趣事:ASCII 艺术水族箱 | http://www.cyberciti.biz/tips/linux-unix-apple-osx-terminal-ascii-aquarium.html | 2015-12-30T15:25:00 | [
"ASCIIQuarium"
] | https://linux.cn/article-6796-1.html | 你可以在你的终端中使用 ASCIIQuarium 安全地欣赏海洋的神秘了。它是一个用 perl 写的 ASCII 艺术水族箱/海洋动画。
### 安装 Term::Animation
首先你需要安装名为 Term-Animation 的perl模块。打开终端(选择程序 > 附件 > 终端),并输入:
```
$ sudo apt-get install libcurses-perl
$ cd /tmp
$ wget http://search.cpan.org/CPAN/authors/id/K/KB/KBAUCOM/Term-Animation-2.4.tar.gz
$ tar -zxvf Term-Animation-2.4.tar.gz
$ cd Term-Animation-2.4/
$ perl Makefile.PL && make && make test
$ sudo make install
```
### 下载安装 ASCIIQuarium
接着在终端中输入:
```
$ cd /tmp
$ wget http://www.robobunny.com/projects/asciiquarium/asciiquarium.tar.gz
$ tar -zxvf asciiquarium.tar.gz
$ cd asciiquarium_1.0/
$ sudo cp asciiquarium /usr/local/bin
$ sudo chmod 0755 /usr/local/bin/asciiquarium
```
### 我怎么观赏 ASCII 水族箱?
输入下面的命令:
```
$ /usr/local/bin/asciiquarium
```
或者
```
$ perl /usr/local/bin/asciiquarium
```

*ASCII 水族箱*
### 相关媒体
### 下载:ASCII Aquarium 的 KDE 和 Mac OS X 版本
[点此下载 asciiquarium](http://www.robobunny.com/projects/asciiquarium/html/)。如果你运行的是 Mac OS X,试下这个可以直接使用的已经打包好的[版本](http://habilis.net/macasciiquarium/)。对于 KDE 用户,试试基于 Asciiquarium 的[KDE 屏幕保护程序](http://kde-look.org/content/show.php?content=29207)
---
via: <http://www.cyberciti.biz/tips/linux-unix-apple-osx-terminal-ascii-aquarium.html>
作者:Vivek Gite 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,801 | 真的,Perl 6 发布了!!!——我们已经等了整整十五年! | https://perl6advent.wordpress.com/2015/12/24/an-unexpectedly-long-expected-party/ | 2015-12-26T18:18:00 | [
"Perl",
"Perl 6"
] | https://linux.cn/article-6801-1.html |
>
> **Larry Wall [发布消息](https://twitter.com/TimToady/status/680511168713064448):Perl 6 于 2015 年 12 月 25 日 22:00 GMT 时间发布了!按照承诺,发布了测试套件和编译器。愿上帝保佑我们每个人。**
>
>
>

Hello,听,听,听!注意!——大家请注意了!!!
喔,谢谢大家。
嗨,我是<ruby> 卡梅丽娅 <rp> ( </rp> <rt> Camelia </rt> <rp> ) </rp></ruby>(LCTT 译注:这是 Perl 6 的 logo 的名字),认识我吧(也许不认识呢)。他们告诉我,我需要在 <ruby> Perl 6 官方发布会 <rp> ( </rp> <rt> Perl 6’s official Coming Out Party </rt> <rp> ) </rp></ruby>上作个讲话,所以我就来了。嗯,他们是棋手,而我只是一枚棋子。他们还跟我强调要严肃点,呃,说的好像我知道怎么认真演讲一样,玩真的吗?
好吧好吧,严肃一些,首先我要感谢所有今天“<ruby> 走出来 <rp> ( </rp> <rt> coming out </rt> <rp> ) </rp></ruby>”的人。
呃,我好像说错了什么。呃,抱歉,我不是指“<ruby> 出柜 <rp> ( </rp> <rt> coming out </rt> <rp> ) </rp></ruby>”的那个意思……
但是,感谢您的到来。今天是 Perl 6 的大日子,从现在起,她成年了。或者说快成年了吧。反正,她可以正式上路了。看着吧,全世界!
*[从后排传来了一些听不清的议论]*
(旁白)额,我之前是不是不应该多嘴的?我并不是说她剐坏了那些翼子板什么的。好吧,无论如何,让继续吧。我相信从现在起她会是一个好司机。
不管怎样,我已经对 Perl 6 着迷不已,因为我就是一只<ruby> 蝴蝶 <rp> ( </rp> <rt> butterfly </rt> <rp> ) </rp></ruby>啊(LCTT 译注,Perl 6 的 logo 就是一只蝴蝶,见题图)。我花了很长一段时间才从蝶蛹里<ruby> 走出来 <rp> ( </rp> <rt> coming out </rt> <rp> ) </rp></ruby>。是真正意义上的走出来,走出来,走出来!重要的事情说三遍!
哎呀,又碰到高压线了,哈哈哈。
不管怎么说,请大家对 Perl 6 耐心点。今天,我们宣布她基本上是个大人了,但是你也知道,她毕竟还年轻啊。我们小时候,岁数有多少,我们就多大。青年时期,经历荷尔蒙的变化,我们开始变得动荡。而且一小会就振动一次。所以我们 15 岁时,波动像是能加减 10 年。所以,有时候我们会表现得像 25 岁那么成熟,有时候又会回到 5 岁般无知。
当然,Perl 6 还要更成熟些,这并不是说在她发脾气把我们逼疯时就不爱她了。我的意思是,她就像家人一样。你和家人有时疏远有时亲近,因为你知道,一家人总会慢慢亲近的。
我们和她是一个大家庭,今天聚集一堂。有人说抚养一个孩子需要有一个村庄,但是从来没有这样的孩子,也没有这样的村庄。明天宿醉醒后,有机会的话看看节目单,你会在后面看到一个感恩列表,有超过 800 个人的名字!他们通过相同或者不同方式,积极地为 Perl 6 的发展做出了贡献。当然,有些名字无法一一列出。
我说的不是你,我说的是在座的各位,你们全是伟大的人!不仅仅是家庭里最亲近的成员。这个家庭很久以前就意识到,对于一个不断发展的编程语言来说,一些最有价值的建议都是来自直系成员之外。来自朋友和熟人的要比家里的更多。所以说需要一个村庄。
成熟是一个分形的概念,它可以在不同的尺度上说。你们全是 Perl 6 走向互联网的代表。眼前是一个粗暴的世界,多亏有你们, Perl 6 已经为它做好了一些准备。
当然,她才仅仅 15 岁,有些事她做的很好,她的沟通技巧很棒,如果她不认识你的时候也很守礼。她能够同时做几个对话,她在数学方面很棒,在操作各种对象时也技巧谙熟,她喜欢外语以及那些有趣的字母。
但是她仍然是个孩子,有时候学习一些东西时觉得有点困难。没关系,接下来几年她会越来越快,越来越有效率,她的大脑也会自我进化得像个成年人一样。她会学习很多东西,包括这个世界和她自己。但是我觉得她的个性是改不了的,至少现在看来如此。
这是因为她的个性都是来自你们。你们全都爱着她,现在,她已经准备好把这些爱传递给她未曾谋面的人。
当火箭发射时我们全都会很兴奋!TimToady(LCTT 译注:即 [Larry Wall](https://twitter.com/TimToady))告诉我凌晨起床去看水星、双子座和阿波罗火箭起飞。我年纪太小,记不清那些。不过我们也有我们自己激动人心的事情要关注。我是非常高兴看到 SpaceX 火箭本周回收成功,虽然有点磕磕碰碰……

*SpaceX 火箭发射回收成功*
*[又一些听不清的议论]*
(旁白)抱歉,我没注意到你。我们确实会忽视某些人,不要成为之一。
好吧,幸灾乐祸的人我也很讨厌。
不管怎么说,Perl 6 的发布挺像火箭发射。倒计时的时候会很紧张,当你在想它是发射成功还是爆炸时会情不自禁的屏住呼吸。这就像我们现在的情况,主引擎已经点火,夹具已经放开。看起来非常戏剧性,主要是因为目前看来不会出大娄子。
但是这并不是火箭发射,戏剧性也不是火箭发射所想要的。火箭要的是发射!越来越快,越来越快!无关高度,甚至无关速度,要的是加速度。
*[让我们举杯]*
所以,Perl 6 破茧了,她可以自由飞翔了。因其成长而快乐,因其发现而欢愉,不断加速吧!干杯!
*感谢 @soooogreen 的校对补完。*
| 200 | OK | Hello. Ting, ting, ting. Attention! … ATTENTION!
Thank you.
Hi, I’m Camelia, if you don’t know me. (Or even if you do.) They told me I had to give a speech at Perl 6’s official Coming Out Party. So here I am. Someone else is doing the roast. I’m just the toast. They told me it had to be a serious speech. Ha, like I’d know how to give a serious speech. Seriously?
Well. Seriously, I’d like to thank you all for coming out today.
Oops, I guess that was a pun. Sorry. Well, no, not really…
But thanks for showing up. This is a big day for Perl 6. She is officially of age now. Well, kinda sorta. She has her driver’s license, anyway. Watch out, world!
[inaudible comment from a table in back]
Oh, should I not have mentioned that? I wasn’t really talking about those fender benders she had while… Well, anyway, let’s move on. I’m sure she’ll be a really good driver. From now on.
Anyway, I have a great deal of empathy for Perl 6, because I am a butterfly. I too had to spend Far Too Long as a chrysalis before I had my own coming out. A literal coming out in my case. Hah, a literal coming out FROM my case, I should say!
Er, oops. I did it again, didn’t I.
Anyway, please be patient with Perl 6. Today we declare her to be a relatively competent being, but she is still just a teenager, y’know. When we’re very young, we’re just the age we are, but when we get to be teenagers, and go through all these hormonal changes, well, we start to oscillate. And the swings just get wider for a while. So when you’re 15, the swing is like plus-or-minus 10 years. One day you’ll act like you’re 25, and the next day like you’re 5 again.
So Perl 6 still has some maturing to do, fershure. That doesn’t mean we don’t love her any less on the days she’s throwing tantrums and driving us crazy. It just means, well, I guess it just means she’s family, and you love family through thick and thin. Because you trust family to turn thin back into thick someday.
And we’re all her extended family, gathered here today. They say it takes a village to raise a child. But never has there been such a child, or such a village! When you get a chance to look at your program tomorrow after your hangover wears off, just look at the list of benefactors in back. There are over 800 names of people who actively contributed to the development of Perl 6, one way or another. And undoubtedly there are a few names missing from the list.
You are a great bunch of people. All of you. Not just the closest members of the family. The family realized long ago that some of the most valuable guidance a growing computer language can get comes from outside the immediate family. It comes from friends and acquaintances who can have more perspective than someone who is always close. That’s why it takes a village.
Maturity is a fractal entity, and operates on many different scales. You all have been a proxy for the wide, wide world that Perl 6 is going out into. And it’s a rough world out there. Perl 6 is ready for some of it, thanks to you.
Of course, she’s still just 15. She does some things really well now. Her communication skills are pretty good, and she is very polite when she can’t understand you. She can carry on several conversations at once. She’s getting pretty good at math, and shows skill in manipulating objects of various sorts. She loves foreign languages, and all those funny characters.
But she’s still a deliberate child, and sometimes seems to be thinking too hard when learning something. That’s okay. She’ll get faster and more efficient over the next several years, as her brain rewires itself into full adulthood. She’ll learn new things, about the world and about herself. But I don’t think her personality will change much, that’s pretty obvious by now.
And that’s because her personality really comes from all of you. You’ve all loved her into existence, and now she’s ready to pass that love on to others who haven’t met her yet.
We all get really excited when a rocket takes off. TimToady tells me about getting up in the wee hours of the morning to watch Mercury, Gemini, and Apollo rockets take off. I’m too young to remember those, but we have our own thrilling developments to track. Me, I was very happy to see a SpaceX rocket stick its landing this week. After several fender benders…
[another inaudible comment]
I’m ignoring you. Be careful. We’ve gotten really, really good at ignoring certain kinds of people. Don’t be one of them.
Really, I feel sorry for the people who are only happy when they have something to be unhappy about.
Anyway, launching Perl 6 into the world is a lot like a rocket launch. A lot of excitement during the countdown, that hold-your-breath moment when you wonder if it’s really going to go up or explode. That’s where we are now. The main engines are lit, the clamps are letting go. It’s all very dramatic, mostly because nothing much seems to be happening right now.
But that’s not what a rocket is about. Drama is not what a rocket wants to do. A rocket wants to go up, faster and faster and faster. It’s not about position. It’s not really even about velocity. It’s about acceleration.
[raises glass]
So, I give you Perl 6. She is free to fly. May she have joy in her existence. May she have joy in discovering the world. May she accelerate as long as she will! Cheers!
Congratulations to Camelia, #perl6, the Perl communities and everyone involved! It’s been a blast! :-D
Reading the blogpost thinking of you, for then reading the first comment – written by you.
I wish all Perl5/6 users the best with their new language. :)
Cheers! Congratulations & thanks for your great efforts!
Looking forward to making your acquaintance, and may it blossom into a great friendship! Thanks for all your efforts!
Hurray !
Six Thousand thanks to the P6 team & long live Camelia.
:-)
Camelia! We are so excited to watch you fly!
Camelia! Congratulations on your quinceañera!
Yay!! It really is Christmas! It’s going to be so exciting to watch what happens when people start getting to know Camelia :)
Merry Christmas to Camelia & Perl! :)
While I was a Perl5 hater, I am warming to Perl6 and rakudo guys have made a great work in advertising it.
In any case, congratulations.
Congrats and thanks . Long live perl6 :)
Merry Christmas and Happy Birthday, Perl 6. |
6,807 | 黑客利用 Wi-Fi 攻击你的七种方法 | http://www.networkworld.com/article/3003170/mobile-security/7-ways-hackers-can-use-wi-fi-against-you.html | 2015-12-28T15:03:00 | [
"安全"
] | https://linux.cn/article-6807-1.html | 
### 黑客利用 Wi-Fi 侵犯你隐私的七种方法
Wi-Fi — 啊,你是如此的方便,却又如此的危险!
这里给大家介绍一下通过 Wi-Fi 连接“慷慨捐赠”你的身份信息的七种方法和反制措施。

### 利用免费热点
它们似乎无处不在,而且它们的数量会在[接下来四年里增加三倍](http://www.pcworld.com/article/243464/number_of_wifi_hotspots_to_quadruple_by_2015_says_study.html)。但是它们当中很多都是不值得信任的,从你的登录凭证、email 甚至更加敏感的账户,都能被黑客用“<ruby> 嗅探器 <rp> ( </rp> <rt> sniffer </rt> <rp> ) </rp></ruby>”软件截获 — 这种软件能截获到任何你通过该连接提交的信息。防止被黑客盯上的最好办法就是使用VPN(<ruby> 虚拟私有网 <rp> ( </rp> <rt> virtual private network </rt> <rp> ) </rp></ruby>),它加密了你所输入的信息,因此能够保护你的数据隐私。

### 网上银行
你可能认为没有人需要被提醒不要使用免费 Wi-Fi 来操作网上银行, 但网络安全厂商卡巴斯基实验室表示**[全球超过100家银行因为网络黑客而损失9亿美元](http://www.nytimes.com/2015/02/15/world/bank-hackers-steal-millions-via-malware.html?hp&action=click&pgtype=Homepage&module=first-column-region%C2%AEion=top-news&WT.nav=top-news&_r=3)**,由此可见还是有很多人因此受害。如果你确信一家咖啡店的免费 Wi-Fi 是正规的,想要连接它,那么你应该向服务员确认网络名称。[其他人在店里用路由器设置一个开放的无线连接](http://news.yahoo.com/blogs/upgrade-your-life/banking-online-not-hacked-182159934.html),并将它的网络名称设置成店名是一件相当简单的事。

### 始终开着 Wi-Fi 开关
如果你手机的 Wi-Fi 开关一直开着的,你会自动被连接到一个不安全的网络中去,你甚至都没有意识到。你可以利用你手机中[基于位置的 Wi-Fi 功能](http://pocketnow.com/2014/10/15/should-you-leave-your-smartphones-wifi-on-or-turn-it-off),如果有这种功能的话,那它会在你离开你所保存的网络范围后自动关闭你的 Wi-Fi 开关并在你回去之后再次开启。

### 不使用防火墙
防火墙是你的第一道抵御恶意入侵的防线,它能有效地让你的电脑网络保持通畅并阻挡黑客和恶意软件。你应该时刻开启它除非你的杀毒软件有它自己的防火墙。

### 浏览非加密网页
说起来很难过,**[世界上排名前100万个网站中55%是不加密的](http://www.cnet.com/news/chrome-becoming-tool-in-googles-push-for-encrypted-web/)**,一个未加密的网站会让一切传输数据暴露在黑客的眼中。如果一个网页是安全的,你的浏览器则会有标明(比如说火狐浏览器是一把灰色的挂锁,Chrome 浏览器则是个绿锁图标)。但是即使是安全的网站不能让你免于被劫持的风险,他们能通过公共网络从你访问过的网站上窃取 cookies,无论是不是正规网站。

### 不更新你的安全防护软件
如果你想要确保你自己的网络是受保护的,就更新路由器固件。你要做的就是进入你的路由器管理页面去检查,通常你能在厂商的官方网页上下载到最新的固件版本。

### 不保护你的家用 Wi-Fi
不用说,设置一个复杂的密码和更改无线连接的默认名都是非常重要的。你还可以过滤你的 MAC 地址来让你的路由器只识别那些确认过的设备。
本文作者 **Josh Althuser** 是一个开源支持者、网络架构师和科技企业家。在过去12年里,他花了很多时间去倡导使用开源软件来管理团队和项目,同时为网络应用程序提供企业级咨询并帮助它们把产品推向市场。你可以通过[他的推特](https://twitter.com/JoshAlthuser)联系他。
---
via: <http://www.networkworld.com/article/3003170/mobile-security/7-ways-hackers-can-use-wi-fi-against-you.html>
作者:[Josh Althuser](https://twitter.com/JoshAlthuser) 译者:[ZTinoZ](https://github.com/ZTinoZ) 校对:[Caroline](https://github.com/carolinewuyan)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,808 | 如何在 Ubuntu 15.04 / CentOS 7 上安装 Android Studio | http://linoxide.com/tools/install-android-studio-ubuntu-15-04-centos-7/ | 2015-12-28T15:25:32 | [
"Android Studio",
"Android"
] | /article-6808-1.html | 随着最近几年智能手机的进步,安卓成为了最大的手机平台之一,在开发安卓应用中所用到的所有工具也都可以免费得到。Android Studio 是基于 [IntelliJ IDEA](https://www.jetbrains.com/idea/) 用于开发安卓应用的集成开发环境(IDE)。它是 Google 2014 年发布的免费开源软件,继 Eclipse 之后成为主要的 IDE。
在这篇文章,我们一起来学习如何在 Ubuntu 15.04 和 CentOS 7 上安装 Android Studio。

### 在 Ubuntu 15.04 上安装
我们可以用两种方式安装 Android Studio。第一种是配置所需的库然后再安装它;另一种是从 Android 官方网站下载然后在本地编译安装。在下面的例子中,我们会使用命令行设置库并安装它。在继续下一步之前,我们需要确保我们已经安装了 JDK 1.6 或者更新版本。
这里,我打算安装 JDK 1.8。
```
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer oracle-java8-set-default
```
验证 java 是否安装成功:
```
poornima@poornima-Lenovo:~$ java -version
```
现在,设置安装 Android Studio 需要的库
```
$ sudo apt-add-repository ppa:paolorotolo/android-studio
```

```
$ sudo apt-get update
$ sudo apt-get install android-studio
```
上面的安装命令会在 /opt 目录下面安装 Android Studio。
现在,运行下面的命令启动安装向导:
```
$ /opt/android-studio/bin/studio.sh
```
这会激活安装窗口。下面的截图展示了安装 Android Studio 的过程。



你点击了 Finish 按钮之后,就会显示同意协议页面。当你接受协议之后,它就开始下载需要的组件。

这一步完成之后就结束了 Android Studio 的安装。当你重启 Android Studio 时,你会看到下面的欢迎界面,从这里你可以开始用 Android Studio 工作了。

### 在 CentOS 7 上安装
现在再让我们来看看如何在 CentOS 7 上安装 Android Studio。这里你同样需要安装 JDK 1.6 或者更新版本。如果你不是 root 用户,记得在命令前面使用 ‘sudo’。你可以下载[最新版本](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)的 JDK。如果你已经安装了一个比较旧的版本,在安装新的版本之前你需要先卸载旧版本。在下面的例子中,我会通过下载需要的 rpm 包安装 JDK 1.8.0\_65。
```
[root@li1260-39 ~]# rpm -ivh jdk-8u65-linux-x64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:jdk1.8.0_65-2000:1.8.0_65-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
jfxrt.jar...
```
如果没有正确设置 Java 路径,你会看到错误信息。因此,设置正确的路径:
```
export JAVA_HOME=/usr/java/jdk1.8.0_25/
export PATH=$PATH:$JAVA_HOME
```
检查是否安装了正确的版本:
```
[root@li1260-39 ~]# java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.65-b01, mixed mode)
```
如果你安装 Android Studio 的时候看到任何类似 “unable-to-run-mksdcard-sdk-tool:” 的错误信息,你可能要在 CentOS 7 64 位系统中安装以下软件包:
* glibc.i686
* glibc-devel.i686
* libstdc++.i686
* zlib-devel.i686
* ncurses-devel.i686
* libX11-devel.i686
* libXrender.i686
* libXrandr.i686
通过从 [Android 网站](http://developer.android.com/sdk/index.html) 下载 IDE 文件然后解压安装 studio 也是一样的。
```
[root@li1260-39 tmp]# unzip android-studio-ide-141.2343393-linux.zip
```
移动 android-studio 目录到 /opt 目录
```
[root@li1260-39 tmp]# mv /tmp/android-studio/ /opt/
```
需要的话你可以创建一个到 studio 可执行文件的符号链接用于快速启动。
```
[root@li1260-39 tmp]# ln -s /opt/android-studio/bin/studio.sh /usr/local/bin/android-studio
```
现在在终端中启动 studio:
```
[root@localhost ~]#studio
```
之后用于完成安装的截图和前面 Ubuntu 安装过程中的是一样的。安装完成后,你就可以开始开发你自己的 Android 应用了。
### 总结
虽然发布不到一年,但是 Android Studio 已经替代 Eclipse 成为了 Android 的开发最主要的 IDE。它是唯一能支持 Google 之后将要提供的 Android SDK 和其它 Android 特性的官方 IDE 工具。那么,你还在等什么呢?赶快安装 Android Studio 来体验开发 Android 应用的乐趣吧。
---
via: <http://linoxide.com/tools/install-android-studio-ubuntu-15-04-centos-7/>
作者:[B N Poornima](http://linoxide.com/author/bnpoornima/) 译者:[ictlyh](http://mutouxiaogui.cn/blog/) 校对:[Caroline](https://github.com/carolinewuyan)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='linoxide.com', port=80): Max retries exceeded with url: /tools/install-android-studio-ubuntu-15-04-centos-7/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327582800>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,809 | 有人试图在树莓派上预装恶意软件! | http://news.softpedia.com/news/somebody-tried-to-get-a-raspberry-pi-exec-to-install-malware-on-its-devices-498088.shtml | 2015-12-28T22:59:05 | [
"树莓派",
"恶意软件"
] | https://linux.cn/article-6809-1.html |
>
> 恶意软件分销商并不知道开源社区是多么痛恨网络犯罪,所以他们就被曝光到推特上了。
>
>
>

树莓派基金会的<ruby> 传播总监 <rp> ( </rp> <rt> Director of Communications </rt> <rp> ) </rp></ruby> Liz Upton 最近在推特上贴出了一封邮件截图,邮件显示有人试图让树莓派基金会在其所有产品上安装恶意软件。
>
> 鹅妹子嘤!有人想要给我们钱让我们在你的机器上安装恶意软件。 [pic.twitter.com/1soL0MIc5Z](https://t.co/1soL0MIc5Z)
>
>
> — Raspberry Pi (@Raspberry\_Pi) [December 23, 2015](https://twitter.com/Raspberry_Pi/status/679640660044058624)
>
>
> 
>
>
>
在该邮件中,一位名叫 Linda 的人向 Upton 夫人提出,她们公司提供一个 EXE 文件,该文件会在桌面上建立一个快捷方式,用户点击即可访问到一个特定的网站。(树莓派也可以运行 Windows,不仅仅是 Linux)
这位来自某 Q 公司的 Linda 也询问了树莓派基金会的 PPI 价格(每份安装价)。
从邮件的用语可以看出其英语并不娴熟,是业务人员,这位 Linda 应该不是来自专业公司的人员。有许多公司充当恶意软件分销商和正规公司之间的中间人,冒充广告代理公司或公关公司。
就在两周前,<ruby> 数字公民联盟 <rp> ( </rp> <rt> Digital Citizens Alliance </rt> <rp> ) </rp></ruby>和 RiskIQ 发布了一份报告称,BT 站点可以通过恶意文件或受感染的种子文件来散发恶意软件给他们的访问者,从而每年[牟取了 7 千万美金](http://news.softpedia.com/news/torrent-sites-earned-70-million-to-drop-malware-on-their-visitors-497470.shtml)。
### 联系开源社区的公司并没有想到其邮件会被曝光
树莓派基金会有多达 5 百万的用户基础,恶意软件分销商肯定对此垂涎欲滴,希望能将他们的恶意代码隐藏在市场上最热的产品固件之中。
树莓派这块信用卡大小的廉价电脑已经用在了物联网方面,黑客可以通过它来访问到其所运行的高安全的环境中。
因为当前还没有可以运行在物联网设备上的安全软件,如果感染了恶意软件,它会持续运行很多年——直到你擦除了固件——而这在产品环境中很少发生。
如果树莓派基金会不是和 Linux 基金会关系密切,而且遵循其开放原则,让社区构建软件,我们可能就得对此担忧了。
在网上有很多人说,绝大多数的树莓派都是运行在 Linux 下,EXE 文件根本没用。其实这并不是关键。发送这封邮件的人显然没有专业水准。这篇文章真正的着眼点是,**恶意软件分销商在不断地寻找可以注入他们的恶意软件的新客户端**,而并不是讨论这封邮件本身的技术问题。
| 301 | Moved Permanently | null |
6,813 | eSpeak: Linux 文本转语音工具 | http://itsfoss.com/espeak-text-speech-linux/ | 2015-12-29T14:18:38 | [
"eSpeak",
"语音"
] | https://linux.cn/article-6813-1.html | 
[eSpeak](http://espeak.sourceforge.net/)是一款 Linux 命令行工具,能把文本转换成语音。它是一款简洁的语音合成器,用C语言编写而成,它支持英语和其它多种语言。
eSpeak 从标准输入或者输入文件中读取文本。虽然语音输出与真人声音相去甚远,但是,在你项目需要的时候,eSpeak 仍不失为一个简便快捷的工具。
eSpeak 部分主要特性如下:
* 提供给 Linux 和 Windows 的命令行工具
* 从文件或者标准输入中把文本读出来
* 提供给其它程序使用的共享库版本
* 为 Windows 提供 SAPI5 版本,所以它能用于 screen-readers 或者其它支持 Windows SAPI5 接口的程序
* 可移植到其它平台,包括安卓,OSX等
* 提供多种声音特性选择
* 语音输出可保存为 [.WAV](http://en.wikipedia.org/wiki/WAV) 格式的文件
* 配合 HTML 部分可支持 SSML(语音合成标记语言,[Speech Synthesis Markup Language](http://en.wikipedia.org/wiki/Speech_Synthesis_Markup_Language))
* 体积小巧,整个程序连同语言支持等占用小于2MB
* 可以实现文本到音素编码(phoneme code)的转化,因此可以作为其它语音合成引擎的前端工具
* 开发工具可用于生产和调整音素数据
### 安装 eSpeak
基于 Ubuntu 的系统中,在终端运行以下命令安装 eSpeak:
```
sudo apt-get install espeak
```
eSpeak 是一个古老的工具,我推测它应该能在其它众多 Linux 发行版中运行,比如 Arch,Fedora。使用 dnf,pacman 等命令就能轻松安装。
eSpeak 用法如下:输入 espeak 运行程序。输入字符按 enter 转换为语音输出(LCTT 译注:补充)。使用 Ctrl+C 来关闭运行中的程序。

还有一些其他的选项可用,可以通过程序帮助进行查看。
### GUI 版本:Gespeaker
如果你更倾向于使用 GUI 版本,可以安装 Gespeaker,它为 eSpeak 提供了 GTK 界面。
使用以下命令来安装 Gespeaker:
```
sudo apt-get install gespeaker
```
操作界面简明易用,你完全可以自行探索。

虽然这些工具在大多数计算任务下用不到,但是当你的项目需要把文本转换成语音时,使用 espeak 还是挺方便的。是否使用 espeak 这款语音合成器,选择权就交给你们啦。
---
via: <http://itsfoss.com/espeak-text-speech-linux/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[soooogreen](https://github.com/soooogreen) 校对:[Caroline](https://github.com/carolinewuyan)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,814 | Linux 中如何通过命令行访问 Dropbox | http://xmodulo.com/access-dropbox-command-line-linux.html | 2015-12-29T14:46:05 | [
"dropbox"
] | https://linux.cn/article-6814-1.html | 在当今这个多设备的环境下,云存储无处不在。无论身处何方,人们都想通过多种设备来从云存储中获取所需的内容。由于拥有漂亮的 UI 和完美的跨平台兼容性,Dropbox 已成为最为广泛使用的云存储服务。 Dropbox 的流行已引发了一系列官方或非官方 Dropbox 客户端的出现,它们支持不同的操作系统平台。

当然 Linux 平台下也有着自己的 Dropbox 客户端: 既有命令行的,也有图形界面客户端。[Dropbox Uploader](http://www.andreafabrizi.it/?dropbox_uploader) 是一个简单易用的 Dropbox 命令行客户端,它是用 Bash 脚本语言所编写的(LCTT 译注:对,你没看错, 就是 Bash)。在这篇教程中,我将描述 **在 Linux 中如何使用 Dropbox Uploader 通过命令行来访问 Dropbox**。
### Linux 中安装和配置 Dropbox Uploader
要使用 Dropbox Uploader,你需要下载该脚本并使其可被执行。
```
$ wget https://raw.github.com/andreafabrizi/Dropbox-Uploader/master/dropbox_uploader.sh
$ chmod +x dropbox_uploader.sh
```
请确保你已经在系统中安装了 `curl`,因为 Dropbox Uploader 通过 curl 来运行 Dropbox 的 API。
要配置 Dropbox Uploader,只需运行 dropbox\_uploader.sh 即可。当你第一次运行这个脚本时,它将请求得到授权以使得脚本可以访问你的 Dropbox 账户。
```
$ ./dropbox_uploader.sh
```

如上图所指示的那样,你需要通过浏览器访问 <https://www.dropbox.com/developers/apps> 页面,并创建一个新的 Dropbox app。接着像下图那样填入新 app 的相关信息,并输入 app 的名称,它与 Dropbox Uploader 所生成的 app 名称类似。

在你创建好一个新的 app 之后,你将在下一个页面看到 app key 和 app secret。请记住它们。

然后在正运行着 dropbox*uploader.sh 的终端窗口中输入 app key 和 app secret。然后 dropbox*uploader.sh 将产生一个 oAUTH 网址(例如,[https://www.dropbox.com/1/oauth/authorize?oauth\_token=XXXXXXXXXXXX)。](https://www.dropbox.com/1/oauth/authorize?oauth_token=XXXXXXXXXXXX)%E3%80%82)

接着通过浏览器访问那个 oAUTH 网址,并同意访问你的 Dropbox 账户。

这便完成了 Dropbox Uploader 的配置。若要确认 Dropbox Uploader 是否真的被成功地认证了,可以运行下面的命令。
```
$ ./dropbox_uploader.sh info
```
---
```
Dropbox Uploader v0.12
> Getting info...
Name: Dan Nanni
UID: XXXXXXXXXX
Email: my@email_address
Quota: 2048 Mb
Used: 13 Mb
Free: 2034 Mb
```
### Dropbox Uploader 示例
要显示根目录中的所有内容,运行:
```
$ ./dropbox_uploader.sh list
```
要列出某个特定文件夹中的所有内容,运行:
```
$ ./dropbox_uploader.sh list Documents/manuals
```
要上传一个本地文件到一个远程的 Dropbox 文件夹,使用:
```
$ ./dropbox_uploader.sh upload snort.pdf Documents/manuals
```
要从 Dropbox 下载一个远程的文件到本地,使用:
```
$ ./dropbox_uploader.sh download Documents/manuals/mysql.pdf ./mysql.pdf
```
要从 Dropbox 下载一个完整的远程文件夹到一个本地的文件夹,运行:
```
$ ./dropbox_uploader.sh download Documents/manuals ./manuals
```
要在 Dropbox 上创建一个新的远程文件夹,使用:
```
$ ./dropbox_uploader.sh mkdir Documents/whitepapers
```
要完全删除 Dropbox 中某个远程的文件夹(包括它所含的所有内容),运行:
```
$ ./dropbox_uploader.sh delete Documents/manuals
```
---
via: <http://xmodulo.com/access-dropbox-command-line-linux.html>
作者:[Dan Nanni](http://xmodulo.com/author/nanni) 译者:[FSSlc](https://github.com/FSSlc) 校对:[Caroline](https://github.com/carolinewuyan)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,827 | 在 Linux 终端下看《星球大战》 | http://itsfoss.com/star-wars-linux/ | 2015-12-31T08:25:00 | [
"终端",
"星球大战"
] | https://linux.cn/article-6827-1.html | 
《星球大战(Star Wars)》已经席卷世界。最新一期的 [《星球大战》系列, 《星球大战7:原力觉醒》,打破了有史以来的记录](http://www.gamespot.com/articles/star-wars-7-breaks-thursday-night-movie-opening-re/1100-6433246/)。
虽然我不能帮你得到一张最新的《星球大战》的电影票,但我可以提供给你一种方式,看[星球大战第四集](http://www.imdb.com/title/tt0076759/),它是非常早期的《星球大战》电影(1977 年)。

不,它不会是高清,也不是蓝光版。相反,它将是 ASCII 版的《星球大战》第四集,你可以在 Linux 终端看它,这才是真正的极客的方式 :)
### 在 Linux 终端看星球大战
打开一个终端,使用以下命令:
```
telnet towel.blinkenlights.nl
```
等待几秒钟,你可以在终端看到类似于以下这样的动画ASCII艺术:
(LCTT 译注:有时候会解析到效果更好 IPv6 版本上,如果你没有 IPv6 地址,可以重新连接试试;另外似乎线路不稳定,出现卡顿时稍等。)

它将继续播映……




要停止动画,按 `ctrl +]`,在这之后输入 `quit` 来退出 telnet 程序。
### 更多有趣的终端
事实上,看《星球大战》并不是你在 Linux 终端下唯一能做有趣的事情。您可以运行[终端里的列车](/article-6795-1.html)或[通过ASCII艺术得到Linux标志](/article-6510-1.html)。
希望你能享受在 Linux 下看《星球大战》。
---
via: <http://itsfoss.com/star-wars-linux/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[zky001](https://github.com/zky001) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,836 | 将 Tor socks 转换成 http 代理 | http://www.unixmen.com/turn-tor-socks-http/ | 2016-01-03T18:36:48 | [
"Tor",
"代理"
] | https://linux.cn/article-6836-1.html | 
你可以通过不同的 Tor 工具来使用 Tor 服务,如 Tor 浏览器、Foxyproxy 和其它东西,像 wget 和 aria2 这样的下载管理器不能直接使用 Tor socks 开始匿名下载,因此我们需要一些工具来将 Tor socks 转换成 http 代理,这样就能用它来下载了。
**注意**:本教程基于 Debian ,其他发行版会有些不同,因此如果你的发行版是基于 Debian 的,就可以直接使用下面的配置了。
### Polipo
这个服务会使用 8123 端口和 127.0.0.1 的 IP 地址,使用下面的命令来在计算机上安装 Polipo:
```
sudo apt install polipo
```
现在使用如下命令打开 Polipo 的配置文件:
```
sudo nano /etc/polipo/config
```
在文件最后加入下面的行:
```
proxyAddress = "::0"
allowedClients = 192.168.1.0/24
socksParentProxy = "localhost:9050"
socksProxyType = socks5
```
用如下的命令来重启 Polipo:
```
sudo service polipo restart
```
现在 Polipo 已经安装好了!在匿名的世界里做你想做的吧!下面是使用的例子:
```
pdmt -l "link" -i 127.0.01 -p 8123
```
通过上面的命令 PDMT(Persian 下载器终端)会匿名地下载你的文件。
### Proxychains
在此服务中你可以设置使用 Tor 或者 Lantern 代理,但是在使用上它和 Polipo 和 Privoxy 有点不同,它不需要使用任何端口!使用下面的命令来安装:
```
sudo apt install proxychains
```
用这条命令来打开配置文件:
```
sudo nano /etc/proxychains.conf
```
现在添加下面的代码到文件底部,这里是 Tor 的端口和 IP:
```
socks5 127.0.0.1 9050
```
如果你在命令的前面加上“proxychains”并运行,它就能通过 Tor 代理来运行:
```
proxychains firefoxt
proxychains aria2c
proxychains wget
```
### Privoxy
Privoxy 使用 8118 端口,可以很轻松地通过 privoxy 包来安装:
```
sudo apt install privoxy
```
我们现在要修改配置文件:
```
sudo nano /etc/pivoxy/config
```
在文件底部加入下面的行:
```
forward-socks5 / 127.0.0.1:9050 .
forward-socks4a / 127.0.0.1:9050 .
forward-socks5t / 127.0.0.1:9050 .
forward 192.168.*.*/ .
forward 10.*.*.*/ .
forward 127.*.*.*/ .
forward localhost/ .
```
重启服务:
```
sudo service privoxy restart
```
服务已经好了!端口是 8118,IP 是 127.0.0.1,就尽情使用吧!
---
via: <http://www.unixmen.com/turn-tor-socks-http/>
作者:[Hossein heydari](http://www.unixmen.com/author/hossein/) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,846 | 如何在 CentOS 7 / Ubuntu 15.04 上安装 PHP 框架 Laravel | http://linoxide.com/linux-how-to/install-laravel-php-centos-7-ubuntu-15-04/ | 2016-01-06T08:20:00 | [
"PHP",
"Laravel"
] | /article-6846-1.html | 大家好,这篇文章将要讲述如何在 CentOS 7 / Ubuntu 15.04 上安装 Laravel。如果你是一个 PHP Web 的开发者,你并不需要考虑如何在琳琅满目的现代 PHP 框架中选择,Laravel 是最轻松启动和运行的,它省时省力,能让你享受到 web 开发的乐趣。Laravel 信奉着一个普世的开发哲学,通过简单的指导创建出可维护代码是最优先的,你将保持着高速的开发效率,能够随时毫不畏惧更改你的代码来改进现有功能。

Laravel 安装并不繁琐,你只要跟着本文章一步步操作就能在 CentOS 7 或者 Ubuntu 15 服务器上安装。
### 1) 服务器要求
在安装 Laravel 前需要安装一些它的依赖前提条件,主要是一些基本的参数调整,比如升级系统到最新版本,sudo 权限和安装依赖包。
当你连接到你的服务器时,请确保你能通以下命令能成功的使用 EPEL 仓库并且升级你的服务器。
#### CentOS-7
```
# yum install epel-release
# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
# yum update
```
#### Ubuntu
```
# apt-get install python-software-properties
# add-apt-repository ppa:ondrej/php5
# apt-get update
# apt-get install -y php5 mcrypt php5-mcrypt php5-gd
```
### 2) 防火墙安装
系统防火墙和 SELinux 设置对于用于产品应用安全来说非常重要,当你使用测试服务器的时候可以关闭防火墙,用以下命令行设置 SELinux 成<ruby> 宽容模式 <rp> ( </rp> <rt> permissive </rt> <rp> ) </rp></ruby>来保证安装程序不受它们的影响。
```
# setenforce 0
```
### 3) Apache, MariaDB, PHP 安装
Laravel 安装程序需要完成安装 LAMP 整个环境,需要额外安装 OpenSSL、PDO,Mbstring 和 Tokenizer 等 PHP 扩展。如果 LAMP 已经运行在你的服务器上你可以跳过这一步,直接确认一些必要的 PHP 插件是否安装好。
要安装完整 AMP 你需要在自己的服务器上运行以下命令。
#### CentOS
```
# yum install httpd mariadb-server php56w php56w-mysql php56w-mcrypt php56w-dom php56w-mbstring
```
要在 CentOS 7 上实现 MySQL / Mariadb 服务开机自动启动,你需要运行以下命令。
```
# systemctl start httpd
# systemctl enable httpd
#systemctl start mysqld
#systemctl enable mysqld
```
在启动 MariaDB 服务之后,你需要运行以下命令配置一个足够安全的密码。
```
#mysql_secure_installation
```
#### Ubuntu
```
# apt-get install mysql-server apache2 libapache2-mod-php5 php5-mysql
```
### 4) 安装 Composer
在我们安装 Laravel 前,先让我们开始安装 composer。安装 composer 是安装 Laravel 的最重要步骤之一,因为 composer 能帮我们安装 Laravel 的各种依赖。
#### CentOS/Ubuntu
在 CentOS / Ubuntu 下运行以下命令来配置 composer 。
```
# curl -sS https://getcomposer.org/installer | php
# mv composer.phar /usr/local/bin/composer
# chmod +x /usr/local/bin/composer
```

### 5) 安装 Laravel
我们可以运行以下命令从 github 上下载 Laravel 的安装包。
```
# wget https://github.com/laravel/laravel/archive/develop.zip
```
运行以下命令解压安装包并且移动 document 的根目录。
```
# unzip develop.zip
# mv laravel-develop /var/www/
```
现在使用 compose 命令来安装目录下所有 Laravel 所需要的依赖。
```
# cd /var/www/laravel-develop/
# composer install
```

### 6) 密钥
为了加密服务器,我们使用以下命令来生成一个加密后的 32 位的密钥。
```
# php artisan key:generate
Application key [Lf54qK56s3qDh0ywgf9JdRxO2N0oV9qI] set successfully
```
现在把这个密钥放到 'app.php' 文件,如以下所示。
```
# vim /var/www/laravel-develop/config/app.php
```

### 7) 虚拟主机和所属用户
在 composer 安装好后,分配 document 根目录的权限和所属用户,如下所示。
```
# chmod 775 /var/www/laravel-develop/app/storage
# chown -R apache:apache /var/www/laravel-develop
```
用任意一款编辑器打开 apache 服务器的默认配置文件,在文件最后加上虚拟主机配置。
```
# vim /etc/httpd/conf/httpd.conf
```
---
```
ServerName laravel-develop
DocumentRoot /var/www/laravel/public
<Directory /var/www/laravel>
AllowOverride All
</Directory>
```
现在我们用以下命令重启 apache 服务器,打开浏览器查看 localhost 页面。
#### CentOS
```
# systemctl restart httpd
```
#### Ubuntu
```
# service apache2 restart
```
### 8) Laravel 5 网络访问
打开浏览器然后输入你配置的 IP 地址或者<ruby> 完整域名 <rp> ( </rp> <rt> Fully qualified domain name </rt> <rp> ) </rp></ruby>你将会看到 Laravel 5 的默认页面。

### 总结
Laravel 框架对于开发网页应用来说是一个绝好的的工具。所以,看了这篇文章你将学会在 Ubuntu 15 和 CentOS 7 上安装 Laravel, 之后你就可以使用这个超棒的 PHP 框架提供的各种功能和舒适便捷性来进行你的开发工作。
如果您有什么意见或者建议请在以下评论区中回复,我们将根据您宝贵的反馈来使我们的文章更加浅显易懂。
---
via: <http://linoxide.com/linux-how-to/install-laravel-php-centos-7-ubuntu-15-04/>
作者:[Kashif](http://linoxide.com/author/kashifs/) 译者:[NearTan](https://github.com/NearTan) 校对:[Caroline](https://github.com/carolinewuyan)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='linoxide.com', port=80): Max retries exceeded with url: /linux-how-to/install-laravel-php-centos-7-ubuntu-15-04/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327582f50>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,847 | 在 Ubuntu 15.10 上为单个网卡设置多个 IP 地址 | http://www.unixmen.com/assign-multiple-ip-addresses-to-one-interface-on-ubuntu-15-10/ | 2016-01-07T08:33:00 | [
"ip"
] | https://linux.cn/article-6847-1.html | 有时候你可能想在你的网卡上使用多个 IP 地址。遇到这种情况你会怎么办呢?买一个新的网卡并分配一个新的 IP?不,没有这个必要(至少在小型网络中)。现在我们可以在 Ubuntu 系统中为一个网卡分配多个 IP 地址。想知道怎么做到的?跟着我往下看,其实并不难。
这个方法也适用于 Debian 以及它的衍生版本。

### 临时添加 IP 地址
首先,让我们找到网卡的 IP 地址。在我的 Ubuntu 15.10 服务器版中,我只使用了一个网卡。
运行下面的命令找到 IP 地址:
```
sudo ip addr
```
**样例输出:**
```
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:2a:03:4b brd ff:ff:ff:ff:ff:ff
inet 192.168.1.103/24 brd 192.168.1.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe2a:34e/64 scope link
valid_lft forever preferred_lft forever
```
或
```
sudo ifconfig
```
**样例输出:**
```
enp0s3 Link encap:Ethernet HWaddr 08:00:27:2a:03:4b
inet addr:192.168.1.103 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe2a:34e/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:186 errors:0 dropped:0 overruns:0 frame:0
TX packets:70 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:21872 (21.8 KB) TX bytes:9666 (9.6 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:217 errors:0 dropped:0 overruns:0 frame:0
TX packets:217 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:38793 (38.7 KB) TX bytes:38793 (38.7 KB)
```
正如你在上面输出中看到的,我的网卡名称是 **enp0s3**,它的 IP 地址是 **192.168.1.103**。
现在让我们来为网卡添加一个新的 IP 地址,例如说 **192.168.1.104**。
打开你的终端并运行下面的命令添加额外的 IP。
```
sudo ip addr add 192.168.1.104/24 dev enp0s3
```
用命令检查是否启用了新的 IP:
```
sudo ip address show enp0s3
```
**样例输出:**
```
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:2a:03:4e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.103/24 brd 192.168.1.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet 192.168.1.104/24 scope global secondary enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe2a:34e/64 scope link
valid_lft forever preferred_lft forever
```
类似地,你可以添加任意数量的 IP 地址,只要你想要。
让我们 ping 一下这个 IP 地址验证一下。
```
sudo ping 192.168.1.104
```
**样例输出**
```
PING 192.168.1.104 (192.168.1.104) 56(84) bytes of data.
64 bytes from 192.168.1.104: icmp_seq=1 ttl=64 time=0.901 ms
64 bytes from 192.168.1.104: icmp_seq=2 ttl=64 time=0.571 ms
64 bytes from 192.168.1.104: icmp_seq=3 ttl=64 time=0.521 ms
64 bytes from 192.168.1.104: icmp_seq=4 ttl=64 time=0.524 ms
```
好极了,它能工作!
要删除 IP,只需要运行:
```
sudo ip addr del 192.168.1.104/24 dev enp0s3
```
再检查一下是否删除了 IP。
```
sudo ip address show enp0s3
```
**样例输出:**
```
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:2a:03:4e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.103/24 brd 192.168.1.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe2a:34e/64 scope link
valid_lft forever preferred_lft forever
```
可以看到已经没有了!!
正如你所知,重启系统后这些设置会失效。那么怎么设置才能永久有效呢?这也很简单。
### 添加永久 IP 地址
Ubuntu 系统的网卡配置文件是 **/etc/network/interfaces**。
让我们来看看上面文件的具体内容。
```
sudo cat /etc/network/interfaces
```
**输出样例:**
```
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet dhcp
```
正如你在上面输出中看到的,网卡启用了 DHCP。
现在,让我们来分配一个额外的地址,例如 **192.168.1.104/24**。
编辑 **/etc/network/interfaces**:
```
sudo nano /etc/network/interfaces
```
如下添加额外的 IP 地址。
```
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s3
iface enp0s3 inet dhcp
iface enp0s3 inet static
address 192.168.1.104/24
```
保存并关闭文件。
运行下面的命令使更改无需重启即生效。
```
sudo ifdown enp0s3 && sudo ifup enp0s3
```
**样例输出:**
```
Killed old client process
Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/enp0s3/08:00:27:2a:03:4e
Sending on LPF/enp0s3/08:00:27:2a:03:4e
Sending on Socket/fallback
DHCPRELEASE on enp0s3 to 192.168.1.1 port 67 (xid=0x225f35)
Internet Systems Consortium DHCP Client 4.3.1
Copyright 2004-2014 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/enp0s3/08:00:27:2a:03:4e
Sending on LPF/enp0s3/08:00:27:2a:03:4e
Sending on Socket/fallback
DHCPDISCOVER on enp0s3 to 255.255.255.255 port 67 interval 3 (xid=0xdfb94764)
DHCPREQUEST of 192.168.1.103 on enp0s3 to 255.255.255.255 port 67 (xid=0x6447b9df)
DHCPOFFER of 192.168.1.103 from 192.168.1.1
DHCPACK of 192.168.1.103 from 192.168.1.1
bound to 192.168.1.103 -- renewal in 35146 seconds.
```
**注意**:如果你从远程连接到服务器,把上面的两个命令放到**一行**中**非常重要**,因为第一个命令会断掉你的连接。而采用这种方式可以保留你的 ssh 会话。
现在,让我们用下面的命令来检查一下是否添加了新的 IP:
```
sudo ip address show enp0s3
```
**输出样例:**
```
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:2a:03:4e brd ff:ff:ff:ff:ff:ff
inet 192.168.1.103/24 brd 192.168.1.255 scope global enp0s3
valid_lft forever preferred_lft forever
inet 192.168.1.104/24 brd 192.168.1.255 scope global secondary enp0s3
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe2a:34e/64 scope link
valid_lft forever preferred_lft forever
```
很好!我们已经添加了额外的 IP。
再次 ping IP 地址进行验证。
```
sudo ping 192.168.1.104
```
**样例输出:**
```
PING 192.168.1.104 (192.168.1.104) 56(84) bytes of data.
64 bytes from 192.168.1.104: icmp_seq=1 ttl=64 time=0.137 ms
64 bytes from 192.168.1.104: icmp_seq=2 ttl=64 time=0.050 ms
64 bytes from 192.168.1.104: icmp_seq=3 ttl=64 time=0.054 ms
64 bytes from 192.168.1.104: icmp_seq=4 ttl=64 time=0.067 ms
```
好极了!它能正常工作。就是这样。
想知道怎么给 CentOS/RHEL/Scientific Linux/Fedora 系统添加额外的 IP 地址,可以点击下面的链接。
* [在CentOS 7上给一个网卡分配多个IP地址](/article-5127-1.html)
工作愉快!
---
via: <http://www.unixmen.com/assign-multiple-ip-addresses-to-one-interface-on-ubuntu-15-10/>
作者:[SK](http://www.unixmen.com/author/sk/) 译者:[ictlyh](http://mutouxiaogui.cn/blog/) 校对:[Caroline](https://github.com/carolinewuyan)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,848 | 如何在 Ubuntu 14/15 上配置 Apache Solr | http://linoxide.com/ubuntu-how-to/configure-apache-solr-ubuntu-14-15/ | 2016-01-06T10:10:00 | [
"Apache Solr",
"搜索"
] | /article-6848-1.html | 大家好,欢迎来阅读我们今天这篇 Apache Solr 的文章。简单的来说,Apache Solr 是一个最负盛名的开源搜索平台,配合运行在网站后端的 Apache Lucene,能够让你轻松创建搜索引擎来搜索网站、数据库和文件。它能够索引和搜索多个网站并根据搜索文本的相关内容返回搜索建议。

Solr 使用 HTTP 可扩展标记语言(XML),可以为 JSON、Python 和 Ruby 等提供应用程序接口(API)。根据 Apache Lucene 项目所述,Solr 提供了非常多的功能,让它很受管理员们的欢迎:
* 全文检索
* <ruby> 分面导航 <rp> ( </rp> <rt> Faceted Navigation </rt> <rp> ) </rp></ruby>
* 拼写建议/自动完成
* 自定义文档排序/排列
#### 前提条件:
在一个使用最小化安装包的全新 Ubuntu 14/15 系统上,你仅仅需要少量的准备,就开始安装 Apache Solor.
### 1)System Update 系统更新
使用一个具有 sudo 权限的非 root 用户登录你的 Ubuntu 服务器,在接下来的所有安装和使用 Solr 的步骤中都会使用它。
登录成功后,使用下面的命令,升级你的系统到最新的更新及补丁:
```
$ sudo apt-get update
```
### 2) 安装 JRE
要安装 Solr,首先需要安装 JRE (Java Runtime Environment) 作为基础环境,因为 solr 和 tomcat 都是基于Java.所以,我们需要安装最新版的 Java 并配置 Java 本地环境.
要想安装最新版的 Java 8,我们需要通过以下命令安装 Python Software Properties 工具包
```
$ sudo apt-get install python-software-properties
```
完成后,配置最新版 Java 8的仓库
```
$ sudo add-apt-repository ppa:webupd8team/java
```
现在你可以通过以下命令更新包源列表,使用‘apt-get’来安装最新版本的 Oracle Java 8。
```
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
```
在安装和配置过程中,点击'OK'按钮接受 Java SE Platform 和 JavaFX 的<ruby> Oracle 二进制代码许可协议 <rp> ( </rp> <rt> Oracle Binary Code License Agreement </rt> <rp> ) </rp></ruby>。
在安装完成后,运行下面的命令,检查是否安装成功以及查看安装的版本。
```
kash@solr:~$ java -version
java version "1.8.0_66"
Java(TM) SE Runtime Environment (build 1.8.0_66-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.66-b17, mixed mode)
```
执行结果表明我们已经成功安装了 Java,并达到安装 Solr 最基本的要求了,接着我们进行下一步。
### 安装 Solr
有两种不同的方式可以在 Ubuntu 上安装 Solr,在本文中我们只用最新的源码包来演示源码安装。
要使用源码安装 Solr,先要从[官网](http://lucene.apache.org/solr/)下载最新的可用安装包。复制以下链接,然后使用 'wget' 命令来下载。
```
$ wget http://www.us.apache.org/dist/lucene/solr/5.3.1/solr-5.3.1.tgz
```
运行下面的命令,将这个已归档的服务解压到 /bin 目录。
```
$ tar -xzf solr-5.3.1.tgz solr-5.3.1/bin/install_solr_service.sh --strip-components=2
```
运行脚本来启动 Solr 服务,这将会先创建一个 solr 的用户,然后将 Solr 安装成服务。
```
$ sudo bash ./install_solr_service.sh solr-5.3.1.tgz
```

使用下面的命令来检查 Solr 服务的状态。
```
$ service solr status
```

### 创建 Solr 集合:
我们现在可以使用 Solr 用户添加多个集合。就像下图所示的那样,我们只需要在命令行中指定集合名称和指定其配置集就可以创建多个集合了。
```
$ sudo su - solr -c "/opt/solr/bin/solr create -c myfirstcollection -n data_driven_schema_configs"
```

我们已经成功的为我们的第一个集合创建了新核心实例目录,并可以将数据添加到里面。要查看库中的默认模式文件,可以在这里找到: '/opt/solr/server/solr/configsets/data*driven*schema\_configs/conf' 。
### 使用 Solr Web
可以使用默认的端口8983连接 Apache Solr。打开浏览器,输入 http://your\_server\_ip:8983/solr 或者 http://your-domain.com:8983/solr. 确保你的防火墙允许8983端口.
```
http://172.25.10.171:8983/solr/
```

在 Solr 的 Web 控制台左侧菜单点击 'Core Admin' 按钮,你将会看见我们之前使用命令行方式创建的集合。你可以点击 'Add Core' 按钮来创建新的核心。

就像下图中所示,你可以选择某个集合并指向文档来向里面添加内容或从文档中查询数据。如下显示的那样添加指定格式的数据。
```
{
"number": 1,
"Name": "George Washington",
"birth_year": 1989,
"Starting_Job": 2002,
"End_Job": "2009-04-30",
"Qualification": "Graduation",
"skills": "Linux and Virtualization"
}
```
添加文件后点击 'Submit Document'按钮.

### 总结
在 Ubuntu 上安装成功后,你就可以使用 Solr Web 接口插入或查询数据。如果你想通过 Solr 来管理更多的数据和文件,可以创建更多的集合。希望你能喜欢这篇文章并且希望它能够帮到你。
---
via: <http://linoxide.com/ubuntu-how-to/configure-apache-solr-ubuntu-14-15/>
作者:[Kashif](http://linoxide.com/author/kashifs/) 译者:[taichirain](https://github.com/taichirain) 校对:[Caroline](https://github.com/carolinewuyan)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='linoxide.com', port=80): Max retries exceeded with url: /ubuntu-how-to/configure-apache-solr-ubuntu-14-15/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327581ab0>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,852 | Debian 项目组向 Ian Murdock 的逝世表示哀悼 | https://www.debian.org/News/2016/20160105 | 2016-01-06T20:10:00 | [
"Ian Murdock",
"debian"
] | https://linux.cn/article-6852-1.html |
>
> Debian 项目组很悲伤地宣布 Debian 社区及项目失去了它的创立者 Ian Murdock。
>
>
>

Debian 只是 Ian 留给世人的一部分遗产,但也是 Ian 最为人所知的遗产之一。
Ian 很小就开始接触电脑。他对电脑从最初的好奇慢慢变得更加熟悉,在9岁的时候就开始经常写代码了。后来在 Krannert 管理学院的时候,有一门必修的编程课;这门课程强化了年轻的 Ian 对电脑的喜爱程度,也让他产生了让某些事情变得更好的想法。
1993年9月, Ian 启动了 Debian 项目;同年的晚些时候,发布了 Debian 的第一个版本。那个时候,Linux 发行版这样的概念还很新颖。正如 Ian 所说,这个想法是受 Linus Torvalds 所启发。Ian 发布 Debian 的目的很简单,他希望这个发行版能体现 Linux 和 GNU 的开源精神。
正是出于这个简单的目的,Ian 在软件世界掀起了一场运动。很多开发者加入 Ian 的项目,以在一个不断进步的世界里做出更好的软件。
正如 Ian 在<ruby> <a href="https://www.debian.org/doc/manuals/project-history/ap-manifesto.en.html"> Debian 宣言 </a> <rp> ( </rp> <rt> Debian Manifesto </rt> <rp> ) </rp></ruby>中所说的那样:“Debian 的设计过程是公开的;这样做的目的是希望保证一流的软件质量,并且能反映和满足用户社区的需求。Debian 可以以模块化的方式进行开发,使得不同背景、不同技能的人都能参与进来。[...] 让不同的人参与也意味着可以在开发过程中博采众长、扬长避短。这样做,也可以让项目满足不同用户的需求而不仅仅是满足开发者的需求。”
他的主要关注点是创建一个 Linux 发行版和一种行正道的社区文化,无论是道义上还是技术上。
Debian 项目不断发布新版本,Debian 关于<ruby> 软件自由 <rp> ( </rp> <rt> Software Freedom </rt> <rp> ) </rp></ruby> 的立场过去是、现在仍然是自由和开源世界的标杆。
Debian 0.01 版到 0.90 版在 1993年8月至93年12月之间发布。Ian Murdock写道:
“Debian 0.91 在1994年1月发布;这个版本有一个比较原始的包管理系统。[...] 那个时候,已经有些人加入到 Debian 的开发中来了,但是绝大部分时间还是我来准备发布的版本。0.91是最后一个这样弄出来的版本。”
“1994年的大部分时间花在了 Debian 项目的组织上,也因此,其它参与者能高效地为该项目添砖添瓦; 还有一部分时间花在了dpkg上[...]。”
"Debian 0.93 的第五个版本是在95年的三月份发布的,它也是 Debain 项目的第一个*现代版*:因为当时有很多开发者参与其中(虽然我记不得到底有多少个了);每个人维护他们自己的软件包;在安装完核心系统之后,当时我们用 dpkg 来管理这些软件包。”
“1995年发布了 Debian 0.93 版的第6个发布版本,这个版本也是 a.out 的最后一个版本(LCTT 译注:在 linux/unix 系统上,通过 gcc、g++ 来编译 C/C++ 程序时,如果没有指定 -o 参数,会默认生成名为 a.out 的目标二进制,这儿说明以前的开发管理相当原始,不是比较规范的那种方式来发布和管理相关的软件包)。当时大约有60多个开发者参与进来维护 0.93R6 的软件包。如果我没记错的话,dselect首先出现在093R6中。”
当他在1996年3月停止积极参与 Debian 项目之时,他表达了对 Debian 093R6 的钟爱;他说 0.93R6 “是我最喜欢的 Debian 版本”,虽然他也承认这有他的个人偏见在里面。
1996年3月,Ian Murdock 退出 Debian 项目的领导,并任命 Bruce Perens 作为 Debin 项目的新的领导人。
行正道这个理念一直影响着 Ian 的工作,包括 Debian 项目和其接下来数年的工作;他总是向着无限可能的明天而努力。
Debian 项目仍将前行,它会成为这个世界上随处可见的<ruby> 通用操作系统 <rp> ( </rp> <rt> Universal Operating System </rt> <rp> ) </rp></ruby>。无论在小的嵌入式设备上,还是庞大的集群系统上,再到空间站上“<ruby> 都能见到 Debian 的身影 <rp> ( </rp> <rt> of course it runs Debian </rt> <rp> ) </rp></ruby>”。Debian 已被移植到了多种架构和硬件类型上。
Ian 的梦想永存:Debian 由一个强大的社区所缔造;这个社区孕育了新的开发方式,成长理念和好奇心。Debian 社区仍是最活跃的社区;数以千计的开发人员日日夜夜的工作,以为人们提供可靠的安全的操作系统。Debian 点燃了那些希望让世界变得更好的人的兴趣、好奇心与激情。这种影响旷日持久。
我们对 Ian 表示由衷的感谢。
我们在 Debian 的所有网站和和服务中用深色的主页旗帜广告及 logo 上的绶带表达了我们的反应和哀悼。在这段艰苦的时期,Debian 社区的关怀与 Ian 的家人同在。
他的家人希望保护他们的隐私,而我们也很愿意遵从他们的意愿。
在 Debian 社区内或 Linux 社区中的成员,可以将悼词发送至 [[email protected]](mailto:[email protected]) , 这些悼词将会被归档留存。
这个电子邮件地址将会在2016年1月末之前有效。而后 Debian 项目组将会将归档交给 Ian 的家人,若 Ian 的家人愿意,我们将在今年晚些时候公布其内容。
---
via: <https://www.debian.org/News/2016/20160105>
译者: [hittlle](https://github.com/hittlle), [StdioA](https://github.com/StdioA) 校对: [wxy](https://github.com/wxy)
| 200 | OK | # The Debian Project mourns the loss of Ian Murdock
**January 5th, 2016**
The Debian Project sadly announces that it has lost the founder of its community and project, Ian Murdock.
Debian is only a part of Ian's legacy but perhaps the one that he is most known for.
Ian was introduced to computers early in his life, and his curiosity turned to familiarity which led him to start actively programming at nine years of age. Later as a young adult at the Krannert School of Management a mandatory programming class rekindled his fascination with computer programming along with an idea and an opportunity to make something better.
Ian started the Debian Project in August of 1993, releasing the first
versions of Debian later that same year. At that time, the whole concept of a
distribution
of Linux was new. Inspired as he said by Linus Torvalds'
own sharing of Linux, he released Debian with the intention that this distribution
should be made openly, in the spirit of Linux and GNU.
With that simple gesture Ian started a movement in the world of software. Many developers joined him in this task of creating better software in a better world.
From his [Debian Manifesto](https://www.debian.org/doc/manuals/project-history/manifesto.en.html):
The Debian design process is open to ensure that the system is of the
highest quality and that it reflects the needs of the user community. By
involving others with a wide range of abilities and backgrounds, Debian
is able to be developed in a modular fashion. […]
Involving others also ensures that
valuable suggestions for improvement can be incorporated into the
distribution during its development; thus, a distribution is created
based on the needs and wants of the users rather than the needs and
wants of the constructor.
His sharp focus was on creating a distribution and community culture that did the right thing, be it ethically, or technically.
Releases went out when they were ready, and the project's staunch stance on Software Freedom was and is still a gold standard in the Free and Open Source world.
Debian 0.01 through Debian 0.90 were released between August and December of 1993. Ian Murdock writes:
Debian 0.91 was released in January 1994. It had a primitive package
system […]. By this time, there were a few dozen people working on
Debian,
though I was still mostly putting together the releases myself. 0.91 was the
last release done in this way.
Most of 1994 was spent organizing the Debian Project so that others
could more effectively contribute, as well as working on dpkg […].
Debian 0.93 Release 5 happened in March 1995 and was the first
"modern" release of Debian: there were many more developers by then (though I
can't remember exactly how many), each maintaining their own packages,
and dpkg was being used to install and maintain all these packages after
a base system was installed.
Debian 0.93 Release 6 happened in November 1995 and was the last
a.out
release. There were about sixty developers maintaining packages in
0.93R6. If I remember correctly, dselect first appeared in 0.93R6.
Ian Murdock also notes that Debian 0.93R6 … has always been my
favorite release of Debian
, although he admits to the possibility of
some personal bias, as he stopped actively working on the project in
March 1996.
Ian Murdock led Debian until March 1996, when he appointed Bruce Perens as the next leader of the project.
The devotion to the right thing guided Ian's work, both in Debian and in the subsequent years, always working towards the best possible future.
Debian would go on to become the world's Universal Operating System, found on
everything from the smallest embedded devices to the largest cluster
systems, to the Space Station because of course it runs Debian
which has been
ported across multiple architectures and types of hardware.
Ian's dream lives on: Debian is made up of a strong community that has fostered development, growth, and wonder. It remains incredibly active with thousands of developers working untold hours to bring the world a reliable and secure operating system. Debian has sparked the interest, curiosity, and passion of those who want to make something better. Then, now, and far into the future.
From the bottom of our hearts, we thank you Ian.
Throughout the Debian infrastructure our websites and services mark our reflection and mourning with a darkened homepage banner and ribbons on our logos. The thoughts of the Debian Community are with Ian's family in this difficult time.
His family has asked for privacy and we very much wish to respect their desires.
Within our Debian community and for the Linux community condolences may be sent
to [[email protected]](mailto:[email protected])
where they will be kept and archived.
This email address will be active until the end of January 2016. The Debian Project will then provide the archive to the family and publish the contents later this year if it is with the wishes of the family.
## About Debian
The Debian Project is an association of Free Software developers who volunteer their time and effort in order to produce a completely free operating system known as Debian.
## Contact Information
For further information, please visit the Debian web pages at
[https://www.debian.org/](../../) or send mail to
<[email protected]>. |
6,858 | 如何在 FreeBSD 10.2 上安装 Nginx 作为 Apache 的反向代理 | http://linoxide.com/linux-how-to/install-nginx-reverse-proxy-apache-freebsd-10-2/ | 2016-01-07T19:05:18 | [
"nginx",
"反向代理"
] | /article-6858-1.html | Nginx 是一款自由开源的 HTTP 和反向代理服务器,也可以用作 POP3/IMAP 的邮件代理服务器。Nginx 是一款高性能的 web 服务器,其特点是功能丰富,结构简单以及内存占用低。 第一个版本由 Igor Sysoev 发布于2002年,到现在有很多大型科技公司在使用,包括 Netflix、 Github、 Cloudflare、 WordPress.com 等等。
在这篇教程里我们会“**在 freebsd 10.2 系统上,安装和配置 Nginx 网络服务器作为 Apache 的反向代理**”。 Apache 将在8080端口上运行 PHP ,而我们会配置 Nginx 运行在80端口以接收用户/访问者的请求。如果80端口接收到用户浏览器的网页请求,那么 Nginx 会将该请求传递给运行在8080端口上的 Apache 网络服务器和 PHP。

#### 前提条件
* FreeBSD 10.2
* Root 权限
### 步骤 1 - 更新系统
使用 SSH 认证方式登录到你的 FreeBSD 服务器,使用下面命令来更新你的系统:
```
freebsd-update fetch
freebsd-update install
```
### 步骤 2 - 安装 Apache
Apache 是开源的、使用范围最广的 web 服务器。在 FreeBSD 里默认没有安装 Apache, 但是我们可以直接通过 /usr/ports/www/apache24 下的 ports 或软件包来安装,也可以直接使用 pkg 命令从 FreeBSD 软件库中安装。在本教程中,我们将使用 pkg 命令从 FreeBSD 软件库中安装:
```
pkg install apache24
```
### 步骤 3 - 安装 PHP
一旦成功安装 Apache,接着将会安装 PHP ,它来负责处理用户对 PHP 文件的请求。我们将会用到如下的 pkg 命令来安装 PHP:
```
pkg install php56 mod_php56 php56-mysql php56-mysqli
```
### 步骤 4 - 配置 Apache 和 PHP
一旦所有都安装好了,我们将会配置 Apache 运行在8080端口上, 并让 PHP 与 Apache 一同工作。 要想配置Apache,我们可以编辑“httpd.conf”这个配置文件, 对于 PHP 我们只需要复制 “/usr/local/etc/”目录下的 PHP 配置文件 php.ini。
进入到“/usr/local/etc/”目录,并且复制 php.ini-production 文件到 php.ini :
```
cd /usr/local/etc/
cp php.ini-production php.ini
```
下一步,在 Apache 目录下通过编辑“httpd.conf”文件来配置 Apache:
```
cd /usr/local/etc/apache24
nano -c httpd.conf
```
端口配置在第**52**行 :
```
Listen 8080
```
服务器名称配置在第**219**行:
```
ServerName 127.0.0.1:8080
```
在第**277**行,添加 DirectoryIndex 文件,Apache 将用它来服务对目录的请求:
```
DirectoryIndex index.php index.html
```
在第**287**行下,配置 Apache ,添加脚本支持:
```
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
```
保存并退出。
现在用 sysrc 命令,来添加 Apache 为开机启动项目:
```
sysrc apache24_enable=yes
```
然后用下面的命令测试 Apache 的配置:
```
apachectl configtest
```
如果到这里都没有问题的话,那么就启动 Apache 吧:
```
service apache24 start
```
如果全部完毕,在“/usr/local/www/apache24/data”目录下创建一个 phpinfo 文件来验证 PHP 在 Apache 下顺利运行:
```
cd /usr/local/www/apache24/data
echo "<?php phpinfo(); ?>" > info.php
```
现在就可以访问 freebsd 的服务器 IP : 192.168.1.123:8080/info.php 。

Apache 及 PHP 运行在 8080 端口。
### 步骤 5 - 安装 Nginx
Nginx 可以以较低内存占用提供高性能的 Web 服务器和反向代理服务器。在这个步骤里,我们将会使用 Nginx 作为Apache 的反向代理,因此让我们用 pkg 命令来安装它吧:
```
pkg install nginx
```
### 步骤 6 - 配置 Nginx
一旦 Nginx 安装完毕,在“**nginx.conf**”文件里,我们需要做一个新的配置文件来替换掉原来的 nginx 配置文件。切换到“/usr/local/etc/nginx/”目录下,并且备份默认 nginx.conf 文件:
```
cd /usr/local/etc/nginx/
mv nginx.conf nginx.conf.oroginal
```
现在就可以创建一个新的 nginx 配置文件了:
```
nano -c nginx.conf
```
然后粘贴下面的配置:
```
user www;
worker_processes 1;
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log;
sendfile on;
keepalive_timeout 65;
# Nginx cache configuration
proxy_cache_path /var/nginx/cache levels=1:2 keys_zone=my-cache:8m max_size=1000m inactive=600m;
proxy_temp_path /var/nginx/cache/tmp;
proxy_cache_key "$scheme$host$request_uri";
gzip on;
server {
#listen 80;
server_name _;
location /nginx_status {
stub_status on;
access_log off;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/local/www/nginx-dist;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:8080
#
location ~ \.php$ {
proxy_pass http://127.0.0.1:8080;
include /usr/local/etc/nginx/proxy.conf;
}
}
include /usr/local/etc/nginx/vhost/*;
}
```
保存并退出。
下一步,在 nginx 目录下面,创建一个 **proxy.conf** 文件,使其作为反向代理 :
```
cd /usr/local/etc/nginx/
nano -c proxy.conf
```
粘贴如下配置:
```
proxy_buffering on;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffers 100 8k;
add_header X-Cache $upstream_cache_status;
```
保存并退出。
最后一步,为 nginx 的高速缓存创建一个“/var/nginx/cache”的新目录:
```
mkdir -p /var/nginx/cache
```
### 步骤 7 - 配置 Nginx 的虚拟主机
在这个步骤里面,我们需要创建一个新的虚拟主机域“saitama.me”,其文档根目录为“/usr/local/www/saitama.me”,日志文件放在“/var/log/nginx”目录下。
我们必须做的第一件事情就是创建新的目录来存放虚拟主机配置文件,我们创建的新目录名为“**vhost**”。创建它:
```
cd /usr/local/etc/nginx/
mkdir vhost
```
创建好 vhost 目录,然后我们就进入这个目录并创建一个新的虚拟主机文件。这里我取名为“**saitama.conf**”:
```
cd vhost/
nano -c saitama.conf
```
粘贴如下虚拟主机的配置:
```
server {
# Replace with your freebsd IP
listen 192.168.1.123:80;
# Document Root
root /usr/local/www/saitama.me;
index index.php index.html index.htm;
# Domain
server_name www.saitama.me saitama.me;
# Error and Access log file
error_log /var/log/nginx/saitama-error.log;
access_log /var/log/nginx/saitama-access.log main;
# Reverse Proxy Configuration
location ~ \.php$ {
proxy_pass http://127.0.0.1:8080;
include /usr/local/etc/nginx/proxy.conf;
# Cache configuration
proxy_cache my-cache;
proxy_cache_valid 10s;
proxy_no_cache $cookie_PHPSESSID;
proxy_cache_bypass $cookie_PHPSESSID;
proxy_cache_key "$scheme$host$request_uri";
}
# Disable Cache for the file type html, json
location ~* .(?:manifest|appcache|html?|xml|json)$ {
expires -1;
}
# Enable Cache the file 30 days
location ~* .(jpg|png|gif|jpeg|css|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx)$ {
proxy_cache_valid 200 120m;
expires 30d;
proxy_cache my-cache;
access_log off;
}
}
```
保存并退出。
下一步,为 nginx 和虚拟主机创建一个新的日志目录“/var/log/”:
```
mkdir -p /var/log/nginx/
```
如果一切顺利,在文件的根目录下创建目录 saitama.me 用作文档根:
```
cd /usr/local/www/
mkdir saitama.me
```
### 步骤 8 - 测试
在这个步骤里面,我们只是测试我们的 nginx 和虚拟主机的配置。
用如下命令测试 nginx 的配置:
```
nginx -t
```
如果一切都没有问题,用 sysrc 命令添加 nginx 为开机启动项,并且启动 nginx 和重启 apache:
```
sysrc nginx_enable=yes
service nginx start
service apache24 restart
```
一切完毕后,在 saitama.me 目录下,添加一个新的 phpinfo 文件来验证 php 的正常运行:
```
cd /usr/local/www/saitama.me
echo "<?php phpinfo(); ?>" > info.php
```
然后访问这个域名: **[www.saitama.me/info.php](http://www.saitama.me/info.php)**。

Nginx 作为 Apache 的反向代理运行了,PHP 也同样工作了。
这是另一个结果:
测试无缓存的 .html 文件。
```
curl -I www.saitama.me
```

测试有三十天缓存的 .css 文件。
```
curl -I www.saitama.me/test.css
```

测试缓存的 .php 文件:
```
curl -I www.saitama.me/info.php
```

全部搞定。
### 总结
Nginx 是最受欢迎的 HTTP 和反向代理服务器,拥有丰富的功能、高性能、低内存/RAM 占用。Nginx 也用于缓存, 我们可以在网络上缓存静态文件使得网页加速,并且缓存用户请求的 php 文件。 Nginx 容易配置和使用,可以将它用作 HTTP 服务器或者 apache 的反向代理。
---
via: <http://linoxide.com/linux-how-to/install-nginx-reverse-proxy-apache-freebsd-10-2/>
作者:[Arul](http://linoxide.com/author/arulm/) 译者:[KnightJoker](https://github.com/KnightJoker) 校对:[Caroline](https://github.com/carolinewuyan),[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='linoxide.com', port=80): Max retries exceeded with url: /linux-how-to/install-nginx-reverse-proxy-apache-freebsd-10-2/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327581540>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,859 | DFileManager:封面流(CoverFlow)文件管理器 | http://gofk.tumblr.com/post/131014089537/dfilemanager-cover-flow-file-manager-a-real-gem | 2016-01-08T07:30:00 | [
"DFileManager",
"文件管理器"
] | https://linux.cn/article-6859-1.html | 
这个一个 Ubuntu 标准软件仓库中缺失的像宝石般的、有着其独特的功能的文件管理器。这是 DFileManager 在推特中的宣称。
有一个不好回答的问题,如何知道到底有多少个 Linux 的开源软件?好奇的话,你可以在 Shell 里输入如下命令:
```
~$ for f in /var/lib/apt/lists/*Packages; do printf '%5d %s\n' $(grep '^Package: ' "$f" | wc -l) ${f##*/} done | sort -rn
```
在我的 Ubuntu 15.04 系统上,产生结果如下:

正如上面的截图所示,在 Universe 仓库中,大约有39000个包,在 main 仓库中大约有8500个包。这听起来很多。但是这些包括了开源应用、工具、库,有很多不是由 Ubuntu 开发者打包的。更重要的是,有很多重要的软件不在库中,只能通过源代码编译。DFileManager 就是这样一个软件。它是仍处在开发早期的一个基于 QT 的跨平台文件管理器。QT提供单一源码下的跨平台可移植性。
现在还没有二进制文件包,用户需要编译源代码才行。对于一些工具来说,这个可能会产生很大的问题,特别是如果这个应用依赖于某个复杂的依赖库,或者需要与已经安装在系统中的软件不兼容的某个版本。
### 安装
幸运的是,DFileManager 非常容易编译。对于我的老 Ubutnu 机器来说,在开发者网站上的安装介绍提供了大部分的重要步骤,不过少量的基础包没有列出(为什么总是这样?虽然许多库会让文件系统变得一团糟!)。在我的系统上,从github 下载源代码并且编译这个软件,我在 Shell 里输入了以下命令:
```
~$ sudo apt-get install qt5-default qt5-qmake libqt5x11extras5-dev
~$ git clone git://git.code.sf.net/p/dfilemanager/code dfilemanager-code
~$ cd dfilemananger-code
~$ mkdir build
~$ cd build
~$ cmake ../ -DCMAKE_INSTALL_PREFIX=/usr
~$ make
~$ sudo make install
```
你可以通过在shell中输入如下命令来启动它:
```
~$ dfm
```
题图是运行中的 DFileManager,完全展示了其最吸引人的地方:<ruby> 封面流 <rp> ( </rp> <rt> Cover Flow </rt> <rp> ) </rp></ruby>视图。可以在当前文件夹的项目间滑动,提供了一个相当有吸引力的体验。这是看图片的理想选择。这个文件管理器酷似 Finder(苹果操作系统下的默认文件管理器),可能会吸引你。
### 特点:
* 4种视图:图标、详情、列视图和封面流
* 按位置和设备归类书签
* 标签页
* 简单的搜索和过滤
* 自定义文件类型的缩略图,包括多媒体文件
* 信息栏可以移走
* 单击打开文件和目录
* 可以排队 IO 操作
* 记住每个文件夹的视图属性
* 显示隐藏文件
DFileManager 不是 KDE 的 Dolphin 的替代品,但是能做相同的事情。这个是一个真正能够帮助人们的浏览文件的文件管理器。还有,别忘了反馈信息给开发者,任何人都可以做出这样的贡献。
---
via: <http://gofk.tumblr.com/post/131014089537/dfilemanager-cover-flow-file-manager-a-real-gem>
作者:[gofk](http://gofk.tumblr.com/) 译者:[bestony](https://github.com/bestony) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,860 | 黑客们成功地在土豆上安装了 Linux ! | http://www.bbspot.com/news/2008/12/linux-on-a-potato.html | 2016-01-08T08:30:00 | [] | https://linux.cn/article-6860-1.html | 来自荷兰阿姆斯特丹的消息称,LinuxOnAnything.nl 网站的黑客们成功地在土豆上安装了 Linux!这是该操作系统第一次在<ruby> 根用蔬菜 <rp> ( </rp> <rt> root vegetable </rt> <rp> ) </rp></ruby>上安装成功(LCTT 译注:root vegetable,一语双关,root 在 Linux 是指超级用户)。

“土豆没有 CPU,内存和存储器,这真的是个挑战,” Linux On Anything (LOA) 小组的 Johan Piest 说。“显然我们不能使用一个像 Fedora 或 Ubuntu 这些体量较大的发行版,所以我们用的是 Damn Small Linux(一个超小型的 Linux)。”
在尝试了几周之后,LOA 小组的同学们弄出了一个适合土豆的 Linux 内核,这玩艺儿上面可以用 vi 来编辑小的文本文件。这个 Linux 通过一个小型的 U 盘加载到土豆上,并通过一组红黑线以二进制的方式向这个土豆发送命令。
LOA 小组是一个不断壮大的黑客组织的分支,这个组织致力于将 Linux 安装到所有物体上;他们先是将 Linux 装到 Gameboy 和 iPod 等电子产品上,不过最近他们在挑战一些高难度的东西,譬如将 Linux 安装到灯泡和小狗身上!
LOA 小组在与另一个黑客小组 Stuttering Monarchs (结巴王)竞赛,看谁先拿到土豆这一分。“土豆是一种每个人都会接触到的蔬菜,它的用途就像 Linux 一样极其广泛。无论你是想煮捣烹炸还是别的都可以” ,Piest 说道,“你也许认为我们完成这个挑战是为了获得某些好处,而我们只是追求逼格而已。”
LOA 是第一个将 Linux 安装到一匹设德兰矮种马上的小组,但这五年来竞争愈演愈烈,其它黑客小组的进度已经反超了他们。
“我们本来可以成为在饼干上面安装 Linux 的第一个小组,但是那群来自挪威的混蛋把我们击败了。” Piest 说。
第一个成功安装了 Linux 的蔬菜是一头卷心菜,它是由一个土耳其的一个黑客小组完成的。
(好啦——是不是已经目瞪口呆,事实上,这是一篇好几年前的恶搞文,你看出来了吗?哈哈哈哈)
---
via: <http://www.bbspot.com/news/2008/12/linux-on-a-potato.html>
作者:[Brian Briggs](file:///Users/wangxingyu/Develop/LCTT/TranslateProject/translated/share/[email protected]) 译者:[StdioA](https://github.com/StdioA), [hittlle](https://github.com/hittlle) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,876 | 问卷:您的意见将指导自由软件运动的发展方向! | http://www.fsf.org/news/whats-your-vision-for-the-fsf-fill-out-our-survey-1 | 2016-01-12T08:00:00 | [
"FSF"
] | /article-6876-1.html | 2015年,<ruby> 自由软件基金会 <rp> ( </rp> <rt> Free Software Foundation </rt> <rp> ) </rp></ruby>(FSF)[度过了其三十岁生日](/article-6384-1.html)。这三十年来,FSF 积极地站在捍卫和推进计算机用户权利的前沿,做出了不可磨灭的贡献。这三十年来,自由软件社区以及 FSF ,已经将<ruby> 自由软件 <rp> ( </rp> <rt> free software </rt> <rp> ) </rp></ruby>的理念传播到了全世界,并得到了社区以及整个网络上的普遍认知。

为了指导 FSF 接下来五年的发展方向,FSF 特地发起了一个投票(兼募捐),希望能听到社区的声音,将您的观点和建议展示给 FSF,共创更加辉煌的未来。
请移步 <https://www.fsf.org/survey?pk_campaign=survey-launch&pk_kwd=survey> 填写调查问卷。
同时,为了方便中国的自由软件运动关注者,我们也对该问卷的内容做了一份翻译,列于下面供参考,如有不当之处敬请指出:
---
>
> FSF 愿景调查
> --------
>
>
> 通过这份问卷调查,您将帮助 FSF 更好的了解自由软件运动的优先事项、需求和关注点。它也许会占用您5到15分钟的时间。本问卷的最终截止时间是北京时间 2016/2/2 凌晨 1:00。
>
>
> 此问卷调查是匿名的(如果没有在最后填入您的邮箱地址)。不管是否匿名,我们都会重视您的意见。我们还是希望能够获得您的联系方式,以防需要跟您进行进一步的沟通。
>
>
> 本问卷一旦开始就不应该停止和重新开始,所有的内容都需要一次完成。所有的问题都可以跳过。您可以随时跳过那些您不关心的问题。十分感谢您的支持。
>
>
> ### FSF 和自由软件
>
>
> ##### 您认为在未来的5年,FSF 应该关注的重点是(最多选择3项):
>
>
> * ☐ 网络自由:自由的 JavaScript,网络中立,推进去中心化的网络服务和抵制“<ruby> <a href="https://www.gnu.org/philosophy/who-does-that-server-really-serve.html"> 服务即软件替代 </a> <rp> ( </rp> <rt> Service as a Software Substitute </rt> <rp> ) </rp></ruby>”(SaaSS)
> * ☐ Copyleft:推广使用类似 GNU GPL 的 copyleft 许可证,而不是更宽松的自由软件许可证,并贯彻 执行 GPL
> * ☐ 监控和安全:使用自由软件以防止大范围的监控,并确保自由软件是安全的
> * ☐ DRM:终结<ruby> 数字版权保护 <rp> ( </rp> <rt> Digital Restrictions Management </rt> <rp> ) </rp></ruby>(DRM),让它从网上滚蛋
> * ☐ 许可证指导:帮助开发人员了解和使用自由许可证,并告诉他们哪个许可证最适合他们
> * ☐ 软件专利:终结(而不只是改革)软件专利
> * ☐ 开发:帮助 GNU 项目和其他项目编写新的软件和改进现有软件
> * ☐ 团队建设:增加多样性,让自由软件中的少数派也能够发声
> * ☐ 硬件:帮助或提振可以 100% 运行自由软件的硬件开发,特别是在移动/嵌入式领域
> * ☐ 采用:帮助个人或团体去使用自由软件
>
>
> ### 评价以下的内容
>
>
> ##### FSF 是自由软件运动的正面典型
>
>
> * ☐ 强烈反对 ☐ 不同意 ☐ 既不同意也不反对 ☐ 同意 ☐ 强烈同意
>
>
> ##### 来自 FSF 的邮件太多
>
>
> * ☐ 强烈反对 ☐ 不同意 ☐ 既不同意也不反对 ☐ 同意 ☐ 强烈同意
>
>
> ##### FSF 的在线资料缺乏吸引力且不够人性化
>
>
> * ☐ 强烈反对 ☐ 不同意 ☐ 既不同意也不反对 ☐ 同意 ☐ 强烈同意
>
>
> ##### FSF 在促进自由软件社区中的多样性和少数派方面做了不少工作
>
>
> * ☐ 强烈反对 ☐ 不同意 ☐ 既不同意也不反对 ☐ 同意 ☐ 强烈同意
>
>
> ##### FSF 偕同其他的组织在为计算机用户权益方面的广泛运动做了很好的工作
>
>
> * ☐ 强烈反对 ☐ 不同意 ☐ 既不同意也不反对 ☐ 同意 ☐ 强烈同意
>
>
> ##### FSF 需要更妥协一些
>
>
> * ☐ 强烈反对 ☐ 不同意 ☐ 既不同意也不反对 ☐ 同意 ☐ 强烈同意
>
>
> ##### FSF 有效地使用了收到的捐款
>
>
> * ☐ 强烈反对 ☐ 不同意 ☐ 既不同意也不反对 ☐ 同意 ☐ 强烈同意
>
>
> ##### FSF 整体运作良好
>
>
> * ☐ 强烈反对 ☐ 不同意 ☐ 既不同意也不反对 ☐ 同意 ☐ 强烈同意
>
>
> ##### 回顾过去30年,自由软件运动已经成功的实现了目标
>
>
> * ☐ 强烈反对 ☐ 不同意 ☐ 既不同意也不反对 ☐ 同意 ☐ 强烈同意
>
>
> ##### 自由软件对于新手来说太过混乱,对于自由软件的开发来说,易用性应该优先考虑
>
>
> * ☐ 强烈反对 ☐ 不同意 ☐ 既不同意也不反对 ☐ 同意 ☐ 强烈同意
>
>
> ##### 假想到2020年,因为自由软件运动和 FSF 的努力,人们在使用计算机方面拥有更多的自由和权力。说说为了达成这一目标,我们应该做些什么。
>
>
> *
>
>
> ##### 假想到2020年,事实恰恰相反——我们作为计算机用户并不是那么自由。说说我们在哪些地方将会做错。
>
>
> *
>
>
> ##### 哪个社会运动或组织是您所乐见我们与之通力协作的。
>
>
> *
>
>
> ### 关于您
>
>
> ##### 过去您是否以以下一种方式参与到 FSF,请选择相应的选项
>
>
> * ☐ 志愿者,工作人员或者是董事会成员
> * ☐ 准成员
> * ☐ 非会员的捐助
> * ☐ 在网络上关注(网站,邮件,社交媒体)
> * ☐ 关注我们的消息
>
>
> ##### 如果您在网络上关注我们,请选择相应的选项
>
>
> * ☐ Email(包括每月的通报: Free Software Supporter)
> * ☐ 博客文章(fsf.org/blogs)
> * ☐ 新闻稿和新闻公告(fsf.org/news)
> * ☐ RSS 源
> * ☐ 除 twitter 外的社交媒体和新闻平台(GNU/social、Pump.io、Reddit 等)
> * ☐ Twitter
>
>
> ##### 如果您支持 FSF 的工作(在任何方面),请告知我们您的主要理由,选择相应的选项
>
>
> * ☐ 我想要支持自由软件的开发
> * ☐ 我想要支持自由软件理念的行动和宣讲
> * ☐ 我关注 GPL 的贯彻执行
> * ☐ 我使用 GNU 软件且想要给予回馈
>
>
> ##### 如果您之前有捐赠我们或是我们的成员,但是现在却不再继续了,请告知原因
>
>
> *
>
>
> ##### 为什么自由软件对你很重要,为什么你选择使用它
>
>
> *
>
>
> ##### 如何形容您参与自由软件的主要方式(以及对 FSF 感兴趣的地方),选择相应的选项
>
>
> * ☐ 我是自由软件的开发者
> * ☐ 我在文档,设计,测试,翻译或者是其他方面为自由软件开发提供帮助
> * ☐ 我使用自由软件
> * ☐ 我是自由软件的积极分子
>
>
> ##### 你为软件开发付过费没有(无论是自由软件还是其它)
>
>
> * ☐ 是 ☐ 否
>
>
> ##### 详细描述你的回答,无论是正面或负面的反馈,都可以在这里填写
>
>
> *
>
>
> ### 统计
>
>
> ##### 性别
>
>
> *
>
>
> ##### 生日
>
>
> *
>
>
> ### 联系信息
>
>
> ##### 是否介意 FSF 在公开著述中匿名引用您的文字?
>
>
> * ☐ 可能介意,请先联系我(假如没有登录,需要留下您的邮箱)
> * ☐ 介意
> * ☐ 不介意
>
>
> ##### 你希望加入我们的低频率邮件列表,接收我们的每月通报吗?
>
>
> (如果你没有登录,需要输入你的邮件地址) ☐ 登记
>
>
> ##### (可选)邮件地址。这将让你调查结果不再匿名
>
>
> *
>
>
>
**注意:以上译文仅供你在提交[调查问卷](https://www.fsf.org/survey?pk_campaign=survey-launch&pk_kwd=survey)时参考,此处并不具备问卷提交功能,请访问 [FSF 的问卷地址](https://www.fsf.org/survey?pk_campaign=survey-launch&pk_kwd=survey)提交。**
最后,提交完问卷之后,FSF 建议你考虑捐赠或付费注册成为会员,以支持 FSF 的工作。
| null | HTTPConnectionPool(host='www.fsf.org', port=80): Max retries exceeded with url: /news/whats-your-vision-for-the-fsf-fill-out-our-survey-1 (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327582b60>, 'Connection to www.fsf.org timed out. (connect timeout=10)')) | null |
6,878 | Ubuntu 里的“间谍软件”将在 Ubuntu 16.04 LTS 中被禁用 | http://www.omgubuntu.co.uk/2016/01/ubuntu-online-search-feature-disabled-16-04 | 2016-01-13T07:40:00 | [
"Ubuntu",
"搜索"
] | https://linux.cn/article-6878-1.html |
>
> 出于用户隐私的考虑,Ubuntu 阉割了一个有争议的功能。
>
>
>

**Unity 中有争议的在线搜索功能将在今年四月份发布的 Ubuntu 16.04 LTS 中被默认禁用**
用户在 Unity 7 的 Dash 搜索栏里将**只能搜索到本地文件、文件夹以及应用**。这样,用户输入的关键词将不会被发送到 Canonical 或任何第三方内容提供商的服务器里。
>
> “现在,Unity 的在线搜索在默认状况下是关闭的”
>
>
>
在目前 ubuntu 的支持版本中,Dash 栏会将用户搜索的关键词发送到 Canonical 运营的远程服务器中。它发送这些数据以用于从50多家在线服务获取搜索结果,这些服务包括维基百科、YouTube 和 The Weather Channel 等。
我们可以选择去**系统设置 > 隐私控制**关闭这项功能。但是,一些开源社区针对的是默认打开这个事情。
### Ubuntu 在线搜索引发的争议
>
> “Richard Stallman 将这个功能描述为 ‘间谍软件’”
>
>
>
早在2012年,在 Ubuntu 搜索中整合了来自亚马逊的内容之后,开源社区就表示为其用户的隐私感到担忧。在2013年,“Smart Scopes 服务”全面推出后,开源社区再度表示担忧.
风波如此之大,以至于开源界大神 [Richard Stallman 都称 Ubuntu 为"间谍软件"](http://arstechnica.com/information-technology/2012/12/richard-stallman-calls-ubuntu-spyware-because-it-tracks-searches/?utm_source=omgubuntu)。
[电子前哨基金会 (EFF)](https://www.eff.org/deeplinks/2012/10/privacy-ubuntu-1210-amazon-ads-and-data-leaks?utm_source=omgubuntu)也在一系列博文中表达出对此的关注,并且建议 Canonical 将这个功能做成用户自由选择是否开启的功能。Privacy International 比其他的组织走的更远,对于 Ubuntu 的工作,他们给 Ubuntu 的缔造者发了一个“[老大哥奖](http://www.omgubuntu.co.uk/2013/10/ubuntu-wins-big-brother-austria-privacy-award)”。
[Canonical](http://blog.canonical.com/2012/12/07/searching-in-the-dash-in-ubuntu-13-04/) 坚称 Unity 的在线搜索功能所收集的数据是匿名的以及“不可识别是来自哪个用户的”。
在[2013年 Canoical 发布的博文中](http://blog.canonical.com/2012/12/07/searching-in-the-dash-in-ubuntu-13-04/?utm_source=omgubuntu)他们解释道:“**(我们)会使用户了解我们收集哪些信息以及哪些第三方服务商将会在他们搜索时从 Dash 栏中给出结果。我们只会收集能够提升用户体验的信息。**”
### Ubuntu 开始严肃对待的用户数据隐私
Canonical 在给新安装的 Ubuntu 14.04 LTS 以及以上版本中禁用了来自亚马逊的产品搜索结果(尽管来自其他服务商的搜索结果仍然在出现,直到你关闭这个选项)
在下一个LTS(长期支持)版,也就是 Ubuntu 16.04 中,Canonical 完全关闭了这个有争议的在线搜索功能,这个功能在用户安装完后就是关闭的。就如同 EFF 在2012年建议他们做的那样。
“你搜索的关键词将不会逃出你的计算机。” [Ubuntu 桌面主管 Will Cooke](http://www.whizzy.org/2015/12/online-searches-in-the-dash-to-be-off-by-default?utm_source=omgubuntu)解释道,“对于搜索结果的更精细的控制”和 Unity 8 所提供的“更有针对性的结果添加不到 Unity 7 里”。
这也就是“(Unity 7)的在线搜索功能将会退役”的原因。
这个变化也会降低对 Unity 7 的支持以及对 Canonical 基础设施的压力。Unity 提供的搜索结果越少,Canonical 就能把时间和工程师放到更加振奋人心的地方,比如更早的发布 Unity 8 桌面环境。
### 在 Ubuntu 16.04 中你需要自己开启在线搜索功能

*在 Ubuntu 隐私设置中你可以打开在线搜索功能*
禁用 Ubuntu 桌面的在线搜索功能的决定将获得众多开源/免费软件社区的欢呼。但是并不是每一个人都对 Dash 提供的语义搜索功能反感,如果你认为你失去了在搜索时预览天气、查看新闻或其他来自 Dash 在线搜索提供的内容所带来的效率的话,你只需要简单的点几下鼠标就可以**再次打开这个功能**,定位到 Ubuntu 的**系统设置 > 隐私控制 > 搜索**然后将选项调至“**开启**”。
这个选项不会自动把亚马逊的产品信息加入到搜索结果中。如果你想看产品信息的话,需要打开第二个可选项“shipping lens”才能看到来自 Amazon (和 Skimlinks)的内容。
### 总结
* 默认情况下,Ubuntu 16.04 LTS 的 Dash 栏将不会搜索到在线结果
* 可以手动打开在线搜索
* **系统设置 > 隐私控制 > 搜索**中的第二个可选项允许你看到亚马逊的产品信息
* 这个变动只会影响新安装的系统。从老版本升级的将会保留用户的喜好
你同意这个决定吗?抑或是 Cononical 可能降低了新用户的体验?在评论中告诉我们。
---
via: <http://www.omgubuntu.co.uk/2016/01/ubuntu-online-search-feature-disabled-16-04>
作者:[Joey-Elijah Sneddon](https://plus.google.com/117485690627814051450/?rel=author) 译者:[name1e5s](https://github.com/name1e5s) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,879 | 开源 DJ 软件 Mixxx 2.0 版发布 | http://itsfoss.com/dj-mixxx-2/ | 2016-01-13T09:35:58 | [
"DJ",
"Mixxx",
"音乐"
] | https://linux.cn/article-6879-1.html | 
时隔三年,开源 DJ 混音软件 [Mixxx](http://mixxx.org/) 再度发布一个大的版本更新----Mixxx 2.0。
Mixxx 是一个跨平台的自由、开源的 DJ 混音软件,它几乎提供了当你想自己混音时需要的一切功能。Mixxx 近几年在专业人士以及业余爱好者中都很火。
甚至在 Mixxx 中你能使用你的 iTunes 音乐库。它的强有力的引擎使它支持多种文件格式。Mixxx 默认即支持超过85种MIDI DJ 调节器以及少部分 HID 调节器。它也包含一个自动选项,可以让你在混音时休息一下。
Mixxx 的完整功能列表可以在[这里](http://mixxx.org/features/)找到。在查看完整列表之前,让我们看看最新版有何更新。
### Mixxx 2.0更新
* 可动态调整大小的外观
* 4 轨道混音并且和主轨道同步
* 内置特效
* 谐波混频(Harmonic Mixing)与音乐按键检测
* RGB 音频波形
* 4 个麦克风输入和 4 个音频输入,麦克风音量可调
* 黑胶音源输入、输出
* 支持自定义封面
* 核心混音引擎改进
* 更新的音乐库
* 改进增强了 DJ 调节器
你可以在[这里](http://mixxx.org/whats-new-in-mixxx-2-0/)中看到所有的新功能。
### 在基于 Ubuntu 的发行版中安装 Mixxx 2.0
Mixxx 提供了他们自己的ppa源,这使得在基于 Ubuntu 的发行版,如 Linux Mint、elementary OS、 Zorin OS 上安装Mixxx 2.0 变得十分简单.
打开终端,并输入如下命令:
```
sudo add-apt-repository ppa:mixxx/mixxx
sudo apt-get update
sudo apt-get install mixxx
```
使用如下命令卸载 Mixxx:
```
sudo apt-get remove mixxx
sudo add-apt-repository --remove ppa:mixxx/mixxx
```
如果你已经在使用旧版本的 Mixxx。它将很快升级到2.0版。
### 在其他发行版中安装 Mixxx 2.0
Archliunx
```
sudo pacman -S mixxx
```
对于其他发行版,你还可以从源码编译安装 Mixxx。从下列地址下载源代码:
* [源码地址](http://downloads.mixxx.org/mixxx-2.0.0/mixxx-2.0.0-src.tar.gz)
由于 Mixxx 是个跨平台的应用,你也可以下载它的 Windows 版或者 Mac OS 版,请访问 Mixxx 下载页面找到对应的下载链接:
* [下载地址](http://mixxx.org/download/)
---
via: <http://itsfoss.com/dj-mixxx-2/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[name1e5s](https://github.com/name1e5s) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,880 | 错误:无法与 SFTP 服务器建立 FTP 连接 | http://itsfoss.com/fix-establish-ftp-connection-sftp-server/ | 2016-01-13T09:42:14 | [
"FTP",
"SFTP"
] | https://linux.cn/article-6880-1.html | ### 问题
有一天我要连接到我的 web 服务器。我使用 [FileZilla](https://filezilla-project.org/) 连接到 FTP 服务器。当我输入主机名和密码连接服务器后,我得到了下面的错误。
>
> Error: Cannot establish FTP connection to an SFTP server. Please select proper protocol.
>
>
> Error: Critical error: Could not connect to server
>
>
>

### 原因
看见错误信息后我意识到了我的错误是什么。我尝试与一台 **SFTP** 服务器建立一个 **[FTP](https://en.wikipedia.org/wiki/File_Transfer_Protocol)** 连接。很明显我没有使用一个正确的协议(应该是SFTP而不是FTP)。
如你在上图所见,FileZilla 默认使用的是FTP协议。
### 解决 “Cannot establish FTP connection to an SFTP server” 的方案
解决方案很简单。使用 SFTP 协议而不是 FTP。你要做的就是把协议修改成 SFTP。这就是我要告诉你的。
在 FileZilla 菜单中,进入 **文件->站点管理**。

在站点管理中,进入通用选项并选择 SFTP 协议。同样填上主机、端口号、用户密码等。

我希望你从这里可以开始工作了。
我希望本篇教程可以帮助你修复 “Cannot establish FTP connection to an SFTP server. Please select proper protocol.”这个问题。在相关的文章中,你可以读[了解在 Linux 中如何设置 FTP](http://itsfoss.com/set-ftp-server-linux/)。
---
via: <http://itsfoss.com/fix-establish-ftp-connection-sftp-server/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,881 | awk & sed ,一个老派系统管理员的基本素养 | http://www.infoworld.com/article/2985804/linux/remember-sed-awk-linux-admins-should.html | 2016-01-13T14:08:00 | [
"awk",
"sed"
] | https://linux.cn/article-6881-1.html | 
*图片来源: Shutterstock*
**我们不要让下一代 Linux 和 Unix 的管理员忘记初始化脚本和基本工具的好处**
我曾经有一次在 Reddit 看到一个帖子,“[请问如何操作文本文件](https://www.reddit.com/r/linuxadmin/comments/3lwyko/how_do_i_remove_every_occurence_of_duplicate_line/)”。这是一个很简单的需求,就像我们常用 Unix 的人每天遇到的一样。他的问题是,如何删除文件中的重复行,只保留不重复的。 这听起来似乎很简单,但是当文件足够大时,就会有些复杂。
这个问题有很多种不同的答案。你可以使用几乎任何一种语言来写这样的一个脚本,只是时间的投入和代码的复杂性不同罢了。根据你的个人水平,它大概会花费20-60分钟。但是如果你使用了 Perl、Python、Ruby 中的一种,你可能很快实现它。
或者你可以使用下面的一个方法,让你无比暖心的: 只用 awk。
这个答案是迄今为止最简明、最简单的解决问题的方法。它只要一行!
```
awk '!seen[$0]++' <filename>
```
让我们来看看发生了什么:
在这个命令中,其实隐藏了很多代码。awk 是一种文本处理语言,并且它内部有很多预设。首先,你看到的实际上是一个 for 循环的结果。awk 假定你想通过循环处理输入文件的每一行,所以你不需要明确的去指定它。awk 还假定了你需要打印输出处理后的数据,所以你也不需要去指定它。最后,awk 假定循环在最后一句指令执行完结束,这一块也不再需要你去指定它。
这个例子中的字符串 seen 是一个关联数组的名字。$0 是一个变量,表示整个当前行。所以,这个命令翻译成人类语言就是“对这个文件的每一行进行检查,如果你之前没有见过它,就打印出来。” 如果该关联数组的键名还不存在就添加到数组,并增加其取值,这样 awk 下次遇到同样的行时就会不匹配(条件判断为“假”),从而不打印出来。
>
> 据微博上 [@ZorroLang](http://weibo.com/3246109510 "ZorroLang") 的补充:少提了一个重点,要不然只会 C 语言的人很难理解为什么 seen[$0]++ 一行代码就行了,这里隐含了 awk 对于其数组变量的处理方式。awk 的数组是关联数组,且不需要声明,而是引用即创建,注意是创建,后面都不会消失的。也就是你像 str[any] 这样随便写一个数组变量,这个数组元素就此就创建了,且初始化为0或空。
>
>
> 谢谢 [@ZorroLang](http://weibo.com/3246109510 "ZorroLang") ~
>
>
>
一些人认为这样是优雅的,另外的人认为这可能会造成混淆。任何在日常工作上使用 awk 的都是第一类人。awk 就是设计用来做这个的。在 awk 中,你可以写多行代码。你甚至可以[用 awk 写一些让人不安的复杂功能](http://intro-to-awk.blogspot.com/2008/08/awk-more-complex-examples.html)。但终究来说,awk 还是一个进行文本处理的程序,一般是通过管道。去掉(没必要的)循环定义是很常见的快捷用法,不过如果你乐意,你也可以用下面的代码做同样的事情:
```
awk '{ if (!seen[$0]) print $0; seen[$0]++ }’
```
这会产生相同的结果。
awk 是完成这项工作的完美工具。不过,我相信很多管理员--特别是新管理员会转而使用 [Bash](http://www.infoworld.com/article/2613338/linux/linux-how-to-script-a-bash-crash-course.html) 或 Python 来完成这一任务,因为对 awk 的知识和对它的能力的了解看起来随着时间而慢慢被人淡忘。我认为这是标志着一个问题,由于对之前的解决方案缺乏了解,那些已经解决了几十年的问题又突然出现了。
shell、grep、sed 和 awk 是 Unix 的基础。如果你不能非常轻松的使用它们,你将会被自己束缚住,因为它们构成了通过命令行和脚本与 Unix 系统交互的基础。学习这些工具如何工作最好的方法之一就是观察真实的例子和实验,你可以在各种 Unix 衍生系统的初始化系统中找到很多,但在 Linux 发行版中它们已经被 [systemd](http://www.infoworld.com/article/2608798/data-center/systemd--harbinger-of-the-linux-apocalypse.html) 取代了。
数以百万计的 Unix 管理员了解 Shell 脚本和 Unix 工具如何读、写、修改和用在初始化脚本上。不同系统的初始化脚本有很大不同,甚至是不同的 Linux 发行版也不同。但是它们都源自 sh,而且它们都用像 sed、awk 还有 grep 这样的核心的命令行工具。
我每天都会听到很多人抱怨初始化脚本太“古老”而且很“难”。但是实际上,初始化脚本和 Unix 管理员每天使用的工具一样,还提供了一个非常好的方式来更加熟悉和习惯这些工具。说初始化脚本难于阅读和难于使用实际上是承认你缺乏对 Unix 基础工具的熟悉。
说起在 Reddit 上看到的内容,我也碰到过这个问题,来自一个新入行的 Linux 系统管理员, “[问他是否应该还要去学老式的初始化系统 sysvinit](https://www.reddit.com/r/linuxadmin/comments/3ltq2y/when_i_start_learning_about_linux_administration/)”。 这个帖子的大多数的答案都是正面的——是的,应该学习 sysvinit 和 systemd 两个。一位评论者甚至指出,初始化脚本是学习 Bash 的好方法。而另一个消息是,Fortune 50 强的公司还没有计划迁移到以 systemd 为基础的发行版上。
但是,这提醒了我这确实是一个问题。如果我们继续沿着消除脚本和脱离操作系统核心组件的方式发展下去,由于疏于接触,我们将会不经意间使新管理员难于学习基本的 Unix 工具。
我不知道为什么有些人想在一层又一层的抽象化来掩盖 Unix 内部,但是这样发展下去可能会让新一代的系统管理员们变成只会按下按钮的工人。我觉得这不是一件好事情。
---
via: <http://www.infoworld.com/article/2985804/linux/remember-sed-awk-linux-admins-should.html>
作者:[Paul Venezia](http://www.infoworld.com/author/Paul-Venezia/) 译者:[Bestony](https://github.com/Bestony) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,882 | 如何在 Ubuntu 上使用 Glances 监控系统 | https://www.maketecheasier.com/glances-monitor-system-ubuntu/ | 2016-01-14T09:28:00 | [
"Glances",
"监控"
] | https://linux.cn/article-6882-1.html | 
Glances 是一个用于监控系统的跨平台、基于文本模式的命令行工具。它是用 Python 编写的,使用 `psutil` 库从系统获取信息。你可以用它来监控 CPU、平均负载、内存、网络接口、磁盘 I/O,文件系统空间利用率、挂载的设备、所有活动进程以及消耗资源最多的进程。Glances 有很多有趣的选项。它的主要特性之一是可以在配置文件中设置阀值(<ruby> careful <rp> ( </rp> <rt> 小心 </rt> <rp> ) </rp></ruby>、<ruby> warning <rp> ( </rp> <rt> 警告 </rt> <rp> ) </rp></ruby>、<ruby> critical <rp> ( </rp> <rt> 致命 </rt> <rp> ) </rp></ruby>),然后它会用不同颜色显示信息以表明系统的瓶颈。
### Glances 的功能
* CPU 平均负载
* 不同状态(如活动、休眠)进程的数量
* 所有内存信息,如物理内存、交换空间、空闲内存
* CPU 信息
* 网络连接的上行/下行速度
* 磁盘 I/O 读/写速度详细信息
* 当前挂载设备的磁盘使用情况
* 消耗资源最多的进程和他们的 CPU/内存使用情况
### 安装 Glances
Glances 在 Ubuntu 的软件仓库中,所以安装很简单。执行下面的命令安装 Glances:
```
sudo apt-get install glances
```
(LCTT 译注:若安装后无法正常使用,可考虑使用 pip 安装/升级 glances:`sudo pip install --upgrade glances`)
### Glances 使用方法
安装完成后,可以执行下面的命令启动 Glances:
```
glances
```
你将看到类似下图的输出:

要退出 Glances 终端,按 ESC 键或 `Ctrl + C`。
默认情况下,时间间隔(LCTT 译注:显示数据刷新的时间间隔)是 1 秒,不过你可以在从终端启动 Glances 时自定义时间间隔。
要把时间间隔设为 5 秒,执行下面的命令:
```
glances -t 5
```
### Glances 中不同颜色含义
Glances 中不同颜色的含义:
* `绿色`:正常(OK)
* `蓝色`:小心(careful)
* `紫色`:警告(warning)
* `红色`:致命(critical)
默认设置下,Glances 的阀值设置是:careful=50,warning=70,critical=90。你可以通过 “/etc/glances/” 目录下的默认配置文件 glances.conf 来自定义这些阀值。
### Glances 的选项
Glances 提供了很多快捷键,可以在它运行时用来查找输出信息。
下面是一些常用的热键列表:
* `m` : 按内存占用排序进程
* `p` : 按进程名称排序进程
* `c` : 按 CPU 占用率排序进程
* `i` : 按 I/O 频率排序进程
* `a` : 自动排序进程
* `d` : 显示/隐藏磁盘 I/O 统计信息
* `f` : 显示/隐藏文件系统统计信息
* `s` : 显示/隐藏传感器统计信息
* `y` : 显示/隐藏硬盘温度统计信息
* `l` : 显示/隐藏日志
* `n` : 显示/隐藏网络统计信息
* `x` : 删除警告和严重日志
* `h` : 显示/隐藏帮助界面
* `q` : 退出
* `w` : 删除警告记录
### 使用 Glances 监控远程系统
你也可以使用 Glances 监控远程系统。要在远程系统上使用它,使用下面的命令:
```
glances -s
```
你会看到类似下面的输出:

如你所见,Glances 运行在 61209 端口。
现在,到远程机器上执行下面的命令以连接到指定 IP 地址的 Glances 服务器上。假设 192.168.1.10 是你的 Glances 服务器 IP 地址。
```
glances -c -P 192.168.1.10
```
### 结论
对于每个 Linux 系统管理员来说,Glances 都是一个非常有用的工具。使用它,你可以轻松、高效地监控 Linux 系统。如果你有什么问题,自由地评论吧。
---
via: <https://www.maketecheasier.com/glances-monitor-system-ubuntu/>
作者:[Hitesh Jethva](https://www.maketecheasier.com/author/hiteshjethva/) 译者:[bianjp](https://github.com/bianjp) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | Glances is a cross-platform command-line text-based tool to monitor your system. It is written in Python language and uses the `psutil`
library to get information from the system. Using it you can monitor CPU, Load Average, Memory, Network Interfaces, Disk I/O, File System spaces utilization, mounted devices, total number of active processes and top processes. There are many interesting options available in Glances. One of the main features is that you can set thresholds (careful, warning and critical) in a configuration file, and information will be shown in colors which indicates the bottleneck in the system.
## Glances Features
- the average CPU load
- total number of processes like active, sleeping processes, etc.
- total memory information like RAM, swap, free memory, etc.
- CPU information
- Network download and upload speed of connections
- Disk I/O read/write speed details
- Currently mounted devices’ disk usages
- Top processes with their CPU/memory usages
## Installing Glances
Installing Glances on Ubuntu is easy, as it is available on Ubuntu’s repository. You can install Glances by running the following command.
sudo apt-get install glances
## Usage of Glances
After installation has been finished, you can launch Glances by running the following command:
glances
You will see an output like the following:
Press ESC or “Ctrl + C” to quit from the Glances terminal.
By default, the interval time is set to 1 second, but you can define the custom interval time while running glances from the terminal.
To set the interval time to 5 seconds, run the following command:
glances -t 5
## Glances Color Codes
Glances color code meanings:
`GREEN`
: OK`BLUE`
: CAREFUL`VIOLET`
: ALERT`RED`
: CRITICAL
By default, Glances thresholds set is: careful=50, warning=70, critical=90. You can customize the threshold by using the default configuration file `glances.conf`
located at the “/etc/glances/” directory.
## Glances Options
Glances provides several hot keys to find output information while it is running.
Below are the list of hot keys.
`m`
: sort processes by MEM%
`p`
: sort processes by name
`c`
: sort processes by CPU%
`d`
: show/hide disk I/O stats
`a`
: sort processes automatically
`f`
: show/hide file system statshddtemp
`i`
: sort processes by I/O rate
`s`
: show/hide sensors’ stats
`y`
: show/hide hddtemp stats
`l`
: show/hide logs
`n`
: show/hide network stats
`x`
: delete warning and critical logs
`h`
: show/hide help screen
`q`
: quit
`w`
: delete warning logs
## Use Glances to Monitor Remote Systems
You can also monitor remote systems using Glances. To use it on a remote system, use the following command:
`glances -s`
You will see an output like the following:
You will see Glances running on port 61209.
Now, go to the remote machine and execute the following command to connect to a Glances server by specifying the IP address as shown below. For example, 192.168.1.10 is your Glances server IP address.
glances -c -P 192.168.1.10
## Conclusion
Glances is a very useful tool for every Linux system administrator. Using it, you can easily monitor your Linux system in less time. Feel free to comment if you have any questions.
Our latest tutorials delivered straight to your inbox |
6,884 | 在大学培养学生们参与开源代码开发的十四个技巧 | http://opensource.com/education/15/9/teaching-open-source-development-undergraduates | 2016-01-14T08:00:00 | [
"开源"
] | https://linux.cn/article-6884-1.html | 
学术界是培养和塑造未来的开源开发者的最佳平台。研究中发现,我们偶尔会开源自己编写的软件。这样做有两个理由,一是为了推广自己编写的工具的使用,二是为了了解人们使用这些工具时会遇到哪些问题。在这样一个编写研究软件的背景下,我的任务就是为 Bradford 大学重新设计二年级的本科软件工程课程。
这是一个挑战,因为我所面对的 80 个学生是来自不同专业的,包括 IT、商务计算和软件工程,这些学生将要在一起上课。最有难度的是,需要和这些编程经验差距很大的学生一起编写代码。按照传统,该课程允许学生选择自己的小组,然后给他们布置构建一个加油站数据库系统的任务,最后提交报告作为评估的一部分。
而我决定重新设计课程,让学生了解现实中的软件团队是如何协作的过程。根据学生的专业和编程技能,我将他们分为五、六个人一组。这是为了确保每个小组的整体水平相当,避免小组之间的不等。
### 核心课程
课程的形式改为讲座和实践课两项结合在一起。然而实践课作为指导过程,主要是老师监督各个小组的实践进度以及他们如何处理客户和产品之间的关系。而传统的教学方式由项目管理、软件测试、工程需求分析以及类似主题的讲座组成,再辅以实践和导师会议。这些会议可以很好的考核学生的水平以及检测出他们是否可以跟得上我们在讲座部分中的软件工程方法。本年的教学主题包括以下内容:
* 工程需求分析
* 如何与客户及其他团队成员互动
* 程序设计方法,如敏捷和极限编程方法
* 如何通过学习不同的软件工程方法进行短期的水平提高
* 小组会议及文档编写
* 项目管理及项目进展图表(甘特图)
* UML 图表及系统描述
* 使用 Git 来进行代码的版本控制
* 软件测试及 BUG 跟踪
* 使用开源库
* 开源代码许可及其选择
* 软件交付
在这些讲座之后,会有一些来自世界各地的嘉宾为我们说说他们在软件交付过程中的经验。我们也设法请来大学里知识产权律师谈关于软件在英国的知识产权问题,以及如何处理软件的知识产权问题。
### 协作工具
为了让上述教学内容的顺利进行,我们将会引入一些工具,并训练学生在他们的项目中使用这些工具。如下:
* Google Drive:团队与导师之间进行共享的工具,暂时存储用于描述项目的文档和图表、需求收集、会议纪要以及项目时间跟踪等信息。采取这样一个方式来监控并提供直接反馈到每个团队,是非常有效的。
* [Basecamp](https://basecamp.com/):同样是用于分享文档,在随后的课程中,我们可能会考虑用它取代 Google Drive。
* BUG 报告工具,如 [Mantis](https://www.mantisbt.org/):只能让有限的用户免费提交 BUG。稍后我们提到的 Git 可以让小组内的所有人员用做 BUG 提交。
* 远程视频会议工具:在人员不在校内,甚至去了其他城市的情况下使用。学生们可以定期通过 Skype 来交流并记录会议内容或则进行录音作为今后其他用处。
* 同时,学生们的项目中还会用到大量的开源工具包。他们可以根据自己小组的项目需求来选择自己使用的工具包和编程语言。唯一的条件是,这些项目必须开源,最后成果可以安装到大学里的实验室,并且大多的研究人员都非常支持这个条件。
* 最后,所有团队必须向客户交付他们的项目,包括完整的可以工作的软件版本、文档和他们自己选择的开放源码许可。大多数的团队选择了 GPLv3 许可证。
### 技巧和经验教训
在最后,这一年过的很愉快,并且所有学生的项目都做的非常棒。这里有一些我学到的经验教训,可能有助于提高明年的课程质量:
1. 提供各种各样有趣的选择项目给学生选择。比如说,游戏开发或者移动应用开发以及完成各种目标的项目等。建立普通的数据库系统已经不能提起学生的兴趣了,而参与到有趣的项目中去,学生本身就是自学者,同时可以帮助解决小组成员和小组之间的常见问题。再通过一个消息列表,学生们发表他们在测试中遇到的任何问题,以寻求其他人的帮助建议。然而,这种方法有一个缺点。外部考官建议我们使用统一种类型的项目和统一的编程语言以帮助缩小对学生的评估标准。
2. 定期给学生在每一个阶段的表现进行反馈。比方说,可以在和各个小组开指导会议的时候,或者每个阶段进行反馈,以帮助他们在接下来的工作中自我改进。
3. 学生更加愿意与校外的客户一起协作。他们期待着与外部公司代表或校外人员协作,不过是为了获得新体验而已。与导师进行交流时,他们都能够表现得很专业,这样使得老师非常放心。
4. 很多团队版将开发单元测试的部分放到项目结束之后,从极限编程方法的角度来说,这是一个严重的禁忌。也许测试应包括在不同阶段的评估中,来提醒他们需要并行开展软件开发和单元测试。
5. 在这个班的 80 个人里边,仅有 4 个女生,每个女生都分在不同的小组里边。我观察到,男生们总是充分准备好来承担起领队角色,并将最有趣的代码部分留给他们自己来编写,女生则多大遵循安排或者是编写文档。出于某种原因,女生选择不出头,即使在女性辅导员鼓励下,她们也不愿编写代码。这仍然是一个需要解决的主要问题。
6. 允许不同风格项目文档,比方说,UML 图表、状态图或其他形式的。让学生学习这些并与其他课程融汇贯通来提高他们的学习经验。
7. 学生里边,有些是很好的开发人员,有些做商务计算的则没有多少编程经验。我们要鼓励团队共同努力,避免开发人员做得比那些只做会议记录或文档的其他成员更好的错误认知。我们常在辅导课程中鼓励角色转换,让每个人都有机会学习如何编程。
8. 小组与导师每周见面沟通是非常重要的,可以有效监督各个小组进展情况,还可以了解是谁做了大部分工作。通常,没来参加会议的小组成员基本就是没有参与到他们的团队工作中去的,并且通过其他成员所提交的工作报告也可以确定哪些人不活跃。
9. 我们鼓励学生们把许可证附加到项目中去,使用外部库以及和客户协作的时候要表明确切知识产权问题。 这样可让打破陈规,开拓思维,并了解真实的软件交付问题。
10. 给学生们自己选择所用技术的空间。
11. 助教是关键。同时管理 80 个学生显然很有难度,特别是需要对他们进行评估的那几周。明年我一定会找个助教来帮我一起管理各个小组。
12. 实验室的技术支持是非常重要的。大学里的技术支持人员对于本课程是非常赞同的。他们正在考虑明年将虚拟机分配给每个团队,这样没个团队可以根据需要自行在虚拟机中安装任何软件。
13. 团队合作,相互帮助。大多数团队自然而然的支持其他团队成员,同时指导员在中间也帮助了不少。
14. 来自其他同事的帮助会锦上添花。作为一名新的大学导师,我需要从经验中学习,如果我想了解如何管理某些学生和团队,或者对如何让学生适应课程感到困惑时,我会通过多个方面来寻求建议。来自资深同事的支持对我来说是一种极大的鼓励。
最后,对于作为导师的我以及所有的学生来说,这都是个有趣的课程。在学习目标和传统评分方案上还有有一些问题需解决,以减少教师的工作量。明年,我计划会保留这种教学模式,并希望能够提出更好的评分方案以及引入更多的软件来帮助监督项目和控制代码版本。
---
via: <http://opensource.com/education/15/9/teaching-open-source-development-undergraduates>
作者:[Mariam Kiran](http://opensource.com/users/mariamkiran) 译者:[GHLandy](https://github.com/GHLandy) 校对:[Caroline](https://github.com/carolinewuyan)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,885 | 如何在 Linux 中根据国家位置来阻断网络流量 | http://xmodulo.com/block-network-traffic-by-country-linux.html | 2016-01-14T09:12:00 | [
"防火墙",
"iptables"
] | https://linux.cn/article-6885-1.html | 作为一名维护 Linux 生产服务器的系统管理员,你可能会遇到这样一些情形:你需要**根据地理位置,选择性地阻断或允许网络流量通过。** 例如你正经历一次由注册在某个特定国家的 IP 发起的 DoS 攻击;或者基于安全考虑,你想阻止来自未知国家的 SSH 登录请求;又或者你的公司对某些在线视频有分销权,它要求只能在特定的国家内合法发行;抑或是由于公司的政策,你需要阻止某个本地主机将文件上传至任意一个非美国的远程云端存储。

所有的上述情形都需要设置防火墙,使之具有**基于国家位置过滤流量**的功能。有几个方法可以做到这一点,其中之一是你可以使用 TCP wrappers 来为某个应用(例如 SSH,NFS, httpd)设置条件阻塞。但其缺点是你想要保护的那个应用必须以支持 TCP wrappers 的方式构建。另外,TCP wrappers 并不总是能够在各个平台中获取到(例如,Arch Linux [放弃了](http://xmodulo.com/block-unwanted-ip-addresses-linux.html)对它的支持)。另一种方式是结合基于国家的 GeoIP 信息,设置 [ipset](http://xtables-addons.sourceforge.net/geoip.php),并将它应用到 iptables 的规则中。后一种方式看起来更有希望一些,因为基于 iptables 的过滤器是与应用无关的,且容易设置。
在本教程中,我将展示 **另一个基于 iptables 的 GeoIP 过滤器,它由 xtables-addons 来实现**。对于那些不熟悉它的人来说, xtables-addons 是用于 netfilter/iptables 的一系列扩展。一个包含在 xtables-addons 中的名为 xt\_geoip 的模块扩展了 netfilter/iptables 的功能,使得它可以根据流量来自或流向的国家来进行过滤,IP 掩蔽(NAT)或丢包。若你想使用 xt\_geoip,你不必重新编译内核或 iptables,你只需要使用当前的内核构建环境(/lib/modules/`uname -r`/build)以模块的形式构建 xtables-addons。同时也不需要进行重启。只要你构建并安装了 xtables-addons , xt\_geoip 便能够配合 iptables 使用。
至于 xt\_geoip 和 ipset 之间的比较,[xtables-addons 的官方网站](http://xtables-addons.sourceforge.net/geoip.php) 上是这么说的: 相比于 ipset,xt\_geoip 在内存占用上更胜一筹,但对于匹配速度,基于哈希的 ipset 可能更有优势。
在教程的余下部分,我将展示**如何使用 iptables/xt\_geoip 来根据流量的来源地或流入的国家阻断网络流量**。
### 在 Linux 中安装 xtables-addons
下面介绍如何在各种 Linux 平台中编译和安装 xtables-addons。
为了编译 xtables-addons,首先你需要安装一些依赖软件包。
#### 在 Debian,Ubuntu 或 Linux Mint 中安装依赖
```
$ sudo apt-get install iptables-dev xtables-addons-common libtext-csv-xs-perl pkg-config
```
#### 在 CentOS,RHEL 或 Fedora 中安装依赖
CentOS/RHEL 6 需要事先设置好 EPEL 仓库(为 perl-Text-CSV\_XS 所需要)。
```
$ sudo yum install gcc-c++ make automake kernel-devel-`uname -r` wget unzip iptables-devel perl-Text-CSV_XS
```
#### 编译并安装 xtables-addons
从 `xtables-addons` 的[官方网站](http://xtables-addons.sourceforge.net/) 下载源码包,然后按照下面的指令编译安装它。
```
$ wget http://downloads.sourceforge.net/project/xtables-addons/Xtables-addons/xtables-addons-2.10.tar.xz
$ tar xf xtables-addons-2.10.tar.xz
$ cd xtables-addons-2.10
$ ./configure
$ make
$ sudo make install
```
需要注意的是,对于基于红帽的系统(CentOS、RHEL、Fedora),它们默认开启了 SELinux,所以有必要像下面这样调整 SELinux 的策略。否则,SELinux 将阻止 iptables 加载 xt\_geoip 模块。
```
$ sudo chcon -vR --user=system_u /lib/modules/$(uname -r)/extra/*.ko
$ sudo chcon -vR --type=lib_t /lib64/xtables/*.so
```
### 为 xtables-addons 安装 GeoIP 数据库
下一步是安装 GeoIP 数据库,它将被 xt\_geoip 用来查询 IP 地址与国家地区之间的对应关系。方便的是,`xtables-addons` 的源码包中带有两个帮助脚本,它们被用来从 MaxMind 下载 GeoIP 数据库并将它转化为 xt\_geoip 可识别的二进制形式文件;它们可以在源码包中的 geoip 目录下找到。请遵循下面的指导来在你的系统中构建和安装 GeoIP 数据库。
```
$ cd geoip
$ ./xt_geoip_dl
$ ./xt_geoip_build GeoIPCountryWhois.csv
$ sudo mkdir -p /usr/share/xt_geoip
$ sudo cp -r {BE,LE} /usr/share/xt_geoip
```
根据 [MaxMind](https://support.maxmind.com/geoip-faq/geoip2-and-geoip-legacy-databases/how-accurate-are-your-geoip2-and-geoip-legacy-databases/) 的说明,他们的 GeoIP 数据库能够以 99.8% 的准确率识别出 ip 所对应的国家,并且每月这个数据库将进行更新。为了使得本地安装的 GeoIP 数据是最新的,或许你需要设置一个按月执行的 [cron job](http://ask.xmodulo.com/add-cron-job-linux.html) 来时常更新你本地的 GeoIP 数据库。
### 阻断来自或流向某个国家的网络流量
一旦 xt\_geoip 模块和 GeoIP 数据库安装好后,你就可以在 iptabels 命令中使用 geoip 的匹配选项。
```
$ sudo iptables -m geoip --src-cc country[,country...] --dst-cc country[,country...]
```
你想要阻断流量的那些国家是使用[2个字母的 ISO3166 代码](https://en.wikipedia.org/wiki/ISO_3166-1) 来特别指定的(例如 US(美国)、CN(中国)、IN(印度)、FR(法国))。
例如,假如你想阻断来自也门(YE) 和 赞比亚(ZM)的流量,下面的 iptabels 命令便可以达到此目的。
```
$ sudo iptables -I INPUT -m geoip --src-cc YE,ZM -j DROP
```
假如你想阻断流向中国(CN) 的流量,可以运行下面的命令:
```
$ sudo iptables -A OUTPUT -m geoip --dst-cc CN -j DROP
```
匹配条件也可以通过在 `--src-cc` 或 `--dst-cc` 选项前加 `!` 来达到相反的目的:
假如你想在你的服务器上阻断来自所有非美国的流量,可以运行:
```
$ sudo iptables -I INPUT -m geoip ! --src-cc US -j DROP
```

#### 对于使用 Firewall-cmd 的用户
某些发行版本例如 CentOS/RHEL7 或 Fedora 已经用 firewalld 替代了 iptables 来作为默认的防火墙服务。在这些系统中,你可以类似使用 xt\_geoip 那样,使用 firewall-cmd 来阻断流量。利用 firewall-cmd 命令,上面的三个例子可被重新写为:
```
$ sudo firewall-cmd --direct --add-rule ipv4 filter INPUT 0 -m geoip --src-cc YE,ZM -j DROP
$ sudo firewall-cmd --direct --add-rule ipv4 filter OUTPUT 0 -m geoip --dst-cc CN -j DROP
$ sudo firewall-cmd --direct --add-rule ipv4 filter INPUT 0 -m geoip ! --src-cc US -j DROP
```
### 总结
在本教程中,我展示了使用 iptables/xt\_geoip 来根据流量的来源地或流入的国家轻松地阻断网络流量。假如你有这方面的需求,把它部署到你的防火墙系统中可以使之成为一个实用的办法。作为最后的警告,我应该提醒你的是:在你的服务器上通过基于 GeoIP 的流量过滤来禁止特定国家的流量并不总是万无一失的。GeoIP 数据库本身就不是很准确或齐全,且流量的来源或目的地可以轻易地通过使用 VPN、Tor 或其他任意易受攻击的中继主机来达到欺骗的目的。基于地理位置的过滤器甚至可能会阻止本不该阻止的合法网络流量。在你决定把它部署到你的生产环境之前请仔细考虑这个限制。
---
via: <http://xmodulo.com/block-network-traffic-by-country-linux.html>
作者:[Dan Nanni](http://xmodulo.com/author/nanni) 译者:[FSSlc](https://github.com/FSSlc) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,886 | 使用 Nmon 监控 Linux 的系统性能 | https://www.maketecheasier.com/monitor-linux-system-performance/ | 2016-01-14T10:34:00 | [
"nmon",
"监控"
] | https://linux.cn/article-6886-1.html | Nmon(得名于 Nigel 的监控器)是IBM的员工 Nigel Griffiths 为 AIX 和 Linux 系统开发的一款计算机性能系统监控工具。Nmon 可以把操作系统的统计数据展示在屏幕上或者存储到一份数据文件里,来帮助了解计算机资源的使用情况、调整方向和系统瓶颈。这个系统基准测试工具只需要使用一条命令就能得到大量重要的性能数据。使用 Nmon 可以很轻松的监控系统的 CPU、内存、网络、硬盘、文件系统、NFS、高耗进程、资源和 IBM Power 系统的微分区的信息。
### Nmon 安装
Nmon 默认是存在于 Ubuntu 的仓库中的。你可以通过下面的命令安装 Nmon:
```
sudo apt-get install nmon
```
### 怎么使用Nmon来监控Linux的性能
安装完成后,通过在终端输入`nmon` 命令来启动 Nmon
```
nmon
```
你会看到下面的输出:

从上面的截图可以看到 nmon 命令行工具完全是交互式运行的,你可以使用快捷键来轻松查看对应的统计数据。你可以使用下面的 nmon 快捷键来显示不同的系统统计数据:
* `q` : 停止并退出 Nmon
* `h` : 查看帮助
* `c` : 查看 CPU 统计数据
* `m` : 查看内存统计数据
* `d` : 查看硬盘统计数据
* `k` : 查看内核统计数据
* `n` : 查看网络统计数据
* `N` : 查看 NFS 统计数据
* `j` : 查看文件系统统计数据
* `t` : 查看高耗进程
* `V` : 查看虚拟内存统计数据
* `v` : 详细模式
### 核查 CPU 处理器
如果你想收集关于 CPU 性能相关的统计数据,你应该按下键盘上的`c`键,之后你将会看到下面的输出:

### 核查高耗进程统计数据
如果想收集系统正在运行的高耗进程的统计数据,按键盘上的`t`键,之后你将会看到下面的输出:

### 核查网络统计数据
如果想收集 Linux 系统的网络统计数据,按下`n`键,你将会看到下面输出:

### 硬盘 I/O 图表
使用`d` 键获取硬盘相关的信息,你会看到下面输出:

### 核查内核信息
Nmon 一个非常重要的快捷键是`k`键,用来显示系统内核相关的概要信息。按下`k`键之后,会看到下面输出:

### 获取系统信息
对每个系统管理员来说一个非常有用的快捷键是`r`键,可以用来显示计算机的系统结构、操作系统版本号和 CPU 等不同资源的信息。按下`r`键之后会看到下面输出:

### 总结
还有许多其他的工具做的和 Nmon 同样的工作,不过 Nmon 对一个 Linux 新手来说还是很友好的。如果你有什么问题,尽管评论。
---
via: <https://www.maketecheasier.com/monitor-linux-system-performance/>
作者:[Hitesh Jethva](https://www.maketecheasier.com/author/hiteshjethva/) 译者:[sonofelice](https://github.com/sonofelice) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | Nmon (also known as Nigel’s Monitor) is a computer performance system monitor tool for the AIX and Linux operating systems developed by IBM employee Nigel Griffiths. The tool displays onscreen or saves to a data file the operating system statistics to aid in the understanding of computer resource use, tuning options and bottlenecks. This system benchmark tool gives you a huge amount of important performance information in one go with a single command. You can easily monitor your system’s CPU, memory, network, disks, file systems, NFS, top processes, resources and power micro-partition information using Nmon.
## Installing Nmon
By default `nmon`
is available in the Ubuntu repository. You can easily install nmon by running the following command:
sudo apt-get install nmon
## How to Use Nmon to Monitor Linux Performance
Once the installation has been finished, you can launch it by typing the `nmon`
command in the terminal.
nmon
You wI’ll see the following output:
You can see from the above screenshot that the nmon command-line utility runs completely in interactive mode, and you can easily toggle statistics using shortcut keys.
You can use the following nmon keyboard shortcuts to display different system stats:
`q`
: to stop and exit Nmon
`h`
: to see help screen
`c`
: see CPU stats
`m`
: see memory stats
`d`
: see disk stats
`k`
: see kernel stats
`n`
: see network stats
`N`
: see NFS stats
`j`
: see file system stats
`t`
: see top process
`V`
: see virtual memory stats
`v`
: verbose mode
## Check CPU by Processor
If you would like to collect some statistics on CPU performance, you should hit the `c`
key on the keyboard.
After hitting the `c`
key you wI’ll see the following output.
## Check Top Process Statistics
To get stats on top processes that are running on your system, press the `t`
key on your keyboard.
You will see the following output.
## Check Network Statistics
To get the network stats of your Linux system, just press the `n`
key on your keyboard.
You wI’ll see the following output:
## Disk I/O Graphs
Use the `d`
key to get information about disks.
You wI’ll see the following output:
## Check Kernel Information
A most important key to use with this tool is `k;`
it is used to display some brief information on the kernel of your system.
You will see the following output after hitting the `k`
key on your keyboard.
## Get System Information
A very useful key for every system admin is the `r`
key which is used to give information on different resources such as machine architecture, operating system version, Linux version and CPU.
You will see the following output by hitting the `r`
key.
## Conclusion
There are many other tools that can do the same job of the Nmon, but Nmon is so usee friendly for a Linux beginner. Please feel free to comment if you have any questions.
Our latest tutorials delivered straight to your inbox |
6,888 | 最简明扼要的 Systemd 教程,只需十分钟 | http://www.linuxvoice.com/linux-101-get-the-most-out-of-systemd/ | 2016-01-14T10:08:00 | [
"systemd"
] | https://linux.cn/article-6888-1.html | 
干嘛要这么做?
* 理解现代 Linux 发行版中的显著变化;
* 看看 Systemd 是如何取代 SysVinit 的;
* 搞定单元(unit)和新的 journal 日志。
吐槽邮件、人身攻击、死亡威胁——Lennart Poettering,Systemd 的作者,对收到这些东西早就习以为常了。这位 Red Hat 公司的员工之前在 Google+ 上怒斥 FOSS 社区(<http://tinyurl.com/poorlennart>)的本质,悲痛且失望地表示:“那真是个令人恶心的地方”。他着重指出 Linus Torvalds 在邮件列表上言辞极其刻薄的帖子,并谴责这位内核的领导者为在线讨论定下基调,并使得人身攻击及贬抑之辞成为常态。
但为何 Poettering 会遭受如此多的憎恨?为何就这么个搞搞开源软件的人要忍受这等愤怒?答案就在于他的软件的重要性。如今大多数发行版中,Systemd 是 Linux 内核发起的第一个程序,并且它还扮演多种角色。它会启动系统服务、处理用户登录,每隔特定的时间执行一些任务,还有很多很多。它在不断地成长,并逐渐成为 Linux 的某种“基础系统”——提供系统启动和发行版维护所需的所有工具。
如今,在以下几点上 Systemd 颇具争议:它逃避了一些已经确立的 Unix 传统,例如纯文本的日志文件;它被看成是个“大一统”的项目,试图接管一切;它还是我们这个操作系统的支柱的重要革新。然而大多数主流发行版已经接受了(或即将接受)它,因此它就活了下来。而且它确实是有好处的:更快地启动,更简单地管理那些有依赖的服务程序,提供强大且安全的日志系统等。
因此在这篇教程中,我们将探索 Systemd 的特性,并向您展示如何最有效地利用这些特性。即便您此刻并不是这款软件的粉丝,读完本文后您至少可以更加了解和适应它。

*这部没正经的动画片来自<http://tinyurl.com/m2e7mv8>,它把 Systemd 塑造成一只狂暴的动物,吞噬它路过的一切。大多数批评者的言辞可不像这只公仔一样柔软。*
### 启动及服务
大多数主流发行版要么已经采用 Systemd,要么即将在下个发布中采用(如 Debian 和 Ubuntu)。在本教程中,我们使用 Fedora 21(该发行版已经是 Systemd 的优秀实验场地)的一个预览版进行演示,但不论您用哪个发行版,要用到的命令和注意事项都应该是一样的。这是 Systemd 的一个加分点:它消除了不同发行版之间许多细微且琐碎的区别。
在终端中输入 `ps ax | grep systemd`,看到第一行,其中的数字 **1** 表示它的进程号是1,也就是说它是 Linux 内核发起的第一个程序。因此,内核一旦检测完硬件并组织好了内存,就会运行 `/usr/lib/systemd/systemd` 可执行程序,这个程序会按顺序依次发起其他程序。(在还没有 Systemd 的日子里,内核会去运行 `/sbin/init`,随后这个程序会在名为 SysVinit 的系统中运行其余的各种启动脚本。)
Systemd 的核心是一个叫<ruby> 单元 <rp> ( </rp> <rt> unit </rt> <rp> ) </rp></ruby>的概念,它是一些存有关于<ruby> 服务 <rp> ( </rp> <rt> service </rt> <rp> ) </rp></ruby>(在运行在后台的程序)、设备、挂载点、和操作系统其他方面信息的配置文件。Systemd 的其中一个目标就是简化这些事物之间的相互作用,因此如果你有程序需要在某个挂载点被创建或某个设备被接入后开始运行,Systemd 可以让这一切正常运作起来变得相当容易。(在没有 Systemd 的日子里,要使用脚本来把这些事情调配好,那可是相当丑陋的。)要列出您 Linux 系统上的所有单元,输入以下命令:
```
systemctl list-unit-files
```
现在,`systemctl` 是与 Systemd 交互的主要工具,它有不少选项。在单元列表中,您会注意到这儿有一些格式化:被<ruby> 启用 <rp> ( </rp> <rt> enabled </rt> <rp> ) </rp></ruby>的单元显示为绿色,被<ruby> 禁用 <rp> ( </rp> <rt> disabled </rt> <rp> ) </rp></ruby>的显示为红色。标记为“static”的单元不能直接启用,它们是其他单元所依赖的对象。若要限制输出列表只包含服务,使用以下命令:
```
systemctl list-unit-files --type=service
```
注意,一个单元显示为“enabled”,并不等于对应的服务正在运行,而只能说明它可以被开启。要获得某个特定服务的信息,以 GDM (Gnome Display Manager) 为例,输入以下命令:
```
systemctl status gdm.service
```
这条命令提供了许多有用的信息:一段给人看的服务描述、单元配置文件的位置、启动的时间、进程号,以及它所从属的 CGroups(用以限制各组进程的资源开销)。
如果您去查看位于 `/usr/lib/systemd/system/gdm.service` 的单元配置文件,您可以看到各种选项,包括要被运行的二进制文件(“ExecStart”那一行),相冲突的其他单元(即不能同时进入运行的单元),以及需要在本单元执行前进入运行的单元(“After”那一行)。一些单元有附加的依赖选项,例如“Requires”(必要的依赖)和“Wants”(可选的依赖)。
此处另一个有趣的选项是:
```
Alias=display-manager.service
```
当您启动 **gdm.service** 后,您将可以通过 `systemctl status display-manager.service` 来查看它的状态。当您知道有<ruby> 显示管理程序 <rp> ( </rp> <rt> display manager </rt> <rp> ) </rp></ruby>在运行并想对它做点什么,但您不关心那究竟是 GDM,KDM,XDM 还是什么别的显示管理程序时,这个选项会非常有用。

*使用 systemctl status 命令后面跟一个单元名,来查看对应的服务有什么情况。*
### “<ruby> 目标 <rp> ( </rp> <rt> target </rt> <rp> ) </rp></ruby>”锁定
如果您在 `/usr/lib/systemd/system` 目录中输入 `ls` 命令,您将看到各种以 `.target` 结尾的文件。启动*<ruby> 目标 <rp> ( </rp> <rt> target </rt> <rp> ) </rp></ruby>*是一种将多个单元聚合在一起以致于将它们同时启动的方式。例如,对大多数类 Unix 操作系统而言有一种“<ruby> 多用户 <rp> ( </rp> <rt> multi-user </rt> <rp> ) </rp></ruby>”状态,意思是系统已被成功启动,后台服务正在运行,并且已准备好让一个或多个用户登录并工作——至少在文本模式下。(其他状态包括用于进行管理工作的<ruby> 单用户 <rp> ( </rp> <rt> single-user </rt> <rp> ) </rp></ruby>状态,以及用于机器关机的<ruby> 重启 <rp> ( </rp> <rt> reboot </rt> <rp> ) </rp></ruby>状态。)
如果您打开 **multi-user.target** 文件一探究竟,您可能期待看到的是一个要被启动的单元列表。但您会发现这个文件内部几乎空空如也——其实,一个服务会通过 **WantedBy** 选项让自己成为启动目标的依赖。因此如果您去打开 **avahi-daemon.service**, **NetworkManager.service** 及其他 **.service** 文件看看,您将在 Install 段看到这一行:
```
WantedBy=multi-user.target
```
因此,切换到多用户启动目标会<ruby> 启用 <rp> ( </rp> <rt> enable </rt> <rp> ) </rp></ruby>那些包含上述语句的单元。还有其他一些启动目标可用(例如 **emergency.target** 提供一个紧急情况使用的 shell,以及 **halt.target** 用于机器关机),您可以用以下方式轻松地在它们之间切换:
```
systemctl isolate emergency.target
```
在许多方面,这些都很像 SysVinit 中的<ruby> 运行级 <rp> ( </rp> <rt> runlevel </rt> <rp> ) </rp></ruby>,如文本模式的 **multi-user.target** 类似于第3运行级,**graphical.target** 类似于第5运行级,**reboot.target** 类似于第6运行级,诸如此类。

*与传统的脚本相比,单元配置文件也许看起来很陌生,但并不难以理解。*
### 开启与停止
现在您也许陷入了沉思:我们已经看了这么多,但仍没看到如何停止和开启服务!这其实是有原因的。从外部看,Systemd 也许很复杂,像野兽一般难以驾驭。因此在您开始摆弄它之前,有必要从宏观的角度看看它是如何工作的。实际用来管理服务的命令非常简单:
```
systemctl stop cups.service
systemctl start cups.service
```
(若某个单元被禁用了,您可以先通过 `systemctl enable` 加上该单元名的方式将其启用。这种做法会为该单元创建一个符号链接,并将其放置在当前启动目标的 `.wants` 目录下,这些 `.wants` 目录在`/etc/systemd/system` 文件夹中。)
还有两个有用的命令是 `systemctl restart` 和 `systemctl reload`,后面接单元名。后者用于让单元重新加载它的配置文件。Systemd 的绝大部分都有良好的文档,因此您可以查看手册 (`man systemctl`) 了解每条命令的细节。
### 定时器单元:取代 Cron
除了系统初始化和服务管理,Systemd 还染指了其他方面。在很大程度上,它能够完成 **cron** 的工作,而且可以说是以更灵活的方式(并带有更易读的语法)。**cron** 是一个以规定时间间隔执行任务的程序——例如清除临时文件,刷新缓存等。
如果您再次进入 `/usr/lib/systemd/system` 目录,您会看到那儿有多个 `.timer` 文件。用 `less` 来查看这些文件,您会发现它们与 `.service` 和 `.target` 文件有着相似的结构,而区别在于 `[Timer]` 段。举个例子:
```
[Timer]
OnBootSec=1h
OnUnitActiveSec=1w
```
**OnBootSec** 选项告诉 Systemd 在系统启动一小时后启动这个单元。第二个选项的意思是:自那以后每周启动这个单元一次。关于定时器有大量选项您可以设置,输入 `man systemd.time` 查看完整列表。
Systemd 的时间精度默认为一分钟。也就是说,它会在设定时刻的一分钟内运行单元,但不一定精确到那一秒。这么做是基于电源管理方面的原因,但如果您需要一个没有任何延时且精确到毫秒的定时器,您可以添加以下一行:
```
AccuracySec=1us
```
另外, **WakeSystem** 选项(可以被设置为 true 或 false)决定了定时器是否可以唤醒处于休眠状态的机器。

*有一个 Systemd 的图形界面程序,即便它已有多年未被积极维护。*
### 日志文件:向 journald 问声好
Systemd 的第二个主要部分是 journal 。这是个日志系统,类似于 syslog 但也有些显著区别。如果您是个 Unix 日志管理模式的粉丝,准备好出离愤怒吧:这是个二进制日志,因此您不能使用常规的命令行文本处理工具来解析它。这个设计决定不出意料地在网上引起了激烈的争论,但它的确有些优点。例如,日志可以被更系统地组织,带有更多的元数据,因此可以更容易地根据可执行文件名和进程号等过滤出信息。
要查看整个 journal,输入以下命令:
```
journalctl
```
像许多其他的 Systemd 命令一样,该命令将输出通过管道的方式引向 `less` 程序,因此您可以使用空格键向下滚动,键入`/`(斜杠)查找,以及其他熟悉的快捷键。您也能在此看到少许颜色,像红色的警告及错误信息。
以上命令会输出很多信息。为了限制其只输出本次启动的消息,使用如下命令:
```
journalctl -b
```
这就是 Systemd 大放异彩的地方!您想查看自上次启动以来的全部消息吗?试试 **journalctl -b -1** 吧。再上一次的?用 **-2** 替换 **-1** 吧。那自某个具体时间,例如2014年10月24日16:38以来的呢?
```
journalctl -b --since=”2014-10-24 16:38”
```
即便您对二进制日志感到遗憾,那依然是个有用的特性,并且对许多系统管理员来说,构建类似的过滤器比起写正则表达式而言容易多了。
我们已经可以根据特定的时间来准确查找日志了,那可以根据特定程序吗?对单元而言,试试这个:
```
journalctl -u gdm.service
```
(注意:这是个查看 X server 产生的日志的好办法。)那根据特定的进程号?
```
journalctl _PID=890
```
您甚至可以请求只看某个可执行文件产生的消息:
```
journalctl /usr/bin/pulseaudio
```
若您想将输出的消息限制在某个优先级,可以使用 **-p** 选项。该选项参数为 0 的话只会显示紧急消息(也就是说,是时候向 **$DEITY** 祈求保佑了)(LCTT 译注: $DEITY 是一个计算机方面的幽默,DEITY 是指广义上的“神”,$前缀表示这是一个变量),为 7 的话会显示所有消息,包括调试消息。请查看手册 (`man journalctl`) 获取更多关于优先级的信息。
值得指出的是,您也可以将多个选项结合在一起,若想查看在当前启动中由 GDM 服务输出的优先级数小于等于 3 的消息,请使用下述命令:
```
journalctl -u gdm.service -p 3 -b
```
最后,如果您仅仅想打开一个随 journal 持续更新的终端窗口,就像在没有 Systemd 时使用 `tail` 命令实现的那样,输入 `journalctl -f` 就好了。

*二进制日志并不流行,但 journal 的确有它的优点,如非常方便的信息查找及过滤。*
### 没有 Systemd 的生活?
如果您就是完全不能接受 Systemd,您仍然有一些主流发行版中的选择。尤其是 Slackware,作为历史最为悠久的发行版,目前还没有做出改变,但它的主要开发者并没有将其从未来规划中移除。一些不出名的发行版也在坚持使用 SysVinit 。
但这又将持续多久呢?Gnome 正越来越依赖于 Systemd,其他的主流桌面环境也会步其后尘。这也是引起 BSD 社区一阵恐慌的原因:Systemd 与 Linux 内核紧密相连,导致在某种程度上,桌面环境正变得越来越不可移植。一种折衷的解决方案也许会以 Uselessd ([http://uselessd.darknedgy.net](http://uselessd.darknedgy.net/)) 的形式到来:一种裁剪版的 Systemd,纯粹专注于启动和监控进程,而不消耗整个基础系统。

*若您不喜欢 Systemd,可以尝试一下 Gentoo 发行版,它将 Systemd 作为初始化工具的一种选择,但并不强制用户使用 Systemd。*
---
via: <http://www.linuxvoice.com/linux-101-get-the-most-out-of-systemd/>
作者:[Mike Saunders](http://www.linuxvoice.com/author/mike/) 译者:[Ricky-Gong](https://github.com/Ricky-Gong) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 500 | Internal Server Error | null |
6,890 | 如何更新 ISPConfig 3 SSL 证书 | http://www.faqforge.com/linux/how-to-renew-the-ispconfig-3-ssl-certificate/ | 2016-01-15T08:36:00 | [
"SSL"
] | https://linux.cn/article-6890-1.html | 本教程描述了如何在 [ISPConfig](http://www.ispconfig.org/) 3控制面板中更新 SSL 证书。有两个可选的方法:
* 用 OpenSSL 创建一个新的 OpenSSL 证书和 CSR。
* 用 ISPConfig updater 更新 SSL 证书

我将从用手工的方法更新 SSL 证书开始。
### 1)用 OpenSSL 创建一个新的 ISPConfig 3 SSL 证书
用 root 用户登录你的服务器。在创建一个新的 SSL 证书之前,先备份现有的。SSL 证书是安全敏感的,因此我将它存储在 /root/ 目录下。
```
tar pcfz /root/ispconfig_ssl_backup.tar.gz /usr/local/ispconfig/interface/ssl
chmod 600 /root/ispconfig_ssl_backup.tar.gz
```
>
> 现在创建一个新的 SSL 证书密钥,证书请求(CSR)和自签发证书。
>
>
>
```
cd /usr/local/ispconfig/interface/ssl
openssl genrsa -des3 -out ispserver.key 4096
openssl req -new -key ispserver.key -out ispserver.csr
openssl x509 -req -days 3650 -in ispserver.csr \
-signkey ispserver.key -out ispserver.crt
openssl rsa -in ispserver.key -out ispserver.key.insecure
mv ispserver.key ispserver.key.secure
mv ispserver.key.insecure ispserver.key
```
重启 apache 来加载新的 SSL 证书
```
service apache2 restart
```
### 2)用 ISPConfig 安装器来更新 SSL 证书
另一个获取新的 SSL 证书的替代方案是使用 ISPConfig 更新脚本。下载 ISPConfig 到 /tmp 目录下,解压包并运行脚本。
```
cd /tmp
wget http://www.ispconfig.org/downloads/ISPConfig-3-stable.tar.gz
tar xvfz ISPConfig-3-stable.tar.gz
cd ispconfig3_install/install
php -q update.php
```
更新脚本会在更新时询问下面的问题:
```
Create new ISPConfig SSL certificate (yes,no) [no]:
```
这里回答“yes”,SSL 证书创建对话框就会启动。
---
via: <http://www.faqforge.com/linux/how-to-renew-the-ispconfig-3-ssl-certificate/>
作者:[Till](http://www.faqforge.com/author/till/) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,891 | 暴增 Emacs 生产力的十大最佳插件 | http://xmodulo.com/best-plugins-to-increase-productivity-on-emacs.html | 2016-01-15T10:32:10 | [
"Emacs"
] | https://linux.cn/article-6891-1.html | 一年前的这个时候,我想要寻找[将 Vim 打造成一个成熟的全功能的 IDE](http://xmodulo.com/turn-vim-full-fledged-ide.html) 的最好插件。有趣的是,那篇文章的很多评论提到了 Emacs 已经大部分有了这些内置插件,已经是一个很棒的 IDE 了。尽管我对 Emacs 的难以置信的多样化表示赞同,它依旧不是一个可以开箱即用的高级编辑器。还好,其庞大的插件库可以解决这个问题。但在过多的选择中,有时很难弄清该如何入手。因此,现在让我试着收集一个不可或缺的插件的简短列表,来提升你使用 Emacs 时的工作效率。 虽然我主要侧重于与编程相关的生产力提升,但是这些插件对所有人或不同用途都是有用的。

### 1. Ido-mode

Ido 或许是对新手最有用的一个插件,Ido 的意思是<ruby> 交互式工作 <rp> ( </rp> <rt> interactively do </rt> <rp> ) </rp></ruby>。它取代了大部分的用花哨字符匹配菜单的枯燥提示。好比说,它用列出了当前目录所有文件的列表来取代了常规的打开文件提示符。输入一些字符,Ido 将尝试匹配最合适的文件。它通过可视化让你的操作变得更容易,这也是一个快速遍历所有文件都有相同前缀的文件夹的方法。
### 2. Smex

它不算最著名的一个、但却是一个替代 Ido-mode 的好选择:Smex 可以优雅的替代普通的`M-x`提示符,灵感大部分来自于 Ido-mode。它也给调用`M-x`后输入的命令带来了同样的交互搜索能力。它简单而有效,是一个为常用操作提升效率的最好方法。
### 3. Auto Complete

知道这个插件的存在之前,我在 Emacs 里面有一半的时间花在敲击 `M-/` 来补完单词上。现在,我有一个漂亮的弹出菜单可以为我做自动补全。无须多说,我们都需要它。
### 4. YASnippet

这是真正的程序员必备利器。总有一些代码片段会让我们觉得我们一辈子都在写它。对我来说,就是调试 PHP 时不断输入的 `var_dump(...);exit;`。经过一段时间一遍又一遍的输入`var_dump(...);exit;`,我觉得我可以预先把其做成录制好的、方便用到的代码片段。使用 YASnippets,可以很容易导入代码片段文件或者自己做个。之后,只要按下一个 tab 键,就可以将一个小的关键词扩展成一大段预先写好的代码,然后可以很方便地在里面修改。
### 5. Org-mode

免责声明,我最近才开始使用 Org-mode,但它已经深深的吸引了我。从我看过数以百计的文章来说,Org-mode 可以改变你的生活。它背后的想法很简单:它是一种用普通文本做简单备注的模式,可以很容易地在任务列表和各种数据中转来转去,并进行一些比如按优先级或到期日期的过滤,或设置一个重复日期。然而,虽然思路简单,但你可以做到很多,用各种方法用于各种用途。与其去看一个长长的介绍,我觉得你可以去读读[现有教程](http://orgmode.org/worg/org-tutorials/),有很多视频可以看,自己去体验一下 Org-mode 是多么强大。
### 6. Helm

一些使用者喜欢它,但是其他人没有这么大的使用热情。我是后者的一部分。但在拥有这样一个庞大的追随者的情况下,是不能不提到它的。Helm 旨在完全变换你的 Emacs 使用体验。简单来说,Helm 是一个在 Emacs 中帮助你快速找到一个文件或命令的框架。根据你的输入,它将尝试使用词语自动完成来引导你将大脑的念头变为行动。起初感觉有点奇怪,但对一些人来说,Helm 本身就是一个信仰。虽然我不是 Helm 的粉丝,我欣赏 helm-occur 这一个伟大的工具可以在一个大文档搜索字符串并且在一个单独的缓冲区显示所有匹配结果,以便很容易在它们之间跳转。如果你正在寻找一个快速演示来了解 Helm 能做什么,我推荐[这篇文章](http://tuhdo.github.io/helm-intro.html)。
### 7. ace-jump-mode

这是另一个有一大群追随者的插件,我正在试图成为 ace-jump-mode 的粉丝。掌握这个插件,你会体验到超越鼠标感受。简单描述一下,通过你选择的快捷方式触发 ace-jump-mode 后,你会被提示输入字符。输入一个字符,所有以该字符开头的单词中的那个字符就会替换成一个唯一字符并被高亮。输入一个屏幕上的高亮字符,你的光标会直接跳转到高亮显示的那个词。我不得不承认,这让我使用它时有点反应不过来,但是,一旦你掌握它,它将显著提升你在一个文档里的移动速度。(LCTT 译注:用文字描述比较困难,如截图中,你输入的是一个“i”,然后屏幕中所有以“i”开头的单词中的那个“i”都被替换成了从 a 到 z 的字符,并高亮;你可以输入这些高亮的字符直接跳转到那个位置。)
### 8. find-file-in-project

如果你喜欢 Sublime text 以及它可以用非常方便的`Ctrl-p`模糊搜索来打开一个项目中的任何文件的功能,你将会喜欢上 find-file-in-project (简称 ffip)的。使用设置指定了您的版本控制的根文件夹后,您可以轻松地调出一个很酷的文本条,通过快速扫描和搜索你的代码,来根据你输入的名称找到匹配的文件。我喜欢把它绑定到键盘上的 F6 键。如果你不知道整个目录从上到下的复杂结构,这很简单,而且非常易用。
### 9. Flymake

对 IDE 的爱好者来说,我认为语法检查器是 IDE 最强大的特性之一,它非常适合初学者和方便了那些疲惫的程序员。感谢 Flymake,Emacs 用户也可以享受到了语法检查器。因为我工作中用 PHP 很多,Flymake 就不需要任何额外的配置。当我写代码的时候,它会自动检查我的代码和高亮任何一个包含问题的行。对于编译语言,Flymake 将寻找一个用于检查你的代码的 Makefile。真神奇。
### 10. electric-pair
最后,但并非最不重要,在我看来,electric-pair 是最简单但最强大的插件之一。它会自动关闭你输入的括号。它起初看起来并不是很有用,但相信我,在被寻找配对括号折磨几百次之后,你会很高兴有这么一个插件,可以确保你所有的表达式的括号都是一一对应的。
总结一下,Emacs 是一个奇妙的工具。这可不是一个令人惊讶的说法。试试这些插件,看着你的效率直线飙升吧。这个列表当然不是详尽的列表。如果你想贡献你的建议,请在评论中这样做。我自己一直在寻找新的插件来试着发现 Emacs 的新体验。
---
via: <http://xmodulo.com/best-plugins-to-increase-productivity-on-emacs.html>
作者:[Adrien Brochard](http://xmodulo.com/author/adrien) 译者:[zky001](https://github.com/zky001) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,892 | Grub 2:拯救你的 bootloader | https://www.linuxvoice.com/grub-2-heal-your-bootloader/ | 2016-01-18T08:32:00 | [
"Grub 2",
"bootloader",
"引导",
"启动"
] | /article-6892-1.html | 
**没有什么事情比 bootloader 坏掉更气人的了。充分发挥 Grub 2 的作用,让 bootloader 安分工作吧。**
为什么这么说?
* Grub 2 是最受欢迎的 bootloader ,几乎用在所有 Linux 发行版上。
* bootloader 是一个至关重要的软件,但是非常容易损坏。
* Grub 2 是兼具扩展性和灵活性的一款引导加载程序,提供了大量可定制选项。
Grub 2 是一款精彩的功能强大的软件。它不是 bootloader 界的一枝独秀,但却最受欢迎,几乎所有主要的桌面发行版都在使用它。 Grub 的工作有两个。首先,它用一个菜单展示计算机上所有已经安装的操作系统供你选择。其次,当你从启动菜单中选择了一个 Linux 操作系统, Grub 便加载这个 Linux 的内核。
你知道,如果使用 Linux ,你就离不开 bootloader 。然而它却是 Linux 发行版内部最鲜为人知的部分。在这篇文章里,我们将带你熟悉 Grub 2 一些著名的特性,强化你相关技能,使你在 bootloader 跑飞的时候能够自行处理。
Grub 2 最重要的部分是一堆文本文件和两个脚本文件。首先需要了解的是 `/etc/default/grub` 。这是一个文本文件,你可以在里面设置通用配置变量和 Grub 2 菜单(见下方 “常见用户设置” )的其它特性。
Grub 2 另一个重要的部分是 `/etc/grub.d` 文件夹。定义每个菜单项的所有脚本都放置在这里。这些脚本的名称必须有两位的数字前缀。其目的是,在构建 Grub 2 菜单时定义脚本的执行顺序以及相应菜单项的顺序。文件 `00_header` 首先被读取,负责解析 `/etc/default/grub` 配置文件。然后是 Linux 内核的菜单项,位于 `10_linux` 文件中。这个脚本在默认的 `/boot` 分区为每个内核创建一个正规菜单项和一个恢复菜单项。
紧接着的是为第三方应用所用的脚本,如 `30_os-prober` 和 `40_custom` 。 **os-prober** 脚本为内核和其它分区里的操作系统创建菜单项。它能识别安装的 Linux、 Windows、 BSD 以及 Mac OS X 。 如果你的硬盘布局比较独特,使得 **os-prober** 无法找到已经安装的发行版,你可以在 `40_custom` 文件(见下方 “添加自定义菜单项”)中添加菜单项。
**Grub** 2 不需要你手动维护你的启动选项的配置文件:取而代之的是使用 `grub2-mkconfig` 命令产生 `/boot/grub/grub.cfg` 文件。这个功能会解析 `/etc/grub.d` 目录中的脚本以及 `/etc/default/grub` 设置文件来定义你的设置情况。
>
> ### 图形化的引导修复
>
>
> 多亏了 Boot Repair 应用,只需要点击按钮,Grub 2 许许多多的问题都能轻易解决。这个漂亮小巧的应用有一个直观的用户界面,可以扫描并识别多种硬盘布局和分区方案,还能发现并正确识别安装在其中的操作系统。这个应用可以处理传统计算机里的<ruby> 主引导记录 <rp> ( </rp> <rt> Master Boot Record </rt> <rp> ) </rp></ruby> (MBR),也可以处理新型 UEFI 计算机中的<ruby> GUID 分区表 <rp> ( </rp> <rt> GUID Partition Table </rt> <rp> ) </rp></ruby>(GPT)。
>
>
> Boot Repair 最简单的使用方式是安装到 Live Ubuntu 会话中。在一个 bootloader 损坏的机器上启动 Ubuntu Live 发行版,先通过添加它的 PPA 版本库来安装 Boot Repair ,命令如下:
>
>
>
> ```
> sudo add-apt-repository ppa:yannubuntu/Boot Repair
>
> ```
>
> 然后刷新版本库列表:
>
>
>
> ```
> sudo apt-get update
>
> ```
>
> 安装应用,如下:
>
>
>
> ```
> sudo apt-get install -y Boot Repair
>
> ```
>
> 安装完毕后就启动应用。在显示它的界面(由一对按键组成)之前将会扫描你的硬盘。根据工具的指示,只需按下 <ruby> Recommended Repair <rp> ( </rp> <rt> 推荐的修复 </rt> <rp> ) </rp></ruby>按钮,即可修复大部分坏掉的 bootloader 。修复 bootloader 之后,这个工具会输出一个短小的 URL ,你应该把它记录下来。这个 URL 包含了硬盘详尽的信息:分区信息以及重要的 Grub 2 文件(如 `/etc/default/grub` 和 `/boot/grub/grub.cfg` )的内容。如果工具不能解决 bootloader 的问题,可以把你这个 URL 共享在你的发行版的论坛上,让其他人可以分析你的硬盘布局以便给你建议。
>
>
> 
>
>
> *Boot Repair 也可以让你定制 Grub 2 的选项。*
>
>
>
### Bootloader 急救
Grub 2 引导问题会让系统处于几种不同状态。屏幕(如你所想,本该显示 bootloader 菜单的地方)所展示的文本会指示出系统的当前状态。如果系统中止于 **grub>** 提示符,表明 Grub 2 模块已经被加载,但是找不到 **grub.cfg** 文件。当前是完全版的 Grub 2 命令行 shell,你可以通过多种方式解决此问题。如果你看到的是 **grub rescue>** 提示符,表明 bootloader 不能找到 Grub 2 模块或者找不到任何<ruby> 引导文件 <rp> ( </rp> <rt> boot files </rt> <rp> ) </rp></ruby>。然而,如果你的屏幕只显示 ‘GRUB’ 一词,表明 bootloader 找不到通常位于<ruby> 主引导记录 <rp> ( </rp> <rt> Master Boot Record </rt> <rp> ) </rp></ruby>里的最基本的信息。
你可以通过使用 live CD 或者在 Grub 2 shell 中修正此类错误。如果你够幸运, bootloader 出现了 **grub>** 提示符,你就能获得 Grub 2 shell 的支配权,来帮助你排错。
接下来几个命令工作在 **grub>** 和 **grub rescue>** 提示符下。 **set pager=1** 命令设置显示<ruby> 分页 <rp> ( </rp> <rt> pager </rt> <rp> ) </rp></ruby>,防止文本在屏幕上一滚而过。你还可以使用 **ls** 命令列出 Grub 识别出的所有分区,如下:
```
grub> ls
(hd0) (hd0,msdos5) (hd0,msdos6) (hd1,msdos1)
```
如你所见,这个命令列出分区的同时一并列出了分区表方案(即 msdos)。
你还可以在每个分区上面使用 **ls** 来查找你的根文件系统:
```
grub> ls (hd0,5)/
lost+found/ var/ etc/ media/ bin/ initrd.gz
boot/ dev/ home/ selinux/ srv/ tmp/ vmlinuz
```
你可以不写上分区名的 **msdos** 部分。同样,如果你忘记了尾部的<ruby> 斜杠 <rp> ( </rp> <rt> trailing slash </rt> <rp> ) </rp></ruby>只输入 `ls (hd0,5)` ,那你将获得分区的信息,比如文件系统类型、总体大小和最后修改时间。如果你有多个分区,可以使用 `cat` 读取 `/etc/issue` 文件中的内容,来确定发行版,格式如 `cat (hd0,5)/etc/issue` 。
假设你在 **(hd0,5)** 中找到根文件系统,请确保它包含 `/boot/grub` 目录,以及你想引导进入的内核镜像,如 **vmlinuz-3.13.0-24-generic** 。此时输入以下命令:
```
grub> set root=(hd0,5)
grub> linux /boot/vmlinuz-3.13.0-24-generic root=/dev/sda5
grub> initrd /boot/initrd.img-3.13.0-24-generic
```
第一个命令把 Grub 指向我们想引导进入的发行版所在的分区。接着第二个命令告知 Grub 内核镜像在分区中的位置,以及根文件系统的位置。最后一行设置<ruby> 虚拟文件系统 <rp> ( </rp> <rt> initial ramdisk </rt> <rp> ) </rp></ruby>文件的位置。你可以使用 tab 补全功能补全内核名字和<ruby> 虚拟文件系统 <rp> ( </rp> <rt> initrd: initial ramdisk </rt> <rp> ) </rp></ruby>的名字,节省时间和精力。
输入完毕,在下一个 **grub>** 提示符后输入 `boot` , Grub 将会引导进入指定的操作系统。
如果你在 **grub rescue>** 提示符下,情况会有些许不同。因为 bootloader 未能够找到并加载任何必需的模块,你需要手动添加这些模块:
```
grub rescue> set root=(hd0,5)
grub rescue> insmod (hd0,5)/boot/grub/normal.mod
grub rescue> normal
grub> insmod linux
```
如上所示,跟之前一样,使用 `ls` 命令列出所有分区之后,使用 `set` 命令标记起来。然后添加 **normal** 模块,此模块激活时将会恢复到标准 **grub>** 模式。如果 linux 模块没加载,接下来的命令会进行添加。如果这个模块已经加载,你可以跟之前一样,把引导加载程序指向内核镜像和<ruby> 虚拟文件系统 <rp> ( </rp> <rt> initrd </rt> <rp> ) </rp></ruby>文件,然后使用 `boot` 启动发行版,完美收官。
一旦成功启动发行版,别忘了为 Grub 重新产生新的配置文件,使用
```
grub-mkconfig -o /boot/grub/grub.cfg
```
命令。你还需要往 MBR 里安装一份 bootloader 的拷贝,使用
```
sudo grub2-install /dev/sda
```
命令。

*想要禁用 `/etc/grub.d` 目录下的脚本,你只需移除其可执行位,比如使用 `chmod -x /etc/grub.d/20_memtest86+` 就能将 ‘Memory Test’ 选项从菜单中移除。*
>
> ### Grub 2 和 UEFI
>
>
> 在支持 UEFI 的机器(最近几年上市的机器大部分都是)调试坏掉的 Grub 2 增加了另一复杂的层次。恢复安装在 UEFI 机器上的 **Grub 2** 的和安装在非 UEFI 机器上的并没多大区别,只是新的固件处理方式不一样,从而导致了很多种恢复结果。
>
>
> 对于基于 UEFI 的系统,不要在 MBR 上安装任何东西。相反,你要在<ruby> EFI 系统分区 <rp> ( </rp> <rt> EFI System Partition </rt> <rp> ) </rp></ruby>( ESP )里安装 Linux EFI bootloader,并且借助工具把它设置为 EFI 的默认启动程序,这个工具对于 Linux 用户是 `efibootmgr` ,对于 window 用户则是 `bcdedit` 。
>
>
> 照目前情况看,在安装任何与 Windows 8 兼容的主流桌面 Linux 发行版前,应该正确安装好 Grub 2。然而,如果 bootloader 损坏,你可以使用 live 发行版修复机器。在启动 live 介质之时,请确保是以 UEFI 模式启动。计算机每个可移动驱动器的启动菜单将会有两个: 一个普通的和一个以 EFI 标记的。使用后者会用到 **/sys/firmware/efi/** 文件中的 EFI 变量。
>
>
> 在 live 环境中,挂载教程前面所提的安装挂掉系统的根文件系统。除此之外,还需要挂载 ESP 分区。假设分区是 **/dev/sda1** ,你可以如下所示挂载:
>
>
>
> ```
> sudo mount /dev/sda1 /mnt/boot/efi
>
> ```
>
> 接着在 chroot 到安装完毕的发行版前之前,使用 `modprobe efivars` 加载 **efivars** 模块。
>
>
> 在这里, Fedora 用户可以使用如下命令重新安装 bootloader
>
>
>
> ```
> yum reinstall grub2-efi shim
>
> ```
>
> 但在此之前,需要使用
>
>
>
> ```
> grub2-mkconfig -o /boot/grub2/grub.cfg
>
> ```
>
> 来产生新的配置文件。 Ubuntu 用户则改用以下命令
>
>
>
> ```
> apt-get install --reinstall grub-efi-amd64
>
> ```
>
> 一旦 bootloader 正确就位,退出 chroot ,卸载所有分区,重启到 Grub 2 菜单。
>
>
>
### 伙计,我的 Grub 哪去了?
Grub 2 最好的特性是可以随时重新安装。因此,当其它像 Windows 之类的系统用它们自己的 bootloader 替换后,导致 Grub 2 丢失,你可以使用 live 发行版,寥寥数步即可重装 Grub 。假设你在 `/dev/sda5` 安装了一个发行版,若要重装 Grub ,你只需首先使用以下命令为发行版创建一个挂载目录:
```
sudo mkdir -p /mnt/distro
```
然后挂载分区,如下:
```
mount /dev/sda5 /mnt/distro
```
接着就能重装 Grub 了,如下:
```
grub2-install --root-directory=/mnt/distro /dev/sda
```
这个命令会改写 `/dev/sda` 设备上的 MBR 信息,指向当前 Linux 系统,并重写一些 Grub 2 文件,如 **grubenv** 和 **device.map** 。
另一个问题常见于装有多个发行版的计算机上。当你安装了新的 Linux 发行版,它的 bootloader 应当要能找到所有已经安装的发行版。一旦不行,只要引导进入新安装的发行版,并运行
```
grub2-mkconfig
```
在运行这个命令之前,请确保启动菜单中缺失的发行版的 root 分区已经挂载。如果你想添加的发行版有单独的 `/root` 和 `/home` 分区,在运行 `grub2-mkconfig` 之前,只需挂载包含 `/root` 的分区。
虽然 Grub 2 能够找到大部分发行版,但是在 Ubuntu 中尝试添加安装的 Fedora 系统需要额外的一个步骤。如果你以默认设置安装了 Fedora ,则发行版的安装器已经创建了 LVM 分区。此时你需要使用发行版的包管理系统安装 **lvm2** 驱动,如下
```
sudo apt-get install lvm2
```
才能使得 Grub 2 的 `os-prober` 脚本能够找到并将 Fedora 添加进启动菜单。
>
> ### 常见用户设置
>
>
> Grub 2 有很多可配置变量。 这里有一些 `/etc/default/grub` 文件中你最可能会修改到的常见变量。 **GRUB\_DEFAULT** 变量指定默认的启动项,可以设置为数字值,比如 0 ,表示第一个菜单项,或者设置为 “saved” ,将指向上一次启动时选中的菜单项。 **GRUB\_TIMEOUT** 变量指定启动默认菜单项之前的停留时间。 **GRUB\_CMDLINE\_LINUX** 列出了要传递给所有 Linux 菜单项的内核命令行参数。
>
>
> 如果 **GRUB\_DISABLE\_RECOVERY** 变量设置为 **true** ,那么将不生成恢复模式菜单项。这些菜单项会以单用户模式启动发行版,这种模式下允许你利用命令行工具修复系统。 **GRUB\_GFXMODE** 变量同样有用,它指定了菜单上文本显示的分辨率,它可以设置为你的显卡所支持的任何数值。
>
>
> 
>
>
> *Grub 2 有个命令行模式,通过在 bootloader 菜单上按 C 进入。*
>
>
>
### 彻底的修复
如果 `grub2-install` 命令不能正常运作,使得你无法引导进入 Linux ,你需要完整地重装以及重新配置 bootloader 。为此目的,需要用到强大的 **chroot** 功能将运行环境从 live CD 环境切换至我们想修复的 Linux 的安装位置。任何拥有 **chroot** 工具的 Linux live CD 都可以实现这个目的。不过需要确保 live 介质的系统架构和硬盘上系统的架构一致。因此当你希望 **chroot** 到 64 位系统,你必须使用 amd64 live 发行版。
启动进入 live 发行版之后,首先需要检查机器上的分区。使用 `fdisk -l` 列出磁盘上所有分区,记录你想修复的 Grub 2 系统所在的分区。
假设我们希望从安装在 `/dev/sda5` 中的发行版中恢复 bootloader 。启动终端使用如下命令挂载分区:
```
sudo mount /dev/sda5 /mnt
```
此时需要<ruby> 绑定 <rp> ( </rp> <rt> bind </rt> <rp> ) </rp></ruby>Grub 2 bootloader 需要进入的目录,以便检测其它操作系统:
```
$ sudo mount --bind /dev /mnt/dev
$ sudo mount --bind /dev/pts /mnt/dev/pts
$ sudo mount --bind /proc /mnt/proc
$ sudo mount --bind /sys /mnt/sys
```
此时可以离开 live 环境进入安装在 **/dev/sda5** 分区中的发行版了,通过 **chroot** :
```
$ sudo chroot /mnt /bin/bash
```
现在可以安装、检测、以及升级 Grub 了,跟之前一样,使用
```
sudo grub2-install /dev/sda
```
命令来重装 bootloader 。因为 **grub2-install** 命令不能创建**grub.cfg** 文件,需要手动创建,如下
```
sudo grub-mkconfig -o /boot/grub/grub.cfg
```
这样应该就可以了。现在你就有了 Grub 2 的一份全新拷贝,罗列了机器上所有的操作系统和发行版。在重启电脑之前,你需要依次退出 chroot 系统,卸载所有分区,如下所示:
```
$ exit
$ sudo umount /mnt/sys
$ sudo umount /mnt/proc
$ sudo umount /mnt/dev/pts
$ sudo umount /mnt/dev
$ sudo umount /mnt
```
现在你可以安全地重启电脑了,而它应该会回退到 Grub 2 的控制之中,你已经修好了这个 bootloader。
>
> ### 添加自定义菜单项
>
>
> 如果希望往 bootloader 菜单里添加菜单项,你需要在 **40\_custom** 文件里添加一个<ruby> 启动段 <rp> ( </rp> <rt> boot stanza </rt> <rp> ) </rp></ruby>。例如,你可以使用它展示一个菜单项来启动安装在可移动 USB 驱动里的 Linux 发行版。假设你的 USB 驱动器是 **sdb1** ,并且 vmlinuz 内核镜像和<ruby> 虚拟文件系统 <rp> ( </rp> <rt> initrd </rt> <rp> ) </rp></ruby>都位于根 (/)目录下,在 **40\_custom** 文件中添加以下内容:
>
>
>
> ```
> menuentry “Linux on USB” {
> set root=(hd1,1)
> linux /vmlinuz root=/dev/sdb1 ro quiet splash
> initrd /initrd.img
> }
>
> ```
>
> 相比使用设备和分区名,使用它们的 UUID 可以获得更精确结果,比如
>
>
>
> ```
> set root=UUID=54f22dd7-eabe
>
> ```
>
> 使用
>
>
>
> ```
> sudo blkid
>
> ```
>
> 来获得所有已连接的驱动器和分区的 UUID 。你还可以为你磁盘上没被 os-prober 脚本找到的发行版添加菜单项,只要你知道该发行版的安装位置以及其内核和<ruby> 虚拟文件系统 <rp> ( </rp> <rt> initrd </rt> <rp> ) </rp></ruby>的位置即可。
>
>
>
---
via: <https://www.linuxvoice.com/grub-2-heal-your-bootloader/>
作者:[Mayank Sharma](https://www.linuxvoice.com/author/mayank/) 译者:[soooogreen](https://github.com/soooogreen) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPSConnectionPool(host='www.linuxvoice.com', port=443): Max retries exceeded with url: /grub-2-heal-your-bootloader/ (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:1007)'))) | null |
6,897 | 为什么主线内核不能运行在我的手机上? | https://lwn.net/Articles/662147/ | 2016-01-16T20:55:14 | [
"手机",
"Linux",
"内核"
] | https://linux.cn/article-6897-1.html | 对于自由软件来说,其最大的自由之一就是能够用一个更新或修改的版本来替换原始版本的程序。尽管如此,数千万使用那些手机里面装着所谓 Linux 的用户却很少能够在他们的手机上运行<ruby> 主线内核 <rp> ( </rp> <rt> mainline kernel </rt> <rp> ) </rp></ruby>,即使他们拥有替换内核代码的专业技能。可悲的是,我们必须承认目前仍然没有可以运行主线内核的主流手机。在由 Rob Herring 主持的2015届<ruby> 内核峰会 <rp> ( </rp> <rt> Kernel Summit </rt> <rp> ) </rp></ruby>上,与会人员共同探讨了这个问题,并进一步谈论了他们应该怎么做才能解决这个问题。

当主持人提问的时候,在座的大多数开发人员都表示他们更乐意在他们的手机上面运行主线内核,然而也有少数人持相反的看法。在 Project Ara 的支持下,Rob 在这个问题上已经研究了近一年半的时间(参见:<https://lwn.net/Articles/648400/> )。但是最新的研究成果并不理想。
Rob 表示,通常手机上运行了太多的<ruby> 过期 <rp> ( </rp> <rt> out-of-tree </rt> <rp> ) </rp></ruby>代码;主线内核只是缺少能使手机正常运行所必须的驱动。每台常规的手机都在运行着100万行到300万行的<ruby> 过期 <rp> ( </rp> <rt> out-of-tree </rt> <rp> ) </rp></ruby>代码。几乎所有的这些手机的内核版本都不超过3.10,有一些甚至更加古老。造成这种情况的原因有很多,但是有一点是很清楚的,在手机的世界里,一切都变化的太快以至于无法跟上内核社区的步伐。如果真是那样,他问到,我们还担心什么呢?
Tim Bird 指出,第一台 Android 手机 Nexus 1 从来没有运行过任何一个主线内核,并且以后也不会。它打破了开源的承诺,也使得用户不可能做到将一个新的内核放到手机中。从这一点上来说,没有任何一款手机支持这种能力。Peter Zijlstra 想知道从一台手机到另一台手机到底复制了多少能够工作的过期代码;Rob 表示,迄今为止,他已经见到了三个独立开发的热插拔 [Governors](http://androidmodguide.blogspot.com/p/blog-page.html)。

Dirk Hohndel 提出了很少有人注意到的建议。他说,对于世界上的数以亿计的手机,大约只有他们27个人关心他们的手机是否运行着主线内核。剩下的用户仅仅只是想让他们的手机正常工作。或许那些关注手机是否在运行主线内核的开发者正在努力去解决这个令人不解的问题。
Chris Mason 说,那些手机厂商当前正面临着相同类型的问题,而这些问题也是那些 Linux 发行版过去所面临过的问题。他们疲于应付大量的无效且重复和能被复用的工作。一旦这些发行版决定将他们的工作配合主线内核而不是使用自己维护的内核,那么问题将会变得好解决的多。解决问题的关键就是去帮助手机制造商们认识到他们可以通过同样的方式获得便利,形成这种认识的关键并不是通过来自用户的压力。这样一来,问题就可以解决了。
Grant Likely 提出了对于安全问题的担忧,这种担忧来自于那些不能升级他们的手机系统的 android 设备。他说,我们需要的是一个真正专为手机设立的发行版。但是,只要手机厂商仍然掌控着手机中的应用软件,那么手机的同步更新将无法实现。我们接下来将面临一个很大的安全难题。Peter 补充说,随着 [Stagefright 漏洞](https://lwn.net/Articles/652728/)的出现,难题已经出现在我们面前了。
Ted Ts'o 说,运行主线内核并不是他的主要关注点。他很乐于见到这个假期中所售卖的手机能够运行3.18或者4.1的内核,而不是继续停留在3.10。他认为这是一个更可能被解决的问题。Steve Rostedt 认为,按照 Ted Ts'o 所说的那样去做并不能解决手机的安全问题,但是,Ted 认为使用一个更新一些的内核至少可以让漏洞修复变得更加容易。Grant 对此回应说,接下来的一年里,这一切都将再次发生;过渡到更新的内核也是一个渐进式的对系统的完善。Kees Cook 补充说,我们无法从修复旧版本的内核漏洞的过程中得到太多的益处,真正的问题是我们没有对 bug 的应对措施(他会在今天的另外一个对话中讲到这个话题)。
Rob 说,任何一种解决方案都需要得到当前市场上的手机供应商的支持。否则,由于厂商对安装到他们生产的手机上的操作系统的封锁,运行主线内核的策略将会陷入麻烦。Paolo Bonzini 提问说是否可以因为那些没有修复的安全漏洞而控告手机厂商,尤其当手机仍然处于保修期内。Grant 认为对于手机的<ruby> 可更新能力 <rp> ( </rp> <rt> upgradeability </rt> <rp> ) </rp></ruby>的保证必须来源于市场需求,否则是无法实现的。而促使它实现的原因可能会是一个严重的安全问题,然后用户开始对手机的可更新能力提出要求。同时,内核开发人员必须不断朝着这个方向努力。Rob 表示,除了到目前为止指出的所有优点之外,运行主线内核也能帮助开发者对安卓设备上的新特性进行测试和验证。
Josh Triplett 提问说,如果手机厂商提出对主线内核提供支持的想法,那么内核社区又将采取什么措施呢?那样将会针对手机各方面的特性要求对内核进行大量的测试和验证;[Android 的兼容性测试套件](https://source.android.com/compatibility/cts/index.html)中出现的失败将不得不被再次回归到内核。Rob 提议这个问题可以在明年讨论,即先将最基本的功能做好。但是,Josh 强调说,如果这个需求出现了,我们就应该能够给出一个好的答案。
Tim 认为,当前,我们和厂商之间存在很大的脱节。厂商根本不会主动报告或者贡献任何反馈给社区。他们之间完全脱节了,这样的话永远不会有进步。Josh 表示,当厂商们开始报告他们正在使用的旧内核的相关 bug 时,双方之间的接受度将变得更加友好。Arnd Bergmann 认为,我们需要的是得到一个大芯片厂商对使用主线内核的认可,并且将该厂商的硬件提升到能够支持主线内核的运行的这样一个水平,而这样将会在其他方面增加负担。但是,他补充说,实现这个目标要求存在一个跟随硬件一起分发的自由 GPU 驱动程序——然而这种程序当前并不存在。

Rob 给存在问题的领域列了一个清单,但是现在已经没有太多的时间去讨论其中的细节了。WiFi 驱动仍然是一个问题,尤其是当这个新特性被添加到 Android 设备上的时候。Johannes Berg 对新特性仍然存在问题表示赞同;Android 的开发人员甚至在这些新特性被应用到 Android 设备上之前都不会去谈论它们是否存在问题。然而,对这些特性中的大多数的技术支持最终都会落实在主线内核中。
随着会议逐渐接近尾声,Ben Herrenschmidt 再次重申:实现在 Android 手机上运行主线内核的关键还是在于让厂商认识到使用主线内核是它们获得最大利润的最好选择。从长远看,使用主线内核能节省大量的工作。Mark Brown 认为,以前,当搭载在 Android 设备上的内核版本以更稳定的方式向前推进的时候,上游工作的好处对运营商来说更加明显。以现在的情况来看,手机上的内核版本似乎停留在了3.10,那种压力是不一样的。
这次谈话以开发者决定进一步改善当前的状况而结束,但是却并没有对如何改善提出一个明确的计划。
---
via: <https://lwn.net/Articles/662147/>
作者:[Jonathan Corbet](https://lwn.net/Articles/KernelSummit2015/) 译者:[kylepeng93](https://github.com/kylepeng93) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
| 404 | Not Found | null |
6,898 | jobs 命令示例 | http://www.cyberciti.biz/faq/unix-linux-jobs-command-examples-usage-syntax/ | 2016-01-17T11:49:14 | [
"jobs"
] | https://linux.cn/article-6898-1.html | 我是个新的 Linux/Unix 用户。我该如何在 Linux 或类 Unix 系统中使用 BASH/KSH/TCSH 或者基于 POSIX 的 shell 来查看当前正在进行的<ruby> 作业 <rp> ( </rp> <rt> job </rt> <rp> ) </rp></ruby>?在 Unix/Linux 上怎样显示当前作业的状态?(LCTT 译注:job,也常称为“任务”)
作业控制是一种能力,可以停止/暂停进程(命令)的执行并按你的要求继续/恢复它们的执行。这是通过你的操作系统和诸如 bash/ksh 或 POSIX shell 等 shell 来执行的。

shell 会将当前所执行的作业保存在一个表中,可以用 jobs 命令来显示。
### 用途
>
> 在当前 shell 会话中显示作业的状态。
>
>
>
### 语法
其基本语法如下:
```
jobs
```
或
```
jobs jobID
```
或者
```
jobs [options] jobID
```
### 启动一些作业来进行示范
在开始使用 jobs 命令前,你需要在系统上先启动多个作业。执行以下命令来启动作业:
```
### 启动 xeyes, calculator, 和 gedit 文本编辑器 ###
xeyes &
gnome-calculator &
gedit fetch-stock-prices.py &
```
最后,在前台运行 ping 命令:
```
ping www.cyberciti.biz
```
按 **Ctrl-Z** 键来<ruby> 挂起 <rp> ( </rp> <rt> suspend </rt> <rp> ) </rp></ruby> ping 命令的作业。
### jobs 命令示例
要在当前 shell 显示作业的状态,请输入:
```
$ jobs
```
输出示例:
```
[1] 7895 Running gpass &
[2] 7906 Running gnome-calculator &
[3]- 7910 Running gedit fetch-stock-prices.py &
[4]+ 7946 Stopped ping cyberciti.biz
```
要显示名字以“p”开头的进程 ID 或作业名称,输入:
```
$ jobs -p %p
```
或者
```
$ jobs %p
```
输出示例:
```
[4]- Stopped ping cyberciti.biz
```
字符 % 是一个指定任务的方法。在这个例子中,你可以使用作业名称开头字符串来来暂停它,如 %ping。
### 如何显示进程 ID 不包含其他正常的信息?
通过 jobs 命令的 -l(小写的 L)选项列出每个作业的详细信息,运行:
```
$ jobs -l
```
示例输出:

*Fig.01: 在 shell 中显示 jobs 的状态*
### 如何只列出最近一次状态改变的进程?
首先,启动一个新的工作如下所示:
```
$ sleep 100 &
```
现在,只显示自从上次提示过停止或退出之后的作业,输入:
```
$ jobs -n
```
示例输出:
```
[5]- Running sleep 100 &
```
### 仅显示进程 ID(PID)
通过 jobs 命令的 -p 选项仅显示 PID:
```
$ jobs -p
```
示例输出:
```
7895
7906
7910
7946
7949
```
### 怎样只显示正在运行的作业呢?
通过 jobs 命令的 -r 选项只显示正在运行的作业,输入:
```
$ jobs -r
```
示例输出:
```
[1] Running gpass &
[2] Running gnome-calculator &
[3]- Running gedit fetch-stock-prices.py &
```
### 怎样只显示已经停止工作的作业?
通过 jobs 命令的 -s 选项只显示停止工作的作业,输入:
```
$ jobs -s
```
示例输出:
```
[4]+ Stopped ping cyberciti.biz
```
要继续执行 ping cyberciti.biz 作业,输入以下 bg 命令:
```
$ bg %4
```
### jobs 命令选项
摘自 [bash(1)](http://www.manpager.com/linux/man1/bash.1.html) 命令 man 手册页:
| 选项 | 描述 |
| --- | --- |
| `-l` | 列出进程 ID 及其它信息。 |
| `-p` | 仅列出进程 ID。 |
| `-n` | 仅列出自从上次输出了状态变化提示(比如显示有进程退出)后的发生了状态变化的进程。 |
| `-r` | 仅显示运行中的作业。 |
| `-s` | 仅显示停止的作业。 |
| `-x` | 运行命令及其参数,并用新的命令的进程 ID 替代所匹配的原有作业的进程组 ID。 |
### 关于 /usr/bin/jobs 和 shell 内建的说明
输入以下 type 命令找出是否 jobs 命令是 shell 的内建命令或是外部命令还是都是:
```
$ type -a jobs
```
输出示例:
```
jobs is a shell builtin
jobs is /usr/bin/jobs
```
在几乎所有情况下,你都需要使用 BASH/KSH/POSIX shell 内建的jobs 命令。/usr/bin/jobs 命令不能被用在当前 shell 中。/usr/bin/jobs 命令工作在不同的环境中,并不共享其父 bash/ksh 的 shell 作业。
---
via: <http://www.cyberciti.biz/faq/unix-linux-jobs-command-examples-usage-syntax/>
作者:Vivek Gite 译者:[strugglingyouth](https://github.com/strugglingyouth) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,899 | 衡量开源社区的五大指标 | https://opensource.com/business/15/12/top-5-open-source-community-metrics-track | 2016-01-17T13:03:45 | [
"开源社区",
"开源"
] | https://linux.cn/article-6899-1.html | 
如果你想要使用指标来追踪你的自由开源软件(FOSS)的社区。现在就面临着一个问题:我应该去追踪哪些指标呢?
要回答这个问题,你必须知道你需要什么信息。比如,你可能想要知道一个项目社区的可持续性。一个社区对问题的应对速度有多快。一个社区怎么吸引、维护或者流失贡献者。一旦你知道需要哪类信息,你就可以找出哪些社区活动可以提供你想要知道的内容。幸运的是,自由开源软件(FOSS)遵从开放式开发模型,在其软件开发仓库里留下了大量的公共数据,我们可以对这些数据进行分析,并从中收集到一些有用的数据。
在这篇文章中,我会介绍一些指标,从而为你的项目社区提供一个多方位的视角分析。
### 1. 社区活动(Activity)
一个社区的总体活动和这个社区怎样随着时间演变,是度量所有社区好坏的非常有用的指标。社区活动是评价一个社区工作量的第一印象,也可以用来追踪不同种类的活动。比如,提交次数,给人的第一印象就是跟开发工作量挂钩。通过<ruby> 提出的问题 <rp> ( </rp> <rt> tickets opened </rt> <rp> ) </rp></ruby>我们可以大概知道提交了多少 bug 或者又提出了多少新特性。邮件列表中的邮件数量或者论坛帖子的数量可以让我们了解到有过多少次公开讨论。

*[OpenStack 活动看板](http://activity.openstack.org/)上面显示的项目代码提交次数和代码评审之后代码合并次数随时间变化的趋势图(周数据)*
### 2. 社区规模(Size)
社区的规模指的是参与到这个社区的人数,但是,基于不同形式的参与人数也有很大的差别。好消息是,通常你只对积极活跃的贡献者比较感兴趣。活跃的贡献者会在项目的仓库留下一些线索。这意味着你可以通过查看 git 仓库存放的代码中 author字段来统计积极贡献代码的人数,或者通过看积极参与问题解决的人数来统计活跃人数。
所谓活动(某些人做了某些事)可以扩展到很多方面。一种常见的跟踪活动的方式是看有多少人做了工作量相当可观的任务。比如,通常一个项目代码的贡献者是来自这个项目社区的一小部分人。了解了这一小部分人,就对核心的工作组(比如,领导这个社区的人)有一个基本的认识了。

*[Xen 项目开发看板](http://projects.bitergia.com/xen-project-dashboard/)上展示的该项目邮件列表上作者人数和提交人数随时间的变化趋势(每月数据)*
### 3. 社区表现(Performance)
到目前为止,关注点主要集中在活动数量和贡献者数量的统计上了。你也可以分析流程还有用户的表现如何。比如,你可以测量某流程需要多久才能执行完成。解决或者关闭问题的时间可以表明一个需要及时响应的项目对新信息的应对如何,比如修复一个报告过来的 bug 或者实现一个新需求。代码评审花费的时间,即从代码修改提交到被通过的时间,可以看出更新一个提出的改变要达到社区期望的标准需要多久。
其他的一些指标主要与项目处理挂起的工作表现如何有关,比如新的和被关闭问题的比例,或者仍然没有完成的代码评审的队列。这些参数能告诉我们像投入到解决这些问题的资源是否充足这样的一些信息。

*在[2015第三季度 OpenStack 开发报告](http://activity.openstack.org/dash/reports/2015-q3/pdf/2015-q3_OpenStack_report.pdf)上显示的,每季度关闭与打开状态的问题数之比,接受与放弃的改变提案与最新的改变提案之比*
### 4. 社区人口特征(Demographics)
随着贡献者的参与或者退出,社区也在不断改变。随着人们加入和退出社区,社区成员的会龄(从社区成员加入时算起)也各异。[社区会龄统计图表](http://radar.oreilly.com/2014/10/measure-your-open-source-communitys-age-to-keep-it-healthy.html)很直观的展现了这些改变随时间的变化。图表是由一系列的水平条组成,每两条水平条代表加入到社区的一代人。对于每一代,<ruby> 吸引力 <rp> ( </rp> <rt> Attracted </rt> <rp> ) </rp></ruby>水平条表示在相应的时间里有多少人加入到了社区。<ruby> 活跃度 <rp> ( </rp> <rt> Retained </rt> <rp> ) </rp></ruby>水平条表示有多少人目前仍然活跃在社区。
代表一代人的两个水平条的关系就是滞留比例:依然在这个项目中的那一代人的一部分。<ruby> 吸引力 <rp> ( </rp> <rt> Attracted </rt> <rp> ) </rp></ruby>水平条的完整集合表示这个项目在过去有多么受欢迎。<ruby> 活跃度 <rp> ( </rp> <rt> Retained </rt> <rp> ) </rp></ruby>水平条的完整集合则表示社区目前的会龄结构。

*[Eclipse 开发看板](http://dashboard.eclipse.org/demographics.html)上显示的 Eclipse 社区的社区年龄表。每六个月定义一次*
### 5. 社区多样性(Diversity)
多样性是一个社区保持弹性的很关键的因素。通常来说,一个社区越具有多样性(人或者组织参与的多元化),那么这个社区的弹性也就越大。比如,如果一个公司要决定离开一个自由开源社区,那么这个公司的员工贡献5%要远比贡献85%所可能引起的潜在问题要小很多。
<ruby> <a href="https://ke4qqq.wordpress.com/2015/02/08/pony-factor-math/"> 小马因素 </a> <rp> ( </rp> <rt> Pony Factor </rt> <rp> ) </rp></ruby>,是 [Daniel Gruno](https://twitter.com/humbedooh) 为“最少的开发者贡献了50%的代码提交量”这一现象定义的术语。基于小马因素,<ruby> 大象因素 <rp> ( </rp> <rt> Elephant Factor </rt> <rp> ) </rp></ruby>则是指最少量的公司其员工贡献了50%的代码提交量。这两个数据提供了一种指示,即这个社区依赖多少人或者公司。

*[2015开发云数量状态统计](https://speakerdeck.com/jgbarah/the-quantitative-state-of-the-open-cloud-2015-edition)显示的在云计算领域的几个自由开源社区项目的小马和大象因素。*
还有许多其他的指标来衡量一个社区。在决定收集哪些指标时,可以考虑一下社区的目标,还有哪些指标能帮到你。
---
via: <https://opensource.com/business/15/12/top-5-open-source-community-metrics-track>
作者:[Jesus M. Gonzalez-Barahona](https://opensource.com/users/jgbarah) 译者:[sonofelice](https://github.com/sonofelice) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | So you decided to use metrics to track your free, open source software (FOSS) community. Now comes the big question: Which metrics should I be tracking?
To answer this question, you must have an idea of what information you need. For example, you may want to know about the sustainability of the project community. How quickly does the community react to problems? How is the community attracting, retaining, or losing contributors? Once you decide which information you need, you can figure out which traces of community activity are available to provide it. Fortunately, FOSS projects following an open development model tend to leave loads of public data in their software development repositories, which can be analyzed to gather useful data.
In this article, I'll introduce metrics that help provide a multi-faceted view of your project community.
## 1. Activity
The overall activity of the community and how it evolves over time is a useful metric for all open source communities. Activity provides a first view of *how much* the community is doing, and can be used to track different kinds of activity. For example, the number of commits gives a first idea about the volume of the development effort. The number of tickets opened provides insight into how many bugs are reported or new features are proposed. The number of messages in mailing lists or posts in forums gives an idea of how much discussion is being held in public.
Number of commits and number of merged changes after code review in the OpenStack project, as found in the OpenStack Activity Dashboard. Evolution over time (weekly data).
## 2. Size
The size of the community is the number of people participating in it, but, depending on the kind of participation, size numbers may vary. Usually you're interested in *active contributors*, which is good news. Active people may leave traces in the repositories of the project, which means you can count contributors who are active in producing code by looking at the *Author* field in git repositories, or count people participating in the resolution of tickets by looking at who is contributing to them.
This basic idea of *activity*" (somebody did something) can be extended in many ways. One common way to track activity is to look at how many people did a sizable chunk of the activity. Generally most of a project's code contributions, for example, are from a small fraction of the people in the project's community. Knowing about that fraction helps provide an idea of the core group (i.e., the people who help lead the community).
Number of authors and number of posters in mailing lists in the Xen project, as found in the Xen Project Development Dashboard. Evolution over time (monthly data).
## 3. Performance
So far, I have focused on measuring quantities of activities and contributors. You also can analyze *how* processes and people are performing. For example, you can measure how long processes take to finish. Time to resolve or close tickets shows how the project is reacting to new information that requires action, such as fixing a reported bug or implementing a requested new feature. Time spent in code review—from the moment when a change to the code is proposed to the moment it is accepted—shows how long upgrading a proposed change to the quality standards expected by the community takes.
Other metrics deal with how well the project is coping with pending work, such as the ratio of new to closed tickets, or the backlog of still non-completed code reviews. Those parameters tell us, for example, whether or not the resources put into solving issues is enough.
Ratio of tickets closed by tickets opened, and ratio of change proposals accepted or abandoned by new change proposals per quarter. OpenStack project, as shown in the OpenStack Development Report, 2015-Q3 (PDF).
## 4. Demographics
Communities change as contributors move in and out. Depending on how people enter and leave a community over time, the *age* (time since members joined the community) of the community varies. The [community aging chart](http://radar.oreilly.com/2014/10/measure-your-open-source-communitys-age-to-keep-it-healthy.html) nicely illustrates these exchanges over time. The chart is structured as a set of horizontal bars, two per "generation" of people joining the community. For each generation, the *attracted* bar shows how many new people joined the community during the corresponding period of time. The *retained* bar shows how many people are still active in the community.
The relationship between the two bars for each generation is the retention rate: the fraction of people of that generation who are still in the project. The complete set of attracted bars show how attractive the project was in the past. And the complete set of the retention bars shows the current age structure of the community.
Community aging chart for the Eclipse community, as shown in the Eclipse Development Dashboard. Generations are defined every six months.
## 5. Diversity
Diversity is an important factor in the resiliency of communities. In general, the more diverse communities are—in terms of people or organizations participating—the more resilient they are. For example, when a company decides to leave a FOSS community, the potential problems the departure may cause are much smaller if its employees were contributing 5% of the work rather than 85%.
The [Pony Factor](https://ke4qqq.wordpress.com/2015/02/08/pony-factor-math/), a term defined by [Daniel Gruno](https://twitter.com/humbedooh) for the minimum number of developers performing 50% of the commits. Based on the Pony Factor, the Elephant Factor is the minimum number of companies whose employees perform 50% of the commits. Both numbers provide an indication of how many people or companies the community depends on.
Pony and Elephant Factor for several FOSS projects in the area of cloud computing, as presented in The quantitative state of the open cloud 2015 (slides).
There are many other metrics to help measure a community. When determining which metrics to collect, think about the goals of your community, and which metrics will help you reach them.
## Comments are closed. |
6,901 | 如何在 CentOS / RHEL 上设置 SSH 免密码登录 | http://www.ehowstuff.com/ssh-login-without-password-centos/ | 2016-01-18T07:08:00 | [
"SSH",
"OpenSSH"
] | https://linux.cn/article-6901-1.html | 
作为系统管理员,你计划在 Linux 上使用 OpenSSH,完成日常工作的自动化,比如文件传输、备份数据库转储文件到另一台服务器等。为实现该目标,你需要从主机 A 能自动登录到主机 B。自动登录也就是说,要在 shell 脚本中使用ssh,而无需要输入任何密码。
本文会告诉你怎样在 CentOS/RHEL 上设置 SSH 免密码登录。自动登录配置好以后,你可以通过它使用 SSH (Secure Shell)和安全复制 (SCP)来移动文件。
SSH 是开源的,是用于远程登录的最为可靠的网络协议。系统管理员用它来执行命令,以及通过 SCP 协议在网络上向另一台电脑传输文件。
通过配置 SSH 免密码登录,你可以享受到如下的便利:
* 用脚本实现日常工作的自动化。
* 增强 Linux 服务器的安全性。这是防范虚拟专用服务器(VPS)遭受暴力破解攻击的一个推荐的方法,SSH 密钥单凭暴力破解是几乎不可攻破的。
### 什么是 ssh-keygen
ssh-keygen 是一个用来生成、创建和管理 SSH 认证用的公私钥的工具。通过 ssh-keygen 命令,用户可以创建支持SSH1 和 SSH2 两个协议的密钥。ssh-keygen 为 SSH1 协议创建 RSA 密钥,SSH2 则可以是 RSA 或 DSA。
### 什么是 ssh-copy-id
ssh-copy-id 是用来将本地公钥拷贝到远程的 authorized\_keys 文件的脚本命令,它还会将身份标识文件追加到远程机器的 ~/.ssh/authorized*\_*keys 文件中,并给远程主机的用户主目录适当的的权限。
### SSH 密钥
SSH 密钥为登录 Linux 服务器提供了更好且安全的机制。运行 ssh-keygen 后,将会生成公私密钥对。你可以将公钥放置到任意服务器,从持有私钥的客户端连接到服务器的时,会用它来解锁。两者匹配时,系统无需密码就能解除锁定。
### 在 CentOS 和 RHEL 上设置免密码登录 SSH
以下步骤在 CentOS 5/6/7、RHEL 5/6/7 和 Oracle Linux 6/7 上测试通过。
节点1 : 192.168.0.9 节点2 : 192.168.l.10
#### 步骤1 :
测试节点1到节点2的连接和访问:
```
[root@node1 ~]# ssh [email protected]
The authenticity of host '192.168.0.10 (192.168.0.10)' can't be established.
RSA key fingerprint is 6d:8f:63:9b:3b:63:e1:72:b3:06:a4:e4:f4:37:21:42.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.0.10' (RSA) to the list of known hosts.
[email protected]'s password:
Last login: Thu Dec 10 22:04:55 2015 from 192.168.0.1
[root@node2 ~]#
```
#### 步骤二:
使用 ssh-key-gen 命令生成公钥和私钥,这里要注意的是可以对私钥进行加密保护以增强安全性。
```
[root@node1 ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
b4:51:7e:1e:52:61:cd:fb:b2:98:4b:ad:a1:8b:31:6d [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
| . ++ |
| o o o |
| o o o . |
| . o + .. |
| S . . |
| . .. .|
| o E oo.o |
| = ooo. |
| . o.o. |
+-----------------+
```
#### 步骤三:
用 ssh-copy-id 命令将公钥复制或上传到远程主机,并将身份标识文件追加到节点2的 ~/.ssh/authorized\_keys 中:
```
[root@node1 ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub 192.168.0.10
[email protected]'s password:
Now try logging into the machine, with "ssh '192.168.0.10'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
```
#### 步骤四:
验证免密码 SSH 登录节点2:
```
[root@node1 ~]# ssh [email protected]
Last login: Sun Dec 13 14:03:20 2015 from www.ehowstuff.local
```
我希望这篇文章能帮助到你,为你提供 SSH 免密码登录 CentOS / RHEL 的基本认知和快速指南。
---
原载: <http://www.ehowstuff.com/ssh-login-without-password-centos/>
作者:[skytech](http://www.ehowstuff.com/author/skytech/) 译者:[fw8899](https://github.com/fw8899) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,902 | 与 Linux 一起学习:学习打字 | https://www.maketecheasier.com/learn-to-type-in-linux/ | 2016-01-18T08:24:00 | [
"打字"
] | https://linux.cn/article-6902-1.html | 
“与 Linux 一起学习”的所有文章:
* [与 Linux 一起学习:学习打字](/article-6902-1.html)
* [与 Linux 一起学习:学习物理](/article-6903-1.html)
* [与 Linux 一起学习:学习音乐](/article-6912-1.html)
* [与 Linux 一起学习:学习地理](/article-6913-1.html)
* [与 Linux 一起学习:学习数学](/article-6546-1.html)
Linux 提供大量的教学软件和工具,面向各个年级以及不同年龄段,提供大量学科的练习实践,其中大多数是可以与用户进行交互的。本“与 Linux 一起学习”系列就来介绍一些教学软件。
很多人都要打字,操作键盘已经成为他们的第二天性。但是这些人中有多少是依然使用两个手指头来快速地按键盘的?即使学校有教我们使用键盘的方法,我们也会慢慢地抛弃正确的打字姿势,养成只用两个大拇指玩键盘的习惯。(LCTT 译注:呃,你确认是拇指而不是食指?)
下面要介绍的两款软件可以帮你掌控你的键盘,然后你就可以让你的手指跟上你的思维,这样你的思维就不会被打断了。当然,还有很多更炫更酷的软件可供选择,但本文所选的这两款是最简单、最容易上手的。
### TuxType (或者叫 TuxTyping)
TuxType 是给小孩子玩的。在一些有趣的游戏中,小学生们可以通过完成一些简单的练习来 Get “双手打字以示清白”的新技能。
Debian 及其衍生版本(包含所有 Ubuntu 衍生版本)的标准软件仓库都有 TuxType,使用下面的命令安装:
```
sudo apt-get install tuxtype
```
软件开始时有一个简单的 Tux 界面和一段难听的 midi 音乐,幸运的是你可以通过右下角的喇叭按钮把声音调低了。(LCTT 译注:Tux 就是那只 Linux 吉祥物,Linus 说它的表情被设计成刚喝完啤酒后的满足感,见《Just For Fun》。)

最开始处的两个选项“Fish Cascade”和“Comet Zap”是打字游戏,当你开始游戏时,你就投入到了这个课程。
第3个选项为“Lessions”,提供40多个简单的课程,每个课程会增加一个字母让你来练习,练习过程中会给出一些提示,比如应该用哪个手指按键盘上的字母。


更高级点的,你可以练习输入句子。不知道为什么,句子练习被放在“Options”选项里。(LCTT 译注:句子练习第一句是“The quick brown fox jumps over the lazy dog”,包含了26个英文字母,可用于检测键盘是否坏键,也是练习英文打字的必备良药啊。)

这个游戏让玩家打出单词来帮助 Tux 吃到小鱼或者干掉掉下来的流星,训练速度和精确度。


除了练习有趣外,这些游戏还可以训练玩家的拼写、速度、手眼配合能力,因为你如果认真在玩的话,必须盯着屏幕,不看键盘打字。
### GNU typist (gtype)
对于成年人或有打字经验的人来说,GNU Typist 可能更合适,它是一个 GNU 项目,基于控制台操作。
GNU Typist 也在大多数 Debian 衍生版本的软件库中,运行下面的命令来安装:
```
sudo apt-get install gtypist
```
你估计不能在应用菜单里找到它,只能在终端界面上执行下面的命令来启动:
```
gtypist
```
界面简单,没有废话,直接提供课程内容,玩家选择就是了。

课程直截了当,内容详细。

在交互练习的过程中,如果你输入错误,会将错误位置高亮显示。不会像其他漂亮界面分散你的注意力,你可以专注于练习。每个课程的右下角都有一组统计数据来展示你的表现,如果你犯了很多错误,就可能无法通过关卡了。

简单练习只需要你重复输入一些字符,而高阶练习需要你输入整个句子。

下图的错误已经超过 3%,错误率太高了,你得降低些。

一些训练用于完成特殊目标,比如“平衡键盘训练(LCTT 译注:感觉是用来练习手感的)”。

下图是速度练习。

下图是要你输入一段经典文章。

如果你想练习其他语种,操作一下命令行参数就行。

### 总结
如果你想练练自己的打字水平,Linux 上有很多软件给你用。本文介绍的两款软件界面简单但内容丰富,能满足绝大多数打字爱好者的需求。如果你正在使用、或者听说过其他的优秀打字练习软件,请在评论栏贴出来,让我们长长姿势。
---
via: <https://www.maketecheasier.com/learn-to-type-in-linux/>
作者:[Attila Orosz](https://www.maketecheasier.com/author/attilaorosz/) 译者:[bazz2](https://github.com/bazz2) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | Linux offers great educational software and many excellent tools to aid students of all grades and ages in learning and practicing a variety of topics, often interactively. The “Learn with Linux” series of articles offers an introduction to a variety of educational apps and software.
Typing is taken for granted by many people; today being keyboard savvy often comes as second nature. Yet how many of us still type with two fingers, even if ever so fast? Once typing was taught in schools, but slowly the art of ten-finger typing is giving way to two thumbs.
The following two applications can help you master the keyboard so that your next thought does not get lost while your fingers catch up. They were chosen for their simplicity and ease of use. While there are some more flashy or better looking typing apps out there, the following two will get the basics covered and offer the easiest way to start out.
## TuxType (or TuxTyping)
TuxType is for children. Young students can learn how to type with ten fingers with simple lessons and practice their newly-acquired skills in fun games.
Debian and derivatives (therefore all Ubuntu derivatives) should have TuxType in their standard repositories. To install simply type
sudo apt-get install tuxtype
The application starts with a simple menu screen featuring Tux and some really bad midi music (Fortunately the sound can be turned off easily with the icon in the lower left corner.).
The top two choices, “Fish Cascade” and “Comet Zap,” represent typing games, but to start learning you need to head over to the lessons.
There are forty simple built-in lessons to choose from. Each one of these will take a letter from the keyboard and make the student practice while giving visual hints, such as which finger to use.
For more advanced practice, phrase typing is also available, although for some reason this is hidden under the options menu.
The games are good for speed and accuracy as the player helps Tux catch falling fish
or zap incoming asteroids by typing the words written over them.
Besides being a fun way to practice, these games teach spelling, speed, and eye-to-hand coordination, as you must type while also watching the screen, building a foundation for touch typing, if taken seriously.
## GNU typist (gtype)
For adults and more experienced typists, there is GNU Typist, a console-based application developed by the GNU project.
GNU Typist will also be carried by most Debian derivatives’ main repos. Installing it is as easy as typing
sudo apt-get install gtype
You will probably not find it in the Applications menu; insteaad you should start it from a terminal window.
gtype
The main menu is simple, no-nonsense and frill-free, yet it is evident how much the software has to offer. Typing lessons of all levels are immediately accessible.
The lessons are straightforward and detailed.
The interactive practice sessions offer little more than highlighting your mistakes. Instead of flashy visuals you have to chance to focus on practising. At the end of each lesson you get some simple statistics of how you’ve been doing. If you make too many mistakes, you cannot proceed until you can pass the level.
While the basic lessons only require you to repeat some characters, more advanced drills will have the practitioner type either whole sentences,
where of course the three percent error margin means you are allowed even fewer mistakes,
or some drills aiming to achieve certain goals, as in the “Balanced keyboard drill.”
Simple speed drills have you type quotes,
while more advanced ones will make you write longer texts taken from classics.
If you’d prefer a different language, more lessons can also be loaded as command line arguments.
## Conclusion
If you care to hone your typing skills, Linux has great software to offer. The two basic, yet feature-rich, applications discussed above will cater to most aspiring typists’ needs. If you use or know of another great typing application, please don’t hesitate to let us know below in the comments.
Our latest tutorials delivered straight to your inbox |
6,903 | 与 Linux 一起学习:学习物理 | https://www.maketecheasier.com/linux-physics-simulation/ | 2016-01-19T09:38:00 | [
"物理"
] | https://linux.cn/article-6903-1.html | 
“与 Linux 一起学习”的所有文章:
* [与 Linux 一起学习:学习打字](/article-6902-1.html)
* [与 Linux 一起学习:学习物理](/article-6903-1.html)
* [与 Linux 一起学习:学习音乐](/article-6912-1.html)
* [与 Linux 一起学习:学习地理](/article-6913-1.html)
* [与 Linux 一起学习:学习数学](/article-6546-1.html)
Linux 提供大量的教学软件和工具,面向各个年级段以及不同年龄段,提供大量学科的练习实践,其中大多数是可以与用户进行交互的。本“与 Linux 一起学习”系列就来介绍一些教学软件。
物理是一个有趣的课题,证据就是任何物理课程都可以用具体的图片演示给你看。能看到物理变化过程是一个很妙的体验,特别是你不需要到教室就能体验到。Linux 上有很多很好的科学软件来为你提供这种美妙感觉,本篇文章只着重介绍其中几种。
### 1. Step
[Step](https://edu.kde.org/applications/all/step) 是一个交互型物理模拟器,属于 [KDEEdu](https://edu.kde.org/)(KDE 教育)项目的一部分。没人会比它的作者更了解它的作用。在项目官网主页上写着“[Step] 是这样玩的:你放点东西进来,添加一些力(地心引力或者弹簧),然后点击‘<ruby> 模拟 <rp> ( </rp> <rt> Simulate </rt> <rp> ) </rp></ruby>’按钮,这款软件就会为你模拟这个物体在真实世界的物理定律影响下的运动状态。你可以改变物体或力的属性(允许在模拟过程中进行修改),然后观察不同属性下产生的现象。Step 可以让你从体验中学习物理!”
Step 依赖 Qt 以及其他一些 KDE 所依赖的软件,正是由于像 KDEEdu 之类的项目存在,才使得 KDE 变得如此强大,当然,你可能需要忍受由此带来的庞大的桌面系统。
Debian 的源中包含了 step 软件,终端下运行以下命令安装:
```
sudo apt-get install step
```
在 KDE 环境下,它只需要很少的依赖,几秒钟就能安装完成。
Step 有个简单的交互界面,你进去后直接可以进行模拟操作。

你会发现所有物品在屏幕左边,包括不同的质点,空气,不同形状的物体,弹簧,以及不同的力(见区域1) 。如果你选中一个物体,屏幕右边会出现简短的描述信息(见区域2),以及你创造的世界的介绍(主要介绍这个世界中包含的物体)(见区域3),以及你当前选中的物体的属性(见区域4),以及你的操作历史(见区域5)。

一旦你放好了所有物体,点击下“模拟”按钮,可以看到物体与物体之间的相互作用。



想要更多了解 Step,按 F1 键,KDE 帮助中心会显示出详细的软件操作手册。
### 2. Lightspeed
Lightspeed 是一个简单的基于 GTK+ 和 OpenGL 的模拟器,可以模拟一个高速移动的物体被观测到的现象。这个模拟器的理论基础是爱因斯坦的狭义相对论,在 Lightspeed 的 [srouceforge 页面](http://lightspeed.sourceforge.net/)上,他们这样介绍:当一个物体被加速到几千公里每秒,它就会表现得扭曲和褪色;当物体被不断加速到接近光速(299,792,458 m/s)时,这个现象会越来越明显,并且在不同方向观察这个物体的扭曲方式,会得到完全不一样的结果。
受到相对速度影响的现象如下(LCTT 译注:都可以从“光速不变”理论推导出来):
* <ruby> 洛伦兹收缩 <rp> ( </rp> <rt> The Lorentz contraction </rt> <rp> ) </rp></ruby> —— 物体看起来变短了
* <ruby> 多普勒红移/蓝移 <rp> ( </rp> <rt> The Doppler red/blue shift </rt> <rp> ) </rp></ruby>—— 物体的颜色变了
* <ruby> 前灯效应 <rp> ( </rp> <rt> The headlight effect </rt> <rp> ) </rp></ruby>—— 物体的明暗变化(LCTT 译注:当物体接近光速移动时,会在它前进的方向强烈地辐射光子,从这个角度看,物体会变得很亮,相反,从物体背后观察,会发现它很暗)
* <ruby> 光行差效应 <rp> ( </rp> <rt> Optical aberration </rt> <rp> ) </rp></ruby>—— 物体扭曲变形了
Lightspeed 有 Debian 的源,执行下面的命令来安装:
```
sudo apt-get install lightspeed
```
用户界面非常简单,里边有一个物体(你可以从 sourceforge 下载更多形状的物体)沿着 x 轴运动(按下 A 键或在菜单栏 object 项目的 Animation 选项设置,物体就会开始运动)。

你可以滑动右边的滑动条来控制物体移动的速度。

其他一些简单的控制器可以让你获得更多的视觉效果。

点击界面并拖动鼠标可以改变物体视角,在 Camera 菜单下可以修改背景颜色或者物体的图形模式,以及其他效果。
### 特别推荐: Physion
Physion 是个非常有趣并且美观的物理模拟软件,比上面介绍的两款软件都好玩好看。
先来看看视频吧:
不用多介绍了,从它的[官网](http://www.physion.net/)下载吧:
* [Linux](http://physion.net/en/downloads/linux/13-physion-linux-x8664/download)
从他们放在 Youtube 上的视频来看,Physion 还是值得我们下载下来玩玩的。
你有其他 Linux 下的好玩的物理模拟、演示、教学软件吗?如果有,请在评论处分享给我们。
---
via: <https://www.maketecheasier.com/linux-physics-simulation/>
作者:[Attila Orosz](https://www.maketecheasier.com/author/attilaorosz/) 译者:[bazz2](https://github.com/bazz2) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | Linux offers great educational software and many excellent tools to aid students of all grades and ages in learning and practicing a variety of topics, often interactively. The “Learn with Linux” series of articles offers an introduction to a variety of educational apps and software.
Physics is an interesting subject, and arguably the most enjoyable part of any Physics class/lecture are the demonstrations. It is really nice to see physics in action, yet the experiments do not need to be restricted to the classroom. While Linux offers many great tools for scientists to support or conduct experiments, this article will concern a few that would make learning physics easier or more fun.
## 1. Step
Step is an interactive physics simulator, part of [KDEEdu, the KDE Education Project](https://edu.kde.org/). Nobody could better describe what Step does than the people who made it. According to the project webpage, “[Step] works like this: you place some bodies on the scene, add some forces such as gravity or springs, then click “Simulate” and Step shows you how your scene will evolve according to the laws of physics. You can change every property of bodies/forces in your experiment (even during simulation) and see how this will change the outcome of the experiment. With Step, you can not only learn but feel how physics works!”
While of course it requires Qt and loads of KDE-specific dependencies to work, projects like this (and KDEEdu itself) are part of the reason why KDE is such an awesome environment (if you don’t mind running a heavier desktop, of course).
Step is in the Debian repositories; to install it on derivatives, simply type
sudo apt-get install step
into a terminal. On a KDE system it should have minimal dependencies and install in seconds.
Step has a simple interface, and it lets you jump right into simulations.
You will find all available objects on the left-hand side. You can have different particles, gas, shaped objects, springs, and different forces in action. (1) If you select an object, a short description of it will appear on the right-hand side (2). On the right you will also see an overview of the “world” you have created (the objects it contains) (3), the properties of the currently selected object (4), and the steps you have taken so far (5).
Once you have placed all you wanted on the canvas, just press “Simulate,” and watch the events unfold as the objects interact with each other.
To get to know Step better you only need to press F1. The KDE Help Center offers a great and detailed Step handbook.
## 2. Lightspeed
Lightspeed is a simple GTK+ and OpenGL based simulator that is meant to demonstrate the effect of how one might observe a fast moving object. Lightspeed will simulate these effects based on Einstein’s special relativity. According to [their sourceforge page](https://lightspeed.sourceforge.net/) “*When an object accelerates to more than a few million meters per second, it begins to appear warped and discolored in strange and unusual ways, and as it approaches the speed of light (299,792,458 m/s) the effects become more and more bizarre. In addition, the manner in which the object is distorted varies drastically with the viewpoint from which it is observed.*”
These effects which come into play at relative velocities are:
**The Lorentz contraction**– causes the object to appear shorter**The Doppler red/blue shift**– alters the hues of color observed**The headlight effect**– brightens or darkens the object**Optical aberration**– deforms the object in unusual ways
Lightspeed is in the Debian repositories; to install it, simply type:
sudo apt-get install lightspeed
The user interface is very simple. You get a shape (more can be downloaded from sourceforge) which would move along the x-axis (animation can be started by processing “A” or by selecting it from the object menu).
You control the speed of its movement with the right-hand side slider and watch how it deforms.
Some simple controls will allow you to add more visual elements
The viewing angles can be adjusted by pressing either the left, middle or right button and dragging the mouse or from the Camera menu that also offers some other adjustments like background colour or graphics mode.
## Notable mention: Physion
Physion looks like an interesting project and a great looking software to simulate physics in a much more colorful and fun way than the above examples would allow. Unfortunately, at the time of writing, the [official website](https://www.physion.net) was experiencing problems, and the download page was unavailable.
Judging from their Youtube videos, Physion must be worth installing once a download line becomes available. Until then we can just enjoy the this video demo.

Do you have another favorite physics simulation/demonstration/learning applications for Linux? Please share with us in the comments below.
Our latest tutorials delivered straight to your inbox |
6,904 | 如何在 Ubuntu/Fedora/Debian 中安装 GitLab | http://linoxide.com/linux-how-to/install-gitlab-on-ubuntu-fedora-debian/ | 2016-01-18T10:23:00 | [
"git",
"GitLab"
] | /article-6904-1.html | 在 Git 问世之前,分布式版本控制从来都不是一件简单的事。Git 是一个自由开源的软件,旨在轻松且快速地对从小规模到非常巨大的项目进行管理。Git 最开始由 Linus Torvalds 开发,他同时也是著名的 Linux 内核的创建者。在 git 和分布式版本控制系统领域中,[GitLab](https://about.gitlab.com/) 是一个极棒的新产品。它是一个基于 web 的 Git 仓库管理应用,包含代码审查、wiki、问题跟踪等诸多功能。使用 GitLab 可以很方便、快速地创建、审查、部署及托管代码。尽管它在其官方的服务器提供了与 Github 类似的免费托管的代码仓库,但它也可以运行在我们自己的服务器上。GitLab 有两个不同的版本:<ruby> 社区版 <rp> ( </rp> <rt> Community Edition </rt> <rp> ) </rp></ruby>和<ruby> 企业版 <rp> ( </rp> <rt> Enterprise Edition </rt> <rp> ) </rp></ruby>。社区版本完全免费且开源,遵循 MIT 协议;而企业版则遵循一个专有的协议,包含一些社区版中没有的功能。下面介绍的是有关如何在我们自己的运行着 Ubuntu、Fedora 或 Debian 操作系统的机器上安装 GitLab 社区版的简单步骤。

### 1. 安装先决条件
首先,我们需要安装 GitLab 所依赖的软件包。我们将安装 `curl`,用以下载我们所需的文件;安装`openssh-server` ,以此来通过 ssh 协议登录到我们的机器上;安装`ca-certificates`,用它来添加 CA 认证;以及 `postfix`,把它作为一个 MTA(Mail Transfer Agent,邮件传输代理)。
注: 若要安装 GitLab 社区版,我们需要一个至少包含 2 GB 内存和 2 核 CPU 的 linux 机器。
#### 在 Ubuntu 14 .04/Debian 8.x 中
鉴于这些依赖包都可以在 Ubuntu 14.04 和 Debian 8.x 的官方软件仓库中获取到,我们只需通过使用 `apt-get` 包管理器来安装它们。为此,我们需要在一个终端或控制台中执行下面的命令:
```
# apt-get install curl openssh-server ca-certificates postfix
```

#### 在 Fedora 22 中
在 Fedora 22 中,由于 `yum` 已经被弃用了,默认的包管理器是 `dnf`。为了安装上面那些需要的软件包,我们只需运行下面的 dnf 命令:
```
# dnf install curl openssh-server postfix
```

### 2. 打开并开启服务
现在,我们将使用我们默认的初始化系统来打开 sshd 和 postfix 服务。并且我们将使得它们在每次系统启动时被自动开启。
#### 在 Ubuntu 14.04 中
由于在 Ubuntu 14.04 中安装的是 SysVinit 初始化系统,我们将使用 service 命令来开启 sshd 和 postfix 守护进程:
```
# service sshd start
# service postfix start
```
现在,为了使得它们在每次开机启动时被自动开启,我们需要运行下面的 update-rc.d 命令:
```
# update-rc.d sshd enable
# update-rc.d postfix enable
```
#### 在 Fedora 22/Debian 8.x 中
鉴于 Fedora 22 和 Debian 8.x 已经用 Systemd 代替了 SysVinit 来作为默认的初始化系统,我们只需运行下面的命令来开启 sshd 和 postfix 服务:
```
# systemctl start sshd postfix
```
现在,为了使得它们在每次开机启动时可以自动运行,我们需要运行下面的 systemctl 命令:
```
# systemctl enable sshd postfix
Created symlink from /etc/systemd/system/multi-user.target.wants/sshd.service to /usr/lib/systemd/system/sshd.service.
Created symlink from /etc/systemd/system/multi-user.target.wants/postfix.service to /usr/lib/systemd/system/postfix.service.
```
### 3. 下载 GitLab
现在,我们将使用 curl 从官方的 GitLab 社区版仓库下载二进制安装文件。首先,为了得到所需文件的下载链接,我们需要浏览到该软件仓库的页面。为此,我们需要在运行着相应操作系统的 linux 机器上运行下面的命令。
#### 在 Ubuntu 14.04 中
由于 Ubuntu 和 Debian 使用相同的 debian 格式的安装包,我们需要在 <https://packages.gitlab.com/gitlab/gitlab-ce?filter=debs> 下搜索所需版本的 GitLab,然后点击有着 ubuntu/trusty 标签的链接,即我们运行着的 Ubuntu 14.04。接着一个新的页面将会出现,我们将看到一个下载按钮,然后我们在它的上面右击,得到文件的链接,然后像下面这样使用 curl 来下载它。
```
# curl https://packages.gitlab.com/gitlab/gitlab-ce/packages/ubuntu/trusty/gitlab-ce_8.1.2-ce.0_amd64.deb
```

#### 在 Debian 8.x 中
与 Ubuntu 类似,我们需要在 <https://packages.gitlab.com/gitlab/gitlab-ce?filter=debs> 页面中搜索所需版本的 GitLab,然后点击带有 debian/jessie 标签的链接,即我们运行着的 Debian 8.x。接着,一个新的页面将会出现,然后我们在下载按钮上右击,得到文件的下载链接。最后我们像下面这样使用 curl 来下载该文件。
```
# curl https://packages.gitlab.com/gitlab/gitlab-ce/packages/debian/jessie/gitlab-ce_8.1.2-ce.0_amd64.deb/download
```

#### 在 Fedora 22 中
由于 Fedora 使用 rpm 文件来作为软件包,我们将在 <https://packages.gitlab.com/gitlab/gitlab-ce?filter=rpms> 页面下搜索所需版本的 GitLab,然后点击所需发行包的链接,这里由于我们运行的是 Fedora 22,所以我们将选择带有 el/7 标签的发行包。一个新的页面将会出现,在其中我们可以看到一个下载按钮,我们将右击它,得到所需文件的链接,然后像下面这样使用 curl 来下载它。
```
# curl https://packages.gitlab.com/gitlab/gitlab-ce/packages/el/7/gitlab-ce-8.1.2-ce.0.el7.x86_64.rpm/download
```

### 4. 安装 GitLab
在相应的软件源被添加到我们的 linux 机器上之后,现在我们将使用相应 linux 发行版本中的默认包管理器来安装 GitLab 社区版。
#### 在 Ubuntu 14.04/Debian 8.x 中
要在运行着 Ubuntu 14.04 或 Debian 8.x linux 发行版本的机器上安装 GitLab 社区版,我们只需运行如下的命令:
```
# dpkg -i gitlab-ce_8.1.2-ce.0_amd64.deb
```

#### 在 Fedora 22 中
我们只需执行下面的 dnf 命令来在我们的 Fedora 22 机器上安装 GitLab。
```
# dnf install gitlab-ce-8.1.2-ce.0.el7.x86_64.rpm
```

### 5. 配置和开启 GitLab
GitLab 社区版已经成功地安装在我们的 linux 系统中了,接下来我们将要配置和开启它了。为此,我们需要运行下面的命令,这在 Ubuntu、Debian 和 Fedora 发行版本上都一样:
```
# gitlab-ctl reconfigure
```

### 6. 允许通过防火墙
假如在我们的 linux 机器中已经启用了防火墙程序,为了使得 GitLab 社区版的 web 界面可以通过网络进行访问,我们需要允许 80 端口通过防火墙,这个端口是 GitLab 社区版的默认端口。为此,我们需要运行下面的命令。
#### 在 iptables 中
Ubuntu 14.04 默认安装和使用的是 iptables。所以,我们将运行下面的 iptables 命令来打开 80 端口:
```
# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
# /etc/init.d/iptables save
```
#### 在 firewalld 中
由于 Fedora 22 和 Debian 8.x 默认安装了 systemd,它包含了作为防火墙程序的 firewalld。为了使得 80 端口(http 服务) 能够通过 firewalld,我们需要执行下面的命令。
```
# firewall-cmd --permanent --add-service=http
success
# firewall-cmd --reload
success
```
### 7. 访问 GitLab Web 界面
最后,我们将访问 GitLab 社区版的 web 界面。为此,我们需要将我们的 web 浏览器指向 GitLab 服务器的网址,根据我们的配置,可能是 http://ip-address/ 或 <http://domain.com/> 的格式。在我们成功指向该网址后,我们将会看到下面的页面。

现在,为了登录进面板,我们需要点击登录按钮,它将询问我们的用户名和密码。然后我们将输入默认的用户名和密码,即 **root** 和 **5iveL!fe** 。在登录进控制面板后,我们将被强制要求为我们的 GitLab root 用户输入新的密码。

### 8. 创建仓库
在我们成功地更改密码并登录到我们的控制面板之后,现在,我们将为我们的新项目创建一个新的仓库。为此,我们需要来到项目栏,然后点击 **新项目** 绿色按钮。

接着,我们将被询问给我们的项目输入所需的信息和设定,正如下面展示的那样。我们甚至可以从其他的 git 仓库提供商和仓库中导入我们的项目。

做完这些后,我们将能够使用任何包含基本 git 命令行的 Git 客户端来访问我们的 Git 仓库。我们可以看到在仓库中进行的任何活动,例如创建一个里程碑,管理问题,合并请求,管理成员,便签,Wiki 等。

### 总结
GitLab 是一个用来管理 git 仓库的很棒的开源 web 应用。它有着漂亮的带有诸多酷炫功能的响应式界面。它还打包有许多酷炫功能,例如管理群组,分发密钥,持续集成,查看日志,广播消息,钩子,系统 OAuth 应用,模板等。(注:OAuth 是一个开放标准,允许用户让第三方应用访问该用户在某一网站上存储的私密的资源(如照片,视频,联系人列表),而无需将用户名和密码提供给第三方应用。--- 摘取自 [维基百科上的 OAuth 词条](https://zh.wikipedia.org/wiki/OAuth)) 它还可以和大量的工具进行交互如 Slack,Hipchat,LDAP,JIRA,Jenkins,有很多类型的钩子和完整的 API。它至少需要 2 GB 的内存和 2 核 CPU 来流畅运行,支持多达 500 个用户,但它也可以被扩展到多个工作服务器上。
假如你有任何的问题,建议,回馈,请将它们写在下面的评论框中,以便我们可以提升或更新我们的内容。谢谢!
---
via: <http://linoxide.com/linux-how-to/install-gitlab-on-ubuntu-fedora-debian/>
作者:[Arun Pyasi](http://linoxide.com/author/arunp/) 译者:[FSSlc](https://github.com/FSSlc) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='linoxide.com', port=80): Max retries exceeded with url: /linux-how-to/install-gitlab-on-ubuntu-fedora-debian/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327581000>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,906 | 2015年 Linux 世界的十个大事件 | http://itsfoss.com/biggest-linux-stories-2015/ | 2016-01-19T07:21:00 | [
"开源"
] | https://linux.cn/article-6906-1.html | 
2015年已经过去,我在这里(It's FOSS)发表《2015年的大事件》系列。这个系列的第一篇文章为《2015年 Linux 世界的十个大事件》。这些事件在 Linux 世界中产生了极大的影响,无论它们是积极的还是消极的。
我总结了2015发生的十件产生了最大影响的事件。让我们来看看:
### 2015年度十大 Linux /开源相关事件
补充一句,以下这些事件没有按照时间顺序排列。
#### 微软与 Linux 的结盟
在9月下旬,所有人听到[微软构建了自己的 Linux 发行版](/article-6269-1.html)这个消息时都大吃一惊。其在后来被揭露,这其实是一个微软开发的用于它的 Azure cloud switches 的[软件](http://arstechnica.com/information-technology/2015/09/microsoft-has-built-software-but-not-a-linux-distribution-for-its-software-switches/)。
但故事还没结束。微软真的与 Canonical(Ubuntu Linux 的母公司)达成合作来开发 [HDInsight](https://azure.microsoft.com/en-us/services/hdinsight/),这是微软在 Azure 上构建的 Hadoop 大数据服务。 Ubuntu 是[微软在其上部署应用](http://www.zdnet.com/article/microsoft-deploys-first-major-server-application-on-ubuntu-linux/)的第一个 Linux 系统。
微软会继续保持它与 Linux 的关系吗? 还是在使用 Linux 达到其目的(Azure)就会收手?只有时间能告诉我们一切。
#### 微软发布适用于 Linux 的 Visual Studio Code
在微软发布 Linux 发行版引起喧嚣之前,微软扔下了另一枚炸弹——发布 [Linux 版 Visual Studio Code](/article-5376-1.html), 与其一并发布的还有 Windows 版以及 OS X 版。尽管 Visual Studio Code 并不是开源的,从某种意义上讲,发布 Linux 版本仍然是 Linux 用户的胜利。(LCTT 译注:此处原文消息有误,[Visual Studio Code 已开源](/article-6604-1.html)。)无论如何,Linus Torvalds 曾说过一句很著名的话:“如果微软给 Linux 开发过一款应用的话,这就意味着我已经赢了”。
你可以看这个教程来学习[如何在 Ubuntu 中安装 Visual Studio Code](/article-5423-1.html)。
#### 苹果公司开源编程语言 Swift
在向 Linux 及开源“示爱”方面,苹果公司也不甘示弱。苹果用来制作 iOS 应用的首选编程语言 Swift,[现已开源](/article-6689-1.html)并移植到 Linux 中。虽然其还在测试中,但你已经可以轻易地[在 Ubuntu 中安装 Swift](/article-6781-1.html)。
但是,苹果就是苹果,它[开始吹嘘](https://business.facebook.com/itsfoss/photos/pb.115098615297581.-2207520000.1450817108./634288916711879/?type=3&theater)其为“第一个视开源开发为公司关键的软件开发策略的计算机公司巨头(原文如此)”。
#### Ubuntu 手机终于发布
Ubuntu 手机终于在今年年初发布。因其早期使用者及开发者,Ubuntu 深受 Ubuntu 社区喜爱。主流智能机用户仍然回避它,主要是[因为该系统还在重度开发中](http://www.engadget.com/2015/07/24/ubuntu-phone-review/)。对于 Ubuntu 手机的问世,2016年将成为决定性的一年。
#### Jolla 遭受经济危机
Jolla 是 Sailfish OS 这个基于 Linux 的智能手机系统的幕后公司,它遭受了严重的财政困难。这导致了[一半的Jolla 员工被裁](/article-6621-1.html)。
Jolla 在2014年针对它的平板电脑完成了一次非常[成功的众筹](https://www.indiegogo.com/projects/jolla-tablet-world-s-first-crowdsourced-tablet#/),显然,他们将大部分预算都花在了 Sailfish OS 的开发上,而在主要投资者退出后,公司正在挣扎以求生存。
不过有一个好消息,Jolla 成功拿到了一些雄厚的资金,而且他们[已经继续运营了](/article-6757-1.html)。
#### Firefox OS 已死
作为安卓的开源替代品,Mozila 的移动操作系统 Firefox OS 在去年底慢性死亡。本打算在发展中国家售卖低至25美金的智能手机,可基于 Firefox OS 的手机却一直没有流行起来。我认为主要原因是它的硬件配置不高,以及它缺少流行应用。
在十二月,[Mozilla 宣布](/article-6800-1.html)其将停止开发 Firefox OS,并停止出售 Firefox 智能手机。
虽然没有正式宣布过,我认为 [Tizen](https://www.tizen.org/),这个 Linux 基金会旗下的基于 Linux 的移动操作系统,也已经消失了。我没有看到任何关于 Tizen 开发的消息,而且 Linux 基金会从未推动过它的开发。Tizen 何时死亡只是一个时间问题。(LCTT 译注:此处原文消息有误,[Tizen 在2015年发布了 3.0 版本](/article-6261-1.html)。)
#### “Ubuntu 家族”内讧
五月份时,Kubuntu 项目的领导者 Jonathan Riddell [被 Ubuntu 社区委员会强制要求下台](/article-5529-1.html),这引起了很多激烈的讨论。Jonathan 曾质问 Ubuntu 所收捐款的使用情况,他抱怨 Kubuntu 从未见到过这些钱。
这导致了两方的互相谴责。最终。Ubuntu 的大老板,[Mark Shuttleworth 要求 Jonathan 下台](http://www.cio.com/article/2926838/linux/mark-shuttleworth-ubuntu-community-council-ask-kubuntu-developer-to-step-down-as-leader.html)。
#### 女性 Linux 内核开发者因“野蛮的沟通方式”而退出
Linux 之父 Linus Torvalds 以其粗俗的语言而著称。Linux 内核开发者 [Sarah Sharp](http://sarah.thesharps.us/) 也因为嘴快心直而闻名。
Sarah Sharp 曾在2013年与 Linus Torvalds 公开争执,[建议 Linus 将“语言暴力”赶出邮件列表](http://www.techeye.net/chips/linus-torvalds-and-intel-woman-in-sweary-spat)。但 Linus 也没有[委婉地](http://marc.info/?l=linux-kernel&m=137392506516022&w=2)回复她。
那是在2013年。2015年,Sarah 宣布她正在[逐步停止她在内核社区的工作](/article-6361-1.html),因为他们的交流方式缺乏基本礼仪,并且野蛮而充满亵渎。
这一举动让人们开始讨论 Linux 内核社区是否真的应该改变他们的行为方式,还是 Sarah 做的太过分了。
#### Unity 游戏编辑器移植到 Linux平台
尽管[在 Linux 上玩游戏](/article-6258-1.html)仍是 Linux 用户们的阿克琉斯之踵,而在游戏引擎 Unity 宣布其正在测试[Linux 下的游戏编辑器](http://itsfoss.com/unity-gaming-engine-linux/)时整个社区都沸腾了。因为在渲染图像时,Linux 是一个最流行的选择,所以我们推测这将使游戏开发者向 Linux 靠拢。不过,Unity 是否真的会推出一个最终版本的游戏编辑器,这个问题还未被证实。
#### 政府机构采用开源软件
欧洲数个城市的管理机构决定[抛弃先前的软件](/article-6459-1.html),并使用其开源的替代品。大多数城市管理机构将 Microsoft Office 替换为 LibreOffice 或 OpenOffice. 一些城市管理机构和[公立学校](http://itsfoss.com/spanish-school-ditches-windows-ubuntu/)也在跟进,将 Microsoft Windows 换成 Linux。
对于这一行为,削减成本是一个重要的因素,因为城市管理机构通过采用开源软件省下了无数欧元。
大学也并没有在采用开源软件的道路上落后。这一年,我们听到了[大学如何抛弃 Photoshop 改用 Krita](http://itsfoss.com/french-university-dumps-adobe-photoshop-open-source-app-krita/) 以及[大学使用开源 Office 软件](http://itsfoss.com/hungarian-universities-switch-eurooffice/)的消息。
### 总结
与其他年一样,2015年同样有许多令 Linux 爱好者感到积极或消极的时刻。我们看到 Linux 的竞争者,如微软和苹果,向 Linux 靠拢,政府机构采用开源软件。同时,我们还见证了 Firefox 智能手机系统的失败。我想说,这真是喜忧参半的一年。
你认为呢?我希望你们分享你所认为对于 Linuxer 们来说最重要的新闻,和你们对这一年的整体感受。
---
via: <http://itsfoss.com/biggest-linux-stories-2015/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[StdioA](https://github.com/StdioA) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,907 | 哪个文件系统最适合你的 Linux 系统? | https://www.maketecheasier.com/best-file-system-linux/ | 2016-01-19T08:47:00 | [
"文件系统"
] | https://linux.cn/article-6907-1.html | 
文件系统: 它们不是世界上最激动人心的技术,但是仍然很重要。本文我们将细数那些流行的 Linux 文件系统 - 它们是什么,它们能够做什么,以及它们的目标用户。
### Ext4

如果你曾经安装过 Linux,你可能在安装过程中看到过“Ext4”字样。用它有一个不错的理由: 它是当前每个可用的 Linux 发行版所选择的文件系统。当然,还有其他的一些选择,但是不可否认的是,Ext4(Extended 4)几乎是所有 Linux 用户都会选择的文件系统。
#### 它能做什么?
Ext4 拥有之前的文件系统(Ext2/Ext3)中你所期待的所有优点, 同时还带来了一些改进。还有很多内容可以发掘,这里列举出了 Ext4 为你带来的最好的部分:
* 日志型文件系统
* 日志校验
* 多重块文件分配
* 向后兼容 Ext2 && Ext3
* 持续的空闲空间预分配
* 改进的文件系统校验(相比于之前的版本)
* 当然,同时支持更大的文件
#### 目标用户
Ext4 针对那些寻找超级可靠的基础环境或者那些只需要能工作就行的用户。这个文件系统不会对你的系统做快照;它甚至没有最好的 SSD 支持,但是如果你不是太挑剔的话,你会觉得它也还不错。
### BtrFS

B 树(B-tree)文件系统 (也被当做是 butterFS,黄油文件系统) 是 Oracle 为 Linux 研发的一款文件系统。它是一个全新的文件系统,而且正处于主要开发阶段。Linux 社区认为其有时候使用上还有些不稳定。BtrFS 的核心原则是围绕着<ruby> 写时复制 <rp> ( </rp> <rt> copy-on-write </rt> <rp> ) </rp></ruby>原则展开的。**写时复制**基本上意味着在写入数据完成前,这份数据的每一比特都有单独的一份副本。当数据写入完毕后,相当于它做了一份副本。
#### 它能做什么
除了支持写时复制之外,BtrFS 也能够胜任许多其他的事务 - 事实上,它可以不断列出各种特性。这里列举最值得一提的特性:支持只读快照、文件克隆、子卷、透明压缩、离线文件系统校验、从 ext3 & 4 原地转换到 BtrFS、在线碎片整理,还支持 RAID 0, RAID 1, RAID 5, RAID 6 和 RAID 10。
#### 目标用户
BtrFS 的开发者们许诺过,该文件系统是当前其他文件系统的新一代替代者。非常正确,虽然目前其处于开发中。它有很多面向高级用户的杀手级特性,对于基本用户也是这样(包括 SSD 上面的更佳性能)。这个文件系统针对那些想要从文件系统中获取更多(特性),以及那些想尝试用写时复制机制做一些事情的用户。
### XFS

由 Silicon Graphics 公司创造开发,XFS 是一个高端文件系统,定位于速度和性能方面。处于对性能方面的专注,使得在并行 IO 方面,XFS 表现的尤其出色。XFS 文件系统能够处理数量庞大的数据,事实上某些 XFS 用户的数据接近300TB 以上。
#### 它能做什么
XFS 是一个经历良好测试的数据存储文件系统,它是为了高性能操作而诞生的。其特性包括:
* RAID 阵列的条带化分配
* 日志型文件系统
* 块大小可变
* 直接 I/O
* <ruby> 指定速率 <rp> ( </rp> <rt> guaranteed-rate </rt> <rp> ) </rp></ruby> I/O
* 快照
* 在线碎片整理
* 在线调整文件系统大小
#### 目标用户
XFS 针对那些想要一个坚如磐石的文件系统方案的用户。它始于1993年,并且随着时间的变迁它变得越来越好。如果你有一台家庭服务器,而且你苦恼于如何部署存储环境,那么可以考虑下 XFS。它拥有的众多特性(比如快照)能够有助于你的文件存储系统。尽管如此,它不局限于服务器端。如果你是一个相对高级一点的用户或者你对 BtrFS 所承诺的很多特性感兴趣的话,尝试一下 XFS。它实现了很多与 BtrFS 相似的特性,并且没有稳定性方面的问题。
### Reiser4

Reiser4 是 ReiserFS 的继任者,由 Namesys 公司创造研发。它的诞生可以追溯到 Linspire 项目和 DARPA。它与众不同的地方在于众多的事务模式。并不止于单一的一种写入数据的方式;取而代之的是,有很多方式(来写入)。
#### 它能做什么
Reiser4 拥有着使用多种不同事务模式的独特能力。它能够使用写时复制模式 (像 BtrFS),<ruby> 任意位置写入 <rp> ( </rp> <rt> write-anywhere </rt> <rp> ) </rp></ruby>,日志,以及混合事务模式。它在 ReiserFS 的基础上做了许多的改进,包括更好的基于漫游日志的文件系统日志,对较小文件的支持更好,以及更快速的目录处理。Reiser4 提供了许多功能特性。还有更多的特性可以探讨,不过简单来讲,相比于 ReiserFS 它不但做了非常大的改进,而且增加了众多特性。
#### 目标用户
Resier4 适合那些想要将一个文件系统应用到多种场景下的用户。可能你想在一台机器上使用写时复制机制,在另一台机器上使用任意位置写入机制,还会在另一台机器上使用混合事务,而你又不希望使用多种不同类型的文件系统来完成这项任务。Reiser4 是适合这种情况的完美方案。
### 结论
Linux 上有许多可用的文件系统。每个文件系统都有其特定的用途,以便于特定用户解决不同的问题。本文的焦点集中在 Linux 平台上文件系统的主流选择。毫无疑问,其它的场景下还有一些别的选择。
你在 Linux 上最喜欢的文件系统是什么?在下面的评论区告诉我们吧!
---
via: <https://www.maketecheasier.com/best-file-system-linux/>
作者:[Derrik Diener](https://www.maketecheasier.com/author/derrikdiener/) 译者:[icecoobe](https://github.com/icecoobe) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | 
When formatting a hard disk to install your Linux system, you have to decide on the best Linux filesystem to use. In 2021, the most popular option is EXT4. Is it the best one, though, and if you have alternatives, should you choose them? Let’s see the (possible) options.
**Also read:** [Check and Repair Your Filesystem With fsck [Linux]](https://www.maketecheasier.com/check-repair-filesystem-fsck-linux/)
## EXT4
The “Fourth Extended Filesystem” is fully backward-compatible with EXT2 and EXT3 and is considered the standard for most Linux distributions, remaining as popular as its predecessors.

It is one of the safest and most stable available options today since it supports [journaling](https://www.maketecheasier.com/journaling-in-file-system/), preventing (as much as possible) the loss of data after a system crash or loss of power.
Two of its most important features are “extents” and “delayed allocation,” which smartly manage how the data is written on the storage medium to improve performance and reduce fragmentation.
## BtrFS
The “b-tree file system” was initially designed by Oracle and has kept increasing in popularity, to the point many consider it the true successor to the EXT dynasty.

Btrfs comes with advanced features, such as automatic defragmentation and transparent compression. It follows a copy-on-write approach, saving new iterations of data and metadata instead of affecting the existing ones (“shadowing”). This also allows for snapshots of different states of the filesystem as well as easy replication, migration, and incremental backups. Online and offline filesystem checks further reduce the possibility of data loss.
BtrFS natively supports RAID, but it doesn’t follow the approach of typical software RAID striping or hardware block mirroring. Instead, it ensures that each block on one device has a copy on another and keeps CRCs for all data. Thus, in case of a failure, it can pull information from backups and checksums to reconstruct corrupted or missing data.
It’s worth noting that BtrFS is also “SSD-friendly” since it automatically disables its features that are useful for mechanical HDDs but could wear out SSDs.
## XFS
XFS was created by Silicon Graphics almost three decades ago for their graphics workstations specializing in rendering 3D graphics.

That’s why XFS remains one of the best options for systems that are constantly reading and writing data. Thanks to the use of “allocation groups” – parts of the filesystem that contain their own [inodes](https://www.maketecheasier.com/how-do-linux-inodes-work/) and free space – it’s possible for multiple threads to read and write data at the same time in parallel. Support for delayed allocation, dynamically allocated inodes, and advanced read-ahead algorithms help it achieve excellent performance, especially on large-scale storage pools up to hundreds of TB in size.
Its support for journaling is restricted, though, compared to more modern alternatives, and it is arguably more prone to data loss. It also doesn’t scale down well for more typical day-to-day and mostly single-threaded scenarios, like when deleting a bunch of photos from your “Pictures” folder. In other words, it’s great if you’re setting up your own datacenter but maybe not for typical personal use.
## F2FS
One of the (relatively) newer filesystems, “Flash-Friendly File System” is one of the best options for use with flash-based storage.

Initially created for that purpose by Samsung, F2FS splits the storage medium into smaller parts that contain zones that also include smaller parts, and so on, and tries to use many of them instead of reusing the same ones. Combined with its support for TRIM/FITRIM, this makes it friendlier to flash-based media that comes with a finite number of writes.
There’s no point in deep-diving into F2FS’s features since it doesn’t excel in anything compared to all alternatives as far as speed or data security goes, nor in using it with typical media, where every other filesystem would come with a better feature-set. The story changes if talking about flash-based storage, though, for which it was explicitly created.
## OpenZFS/ZFS
OpenZFS is a fork of the Zettabyte File System (ZFS) that initially appeared on Sun’s Solaris. Up to 2010, ZFS could be used on Linux primarily through FUSE, due to licensing issues. It was after 2010 that its development started opening up, and in 2016 Ubuntu supported, by default, its open-source version. Since then, when people refer to “ZFS,” they’re usually talking about its open variant instead of Solaris ZFS – that also keeps evolving but on a parallel path.

ZFS differs from all alternatives in that it combines the filesystem with a volume manager. Because of that, it doesn’t just manage files and directories but also the physical media on which they reside. Thanks to this, every storage device can be assigned to a pool that is treated as a single resource. If you’re ever out of space, you can add new storage to this pool to expand it, letting ZFS take care of the details.
By managing the media itself, ZFS also excels in its support for RAID. You can set up RAID arrays of most types (RAID 0, 2, 5, etc.) but also use its approach of “RAIDZ.” Unlike typical RAID arrays, RAIDZ uses variable width stripes between the drives it includes, increasing its tolerance on data loss after a power failure.
ZFS also follows a copy-on-write approach, where instead of modifying existing data, it only saves the changes (“deltas”) between the old and new versions. This allows for transparent, smart storage of multiple copies of data, without taking up a lot of space, that can work as backups or snapshots. The user can return to previous states of the filesystem, reverting changes, or do the opposite: pull all changes into clones of existing data.
Those are some of the features that help it nearly eliminate any possibility of data loss – at least, in theory.
## JFS
The Journaling File System by IBM was one of the first filesystems that supported journaling, leading to reduced chances of data loss. It uses extents like many other modern alternatives and allocation groups like XFS, aiming to offer high read/write performance.

By not prioritizing a single feature, it’s a great all-arounder under different workloads for different needs. Unfortunately, this also means that it doesn’t excel in anything. Plus, it has some problems that many people would consider a negative when choosing a filesystem for their storage. For example, it can delay updating its journal indefinitely, increasing the chances of data loss and almost nullifying the fact that it’s a journaling file system. It’s better at parallel writes that are of most use to servers and large databases but performs worse than EXT4 in more popular desktop usage scenarios.
Those are probably the reasons why it’s not as popular as other filesystems, which can either perform faster or be better shielded against data loss.
## Which Should You Use?
There’s a reason EXT4 is the default choice for most Linux distributions. It’s tried, tested, stable, performs great, and is widely supported. If you are looking for stability, EXT4 is the best Linux filesystem for you.
If you aren’t afraid of having to deal with a somewhat less mature ecosystem, though, BtrFS may be the better option for you.
For server use where you want to eliminate almost entirely any possibility of data loss and stability is the name of the game, you may want to look into ZFS. To really take advantage of it, though, prepare for a lot of reading. Thankfully, [we can help with its initial setup](https://www.maketecheasier.com/use-zfs-filesystem-ubuntu-linux/).
For flash media, F2FS is the best option by default.
Whichever file system you choose, remember to [fully erase your HDD beforehand](https://www.maketecheasier.com/low-level-format-zero-fill-hard-disk/) if you want to render its existing content almost unrecoverable.
Our latest tutorials delivered straight to your inbox |
6,912 | 与 Linux 一起学习:学习音乐 | https://www.maketecheasier.com/linux-learning-music/ | 2016-01-20T20:52:00 | [
"音乐"
] | https://linux.cn/article-6912-1.html | 
“与 Linux 一起学习”的所有文章:
* [与 Linux 一起学习:学习打字](/article-6902-1.html)
* [与 Linux 一起学习:学习物理](/article-6903-1.html)
* [与 Linux 一起学习:学习音乐](/article-6912-1.html)
* [与 Linux 一起学习:学习地理](/article-6913-1.html)
* [与 Linux 一起学习:学习数学](/article-6546-1.html)
引言:Linux 提供大量的教学软件和工具,面向各个年级段以及不同年龄段,提供大量学科的练习实践,其中大多数是可以与用户进行交互的。本“与 Linux 一起学习:”系列就来介绍一些教学软件。
学习音乐是一个很好的消遣方式。训练你的耳朵能识别音阶与和弦、掌握一门乐器、控制自己的嗓音,这些都需要大量的练习,以及会遇到很多困难。音乐理论非常博大精深,有太多东西需要记忆,你需要非常勤奋才能将这些东西变成你的“技术”。在你的音乐之路上,Linux 提供了杰出的软件来帮助你前行。它们不能让你立刻成为一个音乐家,但可以作为一个降低学习难度的好助手。
### Gnu Solfège
[Solfège](https://en.wikipedia.org/wiki/Solf%C3%A8ge) 是一个世界流行的音乐教学工具,适用于各个级别的音乐教育。很多流行的教学方法(比如著名的柯达伊教学法)就使用 Solfège 作为它们的基础。相比于学到音乐知识,Solfège 更关注于让用户不断练习音乐。它预期的用户是那些已经有一些音乐基础,并且想不断练习音乐技巧的学生。
以下是 GNU 网站的开发者声明:
>
> “当你在高校、学院、音乐学校中学习音乐,你一般要进行的一些听力训练,比如视唱,会比较简单,但是通常需要两个人配合,一个问,一个答。[...] GNU Solfège 尝试着解决这个问题,你可以在没有其他人的帮助下完成更多的简单机械式练习。只是别忘了这些练习只是整个音乐训练过程的一部分。”
>
>
>
这款软件兑现了它的承诺,你可以在试听帮手的帮助下练习几乎所有音乐技巧。
Debian 和 Ubuntu 的仓库上有这款软件,在终端运行下面命令安装软件:
```
sudo apt-get install solfege
```
它开启的时候会出现一个简单的开始界面。

这些选项几乎包含了所有种类,大多数链接里面都有子类,你可以从中选择独立的练习。


软件提供多种练习和测试项目,都能通过外接的 MIDI 设备(LCTT 译注:MIDI,Musical Instrument Digital Interface,乐器数字接口)或者声卡来播放音乐。这些练习还配合音符播放,以及支持慢动作回放功能。
很重要的一点是如果你在 Ubuntu 下使用 Solfège,默认情况下你可能没法听到声音(除非你有外接 MIDI 设备)。如果出现了这种情况,点击“File -> Prefernces -> Sound Setup”,选择合适的设备(一般情况下选 ALSA 都能解决问题)。

Solfège 对你的日常练习非常有帮助,经常使用它,可以在你开始唱 do-re-mi 之前练好你的音乐听觉。
### Tete (听力训练)
[Tete](http://tete.sourceforge.net/index.shtml) (这款听力训练软件)是一款简单但有效的 JAVA 软件,用于[训练听力](https://en.wikipedia.org/wiki/Ear_training)。它通过在不同背景下播放不同和弦以及不同 MIDI 声音来训练你分辨不同的音阶。[从 SourceForge 下载](http://sourceforge.net/projects/tete/files/latest/download),然后解压它。
```
unzip Tete-*
```
进入解压出来的目录:
```
cd Tete-*
```
这里假设你的系统已经安装好了 JAVA,你可以使用下面的命令执行 Java 文件:
```
java -jar Tete-[版本号]
```
(可以在输入“Tete-”后按 Tab 键进行自动补全。)
Tete 只有一个简单的界面,所有内容都在这里了。

你可以选择表演音阶(见上图),和弦(下图),

或音程。

你可以“精调”很多选项,包括 midi 乐器的声音、提升或降低音阶以及回放的快慢等等。SourceForge 网站上有关于 Tete 的非常有用的教程,介绍了这个软件的各个方面。
### JalMus
Jalmus 是用 JAVA 写的键盘音符阅读训练器。可以外接 MIDI 键盘,也可以使用虚拟键盘。它提供很多简单的课程练习来训练你的音符阅读能力。虽然这个软件在2013年之后就不再更新了,但还是比较实用的。
进入 [sourceforge 页面](http://sourceforge.net/projects/jalmus/files/Jalmus-2.3/)下载最后版本(v2.3)的 JAVA 安装器,或者在终端输入下面的命令下载:
```
wget http://garr.dl.sourceforge.net/project/jalmus/Jalmus-2.3/installjalmus23.jar
```
下载完成后,加载安装器:
```
java -jar installjalmus23.jar
```
跨平台的 JAVA 安装器会一步一步引导你完成安装的。
Jalmus 的主界面非常朴素。

你可以在“Lessons”菜单中找到各种不同难度的课程,从非常简单(一行音符从左边向右滑过,键盘上相应的按键会高亮显示),

到非常困难(有多行音符从右向左滑过,你需要按顺序键入音符)。

Jalmus 也包含一些阅读单个音符的训练,内容和课程相似,只是没有那些视觉上的提示了。当完成训练后,屏幕上会显示你的乐谱。它还提供不同难度的节拍训练,你能听到并看到这些训练里面播放的节拍。在多行乐谱同时播放时,一个节拍器(能听见能看见)可以帮你理解

和阅读乐谱。

所有这些功能都是可配置的,你可以选择打开或者关闭它们。
总的来说,Jalmus 可能是节奏训练软件中属于功能最强的,虽然它不是学音乐必备的软件,但在节奏训练这个特殊的领域,它做得很出色。
### 号外
#### TuxGuitar
对于吉他练习者,[TuxGuitar](http://tuxguitar.herac.com.ar/) 看起来很像 Windows 下面的 Guitar Pro 软件(它也可以读 Guitar Pro 格式的文件)。
#### PianoBooster
[Piano Booster](http://www.linuxlinks.com/article/20090517041840856/PianoBooster.html) 可以练习钢琴技巧,它能播放 MIDI 文件,你可以使用外接键盘来弹钢琴,同时还能查看屏幕上滑过的乐谱。
### 总结
Linux 提供很多优秀的工具供你学习,如果你对音乐感兴趣,你完全不用担心没有帮你练习音乐技术的软件。实际上,可供学习音乐的学生选择的优秀软件数量远比上面介绍的要多。如果你还知道其他的音乐训练软件,请在写下你的评论,让我们能够知道。
---
via: <https://www.maketecheasier.com/linux-learning-music/>
作者:[Attila Orosz](https://www.maketecheasier.com/author/attilaorosz/) 译者:[bazz2](https://github.com/bazz2) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | Linux offers great educational software and many excellent tools to aid students of all grades and ages in learning and practicing a variety of topics, often interactively. The “Learn with Linux” series of articles offers an introduction to a variety of educational apps and software.
Learning music is a great pastime. Training your ears to identify scales and chords and mastering an instrument or your own voice requires lots of practise and could become difficult. Music theory is extensive. There is much to memorize, and to turn it into a “skill” you will need diligence. Linux offers exceptional software to help you along your musical journey. They will not help you become a professional musician instantly but could ease the process of learning, being a great aide and reference point.
## Gnu Solfège
[Solfège](https://en.wikipedia.org/wiki/Solf%C3%A8ge) is a popular music education method that is used in all levels of music education all around the world. Many popular methods (like the Kodály method) use Solfège as their basis. GNU Solfège is a great software aimed more at practising Solfège than learning it. It assumes the student has already acquired the basics and wishes to practise what they have learned.
As the developer states on the GNU website:
“When you study music on high school, college, music conservatory, you usually have to do ear training. Some of the exercises, like sight singing, is easy to do alone [sic]. But often you have to be at least two people, one making questions, the other answering. […] GNU Solfège tries to help out with this. With Solfege you can practise the more simple and mechanical exercises without the need to get others to help you. Just don’t forget that this program only touches a part of the subject.”
The software delivers its promise; you can practise essentially everything with audible and visual aids.
GNU solfege is in the Debian (therefore Ubuntu) repositories. To get it just type the following command into a terminal:
sudo apt-get install solfege
When it loads, you find yourself on a simple starting screen/
The number of options is almost overwhelming. Most of the links will open sub-categories
from where you can select individual exercises.
There are practice sessions and tests. Both will be able to play the tones through any connected MIDI device or just your sound card’s MIDI player. The exercises often have visual notation and the ability to play back the sequence slowly.
One important note about Solfège is that under Ubuntu you might not be able to hear anything with the default setup (unless you have a MIDI device connected). If that is the case, head over to “File -> Preferences,” select sound setup and choose the appropriate option for your system (choosing ALSA would probably work in most cases).
Solfège could be very helpful for your daily practise. Use it regularly and you will have trained your ear before you can sing do-re-mi.
## Tete (ear trainer)
[Tete](https://tete.sourceforge.net/index.shtml) (This ear trainer ‘ere) is a Java application for simple, yet efficient, [ear training](https://en.wikipedia.org/wiki/Ear_training). It helps you identify a variety of scales by playing thhm back under various circumstances, from different roots and on different MIDI sounds. [Download it from SourceForge](https://sourceforge.net/projects/tete/files/latest/download). You then need to unzip the downloaded file.
unzip Tete-*
Enter the unpacked directory:
cd Tete-*
Assuming you have Java installed in your system, you can run the java file with
java -jar Tete-[your version]
(To autocomplete the above command, just press the `Tab`
key after typing “Tete-“.)
Tete has a simple, one-page interface with everything on it.
You can choose to play scales (see above), chords,
or intervals.
You can “fine tune” your experience with various options including the midi instrument’s sound, what note to start from, ascending or descending scales, and how slow/fast the playback should be. Tete’s SourceForge page includes a very useful [tutorial](https://tete.sourceforge.net/tutorial.shtml) that explains most aspects of the software.
## JalMus
Jalmus is a Java-based keyboard note reading trainer. It works with attached MIDI keyboards or with the on-screen virtual keyboard. It has many simple lessons and exercises to train in music reading. Unfortunately, its development has been discontinued since 2013, but the software appears to still be functional.
To get Jalmus, head over to the [sourceforge page](https://sourceforge.net/projects/jalmus/files/Jalmus-2.3/) of its last version (2.3) to get the Java installer, or just type the following command into a terminal:
wget http://garr.dl.sourceforge.net/project/jalmus/Jalmus-2.3/installjalmus23.jar
Once the download finishes, load the installer with
java -jar installjalmus23.jar
You will be guided through a simple Java-based installer that was made for cross-platform installation.
Jalmus’s main screen is plain.
You can find lessons of varying difficulty in the Lessons menu. It ranges from very simple ones, where one notes swims in from the left, and the corresponding key lights up on the on screen keyboard …
… to difficult ones with many notes swimming in from the right, and you are required to repeat the sequence on your keyboard.
Jalmus also includes exercises of note reading single notes, which are very similar to the lessons, only without the visual hints, where your score will be displayed after you finished. It also aids rhythm reading of varying difficulty, where the rhythm is both audible and visually marked. A metronome (audible and visual) aids in the understanding
and score reading where multiple notes will be played
All these options are configurable; you can switch features on and off as you like.
All things considered, Jalmus probably works best for rhythm training. Although it was not necessarily its intended purpose, the software really excelled in this particular use-case.
## Notable mentions
### TuxGuitar
For guitarists, [TuxGuitar](https://tuxguitar.herac.com.ar/) works much like Guitar Pro on Windows (and it can also read guitar-pro files).
### PianoBooster
[Piano Booster](https://www.linuxlinks.com/article/20090517041840856/PianoBooster.html) can help with piano skills. It is designed to play MIDI files, which you can play along with on an attached keyboard, watching the core roll past on the screen.
## Conclusion
Linux offers many great tools for learning, and if your particular interest is music, your will not be left without software to aid your practice. Surely there are many more excellent software tools available for music students than were mentioned above. Do you know of any? Please let us know in the comments below.
Our latest tutorials delivered straight to your inbox |
6,913 | 与 Linux 一起学习:学习地理 | https://www.maketecheasier.com/linux-geography-apps/ | 2016-01-21T10:00:00 | [
"地理"
] | https://linux.cn/article-6913-1.html | 
“与 Linux 一起学习”的所有文章:
* [与 Linux 一起学习:学习打字](/article-6902-1.html)
* [与 Linux 一起学习:学习物理](/article-6903-1.html)
* [与 Linux 一起学习:学习音乐](/article-6912-1.html)
* [与 Linux 一起学习:学习地理](/article-6913-1.html)
* [与 Linux 一起学习:学习数学](/article-6546-1.html)
引言:Linux 提供大量的教学软件和工具,面向各个年级段以及各个年龄段,提供大量学科的练习实践,其中大多数是可以与用户进行交互的。本“与 Linux 一起学习”系列就来介绍一些教学软件。
地理是一门有趣的学科,我们每天都能接触到,虽然可能没有意识到,但当你打开 GPS、SatNav 或谷歌地图时,你就已经在使用这些软件提供的地理数据了;当你在新闻中看到一个国家的消息或听到一些金融数据时,这些信息都可以归于地理学范畴。Linux 提供了很多学习地理学的软件,可用于教学,也可用于自学。
### Kgeography
在多数 Linux 发行版的软件库中,只有两个与地理有关的软件,两个都属于 KDE 阵营,或者说都属于 KDE 教育项目。Kgeopraphy 使用简单的彩色编码图来绘制被选中的国家。
Ubuntu 及衍生版在终端执行下面命令安装软件:
```
sudo apt-get install kgeography
```
界面很简单,给你一个选择界面,你可以选择不同的国家。

点击地图上的某个区域,界面就会显示这个区域所在的国家和首都。

以及给出不同的测试题来检测你的知识水平。

这款软件以交互的方式测试你的地理知识,并且可以帮你为考试做好充足的准备。
### Marble
Marble 是一个稍微高级一点的软件,无需 3D 加速就能提供全球视角。

在 Ubuntu 及衍生版的终端输入下面的命令来安装 Marble:
```
sudo apt-get install marble
```
Marble 专注于地图绘制,它的主界面就是一张地图。

你可以选择不同的投影方法,比如球状投影和麦卡托投影(LCTT 译注:把地球表面绘制在平面上的方法),在下拉菜单里你可以选择平面视角或外部视角,包括 Atlas 视角,OpenStreetMap 提供的成熟的离线地图,

以及卫星视角(由 NASA 提供),

以及政治上甚至是历史上的世界地图。

除了有包含不同界面和大量数据的离线地图,Marble 还提供其他信息。你可以在菜单中打开或关闭不同的离线信息框

和在线服务。

一个有趣的在线服务是维基百科,点击下 Wiki 图标,会弹出一个界面来展示你选中区域的详细信息。

这款软件还提供定位追踪、路由规划、位置搜索和其他有用的功能。如果你喜欢地图学,Marble 可以让你长时间享受探索和学习的乐趣。
### 总结
Linux 提供大量优秀的教育软件,当然也包括地理学科。本文介绍的两款软件可以帮你学到很多地理知识,并且你可以以一种好玩的人机交互方式来测试你的知识量。
---
via: <https://www.maketecheasier.com/linux-geography-apps/>
作者:[Attila Orosz](https://www.maketecheasier.com/author/attilaorosz/) 译者:[bazz2](https://github.com/bazz2) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | Linux offers great educational software and many excellent tools to aid students of all grades and ages in learning and practicing a variety of topics, often interactively. The “Learn with Linux” series of articles offers an introduction to a variety of educational apps and software.
Geography is an interesting subject, used by many of us day to day, often without realizing. But when you fire up GPS, SatNav, or just Google maps, you are using the geographical data provided by this software with the maps drawn by cartographists. When you hear about a certain country in the news or hear financial data being recited, these all fall under the umbrella of geography. And you have some great Linux software to study and practice these, whether it is for school or your own improvement.
## Kgeography
There are only two geography-related applications readily available in most Linux repositories, and both of these are KDE applications, in fact part of the KDE Educatonal project. Kgeography uses simple color-coded maps of any selected country.
To install kegeography just type
sudo apt-get install kgeography
into a terminal window of any Ubuntu-based distribution.
The interface is very basic. You are first presented with a picker menu that lets you choose an area map.
On the map you can display the name and capital of any given territory by clicking on it,
and test your knowledge in different quizzes.
It is an interactive way to test your basic geographical knowledge and could be an excellent tool to help you prepare for exams.
## Marble
Marble is a somewhat more advanced software, offering a global view of the world without the need of 3D acceleration.
To get Marble, type
sudo apt-get install marble
into a terminal window of any Ubuntu-based distribution.
Marble focuses on cartography, its main view being that of an atlas.
You can have different projections, like Globe or Mercator displayed as defaults, with flat and other exotic views available from a drop-down menu. The surfaces include the basic Atlas view, a full-fledged offline map powered by OpenStreetMap,
satellite view (by NASA),
and political and even historical maps of the world, among others.
Besides providing great offline maps with different skins and varying amount of data, Marble offers other types of information as well. You can switch on and off various offline info-boxes
and online services from the menu.
An interesting online service is Wikipedia integration. Clicking on the little Wiki logos will bring up a pop-up featuring detailed information about the selected places.
The software also includes options for location tracking, route planning, and searching for locations, among other great and useful features. If you enjoy cartography, Marble offers hours of fun exploring and learning.
## Conclusion
Linux offers many great educational applications, and the subject of geography is no exception. With the above two programs you can learn a lot about our globe and test your knowledge in a fun and interactive manner.
Our latest tutorials delivered straight to your inbox |
6,914 | IPv6 互联网中的隐私保护和网络管理器 | https://blogs.gnome.org/lkundrak/2015/12/03/networkmanager-and-privacy-in-the-ipv6-internet/ | 2016-01-21T07:40:00 | [
"IPv6",
"隐私"
] | https://linux.cn/article-6914-1.html | IPv6 的使用量正在不断增加,让我们始料未及的是,伴随这个协议不断增加的使用量,大量的隐私问题涌现出来。互联网社区在积极发布相关解决方案。当前状况是怎样的呢?<ruby> 网络管理器 <rp> ( </rp> <rt> NetworkManager </rt> <rp> ) </rp></ruby>又是如何跟上的呢?让我们来瞧瞧吧!

### 通过 IPv6 方式连接的主机的特性
启用了 IPv6 的节点(LCTT 译注:节点在网络中指一个联网的设备)并不需要类似 IPv4 网络中 [DHCP](https://tools.ietf.org/html/rfc2132) 服务器的中央机构来配置他们的地址。它们<ruby> 发现 <rp> ( </rp> <rt> discover </rt> <rp> ) </rp></ruby>自己所在的网络,然后通过生成主机部分来[自主生成地址](https://tools.ietf.org/html/rfc4862)。这种方式使得网络配置更加简单,并且能够更好的扩展到更大规模的网络。然而,这种方式也有一些缺点。首先,这个节点需要确保它的地址不会和网络上其他节点冲突。其次,如果这个节点在进入的每一个网络中使用相同的主机部分,它的运动就可以被追踪,如此一来,隐私便处于危险之中。
负责制定因特网标准的组织 <ruby> Internet 工程任务组 <rp> ( </rp> <rt> Internet Engineering Task Force </rt> <rp> ) </rp></ruby>(IETF)[意识到了这个问题](https://tools.ietf.org/html/draft-iesg-serno-privacy-00),这个组织建议取消使用硬件序列号来识别网络上的节点。
但实际的实施情况是怎样的呢?
地址唯一性问题可以通过<ruby> <a href="https://tools.ietf.org/html/rfc4862#section-5.4"> 重复地址检测 </a> <rp> ( </rp> <rt> Duplicate Address Detection </rt> <rp> ) </rp></ruby>(DAD)机制来解决。当节点为自身创建地址的时候,它首先通过<ruby> <a href="https://tools.ietf.org/html/rfc4861"> 邻居发现协议 </a> <rp> ( </rp> <rt> Neighbor Discovery Protocol </rt> <rp> ) </rp></ruby> (一种不同于 IPv4 [ARP](https://tools.ietf.org/html/rfc826) 协议的机制)来检查另一个节点是否使用了相同的地址。当它发现地址已经被使用,它必须抛弃掉这个地址。
解决另一个问题——隐私问题,有一点困难。一个 IP 地址(无论 IPv4 或 IPv6)由网络部分和主机部分组成(LCTT 译注:网络部分用来划分子网,主机部分用来从相应子网中找到具体的主机)。主机查找出相关的地址的网络部分,并且生成地址的主机部分。传统上它只使用了源自网络硬件(MAC)地址的<ruby> 接口识别器 <rp> ( </rp> <rt> Interface Identifier </rt> <rp> ) </rp></ruby>。MAC 地址在硬件制造的时候就被设置好了,它可以唯一的识别机器。这样就确保了地址的稳定性和唯一性。这对避免地址冲突来说是件好事,但是对隐私来说一点也不好。主机部分在不同网络下保持恒定意味着机器在进入不同网络时可以被唯一的识别。这在协议制定的时候看起来无可非议,但是随着 IPv6 的流行,人们对于隐私问题的担忧也愈演愈烈。幸运的是,解决办法还是有的。
### 使用<ruby> 隐私扩展 <rp> ( </rp> <rt> privacy extensions </rt> <rp> ) </rp></ruby>
IPv4 的最大问题——地址枯竭,已经不是什么秘密。对 IPv6 来说,这一点不再成立,事实上,使用 IPv6 的主机能够相当大方的利用地址。多个 IPv6 地址对应一块网卡绝对没有任何不合适,正好相反,这是一种标准情形。最起码每个节点都有一个“<ruby> 本地连接 <rp> ( </rp> <rt> link-local </rt> <rp> ) </rp></ruby>地址”,它被用来与同一物理链路的节点联络。当网络包含了一个连接其他网络的路由器,这个网络中的每个节点都有一个与每个直接连接的网络相联络的地址。如果主机在同一个网络有更多的地址,该节点(LCTT 译注:指路由器)将接受它们全部的传入流量。对于外发连接,它会把地址显示给远程主机,内核会挑选最适合的地址。但到底是哪一个呢?
启用了隐私扩展,就像 [RFC4941](https://tools.ietf.org/html/rfc4941) 定义的那样,时常会生成带有随机主机部分的新地址。最新的那个被用于最新的外发连接,与此同时,那些不被使用了的旧地址将被丢弃。这是一个极好的策略——主机不会对外暴露其固定地址,因为它不用于外发连接,但它仍然会接受知道其固定地址的主机连接。
但这也存在美中不足之处——某些应用会把地址与用户识别绑定在一起。让我们来考虑一下这种情形,一个 web 应用在用户认证的时候生成一个 HTTP Cookie,但它只接受实施认证的地址的连接。当内核生成了一个新的临时地址,服务器会拒绝使用这个地址的请求,实际上相当于用户登出了。地址是不是建立用户认证的合适机制值得商榷,但这确实是现实中应用程序正在做的。
### 解救之道——<ruby> 隐私固定寻址 <rp> ( </rp> <rt> Privacy stable addressing </rt> <rp> ) </rp></ruby>
解决这个问题可能需要另辟蹊径。唯一的(当然咯)地址确实有必要,对于特定网络来说是稳定的,但当用户进入了另一个网络后仍然会变,这样的话追踪就变得几乎不可能。RFC7217 介绍了一种如上所述的机制。
创建隐私固定地址依赖于伪随机值,这个随机值只被主机本身知晓,它不会暴露给网络上的其他主机。这个随机值随后被一个密码安全算法加密,一起被加密的还有一些与网络连接的特定值。这些值包含:用以标识网卡的名称;网络地址;对于这个网络来说有可能的其他特殊值,例如无线网络的 SSID。使用这个安全密钥使其他主机很难预测结果地址,与此同时,当进入不同的网络时,网络的特殊数据会让地址变得不同。
这也巧妙的解决了地址重复问题。因为有随机值的存在,冲突也不太可能发生。万一发生了冲突,结果地址会得到重复地址检测失败的记录,这时会生成一个不同的地址而不会断开网络连接。看,这种方式很聪明吧。
使用隐私固定地址一点儿也不会妨碍隐私扩展。你可以在使用 RFC4941 所描述的临时地址的同时使用 [RFC7217](https://tools.ietf.org/html/rfc7217)中的固定地址。
### <ruby> 网络管理器 <rp> ( </rp> <rt> NetworkManager </rt> <rp> ) </rp></ruby>处于什么样的状况?
我们已经在网络管理器1.0.4版本中实现了<ruby> 隐私扩展 <rp> ( </rp> <rt> privacy extensions </rt> <rp> ) </rp></ruby>。在这个版本中,隐私扩展默认开启。你可以用 ipv6.ip6-privacy 参数来控制它。
在网络管理器1.2版本中,我们将会加入<ruby> 固定隐私寻址 <rp> ( </rp> <rt> stable privacy addressing </rt> <rp> ) </rp></ruby>。应该指出的是,目前的隐私扩展还不符合这种需求。我们可以使用 ipv6.addr-gen-mode 参数来控制这个特性。如果它被设置成固定隐私,那么将会使用固定隐私寻址。设置成“eui64”或者干脆不设置它将会保持传统的默认寻址方式。
敬请期待2016年年初网络管理器1.2版本的发布吧!如果你想尝试一下最新的版本,不妨试试 Fedora Rawhide,它最终会变成 Fedora 24。
*我想感谢 Hannes Frederic Sowa,他给了我很有价值的反馈。如果没有他的帮助,这篇文章的作用将会逊色很多。另外,Hannes 也是 RFC7217 所描述机制的内核实现者,当网络管理器不起作用的时候,它将发挥作用。*
---
via: <https://blogs.gnome.org/lkundrak/2015/12/03/networkmanager-and-privacy-in-the-ipv6-internet/>
作者:Lubomir Rintel 译者:[itsang](https://github.com/itsang) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
| 200 | OK | IPv6 is gaining momentum. With growing use of the protocol concerns about privacy that were not initially anticipated arise. The Internet community actively publishes solutions to them. What’s the current state and how does NetworkManager catch up? Let’s figure out!
## The identity of a IPv6-connected host
The IPv6 enabled nodes don’t need a central authority similar to IPv4 [DHCP](https://tools.ietf.org/html/rfc2132) servers to configure their addresses. They discover the networks they are in and [complete the addresses themselves](https://tools.ietf.org/html/rfc4862) by generating the host part. This makes the network configuration simpler and scales better to larger networks. However, there’s some drawbacks to this approach. Firstly, the node needs to ensure that its address doesn’t collide with an address of any other node on the network. Secondly, if the node uses the same host part of the address in every network it enters then its movement can be tracked and the privacy is at risk.
Internet Engineering Task Force (IETF), the organization behind the Internet standards, [acknowledged this problem](https://tools.ietf.org/html/draft-iesg-serno-privacy-00) and recommends against use of hardware serial numbers to identify the node in the network.
But what does the actual implementation look like?
The problem of address uniqueness is addressed with [Duplicate Address Detection](https://tools.ietf.org/html/rfc4862#section-5.4) (DAD) mechanism. When a node creates an address for itself it first checks whether another node uses the same address using the [Neighbor Discovery Protocol](https://tools.ietf.org/html/rfc4861) (a mechanism not unlike IPv4 [ARP](https://tools.ietf.org/html/rfc826) protocol). When it discovers the address is already used, it must discard it.
The other problem (privacy) is a bit harder to solve. An IP address (be it IPv4 or IPv6) address consists of a network part and the host part. The host discovers the relevant network parts and is supposed generate the host part. Traditionally it just uses an Interface Identifier derived from the network hardware’s (MAC) address. The MAC address is set at manufacturing time and can uniquely identify the machine. This guarantees the address is stable and unique. That’s a good thing for address collision avoidance but a bad thing for privacy. The host part remaining constant in different network means that the machine can be uniquely identified as it enters different networks. This seemed like non-issue at the time the protocol was designed, but the privacy concerns arose as the IPv6 gained popularity. Fortunately, there’s a solution to this problem.
## Enter privacy extensions
It’s no secret that the biggest problem with IPv4 is that the addresses are scarce. This is no longer true with IPv6 and in fact an IPv6-enabled host can use addresses quite liberally. There’s absolutely nothing wrong with having multiple IPv6 addresses attached to the same interface. On the contrary, it’s a pretty standard situation. At the very minimum each node has an address that is used for contacting nodes on the same hardware link called a link-local address. When the network contains a router that connects it to other networks in the internet, a node has an address for every network it’s directly connected to. If a host has more addresses in the same network the node accepts incoming traffic for all of them. For the outgoing connections which, of course, reveal the address to the remote host, the kernel picks the fittest one. But which one is it?
With privacy extensions enabled, as defined by [RFC4941](https://tools.ietf.org/html/rfc4941), a new address with a random host part is generated every now and then. The newest one is used for new outgoing connections while the older ones are deprecated when they’re unused. This is a nifty trick — the host does not reveal the stable address as it’s not used for outgoing connections, but still accepts connections to it from the hosts that are aware of it.
There’s a downside to this. Certain applications tie the address to the user identity. Consider a web application that issues a HTTP Cookie for the user during the authentication but only accepts it for the connections that come from the address that conducted the authentications. As the kernel generates a new temporary address, the server would reject the requests that use it, effectively logging the user out. It could be argued that the address is not an appropriate mechanism for establishing user’s identity but that’s what some real-world applications do.
## Privacy stable addressing to the rescue
Another approach would be needed to cope with this. There’s a need for an address that is unique (of course), stable for a particular network but still changes when user enters another network so that tracking is not possible. The [RFC7217](https://tools.ietf.org/html/rfc7217) introduces a mechanism that provides exactly this.
Creation of a privacy stable address relies on a pseudo-random key that’s only known the host itself and never revealed to other hosts in the network. This key is then hashed using a cryptographically secure algorithm along with values specific for a particular network connection. It includes an identifier of the network interface, the network prefix and possibly other values specific to the network such as the wireless SSID. The use of the secret key makes it impossible to predict the resulting address for the other hosts while the network-specific data causes it to be different when entering a different network.
This also solves the duplicate address problem nicely. The random key makes collisions unlikely. If, in spite of this, a collision occurs then the hash can be salted with a DAD failure counter and a different address can be generated instead of failing the network connectivity. Now that’s clever.
Using privacy stable address doesn’t interfere with the privacy extensions at all. You can use the RFC7217 stable address while still employing the RFC4941 temporary addresses at the same time.
## Where does NetworkManager stand?
We’ve already enabled the privacy extensions with the release NetworkManager 1.0.4. They’re turned on by default; you can control them with ipv6.ip6-privacy property.
With the release of NetworkManager 1.2, we’re adding the stable privacy addressing. It’s supposed to address the situations where the privacy extensions don’t make the cut. The use of the feature is controlled with the ipv6.addr-gen-mode property. If it’s set to stable-privacy then stable privacy addressing is used. Setting it to “eui64” or not setting it at all preserves the traditional default behavior.
Stay tuned for NetworkManager 1.2 release in early 2016! If you want to try the bleeding-edge snapshot, give Fedora Rawhide a try. It will eventually become Fedora 24.
*I’d like to thank Hannes Frederic Sowa for a valuable feedback. The article would make less sense without his corrections. Hannes also created the in-kernel implementation of the RFC7217 mechanism which can be used when the networking is not managed by NetworkManager.*
Privacy extensions don’t appear enabled by default on Fedora 23 which has NM 1.0.6, and in fact the ipv6 and IID leak the MAC address. https://bugzilla.redhat.com/show_bug.cgi?id=1279242
With NetworkManager 1.2 (Fedora 24) we’re adding the RFC7217 stable privacy addresses and enabling them by default. |
6,919 | 70% 的 Android 设备被曝发现可获得最高权限的安全漏洞! | http://www.wired.com/2016/01/hack-brief-years-old-linux-bug/ | 2016-01-22T16:02:00 | [
"Android",
"Linux",
"漏洞"
] | https://linux.cn/article-6919-1.html | 一家以色列安全公司在 Linux 内核中发现了一个重大的安全漏洞([CVE-2016-0728](http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=2016-0728)),它已经存在了将近三年。影响到了成千上万的 Linux 服务器和 Linux 桌面计算机;此外,近 70% 的 Android 手机和平板也受此漏洞影响。

### 漏洞情况
在 Perception Point 发表的[一篇文章](http://perception-point.io/2016/01/14/analysis-and-exploitation-of-a-linux-kernel-vulnerability-cve-2016-0728/)中说,该漏洞出现在 Linux <ruby> 钥匙环 <rp> ( </rp> <rt> keyring </rt> <rp> ) </rp></ruby>中,钥匙环用于存储认证信息、加密密钥、安全数据和其它敏感信息。简单来说,该漏洞允许攻击者提升普通本地用户的权限,获得设备的 root 权限。关于该漏洞的深入的描述,可以见[此文章](http://perception-point.io/2016/01/14/analysis-and-exploitation-of-a-linux-kernel-vulnerability-cve-2016-0728/)。
这很可怕,获得了 root 权限的攻击者可以在设备上做任何事情,包括安装恶意软件、删除文件、读取敏感信息等等。而**在有该漏洞的 Android 设备上得到 root 权限很简单,只需要用户点击某个恶意链接或扫描二维码,下载并打开来路不明的恶意应用就会受到攻击。**
### 谁会受到影响?
据 Perception Point 掌握的数据,目前还没有人受到该漏洞的攻击。这让人稍有安慰,但是有大量的设备都暴露在该安全漏洞之下,存在潜在的被攻击风险。
“虽然我们和内核安全团队没有观察到对此安全漏洞的攻击,但是这个安全漏洞暴露在外,随时有可能被利用”, Perception Point 的文章说,“我们建议安全团队检查受影响的设备,并尽快实施补丁”。
成千上万的运行 Linux 内核 3.8 及其以上版本的 Linux 桌面计算机和服务器会受此漏洞影响,而由于 Android 继承了部分 Linux 内核的代码,所以该漏洞也影响到了 Android 4.4 及其以上版本的设备。截止到目前,估计有超过 69.4%的 Android 设备受此影响,这已经远超安全研究人员的预计。简单的来说,如果你是两年内购买或升级的 Android 设备,那么你的设备是肯定受影响的。
Google [回应](https://plus.google.com/+AdrianLudwig/posts/KxHcLPgSPoY)了 Perception Point 的发现,并已经发布安全补丁交付给了合作厂商,称其实受到影响的设备“明显少于最初报道的”数量。
“我们确信 Nexus 设备不会因这个漏洞而受到第三方应用的影响”,Google 的 Adrian Ludwig 写到,“此外,Android 5.0 及其以上版本是受保护的,因为其上的 SELinux 策略会防止第三方应用访问到这些有问题的代码。还有,运行 Android 4.4 及更旧版本的设备也不包含这些有问题的代码,它们是在 Linux 内核 3.8 版本引入的,这些新的内核版本并不能用在旧的 Android 设备上。”
### 有多严重?
这个已经潜伏了近三年的安全漏洞非常严重,特别是 Perception Point 已经提出了验证该漏洞概念的代码。
好消息是,在 Linux 公司方面,[Red Hat](https://access.redhat.com/errata/RHSA-2016:0045) 和 Ubuntu 已经发布了更新,现在管理员们可以更新补丁了。
而 Android 方面有些复杂。虽然 Google 已经启动了[按月发布安全更新](http://www.wired.com/2015/08/google-samsung-lg-roll-regular-android-security-updates/)的计划,但是该公司并没有说这次的补丁是否会出现在2月份的更新中。即便发布,这个补丁也需要通过复杂的过程才能更新到那些 Android 定制厂商的设备中。换句话说,没有人能告诉你什么时候所有受影响的 Android 设备才会更新完成。
不过,好在你只要**不点击可疑链接或扫描来路不明的二维码去下载安全性未知的应用,就可以免受该漏洞的影响**。而一旦有了相关的安全更新,尽快更新就好。
| 301 | Moved Permanently | null |
6,920 | 在 Linux 上安装和配置 Munin 监控服务器 | http://www.linuxnix.com/install-and-configure-munin-monitoring-server-in-linux/ | 2016-01-22T21:32:28 | [
"监控",
"Munin"
] | https://linux.cn/article-6920-1.html | 
Munin 是一款类似 [RRD tool](http://www.linuxnix.com/network-monitoringinfo-gathering-tools-in-linux/) 的非常棒的系统监控工具,它能提供给你多方面的系统性能信息,例如 **磁盘、网络、进程、系统和用户**。这些是 Munin 默认监控的内容。
### Munin 如何工作?
Munin 以客户端-服务器模式运行。主服务器上运行的 Munin 服务器进程会从本地运行的客户端守护进程(Munin 可以监控它自己的资源)或者远程客户端(Munin 可以监控上百台机器)收集数据,然后在它的 web 界面上以图形的方式显示出来。
### 在服务器中配置 Munin
要配置服务器端和客户端,我们需要完成以下两步。
1. 安装 Munin 服务器软件包并配置,使得它能从客户端收集数据。
2. 安装 Munin 客户端,使得服务器能连接到客户端守护进程进行数据收集。
### 在 Linux 上安装 munin 服务器端
在基于 Ubuntu/Debian 的机器上安装 Munin 服务器:
```
apt-get install munin apache2
```
在基于 Redhat/CentOS 的机器上安装 Munin 服务器:
在基于 Redhat 的机器上安装 Munin 之前,你需要确保 [启用 EPEL 软件仓库](/article-2324-1.html),因为基于 Redhat 的机器的软件仓库默认没有 Munin。
```
yum install munin httpd
```
### 在 Linux 上配置 Munin 服务器端
下面是我们要在服务器上启动 Munini 所进行的步骤:
1. 在 /etc/munin/munin.conf 中添加需要监控的主机详情。
2. 配置 apache web 服务器使其包括 munin 配置。
3. 为 web 界面创建用户名和密码
4. 重启 apache 服务器
#### 步骤 1
在 **/etc/munin/munin.conf** 文件中添加主机条目。调到文件末尾添加要监控的客户端。在这个例子中,我添加了要监控的数据库服务器和它的 IP 地址。
示例:
```
[db.linuxnix.com]
address 192.168.1.25
use_node_name yes
```
保存文件并退出。
#### 步骤 2
在 /etc/apache2/conf.d 目录中编辑或创建文件 munin.conf 用于包括 Munin 和 Apache 相关的配置。另外注意一点,默认其它和 web 相关的 Munin 配置保存在 /var/www/munin 目录。
```
vi /etc/apache2/conf.d/munin.conf
```
内容:
```
Alias /munin /var/www/munin
<Directory /var/www/munin>
Order allow,deny
Allow from localhost 127.0.0.0/8 ::1
AllowOverride None
Options ExecCGI FollowSymlinks
AddHandler cgi-script .cgi
DirectoryIndex index.cgi
AuthUserFile /etc/munin/munin.passwd
AuthType basic
AuthName "Munin stats"
require valid-user
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault M310
</IfModule>
</Directory>
```
保存文件并退出。
#### 步骤 3
现在为查看 munin 的图示而创建用户名和密码:
```
htpasswd -c /etc/munin/munin-htpasswd munin
```
**注意**:对于 Redhat/Centos 机器,要访问你的配置文件,需要在每个路径中用 “**httpd**” 替换 “**apache2**”。
#### 步骤 4
重启 Apache 服务器,使得 Munin 配置生效。
基于 Ubuntu/Debian :
```
service apache2 restart
```
基于 Centos/Redhat :
```
service httpd restart
```
### 在 Linux 上安装和配置 Munin 客户端
#### 步骤 1
在 Linux 上安装 Munin 客户端
```
apt-get install munin-node
```
**注意**:如果你想监控你的 Munin 服务器端,你也需要在服务器端安装 munin-node。
#### 步骤 2
编辑 munin-node.conf 文件配置客户端。
```
vi /etc/munin/munin-node.conf
```
示例:
```
allow ^127\.0\.0\.1$
allow ^10\.10\.20\.20$
```
---
```
# 监听到哪个地址上
host *
```
---
```
# 以及哪个端口
port 4949
```
**注意**: 10.10.20.20 是我的 Munin 服务器,它连接到客户端的 4949 端口获取数据。
#### 步骤 3
在客户端机器中重启 munin-node:
```
service munin-node restart
```
### 测试连接
检查你是否能从服务器的连接到客户端的 4949 端口,如果不行,你需要在客户端机器中的防火墙打开该端口。
```
telnet db.linuxnix.com 4949
```
访问 Munin web 页面
```
http://munin.linuxnix.com/munin/index.html
```
希望这些能对你配置基本的 Munin 服务器有所帮助。

---
via: <http://www.linuxnix.com/install-and-configure-munin-monitoring-server-in-linux/>
作者:[Surendra Anne](http://www.linuxnix.com/author/surendra/) 译者:[ictlyh](http://mutouxiaogui.cn/blog/) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,921 | 微软开源 .NET 一年后,ASP.NET 情况分析 | http://mattwarren.github.io/2016/01/15/open-source-net-1-year-later-now-with-aspnet/ | 2016-01-23T08:03:00 | [
".NET",
"开源",
"微软"
] | https://linux.cn/article-6921-1.html | 在[前一篇文章](/article-6727-1.html)中,我们了解了微软在开源了 .NET 框架中最大一部分一年以来社区的参与情况。
接下来,我们将继续重复这个分析,但是这次我们将针对 [**ASP.NET**](https://github.com/aspnet) 系列项目进行分析:
* [**MVC**](https://github.com/aspnet/mvc/) - 通过分成“模型-视图-控制器(MVC)”等不同的概念部分来构建动态网站的框架,包括合并的 MVC、 Web API、 和 Web Pages w/ Razor。
* [**DNX**](https://github.com/aspnet/dnx/) - DNX(一个 .NET 扩展环境)包含了用于启动和运行应用的代码,包括编译系统、SDK 工具和原生 CLR 宿主。
* [**EntityFramework**](https://github.com/aspnet/EntityFramework/) - 微软推荐用于新的 .NET 应用的数据访问技术。
* [**KestrelHttpServer**](https://github.com/aspnet/KestrelHttpServer/) - 一个基于 libuv 的 ASP.NET 5 的 Web 服务器。

### **方法**
在[上一篇](/article-6727-1.html)中,我们首先把<ruby> 问题 <rp> ( </rp> <rt> issue </rt> <rp> ) </rp></ruby>/<ruby> 拉取请求 <rp> ( </rp> <rt> PR </rt> <rp> ) </rp></ruby>分成<ruby> 拥有者 <rp> ( </rp> <rt> Owner </rt> <rp> ) </rp></ruby>、<ruby> 协作者 <rp> ( </rp> <rt> Collaborator </rt> <rp> ) </rp></ruby>或<ruby> 社区 <rp> ( </rp> <rt> Community </rt></ruby>三类。然而这有一些问题,正如在评论中指出的那样,有几个人并非微软雇员,但是由于其在某个项目上的积极贡献也被列为了协作者,比如 [@kangaroo](https://github.com/kangaroo) 和 [@benpye](https://github.com/benpye/)。
为了解决这个问题,我决定分成两类:
* **微软**
* **社区**
这是可行的,因为(基本上)所有的微软雇员都会在其 GitHub 个人页面上标记其为微软雇员,比如:

这种情况有一些例外,比如 [@shanselman](https://github.com/shanselman) 显然是在微软工作,不过这种情况很好解决。
### 结果
在结束了所有分析之后,我得到了结果。总的来说,超过 60% 的“<ruby> 发现的问题 <rp> ( </rp> <rt> Issues Created </rt> <rp> ) </rp></ruby>”和 33% 的“<ruby> 合并的 PR <rp> ( </rp> <rt> Merged Pull Requests </rt> <rp> ) </rp></ruby>”来自社区。然而,PR 的占比受到了 Entity Framework 项目中微软雇员超高的 PR 数量的影响,从而有些不能准确反映情况。如果忽略这个项目,社区贡献的 PR 将占到 44%。
**发现的问题(2013/11 - 2015/12)**
| 项目 | **微软** | **社区** | 合计 |
| --- | --- | --- | --- |
| aspnet/**MVC** | 716 | 1380 | 2096 |
| aspnet/**dnx** | 897 | 1206 | 2103 |
| aspnet/**EntityFramework** | 1066 | 1427 | 2493 |
| aspnet/**KestrelHttpServer** | 89 | 176 | 265 |
| **合计** | **2768** | **4189** | **6957** |
**合并的 PR(2013/11 - 2015/12)**
| **项目** | **微软** | **社区** | **合计** |
| --- | --- | --- | --- |
| aspnet/**MVC** | 385 | 228 | 613 |
| aspnet/**dnx** | 406 | 368 | 774 |
| aspnet/**EntityFramework** | 937 | 225 | 1162 |
| aspnet/**KestrelHttpServer** | 69 | 88 | 157 |
| **合计** | **1798** | **909** | **2706** |
备注:我包括了 [Kestrel Http Server](https://github.com/aspnet/KestrelHttpServer) 项目,因为它是一个有趣的例子。当前它的第一号贡献者 [Ben Adams](https://twitter.com/ben_a_adams/status/684503094810525696/photo/1) 并非微软雇员,他为[改善其内存使用](http://www.hanselman.com/blog/WhenDidWeStopCaringAboutMemoryManagement.aspx)做出了很大的贡献,让 Kestrel 可以每秒钟接受更多的请求。
通过观察随时间推移的变化,可以很清楚的看到社区(浅色条)在过去两年(2013/11 - 2015/12)来的参与情况,看起来并不像是趋于停止。
**每月发现的问题数 - 按提交者**
[](https://cloud.githubusercontent.com/assets/157298/12142495/6f746e92-b470-11e5-97fd-bf0d59a74875.png)
此外,虽然社区参与情况可以很容易地从每月发现的问题数上看出来,不过从合并的 PR 数上也可以再次印证这两年来的趋势。
**每月合并的 PR 数 - 按提交者**
[](https://cloud.githubusercontent.com/assets/157298/12142522/9f72726a-b470-11e5-8333-aec772ff9f6b.png)
**贡献总数**
每个项目的贡献人数也很有意思。通过这个你可以看到社区贡献者的实际规模,并不是少量的人做了大量的工作,而是这些工作由大量的人分散完成的。
这个表格展示了每个项目中发现问题和提交了被合并的 PR 的人数:
| **项目** | **微软** | **社区** | 合计 |
| --- | --- | --- | --- |
| aspnet/**MVC** | 39 | 395 | 434 |
| aspnet/**dnx** | 46 | 421 | 467 |
| aspnet/**EntityFramework** | 31 | 570 | 601 |
| aspnet/**KestrelHttpServer** | 22 | 95 | 117 |
| **合计** | **138** | **1481** | **1619** |
### **FSharp**
在我的第一篇文章的评论中,Isaac Abraham 指正说:
>
> .NET 的一部分已经开源一年多了,F# 编译器和 FSharp.Core 已经开源一段时间了。
>
>
>
所以,为了解决这个问题,我去了解了一下主要的 FSharp 仓库:
* [**microsoft/visualfsharp**](http://mattwarren.github.io/2016/01/15/open-source-net-1-year-later-now-with-aspnet/github.com/microsoft/visualfsharp)
* [**fsharp/fsharp**](https://github.com/fsharp/fsharp)
按 Isaac 的解释,他们之间的关系是:
>
> ... visualfsharp 是微软自己的 Visual F# 版本仓库。而另外一个是社区管理的一个。前一个是直接作为 Visual Studio 其中的 Visual F# 工具;而后一个则是类似 Xamarin 的东西。这里有个(稍微过时的)[解析它们关系的图表](http://fsharp.github.io/2014/06/18/fsharp-contributions.html),以及另外一个有用的资源:<http://fsharp.github.io/> 。
>
>
>
**FSharp - 发现的问题(2010/12 - 2015/12)**
| **项目** | **微软** | **社区** | **合计** |
| --- | --- | --- | --- |
| fsharp/fsharp | 9 | 312 | 321 |
| microsoft/visualfsharp | 161 | 367 | 528 |
| **合计** | **170** | **679** | **849** |
**FSharp - 合并的 PR(2011/5 - 2015/12)**
| **项目** | **微软** | **社区** | **合计** |
| --- | --- | --- | --- |
| fsharp/fsharp | 27 | 134 | 161 |
| microsoft/visualfsharp | 36 | 33 | 69 |
| **合计** | **63** | **167** | **230** |
### 结论
我认为,公平地说社区已经对微软越来越多地开源其代码的动作做出了回应。在几个项目上社区花费了大量时间,做出了显著的贡献。虽然你可以说微软也花费了大量的时间来开源,但是看起来 .NET 开发人员很喜欢他们做的事情,体现了可观的社区响应。
| 301 | Moved Permanently | null |
6,923 | 英伟达和 Valve 携手推进 Vulkan 开发,准备取代 OpenGL | http://news.softpedia.com/news/nvidia-and-valve-are-spearheading-vulkan-development-499174.shtml | 2016-01-23T18:59:02 | [
"Vulkan",
"OpenGL"
] | https://linux.cn/article-6923-1.html | 
英伟达、Valve 及来自 Khronos Group 的 Vulkan 开发者们正在准备召开首次 Vulkan 开发者日。
显然, Vulkan 应该就是图形化标准的未来,至少在<ruby> 开放标准图形化 <rp> ( </rp> <rt> open-standard graphics </rt> <rp> ) </rp></ruby>方面是这样的,而且毫无疑问 Valve 将在里面扮演重要角色。Khronos Group 同样也是 OpenGL 的推动者,而且一直有些进展,但是事实上 OpenGL 有点跟不上发展了,进度远远落后于 Direct X。
Khronos Group 是一个行业联盟,它得到了很多公司的支持,包括 AMD、 Intel、 Apple、 Qualcomm、 Sony、 Google、 Adobe、 Amazon、 Pixar、 Valve,甚至还包括竞争对手微软。有趣的是如果拿 Vulkan 与 OpenGL 进行比较,即将出现的 Vulkan 来自和 OpenGL 同样的开发者,但是进展似乎更快。
### 英伟达和 Valve 正在推动 Vulkan
Vulkan 本来是一个新的跨平台、开放标准的图形与计算应用编程接口,但是多数人似乎希望它能够最终取代旧的 OpenGL。更重要的是,它集合了各个公司,甚至是竞争对手的力量,而最终的目标是形成一个可以被任何人使用的开放标准。
“Vulkan 超越 OpenGL 的一个关键优势是它能生成横跨多个 CPU 线程的 GPU 任务,这对于处理<ruby> 计算密集型 <rp> ( </rp> <rt> CPU-bound </rt> <rp> ) </rp></ruby>任务的开发者特别有用,可以用于很多应用领域,包括游戏、计算机辅助设计和移动应用等”,英伟达的 [Neil Trevett](http://blogs.nvidia.com/blog/2016/01/19/vulkan-developers-day/) 写到,他是 Khronos 主席。
新召开的 Vulkan 开发者日将在英伟达的园区召开,Valve 的 John McDonald 将会发表高性能 Vulkan 编程的演讲。看起来2016年会发生一些有趣的大事,这些 Khronos Group 背后的公司实际上掌握着整个行业发展,而 Valve 也做的不错。
| 301 | Moved Permanently | null |
6,927 | grep 命令系列:如何在 Linux/UNIX 中使用 grep 命令 | http://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/ | 2016-01-25T08:02:00 | [
"grep"
] | https://linux.cn/article-6927-1.html | 我该怎样在 Linux、Apple OS X 及其他类 UNIX 系统中使用 grep 命令,你能给我展示一些简单的例子吗?
grep 命令用来搜索文本,或从给定的文件中搜索行内包含了给定字符串或单词的文件。通常来说,grep 显示匹配到的行。使用 grep 来搜索包括一个或多个正则表达式匹配到的文本行,然后只显示匹配到的行。grep 被视作在 Linux/ Unix 系统中最有用的命令之一。

### 你知道吗
grep 这个名字,来源于一个 Unix/Linux 中的古老的行编辑器 [ed](https://en.wikipedia.org/wiki/Ed_(text_editor)) 中执行相似操作的命令:
```
g/re/p
```
### grep 命令的语法
语法如下所示:
```
grep 'word' 文件名
grep 'word' 文件1 文件2 文件3
grep 'word1\|word2' 文件名
cat 某个文件 | grep '某个东西'
command | grep '某个东西'
command 选项1 | grep '数据'
grep --color '数据' 文件名
```
### 怎么样使用 grep 来搜索一个文件
搜索 /etc/passwd 文件下的 boo 用户,输入:
```
$ grep boo /etc/passwd
```
输出内容:
```
foo:x:1000:1000:foo,,,:/home/foo:/bin/ksh
```
可以使用 grep 去强制忽略大小写。例如,使用 -i 选项可以匹配 boo, Boo, BOO 和其他组合:
```
$ grep -i "boo" /etc/passwd
```
### 递归使用 grep
你可以递归地使用 grep 进行搜索。例如,在文件目录下面搜索所有包含字符串“192.168.1.5”的文件
```
$ grep -r "192.168.1.5" /etc/
```
或者是:
```
$ grep -R "192.168.1.5" /etc/
```
示例输出:
```
/etc/ppp/options:# ms-wins 192.168.1.50
/etc/ppp/options:# ms-wins 192.168.1.51
/etc/NetworkManager/system-connections/Wired connection 1:addresses1=192.168.1.5;24;192.168.1.2;
```
你会看到搜索到 192.168.1.5 的结果每一行都前缀以找到匹配的文件名(例如:/etc/ppp/options)。输出之中包含的文件名可以加 -h 选项来禁止输出:
```
$ grep -h -R "192.168.1.5" /etc/
```
或者
```
$ grep -hR "192.168.1.5" /etc/
```
示例输出:
```
# ms-wins 192.168.1.50
# ms-wins 192.168.1.51
addresses1=192.168.1.5;24;192.168.1.2;
```
### 使用 grep 去搜索文本
当你搜索 boo 时,grep 命令将会匹配 fooboo,boo123, barfoo35 和其他所有包含 boo 的字符串,你可以使用 -w 选项去强制只输出那些仅仅包含那个整个单词的行(LCTT译注:即该字符串两侧是英文单词分隔符,如空格,标点符号,和末端等,因此对中文这种没有断字符号的语言并不适用。)。
```
$ grep -w "boo" file
```
### 使用 grep 命令去搜索两个不同的单词
使用 egrep 命令如下:
```
$ egrep -w 'word1|word2' /path/to/file
```
(LCTT 译注:这里使用到了正则表达式,因此使用的是 egrep 命令,即扩展的 grep 命令。)
### 统计文本匹配到的行数
grep 命令可以通过加 -c 参数显示每个文件中匹配到的次数:
```
$ grep -c 'word' /path/to/file
```
传递 -n 选项可以输出的行前加入匹配到的行的行号:
```
$ grep -n 'root' /etc/passwd
```
示例输出:
```
1:root:x:0:0:root:/root:/bin/bash
1042:rootdoor:x:0:0:rootdoor:/home/rootdoor:/bin/csh
3319:initrootapp:x:0:0:initrootapp:/home/initroot:/bin/ksh
```
### 反转匹配(不匹配)
可以使用 -v 选项来输出不包含匹配项的内容,输出内容仅仅包含那些不含给定单词的行,例如输出所有不包含 bar 单词的行:
```
$ grep -v bar /path/to/file
```
### UNIX/Linux 管道与 grep 命令
grep 常常与管道一起使用,在这个例子中,显示硬盘设备的名字:
```
# dmesg | egrep '(s|h)d[a-z]'
```
显示 CPU 型号:
```
# cat /proc/cpuinfo | grep -i 'Model'
```
然而,以上命令也可以按照以下方法使用,不使用管道:
```
# grep -i 'Model' /proc/cpuinfo
```
示例输出:
```
model : 30
model name : Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz
model : 30
model name : Intel(R) Core(TM) i7 CPU Q 820 @ 1.73GHz
```
### 如何仅仅显示匹配到内容的文件名字?
使用 -l 选项去显示那些文件内容中包含 main() 的文件名:
```
$ grep -l 'main' *.c
```
最后,你可以强制 grep 以彩色输出:
```
$ grep --color vivek /etc/passwd
```
示例输出:

---
via: <http://www.cyberciti.biz/faq/howto-use-grep-command-in-linux-unix/>
作者:Vivek Gite 译者:[zky001](https://github.com/zky001) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,928 | Linux 系统下查看硬件信息命令大全 | https://www.maketecheasier.com/check-hardware-information-linux/ | 2016-01-25T08:23:10 | [
"硬件"
] | https://linux.cn/article-6928-1.html | 
有许多命令可以用来查看 Linux 系统上的硬件信息。有些命令只能够打印出像 CPU 和内存这一特定的硬件组件信息,另外一些命令可以查看多种硬件组件的信息。
这个教程可以带大家快速了解一下查看各种硬件设备的信息和配置详情的最常用的命令。
### lscpu
`lscpu`命令能够查看 CPU 和处理单元的信息。该命令没有任何其他选项或者别的功能。
```
lscpu
```
运行该命令会看到下面输出:

### lspci
`lspci`是另一个命令行工具,可以用来列出所有的 PCI 总线,还有与 PCI 总线相连的设备的详细信息,比如 VGA 适配器、显卡、网络适配器、usb 端口、SATA 控制器等。
```
lspci
```
你可以看到类似下图的输出信息。

可以通过运行下面的命令来过滤出特定设备的信息:
```
lspci -v | grep "VGA" -A 12
```
运行上面的命令可以看到类似下图的关于显卡的信息。

### lshw
`lshw`是一个通用的工具,可以列出多种硬件单元的详细或者概要的信息,比如 CPU、内存、usb 控制器、硬盘等。`lshw`能够从各个“/proc”文件中提取出相关的信息。
```
lshw -short
```
通过运行上面的命令可以看到下面的信息。

### lsscsi
通过运行下面的命令可以列出像硬盘和光驱等 scsi/sata 设备的信息:
```
lsscsi
```
会得到类似下面的输出。

### lsusb
`lsusb`命令能够列出 USB 控制器和与 USB 控制器相连的设备的详细信息。默认情况下,`lsusb`命令只打印出概要信息。可以通过使用-v参数打印每一个usb端口的详细信息。
```
lsusb
```
可以看到下面输出。

### Inxi
`Inxi`是一个 bash 脚本,能够从系统的多个来源和命令获取硬件信息,并打印出一个非技术人员也能看懂的友好的报告。
默认情况下,Ubuntu 上没有安装`inxi`。可以通过运行下面命令来安装`Inxi`:
```
sudo apt-get install inxi
```
安装完`Inxi`之后,通过运行下面命令能够得到硬件相关的信息:
```
inxi -Fx
```
能够得到类似下图的输出。

### df
`df`命令能够列出不同分区的概要信息、挂载点、已用的和可用的空间。
可以在使用`df`命令的时候加上`-H`参数。
```
df -H
```
会得到下面的输出。

### Free
通过使用`free`命令可以查看系统中使用的、闲置的和 RAM 的总体数量。
```
free -m
```
会看到下面输出。

### Dmidecode
`dmidecode`命令与其他命令不同。该命令是从硬件中的 DMI 表中读取信息的。
要查看处理器的信息,运行下面命令:
```
sudo dmidecode -t processor
```

要查看内存的信息,运行下面命令:
```
sudo dmidecode -t memory
```

要查看 bios 的信息,运行下面命令:
```
sudo dmidecode -t bios
```

### Hdparm
`hdparm`命令可以用来显示像硬盘这样的 sata 设备的信息。
```
sudo hdparm
```
可以看到下面的输出。

### 总结
每个命令都有不同的方式来获取硬件的信息。在查看特定的硬件信息的时候,可以尝试使用不同的方式。上面所有的命令行工具在大部分的 Linux 发行版本中都是可以使用的,可以很容易的从仓库中获取安装。
---
via: <https://www.maketecheasier.com/check-hardware-information-linux/>
作者:[Hitesh Jethva](https://www.maketecheasier.com/author/hiteshjethva/) 译者:[sonofelice](https://github.com/sonofelice) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | There are many commands available to check hardware information of your Linux system. Some commands report only specific hardware components like CPU or memory while the rest cover multiple hardware units.
This tutorial takes a quick look at some of the most commonly used commands to check information and configuration details about various hardware devices.
## lscpu
The `lscpu`
command gives you information about the CPU and processing units. It does not have any other options or functionality.
lscpu
You will see the following output by running the above command.
## lspci
The `lspci`
is another command line tool that lists all the PCI buses and details about the devices connected to them like VGA adapter, graphics card, network adapter, usb ports, SATA controller, etc.
`lspci`
You will see an output similar to the following image.
You can also filter out specific device information by running the following command:
lspci -v | grep "VGA" -A 12
You will see graphics card information similar to the following.
## lshw
The `lshw`
is a general purpose utility that reports detailed and brief information about multiple hardware units like CPU, memory, usb controller, disk, etc. Lshw extracts the information from different “/proc” files.
`lshw -short`
You will see the following information by running the above command.
## lsscsi
You can list all scsi/sata devices like hard drives and optical drives by running the following command:
lsscsi
The output wI’ll look something like this image.
## lsusb
This command shows you the USB controllers and details about devices connected to them. By default, the `lsusb`
command prints brief information. You can also use the verbose option `-v`
to print detailed information about each usb port.
lsusb
You will see the following output.
## Inxi
`Inxi`
is a bash script that fetches hardware information from multiple sources and commands on the system and gives you goodlooking reports that non-technical users can read easily.
By default, `inxi`
is not installed in Ubuntu. You can install it by running the following command:
sudo apt-get install inxi
After installing inxi, you can get hardware information by running the following command:
`inxi -Fx`
You will see an output similar to the image below.
## df
This command gives you brief information about various partitions, their mount points and the used and available space on each.
You can run the `df`
command with the `-H`
parameter.
df -H
You will see the following output.
## Free
You can check the amount of used, free and total amount of RAM on your system with the free command.
free -m
You will see the following output.
## Dmidecode
The `dmidecode`
command is different from all other commands. It extracts hardware information by reading data from the DMI tables.
To display information about the processor, run:
sudo dmidecode -t processor
To display information about the memory, run:
sudo dmidecode -t memory
To display information about the bios, run:
sudo dmidecode -t bios
## Hdparm
The `hdparm`
command gives you information about sata devices like hard disks.
`sudo hdparm`
You will see the following output.
## Conclusion
Each of the commands has a different method of extracting hardware information. You can try more than one of them while looking for specific hardware details. All of the above tools are available in most Linux distros, and can be easily installed from the default repository.
Our latest tutorials delivered straight to your inbox |
6,931 | 基于 JavaScript 的操作系统你听说过吗? | http://www.toptal.com/nodejs/nodeos-the-javascript-based-operating-system | 2016-01-25T17:40:00 | [
"Node.js",
"NodeOS",
"JavaScript"
] | https://linux.cn/article-6931-1.html | 我想大多数人听说过 Node.js,但是你听说过 NodeOS 吗?没错,NodeOS,一个用 Node.js 写的操作系统。好吧,实话说,NodeOS 用 Linux 内核来处理各种底层任务,比如硬件通讯什么的,但是除此之外,使用的都是 Node.js。NodeOS 的开发始于两年前,创建者的目的很简单,他只是好奇,“是否有可能仅使用 Node.js 创建一个操作系统呢?”

*是否有可能仅使用 Node.js 创建一个操作系统呢?*
### 这个主意怎么样?
我们已经看到了 Node.js 在这几年已经取得如此迅猛的发展,那么我们为何不让它更酷一些呢?比如用它做个操作系统。
### 用户自主的独立文件系统
NodeOS 引入了一个有趣的特性:所有的用户都有一个独立的文件系统,他们在一个简单的文件系统中完成各种工作。因为他们的“主目录”事实上就是他们自己的文件系统的根(root),所以他们可以不需要任何超级权限就可以将软件包安装到系统中,也不需要配置什么,因为软件包默认就安装在他们自己的主目录里面。此外,这样也提供了良好的安全性,如果黑客攻入到了某个账户,那么只能访问到该用户所在的部分,最终的结果就是黑客并不能由此影响到整个系统。
### Node.js 和 NPM
你可以想想,如果一个操作系统使用 Node.js,那就意味着所有在 NPM 中可用的包同时也都是 NodeOS 的软件包。在写作本文时,已经有了超过 21 万的软件包,而且每分每秒都在不断增长。如果几年以后,NodeOS 有了一百万应用,那也没什么好奇怪的。
### 基于 Linux 内核
这看起来并不算什么,Linux 是大多数服务器所采用的操作系统。因为 NodeOS 是基于 Linux 内核的,所以你只需要很少的修改就可以使用那些给其它的 Linux 发行版开发的应用了。
### 不好的消息
我非常希望 NodeOS 是一个已经完成的作品,但是,它现在还不是。它仍然缺少一些服务器操作系统所必需的关键功能。比如,缺失完整的 BASH 工具集,包括 ps、tail、nano 和 grep 等都没有。更糟糕的是,你也不能把它当成桌面操作系统使用,因为它没有 GUI。当然,你可以实现一些缺失的功能,只需要使用一点点 JavaScript,但是默认情况下,这些功能现在都还没有,真糟糕。
### 好吧,那我可以试试 NodeOS 吗?
#### 使用 Docker 来体验
最容易、最快捷的体验 NodeOS 的方法如下:
1. 一台运行 Mac OSX 或 Linux 计算机,也许 Windows 也可以,但是我没试过。
2. Docker。
当你安装好 Docker 之后,运行一个 NodeOS 实例是很容易的。你只需要执行如下命令就可以了, Docker 会为你完成这魔法般的一切:
```
sudo docker run -t -i nodeos/nodeos
```

*最容易、最快捷的体验 NodeOS 的方法是通过 Docker。*
当你运行了上述命令,Docker 会自动从仓库下载 NodeOS 的镜像,并将其安装到一个虚拟环境中。安装好之后,会打开一个连接到 NodeOS 的 SSH 会话。
#### 不用 docker 呢?
有些情况下你也许不能使用 Docker 来体验,或者是你想体验一下最新版本的 NodeOS 。在写作本文时,NodeOS 的镜像已经是两个月前生成的了,而开发版本则是六天前更新的。所以,如果你希望使用最新版本,你应该从源代码开始。这也不算很难,但是要花费一些时间。你需要:
1. 一台运行 Linux 的计算机。你可以在 OS X 上编译它,但是跨平台编译需要花费很多时间,对于 Windows 也如此。
2. Linux 编译构建相关的工具(make、g++、gcc、autoconf)。
3. Qemu。
4. 时间,真的需要很多。
如果万事俱备,你就可以从源代码开始编译了:
1. 下载项目源代码:`bash git clone [email protected]:NodeOS/NodeOS.git`。
2. 使用下列命令编译: `cd NodeOS` 并 `npm install`。
3. 我逐字引用了其官方文档的话:“拿上爆米花去看场电影吧,不开玩笑,真的。”,是的,它需要很多时间,做些有意思的事情去吧。
4. 执行 `bash npm start` 来在 Qemu 中运行 NodeOS。
#### 可以工作了吗?
当安装完成后,我们可以通过在 NodeOS 的 shell 中执行 `ls`命令来看看它是否工作了。输出类似如下:
```
[ 'etc', 'lib', 'lib64', 'root', 'bin', 'sys', 'usr', 'share', 'proc' ]
```
如果显示如上,说明一些基本的命令可以工作了。但是如果我们想要知道网卡地址呢?在 Linux 下,这个命令是 `ifconfig` ,让我们试试:
```
command not found: ifconfig
```
看起来没有 `ifconfig` 命令。这是因为 NodeOS 默认没有 `ifconfig`命令。现在怎么办?很简单,NodeOS 有一个集成的包管理器(类似 `apt` 或 `yum`) ,叫做 `npkg`,它是基于 Node 的 NPM 的,很容易使用。可以通过如下命令很方便的安装 `ifconfig` :
```
npkg install bin-ifconfig
```
如果一切正常, `ifconfig` 命令现在就可以在 shell 中使用了。我们再次试着执行一下,输出类似如下:(我替换了其中的 MAC 地址):
```
eth0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 01:23:45:67:89:ab
inet6 f0cd::ef01:0203:0405:181%en1 prefixlen 64 scopeid 0x5
inet 192.168.0.21 netmask 0xffffff00 broadcast 192.168.0.21
nd6 options=1<PERFORMNUD>
media: autoselect
status: active
```
如果你的输出也类似如上,那说明它可以工作了。你已经成功地安装了你的第一个 NodeOS 应用: `ifconfig`。
### 它是可以工作了,然而我们可以用这个操作系统做什么呢?
如果我们只能拿这个用 Node.js 写的操作系统做到你在 Ubuntu 或其它 Linux 发行版上一样的(或更少的)事情,那它有什么价值?其实,整个事情中最有趣的地方是所有的东西都是 Node.js 开发的。这意味着我们可以只需要使用 Node.js 就可以[开发](http://www.toptal.com/nodejs/why-the-hell-would-i-use-node-js)我们的应用了。比如,NodeOS 里没有默认实现的 man 命令,它用于显示其它命令的帮助信息。不用担心,实现它很简单。

*使用 Node.js 构建一个 NodeOS 应用*
首先让我们来安装一个叫做 Hipster 的文本编辑器,以便我们可以创建和编辑文件。执行如下命令: `npm install -g [email protected]`。这个文本编辑器很简单,除了用作文本编辑之外啥也干不了,不过对于我们来说足够了。
用 Hipster 创建文件很简单,运行 `hip filename`即可,如: `hip package.json`。要保存文件请按下 `Ctrl + s` ,退出按下 `Ctrl + q`。
在这里,我们使用了一个 NodeOS 的主开发人员所开发的代码,我自己并没有真的去开发这个应用。我们例子中的原始代码可以在 [node-bin-man Git 仓库](https://github.com/groundwater/node-bin-man)中找到。
让我们回过头来创建我们的第一个 NodeOS 应用。像每个 Node.js 应用(或 NPM 包)一样,我们从创建一个 `package.json` 文件开始,内容如下:
```
{
"name": "bin-man",
"version": "0.0.1",
"description": "Format and display manual pages",
"bin": {
"man": "man.js"
},
"repository": "https://github.com/groundwater/node-bin-man",
"author": "groundwater",
"license": "MIT",
"dependencies": {
"blessed": "~0.0.22"
}
}
```
这些参数 `name`、`version`、 `author`、 `repository`、 `license`和 `description` 是其意自明的。这个 `bin` 集合是一个 JSON 的键值对对象,包含了命令名及其关联的 JavaScript 文件。在我们的例子中, `man` 命令关联到 `man.js`文件。而 `dependencies`集合包含了这个应用所需要的 NPM 包的列表。在我们的例子中,代码的作者包含了 Blessed 包,这是一个类 curses 的库,可以让 Node.js 支持高级终端界面的 API。
现在我们进入了主要的部分,实际的代码。
```
#!/usr/bin/env node
```
这个部分叫做<ruby> <a href="/article-3664-1.html"> 释伴 </a> <rp> ( </rp> <rt> shebang </rt> <rp> ) </rp></ruby>。NodeOS 实际上并不需要它,但是它用于告诉操作系统如何执行下面的代码。在这里的意思是,它告诉系统下面的每行代码都需要通过 `/usr/bin/env node`命令来解释执行。
```
var fs = require('fs');
var blessed = require('blessed');
```
像在 Node.js 中一样, `require()` 函数加载选定的包到内存中,并将其保存为特定的变量。
```
var arg = process.argv[2] || 'bin-man';
```
`man` 命令的标准行为是如果没有指定要查看的命令时,就显示它自己的帮助信息。在我们的代码示例中也一样:如果没有给出第二个参数(第一个参数是 man 本身),那么该参数的默认值是 bin-man。
```
var path = process.env.HOME + "/lib/node_modules/" + arg + "/README.md";
try{
var readme = fs.readFileSync(path, 'utf-8');
}catch(e){
console.log('No README.md for Package ',arg);
process.exit(-1);
}
```
在这里,程序检查给定的应用是否有一个 readme 文件。在 NodeOS 中,每个应用的安装路径是其主目录(/)下的 `lib/node_modules`。如果 `README.md` 文件存在,就将其内容保存到 `readme`变量中。否则,显示一个错误信息并退出。
```
// Create a screen object.
var screen = blessed.screen();
var box = blessed.box({
content: readme,
alwaysScroll:true,
scrollable: true,
});
// Append our box to the screen.
screen.append(box);
```
Blessed 有一个非常简单的 API,要显示一个文件的内容很容易,只需要创建一个 `box` ,然后载入内容即可。
```
screen.key(['escape', 'q', 'C-c'], function(ch, key) {
return process.exit(0);
});
```
现在,让我们找个退出 `man` 应用的方法。我们组合了 `escape`、 `q` 或 emacs 风格的 `C-c` 来退出应用。
```
screen.key(['space','f','j','n'], function(ch, key) {
box.scroll(box.height);
screen.render();
});
screen.key(['down'], function(ch, key) {
box.scroll(1);
screen.render();
});
screen.key(['up'], function(ch, key) {
box.scroll(-1);
screen.render();
});
screen.key(['b','k','p'], function(ch, key) {
box.scroll(-box.height);
screen.render();
});
```
我们使用方向键来上滚和下滚,用 `space`、 `f`、 `j` 或 `n` 向下翻页,`b`、 `k` 或 `p` 向上翻页。
```
box.focus();
screen.render();
```
最后,我们让应用将输入焦点放到 `box` ,我们在这里创建和渲染所有内容。
把上面编辑的这个文件存放到 `/lib/node_modules/bin-man` 目录下(名字是 `man.js`),并加一个简单的 `README.md` ,类似如下:
```
# Man
Author: @groundwater
## Install
npkg install bin-man
## Usage
```
Usage: man PKGNAME
Display a packages README.md file
```
```
我们已经基本完成了我们的第一个 NodeOS 定制应用。最后剩下一小步了,我们需要创建一个 NodeOS 应用需要的配置文件。很简单,把它创建到 `/etc/bin-man/config.json` ,内容只是一个空的 JSON 对象: `{}`。
现在我们可以试试我们的新应用了。在 NodeOS 中运行 `man` ,它将展示我们之前创建的 readme 文件。
### 总结
如你所见,在 NodeOS 中实现任何东西都很简单,你只需要懂得 Node.js 即可。
NodeOS 很有潜力,我认为当实现了更多的功能之后它会成为一个伟大的操作系统。目前仍然需要很多工作,但是在整个Node.js 生态系统兴盛发展的形势下,万一哪天它很快地成为一个流行的操作系统也没什么好惊奇的。
你怎么看?发表你的评论让我们知道。
| 301 | Moved Permanently | null |
6,941 | grep 命令系列:grep 中的正则表达式 | http://www.cyberciti.biz/faq/grep-regular-expressions/ | 2016-01-27T11:30:00 | [
"grep",
"正则表达式"
] | https://linux.cn/article-6941-1.html | 在 Linux 、类 Unix 系统中我该如何使用 Grep 命令的正则表达式呢?
Linux 附带有 GNU grep 命令工具,它支持<ruby> 扩展正则表达式 <rp> ( </rp> <rt> extended regular expressions </rt> <rp> ) </rp></ruby>,而且 GNU grep 在所有的 Linux 系统中都是默认有的。Grep 命令被用于搜索定位存储在您服务器或工作站上的任何信息。

### 正则表达式
正则表达式就是用于匹配每行输入的一种模式,模式是指一串字符序列。下面是范例:
```
^w1
w1|w2
[^ ]
```
#### grep 正则表达式示例
在 /etc/passswd 目录中搜索 'vivek'
```
grep vivek /etc/passwd
```
输出例子:
```
vivek:x:1000:1000:Vivek Gite,,,:/home/vivek:/bin/bash
vivekgite:x:1001:1001::/home/vivekgite:/bin/sh
gitevivek:x:1002:1002::/home/gitevivek:/bin/sh
```
搜索大小写任意的 vivek(即不区分大小写的搜索)
```
grep -i -w vivek /etc/passwd
```
搜索大小写任意的 vivek 或 raj
```
grep -E -i -w 'vivek|raj' /etc/passwd
```
上面最后的例子显示的,就是一个扩展的正则表达式的模式。
### 锚点
你可以分别使用 ^ 和 $ 符号来正则匹配输入行的开始或结尾。下面的例子搜索显示仅仅以 vivek 开始的输入行:
```
grep ^vivek /etc/passwd
```
输出例子:
```
vivek:x:1000:1000:Vivek Gite,,,:/home/vivek:/bin/bash
vivekgite:x:1001:1001::/home/vivekgite:/bin/sh
```
你可以仅仅只搜索出以单词 vivek 开始的行,即不显示 vivekgit、vivekg 等(LCTT 译注:即该单词后面是空格、符号等英文的单词分隔符。)
```
grep -w ^vivek /etc/passwd
```
找出以单词 word 结尾的行:
```
grep 'foo$' 文件名
```
匹配仅仅只包含 foo 的行:
```
grep '^foo$' 文件名
```
如下所示的例子可以搜索空行:
```
grep '^$' 文件名
```
### 字符类
匹配 Vivek 或 vivek:
```
grep '[vV]ivek' 文件名
```
或者
```
grep '[vV][iI][Vv][Ee][kK]' 文件名
```
也可以匹配数字 (即匹配 vivek1 或 Vivek2 等等):
```
grep -w '[vV]ivek[0-9]' 文件名
```
可以匹配两个数字字符(即 foo11、foo12 等):
```
grep 'foo[0-9][0-9]' 文件名
```
不仅仅局限于数字,也能匹配至少一个字母的:
```
grep '[A-Za-z]' 文件名
```
显示含有 "w" 或 "n" 字符的所有行:
```
grep [wn] 文件名
```
放在括号内的表达式,即包在 "[:" 和 ":]" 之间的字符类的名字,它表示的是属于此类的所有字符列表。标准的字符类名称如下:
* `[:alnum:]` - 字母数字字符
* `[:alpha:]` - 字母字符
* `[:blank:]` - 空字符: 空格键符 和 制表符
* `[:digit:]` - 数字: '0 1 2 3 4 5 6 7 8 9'
* `[:lower:]` - 小写字母: 'a b c d e f g h i j k l m n o p q r s t u v w x y z'
* `[:space:]` - 空格字符: 制表符、换行符、垂直制表符、换页符、回车符和空格键符
* `[:upper:]` - 大写字母: 'A B C D E F G H I J K L M N O P Q R S T U V W X Y Z'
在这个例子所示的是匹配所有大写字母:
```
grep '[:upper:]' 文件名
```
### 通配符
你可以使用 "." 来匹配单个字符。例子中匹配以 "b" 开头以 "t" 结尾的3个字符的单词:
```
grep '\<b.t\>' 文件名
```
在这儿,
* `\<` 匹配单词前面的空字符串
* `\>` 匹配单词后面的空字符串
打印出只有两个字符的所有行:
```
grep '^..$' 文件名
```
显示以一个点和一个数字开头的行:
```
grep '^\.[0-9]' 文件名
```
#### 点字符转义
下面要匹配到 IP 地址为 192.168.1.254 的正则式是不正确的:(LCTT 译注:可以匹配到该 IP 地址,但是也有可能匹配到间隔符号不是点的类似格式)
```
grep '192.168.1.254' /etc/hosts
```
三个点字符都需要转义:
```
grep '192\.168\.1\.254' /etc/hosts
```
下面的例子只能匹配出 IP 地址:(LCTT 译注:实际上由于 IP 地址中数字的取值范围,该正则表达式并不精确)
```
egrep '[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}\.[[:digit:]]{1,3}' 文件名
```
### 怎么样搜索以“-” 符号开头的匹配模式?
要使用 -e 选项来搜索匹配 '--test--' 字符串,如果不使用 -e 选项,grep 命令会试图把 '--test--' 当作自己的选项参数来解析:
```
grep -e '--test--' 文件名
```
### 怎么使用 grep 的“或”匹配?
使用如下的语法:
```
grep -E 'word1|word2' 文件名
或
egrep 'word1|word2' 文件名
```
或者是
```
grep 'word1\|word2' 文件名
```
### 怎么使用 grep 的“和”匹配?
使用下面的语法来显示既包含 'word1' 又包含 'word2' 的所有行
```
grep 'word1' 文件名 | grep 'word2'
```
### 怎么样使用序列检测?
使用如下的语法,您可以检测一个字符在序列中重复出现次数:
```
{N}
{N,}
{min,max}
```
要匹配字符 “v" 出现两次:
```
egrep "v{2}" 文件名
```
下面的命令能匹配到 "col" 和 "cool" :
```
egrep 'co{1,2}l' 文件名
```
下面的命令将会匹配出至少有三个 'c' 字符的所有行。
```
egrep 'c{3,}' 文件名
```
下面的例子会匹配 91-1234567890(即二个数字-十个数字) 这种格式的手机号。
```
grep "[[:digit:]]\{2\}[ -]\?[[:digit:]]\{10\}" 文件名
```
### 怎么样使 grep 命令高亮显示?
使用如下的语法:
```
grep --color 正则表达式 文件名
```
### 怎么样仅仅只显示匹配出的字符,而不是匹配出的行?
使用如下语法:
```
grep -o 正则表达式 文件名
```
### 正则表达式限定符
| 限定符 | 描述 |
| --- | --- |
| `.` | 匹配任意的一个字符。 |
| `?` | 匹配前面的子表达式,最多一次。 |
| `*` | 匹配前面的子表达式零次或多次。 |
| `+` | 匹配前面的子表达式一次或多次。 |
| `{N}` | 匹配前面的子表达式 N 次。 |
| `{N,}` | 匹配前面的子表达式 N 次到多次。 |
| `{N,M}` | 匹配前面的子表达式 N 到 M 次,至少 N 次至多 M 次。 |
| `-` | 只要不是在序列开始、结尾或者序列的结束点上,表示序列范围。 |
| `^` | 匹配一行开始的空字符串;也表示字符不在要匹配的列表中。 |
| `$` | 匹配一行末尾的空字符串。 |
| `\b` | 匹配一个单词前后的空字符串。 |
| `\B` | 匹配一个单词中间的空字符串。 |
| `\<` | 匹配单词前面的空字符串。 |
| `\>` | 匹配单词后面的空字符串。 |
#### grep 和 egrep
egrep 等同于 **grep -E** 。它会以扩展的正则表达式的模式来解释模式。下面来自 grep 的帮助页:
>
> 基本的正则表达式元字符 ?、+、 {、 |、 ( 和 ) 已经失去了它们原来的意义,要使用的话用反斜线的版本 \?、\+、\{、\|、\( 和 \) 来代替。 传统的 egrep 并不支持 { 元字符,一些 egrep 的实现是以 \{ 替代的,所以一个可移植的脚本应该避免在 grep -E 使用 { 符号,要匹配字面的 { 应该使用 [}]。
>
>
> GNU grep -E 试图支持传统的用法,如果 { 出在在无效的间隔规范字符串这前,它就会假定 { 不是特殊字符。
>
>
> 例如,grep -E '{1' 命令搜索包含 {1 两个字符的串,而不会报出正则表达式语法错误。
>
>
> POSIX.2 标准允许这种操作的扩展,但在可移植脚本文件里应该避免这样使用。
>
>
>
参考:
* grep 和 regex 帮助手册页(7)
* grep 的 info 页
---
via: <http://www.cyberciti.biz/faq/grep-regular-expressions/>
作者:Vivek Gite 译者:[runningwater](https://github.com/runningwater) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,944 | Linux 基金会引发巨大争议,它到底是企业的还是草根的? | http://www.zdnet.com/article/linux-foundation-leadership-controversy-erupts/ | 2016-01-28T08:39:00 | [
"Linux基金会"
] | https://linux.cn/article-6944-1.html |
>
> 开源界爆发了一场“Linux基金会到底是姓‘企业’还是姓‘草根’?”的争论。
>
>
>
Linux 圈一直以来争议不断,无论 [Sarah Sharp](http://www.zdnet.com/article/linux-developer-who-took-on-linus-torvalds-over-abuse-quits-toxic-kernel-community/) 愤而离开了 [Linux 内核邮件列表(LKML)](https://lkml.org/),还是 [Matthew Garrett 去单干了](http://www.zdnet.com/article/matthew-garrett-is-not-forking-linux/),往往连这些顶级开发者都深陷争议之中。甚至连 Linus Torvalds 也是以口无遮拦著称,[对看不上的代码就破口大骂](http://www.zdnet.com/article/linux-4-3-released-after-linus-torvalds-scraps-brain-damage-code/)。

而最近成为争议焦点的 <ruby> <a href="http://www.linuxfoundation.org/"> Linux 基金会 </a> <rp> ( </rp> <rt> The Linux Foundation </rt> <rp> ) </rp></ruby>不但是一个支持 Linux 的非盈利组织,而且也支持了越来越多的开源项目,比如 SDN 方面的 [OpenDaylight](https://www.opendaylight.org/)、容器方面的 <ruby> <a href="https://www.opencontainers.org/"> Open Container Initiative </a> <rp> ( </rp> <rt> 开放容器计划 </rt> <rp> ) </rp></ruby>,以及 R 语言方面的 <ruby> <a href="https://www.r-consortium.org/"> R Consortium </a> <rp> ( </rp> <rt> R 语言联盟 </rt> <rp> ) </rp></ruby>等。
[CoreOS](https://coreos.com/) 的安全开发人员 Garrett 最近披露,Linux 基金会[悄悄修改了其法律条款](/article-6916-1.html),**不再允许基金会的个人会员选举董事成员**。Garrett 写到,“Linux 基金会的董事主要是由其企业会员选出的:10个来自白金会员(年费50万美金),3个来自金牌会员(年费10万美金),1个来自银牌会员(根据公司规模不同,年费在5千到2万美金)。直到最近,个人会员(年费99美元)还能够选举两位董事成员,以在董事会层面代表社区的意见。”
为什么 Linux 基金会要这样做?Garrett 猜测是因为 Karen Sandler,她是<ruby> <a href="http://sfconservancy.org/"> 软件自由保护协会 </a> <rp> ( </rp> <rt> Software Freedom Conservancy </rt></ruby> (SFC)的执行董事,该组织[致力于非常重要的 GPL 开源许可证的执法工作](https://mjg59.dreamwidth.org/38992.html),她正在谋求[竞选 Linux 基金会的董事](https://sfconservancy.org/blog/2016/jan/17/karen-LF-candidacy/)。Garrett 说,“Linux 基金会的‘<ruby> 个人会员 <rp> ( </rp> <rt> Individual membership </rt> <rp> ) </rp></ruby>’被悄然改为‘<ruby> 个人支持者 <rp> ( </rp> <rt> Individual supporter </rt> <rp> ) </rp></ruby>’,而之前承诺的可以参选和选举董事的权利被删除了(可以比较[新版本](https://www.linuxfoundation.org/about/join/individual)和[旧版本](http://web.archive.org/web/20150321165558/https://www.linuxfoundation.org/about/join/individual))。”
Garrett 指出,“(Linux 基金会)一直以来就对 GPL 执法并不热心,而 SFC 正在[资助](https://sfconservancy.org/news/2015/mar/05/vmware-lawsuit/)一起针对其董事会成员(VMware)违反了 GPL 的诉讼。时间上也许是巧合,但是看起来像是 Linux 基金会为了避免在董事会内出现关于 GPL 方面的执法提案而扔掉了其代表了社区的伪装。”
由于 Linux 基金会主席 Jim Zemlin 前几天在中国开会,[访问互联网和收发电子邮件受限](http://www.linuxfoundation.org/news-media/blogs/browse/2016/01/linux-foundation-update),所以对这两天社区里面发生的争论没有及时回复。
Zemlin 对此反驳道:“[Linux 基金会的董事会结构没有改变过](http://www.linuxfoundation.org/news-media/blogs/browse/2016/01/linux-foundation-update)。个人仍然可以成为董事,来自企业和个人的董事比例也没有变化。我们做这件事之前经过了长期讨论,这十年来的首次改变可以为个人支持者带来更多的价值。而**招募来自社区的董事的流程会变得和业界其它的顶尖组织一样**。”
Zemlin 继续说道:“董事会投票继续留任 Larry Augustin [[SugarCRM](https://www.sugarcrm.com/) 的 CEO] 和 Bdale Garbee [[惠普企业](http://hpe.com/) 的 CTO 办公室研究员] 作为个人<ruby> 非执行董事 <rp> ( </rp> <rt> At-Large Director </rt> <rp> ) </rp></ruby> ,以表彰他们对社区的长期服务及对 Linux 基金会的个人参与。内核开发者们也会继续任命一位董事,我们欢迎并认可 Grant Likely 继续以这种身份参与进来。随着时间的推移,Linux 基金会董事会也许会从日益增长的社区增加更多的个人董事。”
他补充道:“我们知道社区政策很重要,而且当发生改变时会有不同的观点碰撞。这是正常的、健康的。但是经常在开发者社区中爆发的‘口水战’则是不健康的。不幸的是,现在发生的事情就是这样,对 Linux 基金会的这个政策改变的争论现在变成了个人的、不合适的攻击,尤其是针对我们社区中的某些成员,特别是 Karen Sandler 的攻击。”
“Karen,” Zemlin 继续说,“在她的职业生涯中致力于推动和捍卫自由软件。因为这些线上的讨论和攻击关系到了 Linux 基金会,我觉得有必要毫不含糊的指出,Linux 基金会对此绝不容忍,并随时会针对这种放任自流的网上行为作出斗争!”
我完全赞同 Zemlin 的这番反对的立场,但是我觉得 Garrett 和 Zemlin 说的不是一个事情,眼前的问题是:“Sandler 是否仍然可以竞选董事?”,我问过 Linux 基金会,但是没有得到答案。
在我看来,这场争论背后的真正的问题是,是谁在控制 Linux 基金会?是用户还是公司?
Garrett 认为 Linux 基金会正在远离社区而投入企业的怀抱。Zemlin 并没有特别谈到这个问题,但是令人注意的是,他说“招募来自社区的董事的流程会变得和业界其它的顶尖组织一样。”
此外,正如 Garrett 指出的,个人不再有“[竞选和投票支持 Linux 基金会董事会席位的能力](http://web.archive.org/web/20150321165558/https://www.linuxfoundation.org/about/join/individual),从而影响基金会的发展方向。”
就个人而言,我认为这是 Linux 基金会进一步走向了被企业控制。不过,正如俗话说的,谁请客谁买单,这也没什么好奇怪的。
开源用户喜欢“社区”这个概念,然而这十来年,“社区”已经变成了企业高管和公司雇员了。只有最理想化的开源开发者和领导者,(令人感到讽刺的是,)以及开源最热切的敌人们仍然认为 Linux 和开源项目是由个人所创建和控制的。
此外,Linux 基金会的绝大多数董事会成员都是由公司选择的。不过,对于 Linux 基金会的这个决定我看的不顺眼。Linux 始于个人项目,其迅猛发展得益于大量程序员的支持,总应该在 Linux 基金会里面有一个为个人而不是为公司说话的地方。
我希望 Sandler,这位强力、才华横溢的开源领袖,不仅能被允许参与竞选,而且能赢得董事会席位。我也希望 Linux 基金会恢复个人参选和投票董事的权利。这要求并不多,这将恢复人们对 Linux 基金会的信心,让我们觉得它并不仅仅只有大公司的位置,也有小小的个人的位置。
| 301 | Moved Permanently | null |
6,950 | grep 命令系列:使用 grep 命令来搜索多个单词 | http://www.cyberciti.biz/faq/searching-multiple-words-string-using-grep/ | 2016-01-29T08:00:00 | [
"grep"
] | https://linux.cn/article-6950-1.html | 要使用 grep 命令来搜索多个字符串或单词,我们该怎么做?例如我想要查找 /path/to/file 文件中的 word1、word2、word3 等单词,我怎么样命令 grep 查找这些单词呢?
[grep 命令支持正则表达式](/article-6941-1.html)匹配模式。要使用多单词搜索,请使用如下语法:
```
grep 'word1\|word2\|word3' /path/to/file
```
下的例子中,要在一个名叫 /var/log/messages 的文本日志文件中查找 warning、error 和 critical 这几个单词,输入:
```
$ grep 'warning\|error\|critical' /var/log/messages
```
仅仅只是要匹配单词(即该词两侧是单词分界符,针对西方以空格分隔的语言而言)的话,可以加上 -w 选项参数:
```
$ grep -w 'warning\|error\|critical' /var/log/messages
```
egrep 命令可以跳过上面的语法格式,其使用的语法格式如下:
```
$ egrep -w 'warning|error|critical' /var/log/messages
```
我建义您们加上 -i (忽略大小写) 和 --color 选项参数,如下示:
```
$ egrep -wi --color 'warning|error|critical' /var/log/messages
```
输出示例:

图一: Linux / Unix egrep 命令查找多个单词输出例子
---
via: <http://www.cyberciti.biz/faq/searching-multiple-words-string-using-grep/>
作者:Vivek Gite 译者:[runningwater](https://github.com/runningwater) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,951 | grep 命令系列:用 grep 命令统计匹配字符串的行数 | http://www.cyberciti.biz/faq/grep-count-lines-if-a-string-word-matches/ | 2016-01-29T14:02:00 | [
"grep"
] | https://linux.cn/article-6951-1.html | 在 Linux 或 UNIX 操作系统下,对于给定的单词或字符串,我们应该怎么统计它们在每个输入文件中存在的行数呢?

您需要通过添加 -c 或者 --count 选项参数来抑制正常的输出。它将会显示对输入文件单词匹配的行数,如下所示:
```
$ grep -c vivek /etc/passwd
```
或者
```
$ grep -w -c vivek /etc/passwd
```
输出的示例:
```
1
```
相反的,使用 -v 或者 --invert 选项参数可以统计出不匹配的输入文件行数,键入:
```
$ grep -c vivek /etc/passwd
```
输出的示例:
```
45
```
---
via: <http://www.cyberciti.biz/faq/grep-count-lines-if-a-string-word-matches/>
作者:Vivek Gite 译者:[runningwater](https://github.com/runningwater) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,952 | KDE 的19年进化历程 | https://tlhp.cf/kde-history/ | 2016-01-29T08:05:00 | [
"KDE"
] | /article-6952-1.html | ### 概述
KDE – 史上功能最强大的桌面环境之一;开源且可自由使用。19年前,1996年10月14日,德国程序员 Matthias Ettrich 开始了这个美观的桌面环境的开发。KDE 提供了用户界面以及其他很多日常使用的程序。今日,KDE 被成千上万人在 Unix 和 Windows 上使用。19年,一个对软件项目而言极为漫长的年岁。现在是时候让我们回到最初,看看这一切肇始于何处。

K Desktop Environment(KDE)有很多创新之处:新设计,美观,一致的体验,易于使用,对普通用户和专业用户都足够强大的应用库。“KDE”这个名字是对单词<ruby> “通用桌面环境” <rp> ( </rp> <rt> Common Desktop Environment </rt> <rp> ) </rp></ruby>玩的一个简单谐音游戏,“K”即“Cool”。 第一代 KDE 在双许可证授权下使用了 Trolltech 公司专利的 Qt framework(现 Qt 的前身),这两个许可证分别是开源的 QPL(Q public license)和<ruby> 商业专利许可证 <rp> ( </rp> <rt> proprietary commercial license </rt> <rp> ) </rp></ruby>。在2000年 Trolltech 公司让一部分 Qt 软件库开始发布在 GPL 证书下; Qt 4.5 发布在了 LGPL 2.1 许可证下。自2009起 KDE 桌面环境由三部分构成:Plasma Workspaces(用做交互界面),KDE Applications,作为 KDE Software 编译的 KDE Platform。
各发布版本
-----
### 预发布版本 – 1996年10月14日

当时名称为 Kool Desktop Environment;“Kool”这个单词在很快就被弃用了。最初,所有 KDE 的组件都是被单独发布在开发社区里的,它们并没有被一个大的项目所贯穿起来。开发组邮件列表中的首选通信是发往 [[email protected]](mailto:[email protected]) 邮件列表。
### KDE 1.0 – 1998年7月12日

这个版本受到了颇有争议的反馈。很多人反对使用 Qt 框架,因为当时的 FreeQt 许可证和自由软件许可证并不兼容,他们建议开发组使用 Motif 或者 LessTif 替代。尽管有着这些反对声,KDE 仍然被很多用户所青睐,并且成功作为第一个 Linux 发行版的环境被集成了进去。

*1999年1月28日*
有一次升级,**K Desktop Environment 1.1**,更快,更稳定的同时加入了很多小的改进。这个版本同时也加入了很多新的图标,背景和材质纹理。和这些全面翻新同时出现的还有 Torsten Rahn 绘制的全新 KDE 图标----一个放在齿轮前的字母 K ;这个图标的修改版也一直沿用至今。
### KDE 2.0 – 2000年10月23日

重大更新:
* DCOP (Desktop COmmunication Protocol),一个端到端的通信协议
* KIO,一个应用程序 I/O 库
* KParts,组件对象模型
* KHTML,一个符合 HTML 4.0 标准的渲染绘制引擎。

*2001年2月26日*
**K Desktop Environment 2.1** 首次发布了媒体播放器 noatun,它使用了模组化、插件设计。为了便利开发者,K Desktop Environment 2.1 打包了 KDevelop。

*2001年8月15日*
**KDE 2.2**版本在 GNU/Linux 上加快了50%的应用启动速度,同时提高了 HTML 渲染、JavaScript 稳定性和性能,同时还增加了一些 KMail 的功能。
### KDE 3.0 – 2002年4月3日

K Desktop Environment 3.0 加入了更好的限制使用功能,这个功能在电话亭、网咖,企业公用电脑上被广泛需求,它可以禁止用户完全使用软件的某些能力。

*2003年1月28日*
**K Desktop Environment 3.1** 加入了新的默认窗口(Keramik)和图标样式(Crystal)和其他一些改进。

*2004年2月3日*
**K Desktop Environment 3.2** 加入了诸如在网页表格、书写邮件中拼写检查的新功能;增强了邮件和日历功能。完善了 Konqueror 中的标签机制和对 Microsoft Windows 桌面共享协议(RDP)的支持。

*2004年8月19日*
**K Desktop Environment 3.3** 侧重于组合不同的桌面组件。Kontact 被放进了群件应用 Kolab 并与 Kpilot 结合。Konqueror 的加入让 KDE 有了更好的 IM 交流功能,比如支持发送文件,以及其他 IM 协议(如IRC)的支持。

*2005年3月16日*
**K Desktop Environment 3.4** 侧重于提高易用性。这次更新为 Konqueror、Kate、KPDF 加入了文字-语音转换功能;也在桌面系统中加入了独立的 KSayIt 文字-语音转换软件。

*2005年11月29日*
**The K Desktop Environment 3.5** 发布加入了 SuperKaramba,为桌面环境提供了易于安装的<ruby> 插件 <rp> ( </rp> <rt> widgets </rt> <rp> ) </rp></ruby>机制。 Konqueror 加入了广告屏蔽功能并成为了有史以来第二个通过 Acid2 CSS 测试的浏览器。
### KDE SC 4.0 – 2008年1月11日

大部分的开发投身于把最新的技术和开发框架整合进 KDE 4 当中。Plasma 和 Oxygen 是两次最大的用户界面风格变更。同时,Dolphin 替代 Konqueror 成为默认文件管理器,Okular 成为了默认文档浏览器。

*2008年7月29日*
**KDE 4.1** 引入了一个在 PIM 和 Kopete 中共享使用的表情主题系统;引入了可以让用户便利地从互联网上一键下载数据的 DXS。同时引入了 GStreamer、QuickTime 和 DirectShow 9 Phonon 后端。加入了新应用如:
* Dragon Player
* Kontact
* Skanlite — 扫描仪软件
* Step —— 物理模拟软件
* 新游戏: Kdiamond、Kollision、KBreakout 和更多......

*2009年1月27日*
**KDE 4.2** 被认为是在已经极佳的 KDE 4.1 基础上的又一次全面超越,同时也成为了大多数用户替换旧 3.5 版本的完美选择。

*2009年8月4日*
**KDE 4.3** 修复了超过10000个 bug,同时加入了让近2000个用户要求的功能。整合一些新的技术例如:PolicyKit、NetworkManage & Geolocation services 等也是这个版本的一大重点。

*2010年2月9日*
**KDE SC 4.4** 基于 Qt 4 toolkit 的 4.6 版本,加入新的应用 KAddressBook。

*2010年8月10日*
**KDE SC 4.5** 增加了一些新特性:整合了开源的浏览器引擎 WebKit 库,其现在也在 Apple Safari 和 Google Chrome 中广泛使用。KPackageKit 替换了 Kpackage。

*2011年1月26日*
**KDE SC 4.6** 加强了 OpenGl 的性能,同时照常更新了无数bug和小改进。

*2011年7月27日*
**KDE SC 4.7** 升级 KWin 以兼容 OpenGL ES 2.0 ,更新了 Qt Quick,Plasma Desktop 带来许多增强和在应用里的大量新特性, 修复了1.2万个 bug。

*2012年1月25日*
**KDE SC 4.8**: 更好的 KWin 性能与 Wayland 支持,更崭新的 Doplhin 的外观设计。

*2012年8月1日*
**KDE SC 4.9**: 向 Dolphin 文件管理器增加了一些更新,比如重新加入了实时文件重命名,鼠标辅助按钮支持,更好的位置面板和更多文件分类管理功能。

*2013年2月6日*
**KDE SC 4.10**: 很多 Plasma 插件使用 QML 重写; Nepomuk、Kontact 和 Okular 得到了很大程度的性能和功能提升。

*2013年8月14日*
**KDE SC 4.11**: Kontact 和 Nepomuk 有了很多优化。 第一代 Plasma Workspaces 进入了单纯维护阶段。

*2013年12月18日*
**KDE SC 4.12**: Kontact 得到了极大的提升,包括许多小的改进。

*2014年4月16日*
**KDE SC 4.13**: Nepomuk 语义搜索功能替代了桌面上的原有的 Baloo 搜索。 KDE SC 4.13 以53个语言版本发布。

*2014年8月20日*
**KDE SC 4.14**: 这个发布版本侧重于稳定性提升:大量的 bug 修复和增加了一些小的功能。这是最后一个 KDE SC 4 发布版本。
### KDE Plasma 5.0 – 2014年7月15日

KDE Plasma 5 – 第五代 KDE。大幅改进了设计和系统,新的默认主题 Breeze 完全迁移到了 QML,更好的 OpenGL 性能,更完美的 HiDPI (高分辨率)显示支持。

*2014年11月11日*
**KDE Plasma 5.1**:迁移了从 Plasma 4 里丢失的功能。

*2015年1月27日*
**KDE Plasma 5.2**:新组件:BlueDevil、KSSHAskPass、Muon、SDDM 主题设置、KScreen、GTK+ 样式设置和 KDecoration。

*2015年4月28日*
**KDE Plasma 5.3**:Plasma Media Center 技术预览。新的蓝牙和触摸板小程序;改良了电源管理。

*2015年8月25日*
**KDE Plasma 5.4**:Wayland 登场,新的基于 QML 的音频管理程序,一个全屏的程序启动器替代品。
万分感谢 [KDE](https://www.kde.org/) 开发者及社区,并感谢 Wikipedia 为书写 [概述](https://en.wikipedia.org/wiki/KDE_Plasma_5) 带来的帮助,同时,感谢所有读者。让我们保持自由精神(be free)并继续支持如同 KDE 一样的开源的自由软件发展。
---
via: <https://tlhp.cf/kde-history/>
作者:[Pavlo Rudyi](https://tlhp.cf/author/paul/) 译者:[jerryling315](https://github.com/jerryling315) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPSConnectionPool(host='tlhp.cf', port=443): Max retries exceeded with url: /kde-history/ (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7b83275812d0>: Failed to resolve 'tlhp.cf' ([Errno -2] Name or service not known)")) | null |
6,956 | grep 命令系列:从文件中搜索并显示文件名 | http://www.cyberciti.biz/faq/grep-from-files-and-display-the-file-name/ | 2016-01-30T14:16:00 | [
"grep"
] | https://linux.cn/article-6956-1.html | 我怎样从几个文件中搜索(grep),并只显示匹配到的文件的文件名?

当你从不止一个的文件中搜索时,默认它将显示文件名:
```
grep "word" 文件名
grep root /etc/*
```
示例输出:
```
/etc/bash.bashrc: See "man sudo_root" for details.
/etc/crontab:17 * * * * root cd / && run-parts --report /etc/cron.hourly
/etc/crontab:25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
/etc/crontab:47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
/etc/crontab:52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
/etc/group:root:x:0:
grep: /etc/gshadow: Permission denied
/etc/logrotate.conf: create 0664 root utmp
/etc/logrotate.conf: create 0660 root utmp
```
每行开始的第一个部分是文件名(如:/etc/crontab、/etc/group)。使用 -l 选项可以只显示文件名:
```
grep -l "string" filename
grep -l root /etc/*
```
示例输出:
```
/etc/aliases
/etc/arpwatch.conf
grep: /etc/at.deny: Permission denied
/etc/bash.bashrc
/etc/bash_completion
/etc/ca-certificates.conf
/etc/crontab
/etc/group
```
你也可以逆转输出;使用 -L 选项来输出**那些不匹配的文件的文件名**:
```
grep -L "word" filename
grep -L root /etc/*
```
示例输出:
```
/etc/apm
/etc/apparmor
/etc/apparmor.d
/etc/apport
/etc/apt
/etc/avahi
/etc/bash_completion.d
/etc/bindresvport.blacklist
/etc/blkid.conf
/etc/bluetooth
/etc/bogofilter.cf
/etc/bonobo-activation
/etc/brlapi.key
```
---
via: <http://www.cyberciti.biz/faq/grep-from-files-and-display-the-file-name/>
作者:Vivek Gite 译者:[wxy](https://github.com/wxy) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,957 | grep 命令系列:如何在 UNIX 中根据文件内容查找文件 | http://www.cyberciti.biz/faq/unix-linux-finding-files-by-content/ | 2016-01-30T16:21:00 | [
"grep"
] | https://linux.cn/article-6957-1.html | 为了完成课程作业,我写了很多 C 语言代码并把它们保存为 /home/user/c/\*.c 和 \*.h。那么在 UNIX shell 窗口中我如何能通过字符串或者单词(例如函数名 main())文件内容来查找文件呢?

你需要用到以下工具:
[a] **grep 命令** : 输出匹配模式的行。
[b] **find 命令**: 在目录层次中查找文件。
### [使用 grep 命令根据内容查找文件](http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/)
输入以下命令:
```
grep 'string' *.txt
grep 'main(' *.c
grep '#include<example.h>' *.c
grep 'getChar*' *.c
grep -i 'ultra' *.conf
grep -iR 'ultra' *.conf
```
其中
* **-i** : 忽略模式(匹配字符串 valid、 VALID、 ValID )和输入文件(匹配 file.c FILE.c FILE.C)的大小写。
* **-R** : 递归读取每个目录下的所有文件。
### 高亮匹配到的模式
在搜索大量文件的时候你可以轻松地高亮模式:
```
$ grep --color=auto -iR 'getChar();' *.c
```
### 为查找到的模式显示文件名和行号
你也许需要显示文件名和行号:
```
$ grep --color=auto -iRnH 'getChar();' *.c
```
其中,
* **-n** : 在输出的每行前面添加以 1 开始的行号。
* **-H** : 为每个匹配打印文件名。要搜索多个文件时这是默认选项。(LCTT 译注:-h 选项强制隐藏文件名;另外 -l 和 -L 选项用于仅显示匹配/不匹配的文件名,而 -H 和 -h用于控制在显示匹配行前显示/不显示文件名,注意区分。)
```
$grep --color=auto -nH 'DIR' *
```
输出样例:

*图 01: grep 命令显示搜索到的模式*
你也可以使用 find 命令:
```
$ find . -name "*.c" -print | xargs grep "main("
```
---
via: <http://www.cyberciti.biz/faq/unix-linux-finding-files-by-content/>
作者:Vivek Gite 译者:[ictlyh](http://mutouxiaogui.cn/blog/) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,958 | grep 命令系列:如何只查看配置文件中未被注释的有效配置行 | http://www.cyberciti.biz/faq/shell-display-uncommented-lines-only/ | 2016-01-24T10:32:00 | [
"grep"
] | https://linux.cn/article-6958-1.html | 大多数的Linux和类Unix系统的配置文件中都有许多的注释行,但是有时候我只想看其中的有效配置行。那我怎么才能只看到quid.conf或httpd.conf这样的配置文件中的非注释命令行呢?怎么去掉这些注释或者空行呢?
我们可以使用 UNIX/BSD/OS X/Linux 这些操作系统自身提供的 grep,sed,awk,perl或者其他文本处理工具来查看配置文件中的有效配置命令行。

### grep 命令示例——去掉注释
可以按照如下示例使用grep命令:
```
$ grep -v "^#" /path/to/config/file
$ grep -v "^#" /etc/apache2/apache2.conf
```
示例输出:
```
ServerRoot "/etc/apache2"
LockFile /var/lock/apache2/accept.lock
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_worker_module>
StartServers 2
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxClients 150
MaxRequestsPerChild 0
</IfModule>
<IfModule mpm_event_module>
StartServers 2
MaxClients 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestsPerChild 0
</IfModule>
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
AccessFileName .htaccess
<Files ~ "^\.ht">
Order allow,deny
Deny from all
Satisfy all
</Files>
DefaultType text/plain
HostnameLookups Off
ErrorLog /var/log/apache2/error.log
LogLevel warn
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
Include /etc/apache2/httpd.conf
Include /etc/apache2/ports.conf
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
Include /etc/apache2/conf.d/
Include /etc/apache2/sites-enabled/
```
想要跳过其中的空行,可以使用 [egrep 命令](http://www.cyberciti.biz/faq/grep-regular-expressions/), 示例:
```
egrep -v "^#|^$" /etc/apache2/apache2.conf
## or pass it to the page such as more or less ##
egrep -v "^#|^$" /etc/apache2/apache2.conf | less
## Bash function ######################################
## or create function or alias and use it as follows ##
## viewconfig /etc/squid/squid.conf ##
#######################################################
viewconfig(){
local f="$1"
[ -f "$1" ] && command egrep -v "^#|^$" "$f" || echo "Error $1 file not found."
}
```
示例输出:

*图 01: Unix/Linux Egrep 除去注释行和空行*
### 理解 grep/egrep 命令行选项
-v 选项,选择出不匹配的命令行。该选项适用于所有基于posix的系统。正则表达式 `^$` 匹配出所有的非空行, `^#` 匹配出所有的不以“#”开头的非注释行。
### sed 命令示例
可以按照如下示例使用 GNU 上的 sed 命令:
```
$ sed '/ *#/d; /^ *$/d' /path/to/file
$ sed '/ *#/d; /^ *$/d' /etc/apache2/apache2.conf
```
GNU 或 BSD 上的 sed 也可以修改配置文件。下面的命令的作用是原地编辑文件,并以特定(比如 .bak)备份文件:
```
sed -i'.bak.2015.12.27' '/ *#/d; /^ *$/d' /etc/apache2/apache2.conf
```
更多信息见参考手册 - [grep(1)](http://www.manpager.com/linux/man1/grep.1.html), [sed(1)](http://www.manpager.com/linux/man1/sed.1.html)。
---
via: <http://www.cyberciti.biz/faq/shell-display-uncommented-lines-only/>
作者:Vivek Gite 译者:[sonofelice](https://github.com/sonofelice) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,959 | 理查德·斯托曼经典语录集锦 | https://tlhp.cf/fsf-richard-stallman/ | 2016-01-30T16:06:00 | [
"RMS",
"FSF"
] | /article-6959-1.html | 
(题图来自:wikimedia)
<ruby> 理查德·马修·斯托曼 <rp> ( </rp> <rt> Richard Matthew Stallman </rt> <rp> ) </rp></ruby> (RMS) – 神级程序员之一。他是一名程序员,是 GCC、GDB、Emacs 的构建者,软件自由的传教士,[GNU Project](http://www.gnu.org/) 和 [FSF](http://www.fsf.org/) 的创办人。
**GNU** 是 “GNU’s Not Unix!”的递归缩写。GNU 是一系列用于基于 Unix 的操作系统的自由软件集合。它能用于 GNU/Hurd 和 Linux 内核。于1983年9月27日公诸于众。常用组件有:
* GNU Compiler Collection (GCC)
* GNU C library (glibc)
* GNU Core Utilities (coreutils)
* GNU Debugger (GDB)
* GNU Binary Utilities (binutils)
* GNU Bash shell
* GNOME desktop environment
<ruby> 自由软件基金会 <rp> ( </rp> <rt> Free Software Foundation </rt> <rp> ) </rp></ruby> (FSF) – 一个自由软件的非营利组织,致力于推进计算机用户的自由和捍卫他们的权力。于 1985年10月4日成立。阅读[更多](https://www.fsf.org/about/)。
许多人不理解<ruby> 开源代码 <rp> ( </rp> <rt> open source code </rt> <rp> ) </rp></ruby>和<ruby> 自由软件 <rp> ( </rp> <rt> free software </rt> <rp> ) </rp></ruby>的区别。每个程序都应该是自由软件:
* 与目的无关,随心运行程序的自由(自由0)。
* 学习程序如何运作,并改变它为你所用的自由(自由1)。可以访问源码是这一条的前提。
* 重新发布副本的自由,如此你便可以帮助你周围的人(自由 2)。
* 发布自己修改版本给他人的自由(自由 3)。这样能让整个社区有机会从你的改变中受益。可以访问源码是这条的前提。
以上为自由软件的四项自由原则。
以下为理查德·斯托曼关于自由、软件、社交、哲学等方面的名言摘引。
#### **关于 Facebook:**
>
> Facebook is not your friend, it is a surveillance engine.
>
>
>
Facebook 不是你的朋友,是监控引擎。
#### **关于 Android:**
>
> Android is very different from the GNU/Linux operating system because it contains very little of GNU. Indeed, just about the only component in common between Android and GNU/Linux is Linux, the kernel.
>
>
>
Android 和 GNU/Linux 有很大的区别,因为其中几乎没有 GNU。的确,Android 和 GNU/Linux 之间仅有一个共同组件,那就是内核 - Linux。
#### **关于计算机行业:**
>
> The computer industry is the only industry that is more fashion-driven than women's fashion.
>
>
>
计算机行业是唯一一个比女性时尚业更容易受潮流影响的行业了。(LCTT 译注:感谢 BIAOXYZ 的修正意见。)
#### **关于云计算:**
>
> The interesting thing about cloud computing is that we've redefined cloud computing to include everything that we already do.
>
>
>
关于云计算,有趣的是我们已经重新定义了云计算来包含我们曾干过的所有事。
#### **关于伦理:**
>
> Whether gods exist or not, there is no way to get absolute certainty about ethics. Without absolute certainty, what do we do? We do the best we can.
>
>
>
无论神存在与否,都没有绝对的伦理道德。没有这份理所当然,我们该如何?也唯有尽善吧。
#### **关于自由:**
>
> Free software is software that respects your freedom and the social solidarity of your community. So it's free as in freedom.
>
>
>
自由软件是尊重个人自由和社会团结的软件。所以才能如自由般自由自在。
#### **关于目标和理想:**
>
> If you want to accomplish something in the world, idealism is not enough - you need to choose a method that works to achieve the goal.
>
>
>
如果你想为这世界做些什么,仅有理想是不够的,你需要找条通往目标的道路并走完。
#### **关于分享:**
>
> Sharing is good, and with digital technology, sharing is easy.
>
>
>
分享很棒,而且数字化技术也使分享变得容易。
#### **关于 facebook(进阶版):**
>
> Facebook mistreats its users. Facebook is not your friend; it is a surveillance engine. For instance, if you browse the Web and you see a 'like' button in some page or some other site that has been displayed from Facebook. Therefore, Facebook knows that your machine visited that page.
>
>
>
Facebook 蹂躏它们的用户。它不是你们的朋友;它就是个监控引擎。举个例子,你是否曾在一些网页或网站上看到 Facebook 的 “like” 按键。对,Facebook 知道你的电脑曾访问过那些网页。
#### **关于 web 应用:**
>
> One reason you should not use web applications to do your computing is that you lose control.
>
>
>
给你个为什么不应该使用 web 应用的理由,因为你失去了计算机的控制权。
>
> If you use a proprietary program or somebody else's web server, you're defenceless. You're putty in the hands of whoever developed that software.
>
>
>
如果你使用私有程序或他人的 web 服务器,那么你只能任人鱼肉。被软件的开发者轻易操纵。
#### **关于书:**
>
> With paper printed books, you have certain freedoms. You can acquire the book anonymously by paying cash, which is the way I always buy books. I never use a credit card. I don't identify to any database when I buy books. Amazon takes away that freedom.
>
>
>
印刷出来的书,当然是自由的。你可以付现金匿名买书,这也是我一直买书的方式。我绝不会使用信用卡,我买书时不会被任何数据库记下。是亚马逊把自由夺走了。
#### **关于 MPAA:**
>
> Officially, MPAA stands for Motion Picture Association of America, but I suggest that MPAA stands for Malicious Power Attacking All.
>
>
>
MPAA 其实是<ruby> 美国电影协会 <rp> ( </rp> <rt> Motion Picture Association of America </rt> <rp> ) </rp></ruby>,但我认为叫做<ruby> 攻击万物的邪恶力量 <rp> ( </rp> <rt> Malicious Power Attacking All </rt> <rp> ) </rp></ruby>更为合适。
#### **关于金钱与职业:**
>
> I could have made money this way, and perhaps amused myself writing code. But I knew that at the end of my career, I would look back on years of building walls to divide people, and feel I had spent my life making the world a worse place.
>
>
>
我可以找份工作赚钱,并沉浸在编码的快乐中。但在职业生涯结束后,回首目睹自己筑就的高墙将人与人分隔开,我会觉得我耗尽毕生精力只换来了一个更糟糕的世界。
#### **关于私有软件:**
>
> Proprietary software keeps users divided and helpless. Divided because each user is forbidden to redistribute it to others, and helpless because the users can't change it since they don't have the source code. They can't study what it really does. So the proprietary program is a system of unjust power.
>
>
>
私有软件使用户孤立、无助。因为禁止将软件给他人使用所以孤立,因为无法改变源码所以无助。他们不能学习其中真正的工作方式,所以整个私有软件体系就是一种不公的力量。
#### **关于智能手机:**
>
> A smartphone is a computer - it's not built using a computer - the job it does is the job of being a computer. So, everything we say about computers, that the software you run should be free - you should insist on that - applies to smart phones just the same. And likewise to those tablets.
>
>
>
智能手机就是电脑 —— 虽然做的和常用的电脑不同 —— 但是却能干电脑能干的活。所以我们所说的一切有关于电脑上的软件应该能自由运行 —— 必须坚持这一点 —— 在智能手机上也是这样,当然也包括平板。
#### **关于 CD 和数字内容:**
>
> CD stores have the disadvantage of an expensive inventory, but digital bookshops would need no such thing: they could write copies at the time of sale on to memory sticks, and sell you one if you forgot your own.
>
>
>
CD 商店有一个弱势就是需要昂贵的库存,但是电子商店就没有这方面的需求:他们只需要将售卖的副本写入记忆棒,并在你忘带自己的记忆棒时卖你一个就是了。
#### **关于<ruby> 竞争范式 <rp> ( </rp> <rt> paradigm of competition </rt> <rp> ) </rp></ruby>:**
>
> The paradigm of competition is a race: by rewarding the winner, we encourage everyone to run faster. When capitalism really works this way, it does a good job; but its defenders are wrong in assuming it always works this way.
>
>
>
竞争范式就像是赛跑:奖励胜者,鼓励每一个跑得更快的人。当资本主义真的这样运作时,当然是件好事;但是维护它的人若是假设它一直这样运作的话那就大错特错了。
#### **关于 vi 和 emacs:**
>
> People sometimes ask me if it is a sin in the Church of Emacs to use vi. Using a free version of vi is not a sin; it is a penance. So happy hacking.
>
>
>
有时会有人问我在 Emacs 的阵营使用 vi 是不是一种罪过。使用自由版的 vi 并不是一种罪过;是一种自我惩罚。所以好好享受其中乐趣吧。
#### **关于自由和历史:**
>
> Value your freedom or you will lose it, teaches history. 'Don't bother us with politics', respond those who don't want to learn.
>
>
>
历史告诉我们不珍惜自由便失去自由,然而有的人不懂吸取教训,只知道说“别拿政治烦我们”。(LCTT 译注:感谢 肖岚 的修正意见。)
#### **关于专利:**
>
> Fighting patents one by one will never eliminate the danger of software patents, any more than swatting mosquitoes will eliminate malaria.
>
>
>
和专利一个一个的战斗并不能解决软件专利带来的危害,就像打再多的蚊子也消灭不了疟疾一样。
>
> Software patents are dangerous to software developers because they impose monopolies on software ideas.
>
>
>
软件专利对于软件的开发者来说十分危险,因为它们加剧了对于软件理念的垄断。
#### **关于版权:**
>
> In practice, the copyright system does a bad job of supporting authors, aside from the most popular ones. Other authors' principal interest is to be better known, so sharing their work benefits them as well as readers.
>
>
>
其实,版权制度对作者也没有什么好处,撇开最受欢迎的那个,其他作者的主旨可能更好理解,所以分享无论对他们还是你的读者都是一件好事。
#### **关于工作与报酬:**
>
> There is nothing wrong with wanting pay for work, or seeking to maximize one's income, as long as one does not use means that are destructive.
>
>
>
劳有所得,或寻求收入的最大化并没有什么错,只要不是不择手段。
#### **关于 Chrome OS:**
>
> In essence, Chrome OS is the GNU/Linux operating system. However, it is delivered without the usual applications, and rigged up to impede and discourage installing applications.
>
>
>
Chrome OS 确实是 GNU/Linux 的操作系统。但是,它在发布时没有安装常用应用,并为安装他们设置了阻碍。
#### **关于 Linux 用户:**
>
> Many users of the GNU/Linux system will not have heard the ideas of free software. They will not be aware that we have ideas, that a system exists because of ethical ideals, which were omitted from ideas associated with the term 'open source.'
>
>
>
许多的 GNU/Linux 用户并没有听过自由软件。他们并没有意识到,这个系统是因为道德理想才存在的,与此一起被忽视的还有所谓的“开源”。
#### **关于 facebook 的隐私:**
>
> If there is a Like button in a page, Facebook knows who visited that page. And it can get IP address of the computer visiting the page even if the person is not a Facebook user.
>
>
>
如果页面上有 “like” 按键,Facebook 就能知道谁访问了页面。即使不是 Facebook 的用户,也可以得到访问该页面电脑的 IP 地址。
#### **关于编程:**
>
> Programming is not a science. Programming is a craft.
>
>
>
编程不是科学,编程是手艺。
>
> My favorite programming languages are Lisp and C. However, since around 1992 I have worked mainly on free software activism, which means I am too busy to do much programming. Around 2008 I stopped doing programming projects.
>
>
>
Lisp 和 C 语言是我的最爱。然自 1992 年以来我主要工作在自由软件活动上,导致我太忙了,没法做更多的编程。大概在 2008 年我便停止了做编程项目。
>
> C++ is a badly designed and ugly language. It would be a shame to use it in Emacs.
>
>
>
C++ 设计的真糟糕、真丑陋。在 Emacs 上用它应该觉得羞愧。
#### **关于<ruby> 钻研 <rp> ( </rp> <rt> hacking </rt> <rp> ) </rp></ruby>和学习编程:**
>
> People could no longer learn hacking the way I did, by starting to work on a real operating system, making real improvements. In fact, in the 1980s I often came across newly graduated computer science majors who had never seen a real program in their lives. They had only seen toy exercises, school exercises, because every real program was a trade secret. They never had the experience of writing features for users to really use, and fixing the bugs that real users came across. The things you need to know to do real work.
>
>
>
(时过境迁,)人们没法再像我当初那样通过改进实实在在的操作系统来学习编程了。上世纪 80 年代,我常遇见计算机专业的毕业生,有生以来没见过真正的程序。他们接触的到的只有小玩意和学校的作业,因为每一个程序都是商业机密。他们没有机会为用户去写真正实用的特性,修复用户真正遭遇的问题。而这些正是真正的工作中你需要掌握的(东西)。(LCTT 译注:感谢 肖岚 的改进意见。)
>
> It is hard to write a simple definition of something as varied as hacking, but I think what these activities have in common is playfulness, cleverness, and exploration. Thus, hacking means exploring the limits of what is possible, in a spirit of playful cleverness. Activities that display playful cleverness have "hack value".
>
>
>
对于如“hacking”这般多样化的东西真的很难简单的下定义,不过在我看来诸如此类的行为都会有以下的这些共同点:嬉乐、智慧和探索。因此,hacking 意味着对可能的极限的探索,一颗向往快乐与智慧的心。能带来快乐与智慧的行为就有 “hack 的价值” 。
#### **关于浏览网页:**
>
> For personal reasons, I do not browse the web from my computer. (I also have no net connection much of the time.) To look at page I send mail to a daemon which runs wget and mails the page back to me. It is very efficient use of my time, but it is slow in real time.
>
>
>
出于个人原因,我不会在我的电脑上浏览网页。(大部分时间处于没有网络连接的状态。)要浏览网页,我需要给一个守护进程发 mail,然后它会运行 wget 并把页面通过 mail 发还给我。这对我而言已经是最效率了,但那真的比实时慢太多了。
#### **关于音乐共享:**
>
> Friends share music with each other, they don't allow themselves to be divided by a system that says that nobody is supposed to have copies.
>
>
>
朋友之间彼此分享音乐,绝不会希望因为系统的一句:“禁止私下拷贝!”而生分。
---
via: <https://tlhp.cf/fsf-richard-stallman/>
作者:[Pavlo Rudyi](https://tlhp.cf/fsf-richard-stallman/) 译者:[martin2011qi](https://github.com/martin2011qi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPSConnectionPool(host='tlhp.cf', port=443): Max retries exceeded with url: /fsf-richard-stallman/ (Caused by NameResolutionError("<urllib3.connection.HTTPSConnection object at 0x7b83275815a0>: Failed to resolve 'tlhp.cf' ([Errno -2] Name or service not known)")) | null |
6,962 | Linux/Unix 桌面趣事:终端上的圣诞树 | http://www.cyberciti.biz/open-source/command-line-hacks/linux-unix-desktop-fun-christmas-tree-for-your-terminal/ | 2016-02-01T07:47:25 | [
"桌面"
] | https://linux.cn/article-6962-1.html | 给你的Linux或Unix控制台创造一棵圣诞树玩玩吧。在此之前,需要先安装一个Perl模块,命名为Acme::POE::Tree。这是一棵很喜庆的圣诞树,我已经在Linux、OSX和类Unix系统上验证过了。

### 安装 Acme::POE::Tree
安装perl模块最简单的办法就是使用CPAN(Perl综合典藏网(Comprehensive Perl Archive Network))。打开终端,把下面的指令敲进去便可安装Acme::POE::Tree。
```
### 以root身份运行 ###
perl -MCPAN -e 'install Acme::POE::Tree'
```
**示例输出:**
```
Installing /home/vivek/perl5/man/man3/POE::NFA.3pm
Installing /home/vivek/perl5/man/man3/POE::Kernel.3pm
Installing /home/vivek/perl5/man/man3/POE::Loop.3pm
Installing /home/vivek/perl5/man/man3/POE::Resource.3pm
Installing /home/vivek/perl5/man/man3/POE::Filter::Map.3pm
Installing /home/vivek/perl5/man/man3/POE::Resource::SIDs.3pm
Installing /home/vivek/perl5/man/man3/POE::Loop::IO_Poll.3pm
Installing /home/vivek/perl5/man/man3/POE::Pipe::TwoWay.3pm
Appending installation info to /home/vivek/perl5/lib/perl5/x86_64-linux-gnu-thread-multi/perllocal.pod
RCAPUTO/POE-1.367.tar.gz
/usr/bin/make install -- OK
RCAPUTO/Acme-POE-Tree-1.022.tar.gz
Has already been unwrapped into directory /home/vivek/.cpan/build/Acme-POE-Tree-1.022-uhlZUz
RCAPUTO/Acme-POE-Tree-1.022.tar.gz
Has already been prepared
Running make for R/RC/RCAPUTO/Acme-POE-Tree-1.022.tar.gz
cp lib/Acme/POE/Tree.pm blib/lib/Acme/POE/Tree.pm
Manifying 1 pod document
RCAPUTO/Acme-POE-Tree-1.022.tar.gz
/usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/01_basic.t .. ok
All tests successful.
Files=1, Tests=2, 6 wallclock secs ( 0.09 usr 0.03 sys + 0.53 cusr 0.06 csys = 0.71 CPU)
Result: PASS
RCAPUTO/Acme-POE-Tree-1.022.tar.gz
Tests succeeded but one dependency not OK (Curses)
RCAPUTO/Acme-POE-Tree-1.022.tar.gz
[dependencies] -- NA
```
### 在Shell中显示圣诞树
只需要在终端上运行以下命令:
```
perl -MAcme::POE::Tree -e 'Acme::POE::Tree->new()->run()'
```
**示例输出**

Gif 01: 一棵用Perl写的喜庆圣诞树
### 树的定制
以下是我的脚本文件tree.pl的内容:
```
#!/usr/bin/perl
use Acme::POE::Tree;
my $tree = Acme::POE::Tree->new(
{
star_delay => 1.5, # shimmer star every 1.5 sec
light_delay => 2, # twinkle lights every 2 sec
run_for => 10, # automatically exit after 10 sec
}
);
$tree->run();
```
这样就可以通过修改star*delay、run*for和light\_delay参数的值来自定义你的树了。一棵好玩的终端圣诞树就此诞生。
---
via: <http://www.cyberciti.biz/open-source/command-line-hacks/linux-unix-desktop-fun-christmas-tree-for-your-terminal/>
作者:Vivek Gite 译者:[soooogreen](https://github.com/soooogreen) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,963 | 如何在 Mutt 邮件客户端中使用密文密码 | http://xmodulo.com/mutt-email-client-encrypted-passwords.html | 2016-02-01T08:36:00 | [
"mutt",
"邮件",
"GPG"
] | https://linux.cn/article-6963-1.html | Mutt 是一个 Linux/UNIX 终端环境下的开源的邮件客户端。Mutt 以及 [Alpine](http://xmodulo.com/gmail-command-line-linux-alpine.html) 在 Linux 命令行爱好者中有着最忠诚的追随者,这不是没有原因的。想一下你所期待邮件客户端应有的功能,Mutt 拥有:多协议支持(例如,POP3、IMAP 和 SMTP),S/MIME 和 PGP/GPG 集成,会话线索,颜色标记,可定制宏/快捷键,等等。另外,基于命令行的 Mutt 相比粗重的基于浏览器的邮件客户端(如:Gmail,Ymail)或图形用户界面的邮件客户端(如:Thunderbird,MS Outlook)而言,是一个使用电子邮件的轻量级替代品。

当你想使用 Mutt 通过公司的 SMTP/IMAP 服务器访问或发送邮件,或取代网页邮件服务,可能所关心的一个问题是如何保护您的邮件凭据(如:SMTP/IMAP 密码),它们存储在一个纯文本 Mutt 配置文件(~/.muttrc)中。
对于这些人对安全的担忧,确实有一个容易的方法来**加密 Mutt 配置文件**\*,以防止这种风险。在这个教程中,我描述了如何加密 Mutt 敏感配置,比如使用 GnuPG(GPG)加密 SMTP/IMAP 密码,GPG 是一个开源的 OpenPGP 实现。
### 第一步 (可选):创建 GPG 密钥
因为我们将要使用 GPG 加密 Mutt 配置文件,如果你没有 GPG 密钥,第一步就是创建一个(公钥/私钥对)。如果有,请忽略这步。
创建一个新 GPG 密钥,输入下面命令:
```
$ gpg --gen-key
```
选择密钥类型(RSA),密钥长度(2048 bits),和过期时间(0 代表不过期)。当出现用户 ID 提示时,输入关联到该公钥/私钥对的名字(Dan Nanni) 和邮箱地址([[email protected]](mailto:[email protected]))。最后,输入一个密码来保护你的私钥。

生成一个 GPG 密钥需要大量的随机字节来构成熵,所以在生成密钥期间确保在你的系统上执行一些随机行为(如:敲打键盘,移动鼠标或者读写磁盘)。根据密钥长度,生成 GPG 密钥要花几分钟或更多时间。

### 第二步:加密 Mutt 敏感配置
下一步,在 ~/.mutt 目录创建一个新的文本文件,然后把一些你想隐藏的 Mutt 敏感配置放进去。这个例子里,我指定了 SMTP/IMAP 密码。
```
$ mkdir ~/.mutt
$ vi ~/.mutt/password
```
---
```
set smtp_pass="XXXXXXX"
set imap_pass="XXXXXXX"
```
现在通过 GPG 使用你的公钥加密这个文件如下:
```
$ gpg -r [email protected] -e ~/.mutt/password
```
这将创建 ~/.mutt/password.gpg,这是一个原始文件的 GPG 加密版本。
然后删除 ~/.mutt/password,只保留 GPG 加密版本。
### 第三步:创建完整 Mutt 配置文件
现在你已经在一个单独的文件放置了加密的 Mutt 敏感配置,你可以在 ~/.muttrc 指定其余的 Mutt 配置。然后增加下面这行在 ~/.muttrc 末尾。
```
source "gpg -d ~/.mutt/password.gpg |"
```
当你启动 Mutt 时,这行将解密 ~/.mutt/password.gpg ,然后将解密内容应用到你的 Mutt 配置中。
下面展示一个完整 Mutt 配置例子,这可以让你通过 Mutt 访问 Gmail,而没有暴露你的 SMTP/IMAP 密码。用你的 Gmail ID 替代下面的 `yourgmailaccount`,此外你也需要在[你的 Goolgle 账户设置](https://www.google.com/settings/u/1/security)中启用“支持不太安全的应用访问”。
```
set from = "[email protected]"
set realname = "Your Name"
set smtp_url = "smtp://[email protected]:587/"
set imap_user = "[email protected]"
set folder = "imaps://imap.gmail.com:993"
set spoolfile = "+INBOX"
set postponed = "+[Google Mail]/Drafts"
set trash = "+[Google Mail]/Trash"
set header_cache =~/.mutt/cache/headers
set message_cachedir =~/.mutt/cache/bodies
set certificate_file =~/.mutt/certificates
set move = no
set imap_keepalive = 900
# encrypted IMAP/SMTP passwords
source "gpg -d ~/.mutt/password.gpg |"
```
### 第四步(可选):配置 GPG 代理
这时候,你将可以使用加密了IMAP/SMTP 密码的 Mutt。然而,每次你运行 Mutt,你都要先被提示输入一个 GPG 密码来使用你的私钥解密 IMAP/SMTP 密码。

如果你想避免这样的 GPG 密码提示,你可以部署一个 gpg-agent。它以后台守护进程方式运行,gpg-agent 可以安全地缓存你的 GPG 密码,无需手工干预,gpg 可以自动从 gpg-agent 获得你的 GPG 密码。如果你正在使用 Linux 桌面,你可以配置使用一些等同于 gpg-agent 的特定的桌面软件,例如,GNOME 桌面的 gnome-keyring-daemon。
你可以在基于 Debian 系统安装 gpg-agent:
```
$ sudo apt-get install gpg-agent
```
gpg-agent 在基于 Red Hat 的系统上是预装好的。
现在增加下面这些到你的 .bashrc 文件中。
```
envfile="$HOME/.gnupg/gpg-agent.env"
if [[ -e "$envfile" ]] && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
eval "$(cat "$envfile")"
else
eval "$(gpg-agent --daemon --allow-preset-passphrase --write-env-file "$envfile")"
fi
export GPG_AGENT_INFO
```
重载 .bashrc,或简单的登出然后重新登录。
```
$ source ~/.bashrc
```
现在确认 GPG*AGENT*INFO 环境变量已经设置妥当。
```
$ echo $GPG_AGENT_INFO
/tmp/gpg-0SKJw8/S.gpg-agent:942:1
```
并且,当你输入 gpg-agent 命令时,你应该看到下面的信息。
```
$ gpg-agent
gpg-agent: gpg-agent running and available
```
一旦 gpg-agent 启动运行,它将会在第一次提示你输入密码时缓存你的 GPG 密码。随后你多次运行 Mutt ,都不会被提示要 GPG 密码(gpg-agent 一直开着,缓存就不会过期)。

### 结论
在这个指导里,我提供一个使用 GnuPG 加密如 SMTP/IMAP 密码这样的 Mutt 敏感配置的方法。注意,如果你想在 Mutt 上使用 GnuPG 来加密或签名你的邮件,你可以参考[官方指南](http://dev.mutt.org/trac/wiki/MuttGuide/UseGPG)关于 GPG 与 Mutt 结合的部分。
如果你知道任何使用 Mutt 的安全技巧,欢迎分享它。
---
via: <http://xmodulo.com/mutt-email-client-encrypted-passwords.html>
作者:[Dan Nanni](http://xmodulo.com/author/nanni) 译者:[wyangsun](https://github.com/wyangsun) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,964 | 用丰富的256色装点你的终端 | http://avalon.gnuzifer.de/~heipei/linux/ | 2016-02-01T09:53:00 | [
"终端",
"颜色",
"命令行"
] | /article-6964-1.html | 终端并不只是黑白两色,虽然使用终端可以提高效率,但是这并不意味着我们只能面对非黑即白的界面。也许你的终端的某些应用在展示部分内容时已经使用了16色了,但是这在当今难免感觉还不够细腻。其实,很多终端,比如 xterm、urxvt,以及 Mac OSX 中的 Iterm.app 等都可以支持256色,可以在这些终端下看到更加细腻优雅的颜色表现。
这里涉及到了几个重要的程序的配置,供大家参考。注意,不是所有的终端和命令行应用都支持256色。
### vim

能够区分不同的黄色,可以让你的 vim 看起来更加漂亮。[点此下载配色文件](http://avalon.gnuzifer.de/~heipei/linux/files/configs/calmar256-dark.vim),配色文件可按如下引入到你的 vim 配置中:
```
if $TERM == "xterm" || $TERM == "rxvt" || $TERM == "xterm-256color" || $TERM == "rxvt-unicode" || &term =~ "builtin_gui" || $TERM == "dumb"
set t_Co=256
colorscheme calmar256-dark
else
colorscheme desert
endif
```
### mutt

[配色方案在此](http://avalon.gnuzifer.de/~heipei/linux/files/configs/mutt_color_256),可以通过 source 引入到你的 .muttrc 中:
```
source ~/.mutt/mutt_color_256
```
### slrn

slrn 支持256色,但是很多元素不支持颜色区分。[配色直接写在配置文件中](http://avalon.gnuzifer.de/~heipei/linux/files/configs/slrnrc)。
### git

看看 git log 的输出,是不是更柔和了?[配置文件在此](http://avalon.gnuzifer.de/~heipei/linux/files/configs/gitconfig)。
### man / less

对于 Xterm/Urxvt,改变终端的前景/背景/粗体/下划线/斜体的颜色,可以让 less 显示更好的高亮效果。而 less 被用在 man 页面显示中,所以你会发现你的 man 显示更漂亮了。[配置文件在此](http://avalon.gnuzifer.de/~heipei/linux/files/configs/Xdefaults)。
另外,可以在你的 `$LESS` 环境变量中添加 `-J` 选项,这样在搜索某个内容时,结果所在行的前面会显示一个“\*”。
### 窗口状态条
很多人喜欢在终端窗口的下方显示一个状态条,尤其是在使用 screen 将窗口分割成几个子窗口时。

[配置文件在此](http://avalon.gnuzifer.de/~heipei/linux/files/configs/screenrc)。
### ls

ls 的彩色输出也可以更好一些。[配置文件在此](http://avalon.gnuzifer.de/~heipei/linux/files/configs/dircolors)。
### grep
你可以设置 grep 以绿色显示匹配内容:
```
export GREP_COLOR='01;32' # color grep matches green
alias grep='grep --color'
```
你是不是也有一些配色方案?欢迎分享。
| null | HTTPConnectionPool(host='avalon.gnuzifer.de', port=80): Max retries exceeded with url: /~heipei/linux/ (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7b83275823b0>: Failed to resolve 'avalon.gnuzifer.de' ([Errno -2] Name or service not known)")) | null |
6,970 | 如何将 Debian Linux 中的默认的 Python 版本切换为替代版本 | http://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux | 2016-02-02T20:09:51 | [
"python"
] | https://linux.cn/article-6970-1.html | 
当你安装 Debian Linux 时,安装过程有可能同时为你提供多个可用的 Python 版本,因此系统中会存在多个 Python 的可执行二进制文件。你可以按照以下方法使用 `ls` 命令来查看你的系统中都有那些 Python 的二进制文件可供使用。
```
$ ls /usr/bin/python*
/usr/bin/python /usr/bin/python2 /usr/bin/python2.7 /usr/bin/python3 /usr/bin/python3.4 /usr/bin/python3.4m /usr/bin/python3m
```
执行如下命令查看默认的 Python 版本信息:
```
$ python --version
Python 2.7.8
```
### 1、基于用户修改 Python 版本:
想要为某个特定用户修改 Python 版本,只需要在其 home 目录下创建一个 `alias`(别名) 即可。打开该用户的 `~/.bashrc` 文件,添加新的别名信息来修改默认使用的 Python 版本。
```
alias python='/usr/bin/python3.4'
```
一旦完成以上操作,重新登录或者重新加载 `.bashrc` 文件,使操作生效。
```
$ . ~/.bashrc
```
检查当前的 Python 版本。
```
$ python --version
Python 3.4.2
```
### 2、 在系统级修改 Python 版本
我们可以使用 `update-alternatives` 来为整个系统更改 Python 版本。以 root 身份登录,首先罗列出所有可用的 python 替代版本信息:
```
# update-alternatives --list python
update-alternatives: error: no alternatives for python
```
如果出现以上所示的错误信息,则表示 Python 的替代版本尚未被 `update-alternatives` 命令识别。想解决这个问题,我们需要更新一下替代列表,将 `python2.7` 和 `python3.4` 放入其中。
```
# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode
# update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2
update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode
```
`--install` 选项使用了多个参数用于创建符号链接。最后一个参数指定了此选项的优先级,如果我们没有手动来设置替代选项,那么具有最高优先级的选项就会被选中。这个例子中,我们为 `/usr/bin/python3.4` 设置的优先级为2,所以 `update-alternatives` 命令会自动将它设置为默认 Python 版本。
```
# python --version
Python 3.4.2
```
接下来,我们再次列出可用的 Python 替代版本。
```
# update-alternatives --list python
/usr/bin/python2.7
/usr/bin/python3.4
```
现在开始,我们就可以使用下方的命令随时在列出的 Python 替代版本中任意切换了。
```
# update-alternatives --config python
```

```
# python --version
Python 2.7.8
```
### 3、移除替代版本
一旦我们的系统中不再存在某个 Python 的替代版本时,我们可以将其从 `update-alternatives` 列表中删除掉。例如,我们可以将列表中的 python2.7 版本移除掉。
```
# update-alternatives --remove python /usr/bin/python2.7
update-alternatives: removing manually selected alternative - switching python to auto mode
update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode
```
---
via: <http://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux>
译者:[mr-ping](https://github.com/mr-ping) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,971 | 10大白帽黑客专用的 Linux 操作系统 | http://www.picateshackz.com/2015/05/top-15-advanced-operating-systems-for.html | 2016-02-03T08:05:00 | [
"黑客",
"渗透测试",
"发行版"
] | https://linux.cn/article-6971-1.html | 
今天让我们来介绍十个黑客专用的操作系统,它们被白帽黑客用作渗透测试的工具。这里我把 Kali Linux 列为首位,是因为它在渗透测试中非常流行,它的开发团队 Offensive security 同时也是开发 BackTrack 的团队。我们没有列出 BackTrack ,是因为在它的官方站点上已经无法下载了,它已经被 Kali Linux 所取代了。这里列出的操作系统都是基于 Linux 内核的,它们全都是自由的操作系统。
推荐你阅读一下我之前的一篇文章,可以深入了解下与黑客、安全相关的 Linux 发行版:[给黑客或安全人员使用的 Linux 发行版: Kali、Tails 和 Qubes](http://picateshackz.com/2015/04/linux-powerful-distros-for-hacking-or.html)。
### 1. Kali Linux

Kali Linux 是一个 Debian 衍生发行版,设计用于数字取证和渗透测试。它是由 Offensive Security 公司开发和维护的,该公司的 Mati Aharoni 和 Devon Kearns 对 BackTrack 进行了重写,从而开发了全新的 Kali Linux 。它是最灵活、最先进的渗透测试发行版。Kali 会不断更新其上的工具。它支持许多不同的平台,包括 VMware 和 ARM 等。如果你想了解更多关于 Kali Linux 的信息,推荐你阅读我之前的文章:[黑客级操作系统 Kali Linux 的介绍与安装指引](http://picateshackz.com/2015/01/an-introduction-to-hackers-os-kali.html)。
**[点此直达下载地址。](https://www.kali.org/downloads/)**
### 2. BackBox

它包括了一些经常使用的安全和分析工具,可以用于从 web 应用分析到网络分析,从压力测试到嗅探,以及脆弱性分析、计算机取证分析和破解等等的各种用途。
这个发行版的一大特点是,它的 Launchpad 软件库会持续更新各种工具的最新稳定版,它们都是白帽黑客所熟知常用的。该发行版中的新工具集成和开发遵循了开源社区的标准,特别是 <ruby> Debian 自由软件指导 <rp> ( </rp> <rt> Debian Free Software Guidelines </rt> <rp> ) </rp></ruby>的标准。
**[点此直达下载地址。](http://www.backbox.org/downloads)**
### 3. Parrot Security os

Parrot Security 是一个基于 Debian GNU/Linux 的发行版,并混以 Frozenbox OS 和 Kali linux 的部分特性,以提供最好的渗透和安全测试体验。它是由 Frozenbox Dev Team 开发的。
Parrot 采用 Kali 的软件库来更新大部分工具,不过也有提供其自己的定制软件的软件库。这也是为何它不只是一个简单的 Kali 修改版,而是一个建立在 Kali 工具库之上的新系统,因此,它引入了许多新功能和不同的开发选择。Parrot 使用 MATE 作为桌面环境,这是一个轻量级的、高效的 Gnome 2 家族的衍生品。还有来自 FrozenBox 的高度定制的迷人的图标、特制的主题和墙纸。系统外观是由该社区的成员以及关注该项目进展的 Frozenbox Network 的成员建议并设计的。
**[点此直达下载地址。](http://www.parrotsec.org/download.fx)**
### 4. deft

deft 是一个 Ubuntu 定制版,带有一整套由数以千计的个人、团队和公司所创建的计算机取证程序和文档。它们每一个都可能采用了不同的许可证,它的许可证策略决定了哪些软件会被放到 deft 中和默认放到它的安装光盘中。
**[点此直达下载地址。](http://www.deftlinux.net/download/)**
### 5. Samurai Web 测试框架

Samurai Web 测试框架是一个<ruby> 即用 <rp> ( </rp> <rt> live </rt> <rp> ) </rp></ruby> Linux 环境,它已经预配置好了 Web 渗透测试环境。这个即用 CD 中包含了最好的针对网站渗透测试和攻击的开源工具。在开发这个环境时,基于我们在安全方面的经验而选择的工具,可以用于 web 渗透测试的四个阶段。
**[点此直达下载地址。](http://sourceforge.net/projects/samurai/files/)**
### 6. 网络安全工具包 (NST)

网络安全工具包(NST)是一个可引导的<ruby> 即用 <rp> ( </rp> <rt> live </rt> <rp> ) </rp></ruby> CD ,基于 Fedora Core。这个工具包设计用来便于访问最棒的开源网络安全应用,主要运行在 x86 平台上。开发这个网络安全工具包的主要目的是为网络安全管理人员提供一套完备的开源网络安全工具。
NST 最神奇的地方是可以将大多数 x86 机器(奔腾2及以上)转换成一台可以用于网络流量分析、入侵检测、网络数据包生成、无线网络监控的虚拟服务器,当然它也可以当做一套复杂的网络/主机扫描器来使用。
**[点此直达下载地址。](http://sourceforge.net/projects/nst/)**
### 7. Bugtraq

Bugtraq 系统是一个很全面的发行版,包括了优化后的、稳定的实时自动服务管理器。该发行版基于 Linux 内核 3.2 和 3.4,支持 32 位和 64 位。Bugtraq 的一大亮点是其放在不同分类中的大量工具,你可以找到移动取证工具、恶意软件测试实验室、Bugtraq 资讯工具、GSM 审计工具,支持无线、蓝牙和 RFID 等,集成了 Windows 工具,以及各种典型的渗透测试和取证工具。
**[点此直达下载地址。](http://bugtraq-team.com/downloads)**
### 8. NodeZero

老话说需求是发明之母,NodeZero Linux 就是这句话的最好例证。这个开发团队是由渗透测试人员和开发人员构成的,他们发现“<ruby> 即用 <rp> ( </rp> <rt> live </rt> <rp> ) </rp></ruby>”系统并不能真正满足他们在安全审计方面的所需。渗透测试发行版一般都是以 Linux “即用”系统方式提供的,这意味着他们并不能对系统做一些永久性的改变。从光盘或 USB 棒中启动运行后,在重启后所有的改变就都丢失了。这对于偶尔的测试也许很有用,但是对于经常性的测试就没什么用了,并不适合需要大量测试的环境。
虽然 NodeZero Linux 可以当做“<ruby> 即用系统 <rp> ( </rp> <rt> Live System </rt> <rp> ) </rp></ruby>”偶尔使用,但是它真正的力量来自于那些需要强有力测试系统的测试人员的需求。它通过持久安装、精选的强大工具、集成于稳定的 Linux 环境来满足了上述需求。
**[点此直达下载地址。](http://www.nodezero-linux.org/downloads)**
### 9. Pentoo

Pentoo 是一个用于渗透测试和安全评估的即用 CD 和 USB。它基于 Gentoo Linux ,提供了 32 位和 64 位的即用 CD 。Pentoo 也可以覆盖安装到现有的 Gentoo 环境中。它提供了特色的带有包注入补丁的 WIFI 驱动,GPGPU 破解软件,以及许多渗透测试和安全评估的软件。Pentoo 内核带有 grsecurity 和 PAX 加固补丁,其提供的二进制是由加固工具链编译而成的,其中一些工具还有最新的每日构建版本。
**[点此直达下载地址。](http://www.pentoo.ch/download/)**
### 10. Cyborg Hawk

迄今以来,最先进的、强大而美观的渗透测试发行版。收集了最完备的工具,可供专业的白帽黑客和网络安全专家使用。它带有700 个以上的工具,而 Kali 仅带了300 多个。这其中包括了移动安全工具和恶意软件分析工具。之所以放到最后是因为笔者并没有测试过它。
Cyborg Hawk 是 Team Cybord 开发的,该组织由来自 Ztrela Knowledge Solutions 的 Vaibhav Singh 和 Shahnawaz Alam 所领导。
**[点此直达下载地址。](http://sourceforge.net/projects/cyborghawk1/files/latest/download)**
| 302 | Found | null |
6,975 | Linux 容器技术史话:从 chroot 到未来 | https://dzone.com/articles/evolution-of-linux-containers-future | 2016-02-04T08:38:00 | [
"容器",
"docker"
] | https://linux.cn/article-6975-1.html | 
Linux 容器是一个在单一 Linux 主机上提供多个隔离的 Linux 环境的[操作系统级虚拟](https://en.wikipedia.org/wiki/Operating-system-level_virtualization#IMPLEMENTATIONS)技术。不像虚拟机(VM),容器并不需要运行专用的<ruby> 访客 <rp> ( </rp> <rt> guest </rt> <rp> ) </rp></ruby>操作系统。容器们共享<ruby> 宿主机的 <rp> ( </rp> <rt> host </rt> <rp> ) </rp></ruby>操作系统内核,并使用访客操作系统的系统库来提供所需的功能。由于不需要专用的操作系统,因此容器要比虚拟器启动快得多。

(图片来自: Docker Inc.)
容器借助 Linux 内核的 Namespaces、Apparmor、SELinux <ruby> 情景模式 <rp> ( </rp> <rt> profile </rt> <rp> ) </rp></ruby>、chroot 和 CGroup 等功能来提供类似于虚拟机的隔离环境。Linux 的安全模块可以确保正确地控制容器对宿主机和内核的访问,从而避免各种入侵活动。此外,在宿主机上可以运行不同的 Linux 发行版,只要它们运行在同样的 CPU 架构下。
简单来说,容器提供的是一种基于各种 Linux 发行版创建容器镜像的方法、一套管理容器生命周期的 API、与该 API 交互的客户端工具、保存快照的功能、在宿主机之间迁移容器实例的能力,等等。
### 容器历史
以下是容器简史,内容来自维基百科及其它来源:
#### 1979 — chroot
容器的概念始于 1979 年的 UNIX [chroot](https://en.wikipedia.org/wiki/Chroot),它是一个 UNIX 操作系统上的系统调用,用于将一个进程及其子进程的根目录改变到文件系统中的一个新位置,让这些进程只能访问到该目录。这个功能的想法是为每个进程提供独立的磁盘空间。其后在 1982年,它被加入到了 BSD 系统中。
#### 2000 — FreeBSD Jails
[FreeBSD Jails](https://en.wikipedia.org/wiki/FreeBSD_jail) 是最早的容器技术之一,它由 R&D Associates 公司的 Derrick T. Woolworth 在 2000 年为 FreeBSD 引入。这是一个类似 chroot 的操作系统级的系统调用,但是为文件系统、用户、网络等的隔离增加了进程沙盒功能。因此,它可以为每个 jail 指定 IP 地址、可以对软件的安装和配置进行定制,等等。
#### 2001 — Linux VServer
[Linux VServer](https://en.wikipedia.org/wiki/Linux-VServer) 是另外一种 jail 机制,它用于对计算机系统上的资源(如文件系统、CPU 处理时间、网络地址和内存等)进行安全地划分。每个所划分的分区叫做一个<ruby> 安全上下文 <rp> ( </rp> <rt> security context </rt> <rp> ) </rp></ruby>,在其中的虚拟系统叫做<ruby> 虚拟私有服务器 <rp> ( </rp> <rt> virtual private server,VPS </rt> <rp> ) </rp></ruby>。
#### 2004 — Solaris Containers
[Solaris Containers](https://en.wikipedia.org/wiki/Solaris_Containers) 支持在 x86 和 SPARC 系统,首次出现在 2004 年 2 月发布的 Solaris 10 的 build 51 beta 上,其后完整发布在 2005 年的 Solaris 10 上。 Solaris Container 是由系统资源控制和通过 zones 提供的<ruby> 边界分离 <rp> ( </rp> <rt> boundary separation </rt> <rp> ) </rp></ruby>所组合而成的。zones 是一个单一操作系统实例中的完全隔离的虚拟服务器。
#### 2005 — OpenVZ
[OpenVZ](https://en.wikipedia.org/wiki/OpenVZ) 类似于 Solaris Containers,它通过对 Linux 内核进行补丁来提供虚拟化、隔离、资源管理和<ruby> 状态检查 <rp> ( </rp> <rt> checkpointing </rt> <rp> ) </rp></ruby>。每个 OpenVZ 容器都有一套隔离的文件系统、用户及用户组、进程树、网络、设备和 IPC 对象。
#### 2006 — Process Containers
[Process Containers](https://en.wikipedia.org/wiki/Cgroups) 是由 Google 在 2006 年实现的,用于对一组进程进行限制、记账、隔离资源使用(CPU、内存、磁盘 I/O、网络等)。后来为了避免和 Linux 内核上下文中的“容器”一词混淆而改名为 Control Groups。它被合并到了 2.6.24 内核中。这表明 Google 很早就参与了容器技术的开发,以及它们是如何回馈到社区的。
#### 2007 — Control Groups
如上面所述,Control Groups (即 cgroups)是由 Google 实现的,并于 2007 年加到了 Linux 内核中。
#### 2008 — LXC
[LXC](https://en.wikipedia.org/wiki/LXC) 的意思是 LinuX Containers,它是第一个最完善的 Linux 容器管理器的实现方案,是通过 cgroups 和 Linux <ruby> 名字空间 <rp> ( </rp> <rt> namespace </rt> <rp> ) </rp></ruby>实现的。LXC 存在于 liblxc 库中,提供了各种编程语言的 API 实现,包括 Python3、Python2、Lua、Go、Ruby 和 Haskell。与其它容器技术不同的是, LXC 可以工作在普通的 Linux 内核上,而不需要增加补丁。现在 [LXC project](https://linuxcontainers.org/lxc/introduction/) 是由 Canonical 公司赞助并托管的。
#### 2011 — Warden
[Warden](https://docs.cloudfoundry.org/concepts/architecture/warden.html) 是由 CloudFoundry 在 2011 年开发的,开始阶段是使用的 LXC,之后替换为他们自己的实现方案。不像 LXC,Warden 并不紧密耦合到 Linux 上,而是可以工作在任何可以提供隔离环境的操作系统上。它以后台守护进程的方式运行,为容器管理提供了 API。请参考 [Warden 文档](https://docs.cloudfoundry.org/concepts/architecture/warden.html)和[这个博客文章](http://blog.altoros.com/cloud-foundry-containers-warden-docker-garden.html)了解更多。
#### 2013 — LMCTFY
[lmctfy](https://github.com/google/lmctfy) 的意思是“<ruby> 让我为你包含 <rp> ( </rp> <rt> Let Me Contain That For You </rt> <rp> ) </rp></ruby>”。这是一个 Google 容器技术的开源版本,提供 Linux 应用容器。Google 启动这个项目旨在提供性能可保证的、高资源利用率的、资源共享的、可超售的、接近零消耗的容器(参考自:[lmctfy 演讲稿](http://www.linuxplumbersconf.org/2013/ocw//system/presentations/1239/original/lmctfy%20(1).pdf))。现在为 Kubernetes 所用的 cAdvisor 工具就是从 lmctfy 项目的成果开始的。lmctfy 首次发布于 2013 年10月,在 2015 年 Google 决定贡献核心的 lmctfy 概念,并抽象成 libcontainer,因此,lmctfy 现在已经没有活跃的开发了。
lincontainer 项目最初由 [Docker](https://github.com/docker/libcontainer) 发起,现在已经被移交给了<ruby> <a href="https://github.com/opencontainers/runc/tree/master/libcontainer"> 开放容器基金会 </a> <rp> ( </rp> <rt> Open Container Foundation </rt> <rp> ) </rp></ruby>。
#### 2013 — Docker
[Docker](https://en.wikipedia.org/wiki/Docker_(software)) 是到现在为止最流行和使用广泛的容器管理系统。它最初是一个叫做 dotCloud 的 PaaS 服务公司的内部项目,后来该公司改名为 Docker。类似 Warden,Docker 开始阶段使用的也是 LXC ,之后采用自己开发的 libcontainer 替代了它。不像其它的容器平台,Docker 引入了一整个管理容器的生态系统,这包括高效、分层的容器镜像模型、全局和本地的容器注册库、清晰的 REST API、命令行等等。稍后的阶段, Docker 推动实现了一个叫做 Docker Swarm 的容器集群管理方案。
#### 2014 — Rocket
[Rocket](https://coreos.com/blog/rocket/) 是由 CoreOS 所启动的项目,非常类似于 Docker,但是修复了一些 Docker 中发现的问题。CoreOS 说他们的目的是提供一个比 Docker 更严格的安全性和产品需求。更重要的是,它是在一个更加开放的标准 App Container 规范上实现的。在 Rocket 之外,CoreOS 也开发了其它几个可以用于 Docker 和 Kubernetes的容器相关的产品,如:[CoreOS 操作系统](https://en.wikipedia.org/wiki/CoreOS)、[etcd](https://coreos.com/etcd/) 和 [flannel](https://github.com/coreos/flannel)。
#### 2016 — Windows Containers
微软 2015 年也在 Windows Server 上为基于 Windows 的应用添加了容器支持,它称之为 [Windows Containers](https://msdn.microsoft.com/en-us/virtualization/windowscontainers/about/about_overview)。它与 Windows Server 2016 一同发布。通过该实现, Docker 可以原生地在 Windows 上运行 Docker 容器,而不需要启动一个虚拟机来运行 Docker( Windows 上早期运行 Docker 需要使用 Linux 虚拟机)。
### 容器的未来
截止到今天(2016年1月),在行业内有一个显著趋势,部署软件应用从虚拟机逐渐移到了容器。其主要的原因是容器相比于虚拟机而言更加灵活和低消耗。Google 已经使用容器技术好多年了,它在 [Borg 和 Omega](http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/43438.pdf) 容器集群管理平台上可以成规模地运行 Google 应用。更重要的是,Google 为容器领域贡献了 cgroups 的实现和参与了 libcontainer 项目。Google 也在过去这些年借助容器在性能、资源利用和整体效率方面取得了巨大收益。最近,一直没有操作系统级的虚拟化技术的微软,也在 Window Server 上迅速采取动作实现了对容器的原生支持。
Docker 、Rocket 以及其它的容器平台并不能以一个单一主机运行在产品环境中,原因是这样面临着单点故障。当一组容器运行在一个单一宿主机时,如果宿主机失效,所有运行在该宿主机上的容器也会失效。要避免这个问题,应该使用容器宿主机集群。Google 借助其在 Borg 中取得的经验,开发了一个叫做 [Kubernetes](http://kubernetes.io/) 的开源容器集群管理系统。Docker 也启动了一个叫做 [Docker Swarm](https://docs.docker.com/swarm/) 的解决方案。目前这些解决方案还都处于相当早期的阶段,也许需要几个月或来年才实现完整的功能集合,才能变得稳定,从而广泛应用于行业内的产品环境中。
<ruby> <a href="http://martinfowler.com/articles/microservices.html"> 微服务 </a> <rp> ( </rp> <rt> Microservices </rt> <rp> ) </rp></ruby>是另一个突破性技术,在软件架构上可以将容器用于部署。微服务并不是一个新东西,只是一个相比标准的 Web 服务超快的轻量级 Web 服务。这是通过将功能单元(也许是一个单一服务或 API 方法)打包到一个服务中,并内嵌其到一个轻量级 Web 服务器软件中实现的。
通过对上面的介绍,我们可以预测接下来几年,容器也许会替代虚拟机,某些情况下也许会全部取代。去年我为一些企业在 POC 层面上实现了基于容器的解决方案。也有人想要在产品环境中尝试它们,这一天也许在容器集群管理系统进一步成熟后很快到来。
| 200 | OK | # The Evolution of Linux Containers and Their Future
### A history of containerization technology starting in 1979, and what the future holds for Docker and similar technologies.
Join the DZone community and get the full member experience.
[Join For Free](/static/registration.html)
Linux containers are an [operating system level virtualization](https://en.wikipedia.org/wiki/Operating-system-level_virtualization#IMPLEMENTATIONS) technology for providing multiple isolated Linux environments on a single Linux host. Unlike virtual machines (VMs), containers do not run dedicated guest operating systems. Rather, they share the host operating system kernel and make use of the guest operating system system libraries for providing the required OS capabilities. Since there is no dedicated operating system, containers start much faster than VMs.
*Image credit: Docker Inc.*
Containers make use of Linux kernel features such as Namespaces, Apparmor, SELinux profiles, chroot, and CGroups for providing an isolated environment similar to VMs. Linux security modules guarantee that access to the host machine and the kernel from the containers is properly managed to avoid any intrusion activities. In addition containers can run different Linux distributions from its host operating system if both operating systems can run on the same CPU architecture.
In general, containers provide a means of creating container images based on various Linux distributions, an API for managing the lifecycle of the containers, client tools for interacting with the API, features to take snapshots, migrating container instances from one container host to another, etc.
## Container History
Below is a short summary of container history extracted from Wikipedia and [other sources](http://pivotal.io/platform/infographic/moments-in-container-history):
### 1979 — chroot
The concept of containers was started way back in 1979 with UNIX [chroot](https://en.wikipedia.org/wiki/Chroot). It’s an UNIX operating-system system call for changing the root directory of a process and it's children to a new location in the filesystem which is only visible to a given process. The idea of this feature is to provide an isolated disk space for each process. Later in 1982 this was added to BSD.
### 2000 — FreeBSD Jails
[FreeBSD Jails](https://en.wikipedia.org/wiki/FreeBSD_jail) is one of the early container technologies introduced by Derrick T. Woolworth at R&D Associates for FreeBSD in year 2000. It is an operating-system system call similar to chroot, but included additional process sandboxing features for isolating the filesystem, users, networking, etc. As a result it could provide means of assigning an IP address for each jail, custom software installations and configurations, etc.
### 2001 — Linux VServer
[Linux VServer](https://en.wikipedia.org/wiki/Linux-VServer) is a another jail mechanism that can be used to securely partition resources on a computer system (file system, CPU time, network addresses and memory). Each partition is called a security context, and the virtualized system within it is called a virtual private server.
### 2004 — Solaris Containers
[Solaris Containers](https://en.wikipedia.org/wiki/Solaris_Containers) were introduced for x86 and SPARC systems, first released publicly in February 2004 in build 51 beta of Solaris 10, and subsequently in the first full release of Solaris 10, 2005. A Solaris Container is a combination of system resource controls and the boundary separation provided by zones. Zones act as completely isolated virtual servers within a single operating system instance.
### 2005 — OpenVZ
[OpenVZ](https://en.wikipedia.org/wiki/OpenVZ) is similar to Solaris Containers and makes use of a patched Linux kernel for providing virtualization, isolation, resource management, and checkpointing. Each OpenVZ container would have an isolated file system, users and user groups, a process tree, network, devices, and IPC objects.
### 2006 — Process Containers
[Process Containers](https://en.wikipedia.org/wiki/Cgroups) was implemented at Google in year 2006 for limiting, accounting, and isolating resource usage (CPU, memory, disk I/O, network, etc.) of a collection of processes. Later on it was renamed to Control Groups to avoid the confusion multiple meanings of the term “container” in the Linux kernel context and merged to the Linux kernel 2.6.24. This shows how early Google was involved in container technology and how they have contributed back.
### 2007 — Control Groups
As explained above, Control Groups AKA cgroups was implemented by Google and added to the Linux Kernel in 2007.
### 2008 — LXC
[LXC](https://en.wikipedia.org/wiki/LXC) stands for LinuX Containers and it is the first, most complete implementation of Linux container manager. It was implemented using cgroups and Linux namespaces. LXC was delivered in liblxc library and provided language bindings for the API in Python3, Python2, Lua, Go, Ruby, and Haskell. Contrast to other container technologies LXC works on vanila Linux kernel without requiring any patches. Today [LXC project](https://linuxcontainers.org/lxc/introduction/) is sponsored by Canonical Ltd. and hosted here.
### 2011 — Warden
[Warden](https://docs.cloudfoundry.org/concepts/architecture/warden.html) was implemented by CloudFoundry in year 2011 by using LXC at the initial stage and later on replaced with their own implementation. Unlike LXC, Warden is not tightly coupled to Linux. Rather, it can work on any operating system that can provide ways of isolating environments. It runs as a daemon and provides an API for managing the containers. Refer to [Warden documentation](https://docs.cloudfoundry.org/concepts/architecture/warden.html) and [this blog post](http://blog.altoros.com/cloud-foundry-containers-warden-docker-garden.html) for more detailed information on Warden.
### 2013 — LMCTFY
[lmctfy](https://github.com/google/lmctfy) stands for “Let Me Contain That For You”. It is the open source version of Google’s container stack, which provides Linux application containers. Google started this project with the intention of providing guaranteed performance, high resource utilization, shared resources, over-commitment, and near zero overhead with containers (Ref: [lmctfy presentation](http://www.linuxplumbersconf.org/2013/ocw//system/presentations/1239/original/lmctfy%20(1).pdf)). The cAdvisor tool used by Kubernetes today was started as a result of lmctfy project. The initial release of lmctfy was made in Oct 2013 and in year 2015 Google has decided to contribute core lmctfy concepts and abstractions to libcontainer. As a result now no active development is done in LMCTFY.
The libcontainer project was initially started by [Docker](https://github.com/docker/libcontainer) and now it has been moved to [Open Container Foundation](https://github.com/opencontainers/runc/tree/master/libcontainer).
### 2013 — Docker
[Docker](https://en.wikipedia.org/wiki/Docker_(software)) is the most popular and widely used container management system as of January 2016. It was developed as an internal project at a platform-as-a-service company called dotCloud and later renamed to Docker. Similar to Warden, Docker also used LXC at the initial stages and later replaced LXC with it’s own library called libcontainer. Unlike any other container platform, Docker introduced an entire ecosystem for managing containers. This includes a highly efficient, layered container image model, a global and local container registries, a clean REST API, a CLI, etc. At a later stage, Docker also took an initiative to implement a container cluster management solution called Docker Swarm.
### 2014 — Rocket
[Rocket](https://coreos.com/blog/rocket/) is a much similar initiative to Docker started by CoreOS for fixing some of the drawbacks they found in Docker. CoreOS has mentioned that their aim is to provide more rigorous security and production requirements than Docker. More importantly, it is implemented on App Container specifications to be a more open standard. In addition to Rocket, CoreOS also develops several other container related products used by Docker and Kubernetes: [CoreOS Operating System](https://en.wikipedia.org/wiki/CoreOS), [etcd](https://coreos.com/etcd/), and [flannel](https://github.com/coreos/flannel).
### 2016 — Windows Containers
Microsoft also took an initiative to add container support to the Microsoft Windows Server operating system in 2015 for Windows based applications, called [Windows Containers](https://msdn.microsoft.com/en-us/virtualization/windowscontainers/about/about_overview). This is to be released with Microsoft Windows Server 2016. With this implementation Docker would be able to run Docker containers on Windows natively without having to run a virtual machine to run Docker (earlier Docker ran on Windows using a Linux VM).
## The Future of Containers
As of today (Jan 2016) there is a significant trend in the industry to move towards containers from VMs for deploying software applications. The main reasons for this are the flexibility and low cost that containers provide compared to VMs. Google has used container technology for many years with [Borg and Omega](http://static.googleusercontent.com/media/research.google.com/en//pubs/archive/43438.pdf) container cluster management platforms for running Google applications at scale. More importantly, Google has contributed to container space by implementing cgroups and participating in libcontainer projects. Google may have gained a huge gain in performance, resource utilization, and overall efficiency using containers during past years. Very recently Microsoft, who did not had an operating system level virtualization on the Windows platform took immediate action to implement native support for containers on Windows Server.
Docker, Rocket, and other container platforms cannot run on a single host in a production environment, the reason is that they are exposed to single point of failure. While a collection of containers are run on a single host, if the host fails, all the containers that run on that host will also fail. To avoid this, a container host cluster needs to be used. One of the first most open source container cluster management platforms to solve this problem was [Apache Mesos](https://en.wikipedia.org/wiki/Apache_Mesos). It was initially developed at University of California, Berkeley as a research project and later moved to Apache in around year 2012. Google took a similar step to implement a cutting edge, open source container cluster management system called [Kubernetes](http://kubernetes.io/) in year 2014 with the experience they got from Borg. Docker also started a solution called [Docker Swarm](https://docs.docker.com/swarm/) in year 2015. Today these solutions are at their very early stages and it may take several months and may be another year to complete their full feature set, become stable and widely used in the industry in production environments.
[Microservices](http://martinfowler.com/articles/microservices.html) are another groundbreaking technology rather a software architecture which uses containers for their deployment. A microservice is nothing new but a lightweight implementation of a web service which can start extremely fast compared to a standard web service. This is done by packaging a unit of functionality (may be a single service/API method) in one service and embedding it into a lightweight web server binary.
By considering the above facts we can predict that in next few years, containers may take over virtual machines, and sometimes might replace them completely. Last year I worked with a handful of enterprises on implementing container-based solutions on a POC level. There were few who wanted to take the challenge and put them in production. This may change very quickly as the container cluster management systems get more mature.
Opinions expressed by DZone contributors are their own.
Comments |
6,981 | 通过修改 glibc 支持 DNS 加密 | https://lwn.net/Articles/664776/ | 2016-02-06T08:43:00 | [
"dnssec",
"glibc",
"DNS"
] | https://linux.cn/article-6981-1.html | 域名解析系统(DNS)是互联网安全的许多薄弱环节之一;可以将应用程序所访问的主机对应的 IP 地址误导到其它地方。也就是说,会连接到错误的位置,从而引发<ruby> 中间人 <rp> ( </rp> <rt> man-in-the-middle </rt> <rp> ) </rp></ruby>攻击等等。而 [DNSSEC](https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions) 扩展协议则通过为 DNS 信息建立一条加密的可信通道来解决这个漏洞。在正确地配置好 DNSSEC 后,应用程序将可以得到可靠的主机查询信息。通过关于[尝试将 DNSSEC 更好地集成到 GNU C 库里](http://lwn.net/Articles/664790/)的讨论,我们知道,确保 DNS 查询信息安全这件事并不是那么简单。

从某种意义上来说,这个问题多年以前就解决了,我们可以配置一个本地域名服务实现完整的 DNSSEC <ruby> 校验 <rp> ( </rp> <rt> verification </rt> <rp> ) </rp></ruby>并允许应用程序通过 glibc 函数来使用该服务。DNSSEC 甚至还可以用于提高其他领域的安全性,比如,它可以携带 SSH 或 TLS 密钥指纹,让应用程序可以确认其在与正确的服务器对话。不过,当我们希望确认这条自称带有 DNSSEC 校验的 DNS 结果是不是真的已通过认证的时候 - 也就是说,当我们想依赖 DNSSEC 所承诺的安全的时候,事情变得有点复杂。
### /etc/resolv.conf 问题
从 glibc 的角度来看,这个问题一部分是因为 glibc 本身并没有做 DNSSEC 校验,而是引用 /etc/resolv.conf 文件,从该文件里读出的服务器来做解析以及校验,再将结果返回给应用程序。如果应用程序使用底层 res\_query() 接口,那结果中将会包含“<ruby> 已认证数据 <rp> ( </rp> <rt> authenticated data </rt> <rp> ) </rp></ruby>”(AD)标识(如果域名服务器设定了的话)以表示 DNSSEC 校验已经成功。但是 glibc 却完全不知道提供这些结果的域名服务器的信用,所以它其实并不能告诉应用程序结果是否真的可靠。
由 glibc 的维护者 Carlos O'Donell 提出的建议是在 resolv.conf 文件里增加一个选项(dns-strip-dnssec-ad-bit)告诉 glibc 无条件移除 AD 标识。这个选项可以由各发行版设定,表示 DNSSEC 级别的 DNS 查询结果并不可靠。而一旦建立好合适的环境可以获得可靠的查询结果后,再移除这个选项。这样一来,虽然问题还没有完全解决,至少应用程序有依据来评价从 glibc 获取的 DNS 查询结果的可靠性。
一个可靠的环境配置应该是什么样?标准情况应该和这个差不太多:有一个本地域名服务器,通过<ruby> 环路 <rp> ( </rp> <rt> loopback </rt> <rp> ) </rp></ruby>接口访问,作为访问 /etc/resolv.conf 文件的唯一条目。这个域名服务器应该配置来做校验,而在校验失败后就只是简单地不返回任何结果。绝大多数情况下,应用程序就不再需要关心 AD 标识,如果结果不可靠,应用程序就根本看不到。一些发行版已经倾向于这种模型,不过情况仍然不像一些人所设想的那么简单。
其中一个问题是,这种方式将 /etc/resolv.conf 文件放到整个系统可信任度的中心。但是,在一个典型的 Linux 系统里,有无数的 DHCP 客户端、网络脚本以及其他更多的程序可以修改这个文件。就像 Paul Wouters 所[指出](http://lwn.net/Articles/664794/)的,在短时间内锁定这个文件是不可能的。有时候这种修改是必须的:在一个无盘系统启动的时候,在自身的域名服务器启动之前也是需要域名服务的;一个系统的整个 DNS 环境也会根据所连接的网络不同而有所改变;运行在容器里的系统也最好是配置成使用宿主机的域名服务器;等等。
所以,现在一般认为,现有系统里的 /etc/resolv.conf 文件并不可信。于是有人提出增加另一个配置文件(/etc/secure-resolv.conf 或其他什么),但这并没有从根本上解决问题。除此之外,有些参与者觉得就算有一个运行在环路接口上的域名服务器也不是真正可靠,比如 Zack Weinberg 甚至[建议](http://lwn.net/Articles/664782/)系统管理员可以有意禁用 DNSSEC <ruby> 确认 <rp> ( </rp> <rt> validation </rt> <rp> ) </rp></ruby>。
既然当前系统里的配置不足以信任,那可以这样推断,在情况有改善能够取得可信的结果后,glibc 需要有一种方式来通知应用程序。可以是上面讨论的屏蔽 AD 标识的方式(或者与之相反,增加一个显示的“此域名服务器可以信任”选项);当然,这都需要一定程度上锁定系统以免 /etc/resolv.conf 受到任何不可预计的修改。按 Petr Spacek 的[建议](http://lwn.net/Articles/664784/),还有一种引申方式,就是提供一种途径允许应用程序查询 glibc 当前通讯的是不是本地域名服务器。
### 在 glibc 里来处理?
另一种方式是不管域名服务器,而是让 glibc 本身来做 DNSSEC 确认。不过,把这么大一坨加密相关代码放进 glibc 也是有很大阻力。这样将增加库本身的大小,从而感觉会增加使用它的应用程序的受攻击可能性。这个方向再引申一下,由 Zack 提出的[建议](http://lwn.net/Articles/664796/),可以把确认相关代码放到域名服务缓冲守护进程(nscd)里。因为 nscd 也是 glibc 的一部分,由 glibc 开发人员维护,因此在一定程度上可以相信能正确执行 DNSSEC 确认。而且 nscd 的通讯 socket 所在位置也是公开的,所以可以不考虑 /etc/resolv.conf 问题。不过,Carlos [担心](http://lwn.net/Articles/664786/)这种方式不能让那些不想使用 nscd 缓存功能的用户所接受;在他看来,基本可以排除 nscd 的方式。
所以,至少近期内,glibc 不太可能全部执行 DNSSEC 确认了的整个查询过程。这意味着,如果一个有安全考虑的应用要使用 glibc 库来查询域名,该库将需要提供一个标识来评价从独立域名服务器返回的结果有多大程度的可靠性。这几乎肯定需要发行版或系统管理员做出一些明确的改动。就像 Simo Sorce [说的](http://lwn.net/Articles/664787/)那样:
>
> 如果 glibc 不使用明确的配置选项来通知应用程序它所用的域名解析是可信的,不会有什么用……不改一下还有很大弊端,因为应用程序开发者将马上认识到他们不能信任从 glibc 获取的任何信息,从而在处理 DNSSEC 相关信息时就简单地不用它。
>
>
>
要配置一个系统能正常使用 DNSSEC 需要改动该系统的很多组件 - 这是一个发行版范围的问题,需要时间来完全解决。在这个转变过程中 glibc 所扮演的角色很可能会比较小,但是很重要的一部分:如果应用程序不实现一套自己的域名解析代码,glibc 很可能是保证 DNS 结果可信的唯一方式。在一个系统中运行多个 DNSSEC 实现方式看起来不像是一种安全的方式,所以最好还是把事情做对了。
glibc 项目目前并没有确定用哪种方式来做这个事情,虽然从 /etc/resolv.conf 文件里的某些标记看上去快好了。这种改动应该需要发布新版本;考虑到 glibc 开发的保守天性,很可能来不及加入预计二月份发布的 2.23 版本了。所以 glibc 中暂时还不会有更高安全性的 DNSSEC ,不过在这个方向上也有一些进展了。
---
via: <https://lwn.net/Articles/664776/>
作者:Jonathan Corbet 译者:[zpl1025](https://github.com/zpl1025) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | # Supporting secure DNS in glibc
One of the many weak links in Internet security is the domain name system (DNS); it is subject to attacks that, among other things, can mislead applications regarding the IP address of a system they wish to connect to. That, in turn, can cause connections to go to the wrong place, facilitating man-in-the-middle attacks and more. TheWe're bad at marketingWe can admit it, marketing is not our strong suit. Our strength is writing the kind of articles that developers, administrators, and free-software supporters depend on to know what is going on in the Linux world. Please
[subscribe today]to help us keep doing that, and so we don’t have to get good at marketing.
[DNSSEC](https://en.wikipedia.org/wiki/Domain_Name_System_Security_Extensions)protocol extensions are meant to address this threat by setting up a cryptographically secure chain of trust for DNS information. When DNSSEC is set up properly, applications should be able to trust the results of domain lookups. As the discussion over
[an attempt to better integrate DNSSEC into the GNU C Library](/Articles/664790/)shows, though, ensuring that DNS lookups are safe is still not a straightforward problem.
In a sense, the problem was solved years ago; one can configure a local nameserver to perform full DNSSEC verification and use that server via glibc calls in applications. DNSSEC can even be used to increase security in other areas; it can, for example, carry SSH or TLS key fingerprints, allowing applications to verify that they are talking to the right server. Things get tricky, though, when one wants to be sure that DNS results claiming to have DNSSEC verification are actually what they claim to be — when one wants the security that DNSSEC is meant to provide, in other words.
#### The /etc/resolv.conf problem
Part of the problem, from the glibc perspective, is that glibc itself does
not do
DNSSEC verification. Instead, it consults `/etc/resolv.conf` and
asks the servers found therein to do the lookup and verification;
the results are then returned to
the application. If the application is using the low-level
`res_query()` interface, those results may include the
"authenticated data" (AD) flag (if the nameserver has set it) indicating
that DNSSEC verification has been
successfully performed. But glibc knows nothing about the trustworthiness
of the nameserver that has provided those results, so it cannot tell the
application anything about whether they should really be trusted.
One of the first steps suggested by glibc maintainer Carlos O'Donell is to
add an option (`dns-strip-dnssec-ad-bit`) to the
`resolv.conf` file telling glibc to unconditionally remove the AD
bit. This option could be set by distributions to indicate that the DNS
lookup results cannot be trusted at a DNSSEC level. Once things have been
set up so that the results *can* be trusted, that option can be
removed. In the meantime, though, applications would have a way to judge
the DNS lookup results they get from glibc, something that does not exist
now.
What would a trustworthy setup look like? The standard picture looks
something like this: there is a local nameserver, accessed via the loopback
interface, as the only entry in `/etc/resolv.conf`. That nameserver
would be configured to do verification and, in the case that verification
fails, simply return no results at all. There would, in almost all cases,
be no need to worry about whether applications see the AD bit or not; if
the results are not trustworthy, applications will simply not see them at
all. A number of distributions are moving toward this model, but the
situation is still not as simple as some might think.
One problem is that this scheme makes `/etc/resolv.conf` into a
central point of trust for the system. But, in a typical Linux system,
there are no end of DHCP clients, networking scripts, and more that will
make changes to that file. As Paul Wouters [pointed out](/Articles/664794/), locking down this file in the
short term is not really an option. Sometimes those changes are necessary:
when a
diskless system is booting, it may need name-resolution service before it
is at a point where it can start up its own nameserver. A system's entire
DNS environment may change depending on which network it is attached to.
Systems in containers may be best configured to talk to a nameserver on the
host. And so on.
So there seems to be a general belief that `/etc/resolv.conf` cannot
really be trusted on current systems. Ideas to add secondary configuration
files
(`/etc/secure-resolv.conf` or whatever) have been floated, but they
don't much change the basic nature of the situation. Beyond that, some
participants felt that even a local nameserver running on the loopback
interface is not really trustworthy; Zack Weinberg [suggested](/Articles/664782/) that administrators might
intentionally short out DNSSEC validation, for example.
Since the configuration cannot be trusted on current systems, the reasoning
goes, glibc needs to have a way to indicate to applications when the
situation has improved and things
*can* be trusted. That could include the AD-stripping option
described above (or, conversely, an explicit "this nameserver is trusted"
option); that, of course, would require that the system be locked down
to a level where surprising changes to `/etc/resolv.conf` no longer
happen. A variant, as [suggested](/Articles/664784/) by Petr
Spacek, is to have a way for an application to ask glibc whether it is
talking to a local nameserver or not.
#### Do it in glibc?
An alternative would be to dispense with the nameserver and have glibc do
DNSSEC validation itself. There is, however, resistance to putting a big
pile of cryptographic code into glibc itself. That would increase the size
of the library and, it is felt, increase the attack surface of any
application using it. A variant of this idea, [suggested](/Articles/664796/) by Zack, would be to put the
validation code into the name-service caching daemon (`nscd`)
instead. Since `nscd` is part of glibc, it is under the control of
the glibc developers and there could be a certain amount of confidence that
DNSSEC validation is being performed properly. The location of the
`nscd` socket is well known, so the `/etc/resolv.conf` issues
don't come into play. Carlos [worried](/Articles/664786/),
though, that this approach might deter adoption by users who do not want
the caching features of `nscd`; in his mind, that seems to rule out
the `nscd` option.
So, in the short term, at least, it seems unlikely that glibc will take on the
full task of performing validated DNSSEC lookups. That means that, if
security-conscious applications are going to use glibc for their name
lookups, the library will have to provide an indication of how trustworthy
the results received from a separate nameserver are. And that will almost
certainly require explicit action on
the part of the distributor and/or system administrator. As Simo Sorce [put it](/Articles/664787/):
Configuring a system to properly use DNSSEC involves change to many of the components of that system — it is a distribution-wide problem that will take time to solve fully. The role that glibc plays in this transition is likely to be relatively small, but it is an important one: glibc is probably the only place where applications can receive some assurance that their DNS results are trustworthy without implementing their own resolver code. Running multiple DNSSEC implementations on a system seems like an unlikely path to greater security, so it would be good to get this right.
The glibc project has not yet chosen a path by which it intends to get
things right, though some sort of annotation in `/etc/resolv.conf`
looks like a likely outcome. Any such change would then have to get into
a release; given the conservative nature of glibc development, it may
already be late for the 2.23 release, which is likely to happen in
February. So higher DNSSEC awareness in glibc may not happen right away,
but there is at least some movement in that direction.
Index entries for this article | |
---|---|
|
[DNSSEC](/Security/Index/#DNSSEC) Posted Nov 18, 2015 23:05 UTC (Wed)
by
Posted Nov 19, 2015 1:41 UTC (Thu)
by
The issue here is playing nice with non-glibc resolvers, like c-ares, adns, and the untold number of similar resolvers floating around. Not to mention non-systemd DHCP clients and other code that manipulates /etc/resolv.conf directly.
The resolved approach also effectively moves the real query code outside the library and into the local [systemd] resolver. But per the article glibc wasn't prepared to always assume the local resolver to be trusted, presumably reasoning that trusting unrelated processes is not something they're prepared to do. Obviously this not reasoning that systemd folk would agree with. But the underlying judgments relate to stances on portability, standards conformance (POSIX, historical, etc), forwards and backwards compatibility, and ultimately where the real interface boundaries should be. Which is basically the whole systemd debate in a nut shell. And perhaps why systemd has felt compelled (rightly or wrongly, for better or worse) to buildup an entire parallel ecosystem of infrastructure software--DNS, NTP, DHCP, etc.
Posted Nov 20, 2015 8:27 UTC (Fri)
by Oh, PLEASE don't take away my resolv.conf—I (ab)use it by adding some 0.0.0.0 entries to get ad.doubleclick.net (and some others) to STFU when web-browsing.
Posted Nov 20, 2015 8:43 UTC (Fri)
by
Note that there is also nsswitch.conf, which governs sources and their order. /etc/hosts is "files" source, while resolv.conf is used by for example "dns" source.
Posted Nov 21, 2015 5:06 UTC (Sat)
by I stand corrected. Not sure what I was thinking when I typed that... :-\
Posted Nov 20, 2015 20:51 UTC (Fri)
by
Posted Nov 20, 2015 21:36 UTC (Fri)
by
In practice I've found that things filtering on source/destination host pairs (NoScript, RequestPolicy, Policeman, uMatrix) are good enough 90% of the time, and closer to 99% if you add content type to the filter. In Chromium-based browsers there's even a special fast path for this specific use case.
Having said that, I also took the malware/spam hosts lists in uMatrix and converted them to empty BIND zones for my LAN. A bit of defence in depth can't hurt.
Posted Nov 23, 2015 2:55 UTC (Mon)
by
I have an SSID on my home network especially for Android devices on which the DNS server handed out by DHCP is a local Unbound server configured with a hosts file style blacklist. It does a great job killing both in-browser and in-app ads.
Posted Dec 3, 2015 1:16 UTC (Thu)
by
I've yet to see a convincing reason why hooking at the NSS level (like libnss-resolve does) is any better than speaking the DNS protocol directly (like unbound would do). There's a straightforward respect in which it's worse, thouggh: the unbound approach works with all the non-glibc third-party asynchronous resolvers.
(Of course, both approaches will want some way to signal to apps that the local resolver is validating, but I think they're on equal footing there in that neither one actually succeeds without library and API changes.)
Posted Dec 3, 2015 6:46 UTC (Thu)
by
Posted Dec 3, 2015 17:56 UTC (Thu)
by
It's a pretty dire situation when an average Linux desktop has more ways of looking up a hostname than graphical toolkits installed.
I wish someone would come along and do for gethostbyname() what sqlite did for fopen() - a library that doesn't suck and offers *no* excuses for not using it.
Posted Nov 19, 2015 10:50 UTC (Thu)
by
If you want secure DNS, the administrator needs to set up the system with a trustworthy resolv.conf. If you can't trust the admin to do that, how can you fix that at the application level?
Posted Nov 19, 2015 15:05 UTC (Thu)
by
Posted Nov 19, 2015 15:26 UTC (Thu)
by
This is why you want a validating resolver on your own machine.
Posted Nov 20, 2015 2:51 UTC (Fri)
by
... or a VPN back to base which has trusted DNS servers. This has the bonus of working for all your users without having to maintain multiple funky resolvers. Either method will work - I do both for myself but my staff (who generally wouldn't know what a resolver is) get a (Open)VPN which forces all traffic via base.
Posted Nov 19, 2015 14:58 UTC (Thu)
by
Posted Nov 20, 2015 7:44 UTC (Fri)
by
Posted Nov 24, 2015 20:03 UTC (Tue)
by
Nevertheless, Snowden did give the IETF a wake-up call and work is proceeding. There is the excellent RFC 7626 by Stephane Bortzmeyer which covers the problem space:
As far as actual standards work, there is DPRIVE, the DNS Privacy working group, which was chartered recently to tackle some of these issues. Current work focuses on moving DNS over TLS or the UDP variant thereof (DTLS). It's not enough, but we are adding more tools to protect against pervasive monitoring via DNS. Sadly a 30 year old protocol is hard to update....
Posted Nov 19, 2015 18:44 UTC (Thu)
by
Posted Nov 19, 2015 19:52 UTC (Thu)
by
Posted Nov 19, 2015 19:58 UTC (Thu)
by
Posted Nov 19, 2015 23:47 UTC (Thu)
by
Posted Nov 20, 2015 3:46 UTC (Fri)
by
I think that HTTP[S] tunneling should only solve the problem of filtering middleboxes and DNSSEC should be used for everything else.
Posted Nov 20, 2015 3:51 UTC (Fri)
by Ah, sounds like you also might be interested in
Posted Nov 19, 2015 21:42 UTC (Thu)
by
I think Cyberax suggested using HTTPS to get authentication, but that draft seems to only talk about using SSL to get privacy.
I don't think HTTPS is the best choice for authentication though made it is so widely used that it is OK.
Would it make sense to put a public key in resolv.conf and configure your trusted DNS server (whether on localhost or in the machine room or whatever) to sign all verified responses with the matching public key?
Then a relatively small amount of crypto code in glibc could verify local responses.
Posted Nov 19, 2015 23:44 UTC (Thu)
by draft-ietf-dprive-dns-over-tls-01 specifies two different usage profiles in section 4, "Opportunistic Privacy Profile" and "Pre-Deployed Profile". The pre-deployed profile requires that the server be authenticated. The short answer is: There have been a few attempts at adding non-TLS crypto privacy to stub lookups, e.g. There are a few IETF-standardized DNS extensions that allow crypto authentication for lookups, TSIG and SIG(0). But these are rarely used (the big problem is key distribution) and don't provide privacy. (TSIG is probably more familiar to people as a mechanism used to protect DNS zone transfers.)
Posted Nov 20, 2015 3:44 UTC (Fri)
by
And then trusted DNS information can be used by other layers.
Posted Nov 20, 2015 22:16 UTC (Fri)
by
Posted Nov 21, 2015 5:40 UTC (Sat)
by
Posted Nov 19, 2015 23:09 UTC (Thu)
by
Hi,
I have a few brief comments.
It looks like these two proposals come down to implementing what the DNSSEC RFCs
call a "Non-Validating Security-Aware Stub Resolver" (the first proposal
described in the article) and a "Validating Security-Aware Stub Resolver" (the
second proposal). Here are the definitions from RFC 4033:
[
][
]## Supporting secure DNS in glibc
**josh** (subscriber, #17465)
[[Link](/Articles/664908/)] (10 responses)
[
]## Supporting secure DNS in glibc
**wahern** (subscriber, #37304)
[[Link](/Articles/664921/)] (6 responses)
[
]## Supporting secure DNS in glibc
**pr1268** (subscriber, #24648)
[[Link](/Articles/665136/)] (5 responses)
it just defines it away by obsoleting /etc/resolv.conf, or at least making it read-only and always pointing to 127.0.0.1.
[
]## Supporting secure DNS in glibc
**zdzichu** (subscriber, #17118)
[[Link](/Articles/665138/)] (1 responses)
[
]## Supporting secure DNS in glibc
**pr1268** (subscriber, #24648)
[[Link](/Articles/665361/)]
You put this in resolv.conf, not in /etc/hosts? Are you sure?
[
]## Supporting secure DNS in glibc
**josh** (subscriber, #17465)
[[Link](/Articles/665286/)] (2 responses)
[
]## Supporting secure DNS in glibc
**flussence** (guest, #85566)
[[Link](/Articles/665287/)]
[
]## Supporting secure DNS in glibc
**edmonds42** (guest, #42670)
[[Link](/Articles/665498/)]
[
]## Supporting secure DNS in glibc
**luto** (subscriber, #39314)
[[Link](/Articles/666632/)] (2 responses)
[
]## Supporting secure DNS in glibc
**Cyberax** (**✭ supporter ✭**, #52523)
[[Link](/Articles/666665/)]
[
]## Supporting secure DNS in glibc
**flussence** (guest, #85566)
[[Link](/Articles/666770/)]
[
]## Supporting secure DNS in glibc
**runekock** (subscriber, #50229)
[[Link](/Articles/664955/)] (3 responses)
[
]## Supporting secure DNS in glibc
**smoogen** (subscriber, #97)
[[Link](/Articles/664983/)] (2 responses)
[
]## Supporting secure DNS in glibc
**anselm** (subscriber, #2796)
[[Link](/Articles/664985/)] (1 responses)
[
]## Supporting secure DNS in glibc
**gerdesj** (subscriber, #5446)
[[Link](/Articles/665111/)]
[
]## "Secure" DNS?
**civodul** (guest, #58311)
[[Link](/Articles/664982/)] (2 responses)
[https://gnunet.org/mcb](https://gnunet.org/mcb) . The "secure" label may give people a wrong sense of security.
[
]## "Secure" DNS?
**kleptog** (subscriber, #1183)
[[Link](/Articles/665132/)]
[
]## "Secure" DNS?
**shane** (subscriber, #3335)
[[Link](/Articles/665723/)]
[https://www.rfc-editor.org/info/rfc7626](https://www.rfc-editor.org/info/rfc7626)
[
]## Supporting secure DNS in glibc
**Cyberax** (**✭ supporter ✭**, #52523)
[[Link](/Articles/665064/)] (10 responses)
[
]## Supporting secure DNS in glibc
**cstrotm** (subscriber, #55963)
[[Link](/Articles/665070/)] (7 responses)
[
]## Supporting secure DNS in glibc
**Cyberax** (**✭ supporter ✭**, #52523)
[[Link](/Articles/665071/)] (3 responses)
[
]## Supporting secure DNS in glibc
**edmonds42** (guest, #42670)
[[Link](/Articles/665101/)] (2 responses)
[draft-hoffman-dprive-dns-tls-https](https://tools.ietf.org/html/draft-hoffman-dprive-dns-tls-https-00) is probably the draft you're looking for, then.
[
]## Supporting secure DNS in glibc
**Cyberax** (**✭ supporter ✭**, #52523)
[[Link](/Articles/665115/)] (1 responses)
[
]## Supporting secure DNS in glibc
**edmonds42** (guest, #42670)
[[Link](/Articles/665116/)]
[draft-ietf-dnsop-dnssec-roadblock-avoidance](https://datatracker.ietf.org/doc/draft-ietf-dnsop-dnssec-roadblock-avoidance/?include_text=1), then.
[
]## Supporting secure DNS in glibc
**neilbrown** (subscriber, #359)
[[Link](/Articles/665083/)] (2 responses)
[
]## Supporting secure DNS in glibc
**edmonds42** (guest, #42670)
[[Link](/Articles/665096/)]
*I think Cyberax suggested using HTTPS to get authentication, but that draft seems to only talk about using SSL to get privacy.**Would it make sense to put a public key in resolv.conf and configure your trusted DNS server (whether on localhost or in the machine room or whatever) to sign all verified responses with the matching public key?**Then a relatively small amount of crypto code in glibc could verify local responses.*[don't design your own cryptosystem, it will look bad when cryptographers review it](https://mailarchive.ietf.org/arch/msg/dns-privacy/P9kHBNpPFmPbMHzfOI-JpVfEDuc).[DNSCrypt](https://dnscrypt.org/), [draft-wijngaards-dnsop-confidentialdns](https://tools.ietf.org/html/draft-wijngaards-dnsop-confidentialdns-03), and [draft-krecicki-dprive-dnsenc](https://tools.ietf.org/html/draft-krecicki-dprive-dnsenc-01). Probably the most successful of those so far is DNSCrypt (e.g., see OpenDNS's deployment), but even that one relies on a local proxy daemon.[
]## Supporting secure DNS in glibc
**Cyberax** (**✭ supporter ✭**, #52523)
[[Link](/Articles/665114/)]
[
]## Supporting secure DNS in glibc
**imMute** (guest, #96323)
[[Link](/Articles/665304/)] (1 responses)
[
]## Supporting secure DNS in glibc
**Cyberax** (**✭ supporter ✭**, #52523)
[[Link](/Articles/665366/)]
[
]## Supporting secure DNS in glibc
**edmonds42** (guest, #42670)
[[Link](/Articles/665055/)]
Non-Validating Security-Aware Stub Resolver: A security-aware stub
resolver that trusts one or more security-aware recursive name
servers to perform most of the tasks discussed in this document
set on its behalf. In particular, a non-validating security-aware
stub resolver is an entity that sends DNS queries, receives DNS
responses, and is capable of establishing an appropriately secured
channel to a security-aware recursive name server that will
provide these services on behalf of the security-aware stub
resolver. See also security-aware stub resolver, validating
security-aware stub resolver.
Non-Validating Stub Resolver: A less tedious term for a
non-validating security-aware stub resolver.
[...]
Validating Security-Aware Stub Resolver: A security-aware resolver
that sends queries in recursive mode but that performs signature
validation on its own rather than just blindly trusting an
upstream security-aware recursive name server. See also
security-aware stub resolver, non-validating security-aware stub
resolver.
Validating Stub Resolver: A less tedious term for a validating
security-aware stub resolver.
The first definition refers to "an appropriately secured channel", which is further mentioned in RFC 4035:
4.9.3. Handling of the AD Bit A non-validating security-aware stub resolver MAY chose to examine the setting of the AD bit in response messages that it receives in order to determine whether the security-aware recursive name server that sent the response claims to have cryptographically verified the data in the Answer and Authority sections of the response message. Note, however, that the responses received by a security-aware stub resolver are heavily dependent on the local policy of the security-aware recursive name server. Therefore, there may be little practical value in checking the status of the AD bit, except perhaps as a debugging aid. In any case, a security-aware stub resolver MUST NOT place any reliance on signature validation allegedly performed on its behalf, except when the security-aware stub resolver obtained the data in question from a trusted security-aware recursive name server via a secure channel. A validating security-aware stub resolver SHOULD NOT examine the setting of the AD bit in response messages, as, by definition, the stub resolver performs its own signature validation regardless of the setting of the AD bit.
The RFCs generally treat the "stub resolver" and applications that rely on the
stub resolver as separate components that communicate via an interface, and this
is true enough if you are using high-level interfaces like
`getaddrinfo()`, but in practice on GNU/Linux and *BSD systems this
abstraction becomes very leaky when you want to do anything other than an
address lookup (A/AAAA). On Linux systems, the DNS "stub resolver" consists of
the `res_*()` functions and related `ns_*()` and `dn_*()`
helper functions, which are provided by a separate library `libresolv`,
which is shipped by glibc.
glibc's `libresolv` is very old. As near as I've been able to track down,
it's a cut down version of the "`libbind`" stub resolver that was
included with CSRG BSD, BIND 4, BIND 8, and BIND 9 (up until BIND 9.6.0, when it
was removed). glibc first(?) imported this code from BIND 4.9.1 in May 1993,
and periodically synchronized with the upstream codebase until the last update
from BIND 8.2.3-T5B in July 2000, at which point it continued to evolve
independently in glibc. This is why if you execute `libc.so.6` glibc will
print out `BIND-8.2.3-T5B` as an "available extension". (The upstream
codebase is still kicking around; ISC split it out into a standalone "libbind"
distribution when it was removed from BIND 9.6.0, and it was later adopted from
ISC by the NetBSD project a few years ago where it was renamed to "netresolv".)
(A digression: parts of the `nss_dns` code in glibc, which interfaces
`libresolv` to the glibc Name Service Switch, is similarly old and
descended from CSRG on stone tablets. This code in its modern glibc form is not
easy to read; to take a cherry-picked example,
[
this 2007 commit
](https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=2f1687b96b25af512b095c9ebfa283f63c13bb78;hp=a15ccd8f07d7afbbd7635f350e318ede84709ac6)
[
[corresponding bug report BZ#4381]
](https://sourceware.org/bugzilla/show_bug.cgi?id=4381)
introduced a vulnerability which was later fixed in
[
this 2015 commit,
](https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=2959eda9272a03386;hp=7bf8fb104226407b75103b95525364c4667c869f)
[
[corresponding bug report BZ#18287]
](https://sourceware.org/bugzilla/show_bug.cgi?id=18287)
resulting in CVE-2015-1781, which could have been exploited remotely by
malformed DNS response packets under certain conditions. If you're a moderately
skilled C programmer who only rarely ventures into the glibc codebase, your
reaction to reading these diffs will probably be similar to
[this fellow](http://i.imgur.com/E3ui9OC.gif), or perhaps [this one](http://i.imgur.com/B9NGjSn.gif). This code is seriously hard
to read.
Fortunately, it appears this bug wasn't likely to be exploitable in practice, at
least in instances of calling code which were audited. According to Florian
Weimer, then of Red Hat Product Security: "This can only happen if these
functions are called with a misaligned buffer. I looked at quite a bit of source
code, and tested applications with a patched glibc that logs misaligned buffers.
I did not observe any such misaligned buffers.")
The `res_*` interface is not very fun to use. The result returned by the
`res_query()`, `res_search()`, and `res_send()` functions
is a bare DNS protocol wire-format message which must be parsed by the
application. `libresolv` offers a number of `ns_*()` functions
(`ns_initparse()`, `ns_parserr()`, etc.) that don't quite amount
to a parser, but are rather a collection of helper functions that can be used to
construct a parser. The `ns_*()` functions aren't fully documented on
GNU or even BSD systems, though; the best API reference available is probably
contained in chapter 15 of the O'Reilly "DNS and BIND" book.
[Here](https://github.com/farsightsec/wrapsrv/blob/tags/v1.0.0/wrapsrv.c#L235-L262)
is a trivial example I wrote of using this interface to parse a DNS `SRV`
response. Note how the caller is responsible for checking that the resource
record is well-formed and for knowing the precise layout of the data fields
within the `SRV` resource record. In practice, the `ns_*()`
functions tend to be avoided by applications that use the `res_*()`
interface to perform lookups. A good example is the Postfix
MTA, which uses the `res_*()` functions to send a query, but implements
its own wire-format message parser. [Debian Code Search](https://codesearch.debian.net/) finds only [34
packages with ns_parserr references](https://codesearch.debian.net/perpackage-results/ns_parserr/2/page_0), though not all of these
instances are actual users of the interface.
Taking the Postfix example, Postfix together with `libresolv`
participate jointly in the parsing of the DNS message, and in particular Postfix
examines the AD bit, which arguably puts that application code within the
boundary of what the DNSSEC RFCs call the "non-validating security-aware stub
resolver". RFC 4035 specifically says, "In any case, a security-aware stub
resolver MUST NOT place any reliance on signature validation allegedly performed
on its behalf [i.e., the AD bit], except when the security-aware stub resolver
obtained the data in question from a trusted security-aware recursive name
server via a secure channel." Postfix tries to conform with that "MUST NOT" by
[warning](https://www.ietf.org/mail-archive/web/dane/current/msg06294.html)
that it's the sysadmin's responsibility to configure the system's resolver
correctly.
(BTW, there is a
[comment](https://github.com/vdukhovni/postfix/blob/e3c9d425eee3cb2088add18025cdd0d141018f8b/postfix/src/dns/dns_lookup.c#L304-L306)
in the Postfix codebase that they might make `libunbound`, a
validating stub resolver library, a mandatory dependency, which would allow
Postfix to do its own validation.)
Another example is the OpenSSH client on Debian and Fedora systems, which is
compiled without `ldns` support. In order to look up `SSHFP`
records it uses the `res_*()` interface with
`RES_USE_EDNS0|RES_USE_DNSSEC` and examines the AD-bit, and it also uses
its
[
own DNS message parsing implementation](http://sources.debian.net/src/openssh/1:6.9p1-2/openbsd-compat/getrrsetbyname.c/)
rather than relying on `libresolv`'s `ns_*()` interface.
If I understand correctly, since e.g. Postfix and OpenSSH currently assume the
AD-bit is trustworthy, the AD-bit stripping proposal described in this article
amounts to declaring that the glibc stub resolver does not always obtain its
data from "a trusted security-aware recursive name server via a secure channel",
and if there were some way to determine that the system's upstream resolver is
both trustworthy and that the system communicates with it over a secure channel,
the AD-bit could be unmasked. Both of those determinations are pretty hard to
evaluate, and to communicate to relying processes with the existing APIs/ABIs.
Especially when those relying processes might use their own stub resolver (e.g.,
`adns`, `c-ares`) and the only ABI you have is the contents of the
`/etc/resolv.conf` file.
The second proposal described in the article appears to be to add a "Validating
Security-Aware Stub Resolver" to glibc, which is the "trust, but verify" (i.e.,
don't trust) mode, where the stub resolver on the end host is responsible for
performing the cryptographic validation itself. However, since DNSSEC validation
requires obtaining additional DNS records
[this
results in short-lived processes spamming the upstream resolver with more
DNS queries](https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=679828;msg=10).
Reducing this query spam requires either a local cache, and/or the deployment
of a proposal like
[draft-ietf-dnsop-edns-chain-query](https://datatracker.ietf.org/doc/draft-ietf-dnsop-edns-chain-query/?include_text=1).
Moreover, in-process validation would result in pulling in a heavyweight library
like `libunbound`, which may spawn threads, perform long-lived heap
allocations for its cache, load hairy crypto libraries like OpenSSL into the
process, etc. As a proof-of-concept, a few years ago I attempted an
[ nss-ubdns](https://github.com/edmonds/nss-ubdns)
module for the Name Service Switch that could replace
`nss_dns`and use
`libunbound`rather than
`libresolv`for DNS resolution. This turned out to be very crashy in practice with nontrivial applications like Firefox, and I lost interest in the approach.
There are also developments on the horizon that lean towards having a local
daemon on the system: the IETF's
[DNS PRIVate Exchange
(DPRIVE)](https://datatracker.ietf.org/wg/dprive/charter/)
working group is coalescing around proposals to protect the privacy of the "last
mile" of DNS with TLS and/or D(TLS) sessions between stub resolvers and
recursive DNS servers. (IANA has provisionally allocated TCP/UDP port 853 for
this.) To scale, this is going to require maintaining a long-lived session with
the recursive DNS server, to minimize the overhead and latency of TCP and TLS
session initiation. That means the end host's stub resolver needs to have a
nearby long-lived daemon somewhere between it and the recursive DNS server.
Probably that means something like a local unbound instance on the system
operating in forwarding mode and speaking the port 853 protocol to its upstream
resolver.
Finally, folks writing new applications that want to rely on
DNSSEC-authenticated resource records from the DNS are unlikely to want to rely
on the old resolver interface, even if eventually bleeding edge versions of the
glibc resolver grow the capability to tell the caller that the results are
trustworthy. (What do you do if you're running on an older glibc version, or the
distro you're running on hasn't set things up properly, or you're on a BSD,
etc.) Easier to add an external dependency on something like [ getdnsapi](https://getdnsapi.net/), which currently only has a
`libunbound`backend but will hopefully have an alternate implementation provided by a library form of CZ.NIC's
[Knot Resolver](https://github.com/CZ-NIC/knot-resolver/issues/5).
Posted Dec 8, 2015 21:49 UTC (Tue)
by
Given this, why do we care about DNS security?
Posted Dec 9, 2015 1:23 UTC (Wed)
by
Posted Dec 9, 2015 9:01 UTC (Wed)
by
[
]## Why Do We Need Secure DNS, Again?
**ldo** (guest, #40946)
[[Link](/Articles/667209/)] (2 responses)
[
]## Why Do We Need Secure DNS, Again?
**flussence** (guest, #85566)
[[Link](/Articles/667234/)]
[
]## Why Do We Need Secure DNS, Again?
**paulj** (subscriber, #341)
[[Link](/Articles/667251/)] |
6,982 | 六款优秀的开源协作编辑工具 | http://www.linuxlinks.com/article/20150823085112605/CollaborativeEditing.html | 2016-02-06T10:02:00 | [
"协作",
"编辑"
] | https://linux.cn/article-6982-1.html | 简而言之,<ruby> 协作编辑 <rp> ( </rp> <rt> Collaborative Edit </rt> <rp> ) </rp></ruby>就是多个人进行编辑。协作有好处也有风险。好处之一是更加全面/协调的方式,更好的利用现有资源和一个更加有力一致的声音。对于我来说,最大的好处是极大的透明度。那是当我需要采纳同事的观点。同事之间来来回回地传文件效率非常低,导致不必要的延误还让人(比如,我)对整个协作这件事都感到不满意。有个好的协作软件,我就能实时地或异步地分享笔记,数据和文件,并用评论来分享自己的想法。这样在文档、图片、视频、演示文稿上协作就不会那么的琐碎而无聊。
有很多种方式能在线进行协作,简直不能更简便了。这篇文章展示了我最喜欢的开源的实时文档协作编辑工具。
Google Docs 是个非常好的高效应用,有着大部分我所需要的功能。它可以作为一个实时地协作编辑文档的工具提供服务。文档可以被分享、打开并被多位用户同时编辑,用户还能看见其他协作者一个字母一个字母的编辑过程。虽然 Google Docs 对个人是免费的,但并不开源。
下面是我带来的最棒的开源协作编辑器,它们能帮你不被打扰的集中精力进行写作,而且是和其他人协同完成。
---
### Hackpad

Hackpad 是个开源的基于网页的实时 wiki,基于开源 EtherPad 协作文档编辑器。
Hackpad 允许用户实时分享你的文档,它还用彩色编码显示各个作者分别贡献了哪部分。它还允许插入图片、清单,由于提供了语法高亮功能,它还能用来写代码。
当2014年4月 Dropbox 收购了 Hackpad 后,就在这个月这款软件以开源的形式发布。让我们经历的等待非常值得。
特性:
* 有类似 wiki 所提供的,一套非常完善的功能
* 实时或者异步地记录协作笔记,共享数据和文件,或用评论分享你们的想法
* 细致的隐私许可让你可以邀请单个朋友、一个十几人的团队或者上千的 Twitter 粉丝
* 智能执行
* 直接从流行的视频分享网站上插入视频
* 表格
* 可对使用广泛的包括 C, C#, CSS, CoffeeScript, Java, 以及 HTML 在内的编程语言进行语法高亮
* 网站:[hackpad.com](https://hackpad.com/)
* 源代码:[github.com/dropbox/hackpad](https://github.com/dropbox/hackpad)
* 开发者:[Contributors](https://github.com/dropbox/hackpad/blob/master/CONTRIBUTORS)
* 许可:Apache License, Version 2.0
* 版本号: -
---
### Etherpad

Etherpad 是个基于网页的开源实时协作编辑器,允许多个作者同时编辑一个文本文档,写评论,并与其他作者用群聊方式进行交流。
Etherpad 是用 JavaScript 编写的,运行在 AppJet 平台之上,通过 Comet 流实现实时的功能。
特性:
* 尽心设计的斯巴达界面
* 简单的格式化文本功能
* “滑动时间轴”——浏览一个工程历史版本
* 可以下载纯文本、 PDF、微软的 Word 文档、Open Document 和 HTML 格式的文档
* 每隔一段很短的时间就会自动保存
* 可个性化程度高
* 有客户端插件可以扩展编辑的功能
* 几百个支持 Etherpad 的扩展,包括支持 email 提醒,pad 管理,授权
* 可访问性开启
* 可从 Node 里或通过 CLI(命令行界面)和 EtherPad 的内容交互
* 网站: [etherpad.org](http://etherpad.org/)
* 源代码:[github.com/ether/etherpad-lite](https://github.com/ether/etherpad-lite)
* 开发者:David Greenspan, Aaron Iba, J.D. Zamfiresc, Daniel Clemens, David Cole
* 许可:Apache License, Version 2.0
* 版本号: 1.5.7
---
### Firepad

Firepad 是个开源的协作文本编辑器。它的设计目的是被嵌入到更大的网页应用中对几天内新加入的代码进行批注。
Firepad 是个全功能的文本编辑器,有解决冲突,光标同步,用户属性,用户在线状态检测功能。它使用 Firebase 作为后台,而且不需要任何服务器端的代码。他可以被加入到任何网页应用中。Firepad 可以使用 CodeMirror 编辑器或者 Ace 编辑器提交文本,它的操作转换代码是从 ot.js 上借鉴的。
如果你想要通过添加简单的文档和代码编辑器来扩展你的网页应用能力,Firepad 最适合不过了。
Firepad 已被多个编辑器使用,包括Atlassian Stash Realtime Editor、Nitrous.IO、LiveMinutes 和 Koding。
特性:
* 纯正的协作编辑
* 基于 OT 的智能合并及解决冲突
* 支持多种格式的文本和代码的编辑
* 光标位置同步
* 撤销/重做
* 文本高亮
* 用户属性
* 在线检测
* 版本检查点
* 图片
* 通过它的 API 拓展 Firepad
* 支持所有现代浏览器:Chrome、Safari、Opera 11+、IE8+、Firefox 3.6+
* 网站: [www.firepad.io](http://www.firepad.io/)
* 源代码:[github.com/firebase/firepad](https://github.com/firebase/firepad)
* 开发者:Michael Lehenbauer and the team at Firebase
* 许可:MIT
* 版本号:1.1.1
---
### OwnCloud Documents

ownCloud Documents 是个可以单独并/或协作进行办公室文档编辑 ownCloud 应用。它允许最多5个人同时在网页浏览器上协作进行编辑 .odt 和 .doc 文件。
ownCloud 是个自托管文件同步和分享服务器。他通过网页界面,同步客户端或 WebDAV 提供你数据的使用权,同时提供一个容易在设备间进行浏览、同步和分享的平台。
特性:
* 协作编辑,多个用户同时进行文件编辑
* 在 ownCloud 里创建文档
* 上传文档
* 在浏览器里分享和编辑文件,然后在 ownCloud 内部或通过公共链接进行分享这些文件
* 有类似 ownCloud 的功能,如版本管理、本地同步、加密、恢复被删文件
* 通过透明转换文件格式的方式无缝支持微软 Word 文档
* 网站:[owncloud.org](https://owncloud.org/)
* 源代码: [github.com/owncloud/documents](http://github.com/owncloud/documents/)
* 开发者:OwnCloud Inc.
* 许可:AGPLv3
* 版本号:8.1.1
---
### Gobby

Gobby 是个支持在一个会话内进行多个用户聊天并打开多个文档的协作编辑器。所有的用户都能同时在文件上进行工作,无需锁定。不同用户编写的部分用不同颜色高亮显示,它还支持多个编程和标记语言的语法高亮。
Gobby 允许多个用户在互联网上实时共同编辑同一个文档。它很好的整合了 GNOME 环境。它拥有一个客户端-服务端结构,这让它能支持一个会话开多个文档,文档同步请求,密码保护和 IRC 式的聊天方式可以在多个频道进行交流。用户可以选择一个颜色对他们在文档中编写的文本进行高亮。
还供有一个叫做 infinoted 的专用服务器。
特性:
* 成熟的文本编辑能力包括使用 GtkSourceView 的语法高亮功能
* 实时、无需锁定、通过加密(包括PFS)连接的协作文本编辑
* 整合了群聊
* 本地组撤销:撤销不会影响远程用户的修改
* 显示远程用户的光标和选择区域
* 用不同颜色高亮不同用户编写的文本
* 适用于大多数编程语言的语法高亮,自动缩进,可配置 tab 宽度
* 零冲突
* 加密数据传输包括完美的正向加密(PFS)
* 会话可被密码保护
* 通过 Access Control Lists (ACLs) 进行精密的权限保护
* 高度个性化的专用服务器
* 自动保存文档
* 先进的查找和替换功能
* 国际化
* 完整的 Unicode 支持
* 网站:[gobby.github.io](https://gobby.github.io/)
* 源代码: [github.com/gobby](https://github.com/gobby)
* 开发者: Armin Burgmeier, Philipp Kern and contributors
* 许可: GNU GPLv2+ and ISC
* 版本号:0.5.0
---
### OnlyOffice

ONLYOFFICE(从前叫 Teamlab Office)是个多功能云端在线办公套件,整合了 CRM(客户关系管理)系统、文档和项目管理工具箱、甘特图以及邮件整合器
它能让你整理商业任务和时间表,保存并分享你的协作或个人文档,使用网络社交工具如博客和论坛,还可以和你的队员通过团队的即时聊天工具进行交流。
能在同一个地方管理文档、项目、团队和顾客关系。OnlyOffice 结合了文本,电子表格和电子幻灯片编辑器,他们的功能跟微软桌面应用(Word、Excel 和 PowerPoint)的功能相同。但是他允许实时进行协作编辑、评论和聊天。
OnlyOffice 是用 ASP.NET 编写的,基于 HTML5 Canvas 元素,并且被翻译成21种语言。
特性:
* 当在大文档里工作、翻页和缩放时,它能与桌面应用一样强大
* 文档可以在浏览/编辑模式下分享
* 文档嵌入
* 电子表格和电子幻灯片编辑器
* 协作编辑
* 评论
* 群聊
* 移动应用
* 甘特图
* 时间管理
* 权限管理
* Invoicing 系统
* 日历
* 整合了文件保存系统:Google Drive、Box、OneDrive、Dropbox、OwnCloud
* 整合了 CRM、电子邮件整合器和工程管理模块
* 邮件服务器
* 邮件整合器
* 可以编辑流行格式的文档、电子表格和电子幻灯片:DOC、DOCX、ODT、RTF、TXT、XLS、XLSX、ODS、CSV、PPTX、PPT、ODP
* 网站:[www.onlyoffice.com](https://www.onlyoffice.com/free-edition.aspx)
* 源代码:[github.com/ONLYOFFICE/DocumentServer](https://github.com/ONLYOFFICE/DocumentServer)
* 开发者:Ascensio System SIA
* 许可:GNU GPL v3
* 版本号:7.7
---
via: <http://www.linuxlinks.com/article/20150823085112605/CollaborativeEditing.html>
作者:Frazer Kline 译者:[H-mudcup](https://github.com/H-mudcup) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,985 | 如何在 Linux 系统上安装 Suricata 入侵检测系统 | http://xmodulo.com/install-suricata-intrusion-detection-system-linux.html | 2016-02-07T10:10:00 | [
"IDS",
"Suricata",
"入侵检测系统"
] | https://linux.cn/article-6985-1.html | 随着安全威胁的不断发生,入侵检测系统(IDS)在如今的数据中心环境中显得尤为必要。然而,随着越来越多的服务器将他们的网卡升级到10GB/40GB以太网,对如此线路上的硬件进行计算密集型的入侵检测越来越困难。其中一种提升入侵检测系统性能的途径是**多线程入侵检测系统**,它将 CPU 密集型的深度包检测工作并行的分配给多个并发任务来完成。这样的并行检测可以充分利用多核硬件的优势来轻松提升入侵检测系统的吞吐量。在这方面有两个知名的开源项目,分别是 [Suricata](http://suricata-ids.org/) 和 [Bro](https://www.bro.org/)。

这个教程里,我会向大家演示**如何在 Linux 服务器上安装和配置 Suricata 入侵检测系统。**
### 在 Linux 上安装 Suricata IDS
让我们从源文件来构建 Suricata,但在此之前,需要按如下所示先安装几个依赖包。
#### 在 Debian, Ubuntu 或者 Linux Mint 操作系统上安装依赖包
```
$ sudo apt-get install wget build-essential libpcre3-dev libpcre3-dbg automake autoconf libtool libpcap-dev libnet1-dev libyaml-dev zlib1g-dev libcap-ng-dev libjansson-dev
```
#### 在 CentOS, Fedora 或者 RHEL 操作系统上安装依赖包
```
$ sudo yum install wget libpcap-devel libnet-devel pcre-devel gcc-c++ automake autoconf libtool make libyaml-devel zlib-devel file-devel jansson-devel nss-devel
```
一旦将所有依赖包安装完毕,我们就可以继续安装 Suricata 了。
首先从 <http://suricata-ids.org/download/> 下载 Suricata 源代码,然后构建它。撰写这篇文章的时候,其最新版本号为 2.0.8 。
```
$ wget http://www.openinfosecfoundation.org/download/suricata-2.0.8.tar.gz
$ tar -xvf suricata-2.0.8.tar.gz
$ cd suricata-2.0.8
$ ./configure --sysconfdir=/etc --localstatedir=/var
```
以下是配置信息的样例。
```
Suricata Configuration:
AF_PACKET support: yes
PF_RING support: no
NFQueue support: no
NFLOG support: no
IPFW support: no
DAG enabled: no
Napatech enabled: no
Unix socket enabled: yes
Detection enabled: yes
libnss support: yes
libnspr support: yes
libjansson support: yes
Prelude support: no
PCRE jit: yes
LUA support: no
libluajit: no
libgeoip: no
Non-bundled htp: no
Old barnyard2 support: no
CUDA enabled: no
```
现在可以编译、安装了。
```
$ make
$ sudo make install
```
Suricata 源代码带有默认的配置文件。按照如下方法安装这些默认配置文件即可。
```
$ sudo make install-conf
```
正如你所料,如果没有IDS规则集的话,Suricata 什么用也没有。幸好 Makefile 为我们提供了 IDS 规则集的安装选项。安装方法如下。
```
$ sudo make install-rules
```
以上的规则安装命令会从 [EmergingThreats.net](http://rules.emergingthreats.net/) 上下载可用的社区规则集快照,并且将其存储在 /etc/suricata/rules 目录下。

### 首次配置 Suricata IDS
现在到了配置 Suricata 的时候了。配置文件的位置是 **/etc/suricata/suricata.yaml**。参照以下命令,用文本编辑器打开这个文件。
```
$ sudo vi /etc/suricata/suricata.yaml
```
文件中有一些运行所需的基本配置。
为`default-log-dir`关键字指定 Suricata 日志文件所在的位置。
```
default-log-dir: /var/log/suricata/
```
在`vars`部分下方,你会发现几项对 Suricata 来说很重要变量。`HOME_NET`变量需要指定 Suricata 检查的网络。被分配给 `EXTERNAL_NET` 变量的 `!$HOME_NET` 代表除本地网络之外的其他网络。`XXX_PORTS`变量用来辨别不同服务所用到的端口号。需要注意的是无论使用什么端口,Suricata 都可以自动检测 HTTP 流量。所以是不是正确指定端口就显得没那么重要了。
```
vars:
HOME_NET: "[192.168.122.0/24]"
EXTERNAL_NET: "!$HOME_NET"
HTTP_PORTS: "80"
SHELLCODE_PORTS: "!80"
SSH_PORTS: 22
```
`host-os-policy` 部分用于防御利用操作系统网络栈的自身行为来逃避检测的一些知名攻击手段(例如:TCP reassembly)。作为对策,通过针对目标操作系统而对检测引擎算法进行微调,现代 IDC 提供了“基于目标”的检测手段。因此,如果你知道某台主机运行了什么操作系统的话,将这个信息提供给 Suricata 就可以大幅提高检测的成功率。这就是 `host-os-policy` 存在的意义。本例中,默认的 IDC 策略是 Linux 系统。如果针对某个 IP 地址没有指定操作系统信息,Suricata 会默认应用基于 Linux 系统的检测策略。如下,当捕获到对 192.168.122.0/28 和 192.168.122.155通讯时,Suricata 就会应用基于 Windows 系统的检测策略。
```
host-os-policy:
# These are Windows machines.
windows: [192.168.122.0/28, 192.168.122.155]
bsd: []
bsd-right: []
old-linux: []
# Make the default policy Linux.
linux: [0.0.0.0/0]
old-solaris: []
solaris: ["::1"]
hpux10: []
hpux11: []
irix: []
macos: []
vista: []
windows2k3: []
```
在 `threading` 部分下,你可以为不同的 Suricata 线程指定 CPU 关联。默认状态下,[CPU 关联](http://xmodulo.com/run-program-process-specific-cpu-cores-linux.html) 是被禁止使用的 (`set-cpu-affinity: no`),这意味着 Suricata 会分配其线程到所有可用的 CPU 核心上。Suricata 会默认为每一个 CPU 核心创建一个检测线程。你可以通过指定 `detect-thread-ratio: N` 来调整此行为。此处会创建 N\*M 个检测线程,M 代表 CPU 核心总数。
```
threading:
set-cpu-affinity: no
detect-thread-ratio: 1.5
```
通过以上对线程的设置,Suricata 会创建 1.5\*M 个检测线程,M 是系统的 CPU 核心总数。
如果你想对 Suricata 配置有更多的了解,可以去翻阅默认配置文件。里边配有有大量的注释以供你清晰理解。
### 使用 Suricata 进行入侵监控
现在是时候让 Suricata 跑起来了,但在这之前还有一个步骤需要去完成。
当你使用 pcap 捕获模式的时候,强烈建议关闭 Suricata 监听网卡上的任何的包卸载(例如 LRO/GRO)功能。这些功能会干扰包的实时捕获行为。
按照以下方法关闭 eth0 接口的 LRO/GRO 功能。
```
$ sudo ethtool -K eth0 gro off lro off
```
这里要注意,在使用某些网卡的情况下,你会看到如下警告信息。忽略它们就行了,这些信息只不过告诉你你的网卡不支持 LRO 功能而已。
```
Cannot change large-receive-offload
```
Suricata 支持许多运行模式。运行模式决定着 IDC 会使用何种线程。以下命令可以查看所有 [可用的运行模式](https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Runmodes)。
```
$ sudo /usr/local/bin/suricata --list-runmodes
```

Suricata 使用的默认运行模式是 autofp(<ruby> auto flow pinned load balancing <rp> ( </rp> <rt> 自动流绑定负载均衡 </rt> <rp> ) </rp></ruby> 的缩写)。这个模式下,来自某一个流的包会被分配到一个单独的检测线程中。这些流会根据未被处理的包的最低数量来分配相应的线程。
最后,让我们将 Suricata 运行起来,看看它表现如何。
```
$ sudo /usr/local/bin/suricata -c /etc/suricata/suricata.yaml -i eth0 --init-errors-fatal
```

本例中,我们在一个8核心系统中监控 eth0 网络接口。如上所示,Suricata 创建了13个包处理线程和3个管理线程。包处理线程中包括一个 PCAP 包捕获线程,12个检测线程(由8\*1.5得出)。这表示 IDS 内的1个包捕获线程均衡负载到12个检测线程中。管理线程包括1个流管理和2个计数/统计相关线程。
以下是一个关于Suricata处理的线程截图(由 [htop](http://ask.xmodulo.com/view-threads-process-linux.html) 绘制)。

Suricata 检测日志存储在 /var/log/suricata 目录下。
```
$ tail -f /var/log/suricata/fast.log
```
---
```
04/01/2015-15:47:12.559075 [**] [1:2200074:1] SURICATA TCPv4 invalid checksum [**] [Classification: (null)] [Priority: 3] {TCP} 172.16.253.158:22 -> 172.16.253.1:46997
04/01/2015-15:49:06.565901 [**] [1:2200074:1] SURICATA TCPv4 invalid checksum [**] [Classification: (null)] [Priority: 3] {TCP} 172.16.253.158:22 -> 172.16.253.1:46317
04/01/2015-15:49:06.566759 [**] [1:2200074:1] SURICATA TCPv4 invalid checksum [**] [Classification: (null)] [Priority: 3] {TCP} 172.16.253.158:22 -> 172.16.253.1:46317
```
日志也可以提供 Json 格式以便导入:
```
$ tail -f /var/log/suricata/eve.json
```
---
```
{"timestamp":"2015-04-01T15:49:06.565901","event_type":"alert","src_ip":"172.16.253.158","src_port":22,"dest_ip":"172.16.253.1","dest_port":46317,"proto":"TCP","alert":{"action":"allowed","gid":1,"signature_id":2200074,"rev":1,"signature":"SURICATA TCPv4 invalid checksum","category":"","severity":3}}
{"timestamp":"2015-04-01T15:49:06.566759","event_type":"alert","src_ip":"172.16.253.158","src_port":22,"dest_ip":"172.16.253.1","dest_port":46317,"proto":"TCP","alert":{"action":"allowed","gid":1,"signature_id":2200074,"rev":1,"signature":"SURICATA TCPv4 invalid checksum","category":"","severity":3}}
```
### 总结
这篇教程中,我为大家演示了如何在一台多核 Linux 服务器上安装 Suricata 入侵检测系统。不同于单线程的 [Snort IDS](http://xmodulo.com/how-to-compile-and-install-snort-from-source-code-on-ubuntu.html) ,Suricata 可以很容易的从多核硬件的多进程特性所带来的好处中获益。定制 Suricata 来最大化其效能和检测范围是一个很好的主意。Suricata 的粉丝们维护着一个 [在线 Wiki](https://redmine.openinfosecfoundation.org/projects/suricata/wiki),如果你打算将 Suricata 部署到你的环境中,我强烈建议你去那儿取取经。
如果你现在已经开始使用 Suricata 了的话,把你的经验也分享出来吧。
---
via: <http://xmodulo.com/install-suricata-intrusion-detection-system-linux.html>
作者:[Dan Nanni](http://xmodulo.com/author/nanni) 译者:[mr-ping](https://github.com/mr-ping) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,986 | Cinnamon 2.8 新变化一览 | https://www.maketecheasier.com/cinnamon-2-8-review/ | 2016-02-08T07:56:00 | [
"Cinnamon"
] | https://linux.cn/article-6986-1.html | 
除了Gnome和KDE外,Cinnamon是另一个很多人使用的桌面环境。它是由创作Linux Mint的团队制作的,并且可以被安装在许多其他发行版上。该桌面环境的最新版本 - Cinnamon 2.8 - 于去年底发布,此版本修复了许多的Bug、做了许多改进并添加了一些新功能。
我将仔细介绍该发行版本的主要改进,以及如何更新到Cinnamon 2.8或者第一次安装它。
### 对Applets的改进
在此版本中,对面板中已有的Applets做了若干的改进。
#### 声音 Applet

声音Applet经过修正,目前可以显示音轨信息并且可以在音频文件的艺术家封面上面进行媒体控制。对于支持拖动的音乐播放器来说(例如Banshee),会有一个进度条显示同样的播放进度,您可以用它来改变音轨位置。在applet的面板上右击将显示对输入和输出设备静音的选项。
#### 电源 Applet
电源applet则会使用电池制造商的数据而不是通用名称来显示每一个连接的电池和设备。
#### 窗口缩略图

在Cinnamon 2.8中,可以在鼠标悬停于面板里窗口列表时展示窗口缩略图。如果您不喜欢该功能,您还可以关闭该选项。
#### 工作区切换 Applet

添加工作区切换applet到您的面板将为您显示一个代表该工作区的可视化图像,一些矩形嵌套显示在其中,代表您的窗口的位置。
#### 系统托盘
Cinnamon 2.8支持在系统托盘中显示应用程序指示器。您可以很容易地在设置中禁用它,这将强制应用程序到以前使用状态图标的方式。
### 视觉改进
Cinnamon 2.8还做了很多视觉上的改进。经典的切换器和Alt + Tab预览切换器都被精细打磨,有了显著的改进,同时修复了Alt + F2对话框的bug,并赋予了它更好的命令自动补全功能。
而且,传统的最小化窗口时动画效果的问题现已被解决,并可用于多个面板。
### Nemo 的改进

Cinnamon默认的文件管理器也修复了一些bug,并有了新的“快速重命名”的功能,用于重命名文件和文件夹。可以通过两次点击文件或文件夹并在两次点击之间进行简短的停顿以重命名文件。
Nemo也会自动地检测缩略图存在的问题,并提示您快速地修复它们。
### 其他值得注意的改进
* Applets如今会在它们被更新的时候自动地重新加载一次。
* 对于多个监视器的支持有了显著的提高。
* 对话框窗口有了改进,并且会附加到它的父窗口上。
* HiDPI检测有了改进。
* QT5应用程序现在看起来更加原生并使用了默认的GTK主题。
* 窗口管理和渲染性能有了提升。
* 修复了许多bug。
### 如何获得 Cinnamon 2.8
如果您在运行Linux Mint,您会在更新Linux Mint 17.3 “Rosa”Cinnamon版本的时候获得Cinnamon 2.8的更新。BETA版本现在已经放出,因此,如果您想立刻尝试新的软件,您可以试试。
对于Arch的用户来说,Cinnamon 2.8已经在Arch的官方仓库了,您可以通过更新软件包和系统级的更新获得Cinnamon的最新版本。
最后,对于Ubuntu用户来说,您可以通过下面的命令安装或更新Cinnamon 2.8:
```
sudo add-apt-repository -y ppa:moorkai/cinnamon
sudo apt-get update
sudo apt-get install cinnamon
```
您已经尝试了Cinnamon 2.8了么?感觉如何呢?
---
via: <https://www.maketecheasier.com/cinnamon-2-8-review/>
作者:[Ayo Isaiah](https://www.maketecheasier.com/author/ayoisaiah/) 译者:[wwy-hust](https://github.com/wwy-hust) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | 
A sometimes-forgotten Linux Desktop Environment, Cinnamon is a contender for your desktop that you may not have seen coming. While Cinnamon is developed by the Linux Mint team as a flagship for their distribution, it is also available to download and use on any other distro. This article covers Cinnamon desktop in depth, exploring the user experience and customization options, performance, usability, and recommendations for who should use Cinnamon.
**Also read:** [GNOME Shell Review: Minimal Desktop with Great Performance](https://www.maketecheasier.com/gnome-shell-review/)
## First Impressions of Cinnamon
Cinnamon was initially a fork of GNOME, but with Cinnamon 2.0, it became an independent desktop environment that is no longer reliant on the GNOME library. Upon logging in, Cinnamon looks clean, modern, and focused. It follows a very traditional desktop paradigm from Windows, with an application menu in the bottom left, applications along the bottom panel, and a system tray in the bottom right. It also has desktop icons for all your disks/file systems with “Computer” and your home folder with “Home.”



Once you get over the initial “Wow, this looks like Windows,” you see that there’s been some work done on Cinnamon to make it feel distinct from both the GNOME backend and the Windows-esque appearance. The “Themes” application gives you a nice overview of all your look-and-feel settings and options, with tons of color choices available, with the options to change things around.
## User Experience
If the aim was to create a DE that follows traditional paradigms, then the Linux Mint team has absolutely done that with Cinnamon. Right out of the box, there are dedicated minimize and maximize buttons, all the window controls are on the right side of the window borders, and the application menu in the bottom left has categories and a powerful search function that not only searches application titles but also descriptions. Navigating the desktop is super simple; the desktop puts you in the driver’s seat while not asking you to drive anything too unwieldy.

For anything you need in Cinnamon, you simply open the applications menu and either look through the categories or start typing to search. It’s a centralized location for you to start digging through everything the system has to offer, and it unifies all of the applications into logical categories and a universal access point. It’s quite similar to Windows in that way, but the feel of the applications is reminiscent of many GNOME applications. The interface is simple but effective, and it gives you what you’re looking for without getting in the way. A great example of this is Xed, which is Cinnamon’s take on Gedit from GNOME. It’s simple, elegant, minimal, and allows you to quickly write your script, text file, or readme without much hassle.
### The Cinnamon X-Apps
Many of the Cinnamon default X-Apps are like GNOME Core apps plus a little extra user-friendliness. Xed, the text editor, is like Gedit with some easier preferences and choices. The ways the apps are designed is partially why Linux Mint has a great reputation of being user-friendly.


### Customization
Cinnamon also has a great deal more customization right out of the box than its ancestor. While the default interface is Windows-like, you can easily move the panel around (or remove it if you want) and make it [macOS-like](https://www.maketecheasier.com/make-ubuntu-look-like-macos/)/Ubuntu-like or any other style you like. You can customize the panel, the icon for the applications menu, the global theme, the accent colors, the icon theme, the window decorations, the window border, and so much more. Almost every aspect of the desktop interface can be customized. The customization isn’t on par with [KDE Plasma](https://www.maketecheasier.com/kde-plasma-review/), but it’s much more thorough than other offerings. It makes space for you to move in and feel at home without overwhelming you. It’s the best parts of Linux without the worst parts: you have the choice and control without the overwhelming amount of freedom that some options give you.
### Keyboard Shortcuts in Cinnamon
Cinnamon also comes with great keyboard shortcuts, especially around window tiling. By holding down the `Super` key and pressing `Left`, `Right`, `Up`, or `Down`, you can half-tile windows to the left, right, top, or bottom of your screen. Plus, once a window is half-tiled to one side, you can quarter-tile it by pressing `Up` or `Down`. The windows tile without any animation or delay, making things feel incredibly fast and like you can just get work done.

Window management is done with a classic `Alt` + `Tab`, giving you an application icon and a drop-down menu of the window preview. In terms of [workspace management](https://www.maketecheasier.com/how-to-work-with-workspaces-gnome/), it’s a similar setup: hold down `Ctrl` and `Alt` and press either `Left`, `Right`, `Up`, or `Down`. `Left` and `Right` will switch workspaces, `Down` will show you an overview of your workspaces, and `Up` will give you a gridded overview of all of your workspaces with the option to add more.
Cinnamon focuses on the keyboard, which is playing to the strengths of Linux particularly well, especially with a lack of easy touchpad gestures in Linux. Being able to hold `Super` or `Ctrl` and `Alt` and use the arrow keys to navigate the system, especially with the quick snap of the keyboard shortcuts, gives you a really logical and simple way to work around the system, and once you embrace those shortcuts, you won’t go back.

`Ctrl`
+ `Alt`
+ `Up`
### Cinnamon Extensions
There are all kinds of Cinnamon extensions available, like a Compiz Cube for your workspaces, a background blur in overview, and wobbly windows, a favorite among its diehard fans. The Cinnamon Extensions give you access to some functional changes in the desktop rather than the typical visual changes afforded by the Themes app. It’s another layer of customization that gives you flexibility in your system.
### Cinnamon Desklets
Another great strength of Cinnamon is its Desklets. These are little applets that you can add to your desktop to give you a larger clock, a dedicated application launcher, CPU usage graphs, and many others. It’s a great way to be able to quickly glance at important information without having to crowd a system tray or open another application. It’s all just baked into the desktop.

## Performance
Cinnamon performance is excellent. At idle on a freshly-booted Linux Mint 19.3 virtual machine, CPU usage is around two to three percent, and idle RAM usage is at 566MB. That’s quite a small footprint, especially considering its lineage. That makes it ideal for older machines with less powerful CPUs and that have lower maximum RAM specifications. I could envision an older ThinkPad running very well with Cinnamon, especially given all of its useful keyboard shortcuts.

As mentioned before, there are very few animations, which can feel a little un-modern. However, it increases overall system performance and makes things feel lightning fast. Switching workspaces, tiling windows, opening the application menu, everything feels incredibly fast. It makes me want to work faster in order to keep up with the desktop, almost like the desktop challenges me to keep up.
## The Cons of Cinnamon
Cinnamon is an excellent desktop environment, but there are some negatives to it. The Mint Icon theme feels a little dated, and it feels like somebody made a caricature of an icon theme from 2007. It’s simple enough to change, like with all Linux desktops, but there’s clearly been much thought that’s gone into the design, theming and accent colors that I’d love to be able to stick with the Mint icon theme. It’s a bit of a letdown.
Another downside is some of the extra applications that come with Cinnamon. Things like Transmission, HexChat, two distinct fonts apps, and two distinct USB formatting and writing applications makes me wonder how much of it is really necessary. I often find myself uninstalling a fair number of applications that come stock with Cinnamon just because they get in my way. The X-Apps are great, as they add usability to the GNOME Core apps, but it’s just hard to get past HexChat in my applications menu.
## Where to Experience Cinnamon
The obvious choice is [Linux Mint](https://www.linuxmint.com/download.php). The Linux Mint team has been iterating on Cinnamon for a good while, and the polish that they’ve achieved is commendable. On top of Cinnamon itself, there are tons of useful applications developed by the team and integrated into Mint specifically, which makes for an incredible user experience. Things like Warpinator, Timeshift, and the Driver Manager give little user-friendly edges to Mint that are hard to find elsewhere.

## Who Should Use Cinnamon
Anybody looking for a lightweight desktop that looks good and works well out of the box should give Cinnamon a try, especially if you consider yourself a keyboard shortcut kind of person. Using Cinnamon even for a day or two will give your desktop a new lease on life and help you realize the potential of how quickly and efficiently you can get work done.
Now that you’ve learned some of the ins and outs of Cinnamon, make sure to check out [how to enable Autologin in LightDM](https://www.maketecheasier.com/enable-autologin-lightdm/) and [why you should use Timeshift in Linux Mint to back up your computer](https://www.maketecheasier.com/backup-computer-timeshift-linux-mint/).
Our latest tutorials delivered straight to your inbox |
6,987 | 最全列表: 80 多个 Linux 系统管理员必备的监控工具 | https://blog.serverdensity.com/80-linux-monitoring-tools-know/ | 2016-02-07T23:43:00 | [
"监控"
] | /article-6987-1.html | 
随着互联网行业的不断发展,各种监控工具多得不可胜数。这里列出网上最全的监控工具。让你可以拥有超过80种方式来管理你的机器。在本文中,我们主要包括以下方面:
* 命令行工具
* 网络相关内容
* 系统相关的监控工具
* 日志监控工具
* 基础设施监控工具
监控和调试性能问题是一个艰巨的任务,但用对了正确的工具有时也是很容易的。下面是一些你可能听说过的工具,也有可能没有听说过——何不赶快开始试试?
### 八大系统监控工具
#### 1. top

这是一个被预装在许多 UNIX 系统中的小工具。当你想要查看在系统中运行的进程或线程时:top 是一个很好的工具。你可以对这些进程以不同的方式进行排序,默认是以 CPU 进行排序的。
#### 2. [htop](http://hisham.hm/htop/)

htop 实质上是 top 的一个增强版本。它更容易对进程排序。它看起来上更容易理解,并且已经内建了许多通用操作。它也是完全交互式的。
#### 3. [atop](http://www.atoptool.nl/)
atop 和 top,htop 非常相似,它也能监控所有进程,但不同于 top 和 htop 的是,它可以按日记录进程的日志供以后分析。它也能显示所有进程的资源消耗。它还会高亮显示已经达到临界负载的资源。
#### 4. [apachetop](https://github.com/JeremyJones/Apachetop)
apachetop 会监控 apache 网络服务器的整体性能。它主要是基于 mytop。它会显示当前的读取进程、写入进程的数量以及请求进程的总数。
#### 5. [ftptop](http://www.proftpd.org/docs/howto/Scoreboard.html)
ftptop 给你提供了当前所有连接到 ftp 服务器的基本信息,如会话总数,正在上传和下载的客户端数量以及客户端是谁。
#### 6. [mytop](http://jeremy.zawodny.com/mysql/mytop/)

mytop 是一个很简洁的工具,用于监控 mysql 的线程和性能。它能让你实时查看数据库以及正在处理哪些查询。
#### 7. [powertop](https://01.org/powertop)

powertop 可以帮助你诊断与电量消耗和电源管理相关的问题。它也可以帮你进行电源管理设置,以实现对你服务器最有效的配置。你可以使用 tab 键切换选项卡。
#### 8. [iotop](http://guichaz.free.fr/iotop/)

iotop 用于检查 I/O 的使用情况,并为你提供了一个类似 top 的界面来显示。它按列显示读和写的速率,每行代表一个进程。当发生交换或 I/O 等待时,它会显示进程消耗时间的百分比。
### 与网络相关的监控
#### 9. [ntopng](http://www.ntop.org/products/ntop/)

ntopng 是 ntop 的升级版,它提供了一个能通过浏览器进行网络监控的图形用户界面。它还有其他用途,如:地理定位主机,显示网络流量和 ip 流量分布并能进行分析。
#### 10. [iftop](http://www.ex-parrot.com/pdw/iftop/)

iftop 类似于 top,但它主要不是检查 cpu 的使用率而是监听所选择网络接口的流量,并以表格的形式显示当前的使用量。像“为什么我的网速这么慢呢?!”这样的问题它可以直接回答。
#### 11. [jnettop](http://jnettop.kubs.info/wiki/)

jnettop 以相同的方式来监测网络流量但比 iftop 更形象。它还支持自定义的文本输出,并能以友好的交互方式来深度分析日志。
#### 12. [bandwidthd](http://bandwidthd.sourceforge.net/)

BandwidthD 可以跟踪 TCP/IP 网络子网的使用情况,并能在浏览器中通过 png 图片形象化地构建一个 HTML 页面。它有一个数据库系统,支持搜索、过滤,多传感器和自定义报表。
#### 13. [EtherApe](http://etherape.sourceforge.net/)
EtherApe 以图形化显示网络流量,可以支持更多的节点。它可以捕获实时流量信息,也可以从 tcpdump 进行读取。也可以使用 pcap 格式的网络过滤器来显示特定信息。
#### 14. [ethtool](https://www.kernel.org/pub/software/network/ethtool/)

ethtool 用于显示和修改网络接口控制器的一些参数。它也可以用来诊断以太网设备,并获得更多的统计数据。
#### 15. [NetHogs](http://nethogs.sourceforge.net/)

NetHogs 打破了网络流量按协议或子网进行统计的惯例,它以进程来分组。所以,当网络流量猛增时,你可以使用 NetHogs 查看是由哪个进程造成的。
#### 16. [iptraf](http://iptraf.seul.org/)

iptraf 收集的各种指标,如 TCP 连接数据包和字节数,端口统计和活动指标,TCP/UDP 通信故障,站内数据包和字节数。
#### 17. [ngrep](http://ngrep.sourceforge.net/)

ngrep 就是网络层的 grep。它使用 pcap ,允许通过指定扩展正则表达式或十六进制表达式来匹配数据包。
#### 18. [MRTG](http://oss.oetiker.ch/mrtg/)

MRTG 最初被开发来监控路由器的流量,但现在它也能够监控网络相关的东西。它每五分钟收集一次,然后产生一个 HTML 页面。它还具有发送邮件报警的能力。
#### 19. [bmon](https://github.com/tgraf/bmon/)

bmon 能监控并帮助你调试网络。它能捕获网络相关的统计数据,并以友好的方式进行展示。你还可以与 bmon 通过脚本进行交互。
#### 20. traceroute

traceroute 是一个内置工具,能显示路由和测量数据包在网络中的延迟。
#### 21. [IPTState](http://www.phildev.net/iptstate/index.shtml)
IPTState 可以让你观察流量是如何通过 iptables,并通过你指定的条件来进行排序。该工具还允许你从 iptables 的表中删除状态信息。
#### 22. [darkstat](https://unix4lyfe.org/darkstat/)

darkstat 能捕获网络流量并计算使用情况的统计数据。该报告保存在一个简单的 HTTP 服务器中,它为你提供了一个非常棒的图形用户界面。
#### 23. [vnStat](http://humdi.net/vnstat/)

vnStat 是一个网络流量监控工具,它的数据统计是由内核进行提供的,其消耗的系统资源非常少。系统重新启动后,它收集的数据仍然存在。有艺术感的系统管理员可以使用它的颜色选项。
#### 24. netstat

netstat 是一个内置的工具,它能显示 TCP 网络连接,路由表和网络接口数量,被用来在网络中查找问题。
#### 25. ss
比起 netstat,使用 ss 更好。ss 命令能够显示的信息比 netstat 更多,也更快。如果你想查看统计结果的总信息,你可以使用命令 `ss -s`。
#### 26. [nmap](http://nmap.org/)

Nmap 可以扫描你服务器开放的端口并且可以检测正在使用哪个操作系统。但你也可以将其用于 SQL 注入漏洞、网络发现和渗透测试相关的其他用途。
#### 27. [MTR](http://www.bitwizard.nl/mtr/)

MTR 将 traceroute 和 ping 的功能结合到了一个网络诊断工具上。当使用该工具时,它会限制单个数据包的跳数,然后监视它们的到期时到达的位置。然后每秒进行重复。
#### 28. [Tcpdump](http://www.tcpdump.org/)

Tcpdump 将按照你在命令行中指定的表达式输出匹配捕获到的数据包的信息。你还可以将此数据保存并进一步分析。
#### 29. [Justniffer](http://justniffer.sourceforge.net/)

Justniffer 是 tcp 数据包嗅探器。使用此嗅探器你可以选择收集低级别的数据还是高级别的数据。它也可以让你以自定义方式生成日志。比如模仿 Apache 的访问日志。
### 与系统有关的监控
#### 30. [nmon](http://nmon.sourceforge.net/pmwiki.php)

nmon 将数据输出到屏幕上的,或将其保存在一个以逗号分隔的文件中。你可以查看 CPU,内存,网络,文件系统,前列 进程。数据也可以被添加到 RRD 数据库中用于进一步分析。
#### 31. [conky](http://conky.sourceforge.net/)

Conky 能监视很多的操作系统数据。它支持 IMAP 和 POP3, 甚至许多流行的音乐播放器!出于方便不同的人,你可以使用自己的 Lua 脚本或程序来进行扩展。
#### 32. [Glances](https://github.com/nicolargo/glances)

使用 Glances 监控你的系统,其旨在使用最小的空间为你呈现最多的信息。它可以在客户端/服务器端模式下运行,也有远程监控的能力。它也有一个 Web 界面。
#### 33. [saidar](https://packages.debian.org/sid/utils/saidar)

Saidar 是一个非常小的工具,为你提供有关系统资源的基础信息。它将系统资源在全屏进行显示。重点是 saidar 会尽可能的简化。
#### 34. [RRDtool](http://oss.oetiker.ch/rrdtool/)

RRDtool 是用来处理 RRD 数据库的工具。RRDtool 旨在处理时间序列数据,如 CPU 负载,温度等。该工具提供了一种方法来提取 RRD 数据并以图形界面显示。
#### 35. [monit](http://mmonit.com/monit)

如果出现故障时,monit 有发送警报以及重新启动服务的功能。它可以对各种数据进行检查,你可以为 monit 写一个脚本,它有一个 Web 用户界面来分担你眼睛的压力。
#### 36. [Linux process explorer](http://sourceforge.net/projects/procexp/)

Linux process explorer 是类似 OSX 或 Windows 的活动监视器。它比 top 或 ps 的使用范围更广。你可以查看每个进程的内存消耗以及 CPU 的使用情况。
#### 37. df

df 是 disk free 的缩写,它是所有 UNIX 系统预装的程序,用来显示用户有访问权限的文件系统的可用磁盘空间。
#### 38. [discus](http://packages.ubuntu.com/lucid/utils/discus)

discus 类似于 df,它的目的是通过使用更吸引人的特性,如颜色,图形和数字来对 df 进行改进。
#### 39. [xosview](http://www.pogo.org.uk/%7Emark/xosview/)

xosview 是一款经典的系统监控工具,它给你提供包括 IRQ 在内的各个不同部分的简单总览。
#### 40. [Dstat](http://dag.wiee.rs/home-made/dstat/)

dstat 旨在替代 vmstat,iostat,netstat 和 ifstat。它可以让你查实时查看所有的系统资源。这些数据可以导出为 CSV。最重要的是 dstat 允许使用插件,因此其可以扩展到更多领域。
#### 41. [Net-SNMP](http://www.net-snmp.org/)
SNMP 即“简单网络管理协议”,Net-SNMP 工具套件使用该协议可帮助你收集服务器的准确信息。
#### 42. [incron](http://inotify.aiken.cz/?section=incron&page=about&lang=en)
incron 允许你监控一个目录树,然后对这些变化采取措施。如果你想在目录‘a’中出现新文件时,将其复制到目录‘b’,这正是 incron 能做的。
#### 43. [monitorix](http://www.monitorix.org/)
Monitorix 是轻量级的系统监控工具。它可以帮助你监控单独一台机器,并为你提供丰富的指标。它也有一个内置的 HTTP 服务器,来查看图表和所有指标的报告。
#### 44. vmstat

vmstat(virtual memory statistics)是一个小型内置工具,能监控和显示机器的内存。
#### 45. uptime
这个小程序能快速显示你机器运行了多久,目前有多少用户登录和系统过去1分钟,5分钟和15分钟的平均负载。
#### 46. mpstat

mpstat 是一个内置的工具,能监视 cpu 的使用情况。最常见的使用方法是 `mpstat -P ALL`,它给你提供 cpu 的使用情况。你也可以间歇性地更新 cpu 的使用情况。
#### 47. pmap

pmap 是一个内置的工具,报告一个进程的内存映射。你可以使用这个命令来找出导致内存瓶颈的原因。
#### 48. ps

该命令将给你当前所有进程的概述。你可以使用 `ps -A` 命令查看所有进程。
#### 49. [sar](http://sebastien.godard.pagesperso-orange.fr/)

sar 是 sysstat 包的一部分,可以帮助你收集、报告和保存不同系统的指标。使用不同的参数,它会给你提供 CPU、 内存和 I/O 使用情况及其他东西。
#### 50. [collectl](http://collectl.sourceforge.net/)

类似于 sar,collectl 收集你机器的性能指标。默认情况下,显示 cpu、网络和磁盘统计数据,但它实际收集了很多信息。与 sar 不同的是,collectl 能够处理比秒更小的单位,它可以被直接送入绘图工具并且 collectl 的监控过程更广泛。
#### 51. [iostat](http://sebastien.godard.pagesperso-orange.fr/)

iostat 也是 sysstat 包的一部分。此命令用于监控系统的输入/输出。其报告可以用来进行系统调优,以更好地调节你机器上硬盘的输入/输出负载。
#### 52. free

这是一个内置的命令,用于显示你机器上可用的内存大小以及已使用的内存大小。它还可以显示某时刻内核所使用的缓冲区大小。
#### 53. /proc 文件系统

proc 文件系统可以让你查看内核的统计信息。从这些统计数据可以得到你机器上不同硬件设备的详细信息。看看这个 [proc 文件统计的完整列表](http://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/proc.html)。
#### 54. [GKrellM](http://members.dslextreme.com/users/billw/gkrellm/gkrellm.html)
GKrellm 是一个图形应用程序,用来监控你硬件的状态信息,像CPU,内存,硬盘,网络接口以及其他的。它也可以监视并启动你所选择的邮件阅读器。
#### 55. [Gnome 系统监控器](http://freecode.com/projects/gnome-system-monitor)

Gnome 系统监控器是一个基本的系统监控工具,其能通过一个树状结构来查看进程的依赖关系,能杀死进程及调整进程优先级,还能以图表形式显示所有服务器的指标。
### 日志监控工具
#### 56. [GoAccess](http://goaccess.io/)

GoAccess 是一个实时的网络日志分析器,它能分析 apache, nginx 和 amazon cloudfront 的访问日志。它也可以将数据输出成 HTML,JSON 或 CSV 格式。它会给你一个基本的统计信息、访问量、404 页面,访客位置和其他东西。
#### 57. [Logwatch](http://sourceforge.net/projects/logwatch/)
Logwatch 是一个日志分析系统。它通过分析系统的日志,并为你所指定的部分创建一个分析报告。它每天给你一个报告,以便让你花费更少的时间来分析日志。
#### 58. [Swatch](http://sourceforge.net/projects/swatch/)

像 Logwatch 一样,Swatch 也监控你的日志,但不是给你一个报告,它会匹配你定义的正则表达式,当匹配到后会通过邮件或控制台通知你。它可用于检测入侵者。
#### 59. [MultiTail](http://www.vanheusden.com/multitail/)

MultiTail 可帮助你在多个窗口之下监控日志文件。你可以将这些日志文件合并到一个窗口。它可以通过正则表达式的帮助,使用不同的颜色来显示日志文件以方便你阅读。
### 系统工具
#### 60. [acct or psacct](http://www.gnu.org/software/acct/)
acct 也称 psacct(取决于如果你使用 apt-get 还是 yum)可以监控所有用户执行的命令,包括 CPU 时间和内存占用。一旦安装完成后你可以使用命令 `sa` 来查看统计。
#### 61. [whowatch](http://whowatch.sourceforge.net/)
类似 acct,这个工具监控系统上所有的用户,并允许你实时查看他们正在执行的命令及运行的进程。它将所有进程以树状结构输出,这样你就可以清楚地看到到底发生了什么。
#### 62. [strace](http://sourceforge.net/projects/strace/)

strace 被用于诊断、调试和监控程序之间的相互调用过程。最常见的做法是用 strace 打印系统调用的程序列表,其可以看出程序是否像预期那样被执行了。
#### 63. [DTrace](http://dtrace.org/blogs/about/)

DTrace 可以说是 strace 的大哥。它动态地跟踪与检测代码实时运行的指令。它允许你深入分析其性能和诊断故障。但是,它并不简单,关于这个话题有1200本书之多。
#### 64. [webmin](http://www.webmin.com/)

Webmin 是一个基于 Web 的系统管理工具。它不需要手动编辑 UNIX 配置文件,可以让你远程管理系统。它有一对监控模块用于连接它。
#### 65. stat

Stat 是一个内置的工具,用于显示文件和文件系统的状态信息。它会显示文件何时被修改、访问或更改。
#### 66. ifconfig

ifconfig 是一个内置的工具,用于配置网络接口。大多数网络监控工具背后都使用 ifconfig 将网卡设置成混乱模式来捕获所有的数据包。你可以手动执行 `ifconfig eth0 promisc` 进入混乱模式,使用 `ifconfig eth0 -promisc` 返回正常模式。
#### 67. [ulimit](http://ss64.com/bash/ulimit.html)

ulimit 是一个内置的工具,可监控系统资源,并可以限制任何监控资源不得超标。比如做一个 fork 炸弹,如果使用 ulimit 正确配置了将完全不受影响。
#### 68. [cpulimit](https://github.com/opsengine/cpulimit)
CPULimit 是一个小工具,用于监控并限制进程对 CPU 的使用率。其特别可以用于将批处理作业对 CPU 的使用率保持在一定范围。
#### 69. lshw

lshw 是一个小的内置工具,能提取关于本机硬件配置的详细信息。它可以输出 CPU 版本和主板配置。
#### 70. w
w 是一个内置命令,用于显示当前登录用户的信息及他们所运行的进程。
#### 71. lsof

lsof 是一个内置的工具,可让你列出所有打开的文件和网络连接。从那里你可以看到文件是由哪个进程打开的,基于进程名可找到其特定的用户,或杀死属于某个用户的所有进程。
### 基础架构监控工具
#### 72. Server Density

我们的 [服务器监控工具](https://www.serverdensity.com/server-monitoring/) 它有一个 web 界面,使你可以进行报警设置并可以通过图表来查看所有系统的网络指标。你还可以设置监控的网站,无论是否在线。Server Density 允许你设置用户的权限,你可以根据我们的插件或 api 来扩展你的监控。该服务已经支持 Nagios 的插件了。
#### 73. [OpenNMS](http://www.opennms.org/)

OpenNMS 主要有四个功能区:事件管理和通知;发现和配置;服务监控和数据收集。其设计为可被在多种网络环境中定制。
#### 74. [SysUsage](http://sysusage.darold.net/)

SysUsage 通过 Sar 和其他系统命令持续监控你的系统。一旦达到阈值它也可以进行报警通知。SysUsage 本身也可以收集所有的统计信息并存储在一个地方。它有一个 Web 界面可以让你查看所有的统计数据。
#### 75. [brainypdm](http://sourceforge.net/projects/brainypdm/)

brainypdm 是一个数据管理和监控工具,它能收集来自 nagios 或其它常规来源的数据并以图表显示。它是跨平台的,其基于 Web 并可自定义图形。
#### 76. [PCP](http://www.pcp.io/)

PCP 可以收集来自多个主机的指标,并且效率很高。它也有一个插件框架,所以你可以让它收集对你很重要的指标。你可以通过任何一个 Web 界面或 GUI 访问图形数据。它比较适合大型监控系统。
#### 77. [KDE 系统守护](https://userbase.kde.org/KSysGuard)

这个工具既是一个系统监控器也是一个任务管理器。你可以通过工作表来查看多台机器的服务指标,如果需要杀死一个进程或者你需要启动一个进程,它可以在 KDE 系统守护中来完成。
#### 78. [Munin](http://munin-monitoring.org/)

Munin 既是一个网络也是系统监控工具,当一个指标超出给定的阈值时它会提供报警机制。它运用 RRDtool 创建图表,并且它也有 Web 界面来显示这些图表。它更强调的是即插即用的功能并且有许多可用的插件。
#### 79. [Nagios](http://www.nagios.org/)

Nagios 是系统和网络监控工具,可帮助你监控多台服务器。当发生错误时它也有报警功能。它的平台也有很多的插件。
#### 80. [Zenoss](http://www.zenoss.com/)

Zenoss 提供了一个 Web 界面,使你可以监控所有的系统及网络指标。此外,它能自动发现网络资源和修改网络配置。并且会提醒你采取行动,它也支持 Nagios 的插件。
#### 81. [Cacti](http://www.cacti.net/)

(和上一个一样!) Cacti 是一个网络图形解决方案,其使用 RRDtool 进行数据存储。它允许用户在预定的时间间隔进行投票服务并将结果以图形显示。Cacti 可以通过 shell 脚本扩展来监控你所选择的来源。
#### 82. [Zabbix](http://www.zabbix.com/)

Zabbix 是一个开源的基础设施监控解决方案。它使用了许多数据库来存放监控统计信息。其核心是用 C 语言编写,并在前端中使用 PHP。如果你不喜欢安装代理端,Zabbix 可能是一个最好选择。
### 附加部分
感谢您的建议。这是我们的一个附加部分,由于我们需要重新编排所有的标题,鉴于此,这是在最后的一个简短部分,根据您的建议添加的一些 Linux 监控工具:
#### 83. [collectd](https://collectd.org/)
Collectd 是一个 Unix 守护进程,用来收集所有的监控数据。它采用了模块化设计并使用插件来填补一些缺陷。这样能使 collectd 保持轻量级并可进行定制。
#### 84. [Observium](http://www.observium.org/)
Observium 是一个自动发现网络的监控平台,支持大量硬件平台和操作系统。Observium 专注于提供一个优美、功能强大、简单直观的界面来显示网络的健康和状态。
#### 85. Nload
这是一个命令行工具来监控网络的吞吐量。它很整洁,因为它使用两个图表和其他一些类似传输的数据总量这样的有用数据来对进出站流量进行可视化。你可以使用如下方法安装它:
```
yum install nload
```
或者
```
sudo apt-get install nload
```
#### 86. [SmokePing](http://oss.oetiker.ch/smokeping/)
SmokePing 可以跟踪你网络延迟,并对他们进行可视化。有各种为 SmokePing 开发的延迟测量插件。如果图形用户界面对你来说非常重要,现在有一个正在开发中的插件来实现此功能。
#### 87. [MobaXterm](http://mobaxterm.mobatek.net/)
如果你整天在 windows 环境下工作。你可能会觉得 Windows 下终端窗口的限制。MobaXterm 正是由此而来的,它允许你使用多个通常出现在 Linux 中的命令。这将会极大地帮助你在监控方面的需求!
#### 88. [Shinken monitoring](http://www.shinken-monitoring.org/)
Shinken 是一个监控框架,其是采用 python 对 Nagios 进行了完全重写。它的目的是增强灵活性和管理更大环境。但仍保持所有的 nagios 配置和插件。
---
via: <https://blog.serverdensity.com/80-linux-monitoring-tools-know/>
作者:[Jonathan Sundqvist](https://www.serverdensity.com/) 译者:[strugglingyouth](https://github.com/strugglingyouth) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPSConnectionPool(host='blog.serverdensity.com', port=443): Read timed out. (read timeout=10) | null |
6,989 | 如何在 Ubuntu 15.04 上安装带 JSON 支持的 SQLite 3.9.1 | http://linoxide.com/ubuntu-how-to/install-sqlite-json-ubuntu-15-04/ | 2016-02-09T10:11:00 | [
"SQLite"
] | /article-6989-1.html | 
欢迎阅读我们关于SQLite 的文章,SQLite 是当今世界上使用最广泛的 SQL 数据库引擎,它基本不需要配置,不需要设置或管理就可以运行。SQLite 是一个是<ruby> 公开领域 <rp> ( </rp> <rt> public-domain </rt> <rp> ) </rp></ruby>的软件,是一个关系型数据库管理系统(RDBMS),用来在一个大数据表中存储用户定义的记录。对于数据存储和管理来说,数据库引擎要处理复杂的查询命令,这些命令可能会从多个表获取数据然后生成报告和数据总结。
SQLite 是一个非常小、轻量级,不需要独立的服务进程或系统。它可以运行在 UNIX,Linux,Mac OS-X,Android,iOS 和 Windows 上,已经被大量的软件程序使用,如 Opera, Ruby On Rails, Adobe System, Mozilla Firefox, Google Chrome 和 Skype。
### 1) 基本需求:
在绝大部分支持 SQLite 的平台上安装 SQLite 基本上并没有复杂的要求。
让我们在 CLI 或者 Secure Shell 上使用 sudo 或者 root 权限登录 Ubuntu 服务器。然后更新系统,这样子就可以让操作系统的软件更新到新版本。
在 Ubuntu 上,使用如下的命令来更新系统的软件源。
```
# apt-get update
```
如果你要在新安装的 Ubuntu 上部署 SQLite,那么你需要安装一些基础的系统管理工具,如 wget, make, unzip, gcc。
要安装 wget,可以使用下面的命令,如果系统提示的话,输入 Y :
```
# apt-get install wget make gcc
```
### 2) 下载 SQLite
要下载 SQLite ,最好是在 [SQLite 官网](https://www.sqlite.org/download.html)下载,如下所示

你也可以直接复制资源的连接然后在命令行使用 wget 下载,如下所示:
```
# wget https://www.sqlite.org/2015/sqlite-autoconf-3090100.tar.gz
```

下载完成之后,解压缩安装包,切换工作目录到解压缩后的 SQLite 目录,使用下面的命令。
```
# tar -zxvf sqlite-autoconf-3090100.tar.gz
```
### 3) 安装 SQLite
现在我们要开始安装、配置刚才下载的 SQLite。在 Ubuntu 上编译、安装 SQLite,运行配置脚本:
```
root@ubuntu-15:~/sqlite-autoconf-3090100# ./configure –prefix=/usr/local
```

配置要上面的安装位置前缀(prefix)之后,运行下面的命令编译安装包。
```
root@ubuntu-15:~/sqlite-autoconf-3090100# make
source='sqlite3.c' object='sqlite3.lo' libtool=yes \
DEPDIR=.deps depmode=none /bin/bash ./depcomp \
/bin/bash ./libtool --tag=CC --mode=compile gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.9.1\" -DPACKAGE_STRING=\"sqlite\ 3.9.1\" -DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.9.1\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_POSIX_FALLOCATE=1 -I. -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2 -c -o sqlite3.lo sqlite3.c
```
运行完上面的命令之后,要在 Ubuntu 上完成 SQLite 的安装得运行下面的命令。
```
# make install
```

### 4) 测试 SQLite 安装
要保证 SQLite 3.9 安装成功了,运行下面的命令。
```
# sqlite3
```
SQLite 的版本会显示在命令行。

### 5) 使用 SQLite
SQLite 很容易上手。要获得详细的使用方法,在SQLite 控制台里输入下面的命令。
```
sqlite> .help
```
这里会显示全部可用的命令和详细说明。

现在开始最后一部分,使用一点 SQLite 命令创建数据库。
要创建一个新的数据库需要运行下面的命令。
```
# sqlite3 test.db
```
然后创建一张新表。
```
sqlite> create table memos(text, priority INTEGER);
```
接着使用下面的命令插入数据。
```
sqlite> insert into memos values('deliver project description', 15);
sqlite> insert into memos values('writing new artilces', 100);
```
要查看插入的数据可以运行下面的命令。
```
sqlite> select * from memos;
deliver project description|15
writing new artilces|100
```
或者使用下面的命令离开。
```
sqlite> .exit
```

### 结论
通过本文你可以了解如果安装支持 JSON1 的最新版的 SQLite,SQLite 从 3.9.0 开始支持 JSON1。这是一个非常棒的库,可以内嵌到应用程序,利用它可以很有效而轻量的管理资源。我们希望你能觉得本文有所帮助,请随意地向我们反馈你遇到的问题和困难。
---
via: <http://linoxide.com/ubuntu-how-to/install-sqlite-json-ubuntu-15-04/>
作者:[Kashif Siddique](http://linoxide.com/author/kashifs/) 译者:[oska874](https://github.com/oska874) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='linoxide.com', port=80): Max retries exceeded with url: /ubuntu-how-to/install-sqlite-json-ubuntu-15-04/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327581270>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.