﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-程序人生-文章分类-ubuntu</title><link>http://www.cppblog.com/liu1061/category/7273.html</link><description>生活和工作都要充满激情,否则你无法体会到淋漓尽致的快乐与痛苦</description><language>zh-cn</language><lastBuildDate>Sat, 19 Sep 2009 11:33:52 GMT</lastBuildDate><pubDate>Sat, 19 Sep 2009 11:33:52 GMT</pubDate><ttl>60</ttl><item><title>learn sed 参数</title><link>http://www.cppblog.com/liu1061/articles/95101.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Wed, 02 Sep 2009 07:14:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/95101.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/95101.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/95101.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/95101.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/95101.html</trackback:ping><description><![CDATA[<h1 class=subject style="WORD-WRAP: break-word"><strong><img src="http://img1.51cto.com/images/orig_1.gif" border=0> Linux sed 15个参数 </strong></h1>
<hr style="BORDER-RIGHT: #eeeeee 1px solid; BORDER-TOP: #eeeeee 1px solid; BORDER-LEFT: #eeeeee 1px solid; BORDER-BOTTOM: #eeeeee 1px solid" align=center width="94%" SIZE=1>
<div>
<div class=posttime><small><font size=1>2008-07-17 23:00:57</font></small></div>
<div style="PADDING-LEFT: 20px; WIDTH: 94%">　标签：<span style="COLOR: #aaaaaa"><a class=operlink href="http://blog.51cto.com/tagindex.php?keyword=sed" target=_blank><u><font color=#ee9020>sed</font></u></a> <a class=operlink href="http://blog.51cto.com/tagindex.php?keyword=15%B8%F6%BB%F9%B1%BE%B2%CE%CA%FD" target=_blank><u><font color=#ee9020>15个基本参数</font></u></a></span>　　　[<a class=operlink onclick="javascript:dfanologin();return false;" href="http://future.blog.51cto.com/#"><u><font color=#ee9020>推送到技术圈</font></u></a>] <br><br></div>
</div>
<div>
<table id=content style="TABLE-LAYOUT: fixed; WIDTH: 650px" cellSpacing=10 cellPadding=0 width=650 border=0>
    <tbody>
        <tr>
            <td>
            <div class=copy><strong>版权声明：</strong>原创作品，允许转载，转载时请务必以超链接形式标明文章 <a style="TEXT-DECORATION: underline" href="http://future.blog.51cto.com/26959/88400" target=_blank><font color=#000000>原始出处</font></a> 、作者信息和本声明。否则将追究法律责任。<a href="http://future.blog.51cto.com/26959/88400"><u><font color=#000000>http://future.blog.51cto.com/26959/88400</font></u></a></div>
            </td>
        </tr>
        <tr>
            <td>
            <div style="FONT-SIZE: 10pt; WORD-BREAK: break-all; POSITION: relative; WORD-WRAP: break-word">
            <div>一、15个参数</div>
            <div>1、r 从文件读入</div>
            <div>[root@watchout2 ~]# cat file<br>1<br>2<br>3<br>4<br>5</div>
            <div>[root@watchout2 ~]# cat newfile <br>a<br>b<br>c<br>d<br>e</div>
            <div>[root@watchout2 ~]# sed '/a/r file' newfile （读入文件file,并显示在newfile文件中匹配行a之后）<br>a<br>1<br>2<br>3<br>4<br>5<br>b<br>c<br>d<br>e<br>[root@watchout2 ~]# touch /file<br>[root@watchout2 ~]# echo "aaaaaaaaaaaaaaaaaaaaaaaaaa" &gt; /file <br>[root@watchout2 ~]# sed '/a/r /file' newfile&nbsp; （读入的文件在不同的路径）<br>a<br>aaaaaaaaaaaaaaaaaaaaaaaaaa<br>b<br>c<br>d<br>e<br>[root@watchout2 ~]# </div>
            <div>&nbsp;</div>
            <div>2、w写入文件</div>
            <div>[root@watchout2 ~]# sed '/a/w bo' newfile <br>a<br>b<br>c<br>d<br>e<br>[root@watchout2 ~]# cat bo （[root@watchout2 ~]# sed -n '/a/w bobo' newfile ）<br>a</div>
            <div>&nbsp;</div>
            <div>3、a 追加命令</div>
            <div>[root@watchout2 ~]# sed '/b/a \bobo' newfile <br>a<br>b</div>
            <div>bobo<br>c<br>d<br>e</div>
            <div>&nbsp;</div>
            <div>4、i 插入</div>
            <div>[root@watchout2 ~]# sed '/a/i \bobo' newfile <br>bobo<br>a<br>b<br>c<br>d<br>e</div>
            <div>&nbsp;</div>
            <div>5、n 下一个</div>
            <div>[root@watchout2 ~]# sed -n '/a/{n;p}' newfile（打印匹配行的下一行） <br>b</div>
            <div>&nbsp;</div>
            <div>[root@watchout2 ~]# sed '/a/{n;s/b/c/p}' newfile <br>a<br>c<br>c<br>c<br>d<br>e</div>
            <div>&nbsp;</div>
            <div>6、y 变形命令</div>
            <div>[root@watchout2 ~]# sed '1,3y/abc/ABC/' newfile <br>A<br>B<br>C<br>d<br>e</div>
            <div>y命令就是将小写转换成了大写，正则表达式元字符不能使用这个命令。</div>
            <div>&nbsp;</div>
            <div>7、q 退出命令</div>
            <div>[root@watchout2 ~]# sed '3q' newfile <br>a<br>b<br>c</div>
            <div>打印前三行后退出。</div>
            <div>&nbsp;</div>
            <div>8、h命令&nbsp;&nbsp; 是将pattern space 模式空间(临时缓冲区)的内容复制到holding buffer保持缓冲区</div>
            <div>9、G命令 是将holding buffer中的内容取得，尔后放回pattern space中，且追加到相应行的末 尾&nbsp;</div>
            <div>&nbsp;&nbsp;&nbsp; g命令是将holding buffer 中的内容取得，尔后放回pattern space 中，且替换相应的行</div>
            <div>&nbsp;</div>
            <div>[root@watchout2 ~]# sed -e '/a/h' -e '/d/G' newfile <br><font color=#ff0000>a<br></font>b<br>c<br>d<br><font color=#ff0000>a</font><br>e</div>
            <div>h命令会把a匹配行，放入保持缓冲区，G命令会把保持缓冲区中的内容放入模式空间，并追加到匹配行d的下一行。</div>
            <div>&nbsp;</div>
            <div>[root@watchout2 ~]# sed -e '/a/h' -e '$G' newfile <br><font color=#ff0000>a<br></font>b<br>c<br>d<br>e<br><font color=#ff0000>a</font></div>
            <div>与上相同，只是$代表最后一行。</div>
            <div>&nbsp;</div>
            <div>[root@watchout2 ~]# sed -e '/a/h' -e '/b/g' newfile <br><font color=#ff0000>a<br></font><font color=#ff0000>a<br></font>c<br>d<br>e<br>[root@watchout2 ~]# sed -e '/a/h' -e '$g' newfile <br><font color=#ff0000>a<br></font>b<br>c<br>d<br><font color=#ff0000>a</font></div>
            <div>&nbsp;</div>
            <div>以上h命令会把匹配行a,放入保持缓冲区，g命令会读取保持缓冲区的内容，将匹配行b(第二个例子就是$最后一行)替换为a 。注：a将覆盖匹配行b(第二个例子就是$最后一行)</div>
            <div>&nbsp;</div>
            <div>10、x命令 是pattern space模式空间将被holding buffer保持缓冲区中的内容替换</div>
            <div>[root@watchout2 ~]# sed -e '/a/h' -e '/d/x' newfile <br><font color=#ff0000>a</font><br>b<br>c<br><font color=#ff0000>a</font><br>e</div>
            <div>匹配行d 将被匹配行a替换。</div>
            <div>&nbsp;</div>
            <div>11、-n选项取消sed的默认行为，sed 默认行为是-p&nbsp;, </div>
            <div>root:/tmp&gt;sed '/6/p' num&nbsp;&nbsp; -p参数打印num的内容，尔后匹配&#8220;6&#8221;在次打印6，所以6会出现两次。<br>1<br>2<br>3<br>4<br>5<br><font color=#ff0000>6<br>6<br></font>7<br>8<br>root:/tmp&gt;sed -n '/6/p' num&nbsp; -n选项取消sed的默认行为（-p ），所以只打印&#8220;6&#8221;<br>6<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div>12、删除：d命令</div>
            <div>删除第6行</div>
            <div>root:/tmp&gt;sed '6d' num<br>1<br>2<br>3<br>4<br>5<br>7<br>8<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div>从第6行删除到行尾</div>
            <div>root:/tmp&gt;sed '6,$d' num<br>1<br>2<br>3<br>4<br>5<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div>d删除最后一行</div>
            <div>root:/tmp&gt;sed '$d' num<br>1<br>2<br>3<br>4<br>5<br>6<br>7<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div>d删除匹配行</div>
            <div>root:/tmp&gt;sed '/6/d' num<br>1<br>2<br>3<br>4<br>5<br>7<br>8<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div>13、替换：s命令</div>
            <div>s表示替换，g表示作用范围整个行，如果没有g标志则只有每行第一个被替换</div>
            <div>root:/tmp&gt;sed 's/1/8/g' num&nbsp;&nbsp;&nbsp; （sed默认有-p参数打印搜索后的所有行。如g后面加p，那么匹配行就会打印两次）<br>8<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div>行首&#8220;1&#8221;开头被替换为&#8220;8&#8221;</div>
            <div>root:/tmp&gt;sed 's/^1/8/g' num <br>8<br>2<br>3<br>4<br>5<br>6<br>7<br>8<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div><font style="BACKGROUND-COLOR: #ffffff" color=#0000ff>&amp;符号表示替换字符串中被找到的部分，所以每个数字后面被追加.6789</font></div>
            <div>root:/tmp&gt;sed 's/[0-9]/&amp;.6789/g' num<br>1.6789<br>2.6789<br>3.6789<br>4.6789<br>5.6789<br>6.6789<br>7.6789<br>8.6789<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div>\(..\) 保存匹配的字符到标签\1中。&nbsp; s/<font color=#0000ff>\(5\)</font>/<font color=#ff0000>\1</font>.6789/&nbsp; 蓝色部分保存到标签\1中。从表达式最左边开始，向右最多可以使用9个标签</div>
            <div>root:/tmp&gt;sed 's/\(5\)/\1.6789/g' num<br>1<br>2<br>3<br>4<br>5.6789<br>6<br>7<br>8<br>root:/tmp&gt;sed 's/\([0-9]\)/\1.6789/g' num<br>1.6789<br>2.6789<br>3.6789<br>4.6789<br>5.6789<br>6.6789<br>7.6789<br>8.6789<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div>s后面的字符是分隔搜索字符串和替换字符串的分隔符。默认分隔符是斜杠，不论什么字符紧跟s命令都被认为是新的分隔符</div>
            <div>root:/tmp&gt;sed 's#6#shell#g' num<br>1<br>2<br>3<br>4<br>5<br>shell<br>7<br>8<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div>14、多点编辑：e命令</div>
            <div>root:/tmp&gt;sed -e '1,6d' -e 's/8/8.shell/g' num<br>7<br>8.shell<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div>15、-f&nbsp; 引导sed脚本文件名</div>
            <div>&nbsp;</div>
            <div>&nbsp;</div>
            <div>16、选定行的范围：逗号</div>
            <div>&nbsp;</div>
            <div>从第一行到第五行</div>
            <div>root:/tmp&gt;sed -n '1,5p' num<br>1<br>2<br>3<br>4<br>5</div>
            <div>&nbsp;</div>
            <div>从第一行到第五行，然后在搜索<br>root:/tmp&gt;sed '1,5s/3/3.linux/g' num<br>1<br>2<br>3.linux<br>4<br>5<br>6<br>7<br>8</div>
            <div>&nbsp;</div>
            <div>显示从第三行到行首为6的中间所有行<br>root:/tmp&gt;sed -n '3,/^6/p' num<br>3<br>4<br>5<br>6<br>root:/tmp&gt;</div>
            <div>&nbsp;</div>
            <div>&nbsp;</div>
            <div>匹配1和5后面追加&#8220;******Total********&#8221;</div>
            <div>root:/tmp&gt;sed '/1/,/5/s/$/******Total********/g' num<br>1******Total********<br>2******Total********<br>3******Total********<br>4******Total********<br>5******Total********<br>6<br>7<br>8<br>root:/tmp&gt;</div>
            </div>
            </td>
        </tr>
    </tbody>
</table>
</div>
<img src ="http://www.cppblog.com/liu1061/aggbug/95101.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2009-09-02 15:14 <a href="http://www.cppblog.com/liu1061/articles/95101.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux学习入门指令！</title><link>http://www.cppblog.com/liu1061/articles/54897.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Sun, 29 Jun 2008 02:14:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/54897.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/54897.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/54897.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/54897.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/54897.html</trackback:ping><description><![CDATA[<div style="FONT-SIZE: 10pt; MARGIN: 15px; FONT-FAMILY: courier new" align=left>linux目录架构<br>/&nbsp; &nbsp;根目录<br>/bin&nbsp; &nbsp; 常用的命令 binary file 的目錄<br>/boot&nbsp; &nbsp;存放系统启动时必须读取的档案，包括核心 (kernel) 在内<br>/boot/grub/menu.lst&nbsp; &nbsp;GRUB设置<br>/boot/vmlinuz&nbsp; &nbsp;内核<br>/boot/initrd&nbsp; &nbsp;&nbsp;&nbsp;核心解壓縮所需 RAM Disk<br>/dev&nbsp; &nbsp; 系统周边设备&nbsp; &nbsp;&nbsp;&nbsp;<br>/etc&nbsp; &nbsp; 系统相关设定文件<br>/etc/DIR_COLORS&nbsp; &nbsp;设定颜色<br>/etc/HOSTNAME&nbsp; &nbsp;设定用户的节点名<br>/etc/NETWORKING&nbsp; &nbsp;只有YES标明网络存在<br>/etc/host.conf 文件说明用户的系统如何查询节点名<br>/etc/hosts 设定用户自已的IP与名字的对应表<br>/etc/hosts.allow 设置允许使用inetd的机器使用&nbsp;<br>/etc/hosts.deny 设置不允许使用inetd的机器使用<br>/etc/hosts.equiv 设置远端机不用密码<br>/etc/inetd.conf 设定系统网络守护进程inetd的配置<br>/etc/gateways 设定路由器<br>/etc/protocols 设定系统支持的协议<br>/etc/named.boot 设定本机为名字服务器的配置文件<br>/etc/sysconfig/network-scripts/ifcfg-eth0&nbsp;&nbsp; 设置IP<br>/etc/resolv.conf&nbsp;&nbsp;&nbsp; 设置DNS&nbsp; <br>/etc/X11&nbsp; X Window的配置文件,xorg.conf 或 XF86Config 這兩個 X Server 的設定檔<br>/etc/fstab&nbsp;&nbsp;&nbsp; 记录开机要mount的文件系统<br>/etc/inittab 设定系统启动时init进程将把系统设置成什么样的runlevel<br>/etc/issue 记录用户登录前显示的信息<br>/etc/group 设定用户的组名与相关信息<br>/etc/passwd 帐号信息<br>/etc/shadow 密码信息<br>/etc/sudoers 可以sudo命令的配置文件<br>/etc/securetty 设定哪些终端可以让root登录<br>/etc/login.defs 所有用户登录时的缺省配置<br>/etc/exports 设定NFS系统用的<br>/etc/init.d/&nbsp;&nbsp; 所有服務的預設啟動 script 都是放在這裡的，例如要啟動或者關閉<br>/etc/xinetd.d/&nbsp; 這就是所謂的 super daemon 管理的各項服務的設定檔目錄<br>/etc/modprobe.conf&nbsp;&nbsp; 内核模块额外参数设定<br>/etc/syslog.conf&nbsp;&nbsp; 日志设置文件</div>
<div style="FONT-SIZE: 10pt; MARGIN: 15px; FONT-FAMILY: courier new" align=left>/home&nbsp;&nbsp; 使用者家目录<br>/lib&nbsp;&nbsp;&nbsp; 系统会使用到的函数库<br>/lib/modules&nbsp;&nbsp; kernel 的相关模块<br>/var/lib/rpm&nbsp;&nbsp; rpm套件安装处 <br>/lost+found&nbsp;&nbsp;&nbsp; 系統不正常產生錯誤時，會將一些遺失的片段放置於此目錄下<br>/mnt&nbsp;&nbsp;&nbsp;&nbsp; 外设的挂载点<br>/media&nbsp;&nbsp; 与/mnt类似<br>/opt&nbsp;&nbsp;&nbsp;&nbsp; 主机额外安装的软件<br>/proc&nbsp;&nbsp;&nbsp; 虚拟目录，是内存的映射<br>/proc/version&nbsp;&nbsp; 内核版本<br>/proc/sys/kernel&nbsp;&nbsp; 系统内核功能<br>/root&nbsp;&nbsp;&nbsp; 系统管理员的家目录<br>/sbin&nbsp;&nbsp;&nbsp; 系统管理员才能执行的指令<br>/srv&nbsp;&nbsp;&nbsp;&nbsp; 一些服務啟動之後，這些服務所需要取用的資料目錄<br>/tmp&nbsp;&nbsp;&nbsp;&nbsp; 一般使用者或者是正在執行的程序暫時放置檔案的地方<br>/usr&nbsp;&nbsp;&nbsp;&nbsp; 最大的目录，存许应用程序和文件<br>/usr/X11R6：&nbsp;&nbsp; X-Window目录 <br>/usr/src：&nbsp;&nbsp;&nbsp; Linux源代码<br>/usr/include：系统头文件<br>/usr/openwin 存放SUN的OpenWin <br>/usr/man 在线使用手册<br>/usr/bin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 使用者可執行的 binary file 的目錄<br>/usr/local/bin&nbsp;&nbsp;&nbsp;&nbsp; 使用者可執行的 binary file 的目錄<br>/usr/lib&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 系统会使用到的函数库<br>/usr/local/lib&nbsp;&nbsp;&nbsp;&nbsp; 系统会使用到的函数库<br>/usr/sbin&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 系统管理员才能执行的指令<br>/usr/local/sbin&nbsp;&nbsp;&nbsp; 系统管理员才能执行的指令<br>/var&nbsp;&nbsp; 日志文件<br>/var/log/secure&nbsp;&nbsp;&nbsp; 記錄登入系統存取資料的檔案，例如 pop3, ssh, telnet, ftp 等都會記錄檔案中<br>/var/log/wtmp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 記錄登入者的訊息資料, last<br>/var/log/messages&nbsp; 幾乎系統發生的錯誤訊息<br>/var/log/boot.log&nbsp; 記錄開機或者是一些服務啟動的時候，所顯示的啟動或關閉訊息<br>/var/log/maillog&nbsp;&nbsp; 紀錄郵件存取或往來( sendmail 與 pop3 )的使用者記錄<br>/var/log/cron&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 記錄 crontab 這個例行性服務的內容<br>/var/log/httpd, /var/log/news, /var/log/mysqld.log, /var/log/samba, /var/log/procmail.log：<br>分別是幾個不同的網路服務的記錄檔</div>
<div style="FONT-SIZE: 10pt; MARGIN: 15px; FONT-FAMILY: courier new" align=left>一些常用的基本命令:<br>uname -a&nbsp; &nbsp; 查看内核版本&nbsp; &nbsp;&nbsp; &nbsp; <br>ls -al&nbsp; &nbsp; 显示所有文件的属性<br>pwd&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;显示当前路径&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br>cd -&nbsp; &nbsp; 返回上一次目录&nbsp; &nbsp;&nbsp;&nbsp;cd ~&nbsp; &nbsp; 返回主目录<br>date s&nbsp; &nbsp;&nbsp; &nbsp;设置时间、日期&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br>cal&nbsp; &nbsp;&nbsp; &nbsp;显示日历&nbsp; &nbsp;&nbsp;&nbsp;cal 2006<br>bc&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; 计算器具&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br>man&nbsp;&nbsp;&amp; info&nbsp; &nbsp;&nbsp;&nbsp;帮助手册<br>locale&nbsp; &nbsp;&nbsp;&nbsp;显示当前字体&nbsp; &nbsp;&nbsp;&nbsp;locale -a&nbsp; &nbsp; 所有可用字体&nbsp; &nbsp;&nbsp;&nbsp;/etc/sysconfig/i18n设置文件<br>LANG=en&nbsp; &nbsp; 使用英文字体&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br>sync&nbsp; &nbsp;&nbsp; &nbsp; 将数据同步写入硬盘&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;<br>shutdonw -h now &amp; half &amp; poweroff&nbsp;&nbsp;关机<br>reboot&nbsp; &nbsp;&nbsp;&nbsp;重启&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br>startx&nbsp;&nbsp;&amp;&nbsp;&nbsp;init 5&nbsp; &nbsp;进入图形介面<br>/work&nbsp;&nbsp;&amp; ?work&nbsp; &nbsp; 向上、下查找文档内容<br>chgrp&nbsp; &nbsp;&nbsp; &nbsp;改变档案群组&nbsp;&nbsp;chgrp testing install.log&nbsp; &nbsp; <br>chown&nbsp; &nbsp;&nbsp;&nbsp;改变所属人&nbsp; &nbsp;chown root:root install.log<br>chmod&nbsp; &nbsp;&nbsp; &nbsp;改变属性&nbsp; &nbsp;&nbsp;&nbsp;chmod 777 install.log&nbsp; &nbsp;&nbsp;&nbsp;read=4&nbsp;&nbsp;write=2&nbsp;&nbsp;execute=1<br>cp&nbsp; &nbsp;复制&nbsp; &nbsp;cp filename<br>rm&nbsp; &nbsp;删除文件&nbsp;&nbsp;rm -rf filename&nbsp; &nbsp;强制删除文件<br>rmdir&nbsp; &nbsp;删除文件夹<br>mv&nbsp;&nbsp;移动&nbsp; &nbsp; mv 123.txt 222.txt&nbsp;&nbsp;重命名<br>mkdir&nbsp; &nbsp;&nbsp;&nbsp;创建文件夹<br>touch&nbsp; &nbsp;&nbsp;&nbsp;创建文件&nbsp;&nbsp;更新当前时间<br>cat&nbsp; &nbsp;&nbsp; &nbsp; 由第一行开始显示&nbsp; &nbsp;&nbsp;&nbsp;cat |more&nbsp;&nbsp;分页<br>nl&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;在内容前加行号<br>more&nbsp;&nbsp;&amp;&nbsp;&nbsp;less&nbsp; &nbsp;一面一面翻动<br>head -n filename&nbsp; &nbsp;显示第N行内容<br>tail -n filename&nbsp;&nbsp;显示后N行内容<br>od&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;显示非纯文档<br>df -h 显示分区空间<br>du&nbsp;&nbsp;显示目录或文件的大小<br>fdisk&nbsp; &nbsp;分区设置&nbsp; &nbsp; fdisk -l /dev/hda&nbsp;&nbsp;显示硬盘分区状态<br>mkfs&nbsp; &nbsp; 建立各种文件系统&nbsp;&nbsp;mkfs -t ext3&nbsp;&nbsp;/dev/ram15&nbsp; &nbsp;<br>fsck&nbsp; &nbsp; 检查和修复LINUX档案<br>ln&nbsp; &nbsp;&nbsp; &nbsp;硬链接&nbsp; &nbsp;ln -s&nbsp;&nbsp;软件链接<br>whereis&nbsp; &nbsp;查找命令<br>locate&nbsp; &nbsp; 查找<br>find&nbsp; &nbsp;&nbsp; &nbsp;查找&nbsp; &nbsp;find / -name "***.***"<br>which&nbsp; &nbsp;&nbsp;&nbsp;查看工具<br>whoami&nbsp; &nbsp; 显示当前用户<br>gcc -v&nbsp; &nbsp; 查看GCC版本<br>chattr +i filename&nbsp;&nbsp;禁止删除&nbsp; &nbsp;chattr -i filename&nbsp;&nbsp;取消禁止<br>lsattr&nbsp; &nbsp; 显示隐藏档属性<br>updatedb&nbsp;&nbsp;更新资料库<br>mke2fs&nbsp; &nbsp; 格式化&nbsp; &nbsp;mkfs -t ext3 <br>dd if=/etc/passwd of=/tmp/passwd.bak&nbsp; &nbsp; 备份<br>mount&nbsp; &nbsp;&nbsp;&nbsp;列出系统所有的分区<br>mount -t iso9660 /dev/cdrom /mnt/cdrom&nbsp; &nbsp;挂载光盘<br>mount -t vfat /dev/fd0 /mnt/floppy&nbsp; &nbsp;&nbsp; &nbsp; 挂载软盘<br>mount -t vfat -o iocharset=utf8,umask=000 /dev/hda2 /mnt/hda2&nbsp; &nbsp;挂载fat32分区<br>mount -t ntfs -o nls=utf8,umask=000 /dev/hda3 /mnt/hda3&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;挂载ntfs分区<br>Linux-NTFS Project: <br><a href="http://linux-ntfs.sourceforge.net/" target=_blank><u><font color=#0000ff>http://linux-ntfs.sourceforge.net/</font></u></a><br>umount /mnt/hda3&nbsp;&nbsp;缷载<br>ifconfig&nbsp; &nbsp;显示或设置网络设备<br>service network restart&nbsp; &nbsp;重启网卡&nbsp;&nbsp;<br>ifdown eth0&nbsp;&nbsp;关闭网卡<br>ifup eth0&nbsp; &nbsp; 开启网卡<br>clear&nbsp; &nbsp; 清屏<br>history&nbsp; &nbsp; 历史记录&nbsp; &nbsp;&nbsp; &nbsp; !55&nbsp;&nbsp;执行第55个指令<br>stty&nbsp; &nbsp;设置终端&nbsp; &nbsp; stty -a<br>fdisk /mbr&nbsp; &nbsp;删除GRUB<br>at&nbsp; &nbsp;&nbsp;&nbsp;僅進行一次的工作排程<br>crontab&nbsp; &nbsp;循環執行的例行性命令&nbsp; &nbsp; [e]编辑,[l]显示,[r]删除任务<br>&amp;&nbsp; &nbsp;&nbsp; &nbsp; 后台运行程序&nbsp; &nbsp; tar -zxvf 123.tar.gz &amp; ---------&gt;后台运行<br>jobs&nbsp; &nbsp; 观看后台暂停的程序&nbsp; &nbsp;jobs -l<br>fg&nbsp; &nbsp;&nbsp; &nbsp;将后台程序调到前台&nbsp; &nbsp;fg n ------&gt;n是数字,可以指定进行那个程序<br>bg&nbsp; &nbsp;&nbsp; &nbsp;让工作在后台运行<br>kill&nbsp; &nbsp; 结束进程&nbsp; &nbsp; kill -9 PID&nbsp; &nbsp;&nbsp;&nbsp;[9]强制结束,[15]正常结束,[l]列出可用的kill信号<br>ps aux&nbsp;&nbsp;查看后台程序&nbsp; &nbsp;<br>top&nbsp; &nbsp;&nbsp;&nbsp;查看后台程序&nbsp; &nbsp;top -d 2&nbsp; &nbsp; 每两秒更新一次&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;top -d 2 -p10604&nbsp; &nbsp;观看某个PID<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;top -b -n 2 &gt; /tmp/top.txt -----&gt;將 top 的資訊進行 2 次，然後將結果輸出到 /tmp/top.txt&nbsp; &nbsp; <br>pstree&nbsp; &nbsp;以树状图显示程序&nbsp; &nbsp; [A]以 ASCII 來連接, <u>列出PID, [p]列出帐号<br>killall&nbsp; &nbsp;要刪除某個服務&nbsp; &nbsp; killall -9 httpd<br>free&nbsp; &nbsp;&nbsp; &nbsp;显示内存状态&nbsp; &nbsp;&nbsp;&nbsp;free -m&nbsp;&nbsp;--------&gt;以M为单位显示<br>uptime&nbsp; &nbsp; 显示目前系统开机时间<br>netstat&nbsp; &nbsp;显示网络状态&nbsp; &nbsp; netstat -tulnp------&gt;找出目前系統上已在監聽的網路連線及其 PID<br>dmesg&nbsp; &nbsp;&nbsp;&nbsp;显示开机信息&nbsp; &nbsp; demsg | more<br>nice&nbsp; &nbsp;&nbsp; &nbsp;设置优先权&nbsp; &nbsp;&nbsp; &nbsp;nice -n -5 vi &amp; -----&gt;用 root 給一個 nice 植為 -5 ，用於執行 vi <br>renice&nbsp; &nbsp; 调整已存在优先权<br>runlevel&nbsp;&nbsp;显示目前的runlevel<br>depmod&nbsp; &nbsp; 分析可载入模块的相依性<br>lsmod&nbsp; &nbsp;&nbsp;&nbsp;显示已载入系统的模块<br>modinfo&nbsp; &nbsp;显示kernel模块的信息<br>insmod&nbsp; &nbsp; 载入模块<br>modprobe&nbsp; &nbsp;自动处理可载入模块<br>rmmod&nbsp; &nbsp;&nbsp;&nbsp;删除模块<br>chkconfig&nbsp; &nbsp;检查，设置系统的各种服务&nbsp; &nbsp;&nbsp;&nbsp;chkconfig --list -----&gt;列出各项服务状态<br>ntsysv&nbsp; &nbsp;&nbsp;&nbsp;设置系统的各种服务<br>cpio&nbsp; &nbsp;&nbsp; &nbsp;备份文件<br><br>压缩命令：<br>*.Z&nbsp; &nbsp;&nbsp; &nbsp;compress 程式壓縮的檔案； <br>*.bz2&nbsp; &nbsp; bzip2 程式壓縮的檔案； <br>*.gz&nbsp; &nbsp;&nbsp;&nbsp;gzip 程式壓縮的檔案； <br>*.tar&nbsp; &nbsp; tar 程式打包的資料，並沒有壓縮過； <br>*.tar.gz tar 程式打包的檔案，其中並且經過 gzip 的壓縮<br>compress filename&nbsp;&nbsp;压缩文件&nbsp;&nbsp;加[-d]解压&nbsp;&nbsp;uncompress<br>gzip filename&nbsp; &nbsp;压缩&nbsp;&nbsp;加[-d]解压&nbsp;&nbsp;zcat 123.gz 查看压缩文件内容<br>bzip2 -z filename&nbsp;&nbsp;压缩&nbsp;&nbsp;加[-d]解压&nbsp; &nbsp;bzcat filename.bz2&nbsp;&nbsp;查看压缩文件内容<br>tar -cvf /home/123.tar /etc&nbsp;&nbsp;打包，不压缩<br>tar -xvf 123.tar&nbsp; &nbsp;解开包<br>tar -zxvf /home/123.tar.gz&nbsp;&nbsp;以gzip解压<br>tar -jxvf /home/123.tar.bz2&nbsp;&nbsp;以bzip2解压<br>tar -ztvf /tmp/etc.tar.gz&nbsp; &nbsp;查看tar内容<br>cpio -covB&nbsp;&nbsp;&gt; [file|device]&nbsp; &nbsp;份份<br>cpio -icduv <br>帐号管理<br>/etc/passwd&nbsp; &nbsp; 系统帐号信息<br>/etc/shadow&nbsp; &nbsp; 帐号密码信息&nbsp; &nbsp; 经MD5 32位加密<br>&nbsp; &nbsp;&nbsp;&nbsp;在密码栏前面加『 * 』『 ! 』禁止使用某帐号<br>/etc/group&nbsp; &nbsp;&nbsp;&nbsp;系统群组信息<br>/etc/gshadow<br>newgrp&nbsp; &nbsp; 改变登陆组<br>useradd&nbsp;&nbsp;&amp;&nbsp;&nbsp;adduser&nbsp; &nbsp; 建立新用户&nbsp;&nbsp;---------&gt; useradd -m test&nbsp;&nbsp;自动建立用户的登入目录<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; useradd -m -g pgroup test ---------&gt;指定所属级<br>/etc/default/useradd&nbsp; &nbsp;相关设定<br>/etc/login.defs&nbsp; &nbsp;&nbsp; &nbsp; UID/GID 有關的設定<br>passwd&nbsp; &nbsp; 更改密码 -----------&gt; passwd test<br>usermod&nbsp; &nbsp;修改用户帐号<br>userdel&nbsp; &nbsp;删除帐号 -----------&gt;userdel -r test<br>chsh&nbsp; &nbsp;&nbsp; &nbsp;更换登陆系统时使用的SHELL&nbsp; &nbsp;[-l]显示可用的SHELL;[-s]修改自己的SHELL<br>chfn&nbsp; &nbsp;&nbsp; &nbsp;改变finger指令显示的信息<br>finger&nbsp; &nbsp; 查找并显示用户信息<br>id&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;显示用户的ID -----------&gt;&nbsp;&nbsp;id test<br>groupadd&nbsp; &nbsp;添加组<br>groupmod&nbsp; &nbsp;与usermod类似<br>groupdel&nbsp; &nbsp;删除组<br>su test&nbsp; &nbsp; 更改用户&nbsp; &nbsp;su -&nbsp; &nbsp; 进入root,且使用root的环境变量<br>sudo&nbsp; &nbsp;&nbsp; &nbsp; 以其他身份来执行指令<br>visudo&nbsp; &nbsp;&nbsp;&nbsp;编辑/etc/sudoers&nbsp; &nbsp;&nbsp; &nbsp;加入一行『 test ALL=(ALL) ALL 』<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;%wheel ALL = (ALL) ALL&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;系统里所有wheel群组的用户都可用sudo<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;%wheel ALL = (ALL) NOPASSWD: ALL&nbsp; &nbsp;&nbsp;&nbsp;wheel群组所有用户都不用密码NOPASSWD<br>&nbsp; &nbsp;&nbsp; &nbsp; User_Alias ADMPW = vbird, dmtsai, vbird1, vbird3&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;加入ADMPW组<br>&nbsp; &nbsp;&nbsp; &nbsp; ADMPW ALL = NOPASSWD: !/usr/bin/passwd, /usr/bin/passwd [A-Za-z]*, \<br>&nbsp; &nbsp;&nbsp; &nbsp; !/usr/bin/passwd root&nbsp; &nbsp;&nbsp; &nbsp;可以更改使用者密码,但不能更改root密码 (在指令前面加入 ! 代表不可)<br>PAM (Pluggable Authentication Modules, 嵌入式模組)<br>who &amp; w&nbsp; &nbsp;&nbsp;&nbsp;看谁在线&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<br>last&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;最近登陆主机的信息<br>lastlog&nbsp; &nbsp;&nbsp;&nbsp;最近登入的時間&nbsp; &nbsp; 读取 /var/log/lastlog <br>talk&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;与其他用户交谈<br>write&nbsp; &nbsp;&nbsp; &nbsp; 发送信息&nbsp; &nbsp; write test&nbsp; &nbsp;[ctrl]+d 发送<br>mesg&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;设置终端机的写入权限&nbsp; &nbsp; mesg n 禁止接收&nbsp; &nbsp;&nbsp;&nbsp;mesg y <br>wall&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;向所有用户发送信息&nbsp; &nbsp; wall this is q test<br>mail&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;写mail&nbsp; &nbsp;<br>/etc/default/useradd&nbsp; &nbsp; 家目录默认设置<br>quota&nbsp; &nbsp;&nbsp; &nbsp;显示磁盘已使用的空间与限制&nbsp; &nbsp;&nbsp;&nbsp;quota -guvs -----&gt;秀出目前 root 自己的 quota 限制值<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;quota -vu&nbsp; &nbsp;查询<br>quotacheck&nbsp; &nbsp;检查磁盘的使用空间与限制&nbsp; &nbsp;&nbsp;&nbsp;quotacheck -avug&nbsp;&nbsp;-----&gt;將所有的在 /etc/mtab 內，含有 quota 支援的 partition 進行掃瞄<br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; [-m] 强制扫描&nbsp;&nbsp;<br>&nbsp; &nbsp;&nbsp;&nbsp;quota一定要是独立的分区,要有quota.user和quota.group两件文件,在/etc/fstab添加一句:<br>&nbsp; &nbsp;&nbsp;&nbsp;/dev/hda3 /home ext3 defaults,usrquota,grpquota 1 2<br>&nbsp; &nbsp;&nbsp;&nbsp;chmod 600 quota*&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;设置完成,重启生效<br>edquota&nbsp; &nbsp; 编辑用户或群组的quota&nbsp;&nbsp;<u>用户,[g]群组,[p]复制,[t]设置宽限期限 <br>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;edquota -a yang&nbsp; &nbsp;&nbsp; &nbsp; edquota -p yang -u young -----&gt;复制&nbsp; &nbsp; <br>quotaon&nbsp; &nbsp; 开启磁盘空间限制&nbsp; &nbsp;&nbsp;&nbsp;quotaon -auvg --------&gt;啟動所有的具有 quota 的 filesystem<br>quotaoff&nbsp; &nbsp;关闭磁盘空间限制&nbsp; &nbsp;&nbsp;&nbsp;quotaoff -a&nbsp;&nbsp;--------&gt;關閉了 quota 的限制<br>repquota -av&nbsp; &nbsp;&nbsp;&nbsp;查閱系統內所有的具有 quota 的 filesystem 的限值狀態<br>Quota 從開始準備 filesystem 的支援到整個設定結束的主要的步驟大概是：<br>1、設定 partition 的 filesystem 支援 quota 參數：<br>由於 quota 必須要讓 partition 上面的 filesystem 支援才行，一般來說， 支援度最好的是 ext2/ext3 ，<br>其他的 filesystem 類型鳥哥我是沒有試過啦！ 啟動 filesystem 支援 quota 最簡單就是編輯 /etc/fstab ，<br>使得準備要開放的 quota 磁碟可以支援 quota 囉；<br>2、建立 quota 記錄檔：<br>剛剛前面講過，整個 quota 進行磁碟限制值記錄的檔案是 aquota.user/aquota.group， <br>要建立這兩個檔案就必須要先利用 quotacheck 掃瞄才行喔！<br>3、編輯 quota 限制值資料：<br>再來就是使用 edquota 來編輯每個使用者或群組的可使用空間囉；<br>4、重新掃瞄與啟動 quota ：<br>設定好 quota 之後，建議可以再進行一次 quotacheck ，然後再以 quotaon 來啟動吧！<br>开机流程简介<br>1、載入 BIOS 的硬體資訊，並取得第一個開機裝置的代號； <br>2、讀取第一個開機裝置的 MBR 的 boot Loader (亦即是 lilo, grub, spfdisk 等等) 的開機資訊； <br>3、載入 Kernel 作業系統核心資訊， Kernel 開始解壓縮，並且嘗試驅動所有硬體裝置； <br>4、Kernel 執行 init 程式並取得 run-level 資訊； <br>5、init 執行 /etc/rc.d/rc.sysinit 檔案； <br>6、啟動核心的外掛模組 (/etc/modprobe.conf)； <br>7、init 執行 run-level 的各個批次檔( Scripts )； <br>8、init 執行 /etc/rc.d/rc.local 檔案； <br>9、執行 /bin/login 程式，並等待使用者登入； <br>10、登入之後開始以 Shell 控管主機。 <br>在/etc/rc.d/rc3.d內,以S开头的为开机启动,以K开头的为关闭,接着的数字代表执行顺序<br>GRUB vga设定<br>彩度\解析度&nbsp;&nbsp;640x480&nbsp;&nbsp;800x600&nbsp;&nbsp;1024x768&nbsp;&nbsp;1280x1024&nbsp; &nbsp;bit <br>&nbsp; &nbsp; 256&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;769&nbsp; &nbsp;&nbsp; &nbsp;771&nbsp; &nbsp;&nbsp; &nbsp;773&nbsp; &nbsp;&nbsp; &nbsp; 775&nbsp; &nbsp;&nbsp; &nbsp;8 bit <br>&nbsp; &nbsp;32768&nbsp; &nbsp;&nbsp; &nbsp; 784&nbsp; &nbsp;&nbsp; &nbsp;787&nbsp; &nbsp;&nbsp; &nbsp;790&nbsp; &nbsp;&nbsp; &nbsp; 793&nbsp; &nbsp;&nbsp;&nbsp;15 bit <br>&nbsp; &nbsp;65536&nbsp; &nbsp;&nbsp; &nbsp; 785&nbsp; &nbsp;&nbsp; &nbsp;788&nbsp; &nbsp;&nbsp; &nbsp;791&nbsp; &nbsp;&nbsp; &nbsp; 794&nbsp; &nbsp;&nbsp;&nbsp;16 bit <br>&nbsp; &nbsp;16.8M&nbsp; &nbsp;&nbsp; &nbsp; 786&nbsp; &nbsp;&nbsp; &nbsp;789&nbsp; &nbsp;&nbsp; &nbsp;792&nbsp; &nbsp;&nbsp; &nbsp; 795&nbsp; &nbsp;&nbsp;&nbsp;32 bit <br>./configure&nbsp; &nbsp; 检查系统信息&nbsp; &nbsp;&nbsp; &nbsp; ./configure --help | more&nbsp;&nbsp;帮助信息<br>make clean&nbsp; &nbsp;&nbsp;&nbsp;清除之前留下的文件<br>make&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;编译<br>make install&nbsp; &nbsp;安装<br>rpm -q&nbsp;&nbsp;-----&gt;查询是否安装&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; rpm -ql ------&gt;查询该套件所有的目录<br>rpm -qi -----&gt;查询套件的说明资料&nbsp; &nbsp;&nbsp; &nbsp; rpm -qc[d] -----&gt;设定档与说明档<br>rpm -ivh&nbsp;&nbsp;----&gt;安装&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;rpm -V&nbsp;&nbsp;--------&gt;查看套件有否更动过<br>rpm -e&nbsp;&nbsp;------&gt;删除&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;rpm -Uvh -------&gt;升级安装&nbsp;&nbsp;<br>--nodeps -----&gt;强行安装&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; --test -----&gt;测试安装<br></div>
</u></u>
<img src ="http://www.cppblog.com/liu1061/aggbug/54897.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-29 10:14 <a href="http://www.cppblog.com/liu1061/articles/54897.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用AutoMake轻松生成Makefile（转）</title><link>http://www.cppblog.com/liu1061/articles/54540.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Wed, 25 Jun 2008 03:18:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/54540.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/54540.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/54540.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/54540.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/54540.html</trackback:ping><description><![CDATA[<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">摘要：</td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">在 Unix 上写过程序的人一般都遇到过 Makefile，尤其是用 C 来开发程序的人。用 make 来开发和编译程序的确很方便，可是要写出一个MakeFile就不那么简单了。偏偏介紹 Makefile 的文件不多，GNU Make 那份印出来要几百页的文件，光看完 Overview 自己就快要先Over了，难怪许多人闻 Unix色变。本文将介绍如何利用 GNU Autoconf 及 Automake 这两套软件来帮助『自动』产生 Makefile 文件，并且让开发出来的的软件可以象 Apache, MySQL 和常見的 GNU 软件一样，只要会 ``./configure'', ``make'', ``make install'' 就可以把程序安裝到系统中。如果您有心开发 Open Source 的软件，或只是想在 Unix 系統下写写程序。希望这份介绍文件能帮助您轻松的进入 Unix Programming 的殿堂。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">1. 简介 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">Makefile 基本上就是『目标』(target), 『关联』(dependencies) 和『动作』三者所组成的一系列规则。而 make 就会根据 Makefile 的规则来決定如何编译 (compile) 和连接 (link) 程式。实际上，make 可做的不只是编译和连接程序，例如 FreeBSD 的 port collection 中，Makefile还可以做到自动下载远程程序，解压缩 (extract) ， 打补丁 (patch)，设定，然后编译，安装到系统中。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">Makefile 基本结构虽然很简单，但是妥善运用这些规则就可以变换出许多不同的花样。却也因为这样，许多刚刚开始学习写Makefile 时会觉得没有规范可以遵循，每个人写出来的Makefile都不大一样，不知道从哪里下手，而且常常会受到自己的开发环境的限制，只要环境参数不同或者路径更改，可能 Makefile 就得跟着修改修改。虽然有 GNU Makefile Conventions (GNU Makefile惯例例)订出一些使用 GNU 程式设计时撰写 Makefile 的一些标准和规范，但是内容很长而且很复杂，并且经常作一些调整，为了减轻程序开发人员维护Makefile 的负担，因此出现了Automake。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">程序设计者只需要写一些预先定义好的宏 (macro)，提交给Automake处理后会产生一个可以供 Autoconf 使用的 Makefile.in文件。再配合利用 Autoconf产生的自动培植设置文件 configure 即可产生一份符合符合 GNU Makefile 惯例的 Makeifle 了。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">2. 上路之前 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">在开始使用 Automake 之前，首先确认你的系统安装有如下软件：</td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">　 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">1. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">GNU Automake </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">2. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">GNU Autoconf </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">3. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">GNU m4 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">4. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">perl </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">5. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">GNU Libtool (如果你需要产生 shared library) </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">建议最好也使用 GNU C/C++ 编译器 、GNU Make 以及其它 GNU 的工具程序来作为开发的环境，这些工具都是属于 Open Source Software 不但免费而且功能强大。如果你是使用 Red Hat Linux 可以找到所有上述软件的 rpm 文件，FreeBSD 也有现成的 package 可以直接安装，或也可以自行下载这些软件的源代码回来安装。下面的示例是在Red Hat Linux 5.2 + CLE2 的环境下所完成的。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">3. 一个简单的例子 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">Automake 所产生的 Makefile 除了可以做到程式的编译和连接，也已经把如何产生程序文件 (如 manual page, info 文件及 dvi 文件) 的动作，还有把源码文件包装起来以供发布都考虑进去了，所以程序源代码所存放的目录结构最好符合GNU 的标准惯例，接下来就用一个hello.c 來做为例子。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">在工作目录下建立一个新的子目录"devel"'，再在 devel 下建立一个"hello"' 的子目录，这个目录将作为存放 hello这个程序及其相关文件的地方： </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% mkdir devel</td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% cd devel</td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% mkdir hello </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% cd hello </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">用编辑器写一个hello.c文件， </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">#include <stdio.h></td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">int main(int argc, char** argv) { </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">printf(``Hello, GNU!\n''); </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">return 0; </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">} </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">接下来就要用 Autoconf 及 Automake 來产生 Makefile 文件了， </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">1. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">用 autoscan 产生一个 configure.in 的原型，执行autoscan 后会产生一个configure.scan 的文件，可以用它作为 configure.in文件的蓝本。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">　 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% autoscan </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% ls </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">configure.scan hello.c </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">2. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">编辑 configure.scan文件，如下所示，並且改名为configure.in </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">dnl Process this file with autoconf to produce a configure script. AC_INIT(hello.c) AM_INIT_AUTOMAKE(hello, 1.0) </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">dnl Checks for programs. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">AC_PROG_CC </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">dnl Checks for libraries. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">dnl Checks for header files. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">dnl Checks for typedefs, structures, and compiler characteristics. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">dnl Checks for library functions. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">AC_OUTPUT(Makefile) </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">3. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">执行 aclocal 和 autoconf ，分別会产生 aclocal.m4 及 configure 两个文件 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% aclocal </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% autoconf </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% ls </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">aclocal.m4 configure configure.in hello.c </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">4. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">编辑 Makefile.am 文件，內容如下 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">AUTOMAKE_OPTIONS= foreign </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">bin_PROGRAMS= hello </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">hello_SOURCES= hello.c </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">5. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">执行 automake --add-missing ，Automake 会根据Makefile.am 文件产生一些文件，包含最重要的 Makefile.in </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% automake --add-missing automake: configure.in: installing `./install-sh' automake: configure.in: installing `./mkinstalldirs' automake: configure.in: installing `./missing' </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">6. </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">最后执行 ./configure ， </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% ./configure creating cache ./config.cache checking for a BSD compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking whether make sets ${MAKE}... yes checking for working aclocal... found checking for working autoconf... found checking for working automake... found checking for working autoheader... found checking for working makeinfo... found checking for gcc... gcc checking whether the C compiler (gcc ) works... yes checking whether the C compiler (gcc ) is a cross-compiler... no checking whether we are using GNU C... yes checking whether gcc accepts -g... yes updating cache ./config.cache creating ./config.status creating Makefile </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">現在你的目录下已经产生了一个 Makefile 檔，下個 ``make'' 指令就可以開始編譯 hello.c 成執行檔，執行 ./hello 和 GNU 打聲招呼吧！ </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">% make gcc -DPACKAGE=\"hello\" -DVERSION=\"1.0\" -I. -I. -g -O2 -c hello.c gcc -g -O2 -o hello hello.o % ./hello Hello! GNU! </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">你還可以試試 ``make clean''，''make install''，''make dist'' 看看會有什麼結果。你也可以把產生出來的 Makefile 秀給你的老闆，讓他從此對你刮目相看 :-) </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">4. 追根问底 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">上述产生Makefile 的过程和以往自行编写的方式非常不一樣，舍弃传统自定义make 的规则，使用 Automake 只需用到一些已经定义好的宏就可以了。我们把宏及目标 (target)写在Makefile.am 文件内，Automake 读入 Makefile.am 文件后会把这一串已经定义好的宏展开并产生相对应的 Makefile.in 文件，然后再由 configure这个 shell script 根据 Makefile.in 产生合适的Makefile。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">
            <p style="FONT-SIZE: 10pt" align=center><v:shapetype id=_x0000_t75 coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"><v:stroke joinstyle="miter"></v:stroke><v:formulas><v:f eqn="if lineDrawn pixelLineWidth 0"></v:f><v:f eqn="sum @0 1 0"></v:f><v:f eqn="sum 0 0 @1"></v:f><v:f eqn="prod @2 1 2"></v:f><v:f eqn="prod @3 21600 pixelWidth"></v:f><v:f eqn="prod @3 21600 pixelHeight"></v:f><v:f eqn="sum @0 0 1"></v:f><v:f eqn="prod @6 1 2"></v:f><v:f eqn="prod @7 21600 pixelWidth"></v:f><v:f eqn="sum @8 21600 0"></v:f><v:f eqn="prod @7 21600 pixelHeight"></v:f><v:f eqn="sum @10 21600 0"></v:f></v:formulas><v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect"></v:path><o:lock v:ext="edit" aspectratio="t"></o:lock></v:shapetype><v:shape id=_x0000_i1025 type="#_x0000_t75" alt=""><v:imagedata src="01_7_214.gif" o:href="http://www.eastlinux.com/make/gif/autoconf.gif"></v:imagedata></v:shape><img height=315 src="http://www.ccw.com.cn/htm/app/linux/develop/01_7_214.gif" width=466 v:shapes="_x0000_i1025"> </p>
            </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">
            <p style="FONT-SIZE: 10pt" align=center>利用 autoconf 及 automake产生Makefile 的流程</p>
            </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">上图表示在上一范例中要使用的文件档案及产生出来的文件，有星号 (*) 者代表可执行文件。在此示例中可由 Autoconf 及 Automake 工具所产生的额外文件有 configure.scan、aclocal.m4、configure、Makefile.in，需要自行加入设置的有configure.in 及 Makefile.am。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">4.1 编辑 configure.in 文件 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">Autoconf 是用来产生 'configure'文件的工具。'configure' 是一个 shell script，它可以自动设定原始程序以符合各种不同平台上Unix 系统的特性，并且根据系统参数及环境产生合适的Makefile文件或C 的头文件(header file)，让原始程式可以很方便地在不同的平台上进行编译。Autoconf会读取 configure.in 文件然后产生'configure' 这个 shell script。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">configure.in 文件内容是一系列GNU m4 的宏，这些宏经autoconf处理后会变成检查系统特性的shell scripts。 configure.in 内宏的顺序并没有特别的规定，但是每一个configure.in 文件必須在所有宏前加入 AC_INIT 宏，然后在所有宏的最后加上 AC_OUTPUT宏。可先用 autoscan 扫描原始文件以产生一个 configure.scan 文件，再对 configure.scan 做些修改成 configure.in 文件。在范例中所用到的宏如下： </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">dnl </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">这个宏后面的字不会被处理，可以视为注释 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">AC_INIT(FILE) </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">该宏用来检查源代码所在路径，autoscan 会自动产生，一般无须修改它。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">AM_INIT_AUTOMAKE(PACKAGE,VERSION) </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">这个是使用 Automake 所必备的宏，PACKAGE 是所要产生软件套件的名称，VERSION 是版本编号。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">AC_PROG_CC </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">检查系统可用的C编译器，若源代码是用C写的就需要这个宏。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">AC_OUTPUT(FILE) </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">设置 configure 所要产生的文件，若是Makefile ，configure 便会把它检查出来的结果带入 Makefile.in 文件后产生合适的 Makefile。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">实际上，这里使用 Automake 时，还需要一些其他的宏，这些额外的宏我们用 aclocal来帮助产生。執行 aclocal会产生aclocal.m4 文件，如果无特别的用途，可以不需要修改它，用 aclocal 所产生的宏会告诉 Automake如何动作。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">有了 configure.in 及 aclocal.m4两个文件以后，便可以执行 autoconf来产生 configure 文件了。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">4.2 编辑Makefile.am 文件 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">接下来要编辑Makefile.am 文件，Automake 会根据 configure.in 中的宏把Makefile.am 转成 Makefile.in 文件。 Makefile.am 文件定义所要产生的目标： </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">AUTOMAKE_OPTIONS </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">设置 automake 的选项。Automake 主要是帮助开发 GNU 软件的人员来维护软件，所以在执行 automake 时，会检查目录下是否存在标准 GNU 软件中应具备的文件，例如 'NEWS'、'AUTHOR'、'ChangeLog' 等文件。设置 foreign 时，automake 会改用一般软件的标准来检查。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">bin_PROGRAMS </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">定义要产生的执行文件名。如果要产生多个执行文件，每个文件名用空白符隔开。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">hello_SOURCES </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">定义 'hello' 这个执行程序所需要的原始文件。如果 'hello'这个程序是由多个原始文件所产生，必須把它所用到的所有原始文件都列出来，以空白符隔开。假设 'hello' 还需要 'hello.c'、'main.c'、'hello.h' 三个文件的话，则定义 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">hello_SOURCES= hello.c main.c hello.h </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">如果定义多个执行文件，则对每个执行程序都要定义相对的filename_SOURCES。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">编辑好 Makefile.am 文件，就可以用 automake --add-missing来产生 Makefile.in。加上 --add-missing 选项来告诉 automake顺便假如包装一个软件所必须的文件。Automake产生生出來的 Makefile.in 文件是完全符合 GNU Makefile 的惯例，只要执行 configure这个shell script 便可以产生合适的 Makefile 文件了。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">4.3 使用 Makefile </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">利用 configure 所产生的 Makefile文件有几个预先设定的目标可供使用，这里只用几个简述如下： </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">make all </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">产生设定的目标，既次范例中的执行文件。只敲入make 也可以，此时会开始编译源代码，然后连接并产生执行文件。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">make clean </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">清除之前所编译的执行文件及目标文件(object file, *.o)。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">make distclean </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">除了清除执行文件和目的文件以外，也把 configure 所产生的 Makefile 清除掉。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">make install </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">將程序安装到系统中，若源码编译成功，且执行结果正确，便可以把程序安装到系统预先设定的执行文件存放路径中，若用 bin_PROGRAMS 宏的话，程序会被安装到 /usr/local/bin下。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">make dist </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">將程序和相关的文档包装为一个压缩文档以供发布 (distribution) 。执行完在目录下会产生一个以PACKAGE-VERSION.tar.gz 为名称的文件。PACKAGE 和 VERSION 这两个参数是根据 configure.in 文件中 AM_INIT_AUTOMAKE(PACKAGE, VERSION) 的定义。在此范例中会产生 'hello-1.0.tar.gz' 的文件。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">make distcheck </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">和 make dist 类似，但是加入检查包装以后的压缩文件是否正常，这个目标除了把程序和相关文档包装成 tar.gz 文件外，还会自动把这个压缩文件解开，执行 configure，并执行 make all ，确认编译无错误以后，户显示这个 tar.gz 文件已经准备好可以发布了。这个检查非常有用，检查过关的套件，基本上可以给任何具备 GNU 开发环境的人去重新编译成功。就 hello-1.tar.gz 这个范例而言，除了在Red Hat Linux 上，在 FreeBSD 2.2.x 也可以正确编译。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">要注意的是，利用 Autoconf 及 Automake 所产生出來的软件套件是可以在没有安装 Autoconf 及 Automake 的环境使用的，因为 configure 是一个 shell script，它己被设计为可以在一般 Unix 的 sh 这个 shell 下执行。但是如果要修改 configure.in 及 Makefile.am 文件再产生新的 configure 及 Makefile.in 文件时就一定要有 Autoconf 及 Automake 了。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">5. 相关资料 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">Autoconf 和 Automake 功能十分强大，可以从它们附带的 info 稳当4中找到详细的使用方法说明。你也可以从许多现有的GNU 软件或 Open Source 软件中找到相关的 configure.in 或 Makefile.am 文件，他们是学习 Autoconf 及 Automake 更多技巧的最佳范例。</td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">这个简介只用到了 Autoconf 及 Automake 的皮毛罢了，如果你有心加入 Open Source 软件开发的行列，希望这篇文章可以帮助你对产生 Makefile 有个简单的了解。其它有关开发 GNU 程式或 C 程序设计及 Makefile 的详细运用及技巧，建议从 GNU Coding Standards (GNU 编码规定) 读起，里面包含了 GNU Makefile 惯例，及开发 GNU 软件的标准程序和惯例。这些 GNU 软件的在线说明文件可以在 http://www.gnu.org/ 上找到。 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">6. 结束语 </td>
        </tr>
    </tbody>
</table>
<table width=620 align=center>
    <tbody>
        <tr>
            <td style="FONT-SIZE: 10pt">利用 Autoconf 及 Automake，产生一个 Makefile 似乎不再象以前那么困难了，而使用 Autoconf 也使得我们在不同平台上或各家 Unix 之间发布及便宜程序变的简单，这对于在Unix 系统上程序开发员来说减轻了许多负担。妥善运用这些 GNU 的工具软件，可以帮助我们更容易的去开发程序，而且更容易维护源代码。</td>
        </tr>
    </tbody>
</table>
<img src ="http://www.cppblog.com/liu1061/aggbug/54540.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-25 11:18 <a href="http://www.cppblog.com/liu1061/articles/54540.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>vim参考手册！</title><link>http://www.cppblog.com/liu1061/articles/54535.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Wed, 25 Jun 2008 01:57:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/54535.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/54535.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/54535.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/54535.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/54535.html</trackback:ping><description><![CDATA[<a title=vim参考手册 href="http://vimcdoc.sourceforge.net/doc/help.html">vim参考手册</a>
<img src ="http://www.cppblog.com/liu1061/aggbug/54535.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-25 09:57 <a href="http://www.cppblog.com/liu1061/articles/54535.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux平台可以用gdb进行反汇编和调试。</title><link>http://www.cppblog.com/liu1061/articles/53762.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Tue, 17 Jun 2008 13:16:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/53762.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/53762.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/53762.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/53762.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/53762.html</trackback:ping><description><![CDATA[如果在Linux平台可以用gdb进行反汇编和调试。(转)<br><br>2. 最简C代码分析<br><br>&nbsp;&nbsp;&nbsp; 为简化问题，来分析一下最简的c代码生成的汇编代码：<br>&nbsp;&nbsp;&nbsp; # vi test1.c<br>&nbsp; &nbsp; &nbsp; <br>&nbsp;&nbsp;&nbsp; int main()<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; return 0;<br>&nbsp;&nbsp;&nbsp; }&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; 编译该程序，产生二进制文件：<br>&nbsp;&nbsp;&nbsp; # gcc test1.c -o test1<br>&nbsp; &nbsp; # file test1 &nbsp;<br>&nbsp;&nbsp;&nbsp; test1: ELF 32-bit LSB executable 80386 Version 1, dynamically linked, not stripped <br><br>&nbsp;&nbsp;&nbsp; test1是一个ELF格式32位小端(Little Endian)的可执行文件，动态链接并且符号表没有去除。<br>&nbsp;&nbsp;&nbsp; 这正是Unix/Linux平台典型的可执行文件格式。<br>&nbsp;&nbsp;&nbsp; 用mdb反汇编可以观察生成的汇编代码：<br><br>&nbsp;&nbsp;&nbsp; # mdb test1<br>&nbsp;&nbsp;&nbsp; Loading modules: [ libc.so.1 ]<br>&nbsp;&nbsp;&nbsp; &gt; main::dis&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ; 反汇编main函数，mdb的命令一般格式为&nbsp; &lt;地址&gt;::dis<br>&nbsp;&nbsp;&nbsp; main:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; pushl&nbsp;&nbsp; %ebp&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ; ebp寄存器内容压栈，即保存main函数的上级调用函数的栈基地址<br>&nbsp;&nbsp;&nbsp; main+1:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; %esp,%ebp&nbsp; ; esp值赋给ebp，设置main函数的栈基址<br>&nbsp;&nbsp;&nbsp; main+3:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; subl&nbsp;&nbsp;&nbsp; $8,%esp<br>&nbsp;&nbsp;&nbsp; main+6:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; andl&nbsp;&nbsp;&nbsp; $0xf0,%esp<br>&nbsp;&nbsp;&nbsp; main+9:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; $0,%eax<br>&nbsp;&nbsp;&nbsp; main+0xe:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; subl&nbsp;&nbsp;&nbsp; %eax,%esp<br>&nbsp;&nbsp;&nbsp; main+0x10:&nbsp;&nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; $0,%eax&nbsp;&nbsp;&nbsp; ; 设置函数返回值0<br>&nbsp;&nbsp;&nbsp; main+0x15:&nbsp;&nbsp;&nbsp;&nbsp; leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; 将ebp值赋给esp，pop先前栈内的上级函数栈的基地址给ebp，恢复原栈基址<br>&nbsp;&nbsp;&nbsp; main+0x16:&nbsp;&nbsp;&nbsp;&nbsp; ret&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; main函数返回，回到上级调用<br>&nbsp;&nbsp;&nbsp; &gt; <br><br>&nbsp;&nbsp;&nbsp; 注：这里得到的汇编语言语法格式与Intel的手册有很大不同，Unix/Linux采用AT&amp;T汇编格式作为汇编语言的语法格式<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; 如果想了解AT&amp;T汇编可以参考文章：<a id=_f558cecf7aa04da3_HomePageDays_DaysList__ctl9_DayItem_DayList__ctl0_TitleUrl href="http://blog.csdn.net/yayong/archive/2004/10/17/139983.aspx"><span style="FONT-SIZE: 10pt">Linux AT&amp;T 汇编语言开发指南</span></a><span style="FONT-SIZE: 10pt"> <br><br>&nbsp;&nbsp;&nbsp; 问题：谁调用了 main函数？<br>&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp; 在C语言的层面来看，main函数是一个程序的起始入口点，而实际上，ELF可执行文件的入口点并不是main而是_start。<br>&nbsp;&nbsp;&nbsp;&nbsp; mdb也可以反汇编_start：<br>&nbsp; &nbsp; &nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &gt; _start::dis&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ;从_start 的地址开始反汇编<br>&nbsp;&nbsp;&nbsp; _start:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; $0<br>&nbsp;&nbsp;&nbsp; _start+2:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; $0<br>&nbsp;&nbsp;&nbsp; _start+4:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; %esp,%ebp<br>&nbsp;&nbsp;&nbsp; _start+6:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; %edx<br>&nbsp;&nbsp;&nbsp; _start+7:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; $0x80504b0,%eax<br>&nbsp;&nbsp;&nbsp; _start+0xc:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; testl&nbsp;&nbsp; %eax,%eax<br>&nbsp;&nbsp;&nbsp; _start+0xe:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; je&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +0xf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;_start+0x1d&gt;<br>&nbsp;&nbsp;&nbsp; _start+0x10:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; $0x80504b0<br>&nbsp;&nbsp;&nbsp; _start+0x15:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call&nbsp;&nbsp;&nbsp; -0x75&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atexit&gt;<br>&nbsp;&nbsp;&nbsp; _start+0x1a:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addl&nbsp;&nbsp;&nbsp; $4,%esp<br>&nbsp;&nbsp;&nbsp; _start+0x1d:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; $0x8060710,%eax<br>&nbsp;&nbsp;&nbsp; _start+0x22:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; testl&nbsp;&nbsp; %eax,%eax<br>&nbsp;&nbsp;&nbsp; _start+0x24:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; je&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; +7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;_start+0x2b&gt;<br>&nbsp;&nbsp;&nbsp; _start+0x26:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call&nbsp;&nbsp;&nbsp; -0x86&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atexit&gt;<br>&nbsp;&nbsp;&nbsp; _start+0x2b:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; $0x80506cd<br>&nbsp;&nbsp;&nbsp; _start+0x30:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call&nbsp;&nbsp;&nbsp; -0x90&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;atexit&gt;<br>&nbsp;&nbsp;&nbsp; _start+0x35:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; +8(%ebp),%eax<br>&nbsp;&nbsp;&nbsp; _start+0x38:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leal&nbsp;&nbsp;&nbsp; +0x10(%ebp,%eax,4),%edx<br>&nbsp;&nbsp;&nbsp; _start+0x3c:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; %edx,0x8060804<br>&nbsp;&nbsp;&nbsp; _start+0x42:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; andl&nbsp;&nbsp;&nbsp; $0xf0,%esp<br>&nbsp;&nbsp;&nbsp; _start+0x45:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; subl&nbsp;&nbsp;&nbsp; $4,%esp<br>&nbsp;&nbsp;&nbsp; _start+0x48:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; %edx<br>&nbsp;&nbsp;&nbsp; _start+0x49:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; leal&nbsp;&nbsp;&nbsp; +0xc(%ebp),%edx<br>&nbsp;&nbsp;&nbsp; _start+0x4c:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; %edx<br>&nbsp;&nbsp;&nbsp; _start+0x4d:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; %eax<br>&nbsp;&nbsp;&nbsp; _start+0x4e:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call&nbsp;&nbsp;&nbsp; +0x152&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;_init&gt;<br>&nbsp;&nbsp;&nbsp; _start+0x53:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call&nbsp;&nbsp;&nbsp; -0xa3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;__fpstart&gt;<br>&nbsp;&nbsp;&nbsp; _start+0x58:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call&nbsp;&nbsp;&nbsp; +0xfb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;main&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ;在这里调用了main函数<br>&nbsp;&nbsp;&nbsp; _start+0x5d:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; addl&nbsp;&nbsp;&nbsp; $0xc,%esp<br>&nbsp;&nbsp;&nbsp; _start+0x60:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; %eax<br>&nbsp;&nbsp;&nbsp; _start+0x61:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call&nbsp;&nbsp;&nbsp; -0xa1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;exit&gt;<br>&nbsp;&nbsp;&nbsp; _start+0x66:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; $0<br>&nbsp;&nbsp;&nbsp; _start+0x68:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; $1,%eax<br>&nbsp;&nbsp;&nbsp; _start+0x6d:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lcall&nbsp;&nbsp; $7,$0<br>&nbsp;&nbsp;&nbsp; _start+0x74:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; hlt<br>&nbsp;&nbsp;&nbsp; &gt; <br><br>&nbsp;&nbsp;&nbsp; 问题：为什么用EAX寄存器保存函数返回值？<br>&nbsp;&nbsp;&nbsp; 实际上IA32并没有规定用哪个寄存器来保存返回值。但如果反汇编Solaris/Linux的二进制文件，就会发现，都用EAX保存函数返回值。<br>&nbsp;&nbsp;&nbsp; 这不是偶然现象，是操作系统的ABI(Application Binary Interface)来决定的。<br>&nbsp;&nbsp;&nbsp; Solaris/Linux操作系统的ABI就是Sytem V ABI。<br><br><br>&nbsp;&nbsp;&nbsp; 概念：SFP (Stack Frame Pointer) 栈框架指针&nbsp;<br><br>&nbsp;&nbsp;&nbsp; 正确理解SFP必须了解：<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; IA32 的栈的概念<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CPU 中32位寄存器ESP/EBP的作用<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; PUSH/POP 指令是如何影响栈的<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; CALL/RET/LEAVE 等指令是如何影响栈的<br><br>&nbsp;&nbsp;&nbsp; 如我们所知：<br>&nbsp;&nbsp;&nbsp; 1)IA32的栈是用来存放临时数据，而且是LIFO，即后进先出的。栈的增长方向是从高地址向低地址增长，按字节为单位编址。<br>&nbsp;&nbsp;&nbsp; 2) EBP是栈基址的指针，永远指向栈底（高地址），ESP是栈指针，永远指向栈顶（低地址）。<br>&nbsp;&nbsp;&nbsp; 3) PUSH一个long型数据时，以字节为单位将数据压入栈，从高到低按字节依次将数据存入ESP-1、ESP-2、ESP-3、ESP-4的地址单元。<br>&nbsp;&nbsp;&nbsp; 4) POP一个long型数据，过程与PUSH相反，依次将ESP-4、ESP-3、ESP-2、ESP-1从栈内弹出，放入一个32位寄存器。<br>&nbsp;&nbsp;&nbsp; 5) CALL指令用来调用一个函数或过程，此时，下一条指令地址会被压入堆栈，以备返回时能恢复执行下条指令。<br>&nbsp;&nbsp;&nbsp; 6) RET指令用来从一个函数或过程返回，之前CALL保存的下条指令地址会从栈内弹出到EIP寄存器中，程序转到CALL之前下条指令处执行<br>&nbsp;&nbsp;&nbsp; 7) ENTER是建立当前函数的栈框架，即相当于以下两条指令：<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; %ebp<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; %esp,%ebp<br>&nbsp;&nbsp;&nbsp; 8) LEAVE是释放当前函数或者过程的栈框架，即相当于以下两条指令：<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; movl ebp esp<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; popl&nbsp; ebp<br><br>&nbsp;&nbsp;&nbsp; 如果反汇编一个函数，很多时候会在函数进入和返回处，发现有类似如下形式的汇编语句： <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; %ebp&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ; ebp寄存器内容压栈，即保存main函数的上级调用函数的栈基地址<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; %esp,%ebp&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ; esp值赋给ebp，设置 main函数的栈基址<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ...........&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; ; 以上两条指令相当于 enter 0,0<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ...........<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; leave&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ; 将ebp值赋给esp，pop先前栈内的上级函数栈的基地址给ebp，恢复原栈基址<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ret&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; main函数返回，回到上级调用<br><br>&nbsp;&nbsp;&nbsp; 这些语句就是用来创建和释放一个函数或者过程的栈框架的。<br>&nbsp;&nbsp;&nbsp; 原来编译器会自动在函数入口和出口处插入创建和释放栈框架的语句。<br>&nbsp;&nbsp;&nbsp; 函数被调用时：<br>&nbsp;&nbsp;&nbsp; 1) EIP/EBP成为新函数栈的边界<br>&nbsp;&nbsp;&nbsp; 函数被调用时，返回时的EIP首先被压入堆栈；创建栈框架时，上级函数栈的EBP被压入堆栈，与EIP一道行成新函数栈框架的边界<br>&nbsp;&nbsp;&nbsp; 2) EBP成为栈框架指针SFP，用来指示新函数栈的边界<br>&nbsp;&nbsp;&nbsp; 栈框架建立后，EBP指向的栈的内容就是上一级函数栈的EBP，可以想象，通过EBP就可以把层层调用函数的栈都回朔遍历一遍，调试器就是利用这个特性实现 backtrace功能的<br>&nbsp;&nbsp;&nbsp; 3) ESP总是作为栈指针指向栈顶，用来分配栈空间<br>&nbsp;&nbsp;&nbsp; 栈分配空间给函数局部变量时的语句通常就是给ESP减去一个常数值，例如，分配一个整型数据就是 ESP-4<br>&nbsp;&nbsp;&nbsp; 4) 函数的参数传递和局部变量访问可以通过SFP即EBP来实现 <br>&nbsp;&nbsp;&nbsp; 由于栈框架指针永远指向当前函数的栈基地址，参数和局部变量访问通常为如下形式：<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; +8+xx(%ebp)&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; ; 函数入口参数的的访问<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; -xx(%ebp)&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; ; 函数局部变量访问<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; 假如函数A调用函数B，函数B调用函数C ，则函数栈框架及调用关系如下图所示：<br></span>
<pre><span style="FONT-SIZE: 10pt">   	+-------------------------+----&gt; 高地址<br>   	| EIP (上级函数返回地址)    | <br>   	+-------------------------+ <br> +--&gt;   | EBP (上级函数的EBP)      | --+ &lt;------当前函数A的EBP (即SFP框架指针) <br> | 	+-------------------------+   +--&gt;偏移量A <br> | 	| Local Variables         |   |<br> | 	| ..........              | --+  &lt;------ESP指向函数A新分配的局部变量,局部变量可以通过A的ebp-偏移量A访问 <br> | f 	+-------------------------+<br> | r 	| Arg n(函数B的第n个参数)   | <br> | a 	+-------------------------+<br> | m 	| Arg .(函数B的第.个参数)   |<br> | e 	+-------------------------+<br> | 	| Arg 1(函数B的第1个参数)   |<br> | o 	+-------------------------+<br> | f 	| Arg 0(函数B的第0个参数)   | --+ &lt;------ B函数的参数可以由B的ebp+偏移量B访问<br> | 	+-------------------------+   +--&gt; 偏移量B<br> | A 	| EIP (A函数的返回地址)     |   | <br> | 	+-------------------------+ --+ <br> +--- 	| EBP (A函数的EBP)         |&lt;--+ &lt;------ 当前函数B的EBP (即SFP框架指针) <br>   	+-------------------------+   |<br>   	| Local Variables         |   |<br>   	| ..........              |   | &lt;------ ESP指向函数B新分配的局部变量<br>   	+-------------------------+   |<br>   	| Arg n(函数C的第n个参数)   |   |<br>   	+-------------------------+   |<br>   	| Arg .(函数C的第.个参数)   |   |<br>   	+-------------------------+   +--&gt; frame of B<br>   	| Arg 1(函数C的第1个参数)   |   |<br>   	+-------------------------+   |<br>   	| Arg 0(函数C的第0个参数)   |   |<br>   	+-------------------------+   |<br>   	| EIP (B函数的返回地址)     |   |<br>   	+-------------------------+   |<br> +--&gt;   | EBP (B函数的EBP)         | --+ &lt;------ 当前函数C的EBP (即SFP框架指针) <br> |      +-------------------------+<br> | 	| Local Variables         |<br> | 	| ..........              | &lt;------ ESP指向函数C新分配的局部变量<br> | 	+-------------------------+----&gt; 低地址<br>frame of C<br>	<br>		图 1-1 <br></span></pre>
<span style="FONT-SIZE: 10pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; 再分析test1反汇编结果中剩余部分语句的含义：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; # mdb test1<br>&nbsp;&nbsp;&nbsp; Loading modules: [ libc.so.1 ]<br>&nbsp;&nbsp;&nbsp; &gt; main::dis&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; 反汇编main函数<br>&nbsp;&nbsp;&nbsp; main:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; %ebp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; main+1:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; %esp,%ebp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; 创建Stack Frame(栈框架)<br>&nbsp;&nbsp;&nbsp; main+3:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; subl&nbsp;&nbsp;&nbsp; $8,%esp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; 通过ESP-8来分配8字节堆栈空间<br>&nbsp;&nbsp;&nbsp; main+6:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; andl&nbsp;&nbsp;&nbsp; $0xf0,%esp&nbsp;&nbsp;&nbsp; ; 使栈地址16字节对齐<br>&nbsp;&nbsp;&nbsp; main+9:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; $0,%eax&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; 无意义<br>&nbsp;&nbsp;&nbsp; main+0xe:&nbsp;&nbsp;&nbsp;&nbsp; subl&nbsp;&nbsp;&nbsp; %eax,%esp&nbsp;&nbsp;&nbsp;&nbsp; ; 无意义<br>&nbsp;&nbsp;&nbsp; main+0x10:&nbsp;&nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; $0,%eax&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; 设置main函数返回值<br>&nbsp;&nbsp;&nbsp; main+0x15:&nbsp;&nbsp;&nbsp;&nbsp; leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; ; 撤销Stack Frame(栈框架)<br>&nbsp;&nbsp;&nbsp; main+0x16:&nbsp;&nbsp;&nbsp;&nbsp; ret&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; main 函数返回<br>&nbsp;&nbsp;&nbsp; &gt;<br><br>&nbsp;&nbsp;&nbsp; 以下两句似乎是没有意义的，果真是这样吗？<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; $0,%eax <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; subl&nbsp;&nbsp;&nbsp;&nbsp; %eax,%esp<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; 用gcc的O2级优化来重新编译test1.c:<br>&nbsp;&nbsp;&nbsp; # gcc -O2 test1.c -o test1<br>&nbsp;&nbsp;&nbsp; # mdb test1<br>&nbsp;&nbsp;&nbsp; &gt; main::dis<br>&nbsp;&nbsp;&nbsp; main:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; %ebp<br>&nbsp;&nbsp;&nbsp; main+1:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; %esp,%ebp<br>&nbsp;&nbsp;&nbsp; main+3:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; subl&nbsp;&nbsp;&nbsp; $8,%esp<br>&nbsp;&nbsp;&nbsp; main+6:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; andl&nbsp;&nbsp;&nbsp; $0xf0,%esp<br>&nbsp;&nbsp;&nbsp; main+9:&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; xorl&nbsp;&nbsp;&nbsp; %eax,%eax&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ; 设置main返回值，使用xorl异或指令来使eax为0<br>&nbsp;&nbsp;&nbsp; main+0xb:&nbsp;&nbsp;&nbsp;&nbsp; leave<br>&nbsp;&nbsp;&nbsp; main+0xc:&nbsp;&nbsp;&nbsp;&nbsp; ret<br>&nbsp;&nbsp;&nbsp; &gt; <br>&nbsp;&nbsp;&nbsp; 新的反汇编结果比最初的结果要简洁一些，果然之前被认为无用的语句被优化掉了，进一步验证了之前的猜测。<br>&nbsp;&nbsp;&nbsp; 提示：编译器产生的某些语句可能在程序实际语义上没有用处，可以用优化选项去掉这些语句。<br><br>&nbsp;&nbsp;&nbsp; 问题：为什么用xorl来设置eax的值？<br>&nbsp;&nbsp;&nbsp; 注意到优化后的代码中，eax返回值的设置由 movl $0,%eax 变为 xorl %eax,%eax ，这是因为IA32指令中，xorl比movl有更高的运行速度。<br><br>&nbsp;&nbsp;&nbsp; 概念：Stack aligned 栈对齐<br>&nbsp;&nbsp;&nbsp; 那么，以下语句到底是和作用呢？<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; subl&nbsp;&nbsp;&nbsp; $8,%esp<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; andl&nbsp;&nbsp;&nbsp; $0xf0,%esp&nbsp;&nbsp;&nbsp;&nbsp; ; 通过andl使低4位为0，保证栈地址16字节对齐<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; 表面来看，这条语句最直接的后果是使ESP的地址后4位为0，即16字节对齐，那么为什么这么做呢？<br>&nbsp;&nbsp;&nbsp; 原来，IA32 系列CPU的一些指令分别在4、8、16字节对齐时会有更快的运行速度，因此gcc编译器为提高生成代码在IA32上的运行速度，默认对产生的代码进行16字节对齐<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; andl $0xf0,%esp 的意义很明显，那么 subl $8,%esp 呢，是必须的吗？<br>&nbsp;&nbsp;&nbsp; 这里假设在进入main函数之前，栈是16字节对齐的话，那么，进入main函数后，EIP和EBP被压入堆栈后，栈地址最末4位二进制位必定是1000，esp -8则恰好使后4位地址二进制位为0000。看来，这也是为保证栈16字节对齐的。<br><br>&nbsp;&nbsp;&nbsp; 如果查一下gcc的手册，就会发现关于栈对齐的参数设置：<br>&nbsp;&nbsp;&nbsp; -mpreferred-stack-boundary=n&nbsp;&nbsp;&nbsp; ; 希望栈按照2的n次的字节边界对齐, n的取值范围是2-12<br><br>&nbsp;&nbsp;&nbsp; 默认情况下，n是等于4的，也就是说，默认情况下，gcc是16字节对齐，以适应IA32大多数指令的要求。<br><br>&nbsp;&nbsp;&nbsp; 让我们利用-mpreferred-stack-boundary=2来去除栈对齐指令：<br>&nbsp;&nbsp;&nbsp; &nbsp; <br>&nbsp;&nbsp;&nbsp; # gcc -mpreferred-stack-boundary=2 test1.c -o test1<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &gt; main::dis<br>&nbsp;&nbsp;&nbsp; main:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pushl&nbsp;&nbsp; %ebp<br>&nbsp;&nbsp;&nbsp; main+1:&nbsp;&nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; %esp,%ebp<br>&nbsp;&nbsp;&nbsp; main+3:&nbsp;&nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; $0,%eax<br>&nbsp;&nbsp;&nbsp; main+8:&nbsp;&nbsp;&nbsp;&nbsp; leave<br>&nbsp;&nbsp;&nbsp; main+9:&nbsp;&nbsp;&nbsp;&nbsp; ret<br>&nbsp;&nbsp;&nbsp; &gt; <br><br>&nbsp;&nbsp;&nbsp; 可以看到，栈对齐指令没有了，因为，IA32的栈本身就是4字节对齐的，不需要用额外指令进行对齐。<br>&nbsp;&nbsp;&nbsp; 那么，栈框架指针SFP是不是必须的呢？<br>&nbsp;&nbsp;&nbsp; # gcc -mpreferred-stack-boundary=2 -fomit-frame-pointer test1.c -o test<br>&nbsp;&nbsp;&nbsp; &gt; main::dis<br>&nbsp;&nbsp;&nbsp; main:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; movl&nbsp;&nbsp;&nbsp; $0,%eax<br>&nbsp;&nbsp;&nbsp; main+5:&nbsp;&nbsp;&nbsp;&nbsp; ret<br>&nbsp;&nbsp;&nbsp; &gt; <br><br>&nbsp;&nbsp;&nbsp; 由此可知，-fomit-frame-pointer 可以去除SFP。<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; 问题：去除SFP后有什么缺点呢？<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; 1)增加调式难度<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 由于SFP在调试器backtrace的指令中被使用到，因此没有SFP该调试指令就无法使用。<br>&nbsp;&nbsp;&nbsp; 2)降低汇编代码可读性<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 函数参数和局部变量的访问，在没有ebp的情况下，都只能通过+xx(esp)的方式访问，而很难区分两种方式，降低了程序的可读性。<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; 问题：去除SFP有什么优点呢？<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; 1)节省栈空间<br>&nbsp;&nbsp;&nbsp; 2)减少建立和撤销栈框架的指令后，简化了代码<br>&nbsp;&nbsp;&nbsp; 3)使ebp空闲出来，使之作为通用寄存器使用，增加通用寄存器的数量<br>&nbsp;&nbsp;&nbsp; 4)以上3点使得程序运行速度更快<br><br>&nbsp;&nbsp;&nbsp; 概念：Calling Convention&nbsp; 调用约定和 ABI (Application Binary Interface) 应用程序二进制接口<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 函数如何找到它的参数？<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 函数如何返回结果？<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 函数在哪里存放局部变量？<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 那一个硬件寄存器是起始空间？<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 那一个硬件寄存器必须预先保留？<br><br>&nbsp;&nbsp;&nbsp; Calling Convention&nbsp; 调用约定对以上问题作出了规定。Calling Convention也是ABI的一部分。<br>&nbsp;&nbsp;&nbsp; 因此，遵守相同ABI规范的操作系统，使其相互间实现二进制代码的互操作成为了可能。<br>&nbsp;&nbsp;&nbsp; 例如：由于Solaris、Linux都遵守System V的ABI，Solaris 10就提供了直接运行Linux二进制程序的功能。<br>&nbsp;&nbsp;&nbsp; 详见文章：</span><a id=_e98ab7f12cd4b33c_HomePageDays_DaysList__ctl10_DayItem_DayList__ctl0_TitleUrl href="http://blog.csdn.net/yayong/archive/2004/09/14/103625.aspx"><span style="FONT-SIZE: 10pt">关注： Solaris 10的10大新变化 </span></a><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <br>3. 小结<br>&nbsp;&nbsp;&nbsp; 本文通过最简的C程序，引入以下概念：<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SFP 栈框架指针<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Stack aligned 栈对齐<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Calling Convention&nbsp; 调用约定 和 ABI (Application Binary Interface) 应用程序二进制接口<br>&nbsp;&nbsp;&nbsp; 今后，将通过进一步的实验，来深入了解这些概念。通过掌握这些概念，使在汇编级调试程序产生的core dump、掌握C语言高级调试技巧成为了可能。<br>
<img src ="http://www.cppblog.com/liu1061/aggbug/53762.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-17 21:16 <a href="http://www.cppblog.com/liu1061/articles/53762.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux 汇编语言开发指南</title><link>http://www.cppblog.com/liu1061/articles/53761.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Tue, 17 Jun 2008 13:11:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/53761.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/53761.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/53761.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/53761.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/53761.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;                                    转载自：IBM developerWorks 中国网站肖文鹏(xiaowp@263.net)北京理工大学计算机系硕士研究生2003 年 7 月                        汇编语言的优点是速度快，可以直接对硬件进行操作，这对诸如图形处理等关键应用是非常重要的。Linux 是一个...&nbsp;&nbsp;<a href='http://www.cppblog.com/liu1061/articles/53761.html'>阅读全文</a><img src ="http://www.cppblog.com/liu1061/aggbug/53761.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-17 21:11 <a href="http://www.cppblog.com/liu1061/articles/53761.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gdb 方法 说明 (转)</title><link>http://www.cppblog.com/liu1061/articles/53249.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Sat, 14 Jun 2008 08:02:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/53249.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/53249.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/53249.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/53249.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/53249.html</trackback:ping><description><![CDATA[<p>* <strong>list</strong>：显示程序中的代码，常用使用格式有：<br><br>　　　　list<br><br>　　　　　　输出从上次调用list命令开始往后的10行程序代码。<br><br>　　　　list -<br><br>　　　　　　输出从上次调用list命令开始往前的10行程序代码。<br><br>　　　　list n<br><br>　　　　　　输出第n行附近的10行程序代码。<br><br>　　　　list function<br><br>　　　　　　输出函数function前后的10行程序代码。<br><br>　* <strong>forward/search</strong>：从当前行向后查找匹配某个字符串的程序行。使用格式：<br><br>　　　　forward/search 字符串<br><br>　　查找到的行号将保存在$_变量中，可以用print $_命令来查看。<br><br>　* <strong>reverse-search</strong>：和forward/search相反，向前查找字符串。使用格式同上。<br><br>　* <strong>break</strong>：在程序中设置断点，当程序运行到指定行上时，会暂停执行。使用格式：<br><br>　　　　break 要设置断点的行号<br><br>　* <strong>tbreak</strong>：设置临时断点，在设置之后只起作用一次。使用格式：<br><br>　　　　tbreak 要设置临时断点的行号<br><br>　* <strong>clear</strong>：和break相反，clear用于清除断点。使用格式：<br><br>　　　　clear 要清除的断点所在的行号<br><br>　* <strong>run</strong>：启动程序，在run后面带上参数可以传递给正在调试的程序。<br><br>　* <strong>awatch</strong>：用来增加一个观察点(add watch)，使用格式：<br><br>　　　　awatch 变量或表达式<br><br>　　当表达式的值发生改变或表达式的值被读取时，程序就会停止运行。<br><br>　* <strong>watch</strong>：与awatch类似用来设置观察点，但程序只有当表达式的值发生改变时才会停止运行。使用格 式：<br><br>　　　　watch 变量或表达式<br><br>　　需要注意的是，awatch和watch都必须在程序运行的过程中设置观察点，即可运行run之后才能设置。<br><br>　* <strong>commands</strong>：设置在遇到断点后执行特定的指令。使用格式有：<br><br>　　　　commands<br><br>　　　　　　设置遇到最后一个遇到的断点时要执行的命令<br><br>　　　　commands n<br><br>　　　　　　设置遇到断点号n时要执行的命令<br><br>　　注意，commands后面跟的是断点号，而不是断点所在的行号。<br><br>　　在输入命令后，就可以输入遇到断点后要执行的命令，每行一条命令，在输入最后一条命令后输入end就可以结束输入。<br><br>　* <strong>delete</strong>：清除断点或自动显示的表达式。使用格式：<br><br>　　　　delete 断点号<br><br>　* <strong>disable</strong>：让指定断点失效。使用格式：<br><br>　　　　disable 断点号列表<br><br>　　断点号之间用空格间隔开。<br><br>　* <strong>enable</strong>：和disable相反，恢复失效的断点。使用格式：<br><br>　　　　enable 断点编号列表<br><br>　* <strong>ignore</strong>：忽略断点。使用格式：<br><br>　　　　ignore 断点号 忽略次数<br><br>　* <strong>condition</strong>：设置断点在一定条件下才能生效。使用格式：<br><br>　　　　condition 断点号 条件表达式<br><br>　* <strong>cont/continue</strong>：使程序在暂停在断点之后继续运行。使用格式：<br><br>　　　　cont<br><br>　　　　　　跳过当前断点继续运行。<br><br>　　　　cont n<br><br>　　　　　　跳过n次断点，继续运行。<br><br>　　当n为1时，cont 1即为cont。<br><br>　* <strong>jump</strong>：让程序跳到指定行开始调试。使用格式：<br><br>　　　　jump 行号<br><br>　* <strong>next</strong>：继续执行语句，但是跳过子程序的调用。使用格式：<br><br>　　　　next<br><br>　　　　　　执行一条语句<br><br>　　　　next n<br><br>　　　　　　执行n条语句<br><br>　* <strong>nexti</strong>：单步执行语句，但和next不同的是，它会跟踪到子程序的内部，但不打印出子程序内部的语句。使用格式同上。<br><br>　* <strong>step</strong>：与next类似，但是它会跟踪到子程序的内部，而且会显示子程序内部的执行情况。使用格式同上。<br><br>　* <strong>stepi</strong>：与step类似，但是比step更详细，是nexti和step的结合。使用格式同上。<br><br>　* <strong>whatis</strong>：显示某个变量或表达式的数据类型。使用格式：<br><br>　　　　whatis 变量或表达式<br><br>　* <strong>ptype</strong>：和whatis类似，用于显示数据类型，但是它还可以显示typedef定义的类型等。使用格式：<br><br>　　　　ptype 变量或表达式<br><br>　* <strong>set</strong>：设置程序中变量的值。使用格式：<br><br>　　　　set 变量=表达式<br><br>　　　　set 变量:=表达式<br><br>　* <strong>display</strong>：增加要显示值的表达式。使用格式：<br><br>　　　　display 表达式<br><br>　* <strong>info display</strong>：显示当前所有的要显示值的表达式。<br><br>　* <strong>delete display/undisplay</strong>：删除要显示值的表达式。使用格式：<br><br>　　　　delete display/undisplay 表达式编号<br><br>　* <strong>disable display</strong>：暂时不显示一个要表达式的值。使用格式：<br><br>　　　　disable display 表达式编号<br><br>　* <strong>enable display</strong>：与disable display相反，使用表达式恢复显示。使用格式：<br><br>　　　　enable display 表达式编号<br><br>　* <strong>print</strong>：打印变量或表达式的值。使用格式：<br><br>　　　　print 变量或表达式<br><br>　　表达式中有两个符号有特殊含义：$和$$。<br><br>　　$表示给定序号的前一个序号，$$表示给定序号的前两个序号。<br><br>　　如果$和$$后面不带数字，则给定序号为当前序号。<br><br>　* <strong>backtrace</strong>：打印指定个数的栈帧(stack frame)。使用格式：<br><br>　　　　backtrace 栈帧个数<br><br>　* <strong>frame</strong>：打印栈帧。使用格式：<br><br>　　　　frame 栈帧号<br><br>　* <strong>info frame</strong>：显示当前栈帧的详细信息。<br><br>　* <strong>select-frame</strong>：选择栈帧，选择后可以用info frame来显示栈帧信息。使用格式：<br><br>　　　　select-frame 栈帧号<br><br>　* <strong>kill</strong>：结束当前程序的调试。<br><br>　* <strong>quit</strong>：退出gdb。</p>
<img src ="http://www.cppblog.com/liu1061/aggbug/53249.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-14 16:02 <a href="http://www.cppblog.com/liu1061/articles/53249.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gdb command! (转)</title><link>http://www.cppblog.com/liu1061/articles/53232.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Sat, 14 Jun 2008 05:37:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/53232.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/53232.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/53232.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/53232.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/53232.html</trackback:ping><description><![CDATA[1.what is gdb? <br>一个调试器，能让你观察到正在运行的程序的某个变量的值，和gcc, emacs组成构建起整个gnu system的3剑客。 <br><br>2.How it work? <br>首先要安装，然后就可以 gdb application,进入gdb模式，执行（run）启动例程。(list-显示源码) <br><br>3.一个优点 <br>GDB的函数调用是缓式的，也就是说只有当变量真正需要时才会被计算。 <br>int c = add(1,1) <br>printf("%d",c); <br><br>gdb--&gt;run--&gt;print c -1222342. c的值直到打印的时候才会被计算。（这里可能有个开关来控制缓式计算） <br><br>4.一个前提 <br>gcc 的时候加上 -g 或者 -ggdb，主要是生成供调试使用的某些信息。（emacs好像默认是关闭这个选项） <br><br>5.存在图形调试界面 <br><br>6.输入help可以查看帮助 <br>help,会显示命令的分类，help 类名 <br><br>7.how use? <br>debug 3 program yourself. <br><br>8.常用命令（From:http://my.donews.com/tangfl/2006/10/23/gdb-debug-example/） <br>　 break NUM 在指定的行上设置断点。 <br>　　bt 显示所有的调用栈帧。该命令可用来显示函数的调用顺序。 <br>　　clear 删除设置在特定源文件、特定行上的断点。其用法为clear FILENAME:NUM <br>　　continue 继续执行正在调试的程序。该命令用在程序由于处理信号或断点而 导致停止运行时。 <br>　　display EXPR 每次程序停止后显示表达式的值。表达式由程序定义的变量组成。 <br>　　file FILE 装载指定的可执行文件进行调试。 <br>　　help NAME 显示指定命令的帮助信息。 <br>　　info break 显示当前断点清单，包括到达断点处的次数等。 <br>　　info files 显示被调试文件的详细信息。 <br>　　info func 显示所有的函数名称。 <br>　　info local 显示当函数中的局部变量信息。 <br>　　info prog 显示被调试程序的执行状态。 <br>　　info var 显示所有的全局和静态变量名称。 <br>　　kill 终止正被调试的程序。 <br>　　list 显示源代码段。 <br>　　make 在不退出 gdb 的情况下运行 make 工具。 <br>　　next 在不单步执行进入其他函数的情况下，向前执行一行源代码。 <br>　　print EXPR 显示表达式 EXPR 的值。 <br>backtrace 显示程序中的当前位置和表示如何到达当前位置的栈跟踪（同义词：where） <br>breakpoint 在程序中设置一个断点 <br>cd 改变当前工作目录 <br>clear 删除刚才停止处的断点 <br>commands 命中断点时，列出将要执行的命令 <br>continue 从断点开始继续执行 <br>delete 删除一个断点或监测点；也可与其他命令一起使用 <br>display 程序停止时显示变量和表达时 <br>down 下移栈帧，使得另一个函数成为当前函数 <br>frame 选择下一条continue命令的帧 <br>info 显示与该程序有关的各种信息 <br>jump 在源程序中的另一点开始运行 <br>kill 异常终止在gdb 控制下运行的程序 <br>list 列出相应于正在执行的程序的原文件内容 <br>next 执行下一个源程序行，从而执行其整体中的一个函数 <br>print 显示变量或表达式的值 <br>pwd 显示当前工作目录 <br>pype 显示一个数据结构（如一个结构或C++类）的内容 <br>quit 退出gdb <br>reverse-search 在源文件中反向搜索正规表达式 <br>run 执行该程序 <br>search 在源文件中搜索正规表达式 <br>set variable 给变量赋值 <br>signal 将一个信号发送到正在运行的进程 <br>step 执行下一个源程序行，必要时进入下一个函数 <br>undisplay display命令的反命令，不要显示表达式 <br>until 结束当前循环 <br>up 上移栈帧，使另一函数成为当前函数 <br>watch 在程序中设置一个监测点（即数据断点） <br>whatis 显示变量或函数类型 
<img src ="http://www.cppblog.com/liu1061/aggbug/53232.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-14 13:37 <a href="http://www.cppblog.com/liu1061/articles/53232.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ubuntu linux base comand</title><link>http://www.cppblog.com/liu1061/articles/52223.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Thu, 05 Jun 2008 02:14:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/52223.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/52223.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/52223.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/52223.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/52223.html</trackback:ping><description><![CDATA[<span style="FONT-SIZE: 10pt; FONT-FAMILY: courier new">NO&nbsp;&nbsp; 分类&nbsp;&nbsp; PS1&nbsp;&nbsp; 命令名&nbsp;&nbsp; 用法及参数&nbsp;&nbsp; 功能注解&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>1&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; ls&nbsp;&nbsp; ls -a&nbsp;&nbsp; 列出当前目录下的所有文件，包括以.头的隐含文件&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; ls&nbsp;&nbsp; ls -l或ll&nbsp;&nbsp; 列出当前目录下文件的详细信息&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; pwd&nbsp;&nbsp; pwd&nbsp;&nbsp; 查看当前所在目录的绝对路经&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; cd&nbsp;&nbsp; cd ..&nbsp;&nbsp; 回当前目录的上一级目录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; cd&nbsp;&nbsp; cd -&nbsp;&nbsp; 回上一次所在的目录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; cd&nbsp;&nbsp; cd ~ 或 cd&nbsp;&nbsp; 回当前用户的宿主目录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; cd&nbsp;&nbsp; cd ~用户名&nbsp;&nbsp; 回指定用户的宿主目录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>2&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; mkdir&nbsp;&nbsp; mkdir 目录名&nbsp;&nbsp; 创建一个目录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; mkdir&nbsp;&nbsp; mkdir &#8211;p&nbsp;&nbsp; 递归式去创建一些嵌套目录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; rmdir&nbsp;&nbsp; Rmdir 空目录名&nbsp;&nbsp; 删除一个空目录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>3&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; rm&nbsp;&nbsp; rm 文件名 文件名&nbsp;&nbsp; 删除一个文件或多个文件&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; rm&nbsp;&nbsp; rm -rf 非空目录名&nbsp;&nbsp; 递归删除一个非空目录下的一切，不让提式-f&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>4&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; cat&nbsp;&nbsp; cat文件名&nbsp;&nbsp; 一屏查看文件内容&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>5&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; more&nbsp;&nbsp; more文件名&nbsp;&nbsp; 分页查看文件内容&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>6&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; less&nbsp;&nbsp; less 文件名&nbsp;&nbsp; 可控分页查看文件内容&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>7&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; grep&nbsp;&nbsp; grep字符 文件名&nbsp;&nbsp; 根据字符匹配来查看文件部分内容&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>8&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; mv&nbsp;&nbsp; mv 路经/文件&nbsp; /经/文件&nbsp;&nbsp; 移动相对路经下的文件到绝对路经下&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; mv&nbsp;&nbsp; mv 文件名 新名称&nbsp;&nbsp; 在当前目录下改名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>9&nbsp; 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; cp&nbsp;&nbsp; cp /路经/文件&nbsp; ./&nbsp;&nbsp; 移动绝对路经下的文件到当前目录下&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>10 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; find&nbsp;&nbsp; find 路经 -name &#8220;字符串&#8221;&nbsp;&nbsp; 查找路经所在范围内满足字符串匹配的文件和目录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>11 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; ln&nbsp;&nbsp; ln 源文件 链接名&nbsp;&nbsp; 创建当前目录源文件的硬链接&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ln /home/test /usr/test1&nbsp;&nbsp; 在/usr下建立/home/test的硬链接&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>12 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; ln&nbsp;&nbsp; Ln -s a b&nbsp;&nbsp; 创建当前目录下a的符号链接b&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>13 文件管理&nbsp;&nbsp; #&nbsp;&nbsp; touch&nbsp;&nbsp; touch file1 file2&nbsp;&nbsp; 创建两个空文件&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>14 磁盘管理&nbsp;&nbsp; #&nbsp;&nbsp; df&nbsp;&nbsp; df&nbsp;&nbsp; 用于报告文件系统的总容量，使用量，剩余容量。&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>15 磁盘管理&nbsp;&nbsp; #&nbsp;&nbsp; du&nbsp;&nbsp; du -b /home&nbsp;&nbsp; 查看目前/HOME目录的容量(k)及子目录的容量(k)。&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>16 磁盘管理&nbsp;&nbsp; #&nbsp;&nbsp; fdisk&nbsp;&nbsp; fdisk -l&nbsp;&nbsp; 查看系统分区信息&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>17 磁盘管理&nbsp;&nbsp; #&nbsp;&nbsp; fdisk&nbsp;&nbsp; fdisk /dev/sdb&nbsp;&nbsp; 为一块新的SCSI硬盘进行分区&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>18 磁盘管理&nbsp;&nbsp; #&nbsp;&nbsp; mkfs.ext3&nbsp;&nbsp; Mkfs.ext3 /dev/sdb1 <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 为第一块SCSI硬盘的第一主分区格式化成ext3的文件系统&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mkfs.ext2&nbsp;&nbsp; Mkfs.ext2/dev/sdb2&nbsp;&nbsp;&nbsp; 格式化成ext2文件系统&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>19 磁盘管理&nbsp;&nbsp; #&nbsp;&nbsp; mount&nbsp;&nbsp; mount -t 文件系统类型 设备路经&nbsp; 访问路经&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp; 磁盘管理&nbsp;&nbsp; #&nbsp;&nbsp; 文件系统类型&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Iso9660&nbsp;&nbsp; 光驱文件系统&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vfat&nbsp;&nbsp; Fat文件系统(windows)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp; 挂载光驱&nbsp;&nbsp; #&nbsp;&nbsp; mount &#8211;t iso9660 /dev/cdrom /mnt/cdrom&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp; 挂载FAT&nbsp;&nbsp;&nbsp; #&nbsp;&nbsp; mount &#8211;t vfat /dev/hda5 /mnt/cdrom&nbsp;&nbsp;&nbsp; 挂第一个ide的第五个逻辑分区&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>17 磁盘管理&nbsp;&nbsp; #&nbsp;&nbsp; Umount /mnt/cdrom&nbsp;&nbsp;&nbsp;&nbsp; 卸载/mnt/cdrom为空&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>18 文件权限&nbsp;&nbsp; #&nbsp;&nbsp; chmod&nbsp;&nbsp; chmod u+s file&nbsp;&nbsp; 为file的属主加上特殊权限&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chmod g+r file&nbsp;&nbsp; 为file的属组加上读权限&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chmod o+w file&nbsp;&nbsp; 为file的其它用户加上写权限&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chmod a-x file&nbsp;&nbsp; 为file的所有用户减去执行权限&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; chmod 765 file&nbsp; 为file的属主设为完全权限，属组设成读写权，其它用户具有读和执心权限&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>19&nbsp;&nbsp; 文件权限&nbsp;&nbsp; #&nbsp;&nbsp; chown&nbsp;&nbsp; chown root /home&nbsp;&nbsp; 把/home的属主改成root用户&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>20&nbsp;&nbsp; 文件权限&nbsp;&nbsp; #&nbsp;&nbsp; chgrp&nbsp;&nbsp; chgrp root /home&nbsp;&nbsp; 把/home的属组改成root组&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>21&nbsp;&nbsp; 打印管理&nbsp;&nbsp; #&nbsp;&nbsp; redhat-config-printer-tui&nbsp;&nbsp; 进入安装打印机界面&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>22&nbsp;&nbsp; 打印管理&nbsp;&nbsp; #&nbsp;&nbsp; lp&nbsp;&nbsp; lp &#8211;d hptr file&nbsp;&nbsp; 打印file到hptr的打印机上&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>23&nbsp;&nbsp; 打印管理&nbsp;&nbsp; #&nbsp;&nbsp; lpq&nbsp;&nbsp; Lpq &#8211;P 打印机名&nbsp;&nbsp; 查看打印机的状态&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>24&nbsp;&nbsp; 打印管理&nbsp;&nbsp; #&nbsp;&nbsp; lprm&nbsp;&nbsp; Lprm &#8211;P 打印机名 a&nbsp;&nbsp; 删除打印机内的打印作业&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>25&nbsp;&nbsp; 打印管理&nbsp;&nbsp; #&nbsp;&nbsp; disable&nbsp;&nbsp; Disable &#8211;r &#8220;changing paper&#8221; HPtr&nbsp;&nbsp;&nbsp; 禁用打印机并提示原因&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>26&nbsp;&nbsp; 打印管理&nbsp;&nbsp; #&nbsp;&nbsp; enable&nbsp;&nbsp; Enable HPtr&nbsp;&nbsp; 重新启用被禁用的&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>27&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; useradd&nbsp;&nbsp; Useradd&nbsp;&nbsp; 创建一个新的用户&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>28&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; groupadd&nbsp;&nbsp; Groupadd 组名&nbsp;&nbsp; 创建一个新的组&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>29&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; passwd&nbsp;&nbsp; Passwd 用户名&nbsp;&nbsp; 为用户创建密码&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>30&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Passwd -d&nbsp;&nbsp; Passwd -d用户名&nbsp;&nbsp; 删除用户密码也能登陆&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>31&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Passwd -l&nbsp;&nbsp; Passwd -l用户名&nbsp;&nbsp; 锁定账号密码&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>32&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Passwd -u&nbsp;&nbsp; Passwd -u用户名&nbsp;&nbsp; 解锁账号密码&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>33&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Passwd -S&nbsp;&nbsp; Passwd -S用户名&nbsp;&nbsp; 查询账号密码&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>34&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Usermod -l&nbsp;&nbsp; Usermod -l 新用户名 老用户名&nbsp;&nbsp; 为用户改名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>35&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Usermod -L&nbsp;&nbsp; Usermod -L 要锁定用户名&nbsp;&nbsp; 锁定用户登陆&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>36&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Usermod -U&nbsp;&nbsp; Usermod &#8211;U解锁用户名&nbsp;&nbsp; 解锁用户登陆&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>37&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Usermod -u&nbsp;&nbsp; Usermod &#8211;u 501用户名&nbsp;&nbsp; 改变用户UID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>38&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Userdel&nbsp;&nbsp; Userdel&#8211;r 用户名&nbsp;&nbsp; 删除用户一切&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>39&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Groupmod -n&nbsp;&nbsp; Groupmod &#8211;n新用户名 老用户名&nbsp;&nbsp; 为组改名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>40&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Groupmod -g&nbsp;&nbsp; Groupmod &#8211;g 501 组名&nbsp;&nbsp; 改变组GID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>41&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; groupdel&nbsp;&nbsp; Groupdel组名&nbsp;&nbsp;&nbsp; 先应删它的用户&nbsp;&nbsp; 删除组&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>42&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; gpasswd -a&nbsp;&nbsp; gpasswd -a 用户名 组名&nbsp;&nbsp; 增加用户到组&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>43&nbsp;&nbsp; 用户管理&nbsp;&nbsp; #&nbsp;&nbsp; Id&nbsp;&nbsp;&nbsp; id&nbsp;&nbsp; 用户名&nbsp;&nbsp; 查用户信息&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>44&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm -qa&nbsp;&nbsp; rpm &#8211;qa | less&nbsp;&nbsp; 查询已安装RPM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>45&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm &#8211;qa | grep ftp&nbsp;&nbsp; 查询指定RPM&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>46&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm -q&nbsp;&nbsp; rpm -q 已安装的RPM包&nbsp;&nbsp; 查是否安装&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>47&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm -q telnet-server&nbsp;&nbsp; 查看telnet服务器包&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>48&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm -qi&nbsp;&nbsp; rpm &#8211;qi 软件包名称&nbsp;&nbsp; 查看软件的描述信息&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>49&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm -ql&nbsp;&nbsp; rpm &#8211;ql软件包名称&nbsp;&nbsp; 查询软件包的文件列表&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>50&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm -qf&nbsp;&nbsp; rpm &#8211;qf软件包名称&nbsp;&nbsp; 查询某个文件所属的软件包&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>51&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm -qp&nbsp;&nbsp; rpm &#8211;qp软件包全名&nbsp;&nbsp; 查询未安装的软件包信息&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>52&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm -e&nbsp;&nbsp; rpm &#8211;e 软件包名称&nbsp;&nbsp; 删除具体的软件包&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>53&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm -U&nbsp;&nbsp; rpm &#8211;Uvh软件包全名&nbsp;&nbsp; 升级软件包并显示过程&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>54&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm -ivh&nbsp;&nbsp; rpm &#8211;ivh 软件包全名&nbsp;&nbsp; 安装软件包并显示过程&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>55&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; rpm -V&nbsp;&nbsp; rpm &#8211;V软件包名称&nbsp;&nbsp; 验证软件包的大小，类型等&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>56&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; tar&nbsp;&nbsp;&nbsp; -c 创建包 &#8211;x 释放包&nbsp; -v 显示命令过程 &#8211;z 代表压缩包&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>57&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; tar -cf&nbsp;&nbsp; tar &#8211;cvf benet.tar /home/benet&nbsp;&nbsp; 把/home/benet目录打包&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>58&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; tar -czf&nbsp;&nbsp; tar &#8211;zcvf benet.tar.gz /mnt&nbsp;&nbsp; 把目录打包并压缩&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>59&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; tar &#8211;tf&nbsp;&nbsp; tar &#8211;tf benet.tar&nbsp;&nbsp; 看非压缩包的文件列表&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>60&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; tar &#8211;tzf&nbsp;&nbsp; tar &#8211;tf benet.tar.gz&nbsp;&nbsp; 看压缩包的文件列表&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>61&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; tar &#8211;xf&nbsp;&nbsp; tar &#8211;xf benet.tar&nbsp;&nbsp; 非压缩包的文件恢复&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>62&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; tar &#8211;zxvf&nbsp;&nbsp; tar &#8211;zxvf benet.tar.gz&nbsp;&nbsp; 压缩包的文件解压恢复&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>63&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; tar -jxvf&nbsp;&nbsp; tar &#8211;jxvf benet.tar.bz2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>64&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; diff&nbsp;&nbsp; diff file1 file2 &gt; 补丁名.patch&nbsp;&nbsp; 为新旧文件生成补丁文件&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>65&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; diff&nbsp;&nbsp; diff file1 file2&nbsp;&nbsp; 比较两个文件的区别&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>66&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; Patch&nbsp;&nbsp;&nbsp; Patch file补丁名.patch&nbsp;&nbsp; 打补丁&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>67&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; ./configure&nbsp; --prefix=/usr/local/&nbsp;&nbsp; 编译前配置&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>68&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; make&nbsp;&nbsp; 编译&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>69&nbsp;&nbsp; 软件管理&nbsp;&nbsp; #&nbsp;&nbsp; make install&nbsp;&nbsp; 安装编译好的源码包&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>70&nbsp;&nbsp; 启动管理&nbsp;&nbsp; #&nbsp;&nbsp; reboot&nbsp;&nbsp; Init 6&nbsp;&nbsp; 重启LINUX系统&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>71&nbsp;&nbsp; 启动管理&nbsp;&nbsp; #&nbsp;&nbsp; Halt&nbsp;&nbsp; Init 0&nbsp;&nbsp; Shutdown &#8211;h now&nbsp;&nbsp; 关闭LINUX系统&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>72&nbsp;&nbsp; 启动管理&nbsp;&nbsp; #&nbsp;&nbsp; runlevel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 显示系统运行级&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>73&nbsp;&nbsp; 启动管理&nbsp;&nbsp; #&nbsp;&nbsp; Init [0123456]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 改变系统运行级,7种&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>74&nbsp;&nbsp; 启动管理&nbsp;&nbsp; #&nbsp;&nbsp; Chkconfig &#8211;-list [服务名称]&nbsp;&nbsp; 查看服务的状态&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>75&nbsp;&nbsp; 启动管理&nbsp;&nbsp; #&nbsp;&nbsp; Chkconfig &#8211;-level &lt;运行级&gt; &lt;服务名&gt; on|off|set&nbsp;&nbsp;&nbsp; 设置服务的启动状态&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>76&nbsp;&nbsp; 启动管理&nbsp;&nbsp; #&nbsp;&nbsp; Chkconfig &lt;服务名&gt; on|off|set&nbsp;&nbsp; 设置非独立服务启状态&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>77&nbsp;&nbsp; 进程管理&nbsp;&nbsp; #&nbsp;&nbsp; Top动态&nbsp;&nbsp; Ps-aux静态&nbsp;&nbsp; 进程树pstree&nbsp;&nbsp;&nbsp; 查看系统进程&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>78&nbsp;&nbsp; 进程管理&nbsp;&nbsp; #&nbsp;&nbsp; 程序名 &amp;&nbsp;&nbsp; 后台运行程序&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>79&nbsp;&nbsp; 进程管理&nbsp;&nbsp; #&nbsp;&nbsp; fg&nbsp;&nbsp; 把后台运行的进程调回前台&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>80&nbsp;&nbsp; 进程管理&nbsp;&nbsp; #&nbsp;&nbsp; bg&nbsp;&nbsp; 把前台运行进程调到后台&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>81&nbsp;&nbsp; 进程管理&nbsp;&nbsp; #&nbsp;&nbsp; renice&nbsp;&nbsp; Renice +1 180&nbsp;&nbsp;&nbsp; 把180号进程的优先级加1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>82&nbsp;&nbsp; 进程管理&nbsp;&nbsp; #&nbsp;&nbsp; kill&nbsp;&nbsp; Kill PID&nbsp;&nbsp;&nbsp; 终止某个PID进程&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>83&nbsp;&nbsp; 进程管理&nbsp;&nbsp; #&nbsp;&nbsp; at&nbsp;&nbsp; at 5pm + 3 days <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /bin/ls&nbsp;&nbsp; 指定三天后下午5:00执行/bin/ls&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>84&nbsp;&nbsp; 进程管理&nbsp;&nbsp; #&nbsp;&nbsp; crontab&nbsp;&nbsp; Crontab -e&nbsp;&nbsp; 用VI的形式来编辑自动周期性任务&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>85&nbsp;&nbsp; 进程管理&nbsp;&nbsp; #&nbsp;&nbsp; crontab&nbsp;&nbsp; Crontab -l&nbsp;&nbsp; 查看自动周期性任务&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>86&nbsp;&nbsp; 进程管理&nbsp;&nbsp; #&nbsp;&nbsp; crontab&nbsp;&nbsp; Crontab -r&nbsp;&nbsp; 删除自动周期性任务&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>87&nbsp;&nbsp; 进程管理&nbsp;&nbsp; #&nbsp;&nbsp; crond&nbsp;&nbsp; Service crond &lt;start|stop|restart|status&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp; 马上启动自动周期性服务&nbsp;&nbsp; Service crond &lt;启动|停止|重启|状态&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp; 实现磁盘配额&nbsp;&nbsp; (注安装LINUX时建立/home分区） <br>目标：对用户zhao在/home目录上实现soft limit为5k,hard limit 为10k的磁盘配额 <br>实现步骤： <br>1. 修改包含/home的行，&nbsp; #vi /etc/fstab， 改为：defaults,usrquota。也就是增加usrquota项。然后保存退出。 <br>2、卸载/home目录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #umount /home <br>3. 挂接/home目录&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #mount /home <br>4、增加用户zhao&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #useradd zhao&nbsp; <br>5、修改密码&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #passwd zhao&nbsp; <br>6、生成关于/home目录的quota信息&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #quotacheck -cmug /home&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#quotacheck -vu /home&nbsp; <br>7、查看所有用户的信息&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #repquota -au <br>8、设置配额&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #edquota -u zhao <br>将soft 和hard 分别改为5和10 <br>9、保存并退出&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #wq!&nbsp; <br>10、修改时间&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #edquota -t&nbsp; <br>11、&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#wq! <br>12.开启/home上的磁盘配额功能&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#quotaon /home <br>13.查询配额&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #quota -u zhao <br>14.验证配额&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #su - zhao&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $touch myfile </span>
<img src ="http://www.cppblog.com/liu1061/aggbug/52223.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-05 10:14 <a href="http://www.cppblog.com/liu1061/articles/52223.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ubuntu一些基本操作用法!(转)</title><link>http://www.cppblog.com/liu1061/articles/52174.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Wed, 04 Jun 2008 08:44:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/52174.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/52174.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/52174.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/52174.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/52174.html</trackback:ping><description><![CDATA[<span class=mw-headline>如何列出硬盘分割表? </span>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>sudo fdisk -l
</pre>
<ul>
    <li>您可以使用 系统 -&gt; 管理 -&gt; Disks </li>
</ul>
<a name=.E5.A6.82.E4.BD.95.E5.88.97.E5.87.BA.E7.A1.AC.E7.A2.9F.E6.AA.94.E6.A1.88.E7.B3.BB.E7.B5.B1.E4.BD.BF.E7.94.A8.E7.8B.80.E6.B3.81.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何列出硬碟檔案系統使用狀況?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=107"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何列出硬盘档案系统使用状况? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>df -T -h
</pre>
<ul>
    <li>您可以使用 系统 -&gt; 管理 -&gt; Disks </li>
</ul>
<a name=.E5.A6.82.E4.BD.95.E5.88.97.E5.87.BA.E6.8E.9B.E8.BC.89.E7.9A.84.E8.A8.AD.E5.82.99.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何列出掛載的設備?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=108"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何列出挂载的设备? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>mount
</pre>
<a name=.E5.A6.82.E4.BD.95.E5.88.97.E5.87.BA_PCI_.E8.A8.AD.E5.82.99.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何列出 PCI 設備?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=109"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何列出 PCI 设备? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>lspci
</pre>
<a name=.E5.A6.82.E4.BD.95.E5.88.97.E5.87.BA_USB_.E8.A8.AD.E5.82.99.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何列出 USB 設備?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=110"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何列出 USB 设备? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>lsusb
</pre>
<a name=.E5.A6.82.E4.BD.95.E6.8F.90.E9.AB.98_CD.2FDVD-ROM_.E9.80.9F.E5.BA.A6.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何提高 CD/DVD-ROM 速度?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=111"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何提高 CD/DVD-ROM 速度? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设 CD/DVD-ROM设备 位置是 /dev/cdrom </em></dd></dl>
<pre class=_fck_mw_lspace>sudo hdparm -d1 /dev/cdrom
sudo cp /etc/hdparm.conf /etc/hdparm.conf_backup
sudo gedit /etc/hdparm.conf
</pre>
<ul>
    <li>档案后面增加此行叙述 </li>
</ul>
<pre class=_fck_mw_lspace>/dev/cdrom {
dma = on
}
</pre>
<ul>
    <li>储存编辑过的档案 </li>
</ul>
<a name=.E5.A6.82.E4.BD.95.E6.89.8B.E5.8B.95_.E6.8E.9B.E8.BC.89.2F.E5.8D.B8.E8.BC.89_CD.2FDVD-ROM_.2C_.E4.B8.A6.E4.B8.94.E9.A1.AF.E7.A4.BA.E6.89.80.E6.9C.89.E9.9A.B1.E8.97.8F.E4.BB.A5.E5.8F.8A.E9.97.9C.E8.81.AF.E7.9A.84_.E6.AA.94.E6.A1.88.2F.E8.B3.87.E6.96.99.E5.A4.BE.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何手動 掛載/卸載 CD/DVD-ROM , 並且顯示所有隱藏以及關聯的 檔案/資料夾?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=112"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何手动 挂载/卸载 CD/DVD-ROM , 并且显示所有隐藏以及关联的 档案/资料夹? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设 CD/DVD-ROM 位置是 /media/cdrom0/ </em></dd></dl>
<ul>
    <li>挂载 CD/DVD-ROM </li>
</ul>
<pre class=_fck_mw_lspace>sudo mount /media/cdrom0/ -o unhide
</pre>
<ul>
    <li>卸载 CD/DVD-ROM </li>
</ul>
<pre class=_fck_mw_lspace>sudo umount /media/cdrom0/
</pre>
<a name=.E5.A6.82.E4.BD.95.E6.89.8B.E5.8B.95.E5.BC.B7.E5.88.B6.E5.8D.B8.E8.BC.89_CD.2FDVD-ROM_.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何手動強制卸載 CD/DVD-ROM&nbsp;?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=113"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何手动强制卸载 CD/DVD-ROM&nbsp;? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设 CD/DVD-ROM 位置是 /media/cdrom0/ </em></dd></dl>
<pre class=_fck_mw_lspace>sudo umount /media/cdrom0/ -l
</pre>
<a name=.E5.A6.82.E4.BD.95.E4.B8.8D.E7.94.A8.E9.87.8D.E9.96.8B.E6.A9.9F.E4.B8.8B.E6.8E.9B.E8.BC.89_.2Fetc.2Ffstab_.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何不用重開機下掛載 /etc/fstab&nbsp;?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=114"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何不用重开机下挂载 /etc/fstab&nbsp;? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>sudo mount -a
</pre>
<a name=CD.2FDVD_.E7.87.92.E9.8C.84></a>
<h2><span class=editsection>[<a title="编辑段落: CD/DVD 燒錄" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=115"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>CD/DVD 烧录 </span></h2>
<a name=.E5.A6.82.E4.BD.95.E6.B8.85.E9.99.A4_CD-RW.2FDVD-RW.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何清除 CD-RW/DVD-RW?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=116"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何清除 CD-RW/DVD-RW? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设 CD/DVD-ROM 位置为 /dev/cdrom </em></dd></dl>
<pre class=_fck_mw_lspace>sudo umount /dev/cdrom
cdrecord dev=/dev/cdrom blank=fast
</pre>
<a name=.E5.A6.82.E4.BD.95.E7.87.92.E9.8C.84_.E6.AA.94.E6.A1.88.2F.E8.B3.87.E6.96.99.E5.A4.BE_.E8.87.B3_CD.2FDVD.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何燒錄 檔案/資料夾 至 CD/DVD?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=117"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何烧录 档案/资料夹 至 CD/DVD? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>nautilus burn:///
</pre>
<ul>
    <li>CD/DVD 光盘制作程序&nbsp;: 档案浏览器 </li>
</ul>
<ul>
    <li>拖曳 档案/资料夹 至窗口内 </li>
</ul>
<pre class=_fck_mw_lspace>档案选单 -&gt; 烧录光盘... -&gt; 烧录
</pre>
<a name=.E5.A6.82.E4.BD.95.E7.87.92.E9.8C.84.E5.BD.B1.E5.83.8F.E6.AA.94_.28ISO.29_.E8.87.B3_CD.2FDVD.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何燒錄影像檔 (ISO) 至 CD/DVD?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=118"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何烧录影像档 (ISO) 至 CD/DVD? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>点选影像档(ISO)右键 -&gt; 烧录光盘... -&gt; 烧录
</pre>
<a name=.E5.A6.82.E4.BD.95.E8.A4.87.E8.A3.BD_CD.2FDVD.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何複製 CD/DVD?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=119"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何复制 CD/DVD? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E5.BE.9E_CD.2FDVD_.E5.BB.BA.E7.AB.8B.E5.BD.B1.E5.83.8F.E6.AA.94_.28ISO.29.3F"><u><font color=#800080>#如何从 CD/DVD 建立影像档 (ISO)?</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E7.87.92.E9.8C.84.E5.BD.B1.E5.83.8F.E6.AA.94_.28ISO.29_.E8.87.B3_CD.2FDVD.3F"><u><font color=#800080>#如何烧录影像档 (ISO) 至 CD/DVD?</font></u></a> </li>
</ul>
<a name=.E5.A6.82.E4.BD.95.E5.BE.9E_CD.2FDVD_.E5.BB.BA.E7.AB.8B.E5.BD.B1.E5.83.8F.E6.AA.94_.28ISO.29.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何從 CD/DVD 建立影像檔 (ISO)?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=120"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何从 CD/DVD 建立影像档 (ISO)? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设 CD/DVD-ROM 位置为 /dev/cdrom</em> </dd></dl>
<pre class=_fck_mw_lspace>sudo umount /dev/cdrom
dd if=/dev/cdrom of=file.iso bs=1024
</pre>
<a name=.E5.A6.82.E4.BD.95.E5.B0.87.E8.B3.87.E6.96.99.E5.A4.BE.E8.B3.87.E6.96.99.E5.BB.BA.E7.AB.8B.E6.88.90.E5.BD.B1.E5.83.8F.E6.AA.94.28ISO.29.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何將資料夾資料建立成影像檔(ISO)?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=121"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何将资料夹资料建立成影像档(ISO)? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>mkisofs -o file.iso /location_of_folder/
</pre>
<a name=.E5.A6.82.E4.BD.95.E7.94.A2.E7.94.9F_MD5_.E6.AA.A2.E6.9F.A5.E7.A2.BC.E6.AA.94.E6.A1.88.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何產生 MD5 檢查碼檔案?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=122"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何产生 MD5 检查码档案? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>md5sum file.iso &gt; file.iso.md5
</pre>
<a name=.E5.A6.82.E4.BD.95.E6.AA.A2.E6.9F.A5.E6.AA.94.E6.A1.88.E7.9A.84_MD5_.E7.A2.BC.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何檢查檔案的 MD5 碼?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=123"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何检查档案的 MD5 码? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设 file.iso 以及 file.iso.md5 位于相同的目录</em> </dd></dl>
<pre class=_fck_mw_lspace>md5sum -c file.iso.md5
</pre>
<a name=.E5.A6.82.E4.BD.95.E4.B8.8D.E9.80.8F.E9.81.8E.E7.87.92.E9.8C.84.E8.80.8C_.E6.8E.9B.E8.BC.89.2F.E5.8D.B8.E8.BC.89_.E5.BD.B1.E5.83.8F.E6.AA.94_.28ISO.29_.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何不透過燒錄而 掛載/卸載 影像檔 (ISO)&nbsp;?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=124"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何不透过烧录而 挂载/卸载 影像档 (ISO)&nbsp;? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>挂载影像档 (ISO) </li>
</ul>
<pre class=_fck_mw_lspace>sudo mkdir /media/iso
sudo modprobe loop
sudo mount file.iso /media/iso/ -t iso9660 -o loop
</pre>
<ul>
    <li>卸载影像档 (ISO) </li>
</ul>
<pre class=_fck_mw_lspace>sudo umount /media/iso/
</pre>
<a name=.E5.A6.82.E4.BD.95_.E8.A8.AD.E5.AE.9A.2F.E6.94.B9.E8.AE.8A_CD.2FDVD_.E7.87.92.E9.8C.84.E9.80.9F.E5.BA.A6.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何 設定/改變 CD/DVD 燒錄速度?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=125"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何 设定/改变 CD/DVD 烧录速度? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>应用程序 -&gt; 系统工具 -&gt; 组态编辑器
    <li>组态编辑器 </li>
</ul>
<pre class=_fck_mw_lspace>/ -&gt; apps -&gt; nautilus-cd-burner -&gt; default_speed (设定/改变 烧录速度)
</pre>
<a name=.E5.A6.82.E4.BD.95.E5.95.9F.E5.8B.95_CD.2FDVD_.E7.87.92.E9.8C.84_burnproof.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何啟動 CD/DVD 燒錄 burnproof?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=126"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何启动 CD/DVD 烧录 burnproof? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>应用程序 -&gt; 系统工具 -&gt; 组态编辑器
    <li>组态编辑器 </li>
</ul>
<pre class=_fck_mw_lspace>/ -&gt; apps -&gt; nautilus-cd-burner -&gt; burnproof (<strong>勾选</strong>)
</pre>
<a name=.E5.A6.82.E4.BD.95.E5.95.9F.E5.8B.95_CD.2FDVD_.E8.B6.85.E7.87.92.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何啟動 CD/DVD 超燒?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=127"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何启动 CD/DVD 超烧? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>应用程序 -&gt; 系统工具 -&gt; 组态编辑器
    <li>组态编辑器 </li>
</ul>
<pre class=_fck_mw_lspace>/ -&gt; apps -&gt; nautilus-cd-burner -&gt; overburn (<strong>勾选</strong>)
</pre>
<a name=.E7.B6.B2.E8.B7.AF></a>
<h2><span class=editsection>[<a title="编辑段落: 網路" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=128"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>网络 </span></h2>
<a name=.E5.A6.82.E4.BD.95.E8.A8.AD.E5.AE.9A_Google_Talk.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何設定 Google Talk?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=129"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何设定 Google Talk? </span></h4>
<ul>
    <li>请在 <a class="external text" title=http://www.google.com/support/talk/bin/answer.py?answer=24073 href="http://www.google.com/support/talk/bin/answer.py?answer=24073" rel=nofollow><u><font color=#0000ff>Google Talk Help Center</font></u></a> 寻找答案 </li>
</ul>
<a name=.E5.A6.82.E4.BD.95_.E5.95.9F.E5.8B.95.2F.E9.97.9C.E9.96.89_.E7.B6.B2.E8.B7.AF.E9.80.A3.E7.B7.9A.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何 啟動/關閉 網路連線?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=130"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何 启动/关闭 网络连线? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>系统 -&gt; 管理 -&gt; 网络
    <li>网络连线 </li>
</ul>
<pre class=_fck_mw_lspace>连线 -&gt; 选择 "以太网连线" -&gt; 启动/停止使用
</pre>
<a name=.E5.A6.82.E4.BD.95.E8.A8.AD.E5.AE.9A.E7.B6.B2.E8.B7.AF.E9.80.A3.E7.B7.9A.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何設定網路連線?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=131"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何设定网络连线? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>系统 -&gt; 管理 -&gt; 网络
    <li>网络连线 </li>
</ul>
<pre class=_fck_mw_lspace>连线 -&gt; 选择 "以太网连线" -&gt; <strong>属性</strong>
连线 -&gt; 启动这个连线 (<strong>勾选</strong>)
连线设定 -&gt; 组态: 选择 "DHCP/固定 IP 位址"
</pre>
<pre class=_fck_mw_lspace>DNS -&gt; DNS 服务器 -&gt; 新增/删除
</pre>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95_.E5.95.9F.E5.8B.95.2F.E9.97.9C.E9.96.89_.E7.B6.B2.E8.B7.AF.E9.80.A3.E7.B7.9A.3F"><u><font color=#800080>#如何 启动/关闭 网络连线?</font></u></a> </li>
</ul>
<a name=.E5.A6.82.E4.BD.95.E8.A8.AD.E5.AE.9A.E6.92.A5.E8.99.9F.E9.80.A3.E7.B7.9A.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何設定撥號連線?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=132"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何设定拨号连线? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>设定拨号连线 </li>
</ul>
<pre class=_fck_mw_lspace>sudo pppconfig
</pre>
<ul>
    <li>开始连线 </li>
</ul>
<pre class=_fck_mw_lspace>sudo pon provider_name
</pre>
<ul>
    <li>结束连线 </li>
</ul>
<pre class=_fck_mw_lspace>sudo poff
</pre>
<a name=.E5.A6.82.E4.BD.95.E8.A8.AD.E5.AE.9A.E5.AF.AC.E9.A0.BB.E9.80.A3.E7.B7.9A.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何設定寬頻連線?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=133"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何设定宽带连线? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>sudo pppoeconf
</pre>
<a name=.E5.A6.82.E4.BD.95.E4.BF.AE.E6.94.B9.E4.B8.BB.E6.A9.9F.E5.90.8D.E7.A8.B1.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何修改主機名稱?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=134"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何修改主机名称? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>系统 -&gt; 管理 -&gt; 网络
    <li>网络设定 </li>
</ul>
<pre class=_fck_mw_lspace>一般 -&gt; 主机设定 -&gt; 主机名称: 指定计算机名称
</pre>
<ul>
    <li>储存并且关闭所有已开启的应用程序，并重开机。 </li>
</ul>
<a name=.E5.A6.82.E4.BD.95.E4.BF.AE.E6.94.B9.E4.B8.BB.E6.A9.9F.E6.95.98.E8.BF.B0.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何修改主機敘述?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=135"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何修改主机叙述? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E5.AE.89.E8.A3.9D_Samba_.E4.BC.BA.E6.9C.8D.E5.99.A8.E6.8F.90.E4.BE.9B.E5.88.86.E4.BA.AB_.E6.AA.94.E6.A1.88.2F.E8.B3.87.E6.96.99.E5.A4.BE_.E6.9C.8D.E5.8B.99.3F"><u><font color=#800080>#如何安装 Samba 服务器提供分享 档案/资料夹 服务?</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
sudo gedit /etc/samba/smb.conf
</pre>
<ul>
    <li>找此行 </li>
</ul>
<pre class=_fck_mw_lspace>...
server string = %h server (Samba, Ubuntu)
...
</pre>
<ul>
    <li>将以下叙述取代此行 </li>
</ul>
<pre class=_fck_mw_lspace>  server string = new_computer_descriptions
</pre>
<ul>
    <li>储存编辑过的档案 </li>
</ul>
<pre class=_fck_mw_lspace>sudo testparm
sudo /etc/init.d/samba restart
</pre>
<a name=.E5.A6.82.E4.BD.95.E6.94.B9.E8.AE.8A.E4.B8.BB.E6.A9.9F.E7.B6.B2.E5.9F.9F.2F.E5.B7.A5.E4.BD.9C.E7.BE.A4.E7.B5.84.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何改變主機網域/工作群組?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=136"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何改变主机网域/工作群组? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E5.AE.89.E8.A3.9D_Samba_.E4.BC.BA.E6.9C.8D.E5.99.A8.E6.8F.90.E4.BE.9B.E5.88.86.E4.BA.AB_.E6.AA.94.E6.A1.88.2F.E8.B3.87.E6.96.99.E5.A4.BE_.E6.9C.8D.E5.8B.99.3F"><u><font color=#800080>#如何安装 Samba 服务器提供分享 档案/资料夹 服务?</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>sudo cp /etc/samba/smb.conf /etc/samba/smb.conf_backup
sudo gedit /etc/samba/smb.conf
</pre>
<ul>
    <li>找此行 </li>
</ul>
<pre class=_fck_mw_lspace>...
workgroup = MSHOME
...
</pre>
<ul>
    <li>将以下叙述取代 </li>
</ul>
<pre class=_fck_mw_lspace>  workgroup = new_domain_or_workgroup
</pre>
<ul>
    <li>储存编辑过的档案 </li>
</ul>
<pre class=_fck_mw_lspace>sudo testparm
sudo /etc/init.d/samba restart
</pre>
<a name=.E5.A6.82.E4.BD.95.E7.94.A8.E5.85.8D.E8.B2.BB_DynDNS_.E6.9C.8D.E5.8B.99.E6.8C.87.E5.AE.9A.E4.BD.BF.E7.94.A8.E5.8B.95.E6.85.8BIP.E6.9C.AC.E6.A9.9F.E7.9A.84.E5.90.8D.E7.A8.B1.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何用免費 DynDNS 服務指定使用動態IP本機的名稱?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=137"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何用免费 DynDNS 服务指定使用动态IP本机的名称? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E6.96.B0.E5.A2.9E.E5.85.B6.E4.BB.96.E7.9A.84.E5.A5.97.E4.BB.B6.E5.BA.AB_.28extra_Repositories.29.3F"><u><font color=#800080>#如何新增其他的套件库 (extra Repositories)?</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设因特网连线组态已经完成<br></em>
<dd><em>注册免费动态 DNS 服务 <a class="external free" title=https://www.dyndns.org href="https://www.dyndns.org/" rel=nofollow><u><font color=#0000ff>https://www.dyndns.org</font></u></a><br></em>
<dd><em>每一小时自动更新 IP 至 DynDNS Database/DNS <br></em>
<dd><em>* * * * * 代表 分 时 日 月 星期</em> </dd></dl>
<pre class=_fck_mw_lspace>sudo apt-get install ipcheck
sudo gedit /root/dyndns_update.sh
</pre>
<ul>
    <li>在新增的档案内加入下面这几行 </li>
</ul>
<pre class=_fck_mw_lspace>USERNAME=myusername
PASSWORD=mypassword
HOSTNAME=myhostname.dyndns.org
</pre>
<pre class=_fck_mw_lspace>cd /root/
if [ -f /root/ipcheck.dat ]; then
ipcheck -r checkip.dyndns.org:8245 $USERNAME $PASSWORD $HOSTNAME
else
ipcheck --makedat -r checkip.dyndns.org:8245 $USERNAME $PASSWORD $HOSTNAME
fi
</pre>
<ul>
    <li>储存编辑过的档案 </li>
</ul>
<pre class=_fck_mw_lspace>sudo chmod 700 /root/dyndns_update.sh
sudo sh /root/dyndns_update.sh
export EDITOR=gedit &amp;&amp; sudo crontab -e
</pre>
<ul>
    <li>在档案后面加入下面这几行 </li>
</ul>
<pre class=_fck_mw_lspace>00 * * * * sudo sh /root/dyndns_update.sh
</pre>
<ul>
    <li>储存编辑过的档案 </li>
</ul>
<a name=.E5.A6.82.E4.BD.95.E7.B0.A1.E5.96.AE.E5.88.86.E4.BA.AB.E8.B3.87.E6.96.99.E5.A4.BE.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何簡單分享資料夾?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=138"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何简单分享资料夹? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E5.AE.89.E8.A3.9D_Samba_.E4.BC.BA.E6.9C.8D.E5.99.A8.E6.8F.90.E4.BE.9B.E5.88.86.E4.BA.AB_.E6.AA.94.E6.A1.88.2F.E8.B3.87.E6.96.99.E5.A4.BE_.E6.9C.8D.E5.8B.99.3F"><u><font color=#800080>#如何安装 Samba 服务器提供分享 档案/资料夹 服务?</font></u></a> </li>
</ul>
<pre class=_fck_mw_lspace>资料夹上按右键 -&gt; 共享资料夹
</pre>
<pre class=_fck_mw_lspace>共享资料夹 -&gt; 共享为: 选择 "SMB"
共享内容 -&gt; 名称: 指定共享名称
</pre>
<a name=.E5.A6.82.E4.BD.95.E7.80.8F.E8.A6.BD.E7.B6.B2.E8.B7.AF.E4.B8.8A.E9.9B.BB.E8.85.A6.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何瀏覽網路上電腦?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=139"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何浏览网络上计算机? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设局域网路已经设定好了</em>
<dd><em>如果计算机或者网络资料夹无法找到，试着接存取他们。</em>
<dd><em>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E4.B8.8D.E5.85.88.E6.8E.9B.E8.BC.89.E5.B0.B1.E8.AE.80.E5.8F.96.E7.B6.B2.E8.B7.AF.E5.88.86.E4.BA.AB.E6.AA.94.E6.A1.88.E5.A4.BE.3F"><u><font color=#800080>#如何不先挂载就读取网络分享档案夹?</font></u></a></em> </dd></dl>
<ul>
    <li>位置 -&gt; 网络服务器 </li>
</ul>
<a name=.E5.A6.82.E4.BD.95.E4.B8.8D.E5.85.88.E6.8E.9B.E8.BC.89.E5.B0.B1.E8.AE.80.E5.8F.96.E7.B6.B2.E8.B7.AF.E5.88.86.E4.BA.AB.E6.AA.94.E6.A1.88.E5.A4.BE.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何不先掛載就讀取網路分享檔案夾?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=140"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何不先挂载就读取网络分享档案夹? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<dl>
<dd><em>例如：假设你已正确设定好网络连线</em>
<dd><em>网络上分享出资料夹的计算机IP位址是: 192.168.0.1</em>
<dd><em>分享出来的资料夹名称是: linux</em> </dd></dl>
<ul>
    <li>应用程序 -&gt; 执行命令...
    <li>输入并执行以下指令 </li>
</ul>
<pre class=_fck_mw_lspace>smb://192.168.0.1/linux
</pre>
<a name=.E5.A6.82.E4.BD.95.E6.89.8B.E5.8B.95_.E6.8E.9B.E8.BC.89.2F.E5.8D.B8.E8.BC.89_.E7.B6.B2.E8.B7.AF.E5.88.86.E4.BA.AB.E7.9A.84.E8.B3.87.E6.96.99.E5.A4.BE.EF.BC.8C.E4.B8.A6.E4.BA.88.E8.A8.B1.E6.89.80.E6.9C.89.E4.BD.BF.E7.94.A8.E8.80.85.E8.AE.80.E5.8F.96.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何手動 掛載/卸載 網路分享的資料夾，並予許所有使用者讀取?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=141"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何手动 挂载/卸载 网络分享的资料夹，并予许所有使用者读取? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E5.AE.89.E8.A3.9D_Samba_.E4.BC.BA.E6.9C.8D.E5.99.A8.E6.8F.90.E4.BE.9B.E5.88.86.E4.BA.AB_.E6.AA.94.E6.A1.88.2F.E8.B3.87.E6.96.99.E5.A4.BE_.E6.9C.8D.E5.8B.99.3F"><u><font color=#800080>#如何安装 Samba 服务器提供分享 档案/资料夹 服务?</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设网络连线已经设定完成</em>
<dd><em>网络计算机 IP: 192.168.0.1</em>
<dd><em>网络计算机帐号: myusername</em>
<dd><em>网络计算机密码: mypassword</em>
<dd><em>分享资料夹名称: linux</em>
<dd><em>本机挂载资料夹: /media/sharename</em> </dd></dl>
<ul>
    <li>挂载网络资料夹 </li>
</ul>
<pre class=_fck_mw_lspace>sudo mkdir /media/sharename
sudo mount //192.168.0.1/linux /media/sharename/ -o username=myusername,password=mypassword
</pre>
<ul>
    <li>卸载网络资料夹 </li>
</ul>
<pre class=_fck_mw_lspace>sudo umount /media/sharename/
</pre>
<a name=.E5.A6.82.E4.BD.95.E6.89.8B.E5.8B.95.E6.8E.9B.E8.BC.89.2F.E5.8D.B8.E9.99.A4.E7.B6.B2.E8.B7.AF.E5.85.B1.E4.BA.AB.E6.AA.94.E6.A1.88.E5.A4.BE.2C_.E4.B8.A6.E5.85.81.E8.A8.B1.E6.89.80.E6.9C.89.E4.BD.BF.E7.94.A8.E8.80.85.E9.83.BD.E5.8F.AF.E8.AE.80.E5.8F.96.E5.92.8C.E5.AF.AB.E5.85.A5.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何手動掛載/卸除網路共享檔案夾, 並允許所有使用者都可讀取和寫入?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=142"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何手动挂载/卸除网络共享档案夹, 并允许所有使用者都可读取和写入? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E5.AE.89.E8.A3.9D_Samba_.E4.BC.BA.E6.9C.8D.E5.99.A8.E6.8F.90.E4.BE.9B.E5.88.86.E4.BA.AB_.E6.AA.94.E6.A1.88.2F.E8.B3.87.E6.96.99.E5.A4.BE_.E6.9C.8D.E5.8B.99.3F"><u><font color=#800080>#如何安装 Samba 服务器提供分享 档案/资料夹 服务?</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设网络连线已经设定完成</em>
<dd><em>网络计算机 IP: 192.168.0.1</em>
<dd><em>网络计算机帐号: myusername</em>
<dd><em>网络计算机密码: mypassword</em>
<dd><em>分享资料夹名称: linux</em>
<dd><em>本机挂载资料夹: /media/sharename</em> </dd></dl>
<ul>
    <li>挂载网络资料夹 </li>
</ul>
<pre class=_fck_mw_lspace>sudo mkdir /media/sharename
sudo mount //192.168.0.1/linux /media/sharename/ -o username=myusername,password=mypassword,dmask=777,fmask=777
</pre>
<ul>
    <li>卸载网络资料夹 </li>
</ul>
<pre class=_fck_mw_lspace>sudo umount /media/sharename/
</pre>
<a name=.E5.A6.82.E4.BD.95.E5.9C.A8.E7.B3.BB.E7.B5.B1.E5.95.9F.E5.8B.95.E6.99.82.2C_.E8.87.AA.E5.8B.95.E6.8E.9B.E8.BC.89.E7.B6.B2.E8.B7.AF.E5.88.86.E4.BA.AB.E6.AA.94.E6.A1.88.E5.A4.BE.2C_.E4.B8.A6.E5.85.81.E8.A8.B1.E6.89.80.E6.9C.89.E4.BD.BF.E7.94.A8.E8.80.85.E9.83.BD.E5.8F.AF.E8.AE.80.E5.8F.96_.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何在系統啟動時, 自動掛載網路分享檔案夾, 並允許所有使用者都可讀取&nbsp;?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=143"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何在系统启动时, 自动挂载网络分享档案夹, 并允许所有使用者都可读取&nbsp;? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E5.AE.89.E8.A3.9D_Samba_.E4.BC.BA.E6.9C.8D.E5.99.A8.E6.8F.90.E4.BE.9B.E5.88.86.E4.BA.AB_.E6.AA.94.E6.A1.88.2F.E8.B3.87.E6.96.99.E5.A4.BE_.E6.9C.8D.E5.8B.99.3F"><u><font color=#800080>#如何安装 Samba 服务器提供分享 档案/资料夹 服务?</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设网络连线已经设定完成</em>
<dd><em>网络计算机 IP: 192.168.0.1</em>
<dd><em>网络计算机帐号: myusername</em>
<dd><em>网络计算机密码: mypassword</em>
<dd><em>分享资料夹名称: linux</em>
<dd><em>本机挂载资料夹: /media/sharename</em> </dd></dl>
<pre class=_fck_mw_lspace>sudo mkdir /media/sharename
sudo gedit /root/.smbcredentials
</pre>
<ul>
    <li>在新增的档案内加入下面这几行 </li>
</ul>
<pre class=_fck_mw_lspace>username=myusername
password=mypassword
</pre>
<ul>
    <li>储存编辑过的档案 </li>
</ul>
<pre class=_fck_mw_lspace>sudo chmod 700 /root/.smbcredentials
sudo cp /etc/fstab /etc/fstab_backup
sudo gedit /etc/fstab
</pre>
<ul>
    <li>在档案后面加入下面这几行 </li>
</ul>
<pre class=_fck_mw_lspace>//192.168.0.1/linux    /media/sharename smbfs  credentials=/root/.smbcredentials    0    0
</pre>
<ul>
    <li>储存编辑过的档案
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E4.B8.8D.E7.94.A8.E9.87.8D.E9.96.8B.E6.A9.9F.E4.B8.8B.E6.8E.9B.E8.BC.89_.2Fetc.2Ffstab_.3F"><u><font color=#800080>#如何不用重开机下挂载 /etc/fstab ?</font></u></a> </li>
</ul>
<a name=.E5.A6.82.E4.BD.95.E5.9C.A8.E7.B3.BB.E7.B5.B1.E5.95.9F.E5.8B.95.E6.99.82.2C_.E8.87.AA.E5.8B.95.E6.8E.9B.E8.BC.89.E7.B6.B2.E8.B7.AF.E5.88.86.E4.BA.AB.E6.AA.94.E6.A1.88.E5.A4.BE.2C_.E4.B8.A6.E5.85.81.E8.A8.B1.E6.89.80.E6.9C.89.E4.BD.BF.E7.94.A8.E8.80.85.E9.83.BD.E5.8F.AF.E8.AE.80.E5.8F.96_.3F_2></a>
<h4><span class=editsection>[<a title="编辑段落: 如何在系統啟動時, 自動掛載網路分享檔案夾, 並允許所有使用者都可讀取&nbsp;?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=144"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何在系统启动时, 自动挂载网络分享档案夹, 并允许所有使用者都可读取&nbsp;? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E5.AE.89.E8.A3.9D_Samba_.E4.BC.BA.E6.9C.8D.E5.99.A8.E6.8F.90.E4.BE.9B.E5.88.86.E4.BA.AB_.E6.AA.94.E6.A1.88.2F.E8.B3.87.E6.96.99.E5.A4.BE_.E6.9C.8D.E5.8B.99.3F"><u><font color=#800080>#如何安装 Samba 服务器提供分享 档案/资料夹 服务?</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设网络连线已经设定完成</em>
<dd><em>网络计算机 IP: 192.168.0.1</em>
<dd><em>网络计算机帐号: myusername</em>
<dd><em>网络计算机密码: mypassword</em>
<dd><em>分享资料夹名称: linux</em>
<dd><em>本机挂载资料夹: /media/sharename</em> </dd></dl>
<pre class=_fck_mw_lspace>sudo mkdir /media/sharename
sudo gedit /root/.smbcredentials
</pre>
<ul>
    <li>在新增的档案内加入下面这几行 </li>
</ul>
<pre class=_fck_mw_lspace>username=myusername
password=mypassword
</pre>
<ul>
    <li>储存编辑过的档案 </li>
</ul>
<pre class=_fck_mw_lspace>sudo chmod 700 /root/.smbcredentials
sudo cp /etc/fstab /etc/fstab_backup
sudo gedit /etc/fstab
</pre>
<ul>
    <li>在档案后面加入下面这几行 </li>
</ul>
<pre class=_fck_mw_lspace>//192.168.0.1/linux    /media/sharename smbfs  credentials=/root/.smbcredentials,dmask=777,fmask=777  0    0
</pre>
<ul>
    <li>储存编辑过的档案
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E4.B8.8D.E7.94.A8.E9.87.8D.E9.96.8B.E6.A9.9F.E4.B8.8B.E6.8E.9B.E8.BC.89_.2Fetc.2Ffstab_.3F"><u><font color=#800080>#如何不用重开机下挂载 /etc/fstab ?</font></u></a> </li>
</ul>
<a name=.E5.A6.82.E4.BD.95.E5.8F.96.E5.BE.97.E7.84.A1.E7.B7.9A.E7.B6.B2.E8.B7.AF.E6.A8.A1.E7.B5.84.28ipw2200.29.E4.B8.A6.E4.B8.94.E4.BD.BF.E7.94.A8.E7.84.A1.E7.B7.9A.E8.B3.87.E6.96.99.E5.82.B3.E8.BC.B8.E5.8D.94.E5.AE.9A.28WAP.29.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何取得無線網路模組(ipw2200)並且使用無線資料傳輸協定(WAP)?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=145"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何取得无线网络模组(ipw2200)并且使用无线资料传输协定(WAP)? </span></h4>
<ul>
    <li>参考 <a class="external text" title=http://www.ubuntuforums.org/showpost.php?p=130227p=423584 href="http://www.ubuntuforums.org/showpost.php?p=130227p=423584" rel=nofollow><u><font color=#0000ff>Ubuntuforuns.org how-tos</font></u></a> </li>
</ul>
<a name=.E9.81.A0.E7.AB.AF.E6.A1.8C.E9.9D.A2></a>
<h2><span class=editsection>[<a title="编辑段落: 遠端桌面" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=146"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>远端桌面 </span></h2>
<a name=.E5.A6.82.E4.BD.95.E8.A8.AD.E5.AE.9A.E9.81.A0.E7.AB.AF.E6.A1.8C.E9.9D.A2_.28.E6.B2.92.E6.9C.89.E5.AE.89.E5.85.A8.E6.80.A7.29.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何設定遠端桌面 (沒有安全性)?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=147"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何设定远端桌面 (没有安全性)? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<dl>
<dd><em>警告! 远端桌面只在 GNOME 登入 session 运作</em>
<dd><em>离开计算机而未注意 GNOME 登入 session 是不安全</em>
<dd><em>使用 (系统 -&gt; 锁定划面) 并且离开计算机时关掉萤幕</em> </dd></dl>
<ul>
    <li>系统 -&gt; 偏好管理 -&gt; 远端桌面
    <li>远端桌面偏好设定 </li>
</ul>
<pre class=_fck_mw_lspace>共享 -&gt;
允许其他使用者观看您的桌面 (<strong>勾选</strong>)
允许其他使用者控制您的桌面 (<strong>勾选</strong>)
</pre>
<pre class=_fck_mw_lspace>安全性 -&gt;
询问您已确认 (不勾选)
使用者需要输入密码: (<strong>勾选</strong>)
密码: 指定密码
</pre>
<a name=.E5.A6.82.E4.BD.95.E9.80.A3.E7.B5.90.E9.81.A0.E7.AB.AF_Ubuntu_.E6.A1.8C.E9.9D.A2.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何連結遠端 Ubuntu 桌面?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=148"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何连结远端 Ubuntu 桌面? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. Assumed that remote Ubuntu machine have configured Remote Desktop</em>
<dd><em>Read <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E8.A8.AD.E5.AE.9A.E9.81.A0.E7.AB.AF.E6.A1.8C.E9.9D.A2_.28.E6.B2.92.E6.9C.89.E5.AE.89.E5.85.A8.E6.80.A7.29.3F"><u><font color=#800080>#如何设定远端桌面 (没有安全性)?</font></u></a></em>
<dd><em>Remote Ubuntu machine: 192.168.0.1</em> </dd></dl>
<pre class=_fck_mw_lspace>vncviewer -fullscreen 192.168.0.1:0
</pre>
<ul>
    <li>To quit vncviewer </li>
</ul>
<pre class=_fck_mw_lspace>Press 'F8' -&gt; Quit viewer
</pre>
<a name=.E5.A6.82.E4.BD.95.E5.BE.9E_Windows_.E6.A9.9F.E5.99.A8.E4.B8.8A.E9.80.A3.E7.B5.90.E9.81.A0.E7.AB.AF_Ubuntu_.E6.A1.8C.E9.9D.A2.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何從 Windows 機器上連結遠端 Ubuntu 桌面?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=149"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何从 Windows 机器上连结远端 Ubuntu 桌面? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. Assumed that remote Ubuntu machine have configured Remote Desktop</em>
<dd><em>Read <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E8.A8.AD.E5.AE.9A.E9.81.A0.E7.AB.AF.E6.A1.8C.E9.9D.A2_.28.E6.B2.92.E6.9C.89.E5.AE.89.E5.85.A8.E6.80.A7.29.3F"><u><font color=#800080>#如何设定远端桌面 (没有安全性)?</font></u></a></em>
<dd><em>Remote Ubuntu machine: 192.168.0.1</em> </dd></dl>
<ul>
    <li>Download VNC Viewer: <a class="external text" title=http://fresh.t-systems-sfr.com/cgi-bin/warex?linux/src/vnc-4_1_1-x86_win32_viewer.zip:a/vnc-4_1_1-x86_win32_viewer.exe href="http://fresh.t-systems-sfr.com/cgi-bin/warex?linux/src/vnc-4_1_1-x86_win32_viewer.zip:a/vnc-4_1_1-x86_win32_viewer.exe" rel=nofollow><u><font color=#0000ff>Here</font></u></a> </li>
</ul>
<a name=Windows></a>
<h2><span class=editsection>[<a title="编辑段落: Windows" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=150"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>Windows </span></h2>
<a name=.E5.A6.82.E4.BD.95.E6.89.8B.E5.8B.95_.E6.8E.9B.E8.BC.89.2F.E5.8D.B8.E8.BC.89_Windows_.E5.88.86.E5.89.B2.E5.8D.80_.28NTFS.29_.2C_.E4.B8.A6.E4.B8.94.E5.85.81.E8.A8.B1.E6.89.80.E6.9C.89.E4.BD.BF.E7.94.A8.E8.80.85.E5.8F.AA.E8.83.BD.E8.AE.80.E5.8F.96.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何手動 掛載/卸載 Windows 分割區 (NTFS) , 並且允許所有使用者只能讀取?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=151"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何手动 挂载/卸载 Windows 分割区 (NTFS) , 并且允许所有使用者只能读取? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#How_to_list_partition_tables.3F"><u><font color=#800080>#How to list partition tables?</font></u></a> </li>
</ul>
<p><br></p>
<dl>
<dd><em>e.g. 假设 Windows 分割区 (NTFS) 位置是 /dev/hda1</em>
<dd><em>本地挂载资料夹: /media/windows</em> </dd></dl>
<ul>
    <li>挂载 Windows 分割区 </li>
</ul>
<pre class=_fck_mw_lspace>sudo mkdir /media/windows
sudo mount /dev/hda1 /media/windows/ -t ntfs -o nls=utf8,umask=0222
</pre>
<ul>
    <li>卸载 Windows 分割区 </li>
</ul>
<pre class=_fck_mw_lspace>sudo umount /media/windows/
</pre>
<a name=.E5.A6.82.E4.BD.95.E6.89.8B.E5.8B.95_.E6.8E.9B.E8.BC.89.2F.E5.8D.B8.E8.BC.89_Windows_.E5.88.86.E5.89.B2.E5.8D.80_.28FAT.29_.2C_.E4.B8.A6.E4.B8.94.E5.85.81.E8.A8.B1.E6.89.80.E6.9C.89.E4.BD.BF.E7.94.A8.E8.80.85.E8.83.BD.E8.AE.80.E5.8F.96.E4.BB.A5.E5.8F.8A.E5.AF.AB.E5.85.A5.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何手動 掛載/卸載 Windows 分割區 (FAT) , 並且允許所有使用者能讀取以及寫入?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=152"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何手动 挂载/卸载 Windows 分割区 (FAT) , 并且允许所有使用者能读取以及写入? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E5.88.97.E5.87.BA.E7.A1.AC.E7.A2.9F.E5.88.86.E5.89.B2.E8.A1.A8.3F"><u><font color=#800080>#如何列出硬盘分割表?</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设 Windows 分割区 (FAT) 位置为 /dev/hda1 </em>
<dd><em>本地挂载资料夹: /media/windows</em> </dd></dl>
<ul>
    <li>挂载 Windows 分割区 </li>
</ul>
<pre class=_fck_mw_lspace>sudo mkdir /media/windows
sudo mount /dev/hda1 /media/windows/ -t vfat -o iocharset=utf8,umask=000
</pre>
<ul>
    <li>卸载 Windows 分割区 </li>
</ul>
<pre class=_fck_mw_lspace>sudo umount /media/windows/
</pre>
<a name=.E5.A6.82.E4.BD.95.E9.96.8B.E6.A9.9F.E6.99.82.E6.8E.9B.E8.BC.89_Windows_.E5.88.86.E5.89.B2.E5.8D.80_.28NTFS.29_.2C_.E4.B8.A6.E4.B8.94.E5.85.81.E8.A8.B1.E6.89.80.E6.9C.89.E4.BD.BF.E7.94.A8.E8.80.85.E8.AE.80.E5.8F.96.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何開機時掛載 Windows 分割區 (NTFS) , 並且允許所有使用者讀取?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=153"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何开机时挂载 Windows 分割区 (NTFS) , 并且允许所有使用者读取? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E5.88.97.E5.87.BA.E7.A1.AC.E7.A2.9F.E5.88.86.E5.89.B2.E8.A1.A8.3F"><u><font color=#800080>#如何列出硬盘分割表?</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假设 Windows 分割区 (NTFS) 位置为 /dev/hda1 </em>
<dd><em>本地挂载资料夹: /media/windows</em> </dd></dl>
<pre class=_fck_mw_lspace>sudo mkdir /media/windows
sudo cp /etc/fstab /etc/fstab_backup
sudo gedit /etc/fstab
</pre>
<ul>
    <li>在档案后面加入下面这几行 </li>
</ul>
<pre class=_fck_mw_lspace>/dev/hda1    /media/windows ntfs  nls=utf8,umask=0222 0    0
</pre>
<ul>
    <li>储存编辑过的档案
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E4.B8.8D.E7.94.A8.E9.87.8D.E9.96.8B.E6.A9.9F.E4.B8.8B.E6.8E.9B.E8.BC.89_.2Fetc.2Ffstab_.3F"><u><font color=#800080>#如何不用重开机下挂载 /etc/fstab ?</font></u></a> </li>
</ul>
<a name=.E5.A6.82.E4.BD.95.E9.96.8B.E6.A9.9F.E6.99.82.E6.8E.9B.E8.BC.89_Windows_.E5.88.86.E5.89.B2.E5.8D.80_.28FAT.29.2C_.E4.B8.A6.E4.B8.94.E5.85.81.E8.A8.B1.E6.89.80.E6.9C.89.E4.BD.BF.E7.94.A8.E8.80.85.E8.AE.80.E5.8F.96.2F.E5.AF.AB.E5.85.A5.3F></a>
<h4><span class=editsection>[<a title="编辑段落: 如何開機時掛載 Windows 分割區 (FAT), 並且允許所有使用者讀取/寫入?" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;action=edit&amp;section=154"><u><font color=#0000ff>编辑</font></u></a>]</span> <span class=mw-headline>如何开机时挂载 Windows 分割区 (FAT), 并且允许所有使用者读取/写入? </span></h4>
<ul>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.9F.BA.E6.9C.AC.E5.82.99.E8.A8.BB"><u><font color=#800080>#基本备注</font></u></a>
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E5.88.97.E5.87.BA.E7.A1.AC.E7.A2.9F.E5.88.86.E5.89.B2.E8.A1.A8.3F"><u><font color=#800080>#如何列出硬盘分割表?</font></u></a> </li>
</ul>
<dl>
<dd><em>e.g. 假定 Windows 分割区 (FAT) 位置为 /dev/hda1 </em>
<dd><em>本地挂载资料夹: /media/windows</em> </dd></dl>
<pre class=_fck_mw_lspace>sudo mkdir /media/windows
sudo cp /etc/fstab /etc/fstab_backup
sudo gedit /etc/fstab
</pre>
<ul>
    <li>在档案后面加入下面这几行 </li>
</ul>
<pre class=_fck_mw_lspace>/dev/hda1    /media/windows vfat  iocharset=utf8,umask=000  0    0
</pre>
<ul>
    <li>储存编辑过的档案
    <li>请参阅 <a title="" href="http://wiki.ubuntu.org.cn/index.php?title=Ubuntu_breezy/zh&amp;variant=zh-cn#.E5.A6.82.E4.BD.95.E4.B8.8D.E7.94.A8.E9.87.8D.E9.96.8B.E6.A9.9F.E4.B8.8B.E6.8E.9B.E8.BC.89_.2Fetc.2Ffstab_.3F"><u><font color=#800080>#如何不用重开机下挂载 /etc/fstab ?</font></u></a> </li>
</ul>
<img src ="http://www.cppblog.com/liu1061/aggbug/52174.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-04 16:44 <a href="http://www.cppblog.com/liu1061/articles/52174.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用GDB调试程序</title><link>http://www.cppblog.com/liu1061/articles/51895.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Mon, 02 Jun 2008 09:09:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/51895.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/51895.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/51895.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/51895.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/51895.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 用GDB调试程序转说明：从CSDN的网站上找到的GDB使用说明。原文标题：用GDB调试程序作者：haoel关键字：gdb 调试 c c++ gun网址链接：出处这篇文章非常好，所以转载了下来，作为收藏。用GDB调试程序GDB概述————GDB是GNU开源组织发布的一个强大的UNIX下的程序调试工具。或许，各位比较喜欢那种图形界面方式的，像VC、BCB等IDE的调...&nbsp;&nbsp;<a href='http://www.cppblog.com/liu1061/articles/51895.html'>阅读全文</a><img src ="http://www.cppblog.com/liu1061/aggbug/51895.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-02 17:09 <a href="http://www.cppblog.com/liu1061/articles/51895.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gcc和g++的区别</title><link>http://www.cppblog.com/liu1061/articles/51872.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Mon, 02 Jun 2008 04:37:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/51872.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/51872.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/51872.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/51872.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/51872.html</trackback:ping><description><![CDATA[<div class=tit>转</div>
<div class=date>2008-03-18 00:32</div>
<table style="TABLE-LAYOUT: fixed">
    <tbody>
        <tr>
            <td>
            <div class=cnt id=blog_text>
            <div class="sysBr500 title">http://www.yuanma.org/data/2007/0406/article_2498.htm<br>gcc和g++的区别</div>
            <table cellSpacing=0 cellPadding=0 align=center border=0>
                <tbody>
                    <tr>
                        <td class=author></td>
                    </tr>
                </tbody>
            </table>
            <div class="sysBr500 text" align=left>
            <div>我们在编译c/c++代码的时候，有人用gcc，有人用g++，于是各种说法都来了，譬如c代码用gcc，而c++代码用g++，或者说编译用 gcc，链接用g++，一时也不知哪个说法正确，如果再遇上个extern "C"，分歧就更多了，这里我想作个了结，毕竟知识的目的是令人更清醒，而不是更糊涂。
            <div></div>
            <div><strong>误区一:gcc只能编译c代码,g++只能编译c++代码</strong></div>
            <div><br>两者都可以，但是请注意：</div>
            <div>1.后缀为.c的，gcc把它当作是C程序，而g++当作是c++程序；后缀为.cpp的，两者都会认为是c++程序，注意，虽然c++是c的超集，但是两者对语法的要求是有区别的，例如：</div>
            <div>#include &lt;stdio.h&gt;</div>
            <div>int main(int argc, char* argv[]) {<br>&nbsp;&nbsp; if(argv == 0) return;</div>
            <div>&nbsp;&nbsp; printString(<font color=#ff0000>argv</font>);</div>
            <div>&nbsp;&nbsp; <font color=#ff0000>return</font>;<br>}<br><font color=#ff0000>int printString(char* string) {<br>sprintf(string, "This is a test.\n");<br>}</font></div>
            <div>如果按照C的语法规则，OK，没问题，但是，一旦把后缀改为cpp，立刻报三个错：&#8220;printString未定义&#8221;；</div>
            <div>&#8220;cannot convert `char**' to `char*&#8221;；</div>
            <div>&#8221;return-statement with no value&#8220;；</div>
            <div>分别对应前面红色标注的部分。可见C++的语法规则更加严谨一些。</div>
            <div>2.编译阶段，g++会调用gcc，对于c++代码，两者是等价的，但是因为gcc命令不能自动和C＋＋程序使用的库联接，所以通常用g++来完成链接，为了统一起见，干脆编译/链接统统用g++了，这就给人一种错觉，好像cpp程序只能用g++似的。</div>
            <div></div>
            <div><strong>误区二:gcc不会定义__cplusplus宏，而g++会</strong></div>
            <div><br>实际上，这个宏只是标志着编译器将会把代码按C还是C++语法来解释，如上所述，如果后缀为.c，并且采用gcc编译器，则该宏就是未定义的，否则，就是已定义。</div>
            <div></div>
            <div><strong>误区三:编译只能用gcc，链接只能用g++</strong></div>
            <div><strong><br></strong>严格来说，这句话不算错误，但是它混淆了概念，<font color=#ff0000>应该这样说：编译可以用gcc/g++，而链接可以用g++或者gcc -lstdc++</font>。因为gcc命令不能自动和C＋＋程序使用的库联接，所以通常使用g++来完成联接。但在编译阶段，g++会自动调用gcc，二者等价。</div>
            <div></div>
            <div><strong>误区四:extern "C"与gcc/g++有关系</strong></div>
            <div><br>实际上并无关系，无论是gcc还是g++，用extern "c"时，都是以C的命名方式来为symbol命名，否则，都以c++方式命名。试验如下：<br><em>me.h</em>：<br><font color=#ff0000>extern "C" void CppPrintf(void);</font></div>
            <div></div>
            <div><em>me.cpp</em>:<br>#include &lt;iostream&gt;<br>#include "me.h"<br>using namespace std;<br>void CppPrintf(void)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp; cout &lt;&lt; "Hello\n";<br>}</div>
            <div></div>
            <div><em>test.cpp:</em><br>#include &lt;stdlib.h&gt;<br>#include &lt;stdio.h&gt;<br>#include "me.h"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>int main(void)<br>{<br>&nbsp;&nbsp;&nbsp; CppPrintf();<br>&nbsp;&nbsp;&nbsp; return 0;<br>}</div>
            <div></div>
            <div><strong>1. 先给me.h加上extern "C"，看用gcc和g++命名有什么不同</strong></div>
            <div><br>[root@root G++]# g++ -S me.cpp<br>[root@root G++]# less me.s<br>.globl _Z9CppPrintfv&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //注意此函数的命名<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .type&nbsp;&nbsp; CppPrintf, @function</div>
            <div>[root@root GCC]# gcc -S me.cpp<br>[root@root GCC]# less me.s<br>.globl _Z9CppPrintfv&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //注意此函数的命名<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .type&nbsp;&nbsp; CppPrintf, @function<br>完全相同！<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><strong>2. 去掉me.h中extern "C"，看用gcc和g++命名有什么不同</strong></div>
            <div><strong><br></strong>[root@root GCC]# gcc -S me.cpp<br>[root@root GCC]# less me.s<br>.globl _Z9CppPrintfv&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //注意此函数的命名<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .type&nbsp;&nbsp; _Z9CppPrintfv, @function</div>
            <div>[root@root G++]# g++ -S me.cpp<br>[root@root G++]# less me.s<br>.globl _Z9CppPrintfv&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //注意此函数的命名<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .type&nbsp;&nbsp; _Z9CppPrintfv, @function<br>完全相同！</div>
            <div><strong>【结论】</strong>完全相同，可见extern "C"与采用gcc/g++并无关系，以上的试验还间接的印证了前面的说法：在编译阶段，g++是调用gcc的。</div>
            </div>
            </div>
            </div>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.cppblog.com/liu1061/aggbug/51872.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-02 12:37 <a href="http://www.cppblog.com/liu1061/articles/51872.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>gcc/g++ 常用选项</title><link>http://www.cppblog.com/liu1061/articles/51870.html</link><dc:creator>T.S Liu</dc:creator><author>T.S Liu</author><pubDate>Mon, 02 Jun 2008 04:32:00 GMT</pubDate><guid>http://www.cppblog.com/liu1061/articles/51870.html</guid><wfw:comment>http://www.cppblog.com/liu1061/comments/51870.html</wfw:comment><comments>http://www.cppblog.com/liu1061/articles/51870.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/liu1061/comments/commentRss/51870.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/liu1061/services/trackbacks/51870.html</trackback:ping><description><![CDATA[<div class=tit>转</div>
<table style="TABLE-LAYOUT: fixed">
    <tbody>
        <tr>
            <td>
            <div class=cnt id=blog_text>http://blog.csdn.net/blade2001/archive/2007/06/10/1646530.aspx<br><br>gcc and g++分别是gnu的c &amp; c++编译器 gcc/g++在执行编译工作的时候，总共需要4步 <br><br>1.预处理,生成.i的文件[预处理器cpp] <br>2.将预处理后的文件不转换成汇编语言,生成文件.s[编译器egcs] <br>3.有汇编变为目标代码(机器代码)生成.o的文件[汇编器as] <br>4.连接目标代码,生成可执行程序[链接器ld] <br>[参数详解] <br>-x language filename <br>设定文件所使用的语言,使后缀名无效,对以后的多个有效.也就是根据约定C语言的后 <br>缀名称是.c的，而C++的后缀名是.C或者.cpp,如果你很个性，决定你的C代码文件的后缀 <br>名是.pig 哈哈，那你就要用这个参数,这个参数对他后面的文件名都起作用，除非到了 <br>下一个参数的使用。 <br>可以使用的参数吗有下面的这些 <br>`c', `objective-c', `c-header', `c++', `cpp-output', `assembler', and `a <br>ssembler-with-cpp'. <br>看到英文，应该可以理解的。 <br>例子用法: <br>gcc -x c hello.pig <br><br>-x none filename <br>关掉上一个选项，也就是让gcc根据文件名后缀，自动识别文件类型 <br>例子用法: <br>gcc -x c hello.pig -x none hello2.c <br><br>-c <br>只激活预处理,编译,和汇编,也就是他只把程序做成obj文件 <br>例子用法: <br>gcc -c hello.c <br>他将生成.o的obj文件 <br>-S <br>只激活预处理和编译，就是指把文件编译成为汇编代码。 <br>例子用法 <br>gcc -S hello.c <br>他将生成.s的汇编代码，你可以用文本编辑器察看 <br>-E <br>只激活预处理,这个不生成文件,你需要把它重定向到一个输出文件里面. <br>例子用法: <br>gcc -E hello.c &gt; pianoapan.txt <br>gcc -E hello.c | more <br>慢慢看吧,一个hello word 也要与处理成800行的代码 <br>-o <br>制定目标名称,缺省的时候,gcc 编译出来的文件是a.out,很难听,如果你和我有同感 <br>，改掉它,哈哈 <br>例子用法 <br>gcc -o hello.exe hello.c (哦,windows用习惯了) <br>gcc -o hello.asm -S hello.c <br>-pipe <br>使用管道代替编译中临时文件,在使用非gnu汇编工具的时候,可能有些问题 <br>gcc -pipe -o hello.exe hello.c <br>-ansi <br>关闭gnu c中与ansi c不兼容的特性,激活ansi c的专有特性(包括禁止一些asm inl <br>ine typeof关键字,以及UNIX,vax等预处理宏, <br>-fno-asm <br>此选项实现ansi选项的功能的一部分，它禁止将asm,inline和typeof用作关键字。 <br><br>-fno-strict-prototype <br>只对g++起作用,使用这个选项,g++将对不带参数的函数,都认为是没有显式的对参数 <br>的个数和类型说明,而不是没有参数. <br>而gcc无论是否使用这个参数,都将对没有带参数的函数,认为城没有显式说明的类型 <br><br><br>-fthis-is-varialble <br>就是向传统c++看齐,可以使用this当一般变量使用. <br><br>-fcond-mismatch <br>允许条件表达式的第二和第三参数类型不匹配,表达式的值将为void类型 <br><br>-funsigned-char <br>-fno-signed-char <br>-fsigned-char <br>-fno-unsigned-char <br>这四个参数是对char类型进行设置,决定将char类型设置成unsigned char(前两个参 <br>数)或者 signed char(后两个参数) <br><br>-include file <br>包含某个代码,简单来说,就是便以某个文件,需要另一个文件的时候,就可以用它设 <br>定,功能就相当于在代码中使用＃i nclude&lt;filename&gt; <br>例子用法: <br>gcc hello.c -include /root/pianopan.h <br><br>-imacros file <br>将file文件的宏,扩展到gcc/g++的输入文件,宏定义本身并不出现在输入文件中 <br><br>-Dmacro <br>相当于C语言中的#define macro <br><br>-Dmacro=defn <br>相当于C语言中的#define macro=defn <br><br>-Umacro <br>相当于C语言中的#undef macro <br>-undef <br>取消对任何非标准宏的定义 <br><br>-Idir <br>在你是用＃i nclude"file"的时候,gcc/g++会先在当前目录查找你所制定的头文件,如 <br>果没有找到,他回到缺省的头文件目录找,如果使用-I制定了目录,他 <br>回先在你所制定的目录查找,然后再按常规的顺序去找. <br>对于＃i nclude&lt;file&gt;,gcc/g++会到-I制定的目录查找,查找不到,然后将到系统的缺 <br>省的头文件目录查找 <br><br>-I- <br>就是取消前一个参数的功能,所以一般在-Idir之后使用 <br><br>-idirafter dir <br>在-I的目录里面查找失败,讲到这个目录里面查找. <br><br>-iprefix prefix <br>-iwithprefix dir <br>一般一起使用,当-I的目录查找失败,会到prefix+dir下查找 <br><br>-nostdinc <br>使编译器不再系统缺省的头文件目录里面找头文件,一般和-I联合使用,明确限定头 <br>文件的位置 <br><br>-nostdin C++ <br>规定不在g++指定的标准路经中搜索,但仍在其他路径中搜索,.此选项在创libg++库 <br>使用 <br><br>-C <br>在预处理的时候,不删除注释信息,一般和-E使用,有时候分析程序，用这个很方便的 <br><br><br>-M <br>生成文件关联的信息。包含目标文件所依赖的所有源代码你可以用gcc -M hello.c <br>来测试一下，很简单。 <br><br>-MM <br>和上面的那个一样，但是它将忽略由＃i nclude&lt;file&gt;造成的依赖关系。 <br><br>-MD <br>和-M相同，但是输出将导入到.d的文件里面 <br><br>-MMD <br>和-MM相同，但是输出将导入到.d的文件里面 <br><br>-Wa,option <br>此选项传递option给汇编程序;如果option中间有逗号,就将option分成多个选项,然 <br>后传递给会汇编程序 <br><br>-Wl.option <br>此选项传递option给连接程序;如果option中间有逗号,就将option分成多个选项,然 <br>后传递给会连接程序. <br><br>-llibrary <br>制定编译的时候使用的库 <br>例子用法 <br>gcc -lcurses hello.c <br>使用ncurses库编译程序 <br><br>-Ldir <br>制定编译的时候，搜索库的路径。比如你自己的库，可以用它制定目录，不然 <br>编译器将只在标准库的目录找。这个dir就是目录的名称。 <br><br>-O0 <br>-O1 <br>-O2 <br>-O3 <br>编译器的优化选项的4个级别，-O0表示没有优化,-O1为缺省值，-O3优化级别最高　 <br>　　 <br>-g <br>只是编译器，在编译的时候，产生调试信息。 <br><br>-gstabs <br>此选项以stabs格式声称调试信息,但是不包括gdb调试信息. <br><br>-gstabs+ <br>此选项以stabs格式声称调试信息,并且包含仅供gdb使用的额外调试信息. <br><br>-ggdb <br>此选项将尽可能的生成gdb的可以使用的调试信息. <br>-static <br>此选项将禁止使用动态库，所以，编译出来的东西，一般都很大，也不需要什么 <br>动态连接库，就可以运行. <br>-share <br>此选项将尽量使用动态库，所以生成文件比较小，但是需要系统由动态库. <br>-traditional <br>试图让编译器支持传统的C语言特性 <br></div>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.cppblog.com/liu1061/aggbug/51870.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/liu1061/" target="_blank">T.S Liu</a> 2008-06-02 12:32 <a href="http://www.cppblog.com/liu1061/articles/51870.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>