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,093 | 在 Linux 下使用 RAID(三):用两块磁盘创建 RAID 1(镜像) | http://www.tecmint.com/create-raid1-in-linux/ | 2015-08-26T09:33:00 | [
"RAID"
] | https://linux.cn/article-6093-1.html | **RAID 镜像**意味着相同数据的完整克隆(或镜像),分别写入到两个磁盘中。创建 RAID 1 至少需要两个磁盘,而且仅用于读取性能或者可靠性要比数据存储容量更重要的场合。

*在 Linux 中设置 RAID 1*
创建镜像是为了防止因硬盘故障导致数据丢失。镜像中的每个磁盘包含数据的完整副本。当一个磁盘发生故障时,相同的数据可以从其它正常磁盘中读取。而后,可以从正在运行的计算机中直接更换发生故障的磁盘,无需任何中断。
### RAID 1 的特点
* 镜像具有良好的性能。
* 磁盘利用率为50%。也就是说,如果我们有两个磁盘每个500GB,总共是1TB,但在镜像中它只会显示500GB。
* 在镜像如果一个磁盘发生故障不会有数据丢失,因为两个磁盘中的内容相同。
* 读取性能会比写入性能更好。
#### 要求
创建 RAID 1 至少要有两个磁盘,你也可以添加更多的磁盘,磁盘数需为2,4,6,8等偶数。要添加更多的磁盘,你的系统必须有 RAID 物理适配器(硬件卡)。
这里,我们使用软件 RAID 不是硬件 RAID,如果你的系统有一个内置的物理硬件 RAID 卡,你可以从它的功能界面或使用 Ctrl + I 键来访问它。
需要阅读: [介绍 RAID 的级别和概念](/article-6085-1.html)
#### 在我的服务器安装
```
操作系统 : CentOS 6.5 Final
IP 地址 : 192.168.0.226
主机名 : rd1.tecmintlocal.com
磁盘 1 [20GB] : /dev/sdb
磁盘 2 [20GB] : /dev/sdc
```
本文将指导你在 Linux 平台上使用 mdadm (用于创建和管理 RAID )一步步的建立一个软件 RAID 1 (镜像)。同样的做法也适用于如 RedHat,CentOS,Fedora 等 Linux 发行版。
### 第1步:安装所需软件并且检查磁盘
1、 正如我前面所说,在 Linux 中我们需要使用 mdadm 软件来创建和管理 RAID。所以,让我们用 yum 或 apt-get 的软件包管理工具在 Linux 上安装 mdadm 软件包。
```
# yum install mdadm [在 RedHat 系统]
# apt-get install mdadm [在 Debain 系统]
```
2、 一旦安装好`mdadm`包,我们需要使用下面的命令来检查磁盘是否已经配置好。
```
# mdadm -E /dev/sd[b-c]
```

*检查 RAID 的磁盘*
正如你从上面图片看到的,没有检测到任何超级块,这意味着还没有创建RAID。
### 第2步:为 RAID 创建分区
3、 正如我提到的,我们使用最少的两个分区 /dev/sdb 和 /dev/sdc 来创建 RAID 1。我们首先使用`fdisk`命令来创建这两个分区并更改其类型为 raid。
```
# fdisk /dev/sdb
```
按照下面的说明
* 按 `n` 创建新的分区。
* 然后按 `P` 选择主分区。
* 接下来选择分区号为1。
* 按两次回车键默认将整个容量分配给它。
* 然后,按 `P` 来打印创建好的分区。
* 按 `L`,列出所有可用的类型。
* 按 `t` 修改分区类型。
* 键入 `fd` 设置为 Linux 的 RAID 类型,然后按 Enter 确认。
* 然后再次使用`p`查看我们所做的更改。
* 使用`w`保存更改。

*创建磁盘分区*
在创建“/dev/sdb”分区后,接下来按照同样的方法创建分区 /dev/sdc 。
```
# fdisk /dev/sdc
```

*创建第二个分区*
4、 一旦这两个分区创建成功后,使用相同的命令来检查 sdb 和 sdc 分区并确认 RAID 分区的类型如上图所示。
```
# mdadm -E /dev/sd[b-c]
```

*验证分区变化*

*检查 RAID 类型*
**注意**: 正如你在上图所看到的,在 sdb1 和 sdc1 中没有任何对 RAID 的定义,这就是我们没有检测到超级块的原因。
### 第3步:创建 RAID 1 设备
5、 接下来使用以下命令来创建一个名为 /dev/md0 的“RAID 1”设备并验证它
```
# mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sd[b-c]1
# cat /proc/mdstat
```

*创建RAID设备*
6、 接下来使用如下命令来检查 RAID 设备类型和 RAID 阵列
```
# mdadm -E /dev/sd[b-c]1
# mdadm --detail /dev/md0
```

*检查 RAID 设备类型*

*检查 RAID 设备阵列*
从上图中,人们很容易理解,RAID 1 已经创建好了,使用了 /dev/sdb1 和 /dev/sdc1 分区,你也可以看到状态为 resyncing(重新同步中)。
### 第4步:在 RAID 设备上创建文件系统
7、 给 md0 上创建 ext4 文件系统
```
# mkfs.ext4 /dev/md0
```

*创建 RAID 设备文件系统*
8、 接下来,挂载新创建的文件系统到“/mnt/raid1”,并创建一些文件,验证在挂载点的数据
```
# mkdir /mnt/raid1
# mount /dev/md0 /mnt/raid1/
# touch /mnt/raid1/tecmint.txt
# echo "tecmint raid setups" > /mnt/raid1/tecmint.txt
```

*挂载 RAID 设备*
9、为了在系统重新启动自动挂载 RAID 1,需要在 fstab 文件中添加条目。打开`/etc/fstab`文件并添加以下行:
```
/dev/md0 /mnt/raid1 ext4 defaults 0 0
```

*自动挂载 Raid 设备*
10、 运行`mount -av`,检查 fstab 中的条目是否有错误
```
# mount -av
```

*检查 fstab 中的错误*
11、 接下来,使用下面的命令保存 RAID 的配置到文件“mdadm.conf”中。
```
# mdadm --detail --scan --verbose >> /etc/mdadm.conf
```

*保存 Raid 的配置*
上述配置文件在系统重启时会读取并加载 RAID 设备。
### 第5步:在磁盘故障后检查数据
12、我们的主要目的是,即使在任何磁盘故障或死机时必须保证数据是可用的。让我们来看看,当任何一个磁盘不可用时会发生什么。
```
# mdadm --detail /dev/md0
```

*验证 RAID 设备*
在上面的图片中,我们可以看到在 RAID 中有2个设备是可用的,并且 Active Devices 是2。现在让我们看看,当一个磁盘拔出(移除 sdc 磁盘)或损坏后会发生什么。
```
# ls -l /dev | grep sd
# mdadm --detail /dev/md0
```

*测试 RAID 设备*
现在,在上面的图片中你可以看到,一个磁盘不见了。我从虚拟机上删除了一个磁盘。此时让我们来检查我们宝贵的数据。
```
# cd /mnt/raid1/
# cat tecmint.txt
```

*验证 RAID 数据*
你可以看到我们的数据仍然可用。由此,我们可以了解 RAID 1(镜像)的优势。在接下来的文章中,我们将看到如何设置一个 RAID 5 条带化分布式奇偶校验。希望这可以帮助你了解 RAID 1(镜像)是如何工作的。
---
via: <http://www.tecmint.com/create-raid1-in-linux/>
作者:[Babin Lonston](http://www.tecmint.com/author/babinlonston/) 译者:[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,095 | Ubuntu 下五个最好的 BT 客户端 | http://itsfoss.com/best-torrent-ubuntu/ | 2015-08-26T13:47:00 | [
"BT"
] | https://linux.cn/article-6095-1.html | 
在寻找 **Ubuntu 中最好的 BT 客户端**吗?事实上,Linux 桌面平台中有许多 BT 客户端,但是它们中的哪些才是**最好的 Ubuntu 客户端**呢?
我将会列出 Linux 上最好的五个 BT 客户端,它们都拥有着体积轻盈,功能强大的特点,而且还有令人印象深刻的用户界面。自然,易于安装和使用也是特性之一。
### Ubuntu 下最好的 BT 客户端
考虑到 Ubuntu 默认安装了 Transmission,所以我将会从这个列表中排除了 Transmission。但是这并不意味着 Transmission 没有资格出现在这个列表中,事实上,Transmission 是一个非常好的BT客户端,这也正是它被包括 Ubuntu 在内的多个发行版默认安装的原因。
### Deluge

[Deluge](http://deluge-torrent.org/) 被 Lifehacker 评选为 Linux 下最好的 BT 客户端,这说明了 Deluge 是多么的有用。而且,并不仅仅只有 Lifehacker 是 Deluge 的粉丝,纵观多个论坛,你都会发现不少 Deluge 的忠实拥趸。
快速,时尚而直观的界面使得 Deluge 成为 Linux 用户的挚爱。
Deluge 可在 Ubuntu 的仓库中获取,你能够在 Ubuntu 软件中心中安装它,或者使用下面的命令:
```
sudo apt-get install deluge
```
### qBittorrent

正如它的名字所暗示的,[qBittorrent](http://www.qbittorrent.org/) 是著名的 [Bittorrent](http://www.bittorrent.com/) 应用的 Qt 版本。如果曾经使用过它,你将会看到和 Windows 下的 Bittorrent 相似的界面。同样轻巧并且有着 BT 客户端的所有标准功能, qBittorrent 也可以在 Ubuntu 的默认仓库中找到。
它可以通过 Ubuntu 软件仓库安装,或者使用下面的命令:
```
sudo apt-get install qbittorrent
```
### Tixati

[Tixati](http://www.tixati.com/) 是另一个不错的 Ubuntu 下的 BT 客户端。它有着一个默认的黑暗主题,尽管很多人喜欢,但是我例外。它拥有着一切你能在 BT 客户端中找到的功能。
除此之外,它还有着数据分析的额外功能。你可以在美观的图表中分析流量以及其它数据。
* [下载 Tixati](http://www.tixati.com/download/)
### Vuze

[Vuze](http://www.vuze.com/) 是许多 Linux 以及 Windows 用户最喜欢的 BT 客户端。除了标准的功能,你可以直接在应用程序中搜索种子,也可以订阅系列片源,这样就无需再去寻找新的片源了,因为你可以在侧边栏中的订阅看到它们。
它还配备了一个视频播放器,可以播放带有字幕的高清视频等等。但是我不认为你会用它来代替那些更好的视频播放器,比如 VLC。
Vuze 可以通过 Ubuntu 软件中心安装或者使用下列命令:
```
sudo apt-get install vuze
```
### Frostwire

[Frostwire](http://www.frostwire.com/) 是一个你应该试一下的应用。它不仅仅是一个简单的 BT 客户端,它还可以应用于安卓,你可以用它通过 Wifi 来共享文件。
你可以在应用中搜索种子并且播放他们。除了下载文件,它还可以浏览本地的影音文件,并且将它们有条理的呈现在播放器中。这同样适用于安卓版本。
还有一个特点是:Frostwire 提供了独立音乐人的[合法音乐下载](http://www.frostclick.com/wp/)。你可以下载并且欣赏它们,免费而且合法。
* [下载 Frostwire](http://www.frostwire.com/downloads)
### 荣誉奖
在 Windows 中,uTorrent(发音:mu torrent)是我最喜欢的 BT 应用。尽管 uTorrent 可以在 Linux 下运行,但是我还是特意忽略了它。因为在 Linux 下使用 uTorrent 不仅困难,而且无法获得完整的应用体验(运行在浏览器中)。
可以[在这里](http://sysads.co.uk/2014/05/install-utorrent-3-3-ubuntu-14-04-13-10/)阅读 Ubuntu下uTorrent 的安装教程。
#### 快速提示:
大多数情况下,BT 应用不会默认自动启动。如果想改变这一行为,请阅读[如何管理 Ubuntu 下的自启动程序](http://itsfoss.com/manage-startup-applications-ubuntu/)来学习。
### 你最喜欢的是什么?
这些是我对于 Ubuntu 下最好的 BT 客户端的意见。你最喜欢的是什么呢?请发表评论。也可以查看与本主题相关的[Ubuntu 最好的下载管理器](http://itsfoss.com/4-best-download-managers-for-linux/)。如果使用 Popcorn Time,试试 [Popcorn Time 技巧](http://itsfoss.com/popcorn-time-tips/)
---
via: <http://itsfoss.com/best-torrent-ubuntu/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[Xuanwo](https://github.com/Xuanwo) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,097 | KDE Plasma 5.4.0 发布,八月特色版 | https://www.kde.org/announcements/plasma-5.4.0.php | 2015-08-27T08:26:00 | [
"KDE",
"Plasma"
] | https://linux.cn/article-6097-1.html | 
2015 年 8 月 25 ,星期二,KDE 发布了 Plasma 5 的一个特色新版本。
此版本为我们带来了许多非常棒的感受,如优化了对高分辨率的支持,KRunner 自动补全和一些新的 Breeze 漂亮图标。这还为不久以后的技术预览版的 Wayland 桌面奠定了基础。我们还带来了几个新组件,如声音音量部件,显示器校准工具和测试版的用户管理工具。
### 新的音频音量程序

新的音频音量程序直接工作于 PulseAudio (Linux 上一个非常流行的音频服务) 之上 ,并且在一个漂亮的简约的界面提供一个完整的音量控制和输出设定。
### 替代的应用控制面板起动器

Plasma 5.4 在 kdeplasma-addons 软件包中提供了一个全新的全屏的应用控制面板,它具有应用菜单的所有功能,还支持缩放和全空间键盘导航。新的起动器可以像你目前所用的“最近使用的”或“收藏的文档和联系人”一样简单和快速地查找应用。
### 丰富的艺术图标

Plasma 5.4 提供了超过 1400 个的新图标,其中不仅包含 KDE 程序的,而且还为 Inkscape, Firefox 和 Libreoffice 提供 Breeze 主题的艺术图标,可以体验到更加一致和本地化的感觉。
### KRunner 历史记录

KRunner 现在可以记住之前的搜索历史并根据历史记录进行自动补全。
### Network 程序中实用的图形展示

Network 程序现在可以以图形形式显示网络流量了,同时也支持两个新的 VPN 插件:通过 SSH 连接或通过 SSTP 连接。
### Wayland 技术预览
随着 Plasma 5.4 ,Wayland 桌面发布了第一个技术预览版。在使用自由图形驱动(free graphics drivers)的系统上可以使用 KWin(Plasma 的 Wayland 合成器和 X11 窗口管理器)通过[内核模式设定](https://en.wikipedia.org/wiki/Direct_Rendering_Manager)来运行 Plasma。现在已经支持的功能需求来自于[手机 Plasma 项目](https://dot.kde.org/2015/07/25/plasma-mobile-free-mobile-platform),更多的面向桌面的功能还未被完全实现。现在还不能作为替换那些基于 Xorg 的桌面,但可以轻松地对它测试和贡献,以及观看令人激动视频。有关如何在 Wayland 中使用 Plasma 的介绍请到:[KWin 维基页](https://community.kde.org/KWin/Wayland#Start_a_Plasma_session_on_Wayland)。Wlayland 将随着我们构建的稳定版本而逐步得到改进。
### 其他的改变和添加
* 优化对高 DPI 支持
* 更少的内存占用
* 桌面搜索使用了更快的新后端
* 便笺增加拖拉支持和键盘导航
* 回收站重新支持拖拉
* 系统托盘获得更快的可配置性
* 文档重新修订和更新
* 优化了窄小面板上的数字时钟的布局
* 数字时钟支持 ISO 日期
* 切换数字时钟 12/24 格式更简单
* 日历显示第几周
* 任何项目都可以收藏进应用菜单(Kicker),支持收藏文档和 Telepathy 联系人
* Telepathy 联系人收藏可以展示联系人的照片和实时状态
* 优化程序与容器间的焦点和激活处理
* 文件夹视图中各种小修复:更好的默认尺寸,鼠标交互问题以及文本标签换行
* 任务管理器更好的呈现起动器默认的应用图标
* 可再次通过将程序拖入任务管理器来添加启动器
* 可配置中间键点击在任务管理器中的行为:无动作,关闭窗口,启动一个相同的程序的新实例
* 任务管理器现在以列排序优先,无论用户是否更倾向于行优先;许多用户更喜欢这样排序是因为它会使更少的任务按钮像窗口一样移来移去
* 优化任务管理器的图标和缩放边
* 任务管理器中各种小修复:垂直下拉,触摸事件处理现在支持所有系统,组扩展箭头的视觉问题
* 提供可用的目的框架技术预览版,可以使用 QuickShare Plasmoid,它可以让许多 web 服务分享文件更容易
* 增加了显示器配置工具
* 增加的 kwallet-pam 可以在登录时打开 wallet
* 用户管理器现在会同步联系人到 KConfig 的设置中,用户账户模块被丢弃了
* 应用程序菜单(Kicker)的性能得到改善
* 应用程序菜单(Kicker)各种小修复:隐藏/显示程序更加可靠,顶部面板的对齐修复,文件夹视图中 “添加到桌面”更加可靠,在基于 KActivities 的最新模块中有更好的表现
* 支持自定义菜单布局 (kmenuedit)和应用程序菜单(Kicker)支持菜单项目分隔
* 当在面板中时,改进了文件夹视图,参见 [blog](https://blogs.kde.org/2015/06/04/folder-view-panel-popups-are-list-views-again)
* 将文件夹拖放到桌面容器现在会再次创建一个文件夹视图
[完整的 Plasma 5.4 变更日志在此](https://www.kde.org/announcements/plasma-5.3.2-5.4.0-changelog.php)。
### Live 镜像
尝鲜的最简单的方式就是从 U 盘中启动,可以在 KDE 社区 Wiki 中找到 各种 [带有 Plasma 5 的 Live 镜像](https://community.kde.org/Plasma/LiveImages)。
### 下载软件包
各发行版已经构建了软件包,或者正在构建,wiki 中的列出了各发行版的软件包名:[软件包下载维基页](https://community.kde.org/Plasma/Packages)。
### 源码下载
可以直接从源码中安装 Plasma 5。KDE 社区 Wiki 已经介绍了[怎样编译](http://community.kde.org/Frameworks/Building)。
注意,Plasma 5 与 Plasma 4 不兼容,必须先卸载旧版本,或者安装到不同的前缀处。
* [源代码信息页](https://www.kde.org/info/plasma-5.4.0.php)
---
via: <https://www.kde.org/announcements/plasma-5.4.0.php>
译者:[Locez](http://locez.com) 校对:[wxy](http://github.com/wxy)
| 301 | Moved Permanently | null |
6,102 | 在 Linux 下使用 RAID(四):创建 RAID 5(条带化与分布式奇偶校验) | http://www.tecmint.com/create-raid-5-in-linux/ | 2015-08-27T13:08:44 | [
"RAID"
] | https://linux.cn/article-6102-1.html | 在 RAID 5 中,数据条带化后存储在分布式奇偶校验的多个磁盘上。分布式奇偶校验的条带化意味着它将奇偶校验信息和条带化数据分布在多个磁盘上,这样会有很好的数据冗余。

*在 Linux 中配置 RAID 5*
对于此 RAID 级别它至少应该有三个或更多个磁盘。RAID 5 通常被用于大规模生产环境中,以花费更多的成本来提供更好的数据冗余性能。
#### 什么是奇偶校验?
奇偶校验是在数据存储中检测错误最简单的常见方式。奇偶校验信息存储在每个磁盘中,比如说,我们有4个磁盘,其中相当于一个磁盘大小的空间被分割去存储所有磁盘的奇偶校验信息。如果任何一个磁盘出现故障,我们可以通过更换故障磁盘后,从奇偶校验信息重建得到原来的数据。
#### RAID 5 的优点和缺点
* 提供更好的性能。
* 支持冗余和容错。
* 支持热备份。
* 将用掉一个磁盘的容量存储奇偶校验信息。
* 单个磁盘发生故障后不会丢失数据。我们可以更换故障硬盘后从奇偶校验信息中重建数据。
* 适合于面向事务处理的环境,读操作会更快。
* 由于奇偶校验占用资源,写操作会慢一些。
* 重建需要很长的时间。
#### 要求
创建 RAID 5 最少需要3个磁盘,你也可以添加更多的磁盘,前提是你要有多端口的专用硬件 RAID 控制器。在这里,我们使用“mdadm”包来创建软件 RAID。
mdadm 是一个允许我们在 Linux 下配置和管理 RAID 设备的包。默认情况下没有 RAID 的配置文件,我们在创建和配置 RAID 后必须将配置文件保存在一个单独的文件 mdadm.conf 中。
在进一步学习之前,我建议你通过下面的文章去了解 Linux 中 RAID 的基础知识。
* [介绍 RAID 的级别和概念](/article-6085-1.html)
* [使用 mdadm 工具创建软件 RAID 0 (条带化)](/article-6087-1.html)
* [用两块磁盘创建 RAID 1(镜像)](/article-6093-1.html)
#### 我的服务器设置
```
操作系统 : CentOS 6.5 Final
IP 地址 : 192.168.0.227
主机名 : rd5.tecmintlocal.com
磁盘 1 [20GB] : /dev/sdb
磁盘 2 [20GB] : /dev/sdc
磁盘 3 [20GB] : /dev/sdd
```
这是9篇系列教程的第4部分,在这里我们要在 Linux 系统或服务器上使用三个20GB(名为/dev/sdb, /dev/sdc 和 /dev/sdd)的磁盘建立带有分布式奇偶校验的软件 RAID 5。
### 第1步:安装 mdadm 并检验磁盘
1、 正如我们前面所说,我们使用 CentOS 6.5 Final 版本来创建 RAID 设置,但同样的做法也适用于其他 Linux 发行版。
```
# lsb_release -a
# ifconfig | grep inet
```

*CentOS 6.5 摘要*
2、 如果你按照我们的 RAID 系列去配置的,我们假设你已经安装了“mdadm”包,如果没有,根据你的 Linux 发行版使用下面的命令安装。
```
# yum install mdadm [在 RedHat 系统]
# apt-get install mdadm [在 Debain 系统]
```
3、 “mdadm”包安装后,先使用`fdisk`命令列出我们在系统上增加的三个20GB的硬盘。
```
# fdisk -l | grep sd
```

*安装 mdadm 工具*
4、 现在该检查这三个磁盘是否存在 RAID 块,使用下面的命令来检查。
```
# mdadm -E /dev/sd[b-d]
# mdadm --examine /dev/sdb /dev/sdc /dev/sdd # 或
```

*检查 Raid 磁盘*
**注意**: 上面的图片说明,没有检测到任何超级块。所以,这三个磁盘中没有定义 RAID。让我们现在开始创建一个吧!
### 第2步:为磁盘创建 RAID 分区
5、 首先,在创建 RAID 前磁盘(/dev/sdb, /dev/sdc 和 /dev/sdd)必须有分区,因此,在进行下一步之前,先使用`fdisk`命令进行分区。
```
# fdisk /dev/sdb
# fdisk /dev/sdc
# fdisk /dev/sdd
```
#### 创建 /dev/sdb 分区
请按照下面的说明在 /dev/sdb 硬盘上创建分区。
* 按 `n` 创建新的分区。
* 然后按 `P` 选择主分区。选择主分区是因为还没有定义过分区。
* 接下来选择分区号为1。默认就是1。
* 这里是选择柱面大小,我们没必要选择指定的大小,因为我们需要为 RAID 使用整个分区,所以只需按两次 Enter 键默认将整个容量分配给它。
* 然后,按 `P` 来打印创建好的分区。
* 改变分区类型,按 `L`可以列出所有可用的类型。
* 按 `t` 修改分区类型。
* 这里使用`fd`设置为 RAID 的类型。
* 然后再次使用`p`查看我们所做的更改。
* 使用`w`保存更改。

*创建 sdb 分区*
**注意**: 我们仍要按照上面的步骤来创建 sdc 和 sdd 的分区。
#### 创建 /dev/sdc 分区
现在,通过下面的截图给出创建 sdc 和 sdd 磁盘分区的方法,或者你可以按照上面的步骤。
```
# fdisk /dev/sdc
```

*创建 sdc 分区*
#### 创建 /dev/sdd 分区
```
# fdisk /dev/sdd
```

*创建 sdd 分区*
6、 创建分区后,检查三个磁盘 sdb, sdc, sdd 的变化。
```
# mdadm --examine /dev/sdb /dev/sdc /dev/sdd
# mdadm -E /dev/sd[b-c] # 或
```

*检查磁盘变化*
**注意**: 在上面的图片中,磁盘的类型是 fd。
7、 现在在新创建的分区检查 RAID 块。如果没有检测到超级块,我们就能够继续下一步,在这些磁盘中创建一个新的 RAID 5 配置。

\*在分区中检查 RAID \*
### 第3步:创建 md 设备 md0
8、 现在使用所有新创建的分区(sdb1, sdc1 和 sdd1)创建一个 RAID 设备“md0”(即 /dev/md0),使用以下命令。
```
# mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1
# mdadm -C /dev/md0 -l=5 -n=3 /dev/sd[b-d]1 # 或
```
9、 创建 RAID 设备后,检查并确认 RAID,从 mdstat 中输出中可以看到包括的设备的 RAID 级别。
```
# cat /proc/mdstat
```

*验证 Raid 设备*
如果你想监视当前的创建过程,你可以使用`watch`命令,将 `cat /proc/mdstat` 传递给它,它会在屏幕上显示且每隔1秒刷新一次。
```
# watch -n1 cat /proc/mdstat
```

*监控 RAID 5 构建过程*

*Raid 5 过程概要*
10、 创建 RAID 后,使用以下命令验证 RAID 设备
```
# mdadm -E /dev/sd[b-d]1
```

*验证 Raid 级别*
**注意**: 因为它显示三个磁盘的信息,上述命令的输出会有点长。
11、 接下来,验证 RAID 阵列,假定包含 RAID 的设备正在运行并已经开始了重新同步。
```
# mdadm --detail /dev/md0
```

*验证 RAID 阵列*
### 第4步:为 md0 创建文件系统
12、 在挂载前为“md0”设备创建 ext4 文件系统。
```
# mkfs.ext4 /dev/md0
```

*创建 md0 文件系统*
13、 现在,在`/mnt`下创建目录 raid5,然后挂载文件系统到 /mnt/raid5/ 下,并检查挂载点下的文件,你会看到 lost+found 目录。
```
# mkdir /mnt/raid5
# mount /dev/md0 /mnt/raid5/
# ls -l /mnt/raid5/
```
14、 在挂载点 /mnt/raid5 下创建几个文件,并在其中一个文件中添加一些内容然后去验证。
```
# touch /mnt/raid5/raid5_tecmint_{1..5}
# ls -l /mnt/raid5/
# echo "tecmint raid setups" > /mnt/raid5/raid5_tecmint_1
# cat /mnt/raid5/raid5_tecmint_1
# cat /proc/mdstat
```

*挂载 RAID 设备*
15、 我们需要在 fstab 中添加条目,否则系统重启后将不会显示我们的挂载点。编辑 fstab 文件添加条目,在文件尾追加以下行。挂载点会根据你环境的不同而不同。
```
# vim /etc/fstab
/dev/md0 /mnt/raid5 ext4 defaults 0 0
```

*自动挂载 RAID 5*
16、 接下来,运行`mount -av`命令检查 fstab 条目中是否有错误。
```
# mount -av
```

*检查 Fstab 错误*
### 第5步:保存 Raid 5 的配置
17、 在前面章节已经说过,默认情况下 RAID 没有配置文件。我们必须手动保存。如果此步中没有跟随不属于 md0 的 RAID 设备,它会是一些其他随机数字。
所以,我们必须要在系统重新启动之前保存配置。如果配置保存它在系统重新启动时会被加载到内核中然后 RAID 也将被加载。
```
# mdadm --detail --scan --verbose >> /etc/mdadm.conf
```

*保存 RAID 5 配置*
注意:保存配置将保持 md0 设备的 RAID 级别稳定不变。
### 第6步:添加备用磁盘
18、 备用磁盘有什么用?它是非常有用的,如果我们有一个备用磁盘,当我们阵列中的任何一个磁盘发生故障后,这个备用磁盘会进入激活重建过程,并从其他磁盘上同步数据,这样就有了冗余。
更多关于添加备用磁盘和检查 RAID 5 容错的指令,请阅读下面文章中的第6步和第7步。
* [在 RAID 5 中添加备用磁盘](http://www.tecmint.com/create-raid-6-in-linux/)
### 结论
在这篇文章中,我们已经看到了如何使用三个磁盘配置一个 RAID 5 。在接下来的文章中,我们将看到如何故障排除并且当 RAID 5 中的一个磁盘损坏后如何恢复。
---
via: <http://www.tecmint.com/create-raid-5-in-linux/>
作者:[Babin Lonston](http://www.tecmint.com/author/babinlonston/) 译者:[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,103 | 如何在 Docker 容器中运行 Kali Linux 2.0 | http://linuxpitstop.com/run-kali-linux-2-0-in-docker-container/ | 2015-08-27T13:31:00 | [
"Docker",
"Kali"
] | https://linux.cn/article-6103-1.html | ### 介绍
Kali Linux 是一个对于安全测试人员和白帽的一个知名操作系统。它带有大量安全相关的程序,这让它很容易用于渗透测试。最近,[Kali Linux 2.0](/article-6005-1.html) 发布了,它被认为是这个操作系统最重要的一次发布。另一方面,Docker 技术由于它的可扩展性和易用性让它变得很流行。Dokcer 让你非常容易地将你的程序带给你的用户。好消息是你可以通过 Docker 运行Kali Linux 了,让我们看看该怎么做 :)

### 在 Docker 中运行 Kali Linux 2.0
**相关提示**
>
> 如果你还没有在系统中安装docker,你可以运行下面的命令:
>
>
> **对于 Ubuntu/Linux Mint/Debian:**
>
>
>
> ```
> sudo apt-get install docker
>
> ```
>
> **对于 Fedora/RHEL/CentOS:**
>
>
>
> ```
> sudo yum install docker
>
> ```
>
> **对于 Fedora 22:**
>
>
>
> ```
> dnf install docker
>
> ```
>
> 你可以运行下面的命令来启动docker:
>
>
>
> ```
> sudo docker start
>
> ```
>
>
首先运行下面的命令确保 Docker 服务运行正常:
```
sudo docker status
```
Kali Linux 的开发团队已将 Kali Linux 的 docker 镜像上传了,只需要输入下面的命令来下载镜像。
```
docker pull kalilinux/kali-linux-docker
```

下载完成后,运行下面的命令来找出你下载的 docker 镜像的 ID。
```
docker images
```

现在运行下面的命令来从镜像文件启动 kali linux docker 容器(这里需用正确的镜像ID替换)。
```
docker run -i -t 198cd6df71ab3 /bin/bash
```
它会立刻启动容器并且让你登录到该操作系统,你现在可以在 Kaili Linux 中工作了。

你可以在容器外面通过下面的命令来验证容器已经启动/运行中了:
```
docker ps
```

### 总结
Docker 是一种最聪明的用来部署和分发包的方式。Kali Linux docker 镜像非常容易上手,也不会消耗很大的硬盘空间,这样也可以很容易地在任何安装了 docker 的操作系统上测试这个很棒的发行版了。
---
via: <http://linuxpitstop.com/run-kali-linux-2-0-in-docker-container/>
作者:[Aun](http://linuxpitstop.com/author/aun/) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 404 | Not Found | null |
6,104 | 使用 dd 命令进行硬盘 I/O 性能检测 | http://www.cyberciti.biz/faq/howto-linux-unix-test-disk-performance-with-dd-command/ | 2015-08-28T07:30:00 | [
"dd",
"硬盘"
] | https://linux.cn/article-6104-1.html | 如何使用dd命令测试我的硬盘性能?如何在linux操作系统下检测硬盘的读写速度?
你可以使用以下命令在一个Linux或类Unix操作系统上进行简单的I/O性能测试。
* **dd命令** :它被用来在Linux和类Unix系统下对硬盘设备进行写性能的检测。
* **hparm命令**:它用来在基于 Linux 的系统上获取或设置硬盘参数,包括测试读性能以及缓存性能等。
在这篇指南中,你将会学到如何使用dd命令来测试硬盘性能。

### 使用dd命令来监控硬盘的读写性能:
* 打开shell终端。
* 或者通过ssh登录到远程服务器。
* 使用dd命令来测量服务器的吞吐率(写速度) `dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync`
* 使用dd命令测量服务器延迟 `dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync`
#### 理解dd命令的选项
在这个例子当中,我将使用搭载Ubuntu Linux 14.04 LTS系统的RAID-10(配有SAS SSD的Adaptec 5405Z)服务器阵列来运行。基本语法为:
```
dd if=/dev/input.file of=/path/to/output.file bs=block-size count=number-of-blocks oflag=dsync
## GNU dd语法 ##
dd if=/dev/zero of=/tmp/test1.img bs=1G count=1 oflag=dsync
##另外一种GNU dd的语法 ##
dd if=/dev/zero of=/tmp/testALT.img bs=1G count=1 conv=fdatasync
```
输出样例:

*图01: 使用dd命令获取的服务器吞吐率*
请各位注意在这个实验中,我们写入一个G的数据,可以发现,服务器的吞吐率是135 MB/s,这其中
* `if=/dev/zero` (if=/dev/input.file) :用来设置dd命令读取的输入文件名。
* `of=/tmp/test1.img` (of=/path/to/output.file):dd命令将input.file写入的输出文件的名字。
* `bs=1G` (bs=block-size) :设置dd命令读取的块的大小。例子中为1个G。
* `count=1` (count=number-of-blocks):dd命令读取的块的个数。
* `oflag=dsync` (oflag=dsync) :使用同步I/O。不要省略这个选项。这个选项能够帮助你去除caching的影响,以便呈现给你精准的结果。
* `conv=fdatasyn`: 这个选项和`oflag=dsync`含义一样。
在下面这个例子中,一共写了1000次,每次写入512字节来获得RAID10服务器的延迟时间:
```
dd if=/dev/zero of=/tmp/test2.img bs=512 count=1000 oflag=dsync
```
输出样例:
```
1000+0 records in
1000+0 records out
512000 bytes (512 kB) copied, 0.60362 s, 848 kB/s
```
请注意服务器的吞吐率以及延迟时间也取决于服务器/应用的负载。所以我推荐你在一个刚刚重启过并且处于峰值时间的服务器上来运行测试,以便得到更加准确的度量。现在你可以在你的所有设备上互相比较这些测试结果了。
### 为什么服务器的吞吐率和延迟时间都这么差?
低的数值并不意味着你在使用差劲的硬件。可能是硬件 RAID10的控制器缓存导致的。
使用hdparm命令来查看硬盘缓存的读速度。
我建议你运行下面的命令2-3次来对设备读性能进行检测,以作为参照和相互比较:
```
### 有缓存的硬盘读性能测试——/dev/sda ###
hdparm -t /dev/sda1
## 或者 ##
hdparm -t /dev/sda
```
然后运行下面这个命令2-3次来对缓存的读性能进行对照性检测:
```
## Cache读基准——/dev/sda ###
hdparm -T /dev/sda1
## 或者 ##
hdparm -T /dev/sda
```
或者干脆把两个测试结合起来:
```
hdparm -Tt /dev/sda
```
输出样例:

*图02: 检测硬盘读入以及缓存性能的Linux hdparm命令*
请再次注意,由于文件文件操作的缓存属性,你将总是会看到很高的读速度。
### 使用dd命令来测试读取速度
为了获得精确的读测试数据,首先在测试前运行下列命令,来将缓存设置为无效:
```
flush
echo 3 | sudo tee /proc/sys/vm/drop_caches
time time dd if=/path/to/bigfile of=/dev/null bs=8k
```
#### 笔记本上的示例
运行下列命令:
```
### 带有Cache的Debian系统笔记本吞吐率###
dd if=/dev/zero of=/tmp/laptop.bin bs=1G count=1 oflag=direct
###使cache失效###
hdparm -W0 /dev/sda
###没有Cache的Debian系统笔记本吞吐率###
dd if=/dev/zero of=/tmp/laptop.bin bs=1G count=1 oflag=direct
```
#### 苹果OS X Unix(Macbook pro)的例子
GNU dd has many more options but OS X/BSD and Unix-like dd command need to run as follows to test real disk I/O and not memory add sync option as follows:
GNU dd命令有其他许多选项,但是在 OS X/BSD 以及类Unix中, dd命令需要像下面那样执行来检测去除掉内存地址同步的硬盘真实I/O性能:
```
## 运行这个命令2-3次来获得更好地结果 ###
time sh -c "dd if=/dev/zero of=/tmp/testfile bs=100k count=1k && sync"
```
输出样例:
```
1024+0 records in
1024+0 records out
104857600 bytes transferred in 0.165040 secs (635346520 bytes/sec)
real 0m0.241s
user 0m0.004s
sys 0m0.113s
```
本人Macbook Pro的写速度是635346520字节(635.347MB/s)。
### 不喜欢用命令行?
你可以在Linux或基于Unix的系统上使用disk utility(gnome-disk-utility)这款工具来得到同样的信息。下面的那个图就是在我的Fedora Linux v22 VM上截取的。
#### 图形化方法
点击“Activites”或者“Super”按键来在桌面和Activites视图间切换。输入“Disks”

*图03: 打开Gnome硬盘工具*
在左边的面板上选择你的硬盘,点击configure按钮,然后点击“Benchmark partition”:

*图04: 评测硬盘/分区*
最后,点击“Start Benchmark...”按钮(你可能需要输入管理员用户名和密码):

*图05: 最终的评测结果*
如果你要问,我推荐使用哪种命令和方法?
* 我推荐在所有的类Unix系统上使用dd命令(`time sh -c "dd if=/dev/zero of=/tmp/testfile bs=100k count=1k && sync`)
* 如果你在使用GNU/Linux,使用dd命令 (`dd if=/dev/zero of=/tmp/testALT.img bs=1G count=1 conv=fdatasync`)
* 确保你每次使用时,都调整了count以及bs参数以获得更好的结果。
* GUI方法只适合桌面系统为Gnome2或Gnome3的Linux/Unix笔记本用户。
---
via: <http://www.cyberciti.biz/faq/howto-linux-unix-test-disk-performance-with-dd-command/>
作者:Vivek Gite 译者:[DongShuaike](https://github.com/DongShuaike) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,105 | Linux有问必答:如何检查MariaDB服务端版本 | http://ask.xmodulo.com/check-mariadb-server-version.html | 2015-08-28T08:12:00 | [
"MariaDB"
] | /article-6105-1.html |
>
> **提问**: 我使用的是一台运行MariaDB的VPS。我该如何检查MariaDB服务端的版本?
>
>
>
有时候你需要知道你的数据库版本,比如当你升级你数据库或对已知缺陷打补丁时。这里有几种方法找出MariaDB版本的方法。

### 方法一
第一种找出版本的方法是登录MariaDB服务器,登录之后,你会看到一些MariaDB的版本信息。

另一种方法是在登录MariaDB后出现的命令行中输入‘status’命令。输出会显示服务器的版本还有协议版本。

### 方法二
如果你不能访问MariaDB服务器,那么你就不能用第一种方法。这种情况下你可以根据MariaDB的安装包的版本来推测。这种方法只有在MariaDB通过包管理器安装的才有用。
你可以用下面的方法检查MariaDB的安装包。
#### Debian、Ubuntu或者Linux Mint:
```
$ dpkg -l | grep mariadb
```
下面的输出说明MariaDB的版本是10.0.17。

#### Fedora、CentOS或者 RHEL:
```
$ rpm -qa | grep mariadb
```
下面的输出说明安装的版本是5.5.41。

---
via: <http://ask.xmodulo.com/check-mariadb-server-version.html>
作者:[Dan Nanni](http://ask.xmodulo.com/author/nanni) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='ask.xmodulo.com', port=80): Max retries exceeded with url: /check-mariadb-server-version.html (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7b8327580f40>: Failed to resolve 'ask.xmodulo.com' ([Errno -2] Name or service not known)")) | null |
6,106 | Linux中通过命令行监控股票报价 | http://xmodulo.com/monitor-stock-quotes-command-line-linux.html | 2015-08-28T09:33:00 | [
"Mop",
"股票",
"终端"
] | https://linux.cn/article-6106-1.html | 如果你是那些股票投资者或者交易者中的一员,那么监控证券市场将是你的日常工作之一。最有可能的是你会使用一个在线交易平台,这个平台有着一些漂亮的实时图表和全部种类的高级股票分析和交易工具。虽然这种复杂的市场研究工具是任何严肃的证券投资者了解市场的必备工具,但是监控最新的股票报价来构建有利可图的投资组合仍然有很长一段路要走。
如果你是一位长久坐在终端前的全职系统管理员,而证券交易又成了你日常生活中的业余兴趣,那么一个简单地显示实时股票报价的命令行工具会是给你的恩赐。
在本教程中,让我来介绍一个灵巧而简洁的命令行工具,它可以让你在Linux上从命令行监控股票报价。

这个工具叫做[Mop](https://github.com/michaeldv/mop)。它是用GO编写的一个轻量级命令行工具,可以极其方便地跟踪来自美国市场的最新股票报价。你可以很轻松地自定义要监控的证券列表,它会在一个基于ncurses的便于阅读的界面显示最新的股票报价。
**注意**:Mop是通过雅虎金融API获取最新的股票报价的。你必须意识到,他们的的股票报价已知会有15分钟的延时。所以,如果你正在寻找0延时的“实时”股票报价,那么Mop就不是你的菜了。这种“现场”股票报价订阅通常可以通过向一些不开放的私有接口付费获取。了解这些之后,让我们来看看怎样在Linux环境下使用Mop吧。
### 安装 Mop 到 Linux
由于Mop是用Go实现的,你首先需要安装Go语言。如果你还没有安装Go,请参照[此指南](http://ask.xmodulo.com/install-go-language-linux.html)将Go安装到你的Linux平台中。请确保按指南中所讲的设置GOPATH环境变量。
安装完Go后,继续像下面这样安装Mop。
**Debian,Ubuntu 或 Linux Mint**
```
$ sudo apt-get install git
$ go get github.com/michaeldv/mop
$ cd $GOPATH/src/github.com/michaeldv/mop
$ make install
```
**Fedora,CentOS,RHEL**
```
$ sudo yum install git
$ go get github.com/michaeldv/mop
$ cd $GOPATH/src/github.com/michaeldv/mop
$ make install
```
上述命令将安装Mop到$GOPATH/bin。
现在,编辑你的.bashrc,将$GOPATH/bin写到你的PATH变量中。
```
export PATH="$PATH:$GOPATH/bin"
```
---
```
$ source ~/.bashrc
```
### 使用Mop来通过命令行监控股票报价
要启动Mop,只需运行名为cmd的命令(LCTT 译注:这名字实在是……)。
```
$ cmd
```
首次启动,你将看到一些Mop预配置的证券行情自动收录器。

报价显示了像最新价格、交易百分比、每日低/高、52周低/高、股息以及年收益率等信息。Mop从[CNN](http://money.cnn.com/data/markets/)获取市场总览信息,从[雅虎金融](http://finance.yahoo.com/)获得个股报价,股票报价信息它自己会在终端内周期性更新。
### 自定义Mop中的股票报价
让我们来试试自定义证券列表吧。对此,Mop提供了易于记忆的快捷键:‘+’用于添加一只新股,而‘-’则用于移除一只股票。
要添加新股,请按‘+’,然后输入股票代码来添加(如MSFT)。你可以通过输入一个由逗号分隔的交易代码列表来一次添加多个股票(如”MSFT, AMZN, TSLA”)。

从列表中移除股票可以类似地按‘-’来完成。
### 对Mop中的股票报价排序
你可以基于任何栏目对股票报价列表进行排序。要排序,请按‘o’,然后使用左/右键来选择排序的基准栏目。当选定了一个特定栏目后,你可以按回车来对列表进行升序排序,或者降序排序。

通过按‘g’,你可以根据股票当日的涨或跌来分组。涨的情况以绿色表示,跌的情况以白色表示。

如果你想要访问帮助页,只需要按‘?’。

### 尾声
正如你所见,Mop是一个轻量级的,然而极其方便的证券监控工具。当然,你可以很轻松地从其它别的什么地方,从在线站点,你的智能手机等等访问到股票报价信息。然而,如果你在整天使用终端环境,Mop可以很容易地适应你的工作环境,希望没有让你过多地从你的工作流程中分心。只要让它在你其中一个终端中运行并保持市场日期持续更新,那就够了。
交易快乐!
---
via: <http://xmodulo.com/monitor-stock-quotes-command-line-linux.html>
作者:[Dan Nanni](http://xmodulo.com/author/nanni) 译者:[GOLinux](https://github.com/GOLinux) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,107 | 如何配置 MongoDB 副本集 | http://xmodulo.com/setup-replica-set-mongodb.html | 2015-08-28T14:31:00 | [
"MongoDB"
] | https://linux.cn/article-6107-1.html | MongoDB 已经成为市面上最知名的 NoSQL 数据库。MongoDB 是面向文档的,它的无模式设计使得它在各种各样的WEB 应用当中广受欢迎。最让我喜欢的特性之一是它的副本集(Replica Set),副本集将同一数据的多份拷贝放在一组 mongod 节点上,从而实现数据的冗余以及高可用性。

这篇教程将向你介绍如何配置一个 MongoDB 副本集。
副本集的最常见配置需要一个主节点以及多个副节点。这之后启动的复制行为会从这个主节点到其他副节点。副本集不止可以针对意外的硬件故障和停机事件对数据库提供保护,同时也因为提供了更多的节点从而提高了数据库客户端数据读取的吞吐量。
### 配置环境
这个教程里,我们会配置一个包括一个主节点以及两个副节点的副本集。

为了达到这个目的,我们使用了3个运行在 VirtualBox 上的虚拟机。我会在这些虚拟机上安装 Ubuntu 14.04,并且安装 MongoDB 官方包。
我会在一个虚拟机实例上配置好所需的环境,然后将它克隆到其他的虚拟机实例上。因此,选择一个名为 master 的虚拟机,执行以下安装过程。
首先,我们需要给 apt 增加一个 MongoDB 密钥:
```
$ sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10
```
然后,将官方的 MongoDB 仓库添加到 source.list 中:
```
$ sudo su
# echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list
```
接下来更新 apt 仓库并且安装 MongoDB。
```
$ sudo apt-get update
$ sudo apt-get install -y mongodb-org
```
现在对 /etc/mongodb.conf 做一些更改
```
auth = true
dbpath=/var/lib/mongodb
logpath=/var/log/mongodb/mongod.log
logappend=true
keyFile=/var/lib/mongodb/keyFile
replSet=myReplica
```
第一行的作用是表明我们的数据库需要验证才可以使用。keyfile 配置用于 MongoDB 节点间复制行为的密钥文件。replSet 为副本集设置一个名称。
接下来我们创建一个用于所有实例的密钥文件。
```
$ echo -n "MyRandomStringForReplicaSet" | md5sum > keyFile
```
这将会创建一个含有 MD5 字符串的密钥文件,但是由于其中包含了一些噪音,我们需要对他们清理后才能正式在 MongoDB 中使用。
```
$ echo -n "MyReplicaSetKey" | md5sum|grep -o "[0-9a-z]\+" > keyFile
```
grep 命令的作用的是把将空格等我们不想要的内容过滤掉之后的 MD5 字符串打印出来。
现在我们对密钥文件进行一些操作,让它真正可用。
```
$ sudo cp keyFile /var/lib/mongodb
$ sudo chown mongodb:nogroup keyFile
$ sudo chmod 400 keyFile
```
接下来,关闭此虚拟机。将其 Ubuntu 系统克隆到其他虚拟机上。

这是克隆后的副节点1和副节点2。确认你已经将它们的MAC地址重新初始化,并且克隆整个硬盘。

请注意,三个虚拟机示例需要在同一个网络中以便相互通讯。因此,我们需要它们弄到“互联网"上去。
这里推荐给每个虚拟机设置一个静态 IP 地址,而不是使用 DHCP。这样它们就不至于在 DHCP 分配IP地址给他们的时候失去连接。
像下面这样编辑每个虚拟机的 /etc/networks/interfaces 文件。
在主节点上:
```
auto eth1
iface eth1 inet static
address 192.168.50.2
netmask 255.255.255.0
```
在副节点1上:
```
auto eth1
iface eth1 inet static
address 192.168.50.3
netmask 255.255.255.0
```
在副节点2上:
```
auto eth1
iface eth1 inet static
address 192.168.50.4
netmask 255.255.255.0
```
由于我们没有 DNS 服务,所以需要设置设置一下 /etc/hosts 这个文件,手工将主机名称放到此文件中。
在主节点上:
```
127.0.0.1 localhost primary
192.168.50.2 primary
192.168.50.3 secondary1
192.168.50.4 secondary2
```
在副节点1上:
```
127.0.0.1 localhost secondary1
192.168.50.2 primary
192.168.50.3 secondary1
192.168.50.4 secondary2
```
在副节点2上:
```
127.0.0.1 localhost secondary2
192.168.50.2 primary
192.168.50.3 secondary1
192.168.50.4 secondary2
```
使用 ping 命令检查各个节点之间的连接。
```
$ ping primary
$ ping secondary1
$ ping secondary2
```
### 配置副本集
验证各个节点可以正常连通后,我们就可以新建一个管理员用户,用于之后的副本集操作。
在主节点上,打开 /etc/mongodb.conf 文件,将 auth 和 replSet 两项注释掉。
```
dbpath=/var/lib/mongodb
logpath=/var/log/mongodb/mongod.log
logappend=true
#auth = true
keyFile=/var/lib/mongodb/keyFile
#replSet=myReplica
```
在一个新安装的 MongoDB 上配置任何用户或副本集之前,你需要注释掉 auth 行。默认情况下,MongoDB 并没有创建任何用户。而如果在你创建用户前启用了 auth,你就不能够做任何事情。你可以在创建一个用户后再次启用 auth。
修改 /etc/mongodb.conf 之后,重启 mongod 进程。
```
$ sudo service mongod restart
```
现在连接到 MongoDB master:
```
$ mongo <master-ip-address>:27017
```
连接 MongoDB 后,新建管理员用户。
```
> use admin
> db.createUser({
user:"admin",
pwd:"
})
```
重启 MongoDB:
```
$ sudo service mongod restart
```
再次连接到 MongoDB,用以下命令将 副节点1 和副节点2节点添加到我们的副本集中。
```
> use admin
> db.auth("admin","myreallyhardpassword")
> rs.initiate()
> rs.add ("secondary1:27017")
> rs.add("secondary2:27017")
```
现在副本集到手了,可以开始我们的项目了。参照 [官方驱动文档](http://docs.mongodb.org/ecosystem/drivers/) 来了解如何连接到副本集。如果你想要用 Shell 来请求数据,那么你需要连接到主节点上来插入或者请求数据,副节点不行。如果你执意要尝试用副本集操作,那么以下错误信息就蹦出来招呼你了。
```
myReplica:SECONDARY>
myReplica:SECONDARY> show databases
2015-05-10T03:09:24.131+0000 E QUERY Error: listDatabases failed:{ "note" : "from execCommand", "ok" : 0, "errmsg" : "not master" }
at Error ()
at Mongo.getDBs (src/mongo/shell/mongo.js:47:15)
at shellHelper.show (src/mongo/shell/utils.js:630:33)
at shellHelper (src/mongo/shell/utils.js:524:36)
at (shellhelp2):1:1 at src/mongo/shell/mongo.js:47
```
如果你要从 shell 连接到整个副本集,你可以安装如下命令。在副本集中的失败切换是自动的。
```
$ mongo primary,secondary1,secondary2:27017/?replicaSet=myReplica
```
如果你使用其它驱动语言(例如,JavaScript、Ruby 等等),格式也许不同。
希望这篇教程能对你有所帮助。你可以使用Vagrant来自动完成你的本地环境配置,并且加速你的代码。
---
via: <http://xmodulo.com/setup-replica-set-mongodb.html>
作者:[Christopher Valerio](http://xmodulo.com/author/valerio) 译者:[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,110 | 如何在树莓派 2 运行 Ubuntu Snappy Core | http://xmodulo.com/ubuntu-snappy-core-raspberry-pi-2.html | 2015-08-29T17:55:00 | [
"Snappy",
"Snappy Core"
] | https://linux.cn/article-6110-1.html | 物联网(Internet of Things, IoT) 时代即将来临。很快,过不了几年,我们就会问自己当初是怎么在没有物联网的情况下生存的,就像我们现在怀疑过去没有手机的年代。Canonical 就是一个物联网快速发展却还是开放市场下的竞争者。这家公司宣称自己把赌注压到了IoT 上,就像他们已经在“云”上做过的一样。在今年一月底,Canonical 启动了一个基于Ubuntu Core 的小型操作系统,名字叫做 [Ubuntu Snappy Core](http://www.ubuntu.com/things) 。

Snappy 代表了两种意思,它是一种用来替代 deb 的新的打包格式;也是一个用来更新系统的前端,从CoreOS、红帽子和其他系统借鉴了**原子更新**这个想法。自从树莓派 2 投入市场,Canonical 很快就发布了用于树莓派的Snappy Core 版本。而第一代树莓派因为是基于ARMv6 ,Ubuntu 的ARM 镜像是基于ARMv7 ,所以不能运行ubuntu 。不过这种状况现在改变了,Canonical 通过发布 Snappy Core 的RPI2 镜像,抓住机会证明了Snappy 就是一个用于云计算,特别是用于物联网的系统。
Snappy 同样可以运行在其它像Amazon EC2, Microsofts Azure, Google的 Compute Engine 这样的云端上,也可以虚拟化在 KVM、Virtuabox 和vagrant 上。Canonical Ubuntu 已经拥抱了微软、谷歌、Docker、OpenStack 这些重量级选手,同时也与一些小项目达成合作关系。除了一些创业公司,比如 Ninja Sphere、Erle Robotics,还有一些开发板生产商,比如 Odroid、Banana Pro, Udoo, PCDuino 和 Parallella 、全志,Snappy 也提供了支持。Snappy Core 同时也希望尽快运行到路由器上来帮助改进路由器生产商目前很少更新固件的策略。
接下来,让我们看看怎么样在树莓派 2 上运行 Ubuntu Snappy Core。
用于树莓派2 的Snappy 镜像可以从 [Raspberry Pi 网站](http://www.raspberrypi.org/downloads/) 上下载。解压缩出来的镜像必须[写到一个至少8GB 大小的SD 卡](http://xmodulo.com/write-raspberry-pi-image-sd-card.html)。尽管原始系统很小,但是原子升级和回滚功能会占用不小的空间。使用 Snappy 启动树莓派 2 后你就可以使用默认用户名和密码(都是ubuntu)登录系统。

sudo 已经配置好了可以直接用,安全起见,你应该使用以下命令来修改你的用户名
```
$ sudo usermod -l <new name> <old name>
```
或者也可以使用`adduser` 为你添加一个新用户。
因为RPI缺少硬件时钟,而 Snappy Core 镜像并不知道这一点,所以系统会有一个小 bug:处理某些命令时会报很多错。不过这个很容易解决:
使用这个命令来确认这个bug 是否影响:
```
$ date
```
如果输出类似 "Thu Jan 1 01:56:44 UTC 1970", 你可以这样做来改正:
```
$ sudo date --set="Sun Apr 04 17:43:26 UTC 2015"
```
改成你的实际时间。

现在你可能打算检查一下,看看有没有可用的更新。注意通常使用的命令是不行的:
```
$ sudo apt-get update && sudo apt-get distupgrade
```
这时系统不会让你通过,因为 Snappy 使用它自己精简过的、基于dpkg 的包管理系统。这么做的原因是 Snappy 会运行很多嵌入式程序,而同时你也会试图所有事情尽可能的简化。
让我们来看看最关键的部分,理解一下程序是如何与 Snappy 工作的。运行 Snappy 的SD 卡上除了 boot 分区外还有3个分区。其中的两个构成了一个重复的文件系统。这两个平行文件系统被固定挂载为只读模式,并且任何时刻只有一个是激活的。第三个分区是一个部分可写的文件系统,用来让用户存储数据。通过更新系统,标记为'system-a' 的分区会保持一个完整的文件系统,被称作核心,而另一个平行的文件系统仍然会是空的。

如果我们运行以下命令:
```
$ sudo snappy update
```
系统将会在'system-b' 上作为一个整体进行更新,这有点像是更新一个镜像文件。接下来你将会被告知要重启系统来激活新核心。
重启之后,运行下面的命令可以检查你的系统是否已经更新到最新版本,以及当前被激活的是哪个核心
```
$ sudo snappy versions -a
```
经过更新-重启两步操作,你应该可以看到被激活的核心已经被改变了。
因为到目前为止我们还没有安装任何软件,所以可以用下面的命令更新:
```
$ sudo snappy update ubuntu-core
```
如果你打算仅仅更新特定的OS 版本这就够了。如果出了问题,你可以使用下面的命令回滚:
```
$ sudo snappy rollback ubuntu-core
```
这将会把系统状态回滚到更新之前。

再来说说那些让 Snappy 变得有用的软件。这里不会讲的太多关于如何构建软件、向 Snappy 应用商店添加软件的基础知识,但是你可以通过 Freenode 上的IRC 频道 #snappy 了解更多信息,那个上面有很多人参与。你可以通过浏览器访问http://<ip-address>:4200 来浏览应用商店,然后从商店安装软件,再在浏览器里访问 <http://webdm.local> 来启动程序。如何构建用于 Snappy 的软件并不难,而且也有了现成的[参考文档](https://developer.ubuntu.com/en/snappy/) 。你也可以很容易的把 DEB 安装包使用Snappy 格式移植到Snappy 上。

尽管 Ubuntu Snappy Core 吸引了我们去研究新型的 Snappy 安装包格式和 Canonical 式的原子更新操作,但是因为有限的可用应用,它现在在生产环境里还不是很有用。但是既然搭建一个 Snappy 环境如此简单,这看起来是一个学点新东西的好机会。
---
via: <http://xmodulo.com/ubuntu-snappy-core-raspberry-pi-2.html>
作者:[Ferdinand Thommes](http://xmodulo.com/author/ferdinand) 译者:[Ezio](https://github.com/oska874) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,111 | Ubuntu 14.04中修复“update information is outdated”错误 | http://itsfoss.com/fix-update-information-outdated-ubuntu/ | 2015-08-29T18:30:56 | [
"Ubuntu",
"更新"
] | https://linux.cn/article-6111-1.html | 
看到过Ubuntu 14.04的顶部面板上那个显示下面这个错误的红色三角形了吗?
>
> 更新信息过时。该错误可能是由网络问题,或者某个仓库不再可用而造成的。请通过从指示器菜单中选择‘显示更新’来手动更新,然后查看是否存在有失败的仓库。
>
>
>
它看起来像这样:

这里的粉红色感叹号标记就是原来的红色三角形,因为我使用了[最佳的Ubuntu图标主题](http://itsfoss.com/best-icon-themes-ubuntu-1404/)之一,Numix。让我们回到该错误中,这是一个常见的更新问题,你也许时不时地会碰到它。现在,你或许想知道的是,到底是什么导致了这个更新错误的出现。
### 引起‘update information is outdated’错误的原因
导致该错误的原因在其自身的错误描述中就讲得相当明白,它告诉你“这可能是由网络问题或者某个不再可用的仓库导致的”。所以,要么是你更新了系统和某些仓库,要么是PPA不再受到支持了,或者你正面对的类似问题。
虽然错误本身就讲得很明白,而它给出了的议操作“请通过从指示器菜单选择‘显示更新’来手动更新以查看失败的仓库”却并不能很好地解决问题。如果你点击显示更新,你所能看见的仅仅是系统已经更新。

很奇怪,不是吗?我们怎样才能找出是什么出错了,哪里出错了,以及为什么出错呢?
### 修复‘update information is outdated’错误
这里讨论的‘解决方案’可能对Ubuntu的这些版本有用:Ubuntu 14.04,12.04。你所要做的仅仅是打开终端(Ctrl+Alt+T),然后使用下面的命令:
```
sudo apt-get update
```
等待命令结束,然后查看其结果。这里插个快速提示,你可以[在终端中添加通知](http://itsfoss.com/notification-terminal-command-completion-ubuntu/),这样当一个耗时很长的命令结束执行时就会通知你。在该命令的最后几行中,可以看到你的系统正面临什么样的错误。是的,你肯定会看到一个错误。
在我这里,我看到了有名的[GPG error: The following could not be verified](http://itsfoss.com/solve-gpg-error-signatures-verified-ubuntu/)错误。很明显,[在Ubuntu 15.04中安装声破天](http://itsfoss.com/install-spotify-ubuntu-1504/)有点问题。

很可能你看到的不是像我一样的GPG错误,那样的话,我建议你读一读我写的这篇文章[修复Ubuntu中的各种常见更新错误](/article-5603-1.html)。
我知道有不少人,尤其是初学者,很是讨厌命令行,但是如果你正在使用Linux,你就无可避免会使用到终端。此外,那东西并没你想象的那么可怕。试试吧,你会很快上手的。
我希望这个快速提示对于你修复Ubuntu中的“update information is outdated”错误有帮助。如果你有任何问题或建议,请不吝提出,我们将无任欢迎。
---
via: <http://itsfoss.com/fix-update-information-outdated-ubuntu/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[GOLinux](https://github.com/GOLinux) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,112 | 在 Linux 中使用日志来排错 | http://www.loggly.com/ultimate-guide/logging/troubleshooting-with-linux-logs/ | 2015-08-30T08:44:00 | [
"日志"
] | https://linux.cn/article-6112-1.html | 人们创建日志的主要原因是排错。通常你会诊断为什么问题发生在你的 Linux 系统或应用程序中。错误信息或一系列的事件可以给你提供找出根本原因的线索,说明问题是如何发生的,并指出如何解决它。这里有几个使用日志来解决的样例。

### 登录失败原因
如果你想检查你的系统是否安全,你可以在验证日志中检查登录失败的和登录成功但可疑的用户。当有人通过不正当或无效的凭据来登录时会出现认证失败,这通常发生在使用 SSH 进行远程登录或 su 到本地其他用户来进行访问权时。这些是由[插入式验证模块(PAM)](http://linux.die.net/man/8/pam.d)来记录的。在你的日志中会看到像 Failed password 和 user unknown 这样的字符串。而成功认证记录则会包括像 Accepted password 和 session opened 这样的字符串。
失败的例子:
```
pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=10.0.2.2
Failed password for invalid user hoover from 10.0.2.2 port 4791 ssh2
pam_unix(sshd:auth): check pass; user unknown
PAM service(sshd) ignoring max retries; 6 > 3
```
成功的例子:
```
Accepted password for hoover from 10.0.2.2 port 4792 ssh2
pam_unix(sshd:session): session opened for user hoover by (uid=0)
pam_unix(sshd:session): session closed for user hoover
```
你可以使用 grep 来查找哪些用户失败登录的次数最多。这些都是潜在的攻击者正在尝试和访问失败的账户。这是一个在 ubuntu 系统上的例子。
```
$ grep "invalid user" /var/log/auth.log | cut -d ' ' -f 10 | sort | uniq -c | sort -nr
23 oracle
18 postgres
17 nagios
10 zabbix
6 test
```
由于没有标准格式,所以你需要为每个应用程序的日志使用不同的命令。日志管理系统,可以自动分析日志,将它们有效的归类,帮助你提取关键字,如用户名。
日志管理系统可以使用自动解析功能从 Linux 日志中提取用户名。这使你可以看到用户的信息,并能通过点击过滤。在下面这个例子中,我们可以看到,root 用户登录了 2700 次之多,因为我们筛选的日志仅显示 root 用户的尝试登录记录。

日志管理系统也可以让你以时间为做坐标轴的图表来查看,使你更容易发现异常。如果有人在几分钟内登录失败一次或两次,它可能是一个真正的用户而忘记了密码。但是,如果有几百个失败的登录并且使用的都是不同的用户名,它更可能是在试图攻击系统。在这里,你可以看到在3月12日,有人试图登录 Nagios 几百次。这显然不是一个合法的系统用户。

### 重启的原因
有时候,一台服务器由于系统崩溃或重启而宕机。你怎么知道它何时发生,是谁做的?
#### 关机命令
如果有人手动运行 shutdown 命令,你可以在验证日志文件中看到它。在这里,你可以看到,有人从 IP 50.0.134.125 上作为 ubuntu 的用户远程登录了,然后关闭了系统。
```
Mar 19 18:36:41 ip-172-31-11-231 sshd[23437]: Accepted publickey for ubuntu from 50.0.134.125 port 52538 ssh
Mar 19 18:36:41 ip-172-31-11-231 23437]:sshd[ pam_unix(sshd:session): session opened for user ubuntu by (uid=0)
Mar 19 18:37:09 ip-172-31-11-231 sudo: ubuntu : TTY=pts/1 ; PWD=/home/ubuntu ; USER=root ; COMMAND=/sbin/shutdown -r now
```
#### 内核初始化
如果你想看看服务器重新启动的所有原因(包括崩溃),你可以从内核初始化日志中寻找。你需要搜索内核类(kernel)和 cpu 初始化(Initializing)的信息。
```
Mar 19 18:39:30 ip-172-31-11-231 kernel: [ 0.000000] Initializing cgroup subsys cpuset
Mar 19 18:39:30 ip-172-31-11-231 kernel: [ 0.000000] Initializing cgroup subsys cpu
Mar 19 18:39:30 ip-172-31-11-231 kernel: [ 0.000000] Linux version 3.8.0-44-generic (buildd@tipua) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #66~precise1-Ubuntu SMP Tue Jul 15 04:01:04 UTC 2014 (Ubuntu 3.8.0-44.66~precise1-generic 3.8.13.25)
```
### 检测内存问题
有很多原因可能导致服务器崩溃,但一个常见的原因是内存用尽。
当你系统的内存不足时,进程会被杀死,通常会杀死使用最多资源的进程。当系统使用了所有内存,而新的或现有的进程试图使用更多的内存时就会出现错误。在你的日志文件查找像 Out of Memory 这样的字符串或类似 kill 这样的内核警告信息。这些信息表明系统故意杀死进程或应用程序,而不是允许进程崩溃。
例如:
```
[33238.178288] Out of memory: Kill process 6230 (firefox) score 53 or sacrifice child
[29923450.995084] select 5230 (docker), adj 0, size 708, to kill
```
你可以使用像 grep 这样的工具找到这些日志。这个例子是在 ubuntu 中:
```
$ grep “Out of memory” /var/log/syslog
[33238.178288] Out of memory: Kill process 6230 (firefox) score 53 or sacrifice child
```
请记住,grep 也要使用内存,所以只是运行 grep 也可能导致内存不足的错误。这是另一个你应该中央化存储日志的原因!
### 定时任务错误日志
cron 守护程序是一个调度器,可以在指定的日期和时间运行进程。如果进程运行失败或无法完成,那么 cron 的错误出现在你的日志文件中。具体取决于你的发行版,你可以在 /var/log/cron,/var/log/messages,和 /var/log/syslog 几个位置找到这个日志。cron 任务失败原因有很多。通常情况下,问题出在进程中而不是 cron 守护进程本身。
默认情况下,cron 任务的输出会通过 postfix 发送电子邮件。这是一个显示了该邮件已经发送的日志。不幸的是,你不能在这里看到邮件的内容。
```
Mar 13 16:35:01 PSQ110 postfix/pickup[15158]: C3EDC5800B4: uid=1001 from=<hoover>
Mar 13 16:35:01 PSQ110 postfix/cleanup[15727]: C3EDC5800B4: message-id=<20150310110501.C3EDC5800B4@PSQ110>
Mar 13 16:35:01 PSQ110 postfix/qmgr[15159]: C3EDC5800B4: from=<hoover@loggly.com>, size=607, nrcpt=1 (queue active)
Mar 13 16:35:05 PSQ110 postfix/smtp[15729]: C3EDC5800B4: to=<hoover@loggly.com>, relay=gmail-smtp-in.l.google.com[74.125.130.26]:25, delay=4.1, delays=0.26/0/2.2/1.7, dsn=2.0.0, status=sent (250 2.0.0 OK 1425985505 f16si501651pdj.5 - gsmtp)
```
你可以考虑将 cron 的标准输出记录到日志中,以帮助你定位问题。这是一个你怎样使用 logger 命令重定向 cron 标准输出到 syslog的例子。用你的脚本来代替 echo 命令,helloCron 可以设置为任何你想要的应用程序的名字。
```
*/5 * * * * echo ‘Hello World’ 2>&1 | /usr/bin/logger -t helloCron
```
它创建的日志条目:
```
Apr 28 22:20:01 ip-172-31-11-231 CRON[15296]: (ubuntu) CMD (echo 'Hello World!' 2>&1 | /usr/bin/logger -t helloCron)
Apr 28 22:20:01 ip-172-31-11-231 helloCron: Hello World!
```
每个 cron 任务将根据任务的具体类型以及如何输出数据来记录不同的日志。
希望在日志中有问题根源的线索,也可以根据需要添加额外的日志记录。
---
via: <http://www.loggly.com/ultimate-guide/logging/troubleshooting-with-linux-logs/>
作者:[Jason Skowronski](https://www.linkedin.com/in/jasonskowronski) 作者:[Amy Echeverri](https://www.linkedin.com/in/amyecheverri) 作者:[Sadequl Hussain](https://www.linkedin.com/pub/sadequl-hussain/14/711/1a7) 译者:[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,113 | 在 VirtualBox 中使用 Docker Machine 管理主机 | http://linoxide.com/linux-how-to/host-virtualbox-docker-machine/ | 2015-08-30T08:15:00 | [
"Docker",
"Docker Machine"
] | /article-6113-1.html | 大家好,今天我们学习在 VirtualBox 中使用 Docker Machine 来创建和管理 Docker 主机。Docker Machine 是一个可以帮助我们在电脑上、在云端、在数据中心内创建 Docker 主机的应用。它为根据用户的配置和需求创建服务器并在其上安装 Docker和客户端提供了一个轻松的解决方案。这个 API 可以用于在本地主机、或数据中心的虚拟机、或云端的实例提供 Docker 服务。Docker Machine 支持 Windows、OSX 和 Linux,并且是以一个独立的二进制文件包形式安装的。仍然使用(与现有 Docker 工具)相同的接口,我们就可以充分利用已经提供 Docker 基础框架的生态系统。只要一个命令,用户就能快速部署 Docker 容器。

本文列出一些简单的步骤用 Docker Machine 来部署 docker 容器。
### 1. 安装 Docker Machine
Docker Machine 完美支持所有 Linux 操作系统。首先我们需要从 [github](https://github.com/docker/machine/releases) 下载最新版本的 Docker Machine,本文使用 curl 作为下载工具,Docker Machine 版本为 0.2.0。
**64 位操作系统**
```
# curl -L https://github.com/docker/machine/releases/download/v0.2.0/docker-machine_linux-amd64 > /usr/local/bin/docker-machine
```
**32 位操作系统**
```
# curl -L https://github.com/docker/machine/releases/download/v0.2.0/docker-machine_linux-i386 > /usr/local/bin/docker-machine
```
下载完成后,找到 **/usr/local/bin** 目录下的 **docker-machine** 文件,让其可以执行:
```
# chmod +x /usr/local/bin/docker-machine
```
确认是否成功安装了 docker-machine,可以运行下面的命令,它会打印 Docker Machine 的版本信息:
```
# docker-machine -v
```

运行下面的命令,安装 Docker 客户端,以便于在我们自己的电脑止运行 Docker 命令:
```
# curl -L https://get.docker.com/builds/linux/x86_64/docker-latest > /usr/local/bin/docker
# chmod +x /usr/local/bin/docker
```
### 2. 创建 VirtualBox 虚拟机
在 Linux 系统上安装完 Docker Machine 后,接下来我们可以安装 VirtualBox 虚拟机,运行下面的就可以了。`--driver virtualbox` 选项表示我们要在 VirtualBox 的虚拟机里面部署 docker,最后的参数“linux” 是虚拟机的名称。这个命令会下载 [boot2docker](https://github.com/boot2docker/boot2docker) iso,它是个基于 Tiny Core Linux 的轻量级发行版,自带 Docker 程序,然后 `docker-machine` 命令会创建一个 VirtualBox 虚拟机(LCTT译注:当然,我们也可以选择其他的虚拟机软件)来运行这个 boot2docker 系统。
```
# docker-machine create --driver virtualbox linux
```

测试下有没有成功运行 VirtualBox 和 Docker,运行命令:
```
# docker-machine ls
```

如果执行成功,我们可以看到在 ACTIVE 那列下面会出现一个星号“\*”。
### 3. 设置环境变量
现在我们需要让 docker 与 docker-machine 通信,运行 `docker-machine env <虚拟机名称>` 来实现这个目的。
```
# eval "$(docker-machine env linux)"
# docker ps
```
这个命令会设置 TLS 认证的环境变量,每次重启机器或者重新打开一个会话都需要执行一下这个命令,我们可以看到它的输出内容:
```
# docker-machine env linux
export DOCKER_TLS_VERIFY=1
export DOCKER_CERT_PATH=/Users/<your username>/.docker/machine/machines/dev
export DOCKER_HOST=tcp://192.168.99.100:2376
```
### 4. 运行 Docker 容器
完成配置后我们就可以在 VirtualBox 上运行 docker 容器了。测试一下,我们可以运行虚拟机 `docker run busybox` ,并在里面里执行 `echo hello world` 命令,我们可以看到容器的输出信息。
```
# docker run busybox echo hello world
```

### 5. 拿到 Docker 主机的 IP
我们可以执行下面的命令获取运行 Docker 的主机的 IP 地址。我们可以看到在 Docker 主机的 IP 地址上的任何暴露出来的端口。
```
# docker-machine ip
```

### 6. 管理主机
现在我们可以随心所欲地使用上述的 docker-machine 命令来不断创建主机了。
当你使用完 docker 时,可以运行 **docker-machine stop** 来停止所有主机,如果想开启所有主机,运行 **docker-machine start**。
```
# docker-machine stop
# docker-machine start
```
你也可以只停止或开启一台主机:
```
$ docker-machine stop linux
$ docker-machine start linux
```
### 总结
最后,我们使用 Docker Machine 成功在 VirtualBox 上创建并管理一台 Docker 主机。Docker Machine 确实能让用户快速地在不同的平台上部署 Docker 主机,就像我们这里部署在 VirtualBox 上一样。这个 virtualbox 驱动可以在本地机器上使用,也可以在数据中心的虚拟机上使用。Docker Machine 驱动除了支持本地的 VirtualBox 之外,还支持远端的 Digital Ocean、AWS、Azure、VMware 以及其它基础设施。
如果你有任何疑问,或者建议,请在评论栏中写出来,我们会不断改进我们的内容。谢谢,祝愉快。
---
via: <http://linoxide.com/linux-how-to/host-virtualbox-docker-machine/>
作者:[Arun Pyasi](http://linoxide.com/author/arunp/) 译者:[bazz2](https://github.com/bazz2) 校对:[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/host-virtualbox-docker-machine/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327580b50>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,114 | 如何在 Linux 中安装 Visual Studio Code | http://linoxide.com/linux-how-to/install-visual-studio-code-linux/ | 2015-08-30T00:40:19 | [
"Visual Studio Code",
"Atom.io",
"编辑器"
] | /article-6114-1.html | 大家好,今天我们一起来学习如何在 Linux 发行版中安装 Visual Studio Code。Visual Studio Code 是基于 Electron 优化代码后的编辑器,后者是基于 Chromium 的一款软件,用于为桌面系统发布 io.js 应用。Visual Studio Code 是微软开发的支持包括 Linux 在内的全平台代码编辑器和文本编辑器。它是免费软件但不开源,在专有软件许可条款下发布。它是可以用于我们日常使用的超级强大和快速的代码编辑器。Visual Studio Code 有很多很酷的功能,例如导航、智能感知支持、语法高亮、括号匹配、自动补全、代码片段、支持自定义键盘绑定、并且支持多种语言,例如 Python、C++、Jade、PHP、XML、Batch、F#、DockerFile、Coffee Script、Java、HandleBars、 R、 Objective-C、 PowerShell、 Luna、 Visual Basic、 .Net、 Asp.Net、 C#、 JSON、 Node.js、 Javascript、 HTML、 CSS、 Less、 Sass 和 Markdown。Visual Studio Code 集成了包管理器、库、构建,以及其它通用任务,以加速日常的工作流。Visual Studio Code 中最受欢迎的是它的调试功能,它包括流式支持 Node.js 的预览调试。
注意:请注意 Visual Studio Code 只支持 64 位的 Linux 发行版。
下面是在所有 Linux 发行版中安装 Visual Studio Code 的几个简单步骤。
### 1. 下载 Visual Studio Code 软件包
首先,我们要从微软服务器中下载 64 位 Linux 操作系统的 Visual Studio Code 安装包,链接是 <http://go.microsoft.com/fwlink/?LinkID=534108>。这里我们使用 wget 下载并保存到 tmp/VSCODE 目录。
```
# mkdir /tmp/vscode; cd /tmp/vscode/
# wget https://az764295.vo.msecnd.net/public/0.3.0/VSCode-linux-x64.zip
--2015-06-24 06:02:54-- https://az764295.vo.msecnd.net/public/0.3.0/VSCode-linux-x64.zip
Resolving az764295.vo.msecnd.net (az764295.vo.msecnd.net)... 93.184.215.200, 2606:2800:11f:179a:1972:2405:35b:459
Connecting to az764295.vo.msecnd.net (az764295.vo.msecnd.net)|93.184.215.200|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 64992671 (62M) [application/octet-stream]
Saving to: ‘VSCode-linux-x64.zip’
100%[================================================>] 64,992,671 14.9MB/s in 4.1s
2015-06-24 06:02:58 (15.0 MB/s) - ‘VSCode-linux-x64.zip’ saved [64992671/64992671]
```
### 2. 提取软件包
现在,下载好 Visual Studio Code 的 zip 压缩包之后,我们打算使用 unzip 命令解压它。我们要在终端或者控制台中运行以下命令。
```
# unzip /tmp/vscode/VSCode-linux-x64.zip -d /opt/
```
注意:如果我们还没有安装 unzip,我们首先需要通过软件包管理器安装它。如果你运行的是 Ubuntu,使用 apt-get,如果运行的是 Fedora、CentOS、可以用 dnf 或 yum 安装它。
### 3. 运行 Visual Studio Code
展开软件包之后,我们可以直接运行一个名为 Code 的文件启动 Visual Studio Code。
```
# sudo chmod +x /opt/VSCode-linux-x64/Code
# sudo /opt/VSCode-linux-x64/Code
```
如果我们想通过终端在任何地方启动 Code,我们就需要创建 /opt/vscode/Code 的一个链接 /usr/local/bin/code。
```
# ln -s /opt/VSCode-linux-x64/Code /usr/local/bin/code
```
现在,我们就可以在终端中运行以下命令启动 Visual Studio Code 了。
```
# code .
```
### 4. 创建桌面启动
下一步,成功展开 Visual Studio Code 软件包之后,我们打算创建桌面启动程序,使得根据不同桌面环境能够从启动器、菜单、桌面启动它。首先我们要复制一个图标文件到 /usr/share/icons/ 目录。
```
# cp /opt/VSCode-linux-x64/resources/app/vso.png /usr/share/icons/
```
然后,我们创建一个桌面启动程序,文件扩展名为 .desktop。这里我们使用喜欢的文本编辑器在 /tmp/VSCODE/ 目录中创建名为 visualstudiocode.desktop 的文件。
```
# vi /tmp/vscode/visualstudiocode.desktop
```
然后,粘贴下面的行到那个文件中。
```
[Desktop Entry]
Name=Visual Studio Code
Comment=Multi-platform code editor for Linux
Exec=/opt/VSCode-linux-x64/Code
Icon=/usr/share/icons/vso.png
Type=Application
StartupNotify=true
Categories=TextEditor;Development;Utility;
MimeType=text/plain;
```
创建完桌面文件之后,我们会复制这个桌面文件到 /usr/share/applications/ 目录,这样启动器和菜单中就可以单击启动 Visual Studio Code 了。
```
# cp /tmp/vscode/visualstudiocode.desktop /usr/share/applications/
```
完成之后,我们可以在启动器或者菜单中启动它。

### 在 Ubuntu 中 Visual Studio Code
要在 Ubuntu 14.04/14.10/15.04 Linux 发行版中安装 Visual Studio Code,我们可以使用 Ubuntu Make 0.7。这是在 ubuntu 中安装 code 最简单的方法,因为我们只需要执行几个命令。首先,我们要在我们的 ubuntu linux 发行版中安装 Ubuntu Make 0.7。要安装它,首先要为它添加 PPA。可以通过运行下面命令完成。
```
# add-apt-repository ppa:ubuntu-desktop/ubuntu-make
This ppa proposes package backport of Ubuntu make for supported releases.
More info: https://launchpad.net/~ubuntu-desktop/+archive/ubuntu/ubuntu-make
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keyring `/tmp/tmpv0vf24us/secring.gpg' created
gpg: keyring `/tmp/tmpv0vf24us/pubring.gpg' created
gpg: requesting key A1231595 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpv0vf24us/trustdb.gpg: trustdb created
gpg: key A1231595: public key "Launchpad PPA for Ubuntu Desktop" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
OK
```
然后,更新本地库索引并安装 ubuntu-make。
```
# apt-get update
# apt-get install ubuntu-make
```
在我们的 ubuntu 操作系统上安装完 Ubuntu Make 之后,我们可以在一个终端中运行以下命令来安装 Code。
```
# umake web visual-studio-code
```

运行完上面的命令之后,会要求我们输入想要的安装路径。然后,会请求我们允许在 ubuntu 系统中安装 Visual Studio Code。我们输入“a”(接受)。输入完后,它会在 ubuntu 机器上下载和安装 Code。最后,我们可以在启动器或者菜单中启动它。
### 总结
我们已经成功地在 Linux 发行版上安装了 Visual Studio Code。在所有 linux 发行版上安装 Visual Studio Code 都和上面介绍的相似,我们也可以使用 umake 在 Ubuntu 发行版中安装。Umake 是一个安装开发工具,IDEs 和语言的流行工具。我们可以用 Umake 轻松地安装 Android Studios、Eclipse 和很多其它流行 IDE。Visual Studio Code 是基于 Github 上一个叫 [Electron](https://github.com/atom/electron) 的项目,它是 [Atom.io](https://github.com/atom/atom) 编辑器的一部分。它有很多 Atom.io 编辑器没有的改进功能。当前 Visual Studio Code 只支持 64 位 linux 操作系统平台。
如果你有任何疑问、建议或者反馈,请在下面的评论框中留言以便我们改进和更新我们的内容。非常感谢!Enjoy :-)
---
via: <http://linoxide.com/linux-how-to/install-visual-studio-code-linux/>
作者:[Arun Pyasi](http://linoxide.com/author/arunp/) 译者:[ictlyh](https://github.com/ictlyh) 校对:[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-visual-studio-code-linux/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b83275817e0>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,117 | 如何在 Ubuntu 15.04 系统中安装 Logwatch | http://linoxide.com/ubuntu-how-to/install-use-logwatch-ubuntu-15-04/ | 2015-08-30T22:01:06 | [
"logwatch",
"日志"
] | /article-6117-1.html | 大家好,今天我们会讲述在 Ubuntu 15.04 操作系统上如何安装 Logwatch 软件,它也可以在各种 Linux 系统和类 Unix 系统上安装。Logwatch 是一款可定制的日志分析和日志监控报告生成系统,它可以根据一段时间的日志文件生成您所希望关注的详细报告。它具有易安装、易配置、可审查等特性,同时对其提供的数据的安全性上也有一些保障措施。Logwatch 会扫描重要的操作系统组件像 SSH、网站服务等的日志文件,然后生成用户所关心的有价值的条目汇总报告。

### 预安装设置
我们会使用 Ubuntu 15.04 版本的操作系统来部署 Logwatch,所以安装 Logwatch 之前,要确保系统上邮件服务设置是正常可用的。因为它会每天把生成的报告通过日报的形式发送邮件给管理员。您的系统的源库也应该设置可用,以便可以从通用源库来安装 Logwatch。
然后打开您 ubuntu 系统的终端,用 root 账号登陆,在进入 Logwatch 的安装操作前,先更新您的系统软件包。
```
root@ubuntu-15:~# apt-get update
```
### 安装 Logwatch
只要你的系统已经更新和已经满足前面说的先决条件,那么就可以在您的机器上输入如下命令来安装 Logwatch。
```
root@ubuntu-15:~# apt-get install logwatch
```
在安装过程中,一旦您按提示按下“Y”键同意对系统修改的话,Logwatch 将会开始安装一些额外的必须软件包。
在安装过程中会根据您机器上的邮件服务器设置情况弹出提示对 Postfix 设置的配置界面。在这篇教程中我们使用最容易的 “仅本地(Local only)” 选项。根据您的基础设施情况也可以选择其它的可选项,然后点击“确定”继续。

随后您得选择邮件服务器名,这邮件服务器名也会被其它程序使用,所以它应该是一个完全合格域名/全称域名(FQDN)。

一旦按下在 postfix 配置提示底端的 “OK”,安装进程就会用 Postfix 的默认配置来安装,并且完成 Logwatch 的整个安装。

您可以在终端下发出如下命令来检查 Logwatch 状态,正常情况下它应该是激活状态。
```
root@ubuntu-15:~# service postfix status
```

要确认 Logwatch 在默认配置下的安装信息,可以如下示简单的发出“logwatch” 命令。
```
root@ubuntu-15:~# logwatch
```
上面执行命令的输出就是终端下编制出的报表展现格式。

### 配置 Logwatch
在成功安装好 Logwatch 后,我们需要在它的配置文件中做一些修改,配置文件位于如下所示的路径。那么,就让我们用文本编辑器打开它,然后按需要做些变动。
```
root@ubuntu-15:~# vim /usr/share/logwatch/default.conf/logwatch.conf
```
**输出/格式化选项**
默认情况下 Logwatch 会以无编码的文本打印到标准输出方式。要改为以邮件为默认方式,需设置“Output = mail”,要改为保存成文件方式,需设置“Output = file”。所以您可以根据您的要求设置其默认配置。
```
Output = stdout
```
如果使用的是因特网电子邮件配置,要用 Html 格式为默认出格式,需要修改成如下行所示的样子。
```
Format = text
```
现在增加默认的邮件报告接收人地址,可以是本地账号也可以是完整的邮件地址,需要的都可以在这行上写上
```
MailTo = root
#MailTo = user@test.com
```
默认的邮件发送人可以是本地账号,也可以是您需要使用的其它名字。
```
# complete email address.
MailFrom = Logwatch
```
对这个配置文件保存修改,至于其它的参数就让它保持默认,无需改动。
**调度任务配置**
现在编辑在 “daily crons” 目录下的 “00logwatch” 文件来配置从 logwatch 生成的报告需要发送的邮件地址。
```
root@ubuntu-15:~# vim /etc/cron.daily/00logwatch
```
在这儿您需要作用“--mailto [user@test.com](mailto:user@test.com)”来替换掉“--output mail”,然后保存文件。

### 生成报告
现在我们在终端中执行“logwatch”命令来生成测试报告,生成的结果在终端中会以文本格式显示出来。
```
root@ubuntu-15:~#logwatch
```
生成的报告开始部分显示的是执行的时间和日期。它包含不同的部分,每个部分以开始标识开始而以结束标识结束,中间显示的是该部分的完整信息。
这儿显示的是开始的样子,它以显示系统上所有安装的软件包的部分开始,如下所示:

接下来的部分显示的日志信息是关于当前系统登录会话、rsyslogs 和当前及最近的 SSH 会话信息。

Logwatch 报告最后显示的是安全方面的 sudo 日志及根目录磁盘使用情况,如下示:

您也可以打开如下的文件来查看生成的 logwatch 报告电子邮件。
```
root@ubuntu-15:~# vim /var/mail/root
```
您会看到发送给你配置的用户的所有已生成的邮件及其邮件递交状态。
### 更多详情
Logwatch 是一款很不错的工具,可以学习的很多很多,所以如果您对它的日志监控功能很感兴趣的话,也以通过如下所示的简短命令来获得更多帮助。
```
root@ubuntu-15:~# man logwatch
```
上面的命令包含所有关于 logwatch 的用户手册,所以仔细阅读,要退出手册的话可以简单的输入“q”。
关于 logwatch 命令的使用,您可以使用如下所示的帮助命令来获得更多的详细信息。
```
root@ubuntu-15:~# logwatch --help
```
### 结论
教程结束,您也学会了如何在 Ubuntu 15.04 上对 Logwatch 的安装、配置等全部设置指导。现在您就可以自定义监控您的系统日志,不管是监控所有服务的运行情况还是对特定的服务在指定的时间发送报告都可以。所以,开始使用这工具吧,无论何时有问题或想知道更多关于 logwatch 的使用的都可以给我们留言。
---
via: <http://linoxide.com/ubuntu-how-to/install-use-logwatch-ubuntu-15-04/>
作者:[Kashif Siddique](http://linoxide.com/author/kashifs/) 译者:[runningwater](https://github.com/runningwater) 校对:[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-use-logwatch-ubuntu-15-04/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b83275820b0>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,119 | Bash 下如何逐行读取一个文件 | http://www.cyberciti.biz/faq/unix-howto-read-line-by-line-from-file/ | 2015-08-31T10:06:52 | [
"bash"
] | https://linux.cn/article-6119-1.html | 在 Linux 或类 UNIX 系统下如何使用 KSH 或 BASH shell 逐行读取一个文件?
在 Linux、OSX、 \*BSD 或者类 Unix 系统下你可以使用 while..do..done 的 bash 循环来逐行读取一个文件。
### 在 Bash Unix 或者 Linux shell 中逐行读取一个文件的语法
对于 bash、ksh、 zsh 和其他的 shells 语法如下
```
while read -r line; do COMMAND; done < input.file
```
通过 -r 选项传递给 read 命令以防止阻止解释其中的反斜杠转义符。
在 read 命令之前添加 `IFS=` 选项,来防止首尾的空白字符被去掉。
```
while IFS= read -r line; do COMMAND_on $line; done < input.file
```
这是更适合人类阅读的语法:
```
#!/bin/bash
input="/path/to/txt/file"
while IFS= read -r var
do
echo "$var"
done < "$input"
```
**示例**
下面是一些例子:
```
#!/bin/ksh
file="/home/vivek/data.txt"
while IFS= read line
do
# display $line or do somthing with $line
echo "$line"
done <"$file"
```
在 bash shell 中相同的例子:
```
#!/bin/bash
file="/home/vivek/data.txt"
while IFS= read -r line
do
# display $line or do somthing with $line
printf '%s\n' "$line"
done <"$file"
```
你还可以看看这个更好的:
```
#!/bin/bash
file="/etc/passwd"
while IFS=: read -r f1 f2 f3 f4 f5 f6 f7
do
# display fields using f1, f2,..,f7
printf 'Username: %s, Shell: %s, Home Dir: %s\n' "$f1" "$f7" "$f6"
done <"$file"
```
示例输出:

*图01:Bash 脚本:读取文件并逐行输出文件*
### Bash 脚本:逐行读取文本文件并创建为 pdf 文件
我的输入文件如下(faq.txt):
```
4|http://www.cyberciti.biz/faq/mysql-user-creation/|Mysql User Creation: Setting Up a New MySQL User Account
4096|http://www.cyberciti.biz/faq/ksh-korn-shell/|What is UNIX / Linux Korn Shell?
4101|http://www.cyberciti.biz/faq/what-is-posix-shell/|What Is POSIX Shell?
17267|http://www.cyberciti.biz/faq/linux-check-battery-status/|Linux: Check Battery Status Command
17245|http://www.cyberciti.biz/faq/restarting-ntp-service-on-linux/|Linux Restart NTPD Service Command
17183|http://www.cyberciti.biz/faq/ubuntu-linux-determine-your-ip-address/|Ubuntu Linux: Determine Your IP Address
17172|http://www.cyberciti.biz/faq/determine-ip-address-of-linux-server/|HowTo: Determine an IP Address My Linux Server
16510|http://www.cyberciti.biz/faq/unix-linux-restart-php-service-command/|Linux / Unix: Restart PHP Service Command
8292|http://www.cyberciti.biz/faq/mounting-harddisks-in-freebsd-with-mount-command/|FreeBSD: Mount Hard Drive / Disk Command
8190|http://www.cyberciti.biz/faq/rebooting-solaris-unix-server/|Reboot a Solaris UNIX System
```
我的 bash 脚本:
```
#!/bin/bash
# Usage: Create pdf files from input (wrapper script)
# Author: Vivek Gite <Www.cyberciti.biz> under GPL v2.x+
#---------------------------------------------------------
#Input file
_db="/tmp/wordpress/faq.txt"
#Output location
o="/var/www/prviate/pdf/faq"
_writer="~/bin/py/pdfwriter.py"
# If file exists
if [[ -f "$_db" ]]
then
# read it
while IFS='|' read -r pdfid pdfurl pdftitle
do
local pdf="$o/$pdfid.pdf"
echo "Creating $pdf file ..."
#Genrate pdf file
$_writer --quiet --footer-spacing 2 \
--footer-left "nixCraft is GIT UL++++ W+++ C++++ M+ e+++ d-" \
--footer-right "Page [page] of [toPage]" --footer-line \
--footer-font-size 7 --print-media-type "$pdfurl" "$pdf"
done <"$_db"
fi
```
### 技巧:从 bash 变量中读取
让我们看看如何在 Debian 或者 Ubuntu Linux 下列出所有安装过的 php 包,请输入:
```
# 我将输出内容赋值到一个变量名为 $list中 #
list=$(dpkg --list php\* | awk '/ii/{print $2}')
printf '%s\n' "$list"
```
示例输出:
```
php-pear
php5-cli
php5-common
php5-fpm
php5-gd
php5-json
php5-memcache
php5-mysql
php5-readline
php5-suhosin-extension
```
你现在可以从 $list 中看到它们,并安装这些包:
```
#!/bin/bash
# BASH can iterate over $list variable using a "here string" #
while IFS= read -r pkg
do
printf 'Installing php package %s...\n' "$pkg"
/usr/bin/apt-get -qq install $pkg
done <<< "$list"
printf '*** Do not forget to run php5enmod and restart the server (httpd or php5-fpm) ***\n'
```
示例输出:
```
Installing php package php-pear...
Installing php package php5-cli...
Installing php package php5-common...
Installing php package php5-fpm...
Installing php package php5-gd...
Installing php package php5-json...
Installing php package php5-memcache...
Installing php package php5-mysql...
Installing php package php5-readline...
Installing php package php5-suhosin-extension...
*** Do not forget to run php5enmod and restart the server (httpd or php5-fpm) ***
```
---
via: <http://www.cyberciti.biz/faq/unix-howto-read-line-by-line-from-file/>
作者: VIVEK GIT 译者:[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,120 | Alien 魔法:RPM 和 DEB 互转 | http://www.tecmint.com/convert-from-rpm-to-deb-and-deb-to-rpm-package-using-alien/ | 2015-08-31T10:45:15 | [
"Alien",
"RPM",
"DEB"
] | https://linux.cn/article-6120-1.html | 正如我确信,你们一定知道Linux下的多种软件安装方式:使用发行版所提供的包管理系统([aptitude,yum,或者zypper](http://www.tecmint.com/linux-package-management/),还可以举很多例子),从源码编译(尽管现在很少用了,但在Linux发展早期却是唯一可用的方法),或者使用各自的低级工具dpkg用于.deb,以及rpm用于.rpm,预编译包,如此这般。

*使用Alien将RPM转换成DEB以及将DEB转换成RPM*
在本文中,我们将为你介绍alien,一个用于在各种不同的Linux包格式相互转换的工具,其最常见的用法是将.rpm转换成.deb(或者反过来)。
如果你需要某个特定类型的包,而你只能找到其它格式的包的时候,该工具迟早能派得上用场——即使是其作者不再维护,并且在其网站声明:alien将可能永远维持在实验状态。
例如,有一次,我正查找一个用于喷墨打印机的.deb驱动,但是却没有找到——生产厂家只提供.rpm包,这时候alien拯救了我。我安装了alien,将包进行转换,不久之后我就可以使用我的打印机了,没有任何问题。
即便如此,我们也必须澄清一下,这个工具不应当用来转换重要的系统文件和库,因为它们在不同的发行版中有不同的配置。只有在前面说的那种情况下所建议的安装方法根本不适合时,alien才能作为最后手段使用。
最后一项要点是,我们必须注意,虽然我们在本文中使用CentOS和Debian,除了前两个发行版及其各自的家族体系外,据我们所知,alien可以工作在Slackware中,甚至Solaris中。
### 步骤1:安装Alien及其依赖包
要安装alien到CentOS/RHEL 7中,你需要启用EPEL和Nux Dextop(是的,是Dextop——不是Desktop)仓库,顺序如下:
```
# yum install epel-release
```
启用Nux Dextop仓库的包的当前最新版本是0.5(2015年8月10日发布),在安装之前你可以查看<http://li.nux.ro/download/nux/dextop/el7/x86_64/>上是否有更新的版本。
```
# rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
```
然后再做,
```
# yum update && yum install alien
```
在Fedora中,你只需要运行上面的命令即可。
在Debian及其衍生版中,只需要:
```
# aptitude install alien
```
### 步骤2:将.deb转换成.rpm包
对于本次测试,我们选择了date工具,它提供了一系列日期和时间工具用于处理大量金融数据。我们将下载.deb包到我们的CentOS 7机器中,将它转换成.rpm并安装:

检查CentOS版本
```
# cat /etc/centos-release
# wget http://ftp.us.debian.org/debian/pool/main/d/dateutils/dateutils_0.3.1-1.1_amd64.deb
# alien --to-rpm --scripts dateutils_0.3.1-1.1_amd64.deb
```

*在Linux中将.deb转换成.rpm*
**重要**:(请注意alien是怎样来增加目标包的次版本号的。如果你想要无视该行为,请添加-keep-version标识)。
如果我们尝试马上安装该包,我们将碰到些许问题:
```
# rpm -Uvh dateutils-0.3.1-2.1.x86_64.rpm
```

*安装RPM包*
要解决该问题,我们需要启用epel-testing仓库,然后安装rpmbuild工具来编辑该包的配置以重建包:
```
# yum --enablerepo=epel-testing install rpmrebuild
```
然后运行,
```
# rpmrebuild -pe dateutils-0.3.1-2.1.x86_64.rpm
```
它会打开你的默认文本编辑器。请转到`%files`章节并删除涉及到错误信息中提到的目录的行,然后保存文件并退出:

*转换.deb到Alien版*
但你退出该文件后,将提示你继续去重构。如果你选择“Y”,该文件会重构到指定的目录(与当前工作目录不同):
```
# rpmrebuild –pe dateutils-0.3.1-2.1.x86_64.rpm
```

*构建RPM包*
现在你可以像以往一样继续来安装包并验证:
```
# rpm -Uvh /root/rpmbuild/RPMS/x86_64/dateutils-0.3.1-2.1.x86_64.rpm
# rpm -qa | grep dateutils
```

*安装构建RPM包*
最后,你可以列出date工具包含的各个工具,也可以查看各自的手册页:
```
# ls -l /usr/bin | grep dateutils
```

*验证安装的RPM包*
### 步骤3:将.rpm转换成.deb包
在本节中,我们将演示如何将.rpm转换成.deb。在一台32位的Debian Wheezy机器中,让我们从CentOS 6操作系统仓库中下载用于zsh shell的.rpm包。注意,该shell在Debian及其衍生版的默认安装中是不可用的。
```
# cat /etc/shells
# lsb_release -a | tail -n 4
```

*检查Shell和Debian操作系统版本*
```
# wget http://mirror.centos.org/centos/6/os/i386/Packages/zsh-4.3.11-4.el6.centos.i686.rpm
# alien --to-deb --scripts zsh-4.3.11-4.el6.centos.i686.rpm
```
你可以安全地无视关于签名丢失的信息:

*将.rpm转换成.deb包*
过了一会儿后,.deb包应该已经生成,并可以安装了:
```
# dpkg -i zsh_4.3.11-5_i386.deb
```

*安装RPM转换来的Deb包*
安装完后,你看看可以zsh是否添加到了合法shell列表中:
```
# cat /etc/shells
```

*确认安装的Zsh包*
### 小结
在本文中,我们已经解释了如何将.rpm转换成.deb及其反向转换,这可以作为这类程序不能从仓库中或者作为可分发源代码获得的最后安装手段。你一定想要将本文添加到书签中,因为我们都需要alien。
请自由分享你关于本文的想法,写到下面的表单中吧。
---
via: <http://www.tecmint.com/convert-from-rpm-to-deb-and-deb-to-rpm-package-using-alien/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[GOLinux](https://github.com/GOLinux) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,121 | 在 Linux 下使用 RAID(五):安装 RAID 6(条带化双分布式奇偶校验) | http://www.tecmint.com/create-raid-6-in-linux/ | 2015-08-31T15:50:00 | [
"RAID"
] | https://linux.cn/article-6121-1.html | RAID 6 是 RAID 5 的升级版,它有两个分布式奇偶校验,即使两个磁盘发生故障后依然有容错能力。在两个磁盘同时发生故障时,系统的关键任务仍然能运行。它与 RAID 5 相似,但性能更健壮,因为它多用了一个磁盘来进行奇偶校验。
在之前的文章中,我们已经在 RAID 5 看了分布式奇偶校验,但在本文中,我们将看到的是 RAID 6 双分布式奇偶校验。不要期望比其他 RAID 有更好的性能,除非你也安装了一个专用的 RAID 控制器。在 RAID 6 中,即使我们失去了2个磁盘,我们仍可以通过更换磁盘,从校验中构建数据,然后取回数据。

*在 Linux 中安装 RAID 6*
要建立一个 RAID 6,一组最少需要4个磁盘。RAID 6 甚至在有些组中会有更多磁盘,这样将多个硬盘捆在一起,当读取数据时,它会同时从所有磁盘读取,所以读取速度会更快,当写数据时,因为它要将数据写在条带化的多个磁盘上,所以性能会较差。
现在,很多人都在讨论为什么我们需要使用 RAID 6,它的性能和其他 RAID 相比并不太好。提出这个问题首先需要知道的是,如果需要高容错性就选择 RAID 6。在每一个用于数据库的高可用性要求较高的环境中,他们需要 RAID 6 因为数据库是最重要,无论花费多少都需要保护其安全,它在视频流环境中也是非常有用的。
#### RAID 6 的的优点和缺点
* 性能不错。
* RAID 6 比较昂贵,因为它要求两个独立的磁盘用于奇偶校验功能。
* 将失去两个磁盘的容量来保存奇偶校验信息(双奇偶校验)。
* 即使两个磁盘损坏,数据也不会丢失。我们可以在更换损坏的磁盘后从校验中重建数据。
* 读性能比 RAID 5 更好,因为它从多个磁盘读取,但对于没有专用的 RAID 控制器的设备写性能将非常差。
#### 要求
要创建一个 RAID 6 最少需要4个磁盘。你也可以添加更多的磁盘,但你必须有专用的 RAID 控制器。使用软件 RAID 我们在 RAID 6 中不会得到更好的性能,所以我们需要一个物理 RAID 控制器。
如果你新接触 RAID 设置,我们建议先看完以下 RAID 文章。
* [介绍 RAID 的级别和概念](/article-6085-1.html)
* [使用 mdadm 工具创建软件 RAID 0 (条带化)](/article-6087-1.html)
* [用两块磁盘创建 RAID 1(镜像)](/article-6093-1.html)
* [创建 RAID 5(条带化与分布式奇偶校验)](/article-6102-1.html)
#### 我的服务器设置
```
操作系统 : CentOS 6.5 Final
IP 地址 : 192.168.0.228
主机名 : rd6.tecmintlocal.com
磁盘 1 [20GB] : /dev/sdb
磁盘 2 [20GB] : /dev/sdc
磁盘 3 [20GB] : /dev/sdd
磁盘 4 [20GB] : /dev/sde
```
这是9篇系列教程的第5部分,在这里我们将看到如何在 Linux 系统或者服务器上使用四个 20GB 的磁盘(名为 /dev/sdb、 /dev/sdc、 /dev/sdd 和 /dev/sde)创建和设置软件 RAID 6 (条带化双分布式奇偶校验)。
### 第1步:安装 mdadm 工具,并检查磁盘
1、 如果你按照我们最进的两篇 RAID 文章(第2篇和第3篇),我们已经展示了如何安装`mdadm`工具。如果你直接看的这篇文章,我们先来解释下在 Linux 系统中如何使用`mdadm`工具来创建和管理 RAID,首先根据你的 Linux 发行版使用以下命令来安装。
```
# yum install mdadm [在 RedHat 系统]
# apt-get install mdadm [在 Debain 系统]
```
2、 安装该工具后,然后来验证所需的四个磁盘,我们将会使用下面的`fdisk`命令来检查用于创建 RAID 的磁盘。
```
# fdisk -l | grep sd
```

*在 Linux 中检查磁盘*
3、 在创建 RAID 磁盘前,先检查下我们的磁盘是否创建过 RAID 分区。
```
# mdadm -E /dev/sd[b-e]
# mdadm --examine /dev/sdb /dev/sdc /dev/sdd /dev/sde # 或
```

*在磁盘上检查 RAID 分区*
**注意**: 在上面的图片中,没有检测到任何 super-block 或者说在四个磁盘上没有 RAID 存在。现在我们开始创建 RAID 6。
### 第2步:为 RAID 6 创建磁盘分区
4、 现在在 `/dev/sdb`, `/dev/sdc`, `/dev/sdd` 和 `/dev/sde`上为 RAID 创建分区,使用下面的 fdisk 命令。在这里,我们将展示如何在 sdb 磁盘创建分区,同样的步骤也适用于其他分区。
**创建 /dev/sdb 分区**
```
# fdisk /dev/sdb
```
请按照说明进行操作,如下图所示创建分区。
* 按 `n`创建新的分区。
* 然后按 `P` 选择主分区。
* 接下来选择分区号为1。
* 只需按两次回车键选择默认值即可。
* 然后,按 `P` 来打印创建好的分区。
* 按 `L`,列出所有可用的类型。
* 按 `t` 去修改分区。
* 键入 `fd` 设置为 Linux 的 RAID 类型,然后按回车确认。
* 然后再次使用`p`查看我们所做的更改。
* 使用`w`保存更改。

*创建 /dev/sdb 分区*
**创建 /dev/sdc 分区**
```
# fdisk /dev/sdc
```

*创建 /dev/sdc 分区*
**创建 /dev/sdd 分区**
```
# fdisk /dev/sdd
```

*创建 /dev/sdd 分区*
**创建 /dev/sde 分区**
```
# fdisk /dev/sde
```

*创建 /dev/sde 分区*
5、 创建好分区后,检查磁盘的 super-blocks 是个好的习惯。如果 super-blocks 不存在我们可以按前面的创建一个新的 RAID。
```
# mdadm -E /dev/sd[b-e]1
# mdadm --examine /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 # 或
```

\*在新分区中检查 RAID \*
### 第3步:创建 md 设备(RAID)
6、 现在可以使用以下命令创建 RAID 设备`md0` (即 /dev/md0),并在所有新创建的分区中应用 RAID 级别,然后确认 RAID 设置。
```
# mdadm --create /dev/md0 --level=6 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
# cat /proc/mdstat
```

*创建 Raid 6 设备*
7、 你还可以使用 watch 命令来查看当前创建 RAID 的进程,如下图所示。
```
# watch -n1 cat /proc/mdstat
```

*检查 RAID 6 创建过程*
8、 使用以下命令验证 RAID 设备。
```
# mdadm -E /dev/sd[b-e]1
```
**注意**::上述命令将显示四个磁盘的信息,这是相当长的,所以没有截取其完整的输出。
9、 接下来,验证 RAID 阵列,以确认重新同步过程已经开始。
```
# mdadm --detail /dev/md0
```

*检查 Raid 6 阵列*
### 第4步:在 RAID 设备上创建文件系统
10、 使用 ext4 为`/dev/md0`创建一个文件系统,并将它挂载在 /mnt/raid6 。这里我们使用的是 ext4,但你可以根据你的选择使用任意类型的文件系统。
```
# mkfs.ext4 /dev/md0
```

*在 RAID 6 上创建文件系统*
11、 将创建的文件系统挂载到 /mnt/raid6,并验证挂载点下的文件,我们可以看到 lost+found 目录。
```
# mkdir /mnt/raid6
# mount /dev/md0 /mnt/raid6/
# ls -l /mnt/raid6/
```
12、 在挂载点下创建一些文件,在任意文件中添加一些文字并验证其内容。
```
# touch /mnt/raid6/raid6_test.txt
# ls -l /mnt/raid6/
# echo "tecmint raid setups" > /mnt/raid6/raid6_test.txt
# cat /mnt/raid6/raid6_test.txt
```

*验证 RAID 内容*
13、 在 /etc/fstab 中添加以下条目使系统启动时自动挂载设备,操作系统环境不同挂载点可能会有所不同。
```
# vim /etc/fstab
/dev/md0 /mnt/raid6 ext4 defaults 0 0
```

*自动挂载 RAID 6 设备*
14、 接下来,执行`mount -a`命令来验证 fstab 中的条目是否有错误。
```
# mount -av
```

*验证 RAID 是否自动挂载*
### 第5步:保存 RAID 6 的配置
15、 请注意,默认情况下 RAID 没有配置文件。我们需要使用以下命令手动保存它,然后检查设备`/dev/md0`的状态。
```
# mdadm --detail --scan --verbose >> /etc/mdadm.conf
# cat /etc/mdadm.conf
# mdadm --detail /dev/md0
```

*保存 RAID 6 配置*

*检查 RAID 6 状态*
### 第6步:添加备用磁盘
16、 现在,已经使用了4个磁盘,并且其中两个作为奇偶校验信息来使用。在某些情况下,如果任意一个磁盘出现故障,我们仍可以得到数据,因为在 RAID 6 使用双奇偶校验。
如果第二个磁盘也出现故障,在第三块磁盘损坏前我们可以添加一个新的。可以在创建 RAID 集时加入一个备用磁盘,但我在创建 RAID 集合前没有定义备用的磁盘。不过,我们可以在磁盘损坏后或者创建 RAID 集合时添加一块备用磁盘。现在,我们已经创建好了 RAID,下面让我演示如何添加备用磁盘。
为了达到演示的目的,我已经热插入了一个新的 HDD 磁盘(即 /dev/sdf),让我们来验证接入的磁盘。
```
# ls -l /dev/ | grep sd
```

*检查新磁盘*
17、 现在再次确认新连接的磁盘没有配置过 RAID ,使用 mdadm 来检查。
```
# mdadm --examine /dev/sdf
```

*在新磁盘中检查 RAID*
**注意**: 像往常一样,我们早前已经为四个磁盘创建了分区,同样,我们使用 fdisk 命令为新插入的磁盘创建新分区。
```
# fdisk /dev/sdf
```

*为 /dev/sdf 创建分区*
18、 在 /dev/sdf 创建新的分区后,在新分区上确认没有 RAID,然后将备用磁盘添加到 RAID 设备 /dev/md0 中,并验证添加的设备。
```
# mdadm --examine /dev/sdf
# mdadm --examine /dev/sdf1
# mdadm --add /dev/md0 /dev/sdf1
# mdadm --detail /dev/md0
```

*在 sdf 分区上验证 Raid*

\*添加 sdf 分区到 RAID \*

*验证 sdf 分区信息*
### 第7步:检查 RAID 6 容错
19、 现在,让我们检查备用驱动器是否能自动工作,当我们阵列中的任何一个磁盘出现故障时。为了测试,我将一个磁盘手工标记为故障设备。
在这里,我们标记 /dev/sdd1 为故障磁盘。
```
# mdadm --manage --fail /dev/md0 /dev/sdd1
```

*检查 RAID 6 容错*
20、 让我们查看 RAID 的详细信息,并检查备用磁盘是否开始同步。
```
# mdadm --detail /dev/md0
```

*检查 RAID 自动同步*
**哇塞!** 这里,我们看到备用磁盘激活了,并开始重建进程。在底部,我们可以看到有故障的磁盘 /dev/sdd1 标记为 faulty。可以使用下面的命令查看进程重建。
```
# cat /proc/mdstat
```

*RAID 6 自动同步*
### 结论:
在这里,我们看到了如何使用四个磁盘设置 RAID 6。这种 RAID 级别是具有高冗余的昂贵设置之一。在接下来的文章中,我们将看到如何建立一个嵌套的 RAID 10 甚至更多。请继续关注。
---
via: <http://www.tecmint.com/create-raid-6-in-linux/>
作者:[Babin Lonston](http://www.tecmint.com/author/babinlonston/) 译者:[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,122 | 在 Linux 下使用 RAID(六):设置 RAID 10 或 1 + 0(嵌套) | http://www.tecmint.com/create-raid-10-in-linux/ | 2015-09-01T08:51:00 | [
"RAID"
] | https://linux.cn/article-6122-1.html | RAID 10 是组合 RAID 1 和 RAID 0 形成的。要设置 RAID 10,我们至少需要4个磁盘。在之前的文章中,我们已经看到了如何使用最少两个磁盘设置 RAID 1 和 RAID 0。
在这里,我们将使用最少4个磁盘组合 RAID 1 和 RAID 0 来设置 RAID 10。假设我们已经在用 RAID 10 创建的逻辑卷保存了一些数据。比如我们要保存数据 “TECMINT”,它将使用以下方法将其保存在4个磁盘中。

*在 Linux 中创建 Raid 10(LCTT 译注:原图有误,已修正)*
RAID 10 是先做镜像,再做条带。因此,在 RAID 1 中,相同的数据将被写入到两个磁盘中,“T”将同时被写入到第一和第二个磁盘中。接着的数据被条带化到另外两个磁盘,“E”将被同时写入到第三和第四个磁盘中。它将继续循环此过程,“C”将同时被写入到第一和第二个磁盘,以此类推。
(LCTT 译注:原文中此处描述混淆有误,已经根据实际情况进行修改。)
现在你已经了解 RAID 10 怎样组合 RAID 1 和 RAID 0 来工作的了。如果我们有4个20 GB 的磁盘,总共为 80 GB,但我们将只能得到40 GB 的容量,另一半的容量在构建 RAID 10 中丢失。
#### RAID 10 的优点和缺点
* 提供更好的性能。
* 在 RAID 10 中我们将失去一半的磁盘容量。
* 读与写的性能都很好,因为它会同时进行写入和读取。
* 它能解决数据库的高 I/O 磁盘写操作。
#### 要求
在 RAID 10 中,我们至少需要4个磁盘,前2个磁盘为 RAID 1,其他2个磁盘为 RAID 0,就像我之前说的,RAID 10 仅仅是组合了 RAID 0和1。如果我们需要扩展 RAID 组,最少需要添加4个磁盘。
**我的服务器设置**
```
操作系统 : CentOS 6.5 Final
IP 地址 : 192.168.0.229
主机名 : rd10.tecmintlocal.com
磁盘 1 [20GB] : /dev/sdd
磁盘 2 [20GB] : /dev/sdc
磁盘 3 [20GB] : /dev/sdd
磁盘 4 [20GB] : /dev/sde
```
有两种方法来设置 RAID 10,在这里两种方法我都会演示,但我更喜欢第一种方法,使用它来设置 RAID 10 更简单。
### 方法1:设置 RAID 10
1、 首先,使用以下命令确认所添加的4块磁盘没有被使用。
```
# ls -l /dev | grep sd
```
2、 四个磁盘被检测后,然后来检查磁盘是否存在 RAID 分区。
```
# mdadm -E /dev/sd[b-e]
# mdadm --examine /dev/sdb /dev/sdc /dev/sdd /dev/sde # 或
```

*验证添加的4块磁盘*
**注意**: 在上面的输出中,如果没有检测到 super-block 意味着在4块磁盘中没有定义过 RAID。
#### 第1步:为 RAID 分区
3、 现在,使用`fdisk`,命令为4个磁盘(/dev/sdb, /dev/sdc, /dev/sdd 和 /dev/sde)创建新分区。
```
# fdisk /dev/sdb
# fdisk /dev/sdc
# fdisk /dev/sdd
# fdisk /dev/sde
```
##### 为 /dev/sdb 创建分区
我来告诉你如何使用 fdisk 为磁盘(/dev/sdb)进行分区,此步也适用于其他磁盘。
```
# fdisk /dev/sdb
```
请使用以下步骤为 /dev/sdb 创建一个新的分区。
* 按 `n` 创建新的分区。
* 然后按 `P` 选择主分区。
* 接下来选择分区号为1。
* 只需按两次回车键选择默认值即可。
* 然后,按 `P` 来打印创建好的分区。
* 按 `L`,列出所有可用的类型。
* 按 `t` 去修改分区。
* 键入 `fd` 设置为 Linux 的 RAID 类型,然后按 Enter 确认。
* 然后再次使用`p`查看我们所做的更改。
* 使用`w`保存更改。

*为磁盘 sdb 分区*
**注意**: 请使用上面相同的指令对其他磁盘(sdc, sdd sdd sde)进行分区。
4、 创建好4个分区后,需要使用下面的命令来检查磁盘是否存在 raid。
```
# mdadm -E /dev/sd[b-e]
# mdadm --examine /dev/sdb /dev/sdc /dev/sdd /dev/sde # 或
# mdadm -E /dev/sd[b-e]1
# mdadm --examine /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 # 或
```

*检查磁盘*
**注意**: 以上输出显示,新创建的四个分区中没有检测到 super-block,这意味着我们可以继续在这些磁盘上创建 RAID 10。
#### 第2步: 创建 RAID 设备 `md`
5、 现在该创建一个`md`(即 /dev/md0)设备了,使用“mdadm” raid 管理工具。在创建设备之前,必须确保系统已经安装了`mdadm`工具,如果没有请使用下面的命令来安装。
```
# yum install mdadm [在 RedHat 系统]
# apt-get install mdadm [在 Debain 系统]
```
`mdadm`工具安装完成后,可以使用下面的命令创建一个`md` raid 设备。
```
# mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/sd[b-e]1
```
6、 接下来使用`cat`命令验证新创建的 raid 设备。
```
# cat /proc/mdstat
```

*创建 md RAID 设备*
7、 接下来,使用下面的命令来检查4个磁盘。下面命令的输出会很长,因为它会显示4个磁盘的所有信息。
```
# mdadm --examine /dev/sd[b-e]1
```
8、 接下来,使用以下命令来查看 RAID 阵列的详细信息。
```
# mdadm --detail /dev/md0
```

*查看 RAID 阵列详细信息*
**注意**: 你在上面看到的结果,该 RAID 的状态是 active 和re-syncing。
#### 第3步:创建文件系统
9、 使用 ext4 作为`md0′的文件系统,并将它挂载到`/mnt/raid10`下。在这里,我用的是 ext4,你可以使用你想要的文件系统类型。
```
# mkfs.ext4 /dev/md0
```

*创建 md 文件系统*
10、 在创建文件系统后,挂载文件系统到`/mnt/raid10`下,并使用`ls -l`命令列出挂载点下的内容。
```
# mkdir /mnt/raid10
# mount /dev/md0 /mnt/raid10/
# ls -l /mnt/raid10/
```
接下来,在挂载点下创建一些文件,并在文件中添加些内容,然后检查内容。
```
# touch /mnt/raid10/raid10_files.txt
# ls -l /mnt/raid10/
# echo "raid 10 setup with 4 disks" > /mnt/raid10/raid10_files.txt
# cat /mnt/raid10/raid10_files.txt
```

*挂载 md 设备*
11、 要想自动挂载,打开`/etc/fstab`文件并添加下面的条目,挂载点根据你环境的不同来添加。使用 wq! 保存并退出。
```
# vim /etc/fstab
/dev/md0 /mnt/raid10 ext4 defaults 0 0
```

*挂载 md 设备*
12、 接下来,在重新启动系统前使用`mount -a`来确认`/etc/fstab`文件是否有错误。
```
# mount -av
```

*检查 Fstab 中的错误*
#### 第四步:保存 RAID 配置
13、 默认情况下 RAID 没有配置文件,所以我们需要在上述步骤完成后手动保存它。
```
# mdadm --detail --scan --verbose >> /etc/mdadm.conf
```

*保存 RAID10 的配置*
就这样,我们使用方法1创建完了 RAID 10,这种方法是比较容易的。现在,让我们使用方法2来设置 RAID 10。
### 方法2:创建 RAID 10
1、 在方法2中,我们必须定义2组 RAID 1,然后我们需要使用这些创建好的 RAID 1 的集合来定义一个 RAID 0。在这里,我们将要做的是先创建2个镜像(RAID1),然后创建 RAID0 (条带化)。
首先,列出所有的可用于创建 RAID 10 的磁盘。
```
# ls -l /dev | grep sd
```

*列出了 4 个设备*
2、 将4个磁盘使用`fdisk`命令进行分区。对于如何分区,您可以按照上面的第1步。
```
# fdisk /dev/sdb
# fdisk /dev/sdc
# fdisk /dev/sdd
# fdisk /dev/sde
```
3、 在完成4个磁盘的分区后,现在检查磁盘是否存在 RAID块。
```
# mdadm --examine /dev/sd[b-e]
# mdadm --examine /dev/sd[b-e]1
```

*检查 4 个磁盘*
#### 第1步:创建 RAID 1
4、 首先,使用4块磁盘创建2组 RAID 1,一组为`sdb1′和`sdc1′,另一组是`sdd1′ 和`sde1′。
```
# mdadm --create /dev/md1 --metadata=1.2 --level=1 --raid-devices=2 /dev/sd[b-c]1
# mdadm --create /dev/md2 --metadata=1.2 --level=1 --raid-devices=2 /dev/sd[d-e]1
# cat /proc/mdstat
```

*创建 RAID 1*

*查看 RAID 1 的详细信息*
#### 第2步:创建 RAID 0
5、 接下来,使用 md1 和 md2 来创建 RAID 0。
```
# mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/md1 /dev/md2
# cat /proc/mdstat
```

*创建 RAID 0*
#### 第3步:保存 RAID 配置
6、 我们需要将配置文件保存在`/etc/mdadm.conf`文件中,使其每次重新启动后都能加载所有的 RAID 设备。
```
# mdadm --detail --scan --verbose >> /etc/mdadm.conf
```
在此之后,我们需要按照方法1中的第3步来创建文件系统。
就是这样!我们采用的方法2创建完了 RAID 1+0。我们将会失去一半的磁盘空间,但相比其他 RAID ,它的性能将是非常好的。
### 结论
在这里,我们采用两种方法创建 RAID 10。RAID 10 具有良好的性能和冗余性。希望这篇文章可以帮助你了解 RAID 10 嵌套 RAID。在后面的文章中我们会看到如何扩展现有的 RAID 阵列以及更多精彩的内容。
---
via: <http://www.tecmint.com/create-raid-10-in-linux/>
作者:[Babin Lonston](http://www.tecmint.com/author/babinlonston/) 译者:[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,123 | 在 Linux 下使用 RAID(七):在 RAID 中扩展现有的 RAID 阵列和删除故障的磁盘 | http://www.tecmint.com/grow-raid-array-in-linux/ | 2015-09-02T09:25:00 | [
"RAID"
] | https://linux.cn/article-6123-1.html | 每个新手都会对阵列(array)这个词所代表的意思产生疑惑。阵列只是磁盘的一个集合。换句话说,我们可以称阵列为一个集合(set)或一组(group)。就像一组鸡蛋中包含6个一样。同样 RAID 阵列中包含着多个磁盘,可能是2,4,6,8,12,16等,希望你现在知道了什么是阵列。
在这里,我们将看到如何扩展现有的阵列或 RAID 组。例如,如果我们在阵列中使用2个磁盘形成一个 raid 1 集合,在某些情况,如果该组中需要更多的空间,就可以使用 mdadm -grow 命令来扩展阵列大小,只需要将一个磁盘加入到现有的阵列中即可。在说完扩展(添加磁盘到现有的阵列中)后,我们将看看如何从阵列中删除故障的磁盘。

*扩展 RAID 阵列和删除故障的磁盘*
假设磁盘中的一个有问题了需要删除该磁盘,但我们需要在删除磁盘前添加一个备用磁盘来扩展该镜像,因为我们需要保存我们的数据。当磁盘发生故障时我们需要从阵列中删除它,这是这个主题中我们将要学习到的。
#### 扩展 RAID 的特性
* 我们可以增加(扩展)任意 RAID 集合的大小。
* 我们可以在使用新磁盘扩展 RAID 阵列后删除故障的磁盘。
* 我们可以扩展 RAID 阵列而无需停机。
#### 要求
* 为了扩展一个RAID阵列,我们需要一个已有的 RAID 组(阵列)。
* 我们需要额外的磁盘来扩展阵列。
* 在这里,我们使用一块磁盘来扩展现有的阵列。
在我们了解扩展和恢复阵列前,我们必须了解有关 RAID 级别和设置的基本知识。点击下面的链接了解这些。
* [介绍 RAID 的级别和概念](/article-6085-1.html)
* [使用 mdadm 工具创建软件 RAID 0 (条带化)](/article-6087-1.html)
#### 我的服务器设置
```
操作系统 : CentOS 6.5 Final
IP地址 : 192.168.0.230
主机名 : grow.tecmintlocal.com
2 块现有磁盘 : 1 GB
1 块额外磁盘 : 1 GB
```
在这里,我们已有一个 RAID ,有2块磁盘,每个大小为1GB,我们现在再增加一个磁盘到我们现有的 RAID 阵列中,其大小为1GB。
### 扩展现有的 RAID 阵列
1、 在扩展阵列前,首先使用下面的命令列出现有的 RAID 阵列。
```
# mdadm --detail /dev/md0
```

*检查现有的 RAID 阵列*
**注意**: 以上输出显示,已经有了两个磁盘在 RAID 阵列中,级别为 RAID 1。现在我们增加一个磁盘到现有的阵列里。
2、 现在让我们添加新的磁盘“sdd”,并使用`fdisk`命令来创建分区。
```
# fdisk /dev/sdd
```
请使用以下步骤为 /dev/sdd 创建一个新的分区。
* 按 `n` 创建新的分区。
* 然后按 `P` 选择主分区。
* 接下来选择分区号为1。
* 只需按两次回车键选择默认值即可。
* 然后,按 `P` 来打印创建好的分区。
* 按 `L`,列出所有可用的类型。
* 按 `t` 去修改分区。
* 键入 `fd` 设置为 Linux 的 RAID 类型,然后按回车确认。
* 然后再次使用`p`查看我们所做的更改。
* 使用`w`保存更改。

*为 sdd 创建新的分区*
3、 一旦新的 sdd 分区创建完成后,你可以使用下面的命令验证它。
```
# ls -l /dev/ | grep sd
```

*确认 sdd 分区*
4、 接下来,在添加到阵列前先检查磁盘是否有 RAID 分区。
```
# mdadm --examine /dev/sdd1
```

*在 sdd 分区中检查 RAID*
**注意**:以上输出显示,该盘有没有发现 super-blocks,意味着我们可以将新的磁盘添加到现有阵列。
5、 要添加新的分区 /dev/sdd1 到现有的阵列 md0,请使用以下命令。
```
# mdadm --manage /dev/md0 --add /dev/sdd1
```

*添加磁盘到 RAID 阵列*
6、 一旦新的磁盘被添加后,在我们的阵列中检查新添加的磁盘。
```
# mdadm --detail /dev/md0
```

*确认将新磁盘添加到 RAID 中*
**注意**: 在上面的输出,你可以看到磁盘已经被添加作为备用的。在这里,我们的阵列中已经有了2个磁盘,但我们期待阵列中有3个磁盘,因此我们需要扩展阵列。
7、 要扩展阵列,我们需要使用下面的命令。
```
# mdadm --grow --raid-devices=3 /dev/md0
```

*扩展 Raid 阵列*
现在我们可以看到第三块磁盘(sdd1)已被添加到阵列中,在第三块磁盘被添加后,它将从另外两块磁盘上同步数据。
```
# mdadm --detail /dev/md0
```

*确认 Raid 阵列*
**注意**: 对于大容量磁盘会需要几个小时来同步数据。在这里,我们使用的是1GB的虚拟磁盘,所以它非常快在几秒钟内便会完成。
### 从阵列中删除磁盘
8、 在数据被从其他两个磁盘同步到新磁盘`sdd1`后,现在三个磁盘中的数据已经相同了(镜像)。
正如我前面所说的,假定一个磁盘出问题了需要被删除。所以,现在假设磁盘`sdc1`出问题了,需要从现有阵列中删除。
在删除磁盘前我们要将其标记为失效,然后我们才可以将其删除。
```
# mdadm --fail /dev/md0 /dev/sdc1
# mdadm --detail /dev/md0
```

*在 RAID 阵列中模拟磁盘故障*
从上面的输出中,我们清楚地看到,磁盘在下面被标记为 faulty。即使它是 faulty 的,我们仍然可以看到 raid 设备有3个,1个损坏了,状态是 degraded。
现在我们要从阵列中删除 faulty 的磁盘,raid 设备将像之前一样继续有2个设备。
```
# mdadm --remove /dev/md0 /dev/sdc1
```

*在 Raid 阵列中删除磁盘*
9、 一旦故障的磁盘被删除,然后我们只能使用2个磁盘来扩展 raid 阵列了。
```
# mdadm --grow --raid-devices=2 /dev/md0
# mdadm --detail /dev/md0
```

*在 RAID 阵列扩展磁盘*
从上面的输出中可以看到,我们的阵列中仅有2台设备。如果你需要再次扩展阵列,按照如上所述的同样步骤进行。如果你需要添加一个磁盘作为备用,将其标记为 spare,因此,如果磁盘出现故障时,它会自动顶上去并重建数据。
### 结论
在这篇文章中,我们已经看到了如何扩展现有的 RAID 集合,以及如何在重新同步已有磁盘的数据后从一个阵列中删除故障磁盘。所有这些步骤都可以不用停机来完成。在数据同步期间,系统用户,文件和应用程序不会受到任何影响。
在接下来的文章我将告诉你如何管理 RAID,敬请关注更新,不要忘了写评论。
---
via: <http://www.tecmint.com/grow-raid-array-in-linux/>
作者:[Babin Lonston](http://www.tecmint.com/author/babinlonston/) 译者:[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,124 | Linux 4.3 将移除 EXT3 文件系统驱动 | http://www.phoronix.com/scan.php?page=news_item&px=EXT3-File-System-Drop-4.3 | 2015-08-31T23:15:59 | [
"文件系统",
"内核",
"ext3"
] | https://linux.cn/article-6124-1.html | 正在开发中的 [Linux 4.3](http://www.phoronix.com/scan.php?page=search&q=Linux+4.3) 已经确定会移除 EXT3 文件系统的驱动。
这个移除 EXT3 驱动的代码请求今天早上发给了内核主线。上个月的 [EXT3 文件系统驱动将从 Linux 内核中移除](http://www.phoronix.com/scan.php?page=news_item&px=Linux-Kernel-Dropping-EXT3) 一文中有更多的细节。
长话短说,EXT4 驱动已经稳定有年,而且它向后兼容 EXT2/EXT3 文件系统。SUSE 的 Jan Kara 从 Linux 4.3 中去除 EXT3 驱动将会让内核减少两万八千行代码。同时,内核的 VM 和块设备层的 EXT3 特定的修复也会被移除。 (LCTT 译注:所以不用担心,你的 ext3 文件系统的分区依旧可以使用,ext4 驱动会兼容它们的。)

这个代码请求现在可以在 [LKML](https://lkml.org/lkml/2015/8/31/22) 上看到。上个月 Kara 准备移除 EXT3 驱动时,他就基本上得到大家的同意。
| 301 | Moved Permanently | null |
6,126 | Ubuntu 上使用 LVM 轻松调整分区并制作快照 | http://www.howtogeek.com/211937/how-to-use-lvm-on-ubuntu-for-easy-partition-resizing-and-snapshots/ | 2015-09-01T08:42:00 | [
"LVM"
] | https://linux.cn/article-6126-1.html | 
Ubuntu的安装器提供了一个轻松“使用LVM”的复选框。它的描述中说,启用逻辑卷管理可以让你制作快照,并更容易地调整硬盘分区大小——这里将为大家讲述如何完成这些操作。
LVM是一种技术,某种程度上和[RAID阵列](http://www.howtogeek.com/162676/how-to-use-multiple-disks-intelligently-an-introduction-to-raid/)或[Windows上的“存储空间”](http://www.howtogeek.com/109380/how-to-use-windows-8s-storage-spaces-to-mirror-combine-drives/)类似。虽然该技术在服务器上更为有用,但是它也可以在桌面端PC上使用。
### 你应该在新安装Ubuntu时使用LVM吗?
第一个问题是,你是否想要在安装Ubuntu时使用LVM?如果是,那么Ubuntu让这一切变得很简单,只需要轻点鼠标就可以完成,但是该选项默认是不启用的。正如安装器所说的,它允许你调整分区、创建快照、将多个磁盘合并到一个逻辑卷等等——所有这一切都可以在系统运行时完成。不同于传统分区,你不需要关掉你的系统,从Live CD或USB驱动,然后[当这些分区不使用时才能调整](http://www.howtogeek.com/114503/how-to-resize-your-ubuntu-partitions/)。
完全坦率地说,普通Ubuntu桌面用户可能不会意识到他们是否正在使用LVM。但是,如果你想要在今后做一些更高深的事情,那么LVM就会有所帮助了。LVM可能更复杂,可能会在你今后恢复数据时会导致问题——尤其是在你经验不足时。这里不会有显著的性能损失——LVM是彻底地在Linux内核中实现的。

### 逻辑卷管理说明
前面,我们已经[说明了何谓LVM](http://www.howtogeek.com/howto/40702/how-to-manage-and-use-lvm-logical-volume-management-in-ubuntu/)。概括来讲,它在你的物理磁盘和呈现在你系统中的分区之间提供了一个抽象层。例如,你的计算机可能装有两个硬盘驱动器,它们的大小都是 1 TB。你必须得在这些磁盘上至少分两个区,每个区大小 1 TB。
LVM就在这些分区上提供了一个抽象层。用于取代磁盘上的传统分区,LVM将在你对这些磁盘初始化后,将它们当作独立的“物理卷”来对待。然后,你就可以基于这些物理卷创建“逻辑卷”。例如,你可以将这两个 1 TB 的磁盘组合成一个 2 TB 的分区,你的系统将只看到一个 2 TB 的卷,而LVM将会在后台处理这一切。一组物理卷以及一组逻辑卷被称之为“卷组”,一个典型的系统只会有一个卷组。
该抽象层使得调整分区、将多个磁盘组合成单个卷、甚至为一个运行着的分区的文件系统创建“快照”变得十分简单,而完成所有这一切都无需先卸载分区。
注意,如果你没有创建备份,那么将多个磁盘合并成一个卷将会是个糟糕的想法。它就像RAID 0——如果你将两个 1 TB 的卷组合成一个 2 TB 的卷,只要其中一个硬盘失败,你将丢失该卷上的重要数据。所以,如果你要走这条路,那么备份就及其重要。
### 管理LVM卷的图形化工具
通常,[LVM通过Linux终端命令来管理](http://www.howtogeek.com/howto/40702/how-to-manage-and-use-lvm-logical-volume-management-in-ubuntu/)。这在Ubuntu上也行得通,但是有个更简单的图形化方法可供大家采用。如果你是一个Linux用户,对GParted或者与其类似的分区管理器熟悉,算了,别瞎掰了——GParted根本不支持LVM磁盘。
然而,你可以使用Ubuntu附带的磁盘工具。该工具也被称之为GNOME磁盘工具,或者叫Palimpsest。点击dash中的图标来开启它吧,搜索“磁盘”然后敲击回车。不像GParted,该磁盘工具将会在“其它设备”下显示LVM分区,因此你可以根据需要格式化这些分区,也可以调整其它选项。该工具在Live CD或USB 驱动下也可以使用。

不幸的是,该磁盘工具不支持LVM的大多数强大的特性,没有管理卷组、扩展分区,或者创建快照等选项。对于这些操作,你可以通过终端来实现,但是没有那个必要。相反,你可以打开Ubuntu软件中心,搜索关键字LVM,然后安装逻辑卷管理工具,你可以在终端窗口中运行**sudo apt-get install system-config-lvm**命令来安装它。安装完之后,你就可以从dash上打开逻辑卷管理工具了。
这个图形化配置工具是由红帽公司开发的,虽然有点陈旧了,但却是唯一的图形化方式,你可以通过它来完成上述操作,将那些终端命令抛诸脑后了。
比如说,你想要添加一个新的物理卷到卷组中。你可以打开该工具,选择未初始化条目下的新磁盘,然后点击“初始化条目”按钮。然后,你就可以在未分配卷下找到新的物理卷了,你可以使用“添加到现存卷组”按钮来将它添加到“ubuntu-vg”卷组,这是Ubuntu在安装过程中创建的卷组。

卷组视图会列出你所有的物理卷和逻辑卷的总览。这里,我们有两个横跨两个独立硬盘驱动器的物理分区,我们有一个交换分区和一个根分区,这是Ubuntu默认设置的分区图表。由于我们从另一个驱动器添加了第二个物理分区,现在那里有大量未使用空间。

要扩展逻辑分区到物理空间,你可以在逻辑视图下选择它,点击编辑属性,然后修改大小来扩大分区。你也可以在这里缩小分区。

system-config-lvm的其它选项允许你设置快照和镜像。对于传统桌面而言,你或许不需要这些特性,但是在这里也可以通过图形化处理。记住,你也可以[使用终端命令完成这一切](http://www.howtogeek.com/howto/40702/how-to-manage-and-use-lvm-logical-volume-management-in-ubuntu/)。
---
via: <http://www.howtogeek.com/211937/how-to-use-lvm-on-ubuntu-for-easy-partition-resizing-and-snapshots/>
译者:[GOLinux](https://github.com/GOLinux) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,127 | fdupes:Linux 中查找并删除重复文件的命令行工具 | http://www.tecmint.com/fdupes-find-and-delete-duplicate-files-in-linux/ | 2015-09-01T14:13:00 | [
"fdupes",
"重复"
] | https://linux.cn/article-6127-1.html | 对于大多数计算机用户而言,查找并替换重复的文件是一个常见的需求。查找并移除重复文件真是一项令人不胜其烦的工作,它耗时又耗力。但如果你的机器上跑着GNU/Linux,那么查找重复文件会变得十分简单,这多亏了`fdupes`工具。

*fdupes——在Linux中查找并删除重复文件*
### fdupes是啥东东?
**fdupes**是Linux下的一个工具,它由**Adrian Lopez**用C编程语言编写并基于MIT许可证发行,该应用程序可以在指定的目录及子目录中查找重复的文件。fdupes通过对比文件的MD5签名,以及逐字节比较文件来识别重复内容,fdupes有各种选项,可以实现对文件的列出、删除、替换为文件副本的硬链接等操作。
文件对比以下列顺序开始:
**大小对比 > 部分 MD5 签名对比 > 完整 MD5 签名对比 > 逐字节对比**
### 安装 fdupes 到 Linux
在基于**Debian**的系统上,如**Ubuntu**和**Linux Mint**,安装最新版fdupes,用下面的命令手到擒来。
```
$ sudo apt-get install fdupes
```
在基于CentOS/RHEL和Fedora的系统上,你需要开启[epel仓库](/article-2324-1.html)来安装fdupes包。
```
# yum install fdupes
# dnf install fdupes [在 Fedora 22 及其以后]
```
**注意**:自Fedora 22之后,默认的包管理器yum被dnf取代了。
### fdupes命令如何使用
1、 作为演示的目的,让我们来在某个目录(比如 tecmint)下创建一些重复文件,命令如下:
```
$ mkdir /home/"$USER"/Desktop/tecmint && cd /home/"$USER"/Desktop/tecmint && for i in {1..15}; do echo "I Love Tecmint. Tecmint is a very nice community of Linux Users." > tecmint${i}.txt ; done
```
在执行以上命令后,让我们使用ls[命令](/article-5109-1.html)验证重复文件是否创建。
```
$ ls -l
total 60
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint10.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint11.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint12.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint13.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint14.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint15.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint1.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint2.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint3.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint4.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint5.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint6.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint7.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint8.txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint9.txt
```
上面的脚本创建了**15**个文件,名称分别为tecmint1.txt,tecmint2.txt……tecmint15.txt,并且每个文件的数据相同,如
```
"I Love Tecmint. Tecmint is a very nice community of Linux Users."
```
2、 现在在**tecmint**文件夹内搜索重复的文件。
```
$ fdupes /home/$USER/Desktop/tecmint
/home/tecmint/Desktop/tecmint/tecmint13.txt
/home/tecmint/Desktop/tecmint/tecmint8.txt
/home/tecmint/Desktop/tecmint/tecmint11.txt
/home/tecmint/Desktop/tecmint/tecmint3.txt
/home/tecmint/Desktop/tecmint/tecmint4.txt
/home/tecmint/Desktop/tecmint/tecmint6.txt
/home/tecmint/Desktop/tecmint/tecmint7.txt
/home/tecmint/Desktop/tecmint/tecmint9.txt
/home/tecmint/Desktop/tecmint/tecmint10.txt
/home/tecmint/Desktop/tecmint/tecmint2.txt
/home/tecmint/Desktop/tecmint/tecmint5.txt
/home/tecmint/Desktop/tecmint/tecmint14.txt
/home/tecmint/Desktop/tecmint/tecmint1.txt
/home/tecmint/Desktop/tecmint/tecmint15.txt
/home/tecmint/Desktop/tecmint/tecmint12.txt
```
3、 使用**-r**选项在每个目录包括其子目录中递归搜索重复文件。
它会递归搜索所有文件和文件夹,花一点时间来扫描重复文件,时间的长短取决于文件和文件夹的数量。在此其间,终端中会显示全部过程,像下面这样。
```
$ fdupes -r /home
Progress [37780/54747] 69%
```
4、 使用**-S**选项来查看某个文件夹内找到的重复文件的大小。
```
$ fdupes -S /home/$USER/Desktop/tecmint
65 bytes each:
/home/tecmint/Desktop/tecmint/tecmint13.txt
/home/tecmint/Desktop/tecmint/tecmint8.txt
/home/tecmint/Desktop/tecmint/tecmint11.txt
/home/tecmint/Desktop/tecmint/tecmint3.txt
/home/tecmint/Desktop/tecmint/tecmint4.txt
/home/tecmint/Desktop/tecmint/tecmint6.txt
/home/tecmint/Desktop/tecmint/tecmint7.txt
/home/tecmint/Desktop/tecmint/tecmint9.txt
/home/tecmint/Desktop/tecmint/tecmint10.txt
/home/tecmint/Desktop/tecmint/tecmint2.txt
/home/tecmint/Desktop/tecmint/tecmint5.txt
/home/tecmint/Desktop/tecmint/tecmint14.txt
/home/tecmint/Desktop/tecmint/tecmint1.txt
/home/tecmint/Desktop/tecmint/tecmint15.txt
/home/tecmint/Desktop/tecmint/tecmint12.txt
```
5、 你可以同时使用**-S**和**-r**选项来查看所有涉及到的目录和子目录中的重复文件的大小,如下:
```
$ fdupes -Sr /home/avi/Desktop/
65 bytes each:
/home/tecmint/Desktop/tecmint/tecmint13.txt
/home/tecmint/Desktop/tecmint/tecmint8.txt
/home/tecmint/Desktop/tecmint/tecmint11.txt
/home/tecmint/Desktop/tecmint/tecmint3.txt
/home/tecmint/Desktop/tecmint/tecmint4.txt
/home/tecmint/Desktop/tecmint/tecmint6.txt
/home/tecmint/Desktop/tecmint/tecmint7.txt
/home/tecmint/Desktop/tecmint/tecmint9.txt
/home/tecmint/Desktop/tecmint/tecmint10.txt
/home/tecmint/Desktop/tecmint/tecmint2.txt
/home/tecmint/Desktop/tecmint/tecmint5.txt
/home/tecmint/Desktop/tecmint/tecmint14.txt
/home/tecmint/Desktop/tecmint/tecmint1.txt
/home/tecmint/Desktop/tecmint/tecmint15.txt
/home/tecmint/Desktop/tecmint/tecmint12.txt
107 bytes each:
/home/tecmint/Desktop/resume_files/r-csc.html
/home/tecmint/Desktop/resume_files/fc.html
```
6、 不同于在一个或所有文件夹内递归搜索,你可以选择按要求有选择性地在两个或三个文件夹内进行搜索。不必再提醒你了吧,如有需要,你可以使用**-S**和/或**-r**选项。
```
$ fdupes /home/avi/Desktop/ /home/avi/Templates/
```
7、 要删除重复文件,同时保留一个副本,你可以使用`-d`选项。使用该选项,你必须额外小心,否则最终结果可能会是文件/数据的丢失。郑重提醒,此操作不可恢复。
```
$ fdupes -d /home/$USER/Desktop/tecmint
[1] /home/tecmint/Desktop/tecmint/tecmint13.txt
[2] /home/tecmint/Desktop/tecmint/tecmint8.txt
[3] /home/tecmint/Desktop/tecmint/tecmint11.txt
[4] /home/tecmint/Desktop/tecmint/tecmint3.txt
[5] /home/tecmint/Desktop/tecmint/tecmint4.txt
[6] /home/tecmint/Desktop/tecmint/tecmint6.txt
[7] /home/tecmint/Desktop/tecmint/tecmint7.txt
[8] /home/tecmint/Desktop/tecmint/tecmint9.txt
[9] /home/tecmint/Desktop/tecmint/tecmint10.txt
[10] /home/tecmint/Desktop/tecmint/tecmint2.txt
[11] /home/tecmint/Desktop/tecmint/tecmint5.txt
[12] /home/tecmint/Desktop/tecmint/tecmint14.txt
[13] /home/tecmint/Desktop/tecmint/tecmint1.txt
[14] /home/tecmint/Desktop/tecmint/tecmint15.txt
[15] /home/tecmint/Desktop/tecmint/tecmint12.txt
Set 1 of 1, preserve files [1 - 15, all]:
```
你可能注意到了,所有重复的文件被列了出来,并给出删除提示,一个一个来,或者指定范围,或者一次性全部删除。你可以选择一个范围,就像下面这样,来删除指定范围内的文件。
```
Set 1 of 1, preserve files [1 - 15, all]: 2-15
[-] /home/tecmint/Desktop/tecmint/tecmint13.txt
[+] /home/tecmint/Desktop/tecmint/tecmint8.txt
[-] /home/tecmint/Desktop/tecmint/tecmint11.txt
[-] /home/tecmint/Desktop/tecmint/tecmint3.txt
[-] /home/tecmint/Desktop/tecmint/tecmint4.txt
[-] /home/tecmint/Desktop/tecmint/tecmint6.txt
[-] /home/tecmint/Desktop/tecmint/tecmint7.txt
[-] /home/tecmint/Desktop/tecmint/tecmint9.txt
[-] /home/tecmint/Desktop/tecmint/tecmint10.txt
[-] /home/tecmint/Desktop/tecmint/tecmint2.txt
[-] /home/tecmint/Desktop/tecmint/tecmint5.txt
[-] /home/tecmint/Desktop/tecmint/tecmint14.txt
[-] /home/tecmint/Desktop/tecmint/tecmint1.txt
[-] /home/tecmint/Desktop/tecmint/tecmint15.txt
[-] /home/tecmint/Desktop/tecmint/tecmint12.txt
```
8、 从安全角度出发,你可能想要打印`fdupes`的输出结果到文件中,然后检查文本文件来决定要删除什么文件。这可以降低意外删除文件的风险。你可以这么做:
```
$ fdupes -Sr /home > /home/fdupes.txt
```
**注意**:你应该替换`/home`为你想要的文件夹。同时,如果你想要递归搜索并打印大小,可以使用`-r`和`-S`选项。
9、 你可以使用`-f`选项来忽略每个匹配集中的首个文件。
首先列出该目录中的文件。
```
$ ls -l /home/$USER/Desktop/tecmint
total 20
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint9 (3rd copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint9 (4th copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint9 (another copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint9 (copy).txt
-rw-r--r-- 1 tecmint tecmint 65 Aug 8 11:22 tecmint9.txt
```
然后,忽略掉每个匹配集中的首个文件。
```
$ fdupes -f /home/$USER/Desktop/tecmint
/home/tecmint/Desktop/tecmint9 (copy).txt
/home/tecmint/Desktop/tecmint9 (3rd copy).txt
/home/tecmint/Desktop/tecmint9 (another copy).txt
/home/tecmint/Desktop/tecmint9 (4th copy).txt
```
10、 检查已安装的fdupes版本。
```
$ fdupes --version
fdupes 1.51
```
11、 如果你需要关于fdupes的帮助,可以使用`-h`开关。
```
$ fdupes -h
Usage: fdupes [options] DIRECTORY...
-r --recurse for every directory given follow subdirectories
encountered within
-R --recurse: for each directory given after this option follow
subdirectories encountered within (note the ':' at
the end of the option, manpage for more details)
-s --symlinks follow symlinks
-H --hardlinks normally, when two or more files point to the same
disk area they are treated as non-duplicates; this
option will change this behavior
-n --noempty exclude zero-length files from consideration
-A --nohidden exclude hidden files from consideration
-f --omitfirst omit the first file in each set of matches
-1 --sameline list each set of matches on a single line
-S --size show size of duplicate files
-m --summarize summarize dupe information
-q --quiet hide progress indicator
-d --delete prompt user for files to preserve and delete all
others; important: under particular circumstances,
data may be lost when using this option together
with -s or --symlinks, or when specifying a
particular directory more than once; refer to the
fdupes documentation for additional information
-N --noprompt together with --delete, preserve the first file in
each set of duplicates and delete the rest without
prompting the user
-v --version display fdupes version
-h --help display this help message
```
到此为止了。让我知道你以前怎么在Linux中查找并删除重复文件的吧?同时,也让我知道你关于这个工具的看法。在下面的评论部分中提供你有价值的反馈吧,别忘了为我们点赞并分享,帮助我们扩散哦。
我正在使用另外一个移除重复文件的工具,它叫**fslint**。很快就会把使用心得分享给大家哦,你们一定会喜欢看的。
---
via: <http://www.tecmint.com/fdupes-find-and-delete-duplicate-files-in-linux/>
作者:[GOLinux](https://github.com/GOLinux) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,130 | 看这些孩子在 Ubuntu 的 Linux 终端下玩耍 | http://itsfoss.com/ubuntu-terminal-train/ | 2015-09-02T07:10:00 | [
"sl"
] | https://linux.cn/article-6130-1.html | 我发现了一个孩子们在他们的计算机教室里玩得很开心的视频。我不知道他们在哪里,但我猜测是在印度尼西亚或者马来西亚。视频请自行搭梯子: <https://youtu.be/z8taQPomp0Y>
### 在Linux终端下面跑火车
这里没有魔术。只是一个叫做“sl”的命令行工具。我想它是在把ls打错的情况下为了好玩而开发的。如果你曾经在Linux的命令行下工作,你会知道ls是一个最常使用的一个命令,也许也是一个最经常打错的命令。
如果你想从这个终端下的火车获得一些乐趣,你可以使用下面的命令安装它。
```
sudo apt-get install sl
```
要运行终端火车,只需要在终端中输入**sl**。它有以下几个选项:
* -a : 意外模式。你会看见哭救的群众
* -l : 显示一个更小的火车但有更多的车厢
* -F : 一个飞行的火车
* -e : 允许通过Ctrl+C。使用其他模式你不能使用Ctrl+C中断火车。但是,它不能长时间运行。
正常情况下,你应该会听到汽笛声但是在大多数Linux系统下都不管用,Ubuntu是其中一个。这就是一个意外的终端火车。

---
via: <http://itsfoss.com/ubuntu-terminal-train/>
作者:[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,131 | 如何在 Windows 上通过 Kitematic 使用 Docker | http://linoxide.com/linux-how-to/interactively-docker-kitematic/ | 2015-09-02T08:35:00 | [
"Docker",
"Kitematic"
] | /article-6131-1.html | 在本篇文章中,我们会学习如何在 Windows 操作系统上安装 Kitematic 以及部署一个测试性的 Nginx Web 服务器。Kitematic 是一个具有现代化的界面设计的自由开源软件,它可以让我们在 Docker 中交互式执行任务。Kitematic 设计的非常漂亮、界面美观。使用它,我们可以简单快速地开箱搭建我们的容器而不需要输入命令,可以在图形用户界面中通过简单的点击从而在容器上部署我们的应用。Kitematic 集成了 Docker Hub,允许我们搜索、拉取任何需要的镜像,并在上面部署应用。它同时也能很好地切换到命令行用户接口模式。目前,它包括了自动映射端口、可视化更改环境变量、配置卷、流式日志以及其它功能。

下面是在 Windows 上安装 Kitematic 并部署测试性 Nginx Web 服务器的 3 个简单步骤。
### 1. 下载 Kitematic
首先,我们需要从 github 仓库 <https://github.com/kitematic/kitematic/releases> 中下载 Windows 操作系统可用的最新的 Kitematic 发行版。我们用下载器或者 web 浏览器下载了它的可执行 EXE 文件。下载完成后,我们需要双击可执行应用文件。

双击应用文件之后,会问我们一个安全问题,我们只需要点击 OK 按钮,如下图所示。

### 2. 安装 Kitematic
下载好可执行安装程序之后,我们现在就可以在我们的 Windows 操作系统上安装 Kitematic了。安装程序现在会开始下载并安装运行 Kitematic 需要的依赖软件,包括 Virtual Box 和 Docker。如果已经在系统上安装了 Virtual Box,它会把它升级到最新版本。安装程序会在几分钟内完成,但取决于你网络和系统的速度。如果你还没有安装 Virtual Box,它会问你是否安装 Virtual Box 网络驱动。建议安装它,因为它用于 Virtual Box 的网络功能。

所需的依赖 Docker 和 Virtual Box 安装完成并运行后,会让我们登录到 Docker Hub。如果我们还没有账户或者还不想登录,可以点击 **SKIP FOR NOW** 继续后面的步骤。

如果你还没有账户,你可以在应用程序上点击注册(Sign Up)链接并在 Docker Hub 上创建账户。
完成之后,就会出现 Kitematic 应用程序的第一个界面。正如下面看到的这样。我们可以搜索可用的 docker 镜像。

### 3. 部署 Nginx Hello World 容器
现在,成功安装完 Kitematic 之后,我们打算部署容器。要运行一个容器,我们只需要在搜索区域中搜索镜像。然后点击 Create 按钮部署容器。在这篇教程中,我们会部署一个小的包含了 Hello World 主页的 Nginx Web 服务器。为此,我们在搜索区域中搜索 Hello World Nginx。看到了容器信息之后,我们点击 Create 来部署容器。

镜像下载完成之后,它会自动部署。我们可以查看 Kitematic 部署容器的命令日志。我们也可以在 Kitematic 界面上预览 web 页面。现在,我们通过点击预览在 web 浏览器中查看我们的 Hello World 页面。

如果我们想切换到命令行接口并用它管理 docker,这里有个称为 Docker CLI 的按钮,它会打开一个 PowerShell,在里面我们可以执行 docker 命令。

现在,如果我们想配置我们的容器并执行类似更改容器名称、设置环境变量、指定端口、配置容器存储以及其它高级功能的任务,我们可以在容器设置页面做到这些。

### 总结
我们终于成功在 Windows 操作系统上安装了 Kitematic 并部署了一个 Hello World Ngnix 服务器。推荐下载安装 Kitematic 最新的发行版,因为会增加很多新的高级功能。由于 Docker 运行在 64 位平台,当前 Kitematic 也是为 64 位操作系统构建。它只能在 Windows 7 以及更高版本上运行。
在这篇教程中,我们部署了一个 Nginx Web 服务器,类似地我们可以在 Kitematic 中简单的点击就能通过镜像部署任何 docker 容器。Kitematic 已经有可用的 Mac OS X 和 Windows 版本,Linux 版本也在开发中很快就会发布。
如果你有任何疑问、建议或者反馈,请在下面的评论框中写下来以便我们更改地改进或更新我们的内容。非常感谢!Enjoy :-)
---
via: <http://linoxide.com/linux-how-to/interactively-docker-kitematic/>
作者:[Arun Pyasi](http://linoxide.com/author/arunp/) 译者:[ictlyh](https://github.com/ictlyh) 校对:[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/interactively-docker-kitematic/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327582c50>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,132 | Linux 文件系统结构介绍 | http://www.blackmoreops.com/2015/06/18/linux-file-system-hierarchy-v2-0/ | 2015-09-02T10:47:00 | [
"文件系统"
] | https://linux.cn/article-6132-1.html | 
Linux中的文件是什么?它的文件系统又是什么?那些配置文件又在哪里?我下载好的程序保存在哪里了?在 Linux 中文件系统是标准结构的吗?好了,上图简明地阐释了Linux的文件系统的层次关系。当你苦于寻找配置文件或者二进制文件的时候,这便显得十分有用了。我在下方添加了一些解释以及例子,不过“篇幅较长,可以有空再看”。
另外一种情况便是当你在系统中获取配置以及二进制文件时,出现了不一致性问题,如果你是在一个大型组织中,或者只是一个终端用户,这也有可能会破坏你的系统(比如,二进制文件运行在旧的库文件上了)。若然你在[你的Linux系统上做安全审计](http://www.blackmoreops.com/2015/02/15/in-light-of-recent-linux-exploits-linux-security-audit-is-a-must/)的话,你将会发现它很容易遭到各种攻击。所以,保持一个清洁的操作系统(无论是Windows还是Linux)都显得十分重要。
### Linux的文件是什么?
对于UNIX系统来说(同样适用于Linux),以下便是对文件简单的描述:
>
> 在UNIX系统中,一切皆为文件;若非文件,则为进程
>
>
>
这种定义是比较正确的,因为有些特殊的文件不仅仅是普通文件(比如命名管道和套接字),不过为了让事情变的简单,“一切皆为文件”也是一个可以让人接受的说法。Linux系统也像UNIX系统一样,将文件和目录视如同物,因为目录只是一个包含了其他文件名的文件而已。程序、服务、文本、图片等等,都是文件。对于系统来说,输入和输出设备,基本上所有的设备,都被当做是文件。
题图版本历史:
* Version 2.0 – 17-06-2015
+ – Improved: 添加标题以及版本历史
+ – Improved: 添加/srv,/meida和/proc
+ – Improved: 更新了反映当前的Linux文件系统的描述
+ – Fixed: 多处的打印错误
+ – Fixed: 外观和颜色
* Version 1.0 – 14-02-2015
+ – Created: 基本的图表
+ – Note: 摒弃更低的版本
### 下载链接
以下是大图的下载地址。如果你需要其他格式,请跟原作者联系,他会尝试制作并且上传到某个地方以供下载
* [大图 (PNG 格式) – 2480×1755 px – 184KB](https://img.linux.net.cn/data/attachment/album/201509/02/004850winnckdkn48yb7br.png)
* [最大图 (PDF 格式) – 9919x7019 px – 1686KB](http://www.blackmoreops.com/wp-content/uploads/2015/06/Linux-File-System-Hierarchy-blackMORE-Ops.pdf)
**注意**: PDF格式文件是打印的最好选择,因为它画质很高。
### Linux 文件系统描述
为了有序地管理那些文件,人们习惯把这些文件当做是硬盘上的有序的树状结构,正如我们熟悉的'MS-DOS'(磁盘操作系统)就是一个例子。大的分枝包括更多的分枝,分枝的末梢是树的叶子或者普通的文件。现在我们将会以这树形图为例,但晚点我们会发现为什么这不是一个完全准确的一幅图。
| 目录 | 描述 |
| --- | --- |
| `/` | *主层次* 的根,也是整个文件系统层次结构的根目录 |
| `/bin` | 存放在单用户模式可用的必要命令二进制文件,所有用户都可用,如 cat、ls、cp等等 |
| `/boot` | 存放引导加载程序文件,例如kernels、initrd等 |
| `/dev` | 存放必要的设备文件,例如`/dev/null` |
| `/etc` | 存放主机特定的系统级配置文件。其实这里有个关于它名字本身意义上的的争议。在贝尔实验室的UNIX实施文档的早期版本中,/etc表示是“其他(etcetera)目录”,因为从历史上看,这个目录是存放各种不属于其他目录的文件(然而,文件系统目录标准 FSH 限定 /etc 用于存放静态配置文件,这里不该存有二进制文件)。早期文档出版后,这个目录名又重新定义成不同的形式。近期的解释中包含着诸如“可编辑文本配置”或者“额外的工具箱”这样的重定义 |
| `/etc/opt` | 存储着新增包的配置文件 `/opt/`. |
| `/etc/sgml` | 存放配置文件,比如 catalogs,用于那些处理SGML(译者注:标准通用标记语言)的软件的配置文件 |
| `/etc/X11` | X Window 系统11版本的的配置文件 |
| `/etc/xml` | 配置文件,比如catalogs,用于那些处理XML(译者注:可扩展标记语言)的软件的配置文件 |
| `/home` | 用户的主目录,包括保存的文件,个人配置,等等 |
| `/lib` | `/bin/` 和 `/sbin/`中的二进制文件的必需的库文件 |
| `/lib<架构位数>` | 备用格式的必要的库文件。 这样的目录是可选的,但如果他们存在的话肯定是有需要用到它们的程序 |
| `/media` | 可移动的多媒体(如CD-ROMs)的挂载点。(出现于 FHS-2.3) |
| `/mnt` | 临时挂载的文件系统 |
| `/opt` | 可选的应用程序软件包 |
| `/proc` | 以文件形式提供进程以及内核信息的虚拟文件系统,在Linux中,对应进程文件系统(procfs )的挂载点 |
| `/root` | 根用户的主目录 |
| `/sbin` | 必要的系统级二进制文件,比如, init, ip, mount |
| `/srv` | 系统提供的站点特定数据 |
| `/tmp` | 临时文件 (另见 `/var/tmp`). 通常在系统重启后删除 |
| `/usr` | *二级层级*存储用户的只读数据; 包含(多)用户主要的公共文件以及应用程序 |
| `/usr/bin` | 非必要的命令二进制文件 (在单用户模式中不需要用到的);用于所有用户 |
| `/usr/include` | 标准的包含文件 |
| `/usr/lib` | 库文件,用于`/usr/bin/` 和 `/usr/sbin/`中的二进制文件 |
| `/usr/lib<架构位数>` | 备用格式库(可选的) |
| `/usr/local` | *三级层次* 用于本地数据,具体到该主机上的。通常会有下一个子目录, *比如*, `bin/`, `lib/`, `share/`. |
| `/usr/local/sbin` | 非必要系统的二进制文件,比如用于不同网络服务的守护进程 |
| `/usr/share` | 架构无关的 (共享) 数据. |
| `/usr/src` | 源代码,比如内核源文件以及与它相关的头文件 |
| `/usr/X11R6` | X Window系统,版本号:11,发行版本:6 |
| `/var` | 各式各样的(Variable)文件,一些随着系统常规操作而持续改变的文件就放在这里,比如日志文件,脱机文件,还有临时的电子邮件文件 |
| `/var/cache` | 应用程序缓存数据. 这些数据是由耗时的I/O(输入/输出)的或者是运算本地生成的结果。这些应用程序是可以重新生成或者恢复数据的。当没有数据丢失的时候,可以删除缓存文件 |
| `/var/lib` | 状态信息。这些信息随着程序的运行而不停地改变,比如,数据库,软件包系统的元数据等等 |
| `/var/lock` | 锁文件。这些文件用于跟踪正在使用的资源 |
| `/var/log` | 日志文件。包含各种日志。 |
| `/var/mail` | 内含用户邮箱的相关文件 |
| `/var/opt` | 来自附加包的各种数据都会存储在 `/var/opt/`. |
| `/var/run` | 存放当前系统上次启动以来的相关信息,例如当前登入的用户以及当前运行的[daemons(守护进程)](http://en.wikipedia.org/wiki/Daemon_%28computing%29). |
| `/var/spool` | 该spool主要用于存放将要被处理的任务,比如打印队列以及邮件外发队列 |
| `/var/mail` | 过时的位置,用于放置用户邮箱文件 |
| `/var/tmp` | 存放重启后保留的临时文件 |
### Linux的文件类型
大多数文件仅仅是普通文件,他们被称为`regular`文件;他们包含普通数据,比如,文本、可执行文件、或者程序、程序的输入或输出等等
虽然你可以认为“在Linux中,一切你看到的皆为文件”这个观点相当保险,但这里仍有着一些例外。
* `目录`:由其他文件组成的文件
* `特殊文件`:用于输入和输出的途径。大多数特殊文件都储存在`/dev`中,我们将会在后面讨论这个问题。
* `链接文件`:让文件或者目录出现在系统文件树结构上多个地方的机制。我们将详细地讨论这个链接文件。
* `(域)套接字`:特殊的文件类型,和TCP/IP协议中的套接字有点像,提供进程间网络通讯,并受文件系统的访问控制机制保护。
* `命名管道` : 或多或少有点像sockets(套接字),提供一个进程间的通信机制,而不用网络套接字协议。
### 现实中的文件系统
对于大多数用户和常规系统管理任务而言,“文件和目录是一个有序的类树结构”是可以接受的。然而,对于电脑而言,它是不会理解什么是树,或者什么是树结构。
每个分区都有它自己的文件系统。想象一下,如果把那些文件系统想成一个整体,我们可以构思一个关于整个系统的树结构,不过这并没有这么简单。在文件系统中,一个文件代表着一个`inode`(索引节点),这是一种包含着构建文件的实际数据信息的序列号:这些数据表示文件是属于谁的,还有它在硬盘中的位置。
每个分区都有一套属于他们自己的inode,在一个系统的不同分区中,可以存在有相同inode的文件。
每个inode都表示着一种在硬盘上的数据结构,保存着文件的属性,包括文件数据的物理地址。当硬盘被格式化并用来存储数据时(通常发生在初始系统安装过程,或者是在一个已经存在的系统中添加额外的硬盘),每个分区都会创建固定数量的inode。这个值表示这个分区能够同时存储各类文件的最大数量。我们通常用一个inode去映射2-8k的数据块。当一个新的文件生成后,它就会获得一个空闲的inode。在这个inode里面存储着以下信息:
* 文件属主和组属主
* 文件类型(常规文件,目录文件......)
* 文件权限
* 创建、最近一次读文件和修改文件的时间
* inode里该信息被修改的时间
* 文件的链接数(详见下一章)
* 文件大小
* 文件数据的实际地址
唯一不在inode的信息是文件名和目录。它们存储在特殊的目录文件。通过比较文件名和inode的数目,系统能够构造出一个便于用户理解的树结构。用户可以通过ls -i查看inode的数目。在硬盘上,inodes有他们独立的空间。
---
via: <http://www.blackmoreops.com/2015/06/18/linux-file-system-hierarchy-v2-0/>
译者:[tnuoccalanosrep](https://github.com/tnuoccalanosrep) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,133 | RHCSA 系列(一): 回顾基础命令及系统文档 | http://www.tecmint.com/rhcsa-exam-reviewing-essential-commands-system-documentation/ | 2015-09-02T12:40:00 | [
"RHEL",
"RHCSA"
] | https://linux.cn/article-6133-1.html | RHCSA (红帽认证系统工程师) 是由 RedHat 公司举行的认证考试,这家公司给商业公司提供开源操作系统和软件,除此之外,还为这些企业和机构提供支持、训练以及咨询服务等。

*RHCSA 考试准备指南*
RHCSA 考试(考试编号 EX200)通过后可以获取由 RedHat 公司颁发的证书. RHCSA 考试是 RHCT(红帽认证技师)的升级版,而且 RHCSA 必须在新的 Red Hat Enterprise Linux(红帽企业版)下完成。RHCT 和 RHCSA 的主要变化就是 RHCT 基于 RHEL5,而 RHCSA 基于 RHEL6 或者7,这两个认证的等级也有所不同。
红帽认证管理员最起码可以在红帽企业版的环境下执行如下系统管理任务:
* 理解并会使用命令管理文件、目录、命令行以及系统/软件包的文档
* 在不同的启动等级操作运行中的系统,识别和控制进程,启动或停止虚拟机
* 使用分区和逻辑卷管理本地存储
* 创建并且配置本地文件系统和网络文件系统,设置他们的属性(权限、加密、访问控制表)
* 部署、配置、并且控制系统,包括安装、升级和卸载软件
* 管理系统用户和组,以及使用集中制的 LDAP 目录进行用户验证
* 确保系统安全,包括基础的防火墙规则和 SELinux 配置
关于你所在国家的考试注册和费用请参考 [RHCSA 认证页面](https://www.redhat.com/en/services/certification/rhcsa)。
在这个有15章的 RHCSA(红帽认证管理员)备考系列中,我们将覆盖以下的关于红帽企业 Linux 第七版的最新的信息:
* [RHCSA 系列(一): 回顾基础命令及系统文档](/article-6133-1.html)
* [RHCSA 系列(二): 如何进行文件和目录管理](/article-6155-1.html)
* [RHCSA 系列(三): 如何管理 RHEL7 的用户和组](/article-6187-1.html)
* [RHCSA 系列(四): 编辑文本文件及分析文本](/article-6229-1.html)
* [RHCSA 系列(五): RHEL7 中的进程管理:开机,关机](/article-6249-1.html)
* [RHCSA 系列(六): 使用 Parted 和 SSM 来配置和加密系统存储](/article-6257-1.html)
* [RHCSA 系列(七): 使用 ACL(访问控制列表) 和挂载 Samba/NFS 共享](/article-6263-1.html)
* [RHCSA 系列(八): 加固 SSH,设定主机名及启用网络服务](/article-6266-1.html)
* [RHCSA 系列(九): 安装、配置及加固一个 Web 和 FTP 服务器](/article-6286-1.html)
* [RHCSA 系列(十): Yum 包管理、Cron 自动任务计划和监控系统日志](/article-6300-1.html)志
* [RHCSA 系列(十一): 使用 firewalld 和 iptables 来控制网络流量](/article-6315-1.html)
* [RHCSA 系列(十二): 使用 Kickstart 完成 RHEL 7 的自动化安装](/article-6335-1.html)
* [RHCSA 系列(十三):在 RHEL 7 中使用 SELinux 进行强制访问控制](/article-6339-1.html)
* [RHCSA 系列(十四):在 RHEL 7 中设置基于 LDAP 的认证](/article-6348-1.html)
* [RHCSA 系列(十五):虚拟化基础和使用 KVM 进行虚拟机管理](/article-6362-1.html)
在第一章,我们讲解如何在终端或者 Shell 窗口输入和运行正确的命令,并且讲解如何找到、查阅,以及使用系统文档。

*RHCSA:回顾必会的 Linux 命令 - 第一部分*
#### 前提:
至少你要熟悉如下命令
* [cd 命令](http://linux.cn/article-2479-1.html) (改变目录)
* [ls 命令](/article-5109-1.html) (列举文件)
* [cp 命令](http://linux.cn/article-2687-1.html) (复制文件)
* [mv 命令](http://www.tecmint.com/rename-multiple-files-in-linux/) (移动或重命名文件)
* [touch 命令](http://linux.cn/article-2740-1.html) (创建一个新的文件或更新已存在文件的时间表)
* rm 命令 (删除文件)
* mkdir 命令 (创建目录)
在这篇文章中你将会找到更多的关于如何更好的使用他们的正确用法和特殊用法.
虽然没有严格的要求,但是作为讨论常用的 Linux 命令和在 Linux 中搜索信息方法,你应该安装 RHEL7 来尝试使用文章中提到的命令。这将会使你学习起来更省力。
* [红帽企业版 Linux(RHEL)7 安装指南](http://www.tecmint.com/redhat-enterprise-linux-7-installation/)
### 使用 Shell 进行交互
如果我们使用文本模式登录 Linux,我们就会直接进入到我们的默认 shell 中。另一方面,如果我们使用图形化界面登录,我们必须通过启动一个终端来开启 shell。无论那种方式,我们都会看到用户提示符,并且我们可以在这里输入并且执行命令(当按下回车时,命令就会被执行)。
命令是由两个部分组成的:
* 命令本身
* 参数
某些参数,称为选项(通常使用一个连字符开头),会改变命令的行为方式,而另外一些则指定了命令所操作的对象。
type 命令可以帮助我们识别某一个特定的命令是由 shell 内置的还是由一个单独的包提供的。这样的区别在于我们能够在哪里找到更多关于该命令的更多信息。对 shell 内置的命令,我们需要看 shell 的手册页;如果是其他的,我们需要看软件包自己的手册页。

*检查Shell的内置命令*
在上面的例子中, `cd` 和 `type` 是 shell 内置的命令,`top` 和 `less` 是由 shell 之外的其他的二进制文件提供的(在这种情况下,type将返回命令的位置)。
其他的内置命令:
* [echo 命令](/article-3948-1.html): 展示字符串
* [pwd 命令](/article-3422-1.html): 输出当前的工作目录

*其它内置命令*
#### **exec 命令**
它用来运行我们指定的外部程序。请注意在多数情况下,只需要输入我们想要运行的程序的名字就行,不过`exec` 命令有一个特殊的特性:不是在 shell 之外创建新的进程运行,而是这个新的进程会替代原来的 shell,可以通过下列命令来验证。
```
# ps -ef | grep [shell 进程的PID]
```
当新的进程终止时,Shell 也随之终止。运行 `exec top` ,然后按下 `q` 键来退出 top,你会注意到 shell 会话也同时终止,如下面的屏幕录像展示的那样:
#### **export 命令**
给之后执行的命令的输出环境变量。
#### **history 命令**
展示数行之前的历史命令。命令编号前面前缀上感叹号可以再次执行这个命令。如果我们需要编辑历史列表中的命令,我们可以按下 `Ctrl + r` 并输入与命令相关的第一个字符。我们可以看到的命令会自动补全,可以根据我们目前的需要来编辑它:
命令列表会保存在一个叫 `.bash_history` 的文件里。`history` 命令是一个非常有用的用于减少输入次数的工具,特别是进行命令行编辑的时候。默认情况下,bash 保留最后输入的500个命令,不过可以通过修改 HISTSIZE 环境变量来增加:

*Linux history 命令*
但上述变化,在我们的下一次启动不会保留。为了保持 HISTSIZE 变量的变化,我们需要通过手工修改文件编辑:
```
# 要设置 history 长度,请看 bash(1)文档中的 HISTSIZE 和 HISTFILESIZE
HISTSIZE=1000
```
**重要**: 我们的更改不会立刻生效,除非我们重启了 shell 。
#### **alias 命令**
没有参数或使用 `-p` 选项时将会以“名称=值”的标准形式输出别名列表。当提供了参数时,就会按照给定的名字和值定义一个别名。
使用 `alias` ,我们可以创建我们自己的命令,或使用所需的参数修改现有的命令。举个例子,假设我们将 `ls` 定义别名为 `ls –color=auto` ,这样就可以使用不同颜色输出文件、目录、链接等等。
```
# alias ls='ls --color=auto'
```

*Linux 别名命令*
**注意**: 你可以给你的“新命令”起任何的名字,并且使用单引号包括很多命令,但是你要用分号区分开它们。如下:
```
# alias myNewCommand='cd /usr/bin; ls; cd; clear'
```
#### **exit 命令**
`exit` 和 `logout` 命令都可以退出 shell 。`exit` 命令可以退出所有的 shell,`logout` 命令只注销登录的 shell(即你用文本模式登录时自动启动的那个)。
#### **man 和 info 命令**
如果你对某个程序有疑问,可以参考它的手册页,可以使用 `man` 命令调出它。此外,还有一些关于重要文件(inittab、fstab、hosts 等等)、库函数、shell、设备及其他功能的手册页。
举例:
* man uname (输出系统信息,如内核名称、处理器、操作系统类型、架构等)
* man inittab (初始化守护进程的设置)
另外一个重要的信息的来源是由 `info` 命令提供的,`info` 命令常常被用来读取 info 文件。这些文件往往比手册页 提供了更多信息。可以通过 `info keyword` 调用某个命令的信息:
```
# info ls
# info cut
```
另外,在 `/usr/share/doc` 文件夹包含了大量的子目录,里面可以找到大量的文档。它们是文本文件或其他可读格式。
你要习惯于使用这三种方法去查找命令的信息。重点关注每个命令文档中介绍的详细的语法。
#### **使用 expand 命令把制表符转换为空格**
有时候文本文档包含了制表符,但是程序无法很好的处理。或者我们只是简单的希望将制表符转换成空格。这就是用到 `expand` 地方(由GNU核心组件包提供) 。
举个例子,我们有个文件 NumberList.txt,让我们使用 `expand` 处理它,将制表符转换为一个空格,并且显示在标准输出上。
```
# expand --tabs=1 NumbersList.txt
```

*Linux expand 命令*
unexpand命令可以实现相反的功能(将空格转为制表符)
#### **使用 head 输出文件首行及使用 tail 输出文件尾行**
通常情况下,`head` 命令后跟着文件名时,将会输出该文件的前十行,我们可以通过 `-n` 参数来自定义具体的行数。
```
# head -n3 /etc/passwd
# tail -n3 /etc/passwd
```

*Linux 的 head 和 tail 命令*
`tail` 最有意思的一个特性就是能够显示增长的输入文件(`tail -f my.log`,my.log 是我们需要监视的文件。)这在我们监控一个持续增加的日志文件时非常有用。
* [使用 head 和 tail 命令有效地管理文件](http://www.tecmint.com/view-contents-of-file-in-linux/)
#### **使用 paste 按行合并文本文件**
`paste` 命令一行一行的合并文件,默认会以制表符来区分每个文件的行,或者你可以自定义的其它分隔符。(下面的例子就是输出中的字段使用等号分隔)。
```
# paste -d= file1 file2
```

*Linux 中的 merge 命令*
#### **使用 split 命令将文件分块**
`split` 命令常常用于把一个文件切割成两个或多个由我们自定义的前缀命名的文件。可以根据大小、区块、行数等进行切割,生成的文件会有一个数字或字母的后缀。在下面的例子中,我们将切割 bash.pdf ,每个文件 50KB (-b 50KB),使用数字后缀 (-d):
```
# split -b 50KB -d bash.pdf bash_
```

*在 Linux 下切割文件*
你可以使用如下命令来合并这些文件,生成原来的文件:
```
# cat bash_00 bash_01 bash_02 bash_03 bash_04 bash_05 > bash.pdf
```
#### **使用 tr 命令替换字符**
`tr` 命令多用于一对一的替换(改变)字符,或者使用字符范围。和之前一样,下面的实例我们将使用之前的同样文件file2,我们将做:
* 小写字母 o 变成大写
* 所有的小写字母都变成大写字母
```
cat file2 | tr o O
cat file2 | tr [a-z] [A-Z]
```

*在 Linux 中替换字符*
#### **使用 uniq 和 sort 检查或删除重复的文字**
`uniq` 命令可以帮我们查出或删除文件中的重复的行,默认会输出到标准输出,我们应当注意,`uniq`只能查出相邻的相同行,所以,`uniq` 往往和 `sort` 一起使用(`sort` 一般用于对文本文件的内容进行排序)
默认情况下,`sort` 以第一个字段(使用空格分隔)为关键字段。想要指定不同关键字段,我们需要使用 -k 参数,请注意如何使用 `sort` 和 `uniq` 输出我们想要的字段,具体可以看下面的例子:
```
# cat file3
# sort file3 | uniq
# sort -k2 file3 | uniq
# sort -k3 file3 | uniq
```

*删除文件中重复的行*
#### **从文件中提取文本的命令**
`cut` 命令基于字节(-b)、字符(-c)、或者字段(-f)的数量,从输入文件(标准输入或文件)中提取到的部分将会以标准输出上。
当我们使用字段 `cut` 时,默认的分隔符是一个制表符,不过你可以通过 -d 参数来自定义分隔符。
```
# cut -d: -f1,3 /etc/passwd # 这个例子提取了第一和第三字段的文本
# cut -d: -f2-4 /etc/passwd # 这个例子提取了第二到第四字段的文本
```

*从文件中提取文本*
注意,简洁起见,上方的两个输出的结果是截断的。
#### **使用 fmt 命令重新格式化文件**
`fmt` 被用于去“清理”有大量内容或行的文件,或者有多级缩进的文件。新的段落格式每行不会超过75个字符宽,你能通过 -w (width 宽度)参数改变这个设定,它可以设置行宽为一个特定的数值。
举个例子,让我们看看当我们用 `fmt` 显示定宽为100个字符的时候的文件 /etc/passwd 时会发生什么。再次,输出截断了。
```
# fmt -w100 /etc/passwd
```

*Linux 文件重新格式化*
#### **使用 pr 命令格式化打印内容**
`pr` 分页并且在按列或多列的方式显示一个或多个文件。 换句话说,使用 `pr` 格式化一个文件使它打印出来时看起来更好。举个例子,下面这个命令:
```
# ls -a /etc | pr -n --columns=3 -h "Files in /etc"
```
以一个友好的排版方式(3列)输出/etc下的文件,自定义了页眉(通过 -h 选项实现)、行号(-n)。

*Linux的文件格式化*
### 总结
在这篇文章中,我们已经讨论了如何在 Shell 或终端以正确的语法输入和执行命令,并解释如何找到,查阅和使用系统文档。正如你看到的一样简单,这就是你成为 RHCSA 的第一大步。
如果你希望添加一些其他的你经常使用的能够有效帮你完成你的日常工作的基础命令,并愿意分享它们,请在下方留言。也欢迎提出问题。我们期待您的回复。
---
via: <http://www.tecmint.com/rhcsa-exam-reviewing-essential-commands-system-documentation/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[xiqingongzi](https://github.com/xiqingongzi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,134 | Linux有问必答:如何启用Open vSwitch的日志功能以便调试和排障 | http://ask.xmodulo.com/enable-logging-open-vswitch.html | 2015-09-02T14:39:51 | [
"Open vSwitch",
"SDN"
] | /article-6134-1.html |
>
> **问题** 我试着为我的Open vSwitch部署排障,鉴于此,我想要检查它的由内建日志机制生成的调试信息。我怎样才能启用Open vSwitch的日志功能,并且修改它的日志等级(如,修改成INFO/DEBUG级别)以便于检查更多详细的调试信息呢?
>
>
>
Open vSwitch(OVS)是Linux平台上最流行的开源的虚拟交换机。由于当今的数据中心日益依赖于软件定义网络(SDN)架构,OVS被作为数据中心的SDN部署中的事实标准上的网络元素而得到飞速应用。
Open vSwitch具有一个内建的日志机制,它称之为VLOG。VLOG工具允许你在各种网络交换组件中启用并自定义日志,由VLOG生成的日志信息可以被发送到一个控制台、syslog以及一个便于查看的单独日志文件。你可以通过一个名为`ovs-appctl`的命令行工具在运行时动态配置OVS日志。

这里为你演示如何使用`ovs-appctl`启用Open vSwitch中的日志功能,并进行自定义。
下面是`ovs-appctl`自定义VLOG的语法。
```
$ sudo ovs-appctl vlog/set module[:facility[:level]]
```
* **Module**:OVS中的任何合法组件的名称(如netdev,ofproto,dpif,vswitchd等等)
* **Facility**:日志信息的目的地(必须是:console,syslog,或者file)
* **Level**:日志的详细程度(必须是:emer,err,warn,info,或者dbg)
在OVS源代码中,模块名称在源文件中是以以下格式定义的:
```
VLOG_DEFINE_THIS_MODULE(<module-name>);
```
例如,在lib/netdev.c中,你可以看到:
```
VLOG_DEFINE_THIS_MODULE(netdev);
```
这个表明,lib/netdev.c是netdev模块的一部分,任何在lib/netdev.c中生成的日志信息将属于netdev模块。
在OVS源代码中,有多个严重度等级用于定义几个不同类型的日志信息:VLOG*INFO()用于报告,VLOG*WARN()用于警告,VLOG*ERR()用于错误提示,VLOG*DBG()用于调试信息,VLOG\_EMERG用于紧急情况。日志等级和工具确定哪个日志信息发送到哪里。
要查看可用模块、工具和各自日志级别的完整列表,请运行以下命令。该命令必须在你启动OVS后调用。
```
$ sudo ovs-appctl vlog/list
```

输出结果显示了用于三个场合(facility:console,syslog,file)的各个模块的调试级别。默认情况下,所有模块的日志等级都被设置为INFO。
指定任何一个OVS模块,你可以选择性地修改任何特定场合的调试级别。例如,如果你想要在控制台屏幕中查看dpif更为详细的调试信息,可以运行以下命令。
```
$ sudo ovs-appctl vlog/set dpif:console:dbg
```
你将看到dpif模块的console工具已经将其日志等级修改为DBG,而其它两个场合syslog和file的日志级别仍然没有改变。

如果你想要修改所有模块的日志等级,你可以指定“ANY”作为模块名。例如,下面命令将修改每个模块的console的日志级别为DBG。
```
$ sudo ovs-appctl vlog/set ANY:console:dbg
```

同时,如果你想要一次性修改所有三个场合的日志级别,你可以指定“ANY”作为场合名。例如,下面的命令将修改每个模块的所有场合的日志级别为DBG。
```
$ sudo ovs-appctl vlog/set ANY:ANY:dbg
```
---
via: <http://ask.xmodulo.com/enable-logging-open-vswitch.html>
作者:[Dan Nanni](http://ask.xmodulo.com/author/nanni) 译者:[GOLinux](https://github.com/GOLinux) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='ask.xmodulo.com', port=80): Max retries exceeded with url: /enable-logging-open-vswitch.html (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7b8327582cb0>: Failed to resolve 'ask.xmodulo.com' ([Errno -2] Name or service not known)")) | null |
6,135 | 在 Ubuntu 15.04 中如何安装和使用 Snort | http://linoxide.com/security/install-snort-usage-ubuntu-15-04/ | 2015-09-03T09:07:00 | [
"snort",
"IDS",
"入侵检测"
] | /article-6135-1.html | 对于网络安全而言入侵检测是一件非常重要的事。入侵检测系统(IDS)用于检测网络中非法与恶意的请求。Snort是一款知名的开源的入侵检测系统。其 Web界面(Snorby)可以用于更好地分析警告。Snort使用iptables/pf防火墙来作为入侵检测系统。本篇中,我们会安装并配置一个开源的入侵检测系统snort。

### Snort 安装
#### 要求
snort所使用的数据采集库(DAQ)用于一个调用包捕获库的抽象层。这个在snort上就有。下载过程如下截图所示。

解压并运行./configure、make、make install来安装DAQ。然而,DAQ要求其他的工具,因此,./configure脚本会生成下面的错误。
flex和bison错误

libpcap错误

因此在安装DAQ之前先安装flex/bison和libcap。

如下所示安装libpcap开发库

安装完必要的工具后,再次运行./configure脚本,将会显示下面的输出。

make和make install 命令的结果如下所示。


成功安装DAQ之后,我们现在安装snort。如下图使用wget下载它。

使用下面的命令解压安装包。
```
#tar -xvzf snort-2.9.7.3.tar.gz
```

创建安装目录并在脚本中设置prefix参数。同样也建议启用包性能监控(PPM)的sourcefire标志。
```
#mkdir /usr/local/snort
#./configure --prefix=/usr/local/snort/ --enable-sourcefire
```

配置脚本会由于缺少libpcre-dev、libdumbnet-dev 和zlib开发库而报错。
配置脚本由于缺少libpcre库报错。

配置脚本由于缺少dnet(libdumbnet)库而报错。

配置脚本由于缺少zlib库而报错

如下所示,安装所有需要的开发库。
```
# aptitude install libpcre3-dev
```

```
# aptitude install libdumbnet-dev
```

```
# aptitude install zlib1g-dev
```

安装完snort需要的库之后,再次运行配置脚本就不会报错了。
运行make和make install命令在/usr/local/snort目录下完成安装。
```
# make
```

```
# make install
```

最后,从/usr/local/snort/bin中运行snort。现在它对eth0的所有流量都处在promisc模式(包转储模式)。

如下图所示snort转储流量。

#### Snort的规则和配置
从源码安装的snort还需要设置规则和配置,因此我们需要复制规则和配置到/etc/snort下面。我们已经创建了单独的bash脚本来用于设置规则和配置。它会设置下面这些snort设置。
* 在linux中创建用于snort IDS服务的snort用户。
* 在/etc下面创建snort的配置文件和文件夹。
* 权限设置并从源代码的etc目录中复制数据。
* 从snort文件中移除规则中的#(注释符号)。
```
#!/bin/bash#
# snort源代码的路径
snort_src="/home/test/Downloads/snort-2.9.7.3"
echo "adding group and user for snort..."
groupadd snort &> /dev/null
useradd snort -r -s /sbin/nologin -d /var/log/snort -c snort_idps -g snort &> /dev/null#snort configuration
echo "Configuring snort..."mkdir -p /etc/snort
mkdir -p /etc/snort/rules
touch /etc/snort/rules/black_list.rules
touch /etc/snort/rules/white_list.rules
touch /etc/snort/rules/local.rules
mkdir /etc/snort/preproc_rules
mkdir /var/log/snort
mkdir -p /usr/local/lib/snort_dynamicrules
chmod -R 775 /etc/snort
chmod -R 775 /var/log/snort
chmod -R 775 /usr/local/lib/snort_dynamicrules
chown -R snort:snort /etc/snort
chown -R snort:snort /var/log/snort
chown -R snort:snort /usr/local/lib/snort_dynamicrules
###copy configuration and rules from etc directory under source code of snort
echo "copying from snort source to /etc/snort ....."
echo $snort_src
echo "-------------"
cp $snort_src/etc/*.conf* /etc/snort
cp $snort_src/etc/*.map /etc/snort##enable rules
sed -i 's/include \$RULE\_PATH/#include \$RULE\_PATH/' /etc/snort/snort.conf
echo "---DONE---"
```
改变脚本中的snort源目录路径并运行。下面是成功的输出。

上面的脚本从snort源中复制下面的文件和文件夹到/etc/snort配置文件中

snort的配置非常复杂,要让IDS能正常工作需要进行下面必要的修改。
```
ipvar HOME_NET 192.168.1.0/24 # LAN side
```
---
```
ipvar EXTERNAL_NET !$HOME_NET # WAN side
```

```
var RULE_PATH /etc/snort/rules # snort signature path
var SO_RULE_PATH /etc/snort/so_rules #rules in shared libraries
var PREPROC_RULE_PATH /etc/snort/preproc_rules # Preproces path
var WHITE_LIST_PATH /etc/snort/rules # dont scan
var BLACK_LIST_PATH /etc/snort/rules # Must scan
```

```
include $RULE_PATH/local.rules # file for custom rules
```
移除ftp.rules、exploit.rules前面的注释符号(#)。

现在[下载社区规则](https://www.snort.org/downloads/community/community-rules.tar.gz)并解压到/etc/snort/rules。启用snort.conf中的社区及紧急威胁规则。


进行了上面的更改后,运行下面的命令来检验配置文件。
```
# snort -T -c /etc/snort/snort.conf
```

### 总结
本篇中,我们关注了开源IDPS系统snort在Ubuntu上的安装和配置。通常它用于监控事件,然而它可以被配置成用于网络保护的在线模式。snort规则可以在离线模式中可以使用pcap捕获文件进行测试和分析
---
via: <http://linoxide.com/security/install-snort-usage-ubuntu-15-04/>
作者:[nido](http://linoxide.com/author/naveeda/) 译者:[geekpi](https://github.com/geekpi) 校对:[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: /security/install-snort-usage-ubuntu-15-04/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327580070>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,136 | Linux 日志管理指南 | http://www.loggly.com/ultimate-guide/logging/managing-linux-logs/ | 2015-09-03T08:24:00 | [
"日志",
"syslog",
"rsyslog"
] | https://linux.cn/article-6136-1.html | 管理日志的一个最好做法是将你的日志集中或整合到一个地方,特别是在你有许多服务器或多层级架构时。我们将告诉你为什么这是一个好主意,然后给出如何更容易的做这件事的一些小技巧。

### 集中管理日志的好处
如果你有很多服务器,查看某个日志文件可能会很麻烦。现代的网站和服务经常包括许多服务器层级、分布式的负载均衡器,等等。找到正确的日志将花费很长时间,甚至要花更长时间在登录服务器的相关问题上。没什么比发现你找的信息没有被保存下来更沮丧的了,或者本该保留的日志文件正好在重启后丢失了。
集中你的日志使它们查找更快速,可以帮助你更快速的解决产品问题。你不用猜测那个服务器存在问题,因为所有的日志在同一个地方。此外,你可以使用更强大的工具去分析它们,包括日志管理解决方案。一些解决方案能[转换纯文本日志](https://docs.google.com/document/d/11LXZxWlkNSHkcrCWTUdnLRf_CiZz9kK0cr3yGM_BU_0/edit#heading=h.esrreycnpnbl)为一些字段,更容易查找和分析。
集中你的日志也可以使它们更易于管理:
* 它们更安全,当它们备份归档到一个单独区域时会有意无意地丢失。如果你的服务器宕机或者无响应,你可以使用集中的日志去调试问题。
* 你不用担心ssh或者低效的grep命令在陷入困境的系统上需要更多的资源。
* 你不用担心磁盘占满,这个能让你的服务器死机。
* 你能保持你的产品服务器的安全性,只是为了查看日志无需给你所有团队登录权限。给你的团队从日志集中区域访问日志权限更安全。
随着集中日志管理,你仍需处理由于网络联通性不好或者耗尽大量网络带宽从而导致不能传输日志到中心区域的风险。在下面的章节我们将要讨论如何聪明的解决这些问题。
### 流行的日志归集工具
在 Linux 上最常见的日志归集是通过使用 syslog 守护进程或者日志代理。syslog 守护进程支持本地日志的采集,然后通过syslog 协议传输日志到中心服务器。你可以使用很多流行的守护进程来归集你的日志文件:
* [rsyslog](http://www.rsyslog.com/) 是一个轻量后台程序,在大多数 Linux 分支上已经安装。
* [syslog-ng](http://www.balabit.com/network-security/syslog-ng/opensource-logging-system) 是第二流行的 Linux 系统日志后台程序。
* [logstash](http://logstash.net/) 是一个重量级的代理,它可以做更多高级加工和分析。
* [fluentd](http://www.fluentd.org/) 是另一个具有高级处理能力的代理。
Rsyslog 是集中日志数据最流行的后台程序,因为它在大多数 Linux 分支上是被默认安装的。你不用下载或安装它,并且它是轻量的,所以不需要占用你太多的系统资源。
如果你需要更多先进的过滤或者自定义分析功能,如果你不在乎额外的系统负载,Logstash 是另一个最流行的选择。
### 配置 rsyslog.conf
既然 rsyslog 是最广泛使用的系统日志程序,我们将展示如何配置它为日志中心。它的全局配置文件位于 /etc/rsyslog.conf。它加载模块,设置全局指令,和包含位于目录 /etc/rsyslog.d 中的应用的特有的配置。目录中包含的 /etc/rsyslog.d/50-default.conf 指示 rsyslog 将系统日志写到文件。在 [rsyslog 文档](http://www.rsyslog.com/doc/rsyslog_conf.html)中你可以阅读更多相关配置。
rsyslog 配置语言是是[RainerScript](http://www.rsyslog.com/doc/master/rainerscript/index.html)。你可以给日志指定输入,就像将它们输出到另外一个位置一样。rsyslog 已经配置标准输入默认是 syslog ,所以你通常只需增加一个输出到你的日志服务器。这里有一个 rsyslog 输出到一个外部服务器的配置例子。在本例中,**BEBOP** 是一个服务器的主机名,所以你应该替换为你的自己的服务器名。
```
action(type="omfwd" protocol="tcp" target="BEBOP" port="514")
```
你可以发送你的日志到一个有足够的存储容量的日志服务器来存储,提供查询,备份和分析。如果你存储日志到文件系统,那么你应该建立[日志轮转](https://docs.google.com/document/d/11LXZxWlkNSHkcrCWTUdnLRf_CiZz9kK0cr3yGM_BU_0/edit#heading=h.eck7acdxin87)来防止你的磁盘爆满。
作为一种选择,你可以发送这些日志到一个日志管理方案。如果你的解决方案是安装在本地你可以发送到系统文档中指定的本地主机和端口。如果你使用基于云提供商,你将发送它们到你的提供商特定的主机名和端口。
### 日志目录
你可以归集一个目录或者匹配一个通配符模式的所有文件。nxlog 和 syslog-ng 程序支持目录和通配符(\*)。
常见的 rsyslog 不能直接监控目录。作为一种解决办法,你可以设置一个定时任务去监控这个目录的新文件,然后配置 rsyslog 来发送这些文件到目的地,比如你的日志管理系统。举个例子,日志管理提供商 Loggly 有一个开源版本的[目录监控脚本](https://www.loggly.com/docs/file-monitoring/)。
### 哪个协议: UDP、TCP 或 RELP?
当你使用网络传输数据时,有三个主流协议可以选择。UDP 在你自己的局域网是最常用的,TCP 用在互联网。如果你不能失去(任何)日志,就要使用更高级的 RELP 协议。
[UDP](http://www.networksorcery.com/enp/protocol/udp.htm) 发送一个数据包,那只是一个单一的信息包。它是一个只外传的协议,所以它不会发送给你回执(ACK)。它只尝试发送包。当网络拥堵时,UDP 通常会巧妙的降级或者丢弃日志。它通常使用在类似局域网的可靠网络。
[TCP](http://www.networksorcery.com/enp/protocol/tcp.htm) 通过多个包和返回确认发送流式信息。TCP 会多次尝试发送数据包,但是受限于 [TCP 缓存](http://blog.gerhards.net/2008/04/on-unreliability-of-plain-tcp-syslog.html)的大小。这是在互联网上发送送日志最常用的协议。
[RELP](http://www.rsyslog.com/doc/relp.html) 是这三个协议中最可靠的,但是它是为 rsyslog 创建的,而且很少有行业采用。它在应用层接收数据,如果有错误就会重发。请确认你的日志接受位置也支持这个协议。
### 用磁盘辅助队列可靠的传送
如果 rsyslog 在存储日志时遭遇错误,例如一个不可用网络连接,它能将日志排队直到连接还原。队列日志默认被存储在内存里。无论如何,内存是有限的并且如果问题仍然存在,日志会超出内存容量。
**警告:如果你只存储日志到内存,你可能会失去数据。**
rsyslog 能在内存被占满时将日志队列放到磁盘。[磁盘辅助队列](http://www.rsyslog.com/doc/queues.html)使日志的传输更可靠。这里有一个例子如何配置rsyslog 的磁盘辅助队列:
```
$WorkDirectory /var/spool/rsyslog # 暂存文件(spool)放置位置
$ActionQueueFileName fwdRule1 # 暂存文件的唯一名字前缀
$ActionQueueMaxDiskSpace 1g # 1gb 空间限制(尽可能大)
$ActionQueueSaveOnShutdown on # 关机时保存日志到磁盘
$ActionQueueType LinkedList # 异步运行
$ActionResumeRetryCount -1 # 如果主机宕机,不断重试
```
### 使用 TLS 加密日志
如果你担心你的数据的安全性和隐私性,你应该考虑加密你的日志。如果你使用纯文本在互联网传输日志,嗅探器和中间人可以读到你的日志。如果日志包含私人信息、敏感的身份数据或者政府管制数据,你应该加密你的日志。rsyslog 程序能使用 TLS 协议加密你的日志保证你的数据更安全。
建立 TLS 加密,你应该做如下任务:
1. 生成一个[证书授权(CA)](http://www.rsyslog.com/doc/tls_cert_ca.html)。在 /contrib/gnutls 有一些证书例子,可以用来测试,但是你需要为产品环境创建自己的证书。如果你正在使用一个日志管理服务,它会给你一个证书。
2. 为你的服务器生成一个[数字证书](http://www.rsyslog.com/doc/tls_cert_machine.html)使它能启用 SSL 操作,或者使用你自己的日志管理服务提供商的一个数字证书。
3. 配置你的 rsyslog 程序来发送 TLS 加密数据到你的日志管理系统。
这有一个 rsyslog 配置 TLS 加密的例子。替换 CERT 和 DOMAIN\_NAME 为你自己的服务器配置。
```
$DefaultNetstreamDriverCAFile /etc/rsyslog.d/keys/ca.d/CERT.crt
$ActionSendStreamDriver gtls
$ActionSendStreamDriverMode 1
$ActionSendStreamDriverAuthMode x509/name
$ActionSendStreamDriverPermittedPeer *.DOMAIN_NAME.com
```
### 应用日志的最佳管理方法
除 Linux 默认创建的日志之外,归集重要的应用日志也是一个好主意。几乎所有基于 Linux 的服务器应用都把它们的状态信息写入到独立、专门的日志文件中。这包括数据库产品,像 PostgreSQL 或者 MySQL,网站服务器,像 Nginx 或者 Apache,防火墙,打印和文件共享服务,目录和 DNS 服务等等。
管理员安装一个应用后要做的第一件事是配置它。Linux 应用程序典型的有一个放在 /etc 目录里 .conf 文件。它也可能在其它地方,但是那是大家找配置文件首先会看的地方。
根据应用程序有多复杂多庞大,可配置参数的数量可能会很少或者上百行。如前所述,大多数应用程序可能会在某种日志文件写它们的状态:配置文件是定义日志设置和其它东西的地方。
如果你不确定它在哪,你可以使用locate命令去找到它:
```
[root@localhost ~]# locate postgresql.conf
/usr/pgsql-9.4/share/postgresql.conf.sample
/var/lib/pgsql/9.4/data/postgresql.conf
```
#### 设置一个日志文件的标准位置
Linux 系统一般保存它们的日志文件在 /var/log 目录下。一般是这样,但是需要检查一下应用是否保存它们在 /var/log 下的特定目录。如果是,很好,如果不是,你也许想在 /var/log 下创建一个专用目录?为什么?因为其它程序也在 /var/log 下保存它们的日志文件,如果你的应用保存超过一个日志文件 - 也许每天一个或者每次重启一个 - 在这么大的目录也许有点难于搜索找到你想要的文件。
如果在你网络里你有运行多于一个的应用实例,这个方法依然便利。想想这样的情景,你也许有一打 web 服务器在你的网络运行。当排查任何一个机器的问题时,你就很容易知道确切的位置。
#### 使用一个标准的文件名
给你的应用最新的日志使用一个标准的文件名。这使一些事变得容易,因为你可以监控和追踪一个单独的文件。很多应用程序在它们的日志文件上追加一种时间戳。它让 rsyslog 更难于找到最新的文件和设置文件监控。一个更好的方法是使用日志轮转给老的日志文件增加时间。这样更易去归档和历史查询。
#### 追加日志文件
日志文件会在每个应用程序重启后被覆盖吗?如果这样,我们建议关掉它。每次重启 app 后应该去追加日志文件。这样,你就可以追溯重启前最后的日志。
#### 日志文件追加 vs. 轮转
要是应用程序每次重启后写一个新日志文件,如何保存当前日志?追加到一个单独的、巨大的文件?Linux 系统并不以频繁重启或者崩溃而出名:应用程序可以运行很长时间甚至不间歇,但是也会使日志文件非常大。如果你查询分析上周发生连接错误的原因,你可能无疑的要在成千上万行里搜索。
我们建议你配置应用每天半晚轮转(rotate)它的日志文件。
为什么?首先它将变得可管理。找一个带有特定日期的文件名比遍历一个文件中指定日期的条目更容易。文件也小的多:你不用考虑当你打开一个日志文件时 vi 僵住。第二,如果你正发送日志到另一个位置 - 也许每晚备份任务拷贝到归集日志服务器 - 这样不会消耗你的网络带宽。最后第三点,这样帮助你做日志保留。如果你想剔除旧的日志记录,这样删除超过指定日期的文件比用一个应用解析一个大文件更容易。
#### 日志文件的保留
你保留你的日志文件多长时间?这绝对可以归结为业务需求。你可能被要求保持一个星期的日志信息,或者管理要求保持一年的数据。无论如何,日志需要在一个时刻或其它情况下从服务器删除。
在我们看来,除非必要,只在线保持最近一个月的日志文件,并拷贝它们到第二个地方如日志服务器。任何比这更旧的日志可以被转到一个单独的介质上。例如,如果你在 AWS 上,你的旧日志可以被拷贝到 Glacier。
#### 给日志单独的磁盘分区
更好的,Linux 通常建议挂载到 /var 目录到一个单独的文件系统。这是因为这个目录的高 I/O。我们推荐挂载 /var/log 目录到一个单独的磁盘系统下。这样可以节省与主要的应用数据的 I/O 竞争。另外,如果一些日志文件变的太多,或者一个文件变的太大,不会占满整个磁盘。
#### 日志条目
每个日志条目中应该捕获什么信息?
这依赖于你想用日志来做什么。你只想用它来排除故障,或者你想捕获所有发生的事?这是一个捕获每个用户在运行什么或查看什么的规则条件吗?
如果你正用日志做错误排查的目的,那么只保存错误,报警或者致命信息。没有理由去捕获调试信息,例如,应用也许默认记录了调试信息或者另一个管理员也许为了故障排查而打开了调试信息,但是你应该关闭它,因为它肯定会很快的填满空间。在最低限度上,捕获日期、时间、客户端应用名、来源 ip 或者客户端主机名、执行的动作和信息本身。
#### 一个 PostgreSQL 的实例
作为一个例子,让我们看看 vanilla PostgreSQL 9.4 安装的主配置文件。它叫做 postgresql.conf,与其它Linux 系统中的配置文件不同,它不保存在 /etc 目录下。下列的代码段,我们可以在我们的 Centos 7 服务器的 /var/lib/pgsql 目录下找到它:
```
root@localhost ~]# vi /var/lib/pgsql/9.4/data/postgresql.conf
...
#------------------------------------------------------------------------------
# ERROR REPORTING AND LOGGING
#------------------------------------------------------------------------------
# - Where to Log -
log_destination = 'stderr'
# Valid values are combinations of
# stderr, csvlog, syslog, and eventlog,
# depending on platform. csvlog
# requires logging_collector to be on.
# This is used when logging to stderr:
logging_collector = on
# Enable capturing of stderr and csvlog
# into log files. Required to be on for
# csvlogs.
# (change requires restart)
# These are only used if logging_collector is on:
log_directory = 'pg_log'
# directory where log files are written,
# can be absolute or relative to PGDATA
log_filename = 'postgresql-%a.log' # log file name pattern,
# can include strftime() escapes
# log_file_mode = 0600 .
# creation mode for log files,
# begin with 0 to use octal notation
log_truncate_on_rotation = on # If on, an existing log file with the
# same name as the new log file will be
# truncated rather than appended to.
# But such truncation only occurs on
# time-driven rotation, not on restarts
# or size-driven rotation. Default is
# off, meaning append to existing files
# in all cases.
log_rotation_age = 1d
# Automatic rotation of logfiles will happen after that time. 0 disables.
log_rotation_size = 0 # Automatic rotation of logfiles will happen after that much log output. 0 disables.
# These are relevant when logging to syslog:
#syslog_facility = 'LOCAL0'
#syslog_ident = 'postgres'
# This is only relevant when logging to eventlog (win32):
#event_source = 'PostgreSQL'
# - When to Log -
#client_min_messages = notice # values in order of decreasing detail:
# debug5
# debug4
# debug3
# debug2
# debug1
# log
# notice
# warning
# error
#log_min_messages = warning # values in order of decreasing detail:
# debug5
# debug4
# debug3
# debug2
# debug1
# info
# notice
# warning
# error
# log
# fatal
# panic
#log_min_error_statement = error # values in order of decreasing detail:
# debug5
# debug4
# debug3
# debug2
# debug1
# info
# notice
# warning
# error
# log
# fatal
# panic (effectively off)
#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
# and their durations, > 0 logs only
# statements running at least this number
# of milliseconds
# - What to Log
#debug_print_parse = off
#debug_print_rewritten = off
#debug_print_plan = off
#debug_pretty_print = on
#log_checkpoints = off
#log_connections = off
#log_disconnections = off
#log_duration = off
#log_error_verbosity = default
# terse, default, or verbose messages
#log_hostname = off
log_line_prefix = '< %m >' # special values:
# %a = application name
# %u = user name
# %d = database name
# %r = remote host and port
# %h = remote host
# %p = process ID
# %t = timestamp without milliseconds
# %m = timestamp with milliseconds
# %i = command tag
# %e = SQL state
# %c = session ID
# %l = session line number
# %s = session start timestamp
# %v = virtual transaction ID
# %x = transaction ID (0 if none)
# %q = stop here in non-session
# processes
# %% = '%'
# e.g. '<%u%%%d> '
#log_lock_waits = off # log lock waits >= deadlock_timeout
#log_statement = 'none' # none, ddl, mod, all
#log_temp_files = -1 # log temporary files equal or larger
# than the specified size in kilobytes;5# -1 disables, 0 logs all temp files5
log_timezone = 'Australia/ACT'
```
虽然大多数参数被加上了注释,它们使用了默认值。我们可以看见日志文件目录是 pg*log(log*directory 参数,在 /var/lib/pgsql/9.4/data/ 下的子目录),文件名应该以 postgresql 开头(log*filename参数),文件每天轮转一次(log*rotation*age 参数)然后每行日志记录以时间戳开头(log*line*prefix参数)。特别值得说明的是 log*line\_prefix 参数:全部的信息你都可以包含在这。
看 /var/lib/pgsql/9.4/data/pg\_log 目录下展现给我们这些文件:
```
[root@localhost ~]# ls -l /var/lib/pgsql/9.4/data/pg_log
total 20
-rw-------. 1 postgres postgres 1212 May 1 20:11 postgresql-Fri.log
-rw-------. 1 postgres postgres 243 Feb 9 21:49 postgresql-Mon.log
-rw-------. 1 postgres postgres 1138 Feb 7 11:08 postgresql-Sat.log
-rw-------. 1 postgres postgres 1203 Feb 26 21:32 postgresql-Thu.log
-rw-------. 1 postgres postgres 326 Feb 10 01:20 postgresql-Tue.log
```
所以日志文件名只有星期命名的标签。我们可以改变它。如何做?在 postgresql.conf 配置 log\_filename 参数。
查看一个日志内容,它的条目仅以日期时间开头:
```
[root@localhost ~]# cat /var/lib/pgsql/9.4/data/pg_log/postgresql-Fri.log
...
< 2015-02-27 01:21:27.020 EST >LOG: received fast shutdown request
< 2015-02-27 01:21:27.025 EST >LOG: aborting any active transactions
< 2015-02-27 01:21:27.026 EST >LOG: autovacuum launcher shutting down
< 2015-02-27 01:21:27.036 EST >LOG: shutting down
< 2015-02-27 01:21:27.211 EST >LOG: database system is shut down
```
### 归集应用的日志
#### 使用 imfile 监控日志
习惯上,应用通常记录它们数据在文件里。文件容易在一个机器上寻找,但是多台服务器上就不是很恰当了。你可以设置日志文件监控,然后当新的日志被添加到文件尾部后就发送事件到一个集中服务器。在 /etc/rsyslog.d/ 里创建一个新的配置文件然后增加一个配置文件,然后输入如下:
```
$ModLoad imfile
$InputFilePollInterval 10
$PrivDropToGroup adm
```
```
# Input for FILE1
$InputFileName /FILE1
$InputFileTag APPNAME1
$InputFileStateFile stat-APPNAME1 #this must be unique for each file being polled
$InputFileSeverity info
$InputFilePersistStateInterval 20000
$InputRunFileMonitor
```
替换 FILE1 和 APPNAME1 为你自己的文件名和应用名称。rsyslog 将发送它到你配置的输出目标中。
#### 本地套接字日志与 imuxsock
套接字类似 UNIX 文件句柄,所不同的是套接字内容是由 syslog 守护进程读取到内存中,然后发送到目的地。不需要写入文件。作为一个例子,logger 命令发送它的日志到这个 UNIX 套接字。
如果你的服务器 I/O 有限或者你不需要本地文件日志,这个方法可以使系统资源有效利用。这个方法缺点是套接字有队列大小的限制。如果你的 syslog 守护进程宕掉或者不能保持运行,然后你可能会丢失日志数据。
rsyslog 程序将默认从 /dev/log 套接字中读取,但是你需要使用如下命令来让 [imuxsock 输入模块](http://www.rsyslog.com/doc/v8-stable/configuration/modules/imuxsock.html) 启用它:
```
$ModLoad imuxsock
```
#### UDP 日志与 imupd
一些应用程序使用 UDP 格式输出日志数据,这是在网络上或者本地传输日志文件的标准 syslog 协议。你的 syslog 守护进程接受这些日志,然后处理它们或者用不同的格式传输它们。备选的,你可以发送日志到你的日志服务器或者到一个日志管理方案中。
使用如下命令配置 rsyslog 通过 UDP 来接收标准端口 514 的 syslog 数据:
```
$ModLoad imudp
```
```
$UDPServerRun 514
```
### 用 logrotate 管理日志
日志轮转是当日志到达指定的时期时自动归档日志文件的方法。如果不介入,日志文件一直增长,会用尽磁盘空间。最后它们将破坏你的机器。
logrotate 工具能随着日志的日期截取你的日志,腾出空间。你的新日志文件保持该文件名。你的旧日志文件被重命名加上后缀数字。每次 logrotate 工具运行,就会创建一个新文件,然后现存的文件被逐一重命名。你来决定何时旧文件被删除或归档的阈值。
当 logrotate 拷贝一个文件,新的文件会有一个新的 inode,这会妨碍 rsyslog 监控新文件。你可以通过增加copytruncate 参数到你的 logrotate 定时任务来缓解这个问题。这个参数会拷贝现有的日志文件内容到新文件然后从现有文件截短这些内容。因为日志文件还是同一个,所以 inode 不会改变;但它的内容是一个新文件。
logrotate 工具使用的主配置文件是 /etc/logrotate.conf,应用特有设置在 /etc/logrotate.d/ 目录下。DigitalOcean 有一个详细的 [logrotate 教程](https://www.digitalocean.com/community/tutorials/how-to-manage-log-files-with-logrotate-on-ubuntu-12-10)
### 管理很多服务器的配置
当你只有很少的服务器,你可以登录上去手动配置。一旦你有几打或者更多服务器,你可以利用工具的优势使这变得更容易和更可扩展。基本上,所有的事情就是拷贝你的 rsyslog 配置到每个服务器,然后重启 rsyslog 使更改生效。
#### pssh
这个工具可以让你在很多服务器上并行的运行一个 ssh 命令。使用 pssh 部署仅用于少量服务器。如果你其中一个服务器失败,然后你必须 ssh 到失败的服务器,然后手动部署。如果你有很多服务器失败,那么手动部署它们会话费很长时间。
#### Puppet/Chef
Puppet 和 Chef 是两个不同的工具,它们能在你的网络按你规定的标准自动的配置所有服务器。它们的报表工具可以使你了解错误情况,然后定期重新同步。Puppet 和 Chef 都有一些狂热的支持者。如果你不确定那个更适合你的部署配置管理,你可以拜读一下 [InfoWorld 上这两个工具的对比](http://www.infoworld.com/article/2614204/data-center/puppet-or-chef--the-configuration-management-dilemma.html)
一些厂商也提供一些配置 rsyslog 的模块或者方法。这有一个 Loggly 上 Puppet 模块的例子。它提供给 rsyslog 一个类,你可以添加一个标识令牌:
```
node 'my_server_node.example.net' {
# Send syslog events to Loggly
class { 'loggly::rsyslog':
customer_token => 'de7b5ccd-04de-4dc4-fbc9-501393600000',
}
}
```
#### Docker
Docker 使用容器去运行应用,不依赖于底层服务。所有东西都运行在内部的容器,你可以把它想象为一个功能单元。ZDNet 有一篇关于在你的数据中心[使用 Docker](http://www.zdnet.com/article/what-is-docker-and-why-is-it-so-darn-popular/) 的深入文章。
这里有很多方式从 Docker 容器记录日志,包括链接到一个日志容器,记录到一个共享卷,或者直接在容器里添加一个 sysllog 代理。其中最流行的日志容器叫做 [logspout](https://github.com/progrium/logspout)。
#### 供应商的脚本或代理
大多数日志管理方案提供一些脚本或者代理,可以从一个或更多服务器相对容易地发送数据。重量级代理会耗尽额外的系统资源。一些供应商像 Loggly 提供配置脚本,来使用现存的 syslog 守护进程更轻松。这有一个 Loggly 上的例子[脚本](https://www.loggly.com/docs/sending-logs-unixlinux-system-setup/),它能运行在任意数量的服务器上。
---
via: <http://www.loggly.com/ultimate-guide/logging/managing-linux-logs/>
作者:[Jason Skowronski](https://www.linkedin.com/in/jasonskowronski) 作者:[Amy Echeverri](https://www.linkedin.com/in/amyecheverri) 作者:[Sadequl Hussain](https://www.linkedin.com/pub/sadequl-hussain/14/711/1a7) 译者:[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,137 | 在 Ubuntu 中如何安装或升级 Linux 内核到4.2 | http://ubuntuhandbook.org/index.php/2015/08/upgrade-kernel-4-2-ubuntu/ | 2015-09-03T07:30:00 | [
"内核",
"Linux"
] | https://linux.cn/article-6137-1.html | 
Linux 内核 4.2已经发布了。Linus Torvalds 在 [lkml.org](https://lkml.org/lkml/2015/8/30/96) 上写到:
>
> 通过这周这么小的变动,看来在最后一周 发布 4.2 版本应该不会有问题,当然还有几个修正,但是看起来也并不需要延迟一周。 所以这就到了,而且 4.3 的合并窗口现已打开。我已经有了几个等待处理的合并请求,明天我开始处理它们,然后在适当的时候放出来。 从 rc8 以来的简短日志很小,已经附加。这个补丁也很小...
>
>
>
### 新内核 4.2 有哪些改进?:
* 重写英特尔的x86汇编代码
* 支持新的 ARM 板和 SoC
* 对 F2FS 的 per-file 加密
* AMDGPU 的内核 DRM 驱动程序
* 对 Radeon DRM 驱动的 VCE1 视频编码支持
* 初步支持英特尔的 Broxton Atom SoC
* 支持 ARCv2 和 HS38 CPU 内核
* 增加了队列自旋锁的支持
* 许多其他的改进和驱动更新。
### 在 Ubuntu 中如何下载4.2内核 :
此内核版本的二进制包可供下载链接如下:
* [下载 4.2 内核(.DEB)](https://lkml.org/lkml/2015/8/30/96)
首先检查你的操作系统类型,32位(i386)的或64位(amd64)的,然后使用下面的方式依次下载并安装软件包:
1. linux-headers-4.2.0-xxx\_all.deb
2. linux-headers-4.2.0-xxx-generic\_xxx\_i386/amd64.deb
3. linux-image-4.2.0-xxx-generic\_xxx\_i386/amd64.deb
安装内核后,在终端((Ctrl+Alt+T))运行`sudo update-grub`命令来更新 grub boot-loader。
如果你需要一个低延迟系统(例如用于录制音频),请下载并安装下面的包:
1. linux-headers-4.2.0\_xxx\_all.deb
2. linux-headers-4.2.0-xxx-lowlatency\_xxx\_i386/amd64.deb
3. linux-image-4.2.0-xxx-lowlatency\_xxx\_i386/amd64.deb
对于没有图形用户界面的 Ubuntu 服务器,你可以运行下面的命令通过 wget 来逐一抓下载,并通过 dpkg 来安装:
对于64位的系统请运行:
```
cd /tmp/
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.2-unstable/linux-headers-4.2.0-040200_4.2.0-040200.201508301530_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.2-unstable/linux-headers-4.2.0-040200-generic_4.2.0-040200.201508301530_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.2-unstable/linux-image-4.2.0-040200-generic_4.2.0-040200.201508301530_amd64.deb
sudo dpkg -i linux-headers-4.2.0-*.deb linux-image-4.2.0-*.deb
```
对于32位的系统,请运行:
```
cd /tmp/
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.2-unstable/linux-headers-4.2.0-040200_4.2.0-040200.201508301530_all.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.2-unstable/linux-headers-4.2.0-040200-generic_4.2.0-040200.201508301530_i386.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.2-unstable/linux-image-4.2.0-040200-generic_4.2.0-040200.201508301530_i386.deb
sudo dpkg -i linux-headers-4.2.0-*.deb linux-image-4.2.0-*.deb
```
最后,重新启动计算机才能生效。
要恢复或删除旧的内核,请参阅[通过脚本安装内核](http://ubuntuhandbook.org/index.php/2015/08/install-latest-kernel-script/)。
---
via: <http://ubuntuhandbook.org/index.php/2015/08/upgrade-kernel-4-2-ubuntu/>
作者:[Ji m](http://ubuntuhandbook.org/index.php/about/) 译者:[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,143 | 如何为你的平台部署一个公开的系统状态页 | http://xmodulo.com/setup-system-status-page.html | 2015-09-03T18:49:28 | [
"Cachet"
] | https://linux.cn/article-6143-1.html | 如果你是一个系统管理员,负责关键的 IT 基础设置或公司的服务,你将明白有效的沟通在日常任务中的重要性。假设你的线上存储服务器故障了。你希望团队所有人达成共识你好尽快的解决问题。当你忙来忙去时,你不会想一半的人问你为什么他们不能访问他们的文档。当一个维护计划快到时间了你想在计划前提醒相关人员,这样避免了不必要的开销。
这一切的要求或多或少改进了你、你的团队、和你服务的用户之间沟通渠道。一个实现它的方法是维护一个集中的系统状态页面,报告和记录故障停机详情、进度更新和维护计划等。这样,在故障期间你避免了不必要的打扰,也可以提醒一些相关方,以及加入一些可选的状态更新。
有一个不错的**开源, 自承载系统状态页解决方案**叫做 [Cachet](https://cachethq.io/)。在这个教程,我将要描述如何用 Cachet 部署一个自承载系统状态页面。

### Cachet 特性
在详细的配置 Cachet 之前,让我简单的介绍一下它的主要特性。
* **全 JSON API**:Cachet API 可以让你使用任意的外部程序或脚本(例如,uptime 脚本)连接到 Cachet 来自动报告突发事件或更新状态。
* **认证**:Cachet 支持基础认证和 JSON API 的 API 令牌,所以只有认证用户可以更新状态页面。
* **衡量系统**:这通常用来展现随着时间推移的自定义数据(例如,服务器负载或者响应时间)。
* **通知**:可选地,你可以给任一注册了状态页面的人发送突发事件的提示邮件。
* **多语言**:状态页被翻译为11种不同的语言。
* **双因子认证**:这允许你使用 Google 的双因子认证来提升 Cachet 管理账户的安全性。
* **跨数据库支持**:你可以选择 MySQL,SQLite,Redis,APC 和 PostgreSQL 作为后端存储。
剩下的教程,我会说明如何在 Linux 上安装配置 Cachet。
### 第一步:下载和安装 Cachet
Cachet 需要一个 web 服务器和一个后端数据库来运转。在这个教程中,我将使用 LAMP 架构。以下是一些特定发行版上安装 Cachet 和 LAMP 架构的指令。
#### Debian,Ubuntu 或者 Linux Mint
```
$ sudo apt-get install curl git apache2 mysql-server mysql-client php5 php5-mysql
$ sudo git clone https://github.com/cachethq/Cachet.git /var/www/cachet
$ cd /var/www/cachet
$ sudo git checkout v1.1.1
$ sudo chown -R www-data:www-data .
```
在基于 Debian 的系统上设置 LAMP 架构的更多细节,参考这个[教程](http://xmodulo.com/install-lamp-stack-ubuntu-server.html)。
#### Fedora, CentOS 或 RHEL
在基于 Red Hat 系统上,你首先需要[设置 REMI 软件库](/article-4192-1.html)(以满足 PHP 的版本需求)。然后执行下面命令。
```
$ sudo yum install curl git httpd mariadb-server
$ sudo yum --enablerepo=remi-php56 install php php-mysql php-mbstring
$ sudo git clone https://github.com/cachethq/Cachet.git /var/www/cachet
$ cd /var/www/cachet
$ sudo git checkout v1.1.1
$ sudo chown -R apache:apache .
$ sudo firewall-cmd --permanent --zone=public --add-service=http
$ sudo firewall-cmd --reload
$ sudo systemctl enable httpd.service; sudo systemctl start httpd.service
$ sudo systemctl enable mariadb.service; sudo systemctl start mariadb.service
```
在基于 Red Hat 系统上设置 LAMP 的更多细节,参考这个[教程](/article-5789-1.html)。
### 配置 Cachet 的后端数据库
下一步是配置后端数据库。
登录到 MySQL/MariaDB 服务,然后创建一个空的数据库称为‘cachet’。
```
$ sudo mysql -uroot -p
```
```
mysql> create database cachet;
mysql> quit
```
现在用一个示例配置文件创建一个 Cachet 配置文件。
```
$ cd /var/www/cachet
$ sudo mv .env.example .env
```
在 .env 文件里,填写你自己设置的数据库信息(例如,DB\_\*)。其他的字段先不改变。
```
APP_ENV=production
APP_DEBUG=false
APP_URL=http://localhost
APP_KEY=SomeRandomString
DB_DRIVER=mysql
DB_HOST=localhost
DB_DATABASE=cachet
DB_USERNAME=root
DB_PASSWORD=<root-password>
CACHE_DRIVER=apc
SESSION_DRIVER=apc
QUEUE_DRIVER=database
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ADDRESS=null
MAIL_NAME=null
REDIS_HOST=null
REDIS_DATABASE=null
REDIS_PORT=null
```
### 第三步:安装 PHP 依赖和执行数据库迁移
下面,我们将要安装必要的PHP依赖包。我们会使用 composer 来安装。如果你的系统还没有安装 composer,先安装它:
```
$ curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
```
现在开始用 composer 安装 PHP 依赖包。
```
$ cd /var/www/cachet
$ sudo composer install --no-dev -o
```
下面执行一次性的数据库迁移。这一步会在我们之前创建的数据库里面创建那些所需的表。
```
$ sudo php artisan migrate
```
假设在 /var/www/cachet/.env 的数据库配置无误,数据库迁移应该像下面显示一样成功完成。

下面,创建一个密钥,它将用来加密进入 Cachet 的数据。
```
$ sudo php artisan key:generate
$ sudo php artisan config:cache
```

生成的应用密钥将自动添加到你的 .env 文件 APP\_KEY 变量中。你不需要自己编辑 .env。
### 第四步:配置 Apache HTTP 服务
现在到了配置运行 Cachet 的 web 服务的时候了。我们使用 Apache HTTP 服务器,为 Cachet 创建一个新的[虚拟主机](http://xmodulo.com/configure-virtual-hosts-apache-http-server.html),如下:
#### Debian,Ubuntu 或 Linux Mint
```
$ sudo vi /etc/apache2/sites-available/cachet.conf
```
```
<VirtualHost *:80>
ServerName cachethost
ServerAlias cachethost
DocumentRoot "/var/www/cachet/public"
<Directory "/var/www/cachet/public">
Require all granted
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
```
启用新虚拟主机和 mod\_rewrite:
```
$ sudo a2ensite cachet.conf
$ sudo a2enmod rewrite
$ sudo service apache2 restart
```
#### Fedora, CentOS 或 RHEL
在基于 Red Hat 系统上,创建一个虚拟主机文件,如下:
```
$ sudo vi /etc/httpd/conf.d/cachet.conf
```
```
<VirtualHost *:80>
ServerName cachethost
ServerAlias cachethost
DocumentRoot "/var/www/cachet/public"
<Directory "/var/www/cachet/public">
Require all granted
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
```
现在重载 Apache 配置:
```
$ sudo systemctl reload httpd.service
```
### 第五步:配置 /etc/hosts 来测试 Cachet
这时候,初始的 Cachet 状态页面应该启动运行了,现在测试一下。
由于 Cachet 被配置为Apache HTTP 服务的虚拟主机,我们需要调整你的客户机的 /etc/hosts 来访问他。你将从这个客户端电脑访问 Cachet 页面。(LCTT 译注:如果你给了这个页面一个正式的主机地址,则不需要这一步。)
打开 /etc/hosts,加入如下行:
```
$ sudo vi /etc/hosts
```
```
<cachet 服务器的 IP 地址> cachethost
```
上面名为“cachethost”必须匹配 Cachet 的 Apache 虚拟主机文件的 ServerName。
### 测试 Cachet 状态页面
现在你准备好访问 Cachet 状态页面。在你浏览器地址栏输入 http://cachethost。你将被转到如下的 Cachet 状态页的初始化设置页面。

选择 cache/session 驱动。这里 cache 和 session 驱动两个都选“File”。
下一步,输入关于状态页面的基本信息(例如,站点名称、域名、时区和语言),以及管理员认证账户。



你的状态页初始化就要完成了。

继续创建组件(你的系统单元)、事件或者任意你要做的维护计划。
例如,增加一个组件:

增加一个维护计划:
公共 Cachet 状态页就像这样:

集成了 SMTP,你可以在状态更新时发送邮件给订阅者。并且你可以使用 CSS 和 markdown 格式来完全自定义布局和状态页面。
### 结论
Cachet 是一个相当易于使用,自托管的状态页面软件。Cachet 一个高级特性是支持全 JSON API。使用它的 RESTful API,Cachet 可以轻松连接单独的监控后端(例如,[Nagios](http://xmodulo.com/monitor-common-services-nagios.html)),然后回馈给 Cachet 事件报告并自动更新状态。比起手工管理一个状态页它更快和有效率。
最后一句,我喜欢提及一个事。用 Cachet 设置一个漂亮的状态页面是很简单的,但要将这个软件用好并不像安装它那么容易。你需要完全保障所有 IT 团队习惯准确及时的更新状态页,从而建立公共信息的准确性。同时,你需要教用户去查看状态页面。最后,如果没有很好的填充数据,部署状态页面就没有意义,并且/或者没有一个人查看它。记住这个,尤其是当你考虑在你的工作环境中部署 Cachet 时。
### 故障排查
补充,万一你安装 Cachet 时遇到问题,这有一些有用的故障排查的技巧。
1. Cachet 页面没有加载任何东西,并且你看到如下报错。
```
production.ERROR: exception 'RuntimeException' with message 'No supported encrypter found. The cipher and / or key length are invalid.' in /var/www/cachet/bootstrap/cache/compiled.php:6695
```
**解决方案**:确保你创建了一个应用密钥,以及明确配置缓存如下所述。
```
$ cd /path/to/cachet
$ sudo php artisan key:generate
$ sudo php artisan config:cache
```
2. 调用 composer 命令时有如下报错。
```
- danielstjules/stringy 1.10.0 requires ext-mbstring * -the requested PHP extension mbstring is missing from your system.
- laravel/framework v5.1.8 requires ext-mbstring * -the requested PHP extension mbstring is missing from your system.
- league/commonmark 0.10.0 requires ext-mbstring * -the requested PHP extension mbstring is missing from your system.
```
**解决方案**:确保在你的系统上安装了必要的 PHP 扩展 mbstring ,并且兼容你的 PHP 版本。在基于 Red Hat 的系统上,由于我们从 REMI-56 库安装PHP,所以要从同一个库安装扩展。
```
$ sudo yum --enablerepo=remi-php56 install php-mbstring
```
3. 你访问 Cachet 状态页面时得到一个白屏。HTTP 日志显示如下错误。
```
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/cachet/storage/logs/laravel-2015-08-21.log" could not be opened: failed to open stream: Permission denied' in /var/www/cachet/bootstrap/cache/compiled.php:12851
```
**解决方案**:尝试如下命令。
```
$ cd /var/www/cachet
$ sudo php artisan cache:clear
$ sudo chmod -R 777 storage
$ sudo composer dump-autoload
```
如果上面的方法不起作用,试试禁止 SELinux:
```
$ sudo setenforce 0
```
---
via: <http://xmodulo.com/setup-system-status-page.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,147 | 如何在 Quagga BGP 路由器中设置 IPv6 的 BGP 对等体和过滤 | http://xmodulo.com/ipv6-bgp-peering-filtering-quagga-bgp-router.html | 2015-09-04T17:39:00 | [
"Quagga",
"路由器"
] | https://linux.cn/article-6147-1.html | 在之前的教程中,我们演示了如何使用Quagga建立一个[完备的BGP路由器](/article-4232-1.html)和配置[前缀过滤](http://xmodulo.com/filter-bgp-routes-quagga-bgp-router.html)。在本教程中,我们会向你演示如何创建IPv6 BGP对等体并通过BGP通告IPv6前缀。同时我们也将演示如何使用前缀列表和路由映射特性来过滤通告的或者获取到的IPv6前缀。
### 拓扑
教程中,我们主要参考如下拓扑。

服务供应商A和B希望在他们之间建立一个IPv6的BGP对等体。他们的IPv6地址和AS信息如下所示。
* 对等体IP块: 2001:DB8:3::/64
* 供应商A: AS 100, 2001:DB8:1::/48
* 供应商B: AS 200, 2001:DB8:2::/48
### CentOS/RHEL安装Quagga
如果Quagga还没有安装,我们可以先使用yum安装。
```
# yum install quagga
```
在CentOS/RHEL 7,SELinux策略会默认的阻止对于/usr/sbin/zebra配置目录的写操作,这会对我们将要介绍的安装操作有所影响。因此我们需要像下面这样关闭这个策略。如果你使用的是CentOS/RHEL 6可以跳过这一步。
```
# setsebool -P zebra_write_config 1
```
### 创建配置文件
在安装过后,我们先创建配置文件zebra/bgpd作为配置流程的开始。
```
# cp /usr/share/doc/quagga-XXXXX/zebra.conf.sample /etc/quagga/zebra.conf
# cp /usr/share/doc/quagga-XXXXX/bgpd.conf.sample /etc/quagga/bgpd.conf
```
然后,允许这些服务开机自启。
**在 CentOS/RHEL 6:**
```
# service zebra start; service bgpd start
# chkconfig zebra on; chkconfig bgpd on
```
**在 CentOS/RHEL 7:**
```
# systemctl start zebra; systemctl start bgpd
# systemctl enable zebra; systmectl enable bgpd
```
Quagga内部提供一个叫作vtysh的shell,其界面与那些主流路由厂商Cisco或Juniper十分相似。启动vtysh shell命令行:
```
# vtysh
```
提示符将改为:
```
router-a#
```
或
```
router-b#
```
在教程的其余部分,这个提示可以表明你正身处在哪个路由的vtysh shell中。
### 为Zebra指定日志文件
来为Zebra配置日志文件,这会有助于调试。
首先,进入全局配置模式通过输入:
```
router-a# configure terminal
```
提示符将变更成:
```
router-a(config)#
```
指定日志文件的位置。然后退出配置模式:
```
router-a(config)# log file /var/log/quagga/quagga.log
router-a(config)# exit
```
保存配置通过:
```
router-a# write
```
### 配置接口IP地址
现在,让我们为Quagga的物理接口配置IP地址。
首先,查看一下vtysh中现有的接口。
```
router-a# show interfaces
```
---
```
Interface eth0 is up, line protocol detection is disabled
## OUTPUT TRUNCATED ###
Interface eth1 is up, line protocol detection is disabled
## OUTPUT TRUNCATED ##
```
现在我们配置IPv6地址。
```
router-a# conf terminal
router-a(config)# interface eth0
router-a(config-if)# ipv6 address 2001:db8:3::1/64
router-a(config-if)# interface eth1
router-a(config-if)# ipv6 address 2001:db8:1::1/64
```
在路由B上采用同样的方式分配IPv6地址。我将配置汇总成如下。
```
router-b# show running-config
```
---
```
interface eth0
ipv6 address 2001:db8:3::2/64
interface eth1
ipv6 address 2001:db8:2::1/64
```
由于两台路由的eth0端口同属一个子网,即2001:DB8:3::/64,你应该可以相互ping通。在保证ping通的情况下,我们开始下面的内容。
```
router-a# ping ipv6 2001:db8:3::2
```
---
```
PING 2001:db8:3::2(2001:db8:3::2) 56 data bytes
64 bytes from 2001:db8:3::2: icmp_seq=1 ttl=64 time=3.20 ms
64 bytes from 2001:db8:3::2: icmp_seq=2 ttl=64 time=1.05 ms
```
### 步骤 1: IPv6 BGP 对等体
本段,我们将在两个路由之间配置IPv6 BGP。首先,我们在路由A上指定BGP邻居。
```
router-a# conf t
router-a(config)# router bgp 100
router-a(config-router)# no auto-summary
router-a(config-router)# no synchronization
router-a(config-router)# neighbor 2001:DB8:3::2 remote-as 200
```
然后,我们定义IPv6的地址族。在地址族中,我们需要定义要通告的网段,并激活邻居。
```
router-a(config-router)# address-family ipv6
router-a(config-router-af)# network 2001:DB8:1::/48
router-a(config-router-af)# neighbor 2001:DB8:3::2 activate
```
我们在路由B上也实施相同的配置。这里提供我归总后的配置。
```
router-b# conf t
router-b(config)# router bgp 200
router-b(config-router)# no auto-summary
router-b(config-router)# no synchronization
router-b(config-router)# neighbor 2001:DB8:3::1 remote-as 100
router-b(config-router)# address-family ipv6
router-b(config-router-af)# network 2001:DB8:2::/48
router-b(config-router-af)# neighbor 2001:DB8:3::1 activate
```
如果一切顺利,在路由间将会形成一个IPv6 BGP会话。如果失败了,请确保[在防火墙中开启了](http://ask.xmodulo.com/open-port-firewall-centos-rhel.html)必要的端口(TCP 179)。
我们使用以下命令来确认IPv6 BGP会话的信息。
**查看BGP汇总:**
```
router-a# show bgp ipv6 unicast summary
```
**查看BGP通告的路由:**
```
router-a# show bgp ipv6 neighbors <neighbor-IPv6-address> advertised-routes
```
**查看BGP获得的路由:**
```
router-a# show bgp ipv6 neighbors <neighbor-IPv6-address> routes
```

### 步骤 2: 过滤IPv6前缀
正如我们在上面看到的输出信息那样,路由间通告了他们完整的/48 IPv6前缀。出于演示的目的,我们会考虑以下要求。
* Router-B将通告一个/64前缀,一个/56前缀,和一个完整的/48前缀.
* Router-A将接受任由B提供的何形式的IPv6前缀,其中包含有/56和/64之间的网络掩码长度。
我们将根据需要过滤的前缀,来使用路由器的前缀列表和路由映射。

#### 为路由B修改通告的前缀
目前,路由B只通告一个/48前缀。我们修改路由B的BGP配置使它可以通告额外的/56和/64前缀。
```
router-b# conf t
router-b(config)# router bgp 200
router-b(config-router)# address-family ipv6
router-b(config-router-af)# network 2001:DB8:2::/56
router-b(config-router-af)# network 2001:DB8:2::/64
```
我们将路由A上验证了所有的前缀都获得到了。

太好了!我们在路由A上收到了所有的前缀,那么我们可以更进一步创建前缀列表和路由映射来过滤这些前缀。
#### 创建前缀列表
就像在[上则教程中](http://xmodulo.com/filter-bgp-routes-quagga-bgp-router.html)描述的那样,前缀列表是一种机制用来匹配带有子网长度的IP地址前缀。按照我们指定的需求,我们需要在路由A的前缀列表中创建一则必要的条目。
```
router-a# conf t
router-a(config)# ipv6 prefix-list FILTER-IPV6-PRFX permit 2001:DB8:2::/56 le 64
```
以上的命令会创建一个名为'FILTER-IPV6-PRFX'的前缀列表,用以匹配任何2001:DB8:2::池内掩码在56和64之间的所有前缀。
#### 创建并应用路由映射
现在已经在前缀列表中创建了条目,我们也应该相应的创建一条使用此条目的路由映射规则了。
```
router-a# conf t
router-a(config)# route-map FILTER-IPV6-RMAP permit 10
router-a(config-route-map)# match ipv6 address prefix-list FILTER-IPV6-PRFX
```
以上的命令会创建一条名为'FILTER-IPV6-RMAP'的路由映射规则。这则规则将会允许与之前在前缀列表中创建'FILTER-IPV6-PRFX'所匹配的IPv6
要记住路由映射规则只有在应用在邻居或者端口的指定方向时才有效。我们将把路由映射应用到BGP的邻居配置中。我们将路由映射应用于入方向,作为进入路由端的前缀过滤器。
```
router-a# conf t
router-a(config)# router bgp 100
router-a(config-router)# address-family ipv6
router-a(config-router-af)# neighbor 2001:DB8:3::2 route-map FILTER-IPV6-RMAP in
```
现在我们在路由A上再查看一边获得到的路由,我们应该只能看见两个被允许的前缀了。

**注意**: 你可能需要重置BGP会话来刷新路由表。
所有IPv6的BGP会话可以使用以下的命令重启:
```
router-a# clear bgp ipv6 *
```
我汇总了两个路由的配置,并做成了一张清晰的图片以便阅读。

### 总结
总结一下,这篇教程重点在于如何创建BGP对等体和IPv6的过滤。我们演示了如何向邻居BGP路由通告IPv6前缀,和如何过滤通告前缀或获得的通告。需要注意,本教程使用的过程可能会对网络供应商的网络运作有所影响,请谨慎参考。
希望这些对你有用。
---
via: <http://xmodulo.com/ipv6-bgp-peering-filtering-quagga-bgp-router.html>
作者:[Sarmed Rahman](http://xmodulo.com/author/sarmed) 译者:[martin2011qi](https://github.com/martin2011qi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,151 | 如何使用 Weave 以及 Docker 搭建 Nginx 反向代理/负载均衡服务器 | http://linoxide.com/linux-how-to/nginx-load-balancer-weave-docker/ | 2015-09-05T09:46:00 | [
"Docker",
"Weave",
"WeaveDNS",
"负载均衡"
] | /article-6151-1.html | Hi, 今天我们将会学习如何使用 Weave 和 Docker 搭建 Nginx 的反向代理/负载均衡服务器。Weave 可以创建一个虚拟网络将 Docker 容器彼此连接在一起,支持跨主机部署及自动发现。它可以让我们更加专注于应用的开发,而不是基础架构。Weave 提供了一个如此棒的环境,仿佛它的所有容器都属于同个网络,不需要端口/映射/连接等的配置。容器中的应用提供的服务在 weave 网络中可以轻易地被外部世界访问,不论你的容器运行在哪里。在这个教程里我们将会使用 weave 快速并且简单地将 nginx web 服务器部署为一个负载均衡器,反向代理一个运行在 Amazon Web Services 里面多个节点上的 docker 容器中的简单 php 应用。这里我们将会介绍 WeaveDNS,它提供一个不需要改变代码就可以让容器利用主机名找到的简单方式,并且能够让其他容器通过主机名连接彼此。
在这篇教程里,我们将使用 nginx 来将负载均衡分配到一个运行 Apache 的容器集合。最简单轻松的方法就是使用 Weave 来把运行在 ubuntu 上的 docker 容器中的 nginx 配置成负载均衡服务器。

### 1. 搭建 AWS 实例
首先,我们需要搭建 Amzaon Web Service 实例,这样才能在 ubuntu 下用 weave 跑 docker 容器。我们将会使用[AWS 命令行](http://console.aws.amazon.com/) 来搭建和配置两个 AWS EC2 实例。在这里,我们使用最小的可用实例,t1.micro。我们需要一个有效的**Amazon Web Services 账户**使用 AWS 命令行界面来搭建和配置。我们先在 AWS 命令行界面下使用下面的命令将 github 上的 weave 仓库克隆下来。
```
$ git clone https://github.com/weaveworks/guides
$ cd weave-gs/aws-nginx-ubuntu-simple
```
在克隆完仓库之后,我们执行下面的脚本,这个脚本将会部署两个 t1.micro 实例,每个实例中都是 ubuntu 作为操作系统并用 weave 跑着 docker 容器。
```
$ sudo ./demo-aws-setup.sh
```
在这里,我们将会在以后用到这些实例的 IP 地址。这些地址储存在一个 weavedemo.env 文件中,这个文件创建于执行 demo-aws-setup.sh 脚本期间。为了获取这些 IP 地址,我们需要执行下面的命令,命令输出类似下面的信息。
```
$ cat weavedemo.env
export WEAVE_AWS_DEMO_HOST1=52.26.175.175
export WEAVE_AWS_DEMO_HOST2=52.26.83.141
export WEAVE_AWS_DEMO_HOSTCOUNT=2
export WEAVE_AWS_DEMO_HOSTS=(52.26.175.175 52.26.83.141)
```
请注意这些不是固定的 IP 地址,AWS 会为我们的实例动态地分配 IP 地址。
我们在 bash 下执行下面的命令使环境变量生效。
```
. ./weavedemo.env
```
### 2. 启动 Weave 和 WeaveDNS
在安装完实例之后,我们将会在每台主机上启动 weave 以及 weavedns。Weave 以及 weavedns 使得我们能够轻易地将容器部署到一个全新的基础架构以及配置中, 不需要改变代码,也不需要去理解像 Ambassador 容器以及 Link 机制之类的概念。下面是在第一台主机上启动 weave 以及 weavedns 的命令。
```
ssh -i weavedemo-key.pem ubuntu@$WEAVE_AWS_DEMO_HOST1
$ sudo weave launch
$ sudo weave launch-dns 10.2.1.1/24
```
下一步,我也准备在第二台主机上启动 weave 以及 weavedns。
```
ssh -i weavedemo-key.pem ubuntu@$WEAVE_AWS_DEMO_HOST2
$ sudo weave launch $WEAVE_AWS_DEMO_HOST1
$ sudo weave launch-dns 10.2.1.2/24
```
### 3. 启动应用容器
现在,我们准备跨两台主机启动六个容器,这两台主机都用 Apache2 Web 服务实例跑着简单的 php 网站。为了在第一个 Apache2 Web 服务器实例跑三个容器, 我们将会使用下面的命令。
```
ssh -i weavedemo-key.pem ubuntu@$WEAVE_AWS_DEMO_HOST1
$ sudo weave run --with-dns 10.3.1.1/24 -h ws1.weave.local fintanr/weave-gs-nginx-apache
$ sudo weave run --with-dns 10.3.1.2/24 -h ws2.weave.local fintanr/weave-gs-nginx-apache
$ sudo weave run --with-dns 10.3.1.3/24 -h ws3.weave.local fintanr/weave-gs-nginx-apache
```
在那之后,我们将会在第二个实例上启动另外三个容器,请使用下面的命令。
```
ssh -i weavedemo-key.pem ubuntu@$WEAVE_AWS_DEMO_HOST2
$ sudo weave run --with-dns 10.3.1.4/24 -h ws4.weave.local fintanr/weave-gs-nginx-apache
$ sudo weave run --with-dns 10.3.1.5/24 -h ws5.weave.local fintanr/weave-gs-nginx-apache
$ sudo weave run --with-dns 10.3.1.6/24 -h ws6.weave.local fintanr/weave-gs-nginx-apache
```
注意: 在这里,--with-dns 选项告诉容器使用 weavedns 来解析主机名,-h x.weave.local 则使得 weavedns 能够解析该主机。
### 4. 启动 Nginx 容器
在应用容器如预期的运行后,我们将会启动 nginx 容器,它将会在六个应用容器服务之间轮询并提供反向代理或者负载均衡。 为了启动 nginx 容器,请使用下面的命令。
```
ssh -i weavedemo-key.pem ubuntu@$WEAVE_AWS_DEMO_HOST1
$ sudo weave run --with-dns 10.3.1.7/24 -ti -h nginx.weave.local -d -p 80:80 fintanr/weave-gs-nginx-simple
```
因此,我们的 nginx 容器在 $WEAVE*AWS*DEMO\_HOST1 上公开地暴露成为一个 http 服务器。
### 5. 测试负载均衡服务器
为了测试我们的负载均衡服务器是否可以工作,我们执行一段可以发送 http 请求给 nginx 容器的脚本。我们将会发送6个请求,这样我们就能看到 nginx 在一次的轮询中服务于每台 web 服务器之间。
```
$ ./access-aws-hosts.sh
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws1.weave.local",
"date" : "2015-06-26 12:24:23"
}
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws2.weave.local",
"date" : "2015-06-26 12:24:23"
}
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws3.weave.local",
"date" : "2015-06-26 12:24:23"
}
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws4.weave.local",
"date" : "2015-06-26 12:24:23"
}
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws5.weave.local",
"date" : "2015-06-26 12:24:23"
}
{
"message" : "Hello Weave - nginx example",
"hostname" : "ws6.weave.local",
"date" : "2015-06-26 12:24:23"
}
```
### 结束语
我们最终成功地将 nginx 配置成一个反向代理/负载均衡服务器,通过使用 weave 以及运行在 AWS(Amazon Web Service)EC2 里面的 ubuntu 服务器中的 docker。从上面的步骤输出可以清楚的看到我们已经成功地配置了 nginx。我们可以看到请求在一次轮询中被发送到6个应用容器,这些容器在 Apache2 Web 服务器中跑着 PHP 应用。在这里,我们部署了一个容器化的 PHP 应用,使用 nginx 横跨多台在 AWS EC2 上的主机而不需要改变代码,利用 weavedns 使得每个容器连接在一起,只需要主机名就够了,眼前的这些便捷, 都要归功于 weave 以及 weavedns。
如果你有任何的问题、建议、反馈,请在评论中注明,这样我们才能够做得更好,谢谢:-)
---
via: <http://linoxide.com/linux-how-to/nginx-load-balancer-weave-docker/>
作者:[Arun Pyasi](http://linoxide.com/author/arunp/) 译者:[dingdongnigetou](https://github.com/dingdongnigetou) 校对:[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/nginx-load-balancer-weave-docker/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b83275828f0>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,152 | Linux 小技巧:Chrome 小游戏,让文字说话,计划作业,重复执行命令 | http://www.tecmint.com/text-to-speech-in-terminal-schedule-a-job-and-watch-commands-in-linux/ | 2015-09-05T17:36:32 | [
"技巧"
] | https://linux.cn/article-6152-1.html | 重要的事情说两遍,我完成了一个[Linux提示与彩蛋](http://www.tecmint.com/tag/linux-tricks/)系列,让你的Linux获得更多创造和娱乐。

*Linux提示与彩蛋系列*
本文,我将会讲解Google-chrome内建小游戏,在终端中如何让文字说话,使用‘at’命令设置作业和使用watch命令重复执行命令。
### 1. Google Chrome 浏览器小游戏彩蛋
网线脱掉或者其他什么原因连不上网时,Google Chrome就会出现一个小游戏。声明,我并不是游戏玩家,因此我的电脑上并没有安装任何第三方的恶意游戏。安全是第一位。
所以当Internet发生出错,会出现一个这样的界面:

*不能连接到互联网*
按下空格键来激活Google-chrome彩蛋游戏。游戏没有时间限制。并且还不需要浪费时间安装使用。
不需要第三方软件的支持。同样支持Windows和Mac平台,但是我的平台是Linux,我也只谈论Linux。当然在Linux,这个游戏运行很好。游戏简单,但也很花费时间。
使用空格/向上方向键来跳跃。请看下列截图:

*Google Chrome中玩游戏*
### 2. Linux 终端中朗读文字
对于那些不能文字朗读的设备,有个小工具可以实现文字说话的转换器。用各种语言写一些东西,espeak就可以朗读给你。
系统应该默认安装了Espeak,如果你的系统没有安装,你可以使用下列命令来安装:
```
# apt-get install espeak (Debian)
# yum install espeak (CentOS)
# dnf install espeak (Fedora 22 及其以后)
```
你可以让espeak接受标准输入的交互输入并及时转换成语音朗读出来。如下:
```
$ espeak [按回车键]
```
更详细的输出你可以这样做:
```
$ espeak --stdout | aplay [按回车键][再次回车]
```
espeak设置灵活,也可以朗读文本文件。你可以这样设置:
```
$ espeak --stdout /path/to/text/file/file_name.txt | aplay [Hit Enter]
```
espeak可以设置朗读速度。默认速度是160词每分钟。使用-s参数来设置。
设置每分钟30词的语速:
```
$ espeak -s 30 -f /path/to/text/file/file_name.txt | aplay
```
设置每分钟200词的语速:
```
$ espeak -s 200 -f /path/to/text/file/file_name.txt | aplay
```
说其他语言,比如北印度语(作者母语),这样设置:
```
$ espeak -v hindi --stdout 'टेकमिंट विश्व की एक बेहतरीन लाइंक्स आधारित वेबसाइट है|' | aplay
```
你可以使用各种语言,让espeak如上面说的以你选择的语言朗读。使用下列命令来获得语言列表:
```
$ espeak --voices
```
### 3. 快速调度任务
我们已经非常熟悉使用[cron](http://www.tecmint.com/11-cron-scheduling-task-examples-in-linux/)守护进程执行一个计划命令。
Cron是一个Linux系统管理的高级命令,用于计划定时任务如备份或者指定时间或间隔的任何事情。
但是,你是否知道at命令可以让你在指定时间调度一个任务或者命令?at命令可以指定时间执行指定内容。
例如,你打算在早上11点2分执行uptime命令,你只需要这样做:
```
$ at 11:02
uptime >> /home/$USER/uptime.txt
Ctrl+D
```

*Linux中计划任务*
检查at命令是否成功设置,使用:
```
$ at -l
```

*浏览计划任务*
at支持计划多个命令,例如:
```
$ at 12:30
Command – 1
Command – 2
…
command – 50
…
Ctrl + D
```
### 4. 特定时间重复执行命令
有时,我们可以需要在指定时间间隔执行特定命令。例如,每3秒,想打印一次时间。
查看现在时间,使用下列命令。
```
$ date +"%H:%M:%S
```

*Linux中查看日期和时间*
为了每三秒查看一下这个命令的输出,我需要运行下列命令:
```
$ watch -n 3 'date +"%H:%M:%S"'
```

*Linux中watch命令*
watch命令的‘-n’开关设定时间间隔。在上述命令中,我们定义了时间间隔为3秒。你可以按你的需求定义。同样watch 也支持其他命令或者脚本。
至此。希望你喜欢这个系列的文章,让你的linux更有创造性,获得更多快乐。所有的建议欢迎评论。欢迎你也看看其他文章,谢谢。
---
via: <http://www.tecmint.com/text-to-speech-in-terminal-schedule-a-job-and-watch-commands-in-linux/>
作者:[Avishek Kumar](http://www.tecmint.com/author/avishek/) 译者:[VicYu/Vic020](http://vicyu.net) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,153 | 如何在 Linux 上自动调整屏幕亮度保护眼睛 | http://xmodulo.com/automatically-dim-your-screen-linux.html | 2015-09-06T07:30:00 | [
"Calise",
"Redshift",
"亮度",
"屏幕"
] | https://linux.cn/article-6153-1.html | 当你开始在计算机前花费大量时间的时候,问题自然开始显现。这健康吗?怎样才能舒缓我眼睛的压力呢?为什么光线灼烧着我?尽管解答这些问题的研究仍然在不断进行着,许多程序员已经采用了一些应用来改变他们的日常习惯,让他们的眼睛更健康点。在这些应用中,我发现了两个特别有趣的东西:Calise和Redshift。
### Calise
处于时断时续的开发中,[Calise](http://calise.sourceforge.net/)的意思是“相机光感应器(Camera Light Sensor)”。换句话说,它是一个根据摄像头接收到的光强度计算屏幕最佳的背光级别的开源程序。更进一步地说,Calise可以基于你的地理坐标来考虑你所在地区的天气。我喜欢它是因为它兼容各个桌面,甚至非X系列。

它同时附带了命令行界面和图形界面,支持多用户配置,而且甚至可以导出数据为CSV。安装完后,你必须在见证奇迹前对它进行快速校正。

不怎么令人喜欢的是,如果你和我一样有被偷窥妄想症,在你的摄像头前面贴了一条胶带,那就会比较不幸了,这会大大影响Calise的精确度。除此之外,Calise还是个很棒的应用,值得我们关注和支持。正如我先前提到的,它在过去几年中经历了一段修修补补的艰难阶段,所以我真的希望这个项目继续开展下去。

### Redshift
如果你想过要减少由屏幕导致的眼睛的压力,那么你很可能听过f.lux,它是一个免费的专有软件,用于根据一天中的时间来修改显示器的亮度和配色。然而,如果真的偏好于开源软件,那么一个可选方案就是:[Redshift](http://jonls.dk/redshift/)。灵感来自f.lux,Redshift也可以改变配色和亮度来加强你夜间坐在屏幕前的体验。启动时,你可以使用经度和纬度来配置地理坐标,然后就可以让它在托盘中运行了。Redshift将根据太阳的位置平滑地调整你的配色或者屏幕。在夜里,你可以看到屏幕的色温调向偏暖色,这会让你的眼睛少遭些罪。

和Calise一样,它提供了一个命令行界面,同时也提供了一个图形客户端。要快速启动Redshift,只需使用命令:
```
$ redshift -l [LAT]:[LON]
```
替换[LAT]:[LON]为你的维度和经度。
然而,它也可以通过gpsd模块来输入你的坐标。对于Arch Linux用户,我推荐你读一读这个[维基页面](https://wiki.archlinux.org/index.php/Redshift#Automatic_location_based_on_GPS)。
### 尾声
总而言之,Linux用户没有理由不去保护自己的眼睛,Calise和Redshift两个都很棒。我真希望它们的开发能够继续下去,让它们获得应有的支持。当然,还有比这两个更多的程序可以满足保护眼睛和保持健康的目的,但是我感觉Calise和Redshift会是一个不错的开端。
如果你有一个经常用来舒缓眼睛的压力的喜欢的程序,请在下面的评论中留言吧。
---
via: <http://xmodulo.com/automatically-dim-your-screen-linux.html>
作者:[Adrien Brochard](http://xmodulo.com/author/adrien) 译者:[GOLinux](https://github.com/GOLinux) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,154 | 在 Ubuntu 上配置高性能的 HHVM 环境 | http://www.tecmint.com/install-hhvm-and-nginx-apache-with-mariadb-on-debian-ubuntu/ | 2015-09-06T08:37:00 | [
"HHVM",
"PHP"
] | https://linux.cn/article-6154-1.html | HHVM全称为 HipHop Virtual Machine,它是一个开源虚拟机,用来运行由 Hack(一种编程语言)和 PHP 开发应用。HHVM 在保证了 PHP 程序员最关注的高灵活性的要求下,通过使用最新的编译方式来取得了非凡的性能。到目前为止,相对于 PHP + [APC (Alternative PHP Cache)](http://www.tecmint.com/install-apc-alternative-php-cache-in-rhel-centos-fedora/) ,HHVM 为 FaceBook 在 HTTP 请求的吞吐量上提高了9倍的性能,在内存的占用上,减少了5倍左右的内存占用。
同时,HHVM 也可以与基于 FastCGI 的 Web 服务器(如 Nginx 或者 Apache )协同工作。

*安装 HHVM,Nginx和 Apache 还有 MariaDB*
在本教程中,我们一起来配置 Nginx/Apache web 服务器、 数据库服务器 MariaDB 和 HHVM 。我们将使用 Ubuntu 15.04 (64 位),因为 HHVM 只能运行在64位系统上。同时,该教程也适用于 Debian 和 Linux Mint。
### 第一步: 安装 Nginx 或者 Apache 服务器
1、首先,先进行一次系统的升级并更新软件仓库列表,命令如下
```
# apt-get update && apt-get upgrade
```

*系统升级*
2、 正如我之前说的,HHVM 能和 Nginx 和 Apache 进行集成。所以,究竟使用哪个服务器,这是你的自由,不过,我们会教你如何安装这两个服务器。
#### 安装 Nginx
我们通过下面的命令安装 Nginx/Apache 服务器
```
# apt-get install nginx
```

*安装 Nginx 服务器*
#### 安装 Apache
```
# apt-get install apache2
```

*安装 Apache 服务器*
完成这一步,你能通过以下的链接看到 Nginx 或者 Apache 的默认页面
```
http://localhost
或
http://IP-Address
```

*Nginx 默认页面*

*Apache 默认页面*
### 第二步: 安装和配置 MariaDB
3、 这一步,我们将通过如下命令安装 MariaDB,它是一个比 MySQL 性能更好的数据库
```
# apt-get install mariadb-client mariadb-server
```

*安装 MariaDB*
4、 在 MariaDB 成功安装之后,你可以启动它,并且设置 root 密码来保护数据库:
```
# systemctl start mysql
# mysql_secure_installation
```
回答以下问题,只需要按下`y`或者 `n`并且回车。请确保你仔细的阅读过说明。
```
Enter current password for root (enter for none) = press enter
Set root password? [Y/n] = y
Remove anonymous users[y/n] = y
Disallow root login remotely[y/n] = y
Remove test database and access to it [y/n] = y
Reload privileges tables now[y/n] = y
```
5、 在设置了密码之后,你就可以登录 MariaDB 了。
```
# mysql -u root -p
```
### 第三步: 安装 HHVM
6、 在此阶段,我们将安装 HHVM。我们需要添加 HHVM 的仓库到你的`sources.list`文件中,然后更新软件列表。
```
# wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add -
# echo deb http://dl.hhvm.com/ubuntu DISTRIBUTION_VERSION main | sudo tee /etc/apt/sources.list.d/hhvm.list
# apt-get update
```
**重要**:不要忘记用你的 Ubuntu 发行版代号替换上述的 DISTRIBUTION\_VERSION (比如:lucid, precise, trusty) 或者是 Debian 的 jessie 或者 wheezy。在 Linux Mint 中也是一样的,不过只支持 petra。
添加了 HHVM 仓库之后,你就可以轻松安装了。
```
# apt-get install -y hhvm
```
安装之后,就可以启动它,但是它并没有做到开机启动。可以用如下命令做到开机启动。
```
# update-rc.d hhvm defaults
```
### 第四步: 配置 Nginx/Apache 连接 HHVM
7、 现在,nginx/apache 和 HHVM 都已经安装完成了,并且都独立运行起来了,所以我们需要对它们进行设置,来让它们互相关联。这个关键的步骤,就是需要告知 nginx/apache 将所有的 php 文件,都交给 HHVM 进行处理。
如果你用了 Nginx,请按照如下步骤:
nginx 的配置文件在 /etc/nginx/sites-available/default, 并且这些配置文件会在 /usr/share/nginx/html 中寻找文件执行,不过,它不知道如何处理 PHP。
为了确保 Nginx 可以连接 HHVM,我们需要执行所带的如下脚本。它可以帮助我们正确的配置 Nginx,将 hhvm.conf 放到 上面提到的配置文件 nginx.conf 的头部。
这个脚本可以确保 Nginx 可以对 .hh 和 .php 的做正确的处理,并且将它们通过 fastcgi 发送给 HHVM。
```
# /usr/share/hhvm/install_fastcgi.sh
```

*配置 Nginx、HHVM*
**重要**: 如果你使用的是 Apache,这里不需要进行配置。
8、 接下来,你需要使用 hhvm 来提供 php 的运行环境。
```
# /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60
```
以上步骤完成之后,你现在可以启动并且测试它了。
```
# systemctl start hhvm
```
### 第五步: 测试 HHVM 和 Nginx/Apache
9、 为了确认 hhvm 是否工作,你需要在 nginx/apache 的文档根目录下建立 hello.php。
```
# nano /usr/share/nginx/html/hello.php [对于 Nginx]
或
# nano /var/www/html/hello.php [对于 Nginx 和 Apache]
```
在文件中添加如下代码:
```
<?php
if (defined('HHVM_VERSION')) {
echo 'HHVM is working';
phpinfo();
} else {
echo 'HHVM is not working';
}
?>
```
然后访问如下链接,确认自己能否看到 "hello world"
```
http://localhost/info.php
或
http://IP-Address/info.php
```

*HHVM 页面*
如果 “HHVM” 的页面出现了,那就说明你成功了。
### 结论
以上的步骤都是非常简单的,希望你能觉得这是一篇有用的教程,如果你在以上的步骤中遇到了问题,给我们留一个评论,我们将全力解决。
---
via: <http://www.tecmint.com/install-hhvm-and-nginx-apache-with-mariadb-on-debian-ubuntu/>
作者:[Ravi Saive](http://www.tecmint.com/author/admin/) 译者:[MikeCoder](https://github.com/MikeCoder) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,155 | RHCSA 系列(二): 如何进行文件和目录管理 | http://www.tecmint.com/file-and-directory-management-in-linux/ | 2015-09-06T09:30:00 | [
"RHCSA"
] | https://linux.cn/article-6155-1.html | 在本篇中,我们将回顾一些系统管理员日常任务需要的技能。

*RHCSA: 运行文件以及进行文件夹管理 - 第二部分*
### 创建、删除、复制和移动文件及目录
文件和目录管理是每一个系统管理员都应该掌握的必备技能。它包括了从头开始的创建、删除文本文件(每个程序的核心配置)以及目录(你用来组织文件和其它目录),以及识别已有文件的类型。
[`touch` 命令](/article-2740-1.html) 不仅仅能用来创建空文件,还能用来更新已有文件的访问时间和修改时间。

*touch 命令示例*
你可以使用 `file [filename]`来判断一个文件的类型 (在你用文本编辑器编辑之前,判断类型将会更方便编辑)。

*file 命令示例*
使用`rm [filename]` 可以删除文件。

*rm 命令示例*
对于目录,你可以使用`mkdir [directory]`在已经存在的路径中创建目录,或者使用 `mkdir -p [/full/path/to/directory]`带全路径创建文件夹。

*mkdir 命令示例*
当你想要去删除目录时,在你使用`rmdir [directory]` 前,你需要先确保目录是空的,或者使用更加强力的命令(小心使用它!)`rm -rf [directory]`。后者会强制删除`[directory]`以及它的内容,所以使用这个命令存在一定的风险。
### 输入输出重定向以及管道
命令行环境提供了两个非常有用的功能:允许重定向命令的输入和输出为另一个文件,以及发送命令的输出到另一个命令,这分别称为重定向和管道。
为了理解这两个重要概念,我们首先需要理解三个最重要的字符输入输出流类型,以 \*nix 的话来说,它们实际上是特殊的文件。
* 标准输入 (即 stdin),默认连接到键盘。 换句话说,键盘是输入命令到命令行的标准输入设备。
* 标准输出 (即 stdout),默认连接到屏幕。 找个设备“接受”命令的输出,并展示到屏幕上。
* 标准错误 (即 stderr),默认是命令的状态消息出现的地方,它也是屏幕。
在下面的例子中,`ls /var`的结果被发送到stdout(屏幕展示),ls /tecmint 的结果也一样。但在后一种情况下,它显示在标准错误输出上。

*输入和输出命令实例*
为了更容易识别这些特殊文件,每个文件都被分配有一个文件描述符,这是用于访问它们的抽象标识。主要要理解的是,这些文件就像其它的一样,可以被重定向。这就意味着你可以从一个文件或脚本中捕获输出,并将它传送到另一个文件、命令或脚本中。这样你就可以在磁盘上存储命令的输出结果,用于稍后的分析。
要重定向 stdin (fd 0)、 stdout (fd 1) 或 stderr (fd 2),可以使用如下操作符。
| | |
| --- | --- |
| **转向操作** | **效果** |
| **>** | 重定向标准输出到一个文件。如果目标文件存在,内容就会被重写。 |
| **>>** | 添加标准输出到文件尾部。 |
| **2>** | 重定向标准错误输出到一个文件。如果目标文件存在,内容就会被重写。 |
| **2>>** | 添加标准错误输出到文件尾部。 |
| **&>** | 重定向标准错误和标准输出到一个文件。如果目标文件存在,内容就会被重写。 |
| **<** | 使用特定的文件做标准输入。 |
| **<>** | 使用特定的文件做标准输入和标准输出。 |
与重定向相比,管道是通过在命令后和另外一个命令前之间添加一个竖杠`(|)`。
记得:
* *重定向*是用来定向命令的输出到一个文件,或把一个文件发送作为到一个命令的输入。
* *管道*是用来将命令的输出转发到另一个命令作为其输入。
#### 重定向和管道的使用实例
**例1:将一个命令的输出到文件**
有些时候,你需要遍历一个文件列表。要做到这样,你可以先将该列表保存到文件中,然后再按行读取该文件。虽然你可以直接遍历ls的输出,不过这个例子是用来说明重定向。
```
# ls -1 /var/mail > mail.txt
```

*将一个命令的输出重定向到文件*
**例2:重定向stdout和stderr到/dev/null**
如果不想让标准输出和标准错误展示在屏幕上,我们可以把这两个文件描述符重定向到 `/dev/null`。请注意对于同样的命令,重定向是如何改变了输出。
```
# ls /var /tecmint
# ls /var/ /tecmint &> /dev/null
```

*重定向stdout和stderr到/dev/null*
**例3:使用一个文件作为命令的输入**
[cat 命令](http://www.tecmint.com/13-basic-cat-command-examples-in-linux/)的经典用法如下
```
# cat [file(s)]
```
您还可以使用正确的重定向操作符发送一个文件作为输入。
```
# cat < mail.txt
```

*cat 命令实例*
**例4:发送一个命令的输出作为另一个命令的输入**
如果你有一个较大的目录或进程列表,并且想快速定位,你或许需要将列表通过管道传送给grep。
接下来我们会在下面的命令中使用管道,第一个管道是查找所需的关键词,第二个管道是除去产生的 `grep command`。这个例子列举了所有与apache用户有关的进程:
```
# ps -ef | grep apache | grep -v grep
```

*发送一个命令的输出作为另一个命令的输入*
### 归档,压缩,解包,解压文件
如果你需要传输、备份、或者通过邮件发送一组文件,你可以使用一个存档(或打包)工具,如 [tar](http://www.tecmint.com/18-tar-command-examples-in-linux/),通常与gzip,bzip2,或 xz 等压缩工具配合使用。
您选择的压缩工具每一个都有自己不同的压缩速度和压缩率。这三种压缩工具,gzip是最古老和可以较小压缩的工具,bzip2提供经过改进的压缩,以及xz是最新的而且压缩最大。通常情况下,使用这些压缩工具压缩的文件的扩展名依次是.gz、.bz2或.xz。
| | | |
| --- | --- | --- |
| **命令** | **缩写** | **描述** |
| –create | c | 创建一个tar归档 |
| –concatenate | A | 添加tar归档到另外一个归档中 |
| –append | r | 添加非tar归档到另外一个归档中 |
| –update | u | 添加比归档中的文件更新的文件 |
| –diff or –compare | d | 将归档中的文件和硬盘的文件进行对比 |
| –list | t | 列举一个tar压缩包的内容 |
| –extract or –get | x | 从归档中提取文件 |
| | | |
| --- | --- | --- |
| **操作参数** | **缩写** | **描述** |
| —directory dir | C | 在执行操作前更改目录 |
| —same-permissions and —same-owner | p | 分别保留权限和所有者信息 |
| –verbose | v | 列举所有读取或提取的文件,如果和 --list 参数一起使用,也会显示文件的大小、所有权和时间戳 |
| —exclude file | — | 从存档中排除文件。在这种情况下,文件可以是一个实际的文件或匹配模式。 |
| —gzip or —gunzip | z | 使用gzip压缩归档 |
| –bzip2 | j | 使用bzip2压缩归档 |
| –xz | J | 使用xz压缩归档 |
**例5:创建一个tar文件,然后使用三种压缩工具压缩**
在决定使用这个还是那个工具之前,您可能想比较每个工具的压缩效率。请注意压缩小文件或几个文件,结果可能不会有太大的差异,但可能会给你看出它们的差异。
```
# tar cf ApacheLogs-$(date +%Y%m%d).tar /var/log/httpd/* # Create an ordinary tarball
# tar czf ApacheLogs-$(date +%Y%m%d).tar.gz /var/log/httpd/* # Create a tarball and compress with gzip
# tar cjf ApacheLogs-$(date +%Y%m%d).tar.bz2 /var/log/httpd/* # Create a tarball and compress with bzip2
# tar cJf ApacheLogs-$(date +%Y%m%d).tar.xz /var/log/httpd/* # Create a tarball and compress with xz
```

*tar 命令实例*
**例6:归档时同时保存原始权限和所有权**
如果你正在从用户的主目录创建备份,你需要要存储的个人文件与原始权限和所有权,而不是通过改变它们的用户帐户或守护进程来执行备份。下面的命令可以在归档时保留文件属性。
```
# tar cJf ApacheLogs-$(date +%Y%m%d).tar.xz /var/log/httpd/* --same-permissions --same-owner
```
### 创建软连接和硬链接
在Linux中,有2种类型的链接文件:硬链接和软(也称为符号)链接。因为硬链接文件只是现存文件的另一个名字,使用相同的 inode 号,它指向实际的数据;而符号链接只是指向的文件名。
此外,硬链接不占用磁盘上的空间,而符号链接则占用少量的空间来存储的链接本身的文本。硬链接的缺点就是要求它们必须在同一个文件系统内,因为 inode 在一个文件系统内是唯一的。而符号链接没有这个限制,它们通过文件名而不是 inode 指向其它文件或目录,所以可以跨文件系统。
创建链接的基本语法看起来是相似的:
```
# ln TARGET LINK_NAME #从LINK_NAME到Target的硬链接
# ln -s TARGET LINK_NAME #从LINK_NAME到Target的软链接
```
**例7:创建硬链接和软链接**
没有更好的方式来形象的说明一个文件和一个指向它的硬链接或符号链接的关系,而不是创建这些链接。在下面的截图中你会看到文件和指向它的硬链接共享相同的inode,都是使用了相同的466个字节的磁盘。
另一方面,在别的磁盘创建一个硬链接将占用5个字节,这并不是说你将耗尽存储容量,而是这个例子足以说明一个硬链接和软链接之间的区别。

*软连接和硬链接之间的不同*
在Linux系统上符号链接的典型用法是指向一个带版本的文件。假设有几个程序需要访问文件fooX.Y,但麻烦是版本经常变化(像图书馆一样)。每次版本更新时我们都需要更新指向 fooX.Y 的单一引用,而更安全、更快捷的方式是,我们可以让程序寻找名为 foo 的符号链接,它实际上指向 fooX.Y。
这样的话,当你的X和Y发生变化后,你只需更新符号链接 foo 到新的目标文件,而不用跟踪每个对目标文件的使用并更新。
### 总结
在这篇文章中,我们回顾了一些基本的文件和目录管理技能,这是每个系统管理员的工具集的一部分。请确保阅读了本系列的其它部分,并将这些主题与本教程所涵盖的内容相结合。
如果你有任何问题或意见,请随时告诉我们。我们总是很高兴从读者那获取反馈.
---
via: <http://www.tecmint.com/file-and-directory-management-in-linux/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[xiqingongzi](https://github.com/xiqingongzi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,160 | 新手指南: Linux 新手应该知道的 26 个命令 | http://locez.com/Linux/common-command/ | 2015-09-06T14:51:00 | [
"命令行",
"Linux"
] | https://linux.cn/article-6160-1.html | 当你进入了 Linux 的世界,在[下载](/article-4130-1.html)、[安装](/article-5893-1.html) 了某个 [Linux 发行版](https://linux.cn/share/distro/),体验了 Linux 桌面并安装了一些你喜爱和需要的[软件](/article-6042-1.html)之后,应该去了解下 Linux 真正的魅力所在:**命令行**。每一个 Linux 命令其实就是一个程序,借助这些命令,我们可以办到非常多的事情。下面将会为大家介绍一下几个常用的命令。

### 如何寻求帮助?
在 Linux 下遇到问题,**最重要的是要自己寻求帮助**,下面是三种寻求帮助的方法。
#### man
`man` 是 Linux 的帮助手册,即 `manual` 。因为大多数程序都会自带手册,所以可以通过 `man` 命令获取帮助。执行以后,在 **man page** 页面中按 `q` 退出。
获取 `ls` 的帮助
```
$ man ls
```
查看有多少(针对不同方面的)同名的手册
```
$ man -f ls
ls (1) - list directory contents
ls (1p) - list directory contents
```
查看特定的手册
```
$ man 1p ls
```
#### info
与 `man` 不同的是,可以像浏览网页一样在各个节点中跳转。
从文档首页开始浏览
```
$ info
```
获取特定程序的帮助
```
$ info program
```
#### help
除了上面的两种方法外,还有一种简单使用的方法,那就是 `--help` 参数,一般程序都会有这个参数,会输出最简单有用的介绍。
```
$ man --help ### 获取 man 的帮助
$ info --help ### 获取 info 的帮助
$ ls --help ### 获取 ls 的帮助
```
### 如何简单操作?
在 `Terminal(终端)` 中,有许多操作技巧,这里就介绍几个简单的。
#### 光标
* up(方向键上) 可以调出输入历史执行记录,快速执行命令
* down(方向键下) 配合 up 选择历史执行记录
* Home 移动光标到本行开头
* End 移动光标到本行结尾
* PgUp 向上翻页
* PaDN 向下翻页
* ctrl + c 终止当前程序
#### Tab 补全
`Tab` 补全是非常有用的一个功能,可以用来自动补全命令或文件名,省时准确。
* 未输入状态下连按**两次** `Tab` 列出所有可用命令
* 已输入部分命令名或文件名,按 `Tab` 进行自动补全,多用你就肯定会喜欢的了。
### 常用命令
以下命令按照通常的使用频度排列。
#### cd
`cd` 是打开某个路径的命令,也就是打开某个文件夹,并跳转到该处。
```
$ cd path ### path 为你要打开的路径。
```
其中 path 有绝对路径和相对路径之分,绝对路径强调从 `/` 起,一直到所在路径。相对路径则相对于当前路径来说,假设当前家目录有`etc` 文件夹(绝对路径应为 `/home/username/etc`),如果直接 `cd etc` 则进入此文件夹,但若是 `cd /etc/` 则是进入系统 `etc` ,多琢磨一下就可以理解了。另外在 Linux 中, `.` 代表当前目录, `..` 代表上级目录,因此返回上级目录可以 `cd ..` 。
#### ls
`ls` 即 **list** ,列出文件。
```
$ ls ### 仅列出当前目录可见文件
$ ls -l ### 列出当前目录可见文件详细信息
$ ls -hl ### 列出详细信息并以可读大小显示文件大小
$ ls -al ### 列出所有文件(包括隐藏)的详细信息
```
**注意**: Linux 中 以 `.` 开头的文件或文件夹均为隐藏文件或隐藏文件夹。
#### pwd
`pwd` 用于返回当前工作目录的名字,为绝对路径名。
```
$ pwd
/home
```
#### mkdir
`mkdir` 用于新建文件夹。
```
$ mkdir folder
$ mkdir -p folder/subfolder ### -p 参数为当父目录存在时忽略,若不存在则建立,用此参数可建立多级文件夹
```
#### rm
`rm` 即 **remove** ,删除文件。
```
$ rm filename ### 删除 filename
$ rm -i filename ### 删除 filename 前提示,若多个文件则每次提示
$ rm -rf folder/subfolder/ ### 递归删除 subfolder 下所有文件及文件夹,包括 subfolder 自身
$ rm -d folder ### 删除空文件夹
```
#### cp
`cp` 即 **copy** ,复制文件。
```
$ cp source dest ### 将 source 复制到 dest
$ cp folder/* dest ### 将 folder 下所有文件(不含子文件夹中的文件)复制到 dest
$ cp -r folder dest ### 将 folder 下所有文件(包含子文件夹中的所有文件)复制到 dest
```
#### mv
`mv` 即 **move** ,移动文件。
```
$ mv source folder ### 将 source 移动到 folder 下,完成后则为 folder/source
$ mv -i source folder ### 在移动时,若文件已存在则提示 **是否覆盖**
$ mv source dest ### 在 dest 不为目录的前提下,重命名 source 为 dest
```
#### cat
`cat` 用于输出文件内容到 Terminal 。
```
$ cat /etc/locale.gen ### 输出 locale.gen 的内容
$ cat -n /etc/locale.gen ### 输出 locale.gen 的内容并显示行号
```
#### more
`more` 与 `cat` 相似,都可以查看文件内容,所不同的是,当一个文档太长时, `cat` 只能展示最后布满屏幕的内容,前面的内容是不可见的。这时候可用 `more` 逐行显示内容。
```
$ more /etc/locale.gen
$ more +100 /etc/locale.gen ### 从 100 行开始显示
```
#### less
`less` 与 `more` 相似,不过 `less` 支持上下滚动查看内容,而 `more` 只支持逐行显示。
```
$ less /etc/locale.gen
$ less +100 /etc/locale.gen
```
#### nano
`nano` 是一个简单实用的文本编辑器,使用简单。
```
$ nano filename ### 编辑 filename 文件,若文件不存在,则新打开一个文件,若退出时保存,则创建该文件
```
编辑完后,`ctrl + X` 提示是否保存,按 `y` 确定保存即可。
**注意**:在使用过程中可用 `ctrl + G` 获取帮助。
#### reboot
`reboot` 为重启命令。
```
# reboot ### '$' 和 '#' 的区别在于 '$' 普通用户即可执行
### 而 '#' 为 root 用户才可执行,或普通用户使用 'sudo'
```
#### poweroff
`poweroff` 为关机命令。
```
# poweroff ### 马上关机
```
#### ping
`ping` 主要用于测试网络连通,通过对目标机器发送数据包来测试两台主机是否连通,及延时情况。
```
$ ping locez.com ### 通过域名 ping,若 DNS 未设置好,可能无法 ping 通
$ ping linux.cn
PING linux.cn (211.157.2.94) 56(84) bytes of data.
64 bytes from 211.157.2.94.static.in-addr.arpa (211.157.2.94): icmp_seq=1 ttl=53 time=41.5 ms
64 bytes from 211.157.2.94.static.in-addr.arpa (211.157.2.94): icmp_seq=2 ttl=53 time=40.4 ms
64 bytes from 211.157.2.94.static.in-addr.arpa (211.157.2.94): icmp_seq=3 ttl=53 time=41.9 ms
^C
--- linux.cn ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 40.406/41.287/41.931/0.644 ms
$ ping 211.157.2.94 ### 通过 IP 地址 ping ,若无法 ping 通可能是网络连接出现问题
```
#### grep
`grep` 主要用于返回匹配的项目,支持正则表达式。
```
$ grep PATTERN filename ### 返回所有含有 PATTERN 的行
$ grep zh_CN /etc/locale.gen ### 返回所有含 zh_CN 的行
```
#### mount
`mount` 用于挂载一个文件系统,需要 `root` 用户执行。一个磁盘可分为若干个分区,在分区上面可以创建文件系统,而挂载点则是提供一个访问的入口,将一个分区的文件系统挂载到某个目录中,称这个目录为挂载点,并且可以通过这个挂载点访问该文件系统中的内容。
例如一块硬盘在 Linux 中表示为 `/dev/sda` 那么它上面的分区应该表示为 `/dev/sda1` 、`/dev/sda2` 。
```
# mount ### 输出系统目前的挂载信息
# mount /dev/sda1 /mnt ### 将 sda1 挂载到 /mnt 中
# cd /mnt ### 直接通过 /mnt 访问内容
# mount -o remount,rw /mnt ### 重新挂载 sda1 到 /mnt 并设置为 可读写
# mount -a ### 挂载 fstab 文件配置好的文件系统
```
#### umount
`umount` 与 `mount` 相反,是卸载一个挂载点,即取消该入口。
```
# umount /mnt ### 卸载 /mnt 这个挂载点的文件系统
# umount -a ### 卸载所有已挂载的文件系统
```
#### tar
`tar` 主要用于创建归档文件,和解压归档文件,其本身是没有压缩功能的,但可以调用 `gzip` 、 `bzip2` 进行压缩处理。
参数解释:
* `-c` 创建归档
* `-x` 解压归档
* `-v` 显示处理过程
* `-f` 目标文件,其后必须紧跟 目标文件
* `-j` 调用 `bzip2` 进行解压缩
* `-z` 调用 `gzip` 进行解压缩
* `-t` 列出归档中的文件
```
$ tar -cvf filename.tar . ### 将当前目录所有文件归档,但不压缩,注意后面有个 ’.‘ ,不可省略,代表当前目录的意思
$ tar -xvf filename.tar ### 解压 filename.tar 到当前文件夹
$ tar -cvjf filename.tar.bz2 . ### 使用 bzip2 压缩
$ tar -xvjf filename.tar.bz2 ### 解压 filename.tar.bz2 到当前文件夹
$ tar -cvzf filename.tar.gz ### 使用 gzip 压缩
$ tar -xvzf filename.tar.gz ### 解压 filename.tar.gz 到当前文件夹
$ tar -tf filename ### 只查看 filename 归档中的文件,不解压
```
#### ln
`ln` 主要用于在两个文件中创建链接,链接又分为 `Hard Links` (硬链接)和 `Symbolic Links` (符号链接或软链接),其中默认为创建**硬链接**,使用 `-s` 参数指定创建软链接。
* 硬链接主要是增加一个文件的链接数,只要该文件的链接数不为 `0` ,该文件就不会被物理删除,所以删除一个具有多个硬链接数的文件,必须删除所有它的硬链接才可删除。
* 软链接简单来说是为文件创建了一个类似快捷方式的东西,通过该链接可以访问文件,修改文件,但不会增加该文件的链接数,删除一个软链接并不会删除源文件,即使源文件被删除,软链接也存在,当重新创建一个同名的源文件,该软链接则指向新创建的文件。
* 硬链接只可链接两个文件,不可链接目录,而软链接可链接目录,所以软链接是非常灵活的。
```
$ ln source dest ### 为 source 创建一个名为 dest 的硬链接
$ ln -s source dest ### 为 source 创建一个名为 dest 的软链接
```
#### chown
`chown` 用于改变一个文件的所有者及所在的组。
```
# chown user filename ### 改变 filename 的所有者为 user
# chown user:group filename ### 改变 filename 的所有者为 user,组为 group
# chown -R root folder ### 改变 folder 文件夹及其子文件的所有者为 root
```
#### chmod
`chmod` 永远更改一个文件的权限,主要有 **读取** 、 **写入** 、 **执行** ,三种权限,其中 **所有者** 、 **用户组** 、 **其他** 各占三个,因此 `ls -l` 可以看到如下的信息
```
-rwxr--r-- 1 locez users 154 Aug 30 18:09 filename
```
其中 `r=read` , `w=write` , `x=execute`
```
# chmod +x filename ### 为 user ,group ,others 添加执行权限
# chmod -x filename ### 取消 user , group ,others 的执行权限
# chmod +w filename ### 为 user 添加写入权限
# chmod ugo=rwx filename ### 设置 user ,group ,others 具有 读取、写入、执行权限
# chmod ug=rw filename ### 设置 user ,group 添加 读取、写入权限
# chmod ugo=--- filename ### 取消所有权限
```
#### useradd
`useradd` 用于添加一个普通用户。
```
# useradd -m -g users -G audio -s /usr/bin/bash newuser
### -m 创建 home 目录, -g 所属的主组, -G 指定该用户在哪些附加组, -s 设定默认的 shell ,newuser 为新的用户名
```
#### passwd
`passwd` 用于改变用户登录密码。
```
$ passwd ### 不带参数更改当前用户密码
# passwd newuser ### 更改上述新建的 newuser 的用户密码
```
#### whereis
`whereis` 用于查找文件、手册等。
```
$ whereis bash
bash: /usr/bin/bash /etc/bash.bashrc /etc/bash.bash_logout /usr/share/man/man1/bash.1.gz /usr/share/info/bash.info.gz
$ whereis -b bash ### 仅查找 binary
bash: /usr/bin/bash /etc/bash.bashrc /etc/bash.bash_logout
$ whereis -m bash ### 仅查找 manual
bash: /usr/share/man/man1/bash.1.gz /usr/share/info/bash.info.gz
```
#### find
`find` 也用于查找文件,但更为强大,支持正则,并且可将查找结果传递到其他命令。
```
$ find . -name PATTERN ### 从当前目录查找符合 PATTERN 的文件
$ find /home -name PATTERN -exec ls -l {} \; # 从 /home 文件查找所有符合 PATTERN 的文件,并交由 ls 输出详细信息
```
#### wget
`wget` 是一个下载工具,简单强大。
```
$ wget -O newname.md https://github.com/LCTT/TranslateProject/blob/master/README.md ### 下载 README 文件并重命名为 newname.md
$ wget -c url ### 下载 url 并开启断点续传
```
恭喜你,你已经学习了完了26 个基础的 Linux 命令。虽然这里只是一些最基础的命令,但是熟练使用这些命令就踏出了你从一位 Linux 新手成为 Linux 玩家的第一步!
| 301 | Moved Permanently | null |
6,170 | 4 个开源的命令行邮件客户端 | http://opensource.com/life/15/8/top-4-open-source-command-line-email-clients | 2015-09-08T07:29:00 | [
"邮件",
"Mutt",
"Alpine"
] | https://linux.cn/article-6170-1.html | 
无论你承认与否,email并没有消亡。对那些对命令行至死不渝的 Linux 高级用户而言,离开 shell 转而使用传统的桌面或网页版邮件客户端并不适应。归根结底,命令行最善于处理文件,特别是文本文件,能使效率倍增。
幸运的是,也有不少的命令行邮件客户端,而它们的用户大都乐于帮助你入门并回答你使用中遇到的问题。但别说我没警告过你:一旦你完全掌握了其中一个客户端,你会发现很难回到基于图形界面的客户端!
要安装下述四个客户端中的任何一个是非常容易的;主要的 Linux 发行版的软件仓库中都提供此类软件,并可通过包管理器进行安装。你也可以在其它的操作系统中寻找并安装这类客户端,但我并未尝试过也没有相关的经验。
### Mutt
* [项目主页](http://www.mutt.org/)
* [源代码](http://dev.mutt.org/trac/)
* 授权协议: [GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
许多终端爱好者都听说过甚至熟悉 Mutt 和 Alpine, 他们已经存在多年。让我们先看看 Mutt。
Mutt 支持许多你所期望 email 系统支持的功能:会话,颜色区分,支持多语言,同时还有很多设置选项。它支持 POP3 和 IMAP 这两个主要的邮件传输协议,以及许多邮箱格式。自从1995年诞生以来, Mutt 就拥有了一个活跃的开发社区,但最近几年,新版本更多的关注于修复问题和安全更新而非提供新功能。这对大多数 Mutt 用户而言并无大碍,他们钟爱这样的界面,并支持此项目的口号:“所有邮件客户端都很烂,只是这个烂的没那么彻底。”
### Alpine
* [项目主页](http://www.washington.edu/alpine/)
* [源代码](http://www.washington.edu/alpine/acquire/)
* 授权协议: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0)
Alpine 是另一款知名的终端邮件客户端,它由华盛顿大学开发,设计初衷是作为一个开源的、支持 unicode 的 Pine (也来自华盛顿大学)的替代版本。
Alpine 不仅容易上手,还为高级用户提供了很多特性,它支持很多协议 —— IMAP, LDAP, NNTP, POP, SMTP 等,同时也支持不同的邮箱格式。Alpine 内置了一款名为 Pico 的可独立使用的简易文本编辑工具,但你也可以使用你常用的文本编辑器: vi, Emacs等。
尽管 Alpine 的升级并不频繁,不过有个名为 re-alpine 的分支为不同的开发者提供了开发此项目的机会。
Alpine 支持在屏幕上显示上下文帮助,但一些用户会喜欢 Mutt 式的独立说明手册,不过它们两个的文档都很完善。用户可以同时尝试 Mutt 和 Alpine,并由个人喜好作出决定,也可以尝试以下的几个新选择。
### Sup
* [项目主页](http://supmua.org/)
* [源代码](https://github.com/sup-heliotrope/sup)
* 授权协议: [GPLv2](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
Sup 是我们列表中能被称为“大容量邮件客户端”的二者之一。自称“为邮件较多的人设计的命令行客户端”,Sup 的目标是提供一个支持层次化设计并允许为会话添加标签进行简单整理的界面。
由于采用 Ruby 编写,Sup 能提供十分快速的搜索并能自动管理联系人列表,同时还允许自定义插件。对于使用 Gmail 作为网页邮件客户端的人们,这些功能都是耳熟能详的,这就使得 Sup 成为一种比较现代的命令行邮件管理方式。
### Notmuch
* [项目主页](http://notmuchmail.org/)
* [源代码](http://notmuchmail.org/releases/)
* 授权协议: [GPLv3](http://www.gnu.org/licenses/gpl.html)
"Sup? Notmuch." Notmuch 作为 Sup 的回应,最初只是重写了 Sup 的一小部分来提高性能。最终,这个项目逐渐变大并成为了一个独立的邮件客户端。
Notmuch 是一款相当精简的软件。它并不能独立的收发邮件,启用 Notmuch 的快速搜索功能的代码实际上是设计成一个程序可以调用的独立库。但这样的模块化设计也使得你能使用你最爱的工具进行写信,发信和收信,集中精力做好一件事情并有效浏览和管理你的邮件。
这个列表并不完整,还有很多 email 客户端,它们或许才是你的最佳选择。你喜欢什么客户端呢?
---
via: <http://opensource.com/life/15/8/top-4-open-source-command-line-email-clients>
作者:[Jason Baker](http://opensource.com/users/jason-baker) 译者:[KevinSJ](https://github.com/KevinSj) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,171 | FISH:Linux 下的一个智能易用的 Shell | http://www.ubuntugeek.com/fish-a-smart-and-user-friendly-command-line-shell-for-linux.html | 2015-09-09T08:46:00 | [
"shell",
"fish"
] | https://linux.cn/article-6171-1.html | FISH(friendly interactive shell)是一个用户友好的命令行 shell,主要是用来进行交互式使用。shell 就是一个用来执行其他程序的程序。

### FISH 特性
#### 自动建议
fish 会根据你的历史输入和补完来提供命令建议,就像一个网络浏览器一样。注意了,就是Netscape Navigator 4.0!

#### 漂亮的VGA 色彩
fish 原生支持 term256, 它就是一个终端技术的艺术国度。 你将可以拥有一个难以置信的、256 色的shell 来使用。
#### 理智的脚本
fish 是完全可以通过脚本控制的,而且它的语法又是那么的简单、干净,而且一致。你甚至不需要去重写。
#### 基于 web 的配置
对于少数能使用图形计算机的幸运儿, 你们可以在网页上配置你们自己的色彩方案,以及查看函数、变量和历史记录。
#### 帮助手册补全
其它的 shell 支持可配置的补全, 但是只有 fish 可以通过自动转换你安装好的 man 手册来实现补全功能。
#### 开箱即用
fish 将会通过 tab 补全和语法高亮使你非常愉快的使用shell, 同时不需要太多的学习或者配置。
### 在ubuntu 15.04 上安装FISH
打开终端,运行下列命令:
```
sudo apt-add-repository ppa:fish-shell/release-2
sudo apt-get update
sudo apt-get install fish
```
### 使用FISH
打开终端,运行下列命令来启动FISH:
```
fish
```
欢迎来到 fish,友好的交互式shell,输入指令 help 来了解怎么使用fish。
阅读[FISH 文档](http://fishshell.com/docs/current/index.html#introduction) ,掌握使用方法。
---
via: <http://www.ubuntugeek.com/fish-a-smart-and-user-friendly-command-line-shell-for-linux.html>
作者:[ruchi](http://www.ubuntugeek.com/author/ubuntufix) 译者:[oska874](https://github.com/oska874) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | # FISH – A smart and user-friendly command line shell for Linux
**Sponsored Link**
**FISH Features**
**Autosuggestions**
fish suggests commands as you type based on history and completions, just like a web browser. Watch out, Netscape Navigator 4.0!
**Glorious VGA Color**
fish natively supports term256, the state of the art in terminal technology. You'll have an astonishing 256 colors available for use!
**Sane Scripting**
fish is fully scriptable, and its syntax is simple, clean, and consistent. You'll never write esac again.
**Web Based configuration**
For those lucky few with a graphical computer, you can set your colors and view functions, variables, and history all from a web page.
**Man Page Completions**
Other shells support programmable completions, but only fish generates them automatically by parsing your installed man pages.
**Works Out Of The Box**
fish will delight you with features like tab completions and syntax highlighting that just work, with nothing new to learn or configure.
**Install FISH On ubuntu 15.04**
Open the terminal and run the following commands
sudo apt-add-repository ppa:fish-shell/release-2
sudo apt-get update
sudo apt-get install fish
**Using FISH**
Open the terminal and run the following command to start FISH
fish
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
Check [FISH Documentation](http://fishshell.com/docs/current/index.html#introduction) How to use. |
6,172 | 如何在 Ubuntu 15.04 下创建一个可供 Android/iOS 连接的 AP | http://www.linuxveda.com/2015/08/23/how-to-create-an-ap-in-ubuntu-15-04-to-connect-to-androidiphone/ | 2015-09-08T00:21:36 | [
"WIFI",
"AP"
] | https://linux.cn/article-6172-1.html | 
我成功地在 Ubuntu 15.04 下用 Gnome Network Manager 创建了一个无线AP热点。接下来我要分享一下我的步骤。请注意:你必须要有一个可以用来创建AP热点的无线网卡。如果你不知道如何确认它的话,在终端(Terminal)里输入`iw list`。
如果你没有安装`iw`的话, 在Ubuntu下你可以使用`sudo apt-get install iw`进行安装.
在你键入`iw list`之后, 查看“支持的接口模式”, 你应该会看到类似下面的条目中看到 AP:
```
Supported interface modes:
* IBSS
* managed
* AP
* AP/VLAN
* monitor
* mesh point
```
让我们一步步看:
1、 断开WIFI连接。使用有线网络接入你的笔记本。
2、 在顶栏面板里点击网络的图标 -> Edit Connections(编辑连接) -> 在弹出窗口里点击Add(新增)按钮。
3、 在下拉菜单内选择Wi-Fi。
4、 接下来:
a、 输入一个链接名 比如: Hotspot 1
b、 输入一个 SSID 比如: Hotspot 1
c、 选择模式(mode): Infrastructure (基础设施)
d、 设备 MAC 地址: 在下拉菜单里选择你的无线设备

5、 进入Wi-Fi安全选项卡,选择 WPA & WPA2 Personal 并且输入密码。 6、 进入IPv4设置选项卡,在Method(方法)下拉菜单里,选择Shared to other computers(共享至其他电脑)。

7、 进入IPv6选项卡,在Method(方法)里设置为忽略ignore (只有在你不使用IPv6的情况下这么做) 8、 点击 Save(保存) 按钮以保存配置。 9、 从 menu/dash 里打开Terminal。 10、 修改你刚刚使用 network settings 创建的连接。
使用 VIM 编辑器:
```
sudo vim /etc/NetworkManager/system-connections/Hotspot
```
或使用Gedit 编辑器:
```
gksu gedit /etc/NetworkManager/system-connections/Hotspot
```
把名字 Hotspot 用你在第4步里起的连接名替换掉。

a、 把 `mode=infrastructure` 改成 `mode=ap` 并且保存文件。 b、 一旦你保存了这个文件,你应该能在 Wifi 菜单里看到你刚刚建立的AP了。(如果没有的话请再顶栏里 关闭/打开 Wifi 选项一次)

11、你现在可以把你的设备连上Wifi了。已经过 Android 5.0的小米4测试。(下载了1GB的文件以测试速度与稳定性)
---
via: <http://www.linuxveda.com/2015/08/23/how-to-create-an-ap-in-ubuntu-15-04-to-connect-to-androidiphone/>
作者:[Sayantan Das](http://www.linuxveda.com/author/sayantan_das/) 译者:[jerryling315](https://github.com/jerryling315) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,175 | 请捐助伟大的 ESR 吧,让他能为这个世界继续奉献 | http://esr.ibiblio.org/?p=6835 | 2015-09-08T22:26:00 | [
"大教堂与集市",
"ESR"
] | https://linux.cn/article-6175-1.html | 
作为开源爱好者,你一定读过 [ESR(Eric S. Raymond)](http://esr.ibiblio.org/)的里程碑著作[《大教堂与集市》](http://www.catb.org/esr/writings/cathedral-bazaar),甚至在各种开源集会中多次见过他的身影。
上个月,ESR 在 [www.patreon.com](https://www.patreon.com/esr?ty=h) 上发起来一份[捐赠众筹](https://www.patreon.com/esr?ty=h),请求大家帮助他,让他能继续为互联网世界奉献。以下是他的众筹全文:
>
> Every time you use a Web browser, locate yourself on Google Maps, draw money from an ATM, or play on a game console, you rely on computer code I wrote and gave away.
>
>
> 每当你使用浏览器、在 Google 地图上定位、从 ATM 里面取钱、或者玩主机游戏时,你都用到了我编写和贡献的那些计算机代码。
>
>
> The Internet was built by people like me. We're still out there, patiently building things and fixing bugs and putting in our time to make sure your world keeps working. We're mostly volunteers, because there is no way to wrap a business model around the most essential services. We do what we do for love, and because software is our art - and because, in the Internet-dependent 21st century, we know civilization would be lost without us just as surely as if the roads and sewers and power grid stopped working.
>
>
> 互联网是由像我这样的人构建的。我们仍然在工作,耐心的建设、修复问题、花费我们的时间来让你的世界继续工作。我们大多是志愿者,因为没有办法将这些基础服务包装到一个商业模式上。我们为爱而工作,因为软件就是我们的艺术,也因为我们知道,在离不了互联网的21世纪,如果没有我们,文明就将不再,就像没有了道路、下水道和电网一样。
>
>
> It's hard to notice us, because we're not the people who write the programs you can easily see. Ours is the software behind the software - the programs and service libraries that paint pixels on your display, move bits along the wires, allow hardware to talk to other hardware. (For those of you more technically inclined, I'm talking about systems code rather than applications.)
>
>
> 你很难注意到我们,因为我们并非编写你常见程序的人。我们编写的是软件背后的软件——这些程序和服务库在你显示器上渲染像素、沿着电路移动字节、让硬件互相通讯。(说的更技术些,我这里说的是系统代码而不是应用。)
>
>
> Though I'm a techie, I'm in a situation similar to a fine artist because the market has not figured out how to value and reward the work I feel called to do. Unlike most artists, it wouldn't be difficult for me to get a well-paid job - but then I'd have to work on what an employer wants, rather than what the world actually needs.
>
>
> 虽然我是一个技术人员,但我现在的这种处境更像一位优秀的艺术家,因为市场上没有办法评估我的价值和奖励我做的事情。不像大多数艺术家,我要找一份收入不菲的工作并不困难——但是这样我就得为这份薪水而工作了,而不是真正在世界所需要的地方奉献自己。
>
>
> Pledge to me so I can keep delivering what the world actually needs.
>
>
> 请为我捐款吧,让我能继续为世界而奉献。
>
>
>
你可能会吃惊,ESR 这样伟大的人,怎么会面临生活困窘?
那是因为,奥巴马医改法案让他的妻子丢掉了全职工作及医保,另外,这个医改法案让个人健康保险费用涨到了“天上”。所以,他现在每个月要支出超过了按揭的费用。他每个月去看医生的费用就需要 $973,而这笔钱没有了着落。
如果你也愿意为我们的 ESR 捐赠一点——哪怕是 $1,那么请点此:<https://www.patreon.com/esr?ty=h> 。
截止到本文发稿时,ESR 已经达成了第一个里程碑 $500(购买测试装备来改进 NTP 互联网时间服务)。目前正在准备完成第二个里程碑 $973(每月医保支出) ,现在已经有110为捐赠者,每月达到了 $615 的捐赠。

在得到捐赠一个月之后,ESR 写了一篇[博文](http://esr.ibiblio.org/?p=6835),讲述了他是如何支配这些钱的:
>
> 在8月2号我去度假之前,我建立了一个捐赠众筹页。这件事的背景是我现在为 NTPsec 工作并获得了一些稳定的收入,但并不多。我的书的版税持续减少,而且我的妻子 Cathy 自从奥巴马医改法案使她失去她的全职的法律工作后,接手了所有她能接到的法律合同工作,但也收入甚微。另外,我们那辆开了八年的车也出了问题,修它的费用比它自身价值都贵得多,而房子也需要一个新的屋顶了,它看起来已经破得不行了。
>
>
> (没错,我们的确有一些储蓄跟股票。但是,不,我不想碰这些资金,因为我还不想到我真的老的时候得去领救助金过活,或者因为挨冻受饿而死。况且,即便这样子做不会跟我的价值观相冲突,但是指望2035年的美国政府能够让我有足够的钱来购买食物和住所的这种想法再愚蠢不过了。)
>
>
> 稍微使我惊讶的是,在一个月的捐献中,这个页面吸引了67个赞助者,总共捐赠409.17美元,我当初想不到能得到这么多捐赠,毕竟这个网站看起来完全是面向那些头戴贝雷帽、鼻子穿环的艺术家人群的。但它确实管用,一定程度上。
>
>
> 所有这些也是为什么现在我新发布的公告出现在 Patreon 上(基本上所有的),而不是博客上。这是我最接近艺术内容的东西了,而它也确实也增加了捐赠金额。
>
>
> 第一个月份的 Patreon 捐款只够让我给 Great Beast 装额外 32GB 内存,这是为了进行 GCC 的 Subversion-to-Git 转换的工作需要的。它解决不了多少(例如说)医疗保险问题,感谢那位专权的混蛋,不断地插手干涉把医疗费用搅得齐天高。(还因此牵连了我妻子的工作--这事件在心理上对她伤害不少)
>
>
> 如果你喜欢这个博客,请慷慨地捐赠吧。无论你以“娱乐”之名,还是以“支持 GNOME 的基础建设,让文明延续下去”之名,每个人的一点点帮忙能使我们走得更远。
>
>
>
| 200 | OK | I created a [Patreon page](https://www.patreon.com/esr) just before leaving for vacation on 2 Aug. The background to this is that while I’m now getting some regular bucks for working on NTPsec, it’s not a lot. Royalties from my books have been dwindling and my wife Cathy isn’t making all that much from legal contract gigs that are all she can get since Obamacare costs killed her full-time law job. Add the fact that our eight-year-old car has developed problems that would cost more to fix than its book value, and the house needs a new roof, and it’s looking pretty broke out.
(Yes, we do have some savings and stock. No, I don’t want to tap them, because thank you I do not want to be on the dole or dead of starvation and exposure when I’m really old. And, even if doing so weren’t in conflict with my values, counting on the U.S. government to be able to keep me in enough money for food and shelter in 2035 or so would be *deeply stupid*.)
Rather to my surprise, the page has attracted a whole 67 patrons and $409.17 in monthly pledges. I wasn’t actually expecting Patreon to yield that much, as it seems to be strongly oriented towards the beret-and-nose-ring crowd. It’ll help, some.
All this is by way of explaining why from now on my new-release announcements will probably be going to Patreon, mostly, rather than here on the blog. They’re the closest I have to the kind of artistic content releases the Patreon base seems to expect, and do seem to actually produce upticks in pledges.
My first month’s Patreon pledges will just about cover the additional 32GB of memory I dropped into the Great Beast in order to work on GCC’s Subversion-to-Git conversion. It’s not going to make much of a dent in (for example) medical insurance, thanks to the statist bastards who’ve driven health-care costs into the stratosphere through their incessant meddling. (They cost my wife her job, too – that’s been psychologically rough on her.)
If you enjoy this blog, please pledge generously. Whether you file the cost under “entertainment” or “keep an infrastructure gnome fed so your civilization will keep working”, a little help from each one of a lot of people can go a long way.
But haven’t you heard? Obama rescued the economy, and the recession has been over for
yearsnow!Seriously, good luck with the Patreon, but I’m still hoping for posts on Trump, the Hugo results, and the current status of Android/iOS….
I’m sorry things are tough, Eric. If I wasn’t broke I’d make a contribution because despite our political differences I’ve always been very impressed with your work in/writings on software. I hope you find some good paid consulting work and your wife gets a full-time job.
Raise your rates and *tell* people that that is because your health insurance rates when up. I’ve been looking for a job for the last 2 months (being picky because I am still working) and I am very explicit with recruiters–my rates are $X and hour because health insurance/health care cost me 8 dollars an hour, and that is now built directly into my costs. The more they can reduce those costs the less I’m willing make per hour.
People are shocked when I tell them what the “bronze” plan costs a family of 4 for insurance that has insane deductibles (it looks like they went up to 5k/person 10k/family) they are shocked.
And by “stock” I hope you really mean “widely diversified holdings in no-load mutual funds”.
Petro: It’s darkly ironic that one of the original arguments for Obamacare’s outlawing of inexpensive “junk insurance policies” was that many had deductibles that were “too high.” So now we’ve got
expensivepolicies with high deductibles that are too high….As I’ve said before, you’re one of the guys who has made my livelihood possible. I’m happy to chip in, and I posted the link to my FB account, where I have a lot of friends who work in the IT field and are likely to throw in a few more bucks.
A simple thank you for all you’ve done to help so many of us over the years.
No beret or nose ring here, but I do support about 58 people on Patreon with small donations. I’ve added you to my list!
Oops, it didn’t take my full name in the last post. Drat.
Glad to set aside a little for you there for all the years I’ve enjoyed this.
Don’t be too surprised by the amount of money you’ve managed to bring in through Patreon: My parents have been living entirely off of donations since before I was born: I was quite literally born on a fundraising trip and raised on donated money. The amount of effort you need to devote to fundraising to make a living that way is non-trivial, but is manageable.
Anyway, as I have, in previous comments here, advocated patronage as the business model that should be used for software development, I am putting my money where my mouth is.
Wouldn’t ICEI help support NTPsec? Or did that hit the skids too?
>Wouldn’t ICEI help support NTPsec? Or did that hit the skids too?
ICEI’s oxygen mostly got cut off wnen CII announced its existence. We’re still trying to recover from that.
Done. It ain’t much, but it’ll get you a cup of coffee once in awhile.
In the UK in theory we pay that ‘medical insurance’ direct to the government who pick up the bill for the entire medical system. Not sure that it is any better a model to cover the costs given it makes the country far too attractive to migrants, but my own income has just about been destroyed by the fact that third world countries can provide much of what we do without ANY of these overheads. Until the playing field is a lot flatter we are not going to get a fair share but at least this side of the pond when they kill off some of my income they also loose out on the tax :)
ICEI? CII?
>ICEI? CII?
ICEI = Internet Civil Engineering Institute, a nonprofit I was trying to bring up to raise funds for Internet infrastructure work. CII = Core Infrastructure Initiative, similar idea with lots of industry funding that launched with big fanfare as ICEI was preparing to go public.
Sad to hear your book royalties are dwindling – I think there are several good books worth of material in this blog and it does not require too much in the way of editing. Excerpts from best comments could be put into floating bubbles inside the text, that would make a cool, readable format. Think like this – your name is a brand name, it sells stuff. And books are probably the kind of stuff it sells best. It sells software too, it is just far harder to figure out how make people actually pay up for it.
Speaking engagements at LUGs and similar places? They dried up? Practically because you won? If yes, that would actually make an excellent book, to document how you won – not many people won causes as big as this. “How To Actually Change The World Like I Did” or something would make a bestseller.
>Speaking engagements at LUGs and similar places? They dried up?
I never charged anything but expenses for those. I felt it was important for my positioning that it not appear I was trying to milk profit from the movement I was then leading.
>“How To Actually Change The World Like I Did” or something would make a bestseller.
It’s an interesting thought, but the way I did it was so particularly tied to my idiosyncratic mix of skills and the contingent circumstances of history that I doubt I could teach anyone else to replicate it.
Which is not quite to say I have nothing to teach – some of my tools are more generally applicable. I have blogged about some of them.
“Towards Zero Defects Software” would be a nice book to read (based among others on your experience developing GPSD)…
>“Towards Zero Defects Software” would be a nice book to read (based among others on your experience developing GPSD)…
That’s more plausible, yes.
What about book about proper version control and DVCS migration?
The version control can be generalized so it is not tied with Git.
Add some patterns and antipatterns observed during project conversions.
A few reposurgeoun cleanup examples.
Hopefully the repo conversion becomes unnecessary soon, but proper repo cleanup will always be needed.
Would be nice to have ‘Zero Change Software’ so we can just get on using it rather than having to learn new user interfaces every few months. My phone is still hassling me to ‘use our new user experience’ but I’m happier with what I know ESPECIALLY hands free in the car!
> What about book about proper version control and DVCS migration?
> The version control can be generalized so it is not tied with Git.
> Add some patterns and antipatterns observed during project conversions.
> A few reposurgeoun cleanup examples.
> Hopefully the repo conversion becomes unnecessary soon, but proper repo cleanup will always be needed.
This project has the advantage that is at least partially written as “Understanding Version-Control Systems (DRAFT)”[1], which in turn was cited[2] in Eric Sink “Version Control by Example” book (available free online, published by Pyrenean Gold Press, available on Amazon).
[1]: http://www.catb.org/esr/writings/version-control/version-control.html
[2]: http://ericsink.com/vcbe/html/history_of_version_control.html
> What about book about proper version control and DVCS migration?
[the link-free version, while the 2-link version avaits moderation]
> The version control can be generalized so it is not tied with Git.
> Add some patterns and antipatterns observed during project conversions.
> A few reposurgeoun cleanup examples.
> Hopefully the repo conversion becomes unnecessary soon, but proper repo cleanup will always be needed.
This project has the advantage that is at least partially written by ESR as “Understanding Version-Control Systems (DRAFT)”, which in turn was cited by Eric Sink in his “Version Control by Example” book (available free online, published by Pyrenean Gold Press, available on Amazon).
I must admit, I did wonder how you kept yourself in bread – the work you’ve spent your life on is important, but never seemed to be long on compensation.
I’m too skint right now to chip in, but *insert statement of moral support here*.
Done.Details to follow (privately); an explanatory blog post and social media signal-boosting forthcoming shortly.
http://www.kiplingsociety.co.uk/poems_martha.htm
At least in the long run, Obamacare will decrease health-care costs and probably raise life span. Switzerland has had the same system for many years now, and has had lower health-care costs and higher life expectancy than the US for all the time we didn’t have it. (They’re also more urbanized, but still.)
@EMF
“Switzerland has had the same system for many years now,”
Not quite. The US has been able to take a straightforward system, like Switzerland, Canada, or many others, and has mangled into some devious system that combines the worst of all worlds.
http://www.nationalreview.com/article/362443/obamacare-worst-case-scenario-kevin-d-williamson
http://www.vox.com/2014/6/16/5812898/five-ways-the-american-health-care-system-is-literally-the-worst
I’m sorry your healthcare costs went up. On the other hand my diabetic cousin is now able to get insurance. Before, no insurance company would touch him with a 10 foot pole, leaving him one bad day away from bankruptcy and death.
I am sorry to intrude, but how does a medical insurance cost somebody a job? I ask genuinely because I don’t know about US politics all that much.
I am curious because I am presently working in an insurance company as a legal officer. I had to get a full-time job because my law practice wasn’t going as well as I hoped and I have monthly commitments to meet. :)
>I am sorry to intrude, but how does a medical insurance cost somebody a job?
The short version is that Obamacare mandates have added so much to an employer’s overhead for anyone full-time that the full-time job is being effectively abolished. Even professionals like lawyers are being fired to be replaced with contractors who have to buy their health insurance a la carte.
It’s a double whammy – first Obamacare destroys secure employment, then it saddles people living hand-to-mouth with ruinously high costs. Our health-insurance premiums are higher than our mortgage.
Congratulations on the patreon going well.
The beret-and-nose-ring crowd? Does this actually make sense? The beats and the popularity of modern piercing are some fifty years or more apart. There isn’t a single crowd, and
On the Roadwould be very different if the trip had been crowdfunded.I’m not sure what you had in mind by the “beret-and-nose-ring crowd”* — too arty? Too young? Too left-wing? For what it’s worth, one of my friends says he knows a bunch of stuff supported by patreons, and it’s typically pretty mainstream.
I don’t know whether you put off setting up a patreon (as distinct from not expecting much from it) because you thought it wasn’t for your kind of people, but if you did put it off, you might consider months when you could have been raising money.
In a previous post, you mentioned worrying about becoming mentally ossified. You’re in good shape for computer programming, but I think you’re missing out on what’s happening socially.
People who recommend that Eric pull together a best of Armed and Dangerous collection are probably underestimating the amount of work involved in editing that much material.
“Zero Defects Programming” might also be a place for a topic you’ve told me about but which I don’t think has turned up in your writing. You seem to be good at staying focused on the goal of a program, and I don’t get the impression this is universal among programmers.
*I’ve been thinking about the effects of vague insults like “puppy” and “literary science fiction”. It’s interesting to see how poor the quality of communication is.
>The beret-and-nose-ring crowd? Does this actually make sense?
Yes, it does. You haven’t been to Seattle recently, have you? A difference from the Beat era is that nowadays it is almost always women wearing the berets. Back in the 1950s it was mostly men, judging from the pictures.
>I’m not sure what you had in mind by the “beret-and-nose-ring crowd”* — too arty? Too young? Too left-wing?
Too arty. Look at the producer categories – they’re all arts and media except for “Science”, which I wedged myself under because everything else was a worse fit.
>I don’t know whether you put off setting up a patreon (as distinct from not expecting much from it) because you thought it wasn’t for your kind of people
Actually, nothing like that. I didn’t do Patreon because I was counting on Gittip/Gratipay for this – but it never worked very well, and eventually ran into some regulatory snafu that caused it to back out of supporting individuals.
>People who recommend that Eric pull together a best of Armed and Dangerous collection are probably underestimating the amount of work involved in editing that much material.
I fear so.
>“Zero Defects Programming” might also be a place for a topic you’ve told me about but which I don’t think has turned up in your writing
I did write a paper on GPSD as a case study in very-high-reliability software: http://www.aosabook.org/en/gpsd.html
>>The beats and the popularity of modern piercing are some fifty years or more apart.
Fallacious: assumes only beatniks wear berets.
>>It’s interesting to see how poor the quality of communication is.
Actually, I’ve found over the past two years that the quality of the communication on this site is far above most others that I visit. Even the comments, which is saying quite a bit.
>>I’ve been thinking about the effects of vague insults like “puppy” and “literary science fiction”.
The insults aren’t vague. They’re carefully chosen for their effect. A puppy is young and enthusiastic, but not necessarily overly bright or wise. Literary Science Fiction is covered in great detail in other posts.
As for their effects, they are *insults*. Their intent is to offend. Looks like they were sucessful.
While Patreon is an obvious match to things like comics or other clearly recurring events, I’ve wondered if it would be possible to be an open source developer on Patreon. It can be a surprisingly efficient aggregator for low amounts of money per month.
Probably the problem with trying to do that with ntp is that only companies care, and getting a company signed up to Patreon would probably be a trial. Something with a more plausible use case for “normal people” could probably do better. If you’re interested in minmaxing this a bit, you could consider also pledging some support for Battle for Wesnoth and seeing if some players might chip in. (I say this more in the spirit of rolling ideas around than necessarily a “suggestion”.)
Don’t apologize for supporting someone for only $1 or $2 a month… a few hundred people do that and soon you’re talking real money.
Obamacare is a massive sop to big insurance disguised as “doing something” about the health-care crisis.
And it’s really emblematic of the problem with America vs. The Entire Rest of the Fucking Planet: other civilized countries’ policies make a good-faith effort to solve the problem, while the American policy was authored by lobbyists to benefit the lobbying organizations and disguised with Bernays black magic to look like an effective solution to an unwitting populace even though it was engineered to be nothing of the sort.
In the case of health care, the solution the civilized world arrived at is cheap, easy, provides equal health outcomes regardless of SES and better health outcomes overall, and has been universally adopted (except of course in the USA): single payer.
Single-payer. Yeah, that’s the “solution” under which hospital patients die in agony of dehydration because the government employees can’t be arsed to bring them a drink of water when they’ve been pleading for days (England’s NHS). When the government employees
arepaying attention, they covertly instititionalize involuntary euthanasia to pull down costs (the Netherlands). Or you get hospitals choked with filth and feces, where the only thing not in short supply is cockroaches the size of your hand (Cuba).No matter how bad the results of government intervention are, more intervention can be counted on to make things worse. Health care illustrates this in particularly gruesome fashion.
Young intellectual counterculturalists today are often called by the same moniker as young intellectual counterculturalists of the Beat era: hipsters. The reasons why are not coincidental, as the latter are often engaged in a game of NLP-esque cargo cult mimicry of the former, in the romantic hope of reviving a more authentic past.
I believe this is rooted in a sort of reactionary disdain for post-1980s high-tech modernity and that Patrick Farley’s comic “The Guy I Almost Was” is good expository material for the phenomenon.
Sorry, switch “former” and “latter” in the above. I know that “aging hipster” is a stereotype but I’ve yet to see any geriatrics who were active in the Beat era hold forth on which was better: Nirvana before
Nevermindor after.Maybe that’s just because I don’t read enough
Rolling Stonethough…>At least in the long run, Obamacare will decrease health-care costs and
> probably raise life span.
That is such BS. It’s not happening, prices are going up, insurance rates are STILL going up, people have *less* access to doctors–one of the common complaints here is that the medical care networks are fracturing, and people can’t use the doctors they did before. Health care is *NOT* a commodity. Doctors are as much or more “hackers” than programmers. Bad ones are hard to distinguish from good ones until you see their work, and by then it’s often too late. Great ones are *INCREDIBLY* useful, but everyone wants them.
The “Bronze” health insurance plan (the cheapest one on the Exchange, and the minimum that private insurance companies can offer (except under certain narrow conditions) has NO HEALTH CARE IN IT. You get *ONE* “preventative” visit a year, and everything else up to the deductible (a few thousand dollars per person) is paid out of pocket.
How does that make health care better?
> Switzerland has had the same system for many years now, and has had lower
> health-care costs and higher life expectancy than the US for all the time we
> didn’t have it. (They’re also more urbanized, but still.)
http://www.forbes.com/sites/peterubel/2014/04/18/the-real-health-care-subsidy-problem/
They’re also a very tight and (relative to the rest of Europe and the US) homogenous culture.
Switzerland has about 8 million people +/-. You know what we call 8 million people in the US? New York City. Or, for slightly more than 8m “The Chicago Metro Area”.
Freaken COOK COUNTY Illinois has *almost* that many people (5+ million) in an area you could (if you were in shape) walk across in 24 hours. Looking at the demographics of Switerland, I had more diverse barracks in the freaken military.
When the dominate culture is northern-european, and you’ve got a small (relatively) number of people in a small (relatively) geographic area to take care of, certain socialistic policies have a reasonable chance of working–when the dominate culture says “don’t be a lazy schmuck” and when lazy schmucks become social outcasts, well, people don’t want to be that.
You simply can’t look at the little flyspec european countries actions since the end of WWII and compare them to what happens in the US. Switzerland, size wise, falls somewhere between Maryland (42nd) and West Virginia (41st) in size.
Of course, that culture is changing, their immigration rate from non-european countries is going up. Get back to me on how they’re doing when over 10% of their population is not of European Christian descent (This isn’t about race, it’s about *culture*. Watch).
I’ve worked in Health Care in the US, and our two biggest problems in health care boil down to refusal to adhere to doctors orders. This comes from (a) directly not following them (take these pills EVERY DAY/Until they’re all gone, exercise, don’t eat crap) or (b) following stupid, unscientific, fraudulent advice from the likes of Dr. Oz and his criminally negligent guests. (See sciencebasedmedicine.org) You *routinely* hear people in the US bemoaning that “Doctors don’t know shit” as they shovel a Denny’s Grand Slam into their mouth in-between insulin injections. You’re just not going to get good medical outcomes NO MATTER HOW MUCH YOU SPEND if you don’t have good science and good compliance.
Switzerland, Canada, and the Netherlands (to name a few) are basically the sociological equivalent of middle and upper middle class America demographically. The simple don’t have the same percentages of urban and fringe-rural poor (those who have the worst compliance and are the most suspicious of and resistant to good health care practices).
Jeff Read: In the UK it turns out the single payer only pays if you’re willing to wait for months in agony for your operation. If not, you dip into your savings.
DysgraphicProgrammer on 2015-09-02 at 11:15:27 said:
> I’m sorry your healthcare costs went up. On the other hand my diabetic cousin is
> now able to get insurance. Before, no insurance company would touch him with a
> 10 foot pole, leaving him one bad day away from bankruptcy and death.
Well, if my 8 year old breaks a leg or gets Leukemia I’ll tell her that it’s just too bad we can’t afford to get it fixed properly because Daddy–who has paid for his OWN damn health insurance since he was 18, was priced out of the market because the best and the brightest people in the US could find only ONE way to get people the health INSURANCE they needed.
Yeah, your cousin can get his health insurance, but I *can’t* because people like Jeff Read really, really want their government to run EVERY part of our lives, and won’t let us make our own contracts. No, it’s got to be SINGLE PAYER or we’re “uncivilized”.
Fucking hell I have to pay $0.80/month in VAT to the British government for the privilege of encouraging you to write about why I shouldn’t have to pay tax! You’d better deliver, Raymond!
Only because in America the path to the OR is greased with cold hard cash.
The NHS is still a vast improvement over American style private insurance. Months in agony is better than the death sentence you would receive for the crime of being poor and sick in America. The Guardian and other British publications are full of stories aimed at NHS critics of the form “it could be worse… we could have (dun dun dun!) the American healthcare system.”
Fun fact: in Canada life expectancy is uniformly into the early 80s for the entire population. In the USA, life expectancy is a function of wealth; only the richest Americans ever achieve Canada’s life expectancy.
What gets me is that pretty much everyone has abandoned the idea that “single-payer” is the best way to provide food, clothing, housing, manufactured goods, education, or pretty much anything other than health care. What makes health care so special that it avoids the catastrophes that “single-payer” created in all those other areas? If the response is: “But medicine can cost too much when you have cancer” (or whatever), you’ve already lost half the argument, because much of health care is not that expensive: check-ups, birth control, etc. The entire single-payer argument is based on obsolete 20th century thinking: “Just centralize it all under the federal government, and it will work fairly and efficiently.” As it turns out, no, it does not.
Jeff Read: Demographics explain much of those differences between the US and Canada.
So say Rick Santorum, Breitbart, the Daily Fail, and other right-wing sources. The actual statistics say otherwise: http://www.washingtonpost.com/blogs/fact-checker/post/euthanasia-in-the-netherlands-rick-santorums-bogus-statistics/2012/02/21/gIQAJaRbSR_blog.html
>The actual statistics say otherwise:
You misspelled “A notoriously left-wing source says otherwise”. I am unimpressed. I’ve seen the pictures of the Cuban filth and cockroaches; there’s your single-payer utopia, right there.
James Noyes, I meant that the quality of communication when people use vague insults is poor, not that the quality of communication on this site is generally poor or has become worse. I suppose this is an example of what I was talking about.
Eric, my apologies– I didn’t realize berets and nose-rings had become a thing in Seattle.
>Eric, my apologies– I didn’t realize berets and nose-rings had become a thing in Seattle.
And a lot of college towns, even off the coasts. You could go to any coffee shop in Ann Arbor or Austin and you’d see hipsters ironically wearing what they take to be Beat garb. Well, except their Beat prototypes didn’t do nose rings.
Heh. And it was supposed to be me that was “missing out on what’s happening socially”. No blame attaches; I travel more than you do and I think I spend proportionally more time around twentysomethings, like at FOSSCON 2015 in Philadelphia a couple weeks ago.
This can have some entertaining effects. One of the local hackerspaces was exhibiting a silly project named Clyde, a “robot” that looked like Irwin Allen’s idea of a computer and gave (actually random) yes/no answers to questions spoken into a microphone, in a cheesy Robby-the-Robot voice.
Hackerspace people: all twentysomething geeks, very clean-cut and earnest, mostly doing a pretty good job of hiding how impressed they were to have “ESR” sitting on the couch in their hangout space.
So, the game was, the hackerspace people would jokingly try to convince those who wandered in that the robot had real AI in it. Why not join the fun? So to one of the bemused passers-by asking what Robbie could do, I said, very straight-faced “Just don’t ask him about tomorrow’s sport scores; his hyperspatial prognosticator is on the fritz.”
One of the hackerspace kids looks at me and says, sounding a bit surprised, “He fits right in…”
And the tone of surprise was just a little irritating, so I gave him my most disarming grin and said “Dude. I designed your culture”
He looked thunderstruck for a moment, recovered gamely, and said “Fair enough!”
That there is a lot of miss information is a simple fact. There are rotten apples everywhere and as soon as they are identified one would like to think they are dealt with appropriately? Perhaps the ‘need’ to keep changing things is all pervasive? Just how many laws do you need to change each year and how many are changed just to justify having politicians? One countries practices are simply not suitable for another, but with all the migration more and more people seem to think they can force their views on the majority and impractical compromises inevitably result. How often nowadays are changes pushed through which ARE stupid, but are the only way to get the main business accepted? Not sure if a ‘clear majority’ as the current UK government is any better than compromise with a coalition … I simply don’t trust any politician to do the right thing :)
Bet it chuffed you nearly as much to drop that bomb as did “I’m your worst nightmare” on that Microsoftie in the elevator…
Current status is, under US law Android is stolen tech.
Rumor has it that Google has super-seekrit internal builds of Android with an all-new native-code runtime (i.e., not ART) and a different C++ API. By about the time Necco Wafer or Oreo gets released, they will probably be forced to deploy it because of the copyright-infringement judgement against them, as well as pay billions in back royalties to Oracle.
And this is why most of the next generation’s software leaders will not be from the USA.
I wasn’t intending to taunt esr, but his predictions of a few years ago re the Android vs. iPhone have not happened, and I’m interested to hear what he has to say about the topic these days. There was supposed to be a market share tipping point, and Apple’s closed-code approach would fall to the “Android army.” But Android’s market share seem to have stopped increasing, and even shrunk by some measures. And nobody besides Samsung seems to be making much money from it, and even Samsung isn’t doing too great these days.
I don’t get ideological objections to things that, in practice, work pretty well.
In practice, single-payer in Canada works very well. One indicator is that you’d find very, very few people who would trade it for what we see down south. There are private clinics around if you want them, but the middle classes don’t go there. Just sports figures, politicians and the wealthy.
And yes, there are waitlists, but these are triaged and prioritized. It’s manageable.
Yes, you’ll see stories about the poor lady who didn’t want to wait six months for a hip replacement and so headed down to the Mayo Clinic, but these are pretty rare. (We call these “whiners”) Last time I got an MRI, I was told the wait would be two months. It was not urgent, so that was okay. (Turns out I got in due to a cancellation in a few days) Emergency cases do not generally wait.
The doctors don’t make as much money. It’s good money, but not rock-star money. Most seem okay with that. Some head down south.
The real downside is taxes. They’re too damned high. (only partly due to Medicare)
But I can change jobs without worrying about my kids pre-existing conditions. We can worry about my dad’s cancer rather than his medical bills. That’s pretty nice.
>One indicator is that you’d find very, very few people who would trade it for what we see down south.
By report, this is not true. Canadians with serious illnesses are notoriously prone to book to the U.S. if they can afford to do it.
Let me point out the Association of American Physicians and Surgeons at http://www.aapsonline.org/ .
This is a group of doctors who practice on contract, with (usually) a monthly subscription fee: — what are sometimes called “concierge practices.” They tend to be conservativish politically, I think, although some practice “alternative” medicine as well as Western Conventional (if I may so call it). They are certainly against (at least most) governmental involvement in health care, and have been since the organization was founded in 1943.
They aim to make their living by providing the best care at the least cost.
Here is the current lead posting on the site:
There’s also a link for interested doctors there.
See also the “About” page: http://www.aapsonline.org/index.php/about_us/ . This page has full contact information, as well as a “mission statement” and other info.
I discovered them while UT-surfing. Their “Thrive Not Just Survive” series of videos is intended for docs, but gives a good feel for the project to us laymen (prospective patients). Select “Resources” in the menu across the top, and “Video” on the (voluminous) “Resources” page.
To see what may be available in your state, visit the link above. Page introduction:
I don’t get ideological objections to things that, in practice, work pretty well. In practice, single-payer in Canada works very well.It’s important to note that you’re not getting an ideological objection here. It’s contingent. People who oppose single-payer don’t simply have some niggling urge to oppose the government. If single payer really did work, a lot of people would be all for it.
It’s just that it doesn’t actually work that well, when one looks closely. (Unless by “works well”, you mean “feels simple and unobtrusive so long as I’m willing to wait a long time for care”. For most Canadians, as for most people in general, particularly younger people, it wouldn’t surprise me if that were satisfactory.)
What’s your complaint about single-payer? It’s cheaper and seems to lead to better life expectancy, especially for the poor. Also see Iconoclast’s point about waitlists being triaged, so that if you can’t wait, you won’t have to. And if you can wait, you should, so that those who can’t will get in first.
>It’s cheaper and seems to lead to better life expectancy, especially for the poor.
My complaint is that I don’t believe either of those claims.
You have to be very careful about comparing international life-expectancy statistics. Comparisons with the U.S. are badly skewed by a difference in reporting practices; neonatal deaths that are filed under “infant mortality” here are often not counted in other jurisdictions.
“Dude. I designed your culture”LOL. Eric for the win!
The Australian version of single-payer keeps victims on the waiting list for a waiting list slot until they die there and are no longer cluttering up the government’s statistics.
“If you can’t wait, you won’t have to” is aspirational – assuming that $IDEALISED_POLITICIAN is in charge, has a solid legislative coalition at his back giving him a free hand, has unlimited budget to live the dream, is glorious leader of an adequate-sized army of fanatically loyal bureaucrats, and will never make serious policy mistakes.
“If you elect us, we promise to at least try to make the waiting lists look shorter” is where the electoral discourse has actually gotten to:
https://www.qld.gov.au/health/services/hospital-care/waiting-lists/
Note they don’t define “elective surgery” as “you could do without it, if you can wait, you should, so that those who can’t will get in first”. They define elective surgery as “planned surgery that can be booked in advance.” If failing to get to the head of the Category 3 waiting list for your elective surgery in time will kill you, well, more room for the rest of us.
The government department that defines that categories is the same one that is accountable for the waiting list statistics.
So, I’ve been covered by private health insurance since I was old enough to afford it. Public policy here is that everyone who can be, should. They don’t have to mandate community rating or online exchanges to make this happen. They just have to make it not illegal for people with cash to buy their own insurance, and make the purchase a tax-advantageous move.
@esr
“they covertly instititionalize involuntary euthanasia to pull down costs (the Netherlands). ”
So you get to the point that you accuse us from murdering people to stay on the cheap. Last time this discussion went on, you still denied that.
You should know better, especially as this accusation has come up on this very blog and you participated. The article Jeff linked to in the Washington post is accurate.
This is the same type of thing as abortion. When it becomes legal, the rate often reduces from the previous illegal practice. The same with euthanasia. Euthanasia does happen in the USA too. There it is disguised as palliative care, but that just means terminal patients are brought into a drug induced coma and are then let to die. An overdose of morphine does not really kill you, so they have to stop giving you liquid or food or do something else that will make the breathing stop. It happens in the USA too.
Patients are desperate and medical practitioners want to help. By making it illegal, patients and doctors have to resort to sub-optimal solutions which often increase suffering.
For the rest, our health care system, and that of the Germans and British and French, works pretty well. The Dutch system is on the expensive side, but we manage. It does not matter much how you organize it. What matters is that you organize it around getting people the health care they need.
The US discussions never are about how everyone can get the health care they need. It is always only about the rules and regulations. And so they created a monster.
If it were not such a sad thing, it would be funny that with all their might the US were unable to create a system that could even match that of either of their neighbors to the north and south.
>Last time this discussion went on, you still denied that.
Correct. Now I think I have better information. When the evidence changes, I change my mind.
>Patients are desperate and medical practitioners want to help. By making it illegal, patients and doctors have to resort to sub-optimal solutions which often increase suffering.
Apples and oranges. I’m not one of those who thinks abortion should be illegal; nor do I think doctor-assisted suicide should be illegal. Government-run hospitals witholding care to hold down terminal-patient costs is a completely different issue; I find reports of it credible because the incentives in a single-payer system favor that behavior.
If patients are paying for their own care, they are revenue sources and the hospital’s incentive will be to keep them alive as long as possible. If their care is being paid out of a fixed pot of single-payer funds, killing them is revenue-neutral and may even feel justified as a way of redirecting rivalrous resources to where they might save a less ill patient.
The pre-existing condition thing is a bit overhyped about the US system. There was already rules in place that if you had coverage in the 6 months before you get your current job, that the pre-existing conditions were covered. Changing jobs is no problem. It’s only people who were completely uninsured while the condition was found that would have a problem. Those things were eventually covered after a year iirc.
Of course most people who have it wouldn’t trade away single-payer health care. Most people are healthy, and single-payer healthcare is well-designed to make healthy people happy, by bundling all the bills for their routine health care (or the expensive care for their sick relatives) in the tax bill. Which is then hidden from them reasonably well by being taken up by paycheck withholding and in the sticker price of goods charged VAT. That you have to wait longer for, say, modern diagnostic tests (Canada had one-third as many MRI units per capita as the US in 2007, which was still only two-thirds the number per-capita that the US had in 1995) doesn’t intrude much; you undergo the test when it’s scheduled, after all, without much idea of how much faster it would be if there were more machines. If you die because you go undiagnosed because your symptoms weren’t acute enough to get you even scheduled for a test on the fewer available machines, well, hey, you’re not a voter anymore, unlike the uninsured guy in the US who got a fat bill for it. How many of your relatives are, as a result of your death, going to start a crusade for replacing single-payer with a system that will charge them for office visits but increase the number of MRI machines?
Yes, yes, you can argue all day over specific questions of the efficient rate of testing, and whether overtesting then gets you iatrogenic troubles as a result, etc. The point is Bastiat’s seen versus unseen; single-payer’s costs tend to accumulate in the realm of the unseen, which is not the same as being costless.
Ah, you say! But if the hidden costs really were at the expense of health, it would show up in the life expectancy!
Well, yes, if life expectancy is a monotonic function of health care quality without any confounding factors.
It’s pretty hard to blame the US health system for the far higher annual per capita rate of fatal car accidents in the US than in the Netherlands, after all (though some people will try). And somebody dying at age 20 instead of 80 on the scene of a car accident depresses life expectancy stats more than you improve it by your superior system saving the lives of ten people at age 75 who go on to live to 80. And setting aside that sort of thing, there’s no monotonicity, either. If a premature infant is born at a hospital where there is no medical technology sufficient to keep it alive, it goes into the books as born non-viable and isn’t counted in life expectancy stats (or infant mortality, for that matter). If it’s born at a hospital where it can be saved with a 50-50 chance, and then succumbs after a week, it goes into the life expectancy stats as a death after seven days of life — and now your better system (since it sends home half of those kids alive instead all of them to the grave) will have to save forty 75 year-olds for age 80 to break even on the life expectancy you lost because you had the ability to try to save the premature baby.
But, of course, while you can point out all the potential confounders of the numbers, how does one go about making the numbers rigorous enough across whole-population studies of multiple countries to actually reach a reasonably-hard number that can tell you about relative quality of health care systems?
With the available data, one can’t. Nobody’s even tried to fund the studies to do it. So it’s perfectly possible to look fairly at the data and conclude that the rest of the industrialized world produces better outcomes from equivalent input, on average, than the US. It’s just that anyone who refuses to grant that a fair look can result in the opposite conclusion is blinded by some combination of ignorance and ideology.
Austria reporting in: most doctors run parallel public and private practices, so I can get a tax-paid appointment in two months advance, or pay out of my pocket about €100 for a 45 min visit and get one in three days. This is a very simple cash fee paid directly to the doctor, avoiding the US type insurance bureaucracy nightmare.
Overally the public part of it sucks, I mean the waiting lists. Although my wife’s childbirth experience was very good, I guess that is a smart move, one way to fight dropping demographics is investing money into making childbirth safer and less of a nightmare. Every mother got a private room with full complete equipment, oxygen to epidural, and a team of one doc and two midwives. That was pretty impressive for me. Other than the positive birth experience, the public part is all waiting lists, overcrowded emergency rooms and hurried, rude doctors.
But I wonder if the public part plays a role in keeping the private part fairly cheap, so that doctors have to keep their prices competitive, by competing with “free” ?
I don’t really understand the economics of it all really well. I try not to use the public part of it, but I do think the public part helps in keeping the cash paid, not-insurance-based private part kinda cheap.
Thankfully, they let private entrepreneurs in the public part as well, which makes it far more bearable. There is one thing I love about Austrian healthcare that is so different from e.g. the UK is that there is no puritan spirit. There is a bar right in the center of our local hospital, the Donauspital, with booze and pizza. http://www.herold.at/FS/picture/6/7/2/2520276.jpg After my daughter was born and she and her mom fell asleep around 06:00 I was doing beer and jäger in this hospital bar / cafe, calling my relatives. It felt a bit surreal. Also, there is a hairdresser, beauty salon etc. so hospitalized people basically feel like they are in a mall, having a good time, not in some puritan monastery. And all these are of course private entrepreneurs renting space, so they actually reduce the taxpayers bill. I was completely dumbfounded. Why doesn’t all of Europe do this? Especially back home in Hungary, we are generally considered a partying type of people and yet the only accepted behaviour in hospitals is, apparently, suffering in silence and consuming unappetizing health-food. Smuggling in a beer would be a scandal. Monastery spirit, puritanical spirit, a place to atone for your sins… and it would cost nothing to the government to change it, in fact it would bring a revenue, just let entrepreneur rent hospital floor space and the rest would be sorted out by the market.
@esr
“Correct. Now I think I have better information. When the evidence changes, I change my mind.”
I would really like to see that evidence.
What I generally see in the US is a complete lack of any understanding of how the systems outside the USA work. Like that hyped “death panels” in Canada.
http://www.slate.com/articles/news_and_politics/jurisprudence/2013/10/canada_has_death_panels_and_that_s_a_good_thing.html
The Netherlands is no different, ignorance rules in the USA about our euthanasia system.
The discussion about how much an extra month of life is worth rages periodically through Dutch politics. No one wants to touch it. As a result, doctors do not touch it too. Given the strict regulations for euthanasia, which include involving OTHER people, no institution will even contemplate using euthanasia to get rid of patients. And thus we see a very small number of euthanasia requests.
So, what problems we have in our health care system do not include too much euthanasia. Actually, the complaint is that it is much too difficult to get euthanasia when you really want it.
Btw, when you cannot get a treatment in the Netherlands in time, you are allowed to go abroad and get refunded.
If patients are paying for their own care, they are revenue sources and the hospital’s incentive will be to keep them alive as long as possible. If their care is being paid out of a fixed pot of single-payer funds, killing them is revenue-neutral and may even feel justified as a way of redirecting rivalrous resources to where they might save a less ill patient
In the UK this is probably the most messy area? Legally euthanasia is blocked preventing a few small number of people who know they are going to become unable to do anything themselves and be reliant on machines to make a choice. If they have money they can go abroad but have to do that before they NEED to, but if they stay in the UK then it may be more ethical not to keep a shell alive.
A slightly more difficult one in my book is the VAST sums of monies drug companies charge for some treatments many of which are developments of work our charity sector have funded when they were not ‘economically viable’. Why should someone who has money get a few more weeks/months when someone who may well have contributed to that research all their lives is denied it because they can’t afford it? ebola is probably a good example of why the whole system is broken, and while yes drug companies have to make money when does profit become excessive?
On the American model currently just how much money goes to ‘caring for health’ and how much to enhancing the bottom line? The problem perhaps is one of just what ‘acceptable profit’ is built into the system and when you compare between countries with different practices this messes up the picture?
( HOW DO YOU ADD A QUOTE? The first paragraph was ‘quoted’ )
Contributed to that research all their lives. Well. Partially.
http://blogs.sciencemag.org/pipeline/archives/2009/07/31/where_drugs_come_from_and_how_once_more_with_a_roll_of_the_eyes
*pauses for moderation*
@Lester Caine –
Easiest way to do quotes is with “<blockquote>” and “</blockquote>” tags. Results like this:
AH – I’d used “” tags … every system is different :)
A waiting list is called “scarcity”. Centrally managed health care causes scarcity. The only thing keeping any of these government programs going in any of the countries mentioned above is central bank printing presses. As I’ve said to unwilling ears too many times, the problem with healthcare run by Washington DC is that you’re talking about 340 million people run out of the most corrupt and crooked city in America. When people talk about Sweden healthcare, they’re ought to be talking about Connecticut. When people talk about Netherlands they should be referring to Iowa. But no, we hear constant references to how things are going “well, perhaps OK, it kinda works” – which is in and of itself and admission that things are not very good and we then project that onto a nation that is an order of magnitude larger than said “meh healthcare” country. Why do technical people here not think about the SCALE of the problem. Healthcare in the US is going to be the next USSR food lines. Because of the sheer scale of the problem, no central government can possibly manage it. Yes, I too am now an independent consultant and contractor with doubled healthcare costs.
If patients are paying for their own care, they are revenue sources and the hospital’s incentive will be to keep them sick as long as possible (or at least prescribe expensive, unnecessary diagnostics and treatments). If their care is being paid out of a fixed pot of single-payer funds, healing them is revenue-neutral and the hospital is incentivized to do so efficiently as a way of redirecting rivalrous resources to where they might save a more ill patient.
Seriously, Eric, go back and read Arrow’s 1963 paper on why health care is not a market good. And while you’re at it, peep some statistics on the actual health outcomes of single payer vs. American style privately funded.
You can start here: http://www.commonwealthfund.org/publications/fund-reports/2014/jun/mirror-mirror
This is consistent with just about everyone else who’s bothered to gather statistics on this issue, and not first run it through a right-wing spin machine. Americans pay more for far lower quality care than do Europeans or Canadians.
What about this is so hard to understand?
@Jeff
“What about this is so hard to understand?”
I suspect that the main pain point that prevents understanding that it implies that government intervention can be effective, and more efficient than the market.
When I read US publications, that statement seems to be like saying that water can run uphill.
And admitting the US is worse performing than any other country in anything seems to be a problem, in general.
> The short version is that Obamacare mandates have added so much to an employer’s overhead for anyone full-time that the full-time job is being effectively abolished.
OK, got it.
“By report, this is not true. Canadians with serious illnesses are notoriously prone to book to the U.S. if they can afford to do it.”
Yep. Hockey players, certain politicians, and the very wealthy. Anyone who doesn’t need insurance in the first place. You’ll hear more about them in the corporate press, of course, because single-payer is the socialist boogeyman. Who else could afford it?
I do hear about people running across the border for MRIs or CAT scans sometimes. For a couple hundred bucks you can save a few months wait. That’s a reasonable cost-benefit tradeoff. If there is a backlog here, they will sometimes pay to send people across the border. That’s just good overflow handling.
Then there are the folks with the sob stories who need a $50k/month experimental drug treatment for some rare dread disease. Sorry, not happening. But for nearly everyone else, I think most would agree we have it pretty good.
BTW, what we have here is actually a hybrid system outside of the hospitals. Doctors run their own practices; all the imaging/bloodwork clinics outside of hospitals are privately run. But the rates are set and the bill goes to the Ministry of Health.
Anyway, Obamacare does seem to be the worst of both worlds. Good luck.
Iconoclast,
Have you ever looked at the parking lots of clinics/hospitals in International Falls or Buffalo? More Canadian plates than American ones. If Canada’s system is soooo superior, then why are they coming down here for treatment? The last time I went fishing up in Western Ontario in 2009, we stopped a gas station to fill up before crossing the border in International Falls. There was a medical clinic across the street that had 10 Canadian plates for every one Minnesota plate on the cars in the parking lot. I know because I went across the street and counted them.
>There was a medical clinic across the street that had 10 Canadian plates for every one Minnesota plate on the cars in the parking lot. I know because I went across the street and counted them.
Facts trump theory. Nobody got shot crossing the Berlin Wall from west to east. When people vote with their feet, believe the people, not apologists for statism like Winter and Jeff Read.
Lester,
Who determines when profit is “excessive?”
This implicitly assumes that handling new patient brings less revenue than prolonging care of an existing patient, and that there is no competition among doctors and hospitals, and medical groups.
Your reasoning, if transformed to e.g. taxi service would mean that each taxi driver would go as long as possible instead of straight to destination, isn’t it?
@ Jeff Read:
I just did, and it was fascinating. Skipping through most of the maths, what is it that Arrow himself proposes as the solution for this crisis of market inefficiency in medicine (emphasis mine)?
“Suppose, therefore,
a large agencyor the government stands ready to offer insurance against medical costs on an actuarially fair basis; … ”In other words, not single payer, but the sort of healthcare insurance market that has existed since the paper’s publication! (One might even argue Arrow ‘predicts’ the rise of HSAs and HMOs by noting that consumers are better served by pre-payment and multiple doctor conglomerates.) However, that wasn’t the part that had my attention. No, in fact it was where he defined what he considered “non-market” goods:
“The value of information is frequently not known in any meaningful sense to the buyer; if, indeed, he knew enough to measure the value of information, he would know the information itself. But information, in the form of skilled care, is precisely what is being bouight from most physicians, and, indeed, from most professionals. The elusive character of information as a commodity suggests that it departs considerably from the usual marketability assumptions about commodities.”
In other words, when you take your car to the mechanic, hire a tax professional or other accountant, architect, software programmer, or any other “knowledge worker”, you are trading in what Arrow has just declared a non-marketable good. I don’t know how to fix every problem with my car, so I must trust the person who does to be honest.
Funny though: automotive insurance covers liability for accidents, but not maintenance. In fact, I am not aware of any “automotive healthcare” insurance plans. I wonder why then that market is never declared a failure in the same manner as actual healthcare?
I’d like to say the general public … but the best example is perhaps the fiasco in the very system that invests those profits. Who trusts a bank these days yet they still feel perfectly entitled to take obscene bonuses out of the losses WE have had to cover.
Then is the price Microsoft and Apple charge justified given the amount of money they have sitting in those banks? Microsoft have wiped out most of my best business in the UK simply by demanding more money to replace perfectly functional XP systems and giving replacements for my systems free in the ‘deal’ to upgrade. THAT is another drain of funds from the NHS in the UK when perhaps we should have been writing contracts to require suppliers to FIX faulty and insecure systems?
Everybody expects their cut so as I asked – how much actually goes on the service.
“Have you ever looked at the parking lots of clinics/hospitals in International Falls or Buffalo? More Canadian plates than American ones. If Canada’s system is soooo superior, then why are they coming down here for treatment?”
Good question. Diagnostics? I don’t know. Plus, border towns have their own dynamics. Buffalo is larger and closer to the Niagara area than Toronto is. I don’t know Wisconsin, but Fort Frances (International Falls) appears to be the largest town between Thunder Bay and Kenora, a hundred miles or so each way. There is a whole lotta nuttin out there.
And I didn’t say it was “sooo superior”… I said it was good enough.
I misread the map… Fort Frances is the small town on the CDN side. International Falls is the much larger US side. And I didn’t mean to say Buffalo was bigger than Toronto, but bigger than anything around Niagara.
@Alex K
BMW and other luxury brands have prepaid maintenance bundled into the price.
@esr
“When people vote with their feet, believe the people, not apologists for statism like Winter and Jeff Read.”
Then we would need the numbers of (poor) US citizens trying to get health care in Canada.
The point has never been that the US can deliver the best quality health care money can buy. The point was always what happens when you do not have the money to buy this care?
How many people in the US were not or under insured?
The study that has been linked several times already shows that US citizens do not get value for money, far from it. And they leave out far to many people already. Medical costs are the main cause of private bankruptcy.
>Then we would need the numbers of (poor) US citizens trying to get health care in Canada.
Can’t be done at all, not without identity theft. There’s a limited exception for hospital emergency room visits.
>Medical costs are the main cause of private bankruptcy.
No, they aren’t. Elizabeth Warren got famous by making this claim but her methodology was shoddy, designed to sweep in people who had medical costs as an incidental rather than primary financial problem. Later studies making similar claims mistook correlation for causation. When you reexamine that data it turns out not to support the conclusion. See for example
http://content.healthaffairs.org/content/25/2/w74.full
“A reexamination of their data suggests that medical bills are a contributing factor in just 17 percent of personal bankruptcies and that those affected tend to have incomes closer to poverty level than to middle class.”
The pattern of errors seems eerily familiar to me from experience with bogus studies on firearms policy.
@Bob
I didn’t know that; however, if full-maintenance plans for automobiles are restricted to the luxury brands, what does that analogy imply about the promises of universal healthcare?
If customers are paying for their own food, they are revenue sources and the restaurant’s incentive will be to keep them hungry as long as possible (or at least suggest expensive, unnecessary dishes)….
Eric,
Indeed, so why do you pound the theory when the facts say you’re wrong?
Once again, the people who actually run the numbers say that Canadians seeking health care in the USA constotute a near-infinitesimal minority, and it is usually for exotic treatments that are available in the USA but not yet in Canada:
http://m.content.healthaffairs.org/content/21/3/19.full
But I’m sure you’ll introduce a “liberal bias” epicycle or some such, to correct the facts to fit your theory.
>Indeed, so why do you pound the theory when the facts say you’re wrong?
Canadian license plates commonly outnumbering U.S. ones in clinics near the border is a fact, not a theory.
>usually for exotic treatments that are available in the USA but not yet in Canada:
Let’s suppose this is true. Now actually think about what it implies, if you are capable.
Yesterday I dropped off some books at the library and encountered a man sitting behind a card table badgering people to sign a petition “to make universal healthcare affordable in Colorado.” The first line of the petition stated, “That taxes shall be increased by $25 billion . . .” Parasitism has no endpoint until the host is dead.
it is usually for exotic treatmentsLike heart surgery?
http://www.foxnews.com/story/2010/02/04/canadian-premier-heart-surgery-plans-raise-questions-about-health-care.html
@esr
“Let’s suppose this is true. Now actually think about what it implies, if you are capable.”
That Costa Rica and Thailand have better health care? Because these are some of the popular destinations.
You know, when some rich third worlder needs complex treatment, they go to the UK, or France, or whatever is politically convenient. Rich medical tourists go where they can spend their money.
If you want to go beyond looking at number plates:
Canada’s turbulent medical tourism industry
http://www.cfp.ca/content/58/4/371.full.pdf
What do we know about Canadian involvement in medical tourism? A scoping review
http://www.openmedicine.ca/article/view/442/421
Yes, Winter, by some measures Costa Rica and Thailand
dohave better health care, because they have more of a free market than the US, and that helps keep costs down.The first line of the petition stated, “That taxes shall be increased by $25 billion . . .” Parasitism has no endpoint until the host is dead.Unfortunately, the devil is in the details. Under this plan, can the government use its power to negotiate the price of drugs in a downward direction? If so, that’s good. If not, that’s really, really bad.
Is there a robust,
transparentmechanism for keeping graft and corruption out of the system? If so, good. If not, bad.Is there some kind of provision to make sure that the government purchases, installs, maintains, and makes available for use the correct number of MRI machines? (Or any other medical good.) Does the government get to use its power to negotiate the price of those MRI machines, including such issues as installation and maintenance? Does the law include some kind of reporting requirement so the public can see that the money is being spent correctly? Etc.,
As far as paying for the service, does the proposed law shift the burden of paying for insurance from business to the consumer? If so, the customer has lost thousands from their paycheck every year. If not, is the proposed system immune to being gamed by businesses or those wealthy enough to afford tax advisors?
My point in asking these questions is that this particular issue is too-easily reduced to some kind of “four legs good” sloganeering and that doesn’t help much because there are so many variables which make single payer good if implemented one way and bad if implemented another.
Mr Caine;
Even the White House admits: stagnant wages in America are cause by “health care.” Of course, how much of this increase is medical care, and how much goes to “carrying charges?” Read on.
The current spike dates back to the US Senate’s tax “reform” in 1986, when they uncapped “health insurance” deductions (great if you’re rich, or in the old UAW). But American health was unfree long before that.
Like Europe, U.S. “health insurance” takes money away from the filthy poor people and then doles it back out to them*, charging them a stiff fee for all the government paperwork and waiting lists, much of which is a supply-side, hidden tax you are not allowed to see. This punishes poor people, who sometimes buy beer instead of health care, to the satisfaction of others.
It’s obvious, I hope, that insurance payments, government or private, must carry a large surcharge (or a sizable deductible) for fraud. (Note: I did not say prevention.) Obviously, it would be far cheaper to schedule and pay for dental cleanings and checkups yourself, and reserve insurance for real emergencies, but then Government might be in danger of you realizing your “free” healthcare… isn’t.
Think about a free market and your health: you have a job (and the housewives of yore had jobs, yes, not getting a paycheck does not mean you are not creating value such as hygienic quarters, cooked, healthy food and/or clothing.) Let’s say you have a broken leg. You need to pay the doctor, but you’re a farmer and can’t work with an unhealed compound fracture. Or you have cancer. How much will you spend beating the cancer?
Obviously, you need to weigh your future income versus your present costs. Your future income, of course, is also your old age savings. We will spend lavishly on a child with leukemia, but cancer at 84 just isn’t worth the same panicked drive, is it?
Since we aren’t paying our health care out of income (pricing disability risk), savings (pricing our life expectancy / quality / future income), or our non-negligible insurance cost (pricing emergencies), we can’t price it properly. But all these factors *directly* impact our cost/care evaluations.
Note how tightly I bind retirement funds into health care. They are indeed like identical twins. Social Security is a 12.5% regressive tax on all working Americans (again, we pay a lot for our “free” retirement). But, with gay marriage legalized, I predict legal polygamy in fifteen or twenty years. At that point, the three wives and eight children of a bus boy who died of sexual exhaustion will apply for full Social Security benefits *and* *they* *will* *get* *them*, and at that point, America is bankrupt.
So… something to look forward to.
* Much of Europe as well, though it is a continent with highly diversified market models for health care, a fact no one in the MSM ever mentions.
somercet – totally agree, but you seem to miss one thing – the first world is already bankrupt! And the debt is going up daily. So just like Eric, many of us are now earning less than they were because the budgets are being cut, but the ‘fat cats’ are still living in cloud coo-coo land thinking their salaries are safe while milking the rest of us. At the end of the day no country can afford the cost of some of the current life lengthening treatments and all we are really arguing about is who tells the patient they can’t have it?
Have any of you guys wanting government run health care considered that most of the money will go to pay the bureaucratic overhead? Government agencies have absolutely NO incentive to keep overhead low. They will expand to the limits of their budget and then demand even more. At least the “evil” insurance companies keep the overhead as low as possible to maximize profits. I have seen estimates that as much as 70% of any agency’s budget goes to pay salaries/benefits of the bureaucrats, whereas most private companies panic at any more than 10%. Also, with Civil Service rules being what they are, it is impossible to get rid of incompetent and lazy employees. .
From 2011: Private Insurer Profits? $13 Billion. Medicare Fraud? $48 Billion.
Under this plan, can the government use its power to negotiate the price of drugs in a downward direction? If so, that’s good. If not, that’s really, really bad.Well, one of the biggest reasons drugs are so expensive is because drug research is expensive. Drug research is expensive mainly because of Phase III clinical trial costs. Phase III clinical trials could be skipped, and the cost brought down significantly… except that Phase III trials are mandated by the FDA.
Meaning that the government requires drugs to be expensive, and demands they be inexpensive, simultaneously.
I’m not a fan of Obamacare. However, I have to suspect you’re doing very well if it’s increased your costs.
In my case, it’s going to mean completely free health coverage next year, after I’ve gotten my paperwork in order. Of course, I make all of about $13,000/year. Yes, you can live on that. Sort-of.
@ Troutwaxer – ‘this particular issue is too-easily reduced to some kind of “four legs good” sloganeering and that doesn’t help’
It would be nice if the majority of US voters were intelligent, highly informed, and possessed the motivation and time to fully analyze complex issues like government-run universal healthcare and then vote accordingly. Unfortunately, that does not appear to be the case. It seems to me that most voters are habitual based upon political bias and primarily respond to sloganeering put forth by favored politicians. I think history will soon show that we have already passed the tipping point here in the US, and that more people now vote for a living than work for a living. If so, then government growth will continue until we run out of other people’s money.
@Paul Brinkley:
That drugs are expensive because of Phase III trials is a fallacy. Specifically, it’s the sunk-cost fallacy. The profit-maximizing price for a drug doesn’t depend on development costs, only on supply costs and demand. Anyone telling you otherwise is most likely lying or mistaken.
EMF: So the $800 million to $1 billion cost to get a drug past the FDA has no bearing on the final cost? And the costs of trials for all the drugs that fail don’t matter, either?
Paul Brinkley: And note that when foreign governments bargain down the costs of US drugs, their savings are made up by higher prices here.
Mr Caine;
No, you still don’t get it. *No* *one* is orchestrating this. Lots of companies and pols are bilking the system, but it is entirely in response to *us*. We are begging them to do it. We vote them into office promising to do it to us.
Just like the subprime bubble. Yeah, the Boston Federal Reserve wrote up the subprime justification, and the NY Fed kept it going, but Barney Frank and Barack Obama were proud of it. They thought it was a brilliant thing.
And actually, that is so much more devastating than some Godfather of “health care” picking our pockets. So much more contingent, more accidental, more mindless… a slaughter of wealth that should mostly have gone to the lower third of American income earners.
it seems to be strongly oriented towards the beret-and-nose-ring crowdHey, now.
I don’t wear a beret.
(Though I also use Patreon to support webcomics.)
That drugs are expensive because of Phase III trials is a fallacy. Specifically, it’s the sunk-cost fallacy. The profit-maximizing price for a drug doesn’t depend on development costs, only on supply costs and demandFor production of a single drug that already exists, you are absolutely correct.
However, to actually get drugs discovered, tested, and made, it won’t suffice.
Because most drugs never make it to production, thus those that do
have tocover the R+D and testing costs of the whole mess.Because if they don’t, nobody will even
startthe process; why would they? Who’d put up the money? Who’ll keep it going through the inevitable string of failures?(It ain’t the Government – they won’t be any better at it than the private sector, and have plenty of perverse incentives not to be.
Nobody ever got fired for not releasing a drug, but people lose careers over approving things that end up being bad for people in a decade! Which are you gonna do, as a Federal bureaucrat?
And every year when billions on end go into Government Drug Labs and we don’t get anything more out, people will demand it be “fixed”, not realizing that it’s not something that can be “fixed” like that.
We’re better off with what we have, by far.
At least if we ever want to see new medicines.
If all we ever want is what we have now, and damn anyone with an untreated disease or poorly managed symptoms, well, your idea will work fine.)
somercet – I get perfectly that no one is in control … at least in the US there is a better chance of a politician actually HAVING a majority, but in the UK at least you only need one third of the country to support you to be able to dictate to the rest. Money is the only thing that has any control and yes the financial institutions still have more control over what is allowed to move forward than the supposedly elected politicians?
I’d just prefer not to reward them by privatizing everything … how much has the current situation in the US been manged by having to keep the ‘investors’ on side? They are all just gambling and fixing the systems to make a better profit?
Sigivald
http://www.cancerresearchuk.org/our-research
http://www.alzheimersresearchuk.org/our-research/
http://www.cysticfibrosis.org.uk/news/venture-philanthropy
and I can go on …
having been involved with helping set up the IT side of a few such research facilities I can add that many of these will be the only way low incidence diseases ill be addressed. There is nothing in it for the big drug companies.
Lester Caine on 2015-09-02 at 08:00:53 said:
I couldn’t possibly agree more, Mr. Caine! Thank you so much for saying so out loud. :)
I’m sorry to “hear” this, Eric. Your wife had said something about her “employment situation” becoming “unstable” in one of her blogs; but I didn’t realize the extent of your problems. Nevertheless, it was inconsiderate of me not to cut the shenanigans (asking lots of questions, making stupid jokes, discussing candies and shit like that), so I apologize. (And are you sure my lurking in her blogs doesn’t bother her? ‘Cause I can stop that, too. I’m ultimately a stranger, so I’d understand.)
Maybe I’m worrying too much again, but I’ve been wanting to say this ever since I read the OP a couple of days ago. I cannot, in good conscience, remain silent about this – especially given the repercussion your statement has had. Peace of mind…
> > People who recommend that Eric pull together a best of Armed and Dangerous collection are probably underestimating the amount of work involved in editing that much material.
> I fear so.
Perhaps I could help with the editing? I suppose I’d need some briefing, but I’d do the work enthusiastically. Since I cannot help you financially, I’m eager to help you in any way I can, however modest. It’s certainly true that your blog is rich in killer material; for example, the other day I read (or reread?) “When there’s nothing left to say, self-parody is the way”, and loved it. Succint and right on target! :-)
>Nevertheless, it was inconsiderate of me not to cut the shenanigans (asking lots of questions, making stupid jokes, discussing candies and shit like that), so I apologize
Oh, stop. Your “shenanigans” are a break from my real troubles.
>Perhaps I could help with the editing?
Or anyway the beta reading. I’ll consider it.
The main problem with “Eric should write another book” proposals is that writing a book is a time investment I can’t really make in the near future, not until NTP is in far better shape.
I grew up in poverty in West Virginia, and I’ve spent most of my adult life working food industry. At 26 year old, I got my CCNA certification this year, and I start my first internship in September. I owe that almost entirely to running into your articles when I was a teenager and remembering them when I decided I’d had enough of my old lifestyle and knew it needed changing.
If I can turn this internship into full time employment, I’ll donate something small monthly. I promise.
Just like the subprime bubble. Yeah, the Boston Federal Reserve wrote up the subprime justification, and the NY Fed kept it going, but Barney Frank and Barack Obama were proud of it. They thought it was a brilliant thing.Except that the subprime bubble popped in October of 2008, a month before Obama’s election, and four months before he was sworn into office. I’m not a huge fan of Obama, but at least get your facts straight – this took place on Bush’s watch.
Eric, you got a nice plug here.
Who continued policies instituted by Clinton, particularly the CRA reforms that turned loan standards into political footballs. Nobody’s got clean hands here.
Who continued policies instituted by Clinton, particularly the CRA reforms that turned loan standards into political footballs. Nobody’s got clean hands here.This is very true. From my point of view the major problem with our politics is not a particular viewpoint, party, or ideology. It’s corruption, pure and simple.
I was thinking about it on the way home, and I’ve come to the conclusion that maybe we shouldn’t discuss politics on this particular thread; I think we should put our brainpower to work on the problem of Eric’s income. I’d like to propose that we drop any political discussion* and brainstorm on how to get Eric a better income, and if possible, how to get Cathy a full-time job – maybe someone has some contacts in the right part of New England or something.
Unfortunately, I’ve got nothing for Cathy; my contacts and experience fit lawyers in New England the way a cheap corset fits Yog Sothoth!
But I was thinking about Eric making more money, and I’m wondering if part of the problem is that the subjects Eric is working on, while important to the deep issues of computer infrastructure, are a little too obscure to be good money makers… so I’ll start the ball rolling with the idea that maybe Eric should start an open source project that fills a need for some large business sector where there might be some money in adding features, customization and tech support.
Ideally such a project would be fairly simple and would involve a programming language like Ruby or Python which can produce results quickly so Eric doesn’t spend too much time on the project (really, we need him working on the infrastructure stuff) and others can get involved without too much overhead. The project should do one thing and do it really, really well, and it should colonize a niche which is not currently inhabited by decent software. Ideally the project should be something that one of us has the connections to use or support in the real world
The example I’m going to use probably doesn’t fit Eric very well, (though he’s welcome to it if he wants) but I think it provides some useful guidance. I’ve been examining (on my own behalf) the idea of a CMS (content management system) for restaurant menus. This solves a major problem for restaurant owners as the cost of retooling menu boards, reprinting menus, etc. every time a price changes is enormous. Wouldn’t it be easier and cheaper to hang a sixty-inch HDMI in a conspicuous area of the restaurant and make all changes in software (and maybe export the latest menu to your website?) The same solution scales from the diner on the corner to big companies like Jack In The Box, and the need to customize this solution, add features, provide support, etc., is probably enormous…
Note that this program solves one problem really, really well and I can cannibalize other projects for things like login code. The rest is easily implemented. Heck, a simple menu is only one table in a relational database! If I do the project I’ll use Ruby because I can make stuff happen quickly with the language even in my spare time, (not a Pythonista) and I have contacts at a national-level provider of field techs which can install the hardware throughout fifty states!
Can we come up with something like this for Eric? Something easy to create/maintain that colonizes a niche, which we can help him leverage?
Or maybe someone has some contacts that Eric can use… or there is a problem worthy of his mettle as a contractor… or maybe someone needs to handle a deep infrastructure issue and is willing to pay the big bucks. What do we have for Eric?
* I’m always happy to discuss politics on another thread.
@esr
“The main problem with “Eric should write another book” proposals is that writing a book is a time investment I can’t really make in the near future, not until NTP is in far better shape.”
It would be marvelous if you could combine them and use your NTP & GPSd experience to write a book about Open Source robust and secure ICT infrastructure development. That is sort of, in the picture nowadays. I have read (most of) your earlier books and such a book would be welcome.
As I mentioned before, someone already wrote a book where NTP was the hidden attack vector.
http://www.amazon.com/The-Lafayette-Campaign-Deception-Elections-ebook/dp/B010RF882O
I think a lot of us are in much the same place Eric. This side of the pond anything non-essential gets funding pulled so while we can always find jobs that need doing it’s finding enough that pay the bills while still maintaining the more philanthropic contributions :(
Belt tightening just needs to be a little better spread around so everybody does their bit?
@esr
“Facts trump theory. Nobody got shot crossing the Berlin Wall from west to east. When people vote with their feet, believe the people, not apologists for statism like Winter and Jeff Read.”
How true!
https://en.wikipedia.org/wiki/Medical_tourism#United_States
Ten times as many USA citizens travel to foreign nations for medical treatment than the reverse.
>Ten times as many USA citizens travel to foreign nations for medical treatment than the reverse.
I have no doubt this is true. If you look into it, you will pretty certainly find that medical tourism always goes from places where there is more government intervention in health-care delivery to where there is less.
Obama did hold office at the time — as a U.S. Senator. Whether or not he was in the Oval Office at the time, his championing the government underwriting sketchy mortgages is a bit of a black mark on his record.
And the bill that authorized Fannie Mae to provide low-income housing was passed during the administration of President George H.W. Bush.
Winter: how it is as a percentage of population of US and countries which citizens can freely travel to US, eh?
I pledged.
I have a feeling I will soon be seeing a *lot* of these sorts of posts, all of them from people I admire who are struggling through our endless national Recovery Summer. On the other hand, if 10% of your blog readership pledged at even small monthly amounts, you’d probably survive the next endless 17 months rather handily.
Love reading the endless explanations in your combox about how wonderful our current political elites are, how brilliant our current economic management is, how the only thing holding us back from Utopia are those stubborn reactionary wreckers, etc. etc. etc.
I can’t help wondering how utterly delusional the explanations will have gotten by Jan. 2017.
It didn’t increase my costs as I simply could not afford it.
Let me fix this for you:
@Jakub
“Winter: how it is as a percentage of population of US and countries which citizens can freely travel to US, eh?”
That would be a few billion people that can travel into the USA. But that makes the foot-voting even more lopsided: US citizens are much more likely to shop for medical treatment abroad than foreigners are likely to travel to the US to buy care.
Or what was your point?
> Oh, stop. Your “shenanigans” are a break from my real troubles.
I’m not sure what you mean. If you’re saying my antics distract you from the troubles, I’ll keep performing them. :o)
In any case, you seem to have taken my comment rather well. That relieves me: I’d posted it because I feared what you’d think of me if I didn’t; but after posting it, I started fearing it might end up being counterproductive! That’s funny: a friend of my father’s recently told me I should be fearless in my interactions with people. I’d like to follow his advice, but… you know: old habits die hard. :-(
(For some reason, I’m generally fearless in my interactions with dogs or cats. Go figure.)
> Or anyway the beta reading. I’ll consider it.
Gladly, if it comes to that.
> …writing a book is a time investment I can’t really make in the near future, not until NTP is in far better shape.
Of course. But if you do think of anything else I could do for you, please let me know. That’s what fanboys are for. ^_^
Given that literally every other country likely to have health care acceptable to Americans has adopted a single payer scheme of some sort — either exclusive of or supplementary to private care — I don’t think a lack of government presence has much at all to do with the reasons why Americans travel abroad.
I mean the simple answer is “it’s cheaper abroad” and there are two factors in that: one is the strong dollar relative to the currency of countries where Americans go for medical procedures; the other is that in these countries, as in Europe and Canada (which, according to Deloitte, is becoming an attractive destination for US patients seeking affordable care), government intervention in health care helps keep costs
down.>government intervention in health care helps keep costs down.
Uh huh. Here’s the NHS version of cost-cutting:
Thousands of cancer patients to be denied treatment. The story continues “Common drugs for breast, bowel, prostate, pancreatic and blood cancer will no longer be funded by the NHS following sweeping cutbacks”
Death by bureaucratic fiat. The natural, indeed inevitable consequence of surrendering health care to the state.
@Winter:
I suspect the numbers on Wikipedia have been misapplied or misinterpreted. Following the citation [#66] in Wikipedia to the source article for the numerical claim, we find this quote (emphasis mine):
In that context, the 85,000 figure is not the entrants to the US, but the total global medical tourism industry. If “most” of those head to the US, how can we figure there are 750,000 Americans—a full ten times that figure—going abroad?
If we check the original survey, or at least the lead, the wording is even clearer on the worldwide nature of this figure. “…McKinsey studied more than 20 medical-travel destinations; analyzed primary data on the number, type, and origin of medical travelers; and conducted interviews with providers, patients, and intermediaries in 20 countries. We place the current market at 60,000 to 85,000 inpatient medical travelers a year—…” (A bit more searching turned up a full copy of the article in PDF form here.)
I don’t know what generated the 750,000 Americans figure, because there’s no way to derive it from the McKinsey article. In fact, the highest number of “medical tourists” I could see that survey supporting is only ~250,000 persons (re-adding the exclusions listed in Exhibit 1). That’s still a third of the figure given by Wikipedia… do you have any ideas of where I might find that number’s original source?
@ Alex K.
When a casual reader accepts Wikipedia as implicit truth, this medical condition is known as Wikinsanity.
@TomA:
That’s a very unfair reading of my objection. After all, there are numerous studies which show Wikipedia is as accurate as the Encyclopedia Brittanica. The problem is not treating “Wikipedia as implicit truth”, because for well over 99% of the content it is accurate.
No, the problem is:
Wikipedia is not a primary source. Furthermore, for these statistics, Wikipedia does not directly cite the primary source—rather than reference the McKinsey survey, they point to Forbes instead, whichstillisn’t the referenced survey. When I went to read that primary source, it didn’t include the data that Wikipedia claims it does. So where did that number originate? How authoritative is that estimate, really? (And does the same source have a different estimate of the number of total medical tourists, or have something to say about inbound-to-US vs outbound numbers?)@Alex K.
Thanks for the clarification. I know about the limitations of Wikipedia and agree with you on this. I mainly use it to find primary sources. But is indeed a good source when you are unable to go to the bottom (as I did here).
But I wonder whether 80,000 medical tourists world wide can be accurate. I would expect much more. Maybe this has to do with their definition using in-patient care.
Watching Americans debate healthcare policy is like stepping into a reality-free zone.
By the way – Eric, if you are banging the begging bowl why not just post a donation bitcoin address here or wherever you think it will get the most views?
Bitcoin is programmable money that facilitates ultra-lown cost micro payments – it seems to me there must be ways that innovators can use this technology to help solve the sort of economic problem you are describing.
Or even
Winter:
85,000 worldwide travelers is
absolutelytoo low of a figure for what I think just about everyone here would include as medical tourism (for me: someone vising a foreign country with the non-exclusive purpose of seeking medical care). The McKinsey survey most expressly would under count this, as they disclaimed any attempt to quantify outpatient medical services. Someone visiting (as an example) Mexico from the US for kidney dialysis or oral surgery would not be counted, but should.While I feel that the 750,000 figure is in the right ballpark (perhaps a whisker’s breath too high for 2008, but a lowball estimate for today) I certainly can’t find a solid source starting from Wikipedia. Using a “wikiblame” website, I was able to find when that statistic was added; unsurprisingly it references a
totally differentsurvey than the current page. I’m not going to cite the entire chain, but that survey led down a rabbit hole to wonderland (which is to say, when I found the earliest source for all other citations, I didn’t consider the author to be very realistic or authoritative).In a broader search, the only open data source I can find is patientsbeyondborders.com, who claim (as of 2014) there were 1.2 million Americans travelling abroad for medical care and 800,000 visitors to the US for the same. [There is also an annual survey done by the International Medical Travel Journal, but that is locked behind a paywall.] Those numbers seem believable, but show a far smaller gap than Wikipedia.
“Yes, you’ll see stories about the poor lady who didn’t want to wait six months for a hip replacement and so headed down to the Mayo Clinic, but these are pretty rare.”
My wife saw a surgeon because of abdominal pain and was diagnosed with “we need to remove your gall bladder.” The doctor wanted to know if we could schedule the surgery for two days later. I guess if she were Canadian she could just suck up the cramps for half a year.
@ Alex K.
My Wikinsanity reference was aimed at the “750,000 medical tourists” guestimate that you have already extensively researched and found to be lacking in clear or reliable supporting documentation. “It sounds about right to me” is not a very high standard for a website that purports to be a foundational information resource.
Get your single-payer news right here! Hot off the presses!
@TomA
You are quick to point fingers, but Alex is dead right and you seem to be clueless (which I am getting used to)
http://www.cdc.gov/features/medicaltourism/
More like “the natural, indeed inevitable consequence of a Tory government”. Conservatives in many nations are notorious for chopping off their country’s nose to spite its face. Stephen Harper’s government is drastically cutting back home postal delivery in Canada, forcing little old ladies in rural and suburban areas to traipse to the post office to pick up the mail.
>More like “the natural, indeed inevitable consequence of a Tory government”.
You miss the point. Whether it’s a Tory cutback or not, the moment you have surrendered your health care to the state, you can die because
someone elsedecided cost-cutting was more important than your life and your choices. It’s execution by death panel, and the death panel’s specific motives or rationale are insignificant compared to the mere fact of its existence and power over you.In other words, once again liberals spend money they don’t have, and then when the bills come due, it’s the fault of conservatives for being big meanies.
@PapayaSF
“In other words, once again liberals spend money they don’t have, and then when the bills come due, it’s the fault of conservatives for being big meanies.”
You obviously have no idea what you are talking about.
The British Health care bill is the lowest of the developed world. If anything, the NHS is too cheap. Actually, as a percentage of GDP the health care costs in the UK are close to half that of the USA, 9.1% vs 17.1%.
http://data.worldbank.org/indicator/SH.XPD.TOTL.ZS
The USA would save 8% of GDP in health care costs if they would introduce the NHS.
@esr
“Thousands of cancer patients to be denied treatment. The story continues “Common drugs for breast, bowel, prostate, pancreatic and blood cancer will no longer be funded by the NHS following sweeping cutbacks””
First, these are still plans. We have seen these things before. They will be opposed by the public and mostly retracted. Meanwhile, this will be used to pressure the manufactorers to reduce the prices.
These are not life saving drugs but life extending drugs. This discussion rages periodically. How many 100k should we spend on average to extend life for another month?
Actually this is the ideal example of the current problem. This fund was set up to pay for the newer drugs many of which never existed 5 years ago. £200 million was thought enough to pay for the EXTRA drugs bill to provide a few extra months for a few thousand patients. What price does the US system pay out for a few extra months of life today which was simply not an option 5 years ago? The cost this year was £380 million or around £100000 per patient all of whom would have been dead already if these drugs had not been created, so does the US system have any cap on these escalating drugs prices? Yes in an ideal world everybody would have the right to these drugs WORLDWIDE, but just who picks up the bill?
@ Winter – “you seem to be clueless (which I am getting used to)”
Now go to the citation page in your response and then use it to trace backwards to an actual reference document that substantiates the claims made in the text. An assertion is not evidence.
These are not life saving drugs but life extending drugs.Strictly speaking *all* medicines are life extending, but that is a semantic argument.
This discussion rages periodically. How many 100k should we spend on average to extend life for another month?Oh look! Its the death panels you people keep denying.
@TomA
“An assertion is not evidence.”
Numbers given by the CDC tend to be authorative. They are the ones paid to know these statistics.
Given a choice between wild accussations by anonymous commenters with a history of unfounded suspicions and the CDC, I go for the CDC. But if you have better numbers, go for it and prove me wrong.
@Foo Quuxman
“Its the death panels you people keep denying.”
What death panels?
This is about deciding which drugs will be renumerated by the NHS. Drugs must be (cost-) effective and there is a limit to what can be paid. For someone from the US with their frequent capped inssurrance, you should know that.
http://www.nbcnews.com/id/25644309/ns/health-health_care/t/health-insurance-caps-leave-patients-stranded/
It is quite easy to spend billions on extending life for days. So choices will have to be made.
Note that the NHS has no life-time caps.
@esr
“the moment you have surrendered your health care to the state, you can die because someone else decided cost-cutting was more important than your life and your choices.”
But history shows that without state intervention, many people would not even have a choice. They would not get the health care they needed because they simply could not afford it. The story about the life-time cap I linked to was from 2008.
And the use of the term “death panel” is pure propaganda. These “panels” in the UK do not decide on patients, but in which drugs and treatments are renumerated. Every health care system in the world, including the USA have these panels. And they have always had them.
You miss the point. Whether it’s a Tory cutback or not, the moment you have surrendered your health care to the state, you can die because someone else decided cost-cutting was more important than your life and your choices. It’s execution by death panel, and the death panel’s specific motives or rationale are insignificant compared to the mere fact of its existence and power over you.
Since only a few people would be able to pick up a £100k a year drugs bill, many of us are reliant on the generosity of others, be that an insurance company who must make a profit to please shareholders, or some other shared payment method. If a drugs company comes up with a new drug that costs £100k per month to provide a few more weeks of life then would any provider not have to adjust prices to cover these sort of costs? The UK system does not have an open ended cheque book and while personally I’d prefer we funded a few more drugs rather than paying the US even larger sums for ‘Trident’ our democracy has decided that one is more important than the other? Which is perhaps why the fact that the government only has the support of 1/3rd of people who voted is irritating, but we have to live with it.
Winter, measuring healthcare by percentage of GDP spent is misleading and foolish. By that measure, every time a US porn star gets a boob job, or an actor a face lift, it somehow “proves” that UK healthcare is superior. Would Americans want the results of British dentistry because it’s a smaller portion of GDP? I don’t think so. Richer countries spend more on health. That doesn’t necessarily make the results optimum, but it’s not necessarily bad, either.
@ Winter – “Numbers given by the CDC tend to be authorative.”
The appeal to authority argument is intellectually lazy, and really only justified when expediency is an imperative. A charlatan cares not for the validity of a source, only its propaganda value.
Sorry, I.m not buying your “trust me I’m right” argument.
@esr
“…the moment you have surrendered your health care to the state, you can die because someone else decided cost-cutting was more important than your life and your choices.”
The moment you have surrendered your health care to an insurance company, you can die because someone else decided cost-cutting (e.g., to help keep premiums affordable) was more important than your life and your choices.
Once the cost of the treatment you want exceeds your ability to pay for it from your own resources, you are necessarily at the mercy of a tradeoff made by someone else, whether it be a government, an insurance company, a charity, or whatever. There’s certainly plenty of room to analyze and debate the particulars about how political and non-political factors influence these tradeoffs under various mixes of public and private provision of health insurance and health care. But there’s no such thing as an unlimited free lunch on someone else’s dime.
>The moment you have surrendered your health care to an insurance company, you can die because someone else decided cost-cutting (e.g., to help keep premiums affordable) was more important than your life and your choices.
Wrong. In a market system, you have the option of paying for your own care. In a single-payer one, you don’t. The situation isn’t symmetrical.
@TomA
“The appeal to authority argument is intellectually lazy, and really only justified when expediency is an imperative.”
Your doctor, your hospital, your state executive and your government trust the numbers from the CDC. Most of these parties trust them blindly. Hence, your life is to some extend in the hands of the numbers of the CDC.
When I wrote “authorative”, I did not mean trust, but that they are the ones who collect the official statistics for the USA. The numbers gathered by the CDC are the Official numbers.
You might chose to question the CDC. But the people in the medical field will just ignore whatever you say after that.
Don’t believe me, ask your doctor next time you see him
As a service to the readers of this blog, I have tracked down the original source of the 750,000 number
http://www.coa.org/docs/deloittestudymedicaltourism_111209_web.pdf
Sorry for being OT, but any comments on the rise of “codes of conduct” that seem to be attempts at SJW entryism?
Eric, you’ve created a Mad Lib for healthcare rants. All we have to do is remove a few words and replace them with blanks!
You miss the point. Whether it’s a __________ cutback or not, the moment you have surrendered your health care to ___________, you can die because someone else decided cost-cutting was more important than your life and your choices. It’s execution by ___________, and the ____________ specific motives or rationale are insignificant compared to the mere fact of its existence and power over you.You can fill in the blanks with words like “Cigna” OR “Obamacare.” Words like “government” OR “big business.” Words like “death panel” OR “corporate accountant.” Depending on the words you use, it’s a Liberal, Libertarian, or Conservative rant, which probably means the complaint is universal. Regardless of who runs the system,
someonehas to make the difficult decisions about how much it’s worth to prolong the life of a cancer patient by six months.In any system imaginable, the amount of money available is finite, the amount of need is damn-near infinite, and there will always be really hard questions like
“If we pay for grandma to use the super-expensive cancer drug, can we afford to vaccinate all the little babies?”In short, its a fundamentally difficult decision!Anyone who complains about government death panels while receiving health care from a corporation is missing the point very badly indeed.
Someone,corporate or otherwise, will always be making those decisions.Eric, you’re too smart by far to be reducing complex issues to Fox News-like rants. This is really, really hard stuff, and ranting about death panels may relieve some stress, but it does
nothingto address the issue.** Since nobody wants to brainstorm Eric’s issues I’m talking politics, I guess. Feh!
>Someone, corporate or otherwise, will always be making those decisions.
Yes. But there are still fundamental questions about whether market allocation works better than political allocation. In true single-payer there is only one death panel, no way around it, you’re not allowed out from under except by fleeing the jurisdiction, and there is effectively no pressure to keep the process overhead low. In a market system there are at least multiple insurance companies and they
areunder market pressure.The worst problems with the U.S. system all trace to the fact that since 1948 the U.S. government has created a web of regulation, subsidies, and perverse incentives that have badly distorted price signaling in the system. Reliably, when the person who pays for a service is not the person who consumes it, you get cost inflation. If food were regulated the way health care is, it too would be eye-wateringly expensive and the monopoly of a rent-seeking specialist caste.
@ Troutwaxer
> Since nobody wants to brainstorm Eric’s issues I’m talking politics, I guess. Feh!
But I like your idea of brainstorming Eric’s issues. I’m confused, though: you said something about lawyers in New England. I thought the Raymonds lived in Pennsylvania; did they move to one of the New England states while I wasn’t paying attention? :S
@ anyone
If the next administration turns out to be Republican, is there a chance Obamacare will be repealed?
Wrong. In a market system, you have the option of paying for your own care. In a single-payer one, you don’t. The situation isn’t symmetrical.Some very small percentage of us can pay for our own care without damaging our finances horribly. I’ve worked in medical billing and it was awful twenty years ago – the Cardiologist’s portion alone for a balloon angioplasty billed out at around $2000 in the early nineties* and that doesn’t count the cost of the operating room or the nursing/technical staff! And balloon angioplasties are well-known, fairly simple procedures that are done every day and only take a couple hours (at most.) I’d guess that paying for one on your own is something like $15-20,000 these days.
My wife’s 4-month hospital stay in 1990 billed out at around 1.5 million dollars. (Fortunately, she was insured and one particular surgery made the Doctor’s reputation, so the $125,000 we owed mysteriously vanished one day!)
The idea that anyone really has the option of paying for more than very simple stuff is complete nonsense. I would have to admit that “single-payer plus add-your-own-cash for stuff the government doesn’t cover” is fairly attractive.**
* Just for the record, insurance would pay between 1000-1600, with the patient paying anywhere from 50-500 dollars!
** The devil, as I said above, is in the details!
>My wife’s 4-month hospital stay in 1990 billed out at around 1.5 million dollars.
This is what happens when you fuck up price signalling and encourage provider monopolies for sixty years.
I’m confused, though: you said something about lawyers in New England. I thought the Raymonds lived in Pennsylvania; did they move to one of the New England states while I wasn’t paying attention?I’m a little vague on where Eric lives. Sorry.
@Troutwaxer: Nobody disputes that in extreme situations like that, bills are very high, but what used to be called “major medical” insurance doesn’t have to be that expensive. When defenders claim that Obamacare “is really the Heritage Foundation plan!” they are talking about an old proposal for mandated “major medical only” insurance. It would have cost a fraction of what Obamacare costs, because the original plan wasn’t larded up with mandates. Imagine what your car insurance would cost if it was forced to include free towing, oil changes, brake jobs, tire inflation, windshield wipers, and detailing.
Everything can be made much cheaper by reducing regulation, allowing competition, encouraging more price transparency and straight payment for services, removing subsidies, and so on. Then, extreme medical catastrophes can be covered by partial self-funding, plus affordable insurance, charity, and (why not?) crowdfunding.
The enemy of competition is not the state, it’s the competitors, each of which want to use the power of the state to make themselves the only competitor (or at worst, part of a cartel). ““People of the same trade seldom meet together, even for merriment and diversion, but the conversation ends in a conspiracy against the public, or in some contrivance to raise prices.” —Adam Smith (the original)
@PapayaSF
“Nobody disputes that in extreme situations like that, bills are very high, but what used to be called “major medical” insurance doesn’t have to be that expensive.”
That kind of insurance is so cheap because the main driver of health-care costs is in care for chronic conditions:
Chronic Disease Overview
http://www.cdc.gov/chronicdisease/overview/index.htm#sec3
In Chronic Condition: Experiences Of Patients With Complex Health Care Needs, In Eight Countries, 2008
http://content.healthaffairs.org/content/28/1/w1.full.pdf+html
You often find numbers in the order of 75% of total costs:
The Impact of Chronic Diseases on Healthcare
http://www.forahealthieramerica.com/ds/impact-of-chronic-disease.html
In short, when you offer insurance for chronic conditions,there will be no cost benefit.
(If you want primary sources for such glaring facts, I suggest you do your own research)
Eric … there is nothing stopping UK residents paying for their own health care. That was the one thing that could not be changed when the NHS was set up. It sounds as if ‘Medicare’ is the American equivalent of the NHS? So isn’t just the split between who gets access and who doesn’t the question here? In the UK it’s 100% in the US is ?% …
There have been high profile cases over here where people who can raise the funds for some alternative treatment which might have some slightly higher chance of success than the one available in the UK. There is nothing stopping them despite what they might think. Is it wrong to run expensive equipment manned by highly experienced staff who get better and better results year on year, or should we scrap that kit as soon as some other alternative with is ‘a little bit better on some conditions’ comes along? Kit which will take years for the users to be come as competent as they are with the kit they are already used to. The goalposts are moving monthly on medical treatment options.
http://www.theguardian.com/society/2010/jul/19/health-insurance-slumps is a little out of date, but does highlight that in the UK we do have options, we perhaps trust the con artists in government more than those in the insurance business? But as with everything to do with money, nothing is a certainty … everyone is gambling with it these days!
>Eric … there is nothing stopping UK residents paying for their own health care.
Hm. So England isn’t de jure single payer. I didn’t know that.
There’s some hope for the market to subvert the regulation, then. It’s beginning to happen here in small ways – cheap clinics in Walmarts, doctors who’ve noticed that if they bail out of Medicare they can spend enough time seeing patyents rather than doing paperwork that their margins go up.
@Troutwaxer –
Eric’s premise is – the
the consumermakes those hard decisions. No one else could possibly have all the information. Yes, there will always be a gap between demand and supply. Why should a distant third party try to arbitrate that? And any attempt to fill it in will necessarily either [a] regulate prices and wages in the health-care industry, which will discourage investment and desire to work in it, or [b] be taking other peoples’ money.What if health insurances plans were voluntary, non-profit co-ops, like credit unions are set up here in the US (contrasted with the for-profit banks)? Different groups could agree to cover each other for various levels of risk or to various levels of comprehensiveness, depending on what everyone agrees to and is willing to pay for. Push both authority and responsibility as low on the ladder as possible.
@esr –
ISTR that I read someplace (sorry, original cite lost in the mists of time) that (one of) the roots of the problem was the government-mandated wage freezes during WWII. Companies started offering “free” health insurance, since they couldn’t offer greater wages.
It never has been although the ‘private sector’ does get blamed for some of the NHS queues in areas where the private sector gets priority or have a monopoly on the service.
Just as there is no ‘death panel’ … if you have the hundreds of thousands for one of the drugs which will give you a few more weeks, the NHS will still provide the rest of your treatment! If there is something approved which ‘NICE’ have considered both safe and practical then that is provided instead. Yes there is distortion, but only on the very edge cases which any commercial enterprise would have to factor into costings?
Politicians tend to lose elections when they overtly raise taxes by large amounts. Consequently, subterfuge is necessity to avoid blame and voter backlash. Best to camouflage a large tax increase as something else; say for example, social security or single payer universal healthcare.
@TomA
“Best to camouflage a large tax increase as something else; say for example, social security or single payer universal healthcare.”
That might work in the USA.
In most countries I know the electorate have a keen eye on health care and pension benefits. Doing creative things with these budgets makes for very big headlines.
@esr
“Hm. So England isn’t de jure single payer. I didn’t know that.”
Neither in the rest of Europe. I do not even know whether such countries exist.
Continental Europe is riddled with private clinics. These are mostly used for cosmetic surgery and diagnostics (MRI on demand etc). Both are not covered by the national systems. Diagnostics are limited because doing more than necessary leads to high costs and unnecessary treatments (you will always find something “worrying” on a MRI).
@esr
“Wrong. In a market system, you have the option of paying for your own care. In a single-payer one, you don’t. The situation isn’t symmetrical.”
You left out my following sentence, which made a point that others have raised as well:
“Once the cost of the treatment you want exceeds your ability to pay for it from your own resources, you are necessarily at the mercy of a tradeoff made by someone else, whether it be a government, an insurance company, a charity, or whatever.”
As for this…
“In a market system there are at least multiple insurance companies and they are under market pressure.”
How much do you know about how health insurance companies in the United States and elsewhere create and manage their coverage policies, and what that means for beneficiary access to expensive and/or investigational diagnostics and treatments? “It doesn’t matter because the whole system is so distorted by government regulation” is not a substantive or useful answer.
Health care poses genuinely difficult problems that would persist under any possible system of government. You can make an argument in favor of a purely hands-off approach, reflecting your values. If you want to be credible, you need to demonstrate a realistic understanding of how health care works and be willing to own all of the likely consequences.
Most fundamentally, “realistic understanding of how health care works” means coming to grips with the profound knowledge problems that are characteristic of medical practice, policy and innovation; the unavoidable limits to our capacity to solve those knowledge problems; and the precise shape of the collective-action problems and freedom-vs-something-else tradeoffs that result.
Winter:
That link may be the Deloitte study referenced elsewhere, but it is not “the original source of the 750,000 number”. If you look at the line in that study where the figure is provided:
Footnote 2 is a direct link to the “earliest source” I had mentioned before (although my link was via archive.org as the original copy is no longer online). Footnote three points to a second study which, when establishing the medical tourism market size, contains a footnote to the exact same page. As a result, that number seems to me not to have been generated in a methodological fashion, but merely cited often enough to become “true” (the CDC doesn’t give any citation for their usage, but seeing
the exact same numerical valuehas me suspecting it came from one of the sources already discussed).The independent second source I found, while potentially biased toward announcing as large a value as possible and provided no explanation of their methods, was still rather close in magnitude. Therefore, while it certainly approximates the true value, the 750,000 figure itself should not be considered substantiated based on any of the articles provided. I’m certainly not saying to stop using it, but merely that there is a strong case against its’ validity.
@ Troutwaxer
> I’m a little vague on where Eric lives. Sorry.
That’s okay. He was born in Boston, after all. ;-) Also, his cat is a (beautiful) Maine Coon. And, according to a map on his personal page (near the bottom), he’s visited all the New England states except Vermont and Rhode Island. Perhaps the map is outdated and he’s since visited those two states; in fact, I’m
surethe maps are out of date, for the second one doesn’t reflect the fact that he has visited Brazil.TBH, I don’t know as much about American geography as the previous paragraph might suggest; I merely looked a couple of things up
ad hocfor this conversation. :-P But I do want to learn more about American geography and history – especially the latter. It’s an admirable country, except for the politicians (and lobbyists?) who betray its founding principles and whom Eric justly calls “statist bastards”.@Health Care Analyst (2015-09-06 at 13:46:56)
Piffle.
In particular, “It doesn’t matter because the whole system is so distorted by government regulation” IS both substantive and useful. Observe, for example, the rise (return, really) of cash-only doctors. Or, for that matter, compare veterinary care, where insurance is an oddity.
Go DISQUALIFY! somewhere else. Special knowledge of the gory details of a system that no one wants is not necessary to a discussion on what to replace that system with.
The free market solution is simple enough. Decouple medical insurance from employment. Decouple it from regulation that requires it to also be not-insurance, but allow that option if the market prefers it. Also, remove geographic restrictions and obnoxious administrative burdens.
In that system, there would be HSAs, there would be major medical insurance, long-term disability insurance, short-term disability insurance, I-just-got-diagnosed-with-an-expensive-chronic-condition insurance, etc. Presumably, there would also be bundles too.
P.S. Whenever you use a phrase like “unavoidable limits to our capacity to solve those knowledge problems” around here you’d better have a free-market solution under your hat. Plenty of folks here have read
The Fatal Conceitand aren’t going to take your word for it that you’ve discovered a way to make all the decisions without a mechanism for collecting all the information.@patrioticduo
>When people talk about Sweden healthcare, they’re ought to be talking about Connecticut.
This is a very good point. The proper comparison of the US FedGov is with the EU as such. 340M vs 550M is a bit off in the other direction, but still closer than any country level ones.
(I have noticed that 90% of libertarian sentiment in the US is directed at the Feds and not state or municipal level. The properly sized parallel for that is called EU-skepticism.)
And yes, I think having the EU ran healthcare or anything big would be an absolute nightmare. As a comparison, there is the HAACP, EU level regulation, which regulates,among others, restaurant kitchens. The goal is to prevent food poisoning. The primary issue is that it is so expensive that the poorer countries in the South and East cannot possibly keep up. Things like separated wash basins, keeping a manual cooler temperature journal, different fridges for everything etc. if it was followed to the letter, the average Pole or Greek could never afford a restaurant dinner. What happens is, usually, bribery, when the controller comes. So in practice it is yet another source of graft, private taxation. Even the richer corporations, like IKEA Austria, cannot really keep up with it. When there is a heat wave, there is often 16C (60F) in their restaurant fridges and then the employees whisper to the customer “you don’t really want that cream cake, trust me”.
In a small country, the practice of the public side of healthcare keeping the private side fairly cheap and yet quick and efficient, seems to be workable, although I would rather not even calculate how much I am paying for that public side that I try hard to avoid using. Blowing that up to EU or US Fed level would be an absolute quagmire. And there are fights even on this level – there is an initative in Austria that every doctor should keep all their patient data in a central electronic database. Every doctor I know fights hard against it, saying that patient data belongs to patients and them. With some paranoia, this could be seen a step towards the nationalization of the private side of healthcare. What is your opinion? When a government, even if a small country or small US state, wants to be the central depository and caretaker of data in a certain field of human activity, time to get paranoid?
Random off topic question:
Can anybody provide pointers to introductory resources on the Linux virtual memory subsystem? Googling results in a whole bunch of links to a resource titled “Understanding The Linux Virtual Memory Manager” by Mel Gorman. This seems to be about what I’m looking for, however, it seems to be over a decade old, and mentions kernel version 2.6 in the future tense.
Therefore:
1) Are there any comparable, but more recent resources?
2) Has memory management in the kernel changed enough in the past decade that I would need to find more recent resources, or does this remain a good primer?
@Shenpen
“And yes, I think having the EU ran healthcare or anything big would be an absolute nightmare. ”
But then, the EU countries do a reasonable job of getting everyone covered by affordable health care insurance. The problem in the USA was that most (almost all?) states did not have a system in place to get everyone covered. Most did not even had plans to get everyone covered. Moreover, the integration in the USA has gone on for over two centuries. The EU is still trying to integrate basic things in the members (say, power outlets).
The whole complaining about Obamacare by the right just disregards that the Republicans never had a plan to get everyone covered under affordable health care (we just had 8 years of Bush). The only thing the Republicans did was to sabotage anyone who tried.
I did not get what Health Care Analyst or you were going on about, but this one statement is perhaps the whole point today. There were 4 emails in my junk box this morning offering software development or web support at sub £5 per hour but while ‘off shoring’ is still a problem people in the UK at least are realizing that it’s not simply a matter of saving money since laying local staff off costs more in ‘administrative burdens’ than are saved by ‘remove geographic restrictions’. China is currently coming to a point where they expect wages to be more in line with the rest of the world, so often now it’s actually cheaper to build locally again.
Once one has a level playing field one can compare systems, and perhaps the millions of people descending on Europe at the moment could be reversed? So perhaps now is the time to pull up the drawbridge, seal the channel tunnel and sink any ships that don’t have the right paperwork :)
>Hm. So England isn’t de jure single payer. I didn’t know that.
In fact, lots of people have private health care insurance in the UK. I do. It costs me less than £100/month for full cover, including access to all the high-end private hospitals in and around London. I’m truly baffled by the cost of insurance in the US.
“In fact, lots of people have private health care insurance in the UK. I do. It costs me less than £100/month for full cover, including access to all the high-end private hospitals in and around London. I’m truly baffled by the cost of insurance in the US.”
More or less the same over here. In the Netherlands, it is mandatory for every person to take health care insurance. It costs around 100 euro a month for basic coverage. Children are free until they reach 18. People pay for their own insurance, but those on low income get financial assistance to help pay that bill.
Long term care is covered by a separate system, paid out of taxes.
https://en.wikipedia.org/wiki/Healthcare_in_the_Netherlands
Insurers are commercial, but they are required to unconditionally take everyone that applies for the basic universal coverage. Basic coverage covers everything that is medically necessary. There is no medical reason to take more insurance. Coverage is uncapped.
In addition to that you can insure whatever extras you want with whoever wants to insure it. That will cost you around 10 euros a month depending on what you want. Otherwise, you will have to pay for the extras. I only take world-wide coverage, because I travel a lot. I do not see the need for the other extras.
There is no law against you paying out of your own pocket for whatever medical treatment you want, wherever you want it.
What surprises me most is how little people from the USA know about health care practices around the world, even in the UK and Canada. A mouth dropping amount of ignorance remains after years of debating health care systems in the US.
Winter: “I do not even know whether [de jure single payer] countries exist.”
North Korea and Canada. Naturally, details are sketchy re NK.
An accurate summary of the Canadian rule can be found here. Canadians are generally happy with the system they’ve constructed. It’s relatively inexpensive because it’s a legislated monopsony. Administrative costs are lower than the US model. Mortality outcomes are comparable. Complaints arise almost entirely from delays in providing non-urgent but still medically necessary care (think hip replacement, e.g.). It is illegal to pay for such services privately (they won’t prosecute a patient but they will go after the doctor or clinic), either in cash or via insurance, so queues develop in the public system. See e.g. this. The governor on the length of the queues is determined by (provincial) politics.
It’s a completely Stalinist regime, but not one Canadian in fifty thinks the US system – now or pre-Obamacare – is preferable. Yes, per the anecdotes above, some near the US border will cross over to lay down $200 for an MRI next week instead of two months from now because it will shorten the wait time to book an appointment with the orthopedist. No, they will not lay down $40,000 to get a hip replaced by an American orthopedist; they will grin and bear the pain for six months and get it “free” in Canada.
Eric, thanks for all you have done for the open source movement. I think what you are doing is cool, and wanted to let you know. I’m still thinking about the idea of supporting you through Patreon. I did do something long overdue, and just ordered a copy of
The Cathedral and The Bazaarfrom Amazon.Eric,
A belated happy Labor Day.
I just wondered if you were aware of ‘Open Source Pharma’.
If not, perhaps a visit to Andy Updegrove’s http://www.consortiuminfo.org might be in order.
Scroll down to The Standards Blog: “What is Open Source Pharma (and why should you care)?” article.
I thought that if they succeed in raising said $1 billion, they might have a $100K+ p.a. slot for someone with skills like yours (NTPsec permitting). Although I fear that the proposed data might overwhelm The Great Beast Of Malvern!
>I thought that if they succeed in raising said $1 billion, they might have a $100K+ p.a. slot for someone with skills like yours
What’s a “p.a. slot”?
Forgot to add that I can have a word with Andy if of interest.
ESR (and friends):
What do you think of the GRSec closing stable patches of it’s derivative work debate? https://soylentnews.org/article.pl?sid=15/09/07/040206
(also: grsecurity.org for the announcement)
>What do you think of the GRSec closing stable patches of it’s derivative work debate?
Given GPL terms, I think it’s on shaky legal ground and even shakier ethical ground.
I think P.A. = Project Administrator.
>I think P.A. = Project Administrator.
I hope not. Putting me in an administrative position would be crazy. First, while I am pretty good at leadership, I am at best only a marginally competent manager (very different skillset). Second, every hour I spend administering would be an hour I’m not spending on being a systems architect, which is the most effective use of my time.
I figured per annum.
p.a. = per annum, slot = role/position (i.e. round peg in round hole).
It occurred to me that they will need someone with extraordinary experience with large repositories of research data, and the ability to design a system that allows the extraction therefrom of relevant ‘search requests’ responses.
Sorry for being obtuse.
@Winter
What, exactly, does “everyone covered” means? There is a different theoretical and practical approach here. Theoretically “everyone is covered” only when it is an entirely unconditional right. This is not true in the average EU country either, like here in Austria went from being covered by her employer to being covered as being on maternity leave and as the documentation of the maternity leave was difficult she spent a few months on being co-insured as a spouse to me. We also had a case when her last job was in France and benefits are not transferable, so she was not eligible for unemployment benefits here, meaning no automatic insurance coverage so we paid her insurance premiums out of the pocket. This clearly demonstrates even the EU does not have fully universal, unconditional coverage, there are theoretically holes a person can fall through.
So while not having it in theory, EU countries tend to have practical near-universal coverage because the holes to fall through are fairly small. The worst case, the paying of insurance premiums out of the pocket, for the long-term unemployed, is something like €50 a month in Austria.
So I think you should analyse the situation from this angle. It is not a binary universal vs. non universal healthcare, but more like a million little practical policies that ended up sewing the holes to fall through fairly small in the EU, while Republicans in the US were unable or unwilling to do that with state-level healthcare policies. But it is closer to a practical small hole sewing, or the lack of that, than some truly sweeping policy decision. If I had to make a wild guess why, I think they didn’t want attract illegals from Mexico too much. But I find it strange how not all college students were automatically insured. I think keeping good future taxpayers alive is usually a good financial investment for a state.
@Shenpen
“It is not a binary universal vs. non universal healthcare, but more like a million little practical policies that ended up sewing the holes to fall through fairly small in the EU, while Republicans in the US were unable or unwilling to do that with state-level healthcare policies.”
I think that is a good assessment. Also, because fairly few people fall through the cracks, there is usually some way to paper over that. Over here, doctors and hospitals insist on treating all, even the uninsured (mostly illegal immigrants that show up in a hospital). There is then some behind the scenes wrangling on who will pay the bill.
@Shenpen
“But I find it strange how not all college students were automatically insured.”
I think that is no accident. I got the strong suspicion that the foundation of the US system was the illusion that it was “everyone for himself”, and that there should be no one who would have to pay for someone else. Paying for other people, even students, would be heretical.
In reality, I think the whole system only worked because of the large federal programs (medicaid and medicare).
@Winter not only those programs, mutual benefit societies were widespread in the US, which went strongly against your supposed principle of every man for himself. The idea of a mutual benefit society is strongly based on solidarity, except that it is a grassroots organization, not a government-organized one. This should be familiar for us as well, interestingly, in Scandinavia, the origins of universal healthcare do not begin with the big large centralized social insurance schemes, but by the government starting to subsidize already existing mutual benefit societies around 1912 or so. This was attitude was markedly different from the bureaucratic Beamter-cultures of Germany and Austria-Hungary where every government involvement meant making some huge centralized office and database and all that. Interestingly, America seems to have inherited German Beamter-culture somehow, it seem government involvement in America always means creating new agencies and many government jobs.
Also, keep in mind that in say 1920 or medical care was cheap because it could not do shit. Most patients were cared for at home and even surgeries were performed at home. So the idea of health insurance in any form was all about the loss of income i.e. social security, and not about the doctors moderate fees.
The idea that a hip replacement surgery could cost a car or a really nasty accident could cost a house is something entirely modern, so that medical costs can be, in themselves, catastrophic and better be really insured for it, is a few decades old at worst, a really modern phenomenon, and I think it was never really thought through because most countries – and this is key here! – just mindlessly extended their existing their previous insurance-for-loss-of-income type of sickness insurance programs for it. This is absolutely key and please try to keep this in mind, it really defines the picture.
So the predictable, cheap kind of loss-of-income sickness insurance that was all about paying some guys wage for a few months until his broken leg mends got blown up into a spiralling medical costs insurance where tech develops so fast and it is so cutting edge that it can have enormous costs.
So imagine this. In the modern world, there is a huge and high-tech industry, the medical industry, that lives practically entirely from insurance claims, be that public or private. This is really unique at that. We also insure our cars and houses, but builders and car makers have only a very low % of their income from people replaced cars that got totalled or houses that burnt down. And the reason the medical industry lives off insurance is that it was originally meant for the loss of income due to sickness, and then got mindlessly repurposed for it.
I hope you are smelling something fishy here. Something comparable with the airline or car industries is not supposed to operate from insurance, public or private. There are huge issues there. Such as the lack of incentive to compete costs down.
Of course it operates from insurance because people, psychologically, set their baseline expectations at being healthy, so everything that is necessary for being healthy again is seen as a catastrophic expense, i.e. to be insured. I don’t know how to fix this. This probably needs to be fixed, but I don’t know how. Keeping 90 years old people alive and mostly functioning is like buying them BMWs in costs. It is not going to be possible to finance this forever.
I think the Nazis brought it over when we hired them to build our rockets after WWII.
Whatever the case, building effective government infrastructure in a society which believes that government is inimical to freedom and well being — even when all available evidence indicates otherwise — is a fool’s game. Without a populace that is emotionally invested in the programs, they will become havens of lobbyist graft and/or be scuppered by conservatives seeking revenge.
> Given GPL terms, I think it’s on shaky legal ground and even shakier ethical ground.
Isn’t it a dangerous precedent to say that anyone who makes an open-source product automatically forfeits all trademark protection for their name?
From the comments elsewhere:
> Detractors then noted that licenses (creatures of property law) can be rescinded by the licensor at-will (barring estoppel), and in that case any contributor to the Linux Kernel code could rescind Brad Spengler’s permission to create derivative works of their code at will
Speaking of dangerous precedents…
(Though, in a world where this is true, the FSF’s insistence on having copyright transferred to them makes a lot more sense)
Yeah, where’s the evidence that government is ever inimical to freedom and well-being? History is a solid string of shining achievements of governments, with nary a blot!
Suppose something like the “uid = 0” backdoor attempt of 2003 happened today, and successfully got into the wild, in a version of the kernel that GRSecurity hasn’t seen yet. But someone else has applied a GRSecurity patch (which, obviously, does not address this hole) to the version which did have the hole, and released it as “GRSecurity 4.3”. Can you claim that this would not harm their brand? This is the scenario they are terrified of when they see other people attach their name to distributions whose security they cannot guarantee.
@Jeff @PapayaSF
I have strongly in my cultural DNA that the purpose of government is war, war, war. Or, I mean, defense. It’s all the heroic stop-the-Ottomans-or-die-trying at Belgrade or Eger scenarios. The whole idea to use government as tool to improve some other aspect of social organization is historically novel to me – yes, it existed in the West for a few centuries, but Eastern Europe has always been to busy at warring or being occupied to really test this.
I guess an organization meant for defense can be useful for other projects as long as they look like defense. The fire department is probably not a bad idea, although I love the Austrian concept of voluntary, free-time fire service as well. Winter tend to bring up Dutch dyke building, I guess that can be seen as a form of defense, or warring with the sea. Churchill supported the idea of the NHS as a war metaphor: “Disease must be attacked, whether it occurs in the poorest or the richest man or woman, simply on the ground that it is the enemy.”
Given that I think folks like Churchill weren’t idiots, I cautiously accept the idea that government is a proper tool for solving problems as far as such solutions can be legitimately seen as defense, or war, even when not against human opponents: fire, natural disasters, contagion (think Spanish Flu post WWI) or the frickin’ sea. (Probably my most unlibertarian belief is that there are acceptable cases of economic protectionism: a sane country must have the industrial basis necessary for warfare inside it, even when it is uneconomical and the market would balance better at free trade. Same for strategic resources that can be used for blackmail – I am not fan of Russian energy diplomacy, “obey guys if you want to heat your flats in the winter” at all. I’d rather have my fossil fuels domestic or from friendly powers and without blackmail, even when the market thinks otherwise. Basically the ability to survive trade blockades and embargoes is a legitimate political goal, because it is clearly a form of defense, and it means protectionism.) Still, with stuff like war on poverty or war on drugs, this metaphor clearly became a huge stretch. I think one current challenge is engineering non-governmental actors for non-defense types of social investment, because just being a naysayer doesn’t really work. I mean, asking progressives here, what is so progressive about repurposing the 500 years old Westphalian nation-state, meant for warfare, for education and healthcare and social welfare? New wine in old skins? People could be more creative than that… I wish I could interview Nassim Taleb on this.
Have you asked him? @nntaleb on Twitter, and he’s both active and responsive.
…and apparently my paste didn’t work and I didn’t notice. Previous in reply to Shenpen.
kjj on 2015-09-07 at 02:21:50 said:
> …if the market prefers it.
Shenpen on 2015-09-09 at 04:37:53 said:
> …even when the market thinks otherwise.
Silly question: in sentences where “market” or “markets” is followed by a verb that’s characteristic of human behavior, it’s because it functions as shorthand for “market actors” or something of the sort, right? If so, I’ve screwed up (see a pattern here?): I once called derecho64 on it, suspecting he was reifying the concept of market. Now I think I was unfair; maybe I did it because he happened to be a non-libertarian, and I probably wanted to score cheap points (“Look, Eric! I’m a libertarian kid! I want your approval!”). I hereby apologize to derecho64, but I don’t know if he still reads this blog. I may have made him feel unwelcome here.
That’s a decent way to explain it. More generally, in such instances, a methodological individualist views such statements–whether about “the market”, “the government”, or that
ne plus ultraof handwaves, “society”–as applying some sort of reduction function to a group of individual people.One of the advantages of using a market as a coordination mechanism is that the reduction function, price, serves both as an indicator of collectively desired behavior and a direct incentive to respond to that behavior, whereas those two components are disjoint in most other mechanisms.
I think the problem with methodological individualism is the lack of awareness for coordination problems. Awareness for coordination problems (nicknamed Moloch) is one of the great truly non-partisan aspects of getting politics and economics right: this is basicially one thing what extremely smart people on the moderate left (Scott Alexander) and reactionary right (Nick Land, xenosystems.net) agree upon.
The point is, the market is a coordinator. It cannot be entirely reduced to market actors – it is an institution in itself, which is meant to reduce coordination problems between market actors.
Overally, the political debate should be largely about market coordination vs. governmental coordination, or suchlike. But the point is, the market is definitely a thing, a coordination institution, which is what IMHO methodological individualism tends to neglect.
My point was largely that market coordination in peacetime tends to not really price in the potential wartime circumstances, but that is a minor point really, not really important to dwell upon in this thread.
The concept of a coordination game only makes sense from the viewpoint of considering the players as distinct entities in the first place.
Why can’t it be reduced to market actors? Take out the people who make the market (including their direct proxies such as automated trading), and there’s nothing left. The “institution” is simply a set of rules for the game that the people play together. The game is much easier when the rules are clearly understood and simple to follow. The NYSE is “an institution”, certainly, that makes matchups between investors wishing to buy and sell easier—but the exchange itself is made up of individuals seeking a profit for providing clearing services.
Just one example, Christopher – if and when civil lawsuits don’t work, you instantly have a very different, actually much worse market, even with the same individuals. This is why it is not really reducible to the individuals. The rules, sure, and then the rule enforcers, and the things people do when the rules are not so well enforced (i.e. sell and buy to trusted buddies) and so on.
For example I saw in post-Soviet countries how the lack of functional civil lawsuit system meant lack of capital investment i.e. every enterpreneur could only use capital he personally owned or was loaned by a cousin or invested by a gangster who did not have to rely on courts to enforce contracts (rather goons). It was a vastly different and vastly worse market than the one you know because capital investment is capitalism’s lifeblood.
This is just one example. It’s complicated, only simple if you work from a self-sufficient frontier-homesteader basis, which is the exception.
There is a tiny but interesting school of econ (econ history) called New Instutitionalism. https://en.wikipedia.org/wiki/Douglass_North#Institutions_.281991.29 Ages ago I saw a PhD paper where a guy took the macro from there and used Austrian methodological individualism as microfoundations. It was the best thing ever, but unfortunately not published in English. My point is simply, meth. inv. is all fine for microfoundations, a useful way of analysis, but not exclusive, there are higher level, less reducible stuff on top of that.
@Jorge Dujan
In the phrase you quoted, I intended “if the market prefers it” to mean “if there are enough customers to sustain that product”. My “the market” there is “the customers”, rather than “The Market(tm)”. I probably should have used a different phrase, since the phrase I used evokes a common cliche (which is probably why it came to mind instead of something more accurate).
I was going to write a point about the UK health service system here after reading this last night – mainly that it isn’t single player but apparently this has been covered. Although I would like to make a few more points regarding the NHS since there seems to be a lot of misunderstanding about what it is and what it does.
As previously stated the NHS is not a state monopoly on health care many private firms do in fact compete with the NHS for customers and they get them. Secondly the NHS isn’t funded by anyone tax and saying the taxpayer pays for it is kind of misleading. The tax payer pays for Government and Government pays for the NHS.
This is important for two reasons. Firstly the Government can be changed by the democratic will of the people, if the people were unsatisfied with the NHS they could get rid of it. Of course there is no political will to do so because, even the Conservatives managed to realize that poor people out number rich people and poor people tend to like the NHS.
Secondly of course is that while everyone pays taxes people do not pay taxes equally. Some people pay more – others pay less. Saying the taxpayer pays for the NHS is a nice way of making it sound like everyone makes a massive contribution to this service and getting people who would otherwise be worse off without it. To side with people who out of, the cynic in me says ‘greed’ and ‘narcissism’ want to get rid of it. The taxpayer no more pays for the NHS than I pay for Larry Page’s mortgage. In practice I do, true – but in actuality Larry Page pays for his mortgage and I have no say in telling him he should get a smaller house or rent instead to save me money. (Down to I could possibly not buy an Android phone until he could not pay for his mortgage but at the end of the day that is significantly less power than I have wielding a piece of paper with the name of someone I want to elect to serve me on it.)
Of course Government backing of a player make fiscal and economic sense too. In ‘In Place of Fear’ the Aneurin Beven argued this by stating that the NHS can buy things cheaper than any other player can simply due to scale. If a single private hospital wants to buy bed sheets it’s significantly more expensive for them than the NHS who wants to buy bed sheets for a few thousand hospitals across the entirety of the UK. Products always get cheaper in bulk and healthcare is no exception.
There’s also the fact the NHS was supposed to also be in some ways a private institution with a capitalistic arm. ‘Capitalism in the NHS’ I can hear the outcries now but it’s not in the way the Tories, or, the Tory-Lite New Labour Party envisage capitalism in the NHS. It was supposed to sell products overseas in much the same way the BBC has its BBC Worldwide arm. I think the original thesis was based on hearing aids because it turns out people needed those and all the ones on the market when the NHS was founded were either poor quality or abysmally expensive.
The other point is that the NHS is supposed to provide a base level of health care coverage – the universal and, if you believe it, intrinsic right everyone should have to healthcare level. Obviously the Government can’t afford to foot the bill for every possible treatment they have other things they need to purchase – such as ineffectual and massively expensive anti-terrorism operations. So the NICE system was created to justify whether medication or treatment should be provided by the NHS or not. (I believe it’s something like £80,000 per Year of Life saved. Which is pretty high when you consider most people aren’t worth £80k a year according to capitalism anyway.) Anyone who thinks they are worth more than that can, of course, go private – either outright buying their own healthcare – or as is more the case buying insurance.
On a final point of course most people don’t pay for their healthcare, they buy insurance and the insurance pays for their healthcare. The example given of hospitals keeping people alive to make more money under private healthcare is of course equally flawed as the previous since the hospital doesn’t make money from their patients but from the people gambling with how long they are going to live for and how expensive their end of life care is.
Under both systems the healthcare providers have as much incentive to keep people alive and functioning as they do under the other. They are both paid for by third parties and the third parties are paid for by the patients.
Mind you I find the claim ESR invented hacker culture mildly entertaining. Seems everyone forgets about MIT Hackers these days and the ones who came before.
>Mind you I find the claim ESR invented hacker culture mildly entertaining.
Perhaps you misunderstood. “Your culture” was not in this instance the hacker culture but the latter-day makerspace culture, which I inadvertently designed (at least in part) by propagating hacker memes forward to it. AFAICT those kids mostly seem to have had very little direct contact with old-school hackers, so my transmission had extra importance there.
I think the kid got that; the incident would become more startling (and to me a bit disturbing) if he made the same error you appear to have.
That said, while claiming that I designed today’s hacker culture would be wrong, it wouldn’t be obviously
crazywrong. Given enough ignorance ofmysources I think a person could be pardoned for making that error, especially a person under 30 or so. If this ever occurs in my presence, I will of course correct it.> Perhaps you misunderstood. “Your culture” was not in this instance the hacker culture but the latter-day makerspace culture, which I inadvertently designed (at least in part) by propagating hacker memes forward to it. AFAICT those kids mostly seem to have had very little direct contact with old-school hackers, so my transmission had extra importance there.
Well, for one thing, you’ve got a funny definition of “designed”. And I’m not sure how exactly you are drawing the line between “distinct culture with memes propagated forward into it from hacker culture” vs “evolution of hacker culture”. Why would direct contact be required?
>Why would direct contact be required?
Clearly it wasn’t
required; the makerspace kids are a lot like hackers, and know that they are, andlikethat they are. In that respect, at least, I did a good job of forward transmission.More direct contact would have hedged against the possibility that I inadvertently distorted or narrowed what I passed on to them, that’s all. I worry a little sometimes that what I did for the propagation of hacker culture might be a bit like what population biologists call a genetic bottleneck – evolution, yes, but a kind that discards a lot of previous genetic variation. Genetic bottlenecks leave species that are homogenous and terrifically well adapted to a specific set of circumstances, but fragile – prone to be wiped out by disease or minor ecological shifts.
Then I go to something like FOSSCON and a see a really vigorous, happy, flourishing hacker population that is doing neat stuff and
trying new things, and I’m reassured. Adaptive radiation into new niches in action; it’s a good thing.Why not just get a job? You’d be surprised how far $1500 a week goes toward paying the bills. Millions of us do/did it and never made a web site asking for money. Do it for 5 years and then write a book about that. As the song says, you don’t have to live like a refugee.
>Why not just get a job?
To quote the page: “Unlike most artists, it wouldn’t be difficult for me to get a well-paid job – but then I’d have to work on what an employer wants, rather than what the world actually needs.”
Would you care to add some context for those who happens to live outside of North America? I thought obamacare is just yet another health insurance scheme – how can it possibly kill lawyer job? And what does it have to do with statistics?
>I thought obamacare is just yet another health insurance scheme – how can it possibly kill lawyer job?
It has loaded such high costs on employers that they’re desperate to dump full-time employees and hire contractors, who if they work less than 30 hours a week don’t trigger the regulations that impose the costs.
And of course as with every single politically rigged attempt to lower the price of commodity X ever, the price of commodity X has skyrocketed. So people earning fewer dollars a week are forced to spend more of them on health insurance.
> I’ve seen the pictures of the Cuban filth and cockroaches;
Come on now, I hoped at least you are better than that. I’ve seen pics of a little green man riding on the ponies – it doesn’t make it valid argument for discussion about extraterrestrial life.
> It has loaded such high costs on employers that they’re desperate to dump full-time employees and hire contractors, who if they work less than 30 hours a week don’t trigger the regulations that impose the costs.
Here in some cases I have heard of downsizing was accompanied by suggestion that former employees form single-person companies / consultancies that would work for their former employer… what isn’t said that it is without lot of benefits that wage employee has (like medical insurance and social security), and of course higher work costs that pay for it. Working around the law, as is.
I guess that wasn’t possible in yours case?
It’s far belated at this point, but…
Scott Alexander did a deep dive on this issue about two years ago which you might be interested in. (His conclusion, along with some excellent bear puns, was that reports of happy old folks being shuffled off for the sake of convenience are unsupportable.)
> The article classifies patients whose lives were shortened by only a few horrible hours as “euthanized without consent”.
Of course it does. The “christian” position is that
obviouslyGod would have come through at the last minute with a miracle to bring them back to full health if only those horrible atheistic doctors had allowed those last few hours to pass.Anyanti-euthanasia writing must be looked at with suspicion of being tainted by this kind of ideological bias.>Any anti-euthanasia writing must be looked at with suspicion of being tainted by this kind of ideological bias.
You raise a valid point. I will re-tune my bullshit filters accordingly.
@Random832
“The “christian” position is that obviously God would have come through at the last minute with a miracle to bring them back to full health if only those horrible atheistic doctors had allowed those last few hours to pass.”
As far as I know, the Christian position is that your horrible last hours are God’s gift and you are not allowed to interfere with His work. And indeed, such people often also refuse other medical treatment.
I liked that Scott Alexander piece. It was quite accurate (I live in the Netherlands). The biggest complaint from old people is
nota fear for unwanted euthanasia, but for a denial of euthanasia when wanted. Too many doctors refuse to allow euthanasia on (religious) principle, leaving their dying patient no recourse. Some religiously based caring homes are notorious for that.BREAKING: Patreon cracked:
http://arstechnica.com/security/2015/10/gigabytes-of-user-data-from-hack-of-patreon-donations-site-dumped-online/
>BREAKING: Patreon cracked:
So far, I think I am not affected. First reports indicate it was patron data cracked and I’m not actually registered as a patron – I know because it still prompts me to do this on the version of my page I can see.
At the very least, according to https://haveibeenpwned.com/ your email address is present in the dump (mine too). Probably any private messages between you and your patrons are there as well.
>At the very least, according to https://haveibeenpwned.com/ your email address is present in the dump (mine too). Probably any private messages between you and your patrons are there as well.
My email address is already public, and my count of private messages is zero.
@ esr
> My email address is already public
This reminds me of a question I’ve considered asking you (sorry for doing this so often). Your home page reads:
I don’t know how to use GPG yet, but want to learn; and I’ve already found a couple of tutorials. Suppose that, once I’ve set GPG up, I decide to send you an encrypted message as a test. But suppose I did something wrong when setting it up. Could that damage you somehow?
@Jorge I can think of two possibilities, both of them remote.
One would be if you held some piece of information that Eric wanted you to keep in confidence, and sent it somewhere in a form readable by an adversary, when you meant to encrypt it.
The other would be to clutter up public keyservers with useless or misleading information about Eric’s key, such as by uploading a key that looks like it belongs to him but doesn’t, or adding a bunch of useless signatures so his key becomes huge. But anybody can do this to anyone at any time. It’s just part of how the keyserver system works.
@ Daniel Franke
Thanks for the info. I guess that, for the time being, I’ll stick to my current policy: communicating with Eric exclusively via A&D. :-) After all, I can’t think of anything I’d say to him that I’m not willing to say publicly, right here. |
6,179 | 对 Linux 内核的发展方向的展望 | http://www.eweek.com/enterprise-apps/a-look-at-whats-next-for-the-linux-kernel.html | 2015-09-09T08:06:00 | [
"内核",
"Linux"
] | https://linux.cn/article-6179-1.html | 
**Linux 4.2 内核涉及到史上最多的贡献者数量,内核开发者 Jonathan Corbet 如是说。**
西雅图报道。Linux 内核持续增长:代码量在增加,代码贡献者数量也在增加。而随之而来的一些挑战需要处理一下。以上是 Jonathan Corbet 在今年的 LinuxCon 的内核年度报告上提出的主要观点。以下是他的主要演讲内容:
Linux 4.2 内核已经于上月底释出。Corbet 强调有 1569 名开发者为这个版本贡献了代码,其中 277 名是第一次提交代码。
越来越多的开发者的加入,内核更新非常快,Corbet 估计现在大概 63 天就能产生一个新的内核里程碑。
Linux 4.2 涉及多方面的更新。其中一个就是引进了 OverLayFS,这是一种只读型文件系统,它可以实现在一个容器之上再放一个容器。
网络系统对小包传输性能也有了提升,这对于高频金融交易而言非常重要。提升的方面主要集中在减小处理数据包的时间的能耗。
依然有新的驱动中加入内核。在每个内核发布周期,平均会有 60 到 80 个新增或升级驱动中加入。
另一个主要更新是实时内核补丁,这个特性在 4.0 版首次引进,好处是系统管理员可以在生产环境中打上内核补丁而不需要重启系统。当补丁所需要的元素都已准备就绪,打补丁的过程会在后台持续而稳定地进行。
**Linux 安全, IoT 和其他关注点**
过去一年中,安全问题在开源社区是一个很热的话题,这都归因于那些引发高度关注的事件,比如 Heartbleed 和 Shellshock。
“我毫不怀疑 Linux 代码对这些方面的忽视会产生一些令人不悦的问题”,Corbet 原话。
他强调说过去 10 年间有超过 3 百万行代码不再被开发者修改,而产生 Shellshock 漏洞的代码的年龄已经是 20 岁了,近年来更是无人问津。
另一个关注点是 2038 问题,Linux 界的“千年虫”,如果不解决,2000 年出现过的问题还会重现。2038 问题说的是在 2038 年一些 Linux 和 Unix 机器会死机(LCTT译注:32 位系统记录的时间,在2038年1月19日星期二晚上03:14:07之后的下一秒,会变成负数)。Corbet 说现在离 2038 年还有 23 年时间,现在部署的系统都会考虑 2038 问题。
Linux 已经启动一些初步的方案来修复 2038 问题了,但做的还远远不够。“现在就要修复这个问题,而不是等 20 年后把这个头疼的问题留给下一代解决,我们却享受着退休的美好时光”。
物联网(IoT)也是 Linux 关注的领域,Linux 是物联网嵌入式操作系统的主要占有者,然而这并没有什么卵用。Corget 认为日渐臃肿的内核对于未来的物联网设备来说肯定过于庞大。
现在有一个项目就是做内核最小化的,获取足够的支持对于这个项目来说非常重要。
“除了 Linux 之外,也有其他项目可以做物联网,但那些项目不会像 Linux 一样开放”,Corbet 说,“我们不能指望 Linux 在物联网领域一直保持优势,我们需要靠自己的努力去做到这点,我们需要注意不能让内核变得越来越臃肿。”
---
via: <http://www.eweek.com/enterprise-apps/a-look-at-whats-next-for-the-linux-kernel.html>
作者:[Sean Michael Kerner](http://www.eweek.com/cp/bio/Sean-Michael-Kerner/) 译者:[bazz2](https://github.com/bazz2) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,180 | Debian GNU/Linux,22 年未完的美妙旅程 | http://www.tecmint.com/happy-birthday-to-debian-gnu-linux/ | 2015-09-09T09:07:01 | [
"Debian"
] | https://linux.cn/article-6180-1.html | 在2015年8月16日, Debian项目组庆祝了 Debian 的22周年纪念日;这也是开源世界历史最悠久、热门的发行版之一。 Debian项目于1993年由Ian Murdock创立。彼时,Slackware 作为最早的 Linux 发行版已经名声在外。

*22岁生日快乐! Debian Linux!*
Ian Ashly Murdock, 一个美国职业软件工程师, 在他还是普渡大学的学生时构想出了 Debian 项目的计划。他把这个项目命名为 Debian 是由于这个名字组合了他彼时女友的名字 Debra Lynn 和他自己的名字 Ian。 他之后和 Lynn 结婚并在2008年1月离婚。

*Debian 创始人:Ian Murdock*
Ian 目前是 ExactTarget 的平台与开发社区的副总裁。
Debian (如同Slackware一样) 都是由于当时缺乏满足合乎标准的发行版才应运而生的。 Ian 在一次采访中说:“免费提供一流的产品会是 Debian 项目的唯一使命。 尽管过去的 Linux 发行版均不尽然可靠抑或是优秀。 我印象里...比如在不同的文件系统间移动文件, 处理大型文件经常会导致内核出错。 但是 Linux 其实是很可靠的, 自由的源代码让这个项目本质上很有前途。”
"我记得过去我像其他想解决问题的人一样, 想在家里运行一个像 UNIX 的东西。 但那是不可能的, 无论是经济上还是法律上或是别的什么角度。 然后我就听闻了 GNU 内核开发项目, 以及这个项目是如何没有任何法律纷争", Ian 补充到。 他早年在开发 Debian 时曾被自由软件基金会(FSF)资助, 这份资助帮助 Debian 取得了长足的发展; 尽管一年后由于学业原因 Ian 退出了 FSF 转而去完成他的学位。
### Debian开发历史
* **Debian 0.01 – 0.09** : 发布于 1993 年八月 – 1993 年十二月。
* **Debian 0.91** : 发布于 1994 年一月。 有了原始的包管理系统, 没有依赖管理机制。
* **Debian 0.93 rc5** : 发布于 1995 年三月。 “现代”意义的 Debian 的第一次发布, 在基础系统安装后会使用dpkg 安装以及管理其他软件包。
* **Debian 0.93 rc6**: 发布于 1995 年十一月。 最后一次 a.out 发布, deselect 机制第一次出现, 有60位开发者在彼时维护着软件包。
* **Debian 1.1**: 发布于 1996 年六月。 项目代号 – Buzz, 软件包数量 – 474, 包管理器 dpkg, 内核版本 2.0, ELF 二进制。
* **Debian 1.2**: 发布于 1996 年十二月。 项目代号 – Rex, 软件包数量 – 848, 开发者数量 – 120。
* **Debian 1.3**: 发布于 1997 年七月。 项目代号 – Bo, 软件包数量 974, 开发者数量 – 200。
* **Debian 2.0**: 发布于 1998 年七月。 项目代号 - Hamm, 支持构架 – Intel i386 以及 Motorola 68000 系列, 软件包数量: 1500+, 开发者数量: 400+, 内置了 glibc。
* **Debian 2.1**: 发布于1999 年三月九日。 项目代号 – slink, 支持构架 - Alpha 和 Sparc, apt 包管理器开始成型, 软件包数量 – 2250。
* **Debian 2.2**: 发布于 2000 年八月十五日。 项目代号 – Potato, 支持构架 – Intel i386, Motorola 68000 系列, Alpha, SUN Sparc, PowerPC 以及 ARM 构架。 软件包数量: 3900+ (二进制) 以及 2600+ (源代码), 开发者数量 – 450。 有一群人在那时研究并发表了一篇论文, 论文展示了自由软件是如何在被各种问题包围的情况下依然逐步成长为优秀的现代操作系统的。
* **Debian 3.0**: 发布于 2002 年七月十九日。 项目代号 – woody, 支持构架新增 – HP, PA\_RISC, IA-64, MIPS 以及 IBM, 首次以DVD的形式发布, 软件包数量 – 8500+, 开发者数量 – 900+, 支持加密。
* **Debian 3.1**: 发布于 2005 年六月六日。 项目代号 – sarge, 支持构架 – 新增 AMD64(非官方渠道发布), 内核 – 2.4 以及 2.6 系列, 软件包数量: 15000+, 开发者数量 : 1500+, 增加了诸如 OpenOffice 套件, Firefox 浏览器, Thunderbird, Gnome 2.8, 支持: RAID, XFS, LVM, Modular Installer。
* **Debian 4.0**: 发布于 2007 年四月八日。 项目代号 – etch, 支持构架 – 如前,包括 AMD64。 软件包数量: 18,200+ 开发者数量 : 1030+, 图形化安装器。
* **Debian 5.0**: 发布于 2009 年二月十四日。 项目代号 – lenny, 支持构架 – 新增 ARM。 软件包数量: 23000+, 开发者数量: 1010+。
* **Debian 6.0**: 发布于 2009 年七月二十九日。 项目代号 – squeeze, 包含的软件包: 内核 2.6.32, Gnome 2.3. Xorg 7.5, 同时包含了 DKMS, 基于依赖包支持。 支持构架 : 新增 kfreebsd-i386 以及 kfreebsd-amd64, 基于依赖管理的启动过程。
* **Debian 7.0**: 发布于 2013 年五月四日。 项目代号: wheezy, 支持 Multiarch, 私有云工具, 升级了安装器, 移除了第三方软件依赖, 全功能多媒体套件-codec, 内核版本 3.2, Xen Hypervisor 4.1.4 ,软件包数量: 37400+。
* **Debian 8.0**: 发布于 2015 年五月二十五日。 项目代号: Jessie, 将 Systemd 作为默认的初始化系统, 内核版本 3.16, 增加了快速启动(fast booting), service进程所依赖的 cgroups 使隔离部分 service 进程成为可能, 43000+ 软件包。 Sysvinit 初始化工具在 Jessie 中可用。
**注意**: Linux的内核第一次是在1991 年十月五日被发布, 而 Debian 的首次发布则在1993 年九月十三日。 所以 Debian 已经在只有24岁的 Linux 内核上运行了整整22年了。
### Debian 的那些事
1994年管理和重整了 Debian 项目以使得其他开发者能更好地加入,所以在那一年并没有发布面向用户的更新, 当然, 内部版本肯定是有的。
Debian 1.0 从来就没有被发布过。 一家 CD-ROM 的生产商错误地把某个未发布的版本标注为了 1.0, 为了避免产生混乱, 原本的 Debian 1.0 以1.1的面貌发布了。 从那以后才有了所谓的官方CD-ROM的概念。
每个 Debian 新版本的代号都是玩具总动员里某个角色的名字哦。
Debian 有四种可用版本: 旧稳定版(old stable), 稳定版(stable), 测试版(testing) 以及 试验版(experimental)。 始终如此。
Debian 项目组一直工作在不稳定发行版上, 这个不稳定版本始终被叫做Sid(玩具总动员里那个邪恶的臭小孩)。 Sid是unstable版本的永久名称, 同时Sid也取自'Still In Development"(译者:还在开发中)的首字母。 Sid 将会成为下一个稳定版, 当前的稳定版本代号为 jessie。
Debian 的官方发行版只包含开源并且自由的软件, 绝无其他东西. 不过 contrib 和非自由软件包使得安装那些本身自由但是其依赖的软件包不自由(contrib)的软件和非自由软件成为了可能。
Debian 是一堆Linux 发行版之母。 举几个例子:
* Damn Small Linux
* KNOPPIX
* Linux Advanced
* MEPIS
* Ubuntu
* 64studio (不再活跃开发)
* LMDE
Debian 是世界上最大的非商业 Linux 发行版。它主要是由C编写的(32.1%), 一并的还有其他70多种语言。

*Debian 开发语言贡献表,图片来源: [Xmodulo](http://xmodulo.com/2013/08/interesting-facts-about-debian-linux.html)*
Debian 项目包含6,850万行代码, 以及 450万行空格和注释。
国际空间站放弃了 Windows 和红帽子, 进而换成了 Debian - 在上面的宇航员使用落后一个版本的稳定发行版, 目前是 squeeze; 这么做是为了稳定程度以及来自 Debian 社区的雄厚帮助支持。
感谢上帝! 我们差点就听到来自国际空间宇航员面对 Windows Metro 界面的尖叫了 :P
#### 黑色星期三
2002 年十一月二十日, Twente 大学的网络运营中心(NOC)着火。 当地消防部门放弃了服务器区域。 NOC维护着satie.debian.org 的网站服务器, 这个网站包含了安全、非美国相关的存档、新维护者资料、数量报告、数据库等等;这一切都化为了灰烬。 之后这些服务由 Debian 重建了。
#### 未来版本
下一个待发布版本是 Debian 9, 项目代号 – Stretch, 它会带来什么还是个未知数。 满心期待吧!
有很多发行版在 Linux 发行版的历史上出现过一瞬间然后很快消失了。 在多数情况下, 维护一个日渐庞大的项目是开发者们面临的挑战。 但这对 Debian 来说不是问题。 Debian 项目有全世界成百上千的开发者、维护者。 它在 Linux 诞生的之初起便一直存在。
Debian 在 Linux 生态环境中的贡献是难以用语言描述的。 如果 Debian 没有出现过, 那么 Linux 世界将不会像现在这样丰富和用户友好。 Debian 是为数不多可以被认为安全可靠又稳定的发行版,是作为网络服务器完美选择。
这仅仅是 Debian 的一个开始。 它走过了这么长的征程, 并将一直走下去。 未来即是现在! 世界近在眼前! 如果你到现在还从来没有使用过 Debian, 我只想问, 你还再等什么? 快去下载一份镜像试试吧, 我们会在此守候遇到任何问题的你。
* [Debian 主页](https://www.debian.org/)
---
via: <http://www.tecmint.com/happy-birthday-to-debian-gnu-linux/>
作者:[Avishek Kumar](http://www.tecmint.com/author/avishek/) 译者:[jerryling315](http://moelf.xyz) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,186 | 如何在 CentOS 7 上安装开源 ITIL 门户 iTOP | http://linoxide.com/tools/setup-itop-centos-7/ | 2015-09-10T09:22:00 | [
"iTOP",
"ITIL"
] | /article-6186-1.html | iTOP是一个简单的基于Web的开源IT服务管理工具。它有所有的ITIL功能,包括服务台、配置管理、事件管理、问题管理、变更管理和服务管理。iTOP依赖于Apache/IIS、MySQL和PHP,因此它可以运行在任何支持这些软件的操作系统中。因为iTOP是一个Web程序,因此你不必在用户的PC端任何客户端程序。一个简单的浏览器就足够每天的IT环境操作了。
我们要在一台有满足基本需求的LAMP环境的CentOS 7上安装和配置iTOP。
### 下载 iTOP
iTOP的下载包现在在SourceForge上,我们可以从这获取它的官方[链接](http://www.combodo.com/spip.php?page=rubrique&id_rubrique=8)。

我们从这里的连接用wget命令获取压缩文件。
```
[root@centos-007 ~]# wget http://downloads.sourceforge.net/project/itop/itop/2.1.0/iTop-2.1.0-2127.zip
```
### iTop扩展和网络安装
使用unzip命令解压到apache根目录下的itop文件夹下。
```
[root@centos-7 ~]# ls
iTop-2.1.0-2127.zip
[root@centos-7 ~]# unzip iTop-2.1.0-2127.zip -d /var/www/html/itop/
```
列出安装包中的内容。
```
[root@centos-7 ~]# ls -lh /var/www/html/itop/
total 68K
-rw-r--r--. 1 root root 1.4K Dec 17 2014 INSTALL
-rw-r--r--. 1 root root 35K Dec 17 2014 LICENSE
-rw-r--r--. 1 root root 23K Dec 17 2014 README
drwxr-xr-x. 19 root root 4.0K Jul 14 13:10 web
```
这些是我们可以安装的扩展。
```
[root@centos-7 2.x]# ls
authent-external itop-backup itop-config-mgmt itop-problem-mgmt itop-service-mgmt-provider itop-welcome-itil
authent-ldap itop-bridge-virtualization-storage itop-datacenter-mgmt itop-profiles-itil itop-sla-computation version.xml
authent-local itop-change-mgmt itop-endusers-devices itop-request-mgmt itop-storage-mgmt wizard-icons
installation.xml itop-change-mgmt-itil itop-incident-mgmt-itil itop-request-mgmt-itil itop-tickets
itop-attachments itop-config itop-knownerror-mgmt itop-service-mgmt itop-virtualization-mgmt
```
在解压的目录下,使用如下的 cp 命令将不同的数据模型从web 下的 datamodels 目录下复制到 extensions 目录,来迁移需要的扩展。
```
[root@centos-7 2.x]# pwd
/var/www/html/itop/web/datamodels/2.x
[root@centos-7 2.x]# cp -r itop-request-mgmt itop-service-mgmt itop-service-mgmt itop-config itop-change-mgmt /var/www/html/itop/web/extensions/
```
### 安装 iTop web界面
大多数服务端设置和配置已经完成了。最后我们安装web界面来完成安装。
打开浏览器使用ip地址或者完整域名来访问iTop 的 web目录。
```
http://servers_ip_address/itop/web/
```
你会被重定向到iTOP的web安装页面。让我们按照要求配置,就像在这篇教程中做的那样。
#### 验证先决要求
这一步你就会看到验证完成的欢迎界面。如果你看到了一些警告信息,你需要先安装这些软件来解决这些问题。

这一步有一个叫php mcrypt的可选包丢失了。下载下面的rpm包接着尝试安装php mcrypt包。
```
[root@centos-7 ~]#yum localinstall php-mcrypt-5.3.3-1.el6.x86_64.rpm libmcrypt-2.5.8-9.el6.x86_64.rpm.
```
成功安装完php-mcrypt后,我们需要重启apache服务,接着刷新页面,这时验证应该已经OK。
#### 安装或者升级 iTop
现在我们要在没有安装iTOP的服务器上选择全新安装。

#### iTop 许可协议
勾选接受 iTOP所有组件的许可协议,并点击“NEXT”。

#### 数据库配置
现在我们输入数据库凭据来配置数据库连接,接着选择如下选择创建新数据库。

#### 管理员账户
这一步中我们会输入它的登录信息来配置管理员账户。

#### 杂项参数
让我们选择额外的参数来选择你是否需要安装一个带有演示内容的数据库或者使用全新的数据库,接着下一步。

### iTop 配置管理
下面的选项允许你配置在iTOP要管理的元素类型,像CMDB、数据中心设备、存储设备和虚拟化这些东西在iTOP中是必须的。

#### 服务管理
选择一个最能描述你的IT设备和环境之间的关系的选项。因此我们这里选择为服务提供商的服务管理。

#### iTop Tickets 管理
从不同的可用选项我们选择符合ITIL Tickets管理选项来管理不同类型的用户请求和事件。

#### 改变管理选项
选择不同的ticket类型以便管理可用选项中的IT设备变更。我们选择ITTL变更管理选项。

#### iTop 扩展
这一节我们选择额外的扩展来安装或者不选直接跳过。

### 准备开始web安装
现在我们开始准备安装先前先前选择的组件。我们也可以下拉这些安装参数来浏览我们的配置。
确认安装参数后点击安装按钮。

让我们等待进度条来完成安装步骤。它也许会花费几分钟来完成安装步骤。

### iTop安装完成
我们的iTOP安装已经完成了,只要如下一个简单的手动操作就可以进入到iTOP。

### 欢迎来到iTop (IT操作门户)

### iTop 面板
你这里可以配置任何东西,服务、计算机、通讯录、位置、合同、网络设备等等。你可以创建你自己的。事实是刚安装的CMDB模块是每一个IT人员的必备模块。

### 总结
ITOP是一个最棒的开源桌面服务解决方案。我们已经在CentOS 7上成功地安装和配置了。因此,iTOP最强大的一方面是它可以很简单地通过扩展来自定义。如果你在安装中遇到任何问题欢迎评论。
---
via: <http://linoxide.com/tools/setup-itop-centos-7/>
作者:[Kashif Siddique](http://linoxide.com/author/kashifs/) 译者:[geekpi](https://github.com/geekpi) 校对:[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: /tools/setup-itop-centos-7/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b83275834c0>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,187 | RHCSA 系列(三): 如何管理 RHEL7 的用户和组 | http://www.tecmint.com/rhcsa-exam-manage-users-and-groups/ | 2015-09-10T10:56:00 | [
"RHCSA"
] | https://linux.cn/article-6187-1.html | 和管理其它Linux服务器一样,管理一个 RHEL 7 服务器要求你能够添加、修改、暂停或删除用户帐户,并且授予他们执行其分配的任务所需的文件、目录、其它系统资源所必要的权限。

*RHCSA: 用户和组管理 – Part 3*
### 管理用户帐户
如果想要给RHEL 7 服务器添加账户,你需要以root用户执行如下两条命令之一:
```
# adduser [new_account]
# useradd [new_account]
```
当添加新的用户帐户时,默认会执行下列操作。
* 它/她的主目录就会被创建(一般是"/home/用户名",除非你特别设置)
* 一些隐藏文件 如`.bash_logout`, `.bash_profile` 以及 `.bashrc` 会被复制到用户的主目录,它们会为用户的回话提供环境变量。你可以进一步查看它们的相关细节。
* 会为您的账号添加一个邮件池目录。
* 会创建一个和用户名同样的组(LCTT 译注:除非你给新创建的用户指定了组)。
用户帐户的全部信息被保存在`/etc/passwd`文件。这个文件以如下格式保存了每一个系统帐户的所有信息(字段以“:”分割)
```
[username]:[x]:[UID]:[GID]:[Comment]:[Home directory]:[Default shell]
```
* `[username]` 和`[Comment]` 其意自明,就是用户名和备注
* 第二个‘x’表示帐户的启用了密码保护(记录在`/etc/shadow`文件),密码用于登录`[username]`
* `[UID]` 和`[GID]`是整数,它们表明了`[username]`的用户ID 和所属的主组ID
最后。
* `[Home directory]`显示`[username]`的主目录的绝对路径
* `[Default shell]` 是当用户登录系统后使用的默认shell
另外一个你必须要熟悉的重要的文件是存储组信息的`/etc/group`。和`/etc/passwd`类似,也是每行一个记录,字段由“:”分割
```
[Group name]:[Group password]:[GID]:[Group members]
```
* `[Group name]` 是组名
* 这个组是否使用了密码 (如果是"x"意味着没有)
* `[GID]`: 和`/etc/passwd`中一样
* `[Group members]`:用户列表,使用“,”隔开。里面包含组内的所有用户
添加过帐户后,任何时候你都可以通过 usermod 命令来修改用户账户信息,基本的语法如下:
```
# usermod [options] [username]
```
相关阅读
* [15 ‘useradd’ 命令示例](http://www.tecmint.com/add-users-in-linux/)
* [15 ‘usermod’ 命令示例](http://www.tecmint.com/usermod-command-examples/)
#### 示例1 : 设置帐户的过期时间
如果你的公司有一些短期使用的帐户或者你要在有限时间内授予访问,你可以使用 `--expiredate` 参数 ,后加YYYY-MM-DD 格式的日期。为了查看是否生效,你可以使用如下命令查看
```
# chage -l [username]
```
帐户更新前后的变动如下图所示

*修改用户信息*
#### 示例 2: 向组内追加用户
除了创建用户时的主用户组,一个用户还能被添加到别的组。你需要使用 -aG或 -append -group 选项,后跟逗号分隔的组名。
#### 示例 3: 修改用户主目录或默认Shell
如果因为一些原因,你需要修改默认的用户主目录(一般为 /home/用户名),你需要使用 -d 或 -home 参数,后跟绝对路径来修改主目录。
如果有用户想要使用其它的shell来取代默认的bash(比如zsh)。使用 usermod ,并使用 -shell 的参数,后加新的shell的路径。
#### 示例 4: 展示组内的用户
当把用户添加到组中后,你可以使用如下命令验证属于哪一个组
```
# groups [username]
# id [username]
```
下面图片的演示了示例2到示例4

*添加用户到额外的组*
在上面的示例中:
```
# usermod --append --groups gacanepa,users --home /tmp --shell /bin/sh tecmint
```
如果想要从组内删除用户,取消 `--append` 选项,并使用 `--groups` 和你要用户属于的组的列表。
#### 示例 5: 通过锁定密码来停用帐户
如果想要关闭帐户,你可以使用 -l(小写的L)或 -lock 选项来锁定用户的密码。这将会阻止用户登录。
#### 示例 6: 解锁密码
当你想要重新启用帐户让它可以继续登录时,使用 -u 或 –unlock 选项来解锁用户的密码,就像示例5 介绍的那样
```
# usermod --unlock tecmint
```
下面的图片展示了示例5和示例6:

*锁定上锁用户*
#### 示例 7:删除组和用户
如果要删除一个组,你需要使用 groupdel ,如果需要删除用户 你需要使用 userdel (添加 -r 可以删除主目录和邮件池的内容)。
```
# groupdel [group_name] # 删除组
# userdel -r [user_name] # 删除用户,并删除主目录和邮件池
```
如果一些文件属于该组,删除组时它们不会也被删除。但是组拥有者的名字将会被设置为删除掉的组的GID。
### 列举,设置,并且修改标准 ugo/rwx 权限
著名的 [ls 命令](http://linux.cn/article-5349-1.html) 是管理员最好的助手. 当我们使用 -l 参数, 这个工具允许您以长格式(或详细格式)查看一个目录中的内容。
而且,该命令还可以用于单个文件中。无论哪种方式,在“ls”输出中的前10个字符表示每个文件的属性。
这10个字符序列的第一个字符用于表示文件类型:
* – (连字符): 一个标准文件
* d: 一个目录
* l: 一个符号链接
* c: 字符设备(将数据作为字节流,例如终端)
* b: 块设备(以块的方式处理数据,例如存储设备)
文件属性的接下来的九个字符,分为三个组,被称为文件模式,并注明读(r)、写(w)、和执行(x)权限授予文件的所有者、文件的所有组、和其它的用户(通常被称为“世界”)。
同文件上的读取权限允许文件被打开和读取一样,如果目录同时有执行权限时,就允许其目录内容被列出。此外,如果一个文件有执行权限,就允许它作为一个程序运行。
文件权限是通过chmod命令改变的,它的基本语法如下:
```
# chmod [new_mode] file
```
new\_mode 是一个八进制数或表达式,用于指定新的权限。随意试试各种权限看看是什么效果。或者您已经有了一个更好的方式来设置文件的权限,你也可以用你自己的方式自由地试试。
八进制数可以基于二进制等价计算,可以从所需的文件权限的文件的所有者、所有组、和世界组合成。每种权限都等于2的幂(R = 2^2,W = 2^1,x = 2^0),没有时即为0。例如:

*文件权限*
在八进制形式下设置文件的权限,如上图所示
```
# chmod 744 myfile
```
请用马上来对比一下我们以前的计算,在更改文件的权限后,我们的实际输出为:

*长列表格式*
#### 示例 8: 寻找777权限的文件
出于安全考虑,你应该确保在正常情况下,尽可能避免777权限(任何人可读、可写、可执行的文件)。虽然我们会在以后的教程中教你如何更有效地找到您的系统的具有特定权限的全部文件,你现在仍可以组合使用ls 和 grep来获取这种信息。
在下面的例子,我们会寻找 /etc 目录下的777权限文件。注意,我们要使用[第二章:文件和目录管理](https://www.linux.cn/article-6155-1.html)中讲到的管道的知识:
```
# ls -l /etc | grep rwxrwxrwx
```

*查找所有777权限的文件*
#### 示例 9: 为所有用户指定特定权限
shell脚本,以及一些二进制文件,所有用户都应该有权访问(不只是其相应的所有者和组),应该有相应的执行权限(我们会讨论特殊情况下的问题):
```
# chmod a+x script.sh
```
**注意**: 我们可以使用表达式设置文件模式,表示用户权限的字母如“u”,组所有者权限的字母“g”,其余的为“o” ,同时具有所有权限为“a”。权限可以通过`+` 或 `-` 来授予和收回。

*为文件设置执行权限*
长目录列表还用两列显示了该文件的所有者和所有组。此功能可作为系统中文件的第一级访问控制方法:

*检查文件的所有者和所有组*
改变文件的所有者,您应该使用chown命令。请注意,您可以在同时或分别更改文件的所有组:
```
# chown user:group file
```
你可以更改用户或组,或在同时更改两个属性,但是不要忘记冒号区分,如果你想要更新其它属性,让另外的部分为空:
```
# chown :group file # 仅改变所有组
# chown user: file # 仅改变所有者
```
#### 示例 10:从一个文件复制权限到另一个文件
如果你想“克隆”一个文件的所有权到另一个,你可以这样做,使用–reference参数,如下:
```
# chown --reference=ref_file file
```
ref\_file的所有信息会复制给 file

*复制文件属主信息*
### 设置 SETGID 协作目录
假如你需要授予在一个特定的目录中拥有访问所有的文件的权限给一个特定的用户组,你有可能需要使用给目录设置setgid的方法。当setgid设置后,该真实用户的有效GID会变成属主的GID。
因此,任何访问该文件的用户会被授予该文件的属组的权限。此外,当setgid设置在一个目录中,新创建的文件继承组该目录的组,而且新创建的子目录也将继承父目录的setgid权限。
```
# chmod g+s [filename]
```
要以八进制形式设置 setgid,需要在基本权限前缀以2。
```
# chmod 2755 [directory]
```
### 总结
扎实的用户和组管理知识,以及标准和特殊的 Linux权限管理,通过实践,可以帮你快速解决 RHEL 7 服务器的文件权限问题。
我向你保证,当你按照本文所概述的步骤和使用系统文档(在本系列的[第一章 回顾基础命令及系统文档](http://www.tecmint.com/rhcsa-exam-reviewing-essential-commands-system-documentation/)中讲到), 你将掌握基本的系统管理的能力。
请随时使用下面的评论框让我们知道你是否有任何问题或意见。
---
via: <http://www.tecmint.com/rhcsa-exam-manage-users-and-groups/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[xiqingongzi](https://github.com/xiqingongzi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,193 | Linux 有问必答:如何解决 Linux 上的 Wireshark 界面僵死 | http://ask.xmodulo.com/fix-wireshark-gui-freeze-linux-desktop.html | 2015-09-11T08:18:00 | [
"Wireshark"
] | /article-6193-1.html |
>
> **问题**: 当我试图在 Ubuntu 上的 Wireshark 中打开一个 pre-recorded 数据包转储时,它的界面突然死机,在我运行 Wireshark 的终端出现了下面的错误和警告。我该如何解决这个问题?
>
>
>
```
(wireshark:3480): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GObject'
(wireshark:3480): GLib-GObject-CRITICAL **: g_object_set_qdata_full: assertion 'G_IS_OBJECT (object)' failed
(wireshark:3480): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkRange'
(wireshark:3480): Gtk-CRITICAL **: gtk_range_get_adjustment: assertion 'GTK_IS_RANGE (range)' failed
(wireshark:3480): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkOrientable'
(wireshark:3480): Gtk-CRITICAL **: gtk_orientable_get_orientation: assertion 'GTK_IS_ORIENTABLE (orientable)' failed
(wireshark:3480): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkScrollbar'
(wireshark:3480): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GtkWidget'
(wireshark:3480): GLib-GObject-WARNING **: invalid unclassed pointer in cast to 'GObject'
(wireshark:3480): GLib-GObject-CRITICAL **: g_object_get_qdata: assertion 'G_IS_OBJECT (object)' failed
(wireshark:3480): Gtk-CRITICAL **: gtk_widget_set_name: assertion 'GTK_IS_WIDGET (widget)' failed
```
Wireshark 是一个基于 GUI 的数据包捕获和嗅探工具。该工具被网络管理员普遍使用,网络安全工程师或开发人员对于各种任务的数据包级的网络分析是必需的,例如在网络故障,漏洞测试,应用程序调试,或逆向协议工程是必需的。 Wireshark 允许实时记录数据包,并通过便捷的图形用户界面浏览他们的协议首部和有效负荷。

这是 Wireshark 的 UI,尤其是在 Ubuntu 桌面下运行时,当你向上或向下滚动分组列表视图时,或开始加载一个 pre-recorded 包转储文件时,有时会挂起或冻结,并出现以下错误。

显然,这个错误是由 Wireshark 和叠加滚动条之间的一些不兼容造成的,在最新的 Ubuntu 桌面还没有被解决(例如,Ubuntu 15.04 的桌面)。
一种避免 Wireshark 的 UI 卡死的办法就是 **暂时禁用叠加滚动条**。在 Wireshark 上有两种方法来禁用叠加滚动条,这取决于你在桌面上如何启动 Wireshark 的。
### 命令行解决方法
叠加滚动条可以通过设置"**LIBOVERLAY\_SCROLLBAR**"环境变量为“0”来被禁止。
所以,如果你是在终端使用命令行启动 Wireshark 的,你可以在 Wireshark 中禁用叠加滚动条,如下所示。
打开你的 .bashrc 文件,并定义以下 alias。
```
alias wireshark="LIBOVERLAY_SCROLLBAR=0 /usr/bin/wireshark"
```
### 桌面启动解决方法
如果你是使用桌面启动器启动的 Wireshark,你可以编辑它的桌面启动器文件。
```
$ sudo vi /usr/share/applications/wireshark.desktop
```
查找以"Exec"开头的行,并如下更改。
```
Exec=env LIBOVERLAY_SCROLLBAR=0 wireshark %f
```
虽然这种解决方法可以在系统级帮助到所有桌面用户,但升级 Wireshark 后被覆盖就没用了。如果你想保留修改的 .desktop 文件,如下所示将它复制到你的主目录。
```
$ cp /usr/share/applications/wireshark.desktop ~/.local/share/applications/
```
---
via: <http://ask.xmodulo.com/fix-wireshark-gui-freeze-linux-desktop.html>
作者:[Dan Nanni](http://ask.xmodulo.com/author/nanni) 译者:[strugglingyouth](https://github.com/strugglingyouth) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='ask.xmodulo.com', port=80): Max retries exceeded with url: /fix-wireshark-gui-freeze-linux-desktop.html (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7b83275809a0>: Failed to resolve 'ask.xmodulo.com' ([Errno -2] Name or service not known)")) | null |
6,194 | LinuxCon: 服务器操作系统的转型 | http://www.serverwatch.com/server-news/linuxcon-the-changing-role-of-the-server-os.html | 2015-09-11T09:32:00 | [
"容器"
] | https://linux.cn/article-6194-1.html | 西雅图报道。容器迟早要改变世界,以及改变操作系统的角色。这是 Wim Coekaerts 带来的 LinuxCon 演讲主题,Coekaerts 是 Oracle 公司 Linux 与虚拟化工程的高级副总裁。

Coekaerts 在开始演讲的时候拿出一张关于“桌面之年”的幻灯片,引发了现场观众的一片笑声。之后他说 2015 年很明显是容器之年,更是应用之年,应用才是容器的关键。
“你需要操作系统做什么事情?”,Coekaerts 回答现场观众:“只需一件事:运行一个应用。操作系统负责管理硬件和资源,来让你的应用运行起来。”
Coakaerts 补充说,在 Docker 容器的帮助下,我们的注意力再次集中在应用上,而在 Oracle,我们将注意力放在如何让应用更好地运行在操作系统上。
“许多人过去常常需要繁琐地安装应用,而现在的年轻人只需要按一个按钮就能让应用在他们的移动设备上运行起来”。
人们对安装企业版的软件需要这么复杂的步骤而感到惊讶,而 Docker 帮助他们脱离了这片苦海。
“操作系统的角色已经变了。” Coekaerts 说。
Docker 的出现不代表虚拟机的淘汰,容器化过程需要经过很长时间才能变得成熟,然后才能在世界范围内得到应用。
在这段时间内,容器会与虚拟机共存,并且我们需要一些工具,将应用在容器和虚拟机之间进行转换迁移。Coekaerts 举例说 Oracle 的 VirtualBox 就可以用来帮助用户运行 Docker,而它原来是被广泛用在桌面系统上的一项开源技术。现在 Docker 的 Kitematic 项目将在 Mac 上使用 VirtualBox 运行 Docker。
### 容器的开放计算计划和一次写随处部署
一个能让容器成功的关键是“一次写,随处部署”的概念。而在容器之间的互操作领域,Linux 基金会的开放计算计划(OCI)扮演一个非常关键的角色。
“使用 OCI,应用编译一次后就可以很方便地在多地运行,所以你可以将你的应用部署在任何地方”。
Coekaerts 总结说虽然在迁移到容器模型过程中会发生很多好玩的事情,但容器还没真正做好准备,他强调 Oracle 现在正在验证将产品运行在容器内的可行性,但这是一个非常艰难的过程。
“运行数据库很简单,难的是要搞定数据库所需的环境”,Coekaerts 说:“容器与虚拟机不一样,一些需要依赖底层系统配置的应用无法从主机迁移到容器中。”
另外,Coekaerts 指出在容器内调试问题与在虚拟机内调试问题也是不一样的,现在还没有成熟的工具来进行容器应用的调试。
Coekaerts 强调当容器足够成熟时,有一点很重要:不要抛弃现有的技术。组织和企业不能抛弃现有的部署好的应用,而完全投入新技术的怀抱。
“部署新技术是很困难的事情,你需要缓慢地迁移过去,能让你顺利迁移的技术才是成功的技术。”Coekaerts 说。
---
via: <http://www.serverwatch.com/server-news/linuxcon-the-changing-role-of-the-server-os.html>
作者:[Sean Michael Kerner](http://www.serverwatch.com/author/Sean-Michael-Kerner-101580.htm) 译者:[bazz2](https://github.com/bazz2) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,195 | Linux 上将出现一个新的文件系统:bcachefs | http://www.linuxveda.com/2015/08/22/linux-gain-new-file-system-bcachefs/ | 2015-09-11T07:30:00 | [
"Bcachefs",
"文件系统"
] | https://linux.cn/article-6195-1.html | 这个有 5 年历史,由 Kent Oberstreet 创建,过去属于谷歌的文件系统,最近完成了全部关键组件。Bcachefs 文件系统自称其性能和稳定性与 ext4 和 xfs 相同,而其他方面的功能又可以与 btrfs 和 zfs 相媲美。主要特性包括校验、压缩、多设备支持、缓存、快照与其他“漂亮”的特性。

Bcachefs 来自 **bcache**,这是一个块级缓存层。从 bcache 到一个功能完整的[写时复制](https://en.wikipedia.org/wiki/Copy-on-write)文件系统,堪称是一项质的转变。
对自己的问题“为什么要出一个新的文件系统”中,Kent Oberstreet 自问自答道:当我还在谷歌的时候,我与其他在 bcache 上工作的同事在偶然的情况下意识到我们正在使用的东西可以成为一个成熟文件系统的功能块,我们可以用 bcache 创建一个拥有干净而优雅设计的文件系统,而最重要的一点是,bcachefs 的主要目的就是在性能和稳定性上能与 ext4 和 xfs 匹敌,同时拥有 btrfs 和 zfs 的特性。
Overstreet 邀请人们在自己的系统上测试 bcachefs,可以通过邮件列表[通告]获取 bcachefs 的操作指南。
Linux 生态系统中文件系统几乎处于一家独大状态,Fedora 在第 16 版的时候就想用 btrfs 换掉 ext4 作为其默认文件系统,但是到现在(LCTT:都出到 Fedora 22 了)还在使用 ext4。而几乎所有 Debian 系的发行版(Ubuntu、Mint、elementary OS 等)也使用 ext4 作为默认文件系统,并且这些主流的发行版都没有替换默认文件系统的意思。
---
via: <http://www.linuxveda.com/2015/08/22/linux-gain-new-file-system-bcachefs/>
作者:[Paul Hill](http://www.linuxveda.com/author/paul_hill/) 译者:[bazz2](https://github.com/bazz2) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,197 | 你知道 Linux 内核是如何构建的吗? | https://github.com/0xAX/linux-insides/blob/master/Misc/how_kernel_compiled.md | 2015-09-11T09:26:04 | [
"Linux",
"内核"
] | https://linux.cn/article-6197-1.html | ### 介绍
我不会告诉你怎么在自己的电脑上去构建、安装一个定制化的 Linux 内核,这样的[资料](https://encrypted.google.com/search?q=building+linux+kernel#q=building+linux+kernel+from+source+code)太多了,它们会对你有帮助。本文会告诉你当你在内核源码路径里敲下`make` 时会发生什么。
当我刚刚开始学习内核代码时,[Makefile](https://github.com/torvalds/linux/blob/master/Makefile) 是我打开的第一个文件,这个文件看起来真令人害怕 :)。那时候这个 [Makefile](https://en.wikipedia.org/wiki/Make_%28software%29) 还只包含了`1591` 行代码,当我开始写本文时,内核已经是[4.2.0的第三个候选版本](https://github.com/torvalds/linux/commit/52721d9d3334c1cb1f76219a161084094ec634dc) 了。
这个 makefile 是 Linux 内核代码的根 makefile ,内核构建就始于此处。是的,它的内容很多,但是如果你已经读过内核源代码,你就会发现每个包含代码的目录都有一个自己的 makefile。当然了,我们不会去描述每个代码文件是怎么编译链接的,所以我们将只会挑选一些通用的例子来说明问题。而你不会在这里找到构建内核的文档、如何整洁内核代码、[tags](https://en.wikipedia.org/wiki/Ctags) 的生成和[交叉编译](https://en.wikipedia.org/wiki/Cross_compiler) 相关的说明,等等。我们将从`make` 开始,使用标准的内核配置文件,到生成了内核镜像 [bzImage](https://en.wikipedia.org/wiki/Vmlinux#bzImage) 结束。
如果你已经很了解 [make](https://en.wikipedia.org/wiki/Make_%28software%29) 工具那是最好,但是我也会描述本文出现的相关代码。
让我们开始吧!

(题图来自:adafruit.com)
### 编译内核前的准备
在开始编译前要进行很多准备工作。最主要的就是找到并配置好配置文件,`make` 命令要使用到的参数都需要从这些配置文件获取。现在就让我们深入内核的根 `makefile` 吧
内核的根 `Makefile` 负责构建两个主要的文件:[vmlinux](https://en.wikipedia.org/wiki/Vmlinux) (内核镜像可执行文件)和模块文件。内核的 [Makefile](https://github.com/torvalds/linux/blob/master/Makefile) 从定义如下变量开始:
```
VERSION = 4
PATCHLEVEL = 2
SUBLEVEL = 0
EXTRAVERSION = -rc3
NAME = Hurr durr I'ma sheep
```
这些变量决定了当前内核的版本,并且被使用在很多不同的地方,比如同一个 `Makefile` 中的 `KERNELVERSION` :
```
KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
```
接下来我们会看到很多`ifeq` 条件判断语句,它们负责检查传递给 `make` 的参数。内核的 `Makefile` 提供了一个特殊的编译选项 `make help` ,这个选项可以生成所有的可用目标和一些能传给 `make` 的有效的命令行参数。举个例子,`make V=1` 会在构建过程中输出详细的编译信息,第一个 `ifeq` 就是检查传递给 make 的 `V=n` 选项。
```
ifeq ("$(origin V)", "command line")
KBUILD_VERBOSE = $(V)
endif
ifndef KBUILD_VERBOSE
KBUILD_VERBOSE = 0
endif
ifeq ($(KBUILD_VERBOSE),1)
quiet =
Q =
else
quiet=quiet_
Q = @
endif
export quiet Q KBUILD_VERBOSE
```
如果 `V=n` 这个选项传给了 `make` ,系统就会给变量 `KBUILD_VERBOSE` 选项附上 `V` 的值,否则的话`KBUILD_VERBOSE` 就会为 `0`。然后系统会检查 `KBUILD_VERBOSE` 的值,以此来决定 `quiet` 和`Q` 的值。符号 `@` 控制命令的输出,如果它被放在一个命令之前,这条命令的输出将会是 `CC scripts/mod/empty.o`,而不是`Compiling .... scripts/mod/empty.o`(LCTT 译注:CC 在 makefile 中一般都是编译命令)。在这段最后,系统导出了所有的变量。
下一个 `ifeq` 语句检查的是传递给 `make` 的选项 `O=/dir`,这个选项允许在指定的目录 `dir` 输出所有的结果文件:
```
ifeq ($(KBUILD_SRC),)
ifeq ("$(origin O)", "command line")
KBUILD_OUTPUT := $(O)
endif
ifneq ($(KBUILD_OUTPUT),)
saved-output := $(KBUILD_OUTPUT)
KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
&& /bin/pwd)
$(if $(KBUILD_OUTPUT),, \
$(error failed to create output directory "$(saved-output)"))
sub-make: FORCE
$(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \
-f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
skip-makefile := 1
endif # ifneq ($(KBUILD_OUTPUT),)
endif # ifeq ($(KBUILD_SRC),)
```
系统会检查变量 `KBUILD_SRC`,它代表内核代码的顶层目录,如果它是空的(第一次执行 makefile 时总是空的),我们会设置变量 `KBUILD_OUTPUT` 为传递给选项 `O` 的值(如果这个选项被传进来了)。下一步会检查变量 `KBUILD_OUTPUT` ,如果已经设置好,那么接下来会做以下几件事:
* 将变量 `KBUILD_OUTPUT` 的值保存到临时变量 `saved-output`;
* 尝试创建给定的输出目录;
* 检查创建的输出目录,如果失败了就打印错误;
* 如果成功创建了输出目录,那么就在新目录重新执行 `make` 命令(参见选项`-C`)。
下一个 `ifeq` 语句会检查传递给 make 的选项 `C` 和 `M`:
```
ifeq ("$(origin C)", "command line")
KBUILD_CHECKSRC = $(C)
endif
ifndef KBUILD_CHECKSRC
KBUILD_CHECKSRC = 0
endif
ifeq ("$(origin M)", "command line")
KBUILD_EXTMOD := $(M)
endif
```
第一个选项 `C` 会告诉 `makefile` 需要使用环境变量 `$CHECK` 提供的工具来检查全部 `c` 代码,默认情况下会使用[sparse](https://en.wikipedia.org/wiki/Sparse)。第二个选项 `M` 会用来编译外部模块(本文不做讨论)。
系统还会检查变量 `KBUILD_SRC`,如果 `KBUILD_SRC` 没有被设置,系统会设置变量 `srctree` 为`.`:
```
ifeq ($(KBUILD_SRC),)
srctree := .
endif
objtree := .
src := $(srctree)
obj := $(objtree)
export srctree objtree VPATH
```
这将会告诉 `Makefile` 内核的源码树就在执行 `make` 命令的目录,然后要设置 `objtree` 和其他变量为这个目录,并且将这些变量导出。接着就是要获取 `SUBARCH` 的值,这个变量代表了当前的系统架构(LCTT 译注:一般都指CPU 架构):
```
SUBARCH := $(shell uname -m | sed -e s/i.86/x86/ -e s/x86_64/x86/ \
-e s/sun4u/sparc64/ \
-e s/arm.*/arm/ -e s/sa110/arm/ \
-e s/s390x/s390/ -e s/parisc64/parisc/ \
-e s/ppc.*/powerpc/ -e s/mips.*/mips/ \
-e s/sh[234].*/sh/ -e s/aarch64.*/arm64/ )
```
如你所见,系统执行 [uname](https://en.wikipedia.org/wiki/Uname) 得到机器、操作系统和架构的信息。因为我们得到的是 `uname` 的输出,所以我们需要做一些处理再赋给变量 `SUBARCH` 。获得 `SUBARCH` 之后就要设置`SRCARCH` 和 `hfr-arch`,`SRCARCH` 提供了硬件架构相关代码的目录,`hfr-arch` 提供了相关头文件的目录:
```
ifeq ($(ARCH),i386)
SRCARCH := x86
endif
ifeq ($(ARCH),x86_64)
SRCARCH := x86
endif
hdr-arch := $(SRCARCH)
```
注意:`ARCH` 是 `SUBARCH` 的别名。如果没有设置过代表内核配置文件路径的变量 `KCONFIG_CONFIG`,下一步系统会设置它,默认情况下就是 `.config` :
```
KCONFIG_CONFIG ?= .config
export KCONFIG_CONFIG
```
以及编译内核过程中要用到的 [shell](https://en.wikipedia.org/wiki/Shell_%28computing%29)
```
CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
else if [ -x /bin/bash ]; then echo /bin/bash; \
else echo sh; fi ; fi)
```
接下来就要设置一组和编译内核的编译器相关的变量。我们会设置主机的 `C` 和 `C++` 的编译器及相关配置项:
```
HOSTCC = gcc
HOSTCXX = g++
HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
HOSTCXXFLAGS = -O2
```
接下来会去适配代表编译器的变量 `CC`,那为什么还要 `HOST*` 这些变量呢?这是因为 `CC` 是编译内核过程中要使用的目标架构的编译器,但是 `HOSTCC` 是要被用来编译一组 `host` 程序的(下面我们就会看到)。
然后我们就看到变量 `KBUILD_MODULES` 和 `KBUILD_BUILTIN` 的定义,这两个变量决定了我们要编译什么东西(内核、模块或者两者):
```
KBUILD_MODULES :=
KBUILD_BUILTIN := 1
ifeq ($(MAKECMDGOALS),modules)
KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
endif
```
在这我们可以看到这些变量的定义,并且,如果们仅仅传递了 `modules` 给 `make`,变量 `KBUILD_BUILTIN` 会依赖于内核配置选项 `CONFIG_MODVERSIONS`。
下一步操作是引入下面的文件:
```
include scripts/Kbuild.include
```
文件 [Kbuild](https://github.com/torvalds/linux/blob/master/Documentation/kbuild/kbuild.txt) 或者又叫做 `Kernel Build System` 是一个用来管理构建内核及其模块的特殊框架。`kbuild` 文件的语法与 makefile 一样。文件[scripts/Kbuild.include](https://github.com/torvalds/linux/blob/master/scripts/Kbuild.include) 为 `kbuild` 系统提供了一些常规的定义。因为我们包含了这个 `kbuild` 文件,我们可以看到和不同工具关联的这些变量的定义,这些工具会在内核和模块编译过程中被使用(比如链接器、编译器、来自 [binutils](http://www.gnu.org/software/binutils/) 的二进制工具包 ,等等):
```
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
CPP = $(CC) -E
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
AWK = awk
...
...
...
```
在这些定义好的变量后面,我们又定义了两个变量:`USERINCLUDE` 和 `LINUXINCLUDE`。他们包含了头文件的路径(第一个是给用户用的,第二个是给内核用的):
```
USERINCLUDE := \
-I$(srctree)/arch/$(hdr-arch)/include/uapi \
-Iarch/$(hdr-arch)/include/generated/uapi \
-I$(srctree)/include/uapi \
-Iinclude/generated/uapi \
-include $(srctree)/include/linux/kconfig.h
LINUXINCLUDE := \
-I$(srctree)/arch/$(hdr-arch)/include \
...
```
以及给 C 编译器的标准标志:
```
KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
-fno-strict-aliasing -fno-common \
-Werror-implicit-function-declaration \
-Wno-format-security \
-std=gnu89
```
这并不是最终确定的编译器标志,它们还可以在其他 makefile 里面更新(比如 `arch/` 里面的 kbuild)。变量定义完之后,全部会被导出供其他 makefile 使用。
下面的两个变量 `RCS_FIND_IGNORE` 和 `RCS_TAR_IGNORE` 包含了被版本控制系统忽略的文件:
```
export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \
-name CVS -o -name .pc -o -name .hg -o -name .git \) \
-prune -o
export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
--exclude CVS --exclude .pc --exclude .hg --exclude .git
```
这就是全部了,我们已经完成了所有的准备工作,下一个点就是如果构建`vmlinux`。
### 直面内核构建
现在我们已经完成了所有的准备工作,根 makefile(注:内核根目录下的 makefile)的下一步工作就是和编译内核相关的了。在这之前,我们不会在终端看到 `make` 命令输出的任何东西。但是现在编译的第一步开始了,这里我们需要从内核根 makefile 的 [598](https://github.com/torvalds/linux/blob/master/Makefile#L598) 行开始,这里可以看到目标`vmlinux`:
```
all: vmlinux
include arch/$(SRCARCH)/Makefile
```
不要操心我们略过的从 `export RCS_FIND_IGNORE.....` 到 `all: vmlinux.....` 这一部分 makefile 代码,他们只是负责根据各种配置文件(`make *.config`)生成不同目标内核的,因为之前我就说了这一部分我们只讨论构建内核的通用途径。
目标 `all:` 是在命令行如果不指定具体目标时默认使用的目标。你可以看到这里包含了架构相关的 makefile(在这里就指的是 [arch/x86/Makefile](https://github.com/torvalds/linux/blob/master/arch/x86/Makefile))。从这一时刻起,我们会从这个 makefile 继续进行下去。如我们所见,目标 `all` 依赖于根 makefile 后面声明的 `vmlinux`:
```
vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE
```
`vmlinux` 是 linux 内核的静态链接可执行文件格式。脚本 [scripts/link-vmlinux.sh](https://github.com/torvalds/linux/blob/master/scripts/link-vmlinux.sh) 把不同的编译好的子模块链接到一起形成了 vmlinux。
第二个目标是 `vmlinux-deps`,它的定义如下:
```
vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
```
它是由内核代码下的每个顶级目录的 `built-in.o` 组成的。之后我们还会检查内核所有的目录,`kbuild` 会编译各个目录下所有的对应 `$(obj-y)` 的源文件。接着调用 `$(LD) -r` 把这些文件合并到一个 `build-in.o` 文件里。此时我们还没有`vmlinux-deps`,所以目标 `vmlinux` 现在还不会被构建。对我而言 `vmlinux-deps` 包含下面的文件:
```
arch/x86/kernel/vmlinux.lds arch/x86/kernel/head_64.o
arch/x86/kernel/head64.o arch/x86/kernel/head.o
init/built-in.o usr/built-in.o
arch/x86/built-in.o kernel/built-in.o
mm/built-in.o fs/built-in.o
ipc/built-in.o security/built-in.o
crypto/built-in.o block/built-in.o
lib/lib.a arch/x86/lib/lib.a
lib/built-in.o arch/x86/lib/built-in.o
drivers/built-in.o sound/built-in.o
firmware/built-in.o arch/x86/pci/built-in.o
arch/x86/power/built-in.o arch/x86/video/built-in.o
net/built-in.o
```
下一个可以被执行的目标如下:
```
$(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
$(vmlinux-dirs): prepare scripts
$(Q)$(MAKE) $(build)=$@
```
就像我们看到的,`vmlinux-dir` 依赖于两部分:`prepare` 和 `scripts`。第一个 `prepare` 定义在内核的根 `makefile` 中,准备工作分成三个阶段:
```
prepare: prepare0
prepare0: archprepare FORCE
$(Q)$(MAKE) $(build)=.
archprepare: archheaders archscripts prepare1 scripts_basic
prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
include/config/auto.conf
$(cmd_crmodverdir)
prepare2: prepare3 outputmakefile asm-generic
```
第一个 `prepare0` 展开到 `archprepare` ,后者又展开到 `archheader` 和 `archscripts`,这两个变量定义在 `x86_64` 相关的 [Makefile](https://github.com/torvalds/linux/blob/master/arch/x86/Makefile)。让我们看看这个文件。`x86_64` 特定的 makefile 从变量定义开始,这些变量都是和特定架构的配置文件 ([defconfig](https://github.com/torvalds/linux/tree/master/arch/x86/configs),等等)有关联。在定义了编译 [16-bit](https://en.wikipedia.org/wiki/Real_mode) 代码的编译选项之后,根据变量 `BITS` 的值,如果是 `32`, 汇编代码、链接器、以及其它很多东西(全部的定义都可以在[arch/x86/Makefile](https://github.com/torvalds/linux/blob/master/arch/x86/Makefile)找到)对应的参数就是 `i386`,而 `64` 就对应的是 `x86_84`。
第一个目标是 makefile 生成的系统调用列表(syscall table)中的 `archheaders` :
```
archheaders:
$(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all
```
第二个目标是 makefile 里的 `archscripts`:
```
archscripts: scripts_basic
$(Q)$(MAKE) $(build)=arch/x86/tools relocs
```
我们可以看到 `archscripts` 是依赖于根 [Makefile](https://github.com/torvalds/linux/blob/master/Makefile)里的`scripts_basic` 。首先我们可以看出 `scripts_basic` 是按照 [scripts/basic](https://github.com/torvalds/linux/blob/master/scripts/basic/Makefile) 的 makefile 执行 make 的:
```
scripts_basic:
$(Q)$(MAKE) $(build)=scripts/basic
```
`scripts/basic/Makefile` 包含了编译两个主机程序 `fixdep` 和 `bin2` 的目标:
```
hostprogs-y := fixdep
hostprogs-$(CONFIG_BUILD_BIN2C) += bin2c
always := $(hostprogs-y)
$(addprefix $(obj)/,$(filter-out fixdep,$(always))): $(obj)/fixdep
```
第一个工具是 `fixdep`:用来优化 [gcc](https://gcc.gnu.org/) 生成的依赖列表,然后在重新编译源文件的时候告诉make。第二个工具是 `bin2c`,它依赖于内核配置选项 `CONFIG_BUILD_BIN2C`,并且它是一个用来将标准输入接口(LCTT 译注:即 stdin)收到的二进制流通过标准输出接口(即:stdout)转换成 C 头文件的非常小的 C 程序。你可能注意到这里有些奇怪的标志,如 `hostprogs-y` 等。这个标志用于所有的 `kbuild` 文件,更多的信息你可以从[documentation](https://github.com/torvalds/linux/blob/master/Documentation/kbuild/makefiles.txt) 获得。在我们这里, `hostprogs-y` 告诉 `kbuild` 这里有个名为 `fixed` 的程序,这个程序会通过和 `Makefile` 相同目录的 `fixdep.c` 编译而来。
执行 make 之后,终端的第一个输出就是 `kbuild` 的结果:
```
$ make
HOSTCC scripts/basic/fixdep
```
当目标 `script_basic` 被执行,目标 `archscripts` 就会 make [arch/x86/tools](https://github.com/torvalds/linux/blob/master/arch/x86/tools/Makefile) 下的 makefile 和目标 `relocs`:
```
$(Q)$(MAKE) $(build)=arch/x86/tools relocs
```
包含了[重定位](https://en.wikipedia.org/wiki/Relocation_%28computing%29) 的信息的代码 `relocs_32.c` 和 `relocs_64.c` 将会被编译,这可以在`make` 的输出中看到:
```
HOSTCC arch/x86/tools/relocs_32.o
HOSTCC arch/x86/tools/relocs_64.o
HOSTCC arch/x86/tools/relocs_common.o
HOSTLD arch/x86/tools/relocs
```
在编译完 `relocs.c` 之后会检查 `version.h`:
```
$(version_h): $(srctree)/Makefile FORCE
$(call filechk,version.h)
$(Q)rm -f $(old_version_h)
```
我们可以在输出看到它:
```
CHK include/config/kernel.release
```
以及在内核的根 Makefiel 使用 `arch/x86/include/generated/asm` 的目标 `asm-generic` 来构建 `generic` 汇编头文件。在目标 `asm-generic` 之后,`archprepare` 就完成了,所以目标 `prepare0` 会接着被执行,如我上面所写:
```
prepare0: archprepare FORCE
$(Q)$(MAKE) $(build)=.
```
注意 `build`,它是定义在文件 [scripts/Kbuild.include](https://github.com/torvalds/linux/blob/master/scripts/Kbuild.include),内容是这样的:
```
build := -f $(srctree)/scripts/Makefile.build obj
```
或者在我们的例子中,它就是当前源码目录路径:`.`:
```
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.build obj=.
```
脚本 [scripts/Makefile.build](https://github.com/torvalds/linux/blob/master/scripts/Makefile.build) 通过参数 `obj` 给定的目录找到 `Kbuild` 文件,然后引入 `kbuild` 文件:
```
include $(kbuild-file)
```
并根据这个构建目标。我们这里 `.` 包含了生成 `kernel/bounds.s` 和 `arch/x86/kernel/asm-offsets.s` 的 [Kbuild](https://github.com/torvalds/linux/blob/master/Kbuild) 文件。在此之后,目标 `prepare` 就完成了它的工作。 `vmlinux-dirs` 也依赖于第二个目标 `scripts` ,它会编译接下来的几个程序:`filealias`,`mk_elfconfig`,`modpost` 等等。之后,`scripts/host-programs` 就可以开始编译我们的目标 `vmlinux-dirs` 了。
首先,我们先来理解一下 `vmlinux-dirs` 都包含了那些东西。在我们的例子中它包含了下列内核目录的路径:
```
init usr arch/x86 kernel mm fs ipc security crypto block
drivers sound firmware arch/x86/pci arch/x86/power
arch/x86/video net lib arch/x86/lib
```
我们可以在内核的根 [Makefile](https://github.com/torvalds/linux/blob/master/Makefile) 里找到 `vmlinux-dirs` 的定义:
```
vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \
$(net-y) $(net-m) $(libs-y) $(libs-m)))
init-y := init/
drivers-y := drivers/ sound/ firmware/
net-y := net/
libs-y := lib/
...
...
...
```
这里我们借助函数 `patsubst` 和 `filter`去掉了每个目录路径里的符号 `/`,并且把结果放到 `vmlinux-dirs` 里。所以我们就有了 `vmlinux-dirs` 里的目录列表,以及下面的代码:
```
$(vmlinux-dirs): prepare scripts
$(Q)$(MAKE) $(build)=$@
```
符号 `$@` 在这里代表了 `vmlinux-dirs`,这就表明程序会递归遍历从 `vmlinux-dirs` 以及它内部的全部目录(依赖于配置),并且在对应的目录下执行 `make` 命令。我们可以在输出看到结果:
```
CC init/main.o
CHK include/generated/compile.h
CC init/version.o
CC init/do_mounts.o
...
CC arch/x86/crypto/glue_helper.o
AS arch/x86/crypto/aes-x86_64-asm_64.o
CC arch/x86/crypto/aes_glue.o
...
AS arch/x86/entry/entry_64.o
AS arch/x86/entry/thunk_64.o
CC arch/x86/entry/syscall_64.o
```
每个目录下的源代码将会被编译并且链接到 `built-io.o` 里:
```
$ find . -name built-in.o
./arch/x86/crypto/built-in.o
./arch/x86/crypto/sha-mb/built-in.o
./arch/x86/net/built-in.o
./init/built-in.o
./usr/built-in.o
...
...
```
好了,所有的 `built-in.o` 都构建完了,现在我们回到目标 `vmlinux` 上。你应该还记得,目标 `vmlinux` 是在内核的根makefile 里。在链接 `vmlinux` 之前,系统会构建 [samples](https://github.com/torvalds/linux/tree/master/samples), [Documentation](https://github.com/torvalds/linux/tree/master/Documentation) 等等,但是如上文所述,我不会在本文描述这些。
```
vmlinux: scripts/link-vmlinux.sh $(vmlinux-deps) FORCE
...
...
+$(call if_changed,link-vmlinux)
```
你可以看到,调用脚本 [scripts/link-vmlinux.sh](https://github.com/torvalds/linux/blob/master/scripts/link-vmlinux.sh) 的主要目的是把所有的 `built-in.o` 链接成一个静态可执行文件,和生成 [System.map](https://en.wikipedia.org/wiki/System.map)。 最后我们来看看下面的输出:
```
LINK vmlinux
LD vmlinux.o
MODPOST vmlinux.o
GEN .version
CHK include/generated/compile.h
UPD include/generated/compile.h
CC init/version.o
LD init/built-in.o
KSYM .tmp_kallsyms1.o
KSYM .tmp_kallsyms2.o
LD vmlinux
SORTEX vmlinux
SYSMAP System.map
```
`vmlinux` 和`System.map` 生成在内核源码树根目录下。
```
$ ls vmlinux System.map
System.map vmlinux
```
这就是全部了,`vmlinux` 构建好了,下一步就是创建 [bzImage](https://en.wikipedia.org/wiki/Vmlinux#bzImage).
### 制作bzImage
`bzImage` 就是压缩了的 linux 内核镜像。我们可以在构建了 `vmlinux` 之后通过执行 `make bzImage` 获得`bzImage`。同时我们可以仅仅执行 `make` 而不带任何参数也可以生成 `bzImage` ,因为它是在 [arch/x86/kernel/Makefile](https://github.com/torvalds/linux/blob/master/arch/x86/Makefile) 里预定义的、默认生成的镜像:
```
all: bzImage
```
让我们看看这个目标,它能帮助我们理解这个镜像是怎么构建的。我已经说过了 `bzImage` 是被定义在 [arch/x86/kernel/Makefile](https://github.com/torvalds/linux/blob/master/arch/x86/Makefile),定义如下:
```
bzImage: vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(KBUILD_IMAGE)
$(Q)mkdir -p $(objtree)/arch/$(UTS_MACHINE)/boot
$(Q)ln -fsn ../../x86/boot/bzImage $(objtree)/arch/$(UTS_MACHINE)/boot/$@
```
在这里我们可以看到第一次为 boot 目录执行 `make`,在我们的例子里是这样的:
```
boot := arch/x86/boot
```
现在的主要目标是编译目录 `arch/x86/boot` 和 `arch/x86/boot/compressed` 的代码,构建 `setup.bin` 和 `vmlinux.bin`,最后用这两个文件生成 `bzImage`。第一个目标是定义在 [arch/x86/boot/Makefile](https://github.com/torvalds/linux/blob/master/arch/x86/boot/Makefile) 的 `$(obj)/setup.elf`:
```
$(obj)/setup.elf: $(src)/setup.ld $(SETUP_OBJS) FORCE
$(call if_changed,ld)
```
我们已经在目录 `arch/x86/boot` 有了链接脚本 `setup.ld`,和扩展到 `boot` 目录下全部源代码的变量 `SETUP_OBJS` 。我们可以看看第一个输出:
```
AS arch/x86/boot/bioscall.o
CC arch/x86/boot/cmdline.o
AS arch/x86/boot/copy.o
HOSTCC arch/x86/boot/mkcpustr
CPUSTR arch/x86/boot/cpustr.h
CC arch/x86/boot/cpu.o
CC arch/x86/boot/cpuflags.o
CC arch/x86/boot/cpucheck.o
CC arch/x86/boot/early_serial_console.o
CC arch/x86/boot/edd.o
```
下一个源码文件是 [arch/x86/boot/header.S](https://github.com/torvalds/linux/blob/master/arch/x86/boot/header.S),但是我们不能现在就编译它,因为这个目标依赖于下面两个头文件:
```
$(obj)/header.o: $(obj)/voffset.h $(obj)/zoffset.h
```
第一个头文件 `voffset.h` 是使用 `sed` 脚本生成的,包含用 `nm` 工具从 `vmlinux` 获取的两个地址:
```
#define VO__end 0xffffffff82ab0000
#define VO__text 0xffffffff81000000
```
这两个地址是内核的起始和结束地址。第二个头文件 `zoffset.h` 在 [arch/x86/boot/compressed/Makefile](https://github.com/torvalds/linux/blob/master/arch/x86/boot/compressed/Makefile) 可以看出是依赖于目标 `vmlinux`的:
```
$(obj)/zoffset.h: $(obj)/compressed/vmlinux FORCE
$(call if_changed,zoffset)
```
目标 `$(obj)/compressed/vmlinux` 依赖于 `vmlinux-objs-y` —— 说明需要编译目录 [arch/x86/boot/compressed](https://github.com/torvalds/linux/tree/master/arch/x86/boot/compressed) 下的源代码,然后生成 `vmlinux.bin`、`vmlinux.bin.bz2`,和编译工具 `mkpiggy`。我们可以在下面的输出看出来:
```
LDS arch/x86/boot/compressed/vmlinux.lds
AS arch/x86/boot/compressed/head_64.o
CC arch/x86/boot/compressed/misc.o
CC arch/x86/boot/compressed/string.o
CC arch/x86/boot/compressed/cmdline.o
OBJCOPY arch/x86/boot/compressed/vmlinux.bin
BZIP2 arch/x86/boot/compressed/vmlinux.bin.bz2
HOSTCC arch/x86/boot/compressed/mkpiggy
```
`vmlinux.bin` 是去掉了调试信息和注释的 `vmlinux` 二进制文件,加上了占用了 `u32` (LCTT 译注:即4-Byte)的长度信息的 `vmlinux.bin.all` 压缩后就是 `vmlinux.bin.bz2`。其中 `vmlinux.bin.all` 包含了 `vmlinux.bin` 和`vmlinux.relocs`(LCTT 译注:vmlinux 的重定位信息),其中 `vmlinux.relocs` 是 `vmlinux` 经过程序 `relocs` 处理之后的 `vmlinux` 镜像(见上文所述)。我们现在已经获取到了这些文件,汇编文件 `piggy.S` 将会被 `mkpiggy` 生成、然后编译:
```
MKPIGGY arch/x86/boot/compressed/piggy.S
AS arch/x86/boot/compressed/piggy.o
```
这个汇编文件会包含经过计算得来的、压缩内核的偏移信息。处理完这个汇编文件,我们就可以看到 `zoffset` 生成了:
```
ZOFFSET arch/x86/boot/zoffset.h
```
现在 `zoffset.h` 和 `voffset.h` 已经生成了,[arch/x86/boot](https://github.com/torvalds/linux/tree/master/arch/x86/boot/) 里的源文件可以继续编译:
```
AS arch/x86/boot/header.o
CC arch/x86/boot/main.o
CC arch/x86/boot/mca.o
CC arch/x86/boot/memory.o
CC arch/x86/boot/pm.o
AS arch/x86/boot/pmjump.o
CC arch/x86/boot/printf.o
CC arch/x86/boot/regs.o
CC arch/x86/boot/string.o
CC arch/x86/boot/tty.o
CC arch/x86/boot/video.o
CC arch/x86/boot/video-mode.o
CC arch/x86/boot/video-vga.o
CC arch/x86/boot/video-vesa.o
CC arch/x86/boot/video-bios.o
```
所有的源代码会被编译,他们最终会被链接到 `setup.elf` :
```
LD arch/x86/boot/setup.elf
```
或者:
```
ld -m elf_x86_64 -T arch/x86/boot/setup.ld arch/x86/boot/a20.o arch/x86/boot/bioscall.o arch/x86/boot/cmdline.o arch/x86/boot/copy.o arch/x86/boot/cpu.o arch/x86/boot/cpuflags.o arch/x86/boot/cpucheck.o arch/x86/boot/early_serial_console.o arch/x86/boot/edd.o arch/x86/boot/header.o arch/x86/boot/main.o arch/x86/boot/mca.o arch/x86/boot/memory.o arch/x86/boot/pm.o arch/x86/boot/pmjump.o arch/x86/boot/printf.o arch/x86/boot/regs.o arch/x86/boot/string.o arch/x86/boot/tty.o arch/x86/boot/video.o arch/x86/boot/video-mode.o arch/x86/boot/version.o arch/x86/boot/video-vga.o arch/x86/boot/video-vesa.o arch/x86/boot/video-bios.o -o arch/x86/boot/setup.elf
```
最后的两件事是创建包含目录 `arch/x86/boot/*` 下的编译过的代码的 `setup.bin`:
```
objcopy -O binary arch/x86/boot/setup.elf arch/x86/boot/setup.bin
```
以及从 `vmlinux` 生成 `vmlinux.bin` :
```
objcopy -O binary -R .note -R .comment -S arch/x86/boot/compressed/vmlinux arch/x86/boot/vmlinux.bin
```
最最后,我们编译主机程序 [arch/x86/boot/tools/build.c](https://github.com/torvalds/linux/blob/master/arch/x86/boot/tools/build.c),它将会用来把 `setup.bin` 和 `vmlinux.bin` 打包成 `bzImage`:
```
arch/x86/boot/tools/build arch/x86/boot/setup.bin arch/x86/boot/vmlinux.bin arch/x86/boot/zoffset.h arch/x86/boot/bzImage
```
实际上 `bzImage` 就是把 `setup.bin` 和 `vmlinux.bin` 连接到一起。最终我们会看到输出结果,就和那些用源码编译过内核的同行的结果一样:
```
Setup is 16268 bytes (padded to 16384 bytes).
System is 4704 kB
CRC 94a88f9a
Kernel: arch/x86/boot/bzImage is ready (#5)
```
全部结束。
### 结论
这就是本文的结尾部分。本文我们了解了编译内核的全部步骤:从执行 `make` 命令开始,到最后生成 `bzImage`。我知道,linux 内核的 makefile 和构建 linux 的过程第一眼看起来可能比较迷惑,但是这并不是很难。希望本文可以帮助你理解构建 linux 内核的整个流程。
### 链接
* [GNU make util](https://en.wikipedia.org/wiki/Make_%28software%29)
* [Linux kernel top Makefile](https://github.com/torvalds/linux/blob/master/Makefile)
* [cross-compilation](https://en.wikipedia.org/wiki/Cross_compiler)
* [Ctags](https://en.wikipedia.org/wiki/Ctags)
* [sparse](https://en.wikipedia.org/wiki/Sparse)
* [bzImage](https://en.wikipedia.org/wiki/Vmlinux#bzImage)
* [uname](https://en.wikipedia.org/wiki/Uname)
* [shell](https://en.wikipedia.org/wiki/Shell_%28computing%29)
* [Kbuild](https://github.com/torvalds/linux/blob/master/Documentation/kbuild/kbuild.txt)
* [binutils](http://www.gnu.org/software/binutils/)
* [gcc](https://gcc.gnu.org/)
* [Documentation](https://github.com/torvalds/linux/blob/master/Documentation/kbuild/makefiles.txt)
* [System.map](https://en.wikipedia.org/wiki/System.map)
* [Relocation](https://en.wikipedia.org/wiki/Relocation_%28computing%29)
---
via: <https://github.com/0xAX/linux-insides/blob/master/Misc/how_kernel_compiled.md>
译者:[oska874](https://github.com/oska874) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 404 | Not Found | null |
6,208 | Shilpa Nair 分享的 RedHat Linux 包管理方面的面试经验 | http://www.tecmint.com/linux-rpm-package-management-interview-questions/ | 2015-09-14T08:09:00 | [
"rpm",
"dnf",
"面试"
] | https://linux.cn/article-6208-1.html | **Shilpa Nair 刚于2015年毕业。她之后去了一家位于 Noida,Delhi 的国家新闻电视台,应聘实习生的岗位。在她去年毕业季的时候,常逛 Tecmint 寻求作业上的帮助。从那时开始,她就常去 Tecmint。**

*有关 RPM 方面的 Linux 面试题*
所有的问题和回答都是 Shilpa Nair 根据回忆重写的。
>
> “大家好!我是来自 Delhi 的Shilpa Nair。我不久前才顺利毕业,正寻找一个实习的机会。在大学早期的时候,我就对 UNIX 十分喜爱,所以我也希望这个机会能适合我,满足我的兴趣。我被提问了很多问题,大部分都是关于 RedHat 包管理的基础问题。”
>
>
>
下面就是我被问到的问题,和对应的回答。我仅贴出了与 RedHat GNU/Linux 包管理相关的,也是主要被提问的。
### 1,Linux 里如何查找一个包安装与否?假设你需要确认 ‘nano’ 有没有安装,你怎么做?
**回答**:为了确认 nano 软件包有没有安装,我们可以使用 rpm 命令,配合 -q 和 -a 选项来查询所有已安装的包
```
# rpm -qa nano
或
# rpm -qa | grep -i nano
nano-2.3.1-10.el7.x86_64
```
同时包的名字必须是完整的,不完整的包名会返回到提示符,不打印任何东西,就是说这包(包名字不全)未安装。下面的例子会更好理解些:
我们通常使用 vim 替代 vi 命令。当时如果我们查找安装包 vi/vim 的时候,我们就会看到标准输出上没有任何结果。
```
# vi
# vim
```
尽管如此,我们仍然可以像上面一样运行 vi/vim 命令来清楚地知道包有没有安装。只是因为我们不知道它的完整包名才不能找到的。如果我们不确切知道完整的文件名,我们可以使用通配符:
```
# rpm -qa vim*
vim-minimal-7.4.160-1.el7.x86_64
```
通过这种方式,我们可以获得任何软件包的信息,安装与否。
### 2. 你如何使用 rpm 命令安装 XYZ 软件包?
**回答**:我们可以使用 rpm 命令安装任何的软件包(\*.rpm),像下面这样,选项 -i(安装),-v(冗余或者显示额外的信息)和 -h(在安装过程中,打印#号显示进度)。
```
# rpm -ivh peazip-1.11-1.el6.rf.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:peazip-1.11-1.el6.rf ################################# [100%]
```
如果要升级一个早期版本的包,应加上 -U 选项,选项 -v 和 -h 可以确保我们得到用 # 号表示的冗余输出,这增加了可读性。
### 3. 你已经安装了一个软件包(假设是 httpd),现在你想看看软件包创建并安装的所有文件和目录,你会怎么做?
**回答**:使用选项 -l(列出所有文件)和 -q(查询)列出 httpd 软件包安装的所有文件(Linux 哲学:所有的都是文件,包括目录)。
```
# rpm -ql httpd
/etc/httpd
/etc/httpd/conf
/etc/httpd/conf.d
...
```
### 4. 假如你要移除一个软件包,叫 postfix。你会怎么做?
**回答**:首先我们需要知道什么包安装了 postfix。查找安装 postfix 的包名后,使用 -e(擦除/卸载软件包)和 -v(冗余输出)两个选项来实现。
```
# rpm -qa postfix*
postfix-2.10.1-6.el7.x86_64
```
然后移除 postfix,如下:
```
# rpm -ev postfix-2.10.1-6.el7.x86_64
Preparing packages...
postfix-2:3.0.1-2.fc22.x86_64
```
### 5. 获得一个已安装包的具体信息,如版本,发行号,安装日期,大小,总结和一个简短的描述。
**回答**:我们通过使用 rpm 的选项 -qi,后面接包名,可以获得关于一个已安装包的具体信息。
举个例子,为了获得 openssh 包的具体信息,我需要做的就是:
```
# rpm -qi openssh
[root@tecmint tecmint]# rpm -qi openssh
Name : openssh
Version : 6.8p1
Release : 5.fc22
Architecture: x86_64
Install Date: Thursday 28 May 2015 12:34:50 PM IST
Group : Applications/Internet
Size : 1542057
License : BSD
....
```
### 6. 假如你不确定一个指定包的配置文件在哪,比如 httpd。你如何找到所有 httpd 提供的配置文件列表和位置。
**回答**: 我们需要用选项 -c 接包名,这会列出所有配置文件的名字和他们的位置。
```
# rpm -qc httpd
/etc/httpd/conf.d/autoindex.conf
/etc/httpd/conf.d/userdir.conf
/etc/httpd/conf.d/welcome.conf
/etc/httpd/conf.modules.d/00-base.conf
/etc/httpd/conf/httpd.conf
/etc/sysconfig/httpd
```
相似地,我们可以列出所有相关的文档文件,如下:
```
# rpm -qd httpd
/usr/share/doc/httpd/ABOUT_APACHE
/usr/share/doc/httpd/CHANGES
/usr/share/doc/httpd/LICENSE
...
```
我们也可以列出所有相关的证书文件,如下:
```
# rpm -qL openssh
/usr/share/licenses/openssh/LICENCE
```
忘了说明上面的选项 -d 和 -L 分别表示 “文档” 和 “证书”,抱歉。
### 7. 你找到了一个配置文件,位于‘/usr/share/alsa/cards/AACI.conf’,现在你不确定该文件属于哪个包。你如何查找出包的名字?
**回答**:当一个包被安装后,相关的信息就存储在了数据库里。所以使用选项 -qf(-f 查询包拥有的文件)很容易追踪谁提供了上述的包。
```
# rpm -qf /usr/share/alsa/cards/AACI.conf
alsa-lib-1.0.28-2.el7.x86_64
```
类似地,我们可以查找(谁提供的)关于任何子包,文档和证书文件的信息。
### 8. 你如何使用 rpm 查找最近安装的软件列表?
**回答**:如刚刚说的,每一样被安装的文件都记录在了数据库里。所以这并不难,通过查询 rpm 的数据库,找到最近安装软件的列表。
我们通过运行下面的命令,使用选项 -last(打印出最近安装的软件)达到目的。
```
# rpm -qa --last
```
上面的命令会打印出所有安装的软件,最近安装的软件在列表的顶部。
如果我们关心的是找出特定的包,我们可以使用 grep 命令从列表中匹配包(假设是 sqlite ),简单如下:
```
# rpm -qa --last | grep -i sqlite
sqlite-3.8.10.2-1.fc22.x86_64 Thursday 18 June 2015 05:05:43 PM IST
```
我们也可以获得10个最近安装的软件列表,简单如下:
```
# rpm -qa --last | head
```
我们可以重定义一下,输出想要的结果,简单如下:
```
# rpm -qa --last | head -n 2
```
上面的命令中,-n 代表数目,后面接一个常数值。该命令是打印2个最近安装的软件的列表。
### 9. 安装一个包之前,你如果要检查其依赖。你会怎么做?
**回答**:检查一个 rpm 包(XYZ.rpm)的依赖,我们可以使用选项 -q(查询包),-p(指定包名)和 -R(查询/列出该包依赖的包,嗯,就是依赖)。
```
# rpm -qpR gedit-3.16.1-1.fc22.i686.rpm
/bin/sh
/usr/bin/env
glib2(x86-32) >= 2.40.0
gsettings-desktop-schemas
gtk3(x86-32) >= 3.16
gtksourceview3(x86-32) >= 3.16
gvfs
libX11.so.6
...
```
### 10. rpm 是不是一个前端的包管理工具呢?
**回答**:**不是!**rpm 是一个后端管理工具,适用于基于 Linux 发行版的 RPM (此处指 Redhat Package Management)。
[YUM](http://www.tecmint.com/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement/),全称 Yellowdog Updater Modified,是一个 RPM 的前端工具。YUM 命令自动完成所有工作,包括解决依赖和其他一切事务。
最近,[DNF](/article-5718-1.html)(YUM命令升级版)在Fedora 22发行版中取代了 YUM。尽管 YUM 仍然可以在 RHEL 和 CentOS 平台使用,我们也可以安装 dnf,与 YUM 命令共存使用。据说 DNF 较于 YUM 有很多提高。
知道更多总是好的,保持自我更新。现在我们移步到前端部分来谈谈。
### 11. 你如何列出一个系统上面所有可用的仓库列表。
**回答**:简单地使用下面的命令,我们就可以列出一个系统上所有可用的仓库列表。
```
# yum repolist
或
# dnf repolist
Last metadata expiration check performed 0:30:03 ago on Mon Jun 22 16:50:00 2015.
repo id repo name status
*fedora Fedora 22 - x86_64 44,762
ozonos Repository for Ozon OS 61
*updates Fedora 22 - x86_64 - Updates
```
上面的命令仅会列出可用的仓库。如果你需要列出所有的仓库,不管可用与否,可以这样做。
```
# yum repolist all
或
# dnf repolist all
Last metadata expiration check performed 0:29:45 ago on Mon Jun 22 16:50:00 2015.
repo id repo name status
*fedora Fedora 22 - x86_64 enabled: 44,762
fedora-debuginfo Fedora 22 - x86_64 - Debug disabled
fedora-source Fedora 22 - Source disabled
ozonos Repository for Ozon OS enabled: 61
*updates Fedora 22 - x86_64 - Updates enabled: 5,018
updates-debuginfo Fedora 22 - x86_64 - Updates - Debug
```
### 12. 你如何列出一个系统上所有可用并且安装了的包?
**回答**:列出一个系统上所有可用的包,我们可以这样做:
```
# yum list available
或
# dnf list available
ast metadata expiration check performed 0:34:09 ago on Mon Jun 22 16:50:00 2015.
Available Packages
0ad.x86_64 0.0.18-1.fc22 fedora
0ad-data.noarch 0.0.18-1.fc22 fedora
0install.x86_64 2.6.1-2.fc21 fedora
0xFFFF.x86_64 0.3.9-11.fc22 fedora
2048-cli.x86_64 0.9-4.git20141214.723738c.fc22 fedora
2048-cli-nocurses.x86_64 0.9-4.git20141214.723738c.fc22 fedora
....
```
而列出一个系统上所有已安装的包,我们可以这样做。
```
# yum list installed
或
# dnf list installed
Last metadata expiration check performed 0:34:30 ago on Mon Jun 22 16:50:00 2015.
Installed Packages
GeoIP.x86_64 1.6.5-1.fc22 @System
GeoIP-GeoLite-data.noarch 2015.05-1.fc22 @System
NetworkManager.x86_64 1:1.0.2-1.fc22 @System
NetworkManager-libnm.x86_64 1:1.0.2-1.fc22 @System
aajohan-comfortaa-fonts.noarch 2.004-4.fc22 @System
....
```
而要同时满足两个要求的时候,我们可以这样做。
```
# yum list
或
# dnf list
Last metadata expiration check performed 0:32:56 ago on Mon Jun 22 16:50:00 2015.
Installed Packages
GeoIP.x86_64 1.6.5-1.fc22 @System
GeoIP-GeoLite-data.noarch 2015.05-1.fc22 @System
NetworkManager.x86_64 1:1.0.2-1.fc22 @System
NetworkManager-libnm.x86_64 1:1.0.2-1.fc22 @System
aajohan-comfortaa-fonts.noarch 2.004-4.fc22 @System
acl.x86_64 2.2.52-7.fc22 @System
....
```
### 13. 你会怎么在一个系统上面使用 YUM 或 DNF 分别安装和升级一个包与一组包?
**回答**:安装一个包(假设是 nano),我们可以这样做,
```
# yum install nano
```
而安装一组包(假设是 Haskell),我们可以这样做,
```
# yum groupinstall 'haskell'
```
升级一个包(还是 nano),我们可以这样做,
```
# yum update nano
```
而为了升级一组包(还是 haskell),我们可以这样做,
```
# yum groupupdate 'haskell'
```
### 14. 你会如何同步一个系统上面的所有安装软件到稳定发行版?
**回答**:我们可以一个系统上(假设是 CentOS 或者 Fedora)的所有包到稳定发行版,如下,
```
# yum distro-sync [在 CentOS/ RHEL]
或
# dnf distro-sync [在 Fedora 20之后版本]
```
似乎来面试之前你做了相当不多的功课,很好!在进一步交谈前,我还想问一两个问题。
### 15. 你对 YUM 本地仓库熟悉吗?你尝试过建立一个本地 YUM 仓库吗?让我们简单看看你会怎么建立一个本地 YUM 仓库。
**回答**:首先,感谢你的夸奖。回到问题,我必须承认我对本地 YUM 仓库十分熟悉,并且在我的本地主机上也部署过,作为测试用。
1、 为了建立本地 YUM 仓库,我们需要安装下面三个包:
```
# yum install deltarpm python-deltarpm createrepo
```
2、 新建一个目录(假设 /home/$USER/rpm),然后复制 RedHat/CentOS DVD 上的 RPM 包到这个文件夹下
```
# mkdir /home/$USER/rpm
# cp /path/to/rpm/on/DVD/*.rpm /home/$USER/rpm
```
3、 新建基本的库头文件如下。
```
# createrepo -v /home/$USER/rpm
```
4、 在路径 /etc/yum.repo.d 下创建一个 .repo 文件(如 abc.repo):
```
cd /etc/yum.repos.d && cat << EOF abc.repo
[local-installation]name=yum-local
baseurl=file:///home/$USER/rpm
enabled=1
gpgcheck=0
EOF
```
**重要**:用你的用户名替换掉 $USER。
以上就是创建一个本地 YUM 仓库所要做的全部工作。我们现在可以从这里安装软件了,相对快一些,安全一些,并且最重要的是不需要 Internet 连接。
好了!面试过程很愉快。我已经问完了。我会将你推荐给 HR。你是一个年轻且十分聪明的候选者,我们很愿意你加入进来。如果你有任何问题,你可以问我。
**我**:谢谢,这确实是一次愉快的面试,我感到今天非常幸运,可以搞定这次面试...
显然,不会在这里结束。我问了很多问题,比如他们正在做的项目。我会担任什么角色,负责什么,,,balabalabala
小伙伴们,这之后的 3 天会经过 HR 轮,到时候所有问题到时候也会被写成文档。希望我当时表现不错。感谢你们所有的祝福。
谢谢伙伴们和 Tecmint,花时间来编辑我的面试经历。我相信 Tecmint 好伙伴们做了很大的努力,必要要赞一个。当我们与他人分享我们的经历的时候,其他人从我们这里知道了更多,而我们自己则发现了自己的不足。
这增加了我们的信心。如果你最近也有任何类似的面试经历,别自己蔵着。分享出来!让我们所有人都知道。你可以使用如下的表单来与我们分享你的经历。
---
via: <http://www.tecmint.com/linux-rpm-package-management-interview-questions/>
作者:[Avishek Kumar](http://www.tecmint.com/author/avishek/) 译者:[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,209 | Xtreme 下载管理器升级带来全新用户界面 | http://itsfoss.com/xtreme-download-manager-install/ | 2015-09-13T20:30:20 | [
"下载",
"XDM"
] | https://linux.cn/article-6209-1.html | 
[Xtreme 下载管理器](http://xdman.sourceforge.net/), 毫无疑问是[Linux界最好的下载管理器](http://itsfoss.com/4-best-download-managers-for-linux/)之一 , 它的新版本名叫 XDM 2015 ,这次的新版本给我们带来了全新的外观体验!
Xtreme 下载管理器,也被称作 XDM 或 XDMAN,它是一个跨平台的下载管理器,可以用于 Linux、Windows 和 Mac OS X 系统之上。同时它兼容于主流的浏览器,如 Chrome, Firefox, Safari 等,因此当你从浏览器下载东西的时候可以直接使用 XDM 下载。
当你的网络连接超慢并且需要管理下载文件的时候,像 XDM 这种软件可以帮到你大忙。例如说你在一个慢的要死的网络速度下下载一个超大文件,或者你想要暂停和恢复下载的话, XDM 可以帮助你。
XDM 的主要功能:
* 暂停和恢复下载
* [从 YouTube 下载视频](http://itsfoss.com/download-youtube-videos-ubuntu/),其他视频网站同样适用
* 强制聚合
* 下载加速
* 计划下载
* 下载限速
* 与浏览器整合
* 支持代理服务器
下面你可以看到 XDM 新旧版本之间的差别。

*老版本XDM*

*新版本XDM*
### 在基于 Ubuntu 的 Linux 发行版上安装 Xtreme下载管理器
感谢 Noobslab 提供的 PPA,你可以使用以下命令来安装 Xtreme 下载管理器。虽然 XDM 依赖 Java,但是托 PPA 的福,你不需要对其进行单独的安装。
```
sudo add-apt-repository ppa:noobslab/apps
sudo apt-get update
sudo apt-get install xdman
```
以上的 PPA 可以在 Ubuntu 或者其他基于 Ubuntu 的发行版上使用,如 Linux Mint, elementary OS, Linux Lite 等。
#### 删除 XDM
如果你是使用 PPA 安装的 XDM ,可以通过以下命令将其删除:
```
sudo apt-get remove xdman
sudo add-apt-repository --remove ppa:noobslab/apps
```
对于其他Linux发行版,可以通过以下连接下载:
* [下载 Xtreme 下载管理器](http://xdman.sourceforge.net/download.html)
---
via: <http://itsfoss.com/xtreme-download-manager-install/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[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,210 | 在 Linux 中怎样将 MySQL 迁移到 MariaDB 上 | http://xmodulo.com/migrate-mysql-to-mariadb-linux.html | 2015-09-14T09:14:00 | [
"MySQL",
"迁移",
"MariaDB"
] | https://linux.cn/article-6210-1.html | 自从甲骨文收购 MySQL 后,由于甲骨文对 MySQL 的开发和维护更多倾向于闭门的立场,很多 MySQL 的开发者和用户放弃了 MySQL。在社区驱动下,促使更多人移到 MySQL 的另一个叫 MariaDB 的分支。在原有 MySQL 开发人员的带领下,MariaDB 的开发遵循开源的理念,并确保[它的二进制格式与 MySQL 兼容](https://mariadb.com/kb/en/mariadb/mariadb-vs-mysql-compatibility/)。Linux 发行版如 Red Hat 家族(Fedora,CentOS,RHEL),Ubuntu 和 Mint,openSUSE 和 Debian 已经开始使用,并支持 MariaDB 作为 MySQL 的直接替换品。

如果你想要将 MySQL 中的数据库迁移到 MariaDB 中,这篇文章就是你所期待的。幸运的是,由于他们的二进制兼容性,MySQL-to-MariaDB 迁移过程是非常简单的。如果你按照下面的步骤,将 MySQL 迁移到 MariaDB 会是无痛的。
### 准备 MySQL 数据库和表
出于演示的目的,我们在做迁移之前在数据库中创建一个测试的 MySQL 数据库和表。如果你在 MySQL 中已经有了要迁移到 MariaDB 的数据库,跳过此步骤。否则,按以下步骤操作。
在终端输入 root 密码登录到 MySQL 。
```
$ mysql -u root -p
```
创建一个数据库和表。
```
mysql> create database test01;
mysql> use test01;
mysql> create table pet(name varchar(30), owner varchar(30), species varchar(20), sex char(1));
```
在表中添加一些数据。
```
mysql> insert into pet values('brandon','Jack','puddle','m'),('dixie','Danny','chihuahua','f');
```
退出 MySQL 数据库.
### 备份 MySQL 数据库
下一步是备份现有的 MySQL 数据库。使用下面的 mysqldump 命令导出现有的数据库到文件中。运行此命令之前,请确保你的 MySQL 服务器上启用了二进制日志。如果你不知道如何启用二进制日志,请参阅结尾的教程说明。
```
$ mysqldump --all-databases --user=root --password --master-data > backupdb.sql
```

现在,在卸载 MySQL 之前先在系统上备份 my.cnf 文件。此步是可选的。
```
$ sudo cp /etc/mysql/my.cnf /opt/my.cnf.bak
```
### 卸载 MySQL
首先,停止 MySQL 服务。
```
$ sudo service mysql stop
```
或者:
```
$ sudo systemctl stop mysql
```
或:
```
$ sudo /etc/init.d/mysql stop
```
然后继续下一步,使用以下命令移除 MySQL 和配置文件。
在基于 RPM 的系统上 (例如, CentOS, Fedora 或 RHEL):
```
$ sudo yum remove mysql* mysql-server mysql-devel mysql-libs
$ sudo rm -rf /var/lib/mysql
```
在基于 Debian 的系统上(例如, Debian, Ubuntu 或 Mint):
```
$ sudo apt-get remove mysql-server mysql-client mysql-common
$ sudo apt-get autoremove
$ sudo apt-get autoclean
$ sudo deluser mysql
$ sudo rm -rf /var/lib/mysql
```
### 安装 MariaDB
在 CentOS/RHEL 7和Ubuntu(14.04或更高版本)上,最新的 MariaDB 已经包含在其官方源。在 Fedora 上,自19 版本后 MariaDB 已经替代了 MySQL。如果你使用的是旧版本或 LTS 类型如 Ubuntu 13.10 或更早的,你仍然可以通过添加其官方仓库来安装 MariaDB。
[MariaDB 网站](https://downloads.mariadb.org/mariadb/repositories/#mirror=aasaam) 提供了一个在线工具帮助你依据你的 Linux 发行版中来添加 MariaDB 的官方仓库。此工具为 openSUSE, Arch Linux, Mageia, Fedora, CentOS, RedHat, Mint, Ubuntu, 和 Debian 提供了 MariaDB 的官方仓库.

下面例子中,我们使用 Ubuntu 14.04 发行版和 CentOS 7 配置 MariaDB 库。
**Ubuntu 14.04**
```
$ sudo apt-get install software-properties-common
$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
$ sudo add-apt-repository 'deb http://mirror.mephi.ru/mariadb/repo/5.5/ubuntu trusty main'
$ sudo apt-get update
$ sudo apt-get install mariadb-server
```
**CentOS 7**
以下为 MariaDB 创建一个自定义的 yum 仓库文件。
```
$ sudo vi /etc/yum.repos.d/MariaDB.repo
```
---
```
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
```
---
```
$ sudo yum install MariaDB-server MariaDB-client
```
安装了所有必要的软件包后,你可能会被要求为 MariaDB 的 root 用户创建一个新密码。设置 root 的密码后,别忘了恢复备份的 my.cnf 文件。
```
$ sudo cp /opt/my.cnf /etc/mysql/
```
现在启动 MariaDB 服务。
```
$ sudo service mariadb start
```
或:
```
$ sudo systemctl start mariadb
```
或:
```
$ sudo /etc/init.d/mariadb start
```
### 导入 MySQL 的数据库
最后,我们将以前导出的数据库导入到 MariaDB 服务器中。
```
$ mysql -u root -p < backupdb.sql
```
输入你 MariaDB 的 root 密码,数据库导入过程将开始。导入过程完成后,将返回到命令提示符下。
要检查导入过程是否完全成功,请登录到 MariaDB 服务器,并查看一些样本来检查。
```
$ mysql -u root -p
```
---
```
MariaDB [(none)]> show databases;
MariaDB [(none)]> use test01;
MariaDB [test01]> select * from pet;
```

### 结论
如你在本教程中看到的,MySQL-to-MariaDB 的迁移并不难。你应该知道,MariaDB 相比 MySQL 有很多新的功能。至于配置方面,在我的测试情况下,我只是将我旧的 MySQL 配置文件(my.cnf)作为 MariaDB 的配置文件,导入过程完全没有出现任何问题。对于配置文件,我建议你在迁移之前请仔细阅读 MariaDB 配置选项的文件,特别是如果你正在使用 MySQL 的特定配置。
如果你正在运行有海量的表、包括群集或主从复制的数据库的复杂配置,看一看 Mozilla IT 和 Operations 团队的 [更详细的指南](https://blog.mozilla.org/it/2013/12/16/upgrading-from-mysql-5-1-to-mariadb-5-5/) ,或者 [官方的 MariaDB 文档](https://mariadb.com/kb/en/mariadb/documentation/)。
### 故障排除
1、 在运行 mysqldump 命令备份数据库时出现以下错误。
```
$ mysqldump --all-databases --user=root --password --master-data > backupdb.sql
```
---
```
mysqldump: Error: Binlogging on server not active
```
通过使用 "--master-data",你可以在导出的输出中包含二进制日志信息,这对于数据库的复制和恢复是有用的。但是,二进制日志未在 MySQL 服务器启用。要解决这个错误,修改 my.cnf 文件,并在 [mysqld] 部分添加下面的选项。(LCTT 译注:事实上,如果你并没有启用二进制日志,那取消"--master-data"即可。)
```
log-bin=mysql-bin
```
保存 my.cnf 文件,并重新启动 MySQL 服务:
```
$ sudo service mysql restart
```
或者:
```
$ sudo systemctl restart mysql
```
或:
```
$ sudo /etc/init.d/mysql restart
```
---
via: <http://xmodulo.com/migrate-mysql-to-mariadb-linux.html>
作者:[Kristophorus Hadiono](http://xmodulo.com/author/kristophorus) 译者:[strugglingyouth](https://github.com/strugglingyouth) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,211 | 守卫自由的 Linux 世界 | http://www.linuxinsider.com/story/Defending-the-Free-Linux-World-81512.html | 2015-09-14T07:33:00 | [
"OIN",
"许可证",
"专利"
] | https://linux.cn/article-6211-1.html | 
**合作是开源的一部分。OIN 的 CEO Keith Bergelt 解释说,开放创新网络(Open Invention Network)模式允许众多企业和公司决定它们该在哪较量,在哪合作。随着开源的演变,“我们需要为合作创造渠道,否则我们将会有几百个团体把数十亿美元花费到同样的技术上。”**
[开放创新网络(Open Invention Network)](http://www.openinventionnetwork.com/),即 OIN,正在全球范围内开展让 Linux 远离专利诉讼的伤害的活动。它的努力得到了一千多个公司的热烈回应,它们的加入让这股力量成为了历史上最大的反专利管理组织。
开放创新网络以白帽子组织的身份创建于2005年,目的是保护 Linux 免受来自许可证方面的困扰。包括 Google、 IBM、 NEC、 Novell、 Philips、 [Red Hat](http://www.redhat.com/) 和 Sony 这些成员的董事会给予了它可观的经济支持。世界范围内的多个组织通过签署自由 OIN 协议加入了这个社区。
创立开放创新网络的组织成员把它当作利用知识产权保护 Linux 的大胆尝试。它的商业模式非常的难以理解。它要求它的成员采用免版权许可证,并永远放弃由于 Linux 相关知识产权起诉其他成员的机会。
然而,从 Linux 收购风波——想想服务器和云平台——那时起,保护 Linux 知识产权的策略就变得越加的迫切。
在过去的几年里,Linux 的版图曾经历了一场变革。OIN 不必再向人们解释这个组织的定义,也不必再解释为什么 Linux 需要保护。据 OIN 的 CEO Keith Bergelt 说,现在 Linux 的重要性得到了全世界的关注。
“我们已经见到了一场人们了解到 OIN 如何让合作受益的文化变革,”他对 LinuxInsider 说。
### 如何运作
开放创新网络使用专利权的方式创建了一个协作环境。这种方法有助于确保创新的延续。这已经使很多软件厂商、顾客、新型市场和投资者受益。
开放创新网络的专利证可以让任何公司、公共机构或个人免版权使用。这些权利的获得建立在签署者同意不会专为了维护专利而攻击 Linux 系统的基础上。
OIN 确保 Linux 的源代码保持开放的状态。这让编程人员、设备厂商、独立软件开发者和公共机构在投资和使用 Linux 时不用过多的担心知识产权的问题。这让对 Linux 进行重新打包、嵌入和使用的公司省了不少钱。
“随着版权许可证越来越广泛的使用,对 OIN 许可证的需求也变得更加的迫切。现在,人们正在寻找更加简单或更实用的解决方法”,Bergelt 说。
OIN 法律防御援助对成员是免费的。成员必须承诺不对 OIN 名单上的软件发起专利诉讼。为了保护他们的软件,他们也同意提供他们自己的专利。最终,这些保证将让几十万的交叉许可通过该网络相互连接起来,Bergelt 如此解释道。
### 填补法律漏洞
“OIN 正在做的事情是非常必要的。它提供另一层 IP (知识产权)保护,”[休斯顿法律中心大学](http://www.law.uh.edu/)的副教授 Greg R. Vetter 这样说道。
他回答 LinuxInsider 说,第二版 GPL 许可证被某些人认为提供了隐含的专利许可,但是律师们更喜欢明确的许可。
OIN 所提供的许可填补了这个空白。它还明确的覆盖了 Linux 内核。据 Vetter 说,明确的专利许可并不是 GPLv2 中的必要部分,但是这个部分被加入到了 GPLv3 中。(LCTT 译注:Linux 内核采用的是 GPLv2 的许可)
拿一个在 GPLv3 中写了10000行代码的代码编写者来说。随着时间推移,其他的代码编写者会贡献更多行的代码,也加入到了知识产权中。GPLv3 中的软件专利许可条款将基于所有参与的贡献者的专利,保护全部代码的使用,Vetter 如此说道。
### 并不完全一样
专利权和许可证在法律结构上层层叠叠互相覆盖。弄清两者对开源软件的作用就像是穿越雷区。
Vetter 说“通常,许可证是授予建立在专利和版权法律上的额外权利的法律结构。许可证被认为是给予了人们做一些的可能会侵犯到其他人的知识产权权利的事的许可。”
Vetter 指出,很多自由开源许可证(例如 Mozilla 公共许可、GNU GPLv3 以及 Apache 软件许可)融合了某些互惠专利权的形式。Vetter 指出,像 BSD 和 MIT 这样旧的许可证不会提到专利。
一个软件的许可证让其他人可以在某种程度上使用这个编程人员创造的代码。版权对所属权的建立是自动的,只要某个人写或者画了某个原创的东西。然而,版权只覆盖了个别的表达方式和衍生的作品。他并没有涵盖代码的功能性或可用的想法。
专利涵盖了功能性。专利权还可以被许可。版权可能无法保护某人如何独立地开发对另一个人的代码的实现,但是专利填补了这个小瑕疵,Vetter 解释道。
### 寻找安全通道
许可证和专利混合的法律性质可能会对开源开发者产生威胁。据 [Chaotic Moon Studios](http://www.chaoticmoon.com/) 的创办者之一、 [IEEE](http://www.ieee.org/) 计算机协会成员 William Hurley 说,对于某些人来说,即使是 GPL 也会成为威胁。
“在很久以前,开源是个完全不同的世界。被彼此间的尊重和把代码视为艺术而非资产的观点所驱动,那时的程序和代码比现在更加的开放。我相信很多为最好的愿景所做的努力几乎最后总是背负着意外的结果,”Hurley 这样告诉 LinuxInsider。
他暗示说,成员人数超越了1000人(的组织)可能会在知识产权保护重要性方面意见不一。这可能会继续搅混开源生态系统这滩浑水。
“最终,这些显现出了围绕着知识产权的常见的一些错误概念。拥有几千个开发者并不会减少风险——而是增加。给出了专利许可的开发者越多,它们看起来就越值钱,”Hurley 说。“它们看起来越值钱,有着类似专利的或者其他知识产权的人就越可能试图利用并从中榨取他们自己的经济利益。”
### 共享与竞争共存
竞合策略是开源的一部分。OIN 模型让各个公司能够决定他们将在哪竞争以及在哪合作,Bergelt 解释道。
“开源演化中的许多改变已经把我们移到了另一个方向上。我们必须为合作创造渠道。否则我们将会有几百个团体把数十亿美元花费到同样的技术上,”他说。
手机产业的革新就是个很好的例子。各个公司放出了不同的标准。没有共享,没有合作,Bergelt 解释道。
他说:“这让我们在美国接触技术的能力落后了七到十年。我们接触设备的经验远远落后于世界其他地方的人。在我们用不上 CDMA (Code Division Multiple Access 码分多址访问通信技术)时对 GSM (Global System for Mobile Communications 全球移动通信系统) 还沾沾自喜。”
### 改变格局
OIN 在去年经历了激增400个新许可的增长。这意味着着开源有了新趋势。
Bergelt 说:“市场到达了一个临界点,组织内的人们终于意识到直白地合作和竞争的需要。结果是两件事同时进行。这可能会变得复杂、费力。”
然而,这个由人们开始考虑合作和竞争的文化革新所驱动的转换过程是可以接受的。他解释说,这也是一个人们怎样拥抱开源的转变——尤其是在 Linux 这个开源社区的领导者项目。
还有一个迹象是,最具意义的新项目都没有在 GPLv3 许可下开发。
### 二个总比一个好
“GPL 极为重要,但是事实是有一堆的许可模型正被使用着。在 Eclipse、Apache 和 Berkeley 许可中,专利问题的相对可解决性通常远远低于在 GPLv3 中的。”Bergelt 说。
GPLv3 对于解决专利问题是个自然的补充——但是 GPL 自身不足以独自解决围绕专利使用的潜在冲突。所以 OIN 的设计是以能够补充版权许可为目的的,他补充道。
然而,层层叠叠的专利和许可也许并没有带来多少好处。到最后,专利在几乎所有的案例中都被用于攻击目的——而不是防御目的,Bergelt 暗示说。
“如果你不准备对其他人采取法律行动,那么对于你的知识产权来说专利可能并不是最佳的法律保护方式”,他说。“我们现在生活在一个对软件——开放的和专有的——误会重重的世界里。这些软件还被错误而过时的专利系统所捆绑。我们每天在工业化和被扼杀的创新中挣扎”,他说。
### 法院是最后的手段
想到 OIN 的出现抑制了诉讼的泛滥就感到十分欣慰,Bergelt 说,或者至少可以说 OIN 的出现扼制了特定的某些威胁。
“可以说我们让人们放下他们的武器。同时我们正在创建一种新的文化规范。一旦你入股这个模型中的非侵略专利,所产生的相关影响就是对合作的鼓励”,他说。
如果你愿意承诺合作,你的第一反应就会趋向于不急着起诉。相反的,你会想如何让我们允许你使用我们所拥有的东西并让它为你赚钱,而同时我们也能使用你所拥有的东西,Bergelt 解释道。
“OIN 是个多面的解决方式。它鼓励签署者创造双赢协议”,他说,“这让起诉成为最逼不得已的行为。那才是它的位置。”
### 底线
Bergelt 坚信,OIN 的运作是为了阻止 Linux 受到专利伤害。在这个需要 Linux 的世界里没有诉讼的地方。
唯一临近的是与微软的移动之争,这关系到行业的发展前景(原文: The only thing that comes close are the mobile wars with Microsoft, which focus on elements high in the stack. 不太理解,请指正。)。那些来自法律的挑战可能是为了提高包括使用 Linux 产品的所属权的成本,Bergelt 说。
尽管如此“这些并不是有关 Linux 诉讼”,他说。“他们的重点并不在于 Linux 的核心。他们关注的是 Linux 系统里都有些什么。”
---
via: <http://www.linuxinsider.com/story/Defending-the-Free-Linux-World-81512.html>
作者:Jack M. Germain 译者:[H-mudcup](https://github.com/H-mudcup) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,212 | Node.js 4.0 中的 ES 6 特性介绍 | http://www.cli-nerd.com/2015/09/09/7-reasons-to-upgrade-to-node-v4-now.html | 2015-09-14T15:03:35 | [
"Node.js",
"ES6"
] | https://linux.cn/article-6212-1.html | [Node.js 4.0.0 已经发布了](/article-6181-1.html)。这是和 io.js 合并之后的首个稳定版本,它带来了一系列的新特性,支持 ES 6的大部分特性。已经有很多 [ES 6 的特性](https://nodejs.org/en/docs/es6/)介绍了,这里我们介绍一下该怎么使用它们。

### 1. 模板字符串
如果你要在 JavaScript 中创建多行字符串,你可能会使用如下的语法:
```
var message = [
'The quick brown fox',
'jumps over',
'the lazy dog'
].join('\n');
```
对于少量字符串这还算合适,但是如果比较多就会显得混乱。不过,有个聪明的开发者提出了一个叫 [multiline](https://github.com/sindresorhus/multiline) 的技巧:
```
var multiline = require('multiline');
var message = multiline(function () {/*
The quick brown fox
jumps over
the lazy dog
*/});
```
幸运的是,ES 6 为我们带来了[模板字符串](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings):
```
var message = `
The quick brown fox
jumps over
the lazy dog
`;
```
此外,它还给我们带来了字符串内插:
```
var name = 'Schroedinger';
// 不要这样做 ...
var message = 'Hello ' + name + ', how is your cat?';
var message = ['Hello ', name, ', how is your cat?'].join('');
var message = require('util').format('Hello %s, how is your cat?', name);
// 应该这样做 ...
var message = `Hello ${name}, how is your cat?`;
```
[在 MDN 上查看模板字符串的细节](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/template_strings).
### 2. 类
在 ES5 中定义类看起来有点奇怪,也比较麻烦:
```
var Pet = function (name) {
this._name = name;
};
Pet.prototype.sayHello = function () {
console.log('*scratch*');
};
Object.defineProperty(Pet.prototype, 'name', {
get: function () {
return this._name;
}
});
var Cat = function (name) {
Pet.call(this, name);
};
require('util').inherits(Cat, Pet);
Cat.prototype.sayHello = function () {
Pet.prototype.sayHello.call(this);
console.log('miaaaauw');
};
```
幸运的是,在 Node.js 中可以使用新的 ES6 格式:
```
class Pet {
constructor(name) {
this._name = name;
}
sayHello() {
console.log('*scratch*');
}
get name() {
return this._name;
}
}
class Cat extends Pet {
constructor(name) {
super(name);
}
sayHello() {
super.sayHello();
console.log('miaaaauw');
}
}
```
有 extends 关键字、构造子、调用超类及属性,是不是很棒?还不止这些,[看看 MDN 上的更详细的介绍。](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes)
### 3. 箭头函数
在函数里面对 `this` 的动态绑定总是会导致一些混乱,人们一般是这样用的:
```
Cat.prototype.notifyListeners = function () {
var self = this;
this._listeners.forEach(function (listener) {
self.notifyListener(listener);
});
};
```
```
Cat.prototype.notifyListeners = function () {
this._listeners.forEach(function (listener) {
this.notifyListener(listener);
}.bind(this));
};
```
现在你可以使用胖箭头函数了:
```
Cat.prototype.notifyListeners = function () {
this._listeners.forEach((listener) => {
this.notifyListener(listener);
});
};
```
[了解箭头函数的更多细节。](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions).
### 4. 对象字面量
使用对象字面量,你现在有了很漂亮的快捷方式:
```
var age = 10, name = 'Petsy', size = 32;
// 不要这样做 ...
var cat = {
age: age,
name: name,
size: size
};
// ... 而是这样做 ...
var cat = {
age,
name,
size
};
```
此外,你现在可以很容易地 [给你的对象字面量添加函数](https://github.com/lukehoban/es6features#enhanced-object-literals)。
### 5. Promise
不用再依赖像 `bluebird` 或 `Q`这样的第三方库了,你现在可以使用 [原生的 promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). 它们公开了如下 API:
```
var p1 = new Promise(function (resolve, reject) {});
var p2 = Promise.resolve(20);
var p3 = Promise.reject(new Error());
var p4 = Promise.all(p1, p2);
var p5 = Promise.race(p1, p2);
// 显然
p1.then(() => {}).catch(() => {});
```
### 6. 字符串方法
我们也有了一系列新的字符串功能:
```
// 在几种情况下可以替代 `indexOf()`
name.startsWith('a')
name.endsWith('c');
name.includes('b');
// 重复字符串三次
name.repeat(3);
```
去告诉那些使用 Ruby 的家伙吧!字符串现在也 [对 unicode 支持更好了](https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/ECMAScript_6_support_in_Mozilla#Additions_to_the_String_object)。
### 7. let 和 const
猜猜下列函数调用的返回值:
```
var x = 20;
(function () {
if (x === 20) {
var x = 30;
}
return x;
}()); // -> undefined
```
是的, `undefined`。使用 `let` 替代 `var` ,你会得到预期的行为:
```
let x = 20;
(function () {
if (x === 20) {
let x = 30;
}
return x;
}()); // -> 20
```
原因是什么呢? `var` 是函数作用域,而 `let` 是块级作用域(如大部分人所预期的)。因此,可以说 `let` 是一个新`var`。 你可以[在 MDN 上了解更多细节](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/let)。
此外,Node.js 也[支持 const 关键字](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/const)了,它可以防止你为同一个引用赋予不同的值:
```
var MY_CONST = 42; // no, no
const MY_CONST = 42; // yes, yes
MY_CONST = 10 // 使用了 const ,这就不行了
```
### 结语
Node.js 4.0.0 带来了更多的 ES6 特性,我希望这七个例子可以吸引你升级到最新版本。
还有更多的语言特性呢(例如,maps/sets, 符号和生成器,这里只提到了一点)。你可以看看 [Node.js 4.0.0 的 ES6 概览](https://nodejs.org/en/docs/es6/)。 赶快升级吧!
| 200 | OK | 151amjs澳金沙门(中国)有限公司
404 Error
: 抱歉, 您所查找的页面不存在, 可能已被删除或您输错了网址!
◂返回首页
◂返回上一页
没有发现你要找的页面, 经砖家仔细研究结果如下:
贵玉手输入地址时可能存在键入错误
小蜗牛把页面落家里忘记带了
电信网通那头接口生锈了
网站首页
|
151amjs澳金沙门
|
新闻中心
|
产品展示
|
在线留言
|
151amjs澳金沙门
XML 地图
|
Sitemap 地图 |
6,219 | 使用脚本便捷地在 Ubuntu 中安装最新 Linux 内核 | http://ubuntuhandbook.org/index.php/2015/08/install-latest-kernel-script/ | 2015-09-15T10:36:00 | [
"内核",
"升级"
] | https://linux.cn/article-6219-1.html | 
想要安装最新的Linux内核吗?一个简单的脚本就可以在Ubuntu系统中方便的完成这项工作。
Michael Murphy 写了一个脚本用来将最新的候选版、标准版、或者低延时版的内核安装到 Ubuntu 系统中。这个脚本会在询问一些问题后从 [Ubuntu 内核主线页面](http://kernel.ubuntu.com/%7Ekernel-ppa/mainline/) 下载安装最新的 Linux 内核包。
### 通过脚本来安装、升级Linux内核:
1、 点击这个 [github 页面](https://gist.github.com/mmstick/8493727) 右上角的 “Download Zip” 来下载该脚本(注:此脚本在墙外,我已经搬运回来了,请参见下面。)。
2、鼠标右键单击用户下载目录下的 Zip 文件,选择 “在此展开” 将其解压。
3、右键点击解压后的文件夹,选择 “在终端中打开” 到此文件夹下。

此时将会打开一个终端,并且自动导航到目标文件夹下。如果你找不到 “在终端中打开” 选项的话,在 Ubuntu 软件中心搜索安装 `nautilus-open-terminal` ,然后重新登录系统即可(也可以再终端中运行 `nautilus -q` 来取代重新登录系统的操作)。
备注:此脚本如下,你可以将它保存为一个可执行的 shell 脚本:
```
#!/bin/bash
cd /tmp
if ! which lynx > /dev/null; then sudo apt-get install lynx -y; fi
if [ "$(getconf LONG_BIT)" == "64" ]; then arch=amd64; else arch=i386; fi
function download() {
wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | grep "$1" | grep "$2" | grep "$arch" | cut -d ' ' -f 4)
}
# Kernel URL
read -p "Do you want the latest RC?" rc
case "$rc" in
y* | Y*) kernelURL=$(lynx -dump -nonumbers http://kernel.ubuntu.com/~kernel-ppa/mainline/ | tail -1) ;;
n* | N*) kernelURL=$(lynx -dump -nonumbers http://kernel.ubuntu.com/~kernel-ppa/mainline/ | grep -v rc | tail -1) ;;
*) exit ;;
esac
read -p "Do you want the lowlatency kernel?" lowlatency
case "$lowlatency" in
y* | Y*) lowlatency=1 ;;
n* | n*) lowlatency=0 ;;
*) exit ;;
esac
# Download Kernel
if [ "$lowlatency" == "0" ]; then
echo "Downloading the latest generic kernel."
download generic header
download generic image
elif [ "$lowlatency" == "1" ]; then
echo "Downloading the latest lowlatency kernel."
download lowlatency header
download lowlatency image
fi
# Shared Kernel Header
wget $(lynx -dump -listonly -dont-wrap-pre $kernelURL | grep all | cut -d ' ' -f 4)
# Install Kernel
echo "Installing Linux Kernel"
sudo dpkg -i linux*.deb
echo "Done. You may now reboot."
```
4. 当进入终端后,运行以下命令来赋予脚本执行本次操作的权限。
```
chmod +x *
```
最后,每当你想要安装或升级 Ubuntu 的 linux 内核时都可以运行此脚本。
```
./*
```

这里之所以使用 \* 替代脚本名称是因为文件夹中只有它一个文件。
如果脚本运行成功,重启电脑即可。
### 恢复并且卸载新版内核
如果因为某些原因要恢复并且移除新版内核的话,请重启电脑,在 Grub 启动器的 **高级选项** 菜单下选择旧版内核来启动系统。
当系统启动后,参照下边章节继续执行。
### 如何移除旧的(或新的)内核:
1. 从 Ubuntu 软件中心安装 Synaptic Package Manager。
2. 打开 Synaptic Package Manager 然后如下操作:
* 点击 **Reload** 按钮,让想要被删除的新内核显示出来.
* 在左侧面板中选择 **Status -> Installed** ,让查找列表更清晰一些。
* 在 Quick filter 输入框中输入 **linux-image-** 用于查询。
* 选择一个内核镜像 “linux-image-x.xx.xx-generic” 然后将其标记为removal(或者Complete Removal)
* 最后,应用变更

重复以上操作直到移除所有你不需要的内核。注意,不要随意移除此刻正在运行的内核,你可以通过 `uname -r` 命令来查看运行的内核。
对于 Ubuntu 服务器来说,你可以一步步运行下面的命令:
```
uname -r
dpkg -l | grep linux-image-
sudo apt-get autoremove KERNEL_IMAGE_NAME
```

---
via: <http://ubuntuhandbook.org/index.php/2015/08/install-latest-kernel-script/>
作者:[Ji m](http://ubuntuhandbook.org/index.php/about/) 译者:[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,220 | 修复安装完 Ubuntu 后无可引导设备的错误 | http://itsfoss.com/no-bootable-device-found-ubuntu/ | 2015-09-15T13:33:00 | [
"UEFI",
"引导",
"安全引导"
] | https://linux.cn/article-6220-1.html | 通常情况下,我会安装启动 Ubuntu 和 Windows 的双系统,但是这次我决定完全消除 Windows 纯净安装 Ubuntu。纯净安装 Ubuntu 完成后,结束时屏幕输出<ruby> 无可引导设备 <rp> ( </rp> <rt> no bootable device found </rt> <rp> ) </rp></ruby>而不是进入 GRUB 界面。显然,安装搞砸了 UEFI 引导设置。

我会告诉你我是如何修复**在宏碁笔记本上安装 Ubuntu 后出现<ruby> 无可引导设备 <rp> ( </rp> <rt> no bootable device found </rt> <rp> ) </rp></ruby>错误**的。我声明了我使用的是宏碁灵越 R13,这很重要,因为我们需要更改固件设置,而这些设置可能因制造商和设备有所不同。
因此在你开始这里介绍的步骤之前,先看一下发生这个错误时我计算机的状态:
* 我的宏碁灵越 R13 预装了 Windows 8.1 和 UEFI 引导管理器
* <ruby> 安全引导 <rp> ( </rp> <rt> Secure boot </rt> <rp> ) </rp></ruby>没有关闭,(我的笔记本刚维修过,维修人员又启用了它,直到出现了问题我才发现)。你可以阅读这篇博文了解[如何在宏碁笔记本中关闭<ruby> 安全引导 <rp> ( </rp> <rt> secure boot </rt> <rp> ) </rp></ruby>](http://itsfoss.com/disable-secure-boot-in-acer/)
* 我选择了清除所有东西安装 Ubuntu,例如现有的 Windows 8.1,各种分区等
* 安装完 Ubuntu 之后,从硬盘启动时我看到无可引导设备错误。但能从 USB 设备正常启动
在我看来,没有禁用<ruby> 安全引导 <rp> ( </rp> <rt> secure boot </rt> <rp> ) </rp></ruby>可能是这个错误的原因。但是,我没有数据支撑我的观点。这仅仅是预感。有趣的是,双系统启动 Windows 和 Linux 经常会出现这两个 Grub 问题:
* [错误:没有 grub 救援分区](http://itsfoss.com/solve-error-partition-grub-rescue-ubuntu-linux/)
* [支持最小化 BASH 式的行编辑](http://itsfoss.com/fix-minimal-bash-line-editing-supported-grub-error-linux/)
如果你遇到类似的情况,你可以试试我的修复方法。
### 修复安装完 Ubuntu 后无可引导设备错误
请原谅我的图片质量很差。我的一加相机不能很好地拍摄笔记本屏幕。
#### 第一步
关闭电源并进入引导设置。我需要在宏碁灵越 R13 上快速地按下 Fn+F2。如果你使用固态硬盘的话要按的非常快,因为固态硬盘启动速度很快。这取决于你的制造商,你可能要用 Del 或 F10 或者 F12。
#### 第二步
在引导设置中,确保启用了<ruby> 安全引导 <rp> ( </rp> <rt> Secure Boot </rt> <rp> ) </rp></ruby>。它在 Boot 标签里。
#### 第三步
进入到 Security 标签,找到 “<ruby> 选择一个用于执行的可信任 UEFI 文件 <rp> ( </rp> <rt> Select an UEFI file as trusted for executing </rt> <rp> ) </rp></ruby>” 并敲击回车。

特意说明,我们这一步是要在你的设备中添加 UEFI 设置文件(安装 Ubuntu 的时候生成)到可信 UEFI 启动中。如果你记得的话,UEFI 启动的主要目的是提供安全性,由于(可能)没有禁用<ruby> 安全引导 <rp> ( </rp> <rt> Secure Boot </rt> <rp> ) </rp></ruby>,设备不会试图从新安装的操作系统中启动。添加它到类似白名单的可信列表,会使设备从 Ubuntu UEFI 文件启动。
#### 第四步
在这里你可以看到你的硬盘,例如 HDD0。如果你有多块硬盘,我希望你记住你安装 Ubuntu 的那块。同样敲击回车。

#### 第五步
你应该可以看到<EFI>了,敲击回车。

#### 第六步
在下一个屏幕中你会看到<ubuntu> 。耐心点,马上就好了。

#### 第七步
你可以看到 shimx64.efi,grubx64.efi 和 MokManager.efi 文件。重要的是 shimx64.efi。选中它并敲击回车。

在下一个屏幕中,输入 Yes 并敲击回车。

#### 第八步
当我们添加它到可信 EFI 文件并执行后,按 F10 保存并退出。

重启你的系统,这时你就可以看到熟悉的 GRUB 界面了。就算你没有看到 Grub 界面,起码也再也不会看到“<ruby> 无可引导设备 <rp> ( </rp> <rt> no bootable device found </rt> <rp> ) </rp></ruby>”。你应该可以进入 Ubuntu 了。
如果修复后搞乱了你的 Grub 界面,但你确实能登录系统,你可以重装 Grub 并进入到 Ubuntu 熟悉的紫色 Grub 界面。
我希望这篇指南能帮助你修复无可引导设备错误。欢迎提出任何疑问、建议或者感谢。
---
via: <http://itsfoss.com/no-bootable-device-found-ubuntu/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[ictlyh](http://www.mutouxiaogui.cn/blog/) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,229 | RHCSA 系列(四): 编辑文本文件及分析文本 | http://www.tecmint.com/rhcsa-exam-how-to-use-nano-vi-editors/ | 2015-09-16T10:11:00 | [
"RHCSA"
] | https://linux.cn/article-6229-1.html | 作为系统管理员的日常职责的一部分,每个系统管理员都必须处理文本文件,这包括编辑已有文件(大多可能是配置文件),或创建新的文件。有这样一个说法,假如你想在 Linux 世界中挑起一场圣战,你可以询问系统管理员们,什么是他们最喜爱的编辑器以及为什么。在这篇文章中,我们并不打算那样做,但我们将向你呈现一些技巧,这些技巧对使用两款在 RHEL 7 中最为常用的文本编辑器: nano(由于其简单和易用,特别是对于新手来说)和 vi/m(由于其自身的几个特色使得它不仅仅是一个简单的编辑器)来说都大有裨益。我确信你可以找到更多的理由来使用其中的一个或另一个,或许其他的一些编辑器如 emacs 或 pico。这完全取决于你自己。

*RHCSA: 使用 Nano 和 Vim 编辑文本文件 – Part 4*
### 使用 Nano 编辑器来编辑文件
要启动 nano,你可以在命令提示符下输入 `nano`,或可选地跟上一个文件名(在这种情况下,若文件存在,它将在编辑模式中被打开)。若文件不存在,或我们省略了文件名, nano 也将在编辑模式下开启,但将为我们开启一个空白屏以便开始输入:

*Nano 编辑器*
正如你在上一张图片中所见的那样, nano 在屏幕的底部呈现出一些可以通过指定的快捷键来触发的功能(^,即插入记号,代指 Ctrl 键)。它们中的一些是:
* Ctrl + G: 触发一个帮助菜单,带有一个关于功能和相应的描述的完整列表;

*Nano 编辑器帮助菜单*
* Ctrl + O: 保存更改到一个文件。它可以让你用一个与源文件相同或不同的名称来保存该文件,然后按 Enter 键来确认。

*Nano 编辑器的保存更改模式*
* Ctrl + X: 离开当前文件,假如更改没有被保存,则它们将被丢弃;
* Ctrl + R: 通过指定一个完整的文件路径,让你选择一个文件来将该文件的内容插入到当前文件中;

*Nano: 插入文件内容到主文件中*
上图的操作将把 `/etc/passwd` 的内容插入到当前文件中。
* Ctrl + K: 剪切当前行;
* Ctrl + U: 粘贴;
* Ctrl + C: 取消当前的操作并返回先前的屏幕;
为了轻松地在打开的文件中浏览, nano 提供了下面的功能:
* Ctrl + F 和 Ctrl + B 分别先前或向后移动光标;而 Ctrl + P 和 Ctrl + N 则分别向上或向下移动一行,功能与箭头键相同;
* Ctrl + space 和 Alt + space 分别向前或向后移动一个单词;
最后,
* 假如你想将光标移动到文档中的特定位置,使用 Ctrl + \_ (下划线) 并接着输入 X,Y 将准确地带你到 第 X 行,第 Y 列。

*在 nano 中定位到具体的行和列*
上面的例子将带你到当前文档的第 15 行,第 14 列。
假如你可以回忆起你早期的 Linux 岁月,特别是当你刚从 Windows 迁移到 Linux 中,你就可能会同意:对于一个新手来说,使用 nano 来开始学习是最好的方式。
### 使用 Vim 编辑器来编辑文件
Vim 是 vi 的加强版本,它是 Linux 中一个著名的文本编辑器,可在所有兼容 POSIX 的 \*nix 系统中获取到,例如在 RHEL 7 中。假如你有机会并可以安装 Vim,请继续;假如不能,这篇文章中的大多数(若不是全部)的提示也应该可以正常工作。
Vim 的一个出众的特点是可以在多个不同的模式中进行操作:
* <ruby> 命令模式 <rp> ( </rp> <rt> Command Mode </rt> <rp> ) </rp></ruby>将允许你在文件中跳转和输入命令,这些命令是由一个或多个字母组成的简洁且大小写敏感的组合。假如你想重复执行某个命令特定次数,你可以在这个命令前加上需要重复的次数(这个规则只有极少数例外)。例如, `yy`(或 `Y`,yank 的缩写)可以复制整个当前行,而 `4yy`(或 `4Y`)则复制整个从当前行到接下来的 3 行(总共 4 行)。
* 我们总是可以通过敲击 `Esc` 键来进入命令模式(无论我们正工作在哪个模式下)。
* 在<ruby> 末行模式 <rp> ( </rp> <rt> Ex Mode </rt> <rp> ) </rp></ruby>中,你可以操作文件(包括保存当前文件和运行外部的程序或命令)。要进入末行模式,你必须从命令模式中(换言之,输入 `Esc` + `:`)输入一个冒号(`:`),再直接跟上你想使用的末行模式命令的名称。
* 对于<ruby> 插入模式 <rp> ( </rp> <rt> Insert Mode </rt> <rp> ) </rp></ruby>,可以输入字母 `i` 进入,然后只需要输入文字即可。大多数的击键结果都将出现在屏幕中的文本中。
现在,让我们看看如何在 vim 中执行在上一节列举的针对 nano 的相同的操作。不要忘记敲击 Enter 键来确认 vim 命令。
为了从命令行中获取 vim 的完整手册,在命令模式下键入 `:help` 并敲击 Enter 键:

*vim 编辑器帮助菜单*
上面的部分呈现出一个内容列表,这些定义的小节则描述了 Vim 的特定话题。要浏览某一个小节,可以将光标放到它的上面,然后按 `Ctrl + ]` (闭方括号)。注意,底部的小节展示的是当前文件的内容。
1、 要保存更改到文件,在命令模式中运行下面命令中的任意一个,就可以达到这个目的:
```
:wq!
:x!
ZZ (是的,两个 ZZ,前面无需添加冒号)
```
2、 要离开并丢弃更改,使用 `:q!`。这个命令也将允许你离开上面描述过的帮助菜单,并返回到命令模式中的当前文件。
3、 剪切 N 行:在命令模式中键入 `Ndd`。
4、 复制 M 行:在命令模式中键入 `Myy`。
5、 粘贴先前剪贴或复制过的行:在命令模式中按 `P`键。
6、 要插入另一个文件的内容到当前文件:
```
:r filename
```
例如,插入 `/etc/fstab` 的内容,可以这样做:
[在 vi 编辑器中插入文件的内容](http://www.tecmint.com/wp-content/uploads/2015/03/Insert-Content-vi-Editor.png)
*在 vi 编辑器中插入文件的内容*
7、 插入一个命令的输出到当前文档:
```
:r! command
```
例如,要在光标所在的当前位置后面插入日期和时间:

*在 vi 编辑器中插入时间和日期*
在另一篇我写的文章中,([LFCS 系列(二)](http://www.tecmint.com/vi-editor-usage/)),我更加详细地解释了在 vim 中可用的键盘快捷键和功能。或许你可以参考那个教程来查看如何使用这个强大的文本编辑器的更深入的例子。
### 使用 grep 和正则表达式来分析文本
到现在为止,你已经学习了如何使用 nano 或 vim 创建和编辑文件。打个比方说,假如你成为了一个文本编辑器忍者 – 那又怎样呢? 在其他事情上,你也需要知道如何在文本中搜索正则表达式。
正则表达式(也称为 "regex" 或 "regexp") 是一种识别一个特定文本字符串或模式的方式,使得一个程序可以将这个模式和任意的文本字符串相比较。尽管利用 grep 来使用正则表达式值得用一整篇文章来描述,这里就让我们复习一些基本的知识:
**1、 最简单的正则表达式是一个由数字和字母构成的字符串(例如,单词 "svm") ,或者两个(在使用两个字符串时,你可以使用 `|`(或) 操作符):**
```
# grep -Ei 'svm|vmx' /proc/cpuinfo
```
上面命令的输出结果中若有这两个字符串之一的出现,则标志着你的处理器支持虚拟化:

*正则表达式示例*
**2、 第二种正则表达式是一个范围列表,由方括号包裹。**
例如, `c[aeiou]t` 匹配字符串 cat、cet、cit、cot 和 cut,而 `[a-z]` 和 `[0-9]` 则相应地匹配小写字母或十进制数字。假如你想重复正则表达式 X 次,在正则表达式的后面立即输入 `{X}`即可。
例如,让我们从 `/etc/fstab` 中析出存储设备的 UUID:
```
# grep -Ei '[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}' -o /etc/fstab
```

*从一个文件中析出字符串*
方括号中的第一个表达式 `[0-9a-f]` 被用来表示小写的十六进制字符,`{8}`是一个量词,暗示前面匹配的字符串应该重复的次数(在一个 UUID 中的开头序列是一个 8 个字符长的十六进制字符串)。
在圆括号中,量词 `{4}`和连字符暗示下一个序列是一个 4 个字符长的十六进制字符串,接着的量词 `({3})`表示前面的表达式要重复 3 次。
最后,在 UUID 中的最后一个 12 个字符长的十六进制字符串可以由 `[0-9a-f]{12}` 取得, `-o` 选项表示只打印出在 `/etc/fstab`中匹配行中的匹配的(非空)部分。
**3、 POSIX 字符类**
| 字符类 | 匹配 … |
| --- | --- |
| `[:alnum:]` | 任意字母或数字 [a-zA-Z0-9] |
| `[:alpha:]` | 任意字母 [a-zA-Z] |
| `[:blank:]` | 空格或制表符 |
| `[:cntrl:]` | 任意控制字符 (ASCII 码的 0 至 32) |
| `[:digit:]` | 任意数字 [0-9] |
| `[:graph:]` | 任意可见字符 |
| `[:lower:]` | 任意小写字母 [a-z] |
| `[:print:]` | 任意非控制字符 |
| `[:space:]` | 任意空格 |
| `[:punct:]` | 任意标点字符 |
| `[:upper:]` | 任意大写字母 [A-Z] |
| `[:xdigit:]` | 任意十六进制数字 [0-9a-fA-F] |
| `[:word:]` | 任意字母,数字和下划线 [a-zA-Z0-9\_] |
例如,我们可能会对查找已添加到我们系统中给真实用户的 UID 和 GID(参考“[RHCSA 系列(二): 如何进行文件和目录管理](/article-6155-1.html)”来回忆起这些知识)感兴趣。那么,我们将在 `/etc/passwd` 文件中查找 4 个字符长的序列:
```
# grep -Ei [[:digit:]]{4} /etc/passwd
```

*在文件中查找一个字符串*
上面的示例可能不是真实世界中使用正则表达式的最好案例,但它清晰地启发了我们如何使用 POSIX 字符类来使用 grep 分析文本。
### 总结
在这篇文章中,我们已经提供了一些技巧来最大地利用针对命令行用户的两个文本编辑器 nano 和 vim,这两个工具都有相关的扩展文档可供阅读,你可以分别查询它们的官方网站(链接在下面给出)以及使用“[RHCSA 系列(一): 回顾基础命令及系统文档](/article-6133-1-rel.html)”中给出的建议。
#### 参考文件链接
* <http://www.nano-editor.org/>
* <http://www.vim.org/>
---
via: <http://www.tecmint.com/rhcsa-exam-how-to-use-nano-vi-editors/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[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,230 | 在 Ubuntu 上安装类 Winamp 的音频播放器 Qmmp 0.9.0 | http://ubuntuhandbook.org/index.php/2015/09/qmmp-0-9-0-in-ubuntu/ | 2015-09-16T14:31:00 | [
"Qmmp",
"媒体播放器"
] | https://linux.cn/article-6230-1.html | 
Qmmp,一个基于 Qt 的音频播放器,与 Winamp 或 xmms 的用户界面类似,现在最新版本是0.9.0。PPA 已经在 Ubuntu 15.10,Ubuntu 15.04,Ubuntu 14.04,Ubuntu 12.04 和其衍生版本中已经更新了。
Qmmp 0.9.0 是一个较大的版本,有许多新的功能,有许多改进和新的转变。它添加了如下功能:
* 音频-信道序列转换器;
* 9通道支持均衡器;
* 支持艺术家专辑标签;
* 异步排序;
* 不用修改 qmmp.pri 来禁用插件(仅在 qmake 中)功能
* 记住播放列表滚动位置功能;
* 排除 cue 数据文件功能;
* 更改用户代理功能;
* 改变窗口标题功能;
* 禁用 gme 插件淡出的功能;
* 简单用户界面(QSUI)有以下变化:
+ 增加了多列的支持;
+ 增加了按艺术家专辑排序;
+ 增加了按文件的修改日期进行排序;
+ 增加了隐藏歌曲长度功能;
+ 增加了“Rename List”的默认热键;
+ 增加了“Save List”功能到标签菜单;
+ 增加了复位字体功能;
+ 增加了复位快捷键功能;
+ 改进了状态栏;
它还改进了播放列表的改变通知,播放列表容器,采样率转换器,cmake 构建脚本,标题格式化,在 mpeg 插件中支持 ape 标签,fileops 插件,降低了 cpu 占用率,改变默认的皮肤(炫光)和分离的播放列表。

### 在 Ubuntu 中安装 Qmmp 0.9.0 :
新版本已经制做了 PPA,适用于目前所有 Ubuntu 发行版和衍生版。
1、添加 [Qmmp PPA](https://launchpad.net/%7Eforkotov02/+archive/ubuntu/ppa).
从 Dash 中打开终端并启动应用,通过按 Ctrl+Alt+T 快捷键。当它打开时,运行命令:
```
sudo add-apt-repository ppa:forkotov02/ppa
```

2、在添加 PPA 后,通过更新软件来升级 Qmmp 播放器。刷新系统缓存,并通过以下命令安装软件:
```
sudo apt-get update
sudo apt-get install qmmp qmmp-plugin-pack
```
就是这样。尽情享受吧!
---
via: <http://ubuntuhandbook.org/index.php/2015/09/qmmp-0-9-0-in-ubuntu/>
作者:[Ji m](http://ubuntuhandbook.org/index.php/about/) 译者:[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,234 | Debian 项目不再提供 CD 格式的 ISO 镜像 | https://lists.debian.org/debian-devel-announce/2015/09/msg00004.html | 2015-09-17T07:36:00 | [
"Debian",
"镜像"
] | https://linux.cn/article-6234-1.html | debian-cd 项目负责人 Stephen McIntyre [今天在Debian邮件列表中](https://lists.debian.org/debian-devel-announce/2015/09/msg00004.html)对近日召开的 DebConf15 大会上的 Debian CD BoF会议进行了摘要总结。
该消息说,自即将发布的 Debian GNU/Linux 9.0 (Stretch) 版本开始,今后 Debian GNU/Linux 系统不再生成 CD 套装的 ISO 镜像,但是会依旧生成 DVD 和蓝光镜像。

当前 debian-cd 项目会生成大量的各种镜像,包括:
* CD
* DVD
* 非自由的网络安装镜像(包括非自由的固件包)
* 非自由的固件打包
debian-live 团队使用 live-build 创建的在线镜像(Live image)
* 包括非自由的固件的镜像
openstack-debian-images 生成的 Openstack 镜像
所有这些都是在 pettersson 上构建的,这是一台托管在 umu.se 的大型中央化的 CD 构建机。
对于新的发行版和测试版本,会停止构建它的完整 CD 套装(针对 90% 以上的系统架构)。同时,也会停止构建针对不同桌面的可选的 CD1 。不过,会继续构建 DVD 和蓝光镜像,DVD#1 也可以继续用于 4GB 的 USB 存储棒。
网络安装镜像会继续构建,这个又小又方便的镜像还有很多人用。对于旧的发行版,会继续构建 CD 套装和可选的 CD1 (Wheezy 和 Jessie),这个不会半途而废。
| 200 | OK | [ Please note the cross-post and Reply-To ] Hi folks, As promised, here's a quick summary of what was discussed at the BoF session in Heidelberg. Apologies for the delay - it takes a while to write these up, especially when struck down with the traditional post-DebConf plague. :-( Thanks to the awesome efforts of our video team, the session is already online [1]. I've taken a copy of the Gobby notes too, alongside my small set of slides for the session. [2] Current state ============= We have a massive number of different images created using debian-cd: * CDs * DVDs * non-free netinsts (including non-free firmware packages) * non-free firmware bundles Live images created using live-build etc. from the debian-live team * including non-free images with firmware Openstack images using openstack-debian-images All of these are built on pettersson, our big central CD builder machine hosted by the nice folks at umu.se. Plans for images - no new CDs! ============================== I'm planning to basically stop making *CD* sets for new builds (testing/stretch onwards). What do I mean by that? We'll stop building full CD sets of all of Debian (up to 90 per architecture) for new releases, and testing. And we'll also kill the differing CD1 options for different desktops. We'll continue building DVD and BD images. DVD#1 will continue to be configured to fir on a 4GB USB stick. We'll *keep* building netinst images as a small handy image type that many people use, and we'll keep building CD sets and CD1 options for older releases (Wheezy and Jessie) - we're not going to change tack on those half-way through. Why are we doing this? Two main reasons: * Essentially, approximately nobody is using these images any more. The chances of anybody actually using (for example) mips CD43 is zero. There's no point in making these any more and wasting the time, effort and disk space. For those people who are still stuck on machines that for some reason can't use bigger media, the netinst will suffice for boot and then use the network or similar. For anybody actually writing CDs, blank DVD media would be so much cheaper today that it would be cheaper to use DVDs and buy a drive! * It's become less and less useful to install from CD in recent years. We've had an ever-present problem with the different desktop environments growing in size as they add more features. For the last couple of releases, the small subset of Gnome or KDE that would fit on a single CD is, at best, not a good representation of the desktop capabilities. At worst, it's been simply non-functional without adding an extra package source (more discs, or a network repository). If users are stuck booting off smaller media, then I'd recommend using the netinst to boot and then add more package sources later. Stretch d-i alpha 3 (just released this week) is the last build I expect to include CDs with. Live images have mostly been too large to fit on CD for a while anyway - no plans to change the set there. I'm open to making more different-sized image types so long as they make sense - ask! get.debian.org ============== With the change to not make CDs, using cdimage.debian.org as the name for our central distribution site is a little silly! After some consultation on the mailing lists for a better name, I've picked get.debian.org as a new name. For the sake of old links etc., the old name is not going to go away. But for new links, documentation etc. we should start linking to get.debian.org instead. For now, the main landing page at get.debian.org is still the same as that for cdimage.debian.org. We'll work on this shortly. Help would be lovely! Non-free images =============== As mentioned in the firmware talk[3], We make a number of *unofficial* non-free images alongside our normal installer and live images today. They're essentially the same as the normal images, but with non-free firmware included for those people who need it to make their hardware function correctly. We've deliberately not advertised these very much in the past, so much so that many people (including lots of DDs!) don't even know these exist. We're planning to advertise them some more, and make some detail changes in how we deal with firmware which will make things easier for people, but we will *not* be including non-free firmware on official Debian media any time soon. See the firmware discussion for more details. New image types =============== We've recently added official Debian Openstack images. We'd like to add more types of image in the future. We have the capacity to make more images available on get.debian.org, and we are currently specifying a new more powerful server which will make that better again. Currently I'm thinking of: * More cloud images (Google, Microsoft, Amazon, Profitbricks, ...), or using cloud-init or something similar to make single images work on all the different clouds. Several of the vendors already have "Debian" images, but we're not 100% sure of their provenance, If possible, it would be lovely to make official images on Debian-controlled machines so that people can trust them fully. * More live images, starting with some for Blends. Iain Learmonth already has been working on a Debian Hams image, and there are more coming, I'm sure. * Live images for non-x86 targets, where they make sense. Many won't make sense, due to difficulty in booting them, lack of memory, etc. But some will, and we're thinking of arm64 and (maybe) armhf as the first targets here. * Neil Williams has been putting a lot of effort into the vmdebootstrap tool as a generic way of making a wide variety of live-style images. A major new addition is UEFI support. \o/ Suggestions and comments from the BoF: * Add a simple live netboot image (kernel and initramfs) which will grab and extract a tarball into a tmpfs for general usage * In Riku's bootable images talk[4] we heard that there are more than 10(!) different image creation tools in common use, just within Debian. Most of the job is simple, but lots of the tools only do a small subset of the simple things! If you're interested in any of this (helping, or ideas for more images) please talk to us! Misc questions and discussion ============================= Q. Multi-architecture CDs - possible? A. Yes, but it depends massively on the architectures involved. We already do multi-arch amd64/i386 CDs/DVDs, and we used to have others: amd64/i386/powerpc, alpha/hppa/ia64 (the HP special!). There's scope to make more like this, so long as the architectures don't clash in terms of how their boot support is configured. Sector 0 is special on lots of different architectures, and some of them clash in terms of what they want in various locations in this boot sector. More important is how useful the resulting images are for users... :-) The m-a x86 netinst is nice as that way we can ship a single image/disc which will work on any PC. Didier Raboud has been hacking on getting auto-detect working again on that image. As/when/if we get another architecture (arm64?) with enough users, we may add that to the m-a netinst too. Q. What should we do to generate and test different cloud images? A. We need to get some testing infrastructure in place to do some basic QA on these. At the moment, the Openstack images seem to work OK (no bad feedback so far!), but we should be doing more. In terms of reporting issues, at the moment we don't have a specific place for that. Bug reports should probably go to the debian-cloud mailing list. Aside: we have a cdimage.debian.org BTS pseudo-package, and we clearly should add get.debian.org too. We should use that and redirect reports appropriately. We need to get some tests defined and running at build-time. Make sure that what we produce looks sane and is fit to be released. Maybe define standard tests for what's allowed to be called "Debian" in this area? Some discussion apparently happened in the "What should be allowed to call itself Debian" talk earlier", but there wasn't a clear agreement there. First test for cloud images - can we boot one of these images and ssh in? We have a framework for testing Debian installer CDs, but it's never been intergrated fully. :-( Similar story for live images - initial test implementation has happened, but it's not in use? "Packer" (I think) was mentioned software written in Go that can automate creation/testing(?) of various virtualisation image formats. Would need packaging for us to use it, needs volunteer(s). This whole area needs more help if it's going to happen in time for Stretch... Q. Can we tweak debian-cd to install a full 64-bit CD/system with *some* 32-bit support included, but not full? A. People have asked about this kind of thing multiple times in the past, but no code yet. debian-cd m-a support is currently designed to include exactly the same level of packages for all the architectures on a m-a CD. This could be hacked fairly easily to fix that - just include the base system and some libraries for secondary architectures. No time to look at this yet, but a wishlist bug would help! :-) UEFI ==== We just started a new UEFI team a few weeks back[6]. We're explicitly looking for bug reports from people. If UEFI does not just work, please report issues. There's a cross-distro effort now going on to track these so that we can share information and complain to manufacturers. Secure Boot is in progress still. We were hoping to get it working last year, but for various reasons it didn't happen yet. Hoping to get something soon, maybe by the end of the year. We'll be adding support for boot, validating kernel and modules etc.; at least that's the plan. Still open for debate as to exactly what we're going to do. We'd love to do SB on x86 and arm64 at the very least. We aim to have working SB support in d-i, debian-cd, kernel and bootloaders. Will derivatives be able to hook in? Honestly not sure - the devil is in the details here. How far does the trust chain extend? Will arm64 shim be signed by Microsoft? No idea - it's under discussion. kFreeBSD ======== UEFI (and SB) on kFreeBSD is an unknown quantity at this time. I've no idea how well it might work (or not). Help needed, happy to plumb it in in Debian if somebody can tell us how! We may get an unofficial kFreeBSD jessie CD release done - waiting on information at this point. Please help! ============ We're always looking for more help, and we're about to add even more stuff to our TODO list. Also, always looking for more help when testing images for release etc. Join us on the debian-cd list, or on #debian-cd. [1][http://meetings-archive.debian.net/pub/debian-meetings/2015/debconf15/Debian_CD_discussion.webm][2][http://www.einval.com/~steve/talks/Debconf15-CDs-are-dead/][3][https://lists.debian.org/debian-devel/2015/08/msg00622.html][4][https://summit.debconf.org/debconf15/meeting/246/creating-bootable-debian-images/][5][https://summit.debconf.org/debconf15/meeting/205/what-should-be-allowed-to-call-itself-debian/][6][http://blog.einval.com/2015/08/02#new_debian_uefi_team]-- Steve McIntyre, Cambridge, UK. steve@einval.com The two hard things in computing: * naming things * cache invalidation * off-by-one errors -- Stig Sandbeck Mathisen
**Attachment:
** |
6,240 | Linux 有问必答:如何在 Linux 中统计一个进程的线程数 | http://ask.xmodulo.com/number-of-threads-process-linux.html | 2015-09-17T10:29:16 | [
"线程",
"进程"
] | /article-6240-1.html |
>
> **问题**: 我正在运行一个程序,它在运行时会派生出多个线程。我想知道程序在运行时会有多少线程。在 Linux 中检查进程的线程数最简单的方法是什么?
>
>
>
如果你想看到 Linux 中每个进程的线程数,有以下几种方法可以做到这一点。
### 方法一: /proc
proc 伪文件系统,它驻留在 /proc 目录,这是最简单的方法来查看任何活动进程的线程数。 /proc 目录以可读文本文件形式输出,提供现有进程和系统硬件相关的信息如 CPU、中断、内存、磁盘等等.
```
$ cat /proc/<pid>/status
```
上面的命令将显示进程 <pid> 的详细信息,包括过程状态(例如, sleeping, running),父进程 PID,UID,GID,使用的文件描述符的数量,以及上下文切换的数量。输出也包括**进程创建的总线程数**如下所示。
```
Threads: <N>
```
例如,检查 PID 20571进程的线程数:
```
$ cat /proc/20571/status
```

输出表明该进程有28个线程。
或者,你可以在 /proc//task 中简单的统计子目录的数量,如下所示。
```
$ ls /proc/<pid>/task | wc
```
这是因为,对于一个进程中创建的每个线程,在 `/proc/<pid>/task` 中会创建一个相应的目录,命名为其线程 ID。由此在 `/proc/<pid>/task` 中目录的总数表示在进程中线程的数目。
### 方法二: ps
如果你是功能强大的 ps 命令的忠实用户,这个命令也可以告诉你一个进程(用“H”选项)的线程数。下面的命令将输出进程的线程数。“h”选项需要放在前面。
```
$ ps hH p <pid> | wc -l
```
如果你想监视一个进程的不同线程消耗的硬件资源(CPU & memory),请参阅[此教程](/article-5633-1.html)。
---
via: <http://ask.xmodulo.com/number-of-threads-process-linux.html>
作者:[Dan Nanni](http://ask.xmodulo.com/author/nanni) 译者:[strugglingyouth](https://github.com/strugglingyouth) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='ask.xmodulo.com', port=80): Max retries exceeded with url: /number-of-threads-process-linux.html (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7b83275812d0>: Failed to resolve 'ask.xmodulo.com' ([Errno -2] Name or service not known)")) | null |
6,241 | Nmcli 网络管理命令行工具基础 | http://www.unixmen.com/basics-networkmanager-command-line-tool-nmcli/ | 2015-09-17T10:57:00 | [
"nmcli"
] | https://linux.cn/article-6241-1.html | 
### 介绍
在本教程中,我们会在CentOS / RHEL 7中讨论<ruby> 网络管理命令行工具 <rp> ( </rp> <rt> NetworkManager command line tool </rt> <rp> ) </rp></ruby>,也叫**nmcli**。那些使用**ifconfig**的用户应该在CentOS 7中避免使用**ifconfig** 了。
让我们用nmcli工具配置一些网络设置。
#### 要得到系统中所有接口的地址信息
```
[root@localhost ~]# ip addr show
```
**示例输出:**
```
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
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: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:67:2f:4c brd ff:ff:ff:ff:ff:ff
inet 192.168.1.51/24 brd 192.168.1.255 scope global eno16777736
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe67:2f4c/64 scope link
valid_lft forever preferred_lft forever
```
#### 检索与已连接的接口相关的数据包统计
```
[root@localhost ~]# ip -s link show eno16777736
```
**示例输出:**

#### 得到路由配置
```
[root@localhost ~]# ip route
```
示例输出:
```
default via 192.168.1.1 dev eno16777736 proto static metric 100
192.168.1.0/24 dev eno16777736 proto kernel scope link src 192.168.1.51 metric 100
```
#### 分析主机/网站路径
```
[root@localhost ~]# tracepath unixmen.com
```
输出像traceroute,但是更加完整。

### nmcli 工具
**nmcli** 是一个非常丰富和灵活的命令行工具。nmcli使用的情况有:
* **设备** – 正在使用的网络接口
* **连接** – 一组配置设置,对于一个单一的设备可以有多个连接,可以在连接之间切换。
#### 找出有多少连接服务于多少设备
```
[root@localhost ~]# nmcli connection show
```

#### 得到特定连接的详情
```
[root@localhost ~]# nmcli connection show eno1
```
**示例输出:**

#### 得到网络设备状态
```
[root@localhost ~]# nmcli device status
```
---
```
DEVICE TYPE STATE CONNECTION
eno16777736 ethernet connected eno1
lo loopback unmanaged --
```
#### 使用“dhcp”创建新的连接
```
[root@localhost ~]# nmcli connection add con-name "dhcp" type ethernet ifname eno16777736
```
这里,
* **connection add** – 添加新的连接
* **con-name** – 连接名
* **type** – 设备类型
* **ifname** – 接口名
这个命令会使用dhcp协议添加连接
**示例输出:**
```
Connection 'dhcp' (163a6822-cd50-4d23-bb42-8b774aeab9cb) successfully added.
```
#### 不通过dhcp分配IP,使用“static”添加地址
```
[root@localhost ~]# nmcli connection add con-name "static" ifname eno16777736 autoconnect no type ethernet ip4 192.168.1.240 gw4 192.168.1.1
```
**示例输出:**
```
Connection 'static' (8e69d847-03d7-47c7-8623-bb112f5cc842) successfully added.
```
**更新连接:**
```
[root@localhost ~]# nmcli connection up eno1
```
再检查一遍,ip地址是否已经改变
```
[root@localhost ~]# ip addr show
```

#### 添加DNS设置到静态连接中
```
[root@localhost ~]# nmcli connection modify "static" ipv4.dns 202.131.124.4
```
#### 添加更多的DNS
```
[root@localhost ~]# nmcli connection modify "static" +ipv4.dns 8.8.8.8
```
**注意**:要使用额外的**+**符号,并且要是**+ipv4.dns**,而不是**ip4.dns**。
#### 添加一个额外的ip地址
```
[root@localhost ~]# nmcli connection modify "static" +ipv4.addresses 192.168.200.1/24
```
使用命令刷新设置:
```
[root@localhost ~]# nmcli connection up eno1
```

你会看见,设置生效了。
完结。
---
via: <http://www.unixmen.com/basics-networkmanager-command-line-tool-nmcli/>
作者:Rajneesh Upadhyay 译者:[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,245 | Linux 有问必答:如何删除 Ubuntu 上不再使用的旧内核 | http://ask.xmodulo.com/remove-kernel-images-ubuntu.html | 2015-09-18T09:14:43 | [
"Ubuntu",
"内核"
] | /article-6245-1.html |
>
> **提问**:过去我已经在我的Ubuntu上升级了几次内核。现在我想要删除这些旧的内核镜像来节省我的磁盘空间。如何用最简单的方法删除Ubuntu上先前版本的内核?
>
>
>
在Ubuntu上,有几个方法来升级内核。在Ubuntu桌面中,软件更新允许你每天检查并更新到最新的内核上。在Ubuntu服务器上,最为重要的安全更新项目之一就是 unattended-upgrades 软件包会自动更新内核。然而,你也可以手动用apt-get或者aptitude命令来更新。
随着时间的流逝,持续的内核更新会在系统中积聚大量的不再使用的内核,浪费你的磁盘空间。每个内核镜像和其相关联的模块/头文件会占用200-400MB的磁盘空间,因此由不再使用的内核而浪费的磁盘空间会快速地增加。

GRUB管理器为每个旧内核都维护了一个GRUB入口,以备你想要使用它们。

作为磁盘清理的一部分,如果你不再使用这些,你可以考虑清理掉这些镜像。
### 如何清理旧内核镜像
在删除旧内核之前,记住最好留有2个最近的内核(最新的和上一个版本),以防主要的版本出错。现在就让我们看看如何在Ubuntu上清理旧内核。
在Ubuntu内核镜像包含了以下的包。
* **linux-image-**: 内核镜像
* **linux-image-extra-**: 额外的内核模块
* **linux-headers-**: 内核头文件
首先检查系统中安装的内核镜像。
```
$ dpkg --list | grep linux-image
$ dpkg --list | grep linux-headers
```
在列出的内核镜像中,你可以移除一个特定的版本(比如3.19.0-15)。
```
$ sudo apt-get purge linux-image-3.19.0-15
$ sudo apt-get purge linux-headers-3.19.0-15
```
上面的命令会删除内核镜像和它相关联的内核模块和头文件。
注意如果你还没有升级内核那么删除旧内核会自动触发安装新内核。这样在删除旧内核之后,GRUB配置会自动升级来移除GRUB菜单中相关GRUB入口。
如果你有很多没用的内核,你可以用shell表达式来一次性地删除多个内核。注意这个括号表达式只在bash或者兼容的shell中才有效。
```
$ sudo apt-get purge linux-image-3.19.0-{18,20,21,25}
$ sudo apt-get purge linux-headers-3.19.0-{18,20,21,25}
```

上面的命令会删除4个内核镜像:3.19.0-18、3.19.0-20、3.19.0-21 和 3.19.0-25。
如果GRUB配置由于任何原因在删除旧内核后没有正确升级,你可以尝试手动用update-grub2命令来更新配置。
```
$ sudo update-grub2
```
现在就重启来验证GRUB菜单是否已经正确清理了。

---
via: <http://ask.xmodulo.com/remove-kernel-images-ubuntu.html>
作者:[Dan Nanni](http://ask.xmodulo.com/author/nanni) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='ask.xmodulo.com', port=80): Max retries exceeded with url: /remove-kernel-images-ubuntu.html (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7b8327580910>: Failed to resolve 'ask.xmodulo.com' ([Errno -2] Name or service not known)")) | null |
6,246 | 在 Ubuntu 和 Elementary OS 上使用 NaSC 进行简单数学运算 | http://itsfoss.com/math-ubuntu-nasc/ | 2015-09-18T09:23:42 | [
"NaSC",
"数学"
] | https://linux.cn/article-6246-1.html | 
[NaSC](http://parnold-x.github.io/nasc/),Not a Soulver Clone 的缩写,是为 elementary 操作系统开发的第三方应用程序。正如名字暗示的那样,NaSC 的灵感来源于 [Soulver](http://www.acqualia.com/soulver/),后者是像普通人一样进行数学计算的 OS X 应用。
Elementary OS 它自己本身借鉴了 OS X,也就不奇怪它的很多第三方应用灵感都来自于 OS X 应用。
回到 NaSC,“像普通人一样进行数学计算”到底是什么意思呢?事实上,它意味着正如你想的那样去书写。按照该应用程序的介绍:
>
> “它能使你像平常那样进行计算。它允许你输入任何你想输入的,智能识别其中的数学部分并在右边面板打印出结果。然后你可以在后面的等式中使用这些结果,如果结果发生了改变,等式中使用的也会同样变化。”
>
>
>
还不相信?让我们来看一个截图。

现在,你明白什么是 “像普通人一样做数学” 了吗?坦白地说,我并不是这类应用程序的粉丝,但对你们中的某些人可能会有用。让我们来看看怎么在 Elementary OS、Ubuntu 和 Linux Mint 上安装 NaSC。
### 在 Ubuntu、Elementary OS 和 Mint 上安装 NaSC
安装 NaSC 有一个可用的 PPA。PPA 是 ‘每日’,意味着每日构建(意即,不稳定),但作为我的快速测试,并没什么影响。
打开一个终端并运行下面的命令:
```
sudo apt-add-repository ppa:nasc-team/daily
sudo apt-get update
sudo apt-get install nasc
```
这是 Ubuntu 15.04 中使用 NaSC 的一个截图:

如果你想卸载它,可以使用下面的命令:
```
sudo apt-get remove nasc
sudo apt-add-repository --remove ppa:nasc-team/daily
```
如果你试用了这个软件,要分享你的经验哦。除此之外,你也可以在第三方 Elementary OS 应用中体验 [Vocal podcast app for Linux](http://itsfoss.com/podcast-app-vocal-linux/)。
---
via: <http://itsfoss.com/math-ubuntu-nasc/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[ictlyh](http://www.mutouxiaogui.cn/blog/) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,249 | RHCSA 系列(五): RHEL7 中的进程管理:开机,关机 | http://www.tecmint.com/rhcsa-exam-boot-process-and-process-management/ | 2015-09-18T14:36:15 | [
"RHCSA"
] | https://linux.cn/article-6249-1.html | 我们将概括和简要地复习从你按开机按钮来打开你的 RHEL 7 服务器到呈现出命令行界面的登录屏幕之间所发生的所有事情,以此来作为这篇文章的开始。

*Linux 开机过程*
**请注意:**
1. 相同的基本原则也可以应用到其他的 Linux 发行版本中,但可能需要较小的更改,并且
2. 下面的描述并不是旨在给出开机过程的一个详尽的解释,而只是介绍一些基础的东西
### Linux 开机过程
1. 初始化 POST(加电自检)并执行硬件检查;
2. 当 POST 完成后,系统的控制权将移交给启动管理器的<ruby> 第一阶段 <rp> ( </rp> <rt> first stage </rt> <rp> ) </rp></ruby>,它存储在一个硬盘的引导扇区(对于使用 BIOS 和 MBR 的旧式的系统而言)或存储在一个专门的 (U)EFI 分区上。
3. 启动管理器的第一阶段完成后,接着进入启动管理器的<ruby> 第二阶段 <rp> ( </rp> <rt> second stage </rt> <rp> ) </rp></ruby>,通常大多数使用的是 GRUB(GRand Unified Boot Loader 的简称),它驻留在 `/boot` 中,然后开始加载内核和驻留在 RAM 中的初始化文件系统(被称为 initramfs,它包含执行必要操作所需要的程序和二进制文件,以此来最终挂载真实的根文件系统)。
4. 接着展示了<ruby> 闪屏 <rp> ( </rp> <rt> splash </rt> <rp> ) </rp></ruby>过后,呈现在我们眼前的是类似下图的画面,它允许我们选择一个操作系统和内核来启动:

*启动菜单屏幕*
5. 内核会对接入到系统的硬件进行设置,当根文件系统被挂载后,接着便启动 PID 为 1 的进程,这个进程将开始初始化其他的进程并最终呈现给我们一个登录提示符界面。
注意:假如我们想在启动后查看这些信息,我们可以使用 [dmesg 命令](/article-3587-1.html),并使用这个系列里的上一篇文章中介绍过的工具(注:即 grep)来过滤它的输出。

*登录屏幕和进程的 PID*
在上面的例子中,我们使用了大家熟知的 `ps` 命令来显示在系统启动过程中的一系列当前进程的信息,它们的父进程(或者换句话说,就是那个开启这些进程的进程)为 systemd(大多数现代的 Linux 发行版本已经切换到的系统和服务管理器):
```
# ps -o ppid,pid,uname,comm --ppid=1
```
记住 `-o`(为 -format 的简写)选项允许你以一个自定义的格式来显示 ps 的输出,以此来满足你的需求;这个自定义格式使用 `man ps` 里 STANDARD FORMAT SPECIFIERS 一节中的特定关键词。
另一个你想自定义 ps 的输出而不是使用其默认输出的情形是:当你需要找到引起 CPU 或内存消耗过多的那些进程,并按照下列方式来对它们进行排序时:
```
# ps aux --sort=+pcpu # 以 %CPU 来排序(增序)
# ps aux --sort=-pcpu # 以 %CPU 来排序(降序)
# ps aux --sort=+pmem # 以 %MEM 来排序(增序)
# ps aux --sort=-pmem # 以 %MEM 来排序(降序)
# ps aux --sort=+pcpu,-pmem # 结合 %CPU (增序) 和 %MEM (降序)来排列
```

*自定义 ps 命令的输出*
### systemd 的一个介绍
在 Linux 世界中,很少有能比在主流的 Linux 发行版本中采用 systemd 引起更多的争论的决定。systemd 的倡导者根据以下事实来表明其主要的优势:
1. 在系统启动期间,systemd 允许并发地启动更多的进程(相比于先前的 SysVinit,SysVinit 似乎总是表现得更慢,因为它一个接一个地启动进程,检查一个进程是否依赖于另一个进程,然后等待守护进程启动才可以启动的更多的服务),并且
2. 在一个运行着的系统中,它用作一个动态的资源管理器。这样在启动期间,当一个服务被需要时,才启动它(以此来避免消耗系统资源)而不是在没有一个合理的原因的情况下启动额外的服务。
3. 向后兼容 sysvinit 的脚本。
另外请阅读: ['init' 和 'systemd' 背后的故事](http://www.tecmint.com/systemd-replaces-init-in-linux/)
systemd 由 systemctl 工具控制,假如你了解 SysVinit,你将会对以下的内容感到熟悉:
* service 工具,在旧一点的系统中,它被用来管理 SysVinit 脚本,以及
* chkconfig 工具,为系统服务升级和查询运行级别信息
* shutdown 你一定使用过几次来重启或关闭一个运行的系统。
下面的表格展示了使用传统的工具和 systemctl 之间的相似之处:
| 旧式工具 | Systemctl 等价命令 | 描述 |
| --- | --- | --- |
| service name start | systemctl start name | 启动 name (这里 name 是一个服务) |
| service name stop | systemctl stop name | 停止 name |
| service name condrestart | systemctl try-restart name | 重启 name (如果它已经运行了) |
| service name restart | systemctl restart name | 重启 name |
| service name reload | systemctl reload name | 重载 name 的配置 |
| service name status | systemctl status name | 显示 name 的当前状态 |
| service - status-all | systemctl | 显示当前所有服务的状态 |
| chkconfig name on | systemctl enable name | 通过一个特定的单元文件,让 name 可以在系统启动时运行(这个文件是一个符号链接)。启用或禁用一个启动时的进程,实际上是增加或移除一个到 /etc/systemd/system 目录中的符号链接。 |
| chkconfig name off | systemctl disable name | 通过一个特定的单元文件,让 name 可以在系统启动时禁止运行(这个文件是一个符号链接)。 |
| chkconfig -list name | systemctl is-enabled name | 确定 name (一个特定的服务)当前是否启用。 |
| chkconfig - list | systemctl - type=service | 显示所有的服务及其是否启用或禁用。 |
| shutdown -h now | systemctl poweroff | 关机 |
| shutdown -r now | systemctl reboot | 重启系统 |
systemd 也引进了单元(unit)(它可能是一个服务,一个挂载点,一个设备或者一个网络套接字)和目标(target)(它们定义了 systemd 如何去管理和同时开启几个相关的进程,可以认为它们与在基于 SysVinit 的系统中的运行级别等价,尽管事实上它们并不等价)的概念。
### 总结归纳
其他与进程管理相关,但并不仅限于下面所列的功能的任务有:
**1. 在考虑到系统资源的使用上,调整一个进程的执行优先级:**
这是通过 `renice` 工具来完成的,它可以改变一个或多个正在运行着的进程的调度优先级。简单来说,调度优先级是一个允许内核(当前只支持 >= 2.6 的版本)根据某个给定进程被分配的执行优先级(即友善度(niceness),从 -20 到 19)来为其分配系统资源的功能。
`renice` 的基本语法如下:
```
# renice [-n] priority [-gpu] identifier
```
在上面的通用命令中,第一个参数是将要使用的优先级数值,而另一个参数可以是进程 ID(这是默认的设定),进程组 ID,用户 ID 或者用户名。一个常规的用户(即除 root 以外的用户)只可以更改他或她所拥有的进程的调度优先级,并且只能增加友善度的层次(这意味着占用更少的系统资源)。

*进程调度优先级*
**2. 按照需要杀死一个进程(或终止其正常执行):**
更精确地说,杀死一个进程指的是通过 [kill 或 pkill](/article-2116-1.html) 命令给该进程发送一个信号,让它优雅地(SIGTERM=15)或立即(SIGKILL=9)结束它的执行。
这两个工具的不同之处在于前一个被用来终止一个特定的进程或一个进程组,而后一个则允许你通过进程的名称和其他属性,执行相同的动作。
另外, pkill 与 pgrep 相捆绑,pgrep 提供将受符合的进程的 PID 给 pkill 来使用。例如,在运行下面的命令之前:
```
# pkill -u gacanepa
```
查看一眼由 gacanepa 所拥有的 PID 或许会带来点帮助:
```
# pgrep -l -u gacanepa
```

*找到用户拥有的 PID*
默认情况下,kill 和 pkiill 都发送 SIGTERM 信号给进程,如我们上面提到的那样,这个信号可以被忽略(即该进程可能会终止其自身的执行,也可能不终止),所以当你因一个合理的理由要真正地停止一个运行着的进程,则你将需要在命令行中带上特定的 SIGKILL 信号:
```
# kill -9 identifier # 杀死一个进程或一个进程组
# kill -s SIGNAL identifier # 同上
# pkill -s SIGNAL identifier # 通过名称或其他属性来杀死一个进程
```
### 结论
在这篇文章中,我们解释了在 RHEL 7 系统中,有关开机启动过程的基本知识,并分析了一些可用的工具来帮助你通过使用一般的程序和 systemd 特有的命令来管理进程。
请注意,这个列表并不旨在涵盖有关这个话题的所有花哨的工具,请随意使用下面的评论栏来添加你自已钟爱的工具和命令。同时欢迎你的提问和其他的评论。
---
via: <http://www.tecmint.com/rhcsa-exam-boot-process-and-process-management/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[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,255 | 也许你需要在 Antergos 与 Arch Linux 中查看印度语和梵文? | http://itsfoss.com/display-hindi-arch-antergos/ | 2015-09-20T19:41:48 | [
"印度语",
"梵文"
] | https://linux.cn/article-6255-1.html | 
你们到目前或许知道,我最近一直在尝试体验 [Antergos Linux](http://antergos.com/)。在安装完[Antergos](http://itsfoss.com/tag/antergos/)后我所首先注意到的一些事情是在默认的 Chromium 浏览器中**没法正确显示印度语脚本**。
这是一件奇怪的事情,在我之前桌面Linux的体验中是从未遇到过的。起初,我认为是浏览器的问题,所以我安装了Firefox,然而问题依旧,Firefox也不能正确显示印度语。和Chromium不显示任何东西不同的是,Firefox确实显示了一些东西,但是毫无可读性。

*Chromium中的印度语显示*

*Firefox中的印度语显示*
奇怪吧?那么,默认情况下基于Arch的Antergos Linux中没有印度语的支持吗?我没有去验证,但是我假设其它基于梵语脚本的印地语之类会产生同样的问题。
在这个快速指南中,我打算为大家演示如何来添加梵语支持,以便让印度语和其它印地语都能正确显示。
### 在Antergos和Arch Linux中添加印地语支持
打开终端,使用以下命令:
```
sudo yaourt -S ttf-indic-otf
```
键入密码,它会提供给你对于印地语的译文支持。
重启Firefox,会马上正确显示印度语了,但是它需要一次重启来显示印度语。因此,我建议你在安装了印地语字体后**重启你的系统**。

我希望这篇快速指南能够帮助你,让你可以在Antergos和其它基于Arch的Linux发行版中,如Manjaro Linux,阅读印度语、梵文、泰米尔语、泰卢固语、马拉雅拉姆语、孟加拉语,以及其它印地语。
---
via: <http://itsfoss.com/display-hindi-arch-antergos/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[GOLinux](https://github.com/GOLinux) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,256 | 如何在 Docker 容器中运行支持 OData 的 JBoss 数据虚拟化 GA | http://linoxide.com/linux-how-to/run-jboss-data-virtualization-ga-odata-docker-container/ | 2015-09-21T10:49:00 | [
"JBoss",
"Docker"
] | /article-6256-1.html | 大家好,我们今天来学习如何在一个 Docker 容器中运行支持 OData(译者注:Open Data Protocol,开放数据协议) 的 JBoss 数据虚拟化 6.0.0 GA(译者注:GA,General Availability,具体定义可以查看[WIKI](https://en.wikipedia.org/wiki/Software_release_life_cycle#General_availability_.28GA.29))。JBoss 数据虚拟化是数据提供和集成解决方案平台,将多种分散的数据源转换为一种数据源统一对待,在正确的时间将所需数据传递给任意的应用或者用户。JBoss 数据虚拟化可以帮助我们将数据快速组合和转换为可重用的商业友好的数据模型,通过开放标准接口简单可用。它提供全面的数据抽取、联合、集成、转换,以及传输功能,将来自一个或多个源的数据组合为可重复使用和共享的灵活数据。要了解更多关于 JBoss 数据虚拟化的信息,可以查看它的[官方文档](http://www.redhat.com/en/technologies/jboss-middleware/data-virtualization)。Docker 是一个提供开放平台用于打包,装载和以轻量级容器运行任何应用的开源平台。使用 Docker 容器我们可以轻松处理和启用支持 OData 的 JBoss 数据虚拟化。

下面是该指南中在 Docker 容器中运行支持 OData 的 JBoss 数据虚拟化的简单步骤。
### 1. 克隆仓库
首先,我们要用 git 命令从 <https://github.com/jbossdemocentral/dv-odata-docker-integration-demo> 克隆带数据虚拟化的 OData 仓库。假设我们的机器上运行着 Ubuntu 15.04 linux 发行版。我们要使用 apt-get 命令安装 git。
```
# apt-get install git
```
安装完 git 之后,我们运行下面的命令克隆仓库。
```
# git clone https://github.com/jbossdemocentral/dv-odata-docker-integration-demo
Cloning into 'dv-odata-docker-integration-demo'...
remote: Counting objects: 96, done.
remote: Total 96 (delta 0), reused 0 (delta 0), pack-reused 96
Unpacking objects: 100% (96/96), done.
Checking connectivity... done.
```
### 2. 下载 JBoss 数据虚拟化安装器
现在,我们需要从下载页 <http://www.jboss.org/products/datavirt/download/> 下载 JBoss 数据虚拟化安装器。下载了 **jboss-dv-installer-6.0.0.GA-redhat-4.jar** 后,我们把它保存在名为 **software** 的目录下。
### 3. 创建 Docker 镜像
下一步,下载了 JBoss 数据虚拟化安装器之后,我们打算使用 Dockerfile 和刚从仓库中克隆的资源创建 docker 镜像。
```
# cd dv-odata-docker-integration-demo/
# docker build -t jbossdv600 .
...
Step 22 : USER jboss
---> Running in 129f701febd0
---> 342941381e37
Removing intermediate container 129f701febd0
Step 23 : EXPOSE 8080 9990 31000
---> Running in 61e6d2c26081
---> 351159bb6280
Removing intermediate container 61e6d2c26081
Step 24 : CMD $JBOSS_HOME/bin/standalone.sh -c standalone.xml -b 0.0.0.0 -bmanagement 0.0.0.0
---> Running in a9fed69b3000
---> 407053dc470e
Removing intermediate container a9fed69b3000
Successfully built 407053dc470e
```
注意:在这里我们假设你已经安装了 docker 并正在运行。
### 4. 启动 Docker 容器
创建了支持 oData 的 JBoss 数据虚拟化 Docker 镜像之后,我们打算运行 docker 容器并用 -P 标签指定端口。我们运行下面的命令来实现。
```
# docker run -p 8080:8080 -d -t jbossdv600
7765dee9cd59c49ca26850e88f97c21f46859d2dc1d74166353d898773214c9c
```
### 5. 获取容器 IP
启动了 Docker 容器之后,我们想要获取正在运行的 docker 容器的 IP 地址。要做到这点,我们运行后面添加了正在运行容器 id 号的 docker inspect 命令。
```
# docker inspect <$containerID>
...
"NetworkSettings": {
"Bridge": "",
"EndpointID": "3e94c5900ac5954354a89591a8740ce2c653efde9232876bc94878e891564b39",
"Gateway": "172.17.42.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"HairpinMode": false,
"IPAddress": "172.17.0.8",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
```
### 6. Web 界面
现在,如果一切如期望的那样进行,当我们用浏览器打开 http://container-ip:8080/ 和 http://container-ip:9990 时会看到支持 oData 的 JBoss 数据虚拟化登录界面和 JBoss 管理界面。管理验证的用户名和密码分别是 admin 和 redhat1!数据虚拟化验证的用户名和密码都是 user。之后,我们可以通过 web 界面在内容间导航。
**注意**: 强烈建议在第一次登录后尽快修改密码。
### 总结
终于我们成功地运行了跑着支持 OData 多源虚拟数据库的 JBoss 数据虚拟化 的 Docker 容器。JBoss 数据虚拟化真的是一个很棒的平台,它为多种不同来源的数据进行虚拟化,并将它们转换为商业友好的数据模型,产生通过开放标准接口简单可用的数据。使用 Docker 技术可以简单、安全、快速地部署支持 OData 多源虚拟数据库的 JBoss 数据虚拟化。如果你有任何疑问、建议或者反馈,请在下面的评论框中写下来,以便我们可以改进和更新内容。非常感谢!Enjoy:-)
---
via: <http://linoxide.com/linux-how-to/run-jboss-data-virtualization-ga-odata-docker-container/>
作者:[Arun Pyasi](http://linoxide.com/author/arunp/) 译者:[ictlyh](http://www.mutouxiaogui.cn/blog) 校对:[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/run-jboss-data-virtualization-ga-odata-docker-container/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327581210>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,257 | RHCSA 系列(六): 使用 Parted 和 SSM 来配置和加密系统存储 | http://www.tecmint.com/rhcsa-exam-create-format-resize-delete-and-encrypt-partitions-in-linux/ | 2015-09-21T08:23:00 | [
"RHCSA",
"分区",
"SSM",
"LVM"
] | https://linux.cn/article-6257-1.html | 在本篇文章中,我们将讨论在 RHEL 7 中如何使用传统的工具来设置和配置本地系统存储,并介绍系统存储管理器(也称为 SSM),它将极大地简化上面的任务。

*RHCSA: 配置和加密系统存储 – Part 6*
请注意,我们将在这篇文章中展开这个话题,但由于该话题的宽泛性,我们将在下一期中继续介绍有关它的描述和使用。
### 在 RHEL 7 中创建和修改分区
在 RHEL 7 中, parted 是默认的用来处理分区的程序,且它允许你:
* 展示当前的分区表
* 操纵(扩大或缩小分区的大小)现有的分区
* 利用空余的磁盘空间或额外的物理存储设备来创建分区
强烈建议你在试图增加一个新的分区或对一个现有分区进行更改前,你应当确保该设备上没有任何一个分区正在使用(`umount /dev/分区`),且假如你正使用设备的一部分来作为 swap 分区,在进行上面的操作期间,你需要将它禁用(`swapoff -v /dev/分区`) 。
实施上面的操作的最简单的方法是使用一个安装介质例如一个 RHEL 7 的 DVD 或 USB 安装盘以急救模式启动 RHEL(`Troubleshooting` → `Rescue a Red Hat Enterprise Linux system`),然后当让你选择一个选项来挂载现有的 Linux 安装时,选择“跳过”这个选项,接着你将看到一个命令行提示符,在其中你可以像下图显示的那样开始键入与在一个未被使用的物理设备上创建一个正常的分区时所用的相同的命令。

*RHEL 7 急救模式*
要启动 parted,只需键入:
```
# parted /dev/sdb
```
其中 `/dev/sdb` 是你将要创建新分区所在的设备;然后键入 `print` 来显示当前设备的分区表:

*创建新的分区*
正如你所看到的那样,在这个例子中,我们正在使用一个 5 GB 的虚拟驱动器。现在我们将要创建一个 4 GB 的主分区,然后将它格式化为 xfs 文件系统,它是 RHEL 7 中默认的文件系统。
你可以从一系列的文件系统中进行选择。你将需要使用 `mkpart` 来手动地创建分区,接着和平常一样,用 `mkfs.类型` 来对分区进行格式化,因为 `mkpart` 并不支持许多现代的文件系统的到即开即用。
在下面的例子中,我们将为设备设定一个标记,然后在 `/dev/sdb` 上创建一个主分区 `(p)`,它从设备的 0% 开始,并在 4000MB(4 GB) 处结束。

*标记分区的名称*
接下来,我们将把分区格式化为 xfs 文件系统,然后再次打印出分区表,以此来确保更改已被应用。
```
# mkfs.xfs /dev/sdb1
# parted /dev/sdb print
```

*格式化分区为 XFS 文件系统*
对于旧一点的文件系统,在 parted 中你可以使用 `resize` 命令来改变分区的大小。不幸的是,这只适用于 ext2, fat16, fat32, hfs, linux-swap, 和 reiserfs (若 libreiserfs 已被安装)。
因此,改变分区大小的唯一方式是删除它然后再创建它(所以,确保你对你的数据做了完整的备份!)。毫无疑问,在 RHEL 7 中默认的分区方案是基于 LVM 的。
使用 parted 来移除一个分区,可以用:
```
# parted /dev/sdb print
# parted /dev/sdb rm 1
```

*移除或删除分区*
### 逻辑卷管理(LVM)
一旦一个磁盘被分好了分区,再去更改分区的大小就是一件困难或冒险的事了。基于这个原因,假如我们计划在我们的系统上对分区的大小进行更改,我们应当考虑使用 LVM 的可能性,而不是使用传统的分区系统。这样多个物理设备可以组成一个逻辑组,以此来存放任意数目的逻辑卷,而逻辑卷的增大或减少不会带来任何麻烦。
简单来说,你会发现下面的示意图对记住 LVM 的基础架构或许有用。

*LVM 的基本架构*
#### 创建物理卷,卷组和逻辑卷
遵循下面的步骤是为了使用传统的卷管理工具来设置 LVM。由于你可以通过阅读这个网站上的 LVM 系列来扩展这个话题,我将只是概要的介绍设置 LVM 的基本步骤,然后与使用 SSM 来实现相同功能做个比较。
**注**: 我们将使用整个磁盘 `/dev/sdb` 和 `/dev/sdc` 来作为物理卷(PV),但是否执行相同的操作完全取决于你。
**1. 使用 /dev/sdb 和 /dev/sdc 中 100% 的可用磁盘空间来创建分区 `/dev/sdb1` 和 `/dev/sdc1`:**
```
# parted /dev/sdb print
# parted /dev/sdc print
```

*创建新分区*
**2. 分别在 /dev/sdb1 和 /dev/sdc1 上共创建 2 个物理卷。**
```
# pvcreate /dev/sdb1
# pvcreate /dev/sdc1
```

*创建两个物理卷*
记住,你可以使用 pvdisplay /dev/sd{b,c}1 来显示有关新建的物理卷的信息。
**3. 在上一步中创建的物理卷之上创建一个卷组(VG):**
```
# vgcreate tecmint_vg /dev/sd{b,c}1
```

*创建卷组*
记住,你可使用 vgdisplay tecmint\_vg 来显示有关新建的卷组的信息。
**4. 像下面那样,在卷组 tecmint\_vg 之上创建 3 个逻辑卷(LV):**
```
# lvcreate -L 3G -n vol01_docs tecmint_vg [vol01_docs → 3 GB]
# lvcreate -L 1G -n vol02_logs tecmint_vg [vol02_logs → 1 GB]
# lvcreate -l 100%FREE -n vol03_homes tecmint_vg [vol03_homes → 6 GB]
```

*创建逻辑卷*
记住,你可以使用 lvdisplay tecmint*vg 来显示有关在 tecmint*vg 之上新建的逻辑卷的信息。
**5. 格式化每个逻辑卷为 xfs 文件系统格式(假如你计划在以后将要缩小卷的大小,请别使用 xfs 文件系统格式!):**
```
# mkfs.xfs /dev/tecmint_vg/vol01_docs
# mkfs.xfs /dev/tecmint_vg/vol02_logs
# mkfs.xfs /dev/tecmint_vg/vol03_homes
```
**6. 最后,挂载它们:**
```
# mount /dev/tecmint_vg/vol01_docs /mnt/docs
# mount /dev/tecmint_vg/vol02_logs /mnt/logs
# mount /dev/tecmint_vg/vol03_homes /mnt/homes
```
#### 移除逻辑卷,卷组和物理卷
**7.现在我们将进行与刚才相反的操作并移除逻辑卷、卷组和物理卷:**
```
# lvremove /dev/tecmint_vg/vol01_docs
# lvremove /dev/tecmint_vg/vol02_logs
# lvremove /dev/tecmint_vg/vol03_homes
# vgremove /dev/tecmint_vg
# pvremove /dev/sd{b,c}1
```
**8. 现在,让我们来安装 SSM,我们将看到如何只用一步就完成上面所有的操作!**
```
# yum update && yum install system-storage-manager
```
我们将和上面一样,使用相同的名称和大小:
```
# ssm create -s 3G -n vol01_docs -p tecmint_vg --fstype ext4 /mnt/docs /dev/sd{b,c}1
# ssm create -s 1G -n vol02_logs -p tecmint_vg --fstype ext4 /mnt/logs /dev/sd{b,c}1
# ssm create -n vol03_homes -p tecmint_vg --fstype ext4 /mnt/homes /dev/sd{b,c}1
```
是的! SSM 可以让你:
* 初始化块设备来作为物理卷
* 创建一个卷组
* 创建逻辑卷
* 格式化逻辑卷,以及
* 只使用一个命令来挂载它们
**9. 现在,我们可以使用下面的命令来展示有关物理卷、卷组或逻辑卷的信息:**
```
# ssm list dev
# ssm list pool
# ssm list vol
```

*检查有关物理卷、卷组或逻辑卷的信息*
**10. 正如我们知道的那样, LVM 的一个显著的特点是可以在不停机的情况下更改(增大或缩小)逻辑卷的大小:**
假定在 vol02*logs 上我们用尽了空间,而 vol03*homes 还留有足够的空间。我们将把 vol03*homes 的大小调整为 4 GB,并使用剩余的空间来扩展 vol02*logs:
```
# ssm resize -s 4G /dev/tecmint_vg/vol03_homes
```
再次运行 `ssm list pool`,并记录 tecmint\_vg 中的剩余空间的大小:

*查看卷的大小*
然后执行:
```
# ssm resize -s+1.99 /dev/tecmint_vg/vol02_logs
```
**注**: 在 `-s` 后的加号暗示特定值应该被加到当前值上。
**11. 使用 ssm 来移除逻辑卷和卷组也更加简单,只需使用:**
```
# ssm remove tecmint_vg
```
这个命令将返回一个提示,询问你是否确认删除卷组和它所包含的逻辑卷:

*移除逻辑卷和卷组*
### 管理加密的卷
SSM 也给系统管理员提供了为新的或现存的卷加密的能力。首先,你将需要安装 cryptsetup 软件包:
```
# yum update && yum install cryptsetup
```
然后写出下面的命令来创建一个加密卷,你将被要求输入一个密码来增强安全性:
```
# ssm create -s 3G -n vol01_docs -p tecmint_vg --fstype ext4 --encrypt luks /mnt/docs /dev/sd{b,c}1
# ssm create -s 1G -n vol02_logs -p tecmint_vg --fstype ext4 --encrypt luks /mnt/logs /dev/sd{b,c}1
# ssm create -n vol03_homes -p tecmint_vg --fstype ext4 --encrypt luks /mnt/homes /dev/sd{b,c}1
```
我们的下一个任务是往 /etc/fstab 中添加条目来让这些逻辑卷在启动时可用,而不是使用设备识别编号(/dev/something)。
我们将使用每个逻辑卷的 UUID (使得当我们添加其他的逻辑卷或设备后,我们的设备仍然可以被唯一的标记),而我们可以使用 blkid 应用来找到它们的 UUID:
```
# blkid -o value UUID /dev/tecmint_vg/vol01_docs
# blkid -o value UUID /dev/tecmint_vg/vol02_logs
# blkid -o value UUID /dev/tecmint_vg/vol03_homes
```
在我们的例子中:

*找到逻辑卷的 UUID*
接着,使用下面的内容来创建 /etc/crypttab 文件(请更改 UUID 来适用于你的设置):
```
docs UUID=ba77d113-f849-4ddf-8048-13860399fca8 none
logs UUID=58f89c5a-f694-4443-83d6-2e83878e30e4 none
homes UUID=92245af6-3f38-4e07-8dd8-787f4690d7ac none
```
然后在 /etc/fstab 中添加如下的条目。请注意到 device*name (/dev/mapper/device*name) 是出现在 /etc/crypttab 中第一列的映射标识:
```
# Logical volume vol01_docs:
/dev/mapper/docs /mnt/docs ext4 defaults 0 2
# Logical volume vol02_logs
/dev/mapper/logs /mnt/logs ext4 defaults 0 2
# Logical volume vol03_homes
/dev/mapper/homes /mnt/homes ext4 defaults 0 2
```
现在重启(`systemctl reboot`),则你将被要求为每个逻辑卷输入密码。随后,你可以通过检查相应的挂载点来确保挂载操作是否成功:

*确保逻辑卷挂载点*
### 总结
在这篇教程中,我们开始探索如何使用传统的卷管理工具和 SSM 来设置和配置系统存储,SSM 也在一个软件包中集成了文件系统和加密功能。这使得对于任何系统管理员来说,SSM 是一个非常有价值的工具。
假如你有任何的问题或评论,请让我们知晓 – 请随意使用下面的评论框来与我们保存联系!
---
via: <http://www.tecmint.com/rhcsa-exam-create-format-resize-delete-and-encrypt-partitions-in-linux/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[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,258 | 五大超酷的开源游戏 | http://fossforce.com/2015/08/five-super-cool-open-source-games/ | 2015-09-21T08:38:00 | [
"游戏"
] | https://linux.cn/article-6258-1.html | 在2014年和2015年,Linux 涌入了一堆流行的付费游戏,例如备受欢迎的无主之地(Borderlands)、巫师(Witcher)、死亡岛(Dead Island) 和 CS 系列游戏。虽然这是令人激动的消息,但玩家有这个支出预算吗?付费游戏很好,但更好的是由了解玩家喜好的开发者开发的免费的替代品。
前段时间,我偶然看到了一个三年前发布的 YouTube 视频,标题非常的有正能量 [5个不算糟糕的开源游戏](https://www.youtube.com/watch?v=BEKVl-XtOP8)。虽然视频表扬了一些开源游戏,我还是更喜欢用一个更加热情的方式来切入这个话题,至少如标题所说。所以,下面是我的一份五大超酷开源游戏的清单。
### Tux Racer

*Tux Racer*
[《Tux Racer》](http://tuxracer.sourceforge.net/download.html)是这份清单上的第一个游戏,因为我对这个游戏很熟悉。最近,我的兄弟和我为了参加[玩电脑的孩子们](http://www.kidsoncomputers.org/an-amazing-week-in-oaxaca)项目,在[去墨西哥的路途中](http://fossforce.com/2015/07/banks-family-values-texas-linux-fest/),Tux Racer 是孩子和教师都喜欢玩的游戏之一。在这个游戏中,玩家使用 Linux 吉祥物——企鹅 Tux——在下山雪道上以计时赛的方式进行比赛。玩家们不断挑战他们自己的最佳纪录。目前还没有多玩家版本,但这是有可能改变的。它适用于 Linux、OS X、Windows 和 Android。
### Warsow

*Warsow*
[《Warsow》](https://www.warsow.net/download)网站介绍道:“设定是有未来感的卡通世界,Warsow 是个完全开放的适用于 Windows、Linux 和 Mac OS X平台的快节奏第一人称射击游戏(FPS)。Warsow 是跨网络的尊重和体育精神的的艺术。(Warsow is the Art of Respect and Sportsmanship Over the Web. 大写回文字母组成 Warsow。)” 我很不情愿的把 FPS 类放到了这个列表中,因为很多人玩过这类的游戏,但是我的确被 Warsow 打动了。它对很多动作进行了优先级排序,游戏节奏很快,一开始就有八个武器。卡通化的风格让玩的过程变得没有那么严肃,更加的休闲,非常适合和亲友一同玩。然而,它却以充满竞争的游戏自居,并且当我体验这个游戏时,我发现周围确实有一些专家级的玩家。它适用于 Linux、Windows 和 OS X。
### M.A.R.S——一个荒诞的射击游戏

*M.A.R.S.——一个荒诞的射击游戏*
[《M.A.R.S——一个荒诞的射击游戏》](http://mars-game.sourceforge.net/)之所以吸引人是因为它充满活力的色彩和画风。支持两个玩家使用同一个键盘,而一个在线多玩家版本目前正在开发中——这意味着想要和朋友们一起玩暂时还要等等。不论如何,它是个可以使用几个不同飞船和武器的有趣的太空射击游戏。飞船的形状不同,从普通的枪、激光、散射枪到更有趣的武器(随机出来的飞船中有一个会对敌人发射泡泡,这为这款混乱的游戏增添了很多乐趣)。游戏有几种模式,比如标准模式和对方进行殊死搏斗以获得高分或先达到某个分数线,还有其他的模式,空间球(Spaceball)、坟坑(Grave-itation Pit)和保加农炮(Cannon Keep)。它适用于 Linux、Windows 和 OS X。
### Valyria Tear

*Valyria Tear*
[Valyria Tear](http://valyriatear.blogspot.com/) 类似近年来拥有众多粉丝的角色扮演游戏(RPG)。故事设定在奇幻游戏的通用年代,充满了骑士、王国和魔法,以及主要角色 Bronann。设计团队在这个世界的设计上做的非常棒,实现了玩家对这类游戏所有的期望:隐藏的宝藏、偶遇的怪物、非玩家操纵角色(NPC)的互动以及所有 RPG 不可或缺的——在低级别的怪物上刷经验直到可以面对大 BOSS。我在试玩的时候,时间不允许我太过深入到这个游戏故事中,但是感兴趣的人可以看 YouTube 上由 Yohann Ferriera 用户发的‘[Let’s Play](https://www.youtube.com/channel/UCQ5KrSk9EqcT_JixWY2RyMA)’系列视频。它适用于 Linux、Windows 和 OS X。
### SuperTuxKart

*SuperTuxKart*
最后一个同样好玩的游戏是 [SuperTuxKart](http://supertuxkart.sourceforge.net/),一个效仿 Mario Kart(马里奥卡丁车)但丝毫不逊色的好游戏。它在2000年-2004年间开始以 Tux Kart 开发,但是在成品中有错误,结果开发就停止了几年。从2006年开始重新开发时起,它就一直在改进,直到四个月前0.9版首次发布。在游戏里,我们的老朋友 Tux 与马里奥和其他一些开源吉祥物一同开始。其中一个熟悉的面孔是 Suzanne,这是 Blender 的那只吉祥物猴子。画面很给力,游戏很流畅。虽然在线游戏还在计划阶段,但是分屏多玩家游戏是可以的。一个电脑最多可以供四个玩家同时玩。它适用于 Linux、Windows、OS X、AmigaOS 4、AROS 和 MorphOS。
---
via: <http://fossforce.com/2015/08/five-super-cool-open-source-games/>
作者:Hunter Banks 译者:[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,259 | Linux 系统是否适合于您? | http://www.datamation.com/open-source/is-linux-right-for-you.html | 2015-09-21T10:00:00 | [
"Linux",
"系统"
] | https://linux.cn/article-6259-1.html |
>
> 并非人人都适合使用 Linux --对许多用户来说,Windows 或 OSX 会是更好的选择。
>
>
>
我喜欢使用 Linux 桌面系统,并不是因为软件的政治性质,也不是不喜欢其它操作系统。我喜欢 Linux 系统因为它能满足我的需求并且确实适合使用。
我的经验是,并非人人都适合切换至“Linux 的生活方式”。本文将帮助您通过分析使用 Linux 系统的利弊来供您自行判断使用 Linux 是否真正适合您。

### 什么时候更换系统?
当有充分的理由时,将系统切换到 Linux 系统是很有意义的。这对 Windows 用户将系统更换到 OSX 或类似的情况都同样适用。为让您的系统转变成功,您必须首先确定为什么要做这种转换。
对某些人来说,更换系统通常意味着他们不满于当前的系统操作平台。也许是最新的升级给了他们糟糕的用户体验,而他们也已准备好更换到别的系统,也许仅仅是因为对某个系统好奇。不管动机是什么,必须要有充分的理由支撑您做出更换操作系统的决定。如果没有一个充足的原因让您这样做,往往不会成功。
然而事事都有例外。如果您确实对 Linux 桌面非常感兴趣,或许可以选择一种折衷的方式。
### 放慢起步的脚步
第一次尝试运行 Linux 系统后,我看到就有人开始批判 Windows 安装过程的费时,完全是因为他们20分钟就用闪存安装好 Ubuntu 的良好体验。但是伙伴们,这并不只是一次测验。相反,我有如下建议:
* 用一周的时间尝试在[虚拟机上运行 Linux 系统](http://www.psychocats.net/ubuntu/virtualbox)。这意味着您将在该系统上执行所有的浏览器工作、邮箱操作和其它想要完成的任务。
* 如果运行虚拟机资源消耗太大,您可以尝试用提供了[一些持久存储](http://www.howtogeek.com/howto/14912/create-a-persistent-bootable-ubuntu-usb-flash-drive/)的 USB 驱动器来运行 Linux,您的主操作系统将不受任何影响。与此同时,您仍可以运行 Linux 系统。
* 运行 Linux 系统一周后,如果一切进展顺利,下一步您可以计算一下这周内登入 Windows 的次数。如果只是偶尔登录 Windows 系统,下一步就可以尝试运行 Windows 和 Linux 的[双系统](http://www.linuxandubuntu.com/home/dual-boot-ubuntu-15-04-14-10-and-windows-10-8-1-8-step-by-step-tutorial-with-screenshots)。对那些只运行了 Linux 系统的用户,可以考虑尝试将系统真正更换为 Linux 系统。
* 在你完全删除 Windows 分区前,更应该购买一个新硬盘来安装 Linux 系统。这样有了充足的硬盘空间,您就可以使用双系统。如果必须要启动 Windows 系统做些事情的话,Windows 系统也是可以运行的。
### 使用 Linux 系统的好处是什么?
将系统更换到 Linux 有什么好处呢?一般而言,这种好处对大多数人来说可以归结到释放个性自由。在使用 Linux 系统的时候,如果您不喜欢某些设置,可以自行更改它们。同时使用 Linux 可以为用户节省大量的硬件升级开支和不必要的软件开支。另外,您不需再费力找寻已丢失的软件许可证密钥,而且如果您不喜欢即将发布的系统版本,大可轻松地更换到别的版本。
在 Linux 桌面方面可以选择的桌面种类是惊人的多,看起来对新手来说做这种选择非常困难。但是如果您发现了喜欢的一款 Linux 版本(Debian、Fedora、Arch等),最困难的工作其实已经完成了,您需要做的就是找到各版本的区别并选择出您最喜欢的系统版本环境。
如今我听到的最常见的抱怨之一是用户发现没有太多的软件能适用于 Linux 系统。然而,这并不是事实。尽管别的操作系统可能会提供更多软件,但是如今的 Linux 也已经提供了足够多应用程序满足您的各种需求,包括视频剪辑(家用和专业级)、摄影、办公管理软件、远程访问、音乐软件、等等等等。
### 使用 Linux 系统您会失去些什么?
虽然我喜欢使用 Linux,但我妻子的家庭办公依然依赖于 OS X。对于用 Linux 系统完成一些特定的任务她心满意足,但是她需要 OS X 来运行一些不支持 Linux 的软件。这是许多想要更换系统的用户会遇到的一个常见的问题。如果要更换系统,您需要考虑是否愿意失去一些关键的软件工具。
有时这个问题是因为软件的数据只能用该软件打开。别的情况下,是传统应用程序的工作流和功能并不适用于在 Linux 系统上可运行的软件。我自己并没有遇到过这类问题,但是我知道确实存在这些问题。许多 Linux 上的软件在其它操作系统上也都可以用。所以如果担心这类软件兼容问题,建议您先尝试在已有的系统上操作一下几款类似的应用程序。
更换成 Linux 系统后,另一件您可能会失去的是本地系统支持服务。人们通常会嘲笑这种愚蠢行径,但我知道,无数的新手在使用 Linux 时会发现解决 Linux 上各种问题的唯一资源就是来自网络另一端的陌生人提供的帮助。如果只是他们的 PC 遇到了一些问题,这将会比较麻烦。Windows 和 OS X 的用户已经习惯各城市遍布了支持他们操作系统的各项技术服务。
### 如何开启新旅程?
这里建议大家要记住最重要的就是总要有个回退方案。如果您将 Windows 10 从硬盘中擦除,您会发现重新安装它又会花费金钱。对那些从其它 Windows 发布版本升级的用户来说尤其会遇到这种情况。请接受这个建议,对新手来说使用闪存安装 Linux 或使用 Windows 和 Linux 双系统都是更值得提倡的做法。您也许会如鱼得水般使用 Linux系统,但是有了一份回退方案,您将高枕无忧。
相反,如果数周以来您一直依赖于使用双操作系统,但是已经准备好冒险去尝试一下单操作系统,那么就去做吧。格式化您的驱动器,重新安装您喜爱的 Linux 发行版。数年来我一直都是“全职” Linux 使用爱好者,这里可以确定地告诉您,使用 Linux 系统感觉棒极了。这种感觉会持续多久?我第一次的 Linux 系统使用经验还是来自早期的 Red Hat 系统,最终在2003年,我在自己的笔记本上整个安装了 Linux 系统。
Linux 爱好者们,你们什么时候开始使用 Linux 的?您在最初更换成 Linux 系统时是兴奋还是焦虑呢?欢迎点击评论分享你们的经验。
---
via: <http://www.datamation.com/open-source/is-linux-right-for-you.html>
作者:[Matt Hartley](http://www.datamation.com/author/Matt-Hartley-3080.html) 译者:[icybreaker](https://github.com/icybreaker) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,262 | mosh:一个基于 SSH 用于连接远程 Unix/Linux 系统的工具 | http://www.tecmint.com/install-mosh-shell-ssh-client-in-linux/ | 2015-09-22T07:16:00 | [
"Mosh",
"ssh"
] | https://linux.cn/article-6262-1.html | Mosh 表示<ruby> 移动 Shell <rp> ( </rp> <rt> Mobile Shell </rt> <rp> ) </rp></ruby>,是一个用于从客户端跨互联网连接远程服务器的命令行工具。它能用于 SSH 连接,但是比 Secure Shell 功能更多。它是一个类似于 SSH 而带有更多功能的应用。程序最初由 Keith Winstein 编写,用于类 Unix 的操作系统中,发布于GNU GPL v3协议下。

*Mosh Shell SSH 客户端*
#### Mosh的功能
* 它是一个支持漫游的远程终端程序。
* 在所有主流的类 Unix 版本中可用,如 Linux、FreeBSD、Solaris、Mac OS X 和 Android。
* 支持不稳定连接
* 支持智能的本地回显
* 支持用户输入的行编辑
* 响应式设计及在 wifi、3G、长距离连接下的鲁棒性
* 在 IP 改变后保持连接。它使用 UDP 代替 TCP(在 SSH 中使用),当连接被重置或者获得新的 IP 后 TCP 会超时,但是 UDP 仍然保持连接。
* 在很长的时候之后恢复会话时仍然保持连接。
* 没有网络延迟。立即显示用户输入和删除而没有延迟
* 像 SSH 那样支持一些旧的方式登录。
* 包丢失处理机制
### Linux 中 mosh 的安装
在 Debian、Ubuntu 和 Mint 类似的系统中,你可以很容易地用 [apt-get 包管理器](http://www.tecmint.com/useful-basic-commands-of-apt-get-and-apt-cache-for-package-management/)安装。
```
# apt-get update
# apt-get install mosh
```
在基于 RHEL/CentOS/Fedora 的系统中,要使用 [yum 包管理器](http://www.tecmint.com/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement/)安装 mosh,你需要打开第三方的 [EPEL](/article-2324-1.html)。
```
# yum update
# yum install mosh
```
在 Fedora 22+的版本中,你需要使用 [dnf 包管理器](http://www.tecmint.com/dnf-commands-for-fedora-rpm-package-management/)来安装 mosh。
```
# dnf install mosh
```
### 我该如何使用 mosh?
1、 让我们尝试使用 mosh 登录远程 Linux 服务器。
```
$ mosh root@192.168.0.150
```

*mosh远程连接*
**注意**:你有没有看到一个连接错误,因为我在 CentOS 7中还有打开这个端口。一个快速但是我并不建议的解决方法是:
```
# systemctl stop firewalld [在远程服务器上]
```
更好的方法是打开一个端口并更新防火墙规则。接着用 mosh 连接到预定义的端口中。至于更深入的细节,也许你会对下面的文章感兴趣。
* [如何配置 Firewalld](http://www.tecmint.com/configure-firewalld-in-centos-7/)
2、 让我们假设把默认的 22 端口改到 70,这时使用 -p 选项来使用自定义端口。
```
$ mosh -p 70 root@192.168.0.150
```
3、 检查 mosh 的版本
```
$ mosh --version
```

*检查mosh版本*
4、 你可以输入`exit`来退出 mosh 会话。
```
$ exit
```
5、 mosh 支持很多选项,你可以用下面的方法看到:
```
$ mosh --help
```

*Mosh 选项*
#### mosh 的优缺点
* mosh 有额外的需求,比如需要允许 UDP 直接连接,这在 SSH 不需要。
* 动态分配的端口范围是 60000-61000。第一个打开的端口是分配好的。每个连接都需要一个端口。
* 默认的端口分配是一个严重的安全问题,尤其是在生产环境中。
* 支持 IPv6 连接,但是不支持 IPv6 漫游。
* 不支持回滚
* 不支持 X11 转发
* 不支持 ssh-agent 转发
### 总结
mosh是一款在大多数linux发行版的仓库中可以下载的一款小工具。虽然它有一些差异尤其是安全问题和额外的需求,它的功能,比如漫游后保持连接是一个加分点。我的建议是任何一个使用ssh的linux用户都应该试试这个程序,mosh值得一试。
---
via: <http://www.tecmint.com/install-mosh-shell-ssh-client-in-linux/>
作者:[Avishek Kumar](http://www.tecmint.com/author/avishek/) 译者:[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,263 | RHCSA 系列(七): 使用 ACL(访问控制列表) 和挂载 Samba/NFS 共享 | http://www.tecmint.com/rhcsa-exam-configure-acls-and-mount-nfs-samba-shares/ | 2015-09-22T09:07:00 | [
"RHCSA",
"ACL"
] | https://linux.cn/article-6263-1.html | 在上一篇文章([RHCSA 系列(六)](/article-6257-1.html))中,我们解释了如何使用 parted 和 ssm 来设置和配置本地系统存储。

*RHCSA 系列: 配置 ACL 及挂载 NFS/Samba 共享 – Part 7*
我们也讨论了如何创建和在系统启动时使用一个密码来挂载加密的卷。另外,我们告诫过你要避免在挂载的文件系统上执行危险的存储管理操作。记住了这点后,现在,我们将回顾在 RHEL 7 中最常使用的文件系统格式,然后将涵盖有关手动或自动挂载、使用和卸载网络文件系统(CIFS 和 NFS)的话题以及在你的操作系统上实现<ruby> 访问控制列表 <rp> ( </rp> <rt> Access Control List </rt> <rp> ) </rp></ruby>的使用。
#### 前提条件
在进一步深入之前,请确保你可使用 Samba 服务和 NFS 服务(注意在 RHEL 7 中 NFSv2 已不再被支持)。
在本次指导中,我们将使用一个IP 地址为 192.168.0.10 且同时运行着 Samba 服务和 NFS 服务的机器来作为服务器,使用一个 IP 地址为 192.168.0.18 的 RHEL 7 机器来作为客户端。在这篇文章的后面部分,我们将告诉你在客户端上你需要安装哪些软件包。
### RHEL 7 中的文件系统格式
从 RHEL 7 开始,由于 XFS 的高性能和可扩展性,它已经被作为所有的架构中的默认文件系统。根据 Red Hat 及其合作伙伴在主流硬件上执行的最新测试,当前 XFS 已支持最大为 500 TB 大小的文件系统。
另外,XFS 启用了 `user_xattr`(扩展用户属性) 和 `acl`(POSIX 访问控制列表)来作为默认的挂载选项,而不像 ext3 或 ext4(对于 RHEL 7 来说,ext2 已过时),这意味着当挂载一个 XFS 文件系统时,你不必显式地在命令行或 /etc/fstab 中指定这些选项(假如你想在后一种情况下禁用这些选项,你必须显式地使用 `no_acl` 和 `no_user_xattr`)。
请记住扩展用户属性可以给文件和目录指定,用来存储任意的额外信息如 mime 类型,字符集或文件的编码,而用户属性中的访问权限由一般的文件权限位来定义。
#### 访问控制列表
作为一名系统管理员,无论你是新手还是专家,你一定非常熟悉与文件和目录有关的常规访问权限,这些权限为所有者,所有组和“世界”(所有的其他人)指定了特定的权限(可读,可写及可执行)。但如若你需要稍微更新下你的记忆,请参考 [RHCSA 系列(三)](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Storage_Administration_Guide/ch-acls.html).
但是,由于标准的 `ugo/rwx` 集合并不允许为不同的用户配置不同的权限,所以 ACL 便被引入了进来,为的是为文件和目录定义更加详细的访问权限,而不仅仅是这些特别指定的特定权限。
事实上, ACL 定义的权限是由文件权限位所特别指定的权限的一个超集。下面就让我们看看这个转换是如何在真实世界中被应用的吧。
1. 存在两种类型的 ACL:访问 ACL,可被应用到一个特定的文件或目录上;以及默认 ACL,只可被应用到一个目录上。假如目录中的文件没有 ACL,则它们将继承它们的父目录的默认 ACL 。
2. 从一开始, ACL 就可以为每个用户,每个组或不在文件所属组中的用户配置相应的权限。
3. ACL 可使用 `setfacl` 来设置(和移除),可相应地使用 -m 或 -x 选项。
例如,让我们创建一个名为 tecmint 的组,并将用户 johndoe 和 davenull 加入该组:
```
# groupadd tecmint
# useradd johndoe
# useradd davenull
# usermod -a -G tecmint johndoe
# usermod -a -G tecmint davenull
```
并且让我们检验这两个用户都已属于追加的组 tecmint:
```
# id johndoe
# id davenull
```

*检验用户*
现在,我们在 /mnt 下创建一个名为 playground 的目录,并在该目录下创建一个名为 testfile.txt 的文件。我们将设定该文件的属组为 tecmint,并更改它的默认 `ugo/rwx` 权限为 770(即赋予该文件的属主和属组可读、可写和可执行权限):
```
# mkdir /mnt/playground
# touch /mnt/playground/testfile.txt
# chown :tecmint /mnt/playground/testfile.txt
# chmod 770 /mnt/playground/testfile.txt
```
接着,依次切换为 johndoe 和 davenull 用户,并在文件中写入一些信息:
```
# su johndoe
$ echo "My name is John Doe" > /mnt/playground/testfile.txt
$ su davenull
$ echo "My name is Dave Null" >> /mnt/playground/testfile.txt
```
到目前为止,一切正常。现在我们让用户 gacanepa 来向该文件执行写操作 – 则写操作将会失败,这是可以预料的。
```
$ su gacanepa
$ echo "My name is Gabriel Canepa" >> /mnt/playground/testfile.txt
```

*管理用户的权限*
但实际上我们需要用户 gacanepa(他不是组 tecmint 的成员)在文件 /mnt/playground/testfile.txt 上有写权限,那又该怎么办呢?首先映入你脑海里的可能是将该用户添加到组 tecmint 中。但那将使得他在所有该组具有写权限位的文件上均拥有写权限,但我们并不想这样,我们只想他能够在文件 /mnt/playground/testfile.txt 上有写权限。
现在,让我们给用户 gacanepa 在 /mnt/playground/testfile.txt 文件上有读和写权限。
以 root 的身份运行如下命令:
```
# setfacl -R -m u:gacanepa:rwx /mnt/playground
```
则你将成功地添加一条 ACL,允许 gacanepa 对那个测试文件可写。然后切换为 gacanepa 用户,并再次尝试向该文件写入一些信息:
```
$ echo "My name is Gabriel Canepa" >> /mnt/playground/testfile.txt
```
要观察一个特定的文件或目录的 ACL,可以使用 `getfacl` 命令:
```
# getfacl /mnt/playground/testfile.txt
```

*检查文件的 ACL*
要为目录设定默认 ACL(它的内容将被该目录下的文件继承,除非另外被覆写),在规则前添加 `d:`并特别指定一个目录名,而不是文件名:
```
# setfacl -m d:o:r /mnt/playground
```
上面的 ACL 将允许不在属组中的用户对目录 /mnt/playground 中的内容有读权限。请注意观察这次更改前后 `getfacl /mnt/playground` 的输出结果的不同:

*在 Linux 中设定默认 ACL*
[在官方的 RHEL 7 存储管理指导手册的第 20 章](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Storage_Administration_Guide/ch-acls.html) 中提供了更多有关 ACL 的例子,我极力推荐你看一看它并将它放在身边作为参考。
#### 挂载 NFS 网络共享
要显示你服务器上可用的 NFS 共享的列表,你可以使用带有 -e 选项的 `showmount` 命令,再跟上机器的名称或它的 IP 地址。这个工具包含在 `nfs-utils` 软件包中:
```
# yum update && yum install nfs-utils
```
接着运行:
```
# showmount -e 192.168.0.10
```
则你将得到一个在 192.168.0.10 上可用的 NFS 共享的列表:

*检查可用的 NFS 共享*
要按照需求在本地客户端上使用命令行来挂载 NFS 网络共享,可使用下面的语法:
```
# mount -t nfs -o [options] remote_host:/remote/directory /local/directory
```
其中,在我们的例子中,对应为:
```
# mount -t nfs 192.168.0.10:/NFS-SHARE /mnt/nfs
```
若你得到如下的错误信息:`Job for rpc-statd.service failed. See "systemctl status rpc-statd.service" and "journalctl -xn" for details.`,请确保 `rpcbind` 服务被启用且已在你的系统中启动了。
```
# systemctl enable rpcbind.socket
# systemctl restart rpcbind.service
```
接着重启。这就应该达到了上面的目的,且你将能够像先前解释的那样挂载你的 NFS 共享了。若你需要在系统启动时自动挂载 NFS 共享,可以向 /etc/fstab 文件添加一个有效的条目:
```
remote_host:/remote/directory /local/directory nfs options 0 0
```
上面的变量 remote\_host, /remote/directory, /local/directory 和 options(可选) 和在命令行中手动挂载一个 NFS 共享时使用的一样。按照我们前面的例子,对应为:
```
192.168.0.10:/NFS-SHARE /mnt/nfs nfs defaults 0 0
```
#### 挂载 CIFS (Samba) 网络共享
Samba 代表一个特别的工具,使得在由 \*nix 和 Windows 机器组成的网络中进行网络共享成为可能。要显示可用的 Samba 共享,可使用带有 -L 选项的 smbclient 命令,再跟上机器的名称或它的 IP 地址。这个工具包含在 samba\_client 软件包中:
你将被提示在远程主机上输入 root 用户的密码:
```
# smbclient -L 192.168.0.10
```

*检查 Samba 共享*
要在本地客户端上挂载 Samba 网络共享,你需要已安装好 cifs-utils 软件包:
```
# yum update && yum install cifs-utils
```
然后在命令行中使用下面的语法:
```
# mount -t cifs -o credentials=/path/to/credentials/file //remote_host/samba_share /local/directory
```
其中,在我们的例子中,对应为:
```
# mount -t cifs -o credentials=~/.smbcredentials //192.168.0.10/gacanepa /mnt/samba
```
其中 `.smbcredentials` 的内容是:
```
username=gacanepa
password=XXXXXX
```
它是一个位于 root 用户的家目录(/root/) 中的隐藏文件,其权限被设置为 600,所以除了该文件的属主外,其他人对该文件既不可读也不可写。
请注意 samba\_share 是 Samba 共享的名称,由上面展示的 `smbclient -L remote_host` 所返回。
现在,若你需要在系统启动时自动地使得 Samba 分享可用,可以向 /etc/fstab 文件添加一个像下面这样的有效条目:
```
//remote_host:/samba_share /local/directory cifs options 0 0
```
上面的变量 remote\_host, /remote/directory, /local/directory 和 options(可选) 和在命令行中手动挂载一个 Samba 共享时使用的一样。按照我们前面的例子中所给的定义,对应为:
```
//192.168.0.10/gacanepa /mnt/samba cifs credentials=/root/smbcredentials,defaults 0 0
```
### 结论
在这篇文章中,我们已经解释了如何在 Linux 中设置 ACL,并讨论了如何在一个 RHEL 7 客户端上挂载 CIFS 和 NFS 网络共享。
我建议你去练习这些概念,甚至混合使用它们(试着在一个挂载的网络共享上设置 ACL),直至你感觉掌握了。假如你有问题或评论,请随时随意地使用下面的评论框来联系我们。另外,请随意通过你的社交网络分享这篇文章。
---
via: <http://www.tecmint.com/rhcsa-exam-configure-acls-and-mount-nfs-samba-shares/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[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,265 | 在 Ubuntu 里如何下载、安装和配置 Plank Dock | https://www.maketecheasier.com/download-install-configure-plank-dock-ubuntu/ | 2015-09-22T10:33:00 | [
"Dock",
"Plank"
] | https://linux.cn/article-6265-1.html | 一个众所周知的事实就是,Linux 是一个用户可以高度自定义的系统,有很多选项可以选择 —— 作为操作系统,有各种各样的发行版,而对于单个发行版来说,又有很多桌面环境可以选择。与其他操作系统的用户一样,Linux 用户也有不同的口味和喜好,特别是对于桌面来说。
一些用户并非很在意他们的桌面,而其他一些则非常关心,要确保他们的桌面看起来很酷,很有吸引力,对于这种情况,有很多不错的应用可以派上用场。有一个应用可以给你的桌面带来活力 —— 特别是当你常用一个全局菜单的时候 —— 这就是 dock 。Linux 上有很多 dock 应用可选用;如果你希望是一个最简洁的,那么就选择 [Plank](https://launchpad.net/plank) 吧,文章接下来就要讨论这个应用。
**注意**:接下提到的例子和命令都已在 Ubuntu(版本 14.10)和 Plank(版本 0.9.1.1383)上测试通过。
### Plank

官方的文档描述 Plank 是“这个星球上最简洁的 dock”。该项目的目的就是仅提供一个 dock 需要的功能,尽管这是很基础的一个库,却可以被扩展,创造其他的含更多高级功能的 dock 程序。
这里值得一提的就是,在 elementary OS 里,Plank 是预装的。并且 Plank 是 Docky 的基础,Docky 也是一个非常流行的 dock 应用,在功能上与 Mac OS X 的 Dock 非常相似。
### 下载和安装
通过在终端里执行下面的命令,可以下载并安装 Plank:
```
sudo add-apt-repository ppa:docky-core/stable
sudo apt-get update
sudo apt-get install plank
```
安装成功后,你就可以在 Unity Dash(见下面图片)里通过输入 Plank 来打开该应用,或者从应用菜单里面打开,如果你没有使用 Unity 环境的话。

### 特性
当 Plank 启用后,你会看见它停靠在你桌面的底部中间位置。

正如上面图片显示的那样,dock 包含许多带橙色标示的应用图标,这表明这些应用正处于运行状态。无需说,你可以点击一个图标来打开那个应用。同时,右击一个应用图标会给出更多的选项,你可能会感兴趣。举个例子,看下面的屏幕快照:

为了获得配置的选项,你需要右击一下 Plank 的图标(左数第一个),然后点击 Preferences 选项。这就会出现如下的窗口。

如你所见,Preferences 窗口包含两个标签:Apperance 和 Behavior,前者是默认选中的。Appearance 标签栏包含 Plank 主题相关的设置,dock 的位置,对齐,还有图标相关的,而 Behavior 标签栏包含 dock 本身相关的设定。

举个例子,我在 Appearance 里改变 dock 的位置为右侧,在 Behavior 里锁定图标(这表示右击选项中不再有 “Keep in Dock”)。

如你所见的上面屏幕快照一样,改变生效了。类似地,根据你个人需求,改变任何可用的设定。
### 结论
如我开始所说的那样,使用 dock 不是强制的。尽管如此,使用一个会让事情变得方便,特别是你习惯了 Mac,而最近由于一些原因切换到了 Linux 系统。就其本身而言,Plank 不仅提供简洁性,还有可信任和稳定性 —— 该项目一直被很好地维护着。
---
via: <https://www.maketecheasier.com/download-install-configure-plank-dock-ubuntu/>
作者:[Himanshu Arora](https://www.maketecheasier.com/author/himanshu/) 译者:[wi-cuckoo](https://github.com/wi-cuckoo) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | 
Macs may have popularized launcher docks, but it’s Linux where they were perfected. Apps like [Plank](https://launchpad.net/plank) allow you to have such a dock on your desktop. From there, you can launch your favorite apps, juggle the active ones, and check out useful information.
Let’s see how you can install, use, and configure Plank in Ubuntu for quick and snazzy-looking access to your favorite apps.
## Installation
If you’re on Ubuntu or a compatible distribution like Mint, you can find Plank in the default repositories. To bring it on-board, fire up your favorite terminal and enter:
sudo apt install plank

When Plank is installed, locate it among the rest of your software and run it.

This may very well be the last time you’re launching your apps “the official way.”
## Usage
Plank’s use is straightforward and doesn’t differ from any typical toolbar-with-icons on any desktop or any operating system. The program comes pre-configured with some of the most popular apps stuck on it, out of which you’re probably using at least one or two. You can click their icon there to launch them.

If you don’t recognize some icons, Plank doesn’t display labels by default. However, it will show the name of each app if you hover your cursor over its icon.

Plank supports dynamic menus that expose some functionality of each app. For example, by right-clicking on an icon for the terminal, you can open a new window or access its preferences.

By right-clicking the icon of a media player app, though, you’ll be able to pause or resume playing, skip tracks, etc.

To rearrange the icons on Plank, click on one of them and keep the mouse button pressed. Then, drag the icon where you want it on the dock.

To remove an icon from the dock, either left-click and drag it outside the dock or right-click and uncheck “Keep in Dock.”
## Configuration
Right-clicking to quickly access your apps’ functions without having to visit their windows is fantastic. However, if the right-click shows each app’s menu, how can you access Plank’s options?
Theoretically, you can right-click directly in the empty space to the left or right of the dock, and, supposedly, its menu will pop up.
This practically never worked for me, so I’m using the easier shortcut instead: keep `Ctrl` held down and right-click anywhere on the dock. Plank’s menu will appear. Choose Preferences from this menu to access the program’s options.

There aren’t many options available, but those that exist can radically change how Plank looks and performs. You’ll find them in three groups: Appearance, Behaviour, and Docklets.
### Appearance
In Appearance, you can change Plank’s Theme and its Position on the screen (top, right, bottom, or left). You can disable the default restriction that keeps it on your Primary Display to have it show up on your other monitors.

Plank appears by default at the center of the screen. You can change that with the Alignment drop-down menu and fine-tune its position with the slider on the right.
There’s also some control over how the icons look. You can change the Icon Alignment and the Icon Size. Plank might not be the fanciest dock, but it does offer a zoom effect that you can enable. When enabled, it will make the icons larger when you hover over them. There’s a slider that controls the zoom level, too. However, when we tried the largest value, it made the icons look somewhat fuzzy.
### Behaviour
In the Behaviour tab, you can choose how Plank will hide when a window tries to share the same screen space. There are different ways it can respond to an approaching window, and you can also add a Hide Delay and Unhide Delay. Or you can disable the feature altogether and have Plank always stay on your screen – even if that means it will overlap with window content.

The subtitle Item Management doesn’t clarify that the options underneath it refer to the icons that appear on Plank.
By disabling “Show Unpinned” (that’s on by default), you can force Plank only to show the apps you’ve manually pinned on it and ignore everything else. Take heed, though; if you disable all other toolbars on your desktop and this option in Plank, you’ll have to jump between your active windows using shortcuts.
Enabling “Lock Icons” will stick the current icons where they are and forbid any tweaks to their placement.
Finally, “Restrict to Workspace” will have Plank only show the apps that are active on the current workspace and ignore the rest.
## Docklets
The last group, Docklets, allows you to add the functionality of a proper toolbar to Plank. Instead of only presenting icons for pinned and active apps, you can add a “start menu” equivalent for instant access to all your installed software, a battery indicator, a clock, etc.

Plank might not be the most impressive dock, but it offers a perfect balance between looks, functionality, and customizability. Meanwhile, do also [check out some other dock applications for Linux](https://www.maketecheasier.com/linux-dock-roundup/).
Our latest tutorials delivered straight to your inbox |
6,266 | RHCSA 系列(八): 加固 SSH,设定主机名及启用网络服务 | http://www.tecmint.com/rhcsa-series-secure-ssh-set-hostname-enable-network-services-in-rhel-7/ | 2015-09-23T08:01:00 | [
"RHCSA"
] | https://linux.cn/article-6266-1.html | 作为一名系统管理员,你将经常使用一个终端模拟器来登录到一个远程的系统中,执行一系列的管理任务。你将很少有机会坐在一个真实的(物理)终端前,所以你需要设定好一种方法来使得你可以登录到你需要去管理的那台远程主机上。
事实上,当你必须坐在一台物理终端前的时候,就可能是你登录到该主机的最后一种方法了。基于安全原因,使用 Telnet 来达到以上目的并不是一个好主意,因为穿行在线缆上的流量并没有被加密,它们以明文方式在传送。
另外,在这篇文章中,我们也将复习如何配置网络服务来使得它在开机时被自动开启,并学习如何设置网络和静态或动态地解析主机名。

*RHCSA: 安全 SSH 和开启网络服务 – Part 8*
### 安装并确保 SSH 通信安全
对于你来说,要能够使用 SSH 远程登录到一个 RHEL 7 机子,你必须安装 `openssh`,`openssh-clients` 和 `openssh-servers` 软件包。下面的命令不仅将安装远程登录程序,也会安装安全的文件传输工具以及远程文件复制程序:
```
# yum update && yum install openssh openssh-clients openssh-servers
```
注意,也安装上服务器所需的相应软件包是一个不错的主意,因为或许在某个时刻,你想使用同一个机子来作为客户端和服务器。
在安装完成后,如若你想安全地访问你的 SSH 服务器,你还需要考虑一些基本的事情。下面的设定应该出现在文件 `/etc/ssh/sshd_config` 中。
1、 更改 sshd 守护进程的监听端口,从 22(默认的端口值)改为一个更高的端口值(2000 或更大),但首先要确保所选的端口没有被占用。
例如,让我们假设你选择了端口 2500 。使用 [netstat](http://www.tecmint.com/20-netstat-commands-for-linux-network-management/) 来检查所选的端口是否被占用:
```
# netstat -npltu | grep 2500
```
假如 netstat 没有返回任何信息,则你可以安全地为 sshd 使用端口 2500,并且你应该在上面的配置文件中更改端口的设定,具体如下:
```
Port 2500
```
2、 只允许协议 2(LCTT 译注:SSHv1 已经被证明不安全,默认情况下 SSHv1 和 SSHv2 都支持,所以应该显示去掉如下配置行的注释,并只支持 SSHv2。):
```
Protocol 2
```
3、 配置验证超时的时间为 2 分钟,不允许以 root 身份登录,并将允许通过 ssh 登录的人数限制到最小:
```
LoginGraceTime 2m
PermitRootLogin no
AllowUsers gacanepa
```
4、 假如可能,使用基于公钥的验证方式而不是使用密码:
```
PasswordAuthentication no
RSAAuthentication yes
PubkeyAuthentication yes
```
这假设了你已经在你的客户端机子上创建了带有你的用户名的一个密钥对,并将公钥复制到了你的服务器上。
* [开启 SSH 无密码登录](/article-5444-1.html)
### 配置网络和名称的解析
1、 每个系统管理员都应该对下面这个系统配置文件非常熟悉:
* /etc/hosts 被用来在小型网络中解析“名称” <---> “IP 地址”。
文件 `/etc/hosts` 中的每一行拥有如下的结构:
```
IP address - Hostname - FQDN
```
例如,
```
192.168.0.10 laptop laptop.gabrielcanepa.com.ar
```
2、 `/etc/resolv.conf` 特别指定 DNS 服务器的 IP 地址和搜索域,它被用来在没有提供域名后缀时,将一个给定的查询名称对应为一个全称域名。
在正常情况下,你不必编辑这个文件,因为它是由系统管理的。然而,若你非要改变 DNS 服务器的 IP 地址,建议你在该文件的每一行中,都应该遵循下面的结构:
```
nameserver - IP address
```
例如,
```
nameserver 8.8.8.8
```
3、 `/etc/host.conf` 特别指定在一个网络中主机名被解析的方法和顺序。换句话说,告诉名称解析器使用哪个服务,并以什么顺序来使用。
尽管这个文件由几个选项,但最为常见和基本的设置包含如下的一行:
```
order bind,hosts
```
它意味着解析器应该首先查看 `resolv.conf` 中特别指定的域名服务器,然后到 `/etc/hosts` 文件中查找解析的名称。
4、 `/etc/sysconfig/network` 包含了所有网络接口的路由和全局主机信息。下面的值可能会被使用:
```
NETWORKING=yes|no
HOSTNAME=value
```
其中的 value 应该是<ruby> 全称域名 <rp> ( </rp> <rt> FQDN </rt> <rp> ) </rp></ruby>。
```
GATEWAY=XXX.XXX.XXX.XXX
```
其中的 XXX.XXX.XXX.XXX 是网关的 IP 地址。
```
GATEWAYDEV=value
```
在一个带有多个网卡的机器中, value 为网关设备名,例如 enp0s3。
5、 位于 `/etc/sysconfig/network-scripts` 中的文件(网络适配器配置文件)。
在上面提到的目录中,你将找到几个被命名为如下格式的文本文件。
```
ifcfg-name
```
其中 name 为网卡的名称,由 `ip link show` 返回:

*检查网络连接状态*
例如:

*网络文件*
除了环回接口(loopback),你还可以为你的网卡指定相似的配置。注意,假如设定了某些变量,它们将为这个指定的接口覆盖掉 `/etc/sysconfig/network` 中定义的默认值。在这篇文章中,为了能够解释清楚,每行都被加上了注释,但在实际的文件中,你应该避免加上注释:
```
HWADDR=08:00:27:4E:59:37 ### 网卡的 MAC 地址
TYPE=Ethernet ### 连接类型
BOOTPROTO=static ### 这代表着该网卡指定了一个静态地址。
### 如果这个值指定为 dhcp,这个网卡会从 DHCP 服务器获取 IP 地址,并且就不应该出现以下两行。
IPADDR=192.168.0.18
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
NM_CONTROLLED=no ### 应该给以太网卡设置,以便可以让 NetworkManager 可以修改这个文件。
NAME=enp0s3
UUID=14033805-98ef-4049-bc7b-d4bea76ed2eb
ONBOOT=yes ### 操作系统会在启动时打开这个网卡。
```
### 设定主机名
在 RHEL 7 中, `hostnamectl` 命令被同时用来查询和设定系统的主机名。
要展示当前的主机名,输入:
```
# hostnamectl status
```

*检查系统的主机名*
要更改主机名,使用
```
# hostnamectl set-hostname [new hostname]
```
例如,
```
# hostnamectl set-hostname cinderella
```
要想使得更改生效,你需要重启 hostnamed 守护进程(这样你就不必因为要应用更改而登出并再登录系统):
```
# systemctl restart systemd-hostnamed
```

*设定系统主机名*
另外, RHEL 7 还包含 `nmcli` 工具,它可被用来达到相同的目的。要展示主机名,运行:
```
# nmcli general hostname
```
且要改变主机名,则运行:
```
# nmcli general hostname [new hostname]
```
例如,
```
# nmcli general hostname rhel7
```

*使用 nmcli 命令来设定主机名*
### 在开机时开启网络服务
作为本文的最后部分,就让我们看看如何确保网络服务在开机时被自动开启。简单来说,这个可通过创建符号链接到某些由服务的配置文件中的 `[Install]` 小节中指定的文件来实现。
以 firewalld(/usr/lib/systemd/system/firewalld.service) 为例:
```
[Install]
WantedBy=basic.target
Alias=dbus-org.fedoraproject.FirewallD1.service
```
要开启该服务,运行:
```
# systemctl enable firewalld
```
另一方面,要禁用 firewalld,则需要移除符号链接:
```
# systemctl disable firewalld
```

*在开机时开启服务*
### 总结
在这篇文章中,我们总结了如何安装 SSH 及使用它安全地连接到一个 RHEL 服务器;如何改变主机名,并在最后如何确保在系统启动时开启服务。假如你注意到某个服务启动失败,你可以使用 `systemctl status -l [service]` 和 `journalctl -xn` 来进行排错。
请随意使用下面的评论框来让我们知晓你对本文的看法。提问也同样欢迎。我们期待着你的反馈!
---
via: <http://www.tecmint.com/rhcsa-series-secure-ssh-set-hostname-enable-network-services-in-rhel-7/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[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,267 | 10 条真心有趣的 Linux 命令 | http://www.unixmen.com/list-10-funny-linux-commands/ | 2015-09-22T11:13:00 | [
"命令行"
] | https://linux.cn/article-6267-1.html | ****
**在终端工作是一件很有趣的事情。今天,我们将会列举一些有趣得为你带来欢笑的Linux命令。**
### 1. rev
创建一个文件,在文件里面输入几个单词,rev命令会将你写的东西反转输出到控制台。
```
# rev <file name>
```


### 2. fortune
这个命令没有被默认安装,用apt-get命令安装它,fortune命令会随机显示一些句子
```
crank@crank-System:~$ sudo apt-get install fortune
```

利用fortune命令的 -s 选项,他会限制一个句子的输出长度。
```
# fortune -s
```

### 3. yes
```
# yes <string>
```
这个命令会不停打印字符串,直到用户把这进程给结束掉。
```
# yes unixmen
```

### 4. figlet
这个命令可以用apt-get安装,安装之后,在**/usr/share/figlet**可以看到一些ascii字体文件。
```
cd /usr/share/figlet
```
---
```
#figlet -f <font> <string>
#figlet -f big.flf unixmen
```

```
#figlet -f block.flf unixmen
```

当然,你也可以尝试使用其他的选项。
### 5. asciiquarium
这个命令会将你的终端变成一个海洋馆。
下载term animator:
```
# 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
```
接着安装下面这个包:
```
# apt-get install libcurses-perl
```
下载并且安装asciiquarium:
```
# wget http://www.robobunny.com/projects/asciiquarium/asciiquarium.tar.gz
# tar -zxvf asciiquarium.tar.gz
# cd asciiquarium_1.0/
# cp asciiquarium /usr/local/bin/
```
执行如下命令:
```
# /usr/local/bin/asciiquarium
```

### 6. bb
```
# apt-get install bb
# bb
```
看看会输出什么?

### 7. sl
有的时候你可能把 **ls** 误打成了 **sl**,其实 **sl** 也是一个命令,如果你打 sl的话,你会看到一个移动的火车头
```
# apt-get install sl
```
---
```
# sl
```

### 8. cowsay
一个很常见的命令,它会用ascii显示你想说的话。
```
apt-get install cowsay
```
---
```
# cowsay <string>
```

或者,你可以用其他的角色来取代默认角色来说这句话,这些角色都存储在**/usr/share/cowsay/cows**目录下
```
# cd /usr/share/cowsay/cows
```
---
```
cowsay -f ghostbusters.cow unixmen
```

或者
```
# cowsay -f bud-frogs.cow Rajneesh
```

### 9. toilet
你没看错,这是个命令来的,他会将字符串以彩色的ascii字符串形式输出到终端
```
# apt-get install toilet
```
---
```
# toilet --gay unixmen
```

```
toilet -F border -F gay unixmen
```

```
toilet -f mono12 -F metal unixmen
```

### 10. aafire
aafire能让你的终端燃起来。
```
# apt-get install libaa-bin
```
---
```
# aafire
```

就这么多,祝你们在Linux终端玩得开心哈!!!
---
via: <http://www.unixmen.com/list-10-funny-linux-commands/>
作者:[Rajneesh Upadhyay](http://www.unixmen.com/author/rajneesh/) 译者:[tnuoccalanosrep](https://github.com/tnuoccalanosrep) 校对:[wxy](https://github.com/%E6%A0%A1%E5%AF%B9%E8%80%85ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,272 | Docker 在安全组件、实时容器迁移方面的进展 | http://www.eweek.com/virtualization/docker-working-on-security-components-live-container-migration.html | 2015-09-23T07:50:00 | [
"Docker",
"容器"
] | https://linux.cn/article-6272-1.html | 
**这是 Docker 开发者在 Containercon 上的演讲,谈论将来的容器在安全和实时迁移方面的创新**
来自西雅图的消息。当前 IT 界最热的词汇是“容器”,美国有两大研讨会:Linuxcon USA 和 Containercon,后者就是为容器而生的。
Docker 公司是开源 Docker 项目的商业赞助商,本次研讨会这家公司有 3 位高管带来主题演讲,但公司创始人 Solomon Hykes 没上场演讲。
Hykes 曾在 2014 年的 Linuxcon 上进行过一次主题演讲,但今年的 Containeron 他只坐在观众席上。而工程部高级副总裁 Marianna Tessel、Docker 首席安全官 Diogo Monica 和核心维护员 Michael Crosby 为我们演讲 Docker 新增的功能和将来会有的功能。
Tessel 强调 Docker 现在已经被很多世界上大型组织用在生产环境中,包括美国政府。Docker 也被用在小环境中,比如树莓派,一块树莓派上可以跑 2300 个容器。
“Docker 的功能正在变得越来越强大,而部署方法变得越来越简单。”Tessel 在会上说道。
Tessel 把 Docker 形容成一艘游轮,内部由强大而复杂的机器驱动,外部为乘客提供平稳航行的体验。
Docker 试图解决的领域是简化安全配置。Tessel 认为对于大多数用户和组织来说,避免网络漏洞所涉及的安全问题是一个乏味而且复杂的过程。
于是 Docker Content Trust 就出现在 Docker 1.8 release 版本中了。安全项目领导 Diogo Mónica 中加入了 Tessel 的台上讨论,说安全是一个难题,而 Docker Content Trust 就是为解决这个难道而存在的。
Docker Content Trust 提供一种方法来验证一个 Docker 应用是否可信,以及多种方法来限制欺骗和病毒注入。
为了证明他的观点,Monica 做了个现场示范,演示 Content Trust 的效果。在一个实验中,一个网站在更新过程中其 Web App 被人为攻破,而当 Content Trust 启动后,这个黑客行为再也无法得逞。
“不要被这个表面上简单的演示欺骗了,”Tessel 说道,“你们看的是最安全的可行方案。”
Docker 以前没有实现的领域是实时迁移,这个技术在 VMware 虚拟机中叫做 vMotion,而现在,Docker 也实现了这个功能。
Docker 首席维护员 Micheal Crosby 在台上做了个实时迁移的演示,Crosby 把这个过程称为快照和恢复:首先从运行中的容器拿到一个快照,之后将这个快照移到另一个地方恢复。
一个容器也可以克隆到另一个地方,Crosby 将他的克隆容器称为“多利”,就是世界上第一只被克隆出来的羊的名字。
Tessel 也花了点时间聊了下 RunC 组件,这是个正在被 Open Container Initiative 作为多方开发的项目,目的是让它可以从 Linux 扩展到包括 Windows 和 Solaris 在内的多种操作系统。
Tessel 总结说她不知道 Docker 的未来是什么样,但对此抱非常乐观的态度。
“我不确定未来是什么样的,但我很确定 Docker 会在这个世界中脱颖而出”,Tessel 说的。
*Sean Michael Kerner 是 eWEEK 和 InternetNews.com 网站的高级编辑,可通过推特 @TechJournalist 关注他。*
---
via: <http://www.eweek.com/virtualization/docker-working-on-security-components-live-container-migration.html>
作者:[Sean Michael Kerner](http://www.eweek.com/cp/bio/Sean-Michael-Kerner/) 译者:[bazz2](https://github.com/bazz2) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,273 | Ubuntu 开源操作系统运行在中国 42% 的 Dell PC 上 | http://thevarguy.com/open-source-application-software-companies/091515/ubuntu-linux-based-open-source-os-runs-42-percent-dell-pc | 2015-09-23T08:00:00 | [
"Ubuntu",
"Dell",
"麒麟"
] | /article-6273-1.html |
>
> Dell 称它在中国市场出售的 42% 的 PC 运行的是 Kylin,这是一款 Canonical 帮助开发的基于 Ubuntu 的操作系统。
>
>
>
让开源粉丝欢喜的是:Linux 桌面年来了。或者说中国正在接近这个目标,[Dell](http://dell.com/) 报告称它售卖的超过 40% 的 PC 机运行的是 [Canonical](http://canonical.com/) 帮助开发的 [Ubuntu Linux](http://ubuntu.com/)。
特别地,Dell 称 42% 的中国电脑运行 NeoKylin(中标麒麟),一款中国本土倾力打造的用于替代 [Microsoft](http://microsoft.com/) Windows的操作系统。它也简称麒麟,这是一款从 2013 年出来的基于 Ubuntu 的操作系统,也是这年开始 Canonical 公司与中国政府合作建立一个专供中国市场的 Ubuntu 变种。
麒麟的早期版本出现于 2001 年左右,也是基于其他操作系统,包括 FreeBSD,这是一个开放源码但是不同于 Linux 的类 Unix 操作系统。
Ubuntu 麒麟的外观和感觉很像 Ubuntu 的现代版本。它拥有的 [Unity](http://unity.ubuntu.com/) 界面,并运行开源软件的标准套件,以及专门的如 Youker 助理程序,它是一个图形化的前端,帮助用户管理基本计算任务。但是麒麟的默认主题使得它看起来有点像 Windows 而不是 Ubuntu。
鉴于桌面 Linux PC 市场在世界上大多数国家的相对停滞,戴尔的宣布是令人吃惊的。结合中国对当前版本 windows 的轻微[敌意](http://www.wsj.com/articles/windows-8-faces-new-criticism-in-china-1401882772),这个消息并不看好着微软在中国市场的前景。
紧跟着 Dell 公司[宣布](http://thevarguy.com/business-technology-solution-sales/091415/dell-125-million-directed-china-jobs-new-business-and-innovation)在华投资1.25亿美元之后,一位决策者给华尔街杂志的评论中提到了 Dell 在中国市场上 PC 的销售。

---
via: <http://thevarguy.com/open-source-application-software-companies/091515/ubuntu-linux-based-open-source-os-runs-42-percent-dell-pc>
作者:[Christopher Tozzi](http://thevarguy.com/author/christopher-tozzi) 译者:[geekpi](https://github.com/geeekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='thevarguy.com', port=80): Max retries exceeded with url: /open-source-application-software-companies/091515/ubuntu-linux-based-open-source-os-runs-42-percent-dell-pc (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7b8327581de0>: Failed to resolve 'thevarguy.com' ([Errno -2] Name or service not known)")) | null |
6,284 | 如何在 linux 中搭建 FTP 服务 | http://itsfoss.com/set-ftp-server-linux/ | 2015-09-24T13:04:00 | [
"FTP",
"vsftp"
] | https://linux.cn/article-6284-1.html | 
在本教程中,我将会介绍如何搭建你自己的FTP服务。但是,首先我们应该来的学习一下FTP是什么。
### FTP是什么?
[FTP](https://en.wikipedia.org/wiki/File_Transfer_Protocol) 是<ruby> 文件传输协议 <rp> ( </rp> <rt> File Transfer Protocol </rt> <rp> ) </rp></ruby>的缩写。顾名思义,FTP用于计算机之间通过网络进行文件传输。你可以通过FTP在计算机账户间进行文件传输,也可以在账户和桌面计算机之间传输文件,或者访问在线软件归档。但是,需要注意的是多数的FTP站点的使用率非常高,可能需要多次重连才能连接上。
FTP地址和HTTP地址(即网页地址)非常相似,只是FTP地址使用ftp://前缀而不是http://
### FTP服务器是什么?
通常,拥有FTP地址的计算机是专用于接收FTP连接请求的。一台专用于接收FTP连接请求的计算机即为FTP服务器或者FTP站点。
现在,我们来开始一个特别的冒险,我们将会搭建一个FTP服务用于和家人、朋友进行文件共享。在本教程,我们将以[vsftpd](https://security.appspot.com/vsftpd.html)作为ftp服务。
VSFTPD是一个自称为最安全的FTP服务端软件。事实上VSFTPD的前两个字母表示“<ruby> 非常安全的 <rp> ( </rp> <rt> very secure </rt> <rp> ) </rp></ruby>”。该软件的构建绕开了FTP协议的漏洞。
尽管如此,你应该知道还有更安全的方法进行文件管理和传输,如:SFTP(使用[OpenSSH](http://www.openssh.com/))。FTP协议对于共享非敏感数据是非常有用和可靠的。
#### 使用 rpm 安装VSFTPD:
你可以使用如下命令在命令行界面中快捷的安装VSFTPD:
```
dnf -y install vsftpd
```
#### 使用 deb 安装VSFTPD:
你可以使用如下命令在命令行界面中快捷的安装VSFTPD:
```
sudo apt-get install vsftpd
```
#### 在Arch 中安装VSFTPD:
你可以使用如下命令在命令行界面中快捷的安装VSFTPD:
```
sudo pacman -S vsftpd
```
#### 配置FTP服务
多数的VSFTPD配置项都在/etc/vsftpd.conf配置文件中。这个文件本身已经有非常良好的文档说明了,因此,在本节中,我只强调一些你可能进行修改的重要选项。使用man页面查看所有可用的选项和基本的 文档说明:
```
man vsftpd.conf
```
根据文件系统层级标准,FTP共享文件默认位于/srv/ftp目录中。
**允许上传:**
为了允许ftp用户可以修改文件系统的内容,如上传文件等,“write\_enable”标志必须设置为 YES。
```
write_enable=YES
```
**允许本地(系统)用户登录:**
为了允许文件/etc/passwd中记录的用户可以登录ftp服务,“local\_enable”标记必须设置为YES。
```
local_enable=YES
```
**匿名用户登录**
下面配置内容控制匿名用户是否允许登录:
```
# 允许匿名用户登录
anonymous_enable=YES
# 匿名登录不需要密码(可选)
no_anon_password=YES
# 匿名登录的最大传输速率,Bytes/second(可选)
anon_max_rate=30000
# 匿名登录的目录(可选)
anon_root=/example/directory/
```
**根目录限制(Chroot Jail)**
( LCTT 译注:chroot jail是类unix系统中的一种安全机制,用于修改进程运行的根目录环境,限制该线程不能感知到其根目录树以外的其他目录结构和文件的存在。详情参看[chroot jail](https://zh.wikipedia.org/wiki/Chroot))
有时我们需要设置根目录(chroot)环境来禁止用户离开他们的家(home)目录。在配置文件中增加/修改下面配置开启根目录限制(Chroot Jail):
```
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list
```
“chroot\_list\_file”变量指定根目录限制所包含的文件/目录( LCTT 译注:即用户只能访问这些文件/目录)
最后你必须重启ftp服务,在命令行中输入以下命令:
```
sudo systemctl restart vsftpd
```
到此为止,你的ftp服务已经搭建完成并且启动了。
---
via: <http://itsfoss.com/set-ftp-server-linux/>
作者:[alimiracle](http://itsfoss.com/author/ali/) 译者:[cvsher](https://github.com/cvsher) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,285 | 开启 Ubuntu 系统自动升级 | http://itsfoss.com/automatic-system-updates-ubuntu/ | 2015-09-24T13:07:55 | [
"Ubuntu"
] | https://linux.cn/article-6285-1.html | 在学习如何开启Ubuntu系统自动升级之前,先解释下为什么需要自动升级。
默认情况下,ubuntu每天一次检查更新。但是一周只会弹出一次软件升级提醒,除非当有安全性升级时,才会立即弹出。所以,如果你已经使用Ubuntu一段时间,你肯定很熟悉这个画面:

但是做为一个正常桌面用户,根本不会去关心有什么更新细节。而且这个提醒完全就是浪费时间,你肯定信任Ubuntu提供的升级补丁,对不对?所以,大部分情况你肯定会选择“现在安装”,对不对?
所以,你需要做的就只是点一下升级按钮。现在,明白为什么需要自动系统升级了吧?开启自动系统升级意味着所有最新的更新都会自动下载并安装,并且没有请求确认。是不是很方便?
### 开启Ubuntu自动升级
演示使用Ubuntu15.04,Ubuntu 14.04步骤类似。
打开Unity Dash ,找到软件&更新:

打开软件资源设置,切换到升级标签:

可以发现,默认设置就是每日检查并立即提醒安全升级。

改变 ‘当有安全升级’和‘当有其他升级’的选项为:下载并自动安装。

关闭对话框完成设定。这样每次Ubuntu检查更新后就会自动升级。事实上,这篇文章十分类似[改变Ubuntu升级提醒频率](http://itsfoss.com/ubuntu-notify-updates-frequently/)。
你喜欢自动升级还是手动安装升级呢?欢迎评论。
---
via: <http://itsfoss.com/automatic-system-updates-ubuntu/>
作者:[Abhishek](http://itsfoss.com/author/abhishek/) 译者:[Vic020/VicYu](http://vicyu.net) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,286 | RHCSA 系列(九): 安装、配置及加固一个 Web 和 FTP 服务器 | http://www.tecmint.com/rhcsa-series-install-and-secure-apache-web-server-and-ftp-in-rhel/ | 2015-09-24T14:11:45 | [
"RHCSA"
] | https://linux.cn/article-6286-1.html | Web 服务器(也被称为 HTTP 服务器)是在网络中将内容(最为常见的是网页,但也支持其他类型的文件)进行处理并传递给客户端的服务。
FTP 服务器是最为古老且最常使用的资源之一(即便到今天也是这样),在身份认证不是必须的情况下,它可通过客户端在一个网络访问文件,因为 FTP 使用没有加密的用户名和密码,所以有些情况下不需要验证也行。
在 RHEL 7 中可用的 web 服务器是版本号为 2.4 的 Apache HTTP 服务器。至于 FTP 服务器,我们将使用 Very Secure Ftp Daemon (又名 vsftpd) 来建立用 TLS 加固的连接。

*RHCSA: 安装,配置及加固 Apache 和 FTP 服务器 – Part 9*
在这篇文章中,我们将解释如何在 RHEL 7 中安装、配置和加固 web 和 FTP 服务器。
### 安装 Apache 和 FTP 服务器
在本指导中,我们将使用一个静态 IP 地址为 192.168.0.18/24 的 RHEL 7 服务器。为了安装 Apache 和 VSFTPD,运行下面的命令:
```
# yum update && yum install httpd vsftpd
```
当安装完成后,这两个服务在开始时是默认被禁用的,所以我们需要暂时手动开启它们并让它们在下一次启动时自动地开启它们:
```
# systemctl start httpd
# systemctl enable httpd
# systemctl start vsftpd
# systemctl enable vsftpd
```
另外,我们必须打开 80 和 21 端口,它们分别是 web 和 ftp 守护进程监听的端口,为的是允许从外面访问这些服务:
```
# firewall-cmd --zone=public --add-port=80/tcp --permanent
# firewall-cmd --zone=public --add-service=ftp --permanent
# firewall-cmd --reload
```
为了确认 web 服务工作正常,打开你的浏览器并输入服务器的 IP,则你应该可以看到如下的测试页面:

*确认 Apache Web 服务器*
对于 ftp 服务器,在确保它如期望中的那样工作之前,我们必须进一步地配置它,我们将在几分钟后来做这件事。
### 配置并加固 Apache Web 服务器
Apache 的主要配置文件位于 `/etc/httpd/conf/httpd.conf` 中,但它可能依赖 `/etc/httpd/conf.d` 中的其他文件。
尽管默认的配置对于大多数的情形都够用了,但熟悉在 [官方文档](http://httpd.apache.org/docs/2.4/) 中介绍的所有可用选项是一个不错的主意。
同往常一样,在编辑主配置文件前先做一个备份:
```
# cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.$(date +%Y%m%d)
```
然后用你钟爱的文本编辑器打开它,并查找下面这些变量:
* `ServerRoot`: 服务器的配置,错误和日志文件保存的目录。
* `Listen`: 通知 Apache 去监听特定的 IP 地址或端口。
* `Include`: 允许包含其他配置文件,要包含的文件必须存在,否则,服务器将会失败。它恰好与 IncludeOptional 相反,假如特定的配置文件不存在,它将静默地忽略掉它们。
* `User` 和 `Group`: 运行 httpd 服务的用户/组的名称。
* `DocumentRoot`: Apache 为你的文档所服务的目录。默认情况下,所有的请求将在这个目录中被获取,但符号链接和别名可能会被用于指向其他位置。
* `ServerName`: 这个指令将设定用于识别它自身的主机名(或 IP 地址)和端口。
安全措施的第一步将包含创建一个特定的用户和组(如 tecmint/tecmint)来运行 web 服务器,以及更改默认的端口为一个更高的端口(在这个例子中为 9000) (LCTT 译注:如果你的 Web 服务器对外公开提供服务,则不建议修改为非默认端口。):
```
ServerRoot "/etc/httpd"
Listen 192.168.0.18:9000
User tecmint
Group tecmint
DocumentRoot "/var/www/html"
ServerName 192.168.0.18:9000
```
你可以使用下面的命令来测试配置文件:
```
# apachectl configtest
```
假如一切 OK,接着重启 web 服务器。
```
# systemctl restart httpd
```
并别忘了在防火墙中开启新的端口(并禁用旧的端口):
```
# firewall-cmd --zone=public --remove-port=80/tcp --permanent
# firewall-cmd --zone=public --add-port=9000/tcp --permanent
# firewall-cmd --reload
```
请注意,由于 SELinux 策略,你只能给给 web 服务器使用如下命令所返回的端口。
```
# semanage port -l | grep -w '^http_port_t'
```
假如你想让 httpd 服务使用另一个端口(如 TCP 端口 8100),你必须将它加到 SELinux 的端口上下文:
```
# semanage port -a -t http_port_t -p tcp 8100
```

*添加 Apache 端口到 SELinux 策略*
为了进一步加固你安装的 Apache,请遵循以下步骤:
1. 运行 Apache 的用户不应该拥有访问 shell 的能力:
```
# usermod -s /sbin/nologin tecmint
```
2. 禁用目录列表功能,这是为了阻止浏览器展示一个未包含 index.html 文件的目录里的内容。
编辑 `/etc/httpd/conf/httpd.conf` (以及虚拟主机的配置文件,假如有的话),并确保出现在顶层的和Directory 块中的 Options 指令都被设置为 None:
```
Options None
```
3. 在 HTTP 响应中隐藏有关 web 服务器和操作系统的信息。像下面这样编辑文件 `/etc/httpd/conf/httpd.conf`:
```
ServerTokens Prod
ServerSignature Off
```
现在,你已经做好了从 `/var/www/html` 目录开始服务内容的准备了。
### 配置并加固 FTP 服务器
和 Apache 的情形类似, Vsftpd 的主配置文件 `/etc/vsftpd/vsftpd.conf` 带有详细的注释,且虽然对于大多数的应用实例,默认的配置应该足够了,但为了更有效率地操作 ftp 服务器,你应该开始熟悉相关的文档和 man 页 `man vsftpd.conf`(对于这点,再多的强调也不为过!)。
在我们的示例中,使用了这些指令:
```
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
chroot_local_user=YES
allow_writeable_chroot=YES
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
```
通过使用 `chroot_local_user=YES`,(默认情况下)本地用户在登录之后,将被限制在以用户的家目录为 chroot 监狱的环境中。这意味着本地用户将不能访问除其家目录之外的任何文件。
最后,为了让 ftp 能够在用户的家目录中读取文件,设置如下的 SELinux 布尔值:
```
# setsebool -P ftp_home_dir on
```
现在,你可以使用一个客户端例如 Filezilla 来连接一个 ftp 服务器:

*查看 FTP 连接*
注意, `/var/log/xferlog` 日志将会记录下载和上传的情况,这与上图的目录列表一致:

*监视 FTP 的下载和上传情况*
另外请参考: [在 Linux 系统中使用 Trickle 来限制应用使用的 FTP 网络带宽](/article-5517-1.html)
### 总结
在本教程中,我们解释了如何设置 web 和 ftp 服务器。由于这个主题的广泛性,涵盖这些话题的所有方面是不可能的(如虚拟主机)。因此,我推荐你也阅读这个网站中有关 [Apache](http://www.google.com/cse?cx=partner-pub-2601749019656699:2173448976&ie=UTF-8&q=virtual+hosts&sa=Search&gws_rd=cr&ei=Dy9EVbb0IdHisASnroG4Bw#gsc.tab=0&gsc.q=apache) 的其他卓越的文章。
---
via: <http://www.tecmint.com/rhcsa-series-install-and-secure-apache-web-server-and-ftp-in-rhel/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[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,289 | 谷歌公布放弃 RC4 和 SSLv3 的详细计划 | https://threatpost.com/google-details-plans-to-disable-sslv3-and-rc4/114732/ | 2015-09-25T07:38:00 | [
"RC4",
"SSL",
"SSLv3",
"https"
] | https://linux.cn/article-6289-1.html | 
不出所料,这周谷歌正式宣布准备放弃支持流算法 RC4 和 SSLv3 协议,这二者都有悠久的被攻击历史。
该公司的一名安全工程师亚当.兰利周四在一篇博客中宣布了该计划。虽然没有一个具体的时间表,但是兰利坚称,谷歌会在适当的时段内在其所有的前端服务器、Chrome、Android、爬虫和 SMTP 服务器中放弃使用 RC4 和 SSLv3。
事实上,该公司宣布放弃 RC4 和 SSLv3 并不令人惊讶,<ruby> 国际互联网工程任务组 <rp> ( </rp> <rt> IETF </rt> <rp> ) </rp></ruby>在今年夏天发布的一个<ruby> 互联网标准跟踪文档 <rp> ( </rp> <rt> Internet Standards Track document </rt> <rp> ) </rp></ruby>中[宣称了 SSLv3 的死亡](https://threatpost.com/ietf-officially-deprecates-sslv3/113503/),说它“不够安全”,而且说“任何版本的 TLS 都比 SSLv3 安全”。
如兰利在博客中说到的,RC4 已经用了28年了,虽然其在早期的表现很好,但是多年来它一直是多种攻击的目标,其中一些攻击可以导致 [TLS 会话降级](https://threatpost.com/attack-exploits-weakness-rc4-cipher-decrypt-user-sessions-031413/77628/)和 cookie 解密。
作为这次计划的一部分,谷歌宣布了一些 TLS 客户端应该具有的最低安全性标准:
1. 必须支持 TLS 1.2
2. 在握手时必须包含<ruby> 服务器名字指示 <rp> ( </rp> <rt> SNI (server name indication) </rt> <rp> ) </rp></ruby>扩展,还要包含将要连接的域名
3. 必须支持带有 P-256 和未压缩点的加密套件 TLS\_ECDHE\_RSA\_WITH\_AES\_128\_GCM\_SHA256
4. 至少要信任 <https://pki.google.com/roots.pem> 中的证书
5. 证书操作一定能支持 DNS <ruby> 主题替代名称 <rp> ( </rp> <rt> SAN(Subject Alternative Name) </rt> <rp> ) </rp></ruby>,并且这些主题替代名称可以包含一个通配符作为名字最左边的标签
兰利说:不满足需求的设备不会很快就停止工作,但是会受到 TLS 变化的影响,这可能持续到2020年。
“如果你的 TLS 客户端、web 服务器或者邮件服务器使用 SSLv3 或 RC4,虽然几年前就该更新了,不过现在更新总比不更新好。然而要注意,你现在使用 RC4 并不意味着你的客户端或网站就无法工作,TLS 会协商加密算法,但是如果你只支持 RC4 那就要出问题了。”,兰利说。
兰利在[这个月早些时候](https://threatpost.com/google-mozilla-microsoft-to-sever-rc4-support-in-early-2016/114498/)发到 [security@chromium.org](mailto:security@chromium.org) 邮件列表的一封帖子中宣布了废弃 RC4 的大致计划。确认这个算法会在将来的 Chrome 构建中禁用,可能会在 2016 年一、二月稳定。该公司也已经做了一些废弃 SSLv3 的工作:[随着取消 Chrome 中的 SSLv3 降级支持,](https://threatpost.com/google-removes-sslv3-fallback-support-from-chrome/109455/) POODLE 攻击就会失效,该公司也会逐步[淘汰 SHA-1 算法](https://threatpost.com/google-sunsetting-weak-sha-1-crypto-algorithm/108145/)。
| 200 | OK | As expected, Google formally announced its intent to move away from the stream cipher RC4 and the SSLv3 protocol this week, citing a long history of weaknesses in both.
Adam Langley, a security engineer for the company, announced the plans through a blog post on Thursday. While there isn’t a concrete timeline, Langely insisted that Google is looking to do away with support for RC4 and SSLv3 in all of its frontend servers, Chrome, Android, webcrawlers, and SMTP servers, in the medium term.
The fact that the company is looking cut ties with both mediums shouldn’t come as little surprise.
The Internet Engineering Task Force [condemned SSLv3](https://threatpost.com/ietf-officially-deprecates-sslv3/113503/) in an Internet Standards Track document over the summer, calling it “not sufficiently secure,” adding that “any version of TLS is more secure than SSLv3.”
As Langely notes in the blog, RC4 is 28 years old, and while it fared well in the early goings, it’s been the target of multiple attacks over the years, including some that can lead to TLS [session compromise](https://threatpost.com/attack-exploits-weakness-rc4-cipher-decrypt-user-sessions-031413/77628/) and cookie decryption.
As part of the switch Google also announced a collection of minimum standards for TLS clients going forward. According to the post, Google will eventually require the following of devices:
- TLS 1.2 must be supported.
- A Server Name Indication (SNI) extension must be included in the handshake and must contain the domain that’s being connected to.
- The cipher suite TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 must be supported with P-256 and uncompressed points.
- At least the certificates in https://pki.google.com/roots.pem must be trusted.
- Certificate handling must be able to support DNS Subject Alternative Names and those SANs may include a single wildcard as the left-most label in the name.
Langley notes that devices that don’t meet the requirements won’t stop working anytime soon, but acknowledges they may be affected by TLS changes later down the line, up to the year 2020.
“If your TLS client, webserver or email server requires the use of SSLv3 or RC4 then the time to update was some years ago, but better late than never. However, note that just because you might be using RC4 today doesn’t mean that your client or website will stop working: TLS can negotiate cipher suites and problems will only occur if you don’t support anything but RC4,” Langley wrote.
Langely announced cursory plans to deprecate RC4 [earlier this month](https://threatpost.com/google-mozilla-microsoft-to-sever-rc4-support-in-early-2016/114498/) in a post to the security@chromium.org mailing list, confirming that the cipher would be disabled in a future Chrome build, likely stable around January or February 2016.
The company has already taken one step towards nixing SSLv3: a month after last fall’s POODLE attack [it did away with support for the fallback to SSLv3 in Chrome](https://threatpost.com/google-removes-sslv3-fallback-support-from-chrome/109455/), a move that went hand in hand with the company’s [phasing out of the SHA-1](https://threatpost.com/google-sunsetting-weak-sha-1-crypto-algorithm/108145/) cryptographic hash algorithm. |
6,294 | Mhddfs:将多个小分区合并成一个大的虚拟存储 | http://www.tecmint.com/combine-partitions-into-one-in-linux-using-mhddfs | 2015-09-25T13:55:55 | [
"mhddds",
"文件系统"
] | https://linux.cn/article-6294-1.html | 让我们假定你有30GB的电影,并且你有3个驱动器,每个的大小为20GB。那么,你会怎么来存放东西呢?
很明显,你可以将你的视频分割成2个或者3个不同的卷,并将它们手工存储到驱动器上。这当然不是一个好主意,它成了一项费力的工作,它需要你手工干预,而且花费你大量时间。
另外一个解决方案是创建一个 [RAID磁盘阵列](http://www.tecmint.com/understanding-raid-setup-in-linux/)。然而,RAID在存储可靠性,磁盘空间可用性差等方面声名狼藉。另外一个解决方案,就是mhddfs。

*Mhddfs——在Linux中合并多个分区*
mhddfs是一个用于Linux的设备驱动,它可以将多个挂载点合并到一个虚拟磁盘中。它是一个基于FUSE的驱动,提供了一个用于大数据存储的简单解决方案。它可以将所有小文件系统合并,创建一个单一的大虚拟文件系统,该文件系统包含其成员文件系统的所有内容,包括文件和空闲空间。
#### 你为什么需要Mhddfs?
你的所有存储设备会创建为一个单一的虚拟池,它可以在启动时被挂载。这个小工具可以智能地照看并处理哪个存储满了,哪个存储空着,以及将数据写到哪个存储中。当你成功创建虚拟驱动器后,你可以使用[SAMBA](http://www.tecmint.com/mount-filesystem-in-linux/)来共享你的虚拟文件系统。你的客户端将在任何时候都看到一个巨大的驱动器和大量的空闲空间。
#### Mhddfs特性
* 获取文件系统属性和系统信息。
* 设置文件系统属性。
* 创建、读取、移除和写入目录和文件。
* 在单一设备上支持文件锁和硬链接。
| mhddfs的优点 | mhddfs的缺点 |
| --- | --- |
| 适合家庭用户 | mhddfs驱动没有内建在Linux内核中 |
| 运行简单 | 运行时需要大量处理能力 |
| 没有明显的数据丢失 | 没有冗余解决方案 |
| 不需要分割文件 | 不支持移动硬链接 |
| 可以添加新文件到组成的虚拟文件系统 | |
| 可以管理文件保存的位置 | |
| 支持扩展文件属性 | |
### Linux中安装Mhddfs
在Debian及其类似的移植系统中,你可以使用下面的命令来安装mhddfs包。
```
# apt-get update && apt-get install mhddfs
```

*安装Mhddfs到基于Debian的系统中*
在RHEL/CentOS Linux系统中,你需要开启[epel仓库](/article-2324-1.html),然后执行下面的命令来安装mhddfs包。
```
# yum install mhddfs
```
在Fedora 22及以上系统中,你可以通过dnf包管理来获得它,就像下面这样。
```
# dnf install mhddfs
```

*安装Mhddfs到Fedora*
如果万一mhddfs包不能从epel仓库获取到,那么你需要解决下面的依赖,然后像下面这样来编译源码并安装。
* FUSE头文件
* GCC
* libc6头文件
* uthash头文件
* libattr1头文件(可选)
接下来,只需从下面建议的地址下载最新的源码包,然后编译。
```
# wget http://mhddfs.uvw.ru/downloads/mhddfs_0.1.39.tar.gz
# tar -zxvf mhddfs*.tar.gz
# cd mhddfs-0.1.39/
# make
```
你应该可以在当前目录中看到mhddfs的二进制文件,以root身份将它移动到/usr/bin/和/usr/local/bin/中。
```
# cp mhddfs /usr/bin/
# cp mhddfs /usr/local/bin/
```
一切搞定,mhddfs已经可以用了。
### 我怎么使用Mhddfs?
1、 让我们看看当前所有挂载到我们系统中的硬盘。
```
$ df -h
```

**样例输出**
```
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 511M 132K 511M 1% /boot/efi
/dev/sda2 451G 92G 336G 22% /
/dev/sdb1 1.9T 161G 1.7T 9% /media/avi/BD9B-5FCE
/dev/sdc1 555M 555M 0 100% /media/avi/Debian 8.1.0 M-A 1
```
注意这里的‘挂载点’名称,我们后面会使用到它们。
2、 创建目录‘/mnt/virtual\_hdd’,所有这些文件系统将会在这里组织到一起。
```
# mkdir /mnt/virtual_hdd
```
3、 然后,挂载所有文件系统。你可以通过root或者FUSE组中的某个用户来完成。
```
# mhddfs /boot/efi, /, /media/avi/BD9B-5FCE/, /media/avi/Debian\ 8.1.0\ M-A\ 1/ /mnt/virtual_hdd -o allow_other
```

*在Linux中挂载所有文件系统*
**注意**:这里我们使用了所有硬盘的挂载点名称,很明显,你的挂载点名称会有所不同。也请注意“-o allow\_other”选项可以让这个虚拟文件系统让其它所有人可见,而不仅仅是创建它的人。
4、 现在,运行“df -h”来看看所有文件系统。它应该包含了你刚才创建的那个。
```
$ df -h
```

*验证虚拟文件系统挂载*
你可以像对已挂在的驱动器那样给虚拟文件系统应用所有的选项。
5、 要在每次系统启动创建这个虚拟文件系统,你应该以root身份添加下面的这行代码(在你那里会有点不同,取决于你的挂载点)到/etc/fstab文件的末尾。
```
mhddfs# /boot/efi, /, /media/avi/BD9B-5FCE/, /media/avi/Debian\ 8.1.0\ M-A\ 1/ /mnt/virtual_hdd fuse defaults,allow_other 0 0
```
6、 如果在任何时候你想要添加/移除一个新的驱动器到/从虚拟硬盘,你可以挂载一个新的驱动器,拷贝/mnt/vritual*hdd的内容,卸载卷,弹出你要移除的的驱动器并/或挂载你要包含的新驱动器。使用mhddfs命令挂载全部文件系统到Virtual*hdd下,这样就全部搞定了。
#### 我怎么卸载Virtual\_hdd?
卸载virtual\_hdd相当简单,就像下面这样
```
# umount /mnt/virtual_hdd
```

*卸载虚拟文件系统*
注意,是umount,而不是unmount,很多用户都输错了。
到现在为止全部结束了。我正在写另外一篇文章,你们一定喜欢读的。到那时,请保持连线。请在下面的评论中给我们提供有用的反馈吧。请为我们点赞并分享,帮助我们扩散。
---
via: <http://www.tecmint.com/combine-partitions-into-one-in-linux-using-mhddfs/>
作者:[Avishek Kumar](http://www.tecmint.com/author/avishek/) 译者:[GOLinux](https://github.com/GOLinux) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,295 | 如何在 Linux 中整理磁盘碎片 | https://www.maketecheasier.com/defragment-linux/ | 2015-09-25T14:58:00 | [
"磁盘",
"碎片",
"文件系统"
] | https://linux.cn/article-6295-1.html | 
有一个神话是 linux 的磁盘从来不需要整理碎片。在大多数情况下这是真的,大多数因为是使用的是优秀的日志文件系统(ext3、4等等)来处理文件系统。然而,在一些特殊情况下,碎片仍旧会产生。如果正巧发生在你身上,解决方法很简单。
### 什么是磁盘碎片
文件系统会按块更新文件,如果这些块没有连成一整块而是分布在磁盘的各个角落中时,就会形成磁盘碎片。这对于 FAT 和 FAT32 文件系统而言是这样的。在 NTFS 中这种情况有所减轻,但在 Linux(extX)中却几乎不会发生。下面是原因:
在像 FAT 和 FAT32 这类文件系统中,文件紧挨着写入到磁盘中。文件之间没有空间来用于增长或者更新:

NTFS 中在文件之间保留了一些空间,因此有空间进行增长。但因块之间的空间是有限的,碎片也会随着时间出现。

Linux 的日志型文件系统采用了一个不同的方案。与文件相互挨着不同,每个文件分布在磁盘的各处,每个文件之间留下了大量的剩余空间。这就给文件更新和增长留下了很大的空间,碎片很少会发生。

此外,碎片一旦出现了,大多数 Linux 文件系统会尝试将文件和块重新连续起来。
### Linux 中的磁盘整理
除非你用的是一个很小的硬盘或者空间不够了,不然 Linux 很少会需要磁盘整理。一些可能需要磁盘整理的情况包括:
* 如果你编辑的是大型视频文件或者 RAW 照片,但磁盘空间有限
* 如果你使用一个老式硬件,如旧笔记本,你的硬盘会很小
* 如果你的磁盘开始满了(大约使用了85%)
* 如果你的家目录中有许多小分区
最好的解决方案是购买一个大硬盘。如果不可能,磁盘碎片整理就很有用了。
### 如何检查碎片
`fsck` 命令会为你做这个,换句话说,如果你可以在 LiveCD 中运行它,那么就可以用于**所有卸载的分区**。
这一点很重要:**在已经挂载的分区中运行 fsck 将会严重危害到你的数据和磁盘**。
你已经被警告过了。开始之前,先做一个完整的备份。
**免责声明**: 本文的作者与本站将不会对您的文件、数据、系统或者其他损害负责。你需要自己承担风险。如果你继续,你需要接受并了解这点。
你应该启动到一个 live 会话中(如使用安装磁盘,系统救援CD等)并在你**卸载**的分区上运行 `fsck` 。要检查是否有任何问题,请在使用 root 权限运行下面的命令:
```
fsck -fn [/path/to/your/partition]
```
您可以运行以下命令找到分区的路径
```
sudo fdisk -l
```
有一个在已挂载的分区中运行 `fsck`(相对)安全的方法是使用`-n`开关。这会对分区进行只读文件系统检查,而不会写入任何东西。当然,这并不能保证十分安全,你应该在创建备份之后进行。在 ext3 中,运行
```
sudo fsck.ext3 -fn /path/to/your/partition
```
这会产生大量的输出,大多数错误信息的原因是分区已经挂载了。最后会给出一个碎片相关的信息。

如果碎片率大于 20% 了,那么你应该开始整理你的磁盘碎片了。
### 如何简单地在 Linux 中整理碎片
你要做的是备份你**所有**的文件和数据到另外一块硬盘中(手动**复制**他们),格式化分区,然后重新复制回去(不要使用备份软件)。日志型文件系统会把它们作为新的文件,并将它们整齐地放置到磁盘中而不产生碎片。
要备份你的文件,运行
```
cp -afv [/path/to/source/partition]/* [/path/to/destination/folder]
```
记住星号(\*)是很重要的。
注意:通常认为复制大文件或者大量文件,使用 `dd` 或许是最好的。这是一个非常底层的操作,它会复制一切,包含空闲的空间甚至是留下的垃圾。这不是我们想要的,因此这里最好使用 `cp`。
现在你只需要删除源文件。
```
sudo rm -rf [/path/to/source/partition]/*
```
**可选**:你可以使用如下命令将空闲空间用零填充。也可以用格式化来达到这点,但是如果你并没有复制整个分区而仅仅是复制大文件(它通常会形成碎片)的话,就不应该使用格式化的方法了。
```
sudo dd if=/dev/zero of=[/path/to/source/partition]/temp-zero.txt
```
等待它结束。你可以用 `pv` 来监测进度。
```
sudo apt-get install pv
sudo pv -tpreb | of=[/path/to/source/partition]/temp-zero.txt
```

这就完成了,只要删除这个用于填充的临时文件就行。
```
sudo rm [/path/to/source/partition]/temp-zero.txt
```
待你清零了空闲空间(或者跳过了这步)。重新复制回文件,将第一个`cp`命令翻转一下:
```
cp -afv [/path/to/original/destination/folder]/* [/path/to/original/source/partition]
```
### 使用 e4defrag
如果你想要简单的方法,安装 `e2fsprogs`,
```
sudo apt-get install e2fsprogs
```
用 root 权限在分区中运行 `e4defrag`。如果你不想或不能卸载该分区,你可以使用它的挂载点而不是路径。要整理整个系统的碎片,运行:
```
sudo e4defrag /
```
在挂载的情况下不保证成功(你也应该在它运行时不要使用你的系统),但是它比复制全部文件再重新复制回来简单多了。
### 总结
linux 系统中由于它的日志型文件系统有效的数据处理很少会出现碎片。如果你因任何原因产生了碎片,简单的方法是重新分配你的磁盘,如复制出去所有文件并复制回来,或者使用`e4defrag`。然而重要的是保证你数据的安全,因此在进行任何可能影响你全部或者大多数文件的操作之前,确保你的文件已经被备份到了另外一个安全的地方去了。
---
via: <https://www.maketecheasier.com/defragment-linux/>
作者:[Attila Orosz](https://www.maketecheasier.com/author/attilaorosz/) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 200 | OK | There is a common myth that Linux disks never need defragmentation at all. In most cases, this is true, due mostly to the excellent journaling filesystems Linux uses (ext2, 3, 4, btrfs, etc.) to handle the filesystem. However, in some specific cases, fragmentation might still occur. If that happens to you, the solution is fortunately very simple.
## What is fragmentation?
Fragmentation occurs when a file system updates files in little chunks, but these chunks do not form a contiguous whole and are scattered around the disk instead. This is particularly true for FAT and FAT32 filesystems. It was somewhat mitigated in NTFS and almost never happens in Linux (extX). Here is why.
In filesystems such as FAT and FAT32, files are written right next to each other on the disk. There is no room left for file growth or updates:
The NTFS leaves somewhat more room between the files, so there is room to grow. As the space between chunks is limited, fragmentation will still occur over time.
Linux’s journaling filesystems take a different approach. Instead of placing files beside each other, each file is scattered all over the disk, leaving generous amounts of free space between each file. There is sufficient room for file updates/growth and fragmentation rarely occurs.
Additionally, if fragmentation does happen, most Linux filesystems would attempt to shuffle files and chunks around to make them contiguous again.
## Disk fragmentation on Linux
Disk fragmentation seldom occurs in Linux unless you have a small hard drive, or it is running out of space. Some possible fragmentation cases include:
- if you edit large video files or raw image files, and disk space is limited
- if you use older hardware like an old laptop, and you have a small hard drive
- if your hard drives start filling up (above 85% used)
- if you have many small partitions cluttering your home folder
The best solution is to buy a larger hard drive. If it’s not possible, this is where defragmentation becomes useful.
## How to check for fragmentation
The `fsck`
command will do this for you – that is, if you have an opportunity to run it from a live CD, with **all affected partitions unmounted.**
This is very important: **RUNNING FSCK ON A MOUNTED PARTITION CAN AND WILL SEVERELY DAMAGE YOUR DATA AND YOUR DISK.**
You have been warned. Before proceeding, make a full system backup.
**Disclaimer**: The author of this article and Make Tech Easier take no responsibility for any damage to your files, data, system, or any other damage, caused by your actions after following this advice. You may proceed at your own risk. If you do proceed, you accept and acknowledge this.
You should just boot into a live session (like an installer disk, system rescue CD, etc.) and run `fsck`
on your **UNMOUNTED** partitions. To check for any problems, run the following command with root permission:
fsck -fn [/path/to/your/partition]
You can check what the `[/path/to/your/partition]`
is by running
sudo fdisk -l
There is a way to run `fsck`
(relatively) safely on a mounted partition – that is by using the `-n`
switch. This will result in a read only file system check without touching anything. Of course, there is no guarantee of safety here, and you should only proceed after creating a backup. On an ext2 filesystem, running
sudo fsck.ext2 -fn /path/to/your/partition
would result in plenty of output – most of them error messages resulting from the fact that the partition is mounted. In the end it will give you fragmentation related information.
If your fragmentation is above 20%, you should proceed to defragment your system.
## How to easily defragment Linux filesystems
All you need to do is to back up **ALL** your files and data to another drive (by manually **copying** them over), format the partition, and copy your files back (don’t use a backup program for this). The journalling file system will handle them as new files and place them neatly to the disk without fragmentation.
To back up your files, run
cp -afv [/path/to/source/partition]/* [/path/to/destination/folder]
Mind the asterix (*); it is important.
**Note**: It is generally agreed that to copy large files or large amounts of data, the `dd`
command might be best. This is a very low level operation and does copy everything “as is”, including the empty space, and even the junk left over. This is not what we want, so it is probably better to use `cp`
.
Now you only need to remove all the original files.
sudo rm -rf [/path/to/source/partition]/*
**Optional:** you can fill the empty space with zeros. You could achieve this with formatting as well, but if for example you did not copy the whole partition, only large files (which are most likely to cause fragmentation), this might not be an option.
sudo dd if=/dev/zero of=[/path/to/source/partition]/temp-zero.txt
Wait for it to finish. You could also monitor the progress with `pv.`
sudo apt-get install pv sudo pv -tpreb | of=[/path/to/source/partition]/temp-zero.txt
When it is done, just delete the temporary file.
sudo rm [/path/to/source/partition]/temp-zero.txt
After you zeroed out the empty space (or just skipped that step entirely), copy your files back, reversing the first `cp`
command:
cp -afv [/path/to/original/destination/folder]/* [/path/to/original/source/partition]
## Using e4defrag
If you prefer a simpler approach, install `e2fsprogs,`
sudo apt-get install e2fsprogs
and run `e4defrag`
as root on the affected partition. If you don’t want to or cannot unmount the partition, you can use its mount point instead of its path. To defragment your whole system, run
sudo e4defrag /
It is not guaranteed to succeed while mounted (you should also stop using your system while it is running), but it is much easier than copying all files away and back.
## Conclusion
Fragmentation should rarely be an issue on a Linux system due to the the journalling filesystem’s efficient data handling. If you do run into fragmentation due to any circumstances, there are simple ways to reallocate your disk space like copying all files away and back or using `e4defrag`
. It is important, however, to keep your data safe, so before attempting any operation that would affect all or most of your files, make sure you make a backup just to be on the safe side.
Our latest tutorials delivered straight to your inbox |
6,299 | 如何在 Ubuntu 中安装 QGit 客户端 | http://linoxide.com/ubuntu-how-to/install-qgit-viewer-ubuntu-14-04/ | 2015-09-26T08:54:23 | [
"git",
"qgit"
] | /article-6299-1.html | QGit是一款由Marco Costalba用Qt和C++写的开源的图形界面 Git 客户端。它是一款可以在图形界面环境下更好地提供浏览版本历史、查看提交记录和文件补丁的客户端。它利用git命令行来执行并显示输出。它有一些常规的功能像浏览版本历史、比较、文件历史、文件标注、归档树。我们可以格式化并用选中的提交应用补丁,在两个或多个实例之间拖拽并提交等等。它允许我们用它内置的生成器来创建自定义的按钮去执行特定的命令。
这里有简单的几步在Ubuntu 14.04 LTS "Trusty"中编译并安装QGit客户端。
### 1. 安装 QT4 库
首先在ubuntu中运行QGit需要先安装QT4库。由于apt是ubuntu默认的包管理器,同时qt4也在官方的仓库中,因此我们直接用下面的apt-get命令来安装qt4。
```
$ sudo apt-get install qt4-default
```
### 2. 下载QGit压缩包
安装完Qt4之后,我们要安装git,这样我们才能在QGit中克隆git仓库。运行下面的apt-get命令。
```
$ sudo apt-get install git
```
现在,我们要使用下面的git命令来克隆QGit客户端的仓库。
```
$ git clone git://repo.or.cz/qgit4/redivivus.git
Cloning into 'redivivus'...
remote: Counting objects: 7128, done.
remote: Compressing objects: 100% (2671/2671), done.
remote: Total 7128 (delta 5464), reused 5711 (delta 4438)
Receiving objects: 100% (7128/7128), 2.39 MiB | 470.00 KiB/s, done.
Resolving deltas: 100% (5464/5464), done.
Checking connectivity... done.
```
### 3. 编译 QGit
克隆之后,我们现在进入redivivus的目录,并创建我们编译需要的makefile文件。进入目录,运行下面的命令。
```
$ cd redivivus
```
接下来,我们运行下面的命令从qmake项目文件(qgit.pro)来生成新的Makefile。
```
$ qmake qgit.pro
```
生成Makefile之后,我们现在终于可以编译qgit的源代码并生成二进制。首先我们要安装make和g++包用于编译,因为这是一个用C++写的程序。
```
$ sudo apt-get install make g++
```
现在,我们要用make命令来编译代码了。
```
$ make
```
### 4. 安装 QGit
成功编译QGit的源码之后,我们就要在Ubuntu 14.04中安装它了,这样就可以在系统中执行它。因此我们将运行下面的命令。
```
$ sudo make install
cd src/ && make -f Makefile install
make[1]: Entering directory `/home/arun/redivivus/src'
make -f Makefile.Release install
make[2]: Entering directory `/home/arun/redivivus/src'
install -m 755 -p "../bin/qgit" "/usr/lib/x86_64-linux-gnu/qt4/bin/qgit"
strip "/usr/lib/x86_64-linux-gnu/qt4/bin/qgit"
make[2]: Leaving directory `/home/arun/redivivus/src'
make[1]: Leaving directory `/home/arun/redivivus/src'
```
接下来,我们需要从bin目录下复制qgit的二进制文件到/usr/bin/,这样我们就可以全局运行它了。
```
$ sudo cp bin/qgit /usr/bin/
```
### 5. 创建桌面文件
既然我们已经在ubuntu中成功安装了qgit,我们来创建一个桌面文件,这样QGit就可以在我们桌面环境中的菜单或者启动器中找到了。要做到这点,我们要在/usr/share/applications/创建一个新文件叫qgit.desktop。
```
$ sudo nano /usr/share/applications/qgit.desktop
```
接下来复制下面的行到文件中。
```
[Desktop Entry]
Name=qgit
GenericName=git 图形界面 viewer
Exec=qgit
Icon=qgit
Type=Application
Comment=git 图形界面 viewer
Terminal=false
MimeType=inode/directory;
Categories=Qt;Development;RevisionControl;
```
完成之后,保存并退出。
### 6. 运行 QGit 客户端
QGit安装完成之后,我们现在就可以从任何启动器或者程序菜单中启动它了。要在终端下面运行QGit,我们可以像下面那样。
```
$ qgit
```
这会打开基于Qt4框架图形界面模式的QGit。

### 总结
QGit是一个很棒的基于QT的git客户端。它可以在Linux、MAC OSX和 Microsoft Windows所有这三个平台中运行。它帮助我们很容易地浏览历史、版本、分支等等git仓库提供的信息。它减少了使用命令行的方式去执行诸如浏览版本、历史、比较功能的需求,并用图形化的方式来简化了这些任务。最新的qgit版本也在默认仓库中,你可以使用 **apt-get install qgit** 命令来安装。因此,QGit用它简单的图形界面使得我们的工作更加简单和快速。
---
via: <http://linoxide.com/ubuntu-how-to/install-qgit-viewer-ubuntu-14-04/>
作者:[Arun Pyasi](http://linoxide.com/author/arunp/) 译者:[geekpi](https://github.com/geekpi) 校对:[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-qgit-viewer-ubuntu-14-04/ (Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7b8327582170>, 'Connection to linoxide.com timed out. (connect timeout=10)')) | null |
6,300 | RHCSA 系列(十): Yum 包管理、Cron 自动任务计划和监控系统日志 | http://www.tecmint.com/yum-package-management-cron-job-scheduling-monitoring-linux-logs/ | 2015-09-26T10:14:00 | [
"RHCSA"
] | https://linux.cn/article-6300-1.html | 在这篇文章中,我们将回顾如何在 RHEL7 中安装,更新和删除软件包。我们还将介绍如何使用 cron 进行任务自动化,并完成如何查找和监控系统日志文件,以及为什么这些技能是系统管理员必备技能。

*RHCSA: Yum包管理、任务计划和系统监控 – Part 10*
### 使用yum 管理包
要安装一个包以及所有尚未安装的依赖包,您可以使用:
```
# yum -y install package_name(s)
```
package\_name(s) 需要是至少一个真实的软件包名
例如,安装 httpd 和 mlocate(按顺序),输入。
```
# yum -y install httpd mlocate
```
**注意**: 字符 y 表示绕过执行下载和安装前的确认提示。如果需要提示,你可以不用它。
默认情况下,yum 将安装与操作系统体系结构相匹配的包,除非通过在包名加入架构名。
例如,在 64 位系统上,`yum install package`将安装包的 x86\_64 版本,而 `yum install package.x86`(如果有的话)将安装 32 位的。
有时,你想安装一个包,但不知道它的确切名称。`search all` 选项可以在当前启用的软件库中的包名称和包描述中搜索它,或者`search`选项可以在包名称中搜索。
比如,
```
# yum search log
```
将搜索安装的软件库中名字和摘要与该词(log)类似的软件,而
```
# yum search all log
```
也将在包描述和网址中寻找寻找相同的关键字。
一旦搜索返回包列表,您可能希望在安装前显示一些信息。这时 info 选项派上了用场:
```
# yum info logwatch
```

*搜索包信息*
您可以定期用以下命令检查更新:
```
# yum check-update
```
上述命令将返回可以更新的所有已安装的软件包。在下图所示的例子中,只有 rhel-7-server-rpms 有可用更新:

*检查包更新*
然后,您可以更新该包,
```
# yum update rhel-7-server-rpms
```
如果有几个包可以一同更新,可以使用 `yum update` 一次性更新所有的包。
当你知道一个可执行文件的名称,如 ps2pdf,但不知道那个包提供了它?你可以通过 `yum whatprovides “*/[executable]”`找到:
```
# yum whatprovides “*/ps2pdf”
```

*查找文件属于哪个包*
当删除包时,你可以使用 `yum remove Package` ,很简单吧?Yum 是一个完整而强大的包管理器。
```
# yum remove httpd
```
* 参见: [20 个管理 RHEL 7 软件包的 Yum 命令](http://www.tecmint.com/20-linux-yum-yellowdog-updater-modified-commands-for-package-mangement/)
### 文本式 RPM 工具
RPM(又名 RPM 包管理器,原意是 RedHat 软件包管理器)也可用于安装或更新独立的`rpm`格式的软件包。
往往使用 `-Uvh` 表明如果这个包没有安装就安装它,如果已存在就尝试更新。这里`-U`表示更新、`-v`表示显示详细输出,用`-h`显示进度条。例如
```
# rpm -Uvh package.rpm
```
rpm 的另一个典型的使用方法是列出所有安装的软件包,
```
# rpm -qa
```

*查询所有包*
* 参见: [20 个管理 RHEL 7 软件包的 RPM 命令](http://www.tecmint.com/20-practical-examples-of-rpm-commands-in-linux/)
### 使用 Cron 调度任务
Linux 和 UNIX 类操作系统包括一个称为 Cron 的工具,允许你周期性调度任务(即命令或 shell 脚本)。cron 会每分钟定时检查 /var/spool/cron 目录中有在 /etc/passwd 帐户文件中指定用户名的文件。
执行命令时,命令输出是发送到该 crontab 的所有者(或者可以在 /etc/crontab,通过 MAILTO 环境变量中指定用户)。
crontab 文件(可以通过键入 `crontab -e`并按 Enter 键创建)的格式如下:

*crontab条目*
因此,如果我们想在每个月第二天上午2:15更新本地文件数据库(用于按名字或通配模式定位文件),我们需要添加以下 crontab 条目:
```
15 02 2 * * /bin/updatedb
```
以上的条目的意思是:”每年每月第二天的凌晨 2:15 运行 /bin/updatedb,无论是周几”,我想你也猜到了。星号作为通配符。
正如我们前面所提到的,添加一个 cron 任务后,你可以看到一个名为 root 的文件被添加在 /var/spool/cron。该文件列出了所有的 crond 守护进程应该运行的任务:
```
# ls -l /var/spool/cron
```

*检查所有cron任务*
在上图中,显示当前用户的 crontab 可以使用 `cat /var/spool/cron` 或
```
# crontab -l
```
如果你需要在一个更精细的时间上运行的任务(例如,一天两次或每月三次),cron 也可以做到。
例如,每个月1号和15号运行 /my/script 并将输出导出到 /dev/null (丢弃输出),您可以添加如下两个crontab 条目:
```
01 00 1 * * /myscript > /dev/null 2>&1
01 00 15 * * /my/script > /dev/null 2>&1
```
不过为了简单,你可以将他们合并:
```
01 00 1,15 * * /my/script > /dev/null 2>&1
```
跟着前面的例子,我们可以在每三个月的第一天的凌晨1:30运行 /my/other/script。
```
30 01 1 1,4,7,10 * /my/other/script > /dev/null 2>&1
```
但是当你必须每隔某分钟、小时、天或月来重复某个任务时,你可以通过所需的频率来划分正确的时间。以下与前一个 crontab 条目具有相同的意义:
```
30 01 1 */3 * /my/other/script > /dev/null 2>&1
```
或者也许你需要在一个固定的频率或系统启动后运行某个固定的工作,你可以使用下列五个字符串中的一个字符串来指示你想让你的任务计划工作的确切时间:
```
@reboot 仅系统启动时运行
@yearly 一年一次, 类似与 00 00 1 1 *
@monthly 一月一次, 类似与 00 00 1 * *
@weekly 一周一次, 类似与 00 00 * * 0
@daily 一天一次, 类似与 00 00 * * *
@hourly 一小时一次, 类似与 00 * * * *
```
* 参见:[11 个在 RHEL7 中调度任务的命令](http://www.tecmint.com/11-cron-scheduling-task-examples-in-linux/)
### 定位和查看日志
系统日志存放(并轮转)在 /var/log 目录。根据 Linux 的文件系统层次标准(Linux Filesystem Hierarchy Standard),这个目录包括各种日志文件,并包含一些必要的子目录(如 audit、 httpd 或 samba ,如下图),并由相应的系统守护进程操作:
```
# ls /var/log
```

*Linux 日志的位置*
其他感兴趣的日志比如 [dmesg](http://www.tecmint.com/dmesg-commands/)(包括了所有内核层缓冲区的消息),secure(记录要求用户认证的连接请求),messages(系统级信息),和 wtmp(记录了所有用户的登录、登出)。
日志是非常重要的,它们让你可以看到任何时刻发生在你的系统的事情,以及已经过去的事情。他们是无价的工具,可以排错和监测一个 Linux 服务器,通常使用 `tail -f` 命令来实时显示正在发生和写入日志的事件。
举个例子,如果你想看你的内核相关的日志,你需要输入如下命令:
```
# tail -f /var/log/dmesg
```
同样的,如果你想查看你的 Web 服务器日志,你需要输入如下命令:
```
# tail -f /var/log/httpd/access.log
```
### 总结
如果你知道如何有效的管理包、调度任务、以及知道在哪寻找系统当前和过去操作的信息,你可以放松工作而不会总被吓到。我希望这篇文章能够帮你学习或回顾这些基础知识。
如果你有任何问题或意见,请使用下面的表单反馈给我们。
---
via: <http://www.tecmint.com/yum-package-management-cron-job-scheduling-monitoring-linux-logs/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[xiqingongzi](https://github.com/xiqingongzi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,301 | Linux 中 10 个有用的命令行补全例子 | http://www.thegeekstuff.com/2013/12/bash-completion-complete/ | 2015-09-26T15:56:51 | [
"补全",
"bash",
"命令行"
] | https://linux.cn/article-6301-1.html | 在 Linux 系统中,当你输入一个命令,再按两次 `TAB` 键,就会列出所有以你输入字符开头的可用命令。这并不新鲜,可能你已经知道了。这个功能被称作<ruby> 命令行补全 <rt> bash completion </rt></ruby>。默认情况下,bash 命令行可以自动补全文件或目录名称。不过,我们可以增强 bash 命令补全功能,通过 `complete` 命令让它达到新的高度。

这个教程说明了我们是怎样使用<ruby> 可编程的命令行补全功能 <rp> ( </rp> <rt> programmable completion </rt> <rp> ) </rp></ruby>把自动补全功能应用于选项或者命令行参数。
例如:在输入 `write` 命令之后,如果你按两次 `TAB` 按键,自动补全功能会提供可供执行 `write` 操作的用户列表。
```
$ write [TAB][TAB]
bala raj
jason randy
john ritu
mayla thomas
nisha www-data
```
在下面的例子中,可以为 `telnet` 命令显示可用的主机名:
```
$ telnet [TAB][TAB]
localhost dev-db fileserver
```
要让可编程命令补全功能在你的终端起作用 ,你只需要如下执行`/etc/bash_completion`即可:
```
# . /etc/bash_completion
```
你也可以取消`/etc/bash.bashrc`(来自 Ubuntu Linux 13.04 系统)中如下的注释,这样,你就可以不需要执行上面的命令了:
```
### enable bash completion in interactive shells
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
```
如果你没有发现这些代码,也没有找到`/etc/bash_completion`文件,那么你只需要通过使用`apt-get`命令来安装bash\_completion 包即可。
### 1. 查看已有的命令行补全
在启用可编程的命令行补全功能后,就已经有了一些定义好的命令补全功能。`complete` 命令用于定义命令行补全。
要查看已有的命令行补全,如下使用 `complete` 命令:
```
complete -p | less
```
上面例子中的 -p 选项是可选的。
### 2. 列出 bash 中标准补全功能
默认情况下,Bash 为 Linux 用户提供了下列标准补全功能。
1. 变量补全
2. 用户名补全
3. 主机名补全
4. 路径补全
5. 文件名补全
我们在之前的 [bash 标准补全](http://www.thegeekstuff.com/2013/11/bash-standard-completion/)中讨论过这些。
### 3. 定义一个命令名补全
通过 -c 选项可以将所有的可用命令作为一个命令的补全参数。在下面的例子里面,为 `which` 命令定义了一个补全(LCTT译注:在按两下 `TAB` 时,可以列出所有命令名作为可补全的参数)。
```
$ complete -c which
$ which [TAB][TAB]
Display all 2116 possibilities? (y or n)
```
如上,如果按下 ‘y’,就会列出所有的命令名。
### 4. 定义一个目录补全
通过选项 -d,可以定义一个仅包含目录名的补全参数。在下面的例子中,为 `ls` 命令定义了补全。
```
$ ls
countfiles.sh dir1/ dir2/ dir3/
$ complete -d ls
$ ls [TAB][TAB]
dir1/ dir2/ dir3/
```
如上,连按下 `TAB` 仅会显示目录名。
### 5. 定义一个后台任务名补全
补全功能也能够以任务名作为补全参数。选项 -j 可以定义任务名作为传递给命令的参数,如下:
```
$ jobs
[1]- Stopped cat
[2]+ Stopped sed 'p'
$ complete -j ./list_job_attrib.sh
$ ./list_job_attrib.sh [TAB][TAB]
cat sed
```
关于后台任务,你可以参考 [Linux 后台任务](http://www.thegeekstuff.com/2010/05/unix-background-job/)中的例子了解如何管理后台任务。
### 6. 带有前缀和后缀的补全
补全功能可以为实际的补全内容定义前缀和后缀。在下面的例子中,为 list\_job\_attrib.sh 定义了补全内容的前缀和后缀。
```
$ jobs
[1]+ Stopped cat
$ complete -P '">' -S '<"' ./list_job_attrib.sh
$ ./list_job_attrib.sh [TAB][TAB]
$ ./list_job_attrib.sh ">cat<"
```
### 7. 带有排除的文件名和目录名补全
假如脚本运行完成后,输出目录如下:
```
$ cd output/
$ ls
all_calls.txt incoming_calls.txt outgoing_calls.txt missed_calls.txt
parser_mod.tmp extract.o
```
如上,如果你想要 `ls` 命令的补全忽略 .tmp 和 .o 文件:
```
$ export FIGNORE='.tmp:.o'
$ complete -f -d ls
$ cd output
$ ls [TAB][TAB]
all_calls.txt incoming_calls.txt outgoing_calls.txt missed_calls.txt
```
`FIGNORE` 是一个环境变量,它包含了自动补全所需要排除的文件名后缀。
### 8. 通过 IFS 变量分割字符串得到补全值
可以通过 -W 选项定义补全值列表,然后通过 `IFS` 环境变量进行切分。切分结果会展开变量并作为补全显示。
```
$ export IFS=" "
$ complete -W "bubble quick" ./sort_numbers.sh
$ ./sort_numbers.sh [TAB][TAB]
bubble quick
```
如上所述,字符串通过 `IFS` 分隔符进行切分后,内嵌的变量会被展开为变量值,所以可以如下使用变量:
```
$ echo $SORT_TYPE1
bubble
$ echo $SORT_TYPE2
quick
$ complete -W "$SORT_TYPE1 $SORT_TYPE2" ./sort_numbers.sh
$ ./sort_numbers.sh [TAB][TAB]
bubble quick
```
### 9. 写个函数来生成补全
你可以引入一个函数来定义补全。使用 -F 选项将函数名传给 `complete` 命令,执行函数生成补全内容。例如,函数如下:
```
_parser_options()
{
local curr_arg;
curr_arg=${COMP_WORDS[COMP_CWORD]}
COMPREPLY=( $(compgen -W '-i --incoming -o --outgoing -m --missed' -- $curr_arg ) );
}
```
在上述函数中:
1. COMPREPLY : 该数组控制连按下 `TAB` 后显示的结果
2. COMP\_WORDS : 该数组包含命令行输入的单词
3. COMP\_CWORD : COMP\_WORDS 数组的索引,使用它来区分命令行可以访问的单词位置
4. compgen : -W 基于 $current\_arg 提供可能的补全及其参数
该函数放在 parser\_option 文件中,并通过 `source` 命令引入:
```
$ source parser_option
```
将该函数和你的 parser.pl 脚本关联起来:
```
$ complete -F _parser_options ./parser.pl
$ ./parser.pl [TAB][TAB]
-i --incoming -o --outgoing -m --missed
```
如上,parser.pl 的选项是由函数 \_parser\_options() 生成的。
提示: 查看`/etc/bash_completion` 来了解更多的可编程补全函数。
### 10. 当第一个规则没有生成结果时,就使用第二个
如果定义的补全规则没有生成匹配时,可以使用 -o 选项生成补全。
```
$ complete -F _count_files -o dirnames ./countfiles.sh
```
如上,为 ./countfiles.sh 定义了 \_count\_files 补全函数。 如果 the \_count\_files() 函数没有生成任何匹配的话,就会触发目录补全。
```
$ ls
countfiles.sh dir1/ dir2/ dir3/
$./countfiles.sh [TAB][TAB]
dir1 dir2 dir3
```
| 301 | Moved Permanently | null |
6,305 | 如何在 Arch Linux 中安装 DNSCrypt 和 Unbound | http://blog.linoxide.com/wp-content/uploads/2015/08/UnboundTest.png | 2015-09-27T23:08:47 | [
"DNS",
"DNSCrypt",
"Unbound"
] | /article-6305-1.html | **DNSCrypt** 是一个用于对 DNS 客户端和 DNS 解析器之间通信进行加密和验证的协议。它可以阻止 DNS 欺骗或中间人攻击。 DNSCrypt 可用于大多数的操作系统,包括 Linux,Windows,MacOSX ,Android 和 iOS。而在本教程中我使用的是内核为4.1的 archlinux。
**Unbound** 是用来解析收到的任意 DNS 查询的 DNS 缓存服务器。如果用户请求一个新的查询,unbound 会将其存储到缓存中,并且当用户再次请求相同的请求时,unbound 将采用已经保存的缓存。这将比第一次请求查询更快。
现在我将尝试安装“DNSCrypt”,以确保 DNS 的通信的安全,并用“Unbound”加速。

### 第一步 - 安装 yaourt
Yaourt 是AUR(ARCH 用户仓库)的辅助工具之一,它可以使用户能够很容易地从 AUR 安装程序。 Yaourt 和 pacman 使用相同的语法,你可以使用 yaourt 安装该程序。下面是安装 yaourt 的简单方法:
1、 用 nano 或者 vi 编辑 arch 仓库配置文件,存放在“/etc/pacman.conf”中。
```
$ nano /etc/pacman.conf
```
2、 在 yaourt 仓库底部添加,粘贴下面的脚本:
```
[archlinuxfr]
SigLevel = Never
Server = http://repo.archlinux.fr/$arch
```
3、 用“Ctrl + x”,接着用“Y”保存。
4、 接着升级仓库数据库并用pacman安装yaourt:
```
$ sudo pacman -Sy yaourt
```
### 第二步 - 安装 DNSCrypt 和 Unbound
DNSCrypt 和 unbound 就在 archlinux 仓库中,你可以用下面的 pacman 命令安装:
```
$ sudo pacman -S dnscrypt-proxy unbound
```
接着在安装的过程中按下“Y”。
### 第三步 - 安装 dnscrypt-autoinstall
Dnscrypt-autoinstall 是一个在基于 Linux 的系统上自动安装和配置 DNSCrypt 的脚本。DNSCrypt 在 AUR 中,因此你必须使用“yaourt”命令来安装它。
```
$ yaourt -S dnscrypt-autoinstall
```
注意 :
-S = 这和 pacman -S 安装程序一样。
### 第四步 - 运行 dnscrypt-autoinstall
用 root 权限运行“dnscrypt-autoinstall”来自动配置 DNSCrypt。
```
$ sudo dnscrypt-autoinstall
```
下一步中按下“回车”,接着输入"Y"来选择你想使用的 DNS 提供者,我这里使用不带日志和 DNSSEC 的 DNSCrypt.eu。

### 第五步 - 配置 DNSCrypt 和 Unbound
1、 打开 dnscrypt 的“/etc/conf.d/dnscrypt-config” ,确认配置文件中“DNSCRYPT*LOCALIP”指向**本地ip**,“DNSCRYPT*LOCALPORT”根据你本人的意愿配置,我是用的是**40**端口。
```
$ nano /etc/conf.d/dnscrypt-config
DNSCRYPT_LOCALIP=127.0.0.1
DNSCRYPT_LOCALIP2=127.0.0.2
DNSCRYPT_LOCALPORT=40
```

保存并退出。
2、 现在你用 nano 编辑器编辑“/etc/unbound/”下 unbound 的配置文件:
```
$ nano /etc/unbound/unbound.conf
```
3、 在脚本最后添加下面的行:
```
do-not-query-localhost: no
forward-zone:
name: "."
forward-addr: 127.0.0.1@40
```
确保**forward-addr**和DNSCrypt中的“**DNSCRYPT\_LOCALPORT**”一致。如你所见,用的是**40**端口。

接着保存并退出。
### 第六步 - 运行 DNSCrypt 和 Unbound,接着添加到开机启动中
请用 root 权限运行 DNSCrypt 和 unbound,你可以用 systemctl 命令来运行:
```
$ sudo systemctl start dnscrypt-proxy unbound
```
将服务添加到启动中。你可以运行“systemctl enable”:
```
$ sudo systemctl enable dnscrypt-proxy unbound
```
命令将会创建软链接到“/usr/lib/systemd/system/”目录的服务。
### 第七步 - 配置 resolv.conf 并重启所有服务
resolv.conf 是一个在 linux 中用于配置 DNS 解析器的文件。它是一个由管理员创建的纯文本,因此你必须用 root 权限编辑并让它不能被其他人修改。
用 nano 编辑器编辑:
```
$ nano /etc/resolv.conf
```
并添加本地IP “**127.0.0.1**”。现在用“chattr”命令使他只读:
```
$ chattr +i /etc/resolv.conf
```
注意:
如果你想要重新编辑,用“chattr -i /etc/resolv.conf”加入写权限。
现在你需要重启 DNSCrypt 和 unbound 和网络;
```
$ sudo systemctl restart dnscrypt-proxy unbound netctl
```
如果你看到错误,检查配置文件。
### 测试
1、 测试 DNSCrypt
你可以通过 <https://dnsleaktest.com/> 来确认 DNSCrypt,点击“标准测试”或者“扩展测试”,然后等待程序运行结束。
现在你可以看到 DNSCrypt.eu 就已经与作为 DNS 提供商的 DNSCrypt 协同工作了。

2、 测试 Unbound
现在你应该确保 unbound 可以正确地与“dig”和“drill”命令一起工作。
这是 dig 命令的结果:
```
$ dig linoxide.com
```
我们现在看下结果,“Query time”是“533 msec”:
```
;; Query time: 533 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sun Aug 30 14:48:19 WIB 2015
;; MSG SIZE rcvd: 188
```
再次输入命令,我们看到“Query time”是“0 msec”。
```
;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Sun Aug 30 14:51:05 WIB 2015
;; MSG SIZE rcvd: 188
```

DNSCrypt 对 DNS 客户端和解析端之间的通讯加密做的很好,并且 Unbound 通过缓存让相同的请求在另一次请求同速度更快。
### 总结
DNSCrypt 是一个可以加密 DNS 客户端和 DNS 解析器之间的数据流的协议。 DNSCrypt 可以在不同的操作系统上运行,无论是移动端或桌面端。选择 DNS 提供商还包括一些重要的事情,应选择那些提供 DNSSEC 同时没有日志的。Unbound 可被用作 DNS 缓存,从而加快解析过程,因为 Unbound 将请求缓存,那么接下来客户端请求相同的查询时,unbound 将从缓存中取出保存的值。 DNSCrypt 和 Unbound 是针对安全性和速度的一个强大的组合。
---
via: <http://linoxide.com/tools/install-dnscrypt-unbound-archlinux/>
作者:[Arul](http://linoxide.com/author/arulm/) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='blog.linoxide.com', port=80): Max retries exceeded with url: /wp-content/uploads/2015/08/UnboundTest.png (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7b8327582290>: Failed to resolve 'blog.linoxide.com' ([Errno -2] Name or service not known)")) | null |
6,307 | Linux 有问必答:如何知道进程运行在哪个 CPU 内核上? | http://ask.xmodulo.com/cpu-core-process-is-running.html | 2015-09-28T10:43:56 | [
"CPU",
"内核",
"进程"
] | /article-6307-1.html |
>
> 问题:我有个 Linux 进程运行在多核处理器系统上。怎样才能找出哪个 CPU 内核正在运行该进程?
>
>
>

当你在 [多核 NUMA 处理器上](http://xmodulo.com/identify-cpu-processor-architecture-linux.html)运行需要较高性能的 HPC(高性能计算)程序或非常消耗网络资源的程序时,CPU/memory 的亲和力是限度其发挥最大性能的重要因素之一。在同一 NUMA 节点上调度最相关的进程可以减少缓慢的远程内存访问。像英特尔 Sandy Bridge 处理器,该处理器有一个集成的 PCIe 控制器,你可以在同一 NUMA 节点上调度网络 I/O 负载(如网卡)来突破 PCI 到 CPU 亲和力限制。
作为性能优化和故障排除的一部分,你可能想知道特定的进程被调度到哪个 CPU 内核(或 NUMA 节点)上运行。
这里有几种方法可以 **找出哪个 CPU 内核被调度来运行给定的 Linux 进程或线程**。
### 方法一
如果一个进程使用 [taskset](http://xmodulo.com/run-program-process-specific-cpu-cores-linux.html) 命令明确的被固定(pinned)到 CPU 的特定内核上,你可以使用 taskset 命令找出被固定的 CPU 内核:
```
$ taskset -c -p <pid>
```
例如, 如果你对 PID 5357 这个进程有兴趣:
```
$ taskset -c -p 5357
pid 5357's current affinity list: 5
```
输出显示这个过程被固定在 CPU 内核 5上。
但是,如果你没有明确固定进程到任何 CPU 内核,你会得到类似下面的亲和力列表。
```
pid 5357's current affinity list: 0-11
```
输出表明该进程可能会被安排在从0到11中的任何一个 CPU 内核。在这种情况下,taskset 不能识别该进程当前被分配给哪个 CPU 内核,你应该使用如下所述的方法。
### 方法二
ps 命令可以告诉你每个进程/线程目前分配到的 (在“PSR”列)CPU ID。
```
$ ps -o pid,psr,comm -p <pid>
PID PSR COMMAND
5357 10 prog
```
输出表示进程的 PID 为 5357(名为"prog")目前在CPU 内核 10 上运行着。如果该过程没有被固定,PSR 列会根据内核可能调度该进程到不同内核而改变显示。
### 方法三
top 命令也可以显示 CPU 被分配给哪个进程。首先,在top 命令中使用“P”选项。然后按“f”键,显示中会出现 "Last used CPU" 列。目前使用的 CPU 内核将出现在 “P”(或“PSR”)列下。
```
$ top -p 5357
```

相比于 ps 命令,使用 top 命令的好处是,你可以连续监视随着时间的改变, CPU 是如何分配的。
### 方法四
另一种来检查一个进程/线程当前使用的是哪个 CPU 内核的方法是使用 [htop 命令](/article-3141-1.html)。
从命令行启动 htop。按 键,进入"Columns",在"Available Columns"下会添加 PROCESSOR。
每个进程当前使用的 CPU ID 将出现在“CPU”列中。

请注意,所有以前使用的命令 taskset,ps 和 top 分配CPU 内核的 IDs 为 0,1,2,...,N-1。然而,htop 分配 CPU 内核 IDs 从 1开始(直到 N)。
---
via: <http://ask.xmodulo.com/cpu-core-process-is-running.html>
作者:[Dan Nanni](http://ask.xmodulo.com/author/nanni) 译者:[strugglingyouth](https://github.com/strugglingyouth) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| null | HTTPConnectionPool(host='ask.xmodulo.com', port=80): Max retries exceeded with url: /cpu-core-process-is-running.html (Caused by NameResolutionError("<urllib3.connection.HTTPConnection object at 0x7b8327581330>: Failed to resolve 'ask.xmodulo.com' ([Errno -2] Name or service not known)")) | null |
6,308 | 使用 tuptime 工具查看 Linux 服务器系统的开机时间的历史和统计 | http://www.cyberciti.biz/hardware/howto-see-historical-statistical-uptime-on-linux-server/ | 2015-09-28T11:00:00 | [
"开机",
"tuptime",
"uptime"
] | https://linux.cn/article-6308-1.html | 你可以使用下面的工具来查看 Linux 或类 Unix 系统运行了多长时间:
* uptime : 告诉你服务器运行了多长的时间。
* lastt : 显示重启和关机时间。
* tuptime : 报告系统的运行时间历史和运行时间统计,这是指重启之间的运行时间。和 uptime 命令类似,不过输出结果更有意思。
### 找出系统上次重启时间和日期
你[可以使用下面的命令来获取Linux操作系统的上次重启和关机时间及日期](http://www.cyberciti.biz/hardware/howto-see-historical-statistical-uptime-on-linux-server/)(在OSX/类Unix系统上也可以用):
```
### 显示系统重启和关机时间
who -b
last reboot
last shutdown
### 开机信息
uptime
cat /proc/uptime
awk '{ print "up " $1 /60 " minutes"}' /proc/uptime
w
```
**样例输出:**

*图01:用于找出服务器开机时间的多个Linux命令*
### 跟 tuptime 问打个招呼吧
tuptime 命令行工具可以报告基于 Linux 的系统上的下列信息:
1. 系统启动次数统计
2. 注册首次启动时间(也就是安装时间)
3. 正常关机和意外关机统计
4. 平均开机时间和故障停机时间
5. 当前开机时间
6. 首次启动以来的开机和故障停机率
7. 累积系统开机时间、故障停机时间和合计
8. 报告每次启动、开机时间、关机和故障停机时间
#### 安装
输入[下面的命令来克隆 git 仓库到 Linux 系统中](http://www.cyberciti.biz/faq/debian-ubunut-linux-download-a-git-repository/):
```
$ cd /tmp
$ git clone https://github.com/rfrail3/tuptime.git
$ ls
$ cd tuptime
$ ls
```
**样例输出:**

*图02:克隆git仓库*
确保你安装了带有 sys,optparse,os,re,string,sqlite3,datetime,disutils 和 locale 模块的 Python v2.7。
你可以像下面这样来安装:
```
$ sudo tuptime-install.sh
```
或者,可以手工安装(基于 systemd 或非 systemd ):
```
$ sudo cp /tmp/tuptime/latest/cron.d/tuptime /etc/cron.d/tuptime
```
如果系统是systemd的,拷贝服务文件并启用:
```
$ sudo cp /tmp/tuptime/latest/systemd/tuptime.service /lib/systemd/system/
$ sudo systemctl enable tuptime.service
```
如果系统不是systemd的,拷贝初始化文件:
```
$ sudo cp /tmp/tuptime/latest/init.d/tuptime.init.d-debian7 /etc/init.d/tuptime
$ sudo update-rc.d tuptime defaults
```
#### 运行
只需输入以下命令:
```
$ sudo tuptime
```
**样例输出:**

*图03:tuptime工作中*
在一次更新内核后,我重启了系统,然后再次输入了同样的命令:
```
$ sudo tuptime
System startups: 2 since 03:52:16 PM 08/21/2015
System shutdowns: 1 ok - 0 bad
Average uptime: 7 days, 16 hours, 48 minutes and 3 seconds
Average downtime: 2 hours, 30 minutes and 5 seconds
Current uptime: 5 minutes and 28 seconds since 06:23:06 AM 09/06/2015
Uptime rate: 98.66 %
Downtime rate: 1.34 %
System uptime: 15 days, 9 hours, 36 minutes and 7 seconds
System downtime: 5 hours, 0 minutes and 11 seconds
System life: 15 days, 14 hours, 36 minutes and 18 seconds
```
你可以像下面这样修改日期和时间格式:
```
$ sudo tuptime -d '%H:%M:%S %m-%d-%Y'
```
**样例输出:**
```
System startups: 1 since 15:52:16 08-21-2015
System shutdowns: 0 ok - 0 bad
Average uptime: 15 days, 9 hours, 21 minutes and 19 seconds
Average downtime: 0 seconds
Current uptime: 15 days, 9 hours, 21 minutes and 19 seconds since 15:52:16 08-21-2015
Uptime rate: 100.0 %
Downtime rate: 0.0 %
System uptime: 15 days, 9 hours, 21 minutes and 19 seconds
System downtime: 0 seconds
System life: 15 days, 9 hours, 21 minutes and 19 seconds
```
计算每次启动、开机时间、关机和故障停机时间:
```
$ sudo tuptime -e
```
**样例输出:**
```
Startup: 1 at 03:52:16 PM 08/21/2015
Uptime: 15 days, 9 hours, 22 minutes and 33 seconds
System startups: 1 since 03:52:16 PM 08/21/2015
System shutdowns: 0 ok - 0 bad
Average uptime: 15 days, 9 hours, 22 minutes and 33 seconds
Average downtime: 0 seconds
Current uptime: 15 days, 9 hours, 22 minutes and 33 seconds since 03:52:16 PM 08/21/2015
Uptime rate: 100.0 %
Downtime rate: 0.0 %
System uptime: 15 days, 9 hours, 22 minutes and 33 seconds
System downtime: 0 seconds
System life: 15 days, 9 hours, 22 minutes and 33 seconds
```
---
via: <http://www.cyberciti.biz/hardware/howto-see-historical-statistical-uptime-on-linux-server/>
作者:Vivek Gite 译者:[GOLinux](https://github.com/GOLinux) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
6,314 | 给新手的 10 个有用 Linux 命令行技巧 | http://www.tecmint.com/10-useful-linux-command-line-tricks-for-newbies/ | 2015-09-29T08:44:00 | [
"命令行"
] | https://linux.cn/article-6314-1.html | 我记得我第一次使用 Linux 的时候,我还习惯于 Windows 的图形界面,我真的很讨厌 Linux 终端。那时候我觉得命令难以记忆,不能正确使用它们。随着时间推移,我意识到了 Linux 终端的优美、灵活和可用性,说实话,我没有一天不使用它。今天,我很高兴和刚开始接触 Linux 的人一起来分享一些有用的技巧和提示,希望能帮助他们更好的向 Linux 过渡,并帮助他们学到一些新的东西(希望如此)。

*10 个 Linux 命令行技巧*
* [5 个有趣的 Linux 命令行技巧](/article-5485-1.html)
* [管理 Linux 文件类型的 5 个有用命令](http://www.tecmint.com/manage-file-types-and-set-system-time-in-linux/)
这篇文章希望向你展示一些不需要很高的技术就可以像一个高手一样使用 Linux 终端的有用技巧。你只需要一个 Linux 终端和一些自由时间来体会这些命令。
### 1. 找到正确的命令
执行正确的命令对你的系统来说非常重要。然而在 Linux 中有如此多的、难以记忆的各种的命令行。那么怎样才能找到你需要的正确命令呢?答案是 apropos。你只需要运行:
```
# apropos <description>
```
其中你要用真正描述你要查找的命令的语句代替 “description”。这里有一个例子:
```
# apropos "list directory"
dir (1) - list directory contents
ls (1) - list directory contents
ntfsls (8) - list directory contents on an NTFS filesystem
vdir (1) - list directory contents
```
左边你看到的是命令,右边是它们的描述。
### 2. 执行之前的命令
很多时候你需要一遍又一遍执行相同的命令。尽管你可以重复按你键盘上的向上光标键,但你也可以用 history 命令替代。这个命令会列出自从你上次启动终端以来所有输入过的命令:
```
# history
1 fdisk -l
2 apt-get install gnome-paint
3 hostname tecmint.com
4 hostnamectl tecmint.com
5 man hostnamectl
6 hostnamectl --set-hostname tecmint.com
7 hostnamectl -set-hostname tecmint.com
8 hostnamectl set-hostname tecmint.com
9 mount -t "ntfs" -o
10 fdisk -l
11 mount -t ntfs-3g /dev/sda5 /mnt
12 mount -t rw ntfs-3g /dev/sda5 /mnt
13 mount -t -rw ntfs-3g /dev/sda5 /mnt
14 mount -t ntfs-3g /dev/sda5 /mnt
15 mount man
16 man mount
17 mount -t -o ntfs-3g /dev/sda5 /mnt
18 mount -o ntfs-3g /dev/sda5 /mnt
19 mount -ro ntfs-3g /dev/sda5 /mnt
20 cd /mnt
...
```
正如你上面看到的,你会得到一个你运行过的命令的列表。每一行中有一个数字表示你在第几行输入了命令。你可以通过以下方法重新调用该命令:
```
!#
```
其中要用命令的实际编号代替 #。为了更好的理解,请看下面的例子:
```
!501
```
等价于:
```
# history
```
### 3. 使用 midnight 命令
如果你不习惯使用类似 cd、cp、mv、rm 等命令,你可以使用 midnight 命令。它是一个简单的可视化 shell,你可以在上面使用鼠标:

*Midnight 命令*
借助 F1 到 F12 键,你可以轻易地执行不同任务。只需要在底部选择对应的命令。要选择文件或者目录,按下 “Insert” 键。
简而言之 midnight 就是所谓的 “mc”。要安装 mc,只需要运行:
```
$ sudo apt-get install mc [On Debian based systems]
```
---
```
# yum install mc [On Fedora based systems]
```
下面是一个使用 midnight 命令器的简单例子。通过输入以下命令打开 mc:
```
# mc
```
现在使用 TAB 键选择不同的窗口 - 左和右。我有一个想要移动到 “Software” 目录的 LibreOffice 文件:

*Midnight 命令移动文件*
按 F6 按钮移动文件到新的目录。MC 会请求你确认:

*移动文件到新目录*
确认了之后,文件就会被移动到新的目标目录。
* 扩展阅读:[如何在 Linux 中使用 Midnight 命令文件管理器](http://www.tecmint.com/midnight-commander-a-console-based-file-manager-for-linux/)
### 4. 在指定时间关闭计算机
有时候你需要在下班几个小时后再关闭计算机。你可以通过使用下面的命令在指定时间关闭你的计算机:
```
$ sudo shutdown 21:00
```
这会告诉你在你指定的时间关闭计算机。你也可以告诉系统在指定分钟后关闭:
```
$ sudo shutdown +15
```
这表示计算机会在 15 分钟后关闭。
### 5. 显示已知用户的信息
你可以使用一个简单的命令列出你 Linux 系统的用户以及一些关于它们的基本信息。
```
# lslogins
```
这会输出下面的结果:
```
UID USER PWD-LOCK PWD-DENY LAST-LOGIN GECOS
0 root 0 0 Apr29/11:35 root
1 bin 0 1 bin
2 daemon 0 1 daemon
3 adm 0 1 adm
4 lp 0 1 lp
5 sync 0 1 sync
6 shutdown 0 1 Jul19/10:04 shutdown
7 halt 0 1 halt
8 mail 0 1 mail
10 uucp 0 1 uucp
11 operator 0 1 operator
12 games 0 1 games
13 gopher 0 1 gopher
14 ftp 0 1 FTP User
23 squid 0 1
25 named 0 1 Named
27 mysql 0 1 MySQL Server
47 mailnull 0 1
48 apache 0 1 Apache
...
```
### 6. 查找文件
查找文件有时候并不像你想象的那么简单。一个搜索文件的好例子是:
```
# find /home/user -type f
```
这个命令会搜索 /home/user 目录下的所有文件。find 命令真的很强大,你可以传递更多选项给它使得你的搜索更加详细。如果你想搜索超过特定大小的文件,可以使用:
```
# find . -type f -size 10M
```
上面的命令会搜索当前目录中所有大于 10M 的文件。确保不要在你 Linux 系统的根目录运行该命令,因为这可能导致你的机器 I/O 瓶颈。
我最经常和 find 命令一起使用的选项之一是 “exec”,这允许你对 find 命令的结果运行一些操作。
例如,假如我们想查找一个目录中的所有文件并更改权限。可以通过以下简单命令完成:
```
# find /home/user/files/ -type f -exec chmod 644 {} \;
```
上面的命令会递归搜索指定目录内的所有文件,并对找到的文件执行 chmod 命令。推荐你阅读 [35 个 Linux ‘find’ 命令的使用方法](http://www.tecmint.com/35-practical-examples-of-linux-find-command/),我肯定你会发现这个命令更多的使用方法。
### 7. 用一个命令创建目录树
你很可能知道可以使用 mkdir 命令创建新的目录。因此如果你想创建一个新的目录,你可能会运行:
```
# mkdir new_folder
```
但如果你想在该目录下创建 5 个子目录呢?运行 5 次 mkdir 命令并非是一个好的选择。相反你可以类似下面这样使用 -p 选项:
```
# mkdir -p new_folder/{folder_1,folder_2,folder_3,folder_4,folder_5}
```
最后你会在 new\_folder 中有 5 个目录:
```
# ls new_folder/
folder_1 folder_2 folder_3 folder_4 folder_5
```
### 8. 复制文件到多个目录
通常使用 cp 命令进行文件复制。复制文件通常看起来类似:
```
# cp /path-to-file/my_file.txt /path-to-new-directory/
```
现在假设你需要复制该文件到多个目录:
```
# cp /home/user/my_file.txt /home/user/1
# cp /home/user/my_file.txt /home/user/2
# cp /home/user/my_file.txt /home/user/3
```
这有点荒唐。相反,你可以用简单的一行命令解决问题:
```
# echo /home/user/1/ /home/user/2/ /home/user/3/ | xargs -n 1 cp /home/user/my_file.txt
```
### 9. 删除大文件
有时候文件可能会变得很大。我看过由于缺乏管理技能一个日志文件就超过 250G 的例子。用 rm 命令可能不足以删除该文件,因为有大量的数据需要移除。应该避免这个很“笨重”的操作。相反,你可以使用一个简单的方法解决这个问题:
```
# > /path-to-file/huge_file.log
```
当然你需要根据你实际情况替换路径和文件名。上面的命令写一个空输出到该文件。用更简单的话说它会清空文件而不会导致你的系统产生大的 I/O 消耗。
### 10. 在多个 Linux 服务器上运行相同命令
最近我们的一个读者在 [LinuxSay 论坛](http://www.linuxsay.com/)提问说如何通过 ssh 在多个 Linux 服务器上执行一个命令。他机器的 IP 地址是:
```
10.0.0.1
10.0.0.2
10.0.0.3
10.0.0.4
10.0.0.5
```
这里有一个简单的解决方法。将服务器的 IP 地址写到文件 list.txt 中,像上面那样一行一个。然后运行:
```
# for in $i(cat list.txt); do ssh user@$i 'bash command'; done
```
上面的命令中你需要用实际登录的用户替换 “user”,用你希望执行的实际命令替换 “bash command”。这个方法非常适用于通过[使用 SSH 密钥进行无密码验证](/article-5202-1.html),因为这样你不需要每次都为用户输入密码。
注意取决于你 Linux 系统的设置,你可能还需要传递一些额外的参数给 SSH 命令。
### 总结
上面的例子都很简单,我希望它们能帮助你发现 Linux 的优美之处,你如何能简单实现在其它操作系统上需要更多时间的不同操作。
---
via: <http://www.tecmint.com/10-useful-linux-command-line-tricks-for-newbies/>
作者:[Marin Todorov](http://www.tecmint.com/author/marintodorov89/) 译者:[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,315 | RHCSA 系列(十一): 使用 firewalld 和 iptables 来控制网络流量 | http://www.tecmint.com/firewalld-vs-iptables-and-control-network-traffic-in-firewall/ | 2015-09-29T10:11:00 | [
"RHCSA"
] | https://linux.cn/article-6315-1.html | 简单来说,防火墙就是一个基于一系列预先定义的规则(例如流量包的目的地或来源,流量的类型等)的安全系统,它控制着一个网络中的流入和流出流量。

*RHCSA: 使用 FirewallD 和 Iptables 来控制网络流量 – Part 11*
在本文中,我们将回顾 firewalld 和 iptables 的基础知识。前者是 RHEL 7 中的默认动态防火墙守护进程,而后者则是针对 Linux 的传统的防火墙服务,大多数的系统和网络管理员都非常熟悉它,并且在 RHEL 7 中也可以用。
### FirewallD 和 Iptables 的一个比较
在后台, firewalld 和 iptables 服务都通过相同的接口来与内核中的 netfilter 框架相交流,这不足为奇,即它们都通过 iptables 命令来与 netfilter 交互。然而,与 iptables 服务相反, firewalld 可以在不丢失现有连接的情况下,在正常的系统操作期间更改设定。
在默认情况下, firewalld 应该已经安装在你的 RHEL 系统中了,尽管它可能没有在运行。你可以使用下面的命令来确认(firewall-config 是用户界面配置工具):
```
# yum info firewalld firewall-config
```

*检查 FirewallD 的信息*
以及,
```
# systemctl status -l firewalld.service
```

*检查 FirewallD 的状态*
另一方面, iptables 服务在默认情况下没有被包含在 RHEL 系统中,但可以被安装上。
```
# yum update && yum install iptables-services
```
这两个守护进程都可以使用常规的 systemd 命令来在开机时被启动和开启:
```
# systemctl start firewalld.service | iptables-service.service
# systemctl enable firewalld.service | iptables-service.service
```
另外,请阅读:[管理 Systemd 服务的实用命令](/article-5926-1.html)
至于配置文件, iptables 服务使用 `/etc/sysconfig/iptables` 文件(假如这个软件包在你的系统中没有被安装,则这个文件将不存在)。在一个被用作集群节点的 RHEL 7 机子上,这个文件看起来是这样:

*Iptables 防火墙配置文件*
而 firewalld 则在两个目录中存储它的配置文件,即 `/usr/lib/firewalld` 和 `/etc/firewalld`:
```
# ls /usr/lib/firewalld /etc/firewalld
```

*FirewallD 的配置文件*
在这篇文章中后面,我们将进一步查看这些配置文件,在那之后,我们将在这两个地方添加一些规则。现在,是时候提醒你了,你总可以使用下面的命令来找到更多有关这两个工具的信息。
```
# man firewalld.conf
# man firewall-cmd
# man iptables
```
除了这些,记得查看一下当前系列的第一篇 [RHCSA 系列(一): 回顾基础命令及系统文档](/article-6133-1.html),在其中我描述了几种渠道来得到安装在你的 RHEL 7 系统上的软件包的信息。
### 使用 Iptables 来控制网络流量
在进一步深入之前,或许你需要参考 Linux 基金会认证工程师(Linux Foundation Certified Engineer,LFCE) 系列中的 [配置 Iptables 防火墙 – Part 8](http://www.tecmint.com/configure-iptables-firewall/) 来复习你脑中有关 iptables 的知识。
#### **例 1:同时允许流入和流出的网络流量**
TCP 端口 80 和 443 是 Apache web 服务器使用的用来处理常规(HTTP)和安全(HTTPS)网络流量的默认端口。你可以像下面这样在 enp0s3 接口上允许流入和流出网络流量通过这两个端口:
```
# iptables -A INPUT -i enp0s3 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A OUTPUT -o enp0s3 -p tcp --sport 80 -m state --state ESTABLISHED -j ACCEPT
# iptables -A INPUT -i enp0s3 -p tcp --dport 443 -m state --state NEW,ESTABLISHED -j ACCEPT
# iptables -A OUTPUT -o enp0s3 -p tcp --sport 443 -m state --state ESTABLISHED -j ACCEPT
```
#### **例 2:从某个特定网络中阻挡所有(或某些)流入连接**
或许有时你需要阻挡来自于某个特定网络的所有(或某些)类型的来源流量,比方说 192.168.1.0/24:
```
# iptables -I INPUT -s 192.168.1.0/24 -j DROP
```
上面的命令将丢掉所有来自 192.168.1.0/24 网络的网络包,而
```
# iptables -A INPUT -s 192.168.1.0/24 --dport 22 -j ACCEPT
```
将只允许通过端口 22 的流入流量。
#### **例 3:将流入流量重定向到另一个目的地**
假如你不仅使用你的 RHEL 7 机子来作为一个软件防火墙,而且还将它作为一个硬件防火墙,使得它位于两个不同的网络之间,那么在你的系统上 IP 转发一定已经被开启了。假如没有开启,你需要编辑 `/etc/sysctl.conf` 文件并将 `net.ipv4.ip_forward` 的值设为 1,即:
```
net.ipv4.ip_forward = 1
```
接着保存更改,关闭你的文本编辑器,并最终运行下面的命令来应用更改:
```
# sysctl -p /etc/sysctl.conf
```
例如,你可能在一个内部的机子上安装了一个打印机,它的 IP 地址为 192.168.0.10,CUPS 服务在端口 631 上进行监听(同时在你的打印服务器和你的防火墙上)。为了从防火墙另一边的客户端传递打印请求,你应该添加下面的 iptables 规则:
```
# iptables -t nat -A PREROUTING -i enp0s3 -p tcp --dport 631 -j DNAT --to 192.168.0.10:631
```
请记住 iptables 会逐条地读取它的规则,所以请确保默认的策略或后面的规则不会重载上面例子中那些规则。
### FirewallD 入门
firewalld 引入的一个变化是区域(zone) (注:翻译参考了 <https://fedoraproject.org/wiki/FirewallD/zh-cn> )。这个概念允许将网路划分为拥有不同信任级别的区域,由用户决定将设备和流量放置到哪个区域。
要获取活动的区域,使用:
```
# firewall-cmd --get-active-zones
```
在下面的例子中,public 区域是激活的,并且 enp0s3 接口被自动地分配到了这个区域。要查看有关一个特定区域的所有信息,可使用:
```
# firewall-cmd --zone=public --list-all
```

*列出所有的 Firewalld 区域*
由于你可以在 [RHEL 7 安全指南](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide/sec-Using_Firewalls.html) 中阅读到更多有关区域的知识,这里我们将仅列出一些特别的例子。
#### **例 4:允许服务通过防火墙**
要获取受支持的服务的列表,可以使用:
```
# firewall-cmd --get-services
```

*列出所有受支持的服务*
要立刻生效且在随后重启后都可以让 http 和 https 网络流量通过防火墙,可以这样:
```
# firewall-cmd --zone=MyZone --add-service=http
# firewall-cmd --zone=MyZone --permanent --add-service=http
# firewall-cmd --zone=MyZone --add-service=https
# firewall-cmd --zone=MyZone --permanent --add-service=https
# firewall-cmd --reload
```
假如 `-–zone` 被忽略,则使用默认的区域(你可以使用 `firewall-cmd –get-default-zone`来查看)。
若要移除这些规则,可以在上面的命令中将 `add` 替换为 `remove`。
#### **例 5:IP 转发或端口转发**
首先,你需要查看在目标区域中,伪装(masquerading)是否被开启:
```
# firewall-cmd --zone=MyZone --query-masquerade
```
在下面的图片中,我们可以看到对于外部区域,伪装已被开启,但对于公用区域则没有:

*查看伪装状态*
你可以为公共区域开启伪装:
```
# firewall-cmd --zone=public --add-masquerade
```
或者在外部区域中使用伪装。下面是使用 firewalld 来重复例 3 中的任务所需的命令:
```
# firewall-cmd --zone=external --add-forward-port=port=631:proto=tcp:toport=631:toaddr=192.168.0.10
```
不要忘了重新加载防火墙。
在 RHCSA 系列的 [第九部分](/article-6286-1.html) 你可以找到更深入的例子,在那篇文章中我们解释了如何允许或禁用通常被 web 服务器和 ftp 服务器使用的端口,以及在针对这两个服务所使用的默认端口被改变时,如何更改相应的规则。另外,你或许想参考 firewalld 的 wiki 来查看更深入的例子。
* 延伸阅读: [在 RHEL 7 中配置防火墙的几个实用的 firewalld 例子](http://www.tecmint.com/firewalld-rules-for-centos-7/)
### 总结
在这篇文章中,我们已经解释了防火墙是什么,介绍了在 RHEL 7 中用来实现防火墙的几个可用的服务,并提供了可以帮助你入门防火墙的几个例子。假如你有任何的评论,建议或问题,请随意使用下面的评论框来让我们知晓。这里就事先感谢了!
---
via: <http://www.tecmint.com/firewalld-vs-iptables-and-control-network-traffic-in-firewall/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[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,335 | RHCSA 系列(十二): 使用 Kickstart 完成 RHEL 7 的自动化安装 | http://www.tecmint.com/automatic-rhel-installations-using-kickstart/ | 2015-10-02T10:11:00 | [
"RHCSA"
] | https://linux.cn/article-6335-1.html | 无论是在数据中心还是实验室环境,Linux 服务器很少是独立的机器,很可能有时你需要安装多个以某种方式相互联系的机器。假如你将在单个服务器上手动安装 RHEL 7 所花的时间乘以你需要配置的机器数量,这将导致你必须做出一场相当长的努力,而通过使用被称为 kicksta 的无人值守安装工具则可以避免这样的麻烦。
在这篇文章中,我们将向你展示使用 kickstart 工具时所需的一切,以便在安装过程中,不用你时不时地照看“处在襁褓中”的服务器。

*RHCSA: RHEL 7 的自动化 Kickstart 安装*
#### Kickstart 和自动化安装简介
Kickstart 是一种被用来执行无人值守操作系统安装和配置的自动化安装方法,主要被 RHEL(以及其他 Fedora 的副产品,如 CentOS,Oracle Linux 等)所使用。因此,kickstart 安装方法可使得系统管理员只需考虑需要安装的软件包组和系统的配置,便可以得到相同的系统,从而省去必须手动安装这些软件包的麻烦。
### 准备 Kickstart 安装
要执行 kickstart 安装,我们需要遵循下面的这些步骤:
1. 创建一个 Kickstart 文件,它是一个带有多个预定义配置选项的纯文本文件。
2. 将 Kickstart 文件保存在可移动介质上,如一个硬盘或一个网络位置。kickstart 客户端需要使用 `rhel-server-7.0-x86_64-boot.iso` 镜像文件,而你还需要可从一个网络资源上获取得到完整的 ISO 镜像 `rhel-server-7.0-x86_64-dvd.iso` ,例如通过一个 FTP 服务器的 HTTP 服务形式(在我们当前的例子中,我们将使用另一个 IP 地址为 192.168.0.18 的 RHEL 7 机器)。
3. 开始 Kickstart 安装。
要创建一个 kickstart 文件,请登录你的红帽客户门户网站(Red Hat Customer Portal)帐户,并使用 [Kickstart 配置工具](https://access.redhat.com/labs/kickstartconfig/) 来选择所需的安装选项。在向下滑动之前请仔细阅读每个选项,然后选择最适合你需求的选项:

*Kickstart 配置工具*
假如你指定安装将通过 HTTP,FTP,NFS 来执行,请确保服务器上的防火墙允许这些服务通过。
尽管你可以使用红帽的在线工具来创建一个 kickstart 文件,但你还可以使用下面的代码来作为参考手动地创建它。例如,你可以注意到,下面的代码指定了安装过程将使用英语环境,使用拉丁美洲键盘布局,并设定时区为 America/Argentina/San\_Luis 时区:
```
lang en_US
keyboard la-latin1
timezone America/Argentina/San_Luis --isUtc
rootpw $1$5sOtDvRo$In4KTmX7OmcOW9HUvWtfn0 --iscrypted
#platform x86, AMD64, or Intel EM64T
text
url --url=http://192.168.0.18//kickstart/media
bootloader --location=mbr --append="rhgb quiet crashkernel=auto"
zerombr
clearpart --all --initlabel
autopart
auth --passalgo=sha512 --useshadow
selinux --enforcing
firewall --enabled
firstboot --disable
%packages
@base
@backup-server
@print-server
%end
```
在上面的在线配置工具中,在选择以 HTTP 来作为安装源后,设置好在安装过程中使用 192.168.0.18 来作为 HTTP 服务器的地址,`/kickstart/tecmint.bin` 作为 HTTP 目录。
在上面的 kickstart 示例文件中,你需要特别注意
```
url --url=http://192.168.0.18//kickstart/media
```
这个目录是你展开 DVD 或 ISO 安装介质内容的地方。在执行解压之前,我们将把 ISO 安装文件作为一个回环设备挂载到 /media/rhel 目录下:
```
# mount -o loop /var/www/html/kickstart/rhel-server-7.0-x86_64-dvd.iso /media/rhel
```

*挂载 RHEL ISO 镜像*
接下来,复制 /media/rhel 中的全部文件到 /var/www/html/kickstart/media 目录:
```
# cp -R /media/rhel /var/www/html/kickstart/media
```
这一步做完后,/var/www/html/kickstart/media 目录中的文件列表和磁盘使用情况将如下所示:

*Kickstart 媒体文件*
现在,我们已经准备好开始 kickstart 安装了。
不管你如何选择创建 kickstart 文件的方式,在执行安装之前检查下这个文件的语法是否有误总是一个不错的主意。为此,我们需要安装 pykickstart 软件包。
```
# yum update && yum install pykickstart
```
然后使用 ksvalidator 工具来检查这个文件:
```
# ksvalidator /var/www/html/kickstart/tecmint.bin
```
假如文件中的语法正确,你将不会得到任何输出,反之,假如文件中存在错误,你得到警告,向你提示在某一行中语法不正确或出错原因未知。
### 执行 Kickstart 安装
首先,使用 rhel-server-7.0-x86\_64-boot.iso 来启动你的客户端。当初始屏幕出现时,选择安装 RHEL 7.0 ,然后按 Tab 键来追加下面这一句,接着按 Enter 键:
```
# inst.ks=http://192.168.0.18/kickstart/tecmint.bin
```

*RHEL Kickstart 安装*
其中 tecmint.bin 是先前创建的 kickstart 文件。
当你按了 Enter 键后,自动安装就开始了,且你将看到一个列有正在被安装的软件的列表(软件包的数目和名称根据你所选择的程序和软件包组而有所不同):

*RHEL 7 的自动化 Kickstart 安装*
当自动化过程结束后,将提示你移除安装介质,接着你就可以启动到你新安装的系统中了:

*RHEL 7 启动屏幕*
尽管你可以像我们前面提到的那样,手动地创建你的 kickstart 文件,但你应该尽可能地考虑使用受推荐的方式:你可以使用在线配置工具,或者使用在安装过程中创建的位于 root 家目录下的 anaconda-ks.cfg 文件。
这个文件实际上就是一个 kickstart 文件,你或许想在选择好所有所需的选项(可能需要更改逻辑卷布局或机器上所用的文件系统)后手动地安装第一个机器,接着使用产生的 anaconda-ks.cfg 文件来自动完成其余机器的安装过程。
另外,使用在线配置工具或 anaconda-ks.cfg 文件来引导将来的安装将允许你在系统安装时以加密的形式设置 root 密码。
### 总结
既然你知道了如何创建 kickstart 文件并如何使用它们来自动完成 RHEL 7 服务器的安装,你就可以不用时时照看安装进度的过程了。这将给你时间来做其他的事情,或者若你足够幸运,你还可以用来休闲一番。
无论以何种方式,请使用下面的评论栏来让我们知晓你对这篇文章的看法。提问也同样欢迎!
另外,请阅读:[使用 PXE 和 kickstart 来自动化安装多个 RHEL/CentOS 7 发行版本](http://www.tecmint.com/multiple-centos-installations-using-kickstart/)
---
via: <http://www.tecmint.com/automatic-rhel-installations-using-kickstart/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[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,339 | RHCSA 系列(十三): 在 RHEL 7 中使用 SELinux 进行强制访问控制 | http://www.tecmint.com/selinux-essentials-and-control-filesystem-access/ | 2015-10-03T09:07:00 | [
"RHCSA"
] | https://linux.cn/article-6339-1.html | 在本系列的前面几篇文章中,我们已经详细地探索了至少两种访问控制方法:标准的 ugo/rwx 权限([RHCSA 系列(三): 如何管理 RHEL7 的用户和组](/article-6187-1.html)) 和访问控制列表([RHCSA 系列(七): 使用 ACL(访问控制列表) 和挂载 Samba/NFS 共享](/article-6263-1.html))。

*RHCSA 认证:SELinux 精要和控制文件系统的访问*
尽管作为第一级别的权限和访问控制机制是必要的,但它们同样有一些局限,而这些局限则可以由<ruby> 安全增强 Linux <rp> ( </rp> <rt> Security Enhanced Linux,简称为 SELinux </rt> <rp> ) </rp></ruby>来处理。
这些局限的一种情形是:某个用户可能通过一个泛泛的 chmod 命令将文件或目录暴露出现了安全违例,从而引起访问权限的意外传播。结果,由该用户开启的任意进程可以对属于该用户的文件进行任意的操作,最终一个恶意的或有其它缺陷的软件可能会取得整个系统的 root 级别的访问权限。
考虑到这些局限性,美国国家安全局(NSA) 率先设计出了 SELinux,一种强制的访问控制方法,它根据最小权限模型去限制进程在系统对象(如文件,目录,网络接口等)上的访问或执行其他的操作的能力,而这些限制可以在之后根据需要进行修改。简单来说,系统的每一个元素只给某个功能所需要的那些权限。
在 RHEL 7 中,SELinux 被并入了内核中,且默认情况下以<ruby> 强制模式 <rp> ( </rp> <rt> Enforcing </rt> <rp> ) </rp></ruby>开启。在这篇文章中,我们将简要地介绍有关 SELinux 及其相关操作的基本概念。
### SELinux 的模式
SELinux 可以以三种不同的模式运行:
* <ruby> 强制模式 <rp> ( </rp> <rt> Enforcing </rt> <rp> ) </rp></ruby>:SELinux 基于其策略规则来拒绝访问,这些规则是用以控制安全引擎的一系列准则;
* <ruby> 宽容模式 <rp> ( </rp> <rt> Permissive </rt> <rp> ) </rp></ruby>:SELinux 不会拒绝访问,但对于那些如果运行在强制模式下会被拒绝访问的行为进行记录;
* <ruby> 关闭 <rp> ( </rp> <rt> Disabled </rt> <rp> ) </rp></ruby> (不言自明,即 SELinux 没有实际运行).
使用 `getenforce` 命令可以展示 SELinux 当前所处的模式,而 `setenforce` 命令(后面跟上一个 1 或 0) 则被用来将当前模式切换到<ruby> 强制模式 <rp> ( </rp> <rt> Enforcing </rt> <rp> ) </rp></ruby>或<ruby> 宽容模式 <rp> ( </rp> <rt> Permissive </rt> <rp> ) </rp></ruby>,但只对当前的会话有效。
为了使得在登出和重启后上面的设置还能保持作用,你需要编辑 `/etc/selinux/config` 文件并将 SELINUX 变量的值设为 enforcing,permissive,disabled 中之一:
```
# getenforce
# setenforce 0
# getenforce
# setenforce 1
# getenforce
# cat /etc/selinux/config
```

*设置 SELinux 模式*
通常情况下,你应该使用 `setenforce` 来在 SELinux 模式间进行切换(从强制模式到宽容模式,或反之),以此来作为你排错的第一步。假如 SELinux 当前被设置为强制模式,而你遇到了某些问题,但当你把 SELinux 切换为宽容模式后问题不再出现了,则你可以确信你遇到了一个 SELinux 权限方面的问题。
### SELinux 上下文
一个 SELinux <ruby> 上下文 <rp> ( </rp> <rt> Context </rt> <rp> ) </rp></ruby>由一个访问控制环境所组成,在这个环境中,决定的做出将基于 SELinux 的用户,角色和类型(和可选的级别):
* 一个 SELinux 用户是通过将一个常规的 Linux 用户账户映射到一个 SELinux 用户账户来实现的,反过来,在一个会话中,这个 SELinux 用户账户在 SELinux 上下文中被进程所使用,以便能够明确定义它们所允许的角色和级别。
* 角色的概念是作为域和处于该域中的 SELinux 用户之间的媒介,它定义了 SELinux 可以访问到哪个进程域和哪些文件类型。这将保护您的系统免受提权漏洞的攻击。
* 类型则定义了一个 SELinux 文件类型或一个 SELinux 进程域。在正常情况下,进程将会被禁止访问其他进程正使用的文件,并禁止对其他进程进行访问。这样只有当一个特定的 SELinux 策略规则允许它访问时,才能够进行访问。
下面就让我们看看这些概念是如何在下面的例子中起作用的。
**例 1:改变 sshd 守护进程的默认端口**
在 [RHCSA 系列(八): 加固 SSH,设定主机名及启用网络服务](/article-6266-1.html) 中,我们解释了更改 sshd 所监听的默认端口是加固你的服务器免受外部攻击的首要安全措施。下面,就让我们编辑 `/etc/ssh/sshd_config` 文件并将端口设置为 9999:
```
Port 9999
```
保存更改并重启 sshd:
```
# systemctl restart sshd
# systemctl status sshd
```

*重启 SSH 服务*
正如你看到的那样, sshd 启动失败,但为什么会这样呢?
快速检查 `/var/log/audit/audit.log` 文件会发现 sshd 已经被拒绝在端口 9999 上开启(SELinux 的日志信息包含单词 "AVC",所以这类信息可以被轻易地与其他信息相区分),因为这个端口是 JBoss 管理服务的保留端口:
```
# cat /var/log/audit/audit.log | grep AVC | tail -1
```

*查看 SSH 日志*
在这种情况下,你可以像先前解释的那样禁用 SELinux(但请不要这样做!),并尝试重启 sshd,且这种方法能够起效。但是, `semanage` 应用可以告诉我们在哪些端口上可以开启 sshd 而不会出现任何问题。
运行:
```
# semanage port -l | grep ssh
```
便可以得到一个 SELinux 允许 sshd 在哪些端口上监听的列表:

*Semanage 工具*
所以让我们在 `/etc/ssh/sshd_config` 中将端口更改为 9998 端口,增加这个端口到 ssh*port*t 的上下文,然后重启 sshd 服务:
```
# semanage port -a -t ssh_port_t -p tcp 9998
# systemctl restart sshd
# systemctl is-active sshd
```

*semanage 添加端口*
如你所见,这次 sshd 服务被成功地开启了。这个例子告诉我们一个事实:SELinux 用它自己的端口类型的内部定义来控制 TCP 端口号。
**例 2:允许 httpd 访问 sendmail**
这是一个 SELinux 管理一个进程来访问另一个进程的例子。假如在你的 RHEL 7 服务器上,[你要为 Apache 配置 mod\_security 和 mod\_evasive](/article-5639-1.html),你需要允许 httpd 访问 sendmail,以便在遭受到 (D)DoS 攻击时能够用邮件来提醒你。在下面的命令中,如果你不想使得更改在重启后仍然生效,请去掉 `-P` 选项。
```
# semanage boolean -1 | grep httpd_can_sendmail
# setsebool -P httpd_can_sendmail 1
# semanage boolean -1 | grep httpd_can_sendmail
```

*允许 Apache 发送邮件*
从上面的例子中,你可以知道 SELinux 布尔设定(或者只是布尔值)分别对应于 true 或 false,被嵌入到了 SELinux 策略中。你可以使用 `semanage boolean -l` 来列出所有的布尔值,也可以管道至 grep 命令以便筛选输出的结果。
**例 3:在一个特定目录而非默认目录下提供一个静态站点服务**
假设你正使用一个不同于默认目录(`/var/www/html`)的目录来提供一个静态站点服务,例如 `/websites` 目录(这种情形会出现在当你把你的网络文件存储在一个共享网络设备上,并需要将它挂载在 /websites 目录时)。
a). 在 /websites 下创建一个 index.html 文件并包含如下的内容:
```
<html>
<h2>SELinux test</h2>
</html>
```
假如你执行
```
# ls -lZ /websites/index.html
```
你将会看到这个 index.html 已经被标记上了 default\_t SELinux 类型,而 Apache 不能访问这类文件:

*检查 SELinux 文件的权限*
b). 将 `/etc/httpd/conf/httpd.conf` 中的 DocumentRoot 改为 /websites,并不要忘了 更新相应的 Directory 块。然后重启 Apache。
c). 浏览 `http://<web server IP address>`,则你应该会得到一个 503 Forbidden 的 HTTP 响应。
d). 接下来,递归地改变 /websites 的标志,将它的标志变为 `httpd_sys_content_t` 类型,以便赋予 Apache 对这些目录和其内容的只读访问权限:
```
# semanage fcontext -a -t httpd_sys_content_t "/websites(/.*)?"
```
e). 最后,应用在 d) 中创建的 SELinux 策略:
```
# restorecon -R -v /websites
```
现在重启 Apache 并再次浏览到 `http://<web server IP address>`,则你可以看到被正确展现出来的 html 文件:

*确认 Apache 页面*
### 总结
在本文中,我们详细地介绍了 SELinux 的基础知识。请注意,由于这个主题的广泛性,在单篇文章中做出一个完全详尽的解释是不可能的,但我们相信,在这个指南中列出的基本原则将会对你进一步了解更高级的话题有所帮助,假如你想了解的话。
假如可以,请让我推荐两个必要的资源来入门 SELinux:[NSA SELinux 页面](https://www.nsa.gov/research/selinux/index.shtml) 和 [针对用户和系统管理员的 RHEL 7 SELinux 指南](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/SELinux_Users_and_Administrators_Guide/part_I-SELinux.html)。
假如你有任何的问题或评论,请不要犹豫,让我们知晓吧。
---
via: <http://www.tecmint.com/selinux-essentials-and-control-filesystem-access/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[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,342 | ifdex: 一个由 ESR 出品的给代码考古学家的工具 | http://esr.ibiblio.org/?p=6851 | 2015-10-03T17:47:17 | [
"配置",
"ifdex"
] | https://linux.cn/article-6342-1.html | Eric Raymond 写了一个工具,用来帮助那些无畏的“代码考古学家们”理解“古代”代码的结构。它叫做 [ifdex](http://www.catb.org/esr/ifdex/),它的背后有一段故事,拿起你的 Fedora 和赶牛的鞭子,让我讲给你听……

在开发 NTPsec 早期, 我们就决定替换它的构建系统——它是如此的难于理解和修改——严重的拖慢了我们的开发进度。
古老的 autoconf 构建方式就像一个恐怖的爬行动物,而 NTP 更是一个极端的例子。不完善的宏技术定义了太多的配置符号,为了掌握这些接口,即使你查看了 config.h 也无济于事。尤其是当你要做一些大的修改时,这更是一个问题!
我们的一个伙计 Amar Takhar,是 waf 构建系统的专家,当他初步提出迁移的想法时得到了我的积极响应。几个月之后,他就做出了一些 waf 功能,虽然还未完成,但是已经至少可以生成用于实际测试的二进制了。
这里我说“未完成”的意思是,代码里面还有一些 waf 构建绝不会设置的 #define 。很多人绝对不会碰那些 autoconf 构建的东西,而另外一些人则不。那些从来用不到的配置开关迷失在大堆的系统头文件和编译器设置的 #define 条件中。
我这里说的不是几个或几十个,我最终统计出了有超过 670 个不同的 #define 用在 #if/#ifdef/#ifndef/#elif 条件中,而这些条件,如 John D. Bell 指出的那样,有 2430 个之多。我需要一些办法来检查它们并分成不同的类型:有的来自系统头文件、有的是配置开关,以及其它的……
所以我写了一个分析器,它可以对代码树解析每个编译时条件的符号,然后将它们分成单纯的列表或 GCC 类的文件/行错误信息,你可以用 Emacs 的编译模式逐个分析。
为了降低干扰,它掌握着一个条件符号的长列表(大概200个),这些可以忽略掉。比如像 \_\_GNUC\_\_ 符号是 GCC 预定义,而 O\_NONBLOCK 宏用于几种系统调用等等。
这些符号分成几组,你可以使用命令行选项分别忽略它们。所以,如果你希望忽略列表中所有标准的 POSIX 宏而想看到操作系统相关的任何东西,那就可以做到了。
另外一个重要的功能是你可以构造你自己的排除列表及注释。这样当我探索 NTP 编译条件的黑暗森林时,所构造的越来越大的排除列表就代表了我已经了解了的条件符号。最终(我希望)未知符号的报告将缩减为空,那么我就已经了解了所有配置开关的确切意义了。
目前为止,我已经搞定了它们之中的 300 个,还有 373 个。这是我用我的漂亮工具在一周内完成的主要工作。噢,从来没有人说过代码考古是如此的容易。
最后, ifdef 的主页是: <http://www.catb.org/esr/ifdex/> ,代码库在这里: <https://gitlab.com/esr/ifdex> 。希望你用的上。
| 200 | OK | I’ve written a tool to assist intrepid code archeologists trying to comprehend the structure of ancient codebases. It’s called [ifdex](http://www.catb.org/esr/ifdex/), and it comes with a backstory. Grab your fedora and your bullwhip, we’re going in…
One of the earliest decisions we made on NTPsec was to replace its build system. It had become so difficult to understand and modify that we knew it would be significant drag on development.
Ancient autoconf builds tend to be crawling horrors and NTP’s is an extreme case – 31KLOC of kludgy macrology that defines enough configuration symbols to make getting a grasp on its interface with the codebase nigh-impossible even when you have a config.h to look at. And that’s a *problem* when you’re planning large changes!
One of our guys, Amar Takhar, is an expert on the waf build system. When he tentatively suggested moving to that I cheered the idea resoundingly. Months later he was able to land a waf recipe which, while not complete, would at least produce binaries that could be live-tested.
When I say “not complete” I mean that I could tell that there were configuration #defines in the codebase that the waf build never set. Quite a few of them – in some cases fossils that the autoconf build didn’t touch either, but in others … not. And these unreached configuration knobs tended to get lost amidst a bunch of conditional guards looking at #defines set by system headers and the compiler.
And we’re not talking a handful or even dozens. I eventually counted over 670 distinct #defines being used in #if/#ifdef/#ifndef/#elif guards – 2430 of them, as A&D regular John D. Bell pointed out in a comment on my last post. I needed some way to examine these and sort them into groups – this is from a system header, that’s a configuration knob, and over there is something else…
So I wrote an analyzer. It parses every compile-time conditional in a code tree for symbols, then reports them either as a bare list or GCC-like file/line error messages that you can step through with Emacs compilation mode.
To reduce noise, it knows about a long list of guard symbols (almost 200 of them) that it should normally ignore – things like the __GNUC__ symbol that GCC predefines, or the O_NONBLOCK macro used by various system calls.
The symbols are divided into groups that you can choose to ignore individually with a command-line option. So, if you want to ignore all standardized POSIX macros in the list but see anything OS-dependent, you can do that.
Another important feature is that you can build your own exclusion lists, with comments. The way I’m exploring the jungle of NTP conditionals is by building a bigger and bigger exclusion list describing the conditional symbols I understand. Eventually (I hope) the report of unknown symbols will shrink to empty. At that point I’ll know what all the configuration knobs are with certainty.
As of now I have knocked out about 300 of them and have 373 to go. That’s most of a week’s work, even with my spiffy new tool. Oh well, nobody ever said code archeology was easy.
Does it know about `#pragma once` guards equivalent?
#ifndef FOO_H
#define FOO_H
….
#endif /* FOO_H */
>Does it know about `#pragma once` guards equivalent?
No. I thought about trying to make it recognize those but decided it would be too failure-prone.
In NTPsec I’ve renamed all those symbols to have a “GUARD_” prefix, so I can just put GUARD_ in my exclude file and ignore them.
>> Does it know about `#pragma once` guards equivalent?
> No. I thought about trying to make it recognize those but decided it would be too failure-prone.
I don’t think it would be error prone if you use the whole context:
1.) include guards are named after the filename (uppercased, with non-word characters replaced by underscore, e.g. hello.h -> HELLO_H), i.e. basename of file and guard should match when using relaxed compare / collation function
2.) the ifdef must be of #ifndef form, must start at the beginning of the file (skipping empty lines and comments), and must stop at the end of the file (again, skipping empty lines and comments)
3.) #ifndef FOO_H should be immediatelly followed by #define FOO_H
This should eliminate false positives (hiding non-guard ifdefs as include guards). And is not possible with regexp-based exclusion – it does not have full information.
OTOH. C99-ification would move header guards to #pragma once…
@esr –
Minor bug – the distribution tarball (from catb.org) has the extension “.tar.gz”, but it is
notcompressed.>Minor bug – the distribution tarball (from catb.org) has the extension “.tar.gz”, but it is not compressed.
I checked and it is. As others have said, the browswe is being overly helpful.
The project I’m working on right now is an old codebase that heavily uses autoconf, automake, autogen, autoopt, and probably autofootgun. I’ve only needed to do a few tweaks to get things working with the newest versions of these tools, but I already long to replace it all with a few lisp macros.
@John D Bell – some webhosts will “helpfully” declare any gzipped file, even if it really is gzipped on the server and has a .gz filename, as “Content-Encoding: gzip”, which will cause browsers to auto-decompress it (but not change the filename).
@esr –
Nit-picky questions about a gnarly detail of the code (please remember that my Python-fu is very weak):
ifdex, line 322:
`ifre = re.compile("^# *(ifdef|ifndef|elif|if)")`
Shouldn’t the whitespace after the hash mark be “[ \t]*” ? (There are a few places in the NTP sources where exactly the pattern “hash – tab – if…” occurs.) And couldn’t the alternation just
be “(if|elif)” (since “if” is a proper prefix of both “ifdef” and “ifndef”)?
>Shouldn’t the whitespace after the hash mark be “[ \t]*” ?
Hm. Yes, actually. Thanks for spotting that.
>And couldn’t the alternation just be “(if|elif)” (since “if” is a proper prefix of both “ifdef” and “ifndef”)?
It could be. I wrote it this way to make the intended semantics clearer
Excellent. Scons for gpsd, now waf for NTPsec.
We need to search and destroy all the GNU build crap in OpenSource. And yes, it is crap. It should know if it has glibc (or whatever Sun SysV had) by checking a few things, but instead tests for memcpy or bcopy and a dozen things individually. It can take longer to do ./configure than to compile the actual code, and if there is an error after 15 minutes you can correct, it takes 15 minutes to get back there.
The proper model is start with POSIX, or what should be common to the most (80-98%) targets, I think headers or macros can test for 64/32 bit or endianness. #ifdef __EXOTIC__ can use macros or shims.
I can appreciate the diversity when autotools was created, there were dozens of hundreds of platforms. But today there has been much more standardization and convergence.
I recently came across a program called “cppp” which claims to be a “partial C preprocessor” and is aimed at cleaning ifdefs out of legacy codebases. I’ve not used it, but it sounds like it would complement ifdex quite nicely.
http://www.muppetlabs.com/~breadbox/software/cppp.html
Random832: That looks like what’s happening here. From the HTTP response:
HTTP/1.1 200 OK
[…]
Content-Type: application/x-gzip
Content-Encoding: x-gzip
This is followed by the (gzipped) tarball. Irritatingly, this happens even if the request doesn’t include an Accept-Encoding header, or if the Accept-Encoding header explicitly says not to. Some browsers have workarounds for this buggy behavior, and others follow the HTTP spec more literally.
What always bothered me about the autoconf stuff is that it checked for features the program doesn’t use. If I don’t call bzero(), why are you checking to see if the system has a working bzero()?
@Garrett isn’t that just a matter of poorly written autoconf scripts?
The autoconf for atool (which was linked here recently, it’s the universal tar unpacker someone mentioned in a recent thread) does basically nothing but check where perl is installed.
>@Garrett isn’t that just a matter of poorly written autoconf scripts?
No. There’s a set of features that autoconf checks for whether you ask or not.
> No. There’s a set of features that autoconf checks for whether you ask or not.
Checking if environment is sane?
http://www.xkcd.com/371/ <– "Title text: Checking whether build environment is sane… build environment is grinning and holding a spatula. Guess not."
Checking if environment is sane?Sanity checking is all fine and good, but if a program doesn’t care about the sanity of obscureFunction23() then autoconf shouldn’t care about it either: the entire point of this kind of tool is so the programmer doesn’t have to worry about the details of 10,000 platforms of widely varying sanity.
But all of this is ignoring a larger question: Is
autoconfsane?I think most here would say no, which puts autoconf in the interesting position of being a fundamentalist preacher railing against the horrors of sex-for-anything-other-than-reproduction while cheating on his wife with another man.
Auto* must die. It is full of cruft.
ifdex? Not ifdefix ;-) ?
Though I see that in English translation the name of Asterix dog is “Dogmatix”, not “Idéfix”…
>ifdex? Not ifdefix ;-) ?
Alas, a missed opportunity.
>Though I see that in English translation the name of Asterix dog is “Dogmatix”, not “Idéfix”…
Yes, which I think is a very clever rendering. Most English speakers aren’t familiar enough with the French phrase “idée fixe” to appreciate the original, even though a close to parallel usage is occasional in English.
Fortunately, the punning names “Asterix” and “Obelix” work as well in English as they do in French. The same is not so true of many of the other character names. For the druid, I prefer the French original “Panoramix” or the German translation “Miraculix” to “Getafix”.
> No. There’s a set of features that autoconf checks for whether you ask or not.
The atool case proves, at least, that bzero is not part of that set.
>The atool case proves, at least, that bzero is not part of that set.
You’re right. I’m looking at the giflib configure – pretty close to minimal, it checks for 4 header files (limits.h, fcntl.h, stdint.h, and stdarg.h) and that’s it. In the resulting config.h, I don’t see a #define for bzero, but I do see several excess #defines. Checks for dlfcn.h, fcntl.h, memory.h, string.h, the way obsolete BSD strings.h, and sys/stat.h are done even though I didn’t order them up.
I’m actually surprised to see there is so little excess. In the past I remember seeing checks for
functionsI wasn’t interested in. Either the maintainers have been cleaning up or many of the excess tests cascade off things one does request.> Sanity checking is all fine and good, but if a program doesn’t care about the sanity of obscureFunction23() then autoconf shouldn’t care about it either
It turns out that “checking if build environment is sane” actually means:
– Directory path doesn’t contain shell metacharacters.
– “ls -t” works (this is a side effect of the fact that the next test depends on it).
– The system clock is set to a reasonable value (i.e. the configure script itself has a timestamp in the past)
I was surprised that atool used autoconf at all (being a perl script), but it does serve as an existence proof against almost anything (e.g. bzero, obscureFunction23) that you might assume autoconf “always” checks.
Though ifdefix would be also #ifdef + fix; ifdex is (?) if + regex ???
…it’s a pity that naming a program ‘#ifdefix’ would be not a good idea (unless you want to annoy users) :-PPP
>Though ifdefix would be also #ifdef + fix; ifdex is (?) if + regex ???
It’s intended to be a portmanteau of “ifdef” and “index”.
literally #ifdefix
please use things like \s in these sorts of cases. Two reasons.
1) you don’t have to worry about whether its a tab or a space and it is clear semantically
2) while probably not an issue in this case I have seen stupid text editors wrap lines on the space in a regex which leads to all sorts of unpleasantness
and 2a) occasional moron developers will add or remove spaces not realizing that that space was intentional in the match and thereby screw it up
>> Though ifdefix would be also #ifdef + fix; ifdex is (?) if + regex ???
> It’s intended to be a portmanteau of “ifdef” and “index”.
That’s actually a good description what program does…
@ESR only tangentially related (as in, open source software development) but have you seen Urbit, esp. the stuff released just three days ago? http://urbit.org/preview/~2015.9.25/materials/whitepaper it tends to press “not 100% sure about what it is about, but smells like pure genius” buttons in my brain.
>not 100% sure about what it is about, but smells like pure genius” buttons in my brain.
Either pure genius or utter crackpottery – not sure which. I will examine more carefully.
Genius and crackpottery are not mutually exclusive: I submit TempleOS as evidence in support.
Building the case for Urbit/Nock/Hoon as a superposition of genius and crackpottery is this seminal fact: it’s Mencius Moldbug’s baby.
Well, either I have not been exposed to the right programming languages, or there is a serious semantics gap (too many new/invented terms) between the content of that paper and a more normal programming/systems discussion. Or both. When I looked at it, I got a gist, but tended to skim….
But it’s interesting it’s from Moldbug – I didn’t know that when I was reading the paper. I actually find his political writing easier to understand – but sometimes I skim there too. And I would still be interested in seeing what ESR thinks about the DE, NRx and Modlbug – it’s been a while since the initial prefatory posts where he said he would get into more detail later.
Of course, he’s been really busy recently, but still…
I’m an urbit developer, so if anyone has questions about urbit, feel free to ask me either here or by email (philip@tlon.io).
Hi Philip,
This a clean, smart, logical, very good idea, this is why in the current incarnation it is destined to fail as generally dirty, illogical, bad ideas tend to win as they match the mindset of users, businesses and less professional programmers better.
Consider Google who won through by denying what every programming university taught, that you search for things by primary key or browsing a filtered list but clearly not something as chaotic and error-prone as a free text search. Consider PHP, which is a programming language for non-programmers who have IRC access and thus they can ask how to multiply something by 10 and then the helpful people on IRC say that out of the 4000 built in functions there is a multiply_by_ten(x) for you.
I never understood why the programming blogosphere always talks about scaling _up_. The success between something like PHP is scaling _down_ – that it enabled the average IT guy working at an average backwoods small business to cruft together a guest book somehow.
So my question is the following. Urbit can be a very good basis. But how are you going to make it a bad and dirty thing enough to actually make it popular? Are you going to build a PHP on top of it – i.e. something that enables any clueless loser to build a webshop or suchlike? Because that is how to be popular. Can you provide the kind of technology and platform, some kind of a loser-friendly quick and dirty mess, that actually attracts the countless amateurs who generated the vast majority of web code? Besides PHP wakanda.org is an absolutely excellent example of that. If Nock is a LISP – it looks like one if you look kinda squinty at it – and thus ideal for DSLs, will you make a stupid-friendly DSL and basically advertise that, not Nock and Hoon itself?
@Philip Do you have any insight into why Urbit uses 3-character CVC “syllables” to represent 8 bits rather than the already-established Bubble Babble CVCVC 16-bit “words”? I always wonder why people reinvent a wheel.
@Dividuals, I think you overestimate the “smartness” of Urbit. It’s really quite dumb. Hoon, for example, might be a purely functional language with type inference, but it’s surely the dumbest one in that class. It feels a lot like an imperative language, and Hindley-Milner is nowhere to be found.
Urbit is clean, though. What we’ve found is that the easiest systems to hack on are those ones which are simple and clean to start with. Too many hacks stacked on top of each other, and you can’t do any more hacking or the whole structure will come crashing down like a game of Jenga. It’s harder to hack on the Unix/Internet than it was.
For example, back in the day, the HTML was clean, and you could just write a scraper to get data from any website. Nowadays, there’s so much javascript and other cruft that it’s nearly impossible, at least with traditional, dumb tools. Back in the day, the average IT guy could cruft together a guest book, and it would be sufficient for the task. You don’t see that anymore. The web got too complicated, and it drifted outside the reach of the average IT guy.
You can slop mud onto a system for a long time with no problems, but eventually, it starts to fall over under its own weight. That’s where Unix and the Internet is. It takes professional mudslingers to make it stick without bringing the rest of the system down.
Unix and the Internet were a sufficient substrate for 40+ years of hacking. We’re trying to be the substrate of the future. We’re clean on the bottom so that you can be dirty on the top.
@The Monster, two reasons come to mind:
Firstly, we don’t like the sound of Bubble Babble words. They’re hard to pronounce, and they don’t seem like something that it would be easy to grow attached to. CVC syllables are easier to pronounce and remember. Bubble Babble was designed for communicating fingerprints, whereas our system was designed for remembering. It’s important for our system to be vaguely “human-like”.
Secondly, we care about the eight-bit case. Our “galaxies” are eight-bit addresses, and we would like them to have names that are distinct from longer addresses. “~zod” is much better for our purposes than “xexax”.
@Phillip
I see you using the “galaxies/stars/planets/comets” terminology, which matches the linked paper, but in other places I’ve seen “carriers/cruisers/destroyers/subs”. Which is it? (And why was the other one ever mentioned?)
@The Monster
It’s “galaxies/stars/planets/moons/comets”. Until a few months ago, we used a warship metaphor, but we changed it for a variety of reasons. For one thing, it’s the 32-bit addresses that are human-sized, so saying that everyone gets their own “destroyer” is confusing without explaining the whole metaphor. Plus, space is cool. Anyway, old habits die hard.
@Philip
I’ve downloaded the code but couldn’t get it to build, but that’s not your problem.
So I downloaded with brew (Mac OSX):
brew install –HEAD homebrew/head-only/urbit
and was able to run it (without a network invitation).
When I look at the urbit material (code, docs) I’m reminded of the Codex Seraphinianus.
It’s all vaguely familiar, but enigmatic. So much so that it seems deliberate.
Why?
@John Franklin
The company behind urbit is named Tlon, from the Borges story. Interpret that as you will.
I can assure you that we are not attempting to be enigmatic. If it looks that way, it’s because Curtis (Moldbug) spent over a decade working on this project alone, and if his fertile imagination isn’t kept in check you end up with something absolutely incomprehensible. Two years ago the first outside developers started making significant contributions and the company was born. Since then, it’s gotten so much more understandable than it used to be, but we’ve still got a long way to go. We recognize that its unnecessary strangeness is a problem, and we’re trying to fix it. We apologize.
If you were able to run urbit, did you ever join urbit-meta? It can take a few minutes for the backlog to download, but there’s a helpful community there that can help you understand it all better.
@Philip
Yes, I joined urbit-meta.. at least I talked to someone, somewhere. Asked some questions, got some answers.
Thanks for answering my question here.
> Grab your fedora and your bullwhip, we’re going in…
Forgive me for saying this, but it sounds a bit more like you caught dysentery and the common sense kicked in:
https://www.youtube.com/watch?v=ua_TZ84hmEA
Assuming that you replace Unix and the internet with an Urbit substrate, who’s to say it won’t accrete mud till it collapses also?
Part of the problem, which sets off people’s crackpottery alarms, is that you’re blaming “Unix and the internet” for cruft that accumulated in the layers above those things. In the nineties, Unix supported nearly all the features present in a modern social network: presence information, status updates (.plan files), real time messaging (email, talk, irc), etc. It was simple, relatively robust, and *distributed*. The centralization of online resources happened because companies like Facebook (and earlier, AOL) saw money to be made in the curation of walled gardens, not because of irreparable design flaws in Unix and the internet. We abandoned IRC, email, and fingerd instead of upgrading and hardening them not because the ideas behind them were inherently broken, but because it was easier for people (especially those approaching the profile of the mythical Average User) to switch to Twitter, Facebook, WhatsApp, and whatever walled garden was being heavily marketed to them. The mess we’re in is Endless September fallout, not mistakes in the design of Unix and the network. Could those things be improved? Certainly — the improved versions are called Plan 9 and IPv6. Both of which are experiencing uptake problems; and you think a slash-and-burn “radical rethink” of the platform will fare better?
I’m reminded of Project COSA, whose creator asserts that software is inherently broken because it is based on algorithms, an inherently flawed model; and that the way to fix software is to base it on a “synchronous, signal based model” akin to digital circuit design because digital circuits are reliable and NEVER exhibit bugs. It’s that whole attitude of “Everything you know about software design is fatally flawed! But I, the lone genius, shall correct the mistakes myself; all you need to do is abandon your traditions, knowledge, and experience and come follow me!”
Urbit has more legs than Project COSA, but the best I can say for it is that it could be the PICO-8 of cloud computing.
@Jeff Read
Presence information, .plan, email, talk, irc all work acceptably only with always-on servers. Only one of those do consumers use nowadays, and they use email through some cloud offering like gmail. Email is only distributed if you own your own mail server. Companies do this because they absolutely must have privacy, nerds do this because they’re nerds, and Hillary Clinton did this because she’s rich enough to pay people to run her server. The problem with Unix is not that it’s impossible to write distributed programs — the problem is that consumers don’t have personal servers. Because who wants a Linux server? It’s a full-time job, complete with the job title “sysadmin”, to run a Linux server.
Urbit’s eventual goal is to make managing your personal server as easy as managing your smartphone. You decide what apps to install, make sure it has enough resources, and then get on with your day.
> Email is only distributed if you own your own mail server.
Unfortunately nowadays thanks to proliferation of closed-source cloud-email offering and spam, it is not easy to have one’s own email server, as Bradley M. Kuhn described in “Exercising Software Freedom in the Global Email System”:
https://sfconservancy.org/blog/2015/sep/15/email/
Summary: Bradley Kuhn describes in detail the trouble that Software Freedom Conservancy has encountered by running its own, in-house mail server—specifically, the manual process required to get the server removed from automated blacklists maintained by large email services (which happened probably because of IPv4 reuse, likely previously by a spammer). Outlook.com to be exact.
So reducing barrier to entry to “managing your personal server as easy as managing your smartphone” is not enough…
> Presence information, .plan, email, talk, irc all work acceptably only with always-on servers.
The whole damn internet only works acceptably with always-on servers. We just live in the world where (except for email) the typical user no longer has a local internet
serviceprovider willing to operate those servers for them.@Jakub Narebski
Indeed, I recall vividly the time when I was forced away from my own email server because gmail had me on a blacklist. Even email, a protocol that used to be truly distributed, has become centralized into just a few cloud services. This is one reason sandstorm.io is insufficient — it can’t solve those problems
The specific problem there was IPv4 reuse. In the Urbit whitepaper we write “Any network with disposable identities can only be an antisocial network, because disposable identities cannot be assigned default positive reputation.” If an identity can be sold for $10, then your spam better net you $10 before it’s blacklisted or else you’d be better off selling it. In the Urbit world, your address has value, and it’s yours forever (or at least until you sell it).
This is exactly the sort of problem that comes with Unix and internet, and it’s why we layered over it completely. It’s hard to build a distributed system on top of an antisocial network, so we fixed the network. There’s a whole set of problems like this, and we dealt with as many as we could. Making managing your personal server easy is truly a large problem.
Basically, Unix and the internet were designed in the ’70s to sole ’70s problems. The designs have proven quite effective and malleable, but they’re starting to fall apart at the seams.
@Random832
Exactly. Unfortunately, the double-whammy of changing the behavior of ISPs and getting users to keep servers always on and updated dooms any hope for redeeming the current internet. Unix and the internet were built back when computers were accessible only at institutions that were willing to put significant effort into maintaining servers.
Yeah, except no, no it’s not. IP address reuse is a social problem and there’s nothing in the Urbit infrastructure that I’ve seen so far that prevents someone from buying up blocks of Urbit addresses and then distributing them randomly to clients, reusing them as clients log off, much like ISPs do today. IP address reuse is in part motivated by a painfully small address space; the solution for that is IPv6 and we’re having enough trouble getting uptake on
that.Address reuse, data silos, the “behavior of ISPs” — these are all social problems that exist in the layers
on topof the internet; they are not intrinsic to its architecture. You go from these problems to grand pronouncements like “the internet has failed” and “we need a replacement for the internet from the ground up” while leaving out the bits in the middle that have to be established in order to conclude that B follows from A, hoping your audience doesn’t notice.If you can migrate the world onto a shiny new platform, you can solve the social problems of the current infrastructure without having to go that far. Recapitulating handwavy talking points from your white paper only further convinces me that you are engaged in a bit of rhetorical sleight-of-hand.
@Jeff Read
Apologies for the delay in responding.
There’s a very simple technical solution to that social problem: don’t let ISPs take back addresses. In Urbit, while most addresses are allocated paracentrally (except for the 128-bit comet space, where your address is just a fingerprint of your public key), once an address is allocated, it can’t be retracted. “Allocation” is the act of the parent Urbit signing the new Urbit’s public key. Once it’s done that, there’s no going back, because the new Urbit can prove that the parent did in fact allocate this address. Any further updates to the public key are signed by the previous key. Thus, addresses are cryptographically owned, and there’s no way for the parent to revoke it.
It’s definitely a valid criticism that we haven’t yet done a good enough job describing our technical solutions to the problems we perceive on the internet. Most of the people who understand them because of they understand the code. We’re writing more documentation on these issues (we plan to release a more thorough description of the network architecture very soon, for example), and hopefully that’ll help. In the meantime, I try to answer questions as well as I can.
I make no defense of neoreactionary thought or rhetorical techniques, for I am far from a neoreactionary. However, with Urbit, I think our problem is rather the opposite of what you suggest: the code contains all the meat, and we’ve been so deep in it that we haven’t given much attention to explaining it to the outside world. We’re trying to change that now, but it’s a nontrivial process for a project the size of Urbit. |
6,347 | 在 CentOS 7 中安装并使用自动化工具 Ansible | http://www.linuxtechi.com/install-and-use-ansible-in-centos-7/ | 2015-10-04T10:19:00 | [
"Ansible"
] | https://linux.cn/article-6347-1.html | Ansible是一款为类Unix系统开发的自由开源的配置和自动化工具。它用Python写成,类似于Chef和Puppet,但是有一个不同和优点是我们不需要在节点中安装任何客户端。它使用SSH来和节点进行通信。

本篇中我们将在CentOS 7上安装并配置Ansible,并且尝试管理两个节点。
* **Ansible 服务端** – ansible.linuxtechi.com ( 192.168.1.15 )
* **节点** – 192.168.1.9 , 192.168.1.10
### 第一步: 设置EPEL仓库
Ansible仓库默认不在yum仓库中,因此我们需要使用下面的命令启用epel仓库。
```
[root@ansible ~]# rpm -iUvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
```
### 第二步: 使用yum安装Ansible
```
[root@ansible ~]# yum install ansible
```
安装完成后,检查ansible版本:
```
[root@ansible ~]# ansible --version
```

### 第三步: 设置用于节点鉴权的SSH密钥
在Ansible服务端生成密钥,并且复制公钥到节点中。
```
root@ansible ~]# ssh-keygen
```

使用ssh-copy-id命令来复制Ansible公钥到节点中。

### 第四步:为Ansible定义节点的清单
文件 `/etc/ansible/hosts` 维护着Ansible中服务器的清单。
```
[root@ansible ~]# vi /etc/ansible/hosts
[test-servers]
192.168.1.9
192.168.1.10
```
保存并退出文件。
主机文件示例如下:

### 第五步:尝试在Ansible服务端运行命令
使用ping检查‘test-servers’或者ansible节点的连通性。
```
[root@ansible ~]# ansible -m ping 'test-servers'
```

#### 执行shell命令
**例子1:检查Ansible节点的运行时间(uptime)**
```
[root@ansible ~]# ansible -m command -a "uptime" 'test-servers'
```

**例子2:检查节点的内核版本**
```
[root@ansible ~]# ansible -m command -a "uname -r" 'test-servers'
```

**例子3:给节点增加用户**
```
[root@ansible ~]# ansible -m command -a "useradd mark" 'test-servers'
[root@ansible ~]# ansible -m command -a "grep mark /etc/passwd" 'test-servers'
```

**例子4:重定向输出到文件中**
```
[root@ansible ~]# ansible -m command -a "df -Th" 'test-servers' > /tmp/command-output.txt
```

---
via: <http://www.linuxtechi.com/install-and-use-ansible-in-centos-7/>
作者:[Pradeep Kumar](http://www.linuxtechi.com/author/pradeep/) 译者:[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,348 | RHCSA 系列(十四): 在 RHEL 7 中设置基于 LDAP 的认证 | http://www.tecmint.com/setup-ldap-server-and-configure-client-authentication/ | 2015-10-04T14:41:00 | [
"RHCSA"
] | https://linux.cn/article-6348-1.html | 在这篇文章中,我们将首先罗列一些 LDAP 的基础知识(它是什么,它被用于何处以及为什么会被这样使用),然后向你展示如何使用 RHEL 7 系统来设置一个 LDAP 服务器以及配置一个客户端来使用它达到认证的目的。

*RHCSA 系列:设置 LDAP 服务器及客户端认证 – Part 14*
正如你将看到的那样,关于认证,还存在其他可能的应用场景,但在这篇指南中,我们将只关注基于 LDAP 的认证。另外,请记住,由于这个话题的广泛性,在这里我们将只涵盖它的基础知识,但你可以参考位于总结部分中列出的文档,以此来了解更加深入的细节。
基于相同的原因,你将注意到:为了简洁起见,我已经决定省略了几个位于 man 页中 LDAP 工具的参考,但相应命令的解释是近在咫尺的(例如,输入 man ldapadd)。
那还是让我们开始吧。
**我们的测试环境**
我们的测试环境包含两台 RHEL 7机器:
```
Server: 192.168.0.18. FQDN: rhel7.mydomain.com
Client: 192.168.0.20. FQDN: ldapclient.mydomain.com
```
如若你想,你可以使用在 [RHCSA 系列(十二): 使用 Kickstart 完成 RHEL 7 的自动化安装](/article-6335-1.html) 中使用 Kickstart 安装的机子来作为客户端。
#### LDAP 是什么?
LDAP 代表<ruby> 轻量级目录访问协议 <rp> ( </rp> <rt> Lightweight Directory Access Protocol </rt> <rp> ) </rp></ruby>,并包含在一系列协议之中,这些协议允许一个客户端通过网络去获取集中存储的信息(例如所登录的 shell 的路径,家目录的绝对路径,或者其他典型的系统用户信息),而这些信息可以从不同的地方访问到或被很多终端用户获取到(另一个例子是含有某个公司所有雇员的家庭地址和电话号码的目录)。
对于那些被赋予了权限可以使用这些信息的人来说,将这些信息进行集中管理意味着可以更容易地维护和获取。
下面的图表提供了一个简化了的关于 LDAP 的示意图,在下面将会进行更多的描述:

*LDAP 示意图*
下面是对上面示意图的一个详细解释。
* 在一个 LDAP 目录中,一个<ruby> 条目 <rp> ( </rp> <rt> entry </rt> <rp> ) </rp></ruby>代表一个独立单元或信息,被所谓的<ruby> 区别名 <rp> ( </rp> <rt> DN,Distinguished Name </rt> <rp> ) </rp></ruby> 唯一识别。
* 一个<ruby> 属性 <rp> ( </rp> <rt> attribute </rt> <rp> ) </rp></ruby>是一些与某个条目相关的信息(例如地址,有效的联系电话号码和邮箱地址)。
* 每个属性被分配有一个或多个<ruby> 值 <rp> ( </rp> <rt> value </rt> <rp> ) </rp></ruby>,这些值被包含在一个以空格为分隔符的列表中。每个条目中那个唯一的值被称为一个<ruby> 相对区别名 <rp> ( </rp> <rt> RDN,Relative Distinguished Name </rt> <rp> ) </rp></ruby>。
接下来,就让我们进入到有关服务器和客户端安装的内容。
### 安装和配置一个 LDAP 服务器和客户端
在 RHEL 7 中, LDAP 由 OpenLDAP 实现。为了安装服务器和客户端,分别使用下面的命令:
```
# yum update && yum install openldap openldap-clients openldap-servers
# yum update && yum install openldap openldap-clients nss-pam-ldapd
```
一旦安装完成,我们还需要关注一些事情。除非显示地提示,下面的步骤都只在服务器上执行:
**1. 在服务器和客户端上,为了确保 SELinux 不会妨碍挡道,长久地开启下列的布尔值:**
```
# setsebool -P allow_ypbind=0 authlogin_nsswitch_use_ldap=0
```
其中 `allow_ypbind` 为基于 LDAP 的认证所需要,而 `authlogin_nsswitch_use_ldap`则可能会被某些应用所需要。
**2. 开启并启动服务:**
```
# systemctl enable slapd.service
# systemctl start slapd.service
```
记住你也可以使用 [systemctl](http://www.tecmint.com/manage-services-using-systemd-and-systemctl-in-linux/) 来禁用,重启或停止服务:
```
# systemctl disable slapd.service
# systemctl restart slapd.service
# systemctl stop slapd.service
```
**3. 由于 slapd 服务是由 ldap 用户来运行的(你可以使用 `ps -e -o pid,uname,comm | grep slapd` 来验证),为了使得服务器能够更改由管理工具创建的条目,该用户应该有目录 `/var/lib/ldap` 的所有权,而这些管理工具仅可以由 root 用户来运行(紧接着有更多这方面的内容)。**
在递归地更改这个目录的所有权之前,将 slapd 的示例数据库配置文件复制进这个目录:
```
# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
# chown -R ldap:ldap /var/lib/ldap
```
**4. 设置一个 OpenLDAP 管理用户并设置密码:**
```
# slappasswd
```
正如下一幅图所展示的那样:

*设置 LDAP 管理密码*
然后以下面的内容创建一个 LDIF 文件(`ldaprootpasswd.ldif`):
```
dn: olcDatabase={0}config,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}PASSWORD
```
其中:
* PASSWORD 是先前得到的经过哈希处理的字符串。
* cn=config 指的是全局配置选项。
* olcDatabase 指的是一个特定的数据库实例的名称,并且通常可以在 `/etc/openldap/slapd.d/cn=config` 目录中发现。
根据上面提供的理论背景,`ldaprootpasswd.ldif` 文件将添加一个条目到 LDAP 目录中。在那个条目中,每一行代表一个属性键值对(其中 dn,changetype,add 和 olcRootPW 为属性,每个冒号右边的字符串为相应的键值)。
随着我们的进一步深入,请记住上面的这些,并注意到在这篇文章的余下部分,我们使用相同的<ruby> 通用名 <rp> ( </rp> <rt> Common Names </rt> <rp> ) </rp></ruby> `(cn=)`,而这些余下的步骤中的每一步都将与其上一步相关。
**5. 现在,通过特别指定相对于 ldap 服务的 URI ,添加相应的 LDAP 条目,其中只有 protocol/host/port 这几个域被允许使用。**
```
# ldapadd -H ldapi:/// -f ldaprootpasswd.ldif
```
上面命令的输出应该与下面的图像相似:

*LDAP 配置*
接着从 `/etc/openldap/schema` 目录导入一个基本的 LDAP 定义:
```
# for def in cosine.ldif nis.ldif inetorgperson.ldif; do ldapadd -H ldapi:/// -f /etc/openldap/schema/$def; done
```

*LDAP 定义*
**6. 让 LDAP 在它的数据库中使用你的域名。**
以下面的内容创建另一个 LDIF 文件,我们称之为 `ldapdomain.ldif`, 然后酌情替换这个文件中的域名(在<ruby> 域名部分 <rp> ( </rp> <rt> Domain Component </rt> <rp> ) </rp></ruby> dc=) 和密码:
```
dn: olcDatabase={1}monitor,cn=config
changetype: modify
replace: olcAccess
olcAccess: {0}to * by dn.base="gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth"
read by dn.base="cn=Manager,dc=mydomain,dc=com" read by * none
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=mydomain,dc=com
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=Manager,dc=mydomain,dc=com
dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcRootPW
olcRootPW: {SSHA}PASSWORD
dn: olcDatabase={2}hdb,cn=config
changetype: modify
add: olcAccess
olcAccess: {0}to attrs=userPassword,shadowLastChange by
dn="cn=Manager,dc=mydomain,dc=com" write by anonymous auth by self write by * none
olcAccess: {1}to dn.base="" by * read
olcAccess: {2}to * by dn="cn=Manager,dc=mydomain,dc=com" write by * read
```
接着使用下面的命令来加载:
```
# ldapmodify -H ldapi:/// -f ldapdomain.ldif
```

*LDAP 域名配置*
**7. 现在,该是添加一些条目到我们的 LDAP 目录的时候了。在下面的文件中,属性和键值由一个冒号`(:)` 所分隔,这个文件我们将命名为 `baseldapdomain.ldif`:**
```
dn: dc=mydomain,dc=com
objectClass: top
objectClass: dcObject
objectclass: organization
o: mydomain com
dc: mydomain
dn: cn=Manager,dc=mydomain,dc=com
objectClass: organizationalRole
cn: Manager
description: Directory Manager
dn: ou=People,dc=mydomain,dc=com
objectClass: organizationalUnit
ou: People
dn: ou=Group,dc=mydomain,dc=com
objectClass: organizationalUnit
ou: Group
```
添加条目到 LDAP 目录中:
```
# ldapadd -x -D cn=Manager,dc=mydomain,dc=com -W -f baseldapdomain.ldif
```

*添加 LDAP 域名,属性和键值*
**8. 创建一个名为 ldapuser 的 LDAP 用户(`adduser ldapuser`),然后在`ldapgroup.ldif` 中为一个 LDAP 组创建定义。**
```
# adduser ldapuser
# vi ldapgroup.ldif
```
添加下面的内容:
```
dn: cn=Manager,ou=Group,dc=mydomain,dc=com
objectClass: top
objectClass: posixGroup
gidNumber: 1004
```
其中 gidNumber 是 ldapuser 在 `/etc/group` 中的 GID,然后加载这个文件:
```
# ldapadd -x -W -D "cn=Manager,dc=mydomain,dc=com" -f ldapgroup.ldif
```
**9. 为用户 ldapuser 添加一个带有定义的 LDIF 文件(`ldapuser.ldif`):**
```
dn: uid=ldapuser,ou=People,dc=mydomain,dc=com
objectClass: top
objectClass: account
objectClass: posixAccount
objectClass: shadowAccount
cn: ldapuser
uid: ldapuser
uidNumber: 1004
gidNumber: 1004
homeDirectory: /home/ldapuser
userPassword: {SSHA}fiN0YqzbDuDI0Fpqq9UudWmjZQY28S3M
loginShell: /bin/bash
gecos: ldapuser
shadowLastChange: 0
shadowMax: 0
shadowWarning: 0
```
并加载它:
```
# ldapadd -x -D cn=Manager,dc=mydomain,dc=com -W -f ldapuser.ldif
```

*LDAP 用户配置*
相似地,你可以删除你刚刚创建的用户条目:
```
# ldapdelete -x -W -D cn=Manager,dc=mydomain,dc=com "uid=ldapuser,ou=People,dc=mydomain,dc=com"
```
**10. 允许有关 ldap 的通信通过防火墙:**
```
# firewall-cmd --add-service=ldap
```
**11. 最后,但并非最不重要的是使用 LDAP 开启客户端的认证。**
为了在最后一步中对我们有所帮助,我们将使用 authconfig 工具(一个配置系统认证资源的界面)。
使用下面的命令,在通过 LDAP 服务器认证成功后,假如请求的用户的家目录不存在,则将会被创建:
```
# authconfig --enableldap --enableldapauth --ldapserver=rhel7.mydomain.com --ldapbasedn="dc=mydomain,dc=com" --enablemkhomedir --update
```

*LDAP 客户端认证*
### 总结
在这篇文章中,我们已经解释了如何利用一个 LDAP 服务器来设置基本的认证。若想对当前这个指南里描述的设置进行更深入的配置,请参考位于 RHEL 系统管理员指南里的 [第 13 章 – LDAP 的配置](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/ch-Directory_Servers.html),并特别注意使用 TLS 来进行安全设定。
请随意使用下面的评论框来留下你的提问。
---
via: <http://www.tecmint.com/setup-ldap-server-and-configure-client-authentication/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[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,352 | Linux 内核 0.01 发布纪念日:协作的价值 | http://www.linuxfoundation.org/news-media/blogs/browse/2015/10/anniversary-first-linux-kernel-release-look-collaborative-value | 2015-10-05T08:00:00 | [
"Linux",
"生日"
] | https://linux.cn/article-6352-1.html | 
Linux 社区通常对 Linux 的诞生日有两种看法:
* [8月25日是 Linus Torvalds 首次发布消息说他开始开发 Linux 的日期](/article-6092-1.html)
* **10月5日**则是第一个内核 [0.01](https://www.kernel.org/pub/linux/kernel/Historic/linux-0.01.tar.gz) 发布的日期
为了纪念1991年第一个 Linux 内核的发布,让我们来看看从第一个版本开始到现在发生了什么变化。
* Linux 内核 0.01 只有 10239 行代码(来源: [Wikipedia](https://en.wikipedia.org/wiki/Linux_kernel))。
* 发布于2015年7月的 4.1 版本,已经有了超过1900万行代码(来源: [Phoronix](http://www.phoronix.com/scan.php?page=news_item&px=Linux-19.5M-Stats))。
现在的 Linux 内核是已知最大的协作项目之一的成果。
根据今年二月发布的 Linux 开发报告《[谁写的 Linux](https://www.linuxfoundation.org/news-media/announcements/2015/02/linux-foundation-releases-linux-development-report)》的数据:
* 从10年前有记录起,来自超过 1200 家公司的近 12000 名开发者为 Linux 内核做出了贡献。
* Linux 开发的速度是无与伦比的。接纳到内核的更改数量是平均每小时 7.71 个,换句话说是,每天 185 个更改或每周 1300 个。
近年来,Linux 内核的飞速发展及其带来的创新鼓舞了更多人参与到其中,在适应了它的原则、做法和方法体系后,推动 Linux 成功地解决了一些当今最复杂的技术问题。
就在这周,Linux 基金会以其<ruby> <a href="http://collabprojects.linuxfoundation.org/"> 合作项目 </a> <rp> ( </rp> <rt> Collaborative Projects </rt> <rp> ) </rp></ruby>作为样本发布了[首份开源开发的价值评估报告](https://www.linuxfoundation.org/publications/linux-foundation/estimating-total-development-cost-linux-foundation-collaborative-projects)。报告的数据十分有趣,令人印象深刻,该报告表明 [Linux 基金会合作项目](http://collabprojects.linuxfoundation.org/)的综合价值超过了五亿美金 ([使用 David A. Wheeler 的模型](http://www.dwheeler.com/sloccount/sloccount.html))。
据此报告:
* 在上个月,Linux 基金会合作项目已经有了一亿一千五百万行(115013302)源代码。
* 这些项目里包含1356名开发者花费了超过30年而重新创造的代码。
* 这些工作的经济总价值评估超过了五亿美金。
我们已经从 Linux 中学到了如此之多,没有什么能阻止我们继续获得更多。来和我们一起庆祝 Linux 的纪念日吧,请关注[Linux 基金会的 Twitter 消息](https://twitter.com/linuxfoundation)和我们下周在爱尔兰都柏林的举办的 [LinuxCon Europe](http://events.linuxfoundation.org/events/cloudopen-europe) 上的庆祝[活动](https://twitter.com/eventslf)吧。
| 301 | Moved Permanently | null |
6,362 | RHCSA 系列(十五): 虚拟化基础和使用 KVM 进行虚拟机管理 | http://www.tecmint.com/kvm-virtualization-basics-and-guest-administration/ | 2015-10-07T10:30:00 | [
"RHCSA"
] | https://linux.cn/article-6362-1.html | 假如你在词典中查一下单词 “<ruby> 虚拟化 <rp> ( </rp> <rt> virtualize </rt> <rp> ) </rp></ruby>”,你将会发现它的意思是 “创造某些事物的一个虚拟物(而非真实的)”。在计算机行业中,术语<ruby> 虚拟化 <rp> ( </rp> <rt> virtualization </rt> <rp> ) </rp></ruby>指的是:在相同的物理(硬件)系统上,同时运行多个操作系统,且这几个系统相互隔离的**可能性**,而那个硬件在虚拟化架构中被称作<ruby> 宿主机 <rp> ( </rp> <rt> host </rt> <rp> ) </rp></ruby>。

*RHCSA 系列: 虚拟化基础和使用 KVM 进行虚拟机管理 – Part 15*
通过使用虚拟机监视器(也被称为<ruby> 虚拟机管理程序 <rp> ( </rp> <rt> hypervisor </rt> <rp> ) </rp></ruby>),虚拟机(被称为 guest)由底层的硬件来供给虚拟资源(举几个例子来说,如 CPU,RAM,存储介质,网络接口等)。
考虑到这一点就可以清楚地看出,虚拟化的主要优点是节约成本(在设备和网络基础设施,及维护工作等方面)和显著地减少容纳所有必要硬件所需的物理空间。
由于这个简单的指南不能涵盖所有的虚拟化方法,我鼓励你参考在总结部分中列出的文档,以此对这个话题做更深入的了解。
请记住当前文章只是用于在 RHEL 7 中用命令行工具使用 [KVM](http://www.linux-kvm.org/page/Main_Page) (<ruby> Kernel-based Virtual Machine <rp> ( </rp> <rt> 基于内核的虚拟机 </rt> <rp> ) </rp></ruby>) 学习虚拟化基础知识的一个起点,而并不是对这个话题的深入探讨。
### 检查硬件要求并安装软件包
为了设置虚拟化,你的 CPU 必须能够支持它。你可以使用下面的命令来查看你的系统是否满足这个要求:
```
# grep -E 'svm|vmx' /proc/cpuinfo
```
在下面的截图中,我们可以看到当前的系统(带有一个 AMD 的微处理器)支持虚拟化,svm 字样的存在暗示了这一点。假如我们有一个 Intel 系列的处理器,我们将会看到上面命令的结果将会出现 vmx 字样。

*检查 KVM 支持*
另外,你需要在你宿主机的硬件(BIOS 或 UEFI)中开启虚拟化。
现在,安装必要的软件包:
* qemu-kvm 是一个开源的虚拟机程序,为 KVM 虚拟机监视器提供硬件仿真,而 qemu-img 则提供了一个操纵磁盘镜像的命令行工具。
* libvirt 包含与操作系统的虚拟化功能交互的工具。
* libvirt-python 包含一个模块,它允许用 Python 写的应用来使用由 libvirt 提供的接口。
* libguestfs-tools 包含各式各样的针对虚拟机的系统管理员命令行工具。
* virt-install 包含针对虚拟机管理的其他命令行工具。
命令如下:
```
# yum update && yum install qemu-kvm qemu-img libvirt libvirt-python libguestfs-tools virt-install
```
一旦安装完成,请确保你启动并开启了 libvirtd 服务:
```
# systemctl start libvirtd.service
# systemctl enable libvirtd.service
```
默认情况下,每个虚拟机将只能够与放在相同的物理服务器上的虚拟机以及宿主机自身通信。要使得虚拟机能够访问位于局域网或因特网中的其他机器,我们需要像下面这样在我们的宿主机上设置一个桥接接口(比如说 br0):
1、 添加下面的一行到我们的 NIC 主配置中(类似 `/etc/sysconfig/network-scripts/ifcfg-enp0s3` 这样的文件):
```
BRIDGE=br0
```
2、 使用下面的内容(注意,你可能需要更改 IP 地址,网关地址和 DNS 信息)为 br0 创建一个配置文件(`/etc/sysconfig/network-scripts/ifcfg-br0`):
```
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
IPADDR=192.168.0.18
NETMASK=255.255.255.0
GATEWAY=192.168.0.1
NM_CONTROLLED=no
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=br0
ONBOOT=yes
DNS1=8.8.8.8
DNS2=8.8.4.4
```
3、 最后在文件`/etc/sysctl.conf` 中设置:
```
net.ipv4.ip_forward = 1
```
来开启包转发并加载更改到当前的内核配置中:
```
# sysctl -p
```
注意,你可能还需要告诉 firewalld 让这类的流量应当被允许通过防火墙。假如你需要这样做,记住你可以参考这个系列的 [使用 firewalld 和 iptables 来控制网络流量](/article-6315-1.html)。
### 创建虚拟机镜像
默认情况下,虚拟机镜像将会被创建到 `/var/lib/libvirt/images` 中,且强烈建议你不要更改这个设定,除非你真的需要那么做且知道你在做什么,并能自己处理有关 SELinux 的设定(这个话题已经超出了本教程的讨论范畴,但你可以参考这个系列的第 13 部分 [使用 SELinux 来进行强制访问控制](/article-6339-1.html),假如你想更新你的知识的话)。
这意味着你需要确保你在文件系统中分配了必要的空间来容纳你的虚拟机。
下面的命令将使用位于 `/home/gacanepa/ISOs`目录下的 rhel-server-7.0-x86\_64-dvd.iso 镜像文件和 br0 这个网桥来创建一个名为 `tecmint-virt01` 的虚拟机,它有一个虚拟 CPU,1 GB(=1024 MB)的 RAM,20 GB 的磁盘空间(由`/var/lib/libvirt/images/tecmint-virt01.img`所代表):
```
# virt-install \
--network bridge=br0
--name tecmint-virt01 \
--ram=1024 \
--vcpus=1 \
--disk path=/var/lib/libvirt/images/tecmint-virt01.img,size=20 \
--graphics none \
--cdrom /home/gacanepa/ISOs/rhel-server-7.0-x86_64-dvd.iso
--extra-args="console=tty0 console=ttyS0,115200"
```
假如安装文件位于一个 HTTP 服务器上,而不是存储在你磁盘中的镜像中,你必须将上面的 `-cdrom` 替换为 `-location`,并明确地指出在线存储仓库的地址。
至于上面的 `–graphics none` 选项,它告诉安装程序只以文本模式执行安装过程。假如你使用一个 GUI 界面和一个 VNC 窗口来访问主虚拟机控制台,则可以省略这个选项。最后,使用 `–extra-args` 参数,我们将传递内核启动参数给安装程序,以此来设置一个串行的虚拟机控制台。
现在,所安装的虚拟机应当可以作为一个正常的(真实的)服务来运行了。假如没有,请查看上面列出的步骤。
### 管理虚拟机
作为一个系统管理员,还有一些典型的管理任务需要你在虚拟机上去完成。注:下面所有的命令都需要在你的宿主机上运行:
**1. 列出所有的虚拟机:**
```
# virsh list --all
```
你必须留意上面命令输出中的虚拟机 ID(尽管上面的命令还会返回虚拟机的名称和当前的状态),因为你需要它来执行有关某个虚拟机的大多数管理任务。
**2. 显示某个虚拟机的信息:**
```
# virsh dominfo [VM Id]
```
**3. 开启,重启或停止一个虚拟机操作系统:**
```
# virsh start | reboot | shutdown [VM Id]
```
**4. 假如网络无法连接且在宿主机上没有运行 X 服务器,可以使用下面的命令来访问虚拟机的串行控制台:**
```
# virsh console [VM Id]
```
**注**:这需要你添加一个串行控制台配置信息到 `/etc/grub.conf` 文件中(参考刚才创建虚拟机时传递给`-extra-args`选项的参数)。
**5. 修改分配的内存或虚拟 CPU:**
首先,关闭虚拟机:
```
# virsh shutdown [VM Id]
```
为 RAM 编辑虚拟机的配置:
```
# virsh edit [VM Id]
```
然后更改
```
<memory>[内存大小,注意不要加上方括号]</memory>
```
使用新的设定重启虚拟机:
```
# virsh create /etc/libvirt/qemu/tecmint-virt01.xml
```
最后,可以使用下面的命令来动态地改变内存的大小:
```
# virsh setmem [VM Id] [内存大小,这里没有括号]
```
对于 CPU,使用:
```
# virsh edit [VM Id]
```
然后更改
```
<cpu>[CPU 数目,这里没有括号]</cpu>
```
至于更深入的命令和细节,请参考 RHEL 5 虚拟化指南(这个指南尽管有些陈旧,但包括了用于管理虚拟机的 virsh 命令的详尽清单)的第 26 章里的表 26.1。
### 总结
在这篇文章中,我们涵盖了在 RHEL 7 中如何使用 KVM 和虚拟化的一些基本概念,这个话题是一个广泛且令人着迷的话题。并且我希望它能成为你在随后阅读官方的 [RHEL 虚拟化入门](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Getting_Started_Guide/index.html) 和 [RHEL 虚拟化部署和管理指南](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Virtualization_Deployment_and_Administration_Guide/index.html) ,探索更高级的主题时的起点教程,并给你带来帮助。
另外,为了分辨或拓展这里解释的某些概念,你还可以参考先前包含在 [KVM 系列](http://www.tecmint.com/install-and-configure-kvm-in-linux/) 中的文章。
---
via: <http://www.tecmint.com/kvm-virtualization-basics-and-guest-administration/>
作者:[Gabriel Cánepa](http://www.tecmint.com/author/gacanepa/) 译者:[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,365 | 看看新的 Ubuntu 15.10 默认壁纸 | http://www.omgubuntu.co.uk/2015/09/ubuntu-15-10-wily-werewolf-default-wallpaper | 2015-10-07T23:21:00 | [
"Ubuntu"
] | https://linux.cn/article-6365-1.html | **全新的Ubuntu 15.10 Wily Werewolf默认壁纸已经亮相**
乍一看你几乎无法发现与今天4月发布的Ubuntu 15.04中受到折纸启发的‘Suru’设计有什么差别。但是仔细看你就会发现默认背景有一些细微差别。
其中一点是更淡,受到由左上角图片发出的橘黄色光的帮助。保持了角褶皱和色块,但是增加了块和矩形部分。
新的背景由Canonica设计团队的Alex Milazzo设计。

*Ubuntu 15.10 默认桌面背景*
为了凸显变化,这个是Ubuntu 15.04的默认壁纸作为比较:

*Ubuntu 15.04 默认壁纸*
### 下载Ubuntu 15.10 壁纸
如果你正运行的是Ubuntu 15.10 Wily Werewolf每日构建版本,那么你无法看到这个默认壁纸:设计已经亮相但是还没有打包到Wily中。
你不必等到10月份来使用新的设计来作为你的桌面背景。你可以点击下面的按钮下载4096×2304高清壁纸。
* [下载Ubuntu 15.10新的默认壁纸](https://launchpadlibrarian.net/218258177/Wolf_Wallpaper_Desktop_4096x2304_Purple_PNG-24.png)
最后,如我们每次在有新壁纸时说的,你不必在意发布版品牌和设计细节。如果壁纸不合你的口味或者不想永远用它,轻易地就换掉,毕竟这不是Ubuntu Phone!
**你是新版本的粉丝么?在评论中让我们知道**
---
via: <http://www.omgubuntu.co.uk/2015/09/ubuntu-15-10-wily-werewolf-default-wallpaper>
作者:[Joey-Elijah Sneddon](https://plus.google.com/117485690627814051450/?rel=author) 译者:[geekpi](https://github.com/geekpi) 校对:[wxy](https://github.com/wxy)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
| 301 | Moved Permanently | null |
Subsets and Splits