﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-方枪枪的java世界</title><link>http://www.blogjava.net/tiandizhijian/</link><description>不要因为风雨飘落就停止了你的脚步，真正的得失就在你的心中。
做喜欢做的事，不轻言放弃！</description><language>zh-cn</language><lastBuildDate>Sun, 12 Apr 2026 13:31:42 GMT</lastBuildDate><pubDate>Sun, 12 Apr 2026 13:31:42 GMT</pubDate><ttl>60</ttl><item><title>Centos6.4_Hadoop2.6.0 环境搭建_Centos6.4下安装配置FTP Server</title><link>http://www.blogjava.net/tiandizhijian/archive/2017/01/07/432251.html</link><dc:creator>做强大的自己</dc:creator><author>做强大的自己</author><pubDate>Sat, 07 Jan 2017 11:44:00 GMT</pubDate><guid>http://www.blogjava.net/tiandizhijian/archive/2017/01/07/432251.html</guid><wfw:comment>http://www.blogjava.net/tiandizhijian/comments/432251.html</wfw:comment><comments>http://www.blogjava.net/tiandizhijian/archive/2017/01/07/432251.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tiandizhijian/comments/commentRss/432251.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tiandizhijian/services/trackbacks/432251.html</trackback:ping><description><![CDATA[<p style="margin: 0px 0px 0.75em; font-size: 16px; line-height: 27.2px; text-indent: 1em; color: #333333; font-family: 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; background-color: #fefefe;"><br />1、<span style="line-height: 27.2px;">service iptables off</span><br /><span style="line-height: 27.2px;">&nbsp; &nbsp; &nbsp;参考命令：<br />&nbsp; &nbsp; &nbsp;service iptables stop</span><br />&nbsp; &nbsp; &nbsp;service iptables start<br /><span style="line-height: 27.2px;">&nbsp; &nbsp; &nbsp;service iptables restart<br /><br />2、yum &nbsp;install &nbsp;vsftpd &nbsp; -y<br /><br />3</span><span style="line-height: 27.2px;">、yum &nbsp;install &nbsp;db4 &nbsp;-y<br /><br /></span><br /><span style="line-height: 27.2px;"><br /></span><br /><span style="line-height: 27.2px;"><br /></span><br /><br /></p><img src ="http://www.blogjava.net/tiandizhijian/aggbug/432251.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tiandizhijian/" target="_blank">做强大的自己</a> 2017-01-07 19:44 <a href="http://www.blogjava.net/tiandizhijian/archive/2017/01/07/432251.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Centos6.4_Hadoop2.6.0 环境搭建_Centos6.4下安装配置FTP Server</title><link>http://www.blogjava.net/tiandizhijian/archive/2017/01/07/432252.html</link><dc:creator>做强大的自己</dc:creator><author>做强大的自己</author><pubDate>Sat, 07 Jan 2017 11:44:00 GMT</pubDate><guid>http://www.blogjava.net/tiandizhijian/archive/2017/01/07/432252.html</guid><wfw:comment>http://www.blogjava.net/tiandizhijian/comments/432252.html</wfw:comment><comments>http://www.blogjava.net/tiandizhijian/archive/2017/01/07/432252.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tiandizhijian/comments/commentRss/432252.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tiandizhijian/services/trackbacks/432252.html</trackback:ping><description><![CDATA[<p style="margin: 0px 0px 0.75em; font-size: 16px; line-height: 27.2px; text-indent: 1em; color: #333333; font-family: 'Helvetica Neue', Helvetica, Tahoma, Arial, STXihei, 'Microsoft YaHei', 微软雅黑, sans-serif; background-color: #fefefe;"><br />1、<span style="line-height: 27.2px;">service iptables off</span><br /><span style="line-height: 27.2px;">&nbsp; &nbsp; &nbsp;参考命令：<br />&nbsp; &nbsp; &nbsp;service iptables stop</span><br />&nbsp; &nbsp; &nbsp;service iptables start<br /><span style="line-height: 27.2px;">&nbsp; &nbsp; &nbsp;service iptables restart<br /><br />2、yum &nbsp;install &nbsp;vsftpd &nbsp; -y<br /><br />3</span><span style="line-height: 27.2px;">、yum &nbsp;install &nbsp;db4 &nbsp;-y<br /><br /></span><br /><span style="line-height: 27.2px;"><br /></span><br /><span style="line-height: 27.2px;"><br /></span><br /><br /></p><img src ="http://www.blogjava.net/tiandizhijian/aggbug/432252.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tiandizhijian/" target="_blank">做强大的自己</a> 2017-01-07 19:44 <a href="http://www.blogjava.net/tiandizhijian/archive/2017/01/07/432252.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux入门教程（六）linux磁盘管理</title><link>http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432231.html</link><dc:creator>做强大的自己</dc:creator><author>做强大的自己</author><pubDate>Sun, 01 Jan 2017 06:44:00 GMT</pubDate><guid>http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432231.html</guid><wfw:comment>http://www.blogjava.net/tiandizhijian/comments/432231.html</wfw:comment><comments>http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432231.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tiandizhijian/comments/commentRss/432231.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tiandizhijian/services/trackbacks/432231.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 第八章&nbsp;Linux磁盘管理【查看磁盘或者目录的容量&nbsp;df&nbsp;和&nbsp;du】df&nbsp;查看已挂载磁盘的总容量、使用容量、剩余容量等，可以不加任何参数，默认是按k为单位显示的df常用参数有&nbsp;&#8211;i -h -k &#8211;m等-i&nbsp;使用inodes&nbsp;显示结果-h&nbsp;使用合适的单位显示，例如G-k -m&nbsp;...&nbsp;&nbsp;<a href='http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432231.html'>阅读全文</a><img src ="http://www.blogjava.net/tiandizhijian/aggbug/432231.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tiandizhijian/" target="_blank">做强大的自己</a> 2017-01-01 14:44 <a href="http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432231.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux入门教程（五）linux系统用户以及用户组管理</title><link>http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432230.html</link><dc:creator>做强大的自己</dc:creator><author>做强大的自己</author><pubDate>Sun, 01 Jan 2017 06:42:00 GMT</pubDate><guid>http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432230.html</guid><wfw:comment>http://www.blogjava.net/tiandizhijian/comments/432230.html</wfw:comment><comments>http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432230.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tiandizhijian/comments/commentRss/432230.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tiandizhijian/services/trackbacks/432230.html</trackback:ping><description><![CDATA[<p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="text-align: center; font-family: 宋体; font-size: 15pt; background-color: #ffffff;"><strong>第七章</strong></span><span style="text-align: center; font-family: Calibri; font-size: 15pt; background-color: #ffffff;"><strong>	linux</strong></span><span style="text-align: center; font-family: 宋体; font-size: 15pt; background-color: #ffffff;"><strong>系统用户以及用户组管理</strong></span><br /><span style="font-family: Calibri; font-size: 10.5pt;"><strong>【</strong></span><span style="font-family: 宋体; font-size: 10.5pt;"><strong>认识</strong></span><span style="font-family: Calibri; font-size: 10.5pt;"><strong>/etc/passwd</strong></span><span style="font-family: 宋体; font-size: 10.5pt;"><strong>和</strong></span><span style="font-family: Calibri; font-size: 10.5pt;"><strong>/etc/shadow】</strong></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal; text-indent: 21pt;"><span style="font-family: 宋体; font-size: 10.5pt;">这两个文件可以说是</span><span style="font-family: Calibri; font-size: 10.5pt;">linux</span><span style="font-family: 宋体; font-size: 10.5pt;">系统中最重要的文件之一</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">如果没有这两个文件或者这两个文件出问题，则你是无法正常登录</span><span style="font-family: Calibri; font-size: 10.5pt;">linux</span><span style="font-family: 宋体; font-size: 10.5pt;">系统的</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_1.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">/etc/passwd</span><span style="font-family: 宋体; font-size: 10.5pt;">由</span><span style="font-family: Calibri; font-size: 10.5pt;">&#8217;:&#8217;</span><span style="font-family: 宋体; font-size: 10.5pt;">分割成</span><span style="font-family: Calibri; font-size: 10.5pt;">7</span><span style="font-family: 宋体; font-size: 10.5pt;">个字段，每个字段的具体含义是：</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">1</span><span style="font-family: 宋体; font-size: 10.5pt;">）用户名（如第一行中的</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">就是用户名），代表用户账号的字符串</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">用户名字符可以是大小写字母</span><span style="font-family: Calibri; font-size: 10.5pt;">、</span><span style="font-family: 宋体; font-size: 10.5pt;">数字</span><span style="font-family: Calibri; font-size: 10.5pt;">、</span><span style="font-family: 宋体; font-size: 10.5pt;">减号（不能出现在首位）</span><span style="font-family: Calibri; font-size: 10.5pt;">、</span><span style="font-family: 宋体; font-size: 10.5pt;">点以及下划线，其他字符不合法</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">虽然用户名中可以出现点，但不建议使用，尤其是首位为点时，另外减号也不建议使用，因为容易造成混淆</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">2</span><span style="font-family: 宋体; font-size: 10.5pt;">）存放的就是该账号的口令，为什么是</span><span style="font-family: Calibri; font-size: 10.5pt;">&#8217;x&#8217;</span><span style="font-family: 宋体; font-size: 10.5pt;">呢？早期的</span><span style="font-family: Calibri; font-size: 10.5pt;">unix</span><span style="font-family: 宋体; font-size: 10.5pt;">系统口令确实是存放在这里，但基于安全因素，后来就将其存放到</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/shadow</span><span style="font-family: 宋体; font-size: 10.5pt;">中了，在这里只用一个</span><span style="font-family: Calibri; font-size: 10.5pt;">&#8217;x&#8217;</span><span style="font-family: 宋体; font-size: 10.5pt;">代替</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">3</span><span style="font-family: 宋体; font-size: 10.5pt;">）这个数字代表用户标识号，也叫做</span><span style="font-family: Calibri; font-size: 10.5pt;">uid。</span><span style="font-family: 宋体; font-size: 10.5pt;">系统识别用户身份就是通过这个数字来的，</span><span style="font-family: Calibri; font-size: 10.5pt;">0</span><span style="font-family: 宋体; font-size: 10.5pt;">就是</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">，也就是说你可以修改</span><span style="font-family: Calibri; font-size: 10.5pt;">test</span><span style="font-family: 宋体; font-size: 10.5pt;">用户的</span><span style="font-family: Calibri; font-size: 10.5pt;">uid</span><span style="font-family: 宋体; font-size: 10.5pt;">为</span><span style="font-family: Calibri; font-size: 10.5pt;">0</span><span style="font-family: 宋体; font-size: 10.5pt;">，那么系统会认为</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">和</span><span style="font-family: Calibri; font-size: 10.5pt;">test</span><span style="font-family: 宋体; font-size: 10.5pt;">为同一个账户</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">通常</span><span style="font-family: Calibri; font-size: 10.5pt;">uid</span><span style="font-family: 宋体; font-size: 10.5pt;">的取值范围是</span><span style="font-family: Calibri; font-size: 10.5pt;">0~65535</span><span style="font-family: 宋体; font-size: 10.5pt;">，</span><span style="font-family: Calibri; font-size: 10.5pt;">0</span><span style="font-family: 宋体; font-size: 10.5pt;">是超级用户（</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">）的标识号，</span><span style="font-family: Calibri; font-size: 10.5pt;">1~499</span><span style="font-family: 宋体; font-size: 10.5pt;">由系统保留，作为管理账号，普通用户的标识号从</span><span style="font-family: Calibri; font-size: 10.5pt;">500</span><span style="font-family: 宋体; font-size: 10.5pt;">开始，如果我们自定义建立一个普通用户，你会看到该账户的标识号是大于或等于</span><span style="font-family: Calibri; font-size: 10.5pt;">500</span><span style="font-family: 宋体; font-size: 10.5pt;">的</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">4</span><span style="font-family: 宋体; font-size: 10.5pt;">）表示组标识号，也叫做</span><span style="font-family: Calibri; font-size: 10.5pt;">gid。</span><span style="font-family: 宋体; font-size: 10.5pt;">这个字段对应着</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/group&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">中的一条记录，其实</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/group</span><span style="font-family: 宋体; font-size: 10.5pt;">和</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/passwd</span><span style="font-family: 宋体; font-size: 10.5pt;">基本上类似</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">5</span><span style="font-family: 宋体; font-size: 10.5pt;">）注释说明，该字段没有实际意义，通常记录该用户的一些属性，例如姓名</span><span style="font-family: Calibri; font-size: 10.5pt;">、</span><span style="font-family: 宋体; font-size: 10.5pt;">电话</span><span style="font-family: Calibri; font-size: 10.5pt;">、</span><span style="font-family: 宋体; font-size: 10.5pt;">地址等等</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">不过，当你使用</span><span style="font-family: Calibri; font-size: 10.5pt;">finger</span><span style="font-family: 宋体; font-size: 10.5pt;">的功能时就会显示这些信息的（稍后做介绍）</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">6</span><span style="font-family: 宋体; font-size: 10.5pt;">）用户的家目录，当用户登录时就处在这个目录下</span><span style="font-family: Calibri; font-size: 10.5pt;">。root</span><span style="font-family: 宋体; font-size: 10.5pt;">的家目录是</span><span style="font-family: Calibri; font-size: 10.5pt;">/root</span><span style="font-family: 宋体; font-size: 10.5pt;">，普通用户的家目录则为</span><span style="font-family: Calibri; font-size: 10.5pt;">/home/username</span><span style="font-family: 宋体; font-size: 10.5pt;">，这个字段是可以自定义的，比如你建立一个普通用户</span><span style="font-family: Calibri; font-size: 10.5pt;">test1</span><span style="font-family: 宋体; font-size: 10.5pt;">，要想让</span><span style="font-family: Calibri; font-size: 10.5pt;">test1</span><span style="font-family: 宋体; font-size: 10.5pt;">的家目录在</span><span style="font-family: Calibri; font-size: 10.5pt;">/data</span><span style="font-family: 宋体; font-size: 10.5pt;">目录下，只要修改</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/passwd</span><span style="font-family: 宋体; font-size: 10.5pt;">文件中</span><span style="font-family: Calibri; font-size: 10.5pt;">test1</span><span style="font-family: 宋体; font-size: 10.5pt;">那行中的该字段为</span><span style="font-family: Calibri; font-size: 10.5pt;">/data</span><span style="font-family: 宋体; font-size: 10.5pt;">即可</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">7</span><span style="font-family: 宋体; font-size: 10.5pt;">）</span><span style="font-family: Calibri; font-size: 10.5pt;">shell</span><span style="font-family: 宋体; font-size: 10.5pt;">，用户登录后要启动一个进程，用来将用户下达的指令传给内核，这就是</span><span style="font-family: Calibri; font-size: 10.5pt;">shell。Linux</span><span style="font-family: 宋体; font-size: 10.5pt;">的</span><span style="font-family: Calibri; font-size: 10.5pt;">shell</span><span style="font-family: 宋体; font-size: 10.5pt;">有很多种</span><span style="font-family: Calibri; font-size: 10.5pt;">sh, csh, ksh, tcsh, bash</span><span style="font-family: 宋体; font-size: 10.5pt;">等，而</span><span style="font-family: Calibri; font-size: 10.5pt;">Redhat/CentOS</span><span style="font-family: 宋体; font-size: 10.5pt;">的</span><span style="font-family: Calibri; font-size: 10.5pt;">shell</span><span style="font-family: 宋体; font-size: 10.5pt;">就是</span><span style="font-family: Calibri; font-size: 10.5pt;">bash。</span><span style="font-family: 宋体; font-size: 10.5pt;">查看</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/passwd</span><span style="font-family: 宋体; font-size: 10.5pt;">文件，该字段中除了</span><span style="font-family: Calibri; font-size: 10.5pt;">/bin/bash</span><span style="font-family: 宋体; font-size: 10.5pt;">外还有</span><span style="font-family: Calibri; font-size: 10.5pt;">/sbin/nologin</span><span style="font-family: 宋体; font-size: 10.5pt;">比较多，它表示不允许该账号登录</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">如果你想建立一个账号不让他登录，那么就可以把该字段改成</span><span style="font-family: Calibri; font-size: 10.5pt;">/sbin/nologin</span><span style="font-family: 宋体; font-size: 10.5pt;">，默认是</span><span style="font-family: Calibri; font-size: 10.5pt;">/bin/bash。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_12.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">再来看看</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/shadow</span><span style="font-family: 宋体; font-size: 10.5pt;">这个文件，和</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/passwd</span><span style="font-family: 宋体; font-size: 10.5pt;">类似，用</span><span style="font-family: Calibri; font-size: 10.5pt;">&#8221;:&#8221;</span><span style="font-family: 宋体; font-size: 10.5pt;">分割成</span><span style="font-family: Calibri; font-size: 10.5pt;">9</span><span style="font-family: 宋体; font-size: 10.5pt;">个字段</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">1</span><span style="font-family: 宋体; font-size: 10.5pt;">）用户名，跟</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/passwd</span><span style="font-family: 宋体; font-size: 10.5pt;">对应</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">2</span><span style="font-family: 宋体; font-size: 10.5pt;">）用户密码，这个才是该账号的真正的密码，不过这个密码已经加密过了，但是有些黑客还是能够解密的</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">所以为了安全，该文件属性设置为</span><span style="font-family: Calibri; font-size: 10.5pt;">600</span><span style="font-family: 宋体; font-size: 10.5pt;">，只允许</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">读写</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">3</span><span style="font-family: 宋体; font-size: 10.5pt;">）上次更改密码的日期，这个数字是这样计算得来的，距离</span><span style="font-family: Calibri; font-size: 10.5pt;">1970</span><span style="font-family: 宋体; font-size: 10.5pt;">年</span><span style="font-family: Calibri; font-size: 10.5pt;">1</span><span style="font-family: 宋体; font-size: 10.5pt;">月</span><span style="font-family: Calibri; font-size: 10.5pt;">1</span><span style="font-family: 宋体; font-size: 10.5pt;">日到上次更改密码的日期，例如上次更改密码的日期为</span><span style="font-family: Calibri; font-size: 10.5pt;">2012</span><span style="font-family: 宋体; font-size: 10.5pt;">年</span><span style="font-family: Calibri; font-size: 10.5pt;">1</span><span style="font-family: 宋体; font-size: 10.5pt;">月</span><span style="font-family: Calibri; font-size: 10.5pt;">1</span><span style="font-family: 宋体; font-size: 10.5pt;">日，则这个值就是</span><span style="font-family: Calibri; font-size: 10.5pt;">365*</span><span style="font-family: 宋体; font-size: 10.5pt;">（</span><span style="font-family: Calibri; font-size: 10.5pt;">2012-1970</span><span style="font-family: 宋体; font-size: 10.5pt;">）</span><span style="font-family: Calibri; font-size: 10.5pt;">+1=15331。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">4</span><span style="font-family: 宋体; font-size: 10.5pt;">）要过多少天才可以更改密码，默认是</span><span style="font-family: Calibri; font-size: 10.5pt;">0</span><span style="font-family: 宋体; font-size: 10.5pt;">，即不限制</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">5</span><span style="font-family: 宋体; font-size: 10.5pt;">）密码多少天后到期</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">即在多少天内必须更改密码，例如这里设置成</span><span style="font-family: Calibri; font-size: 10.5pt;">30</span><span style="font-family: 宋体; font-size: 10.5pt;">，则</span><span style="font-family: Calibri; font-size: 10.5pt;">30</span><span style="font-family: 宋体; font-size: 10.5pt;">天内必须更改一次密码，否则将不能登录系统，默认是</span><span style="font-family: Calibri; font-size: 10.5pt;">99999</span><span style="font-family: 宋体; font-size: 10.5pt;">，可以理解为永远不需要改</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">6</span><span style="font-family: 宋体; font-size: 10.5pt;">）密码到期前的警告期限，若这个值设置成</span><span style="font-family: Calibri; font-size: 10.5pt;">7</span><span style="font-family: 宋体; font-size: 10.5pt;">，则表示当</span><span style="font-family: Calibri; font-size: 10.5pt;">7</span><span style="font-family: 宋体; font-size: 10.5pt;">天后密码过期时，系统就发出警告告诉用户，提醒用户他的密码将在</span><span style="font-family: Calibri; font-size: 10.5pt;">7</span><span style="font-family: 宋体; font-size: 10.5pt;">天后到期</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">7</span><span style="font-family: 宋体; font-size: 10.5pt;">）账号失效期限</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">你可以这样理解，如果设置这个值为</span><span style="font-family: Calibri; font-size: 10.5pt;">3</span><span style="font-family: 宋体; font-size: 10.5pt;">，则表示：密码已经到期，然而用户并没有在到期前修改密码，那么再过</span><span style="font-family: Calibri; font-size: 10.5pt;">3</span><span style="font-family: 宋体; font-size: 10.5pt;">天，则这个账号就失效了，即锁定了</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">8</span><span style="font-family: 宋体; font-size: 10.5pt;">）账号的生命周期，跟第三段一样，是按距离</span><span style="font-family: Calibri; font-size: 10.5pt;">1970</span><span style="font-family: 宋体; font-size: 10.5pt;">年</span><span style="font-family: Calibri; font-size: 10.5pt;">1</span><span style="font-family: 宋体; font-size: 10.5pt;">月</span><span style="font-family: Calibri; font-size: 10.5pt;">1</span><span style="font-family: 宋体; font-size: 10.5pt;">日多少天算的</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">它表示的含义是，账号在这个日期前可以使用，到期后账号作废</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">9</span><span style="font-family: 宋体; font-size: 10.5pt;">）作为保留用的，没有什么意义</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><strong>【</strong></span><span style="font-family: 宋体; font-size: 10.5pt;"><strong>新增</strong></span><span style="font-family: Calibri; font-size: 10.5pt;"><strong>/</strong></span><span style="font-family: 宋体; font-size: 10.5pt;"><strong>删除用户和用户组</strong></span><span style="font-family: Calibri; font-size: 10.5pt;"><strong>】</strong></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">a.&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">新增一个组</span><span style="font-family: Calibri; font-size: 10.5pt;">&nbsp;groupadd [-g GID] groupname</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_13.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">不加</span><span style="font-family: Calibri; font-size: 10.5pt;">-g&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">则按照系统默认的</span><span style="font-family: Calibri; font-size: 10.5pt;">gid</span><span style="font-family: 宋体; font-size: 10.5pt;">创建组，跟用户一样，</span><span style="font-family: Calibri; font-size: 10.5pt;">gid</span><span style="font-family: 宋体; font-size: 10.5pt;">也是从</span><span style="font-family: Calibri; font-size: 10.5pt;">500</span><span style="font-family: 宋体; font-size: 10.5pt;">开始的</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_14.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">-g</span><span style="font-family: 宋体; font-size: 10.5pt;">选项可以自定义</span><span style="font-family: Calibri; font-size: 10.5pt;">gid</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">b.&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">删除组</span><span style="font-family: Calibri; font-size: 10.5pt;">&nbsp;gropudel groupname</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_15.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">没有特殊选项</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">c.&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">增加用户</span><span style="font-family: Calibri; font-size: 10.5pt;">&nbsp;useradd [-u UID] [-g GID] [-d HOME] [-M] [-s]</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">-u&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">自定义</span><span style="font-family: Calibri; font-size: 10.5pt;">UID</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">-g&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">使其属于已经存在的某个</span><span style="font-family: Calibri; font-size: 10.5pt;">GID</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">-d&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">自定义用户的家目录</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">-M	</span><span style="font-family: 宋体; font-size: 10.5pt;">不建立家目录</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">-s	</span><span style="font-family: 宋体; font-size: 10.5pt;">自定义</span><span style="font-family: Calibri; font-size: 10.5pt;">shell</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_16.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">你会发现，创建</span><span style="font-family: Calibri; font-size: 10.5pt;">test11</span><span style="font-family: 宋体; font-size: 10.5pt;">时，加上了</span><span style="font-family: Calibri; font-size: 10.5pt;">-M</span><span style="font-family: 宋体; font-size: 10.5pt;">选项后，在</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/passwd</span><span style="font-family: 宋体; font-size: 10.5pt;">文件中</span><span style="font-family: Calibri; font-size: 10.5pt;">test11</span><span style="font-family: 宋体; font-size: 10.5pt;">那行的第六字段依然有</span><span style="font-family: Calibri; font-size: 10.5pt;">/home/test11</span><span style="font-family: 宋体; font-size: 10.5pt;">，可是</span><span style="font-family: Calibri; font-size: 10.5pt;">ls</span><span style="font-family: 宋体; font-size: 10.5pt;">查看该目录时，会提示该目录不存在</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_17.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">-M</span><span style="font-family: 宋体; font-size: 10.5pt;">选项的作用就是不创建用户的家目录</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">-d.&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">删除用户</span><span style="font-family: Calibri; font-size: 10.5pt;">&nbsp;userdel [-r] username</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_18.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">-r&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">选项的作用是删除用户时，连同用户的家目录一起删除</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><strong>【chfn&nbsp;</strong></span><span style="font-family: 宋体; font-size: 10.5pt;"><strong>更改用户的</strong></span><span style="font-family: Calibri; font-size: 10.5pt;"><strong>finger&nbsp;</strong></span><span style="font-family: 宋体; font-size: 10.5pt;"><strong>（不常用）</strong></span><span style="font-family: Calibri; font-size: 10.5pt;"><strong>】</strong></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal; text-indent: 21pt;"><span style="font-family: 宋体; font-size: 10.5pt;">前面内容中提到了</span><span style="font-family: Calibri; font-size: 10.5pt;">findger</span><span style="font-family: 宋体; font-size: 10.5pt;">，即在</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/passwd</span><span style="font-family: 宋体; font-size: 10.5pt;">文件中的第</span><span style="font-family: Calibri; font-size: 10.5pt;">5</span><span style="font-family: 宋体; font-size: 10.5pt;">个字段中所显示的信息，那么如何去设定这个信息呢？</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_19.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">就是</span><span style="font-family: Calibri; font-size: 10.5pt;">chfn</span><span style="font-family: 宋体; font-size: 10.5pt;">这个命令了</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">修改完后，就会在</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/passwd</span><span style="font-family: 宋体; font-size: 10.5pt;">文件中的</span><span style="font-family: Calibri; font-size: 10.5pt;">test</span><span style="font-family: 宋体; font-size: 10.5pt;">的那一行第五个字段中看到相关信息了，默认是空的</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><strong>【</strong></span><span style="font-family: 宋体; font-size: 10.5pt;"><strong>创建</strong></span><span style="font-family: Calibri; font-size: 10.5pt;"><strong>/</strong></span><span style="font-family: 宋体; font-size: 10.5pt;"><strong>修改一个用户的密码</strong></span><span style="font-family: Calibri; font-size: 10.5pt;"><strong>&nbsp;&#8220;passwd [username]&#8221;】</strong></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal; text-indent: 21pt;"><span style="font-family: 宋体; font-size: 10.5pt;">等创建完账户后，默认是没有设置密码的，虽然没有密码，但该账户同样登录不了系统</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">只有设置好密码后方可登录系统</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal; text-indent: 21pt;"><span style="font-family: 宋体; font-size: 10.5pt;">为用户创建密码时，为了安全起见，请尽量设置复杂一些</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">你可以按照这样的规则来设置密码：</span><span style="font-family: Calibri; font-size: 10.5pt;">a.&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">长度大于</span><span style="font-family: Calibri; font-size: 10.5pt;">10</span><span style="font-family: 宋体; font-size: 10.5pt;">个字符；</span><span style="font-family: Calibri; font-size: 10.5pt;">b.&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">密码中包含大小写字母数字以及特殊字符（</span><span style="font-family: Calibri; font-size: 10.5pt;">*&amp;</span><span style="font-family: 宋体; font-size: 10.5pt;">等）；</span><span style="font-family: Calibri; font-size: 10.5pt;">c.&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">不规则性（不要出现</span><span style="font-family: Calibri; font-size: 10.5pt;">root, happy, love, linux, 123456, 111111</span><span style="font-family: 宋体; font-size: 10.5pt;">等等单词或者数字）；</span><span style="font-family: Calibri; font-size: 10.5pt;">d.&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">不要带有自己名字</span><span style="font-family: Calibri; font-size: 10.5pt;">、</span><span style="font-family: 宋体; font-size: 10.5pt;">公司名字</span><span style="font-family: Calibri; font-size: 10.5pt;">、</span><span style="font-family: 宋体; font-size: 10.5pt;">自己电话</span><span style="font-family: Calibri; font-size: 10.5pt;">、</span><span style="font-family: 宋体; font-size: 10.5pt;">自己生日等</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_20.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">passwd&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">后面不跟用户名则是更改当前用户的密码，当前用户为</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">，所以此时修改的是</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">的密码，后面跟</span><span style="font-family: Calibri; font-size: 10.5pt;">test</span><span style="font-family: 宋体; font-size: 10.5pt;">则修改的是</span><span style="font-family: Calibri; font-size: 10.5pt;">test</span><span style="font-family: 宋体; font-size: 10.5pt;">的密码</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><strong>【</strong></span><span style="font-family: 宋体; font-size: 10.5pt;"><strong>用户身份切换</strong></span><span style="font-family: Calibri; font-size: 10.5pt;"><strong>】</strong></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal; text-indent: 21pt;"><span style="font-family: Calibri; font-size: 10.5pt;">Linux</span><span style="font-family: 宋体; font-size: 10.5pt;">系统中，有时候普通用户有些事情是不能做的，除非是</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">用户才能做到</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">这时就需要临时切换到</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">身份来做事了</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_21.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">用</span><span style="font-family: Calibri; font-size: 10.5pt;">test</span><span style="font-family: 宋体; font-size: 10.5pt;">账号登录</span><span style="font-family: Calibri; font-size: 10.5pt;">linux</span><span style="font-family: 宋体; font-size: 10.5pt;">系统，然后使用</span><span style="font-family: Calibri; font-size: 10.5pt;">su -&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">就可以切换成</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">身份，前提是知道</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">的密码</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_29.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">你可以使用</span><span style="font-family: Calibri; font-size: 10.5pt;">echo $LOGNAME</span><span style="font-family: 宋体; font-size: 10.5pt;">来查看当前登录的用户名</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_30.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;">su&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">的语法为：</span><span style="font-family: Calibri; font-size: 10.5pt;">&nbsp;su [-] username</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">后面可以跟</span><span style="font-family: Calibri; font-size: 10.5pt;">&#8221;-&#8221;</span><span style="font-family: 宋体; font-size: 10.5pt;">也可以不跟，普通用户</span><span style="font-family: Calibri; font-size: 10.5pt;">su</span><span style="font-family: 宋体; font-size: 10.5pt;">不加</span><span style="font-family: Calibri; font-size: 10.5pt;">username</span><span style="font-family: 宋体; font-size: 10.5pt;">时就是切换到</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">用户，当然</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">用户同样可以</span><span style="font-family: Calibri; font-size: 10.5pt;">su</span><span style="font-family: 宋体; font-size: 10.5pt;">到普通用户</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_31.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">加</span><span style="font-family: Calibri; font-size: 10.5pt;">&#8221;-&#8220;</span><span style="font-family: 宋体; font-size: 10.5pt;">后会连同用户的环境变量一起切换过来</span><span style="font-family: Calibri; font-size: 10.5pt;">。su test&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">后虽然切换到了</span><span style="font-family: Calibri; font-size: 10.5pt;">test</span><span style="font-family: 宋体; font-size: 10.5pt;">用户，但是当前目录还是切换前的</span><span style="font-family: Calibri; font-size: 10.5pt;">/root</span><span style="font-family: 宋体; font-size: 10.5pt;">目录，然后当用</span><span style="font-family: Calibri; font-size: 10.5pt;">su - test</span><span style="font-family: 宋体; font-size: 10.5pt;">时切换用户后则到了</span><span style="font-family: Calibri; font-size: 10.5pt;">test</span><span style="font-family: 宋体; font-size: 10.5pt;">的家目录</span><span style="font-family: Calibri; font-size: 10.5pt;">/home/test。</span><span style="font-family: 宋体; font-size: 10.5pt;">当用</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">切换普通用户时，是不需要输入密码的</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">这也体现了</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">用户至高无上的权利</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">用</span><span style="font-family: Calibri; font-size: 10.5pt;">su</span><span style="font-family: 宋体; font-size: 10.5pt;">是可以切换用户身份，如果每个普通用户都能切换到</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">身份，如果某个用户不小心泄漏了</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">的密码，那岂不是系统非常的不安全？没有错，为了改进这个问题，产生了</span><span style="font-family: Calibri; font-size: 10.5pt;">sudo</span><span style="font-family: 宋体; font-size: 10.5pt;">这个命令</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">使用</span><span style="font-family: Calibri; font-size: 10.5pt;">sudo</span><span style="font-family: 宋体; font-size: 10.5pt;">执行一个</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">才能执行的命令是可以办到的，但是需要输入密码，这个密码并不是</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">的密码而是用户自己的密码</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">默认只有</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">用户能使用</span><span style="font-family: Calibri; font-size: 10.5pt;">sudo</span><span style="font-family: 宋体; font-size: 10.5pt;">命令，普通用户想要使用</span><span style="font-family: Calibri; font-size: 10.5pt;">sudo</span><span style="font-family: 宋体; font-size: 10.5pt;">，是需要</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">预先设定的，即，使用</span><span style="font-family: Calibri; font-size: 10.5pt;">visudo</span><span style="font-family: 宋体; font-size: 10.5pt;">命令去编辑相关的配置文件</span><span style="font-family: Calibri; font-size: 10.5pt;">/etc/sudoers。</span><span style="font-family: 宋体; font-size: 10.5pt;">如果没有</span><span style="font-family: Calibri; font-size: 10.5pt;">visudo</span><span style="font-family: 宋体; font-size: 10.5pt;">这个命令，请使用</span><span style="font-family: Calibri; font-size: 10.5pt;">&#8221; yum install -y sudo&#8221;</span><span style="font-family: 宋体; font-size: 10.5pt;">安装</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_32.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">默认</span><span style="font-family: Calibri; font-size: 10.5pt;">root</span><span style="font-family: 宋体; font-size: 10.5pt;">能够</span><span style="font-family: Calibri; font-size: 10.5pt;">sudo</span><span style="font-family: 宋体; font-size: 10.5pt;">是因为这个文件中有一行</span><span style="font-family: Calibri; font-size: 10.5pt;">&#8221; root ALL=(ALL) ALL&#8221;&nbsp;</span><span style="font-family: 宋体; font-size: 10.5pt;">在该行下面加入</span><span style="font-family: Calibri; font-size: 10.5pt;">&#8221; test ALL=(ALL) ALL&#8221;</span><span style="font-family: 宋体; font-size: 10.5pt;">就可以让</span><span style="font-family: Calibri; font-size: 10.5pt;">test</span><span style="font-family: 宋体; font-size: 10.5pt;">用户拥有了</span><span style="font-family: Calibri; font-size: 10.5pt;">sudo</span><span style="font-family: 宋体; font-size: 10.5pt;">的权利</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">如果每增加一用户就设置一行，这样太麻烦了</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">所以你可以这样设置</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_33.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">把这一行前面的</span><span style="font-family: Calibri; font-size: 10.5pt;">&#8221;#&#8221;</span><span style="font-family: 宋体; font-size: 10.5pt;">去掉，让这一行生效</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">它的意思是，</span><span style="font-family: Calibri; font-size: 10.5pt;">wheel</span><span style="font-family: 宋体; font-size: 10.5pt;">这个组的所有用户都拥有了</span><span style="font-family: Calibri; font-size: 10.5pt;">sudo</span><span style="font-family: 宋体; font-size: 10.5pt;">的权利</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span><span style="font-family: 宋体; font-size: 10.5pt;">接下来就需要你把想让有</span><span style="font-family: Calibri; font-size: 10.5pt;">sudo</span><span style="font-family: 宋体; font-size: 10.5pt;">权利的所有用户加入到</span><span style="font-family: Calibri; font-size: 10.5pt;">wheel</span><span style="font-family: 宋体; font-size: 10.5pt;">这个组中即可</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: Calibri; font-size: 10.5pt;"><img src="http://www.92csz.com/study/linux/images/7_34.png" alt="[image]" border="0" /></span></p><p style="font-family: Simsun; font-size: medium; line-height: normal;"><span style="font-family: 宋体; font-size: 10.5pt;">你不妨跟笔者试一下，非常有意思</span><span style="font-family: Calibri; font-size: 10.5pt;">。</span></p><img src ="http://www.blogjava.net/tiandizhijian/aggbug/432230.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tiandizhijian/" target="_blank">做强大的自己</a> 2017-01-01 14:42 <a href="http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432230.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux入门教程（四）文件与目录管理</title><link>http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432229.html</link><dc:creator>做强大的自己</dc:creator><author>做强大的自己</author><pubDate>Sun, 01 Jan 2017 06:40:00 GMT</pubDate><guid>http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432229.html</guid><wfw:comment>http://www.blogjava.net/tiandizhijian/comments/432229.html</wfw:comment><comments>http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432229.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tiandizhijian/comments/commentRss/432229.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tiandizhijian/services/trackbacks/432229.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 第六章&nbsp;Linux文件与目录管理在linux中什么是一个文件的路径呢，说白了就是这个文件存在的地方，例如在上一章提到的/root/.ssh/authorized_keys&nbsp;这就是一个文件的路径。如果你告诉系统这个文件的路径，那么系统就可以找到这个文件。在linux的世界中，存在着绝对路径和相对路径。绝对路径：路径的写法一定由根目录&#8221;/&#8221;写起，例如/usr...&nbsp;&nbsp;<a href='http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432229.html'>阅读全文</a><img src ="http://www.blogjava.net/tiandizhijian/aggbug/432229.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tiandizhijian/" target="_blank">做强大的自己</a> 2017-01-01 14:40 <a href="http://www.blogjava.net/tiandizhijian/archive/2017/01/01/432229.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Docker 在windows上安装运行</title><link>http://www.blogjava.net/tiandizhijian/archive/2016/12/28/432209.html</link><dc:creator>做强大的自己</dc:creator><author>做强大的自己</author><pubDate>Wed, 28 Dec 2016 13:52:00 GMT</pubDate><guid>http://www.blogjava.net/tiandizhijian/archive/2016/12/28/432209.html</guid><wfw:comment>http://www.blogjava.net/tiandizhijian/comments/432209.html</wfw:comment><comments>http://www.blogjava.net/tiandizhijian/archive/2016/12/28/432209.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tiandizhijian/comments/commentRss/432209.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tiandizhijian/services/trackbacks/432209.html</trackback:ping><description><![CDATA[<span style="background-color: #ffffff;">Windows用户使用Docker ToolBox来安装Docker软件。<br /></span><span style="background-color: #ffffff;">Windows上运行Docker，必须是64位的win7或者更高的64位版本<br /></span><br /><span style="background-color: #ffffff;">Docker ToolBox安装</span><br /><span style="background-color: #ffffff;">需要安装如下部分：</span><br /><span style="background-color: #ffffff;">Docker Client for Windows</span><br /><span style="background-color: #ffffff;">Docker Toolbox management tool and ISO</span><br /><span style="background-color: #ffffff;">Oracle VM VirtualBox</span><br /><span style="background-color: #ffffff;">Git MSYS-git UNIX tools<br /></span><br /><span style="background-color: #ffffff;">安装完成后会生成三个快捷方式，分别为：</span><br /><span style="background-color: #ffffff;">(1) Docker Quickstart Terminal: 提供Docker的命令行操作</span><br /><span style="background-color: #ffffff;">(2) Oracle VM VirtualBox: 打开可以看到有一个虚拟机，里面安装了Core Linux机器，名字为default。</span><br /><span style="background-color: #ffffff;">(3) Kitematic (Alpha)：图形化的docker工具<br /></span><br /><span style="background-color: #ffffff;">启动Terminal窗口工具之后，我运行hello world报错了</span><br /><span style="background-color: #ffffff;">$ docker run hello-world</span><br /><span style="background-color: #ffffff;">docker: An error occurred trying to connect: Post http://127.0.0.1:2375/v1.22/co</span><br /><span style="background-color: #ffffff;">ntainers/create: dial tcp 127.0.0.1:2375: connectex: No connection could be made</span><br /><span style="background-color: #ffffff;">because the target machine actively refused it..</span><br /><span style="background-color: #ffffff;">See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.</span><br /><span style="background-color: #ffffff;">上面问题的解决办法：<br />经过多方查资料，可能的原因是本机安装的其他虚拟网络，如VMWare, VPN等可能造成网络冲突导致。<br />因此我打算重建自定义网络，在重建之前，我打开"Oracle VM VirtualBox"，删除了默认的default虚拟机和两个Host-only网络。<br />本来打算执行一个命令来自定义创建的的，结果当我启动"Docker Quickstart Terminal"时，系统自动重建了虚拟机和网络，然后进入结果就OK了。<br />因此，解决办法就是删除默认的虚拟机和网络，让系统帮你重建一次。<br /></span><br /><span style="background-color: #ffffff;">default虚拟机</span><br /><span style="background-color: #ffffff;">可以直接从"Oracle VM VirtualBox"界面进入default虚拟机，不需要输入密码即可进入root环境，输入ifconfig命令可以看到default有三个网段的IP地址，分别为：</span><br /><span style="background-color: #ffffff;">docker0: 172.17.0.1，这个是docker的网桥。</span><br /><span style="background-color: #ffffff;">eth0:10.0.2.15，这个网段在Ubuntu环境中是没有的，暂不知道为什么会多这一个。</span><br /><span style="background-color: #ffffff;">eth1:192.168.99.100，这个数宿主机的IP地址。<br /></span><br /><span style="background-color: #ffffff;">windows环境部分docker命令</span><br /><span style="background-color: #ffffff;">$ docker-machine env</span><br /><span style="background-color: #ffffff;">export DOCKER_TLS_VERIFY="1"</span><br /><span style="background-color: #ffffff;">export DOCKER_HOST="tcp://192.168.99.100:2376"</span><br /><span style="background-color: #ffffff;">export DOCKER_CERT_PATH="C:\Users\dhu\.docker\machine\machines\default"</span><br /><span style="background-color: #ffffff;">export DOCKER_MACHINE_NAME="default"</span><br /><span style="background-color: #ffffff;">$ docker info</span><br /><span style="background-color: #ffffff;">Containers: 2</span><br /><span style="background-color: #ffffff;">Running: 0</span><br /><span style="background-color: #ffffff;">Paused: 0</span><br /><span style="background-color: #ffffff;">Stopped: 2</span><br /><span style="background-color: #ffffff;">Images: 1</span><br /><span style="background-color: #ffffff;">Server Version: 1.10.3</span><br /><span style="background-color: #ffffff;">Storage Driver: aufs</span><br /><span style="background-color: #ffffff;">Root Dir: /mnt/sda1/var/lib/docker/aufs</span><br /><span style="background-color: #ffffff;">Backing Filesystem: extfs</span><br /><span style="background-color: #ffffff;">Dirs: 6</span><br /><span style="background-color: #ffffff;">Dirperm1 Supported: true</span><br /><span style="background-color: #ffffff;">Execution Driver: native-0.2</span><br /><span style="background-color: #ffffff;">Logging Driver: json-file</span><br /><span style="background-color: #ffffff;">Plugins:</span><br /><span style="background-color: #ffffff;">Volume: local</span><br /><span style="background-color: #ffffff;">Network: bridge null host</span><br /><span style="background-color: #ffffff;">Kernel Version: 4.1.19-boot2docker</span><br /><span style="background-color: #ffffff;">Operating System: Boot2Docker 1.10.3 (TCL 6.4.1); master : 625117e - Thu Mar 10</span><br /><span style="background-color: #ffffff;">22:09:02 UTC 2016</span><br /><span style="background-color: #ffffff;">OSType: linux</span><br /><span style="background-color: #ffffff;">Architecture: x86_64</span><br /><span style="background-color: #ffffff;">CPUs: 1</span><br /><span style="background-color: #ffffff;">Total Memory: 996.1 MiB</span><br /><span style="background-color: #ffffff;">Name: default</span><br /><span style="background-color: #ffffff;">ID: PKEB:7MPC:BCKW:4RCR:JLMF:OMOO:ZY5T:O2W2:3LLX:OXDM:DD56:I4B7</span><br /><span style="background-color: #ffffff;">Debug mode (server): true</span><br /><span style="background-color: #ffffff;">File Descriptors: 10</span><br /><span style="background-color: #ffffff;">Goroutines: 22</span><br /><span style="background-color: #ffffff;">System Time: 2016-04-09T15:39:25.323452975Z</span><br /><span style="background-color: #ffffff;">EventsListeners: 0</span><br /><span style="background-color: #ffffff;">Init SHA1:</span><br /><span style="background-color: #ffffff;">Init Path: /usr/local/bin/docker</span><br /><span style="background-color: #ffffff;">Docker Root Dir: /mnt/sda1/var/lib/docker</span><br /><span style="background-color: #ffffff;">Labels:</span><br /><span style="background-color: #ffffff;">provider=virtualbox</span><br /><span style="background-color: #ffffff;">docker-machine rm default 删除一个虚拟机<br /></span><br /><span style="background-color: #ffffff;">打开"Oracle VM VirtualBox"，进入File-&amp;gt;Preferences-&amp;gt;Network-&amp;gt;Host-only Networks，删除两个默认的网络。</span><br /><span style="background-color: #ffffff;">docker-machine create --driver virtualbox --virtualbox-hostonly-cidr "25.0.1.100/24" dev<br /></span><br /><span style="background-color: #ffffff;">总结一下：Docker在windows上运行其本质是运行在Windows上的虚拟机里面的Linux上，实质上还是运行在Linux，因为Docker是建立在Linux内核基础上的，Windows无法适应。<br /></span><br /><span style="background-color: #ffffff;">参考资料：</span><br /><span style="background-color: #ffffff;">[1] https://docs.docker.com/windows/</span><br /><span style="background-color: #ffffff;">[2] http://docs.docker.com/windows/started/</span><img src ="http://www.blogjava.net/tiandizhijian/aggbug/432209.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tiandizhijian/" target="_blank">做强大的自己</a> 2016-12-28 21:52 <a href="http://www.blogjava.net/tiandizhijian/archive/2016/12/28/432209.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Thinkpad T410 安装 Ubuntu10.04 </title><link>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432199.html</link><dc:creator>做强大的自己</dc:creator><author>做强大的自己</author><pubDate>Tue, 27 Dec 2016 13:51:00 GMT</pubDate><guid>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432199.html</guid><wfw:comment>http://www.blogjava.net/tiandizhijian/comments/432199.html</wfw:comment><comments>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432199.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tiandizhijian/comments/commentRss/432199.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tiandizhijian/services/trackbacks/432199.html</trackback:ping><description><![CDATA[http://blog.sina.com.cn/s/blog_5038ce7a0100qfyj.html <br /><br />Thinkpad T410 安装 Ubuntu10.04 (2011-03-06 14:43:06)转载&#9660; <br />标签： linux ubuntu 10.04 thinkpadt410 杂谈	分类： Linux <br />Thinkpad T410 下安装 Ubuntu10.04&nbsp; <br /><br />移动硬盘上安装Ubuntu备忘 <br /><br />======================================== <br />1. 系统安装 <br />======================================== <br /><br />&nbsp;&nbsp;&nbsp; 下载安装镜像一步步装即可，没有太多复杂的，安装完后系统后： <br /><br />****************************** <br />1.1 更改源 <br />****************************** <br />&nbsp;&nbsp;&nbsp; 编辑/etc/apt/sources.list 文件，网上有好多源，比如163,骨头源等，注意先把官方默认的源备份一下 <br />&nbsp;&nbsp;&nbsp; sudo cp /etc/apt/sources.list /etc/apt/sources.list.backup <br />&nbsp;&nbsp;&nbsp; 以便日后要用。网络不受限制的话默认的源速度就可以了。 <br /><br />****************************** <br />1.2 更新语文支持 <br />****************************** <br />&nbsp;&nbsp;&nbsp; 更新语文支持，把oOo什么的汉化 <br /><br />****************************** <br />1.3 更新系统 <br />****************************** <br />&nbsp;&nbsp;&nbsp; 用更新管理器更新系统内核，模块，软件等 <br /><br />======================================== <br />2. 安装必要驱动 <br />======================================== <br /><br />&nbsp;&nbsp;&nbsp; ubuntu10.04 对 ThinkpadT410 大部分硬件支持良好，但无线网络能发现却不能用 <br /><br />****************************** <br />2.1 无线网卡驱动安装 <br />****************************** <br />&nbsp;&nbsp;&nbsp; 参考网址：http://www.realtek.com.tw/downloads/ <br />&nbsp;&nbsp;&nbsp; T410无线网卡型号： <br />&nbsp;&nbsp;&nbsp; * Chipset: Realtek RTL8192SE <br />&nbsp;&nbsp;&nbsp; * IEEE Standards: 802.11b, 802.11g, 802.11n <br />&nbsp;&nbsp;&nbsp; * 1x2 MIMO <br />&nbsp;&nbsp;&nbsp; * PCI ID: 10ec:8172&nbsp; <br />&nbsp;&nbsp;&nbsp; 到realtek 官网下载RTL8192SE对应的linux驱动,之后安装重启就可以了。安装过程见安装包中的readme.txt，很简单。 <br /><br />****************************** <br />2.2 安装电源软件和硬盘保护 <br />****************************** <br />&nbsp;&nbsp;&nbsp; 参考文献：http://www.thinkwiki.org/wiki/Tp_smapi <br />&nbsp;&nbsp;&nbsp; 到thinkwiki上下载安装tp_smapi，安装过程可参考网页说明，可从源码安装，对ubuntu10.04,也可用apt-get install安装。 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 源码安装方式： <br />&nbsp;&nbsp;&nbsp; # tar xzvf tp_smapi-0.40.tgz <br />&nbsp;&nbsp;&nbsp; # cd tp_smapi-0.40 <br />&nbsp;&nbsp;&nbsp; # make install <br />&nbsp;&nbsp;&nbsp; 如果你使用HDAPS驱动（HDAPS - IBM Active Protection System Linux Driver），因为tp_smapi已经patch了与其相容的模块，所以安装方式改为： <br />&nbsp;&nbsp;&nbsp; # make install HDAPS=1 <br />&nbsp;&nbsp;&nbsp; 按官方的说明下述安装不是必须的，hdaps已集成在tp_smapi中，但装一下也无妨 <br />&nbsp;&nbsp;&nbsp; sudo apt-get install hdaps-utils hdapsd <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 查看模块是否运行： <br />&nbsp;&nbsp;&nbsp; lsmod | grep hdaps <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 对于ubuntu10.04,可按如下安装： <br />&nbsp;&nbsp;&nbsp; # aptitude install tp-smapi-dkms <br />&nbsp;&nbsp;&nbsp; # modprobe tp_smapi <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 设置充电阈值： <br />&nbsp;&nbsp;&nbsp; # echo 40 &gt; /sys/devices/platform/smapi/BAT0/start_charge_thresh <br />&nbsp;&nbsp;&nbsp; # echo 70 &gt; /sys/devices/platform/smapi/BAT0/stop_charge_thresh <br />&nbsp;&nbsp;&nbsp; # cat /sys/devices/platform/smapi/BAT0/*_charge_thresh <br />&nbsp;&nbsp;&nbsp; 注意：运行以上命令时即使用sudo，也可能提示权限不够，可先执行: sudo -i <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 其它设置： <br />&nbsp;&nbsp;&nbsp; 17 分钟后禁止充电（不论充电阈值为多少）： <br />&nbsp;&nbsp;&nbsp; # echo 17 &gt; /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes <br />&nbsp;&nbsp;&nbsp; 取消充电保护： <br />&nbsp;&nbsp;&nbsp; # echo 0 &gt; /sys/devices/platform/smapi/BAT0/inhibit_charge_minutes <br />&nbsp;&nbsp;&nbsp; 强制停止充电（即使连接了AC）： <br />&nbsp;&nbsp;&nbsp; # echo 1 &gt; /sys/devices/platform/smapi/BAT0/force_discharge <br />&nbsp;&nbsp;&nbsp; 取消强制停止充电： <br />&nbsp;&nbsp;&nbsp; # echo 0 &gt; /sys/devices/platform/smapi/BAT0/force_discharge <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 开机时自动加载官方方法： <br />&nbsp;&nbsp;&nbsp; it is not necessary to create your own init.d script or modify /etc/rc.local - you just need the package sysfsutils: <br />&nbsp;&nbsp;&nbsp; # apt-get install sysfsutils <br />&nbsp;&nbsp;&nbsp; # sudo gedit /etc/sysfs.conf <br />&nbsp;&nbsp;&nbsp; 修改文件 /etc/sysfs.conf 即可: <br />&nbsp;&nbsp;&nbsp; # cat &gt;&gt; /etc/sysfs.conf &lt;&lt; EOF <br />&nbsp;&nbsp;&nbsp; # For a LiIon battery in a Thinkpad <br />&nbsp;&nbsp;&nbsp; devices/platform/smapi/BAT0/start_charge_thresh = 50 <br />&nbsp;&nbsp;&nbsp; devices/platform/smapi/BAT0/stop_charge_thresh = 80 <br />&nbsp;&nbsp;&nbsp; EOF <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 开机时自动加载其它方法： <br />&nbsp;&nbsp;&nbsp; 增加开机启动模块 <br />&nbsp;&nbsp;&nbsp; sudo gedit /etc/modules <br />&nbsp;&nbsp;&nbsp; 添加以下内容： <br />&nbsp;&nbsp;&nbsp; thinkpad_ec <br />&nbsp;&nbsp;&nbsp; tp_smapi <br />&nbsp;&nbsp;&nbsp; hdaps <br />&nbsp;&nbsp;&nbsp; 另外编辑文件： <br />&nbsp;&nbsp;&nbsp; sudo gedit /etc/rc.local <br />&nbsp;&nbsp;&nbsp; 加入： <br />&nbsp;&nbsp;&nbsp; # Make battery live longer <br />&nbsp;&nbsp;&nbsp; echo 50 &gt; /sys/devices/platform/smapi/BAT0/start_charge_thresh <br />&nbsp;&nbsp;&nbsp; echo 80 &gt; /sys/devices/platform/smapi/BAT0/stop_charge_thresh <br />&nbsp;&nbsp;&nbsp; 上面方法未经试验，还是用官方方法好 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 问题：重启后在platform下没有发现smpi文件夹，在源码包里执行make load HDAPS=1后方出现，是否需在启动模块中加载？已解决，见上。 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />****************************** <br />2.3 显卡驱动 <br />****************************** <br /><br />&nbsp;&nbsp;&nbsp; 注意：不要更新显卡驱动，用开源驱动即可，更新后可能会出现一系列的问题，如开机画面LOGO分辨率，亮度调节等，并且感觉看字的时候分辨率不对了，网上的解决方案不是很完美，有好几次按网上的更改后直接黑屏进不去系统了，默认驱动除了不能开启特效外也没什么不好的，再说特效这东西是给别看的，不用无所谓。官方还没有 NVS 3100M 相对应的显卡程序，所以还是等等吧。 <br /><br />经后来测试可以装，但得做一些设置，查看博文： http://blog.sina.com.cn/s/blog_5038ce7a0100r8lf.html <br /><br />2.3.1 调节屏幕亮度方法： <br /><br />A：(快捷的方法，临时的) <br />&nbsp;&nbsp;&nbsp; a. 按Ctrl+Alt+F1进入命令行 <br />&nbsp;&nbsp;&nbsp; b. 用快捷键调节亮度 <br />&nbsp;&nbsp;&nbsp; c. 按Ctrl+Alt+F7回到GUI <br /><br />B：nvclock <br />&nbsp;&nbsp;&nbsp; sudo apt-get install nvclock <br />&nbsp;&nbsp;&nbsp; nvclock -S -10 <br /><br />C：/etc/X11/xorg.conf <br />&nbsp;&nbsp;&nbsp; 添加Option "RegistryDwords" "EnableBrightnessControl=1" <br /><br />2.3.2 开关机分辨率： <br /><br />A. 确认grub和plymouth的系统配置文件是原始状态，没有应用过其它的修改方案。 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />B. 安装v86d和hwinfo包 <br />&nbsp;&nbsp;&nbsp; sudo apt-get install v86d hwinfo <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />C. 查看自己显卡支持的分辨率： <br />&nbsp;&nbsp;&nbsp; sudo hwinfo --framebuffer <br />&nbsp;&nbsp;&nbsp; 显示的结果中没有支持的最大分辨率1440x900，但下面设置了是可以启用的。 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />D. 修改/etc/default/grub文件，使用uvesafb的framebuffer来启动 <br />&nbsp;&nbsp;&nbsp; sudo gedit /etc/default/grub <br />&nbsp;&nbsp;&nbsp; 把下面的两行: <br />&nbsp;&nbsp;&nbsp; GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" <br />&nbsp;&nbsp;&nbsp; #GRUB_GFXMODE=640x480 <br />&nbsp;&nbsp;&nbsp; 修改为： <br />&nbsp;&nbsp;&nbsp; GRUB_CMDLINE_LINUX_DEFAULT="quiet splash nomodeset video=uvesafb:mode_option=1440x900-24,mtrr=3,scroll=ywrap" <br />&nbsp;&nbsp;&nbsp; GRUB_GFXMODE=1440x900 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />E. 修改/etc/initramfs-tools/modules文件 <br />&nbsp;&nbsp;&nbsp; sudo gedit /etc/initramfs-tools/modules <br />&nbsp;&nbsp;&nbsp; 添加下面这行： <br />&nbsp;&nbsp;&nbsp; uvesafb mode_option=1440x900-24 mtrr=3 scroll=ywrap <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />F. 运行下面的命令，启用framebuffer: <br />&nbsp;&nbsp;&nbsp; 代码: <br />&nbsp;&nbsp;&nbsp; echo FRAMEBUFFER=y | sudo tee /etc/initramfs-tools/conf.d/splash <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />G. 运行下面的命令，更新grub配置文件： <br />&nbsp;&nbsp;&nbsp; sudo update-grub <br />&nbsp;&nbsp;&nbsp; sudo update-initramfs -u <br /><br />H. 重启，开关机分辨率，tty1-tty6分辨率问题均得到解决。 <br /><br />****************************** <br />2.4 安装小红点驱动 <br />****************************** <br />&nbsp;&nbsp;&nbsp; sudo apt-get install gpointing-device-settings <br /><br /><br />****************************** <br />2.5 安装thinkfan <br />****************************** <br />&nbsp;&nbsp;&nbsp; 打开thingkpad_acpi的风扇控制 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 首先要打开thinpad_acpi的风扇控制支持，具体做法是在加载这个内核模块的时候给它传递一 <br />&nbsp;&nbsp;&nbsp; 个打开风扇控制的变量。具体做法如下： <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; modprobe thinkpad_acpi fan_control=1 experimental=1 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 要实现开机加载模块时设置，则需要在/etc/modprobe.d/下增加一个配置文件thinkpad-acpi.conf，内容： <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; options thinkpad_acpi experimental=1 fan_control=1 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 安装ubuntu软件仓库里面的thinkfan和sysfsutils(读取和设置sysfs属性)。 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; sudo aptitude install thinkfan sysfsutils <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; thinkfan会在系统的运行级别中添加thinkfan的后台服务，这样就可实现开机运行。 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 配置和激活thinkfan <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 阅读/etc/thinkfan.conf可以知道它是通过thinkpad_acpi提供的风扇控制接口来实现风扇控制的，它给风扇的转速级别对应了一个上下限温度，在这个上下限内就设置对应的转速。 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 安装后发现thinkfan并没有直接生效， <br />&nbsp;&nbsp;&nbsp; 脚本：/etc/init.d/thinkfan 查看怎样设置自动启动 <br />&nbsp;&nbsp;&nbsp; 自动启动：/etc/default/thinkfan 文件中的START=yes。 <br />&nbsp;&nbsp;&nbsp; 风扇控制温度输入为：/proc/acpi/ibm/thermal <br />&nbsp;&nbsp;&nbsp; cat /proc/acpi/ibm/fan可以得到控制风扇的方法 <br /><br />&nbsp;&nbsp;&nbsp; 安装完成后手动更新下载后的源码版本：0.7.1 <br />&nbsp;&nbsp;&nbsp; sudo make&nbsp; <br />&nbsp;&nbsp;&nbsp; 将开机自动运行关闭，重启后进入源码文件夹，执行 <br />&nbsp;&nbsp;&nbsp; sudo cp thinkfan /usr/sbin <br />&nbsp;&nbsp;&nbsp; 然后运行thinkfan, 并将开机自运行打开。 <br /><br />&nbsp;&nbsp;&nbsp; 手动更改风扇转速： <br />&nbsp;&nbsp;&nbsp; sudo -i&nbsp; <br />&nbsp;&nbsp;&nbsp; echo "level 6" &gt; /proc/acpi/ibm/fan <br />&nbsp;&nbsp;&nbsp; 但过几秒钟后会变为自动控制。 <br /><br />&nbsp;&nbsp;&nbsp; 重新加载配置文件 <br />&nbsp;&nbsp;&nbsp; # kill -HUP $(&lt;/var/run/thinkfan.pid) <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 卸载： <br />&nbsp;&nbsp;&nbsp; sudo aptitude remove thinkfan，注意不要把sysfsutils也卸载了 <br />&nbsp;&nbsp;&nbsp; rm /etc/modprobe.d/thinkpad-acpi.conf <br />&nbsp;&nbsp;&nbsp; 其余配置文件可暂时保留 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 参考网址：&nbsp; http://vmlinz.is-programmer.com/posts/25834.html <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; http://sourceforge.net/projects/thinkfan/ <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; http://www.thinkwiki.org/wiki/Fan_control_scripts <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />****************************** <br />2.6 配置laptop-model <br />****************************** <br />&nbsp;&nbsp;&nbsp; sudo apt-get install laptop-mode-tools <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 修改文件： /etc/laptop-mode/laptop-mode.conf <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; ENABLE_LAPTOP_MODE_ON_AC=1 <br />&nbsp;&nbsp;&nbsp; ENABLE_LAPTOP_MODE_WHEN_LID_CLOSED=1 <br />&nbsp;&nbsp;&nbsp; CONTROL_HD_IDLE_TIMEOUT=0 <br />&nbsp;&nbsp;&nbsp; # ArchLinux/Debian 默认 20 ，导致硬盘经常停转起转，Ubuntu 默认 60 ，用了几天没感觉。总之我关掉了这项功能。 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 即在使用交流电源和合上盖时启用LatTopMode，关于LapTopMode信息查看 <br />&nbsp;&nbsp;&nbsp; http://hi.baidu.com/skubuntu/blog/item/c70ad563e1bf93d38db10d07.html <br />&nbsp;&nbsp;&nbsp; 另外可解决发热大的问题： <br />&nbsp;&nbsp;&nbsp; http://www.cnblogs.com/droi/archive/2011/01/20/1940300.html <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />****************************** <br />2.7 安装sensors <br />****************************** <br />&nbsp;&nbsp;&nbsp; 参考文献：http://forum.ubuntu.org.cn/viewtopic.php?t=55438 <br />&nbsp;&nbsp;&nbsp; sudo apt-get install lm-sensors sensors-applet <br />&nbsp;&nbsp;&nbsp; sudo sensors-detect 并一路YES 回车 <br />&nbsp;&nbsp;&nbsp; 找到确认添加的模块 <br />&nbsp;&nbsp;&nbsp; sudo gedit /etc/modules 添加进去，但我的没有找到 <br />&nbsp;&nbsp;&nbsp; 安装界面显示程序： <br />&nbsp;&nbsp;&nbsp; sudo apt-get install xsensors <br />&nbsp;&nbsp;&nbsp; sudo apt-get install gdesklets gkrellm <br />&nbsp;&nbsp;&nbsp; 安装硬盘温度监控: <br />&nbsp;&nbsp;&nbsp; sudo apt-get install hddtemp <br /><br />****************************** <br />2.8 安装cpufrequtils <br />****************************** <br />&nbsp;&nbsp;&nbsp; 因为Ubuntu 默认的 CPU 式作方式为ondemand，这样只要一有 cpu 计算量的任务，就会立即达到最大频率运行，等执行完后立即回到最低频率，因此会出现 cpu 温度的急骤升高，如果采用 tinkfan 控制风扇转速，则风扇会再现突然猛转的情况。右键单击面板,选择&#8220;添加到面板&#8221;,里面找到&#8220;cpu频率范围监视器&#8221;, cpu 有几个核就加几个，单击可改变 cpu 工作模式，几种工作模式分别如下： <br />&nbsp;&nbsp;&nbsp; powersave,是无论如何都只会保持最低频率的所谓&#8220;省电&#8221;模式； <br />　　ondemand,默认模式.一有cpu计算量的任务,就会立即达到最大频率运行,等执行完毕就立即回到最低频率； <br />　　conservative,翻译成保守（中庸）模式,会自动在频率上下限调整,和ondemand的区别在于它会按需分配频率,而不是一味追求最高频率； <br />　　performance,顾名思义只注重效率,无论如何一直保持以最大频率运行. <br />&nbsp;&nbsp;&nbsp; 将四个核均改为 conservative 后，cpu 温度降到了 46 度左右，比以前有大大降低。 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 另外，安装： <br />&nbsp;&nbsp;&nbsp; sudo apt-get install cpufrequtils <br /><br />&nbsp;&nbsp;&nbsp; 用法： <br />&nbsp;&nbsp;&nbsp; 代码：cpufreq-info, cpufreq-selector, cpufreq-set <br />&nbsp;&nbsp;&nbsp; 具体用法可以用 -h 或 man 查看。 <br />&nbsp;&nbsp;&nbsp; A. 查看cpu类型、当前频率、支持频率、运行模式等 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cpufreq-info&nbsp; <br />&nbsp;&nbsp;&nbsp; B. 选择需要调整的cpu <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo cpufreq-selector -c cpu号 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo cpufreq-set -c cpu号 <br />&nbsp;&nbsp;&nbsp; C. 调整cpu频率 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo cpufreq-selector -f 你所需要的频率 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo cpufreq-set -f 你所需要的频率 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注意，此处的频率必须是以KHz为单位，并且是可以达到的频率（也就是用cpufreq-info查看到的各个频率），cpu频率＝倍频x外频。以下凡是涉及频率的一律如此。 <br />&nbsp;&nbsp;&nbsp; D. 调整cpu频率上下限 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo cpufreq-set -d 频率下限 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo cpufreq-set -u 频率上限 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 因此，可能可以对cpu进行降频或者超频 <br />&nbsp;&nbsp;&nbsp; E. 调整cpu运行模式 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo cpufreq-selecotr -g 模式 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo cpufreq-set -g 模式 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eg: sudo cpufreq-set -c 0 -g powersave <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 这里，模式就是执行cpufreq-info后看到的所支持的模式。比如我的支持以下几种：powersave, userspace, ondemand, conservative, performance。 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; powersave，是无论如何都只会保持最低频率的所谓&#8220;省电&#8221;模式； <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; userspace，是自定义频率时的模式，这个是当你设定特定频率时自动转变的； <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ondemand，默认模式。一有cpu计算量的任务，就会立即达到最大频率运行，等执行完毕就立即回到最低频率； <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; conservative，翻译成保守（中庸）模式，会自动在频率上下限调整，和ondemand的区别在于它会按需分配频率，而不是一味追求最高频率； <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; performance，顾名思义只注重效率，无论如何一直保持以最大频率运行。 <br />&nbsp;&nbsp;&nbsp;&nbsp; F. 添加cpu监视器 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 监视cpu频率，右键单击面板，选择&#8220;添加到面板&#8221;，里面找到&#8220;cpu频率范围监视器&#8221;。 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 另外，如果嫌命令行麻烦，可以这么做 <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sudo chmod +s /usr/bin/cpufreq-selector <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 然后，cpu频率范围监视器的首选项里会多出一个&#8220;频率选择器&#8221;，显示菜单选择&#8220;频率和调速器&#8221;。鼠标左键单击cpu频率范围监视器，会发现&#8220;频率&#8221;和&#8220;调速器&#8221;两个菜单，就可以随便调了。当然不需要随便调，这里只是说明一下方法。 <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />&nbsp;&nbsp;&nbsp; 添加开机自启动：修改/etc/rc.local 文件，在 exit 0 前面增加如下内容： <br />&nbsp;&nbsp;&nbsp; cpufreq-set -c 0 -g conservative <br />&nbsp;&nbsp;&nbsp; cpufreq-set -c 1 -g conservative <br />&nbsp;&nbsp;&nbsp; cpufreq-set -c 2 -g conservative <br />&nbsp;&nbsp;&nbsp; cpufreq-set -c 3 -g conservative <br />&nbsp;&nbsp;&nbsp; 但开机后不久会自动改为ondemand, 这时再运行桌面脚本即可 <br /><br />&nbsp;&nbsp;&nbsp; laptop-mode 下的配置文件位置： <br />&nbsp;&nbsp;&nbsp; /etc/laptop-mode/conf.d/cpufreq.conf&nbsp; <br />&nbsp;&nbsp;&nbsp; 可更改是否启用及CPU工作模式。 <br />&nbsp;&nbsp;&nbsp; 更改后发现启动后频率监视器上仍为ondemand, 但cpu温度降低了，是不是在内部自己调整的，因为启用了ac-laptopmod <br /><br /><br />======================================== <br />3. 主要应用软件安装 <br />======================================== <br /><br />****************************** <br />3.1 安装方式 <br />****************************** <br />&nbsp;&nbsp;&nbsp; sudo apt-get install ... <br />&nbsp;&nbsp;&nbsp; 软件中心 <br />&nbsp;&nbsp;&nbsp; 新立得软件包 <br /><br />****************************** <br />3.2 主要软件列表 <br />****************************** <br />&nbsp;&nbsp;&nbsp; ubuntu-restricted-extras&nbsp;&nbsp; 其他Ubuntu应用程序可能需要的软件或者编码器 <br />&nbsp;&nbsp;&nbsp; audacious&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注：需装音频解码器（打开文件自动安装），乱码问题：播放列表，自定义：%f <br />&nbsp;&nbsp;&nbsp; mplayer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注：需装解码器 <br />&nbsp;&nbsp;&nbsp; stardict <br />&nbsp;&nbsp;&nbsp; 发音不好，干脆卸载了： <br />&nbsp;&nbsp;&nbsp; sudo apt-get install stardict-plugin-espeak&nbsp; stardict-plugin-festival&nbsp; <br />&nbsp;&nbsp;&nbsp; goldendict&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注：推荐，有好多词典 <br />&nbsp;&nbsp;&nbsp; g++ <br />&nbsp;&nbsp;&nbsp; vim&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注：用源码编译时gvim 有问题。另screen下不同标签间的"*"寄存器可用，太好了 <br />&nbsp;&nbsp;&nbsp; cscope <br />&nbsp;&nbsp;&nbsp; ctags <br />&nbsp;&nbsp;&nbsp; cgdb <br />&nbsp;&nbsp;&nbsp; rar unrar p7zip <br />&nbsp;&nbsp;&nbsp; flashplayer <br />&nbsp;&nbsp;&nbsp; fonts&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注：将Win下的TrueType字体放入$HOME/.fonts目录即可，也可打开安装 <br />&nbsp;&nbsp;&nbsp; xrgsu-&gt;mentohust <br />&nbsp;&nbsp;&nbsp; scilab <br />&nbsp;&nbsp;&nbsp; octave <br />&nbsp;&nbsp;&nbsp; pdf comment: xournal,okular <br />&nbsp;&nbsp;&nbsp; FoxitReader <br />&nbsp;&nbsp;&nbsp; texlive <br />&nbsp;&nbsp;&nbsp; OpenFOAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注：源码编译，安装方式见别一文档 <br />&nbsp;&nbsp;&nbsp; gnuplot&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注：画图程序，octave用的就是她 <br />&nbsp;&nbsp;&nbsp; octave <br />&nbsp;&nbsp;&nbsp; noflushd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注：硬盘控制程序 <br />&nbsp;&nbsp;&nbsp; ailurus&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 注：推荐 <br />&nbsp;&nbsp;&nbsp; Jabref <br />&nbsp;&nbsp;&nbsp; Bibus <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />======================================== <br />4. 主要问题 <br />======================================== <br /><br />****************************** <br />4.1 中文支持 <br />****************************** <br />&nbsp;&nbsp;&nbsp; pdf中文支持：sudo apt-get install xpdf-chinese-simplified xpdf-chinese-traditional poppler-data <br />&nbsp;&nbsp;&nbsp; gedit乱码：运行 gconf-editor，在/apps/gedit-2/preferences/encodings/auto_detected 下面加入 GB18030,GB2312 ,GBK（ GB18030 兼容GB2312 ,GBK的，所以只添加有一个 GB18030就可以了的） <br /><br />****************************** <br />4.2 Chrome中一旦退格IBus无法输入 <br />****************************** <br />&nbsp;&nbsp;&nbsp; 一旦按了backspace删除之前输入的文字，就要重新启动ibus才能输入，不然输入什么都是不能显示的， <br />&nbsp;&nbsp;&nbsp; 已经证实是iBus的key snooper特性导致了这个问题。可以考虑将iBus升级到1.3.5以上（添加PPA） <br /><br />&nbsp;&nbsp;&nbsp; $sudo add-apt-repository ppa:shawn-p-huang/ppa <br />&nbsp;&nbsp;&nbsp; $sudo apt-get update <br />&nbsp;&nbsp;&nbsp; $sudo apt-get dist-upgrade <br /><br />****************************** <br />4.3 更改密码问题 <br />****************************** <br />&nbsp;&nbsp;&nbsp; 密码太短或太简单，用sudo更改： <br />&nbsp;&nbsp;&nbsp; sudo passwd terry <br />&nbsp;&nbsp;&nbsp;&nbsp; <br />****************************** <br />4.4 面版重置 <br />****************************** <br />&nbsp;&nbsp;&nbsp; 打开终端，终端窗口打开之后，立即在提示符后面输入下列命令： gconftool --recursive-unset /apps/panel （注意：每个斜杠 &#8220;/&#8221; 后面没有空格）接下来输入下列命令： rm -rf ~/.gconf/apps/panel 最后还需要执行： pkill gnome-panel 接下来，Ubuntu 默认的上下两栏面板就会恢复默认值，出现顶部+底部各一面板的默认布局。 <br /><br />****************************** <br />4.5. 安装出错 <br />****************************** <br />&nbsp;&nbsp;&nbsp; dpkg：处理 tex-common (--configure)时出错： <br />&nbsp;&nbsp;&nbsp;&nbsp; 子进程 已安装的 post-installation 脚本 返回了错误号 1 <br />&nbsp;&nbsp;&nbsp; dpkg：依赖关系问题使得 texlive-binaries 的配置工作不能继续： <br />&nbsp;&nbsp;&nbsp;&nbsp; texlive-binaries 依赖于 tex-common (&gt;= 2.00)；然而： <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 软件包 tex-common 还没有被配置。 <br />&nbsp;&nbsp;&nbsp; dpkg：处理 texlive-binaries (--configure)时出错： <br />&nbsp;&nbsp;&nbsp;&nbsp; 依赖关系问题 - 仍未被配置 <br />&nbsp;&nbsp;&nbsp; 在处理时有错误发生： <br />&nbsp;&nbsp;&nbsp;&nbsp; tex-common <br />&nbsp;&nbsp;&nbsp;&nbsp; texlive-binaries <br />&nbsp;&nbsp;&nbsp; 解决办法： 直接去掉那两个包 <br /><br />****************************** <br />4.6 时区设置问题 <br />****************************** <br />&nbsp;&nbsp;&nbsp; 解决linux与windows的时间同步问题 <br />&nbsp;&nbsp;&nbsp; sudo vim /etc/default/rcS <br />&nbsp;&nbsp;&nbsp; 设置 UTC=no <br /><br />****************************** <br />4.7 修改默认打开程序 <br />****************************** <br />&nbsp;&nbsp;&nbsp; 这个问题跟两个文件有关：&nbsp; <br />&nbsp;&nbsp;&nbsp; /etc/gnome/defaults.list （这个文件保存了全局的打开方式） <br />&nbsp;&nbsp;&nbsp; ~/.local/share/applications/mimeapps.list （这个文件保存了个人的打开方式）&nbsp; <br />&nbsp;&nbsp; 建议只更改当前用户的配置文件 <br />&nbsp;&nbsp; 也可用在Nautilus中选择属性，从打开方式标签更改 <br /><br />****************************** <br />4.8 相关命令 <br />****************************** <br />&nbsp;&nbsp;&nbsp; 查看uvesafb支持的分辨率：/sys/bus/platform/drivers/uvesafb/uvesafb.0/vbe_modes <br />&nbsp;&nbsp;&nbsp; 关于framebuffer的说明可以查看Gentoo文档，另外/usr/src/linux/Documentation/fb/uvesafb.txt列出了所有变量 <br />&nbsp;&nbsp;&nbsp; /etc/X11/xorg.conf可查看显卡驱动及相关信息 <br />&nbsp;&nbsp;&nbsp; 让硬盘进入休眠：sudo hdparm -Y /dev/sda <img src ="http://www.blogjava.net/tiandizhijian/aggbug/432199.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tiandizhijian/" target="_blank">做强大的自己</a> 2016-12-27 21:51 <a href="http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432199.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Docker学习笔记（八）构建私有库 </title><link>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432198.html</link><dc:creator>做强大的自己</dc:creator><author>做强大的自己</author><pubDate>Tue, 27 Dec 2016 13:41:00 GMT</pubDate><guid>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432198.html</guid><wfw:comment>http://www.blogjava.net/tiandizhijian/comments/432198.html</wfw:comment><comments>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432198.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tiandizhijian/comments/commentRss/432198.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tiandizhijian/services/trackbacks/432198.html</trackback:ping><description><![CDATA[<h2 id="articleHeader57">十、构建私有库 </h2><p>Docker 官方提供了 docker registry 的构建方法 <a href="https://github.com/docker/docker-registry">docker-registry </a></p><h3 id="articleHeader58">10.1 快速构建 </h3><p>快速构建 docker registry 通过以下两步: </p><ul><li>安装 docker </li><li>运行 registry:docker run -p 5000:5000 registry </li></ul><p>这种方法通过 Docker hub 使用官方镜像 <a href="https://registry.hub.docker.com/_/registry/">official image from the Docker hub</a> </p><h3 id="articleHeader59">10.2 不使用容器构建 registry </h3><h4>安装必要的软件 </h4><div><pre>$ sudo apt-get install build-essential python-dev libevent-dev python-pip liblzma-dev</pre></div><h4>配置 docker-registry </h4><div><pre>sudo pip install docker-registry</pre></div><p>或者 使用 github clone 手动安装 </p><div><pre>$ git clone https://github.com/dotcloud/docker-registry.git
$ cd docker-registry/
$ cp config/config_sample.yml config/config.yml
$ mkdir /data/registry -p
$ pip install .</pre></div><h4>运行 </h4><div><pre>docker-registry</pre></div><h4>高级启动方式 [不推荐] </h4><p>使用gunicorn控制: </p><div><pre>gunicorn -c contrib/gunicorn_config.py docker_registry.wsgi:application</pre></div><p>或者对外监听开放 </p><div><pre>gunicorn --access-logfile - --error-logfile - -k gevent -b 0.0.0.0:5000 -w 4 --max-requests 100 docker_registry.wsgi:application</pre></div><h3 id="articleHeader60">10.3 提交指定容器到私有库 </h3><div><pre>$ docker tag ubuntu:12.04 私有库IP:5000/ubuntu:12.04
$ docker push 私有库IP:5000/ubuntu</pre></div><p>更多的配置选项推荐阅读官方文档: </p><ul><li><a href="https://github.com/docker/docker-registry/blob/master/README.md">Docker-Registry README</a> </li><li><a href="https://github.com/docker/docker-registry/blob/master/ADVANCED.md">Docker-Registry advanced use</a> </li></ul><img src ="http://www.blogjava.net/tiandizhijian/aggbug/432198.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tiandizhijian/" target="_blank">做强大的自己</a> 2016-12-27 21:41 <a href="http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432198.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Docker学习笔记（七）链接容器 </title><link>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432197.html</link><dc:creator>做强大的自己</dc:creator><author>做强大的自己</author><pubDate>Tue, 27 Dec 2016 13:40:00 GMT</pubDate><guid>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432197.html</guid><wfw:comment>http://www.blogjava.net/tiandizhijian/comments/432197.html</wfw:comment><comments>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432197.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tiandizhijian/comments/commentRss/432197.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tiandizhijian/services/trackbacks/432197.html</trackback:ping><description><![CDATA[<h2 id="articleHeader54">九、链接容器 </h2><p>docker 允许把多个容器连接在一起，相互交互信息。docker 链接会创建一种容器父子级别的关系，其中父容器可以看到其子容器提供的信息。 </p><h3 id="articleHeader55">9.1 容器命名 </h3><p>在创建容器时，如果不指定容器的名字，则默认会自动创建一个名字，这里推荐给容器命名： </p><ul><li>1、给容器命名方便记忆，如命名运行 web 应用的容器为 web </li><li>2、为 docker 容器提供一个参考，允许方便其他容器调用，如把容器 web 链接到容器 db </li></ul><p>可以通过--name选项给容器自定义命名： </p><div><pre>$ sudo docker run -d -t -i --name test ubuntu:14.04 bash              
$ sudo docker  inspect --format="{{ .Nmae }}" test
/test</pre></div><blockquote><p>注：容器名称必须唯一，即你只能命名一个叫test的容器。如果你想复用容器名，则必须在创建新的容器前通过docker rm删除旧的容器或者创建容器时添加--rm选项。 </p></blockquote><h3 id="articleHeader56">9.2 链接容器 </h3><p>链接允许容器间安全通信，使用--link选项创建链接。 </p><div><pre>$ sudo docker run -d --name db training/postgres</pre></div><p>基于 training/postgres 镜像创建一个名为 db 的容器，然后下面创建一个叫做 web 的容器，并且将它与 db 相互连接在一起 </p><div><pre>$ sudo docker run -d -P --name web --link db:db training/webapp python app.py</pre></div><p>--link &lt;name or id&gt;:alias选项指定链接到的容器。 </p><p>查看 web 容器的链接关系: </p><div><pre>$ sudo docker inspect -f "{{ .HostConfig.Links }}" web
[/db:/web/db]</pre></div><p>可以看到 web 容器被链接到 db 容器为/web/db，这允许 web 容器访问 db 容器的信息。 </p><p>容器之间的链接实际做了什么？一个链接允许一个源容器提供信息访问给一个接收容器。在本例中，web 容器作为一个接收者，允许访问源容器 db 的相关服务信息。Docker 创建了一个安全隧道而不需要对外公开任何端口给外部容器，因此不需要在创建容器的时候添加-p或-P指定对外公开的端口，这也是链接容器的最大好处，本例为 PostgreSQL 数据库。 </p><p>Docker 主要通过以下两个方式提供连接信息给接收容器： </p><ul><li>环境变量 </li><li>更新/etc/hosts文件 </li></ul><h4>环境变量 </h4><p>当两个容器链接，Docker 会在目标容器上设置一些环境变量，以获取源容器的相关信息。 </p><p>首先，Docker 会在每个通过--link选项指定别名的目标容器上设置一个&lt;alias&gt;_NAME环境变量。如果一个名为 web 的容器通过--link db:webdb被链接到一个名为 db 的数据库容器，那么 web 容器上会设置一个环境变量为WEBDB_NAME=/web/webdb. </p><p>以之前的为例，Docker 还会设置端口变量: </p><div><pre>$ sudo docker run --rm --name web2 --link db:db training/webapp env
. . .
DB_NAME=/web2/db
DB_PORT=tcp://172.17.0.5:5432           
DB_PORT_5432_TCP=tcp://172.17.0.5:5432  # &lt;name&gt;_PORT_&lt;port&gt;_&lt;protocol&gt; 协议可以是 TCP 或 UDP
DB_PORT_5432_TCP_PROTO=tcp
DB_PORT_5432_TCP_PORT=5432
DB_PORT_5432_TCP_ADDR=172.17.0.5
. . .</pre></div><blockquote><p>注：这些环境变量只设置给容器中的第一个进程，类似一些守护进程 (如 sshd ) 当他们派生 shells 时会清除这些变量 </p></blockquote><h4>更新/etc/hosts文件 </h4><p>除了环境变量，Docker 会在目标容器上添加相关主机条目到/etc/hosts中，上例中就是 web 容器。 </p><div><pre>$ sudo docker run -t -i --rm --link db:db training/webapp /bin/bash
root@aed84ee21bde:/opt/webapp# cat /etc/hosts
172.17.0.7  aed84ee21bde
. . .
172.17.0.5  db</pre></div><blockquote><p>/etc/host文件在源容器被重启之后会自动更新 IP 地址，而环境变量中的 IP 地址则不会自动更新的。 </p></blockquote><img src ="http://www.blogjava.net/tiandizhijian/aggbug/432197.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tiandizhijian/" target="_blank">做强大的自己</a> 2016-12-27 21:40 <a href="http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432197.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Docker学习笔记（六）容器数据管理 </title><link>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432196.html</link><dc:creator>做强大的自己</dc:creator><author>做强大的自己</author><pubDate>Tue, 27 Dec 2016 13:39:00 GMT</pubDate><guid>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432196.html</guid><wfw:comment>http://www.blogjava.net/tiandizhijian/comments/432196.html</wfw:comment><comments>http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432196.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/tiandizhijian/comments/commentRss/432196.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/tiandizhijian/services/trackbacks/432196.html</trackback:ping><description><![CDATA[<h2 id="articleHeader49">八、容器数据管理 </h2><p>docker管理数据的方式有两种： </p><ul><li>数据卷 </li><li>数据卷容器 </li></ul><h3 id="articleHeader50">8.1 数据卷 </h3><p>数据卷是一个或多个容器专门指定绕过Union File System的目录，为持续性或共享数据提供一些有用的功能： </p><ul><li>数据卷可以在容器间共享和重用 </li><li>数据卷数据改变是直接修改的 </li><li>数据卷数据改变不会被包括在容器中 </li><li>数据卷是持续性的，直到没有容器使用它们 </li></ul><h4>添加一个数据卷 </h4><p>你可以使用-v选项添加一个数据卷，或者可以使用多次-v选项为一个 docker 容器运行挂载多个数据卷。 </p><div><pre>$ sudo docker run --name data -v /data -t -i ubuntu:14.04 /bin/bash # 创建数据卷绑定到到新建容器，新建容器中会创建 /data 数据卷 bash-4.1# ls -ld /data/
drwxr-xr-x 2 root root 4096 Jul 23 06:59 /data/
bash-4.1# df -Th
Filesystem    Type    Size  Used Avail Use% Mounted on
... ...
              ext4     91G  4.6G   82G   6% /data</pre></div><p>创建的数据卷可以通过docker inspect获取宿主机对应路径 </p><div><pre>$ sudo docker inspect data
... ... "Volumes": { "/data": "/var/lib/docker/vfs/dir/151de401d268226f96d824fdf444e77a4500aed74c495de5980c807a2ffb7ea9" }, # 可以看到创建的数据卷宿主机路径 ... ...</pre></div><p>或者直接指定获取 </p><div><pre>$ sudo docker inspect --format="{{ .Volumes }}" data
map[/data: /var/lib/docker/vfs/dir/151de401d268226f96d824fdf444e77a4500aed74c495de5980c807a2ffb7ea9]</pre></div><h4>挂载宿主机目录为一个数据卷 </h4><p>-v选项除了可以创建卷，也可以挂载当前主机的一个目录到容器中。 </p><div><pre>$ sudo docker run --name web -v /source/:/web -t -i ubuntu:14.04 /bin/bash
bash-4.1# ls -ld /web/
drwxr-xr-x 2 root root 4096 Jul 23 06:59 /web/
bash-4.1# df -Th
... ...
              ext4     91G  4.6G   82G   6% /web
bash-4.1# exit </pre></div><p>默认挂载卷是可读写的，可以在挂载时指定只读 </p><div><pre>$ sudo docker run --rm --name test -v /source/:/test:ro -t -i ubuntu:14.04 /bin/bash</pre></div><h3 id="articleHeader51">8.2 创建和挂载一个数据卷容器 </h3><p>如果你有一些持久性的数据并且想在容器间共享，或者想用在非持久性的容器上，最好的方法是创建一个数据卷容器，然后从此容器上挂载数据。 </p><p>创建数据卷容器 </p><div><pre>$ sudo docker run -t -i -d -v /test --name test ubuntu:14.04 echo hello</pre></div><p>使用--volumes-from选项在另一个容器中挂载 /test 卷。不管 test 容器是否运行，其它容器都可以挂载该容器数据卷，当然如果只是单独的数据卷是没必要运行容器的。 </p><div><pre>$ sudo docker run -t -i -d --volumes-from test --name test1 ubuntu:14.04 /bin/bash</pre></div><p>添加另一个容器 </p><div><pre>$ sudo docker run -t -i -d --volumes-from test --name test2 ubuntu:14.04 /bin/bash</pre></div><p>也可以继承其它挂载有 /test 卷的容器 </p><div><pre>$ sudo docker run -t -i -d --volumes-from test1 --name test3 ubuntu:14.04 /bin/bash</pre></div><p><img width="652" height="209" alt="非常详细的 Docker 学习笔记" src="http://static.open-open.com/lib/uploadImg/20150212/20150212091035_912.png" /> </p><h3 id="articleHeader52">8.3 备份、恢复或迁移数据卷 </h3><h4>备份 </h4><div><pre>$ sudo docker run --rm --volumes-from test -v $(pwd):/backup ubuntu:14.04 tar cvf /backup/test.tar /test
tar: Removing leading `/' from member names
/test/
/test/b
/test/d
/test/c
/test/a</pre></div><p>启动一个新的容器并且从test容器中挂载卷，然后挂载当前目录到容器中为 backup，并备份 test 卷中所有的数据为 test.tar，执行完成之后删除容器--rm，此时备份就在当前的目录下，名为test.tar。 </p><div><pre>$ ls # 宿主机当前目录下产生了 test 卷的备份文件 test.tar test.tar</pre></div><h4>恢复 </h4><p>你可以恢复给同一个容器或者另外的容器，新建容器并解压备份文件到新的容器数据卷 </p><div><pre>$ sudo docker run -t -i -d -v /test --name test4 ubuntu:14.04  /bin/bash $ sudo docker run --rm --volumes-from test4 -v $(pwd):/backup ubuntu:14.04 tar xvf /backup/test.tar -C / # 恢复之前的文件到新建卷中，执行完后自动删除容器 test/ test/b test/d test/c test/a</pre></div><h3 id="articleHeader53">8.4 删除 Volumes </h3><p>Volume 只有在下列情况下才能被删除： </p><ul><li>docker rm -v删除容器时添加了-v选项 </li><li>docker run --rm运行容器时添加了--rm选项 </li></ul><p>否则，会在/var/lib/docker/vfs/dir目录中遗留很多不明目录。 </p><p>参考文档： </p><ul><li><a href="http://docs.docker.com/userguide/dockervolumes/#data-volumes">Managing Data in Containers</a> </li><li><a href="http://dockerone.com/article/128">深入理解Docker Volume（一） </a></li><li><a href="http://dockerone.com/article/129">深入理解Docker Volume（二）</a> </li></ul><img src ="http://www.blogjava.net/tiandizhijian/aggbug/432196.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/tiandizhijian/" target="_blank">做强大的自己</a> 2016-12-27 21:39 <a href="http://www.blogjava.net/tiandizhijian/archive/2016/12/27/432196.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>