﻿<?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>C++博客-哈士奇_部落格</title><link>http://www.cppblog.com/wuyaowugang/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 14 Apr 2026 23:10:12 GMT</lastBuildDate><pubDate>Tue, 14 Apr 2026 23:10:12 GMT</pubDate><ttl>60</ttl><item><title>Linux netstat命令详解</title><link>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185005.html</link><dc:creator>拉风</dc:creator><author>拉风</author><pubDate>Wed, 25 Jul 2012 03:07:00 GMT</pubDate><guid>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185005.html</guid><wfw:comment>http://www.cppblog.com/wuyaowugang/comments/185005.html</wfw:comment><comments>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185005.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wuyaowugang/comments/commentRss/185005.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wuyaowugang/services/trackbacks/185005.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>简介</strong></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">Netstat&nbsp;命令用于显示各种网络相关信息，如网络连接，路由表，接口状态&nbsp;(Interface&nbsp;Statistics)，masquerade&nbsp;连接，多播成员&nbsp;(Multicast&nbsp;Memberships)&nbsp;等等。</p><strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">输出信息含义</strong><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">执行netstat后，其输出结果为</p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>Active&nbsp;Internet&nbsp;connections&nbsp;(w/o&nbsp;servers)<br />Proto&nbsp;Recv-Q&nbsp;Send-Q&nbsp;Local&nbsp;Address&nbsp;Foreign&nbsp;Address&nbsp;State<br />tcp&nbsp;02210.34.6.89:telnet&nbsp;210.34.6.96:2873ESTABLISHED<br />tcp&nbsp;2960210.34.6.89:1165210.34.6.84:netbios-ssn&nbsp;ESTABLISHED<br />tcp&nbsp;00localhost.localdom:9001localhost.localdom:1162ESTABLISHED<br />tcp&nbsp;00localhost.localdom:1162localhost.localdom:9001ESTABLISHED<br />tcp&nbsp;080210.34.6.89:1161210.34.6.10:netbios-ssn&nbsp;CLOSE<br /><br />Active&nbsp;UNIX&nbsp;domain&nbsp;sockets&nbsp;(w/o&nbsp;servers)<br />Proto&nbsp;RefCnt&nbsp;Flags&nbsp;Type&nbsp;State&nbsp;I-Node&nbsp;Path<br />unix&nbsp;1[&nbsp;]&nbsp;STREAM&nbsp;CONNECTED&nbsp;16178@000000dd<br />unix&nbsp;1[&nbsp;]&nbsp;STREAM&nbsp;CONNECTED&nbsp;16176@000000dc<br />unix&nbsp;9[&nbsp;]&nbsp;DGRAM&nbsp;5292/dev/log<br />unix&nbsp;1[&nbsp;]&nbsp;STREAM&nbsp;CONNECTED&nbsp;16182@000000df<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br />从整体上看，netstat的输出结果可以分为两个部分：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">一个是Active&nbsp;Internet&nbsp;connections，称为有源TCP连接，其中"Recv-Q"和"Send-Q"指%0A的是接收队列和发送队列。这些数字一般都应该是0。如果不是则表示软件包正在队列中堆积。这种情况只能在非常少的情况见到。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">另一个是Active&nbsp;UNIX&nbsp;domain&nbsp;sockets，称为有源Unix域套接口(和网络套接字一样，但是只能用于本机通信，性能可以提高一倍)。<br />Proto显示连接使用的协议,RefCnt表示连接到本套接口上的进程号,Types显示套接口的类型,State显示套接口当前的状态,Path表示连接到套接口的其它进程使用的路径名。</p><strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">常见参数</strong><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">-a&nbsp;(all)显示所有选项，默认不显示LISTEN相关<br />-t&nbsp;(tcp)仅显示tcp相关选项<br />-u&nbsp;(udp)仅显示udp相关选项<br />-n&nbsp;拒绝显示别名，能显示数字的全部转化成数字。<br />-l&nbsp;仅列出有在&nbsp;Listen&nbsp;(监听)&nbsp;的服務状态</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">-p&nbsp;显示建立相关链接的程序名<br />-r&nbsp;显示路由信息，路由表<br />-e&nbsp;显示扩展信息，例如uid等<br />-s&nbsp;按各个协议进行统计<br />-c&nbsp;每隔一个固定时间，执行该netstat命令。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">提示：LISTEN和LISTENING的状态只有用-a或者-l才能看到</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;</p><strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">实用命令实例</strong><strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></strong><strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">1.&nbsp;列出所有端口&nbsp;(包括监听和未监听的)</strong><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>&nbsp;&nbsp;列出所有端口&nbsp;netstat&nbsp;-a</strong></p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>#&nbsp;netstat&nbsp;-a&nbsp;|&nbsp;more<br />Active&nbsp;Internet&nbsp;connections&nbsp;(servers&nbsp;and&nbsp;established)<br />Proto&nbsp;Recv-Q&nbsp;Send-Q&nbsp;Local&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Foreign&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00localhost:30037*:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN<br />udp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00*:bootpc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*:*<br /><br />Active&nbsp;UNIX&nbsp;domain&nbsp;sockets&nbsp;(servers&nbsp;and&nbsp;established)<br />Proto&nbsp;RefCnt&nbsp;Flags&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I-Node&nbsp;&nbsp;&nbsp;Path<br />unix&nbsp;&nbsp;2[&nbsp;ACC&nbsp;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STREAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTENING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6135/tmp/.X11-unix/X0<br />unix&nbsp;&nbsp;2[&nbsp;ACC&nbsp;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STREAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTENING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5140/var/run/acpid.socket<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>&nbsp;&nbsp;列出所有&nbsp;tcp&nbsp;端口&nbsp;netstat&nbsp;-at</strong></p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>#&nbsp;netstat&nbsp;-at<br />Active&nbsp;Internet&nbsp;connections&nbsp;(servers&nbsp;and&nbsp;established)<br />Proto&nbsp;Recv-Q&nbsp;Send-Q&nbsp;Local&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Foreign&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00localhost:30037*:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00localhost:ipp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00*:smtp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN<br />tcp6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00localhost:ipp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[::]:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>&nbsp;&nbsp;列出所有&nbsp;udp&nbsp;端口&nbsp;netstat&nbsp;-au</strong></p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>#&nbsp;netstat&nbsp;-au<br />Active&nbsp;Internet&nbsp;connections&nbsp;(servers&nbsp;and&nbsp;established)<br />Proto&nbsp;Recv-Q&nbsp;Send-Q&nbsp;Local&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Foreign&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State<br />udp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00*:bootpc&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*:*<br />udp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00*:49119*:*<br />udp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00*:mdns&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*:*<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></strong><strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">2.&nbsp;列出所有处于监听状态的&nbsp;Sockets</strong><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>&nbsp;&nbsp;只显示监听端口&nbsp;netstat&nbsp;-l</strong></p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>#&nbsp;netstat&nbsp;-l<br />Active&nbsp;Internet&nbsp;connections&nbsp;(only&nbsp;servers)<br />Proto&nbsp;Recv-Q&nbsp;Send-Q&nbsp;Local&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Foreign&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00localhost:ipp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN<br />tcp6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00localhost:ipp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[::]:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN<br />udp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00*:49119*:*<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>&nbsp;&nbsp;只列出所有监听&nbsp;tcp&nbsp;端口&nbsp;netstat&nbsp;-lt</strong></p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>#&nbsp;netstat&nbsp;-lt<br />Active&nbsp;Internet&nbsp;connections&nbsp;(only&nbsp;servers)<br />Proto&nbsp;Recv-Q&nbsp;Send-Q&nbsp;Local&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Foreign&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00localhost:30037*:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00*:smtp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN<br />tcp6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00localhost:ipp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[::]:*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTEN<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>&nbsp;&nbsp;只列出所有监听&nbsp;udp&nbsp;端口&nbsp;netstat&nbsp;-lu</strong></p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">#&nbsp;netstat&nbsp;-lu<br />Active&nbsp;Internet&nbsp;connections&nbsp;(only&nbsp;servers)<br />Proto&nbsp;Recv-Q&nbsp;Send-Q&nbsp;Local&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Foreign&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State<br />udp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00*:49119*:*<br />udp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00*:mdns&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*:*</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>&nbsp;&nbsp;只列出所有监听&nbsp;UNIX&nbsp;端口&nbsp;netstat&nbsp;-lx</strong></p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>#&nbsp;netstat&nbsp;-lx<br />Active&nbsp;UNIX&nbsp;domain&nbsp;sockets&nbsp;(only&nbsp;servers)<br />Proto&nbsp;RefCnt&nbsp;Flags&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I-Node&nbsp;&nbsp;&nbsp;Path<br />unix&nbsp;&nbsp;2[&nbsp;ACC&nbsp;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STREAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTENING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6294private/maildrop<br />unix&nbsp;&nbsp;2[&nbsp;ACC&nbsp;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STREAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTENING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6203public/cleanup<br />unix&nbsp;&nbsp;2[&nbsp;ACC&nbsp;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STREAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTENING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6302private/ifmail<br />unix&nbsp;&nbsp;2[&nbsp;ACC&nbsp;]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;STREAM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LISTENING&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;6306private/bsmtp<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><br /></div><strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">3.&nbsp;显示每个协议的统计信息</strong><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>&nbsp;&nbsp;显示所有端口的统计信息&nbsp;netstat&nbsp;-s</strong></p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>#&nbsp;netstat&nbsp;-s<br />Ip:<br />11150total&nbsp;packets&nbsp;received<br />1with&nbsp;invalid&nbsp;addresses<br />0forwarded<br />0incoming&nbsp;packets&nbsp;discarded<br />11149incoming&nbsp;packets&nbsp;delivered<br />11635requests&nbsp;sent&nbsp;out<br />Icmp:<br />0ICMP&nbsp;messages&nbsp;received<br />0input&nbsp;ICMP&nbsp;message&nbsp;failed.<br />Tcp:<br />582active&nbsp;connections&nbsp;openings<br />2failed&nbsp;connection&nbsp;attempts<br />25connection&nbsp;resets&nbsp;received<br />Udp:<br />1183packets&nbsp;received<br />4packets&nbsp;to&nbsp;unknown&nbsp;port&nbsp;received.<br />.....<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>&nbsp;&nbsp;显示&nbsp;TCP&nbsp;或&nbsp;UDP&nbsp;端口的统计信息&nbsp;netstat&nbsp;-st&nbsp;或&nbsp;-su</strong></p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">#&nbsp;netstat&nbsp;-st&nbsp;<br />#&nbsp;netstat&nbsp;-su</div>&nbsp;<strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">4.&nbsp;在&nbsp;netstat&nbsp;输出中显示&nbsp;PID&nbsp;和进程名称&nbsp;netstat&nbsp;-p</strong><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">netstat&nbsp;-p&nbsp;可以与其它开关一起使用，就可以添加&nbsp;&#8220;PID/进程名称&#8221;&nbsp;到&nbsp;netstat&nbsp;输出中，这样&nbsp;debugging&nbsp;的时候可以很方便的发现特定端口运行的程序。</p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">#&nbsp;netstat&nbsp;-pt<br />Active&nbsp;Internet&nbsp;connections&nbsp;(w/o&nbsp;servers)<br />Proto&nbsp;Recv-Q&nbsp;Send-Q&nbsp;Local&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Foreign&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PID/Program&nbsp;name<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10ramesh-laptop.loc:47212192.168.185.75:www&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CLOSE_WAIT&nbsp;&nbsp;2109/firefox<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00ramesh-laptop.loc:52750lax:www&nbsp;ESTABLISHED&nbsp;2109/firefox</div><strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">5.&nbsp;在&nbsp;netstat&nbsp;输出中不显示主机，端口和用户名&nbsp;(host,&nbsp;port&nbsp;or&nbsp;user)</strong><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">当你不想让主机，端口和用户名显示，使用&nbsp;netstat&nbsp;-n。将会使用数字代替那些名称。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">同样可以加速输出，因为不用进行比对查询。</p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">#&nbsp;netstat&nbsp;-an</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">如果只是不想让这三个名称中的一个被显示，使用以下命令</p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">#&nbsp;netsat&nbsp;-a&nbsp;--numeric-ports<br />#&nbsp;netsat&nbsp;-a&nbsp;--numeric-hosts<br />#&nbsp;netsat&nbsp;-a&nbsp;--numeric-users</div>&nbsp;<strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">6.&nbsp;持续输出&nbsp;netstat&nbsp;信息</strong><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">netstat&nbsp;将每隔一秒输出网络信息。</p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>#&nbsp;netstat&nbsp;-c<br />Active&nbsp;Internet&nbsp;connections&nbsp;(w/o&nbsp;servers)<br />Proto&nbsp;Recv-Q&nbsp;Send-Q&nbsp;Local&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Foreign&nbsp;Address&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;State<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00ramesh-laptop.loc:36130101-101-181-225.ama:www&nbsp;ESTABLISHED<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;11ramesh-laptop.loc:52564101.11.169.230:www&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CLOSING<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;00ramesh-laptop.loc:43758server-101-101-43-2:www&nbsp;ESTABLISHED<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;11ramesh-laptop.loc:42367101.101.34.101:www&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CLOSING<br />^C<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div>&nbsp;<strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">7.&nbsp;显示系统不支持的地址族&nbsp;(Address&nbsp;Families)</strong><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">netstat&nbsp;--verbose</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">在输出的末尾，会有如下的信息</p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">netstat:&nbsp;no&nbsp;support&nbsp;for`AF&nbsp;IPX'on&nbsp;this&nbsp;system.<br />netstat:&nbsp;no&nbsp;support&nbsp;for`AF&nbsp;AX25'on&nbsp;this&nbsp;system.<br />netstat:&nbsp;no&nbsp;support&nbsp;for`AF&nbsp;X25'on&nbsp;this&nbsp;system.<br />netstat:&nbsp;no&nbsp;support&nbsp;for`AF&nbsp;NETROM'on&nbsp;this&nbsp;system.</div>&nbsp;<strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">8.&nbsp;显示核心路由信息&nbsp;netstat&nbsp;-r</strong><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>#&nbsp;netstat&nbsp;-r<br />Kernel&nbsp;IP&nbsp;routing&nbsp;table<br />Destination&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Gateway&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Genmask&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Flags&nbsp;&nbsp;&nbsp;MSS&nbsp;Window&nbsp;&nbsp;irtt&nbsp;Iface<br />192.168.1.0*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;255.255.255.0U&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;000eth2<br />link-local&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;255.255.0.0U&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;000eth2<br />default192.168.1.10.0.0.0UG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;000eth2<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>注意：</strong>&nbsp;使用&nbsp;netstat&nbsp;-rn&nbsp;显示数字格式，不查询主机名称。</p>&nbsp;<strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">9.&nbsp;找出程序运行的端口</strong><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">并不是所有的进程都能找到，没有权限的会不显示，使用&nbsp;root&nbsp;权限查看所有的信息。</p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">#&nbsp;netstat&nbsp;-ap&nbsp;|&nbsp;grep&nbsp;ssh<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10dev-db:ssh&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;101.174.100.22:39213CLOSE_WAIT&nbsp;&nbsp;-<br />tcp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;10dev-db:ssh&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;101.174.100.22:57643CLOSE_WAIT&nbsp;&nbsp;-</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><strong>&nbsp;&nbsp;找出运行在指定端口的进程</strong></p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">#&nbsp;netstat&nbsp;-an&nbsp;|&nbsp;grep&nbsp;':80'</div>&nbsp;<strong style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">10.&nbsp;显示网络接口列表</strong><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>#&nbsp;netstat&nbsp;-i<br />Kernel&nbsp;Interface&nbsp;table<br />Iface&nbsp;&nbsp;&nbsp;MTU&nbsp;Met&nbsp;&nbsp;&nbsp;RX-OK&nbsp;RX-ERR&nbsp;RX-DRP&nbsp;RX-OVR&nbsp;&nbsp;&nbsp;&nbsp;TX-OK&nbsp;TX-ERR&nbsp;TX-DRP&nbsp;TX-OVR&nbsp;Flg<br />eth0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1500000000000BMU<br />eth2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;150002619600026883600BMRU<br />lo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;16436040004000LRU<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">显示详细信息，像是&nbsp;ifconfig&nbsp;使用&nbsp;netstat&nbsp;-ie:</p><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><div><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>#&nbsp;netstat&nbsp;-ie<br />Kernel&nbsp;Interface&nbsp;table<br />eth0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Link&nbsp;encap:Ethernet&nbsp;&nbsp;HWaddr&nbsp;00:10:40:11:11:11<br />UP&nbsp;BROADCAST&nbsp;MULTICAST&nbsp;&nbsp;MTU:1500Metric:1<br />RX&nbsp;packets:0errors:0dropped:0overruns:0frame:0<br />TX&nbsp;packets:0errors:0dropped:0overruns:0carrier:0<br />collisions:0txqueuelen:1000<br />RX&nbsp;bytes:0(0.0B)&nbsp;&nbsp;TX&nbsp;bytes:0(0.0B)<br />Memory:f6ae0000-f6b00000<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><strong><br /></strong><strong>11.&nbsp;IP和TCP分析</strong><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strong>&nbsp;&nbsp;查看连接某服务端口最多的的IP地址</strong></p><div><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>wss8848@ubuntu:~$&nbsp;netstat&nbsp;-nat&nbsp;|&nbsp;grep&nbsp;"192.168.1.15:22"|awk&nbsp;'{print&nbsp;$5}'|awk&nbsp;-F:&nbsp;'{print&nbsp;$1}'|sort|uniq&nbsp;-c|sort&nbsp;-nr|head&nbsp;-20<br />18221.136.168.36<br />3154.74.45.242<br />278.173.31.236<br />262.183.207.98<br />2192.168.1.14<br />2182.48.111.215<br />2124.193.219.34<br />2119.145.41.2<br />2114.255.41.30<br />175.102.11.99<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><strong>&nbsp;&nbsp;TCP各种状态列表</strong></p><div><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>wss8848@ubuntu:~$&nbsp;netstat&nbsp;-nat&nbsp;|awk&nbsp;'{print&nbsp;$6}'<br />established)<br />Foreign<br />LISTEN<br />TIME_WAIT<br />ESTABLISHED<br />TIME_WAIT<br />SYN_SENT<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div>先把状态全都取出来,然后使用uniq&nbsp;-c统计，之后再进行排序。<div><div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div>wss8848@ubuntu:~$&nbsp;netstat&nbsp;-nat&nbsp;|awk&nbsp;'{print&nbsp;$6}'|sort|uniq&nbsp;-c<br />143ESTABLISHED<br />1FIN_WAIT1<br />1Foreign<br />1LAST_ACK<br />36LISTEN<br />6SYN_SENT<br />113TIME_WAIT<br />1established)<div><img src="http://common.cnblogs.com/images/copycode.gif" alt="复制代码" width="20" height="20" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; " /></div></div>最后的命令如下:<div>netstat&nbsp;-nat&nbsp;|awk&nbsp;'{print&nbsp;$6}'|sort|uniq&nbsp;-c|sort&nbsp;-rn</div><strong>分析access.log获得访问前10位的ip地址</strong><div>awk&nbsp;'{print&nbsp;$1}'access.log&nbsp;|sort|uniq&nbsp;-c|sort&nbsp;-nr|head&nbsp;-10</div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">参考资料:<a href="http://blog.maxiang.net/10-netstat-command-examples/139/" target="_blank" style="color: #9f9f9f; ">http://blog.maxiang.net/10-netstat-command-examples/139/</a></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.ipcpu.com/2011/07/netstat-linux/" target="_blank" style="color: #9f9f9f; ">http://www.ipcpu.com/2011/07/netstat-linux/</a></p></div><img src ="http://www.cppblog.com/wuyaowugang/aggbug/185005.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wuyaowugang/" target="_blank">拉风</a> 2012-07-25 11:07 <a href="http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185005.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Debian中设置sudo</title><link>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185004.html</link><dc:creator>拉风</dc:creator><author>拉风</author><pubDate>Wed, 25 Jul 2012 03:06:00 GMT</pubDate><guid>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185004.html</guid><wfw:comment>http://www.cppblog.com/wuyaowugang/comments/185004.html</wfw:comment><comments>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185004.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wuyaowugang/comments/commentRss/185004.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wuyaowugang/services/trackbacks/185004.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp; &nbsp; 安装好Debian后还不能使用sudo</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;如果没有安装sudo，则在root用户下apt-get&nbsp;install&nbsp;sudo</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;在root设置sudoers配制文件</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;chmod&nbsp;+w&nbsp;/etc/sudoers</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;vim&nbsp;/etc/sudoers</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;添加一行&nbsp;username&nbsp;ALL=(ALL)&nbsp;ALL</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;其中username是你的用户名，保存</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;更改sudoers文件权限&nbsp;chmod&nbsp;0440&nbsp;/etc/sudoers</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;退出root</p><img src ="http://www.cppblog.com/wuyaowugang/aggbug/185004.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wuyaowugang/" target="_blank">拉风</a> 2012-07-25 11:06 <a href="http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185004.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Ubuntu安装VMware Workstation8.0.3</title><link>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185003.html</link><dc:creator>拉风</dc:creator><author>拉风</author><pubDate>Wed, 25 Jul 2012 03:06:00 GMT</pubDate><guid>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185003.html</guid><wfw:comment>http://www.cppblog.com/wuyaowugang/comments/185003.html</wfw:comment><comments>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185003.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wuyaowugang/comments/commentRss/185003.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wuyaowugang/services/trackbacks/185003.html</trackback:ping><description><![CDATA[<div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">Ubuntu安装VMware&nbsp;Workstation8.0.3</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">由于使用Ubuntu的人比较少，网上关于Ubuntu的资料也很少，笔者在安装VMware&nbsp;Workstation时就遇到了问题，首先网上关于Ubuntu12.04先行版的内容比较少，其次关于在Ubuntu12.04下安装VMware&nbsp;Workstation8.0.3最新版的资料就更少。</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">我遇到的问题是：</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">1.&nbsp;<a href="http://www.2cto.com/soft" target="_blank" style="color: #9f9f9f; ">下载</a>好VMware&nbsp;Workstation8.0.3的bundle版本（linux）后，无法运行</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">2.&nbsp;经过几番折腾终于能运行安装后，却无法运行VMware&nbsp;Workstation8.0.3</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">3.&nbsp;安装完VMware&nbsp;Workstation后，通常我们要更改一些设置来优化，但是却也改不了。</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">4.&nbsp;安装完后，想卸载怎么办？&nbsp;&nbsp;www.2cto.com&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">基于以上我遇到的几点问题，经过我半天的努力&#8220;折腾&#8221;终于解决了，半天啊！也够折磨人了，特此拿出来给大家分享，目的就是为了节省大家宝贵的时间！</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">一、下载最新VMware&nbsp;Workstation的bundle版本（linux）【这里笔者已上传至115网盘上了，免得大家还要从官网先注册再下载】</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">32位：http://115.com/file/e7ii0l33</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">64位：http://115.com/file/dpww9wzw</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">二、修改文件的属性</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">下载好后，我们要修改下文件的一个属性，目的是更改程序运行方式，具体如下：</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">进入下载文件的目录，找到下载文件（VMware-Workstation-Full-8.0.3-703057.i386.bundle），右击选择属性，选择权限选项卡，勾选&#8220;允许以程序执行文件&#8221;，完毕</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">或者也可以用终端命令的方式：</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">先cd到下载文件所在目录，然后输入</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">[plain]&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">chmod&nbsp;+x&nbsp;VMware-Workstation-Full-8.0.3-703057.i386.bundle&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">三、运行bundle安装程序，安装VMware&nbsp;Workstation8.0.3</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">四、下载针对linux内核的VMware&nbsp;Workstation8.0.2补丁</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">我们安装完后，运行VMware&nbsp;Workstation时无法运行，具体情况如下：</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><img src="http://b.hiphotos.baidu.com/space/pic/item/342ac65c103853435a0a73b09313b07ecb80885e.jpg" width="502" height="134" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; "  alt="" /><br /><br /><img src="http://f.hiphotos.baidu.com/space/pic/item/b3119313b07eca80c028ce76912397dda1448376.jpg" width="376" height="313" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; margin-bottom: 8px; clear: both; max-width: 758px; vertical-align: top; "  alt="" /><br />&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">上面的意思是vmware的相关服务没有启动，要求你先启动服务再运行程序，然而启动服务的时候&#8220;Virtual&nbsp;Network&nbsp;Device&#8221;却怎么也启动不起来，这其实是Vmware对于最新版Ubuntu的<a href="http://www.2cto.com/os/linux/" target="_blank" style="color: #9f9f9f; ">Linux</a>内核的支持问题，因此需要下载个补丁才能解决此问题，下载地址如下：&nbsp;&nbsp;www.2cto.com&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">vmware802fixlinux320.tar.bz2：http://115.com/file/c28j2n5y</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">五、解压vmware802fixlinux320.tar.bz2，修改patch-modules_3.2.0.sh文件</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">在第7行，将vmreqver=8.0.2改为vmreqver=8.0.3，保存退出</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">因为这个补丁是针对8.0.2版本的，8.0.3版本直接运行这个的话是没有作用的。</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">六、以root权限运行patch-modules_3.2.0.sh</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">打开终端，利用&#8220;cd&#8221;命令进入patch-modules_3.2.0.sh所在文件目录下，并输入以下命令</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">[plain]&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">sudo&nbsp;./patch-modules_3.2.0.sh&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">七、运行&nbsp;，安装VMware&nbsp;Workstation8.0.3，基本上一直next就行</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">八、安装完后，若想修改VMware&nbsp;Workstation的全局设置，需要以root运行程序</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">首先要进入VMware&nbsp;Workstation运行文件所在目录，默认是在&#8220;文件系统&#8221;里（文件系统是类似<a href="http://www.2cto.com/os/windows/" target="_blank" style="color: #9f9f9f; ">windows</a>的c盘里的window文件夹），具体位置是：/usr/bin/vmware</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">可以通过&#8220;主文件夹&#8221;进入，也可以通过终端进入，终端命令如下：</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">[plain]&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&lt;pre&nbsp;name="code"&nbsp;class="plain"&gt;cd&nbsp;../&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">cd&nbsp;../&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">cd&nbsp;usr&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">cd&nbsp;bin&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">sudo&nbsp;./vmware&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">九、卸载VMware&nbsp;Workstation的方法</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">卸载VMware&nbsp;Workstation从&#8220;Ubuntu软件中心&#8221;是找不到的（我是没找到），那么卸载的方法其实跟第七步是类似的</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">首先要进入VMware&nbsp;Workstation卸载文件所在目录，同样是在&#8220;文件系统&#8221;里的&#8220;/usr/bin/&#8221;目录下，卸载我们只能通过终端来运行，命令如下：</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">[plain]&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">cd&nbsp;../&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">cd&nbsp;../&nbsp;&nbsp;&nbsp;&nbsp;www.2cto.com&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">cd&nbsp;usr&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">cd&nbsp;bin&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">sudo&nbsp;./vmware-uninstall&nbsp;&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">好啦，以上就是我关于Ubuntu下安装VMware&nbsp;Workstation8.0.3的一些心得，希望能给需要用的朋友一些帮助。</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br />&nbsp;</div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">作者&nbsp;wangpeng047</div><img src ="http://www.cppblog.com/wuyaowugang/aggbug/185003.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wuyaowugang/" target="_blank">拉风</a> 2012-07-25 11:06 <a href="http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185003.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>debian root 密码破解</title><link>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185002.html</link><dc:creator>拉风</dc:creator><author>拉风</author><pubDate>Wed, 25 Jul 2012 03:05:00 GMT</pubDate><guid>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185002.html</guid><wfw:comment>http://www.cppblog.com/wuyaowugang/comments/185002.html</wfw:comment><comments>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185002.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wuyaowugang/comments/commentRss/185002.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wuyaowugang/services/trackbacks/185002.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">1/debian&nbsp;linux&nbsp;系统密码破解</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　1.在grub选项菜单&#8217;Debian&nbsp;GNU/Linux,...(recovery&nbsp;mode)&#8217;,按e进入编辑模式</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　2.编辑kernel那行面的&nbsp;ro&nbsp;single&nbsp;改成&nbsp;rw&nbsp;single&nbsp;init=/bin/bash,按b执行重启</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　3.进入后执行下列命令</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　root@(none)#mount&nbsp;-a</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　root@(none)#passwd&nbsp;root</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　root@(none)#reboot</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">2/debian&nbsp;linux系统密码破解<br />　　1、在Grub的引导装载程序菜单上,选择你要进入的条目,键入&nbsp;&#8220;e&#8221;&nbsp;来进入编辑模式；<br />　　2、在第二行（类似于kernel&nbsp;/vmlinuz-2.6.15&nbsp;ro&nbsp;root=/dev/hda2&nbsp;）,键入&#8221;e&#8221;进入编辑模式；<br />　　3、在句末加上&#8221;init=/bin/bash&#8221;,回车；<br />　　4、按&#8220;b&#8221;启动系统.<br />　　这样我们即可获得一个bash的shell,进入shell后,根分区的挂载模式默认是只读,我们要将其改为可写,否则不能更改root密码:<br />　　mount&nbsp;-no&nbsp;remount,rw&nbsp;/<br />　　passwd&nbsp;root<br />　　sync<br />　　mount&nbsp;-no&nbsp;remount,ro&nbsp;/<br />　　reboot<br />　　这样即可成功更改debian的root用户的密码.</p><img src ="http://www.cppblog.com/wuyaowugang/aggbug/185002.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wuyaowugang/" target="_blank">拉风</a> 2012-07-25 11:05 <a href="http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185002.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>expect 讲解</title><link>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185001.html</link><dc:creator>拉风</dc:creator><author>拉风</author><pubDate>Wed, 25 Jul 2012 03:04:00 GMT</pubDate><guid>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185001.html</guid><wfw:comment>http://www.cppblog.com/wuyaowugang/comments/185001.html</wfw:comment><comments>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185001.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wuyaowugang/comments/commentRss/185001.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wuyaowugang/services/trackbacks/185001.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">使用expect实现自动登录的脚本，网上有很多，可是都没有一个明白的说明，初学者一般都是照抄、收藏。可是为什么要这么写却不知其然。本文用一个最短的例子说明脚本的原理。&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">脚本代码如下：&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">##############################################&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">#!/usr/bin/expect&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">set&nbsp;timeout&nbsp;30&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">spawn&nbsp;ssh&nbsp;-l&nbsp;username&nbsp;192.168.1.1&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">expect&nbsp;"password:"&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">send&nbsp;"ispass/r"&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">interact&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">##############################################&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">1.&nbsp;［#!/usr/bin/expect］&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">这一行告诉操作系统脚本里的代码使用那一个shell来执行。这里的expect其实和linux下的bash、windows下的cmd是一类东西。&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">注意：这一行需要在脚本的第一行。&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">2.&nbsp;［set&nbsp;timeout&nbsp;30］&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">基本上认识英文的都知道这是设置超时时间的，现在你只要记住他的计时单位是：秒&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">3.&nbsp;［spawn&nbsp;ssh&nbsp;-l&nbsp;username&nbsp;192.168.1.1］&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">spawn是进入expect环境后才可以执行的expect内部命令，如果没有装expect或者直接在默认的SHELL下执行是找不到spawn命令的。所以不要用&nbsp;&#8220;which&nbsp;spawn&#8220;之类的命令去找spawn命令。好比windows里的dir就是一个内部命令，这个命令由shell自带，你无法找到一个dir.com&nbsp;或&nbsp;dir.exe&nbsp;的可执行文件。&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">它主要的功能是给ssh运行进程加个壳，用来传递交互指令。&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">4.&nbsp;［expect&nbsp;"password:"］&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">这里的expect也是expect的一个内部命令，有点晕吧，expect的shell命令和内部命令是一样的，但不是一个功能，习惯就好了。这个命令的意思是判断上次输出结果里是否包含&#8220;password:&#8221;的字符串，如果有则立即返回，否则就等待一段时间后返回，这里等待时长就是前面设置的30秒&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">5.&nbsp;［send&nbsp;"ispass/r"］&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">这里就是执行交互动作，与手工输入密码的动作等效。&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">温馨提示：&nbsp;命令字符串结尾别忘记加上&nbsp;&#8220;/r&#8221;，如果出现异常等待的状态可以核查一下。&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">6.&nbsp;［interact］&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">执行完成后保持交互状态，把控制权交给控制台，这个时候就可以手工操作了。如果没有这一句登录完成后会退出，而不是留在远程终端上。如果你只是登录过去执行一段命令就退出，可改为［expect&nbsp;eof］</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">百度知道解答：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">shell脚本&nbsp;，在linux&nbsp;下运行一个shell脚本登陆远程unix&nbsp;服务器</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">#!/usr/local/bin/expect</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　set&nbsp;timeout&nbsp;10</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　spawn&nbsp;ssh&nbsp;root@ip</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　expect&nbsp;"*password*"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　send&nbsp;"123456\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　expect&nbsp;"#"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　send&nbsp;"service&nbsp;crond&nbsp;restart\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">　　expect&nbsp;eof</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">我的脚本：</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">set&nbsp;timeout&nbsp;30&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">spawn&nbsp;ssh&nbsp;-l&nbsp;www-data&nbsp;192.168.206.120&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">expect&nbsp;"*password:"&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">send&nbsp;"123456\r"&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">send&nbsp;"\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">expect&nbsp;"$"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">send&nbsp;"mysqldump&nbsp;-uroot&nbsp;-p123456&nbsp;mysql&nbsp;&gt;&nbsp;/data/webroot/mysql.sql\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">send&nbsp;"cd\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">send&nbsp;"tar&nbsp;vzcf&nbsp;mysql.sql.tar.gz&nbsp;mysql.sql\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">expect&nbsp;eof<br /><br /><br /><br /><br /><br /><br /><br /><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">#!/usr/bin/expect&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">set&nbsp;timeout&nbsp;30&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">spawn&nbsp;ssh&nbsp;-l&nbsp;www-data&nbsp;192.168.206.120&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">expect&nbsp;"*password:"&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">&nbsp;&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">send&nbsp;"123456\r"&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">send&nbsp;"\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">expect&nbsp;"$"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">send&nbsp;"mysqldump&nbsp;-uroot&nbsp;-p123456&nbsp;mysql&nbsp;&gt;&nbsp;/data/webroot/mysql.sql\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">send&nbsp;"cd\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">send&nbsp;"tar&nbsp;vzcf&nbsp;mysql.sql.tar.gz&nbsp;mysql.sql\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">send&nbsp;"date\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">expect&nbsp;eof</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">wuyao@wuyao-Insp</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">wuyao@wuyao-Inspiron-1427:~$&nbsp;cat&nbsp;mysql_download_20120712.sh&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">#!/usr/bin/expect</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">spawn&nbsp;scp&nbsp;www-data@192.168.206.120:/data/webroot/mysql.sql.tar.gz&nbsp;/home/wuyao/</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">expect&nbsp;"password:"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">send&nbsp;"123456\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">expect&nbsp;"$"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">send&nbsp;"mysql&nbsp;-uroot&nbsp;-p123456&nbsp;mysql&nbsp;&lt;&nbsp;/data/mysql.sql.tar.gz\r"</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">expect&nbsp;eof</p><div></div><br /><br /><br /></p><img src ="http://www.cppblog.com/wuyaowugang/aggbug/185001.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wuyaowugang/" target="_blank">拉风</a> 2012-07-25 11:04 <a href="http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185001.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>神奇的ps命令详解以及pstree top等管理监控命令</title><link>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185000.html</link><dc:creator>拉风</dc:creator><author>拉风</author><pubDate>Wed, 25 Jul 2012 03:03:00 GMT</pubDate><guid>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185000.html</guid><wfw:comment>http://www.cppblog.com/wuyaowugang/comments/185000.html</wfw:comment><comments>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185000.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wuyaowugang/comments/commentRss/185000.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wuyaowugang/services/trackbacks/185000.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: ps：将某个时间点的程序运作情况撷取下来?[root@linux&nbsp;~]#&nbsp;ps&nbsp;aux[root@linux&nbsp;~]#&nbsp;ps&nbsp;-lA[root@linux&nbsp;~]#&nbsp;ps&nbsp;axjf参数：-A&nbsp;：所有的&nbsp;process&nbsp;均显示出来，与&nbsp;-e&nbsp;具有同样的效用；-a&n...&nbsp;&nbsp;<a href='http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185000.html'>阅读全文</a><img src ="http://www.cppblog.com/wuyaowugang/aggbug/185000.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wuyaowugang/" target="_blank">拉风</a> 2012-07-25 11:03 <a href="http://www.cppblog.com/wuyaowugang/archive/2012/07/25/185000.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>LINUX任务(jobs)详解</title><link>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184999.html</link><dc:creator>拉风</dc:creator><author>拉风</author><pubDate>Wed, 25 Jul 2012 03:02:00 GMT</pubDate><guid>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184999.html</guid><wfw:comment>http://www.cppblog.com/wuyaowugang/comments/184999.html</wfw:comment><comments>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184999.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wuyaowugang/comments/commentRss/184999.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wuyaowugang/services/trackbacks/184999.html</trackback:ping><description><![CDATA[<div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">LINUX任务(jobs)详解</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">在用管理员执行一个命令后，用Ctrl+Z把命令转移到了后台。导致无法退出root的。</p></div><div style="color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><br />输入命令：exit<br />终端显示：There&nbsp;are&nbsp;stopped&nbsp;jobs.<br /><br />解决方法：<br />方法一、输入命令：jobs<br />终端显示：[1]+&nbsp;Stopped&nbsp;vim&nbsp;/etc/network/interfaces&nbsp;&gt;&nbsp;/home/leo/Desktop/ip.txt&nbsp;(wd:&nbsp;/)</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">KILL&nbsp;%1<br /><br />方法二、输入命令：jobs&nbsp;-l<br />终端显示：[1]+&nbsp;4664&nbsp;停止&nbsp;vim&nbsp;/etc/network/interfaces&nbsp;&gt;&nbsp;/home/leo/Desktop/ip.txt&nbsp;(wd:&nbsp;/)<br /><br />看到4664,这个就是PID了<br /><br />现在开始杀掉它：<br />输入命令:kill&nbsp;4664<br />终端没有显示。ok。<br /><br />再用jobs命令查看，确认已经杀掉了</p><div>Linux&nbsp;Jobs等前后台运行命令解</div><div><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">A,Shell支持作用控制，有以下命令：&nbsp;<br />1.&nbsp;command&amp;&nbsp;让进程在后台运行&nbsp;<br />2.&nbsp;jobs&nbsp;查看后台运行的进程&nbsp;<br />3.&nbsp;fg&nbsp;%n&nbsp;让后台运行的进程n到前台来&nbsp;<br />4.&nbsp;bg&nbsp;%n&nbsp;让进程n到后台去；&nbsp;&nbsp;&nbsp;<br />PS:"n"为jobs查看到的进程编号.</p></div><div></div></div><img src ="http://www.cppblog.com/wuyaowugang/aggbug/184999.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wuyaowugang/" target="_blank">拉风</a> 2012-07-25 11:02 <a href="http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184999.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mysqldump 导出数据库文件出错</title><link>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184998.html</link><dc:creator>拉风</dc:creator><author>拉风</author><pubDate>Wed, 25 Jul 2012 03:02:00 GMT</pubDate><guid>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184998.html</guid><wfw:comment>http://www.cppblog.com/wuyaowugang/comments/184998.html</wfw:comment><comments>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184998.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wuyaowugang/comments/commentRss/184998.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wuyaowugang/services/trackbacks/184998.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">mysqldump&nbsp;-uhigh_tv&nbsp;-phigh_tv&nbsp;-hdb199&nbsp;-P3300&nbsp;high_tv&nbsp;films&nbsp;&gt;&nbsp;/data/webroot/high_tv.films.120711.sql&nbsp;</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">mysqldump:&nbsp;Got&nbsp;error:&nbsp;1044:&nbsp;Access&nbsp;denied&nbsp;for&nbsp;user&nbsp;'high_tv'@'192.168.1.%'&nbsp;to&nbsp;database&nbsp;'high_tv'&nbsp;when&nbsp;doing&nbsp;LOCK&nbsp;TABLES</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">意思大概是拒绝high_tv用户访问，因为tables&nbsp;被lock，但是可以用来正常的登陆。。。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">所以需要一个命令来解除锁定</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">--skip-lock-tables<br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">mysqldump&nbsp;-uhigh_tv&nbsp;-phigh_tv&nbsp;-hdb199&nbsp;-P3300&nbsp;--skip-lock-tables&nbsp;high_tv&nbsp;films&nbsp;&gt;&nbsp;/data/webroot/high_tv.films.120711.sql</p><img src ="http://www.cppblog.com/wuyaowugang/aggbug/184998.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wuyaowugang/" target="_blank">拉风</a> 2012-07-25 11:02 <a href="http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184998.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>[Debian]alias 用法及配置</title><link>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184997.html</link><dc:creator>拉风</dc:creator><author>拉风</author><pubDate>Wed, 25 Jul 2012 03:01:00 GMT</pubDate><guid>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184997.html</guid><wfw:comment>http://www.cppblog.com/wuyaowugang/comments/184997.html</wfw:comment><comments>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184997.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wuyaowugang/comments/commentRss/184997.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wuyaowugang/services/trackbacks/184997.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp; &nbsp; alias是一个非常有用的配置，在linux中，通过alias可以把一些常用但是又比较长的指令用一些简写代替。比如ls&nbsp;－al简写成ll，还有就是一些比较危险的指令最好加一个显示提示的选项，比如在rm的时候默认提示是否要删除等等，这些命令和设置都是非常好用的。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">设置很简单，只要在&nbsp;终端输入</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">$&nbsp;alias&nbsp;ll='ls&nbsp;-al'</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">&nbsp;&nbsp;&nbsp;&nbsp;这样输入ll就显示的是ls&nbsp;-al的效果，很不错吧。但是这样有个问题就是，如果下次登入的时候，设置还是回到以前，怎么办？其实这样修改用户根目录下一个文件就可以了。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">$&nbsp;vim&nbsp;.bashrc（这里注明一下，因为我发觉vim这个比默认的vi好用，其实你用vi也是一样的效果，）</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">然后把下面几行</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">#&nbsp;some&nbsp;more&nbsp;ls&nbsp;aliases<br />alias&nbsp;ll='ls&nbsp;-al'<br />alias&nbsp;la='ls&nbsp;-A'<br />alias&nbsp;rm='rm&nbsp;-i'<br />alias&nbsp;l='ls&nbsp;-CF'<br />修改成需要的就可以了，注意前面如果有#的要删除，不然就被注释掉拉。上面是我的alias设定，你也可以结合自己需要配置自己的alias方式</p><img src ="http://www.cppblog.com/wuyaowugang/aggbug/184997.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wuyaowugang/" target="_blank">拉风</a> 2012-07-25 11:01 <a href="http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184997.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>debian字符界面下的颜色显示和更改</title><link>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184996.html</link><dc:creator>拉风</dc:creator><author>拉风</author><pubDate>Wed, 25 Jul 2012 03:00:00 GMT</pubDate><guid>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184996.html</guid><wfw:comment>http://www.cppblog.com/wuyaowugang/comments/184996.html</wfw:comment><comments>http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184996.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/wuyaowugang/comments/commentRss/184996.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/wuyaowugang/services/trackbacks/184996.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">在linux字符下面，颜色能帮助更好的区分不同的文件，在编辑脚本中，可以起到纠错的作用，下面就讲一下debian字符下颜色的开启和更改</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">ls命令是查看目录下面的文件，一般情况下会有颜色区分，但默认情况下debian是不开启的，所以这时候需要加一个参数&nbsp;--color&nbsp;用来开启ls命令的颜色显示。</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "><br /></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">更改ls&nbsp;参数只能在这一次命令中有颜色效果，为了方便，可以开启shell的颜色</p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: #454545; font-family: Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">修改&nbsp;.bashrc&nbsp;文件<br />每次都带参数未免有些麻烦，最好的方法是把它写到默认配置文件&nbsp;.bashrc&nbsp;里,位于用户目录。<br /><br />$&nbsp;nano&nbsp;~/.bashrc<br /><br />代码:<br />#&nbsp;enable&nbsp;color&nbsp;support&nbsp;of&nbsp;ls&nbsp;and&nbsp;also&nbsp;add&nbsp;handy&nbsp;aliases<br />if["$term"&nbsp;!="dumb"];then<br />export&nbsp;LS_OPTIONS='--color=auto'<br />eva</p><img src ="http://www.cppblog.com/wuyaowugang/aggbug/184996.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/wuyaowugang/" target="_blank">拉风</a> 2012-07-25 11:00 <a href="http://www.cppblog.com/wuyaowugang/archive/2012/07/25/184996.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>