<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet href='http://feed.feedsky.com/styles/temp01.xsl' type='text/xsl' ?><!--这是一个由Feedsy提供技术支持的Feed，为了提高读者阅读的体验，以及满足用户美化自己Feed的需要，我们设计了多种精美的Feed模板，提供给大家选择，所有最终呈现出来的样式，皆由用户自愿选择使用，未经许可，任何团体和个人，请不要擅自修改样式或者盗用，这是对于用户选择权的尊重。--><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:fs="http://www.feedsky.com/namespace/feed" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link href="http://feed.feedsky.com/linuxers" type="application/rss+xml" rel="self"></atom:link><fs:self_link href="http://feed.feedsky.com/linuxers" type="application/rss+xml"></fs:self_link><lastBuildDate>Wed, 02 Jun 2010 00:49:41 GMT</lastBuildDate><title>Linux爱好者</title><description>linux</description><link>http://www.linuxers.cn</link><sy:updatePeriod>hourly</sy:updatePeriod><sy:updateFrequency>1</sy:updateFrequency><language>en</language><pubDate>Wed, 02 Jun 2010 00:52:08 GMT</pubDate><item><title>推荐一个debian源</title><link>http://www.linuxers.cn/2010/06/02/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aadebian%e6%ba%90/</link><content:encoded>&lt;p&gt;我们使用debian的stable版很不爽的一点就是软件比较陈旧，最新版的往往都是在unstable或者testing里。http://www.backports.org/这个网站就是为了解决这个问题出现的，它将testing和unstable里的许多软件重新编译打包提供。&lt;/p&gt;
&lt;p&gt;它的详细使用说明在这里&lt;br /&gt;
&lt;a href=&quot;http://www.backports.org/dokuwiki/doku.php?id=instructions&quot; target=&quot;_blank&quot;&gt;http://www.backports.org/dokuwiki/doku.php?id=instructions&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;主要是下面几步&lt;br /&gt;
1.将deb http://www.backports.org/debian lenny-backports main contrib non-free添加到/etc/apt/sources.list中&lt;br /&gt;
2.执行apt-get install debian-backports-keyring安装key&lt;/p&gt;
&lt;p&gt;然后通过apt-get update更新后即可使用，例如在这个源上能够找到最新版的java6 jdk&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;debian:~$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;apt-cache&lt;/span&gt; search java6
sun-java6-bin - Sun Java&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;TM&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; Runtime Environment &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;JRE&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;architecture dependent files&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;
sun-java6-demo - Sun Java&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;TM&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; Development Kit &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;JDK&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;6&lt;/span&gt; demos and examples
sun-java6-doc - Sun JDK&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;TM&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; Documention &lt;span style=&quot;color: #660033;&quot;&gt;--&lt;/span&gt; integration installer
sun-java6-fonts - Lucida TrueType fonts &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;from the Sun JRE&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;
sun-java6-javadb - Java&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;TM&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; DB, Sun Microsystems&lt;span style=&quot;color: #ff0000;&quot;&gt;' distribution of Apache Derby
sun-java6-jdk - Sun Java(TM) Development Kit (JDK) 6
sun-java6-jre - Sun Java(TM) Runtime Environment (JRE) 6 (architecture independent files)
sun-java6-plugin - The Java(TM) Plug-in, Java SE 6
sun-java6-source - Sun Java(TM) Development Kit (JDK) 6 source files&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p style='text-align:left'&gt;&amp;copy; 2010, &lt;a target='_blank' href='http://www.linuxers.cn'&gt;Linux爱好者&lt;/a&gt;. 版权所有. 转载请注明来自http://www.linuxers.cn&lt;/p&gt;
&lt;h4  class=&quot;related_post_title&quot;&gt;相关日志&lt;/h4&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;2010/06/02 -- &lt;a href=&quot;http://www.linuxers.cn/2010/06/02/%e5%9c%a8debian%e4%b8%8b%e8%ae%be%e7%bd%aeip%e7%9a%84%e6%96%b9%e6%b3%95/&quot; title=&quot;在debian下设置ip的方法&quot;&gt;在debian下设置ip的方法&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/04/23 -- &lt;a href=&quot;http://www.linuxers.cn/2010/04/23/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e6%ba%90%e4%bb%a3%e7%a0%81%e6%b5%8f%e8%a7%88%e7%bd%91%e7%ab%99/&quot; title=&quot;推荐一个源代码浏览网站&quot;&gt;推荐一个源代码浏览网站&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2009/12/03 -- &lt;a href=&quot;http://www.linuxers.cn/2009/12/03/%e4%bd%bf%e7%94%a8apt-spy%e6%89%be%e5%88%b0%e6%9c%80%e5%bf%ab%e7%9a%84debian%e6%ba%90/&quot; title=&quot;使用apt-spy找到最快的debian源&quot;&gt;使用apt-spy找到最快的debian源&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700035/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/06/02/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aadebian%e6%ba%90/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700035/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700035/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.linuxers.cn/2010/06/02/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aadebian%e6%ba%90/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>我们使用debian的stable版很不爽的一点就是软件比较陈旧，最新版的往往都是在unstable或者testing里。http://www.backports.org/这个网站就是为了解决这个问题出现的，它将testing和unstable里的许多软件重新编译打包提供。
它的详细使用说明在这里
&lt;span class=&quot;readmore&quot;&gt;&lt;a href=&quot;http://www.linuxers.cn/2010/06/02/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aadebian%e6%ba%90/&quot; title=&quot;推荐一个debian源&quot; target=&quot;_blank&quot;&gt;Read more 982 words&lt;/a&gt;&lt;/span&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700035/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/06/02/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aadebian%e6%ba%90/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700035/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700035/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>source</category><category>debian</category><category>jdk</category><category>Linux软件</category><pubDate>Wed, 02 Jun 2010 08:49:41 +0800</pubDate><author>leconte</author><comments>http://www.linuxers.cn/2010/06/02/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aadebian%e6%ba%90/#comments</comments><guid isPermaLink="false">http://www.linuxers.cn/?p=499</guid><dc:creator>leconte</dc:creator><fs:srclink>http://www.linuxers.cn/2010/06/02/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aadebian%e6%ba%90/</fs:srclink><fs:srcfeed>http://www.linuxers.cn/feed/</fs:srcfeed><fs:itemid>feedsky/linuxers/~7972096/373700035/6081772</fs:itemid></item><item><title>在debian下设置ip的方法</title><link>http://www.linuxers.cn/2010/06/02/%e5%9c%a8debian%e4%b8%8b%e8%ae%be%e7%bd%aeip%e7%9a%84%e6%96%b9%e6%b3%95/</link><content:encoded>&lt;p&gt;debian和redhat设置ip的地方有所不同，关于redhat的ip设置请看&lt;a href=&quot;http://www.linuxers.cn/2010/03/28/redhat%E4%B8%8B%E7%9A%84%E7%BD%91%E5%8D%A1%E9%85%8D%E7%BD%AE/&quot;&gt;这里&lt;/a&gt;，今天介绍一下debian的配置。&lt;/p&gt;
&lt;p&gt;debian的ip配置文件位于/etc/network/interfaces文件中，我的文件内容如下：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&amp;nbsp;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# This file describes the network interfaces available on your system&lt;/span&gt;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# and how to activate them. For more information, see interfaces(5).&lt;/span&gt;
&amp;nbsp;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# The loopback network interface&lt;/span&gt;
auto lo
iface lo inet loopback
&amp;nbsp;
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;# The primary network interface&lt;/span&gt;
auto eth0
&lt;span style=&quot;color: #666666; font-style: italic;&quot;&gt;#iface eth0 inet dhcp&lt;/span&gt;
iface eth0 inet static
address 10.32.20.33
netmask 255.255.255.0
up route add default gw 10.32.20.62&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;iface eth0 inet static代表eth0这块网卡采用静态ip的方式，address和netmask分别指明了ip地址和子网掩码。&lt;/p&gt;
&lt;p&gt;如果想采用dhcp方式配置ip，则无需指定address和netmask，而只需设置iface eth0 inet dhcp即可。&lt;/p&gt;
&lt;p&gt;up route add default gw 10.32.20.62代表在网卡启动(up)之后自动执行route add default gw 10.32.20.62这条命令，即添加一个默认网关&lt;/p&gt;
&lt;p&gt;auto lo和iface lo inet loopback是设置本次回环接口，即127.0.0.1。&lt;/p&gt;
&lt;p&gt;经过设置后执行/etc/init.d/networking restart即可令修改生效，执行ifconfig可以看到当前的ip配置：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;debian:~$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;sudo&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ifconfig&lt;/span&gt;
eth0      Link encap:Ethernet  HWaddr 00:1a:4b:3e:07:0c
          inet addr:10.32.20.33  Bcast:10.32.20.255  Mask:255.255.255.0
          inet6 addr: fe80::21a:4bff:fe3e:70c&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;64&lt;/span&gt; Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:&lt;span style=&quot;color: #000000;&quot;&gt;1500&lt;/span&gt;  Metric:&lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;
          RX packets:&lt;span style=&quot;color: #000000;&quot;&gt;504593&lt;/span&gt; errors:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; dropped:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; overruns:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; frame:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;
          TX packets:&lt;span style=&quot;color: #000000;&quot;&gt;151595&lt;/span&gt; errors:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; dropped:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; overruns:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; carrier:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;
          collisions:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; txqueuelen:&lt;span style=&quot;color: #000000;&quot;&gt;1000&lt;/span&gt;
          RX bytes:&lt;span style=&quot;color: #000000;&quot;&gt;305990674&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;291.8&lt;/span&gt; MiB&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;  TX bytes:&lt;span style=&quot;color: #000000;&quot;&gt;51901895&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;49.4&lt;/span&gt; MiB&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;
          Interrupt:&lt;span style=&quot;color: #000000;&quot;&gt;16&lt;/span&gt; Base address:0x4000
&amp;nbsp;
lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::&lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;128&lt;/span&gt; Scope:Host
          UP LOOPBACK RUNNING  MTU:&lt;span style=&quot;color: #000000;&quot;&gt;16436&lt;/span&gt;  Metric:&lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;
          RX packets:&lt;span style=&quot;color: #000000;&quot;&gt;173&lt;/span&gt; errors:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; dropped:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; overruns:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; frame:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;
          TX packets:&lt;span style=&quot;color: #000000;&quot;&gt;173&lt;/span&gt; errors:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; dropped:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; overruns:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; carrier:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;
          collisions:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt; txqueuelen:&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;
          RX bytes:&lt;span style=&quot;color: #000000;&quot;&gt;123368&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;120.4&lt;/span&gt; KiB&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;  TX bytes:&lt;span style=&quot;color: #000000;&quot;&gt;123368&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;120.4&lt;/span&gt; KiB&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;可以看到，interfaces文件中的lo和eth0两块设备都正常工作了。&lt;/p&gt;
&lt;p style='text-align:left'&gt;&amp;copy; 2010, &lt;a target='_blank' href='http://www.linuxers.cn'&gt;Linux爱好者&lt;/a&gt;. 版权所有. 转载请注明来自http://www.linuxers.cn&lt;/p&gt;
&lt;h4  class=&quot;related_post_title&quot;&gt;相关日志&lt;/h4&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;2010/06/02 -- &lt;a href=&quot;http://www.linuxers.cn/2010/06/02/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aadebian%e6%ba%90/&quot; title=&quot;推荐一个debian源&quot;&gt;推荐一个debian源&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2009/12/03 -- &lt;a href=&quot;http://www.linuxers.cn/2009/12/03/%e4%bd%bf%e7%94%a8apt-spy%e6%89%be%e5%88%b0%e6%9c%80%e5%bf%ab%e7%9a%84debian%e6%ba%90/&quot; title=&quot;使用apt-spy找到最快的debian源&quot;&gt;使用apt-spy找到最快的debian源&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700036/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/06/02/%e5%9c%a8debian%e4%b8%8b%e8%ae%be%e7%bd%aeip%e7%9a%84%e6%96%b9%e6%b3%95/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700036/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700036/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.linuxers.cn/2010/06/02/%e5%9c%a8debian%e4%b8%8b%e8%ae%be%e7%bd%aeip%e7%9a%84%e6%96%b9%e6%b3%95/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>debian和redhat设置ip的地方有所不同，关于redhat的ip设置请看这里，今天介绍一下debian的配置。
debian的ip配置文件位于/etc/network/interfaces文件中，我的文件内容如下：

&amp;#160;
&lt;span class=&quot;readmore&quot;&gt;&lt;a href=&quot;http://www.linuxers.cn/2010/06/02/%e5%9c%a8debian%e4%b8%8b%e8%ae%be%e7%bd%aeip%e7%9a%84%e6%96%b9%e6%b3%95/&quot; title=&quot;在debian下设置ip的方法&quot; target=&quot;_blank&quot;&gt;Read more 1506 words&lt;/a&gt;&lt;/span&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700036/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/06/02/%e5%9c%a8debian%e4%b8%8b%e8%ae%be%e7%bd%aeip%e7%9a%84%e6%96%b9%e6%b3%95/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700036/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700036/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>debian</category><category>Linux软件</category><category>ip</category><pubDate>Wed, 02 Jun 2010 08:31:24 +0800</pubDate><author>leconte</author><comments>http://www.linuxers.cn/2010/06/02/%e5%9c%a8debian%e4%b8%8b%e8%ae%be%e7%bd%aeip%e7%9a%84%e6%96%b9%e6%b3%95/#comments</comments><guid isPermaLink="false">http://www.linuxers.cn/?p=497</guid><dc:creator>leconte</dc:creator><fs:srclink>http://www.linuxers.cn/2010/06/02/%e5%9c%a8debian%e4%b8%8b%e8%ae%be%e7%bd%aeip%e7%9a%84%e6%96%b9%e6%b3%95/</fs:srclink><fs:srcfeed>http://www.linuxers.cn/feed/</fs:srcfeed><fs:itemid>feedsky/linuxers/~7972096/373700036/6081772</fs:itemid></item><item><title>使用last查看系统最近登录用户记录</title><link>http://www.linuxers.cn/2010/05/19/%e4%bd%bf%e7%94%a8last%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e6%9c%80%e8%bf%91%e7%99%bb%e5%bd%95%e7%94%a8%e6%88%b7%e8%ae%b0%e5%bd%95/</link><content:encoded>&lt;p&gt;linux下的last命令可以用来查看最近登录过的用户记录，包括详细的时间和时长，例如:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;web ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;last&lt;/span&gt;
leconte  pts&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;        114.251.86.0     Wed May &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;42&lt;/span&gt;   still logged &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;in&lt;/span&gt;
leconte  pts&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;        114.251.86.0     Wed May &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;17&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;22&lt;/span&gt; - &lt;span style=&quot;color: #000000;&quot;&gt;17&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;22&lt;/span&gt;  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;00:00&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;
leconte  pts&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;        114.252.182.234  Tue May &lt;span style=&quot;color: #000000;&quot;&gt;18&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;21&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;47&lt;/span&gt; - &lt;span style=&quot;color: #000000;&quot;&gt;22&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;00:&lt;span style=&quot;color: #000000;&quot;&gt;28&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;
leconte  pts&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;        114.251.86.0     Fri May  &lt;span style=&quot;color: #000000;&quot;&gt;7&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;18&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;26&lt;/span&gt; - &lt;span style=&quot;color: #000000;&quot;&gt;18&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;56&lt;/span&gt;  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;00:&lt;span style=&quot;color: #000000;&quot;&gt;30&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;
leconte  pts&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;        114.251.86.0     Fri Apr &lt;span style=&quot;color: #000000;&quot;&gt;23&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;11&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;49&lt;/span&gt; - &lt;span style=&quot;color: #000000;&quot;&gt;11&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;51&lt;/span&gt;  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;00:02&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;
leconte  pts&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;        114.251.86.0     Mon Apr &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;17&lt;/span&gt;:03 - &lt;span style=&quot;color: #000000;&quot;&gt;17&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;30&lt;/span&gt;  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;00:&lt;span style=&quot;color: #000000;&quot;&gt;27&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;
leconte  pts&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;        114.251.86.0     Mon Apr &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;10&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;56&lt;/span&gt; - &lt;span style=&quot;color: #000000;&quot;&gt;11&lt;/span&gt;:03  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;00:06&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;
leconte  pts&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;        121.0.29.237     Tue Apr &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;25&lt;/span&gt; - &lt;span style=&quot;color: #000000;&quot;&gt;16&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt;  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;00:&lt;span style=&quot;color: #000000;&quot;&gt;47&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;
leconte  pts&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;        121.0.29.237     Tue Apr &lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;16&lt;/span&gt; - &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;24&lt;/span&gt;  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;00:08&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;
...&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;通过这个清单起码可以部分排除服务器被别人非法登录的情况，当然，手法严谨的高手是不会留下蛛丝马迹的。他们往往清空这个记录让你无迹可查。&lt;/p&gt;
&lt;p&gt;通过strace跟踪会发现last实际读取的是/var/log/wtmp这个文件&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;open&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/var/log/wtmp&amp;quot;&lt;/span&gt;, O_RDONLY&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;         = &lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;
fstat64&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;, &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #007800;&quot;&gt;st_mode&lt;/span&gt;=S_IFREG&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt;0664, &lt;span style=&quot;color: #007800;&quot;&gt;st_size&lt;/span&gt;=&lt;span style=&quot;color: #000000;&quot;&gt;264576&lt;/span&gt;, ...&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;
mmap2&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;NULL, &lt;span style=&quot;color: #000000;&quot;&gt;4096&lt;/span&gt;, PROT_READ&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt;PROT_WRITE, MAP_PRIVATE&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt;MAP_ANONYMOUS, -&lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; = 0xb7fea000
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;read&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;\10\0\0\0\255\1\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0&amp;quot;&lt;/span&gt;..., &lt;span style=&quot;color: #000000;&quot;&gt;4096&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;span style=&quot;color: #000000;&quot;&gt;4096&lt;/span&gt;
fstat64&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;, &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #007800;&quot;&gt;st_mode&lt;/span&gt;=S_IFREG&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt;0664, &lt;span style=&quot;color: #007800;&quot;&gt;st_size&lt;/span&gt;=&lt;span style=&quot;color: #000000;&quot;&gt;264576&lt;/span&gt;, ...&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;如果我手工删除这个文件，再执行last则会是这样的结果：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;web log&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;sudo&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;mv&lt;/span&gt; wtmp wtmp.bk
Password:
&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;web log&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;last&lt;/span&gt;
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;last&lt;/span&gt;: &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;var&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;log&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;wtmp: No such &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;file&lt;/span&gt; or directory
Perhaps this &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;file&lt;/span&gt; was removed by the operator to prevent logging &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;last&lt;/span&gt; info.&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;所以last的输出不可全信，毕竟服务器被入侵的话别人如果想删除wtmp文件是轻而易举的事情。&lt;/p&gt;
&lt;p style='text-align:left'&gt;&amp;copy; 2010, &lt;a target='_blank' href='http://www.linuxers.cn'&gt;Linux爱好者&lt;/a&gt;. 版权所有. 转载请注明来自http://www.linuxers.cn&lt;/p&gt;
&lt;h4  class=&quot;related_post_title&quot;&gt;相关日志&lt;/h4&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;2010/02/08 -- &lt;a href=&quot;http://www.linuxers.cn/2010/02/08/%e4%bd%bf%e7%94%a8strace%e5%92%8cltrace%e5%8a%a8%e6%80%81%e8%b7%9f%e8%b8%aa%e7%a8%8b%e5%ba%8f/&quot; title=&quot;使用strace和ltrace动态跟踪程序&quot;&gt;使用strace和ltrace动态跟踪程序&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/01/22 -- &lt;a href=&quot;http://www.linuxers.cn/2010/01/22/%e4%bd%bf%e7%94%a8ltrace%e8%b7%9f%e8%b8%aa%e5%ba%93%e5%87%bd%e6%95%b0%e8%b0%83%e7%94%a8/&quot; title=&quot;使用ltrace跟踪库函数调用&quot;&gt;使用ltrace跟踪库函数调用&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/01/11 -- &lt;a href=&quot;http://www.linuxers.cn/2010/01/11/%e7%b3%bb%e7%bb%9f%e8%b0%83%e7%94%a8%e8%b7%9f%e8%b8%aa%e5%b7%a5%e5%85%b7strace/&quot; title=&quot;系统调用跟踪工具strace&quot;&gt;系统调用跟踪工具strace&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700037/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/05/19/%e4%bd%bf%e7%94%a8last%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e6%9c%80%e8%bf%91%e7%99%bb%e5%bd%95%e7%94%a8%e6%88%b7%e8%ae%b0%e5%bd%95/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700037/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700037/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.linuxers.cn/2010/05/19/%e4%bd%bf%e7%94%a8last%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e6%9c%80%e8%bf%91%e7%99%bb%e5%bd%95%e7%94%a8%e6%88%b7%e8%ae%b0%e5%bd%95/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>linux下的last命令可以用来查看最近登录过的用户记录，包括详细的时间和时长，例如:

&amp;#91;leconte@web ~&amp;#93;$ last
leconte  pts/0        114.251.86.0     Wed May 19 19:42   still logged in
&lt;span class=&quot;readmore&quot;&gt;&lt;a href=&quot;http://www.linuxers.cn/2010/05/19/%e4%bd%bf%e7%94%a8last%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e6%9c%80%e8%bf%91%e7%99%bb%e5%bd%95%e7%94%a8%e6%88%b7%e8%ae%b0%e5%bd%95/&quot; title=&quot;使用last查看系统最近登录用户记录&quot; target=&quot;_blank&quot;&gt;Read more 1174 words&lt;/a&gt;&lt;/span&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700037/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/05/19/%e4%bd%bf%e7%94%a8last%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e6%9c%80%e8%bf%91%e7%99%bb%e5%bd%95%e7%94%a8%e6%88%b7%e8%ae%b0%e5%bd%95/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700037/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700037/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>last</category><category>strace</category><category>Linux软件</category><pubDate>Wed, 19 May 2010 19:53:07 +0800</pubDate><author>leconte</author><comments>http://www.linuxers.cn/2010/05/19/%e4%bd%bf%e7%94%a8last%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e6%9c%80%e8%bf%91%e7%99%bb%e5%bd%95%e7%94%a8%e6%88%b7%e8%ae%b0%e5%bd%95/#comments</comments><guid isPermaLink="false">http://www.linuxers.cn/?p=495</guid><dc:creator>leconte</dc:creator><fs:srclink>http://www.linuxers.cn/2010/05/19/%e4%bd%bf%e7%94%a8last%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e6%9c%80%e8%bf%91%e7%99%bb%e5%bd%95%e7%94%a8%e6%88%b7%e8%ae%b0%e5%bd%95/</fs:srclink><fs:srcfeed>http://www.linuxers.cn/feed/</fs:srcfeed><fs:itemid>feedsky/linuxers/~7972096/373700037/6081772</fs:itemid></item><item><title>使用uptime查看系统启动时间</title><link>http://www.linuxers.cn/2010/05/07/%e4%bd%bf%e7%94%a8uptime%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e6%97%b6%e9%97%b4/</link><content:encoded>&lt;p&gt;哈哈，我的几个小站服务器硬件虽然很烂，但是到现在为止也坚持了近3个月了。&lt;/p&gt;
&lt;p&gt;show一下以作纪念~&lt;/p&gt;
&lt;p&gt;[leconte@web ~]$ uptime&lt;br /&gt;
 18:26:39 up 98 days,  9:16,  1 user,  load average: 0.10, 0.05, 0.01&lt;/p&gt;
&lt;p&gt;uptime能显示当前时间、电脑启动天数、登录用户数，以及系统负载情况。&lt;/p&gt;
&lt;p&gt;服务器负载很低，毕竟目前还没有跑什么大型的应用，慢慢来吧。&lt;/p&gt;
&lt;p style='text-align:left'&gt;&amp;copy; 2010, &lt;a target='_blank' href='http://www.linuxers.cn'&gt;Linux爱好者&lt;/a&gt;. 版权所有. 转载请注明来自http://www.linuxers.cn&lt;/p&gt;
&lt;h4  class=&quot;related_post_title&quot;&gt;推荐日志&lt;/h4&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;2009/12/13 -- &lt;a href=&quot;http://www.linuxers.cn/2009/12/13/linux%e7%bb%88%e7%ab%af%e4%b8%8b%e6%9c%80%e5%bc%ba%e5%a4%a7%e7%9a%84%e5%b1%8f%e5%b9%95%e7%ae%a1%e7%90%86%e8%bd%af%e4%bb%b6screen3/&quot; title=&quot;Linux终端下最强大的屏幕管理软件screen(3)&quot;&gt;Linux终端下最强大的屏幕管理软件screen(3)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2009/12/12 -- &lt;a href=&quot;http://www.linuxers.cn/2009/12/12/linux%e7%bb%88%e7%ab%af%e4%b8%8b%e6%9c%80%e5%bc%ba%e5%a4%a7%e7%9a%84%e5%b1%8f%e5%b9%95%e7%ae%a1%e7%90%86%e8%bd%af%e4%bb%b6screen2/&quot; title=&quot;Linux终端下最强大的屏幕管理软件screen(2)&quot;&gt;Linux终端下最强大的屏幕管理软件screen(2)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/01/25 -- &lt;a href=&quot;http://www.linuxers.cn/2010/01/25/%e6%8e%a8%e8%8d%90google%e7%9a%84dns-8-8-8-8/&quot; title=&quot;推荐google的dns 8.8.8.8&quot;&gt;推荐google的dns 8.8.8.8&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/02/09 -- &lt;a href=&quot;http://www.linuxers.cn/2010/02/09/%e4%bd%bf%e7%94%a8watch%e8%bf%9b%e8%a1%8c%e5%ae%9a%e6%9c%9f%e8%a7%82%e6%b5%8b/&quot; title=&quot;使用watch进行定期观测&quot;&gt;使用watch进行定期观测&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/01/22 -- &lt;a href=&quot;http://www.linuxers.cn/2010/01/22/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aaphp%e5%ae%9e%e7%8e%b0%e7%9a%84%e9%a3%9e%e4%bf%a1%e7%9f%ad%e4%bf%a1%e5%ae%a2%e6%88%b7%e7%ab%af/&quot; title=&quot;推荐一个php实现的飞信短信客户端&quot;&gt;推荐一个php实现的飞信短信客户端&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700038/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/05/07/%e4%bd%bf%e7%94%a8uptime%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e6%97%b6%e9%97%b4/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700038/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700038/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.linuxers.cn/2010/05/07/%e4%bd%bf%e7%94%a8uptime%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e6%97%b6%e9%97%b4/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>哈哈，我的几个小站服务器硬件虽然很烂，但是到现在为止也坚持了近3个月了。
show一下以作纪念~
[leconte@web ~]$ uptime
 18:26:39 up 98 days,  9:16,  1 user,  load average: 0.10, 0.05, 0.01
&lt;span class=&quot;readmore&quot;&gt;&lt;a href=&quot;http://www.linuxers.cn/2010/05/07/%e4%bd%bf%e7%94%a8uptime%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e6%97%b6%e9%97%b4/&quot; title=&quot;使用uptime查看系统启动时间&quot; target=&quot;_blank&quot;&gt;Read more 187 words&lt;/a&gt;&lt;/span&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700038/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/05/07/%e4%bd%bf%e7%94%a8uptime%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e6%97%b6%e9%97%b4/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700038/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700038/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>uptime</category><category>Linux软件</category><pubDate>Fri, 07 May 2010 18:31:40 +0800</pubDate><author>leconte</author><comments>http://www.linuxers.cn/2010/05/07/%e4%bd%bf%e7%94%a8uptime%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e6%97%b6%e9%97%b4/#comments</comments><guid isPermaLink="false">http://www.linuxers.cn/?p=493</guid><dc:creator>leconte</dc:creator><fs:srclink>http://www.linuxers.cn/2010/05/07/%e4%bd%bf%e7%94%a8uptime%e6%9f%a5%e7%9c%8b%e7%b3%bb%e7%bb%9f%e5%90%af%e5%8a%a8%e6%97%b6%e9%97%b4/</fs:srclink><fs:srcfeed>http://www.linuxers.cn/feed/</fs:srcfeed><fs:itemid>feedsky/linuxers/~7972096/373700038/6081772</fs:itemid></item><item><title>使用date查看和设置系统时间</title><link>http://www.linuxers.cn/2010/04/29/%e4%bd%bf%e7%94%a8date%e6%9f%a5%e7%9c%8b%e5%92%8c%e8%ae%be%e7%bd%ae%e7%b3%bb%e7%bb%9f%e6%97%b6%e9%97%b4/</link><content:encoded>&lt;p&gt;在linux下可以用date命令方便的查看和修改系统时间。&lt;/p&gt;
&lt;p&gt;不带任何参数执行date将输出系统的当前时间：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;localhost ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;date&lt;/span&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;年 03月 &lt;span style=&quot;color: #000000;&quot;&gt;30&lt;/span&gt;日 星期二 &lt;span style=&quot;color: #000000;&quot;&gt;10&lt;/span&gt;:00:&lt;span style=&quot;color: #000000;&quot;&gt;37&lt;/span&gt; CST&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;这里显示中文是因为我的LC_ALL是zh_CN.UTF-8，date这个命令是支持这些标准locale环境变量的。如果将LC_ALL设置为C的话，将会输出英文:&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;localhost ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;export&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;LC_ALL&lt;/span&gt;=C
&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;localhost ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;date&lt;/span&gt;
Tue Mar &lt;span style=&quot;color: #000000;&quot;&gt;30&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;10&lt;/span&gt;:01:&lt;span style=&quot;color: #000000;&quot;&gt;12&lt;/span&gt; CST &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;通过date -s 可以对系统时间进行设置，例如：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;localhost ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;sudo&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;date&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-s&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'2010-04-29 22:00:00'&lt;/span&gt;
Thu Apr &lt;span style=&quot;color: #000000;&quot;&gt;29&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;22&lt;/span&gt;:00:00 CST &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;设置的时间格式其实很灵活，例如通过&amp;#8217;20100429 22:00:00&amp;#8242;也可以达到同样的效果。&lt;/p&gt;
&lt;p&gt;此外也可以仅设置时间，例如：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;localhost ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;sudo&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;date&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-s&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'11:00:00'&lt;/span&gt;
Password:
Thu Apr &lt;span style=&quot;color: #000000;&quot;&gt;29&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;11&lt;/span&gt;:00:00 CST &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;需要注意设置系统时间是需要root权限的，因此需要sudo后执行。如果用strace跟踪就会发现，其实date存取时间访问的是/etc/localtime这个文件，例如用date读取时间的时候，跟踪结果的片段如下：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;open&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;/etc/localtime&amp;quot;&lt;/span&gt;, O_RDONLY&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;        = &lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;
fstat64&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;, &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #007800;&quot;&gt;st_mode&lt;/span&gt;=S_IFREG&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt;0644, &lt;span style=&quot;color: #007800;&quot;&gt;st_size&lt;/span&gt;=&lt;span style=&quot;color: #000000;&quot;&gt;405&lt;/span&gt;, ...&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;
fstat64&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;, &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#123;&lt;/span&gt;&lt;span style=&quot;color: #007800;&quot;&gt;st_mode&lt;/span&gt;=S_IFREG&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt;0644, &lt;span style=&quot;color: #007800;&quot;&gt;st_size&lt;/span&gt;=&lt;span style=&quot;color: #000000;&quot;&gt;405&lt;/span&gt;, ...&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;
mmap2&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;NULL, &lt;span style=&quot;color: #000000;&quot;&gt;4096&lt;/span&gt;, PROT_READ&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt;PROT_WRITE, MAP_PRIVATE&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt;MAP_ANONYMOUS, -&lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt;, &lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; = 0xb7ffc000
&lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;read&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;TZif2\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\3\0\0\0\3\0\0\0\0&amp;quot;&lt;/span&gt;..., &lt;span style=&quot;color: #000000;&quot;&gt;4096&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt; = &lt;span style=&quot;color: #000000;&quot;&gt;405&lt;/span&gt;
close&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000;&quot;&gt;3&lt;/span&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#41;&lt;/span&gt;                                = &lt;span style=&quot;color: #000000;&quot;&gt;0&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;用file和ls查看这个文件可以看到，它仅是root可写的&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;localhost ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;file&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;localtime
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;localtime: timezone data
&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;localhost ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ls&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-al&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;localtime
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-r--r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; root root &lt;span style=&quot;color: #000000;&quot;&gt;405&lt;/span&gt; Oct &lt;span style=&quot;color: #000000;&quot;&gt;22&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2009&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;etc&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;localtime&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;用file也能看到它是timezone类型的数据，file命令对数据格式收集的还是挺全的。&lt;/p&gt;
&lt;p style='text-align:left'&gt;&amp;copy; 2010, &lt;a target='_blank' href='http://www.linuxers.cn'&gt;Linux爱好者&lt;/a&gt;. 版权所有. 转载请注明来自http://www.linuxers.cn&lt;/p&gt;
&lt;h4  class=&quot;related_post_title&quot;&gt;相关日志&lt;/h4&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;2010/04/20 -- &lt;a href=&quot;http://www.linuxers.cn/2010/04/20/linux%e4%b8%8b%e6%9c%80%e7%ae%80%e5%8d%95%e7%9a%84%e7%a7%92%e8%a1%a8/&quot; title=&quot;linux下最简单的秒表&quot;&gt;linux下最简单的秒表&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/01/12 -- &lt;a href=&quot;http://www.linuxers.cn/2010/01/12/%e4%bd%bf%e7%94%a8time%e5%91%bd%e4%bb%a4%e8%8e%b7%e5%8f%96%e5%91%bd%e4%bb%a4%e6%89%a7%e8%a1%8c%e6%97%b6%e9%97%b4/&quot; title=&quot;使用time命令获取命令执行时间&quot;&gt;使用time命令获取命令执行时间&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700039/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/29/%e4%bd%bf%e7%94%a8date%e6%9f%a5%e7%9c%8b%e5%92%8c%e8%ae%be%e7%bd%ae%e7%b3%bb%e7%bb%9f%e6%97%b6%e9%97%b4/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700039/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700039/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.linuxers.cn/2010/04/29/%e4%bd%bf%e7%94%a8date%e6%9f%a5%e7%9c%8b%e5%92%8c%e8%ae%be%e7%bd%ae%e7%b3%bb%e7%bb%9f%e6%97%b6%e9%97%b4/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>在linux下可以用date命令方便的查看和修改系统时间。
不带任何参数执行date将输出系统的当前时间：

&amp;#91;leconte@localhost ~&amp;#93;$ date
&lt;span class=&quot;readmore&quot;&gt;&lt;a href=&quot;http://www.linuxers.cn/2010/04/29/%e4%bd%bf%e7%94%a8date%e6%9f%a5%e7%9c%8b%e5%92%8c%e8%ae%be%e7%bd%ae%e7%b3%bb%e7%bb%9f%e6%97%b6%e9%97%b4/&quot; title=&quot;使用date查看和设置系统时间&quot; target=&quot;_blank&quot;&gt;Read more 1132 words&lt;/a&gt;&lt;/span&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700039/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/29/%e4%bd%bf%e7%94%a8date%e6%9f%a5%e7%9c%8b%e5%92%8c%e8%ae%be%e7%bd%ae%e7%b3%bb%e7%bb%9f%e6%97%b6%e9%97%b4/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700039/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700039/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>date</category><category>Linux软件</category><category>time</category><pubDate>Thu, 29 Apr 2010 20:42:18 +0800</pubDate><author>leconte</author><comments>http://www.linuxers.cn/2010/04/29/%e4%bd%bf%e7%94%a8date%e6%9f%a5%e7%9c%8b%e5%92%8c%e8%ae%be%e7%bd%ae%e7%b3%bb%e7%bb%9f%e6%97%b6%e9%97%b4/#comments</comments><guid isPermaLink="false">http://www.linuxers.cn/?p=491</guid><dc:creator>leconte</dc:creator><fs:srclink>http://www.linuxers.cn/2010/04/29/%e4%bd%bf%e7%94%a8date%e6%9f%a5%e7%9c%8b%e5%92%8c%e8%ae%be%e7%bd%ae%e7%b3%bb%e7%bb%9f%e6%97%b6%e9%97%b4/</fs:srclink><fs:srcfeed>http://www.linuxers.cn/feed/</fs:srcfeed><fs:itemid>feedsky/linuxers/~7972096/373700039/6081772</fs:itemid></item><item><title>推荐一个源代码浏览网站</title><link>http://www.linuxers.cn/2010/04/23/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e6%ba%90%e4%bb%a3%e7%a0%81%e6%b5%8f%e8%a7%88%e7%bd%91%e7%ab%99/</link><content:encoded>&lt;p&gt;今天在逛水木linux dev版的时候发现了一个不错的网站，&lt;a href=&quot;http://www.sooset.com&quot; target=&quot;_blank&quot;&gt;www.sooset.com&lt;/a&gt;，它可以提供在线的源代码浏览。目前提供的工程很多了，比如kernel，lucene,apache等。&lt;/p&gt;
&lt;p&gt;它目前支持在右侧以文件夹形式浏览，对于C和Cpp等常见格式的文件都可以做到语法高亮；左侧有一个符号列表，能列出在当前文章中出现的符号；当你在源代码中点击那些符号的时候，在下边会列出该项目中所有出现该符号的文件，点击它可以在各个文件中进行切换。整体如图所示：&lt;br /&gt;
&lt;a href=&quot;http://www.linuxers.cn/wp-content/uploads/2010/04/12.png&quot;&gt;&lt;img class=&quot;alignnone size-medium wp-image-489&quot; title=&quot;1&quot; src=&quot;http://www.linuxers.cn/wp-content/uploads/2010/04/12-672x312.png&quot; alt=&quot;1&quot; width=&quot;672&quot; height=&quot;312&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;整体看来就像是一个整合了ctags,filemanager功能的vim，值得称赞的是它的速度相当快，强烈推荐！&lt;/p&gt;
&lt;p style='text-align:left'&gt;&amp;copy; 2010, &lt;a target='_blank' href='http://www.linuxers.cn'&gt;Linux爱好者&lt;/a&gt;. 版权所有. 转载请注明来自http://www.linuxers.cn&lt;/p&gt;
&lt;h4  class=&quot;related_post_title&quot;&gt;相关日志&lt;/h4&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;2010/06/02 -- &lt;a href=&quot;http://www.linuxers.cn/2010/06/02/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aadebian%e6%ba%90/&quot; title=&quot;推荐一个debian源&quot;&gt;推荐一个debian源&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700040/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/23/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e6%ba%90%e4%bb%a3%e7%a0%81%e6%b5%8f%e8%a7%88%e7%bd%91%e7%ab%99/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700040/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700040/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.linuxers.cn/2010/04/23/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e6%ba%90%e4%bb%a3%e7%a0%81%e6%b5%8f%e8%a7%88%e7%bd%91%e7%ab%99/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>今天在逛水木linux dev版的时候发现了一个不错的网站，www.sooset.com，它可以提供在线的源代码浏览。目前提供的工程很多了，比如kernel，lucene,apache等。
它目前支持在右侧以文件夹形式浏览，对于C和Cpp等常见格式的文件都可以做到语法高亮；左侧有一个符号列表，能列出在当前文章中出现的符号；当你在源代码中点击那些符号的时候，在下边会列出该项目中所有出现该符号的文件，点击它可以在各个文件中进行切换。整体如图所示：
&lt;span class=&quot;readmore&quot;&gt;&lt;a href=&quot;http://www.linuxers.cn/2010/04/23/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e6%ba%90%e4%bb%a3%e7%a0%81%e6%b5%8f%e8%a7%88%e7%bd%91%e7%ab%99/&quot; title=&quot;推荐一个源代码浏览网站&quot; target=&quot;_blank&quot;&gt;Read more 276 words&lt;/a&gt;&lt;/span&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700040/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/23/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e6%ba%90%e4%bb%a3%e7%a0%81%e6%b5%8f%e8%a7%88%e7%bd%91%e7%ab%99/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700040/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700040/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>source</category><category>sooset</category><category>Linux开发</category><pubDate>Fri, 23 Apr 2010 12:18:55 +0800</pubDate><author>leconte</author><comments>http://www.linuxers.cn/2010/04/23/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e6%ba%90%e4%bb%a3%e7%a0%81%e6%b5%8f%e8%a7%88%e7%bd%91%e7%ab%99/#comments</comments><guid isPermaLink="false">http://www.linuxers.cn/?p=488</guid><dc:creator>leconte</dc:creator><fs:srclink>http://www.linuxers.cn/2010/04/23/%e6%8e%a8%e8%8d%90%e4%b8%80%e4%b8%aa%e6%ba%90%e4%bb%a3%e7%a0%81%e6%b5%8f%e8%a7%88%e7%bd%91%e7%ab%99/</fs:srclink><fs:srcfeed>http://www.linuxers.cn/feed/</fs:srcfeed><fs:itemid>feedsky/linuxers/~7972096/373700040/6081772</fs:itemid></item><item><title>linux下最简单的秒表</title><link>http://www.linuxers.cn/2010/04/20/linux%e4%b8%8b%e6%9c%80%e7%ae%80%e5%8d%95%e7%9a%84%e7%a7%92%e8%a1%a8/</link><content:encoded>&lt;p&gt;今天介绍个小玩意，在linux下用最简单的方式实现秒表。&lt;/p&gt;
&lt;p&gt;time这个命令我在之前的文章中介绍过了，它可以用来统计一个程序的执行时间，并且能详细到用户态执行时间和内核态执行时间。read指令是bash内建的命令，它用来从标准输入读取一行数据。将这两个命令相结合即可实现秒表功能。&lt;/p&gt;
&lt;p&gt;执行time read之后将处于等待输入状态，这时候你可以去做想做的事情，比如统计脉搏，再比如你出去跑一圈。做完这些之后在终端上按回车或者Ctrl+D结束输入，此时屏幕就会显示出你耗费的时间。&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;vmout103 tmp&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;time&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;read&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
real    0m6.248s
user    0m0.000s
sys     0m0.000s&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;real的值即耗费的总时间，为6.248s，user和sys的值为0，因为这段时间里该程序一直在等待输入状态，并没有占据CPU时间。&lt;/p&gt;
&lt;p style='text-align:left'&gt;&amp;copy; 2010, &lt;a target='_blank' href='http://www.linuxers.cn'&gt;Linux爱好者&lt;/a&gt;. 版权所有. 转载请注明来自http://www.linuxers.cn&lt;/p&gt;
&lt;h4  class=&quot;related_post_title&quot;&gt;相关日志&lt;/h4&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;2010/04/29 -- &lt;a href=&quot;http://www.linuxers.cn/2010/04/29/%e4%bd%bf%e7%94%a8date%e6%9f%a5%e7%9c%8b%e5%92%8c%e8%ae%be%e7%bd%ae%e7%b3%bb%e7%bb%9f%e6%97%b6%e9%97%b4/&quot; title=&quot;使用date查看和设置系统时间&quot;&gt;使用date查看和设置系统时间&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/01/12 -- &lt;a href=&quot;http://www.linuxers.cn/2010/01/12/%e4%bd%bf%e7%94%a8time%e5%91%bd%e4%bb%a4%e8%8e%b7%e5%8f%96%e5%91%bd%e4%bb%a4%e6%89%a7%e8%a1%8c%e6%97%b6%e9%97%b4/&quot; title=&quot;使用time命令获取命令执行时间&quot;&gt;使用time命令获取命令执行时间&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700041/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/20/linux%e4%b8%8b%e6%9c%80%e7%ae%80%e5%8d%95%e7%9a%84%e7%a7%92%e8%a1%a8/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700041/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700041/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.linuxers.cn/2010/04/20/linux%e4%b8%8b%e6%9c%80%e7%ae%80%e5%8d%95%e7%9a%84%e7%a7%92%e8%a1%a8/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>今天介绍个小玩意，在linux下用最简单的方式实现秒表。
time这个命令我在之前的文章中介绍过了，它可以用来统计一个程序的执行时间，并且能详细到用户态执行时间和内核态执行时间。read指令是bash内建的命令，它用来从标准输入读取一行数据。将这两个命令相结合即可实现秒表功能。
执行time read之后将处于等待输入状态，这时候你可以去做想做的事情，比如统计脉搏，再比如你出去跑一圈。做完这些之后在终端上按回车或者Ctrl+D结束输入，此时屏幕就会显示出你耗费的时间。
&lt;span class=&quot;readmore&quot;&gt;&lt;a href=&quot;http://www.linuxers.cn/2010/04/20/linux%e4%b8%8b%e6%9c%80%e7%ae%80%e5%8d%95%e7%9a%84%e7%a7%92%e8%a1%a8/&quot; title=&quot;linux下最简单的秒表&quot; target=&quot;_blank&quot;&gt;Read more 364 words&lt;/a&gt;&lt;/span&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700041/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/20/linux%e4%b8%8b%e6%9c%80%e7%ae%80%e5%8d%95%e7%9a%84%e7%a7%92%e8%a1%a8/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700041/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700041/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>Linux软件</category><category>time</category><pubDate>Tue, 20 Apr 2010 17:32:12 +0800</pubDate><author>leconte</author><comments>http://www.linuxers.cn/2010/04/20/linux%e4%b8%8b%e6%9c%80%e7%ae%80%e5%8d%95%e7%9a%84%e7%a7%92%e8%a1%a8/#comments</comments><guid isPermaLink="false">http://www.linuxers.cn/?p=486</guid><dc:creator>leconte</dc:creator><fs:srclink>http://www.linuxers.cn/2010/04/20/linux%e4%b8%8b%e6%9c%80%e7%ae%80%e5%8d%95%e7%9a%84%e7%a7%92%e8%a1%a8/</fs:srclink><fs:srcfeed>http://www.linuxers.cn/feed/</fs:srcfeed><fs:itemid>feedsky/linuxers/~7972096/373700041/6081772</fs:itemid></item><item><title>软链接和硬链接</title><link>http://www.linuxers.cn/2010/04/19/%e8%bd%af%e9%93%be%e6%8e%a5%e5%92%8c%e7%a1%ac%e9%93%be%e6%8e%a5/</link><content:encoded>&lt;p&gt;在linux下存在两种文件链接方式，软连接和硬链接，软链接又叫符号链接，它实际上一种类似于windows快捷方式的概念。硬链接实际是文件系统上实现的一种文件指针，它可以令两个文件指向同样一个inode，本质来说他们是一个文件。&lt;/p&gt;
&lt;p&gt;二者都可以通过ln命令来创建。基本的创建语法如下：&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;ln [源] [目标] &lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;默认情况下将会建立硬链接，例如&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;web tmkp&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ln&lt;/span&gt; data ha
&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;web tmkp&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ls&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-al&lt;/span&gt;
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-rw-r--&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2&lt;/span&gt; leconte leconte  &lt;span style=&quot;color: #000000;&quot;&gt;402&lt;/span&gt; Apr &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;11&lt;/span&gt;:00 data
&lt;span style=&quot;color: #660033;&quot;&gt;-rw-rw-r--&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2&lt;/span&gt; leconte leconte  &lt;span style=&quot;color: #000000;&quot;&gt;402&lt;/span&gt; Apr &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;11&lt;/span&gt;:00 ha&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我们为data创建了一个硬链接ha，然后用ls -al去看，它们的大小完全一样，细心的话你会发现在leconte leconte前有一个数字2，这代表的是指向该文件inode的链接数为2，实际就是data和ha这两个文件。&lt;/p&gt;
&lt;p&gt;使用ls -il可以更直观的看到inode号&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;web tmkp&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ls&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-il&lt;/span&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;493327&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-rw-rw-r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;2&lt;/span&gt; leconte leconte &lt;span style=&quot;color: #000000;&quot;&gt;402&lt;/span&gt; Apr &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;17&lt;/span&gt;:06 data
&lt;span style=&quot;color: #000000;&quot;&gt;493327&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-rw-rw-r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;2&lt;/span&gt; leconte leconte &lt;span style=&quot;color: #000000;&quot;&gt;402&lt;/span&gt; Apr &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;17&lt;/span&gt;:06 ha&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;可以看到，data和ha这两个文件的inode号都是493327。&lt;/p&gt;
&lt;p&gt;为ln指定-s参数就可以用来创建软链接（符号链接），这也是我们平常更常用的链接方式&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;web tmkp&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ln&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-fs&lt;/span&gt; data a
&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;web tmkp&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ls&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-il&lt;/span&gt;
total &lt;span style=&quot;color: #000000;&quot;&gt;12&lt;/span&gt;
&lt;span style=&quot;color: #000000;&quot;&gt;493329&lt;/span&gt; lrwxrwxrwx &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; leconte leconte   &lt;span style=&quot;color: #000000;&quot;&gt;4&lt;/span&gt; Apr &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;17&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt; a -&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;gt;&lt;/span&gt; data
&lt;span style=&quot;color: #000000;&quot;&gt;493328&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-rw-rw-r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;1&lt;/span&gt; leconte leconte  &lt;span style=&quot;color: #000000;&quot;&gt;39&lt;/span&gt; Nov &lt;span style=&quot;color: #000000;&quot;&gt;25&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;18&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;27&lt;/span&gt; ab
&lt;span style=&quot;color: #000000;&quot;&gt;493327&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-rw-rw-r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;2&lt;/span&gt; leconte leconte &lt;span style=&quot;color: #000000;&quot;&gt;410&lt;/span&gt; Apr &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;17&lt;/span&gt;:06 data
&lt;span style=&quot;color: #000000;&quot;&gt;493327&lt;/span&gt; &lt;span style=&quot;color: #660033;&quot;&gt;-rw-rw-r--&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;2&lt;/span&gt; leconte leconte &lt;span style=&quot;color: #000000;&quot;&gt;410&lt;/span&gt; Apr &lt;span style=&quot;color: #000000;&quot;&gt;19&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;17&lt;/span&gt;:06 ha&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;我们为data又创建了一个符号链接a，通过ls -il看的时候会发现几点&lt;br /&gt;
1.a的inode号和data不同，它本质上是另外一个文件&lt;br /&gt;
2.ls的结果a-&gt;data直接反映a是指向data的符号链接。&lt;br /&gt;
3.为data增加一个符号链接并不会增加data的链接数，它仍然是2&lt;br /&gt;
4.a的大小为4字节，实际上它只会保存指向信息，并不会保存实际指向文件的内容。&lt;/p&gt;
&lt;p&gt;此外，由于硬链接是基于文件系统实现的，因此是无法跨文件系统创建的，而符号链接可以。&lt;/p&gt;
&lt;p style='text-align:left'&gt;&amp;copy; 2010, &lt;a target='_blank' href='http://www.linuxers.cn'&gt;Linux爱好者&lt;/a&gt;. 版权所有. 转载请注明来自http://www.linuxers.cn&lt;/p&gt;
&lt;h4  class=&quot;related_post_title&quot;&gt;推荐日志&lt;/h4&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;2010/03/17 -- &lt;a href=&quot;http://www.linuxers.cn/2010/03/17/%e6%9f%a5%e7%9c%8blinux%e6%93%8d%e4%bd%9c%e7%b3%bb%e7%bb%9f%e7%89%88%e6%9c%ac%e7%9a%84%e5%b7%a5%e5%85%b7lsb_release/&quot; title=&quot;查看linux操作系统版本的工具lsb_release&quot;&gt;查看linux操作系统版本的工具lsb_release&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/04/02 -- &lt;a href=&quot;http://www.linuxers.cn/2010/04/02/linux%e4%b8%8b%e5%8a%a8%e6%80%81%e9%93%be%e6%8e%a5%e5%ba%93%e7%9a%84%e6%90%9c%e7%b4%a2%e8%b7%af%e5%be%84%e9%85%8d%e7%bd%ae/&quot; title=&quot;linux下动态链接库的搜索路径配置&quot;&gt;linux下动态链接库的搜索路径配置&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/04/13 -- &lt;a href=&quot;http://www.linuxers.cn/2010/04/13/linux%e4%b8%8b%e5%8e%86%e5%8f%b2%e5%91%bd%e4%bb%a4history%e6%b7%bb%e5%8a%a0%e6%97%b6%e9%97%b4%e6%88%b3/&quot; title=&quot;Linux下历史命令(history)添加时间戳&quot;&gt;Linux下历史命令(history)添加时间戳&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/03/28 -- &lt;a href=&quot;http://www.linuxers.cn/2010/03/28/redhat%e4%b8%8b%e7%9a%84%e7%bd%91%e5%8d%a1%e9%85%8d%e7%bd%ae/&quot; title=&quot;Redhat下的网卡配置&quot;&gt;Redhat下的网卡配置&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/01/08 -- &lt;a href=&quot;http://www.linuxers.cn/2010/01/08/%e4%bd%bf%e7%94%a8libsegfault-so%e6%8b%a6%e6%88%aa%e6%ae%b5%e9%94%99%e8%af%af%e4%bf%a1%e5%8f%b7/&quot; title=&quot;使用libSegFault.so拦截段错误信号&quot;&gt;使用libSegFault.so拦截段错误信号&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700042/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/19/%e8%bd%af%e9%93%be%e6%8e%a5%e5%92%8c%e7%a1%ac%e9%93%be%e6%8e%a5/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700042/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700042/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.linuxers.cn/2010/04/19/%e8%bd%af%e9%93%be%e6%8e%a5%e5%92%8c%e7%a1%ac%e9%93%be%e6%8e%a5/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>在linux下存在两种文件链接方式，软连接和硬链接，软链接又叫符号链接，它实际上一种类似于windows快捷方式的概念。硬链接实际是文件系统上实现的一种文件指针，它可以令两个文件指向同样一个inode，本质来说他们是一个文件。
二者都可以通过ln命令来创建。基本的创建语法如下：
ln [源] [目标] 
&lt;span class=&quot;readmore&quot;&gt;&lt;a href=&quot;http://www.linuxers.cn/2010/04/19/%e8%bd%af%e9%93%be%e6%8e%a5%e5%92%8c%e7%a1%ac%e9%93%be%e6%8e%a5/&quot; title=&quot;软链接和硬链接&quot; target=&quot;_blank&quot;&gt;Read more 1070 words&lt;/a&gt;&lt;/span&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700042/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/19/%e8%bd%af%e9%93%be%e6%8e%a5%e5%92%8c%e7%a1%ac%e9%93%be%e6%8e%a5/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700042/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700042/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>link</category><category>Linux软件</category><pubDate>Mon, 19 Apr 2010 17:19:55 +0800</pubDate><author>leconte</author><comments>http://www.linuxers.cn/2010/04/19/%e8%bd%af%e9%93%be%e6%8e%a5%e5%92%8c%e7%a1%ac%e9%93%be%e6%8e%a5/#comments</comments><guid isPermaLink="false">http://www.linuxers.cn/?p=482</guid><dc:creator>leconte</dc:creator><fs:srclink>http://www.linuxers.cn/2010/04/19/%e8%bd%af%e9%93%be%e6%8e%a5%e5%92%8c%e7%a1%ac%e9%93%be%e6%8e%a5/</fs:srclink><fs:srcfeed>http://www.linuxers.cn/feed/</fs:srcfeed><fs:itemid>feedsky/linuxers/~7972096/373700042/6081772</fs:itemid></item><item><title>Linux下历史命令(history)添加时间戳</title><link>http://www.linuxers.cn/2010/04/13/linux%e4%b8%8b%e5%8e%86%e5%8f%b2%e5%91%bd%e4%bb%a4history%e6%b7%bb%e5%8a%a0%e6%97%b6%e9%97%b4%e6%88%b3/</link><content:encoded>&lt;p&gt;熟悉bash的都一定知道使用history可以输出你曾经输入过的历史命令，例如&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;web ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;history&lt;/span&gt;  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;more&lt;/span&gt;
   &lt;span style=&quot;color: #000000;&quot;&gt;25&lt;/span&gt;  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;cd&lt;/span&gt; docroot&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
   &lt;span style=&quot;color: #000000;&quot;&gt;26&lt;/span&gt;  &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ls&lt;/span&gt;
   &lt;span style=&quot;color: #000000;&quot;&gt;27&lt;/span&gt;  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;cd&lt;/span&gt; blog&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
   &lt;span style=&quot;color: #000000;&quot;&gt;28&lt;/span&gt;  &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ls&lt;/span&gt;
   &lt;span style=&quot;color: #000000;&quot;&gt;29&lt;/span&gt;  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;cd&lt;/span&gt; wp-content&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;themes&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;/&lt;/span&gt;
   &lt;span style=&quot;color: #000000;&quot;&gt;30&lt;/span&gt;  &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;ls&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;但是这里只显示了命令，并没有显示执行命令的时间，因为保存历史命令的~/.bash_history里并没有保存时间。&lt;/p&gt;
&lt;p&gt;通过设置环境变量&lt;strong&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;HISTTIMEFORMAT=&amp;#8221;%F %T &amp;#8220;&lt;/span&gt;&lt;/strong&gt;即可为history加上时间戳，例如：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;web ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;export&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;HISTTIMEFORMAT&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;%F %T &amp;quot;&lt;/span&gt;
&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;web ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$ &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;history&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;tail&lt;/span&gt;
  &lt;span style=&quot;color: #000000;&quot;&gt;997&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;-04-&lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;25&lt;/span&gt;:08 &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;history&lt;/span&gt;
  &lt;span style=&quot;color: #000000;&quot;&gt;998&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;-04-&lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;25&lt;/span&gt;:08 &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;history&lt;/span&gt;  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt; gmore
  &lt;span style=&quot;color: #000000;&quot;&gt;999&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;-04-&lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;25&lt;/span&gt;:08 &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;history&lt;/span&gt;  &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;more&lt;/span&gt;
 &lt;span style=&quot;color: #000000;&quot;&gt;1000&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;-04-&lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;25&lt;/span&gt;:08 &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;exit&lt;/span&gt;
 &lt;span style=&quot;color: #000000;&quot;&gt;1001&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;-04-&lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;25&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;10&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;history&lt;/span&gt;
 &lt;span style=&quot;color: #000000;&quot;&gt;1002&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;-04-&lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;37&lt;/span&gt;:07  &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;export&lt;/span&gt; &lt;span style=&quot;color: #007800;&quot;&gt;HISTTIMEFORMAT&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;%F %T &amp;quot;&lt;/span&gt;
 &lt;span style=&quot;color: #000000;&quot;&gt;1003&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;-04-&lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;37&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;12&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;history&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;head&lt;/span&gt;
 &lt;span style=&quot;color: #000000;&quot;&gt;1004&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;-04-&lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;37&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;26&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;history&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;tail&lt;/span&gt;
 &lt;span style=&quot;color: #000000;&quot;&gt;1005&lt;/span&gt;  &lt;span style=&quot;color: #000000;&quot;&gt;2010&lt;/span&gt;-04-&lt;span style=&quot;color: #000000;&quot;&gt;13&lt;/span&gt; &lt;span style=&quot;color: #000000;&quot;&gt;15&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;37&lt;/span&gt;:&lt;span style=&quot;color: #000000;&quot;&gt;37&lt;/span&gt; &lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;history&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;|&lt;/span&gt; &lt;span style=&quot;color: #c20cb9; font-weight: bold;&quot;&gt;head&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;可以看到，历史命令的时间戳已经加上了，但是.bash_history里并没有加上这个时间戳。其实这个时间记录是保存在当前shell进程内存里的，如果你logout并且重新登录的话会发现你上次登录时执行的那些命令的时间戳都为同一个值，即当时logout时的时间。&lt;/p&gt;
&lt;p&gt;尽管如此，对于加上screen的bash来说，这个时间戳仍然可以长时间有效的，毕竟只要你的server不重启，screen就不会退出，因而这些时间就能长时间保留。&lt;/p&gt;
&lt;p style='text-align:left'&gt;&amp;copy; 2010, &lt;a target='_blank' href='http://www.linuxers.cn'&gt;Linux爱好者&lt;/a&gt;. 版权所有. 转载请注明来自http://www.linuxers.cn&lt;/p&gt;
&lt;h4  class=&quot;related_post_title&quot;&gt;推荐日志&lt;/h4&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;2009/12/19 -- &lt;a href=&quot;http://www.linuxers.cn/2009/12/19/vim%e6%8f%92%e4%bb%b6%e6%8e%a8%e8%8d%901-bufexplorer/&quot; title=&quot;Vim插件推荐(1)&amp;#8211;bufexplorer&quot;&gt;Vim插件推荐(1)&amp;#8211;bufexplorer&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2009/12/01 -- &lt;a href=&quot;http://www.linuxers.cn/2009/12/01/%e4%bd%bf%e7%94%a8scons%e6%9b%bf%e4%bb%a3makefile-1/&quot; title=&quot;使用scons替代makefile(1)&quot;&gt;使用scons替代makefile(1)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2009/12/13 -- &lt;a href=&quot;http://www.linuxers.cn/2009/12/13/linux%e7%bb%88%e7%ab%af%e4%b8%8b%e6%9c%80%e5%bc%ba%e5%a4%a7%e7%9a%84%e5%b1%8f%e5%b9%95%e7%ae%a1%e7%90%86%e8%bd%af%e4%bb%b6screen3/&quot; title=&quot;Linux终端下最强大的屏幕管理软件screen(3)&quot;&gt;Linux终端下最强大的屏幕管理软件screen(3)&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2010/03/07 -- &lt;a href=&quot;http://www.linuxers.cn/2010/03/07/%e4%bd%bf%e7%94%a8pstree%e6%9f%a5%e7%9c%8b%e8%bf%9b%e7%a8%8b%e6%a0%91/&quot; title=&quot;使用pstree查看进程树&quot;&gt;使用pstree查看进程树&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2009/12/07 -- &lt;a href=&quot;http://www.linuxers.cn/2009/12/07/%e4%bd%bf%e7%94%a8ld_preload%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8fhack%e7%b3%bb%e7%bb%9f%e5%ba%93%e5%87%bd%e6%95%b0/&quot; title=&quot;使用LD_PRELOAD环境变量hack系统库函数&quot;&gt;使用LD_PRELOAD环境变量hack系统库函数&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700043/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/13/linux%e4%b8%8b%e5%8e%86%e5%8f%b2%e5%91%bd%e4%bb%a4history%e6%b7%bb%e5%8a%a0%e6%97%b6%e9%97%b4%e6%88%b3/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700043/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700043/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.linuxers.cn/2010/04/13/linux%e4%b8%8b%e5%8e%86%e5%8f%b2%e5%91%bd%e4%bb%a4history%e6%b7%bb%e5%8a%a0%e6%97%b6%e9%97%b4%e6%88%b3/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>熟悉bash的都一定知道使用history可以输出你曾经输入过的历史命令，例如

&amp;#91;leconte@web ~&amp;#93;$ history  &amp;#124; more
   25  cd docroot/
&lt;span class=&quot;readmore&quot;&gt;&lt;a href=&quot;http://www.linuxers.cn/2010/04/13/linux%e4%b8%8b%e5%8e%86%e5%8f%b2%e5%91%bd%e4%bb%a4history%e6%b7%bb%e5%8a%a0%e6%97%b6%e9%97%b4%e6%88%b3/&quot; title=&quot;Linux下历史命令(history)添加时间戳&quot; target=&quot;_blank&quot;&gt;Read more 807 words&lt;/a&gt;&lt;/span&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700043/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/13/linux%e4%b8%8b%e5%8e%86%e5%8f%b2%e5%91%bd%e4%bb%a4history%e6%b7%bb%e5%8a%a0%e6%97%b6%e9%97%b4%e6%88%b3/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700043/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700043/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>history</category><category>timestamp</category><category>Linux软件</category><pubDate>Tue, 13 Apr 2010 15:44:07 +0800</pubDate><author>leconte</author><comments>http://www.linuxers.cn/2010/04/13/linux%e4%b8%8b%e5%8e%86%e5%8f%b2%e5%91%bd%e4%bb%a4history%e6%b7%bb%e5%8a%a0%e6%97%b6%e9%97%b4%e6%88%b3/#comments</comments><guid isPermaLink="false">http://www.linuxers.cn/?p=480</guid><dc:creator>leconte</dc:creator><fs:srclink>http://www.linuxers.cn/2010/04/13/linux%e4%b8%8b%e5%8e%86%e5%8f%b2%e5%91%bd%e4%bb%a4history%e6%b7%bb%e5%8a%a0%e6%97%b6%e9%97%b4%e6%88%b3/</fs:srclink><fs:srcfeed>http://www.linuxers.cn/feed/</fs:srcfeed><fs:itemid>feedsky/linuxers/~7972096/373700043/6081772</fs:itemid></item><item><title>bash PS1环境变量的设置</title><link>http://www.linuxers.cn/2010/04/12/bash-ps1%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e7%9a%84%e8%ae%be%e7%bd%ae/</link><content:encoded>&lt;p&gt;在bash下，命令行提示符的格式是由PS1这个环境变量来设置的。通常在/etc/bashrc会有一个系统级别的设置，例如我本机/etc/bashrc中的：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #007800;&quot;&gt;PS1&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;[\u@\h \W]\&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\$&lt;/span&gt; &amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;\u,\h,\W分别代表用户名，主机名和当前目录名。\$的含义是如果用户为root则输出#，否则输出$。&lt;br /&gt;
因此在这种PS1的设置下，终端提示符通常如下：&lt;/p&gt;

&lt;div class=&quot;wp_syntax&quot;&gt;&lt;div class=&quot;code&quot;&gt;&lt;pre class=&quot;bash&quot; style=&quot;font-family: Consolas,'Courier New',monospace&quot;&gt;&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#91;&lt;/span&gt;leconte&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;@&lt;/span&gt;localhost ~&lt;span style=&quot;color: #7a0874; font-weight: bold;&quot;&gt;&amp;#93;&lt;/span&gt;$&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;当然，用户可以~/.bashrc中自定义自己的提示符样式以满足自己的习惯。PS1支持的标示符很多，常用的有以下一些：&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;\d:日期，例如Tue May 26&lt;br /&gt;
\h:主机名&lt;br /&gt;
\H:机器名&lt;br /&gt;
\j:当前shell的job数&lt;br /&gt;
\t:\T\@\A:四种格式显示的当前时间&lt;br /&gt;
\u:当前用户名&lt;br /&gt;
\w\W:当前工作目录&lt;br /&gt;
\!:历史命令条数&lt;br /&gt;
\e:转义字符&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;值得一提的是可以通过\e结合终端的颜色支持实现提示符的彩色化，通过\e[开头，m结尾的格式可以定义一种颜色，例如\e[32;40m代表将当前色设置为绿色，如图：&lt;br /&gt;
&lt;a href=&quot;http://www.linuxers.cn/wp-content/uploads/2010/04/11.png&quot;&gt;&lt;img src=&quot;http://www.linuxers.cn/wp-content/uploads/2010/04/11.png&quot; alt=&quot;1&quot; title=&quot;1&quot; width=&quot;442&quot; height=&quot;90&quot; class=&quot;alignnone size-full wp-image-477&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;可以看到提示符变成了绿色的，这个PS1的设置为[\e[32;40m\u@\w]\$\e[0m，我们来从前往后解析它，\e[32;40m代表将当前颜色改为绿色，因此它之前输出的[是白色，之后的leconte@~]$都是绿色，\e[0m代表恢复默认颜色，因此随后输出的ls的颜色为默认的白色。&lt;/p&gt;
&lt;p&gt;这样以来，通过ascii颜色就可以定制出满足自身审美和需求的终端提示了，hoho&lt;/p&gt;
&lt;p style='text-align:left'&gt;&amp;copy; 2010, &lt;a target='_blank' href='http://www.linuxers.cn'&gt;Linux爱好者&lt;/a&gt;. 版权所有. 转载请注明来自http://www.linuxers.cn&lt;/p&gt;
&lt;h4  class=&quot;related_post_title&quot;&gt;相关日志&lt;/h4&gt;&lt;ul class=&quot;related_post&quot;&gt;&lt;li&gt;2009/12/28 -- &lt;a href=&quot;http://www.linuxers.cn/2009/12/28/bash%e7%9a%84vi%e6%a8%a1%e5%bc%8f%e4%bb%8b%e7%bb%8d/&quot; title=&quot;bash的vi模式介绍&quot;&gt;bash的vi模式介绍&lt;/a&gt;&lt;/li&gt;&lt;li&gt;2009/12/15 -- &lt;a href=&quot;http://www.linuxers.cn/2009/12/15/su%e5%92%8csu-%e7%9a%84%e5%8c%ba%e5%88%ab/&quot; title=&quot;su和su -的区别&quot;&gt;su和su -的区别&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700044/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/12/bash-ps1%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e7%9a%84%e8%ae%be%e7%bd%ae/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700044/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700044/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</content:encoded><wfw:commentRss>http://www.linuxers.cn/2010/04/12/bash-ps1%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e7%9a%84%e8%ae%be%e7%bd%ae/feed/</wfw:commentRss><slash:comments>0</slash:comments><description>在bash下，命令行提示符的格式是由PS1这个环境变量来设置的。通常在/etc/bashrc会有一个系统级别的设置，例如我本机/etc/bashrc中的：

PS1=&amp;#34;[\u@\h \W]\\$ &amp;#34;

&lt;span class=&quot;readmore&quot;&gt;&lt;a href=&quot;http://www.linuxers.cn/2010/04/12/bash-ps1%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e7%9a%84%e8%ae%be%e7%bd%ae/&quot; title=&quot;bash PS1环境变量的设置&quot; target=&quot;_blank&quot;&gt;Read more 612 words&lt;/a&gt;&lt;/span&gt;&lt;img src=&quot;http://www1.feedsky.com/t1/373700044/linuxers/feedsky/s.gif?r=http://www.linuxers.cn/2010/04/12/bash-ps1%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e7%9a%84%e8%ae%be%e7%bd%ae/&quot; border=&quot;0&quot; height=&quot;0&quot; width=&quot;0&quot; style=&quot;position:absolute&quot; /&gt;&lt;p class=&quot;fswww1&quot;&gt;&lt;a href=&quot;http://www1.feedsky.com/r/l/feedsky/linuxers/373700044/art01.html&quot; target=&quot;_blank&quot;&gt;&lt;img border=&quot;0&quot; ismap=&quot;ismap&quot; src=&quot;http://www1.feedsky.com/r/i/feedsky/linuxers/373700044/art01.gif&quot; onerror=&quot;this.style.display='none'&quot; /&gt;&lt;/a&gt;&lt;/p&gt;</description><category>bash</category><category>PS1</category><category>Linux软件</category><pubDate>Mon, 12 Apr 2010 10:40:50 +0800</pubDate><author>leconte</author><comments>http://www.linuxers.cn/2010/04/12/bash-ps1%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e7%9a%84%e8%ae%be%e7%bd%ae/#comments</comments><guid isPermaLink="false">http://www.linuxers.cn/?p=476</guid><dc:creator>leconte</dc:creator><fs:srclink>http://www.linuxers.cn/2010/04/12/bash-ps1%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e7%9a%84%e8%ae%be%e7%bd%ae/</fs:srclink><fs:srcfeed>http://www.linuxers.cn/feed/</fs:srcfeed><fs:itemid>feedsky/linuxers/~7972096/373700044/6081772</fs:itemid></item></channel></rss>
